// File: /workspace/github_cpp_makefile_star2_O3/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 %r12
pushq %rbx
subq $0x30, %rsp
movl 0xb4(%rsi), %eax
cmpl 0xc(%rdi), %eax
jl 0xf127
movq %rsi, %rbx
movq %rdi, %r14
movl 0x8(%rdi), %eax
cmpq $0x4, %rax
ja 0xf0d0
leaq 0x15a58(%rip), %rcx     # 0x247c0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x50(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x1abfc
movslq 0xc(%r14), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r14
testq %r14, %r14
je 0xf33f
movq (%r14), %rax
movq -0x8(%rax), %rax
leaq 0x24e28(%rip), %rcx     # 0x33bc8
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0xedc3
cmpb $0x2a, (%rdi)
je 0xf232
callq 0x6310
testl %eax, %eax
jne 0xf232
movl $0x10, %edi
callq 0x6200
movq %rax, %r15
leaq 0x18(%rbx), %r12
leaq 0x24c55(%rip), %rsi     # 0x33a30
leaq 0x24de6(%rip), %rdx     # 0x33bc8
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x6260
leaq 0x24d1d(%rip), %rcx     # 0x33b10
addq $0x10, %rcx
movq %rcx, (%r15)
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x8(%r15)
leaq -0x40(%rbp), %rsi
movq %r15, (%rsi)
movq %r12, %rdi
callq 0xa334
leaq -0x50(%rbp), %rdi
callq 0x1ac2a
jmp 0xf0d0
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1a104
movslq 0xc(%r14), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r14
testq %r14, %r14
je 0xf335
movq (%r14), %rax
movq -0x8(%rax), %rax
leaq 0x24b10(%rip), %rcx     # 0x33960
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0xee73
cmpb $0x2a, (%rdi)
je 0xf180
callq 0x6310
testl %eax, %eax
jne 0xf180
movl $0x10, %edi
callq 0x6200
movq %rax, %r15
leaq 0x18(%rbx), %r12
leaq 0x24ba5(%rip), %rsi     # 0x33a30
leaq 0x24ace(%rip), %rdx     # 0x33960
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x6260
leaq 0x24a05(%rip), %rcx     # 0x338a8
addq $0x10, %rcx
movq %rcx, (%r15)
movl 0x8(%rax), %eax
movl %eax, 0x8(%r15)
leaq -0x40(%rbp), %rsi
movq %r15, (%rsi)
movq %r12, %rdi
callq 0xa334
leaq -0x50(%rbp), %rdi
callq 0x1a128
jmp 0xf0d0
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1ae40
movslq 0xc(%r14), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r14
testq %r14, %r14
je 0xf33a
movq (%r14), %rax
movq -0x8(%rax), %rax
leaq 0x24d9c(%rip), %rcx     # 0x33c98
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0xef1f
cmpb $0x2a, (%rdi)
je 0xf1d9
callq 0x6310
testl %eax, %eax
jne 0xf1d9
movl $0x10, %edi
callq 0x6200
movq %rax, %r15
leaq 0x18(%rbx), %r12
leaq 0x24af9(%rip), %rsi     # 0x33a30
leaq 0x24d5a(%rip), %rdx     # 0x33c98
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x6260
leaq 0x24c91(%rip), %rcx     # 0x33be0
addq $0x10, %rcx
movq %rcx, (%r15)
movl 0x8(%rax), %eax
movl %eax, 0x8(%r15)
leaq -0x40(%rbp), %rsi
movq %r15, (%rsi)
movq %r12, %rdi
callq 0xa334
leaq -0x50(%rbp), %rdi
callq 0x1ae64
jmp 0xf0d0
leaq -0x50(%rbp), %rdi
movl $0x61, %esi
callq 0x1b03c
movslq 0xc(%r14), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r14
testq %r14, %r14
je 0xf344
movq (%r14), %rax
movq -0x8(%rax), %rax
leaq 0x24dbd(%rip), %rcx     # 0x33d68
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0xefce
cmpb $0x2a, (%rdi)
je 0xf28b
callq 0x6310
testl %eax, %eax
jne 0xf28b
movl $0x10, %edi
callq 0x6200
movq %rax, %r15
leaq 0x18(%rbx), %r12
leaq 0x24a4a(%rip), %rsi     # 0x33a30
leaq 0x24d7b(%rip), %rdx     # 0x33d68
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x6260
leaq 0x24cb2(%rip), %rcx     # 0x33cb0
addq $0x10, %rcx
movq %rcx, (%r15)
movb 0x8(%rax), %al
movb %al, 0x8(%r15)
leaq -0x40(%rbp), %rsi
movq %r15, (%rsi)
movq %r12, %rdi
callq 0xa334
leaq -0x50(%rbp), %rdi
callq 0x1b060
jmp 0xf0d0
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1a9d4
movslq 0xc(%r14), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r14
testq %r14, %r14
je 0xf349
movq (%r14), %rax
movq -0x8(%rax), %rax
leaq 0x24aa1(%rip), %rcx     # 0x33af8
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0xf07a
cmpb $0x2a, (%rdi)
je 0xf2e1
callq 0x6310
testl %eax, %eax
jne 0xf2e1
movl $0x10, %edi
callq 0x6200
movq %rax, %r15
leaq 0x18(%rbx), %r12
leaq 0x2499e(%rip), %rsi     # 0x33a30
leaq 0x24a5f(%rip), %rdx     # 0x33af8
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x6260
leaq 0x24996(%rip), %rcx     # 0x33a40
addq $0x10, %rcx
movq %rcx, (%r15)
movl 0x8(%rax), %eax
movl %eax, 0x8(%r15)
leaq -0x40(%rbp), %rsi
movq %r15, (%rsi)
movq %r12, %rdi
callq 0xa334
leaq -0x50(%rbp), %rdi
callq 0x1a9f8
incl 0xb4(%rbx)
leaq -0x30(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x15846(%rip), %rsi     # 0x2492b
leaq 0x15842(%rip), %rdx     # 0x2492e
leaq -0x40(%rbp), %rdi
callq 0x746c
addq $0x78, %rbx
leaq -0x40(%rbp), %rsi
movq %rbx, %rdi
callq 0x1cbc8
movq -0x40(%rbp), %rdi
cmpq %r14, %rdi
je 0xf11a
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x15696(%rip), %rsi     # 0x247d9
leaq 0x156bf(%rip), %rdx     # 0x24809
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x2391c(%rip), %rsi     # 0x32a88
leaq 0xbff7(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0xf335
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x15755(%rip), %rsi     # 0x248f1
leaq 0x15787(%rip), %rdx     # 0x2492a
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x238c3(%rip), %rsi     # 0x32a88
leaq 0xbf9e(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0xf335
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x15686(%rip), %rsi     # 0x2487b
leaq 0x156b8(%rip), %rdx     # 0x248b4
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x2386a(%rip), %rsi     # 0x32a88
leaq 0xbf45(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0xf335
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x155f6(%rip), %rsi     # 0x24844
leaq 0x15625(%rip), %rdx     # 0x2487a
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x23811(%rip), %rsi     # 0x32a88
leaq 0xbeec(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0xf335
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x1560e(%rip), %rsi     # 0x248b5
leaq 0x15642(%rip), %rdx     # 0x248f0
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x237b8(%rip), %rsi     # 0x32a88
leaq 0xbe93(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0xf335
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x1550d(%rip), %rsi     # 0x2480a
leaq 0x1553f(%rip), %rdx     # 0x24843
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x23762(%rip), %rsi     # 0x32a88
leaq 0xbe3d(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
callq 0x6250
callq 0x6250
callq 0x6250
callq 0x6250
callq 0x6250
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0xf366
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0xf373
jmp 0xf446
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0xf446
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0xf398
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0xf3a5
jmp 0xf465
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0xf465
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0xf3ca
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0xf3d7
jmp 0xf457
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0xf457
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0xf3f9
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0xf403
jmp 0xf473
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0xf473
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0xf425
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0xf42f
jmp 0xf481
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0xf481
jmp 0xf443
jmp 0xf454
jmp 0xf462
jmp 0xf470
jmp 0xf47e
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1a9f8
jmp 0xf4d5
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1ac2a
jmp 0xf4d5
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1b060
jmp 0xf4d5
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1ae64
jmp 0xf4d5
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1a128
jmp 0xf4d5
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0xf4a4
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0xf4ae
jmp 0xf4d5
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0xf4d5
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r14, %rdi
je 0xf4d5
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0xf4d5
movq %rax, %rbx
movq %rbx, %rdi
callq 0x6410
nop