// examples/test_conditional translated by mycpp

// BEGIN mycpp output

#include "mycpp/runtime.h"

GLOBAL_STR(str0, "CPP");
GLOBAL_STR(str1, "PYTHON");
GLOBAL_STR(str2, "ZERO");
GLOBAL_STR(str3, "int = %d");
GLOBAL_STR(str4, "123");
GLOBAL_STR(str5, "bool = %d");
GLOBAL_STR(str6, "mylist");
GLOBAL_STR(str7, "x = %d");
GLOBAL_STR(str8, "yes");
GLOBAL_STR(str9, "no");

namespace test_conditional {  // forward declare


}  // forward declare namespace test_conditional

namespace test_conditional {  // declare

void run_tests();
void run_benchmarks();

}  // declare namespace test_conditional

namespace test_conditional {  // define


void run_tests() {
  List<int>* mylist = nullptr;
  int x;
  bool a;
  StackRoot _root0(&mylist);

  // if MYCPP
  {
    mylib::print_stderr(str0);
  }
  // endif MYCPP
  // if not PYTHON
  {
    mylib::print_stderr(str1);
  }
  // endif MYCPP
  mylib::print_stderr(StrFormat("int = %d", to_int(str4)));
  mylib::print_stderr(StrFormat("bool = %d", to_bool(42)));
  mylist = Alloc<List<int>>();
  if (len(mylist)) {
    print(str6);
  }
  x = len(mylist) ? 1 : 2;
  mylib::print_stderr(StrFormat("x = %d", x));
  a = false;
  if ((a and (false or true))) {
    print(str8);
  }
  else {
    print(str9);
  }
}

void run_benchmarks() {
  FAIL(kNotImplemented);  // Python NotImplementedError
}

}  // define namespace test_conditional

int main(int argc, char **argv) {
  gHeap.Init();

  char* b = getenv("BENCHMARK");
  if (b && strlen(b)) {  // match Python's logic
    fprintf(stderr, "Benchmarking...\n");
    test_conditional::run_benchmarks();
  } else {
    test_conditional::run_tests();
  }

  gHeap.CleanProcessExit();
}