// File: zerolfx[P]P-Machine/mod.cpp
// Function: Mod::execute(StackMachine*)
void Mod::execute(StackMachine *stack) {
    if(typeid(StackInteger) != typeid(*(stack->fStore[stack->fSP])))
        throw ExecutionError("instruction mod: SP does not point to element of type integer.");
    if(typeid(StackInteger) != typeid(*(stack->fStore[stack->fSP - 1])))
        throw ExecutionError("instruction mod: SP - 1 does not point to element of type integer.");


    // actual addition
    stack->fStore[stack->fSP - 1]->mod(stack->fStore[stack->fSP]);

    // SP := SP - 1
    delete stack->fStore[stack->fSP];
    stack->fStore[stack->fSP] = 0;
    stack->fStore.pop_back();
    --stack->fSP;

    stack->fTime.count("mod");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0xa0(%rbp)
cmpq $0x0, %rax
jne 0x8fd0
callq 0x7300
movq -0xa0(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x41b0b(%rip), %rdi     # 0x4aaf0
callq 0x9370
testb $0x1, %al
jne 0x8ff3
jmp 0x90ab
movb $0x1, -0x45(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0xb0(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
callq 0x74f0
movq -0xa8(%rbp), %rdx
leaq 0x2e033(%rip), %rsi     # 0x37059
leaq -0x30(%rbp), %rdi
callq 0x8940
jmp 0x9031
movq -0xb0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x283d0
jmp 0x9043
movq -0xb0(%rbp), %rdi
movb $0x0, -0x45(%rbp)
leaq 0x40a2b(%rip), %rsi     # 0x49a80
leaq 0x1f3a4(%rip), %rdx     # 0x28400
callq 0x74a0
jmp 0x9338
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x9089
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 0x909a
jmp 0x90a6
movq -0xb0(%rbp), %rdi
callq 0x71c0
jmp 0x932f
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, -0xb8(%rbp)
cmpq $0x0, %rax
jne 0x90dd
callq 0x7300
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rsi
leaq 0x419fe(%rip), %rdi     # 0x4aaf0
callq 0x9370
testb $0x1, %al
jne 0x9100
jmp 0x91b8
movb $0x1, -0x6a(%rbp)
movl $0x20, %edi
callq 0x7110
movq %rax, -0xc8(%rbp)
leaq -0x69(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0x74f0
movq -0xc0(%rbp), %rdx
leaq 0x2df65(%rip), %rsi     # 0x37098
leaq -0x68(%rbp), %rdi
callq 0x8940
jmp 0x913e
movq -0xc8(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x283d0
jmp 0x9150
movq -0xc8(%rbp), %rdi
movb $0x0, -0x6a(%rbp)
leaq 0x4091e(%rip), %rsi     # 0x49a80
leaq 0x1f297(%rip), %rdx     # 0x28400
callq 0x74a0
jmp 0x9338
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x9196
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x7170
leaq -0x69(%rbp), %rdi
callq 0x72e0
testb $0x1, -0x6a(%rbp)
jne 0x91a7
jmp 0x91b3
movq -0xc8(%rbp), %rdi
callq 0x71c0
jmp 0x932f
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, -0xd8(%rbp)
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq -0xd8(%rbp), %rdi
movq (%rax), %rsi
movq (%rdi), %rax
callq *0x20(%rax)
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movslq 0xb4(%rax), %rsi
callq 0x8e70
movq (%rax), %rax
movq %rax, -0xd0(%rbp)
cmpq $0x0, %rax
je 0x924c
movq -0xd0(%rbp), %rdi
callq 0x26ca0
movq -0xd0(%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, -0xe8(%rbp)
leaq -0x91(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x74f0
movq -0xe0(%rbp), %rdx
leaq 0x2de22(%rip), %rsi     # 0x370db
leaq -0x90(%rbp), %rdi
callq 0x8940
jmp 0x92c7
movq -0xe8(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x2c4d0
jmp 0x92dc
leaq -0x90(%rbp), %rdi
callq 0x7170
leaq -0x91(%rbp), %rdi
callq 0x72e0
addq $0xf0, %rsp
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x9323
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x7170
leaq -0x91(%rbp), %rdi
callq 0x72e0
movq -0x40(%rbp), %rdi
callq 0x74e0
nopl (%rax,%rax)