// File: /workspace/github_cpp_makefile_star2_O2/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 $0x40, %rsp
cmpl $0x0, 0xb4(%rsi)
jle 0xb573
movq %rsi, %rbx
movl 0x8(%rdi), %eax
cmpq $0x4, %rax
ja 0xb46c
leaq 0x13d43(%rip), %rcx     # 0x1ef2c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x58(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x177d4
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0xb5ce
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x239a4(%rip), %rdi     # 0x2ebc8
callq 0x76ba
testb %al, %al
jne 0xb6bc
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %rax
testq %rax, %rax
je 0xb5ce
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x23970(%rip), %rdi     # 0x2ebc8
callq 0x76ba
testb %al, %al
jne 0xb7ec
leaq -0x58(%rbp), %rdi
callq 0x17802
jmp 0xb46c
leaq -0x58(%rbp), %rdi
xorl %esi, %esi
callq 0x1704c
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0xb5bf
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x236bc(%rip), %rdi     # 0x2e960
callq 0x76ba
testb %al, %al
jne 0xb5d8
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %rax
testq %rax, %rax
je 0xb5bf
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x23688(%rip), %rdi     # 0x2e960
callq 0x76ba
testb %al, %al
jne 0xb754
leaq -0x58(%rbp), %rdi
callq 0x17070
jmp 0xb46c
leaq -0x58(%rbp), %rdi
xorl %esi, %esi
callq 0x17a18
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0xb5c4
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x23974(%rip), %rdi     # 0x2ec98
callq 0x76ba
testb %al, %al
jne 0xb624
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %rax
testq %rax, %rax
je 0xb5c4
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x23940(%rip), %rdi     # 0x2ec98
callq 0x76ba
testb %al, %al
jne 0xb7a0
leaq -0x58(%rbp), %rdi
callq 0x17a3c
jmp 0xb46c
leaq -0x58(%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 0xb5c9
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x239c3(%rip), %rdi     # 0x2ed68
callq 0x76ba
testb %al, %al
jne 0xb670
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %rax
testq %rax, %rax
je 0xb5c9
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x2398f(%rip), %rdi     # 0x2ed68
callq 0x76ba
testb %al, %al
jne 0xb838
leaq -0x58(%rbp), %rdi
callq 0x17c2c
jmp 0xb46c
leaq -0x58(%rbp), %rdi
xorl %esi, %esi
callq 0x175ac
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %rax
testq %rax, %rax
je 0xb5d3
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x236d6(%rip), %rdi     # 0x2eaf8
callq 0x76ba
testb %al, %al
jne 0xb708
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %rax
testq %rax, %rax
je 0xb5d3
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x236a2(%rip), %rdi     # 0x2eaf8
callq 0x76ba
testb %al, %al
jne 0xb881
leaq -0x58(%rbp), %rdi
callq 0x175d0
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %rdi
movq (%rcx,%rax,8), %rsi
callq 0x17573
movl %eax, %r15d
pushq $0x10
popq %rdi
callq 0x61d0
movq %rax, %r14
testb %r15b, %r15b
je 0xb4a5
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x17a18
jmp 0xb4af
movq %r14, %rdi
xorl %esi, %esi
callq 0x17a18
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq (%rcx,%rax,8), %r12
testq %r12, %r12
je 0xb4cb
movq %r12, %rdi
callq 0x17248
leaq 0x18(%rbx), %r15
pushq $0x8
popq %rsi
movq %r12, %rdi
callq 0x61e0
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
andq $0x0, (%rcx,%rax,8)
movq 0x18(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %r12
testq %r12, %r12
je 0xb500
movq %r12, %rdi
callq 0x17248
pushq $0x8
popq %rsi
movq %r12, %rdi
callq 0x61e0
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
andq $0x0, -0x8(%rcx,%rax,8)
addq $-0x10, 0x20(%rbx)
decq %rax
movl %eax, 0xb4(%rbx)
leaq -0x48(%rbp), %rsi
movq %r14, (%rsi)
movq %r15, %rdi
callq 0x99a0
leaq 0x13cc6(%rip), %rsi     # 0x1f206
leaq -0x48(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0x72a6
addq $0x78, %rbx
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x1925e
leaq -0x48(%rbp), %rdi
callq 0x60d0
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x139c0(%rip), %rsi     # 0x1ef45
leaq -0x48(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x224dd(%rip), %rsi     # 0x2da88
leaq 0xc768(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xb8c8
callq 0x6220
callq 0x6220
callq 0x6220
callq 0x6220
callq 0x6220
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x13b9a(%rip), %rsi     # 0x1f184
leaq -0x48(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x22478(%rip), %rsi     # 0x2da88
leaq 0xc703(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xb8c8
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x13a46(%rip), %rsi     # 0x1f07c
leaq -0x48(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x2242c(%rip), %rsi     # 0x2da88
leaq 0xc6b7(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xb8c8
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x13a7c(%rip), %rsi     # 0x1f0fe
leaq -0x48(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x223e0(%rip), %rsi     # 0x2da88
leaq 0xc66b(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xb8c8
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x13932(%rip), %rsi     # 0x1f000
leaq -0x48(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x22394(%rip), %rsi     # 0x2da88
leaq 0xc61f(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xb8c8
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x13864(%rip), %rsi     # 0x1ef7e
leaq -0x48(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x22348(%rip), %rsi     # 0x2da88
leaq 0xc5d3(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xb8c8
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x13a5d(%rip), %rsi     # 0x1f1c3
leaq -0x48(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x222fc(%rip), %rsi     # 0x2da88
leaq 0xc587(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xb8c8
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x13909(%rip), %rsi     # 0x1f0bb
leaq -0x48(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x222b0(%rip), %rsi     # 0x2da88
leaq 0xc53b(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xb8c8
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x1383e(%rip), %rsi     # 0x1f03c
leaq -0x48(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x22264(%rip), %rsi     # 0x2da88
leaq 0xc4ef(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xb8c8
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x138f5(%rip), %rsi     # 0x1f13f
leaq -0x48(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x22218(%rip), %rsi     # 0x2da88
leaq 0xc4a3(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xb8c8
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x1372a(%rip), %rsi     # 0x1efbd
leaq -0x48(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x221cf(%rip), %rsi     # 0x2da88
leaq 0xc45a(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xb8e5
jmp 0xb911
jmp 0xb92b
jmp 0xb93e
jmp 0xb8fb
jmp 0xb91e
jmp 0xb94b
jmp 0xb95e
jmp 0xb96b
jmp 0xb97e
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0xb914
jmp 0xb98e
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0xb921
jmp 0xb99c
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0xb98e
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0xb99c
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0xb941
jmp 0xb9aa
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0xb9aa
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0xb961
jmp 0xb9b8
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0xb9b8
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0xb981
jmp 0xb9c6
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0xb9c6
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x175d0
jmp 0xba14
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x17802
jmp 0xba14
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x17c2c
jmp 0xba14
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x17a3c
jmp 0xba14
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x17070
jmp 0xba14
jmp 0xb9d3
movq %rax, %rbx
pushq $0x10
popq %rsi
movq %r14, %rdi
callq 0x61e0
jmp 0xba14
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0xb9f9
jmp 0xba14
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0xba14
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x60d0
jmp 0xba14
movq %rax, %rbx
movq %rbx, %rdi
callq 0x63f0