// File: /workspace/github_cpp_makefile_star2_O3/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 0x9ba9
movl $0x38, %edi
callq 0x2160
leaq 0x7644(%rip), %rcx      # 0x111a8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rax)
leaq -0x140c(%rip), %rcx     # 0x8774
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
popq %rbx
popq %r14
popq %r15
jmpq *%rcx
movsd 0x20(%r14), %xmm0
movsd 0xb0(%rbx), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x9c85
testq %rax, %rax
je 0x9d99
cmpb $0x1, 0x60(%rbx)
jne 0x9b53
movq 0x48(%r14), %xmm0
pcmpeqd %xmm1, %xmm1
psubd %xmm1, %xmm0
movq %xmm0, 0x48(%r14)
cmpl $0x2, 0x38(%r14)
ja 0x9c7c
movq 0x73da(%rip), %r15      # 0x10fd0
leaq 0x2860(%rip), %rsi      # 0xc45d
movl $0x1, %edx
movq %r15, %rdi
callq 0x21a0
movq (%r14), %rsi
movq %r15, %rdi
callq 0x20e0
movq %rax, %r15
leaq 0x2817(%rip), %rsi      # 0xc436
movl $0x2, %edx
movq %rax, %rdi
callq 0x21a0
movsd 0xb0(%rbx), %xmm0
movq %r15, %rdi
callq 0x2230
movq %rax, %r15
leaq 0x285a(%rip), %rsi      # 0xc4a0
movl $0xc, %edx
movq %rax, %rdi
callq 0x21a0
movq 0x20(%r14), %xmm0
movq %r15, %rdi
callq 0x2230
leaq 0x2845(%rip), %rsi      # 0xc4ad
movl $0xb, %edx
movq %rax, %rdi
callq 0x21a0
movq 0xc8(%rbx), %rax
movq 0x28(%rax), %r15
jmp 0x9d4b
ucomisd %xmm1, %xmm0
jae 0x9c91
popq %rbx
popq %r14
popq %r15
retq
cmpb $0x1, 0x61(%rbx)
jne 0x9b53
movq 0x48(%r14), %xmm0
pcmpeqd %xmm1, %xmm1
psubd %xmm1, %xmm0
movq %xmm0, 0x48(%r14)
cmpl $0x2, 0x38(%r14)
ja 0x9d47
movq 0x730f(%rip), %r15      # 0x10fd0
leaq 0x2795(%rip), %rsi      # 0xc45d
movl $0x1, %edx
movq %r15, %rdi
callq 0x21a0
movq (%r14), %rsi
movq %r15, %rdi
callq 0x20e0
movq %rax, %r15
leaq 0x274c(%rip), %rsi      # 0xc436
movl $0x2, %edx
movq %rax, %rdi
callq 0x21a0
movsd 0xb0(%rbx), %xmm0
movq %r15, %rdi
callq 0x2230
movq %rax, %r15
leaq 0x278f(%rip), %rsi      # 0xc4a0
movl $0xc, %edx
movq %rax, %rdi
callq 0x21a0
movq 0x20(%r14), %xmm0
movq %r15, %rdi
callq 0x2230
leaq 0x2786(%rip), %rsi      # 0xc4b9
movl $0xc, %edx
movq %rax, %rdi
callq 0x21a0
movq 0xd0(%rbx), %rcx
movq 0x28(%rcx), %r15
movl $0x38, %edi
callq 0x2160
leaq 0x744c(%rip), %rcx      # 0x111a8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
pxor %xmm0, %xmm0
movdqu %xmm0, 0x8(%rax)
leaq -0x1604(%rip), %rcx     # 0x8774
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 0x9b9c
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x20(%r14)
movl $0x0, 0x48(%r14)
movq %rbx, %rdi
movq %r14, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x8774
nop