// File: kram[P]kram/./src/parser/parser.cpp
// Function: Parser::keyword_if()
Instruction* Parser::keyword_if() {
	Instruction* ins = new Instruction(Ins::IF);

	ins->center = this->read_until(std::vector<lexer::Token>{
		lexer::Token::OPERATOR("{")
	});

	this->advance();
	ins->left = this->read_until(std::vector<lexer::Token>{
		lexer::Token::OPERATOR("}")
	});

	// Test if there is any "else" part
	this->advance();
	if (this->get_token()->sub != lexer::Type::KEYWORD_ELSE) {
		this->reverse();
		return ins;
	}

	this->advance();
	this->get_and_expect_token(lexer::Token::OPERATOR("{"));

	ins->right = this->read_until(std::vector<lexer::Token>{
		lexer::Token::OPERATOR("}")
	});

	return ins;
}

// Assembly:
subq $0x348, %rsp            # imm = 0x348
movq %rdi, 0x338(%rsp)
movq 0x338(%rsp), %rax
movq %rax, 0xf8(%rsp)
movl $0x80, %edi
callq 0x32e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x100(%rsp)
movl $0x5, %esi
callq 0x26dd0
jmp 0x24a83
movq 0x100(%rsp), %rax
movq %rax, 0x330(%rsp)
movb $0x1, 0x28e(%rsp)
leaq 0x2b8(%rsp), %rax
movq %rax, 0x2b0(%rsp)
leaq 0x28f(%rsp), %rdi
movq %rdi, 0xf0(%rsp)
callq 0x34a0
movq 0xf0(%rsp), %rdx
leaq 0x67e2(%rip), %rsi      # 0x2b2b1
leaq 0x290(%rsp), %rdi
callq 0x3390
jmp 0x24ade
leaq 0x2b8(%rsp), %rdi
leaq 0x290(%rsp), %rsi
callq 0xd7e0
jmp 0x24af5
movb $0x0, 0x28e(%rsp)
leaq 0x2b8(%rsp), %rax
movq %rax, 0x2e0(%rsp)
movq $0x1, 0x2e8(%rsp)
leaq 0x28d(%rsp), %rdi
movq %rdi, 0xe8(%rsp)
callq 0x26940
movq 0xe8(%rsp), %rcx
movq 0x2e0(%rsp), %rsi
movq 0x2e8(%rsp), %rdx
leaq 0x2f0(%rsp), %rdi
callq 0x26950
jmp 0x24b55
movq 0xf8(%rsp), %rsi
leaq 0x308(%rsp), %rdi
leaq 0x2f0(%rsp), %rdx
callq 0x20b20
jmp 0x24b74
movq 0x330(%rsp), %rdi
addq $0x68, %rdi
leaq 0x308(%rsp), %rsi
callq 0x26e30
leaq 0x308(%rsp), %rdi
callq 0x5560
leaq 0x2f0(%rsp), %rdi
callq 0x269e0
leaq 0x28d(%rsp), %rdi
callq 0x26a40
leaq 0x2b8(%rsp), %rax
movq %rax, 0xd8(%rsp)
addq $0x28, %rax
movq %rax, 0xe0(%rsp)
movq 0xe0(%rsp), %rdi
addq $-0x28, %rdi
movq %rdi, 0xd0(%rsp)
callq 0xdeb0
movq 0xd8(%rsp), %rcx
movq 0xd0(%rsp), %rax
cmpq %rcx, %rax
movq %rax, 0xe0(%rsp)
jne 0x24bd0
leaq 0x290(%rsp), %rdi
callq 0x31f0
leaq 0x28f(%rsp), %rdi
callq 0x3310
movq 0xf8(%rsp), %rdi
callq 0x21220
movb $0x1, 0x1f6(%rsp)
leaq 0x220(%rsp), %rax
movq %rax, 0x218(%rsp)
leaq 0x1f7(%rsp), %rdi
movq %rdi, 0xc8(%rsp)
callq 0x34a0
movq 0xc8(%rsp), %rdx
leaq 0x664a(%rip), %rsi      # 0x2b2b3
leaq 0x1f8(%rsp), %rdi
callq 0x3390
jmp 0x24c78
leaq 0x220(%rsp), %rdi
leaq 0x1f8(%rsp), %rsi
callq 0xd7e0
jmp 0x24c8f
movb $0x0, 0x1f6(%rsp)
leaq 0x220(%rsp), %rax
movq %rax, 0x248(%rsp)
movq $0x1, 0x250(%rsp)
leaq 0x1f5(%rsp), %rdi
movq %rdi, 0xc0(%rsp)
callq 0x26940
movq 0xc0(%rsp), %rcx
movq 0x248(%rsp), %rsi
movq 0x250(%rsp), %rdx
leaq 0x258(%rsp), %rdi
callq 0x26950
jmp 0x24cef
movq 0xf8(%rsp), %rsi
leaq 0x270(%rsp), %rdi
leaq 0x258(%rsp), %rdx
callq 0x20b20
jmp 0x24d0e
movq 0x330(%rsp), %rdi
addq $0x38, %rdi
leaq 0x270(%rsp), %rsi
callq 0x26e30
leaq 0x270(%rsp), %rdi
callq 0x5560
leaq 0x258(%rsp), %rdi
callq 0x269e0
leaq 0x1f5(%rsp), %rdi
callq 0x26a40
leaq 0x220(%rsp), %rax
movq %rax, 0xb0(%rsp)
addq $0x28, %rax
movq %rax, 0xb8(%rsp)
movq 0xb8(%rsp), %rdi
addq $-0x28, %rdi
movq %rdi, 0xa8(%rsp)
callq 0xdeb0
movq 0xb0(%rsp), %rcx
movq 0xa8(%rsp), %rax
cmpq %rcx, %rax
movq %rax, 0xb8(%rsp)
jne 0x24d6a
leaq 0x1f8(%rsp), %rdi
callq 0x31f0
leaq 0x1f7(%rsp), %rdi
callq 0x3310
movq 0xf8(%rsp), %rdi
callq 0x21220
movq 0xf8(%rsp), %rdi
callq 0x21200
cmpl $0xd, 0x4(%rax)
je 0x25096
movq 0xf8(%rsp), %rdi
callq 0x229d0
movq 0x330(%rsp), %rax
movq %rax, 0x340(%rsp)
jmp 0x25433
movq 0x100(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x328(%rsp)
movl %eax, 0x324(%rsp)
callq 0x32b0
jmp 0x25443
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x328(%rsp)
movl %eax, 0x324(%rsp)
jmp 0x24efd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x328(%rsp)
movl %eax, 0x324(%rsp)
jmp 0x24ef0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x328(%rsp)
movl %eax, 0x324(%rsp)
jmp 0x24e8f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x328(%rsp)
movl %eax, 0x324(%rsp)
leaq 0x2f0(%rsp), %rdi
callq 0x269e0
leaq 0x28d(%rsp), %rdi
callq 0x26a40
leaq 0x2b8(%rsp), %rax
movq %rax, 0x98(%rsp)
addq $0x28, %rax
movq %rax, 0xa0(%rsp)
movq 0xa0(%rsp), %rdi
addq $-0x28, %rdi
movq %rdi, 0x90(%rsp)
callq 0xdeb0
movq 0x98(%rsp), %rcx
movq 0x90(%rsp), %rax
cmpq %rcx, %rax
movq %rax, 0xa0(%rsp)
jne 0x24eb8
jmp 0x24ef0
leaq 0x290(%rsp), %rdi
callq 0x31f0
leaq 0x28f(%rsp), %rdi
callq 0x3310
testb $0x1, 0x28e(%rsp)
jne 0x24f16
jmp 0x24f6b
movq 0x2b0(%rsp), %rax
leaq 0x2b8(%rsp), %rcx
cmpq %rax, %rcx
movq %rax, 0x88(%rsp)
je 0x24f69
movq 0x88(%rsp), %rdi
addq $-0x28, %rdi
movq %rdi, 0x80(%rsp)
callq 0xdeb0
movq 0x80(%rsp), %rax
leaq 0x2b8(%rsp), %rcx
cmpq %rcx, %rax
movq %rax, 0x88(%rsp)
jne 0x24f33
jmp 0x24f6b
jmp 0x25443
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x328(%rsp)
movl %eax, 0x324(%rsp)
jmp 0x25032
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x328(%rsp)
movl %eax, 0x324(%rsp)
jmp 0x25025
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x328(%rsp)
movl %eax, 0x324(%rsp)
jmp 0x24fd9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x328(%rsp)
movl %eax, 0x324(%rsp)
leaq 0x258(%rsp), %rdi
callq 0x269e0
leaq 0x1f5(%rsp), %rdi
callq 0x26a40
leaq 0x220(%rsp), %rax
movq %rax, 0x70(%rsp)
addq $0x28, %rax
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rdi
addq $-0x28, %rdi
movq %rdi, 0x68(%rsp)
callq 0xdeb0
movq 0x70(%rsp), %rcx
movq 0x68(%rsp), %rax
cmpq %rcx, %rax
movq %rax, 0x78(%rsp)
jne 0x24ffc
jmp 0x25025
leaq 0x1f8(%rsp), %rdi
callq 0x31f0
leaq 0x1f7(%rsp), %rdi
callq 0x3310
testb $0x1, 0x1f6(%rsp)
jne 0x2504b
jmp 0x25091
movq 0x218(%rsp), %rax
leaq 0x220(%rsp), %rcx
cmpq %rax, %rcx
movq %rax, 0x60(%rsp)
je 0x2508f
movq 0x60(%rsp), %rdi
addq $-0x28, %rdi
movq %rdi, 0x58(%rsp)
callq 0xdeb0
movq 0x58(%rsp), %rax
leaq 0x220(%rsp), %rcx
cmpq %rcx, %rax
movq %rax, 0x60(%rsp)
jne 0x25065
jmp 0x25091
jmp 0x25443
movq 0xf8(%rsp), %rdi
callq 0x21220
leaq 0x1a7(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x34a0
movq 0x50(%rsp), %rdx
leaq 0x61f0(%rip), %rsi      # 0x2b2b1
leaq 0x1a8(%rsp), %rdi
callq 0x3390
jmp 0x250d0
leaq 0x1c8(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
callq 0xd7e0
jmp 0x250e7
movq 0xf8(%rsp), %rdi
leaq 0x1c8(%rsp), %rsi
callq 0x229f0
jmp 0x250fe
leaq 0x1c8(%rsp), %rdi
callq 0xdeb0
leaq 0x1a8(%rsp), %rdi
callq 0x31f0
leaq 0x1a7(%rsp), %rdi
callq 0x3310
movb $0x1, 0x10e(%rsp)
leaq 0x138(%rsp), %rax
movq %rax, 0x130(%rsp)
leaq 0x10f(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x34a0
movq 0x48(%rsp), %rdx
leaq 0x6158(%rip), %rsi      # 0x2b2b3
leaq 0x110(%rsp), %rdi
callq 0x3390
jmp 0x2516a
leaq 0x138(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0xd7e0
jmp 0x25181
movb $0x0, 0x10e(%rsp)
leaq 0x138(%rsp), %rax
movq %rax, 0x160(%rsp)
movq $0x1, 0x168(%rsp)
leaq 0x10d(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x26940
movq 0x40(%rsp), %rcx
movq 0x160(%rsp), %rsi
movq 0x168(%rsp), %rdx
leaq 0x170(%rsp), %rdi
callq 0x26950
jmp 0x251db
movq 0xf8(%rsp), %rsi
leaq 0x188(%rsp), %rdi
leaq 0x170(%rsp), %rdx
callq 0x20b20
jmp 0x251fa
movq 0x330(%rsp), %rdi
addq $0x50, %rdi
leaq 0x188(%rsp), %rsi
callq 0x26e30
leaq 0x188(%rsp), %rdi
callq 0x5560
leaq 0x170(%rsp), %rdi
callq 0x269e0
leaq 0x10d(%rsp), %rdi
callq 0x26a40
leaq 0x138(%rsp), %rax
movq %rax, 0x30(%rsp)
addq $0x28, %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rdi
addq $-0x28, %rdi
movq %rdi, 0x28(%rsp)
callq 0xdeb0
movq 0x30(%rsp), %rcx
movq 0x28(%rsp), %rax
cmpq %rcx, %rax
movq %rax, 0x38(%rsp)
jne 0x25250
leaq 0x110(%rsp), %rdi
callq 0x31f0
leaq 0x10f(%rsp), %rdi
callq 0x3310
movq 0x330(%rsp), %rax
movq %rax, 0x340(%rsp)
jmp 0x25433
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x328(%rsp)
movl %eax, 0x324(%rsp)
jmp 0x25300
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x328(%rsp)
movl %eax, 0x324(%rsp)
jmp 0x252f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x328(%rsp)
movl %eax, 0x324(%rsp)
leaq 0x1c8(%rsp), %rdi
callq 0xdeb0
leaq 0x1a8(%rsp), %rdi
callq 0x31f0
leaq 0x1a7(%rsp), %rdi
callq 0x3310
jmp 0x25443
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x328(%rsp)
movl %eax, 0x324(%rsp)
jmp 0x253d4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x328(%rsp)
movl %eax, 0x324(%rsp)
jmp 0x253c7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x328(%rsp)
movl %eax, 0x324(%rsp)
jmp 0x2537b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x328(%rsp)
movl %eax, 0x324(%rsp)
leaq 0x170(%rsp), %rdi
callq 0x269e0
leaq 0x10d(%rsp), %rdi
callq 0x26a40
leaq 0x138(%rsp), %rax
movq %rax, 0x18(%rsp)
addq $0x28, %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rdi
addq $-0x28, %rdi
movq %rdi, 0x10(%rsp)
callq 0xdeb0
movq 0x18(%rsp), %rcx
movq 0x10(%rsp), %rax
cmpq %rcx, %rax
movq %rax, 0x20(%rsp)
jne 0x2539e
jmp 0x253c7
leaq 0x110(%rsp), %rdi
callq 0x31f0
leaq 0x10f(%rsp), %rdi
callq 0x3310
testb $0x1, 0x10e(%rsp)
jne 0x253ed
jmp 0x25431
movq 0x130(%rsp), %rax
leaq 0x138(%rsp), %rcx
cmpq %rax, %rcx
movq %rax, 0x8(%rsp)
je 0x2542f
movq 0x8(%rsp), %rdi
addq $-0x28, %rdi
movq %rdi, (%rsp)
callq 0xdeb0
movq (%rsp), %rax
leaq 0x138(%rsp), %rcx
cmpq %rcx, %rax
movq %rax, 0x8(%rsp)
jne 0x25407
jmp 0x25431
jmp 0x25443
movq 0x340(%rsp), %rax
addq $0x348, %rsp            # imm = 0x348
retq
movq 0x328(%rsp), %rdi
callq 0x3490