// File: /workspace/github_cpp_makefile_star2_O1/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 $0x28, %rsp
movl %ecx, %ebp
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdx), %rax
movsd 0x20(%rsi), %xmm0
testq %rax, %rax
je 0xb938
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 0xb978
movl $0x38, %edi
callq 0x3160
leaq 0x68ad(%rip), %rcx      # 0x121a8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rax)
leaq -0x3507(%rip), %rcx     # 0x8410
movq %rcx, 0x18(%rax)
xorl %ecx, %ecx
movq %rcx, 0x20(%rax)
movq %r14, 0x28(%rax)
movq %rcx, 0x30(%rax)
movq (%r15), %rcx
movq 0x8(%rcx), %rcx
movq %r15, %rdi
jmp 0xbb9a
movsd 0x1a80(%rip), %xmm1     # 0xd3c0
ucomisd %xmm0, %xmm1
jbe 0xba6d
movl $0x38, %edi
callq 0x3160
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x4dae
movq %r15, (%r12)
testb %bpl, %bpl
je 0xbb03
movb $0x0, 0x61(%rbx)
jmp 0xbb07
movq (%rbx), %rax
movq %rbx, %rdi
movq %r15, %rsi
callq *0x58(%rax)
movl %eax, %r13d
movl $0x38, %edi
callq 0x3160
movq %rax, %r15
testl %r13d, %r13d
je 0xba91
movq (%r12), %rax
movq %rax, 0x10(%rsp)
movsd 0x20(%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x67e8(%rip), %rax      # 0x121a0
movq (%rax), %r13
testq %r13, %r13
je 0xb9e6
cmpq $0x0, 0x10(%rbx)
jne 0xb9ce
cmpq $0x0, 0x8(%rbx)
jne 0xb9e6
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rax
testq %rax, %rax
je 0xb9e6
cmpq %rbx, 0x18(%rax)
je 0xbbb0
xorl %esi, %esi
movq (%r12), %rdi
movl 0x30(%rdi), %eax
leaq 0x6792(%rip), %rcx      # 0x12188
movq (%rcx), %rdx
movq %rdx, (%r15)
incq %rdx
movq %rdx, (%rcx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%r15)
movq $0x0, 0x18(%r15)
leaq 0x6785(%rip), %rcx      # 0x121a0
movq (%rcx), %rcx
testq %rcx, %rcx
je 0xba2d
movq %r15, %rdx
addq $0x8, %rdx
movq %rcx, (%rdx)
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x20(%r15)
movq %rsi, 0x28(%r15)
movl %eax, 0x30(%r15)
testb %bpl, %bpl
je 0xbae7
cmpb $0x1, 0x61(%rbx)
jne 0xbb16
movsd 0x20(%r14), %xmm0
cmpeqsd 0x20(%rdi), %xmm0
movq %xmm0, %rax
andl $0x1, %eax
jmp 0xbb18
testq %r14, %r14
je 0xbb07
movl $0x38, %esi
movq %r14, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3170
leaq 0x6710(%rip), %rax      # 0x121a8
movq (%rax), %rcx
movq %rcx, (%r15)
incq %rcx
movq %rcx, (%rax)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%r15)
leaq -0x36a5(%rip), %rax     # 0x8410
movq %rax, 0x18(%r15)
xorl %eax, %eax
movq %rax, 0x20(%r15)
movq %r14, 0x28(%r15)
movq %rax, 0x30(%r15)
movq (%rbx), %rax
movq 0x48(%rax), %rax
movq %rbx, %rdi
movq %rbx, %rsi
movq %r15, %rdx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
cmpb $0x1, 0x60(%rbx)
jne 0xbb1d
movsd 0x20(%r14), %xmm0
cmpeqsd 0x20(%rdi), %xmm0
movq %xmm0, %rax
andl $0x1, %eax
jmp 0xbb1f
movb $0x0, 0x60(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
movb %al, 0x61(%rbx)
jmp 0xbb22
xorl %eax, %eax
movb %al, 0x60(%rbx)
testq %rdi, %rdi
je 0xbb31
movl $0x38, %esi
callq 0x3170
movl $0x38, %edi
callq 0x3160
movq %rax, %r13
movq %rax, %rdi
movq %r14, %rsi
callq 0x4dae
movq %r13, (%r12)
movq 0x28(%r13), %r14
movl $0x38, %edi
callq 0x3160
leaq 0x6646(%rip), %rcx      # 0x121a8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rax)
leaq -0x376e(%rip), %rcx     # 0x8410
movq %rcx, 0x18(%rax)
xorl %ecx, %ecx
movq %rcx, 0x20(%rax)
movq %r15, 0x28(%rax)
movq %rcx, 0x30(%rax)
movq (%r14), %rcx
movq 0x8(%rcx), %rcx
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rcx
movq %rax, 0x18(%rsp)
movl $0x28, %edi
callq 0x3160
movq %rax, 0x8(%rsp)
leaq 0x65bd(%rip), %rax      # 0x12188
movq (%rax), %rcx
movq 0x8(%rsp), %rdx
movq %rcx, (%rdx)
incq %rcx
movq %rcx, (%rax)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rdx)
movupd %xmm0, 0x18(%rdx)
movq %r13, 0x8(%rdx)
movupd %xmm0, 0x10(%rdx)
movq 0x18(%rsp), %rax
movq 0x28(%rax), %r13
movq %r13, 0x10(%rdx)
cmpl $0x0, 0x14(%rax)
je 0xbc0c
movq 0x20(%rbx), %rax
jmp 0xbc0e
xorl %eax, %eax
movq 0x8(%rsp), %rcx
movq %rax, 0x18(%rcx)
movq 0x18(%rsp), %rax
movq 0x30(%rax), %rax
movq %rax, 0x20(%rcx)
testq %r13, %r13
je 0xbc5f
movl $0x18, %edi
callq 0x3160
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
movq 0x8(%rsp), %rcx
movq %rcx, 0x10(%rax)
movq 0x40(%r13), %rcx
movq 0x8(%rcx), %rdx
testq %rdx, %rdx
je 0xbc54
movq %rax, (%rdx)
movq %rdx, 0x8(%rax)
movq %rcx, (%rax)
movq %rax, 0x8(%rcx)
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movq 0x10(%rsp), %rax
movq $0x0, 0x28(%rax)
movq 0x8(%rsp), %rsi
jmp 0xb9e8
jmp 0xbc87
movq %rax, %rbx
jmp 0xbc92
movq %rax, %rbx
movq %r13, %r15
movl $0x38, %esi
movq %r15, %rdi
callq 0x3170
movq %rbx, %rdi
callq 0x3280
nop