#include <metal_stdlib>

using namespace metal;
void textureLoad_3c9587(texture2d<float, access::read> tint_symbol_1, device float4* const tint_symbol_2) {
  int2 arg_1 = int2(1);
  float4 res = tint_symbol_1.read(uint2(arg_1));
  *(tint_symbol_2) = res;
}

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

float4 vertex_main_inner(texture2d<float, access::read> tint_symbol_3, device float4* const tint_symbol_4) {
  textureLoad_3c9587(tint_symbol_3, tint_symbol_4);
  return float4(0.0f);
}

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

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

