// File: /workspace/github_cpp_makefile_star2_O3/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 0x1afb58
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 0x1af9a5
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq 0x10(%rbx), %rcx
jne 0x1af965
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
cmoveq %r14, %rdx
movq %rdx, 0x10(%rbx)
leaq (%rdx,%rdx,8), %rcx
leaq (%rcx,%rcx,2), %rsi
addq %rdx, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, (%rbx)
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
movq -0x8(%r12), %rcx
movq %rcx, 0x4(%rax,%rdx)
movl 0x18(%rax,%rdx), %ecx
movl %ecx, %esi
orl $0x40000000, %esi       # imm = 0x40000000
movl %esi, 0x18(%rax,%rdx)
cmpl $0x0, (%r12)
jns 0x1af9a5
addq %rdx, %rax
andl $0xbfffffff, %ecx       # imm = 0xBFFFFFFF
movl %ecx, 0x18(%rax)
addq $0x28, %r12
decq %r13
jne 0x1af927
movq 0x8(%rbx), %rsi
testq %rsi, %rsi
je 0x1afb58
movq (%rbx), %rdi
movss 0x2c(%rsp), %xmm0
callq 0x1af7f3
movq %rax, %rcx
movl $0x1, %eax
testq %rcx, %rcx
jne 0x1afb5a
movq $0x0, 0x8(%rbx)
xorl %r12d, %r12d
movq 0x40(%rsp), %r14
movq 0x38(%rsp), %r13
movslq (%rbp), %rsi
testq %rsi, %rsi
js 0x1afb0d
cmpl $0x0, 0x1c(%rbp)
js 0x1afa67
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq 0x10(%rbx), %rcx
jne 0x1afa41
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rdx
movq %rdx, 0x10(%rbx)
leaq (%rdx,%rdx,8), %rcx
leaq (%rcx,%rcx,2), %rsi
addq %rdx, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, (%rbx)
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
movq 0x14(%rbp), %rcx
movq %rcx, 0x4(%rax,%rdx)
orb $0x40, 0x1b(%rax,%rdx)
jmp 0x1afb0d
movq $0x0, 0x30(%rsp)
movl $0x1, %r8d
movq %r13, %rdi
leaq 0x30(%rsp), %rdx
xorl %ecx, %ecx
callq 0x1a7f4d
testq %rax, %rax
jle 0x1afb69
movq 0x50(%rsp), %rcx
movq (%rcx), %rsi
movslq (%rbp), %rcx
imulq $0xa8, %rcx, %rcx
cmpb $0x2, 0x2c(%rsi,%rcx)
jne 0x1afb69
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 0x1afb0d
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 0x1a9863
addq %rax, %r12
addq $0x28, %rbp
decq %r15
jne 0x1af9f3
testq %r12, %r12
je 0x1afb58
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
leaq (%rsi,%rsi,8), %rax
leaq (%rax,%rax,2), %rax
addq %rdi, %rsi
addq %rax, %rsi
callq 0x19e2b4
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
movss 0x2c(%rsp), %xmm0
callq 0x1af7f3
movq %rax, %rcx
movl $0x1, %eax
testq %rcx, %rcx
jne 0x1afb5a
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x90f31(%rip), %rdi     # 0x240aa1
leaq 0x900e4(%rip), %rsi     # 0x23fc5b
leaq 0x90f54(%rip), %rcx     # 0x240ad2
movl $0x1233, %edx           # imm = 0x1233
callq 0x2110