// File: /workspace/github_cpp_makefile_star2_O2/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 $0x28, %rsp
movq %rcx, %r12
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x2090
leaq 0x32(%rax), %rdi
callq 0x2280
movq %rax, %r13
leaq 0x61049(%rip), %rsi     # 0x1fbac5
xorl %ebp, %ebp
movq %rax, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x56c25(%rip), %rsi     # 0x1f16b7
movq %r13, %rdi
callq 0x2210
movq %rax, %r14
movq %r13, %rdi
callq 0x2220
movq %r14, 0x8(%rsp)
testq %r14, %r14
jne 0x19aac0
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r12, %r12
je 0x19aae4
movq %r12, %rdi
movq 0x8(%rsp), %rsi
callq 0x871ea
testl %eax, %eax
jne 0x19aae4
xorl %ebp, %ebp
leaq 0x517d4(%rip), %rsi     # 0x1ec2b3
jmp 0x19ad9e
movq %rbx, %rdi
callq 0x7d55
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%rbx)
movups %xmm0, 0x40(%rbx)
movups %xmm0, 0x30(%rbx)
movups %xmm0, 0x20(%rbx)
movups %xmm0, 0x10(%rbx)
movups %xmm0, (%rbx)
movq %r15, 0x60(%rbx)
callq 0x6b0f
pushq $0x8
popq %r15
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r15, %rsi
movq 0x8(%rsp), %rcx
callq 0x22f0
movq (%rbx), %rbp
movq %rbp, 0x8(%rbx)
movq %rbp, %rdi
shlq $0x4, %rdi
callq 0x2280
movq %rbx, 0x10(%rsp)
movq %rax, 0x10(%rbx)
xorl %ebx, %ebx
movq 0x10(%rsp), %r12
movq 0x8(%rsp), %r14
cmpq %rbp, %rbx
jae 0x19ab9e
movq 0x10(%r12), %rdi
addq %r15, %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rcx
callq 0x22f0
movq 0x10(%r12), %r13
movl (%r13,%r15), %ebp
movq %rbp, %rdi
callq 0x2280
movq %rax, -0x8(%r13,%r15)
movq %rax, %rdi
pushq $0x1
popq %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x22f0
incq %rbx
movq (%r12), %rbp
addq $0x10, %r15
jmp 0x19ab4e
movq 0x10(%rsp), %rbx
leaq 0x18(%rbx), %rdi
pushq $0x8
popq %r15
pushq $0x1
popq %r14
movq %r15, %rsi
movq %r14, %rdx
movq 0x8(%rsp), %rcx
callq 0x22f0
movq 0x18(%rbx), %r13
movq %r13, 0x20(%rbx)
leaq (,%r13,4), %rdi
callq 0x2280
movq %rax, 0x28(%rbx)
pushq $0x4
popq %rsi
movq %rax, %rdi
movq %r13, %rdx
movq 0x8(%rsp), %rcx
callq 0x22f0
leaq 0x30(%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq 0x8(%rsp), %rcx
callq 0x22f0
movq 0x30(%rbx), %r13
movq %r13, 0x38(%rbx)
leaq (,%r13,8), %rdi
callq 0x2280
movq %rax, 0x40(%rbx)
movq %rax, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq 0x8(%rsp), %rcx
callq 0x22f0
leaq 0x50(%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq 0x8(%rsp), %rcx
callq 0x22f0
movq 0x50(%rbx), %r15
movq %r15, 0x58(%rbx)
imulq $0x58, %r15, %rdi
callq 0x2280
movq %rax, 0x48(%rbx)
pushq $0x40
popq %rbx
xorl %eax, %eax
pushq $0x1
popq %rbp
cmpq %r15, %rax
jae 0x19ad97
movq 0x10(%rsp), %rcx
movq 0x48(%rcx), %r12
leaq (%r12,%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq (%r12,%rbx), %r13
addq $-0x40, %r13
leaq 0x10(%r12,%rbx), %rdi
pushq $0x1
popq %r14
movq %r14, %rsi
movq %r14, %rdx
movq 0x8(%rsp), %rcx
movq %rax, 0x20(%rsp)
callq 0x22f0
leaq (%r12,%rbx), %r15
addq $-0x28, %r15
movq %r15, %rdi
pushq $0x4
popq %rsi
movq %r14, %rdx
movq 0x8(%rsp), %rcx
callq 0x22f0
movq %r13, %rdi
pushq $0x8
popq %rbp
movq %rbp, %rsi
movq %r14, %rdx
movq 0x8(%rsp), %rcx
callq 0x22f0
movq -0x18(%r15), %r13
movq %r13, -0x10(%r15)
movq %r13, %rdi
callq 0x2280
movq %rax, -0x8(%r15)
movq %rax, %rdi
movq %r14, %rsi
movq %r13, %rdx
movq 0x8(%rsp), %rcx
callq 0x22f0
leaq (%r12,%rbx), %r13
addq $-0x20, %r13
movq %r13, %rdi
movq %rbp, %rsi
movq %r14, %rdx
movq 0x8(%rsp), %rcx
callq 0x22f0
movq (%r13), %r15
movq %r15, 0x8(%r13)
imulq $0x24, %r15, %rdi
callq 0x2280
movq %rax, 0x10(%r13)
movq %rax, %rdi
pushq $0x24
popq %rsi
movq %r15, %rdx
movq 0x8(%rsp), %rcx
callq 0x22f0
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
pushq $0x1
popq %rbp
movq %r14, %rdx
movq 0x8(%rsp), %r14
movq %r14, %rcx
callq 0x22f0
movq 0x20(%r13), %r15
movq %r15, 0x28(%r13)
leaq (,%r15,4), %rdi
callq 0x2280
movq %rax, 0x18(%r13)
movq %rax, %rdi
pushq $0x4
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x22f0
movq 0x20(%rsp), %rax
incq %rax
movq 0x10(%rsp), %rcx
movq 0x50(%rcx), %r15
addq $0x58, %rbx
jmp 0x19ac5c
leaq 0x51428(%rip), %rsi     # 0x1ec1c6
movq 0xb823b(%rip), %rax     # 0x252fe0
movq (%rax), %rdi
leaq 0x5ba21(%rip), %rdx     # 0x1f67d0
xorl %eax, %eax
callq 0x22b0
movq 0x8(%rsp), %rdi
callq 0x2190
jmp 0x19aaaf