// File: 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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x18(%rbp), %rdi
callq 0x20a0
movq %rax, %rdi
addq $0x32, %rdi
shlq $0x0, %rdi
callq 0x2270
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0x9ceda(%rip), %rsi     # 0x39a7f6
movb $0x0, %al
callq 0x2050
movq -0x30(%rbp), %rdi
leaq 0x92aa8(%rip), %rsi     # 0x3903d6
callq 0x2200
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
callq 0x2210
cmpq $0x0, -0x38(%rbp)
jne 0x2fd953
movl $0x0, -0x4(%rbp)
jmp 0x2fddba
cmpq $0x0, -0x28(%rbp)
je 0x2fd9a0
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x101650
cmpl $0x0, %eax
jne 0x2fd9a0
movq 0xc666d(%rip), %rax     # 0x3c3fe0
movq (%rax), %rdi
leaq 0x8d616(%rip), %rsi     # 0x38af93
leaq 0x97b58(%rip), %rdx     # 0x3954dc
movb $0x0, %al
callq 0x22a0
movq -0x38(%rbp), %rdi
callq 0x21a0
movl $0x0, -0x4(%rbp)
jmp 0x2fddba
movq -0x10(%rbp), %rdi
callq 0xbb90
movq -0x10(%rbp), %rdi
xorl %esi, %esi
movl $0x68, %edx
callq 0x2100
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x60(%rax)
callq 0x9690
movq $0x0, -0x48(%rbp)
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rcx
movl $0x8, %esi
movl $0x1, %edx
callq 0x22e0
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
shlq $0x4, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x2fdadd
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x40(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
addq $0x8, %rdi
movq -0x38(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x22e0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x40(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, %edi
shlq $0x0, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x40(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x40(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x40(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, %edx
movq -0x38(%rbp), %rcx
movl $0x1, %esi
callq 0x22e0
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x2fda1b
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
movq -0x38(%rbp), %rcx
movl $0x8, %esi
movl $0x1, %edx
callq 0x22e0
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
shlq $0x2, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdx
movq -0x38(%rbp), %rcx
movl $0x4, %esi
callq 0x22e0
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
addq $0x18, %rdi
movq -0x38(%rbp), %rcx
movl $0x8, %esi
movl $0x1, %edx
callq 0x22e0
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
shlq $0x3, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdx
movq -0x38(%rbp), %rcx
movl $0x8, %esi
callq 0x22e0
movq -0x10(%rbp), %rdi
addq $0x50, %rdi
movq -0x38(%rbp), %rcx
movl $0x8, %esi
movl $0x1, %edx
callq 0x22e0
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x10(%rbp), %rax
imulq $0x58, 0x50(%rax), %rdi
callq 0x2270
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x48(%rax)
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x50(%rcx), %rax
jae 0x2fdd8b
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
imulq $0x58, -0x40(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
addq $0x50, %rdi
movq -0x38(%rbp), %rcx
movl $0x1, %edx
movq %rdx, %rsi
callq 0x22e0
movq -0x48(%rbp), %rdi
addq $0x18, %rdi
movq -0x38(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x22e0
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rcx
movl $0x8, %esi
movl $0x1, %edx
callq 0x22e0
movq -0x48(%rbp), %rax
movq (%rax), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x48(%rbp), %rax
movq (%rax), %rdi
shlq $0x0, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x48(%rbp), %rax
movq (%rax), %rdx
movq -0x38(%rbp), %rcx
movl $0x1, %esi
callq 0x22e0
movq -0x48(%rbp), %rdi
addq $0x20, %rdi
movq -0x38(%rbp), %rcx
movl $0x8, %esi
movl $0x1, %edx
callq 0x22e0
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x48(%rbp), %rax
imulq $0x24, 0x20(%rax), %rdi
callq 0x2270
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x48(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rdx
movq -0x38(%rbp), %rcx
movl $0x24, %esi
callq 0x22e0
movq -0x48(%rbp), %rdi
addq $0x38, %rdi
addq $0x8, %rdi
movq -0x38(%rbp), %rcx
movl $0x8, %esi
movl $0x1, %edx
callq 0x22e0
movq -0x48(%rbp), %rax
movq 0x40(%rax), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x48(%rbp), %rax
movq 0x40(%rax), %rdi
shlq $0x2, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x48(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x48(%rbp), %rax
movq 0x40(%rax), %rdx
movq -0x38(%rbp), %rcx
movl $0x4, %esi
callq 0x22e0
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x2fdbf7
movq 0xc624e(%rip), %rax     # 0x3c3fe0
movq (%rax), %rdi
leaq 0x8d10a(%rip), %rsi     # 0x38aea6
leaq 0x97739(%rip), %rdx     # 0x3954dc
movb $0x0, %al
callq 0x22a0
movq -0x38(%rbp), %rdi
callq 0x21a0
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)