// File: kram[P]kram/./src/parser/parser.cpp
// Function: Parser::function_parameter_with_default_value(Instruction*)
Instruction* Parser::function_parameter_with_default_value(Instruction* ins) {

	if (ins->instruction != Ins::FUNCTION_PARAMETER) {
		std::cout << "Parameter default value expected Ins::FUNCTION_PARAMETER before =, got:\n";
		ins->print();
		exit(1);
	}

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

	// Reverse one step because Parser::keyword_fn() is consuming the same tokens
	this->reverse();

	return ins;
}

// Assembly:
subq $0x178, %rsp            # imm = 0x178
movq %rdi, 0x170(%rsp)
movq %rsi, 0x168(%rsp)
movq 0x170(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x168(%rsp), %rax
cmpl $0xb, (%rax)
je 0x21e2d
movq 0x181d0(%rip), %rdi     # 0x39fd8
leaq 0xa20c(%rip), %rsi      # 0x2c01b
callq 0x32d0
movq 0x168(%rsp), %rdi
xorl %esi, %esi
callq 0x42f0
movl $0x1, %edi
callq 0x3330
movb $0x1, 0x76(%rsp)
leaq 0xd8(%rsp), %rax
movq %rax, 0xd0(%rsp)
leaq 0xaf(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x34a0
movq 0x60(%rsp), %rdx
leaq 0x9d7b(%rip), %rsi      # 0x2bbdb
leaq 0xb0(%rsp), %rdi
callq 0x3390
jmp 0x21e6f
leaq 0xd8(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0xd7e0
jmp 0x21e86
leaq 0x100(%rsp), %rax
movq %rax, 0x50(%rsp)
movq %rax, 0xd0(%rsp)
leaq 0x77(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x34a0
movq 0x58(%rsp), %rdx
leaq 0x93d0(%rip), %rsi      # 0x2b286
leaq 0x78(%rsp), %rdi
callq 0x3390
jmp 0x21ec2
movq 0x50(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0xd7e0
jmp 0x21ed3
movb $0x0, 0x76(%rsp)
leaq 0xd8(%rsp), %rax
movq %rax, 0x128(%rsp)
movq $0x2, 0x130(%rsp)
leaq 0x75(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x26940
movq 0x48(%rsp), %rcx
movq 0x128(%rsp), %rsi
movq 0x130(%rsp), %rdx
leaq 0x138(%rsp), %rdi
callq 0x26950
jmp 0x21f27
movq 0x68(%rsp), %rsi
leaq 0x150(%rsp), %rdi
leaq 0x138(%rsp), %rdx
callq 0x20b20
jmp 0x21f43
movq 0x168(%rsp), %rdi
addq $0x50, %rdi
leaq 0x150(%rsp), %rsi
callq 0x26e30
leaq 0x150(%rsp), %rdi
callq 0x5560
leaq 0x138(%rsp), %rdi
callq 0x269e0
leaq 0x75(%rsp), %rdi
callq 0x26a40
leaq 0xd8(%rsp), %rax
movq %rax, 0x38(%rsp)
addq $0x50, %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rdi
addq $-0x28, %rdi
movq %rdi, 0x30(%rsp)
callq 0xdeb0
movq 0x38(%rsp), %rcx
movq 0x30(%rsp), %rax
cmpq %rcx, %rax
movq %rax, 0x40(%rsp)
jne 0x21f96
leaq 0x78(%rsp), %rdi
callq 0x31f0
leaq 0x77(%rsp), %rdi
callq 0x3310
leaq 0xb0(%rsp), %rdi
callq 0x31f0
leaq 0xaf(%rsp), %rdi
callq 0x3310
movq 0x68(%rsp), %rdi
callq 0x229d0
movq 0x168(%rsp), %rax
addq $0x178, %rsp            # imm = 0x178
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
jmp 0x2210a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
jmp 0x220fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
jmp 0x220f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
jmp 0x220e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
jmp 0x220a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
leaq 0x138(%rsp), %rdi
callq 0x269e0
leaq 0x75(%rsp), %rdi
callq 0x26a40
leaq 0xd8(%rsp), %rax
movq %rax, 0x20(%rsp)
addq $0x50, %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rdi
addq $-0x28, %rdi
movq %rdi, 0x18(%rsp)
callq 0xdeb0
movq 0x20(%rsp), %rcx
movq 0x18(%rsp), %rax
cmpq %rcx, %rax
movq %rax, 0x28(%rsp)
jne 0x220c0
jmp 0x220e9
leaq 0x78(%rsp), %rdi
callq 0x31f0
leaq 0x77(%rsp), %rdi
callq 0x3310
leaq 0xb0(%rsp), %rdi
callq 0x31f0
leaq 0xaf(%rsp), %rdi
callq 0x3310
testb $0x1, 0x76(%rsp)
jne 0x22120
jmp 0x22166
movq 0xd0(%rsp), %rax
leaq 0xd8(%rsp), %rcx
cmpq %rax, %rcx
movq %rax, 0x10(%rsp)
je 0x22164
movq 0x10(%rsp), %rdi
addq $-0x28, %rdi
movq %rdi, 0x8(%rsp)
callq 0xdeb0
movq 0x8(%rsp), %rax
leaq 0xd8(%rsp), %rcx
cmpq %rcx, %rax
movq %rax, 0x10(%rsp)
jne 0x2213a
jmp 0x22166
jmp 0x22168
movq 0xa0(%rsp), %rdi
callq 0x3490
nopw %cs:(%rax,%rax)