// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Overlaps.cpp
// Function: get_tip_trio_infor(asg_t*, unsigned int)
uint8_t get_tip_trio_infor(asg_t *sg, uint32_t begNode)
{
    uint32_t v = begNode, w;
    uint32_t kv;
    uint32_t eLen = 0, uLen = 0;
    uint32_t father_occ = 0, mother_occ = 0, ambigious_occ = 0;

    while (1)
    {
        kv = get_real_length(sg, v, NULL);
        eLen++;

        if(R_INF.trio_flag[v>>1]==FATHER)
        {
            father_occ++;
        }
        else if(R_INF.trio_flag[v>>1]==MOTHER)
        {
            mother_occ++;
        }
        else if((R_INF.trio_flag[v>>1]==AMBIGU) || (R_INF.trio_flag[v>>1]==DROP))
        {
            ambigious_occ++;
        }
        
        if(kv!=1) break;
        ///kv must be 1 here
        kv = get_real_length(sg, v, &w);
        if(get_real_length(sg, w^1, NULL)!=1) break;
        v = w;
        if(v == begNode) break;
    }

    uLen = eLen;
    eLen = father_occ + mother_occ;
    if(eLen == 0) return AMBIGU;
    if(father_occ >= mother_occ)
    {
        if((father_occ > TRIO_THRES*eLen) && (father_occ >= DOUBLE_CHECK_THRES*uLen)) return FATHER;
    }
    else
    {
        if((mother_occ > TRIO_THRES*eLen) && (mother_occ >= DOUBLE_CHECK_THRES*uLen)) return MOTHER;
    }
    return AMBIGU;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq 0x28(%rdi), %r8
leaq 0x1e99a1(%rip), %rax    # 0x296230
movq 0x28(%rax), %r9
xorl %eax, %eax
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
movl %esi, %r11d
movl $0x0, -0x4(%rsp)
xorl %edx, %edx
movl %r11d, %ebx
movq (%r8,%rbx,8), %rbx
xorl %r15d, %r15d
movq %rbx, %r14
andq %r10, %r14
je 0xac8fe
movq 0x8(%rdi), %r12
movq %rbx, %r13
shrq $0x20, %r13
leaq (%r13,%r13,2), %r13
leaq (%r12,%r13,8), %r12
addq $0xc, %r12
leaq (,%r14,8), %r13
leaq (%r13,%r13,2), %r13
xorl %ebp, %ebp
movl (%r12,%rbp), %ecx
notl %ecx
shrl $0x1f, %ecx
addl %ecx, %r15d
addq $0x18, %rbp
cmpq %rbp, %r13
jne 0xac8e1
cmpl $0x1, %r15d
sete %r15b
movl %r11d, %ecx
shrl %ecx
movzbl (%r9,%rcx), %ebp
cmpl $0x2, %ebp
je 0xac918
cmpl $0x1, %ebp
jne 0xac91a
incl -0x4(%rsp)
jmp 0xac91a
incl %edx
incl %eax
testb %r15b, %r15b
je 0xac9b3
testq %r14, %r14
je 0xac95e
movq 0x8(%rdi), %rcx
shrq $0x20, %rbx
shlq $0x3, %r14
leaq (%r14,%r14,2), %r14
leaq (%rbx,%rbx,2), %rbx
leaq (%rcx,%rbx,8), %rbx
addq $0xc, %rbx
xorl %r15d, %r15d
cmpl $0x0, (%rbx,%r15)
js 0xac955
movl -0x4(%rbx,%r15), %r11d
addq $0x18, %r15
cmpq %r15, %r14
jne 0xac949
movl %r11d, %ecx
xorl $0x1, %ecx
movq (%r8,%rcx,8), %rbx
movq %rbx, %r14
andq %r10, %r14
je 0xac9b3
movq 0x8(%rdi), %rcx
shrq $0x20, %rbx
leaq (%rbx,%rbx,2), %rbx
leaq (%rcx,%rbx,8), %rbx
addq $0xc, %rbx
shlq $0x3, %r14
leaq (%r14,%r14,2), %r14
xorl %r15d, %r15d
xorl %ebp, %ebp
movl (%rbx,%r15), %ecx
notl %ecx
shrl $0x1f, %ecx
addl %ecx, %ebp
addq $0x18, %r15
cmpq %r15, %r14
jne 0xac991
cmpl %esi, %r11d
je 0xac9b3
cmpl $0x1, %ebp
je 0xac8a8
movl %edx, %esi
movl -0x4(%rsp), %edi
addl %edi, %esi
je 0xaca1a
movl %esi, %ecx
cvtsi2sd %rcx, %xmm0
mulsd 0x184c2c(%rip), %xmm0   # 0x2315f8
cmpl %edx, %edi
jae 0xac9f3
movl %edx, %ecx
cvtsi2sd %rcx, %xmm1
ucomisd %xmm0, %xmm1
jbe 0xaca1a
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x184221(%rip), %xmm0   # 0x230c10
movb $0x2, %al
jmp 0xaca14
movl %edi, %ecx
cvtsi2sd %rcx, %xmm1
ucomisd %xmm0, %xmm1
jbe 0xaca1a
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x1841fe(%rip), %xmm0   # 0x230c10
movb $0x1, %al
ucomisd %xmm0, %xmm1
jae 0xaca1c
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq