// File: RuiDGPires[P]CrimLang/src/generator.cpp
// Function: crl::generate_cas(crl::Node*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void generate_cas(Ast *ast, std::string filename){
	std::ofstream file;
	file.open(filename);

	ASSERT(ast->type == Node::Type::NONE, "Invalid type");
	ASSERT(ast->children.size() == 1, "Invalid size");

	ast = ast->get_child(0); // Program

	_gc_Tracker tracker(&file);


	tracker.parse_node(ast);

	file.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x860, %rsp            # imm = 0x860
movq %rsi, -0x830(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x210(%rbp), %rdi
movq %rdi, -0x838(%rbp)
callq 0x4540
movq -0x838(%rbp), %rdi
movq -0x830(%rbp), %rsi
movl $0x10, %edx
callq 0x4180
jmp 0x12c27
movq -0x8(%rbp), %rax
cmpl $0x0, 0x8(%rax)
je 0x12d2f
movb $0x1, -0x242(%rbp)
movl $0x50, %edi
callq 0x4190
movq %rax, -0x848(%rbp)
leaq -0x241(%rbp), %rdi
movq %rdi, -0x840(%rbp)
callq 0x4590
movq -0x840(%rbp), %rdx
leaq 0x189eb(%rip), %rsi     # 0x2b659
leaq -0x240(%rbp), %rdi
callq 0x52e0
jmp 0x12c7c
movq -0x848(%rbp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
leaq -0x240(%rbp), %rcx
movl %edx, %esi
callq 0x9140
jmp 0x12c98
movq -0x848(%rbp), %rdi
movb $0x0, -0x242(%rbp)
leaq 0x270d3(%rip), %rsi     # 0x39d80
leaq -0x99a4(%rip), %rdx     # 0x9310
callq 0x4550
jmp 0x12ed8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x12ec0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x12d07
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
leaq -0x240(%rbp), %rdi
callq 0x41e0
leaq -0x241(%rbp), %rdi
callq 0x4360
testb $0x1, -0x242(%rbp)
jne 0x12d1e
jmp 0x12d2a
movq -0x848(%rbp), %rdi
callq 0x4230
jmp 0x12ec0
movq -0x8(%rbp), %rdi
addq $0x10, %rdi
callq 0x51d0
cmpq $0x1, %rax
je 0x12e29
movb $0x1, -0x26a(%rbp)
movl $0x50, %edi
callq 0x4190
movq %rax, -0x858(%rbp)
leaq -0x269(%rbp), %rdi
movq %rdi, -0x850(%rbp)
callq 0x4590
movq -0x850(%rbp), %rdx
leaq 0x188e7(%rip), %rsi     # 0x2b666
leaq -0x268(%rbp), %rdi
callq 0x52e0
jmp 0x12d8d
movq -0x858(%rbp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
leaq -0x268(%rbp), %rcx
movl %edx, %esi
callq 0x9140
jmp 0x12da9
movq -0x858(%rbp), %rdi
movb $0x0, -0x26a(%rbp)
leaq 0x26fc2(%rip), %rsi     # 0x39d80
leaq -0x9ab5(%rip), %rdx     # 0x9310
callq 0x4550
jmp 0x12ed8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x12e01
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
leaq -0x268(%rbp), %rdi
callq 0x41e0
leaq -0x269(%rbp), %rdi
callq 0x4360
testb $0x1, -0x26a(%rbp)
jne 0x12e18
jmp 0x12e24
movq -0x858(%rbp), %rdi
callq 0x4230
jmp 0x12ec0
movq -0x8(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
xorl %esi, %esi
callq *%rax
movq %rax, -0x860(%rbp)
jmp 0x12e41
movq -0x860(%rbp), %rax
movq %rax, -0x8(%rbp)
leaq -0x828(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x13a70
jmp 0x12e61
movq -0x8(%rbp), %rsi
leaq -0x828(%rbp), %rdi
callq 0x12630
jmp 0x12e73
leaq -0x210(%rbp), %rdi
callq 0x4460
jmp 0x12e81
leaq -0x828(%rbp), %rdi
callq 0x13be0
leaq -0x210(%rbp), %rdi
callq 0x4490
addq $0x860, %rsp            # imm = 0x860
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
leaq -0x828(%rbp), %rdi
callq 0x13be0
leaq -0x210(%rbp), %rdi
callq 0x4490
movq -0x218(%rbp), %rdi
callq 0x4580
nopl (%rax,%rax)