#include <metal_stdlib>

using namespace metal;
void step_334303(device packed_float3* const tint_symbol_1) {
  float3 res = float3(1.0f);
  *(tint_symbol_1) = packed_float3(res);
}

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

float4 vertex_main_inner(device packed_float3* const tint_symbol_2) {
  step_334303(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)]]) {
  step_334303(tint_symbol_4);
  return;
}

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

