// File: /workspace/github_cpp_makefile_star2_O1/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 0xc4a9
movq %rsi, %rbx
movl 0x8(%rdi), %eax
cmpq $0x4, %rax
ja 0xc37d
leaq 0x17ecd(%rip), %rcx     # 0x23f2c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x50(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x1aec8
movslq 0xb4(%rbx), %r15
movq 0x18(%rbx), %r12
movq (%r12,%r15,8), %rax
testq %rax, %rax
je 0xc512
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x27b2e(%rip), %rcx     # 0x33bc8
movq 0x8(%rcx), %r14
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0xc0c1
cmpb $0x2a, (%r14)
je 0xc5d0
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0xc5d0
movq -0x8(%r12,%r15,8), %rax
testq %rax, %rax
je 0xc512
movq (%rax), %rax
movq -0x8(%rax), %rax
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0xc0f9
cmpb $0x2a, (%r14)
je 0xc792
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0xc792
leaq -0x50(%rbp), %rdi
callq 0x1aef6
jmp 0xc37d
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1a3d0
movslq 0xb4(%rbx), %r15
movq 0x18(%rbx), %r12
movq (%r12,%r15,8), %rax
testq %rax, %rax
je 0xc503
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x27828(%rip), %rcx     # 0x33960
movq 0x8(%rcx), %r14
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0xc15f
cmpb $0x2a, (%r14)
je 0xc51c
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0xc51c
movq -0x8(%r12,%r15,8), %rax
testq %rax, %rax
je 0xc503
movq (%rax), %rax
movq -0x8(%rax), %rax
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0xc197
cmpb $0x2a, (%r14)
je 0xc6de
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0xc6de
leaq -0x50(%rbp), %rdi
callq 0x1a3f4
jmp 0xc37d
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1b10c
movslq 0xb4(%rbx), %r15
movq 0x18(%rbx), %r12
movq (%r12,%r15,8), %rax
testq %rax, %rax
je 0xc508
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x27ac2(%rip), %rcx     # 0x33c98
movq 0x8(%rcx), %r14
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0xc1fd
cmpb $0x2a, (%r14)
je 0xc576
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0xc576
movq -0x8(%r12,%r15,8), %rax
testq %rax, %rax
je 0xc508
movq (%rax), %rax
movq -0x8(%rax), %rax
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0xc235
cmpb $0x2a, (%r14)
je 0xc738
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0xc738
leaq -0x50(%rbp), %rdi
callq 0x1b130
jmp 0xc37d
leaq -0x50(%rbp), %rdi
movl $0x61, %esi
callq 0x1b308
movslq 0xb4(%rbx), %r15
movq 0x18(%rbx), %r12
movq (%r12,%r15,8), %rax
testq %rax, %rax
je 0xc50d
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x27af1(%rip), %rcx     # 0x33d68
movq 0x8(%rcx), %r14
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0xc29e
cmpb $0x2a, (%r14)
je 0xc62a
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0xc62a
movq -0x8(%r12,%r15,8), %rax
testq %rax, %rax
je 0xc50d
movq (%rax), %rax
movq -0x8(%rax), %rax
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0xc2d6
cmpb $0x2a, (%r14)
je 0xc7ec
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0xc7ec
leaq -0x50(%rbp), %rdi
callq 0x1b32c
jmp 0xc37d
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1aca0
movslq 0xb4(%rbx), %r15
movq 0x18(%rbx), %r12
movq (%r12,%r15,8), %rax
testq %rax, %rax
je 0xc517
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x277e3(%rip), %rcx     # 0x33af8
movq 0x8(%rcx), %r14
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0xc33c
cmpb $0x2a, (%r14)
je 0xc684
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0xc684
movq -0x8(%r12,%r15,8), %rax
testq %rax, %rax
je 0xc517
movq (%rax), %rax
movq -0x8(%rax), %rax
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0xc374
cmpb $0x2a, (%r14)
je 0xc843
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0xc843
leaq -0x50(%rbp), %rdi
callq 0x1acc4
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %rdi
movq (%rcx,%rax,8), %rsi
callq 0x1ac61
movl %eax, %r15d
movl $0x10, %edi
callq 0x6200
movq %rax, %r14
testb %r15b, %r15b
je 0xc3ba
movq %r14, %rdi
movl $0x1, %esi
callq 0x1b10c
jmp 0xc3c4
movq %r14, %rdi
xorl %esi, %esi
callq 0x1b10c
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r15
testq %r15, %r15
je 0xc3ed
movq %r15, %rdi
callq 0x1a5cc
movl $0x8, %esi
movq %r15, %rdi
callq 0x6210
leaq 0x18(%rbx), %r15
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 0xc427
movq %r12, %rdi
callq 0x1a5cc
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 0xa3ae
leaq -0x30(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x17d9f(%rip), %rsi     # 0x24206
leaq 0x17d9b(%rip), %rdx     # 0x24209
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 0xc49c
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), %r12
movq %r12, -0x10(%r12)
leaq 0x17a7f(%rip), %rsi     # 0x23f45
leaq 0x17ab0(%rip), %rdx     # 0x23f7d
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x26599(%rip), %rsi     # 0x32a88
leaq 0xef40(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0xc898
callq 0x6250
callq 0x6250
callq 0x6250
callq 0x6250
callq 0x6250
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x17c4b(%rip), %rsi     # 0x24184
leaq 0x17c82(%rip), %rdx     # 0x241c2
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x26526(%rip), %rsi     # 0x32a88
leaq 0xeecd(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0xc898
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x17ae9(%rip), %rsi     # 0x2407c
leaq 0x17b20(%rip), %rdx     # 0x240ba
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x264cc(%rip), %rsi     # 0x32a88
leaq 0xee73(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0xc898
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x17a13(%rip), %rsi     # 0x24000
leaq 0x17a47(%rip), %rdx     # 0x2403b
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x26472(%rip), %rsi     # 0x32a88
leaq 0xee19(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0xc898
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x17ab7(%rip), %rsi     # 0x240fe
leaq 0x17af0(%rip), %rdx     # 0x2413e
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x26418(%rip), %rsi     # 0x32a88
leaq 0xedbf(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0xc898
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x178dd(%rip), %rsi     # 0x23f7e
leaq 0x17914(%rip), %rdx     # 0x23fbc
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x263be(%rip), %rsi     # 0x32a88
leaq 0xed65(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0xc898
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x17ac8(%rip), %rsi     # 0x241c3
leaq 0x17b03(%rip), %rdx     # 0x24205
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x26364(%rip), %rsi     # 0x32a88
leaq 0xed0b(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0xc898
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x17966(%rip), %rsi     # 0x240bb
leaq 0x179a1(%rip), %rdx     # 0x240fd
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x2630a(%rip), %rsi     # 0x32a88
leaq 0xecb1(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0xc898
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x1788d(%rip), %rsi     # 0x2403c
leaq 0x178c5(%rip), %rdx     # 0x2407b
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x262b0(%rip), %rsi     # 0x32a88
leaq 0xec57(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0xc898
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x17936(%rip), %rsi     # 0x2413f
leaq 0x17973(%rip), %rdx     # 0x24183
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x26256(%rip), %rsi     # 0x32a88
leaq 0xebfd(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0xc898
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x1775d(%rip), %rsi     # 0x23fbd
leaq 0x17798(%rip), %rdx     # 0x23fff
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x261ff(%rip), %rsi     # 0x32a88
leaq 0xeba6(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0xc8be
jmp 0xc8d8
jmp 0xc8f4
jmp 0xc90e
jmp 0xc92a
jmp 0xc944
jmp 0xc959
jmp 0xc973
jmp 0xc988
jmp 0xc9a2
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0xc8de
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0xc8de
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0xc9ba
movq %r14, %rdi
callq 0x6170
jmp 0xc9ba
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0xc914
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0xc914
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0xc9dc
movq %r14, %rdi
callq 0x6170
jmp 0xc9dc
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0xc94a
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0xc94a
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0xc9cb
movq %r14, %rdi
callq 0x6170
jmp 0xc9cb
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0xc979
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0xc979
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0xc9ea
movq %r14, %rdi
callq 0x6170
jmp 0xc9ea
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0xc9a8
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0xc9a8
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0xc9f8
movq %r14, %rdi
callq 0x6170
jmp 0xc9f8
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1acc4
jmp 0xca5e
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1aef6
jmp 0xca5e
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1b32c
jmp 0xca5e
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1b130
jmp 0xca5e
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1a3f4
jmp 0xca5e
jmp 0xca05
movq %rax, %rbx
movl $0x10, %esi
movq %r14, %rdi
jmp 0xca54
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0xca32
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0xca32
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0xca5e
movq %r14, %rdi
callq 0x6170
jmp 0xca5e
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r14, %rdi
je 0xca5e
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0xca5e
movq %rax, %rbx
movq %rbx, %rdi
callq 0x6410