// File: /workspace/github_cpp_makefile_star2_O3/jstaursky[P]hutch/src/Sleigh/sleigh.cc
// Function: SleighBuilder::delaySlot(OpTpl*)
void SleighBuilder::delaySlot (OpTpl* op)

{ // Append pcode for an entire instruction (delay slot)
    // in the middle of the current instruction
    ParserWalker* tmp = walker;
    uintb olduniqueoffset = uniqueoffset;

    Address baseaddr = tmp->getAddr ();
    int4 fallOffset = tmp->getLength ();
    int4 delaySlotByteCnt = tmp->getParserContext ()->getDelaySlot ();
    int4 bytecount = 0;
    do {
        Address newaddr = baseaddr + fallOffset;
        setUniqueOffset (newaddr);
        const ParserContext* pos = discache->getParserContext (newaddr);
        if (pos->getParserState () != ParserContext::pcode)
            throw LowlevelError (
                "Could not obtain cached delay slot instruction");
        int4 len = pos->getLength ();

        ParserWalker newwalker (pos);
        walker = &newwalker;
        walker->baseState ();
        build (walker->getConstructor ()->getTempl (),
               -1); // Build the whole delay slot
        fallOffset += len;
        bytecount += len;
    } while (bytecount < delaySlotByteCnt);
    walker = tmp; // Restore original context
    uniqueoffset = olduniqueoffset;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rdi, %rbx
movq 0x10(%rdi), %rcx
movq 0x30(%rdi), %rax
movq %rax, (%rsp)
movq (%rcx), %rax
movq %rcx, 0x8(%rsp)
movq 0x8(%rcx), %rcx
testq %rcx, %rcx
cmoveq %rax, %rcx
movq 0x50(%rcx), %r13
movq 0x58(%rcx), %rcx
movq %rcx, 0x10(%rsp)
movq 0x98(%rax), %rcx
movl 0x60(%rcx), %r12d
movl 0xa4(%rax), %r15d
xorl %ebp, %ebp
movslq %r12d, %rax
addq 0x10(%rsp), %rax
movq 0x28(%r13), %rcx
cmpq %rax, %rcx
jae 0x577d6
incq %rcx
cqto
idivq %rcx
movq %rdx, %rax
sarq $0x3f, %rax
andq %rcx, %rax
addq %rdx, %rax
movq %r13, 0x18(%rsp)
movq %rax, 0x20(%rsp)
andq 0x28(%rbx), %rax
shlq $0x4, %rax
movq %rax, 0x30(%rbx)
movq 0x38(%rbx), %rdi
leaq 0x18(%rsp), %rsi
callq 0x3fd60
cmpl $0x2, (%rax)
jne 0x5786f
movq 0x98(%rax), %rcx
movl 0x60(%rcx), %r14d
movq %rax, 0x28(%rsp)
xorl %eax, %eax
movq %rax, 0x30(%rsp)
leaq 0x28(%rsp), %rdx
movq %rdx, 0x10(%rbx)
movq %rcx, 0x38(%rsp)
movq %rax, 0x40(%rsp)
movq (%rcx), %rax
movq 0x60(%rax), %rsi
movq %rbx, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x3f5a0
addl %r14d, %r12d
addl %r14d, %ebp
cmpl %r15d, %ebp
jl 0x577b0
movq 0x8(%rsp), %rax
movq %rax, 0x10(%rbx)
movq (%rsp), %rax
movq %rax, 0x30(%rbx)
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x20, %edi
callq 0x3fb00
movq %rax, %rbx
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x28ba0(%rip), %rsi     # 0x8042c
leaq 0x28bc7(%rip), %rdx     # 0x8045a
leaq 0x28(%rsp), %rdi
callq 0x3f8a0
movb $0x1, %bpl
leaq 0x28(%rsp), %rsi
movq %rbx, %rdi
callq 0x3f890
xorl %ebp, %ebp
movq 0x4b5f2(%rip), %rsi     # 0xa2ea8
movq 0x4b37b(%rip), %rdx     # 0xa2c38
movq %rbx, %rdi
callq 0x41d70
movq %rax, %r14
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x578df
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x40880
testb %bpl, %bpl
jne 0x578e9
jmp 0x578f1
movq %rax, %r14
movq %rbx, %rdi
callq 0x40090
movq %r14, %rdi
callq 0x41f10
nop