#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 i = 0;
  {
    int i_1 = 0;
    while(true) {
      TINT_ISOLATE_UB(tint_volatile_false)
      if ((i_1 < 2)) {
      } else {
        break;
      }
      bool tint_continue = false;
      switch(i_1) {
        case 0:
        {
          tint_continue = true;
          break;
        }
        default:
        {
          break;
        }
      }
      if (tint_continue) {
        {
          i_1 = as_type<int>((as_type<uint>(i_1) + as_type<uint>(1)));
        }
        continue;
      }
      bool tint_continue_1 = false;
      switch(i_1) {
        case 0:
        {
          tint_continue_1 = true;
          break;
        }
        default:
        {
          break;
        }
      }
      if (tint_continue_1) {
        {
          i_1 = as_type<int>((as_type<uint>(i_1) + as_type<uint>(1)));
        }
        continue;
      }
      {
        i_1 = as_type<int>((as_type<uint>(i_1) + as_type<uint>(1)));
      }
      continue;
    }
  }
}
