// File: /workspace/github_cpp_makefile_star2_O2/kiudee[P]VAHD-Projekt/Node.cpp
// Function: Node::Leave()
Action Node::Leave()
{
    std::cout << num << "<-Leave();\n";
    if (leftstable && left != NULL) { //first node must be a virtual node, so it must exist
        for (HashMap::iterator it = data.begin(); it != data.end(); ++it) {
            DateObj *dob = new DateObj(it->first, it->second);
            if (left->_owner == node0->_owner) {
                //the first real node whats to leave. the left neighbor is the very first node and it is node0, which is also leaving

                SearchJob *sj = new SearchJob(MAX, INSERT,
                                              Node::calcRoutingBound(), dob, num);
                Search(sj);
            } else {
                left->out->call(Node::Insert, dob);//do not use DataInsert!
            }
        }
        data.clear();

        std::cout << "Node " << num << " is preparing to leave system.\n";
        num = num + MAX; // increase num to get to end of list
        delete in; // invalidate existing links/identities to 'in'
        in = new Relay; // create new 'in' to be used for new 'num'

        node0->out->call(Node::VirtualNodeLeave, NONE);
        node1->out->call(Node::VirtualNodeLeave, NONE);
    } else {
        call(Node::Leave, NONE);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movsd 0xb0(%rdi), %xmm0
movq 0x7ace(%rip), %rdi      # 0xffd0
callq 0x2240
leaq 0x1fe3(%rip), %rsi      # 0xa4f1
movq %rax, %rdi
callq 0x2160
cmpb $0x1, 0x60(%rbx)
jne 0x862f
cmpq $0x0, 0xc8(%rbx)
je 0x862f
leaq 0x68(%rbx), %rax
movq %rax, (%rsp)
leaq 0x78(%rbx), %rbp
leaq 0x8(%rsp), %r12
leaq 0x7c72(%rip), %r15      # 0x101b8
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x8672
pushq $0x48
popq %rdi
callq 0x2170
movq %rax, %r14
movl 0x8(%rbp), %r13d
leaq 0x10(%rbp), %rsi
movq %r12, %rdi
callq 0x21d0
movq %r14, %rdi
movl %r13d, %esi
movq %r12, %rdx
callq 0x391e
movq %r12, %rdi
callq 0x20a0
movq 0xc8(%rbx), %rax
movq 0xd8(%rbx), %rcx
movq 0x8(%rax), %rdx
cmpq 0x8(%rcx), %rdx
je 0x85eb
movq 0x28(%rax), %r13
pushq $0x38
popq %rdi
callq 0x2170
movq (%r15), %rcx
movq %rcx, (%rax)
incq %rcx
movq %rcx, (%r15)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rax)
leaq -0x146e(%rip), %rcx     # 0x7156
movq %rcx, 0x18(%rax)
andq $0x0, 0x20(%rax)
movq %r14, 0x28(%rax)
andq $0x0, 0x30(%rax)
movq (%r13), %rcx
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq *0x8(%rcx)
jmp 0x8546
pushq $0x60
popq %rdi
callq 0x2170
movq %rax, %r13
movq %rbx, %rdi
callq 0x6a96
movapd %xmm0, %xmm1
movsd 0xb0(%rbx), %xmm2
movq %r13, %rdi
movsd 0x1db3(%rip), %xmm0     # 0xa3c8
xorl %esi, %esi
movq %r14, %rdx
callq 0x9406
movq %rbx, %rdi
movq %r13, %rsi
callq 0x7228
jmp 0x8546
pushq $0x38
popq %rdi
callq 0x2170
movq %rax, %r14
leaq -0x15f(%rip), %rsi      # 0x84e2
leaq 0x7b78(%rip), %rcx      # 0x101c0
movq %rax, %rdi
xorl %edx, %edx
callq 0x3890
movq (%rbx), %rax
movq 0x48(%rax), %rax
movq %rbx, %rdi
movq %rbx, %rsi
movq %r14, %rdx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movq (%rsp), %rdi
callq 0x4444
movq 0x794e(%rip), %rdi      # 0xffd0
leaq 0x1b99(%rip), %rsi      # 0xa222
callq 0x2160
movsd 0xb0(%rbx), %xmm0
movq %rax, %rdi
callq 0x2240
leaq 0x1e58(%rip), %rsi      # 0xa4fd
movq %rax, %rdi
callq 0x2160
movsd 0xb0(%rbx), %xmm0
addsd 0x1d0b(%rip), %xmm0     # 0xa3c8
movsd %xmm0, 0xb0(%rbx)
movq 0xc0(%rbx), %r14
testq %r14, %r14
je 0x86d9
movq %r14, %rdi
callq 0x426a
pushq $0x48
popq %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x2180
movq %r15, %rdi
callq 0x2170
movq %rax, %r14
movq %rax, %rdi
callq 0x927c
movq %r14, 0xc0(%rbx)
movq 0xd8(%rbx), %rax
movq 0x28(%rax), %r15
pushq $0x38
popq %rdi
callq 0x2170
movq %rax, %r14
leaq 0x9f(%rip), %rsi        # 0x87be
leaq 0x7a9a(%rip), %rcx      # 0x101c0
movq %rax, %rdi
xorl %edx, %edx
callq 0x3890
movq (%r15), %rax
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq *0x8(%rax)
movq 0xe0(%rbx), %rax
movq 0x28(%rax), %r15
pushq $0x38
popq %rdi
callq 0x2170
movq %rax, %r14
leaq 0x62(%rip), %rsi        # 0x87be
leaq 0x7a5d(%rip), %rcx      # 0x101c0
movq %rax, %rdi
xorl %edx, %edx
callq 0x3890
movq (%r15), %rax
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq *0x8(%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8791
jmp 0x8791
jmp 0x8798
movq %rax, %rbx
pushq $0x38
jmp 0x87ac
movq %rax, %rbx
jmp 0x87aa
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x20a0
pushq $0x48
popq %rsi
movq %r14, %rdi
callq 0x2180
movq %rbx, %rdi
callq 0x2290
nop