#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_f16_array_element {
  /* 0x0000 */ packed_half3 elements;
  /* 0x0006 */ tint_array<int8_t, 2> tint_pad;
};

struct S_tint_packed_vec3 {
  /* 0x0000 */ tint_array<tint_packed_vec3_f16_array_element, 4> tint_symbol;
  /* 0x0020 */ packed_half3 vector;
  /* 0x0026 */ tint_array<int8_t, 2> tint_pad_1;
};

half4x3 tint_unpack_vec3_in_composite(tint_array<tint_packed_vec3_f16_array_element, 4> in) {
  half4x3 result = half4x3(half3(in[0].elements), half3(in[1].elements), half3(in[2].elements), half3(in[3].elements));
  return result;
}

struct S {
  half4x3 tint_symbol;
  half3 vector;
};

fragment void tint_symbol_1(const constant S_tint_packed_vec3* tint_symbol_2 [[buffer(0)]]) {
  half4 const x = (half3((*(tint_symbol_2)).vector) * tint_unpack_vec3_in_composite((*(tint_symbol_2)).tint_symbol));
  return;
}

