// File: /workspace/github_cpp_makefile_star2_O3/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, %r14
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r15
movq 0xc0(%rsp), %r13
movq 0xb0(%rsp), %rbp
movq 0x98(%rsp), %r8
movq 0x90(%rsp), %rcx
movq %rbp, (%rsp)
movq %r14, %rdi
movq %rax, %rsi
movq %r9, %rdx
movq %r13, %r9
callq 0x21fa43
testq %rax, %rax
je 0x21fcb5
movq (%rbp), %rdx
cmpq $0x1, %rdx
jbe 0x21feec
movq 0x10(%rbp), %rsi
movq (%rsi), %rax
cmpb $0x0, (%r13,%rax)
je 0x21fee3
movq -0x8(%rsi,%rdx,8), %rax
xorq $0x1, %rax
cmpb $0x0, (%r13,%rax)
je 0x21fee3
movq %r15, %rdi
movq %rbx, %rcx
callq 0x21badd
movq %rax, 0x20(%rsp)
cmpq $0x3, %rax
jae 0x21fcc3
movq $0x0, 0x10(%rsp)
jmp 0x21fea7
movq %r15, 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 0x21fe9d
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 0x11563(%rip), %xmm0    # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1156b(%rip), %xmm0    # 0x231290
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), %r15
movq %rbp, 0x18(%rsp)
movq 0x28(%rsp), %rax
movq (%rax,%rbx,8), %rax
movl %eax, %ecx
cmpq %r15, %rcx
je 0x21fe62
shrq $0x20, %rax
movq (%r12,%rax,8), %rsi
movl %esi, %edx
shrq $0x20, %rsi
addq %rsi, %rdx
movq %rdi, (%rsp)
movq %r14, %rdi
movq 0x98(%rsp), %r8
movq %r13, %r9
callq 0x21fa43
movq 0xb8(%rsp), %rdi
testq %rax, %rax
je 0x21fe62
movq %r12, %rbp
movq (%rdi), %r12
cmpq $0x1, %r12
jbe 0x21fec4
movq %r14, %r15
movq 0x10(%rdi), %r14
movq (%r14), %rax
cmpb $0x0, (%r13,%rax)
je 0x21febb
movq -0x8(%r14,%r12,8), %rax
xorq $0x1, %rax
cmpb $0x0, (%r13,%rax)
je 0x21febb
movq 0xb0(%rsp), %rax
cmpq %r12, (%rax)
jne 0x21fe02
movq 0x10(%rax), %rdi
leaq (,%r12,8), %rdx
movq %r14, %rsi
callq 0x21a0
testl %eax, %eax
je 0x21fe70
movq 0x38(%rsp), %rdi
movq %r14, %rsi
movq %r12, %rdx
movq 0x30(%rsp), %rcx
callq 0x21badd
movq %rax, %xmm0
punpckldq 0x1145c(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x11464(%rip), %xmm0    # 0x231290
cmpq %rax, 0x20(%rsp)
jbe 0x21fea7
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
ucomisd 0x40(%rsp), %xmm1
movq %r15, %r14
movq %rbp, %r12
movq 0x90(%rsp), %r15
movq 0x18(%rsp), %rbp
movq 0xb8(%rsp), %rdi
ja 0x21fea7
incq %rbx
cmpq %rbx, %rbp
jne 0x21fd55
jmp 0x21fe9d
movq 0x28(%rsp), %rax
movl (%rax,%rbx,8), %eax
movq 0x90(%rsp), %rcx
cmpq %rcx, %rax
movq %r15, %r14
movq %rcx, %r15
movq %rbp, %r12
movq 0x18(%rsp), %rbp
movq 0xb8(%rsp), %rdi
ja 0x21fe62
jmp 0x21fea7
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 0x29787(%rip), %rdi     # 0x249649
jmp 0x21fecb
leaq 0x29773(%rip), %rdi     # 0x24963e
leaq 0x25737(%rip), %rsi     # 0x245609
leaq 0x29692(%rip), %rcx     # 0x24956b
movl $0x3781, %edx           # imm = 0x3781
callq 0x2110
leaq 0x29731(%rip), %rdi     # 0x24961b
jmp 0x21fef3
leaq 0x2966d(%rip), %rdi     # 0x249560
leaq 0x2570f(%rip), %rsi     # 0x245609
leaq 0x2966a(%rip), %rcx     # 0x24956b
movl $0x3776, %edx           # imm = 0x3776
callq 0x2110