// File: RuiDGPires[P]CrimLang/src/generator.cpp
// Function: gc_Tracker::if_(crl::Node*)
void _gc_Tracker::if_(crl::Node *node){
	u32 reg = this->expression_reg(node->get_child(0), stream_funcs);

	std::string	done_label = label_tracker.name(label_tracker.create());

	std::string false_label;

	bool has_else = node->children.size() == 3;
	if (has_else)
		false_label	= label_tracker.name(label_tracker.create());
	else
		false_label = done_label;
	
	stream_funcs <<
		"CMP " << reg_tracker.reg_name(reg) << " R0\n" <<
		"JMP.Z " << false_label << "\n";
		
	reg_tracker.free(reg);
	this->parse_node(node->get_child(1)->get_child(0));

	stream_funcs << "JMP " << done_label << "\n";

	if (has_else){
		stream_funcs <<
			false_label << ":\n";
		this->parse_node(node->get_child(2)->get_child(0));
	}
	stream_funcs <<
		done_label << ":\n";
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
xorl %esi, %esi
callq *0x18(%rax)
movq -0xc0(%rbp), %rdi
movq %rax, %rsi
movq %rdi, %rdx
addq $0x318, %rdx            # imm = 0x318
callq 0xa310
movq -0xc0(%rbp), %rdi
movl %eax, -0x14(%rbp)
movq %rdi, %rax
addq $0x528, %rax            # imm = 0x528
movq %rax, -0xb8(%rbp)
addq $0x528, %rdi            # imm = 0x528
callq 0x13900
movq -0xb8(%rbp), %rsi
movl %eax, %edx
leaq -0x38(%rbp), %rdi
callq 0x13820
leaq -0x58(%rbp), %rdi
callq 0x4450
movq -0x10(%rbp), %rdi
addq $0x10, %rdi
callq 0x51d0
cmpq $0x3, %rax
sete %al
andb $0x1, %al
movb %al, -0x59(%rbp)
testb $0x1, -0x59(%rbp)
je 0x1237c
movq -0xc0(%rbp), %rdi
addq $0x528, %rdi            # imm = 0x528
movq %rdi, -0xd0(%rbp)
callq 0x13900
movl %eax, -0xc4(%rbp)
jmp 0x12335
movl -0xc4(%rbp), %edx
movq -0xd0(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0x13820
jmp 0x1234d
leaq -0x58(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x43c0
leaq -0x80(%rbp), %rdi
callq 0x41e0
jmp 0x1238d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x1260d
leaq -0x58(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x4050
jmp 0x1238b
jmp 0x1238d
movq -0xc0(%rbp), %rdi
addq $0x328, %rdi            # imm = 0x328
leaq 0x1924f(%rip), %rsi     # 0x2b5f1
callq 0x42e0
movq %rax, -0xd8(%rbp)
jmp 0x123b0
movq -0xc0(%rbp), %rsi
addq $0x500, %rsi            # imm = 0x500
movl -0x14(%rbp), %edx
leaq -0xb0(%rbp), %rdi
callq 0x13040
jmp 0x123cf
movq -0xd8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x42c0
movq %rax, -0xe0(%rbp)
jmp 0x123eb
movq -0xe0(%rbp), %rdi
leaq 0x19239(%rip), %rsi     # 0x2b632
callq 0x42e0
movq %rax, -0xe8(%rbp)
jmp 0x12407
movq -0xe8(%rbp), %rdi
leaq 0x191e1(%rip), %rsi     # 0x2b5f6
callq 0x42e0
movq %rax, -0xf0(%rbp)
jmp 0x12423
movq -0xf0(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x42c0
movq %rax, -0xf8(%rbp)
jmp 0x1243c
movq -0xf8(%rbp), %rdi
leaq 0x19099(%rip), %rsi     # 0x2b4e3
callq 0x42e0
jmp 0x12451
leaq -0xb0(%rbp), %rdi
callq 0x41e0
movq -0xc0(%rbp), %rdi
addq $0x500, %rdi            # imm = 0x500
movl -0x14(%rbp), %esi
callq 0x13240
jmp 0x12475
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
movl $0x1, %esi
callq *%rax
movq %rax, -0x100(%rbp)
jmp 0x12490
movq -0x100(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
xorl %esi, %esi
callq *%rax
movq %rax, -0x108(%rbp)
jmp 0x124ab
movq -0x108(%rbp), %rsi
movq -0xc0(%rbp), %rdi
callq 0x12630
jmp 0x124c0
movq -0xc0(%rbp), %rdi
addq $0x328, %rdi            # imm = 0x328
leaq 0x19040(%rip), %rsi     # 0x2b515
callq 0x42e0
movq %rax, -0x110(%rbp)
jmp 0x124e3
movq -0x110(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x42c0
movq %rax, -0x118(%rbp)
jmp 0x124fc
movq -0x118(%rbp), %rdi
leaq 0x18fd9(%rip), %rsi     # 0x2b4e3
callq 0x42e0
jmp 0x12511
testb $0x1, -0x59(%rbp)
je 0x125bd
movq -0xc0(%rbp), %rdi
addq $0x328, %rdi            # imm = 0x328
leaq -0x58(%rbp), %rsi
callq 0x42c0
movq %rax, -0x120(%rbp)
jmp 0x1253b
movq -0x120(%rbp), %rdi
leaq 0x18f5b(%rip), %rsi     # 0x2b4a4
callq 0x42e0
jmp 0x12550
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
movl $0x2, %esi
callq *%rax
movq %rax, -0x128(%rbp)
jmp 0x1256b
movq -0x128(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
xorl %esi, %esi
callq *%rax
movq %rax, -0x130(%rbp)
jmp 0x12586
movq -0x130(%rbp), %rsi
movq -0xc0(%rbp), %rdi
callq 0x12630
jmp 0x1259b
jmp 0x125bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x41e0
jmp 0x1260d
movq -0xc0(%rbp), %rdi
addq $0x328, %rdi            # imm = 0x328
leaq -0x38(%rbp), %rsi
callq 0x42c0
movq %rax, -0x138(%rbp)
jmp 0x125dd
movq -0x138(%rbp), %rdi
leaq 0x18eb9(%rip), %rsi     # 0x2b4a4
callq 0x42e0
jmp 0x125f2
leaq -0x58(%rbp), %rdi
callq 0x41e0
leaq -0x38(%rbp), %rdi
callq 0x41e0
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
leaq -0x58(%rbp), %rdi
callq 0x41e0
leaq -0x38(%rbp), %rdi
callq 0x41e0
movq -0x88(%rbp), %rdi
callq 0x4580
nopl (%rax,%rax)