// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/hic.cpp
// Function: label_unitigs(G_partition*, ma_ug_t*)
void label_unitigs(G_partition* g_p, ma_ug_t* ug)
{
    memset(R_INF.trio_flag, AMBIGU, R_INF.total_reads * sizeof(uint8_t));
    uint32_t i, k, j, *h0, h0_n, *h1, h1_n, uID, *h = NULL, h_n, flag = AMBIGU;
    int status;
    ma_utg_t *u = NULL;

    for (i = 0; i < g_p->n; i++)
    {
        if(g_p->a[i].h[0] > 0 && g_p->a[i].status[0] != 1 && g_p->a[i].status[0] != -1) continue;
        if(g_p->a[i].h[1] > 0 && g_p->a[i].status[1] != 1 && g_p->a[i].status[1] != -1) continue;
        get_phased_block(g_p, NULL, i, NULL, NULL, &h0, &h0_n, &h1, &h1_n, NULL, NULL);

        status = g_p->a[i].status[0];
        h = h0; h_n = h0_n;
        if(status == 1)
        {
            flag = FATHER;
        }
        else if (status == -1)
        {
            flag = MOTHER;
        }
        for (j = 0; j < h_n; j++)
        {
            uID = h[j];
            u = &ug->u.a[uID];
            if(u->m == 0) continue;
            for (k = 0; k < u->n; k++)
            {
                R_INF.trio_flag[u->a[k]>>33] = flag;
            }
        }



        status = g_p->a[i].status[1];
        h = h1; h_n = h1_n;
        if(status == 1)
        {
            flag = FATHER;
        }
        else if (status == -1)
        {
            flag = MOTHER;
        }
        for (j = 0; j < h_n; j++)
        {
            uID = h[j];
            u = &ug->u.a[uID];
            if(u->m == 0) continue;
            for (k = 0; k < u->n; k++)
            {
                R_INF.trio_flag[u->a[k]>>33] = flag;
            }
        }
    }


    uint64_t occ = 0; 
    for (i = 0; i < ug->u.n; i++)
    {
        occ += ug->u.a[i].n;
    }

    ///fprintf(stderr, "# reads: %lu\n", occ);

    for (i = occ = 0; i < R_INF.total_reads; i++)
    {
        if(R_INF.trio_flag[i] == FATHER) occ++;
    }

    ///fprintf(stderr, "# Father reads: %lu\n", occ);

    for (i = occ = 0; i < R_INF.total_reads; i++)
    {
        if(R_INF.trio_flag[i] == MOTHER) occ++;
    }
    
    ///fprintf(stderr, "# Mother reads: %lu\n", occ);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x13e1f7(%rip), %r15    # 0x254230
movq 0x28(%r15), %rdi
movq 0x50(%r15), %rdx
xorl %r12d, %r12d
xorl %esi, %esi
callq 0x20e0
xorl %ecx, %ecx
movl %r12d, %r12d
cmpq %r12, (%r14)
jbe 0x11617a
movq 0x10(%r14), %r10
imulq $0x48, %r12, %rdi
leaq (%r10,%rdi), %rsi
movl 0x18(%r10,%rdi), %r8d
testq %r8, %r8
je 0x116080
movl 0x24(%rsi), %edx
cmpl $0x1, %edx
je 0x116080
cmpl $-0x1, %edx
jne 0x116172
movl 0x1c(%rsi), %edx
testq %rdx, %rdx
je 0x116099
movl 0x28(%rsi), %esi
cmpl $0x1, %esi
je 0x116099
cmpl $-0x1, %esi
jne 0x116172
testq %r8, %r8
movq 0x10(%r10,%rdi), %r9
leaq (%r9,%r8,4), %rsi
cmoveq %r8, %r9
testq %rdx, %rdx
cmoveq %rdx, %rsi
movl 0x24(%r10,%rdi), %r10d
cmpl $0x1, %r10d
je 0x1160c6
cmpl $-0x1, %r10d
jne 0x1160c9
pushq $0x2
popq %rcx
jmp 0x1160c9
movl %r10d, %ecx
xorl %r10d, %r10d
cmpq %r8, %r10
je 0x116112
movl (%r9,%r10,4), %r13d
movq 0x10(%rbx), %r11
imulq $0x28, %r13, %r13
cmpl $0x0, 0xc(%r11,%r13)
je 0x11610d
addq %r13, %r11
xorl %r13d, %r13d
movl 0x10(%r11), %ebp
cmpq %rbp, %r13
jae 0x11610d
movq 0x28(%r15), %rbp
movq 0x18(%r11), %rax
movq (%rax,%r13,8), %rax
shrq $0x21, %rax
movb %cl, (%rbp,%rax)
incq %r13
jmp 0x1160eb
incq %r10
jmp 0x1160cc
movq 0x10(%r14), %rax
movl 0x28(%rax,%rdi), %edi
cmpl $0x1, %edi
je 0x116129
cmpl $-0x1, %edi
jne 0x11612b
pushq $0x2
popq %rcx
jmp 0x11612b
movl %edi, %ecx
xorl %edi, %edi
cmpq %rdx, %rdi
je 0x116172
movl (%rsi,%rdi,4), %eax
movq 0x10(%rbx), %r8
imulq $0x28, %rax, %r9
cmpl $0x0, 0xc(%r8,%r9)
je 0x11616d
addq %r9, %r8
xorl %r9d, %r9d
movl 0x10(%r8), %eax
cmpq %rax, %r9
jae 0x11616d
movq 0x28(%r15), %rax
movq 0x18(%r8), %r10
movq (%r10,%r9,8), %r10
shrq $0x21, %r10
movb %cl, (%rax,%r10)
incq %r9
jmp 0x11614b
incq %rdi
jmp 0x11612d
incl %r12d
jmp 0x11604d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq