// File: /workspace/github_cpp_makefile_star2_O2/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 $0x40, %rsp
movl 0xb4(%rsi), %eax
cmpl 0xc(%rdi), %eax
jl 0xdbb9
movq %rsi, %rbx
movq %rdi, %r14
movl 0x8(%rdi), %eax
cmpq $0x4, %rax
ja 0xdb79
leaq 0x11f62(%rip), %rcx     # 0x1f7c0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x38(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x177d4
movslq 0xc(%r14), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0xdc0f
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x21332(%rip), %rdi     # 0x2ebc8
callq 0x76ba
testb %al, %al
jne 0xdd02
pushq $0x10
popq %rdi
callq 0x61d0
movq %rax, %r15
leaq 0x18(%rbx), %r12
movslq 0xc(%r14), %rax
movq (%r12), %rcx
movq (%rcx,%rax,8), %rdi
leaq 0x2116b(%rip), %rsi     # 0x2ea30
leaq 0x212fc(%rip), %rdx     # 0x2ebc8
xorl %ecx, %ecx
callq 0x6230
leaq 0x21236(%rip), %rcx     # 0x2eb10
addq $0x10, %rcx
movq %rcx, (%r15)
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x8(%r15)
leaq -0x58(%rbp), %rsi
movq %r15, (%rsi)
movq %r12, %rdi
callq 0x99a0
leaq -0x38(%rbp), %rdi
callq 0x17802
jmp 0xdb79
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x1704c
movslq 0xc(%r14), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0xdc05
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x21029(%rip), %rdi     # 0x2e960
callq 0x76ba
testb %al, %al
jne 0xdc1e
pushq $0x10
popq %rdi
callq 0x61d0
movq %rax, %r15
leaq 0x18(%rbx), %r12
movslq 0xc(%r14), %rax
movq (%r12), %rcx
movq (%rcx,%rax,8), %rdi
leaq 0x210ca(%rip), %rsi     # 0x2ea30
leaq 0x20ff3(%rip), %rdx     # 0x2e960
xorl %ecx, %ecx
callq 0x6230
leaq 0x20f2d(%rip), %rcx     # 0x2e8a8
addq $0x10, %rcx
movq %rcx, (%r15)
movl 0x8(%rax), %eax
movl %eax, 0x8(%r15)
leaq -0x58(%rbp), %rsi
movq %r15, (%rsi)
movq %r12, %rdi
callq 0x99a0
leaq -0x38(%rbp), %rdi
callq 0x17070
jmp 0xdb79
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x17a18
movslq 0xc(%r14), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0xdc0a
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x212c4(%rip), %rdi     # 0x2ec98
callq 0x76ba
testb %al, %al
jne 0xdc6a
pushq $0x10
popq %rdi
callq 0x61d0
movq %rax, %r15
leaq 0x18(%rbx), %r12
movslq 0xc(%r14), %rax
movq (%r12), %rcx
movq (%rcx,%rax,8), %rdi
leaq 0x2102d(%rip), %rsi     # 0x2ea30
leaq 0x2128e(%rip), %rdx     # 0x2ec98
xorl %ecx, %ecx
callq 0x6230
leaq 0x211c8(%rip), %rcx     # 0x2ebe0
addq $0x10, %rcx
movq %rcx, (%r15)
movl 0x8(%rax), %eax
movl %eax, 0x8(%r15)
leaq -0x58(%rbp), %rsi
movq %r15, (%rsi)
movq %r12, %rdi
callq 0x99a0
leaq -0x38(%rbp), %rdi
callq 0x17a3c
jmp 0xdb79
leaq -0x38(%rbp), %rdi
pushq $0x61
popq %rsi
callq 0x17c08
movslq 0xc(%r14), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0xdc14
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x212f6(%rip), %rdi     # 0x2ed68
callq 0x76ba
testb %al, %al
jne 0xdcb6
pushq $0x10
popq %rdi
callq 0x61d0
movq %rax, %r15
leaq 0x18(%rbx), %r12
movslq 0xc(%r14), %rax
movq (%r12), %rcx
movq (%rcx,%rax,8), %rdi
leaq 0x20f8f(%rip), %rsi     # 0x2ea30
leaq 0x212c0(%rip), %rdx     # 0x2ed68
xorl %ecx, %ecx
callq 0x6230
leaq 0x211fa(%rip), %rcx     # 0x2ecb0
addq $0x10, %rcx
movq %rcx, (%r15)
movb 0x8(%rax), %al
movb %al, 0x8(%r15)
leaq -0x58(%rbp), %rsi
movq %r15, (%rsi)
movq %r12, %rdi
callq 0x99a0
leaq -0x38(%rbp), %rdi
callq 0x17c2c
jmp 0xdb79
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x175ac
movslq 0xc(%r14), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0xdc19
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x20fe9(%rip), %rdi     # 0x2eaf8
callq 0x76ba
testb %al, %al
jne 0xdd4b
pushq $0x10
popq %rdi
callq 0x61d0
movq %rax, %r15
leaq 0x18(%rbx), %r12
movslq 0xc(%r14), %rax
movq (%r12), %rcx
movq (%rcx,%rax,8), %rdi
leaq 0x20ef2(%rip), %rsi     # 0x2ea30
leaq 0x20fb3(%rip), %rdx     # 0x2eaf8
xorl %ecx, %ecx
callq 0x6230
leaq 0x20eed(%rip), %rcx     # 0x2ea40
addq $0x10, %rcx
movq %rcx, (%r15)
movl 0x8(%rax), %eax
movl %eax, 0x8(%r15)
leaq -0x58(%rbp), %rsi
movq %r15, (%rsi)
movq %r12, %rdi
callq 0x99a0
leaq -0x38(%rbp), %rdi
callq 0x175d0
incl 0xb4(%rbx)
leaq 0x11da5(%rip), %rsi     # 0x1f92b
leaq -0x58(%rbp), %rdi
leaq -0x38(%rbp), %rdx
callq 0x72a6
addq $0x78, %rbx
leaq -0x58(%rbp), %rsi
movq %rbx, %rdi
callq 0x1925e
leaq -0x58(%rbp), %rdi
callq 0x60d0
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x11c0e(%rip), %rsi     # 0x1f7d9
leaq -0x58(%rbp), %rdi
leaq -0x38(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x58(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x1fe97(%rip), %rsi     # 0x2da88
leaq 0xa122(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xdd92
callq 0x6220
callq 0x6220
callq 0x6220
callq 0x6220
callq 0x6220
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x11cc1(%rip), %rsi     # 0x1f8f1
leaq -0x58(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x58(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x1fe32(%rip), %rsi     # 0x2da88
leaq 0xa0bd(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xdd92
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x11bff(%rip), %rsi     # 0x1f87b
leaq -0x58(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x58(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x1fde6(%rip), %rsi     # 0x2da88
leaq 0xa071(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xdd92
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x11bed(%rip), %rsi     # 0x1f8b5
leaq -0x58(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x58(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x1fd9a(%rip), %rsi     # 0x2da88
leaq 0xa025(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xdd92
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x11b30(%rip), %rsi     # 0x1f844
leaq -0x58(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x58(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x1fd4e(%rip), %rsi     # 0x2da88
leaq 0x9fd9(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xdd92
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x11aad(%rip), %rsi     # 0x1f80a
leaq -0x58(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x58(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x1fd05(%rip), %rsi     # 0x2da88
leaq 0x9f90(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0xddc1
jmp 0xde45
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0xddce
jmp 0xde53
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0xde45
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0xde53
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0xddee
jmp 0xde61
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0xde61
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0xde0e
jmp 0xde6f
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0xde6f
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0xde2e
jmp 0xde7d
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0xde7d
jmp 0xde42
jmp 0xde50
jmp 0xde5e
jmp 0xde6c
jmp 0xde7a
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x175d0
jmp 0xdeb9
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x17802
jmp 0xdeb9
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x17c2c
jmp 0xdeb9
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x17a3c
jmp 0xdeb9
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x17070
jmp 0xdeb9
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0xde9e
jmp 0xdeb9
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0xdeb9
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x60d0
jmp 0xdeb9
movq %rax, %rbx
movq %rbx, %rdi
callq 0x63f0
nop