// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/inter.cpp
// Function: max_ovlp_src_contain(ug_opt_t const*, unsigned int)
int64_t max_ovlp_src_contain(const ug_opt_t *uopt, uint32_t v)
{
	ma_hit_t_alloc* src = uopt->sources;
    int64_t min_ovlp = uopt->min_ovlp, max_hang = uopt->max_hang;
	uint32_t i, qn, tn, o = 0, x = v>>1, dt; asg_arc_t e; int32_t r = 1;

	for (i = 0; i < src[x].length; i++) {
        qn = Get_qn(src[x].buffer[i]); tn = Get_tn(src[x].buffer[i]);
		r = ma_hit2arc(&(src[x].buffer[i]), Get_READ_LENGTH(R_INF, qn), Get_READ_LENGTH(R_INF, tn), 
														max_hang, asm_opt.max_hang_rate, min_ovlp, &e);
		// if(qn == 20171 && tn == 20172) {
		// 	fprintf(stderr, "[r::%d]\t%.*s\t%c\tq::[%u, %u)\t%.*s\tt::[%u, %u)\n", r,
        //             (int)Get_NAME_LENGTH(R_INF, qn), Get_NAME(R_INF, qn), "+-"[src[x].buffer[i].rev], 
		// 			Get_qs(src[x].buffer[i]), Get_qe(src[x].buffer[i]), 
		// 			(int)Get_NAME_LENGTH(R_INF, tn), Get_NAME(R_INF, tn),
		// 			Get_ts(src[x].buffer[i]), Get_te(src[x].buffer[i]));
		// }
		if(r >= 0) {
			if((e.ul>>32) != v) continue;
			if(o < e.ol) o = e.ol;
		} else if(r == MA_HT_TCONT) {///tn is contained in qn
			if(v&1) dt = Get_qe(src[x].buffer[i]);
			else dt = Get_READ_LENGTH(R_INF, qn) - Get_qs(src[x].buffer[i]);
			if(o < dt) o = dt;
		}
    }

	return o;
}

// Assembly:
movq 0x8(%rdi), %rcx
movl %esi, %eax
shrl %eax
leaq (%rax,%rax,2), %r8
movl 0xc(%rcx,%r8,8), %r9d
xorl %eax, %eax
testq %r9, %r9
je 0x1be2d8
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq $0x0, -0x20(%rsp)
movl 0x44(%rdi), %eax
movl 0x40(%rdi), %edx
leaq (%rcx,%r8,8), %rcx
movq (%rcx), %rdi
leaq 0xd80f9(%rip), %rcx     # 0x296230
movq 0x18(%rcx), %r8
leaq 0xd7616(%rip), %rcx     # 0x295758
movss 0x158(%rcx), %xmm0
movl %esi, -0x14(%rsp)
movl %esi, %ecx
movq %rcx, -0x10(%rsp)
movl %eax, %esi
shlq $0x3, %r9
leaq (%r9,%r9,4), %rax
movq %rax, -0x8(%rsp)
xorl %r11d, %r11d
movl %edx, -0x24(%rsp)
movl 0xc(%rdi,%r11), %eax
movl (%r8,%rax,8), %ebp
testb $-0x80, 0x1b(%rdi,%r11)
jne 0x1be191
movl 0x10(%rdi,%r11), %r9d
movl 0x14(%rdi,%r11), %r13d
subl %r13d, %ebp
movl %ebp, %r12d
movl %r9d, %ebp
jmp 0x1be1a1
movl 0x10(%rdi,%r11), %r9d
movl 0x14(%rdi,%r11), %r13d
subl %r13d, %ebp
movl %r9d, %r12d
movq (%rdi,%r11), %r14
movq %r14, %rax
shrq $0x20, %rax
movq (%r8,%rax,8), %rbx
cmpl %r14d, %ebp
movl %r14d, %eax
cmovll %ebp, %eax
movl 0x8(%rdi,%r11), %r15d
movl %ebx, %r10d
subl %r15d, %r10d
cmpl %r12d, %r10d
movl %r12d, %ecx
cmovll %r10d, %ecx
cmpl %edx, %eax
jg 0x1be257
cmpl %edx, %ecx
jg 0x1be257
movl %esi, %edx
movl %r15d, %esi
subl %r14d, %esi
xorps %xmm1, %xmm1
cvtsi2ss %rsi, %xmm1
addl %eax, %esi
addl %ecx, %esi
xorps %xmm2, %xmm2
cvtsi2ss %rsi, %xmm2
mulss %xmm0, %xmm2
ucomiss %xmm1, %xmm2
ja 0x1be251
subl %r9d, %r13d
xorps %xmm1, %xmm1
cvtsi2ss %r13, %xmm1
addl %eax, %ecx
addl %r13d, %ecx
xorps %xmm2, %xmm2
cvtsi2ss %rcx, %xmm2
mulss %xmm0, %xmm2
ucomiss %xmm1, %xmm2
ja 0x1be251
cmpl %ebp, %r14d
jg 0x1be22a
cmpl %r12d, %r10d
jle 0x1be251
cmpl %ebp, %r14d
jl 0x1be268
cmpl %r12d, %r10d
jl 0x1be268
subl %r14d, %ebx
testb $0x1, -0x14(%rsp)
cmovel %ebx, %r15d
movq -0x20(%rsp), %rax
cmpl %r15d, %eax
cmovbel %r15d, %eax
movq %rax, -0x20(%rsp)
movl %edx, %esi
movl -0x24(%rsp), %edx
addq $0x28, %r11
cmpq %r11, -0x8(%rsp)
jne 0x1be16b
jmp 0x1be2c7
cmpl %edx, %esi
movl %edx, %esi
jl 0x1be253
cmpl %esi, %ecx
jl 0x1be253
addl %r15d, %r12d
movl %ebx, %ecx
subl %r12d, %ecx
movl %r14d, %eax
subl %ebp, %eax
cmovlel %ecx, %eax
testl %eax, %eax
js 0x1be2bc
xorl %ecx, %ecx
cmpl %ebp, %r14d
setle %cl
shrq $0x1f, %r14
andl $-0x2, %r14d
orl %r14d, %ecx
cmpl -0x10(%rsp), %ecx
movl -0x24(%rsp), %edx
jne 0x1be257
subl %eax, %ebx
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
movq -0x20(%rsp), %rax
cmpl %ebx, %eax
cmoval %eax, %ebx
movq %rbx, -0x20(%rsp)
jmp 0x1be257
cmpl $-0x3, %eax
je 0x1be234
jmp 0x1be251
movq -0x20(%rsp), %rax
movl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq