#include <metal_stdlib>

using namespace metal;
uint4 textureLoad_a2b3f4(texture2d_array<uint, access::read_write> tint_symbol) {
  uint2 arg_1 = uint2(1u);
  uint arg_2 = 1u;
  uint4 res = tint_symbol.read(uint2(arg_1), arg_2);
  return res;
}

fragment void fragment_main(device uint4* tint_symbol_1 [[buffer(0)]], texture2d_array<uint, access::read_write> tint_symbol_2 [[texture(0)]]) {
  *(tint_symbol_1) = textureLoad_a2b3f4(tint_symbol_2);
  return;
}

kernel void compute_main(device uint4* tint_symbol_3 [[buffer(0)]], texture2d_array<uint, access::read_write> tint_symbol_4 [[texture(0)]]) {
  *(tint_symbol_3) = textureLoad_a2b3f4(tint_symbol_4);
  return;
}

