// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %r15
pushq %r14
pushq %rbx
subq $0x140, %rsp            # imm = 0x140
movq %rdi, %r14
movl $0x80, %edi
callq 0x3230
movq %rax, %rbx
movl $0x5, (%rax)
addq $0x18, %rax
movq %rax, 0x8(%rbx)
andq $0x0, 0x10(%rbx)
movb $0x0, 0x18(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%rbx)
movups %xmm0, 0x48(%rbx)
movups %xmm0, 0x58(%rbx)
movups %xmm0, 0x68(%rbx)
andq $0x0, 0x78(%rbx)
movl $0x2, 0x30(%rbx)
leaq 0x2884(%rip), %rsi      # 0x112ad
leaq 0xf8(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x30f0
leaq 0x10(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0x63f2
leaq 0x80(%rsp), %rdi
leaq 0x10(%rsp), %rsi
pushq $0x1
popq %rdx
leaq 0xe(%rsp), %rcx
callq 0xf720
leaq 0x38(%rsp), %rdi
leaq 0x80(%rsp), %rdx
movq %r14, %rsi
callq 0xca06
leaq 0x68(%rbx), %rdi
leaq 0x38(%rsp), %r15
movq %r15, %rsi
callq 0x10148
movq %r15, %rdi
callq 0x42f2
leaq 0x80(%rsp), %rdi
callq 0xf75a
leaq 0x18(%rsp), %rdi
callq 0x3130
leaq 0xf8(%rsp), %rdi
callq 0x3130
cmpb $0x1, 0x20(%r14)
jne 0xeac6
incl 0x18(%r14)
jmp 0xeacb
movb $0x1, 0x20(%r14)
leaq 0x27dd(%rip), %rsi      # 0x112af
leaq 0xd8(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x30f0
leaq 0x10(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x63f2
leaq 0x68(%rsp), %rdi
leaq 0x10(%rsp), %rsi
pushq $0x1
popq %rdx
leaq 0xe(%rsp), %rcx
callq 0xf720
leaq 0x38(%rsp), %rdi
leaq 0x68(%rsp), %rdx
movq %r14, %rsi
callq 0xca06
leaq 0x38(%rbx), %rdi
leaq 0x38(%rsp), %r15
movq %r15, %rsi
callq 0x10148
movq %r15, %rdi
callq 0x42f2
leaq 0x68(%rsp), %rdi
callq 0xf75a
leaq 0x18(%rsp), %rdi
callq 0x3130
leaq 0xd8(%rsp), %rdi
callq 0x3130
movb 0x20(%r14), %cl
cmpb $0x1, %cl
jne 0xeb6e
movl 0x18(%r14), %eax
incl %eax
movl %eax, 0x18(%r14)
jmp 0xeb79
movb $0x1, 0x20(%r14)
movl 0x18(%r14), %eax
movb $0x1, %cl
movslq %eax, %rdx
movq (%r14), %rsi
movq (%rsi,%rdx,8), %rdx
cmpl $0xd, 0x4(%rdx)
jne 0xeb95
testb %cl, %cl
je 0xeba0
incl %eax
movl %eax, 0x18(%r14)
jmp 0xeba5
decl %eax
movl %eax, 0x18(%r14)
jmp 0xec8b
movb $0x1, 0x20(%r14)
leaq 0x2701(%rip), %rsi      # 0x112ad
leaq 0xb8(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x30f0
leaq 0x118(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x63f2
leaq 0x118(%rsp), %rsi
movq %r14, %rdi
callq 0xd9bc
leaq 0x120(%rsp), %rdi
callq 0x3130
leaq 0xb8(%rsp), %rdi
callq 0x3130
leaq 0x26ab(%rip), %rsi      # 0x112af
leaq 0x98(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x30f0
leaq 0x10(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x63f2
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rsi
pushq $0x1
popq %rdx
leaq 0xe(%rsp), %rcx
callq 0xf720
leaq 0x38(%rsp), %rdi
leaq 0x50(%rsp), %rdx
movq %r14, %rsi
callq 0xca06
leaq 0x50(%rbx), %rdi
leaq 0x38(%rsp), %r14
movq %r14, %rsi
callq 0x10148
movq %r14, %rdi
callq 0x42f2
leaq 0x50(%rsp), %rdi
callq 0xf75a
leaq 0x18(%rsp), %rdi
callq 0x3130
leaq 0x98(%rsp), %rdi
callq 0x3130
movq %rbx, %rax
addq $0x140, %rsp            # imm = 0x140
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0xf75a
jmp 0xecad
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x3130
jmp 0xecbc
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
jmp 0xed45
jmp 0xed4c
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
callq 0x3130
jmp 0xece0
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
jmp 0xed45
jmp 0xed4c
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0xf75a
jmp 0xecfe
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x3130
jmp 0xed0d
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
jmp 0xed45
jmp 0xed4c
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0xf75a
jmp 0xed2e
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x3130
jmp 0xed3d
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x3130
jmp 0xed4f
movq %rax, %rbx
movq %rbx, %rdi
callq 0x3390
nop