// File: /workspace/github_cpp_makefile_star2_O3/jstaursky[P]hutch/src/Sleigh/sleigh.cc
// Function: SleighBuilder::appendCrossBuild(OpTpl*, int)
void SleighBuilder::appendCrossBuild (OpTpl* bld, int4 secnum)

{ // Weave in the p-code section from an instruction at another address
    // bld-param(0) contains the address of the instruction
    // bld-param(1) contains the section number
    if (secnum >= 0)
        throw LowlevelError ("CROSSBUILD directive within a named section");
    secnum = bld->getIn (1)->getOffset ().getReal ();
    VarnodeTpl* vn = bld->getIn (0);
    AddrSpace* spc = vn->getSpace ().fixSpace (*walker);
    uintb addr = spc->wrapOffset (vn->getOffset ().fix (*walker));

    ParserWalker* tmp = walker;
    uintb olduniqueoffset = uniqueoffset;

    Address newaddr (spc, addr);
    setUniqueOffset (newaddr);
    const ParserContext* pos = discache->getParserContext (newaddr);
    if (pos->getParserState () != ParserContext::pcode)
        throw LowlevelError ("Could not obtain cached crossbuild instruction");

    ParserWalker newwalker (pos, tmp->getParserContext ());
    walker = &newwalker;

    walker->baseState ();
    Constructor* ct = walker->getConstructor ();
    ConstructTpl* construct = ct->getNamedTempl (secnum);
    if (construct == (ConstructTpl*)0)
        buildEmpty (ct, secnum);
    else
        build (construct, secnum);
    walker = tmp;
    uniqueoffset = olduniqueoffset;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xb0, %rsp
testl %edx, %edx
jns 0x57a73
movq %rdi, %rbx
movq 0x10(%rsi), %rax
movq (%rax), %r15
movq 0x8(%rax), %rax
movl 0x30(%rax), %ebp
movq 0x10(%rdi), %rsi
movq %r15, %rdi
callq 0x3ffa0
movq %rax, %r14
addq $0x20, %r15
movq 0x10(%rbx), %rsi
movq %r15, %rdi
callq 0x40030
movq 0x28(%r14), %rcx
cmpq %rax, %rcx
jae 0x579d7
incq %rcx
cqto
idivq %rcx
movq %rdx, %rax
sarq $0x3f, %rax
andq %rcx, %rax
addq %rdx, %rax
movq 0x10(%rbx), %r15
movq 0x30(%rbx), %r12
leaq 0xa0(%rsp), %rsi
movq %r14, (%rsi)
movq %rax, 0x8(%rsi)
andq 0x28(%rbx), %rax
shlq $0x4, %rax
movq %rax, 0x30(%rbx)
movq 0x38(%rbx), %rdi
callq 0x3fd60
cmpl $0x2, (%rax)
jne 0x57ac7
movq (%r15), %rcx
movq %rsp, %rdx
movq %rax, (%rdx)
movq %rcx, 0x8(%rdx)
movq %rdx, 0x10(%rbx)
movq 0x98(%rax), %rax
movq %rax, 0x10(%rdx)
movq $0x0, 0x18(%rdx)
movq (%rax), %r14
movq %r14, %rdi
movl %ebp, %esi
callq 0x41f60
movq %rbx, %rdi
testq %rax, %rax
je 0x57a51
movq %rax, %rsi
movl %ebp, %edx
callq 0x3f5a0
jmp 0x57a5b
movq %r14, %rsi
movl %ebp, %edx
callq 0x417e0
movq %r15, 0x10(%rbx)
movq %r12, 0x30(%rbx)
addq $0xb0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x20, %edi
callq 0x3fb00
movq %rax, %r14
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x289cb(%rip), %rsi     # 0x8045b
leaq 0x289ef(%rip), %rdx     # 0x80486
movq %rsp, %rdi
callq 0x3f8a0
movb $0x1, %bpl
movq %rsp, %rsi
movq %r14, %rdi
callq 0x3f890
xorl %ebp, %ebp
movq 0x4b3f2(%rip), %rsi     # 0xa2ea8
movq 0x4b17b(%rip), %rdx     # 0xa2c38
movq %r14, %rdi
callq 0x41d70
jmp 0x57b19
movl $0x20, %edi
callq 0x3fb00
movq %rax, %r14
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x289a3(%rip), %rsi     # 0x80487
leaq 0x289ca(%rip), %rdx     # 0x804b5
movq %rsp, %rdi
callq 0x3f8a0
movb $0x1, %bpl
movq %rsp, %rsi
movq %r14, %rdi
callq 0x3f890
xorl %ebp, %ebp
movq 0x4b39e(%rip), %rsi     # 0xa2ea8
movq 0x4b127(%rip), %rdx     # 0xa2c38
movq %r14, %rdi
callq 0x41d70
jmp 0x57b1d
jmp 0x57b3d
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x57b36
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x40880
testb %bpl, %bpl
jne 0x57b40
jmp 0x57b48
movq %rax, %rbx
movq %r14, %rdi
callq 0x40090
movq %rbx, %rdi
callq 0x41f10