// File: /workspace/github_cpp_makefile_star2_O3/zerolfx[P]P-Machine/out.cpp
// Function: Out::execute(StackMachine*)
void Out::execute(StackMachine *stack) 
{	
	switch(fType)
	{
		case integer:
		{
			StackInteger p1;
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP])))
				throw ExecutionError("instruction out: SP does not point to element of type integer.");
			
			cout << *stack->fStore[stack->fSP];
			
			// SP := SP + 1
			delete stack->fStore[stack->fSP];
			stack->fStore.pop_back();
			--stack->fSP;
		
			break;
		}
		case character:
		{
			StackCharacter p1;
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP])))
				throw ExecutionError("instruction out: SP does not point to element of type character.");
			
			cout << *stack->fStore[stack->fSP];
			
			// SP := SP + 1
			delete stack->fStore[stack->fSP];
			stack->fStore.pop_back();
			--stack->fSP;
		
			break;
		}
		case boolean:
		{
			StackBoolean p1;
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP])))
				throw ExecutionError("instruction out: SP does not point to element of type boolean.");
			
			cout << *stack->fStore[stack->fSP];
			
			// SP := SP + 1
			delete stack->fStore[stack->fSP];
			stack->fStore.pop_back();
			--stack->fSP;
		
			break;
		}
		case address:
		{
			StackAddress p1;
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP])))
				throw ExecutionError("instruction out: SP does not point to element of type boolean.");

			cout << *stack->fStore[stack->fSP];
			
			// SP := SP + 1
			delete stack->fStore[stack->fSP];
			stack->fStore.pop_back();
			--stack->fSP;
		
			break;
		}	
		case real:
		{
			StackInteger p1;
			StackReal p2;
				
			if(fPrecisionMarker)
			{
				// check if the two uppermost stackentries are of type integer and real respectively
				if(typeid(p1) != typeid(*(stack->fStore[stack->fSP])))
					throw ExecutionError("instruction out: SP does not point to element of type integer.");
				if(typeid(p2) != typeid(*(stack->fStore[stack->fSP - 1])))
					throw ExecutionError("instruction out: SP - 1 does not point to element of type real.");
								
				cout.precision(stack->fStore[stack->fSP]->getValue());
				cout << *stack->fStore[stack->fSP - 1];
				
				delete stack->fStore[stack->fSP];
				delete stack->fStore[stack->fSP - 1];
				stack->fStore.pop_back();
				stack->fStore.pop_back();
				stack->fSP -= 2;
			}
			else
			{
				if(typeid(p2) != typeid(*(stack->fStore[stack->fSP])))
					throw ExecutionError("instruction out: SP does not point to element of type real.");
				
				cout << *stack->fStore[stack->fSP];
				
				delete stack->fStore[stack->fSP];
				stack->fStore.pop_back();
				--stack->fSP;
			}			
			break;
		}
	}

	// adding cost of this instruction
	stack->fTime.count("out");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %rbx
movl 0x8(%rdi), %eax
cmpq $0x4, %rax
ja 0x18f70
leaq 0xd5b2(%rip), %rcx      # 0x260c0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rdi, %r15
leaq -0x58(%rbp), %rdi
xorl %esi, %esi
callq 0x1a9d4
leaq -0x68(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x1abfc
movslq 0xb4(%rbx), %r13
movq 0x18(%rbx), %r12
movq (%r12,%r13,8), %r14
cmpb $0x1, 0xc(%r15)
jne 0x18ed4
testq %r14, %r14
je 0x18fc3
movq (%r14), %r15
movq -0x8(%r15), %rax
leaq 0x1af96(%rip), %rcx     # 0x33af8
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x18b85
cmpb $0x2a, (%rdi)
je 0x19140
callq 0x6310
testl %eax, %eax
jne 0x19140
movq -0x8(%r12,%r13,8), %rax
testq %rax, %rax
je 0x18fc3
movq %r15, %r13
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x1b024(%rip), %rcx     # 0x33bc8
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x18bc7
cmpb $0x2a, (%rdi)
je 0x191ef
callq 0x6310
testl %eax, %eax
jne 0x191ef
movq 0x1b3f2(%rip), %r15     # 0x33fc0
movq (%r15), %rax
movq -0x18(%rax), %r12
movq %r14, %rdi
callq *0x68(%r13)
cltq
movq %rax, 0x8(%r15,%r12)
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %rsi
movq %r15, %rdi
callq 0x1a8ef
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r14
testq %r14, %r14
je 0x18c17
movq %r14, %rdi
callq 0x1a300
movl $0x8, %esi
movq %r14, %rdi
callq 0x6210
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %r14
movl $0xfffffffe, %r15d      # imm = 0xFFFFFFFE
movq $-0x10, %r12
jmp 0x18f39
leaq -0x58(%rbp), %rdi
xorl %esi, %esi
callq 0x1a104
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r14
testq %r14, %r14
je 0x1912c
movq (%r14), %rax
movq -0x8(%rax), %rax
leaq 0x1ace9(%rip), %rcx     # 0x33960
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x18c9a
cmpb $0x2a, (%rdi)
je 0x18fc8
callq 0x6310
testl %eax, %eax
jne 0x18fc8
movq 0x1b31f(%rip), %rdi     # 0x33fc0
movq %r14, %rsi
callq 0x1a8ef
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r14
testq %r14, %r14
je 0x18cc5
movq %r14, %rdi
callq 0x1a300
movl $0x8, %esi
movq %r14, %rdi
callq 0x6210
addq $-0x8, 0x20(%rbx)
decl 0xb4(%rbx)
leaq -0x58(%rbp), %rdi
callq 0x1a128
jmp 0x18f70
leaq -0x58(%rbp), %rdi
xorl %esi, %esi
callq 0x1ae40
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r14
testq %r14, %r14
je 0x19131
movq (%r14), %rax
movq -0x8(%rax), %rax
leaq 0x1af7c(%rip), %rcx     # 0x33c98
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x18d3f
cmpb $0x2a, (%rdi)
je 0x19021
callq 0x6310
testl %eax, %eax
jne 0x19021
movq 0x1b27a(%rip), %rdi     # 0x33fc0
movq %r14, %rsi
callq 0x1a8ef
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r14
testq %r14, %r14
je 0x18d6a
movq %r14, %rdi
callq 0x1a300
movl $0x8, %esi
movq %r14, %rdi
callq 0x6210
addq $-0x8, 0x20(%rbx)
decl 0xb4(%rbx)
leaq -0x58(%rbp), %rdi
callq 0x1ae64
jmp 0x18f70
leaq -0x58(%rbp), %rdi
movl $0x61, %esi
callq 0x1b03c
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r14
testq %r14, %r14
je 0x19136
movq (%r14), %rax
movq -0x8(%rax), %rax
leaq 0x1afa4(%rip), %rcx     # 0x33d68
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x18de7
cmpb $0x2a, (%rdi)
je 0x1907a
callq 0x6310
testl %eax, %eax
jne 0x1907a
movq 0x1b1d2(%rip), %rdi     # 0x33fc0
movq %r14, %rsi
callq 0x1a8ef
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r14
testq %r14, %r14
je 0x18e12
movq %r14, %rdi
callq 0x1a300
movl $0x8, %esi
movq %r14, %rdi
callq 0x6210
addq $-0x8, 0x20(%rbx)
decl 0xb4(%rbx)
leaq -0x58(%rbp), %rdi
callq 0x1b060
jmp 0x18f70
leaq -0x58(%rbp), %rdi
xorl %esi, %esi
callq 0x1a9d4
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r14
testq %r14, %r14
je 0x1913b
movq (%r14), %rax
movq -0x8(%rax), %rax
leaq 0x1ac8f(%rip), %rcx     # 0x33af8
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x18e8c
cmpb $0x2a, (%rdi)
je 0x190d3
callq 0x6310
testl %eax, %eax
jne 0x190d3
movq 0x1b12d(%rip), %rdi     # 0x33fc0
movq %r14, %rsi
callq 0x1a8ef
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r14
testq %r14, %r14
je 0x18eb7
movq %r14, %rdi
callq 0x1a300
movl $0x8, %esi
movq %r14, %rdi
callq 0x6210
addq $-0x8, 0x20(%rbx)
decl 0xb4(%rbx)
jmp 0x18f67
testq %r14, %r14
je 0x18fc3
movq (%r14), %rax
movq -0x8(%rax), %rax
leaq 0x1acdd(%rip), %rcx     # 0x33bc8
movq 0x8(%rcx), %rdi
movq 0x8(%rax), %rsi
cmpq %rsi, %rdi
je 0x18f0e
cmpb $0x2a, (%rdi)
je 0x19199
callq 0x6310
testl %eax, %eax
jne 0x19199
movq 0x1b0ab(%rip), %rdi     # 0x33fc0
movq %r14, %rsi
callq 0x1a8ef
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r14
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movq $-0x8, %r12
testq %r14, %r14
je 0x18f46
movq %r14, %rdi
callq 0x1a300
movl $0x8, %esi
movq %r14, %rdi
callq 0x6210
addq %r12, 0x20(%rbx)
addl %r15d, 0xb4(%rbx)
leaq -0x68(%rbp), %rdi
callq 0x1ac2a
leaq -0x58(%rbp), %rdi
callq 0x1a9f8
leaq -0x38(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0xd295(%rip), %rsi      # 0x26214
leaq 0xd291(%rip), %rdx      # 0x26217
leaq -0x48(%rbp), %rdi
callq 0x746c
addq $0x78, %rbx
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x1cbc8
movq -0x48(%rbp), %rdi
cmpq %r14, %rdi
je 0x18fb4
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x6210
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x6250
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x38(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0xd175(%rip), %rsi      # 0x26159
leaq 0xd1ac(%rip), %rdx      # 0x26197
leaq -0x48(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x19a7b(%rip), %rsi     # 0x32a88
leaq 0x2156(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0x19243
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x38(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0xd11c(%rip), %rsi      # 0x26159
leaq 0xd153(%rip), %rdx      # 0x26197
leaq -0x48(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x19a22(%rip), %rsi     # 0x32a88
leaq 0x20fd(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0x19243
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x38(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0xd082(%rip), %rsi      # 0x26118
leaq 0xd0bb(%rip), %rdx      # 0x26158
leaq -0x48(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x199c9(%rip), %rsi     # 0x32a88
leaq 0x20a4(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0x19243
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x38(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0xcfea(%rip), %rsi      # 0x260d9
leaq 0xd021(%rip), %rdx      # 0x26117
leaq -0x48(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x19970(%rip), %rsi     # 0x32a88
leaq 0x204b(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0x19243
callq 0x6250
callq 0x6250
callq 0x6250
callq 0x6250
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x38(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0xcf7d(%rip), %rsi      # 0x260d9
leaq 0xcfb4(%rip), %rdx      # 0x26117
leaq -0x48(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x19903(%rip), %rsi     # 0x32a88
leaq 0x1fde(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0x19243
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x38(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0xd023(%rip), %rsi      # 0x261d8
leaq 0xd057(%rip), %rdx      # 0x26213
leaq -0x48(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x198aa(%rip), %rsi     # 0x32a88
leaq 0x1f85(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0x19243
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x38(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0xcf8d(%rip), %rsi      # 0x26198
leaq 0xcfc5(%rip), %rdx      # 0x261d7
leaq -0x48(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x19854(%rip), %rsi     # 0x32a88
leaq 0x1f2f(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0x1924b
jmp 0x1926d
jmp 0x1924b
jmp 0x1926d
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0x19263
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0x19270
jmp 0x19367
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0x19367
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0x19295
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0x192a2
jmp 0x19370
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0x19370
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0x192c7
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0x192d1
jmp 0x1933d
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0x1933d
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0x192f3
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0x192fd
jmp 0x1934b
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0x1934b
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0x1931f
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0x19329
jmp 0x19359
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0x19359
jmp 0x19335
movq %rax, %rbx
jmp 0x19370
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x1b060
jmp 0x19398
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x1ae64
jmp 0x19398
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x1a128
jmp 0x19398
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x1ac2a
leaq -0x58(%rbp), %rdi
callq 0x1a9f8
jmp 0x19398
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r14, %rdi
je 0x19398
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x19398
movq %rax, %rbx
movq %rbx, %rdi
callq 0x6410