// File: /workspace/github_cpp_makefile_star2_O2/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 %rcx, %r15
movq %rdx, %r12
movq %rsi, 0x20(%rsp)
movq %rdi, 0x18(%rsp)
movq 0xc0(%rsp), %r13
movq 0xb0(%rsp), %rbx
movq 0x98(%rsp), %r14
movq 0x90(%rsp), %rbp
movq %rbx, (%rsp)
movq %rcx, %rdi
movq %r8, %rsi
movq %r9, %rdx
movq %rbp, %rcx
movq %r14, %r8
movq %r13, %r9
callq 0x1d0b6e
testq %rax, %rax
je 0x1d0dd9
movq (%rbx), %rdx
cmpq $0x1, %rdx
jbe 0x1d0ff9
movq 0x10(%rbx), %rsi
movq (%rsi), %rax
cmpb $0x0, (%r13,%rax)
je 0x1d0ff0
movq -0x8(%rsi,%rdx,8), %rax
xorq $0x1, %rax
cmpb $0x0, (%r13,%rax)
je 0x1d0ff0
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rcx
callq 0x1ccf02
cmpq $0x3, %rax
jae 0x1d0de7
movq $0x0, 0x10(%rsp)
jmp 0x1d0fb4
movq %rax, %rsi
movq 0xb8(%rsp), %rdi
movq 0xa8(%rsp), %rax
movq 0xa0(%rsp), %rcx
movq %r14, %rdx
andq $-0x2, %rdx
movq (%rax,%rdx,4), %rax
movl %eax, %edx
movq %rdx, 0x38(%rsp)
shrq $0x20, %rax
movq %rsi, 0x30(%rsp)
movq %rsi, %xmm0
punpckldq 0x12446(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
leaq (%rcx,%rax,8), %rax
movq %rax, 0x28(%rsp)
subpd 0x12445(%rip), %xmm0    # 0x1e3280
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
cmpq %rbx, 0x38(%rsp)
je 0x1d0fac
movq 0x28(%rsp), %rax
movq (%rax,%rbx,8), %rax
movl %eax, %ecx
cmpq %rbp, %rcx
je 0x1d0f74
shrq $0x20, %rax
movq (%r12,%rax,8), %rsi
movl %esi, %edx
shrq $0x20, %rsi
addq %rsi, %rdx
movq %rdi, (%rsp)
movq %r15, %rdi
movq %r14, %r8
movq %r13, %r9
callq 0x1d0b6e
movq 0xb8(%rsp), %rdi
testq %rax, %rax
je 0x1d0f74
movq %r12, %rbp
movq (%rdi), %r12
cmpq $0x1, %r12
jbe 0x1d0fd1
movq %r15, %r14
movq 0x10(%rdi), %r15
movq (%r15), %rax
cmpb $0x0, (%r13,%rax)
je 0x1d0fc8
movq -0x8(%r15,%r12,8), %rax
xorq $0x1, %rax
cmpb $0x0, (%r13,%rax)
je 0x1d0fc8
movq 0xb0(%rsp), %rax
cmpq %r12, (%rax)
jne 0x1d0f11
movq 0x10(%rax), %rdi
leaq (,%r12,8), %rdx
movq %r15, %rsi
callq 0x21a0
testl %eax, %eax
je 0x1d0f7c
movq 0x18(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
movq 0x20(%rsp), %rcx
callq 0x1ccf02
movq %rax, %xmm0
punpckldq 0x1233d(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x12345(%rip), %xmm0    # 0x1e3280
cmpq %rax, 0x30(%rsp)
jbe 0x1d0fb4
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 0x98(%rsp), %r14
movq 0x90(%rsp), %rbp
movq 0xb8(%rsp), %rdi
ja 0x1d0fb4
incq %rbx
jmp 0x1d0e5e
movq 0x28(%rsp), %rax
movl (%rax,%rbx,8), %eax
movq 0x90(%rsp), %rcx
cmpq %rcx, %rax
movq %r14, %r15
movq %rbp, %r12
movq %rcx, %rbp
movq 0x98(%rsp), %r14
movq 0xb8(%rsp), %rdi
ja 0x1d0f74
jmp 0x1d0fb4
pushq $0x1
popq %rax
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 0x2a639(%rip), %rdi     # 0x1fb608
jmp 0x1d0fd8
leaq 0x2a625(%rip), %rdi     # 0x1fb5fd
leaq 0x264fa(%rip), %rsi     # 0x1f74d9
leaq 0x2a544(%rip), %rcx     # 0x1fb52a
movl $0x3781, %edx           # imm = 0x3781
callq 0x2110
leaq 0x2a5e3(%rip), %rdi     # 0x1fb5da
jmp 0x1d1000
leaq 0x2a51f(%rip), %rdi     # 0x1fb51f
leaq 0x264d2(%rip), %rsi     # 0x1f74d9
leaq 0x2a51c(%rip), %rcx     # 0x1fb52a
movl $0x3776, %edx           # imm = 0x3776
callq 0x2110