// File: jstaursky[P]hutch/src/Sleigh/sleigh.cc
// Function: Sleigh::resolve(ParserContext&) const
void Sleigh::resolve (ParserContext& pos) const
// Resolve ALL the constructors involved in the
{
    // instruction at this address
    loader->loadFill (pos.getBuffer (), 16, pos.getAddr ());
    ParserWalkerChange walker (&pos);
    // Clear the previous resolve and initialize the walker
    pos.deallocateState (walker);
    Constructor *ct, *subct;
    uint4 off;
    int4 oper, numoper;

    pos.setDelaySlot (0);
    walker.setOffset (0);        // Initial offset
    pos.clearCommits ();         // Clear any old context commits
    pos.loadContext ();          // Get context for current address
    ct = root->resolve (walker); // Base constructor
    walker.setConstructor (ct);
    ct->applyContext (walker);
    while (walker.isState ()) {
        ct = walker.getConstructor ();
        oper = walker.getOperand ();
        numoper = ct->getNumOperands ();
        while (oper < numoper) {
            OperandSymbol* sym = ct->getOperand (oper);
            off = walker.getOffset (sym->getOffsetBase ()) +
                  sym->getRelativeOffset ();
            // Descend into new operand and reserve space
            pos.allocateOperand (oper, walker);
            walker.setOffset (off);
            TripleSymbol* tsym = sym->getDefiningSymbol ();
            if (tsym != (TripleSymbol*)0) {
                subct = tsym->resolve (walker);
                if (subct != (Constructor*)0) {
                    walker.setConstructor (subct);
                    subct->applyContext (walker);
                    break;
                }
            }
            walker.setCurrentLength (sym->getMinimumLength ());
            walker.popOperand ();
            oper += 1;
        }
        if (oper >= numoper) { // Finished processing constructor
            walker.calcCurrentLength (ct->getMinimumLength (), numoper);
            walker.popOperand ();
            // Check for use of delayslot
            ConstructTpl* templ = ct->getTempl ();
            if ((templ != (ConstructTpl*)0) && (templ->delaySlot () > 0))
                pos.setDelaySlot (templ->delaySlot ());
        }
    }
    // Update Naddr to pointer after instruction
    pos.setNaddr (pos.getAddr () + pos.getLength ());
    pos.setParserState (ParserContext::disassembly);
}

// Assembly:
subq $0x138, %rsp            # imm = 0x138
movq %rdi, 0x130(%rsp)
movq %rsi, 0x128(%rsp)
movq 0x130(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x1e0(%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x128(%rsp), %rdi
callq 0xdf810
movq %rax, 0x28(%rsp)
movq 0x128(%rsp), %rdi
callq 0xd2a50
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq %rax, %rcx
movq (%rdi), %rax
movl $0x10, %edx
callq *0x10(%rax)
movq 0x128(%rsp), %rsi
leaq 0x80(%rsp), %rdi
callq 0xdcbf0
movq 0x128(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0xe22a0
movq 0x128(%rsp), %rdi
xorl %esi, %esi
callq 0xce880
leaq 0x80(%rsp), %rdi
xorl %esi, %esi
callq 0xcec80
movq 0x128(%rsp), %rdi
callq 0xe2820
movq 0x128(%rsp), %rdi
callq 0xcfa70
movq 0x30(%rsp), %rax
movq 0x190(%rax), %rdi
movq (%rdi), %rax
leaq 0x80(%rsp), %rsi
callq *0x30(%rax)
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rsi
leaq 0x80(%rsp), %rdi
callq 0xe2ce0
movq 0x78(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0xdc870
leaq 0x80(%rsp), %rdi
callq 0xd0910
testb $0x1, %al
jne 0x11c632
jmp 0x11c7fa
leaq 0x80(%rsp), %rdi
callq 0xd81d0
movq %rax, 0x78(%rsp)
leaq 0x80(%rsp), %rdi
callq 0xd9aa0
movl %eax, 0x68(%rsp)
movq 0x78(%rsp), %rdi
callq 0xd0880
movl %eax, 0x64(%rsp)
movl 0x68(%rsp), %eax
cmpl 0x64(%rsp), %eax
jge 0x11c776
movq 0x78(%rsp), %rdi
movl 0x68(%rsp), %esi
callq 0xd3060
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rdi
callq 0xdc230
movl %eax, %esi
leaq 0x80(%rsp), %rdi
callq 0xdc210
movl %eax, 0x1c(%rsp)
movq 0x58(%rsp), %rdi
callq 0xdae70
movl %eax, %ecx
movl 0x1c(%rsp), %eax
addl %ecx, %eax
movl %eax, 0x6c(%rsp)
movq 0x128(%rsp), %rdi
movl 0x68(%rsp), %esi
leaq 0x80(%rsp), %rdx
callq 0xd8740
movl 0x6c(%rsp), %esi
leaq 0x80(%rsp), %rdi
callq 0xcec80
movq 0x58(%rsp), %rdi
callq 0xdf550
movq %rax, 0x50(%rsp)
cmpq $0x0, 0x50(%rsp)
je 0x11c740
movq 0x50(%rsp), %rdi
movq (%rdi), %rax
leaq 0x80(%rsp), %rsi
callq *0x30(%rax)
movq %rax, 0x70(%rsp)
cmpq $0x0, 0x70(%rsp)
je 0x11c73e
movq 0x70(%rsp), %rsi
leaq 0x80(%rsp), %rdi
callq 0xe2ce0
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0xdc870
jmp 0x11c776
jmp 0x11c740
movq 0x58(%rsp), %rdi
callq 0xe0c10
movl %eax, %esi
leaq 0x80(%rsp), %rdi
callq 0xdf7c0
leaq 0x80(%rsp), %rdi
callq 0xceb70
movl 0x68(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x68(%rsp)
jmp 0x11c663
movl 0x68(%rsp), %eax
cmpl 0x64(%rsp), %eax
jl 0x11c7f5
movq 0x78(%rsp), %rdi
callq 0xe10a0
movl %eax, %esi
movl 0x64(%rsp), %edx
leaq 0x80(%rsp), %rdi
callq 0xe2920
leaq 0x80(%rsp), %rdi
callq 0xceb70
movq 0x78(%rsp), %rdi
callq 0xd87a0
movq %rax, 0x48(%rsp)
cmpq $0x0, 0x48(%rsp)
je 0x11c7f3
movq 0x48(%rsp), %rdi
callq 0xe0270
cmpl $0x0, %eax
jbe 0x11c7f3
movq 0x128(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x48(%rsp), %rdi
callq 0xe0270
movq 0x10(%rsp), %rdi
movl %eax, %esi
callq 0xce880
jmp 0x11c7f5
jmp 0x11c61c
movq 0x128(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x128(%rsp), %rdi
callq 0xd2a50
movq %rax, (%rsp)
movq 0x128(%rsp), %rdi
callq 0xd1b00
movq (%rsp), %rsi
movl %eax, %edx
leaq 0x38(%rsp), %rdi
callq 0xd8150
movq 0x8(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0xd6e80
movq 0x128(%rsp), %rdi
movl $0x1, %esi
callq 0xd58a0
addq $0x138, %rsp            # imm = 0x138
retq
nop