#include <metal_stdlib>

using namespace metal;
void textureLoad_5d4042(texture2d_array<float, access::read> tint_symbol_1, device float4* const tint_symbol_2) {
  uint2 arg_1 = uint2(1u);
  int arg_2 = 1;
  float4 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<float, access::read> tint_symbol_3, device float4* const tint_symbol_4) {
  textureLoad_5d4042(tint_symbol_3, tint_symbol_4);
  return float4(0.0f);
}

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

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

