// File: /workspace/github_c_makefile_star2_O2/jech[P]dht/dht.c
// Function: send_closest_nodes
int
send_closest_nodes(const struct sockaddr *sa, int salen,
                   const unsigned char *tid, int tid_len,
                   const unsigned char *id, int want,
                   int af, struct storage *st,
                   const unsigned char *token, int token_len)
{
    unsigned char nodes[8 * 26];
    unsigned char nodes6[8 * 38];
    int numnodes = 0, numnodes6 = 0;
    struct bucket *b;

    if(want <= 0)
        want = sa->sa_family == AF_INET ? WANT4 : WANT6;

    if((want & WANT4)) {
        b = find_bucket(id, AF_INET);
        if(b) {
            numnodes = buffer_closest_nodes(nodes, numnodes, id, b);
            if(b->next)
                numnodes = buffer_closest_nodes(nodes, numnodes, id, b->next);
            b = previous_bucket(b);
            if(b)
                numnodes = buffer_closest_nodes(nodes, numnodes, id, b);
        }
    }

    if((want & WANT6)) {
        b = find_bucket(id, AF_INET6);
        if(b) {
            numnodes6 = buffer_closest_nodes(nodes6, numnodes6, id, b);
            if(b->next)
                numnodes6 =
                    buffer_closest_nodes(nodes6, numnodes6, id, b->next);
            b = previous_bucket(b);
            if(b)
                numnodes6 = buffer_closest_nodes(nodes6, numnodes6, id, b);
        }
    }
    debugf("  (%d+%d nodes.)\n", numnodes, numnodes6);

    return send_nodes_peers(sa, salen, tid, tid_len,
                            nodes, numnodes * 26,
                            nodes6, numnodes6 * 38,
                            af, st, token, token_len);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa48, %rsp            # imm = 0xA48
movl %r9d, %r15d
movq %r8, %rbp
movq %rcx, 0x10(%rsp)
movq %rdx, 0x38(%rsp)
movl %esi, 0x1c(%rsp)
testl %r9d, %r9d
jg 0x6656
xorl %r15d, %r15d
cmpw $0x2, (%rdi)
setne %r15b
incl %r15d
movq %rdi, 0x30(%rsp)
xorl %r13d, %r13d
movl $0x0, %ebx
testb $0x1, %r15b
je 0x66d4
pushq $0x2
popq %rsi
movq %rbp, %rdi
callq 0x329c
movl $0x0, %ebx
testq %rax, %rax
je 0x66d4
movq %rax, %r12
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
movq %rbp, %rdx
movq %rax, %rcx
callq 0x7a07
movl %eax, %ebx
movq 0xb8(%r12), %rcx
testq %rcx, %rcx
je 0x66b3
leaq 0x40(%rsp), %rdi
movl %ebx, %esi
movq %rbp, %rdx
callq 0x7a07
movl %eax, %ebx
movq %r12, %rdi
callq 0x348a
testq %rax, %rax
je 0x66d4
leaq 0x40(%rsp), %rdi
movl %ebx, %esi
movq %rbp, %rdx
movq %rax, %rcx
callq 0x7a07
movl %eax, %ebx
testb $0x2, %r15b
je 0x674d
pushq $0xa
popq %rsi
movq %rbp, %rdi
callq 0x329c
testq %rax, %rax
je 0x674d
movq %rax, %r15
leaq 0x110(%rsp), %rdi
xorl %esi, %esi
movq %rbp, %rdx
movq %rax, %rcx
callq 0x7a07
movl %eax, %r13d
movq 0xb8(%r15), %rcx
testq %rcx, %rcx
je 0x6727
leaq 0x110(%rsp), %rdi
movl %r13d, %esi
movq %rbp, %rdx
callq 0x7a07
movl %eax, %r13d
movq %r15, %rdi
callq 0x348a
testq %rax, %rax
je 0x674d
leaq 0x110(%rsp), %rdi
movl %r13d, %esi
movq %rbp, %rdx
movq %rax, %rcx
callq 0x7a07
movl %eax, %r13d
leaq 0x2259(%rip), %rdi      # 0x89ad
movl %ebx, %esi
movl %r13d, %edx
xorl %eax, %eax
callq 0x3324
movabsq $0x3a303264693a32, %rax # imm = 0x3A303264693A32
movq %rax, 0x245(%rsp)
movabsq $0x693a3264723a3164, %rax # imm = 0x693A3264723A3164
movq %rax, 0x240(%rsp)
movl 0x74b6(%rip), %eax      # 0xdc40
movl %eax, 0x25c(%rsp)
movaps 0x7498(%rip), %xmm0     # 0xdc30
movups %xmm0, 0x24c(%rsp)
testl %ebx, %ebx
jle 0x6804
imull $0x1a, %ebx, %ebx
leaq 0x260(%rsp), %rdi
leaq 0x2209(%rip), %rdx      # 0x89bf
movl $0x7e0, %esi            # imm = 0x7E0
movl %ebx, %ecx
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x6b8b
cmpl $0x7e0, %eax            # imm = 0x7E0
ja 0x6b8b
addl $0x20, %eax
leal (%rax,%rbx), %ebp
cmpl $0x800, %ebp            # imm = 0x800
ja 0x6b8b
movl %eax, %eax
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl %ebx, %edx
leaq 0x40(%rsp), %rsi
callq 0x2200
jmp 0x6807
pushq $0x20
popq %rbp
testl %r13d, %r13d
jle 0x6874
imull $0x26, %r13d, %ebx
movl %ebp, %eax
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl $0x800, %esi            # imm = 0x800
subl %ebp, %esi
leaq 0x219f(%rip), %rdx      # 0x89ca
movl %ebx, %ecx
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x6b8b
addl %ebp, %eax
cmpl $0x800, %eax            # imm = 0x800
ja 0x6b8b
leal (%rax,%rbx), %ebp
cmpl $0x800, %ebp            # imm = 0x800
ja 0x6b8b
movl %eax, %eax
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl %ebx, %edx
leaq 0x110(%rsp), %rsi
callq 0x2200
movl 0xa98(%rsp), %ebx
testl %ebx, %ebx
jle 0x68e3
movl %ebp, %eax
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl $0x800, %esi            # imm = 0x800
subl %ebp, %esi
leaq 0x1e08(%rip), %rdx      # 0x86a2
movl %ebx, %ecx
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x6b8b
addl %ebp, %eax
cmpl $0x800, %eax            # imm = 0x800
ja 0x6b8b
leal (%rax,%rbx), %ebp
cmpl $0x800, %ebp            # imm = 0x800
ja 0x6b8b
movq 0xa90(%rsp), %rsi
movl %eax, %eax
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl %ebx, %edx
callq 0x2200
movq 0xa88(%rsp), %rbx
testq %rbx, %rbx
je 0x6aba
cmpl $0x0, 0x14(%rbx)
jle 0x6aba
cmpl $0x2, 0xa80(%rsp)
pushq $0x4
popq %rax
pushq $0x10
popq %rcx
cmovel %eax, %ecx
movl %ecx, 0xc(%rsp)
callq 0x2230
movslq 0x14(%rbx), %rcx
cqto
idivq %rcx
movq %rdx, 0x28(%rsp)
movl %ebp, %eax
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl $0x800, %esi            # imm = 0x800
subl %ebp, %esi
leaq 0x2095(%rip), %rdx      # 0x89d6
xorl %eax, %eax
callq 0x2110
movl %eax, %r12d
testl %eax, %eax
sets %al
addl %ebp, %r12d
cmpl $0x801, %r12d           # imm = 0x801
setge %cl
orb %al, %cl
jne 0x6b8b
movl 0xc(%rsp), %esi
movl %esi, %eax
orl $0x2, %eax
movl %eax, 0x18(%rsp)
movl %esi, %eax
movq %rax, 0x20(%rsp)
movq 0xa88(%rsp), %rcx
movq 0x20(%rcx), %rbp
movq 0x28(%rsp), %rax
movl %eax, %r15d
xorl %ebx, %ebx
movslq %r15d, %r13
shlq $0x5, %r13
movzwl 0x18(%rbp,%r13), %eax
cmpl %eax, %esi
jne 0x6a5f
addq %r13, %rbp
movzwl 0x1a(%rbp), %r14d
movl %r12d, %eax
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl $0x800, %esi            # imm = 0x800
subl %r12d, %esi
leaq 0x2009(%rip), %rdx      # 0x89d2
movl 0x18(%rsp), %ecx
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x6b8b
addl %r12d, %eax
cmpl $0x800, %eax            # imm = 0x800
jg 0x6b8b
movl %eax, %eax
movq 0x20(%rsp), %rcx
leaq (%rcx,%rax), %r12
cmpl $0x800, %r12d           # imm = 0x800
jg 0x6b8b
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movq 0xa88(%rsp), %rax
movq 0x20(%rax), %rbp
leaq 0x8(,%r13), %rsi
addq %rbp, %rsi
movq 0x20(%rsp), %rdx
callq 0x2200
cmpl $0x7fe, %r12d           # imm = 0x7FE
jg 0x6b8b
rolw $0x8, %r14w
leal 0x2(%r12), %eax
movw %r14w, 0x240(%rsp,%r12)
movl %eax, %r12d
incl %ebx
movq 0xa88(%rsp), %rcx
movl 0xc(%rsp), %esi
incl %r15d
movl %r15d, %eax
cltd
idivl 0x14(%rcx)
cmpl 0x28(%rsp), %edx
je 0x6a7b
movl %edx, %r15d
cmpl $0x32, %ebx
jl 0x698f
movl %r12d, %eax
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl $0x800, %esi            # imm = 0x800
subl %r12d, %esi
leaq 0x205f(%rip), %rdx      # 0x8af7
xorl %eax, %eax
callq 0x2110
movl %eax, %ebp
testl %eax, %eax
sets %al
addl %r12d, %ebp
cmpl $0x801, %ebp            # imm = 0x801
setge %cl
orb %al, %cl
jne 0x6b8b
movslq %ebp, %rax
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl $0x800, %esi            # imm = 0x800
subl %eax, %esi
leaq 0x1e76(%rip), %rdx      # 0x894c
movq 0x10(%rsp), %rcx
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x6b8b
addl %ebp, %eax
cmpl $0x800, %eax            # imm = 0x800
jg 0x6b8b
movq 0x10(%rsp), %rcx
leal (%rax,%rcx), %ebx
cmpl $0x800, %ebx            # imm = 0x800
jg 0x6b8b
cltq
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl 0x10(%rsp), %edx
movq 0x38(%rsp), %rsi
callq 0x2200
cmpb $0x1, 0x714f(%rip)      # 0xdc7c
jne 0x6b5b
movslq %ebx, %rax
leaq 0x9(%rax), %rbx
cmpq $0x800, %rbx            # imm = 0x800
ja 0x6b8b
movb 0x7133(%rip), %cl       # 0xdc78
movb %cl, 0x248(%rsp,%rax)
movq 0x711d(%rip), %rcx      # 0xdc70
movq %rcx, 0x240(%rsp,%rax)
movslq %ebx, %rax
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl $0x800, %esi            # imm = 0x800
subl %eax, %esi
leaq 0x1e2e(%rip), %rdx      # 0x89a5
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x6b8b
addl %ebx, %eax
cmpl $0x800, %eax            # imm = 0x800
jle 0x6ba8
callq 0x2060
movl $0x1c, (%rax)
addq $0xa48, %rsp            # imm = 0xA48
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq %eax, %rsi
leaq 0x240(%rsp), %rdi
xorl %edx, %edx
movq 0x30(%rsp), %rcx
movl 0x1c(%rsp), %r8d
callq 0x7516
jmp 0x6b96