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

	/*if (prev->size() != 1) {
		std::cout << "oper_list_extraction: There can only be one list to extract from\n";
		exit(0);
	}*/

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

	if (ins->right.size() != 1) {
		std::cout << "oper_list_extraction: Only one value can be extracted\n";
		exit(0);
	}

	return ins;
}

// Assembly:
subq $0x168, %rsp            # imm = 0x168
movq %rdi, 0x160(%rsp)
movq %rsi, 0x158(%rsp)
movq 0x160(%rsp), %rax
movq %rax, 0x60(%rsp)
movl $0x80, %edi
callq 0x32e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x68(%rsp)
movl $0xf, %esi
callq 0x26dd0
jmp 0x22625
movq 0x68(%rsp), %rax
movq %rax, 0x150(%rsp)
movq 0x158(%rsp), %rax
movq %rax, 0x110(%rsp)
leaq 0x110(%rsp), %rax
movq %rax, 0x118(%rsp)
movq $0x1, 0x120(%rsp)
leaq 0x10f(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x16cc0
movq 0x58(%rsp), %rcx
movq 0x118(%rsp), %rsi
movq 0x120(%rsp), %rdx
leaq 0x128(%rsp), %rdi
callq 0x26e70
jmp 0x22694
movq 0x150(%rsp), %rdi
addq $0x38, %rdi
leaq 0x128(%rsp), %rsi
movq %rsi, 0x48(%rsp)
callq 0x26e30
movq 0x48(%rsp), %rdi
callq 0x5560
leaq 0x10f(%rsp), %rdi
callq 0x7010
movb $0x1, 0x76(%rsp)
leaq 0xa0(%rsp), %rax
movq %rax, 0x98(%rsp)
leaq 0x77(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x34a0
movq 0x50(%rsp), %rdx
leaq 0x8bbe(%rip), %rsi      # 0x2b2b7
leaq 0x78(%rsp), %rdi
callq 0x3390
jmp 0x22705
leaq 0xa0(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0xd7e0
jmp 0x22719
movb $0x0, 0x76(%rsp)
leaq 0xa0(%rsp), %rax
movq %rax, 0xc8(%rsp)
movq $0x1, 0xd0(%rsp)
leaq 0x75(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x26940
movq 0x40(%rsp), %rcx
movq 0xc8(%rsp), %rsi
movq 0xd0(%rsp), %rdx
leaq 0xd8(%rsp), %rdi
callq 0x26950
jmp 0x2276d
movq 0x60(%rsp), %rsi
leaq 0xf0(%rsp), %rdi
leaq 0xd8(%rsp), %rdx
callq 0x20b20
jmp 0x22789
movq 0x150(%rsp), %rdi
addq $0x50, %rdi
leaq 0xf0(%rsp), %rsi
callq 0x26e30
leaq 0xf0(%rsp), %rdi
callq 0x5560
leaq 0xd8(%rsp), %rdi
callq 0x269e0
leaq 0x75(%rsp), %rdi
callq 0x26a40
leaq 0xa0(%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 0x227dc
leaq 0x78(%rsp), %rdi
callq 0x31f0
leaq 0x77(%rsp), %rdi
callq 0x3310
movq 0x150(%rsp), %rdi
addq $0x50, %rdi
callq 0x56b0
cmpq $0x1, %rax
je 0x229aa
movq 0x1779f(%rip), %rdi     # 0x39fd8
leaq 0x9792(%rip), %rsi      # 0x2bfd2
callq 0x32d0
xorl %edi, %edi
callq 0x3330
movq 0x68(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x148(%rsp)
movl %eax, 0x144(%rsp)
callq 0x32b0
jmp 0x229ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x148(%rsp)
movl %eax, 0x144(%rsp)
leaq 0x10f(%rsp), %rdi
callq 0x7010
jmp 0x229ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x148(%rsp)
movl %eax, 0x144(%rsp)
jmp 0x22951
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x148(%rsp)
movl %eax, 0x144(%rsp)
jmp 0x22947
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x148(%rsp)
movl %eax, 0x144(%rsp)
jmp 0x228fe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x148(%rsp)
movl %eax, 0x144(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x269e0
leaq 0x75(%rsp), %rdi
callq 0x26a40
leaq 0xa0(%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 0x2291e
jmp 0x22947
leaq 0x78(%rsp), %rdi
callq 0x31f0
leaq 0x77(%rsp), %rdi
callq 0x3310
testb $0x1, 0x76(%rsp)
jne 0x22964
jmp 0x229a8
movq 0x98(%rsp), %rax
leaq 0xa0(%rsp), %rcx
cmpq %rax, %rcx
movq %rax, 0x8(%rsp)
je 0x229a6
movq 0x8(%rsp), %rdi
addq $-0x28, %rdi
movq %rdi, (%rsp)
callq 0xdeb0
movq (%rsp), %rax
leaq 0xa0(%rsp), %rcx
cmpq %rcx, %rax
movq %rax, 0x8(%rsp)
jne 0x2297e
jmp 0x229a8
jmp 0x229ba
movq 0x150(%rsp), %rax
addq $0x168, %rsp            # imm = 0x168
retq
movq 0x148(%rsp), %rdi
callq 0x3490
nopw (%rax,%rax)