// File: /workspace/github_cpp_makefile_star2_O2/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 %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movq 0xc8(%rdi), %rax
movq 0xd0(%rdi), %rcx
movq %rax, %rdx
orq %rcx, %rdx
jne 0x8119
pushq $0x38
popq %rdi
callq 0x2170
leaq 0x80e4(%rip), %rcx      # 0x101b8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rax)
leaq -0xec8(%rip), %rcx      # 0x7228
movq %rcx, 0x18(%rax)
andq $0x0, 0x20(%rax)
movq %r14, 0x28(%rax)
andq $0x0, 0x30(%rax)
movq (%rbx), %rcx
movq 0x48(%rcx), %rcx
movq %rbx, %rdi
movq %rbx, %rsi
movq %rax, %rdx
popq %rbx
popq %r14
popq %r15
jmpq *%rcx
movsd 0x20(%r14), %xmm0
movsd 0xb0(%rbx), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x81d4
testq %rax, %rax
je 0x82c5
cmpb $0x1, 0x60(%rbx)
jne 0x80c5
movq 0x48(%r14), %xmm0
pcmpeqd %xmm1, %xmm1
psubd %xmm1, %xmm0
movq %xmm0, 0x48(%r14)
cmpl $0x2, 0x38(%r14)
ja 0x81cb
movq 0x7e6e(%rip), %rdi      # 0xffd0
leaq 0x22f4(%rip), %rsi      # 0xa45d
callq 0x2160
movq (%r14), %rsi
movq %rax, %rdi
callq 0x20e0
leaq 0x22b6(%rip), %rsi      # 0xa436
movq %rax, %rdi
callq 0x2160
movsd 0xb0(%rbx), %xmm0
movq %rax, %rdi
callq 0x2240
leaq 0x2301(%rip), %rsi      # 0xa4a0
movq %rax, %rdi
callq 0x2160
movq 0x20(%r14), %xmm0
movq %rax, %rdi
callq 0x2240
leaq 0x22f1(%rip), %rsi      # 0xa4ad
movq %rax, %rdi
callq 0x2160
movq 0xc8(%rbx), %rax
movq 0x28(%rax), %r15
jmp 0x8279
ucomisd %xmm1, %xmm0
jae 0x81e0
popq %rbx
popq %r14
popq %r15
retq
cmpb $0x1, 0x61(%rbx)
jne 0x80c5
movq 0x48(%r14), %xmm0
pcmpeqd %xmm1, %xmm1
psubd %xmm1, %xmm0
movq %xmm0, 0x48(%r14)
cmpl $0x2, 0x38(%r14)
ja 0x8275
movq 0x7dc4(%rip), %rdi      # 0xffd0
leaq 0x224a(%rip), %rsi      # 0xa45d
callq 0x2160
movq (%r14), %rsi
movq %rax, %rdi
callq 0x20e0
leaq 0x220c(%rip), %rsi      # 0xa436
movq %rax, %rdi
callq 0x2160
movsd 0xb0(%rbx), %xmm0
movq %rax, %rdi
callq 0x2240
leaq 0x2257(%rip), %rsi      # 0xa4a0
movq %rax, %rdi
callq 0x2160
movq 0x20(%r14), %xmm0
movq %rax, %rdi
callq 0x2240
leaq 0x2253(%rip), %rsi      # 0xa4b9
movq %rax, %rdi
callq 0x2160
movq 0xd0(%rbx), %rcx
movq 0x28(%rcx), %r15
pushq $0x38
popq %rdi
callq 0x2170
leaq 0x7f30(%rip), %rcx      # 0x101b8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
pxor %xmm0, %xmm0
movdqu %xmm0, 0x8(%rax)
leaq -0x107c(%rip), %rcx     # 0x7228
movq %rcx, 0x18(%rax)
andq $0x0, 0x20(%rax)
movq %r14, 0x28(%rax)
andq $0x0, 0x30(%rax)
movq (%r15), %rcx
movq 0x8(%rcx), %rcx
movq %r15, %rdi
jmp 0x810c
movq %rbx, %rdi
movq %r14, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x7e0a
nop