// File: /workspace/github_cpp_makefile_star2_O2/zerolfx[P]P-Machine/equ.cpp
// Function: Equ::execute(StackMachine*)
void Equ::execute(StackMachine *stack) 
{
	// check if the stack contains at least two entries
	if(stack->fSP < 1)
		throw ExecutionError("instruction equ: 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 equ: SP does not point to element of type integer.");
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP - 1])))
				throw ExecutionError("instruction equ: 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 equ: SP does not point to element of type real.");
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP - 1])))
				throw ExecutionError("instruction equ: 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 equ: SP does not point to element of type boolean.");
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP - 1])))
				throw ExecutionError("instruction equ: 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 equ: SP does not point to element of type character.");
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP - 1])))
				throw ExecutionError("instruction equ: 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 equ: SP does not point to element of type address.");
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP - 1])))
				throw ExecutionError("instruction equ: SP - 1 does not point to element of type address.");
			break;
		}

	}
		
	// compare
	StackBoolean *result;
	if(*(stack->fStore[stack->fSP]) == *(stack->fStore[stack->fSP - 1]))
		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("equ");

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
cmpl $0x0, 0xb4(%rsi)
jle 0xa0ef
movq %rsi, %rbx
movl 0x8(%rdi), %eax
cmpq $0x4, %rax
ja 0x9fe8
leaq 0x14bb3(%rip), %rcx     # 0x1e918
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 0xa14a
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x24e28(%rip), %rdi     # 0x2ebc8
callq 0x76ba
testb %al, %al
jne 0xa238
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %rax
testq %rax, %rax
je 0xa14a
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x24df4(%rip), %rdi     # 0x2ebc8
callq 0x76ba
testb %al, %al
jne 0xa368
leaq -0x58(%rbp), %rdi
callq 0x17802
jmp 0x9fe8
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 0xa13b
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x24b40(%rip), %rdi     # 0x2e960
callq 0x76ba
testb %al, %al
jne 0xa154
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %rax
testq %rax, %rax
je 0xa13b
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x24b0c(%rip), %rdi     # 0x2e960
callq 0x76ba
testb %al, %al
jne 0xa2d0
leaq -0x58(%rbp), %rdi
callq 0x17070
jmp 0x9fe8
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 0xa140
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x24df8(%rip), %rdi     # 0x2ec98
callq 0x76ba
testb %al, %al
jne 0xa1a0
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %rax
testq %rax, %rax
je 0xa140
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x24dc4(%rip), %rdi     # 0x2ec98
callq 0x76ba
testb %al, %al
jne 0xa31c
leaq -0x58(%rbp), %rdi
callq 0x17a3c
jmp 0x9fe8
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 0xa145
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x24e47(%rip), %rdi     # 0x2ed68
callq 0x76ba
testb %al, %al
jne 0xa1ec
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %rax
testq %rax, %rax
je 0xa145
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x24e13(%rip), %rdi     # 0x2ed68
callq 0x76ba
testb %al, %al
jne 0xa3b4
leaq -0x58(%rbp), %rdi
callq 0x17c2c
jmp 0x9fe8
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 0xa14f
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x24b5a(%rip), %rdi     # 0x2eaf8
callq 0x76ba
testb %al, %al
jne 0xa284
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %rax
testq %rax, %rax
je 0xa14f
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x24b26(%rip), %rdi     # 0x2eaf8
callq 0x76ba
testb %al, %al
jne 0xa3fd
leaq -0x58(%rbp), %rdi
callq 0x175d0
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %rsi
movq (%rcx,%rax,8), %rdi
callq 0x174e7
movl %eax, %r15d
pushq $0x10
popq %rdi
callq 0x61d0
movq %rax, %r14
testb %r15b, %r15b
je 0xa021
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x17a18
jmp 0xa02b
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 0xa047
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 0xa07c
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 0x14b36(%rip), %rsi     # 0x1ebf2
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 0x14830(%rip), %rsi     # 0x1e931
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 0x23961(%rip), %rsi     # 0x2da88
leaq 0xdbec(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xa444
callq 0x6220
callq 0x6220
callq 0x6220
callq 0x6220
callq 0x6220
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x14a0a(%rip), %rsi     # 0x1eb70
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 0x238fc(%rip), %rsi     # 0x2da88
leaq 0xdb87(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xa444
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x148b6(%rip), %rsi     # 0x1ea68
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 0x238b0(%rip), %rsi     # 0x2da88
leaq 0xdb3b(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xa444
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x148ec(%rip), %rsi     # 0x1eaea
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 0x23864(%rip), %rsi     # 0x2da88
leaq 0xdaef(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xa444
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x147a2(%rip), %rsi     # 0x1e9ec
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 0x23818(%rip), %rsi     # 0x2da88
leaq 0xdaa3(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xa444
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x146d4(%rip), %rsi     # 0x1e96a
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 0x237cc(%rip), %rsi     # 0x2da88
leaq 0xda57(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xa444
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x148cd(%rip), %rsi     # 0x1ebaf
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 0x23780(%rip), %rsi     # 0x2da88
leaq 0xda0b(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xa444
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x14779(%rip), %rsi     # 0x1eaa7
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 0x23734(%rip), %rsi     # 0x2da88
leaq 0xd9bf(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xa444
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x146ae(%rip), %rsi     # 0x1ea28
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 0x236e8(%rip), %rsi     # 0x2da88
leaq 0xd973(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xa444
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x14765(%rip), %rsi     # 0x1eb2b
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 0x2369c(%rip), %rsi     # 0x2da88
leaq 0xd927(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xa444
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x1459a(%rip), %rsi     # 0x1e9a9
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 0x23653(%rip), %rsi     # 0x2da88
leaq 0xd8de(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xa461
jmp 0xa48d
jmp 0xa4a7
jmp 0xa4ba
jmp 0xa477
jmp 0xa49a
jmp 0xa4c7
jmp 0xa4da
jmp 0xa4e7
jmp 0xa4fa
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0xa490
jmp 0xa50a
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0xa49d
jmp 0xa518
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0xa50a
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0xa518
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0xa4bd
jmp 0xa526
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0xa526
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0xa4dd
jmp 0xa534
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0xa534
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0xa4fd
jmp 0xa542
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0xa542
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x175d0
jmp 0xa590
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x17802
jmp 0xa590
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x17c2c
jmp 0xa590
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x17a3c
jmp 0xa590
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x17070
jmp 0xa590
jmp 0xa54f
movq %rax, %rbx
pushq $0x10
popq %rsi
movq %r14, %rdi
callq 0x61e0
jmp 0xa590
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0xa575
jmp 0xa590
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0xa590
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x60d0
jmp 0xa590
movq %rax, %rbx
movq %rbx, %rdi
callq 0x63f0