// File: /workspace/github_c_makefile_star2_O2/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 0x2996(%rip), %r10      # 0x5943
leaq 0x2985(%rip), %r11      # 0x5939
leaq 0x2976(%rip), %rbx      # 0x5931
leaq 0x2967(%rip), %r14      # 0x5929
leaq 0x295c(%rip), %r15      # 0x5925
leaq 0x294f(%rip), %r13      # 0x591f
leaq 0x2910(%rip), %rdx      # 0x58e7
leaq 0x2930(%rip), %rcx      # 0x590e
leaq 0x292c(%rip), %r8       # 0x5911
leaq 0x292b(%rip), %r9       # 0x5917
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, %r15d
subl %eax, %r12d
jle 0x3031
movslq %r15d, %rdi
addq 0x10(%rsp), %rdi
movslq %r12d, %rsi
leaq 0x2921(%rip), %rdx      # 0x5948
xorl %eax, %eax
callq 0x2160
addl %eax, %r15d
movq (%rsp), %rdi
callq 0x2460
xorl %edx, %edx
cmpl $0x2, %edx
je 0x3141
testb $0x1, %dl
leaq 0x2952(%rip), %r13      # 0x59a1
leaq 0x2950(%rip), %rax      # 0x59a6
cmovneq %rax, %r13
movl %edx, %eax
andl $0x1, %eax
shll $0x4, %eax
movq (%rsp), %rcx
leaq (%rcx,%rax), %r14
addq $0x28, %r14
movq (%r14), %r14
testq %r14, %r14
je 0x313a
movl %ebp, %ebx
subl %r15d, %ebx
jle 0x306e
leaq 0x40(%r14), %rdi
leaq 0x40(%rsp), %rsi
movl %edx, 0xc(%rsp)
callq 0x2080
movslq %r15d, %rdi
addq 0x10(%rsp), %rdi
movslq %ebx, %rsi
movq 0x50(%r14), %rcx
movq 0x58(%r14), %r8
movl (%r8), %r9d
addq $0x5, %r8
movl 0x4c(%r14), %eax
movq %rax, 0x38(%rsp)
movl 0x48(%r14), %eax
movq %rax, 0x30(%rsp)
movl 0x28(%r14), %eax
movq %rax, 0x28(%rsp)
movl 0x54(%rsp), %r10d
addl $-0x64, %r10d
movl 0x50(%rsp), %r11d
incl %r11d
movl 0x4c(%rsp), %eax
movq %rax, 0x20(%rsp)
movl 0x48(%rsp), %eax
movq %rax, 0x18(%rsp)
movl 0x40(%rsp), %r12d
movl 0x44(%rsp), %ebx
subq $0x8, %rsp
leaq 0x28ad(%rip), %rdx      # 0x59ac
xorl %eax, %eax
pushq 0x20(%r14)
pushq %r12
pushq %rbx
pushq 0x38(%rsp)
pushq 0x48(%rsp)
pushq %r11
pushq %r10
pushq 0x68(%rsp)
pushq 0x78(%rsp)
pushq 0x88(%rsp)
pushq %r13
callq 0x2160
movl 0x6c(%rsp), %edx
addq $0x60, %rsp
addl %eax, %r15d
jmp 0x306e
incl %edx
jmp 0x303c
movq (%rsp), %rdi
callq 0x22a0
movl %r15d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq