#include <metal_stdlib>
using namespace metal;

struct VertexInputs0 {
  uint vertex_index;
  int loc0;
};

struct VertexInputs1 {
  uint loc1;
  float4 loc3;
};

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

struct tint_symbol_inputs {
  int VertexInputs0_loc0 [[attribute(0)]];
  uint loc1 [[attribute(1)]];
  uint VertexInputs1_loc1 [[attribute(2)]];
  float4 VertexInputs1_loc3 [[attribute(3)]];
};

float4 tint_symbol_inner(VertexInputs0 inputs0, uint loc1, uint instance_index, VertexInputs1 inputs1) {
  uint const foo = (inputs0.vertex_index + instance_index);
  return float4(0.0f);
}

vertex tint_symbol_outputs tint_symbol(uint VertexInputs0_vertex_index [[vertex_id]], tint_symbol_inputs inputs [[stage_in]], uint instance_index [[instance_id]]) {
  VertexInputs0 const v = VertexInputs0{.vertex_index=VertexInputs0_vertex_index, .loc0=inputs.VertexInputs0_loc0};
  return tint_symbol_outputs{.tint_symbol_1=tint_symbol_inner(v, inputs.loc1, instance_index, VertexInputs1{.loc1=inputs.VertexInputs1_loc1, .loc3=inputs.VertexInputs1_loc3})};
}
