#include <metal_stdlib>

using namespace metal;
void reflect_bb15ac(device half2* const tint_symbol_1) {
  half2 res = half2(-3.0h);
  *(tint_symbol_1) = res;
}

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

float4 vertex_main_inner(device half2* const tint_symbol_2) {
  reflect_bb15ac(tint_symbol_2);
  return float4(0.0f);
}

vertex tint_symbol vertex_main(device half2* tint_symbol_3 [[buffer(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(device half2* tint_symbol_4 [[buffer(0)]]) {
  reflect_bb15ac(tint_symbol_4);
  return;
}

kernel void compute_main(device half2* tint_symbol_5 [[buffer(0)]]) {
  reflect_bb15ac(tint_symbol_5);
  return;
}

