// File: /workspace/github_cpp_makefile_star2_O3/kiudee[P]VAHD-Projekt/Node.cpp
// Function: Node::BuildList(IdObj*)
Action Node::BuildList(IdObj *ido)
{

    IdObj *tempido;
    // Check if there are dead links from both sides:
    //   -> Delete if dead.
    checkDead(&left, false);
    checkDead(&right, true);

    // Check if both links are still valid:
    //   -> Call BuildDeBruijn if not.
    checkValid();

    if (ido != NULL && isSelf(ido)) {
        //delete ido;
        return;
    }

    if (ido == NULL) {
        // timeout: ask neighbors to create return links
        if (left != NULL) {
            tempido = new IdObj(num, new Identity(in), _debugID);
            left->out->call(Node::BuildList, tempido);
        }
        if (right != NULL) {
            tempido = new IdObj(num, new Identity(in), _debugID);
            right->out->call(Node::BuildList, tempido);
        }
        if (right == NULL && num > MAX && idle(in)) {
            if (isReal) {
                if (node0left && node1left) {
                    DoubleObj *dob = new DoubleObj(num - MAX);
                    parent->call(Supervisor::RemoveRealChild, dob);
                } else {
                    call(Node::BuildList, ido);
                }
            } else {
                std::cout << "Node " << (num - MAX) << " leaves. Ciao.\n";
                DoubleObj *obj = new DoubleObj(num - MAX);
                parent->call(Node::RemoveVirtualChild, obj);
            }
        } else {
            // prepare next timeout
            NumObj *counter = new NumObj(5);
            call(Node::Wakeup, counter);
        }
    } else {
        checkStable(ido->num);
        if (ido->num > num) {
            BuildSide(ido, &right, true);
        } else if (ido->num < num) { // ido->num <= num
            BuildSide(ido, &left, false);
        } else if (isReal) { // prioritize real nodes
            BuildSide(ido, &left, false);
        } else {
            BuildSide(ido, &right, true);
        }
    }

    /*
    if(isReal)
        std::cout << "REAL";
    else
        std::cout << "VIRTUAL";


    std::cout << "\tNode: " << num << " " << _debugID;

    if (left == NULL) {
        //std::cout << "\tLeft: NULL";
    } else {
        //std::cout << "\tLeft: " << left->num << " " << left->_debugID;
    }

    if (right == NULL) {
        //std::cout << "\tRight: NULL";
    } else {
        //std::cout << "\tRight: " << right->num << " " << right->_debugID;
    }

    //std::cout << "\n";
     */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0xc8(%rdi), %r12
movq %r12, %rsi
xorl %edx, %edx
callq 0x6f1e
leaq 0xd0(%rbx), %r15
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x6f1e
movq %rbx, %rdi
callq 0x6f92
testq %r14, %r14
je 0x73cf
movq %rbx, %rdi
movq %r14, %rsi
callq 0xace6
testb %al, %al
je 0x74cf
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r12), %rax
testq %rax, %rax
je 0x75d8
movq %rax, 0x8(%rsp)
movl $0x38, %edi
callq 0x2160
movq %rax, %r14
movsd 0xb0(%rbx), %xmm0
movsd %xmm0, 0x18(%rsp)
movl $0x28, %edi
callq 0x2160
movq %rax, %r12
movq 0xc0(%rbx), %rax
leaq 0x9d71(%rip), %rcx      # 0x11188
movq (%rcx), %rbp
movq %rbp, (%r12)
leaq 0x1(%rbp), %rdx
movq %rdx, (%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r12)
movq $0x0, 0x18(%r12)
leaq 0x9d62(%rip), %rsi      # 0x111a0
movq (%rsi), %r13
testq %r13, %r13
je 0x752e
movq %r13, 0x8(%r12)
movups %xmm0, 0x10(%r12)
movq $0x0, 0x20(%r12)
testq %rax, %rax
je 0x7540
cmpq %r13, 0x18(%rax)
jne 0x7540
movq %rdx, 0x10(%rsp)
movq %rax, 0x10(%r12)
movq %rax, 0x20(%rsp)
movq 0x30(%rax), %rax
movq %rax, 0x20(%r12)
movl $0x18, %edi
callq 0x2160
movq %r12, 0x10(%rax)
movq 0x20(%rsp), %rcx
movq 0x40(%rcx), %rcx
movq 0x8(%rcx), %rdx
testq %rdx, %rdx
leaq 0x9cf2(%rip), %rsi      # 0x111a0
je 0x74b6
movq %rax, (%rdx)
movq (%rsi), %r13
movq %rdx, 0x8(%rax)
movq %rcx, (%rax)
movq %rax, 0x8(%rcx)
leaq 0x9cc0(%rip), %rcx      # 0x11188
movq 0x10(%rsp), %rdx
jmp 0x7540
movsd 0x20(%r14), %xmm0
movq %rbx, %rdi
callq 0xa738
movsd 0x20(%r14), %xmm0
movsd 0xb0(%rbx), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x7501
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movl $0x1, %ecx
jmp 0x751b
ucomisd %xmm0, %xmm1
ja 0x7510
cmpb $0x1, 0xb8(%rbx)
jne 0x74f1
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa8d6
movups %xmm0, 0x10(%r12)
movq $0x0, 0x20(%r12)
xorl %r13d, %r13d
movl 0x8(%rbx), %eax
movq %rdx, (%r14)
addq $0x2, %rbp
movq %rbp, (%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r14)
movq $0x0, 0x18(%r14)
testq %r13, %r13
je 0x756c
movq %r14, %rcx
addq $0x8, %rcx
movq %r13, (%rcx)
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x20(%r14)
movq %r12, 0x28(%r14)
movl %eax, 0x30(%r14)
movq 0x8(%rsp), %rax
movq 0x28(%rax), %r12
movl $0x38, %edi
callq 0x2160
leaq 0x9c0e(%rip), %rcx      # 0x111a8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rax)
leaq -0x252(%rip), %rcx      # 0x7364
movq %rcx, 0x18(%rax)
xorl %ecx, %ecx
movq %rcx, 0x20(%rax)
movq %r14, 0x28(%rax)
movq %rcx, 0x30(%rax)
movq (%r12), %rcx
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq *0x8(%rcx)
movq (%r15), %rax
testq %rax, %rax
je 0x7775
movq %rax, 0x8(%rsp)
movl $0x38, %edi
callq 0x2160
movq %rax, %r14
movsd 0xb0(%rbx), %xmm0
movsd %xmm0, 0x18(%rsp)
movl $0x28, %edi
callq 0x2160
movq %rax, %r15
movq 0xc0(%rbx), %r12
leaq 0x9b69(%rip), %rcx      # 0x11188
movq (%rcx), %rbp
movq %rbp, (%rax)
leaq 0x1(%rbp), %rsi
movq %rsi, (%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
movq $0x0, 0x18(%rax)
leaq 0x9b5e(%rip), %rax      # 0x111a0
movq (%rax), %r13
testq %r13, %r13
je 0x76c0
movq %r13, 0x8(%r15)
movups %xmm0, 0x10(%r15)
movq $0x0, 0x20(%r15)
testq %r12, %r12
je 0x76d0
cmpq %r13, 0x18(%r12)
jne 0x76d0
movq %rsi, 0x10(%rsp)
movq %r12, 0x10(%r15)
movq 0x30(%r12), %rax
movq %rax, 0x20(%r15)
movl $0x18, %edi
callq 0x2160
movq %r15, 0x10(%rax)
movq 0x40(%r12), %rcx
movq 0x8(%rcx), %rdx
testq %rdx, %rdx
movq 0x10(%rsp), %rsi
je 0x76a7
movq %rax, (%rdx)
leaq 0x9afc(%rip), %rdi      # 0x111a0
movq (%rdi), %r13
movq %rdx, 0x8(%rax)
movq %rcx, (%rax)
movq %rax, 0x8(%rcx)
movq 0x8(%rsp), %rdx
leaq 0x9aca(%rip), %rcx      # 0x11188
jmp 0x76d5
movups %xmm0, 0x10(%r15)
movq $0x0, 0x20(%r15)
xorl %r13d, %r13d
movq 0x8(%rsp), %rdx
movl 0x8(%rbx), %eax
movq %rsi, (%r14)
addq $0x2, %rbp
movq %rbp, (%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r14)
movq $0x0, 0x18(%r14)
testq %r13, %r13
je 0x7701
movq %r14, %rcx
addq $0x8, %rcx
movq %r13, (%rcx)
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x20(%r14)
movq %r15, 0x28(%r14)
movl %eax, 0x30(%r14)
movq 0x28(%rdx), %r15
movl $0x38, %edi
callq 0x2160
leaq 0x9a7e(%rip), %rcx      # 0x111a8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rax)
leaq -0x3e2(%rip), %rcx      # 0x7364
movq %rcx, 0x18(%rax)
xorl %r12d, %r12d
movq %r12, 0x20(%rax)
movq %r14, 0x28(%rax)
movq %r12, 0x30(%rax)
movq (%r15), %rcx
movq %r15, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq *0x8(%rcx)
cmpq %r12, 0xd0(%rbx)
jne 0x7859
movsd 0xb0(%rbx), %xmm0
ucomisd 0x4c3b(%rip), %xmm0     # 0xc3c0
jbe 0x7859
movq (%rbx), %rax
movq 0xc0(%rbx), %rsi
movq %rbx, %rdi
callq *0x58(%rax)
testl %eax, %eax
je 0x7859
cmpb $0x1, 0xb8(%rbx)
jne 0x790b
cmpb $0x1, 0x62(%rbx)
jne 0x7a03
cmpb $0x1, 0x63(%rbx)
jne 0x7a03
movl $0x28, %edi
callq 0x2160
movsd 0xb0(%rbx), %xmm0
addsd 0x4bea(%rip), %xmm0     # 0xc3c8
movq %rax, %r14
leaq 0x99a0(%rip), %rax      # 0x11188
movq (%rax), %rcx
movq %rcx, (%r14)
incq %rcx
movq %rcx, (%rax)
xorps %xmm1, %xmm1
movups %xmm1, 0x8(%r14)
movq $0x0, 0x18(%r14)
leaq 0x9995(%rip), %rax      # 0x111a0
movq (%rax), %rax
testq %rax, %rax
je 0x781d
movq %r14, %rcx
addq $0x8, %rcx
movq %rax, (%rcx)
movsd %xmm0, 0x20(%r14)
movq 0x28(%rbx), %r15
movl $0x38, %edi
callq 0x2160
leaq 0x9970(%rip), %rcx      # 0x111a8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rax)
leaq -0x3cdc(%rip), %rcx     # 0x3b78
jmp 0x79e2
movl $0x28, %edi
callq 0x2160
movq %rax, %r14
leaq 0x991b(%rip), %rax      # 0x11188
movq (%rax), %rcx
movq %rcx, (%r14)
incq %rcx
movq %rcx, (%rax)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%r14)
movq $0x0, 0x18(%r14)
leaq 0x990e(%rip), %rax      # 0x111a0
movq (%rax), %rax
testq %rax, %rax
je 0x78a4
movq %r14, %rcx
addq $0x8, %rcx
movq %rax, (%rcx)
movl $0x5, 0x20(%r14)
movl $0x38, %edi
callq 0x2160
leaq 0x98eb(%rip), %rcx      # 0x111a8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rax)
leaq -0xa59(%rip), %rcx      # 0x6e80
movq %rcx, 0x18(%rax)
xorl %ecx, %ecx
movq %rcx, 0x20(%rax)
movq %r14, 0x28(%rax)
movq %rcx, 0x30(%rax)
movq (%rbx), %rcx
movq 0x48(%rcx), %rcx
movq %rbx, %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 0x96be(%rip), %r14      # 0x10fd0
leaq 0x4909(%rip), %rsi      # 0xc222
movl $0x5, %edx
movq %r14, %rdi
callq 0x21a0
movsd 0xb0(%rbx), %xmm0
addsd 0x4a92(%rip), %xmm0     # 0xc3c8
movq %r14, %rdi
callq 0x2230
leaq 0x48e3(%rip), %rsi      # 0xc228
movl $0xf, %edx
movq %rax, %rdi
callq 0x21a0
movl $0x28, %edi
callq 0x2160
movsd 0x4a64(%rip), %xmm0     # 0xc3c8
addsd 0xb0(%rbx), %xmm0
movq %rax, %r14
leaq 0x9812(%rip), %rax      # 0x11188
movq (%rax), %rcx
movq %rcx, (%r14)
incq %rcx
movq %rcx, (%rax)
xorps %xmm1, %xmm1
movups %xmm1, 0x8(%r14)
movq $0x0, 0x18(%r14)
leaq 0x9807(%rip), %rax      # 0x111a0
movq (%rax), %rax
testq %rax, %rax
je 0x79ab
movq %r14, %rcx
addq $0x8, %rcx
movq %rax, (%rcx)
movsd %xmm0, 0x20(%r14)
movq 0x28(%rbx), %r15
movl $0x38, %edi
callq 0x2160
leaq 0x97e2(%rip), %rcx      # 0x111a8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rax)
leaq 0x3658(%rip), %rcx      # 0xb03a
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 0x78f5
movl $0x38, %edi
callq 0x2160
leaq 0x9794(%rip), %rcx      # 0x111a8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rax)
leaq -0x6cc(%rip), %rcx      # 0x7364
movq %rcx, 0x18(%rax)
movupd %xmm0, 0x20(%rax)
movq $0x0, 0x30(%rax)
jmp 0x78eb
movq %rax, %rbx
movl $0x28, %esi
movq %r15, %rdi
jmp 0x7a5e
movq %rax, %rbx
movl $0x28, %esi
movq %r12, %rdi
callq 0x2170
jmp 0x7a6a
jmp 0x7a67
movq %rax, %rbx
movl $0x38, %esi
movq %r14, %rdi
callq 0x2170
movq %rbx, %rdi
callq 0x2280
nop