// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: reload_uovl(all_ul_t*, char*)
int64_t reload_uovl(all_ul_t *x, char* file_name)
{
    char* gfa_name = NULL; MALLOC(gfa_name, strlen(file_name)+100);
    sprintf(gfa_name, "%s.%s.ul.ovlp.bin", file_name, "re");
    FILE* fp = fopen(gfa_name, "r"); free(gfa_name);
    if (!fp) return 0;
    uint64_t k; size_t kn; ul_vec_t *p = NULL;

    ///skip test ug
    size_t tt, i; uint32_t t; ma_utg_t ua;
    fread(&tt, sizeof(tt), 1, fp);
    for (i = 0; i < tt; i++) {
        fread(&t, sizeof(t), 1, fp);
        fread(&t, sizeof(t), 1, fp);
        fread(&(ua.start), sizeof(ua.start), 1, fp);
        fread(&(ua.end), sizeof(ua.end), 1, fp);
        fread(&(ua.n), sizeof(ua.n), 1, fp);
        fseek(fp, sizeof(uint64_t)*ua.n, SEEK_CUR);
        // fread(ua.a, sizeof(uint64_t), ua.n, fp);
    }



    fseek(fp, sizeof(x->nid.n), SEEK_CUR);
	for (k = 0; k < x->nid.n; k++) {
        fseek(fp, sizeof(x->nid.a[k].n), SEEK_CUR); 
        fseek(fp, sizeof((*(x->nid.a[k].a)))*x->nid.a[k].n, SEEK_CUR);
	}

    // free(x->ridx.idx.a); x->ridx.idx.a = NULL;
    fread(&kn, sizeof(kn), 1, fp); 
    fseek(fp, sizeof((*(x->ridx.idx.a)))*kn, SEEK_CUR);

    // free(x->ridx.occ.a); x->ridx.occ.a = NULL;
    fread(&kn, sizeof(kn), 1, fp); 
    fseek(fp, sizeof((*(x->ridx.occ.a)))*kn, SEEK_CUR);

    fread(&x->n, sizeof(x->n), 1, fp); assert(x->nid.n == x->n);
    if(x->n > x->m) kv_resize(ul_vec_t, *x, x->n);    
    fprintf(stderr, "[M::%s] x->n::%u, x->nid.n::%u\n", __func__, (uint32_t)x->n, (uint32_t)x->nid.n);
    for (k = 0; k < x->n; k++) {
        p = &(x->a[k]);
        fread(&p->dd, sizeof(p->dd), 1, fp);
        fread(&p->rlen, sizeof(p->rlen), 1, fp);

        fread(&p->r_base.n, sizeof(p->r_base.n), 1, fp); 
        if(p->r_base.n > p->r_base.m) kv_resize(uint8_t, p->r_base, p->r_base.n);        
        fread(p->r_base.a, sizeof((*(p->r_base.a))), p->r_base.n, fp);

        fread(&p->bb.n, sizeof(p->bb.n), 1, fp); 
        if(p->bb.n > p->bb.m) kv_resize(uc_block_t, p->bb, p->bb.n);
        fread(p->bb.a, sizeof((*(p->bb.a))), p->bb.n, fp);

        fread(&p->N_site.n, sizeof(p->N_site.n), 1, fp); 
        if(p->N_site.n > p->N_site.m) kv_resize(uint32_t, p->N_site, p->N_site.n);        
        fread(p->N_site.a, sizeof((*(p->N_site.a))), p->N_site.n, fp);
    }
    fclose(fp);
    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x2090
leaq 0x64(%rax), %rdi
callq 0x2280
movq %rax, %r12
leaq 0x282dd(%rip), %rsi     # 0x249b03
leaq 0x217f0(%rip), %rcx     # 0x24301d
xorl %r15d, %r15d
movq %rax, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x1dfb3(%rip), %rsi     # 0x23f7f7
movq %r12, %rdi
callq 0x2210
movq %rax, %r14
movq %r12, %rdi
callq 0x2220
testq %r14, %r14
jne 0x22186e
movq %r15, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, 0x10(%rsp)
leaq 0x20(%rsp), %r15
movl $0x8, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x22f0
movq (%r15), %rbx
testq %rbx, %rbx
je 0x221934
leaq 0x34(%rsp), %r15
leaq 0x38(%rsp), %r12
leaq 0x40(%rsp), %r13
leaq 0x1c(%rsp), %rbp
movl $0x4, %esi
movl $0x1, %edx
movq %rbp, %rdi
movq %r14, %rcx
callq 0x22f0
movl $0x4, %esi
movl $0x1, %edx
movq %rbp, %rdi
movq %r14, %rcx
callq 0x22f0
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x22f0
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rdi
movq %r14, %rcx
callq 0x22f0
movl $0x4, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %r14, %rcx
callq 0x22f0
movl 0x40(%rsp), %esi
shlq $0x3, %rsi
movq %r14, %rdi
movl $0x1, %edx
callq 0x21b0
decq %rbx
jne 0x2218ad
movl $0x8, %ebx
movl $0x8, %esi
movq %r14, %rdi
movl $0x1, %edx
callq 0x21b0
movq 0x10(%rsp), %r12
cmpq $0x0, (%r12)
je 0x22198e
xorl %r15d, %r15d
movl $0x4, %esi
movq %r14, %rdi
movl $0x1, %edx
callq 0x21b0
movq 0x10(%r12), %rax
movl (%rax,%rbx), %esi
movq %r14, %rdi
movl $0x1, %edx
callq 0x21b0
incq %r15
addq $0x10, %rbx
cmpq (%r12), %r15
jb 0x22195a
leaq 0x28(%rsp), %r15
movl $0x8, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x22f0
movq (%r15), %rsi
shlq $0x2, %rsi
movq %r14, %rdi
movl $0x1, %edx
callq 0x21b0
movl $0x8, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0x22f0
movq (%r15), %rsi
shlq $0x3, %rsi
movq %r14, %rdi
movl $0x1, %edx
callq 0x21b0
leaq 0x50(%r12), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %rdi, 0x8(%rsp)
movq %r14, %rcx
callq 0x22f0
movq (%r12), %r8
cmpq 0x50(%r12), %r8
jne 0x221cc2
cmpq 0x58(%r12), %r8
jbe 0x221a71
decq %r8
movq %r8, %rax
shrq %rax
orq %r8, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x10, %rax
orq %rcx, %rax
incq %rax
movq %rax, 0x58(%r12)
movq 0x48(%r12), %rdi
imulq $0x58, %rax, %rsi
callq 0x2370
movq %rax, 0x48(%r12)
movq (%r12), %r8
movq 0x50(%r12), %rcx
jmp 0x221a74
movq %r8, %rcx
movq 0x73565(%rip), %rax     # 0x294fe0
movq (%rax), %rdi
leaq 0x280c9(%rip), %rsi     # 0x249b4e
leaq 0x280e2(%rip), %rdx     # 0x249b6e
xorl %eax, %eax
callq 0x22b0
movq 0x8(%rsp), %rax
cmpq $0x0, (%rax)
je 0x221caf
movl $0x40, %ebp
xorl %ebx, %ebx
movq 0x48(%r12), %r15
leaq (%r15,%rbp), %r12
addq $-0x40, %r12
leaq 0x10(%r15,%rbp), %rdi
movl $0x1, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x22f0
leaq (%r15,%rbp), %r13
addq $-0x28, %r13
movl $0x4, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %r14, %rcx
callq 0x22f0
movl $0x8, %esi
movl $0x1, %edx
movq %r12, %rdi
movq %r14, %rcx
callq 0x22f0
movq -0x18(%r13), %rdx
cmpq -0x10(%r13), %rdx
jbe 0x221b5e
decq %rdx
movq %rdx, %rax
shrq %rax
orq %rdx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, -0x38(%r15,%rbp)
movq -0x30(%r15,%rbp), %rdi
callq 0x2370
movq %rax, %rdi
movq %rax, -0x30(%r15,%rbp)
movq -0x40(%r15,%rbp), %rdx
jmp 0x221b63
movq -0x30(%r15,%rbp), %rdi
movl $0x1, %esi
movq %r14, %rcx
callq 0x22f0
leaq (%r15,%rbp), %r12
addq $-0x20, %r12
movl $0x8, %esi
movl $0x1, %edx
movq %r12, %rdi
movq %r14, %rcx
callq 0x22f0
movq (%r12), %rdx
cmpq 0x8(%r12), %rdx
movq 0x10(%rsp), %r12
jbe 0x221bff
decq %rdx
movq %rdx, %rax
shrq %rax
orq %rdx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x10, %rax
orq %rcx, %rax
leaq 0x1(%rax), %rcx
movq %rcx, -0x18(%r15,%rbp)
movq -0x10(%r15,%rbp), %rdi
leaq 0x4(,%rax,4), %rax
leaq (%rax,%rax,8), %rsi
callq 0x2370
movq %rax, %rdi
movq %rax, -0x10(%r15,%rbp)
movq -0x20(%r15,%rbp), %rdx
jmp 0x221c04
movq -0x10(%r15,%rbp), %rdi
movl $0x24, %esi
movq %r14, %rcx
callq 0x22f0
leaq (%r15,%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x22f0
movq -0x8(%r15,%rbp), %rdi
movq (%r15,%rbp), %rdx
cmpq 0x8(%r15,%rbp), %rdx
jbe 0x221c8d
decq %rdx
movq %rdx, %rax
shrq %rax
orq %rdx, %rax
movq %rax, %rcx
shrq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x10, %rax
orq %rcx, %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%r15,%rbp)
leaq 0x4(,%rax,4), %rsi
callq 0x2370
movq %rax, %rdi
movq %rax, -0x8(%r15,%rbp)
movq (%r15,%rbp), %rdx
movl $0x4, %esi
movq %r14, %rcx
callq 0x22f0
incq %rbx
addq $0x58, %rbp
movq 0x8(%rsp), %rax
cmpq (%rax), %rbx
jb 0x221aa9
movq %r14, %rdi
callq 0x2190
movl $0x1, %r15d
jmp 0x22185c
leaq 0x27e4c(%rip), %rdi     # 0x249b15
leaq 0x23939(%rip), %rsi     # 0x245609
leaq 0x27e4f(%rip), %rcx     # 0x249b26
movl $0x39dd, %edx           # imm = 0x39DD
callq 0x2110