#include <metal_stdlib>
using namespace metal;
struct MyStruct {
  float f1;
};
template<typename T, size_t N>
struct tint_array {
  const constant T& operator[](size_t i) const constant { return elements[i]; }
  device T& operator[](size_t i) device { return elements[i]; }
  const device T& operator[](size_t i) const device { return elements[i]; }
  thread T& operator[](size_t i) thread { return elements[i]; }
  const thread T& operator[](size_t i) const thread { return elements[i]; }
  threadgroup T& operator[](size_t i) threadgroup { return elements[i]; }
  const threadgroup T& operator[](size_t i) const threadgroup { return elements[i]; }
  T elements[N];
};

struct tint_symbol_outputs {
  float4 tint_symbol_1 [[color(0)]];
};

int ret_i32() {
  return 1;
}
uint ret_u32() {
  return 1u;
}
float ret_f32() {
  return 1.0f;
}
MyStruct ret_MyStruct() {
  return MyStruct{};
}
tint_array<float, 10> ret_MyArray() {
  return tint_array<float, 10>{};
}
void var_decls() {
  int v1 = 1;
  uint v2 = 1u;
  float v3 = 1.0f;
  int3 v4 = int3(1);
  uint3 v5 = uint3(1u);
  float3 v6 = float3(1.0f);
  float3x3 v7 = float3x3(v6, v6, v6);
  MyStruct v8 = MyStruct{.f1=1.0f};
  tint_array<float, 10> v9 = tint_array<float, 10>{};
  int v10 = ret_i32();
  uint v11 = ret_u32();
  float v12 = ret_f32();
  MyStruct v13 = ret_MyStruct();
  MyStruct v14 = ret_MyStruct();
  tint_array<float, 10> v15 = ret_MyArray();
}
float4 tint_symbol_inner() {
  return float4(0.0f);
}
fragment tint_symbol_outputs tint_symbol() {
  return tint_symbol_outputs{.tint_symbol_1=tint_symbol_inner()};
}
