// File: /workspace/github_c_makefile_star2_O1/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 0x6bec
xorl %r15d, %r15d
cmpw $0x2, (%rdi)
setne %r15b
incl %r15d
movq %rdi, 0x30(%rsp)
xorl %ebp, %ebp
movl $0x0, %ebx
testb $0x1, %r15b
je 0x6c9f
movq %r13, %rdi
movl $0x2, %esi
callq 0x35d4
movl $0x0, %ebx
testq %rax, %rax
je 0x6c9f
movq %rax, %r12
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
movq %r13, %rdx
movq %rax, %rcx
callq 0x8564
movl %eax, %ebx
movq 0xb8(%r12), %rcx
testq %rcx, %rcx
je 0x6c52
leaq 0x40(%rsp), %rdi
movl %ebx, %esi
movq %r13, %rdx
callq 0x8564
movl %eax, %ebx
cmpl $0x2, (%r12)
leaq 0x6ff2(%rip), %rax      # 0xdc50
leaq 0x6ff3(%rip), %rcx      # 0xdc58
cmoveq %rax, %rcx
movq (%rcx), %rax
cmpq %r12, %rax
je 0x6c87
movq %rax, %rcx
movq 0xb8(%rax), %rax
testq %rax, %rax
je 0x6c87
cmpq %r12, %rax
jne 0x6c71
jmp 0x6c89
xorl %ecx, %ecx
testq %rcx, %rcx
je 0x6c9f
leaq 0x40(%rsp), %rdi
movl %ebx, %esi
movq %r13, %rdx
callq 0x8564
movl %eax, %ebx
testb $0x2, %r15b
je 0x6d48
movq %r13, %rdi
movl $0xa, %esi
callq 0x35d4
testq %rax, %rax
je 0x6d48
movq %rax, %r15
leaq 0x110(%rsp), %rdi
xorl %esi, %esi
movq %r13, %rdx
movq %rax, %rcx
callq 0x8564
movl %eax, %ebp
movq 0xb8(%r15), %rcx
testq %rcx, %rcx
je 0x6cf9
leaq 0x110(%rsp), %rdi
movl %ebp, %esi
movq %r13, %rdx
callq 0x8564
movl %eax, %ebp
cmpl $0x2, (%r15)
leaq 0x6f4c(%rip), %rax      # 0xdc50
leaq 0x6f4d(%rip), %rcx      # 0xdc58
cmoveq %rax, %rcx
movq (%rcx), %rax
cmpq %r15, %rax
je 0x6d2d
movq %rax, %rcx
movq 0xb8(%rax), %rax
testq %rax, %rax
je 0x6d2d
cmpq %r15, %rax
jne 0x6d17
jmp 0x6d2f
xorl %ecx, %ecx
testq %rcx, %rcx
je 0x6d48
leaq 0x110(%rsp), %rdi
movl %ebp, %esi
movq %r13, %rdx
callq 0x8564
movl %eax, %ebp
leaq 0x2c6e(%rip), %rdi      # 0x99bd
movl %ebx, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0x366b
movabsq $0x3a303264693a32, %rax # imm = 0x3A303264693A32
movq %rax, 0x245(%rsp)
movabsq $0x693a3264723a3164, %rax # imm = 0x693A3264723A3164
movq %rax, 0x240(%rsp)
movl 0x6ebc(%rip), %eax      # 0xdc40
movl %eax, 0x25c(%rsp)
movaps 0x6e9e(%rip), %xmm0     # 0xdc30
movups %xmm0, 0x24c(%rsp)
testl %ebx, %ebx
jle 0x6e09
leal (%rbx,%rbx,4), %eax
leal (%rax,%rax,4), %r15d
addl %ebx, %r15d
leaq 0x260(%rsp), %rdi
leaq 0x2c18(%rip), %rdx      # 0x99cf
movl $0x7e0, %esi            # imm = 0x7E0
movl %r15d, %ecx
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x71a2
cmpl $0x7e0, %eax            # imm = 0x7E0
jg 0x71a2
addl $0x20, %eax
leal (%rax,%r15), %r13d
cmpl $0x800, %r13d           # imm = 0x800
jg 0x71a2
movl %eax, %eax
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl %r15d, %edx
leaq 0x40(%rsp), %rsi
callq 0x2200
jmp 0x6e0f
movl $0x20, %r13d
testl %ebp, %ebp
jle 0x6e7f
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 0x2ba7(%rip), %rdx      # 0x99da
movl %ebx, %ecx
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x71a2
addl %r13d, %eax
cmpl $0x800, %eax            # imm = 0x800
jg 0x71a2
leal (%rax,%rbx), %r13d
cmpl $0x800, %r13d           # imm = 0x800
jg 0x71a2
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 0x6ef3
movl %r13d, %eax
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl $0x800, %esi            # imm = 0x800
subl %r13d, %esi
leaq 0x280b(%rip), %rdx      # 0x96b2
movl %ebx, %ecx
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x71a2
addl %r13d, %eax
cmpl $0x800, %eax            # imm = 0x800
jg 0x71a2
leal (%rax,%rbx), %r13d
cmpl $0x800, %r13d           # imm = 0x800
jg 0x71a2
movq 0xa90(%rsp), %rsi
movl %eax, %eax
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl %ebx, %edx
callq 0x2200
movq 0xa88(%rsp), %r12
testq %r12, %r12
je 0x70ca
cmpl $0x0, 0x14(%r12)
jle 0x70ca
cmpl $0x2, 0xa80(%rsp)
movl $0x4, %eax
movl $0x10, %r14d
cmovel %eax, %r14d
callq 0x2230
movslq 0x14(%r12), %rcx
cqto
idivq %rcx
movq %rdx, 0x20(%rsp)
movl %r13d, %eax
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl $0x800, %esi            # imm = 0x800
subl %r13d, %esi
leaq 0x2a8e(%rip), %rdx      # 0x99e6
movl $0x0, 0xc(%rsp)
xorl %eax, %eax
callq 0x2110
movl %eax, %ebp
testl %eax, %eax
sets %al
addl %r13d, %ebp
cmpl $0x801, %ebp            # imm = 0x801
setge %cl
orb %al, %cl
jne 0x71a2
movl %r14d, %eax
orl $0x2, %eax
movl %eax, 0x18(%rsp)
movl %r14d, %eax
movq %rax, 0x28(%rsp)
movq 0x20(%rsp), %rax
movl %eax, %r15d
movq 0x20(%r12), %rax
movslq %r15d, %rbx
shlq $0x5, %rbx
movzwl 0x18(%rax,%rbx), %ecx
cmpl %ecx, %r14d
jne 0x706b
movl %r14d, %r13d
movq %r12, %r14
addq %rbx, %rax
movzwl 0x1a(%rax), %eax
movw %ax, 0xa(%rsp)
movl %ebp, %eax
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl $0x800, %esi            # imm = 0x800
subl %ebp, %esi
xorl %r12d, %r12d
leaq 0x29fc(%rip), %rdx      # 0x99e2
movl 0x18(%rsp), %ecx
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x705c
addl %ebp, %eax
cmpl $0x800, %eax            # imm = 0x800
jle 0x7003
xorl %r12d, %r12d
jmp 0x705c
movl %eax, %ecx
movq 0x28(%rsp), %rdx
leaq (%rdx,%rcx), %rbp
cmpl $0x800, %ebp            # imm = 0x800
jle 0x701b
xorl %r12d, %r12d
jmp 0x705a
leaq (%rsp,%rcx), %rdi
addq $0x240, %rdi            # imm = 0x240
movq 0x20(%r14), %rax
leaq (%rax,%rbx), %rsi
addq $0x8, %rsi
callq 0x2200
cmpl $0x7fe, %ebp            # imm = 0x7FE
jg 0x6ffe
movzwl 0xa(%rsp), %eax
rolw $0x8, %ax
movw %ax, 0x240(%rsp,%rbp)
leal 0x2(%rbp), %eax
incl 0xc(%rsp)
movb $0x1, %r12b
movl %eax, %ebp
testb %r12b, %r12b
movq %r14, %r12
movl %r13d, %r14d
je 0x71a2
incl %r15d
movl %r15d, %eax
cltd
idivl 0x14(%r12)
cmpl 0x20(%rsp), %edx
je 0x708b
movl %edx, %r15d
cmpl $0x32, 0xc(%rsp)
jl 0x6f9c
movl %ebp, %eax
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl $0x800, %esi            # imm = 0x800
subl %ebp, %esi
leaq 0x2a61(%rip), %rdx      # 0x9b07
xorl %eax, %eax
callq 0x2110
movl %eax, %r13d
testl %eax, %eax
sets %al
addl %ebp, %r13d
cmpl $0x801, %r13d           # imm = 0x801
setge %cl
orb %al, %cl
jne 0x71a2
movslq %r13d, %rax
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl $0x800, %ecx            # imm = 0x800
subl %eax, %ecx
movslq %ecx, %rsi
leaq 0x2873(%rip), %rdx      # 0x995c
movq 0x10(%rsp), %rcx
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x71a2
addl %r13d, %eax
cmpl $0x800, %eax            # imm = 0x800
jg 0x71a2
movq 0x10(%rsp), %rcx
leal (%rax,%rcx), %ebx
cmpl $0x800, %ebx            # imm = 0x800
jg 0x71a2
cltq
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl 0x10(%rsp), %edx
movq 0x38(%rsp), %rsi
callq 0x2200
cmpb $0x1, 0x6b3b(%rip)      # 0xdc7c
jne 0x716f
movslq %ebx, %rax
leaq 0x9(%rax), %rbx
cmpq $0x800, %rbx            # imm = 0x800
ja 0x71a2
movb 0x6b1f(%rip), %cl       # 0xdc78
movb %cl, 0x248(%rsp,%rax)
movq 0x6b09(%rip), %rcx      # 0xdc70
movq %rcx, 0x240(%rsp,%rax)
movslq %ebx, %rax
leaq (%rsp,%rax), %rdi
addq $0x240, %rdi            # imm = 0x240
movl $0x800, %ecx            # imm = 0x800
subl %eax, %ecx
movslq %ecx, %rsi
leaq 0x2827(%rip), %rdx      # 0x99b5
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x71a2
addl %ebx, %eax
cmpl $0x800, %eax            # imm = 0x800
jle 0x71bf
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 0x8058
jmp 0x71ad