#include <metal_stdlib>
using namespace metal;

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

kernel void tint_symbol() {
  int j = 0;
  {
    int i = 0;
    while(true) {
      TINT_ISOLATE_UB(tint_volatile_false)
      if ((i < 2)) {
      } else {
        break;
      }
      bool tint_continue = false;
      switch(i) {
        case 0:
        {
          bool tint_continue_1 = false;
          switch(j) {
            case 0:
            {
              tint_continue_1 = true;
              break;
            }
            default:
            {
              break;
            }
          }
          if (tint_continue_1) {
            tint_continue = true;
            break;
          }
          break;
        }
        default:
        {
          break;
        }
      }
      if (tint_continue) {
        {
          i = as_type<int>((as_type<uint>(i) + as_type<uint>(2)));
        }
        continue;
      }
      {
        i = as_type<int>((as_type<uint>(i) + as_type<uint>(2)));
      }
      continue;
    }
  }
}
