// File: /workspace/github_cpp_makefile_star2_O2/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 0xb62(%rip), %rdi       # 0x846a
xorl %esi, %esi
callq 0x7a72
leaq 0xb69(%rip), %rdi       # 0x847f
xorl %esi, %esi
callq 0x7a72
leaq 0xb80(%rip), %rdi       # 0x84a4
pushq $0x1
popq %rsi
callq 0x7a72
leaq 0xb92(%rip), %rdi       # 0x84c5
xorl %esi, %esi
callq 0x7a72
leaq 0xb9c(%rip), %rdi       # 0x84dd
xorl %esi, %esi
callq 0x7a72
leaq 0xbae(%rip), %rdi       # 0x84fd
xorl %esi, %esi
callq 0x7a72
leaq 0xbd0(%rip), %rdi       # 0x852d
xorl %esi, %esi
callq 0x7a72
leaq 0xbef(%rip), %rdi       # 0x855a
xorl %esi, %esi
callq 0x7a72
leaq 0xbfc(%rip), %rdi       # 0x8575
xorl %esi, %esi
callq 0x7a72
leaq 0xc09(%rip), %rdi       # 0x8590
xorl %esi, %esi
callq 0x7a72
leaq 0xc17(%rip), %rdi       # 0x85ac
xorl %esi, %esi
callq 0x7a72
leaq 0xc38(%rip), %rdi       # 0x85db
xorl %esi, %esi
callq 0x7a72
leaq 0xc5c(%rip), %rdi       # 0x860d
xorl %esi, %esi
callq 0x7a72
leaq 0xc9d(%rip), %rdi       # 0x865c
xorl %esi, %esi
callq 0x7a72
leaq 0xcdc(%rip), %rdi       # 0x86a9
xorl %esi, %esi
callq 0x7a72
leaq 0xd1b(%rip), %rdi       # 0x86f6
xorl %esi, %esi
callq 0x7a72
leaq 0xd50(%rip), %rdi       # 0x8739
xorl %esi, %esi
callq 0x7a72
leaq 0xd56(%rip), %rdi       # 0x874d
xorl %esi, %esi
callq 0x7a72
leaq 0xd55(%rip), %rdi       # 0x875a
xorl %esi, %esi
callq 0x7a72
leaq 0xd63(%rip), %rdi       # 0x8776
xorl %esi, %esi
callq 0x7a72
leaq 0xd83(%rip), %rdi       # 0x87a4
xorl %esi, %esi
callq 0x7a72
leaq 0xd5e(%rip), %rdi       # 0x878d
xorl %esi, %esi
callq 0x7a72
leaq 0xd95(%rip), %rdi       # 0x87d2
xorl %esi, %esi
callq 0x7a72
leaq 0xdd1(%rip), %rdi       # 0x881c
xorl %esi, %esi
callq 0x7a72
leaq 0xe32(%rip), %rdi       # 0x888b
xorl %esi, %esi
callq 0x7a72
leaq 0xe89(%rip), %rdi       # 0x88f0
xorl %esi, %esi
callq 0x7a72
xorl %eax, %eax
popq %rcx
retq