// File: /workspace/github_cpp_makefile_star2_O3/zerolfx[P]P-Machine/grt.cpp
// Function: Grt::execute(StackMachine*)
void Grt::execute(StackMachine *stack) 
{
	// check if the stack contains at least two entries
	if(stack->fSP < 1)
		throw ExecutionError("instruction grt: requires 2 stackelements to be present.");

	switch(fType)
	{
		case integer:
		{
			StackInteger p1;

			// check if the two uppermost stackentries are of type integer
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP])))
				throw ExecutionError("instruction grt: SP does not point to element of type integer.");
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP - 1])))
				throw ExecutionError("instruction grt: SP - 1 does not point to element of type integer.");

			break;
		}	
		case real:
		{
			StackReal p1;
			// check if the two uppermost stackentries are of type real
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP])))
				throw ExecutionError("instruction grt: SP does not point to element of type real.");
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP - 1])))
				throw ExecutionError("instruction grt: SP - 1 does not point to element of type real.");
			break;
		}
		case boolean:
		{
			StackBoolean p1;
			// check if the two uppermost stackentries are of type real
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP])))
				throw ExecutionError("instruction grt: SP does not point to element of type boolean.");
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP - 1])))
				throw ExecutionError("instruction grt: SP - 1 does not point to element of type boolean.");
			break;
		}
		case character:
		{
			StackCharacter p1;
			// check if the two uppermost stackentries are of type real
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP])))
				throw ExecutionError("instruction grt: SP does not point to element of type character.");
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP - 1])))
				throw ExecutionError("instruction grt: SP - 1 does not point to element of type character.");
			break;
		}
		case address:
		{
			StackAddress p1;
			// check if the two uppermost stackentries are of type real
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP])))
				throw ExecutionError("instruction grt: SP does not point to element of type address.");
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP - 1])))
				throw ExecutionError("instruction grt: SP - 1 does not point to element of type address.");
			break;
		}

	}
		
	// compare
	StackBoolean *result;
	if(*(stack->fStore[stack->fSP - 1]) > *(stack->fStore[stack->fSP]))
		result = new StackBoolean(true);
	else
		result = new StackBoolean(false);
		
	// remove operands
	delete stack->fStore[stack->fSP];
	stack->fStore[stack->fSP] = 0;
	delete stack->fStore[stack->fSP - 1];
	stack->fStore[stack->fSP - 1] = 0;
	stack->fStore.pop_back();
	stack->fStore.pop_back();
	--stack->fSP;

	// put result on top of stack
	stack->fStore.push_back(result);
	
	// adding cost of this instruction
	stack->fTime.count("grt");

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
cmpl $0x0, 0xb4(%rsi)
jle 0xc3f5
movq %rsi, %rbx
movl 0x8(%rdi), %eax
cmpq $0x4, %rax
ja 0xc2c9
leaq 0x17f81(%rip), %rcx     # 0x23f2c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x50(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x1abfc
movslq 0xb4(%rbx), %r15
movq 0x18(%rbx), %r12
movq (%r12,%r15,8), %rax
testq %rax, %rax
je 0xc45d
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x27be2(%rip), %rcx     # 0x33bc8
movq 0x8(%rcx), %r14
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0xc00d
cmpb $0x2a, (%r14)
je 0xc519
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0xc519
movq -0x8(%r12,%r15,8), %rax
testq %rax, %rax
je 0xc45d
movq (%rax), %rax
movq -0x8(%rax), %rax
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0xc045
cmpb $0x2a, (%r14)
je 0xc6d6
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0xc6d6
leaq -0x50(%rbp), %rdi
callq 0x1ac2a
jmp 0xc2c9
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1a104
movslq 0xb4(%rbx), %r15
movq 0x18(%rbx), %r12
movq (%r12,%r15,8), %rax
testq %rax, %rax
je 0xc44e
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x278dc(%rip), %rcx     # 0x33960
movq 0x8(%rcx), %r14
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0xc0ab
cmpb $0x2a, (%r14)
je 0xc467
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0xc467
movq -0x8(%r12,%r15,8), %rax
testq %rax, %rax
je 0xc44e
movq (%rax), %rax
movq -0x8(%rax), %rax
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0xc0e3
cmpb $0x2a, (%r14)
je 0xc624
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0xc624
leaq -0x50(%rbp), %rdi
callq 0x1a128
jmp 0xc2c9
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1ae40
movslq 0xb4(%rbx), %r15
movq 0x18(%rbx), %r12
movq (%r12,%r15,8), %rax
testq %rax, %rax
je 0xc453
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x27b76(%rip), %rcx     # 0x33c98
movq 0x8(%rcx), %r14
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0xc149
cmpb $0x2a, (%r14)
je 0xc4c0
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0xc4c0
movq -0x8(%r12,%r15,8), %rax
testq %rax, %rax
je 0xc453
movq (%rax), %rax
movq -0x8(%rax), %rax
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0xc181
cmpb $0x2a, (%r14)
je 0xc67d
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0xc67d
leaq -0x50(%rbp), %rdi
callq 0x1ae64
jmp 0xc2c9
leaq -0x50(%rbp), %rdi
movl $0x61, %esi
callq 0x1b03c
movslq 0xb4(%rbx), %r15
movq 0x18(%rbx), %r12
movq (%r12,%r15,8), %rax
testq %rax, %rax
je 0xc458
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x27ba5(%rip), %rcx     # 0x33d68
movq 0x8(%rcx), %r14
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0xc1ea
cmpb $0x2a, (%r14)
je 0xc572
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0xc572
movq -0x8(%r12,%r15,8), %rax
testq %rax, %rax
je 0xc458
movq (%rax), %rax
movq -0x8(%rax), %rax
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0xc222
cmpb $0x2a, (%r14)
je 0xc72f
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0xc72f
leaq -0x50(%rbp), %rdi
callq 0x1b060
jmp 0xc2c9
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1a9d4
movslq 0xb4(%rbx), %r15
movq 0x18(%rbx), %r12
movq (%r12,%r15,8), %rax
testq %rax, %rax
je 0xc462
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x27897(%rip), %rcx     # 0x33af8
movq 0x8(%rcx), %r14
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0xc288
cmpb $0x2a, (%r14)
je 0xc5cb
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0xc5cb
movq -0x8(%r12,%r15,8), %rax
testq %rax, %rax
je 0xc462
movq (%rax), %rax
movq -0x8(%rax), %rax
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0xc2c0
cmpb $0x2a, (%r14)
je 0xc785
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0xc785
leaq -0x50(%rbp), %rdi
callq 0x1a9f8
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %rdi
movq (%rcx,%rax,8), %rsi
callq 0x1a995
movl %eax, %r15d
movl $0x10, %edi
callq 0x6200
movq %rax, %r14
testb %r15b, %r15b
je 0xc306
movq %r14, %rdi
movl $0x1, %esi
callq 0x1ae40
jmp 0xc310
movq %r14, %rdi
xorl %esi, %esi
callq 0x1ae40
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r12
testq %r12, %r12
je 0xc32c
movq %r12, %rdi
callq 0x1a300
leaq 0x18(%rbx), %r15
movl $0x8, %esi
movq %r12, %rdi
callq 0x6210
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq $0x0, (%rcx,%rax,8)
movq 0x18(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %r12
testq %r12, %r12
je 0xc366
movq %r12, %rdi
callq 0x1a300
movl $0x8, %esi
movq %r12, %rdi
callq 0x6210
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq $0x0, -0x8(%rcx,%rax,8)
addq $-0x10, 0x20(%rbx)
decq %rax
movl %eax, 0xb4(%rbx)
leaq -0x40(%rbp), %rsi
movq %r14, (%rsi)
movq %r15, %rdi
callq 0xa334
leaq -0x30(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x17e53(%rip), %rsi     # 0x24206
leaq 0x17e4f(%rip), %rdx     # 0x24209
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 0xc3e8
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
addq $0x30, %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 0x17b34(%rip), %rsi     # 0x23f45
leaq 0x17b65(%rip), %rdx     # 0x23f7d
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x2664e(%rip), %rsi     # 0x32a88
leaq 0xed29(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0xc7d9
callq 0x6250
callq 0x6250
callq 0x6250
callq 0x6250
callq 0x6250
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x17d01(%rip), %rsi     # 0x24184
leaq 0x17d38(%rip), %rdx     # 0x241c2
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x265dc(%rip), %rsi     # 0x32a88
leaq 0xecb7(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0xc7d9
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x17ba0(%rip), %rsi     # 0x2407c
leaq 0x17bd7(%rip), %rdx     # 0x240ba
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x26583(%rip), %rsi     # 0x32a88
leaq 0xec5e(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0xc7d9
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x17acb(%rip), %rsi     # 0x24000
leaq 0x17aff(%rip), %rdx     # 0x2403b
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x2652a(%rip), %rsi     # 0x32a88
leaq 0xec05(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0xc7d9
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x17b70(%rip), %rsi     # 0x240fe
leaq 0x17ba9(%rip), %rdx     # 0x2413e
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x264d1(%rip), %rsi     # 0x32a88
leaq 0xebac(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0xc7d9
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x17997(%rip), %rsi     # 0x23f7e
leaq 0x179ce(%rip), %rdx     # 0x23fbc
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x26478(%rip), %rsi     # 0x32a88
leaq 0xeb53(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0xc7d9
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x17b83(%rip), %rsi     # 0x241c3
leaq 0x17bbe(%rip), %rdx     # 0x24205
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x2641f(%rip), %rsi     # 0x32a88
leaq 0xeafa(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0xc7d9
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x17a22(%rip), %rsi     # 0x240bb
leaq 0x17a5d(%rip), %rdx     # 0x240fd
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x263c6(%rip), %rsi     # 0x32a88
leaq 0xeaa1(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0xc7d9
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x1794a(%rip), %rsi     # 0x2403c
leaq 0x17982(%rip), %rdx     # 0x2407b
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x2636d(%rip), %rsi     # 0x32a88
leaq 0xea48(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0xc7d9
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x179f4(%rip), %rsi     # 0x2413f
leaq 0x17a31(%rip), %rdx     # 0x24183
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x26314(%rip), %rsi     # 0x32a88
leaq 0xe9ef(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0xc7d9
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x1781c(%rip), %rsi     # 0x23fbd
leaq 0x17857(%rip), %rdx     # 0x23fff
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r12b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b14c
xorl %r12d, %r12d
leaq 0x262be(%rip), %rsi     # 0x32a88
leaq 0xe999(%rip), %rdx      # 0x1b16a
movq %r14, %rdi
callq 0x63e0
jmp 0xc7fc
jmp 0xc81e
jmp 0xc82e
jmp 0xc850
jmp 0xc860
jmp 0xc87f
jmp 0xc88c
jmp 0xc8ab
jmp 0xc8b8
jmp 0xc8d7
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0xc814
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0xc821
jmp 0xc8e7
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0xc8e7
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0xc846
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0xc853
jmp 0xc909
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0xc909
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0xc878
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0xc882
jmp 0xc8f8
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0xc8f8
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0xc8a4
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0xc8ae
jmp 0xc917
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0xc917
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0xc8d0
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0xc8da
jmp 0xc925
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0xc925
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1a9f8
jmp 0xc988
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1ac2a
jmp 0xc988
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1b060
jmp 0xc988
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1ae64
jmp 0xc988
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1a128
jmp 0xc988
jmp 0xc932
movq %rax, %rbx
movl $0x10, %esi
movq %r14, %rdi
jmp 0xc97e
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0xc957
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
testb %r12b, %r12b
jne 0xc961
jmp 0xc988
movq %rax, %rbx
movq %r14, %rdi
callq 0x6170
jmp 0xc988
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r14, %rdi
je 0xc988
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0xc988
movq %rax, %rbx
movq %rbx, %rdi
callq 0x6410