// File: kiudee[P]VAHD-Projekt/Node.cpp
// Function: Node::doListHop(SearchJob*)
void Node::doListHop(SearchJob *sj)
{
    double hashedkey = sj->sid;
    if (left == NULL && right == NULL) {
        //std::cout << "SearchJob " << sj->sid << " waiting at " << num << " (3)\n";
        call(Node::Search, sj);//because of virtual nodes, every node will eventually have at least one neighbor
        return;
    }
    //do normal routing if possible
    if (hashedkey < num) {
        if (left == NULL) {
            delegateSearchJobToLastNode(sj);
            return;
        } else if (leftstable) {
            sj->round++;
            sj->hopcount++;
            if (sj->type == LOOKUP || sj->type == INSERT || sj->type == DELETE) {
                std::cout << "(" << sj->_debugID << ") " << num << "<-doListHop(" <<  sj->sid << ") to left \n";
            }
            left->out->call(Node::Search, sj);
            return;
        } else {
            //std::cout << "SearchJob " << sj->sid << " waiting at " << num << " (4)\n";
            call(Node::Search, sj);
            return;
        }
    } else if (hashedkey >= num) {//find the right end of a sequence of nodes with the same id
        if (rightstable) {//at this point right must be !=NULL, otherwise we would not reach this point
            sj->round++;
            sj->hopcount++;
            if (sj->type == LOOKUP || sj->type == INSERT || sj->type == DELETE) {
                std::cout << "(" << sj->_debugID << ") " << num << "<-doListHop(" <<  sj->sid << ") to right \n";
            }
            right->out->call(Node::Search, sj);
            return;
        } else {
            //std::cout << "SearchJob " << sj->sid << " waiting at " << num << " (5)\n";
            call(Node::Search, sj);
            return;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rcx
movsd 0x20(%rcx), %xmm0
movsd %xmm0, -0x18(%rbp)
cmpq $0x0, 0xc8(%rax)
jne 0x1337d
movq -0x80(%rbp), %rax
cmpq $0x0, 0xd0(%rax)
jne 0x1337d
movl $0x38, %edi
callq 0x31c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x88(%rbp)
leaq -0x1aa3(%rip), %rax     # 0x11880
movq %rax, -0x28(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
leaq -0x10(%rbp), %rcx
callq 0x5ae0
jmp 0x13342
movq -0x88(%rbp), %rdx
movq -0x80(%rbp), %rsi
movq (%rsi), %rax
movq %rsi, %rdi
callq *0x48(%rax)
jmp 0x13750
movq -0x88(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
movl $0x38, %esi
callq 0x31d0
jmp 0x13759
movq -0x80(%rbp), %rax
movsd -0x18(%rbp), %xmm1
movsd 0xb0(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1357c
movq -0x80(%rbp), %rax
cmpq $0x0, 0xc8(%rax)
jne 0x133b8
movq -0x80(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x12e70
jmp 0x13750
movq -0x80(%rbp), %rax
testb $0x1, 0x60(%rax)
je 0x13504
movq -0x10(%rbp), %rax
movl 0x48(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x48(%rax)
movq -0x10(%rbp), %rax
movl 0x4c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x4c(%rax)
movq -0x10(%rbp), %rax
cmpl $0x2, 0x38(%rax)
je 0x133fe
movq -0x10(%rbp), %rax
cmpl $0x0, 0x38(%rax)
je 0x133fe
movq -0x10(%rbp), %rax
cmpl $0x1, 0x38(%rax)
jne 0x13472
movq 0xdbcb(%rip), %rdi      # 0x20fd0
leaq 0x40a1(%rip), %rsi      # 0x174ad
callq 0x31b0
movq %rax, %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x3060
movq %rax, %rdi
leaq 0x405c(%rip), %rsi      # 0x17486
callq 0x31b0
movq %rax, %rdi
movq -0x80(%rbp), %rax
movsd 0xb0(%rax), %xmm0
callq 0x3370
movq %rax, %rdi
leaq 0x40a3(%rip), %rsi      # 0x174f0
callq 0x31b0
movq %rax, %rdi
movq -0x10(%rbp), %rax
movsd 0x20(%rax), %xmm0
callq 0x3370
movq %rax, %rdi
leaq 0x4090(%rip), %rsi      # 0x174fd
callq 0x31b0
movq -0x80(%rbp), %rax
movq 0xc8(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0x98(%rbp)
movl $0x38, %edi
callq 0x31c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x90(%rbp)
leaq -0x1c26(%rip), %rax     # 0x11880
movq %rax, -0x48(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
leaq -0x10(%rbp), %rcx
callq 0x5ae0
jmp 0x134c5
movq -0x90(%rbp), %rdx
movq -0x80(%rbp), %rsi
movq -0x98(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x13750
movq -0x90(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
movl $0x38, %esi
callq 0x31d0
jmp 0x13759
movl $0x38, %edi
callq 0x31c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xa0(%rbp)
leaq -0x1ca2(%rip), %rax     # 0x11880
movq %rax, -0x58(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
leaq -0x10(%rbp), %rcx
callq 0x5ae0
jmp 0x13541
movq -0xa0(%rbp), %rdx
movq -0x80(%rbp), %rsi
movq (%rsi), %rax
movq %rsi, %rdi
callq *0x48(%rax)
jmp 0x13750
movq -0xa0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
movl $0x38, %esi
callq 0x31d0
jmp 0x13759
movq -0x80(%rbp), %rax
movsd -0x18(%rbp), %xmm0
ucomisd 0xb0(%rax), %xmm0
jb 0x1374e
movq -0x80(%rbp), %rax
testb $0x1, 0x61(%rax)
je 0x136dc
movq -0x10(%rbp), %rax
movl 0x48(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x48(%rax)
movq -0x10(%rbp), %rax
movl 0x4c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x4c(%rax)
movq -0x10(%rbp), %rax
cmpl $0x2, 0x38(%rax)
je 0x135d9
movq -0x10(%rbp), %rax
cmpl $0x0, 0x38(%rax)
je 0x135d9
movq -0x10(%rbp), %rax
cmpl $0x1, 0x38(%rax)
jne 0x1364d
movq 0xd9f0(%rip), %rdi      # 0x20fd0
leaq 0x3ec6(%rip), %rsi      # 0x174ad
callq 0x31b0
movq %rax, %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x3060
movq %rax, %rdi
leaq 0x3e81(%rip), %rsi      # 0x17486
callq 0x31b0
movq %rax, %rdi
movq -0x80(%rbp), %rax
movsd 0xb0(%rax), %xmm0
callq 0x3370
movq %rax, %rdi
leaq 0x3ec8(%rip), %rsi      # 0x174f0
callq 0x31b0
movq %rax, %rdi
movq -0x10(%rbp), %rax
movsd 0x20(%rax), %xmm0
callq 0x3370
movq %rax, %rdi
leaq 0x3ec1(%rip), %rsi      # 0x17509
callq 0x31b0
movq -0x80(%rbp), %rax
movq 0xd0(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0xb0(%rbp)
movl $0x38, %edi
callq 0x31c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xa8(%rbp)
leaq -0x1e01(%rip), %rax     # 0x11880
movq %rax, -0x68(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
leaq -0x10(%rbp), %rcx
callq 0x5ae0
jmp 0x136a0
movq -0xa8(%rbp), %rdx
movq -0x80(%rbp), %rsi
movq -0xb0(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x13750
movq -0xa8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
movl $0x38, %esi
callq 0x31d0
jmp 0x13759
movl $0x38, %edi
callq 0x31c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xb8(%rbp)
leaq -0x1e7a(%rip), %rax     # 0x11880
movq %rax, -0x78(%rbp)
movq $0x0, -0x70(%rbp)
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
leaq -0x10(%rbp), %rcx
callq 0x5ae0
jmp 0x13719
movq -0xb8(%rbp), %rdx
movq -0x80(%rbp), %rsi
movq (%rsi), %rax
movq %rsi, %rdi
callq *0x48(%rax)
jmp 0x13750
movq -0xb8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
movl $0x38, %esi
callq 0x31d0
jmp 0x13759
jmp 0x13750
addq $0xc0, %rsp
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x3330
nopw %cs:(%rax,%rax)