#include <metal_stdlib>

using namespace metal;
uint textureDimensions_709357(texture1d<uint, access::read> tint_symbol_1) {
  uint res = tint_symbol_1.get_width(0);
  return res;
}

fragment void fragment_main(device uint* tint_symbol_2 [[buffer(0)]], texture1d<uint, access::read> tint_symbol_3 [[texture(0)]]) {
  *(tint_symbol_2) = textureDimensions_709357(tint_symbol_3);
  return;
}

kernel void compute_main(device uint* tint_symbol_4 [[buffer(0)]], texture1d<uint, access::read> tint_symbol_5 [[texture(0)]]) {
  *(tint_symbol_4) = textureDimensions_709357(tint_symbol_5);
  return;
}

struct VertexOutput {
  float4 pos;
  uint prevent_dce;
};

struct tint_symbol {
  uint prevent_dce [[user(locn0)]] [[flat]];
  float4 pos [[position]];
};

VertexOutput vertex_main_inner(texture1d<uint, access::read> tint_symbol_6) {
  VertexOutput out = {};
  out.pos = float4(0.0f);
  out.prevent_dce = textureDimensions_709357(tint_symbol_6);
  return out;
}

vertex tint_symbol vertex_main(texture1d<uint, access::read> tint_symbol_7 [[texture(0)]]) {
  VertexOutput const inner_result = vertex_main_inner(tint_symbol_7);
  tint_symbol wrapper_result = {};
  wrapper_result.pos = inner_result.pos;
  wrapper_result.prevent_dce = inner_result.prevent_dce;
  return wrapper_result;
}

