// File: /workspace/github_cpp_makefile_star2_O2/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 0x7774
movq (%r14), %rax
pushq $0x1
popq %rsi
movq %r14, %rdi
callq *0x18(%rax)
cmpl $0x10, 0x8(%rax)
jne 0x77cb
movq (%r14), %rax
movq %r14, %rdi
xorl %esi, %esi
callq *0x18(%rax)
leaq 0x58(%rax), %rsi
leaq -0x78(%rbp), %r15
movq %r15, %rdi
callq 0xb24a
leaq -0x88(%rbp), %rax
movq %rax, -0x10(%rax)
movq (%r15), %rcx
leaq -0x68(%rbp), %r15
cmpq %r15, %rcx
je 0x7507
movq %rcx, -0x98(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x750e
movups (%r15), %xmm0
movups %xmm0, (%rax)
leaq -0x78(%rbp), %rdi
movq 0x8(%rdi), %rax
movq %rax, -0x90(%rbp)
movq %r15, (%rdi)
andq $0x0, 0x8(%rdi)
movb $0x0, 0x10(%rdi)
callq 0x135f8
movq (%r14), %rax
pushq $0x1
popq %rsi
movq %r14, %rdi
callq *0x18(%rax)
addq $0x58, %rax
leaq -0x78(%rbp), %rdi
movq %rax, %rsi
callq 0xb24a
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
movq -0x78(%rbp), %rcx
cmpq %r15, %rcx
je 0x7569
movq %rcx, -0x48(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x7570
movups (%r15), %xmm0
movups %xmm0, (%rax)
leaq -0x78(%rbp), %rdi
movq 0x8(%rdi), %rax
movq %rax, -0x40(%rbp)
movq %r15, (%rdi)
andq $0x0, 0x8(%rdi)
movb $0x0, 0x10(%rdi)
callq 0x135f8
leaq -0xd8(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x32f0
leaq -0xd8(%rbp), %rdi
callq 0x7909
movl %eax, %r15d
leaq -0xd8(%rbp), %rdi
callq 0x3110
leaq 0x18(%rbx), %rdi
leaq 0xdd89(%rip), %rsi      # 0x1534f
callq 0x3230
leaq -0x48(%rbp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0xda27(%rip), %rsi      # 0x15005
movq %rax, %rdi
callq 0x3230
movq %rax, %r12
leaq -0xb8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x32f0
leaq 0x530(%rbx), %rdi
leaq -0xb8(%rbp), %rsi
movl %r15d, %edx
callq 0xac26
movl %eax, %esi
movq %r12, %rdi
callq 0x3180
leaq 0xdec3(%rip), %rsi      # 0x154e3
movq %rax, %rdi
callq 0x3230
leaq -0xb8(%rbp), %rdi
callq 0x3110
movq 0x18(%r14), %rax
subq 0x10(%r14), %rax
cmpq $0x18, %rax
jne 0x774d
movq (%r14), %rax
pushq $0x2
popq %rsi
movq %r14, %rdi
callq *0x18(%rax)
cmpl $0x6, 0x8(%rax)
jne 0x781f
movq (%r14), %rax
pushq $0x2
popq %rsi
movq %r14, %rdi
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 0x73e0
addq $0x1a0, %rbx            # imm = 0x1A0
leaq 0xdce0(%rip), %rsi      # 0x15373
movq %rbx, %rdi
callq 0x3230
leaq -0x48(%rbp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0xde35(%rip), %rsi      # 0x154e3
movq %rax, %rdi
callq 0x3230
leaq 0xdcc0(%rip), %rsi      # 0x1537d
movq %rax, %rdi
callq 0x3230
leaq -0x48(%rbp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0xde0b(%rip), %rsi      # 0x154e3
movq %rax, %rdi
callq 0x3230
leaq 0xdc9e(%rip), %rsi      # 0x15385
movq %rax, %rdi
callq 0x3230
movl %r15d, %r13d
leaq 0xdcb2(%rip), %r14      # 0x153ab
leaq 0xdcb3(%rip), %r15      # 0x153b3
leaq 0xdcb9(%rip), %r12      # 0x153c0
testq %r13, %r13
je 0x773e
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3230
movq %rax, %rdi
movq %r15, %rsi
callq 0x3230
leal -0x1(%r13), %esi
movq %rax, %rdi
callq 0x3180
movq %rax, %rdi
movq %r12, %rsi
callq 0x3230
decq %r13
jmp 0x7707
leaq 0xdd9e(%rip), %rsi      # 0x154e3
movq %rbx, %rdi
callq 0x3230
leaq -0x48(%rbp), %rdi
callq 0x3110
leaq -0x98(%rbp), %rdi
callq 0x3110
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x50
popq %rdi
callq 0x3140
movq %rax, %r14
leaq 0xdb73(%rip), %rsi      # 0x152f9
leaq -0x138(%rbp), %rdi
leaq -0x78(%rbp), %rdx
callq 0x3be4
movb $0x1, %r15b
pushq $-0x1
popq %rdx
leaq -0x138(%rbp), %rcx
movq %r14, %rdi
movl %edx, %esi
callq 0x4e88
xorl %r15d, %r15d
leaq 0x165d9(%rip), %rsi     # 0x1dd90
leaq -0x2886(%rip), %rdx     # 0x4f38
movq %r14, %rdi
callq 0x33f0
jmp 0x7871
pushq $0x50
popq %rdi
callq 0x3140
movq %rax, %r14
leaq 0xdb41(%rip), %rsi      # 0x1531e
leaq -0x118(%rbp), %rdi
leaq -0x78(%rbp), %rdx
callq 0x3be4
movb $0x1, %r15b
pushq $-0x1
popq %rdx
leaq -0x118(%rbp), %rcx
movq %r14, %rdi
movl %edx, %esi
callq 0x4e88
xorl %r15d, %r15d
leaq 0x16582(%rip), %rsi     # 0x1dd90
leaq -0x28dd(%rip), %rdx     # 0x4f38
movq %r14, %rdi
callq 0x33f0
jmp 0x7871
pushq $0x50
popq %rdi
callq 0x3140
movq %rax, %r14
leaq 0xdb27(%rip), %rsi      # 0x15358
leaq -0xf8(%rbp), %rdi
leaq -0x78(%rbp), %rdx
callq 0x3be4
movb $0x1, %r15b
pushq $-0x1
popq %rdx
leaq -0xf8(%rbp), %rcx
movq %r14, %rdi
movl %edx, %esi
callq 0x4e88
xorl %r15d, %r15d
leaq 0x1652e(%rip), %rsi     # 0x1dd90
leaq -0x2931(%rip), %rdx     # 0x4f38
movq %r14, %rdi
callq 0x33f0
movq %rax, %rbx
leaq -0xf8(%rbp), %rdi
callq 0x3110
testb %r15b, %r15b
jne 0x788a
jmp 0x78ec
movq %rax, %rbx
movq %r14, %rdi
callq 0x31b0
jmp 0x78ec
movq %rax, %rbx
leaq -0x118(%rbp), %rdi
jmp 0x78ac
jmp 0x78b8
movq %rax, %rbx
leaq -0x138(%rbp), %rdi
callq 0x3110
testb %r15b, %r15b
jne 0x78bb
jmp 0x7901
movq %rax, %rbx
movq %r14, %rdi
callq 0x31b0
jmp 0x7901
movq %rax, %rbx
leaq -0xd8(%rbp), %rdi
jmp 0x78e0
movq %rax, %rbx
jmp 0x78f5
movq %rax, %rbx
leaq -0xb8(%rbp), %rdi
callq 0x3110
jmp 0x78ec
jmp 0x78e9
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x3110
leaq -0x98(%rbp), %rdi
callq 0x3110
movq %rbx, %rdi
callq 0x3410