// File: /workspace/github_cpp_makefile_star2_O1/jstaursky[P]hutch/src/hutch.cpp
// Function: Hutch::inspectPreviousInstruction(unsigned long, unsigned long, Hutch_Instructions&, bool (*)(PcodeData))
vector<Instruction>
Hutch::inspectPreviousInstruction (uintb offset, uintb limit,
                                   Hutch_Instructions& insn,
                                   bool (*select) (PcodeData))
{
    vector<Instruction> res;

    resetMark (offset, insn);
    if (insn.getMark ()->address - 1 == 0)
        return {};

    for (auto r = 1; (r != limit) && ((offset - r) > 0) &&
                     disassemble_iter (offset - r, &insn);
         ++r)
        ;
    for (auto rinsn = insn.getMark () - 1; rinsn != insn.current (); --rinsn) {
        // For ROP:
        // Need to determine whether the instruction ends immediately prior to
        // the marked/c3(ret) instruction for instruction to be useful.
        if (select == nullptr) {
            if ((rinsn->address + rinsn->bytelength) ==
                insn.getMark ()->address)
                res.push_back (*rinsn);
            continue;
        }
        // Only add those instructions that meet the alignment requirement
        // described above AND satisfy whatever condition the fptr "select" imposes.
        if (bool isSelected = false;
            (rinsn->address + rinsn->bytelength) == insn.getMark ()->address) {
            for (auto p : rinsn->pcode) {
                isSelected = select (p);
                if (isSelected) {
                    res.push_back (*rinsn);
                    break;
                }
            }
        }
    }
    return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r9, %r14
movq %r8, %rbp
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %r15
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq %rsi, %rdi
movq %rdx, %rsi
movq %r8, %rdx
callq 0x416b0
movq 0x28(%rbp), %rax
movq %rax, 0x30(%rbp)
cmpq $0x1, (%rax)
movq %r15, %rax
je 0x7776e
cmpq $0x1, %rbx
sete %al
cmpq $0x1, %r12
sete %cl
orb %al, %cl
jne 0x7764c
addq $-0x2, %rbx
leaq -0x2(%r12), %rax
cmpq %rax, %rbx
cmovaeq %rax, %rbx
decq %r12
movq %r13, %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x416b0
subq $0x1, %rbx
setb %cl
testl %eax, %eax
je 0x7764c
decq %r12
testb %cl, %cl
je 0x7762c
movq %r15, 0x18(%rsp)
movq 0x30(%rbp), %r12
leaq -0x58(%r12), %rax
cmpq 0x28(%rbp), %rax
je 0x77757
leaq 0x48(%rsp), %rbx
movq %rbp, 0x20(%rsp)
movq %r12, %rcx
movq -0x50(%r12), %rdx
addq -0x58(%r12), %rdx
movq %rax, %r12
movq 0x30(%rbp), %rax
movq (%rax), %rax
testq %r14, %r14
je 0x77733
cmpq %rax, %rdx
jne 0x77743
movq -0x28(%rcx), %r15
movq -0x20(%rcx), %rbp
cmpq %rbp, %r15
je 0x77743
leaq 0x30(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movl (%r15), %eax
movl %eax, 0x28(%rsp)
movl 0x18(%r15), %eax
movl %eax, 0x40(%rsp)
movq 0x8(%r15), %rsi
movq 0x10(%r15), %rdx
leaq 0x28(%rsp), %rdi
callq 0x41000
leaq 0x50(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movl 0x28(%rsp), %eax
movl %eax, 0x48(%rsp)
movl 0x40(%rsp), %eax
movl %eax, 0x60(%rsp)
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq %rbx, %rdi
callq 0x41000
movq %rbx, %rdi
callq *%r14
movl %eax, %r13d
testb %al, %al
je 0x7772a
movq %rsp, %rdi
movq %r12, %rsi
callq 0x41fb0
addq $0x20, %r15
cmpq %rbp, %r15
sete %al
orb %al, %r13b
je 0x776a8
jmp 0x77743
addq $0x20, %r15
jmp 0x7769f
cmpq %rax, %rdx
jne 0x77743
movq %rsp, %rdi
movq %r12, %rsi
callq 0x41fb0
leaq -0x58(%r12), %rax
movq 0x20(%rsp), %rbp
cmpq 0x28(%rbp), %rax
jne 0x7766e
movq %rsp, %rax
movaps (%rax), %xmm0
movq 0x18(%rsp), %r15
movups %xmm0, (%r15)
movq 0x10(%rax), %rcx
movq %rcx, 0x10(%r15)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq %rsp, %rdi
callq 0x401a0
movq %r15, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7779c
jmp 0x7779c
jmp 0x7779c
movq %rax, %rbx
movq %rsp, %rdi
callq 0x401a0
movq %rbx, %rdi
callq 0x41f00
nop