// File: /workspace/github_cpp_makefile_star2_O1/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 0x7fa6
leaq 0xd0(%rbx), %r15
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x7fa6
movq %rbx, %rdi
callq 0x8020
testq %r14, %r14
je 0x84b5
movq %rbx, %rdi
movq %r14, %rsi
callq 0xbca8
testb %al, %al
je 0x8477
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r14, %r14
je 0x84b5
movsd 0x20(%r14), %xmm0
movq %rbx, %rdi
callq 0xb680
movsd 0x20(%r14), %xmm0
movsd 0xb0(%rbx), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x8980
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movl $0x1, %ecx
jmp 0x899e
movq (%r12), %rax
testq %rax, %rax
movq %r14, 0x20(%rsp)
movq %r15, 0x18(%rsp)
je 0x8650
movq %rax, 0x10(%rsp)
movl $0x38, %edi
callq 0x3160
movq %rax, %r12
movsd 0xb0(%rbx), %xmm0
movsd %xmm0, 0x8(%rsp)
movl $0x28, %edi
callq 0x3160
movq %rax, %r13
movq 0xc0(%rbx), %rbp
leaq 0x9c81(%rip), %rsi      # 0x12188
movq (%rsi), %r14
movq %r14, (%rax)
leaq 0x1(%r14), %r15
movq %r15, (%rsi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
movq $0x0, 0x18(%rax)
leaq 0x9c76(%rip), %rdi      # 0x121a0
movq (%rdi), %rax
testq %rax, %rax
je 0x853c
movq %r13, %rcx
addq $0x8, %rcx
movq %rax, (%rcx)
testq %rax, %rax
sete %cl
testq %rbp, %rbp
sete %dl
orb %cl, %dl
movups %xmm0, 0x10(%r13)
movq $0x0, 0x20(%r13)
jne 0x85a8
cmpq %rax, 0x18(%rbp)
jne 0x85a8
movq %rbp, 0x10(%r13)
movq 0x30(%rbp), %rax
movq %rax, 0x20(%r13)
movl $0x18, %edi
callq 0x3160
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %r13, 0x10(%rax)
movq 0x40(%rbp), %rcx
movq 0x8(%rcx), %rdx
testq %rdx, %rdx
je 0x858f
movq %rax, (%rdx)
movq %rdx, 0x8(%rax)
movq %rcx, (%rax)
movq %rax, 0x8(%rcx)
leaq 0x9be7(%rip), %rsi      # 0x12188
leaq 0x9bf8(%rip), %rdi      # 0x121a0
movl 0x8(%rbx), %eax
movq %r15, (%r12)
addq $0x2, %r14
movq %r14, (%rsi)
movups %xmm0, 0x8(%r12)
movq $0x0, 0x18(%r12)
movq (%rdi), %rcx
testq %rcx, %rcx
je 0x85d7
movq %r12, %rdx
addq $0x8, %rdx
movq %rcx, (%rdx)
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x20(%r12)
movq %r13, 0x28(%r12)
movl %eax, 0x30(%r12)
movq 0x10(%rsp), %rax
movq 0x28(%rax), %r13
movl $0x38, %edi
callq 0x3160
leaq 0x9ba0(%rip), %rcx      # 0x121a8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rax)
leaq -0x214(%rip), %rcx      # 0x8410
movq %rcx, 0x18(%rax)
xorl %ecx, %ecx
movq %rcx, 0x20(%rax)
movq %r12, 0x28(%rax)
movq %rcx, 0x30(%rax)
movq (%r13), %rcx
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq *0x8(%rcx)
movq 0x20(%rsp), %r14
movq 0x18(%rsp), %r15
movq (%r15), %rax
testq %rax, %rax
je 0x87e0
movq %rax, 0x10(%rsp)
movl $0x38, %edi
callq 0x3160
movq %rax, %r12
movsd 0xb0(%rbx), %xmm0
movsd %xmm0, 0x8(%rsp)
movl $0x28, %edi
callq 0x3160
movq %rax, %r13
movq 0xc0(%rbx), %rbp
leaq 0x9af1(%rip), %rsi      # 0x12188
movq (%rsi), %r14
movq %r14, (%rax)
leaq 0x1(%r14), %r15
movq %r15, (%rsi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
movq $0x0, 0x18(%rax)
leaq 0x9ae6(%rip), %rdi      # 0x121a0
movq (%rdi), %rax
testq %rax, %rax
je 0x86cc
movq %r13, %rcx
addq $0x8, %rcx
movq %rax, (%rcx)
testq %rax, %rax
sete %cl
testq %rbp, %rbp
sete %dl
orb %cl, %dl
movups %xmm0, 0x10(%r13)
movq $0x0, 0x20(%r13)
jne 0x8738
cmpq %rax, 0x18(%rbp)
jne 0x8738
movq %rbp, 0x10(%r13)
movq 0x30(%rbp), %rax
movq %rax, 0x20(%r13)
movl $0x18, %edi
callq 0x3160
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %r13, 0x10(%rax)
movq 0x40(%rbp), %rcx
movq 0x8(%rcx), %rdx
testq %rdx, %rdx
je 0x871f
movq %rax, (%rdx)
movq %rdx, 0x8(%rax)
movq %rcx, (%rax)
movq %rax, 0x8(%rcx)
leaq 0x9a57(%rip), %rsi      # 0x12188
leaq 0x9a68(%rip), %rdi      # 0x121a0
movl 0x8(%rbx), %eax
movq %r15, (%r12)
addq $0x2, %r14
movq %r14, (%rsi)
movups %xmm0, 0x8(%r12)
movq $0x0, 0x18(%r12)
movq (%rdi), %rcx
testq %rcx, %rcx
je 0x8767
movq %r12, %rdx
addq $0x8, %rdx
movq %rcx, (%rdx)
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x20(%r12)
movq %r13, 0x28(%r12)
movl %eax, 0x30(%r12)
movq 0x10(%rsp), %rax
movq 0x28(%rax), %r13
movl $0x38, %edi
callq 0x3160
leaq 0x9a10(%rip), %rcx      # 0x121a8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rax)
leaq -0x3a4(%rip), %rcx      # 0x8410
movq %rcx, 0x18(%rax)
xorl %ecx, %ecx
movq %rcx, 0x20(%rax)
movq %r12, 0x28(%rax)
movq %rcx, 0x30(%rax)
movq (%r13), %rcx
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq *0x8(%rcx)
movq 0x20(%rsp), %r14
movq 0x18(%rsp), %r15
cmpq $0x0, (%r15)
jne 0x88ce
movsd 0xb0(%rbx), %xmm0
ucomisd 0x4bc6(%rip), %xmm0     # 0xd3c0
jbe 0x88ce
movq (%rbx), %rax
movq 0xc0(%rbx), %rsi
movq %rbx, %rdi
callq *0x58(%rax)
testl %eax, %eax
je 0x88ce
cmpb $0x1, 0xb8(%rbx)
jne 0x89b1
cmpb $0x1, 0x62(%rbx)
jne 0x8aa9
cmpb $0x1, 0x63(%rbx)
jne 0x8aa9
movl $0x28, %edi
callq 0x3160
movsd 0xb0(%rbx), %xmm0
addsd 0x4b75(%rip), %xmm0     # 0xd3c8
movq %rax, %r14
leaq 0x992b(%rip), %rax      # 0x12188
movq (%rax), %rcx
movq %rcx, (%r14)
incq %rcx
movq %rcx, (%rax)
xorps %xmm1, %xmm1
movups %xmm1, 0x8(%r14)
movq $0x0, 0x18(%r14)
leaq 0x9920(%rip), %rax      # 0x121a0
movq (%rax), %rax
testq %rax, %rax
je 0x8892
movq %r14, %rcx
addq $0x8, %rcx
movq %rax, (%rcx)
movsd %xmm0, 0x20(%r14)
movq 0x28(%rbx), %r15
movl $0x38, %edi
callq 0x3160
leaq 0x98fb(%rip), %rcx      # 0x121a8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rax)
leaq -0x3d39(%rip), %rcx     # 0x4b90
jmp 0x8a88
movl $0x28, %edi
callq 0x3160
movq %rax, %r14
leaq 0x98a6(%rip), %rax      # 0x12188
movq (%rax), %rcx
movq %rcx, (%r14)
incq %rcx
movq %rcx, (%rax)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%r14)
movq $0x0, 0x18(%r14)
leaq 0x9899(%rip), %rax      # 0x121a0
movq (%rax), %rax
testq %rax, %rax
je 0x8919
movq %r14, %rcx
addq $0x8, %rcx
movq %rax, (%rcx)
movl $0x5, 0x20(%r14)
movl $0x38, %edi
callq 0x3160
leaq 0x9876(%rip), %rcx      # 0x121a8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rax)
leaq -0xa46(%rip), %rcx      # 0x7f08
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
ucomisd %xmm0, %xmm1
ja 0x8993
cmpb $0x1, 0xb8(%rbx)
jne 0x84a2
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 0xb89a
movq 0x9618(%rip), %r14      # 0x11fd0
leaq 0x4863(%rip), %rsi      # 0xd222
movl $0x5, %edx
movq %r14, %rdi
callq 0x31a0
movsd 0xb0(%rbx), %xmm0
addsd 0x49ec(%rip), %xmm0     # 0xd3c8
movq %r14, %rdi
callq 0x3230
leaq 0x483d(%rip), %rsi      # 0xd228
movl $0xf, %edx
movq %rax, %rdi
callq 0x31a0
movl $0x28, %edi
callq 0x3160
movsd 0x49be(%rip), %xmm0     # 0xd3c8
addsd 0xb0(%rbx), %xmm0
movq %rax, %r14
leaq 0x976c(%rip), %rax      # 0x12188
movq (%rax), %rcx
movq %rcx, (%r14)
incq %rcx
movq %rcx, (%rax)
xorps %xmm1, %xmm1
movups %xmm1, 0x8(%r14)
movq $0x0, 0x18(%r14)
leaq 0x9761(%rip), %rax      # 0x121a0
movq (%rax), %rax
testq %rax, %rax
je 0x8a51
movq %r14, %rcx
addq $0x8, %rcx
movq %rax, (%rcx)
movsd %xmm0, 0x20(%r14)
movq 0x28(%rbx), %r15
movl $0x38, %edi
callq 0x3160
leaq 0x973c(%rip), %rcx      # 0x121a8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rax)
leaq 0x355a(%rip), %rcx      # 0xbfe2
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 0x896a
movl $0x38, %edi
callq 0x3160
leaq 0x96ee(%rip), %rcx      # 0x121a8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rax)
leaq -0x6c6(%rip), %rcx      # 0x8410
jmp 0x894e
jmp 0x8add
movq %rax, %rbx
movl $0x28, %esi
movq %r13, %rdi
callq 0x3170
jmp 0x8af4
jmp 0x8af1
movq %rax, %rbx
movl $0x38, %esi
movq %r12, %rdi
callq 0x3170
movq %rbx, %rdi
callq 0x3280
nop