// File: zerolfx[P]P-Machine/neg.cpp
// Function: Neg::execute(StackMachine*)
void Neg::execute(StackMachine *stack) 
{
	// check if the stack contains at least one entry
	if(stack->fSP < 0)
		throw ExecutionError("instruction neg: requires 1 stackelement to be present.");
		
	switch(fType)
	{
		case integer:
		{
			StackInteger p1;

			// check if the uppermost stackentry is of type integer
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP])))
				throw ExecutionError("instruction add: SP does not point to element of type integer.");

			break;
		}	
		case real:
		{
			StackReal p1;
			// check if the uppermost stackentry is of type real
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP])))
				throw ExecutionError("instruction add: SP does not point to element of type real.");
				
			break;
		}
	}
	
	// actual operation
	stack->fStore[stack->fSP]->neg();
	
	// adding cost of this instruction
	stack->fTime.count("neg");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0xb4(%rax)
jge 0x1c927
movb $0x1, -0x45(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0xf8(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x74f0
movq -0xf0(%rbp), %rdx
leaq 0x1c90b(%rip), %rsi     # 0x391ad
leaq -0x30(%rbp), %rdi
callq 0x8940
jmp 0x1c8ad
movq -0xf8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x283d0
jmp 0x1c8bf
movq -0xf8(%rbp), %rdi
movb $0x0, -0x45(%rbp)
leaq 0x2d1af(%rip), %rsi     # 0x49a80
leaq 0xbb28(%rip), %rdx      # 0x28400
callq 0x74a0
jmp 0x1ccbb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1c905
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 0x1c916
jmp 0x1c922
movq -0xf8(%rbp), %rdi
callq 0x71c0
jmp 0x1ccb2
movq -0xe8(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0xfc(%rbp)
testl %eax, %eax
je 0x1ca8e
jmp 0x1c941
movl -0xfc(%rbp), %eax
subl $0x1, %eax
jne 0x1cbe9
jmp 0x1c952
leaq -0x58(%rbp), %rdi
xorl %esi, %esi
callq 0x27340
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0x108(%rbp)
cmpq $0x0, %rax
jne 0x1c98c
callq 0x7300
jmp 0x1c98c
movq -0x108(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x2e14f(%rip), %rdi     # 0x4aaf0
callq 0x9370
testb $0x1, %al
jne 0x1c9af
jmp 0x1ca72
movb $0x1, -0x7a(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x118(%rbp)
leaq -0x79(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x74f0
movq -0x110(%rbp), %rdx
leaq 0x1a810(%rip), %rsi     # 0x371f2
leaq -0x78(%rbp), %rdi
callq 0x8940
jmp 0x1c9ed
movq -0x118(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x283d0
jmp 0x1c9ff
movq -0x118(%rbp), %rdi
movb $0x0, -0x7a(%rbp)
leaq 0x2d06f(%rip), %rsi     # 0x49a80
leaq 0xb9e8(%rip), %rdx      # 0x28400
callq 0x74a0
jmp 0x1ccbb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1ca80
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1ca53
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 0x1ca64
jmp 0x1ca70
movq -0x118(%rbp), %rdi
callq 0x71c0
jmp 0x1ca80
leaq -0x58(%rbp), %rdi
callq 0x27380
jmp 0x1cbe9
leaq -0x58(%rbp), %rdi
callq 0x27380
jmp 0x1ccb2
leaq -0x90(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x27840
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
jne 0x1cacc
callq 0x7300
jmp 0x1cacc
movq -0x120(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x2e0df(%rip), %rdi     # 0x4abc0
callq 0x9370
testb $0x1, %al
jne 0x1caef
jmp 0x1cbca
movb $0x1, -0xb2(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x130(%rbp)
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0x74f0
movq -0x128(%rbp), %rdx
leaq 0x1a74c(%rip), %rsi     # 0x37274
leaq -0xb0(%rbp), %rdi
callq 0x8940
jmp 0x1cb36
movq -0x130(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x283d0
jmp 0x1cb4b
movq -0x130(%rbp), %rdi
movb $0x0, -0xb2(%rbp)
leaq 0x2cf20(%rip), %rsi     # 0x49a80
leaq 0xb899(%rip), %rdx      # 0x28400
callq 0x74a0
jmp 0x1ccbb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1cbd8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1cba5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x7170
leaq -0xb1(%rbp), %rdi
callq 0x72e0
testb $0x1, -0xb2(%rbp)
jne 0x1cbbc
jmp 0x1cbc8
movq -0x130(%rbp), %rdi
callq 0x71c0
jmp 0x1cbd8
leaq -0x90(%rbp), %rdi
callq 0x27880
jmp 0x1cbe9
leaq -0x90(%rbp), %rdi
callq 0x27880
jmp 0x1ccb2
movq -0x10(%rbp), %rax
movq %rax, %rdi
addq $0x18, %rdi
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rdi
movq (%rdi), %rax
movq 0x28(%rax), %rax
callq *%rax
movq -0x10(%rbp), %rax
addq $0x78, %rax
movq %rax, -0x140(%rbp)
leaq -0xd9(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x74f0
movq -0x138(%rbp), %rdx
leaq 0x1c5a9(%rip), %rsi     # 0x391e5
leaq -0xd8(%rbp), %rdi
callq 0x8940
jmp 0x1cc4a
movq -0x140(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x2c4d0
jmp 0x1cc5f
leaq -0xd8(%rbp), %rdi
callq 0x7170
leaq -0xd9(%rbp), %rdi
callq 0x72e0
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1cca6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x7170
leaq -0xd9(%rbp), %rdi
callq 0x72e0
movq -0x40(%rbp), %rdi
callq 0x74e0
nopl (%rax,%rax)