// File: /workspace/github_c_makefile_star2_O1/desion[P]terminal/src/hdict.c
// Function: hdb_info
int hdb_info(hdb_t *hdb, char *buf, int size)
{
    int len = 0;
    len += snprintf(buf+len, size-len, "%2s %20s %10s %5s %3s %9s %8s %13s %s\n", 
            "id", "label", "version", "state", "ref", "num_qry", "idx_num", "open_time", "path");
    if (len < size) 
        len += snprintf(buf+len, size-len, "---------------------------------------------------------------------------------------\n");
    int pass, k;
    hdict_t *hdict;
    LOCK(hdb);
    for (pass = 0; pass < 2; ++pass) {
        const char *state;
        struct hdict_list_t *hlist;
        switch (pass) {
        case 0:
            state = "OPEN";
            hlist = &hdb->open_list;
            break;
        case 1:
            state = "CLOSE";
            hlist = &hdb->close_list;
            break;
        default:
            state = NULL;
            hlist = NULL;
        }

        k = 0;
        for (hdict = TAILQ_FIRST(hlist); hdict; hdict = TAILQ_NEXT(hdict, link)) {
            ++k;
            if (len < size) {
                struct tm tm;
                localtime_r(&hdict->open_time, &tm);
                len += snprintf(buf+len, size-len, "%2lu %20s %u %5s %2d %10d %8d %02d%02d%02d-%02d%02d%02d %s\n",
                    hdict->hdid,
                    hdict->hdict_meta->label,
                    hdict->hdict_meta->version,
                    state,
                    hdict->ref,
                    hdict->num_qry,
                    hdict->idx_num,
                    tm.tm_year - 100, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec,
                    hdict->path);
            }
        }
    }
    UNLK(hdb);
    return len;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %edx, %ebp
movq %rdi, (%rsp)
movslq %edx, %r12
leaq 0x262c(%rip), %r10      # 0x5933
leaq 0x261b(%rip), %r11      # 0x5929
leaq 0x260c(%rip), %rbx      # 0x5921
leaq 0x25fd(%rip), %r14      # 0x5919
leaq 0x25f2(%rip), %r15      # 0x5915
leaq 0x25e5(%rip), %r13      # 0x590f
leaq 0x25a6(%rip), %rdx      # 0x58d7
leaq 0x25c6(%rip), %rcx      # 0x58fe
leaq 0x25c2(%rip), %r8       # 0x5901
leaq 0x25c1(%rip), %r9       # 0x5907
movq %rsi, 0x10(%rsp)
movq %rsi, %rdi
movq %r12, %rsi
xorl %eax, %eax
pushq %r10
pushq %r11
pushq %rbx
pushq %r14
pushq %r15
pushq %r13
callq 0x2160
addq $0x30, %rsp
movl %eax, %r14d
subl %eax, %r12d
jle 0x338b
movslq %r14d, %rdi
addq 0x10(%rsp), %rdi
movslq %r12d, %rsi
leaq 0x25b7(%rip), %rdx      # 0x5938
xorl %eax, %eax
callq 0x2160
addl %eax, %r14d
movq (%rsp), %rdi
callq 0x2470
xorl %ecx, %ecx
testb $0x1, %cl
leaq 0x25f1(%rip), %rdx      # 0x5991
leaq 0x25ef(%rip), %rax      # 0x5996
cmovneq %rax, %rdx
movq %rdx, 0x20(%rsp)
movq %rcx, 0x18(%rsp)
movl %ecx, %eax
andl $0x1, %eax
shll $0x4, %eax
movq (%rsp), %rcx
movq 0x28(%rcx,%rax), %r13
testq %r13, %r13
je 0x3491
movl %ebp, %ebx
subl %r14d, %ebx
jle 0x3488
leaq 0x40(%r13), %rdi
leaq 0x40(%rsp), %rsi
callq 0x2080
movslq %r14d, %rdi
addq 0x10(%rsp), %rdi
movslq %ebx, %rsi
movq 0x50(%r13), %rcx
movq 0x58(%r13), %r8
movl (%r8), %r9d
addq $0x5, %r8
movl 0x4c(%r13), %eax
movq %rax, 0x38(%rsp)
movl 0x48(%r13), %eax
movq %rax, 0x30(%rsp)
movl 0x28(%r13), %eax
movq %rax, 0x28(%rsp)
movl 0x54(%rsp), %ebx
addl $-0x64, %ebx
movl %r14d, 0xc(%rsp)
movl %ebp, %r14d
movl 0x50(%rsp), %ebp
incl %ebp
movl 0x4c(%rsp), %r12d
movl 0x48(%rsp), %r15d
movl 0x40(%rsp), %r10d
movl 0x44(%rsp), %r11d
subq $0x8, %rsp
leaq 0x254b(%rip), %rdx      # 0x599c
xorl %eax, %eax
pushq 0x20(%r13)
pushq %r10
pushq %r11
pushq %r15
pushq %r12
pushq %rbp
movl %r14d, %ebp
movl 0x44(%rsp), %r14d
pushq %rbx
pushq 0x68(%rsp)
pushq 0x78(%rsp)
pushq 0x88(%rsp)
pushq 0x78(%rsp)
callq 0x2160
addq $0x60, %rsp
addl %eax, %r14d
movq (%r13), %r13
jmp 0x33c6
movq 0x18(%rsp), %rcx
leal 0x1(%rcx), %eax
testl %ecx, %ecx
movl %eax, %ecx
je 0x3396
movq (%rsp), %rdi
callq 0x22b0
movl %r14d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq