#include <metal_stdlib>

using namespace metal;
void refract_570cb3(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) {
  refract_570cb3(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)]]) {
  refract_570cb3(tint_symbol_4);
  return;
}

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

