// File: /workspace/github_cpp_makefile_star2_O1/zerolfx[P]P-Machine/lod.cpp
// Function: Lod::execute(StackMachine*)
void Lod::execute(StackMachine *stack)
{

	if(stack->base(fP, stack->fMP) + fQ > stack->fSP)
		throw ExecutionError("instruction lod: trying to access element above SP");
		
	StackElement *element = stack->fStore[stack->base(fP, stack->fMP) + fQ];
	
	switch(fType)
	{
		case integer:
		{
			StackInteger p;

			if(typeid(p) != typeid(*element))
			{
				strstream convertor;
				convertor << "instruction lod: element at MP + " << fQ << " you are trying to access is not of type integer.";
				throw ExecutionError(convertor.str());
			}
			else
				stack->fStore.push_back(new StackInteger(*(dynamic_cast<StackInteger*>(element))));

			break;
		}	
		case real:
		{
			StackReal p;

			if(typeid(p) != typeid(*element))
			{
				strstream convertor;
				convertor << "instruction lod: element at MP + " << fQ << " you are trying to access is not of type real.";
				throw ExecutionError(convertor.str());
			}
			else
				stack->fStore.push_back(new StackReal(*(dynamic_cast<StackReal*>(element))));


			break;
		}
		case boolean:
		{
			StackBoolean p;
			
			if(typeid(p) != typeid(*element))
			{
				strstream convertor;
				convertor << "instruction lod: element at MP + " << fQ << " you are trying to access is not of type boolean.";
				throw ExecutionError(convertor.str());
			}
			else
				stack->fStore.push_back(new StackBoolean(*(dynamic_cast<StackBoolean*>(element))));


			break;
		}
		case character:
		{
			StackCharacter p;

			if(typeid(p) != typeid(*element))
			{
				strstream convertor;
				convertor << "instruction lod: element at MP + " << fQ << " you are trying to access is not of type character.";
				throw ExecutionError(convertor.str());
			}
			else
				stack->fStore.push_back(new StackCharacter(*(dynamic_cast<StackCharacter*>(element))));


			break;
		}
		case address:
		{
			StackAddress p;
			
			if(typeid(p) != typeid(*element))
			{
				strstream convertor;
				convertor << "instruction lod: element at MP + " << fQ << " you are trying to access is not of type address.";
				throw ExecutionError(convertor.str());
			}
			else
				stack->fStore.push_back(new StackAddress(*(dynamic_cast<StackAddress*>(element))));


			break;
		}
	}
	
	++stack->fSP;
	
	// adding cost of this instruction
	stack->fTime.count("lod");

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rsi, %rbx
movq %rdi, %r15
movl 0xc(%rdi), %esi
movl 0xc0(%rbx), %edx
movq %rbx, %rdi
callq 0x1d7fc
addl 0x10(%r15), %eax
cmpl 0xb4(%rbx), %eax
jg 0x11194
movl 0xc(%r15), %esi
movl 0xc0(%rbx), %edx
movq %rbx, %rdi
callq 0x1d7fc
movl 0x8(%r15), %ecx
cmpq $0x4, %rcx
ja 0x1112b
leaq 0x18(%rbx), %r14
movslq 0x10(%r15), %rdx
cltq
addq %rdx, %rax
movq 0x18(%rbx), %rdx
movq (%rdx,%rax,8), %r12
leaq 0x140fd(%rip), %rax     # 0x24efc
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
leaq -0x38(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x1aec8
testq %r12, %r12
je 0x1150d
movq (%r12), %rax
movq -0x8(%rax), %rax
leaq 0x22d9c(%rip), %rcx     # 0x33bc8
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x10e4f
cmpb $0x2a, (%rdi)
je 0x11331
callq 0x6310
testl %eax, %eax
jne 0x11331
movl $0x10, %edi
callq 0x6200
movq %rax, %r15
leaq 0x22bcd(%rip), %rsi     # 0x33a30
leaq 0x22d5e(%rip), %rdx     # 0x33bc8
movq %r12, %rdi
xorl %ecx, %ecx
callq 0x6260
leaq 0x22c95(%rip), %rcx     # 0x33b10
addq $0x10, %rcx
movq %rcx, (%r15)
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x8(%r15)
leaq -0x1d0(%rbp), %rsi
movq %r15, (%rsi)
movq %r14, %rdi
callq 0xa3ae
leaq -0x38(%rbp), %rdi
callq 0x1aef6
jmp 0x1112b
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x1a3d0
testq %r12, %r12
je 0x11503
movq (%r12), %rax
movq -0x8(%rax), %rax
leaq 0x22a90(%rip), %rcx     # 0x33960
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x10ef3
cmpb $0x2a, (%rdi)
je 0x111f7
callq 0x6310
testl %eax, %eax
jne 0x111f7
movl $0x10, %edi
callq 0x6200
movq %rax, %r15
leaq 0x22b29(%rip), %rsi     # 0x33a30
leaq 0x22a52(%rip), %rdx     # 0x33960
movq %r12, %rdi
xorl %ecx, %ecx
callq 0x6260
leaq 0x22989(%rip), %rcx     # 0x338a8
addq $0x10, %rcx
movq %rcx, (%r15)
movl 0x8(%rax), %eax
movl %eax, 0x8(%r15)
leaq -0x1d0(%rbp), %rsi
movq %r15, (%rsi)
movq %r14, %rdi
callq 0xa3ae
leaq -0x38(%rbp), %rdi
callq 0x1a3f4
jmp 0x1112b
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x1b10c
testq %r12, %r12
je 0x11508
movq (%r12), %rax
movq -0x8(%rax), %rax
leaq 0x22d28(%rip), %rcx     # 0x33c98
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x10f93
cmpb $0x2a, (%rdi)
je 0x11294
callq 0x6310
testl %eax, %eax
jne 0x11294
movl $0x10, %edi
callq 0x6200
movq %rax, %r15
leaq 0x22a89(%rip), %rsi     # 0x33a30
leaq 0x22cea(%rip), %rdx     # 0x33c98
movq %r12, %rdi
xorl %ecx, %ecx
callq 0x6260
leaq 0x22c21(%rip), %rcx     # 0x33be0
addq $0x10, %rcx
movq %rcx, (%r15)
movl 0x8(%rax), %eax
movl %eax, 0x8(%r15)
leaq -0x1d0(%rbp), %rsi
movq %r15, (%rsi)
movq %r14, %rdi
callq 0xa3ae
leaq -0x38(%rbp), %rdi
callq 0x1b130
jmp 0x1112b
leaq -0x38(%rbp), %rdi
movl $0x61, %esi
callq 0x1b308
testq %r12, %r12
je 0x11512
movq (%r12), %rax
movq -0x8(%rax), %rax
leaq 0x22d55(%rip), %rcx     # 0x33d68
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x11036
cmpb $0x2a, (%rdi)
je 0x113ce
callq 0x6310
testl %eax, %eax
jne 0x113ce
movl $0x10, %edi
callq 0x6200
movq %rax, %r15
leaq 0x229e6(%rip), %rsi     # 0x33a30
leaq 0x22d17(%rip), %rdx     # 0x33d68
movq %r12, %rdi
xorl %ecx, %ecx
callq 0x6260
leaq 0x22c4e(%rip), %rcx     # 0x33cb0
addq $0x10, %rcx
movq %rcx, (%r15)
movb 0x8(%rax), %al
movb %al, 0x8(%r15)
leaq -0x1d0(%rbp), %rsi
movq %r15, (%rsi)
movq %r14, %rdi
callq 0xa3ae
leaq -0x38(%rbp), %rdi
callq 0x1b32c
jmp 0x1112b
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x1aca0
testq %r12, %r12
je 0x11517
movq (%r12), %rax
movq -0x8(%rax), %rax
leaq 0x22a45(%rip), %rcx     # 0x33af8
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x110d6
cmpb $0x2a, (%rdi)
je 0x1146b
callq 0x6310
testl %eax, %eax
jne 0x1146b
movl $0x10, %edi
callq 0x6200
movq %rax, %r15
leaq 0x22946(%rip), %rsi     # 0x33a30
leaq 0x22a07(%rip), %rdx     # 0x33af8
movq %r12, %rdi
xorl %ecx, %ecx
callq 0x6260
leaq 0x2293e(%rip), %rcx     # 0x33a40
addq $0x10, %rcx
movq %rcx, (%r15)
movl 0x8(%rax), %eax
movl %eax, 0x8(%r15)
leaq -0x1d0(%rbp), %rsi
movq %r15, (%rsi)
movq %r14, %rdi
callq 0xa3ae
leaq -0x38(%rbp), %rdi
callq 0x1acc4
incl 0xb4(%rbx)
leaq -0x1c0(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x13e27(%rip), %rsi     # 0x24f6a
leaq 0x13e23(%rip), %rdx     # 0x24f6d
leaq -0x1d0(%rbp), %rdi
callq 0x746c
addq $0x78, %rbx
leaq -0x1d0(%rbp), %rsi
movq %rbx, %rdi
callq 0x1ce78
movq -0x1d0(%rbp), %rdi
cmpq %r14, %rdi
je 0x11184
movq -0x1c0(%rbp), %rsi
incq %rsi
callq 0x6210
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x1c0(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x13d61(%rip), %rsi     # 0x24f15
leaq 0x13d8c(%rip), %rdx     # 0x24f47
leaq -0x1d0(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x1d0(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x218a5(%rip), %rsi     # 0x32a88
leaq 0xa24c(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0x11503
leaq -0x1d0(%rbp), %rdi
callq 0x6300
leaq -0x1c0(%rbp), %rbx
leaq 0x13d37(%rip), %rsi     # 0x24f48
movl $0x21, %edx
movq %rbx, %rdi
callq 0x6270
movl 0x10(%r15), %esi
movq %rbx, %rdi
callq 0x63f0
leaq 0x14c6b(%rip), %rsi     # 0x25e9c
movl $0x31, %edx
movq %rax, %rdi
callq 0x6270
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x1d0(%rbp), %rdi
callq 0x6340
leaq -0x58(%rbp), %rdi
leaq -0x21(%rbp), %rdx
movq %rax, %rsi
callq 0x1181e
movb $0x1, %r15b
leaq -0x58(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x21808(%rip), %rsi     # 0x32a88
leaq 0xa1af(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0x11503
leaq -0x1d0(%rbp), %rdi
callq 0x6300
leaq -0x1c0(%rbp), %rbx
leaq 0x13c9a(%rip), %rsi     # 0x24f48
movl $0x21, %edx
movq %rbx, %rdi
callq 0x6270
movl 0x10(%r15), %esi
movq %rbx, %rdi
callq 0x63f0
leaq 0x14b38(%rip), %rsi     # 0x25e06
movl $0x31, %edx
movq %rax, %rdi
callq 0x6270
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x1d0(%rbp), %rdi
callq 0x6340
leaq -0x58(%rbp), %rdi
leaq -0x21(%rbp), %rdx
movq %rax, %rsi
callq 0x1181e
movb $0x1, %r15b
leaq -0x58(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x2176b(%rip), %rsi     # 0x32a88
leaq 0xa112(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0x11503
leaq -0x1d0(%rbp), %rdi
callq 0x6300
leaq -0x1c0(%rbp), %rbx
leaq 0x13bfd(%rip), %rsi     # 0x24f48
movl $0x21, %edx
movq %rbx, %rdi
callq 0x6270
movl 0x10(%r15), %esi
movq %rbx, %rdi
callq 0x63f0
leaq 0x14a54(%rip), %rsi     # 0x25dbf
movl $0x2e, %edx
movq %rax, %rdi
callq 0x6270
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x1d0(%rbp), %rdi
callq 0x6340
leaq -0x58(%rbp), %rdi
leaq -0x21(%rbp), %rdx
movq %rax, %rsi
callq 0x1181e
movb $0x1, %r15b
leaq -0x58(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x216ce(%rip), %rsi     # 0x32a88
leaq 0xa075(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0x11503
leaq -0x1d0(%rbp), %rdi
callq 0x6300
leaq -0x1c0(%rbp), %rbx
leaq 0x13b60(%rip), %rsi     # 0x24f48
movl $0x21, %edx
movq %rbx, %rdi
callq 0x6270
movl 0x10(%r15), %esi
movq %rbx, %rdi
callq 0x63f0
leaq 0x14a48(%rip), %rsi     # 0x25e50
movl $0x33, %edx
movq %rax, %rdi
callq 0x6270
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x1d0(%rbp), %rdi
callq 0x6340
leaq -0x58(%rbp), %rdi
leaq -0x21(%rbp), %rdx
movq %rax, %rsi
callq 0x1181e
movb $0x1, %r15b
leaq -0x58(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x21631(%rip), %rsi     # 0x32a88
leaq 0x9fd8(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0x11503
leaq -0x1d0(%rbp), %rdi
callq 0x6300
leaq -0x1c0(%rbp), %rbx
leaq 0x13ac3(%rip), %rsi     # 0x24f48
movl $0x21, %edx
movq %rbx, %rdi
callq 0x6270
movl 0x10(%r15), %esi
movq %rbx, %rdi
callq 0x63f0
leaq 0x148d0(%rip), %rsi     # 0x25d75
movl $0x31, %edx
movq %rax, %rdi
callq 0x6270
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x1d0(%rbp), %rdi
callq 0x6340
leaq -0x58(%rbp), %rdi
leaq -0x21(%rbp), %rdx
movq %rax, %rsi
callq 0x1181e
movb $0x1, %r15b
leaq -0x58(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x21594(%rip), %rsi     # 0x32a88
leaq 0x9f3b(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
callq 0x6250
callq 0x6250
callq 0x6250
callq 0x6250
callq 0x6250
movq %rax, %rbx
leaq -0x48(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x11540
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x11540
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0x11633
movq %r14, %rdi
callq 0x6170
jmp 0x11633
movq %rax, %rbx
leaq -0x48(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1157a
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x1157a
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0x11644
movq %r14, %rdi
callq 0x6170
jmp 0x11644
movq %rax, %rbx
leaq -0x48(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x115b4
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x115b4
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0x11655
movq %r14, %rdi
callq 0x6170
jmp 0x11655
movq %rax, %rbx
leaq -0x48(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x115ee
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x115ee
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0x11666
movq %r14, %rdi
callq 0x6170
jmp 0x11666
movq %rax, %rbx
leaq -0x48(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x11621
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x11621
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0x11677
movq %r14, %rdi
callq 0x6170
jmp 0x11677
movq %rax, %rbx
leaq -0x1d0(%rbp), %rdi
callq 0x6440
jmp 0x1169c
movq %rax, %rbx
leaq -0x1d0(%rbp), %rdi
callq 0x6440
jmp 0x116be
movq %rax, %rbx
leaq -0x1d0(%rbp), %rdi
callq 0x6440
jmp 0x116ad
movq %rax, %rbx
leaq -0x1d0(%rbp), %rdi
callq 0x6440
jmp 0x116cc
movq %rax, %rbx
leaq -0x1d0(%rbp), %rdi
callq 0x6440
jmp 0x116da
jmp 0x11699
jmp 0x116bb
jmp 0x116aa
jmp 0x116c9
jmp 0x116d7
jmp 0x11699
jmp 0x116aa
jmp 0x116bb
jmp 0x116c9
jmp 0x116d7
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x1acc4
jmp 0x1173d
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x1aef6
jmp 0x1173d
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x1b32c
jmp 0x1173d
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x1b130
jmp 0x1173d
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x1a3f4
jmp 0x1173d
movq %rax, %rbx
movq -0x1d0(%rbp), %rdi
cmpq %r12, %rdi
je 0x1170b
movq -0x1c0(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x1170b
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0x1173d
movq %r14, %rdi
callq 0x6170
jmp 0x1173d
movq %rax, %rbx
movq -0x1d0(%rbp), %rdi
cmpq %r14, %rdi
je 0x1173d
movq -0x1c0(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x1173d
movq %rax, %rbx
movq %rbx, %rdi
callq 0x6410
nop