// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: is_best_pair(ul_resolve_t*, usg_t*, unsigned long*, unsigned long*, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long*, unsigned long*, asg64_v*, asg64_v*, unsigned char*, double)
uint64_t is_best_pair(ul_resolve_t *uidx, usg_t *ng, uint64_t *int_idx, uint64_t *int_a, 
uint64_t s, uint64_t e, uint64_t it, uint64_t v, uint64_t *ridx_a, uint64_t *ridx, 
asg64_v *b0, asg64_v *b1, uint8_t *f, double cutoff)
{
    uint64_t *arc_a, arc_n, k, is, ie, w0 = 0, w1 = 0, sup_cut = 3; 
    if(!gen_sub_integer_path_ff(int_a, s, e, it, v, f, b0)) return 0;
    assert(b0->n >= 2); assert(f[b0->a[0]] && f[b0->a[b0->n-1]^1]);
    w0 = get_arc_support_chain(uidx, b0->a, b0->n, ng);
    if(w0 < sup_cut) return 0;

    arc_a = ridx_a + (ridx[v>>1]>>32); 
    arc_n = (uint32_t)ridx[v>>1];
    for (k = 0; k < arc_n; k++) {
        if(it == ((uint32_t)arc_a[k])) continue;
        is = int_idx[arc_a[k]>>32]>>32; 
        ie = is + ((uint32_t)(int_idx[arc_a[k]>>32])); 
        if(!gen_sub_integer_path_ff(int_a, is, ie, ((uint32_t)arc_a[k]), v, f, b1)) continue;
        assert(b1->n >= 2); assert(f[b1->a[0]] && f[b1->a[b1->n-1]^1]);
        if((b0->n == b1->n) && (memcmp(b0->a, b1->a, sizeof((*(b0->a)))*b0->n) == 0)) {
            if(it < ((uint32_t)arc_a[k])) continue;
            else return 0;///only keep 1 equal interval
        }
        w1 = get_arc_support_chain(uidx, b1->a, b1->n, ng);
        // fprintf(stderr, "[M::%s::] w0::%lu, w1::%lu\n", __func__, w0, w1);
        if((w0 <= w1) || (w1 > (w0*cutoff))) return 0;
    }
    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movsd %xmm0, 0x10(%rsp)
movq %r8, %rax
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r14
movq 0xc0(%rsp), %r13
movq 0xb0(%rsp), %rbp
movq 0x98(%rsp), %r8
movq 0x90(%rsp), %rcx
movq %rbp, (%rsp)
movq %r15, %rdi
movq %rax, %rsi
movq %r9, %rdx
movq %r13, %r9
callq 0x2145fd
testq %rax, %rax
je 0x21486f
movq (%rbp), %rdx
cmpq $0x1, %rdx
jbe 0x214aa5
movq 0x10(%rbp), %rsi
movq (%rsi), %rax
cmpb $0x0, (%r13,%rax)
je 0x214a9c
movq -0x8(%rsi,%rdx,8), %rax
xorq $0x1, %rax
cmpb $0x0, (%r13,%rax)
je 0x214a9c
movq %r14, %rdi
movq %rbx, %rcx
callq 0x2106cf
movq %rax, 0x20(%rsp)
cmpq $0x3, %rax
jae 0x21487d
movq $0x0, 0x10(%rsp)
jmp 0x214a60
movq %r14, 0x38(%rsp)
movq 0xa8(%rsp), %rax
movq 0x98(%rsp), %rcx
andq $-0x2, %rcx
movq (%rax,%rcx,4), %rax
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
andq %rax, %rbp
je 0x214a56
movq %rbx, 0x30(%rsp)
movq 0xb8(%rsp), %rdi
movq 0xa0(%rsp), %rcx
shrq $0x20, %rax
leaq (%rcx,%rax,8), %rax
movq %rax, 0x28(%rsp)
movsd 0x20(%rsp), %xmm0
unpcklps 0x10969(%rip), %xmm0    # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x10971(%rip), %xmm0    # 0x225250
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x10(%rsp), %xmm1
movapd %xmm1, 0x40(%rsp)
movq $0x0, 0x10(%rsp)
xorl %ebx, %ebx
movq 0x90(%rsp), %r14
movq %rbp, 0x18(%rsp)
movq 0x28(%rsp), %rax
movq (%rax,%rbx,8), %rax
movl %eax, %ecx
cmpq %r14, %rcx
je 0x214a1b
shrq $0x20, %rax
movq (%r12,%rax,8), %rsi
movl %esi, %edx
shrq $0x20, %rsi
addq %rsi, %rdx
movq %rdi, (%rsp)
movq %r15, %rdi
movq 0x98(%rsp), %r8
movq %r13, %r9
callq 0x2145fd
movq 0xb8(%rsp), %rdi
testq %rax, %rax
je 0x214a1b
movq %r12, %rbp
movq (%rdi), %r12
cmpq $0x1, %r12
jbe 0x214a7d
movq %r15, %r14
movq 0x10(%rdi), %r15
movq (%r15), %rax
cmpb $0x0, (%r13,%rax)
je 0x214a74
movq -0x8(%r15,%r12,8), %rax
xorq $0x1, %rax
cmpb $0x0, (%r13,%rax)
je 0x214a74
movq 0xb0(%rsp), %rax
movq (%rax), %rdx
cmpq %r12, %rdx
jne 0x2149bb
movq 0x10(%rax), %rdi
shlq $0x3, %rdx
movq %r15, %rsi
callq 0x21a0
testl %eax, %eax
je 0x214a29
movq 0x38(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
movq 0x30(%rsp), %rcx
callq 0x2106cf
movq %rax, %xmm0
punpckldq 0x10863(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1086b(%rip), %xmm0    # 0x225250
cmpq %rax, 0x20(%rsp)
jbe 0x214a60
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
ucomisd 0x40(%rsp), %xmm1
movq %r14, %r15
movq %rbp, %r12
movq 0x90(%rsp), %r14
movq 0x18(%rsp), %rbp
movq 0xb8(%rsp), %rdi
ja 0x214a60
incq %rbx
cmpq %rbx, %rbp
jne 0x21490f
jmp 0x214a56
movq 0x28(%rsp), %rax
movl (%rax,%rbx,8), %eax
movq 0x90(%rsp), %rcx
cmpq %rcx, %rax
movq %r14, %r15
movq %rcx, %r14
movq %rbp, %r12
movq 0x18(%rsp), %rbp
movq 0xb8(%rsp), %rdi
ja 0x214a1b
jmp 0x214a60
movl $0x1, %eax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x288ea(%rip), %rdi     # 0x23d365
jmp 0x214a84
leaq 0x288d6(%rip), %rdi     # 0x23d35a
leaq 0x2489a(%rip), %rsi     # 0x239325
leaq 0x287f5(%rip), %rcx     # 0x23d287
movl $0x3781, %edx           # imm = 0x3781
callq 0x2110
leaq 0x28894(%rip), %rdi     # 0x23d337
jmp 0x214aac
leaq 0x287d0(%rip), %rdi     # 0x23d27c
leaq 0x24872(%rip), %rsi     # 0x239325
leaq 0x287cd(%rip), %rcx     # 0x23d287
movl $0x3776, %edx           # imm = 0x3776
callq 0x2110