// File: /workspace/github_cpp_makefile_star2_O2/jstaursky[P]hutch/src/hutch.cpp
// Function: Hutch_Instructions::storeInstruction(Address const&, std::any)
void Hutch_Instructions::storeInstruction (Address const& addr, any insn)
{
    auto len = addr.getSpace ()->getTrans ()->instructionLength (addr);

    // Keep track of vector relocations for Hutch_Instructions::mark.
    auto ofront = (!instructions.empty ()) ? instructions.data () : 0;
    auto oback = (!instructions.empty ()) ?
                     instructions.data () + instructions.size () - 1 :
                     0;
    size_t fdiff, bdiff;

    // Do not need to track very initial run (when instructions.empty ())
    if (instructions.empty ()) {
        Instruction instr;
        instr.bytelength = len;
        instr.address = addr.getOffset ();
        if (insn.type () == typeid (string)) {
            instr.assembly = any_cast<string> (insn);
        }
        if (insn.type () == typeid (PcodeData)) {
            instr.pcode.push_back (any_cast<PcodeData> (insn));
        }
        instructions.push_back (instr);
        this->currentinsn = &instructions.back ();
        return;
    } else if ((insn.type () == typeid (PcodeData)) and
               (instructions.front ().pcode.empty ())) {
        instructions.front ().pcode.push_back (any_cast<PcodeData> (insn));
        instructions.front ().bytelength = len;
        this->currentinsn = &instructions.front ();

        // Move mark if vector instructions has moved.
        fdiff = instructions.data () - ofront;
        bdiff = (instructions.data () + instructions.size () - 1) - oback;
        mark = (mark != nullptr) ?
                     (fdiff != 0) || (bdiff != 0) ?
                     (fdiff > bdiff) ? mark + fdiff : mark + bdiff :
                     mark :
                     nullptr;
        return;
    }

    for (auto i = 0; i != instructions.size (); ++i) {
        if ((instructions[i].address == addr.getOffset ()) and
            (insn.type () == typeid (string))) {
            if (instructions[i].assembly == any_cast<string> (insn)) {
                this->currentinsn = &instructions[i];
                return;
            }
            if (instructions[i].assembly == "") {
                instructions[i].assembly = any_cast<string> (insn);
                instructions[i].bytelength = len;
                this->currentinsn = &instructions[i];
                return;
            }
        }
        if ((instructions[i].address == addr.getOffset ()) and
            (insn.type () == typeid (PcodeData))) {
            auto pcode = any_cast<PcodeData> (insn);
            if (find (instructions[i].pcode.begin (),
                      instructions[i].pcode.end (),
                      pcode) != instructions[i].pcode.end ()) {
                pcode.release ();
                this->currentinsn = &instructions[i];
                return;
            } else {
                instructions[i].pcode.push_back (any_cast<PcodeData> (insn));
                instructions[i].bytelength = len;
                this->currentinsn = &instructions[i];
                // Move mark if vector instructions has moved.
                fdiff = instructions.data () - ofront;
                bdiff =
                    (instructions.data () + instructions.size () - 1) - oback;
                mark = (mark != nullptr) ?
                             (fdiff != 0) || (bdiff != 0) ?
                             (fdiff > bdiff) ? mark + fdiff : mark + bdiff :
                             mark :
                             nullptr;
                return;
            }
        }
    }

    Instruction instr;

    instr.address = addr.getOffset ();
    instr.bytelength = len;

    if (insn.type () == typeid (string))
        instr.assembly = any_cast<string> (insn);
    if (insn.type () == typeid (PcodeData))
        instr.pcode.push_back (any_cast<PcodeData> (insn));

    auto index = distance (
        instructions.begin (),
        lower_bound (instructions.begin (), instructions.end (),
                     addr.getOffset (),
                     [](const Instruction& lhs, const uintb& rhs) -> bool {
                         return lhs.address < rhs;
                     }));

    if (instructions[index].address != addr.getOffset ()) {
        instructions.insert (instructions.begin () + index, instr);
        if (index > 0)
            this->currentinsn = &instructions[index - 1];
        else
            this->currentinsn = &instructions[index];
        // Move mark if vector instructions has moved.
        fdiff = instructions.data () - ofront;
        bdiff = (instructions.data () + instructions.size () - 1) - oback;
        mark = (mark != nullptr) ?
                     (fdiff != 0) || (bdiff != 0) ?
                     (fdiff > bdiff) ? mark + fdiff : mark + bdiff :
                     mark :
                     nullptr;
        return;
    }
    this->currentinsn = &instructions[index];
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
movq (%rsi), %rax
movq 0x18(%rax), %rdi
movq (%rdi), %rax
callq *0x58(%rax)
movl %eax, %r14d
leaq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rbx), %rbp
movq 0x18(%rbx), %rax
cmpq %rax, %rbp
je 0x7eea4
movl %r14d, 0xc(%rsp)
movq %rax, 0x20(%rsp)
addq $-0x58, %rax
movq %rax, 0x18(%rsp)
movq %r15, %rdi
callq 0x51900
movq 0x2fe52(%rip), %rsi     # 0xaebe0
movq %rax, %rdi
callq 0x4e960
testb %al, %al
je 0x7edb0
movq 0x10(%rsp), %rax
movq (%rax), %r13
movq 0x30(%r13), %rax
cmpq 0x38(%r13), %rax
je 0x7f111
movq %rbp, 0x28(%rsp)
xorl %r14d, %r14d
xorl %ebp, %ebp
movq 0x10(%rsp), %r13
movq 0x10(%rbx), %rcx
movq 0x18(%rbx), %rax
subq %rcx, %rax
cqto
pushq $0x58
popq %rsi
idivq %rsi
cmpq %rax, %rbp
je 0x7ef60
movq (%rcx,%r14), %rax
cmpq 0x8(%r12), %rax
jne 0x7ee6e
movq %r15, %rdi
callq 0x51900
movq %rax, %rdi
movq 0x2fdcc(%rip), %rsi     # 0xaebc8
callq 0x4e960
movq (%r13), %rcx
testb %al, %al
je 0x7ee6e
movq %r15, %rsi
leaq (%rcx,%r14), %r13
addq $0x10, %r13
leaq 0x50(%rsp), %rdi
callq 0x4e320
movq %r13, %rdi
leaq 0x50(%rsp), %rsi
callq 0x4e5d0
movl %eax, %r13d
leaq 0x50(%rsp), %rdi
callq 0x4e020
movq 0x10(%rsp), %rax
movq (%rax), %rax
testb %r13b, %r13b
jne 0x7f171
leaq (%rax,%r14), %rdi
addq $0x10, %rdi
leaq 0x9368(%rip), %rsi      # 0x881c0
callq 0x520f0
testb %al, %al
jne 0x7f17d
movq 0x10(%rsp), %r13
movq (%r13), %rcx
movq (%rcx,%r14), %rax
cmpq 0x8(%r12), %rax
jne 0x7ee98
movq %r15, %rdi
callq 0x51900
movq %rax, %rdi
movq 0x2fd55(%rip), %rsi     # 0xaebe0
callq 0x4e960
testb %al, %al
jne 0x7f0c5
incq %rbp
addq $0x58, %r14
jmp 0x7edbf
leaq 0x50(%rsp), %r13
movq %r13, %rdi
callq 0x4dca0
movslq %r14d, %rax
movq %rax, 0x8(%r13)
movq 0x8(%r12), %rax
movq %rax, (%r13)
movq %r15, %rdi
callq 0x51900
movq 0x2fcf8(%rip), %rsi     # 0xaebc8
movq %rax, %rdi
callq 0x4e960
testb %al, %al
je 0x7ef03
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
callq 0x4e320
leaq 0x60(%rsp), %rdi
leaq 0x30(%rsp), %r12
movq %r12, %rsi
callq 0x4fef0
movq %r12, %rdi
callq 0x4e020
movq %r15, %rdi
callq 0x51900
movq 0x2fcce(%rip), %rsi     # 0xaebe0
movq %rax, %rdi
callq 0x4e960
testb %al, %al
movq 0x10(%rsp), %r14
je 0x7ef42
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
callq 0x4fb60
leaq 0x80(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x51ff0
leaq 0x50(%rsp), %rsi
movq %r14, %rdi
callq 0x519b0
movq 0x18(%rbx), %rax
addq $-0x58, %rax
movq %rax, 0x28(%rbx)
jmp 0x7f253
leaq 0x50(%rsp), %r13
movq %r13, %rdi
callq 0x4dca0
movq 0x8(%r12), %rax
movq %rax, (%r13)
movslq 0xc(%rsp), %rax
movq %rax, 0x8(%r13)
movq %r15, %rdi
callq 0x51900
movq 0x2fc3a(%rip), %rsi     # 0xaebc8
movq %rax, %rdi
callq 0x4e960
testb %al, %al
movq 0x28(%rsp), %rbp
je 0x7efc6
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
callq 0x4e320
leaq 0x60(%rsp), %rdi
leaq 0x30(%rsp), %r13
movq %r13, %rsi
callq 0x4fef0
movq %r13, %rdi
callq 0x4e020
movq %r15, %rdi
callq 0x51900
movq 0x2fc0b(%rip), %rsi     # 0xaebe0
movq %rax, %rdi
callq 0x4e960
testb %al, %al
movq 0x10(%rsp), %r13
je 0x7f005
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
callq 0x4fb60
leaq 0x80(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x51ff0
movq 0x10(%rbx), %r14
movq 0x18(%rbx), %rax
movq 0x8(%r12), %rcx
subq %r14, %rax
cqto
pushq $0x58
popq %rsi
idivq %rsi
movq %r14, %r15
testq %rax, %rax
jle 0x7f047
movq %rax, %rdx
shrq %rdx
imulq $0x58, %rdx, %rsi
cmpq %rcx, (%r15,%rsi)
jae 0x7f042
notq %rdx
addq %rax, %rdx
addq %rsi, %r15
addq $0x58, %r15
movq %rdx, %rax
jmp 0x7f020
cmpq %rcx, (%r15)
jne 0x7f055
movq %r15, 0x28(%rbx)
jmp 0x7f253
leaq 0x50(%rsp), %rdx
movq %r13, %rdi
movq %r15, %rsi
callq 0x50520
subq %r14, %r15
movq 0x10(%rbx), %rcx
leaq (%rcx,%r15), %rax
testq %r15, %r15
leaq -0x58(%rcx,%r15), %rsi
cmovleq %rax, %rsi
movq 0x18(%rbx), %rdx
movq %rsi, 0x28(%rbx)
movq 0x30(%rbx), %rax
testq %rax, %rax
je 0x7f1c4
movq %rbp, %rsi
xorq %rcx, %rsi
movq 0x20(%rsp), %rdi
xorq %rdx, %rdi
orq %rsi, %rdi
je 0x7f24f
subq %rbp, %rcx
subq 0x18(%rsp), %rdx
addq $-0x58, %rdx
cmpq %rdx, %rcx
jbe 0x7f24c
addq %rcx, %rax
jmp 0x7f24f
leaq 0x50(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x4fb60
movq (%r13), %rax
movq 0x30(%rax,%r14), %rdi
movq 0x38(%rax,%r14), %rsi
movq %r12, %rdx
callq 0x52130
movq (%r13), %rcx
cmpq 0x38(%rcx,%r14), %rax
je 0x7f1cb
leaq 0x50(%rsp), %rdi
callq 0x4d190
addq 0x10(%rbx), %r14
movq %r14, 0x28(%rbx)
jmp 0x7f25d
addq $0x30, %r13
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x4fb60
movq %r13, %rdi
movq %r14, %rsi
callq 0x51ff0
movslq 0xc(%rsp), %rax
movq 0x10(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq %rcx, 0x28(%rbx)
movq 0x30(%rbx), %rax
testq %rax, %rax
je 0x7f23f
movq 0x18(%rbx), %rdx
movq %rbp, %rsi
xorq %rcx, %rsi
movq 0x20(%rsp), %rdi
xorq %rdx, %rdi
orq %rsi, %rdi
je 0x7f246
subq %rbp, %rcx
jmp 0x7f22c
addq %r14, %rax
movq %rax, 0x28(%rbx)
jmp 0x7f25d
leaq 0x50(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x4e320
movq 0x10(%rbx), %rax
leaq (%rax,%r14), %rdi
addq $0x10, %rdi
movq %r12, %rsi
callq 0x4fef0
movq %r12, %rdi
callq 0x4e020
movslq 0xc(%rsp), %rax
movq 0x10(%rbx), %rcx
leaq (%rcx,%r14), %rdx
movq %rax, 0x8(%rcx,%r14)
movq %rdx, 0x28(%rbx)
jmp 0x7f25d
xorl %eax, %eax
jmp 0x7f24f
leaq (%rcx,%r14), %r13
addq $0x30, %r13
leaq 0x30(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x4fb60
movq %r13, %rdi
movq %r12, %rsi
callq 0x51ff0
movslq 0xc(%rsp), %rax
movq 0x10(%rbx), %rcx
leaq (%rcx,%r14), %rdx
movq %rax, 0x8(%rcx,%r14)
movq %rdx, 0x28(%rbx)
movq 0x30(%rbx), %rax
testq %rax, %rax
je 0x7f23f
movq 0x18(%rbx), %rdx
movq 0x28(%rsp), %rdi
movq %rdi, %rsi
xorq %rcx, %rsi
movq 0x20(%rsp), %r8
xorq %rdx, %r8
orq %rsi, %r8
je 0x7f246
subq %rdi, %rcx
subq 0x18(%rsp), %rdx
addq $-0x58, %rdx
cmpq %rdx, %rcx
jbe 0x7f243
addq %rcx, %rax
jmp 0x7f246
xorl %eax, %eax
jmp 0x7f246
addq %rdx, %rax
movq %rax, 0x30(%rbx)
jmp 0x7f25d
addq %rdx, %rax
movq %rax, 0x30(%rbx)
leaq 0x50(%rsp), %rdi
callq 0x4e9a0
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7f279
jmp 0x7f279
jmp 0x7f279
jmp 0x7f279
jmp 0x7f279
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x4e9a0
movq %rbx, %rdi
callq 0x518c0