// File: /workspace/github_cpp_makefile_star2_O1/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 0x19ece
movq %rsi, %rbx
movq %rdi, %r14
movl 0x8(%rdi), %eax
cmpq $0x4, %rax
ja 0x19cfb
leaq 0xc83e(%rip), %rcx      # 0x262b0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x50(%rbp), %rdi
xorpd %xmm0, %xmm0
callq 0x1aec8
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r15
testq %r15, %r15
je 0x1a0ec
movq (%r15), %r12
movq -0x8(%r12), %rax
leaq 0x1a119(%rip), %rcx     # 0x33bc8
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x19ad2
cmpb $0x2a, (%rdi)
je 0x19fdc
callq 0x6310
testl %eax, %eax
jne 0x19fdc
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 0x19b08
movq %r15, %rdi
callq 0x1a5cc
movl $0x8, %esi
movq %r15, %rdi
callq 0x6210
movl 0xc(%r14), %eax
cmpq $0x4, %rax
ja 0x19eb8
leaq 0xc7a7(%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 0x1aec8
jmp 0x19ea9
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1a3d0
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r15
testq %r15, %r15
je 0x1a0e2
movq (%r15), %r12
movq -0x8(%r12), %rax
leaq 0x19de9(%rip), %rcx     # 0x33960
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x19b9a
cmpb $0x2a, (%rdi)
je 0x19f28
callq 0x6310
testl %eax, %eax
jne 0x19f28
movq %r15, %rdi
callq *0x68(%r12)
movl %eax, %r15d
leaq -0x50(%rbp), %rdi
callq 0x1a3f4
jmp 0x19cfb
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1b10c
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r15
testq %r15, %r15
je 0x1a0e7
movq (%r15), %r12
movq -0x8(%r12), %rax
leaq 0x1a0b3(%rip), %rcx     # 0x33c98
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x19c08
cmpb $0x2a, (%rdi)
je 0x19f82
callq 0x6310
testl %eax, %eax
jne 0x19f82
movq %r15, %rdi
callq *0x70(%r12)
movzbl %al, %r15d
leaq -0x50(%rbp), %rdi
callq 0x1b130
jmp 0x19cfb
leaq -0x50(%rbp), %rdi
movl $0x61, %esi
callq 0x1b308
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r15
testq %r15, %r15
je 0x1a0f1
movq (%r15), %r12
movq -0x8(%r12), %rax
leaq 0x1a111(%rip), %rcx     # 0x33d68
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x19c7a
cmpb $0x2a, (%rdi)
je 0x1a036
callq 0x6310
testl %eax, %eax
jne 0x1a036
movq %r15, %rdi
callq *0x68(%r12)
movl %eax, %r15d
leaq -0x50(%rbp), %rdi
callq 0x1b32c
jmp 0x19cfb
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1aca0
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r15
testq %r15, %r15
je 0x1a0f6
movq (%r15), %r12
movq -0x8(%r12), %rax
leaq 0x19e36(%rip), %rcx     # 0x33af8
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x19ce5
cmpb $0x2a, (%rdi)
je 0x1a08d
callq 0x6310
testl %eax, %eax
jne 0x1a08d
movq %r15, %rdi
callq *0x68(%r12)
movl %eax, %r15d
leaq -0x50(%rbp), %rdi
callq 0x1acc4
jmp 0x19cfb
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r12
testq %r12, %r12
je 0x19d24
movq %r12, %rdi
callq 0x1a5cc
movl $0x8, %esi
movq %r12, %rdi
callq 0x6210
movl 0xc(%r14), %eax
cmpq $0x4, %rax
ja 0x19dda
leaq 0xc59f(%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 0x1aec8
jmp 0x19dcb
movl $0x10, %edi
callq 0x6200
movq %rax, %r14
movq %rax, %rdi
movl %r15d, %esi
callq 0x1a3d0
jmp 0x19dcb
movl $0x10, %edi
callq 0x6200
movq %rax, %r14
xorl %esi, %esi
testl %r15d, %r15d
setne %sil
movq %rax, %rdi
callq 0x1b10c
jmp 0x19dcb
movl $0x10, %edi
callq 0x6200
movq %rax, %r14
movsbl %r15b, %esi
movq %rax, %rdi
callq 0x1b308
jmp 0x19dcb
movl $0x10, %edi
callq 0x6200
movq %rax, %r14
movq %rax, %rdi
movl %r15d, %esi
callq 0x1aca0
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq %r14, (%rcx,%rax,8)
leaq -0x30(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0xc681(%rip), %rsi      # 0x2646a
leaq 0xc67e(%rip), %rdx      # 0x2646e
leaq -0x40(%rbp), %rdi
callq 0x746c
addq $0x78, %rbx
leaq -0x40(%rbp), %rsi
movq %rbx, %rdi
callq 0x1ce78
movq -0x40(%rbp), %rdi
cmpq %r14, %rdi
je 0x19ec1
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x19ec1
movl $0x10, %edi
callq 0x6200
movq %rax, %r14
cvttsd2si -0x58(%rbp), %esi
movq %rax, %rdi
callq 0x1a3d0
jmp 0x19ea9
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 0x1b10c
jmp 0x19ea9
movl $0x10, %edi
callq 0x6200
movq %rax, %r14
cvttsd2si -0x58(%rbp), %eax
movsbl %al, %esi
movq %r14, %rdi
callq 0x1b308
jmp 0x19ea9
movl $0x10, %edi
callq 0x6200
movq %rax, %r14
cvttsd2si -0x58(%rbp), %esi
movq %rax, %rdi
callq 0x1aca0
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq %r14, (%rcx,%rax,8)
leaq -0x50(%rbp), %rdi
callq 0x1aef6
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), %r12
movq %r12, -0x10(%r12)
leaq 0xc407(%rip), %rsi      # 0x262f2
leaq 0xc438(%rip), %rdx      # 0x2632a
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x18b74(%rip), %rsi     # 0x32a88
leaq 0x151b(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0x1a0e2
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0xc4e5(%rip), %rsi      # 0x2642a
leaq 0xc51d(%rip), %rdx      # 0x26469
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x18b1a(%rip), %rsi     # 0x32a88
leaq 0x14c1(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0x1a0e2
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0xc44b(%rip), %rsi      # 0x263ea
leaq 0xc483(%rip), %rdx      # 0x26429
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x18ac0(%rip), %rsi     # 0x32a88
leaq 0x1467(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0x1a0e2
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0xc372(%rip), %rsi      # 0x2636b
leaq 0xc3a7(%rip), %rdx      # 0x263a7
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x18a66(%rip), %rsi     # 0x32a88
leaq 0x140d(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0x1a0e2
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0xc355(%rip), %rsi      # 0x263a8
leaq 0xc38f(%rip), %rdx      # 0x263e9
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x18a0c(%rip), %rsi     # 0x32a88
leaq 0x13b3(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0x1a0e2
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0xc281(%rip), %rsi      # 0x2632b
leaq 0xc2b9(%rip), %rdx      # 0x2636a
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x189b5(%rip), %rsi     # 0x32a88
leaq 0x135c(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
callq 0x6250
callq 0x6250
callq 0x6250
callq 0x6250
callq 0x6250
jmp 0x1a103
jmp 0x1a103
jmp 0x1a103
jmp 0x1a103
movq %rax, %rbx
movl $0x10, %esi
movq %r14, %rdi
callq 0x6210
jmp 0x1a236
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x1a138
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x1a138
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0x1a247
movq %r14, %rdi
callq 0x6170
jmp 0x1a247
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x1a16e
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x1a16e
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0x1a255
movq %r14, %rdi
callq 0x6170
jmp 0x1a255
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x1a1a4
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x1a1a4
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0x1a236
movq %r14, %rdi
callq 0x6170
jmp 0x1a236
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x1a1d7
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x1a1d7
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0x1a263
movq %r14, %rdi
callq 0x6170
jmp 0x1a263
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x1a20a
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x1a20a
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0x1a271
movq %r14, %rdi
callq 0x6170
jmp 0x1a271
jmp 0x1a221
jmp 0x1a221
jmp 0x1a221
jmp 0x1a221
movq %rax, %rbx
movl $0x10, %esi
movq %r14, %rdi
jmp 0x1a2be
jmp 0x1a233
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1aef6
jmp 0x1a2c8
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1acc4
jmp 0x1a2c8
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1b32c
jmp 0x1a2c8
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1b130
jmp 0x1a2c8
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1a3f4
jmp 0x1a2c8
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x1a29c
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x1a29c
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0x1a2c8
movq %r14, %rdi
callq 0x6170
jmp 0x1a2c8
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r14, %rdi
je 0x1a2c8
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x1a2c8
movq %rax, %rbx
movq %rbx, %rdi
callq 0x6410