#include <metal_stdlib>

using namespace metal;
void textureStore_6d1809(texture2d_array<float, access::read_write> tint_symbol_1) {
  uint2 arg_1 = uint2(1u);
  uint arg_2 = 1u;
  float4 arg_3 = float4(1.0f);
  tint_symbol_1.write(arg_3, uint2(arg_1), arg_2); tint_symbol_1.fence();
}

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

float4 vertex_main_inner(texture2d_array<float, access::read_write> tint_symbol_2) {
  textureStore_6d1809(tint_symbol_2);
  return float4(0.0f);
}

vertex tint_symbol vertex_main(texture2d_array<float, access::read_write> tint_symbol_3 [[texture(0)]]) {
  float4 const inner_result = vertex_main_inner(tint_symbol_3);
  tint_symbol wrapper_result = {};
  wrapper_result.value = inner_result;
  return wrapper_result;
}

fragment void fragment_main(texture2d_array<float, access::read_write> tint_symbol_4 [[texture(0)]]) {
  textureStore_6d1809(tint_symbol_4);
  return;
}

kernel void compute_main(texture2d_array<float, access::read_write> tint_symbol_5 [[texture(0)]]) {
  textureStore_6d1809(tint_symbol_5);
  return;
}

