#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];
};

#define TINT_ISOLATE_UB(VOLATILE_NAME) \
  {volatile bool VOLATILE_NAME = false; if (VOLATILE_NAME) break;}

kernel void foo(device tint_array<int, 10>* tint_symbol [[buffer(0)]]) {
  int i = 0;
  while(true) {
    TINT_ISOLATE_UB(tint_volatile_false);
    int x = (*(tint_symbol))[i];
    {
      int x_1 = (*(tint_symbol))[x];
      i = as_type<int>((as_type<uint>(i) + as_type<uint>(x_1)));
      if ((i > 10)) { break; }
    }
  }
  (*(tint_symbol))[0] = i;
  return;
}

