// File: 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
movq %rsp, %rbp
subq $0xb0, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movsd %xmm0, -0x40(%rbp)
movss %xmm1, -0x44(%rbp)
cmpq $0x0, -0x18(%rbp)
jg 0x2995f5
movq $0x0, -0x8(%rbp)
jmp 0x299a75
movq $0x0, -0x78(%rbp)
movq -0x20(%rbp), %rax
movq $0x0, 0x8(%rax)
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x18(%rbp), %rax
jge 0x29973a
movq -0x10(%rbp), %rax
imulq $0x28, -0x50(%rbp), %rcx
addq %rcx, %rax
cmpl $0x0, (%rax)
jge 0x299635
jmp 0x299729
jmp 0x299637
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x20(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x29969b
movq -0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x299665
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
shlq %rax
movq %rax, -0x80(%rbp)
jmp 0x299670
movl $0x2, %eax
movq %rax, -0x80(%rbp)
jmp 0x299670
movq -0x80(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rax
imulq $0x1c, 0x10(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq -0x20(%rbp), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x8(%rdx)
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rax
imulq $0x28, -0x50(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %ecx
movq -0x68(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
imulq $0x28, -0x50(%rbp), %rcx
addq %rcx, %rax
movl 0x18(%rax), %ecx
movq -0x68(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x68(%rbp), %rax
movl 0x18(%rax), %ecx
andl $0xbfffffff, %ecx       # imm = 0xBFFFFFFF
orl $0x40000000, %ecx       # imm = 0x40000000
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rax
imulq $0x28, -0x50(%rbp), %rcx
addq %rcx, %rax
cmpl $0x0, 0x1c(%rax)
jge 0x299727
movq -0x68(%rbp), %rax
movl 0x18(%rax), %ecx
andl $0xbfffffff, %ecx       # imm = 0xBFFFFFFF
orl $0x0, %ecx
movl %ecx, 0x18(%rax)
jmp 0x299729
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x299611
movq -0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
ja 0x299752
movq $0x0, -0x8(%rbp)
jmp 0x299a75
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
movss -0x44(%rbp), %xmm0
callq 0x2993b0
cmpq $0x0, %rax
je 0x29977e
movq $0x1, -0x8(%rbp)
jmp 0x299a75
movq -0x20(%rbp), %rax
movq $0x0, 0x8(%rax)
movq $0x0, -0x58(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x18(%rbp), %rax
jge 0x299a1c
movq -0x10(%rbp), %rax
imulq $0x28, -0x50(%rbp), %rcx
addq %rcx, %rax
cmpl $0x0, (%rax)
jge 0x2997be
jmp 0x299a0b
movq -0x10(%rbp), %rax
imulq $0x28, -0x50(%rbp), %rcx
addq %rcx, %rax
cmpl $0x0, 0x1c(%rax)
jl 0x2998af
jmp 0x2997d6
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x20(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x299843
movq -0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x299807
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
shlq %rax
movq %rax, -0x88(%rbp)
jmp 0x299815
movl $0x2, %eax
movq %rax, -0x88(%rbp)
jmp 0x299815
movq -0x88(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rax
imulq $0x1c, 0x10(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq -0x20(%rbp), %rdx
movq 0x8(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x8(%rdx)
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rax
imulq $0x28, -0x50(%rbp), %rcx
addq %rcx, %rax
movl 0x14(%rax), %ecx
movq -0x68(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
imulq $0x28, -0x50(%rbp), %rcx
addq %rcx, %rax
movl 0x18(%rax), %ecx
movq -0x68(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x68(%rbp), %rax
movl 0x18(%rax), %ecx
andl $0xbfffffff, %ecx       # imm = 0xBFFFFFFF
orl $0x40000000, %ecx       # imm = 0x40000000
movl %ecx, 0x18(%rax)
jmp 0x299a09
movq $0x0, -0x70(%rbp)
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
imulq $0x28, -0x50(%rbp), %rcx
addq %rcx, %rax
movslq (%rax), %rsi
leaq -0x70(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
movl $0x1, %r8d
callq 0x28c790
movq %rax, -0x60(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x60(%rbp)
movb %al, -0x89(%rbp)
jle 0x299920
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
imulq $0x28, -0x50(%rbp), %rdx
addq %rdx, %rcx
movslq (%rcx), %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movzbl 0x2c(%rax), %eax
cmpl $0x2, %eax
sete %al
movb %al, -0x89(%rbp)
movb -0x89(%rbp), %al
testb $0x1, %al
jne 0x29992c
jmp 0x29992e
jmp 0x29994d
leaq 0xf7d40(%rip), %rdi     # 0x391675
leaq 0xf6ef3(%rip), %rsi     # 0x39082f
movl $0x1233, %edx           # imm = 0x1233
leaq 0xf7d5e(%rip), %rcx     # 0x3916a6
callq 0x2130
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rcx), %rcx
movq -0x10(%rbp), %rdx
imulq $0x28, -0x50(%rbp), %rsi
addq %rsi, %rdx
movslq (%rdx), %rdx
imulq $0xa8, %rdx, %rdx
addq %rdx, %rcx
movl 0x10(%rcx), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpl $0x1, 0x10(%rax)
jbe 0x299a07
movq -0x38(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rsi
movq -0x10(%rbp), %rax
imulq $0x28, -0x50(%rbp), %rcx
addq %rcx, %rax
movslq (%rax), %rax
imulq $0xa8, %rax, %rax
addq %rax, %rsi
movq -0x30(%rbp), %rax
movq (%rax), %rdx
imulq $0x18, -0x70(%rbp), %rax
addq %rax, %rdx
movq -0x60(%rbp), %rcx
movq -0x78(%rbp), %r8
movq -0x20(%rbp), %r9
movsd -0x40(%rbp), %xmm0
movq 0x10(%rbp), %rax
xorl %r10d, %r10d
movq %rax, (%rsp)
movq $0x0, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
callq 0x28f130
addq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0x299a09
jmp 0x299a0b
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x29979a
cmpq $0x0, -0x58(%rbp)
je 0x299a6d
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rsi
movq -0x20(%rbp), %rax
imulq $0x1c, 0x8(%rax), %rax
addq %rax, %rsi
callq 0x27b350
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
movss -0x44(%rbp), %xmm0
callq 0x2993b0
cmpq $0x0, %rax
je 0x299a6b
movq $0x1, -0x8(%rbp)
jmp 0x299a75
jmp 0x299a6d
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)