#include <metal_stdlib>

using namespace metal;
void textureLoad_4c423f(texture1d<int, access::sample> tint_symbol_1, device int4* const tint_symbol_2) {
  int4 res = tint_symbol_1.read(uint(1u), 0);
  *(tint_symbol_2) = res;
}

struct tint_symbol {
  float4 value [[position]];
};

float4 vertex_main_inner(texture1d<int, access::sample> tint_symbol_3, device int4* const tint_symbol_4) {
  textureLoad_4c423f(tint_symbol_3, tint_symbol_4);
  return float4(0.0f);
}

vertex tint_symbol vertex_main(texture1d<int, access::sample> tint_symbol_5 [[texture(0)]], device int4* tint_symbol_6 [[buffer(0)]]) {
  float4 const inner_result = vertex_main_inner(tint_symbol_5, tint_symbol_6);
  tint_symbol wrapper_result = {};
  wrapper_result.value = inner_result;
  return wrapper_result;
}

fragment void fragment_main(texture1d<int, access::sample> tint_symbol_7 [[texture(0)]], device int4* tint_symbol_8 [[buffer(0)]]) {
  textureLoad_4c423f(tint_symbol_7, tint_symbol_8);
  return;
}

kernel void compute_main(texture1d<int, access::sample> tint_symbol_9 [[texture(0)]], device int4* tint_symbol_10 [[buffer(0)]]) {
  textureLoad_4c423f(tint_symbol_9, tint_symbol_10);
  return;
}

