// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/inter.cpp
// Function: get_ecov_el(ul_idx_t const*, ug_opt_t const*, unsigned int, unsigned int, long, double, long, unsigned long, long*)
int64_t get_ecov_el(const ul_idx_t *uref, const ug_opt_t *uopt, uint32_t v, uint32_t w, int64_t bw, double diff_ec_ul, int64_t dq, uint64_t mode, int64_t *el)
{
	int64_t dt = -1, dif, mm; (*el) = 0;
	uint32_t nv, i; asg_arc_t *av = NULL; ///ma_hit_t *x = NULL;
	if(!mode) {
		const asg_t *g = uref?uref->ug->g:NULL;
		nv = asg_arc_n(g, v); av = asg_arc_a(g, v);
		for (i = 0; i < nv; i++) {
			if(av[i].del || av[i].v != w) continue;
			dt = av[i].ol; (*el) = av[i].el;
			// if(v==1772 && w==1769) fprintf(stderr, "+++v:%u, w:%u, ou:%u\n", v, w, av[i].ou);
			// if((v>>1) == 3012 && (w>>1) == 3011) fprintf(stderr, "******************\n");
			break;
		}
	}else {
		ma_hit_t_alloc* src = uopt->sources;
		int64_t min_ovlp = uopt->min_ovlp;
		int64_t max_hang = uopt->max_hang;
		uint64_t z, qn, tn, x = v>>1; int32_t r = 1; asg_arc_t e;
		for (z = 0; z < src[x].length; z++) {
			qn = Get_qn(src[x].buffer[z]); tn = Get_tn(src[x].buffer[z]);
			if(tn != (w>>1)) continue;
			r = ma_hit2arc(&(src[x].buffer[z]), Get_READ_LENGTH(R_INF, qn), Get_READ_LENGTH(R_INF, tn), max_hang, asm_opt.max_hang_rate, min_ovlp, &e);
			if(r < 0) continue;
			if((e.ul>>32) != v || e.v != w) continue;
			dt = e.ol; (*el) = src[x].buffer[z].el;
			break;
		}
	}
	if(dt < 0) return 0;
	dif = (dq>dt? dq-dt:dt-dq);
	mm = MAX(dq, dt); mm *= diff_ec_ul; if(mm < bw) mm = bw;
	// if((v>>1) == 1163 && (w>>1) == 1168) fprintf(stderr, ">>>>>>dis_q:%ld, dis_t:%ld, dif:%ld, mm:%ld\n", dis_q, dis_t, dif, mm);
	if(dif <= mm) return 1;
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq 0x40(%rsp), %r10
movq $0x0, (%r10)
cmpq $0x0, 0x38(%rsp)
je 0x1b49c4
movq 0x8(%rsi), %rax
movl %edx, %edi
shrl %edi
leaq (%rdi,%rdi,2), %r10
movl 0xc(%rax,%r10,8), %edi
testq %rdi, %rdi
je 0x1b4a0d
movq %r9, -0x18(%rsp)
movq %r8, -0x10(%rsp)
movl 0x44(%rsi), %r8d
movl %r8d, -0x30(%rsp)
movl 0x40(%rsi), %esi
movl %esi, -0x2c(%rsp)
leaq (%rax,%r10,8), %rax
movq (%rax), %rsi
movl %ecx, %r14d
shrl %r14d
leaq 0xe1a3e(%rip), %rax     # 0x296230
movq 0x18(%rax), %rax
movq %rax, -0x20(%rsp)
leaq 0xe0f56(%rip), %rax     # 0x295758
movss 0x158(%rax), %xmm1
movl %edx, %eax
movq %rax, -0x8(%rsp)
movl %ecx, -0x24(%rsp)
andl $-0x2, %ecx
movl %ecx, -0x28(%rsp)
addq $0x20, %rsi
cmpl %r14d, -0x14(%rsi)
jne 0x1b48de
movq -0x8(%rsi), %rcx
movq -0x20(%rsp), %rax
movl (%rax,%r14,8), %edx
testl %ecx, %ecx
js 0x1b484c
movl -0x10(%rsi), %ebx
movl -0xc(%rsi), %r9d
subl %r9d, %edx
movl %edx, %r11d
movl %ebx, %edx
jmp 0x1b4859
movl -0x10(%rsi), %ebx
movl -0xc(%rsi), %r9d
subl %r9d, %edx
movl %ebx, %r11d
movq -0x20(%rsi), %r10
movq %r10, %rax
shrq $0x20, %rax
movq -0x20(%rsp), %r8
movl (%r8,%rax,8), %r13d
cmpl %r10d, %edx
movl %r10d, %r15d
cmovll %edx, %r15d
movl -0x18(%rsi), %r8d
movl %r13d, %r12d
subl %r8d, %r12d
cmpl %r11d, %r12d
movl %r11d, %ebp
cmovll %r12d, %ebp
cmpl -0x2c(%rsp), %r15d
jg 0x1b48de
cmpl -0x2c(%rsp), %ebp
jg 0x1b48de
movl %r8d, %eax
subl %r10d, %eax
xorps %xmm2, %xmm2
cvtsi2ss %rax, %xmm2
addl %r15d, %eax
addl %ebp, %eax
xorps %xmm3, %xmm3
cvtsi2ss %rax, %xmm3
mulss %xmm1, %xmm3
ucomiss %xmm2, %xmm3
ja 0x1b48de
subl %ebx, %r9d
xorps %xmm2, %xmm2
cvtsi2ss %r9, %xmm2
addl %r15d, %ebp
addl %r9d, %ebp
xorps %xmm3, %xmm3
cvtsi2ss %rbp, %xmm3
mulss %xmm1, %xmm3
ucomiss %xmm2, %xmm3
jbe 0x1b48f0
addq $0x28, %rsi
decq %rdi
jne 0x1b4820
jmp 0x1b4a0d
cmpl %r11d, %r12d
setl %r9b
setg %r15b
cmpl %edx, %r10d
setg %r12b
setl %bl
orb %r15b, %r12b
cmpb $0x1, %r12b
jne 0x1b48de
orb %r9b, %bl
je 0x1b48de
cmpl -0x30(%rsp), %eax
jl 0x1b48de
cmpl -0x30(%rsp), %ebp
jl 0x1b48de
addl %r8d, %r11d
movl %r13d, %r8d
subl %r11d, %r8d
movl %r10d, %eax
subl %edx, %eax
cmovlel %r8d, %eax
testl %eax, %eax
js 0x1b48de
xorl %r9d, %r9d
cmpl %edx, %r10d
setle %r9b
setg %dl
testl %ecx, %ecx
setns %r8b
shrq $0x1f, %r10
andl $-0x2, %r10d
orl %r10d, %r9d
cmpl -0x8(%rsp), %r9d
jne 0x1b48de
xorb %dl, %r8b
movzbl %r8b, %edx
orl -0x28(%rsp), %edx
cmpl -0x24(%rsp), %edx
jne 0x1b48de
subl %eax, %r13d
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
movq -0x10(%rsp), %r8
movq 0x40(%rsp), %r10
movq -0x18(%rsp), %r9
movl %r13d, %eax
movq %rax, %rcx
subq %r9, %rcx
cmovgq %rax, %r9
movq %rcx, %rdi
negq %rdi
cmovsq %rcx, %rdi
cvtsi2sd %r9, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %rcx
movzbl (%rsi), %edx
cmpq %r8, %rcx
cmovgq %rcx, %r8
movq %rdx, (%r10)
xorl %eax, %eax
cmpq %r8, %rdi
setle %al
jmp 0x1b4a0f
movq (%rdi), %rax
movq 0x18(%rax), %rsi
movq 0x28(%rsi), %rax
movl %edx, %edx
movq (%rax,%rdx,8), %rax
testl %eax, %eax
je 0x1b4a0d
movq 0x8(%rsi), %rsi
movq %rax, %rdx
shrq $0x20, %rdx
movl %eax, %edi
leaq (%rdx,%rdx,2), %rdx
leaq (%rsi,%rdx,8), %rsi
addq $0x12, %rsi
xorl %eax, %eax
movl -0x6(%rsi), %r13d
testl %r13d, %r13d
js 0x1b4a02
cmpl %ecx, -0xa(%rsi)
je 0x1b4988
addq $0x18, %rsi
decq %rdi
jne 0x1b49f4
jmp 0x1b4a0f
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq