// File: 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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x18(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
movl %eax, -0x20(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
leaq 0x2e6975(%rip), %rax    # 0x3c52d0
movq 0x28(%rax), %rax
movl -0x18(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x1, %eax
jne 0xde97a
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xde9e3
leaq 0x2e694f(%rip), %rax    # 0x3c52d0
movq 0x28(%rax), %rax
movl -0x18(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x2, %eax
jne 0xde9a0
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xde9e1
leaq 0x2e6929(%rip), %rax    # 0x3c52d0
movq 0x28(%rax), %rax
movl -0x18(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0xde9d6
leaq 0x2e690e(%rip), %rax    # 0x3c52d0
movq 0x28(%rax), %rax
movl -0x18(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x5, %eax
jne 0xde9df
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xde9e1
jmp 0xde9e3
cmpl $0x1, -0x20(%rbp)
je 0xde9eb
jmp 0xdea2d
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %esi
leaq -0x1c(%rbp), %rdx
callq 0x166b50
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %esi
xorl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
cmpl $0x1, %eax
je 0xdea18
jmp 0xdea2d
movl -0x1c(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jne 0xdea28
jmp 0xdea2d
jmp 0xde938
movl -0x24(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x2c(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0xdea4b
movb $0x0, -0x1(%rbp)
jmp 0xdeaef
movl -0x2c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jb 0xdea9f
movl -0x2c(%rbp), %eax
cvtsi2sd %rax, %xmm0
movl -0x24(%rbp), %eax
cvtsi2sd %rax, %xmm2
movsd 0x2a37fd(%rip), %xmm1   # 0x382268
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xdea9d
movl -0x2c(%rbp), %eax
cvtsi2sd %rax, %xmm0
movl -0x28(%rbp), %eax
cvtsi2sd %rax, %xmm2
movsd 0x2a058b(%rip), %xmm1   # 0x37f018
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jb 0xdea9d
movb $0x1, -0x1(%rbp)
jmp 0xdeaef
jmp 0xdeaeb
movl -0x30(%rbp), %eax
cvtsi2sd %rax, %xmm0
movl -0x24(%rbp), %eax
cvtsi2sd %rax, %xmm2
movsd 0x2a37b1(%rip), %xmm1   # 0x382268
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xdeae9
movl -0x30(%rbp), %eax
cvtsi2sd %rax, %xmm0
movl -0x28(%rbp), %eax
cvtsi2sd %rax, %xmm2
movsd 0x2a053f(%rip), %xmm1   # 0x37f018
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jb 0xdeae9
movb $0x2, -0x1(%rbp)
jmp 0xdeaef
jmp 0xdeaeb
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)