// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/inter.cpp
// Function: ds_check_vec_mg_lchain_t(mg_lchain_t*, long, kv_ul_ov_t*, overlap_region_alloc*, haplotype_evdience_alloc*, ul_idx_t const*, double, long, float)
int64_t ds_check_vec_mg_lchain_t(mg_lchain_t *a, int64_t a_n, kv_ul_ov_t *buf, overlap_region_alloc* olist, 
haplotype_evdience_alloc *hap, const ul_idx_t *uref, double diff_ec_ul, int64_t winLen, float trans_thres)
{
	if(a_n <= 0) return 0;
	int64_t k, resc_tk, het_n; ul_ov_t *p; uint64_t si; ma_utg_t *u = NULL; buf->n = 0;
	for (k = 0; k < a_n; k++) {
		if(a[k].off < 0) continue;
		kv_pushp(ul_ov_t, *buf, &p);
		p->qs = a[k].qs; p->qe = a[k].qe; p->el = 1;
		if(a[k].score < 0) p->el = 0;
	}
	if(buf->n <= 0) return 0;
	if(check_elen_gchain(buf->a, buf->n, trans_thres)) return 1;

	buf->n = 0; resc_tk = 0;
	for (k = 0; k < a_n; k++) {
		if(a[k].off < 0) continue;
		if(a[k].score >= 0) {
			kv_pushp(ul_ov_t, *buf, &p);
			p->qs = a[k].qs; p->qe = a[k].qe; p->el = 1;
		} else {
			si = 0;
			het_n = update_ava_het_site(hap, a[k].off, &si, NULL, 1);
			assert(het_n > 0 && olist->list[a[k].off].is_match == 2);
			u = &(uref->ug->u.a[olist->list[a[k].off].y_id]);
			if(u->n > 1) {
				resc_tk += rescue_trans_ul_chains(uref, &(olist->list[a[k].off]), hap->list+si, het_n, u, 
				buf, diff_ec_ul, winLen, 0, NULL, NULL);
			}
		}		
	}

	if(resc_tk) {
		radix_sort_ul_ov_srt_qe(buf->a, buf->a+buf->n);
		if(check_elen_gchain(buf->a, buf->n, trans_thres)) return 1;
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movsd %xmm0, 0x48(%rsp)
movq %r8, 0x30(%rsp)
movq %rcx, 0x50(%rsp)
testq %rsi, %rsi
jle 0x166efb
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %rbp
movq %r9, 0x40(%rsp)
andq $0x0, 0x8(%rdx)
leaq 0x1c(%rdi), %r12
pushq $0x2
popq %r14
movq %rsi, %r13
movss %xmm1, 0x24(%rsp)
subq $0x1, %r13
jb 0x166d7c
cmpl $0x0, -0x1c(%r12)
js 0x166d73
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq 0x10(%rbx), %rcx
jne 0x166d3a
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
cmoveq %r14, %rdx
movq %rdx, 0x10(%rbx)
imulq $0x1c, %rdx, %rsi
movq %rax, %rdi
callq 0x2370
movss 0x24(%rsp), %xmm1
movq %rax, (%rbx)
movq 0x8(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rbx)
imulq $0x1c, %rcx, %rcx
movq -0x8(%r12), %rdx
movq %rdx, 0x4(%rax,%rcx)
movl 0x18(%rax,%rcx), %edx
movl %edx, %esi
orl $0x40000000, %esi       # imm = 0x40000000
movl %esi, 0x18(%rax,%rcx)
cmpl $0x0, (%r12)
jns 0x166d73
addq %rcx, %rax
andl $0xbfffffff, %edx       # imm = 0xBFFFFFFF
movl %edx, 0x18(%rax)
addq $0x28, %r12
jmp 0x166cf7
movq 0x8(%rbx), %rsi
testq %rsi, %rsi
je 0x166efb
movq (%rbx), %rdi
movaps %xmm1, %xmm0
callq 0x166be1
testq %rax, %rax
je 0x166da2
pushq $0x1
popq %r12
jmp 0x166efe
andq $0x0, 0x8(%rbx)
movq $0x0, 0x28(%rsp)
pushq $0x1
popq %r12
movq 0x40(%rsp), %r13
subq $0x1, %r15
jb 0x166ecc
movslq (%rbp), %rsi
testq %rsi, %rsi
js 0x166ec3
cmpl $0x0, 0x1c(%rbp)
js 0x166e24
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq 0x10(%rbx), %rcx
jne 0x166e05
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
cmoveq %r14, %rdx
movq %rdx, 0x10(%rbx)
imulq $0x1c, %rdx, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, (%rbx)
movq 0x8(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rbx)
imulq $0x1c, %rcx, %rcx
movq 0x14(%rbp), %rdx
movq %rdx, 0x4(%rax,%rcx)
orb $0x40, 0x1b(%rax,%rcx)
jmp 0x166ec3
andq $0x0, 0x38(%rsp)
movq 0x30(%rsp), %rdi
leaq 0x38(%rsp), %rdx
xorl %ecx, %ecx
movq %r12, %r8
callq 0x160309
testq %rax, %rax
jle 0x166f10
movq 0x50(%rsp), %rcx
movq (%rcx), %rsi
movslq (%rbp), %rcx
imulq $0xa8, %rcx, %rcx
cmpb $0x2, 0x2c(%rsi,%rcx)
jne 0x166f10
addq %rcx, %rsi
movq (%r13), %rcx
movq 0x10(%rcx), %r8
movl 0x10(%rsi), %ecx
imulq $0x28, %rcx, %rcx
cmpl $0x2, 0x10(%r8,%rcx)
jb 0x166ec3
addq %rcx, %r8
imulq $0x18, 0x38(%rsp), %rdx
movq 0x30(%rsp), %rcx
addq (%rcx), %rdx
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsp)
andq $0x0, 0x18(%rsp)
movq 0x90(%rsp), %rcx
movq %rcx, (%rsp)
movq %r13, %rdi
movq %rax, %rcx
movq %rbx, %r9
movsd 0x48(%rsp), %xmm0
callq 0x1619a7
addq %rax, 0x28(%rsp)
addq $0x28, %rbp
jmp 0x166db9
cmpq $0x0, 0x28(%rsp)
je 0x166efb
movq (%rbx), %rdi
imulq $0x1c, 0x8(%rbx), %rsi
addq %rdi, %rsi
callq 0x156f5c
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
movss 0x24(%rsp), %xmm0
callq 0x166be1
testq %rax, %rax
jne 0x166efe
xorl %r12d, %r12d
movq %r12, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8ba52(%rip), %rdi     # 0x1f2969
leaq 0x8ac05(%rip), %rsi     # 0x1f1b23
leaq 0x8ba75(%rip), %rcx     # 0x1f299a
movl $0x1233, %edx           # imm = 0x1233
callq 0x2110