// File: /workspace/github_cpp_makefile_star2_O2/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 %r12
pushq %rbx
subq $0x50, %rsp
movq %rsi, %rbx
movl 0x8(%rdi), %eax
cmpq $0x4, %rax
ja 0x1615a
leaq 0xb366(%rip), %rcx      # 0x210c0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rdi, %r14
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x175ac
leaq -0x68(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x177d4
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
cmpb $0x1, 0xc(%r14)
jne 0x160cf
testq %rax, %rax
je 0x16194
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x18d4a(%rip), %rdi     # 0x2eaf8
callq 0x76ba
testb %al, %al
jne 0x162dd
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %rax
testq %rax, %rax
je 0x16194
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x18de6(%rip), %rdi     # 0x2ebc8
callq 0x76ba
testb %al, %al
jne 0x16372
movq 0x191ca(%rip), %r14     # 0x2efc0
movq (%r14), %rax
movq -0x18(%rax), %r15
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rdi
movq (%rdi), %rax
callq *0x68(%rax)
cltq
movq %rax, 0x8(%r14,%r15)
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %rsi
movq %r14, %rdi
callq 0x174cd
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r14
testq %r14, %r14
je 0x15e4d
movq %r14, %rdi
callq 0x17248
pushq $0x8
popq %rsi
movq %r14, %rdi
callq 0x61e0
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %r14
pushq $-0x2
popq %r15
pushq $-0x10
jmp 0x16123
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x1704c
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0x16199
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x18abc(%rip), %rdi     # 0x2e960
callq 0x76ba
testb %al, %al
jne 0x161ad
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rsi
movq 0x190f9(%rip), %rdi     # 0x2efc0
callq 0x174cd
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r14
testq %r14, %r14
je 0x15ee8
movq %r14, %rdi
callq 0x17248
pushq $0x8
popq %rsi
movq %r14, %rdi
callq 0x61e0
addq $-0x8, 0x20(%rbx)
decl 0xb4(%rbx)
leaq -0x38(%rbp), %rdi
callq 0x17070
jmp 0x1615a
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x17a18
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0x1619e
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x18d5b(%rip), %rdi     # 0x2ec98
callq 0x76ba
testb %al, %al
jne 0x161f9
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rsi
movq 0x19060(%rip), %rdi     # 0x2efc0
callq 0x174cd
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r14
testq %r14, %r14
je 0x15f81
movq %r14, %rdi
callq 0x17248
pushq $0x8
popq %rsi
movq %r14, %rdi
callq 0x61e0
addq $-0x8, 0x20(%rbx)
decl 0xb4(%rbx)
leaq -0x38(%rbp), %rdi
callq 0x17a3c
jmp 0x1615a
leaq -0x38(%rbp), %rdi
pushq $0x61
popq %rsi
callq 0x17c08
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0x161a3
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x18d91(%rip), %rdi     # 0x2ed68
callq 0x76ba
testb %al, %al
jne 0x16245
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rsi
movq 0x18fc6(%rip), %rdi     # 0x2efc0
callq 0x174cd
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r14
testq %r14, %r14
je 0x1601b
movq %r14, %rdi
callq 0x17248
pushq $0x8
popq %rsi
movq %r14, %rdi
callq 0x61e0
addq $-0x8, 0x20(%rbx)
decl 0xb4(%rbx)
leaq -0x38(%rbp), %rdi
callq 0x17c2c
jmp 0x1615a
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x175ac
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0x161a8
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x18a88(%rip), %rdi     # 0x2eaf8
callq 0x76ba
testb %al, %al
jne 0x16291
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rsi
movq 0x18f2d(%rip), %rdi     # 0x2efc0
callq 0x174cd
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r14
testq %r14, %r14
je 0x160b4
movq %r14, %rdi
callq 0x17248
pushq $0x8
popq %rsi
movq %r14, %rdi
callq 0x61e0
addq $-0x8, 0x20(%rbx)
decl 0xb4(%rbx)
jmp 0x16151
testq %rax, %rax
je 0x16194
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x18ae2(%rip), %rdi     # 0x2ebc8
callq 0x76ba
testb %al, %al
jne 0x16329
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rsi
movq 0x18eb7(%rip), %rdi     # 0x2efc0
callq 0x174cd
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r14
pushq $-0x1
popq %r15
pushq $-0x8
popq %r12
testq %r14, %r14
je 0x16132
movq %r14, %rdi
callq 0x17248
pushq $0x8
popq %rsi
movq %r14, %rdi
callq 0x61e0
addq %r12, 0x20(%rbx)
addl %r15d, 0xb4(%rbx)
leaq -0x68(%rbp), %rdi
callq 0x17802
leaq -0x38(%rbp), %rdi
callq 0x175d0
leaq 0xb0b3(%rip), %rsi      # 0x21214
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 $0x50, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x6220
callq 0x6220
callq 0x6220
callq 0x6220
callq 0x6220
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0xaf9a(%rip), %rsi      # 0x21159
leaq -0x58(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x58(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x178a3(%rip), %rsi     # 0x2da88
leaq 0x1b2e(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0x163b9
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0xaf4e(%rip), %rsi      # 0x21159
leaq -0x58(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x58(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x17857(%rip), %rsi     # 0x2da88
leaq 0x1ae2(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0x163b9
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0xaec1(%rip), %rsi      # 0x21118
leaq -0x58(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x58(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x1780b(%rip), %rsi     # 0x2da88
leaq 0x1a96(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0x163b9
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0xae36(%rip), %rsi      # 0x210d9
leaq -0x58(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x58(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x177bf(%rip), %rsi     # 0x2da88
leaq 0x1a4a(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0x163b9
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0xadea(%rip), %rsi      # 0x210d9
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 0x17773(%rip), %rsi     # 0x2da88
leaq 0x19fe(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0x163b9
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0xae9d(%rip), %rsi      # 0x211d8
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 0x17727(%rip), %rsi     # 0x2da88
leaq 0x19b2(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0x163b9
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0xae14(%rip), %rsi      # 0x21198
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 0x176de(%rip), %rsi     # 0x2da88
leaq 0x1969(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0x163bf
jmp 0x163d7
jmp 0x163bf
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0x163da
jmp 0x164a1
jmp 0x163d7
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0x164a1
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0x16400
jmp 0x164aa
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0x164aa
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0x16423
jmp 0x16477
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0x16477
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0x16443
jmp 0x16485
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0x16485
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0x16463
jmp 0x16493
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0x16493
jmp 0x1646f
movq %rax, %rbx
jmp 0x164aa
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x17c2c
jmp 0x164c6
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x17a3c
jmp 0x164c6
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x17070
jmp 0x164c6
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x17802
leaq -0x38(%rbp), %rdi
callq 0x175d0
jmp 0x164c6
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x60d0
jmp 0x164c6
movq %rax, %rbx
movq %rbx, %rdi
callq 0x63f0