// File: andrakis[P]alisp/tests.cpp
// Function: test_eval()
void test_eval() {
	StringType code = "(begin (define fac (lambda (n) (fac/2 n 1))) (define fac/2 (lambda (n a) (if (= 1 n) a (fac/2 (- n 1) (* n a))))) (define x 10) (print \"Fac\" x(fac x)))";
	Cell code_cell = Parser::read(code);
	Environment *env_ptr = new Environment();
	EnvironmentType env_t(env_ptr);

	env_t->create(Declare("print"), ProcCell(Stdlib::print));
	env_t->create(Declare("+"), ProcCell(Stdlib::plus));
	env_t->create(Declare("-"), ProcCell(Stdlib::minus));
	env_t->create(Declare("*"), ProcCell(Stdlib::multiply));
	env_t->create(Declare("="), ProcCell(Stdlib::equal));

	EnvironmentCell env_cell(env_t);

	Cell result = Eval::Simple::eval(code_cell, env_cell);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
leaq -0x21(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x87d0
movq -0x110(%rbp), %rdx
leaq 0x3a5b(%rip), %rsi      # 0x3db34
leaq -0x20(%rbp), %rdi
callq 0x8610
jmp 0x3a0e4
leaq -0x21(%rbp), %rdi
callq 0x8490
leaq -0x40(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x2d200
jmp 0x3a0fc
movl $0x48, %edi
callq 0x8400
movq %rax, -0x118(%rbp)
jmp 0x3a10f
movb $0x1, -0x59(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x58(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0xd310
movq -0x118(%rbp), %rdi
movq -0x120(%rbp), %rsi
callq 0xf7c0
jmp 0x3a13c
movb $0x0, -0x59(%rbp)
leaq -0x58(%rbp), %rdi
callq 0xb8e0
movq -0x118(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x3aef0
jmp 0x3a163
leaq -0x70(%rbp), %rdi
callq 0xba80
movq %rax, -0x128(%rbp)
leaq 0x3771(%rip), %rsi      # 0x3d8eb
leaq -0x78(%rbp), %rdi
callq 0x17fe0
jmp 0x3a185
leaq -0x594c(%rip), %rsi     # 0x34840
leaq -0x88(%rbp), %rdi
callq 0x33500
jmp 0x3a19a
leaq -0x80(%rbp), %rdi
movq %rdi, -0x130(%rbp)
leaq -0x88(%rbp), %rsi
callq 0xbd50
movq -0x128(%rbp), %rdi
movq -0x130(%rbp), %rdx
leaq -0x78(%rbp), %rsi
callq 0xbaa0
jmp 0x3a1ca
leaq -0x80(%rbp), %rdi
callq 0xb9d0
leaq -0x88(%rbp), %rdi
callq 0x33560
leaq -0x78(%rbp), %rdi
callq 0xb9d0
leaq -0x70(%rbp), %rdi
callq 0xba80
movq %rax, -0x138(%rbp)
leaq 0x3665(%rip), %rsi      # 0x3d864
leaq -0x90(%rbp), %rdi
callq 0x17fe0
jmp 0x3a20d
leaq -0x33c4(%rip), %rsi     # 0x36e50
leaq -0xa0(%rbp), %rdi
callq 0x33500
jmp 0x3a222
leaq -0x98(%rbp), %rdi
movq %rdi, -0x140(%rbp)
leaq -0xa0(%rbp), %rsi
callq 0xbd50
movq -0x138(%rbp), %rdi
movq -0x140(%rbp), %rdx
leaq -0x90(%rbp), %rsi
callq 0xbaa0
jmp 0x3a258
leaq -0x98(%rbp), %rdi
callq 0xb9d0
leaq -0xa0(%rbp), %rdi
callq 0x33560
leaq -0x90(%rbp), %rdi
callq 0xb9d0
leaq -0x70(%rbp), %rdi
callq 0xba80
movq %rax, -0x148(%rbp)
leaq 0x2799(%rip), %rsi      # 0x3ca2c
leaq -0xa8(%rbp), %rdi
callq 0x17fe0
jmp 0x3a2a1
leaq -0x3248(%rip), %rsi     # 0x37060
leaq -0xb8(%rbp), %rdi
callq 0x33500
jmp 0x3a2b6
leaq -0xb0(%rbp), %rdi
movq %rdi, -0x150(%rbp)
leaq -0xb8(%rbp), %rsi
callq 0xbd50
movq -0x148(%rbp), %rdi
movq -0x150(%rbp), %rdx
leaq -0xa8(%rbp), %rsi
callq 0xbaa0
jmp 0x3a2ec
leaq -0xb0(%rbp), %rdi
callq 0xb9d0
leaq -0xb8(%rbp), %rdi
callq 0x33560
leaq -0xa8(%rbp), %rdi
callq 0xb9d0
leaq -0x70(%rbp), %rdi
callq 0xba80
movq %rax, -0x158(%rbp)
leaq 0x35ca(%rip), %rsi      # 0x3d8f1
leaq -0xc0(%rbp), %rdi
callq 0x17fe0
jmp 0x3a335
leaq -0x312c(%rip), %rsi     # 0x37210
leaq -0xd0(%rbp), %rdi
callq 0x33500
jmp 0x3a34a
leaq -0xc8(%rbp), %rdi
movq %rdi, -0x160(%rbp)
leaq -0xd0(%rbp), %rsi
callq 0xbd50
movq -0x158(%rbp), %rdi
movq -0x160(%rbp), %rdx
leaq -0xc0(%rbp), %rsi
callq 0xbaa0
jmp 0x3a380
leaq -0xc8(%rbp), %rdi
callq 0xb9d0
leaq -0xd0(%rbp), %rdi
callq 0x33560
leaq -0xc0(%rbp), %rdi
callq 0xb9d0
leaq -0x70(%rbp), %rdi
callq 0xba80
movq %rax, -0x168(%rbp)
leaq 0x353c(%rip), %rsi      # 0x3d8f7
leaq -0xd8(%rbp), %rdi
callq 0x17fe0
jmp 0x3a3c9
leaq -0x2e60(%rip), %rsi     # 0x37570
leaq -0xe8(%rbp), %rdi
callq 0x33500
jmp 0x3a3de
leaq -0xe0(%rbp), %rdi
movq %rdi, -0x170(%rbp)
leaq -0xe8(%rbp), %rsi
callq 0xbd50
movq -0x168(%rbp), %rdi
movq -0x170(%rbp), %rdx
leaq -0xd8(%rbp), %rsi
callq 0xbaa0
jmp 0x3a414
leaq -0xe0(%rbp), %rdi
callq 0xb9d0
leaq -0xe8(%rbp), %rdi
callq 0x33560
leaq -0xd8(%rbp), %rdi
callq 0xb9d0
leaq -0x100(%rbp), %rdi
movq %rdi, -0x178(%rbp)
leaq -0x70(%rbp), %rsi
callq 0xf830
movq -0x178(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0xb880
jmp 0x3a464
leaq -0x100(%rbp), %rdi
callq 0xb8e0
leaq -0x108(%rbp), %rdi
leaq -0x40(%rbp), %rsi
leaq -0xf0(%rbp), %rdx
callq 0x27080
jmp 0x3a489
leaq -0x108(%rbp), %rdi
callq 0xb9d0
leaq -0xf0(%rbp), %rdi
callq 0xc060
leaq -0x70(%rbp), %rdi
callq 0xb8e0
leaq -0x40(%rbp), %rdi
callq 0xb9d0
leaq -0x20(%rbp), %rdi
callq 0x8878
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x21(%rbp), %rdi
callq 0x8490
jmp 0x3a6d5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x3a6cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x3a6c3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x58(%rbp), %rdi
callq 0xb8e0
testb $0x1, -0x59(%rbp)
jne 0x3a51e
jmp 0x3a52f
movq -0x118(%rbp), %rdi
movl $0x48, %esi
callq 0x8420
jmp 0x3a6c3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x3a6ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x3a574
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x80(%rbp), %rdi
callq 0xb9d0
leaq -0x88(%rbp), %rdi
callq 0x33560
leaq -0x78(%rbp), %rdi
callq 0xb9d0
jmp 0x3a6ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x3a5b4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x98(%rbp), %rdi
callq 0xb9d0
leaq -0xa0(%rbp), %rdi
callq 0x33560
leaq -0x90(%rbp), %rdi
callq 0xb9d0
jmp 0x3a6ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x3a5f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0xb9d0
leaq -0xb8(%rbp), %rdi
callq 0x33560
leaq -0xa8(%rbp), %rdi
callq 0xb9d0
jmp 0x3a6ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x3a63a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0xb9d0
leaq -0xd0(%rbp), %rdi
callq 0x33560
leaq -0xc0(%rbp), %rdi
callq 0xb9d0
jmp 0x3a6ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x3a67a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0xb9d0
leaq -0xe8(%rbp), %rdi
callq 0x33560
leaq -0xd8(%rbp), %rdi
callq 0xb9d0
jmp 0x3a6ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x100(%rbp), %rdi
callq 0xb8e0
jmp 0x3a6ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0xc060
leaq -0x70(%rbp), %rdi
callq 0xb8e0
leaq -0x40(%rbp), %rdi
callq 0xb9d0
leaq -0x20(%rbp), %rdi
callq 0x8878
movq -0x30(%rbp), %rdi
callq 0x87b0
nop