
void f() {
  {
    int i0520 = int(0);
    while(true) {
      if (false) {
      } else {
        break;
      }
      {
      }
      continue;
    }
  }
  {
    int i62 = int(0);
    while(true) {
      if (false) {
      } else {
        break;
      }
      {
      }
      continue;
    }
  }
  {
    int i0520 = int(0);
    while(true) {
      if (false) {
      } else {
        break;
      }
      {
      }
      continue;
    }
  }
  {
    int i62 = int(0);
    while(true) {
      if (false) {
      } else {
        break;
      }
      {
      }
      continue;
    }
  }
  {
    int i62 = int(0);
    while(true) {
      if (false) {
      } else {
        break;
      }
      {
      }
      continue;
    }
  }
  {
    int i60 = int(0);
    while(true) {
      if (false) {
      } else {
        break;
      }
      {
      }
      continue;
    }
  }
  {
    int i62 = int(0);
    while(true) {
      if (false) {
      } else {
        break;
      }
      {
      }
      continue;
    }
  }
  {
    int i60 = int(0);
    while(true) {
      if (false) {
      } else {
        break;
      }
      {
      }
      continue;
    }
  }
}

[numthreads(1, 1, 1)]
void unused_entry_point() {
}

