// File: /workspace/github_cpp_makefile_star2_O1/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
movss %xmm1, 0x2c(%rsp)
movsd %xmm0, 0x48(%rsp)
movq %rcx, 0x50(%rsp)
testq %rsi, %rsi
jle 0x1a6919
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %rbp
movq %r8, 0x38(%rsp)
movq %r9, 0x40(%rsp)
movq $0x0, 0x8(%rdx)
leaq 0x1c(%rdi), %r12
movl $0x2, %r14d
movq %rsi, %r13
cmpl $0x0, -0x1c(%r12)
js 0x1a6761
movq 0x10(%rbx), %rax
cmpq %rax, 0x8(%rbx)
jne 0x1a6712
leaq (%rax,%rax), %rcx
testq %rax, %rax
cmoveq %r14, %rcx
movq %rcx, 0x10(%rbx)
movq (%rbx), %rdi
leaq (%rcx,%rcx,8), %rax
leaq (%rax,%rax,2), %rsi
addq %rcx, %rsi
callq 0x2370
movq %rax, (%rbx)
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
leaq 0x1(%rdx), %rcx
movq %rcx, 0x8(%rbx)
leaq (%rdx,%rdx,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rdx, %rcx
movl -0x8(%r12), %edx
movl %edx, 0x4(%rax,%rcx)
movl -0x4(%r12), %edx
movl %edx, 0x8(%rax,%rcx)
movl 0x18(%rax,%rcx), %edx
movl %edx, %esi
orl $0x40000000, %esi       # imm = 0x40000000
movl %esi, 0x18(%rax,%rcx)
cmpl $0x0, (%r12)
jns 0x1a6761
addq %rcx, %rax
andl $0xbfffffff, %edx       # imm = 0xBFFFFFFF
movl %edx, 0x18(%rax)
addq $0x28, %r12
decq %r13
jne 0x1a66db
movq 0x8(%rbx), %rsi
testq %rsi, %rsi
je 0x1a6919
movq (%rbx), %rdi
movss 0x2c(%rsp), %xmm0
callq 0x1a659a
movq %rax, %rcx
movl $0x1, %eax
testq %rcx, %rcx
jne 0x1a691b
movq $0x0, 0x8(%rbx)
xorl %r12d, %r12d
movq 0x40(%rsp), %r14
movq 0x38(%rsp), %r13
movslq (%rbp), %rsi
testq %rsi, %rsi
js 0x1a68ce
cmpl $0x0, 0x1c(%rbp)
js 0x1a6828
movq 0x10(%rbx), %rax
cmpq %rax, 0x8(%rbx)
jne 0x1a67f6
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x10(%rbx)
movq (%rbx), %rdi
leaq (%rcx,%rcx,8), %rax
leaq (%rax,%rax,2), %rsi
addq %rcx, %rsi
callq 0x2370
movq %rax, (%rbx)
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rbx)
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
movl 0x14(%rbp), %ecx
movl %ecx, 0x4(%rax,%rdx)
movl 0x18(%rbp), %ecx
movl %ecx, 0x8(%rax,%rdx)
orb $0x40, 0x1b(%rax,%rdx)
jmp 0x1a68ce
movq $0x0, 0x30(%rsp)
movl $0x1, %r8d
movq %r13, %rdi
leaq 0x30(%rsp), %rdx
xorl %ecx, %ecx
callq 0x19f226
testq %rax, %rax
jle 0x1a692a
movq 0x50(%rsp), %rcx
movq (%rcx), %rsi
movslq (%rbp), %rcx
imulq $0xa8, %rcx, %rcx
cmpb $0x2, 0x2c(%rsi,%rcx)
jne 0x1a692a
addq %rcx, %rsi
movq (%r14), %rcx
movq 0x10(%rcx), %rcx
movl 0x10(%rsi), %edx
leaq (%rdx,%rdx,4), %rdx
cmpl $0x2, 0x10(%rcx,%rdx,8)
jb 0x1a68ce
leaq (%rcx,%rdx,8), %r8
movq 0x30(%rsp), %rcx
leaq (%rcx,%rcx,2), %rdx
shlq $0x3, %rdx
addq (%r13), %rdx
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsp)
movq 0x90(%rsp), %rcx
movq %rcx, (%rsp)
movq $0x0, 0x18(%rsp)
movq %r14, %rdi
movq %rax, %rcx
movq %rbx, %r9
movsd 0x48(%rsp), %xmm0
callq 0x1a0ae8
addq %rax, %r12
addq $0x28, %rbp
decq %r15
jne 0x1a67af
testq %r12, %r12
je 0x1a6919
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
leaq (%rsi,%rsi,8), %rax
leaq (%rax,%rax,2), %rax
addq %rdi, %rsi
addq %rax, %rsi
callq 0x195511
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
movss 0x2c(%rsp), %xmm0
callq 0x1a659a
movq %rax, %rcx
movl $0x1, %eax
testq %rcx, %rcx
jne 0x1a691b
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8dea0(%rip), %rdi     # 0x2347d1
leaq 0x8d053(%rip), %rsi     # 0x23398b
leaq 0x8dec3(%rip), %rcx     # 0x234802
movl $0x1233, %edx           # imm = 0x1233
callq 0x2110