// File: chhylp123[P]hifiasm/Overlaps.cpp
// Function: cal_trio_vec(buf_t*, ma_ug_t*, float)
uint32_t cal_trio_vec(buf_t* b, ma_ug_t *ug, float thres)
{
    uint32_t i, father_occ = 0, mother_occ = 0, v, k, rId;
    if(ug == NULL)
    {
        for (i = 0; i < b->b.n; ++i)
        {
            if(R_INF.trio_flag[b->b.a[i]>>1]==FATHER)
            {
                father_occ++;
            }
            else if(R_INF.trio_flag[b->b.a[i]>>1]==MOTHER)
            {
                mother_occ++;
            }
        }
    }
    else
    {
        ma_utg_t* u = NULL;
        for (i = 0; i < b->b.n; ++i)
        {
            v = b->b.a[i]>>1;
            u = &(ug->u.a[v]);
            if(u->m == 0) continue;
            for (k = 0; k < u->n; k++)
            {
                rId = u->a[k]>>33;
                if(R_INF.trio_flag[rId]==FATHER)
                {
                    father_occ++;
                }
                else if(R_INF.trio_flag[rId]==MOTHER)
                {
                    mother_occ++;
                }
            }
        }
    }
    
    

    if(father_occ >= thres*(father_occ+mother_occ)) return FATHER;
    if(mother_occ >= thres*(father_occ+mother_occ)) return MOTHER;
    return AMBIGU;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movss %xmm0, -0x1c(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x116792
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jae 0x11678d
leaq 0x2aebab(%rip), %rax    # 0x3c52d0
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x48(%rcx), %rcx
movl -0x20(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
shrl %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x1, %eax
jne 0x11674f
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x116780
leaq 0x2aeb7a(%rip), %rax    # 0x3c52d0
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x48(%rcx), %rcx
movl -0x20(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
shrl %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x2, %eax
jne 0x11677e
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x116780
jmp 0x116782
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x116711
jmp 0x116873
movq $0x0, -0x40(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jae 0x116871
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movl -0x20(%rbp), %ecx
movl (%rax,%rcx,4), %eax
shrl %eax
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jne 0x1167e7
jmp 0x116863
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x40(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x116861
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x30(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
movl %eax, -0x34(%rbp)
leaq 0x2aeab9(%rip), %rax    # 0x3c52d0
movq 0x28(%rax), %rax
movl -0x34(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x1, %eax
jne 0x116832
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x116854
leaq 0x2aea97(%rip), %rax    # 0x3c52d0
movq 0x28(%rax), %rax
movl -0x34(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x2, %eax
jne 0x116852
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x116854
jmp 0x116856
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x1167ee
jmp 0x116863
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1167a1
jmp 0x116873
movl -0x24(%rbp), %eax
movl %eax, %ecx
movl %ecx, %eax
cvtsi2ss %rcx, %xmm0
movss -0x1c(%rbp), %xmm1
movl -0x28(%rbp), %ecx
addl %ecx, %eax
cvtsi2ss %rax, %xmm2
mulss %xmm2, %xmm1
ucomiss %xmm1, %xmm0
jb 0x1168a0
movl $0x1, -0x4(%rbp)
jmp 0x1168d2
movl -0x28(%rbp), %eax
movl %eax, %ecx
cvtsi2ss %rax, %xmm0
movss -0x1c(%rbp), %xmm1
movl -0x24(%rbp), %eax
addl %ecx, %eax
cvtsi2ss %rax, %xmm2
mulss %xmm2, %xmm1
ucomiss %xmm1, %xmm0
jb 0x1168cb
movl $0x2, -0x4(%rbp)
jmp 0x1168d2
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopw (%rax,%rax)