// File: /workspace/github_cpp_makefile_star2_O1/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), %ecx
shrdl $0x1f, %eax, %ecx
addl %r8d, %r8d
movq 0x18(%rsi), %rax
movq 0x8(%rax), %rdx
movq 0x28(%rax), %rsi
movq (%rsi,%r8,8), %r9
movq %r9, %rax
shlq $0x20, %rax
setne %al
je 0x1b9e90
movq %r9, %r11
shrq $0x20, %r11
movl %r9d, %r10d
leaq (%r11,%r11,2), %r9
leaq (%rdx,%r9,8), %r11
addq $0xc, %r11
movq %r10, %rbx
negq %rbx
movl $0x1, %r14d
movl (%r11), %r9d
testl %r9d, %r9d
js 0x1b9e76
cmpl %ecx, -0x4(%r11)
je 0x1b9e96
cmpq %r10, %r14
setb %al
addq $0x18, %r11
leaq (%rbx,%r14), %r9
incq %r9
incq %r14
cmpq $0x1, %r9
jne 0x1b9e68
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
testb $0x1, %al
je 0x1b9f26
movl 0x8(%rdi), %r11d
subl 0x4(%rdi), %r11d
movl %r9d, %eax
subl %r11d, %eax
movl %r11d, %r10d
cmoval %r9d, %r10d
subl %r9d, %r11d
cmovbl %eax, %r11d
cvtsi2sd %r10, %xmm0
mulsd 0x6b6a1(%rip), %xmm0    # 0x225568
cvttsd2si %xmm0, %rbx
cmpl $0x9, %ebx
movl $0x8, %r10d
cmovbl %r10d, %ebx
xorl %eax, %eax
cmpl %ebx, %r11d
jbe 0x1ba009
movl 0x14(%rdi), %r11d
subl 0x10(%rdi), %r11d
movl %r9d, %ebx
subl %r11d, %ebx
movl %r11d, %r14d
cmoval %r9d, %r14d
subl %r9d, %r11d
cmovbl %ebx, %r11d
xorps %xmm0, %xmm0
cvtsi2sd %r14, %xmm0
mulsd 0x6b658(%rip), %xmm0    # 0x225568
cvttsd2si %xmm0, %r9
cmpl $0x9, %r9d
cmovael %r9d, %r10d
cmpl %r10d, %r11d
jbe 0x1ba009
movl %r8d, %eax
movq 0x8(%rsi,%rax,8), %rsi
movq %rsi, %rax
shlq $0x20, %rax
setne %al
je 0x1b9f89
movq %rsi, %r8
shrq $0x20, %r8
movl %esi, %esi
leaq (%r8,%r8,2), %r8
leaq (%rdx,%r8,8), %r8
addq $0xc, %r8
movq %rsi, %r9
negq %r9
movl $0x1, %r10d
movl (%r8), %edx
testl %edx, %edx
js 0x1b9f6f
movl -0x4(%r8), %r11d
xorl %ecx, %r11d
cmpl $0x1, %r11d
je 0x1b9f8e
cmpq %rsi, %r10
setb %al
addq $0x18, %r8
leaq (%r9,%r10), %rdx
incq %rdx
incq %r10
cmpq $0x1, %rdx
jne 0x1b9f5b
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
testb $0x1, %al
je 0x1ba004
movl 0x8(%rdi), %esi
subl 0x4(%rdi), %esi
movl %edx, %eax
subl %esi, %eax
movl %esi, %ecx
cmoval %edx, %ecx
subl %edx, %esi
cmovbl %eax, %esi
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
mulsd 0x6b5b2(%rip), %xmm0    # 0x225568
cvttsd2si %xmm0, %r8
cmpl $0x9, %r8d
movl $0x8, %ecx
cmovbl %ecx, %r8d
xorl %eax, %eax
cmpl %r8d, %esi
jbe 0x1ba009
movl 0x14(%rdi), %esi
subl 0x10(%rdi), %esi
movl %edx, %edi
subl %esi, %edi
movl %esi, %r8d
cmoval %edx, %r8d
subl %edx, %esi
cmovbl %edi, %esi
xorps %xmm0, %xmm0
cvtsi2sd %r8, %xmm0
mulsd 0x6b573(%rip), %xmm0    # 0x225568
cvttsd2si %xmm0, %rdx
cmpl $0x9, %edx
cmovael %edx, %ecx
cmpl %ecx, %esi
jbe 0x1ba009
movl $0x1, %eax
popq %rbx
popq %r14
retq