#include <metal_stdlib>
using namespace metal;

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)]];
};

float4 tint_symbol_inner() {
  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(float3(1.0f), float3(1.0f), float3(1.0f));
  tint_array<float, 10> v9 = tint_array<float, 10>{};
  return float4(0.0f);
}

fragment tint_symbol_outputs tint_symbol() {
  tint_symbol_outputs tint_wrapper_result = {};
  tint_wrapper_result.tint_symbol_1 = tint_symbol_inner();
  return tint_wrapper_result;
}
