// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/hic.cpp
// Function: write_hc_pt_index(ha_ug_index*, char*)
int write_hc_pt_index(ha_ug_index* idx, char* file_name)
{
    char* gfa_name = (char*)malloc(strlen(file_name)+25);
    sprintf(gfa_name, "%s.hic.tlb.bin", file_name);
    FILE* fp = fopen(gfa_name, "w");
    if (!fp) {
        free(gfa_name);
        return 0;
    }
    uint64_t i = HC_PT_MA;

    fwrite(&i, sizeof(i), 1, fp);
    fwrite(&idx->uID_bits, sizeof(idx->uID_bits), 1, fp);
    fwrite(&idx->uID_mode, sizeof(idx->uID_mode), 1, fp);
    fwrite(&idx->pos_bits, sizeof(idx->pos_bits), 1, fp);
    fwrite(&idx->pos_mode, sizeof(idx->pos_mode), 1, fp);
    fwrite(&idx->rev_mode, sizeof(idx->rev_mode), 1, fp);
    fwrite(&idx->k, sizeof(idx->k), 1, fp);
    fwrite(&idx->pre, sizeof(idx->pre), 1, fp);
    fwrite(&idx->tot, sizeof(idx->tot), 1, fp);
    fwrite(&idx->tot_pos, sizeof(idx->tot_pos), 1, fp);

    for (i = 0; i < idx->tot; i++)
    {
        fwrite(&idx->idx_buf[i].n, sizeof(idx->idx_buf[i].n), 1, fp);
        fwrite(&idx->idx_buf[i].end, sizeof(idx->idx_buf[i].end), 1, fp);
        fwrite(idx->idx_buf[i].a, sizeof(uint64_t), idx->idx_buf[i].n, fp);
        hc_pt_save(idx->idx_buf[i].h, fp);
    }

    write_dbug(idx->ug, fp);

    fprintf(stderr, "[M::%s] Index has been written.\n", __func__);
    free(gfa_name);
    fclose(fp);
    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %r14
movq %rsi, %rdi
callq 0x2090
leaq 0x19(%rax), %rdi
callq 0x2280
movq %rax, %rbx
leaq 0xfa86a(%rip), %rsi     # 0x22f0b4
xorl %ebp, %ebp
movq %rax, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x107b9e(%rip), %rsi    # 0x23c3fe
movq %rbx, %rdi
callq 0x2210
testq %rax, %rax
jne 0x134886
movq %rbx, %rdi
callq 0x2220
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
movq %rsp, %rdi
movq $0x41, (%rdi)
movl $0x8, %esi
movl $0x1, %edx
movq %rax, %rcx
callq 0x2410
leaq 0x18(%r14), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2410
leaq 0x20(%r14), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2410
leaq 0x28(%r14), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2410
leaq 0x30(%r14), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2410
leaq 0x38(%r14), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2410
leaq 0x40(%r14), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2410
leaq 0x50(%r14), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2410
leaq 0x58(%r14), %r12
movl $0x8, %esi
movl $0x1, %edx
movq %r12, %rdi
movq %r15, %rcx
callq 0x2410
leaq 0x60(%r14), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2410
cmpq $0x0, 0x58(%r14)
jne 0x1349c0
xorl %r13d, %r13d
movq %r13, (%rsp)
movq (%r14), %rdi
movq %r15, %rsi
callq 0xc293c
movq 0x155652(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
leaq 0xf96da(%rip), %rsi     # 0x22e072
leaq 0xfa724(%rip), %rdx     # 0x22f0c3
xorl %eax, %eax
callq 0x22b0
movq %rbx, %rdi
callq 0x2220
movq %r15, %rdi
callq 0x2190
movl $0x1, %ebp
jmp 0x134875
movl $0x18, %ebp
xorl %r13d, %r13d
movq 0x78(%r14), %rax
leaq (%rax,%rbp), %rdi
addq $-0x10, %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2410
movq 0x78(%r14), %rdi
addq %rbp, %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2410
movq 0x78(%r14), %rax
movq -0x10(%rax,%rbp), %rdx
movq -0x8(%rax,%rbp), %rdi
movl $0x8, %esi
movq %r15, %rcx
callq 0x2410
movq 0x78(%r14), %rax
movq -0x18(%rax,%rbp), %rdi
testq %rdi, %rdi
jne 0x134a3a
incq %r13
addq $0x20, %rbp
cmpq (%r12), %r13
jb 0x1349c8
jmp 0x134978
movq %r15, %rsi
callq 0x1c7f7
jmp 0x134a28