// File: /workspace/github_cpp_makefile_star2_O3/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, 0x10(%rsp)
movq 0x30(%rcx), %r14
movl %r8d, %eax
leaq (%rax,%rax,8), %rcx
movzbl 0x20(%r14,%rcx,4), %eax
testb $0x40, %al
jne 0x1e160c
leaq (%r14,%rcx,4), %r15
movl (%r15), %ecx
cmpq %r9, %rcx
jne 0x1e160c
testb %al, %al
jns 0x1e15fd
movl %r8d, %r12d
testl %r8d, %r8d
je 0x1e15fd
movq %rdx, %r13
movl %eax, %edx
andb $0x1f, %dl
je 0x1e15fd
shrl $0x5, %eax
andl $0x1, %eax
leal (%rax,%rcx,2), %eax
movl %eax, 0xc(%rsp)
xorl $0x1, %eax
movq %rsi, 0x18(%rsp)
movq %rsi, %rdi
movl %eax, 0x8(%rsp)
movl %eax, %esi
callq 0x1a4c50
movl 0x4(%r15), %ecx
addq %rax, %rcx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
mulsd 0x10(%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
subl $-0x80, %r13d
movl %r12d, %edi
movq %r14, %rsi
movl %r13d, %edx
callq 0x1e13ab
testl %eax, %eax
js 0x1e15fd
movl %eax, %eax
leaq 0x1(%rax), %r13
shlq $0x2, %rax
leaq (%rax,%rax,8), %r12
leaq 0xb4d23(%rip), %rbp     # 0x296230
movq 0x30(%rbx), %rcx
movl 0x8(%rcx,%r12), %eax
subl $-0x80, %eax
cmpl 0x4(%r15), %eax
jbe 0x1e15fd
movl 0x20(%rcx,%r12), %edx
testb $0x40, %dl
jne 0x1e15f0
movl %edx, %eax
andb $0x1f, %al
je 0x1e15f0
testb %dl, %dl
jns 0x1e15f0
movl (%rcx,%r12), %eax
shrl $0x5, %edx
andl $0x1, %edx
leal (%rdx,%rax,2), %r14d
cmpl %r14d, 0xc(%rsp)
je 0x1e15f0
movl 0x10(%r15), %esi
subl 0xc(%r15), %esi
movl (%r15), %edi
movq 0x18(%rbp), %rdx
cmpq %rsi, (%rdx,%rdi,8)
ja 0x1e15f0
movl 0x10(%rcx,%r12), %esi
subl 0xc(%rcx,%r12), %esi
cmpq %rsi, (%rdx,%rax,8)
ja 0x1e15f0
addq %r12, %rcx
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %rbp, %r8
xorl %r9d, %r9d
callq 0x6ea22
xorl $0x1, %r14d
movq 0x18(%rsp), %rdi
movl 0x8(%rsp), %esi
movl %r14d, %edx
movq %rax, %rcx
movsd 0x10(%rsp), %xmm0
leaq 0x24(%rsp), %r8
callq 0x1aa28b
testq %rax, %rax
je 0x1e15f0
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)
addq $-0x24, %r12
decq %r13
jg 0x1e150d
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x62bfc(%rip), %rdi     # 0x24420f
leaq 0x5e641(%rip), %rsi     # 0x23fc5b
leaq 0x62c1c(%rip), %rcx     # 0x24423d
movl $0x4d7f, %edx           # imm = 0x4D7F
callq 0x2110