// File: /workspace/github_cpp_makefile_star2_O1/bsegovia[P]boodew/tests.cpp
// Function: main
int main(int argc, const char *argv[]) {
  // global variable
  run("echo ($ some_global)");
  run("var f [echo (* ($ 0)($ 0))]; ($ f) 3");
  run("var x 1; var y 2; echo (+ ($ x))",true);

  // string substitution
  run("var i; echo [hop@($ i)]");
  run("var i 4; echo [hop@(int ($ i))]");
  run("var str [[bla @(.. [echo] [ 4])]]; echo ($ str)");
  run("var str [[bla @(.. [echo] [ 4])]]; (($ str))");

  // delayed string substitution
  run("var i 4; echo [hop@[($ i)]");
  run("var i 4; echo [hop@@($ i)]");
  run("var i 4; echo [[hop@($ i)]]");

  // loop + control flow
  run("loop i 16 [? (< ($ i) 8) [echo ($ i)] [break]]");
  run("loop i 16 [? (< ($ i) 8) [echo ($ i)] [continue]]");
  run("echo (do [loop i 16 [? (!= ($ i) 8) [echo ($ i)] [return (int (- ($ i) 1))]]])");

  // more conditionals
  run("var i 5; var hop salut; echo (? (< ($ i) 3) [do [return [@(echo ($ hop))]]])");
  run("var i 5; var hop salut; echo (? (> ($ i) 3) [do [return [@(echo ($ hop))]]])");

  // dynamic scoping
  run("var fn [echo ($ in_upper_scope)]; (var in_upper_scope bim); ($ fn)");

  // simple echo
  run("echo deded; echo er");

  // simple operator
  run("echo (+ 1 2)");

  // string concat
  run("echo (.. (.. a bb) (+ 1 2))");
  run("echo (.. (.. a bb) cc)");

  // storing a function in a variable
  run("var fn [echo ($ 0)]; ($ fn) boum\n($ fn) boum2");
  run("# [this is a comment]; var fn [echo ($ 0)]; ($ fn) boum\n($ fn) boum2");

  // function arguments currying
  run("var bind [do [return [[@@($ 0) @@($ 1) ($ 0)]]]]; echo ((($ bind) + 2) 3)");
  run("var bind [do [return [[@@($ 0) @@($ 1) ($ 0)]]]];"
      "var plus (($ bind) + 2);"
      "echo (int (do [return (($ plus) 3)]))");
  run("var bind [^ [[@@($ 0) @@($ 1) ($ 0)]]];"
      "var plus (($ bind) + 2);"
      "echo (int (do [return (($ plus) 3)]))");
  run("var bind [^ [[@@($ 0) @@($ 1) ($ 0)]]];"
      "var plus (($ bind) + 2);"
      "echo ((($ plus) 3))");
  return 0;
}

// Assembly:
pushq %rax
leaq 0x162e(%rip), %rdi      # 0xa43a
xorl %esi, %esi
callq 0x8f78
leaq 0x1635(%rip), %rdi      # 0xa44f
xorl %esi, %esi
callq 0x8f78
leaq 0x164c(%rip), %rdi      # 0xa474
movl $0x1, %esi
callq 0x8f78
leaq 0x165c(%rip), %rdi      # 0xa495
xorl %esi, %esi
callq 0x8f78
leaq 0x1666(%rip), %rdi      # 0xa4ad
xorl %esi, %esi
callq 0x8f78
leaq 0x1678(%rip), %rdi      # 0xa4cd
xorl %esi, %esi
callq 0x8f78
leaq 0x169a(%rip), %rdi      # 0xa4fd
xorl %esi, %esi
callq 0x8f78
leaq 0x16b9(%rip), %rdi      # 0xa52a
xorl %esi, %esi
callq 0x8f78
leaq 0x16c6(%rip), %rdi      # 0xa545
xorl %esi, %esi
callq 0x8f78
leaq 0x16d3(%rip), %rdi      # 0xa560
xorl %esi, %esi
callq 0x8f78
leaq 0x16e1(%rip), %rdi      # 0xa57c
xorl %esi, %esi
callq 0x8f78
leaq 0x1702(%rip), %rdi      # 0xa5ab
xorl %esi, %esi
callq 0x8f78
leaq 0x1726(%rip), %rdi      # 0xa5dd
xorl %esi, %esi
callq 0x8f78
leaq 0x1767(%rip), %rdi      # 0xa62c
xorl %esi, %esi
callq 0x8f78
leaq 0x17a6(%rip), %rdi      # 0xa679
xorl %esi, %esi
callq 0x8f78
leaq 0x17e5(%rip), %rdi      # 0xa6c6
xorl %esi, %esi
callq 0x8f78
leaq 0x181a(%rip), %rdi      # 0xa709
xorl %esi, %esi
callq 0x8f78
leaq 0x1820(%rip), %rdi      # 0xa71d
xorl %esi, %esi
callq 0x8f78
leaq 0x181f(%rip), %rdi      # 0xa72a
xorl %esi, %esi
callq 0x8f78
leaq 0x182d(%rip), %rdi      # 0xa746
xorl %esi, %esi
callq 0x8f78
leaq 0x184d(%rip), %rdi      # 0xa774
xorl %esi, %esi
callq 0x8f78
leaq 0x1828(%rip), %rdi      # 0xa75d
xorl %esi, %esi
callq 0x8f78
leaq 0x185f(%rip), %rdi      # 0xa7a2
xorl %esi, %esi
callq 0x8f78
leaq 0x189b(%rip), %rdi      # 0xa7ec
xorl %esi, %esi
callq 0x8f78
leaq 0x18fc(%rip), %rdi      # 0xa85b
xorl %esi, %esi
callq 0x8f78
leaq 0x1953(%rip), %rdi      # 0xa8c0
xorl %esi, %esi
callq 0x8f78
xorl %eax, %eax
popq %rcx
retq