#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 Inner {
  int scalar_i32;
  float scalar_f32;
};
struct S {
  float scalar_f32;
  int scalar_i32;
  uint scalar_u32;
  float2 vec2_f32;
  int2 vec2_i32;
  uint2 vec2_u32;
  float3 vec3_f32;
  int3 vec3_i32;
  uint3 vec3_u32;
  float4 vec4_f32;
  int4 vec4_i32;
  uint4 vec4_u32;
  float2x2 mat2x2_f32;
  float2x3 mat2x3_f32;
  float2x4 mat2x4_f32;
  float3x2 mat3x2_f32;
  float3x3 mat3x3_f32;
  float3x4 mat3x4_f32;
  float4x2 mat4x2_f32;
  float4x3 mat4x3_f32;
  float4x4 mat4x4_f32;
  tint_array<float3, 2> arr2_vec3_f32;
  Inner struct_inner;
  tint_array<Inner, 4> array_struct_inner;
};
struct tint_module_vars_struct {
  device S* sb;
};

void tint_store_and_preserve_padding(device tint_array<float3, 2>* const target, tint_array<float3, 2> value_param) {
  {
    uint v = 0u;
    v = 0u;
    while(true) {
      uint const v_1 = v;
      if ((v_1 >= 2u)) {
        break;
      }
      (*target)[v_1] = value_param[v_1];
      v = (v_1 + 1u);
      continue;
    }
  }
}
void tint_store_and_preserve_padding(device float4x3* const target, float4x3 value_param) {
  (*target)[0u] = value_param[0u];
  (*target)[1u] = value_param[1u];
  (*target)[2u] = value_param[2u];
  (*target)[3u] = value_param[3u];
}
void tint_store_and_preserve_padding(device float3x3* const target, float3x3 value_param) {
  (*target)[0u] = value_param[0u];
  (*target)[1u] = value_param[1u];
  (*target)[2u] = value_param[2u];
}
void tint_store_and_preserve_padding(device float2x3* const target, float2x3 value_param) {
  (*target)[0u] = value_param[0u];
  (*target)[1u] = value_param[1u];
}
kernel void tint_symbol(device S* sb [[buffer(0)]]) {
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.sb=sb};
  (*tint_module_vars.sb).scalar_f32 = 0.0f;
  (*tint_module_vars.sb).scalar_i32 = 0;
  (*tint_module_vars.sb).scalar_u32 = 0u;
  (*tint_module_vars.sb).vec2_f32 = float2(0.0f);
  (*tint_module_vars.sb).vec2_i32 = int2(0);
  (*tint_module_vars.sb).vec2_u32 = uint2(0u);
  (*tint_module_vars.sb).vec3_f32 = float3(0.0f);
  (*tint_module_vars.sb).vec3_i32 = int3(0);
  (*tint_module_vars.sb).vec3_u32 = uint3(0u);
  (*tint_module_vars.sb).vec4_f32 = float4(0.0f);
  (*tint_module_vars.sb).vec4_i32 = int4(0);
  (*tint_module_vars.sb).vec4_u32 = uint4(0u);
  (*tint_module_vars.sb).mat2x2_f32 = float2x2(float2(0.0f), float2(0.0f));
  tint_store_and_preserve_padding((&(*tint_module_vars.sb).mat2x3_f32), float2x3(float3(0.0f), float3(0.0f)));
  (*tint_module_vars.sb).mat2x4_f32 = float2x4(float4(0.0f), float4(0.0f));
  (*tint_module_vars.sb).mat3x2_f32 = float3x2(float2(0.0f), float2(0.0f), float2(0.0f));
  tint_store_and_preserve_padding((&(*tint_module_vars.sb).mat3x3_f32), float3x3(float3(0.0f), float3(0.0f), float3(0.0f)));
  (*tint_module_vars.sb).mat3x4_f32 = float3x4(float4(0.0f), float4(0.0f), float4(0.0f));
  (*tint_module_vars.sb).mat4x2_f32 = float4x2(float2(0.0f), float2(0.0f), float2(0.0f), float2(0.0f));
  tint_store_and_preserve_padding((&(*tint_module_vars.sb).mat4x3_f32), float4x3(float3(0.0f), float3(0.0f), float3(0.0f), float3(0.0f)));
  (*tint_module_vars.sb).mat4x4_f32 = float4x4(float4(0.0f), float4(0.0f), float4(0.0f), float4(0.0f));
  tint_store_and_preserve_padding((&(*tint_module_vars.sb).arr2_vec3_f32), tint_array<float3, 2>{});
  (*tint_module_vars.sb).struct_inner = Inner{};
  (*tint_module_vars.sb).array_struct_inner = tint_array<Inner, 4>{};
}
