// File: /workspace/github_cpp_makefile_star2_O2/zerolfx[P]P-Machine/retp.cpp
// Function: Retp::execute(StackMachine*)
void Retp::execute(StackMachine *stack)
{	
	StackAddress p;
	if((typeid(p) != typeid(*(stack->fStore[stack->fMP + 2]))
		|| (typeid(p) != typeid(*(stack->fStore[stack->fMP + 3])))
		|| (typeid(p) != typeid(*(stack->fStore[stack->fMP + 4])))))
	{
		throw ExecutionError("instruction retp: stackframe has been compromised.");
	}
	
	int oldSP = stack->fSP;
	
	// proper procedure with no results
	stack->fSP = stack->fMP - 1;
	
	// return branch
	stack->fPC = stack->fStore[stack->fMP + 4]->getValue();
	
	// restore EP
	stack->fEP = stack->fStore[stack->fMP + 3]->getValue();

	// dynamic link
	stack->fMP = stack->fStore[stack->fMP + 2]->getValue();
	
	for(int i = oldSP; i > stack->fSP; --i)
	{
		delete stack->fStore[i];
		stack->fStore.pop_back();
	}
	
	// adding cost of this instruction
	stack->fTime.count("retp");

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rsi, %rbx
leaq -0x58(%rbp), %rdi
xorl %esi, %esi
callq 0x1704c
movslq 0xc0(%rbx), %rax
movq 0x18(%rbx), %rcx
movq 0x10(%rcx,%rax,8), %rax
testq %rax, %rax
je 0x134c8
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x1b5ee(%rip), %rdi     # 0x2e960
callq 0x76ba
testb %al, %al
jne 0x134cd
movslq 0xc0(%rbx), %rax
movq 0x18(%rbx), %rcx
movq 0x18(%rcx,%rax,8), %rax
testq %rax, %rax
je 0x134c8
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x1b5ba(%rip), %rdi     # 0x2e960
callq 0x76ba
testb %al, %al
jne 0x134cd
movslq 0xc0(%rbx), %rax
movq 0x18(%rbx), %rcx
movq 0x20(%rcx,%rax,8), %rax
testq %rax, %rax
je 0x134c8
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x1b586(%rip), %rdi     # 0x2e960
callq 0x76ba
testb %al, %al
jne 0x134cd
movslq 0xb4(%rbx), %r12
movslq 0xc0(%rbx), %rax
leal -0x1(%rax), %ecx
movl %ecx, 0xb4(%rbx)
movq 0x18(%rbx), %rcx
movq 0x20(%rcx,%rax,8), %rdi
movq (%rdi), %rax
callq *0x68(%rax)
movl %eax, 0xb0(%rbx)
movslq 0xc0(%rbx), %rax
movq 0x18(%rbx), %rcx
movq 0x18(%rcx,%rax,8), %rdi
movq (%rdi), %rax
callq *0x68(%rax)
movl %eax, 0xbc(%rbx)
movslq 0xc0(%rbx), %rax
movq 0x18(%rbx), %rcx
movq 0x10(%rcx,%rax,8), %rdi
movq (%rdi), %rax
callq *0x68(%rax)
movl %eax, 0xc0(%rbx)
pushq $0x8
popq %r14
movslq 0xb4(%rbx), %rax
cmpq %rax, %r12
jle 0x13485
movq 0x18(%rbx), %rax
movq (%rax,%r12,8), %r15
testq %r15, %r15
je 0x13470
movq %r15, %rdi
callq 0x17248
movq %r15, %rdi
movq %r14, %rsi
callq 0x61e0
addq $-0x8, 0x20(%rbx)
decq %r12
jmp 0x1344f
leaq 0xd30e(%rip), %rsi      # 0x2079a
leaq -0x48(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0x72a6
addq $0x78, %rbx
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x1925e
leaq -0x48(%rbp), %rdi
callq 0x60d0
leaq -0x58(%rbp), %rdi
callq 0x17070
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x6220
pushq $0x20
popq %rdi
callq 0x60f0
movq %rax, %rbx
leaq 0xd288(%rip), %rsi      # 0x20767
leaq -0x48(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0x72a6
movb $0x1, %r15b
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x17d10
xorl %r15d, %r15d
leaq 0x1a583(%rip), %rsi     # 0x2da88
leaq 0x480e(%rip), %rdx      # 0x17d1a
movq %rbx, %rdi
callq 0x63c0
movq %rax, %r14
leaq -0x48(%rbp), %rdi
callq 0x60d0
jmp 0x13549
jmp 0x13546
movq %rax, %r14
leaq -0x48(%rbp), %rdi
callq 0x60d0
testb %r15b, %r15b
jne 0x1353a
jmp 0x13549
movq %rax, %r14
movq %rbx, %rdi
callq 0x6150
jmp 0x13549
jmp 0x13546
movq %rax, %r14
leaq -0x58(%rbp), %rdi
callq 0x17070
movq %r14, %rdi
callq 0x63f0