// File: /workspace/github_cpp_makefile_star2_O3/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 0x1d550
addl 0x10(%r15), %eax
cmpl 0xb4(%rbx), %eax
jg 0x10ff8
movl 0xc(%r15), %esi
movl 0xc0(%rbx), %edx
movq %rbx, %rdi
callq 0x1d550
movl 0x8(%r15), %ecx
cmpq $0x4, %rcx
ja 0x10f8f
leaq 0x18(%rbx), %r14
movslq 0x10(%r15), %rdx
cltq
addq %rdx, %rax
movq 0x18(%rbx), %rdx
movq (%rdx,%rax,8), %r12
leaq 0x14299(%rip), %rax     # 0x24efc
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
leaq -0x38(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x1abfc
testq %r12, %r12
je 0x11370
movq (%r12), %rax
movq -0x8(%rax), %rax
leaq 0x22f38(%rip), %rcx     # 0x33bc8
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x10cb3
cmpb $0x2a, (%rdi)
je 0x11194
callq 0x6310
testl %eax, %eax
jne 0x11194
movl $0x10, %edi
callq 0x6200
movq %rax, %r15
leaq 0x22d69(%rip), %rsi     # 0x33a30
leaq 0x22efa(%rip), %rdx     # 0x33bc8
movq %r12, %rdi
xorl %ecx, %ecx
callq 0x6260
leaq 0x22e31(%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 0xa334
leaq -0x38(%rbp), %rdi
callq 0x1ac2a
jmp 0x10f8f
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x1a104
testq %r12, %r12
je 0x11366
movq (%r12), %rax
movq -0x8(%rax), %rax
leaq 0x22c2c(%rip), %rcx     # 0x33960
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x10d57
cmpb $0x2a, (%rdi)
je 0x1105a
callq 0x6310
testl %eax, %eax
jne 0x1105a
movl $0x10, %edi
callq 0x6200
movq %rax, %r15
leaq 0x22cc5(%rip), %rsi     # 0x33a30
leaq 0x22bee(%rip), %rdx     # 0x33960
movq %r12, %rdi
xorl %ecx, %ecx
callq 0x6260
leaq 0x22b25(%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 0xa334
leaq -0x38(%rbp), %rdi
callq 0x1a128
jmp 0x10f8f
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x1ae40
testq %r12, %r12
je 0x1136b
movq (%r12), %rax
movq -0x8(%rax), %rax
leaq 0x22ec4(%rip), %rcx     # 0x33c98
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x10df7
cmpb $0x2a, (%rdi)
je 0x110f7
callq 0x6310
testl %eax, %eax
jne 0x110f7
movl $0x10, %edi
callq 0x6200
movq %rax, %r15
leaq 0x22c25(%rip), %rsi     # 0x33a30
leaq 0x22e86(%rip), %rdx     # 0x33c98
movq %r12, %rdi
xorl %ecx, %ecx
callq 0x6260
leaq 0x22dbd(%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 0xa334
leaq -0x38(%rbp), %rdi
callq 0x1ae64
jmp 0x10f8f
leaq -0x38(%rbp), %rdi
movl $0x61, %esi
callq 0x1b03c
testq %r12, %r12
je 0x11375
movq (%r12), %rax
movq -0x8(%rax), %rax
leaq 0x22ef1(%rip), %rcx     # 0x33d68
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x10e9a
cmpb $0x2a, (%rdi)
je 0x11231
callq 0x6310
testl %eax, %eax
jne 0x11231
movl $0x10, %edi
callq 0x6200
movq %rax, %r15
leaq 0x22b82(%rip), %rsi     # 0x33a30
leaq 0x22eb3(%rip), %rdx     # 0x33d68
movq %r12, %rdi
xorl %ecx, %ecx
callq 0x6260
leaq 0x22dea(%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 0xa334
leaq -0x38(%rbp), %rdi
callq 0x1b060
jmp 0x10f8f
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x1a9d4
testq %r12, %r12
je 0x1137a
movq (%r12), %rax
movq -0x8(%rax), %rax
leaq 0x22be1(%rip), %rcx     # 0x33af8
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x10f3a
cmpb $0x2a, (%rdi)
je 0x112ce
callq 0x6310
testl %eax, %eax
jne 0x112ce
movl $0x10, %edi
callq 0x6200
movq %rax, %r15
leaq 0x22ae2(%rip), %rsi     # 0x33a30
leaq 0x22ba3(%rip), %rdx     # 0x33af8
movq %r12, %rdi
xorl %ecx, %ecx
callq 0x6260
leaq 0x22ada(%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 0xa334
leaq -0x38(%rbp), %rdi
callq 0x1a9f8
incl 0xb4(%rbx)
leaq -0x1c0(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x13fc3(%rip), %rsi     # 0x24f6a
leaq 0x13fbf(%rip), %rdx     # 0x24f6d
leaq -0x1d0(%rbp), %rdi
callq 0x746c
addq $0x78, %rbx
leaq -0x1d0(%rbp), %rsi
movq %rbx, %rdi
callq 0x1cbc8
movq -0x1d0(%rbp), %rdi
cmpq %r14, %rdi
je 0x10fe8
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), %r15
movq %r15, -0x10(%r15)
leaq 0x13efe(%rip), %rsi     # 0x24f15
leaq 0x13f29(%rip), %rdx     # 0x24f47
leaq -0x1d0(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x1d0(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x21a42(%rip), %rsi     # 0x32a88
leaq 0xa11d(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0x11366
leaq -0x1d0(%rbp), %rdi
callq 0x6300
leaq -0x1c0(%rbp), %rbx
leaq 0x13ed4(%rip), %rsi     # 0x24f48
movl $0x21, %edx
movq %rbx, %rdi
callq 0x6270
movl 0x10(%r15), %esi
movq %rbx, %rdi
callq 0x63f0
leaq 0x14e08(%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 0x11668
movb $0x1, %r15b
leaq -0x58(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r15d, %r15d
leaq 0x219a5(%rip), %rsi     # 0x32a88
leaq 0xa080(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0x11366
leaq -0x1d0(%rbp), %rdi
callq 0x6300
leaq -0x1c0(%rbp), %rbx
leaq 0x13e37(%rip), %rsi     # 0x24f48
movl $0x21, %edx
movq %rbx, %rdi
callq 0x6270
movl 0x10(%r15), %esi
movq %rbx, %rdi
callq 0x63f0
leaq 0x14cd5(%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 0x11668
movb $0x1, %r15b
leaq -0x58(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r15d, %r15d
leaq 0x21908(%rip), %rsi     # 0x32a88
leaq 0x9fe3(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0x11366
leaq -0x1d0(%rbp), %rdi
callq 0x6300
leaq -0x1c0(%rbp), %rbx
leaq 0x13d9a(%rip), %rsi     # 0x24f48
movl $0x21, %edx
movq %rbx, %rdi
callq 0x6270
movl 0x10(%r15), %esi
movq %rbx, %rdi
callq 0x63f0
leaq 0x14bf1(%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 0x11668
movb $0x1, %r15b
leaq -0x58(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r15d, %r15d
leaq 0x2186b(%rip), %rsi     # 0x32a88
leaq 0x9f46(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0x11366
leaq -0x1d0(%rbp), %rdi
callq 0x6300
leaq -0x1c0(%rbp), %rbx
leaq 0x13cfd(%rip), %rsi     # 0x24f48
movl $0x21, %edx
movq %rbx, %rdi
callq 0x6270
movl 0x10(%r15), %esi
movq %rbx, %rdi
callq 0x63f0
leaq 0x14be5(%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 0x11668
movb $0x1, %r15b
leaq -0x58(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r15d, %r15d
leaq 0x217ce(%rip), %rsi     # 0x32a88
leaq 0x9ea9(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0x11366
leaq -0x1d0(%rbp), %rdi
callq 0x6300
leaq -0x1c0(%rbp), %rbx
leaq 0x13c60(%rip), %rsi     # 0x24f48
movl $0x21, %edx
movq %rbx, %rdi
callq 0x6270
movl 0x10(%r15), %esi
movq %rbx, %rdi
callq 0x63f0
leaq 0x14a6d(%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 0x11668
movb $0x1, %r15b
leaq -0x58(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r15d, %r15d
leaq 0x21731(%rip), %rsi     # 0x32a88
leaq 0x9e0c(%rip), %rdx      # 0x1b16a
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 0x1139b
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r15b, %r15b
jne 0x113a8
jmp 0x11484
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0x11484
movq %rax, %rbx
leaq -0x48(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x113d1
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r15b, %r15b
jne 0x113de
jmp 0x11495
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0x11495
movq %rax, %rbx
leaq -0x48(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x11407
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r15b, %r15b
jne 0x11414
jmp 0x114a6
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0x114a6
movq %rax, %rbx
leaq -0x48(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1143d
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r15b, %r15b
jne 0x11447
jmp 0x114b7
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0x114b7
movq %rax, %rbx
leaq -0x48(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1146d
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r15b, %r15b
jne 0x11477
jmp 0x114c8
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0x114c8
movq %rax, %rbx
leaq -0x1d0(%rbp), %rdi
callq 0x6440
jmp 0x114ed
movq %rax, %rbx
leaq -0x1d0(%rbp), %rdi
callq 0x6440
jmp 0x1150c
movq %rax, %rbx
leaq -0x1d0(%rbp), %rdi
callq 0x6440
jmp 0x114fe
movq %rax, %rbx
leaq -0x1d0(%rbp), %rdi
callq 0x6440
jmp 0x1151a
movq %rax, %rbx
leaq -0x1d0(%rbp), %rdi
callq 0x6440
jmp 0x11528
jmp 0x114ea
jmp 0x11509
jmp 0x114fb
jmp 0x11517
jmp 0x11525
jmp 0x114ea
jmp 0x114fb
jmp 0x11509
jmp 0x11517
jmp 0x11525
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x1a9f8
jmp 0x11588
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x1ac2a
jmp 0x11588
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x1b060
jmp 0x11588
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x1ae64
jmp 0x11588
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x1a128
jmp 0x11588
movq %rax, %rbx
movq -0x1d0(%rbp), %rdi
cmpq %r15, %rdi
je 0x11551
movq -0x1c0(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0x1155b
jmp 0x11588
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0x11588
movq %rax, %rbx
movq -0x1d0(%rbp), %rdi
cmpq %r14, %rdi
je 0x11588
movq -0x1c0(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x11588
movq %rax, %rbx
movq %rbx, %rdi
callq 0x6410