// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: trio_check(ma_ug_t*, unsigned int*, unsigned int, unsigned int)
inline int trio_check(ma_ug_t *ug, uint32_t *a, uint32_t a_n, uint32_t flag)
{
    if(flag != FATHER && flag != MOTHER) return 0;
    uint32_t flag_occ = 0, non_flag_occ = 0, ambigious = 0, u_n = 0, f, nf, ab, k;
    for (k = 0; k < a_n; k++) {
        get_unitig_trio_flag(&(ug->u.a[a[k]>>1]), flag, &f, &nf, &ab);
        flag_occ += f;
        non_flag_occ += nf;
        ambigious += ab;
        u_n += ug->u.a[a[k]>>1].n;
    }    
    if((flag_occ+non_flag_occ) == 0) return 0;
    if(flag_occ <= ((non_flag_occ+flag_occ)*0.75)) return 0;
    if(non_flag_occ == 0 && flag_occ >= 20) return 1;
    if(u_n >= 100)
    {
        if(flag_occ < u_n*DOUBLE_CHECK_THRES) return 0;
    }
    else if(u_n >= 50)
    {
        if(flag_occ < u_n*DOUBLE_CHECK_THRES*0.5) return 0;
    }
    else
    {
        if(flag_occ < u_n*DOUBLE_CHECK_THRES*0.25) return 0;
    }
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
cmpl $0x1, -0x20(%rbp)
je 0x167d6e
cmpl $0x2, -0x20(%rbp)
je 0x167d6e
movl $0x0, -0x4(%rbp)
jmp 0x167f35
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jae 0x167e1d
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rax
movl -0x40(%rbp), %ecx
movl (%rax,%rcx,4), %eax
shrl %eax
movl %eax, %eax
imulq $0x28, %rax, %rax
addq %rax, %rdi
movl -0x20(%rbp), %esi
leaq -0x34(%rbp), %rdx
leaq -0x38(%rbp), %rcx
leaq -0x3c(%rbp), %r8
callq 0x118e40
movl -0x34(%rbp), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x38(%rbp), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x3c(%rbp), %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
movl -0x40(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x167d91
movl -0x24(%rbp), %eax
addl -0x28(%rbp), %eax
cmpl $0x0, %eax
jne 0x167e34
movl $0x0, -0x4(%rbp)
jmp 0x167f35
movl -0x24(%rbp), %eax
movl %eax, %ecx
cvtsi2sd %rax, %xmm1
movl -0x28(%rbp), %eax
addl %ecx, %eax
cvtsi2sd %rax, %xmm0
movsd 0x2171d0(%rip), %xmm2   # 0x37f020
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jb 0x167e66
movl $0x0, -0x4(%rbp)
jmp 0x167f35
cmpl $0x0, -0x28(%rbp)
jne 0x167e7e
cmpl $0x14, -0x24(%rbp)
jb 0x167e7e
movl $0x1, -0x4(%rbp)
jmp 0x167f35
cmpl $0x64, -0x30(%rbp)
jb 0x167eb4
movl -0x24(%rbp), %eax
cvtsi2sd %rax, %xmm1
movl -0x30(%rbp), %eax
cvtsi2sd %rax, %xmm0
movsd 0x21717c(%rip), %xmm2   # 0x37f018
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x167eb2
movl $0x0, -0x4(%rbp)
jmp 0x167f35
jmp 0x167f2e
cmpl $0x32, -0x30(%rbp)
jb 0x167ef3
movl -0x24(%rbp), %eax
cvtsi2sd %rax, %xmm1
movl -0x30(%rbp), %eax
cvtsi2sd %rax, %xmm0
movsd 0x217146(%rip), %xmm2   # 0x37f018
mulsd %xmm2, %xmm0
movsd 0x21a392(%rip), %xmm2   # 0x382270
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x167ef1
movl $0x0, -0x4(%rbp)
jmp 0x167f35
jmp 0x167f2c
movl -0x24(%rbp), %eax
cvtsi2sd %rax, %xmm1
movl -0x30(%rbp), %eax
cvtsi2sd %rax, %xmm0
movsd 0x21710d(%rip), %xmm2   # 0x37f018
mulsd %xmm2, %xmm0
movsd 0x21a339(%rip), %xmm2   # 0x382250
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x167f2a
movl $0x0, -0x4(%rbp)
jmp 0x167f35
jmp 0x167f2c
jmp 0x167f2e
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nop