// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/inter.cpp
// Function: load_all_ul_t(all_ul_t*, char*, All_reads*, ma_ug_t*)
int32_t load_all_ul_t(all_ul_t *x, char* file_name, All_reads *hR, ma_ug_t *ug)
{
	char* gfa_name = NULL; MALLOC(gfa_name, strlen(file_name)+50);
	sprintf(gfa_name, "%s.ul.ovlp.bin", file_name);
	FILE* fp = fopen(gfa_name, "r"); free(gfa_name);
	if (!fp) return 0;
	if(ug && (!test_dbug(ug, fp))) {
		fprintf(stderr, "[M::%s] Renew UL Index\n", __func__);
		fclose(fp);
		return 0;
    }

	destory_all_ul_t(x); 
	memset(x, 0, sizeof(*x)); x->hR = hR; init_aux_table();
	uint64_t k; ul_vec_t *p = NULL;
	
	fread(&x->nid.n, sizeof(x->nid.n), 1, fp); x->nid.m = x->nid.n; MALLOC(x->nid.a, x->nid.n); 
	for (k = 0; k < x->nid.n; k++) {
		fread(&x->nid.a[k].n, sizeof(x->nid.a[k].n), 1, fp); MALLOC(x->nid.a[k].a, x->nid.a[k].n);
		fread(x->nid.a[k].a, sizeof((*(x->nid.a[k].a))), x->nid.a[k].n, fp);
	}

	fread(&x->ridx.idx.n, sizeof(x->ridx.idx.n), 1, fp); x->ridx.idx.m = x->ridx.idx.n; MALLOC(x->ridx.idx.a, x->ridx.idx.n);
	fread(x->ridx.idx.a, sizeof((*(x->ridx.idx.a))), x->ridx.idx.n, fp);

	fread(&x->ridx.occ.n, sizeof(x->ridx.occ.n), 1, fp); x->ridx.occ.m = x->ridx.occ.n; MALLOC(x->ridx.occ.a, x->ridx.occ.n);
	fread(x->ridx.occ.a, sizeof((*(x->ridx.occ.a))), x->ridx.occ.n, fp);

	fread(&x->n, sizeof(x->n), 1, fp); x->m = x->n; MALLOC(x->a, x->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); p->r_base.m = p->r_base.n; MALLOC(p->r_base.a, 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); p->bb.m = p->bb.n; MALLOC(p->bb.a, 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); p->N_site.m = p->N_site.n; MALLOC(p->N_site.a, p->N_site.n);
		fread(p->N_site.a, sizeof((*(p->N_site.a))), p->N_site.n, fp);
	}

	fprintf(stderr, "[M::%s] Index has been loaded.\n", __func__);
	fclose(fp);
	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r12
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %rbp
movq %rsi, %rdi
callq 0x2090
leaq 0x32(%rax), %rdi
callq 0x2280
movq %rax, %r13
leaq 0x632d6(%rip), %rsi     # 0x249b06
xorl %r14d, %r14d
movq %rax, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x58fb0(%rip), %rsi     # 0x23f7f7
movq %r13, %rdi
callq 0x2210
movq %rax, %rbx
movq %r13, %rdi
callq 0x2220
testq %rbx, %rbx
jne 0x1e6871
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r12, %r12
je 0x1e6894
movq %r12, %rdi
movq %rbx, %rsi
callq 0xc3645
testl %eax, %eax
jne 0x1e6894
xorl %r14d, %r14d
leaq 0x53b44(%rip), %rsi     # 0x23a3d3
jmp 0x1e6b5a
movq %rbp, %rdi
callq 0x33e30
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%rbp)
movups %xmm0, 0x40(%rbp)
movups %xmm0, 0x30(%rbp)
movups %xmm0, 0x20(%rbp)
movups %xmm0, 0x10(%rbp)
movups %xmm0, (%rbp)
movq %r15, 0x60(%rbp)
callq 0x32d70
movl $0x8, %r14d
movl $0x8, %esi
movl $0x1, %edx
movq %rbp, %rdi
movq %rbx, %rcx
callq 0x22f0
movq (%rbp), %r15
movq %r15, 0x8(%rbp)
movq %r15, %rdi
shlq $0x4, %rdi
callq 0x2280
movq %rax, 0x10(%rbp)
testq %r15, %r15
je 0x1e694a
xorl %r12d, %r12d
movq 0x10(%rbp), %rdi
addq %r14, %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x22f0
movq 0x10(%rbp), %r13
movl (%r13,%r14), %r15d
movq %r15, %rdi
callq 0x2280
movq %rax, -0x8(%r13,%r14)
movl $0x1, %esi
movq %rax, %rdi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x22f0
incq %r12
addq $0x10, %r14
cmpq (%rbp), %r12
jb 0x1e68fb
leaq 0x18(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x22f0
movq 0x18(%rbp), %r15
movq %r15, 0x20(%rbp)
leaq (,%r15,4), %rdi
callq 0x2280
movq %rax, 0x28(%rbp)
movl $0x4, %esi
movq %rax, %rdi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x22f0
leaq 0x30(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x22f0
movq 0x30(%rbp), %r15
movq %r15, 0x38(%rbp)
leaq (,%r15,8), %rdi
callq 0x2280
movq %rax, 0x40(%rbp)
movl $0x8, %esi
movq %rax, %rdi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x22f0
leaq 0x50(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x22f0
movq 0x50(%rbp), %r14
movq %r14, 0x58(%rbp)
imulq $0x58, %r14, %rdi
callq 0x2280
movq %rax, 0x48(%rbp)
leaq 0x538e6(%rip), %rsi     # 0x23a2e6
testq %r14, %r14
jne 0x1e6a10
movl $0x1, %r14d
jmp 0x1e6b5a
movq %rbp, 0x8(%rsp)
movl $0x40, %ebp
xorl %r14d, %r14d
movq 0x8(%rsp), %rax
movq 0x48(%rax), %r12
leaq (%r12,%rbp), %rax
movq %rax, 0x10(%rsp)
leaq (%r12,%rbp), %r13
addq $-0x40, %r13
leaq 0x10(%r12,%rbp), %rdi
movl $0x1, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x22f0
leaq (%r12,%rbp), %r15
addq $-0x28, %r15
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x22f0
movl $0x8, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %rbx, %rcx
callq 0x22f0
movq -0x18(%r15), %r13
movq %r13, -0x10(%r15)
movq %r13, %rdi
callq 0x2280
movq %rax, -0x8(%r15)
movl $0x1, %esi
movq %rax, %rdi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x22f0
leaq (%r12,%rbp), %r13
addq $-0x20, %r13
movl $0x8, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %rbx, %rcx
callq 0x22f0
movq (%r13), %r15
movq %r15, 0x8(%r13)
leaq (,%r15,4), %rax
leaq (%rax,%rax,8), %rdi
callq 0x2280
movq %rax, 0x10(%r13)
movl $0x24, %esi
movq %rax, %rdi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x22f0
movl $0x8, %esi
movl $0x1, %edx
movq 0x10(%rsp), %rdi
movq %rbx, %rcx
callq 0x22f0
movq 0x20(%r13), %r15
movq %r15, 0x28(%r13)
leaq (,%r15,4), %rdi
callq 0x2280
movq %rax, 0x18(%r13)
movl $0x4, %esi
movq %rax, %rdi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x22f0
incq %r14
addq $0x58, %rbp
movq 0x8(%rsp), %rax
cmpq 0x50(%rax), %r14
jb 0x1e6a1d
movl $0x1, %r14d
leaq 0x5378c(%rip), %rsi     # 0x23a2e6
movq 0xae47f(%rip), %rax     # 0x294fe0
movq (%rax), %rdi
leaq 0x5dd9d(%rip), %rdx     # 0x244908
xorl %eax, %eax
callq 0x22b0
movq %rbx, %rdi
callq 0x2190
jmp 0x1e685f