// File: 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
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa0(%rbp)
movsd 0xb0(%rax), %xmm0
movq 0xd547(%rip), %rdi      # 0x20fd0
callq 0x3370
movq %rax, %rdi
leaq 0x3aa9(%rip), %rsi      # 0x17541
callq 0x31b0
movq -0xa0(%rbp), %rax
testb $0x1, 0x60(%rax)
je 0x13f3a
movq -0xa0(%rbp), %rax
cmpq $0x0, 0xc8(%rax)
je 0x13f3a
movq -0xa0(%rbp), %rdi
addq $0x68, %rdi
callq 0x15b40
movq %rax, -0x10(%rbp)
movq -0xa0(%rbp), %rdi
addq $0x68, %rdi
callq 0x15ba0
movq %rax, -0x18(%rbp)
leaq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x15b70
testb $0x1, %al
jne 0x13b01
jmp 0x13d19
movl $0x48, %edi
callq 0x31c0
movq %rax, -0xb8(%rbp)
movb $0x1, -0x4d(%rbp)
leaq -0x10(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x15bd0
movq -0xb0(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0xa4(%rbp)
callq 0x15bd0
movq %rax, %rsi
addq $0x8, %rsi
leaq -0x40(%rbp), %rdi
callq 0x30c0
jmp 0x13b4c
movl -0xa4(%rbp), %esi
movq -0xb8(%rbp), %rdi
leaq -0x40(%rbp), %rdx
callq 0x5dd0
jmp 0x13b64
movb $0x0, -0x4d(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3100
movq -0xb8(%rbp), %rax
movq -0xa0(%rbp), %rcx
movq %rax, -0x20(%rbp)
movq 0xc8(%rcx), %rax
movq 0x8(%rax), %rax
movq 0xd8(%rcx), %rcx
cmpq 0x8(%rcx), %rax
jne 0x13c74
movl $0x60, %edi
callq 0x31c0
movq -0xa0(%rbp), %rdi
movq %rax, -0xc0(%rbp)
movq %rax, -0xc8(%rbp)
callq 0x102b0
movq -0xa0(%rbp), %rax
movq -0xc0(%rbp), %rdi
movaps %xmm0, %xmm1
movq -0x20(%rbp), %rdx
movsd 0xb0(%rax), %xmm2
movsd 0x3820(%rip), %xmm0     # 0x17408
xorl %esi, %esi
callq 0x15800
jmp 0x13bf1
movq -0xa0(%rbp), %rdi
movq -0xc8(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rsi
callq 0x11880
jmp 0x13d09
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x13c34
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3100
testb $0x1, -0x4d(%rbp)
jne 0x13c3c
jmp 0x13c4d
movq -0xb8(%rbp), %rdi
movl $0x48, %esi
callq 0x31d0
jmp 0x13fc7
movq -0xc8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movl $0x60, %esi
callq 0x31d0
jmp 0x13fc7
movq -0xa0(%rbp), %rax
movq 0xc8(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0xd8(%rbp)
movl $0x38, %edi
callq 0x31c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xd0(%rbp)
leaq -0x253b(%rip), %rax     # 0x11770
movq %rax, -0x68(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
leaq -0x20(%rbp), %rcx
callq 0x5ae0
jmp 0x13cca
movq -0xd0(%rbp), %rdx
movq -0xa0(%rbp), %rsi
movq -0xd8(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x13d09
movq -0xd0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movl $0x38, %esi
callq 0x31d0
jmp 0x13fc7
jmp 0x13d0b
leaq -0x10(%rbp), %rdi
callq 0x15c00
jmp 0x13ad7
movq -0xa0(%rbp), %rdi
addq $0x68, %rdi
callq 0x15c30
movq 0xd2a0(%rip), %rdi      # 0x20fd0
leaq 0x34d3(%rip), %rsi      # 0x1720a
callq 0x31b0
movq %rax, %rdi
movq -0xa0(%rbp), %rax
movsd 0xb0(%rax), %xmm0
callq 0x3370
movq %rax, %rdi
leaq 0x37f0(%rip), %rsi      # 0x1754d
callq 0x31b0
movq -0xa0(%rbp), %rax
movsd 0x3697(%rip), %xmm0     # 0x17408
addsd 0xb0(%rax), %xmm0
movsd %xmm0, 0xb0(%rax)
movq 0xc0(%rax), %rax
movq %rax, -0xe0(%rbp)
cmpq $0x0, %rax
je 0x13db2
movq -0xe0(%rbp), %rdi
callq 0x74c0
movq -0xe0(%rbp), %rdi
movl $0x48, %esi
callq 0x31d0
movl $0x48, %edi
callq 0x31c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xe8(%rbp)
callq 0x15340
jmp 0x13dd0
movq -0xa0(%rbp), %rax
movq -0xe8(%rbp), %rcx
movq %rcx, 0xc0(%rax)
movq 0xd8(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0xf8(%rbp)
movl $0x38, %edi
callq 0x31c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xf0(%rbp)
leaq 0x1bb(%rip), %rax       # 0x13fd0
movq %rax, -0x78(%rbp)
movq $0x0, -0x70(%rbp)
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
leaq 0xd3f0(%rip), %rcx      # 0x21220
callq 0x5ae0
jmp 0x13e37
movq -0xa0(%rbp), %rsi
movq -0xf0(%rbp), %rdx
movq -0xf8(%rbp), %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
callq *%rax
movq -0xa0(%rbp), %rax
movq 0xe0(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0x108(%rbp)
movl $0x38, %edi
callq 0x31c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x100(%rbp)
leaq 0x144(%rip), %rax       # 0x13fd0
movq %rax, -0x88(%rbp)
movq $0x0, -0x80(%rbp)
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rdx
leaq 0xd373(%rip), %rcx      # 0x21220
callq 0x5ae0
jmp 0x13eb4
movq -0x100(%rbp), %rdx
movq -0xa0(%rbp), %rsi
movq -0x108(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x13fbe
movq -0xe8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movl $0x48, %esi
callq 0x31d0
jmp 0x13fc7
movq -0xf0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movl $0x38, %esi
callq 0x31d0
jmp 0x13fc7
movq -0x100(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movl $0x38, %esi
callq 0x31d0
jmp 0x13fc7
movl $0x38, %edi
callq 0x31c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x110(%rbp)
leaq -0x4f8(%rip), %rax      # 0x13a60
movq %rax, -0x98(%rbp)
movq $0x0, -0x90(%rbp)
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rdx
leaq 0xd2a1(%rip), %rcx      # 0x21220
callq 0x5ae0
jmp 0x13f86
movq -0x110(%rbp), %rdx
movq -0xa0(%rbp), %rsi
movq (%rsi), %rax
movq %rsi, %rdi
callq *0x48(%rax)
jmp 0x13fbe
movq -0x110(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movl $0x38, %esi
callq 0x31d0
jmp 0x13fc7
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x3330