// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: load_scaf_base(all_ul_t*, char*, char const*)
uint32_t load_scaf_base(all_ul_t *x, char* file_name, const char *bin_file)
{
    char *gfa_name = (char*)malloc(strlen(file_name)+50);
	sprintf(gfa_name, "%s.%s.uidx.ucr.bin", file_name, bin_file);
    // fprintf(stderr, "[M::%s] open %s...\n", __func__, gfa_name);
    FILE *fp = fopen(gfa_name, "r"); free(gfa_name);
    if (!fp) return 0;
    // fprintf(stderr, "[M::%s] open sucess\n", __func__);
    uint64_t rid; uint32_t len; ul_vec_t ss, *z; memset(&ss, 0, sizeof(ss));
    while(1) {
        fread(&rid, sizeof(rid), 1, fp);
        if(feof(fp)) break;
        z = &(x->a[rid]);
        fread(&len, sizeof(len), 1, fp); assert(z->rlen == len);
        fread(&(ss.N_site.n), sizeof(ss.N_site.n), 1, fp);
        kv_resize(uint32_t, ss.N_site, ss.N_site.n);
        fread(ss.N_site.a, sizeof((*(ss.N_site.a))), ss.N_site.n, fp);
        ss.r_base.n = B4Lg(len); kv_resize(uint8_t, ss.r_base, ss.r_base.n); 
        fread(ss.r_base.a, sizeof((*(ss.r_base.a))), ss.r_base.n, fp);
        // if(rid == 37238) {
        //     fprintf(stderr, "[M::%s::37238] z->dd::%u\n", __func__, z->dd);
        // }
        // fprintf(stderr, "[M::%s::rid->%lu] z->dd::%u\n", __func__, rid, z->dd);
        if(z->dd != 4) continue;

        
        kv_resize(uint32_t, z->N_site, ss.N_site.n); z->N_site.n = ss.N_site.n;
        memcpy(z->N_site.a, ss.N_site.a, sizeof((*(z->N_site.a)))*z->N_site.n);

        kv_resize(uint8_t, z->r_base, ss.r_base.n); z->r_base.n = ss.r_base.n;
        memcpy(z->r_base.a, ss.r_base.a, sizeof((*(z->r_base.a)))*z->r_base.n);
    }
    // load_compress_base_disk(fp, &rid, des.a, &ulen, &(sl->ucr_s->u));

    fclose(fp); free(ss.N_site.a); free(ss.r_base.a);
    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, 0x10(%rsp)
movq %rsi, %rdi
callq 0x2090
leaq 0x32(%rax), %rdi
callq 0x2280
movq %rax, %r12
leaq 0x27a04(%rip), %rsi     # 0x23d53c
xorl %ebp, %ebp
movq %rax, %rdi
movq %r15, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x2050
leaq 0x1da56(%rip), %rsi     # 0x2335a7
movq %r12, %rdi
callq 0x2210
movq %rax, %r14
movq %r12, %rdi
callq 0x2220
testq %r14, %r14
je 0x215e18
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x70(%rsp)
leaq 0x8(%rsp), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x22f0
movq %r14, %rdi
callq 0x2320
testl %eax, %eax
jne 0x215df7
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rbx
imulq $0x58, 0x8(%rsp), %r13
movl $0x4, %esi
movl $0x1, %edx
leaq 0x4(%rsp), %rdi
movq %r14, %rcx
callq 0x22f0
movl 0x4(%rsp), %r12d
cmpl %r12d, 0x18(%rbx,%r13)
jne 0x215e29
movl $0x8, %esi
movl $0x1, %edx
leaq 0x60(%rsp), %rdi
movq %r14, %rcx
callq 0x22f0
movq 0x60(%rsp), %rbp
cmpq %rbp, 0x68(%rsp)
jae 0x215c67
leaq -0x1(%rbp), %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0x68(%rsp)
movq 0x58(%rsp), %rdi
leaq 0x4(,%rcx,4), %rsi
callq 0x2370
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rdi
movl $0x4, %esi
movq %rdi, 0x18(%rsp)
movq %rbp, %rdx
movq %r14, %rcx
callq 0x22f0
movl %r12d, %r15d
shrl $0x2, %r15d
andl $0x3, %r12d
cmpl $0x1, %r12d
sbbl $-0x1, %r15d
movq %r15, 0x20(%rsp)
cmpq %r15, 0x28(%rsp)
jae 0x215cec
leaq -0x1(%r15), %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x28(%rsp)
movq 0x30(%rsp), %rdi
callq 0x2370
movq %rax, 0x30(%rsp)
addq %r13, %rbx
movq 0x30(%rsp), %r13
movl $0x1, %esi
movq %r13, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0x22f0
cmpb $0x4, 0x50(%rbx)
jne 0x215de3
cmpq %rbp, 0x48(%rbx)
jae 0x215d69
leaq -0x1(%rbp), %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0x48(%rbx)
movq 0x38(%rbx), %rdi
leaq 0x4(,%rcx,4), %rsi
callq 0x2370
movq %rax, 0x38(%rbx)
movq %rbp, 0x40(%rbx)
movq 0x38(%rbx), %rdi
shlq $0x2, %rbp
movq 0x18(%rsp), %rsi
movq %rbp, %rdx
callq 0x2160
cmpq %r15, 0x8(%rbx)
jae 0x215dd1
leaq -0x1(%r15), %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
callq 0x2370
movq %rax, 0x10(%rbx)
movq %r15, (%rbx)
movq 0x10(%rbx), %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x2160
movl $0x8, %esi
movl $0x1, %edx
leaq 0x8(%rsp), %rdi
jmp 0x215ba1
movq %r14, %rdi
callq 0x2190
movq 0x58(%rsp), %rdi
callq 0x2220
movq 0x30(%rsp), %rdi
callq 0x2220
movl $0x1, %ebp
movl %ebp, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2771f(%rip), %rdi     # 0x23d54f
leaq 0x234ee(%rip), %rsi     # 0x239325
leaq 0x27720(%rip), %rcx     # 0x23d55e
movl $0x38b4, %edx           # imm = 0x38B4
callq 0x2110