// File: /workspace/github_cpp_makefile_star2_O3/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, 0x18(%rsp)
movq %rsi, %rdi
callq 0x2090
leaq 0x32(%rax), %rdi
callq 0x2280
movq %rax, %r12
leaq 0x28917(%rip), %rsi     # 0x249820
xorl %ebp, %ebp
movq %rax, %rdi
movq %r15, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x2050
leaq 0x1e8d5(%rip), %rsi     # 0x23f7f7
movq %r12, %rdi
callq 0x2210
movq %rax, %r14
movq %r12, %rdi
callq 0x2220
testq %r14, %r14
je 0x221208
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 0x10(%rsp), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x22f0
movq %r14, %rdi
callq 0x2320
testl %eax, %eax
je 0x220f96
xorl %r15d, %r15d
movq $0x0, (%rsp)
jmp 0x2211ea
movq 0x18(%rsp), %rax
movq 0x48(%rax), %rbx
imulq $0x58, 0x10(%rsp), %rbp
movl $0x4, %esi
movl $0x1, %edx
leaq 0xc(%rsp), %rdi
movq %r14, %rcx
callq 0x22f0
movl 0x18(%rbx,%rbp), %r15d
cmpl 0xc(%rsp), %r15d
jne 0x221219
movl $0x8, %esi
movl $0x1, %edx
leaq 0x60(%rsp), %rdi
movq %r14, %rcx
callq 0x22f0
movq 0x58(%rsp), %rdi
movq 0x60(%rsp), %r13
cmpq %r13, 0x68(%rsp)
jae 0x221047
leaq -0x1(%r13), %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)
leaq 0x4(,%rcx,4), %rsi
callq 0x2370
movq %rax, %rdi
movq %rax, 0x58(%rsp)
movl $0x4, %esi
movq %rdi, (%rsp)
movq %r13, %rdx
movq %r14, %rcx
callq 0x22f0
movl %r15d, %r12d
shrl $0x2, %r12d
andl $0x3, %r15d
cmpl $0x1, %r15d
sbbl $-0x1, %r12d
movq %r12, 0x20(%rsp)
movq 0x30(%rsp), %r15
cmpq %r12, 0x28(%rsp)
jae 0x2210cd
leaq -0x1(%r12), %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 %r15, %rdi
callq 0x2370
movq %rax, %r15
movq %rax, 0x30(%rsp)
addq %rbp, %rbx
movl $0x1, %esi
movq %r15, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0x22f0
cmpb $0x4, 0x50(%rbx)
jne 0x2211c3
movq 0x38(%rbx), %rdi
cmpq %r13, 0x48(%rbx)
jae 0x221148
leaq -0x1(%r13), %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)
leaq 0x4(,%rcx,4), %rsi
callq 0x2370
movq %rax, %rdi
movq %rax, 0x38(%rbx)
movq %r13, 0x40(%rbx)
shlq $0x2, %r13
movq (%rsp), %rsi
movq %r13, %rdx
callq 0x2160
cmpq %r12, 0x8(%rbx)
jae 0x2211b1
leaq -0x1(%r12), %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, %rdi
movq %rax, 0x10(%rbx)
jmp 0x2211b5
movq 0x10(%rbx), %rdi
movq %r12, (%rbx)
movq %r15, %rsi
movq %r12, %rdx
callq 0x2160
movl $0x8, %esi
movl $0x1, %edx
leaq 0x10(%rsp), %rdi
movq %r14, %rcx
callq 0x22f0
movq %r14, %rdi
callq 0x2320
testl %eax, %eax
je 0x220f96
movq %r14, %rdi
callq 0x2190
movq (%rsp), %rdi
callq 0x2220
movq %r15, %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 0x28613(%rip), %rdi     # 0x249833
leaq 0x243e2(%rip), %rsi     # 0x245609
leaq 0x28614(%rip), %rcx     # 0x249842
movl $0x38b4, %edx           # imm = 0x38B4
callq 0x2110