// File: 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 %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
shll %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
shll %eax
movq -0x10(%rbp), %rcx
movl 0x18(%rcx), %ecx
shrl $0x1f, %ecx
addl %ecx, %eax
movl %eax, -0x20(%rbp)
movl $0xffffffff, -0x28(%rbp) # imm = 0xFFFFFFFF
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq 0x28(%rcx), %rcx
movl -0x1c(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movl -0x1c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x44(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x44(%rbp), %eax
jae 0x2bbea0
movq -0x40(%rbp), %rax
movl -0x24(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x2bbe78
movq -0x40(%rbp), %rax
movl -0x24(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
cmpl -0x20(%rbp), %eax
je 0x2bbe7a
jmp 0x2bbe95
movq -0x40(%rbp), %rax
movl -0x24(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, -0x28(%rbp)
jmp 0x2bbea0
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2bbe41
movl -0x24(%rbp), %eax
cmpl -0x44(%rbp), %eax
jae 0x2bbfc6
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
subl 0x4(%rcx), %eax
movl %eax, -0x2c(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jbe 0x2bbed0
movl -0x28(%rbp), %eax
subl -0x2c(%rbp), %eax
movl %eax, -0x48(%rbp)
jmp 0x2bbed9
movl -0x2c(%rbp), %eax
subl -0x28(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jb 0x2bbeef
movl -0x28(%rbp), %eax
movl %eax, -0x4c(%rbp)
jmp 0x2bbef5
movl -0x2c(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cvtsi2sd %rax, %xmm0
movsd 0xc63cd(%rip), %xmm1    # 0x3822d8
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, -0x34(%rbp)
cmpl $0x8, -0x34(%rbp)
jae 0x2bbf24
movl $0x8, -0x34(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x34(%rbp), %eax
ja 0x2bbf38
movl $0x0, -0x4(%rbp)
jmp 0x2bc1b3
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
movq -0x10(%rbp), %rcx
subl 0x10(%rcx), %eax
movl %eax, -0x2c(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jbe 0x2bbf5c
movl -0x28(%rbp), %eax
subl -0x2c(%rbp), %eax
movl %eax, -0x50(%rbp)
jmp 0x2bbf65
movl -0x2c(%rbp), %eax
subl -0x28(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jb 0x2bbf7b
movl -0x28(%rbp), %eax
movl %eax, -0x54(%rbp)
jmp 0x2bbf81
movl -0x2c(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cvtsi2sd %rax, %xmm0
movsd 0xc6341(%rip), %xmm1    # 0x3822d8
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, -0x34(%rbp)
cmpl $0x8, -0x34(%rbp)
jae 0x2bbfb0
movl $0x8, -0x34(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x34(%rbp), %eax
ja 0x2bbfc4
movl $0x0, -0x4(%rbp)
jmp 0x2bc1b3
jmp 0x2bbfc6
movl -0x1c(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x20(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0x20(%rbp)
movl $0xffffffff, -0x28(%rbp) # imm = 0xFFFFFFFF
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq 0x28(%rcx), %rcx
movl -0x1c(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movl -0x1c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x44(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x44(%rbp), %eax
jae 0x2bc089
movq -0x40(%rbp), %rax
movl -0x24(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x2bc061
movq -0x40(%rbp), %rax
movl -0x24(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
cmpl -0x20(%rbp), %eax
je 0x2bc063
jmp 0x2bc07e
movq -0x40(%rbp), %rax
movl -0x24(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, -0x28(%rbp)
jmp 0x2bc089
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2bc02a
movl -0x24(%rbp), %eax
cmpl -0x44(%rbp), %eax
jae 0x2bc1ac
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
subl 0x4(%rcx), %eax
movl %eax, -0x2c(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jbe 0x2bc0b9
movl -0x28(%rbp), %eax
subl -0x2c(%rbp), %eax
movl %eax, -0x58(%rbp)
jmp 0x2bc0c2
movl -0x2c(%rbp), %eax
subl -0x28(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jb 0x2bc0d8
movl -0x28(%rbp), %eax
movl %eax, -0x5c(%rbp)
jmp 0x2bc0de
movl -0x2c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cvtsi2sd %rax, %xmm0
movsd 0xc61e4(%rip), %xmm1    # 0x3822d8
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, -0x34(%rbp)
cmpl $0x8, -0x34(%rbp)
jae 0x2bc10d
movl $0x8, -0x34(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x34(%rbp), %eax
ja 0x2bc121
movl $0x0, -0x4(%rbp)
jmp 0x2bc1b3
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
movq -0x10(%rbp), %rcx
subl 0x10(%rcx), %eax
movl %eax, -0x2c(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jbe 0x2bc145
movl -0x28(%rbp), %eax
subl -0x2c(%rbp), %eax
movl %eax, -0x60(%rbp)
jmp 0x2bc14e
movl -0x2c(%rbp), %eax
subl -0x28(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jb 0x2bc164
movl -0x28(%rbp), %eax
movl %eax, -0x64(%rbp)
jmp 0x2bc16a
movl -0x2c(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cvtsi2sd %rax, %xmm0
movsd 0xc6158(%rip), %xmm1    # 0x3822d8
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, -0x34(%rbp)
cmpl $0x8, -0x34(%rbp)
jae 0x2bc199
movl $0x8, -0x34(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x34(%rbp), %eax
ja 0x2bc1aa
movl $0x0, -0x4(%rbp)
jmp 0x2bc1b3
jmp 0x2bc1ac
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax,%rax)