#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ stua_run_script(char *);
void test_script(void) {
  stua_run_script(
      "var g = (2+3)*5 + 3*(2+1) + ((7)); \n"
      "func sprint(x) _print(x) _print(' ') x end;\n"
      "func foo(y) var q = func(x) sprint(x) end; q end;\n "
      "var z=foo(5); z(77);\n"
      "func counter(z) func(x) z=z+1 end end\n"
      "var q=counter(0), p=counter(5);\n"
      "sprint(q()) sprint(p()) sprint(q()) sprint(p()) sprint(q()) "
      "sprint(p())\n"
      "var x=2222;\n"
      "if 1 == 2 then 3333 else 4444 end; => x; sprint(x);\n"
      "var x1 = sprint(1.5e3);  \n"
      "var x2 = sprint(.5);  \n"
      "var x3 = sprint(1.);  \n"
      "var x4 = sprint(1.e3);  \n"
      "var x5 = sprint(1e3);  \n"
      "var x6 = sprint(0.5e3);  \n"
      "var x7 = sprint(.5e3);  \n"
      " func sum(x,y) x+y end                                       \n"
      " func sumfunc(a) sum+{x=a} end                               \n"
      " var q = sumfunc(3) \n"
      " var p = sumfunc(20) \n"
      " var d = sprint(q(5)) - sprint(q(8)) \n"
      " var e = sprint(p(5)) - sprint(p(8)) \n"
      " func test3(x)       \n"
      "    sprint(x)         \n"
      "    x = x+3          \n"
      "    sprint(x)         \n"
      "    x+5              \n"
      " end                 \n"
      " var y = test3(4);   \n"
      " func fib(x)         \n"
      "    if x < 3 then    \n"
      "       1             \n"
      "    else             \n"
      "      fib(x-1) + fib(x-2); \n"
      "    end              \n"
      " end                 \n"
      "                     \n"
      " func fib2(x)        \n"
      "    var a=1          \n"
      "    var b=1          \n"
      "    sprint(a)        \n"
      "    sprint(b)        \n"
      "    while x > 2 do   \n"
      "       var c=a+b     \n"
      "       a=b           \n"
      "       b=c           \n"
      "       sprint(b)     \n"
      "       x=x-1         \n"
      "    end              \n"
      "    b                \n"
      " end                 \n"
      "                                                             \n"
      " func assign(z)                                              \n"
      "    var y = { 'this', 'is', 'a', 'lame', 'day', 'to', 'die'} \n"
      "    y[3] = z                                                 \n"
      "    var i = 0                                                \n"
      "    while y[i] != nil do                                     \n"
      "       sprint(y[i])                                          \n"
      "       i = i+1                                               \n"
      "    end                                                      \n"
      " end                                                         \n"
      "                                                             \n"
      " sprint(fib(12)); \n"
      " assign(\"good\"); \n"
      " fib2(20); \n"
      " sprint('ok'); \n"
      " sprint(-5); \n"
      " // final comment with no newline");
}


x86 assembly (clang, -O0):
<test_script>:
push   %rbp
mov    %rsp,%rbp
lea    0xee5(%rip),%rdi
call   1030 <stua_run_script@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_script>:
lea    0xee9(%rip),%rdi
jmp    1030 <stua_run_script@plt>

LLVM IR (-O0):
@.str = [2214 x i8] c"var g = (2+3)*5 + 3*(2+1) + ((7)); \0Afunc sprint(x) _print(x) _print(' ') x end;\0Afunc foo(y) var q = func(x) sprint(x) end; q end;\0A var z=foo(5); z(77);\0Afunc counter(z) func(x) z=z+1 end end\0Avar q=counter(0), p=counter(5);\0Asprint(q()) sprint(p()) sprint(q()) sprint(p()) sprint(q()) sprint(p())\0Avar x=2222;\0Aif 1 == 2 then 3333 else 4444 end; => x; sprint(x);\0Avar x1 = sprint(1.5e3); \0Avar x2 = sprint(.5); \0Avar x3 = sprint(1.); \0Avar x4 = sprint(1.e3); \0Avar x5 = sprint(1e3); \0Avar x6 = sprint(0.5e3); \0Avar x7 = sprint(.5e3); \0A func sum(x,y) x+y end \0A func sumfunc(a) sum+{x=a} end \0A var q = sumfunc(3) \0A var p = sumfunc(20) \0A var d = sprint(q(5)) - sprint(q(8)) \0A var e = sprint(p(5)) - sprint(p(8)) \0A func test3(x) \0A sprint(x) \0A x = x+3 \0A sprint(x) \0A x+5 \0A end \0A var y = test3(4); \0A func fib(x) \0A if x < 3 then \0A 1 \0A else \0A fib(x-1) + fib(x-2); \0A end \0A end \0A \0A func fib2(x) \0A var a=1 \0A var b=1 \0A sprint(a) \0A sprint(b) \0A while x > 2 do \0A var c=a+b \0A a=b \0A b=c \0A sprint(b) \0A x=x-1 \0A end \0A b \0A end \0A \0A func assign(z) \0A var y = { 'this', 'is', 'a', 'lame', 'day', 'to', 'die'} \0A y[3] = z \0A var i = 0 \0A while y[i] != nil do \0A sprint(y[i]) \0A i = i+1 \0A end \0A end \0A \0A sprint(fib(12)); \0A assign(\22good\22); \0A fib2(20); \0A sprint('ok'); \0A sprint(-5); \0A // final comment with no newline\00"
define void @test_script() {
%1 = call i32 @stua_run_script(i8* getelementptr inbounds ([2214 x i8], [2214 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [2214 x i8] c"var g = (2+3)*5 + 3*(2+1) + ((7)); \0Afunc sprint(x) _print(x) _print(' ') x end;\0Afunc foo(y) var q = func(x) sprint(x) end; q end;\0A var z=foo(5); z(77);\0Afunc counter(z) func(x) z=z+1 end end\0Avar q=counter(0), p=counter(5);\0Asprint(q()) sprint(p()) sprint(q()) sprint(p()) sprint(q()) sprint(p())\0Avar x=2222;\0Aif 1 == 2 then 3333 else 4444 end; => x; sprint(x);\0Avar x1 = sprint(1.5e3); \0Avar x2 = sprint(.5); \0Avar x3 = sprint(1.); \0Avar x4 = sprint(1.e3); \0Avar x5 = sprint(1e3); \0Avar x6 = sprint(0.5e3); \0Avar x7 = sprint(.5e3); \0A func sum(x,y) x+y end \0A func sumfunc(a) sum+{x=a} end \0A var q = sumfunc(3) \0A var p = sumfunc(20) \0A var d = sprint(q(5)) - sprint(q(8)) \0A var e = sprint(p(5)) - sprint(p(8)) \0A func test3(x) \0A sprint(x) \0A x = x+3 \0A sprint(x) \0A x+5 \0A end \0A var y = test3(4); \0A func fib(x) \0A if x < 3 then \0A 1 \0A else \0A fib(x-1) + fib(x-2); \0A end \0A end \0A \0A func fib2(x) \0A var a=1 \0A var b=1 \0A sprint(a) \0A sprint(b) \0A while x > 2 do \0A var c=a+b \0A a=b \0A b=c \0A sprint(b) \0A x=x-1 \0A end \0A b \0A end \0A \0A func assign(z) \0A var y = { 'this', 'is', 'a', 'lame', 'day', 'to', 'die'} \0A y[3] = z \0A var i = 0 \0A while y[i] != nil do \0A sprint(y[i]) \0A i = i+1 \0A end \0A end \0A \0A sprint(fib(12)); \0A assign(\22good\22); \0A fib2(20); \0A sprint('ok'); \0A sprint(-5); \0A // final comment with no newline\00"
define void @test_script() {
%1 = tail call i32 @stua_run_script(i8* getelementptr inbounds ([2214 x i8], [2214 x i8]* @.str, i64 0, i64 0))
ret void
}