// File: /workspace/github_cpp_makefile_star2_O2/RuiDGPires[P]CrimLang/src/generator.cpp
// Function: gc_Tracker::assign(crl::Node*)
void _gc_Tracker::assign(crl::Node *node){
	std::string op;
	if (node->annotation == "plus")
		op = "ADD";
	else if	(node->annotation == "minus")
		op = "SUB";
	else if	(node->annotation == "times")
		op = "MUL";
	else if	(node->annotation == "slash")
		op = "DIV";
	
	if (op != "") {
		this->assign_op(node, op);
		return;
	}
	u32 reg1 = reg_tracker.alloc();
	std::string name1 = reg_tracker.reg_name(reg1);

	u32 reg2 = this->expression_reg(node->get_child(1), stream_funcs);
	std::string name2 = reg_tracker.reg_name(reg2);

	crl::Token t;	
	if (node->get_child(0)->type == crl::Node::Type::VECTOR){
		t = get_token(node->get_child(0)->get_child(0));
		u32 reg_aux = reg_tracker.alloc();
		std::string name_aux = reg_tracker.reg_name(reg_aux);

		u32 offset = atoi(get_token(node->get_child(0)->get_child(1)).str.c_str());

		if (symb_tracker.has_local(t.str)){
			std::pair<u32, bool> p = symb_tracker.get_local(t.str);

			if (p.second)
				stream_funcs <<
				"LOAD " << name1 << " m[RF][-" << p.first  << "]\n" <<
				"MVI " << name_aux << " " << offset << "\n" <<
				"ADD " << name1 << " " << name_aux << "\n" <<
				"STORE m[" << name1 << "] " << name2 << "\n";
			else
				stream_funcs <<
					"STORE m[RF][-" << p.first + offset << "] " << name2 << "\n";
		}else
			stream_funcs <<
				"MVI " << name1 << " " << t.str << "\n" <<
				"MVI " << name_aux << " " << offset << "\n" <<
				"ADD " << name1 << " " << name_aux << "\n" <<
				"STORE m[" << name1 << "] " << name2 << "\n";
		
		reg_tracker.free(reg1);
		reg_tracker.free(reg2);
		reg_tracker.free(reg_aux);
		return;
	}
	
	t = get_token(node->get_child(0));
	if (symb_tracker.has_local(t.str)){
		std::pair<u32, bool> p = symb_tracker.get_local(t.str);

		if (p.second)
			stream_funcs <<
				"LOAD " << name1 << " m[RF][-" << p.first  << "]\n" <<
				"STORE m[" << name1 << "] " << name2 << "\n";
		else
			stream_funcs <<
				"STORE m[RF][-" << p.first << "] " << name2 << "\n";
	}else{
		stream_funcs << "MVI " << name1 << " " << t.str << "\n" <<
			"STORE m[" << name1 << "] " << name2 << "\n";
	}
	
	reg_tracker.free(reg1);
	reg_tracker.free(reg2);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
leaq -0x108(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movq %rsi, %r12
movq %rdi, %r13
movb $0x0, (%rax)
leaq 0x30(%rsi), %rbx
leaq 0xc16e(%rip), %rsi      # 0x155a8
movq %rbx, %rdi
callq 0x410a
testb %al, %al
je 0x944f
leaq 0xc160(%rip), %rsi      # 0x155ad
jmp 0x94a1
leaq 0xc15b(%rip), %rsi      # 0x155b1
movq %rbx, %rdi
callq 0x410a
testb %al, %al
je 0x946b
leaq 0xc14e(%rip), %rsi      # 0x155b7
jmp 0x94a1
leaq 0xc149(%rip), %rsi      # 0x155bb
movq %rbx, %rdi
callq 0x410a
testb %al, %al
je 0x9487
leaq 0xc13c(%rip), %rsi      # 0x155c1
jmp 0x94a1
leaq 0xc137(%rip), %rsi      # 0x155c5
movq %rbx, %rdi
callq 0x410a
testb %al, %al
je 0x94ad
leaq 0xc12a(%rip), %rsi      # 0x155cb
leaq -0x118(%rbp), %rdi
callq 0x3450
leaq 0xc030(%rip), %rsi      # 0x154e4
leaq -0x118(%rbp), %rdi
callq 0x3c1f
testb %al, %al
je 0x94f5
leaq -0x1b8(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x32f0
leaq -0x1b8(%rbp), %rdx
movq %r13, %rdi
movq %r12, %rsi
callq 0x9c4c
leaq -0x1b8(%rbp), %rdi
jmp 0x9b69
leaq 0x500(%r13), %rbx
movq %rbx, %rdi
callq 0xaa6c
leaq -0x58(%rbp), %rdi
movq %rbx, %rsi
movl %eax, -0x30(%rbp)
movl %eax, %edx
callq 0xab34
movq (%r12), %rax
pushq $0x1
popq %rsi
movq %r12, %rdi
callq *0x18(%rax)
leaq 0x318(%r13), %rdx
movq %r13, %rdi
movq %rax, %rsi
callq 0x586e
leaq -0xc8(%rbp), %rdi
movq %rbx, %rsi
movl %eax, -0x2c(%rbp)
movl %eax, %edx
callq 0xab34
leaq -0x88(%rbp), %rdi
callq 0x135b0
movq (%r12), %rax
movq %r12, %rdi
xorl %esi, %esi
callq *0x18(%rax)
cmpl $0x19, 0x8(%rax)
jne 0x96ba
movq (%r12), %rax
movq %r12, %rdi
xorl %esi, %esi
callq *0x18(%rax)
movq (%rax), %rcx
movq %rax, %rdi
xorl %esi, %esi
callq *0x18(%rcx)
addq $0x58, %rax
leaq -0xf8(%rbp), %rdi
movq %rax, %rsi
callq 0xb24a
leaq -0x88(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x3df4
leaq -0xf8(%rbp), %rdi
callq 0x135f8
movq %rbx, %rdi
callq 0xaa6c
leaq -0xa8(%rbp), %rdi
movq %rbx, %rsi
movl %eax, -0x34(%rbp)
movl %eax, %edx
callq 0xab34
movq (%r12), %rax
movq %r12, %rdi
xorl %esi, %esi
callq *0x18(%rax)
movq (%rax), %rcx
pushq $0x1
popq %rsi
movq %rax, %rdi
callq *0x18(%rcx)
addq $0x58, %rax
leaq -0xf8(%rbp), %rdi
movq %rax, %rsi
callq 0xb24a
leaq -0xf8(%rbp), %r14
movq (%r14), %rdi
callq 0x3350
movl %eax, %r12d
movq %r14, %rdi
callq 0x135f8
leaq -0x198(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x32f0
leaq 0x530(%r13), %r14
leaq -0x198(%rbp), %rsi
movq %r14, %rdi
callq 0xabb4
movl %eax, %r15d
leaq -0x198(%rbp), %rdi
callq 0x3110
testb %r15b, %r15b
je 0x9833
leaq -0x178(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x32f0
leaq -0x178(%rbp), %rsi
movq %r14, %rdi
callq 0xabee
movq %rax, %r14
leaq -0x178(%rbp), %rdi
callq 0x3110
addq $0x328, %r13            # imm = 0x328
btq $0x20, %r14
jb 0x9a05
leaq 0xbf3c(%rip), %rsi      # 0x155db
movq %r13, %rdi
callq 0x3230
addl %r14d, %r12d
movq %rax, %rdi
movq %r12, %rsi
callq 0x3180
jmp 0x9af3
movq (%r12), %rax
movq %r12, %rdi
xorl %esi, %esi
callq *0x18(%rax)
addq $0x58, %rax
leaq -0xf8(%rbp), %rdi
movq %rax, %rsi
callq 0xb24a
leaq -0x88(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x3df4
leaq -0xf8(%rbp), %rdi
callq 0x135f8
leaq -0x158(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x32f0
leaq 0x530(%r13), %r14
leaq -0x158(%rbp), %rsi
movq %r14, %rdi
callq 0xabb4
movl %eax, %r12d
leaq -0x158(%rbp), %rdi
callq 0x3110
testb %r12b, %r12b
je 0x9797
leaq -0x138(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x32f0
leaq -0x138(%rbp), %rsi
movq %r14, %rdi
callq 0xabee
movq %rax, %r14
leaq -0x138(%rbp), %rdi
callq 0x3110
addq $0x328, %r13            # imm = 0x328
btq $0x20, %r14
jb 0x995e
leaq 0xbe5c(%rip), %rsi      # 0x155db
movq %r13, %rdi
callq 0x3230
movl %r14d, %esi
movq %rax, %rdi
callq 0x3180
jmp 0x99bd
addq $0x328, %r13            # imm = 0x328
leaq 0xbaa4(%rip), %rsi      # 0x15249
movq %r13, %rdi
callq 0x3230
leaq -0x58(%rbp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0xb845(%rip), %rsi      # 0x15005
movq %rax, %rdi
callq 0x3230
leaq -0x88(%rbp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0xbd05(%rip), %rsi      # 0x154e3
movq %rax, %rdi
callq 0x3230
leaq 0xbde2(%rip), %rsi      # 0x155cf
movq %rax, %rdi
callq 0x3230
leaq -0x58(%rbp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0xbdd0(%rip), %rsi      # 0x155d8
movq %rax, %rdi
callq 0x3230
leaq -0xc8(%rbp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0xbcbd(%rip), %rsi      # 0x154e3
movq %rax, %rdi
callq 0x3230
jmp 0x99ea
addq $0x328, %r13            # imm = 0x328
leaq 0xba08(%rip), %rsi      # 0x15249
movq %r13, %rdi
callq 0x3230
leaq -0x58(%rbp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0xb7a9(%rip), %rsi      # 0x15005
movq %rax, %rdi
callq 0x3230
leaq -0x88(%rbp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0xbc69(%rip), %rsi      # 0x154e3
movq %rax, %rdi
callq 0x3230
leaq 0xb9c0(%rip), %rsi      # 0x15249
movq %rax, %rdi
callq 0x3230
leaq -0xa8(%rbp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0xb75e(%rip), %rsi      # 0x15005
movq %rax, %rdi
callq 0x3230
movl %r12d, %esi
movq %rax, %rdi
callq 0x3180
leaq 0xbc22(%rip), %rsi      # 0x154e3
movq %rax, %rdi
callq 0x3230
leaq 0xb9f9(%rip), %rsi      # 0x152c9
movq %rax, %rdi
callq 0x3230
leaq -0x58(%rbp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0xb71a(%rip), %rsi      # 0x15005
movq %rax, %rdi
callq 0x3230
leaq -0xa8(%rbp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0xbbda(%rip), %rsi      # 0x154e3
movq %rax, %rdi
callq 0x3230
leaq 0xbcb7(%rip), %rsi      # 0x155cf
movq %rax, %rdi
callq 0x3230
leaq -0x58(%rbp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0xbca5(%rip), %rsi      # 0x155d8
movq %rax, %rdi
callq 0x3230
leaq -0xc8(%rbp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0xbb92(%rip), %rsi      # 0x154e3
movq %rax, %rdi
callq 0x3230
jmp 0x9b20
leaq 0xb8db(%rip), %rsi      # 0x15240
movq %r13, %rdi
callq 0x3230
leaq -0x58(%rbp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0xbc60(%rip), %rsi      # 0x155e0
movq %rax, %rdi
callq 0x3230
movl %r14d, %esi
movq %rax, %rdi
callq 0x3180
leaq 0xb8ac(%rip), %rsi      # 0x15246
movq %rax, %rdi
callq 0x3230
leaq 0xbc26(%rip), %rsi      # 0x155cf
movq %rax, %rdi
callq 0x3230
leaq -0x58(%rbp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0xbc14(%rip), %rsi      # 0x155d8
movq %rax, %rdi
callq 0x3230
leaq -0xc8(%rbp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0xbb01(%rip), %rsi      # 0x154e3
movq %rax, %rdi
callq 0x3230
movq %rbx, %rdi
movl -0x30(%rbp), %esi
callq 0xac12
movq %rbx, %rdi
movl -0x2c(%rbp), %esi
callq 0xac12
jmp 0x9b4d
leaq 0xb834(%rip), %rsi      # 0x15240
movq %r13, %rdi
callq 0x3230
leaq -0x58(%rbp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0xbbb9(%rip), %rsi      # 0x155e0
movq %rax, %rdi
callq 0x3230
movl %r14d, %esi
movq %rax, %rdi
callq 0x3180
leaq 0xb805(%rip), %rsi      # 0x15246
movq %rax, %rdi
callq 0x3230
leaq 0xb7f9(%rip), %rsi      # 0x15249
movq %rax, %rdi
callq 0x3230
leaq -0xa8(%rbp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0xb597(%rip), %rsi      # 0x15005
movq %rax, %rdi
callq 0x3230
movl %r12d, %esi
movq %rax, %rdi
callq 0x3180
leaq 0xba5b(%rip), %rsi      # 0x154e3
movq %rax, %rdi
callq 0x3230
leaq 0xb832(%rip), %rsi      # 0x152c9
movq %rax, %rdi
callq 0x3230
leaq -0x58(%rbp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0xb553(%rip), %rsi      # 0x15005
movq %rax, %rdi
callq 0x3230
leaq -0xa8(%rbp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0xba13(%rip), %rsi      # 0x154e3
movq %rax, %rdi
callq 0x3230
leaq 0xbaf0(%rip), %rsi      # 0x155cf
movq %rax, %rdi
callq 0x3230
leaq -0x58(%rbp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0xbade(%rip), %rsi      # 0x155d8
movq %rax, %rdi
callq 0x3230
leaq -0xc8(%rbp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0xb9cb(%rip), %rsi      # 0x154e3
movq %rax, %rdi
callq 0x3230
movq %rbx, %rdi
movl -0x30(%rbp), %esi
callq 0xac12
movq %rbx, %rdi
movl -0x2c(%rbp), %esi
callq 0xac12
movq %rbx, %rdi
movl -0x34(%rbp), %esi
callq 0xac12
leaq -0xa8(%rbp), %rdi
callq 0x3110
leaq -0x88(%rbp), %rdi
callq 0x135f8
leaq -0xc8(%rbp), %rdi
callq 0x3110
leaq -0x58(%rbp), %rdi
callq 0x3110
leaq -0x118(%rbp), %rdi
callq 0x3110
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x178(%rbp), %rdi
jmp 0x9bae
movq %rax, %rbx
leaq -0x138(%rbp), %rdi
jmp 0x9c12
movq %rax, %rbx
leaq -0x198(%rbp), %rdi
callq 0x3110
jmp 0x9c0b
jmp 0x9c03
movq %rax, %rbx
leaq -0x158(%rbp), %rdi
jmp 0x9c12
jmp 0x9c03
jmp 0x9bc7
movq %rax, %rbx
leaq -0xf8(%rbp), %rdi
callq 0x135f8
jmp 0x9c17
jmp 0x9c03
movq %rax, %rbx
jmp 0x9c23
jmp 0x9bf5
jmp 0x9bfc
movq %rax, %rbx
leaq -0x1b8(%rbp), %rdi
jmp 0x9c33
jmp 0x9bfc
jmp 0x9c08
jmp 0x9c03
movq %rax, %rbx
jmp 0x9c2f
jmp 0x9c03
movq %rax, %rbx
jmp 0x9c38
jmp 0x9c08
movq %rax, %rbx
jmp 0x9c17
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x3110
leaq -0x88(%rbp), %rdi
callq 0x135f8
leaq -0xc8(%rbp), %rdi
callq 0x3110
leaq -0x58(%rbp), %rdi
callq 0x3110
leaq -0x118(%rbp), %rdi
callq 0x3110
movq %rbx, %rdi
callq 0x3410