#include <metal_stdlib>

using namespace metal;
void textureStore_6fd2b1(texture1d<float, access::write> tint_symbol_1) {
  uint arg_1 = 1u;
  float4 arg_2 = float4(1.0f);
  tint_symbol_1.write(arg_2, uint(arg_1));
}

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

float4 vertex_main_inner(texture1d<float, access::write> tint_symbol_2) {
  textureStore_6fd2b1(tint_symbol_2);
  return float4(0.0f);
}

vertex tint_symbol vertex_main(texture1d<float, access::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(texture1d<float, access::write> tint_symbol_4 [[texture(0)]]) {
  textureStore_6fd2b1(tint_symbol_4);
  return;
}

kernel void compute_main(texture1d<float, access::write> tint_symbol_5 [[texture(0)]]) {
  textureStore_6fd2b1(tint_symbol_5);
  return;
}

