// File: /workspace/github_c_makefile_star2_O3/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, %r13
movq %rcx, 0x10(%rsp)
movq %rdx, 0x38(%rsp)
movl %esi, 0x1c(%rsp)
testl %r9d, %r9d
jg 0x6ba1
xorl %r15d, %r15d
cmpw $0x2, (%rdi)
setne %r15b
incl %r15d
movq %rdi, 0x30(%rsp)
xorl %ebp, %ebp
movl $0x0, %ebx
testb $0x1, %r15b
je 0x6c47
movq %r13, %rdi
movl $0x2, %esi
callq 0x3593
movl $0x0, %ebx
testq %rax, %rax
je 0x6c47
movq %rax, %r12
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
movq %r13, %rdx
movq %rax, %rcx
callq 0x8576
movl %eax, %ebx
movq 0xb8(%r12), %rcx
testq %rcx, %rcx
je 0x6c03
leaq 0x40(%rsp), %rdi
movl %ebx, %esi
movq %r13, %rdx
callq 0x8576
movl %eax, %ebx
cmpl $0x2, (%r12)
leaq 0x7041(%rip), %rax      # 0xdc50
leaq 0x7042(%rip), %rcx      # 0xdc58
cmoveq %rax, %rcx
movq (%rcx), %rax
cmpq %r12, %rax
je 0x6c47
movq %rax, %rcx
movq 0xb8(%rax), %rax
testq %rax, %rax
je 0x6c47
cmpq %r12, %rax
jne 0x6c22
leaq 0x40(%rsp), %rdi
movl %ebx, %esi
movq %r13, %rdx
callq 0x8576
movl %eax, %ebx
testb $0x2, %r15b
je 0x6ce7
movq %r13, %rdi
movl $0xa, %esi
callq 0x3593
testq %rax, %rax
je 0x6ce7
movq %rax, %r15
leaq 0x110(%rsp), %rdi
xorl %esi, %esi
movq %r13, %rdx
movq %rax, %rcx
callq 0x8576
movl %eax, %ebp
movq 0xb8(%r15), %rcx
testq %rcx, %rcx
je 0x6ca1
leaq 0x110(%rsp), %rdi
movl %ebp, %esi
movq %r13, %rdx
callq 0x8576
movl %eax, %ebp
cmpl $0x2, (%r15)
leaq 0x6fa4(%rip), %rax      # 0xdc50
leaq 0x6fa5(%rip), %rcx      # 0xdc58
cmoveq %rax, %rcx
movq (%rcx), %rax
cmpq %r15, %rax
je 0x6ce7
movq %rax, %rcx
movq 0xb8(%rax), %rax
testq %rax, %rax
je 0x6ce7
cmpq %r15, %rax
jne 0x6cbf
leaq 0x110(%rsp), %rdi
movl %ebp, %esi
movq %r13, %rdx
callq 0x8576
movl %eax, %ebp
leaq 0x2cbf(%rip), %rdi      # 0x99ad
movl %ebx, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0x362c
movabsq $0x3a303264693a32, %rax # imm = 0x3A303264693A32
movq %rax, 0x245(%rsp)
movabsq $0x693a3264723a3164, %rax # imm = 0x693A3264723A3164
movq %rax, 0x240(%rsp)
movl 0x6f1d(%rip), %eax      # 0xdc40
movl %eax, 0x25c(%rsp)
movaps 0x6eff(%rip), %xmm0     # 0xdc30
movups %xmm0, 0x24c(%rsp)
testl %ebx, %ebx
jle 0x6da8
leal (%rbx,%rbx,4), %eax
leal (%rax,%rax,4), %r15d
addl %ebx, %r15d
leaq 0x260(%rsp), %rdi
leaq 0x2c69(%rip), %rdx      # 0x99bf
movl $0x7e0, %esi            # imm = 0x7E0
movl %r15d, %ecx
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x7140
cmpl $0x7e0, %eax            # imm = 0x7E0
ja 0x7140
addl $0x20, %eax
leal (%rax,%r15), %r13d
cmpl $0x800, %r13d           # imm = 0x800
ja 0x7140
movl %eax, %eax
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl %r15d, %edx
leaq 0x40(%rsp), %rsi
callq 0x2200
jmp 0x6dae
movl $0x20, %r13d
testl %ebp, %ebp
jle 0x6e1e
imull $0x26, %ebp, %ebx
movl %r13d, %eax
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl $0x800, %esi            # imm = 0x800
subl %r13d, %esi
leaq 0x2bf8(%rip), %rdx      # 0x99ca
movl %ebx, %ecx
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x7140
addl %r13d, %eax
cmpl $0x800, %eax            # imm = 0x800
ja 0x7140
leal (%rax,%rbx), %r13d
cmpl $0x800, %r13d           # imm = 0x800
ja 0x7140
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 0x6e92
movl %r13d, %eax
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl $0x800, %esi            # imm = 0x800
subl %r13d, %esi
leaq 0x285c(%rip), %rdx      # 0x96a2
movl %ebx, %ecx
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x7140
addl %r13d, %eax
cmpl $0x800, %eax            # imm = 0x800
ja 0x7140
leal (%rax,%rbx), %r13d
cmpl $0x800, %r13d           # imm = 0x800
ja 0x7140
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 0x706e
cmpl $0x0, 0x14(%rbx)
jle 0x706e
cmpl $0x2, 0xa80(%rsp)
movl $0x4, %eax
movl $0x10, %ecx
cmovel %eax, %ecx
movl %ecx, 0xc(%rsp)
callq 0x2230
movslq 0x14(%rbx), %rcx
cqto
idivq %rcx
movq %rdx, 0x28(%rsp)
movl %r13d, %eax
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl $0x800, %esi            # imm = 0x800
subl %r13d, %esi
leaq 0x2ae0(%rip), %rdx      # 0x99d6
xorl %eax, %eax
callq 0x2110
movl %eax, %r12d
testl %eax, %eax
sets %al
addl %r13d, %r12d
cmpl $0x801, %r12d           # imm = 0x801
setge %cl
orb %al, %cl
jne 0x7140
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), %r13
movq 0x28(%rsp), %rax
movl %eax, %r15d
xorl %ebp, %ebp
movslq %r15d, %rbx
shlq $0x5, %rbx
movzwl 0x18(%r13,%rbx), %eax
cmpl %eax, %esi
jne 0x7011
addq %rbx, %r13
movzwl 0x1a(%r13), %r14d
movl %r12d, %eax
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl $0x800, %esi            # imm = 0x800
subl %r12d, %esi
leaq 0x2a54(%rip), %rdx      # 0x99d2
movl 0x18(%rsp), %ecx
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x7140
addl %r12d, %eax
cmpl $0x800, %eax            # imm = 0x800
jg 0x7140
movl %eax, %eax
movq 0x20(%rsp), %rcx
leaq (%rcx,%rax), %r12
cmpl $0x800, %r12d           # imm = 0x800
jg 0x7140
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movq 0xa88(%rsp), %rax
movq 0x20(%rax), %r13
leaq (%rbx,%r13), %rsi
addq $0x8, %rsi
movq 0x20(%rsp), %rdx
callq 0x2200
cmpl $0x7fe, %r12d           # imm = 0x7FE
jg 0x7140
rolw $0x8, %r14w
leal 0x2(%r12), %eax
movw %r14w, 0x240(%rsp,%r12)
movl %eax, %r12d
incl %ebp
movq 0xa88(%rsp), %rcx
movl 0xc(%rsp), %esi
incl %r15d
movl %r15d, %eax
cltd
idivl 0x14(%rcx)
cmpl 0x28(%rsp), %edx
je 0x702d
movl %edx, %r15d
cmpl $0x32, %ebp
jl 0x6f44
movl %r12d, %eax
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl $0x800, %esi            # imm = 0x800
subl %r12d, %esi
leaq 0x2aad(%rip), %rdx      # 0x9af7
xorl %eax, %eax
callq 0x2110
movl %eax, %r13d
testl %eax, %eax
sets %al
addl %r12d, %r13d
cmpl $0x801, %r13d           # imm = 0x801
setge %cl
orb %al, %cl
jne 0x7140
movslq %r13d, %rax
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl $0x800, %esi            # imm = 0x800
subl %eax, %esi
leaq 0x28c2(%rip), %rdx      # 0x994c
movq 0x10(%rsp), %rcx
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x7140
addl %r13d, %eax
cmpl $0x800, %eax            # imm = 0x800
jg 0x7140
movq 0x10(%rsp), %rcx
leal (%rax,%rcx), %ebx
cmpl $0x800, %ebx            # imm = 0x800
jg 0x7140
cltq
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl 0x10(%rsp), %edx
movq 0x38(%rsp), %rsi
callq 0x2200
cmpb $0x1, 0x6b9a(%rip)      # 0xdc7c
jne 0x7110
movslq %ebx, %rax
leaq 0x9(%rax), %rbx
cmpq $0x800, %rbx            # imm = 0x800
ja 0x7140
movb 0x6b7e(%rip), %cl       # 0xdc78
movb %cl, 0x248(%rsp,%rax)
movq 0x6b68(%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 0x2879(%rip), %rdx      # 0x99a5
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x7140
addl %ebx, %eax
cmpl $0x800, %eax            # imm = 0x800
jle 0x715d
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 0x8043
jmp 0x714b