#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 Outputs {
  /* 0x0000 */ tint_array<uint, 1> data;
};

struct tint_module_vars_struct {
  thread uint* count;
  device Outputs* outputs;
};

void push_output(uint value, tint_module_vars_struct tint_module_vars) {
  (*tint_module_vars.outputs).data[(*tint_module_vars.count)] = value;
  (*tint_module_vars.count) = ((*tint_module_vars.count) + 1u);
}

kernel void tint_symbol(device Outputs* outputs [[buffer(0)]]) {
  thread uint count = 0u;
  tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.count=(&count), .outputs=outputs};
  uint a = 0u;
  uint b = 10u;
  uint c = 4294967294u;
  a = (a + 1u);
  b = (b + 1u);
  c = (c + 1u);
  push_output(a, tint_module_vars);
  push_output(b, tint_module_vars);
  push_output(c, tint_module_vars);
}
