// File: /workspace/github_cpp_makefile_star2_O1/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 0x1dfa06(%rip), %rax    # 0x28b230
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 0xab899
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 0xab87c
cmpl $0x1, %r15d
sete %r15b
movl %r11d, %ecx
shrl %ecx
movzbl (%r9,%rcx), %ebp
cmpl $0x2, %ebp
je 0xab8b3
cmpl $0x1, %ebp
jne 0xab8b5
incl -0x4(%rsp)
jmp 0xab8b5
incl %edx
incl %eax
testb %r15b, %r15b
je 0xab957
testq %r14, %r14
je 0xab8f9
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 0xab8f0
movl -0x4(%rbx,%r15), %r11d
addq $0x18, %r15
cmpq %r15, %r14
jne 0xab8e4
movl %r11d, %ecx
xorl $0x1, %ecx
movq (%r8,%rcx,8), %rbx
movq %rbx, %r14
andq %r10, %r14
je 0xab948
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 0xab92c
cmpl $0x1, %ebp
setne %bl
jmp 0xab94a
movb $0x1, %bl
cmpl %esi, %r11d
je 0xab957
testb %bl, %bl
je 0xab843
movl %edx, %esi
movl -0x4(%rsp), %edi
addl %edi, %esi
je 0xab9be
movl %esi, %ecx
cvtsi2sd %rcx, %xmm0
mulsd 0x179b88(%rip), %xmm0   # 0x2254f8
cmpl %edx, %edi
jae 0xab997
movl %edx, %ecx
cvtsi2sd %rcx, %xmm1
ucomisd %xmm0, %xmm1
jbe 0xab9be
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x17923d(%rip), %xmm0   # 0x224bd0
movb $0x2, %al
jmp 0xab9b8
movl %edi, %ecx
cvtsi2sd %rcx, %xmm1
ucomisd %xmm0, %xmm1
jbe 0xab9be
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x17921a(%rip), %xmm0   # 0x224bd0
movb $0x1, %al
ucomisd %xmm0, %xmm1
jae 0xab9c0
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq