// File: RuiDGPires[P]CrimLang/src/generator.cpp
// Function: gc_Tracker::while_(crl::Node*)
void _gc_Tracker::while_(crl::Node *node){
	std::string	loop_label = label_tracker.name(label_tracker.create());
	std::string end_label	= label_tracker.name(label_tracker.create());
	this->breakable_labels = std::pair(loop_label, end_label);

	stream_funcs <<	loop_label << ":\n";

	u32 reg = this->expression_reg(node->get_child(0), stream_funcs);

	stream_funcs <<
		"CMP " << reg_tracker.reg_name(reg) << " R0\n" <<
		"JMP.Z " << end_label << "\n";
		
	reg_tracker.free(reg);

	this->parse_node(node->get_child(1));

	stream_funcs << "JMP " << loop_label << "\n" <<
		end_label << ":\n";
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
addq $0x528, %rdi            # imm = 0x528
movq %rdi, -0xd8(%rbp)
callq 0x13900
movq -0xd8(%rbp), %rsi
movl %eax, %edx
leaq -0x30(%rbp), %rdi
callq 0x13820
movq -0xd8(%rbp), %rdi
callq 0x13900
movl %eax, -0xcc(%rbp)
jmp 0x126b7
movl -0xcc(%rbp), %edx
movq -0xd8(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x13820
jmp 0x126cf
leaq -0xa0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x13920
jmp 0x126e5
movq -0xe0(%rbp), %rdi
addq $0x4c0, %rdi            # imm = 0x4C0
leaq -0xa0(%rbp), %rsi
movq %rsi, -0xf0(%rbp)
callq 0x13980
movq -0xf0(%rbp), %rdi
callq 0x139c0
movq -0xe0(%rbp), %rdi
addq $0x328, %rdi            # imm = 0x328
leaq -0x30(%rbp), %rsi
callq 0x42c0
movq %rax, -0xe8(%rbp)
jmp 0x12732
movq -0xe8(%rbp), %rdi
leaq 0x18d64(%rip), %rsi     # 0x2b4a4
callq 0x42e0
jmp 0x12747
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
xorl %esi, %esi
callq *%rax
movq %rax, -0xf8(%rbp)
jmp 0x1275f
movq -0xf8(%rbp), %rsi
movq -0xe0(%rbp), %rdi
movq %rdi, %rdx
addq $0x318, %rdx            # imm = 0x318
callq 0xa310
movl %eax, -0xfc(%rbp)
jmp 0x12784
movq -0xe0(%rbp), %rdi
movl -0xfc(%rbp), %eax
movl %eax, -0xa4(%rbp)
addq $0x328, %rdi            # imm = 0x328
leaq 0x18e4c(%rip), %rsi     # 0x2b5f1
callq 0x42e0
movq %rax, -0x108(%rbp)
jmp 0x127b3
movq -0xe0(%rbp), %rsi
addq $0x500, %rsi            # imm = 0x500
movl -0xa4(%rbp), %edx
leaq -0xc8(%rbp), %rdi
callq 0x13040
jmp 0x127d5
movq -0x108(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x42c0
movq %rax, -0x110(%rbp)
jmp 0x127f1
movq -0x110(%rbp), %rdi
leaq 0x18e33(%rip), %rsi     # 0x2b632
callq 0x42e0
movq %rax, -0x118(%rbp)
jmp 0x1280d
movq -0x118(%rbp), %rdi
leaq 0x18ddb(%rip), %rsi     # 0x2b5f6
callq 0x42e0
movq %rax, -0x120(%rbp)
jmp 0x12829
movq -0x120(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x42c0
movq %rax, -0x128(%rbp)
jmp 0x12842
movq -0x128(%rbp), %rdi
leaq 0x18c93(%rip), %rsi     # 0x2b4e3
callq 0x42e0
jmp 0x12857
leaq -0xc8(%rbp), %rdi
callq 0x41e0
movq -0xe0(%rbp), %rdi
addq $0x500, %rdi            # imm = 0x500
movl -0xa4(%rbp), %esi
callq 0x13240
jmp 0x1287e
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
movl $0x1, %esi
callq *%rax
movq %rax, -0x130(%rbp)
jmp 0x12899
movq -0x130(%rbp), %rsi
movq -0xe0(%rbp), %rdi
callq 0x12630
jmp 0x128ae
movq -0xe0(%rbp), %rdi
addq $0x328, %rdi            # imm = 0x328
leaq 0x18c52(%rip), %rsi     # 0x2b515
callq 0x42e0
movq %rax, -0x138(%rbp)
jmp 0x128d1
movq -0x138(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x42c0
movq %rax, -0x140(%rbp)
jmp 0x128ea
movq -0x140(%rbp), %rdi
leaq 0x18beb(%rip), %rsi     # 0x2b4e3
callq 0x42e0
movq %rax, -0x148(%rbp)
jmp 0x12906
movq -0x148(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x42c0
movq %rax, -0x150(%rbp)
jmp 0x1291f
movq -0x150(%rbp), %rdi
leaq 0x18b77(%rip), %rsi     # 0x2b4a4
callq 0x42e0
jmp 0x12934
leaq -0x50(%rbp), %rdi
callq 0x41e0
leaq -0x30(%rbp), %rdi
callq 0x41e0
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x1298c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x12983
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x41e0
leaq -0x50(%rbp), %rdi
callq 0x41e0
leaq -0x30(%rbp), %rdi
callq 0x41e0
movq -0x58(%rbp), %rdi
callq 0x4580
nop