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

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

    kv_init(link->a);
    flag += fread(&link->a.n, sizeof(link->a.n), 1, fp);
    link->a.m = link->a.n; CALLOC(link->a.a, link->a.n);
    for (k = 0; k < link->a.n; k++)
    {
        flag += fread(&link->a.a[k].e.n, sizeof(link->a.a[k].e.n), 1, fp);
        link->a.a[k].e.m = link->a.a[k].e.n; MALLOC(link->a.a[k].e.a, link->a.a[k].e.n);
        flag += fread(link->a.a[k].e.a, sizeof(hc_edge), link->a.a[k].e.n, fp);

        flag += fread(&link->a.a[k].f.n, sizeof(link->a.a[k].f.n), 1, fp);
        link->a.a[k].f.m = link->a.a[k].f.n; MALLOC(link->a.a[k].f.a, link->a.a[k].f.n);
        flag += fread(link->a.a[k].f.a, sizeof(hc_edge), link->a.a[k].f.n, fp);
    }

    kv_init(link->enzymes);
    flag += fread(&link->enzymes.n, sizeof(link->enzymes.n), 1, fp);
    link->enzymes.m = link->enzymes.n; MALLOC(link->enzymes.a, link->enzymes.n);
    flag += fread(link->enzymes.a, sizeof(uint64_t), link->enzymes.n, fp);

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r13
movq %rsi, %rdi
callq 0x2090
leaq 0x19(%rax), %rdi
pushq $0x1
popq %rsi
callq 0x2120
movq %rax, %r12
leaq 0xeed70(%rip), %rsi     # 0x1ed699
xorl %ebp, %ebp
movq %rax, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0xf2d78(%rip), %rsi     # 0x1f16b7
movq %r12, %rdi
callq 0x2210
testq %rax, %rax
jne 0xfe965
movq %r12, %rdi
callq 0x2220
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, 0x8(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%r13)
andq $0x0, 0x10(%r13)
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
movq %r13, %rdi
movq %rax, (%rsp)
movq %rax, %rcx
callq 0x22f0
movq (%r13), %rbx
movq %rbx, 0x8(%r13)
pushq $0x30
popq %rsi
movq %rbx, %rdi
callq 0x2120
movq %rax, 0x10(%r13)
xorl %r12d, %r12d
xorl %eax, %eax
pushq $0x8
popq %r15
movq (%rsp), %r14
jmp 0xfea53
movq 0x10(%r13), %rdi
addq %r12, %rdi
movq %r15, %rsi
movq %rax, 0x10(%rsp)
pushq $0x1
popq %rdx
movq %r14, %rcx
callq 0x22f0
movq 0x10(%r13), %rbp
movq (%rbp,%r12), %rbx
movq %rbx, 0x8(%rbp,%r12)
imulq $0x28, %rbx, %rdi
callq 0x2280
movq %rax, 0x10(%rbp,%r12)
movq %rax, %rdi
pushq $0x28
popq %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x22f0
movq 0x10(%r13), %rax
leaq (%rax,%r12), %rdi
addq $0x18, %rdi
movq %r15, %rsi
pushq $0x1
popq %rdx
movq %r14, %rcx
callq 0x22f0
movq 0x10(%r13), %rbp
movq 0x18(%rbp,%r12), %rbx
movq %rbx, 0x20(%rbp,%r12)
imulq $0x28, %rbx, %rdi
callq 0x2280
movq %rax, 0x28(%rbp,%r12)
movq %rax, %rdi
pushq $0x28
popq %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x22f0
movq 0x10(%rsp), %rax
incq %rax
movq (%r13), %rbx
addq $0x30, %r12
cmpq %rbx, %rax
jb 0xfe9b5
leaq 0x18(%r13), %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%r13)
andq $0x0, 0x28(%r13)
pushq $0x8
popq %rbx
pushq $0x1
popq %rdx
movq %rbx, %rsi
movq (%rsp), %r14
movq %r14, %rcx
callq 0x22f0
movq 0x18(%r13), %r12
movq %r12, 0x20(%r13)
leaq (,%r12,8), %rdi
callq 0x2280
movq %rax, 0x28(%r13)
movq %rax, %rdi
movq %rbx, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x22f0
movq %r14, %rdi
callq 0x2190
movq 0x8(%rsp), %rdi
callq 0x2220
movq 0x15451b(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
leaq 0xeec18(%rip), %rsi     # 0x1ed6e7
leaq 0xeec3f(%rip), %rdx     # 0x1ed715
xorl %eax, %eax
callq 0x22b0
pushq $0x1
popq %rbp
jmp 0xfe954