// File: /workspace/github_cpp_makefile_star2_O3/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 0x139df0(%rip), %r15    # 0x296230
movq 0x28(%r15), %rdi
movq 0x50(%r15), %rdx
xorl %r12d, %r12d
xorl %esi, %esi
callq 0x20e0
cmpq $0x0, (%r14)
je 0x15c5a1
xorl %ecx, %ecx
xorl %eax, %eax
movq 0x10(%r14), %r9
leaq (%rcx,%rcx,8), %rsi
leaq (%r9,%rsi,8), %rdx
movl 0x18(%rdx), %edi
testq %rdi, %rdi
je 0x15c485
movl 0x24(%rdx), %ecx
cmpl $0x1, %ecx
je 0x15c485
cmpl $-0x1, %ecx
jne 0x15c593
movl 0x1c(%rdx), %ecx
testq %rcx, %rcx
je 0x15c49e
movl 0x28(%rdx), %edx
cmpl $0x1, %edx
je 0x15c49e
cmpl $-0x1, %edx
jne 0x15c593
testq %rdi, %rdi
movq 0x10(%r9,%rsi,8), %r8
leaq (%r8,%rdi,4), %rdx
cmoveq %rdi, %r8
testq %rcx, %rcx
cmoveq %rcx, %rdx
movl 0x24(%r9,%rsi,8), %r10d
cmpl $0x1, %r10d
je 0x15c4ce
cmpl $-0x1, %r10d
jne 0x15c4d1
movl $0x2, %r12d
jmp 0x15c4d1
movl %r10d, %r12d
testq %rdi, %rdi
je 0x15c529
xorl %r9d, %r9d
movl (%r8,%r9,4), %r11d
movq 0x10(%rbx), %r10
leaq (%r11,%r11,4), %r11
cmpl $0x0, 0xc(%r10,%r11,8)
je 0x15c51d
leaq (%r10,%r11,8), %r10
cmpl $0x0, 0x10(%r10)
je 0x15c51d
xorl %r11d, %r11d
movq 0x28(%r15), %r13
movq 0x18(%r10), %rbp
movq (%rbp,%r11,8), %rbp
shrq $0x21, %rbp
movb %r12b, (%r13,%rbp)
incq %r11
movl 0x10(%r10), %r13d
cmpq %r13, %r11
jb 0x15c4fb
incq %r9
cmpq %rdi, %r9
jne 0x15c4d9
movq 0x10(%r14), %r9
movl 0x28(%r9,%rsi,8), %esi
cmpl $0x1, %esi
je 0x15c540
cmpl $-0x1, %esi
jne 0x15c543
movl $0x2, %r12d
jmp 0x15c543
movl %esi, %r12d
testq %rcx, %rcx
je 0x15c593
xorl %esi, %esi
movl (%rdx,%rsi,4), %r8d
movq 0x10(%rbx), %rdi
leaq (%r8,%r8,4), %r8
cmpl $0x0, 0xc(%rdi,%r8,8)
je 0x15c58b
leaq (%rdi,%r8,8), %rdi
cmpl $0x0, 0x10(%rdi)
je 0x15c58b
xorl %r8d, %r8d
movq 0x28(%r15), %r9
movq 0x18(%rdi), %r10
movq (%r10,%r8,8), %r10
shrq $0x21, %r10
movb %r12b, (%r9,%r10)
incq %r8
movl 0x10(%rdi), %r9d
cmpq %r9, %r8
jb 0x15c56b
incq %rsi
cmpq %rcx, %rsi
jne 0x15c54a
incl %eax
movq %rax, %rcx
cmpq %rax, (%r14)
ja 0x15c460
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq