#include <metal_stdlib>
using namespace metal;

struct tint_module_vars_struct {
  thread float4* gl_Position;
};

struct main_out {
  float4 gl_Position;
};

struct tint_symbol_outputs {
  float4 main_out_gl_Position [[position]];
};

void main_1(tint_module_vars_struct tint_module_vars) {
  (*tint_module_vars.gl_Position) = float4(0.0f);
}

main_out tint_symbol_inner(tint_module_vars_struct tint_module_vars) {
  main_1(tint_module_vars);
  return main_out{.gl_Position=(*tint_module_vars.gl_Position)};
}

vertex tint_symbol_outputs tint_symbol() {
  thread float4 gl_Position = 0.0f;
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.gl_Position=(&gl_Position)};
  tint_symbol_outputs tint_wrapper_result = {};
  tint_wrapper_result.main_out_gl_Position = tint_symbol_inner(tint_module_vars).gl_Position;
  return tint_wrapper_result;
}
