// File: /workspace/github_cpp_makefile_star2_O3/zerolfx[P]P-Machine/conv.cpp
// Function: Conv::execute(StackMachine*)
void Conv::execute(StackMachine *stack) 
{
	// check if the stack contains at least one entries
	if(stack->fSP < 0)
		throw ExecutionError("instruction conv: requires 1 stackelement to be present.");
	
	int integervalue;
	
	switch(fType1)
	{
		case integer:
		{
			StackInteger p1;

			// check if the uppermost stackentry is of type integer
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP])))
				throw ExecutionError("instruction conv: SP does not point to element of type integer.");
			
			integervalue = stack->fStore[stack->fSP]->getValue();
			
			break;
		}	
		case real:
		{
			StackReal p1;
			// check if the uppermost stackentry is of type real
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP])))
				throw ExecutionError("instruction conv: SP does not point to element of type real.");
			
			double realvalue = stack->fStore[stack->fSP]->getReal();
			delete stack->fStore[stack->fSP];	
			
			switch(fType2)
			{
				case integer:
					stack->fStore[stack->fSP] = new StackInteger(realvalue);
					break;
				case boolean:
					stack->fStore[stack->fSP] = new StackBoolean(realvalue);
					break;
				case character:
					stack->fStore[stack->fSP] = new StackCharacter(realvalue);
					break;
				case address:
					stack->fStore[stack->fSP] = new StackAddress(realvalue);
					break;
				case real:
					stack->fStore[stack->fSP] = new StackReal(realvalue);
					break;
			}

			return;
		}
		case character:
		{
			StackCharacter p1;
			// check if the uppermost stackentry is of type character
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP])))
				throw ExecutionError("instruction conv: SP does not point to element of type character.");
			
			integervalue = stack->fStore[stack->fSP]->getValue();
			
			break;  
		}
		case boolean:
		{
			StackBoolean p1;
			// check if the uppermost stackentry is of type boolean
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP])))
				throw ExecutionError("instruction conv: SP does not point to element of type boolean.");

			integervalue = stack->fStore[stack->fSP]->getBoolean();
			
			break;
		}
		case address:
		{
			StackAddress p1;
			// check if the uppermost stackentry is of type address
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP])))
				throw ExecutionError("instruction conv: SP does not point to element of type address.");
			
			integervalue = stack->fStore[stack->fSP]->getValue();

			break;
		}
	}
	
	delete stack->fStore[stack->fSP];	
	
	switch(fType2)
	{
		case integer:
			stack->fStore[stack->fSP] = new StackInteger(integervalue);
			break;
		case boolean:
			stack->fStore[stack->fSP] = new StackBoolean(static_cast<bool>(integervalue));
			break;
		case character:
			stack->fStore[stack->fSP] = new StackCharacter(static_cast<char>(integervalue));
			break;
		case address:
			stack->fStore[stack->fSP] = new StackAddress(integervalue);
			break;
		case real:
			stack->fStore[stack->fSP] = new StackReal(integervalue);
			break;
	}
	
	// adding cost of this instruction
	stack->fTime.count("conv");

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
cmpl $0x0, 0xb4(%rsi)
js 0x19c1e
movq %rsi, %rbx
movq %rdi, %r14
movl 0x8(%rdi), %eax
cmpq $0x4, %rax
ja 0x19a4b
leaq 0xcaee(%rip), %rcx      # 0x262b0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x50(%rbp), %rdi
xorpd %xmm0, %xmm0
callq 0x1abfc
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r15
testq %r15, %r15
je 0x19e36
movq (%r15), %r12
movq -0x8(%r12), %rax
leaq 0x1a3c9(%rip), %rcx     # 0x33bc8
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x19822
cmpb $0x2a, (%rdi)
je 0x19d29
callq 0x6310
testl %eax, %eax
jne 0x19d29
movq %r15, %rdi
callq *0x78(%r12)
movsd %xmm0, -0x58(%rbp)
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r15
testq %r15, %r15
je 0x1984b
movq %r15, %rdi
callq 0x1a300
movl $0x8, %esi
movq %r15, %rdi
callq 0x6210
movl 0xc(%r14), %eax
cmpq $0x4, %rax
ja 0x19c08
leaq 0xca57(%rip), %rcx      # 0x262c4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x10, %edi
callq 0x6200
movq %rax, %r14
movq %rax, %rdi
movsd -0x58(%rbp), %xmm0
callq 0x1abfc
jmp 0x19bf9
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1a104
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r15
testq %r15, %r15
je 0x19e2c
movq (%r15), %r12
movq -0x8(%r12), %rax
leaq 0x1a099(%rip), %rcx     # 0x33960
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x198ea
cmpb $0x2a, (%rdi)
je 0x19c77
callq 0x6310
testl %eax, %eax
jne 0x19c77
movq %r15, %rdi
callq *0x68(%r12)
movl %eax, %r15d
leaq -0x50(%rbp), %rdi
callq 0x1a128
jmp 0x19a4b
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1ae40
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r15
testq %r15, %r15
je 0x19e31
movq (%r15), %r12
movq -0x8(%r12), %rax
leaq 0x1a363(%rip), %rcx     # 0x33c98
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x19958
cmpb $0x2a, (%rdi)
je 0x19cd0
callq 0x6310
testl %eax, %eax
jne 0x19cd0
movq %r15, %rdi
callq *0x70(%r12)
movzbl %al, %r15d
leaq -0x50(%rbp), %rdi
callq 0x1ae64
jmp 0x19a4b
leaq -0x50(%rbp), %rdi
movl $0x61, %esi
callq 0x1b03c
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r15
testq %r15, %r15
je 0x19e3b
movq (%r15), %r12
movq -0x8(%r12), %rax
leaq 0x1a3c1(%rip), %rcx     # 0x33d68
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x199ca
cmpb $0x2a, (%rdi)
je 0x19d82
callq 0x6310
testl %eax, %eax
jne 0x19d82
movq %r15, %rdi
callq *0x68(%r12)
movl %eax, %r15d
leaq -0x50(%rbp), %rdi
callq 0x1b060
jmp 0x19a4b
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1a9d4
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r15
testq %r15, %r15
je 0x19e40
movq (%r15), %r12
movq -0x8(%r12), %rax
leaq 0x1a0e6(%rip), %rcx     # 0x33af8
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x19a35
cmpb $0x2a, (%rdi)
je 0x19dd8
callq 0x6310
testl %eax, %eax
jne 0x19dd8
movq %r15, %rdi
callq *0x68(%r12)
movl %eax, %r15d
leaq -0x50(%rbp), %rdi
callq 0x1a9f8
jmp 0x19a4b
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r12
testq %r12, %r12
je 0x19a67
movq %r12, %rdi
callq 0x1a300
movl $0x8, %esi
movq %r12, %rdi
callq 0x6210
movl 0xc(%r14), %eax
cmpq $0x4, %rax
ja 0x19b2a
leaq 0xc84f(%rip), %rcx      # 0x262d8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x10, %edi
callq 0x6200
movq %rax, %r14
cvtsi2sd %r15d, %xmm0
movq %rax, %rdi
callq 0x1abfc
jmp 0x19b1b
movl $0x10, %edi
callq 0x6200
movq %rax, %r14
movq %rax, %rdi
movl %r15d, %esi
callq 0x1a104
jmp 0x19b1b
movl $0x10, %edi
callq 0x6200
movq %rax, %r14
xorl %esi, %esi
testl %r15d, %r15d
setne %sil
movq %rax, %rdi
callq 0x1ae40
jmp 0x19b1b
movl $0x10, %edi
callq 0x6200
movq %rax, %r14
movsbl %r15b, %esi
movq %rax, %rdi
callq 0x1b03c
jmp 0x19b1b
movl $0x10, %edi
callq 0x6200
movq %rax, %r14
movq %rax, %rdi
movl %r15d, %esi
callq 0x1a9d4
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq %r14, (%rcx,%rax,8)
leaq -0x30(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0xc931(%rip), %rsi      # 0x2646a
leaq 0xc92e(%rip), %rdx      # 0x2646e
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 0x19c11
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x19c11
movl $0x10, %edi
callq 0x6200
movq %rax, %r14
cvttsd2si -0x58(%rbp), %esi
movq %rax, %rdi
callq 0x1a104
jmp 0x19bf9
movl $0x10, %edi
callq 0x6200
movq %rax, %r14
xorpd %xmm0, %xmm0
movsd -0x58(%rbp), %xmm1
cmpneqsd %xmm0, %xmm1
movq %xmm1, %rsi
andl $0x1, %esi
movq %rax, %rdi
callq 0x1ae40
jmp 0x19bf9
movl $0x10, %edi
callq 0x6200
movq %rax, %r14
cvttsd2si -0x58(%rbp), %eax
movsbl %al, %esi
movq %r14, %rdi
callq 0x1b03c
jmp 0x19bf9
movl $0x10, %edi
callq 0x6200
movq %rax, %r14
cvttsd2si -0x58(%rbp), %esi
movq %rax, %rdi
callq 0x1a9d4
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq %r14, (%rcx,%rax,8)
leaq -0x50(%rbp), %rdi
callq 0x1ac2a
addq $0x40, %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 0xc6b8(%rip), %rsi      # 0x262f2
leaq 0xc6e9(%rip), %rdx      # 0x2632a
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x18e25(%rip), %rsi     # 0x32a88
leaq 0x1500(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0x19e2c
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0xc797(%rip), %rsi      # 0x2642a
leaq 0xc7cf(%rip), %rdx      # 0x26469
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x18dcc(%rip), %rsi     # 0x32a88
leaq 0x14a7(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0x19e2c
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0xc6fe(%rip), %rsi      # 0x263ea
leaq 0xc736(%rip), %rdx      # 0x26429
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x18d73(%rip), %rsi     # 0x32a88
leaq 0x144e(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0x19e2c
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0xc626(%rip), %rsi      # 0x2636b
leaq 0xc65b(%rip), %rdx      # 0x263a7
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x18d1a(%rip), %rsi     # 0x32a88
leaq 0x13f5(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0x19e2c
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0xc60a(%rip), %rsi      # 0x263a8
leaq 0xc644(%rip), %rdx      # 0x263e9
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x18cc1(%rip), %rsi     # 0x32a88
leaq 0x139c(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0x19e2c
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0xc537(%rip), %rsi      # 0x2632b
leaq 0xc56f(%rip), %rdx      # 0x2636a
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x18c6b(%rip), %rsi     # 0x32a88
leaq 0x1346(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
callq 0x6250
callq 0x6250
callq 0x6250
callq 0x6250
callq 0x6250
jmp 0x19e4d
jmp 0x19e4d
jmp 0x19e4d
jmp 0x19e4d
movq %rax, %rbx
movl $0x10, %esi
movq %r14, %rdi
callq 0x6210
jmp 0x19f6d
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0x19e7a
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0x19e87
jmp 0x19f7e
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0x19f7e
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0x19eac
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0x19eb9
jmp 0x19f8c
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0x19f8c
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0x19ede
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0x19eeb
jmp 0x19f6d
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0x19f6d
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0x19f0d
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0x19f1a
jmp 0x19f9a
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0x19f9a
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0x19f3c
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0x19f46
jmp 0x19fa8
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0x19fa8
jmp 0x19f58
jmp 0x19f58
jmp 0x19f58
jmp 0x19f58
movq %rax, %rbx
movl $0x10, %esi
movq %r14, %rdi
jmp 0x19ff2
jmp 0x19f6a
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1ac2a
jmp 0x19ffc
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1a9f8
jmp 0x19ffc
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1b060
jmp 0x19ffc
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1ae64
jmp 0x19ffc
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1a128
jmp 0x19ffc
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0x19fcb
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0x19fd5
jmp 0x19ffc
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0x19ffc
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r14, %rdi
je 0x19ffc
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x19ffc
movq %rax, %rbx
movq %rbx, %rdi
callq 0x6410