// File: /workspace/github_c_makefile_star2_O3/jech[P]dht/dht.c
// Function: dht_dump_tables
void
dht_dump_tables(FILE *f)
{
    int i;
    struct bucket *b;
    struct storage *st = storage;
    struct search *sr = searches;

    fprintf(f, "My id ");
    print_hex(f, myid, 20);
    fprintf(f, "\n");

    b = buckets;
    while(b) {
        dump_bucket(f, b);
        b = b->next;
    }

    fprintf(f, "\n");

    b = buckets6;
    while(b) {
        dump_bucket(f, b);
        b = b->next;
    }

    while(sr) {
        fprintf(f, "\nSearch%s id ", sr->af == AF_INET6 ? " (IPv6)" : "");
        print_hex(f, sr->id, 20);
        fprintf(f, " age %d%s\n", (int)(now.tv_sec - sr->step_time),
               sr->done ? " (done)" : "");
        for(i = 0; i < sr->numnodes; i++) {
            struct search_node *n = &sr->nodes[i];
            fprintf(f, "Node %d id ", i);
            print_hex(f, n->id, 20);
            fprintf(f, " bits %d age ", common_bits(sr->id, n->id));
            if(n->request_time)
                fprintf(f, "%d, ", (int)(now.tv_sec - n->request_time));
            fprintf(f, "%d", (int)(now.tv_sec - n->reply_time));
            if(n->pinged)
                fprintf(f, " (%d)", n->pinged);
            fprintf(f, "%s%s.\n",
                    find_node(n->id, sr->af) ? " (known)" : "",
                    n->replied ? " (replied)" : "");
        }
        sr = sr->next;
    }

    while(st) {
        fprintf(f, "\nStorage ");
        print_hex(f, st->id, 20);
        fprintf(f, " %d/%d nodes:", st->numpeers, st->maxpeers);
        for(i = 0; i < st->numpeers; i++) {
            char buf[100];
            if(st->peers[i].len == 4) {
                inet_ntop(AF_INET, st->peers[i].ip, buf, 100);
            } else if(st->peers[i].len == 16) {
                buf[0] = '[';
                inet_ntop(AF_INET6, st->peers[i].ip, buf + 1, 98);
                strcat(buf, "]");
            } else {
                strcpy(buf, "???");
            }
            fprintf(f, " %s:%u (%ld)",
                    buf, st->peers[i].port,
                    (long)(now.tv_sec - st->peers[i].time));
        }
        st = st->next;
    }

    fprintf(f, "\n\n");
    fflush(f);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %rbx
movq 0xa003(%rip), %rax      # 0xdc60
movq %rax, (%rsp)
movq 0x9fa0(%rip), %r13      # 0xdc08
leaq 0x560f(%rip), %rdi      # 0x927e
movl $0x6, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2300
leaq 0x9fa8(%rip), %r14      # 0xdc30
leaq 0x5a88(%rip), %r15      # 0x9717
xorl %r12d, %r12d
movzbl (%r12,%r14), %edx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x21c0
incq %r12
cmpq $0x14, %r12
jne 0x3c92
movl $0xa, %edi
movq %rbx, %rsi
callq 0x2170
movq 0x9f8f(%rip), %r15      # 0xdc50
testq %r15, %r15
je 0x3cda
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4096
movq 0xb8(%r15), %r15
jmp 0x3cc1
movl $0xa, %edi
movq %rbx, %rsi
callq 0x2170
movq 0x9f6a(%rip), %r15      # 0xdc58
testq %r15, %r15
je 0x3d07
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4096
movq 0xb8(%r15), %r15
jmp 0x3cee
testq %r13, %r13
je 0x3f1c
leaq 0x5a00(%rip), %r15      # 0x9717
cmpl $0xa, 0x4(%r13)
leaq 0x55f5(%rip), %rdx      # 0x9318
leaq 0x5569(%rip), %rax      # 0x9293
cmoveq %rax, %rdx
movq %rbx, %rdi
leaq 0x554d(%rip), %rsi      # 0x9285
xorl %eax, %eax
callq 0x21c0
movq $-0x14, %r14
movzbl 0x24(%r13,%r14), %edx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x21c0
incq %r14
jne 0x3d46
movl 0x9eac(%rip), %edx      # 0xdc10
subl 0x8(%r13), %edx
cmpl $0x0, 0x28(%r13)
leaq 0x5532(%rip), %rcx      # 0x92a6
leaq 0x559d(%rip), %rax      # 0x9318
cmoveq %rax, %rcx
movq %rbx, %rdi
leaq 0x5512(%rip), %rsi      # 0x929b
xorl %eax, %eax
callq 0x21c0
cmpl $0x0, 0xce0(%r13)
jle 0x3f0c
leaq 0x30(%r13), %r14
movl $0x30, %r12d
movq %r14, 0x8(%rsp)
xorl %edx, %edx
movq %r13, 0x10(%rsp)
imulq $0xe8, %rdx, %rbp
addq 0x8(%rsp), %rbp
movq %rbx, %rdi
leaq 0x54e4(%rip), %rsi      # 0x92ae
movq %rdx, 0x18(%rsp)
xorl %eax, %eax
callq 0x21c0
movq $-0x14, %r13
movzbl 0x14(%r14,%r13), %edx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x21c0
incq %r13
jne 0x3ddd
xorl %eax, %eax
movq 0x10(%rsp), %r13
movq %r13, %rdx
movb 0x10(%rdx), %cl
cmpb (%rdx,%r12), %cl
jne 0x3e1e
incq %rdx
addq $-0x8, %rax
cmpq $-0xa0, %rax
jne 0x3dff
movl $0xa0, %edx
jmp 0x3e37
movb (%rdx,%r12), %cl
xorb 0x10(%rdx), %cl
js 0x3e33
xorl %edx, %edx
addb %cl, %cl
incl %edx
testb %cl, %cl
jns 0x3e29
jmp 0x3e35
xorl %edx, %edx
subl %eax, %edx
movq %rbx, %rdi
leaq 0x5479(%rip), %rsi      # 0x92ba
xorl %eax, %eax
callq 0x21c0
movq 0xa0(%rbp), %rax
testq %rax, %rax
je 0x3e6d
movl 0x9db6(%rip), %edx      # 0xdc10
subl %eax, %edx
movq %rbx, %rdi
leaq 0x5462(%rip), %rsi      # 0x92c8
xorl %eax, %eax
callq 0x21c0
movl 0x9d9d(%rip), %edx      # 0xdc10
subl 0xa8(%rbp), %edx
movq %rbx, %rdi
leaq 0x544a(%rip), %rsi      # 0x92cd
xorl %eax, %eax
callq 0x21c0
movl 0xb0(%rbp), %edx
testl %edx, %edx
je 0x3ea5
movq %rbx, %rdi
leaq 0x5432(%rip), %rsi      # 0x92d0
xorl %eax, %eax
callq 0x21c0
movl 0x4(%r13), %esi
movq %rbp, %rdi
callq 0x42f4
testq %rax, %rax
leaq 0x5422(%rip), %rdx      # 0x92dd
leaq 0x5456(%rip), %rax      # 0x9318
cmoveq %rax, %rdx
cmpl $0x0, 0xe0(%rbp)
leaq 0x5412(%rip), %rcx      # 0x92e6
cmoveq %rax, %rcx
movq %rbx, %rdi
leaq 0x53f4(%rip), %rsi      # 0x92d6
xorl %eax, %eax
callq 0x21c0
movq 0x18(%rsp), %rdx
incq %rdx
movslq 0xce0(%r13), %rax
movl $0xe8, %ecx
addq %rcx, %r14
addq %rcx, %r12
cmpq %rax, %rdx
jl 0x3db4
movq 0xce8(%r13), %r13
testq %r13, %r13
jne 0x3d17
movq (%rsp), %r12
testq %r12, %r12
je 0x4063
leaq 0x57e7(%rip), %r15      # 0x9717
leaq 0x20(%rsp), %rbp
movl $0x9, %esi
movl $0x1, %edx
leaq 0x53ab(%rip), %rdi      # 0x92f1
movq %rbx, %rcx
callq 0x2300
xorl %r14d, %r14d
movzbl (%r12,%r14), %edx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x21c0
incq %r14
cmpq $0x14, %r14
jne 0x3f51
movl 0x14(%r12), %edx
movl 0x18(%r12), %ecx
movq %rbx, %rdi
leaq 0x537b(%rip), %rsi      # 0x92fb
xorl %eax, %eax
callq 0x21c0
cmpl $0x0, 0x14(%r12)
movq %r12, %r15
jle 0x404c
movl $0x1a, %r12d
xorl %r14d, %r14d
movq %r15, %r13
movq 0x20(%r15), %rax
movzwl -0x2(%rax,%r12), %ecx
cmpl $0x10, %ecx
je 0x3fd2
cmpl $0x4, %ecx
jne 0x4004
leaq (%rax,%r12), %rsi
addq $-0x12, %rsi
movl $0x2, %edi
movq %rbp, %rdx
movl $0x64, %ecx
callq 0x2030
jmp 0x400c
movb $0x5b, 0x20(%rsp)
leaq (%rax,%r12), %rsi
addq $-0x12, %rsi
movl $0xa, %edi
leaq 0x21(%rsp), %rdx
movl $0x62, %ecx
callq 0x2030
movq %rbp, %rdi
callq 0x20f0
movw $0x5d, 0x20(%rsp,%rax)
jmp 0x400c
movl $0x3f3f3f, 0x20(%rsp)   # imm = 0x3F3F3F
movq %r13, %r15
movq 0x20(%r13), %rax
movzwl (%rax,%r12), %ecx
movq 0x9bf1(%rip), %r8       # 0xdc10
subq -0x1a(%rax,%r12), %r8
movq %rbx, %rdi
leaq 0x52db(%rip), %rsi      # 0x9309
movq %rbp, %rdx
xorl %eax, %eax
callq 0x21c0
incq %r14
movslq 0x14(%r13), %rax
addq $0x20, %r12
cmpq %rax, %r14
jl 0x3f9f
movq 0x28(%r15), %r15
testq %r15, %r15
movq %r15, %r12
leaq 0x56ba(%rip), %r15      # 0x9717
jne 0x3f35
leaq 0x52ac(%rip), %rdi      # 0x9316
movl $0x2, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2300
movq %rbx, %rdi
callq 0x2240
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq