// File: /workspace/github_c_makefile_star2_O0/jech[P]dht/dht.c
// Function: neighbourhood_maintenance
static int
neighbourhood_maintenance(int af)
{
    unsigned char id[20];
    struct bucket *b = find_bucket(myid, af);
    struct bucket *q;
    struct node *n;

    if(b == NULL)
        return 0;

    memcpy(id, myid, 20);
    id[19] = random() & 0xFF;
    q = b;
    if(q->next && (q->count == 0 || (random() & 7) == 0))
        q = b->next;
    if(q->count == 0 || (random() & 7) == 0) {
        struct bucket *r;
        r = previous_bucket(b);
        if(r && r->count > 0)
            q = r;
    }

    if(q) {
        /* Since our node-id is the same in both DHTs, it's probably
           profitable to query both families. */
        int want = dht_socket >= 0 && dht_socket6 >= 0 ? (WANT4 | WANT6) : -1;
        n = random_node(q);
        if(n) {
            unsigned char tid[4];
            debugf("Sending find_node for%s neighborhood maintenance.\n",
                   af == AF_INET6 ? " IPv6" : "");
            make_tid(tid, "fn", 0);
            send_find_node((struct sockaddr*)&n->ss, n->sslen,
                           tid, 4, id, want,
                           n->reply_time >= now.tv_sec - 15);
            pinged(n, q);
        }
        return 1;
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl %edi, -0x8(%rbp)
movl -0x8(%rbp), %esi
leaq 0x790b(%rip), %rdi      # 0x10c30
callq 0x39a0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x9341
movl $0x0, -0x4(%rbp)
jmp 0x94e2
movq 0x78e8(%rip), %rax      # 0x10c30
movq %rax, -0x20(%rbp)
movq 0x78e5(%rip), %rax      # 0x10c38
movq %rax, -0x18(%rbp)
movl 0x78e3(%rip), %eax      # 0x10c40
movl %eax, -0x10(%rbp)
callq 0x2230
andq $0xff, %rax
movb %al, -0xd(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq $0x0, 0xb8(%rax)
je 0x93ac
movq -0x30(%rbp), %rax
cmpl $0x0, 0x18(%rax)
je 0x939d
callq 0x2230
andq $0x7, %rax
cmpq $0x0, %rax
jne 0x93ac
movq -0x28(%rbp), %rax
movq 0xb8(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, 0x18(%rax)
je 0x93c5
callq 0x2230
andq $0x7, %rax
cmpq $0x0, %rax
jne 0x93ed
movq -0x28(%rbp), %rdi
callq 0x3de0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x93eb
movq -0x40(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jle 0x93eb
movq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x93ed
cmpq $0x0, -0x30(%rbp)
je 0x94db
xorl %eax, %eax
cmpl $0x0, 0x5dc7(%rip)      # 0xf1c8
movb %al, -0x49(%rbp)
jl 0x9413
cmpl $0x0, 0x5dbf(%rip)      # 0xf1cc
setge %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %dl
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl $0x3, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x44(%rbp)
movq -0x30(%rbp), %rdi
callq 0xafb0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x94d2
movl -0x8(%rbp), %ecx
leaq 0x2ed3(%rip), %rsi      # 0xc31e
leaq 0x30f3(%rip), %rax      # 0xc545
cmpl $0xa, %ecx
cmoveq %rax, %rsi
leaq 0x3506(%rip), %rdi      # 0xc966
movb $0x0, %al
callq 0x3aa0
leaq -0x48(%rbp), %rdi
leaq 0x2f7f(%rip), %rsi      # 0xc3f1
xorl %edx, %edx
callq 0x9990
movq -0x38(%rbp), %rdi
addq $0x18, %rdi
movq -0x38(%rbp), %rax
movl 0x98(%rax), %esi
leaq -0x48(%rbp), %rdx
leaq -0x20(%rbp), %r8
movl -0x44(%rbp), %r9d
movq -0x38(%rbp), %rax
movq 0xa8(%rax), %rax
movq 0x7767(%rip), %rcx      # 0x10c10
subq $0xf, %rcx
cmpq %rcx, %rax
setge %al
andb $0x1, %al
movzbl %al, %eax
movl $0x4, %ecx
movl %eax, (%rsp)
callq 0xb040
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0xa090
movl $0x1, -0x4(%rbp)
jmp 0x94e2
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)