// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/inter.cpp
// Function: determine_connective_backtrack(all_ul_t*, ug_opt_t const*, ul_vec_t*, unsigned int, unsigned long, unsigned long)
void determine_connective_backtrack(all_ul_t *m, const ug_opt_t *uopt, ul_vec_t *p, uint32_t ii, uint64_t rid, uint64_t ulid)
{
	assert((!p->bb.a[ii].base)&&(p->bb.a[ii].hid == rid)&&(p->bb.a[ii].el));
	if(ii <= 0) return;
	if(!(p->bb.a[ii].pchain)) return; ///not a primary chain
	if(p->bb.a[ii].pidx == (uint32_t)-1) return; ///not connected
	uint32_t li_v, lk_v, z, qn, tn; int32_t r; uc_block_t *li = NULL, *lk = NULL; asg_arc_t t; 
	li = &(p->bb.a[ii]); li_v = (((uint32_t)(li->hid))<<1)|((uint32_t)(li->rev)); li_v^=1;
	if((li->te - li->ts) < Get_READ_LENGTH(R_INF, li->hid)) return;
	ma_hit_t_alloc *x = &(uopt->sources[li_v>>1]);
    int64_t min_ovlp = uopt->min_ovlp;
    int64_t max_hang = uopt->max_hang;
	// if(rid == 4217) fprintf(stderr, "rid: %lu, p->bb.n: %u\n", rid, p->bb.n);

	for (lk = &(p->bb.a[li->pidx]); lk; ) {
		lk_v = (((uint32_t)(lk->hid))<<1)|((uint32_t)(lk->rev)); lk_v^=1;
		assert((!(lk->base)) && (lk->pchain) && (lk->el));
		if((lk->te - lk->ts) >= Get_READ_LENGTH(R_INF, lk->hid)) {
			for (z = 0; z < x->length; z++) {
				qn = Get_qn(x->buffer[z]);
				tn = Get_tn(x->buffer[z]);
				if(qn == (li_v>>1) && tn == (lk_v>>1)) {
					r = ma_hit2arc(&(x->buffer[z]), Get_READ_LENGTH(R_INF, li_v>>1), Get_READ_LENGTH(R_INF, lk_v>>1),
						max_hang, asm_opt.max_hang_rate, min_ovlp, &t);
					if(r < 0) continue;
					if((t.ul>>32) != li_v || t.v != lk_v) continue;
					break;
				}
			}
			if(z < x->length) {
				x->buffer[z].bl++;
				// if(((li_v>>1) == 1656459) || ((li_v>>1) == 4179430)|| 
				// 	((lk_v>>1) == 1656459) || ((lk_v>>1) == 4179430)) {
				// 	fprintf(stderr, "[M::%s::]\tulid::%lu\n", __func__, ulid);
				// }
			}
		}

		lk = ((lk->pidx==(uint32_t)-1)?NULL:&(p->bb.a[lk->pidx]));
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, 0x40(%rsp)
movq 0x30(%rdx), %rdx
movl %ecx, %eax
leaq (%rax,%rax,8), %rax
movzbl 0x20(%rdx,%rax,4), %edi
testb $0x40, %dil
jne 0x1e1987
testb %dil, %dil
jns 0x1e1987
leaq (%rdx,%rax,4), %rax
movl (%rax), %r9d
cmpq %r8, %r9
jne 0x1e1987
testl %ecx, %ecx
je 0x1e1959
movl %edi, %ecx
andb $0x1f, %cl
je 0x1e1959
movq %r9, %r10
movl 0x14(%rax), %ecx
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
cmpq %r9, %rcx
je 0x1e1959
movl 0x10(%rax), %r9d
subl 0xc(%rax), %r9d
leaq 0xb4b89(%rip), %rax     # 0x296230
movq 0x18(%rax), %rax
cmpq %r9, (%rax,%r8,8)
ja 0x1e1959
shrl $0x5, %edi
andl $0x1, %edi
leal (%rdi,%r10,2), %eax
xorl $0x1, %eax
movq %rax, 0x30(%rsp)
andl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
movq %r10, %r13
leaq (%r10,%r10,2), %rax
shlq $0x3, %rax
addq 0x8(%rsi), %rax
movq %rax, 0x18(%rsp)
movl 0x40(%rsi), %eax
movl %eax, 0x10(%rsp)
movl 0x44(%rsi), %eax
movl %eax, 0xc(%rsp)
leaq (%rcx,%rcx,8), %rax
leaq (%rdx,%rax,4), %rdx
movl 0x20(%rdx), %ecx
movl %ecx, %eax
andb $-0x40, %al
negb %al
jno 0x1e1968
movl %ecx, %eax
andb $0x1f, %al
je 0x1e1968
movl 0x10(%rdx), %eax
subl 0xc(%rdx), %eax
movq %rdx, 0x48(%rsp)
movl (%rdx), %esi
leaq 0xb4b0b(%rip), %rdx     # 0x296230
movq 0x18(%rdx), %rdi
movq %rdi, 0x20(%rsp)
cmpq %rax, (%rdi,%rsi,8)
ja 0x1e192d
movq 0x18(%rsp), %rax
movl 0xc(%rax), %eax
testq %rax, %rax
je 0x1e192d
movq %rsi, %rdx
shrl $0x5, %ecx
andl $0x1, %ecx
leal (%rcx,%rsi,2), %ecx
movl %ecx, 0x14(%rsp)
movq 0x18(%rsp), %rcx
movq (%rcx), %rbx
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq %rcx, 0x28(%rsp)
leaq 0xb3fe3(%rip), %rcx     # 0x295758
movss 0x158(%rcx), %xmm0
addl %edx, %edx
movq %rdx, 0x38(%rsp)
shlq $0x3, %rax
leaq (%rax,%rax,4), %rdi
xorl %r11d, %r11d
movq (%rbx,%r11), %rsi
movq %rsi, %rax
shrq $0x20, %rax
cmpl %eax, %r13d
jne 0x1e1869
movq 0x28(%rsp), %rax
cmpl %eax, 0xc(%rbx,%r11)
jne 0x1e1869
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
movl (%rax,%rcx,8), %r14d
movq 0x18(%rbx,%r11), %rax
movq %rax, 0x50(%rsp)
testl %eax, %eax
js 0x1e17e4
movl 0x10(%rbx,%r11), %r12d
movl 0x14(%rbx,%r11), %r9d
subl %r9d, %r14d
movl %r14d, %ecx
movl %r12d, %r14d
jmp 0x1e17f4
movl 0x10(%rbx,%r11), %r12d
movl 0x14(%rbx,%r11), %r9d
subl %r9d, %r14d
movl %r12d, %ecx
movq 0x20(%rsp), %rax
movl (%rax,%r13,8), %r10d
cmpl %esi, %r14d
movl %esi, %eax
cmovll %r14d, %eax
movl 0x8(%rbx,%r11), %r15d
movl %r10d, %r8d
subl %r15d, %r8d
cmpl %ecx, %r8d
movl %ecx, %edx
cmovll %r8d, %edx
cmpl 0x10(%rsp), %eax
jg 0x1e1869
cmpl 0x10(%rsp), %edx
jg 0x1e1869
movl %r15d, %ebp
subl %esi, %ebp
xorps %xmm1, %xmm1
cvtsi2ss %rbp, %xmm1
addl %eax, %ebp
addl %edx, %ebp
xorps %xmm2, %xmm2
cvtsi2ss %rbp, %xmm2
mulss %xmm0, %xmm2
ucomiss %xmm1, %xmm2
ja 0x1e1869
subl %r12d, %r9d
xorps %xmm1, %xmm1
cvtsi2ss %r9, %xmm1
addl %eax, %edx
addl %r9d, %edx
xorps %xmm2, %xmm2
cvtsi2ss %rdx, %xmm2
mulss %xmm0, %xmm2
ucomiss %xmm1, %xmm2
jbe 0x1e187b
addq $0x28, %r11
cmpq %r11, %rdi
jne 0x1e178f
jmp 0x1e192d
cmpl %ecx, %r8d
setl %al
setg %r9b
cmpl %r14d, %esi
setg %r12b
setl %r8b
orb %r9b, %r12b
cmpb $0x1, %r12b
jne 0x1e1869
orb %al, %r8b
je 0x1e1869
cmpl 0xc(%rsp), %ebp
jl 0x1e1869
cmpl 0xc(%rsp), %edx
jl 0x1e1869
cmpl $0x0, 0x50(%rsp)
setns %al
addl %r15d, %ecx
subl %ecx, %r10d
xorl %edx, %edx
movl %esi, %r9d
subl %r14d, %r9d
setle %r8b
setg %cl
cmovlel %r10d, %r9d
testl %r9d, %r9d
js 0x1e1869
movb %r8b, %dl
shrq $0x1f, %rsi
andl $-0x2, %esi
orq %rdx, %rsi
cmpl 0x30(%rsp), %esi
jne 0x1e1869
xorb %cl, %al
movzbl %al, %eax
orl 0x38(%rsp), %eax
xorl 0x14(%rsp), %eax
cmpl $0x1, %eax
jne 0x1e1869
movq 0x18(%rbx,%r11), %rax
movabsq $0x100000000, %rcx      # imm = 0x100000000
addq %rax, %rcx
movabsq $0x7fffffff00000000, %rdx # imm = 0x7FFFFFFF00000000
andq %rdx, %rcx
movabsq $-0x7fffffff00000001, %rdx # imm = 0x80000000FFFFFFFF
andq %rdx, %rax
orq %rcx, %rax
movq %rax, 0x18(%rbx,%r11)
movq 0x48(%rsp), %rax
movl 0x14(%rax), %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
je 0x1e1959
movq 0x40(%rsp), %rcx
movq 0x30(%rcx), %rcx
leaq (%rax,%rax,8), %rax
leaq (%rcx,%rax,4), %rdx
testq %rcx, %rcx
jne 0x1e16f8
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x629e7(%rip), %rdi     # 0x244356
leaq 0x5e2e5(%rip), %rsi     # 0x23fc5b
leaq 0x6296d(%rip), %rcx     # 0x2442ea
movl $0x4db2, %edx           # imm = 0x4DB2
callq 0x2110
leaq 0x6291c(%rip), %rdi     # 0x2442aa
leaq 0x5e2c6(%rip), %rsi     # 0x23fc5b
leaq 0x6294e(%rip), %rcx     # 0x2442ea
movl $0x4da4, %edx           # imm = 0x4DA4
callq 0x2110