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

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

struct tint_packed_vec3_f32_array_element {
  /* 0x0000 */ packed_float3 elements;
  /* 0x000c */ tint_array<int8_t, 4> tint_pad;
};

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

struct S_tint_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 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;
};

void assign_and_preserve_padding(device tint_array<tint_packed_vec3_f32_array_element, 2>* const dest, float2x3 value) {
  (*(dest))[0u].elements = packed_float3(value[0u]);
  (*(dest))[1u].elements = packed_float3(value[1u]);
}

void assign_and_preserve_padding_1(device tint_array<tint_packed_vec3_f32_array_element, 3>* const dest, float3x3 value) {
  (*(dest))[0u].elements = packed_float3(value[0u]);
  (*(dest))[1u].elements = packed_float3(value[1u]);
  (*(dest))[2u].elements = packed_float3(value[2u]);
}

void assign_and_preserve_padding_2(device tint_array<tint_packed_vec3_f32_array_element, 4>* const dest, float4x3 value) {
  (*(dest))[0u].elements = packed_float3(value[0u]);
  (*(dest))[1u].elements = packed_float3(value[1u]);
  (*(dest))[2u].elements = packed_float3(value[2u]);
  (*(dest))[3u].elements = packed_float3(value[3u]);
}

void assign_and_preserve_padding_3(device tint_array<tint_packed_vec3_f32_array_element, 2>* const dest, tint_array<float3, 2> value) {
  for(uint i = 0u; (i < 2u); i = (i + 1u)) {
    TINT_ISOLATE_UB(tint_volatile_false);
    (*(dest))[i].elements = packed_float3(value[i]);
  }
}

kernel void tint_symbol(device S_tint_packed_vec3* tint_symbol_4 [[buffer(0)]]) {
  (*(tint_symbol_4)).scalar_f32 = 0.0f;
  (*(tint_symbol_4)).scalar_i32 = 0;
  (*(tint_symbol_4)).scalar_u32 = 0u;
  (*(tint_symbol_4)).vec2_f32 = float2(0.0f);
  (*(tint_symbol_4)).vec2_i32 = int2(0);
  (*(tint_symbol_4)).vec2_u32 = uint2(0u);
  (*(tint_symbol_4)).vec3_f32 = packed_float3(0.0f);
  (*(tint_symbol_4)).vec3_i32 = packed_int3(0);
  (*(tint_symbol_4)).vec3_u32 = packed_uint3(0u);
  (*(tint_symbol_4)).vec4_f32 = float4(0.0f);
  (*(tint_symbol_4)).vec4_i32 = int4(0);
  (*(tint_symbol_4)).vec4_u32 = uint4(0u);
  (*(tint_symbol_4)).mat2x2_f32 = float2x2(float2(0.0f), float2(0.0f));
  assign_and_preserve_padding(&((*(tint_symbol_4)).mat2x3_f32), float2x3(float3(0.0f), float3(0.0f)));
  (*(tint_symbol_4)).mat2x4_f32 = float2x4(float4(0.0f), float4(0.0f));
  (*(tint_symbol_4)).mat3x2_f32 = float3x2(float2(0.0f), float2(0.0f), float2(0.0f));
  assign_and_preserve_padding_1(&((*(tint_symbol_4)).mat3x3_f32), float3x3(float3(0.0f), float3(0.0f), float3(0.0f)));
  (*(tint_symbol_4)).mat3x4_f32 = float3x4(float4(0.0f), float4(0.0f), float4(0.0f));
  (*(tint_symbol_4)).mat4x2_f32 = float4x2(float2(0.0f), float2(0.0f), float2(0.0f), float2(0.0f));
  assign_and_preserve_padding_2(&((*(tint_symbol_4)).mat4x3_f32), float4x3(float3(0.0f), float3(0.0f), float3(0.0f), float3(0.0f)));
  (*(tint_symbol_4)).mat4x4_f32 = float4x4(float4(0.0f), float4(0.0f), float4(0.0f), float4(0.0f));
  tint_array<float3, 2> const tint_symbol_1 = tint_array<float3, 2>{};
  assign_and_preserve_padding_3(&((*(tint_symbol_4)).arr2_vec3_f32), tint_symbol_1);
  Inner const tint_symbol_2 = Inner{};
  (*(tint_symbol_4)).struct_inner = tint_symbol_2;
  tint_array<Inner, 4> const tint_symbol_3 = tint_array<Inner, 4>{};
  (*(tint_symbol_4)).array_struct_inner = tint_symbol_3;
  return;
}

