// File: /workspace/github_cpp_makefile_star2_O1/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 0x57d3f
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 0x3ff90
movq %rax, %r14
addq $0x20, %r15
movq 0x10(%rbx), %rsi
movq %r15, %rdi
callq 0x40020
movq 0x28(%r14), %rcx
cmpq %rax, %rcx
jae 0x57ca3
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 0x57d93
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 0x41f50
movq %rbx, %rdi
testq %rax, %rax
je 0x57d1d
movq %rax, %rsi
movl %ebp, %edx
callq 0x3f5a0
jmp 0x57d27
movq %r14, %rsi
movl %ebp, %edx
callq 0x417d0
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 0x286ff(%rip), %rsi     # 0x8045b
leaq 0x28723(%rip), %rdx     # 0x80486
movq %rsp, %rdi
callq 0x3f8a0
movb $0x1, %bpl
movq %rsp, %rsi
movq %r14, %rdi
callq 0x3f890
xorl %ebp, %ebp
movq 0x4b126(%rip), %rsi     # 0xa2ea8
movq 0x4aeaf(%rip), %rdx     # 0xa2c38
movq %r14, %rdi
callq 0x41d60
jmp 0x57de5
movl $0x20, %edi
callq 0x3fb00
movq %rax, %r14
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x286d7(%rip), %rsi     # 0x80487
leaq 0x286fe(%rip), %rdx     # 0x804b5
movq %rsp, %rdi
callq 0x3f8a0
movb $0x1, %bpl
movq %rsp, %rsi
movq %r14, %rdi
callq 0x3f890
xorl %ebp, %ebp
movq 0x4b0d2(%rip), %rsi     # 0xa2ea8
movq 0x4ae5b(%rip), %rdx     # 0xa2c38
movq %r14, %rdi
callq 0x41d60
jmp 0x57de9
jmp 0x57e04
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x57e0a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x40870
jmp 0x57e0a
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x57e17
movq %r14, %rdi
callq 0x40080
movq %rbx, %rdi
callq 0x41f00
nop