// File: chhylp123[P]hifiasm/inter.cpp
// Function: drenew_UL_reovlps(uldat_t*, ma_ug_t*, asg_t*, char*, int)
uint32_t drenew_UL_reovlps(uldat_t *sl, ma_ug_t *ug, asg_t *sg, char* gfa_name, int32_t cutoff)
{
	uint32_t k, f_occ;
	kt_for(asm_opt.thread_num, dcheck_ulalignments_mul, ug, UL_INF.n);
	for (k = f_occ = 0; k < UL_INF.n; k++) {
		if(UL_INF.a[k].rlen&((uint32_t)(0x80000000))) f_occ++;
	}
	fprintf(stderr, "[M::%s::] # wrong UL alignments::%u\n", __func__, f_occ);
	if(f_occ == 0) return 0;//all set

	ul_idx_t *uu = gen_ul_idx(sl->uopt, ug, sg);
	int exist = (asm_opt.load_index_from_disk? uidx_load(&ha_flt_tab, &ha_idx, gfa_name, ug) : 0);
    if(exist == 0) uidx_l_build(uu->ug, (mg_idxopt_t *)sl->opt, cutoff);
	if(exist == 0) uidx_write(ha_flt_tab, ha_idx, gfa_name, ug);
	sl->ha_flt_tab = ha_flt_tab; sl->ha_idx = (ha_pt_t *)ha_idx; sl->uu = uu;	

	// init_ucr_file_t(sl, gfa_name, 1);
	recorrect_ul_pipeline(sl, asm_opt.ar);
	// destory_ucr_file_t(sl);
	///do not free ug
	uu->ug = NULL; destroy_ul_idx_t(uu); ha_ft_destroy(ha_flt_tab); ha_pt_destroy(ha_idx);
	sl->ha_flt_tab = NULL; sl->ha_idx = NULL; sl->uu = NULL;
	return 1;
	// exit(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)
movl %r8d, -0x2c(%rbp)
leaq 0xc7555(%rip), %rax     # 0x3c47f8
movl 0x7c(%rax), %edi
movq -0x18(%rbp), %rdx
leaq 0xc8107(%rip), %rax     # 0x3c53b8
movq 0x50(%rax), %rcx
leaq 0x1d4(%rip), %rsi       # 0x2fd490
callq 0x16d710
movl $0x0, -0x34(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
leaq 0xc80df(%rip), %rcx     # 0x3c53b8
cmpq 0x50(%rcx), %rax
jae 0x2fd317
leaq 0xc80d2(%rip), %rax     # 0x3c53b8
movq 0x48(%rax), %rax
movl -0x30(%rbp), %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
andl $0x80000000, %eax       # imm = 0x80000000
cmpl $0x0, %eax
je 0x2fd30a
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x2fd30c
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x2fd2cf
movq 0xc6cc2(%rip), %rax     # 0x3c3fe0
movq (%rax), %rdi
movl -0x34(%rbp), %ecx
leaq 0x9816b(%rip), %rsi     # 0x395496
leaq 0x98189(%rip), %rdx     # 0x3954bb
movb $0x0, %al
callq 0x22a0
cmpl $0x0, -0x34(%rbp)
jne 0x2fd34b
movl $0x0, -0x4(%rbp)
jmp 0x2fd484
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x2fb960
movq %rax, -0x40(%rbp)
leaq 0xc748d(%rip), %rax     # 0x3c47f8
cmpl $0x0, 0xf0(%rax)
je 0x2fd394
movq -0x28(%rbp), %rdx
movq -0x18(%rbp), %rcx
leaq 0xc814d(%rip), %rdi     # 0x3c54d0
leaq 0xc814e(%rip), %rsi     # 0x3c54d8
callq 0x18b820
movl %eax, -0x48(%rbp)
jmp 0x2fd39b
xorl %eax, %eax
movl %eax, -0x48(%rbp)
jmp 0x2fd39b
movl -0x48(%rbp), %eax
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jne 0x2fd3be
movq -0x40(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
movl -0x2c(%rbp), %edx
callq 0x282e90
cmpl $0x0, -0x44(%rbp)
jne 0x2fd3e5
leaq 0xc8105(%rip), %rax     # 0x3c54d0
movq (%rax), %rdi
leaq 0xc8103(%rip), %rax     # 0x3c54d8
movq (%rax), %rsi
movq -0x28(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0x18b600
leaq 0xc80e4(%rip), %rax     # 0x3c54d0
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
leaq 0xc80db(%rip), %rax     # 0x3c54d8
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x10(%rbp), %rdi
leaq 0xc73d9(%rip), %rax     # 0x3c47f8
movq 0x68(%rax), %rsi
callq 0x2f3ac0
movq -0x40(%rbp), %rax
movq $0x0, (%rax)
movq -0x40(%rbp), %rdi
callq 0x2fc8d0
leaq 0xc808d(%rip), %rax     # 0x3c54d0
movq (%rax), %rdi
callq 0x188df0
leaq 0xc8086(%rip), %rax     # 0x3c54d8
movq (%rax), %rdi
callq 0x187660
movq -0x10(%rbp), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x30(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)