#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 let_decls() {
  int const v1 = 1;
  uint const v2 = 1u;
  float const v3 = 1.0f;
  int3 const v4 = int3(1);
  uint3 const v5 = uint3(1u);
  float3 const v6 = float3(1.0f);
  float3x3 const v7 = float3x3(v6, v6, v6);
  MyStruct const v8 = MyStruct{.f1=1.0f};
  tint_array<float, 10> const v9 = tint_array<float, 10>{};
  int const v10 = ret_i32();
  uint const v11 = ret_u32();
  float const v12 = ret_f32();
  MyStruct const v13 = ret_MyStruct();
  MyStruct const v14 = ret_MyStruct();
  tint_array<float, 10> const 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()};
}
