// File: /workspace/github_c_makefile_star2_O0/desion[P]terminal/src/hdict.c
// Function: hdb_append
int hdb_append(hdb_t *hdb, const char *hdict_path){
    hdict_t *hd, *ihd = NULL;
    char rpath[1024];
    realpath(hdict_path, rpath);

    int hdict_errno = 0;
    hdict_t *hdict = hdict_open(rpath, &hdict_errno);
    if(NULL == hdict) return hdict_errno;
    LOCK(hdb);
    //use the label to generate hash id
    uint64_t key_hash = bkdr_hash(hdict->hdict_meta->label);
    uint32_t hash = HASH(key_hash);
    for (hd = LIST_FIRST(&hdb->htab[hash]); hd; hd = LIST_NEXT(hd, h_link)) {
        if (hd->hdict_meta->version <= hdict->hdict_meta->version) {
            ihd = hd;
            break;
        }
    }
    hdict->hdid = key_hash;
    TAILQ_INSERT_TAIL(&hdb->open_list, hdict, link);
    if(NULL == ihd){
        LIST_INSERT_HEAD(&hdb->htab[hash], hdict, h_link);
    }else{
        LIST_INSERT_BEFORE(ihd, hdict, h_link);
    }
    hdb->num_open++;
    UNLK(hdb);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x450, %rsp            # imm = 0x450
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x430(%rbp), %rsi
callq 0x2290
movl $0x0, -0x434(%rbp)
leaq -0x430(%rbp), %rdi
leaq -0x434(%rbp), %rsi
callq 0x2650
movq %rax, -0x440(%rbp)
xorl %eax, %eax
cmpq -0x440(%rbp), %rax
jne 0x32b8
movl -0x434(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3478
movq -0x10(%rbp), %rdi
callq 0x2490
movq -0x440(%rbp), %rax
movq 0x58(%rax), %rdi
addq $0x5, %rdi
callq 0x5170
movq %rax, -0x448(%rbp)
movq -0x448(%rbp), %rax
andq $0x3ff, %rax            # imm = 0x3FF
movl %eax, -0x44c(%rbp)
movq -0x10(%rbp), %rax
movl -0x44c(%rbp), %ecx
movq 0x50(%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x333c
movq -0x20(%rbp), %rax
movq 0x58(%rax), %rax
movl (%rax), %eax
movq -0x440(%rbp), %rcx
movq 0x58(%rcx), %rcx
cmpl (%rcx), %eax
ja 0x332c
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x333c
jmp 0x332e
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x3302
movq -0x448(%rbp), %rcx
movq -0x440(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x440(%rbp), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rcx
movq -0x440(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x440(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq %rcx, (%rax)
movq -0x440(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x30(%rax)
xorl %eax, %eax
cmpq -0x28(%rbp), %rax
jne 0x3410
jmp 0x339a
movq -0x10(%rbp), %rax
movl -0x44c(%rbp), %ecx
movq 0x50(%rax,%rcx,8), %rax
movq -0x440(%rbp), %rcx
movq %rax, 0x10(%rcx)
cmpq $0x0, %rax
je 0x33d8
movq -0x440(%rbp), %rcx
addq $0x10, %rcx
movq -0x10(%rbp), %rax
movl -0x44c(%rbp), %edx
movq 0x50(%rax,%rdx,8), %rax
movq %rcx, 0x18(%rax)
movq -0x440(%rbp), %rdx
movq -0x10(%rbp), %rax
movl -0x44c(%rbp), %ecx
movq %rdx, 0x50(%rax,%rcx,8)
movq -0x10(%rbp), %rcx
addq $0x50, %rcx
movl -0x44c(%rbp), %eax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x440(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x345b
jmp 0x3412
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x440(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x28(%rbp), %rcx
movq -0x440(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x440(%rbp), %rcx
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movq %rcx, (%rax)
movq -0x440(%rbp), %rcx
addq $0x10, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x345b
movq -0x10(%rbp), %rax
movl 0x48(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x48(%rax)
movq -0x10(%rbp), %rdi
callq 0x22d0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x450, %rsp            # imm = 0x450
popq %rbp
retq
nopw %cs:(%rax,%rax)