// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/inter.cpp
// Function: determine_connective_adv(all_ul_t*, ug_opt_t const*, long, double, ul_vec_t*, unsigned int, unsigned long)
void determine_connective_adv(all_ul_t *m, const ug_opt_t *uopt, int64_t bw, double diff_ec_ul, ul_vec_t *p, uint32_t ii, uint64_t rid)
{
	assert((!p->bb.a[ii].base)&&(p->bb.a[ii].hid == rid));
	if(ii <= 0) return;
	if(!(p->bb.a[ii].pchain)) return; ///not a primary chain
	if(!(p->bb.a[ii].el)) return; ///not a cis alignment
	uint32_t li_v, lk_v, ol; int64_t mm_ovlp, k, x; 
	uc_block_t *li = NULL, *lk = NULL;
	ma_hit_t *t = NULL;
	li = &(p->bb.a[ii]); li_v = (((uint32_t)(li->hid))<<1)|((uint32_t)(li->rev));
	mm_ovlp = max_ovlp_src(uopt, li_v^1);
	x = (li->qs + mm_ovlp)*diff_ec_ul; 
	if(x < bw) x = bw; 
	x += li->qs + mm_ovlp;
	if (x > p->rlen+1) x = p->rlen+1;
	x = find_ul_block_max(ii, p->bb.a, x+G_CHAIN_INDEL);
	for (k = x; k >= 0; --k) { // collect potential destination vertices
		lk = &(p->bb.a[k]); lk_v = (((uint32_t)(lk->hid))<<1)|((uint32_t)(lk->rev));
		if(lk->qe+G_CHAIN_INDEL <= li->qs) break;//even this pair has a overlap, its length will be very small; just ignore
		if(lk->base || (!(lk->pchain)) || (!(lk->el))) continue; 
		if(li_v == lk_v) continue;
		// if(li->qs <= 0) continue;///means the UL read does not longer than the overlap between li and lk
		// if(lk->qs <= 0) continue;//the UL read should be cover the whole HiFi reads li and lk
		// if(((li->te - li->ts)*1.05) < Get_READ_LENGTH(R_INF, li->hid)) continue;
		// if(((lk->te - lk->ts)*1.05) < Get_READ_LENGTH(R_INF, lk->hid)) continue;
		if((li->te - li->ts) < Get_READ_LENGTH(R_INF, li->hid)) continue;
		if((lk->te - lk->ts) < Get_READ_LENGTH(R_INF, lk->hid)) continue;
		x = /**((int64_t)(lk->qe))-((int64_t)(li->qs))**/infer_rovlp(NULL, NULL, li, lk, &R_INF, NULL);
		t = query_ovlp_src(uopt, li_v^1, lk_v^1, x, diff_ec_ul, &ol);
		if(t) {
			// sum = t->bl + ol;
			// t->bl = (sum & 0x7fffffffU);
			t->bl++;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %rbx
movsd %xmm0, 0x8(%rsp)
movq 0x30(%rcx), %r15
movl %r8d, %eax
imulq $0x24, %rax, %rcx
movzbl 0x20(%r15,%rcx), %eax
testb $0x40, %al
jne 0x1946b0
addq %rcx, %r15
movl (%r15), %ecx
cmpq %r9, %rcx
jne 0x1946b0
testb %al, %al
jns 0x1946a1
movl %r8d, %r12d
testl %r8d, %r8d
je 0x1946a1
movq %rdx, %r13
movl %eax, %edx
andb $0x1f, %dl
je 0x1946a1
shrl $0x5, %eax
andl $0x1, %eax
leal (%rax,%rcx,2), %ebp
movl %ebp, %eax
xorl $0x1, %eax
movq %rsi, 0x18(%rsp)
movq %rsi, %rdi
movl %eax, 0x4(%rsp)
movl %eax, %esi
callq 0x15d49a
movl 0x4(%r15), %ecx
addq %rax, %rcx
cvtsi2sd %rcx, %xmm0
mulsd 0x8(%rsp), %xmm0
cvttsd2si %xmm0, %rax
cmpq %r13, %rax
cmovgq %rax, %r13
addq %rcx, %r13
movl 0x18(%rbx), %eax
incl %eax
cmpq %rax, %r13
cmovgeq %rax, %r13
movq 0x30(%rbx), %rsi
subl $-0x80, %r13d
movl %r12d, %edi
movl %r13d, %edx
callq 0x194442
movl %ebp, %r8d
movslq %eax, %r14
imulq $0x24, %r14, %r12
leaq 0xbfc99(%rip), %rbp     # 0x254230
movq %rbx, 0x10(%rsp)
testq %r14, %r14
js 0x1946a1
movq 0x30(%rbx), %rcx
movl 0x8(%rcx,%r12), %eax
subl $-0x80, %eax
cmpl 0x4(%r15), %eax
jbe 0x1946a1
movl 0x20(%rcx,%r12), %edx
testb $0x40, %dl
jne 0x194695
movl %edx, %eax
andb $0x1f, %al
je 0x194695
testb %dl, %dl
jns 0x194695
movl (%rcx,%r12), %eax
shrl $0x5, %edx
andl $0x1, %edx
leal (%rdx,%rax,2), %r13d
cmpl %r13d, %r8d
je 0x194695
movl 0x10(%r15), %esi
subl 0xc(%r15), %esi
movl (%r15), %edi
movq 0x18(%rbp), %rdx
cmpq %rsi, (%rdx,%rdi,8)
ja 0x194695
movl 0x10(%rcx,%r12), %esi
subl 0xc(%rcx,%r12), %esi
cmpq %rsi, (%rdx,%rax,8)
ja 0x194695
addq %r12, %rcx
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movl %r8d, %ebx
movq %rbp, %r8
xorl %r9d, %r9d
callq 0x3d261
xorl $0x1, %r13d
movq 0x18(%rsp), %rdi
movl 0x4(%rsp), %esi
movl %r13d, %edx
movq %rax, %rcx
movsd 0x8(%rsp), %xmm0
leaq 0x24(%rsp), %r8
callq 0x1621e3
movl %ebx, %r8d
movq 0x10(%rsp), %rbx
testq %rax, %rax
je 0x194695
movq 0x18(%rax), %rcx
movabsq $0x100000000, %rdx      # imm = 0x100000000
addq %rcx, %rdx
movabsq $0x7fffffff00000000, %rsi # imm = 0x7FFFFFFF00000000
andq %rsi, %rdx
movabsq $-0x7fffffff00000001, %rsi # imm = 0x80000000FFFFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, 0x18(%rax)
decq %r14
addq $-0x24, %r12
jmp 0x19459c
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x61a20(%rip), %rdi     # 0x1f60d7
leaq 0x5d465(%rip), %rsi     # 0x1f1b23
leaq 0x61a40(%rip), %rcx     # 0x1f6105
movl $0x4d7f, %edx           # imm = 0x4D7F
callq 0x2110