// File: zerolfx[P]P-Machine/dec.cpp
// Function: Dec::execute(StackMachine*)
void Dec::execute(StackMachine *stack)
{
	// check if the stack contains at least one entry
	if(stack->fSP < 0)
		throw ExecutionError("instruction dec: 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 dec: 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 dec: SP does not point to element of type real.");

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

			break;
		}
		case character:
		{
			StackCharacter p1;
			// check if the  uppermost stackentriy is of type character
			if(typeid(p1) != typeid(*(stack->fStore[stack->fSP])))
				throw ExecutionError("instruction dec: SP does not point to element of type character.");

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

			break;
		}
	}
	
	// actual decrement
	stack->fStore[stack->fSP]->inc(fP);
	
	// adding cost of this instruction
	stack->fTime.count("dec");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x230, %rsp            # imm = 0x230
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x190(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0xb4(%rax)
jge 0xb3e7
movb $0x1, -0x45(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x1a0(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x198(%rbp)
callq 0x74f0
movq -0x198(%rbp), %rdx
leaq 0x2c17b(%rip), %rsi     # 0x374dd
leaq -0x30(%rbp), %rdi
callq 0x8940
jmp 0xb36d
movq -0x1a0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x283d0
jmp 0xb37f
movq -0x1a0(%rbp), %rdi
movb $0x0, -0x45(%rbp)
leaq 0x3e6ef(%rip), %rsi     # 0x49a80
leaq 0x1d068(%rip), %rdx     # 0x28400
callq 0x74a0
jmp 0xbbac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xb3c5
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 0xb3d6
jmp 0xb3e2
movq -0x1a0(%rbp), %rdi
callq 0x71c0
jmp 0xbba3
movq -0x190(%rbp), %rax
movl 0xc(%rax), %eax
movq %rax, -0x1a8(%rbp)
subq $0x4, %rax
ja 0xbaca
movq -0x1a8(%rbp), %rax
leaq 0x2c0b4(%rip), %rcx     # 0x374c4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
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, -0x1b0(%rbp)
cmpq $0x0, %rax
jne 0xb453
callq 0x7300
jmp 0xb453
movq -0x1b0(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x3f688(%rip), %rdi     # 0x4aaf0
callq 0x9370
testb $0x1, %al
jne 0xb476
jmp 0xb539
movb $0x1, -0x7a(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x1c0(%rbp)
leaq -0x79(%rbp), %rdi
movq %rdi, -0x1b8(%rbp)
callq 0x74f0
movq -0x1b8(%rbp), %rdx
leaq 0x2c06c(%rip), %rsi     # 0x37515
leaq -0x78(%rbp), %rdi
callq 0x8940
jmp 0xb4b4
movq -0x1c0(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x283d0
jmp 0xb4c6
movq -0x1c0(%rbp), %rdi
movb $0x0, -0x7a(%rbp)
leaq 0x3e5a8(%rip), %rsi     # 0x49a80
leaq 0x1cf21(%rip), %rdx     # 0x28400
callq 0x74a0
jmp 0xbbac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xb547
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xb51a
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 0xb52b
jmp 0xb537
movq -0x1c0(%rbp), %rdi
callq 0x71c0
jmp 0xb547
leaq -0x58(%rbp), %rdi
callq 0x27380
jmp 0xbaca
leaq -0x58(%rbp), %rdi
callq 0x27380
jmp 0xbba3
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, -0x1c8(%rbp)
cmpq $0x0, %rax
jne 0xb593
callq 0x7300
jmp 0xb593
movq -0x1c8(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x3f618(%rip), %rdi     # 0x4abc0
callq 0x9370
testb $0x1, %al
jne 0xb5b6
jmp 0xb691
movb $0x1, -0xb2(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x1d8(%rbp)
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x74f0
movq -0x1d0(%rbp), %rdx
leaq 0x2bf65(%rip), %rsi     # 0x37554
leaq -0xb0(%rbp), %rdi
callq 0x8940
jmp 0xb5fd
movq -0x1d8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x283d0
jmp 0xb612
movq -0x1d8(%rbp), %rdi
movb $0x0, -0xb2(%rbp)
leaq 0x3e459(%rip), %rsi     # 0x49a80
leaq 0x1cdd2(%rip), %rdx     # 0x28400
callq 0x74a0
jmp 0xbbac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xb6a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xb66c
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 0xb683
jmp 0xb68f
movq -0x1d8(%rbp), %rdi
callq 0x71c0
jmp 0xb6a2
leaq -0x90(%rbp), %rdi
callq 0x27880
jmp 0xbaca
leaq -0x90(%rbp), %rdi
callq 0x27880
jmp 0xbba3
leaq -0xc8(%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, -0x1e0(%rbp)
cmpq $0x0, %rax
jne 0xb6f0
callq 0x7300
jmp 0xb6f0
movq -0x1e0(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x3f58b(%rip), %rdi     # 0x4ac90
callq 0x9370
testb $0x1, %al
jne 0xb713
jmp 0xb7ee
movb $0x1, -0xea(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x1f0(%rbp)
leaq -0xe9(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
callq 0x74f0
movq -0x1e8(%rbp), %rdx
leaq 0x2be44(%rip), %rsi     # 0x37590
leaq -0xe8(%rbp), %rdi
callq 0x8940
jmp 0xb75a
movq -0x1f0(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x283d0
jmp 0xb76f
movq -0x1f0(%rbp), %rdi
movb $0x0, -0xea(%rbp)
leaq 0x3e2fc(%rip), %rsi     # 0x49a80
leaq 0x1cc75(%rip), %rdx     # 0x28400
callq 0x74a0
jmp 0xbbac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xb7ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xb7c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x7170
leaq -0xe9(%rbp), %rdi
callq 0x72e0
testb $0x1, -0xea(%rbp)
jne 0xb7e0
jmp 0xb7ec
movq -0x1f0(%rbp), %rdi
callq 0x71c0
jmp 0xb7ff
leaq -0xc8(%rbp), %rdi
callq 0x27d70
jmp 0xbaca
leaq -0xc8(%rbp), %rdi
callq 0x27d70
jmp 0xbba3
leaq -0x100(%rbp), %rdi
movl $0x61, %esi
callq 0x28170
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0x1f8(%rbp)
cmpq $0x0, %rax
jne 0xb850
callq 0x7300
jmp 0xb850
movq -0x1f8(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x3f4fb(%rip), %rdi     # 0x4ad60
callq 0x9370
testb $0x1, %al
jne 0xb873
jmp 0xb94e
movb $0x1, -0x122(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x208(%rbp)
leaq -0x121(%rbp), %rdi
movq %rdi, -0x200(%rbp)
callq 0x74f0
movq -0x200(%rbp), %rdx
leaq 0x2bd23(%rip), %rsi     # 0x375cf
leaq -0x120(%rbp), %rdi
callq 0x8940
jmp 0xb8ba
movq -0x208(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x283d0
jmp 0xb8cf
movq -0x208(%rbp), %rdi
movb $0x0, -0x122(%rbp)
leaq 0x3e19c(%rip), %rsi     # 0x49a80
leaq 0x1cb15(%rip), %rdx     # 0x28400
callq 0x74a0
jmp 0xbbac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xb95f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xb929
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x7170
leaq -0x121(%rbp), %rdi
callq 0x72e0
testb $0x1, -0x122(%rbp)
jne 0xb940
jmp 0xb94c
movq -0x208(%rbp), %rdi
callq 0x71c0
jmp 0xb95f
leaq -0x100(%rbp), %rdi
callq 0x281b0
jmp 0xbaca
leaq -0x100(%rbp), %rdi
callq 0x281b0
jmp 0xbba3
leaq -0x138(%rbp), %rdi
xorl %esi, %esi
callq 0x26800
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0x210(%rbp)
cmpq $0x0, %rax
jne 0xb9ad
callq 0x7300
jmp 0xb9ad
movq -0x210(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x3ef96(%rip), %rdi     # 0x4a958
callq 0x9370
testb $0x1, %al
jne 0xb9d0
jmp 0xbaab
movb $0x1, -0x15a(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0x220(%rbp)
leaq -0x159(%rbp), %rdi
movq %rdi, -0x218(%rbp)
callq 0x74f0
movq -0x218(%rbp), %rdx
leaq 0x2bc07(%rip), %rsi     # 0x37610
leaq -0x158(%rbp), %rdi
callq 0x8940
jmp 0xba17
movq -0x220(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x283d0
jmp 0xba2c
movq -0x220(%rbp), %rdi
movb $0x0, -0x15a(%rbp)
leaq 0x3e03f(%rip), %rsi     # 0x49a80
leaq 0x1c9b8(%rip), %rdx     # 0x28400
callq 0x74a0
jmp 0xbbac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xbab9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xba86
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x7170
leaq -0x159(%rbp), %rdi
callq 0x72e0
testb $0x1, -0x15a(%rbp)
jne 0xba9d
jmp 0xbaa9
movq -0x220(%rbp), %rdi
callq 0x71c0
jmp 0xbab9
leaq -0x138(%rbp), %rdi
callq 0x26840
jmp 0xbaca
leaq -0x138(%rbp), %rdi
callq 0x26840
jmp 0xbba3
movq -0x10(%rbp), %rax
movq %rax, %rdi
addq $0x18, %rdi
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq %rax, %rcx
movq -0x190(%rbp), %rax
movq (%rcx), %rdi
movl 0x8(%rax), %esi
movq (%rdi), %rax
movq 0x80(%rax), %rax
callq *%rax
movq -0x10(%rbp), %rax
addq $0x78, %rax
movq %rax, -0x230(%rbp)
leaq -0x181(%rbp), %rdi
movq %rdi, -0x228(%rbp)
callq 0x74f0
movq -0x228(%rbp), %rdx
leaq 0x2bb22(%rip), %rsi     # 0x3764f
leaq -0x180(%rbp), %rdi
callq 0x8940
jmp 0xbb3b
movq -0x230(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x2c4d0
jmp 0xbb50
leaq -0x180(%rbp), %rdi
callq 0x7170
leaq -0x181(%rbp), %rdi
callq 0x72e0
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xbb97
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x7170
leaq -0x181(%rbp), %rdi
callq 0x72e0
movq -0x40(%rbp), %rdi
callq 0x74e0
nopl (%rax)