// File: /workspace/github_c_makefile_star2_O2/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 0xa2b9(%rip), %rax      # 0xdc60
movq %rax, 0x8(%rsp)
movq 0xa255(%rip), %r12      # 0xdc08
leaq 0x48c4(%rip), %rdi      # 0x827e
pushq $0x6
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x2300
leaq 0xa261(%rip), %rsi      # 0xdc30
movq %rbx, %rdi
callq 0x3d37
pushq $0xa
popq %rdi
movq %rbx, %rsi
callq 0x2170
leaq 0xa267(%rip), %r15      # 0xdc50
movq (%r15), %r15
testq %r15, %r15
je 0x3a05
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3d78
addq $0xb8, %r15
jmp 0x39e9
pushq $0xa
popq %rdi
movq %rbx, %rsi
callq 0x2170
leaq 0xa241(%rip), %r15      # 0xdc58
movq (%r15), %r15
testq %r15, %r15
je 0x3c02
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3d78
addq $0xb8, %r15
jmp 0x3a17
cmpl $0xa, 0x4(%r12)
leaq 0x48d4(%rip), %r14      # 0x8318
movq %r14, %rdx
leaq 0x4845(%rip), %rax      # 0x8293
cmoveq %rax, %rdx
movq %rbx, %rdi
leaq 0x4829(%rip), %rsi      # 0x8285
xorl %eax, %eax
callq 0x21c0
leaq 0x10(%r12), %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3d37
movl 0xa197(%rip), %edx      # 0xdc10
subl 0x8(%r12), %edx
cmpl $0x0, 0x28(%r12)
leaq 0x481b(%rip), %rcx      # 0x82a6
cmoveq %r14, %rcx
movq %rbx, %rdi
leaq 0x4802(%rip), %rsi      # 0x829b
xorl %eax, %eax
callq 0x21c0
leaq 0x30(%r12), %r14
movq %r14, 0x10(%rsp)
xorl %ebp, %ebp
movq %r12, 0x18(%rsp)
movslq 0xce0(%r12), %rax
cmpq %rax, %rbp
jge 0x3bfa
imulq $0xe8, %rbp, %r15
addq 0x10(%rsp), %r15
xorl %r12d, %r12d
movq %rbx, %rdi
leaq 0x47d3(%rip), %rsi      # 0x82ae
movl %ebp, %edx
xorl %eax, %eax
callq 0x21c0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3d37
xorl %eax, %eax
cmpq $0x14, %rax
je 0x3b0f
movb (%r13,%rax), %cl
cmpb (%r14,%rax), %cl
jne 0x3be2
incq %rax
addl $0x8, %r12d
jmp 0x3af1
movl $0xa0, %r12d
movq %rbx, %rdi
leaq 0x479b(%rip), %rsi      # 0x82ba
movl %r12d, %edx
xorl %eax, %eax
callq 0x21c0
movq 0xa0(%r15), %rax
testq %rax, %rax
je 0x3b4e
movl 0xa0d5(%rip), %edx      # 0xdc10
subl %eax, %edx
movq %rbx, %rdi
leaq 0x4781(%rip), %rsi      # 0x82c8
xorl %eax, %eax
callq 0x21c0
movl 0xa0bc(%rip), %edx      # 0xdc10
subl 0xa8(%r15), %edx
movq %rbx, %rdi
leaq 0x4768(%rip), %rsi      # 0x82cd
xorl %eax, %eax
callq 0x21c0
movl 0xb0(%r15), %edx
testl %edx, %edx
movq 0x18(%rsp), %r12
je 0x3b8d
movq %rbx, %rdi
leaq 0x474a(%rip), %rsi      # 0x82d0
xorl %eax, %eax
callq 0x21c0
movl 0x4(%r12), %esi
movq %r15, %rdi
callq 0x3f70
testq %rax, %rax
leaq 0x4739(%rip), %rdx      # 0x82dd
leaq 0x476d(%rip), %rax      # 0x8318
cmoveq %rax, %rdx
cmpl $0x0, 0xe0(%r15)
leaq 0x4728(%rip), %rcx      # 0x82e6
cmoveq %rax, %rcx
movq %rbx, %rdi
leaq 0x470a(%rip), %rsi      # 0x82d6
xorl %eax, %eax
callq 0x21c0
incq %rbp
addq $0xe8, %r14
jmp 0x3ab1
movb (%r14,%rax), %cl
xorb (%r13,%rax), %cl
testb %cl, %cl
js 0x3b15
addb %cl, %cl
incl %r12d
jmp 0x3beb
movq 0xce8(%r12), %r12
testq %r12, %r12
jne 0x3a37
leaq 0x20(%rsp), %r12
movq 0x8(%rsp), %rbp
testq %rbp, %rbp
je 0x3d08
leaq 0x46cc(%rip), %rdi      # 0x82f1
pushq $0x9
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x2300
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x3d37
movl 0x14(%rbp), %edx
movl 0x18(%rbp), %ecx
movq %rbx, %rdi
leaq 0x46ad(%rip), %rsi      # 0x82fb
xorl %eax, %eax
callq 0x21c0
pushq $0x1a
popq %r14
xorl %r13d, %r13d
movq %rbp, %r15
movslq 0x14(%rbp), %rax
cmpq %rax, %r13
jge 0x3cff
movq 0x20(%rbp), %rax
leaq (%rax,%r14), %rsi
addq $-0x12, %rsi
movzwl 0x10(%rsi), %eax
cmpl $0x10, %eax
je 0x3c99
cmpl $0x4, %eax
jne 0x3cc2
pushq $0x2
popq %rdi
movq %r12, %rdx
pushq $0x64
popq %rcx
callq 0x2030
movq %r15, %rbp
jmp 0x3cca
movb $0x5b, 0x20(%rsp)
pushq $0xa
popq %rdi
leaq 0x21(%rsp), %rdx
pushq $0x62
popq %rcx
callq 0x2030
movq %r12, %rdi
callq 0x20f0
movq %r15, %rbp
movw $0x5d, 0x20(%rsp,%rax)
jmp 0x3cca
movl $0x3f3f3f, 0x20(%rsp)   # imm = 0x3F3F3F
movq 0x20(%rbp), %rax
movzwl (%rax,%r14), %ecx
movq 0x9f36(%rip), %r8       # 0xdc10
subq -0x1a(%rax,%r14), %r8
movq %rbx, %rdi
leaq 0x4620(%rip), %rsi      # 0x8309
movq %r12, %rdx
xorl %eax, %eax
callq 0x21c0
incq %r13
addq $0x20, %r14
jmp 0x3c5f
movq 0x28(%rbp), %rbp
jmp 0x3c15
leaq 0x4607(%rip), %rdi      # 0x8316
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
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