// File: /workspace/github_cpp_makefile_star2_O3/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 %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rdi, %r14
movl $0x80, %edi
callq 0x3260
movq %rax, %rbx
movl $0x5, (%rax)
addq $0x18, %rax
movq %rax, 0x8(%rbx)
xorl %eax, %eax
movq %rax, 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)
movq %rax, 0x78(%rbx)
movl $0x2, 0x30(%rbx)
leaq 0x110(%rsp), %r12
movq %r12, -0x10(%r12)
movw $0x7b, (%r12)
movq $0x1, -0x8(%r12)
leaq 0x30(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x6d4c
leaq 0x88(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0xf(%rsp), %rcx
movl $0x1, %edx
callq 0x111aa
leaq 0x10(%rsp), %rdi
leaq 0x88(%rsp), %rdx
movq %r14, %rsi
callq 0xdcd2
movq 0x68(%rbx), %rdi
movaps 0x10(%rsp), %xmm0
movups %xmm0, 0x68(%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0x78(%rbx)
testq %rdi, %rdi
je 0x10310
callq 0x3230
leaq 0x88(%rsp), %rdi
callq 0x111ec
leaq 0x48(%rsp), %r15
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0x10330
callq 0x3230
movq 0x100(%rsp), %rdi
cmpq %r12, %rdi
je 0x10342
callq 0x3230
cmpb $0x1, 0x20(%r14)
jne 0x1034f
incl 0x18(%r14)
jmp 0x10354
movb $0x1, 0x20(%r14)
leaq 0xf0(%rsp), %r12
movq %r12, -0x10(%r12)
movw $0x7d, (%r12)
movq $0x1, -0x8(%r12)
leaq 0x30(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x6d4c
leaq 0x70(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0xf(%rsp), %rcx
movl $0x1, %edx
callq 0x111aa
leaq 0x10(%rsp), %rdi
leaq 0x70(%rsp), %rdx
movq %r14, %rsi
callq 0xdcd2
movq 0x38(%rbx), %rdi
movaps 0x10(%rsp), %xmm0
movups %xmm0, 0x38(%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0x48(%rbx)
testq %rdi, %rdi
je 0x103ce
callq 0x3230
leaq 0x70(%rsp), %rdi
callq 0x111ec
movq 0x38(%rsp), %rdi
cmpq %r15, %rdi
je 0x103e7
callq 0x3230
movq 0xe0(%rsp), %rdi
cmpq %r12, %rdi
je 0x103f9
callq 0x3230
cmpb $0x1, 0x20(%r14)
jne 0x1041a
leaq 0x18(%r14), %rax
movslq 0x18(%r14), %rdx
leaq 0x1(%rdx), %rcx
movl %ecx, 0x18(%r14)
movq (%r14), %rsi
movq 0x8(%rsi,%rdx,8), %rdx
jmp 0x1042e
movb $0x1, 0x20(%r14)
leaq 0x18(%r14), %rax
movslq 0x18(%r14), %rcx
movq (%r14), %rdx
movq (%rdx,%rcx,8), %rdx
cmpl $0xd, 0x4(%rdx)
jne 0x1054d
incl %ecx
movl %ecx, (%rax)
leaq 0xd0(%rsp), %r12
movq %r12, -0x10(%r12)
movw $0x7b, (%r12)
movq $0x1, -0x8(%r12)
leaq 0x120(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x6d4c
leaq 0x120(%rsp), %rsi
movq %r14, %rdi
callq 0xef56
leaq 0x138(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x10494
callq 0x3230
movq 0xc0(%rsp), %rdi
cmpq %r12, %rdi
je 0x104a6
callq 0x3230
leaq 0xb0(%rsp), %r12
movq %r12, -0x10(%r12)
movw $0x7d, (%r12)
movq $0x1, -0x8(%r12)
leaq 0x30(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x6d4c
leaq 0x58(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0xf(%rsp), %rcx
movl $0x1, %edx
callq 0x111aa
leaq 0x10(%rsp), %rdi
leaq 0x58(%rsp), %rdx
movq %r14, %rsi
callq 0xdcd2
movq 0x50(%rbx), %rdi
movaps 0x10(%rsp), %xmm0
movups %xmm0, 0x50(%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0x60(%rbx)
testq %rdi, %rdi
je 0x10520
callq 0x3230
leaq 0x58(%rsp), %rdi
callq 0x111ec
movq 0x38(%rsp), %rdi
cmpq %r15, %rdi
je 0x10539
callq 0x3230
movq 0xa0(%rsp), %rdi
cmpq %r12, %rdi
je 0x10551
callq 0x3230
jmp 0x10551
decl %ecx
movl %ecx, (%rax)
movq %rbx, %rax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x111ec
jmp 0x10575
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r15, %rdi
je 0x10589
callq 0x3230
jmp 0x10589
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
jmp 0x10623
movq %rax, %rbx
leaq 0x138(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x105b4
callq 0x3230
jmp 0x105b4
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
jmp 0x10623
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x111ec
jmp 0x105d0
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r15, %rdi
je 0x105e4
callq 0x3230
jmp 0x105e4
movq %rax, %rbx
movq 0xe0(%rsp), %rdi
jmp 0x10623
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x111ec
jmp 0x10603
movq %rax, %rbx
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1061b
callq 0x3230
jmp 0x1061b
movq %rax, %rbx
movq 0x100(%rsp), %rdi
cmpq %r12, %rdi
je 0x1062d
callq 0x3230
movq %rbx, %rdi
callq 0x33c0
nop