// File: /workspace/github_c_makefile_star2_O1/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 0x9f98(%rip), %rax      # 0xdc60
movq %rax, 0x8(%rsp)
movq 0x9f34(%rip), %r14      # 0xdc08
leaq 0x55b3(%rip), %rdi      # 0x928e
movl $0x6, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2300
leaq 0x9f3c(%rip), %r12      # 0xdc30
leaq 0x5a2c(%rip), %r15      # 0x9727
xorl %r13d, %r13d
movzbl (%r13,%r12), %edx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x21c0
incq %r13
cmpq $0x14, %r13
jne 0x3cfe
movl $0xa, %edi
movq %rbx, %rsi
callq 0x2170
movq 0x9f22(%rip), %r15      # 0xdc50
testq %r15, %r15
je 0x3d47
movq %rbx, %rdi
movq %r15, %rsi
callq 0x40f6
movq 0xb8(%r15), %r15
jmp 0x3d2e
movl $0xa, %edi
movq %rbx, %rsi
callq 0x2170
movq 0x9efd(%rip), %r15      # 0xdc58
testq %r15, %r15
je 0x3d74
movq %rbx, %rdi
movq %r15, %rsi
callq 0x40f6
movq 0xb8(%r15), %r15
jmp 0x3d5b
testq %r14, %r14
je 0x3f7b
leaq 0x59a3(%rip), %r15      # 0x9727
cmpl $0xa, 0x4(%r14)
leaq 0x5598(%rip), %rdx      # 0x9328
leaq 0x550c(%rip), %rax      # 0x92a3
cmoveq %rax, %rdx
movq %rbx, %rdi
leaq 0x54f0(%rip), %rsi      # 0x9295
xorl %eax, %eax
callq 0x21c0
movq $-0x14, %r12
movzbl 0x24(%r14,%r12), %edx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x21c0
incq %r12
jne 0x3db3
movl 0x9e3f(%rip), %edx      # 0xdc10
subl 0x8(%r14), %edx
cmpl $0x0, 0x28(%r14)
leaq 0x54d5(%rip), %rcx      # 0x92b6
leaq 0x5540(%rip), %rax      # 0x9328
cmoveq %rax, %rcx
movq %rbx, %rdi
leaq 0x54b5(%rip), %rsi      # 0x92ab
xorl %eax, %eax
callq 0x21c0
cmpl $0x0, 0xce0(%r14)
jle 0x3f6b
leaq 0x30(%r14), %r12
movq %r12, 0x10(%rsp)
xorl %edx, %edx
imulq $0xe8, %rdx, %rbp
addq 0x10(%rsp), %rbp
movq %rbx, %rdi
leaq 0x5492(%rip), %rsi      # 0x92be
movq %rdx, 0x18(%rsp)
xorl %eax, %eax
callq 0x21c0
movq $-0x14, %r13
movzbl 0x14(%r12,%r13), %edx
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x21c0
incq %r13
jne 0x3e3f
xorl %eax, %eax
movb 0x10(%r14,%rax), %cl
cmpb (%r12,%rax), %cl
jne 0x3e72
incq %rax
cmpq $0x14, %rax
jne 0x3e59
movl $0x14, %eax
movl $0xa0, %edx
cmpl $0x14, %eax
je 0x3e9a
movl %eax, %ecx
movb (%rbp,%rcx), %dl
xorb 0x10(%r14,%rcx), %dl
js 0x3e95
xorl %ecx, %ecx
addb %dl, %dl
incl %ecx
testb %dl, %dl
jns 0x3e8b
jmp 0x3e97
xorl %ecx, %ecx
leal (%rcx,%rax,8), %edx
movq %rbx, %rdi
leaq 0x5426(%rip), %rsi      # 0x92ca
xorl %eax, %eax
callq 0x21c0
movq 0xa0(%rbp), %rax
testq %rax, %rax
je 0x3ed0
movl 0x9d53(%rip), %edx      # 0xdc10
subl %eax, %edx
movq %rbx, %rdi
leaq 0x540f(%rip), %rsi      # 0x92d8
xorl %eax, %eax
callq 0x21c0
movl 0x9d3a(%rip), %edx      # 0xdc10
subl 0xa8(%rbp), %edx
movq %rbx, %rdi
leaq 0x53f7(%rip), %rsi      # 0x92dd
xorl %eax, %eax
callq 0x21c0
movl 0xb0(%rbp), %edx
testl %edx, %edx
je 0x3f08
movq %rbx, %rdi
leaq 0x53df(%rip), %rsi      # 0x92e0
xorl %eax, %eax
callq 0x21c0
movl 0x4(%r14), %esi
movq %rbp, %rdi
callq 0x4354
testq %rax, %rax
leaq 0x53cf(%rip), %rdx      # 0x92ed
leaq 0x5403(%rip), %rax      # 0x9328
cmoveq %rax, %rdx
cmpl $0x0, 0xe0(%rbp)
leaq 0x53bf(%rip), %rcx      # 0x92f6
cmoveq %rax, %rcx
movq %rbx, %rdi
leaq 0x53a1(%rip), %rsi      # 0x92e6
xorl %eax, %eax
callq 0x21c0
movq 0x18(%rsp), %rdx
incq %rdx
movslq 0xce0(%r14), %rax
addq $0xe8, %r12
cmpq %rax, %rdx
jl 0x3e16
movq 0xce8(%r14), %r14
testq %r14, %r14
jne 0x3d84
movq 0x8(%rsp), %r12
testq %r12, %r12
je 0x40c3
leaq 0x5797(%rip), %r15      # 0x9727
leaq 0x20(%rsp), %rbp
movl $0x9, %esi
movl $0x1, %edx
leaq 0x535b(%rip), %rdi      # 0x9301
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 0x3fb1
movl 0x14(%r12), %edx
movl 0x18(%r12), %ecx
movq %rbx, %rdi
leaq 0x532b(%rip), %rsi      # 0x930b
xorl %eax, %eax
callq 0x21c0
cmpl $0x0, 0x14(%r12)
movq %r12, %r15
jle 0x40ac
movl $0x1a, %r12d
xorl %r14d, %r14d
movq %r15, %r13
movq 0x20(%r15), %rax
movzwl -0x2(%rax,%r12), %ecx
cmpl $0x10, %ecx
je 0x4032
cmpl $0x4, %ecx
jne 0x4064
leaq (%rax,%r12), %rsi
addq $-0x12, %rsi
movl $0x2, %edi
movq %rbp, %rdx
movl $0x64, %ecx
callq 0x2030
jmp 0x406c
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 0x406c
movl $0x3f3f3f, 0x20(%rsp)   # imm = 0x3F3F3F
movq %r13, %r15
movq 0x20(%r13), %rax
movzwl (%rax,%r12), %ecx
movq 0x9b91(%rip), %r8       # 0xdc10
subq -0x1a(%rax,%r12), %r8
movq %rbx, %rdi
leaq 0x528b(%rip), %rsi      # 0x9319
movq %rbp, %rdx
xorl %eax, %eax
callq 0x21c0
incq %r14
movslq 0x14(%r13), %rax
addq $0x20, %r12
cmpq %rax, %r14
jl 0x3fff
movq 0x28(%r15), %r15
testq %r15, %r15
movq %r15, %r12
leaq 0x566a(%rip), %r15      # 0x9727
jne 0x3f95
leaq 0x525c(%rip), %rdi      # 0x9326
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