#include <metal_stdlib>

using namespace metal;
void bitcast_a8ea1b(device packed_int3* const tint_symbol_1) {
  int3 res = int3(1);
  *(tint_symbol_1) = packed_int3(res);
}

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

float4 vertex_main_inner(device packed_int3* const tint_symbol_2) {
  bitcast_a8ea1b(tint_symbol_2);
  return float4(0.0f);
}

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

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

