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

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
cmpl $0x0, 0xb4(%rsi)
jle 0xec77
movq %rsi, %rbx
movl 0x8(%rdi), %eax
cmpq $0x4, %rax
ja 0xeb70
leaq 0x1132b(%rip), %rcx     # 0x1fc18
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 0xecd2
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x202a0(%rip), %rdi     # 0x2ebc8
callq 0x76ba
testb %al, %al
jne 0xedc0
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %rax
testq %rax, %rax
je 0xecd2
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x2026c(%rip), %rdi     # 0x2ebc8
callq 0x76ba
testb %al, %al
jne 0xeef0
leaq -0x58(%rbp), %rdi
callq 0x17802
jmp 0xeb70
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 0xecc3
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x1ffb8(%rip), %rdi     # 0x2e960
callq 0x76ba
testb %al, %al
jne 0xecdc
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %rax
testq %rax, %rax
je 0xecc3
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x1ff84(%rip), %rdi     # 0x2e960
callq 0x76ba
testb %al, %al
jne 0xee58
leaq -0x58(%rbp), %rdi
callq 0x17070
jmp 0xeb70
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 0xecc8
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x20270(%rip), %rdi     # 0x2ec98
callq 0x76ba
testb %al, %al
jne 0xed28
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %rax
testq %rax, %rax
je 0xecc8
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x2023c(%rip), %rdi     # 0x2ec98
callq 0x76ba
testb %al, %al
jne 0xeea4
leaq -0x58(%rbp), %rdi
callq 0x17a3c
jmp 0xeb70
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 0xeccd
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x202bf(%rip), %rdi     # 0x2ed68
callq 0x76ba
testb %al, %al
jne 0xed74
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %rax
testq %rax, %rax
je 0xeccd
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x2028b(%rip), %rdi     # 0x2ed68
callq 0x76ba
testb %al, %al
jne 0xef3c
leaq -0x58(%rbp), %rdi
callq 0x17c2c
jmp 0xeb70
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 0xecd7
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x1ffd2(%rip), %rdi     # 0x2eaf8
callq 0x76ba
testb %al, %al
jne 0xee0c
movslq 0xb4(%rbx), %rax
movq 0x18(%rbx), %rcx
movq -0x8(%rcx,%rax,8), %rax
testq %rax, %rax
je 0xecd7
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x1ff9e(%rip), %rdi     # 0x2eaf8
callq 0x76ba
testb %al, %al
jne 0xef85
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 0x17565
movl %eax, %r15d
pushq $0x10
popq %rdi
callq 0x61d0
movq %rax, %r14
testb %r15b, %r15b
je 0xeba9
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x17a18
jmp 0xebb3
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 0xebcf
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 0xec04
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 0x112ae(%rip), %rsi     # 0x1fef2
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 0x10fa8(%rip), %rsi     # 0x1fc31
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 0x1edd9(%rip), %rsi     # 0x2da88
leaq 0x9064(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xefcc
callq 0x6220
callq 0x6220
callq 0x6220
callq 0x6220
callq 0x6220
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x11182(%rip), %rsi     # 0x1fe70
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 0x1ed74(%rip), %rsi     # 0x2da88
leaq 0x8fff(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xefcc
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x1102e(%rip), %rsi     # 0x1fd68
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 0x1ed28(%rip), %rsi     # 0x2da88
leaq 0x8fb3(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xefcc
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x11064(%rip), %rsi     # 0x1fdea
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 0x1ecdc(%rip), %rsi     # 0x2da88
leaq 0x8f67(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xefcc
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x10f1a(%rip), %rsi     # 0x1fcec
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 0x1ec90(%rip), %rsi     # 0x2da88
leaq 0x8f1b(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xefcc
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x10e4c(%rip), %rsi     # 0x1fc6a
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 0x1ec44(%rip), %rsi     # 0x2da88
leaq 0x8ecf(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xefcc
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x11045(%rip), %rsi     # 0x1feaf
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 0x1ebf8(%rip), %rsi     # 0x2da88
leaq 0x8e83(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xefcc
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x10ef1(%rip), %rsi     # 0x1fda7
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 0x1ebac(%rip), %rsi     # 0x2da88
leaq 0x8e37(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xefcc
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x10e26(%rip), %rsi     # 0x1fd28
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 0x1eb60(%rip), %rsi     # 0x2da88
leaq 0x8deb(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xefcc
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x10edd(%rip), %rsi     # 0x1fe2b
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 0x1eb14(%rip), %rsi     # 0x2da88
leaq 0x8d9f(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xefcc
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %r14
leaq 0x10d12(%rip), %rsi     # 0x1fca9
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 0x1eacb(%rip), %rsi     # 0x2da88
leaq 0x8d56(%rip), %rdx      # 0x17d1a
movq %r14, %rdi
callq 0x63c0
jmp 0xefe9
jmp 0xf015
jmp 0xf02f
jmp 0xf042
jmp 0xefff
jmp 0xf022
jmp 0xf04f
jmp 0xf062
jmp 0xf06f
jmp 0xf082
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0xf018
jmp 0xf092
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0xf025
jmp 0xf0a0
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0xf092
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0xf0a0
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0xf045
jmp 0xf0ae
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0xf0ae
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0xf065
jmp 0xf0bc
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0xf0bc
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0xf085
jmp 0xf0ca
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0xf0ca
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x175d0
jmp 0xf118
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x17802
jmp 0xf118
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x17c2c
jmp 0xf118
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x17a3c
jmp 0xf118
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x17070
jmp 0xf118
jmp 0xf0d7
movq %rax, %rbx
pushq $0x10
popq %rsi
movq %r14, %rdi
callq 0x61e0
jmp 0xf118
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0xf0fd
jmp 0xf118
movq %rax, %rbx
movq %r14, %rdi
callq 0x6150
jmp 0xf118
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x60d0
jmp 0xf118
movq %rax, %rbx
movq %rbx, %rdi
callq 0x63f0