// File: zerolfx[P]P-Machine/or.cpp
// Function: Or::execute(StackMachine*)
void Or::execute(StackMachine *stack) 
{
	// check if the stack contains at least two entries
	if(stack->fSP < 1)
		throw ExecutionError("instruction or: requires 2 stackelements to be present.");
		
	StackBoolean p1;
	
	if(typeid(p1) != typeid(*(stack->fStore[stack->fSP])))
		throw ExecutionError("instruction or: SP does not point to element of type boolean.");
	if(typeid(p1) != typeid(*(stack->fStore[stack->fSP - 1])))
		throw ExecutionError("instruction or: SP - 1 does not point to element of type boolean.");

	
	// actual or-operation
	stack->fStore[stack->fSP - 1]->ori(stack->fStore[stack->fSP]);
	
	// SP := SP - 1
	delete stack->fStore[stack->fSP];
	stack->fStore[stack->fSP] = 0;
	stack->fStore.pop_back();
	--stack->fSP;
	
	// adding cost of this instruction
	stack->fTime.count("or");

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x1, 0xb4(%rax)
jge 0x1eddc
movb $0x1, -0x45(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0xe0(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x74f0
movq -0xd8(%rbp), %rdx
leaq 0x1a916(%rip), %rsi     # 0x3966d
leaq -0x30(%rbp), %rdi
callq 0x8940
jmp 0x1ed62
movq -0xe0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x283d0
jmp 0x1ed74
movq -0xe0(%rbp), %rdi
movb $0x0, -0x45(%rbp)
leaq 0x2acfa(%rip), %rsi     # 0x49a80
leaq 0x9673(%rip), %rdx      # 0x28400
callq 0x74a0
jmp 0x1f1bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1edba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x7170
leaq -0x31(%rbp), %rdi
callq 0x72e0
testb $0x1, -0x45(%rbp)
jne 0x1edcb
jmp 0x1edd7
movq -0xe0(%rbp), %rdi
callq 0x71c0
jmp 0x1f1b4
leaq -0x58(%rbp), %rdi
xorl %esi, %esi
callq 0x27d20
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0xe8(%rbp)
cmpq $0x0, %rax
jne 0x1ee16
callq 0x7300
jmp 0x1ee16
movq -0xe8(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x2be65(%rip), %rdi     # 0x4ac90
callq 0x9370
testb $0x1, %al
jne 0x1ee39
jmp 0x1ef02
movb $0x1, -0x7a(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0xf8(%rbp)
leaq -0x79(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x74f0
movq -0xf0(%rbp), %rdx
leaq 0x1a839(%rip), %rsi     # 0x396a5
leaq -0x78(%rbp), %rdi
callq 0x8940
jmp 0x1ee77
movq -0xf8(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x283d0
jmp 0x1ee89
movq -0xf8(%rbp), %rdi
movb $0x0, -0x7a(%rbp)
leaq 0x2abe5(%rip), %rsi     # 0x49a80
leaq 0x955e(%rip), %rdx      # 0x28400
callq 0x74a0
jmp 0x1f1bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1f1ab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1eee0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x7170
leaq -0x79(%rbp), %rdi
callq 0x72e0
testb $0x1, -0x7a(%rbp)
jne 0x1eef1
jmp 0x1eefd
movq -0xf8(%rbp), %rdi
callq 0x71c0
jmp 0x1f1ab
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movl 0xb4(%rax), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0x100(%rbp)
cmpq $0x0, %rax
jne 0x1ef36
callq 0x7300
jmp 0x1ef36
movq -0x100(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x2bd45(%rip), %rdi     # 0x4ac90
callq 0x9370
testb $0x1, %al
jne 0x1ef59
jmp 0x1f029
movb $0x1, -0xa2(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x110(%rbp)
leaq -0xa1(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x74f0
movq -0x108(%rbp), %rdx
leaq 0x1a751(%rip), %rsi     # 0x396e3
leaq -0xa0(%rbp), %rdi
callq 0x8940
jmp 0x1efa0
movq -0x110(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x283d0
jmp 0x1efb5
movq -0x110(%rbp), %rdi
movb $0x0, -0xa2(%rbp)
leaq 0x2aab6(%rip), %rsi     # 0x49a80
leaq 0x942f(%rip), %rdx      # 0x28400
callq 0x74a0
jmp 0x1f1bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1f001
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x7170
leaq -0xa1(%rbp), %rdi
callq 0x72e0
testb $0x1, -0xa2(%rbp)
jne 0x1f018
jmp 0x1f024
movq -0x110(%rbp), %rdi
callq 0x71c0
jmp 0x1f1ab
movq -0x10(%rbp), %rax
movq %rax, %rdi
addq $0x18, %rdi
movl 0xb4(%rax), %eax
decl %eax
movslq %eax, %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0x118(%rbp)
movq -0x10(%rbp), %rax
movq %rax, %rdi
addq $0x18, %rdi
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq -0x118(%rbp), %rdi
movq (%rax), %rsi
movq (%rdi), %rax
movq 0x38(%rax), %rax
callq *%rax
jmp 0x1f07a
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0x120(%rbp)
cmpq $0x0, %rax
je 0x1f0bf
movq -0x120(%rbp), %rdi
callq 0x26ca0
movq -0x120(%rbp), %rdi
movl $0x8, %esi
callq 0x7280
movq -0x10(%rbp), %rax
movq %rax, %rdi
addq $0x18, %rdi
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq $0x0, (%rax)
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
callq 0x8e90
movq -0x10(%rbp), %rax
movl 0xb4(%rax), %ecx
decl %ecx
movl %ecx, 0xb4(%rax)
movq -0x10(%rbp), %rax
addq $0x78, %rax
movq %rax, -0x130(%rbp)
leaq -0xc9(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0x74f0
movq -0x128(%rbp), %rdx
leaq 0x1b924(%rip), %rsi     # 0x3aa50
leaq -0xc8(%rbp), %rdi
callq 0x8940
jmp 0x1f13a
movq -0x130(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x2c4d0
jmp 0x1f14f
leaq -0xc8(%rbp), %rdi
callq 0x7170
leaq -0xc9(%rbp), %rdi
callq 0x72e0
leaq -0x58(%rbp), %rdi
callq 0x27d70
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1f19f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x7170
leaq -0xc9(%rbp), %rdi
callq 0x72e0
leaq -0x58(%rbp), %rdi
callq 0x27d70
movq -0x40(%rbp), %rdi
callq 0x74e0
nopl (%rax)