// File: /workspace/github_cpp_makefile_star2_O1/zerolfx[P]P-Machine/ldo.cpp
// Function: Ldo::execute(StackMachine*)
void Ldo::execute(StackMachine *stack)
{
	if(stack->fSP < fQ)
		throw ExecutionError("instruction ldo: no element present at STORE[q].");
		
	switch(fType)
	{
		case integer:
		{
			StackInteger p1;

			// check if STORE[q] is of type integer
			if(typeid(p1) != typeid(*stack->fStore[fQ]))
			{
				throw ExecutionError("instruction ldo: type of STORE[q] is not of type integer.");
			}
			else
			{
				stack->fStore.push_back(new StackInteger(*(dynamic_cast<StackInteger*>(stack->fStore[fQ]))));
			}
				
			break;
		}	
		case real:
		{
			StackReal p1;
			
			// check if STORE[q] is of type real
			if(typeid(p1) != typeid(*stack->fStore[fQ]))
			{
				throw ExecutionError("instruction ldo: type of STORE[q] is not of type real.");
			}
			else
			{
				stack->fStore.push_back(new StackReal(*(dynamic_cast<StackReal*>(stack->fStore[fQ]))));
			}


			break;
		}
		case boolean:
		{
			StackBoolean p1;
			
			// check if STORE[q] is of type boolean
			if(typeid(p1) != typeid(*stack->fStore[fQ]))
			{
				throw ExecutionError("instruction ldo: type of STORE[q] is not of type boolean.");
			}
			else
			{
				stack->fStore.push_back(new StackBoolean(*(dynamic_cast<StackBoolean*>(stack->fStore[fQ]))));
			}


			break;
		}
		case character:
		{
			StackCharacter p1;
			
			// check if STORE[q] is of type character
			if(typeid(p1) != typeid(*stack->fStore[fQ]))
			{
				throw ExecutionError("instruction ldo: type of STORE[q] is not of type character.");
			}
			else
			{
				stack->fStore.push_back(new StackCharacter(*(dynamic_cast<StackCharacter*>(stack->fStore[fQ]))));
			}


			break;
		}
		case address:
		{
			StackAddress p1;

			// check if STORE[q] is of type address
			if(typeid(p1) != typeid(*stack->fStore[fQ]))
			{
				throw ExecutionError("instruction ldo: type of STORE[q] is not of type address.");
			}
			else
			{
				stack->fStore.push_back(new StackAddress(*(dynamic_cast<StackAddress*>(stack->fStore[fQ]))));
			}

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

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl 0xb4(%rsi), %eax
cmpl 0xc(%rdi), %eax
jl 0xf26a
movq %rsi, %rbx
movq %rdi, %r14
movl 0x8(%rdi), %eax
cmpq $0x4, %rax
ja 0xf211
leaq 0x15926(%rip), %rcx     # 0x247c0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x58(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x1aec8
movslq 0xc(%r14), %r12
movq 0x18(%rbx), %r13
movq (%r13,%r12,8), %rax
testq %rax, %rax
je 0xf488
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x24cf5(%rip), %rcx     # 0x33bc8
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0xeef6
cmpb $0x2a, (%rdi)
je 0xf378
callq 0x6310
testl %eax, %eax
jne 0xf378
movl $0x10, %edi
callq 0x6200
movq %rax, %r14
leaq 0x18(%rbx), %r15
movq (%r13,%r12,8), %rdi
leaq 0x24b1d(%rip), %rsi     # 0x33a30
leaq 0x24cae(%rip), %rdx     # 0x33bc8
xorl %ecx, %ecx
callq 0x6260
leaq 0x24be8(%rip), %rcx     # 0x33b10
addq $0x10, %rcx
movq %rcx, (%r14)
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x8(%r14)
leaq -0x48(%rbp), %rsi
movq %r14, (%rsi)
movq %r15, %rdi
callq 0xa3ae
leaq -0x58(%rbp), %rdi
callq 0x1aef6
jmp 0xf211
leaq -0x58(%rbp), %rdi
xorl %esi, %esi
callq 0x1a3d0
movslq 0xc(%r14), %r12
movq 0x18(%rbx), %r13
movq (%r13,%r12,8), %rax
testq %rax, %rax
je 0xf47e
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x249da(%rip), %rcx     # 0x33960
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0xefa9
cmpb $0x2a, (%rdi)
je 0xf2c4
callq 0x6310
testl %eax, %eax
jne 0xf2c4
movl $0x10, %edi
callq 0x6200
movq %rax, %r14
leaq 0x18(%rbx), %r15
movq (%r13,%r12,8), %rdi
leaq 0x24a6a(%rip), %rsi     # 0x33a30
leaq 0x24993(%rip), %rdx     # 0x33960
xorl %ecx, %ecx
callq 0x6260
leaq 0x248cd(%rip), %rcx     # 0x338a8
addq $0x10, %rcx
movq %rcx, (%r14)
movl 0x8(%rax), %eax
movl %eax, 0x8(%r14)
leaq -0x48(%rbp), %rsi
movq %r14, (%rsi)
movq %r15, %rdi
callq 0xa3ae
leaq -0x58(%rbp), %rdi
callq 0x1a3f4
jmp 0xf211
leaq -0x58(%rbp), %rdi
xorl %esi, %esi
callq 0x1b10c
movslq 0xc(%r14), %r12
movq 0x18(%rbx), %r13
movq (%r13,%r12,8), %rax
testq %rax, %rax
je 0xf483
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x24c63(%rip), %rcx     # 0x33c98
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0xf058
cmpb $0x2a, (%rdi)
je 0xf31e
callq 0x6310
testl %eax, %eax
jne 0xf31e
movl $0x10, %edi
callq 0x6200
movq %rax, %r14
leaq 0x18(%rbx), %r15
movq (%r13,%r12,8), %rdi
leaq 0x249bb(%rip), %rsi     # 0x33a30
leaq 0x24c1c(%rip), %rdx     # 0x33c98
xorl %ecx, %ecx
callq 0x6260
leaq 0x24b56(%rip), %rcx     # 0x33be0
addq $0x10, %rcx
movq %rcx, (%r14)
movl 0x8(%rax), %eax
movl %eax, 0x8(%r14)
leaq -0x48(%rbp), %rsi
movq %r14, (%rsi)
movq %r15, %rdi
callq 0xa3ae
leaq -0x58(%rbp), %rdi
callq 0x1b130
jmp 0xf211
leaq -0x58(%rbp), %rdi
movl $0x61, %esi
callq 0x1b308
movslq 0xc(%r14), %r12
movq 0x18(%rbx), %r13
movq (%r13,%r12,8), %rax
testq %rax, %rax
je 0xf48d
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x24c81(%rip), %rcx     # 0x33d68
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0xf10a
cmpb $0x2a, (%rdi)
je 0xf3d2
callq 0x6310
testl %eax, %eax
jne 0xf3d2
movl $0x10, %edi
callq 0x6200
movq %rax, %r14
leaq 0x18(%rbx), %r15
movq (%r13,%r12,8), %rdi
leaq 0x24909(%rip), %rsi     # 0x33a30
leaq 0x24c3a(%rip), %rdx     # 0x33d68
xorl %ecx, %ecx
callq 0x6260
leaq 0x24b74(%rip), %rcx     # 0x33cb0
addq $0x10, %rcx
movq %rcx, (%r14)
movb 0x8(%rax), %al
movb %al, 0x8(%r14)
leaq -0x48(%rbp), %rsi
movq %r14, (%rsi)
movq %r15, %rdi
callq 0xa3ae
leaq -0x58(%rbp), %rdi
callq 0x1b32c
jmp 0xf211
leaq -0x58(%rbp), %rdi
xorl %esi, %esi
callq 0x1aca0
movslq 0xc(%r14), %r12
movq 0x18(%rbx), %r13
movq (%r13,%r12,8), %rax
testq %rax, %rax
je 0xf492
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x24962(%rip), %rcx     # 0x33af8
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0xf1b9
cmpb $0x2a, (%rdi)
je 0xf429
callq 0x6310
testl %eax, %eax
jne 0xf429
movl $0x10, %edi
callq 0x6200
movq %rax, %r14
leaq 0x18(%rbx), %r15
movq (%r13,%r12,8), %rdi
leaq 0x2485a(%rip), %rsi     # 0x33a30
leaq 0x2491b(%rip), %rdx     # 0x33af8
xorl %ecx, %ecx
callq 0x6260
leaq 0x24855(%rip), %rcx     # 0x33a40
addq $0x10, %rcx
movq %rcx, (%r14)
movl 0x8(%rax), %eax
movl %eax, 0x8(%r14)
leaq -0x48(%rbp), %rsi
movq %r14, (%rsi)
movq %r15, %rdi
callq 0xa3ae
leaq -0x58(%rbp), %rdi
callq 0x1acc4
incl 0xb4(%rbx)
leaq -0x38(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x15705(%rip), %rsi     # 0x2492b
leaq 0x15701(%rip), %rdx     # 0x2492e
leaq -0x48(%rbp), %rdi
callq 0x746c
addq $0x78, %rbx
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x1ce78
movq -0x48(%rbp), %rdi
cmpq %r14, %rdi
je 0xf25b
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x6210
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x38(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x15552(%rip), %rsi     # 0x247d9
leaq 0x1557b(%rip), %rdx     # 0x24809
leaq -0x48(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x237d8(%rip), %rsi     # 0x32a88
leaq 0xc17f(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0xf47e
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x38(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x15610(%rip), %rsi     # 0x248f1
leaq 0x15642(%rip), %rdx     # 0x2492a
leaq -0x48(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x2377e(%rip), %rsi     # 0x32a88
leaq 0xc125(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0xf47e
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x38(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x15540(%rip), %rsi     # 0x2487b
leaq 0x15572(%rip), %rdx     # 0x248b4
leaq -0x48(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x23724(%rip), %rsi     # 0x32a88
leaq 0xc0cb(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0xf47e
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x38(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x154af(%rip), %rsi     # 0x24844
leaq 0x154de(%rip), %rdx     # 0x2487a
leaq -0x48(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x236ca(%rip), %rsi     # 0x32a88
leaq 0xc071(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0xf47e
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x38(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x154c6(%rip), %rsi     # 0x248b5
leaq 0x154fa(%rip), %rdx     # 0x248f0
leaq -0x48(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x23670(%rip), %rsi     # 0x32a88
leaq 0xc017(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0xf47e
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x38(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x153c4(%rip), %rsi     # 0x2480a
leaq 0x153f6(%rip), %rdx     # 0x24843
leaq -0x48(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x23619(%rip), %rsi     # 0x32a88
leaq 0xbfc0(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
callq 0x6250
callq 0x6250
callq 0x6250
callq 0x6250
callq 0x6250
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0xf4b7
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0xf4b7
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0xf5a1
movq %r14, %rdi
callq 0x6170
jmp 0xf5a1
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0xf4ed
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0xf4ed
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0xf5c0
movq %r14, %rdi
callq 0x6170
jmp 0xf5c0
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0xf523
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0xf523
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0xf5b2
movq %r14, %rdi
callq 0x6170
jmp 0xf5b2
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0xf556
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0xf556
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0xf5ce
movq %r14, %rdi
callq 0x6170
jmp 0xf5ce
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0xf585
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0xf585
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0xf5dc
movq %r14, %rdi
callq 0x6170
jmp 0xf5dc
jmp 0xf59e
jmp 0xf5af
jmp 0xf5bd
jmp 0xf5cb
jmp 0xf5d9
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x1acc4
jmp 0xf633
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x1aef6
jmp 0xf633
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x1b32c
jmp 0xf633
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x1b130
jmp 0xf633
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x1a3f4
jmp 0xf633
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0xf607
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0xf607
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0xf633
movq %r14, %rdi
callq 0x6170
jmp 0xf633
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r14, %rdi
je 0xf633
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0xf633
movq %rax, %rbx
movq %rbx, %rdi
callq 0x6410
nop