#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 TintArrayLengths {
  /* 0x0000 */ tint_array<uint4, 1> array_lengths;
};

struct SB_RW {
  tint_array<float, 1> arg_0;
};

uint arrayLength_cdd123(const constant TintArrayLengths* const tint_symbol) {
  uint res = (((*(tint_symbol)).array_lengths[0u][0u] - 0u) / 4u);
  return res;
}

fragment void fragment_main(device uint* tint_symbol_1 [[buffer(0)]], const constant TintArrayLengths* tint_symbol_2 [[buffer(30)]]) {
  *(tint_symbol_1) = arrayLength_cdd123(tint_symbol_2);
  return;
}

kernel void compute_main(device uint* tint_symbol_3 [[buffer(0)]], const constant TintArrayLengths* tint_symbol_4 [[buffer(30)]]) {
  *(tint_symbol_3) = arrayLength_cdd123(tint_symbol_4);
  return;
}

