// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %ebp
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdx), %rax
movsd 0x20(%rsi), %xmm0
testq %rax, %rax
je 0x8a50
movsd 0x20(%rax), %xmm1
xorl %ecx, %ecx
ucomisd %xmm1, %xmm0
seta %cl
xorl %edx, %edx
ucomisd %xmm0, %xmm1
seta %dl
testb %bpl, %bpl
cmovnel %ecx, %edx
movq 0x28(%rax), %r15
cmpb $0x1, %dl
jne 0x8a8e
pushq $0x38
popq %rdi
callq 0x2170
leaq 0x77a5(%rip), %rcx      # 0x101b8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rax)
leaq -0x243d(%rip), %rcx     # 0x65f2
movq %rcx, 0x18(%rax)
andq $0x0, 0x20(%rax)
movq %r14, 0x28(%rax)
andq $0x0, 0x30(%rax)
movq (%r15), %rcx
movq 0x8(%rcx), %rcx
movq %r15, %rdi
jmp 0x8c50
movsd 0x1970(%rip), %xmm1     # 0xa3c8
ucomisd %xmm0, %xmm1
jbe 0x8b2d
pushq $0x38
popq %rdi
callq 0x2170
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x3766
movq %r15, (%r12)
testb %bpl, %bpl
je 0x8bbc
movb $0x0, 0x61(%rbx)
jmp 0x8bc0
movq (%rbx), %rax
movq %rbx, %rdi
movq %r15, %rsi
callq *0x58(%rax)
movl %eax, %r13d
pushq $0x38
popq %rdi
callq 0x2170
movq %rax, %r15
testl %r13d, %r13d
je 0x8b46
movq (%r12), %rdx
movsd 0x20(%rdx), %xmm0
movsd %xmm0, 0x10(%rsp)
addq $0x28, %rdx
movq %rbx, %rdi
movq %rbx, %rsi
callq 0x933a
movq %rax, 0x8(%rsp)
movq (%r12), %rax
movl 0x30(%rax), %r13d
movq %r15, %rdi
callq 0x3a32
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x20(%r15)
movq 0x8(%rsp), %rax
movq %rax, 0x28(%r15)
movl %r13d, 0x30(%r15)
testb %bpl, %bpl
je 0x8b9c
cmpb $0x1, 0x61(%rbx)
jne 0x8bcf
movq (%r12), %rax
movsd 0x20(%r14), %xmm0
cmpeqsd 0x20(%rax), %xmm0
movq %xmm0, %rax
andl $0x1, %eax
jmp 0x8bd1
pushq $0x38
popq %rsi
movq %r14, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2180
leaq 0x766b(%rip), %rax      # 0x101b8
movq (%rax), %rcx
movq %rcx, (%r15)
incq %rcx
movq %rcx, (%rax)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%r15)
leaq -0x2578(%rip), %rax     # 0x65f2
movq %rax, 0x18(%r15)
andq $0x0, 0x20(%r15)
movq %r14, 0x28(%r15)
andq $0x0, 0x30(%r15)
movq (%rbx), %rax
movq 0x48(%rax), %rax
movq %rbx, %rdi
movq %rbx, %rsi
movq %r15, %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
cmpb $0x1, 0x60(%rbx)
jne 0x8bd6
movq (%r12), %rax
movsd 0x20(%r14), %xmm0
cmpeqsd 0x20(%rax), %xmm0
movq %xmm0, %rax
andl $0x1, %eax
jmp 0x8bd8
movb $0x0, 0x60(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
movb %al, 0x61(%rbx)
jmp 0x8bdb
xorl %eax, %eax
movb %al, 0x60(%rbx)
movq (%r12), %rdi
pushq $0x38
popq %r13
movq %r13, %rsi
callq 0x2180
movq %r13, %rdi
callq 0x2170
movq %rax, %r13
movq %rax, %rdi
movq %r14, %rsi
callq 0x3766
movq %r13, (%r12)
movq 0x28(%r13), %r14
pushq $0x38
popq %rdi
callq 0x2170
leaq 0x75a0(%rip), %rcx      # 0x101b8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rax)
leaq -0x2642(%rip), %rcx     # 0x65f2
movq %rcx, 0x18(%rax)
andq $0x0, 0x20(%rax)
movq %r15, 0x28(%rax)
andq $0x0, 0x30(%rax)
movq (%r14), %rcx
movq 0x8(%rcx), %rcx
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rcx
jmp 0x8c70
movq %rax, %rbx
movq %r13, %r15
jmp 0x8c73
movq %rax, %rbx
pushq $0x38
popq %rsi
movq %r15, %rdi
callq 0x2180
movq %rbx, %rdi
callq 0x2290