// File: /workspace/github_cpp_makefile_star2_O1/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 $0x30, %rsp
cmpl $0x0, 0xb4(%rsi)
jle 0x106d5
movq %rsi, %rbx
movl 0x8(%rdi), %eax
cmpq $0x4, %rax
ja 0x105a9
leaq 0x1498d(%rip), %rcx     # 0x24c18
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 0x1073e
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x23902(%rip), %rcx     # 0x33bc8
movq 0x8(%rcx), %r14
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0x102ed
cmpb $0x2a, (%r14)
je 0x107fc
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0x107fc
movq -0x8(%r12,%r15,8), %rax
testq %rax, %rax
je 0x1073e
movq (%rax), %rax
movq -0x8(%rax), %rax
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0x10325
cmpb $0x2a, (%r14)
je 0x109be
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0x109be
leaq -0x50(%rbp), %rdi
callq 0x1aef6
jmp 0x105a9
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 0x1072f
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x235fc(%rip), %rcx     # 0x33960
movq 0x8(%rcx), %r14
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0x1038b
cmpb $0x2a, (%r14)
je 0x10748
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0x10748
movq -0x8(%r12,%r15,8), %rax
testq %rax, %rax
je 0x1072f
movq (%rax), %rax
movq -0x8(%rax), %rax
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0x103c3
cmpb $0x2a, (%r14)
je 0x1090a
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0x1090a
leaq -0x50(%rbp), %rdi
callq 0x1a3f4
jmp 0x105a9
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 0x10734
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x23896(%rip), %rcx     # 0x33c98
movq 0x8(%rcx), %r14
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0x10429
cmpb $0x2a, (%r14)
je 0x107a2
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0x107a2
movq -0x8(%r12,%r15,8), %rax
testq %rax, %rax
je 0x10734
movq (%rax), %rax
movq -0x8(%rax), %rax
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0x10461
cmpb $0x2a, (%r14)
je 0x10964
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0x10964
leaq -0x50(%rbp), %rdi
callq 0x1b130
jmp 0x105a9
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 0x10739
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x238c5(%rip), %rcx     # 0x33d68
movq 0x8(%rcx), %r14
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0x104ca
cmpb $0x2a, (%r14)
je 0x10856
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0x10856
movq -0x8(%r12,%r15,8), %rax
testq %rax, %rax
je 0x10739
movq (%rax), %rax
movq -0x8(%rax), %rax
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0x10502
cmpb $0x2a, (%r14)
je 0x10a18
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0x10a18
leaq -0x50(%rbp), %rdi
callq 0x1b32c
jmp 0x105a9
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 0x10743
movq (%rax), %rax
movq -0x8(%rax), %rax
leaq 0x235b7(%rip), %rcx     # 0x33af8
movq 0x8(%rcx), %r14
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0x10568
cmpb $0x2a, (%r14)
je 0x108b0
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0x108b0
movq -0x8(%r12,%r15,8), %rax
testq %rax, %rax
je 0x10743
movq (%rax), %rax
movq -0x8(%rax), %rax
movq 0x8(%rax), %rsi
cmpq %rsi, %r14
je 0x105a0
cmpb $0x2a, (%r14)
je 0x10a6f
movq %r14, %rdi
callq 0x6310
testl %eax, %eax
jne 0x10a6f
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 0x1ac53
movl %eax, %r15d
movl $0x10, %edi
callq 0x6200
movq %rax, %r14
testb %r15b, %r15b
je 0x105e6
movq %r14, %rdi
movl $0x1, %esi
callq 0x1b10c
jmp 0x105f0
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 0x10619
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 0x10653
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 0x1485f(%rip), %rsi     # 0x24ef2
leaq 0x1485b(%rip), %rdx     # 0x24ef5
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 0x106c8
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 0x1453f(%rip), %rsi     # 0x24c31
leaq 0x14570(%rip), %rdx     # 0x24c69
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x2236d(%rip), %rsi     # 0x32a88
leaq 0xad14(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0x10ac4
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 0x1470b(%rip), %rsi     # 0x24e70
leaq 0x14742(%rip), %rdx     # 0x24eae
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x222fa(%rip), %rsi     # 0x32a88
leaq 0xaca1(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0x10ac4
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x145a9(%rip), %rsi     # 0x24d68
leaq 0x145e0(%rip), %rdx     # 0x24da6
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x222a0(%rip), %rsi     # 0x32a88
leaq 0xac47(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0x10ac4
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x144d3(%rip), %rsi     # 0x24cec
leaq 0x14507(%rip), %rdx     # 0x24d27
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x22246(%rip), %rsi     # 0x32a88
leaq 0xabed(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0x10ac4
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x14577(%rip), %rsi     # 0x24dea
leaq 0x145b0(%rip), %rdx     # 0x24e2a
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x221ec(%rip), %rsi     # 0x32a88
leaq 0xab93(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0x10ac4
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x1439d(%rip), %rsi     # 0x24c6a
leaq 0x143d4(%rip), %rdx     # 0x24ca8
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x22192(%rip), %rsi     # 0x32a88
leaq 0xab39(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0x10ac4
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x14588(%rip), %rsi     # 0x24eaf
leaq 0x145c3(%rip), %rdx     # 0x24ef1
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x22138(%rip), %rsi     # 0x32a88
leaq 0xaadf(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0x10ac4
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x14426(%rip), %rsi     # 0x24da7
leaq 0x14461(%rip), %rdx     # 0x24de9
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x220de(%rip), %rsi     # 0x32a88
leaq 0xaa85(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0x10ac4
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x1434d(%rip), %rsi     # 0x24d28
leaq 0x14385(%rip), %rdx     # 0x24d67
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x22084(%rip), %rsi     # 0x32a88
leaq 0xaa2b(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0x10ac4
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x143f6(%rip), %rsi     # 0x24e2b
leaq 0x14433(%rip), %rdx     # 0x24e6f
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x2202a(%rip), %rsi     # 0x32a88
leaq 0xa9d1(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0x10ac4
movl $0x20, %edi
callq 0x6100
movq %rax, %r14
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x1421d(%rip), %rsi     # 0x24ca9
leaq 0x14258(%rip), %rdx     # 0x24ceb
leaq -0x40(%rbp), %rdi
callq 0x746c
movb $0x1, %r15b
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x1b418
xorl %r15d, %r15d
leaq 0x21fd3(%rip), %rsi     # 0x32a88
leaq 0xa97a(%rip), %rdx      # 0x1b436
movq %r14, %rdi
callq 0x63e0
jmp 0x10aea
jmp 0x10b04
jmp 0x10b20
jmp 0x10b3a
jmp 0x10b56
jmp 0x10b70
jmp 0x10b85
jmp 0x10b9f
jmp 0x10bb4
jmp 0x10bce
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x10b0a
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x10b0a
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0x10be6
movq %r14, %rdi
callq 0x6170
jmp 0x10be6
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x10b40
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x10b40
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0x10c08
movq %r14, %rdi
callq 0x6170
jmp 0x10c08
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x10b76
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x10b76
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0x10bf7
movq %r14, %rdi
callq 0x6170
jmp 0x10bf7
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x10ba5
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x10ba5
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0x10c16
movq %r14, %rdi
callq 0x6170
jmp 0x10c16
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x10bd4
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x10bd4
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0x10c24
movq %r14, %rdi
callq 0x6170
jmp 0x10c24
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1acc4
jmp 0x10c8a
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1aef6
jmp 0x10c8a
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1b32c
jmp 0x10c8a
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1b130
jmp 0x10c8a
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x1a3f4
jmp 0x10c8a
jmp 0x10c31
movq %rax, %rbx
movl $0x10, %esi
movq %r14, %rdi
jmp 0x10c80
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x10c5e
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x10c5e
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0x10c8a
movq %r14, %rdi
callq 0x6170
jmp 0x10c8a
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r14, %rdi
je 0x10c8a
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x6210
jmp 0x10c8a
movq %rax, %rbx
movq %rbx, %rdi
callq 0x6410