// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: is_connect_arc(u_trans_t*, u_trans_t*, ma_ug_t*, double)
uint32_t is_connect_arc(u_trans_t *li, u_trans_t *lj, ma_ug_t *ug, double diff_ec_ul)
{
    if(li->qs >= lj->qs && li->qe >= lj->qe) {
        int64_t dq = infer_utrans_ovlp_len(li, lj, ug);
        uint32_t v = (li->tn<<1)|li->rev, w = (lj->tn<<1)|lj->rev;
        int64_t dt = -1, dif, mm; uint32_t nv, i; asg_arc_t *av;
        nv = asg_arc_n(ug->g, v); av = asg_arc_a(ug->g, v);
		for (i = 0; i < nv; i++) {
			if(av[i].del || av[i].v != w) continue;
			dt = av[i].ol;
			break;
		}

        if(dt < 0) return 0;
	    dif = (dq>dt? dq-dt:dt-dq);
	    mm = MAX(dq, dt); mm *= diff_ec_ul; if(mm < 8) mm = 8;
        if(dif <= mm) return 1;
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movsd %xmm0, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
jb 0x102864
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jb 0x102864
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x102250
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
shll %eax
movq -0x10(%rbp), %rcx
movb 0x28(%rcx), %cl
shrb $0x6, %cl
andb $0x1, %cl
movzbl %cl, %ecx
orl %ecx, %eax
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
shll %eax
movq -0x18(%rbp), %rcx
movb 0x28(%rcx), %cl
shrb $0x6, %cl
andb $0x1, %cl
movzbl %cl, %ecx
orl %ecx, %eax
movl %eax, -0x38(%rbp)
movq $-0x1, -0x40(%rbp)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movl -0x34(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x54(%rbp)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rax
movq -0x20(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq 0x28(%rcx), %rcx
movl -0x34(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x54(%rbp), %eax
jae 0x1027c5
movq -0x60(%rbp), %rax
movl -0x58(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x10279a
movq -0x60(%rbp), %rax
movl -0x58(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
cmpl -0x38(%rbp), %eax
je 0x10279c
jmp 0x1027ba
movq -0x60(%rbp), %rax
movl -0x58(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movq %rax, -0x40(%rbp)
jmp 0x1027c5
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x102763
cmpq $0x0, -0x40(%rbp)
jge 0x1027d8
movl $0x0, -0x4(%rbp)
jmp 0x10286b
movq -0x30(%rbp), %rax
cmpq -0x40(%rbp), %rax
jle 0x1027f0
movq -0x30(%rbp), %rax
subq -0x40(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x1027fc
movq -0x40(%rbp), %rax
subq -0x30(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x40(%rbp), %rax
jl 0x102818
movq -0x30(%rbp), %rax
movq %rax, -0x70(%rbp)
jmp 0x102820
movq -0x40(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x50(%rbp)
movsd -0x28(%rbp), %xmm1
cvtsi2sdq -0x50(%rbp), %xmm0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0x50(%rbp)
cmpq $0x8, -0x50(%rbp)
jge 0x10284f
movq $0x8, -0x50(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
jg 0x102862
movl $0x1, -0x4(%rbp)
jmp 0x10286b
jmp 0x102864
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)