// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/inter.cpp
// Function: trans_ovlp_connect(ul_ov_t*, ma_ug_t*)
uint32_t trans_ovlp_connect(ul_ov_t *p, ma_ug_t *ug)
{
	uint32_t v = p->qn<<1, w = (p->tn<<1) + ((uint32_t)p->rev), i, dg = (uint32_t)-1, da, dif, mm;
	asg_arc_t *av = asg_arc_a(ug->g, v); uint32_t nv = asg_arc_n(ug->g, v);
	for (i = 0; i < nv; i++) {
		if(av[i].del || av[i].v != w) continue;
		dg = av[i].ol; 
		break;
	}
	// if(i >= nv) return 1;
	if(i < nv) {
		da = (p->qe - p->qs);
		dif = (dg>da? dg-da:da-dg); mm = MAX(dg, da); mm *= 0.06; if(mm < 8) mm = 8;
		if(dif <= mm) return 0;

		da = (p->te - p->ts);
		dif = (dg>da? dg-da:da-dg); mm = MAX(dg, da); mm *= 0.06; if(mm < 8) mm = 8;
		if(dif <= mm) return 0;
	}


	v ^= 1; w ^= 1; dg = (uint32_t)-1;
	av = asg_arc_a(ug->g, v); nv = asg_arc_n(ug->g, v);
	for (i = 0; i < nv; i++) {
		if(av[i].del || av[i].v != w) continue;
		dg = av[i].ol; 
		break;
	}
	if(i < nv) {
		da = (p->qe - p->qs);
		dif = (dg>da? dg-da:da-dg); mm = MAX(dg, da); mm *= 0.06; if(mm < 8) mm = 8;
		if(dif <= mm) return 0;

		da = (p->te - p->ts);
		dif = (dg>da? dg-da:da-dg); mm = MAX(dg, da); mm *= 0.06; if(mm < 8) mm = 8;
		if(dif <= mm) return 0;
	}

	return 1;
}

// Assembly:
pushq %r14
pushq %rbx
movl (%rdi), %r8d
movl 0xc(%rdi), %eax
movl 0x18(%rdi), %edx
shrdl $0x1f, %eax, %edx
addl %r8d, %r8d
movq 0x18(%rsi), %rax
movq 0x8(%rax), %rsi
movq 0x28(%rax), %r9
movq (%r9,%r8,8), %rax
movl %eax, %ecx
movq %rax, %r10
shrq $0x20, %r10
imulq $0x18, %rcx, %rax
imulq $0x18, %r10, %rcx
leaq (%rcx,%rsi), %r11
addq $0xc, %r11
xorl %ebx, %ebx
movl $0x8, %ecx
cmpq %rbx, %rax
je 0x178922
movl (%r11,%rbx), %r10d
testl %r10d, %r10d
js 0x17889e
cmpl %edx, -0x4(%r11,%rbx)
je 0x1788a4
addq $0x18, %rbx
jmp 0x178885
movl 0x8(%rdi), %r11d
subl 0x4(%rdi), %r11d
movl %r10d, %eax
subl %r11d, %eax
movl %r11d, %ebx
cmoval %r10d, %ebx
subl %r10d, %r11d
cmovbl %eax, %r11d
cvtsi2sd %rbx, %xmm0
mulsd 0x6aceb(%rip), %xmm0    # 0x1e35b8
cvttsd2si %xmm0, %rbx
cmpl $0x9, %ebx
cmovbl %ecx, %ebx
xorl %eax, %eax
cmpl %ebx, %r11d
jbe 0x1789d9
movl 0x14(%rdi), %r11d
subl 0x10(%rdi), %r11d
movl %r10d, %ebx
subl %r11d, %ebx
movl %r11d, %r14d
cmoval %r10d, %r14d
subl %r10d, %r11d
cmovbl %ebx, %r11d
cvtsi2sd %r14, %xmm0
mulsd 0x6acac(%rip), %xmm0    # 0x1e35b8
cvttsd2si %xmm0, %r10
cmpl $0x9, %r10d
cmovbl %ecx, %r10d
cmpl %r10d, %r11d
jbe 0x1789d9
movl %r8d, %eax
movq 0x8(%r9,%rax,8), %rax
movl %eax, %r8d
movq %rax, %r9
shrq $0x20, %r9
imulq $0x18, %r8, %rax
imulq $0x18, %r9, %r8
addq %rsi, %r8
addq $0xc, %r8
xorl %r9d, %r9d
cmpq %r9, %rax
je 0x1789d4
movl (%r8,%r9), %esi
testl %esi, %esi
js 0x178965
movl -0x4(%r8,%r9), %r10d
xorl %edx, %r10d
cmpl $0x1, %r10d
je 0x17896b
addq $0x18, %r9
jmp 0x178946
movl 0x8(%rdi), %edx
subl 0x4(%rdi), %edx
movl %esi, %eax
subl %edx, %eax
movl %edx, %r8d
cmoval %esi, %r8d
subl %esi, %edx
cmovbl %eax, %edx
cvtsi2sd %r8, %xmm0
mulsd 0x6ac2a(%rip), %xmm0    # 0x1e35b8
cvttsd2si %xmm0, %r8
cmpl $0x9, %r8d
cmovbl %ecx, %r8d
xorl %eax, %eax
cmpl %r8d, %edx
jbe 0x1789d9
movl 0x14(%rdi), %edx
subl 0x10(%rdi), %edx
movl %esi, %edi
subl %edx, %edi
movl %edx, %r8d
cmoval %esi, %r8d
subl %esi, %edx
cmovbl %edi, %edx
cvtsi2sd %r8, %xmm0
mulsd 0x6abf3(%rip), %xmm0    # 0x1e35b8
cvttsd2si %xmm0, %rsi
cmpl $0x9, %esi
cmovael %esi, %ecx
cmpl %ecx, %edx
jbe 0x1789d9
movl $0x1, %eax
popq %rbx
popq %r14
retq