#include <metal_stdlib>

using namespace metal;
void bitcast_2b05b3(device packed_float3* const tint_symbol_1) {
  float3 arg_0 = float3(1.0f);
  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_2b05b3(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_2b05b3(tint_symbol_4);
  return;
}

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

