#include <metal_stdlib>

using namespace metal;
void bitcast_0fe0c9(device packed_float3* const tint_symbol_1) {
  uint3 arg_0 = uint3(1u);
  float3 res = as_type<float3>(arg_0);
  *(tint_symbol_1) = packed_float3(res);
}

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

float4 vertex_main_inner(device packed_float3* const tint_symbol_2) {
  bitcast_0fe0c9(tint_symbol_2);
  return float4(0.0f);
}

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

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

