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

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

struct S_packed_vec3 {
  /* 0x0000 */ tint_array<Inner_packed_vec3, 8> arr;
};

struct tint_module_vars_struct {
  const constant S_packed_vec3* ub;
  device int* s;
};

int tint_f32_to_i32(float value) {
  return select(2147483647, select((-2147483647 - 1), int(value), (value >= -2147483648.0f)), (value <= 2147483520.0f));
}

tint_array<float3, 2> tint_load_array_packed_vec3(const constant tint_array<tint_packed_vec3_f32_array_element, 2>* const from) {
  float3 const v = float3((*from)[0u].packed);
  return tint_array<float3, 2>{v, float3((*from)[1u].packed)};
}

void tint_symbol_inner(uint idx, tint_module_vars_struct tint_module_vars) {
  float const scalar_f32 = (*tint_module_vars.ub).arr[min(idx, 7u)].scalar_f32;
  int const scalar_i32 = (*tint_module_vars.ub).arr[min(idx, 7u)].scalar_i32;
  uint const scalar_u32 = (*tint_module_vars.ub).arr[min(idx, 7u)].scalar_u32;
  float2 const vec2_f32 = (*tint_module_vars.ub).arr[min(idx, 7u)].vec2_f32;
  int2 const vec2_i32 = (*tint_module_vars.ub).arr[min(idx, 7u)].vec2_i32;
  uint2 const vec2_u32 = (*tint_module_vars.ub).arr[min(idx, 7u)].vec2_u32;
  float3 const vec3_f32 = float3((*tint_module_vars.ub).arr[min(idx, 7u)].vec3_f32);
  int3 const vec3_i32 = int3((*tint_module_vars.ub).arr[min(idx, 7u)].vec3_i32);
  uint3 const vec3_u32 = uint3((*tint_module_vars.ub).arr[min(idx, 7u)].vec3_u32);
  float4 const vec4_f32 = (*tint_module_vars.ub).arr[min(idx, 7u)].vec4_f32;
  int4 const vec4_i32 = (*tint_module_vars.ub).arr[min(idx, 7u)].vec4_i32;
  uint4 const vec4_u32 = (*tint_module_vars.ub).arr[min(idx, 7u)].vec4_u32;
  float2x2 const mat2x2_f32 = (*tint_module_vars.ub).arr[min(idx, 7u)].mat2x2_f32;
  tint_array<tint_packed_vec3_f32_array_element, 2> const v_1 = (*tint_module_vars.ub).arr[min(idx, 7u)].mat2x3_f32;
  float3 const v_2 = float3(v_1[0u].packed);
  float2x3 const mat2x3_f32 = float2x3(v_2, float3(v_1[1u].packed));
  float2x4 const mat2x4_f32 = (*tint_module_vars.ub).arr[min(idx, 7u)].mat2x4_f32;
  float3x2 const mat3x2_f32 = (*tint_module_vars.ub).arr[min(idx, 7u)].mat3x2_f32;
  tint_array<tint_packed_vec3_f32_array_element, 3> const v_3 = (*tint_module_vars.ub).arr[min(idx, 7u)].mat3x3_f32;
  float3 const v_4 = float3(v_3[0u].packed);
  float3 const v_5 = float3(v_3[1u].packed);
  float3x3 const mat3x3_f32 = float3x3(v_4, v_5, float3(v_3[2u].packed));
  float3x4 const mat3x4_f32 = (*tint_module_vars.ub).arr[min(idx, 7u)].mat3x4_f32;
  float4x2 const mat4x2_f32 = (*tint_module_vars.ub).arr[min(idx, 7u)].mat4x2_f32;
  tint_array<tint_packed_vec3_f32_array_element, 4> const v_6 = (*tint_module_vars.ub).arr[min(idx, 7u)].mat4x3_f32;
  float3 const v_7 = float3(v_6[0u].packed);
  float3 const v_8 = float3(v_6[1u].packed);
  float3 const v_9 = float3(v_6[2u].packed);
  float4x3 const mat4x3_f32 = float4x3(v_7, v_8, v_9, float3(v_6[3u].packed));
  float4x4 const mat4x4_f32 = (*tint_module_vars.ub).arr[min(idx, 7u)].mat4x4_f32;
  tint_array<float3, 2> const arr2_vec3_f32 = tint_load_array_packed_vec3((&(*tint_module_vars.ub).arr[min(idx, 7u)].arr2_vec3_f32));
  int const v_10 = as_type<int>((as_type<uint>(tint_f32_to_i32(scalar_f32)) + as_type<uint>(scalar_i32)));
  int const v_11 = as_type<int>((as_type<uint>(v_10) + as_type<uint>(int(scalar_u32))));
  int const v_12 = as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(v_11) + as_type<uint>(tint_f32_to_i32(vec2_f32.x))))) + as_type<uint>(vec2_i32.x)));
  int const v_13 = as_type<int>((as_type<uint>(v_12) + as_type<uint>(int(vec2_u32.x))));
  int const v_14 = as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(v_13) + as_type<uint>(tint_f32_to_i32(vec3_f32.y))))) + as_type<uint>(vec3_i32.y)));
  int const v_15 = as_type<int>((as_type<uint>(v_14) + as_type<uint>(int(vec3_u32.y))));
  int const v_16 = as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(v_15) + as_type<uint>(tint_f32_to_i32(vec4_f32.z))))) + as_type<uint>(vec4_i32.z)));
  int const v_17 = as_type<int>((as_type<uint>(v_16) + as_type<uint>(int(vec4_u32.z))));
  int const v_18 = as_type<int>((as_type<uint>(v_17) + as_type<uint>(tint_f32_to_i32(mat2x2_f32[0u].x))));
  int const v_19 = as_type<int>((as_type<uint>(v_18) + as_type<uint>(tint_f32_to_i32(mat2x3_f32[0u].x))));
  int const v_20 = as_type<int>((as_type<uint>(v_19) + as_type<uint>(tint_f32_to_i32(mat2x4_f32[0u].x))));
  int const v_21 = as_type<int>((as_type<uint>(v_20) + as_type<uint>(tint_f32_to_i32(mat3x2_f32[0u].x))));
  int const v_22 = as_type<int>((as_type<uint>(v_21) + as_type<uint>(tint_f32_to_i32(mat3x3_f32[0u].x))));
  int const v_23 = as_type<int>((as_type<uint>(v_22) + as_type<uint>(tint_f32_to_i32(mat3x4_f32[0u].x))));
  int const v_24 = as_type<int>((as_type<uint>(v_23) + as_type<uint>(tint_f32_to_i32(mat4x2_f32[0u].x))));
  int const v_25 = as_type<int>((as_type<uint>(v_24) + as_type<uint>(tint_f32_to_i32(mat4x3_f32[0u].x))));
  int const v_26 = as_type<int>((as_type<uint>(v_25) + as_type<uint>(tint_f32_to_i32(mat4x4_f32[0u].x))));
  (*tint_module_vars.s) = as_type<int>((as_type<uint>(v_26) + as_type<uint>(tint_f32_to_i32(arr2_vec3_f32[0u].x))));
}

kernel void tint_symbol(uint idx [[thread_index_in_threadgroup]], const constant S_packed_vec3* ub [[buffer(0)]], device int* s [[buffer(1)]]) {
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.ub=ub, .s=s};
  tint_symbol_inner(idx, tint_module_vars);
}
