// File: /workspace/github_cpp_makefile_star2_O3/RuiDGPires[P]CrimLang/src/generator.cpp
// Function: gc_Tracker::declaration_var(crl::Node*)
void _gc_Tracker::declaration_var(crl::Node *node){
	ASSERT(node->get_child(0)->type == crl::Node::Type::LEAF, "Var declaration must start with type");
	ASSERT(node->get_child(1)->type == crl::Node::Type::LEAF, "Var declaration must have a name as second token");
	std::string type = get_token(node->get_child(0)).str;
	std::string name = get_token(node->get_child(1)).str;


	u32 size = size_of(type);

	this->stream_defines << "%define " << name << " " << symb_tracker.global_create(name, size) << "\n";

	if (node->children.size() == 3){
		ASSERT(node->get_child(2)->type == crl::Node::Type::ASSIGN, "Third child must be assign");
		this->expression(node->get_child(2)->get_child(0), this->stream_global_vars);
		this->stream_global_vars << 
			"; Global " << name << "\n" << 
			"MVI R1 " << name << "\n" <<
			"; Pop the result from the expression\n";
		for (u32 i = 0; i < size; i++)
				this->stream_global_vars <<
				"POP R2\n" <<
				"STORE m[R1][" << size - i - 1<< "] R2\n";
		this->stream_global_vars << "\n";
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rax
movq %rsi, %rdi
xorl %esi, %esi
callq *0x18(%rax)
cmpl $0x10, 0x8(%rax)
jne 0x915c
movq (%r14), %rax
movq %r14, %rdi
movl $0x1, %esi
callq *0x18(%rax)
cmpl $0x10, 0x8(%rax)
jne 0x91c8
movq (%r14), %rax
movq %r14, %rdi
xorl %esi, %esi
callq *0x18(%rax)
movq %rax, %r15
leaq -0xc8(%rbp), %r13
movq %r13, -0x10(%r13)
movq 0x58(%rax), %rsi
movq 0x60(%rax), %rdx
addq %rsi, %rdx
leaq -0xd8(%rbp), %r12
movq %r12, %rdi
callq 0x4d52
movl 0x80(%r15), %eax
movl %eax, 0x28(%r12)
movq 0x78(%r15), %rax
movq %rax, 0x20(%r12)
leaq -0x58(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq (%r12), %rax
cmpq %r13, %rax
je 0x8e0b
movq %rax, -0x68(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0x8e13
movups (%r13), %xmm0
movups %xmm0, (%rcx)
leaq -0xd8(%rbp), %rdi
movq 0x8(%rdi), %rax
movq %rax, -0x60(%rbp)
movq %r13, (%rdi)
movq $0x0, 0x8(%rdi)
movb $0x0, 0x10(%rdi)
callq 0x191f8
movq (%r14), %rax
movq %r14, %rdi
movl $0x1, %esi
callq *0x18(%rax)
movq %rax, %r15
leaq -0xd8(%rbp), %rdi
movq %r13, (%rdi)
movq 0x58(%rax), %rsi
movq 0x60(%rax), %rdx
addq %rsi, %rdx
callq 0x4d52
movl 0x80(%r15), %eax
movl %eax, -0xb0(%rbp)
movq 0x78(%r15), %rax
movq %rax, -0xb8(%rbp)
leaq -0x38(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq -0xd8(%rbp), %rax
cmpq %r13, %rax
je 0x8e9e
movq %rax, -0x48(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x8ea6
movups (%r13), %xmm0
movups %xmm0, (%rcx)
leaq -0xd8(%rbp), %rdi
movq 0x8(%rdi), %rax
movq %rax, -0x40(%rbp)
movq %r13, (%rdi)
movq $0x0, 0x8(%rdi)
movb $0x0, 0x10(%rdi)
callq 0x191f8
leaq -0x98(%rbp), %r12
movq %r12, -0x10(%r12)
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
addq %rsi, %rdx
leaq -0xa8(%rbp), %rdi
callq 0x4d52
leaq -0xa8(%rbp), %rdi
callq 0x9395
movl %eax, %r15d
movq -0xa8(%rbp), %rdi
cmpq %r12, %rdi
je 0x8f16
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x3230
leaq 0x18(%rbx), %r12
leaq 0x1242e(%rip), %rsi     # 0x1b34f
movl $0x8, %edx
movq %r12, %rdi
callq 0x3280
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %r12, %rdi
callq 0x3280
movq %rax, %r12
leaq 0x120bd(%rip), %rsi     # 0x1b005
movl $0x1, %edx
movq %rax, %rdi
callq 0x3280
leaq -0x78(%rbp), %r13
movq %r13, -0x10(%r13)
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
addq %rsi, %rdx
leaq -0x88(%rbp), %rdi
callq 0x4d52
leaq 0x530(%rbx), %rdi
leaq -0x88(%rbp), %rsi
movl %r15d, %edx
callq 0xdea8
movl %eax, %esi
movq %r12, %rdi
callq 0x3170
leaq 0x12548(%rip), %rsi     # 0x1b4e3
movl $0x1, %edx
movq %rax, %rdi
callq 0x3280
movq -0x88(%rbp), %rdi
cmpq %r13, %rdi
je 0x8fc0
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x3230
movq 0x18(%r14), %rax
subq 0x10(%r14), %rax
cmpq $0x18, %rax
jne 0x9118
movq (%r14), %rax
movq %r14, %rdi
movl $0x2, %esi
callq *0x18(%rax)
cmpl $0x6, 0x8(%rax)
jne 0x9231
movq (%r14), %rax
movq %r14, %rdi
movl $0x2, %esi
callq *0x18(%rax)
movq (%rax), %rcx
movq %rax, %rdi
xorl %esi, %esi
callq *0x18(%rcx)
leaq 0x190(%rbx), %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x8c5c
addq $0x1a0, %rbx            # imm = 0x1A0
leaq 0x12350(%rip), %rsi     # 0x1b373
movl $0x9, %edx
movq %rbx, %rdi
callq 0x3280
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %rbx, %rdi
callq 0x3280
movq %rax, %r14
leaq 0x12499(%rip), %rsi     # 0x1b4e3
movl $0x1, %edx
movq %rax, %rdi
callq 0x3280
leaq 0x1231f(%rip), %rsi     # 0x1b37d
movl $0x7, %edx
movq %r14, %rdi
callq 0x3280
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %r14, %rdi
callq 0x3280
movq %rax, %r14
leaq 0x1245e(%rip), %rsi     # 0x1b4e3
movl $0x1, %edx
movq %rax, %rdi
callq 0x3280
leaq 0x122ec(%rip), %rsi     # 0x1b385
movl $0x25, %edx
movq %r14, %rdi
callq 0x3280
testl %r15d, %r15d
je 0x9104
movl %r15d, %r13d
leaq 0x122f6(%rip), %r14     # 0x1b3ab
leaq 0x122f7(%rip), %r15     # 0x1b3b3
leaq 0x122fd(%rip), %r12     # 0x1b3c0
movl $0x7, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3280
movl $0xc, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3280
leal -0x1(%r13), %esi
movq %rbx, %rdi
callq 0x3170
movl $0x5, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x3280
decq %r13
jne 0x90c3
leaq 0x123d8(%rip), %rsi     # 0x1b4e3
movl $0x1, %edx
movq %rbx, %rdi
callq 0x3280
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x9131
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3230
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x914a
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x3230
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x50, %edi
callq 0x3120
movq %rax, %r14
leaq -0x128(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x1217e(%rip), %rsi     # 0x1b2f9
leaq 0x1219b(%rip), %rdx     # 0x1b31d
leaq -0x138(%rbp), %rdi
callq 0x4336
movb $0x1, %r12b
leaq -0x138(%rbp), %rcx
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x5470
xorl %r12d, %r12d
leaq 0x19bc4(%rip), %rsi     # 0x22d78
leaq -0x3bd5(%rip), %rdx     # 0x55e6
movq %r14, %rdi
callq 0x33d0
jmp 0x9298
movl $0x50, %edi
callq 0x3120
movq %rax, %r14
leaq -0x108(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x12137(%rip), %rsi     # 0x1b31e
leaq 0x12160(%rip), %rdx     # 0x1b34e
leaq -0x118(%rbp), %rdi
callq 0x4336
movb $0x1, %r12b
leaq -0x118(%rbp), %rcx
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x5470
xorl %r12d, %r12d
leaq 0x19b58(%rip), %rsi     # 0x22d78
leaq -0x3c41(%rip), %rdx     # 0x55e6
movq %r14, %rdi
callq 0x33d0
jmp 0x9298
movl $0x50, %edi
callq 0x3120
movq %rax, %r14
leaq -0xe8(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x12108(%rip), %rsi     # 0x1b358
leaq 0x1211b(%rip), %rdx     # 0x1b372
leaq -0xf8(%rbp), %rdi
callq 0x4336
movb $0x1, %r12b
leaq -0xf8(%rbp), %rcx
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x5470
xorl %r12d, %r12d
leaq 0x19aef(%rip), %rsi     # 0x22d78
leaq -0x3caa(%rip), %rdx     # 0x55e6
movq %r14, %rdi
callq 0x33d0
movq %rax, %rbx
movq -0xf8(%rbp), %rdi
cmpq %r15, %rdi
je 0x92b6
movq -0xe8(%rbp), %rsi
incq %rsi
callq 0x3230
testb %r12b, %r12b
jne 0x92c3
jmp 0x935b
movq %rax, %rbx
movq %r14, %rdi
callq 0x31a0
jmp 0x935b
movq %rax, %rbx
movq -0x118(%rbp), %rdi
cmpq %r15, %rdi
je 0x9308
movq -0x108(%rbp), %rsi
jmp 0x9300
jmp 0x930f
movq %rax, %rbx
movq -0x138(%rbp), %rdi
cmpq %r15, %rdi
je 0x9308
movq -0x128(%rbp), %rsi
incq %rsi
callq 0x3230
testb %r12b, %r12b
jne 0x9312
jmp 0x938d
movq %rax, %rbx
movq %r14, %rdi
callq 0x31a0
jmp 0x938d
movq %rax, %rbx
movq -0xa8(%rbp), %rdi
cmpq %r12, %rdi
je 0x935b
movq -0x98(%rbp), %rsi
jmp 0x934c
movq %rax, %rbx
jmp 0x9374
movq %rax, %rbx
movq -0x88(%rbp), %rdi
cmpq %r13, %rdi
je 0x935b
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x3230
jmp 0x935b
jmp 0x9358
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x9374
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3230
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x938d
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x3230
movq %rbx, %rdi
callq 0x33f0