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

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

	// All parameters
	do {
		ins->left = this->read_until(std::vector<lexer::Token>{
			lexer::Token::OPERATOR(")"),
			lexer::Token::OPERATOR(","),
		}, ins->left, ON::FUNCTION_PARAMETER_LIST);
	} while (this->get_token()->sub == lexer::Type::OPERATOR_COMMA);

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

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

	return ins;
}

// Assembly:
subq $0x328, %rsp            # imm = 0x328
movq %rdi, 0x320(%rsp)
movq 0x320(%rsp), %rax
movq %rax, 0xc0(%rsp)
movl $0x80, %edi
callq 0x32e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0xc8(%rsp)
movl $0xa, %esi
callq 0x26dd0
jmp 0x24163
movq 0xc0(%rsp), %rdi
movq 0xc8(%rsp), %rax
movq %rax, 0x318(%rsp)
callq 0x21220
leaq 0x2bf(%rsp), %rdi
movq %rdi, 0xb8(%rsp)
callq 0x34a0
movq 0xb8(%rsp), %rdx
leaq 0x70a5(%rip), %rsi      # 0x2b249
leaq 0x2c0(%rsp), %rdi
callq 0x3390
jmp 0x241b3
leaq 0x2e0(%rsp), %rdi
leaq 0x2c0(%rsp), %rsi
callq 0xd7e0
jmp 0x241ca
movq 0xc0(%rsp), %rdi
leaq 0x2e0(%rsp), %rsi
callq 0x229f0
jmp 0x241e1
leaq 0x2e0(%rsp), %rdi
callq 0xdeb0
leaq 0x2c0(%rsp), %rdi
callq 0x31f0
leaq 0x2bf(%rsp), %rdi
callq 0x3310
movb $0x1, 0x1d6(%rsp)
leaq 0x228(%rsp), %rax
movq %rax, 0x220(%rsp)
leaq 0x1ff(%rsp), %rdi
movq %rdi, 0xb0(%rsp)
callq 0x34a0
movq 0xb0(%rsp), %rdx
leaq 0x7997(%rip), %rsi      # 0x2bbdb
leaq 0x200(%rsp), %rdi
callq 0x3390
jmp 0x24253
leaq 0x228(%rsp), %rdi
leaq 0x200(%rsp), %rsi
callq 0xd7e0
jmp 0x2426a
leaq 0x250(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq %rax, 0x220(%rsp)
leaq 0x1d7(%rsp), %rdi
movq %rdi, 0xa8(%rsp)
callq 0x34a0
movq 0xa8(%rsp), %rdx
leaq 0x6fe0(%rip), %rsi      # 0x2b286
leaq 0x1d8(%rsp), %rdi
callq 0x3390
jmp 0x242b5
movq 0xa0(%rsp), %rdi
leaq 0x1d8(%rsp), %rsi
callq 0xd7e0
jmp 0x242cc
movb $0x0, 0x1d6(%rsp)
leaq 0x228(%rsp), %rax
movq %rax, 0x278(%rsp)
movq $0x2, 0x280(%rsp)
leaq 0x1d5(%rsp), %rdi
movq %rdi, 0x98(%rsp)
callq 0x26940
movq 0x98(%rsp), %rcx
movq 0x278(%rsp), %rsi
movq 0x280(%rsp), %rdx
leaq 0x288(%rsp), %rdi
callq 0x26950
jmp 0x2432c
movq 0x318(%rsp), %rsi
addq $0x38, %rsi
leaq 0x1b8(%rsp), %rdi
callq 0x5460
jmp 0x24347
movq 0xc0(%rsp), %rsi
leaq 0x2a0(%rsp), %rdi
leaq 0x288(%rsp), %rdx
leaq 0x1b8(%rsp), %rcx
movl $0x4, %r8d
callq 0x20e00
jmp 0x24374
movq 0x318(%rsp), %rdi
addq $0x38, %rdi
leaq 0x2a0(%rsp), %rsi
callq 0x26e30
leaq 0x2a0(%rsp), %rdi
callq 0x5560
leaq 0x1b8(%rsp), %rdi
callq 0x5560
leaq 0x288(%rsp), %rdi
callq 0x269e0
leaq 0x1d5(%rsp), %rdi
callq 0x26a40
leaq 0x228(%rsp), %rax
movq %rax, 0x88(%rsp)
addq $0x50, %rax
movq %rax, 0x90(%rsp)
movq 0x90(%rsp), %rdi
addq $-0x28, %rdi
movq %rdi, 0x80(%rsp)
callq 0xdeb0
movq 0x88(%rsp), %rcx
movq 0x80(%rsp), %rax
cmpq %rcx, %rax
movq %rax, 0x90(%rsp)
jne 0x243dd
leaq 0x1d8(%rsp), %rdi
callq 0x31f0
leaq 0x1d7(%rsp), %rdi
callq 0x3310
leaq 0x200(%rsp), %rdi
callq 0x31f0
leaq 0x1ff(%rsp), %rdi
callq 0x3310
movq 0xc0(%rsp), %rdi
callq 0x21200
cmpl $0x12, 0x4(%rax)
je 0x24208
movq 0xc0(%rsp), %rdi
callq 0x21220
leaq 0x16f(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x34a0
movq 0x78(%rsp), %rdx
leaq 0x6e28(%rip), %rsi      # 0x2b2b1
leaq 0x170(%rsp), %rdi
callq 0x3390
jmp 0x24498
leaq 0x190(%rsp), %rdi
leaq 0x170(%rsp), %rsi
callq 0xd7e0
jmp 0x244af
movq 0xc0(%rsp), %rdi
leaq 0x190(%rsp), %rsi
callq 0x229f0
jmp 0x244c6
leaq 0x190(%rsp), %rdi
callq 0xdeb0
leaq 0x170(%rsp), %rdi
callq 0x31f0
leaq 0x16f(%rsp), %rdi
callq 0x3310
movq 0xc0(%rsp), %rdi
callq 0x21220
movb $0x1, 0xd6(%rsp)
leaq 0x100(%rsp), %rax
movq %rax, 0xf8(%rsp)
leaq 0xd7(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0x34a0
movq 0x70(%rsp), %rdx
leaq 0x6d83(%rip), %rsi      # 0x2b2b3
leaq 0xd8(%rsp), %rdi
callq 0x3390
jmp 0x2453f
leaq 0x100(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0xd7e0
jmp 0x24556
movb $0x0, 0xd6(%rsp)
leaq 0x100(%rsp), %rax
movq %rax, 0x128(%rsp)
movq $0x1, 0x130(%rsp)
leaq 0xd5(%rsp), %rdi
movq %rdi, 0x68(%rsp)
callq 0x26940
movq 0x68(%rsp), %rcx
movq 0x128(%rsp), %rsi
movq 0x130(%rsp), %rdx
leaq 0x138(%rsp), %rdi
callq 0x26950
jmp 0x245b0
movq 0xc0(%rsp), %rsi
leaq 0x150(%rsp), %rdi
leaq 0x138(%rsp), %rdx
callq 0x20b20
jmp 0x245cf
movq 0x318(%rsp), %rdi
addq $0x50, %rdi
leaq 0x150(%rsp), %rsi
callq 0x26e30
leaq 0x150(%rsp), %rdi
callq 0x5560
leaq 0x138(%rsp), %rdi
callq 0x269e0
leaq 0xd5(%rsp), %rdi
callq 0x26a40
leaq 0x100(%rsp), %rax
movq %rax, 0x58(%rsp)
addq $0x28, %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rdi
addq $-0x28, %rdi
movq %rdi, 0x50(%rsp)
callq 0xdeb0
movq 0x58(%rsp), %rcx
movq 0x50(%rsp), %rax
cmpq %rcx, %rax
movq %rax, 0x60(%rsp)
jne 0x24625
leaq 0xd8(%rsp), %rdi
callq 0x31f0
leaq 0xd7(%rsp), %rdi
callq 0x3310
movq 0x318(%rsp), %rax
addq $0x328, %rsp            # imm = 0x328
retq
movq 0xc8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x310(%rsp)
movl %eax, 0x30c(%rsp)
callq 0x32b0
jmp 0x24a2a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x310(%rsp)
movl %eax, 0x30c(%rsp)
jmp 0x246f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x310(%rsp)
movl %eax, 0x30c(%rsp)
jmp 0x246e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x310(%rsp)
movl %eax, 0x30c(%rsp)
leaq 0x2e0(%rsp), %rdi
callq 0xdeb0
leaq 0x2c0(%rsp), %rdi
callq 0x31f0
leaq 0x2bf(%rsp), %rdi
callq 0x3310
jmp 0x24a2a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x310(%rsp)
movl %eax, 0x30c(%rsp)
jmp 0x24839
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x310(%rsp)
movl %eax, 0x30c(%rsp)
jmp 0x2482c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x310(%rsp)
movl %eax, 0x30c(%rsp)
jmp 0x2481f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x310(%rsp)
movl %eax, 0x30c(%rsp)
jmp 0x24812
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x310(%rsp)
movl %eax, 0x30c(%rsp)
jmp 0x247c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x310(%rsp)
movl %eax, 0x30c(%rsp)
jmp 0x247b9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x310(%rsp)
movl %eax, 0x30c(%rsp)
leaq 0x1b8(%rsp), %rdi
callq 0x5560
leaq 0x288(%rsp), %rdi
callq 0x269e0
leaq 0x1d5(%rsp), %rdi
callq 0x26a40
leaq 0x228(%rsp), %rax
movq %rax, 0x40(%rsp)
addq $0x50, %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rdi
addq $-0x28, %rdi
movq %rdi, 0x38(%rsp)
callq 0xdeb0
movq 0x40(%rsp), %rcx
movq 0x38(%rsp), %rax
cmpq %rcx, %rax
movq %rax, 0x48(%rsp)
jne 0x247e9
jmp 0x24812
leaq 0x1d8(%rsp), %rdi
callq 0x31f0
leaq 0x1d7(%rsp), %rdi
callq 0x3310
leaq 0x200(%rsp), %rdi
callq 0x31f0
leaq 0x1ff(%rsp), %rdi
callq 0x3310
testb $0x1, 0x1d6(%rsp)
jne 0x24852
jmp 0x24898
movq 0x220(%rsp), %rax
leaq 0x228(%rsp), %rcx
cmpq %rax, %rcx
movq %rax, 0x30(%rsp)
je 0x24896
movq 0x30(%rsp), %rdi
addq $-0x28, %rdi
movq %rdi, 0x28(%rsp)
callq 0xdeb0
movq 0x28(%rsp), %rax
leaq 0x228(%rsp), %rcx
cmpq %rcx, %rax
movq %rax, 0x30(%rsp)
jne 0x2486c
jmp 0x24898
jmp 0x24a2a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x310(%rsp)
movl %eax, 0x30c(%rsp)
jmp 0x248f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x310(%rsp)
movl %eax, 0x30c(%rsp)
jmp 0x248ea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x310(%rsp)
movl %eax, 0x30c(%rsp)
leaq 0x190(%rsp), %rdi
callq 0xdeb0
leaq 0x170(%rsp), %rdi
callq 0x31f0
leaq 0x16f(%rsp), %rdi
callq 0x3310
jmp 0x24a2a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x310(%rsp)
movl %eax, 0x30c(%rsp)
jmp 0x249cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x310(%rsp)
movl %eax, 0x30c(%rsp)
jmp 0x249be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x310(%rsp)
movl %eax, 0x30c(%rsp)
jmp 0x24972
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x310(%rsp)
movl %eax, 0x30c(%rsp)
leaq 0x138(%rsp), %rdi
callq 0x269e0
leaq 0xd5(%rsp), %rdi
callq 0x26a40
leaq 0x100(%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 0x24995
jmp 0x249be
leaq 0xd8(%rsp), %rdi
callq 0x31f0
leaq 0xd7(%rsp), %rdi
callq 0x3310
testb $0x1, 0xd6(%rsp)
jne 0x249e4
jmp 0x24a28
movq 0xf8(%rsp), %rax
leaq 0x100(%rsp), %rcx
cmpq %rax, %rcx
movq %rax, 0x8(%rsp)
je 0x24a26
movq 0x8(%rsp), %rdi
addq $-0x28, %rdi
movq %rdi, (%rsp)
callq 0xdeb0
movq (%rsp), %rax
leaq 0x100(%rsp), %rcx
cmpq %rcx, %rax
movq %rax, 0x8(%rsp)
jne 0x249fe
jmp 0x24a28
jmp 0x24a2a
movq 0x310(%rsp), %rdi
callq 0x3490
nopw (%rax,%rax)