#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_packed_vec3_f32_array_element {
  /* 0x0000 */ packed_float3 packed;
  /* 0x000c */ tint_array<int8_t, 4> tint_pad;
};

#define TINT_ISOLATE_UB(VOLATILE_NAME) \
  {volatile bool VOLATILE_NAME = false; if (VOLATILE_NAME) break;}

struct Inner {
  /* 0x0000 */ int scalar_i32;
  /* 0x0004 */ float scalar_f32;
};

struct S_packed_vec3 {
  /* 0x0000 */ float scalar_f32;
  /* 0x0004 */ int scalar_i32;
  /* 0x0008 */ uint scalar_u32;
  /* 0x000c */ tint_array<int8_t, 4> tint_pad_1;
  /* 0x0010 */ float2 vec2_f32;
  /* 0x0018 */ int2 vec2_i32;
  /* 0x0020 */ uint2 vec2_u32;
  /* 0x0028 */ tint_array<int8_t, 8> tint_pad_2;
  /* 0x0030 */ packed_float3 vec3_f32;
  /* 0x003c */ tint_array<int8_t, 4> tint_pad_3;
  /* 0x0040 */ packed_int3 vec3_i32;
  /* 0x004c */ tint_array<int8_t, 4> tint_pad_4;
  /* 0x0050 */ packed_uint3 vec3_u32;
  /* 0x005c */ tint_array<int8_t, 4> tint_pad_5;
  /* 0x0060 */ float4 vec4_f32;
  /* 0x0070 */ int4 vec4_i32;
  /* 0x0080 */ uint4 vec4_u32;
  /* 0x0090 */ float2x2 mat2x2_f32;
  /* 0x00a0 */ tint_array<tint_packed_vec3_f32_array_element, 2> mat2x3_f32;
  /* 0x00c0 */ float2x4 mat2x4_f32;
  /* 0x00e0 */ float3x2 mat3x2_f32;
  /* 0x00f8 */ tint_array<int8_t, 8> tint_pad_6;
  /* 0x0100 */ tint_array<tint_packed_vec3_f32_array_element, 3> mat3x3_f32;
  /* 0x0130 */ float3x4 mat3x4_f32;
  /* 0x0160 */ float4x2 mat4x2_f32;
  /* 0x0180 */ tint_array<tint_packed_vec3_f32_array_element, 4> mat4x3_f32;
  /* 0x01c0 */ float4x4 mat4x4_f32;
  /* 0x0200 */ tint_array<tint_packed_vec3_f32_array_element, 2> arr2_vec3_f32;
  /* 0x0220 */ Inner struct_inner;
  /* 0x0228 */ tint_array<Inner, 4> array_struct_inner;
  /* 0x0248 */ tint_array<int8_t, 8> tint_pad_7;
};

struct tint_module_vars_struct {
  device S_packed_vec3* sb;
};

void tint_store_and_preserve_padding_3(device tint_array<tint_packed_vec3_f32_array_element, 2>* const target, tint_array<float3, 2> value_param) {
  {
    uint v = 0u;
    v = 0u;
    while(true) {
      TINT_ISOLATE_UB(tint_volatile_false)
      uint const v_1 = v;
      if ((v_1 >= 2u)) {
        break;
      }
      (*target)[v_1].packed = packed_float3(value_param[v_1]);
      {
        v = (v_1 + 1u);
      }
      continue;
    }
  }
}

void tint_store_and_preserve_padding_2(device tint_array<tint_packed_vec3_f32_array_element, 4>* const target, float4x3 value_param) {
  (*target)[0u].packed = packed_float3(value_param[0u]);
  (*target)[1u].packed = packed_float3(value_param[1u]);
  (*target)[2u].packed = packed_float3(value_param[2u]);
  (*target)[3u].packed = packed_float3(value_param[3u]);
}

void tint_store_and_preserve_padding_1(device tint_array<tint_packed_vec3_f32_array_element, 3>* const target, float3x3 value_param) {
  (*target)[0u].packed = packed_float3(value_param[0u]);
  (*target)[1u].packed = packed_float3(value_param[1u]);
  (*target)[2u].packed = packed_float3(value_param[2u]);
}

void tint_store_and_preserve_padding(device tint_array<tint_packed_vec3_f32_array_element, 2>* const target, float2x3 value_param) {
  (*target)[0u].packed = packed_float3(value_param[0u]);
  (*target)[1u].packed = packed_float3(value_param[1u]);
}

kernel void tint_symbol(device S_packed_vec3* 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 = packed_float3(float3(0.0f));
  (*tint_module_vars.sb).vec3_i32 = packed_int3(int3(0));
  (*tint_module_vars.sb).vec3_u32 = packed_uint3(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_1((&(*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_2((&(*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_3((&(*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>{};
}
