// File: kiudee[P]VAHD-Projekt/Node.cpp
// Function: Node::BuildSide(IdObj*, NodeRelay**, bool)
void Node::BuildSide(IdObj *ido, NodeRelay **side, bool right)
{
    auto compare = [right](double x, double y) -> bool {
        if (right) {
            return x > y;
        } else
        {
            return x < y;
        }
    };

    if (*side == NULL) { // link not yet defined
        //std::cout << "Node " << num << ": creating link to " << ido->num
        //          << ".\n";
        if (ido->num < MAX) {
            *side = new NodeRelay(ido);//do not link to leaving nodes

            if (right) {

                rightstable = false;
            } else {

                leftstable = false;
            }
        } else {
            delete ido; //ido references to a leaving node.
        }
    } else {
        if (compare(ido->num, (*side)->num)) { // ido beyond link
            //std::cout << "Node " << num << ": forwarding " << ido->num
            //          << " to " << (*side)->num << ".\n";
            (*side)->out->call(Node::BuildList, ido);
        } else {
            // ido between node and link
            if (idle((*side)->out)) {
                //std::cout << "Node " << num << ": new side " << ido->num
                //          << ", forwarding " << (*side)->num << ".\n";
                IdObj *tempido = new IdObj((*side)->num,
                                           extractIdentity((*side)->out),
                                           (*side)->debugID);

                if (right) {
                    rightstable = (rightstable && (*side)->num == ido->num);
                } else {
                    leftstable = (leftstable && (*side)->num == ido->num);
                }
                delete *side;
                (*side) = new NodeRelay(ido);
                (*side)->out->call(Node::BuildList, tempido);
            } else {
                call(Node::BuildList, ido);
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movb %cl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
movb -0x19(%rbp), %al
andb $0x1, %al
movb %al, -0x1a(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x144b5
movq -0x10(%rbp), %rax
movsd 0x2fe0(%rip), %xmm0     # 0x17408
ucomisd 0x20(%rax), %xmm0
jbe 0x14492
movl $0x38, %edi
callq 0x31c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rsi
callq 0x57f0
jmp 0x1444e
movq -0x78(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
testb $0x1, -0x19(%rbp)
je 0x14488
movq -0x70(%rbp), %rax
movb $0x0, 0x61(%rax)
jmp 0x14490
movq -0x78(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x38, %esi
callq 0x31d0
jmp 0x1482d
movq -0x70(%rbp), %rax
movb $0x0, 0x60(%rax)
jmp 0x144b0
movq -0x10(%rbp), %rax
movq %rax, -0x80(%rbp)
cmpq $0x0, %rax
je 0x144ae
movq -0x80(%rbp), %rdi
movl $0x38, %esi
callq 0x31d0
jmp 0x144b0
jmp 0x14824
movq -0x10(%rbp), %rax
movsd 0x20(%rax), %xmm0
movq -0x18(%rbp), %rax
movq (%rax), %rax
movsd 0x20(%rax), %xmm1
leaq -0x1a(%rbp), %rdi
callq 0x14840
testb $0x1, %al
jne 0x144dc
jmp 0x1456a
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0x90(%rbp)
movl $0x38, %edi
callq 0x31c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x88(%rbp)
leaq -0x4aec(%rip), %rax     # 0xfa20
movq %rax, -0x40(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0x10(%rbp), %rcx
callq 0x5ae0
jmp 0x1452b
movq -0x88(%rbp), %rdx
movq -0x70(%rbp), %rsi
movq -0x90(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x14822
movq -0x88(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x38, %esi
callq 0x31d0
jmp 0x1482d
movq -0x70(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x28(%rax), %rsi
movq (%rdi), %rax
callq *0x58(%rax)
cmpl $0x0, %eax
je 0x147ae
movl $0x38, %edi
callq 0x31c0
movq -0x70(%rbp), %rsi
movq %rax, -0xa8(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdx
movsd 0x20(%rdx), %xmm0
movsd %xmm0, -0xa0(%rbp)
addq $0x28, %rdx
movq %rsi, %rdi
callq 0x155f0
movq %rax, -0x98(%rbp)
jmp 0x145c6
movq -0x98(%rbp), %rsi
movsd -0xa0(%rbp), %xmm0
movq -0xa8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl 0x30(%rax), %edx
callq 0x15520
jmp 0x145ed
movq -0xa8(%rbp), %rax
movq %rax, -0x48(%rbp)
testb $0x1, -0x19(%rbp)
je 0x14667
movq -0x70(%rbp), %rcx
xorl %eax, %eax
testb $0x1, 0x61(%rcx)
movb %al, -0xa9(%rbp)
je 0x14633
movq -0x18(%rbp), %rax
movq (%rax), %rax
movsd 0x20(%rax), %xmm0
movq -0x10(%rbp), %rax
ucomisd 0x20(%rax), %xmm0
sete %al
setnp %cl
andb %cl, %al
movb %al, -0xa9(%rbp)
movq -0x70(%rbp), %rax
movb -0xa9(%rbp), %cl
andb $0x1, %cl
movb %cl, 0x61(%rax)
jmp 0x146ac
movq -0xa8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x38, %esi
callq 0x31d0
jmp 0x1482d
movq -0x70(%rbp), %rcx
xorl %eax, %eax
testb $0x1, 0x60(%rcx)
movb %al, -0xaa(%rbp)
je 0x1469c
movq -0x18(%rbp), %rax
movq (%rax), %rax
movsd 0x20(%rax), %xmm0
movq -0x10(%rbp), %rax
ucomisd 0x20(%rax), %xmm0
sete %al
setnp %cl
andb %cl, %al
movb %al, -0xaa(%rbp)
movq -0x70(%rbp), %rax
movb -0xaa(%rbp), %cl
andb $0x1, %cl
movb %cl, 0x60(%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xb8(%rbp)
cmpq $0x0, %rax
je 0x146d1
movq -0xb8(%rbp), %rdi
movl $0x38, %esi
callq 0x31d0
movl $0x38, %edi
callq 0x31c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rsi
callq 0x57f0
jmp 0x146f3
movq -0xc0(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0xd0(%rbp)
movl $0x38, %edi
callq 0x31c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xc8(%rbp)
leaq -0x4d11(%rip), %rax     # 0xfa20
movq %rax, -0x58(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
leaq -0x48(%rbp), %rcx
callq 0x5ae0
jmp 0x14750
movq -0xc8(%rbp), %rdx
movq -0x70(%rbp), %rsi
movq -0xd0(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x14820
movq -0xc0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x38, %esi
callq 0x31d0
jmp 0x1482d
movq -0xc8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x38, %esi
callq 0x31d0
jmp 0x1482d
movl $0x38, %edi
callq 0x31c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xd8(%rbp)
leaq -0x4dac(%rip), %rax     # 0xfa20
movq %rax, -0x68(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
leaq -0x10(%rbp), %rcx
callq 0x5ae0
jmp 0x147eb
movq -0xd8(%rbp), %rdx
movq -0x70(%rbp), %rsi
movq (%rsi), %rax
movq %rsi, %rdi
callq *0x48(%rax)
jmp 0x14820
movq -0xd8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x38, %esi
callq 0x31d0
jmp 0x1482d
jmp 0x14822
jmp 0x14824
addq $0xe0, %rsp
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x3330
nopw %cs:(%rax,%rax)