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

	if (prev->instruction != Ins::NAME) {
		std::cout << ": expects previous instruction to be of type NAME";
		exit(0);
	}

	// Get name from previous OP
	ins->name = prev->name;

	// Read the rest of the row
	std::vector<Instruction*> row = this->read_until_eol();

	// Expect exactly one name
	if (row.size() != 1 || row[0]->instruction != Ins::NAME) {
		std::cout << ": needs to be followed by exactly one NAME (aka the type)";
		exit(0);
	}

	std::string type = row[0]->name;

	if (type == "Number") {
		ins->right.push_back(this->number_init());
	} else if (type == "String") {
		ins->right.push_back(this->string_init());
	} else if (type == "Bool") {
		ins->right.push_back(this->boolean_init());
	} else {
		std::cout << "Does not know how to init type " << type << " after :";
		exit(0);
	}

	return ins;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x40, %rsp
movq %rsi, %r15
movq %rdi, %r14
movl $0x80, %edi
callq 0x3260
movq %rax, %rbx
movl $0x0, (%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)
cmpl $0x3, (%r15)
jne 0xecf3
leaq 0x8(%rbx), %rdi
addq $0x8, %r15
movq %r15, %rsi
callq 0x3150
leaq 0x28(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0xdd8e
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
cmpq $0x8, %rcx
jne 0xecde
movq (%rax), %rax
cmpl $0x3, (%rax)
jne 0xecde
leaq 0x18(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0x473c
leaq 0x3b2e(%rip), %rsi      # 0x12731
leaq 0x8(%rsp), %rdi
callq 0x30a0
testl %eax, %eax
je 0xec63
leaq 0x3b20(%rip), %rsi      # 0x12738
leaq 0x8(%rsp), %rdi
callq 0x30a0
testl %eax, %eax
je 0xec87
leaq 0x4659(%rip), %rsi      # 0x13286
leaq 0x8(%rsp), %rdi
callq 0x30a0
testl %eax, %eax
jne 0xed0d
callq 0x10dd0
movq %rax, (%rsp)
movq 0x58(%rbx), %rsi
cmpq 0x60(%rbx), %rsi
jne 0xec9a
movq %rbx, %rdi
addq $0x50, %rdi
movq %rsp, %rdx
callq 0x11c10
jmp 0xeca2
callq 0xf76a
movq %rax, (%rsp)
movq 0x58(%rbx), %rsi
cmpq 0x60(%rbx), %rsi
jne 0xec9a
movq %rbx, %rdi
addq $0x50, %rdi
movq %rsp, %rdx
callq 0x11c10
jmp 0xeca2
callq 0x10d0a
movq %rax, (%rsp)
movq 0x58(%rbx), %rsi
cmpq 0x60(%rbx), %rsi
je 0xeccd
movq %rax, (%rsi)
addq $0x8, 0x58(%rbx)
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0xecb1
callq 0x3230
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0xecc0
callq 0x3230
movq %rbx, %rax
addq $0x40, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq %rbx, %rdi
addq $0x50, %rdi
movq %rsp, %rdx
callq 0x11c10
jmp 0xeca2
movq 0xc2eb(%rip), %rdi      # 0x1afd0
leaq 0x4560(%rip), %rsi      # 0x1324c
callq 0x3250
jmp 0xed06
movq 0xc2d6(%rip), %rdi      # 0x1afd0
leaq 0x4519(%rip), %rsi      # 0x1321a
callq 0x3250
xorl %edi, %edi
callq 0x32c0
movq 0xc2bc(%rip), %rdi      # 0x1afd0
leaq 0x4570(%rip), %rsi      # 0x1328b
movl $0x1f, %edx
callq 0x32a0
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0xc29a(%rip), %rdi      # 0x1afd0
callq 0x32a0
leaq 0x4569(%rip), %rsi      # 0x132ab
movq %rax, %rdi
callq 0x3250
jmp 0xed06
jmp 0xed52
jmp 0xed52
jmp 0xed52
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0xed6b
callq 0x3230
jmp 0xed6b
jmp 0xed68
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0xed7a
callq 0x3230
movq %rbx, %rdi
callq 0x33c0