// File: /workspace/github_cpp_makefile_star2_O3/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 0x17b2(%rip), %rdi      # 0xa43a
xorl %esi, %esi
callq 0x8df4
leaq 0x17b9(%rip), %rdi      # 0xa44f
xorl %esi, %esi
callq 0x8df4
leaq 0x17d0(%rip), %rdi      # 0xa474
movl $0x1, %esi
callq 0x8df4
leaq 0x17e0(%rip), %rdi      # 0xa495
xorl %esi, %esi
callq 0x8df4
leaq 0x17ea(%rip), %rdi      # 0xa4ad
xorl %esi, %esi
callq 0x8df4
leaq 0x17fc(%rip), %rdi      # 0xa4cd
xorl %esi, %esi
callq 0x8df4
leaq 0x181e(%rip), %rdi      # 0xa4fd
xorl %esi, %esi
callq 0x8df4
leaq 0x183d(%rip), %rdi      # 0xa52a
xorl %esi, %esi
callq 0x8df4
leaq 0x184a(%rip), %rdi      # 0xa545
xorl %esi, %esi
callq 0x8df4
leaq 0x1857(%rip), %rdi      # 0xa560
xorl %esi, %esi
callq 0x8df4
leaq 0x1865(%rip), %rdi      # 0xa57c
xorl %esi, %esi
callq 0x8df4
leaq 0x1886(%rip), %rdi      # 0xa5ab
xorl %esi, %esi
callq 0x8df4
leaq 0x18aa(%rip), %rdi      # 0xa5dd
xorl %esi, %esi
callq 0x8df4
leaq 0x18eb(%rip), %rdi      # 0xa62c
xorl %esi, %esi
callq 0x8df4
leaq 0x192a(%rip), %rdi      # 0xa679
xorl %esi, %esi
callq 0x8df4
leaq 0x1969(%rip), %rdi      # 0xa6c6
xorl %esi, %esi
callq 0x8df4
leaq 0x199e(%rip), %rdi      # 0xa709
xorl %esi, %esi
callq 0x8df4
leaq 0x19a4(%rip), %rdi      # 0xa71d
xorl %esi, %esi
callq 0x8df4
leaq 0x19a3(%rip), %rdi      # 0xa72a
xorl %esi, %esi
callq 0x8df4
leaq 0x19b1(%rip), %rdi      # 0xa746
xorl %esi, %esi
callq 0x8df4
leaq 0x19d1(%rip), %rdi      # 0xa774
xorl %esi, %esi
callq 0x8df4
leaq 0x19ac(%rip), %rdi      # 0xa75d
xorl %esi, %esi
callq 0x8df4
leaq 0x19e3(%rip), %rdi      # 0xa7a2
xorl %esi, %esi
callq 0x8df4
leaq 0x1a1f(%rip), %rdi      # 0xa7ec
xorl %esi, %esi
callq 0x8df4
leaq 0x1a80(%rip), %rdi      # 0xa85b
xorl %esi, %esi
callq 0x8df4
leaq 0x1ad7(%rip), %rdi      # 0xa8c0
xorl %esi, %esi
callq 0x8df4
xorl %eax, %eax
popq %rcx
retq