// File: RuiDGPires[P]CrimLang/src/generator.cpp
// Function: gc_Tracker::unary_reg(crl::Node*)
u32 _gc_Tracker::unary_reg(crl::Node *node){
	crl::Token t = get_token(node->get_child(0));
	std::string op;
	switch (node->type){
		case crl::Node::Type::INC:
			op = "INC";
		break;
		case crl::Node::Type::DEC:
			op = "DEC";
		break;
		default:
		break;
	}
	u32 reg = reg_tracker.alloc();
	std::string name = reg_tracker.reg_name(reg);
	
	if (symb_tracker.has_local(t.str)){
		std::pair<u32, bool> p = symb_tracker.get_local(t.str);

		if (p.second){
			u32 reg2 = reg_tracker.alloc();
			std::string name2 = reg_tracker.reg_name(reg2);
			stream_funcs <<
				"LOAD " << name << " m[RF][-" << p.first  << "]\n" <<
				"LOAD " << name2 << " m[" << name  << "]\n" <<
				"PSH " << name2 << "\n" <<
				op << " " << name2 << "\n" <<
				"STORE m[" << name << "] " << name2 << "\n" <<
				"POP " << name << "\n";

			reg_tracker.free(reg2);
		} else
			stream_funcs <<
				"LOAD " << name << " m[RF][-" << p.first  << "]\n" <<
				"PSH " << name << "\n" <<
				op << " " << name << "\n" <<
				"STORE m[RF][-" << p.first << "] " << name << "\n" <<
				"POP " << name << "\n";
	}else{
		u32 reg2 = reg_tracker.alloc();
		std::string name2 = reg_tracker.reg_name(reg2);

		stream_funcs << "MVI " << name << " " << t.str << "\n" <<
			"LOAD " << name2 << " m[" << name << "]\n" <<
			"PSH " << name2 << "\n" <<
			op << " " << name2 << "\n" <<
			"STORE m[" << name << "] " << name2 << "\n" <<
			"POP " << name << "\n";

		reg_tracker.free(reg2);
	}

	return reg;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x390, %rsp            # imm = 0x390
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
xorl %esi, %esi
callq *%rax
movq %rax, %rsi
leaq -0x40(%rbp), %rdi
callq 0xa2e0
leaq -0x60(%rbp), %rdi
callq 0x4450
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x12c(%rbp)
subl $0x13, %eax
je 0xad13
jmp 0xad06
movl -0x12c(%rbp), %eax
subl $0x14, %eax
je 0xad38
jmp 0xad4c
leaq 0x208cf(%rip), %rsi     # 0x2b5e9
leaq -0x60(%rbp), %rdi
callq 0x4440
jmp 0xad25
jmp 0xad4e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xb7ac
leaq 0x208ae(%rip), %rsi     # 0x2b5ed
leaq -0x60(%rbp), %rdi
callq 0x4440
jmp 0xad4a
jmp 0xad4e
jmp 0xad4e
movq -0x138(%rbp), %rdi
addq $0x500, %rdi            # imm = 0x500
callq 0x12ee0
movl %eax, -0x13c(%rbp)
jmp 0xad69
movq -0x138(%rbp), %rsi
movl -0x13c(%rbp), %eax
movl %eax, -0x70(%rbp)
addq $0x500, %rsi            # imm = 0x500
movl -0x70(%rbp), %edx
leaq -0x90(%rbp), %rdi
callq 0x13040
jmp 0xad91
movq -0x138(%rbp), %rax
addq $0x530, %rax            # imm = 0x530
movq %rax, -0x148(%rbp)
leaq -0xb0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x4150
jmp 0xadb7
movq -0x148(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x13160
movb %al, -0x149(%rbp)
jmp 0xadd2
leaq -0xb0(%rbp), %rdi
callq 0x41e0
movb -0x149(%rbp), %al
testb $0x1, %al
jne 0xaded
jmp 0xb428
movq -0x138(%rbp), %rax
addq $0x530, %rax            # imm = 0x530
movq %rax, -0x158(%rbp)
leaq -0xd8(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x4150
jmp 0xae13
movq -0x158(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x131d0
movq %rax, -0x160(%rbp)
jmp 0xae2f
movq -0x160(%rbp), %rax
movl %eax, %ecx
movl %ecx, -0xb8(%rbp)
shrq $0x20, %rax
movb %al, -0xb4(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x41e0
testb $0x1, -0xb4(%rbp)
je 0xb1f6
movq -0x138(%rbp), %rdi
addq $0x500, %rdi            # imm = 0x500
callq 0x12ee0
movl %eax, -0x164(%rbp)
jmp 0xae7c
movq -0x138(%rbp), %rsi
movl -0x164(%rbp), %eax
movl %eax, -0xdc(%rbp)
addq $0x500, %rsi            # imm = 0x500
movl -0xdc(%rbp), %edx
leaq -0x100(%rbp), %rdi
callq 0x13040
jmp 0xaeaa
movq -0x138(%rbp), %rdi
addq $0x328, %rdi            # imm = 0x328
leaq 0x20381(%rip), %rsi     # 0x2b240
callq 0x42e0
movq %rax, -0x170(%rbp)
jmp 0xaecd
movq -0x170(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x42c0
movq %rax, -0x178(%rbp)
jmp 0xaee9
movq -0x178(%rbp), %rdi
leaq 0x206e9(%rip), %rsi     # 0x2b5e0
callq 0x42e0
movq %rax, -0x180(%rbp)
jmp 0xaf05
movq -0x180(%rbp), %rdi
movl -0xb8(%rbp), %esi
callq 0x4420
movq %rax, -0x188(%rbp)
jmp 0xaf20
movq -0x188(%rbp), %rdi
leaq 0x20318(%rip), %rsi     # 0x2b246
callq 0x42e0
movq %rax, -0x190(%rbp)
jmp 0xaf3c
movq -0x190(%rbp), %rdi
leaq 0x202f6(%rip), %rsi     # 0x2b240
callq 0x42e0
movq %rax, -0x198(%rbp)
jmp 0xaf58
movq -0x198(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x42c0
movq %rax, -0x1a0(%rbp)
jmp 0xaf74
movq -0x1a0(%rbp), %rdi
leaq 0x20652(%rip), %rsi     # 0x2b5d4
callq 0x42e0
movq %rax, -0x1a8(%rbp)
jmp 0xaf90
movq -0x1a8(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x42c0
movq %rax, -0x1b0(%rbp)
jmp 0xafac
movq -0x1b0(%rbp), %rdi
leaq 0x2028c(%rip), %rsi     # 0x2b246
callq 0x42e0
movq %rax, -0x1b8(%rbp)
jmp 0xafc8
movq -0x1b8(%rbp), %rdi
leaq 0x2031e(%rip), %rsi     # 0x2b2f4
callq 0x42e0
movq %rax, -0x1c0(%rbp)
jmp 0xafe4
movq -0x1c0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x42c0
movq %rax, -0x1c8(%rbp)
jmp 0xb000
movq -0x1c8(%rbp), %rdi
leaq 0x204d5(%rip), %rsi     # 0x2b4e3
callq 0x42e0
movq %rax, -0x1d0(%rbp)
jmp 0xb01c
movq -0x1d0(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x42c0
movq %rax, -0x1d8(%rbp)
jmp 0xb035
movq -0x1d8(%rbp), %rdi
leaq 0x1ffc2(%rip), %rsi     # 0x2b005
callq 0x42e0
movq %rax, -0x1e0(%rbp)
jmp 0xb051
movq -0x1e0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x42c0
movq %rax, -0x1e8(%rbp)
jmp 0xb06d
movq -0x1e8(%rbp), %rdi
leaq 0x20468(%rip), %rsi     # 0x2b4e3
callq 0x42e0
movq %rax, -0x1f0(%rbp)
jmp 0xb089
movq -0x1f0(%rbp), %rdi
leaq 0x20538(%rip), %rsi     # 0x2b5cf
callq 0x42e0
movq %rax, -0x1f8(%rbp)
jmp 0xb0a5
movq -0x1f8(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x42c0
movq %rax, -0x200(%rbp)
jmp 0xb0c1
movq -0x200(%rbp), %rdi
leaq 0x20509(%rip), %rsi     # 0x2b5d8
callq 0x42e0
movq %rax, -0x208(%rbp)
jmp 0xb0dd
movq -0x208(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x42c0
movq %rax, -0x210(%rbp)
jmp 0xb0f9
movq -0x210(%rbp), %rdi
leaq 0x203dc(%rip), %rsi     # 0x2b4e3
callq 0x42e0
movq %rax, -0x218(%rbp)
jmp 0xb115
movq -0x218(%rbp), %rdi
leaq 0x20149(%rip), %rsi     # 0x2b26c
callq 0x42e0
movq %rax, -0x220(%rbp)
jmp 0xb131
movq -0x220(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x42c0
movq %rax, -0x228(%rbp)
jmp 0xb14d
movq -0x228(%rbp), %rdi
leaq 0x20388(%rip), %rsi     # 0x2b4e3
callq 0x42e0
jmp 0xb162
movq -0x138(%rbp), %rdi
addq $0x500, %rdi            # imm = 0x500
movl -0xdc(%rbp), %esi
callq 0x13240
jmp 0xb17d
leaq -0x100(%rbp), %rdi
callq 0x41e0
jmp 0xb423
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xb7a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x41e0
jmp 0xb7a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x41e0
jmp 0xb7a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x41e0
jmp 0xb7a0
movq -0x138(%rbp), %rdi
addq $0x328, %rdi            # imm = 0x328
leaq 0x20035(%rip), %rsi     # 0x2b240
callq 0x42e0
movq %rax, -0x230(%rbp)
jmp 0xb219
movq -0x230(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x42c0
movq %rax, -0x238(%rbp)
jmp 0xb235
movq -0x238(%rbp), %rdi
leaq 0x2039d(%rip), %rsi     # 0x2b5e0
callq 0x42e0
movq %rax, -0x240(%rbp)
jmp 0xb251
movq -0x240(%rbp), %rdi
movl -0xb8(%rbp), %esi
callq 0x4420
movq %rax, -0x248(%rbp)
jmp 0xb26c
movq -0x248(%rbp), %rdi
leaq 0x1ffcc(%rip), %rsi     # 0x2b246
callq 0x42e0
movq %rax, -0x250(%rbp)
jmp 0xb288
movq -0x250(%rbp), %rdi
leaq 0x2005e(%rip), %rsi     # 0x2b2f4
callq 0x42e0
movq %rax, -0x258(%rbp)
jmp 0xb2a4
movq -0x258(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x42c0
movq %rax, -0x260(%rbp)
jmp 0xb2c0
movq -0x260(%rbp), %rdi
leaq 0x20215(%rip), %rsi     # 0x2b4e3
callq 0x42e0
movq %rax, -0x268(%rbp)
jmp 0xb2dc
movq -0x268(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x42c0
movq %rax, -0x270(%rbp)
jmp 0xb2f5
movq -0x270(%rbp), %rdi
leaq 0x1fd02(%rip), %rsi     # 0x2b005
callq 0x42e0
movq %rax, -0x278(%rbp)
jmp 0xb311
movq -0x278(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x42c0
movq %rax, -0x280(%rbp)
jmp 0xb32d
movq -0x280(%rbp), %rdi
leaq 0x201a8(%rip), %rsi     # 0x2b4e3
callq 0x42e0
movq %rax, -0x288(%rbp)
jmp 0xb349
movq -0x288(%rbp), %rdi
leaq 0x20284(%rip), %rsi     # 0x2b5db
callq 0x42e0
movq %rax, -0x290(%rbp)
jmp 0xb365
movq -0x290(%rbp), %rdi
movl -0xb8(%rbp), %esi
callq 0x4420
movq %rax, -0x298(%rbp)
jmp 0xb380
movq -0x298(%rbp), %rdi
leaq 0x2024a(%rip), %rsi     # 0x2b5d8
callq 0x42e0
movq %rax, -0x2a0(%rbp)
jmp 0xb39c
movq -0x2a0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x42c0
movq %rax, -0x2a8(%rbp)
jmp 0xb3b8
movq -0x2a8(%rbp), %rdi
leaq 0x2011d(%rip), %rsi     # 0x2b4e3
callq 0x42e0
movq %rax, -0x2b0(%rbp)
jmp 0xb3d4
movq -0x2b0(%rbp), %rdi
leaq 0x1fe8a(%rip), %rsi     # 0x2b26c
callq 0x42e0
movq %rax, -0x2b8(%rbp)
jmp 0xb3f0
movq -0x2b8(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x42c0
movq %rax, -0x2c0(%rbp)
jmp 0xb40c
movq -0x2c0(%rbp), %rdi
leaq 0x200c9(%rip), %rsi     # 0x2b4e3
callq 0x42e0
jmp 0xb421
jmp 0xb423
jmp 0xb76a
movq -0x138(%rbp), %rdi
addq $0x500, %rdi            # imm = 0x500
callq 0x12ee0
movl %eax, -0x2c4(%rbp)
jmp 0xb443
movq -0x138(%rbp), %rsi
movl -0x2c4(%rbp), %eax
movl %eax, -0x104(%rbp)
addq $0x500, %rsi            # imm = 0x500
movl -0x104(%rbp), %edx
leaq -0x128(%rbp), %rdi
callq 0x13040
jmp 0xb471
movq -0x138(%rbp), %rdi
addq $0x328, %rdi            # imm = 0x328
leaq 0x1fdc3(%rip), %rsi     # 0x2b249
callq 0x42e0
movq %rax, -0x2d0(%rbp)
jmp 0xb494
movq -0x2d0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x42c0
movq %rax, -0x2d8(%rbp)
jmp 0xb4b0
movq -0x2d8(%rbp), %rdi
leaq 0x1fb47(%rip), %rsi     # 0x2b005
callq 0x42e0
movq %rax, -0x2e0(%rbp)
jmp 0xb4cc
movq -0x2e0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x42c0
movq %rax, -0x2e8(%rbp)
jmp 0xb4e5
movq -0x2e8(%rbp), %rdi
leaq 0x1fff0(%rip), %rsi     # 0x2b4e3
callq 0x42e0
movq %rax, -0x2f0(%rbp)
jmp 0xb501
movq -0x2f0(%rbp), %rdi
leaq 0x1fd31(%rip), %rsi     # 0x2b240
callq 0x42e0
movq %rax, -0x2f8(%rbp)
jmp 0xb51d
movq -0x2f8(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x42c0
movq %rax, -0x300(%rbp)
jmp 0xb539
movq -0x300(%rbp), %rdi
leaq 0x2008d(%rip), %rsi     # 0x2b5d4
callq 0x42e0
movq %rax, -0x308(%rbp)
jmp 0xb555
movq -0x308(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x42c0
movq %rax, -0x310(%rbp)
jmp 0xb571
movq -0x310(%rbp), %rdi
leaq 0x1fcc7(%rip), %rsi     # 0x2b246
callq 0x42e0
movq %rax, -0x318(%rbp)
jmp 0xb58d
movq -0x318(%rbp), %rdi
leaq 0x1fd59(%rip), %rsi     # 0x2b2f4
callq 0x42e0
movq %rax, -0x320(%rbp)
jmp 0xb5a9
movq -0x320(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x42c0
movq %rax, -0x328(%rbp)
jmp 0xb5c5
movq -0x328(%rbp), %rdi
leaq 0x1ff10(%rip), %rsi     # 0x2b4e3
callq 0x42e0
movq %rax, -0x330(%rbp)
jmp 0xb5e1
movq -0x330(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x42c0
movq %rax, -0x338(%rbp)
jmp 0xb5fa
movq -0x338(%rbp), %rdi
leaq 0x1f9fd(%rip), %rsi     # 0x2b005
callq 0x42e0
movq %rax, -0x340(%rbp)
jmp 0xb616
movq -0x340(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x42c0
movq %rax, -0x348(%rbp)
jmp 0xb632
movq -0x348(%rbp), %rdi
leaq 0x1fea3(%rip), %rsi     # 0x2b4e3
callq 0x42e0
movq %rax, -0x350(%rbp)
jmp 0xb64e
movq -0x350(%rbp), %rdi
leaq 0x1ff73(%rip), %rsi     # 0x2b5cf
callq 0x42e0
movq %rax, -0x358(%rbp)
jmp 0xb66a
movq -0x358(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x42c0
movq %rax, -0x360(%rbp)
jmp 0xb686
movq -0x360(%rbp), %rdi
leaq 0x1ff44(%rip), %rsi     # 0x2b5d8
callq 0x42e0
movq %rax, -0x368(%rbp)
jmp 0xb6a2
movq -0x368(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x42c0
movq %rax, -0x370(%rbp)
jmp 0xb6be
movq -0x370(%rbp), %rdi
leaq 0x1fe17(%rip), %rsi     # 0x2b4e3
callq 0x42e0
movq %rax, -0x378(%rbp)
jmp 0xb6da
movq -0x378(%rbp), %rdi
leaq 0x1fb84(%rip), %rsi     # 0x2b26c
callq 0x42e0
movq %rax, -0x380(%rbp)
jmp 0xb6f6
movq -0x380(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x42c0
movq %rax, -0x388(%rbp)
jmp 0xb712
movq -0x388(%rbp), %rdi
leaq 0x1fdc3(%rip), %rsi     # 0x2b4e3
callq 0x42e0
jmp 0xb727
movq -0x138(%rbp), %rdi
addq $0x500, %rdi            # imm = 0x500
movl -0x104(%rbp), %esi
callq 0x13240
jmp 0xb742
leaq -0x128(%rbp), %rdi
callq 0x41e0
jmp 0xb76a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x41e0
jmp 0xb7a0
movl -0x70(%rbp), %eax
movl %eax, -0x38c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x41e0
leaq -0x60(%rbp), %rdi
callq 0x41e0
leaq -0x40(%rbp), %rdi
callq 0x285a0
movl -0x38c(%rbp), %eax
addq $0x390, %rsp            # imm = 0x390
popq %rbp
retq
leaq -0x90(%rbp), %rdi
callq 0x41e0
leaq -0x60(%rbp), %rdi
callq 0x41e0
leaq -0x40(%rbp), %rdi
callq 0x285a0
movq -0x68(%rbp), %rdi
callq 0x4580
nopw (%rax,%rax)