#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_module_vars_struct {
  thread tint_array<tint_array<int, 3>, 2>* zero;
  thread tint_array<tint_array<int, 3>, 2>* init;
};

kernel void tint_symbol() {
  thread tint_array<tint_array<int, 3>, 2> zero = {};
  thread tint_array<tint_array<int, 3>, 2> init = tint_array<tint_array<int, 3>, 2>{tint_array<int, 3>{1, 2, 3}, tint_array<int, 3>{4, 5, 6}};
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.zero=(&zero), .init=(&init)};
  tint_array<tint_array<int, 3>, 2> v0 = (*tint_module_vars.zero);
  tint_array<tint_array<int, 3>, 2> v1 = (*tint_module_vars.init);
}
