// File: zerolfx[P]P-Machine/mstf.cpp
// Function: Mstf::execute(StackMachine*)
void Mstf::execute(StackMachine *stack)
{	
	for(int i = 0; i < 5; ++i)
	{
		stack->fStore.push_back(new StackElement());
	}
	
	// static link
	delete stack->fStore[stack->fSP + 2];
	stack->fStore[stack->fSP + 2] = new StackAddress(stack->fStore[stack->base(fP, stack->fMP) + fQ + 1]->getValue());
	
	// dynamic link
	delete stack->fStore[stack->fSP + 3];
	stack->fStore[stack->fSP + 3] = new StackAddress(stack->fMP);
	
	// save EP
	delete stack->fStore[stack->fSP + 4];
	stack->fStore[stack->fSP + 4] = new StackAddress(stack->fEP);
	
	stack->fSP += 5;
	
	// adding cost of this instruction
	stack->fTime.count("mstf");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0x5, -0x14(%rbp)
jge 0x1bb5e
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x70(%rbp)
movl $0x8, %edi
callq 0x7270
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x68(%rbp)
callq 0x26c80
jmp 0x1bb1f
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rax
movq %rax, -0x20(%rbp)
leaq -0x20(%rbp), %rsi
callq 0xd2a0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1baf2
movq -0x68(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x8, %esi
callq 0x7280
jmp 0x1be7e
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movl 0xb4(%rax), %eax
addl $0x2, %eax
movslq %eax, %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, %rax
je 0x1bb9f
movq -0x78(%rbp), %rdi
callq 0x26ca0
movq -0x78(%rbp), %rdi
movl $0x8, %esi
callq 0x7280
movl $0x10, %edi
callq 0x7270
movq %rax, %rcx
movq -0x60(%rbp), %rax
movq %rcx, -0x90(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, %rcx
addq $0x18, %rcx
movq %rcx, -0x88(%rbp)
movl 0x8(%rax), %esi
movl 0xc0(%rdi), %edx
callq 0x2d050
movl %eax, -0x7c(%rbp)
jmp 0x1bbdc
movq -0x88(%rbp), %rdi
movl -0x7c(%rbp), %ecx
movq -0x60(%rbp), %rax
movl 0xc(%rax), %edx
movl %ecx, %eax
movl %edx, %ecx
leal 0x1(%rax,%rcx), %eax
movslq %eax, %rsi
callq 0x8e70
movq (%rax), %rdi
movq (%rdi), %rax
movq 0x68(%rax), %rax
callq *%rax
movl %eax, -0x94(%rbp)
jmp 0x1bc11
movl -0x94(%rbp), %esi
movq -0x90(%rbp), %rdi
callq 0x26800
jmp 0x1bc25
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movl 0xb4(%rax), %eax
addl $0x2, %eax
movslq %eax, %rsi
callq 0x8e70
movq -0x90(%rbp), %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movl 0xb4(%rax), %eax
addl $0x3, %eax
movslq %eax, %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0xa0(%rbp)
cmpq $0x0, %rax
je 0x1bc96
movq -0xa0(%rbp), %rdi
callq 0x26ca0
movq -0xa0(%rbp), %rdi
movl $0x8, %esi
callq 0x7280
movl $0x10, %edi
callq 0x7270
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xa8(%rbp)
movq -0x10(%rbp), %rax
movl 0xc0(%rax), %esi
callq 0x26800
jmp 0x1bcbe
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movl 0xb4(%rax), %eax
addl $0x3, %eax
movslq %eax, %rsi
callq 0x8e70
movq -0xa8(%rbp), %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movl 0xb4(%rax), %eax
addl $0x4, %eax
movslq %eax, %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0xb0(%rbp)
cmpq $0x0, %rax
je 0x1bd2f
movq -0xb0(%rbp), %rdi
callq 0x26ca0
movq -0xb0(%rbp), %rdi
movl $0x8, %esi
callq 0x7280
movl $0x10, %edi
callq 0x7270
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rax
movl 0xbc(%rax), %esi
callq 0x26800
jmp 0x1bd57
movq -0x10(%rbp), %rax
movq %rax, %rdi
addq $0x18, %rdi
movl 0xb4(%rax), %eax
addl $0x4, %eax
movslq %eax, %rsi
callq 0x8e70
movq -0xb8(%rbp), %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movl 0xb4(%rax), %ecx
addl $0x5, %ecx
movl %ecx, 0xb4(%rax)
movq -0x10(%rbp), %rax
addq $0x78, %rax
movq %rax, -0xc8(%rbp)
leaq -0x51(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0x74f0
movq -0xc0(%rbp), %rdx
leaq 0x1d2d3(%rip), %rsi     # 0x39090
leaq -0x50(%rbp), %rdi
callq 0x8940
jmp 0x1bdc8
movq -0xc8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x2c4d0
jmp 0x1bdda
leaq -0x50(%rbp), %rdi
callq 0x7170
leaq -0x51(%rbp), %rdi
callq 0x72e0
addq $0xd0, %rsp
popq %rbp
retq
movq -0x90(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x10, %esi
callq 0x7280
jmp 0x1be7e
movq -0xa8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x10, %esi
callq 0x7280
jmp 0x1be7e
movq -0xb8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x10, %esi
callq 0x7280
jmp 0x1be7e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x1be75
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x7170
leaq -0x51(%rbp), %rdi
callq 0x72e0
movq -0x28(%rbp), %rdi
callq 0x74e0
nopw (%rax,%rax)