#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 {
  const constant S* 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));
}
kernel void tint_symbol(const constant S* ub [[buffer(0)]], device int* s [[buffer(1)]]) {
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.ub=ub, .s=s};
  float const scalar_f32 = (*tint_module_vars.ub).scalar_f32;
  int const scalar_i32 = (*tint_module_vars.ub).scalar_i32;
  uint const scalar_u32 = (*tint_module_vars.ub).scalar_u32;
  float2 const vec2_f32 = (*tint_module_vars.ub).vec2_f32;
  int2 const vec2_i32 = (*tint_module_vars.ub).vec2_i32;
  uint2 const vec2_u32 = (*tint_module_vars.ub).vec2_u32;
  float3 const vec3_f32 = (*tint_module_vars.ub).vec3_f32;
  int3 const vec3_i32 = (*tint_module_vars.ub).vec3_i32;
  uint3 const vec3_u32 = (*tint_module_vars.ub).vec3_u32;
  float4 const vec4_f32 = (*tint_module_vars.ub).vec4_f32;
  int4 const vec4_i32 = (*tint_module_vars.ub).vec4_i32;
  uint4 const vec4_u32 = (*tint_module_vars.ub).vec4_u32;
  float2x2 const mat2x2_f32 = (*tint_module_vars.ub).mat2x2_f32;
  float2x3 const mat2x3_f32 = (*tint_module_vars.ub).mat2x3_f32;
  float2x4 const mat2x4_f32 = (*tint_module_vars.ub).mat2x4_f32;
  float3x2 const mat3x2_f32 = (*tint_module_vars.ub).mat3x2_f32;
  float3x3 const mat3x3_f32 = (*tint_module_vars.ub).mat3x3_f32;
  float3x4 const mat3x4_f32 = (*tint_module_vars.ub).mat3x4_f32;
  float4x2 const mat4x2_f32 = (*tint_module_vars.ub).mat4x2_f32;
  float4x3 const mat4x3_f32 = (*tint_module_vars.ub).mat4x3_f32;
  float4x4 const mat4x4_f32 = (*tint_module_vars.ub).mat4x4_f32;
  tint_array<float3, 2> const arr2_vec3_f32 = (*tint_module_vars.ub).arr2_vec3_f32;
  Inner const struct_inner = (*tint_module_vars.ub).struct_inner;
  tint_array<Inner, 4> const array_struct_inner = (*tint_module_vars.ub).array_struct_inner;
  int const v = (tint_f32_to_i32(scalar_f32) + scalar_i32);
  int const v_1 = (v + int(scalar_u32));
  int const v_2 = ((v_1 + tint_f32_to_i32(vec2_f32[0u])) + vec2_i32[0u]);
  int const v_3 = (v_2 + int(vec2_u32[0u]));
  int const v_4 = ((v_3 + tint_f32_to_i32(vec3_f32[1u])) + vec3_i32[1u]);
  int const v_5 = (v_4 + int(vec3_u32[1u]));
  int const v_6 = ((v_5 + tint_f32_to_i32(vec4_f32[2u])) + vec4_i32[2u]);
  int const v_7 = (v_6 + int(vec4_u32[2u]));
  int const v_8 = (v_7 + tint_f32_to_i32(mat2x2_f32[0][0u]));
  int const v_9 = (v_8 + tint_f32_to_i32(mat2x3_f32[0][0u]));
  int const v_10 = (v_9 + tint_f32_to_i32(mat2x4_f32[0][0u]));
  int const v_11 = (v_10 + tint_f32_to_i32(mat3x2_f32[0][0u]));
  int const v_12 = (v_11 + tint_f32_to_i32(mat3x3_f32[0][0u]));
  int const v_13 = (v_12 + tint_f32_to_i32(mat3x4_f32[0][0u]));
  int const v_14 = (v_13 + tint_f32_to_i32(mat4x2_f32[0][0u]));
  int const v_15 = (v_14 + tint_f32_to_i32(mat4x3_f32[0][0u]));
  int const v_16 = (v_15 + tint_f32_to_i32(mat4x4_f32[0][0u]));
  (*tint_module_vars.s) = (((v_16 + tint_f32_to_i32(arr2_vec3_f32[0][0u])) + struct_inner.scalar_i32) + array_struct_inner[0].scalar_i32);
}
