#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 S {
  tint_array<int, 1> a;
};
struct tint_module_vars_struct {
  const device S* G;
  const constant tint_array<uint4, 1>* tint_storage_buffer_sizes;
};

kernel void tint_symbol(const device S* G [[buffer(0)]], const constant tint_array<uint4, 1>* tint_storage_buffer_sizes) {
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.G=G, .tint_storage_buffer_sizes=tint_storage_buffer_sizes};
  const device tint_array<int, 1>* const p = (&(*tint_module_vars.G).a);
  const device tint_array<int, 1>* const p2 = p;
  uint const l1 = (((*tint_module_vars.tint_storage_buffer_sizes)[0u][0u] - 0u) / 4u);
}
