// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x278, %rsp            # imm = 0x278
movl 0x28(%rbp), %eax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movl 0x10(%rbp), %eax
movq %rdi, -0x20(%rbp)
movl %esi, -0x24(%rbp)
movq %rdx, -0x30(%rbp)
movl %ecx, -0x34(%rbp)
movq %r8, -0x40(%rbp)
movl %r9d, -0x44(%rbp)
movl $0x0, -0x254(%rbp)
movl $0x0, -0x258(%rbp)
cmpl $0x0, -0x44(%rbp)
jg 0x81b8
movq -0x20(%rbp), %rax
movzwl (%rax), %edx
movl $0x2, %eax
movl $0x1, %ecx
cmpl $0x2, %edx
cmovel %ecx, %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x828c
movq -0x40(%rbp), %rdi
movl $0x2, %esi
callq 0x39a0
movq %rax, -0x260(%rbp)
cmpq $0x0, -0x260(%rbp)
je 0x828a
leaq -0x120(%rbp), %rdi
movl -0x254(%rbp), %esi
movq -0x40(%rbp), %rdx
movq -0x260(%rbp), %rcx
callq 0xb440
movl %eax, -0x254(%rbp)
movq -0x260(%rbp), %rax
cmpq $0x0, 0xb8(%rax)
je 0x8248
leaq -0x120(%rbp), %rdi
movl -0x254(%rbp), %esi
movq -0x40(%rbp), %rdx
movq -0x260(%rbp), %rax
movq 0xb8(%rax), %rcx
callq 0xb440
movl %eax, -0x254(%rbp)
movq -0x260(%rbp), %rdi
callq 0x3de0
movq %rax, -0x260(%rbp)
cmpq $0x0, -0x260(%rbp)
je 0x8288
leaq -0x120(%rbp), %rdi
movl -0x254(%rbp), %esi
movq -0x40(%rbp), %rdx
movq -0x260(%rbp), %rcx
callq 0xb440
movl %eax, -0x254(%rbp)
jmp 0x828a
jmp 0x828c
movl -0x44(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x8360
movq -0x40(%rbp), %rdi
movl $0xa, %esi
callq 0x39a0
movq %rax, -0x260(%rbp)
cmpq $0x0, -0x260(%rbp)
je 0x835e
leaq -0x250(%rbp), %rdi
movl -0x258(%rbp), %esi
movq -0x40(%rbp), %rdx
movq -0x260(%rbp), %rcx
callq 0xb440
movl %eax, -0x258(%rbp)
movq -0x260(%rbp), %rax
cmpq $0x0, 0xb8(%rax)
je 0x831c
leaq -0x250(%rbp), %rdi
movl -0x258(%rbp), %esi
movq -0x40(%rbp), %rdx
movq -0x260(%rbp), %rax
movq 0xb8(%rax), %rcx
callq 0xb440
movl %eax, -0x258(%rbp)
movq -0x260(%rbp), %rdi
callq 0x3de0
movq %rax, -0x260(%rbp)
cmpq $0x0, -0x260(%rbp)
je 0x835c
leaq -0x250(%rbp), %rdi
movl -0x258(%rbp), %esi
movq -0x40(%rbp), %rdx
movq -0x260(%rbp), %rcx
callq 0xb440
movl %eax, -0x258(%rbp)
jmp 0x835e
jmp 0x8360
movl -0x254(%rbp), %esi
movl -0x258(%rbp), %edx
leaq 0x464c(%rip), %rdi      # 0xc9bf
movb $0x0, %al
callq 0x3aa0
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %esi
movq -0x30(%rbp), %rdx
movl -0x34(%rbp), %ecx
leaq -0x120(%rbp), %r8
imull $0x1a, -0x254(%rbp), %r9d
leaq -0x250(%rbp), %r15
imull $0x26, -0x258(%rbp), %r14d
movl 0x10(%rbp), %ebx
movq 0x18(%rbp), %r11
movq 0x20(%rbp), %r10
movl 0x28(%rbp), %eax
movq %r15, (%rsp)
movl %r14d, 0x8(%rsp)
movl %ebx, 0x10(%rsp)
movq %r11, 0x18(%rsp)
movq %r10, 0x20(%rsp)
movl %eax, 0x28(%rsp)
callq 0xb4b0
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nopw %cs:(%rax,%rax)