// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Overlaps.cpp
// Function: load_hc_trans(char const*)
trans_chain* load_hc_trans(const char *fn)
{
    uint64_t flag = 0;
    char *buf = (char*)calloc(strlen(fn) + 25, 1);
    sprintf(buf, "%s.hic.trans.bin", fn);

    FILE* fp = NULL; 
    fp = fopen(buf, "r"); 
    if(!fp) return NULL;

    trans_chain *t_ch = NULL;
    CALLOC(t_ch, 1);

    flag += fread(&t_ch->r_num, sizeof(t_ch->r_num), 1, fp);
    MALLOC(t_ch->ir_het, t_ch->r_num);
    flag += fread(t_ch->ir_het, sizeof(uint8_t), t_ch->r_num, fp);

    uint32_t i;
    flag += fread(&t_ch->bed.n, sizeof(t_ch->bed.n), 1, fp);
    MALLOC(t_ch->bed.a, t_ch->bed.n); t_ch->bed.m = t_ch->bed.n;
    for (i = 0; i < t_ch->bed.n; i++)
    {
        flag += fread(&t_ch->bed.a[i].n, sizeof(t_ch->bed.a[i].n), 1, fp);
        MALLOC(t_ch->bed.a[i].a, t_ch->bed.a[i].n); t_ch->bed.a[i].m = t_ch->bed.a[i].n;
        flag += fread(t_ch->bed.a[i].a, sizeof(bed_interval), t_ch->bed.a[i].n, fp);
    }

    flag += fread(&t_ch->k_trans.n, sizeof(t_ch->k_trans.n), 1, fp);
    MALLOC(t_ch->k_trans.a, t_ch->k_trans.n); t_ch->k_trans.m = t_ch->k_trans.n;
    flag += fread(t_ch->k_trans.a, sizeof(u_trans_t), t_ch->k_trans.n, fp);

    flag += fread(&t_ch->k_trans.idx.n, sizeof(t_ch->k_trans.idx.n), 1, fp);
    MALLOC(t_ch->k_trans.idx.a, t_ch->k_trans.idx.n); t_ch->k_trans.idx.m = t_ch->k_trans.idx.n;
    flag += fread(t_ch->k_trans.idx.a, sizeof(uint64_t), t_ch->k_trans.idx.n, fp);


    fclose(fp);
    free(buf);
    fprintf(stderr, "[M::%s::] ==> Hi-C cov have been loaded\n", __func__);
    return t_ch;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
callq 0x2090
leaq 0x19(%rax), %rdi
pushq $0x1
popq %rsi
callq 0x2120
movq %rax, %r12
leaq 0x164752(%rip), %rsi    # 0x1e898f
xorl %ebx, %ebx
movq %rax, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x16d464(%rip), %rsi    # 0x1f16b7
movq %r12, %rdi
callq 0x2210
testq %rax, %rax
jne 0x84275
xorl %r13d, %r13d
movq %r13, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
movq %r12, 0x10(%rsp)
pushq $0x1
popq %r12
movl $0x1d0, %esi            # imm = 0x1D0
movq %r12, %rdi
callq 0x2120
movq %rax, %r13
leaq 0x18(%rax), %rdi
pushq $0x4
popq %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x22f0
movl 0x18(%r13), %r14d
movq %r14, %rdi
callq 0x2280
movq %rax, 0x10(%r13)
movq %rax, %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %r15, %rcx
callq 0x22f0
leaq 0x20(%r13), %rdi
pushq $0x8
popq %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x22f0
movq 0x20(%r13), %r12
imulq $0x18, %r12, %rdi
callq 0x2280
movq %rax, %rbp
movq %rax, 0x30(%r13)
movq %r13, 0x8(%rsp)
movq %r12, 0x28(%r13)
jmp 0x8433b
imulq $0x18, %r13, %r14
leaq (%r14,%rbp), %rdi
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
movq %r15, %rcx
callq 0x22f0
movq (%rbp,%r14), %rbx
movq %rbx, %rdi
shlq $0x4, %rdi
callq 0x2280
movq %rax, 0x10(%rbp,%r14)
movq %rbx, 0x8(%rbp,%r14)
movq %rax, %rdi
pushq $0x10
popq %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x22f0
leal 0x1(%r13), %ebx
movl %ebx, %r13d
cmpq %r13, %r12
ja 0x842f5
movq 0x8(%rsp), %r13
leaq 0x138(%r13), %rdi
pushq $0x8
popq %r12
pushq $0x1
popq %rbx
movq %r12, %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x22f0
movq 0x138(%r13), %r14
imulq $0x30, %r14, %rdi
callq 0x2280
movq %rax, 0x148(%r13)
movq %r14, 0x140(%r13)
pushq $0x30
popq %rsi
movq %rax, %rdi
movq %r14, %rdx
movq %r15, %rcx
callq 0x22f0
movq %r13, %rdi
addq $0x150, %rdi            # imm = 0x150
movq %r12, %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x22f0
movq 0x150(%r13), %rbx
leaq (,%rbx,8), %rdi
callq 0x2280
movq %rax, 0x160(%r13)
movq %rbx, 0x158(%r13)
movq %rax, %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x22f0
movq %r15, %rdi
callq 0x2190
movq 0x10(%rsp), %rdi
callq 0x2220
movq 0x1cebe9(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
leaq 0x16459f(%rip), %rsi    # 0x1e89a0
leaq 0x1645c1(%rip), %rdx    # 0x1e89c9
xorl %eax, %eax
callq 0x22b0
jmp 0x84263