#include <metal_stdlib>

using namespace metal;
void textureLoad_22e963(texture2d_array<uint, access::read> tint_symbol_1, device uint4* const tint_symbol_2) {
  uint2 arg_1 = uint2(1u);
  uint arg_2 = 1u;
  uint4 res = tint_symbol_1.read(uint2(arg_1), arg_2);
  *(tint_symbol_2) = res;
}

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

float4 vertex_main_inner(texture2d_array<uint, access::read> tint_symbol_3, device uint4* const tint_symbol_4) {
  textureLoad_22e963(tint_symbol_3, tint_symbol_4);
  return float4(0.0f);
}

vertex tint_symbol vertex_main(texture2d_array<uint, access::read> tint_symbol_5 [[texture(0)]], device uint4* 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(texture2d_array<uint, access::read> tint_symbol_7 [[texture(0)]], device uint4* tint_symbol_8 [[buffer(0)]]) {
  textureLoad_22e963(tint_symbol_7, tint_symbol_8);
  return;
}

kernel void compute_main(texture2d_array<uint, access::read> tint_symbol_9 [[texture(0)]], device uint4* tint_symbol_10 [[buffer(0)]]) {
  textureLoad_22e963(tint_symbol_9, tint_symbol_10);
  return;
}

