// File: /workspace/github_cpp_makefile_star2_O1/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 %rdx, %r13
movq 0x30(%rcx), %rcx
movl %r8d, %eax
leaq (%rax,%rax,8), %rdx
movb 0x20(%rcx,%rdx,4), %al
testb $0x40, %al
jne 0x1d7731
leaq (%rcx,%rdx,4), %r15
movl (%r15), %ecx
cmpq %r9, %rcx
jne 0x1d7731
testb %al, %al
jns 0x1d7722
movl %r8d, %r12d
testl %r8d, %r8d
je 0x1d7722
andb $0x1f, %al
je 0x1d7722
movl (%r15), %eax
movl 0x20(%r15), %ecx
shrl $0x5, %ecx
andl $0x1, %ecx
leal (%rcx,%rax,2), %eax
movl %eax, 0xc(%rsp)
xorl $0x1, %eax
movq %rsi, 0x18(%rsp)
movq %rsi, %rdi
movl %eax, 0x8(%rsp)
movl %eax, %esi
callq 0x19c00f
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
movq 0x30(%rbx), %rsi
subl $-0x80, %r13d
movl %r12d, %edi
movl %r13d, %edx
callq 0x1d74cd
testl %eax, %eax
js 0x1d7722
movl %eax, %eax
leaq 0x1(%rax), %r12
shlq $0x2, %rax
leaq (%rax,%rax,8), %r14
leaq 0xb3bfe(%rip), %rbp     # 0x28b230
movq 0x30(%rbx), %rcx
movl 0x8(%rcx,%r14), %eax
subl $-0x80, %eax
cmpl 0x4(%r15), %eax
jbe 0x1d7722
movl 0x20(%rcx,%r14), %edx
testb $0x40, %dl
jne 0x1d7715
movl %edx, %eax
andb $0x1f, %al
je 0x1d7715
testb %dl, %dl
jns 0x1d7715
movl (%rcx,%r14), %eax
shrl $0x5, %edx
andl $0x1, %edx
leal (%rdx,%rax,2), %r13d
cmpl %r13d, 0xc(%rsp)
je 0x1d7715
movl 0x10(%r15), %esi
subl 0xc(%r15), %esi
movl (%r15), %edi
movq 0x18(%rbp), %rdx
cmpq %rsi, (%rdx,%rdi,8)
ja 0x1d7715
movl 0x10(%rcx,%r14), %esi
subl 0xc(%rcx,%r14), %esi
cmpq %rsi, (%rdx,%rax,8)
ja 0x1d7715
addq %r14, %rcx
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %rbp, %r8
xorl %r9d, %r9d
callq 0x6f050
xorl $0x1, %r13d
movq 0x18(%rsp), %rdi
movl 0x8(%rsp), %esi
movl %r13d, %edx
movq %rax, %rcx
movsd 0x10(%rsp), %xmm0
leaq 0x24(%rsp), %r8
callq 0x1a1445
testq %rax, %rax
je 0x1d7715
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, %r14
decq %r12
jg 0x1d7632
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x60807(%rip), %rdi     # 0x237f3f
leaq 0x5c24c(%rip), %rsi     # 0x23398b
leaq 0x60827(%rip), %rcx     # 0x237f6d
movl $0x4d7f, %edx           # imm = 0x4D7F
callq 0x2110