// File: chhylp123[P]hifiasm/Purge_Dups.cpp
// Function: get_contig_length(ma_ug_t*, asg_t*, unsigned long*, unsigned long*)
void get_contig_length(ma_ug_t *ug, asg_t *g, uint64_t* primaryLen, uint64_t* alterLen)
{
    uint8_t *del = (uint8_t *)malloc(sizeof(uint8_t)*g->n_seq);
    uint32_t v, k;
    ma_utg_t* u = NULL;
    memset(del, 1, g->n_seq);
    (*primaryLen) = (*alterLen) = 0;

    for (v = 0; v < ug->g->n_seq; ++v) 
    {
        if(ug->g->seq[v].del) continue;
        if(ug->g->seq[v].c == ALTER_LABLE) continue;
        u = &(ug->u.a[v]);
        if(u->m == 0) continue;
        for (k = 0; k < u->n; k++)
        {
            del[u->a[k]>>33] = 0;
        }
    }
    (*primaryLen) = get_specific_contig_length(g, del);


    for (v = 0; v < g->n_seq; ++v) 
    {
        del[v] = 1 - del[v];
    }

    (*alterLen) = get_specific_contig_length(g, del);

    free(del);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %edi
shlq $0x0, %rdi
callq 0x2270
movq %rax, -0x28(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %edx
movl $0x1, %esi
callq 0x2100
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl 0x14(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl %ecx, %eax
jae 0x181266
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movl -0x2c(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x1811e0
jmp 0x181258
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movl -0x2c(%rbp), %ecx
movzbl 0x4(%rax,%rcx,8), %eax
cmpl $0x1, %eax
jne 0x1811fb
jmp 0x181258
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jne 0x18121d
jmp 0x181258
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x181256
movq -0x28(%rbp), %rax
movq -0x38(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl -0x30(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x21, %rcx
movb $0x0, (%rax,%rcx)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x181224
jmp 0x181258
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1811a8
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x180e10
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
movl 0x14(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl %ecx, %eax
jae 0x1812c1
movq -0x28(%rbp), %rax
movl -0x2c(%rbp), %ecx
movzbl (%rax,%rcx), %ecx
movl $0x1, %eax
subl %ecx, %eax
movb %al, %dl
movq -0x28(%rbp), %rax
movl -0x2c(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x181284
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x180e10
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rdi
callq 0x2210
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)