// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: update_ug_clean_t(ug_clean_t*)
void update_ug_clean_t(ug_clean_t *sl)
{
    uint32_t v, k, i, n_vtx = sl->ug->g->n_seq<<1;
    sl->tlen = get_bub_pop_max_dist_advance(sl->ug->g, &(sl->b));
    for (k = 0; k < sl->ug->g->n_seq; ++k) {
        sl->idx[k<<1] = sl->idx[(k<<1)+1] = sl->bid[k<<1] = sl->bid[(k<<1)+1] = (uint32_t)-1;
        if(sl->ug->g->seq[k].del) continue;
        sl->ug->g->seq[k].c = PRIMARY_LABLE;
    }

    for (v = 0; v < n_vtx; ++v) {
        if(sl->ug->g->seq[v>>1].del) continue;
        if(asg_arc_n(sl->ug->g, v) < 2) continue;
        if(sl->bid[v] != ((uint32_t)-1)) continue;
        if(asg_bub_pop1_primary_trio(sl->ug->g, NULL, v, sl->tlen, &(sl->b), (uint32_t)-1, (uint32_t)-1, 0, NULL, NULL, NULL, 0, 0, NULL)) {
            //beg is v, end is b.S.a[0]
            //note b.b include end, does not include beg
            for (i = 0; i < sl->b.b.n; i++) {
                if(sl->b.b.a[i]==v || sl->b.b.a[i]==sl->b.S.a[0]) continue;
                sl->bid[sl->b.b.a[i]] = sl->bid[sl->b.b.a[i]^1] = 1;
            }
            sl->bid[v] = 2; sl->bid[sl->b.S.a[0]^1] = 3;
        }
    }

    for (v = 0; v < n_vtx; ++v) {
        if(sl->bid[v] !=2) continue;
        if(asg_bub_pop1_primary_trio(sl->ug->g, NULL, v, sl->tlen, &(sl->b), (uint32_t)-1, (uint32_t)-1, 0, NULL, NULL, NULL, 0, 0, NULL)) {
            //note b.b include end, does not include beg
            for (i = 0; i < sl->b.b.n; i++) {
                if(sl->b.b.a[i]==v || sl->b.b.a[i]==sl->b.S.a[0]) continue;
                sl->idx[sl->b.b.a[i]] = v;
                sl->idx[sl->b.b.a[i]^1] = sl->b.S.a[0]^1;
            }
            sl->idx[v] = v; sl->idx[sl->b.S.a[0]^1] = sl->b.S.a[0]^1;
        }
    }
    memcpy(sl->bid, sl->idx, sizeof((*(sl->bid)))*n_vtx);
    // memset(sl->idx, -1, sizeof((*(sl->idx)))*n_vtx);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movq 0x10(%rdi), %rax
movq 0x18(%rax), %rdi
movl 0x14(%rdi), %ebp
addl %ebp, %ebp
leaq 0x18(%rbx), %r14
movq %r14, %rsi
callq 0xbf22d
movq %rax, 0xa8(%rbx)
movq 0x10(%rbx), %rax
movq 0x18(%rax), %rax
testl $0x7fffffff, 0x14(%rax) # imm = 0x7FFFFFFF
je 0x21fa98
movq 0x80(%rbx), %rcx
movq 0x88(%rbx), %rdx
movq 0x20(%rax), %rsi
xorl %edi, %edi
movq $-0x1, %r8
movq %r8, (%rdx,%rdi,8)
movq %r8, (%rcx,%rdi,8)
cmpl $0x0, (%rsi,%rdi,8)
js 0x21fa85
movb $0x0, 0x4(%rsi,%rdi,8)
incq %rdi
movl 0x14(%rax), %r9d
andl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
cmpq %r9, %rdi
jb 0x21fa72
movl %ebp, %r15d
testl %ebp, %ebp
je 0x21fc6c
xorl %r13d, %r13d
movl $0x1, %ebp
xorl %r12d, %r12d
movq 0x10(%rbx), %rax
movq 0x18(%rax), %rdi
movq 0x20(%rdi), %rax
movl %r12d, %ecx
shrl %ecx
cmpl $0x0, (%rax,%rcx,8)
js 0x21fb91
movq 0x28(%rdi), %rax
testl $0xfffffffe, (%rax,%r12,8) # imm = 0xFFFFFFFE
je 0x21fb91
movq 0x88(%rbx), %rax
cmpl $-0x1, (%rax,%r12,4)
jne 0x21fb91
movq 0xa8(%rbx), %rcx
movq %r13, 0x38(%rsp)
movl %r13d, 0x30(%rsp)
movl %r13d, 0x28(%rsp)
movq %r13, 0x20(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rsp)
movl %r13d, 0x8(%rsp)
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
xorl %esi, %esi
movl %r12d, %edx
movq %r14, %r8
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
callq 0xbf39f
testq %rax, %rax
je 0x21fb91
movq 0x50(%rbx), %rax
testq %rax, %rax
je 0x21fb71
movq 0x60(%rbx), %rcx
xorl %edx, %edx
movl (%rcx,%rdx,4), %esi
cmpq %rsi, %r12
je 0x21fb67
movq 0x30(%rbx), %rdi
cmpl (%rdi), %esi
je 0x21fb67
movq 0x88(%rbx), %rdi
xorq $0x1, %rsi
movl %ebp, (%rdi,%rsi,4)
movl (%rcx,%rdx,4), %esi
movl %ebp, (%rdi,%rsi,4)
incq %rdx
movl %edx, %esi
cmpq %rsi, %rax
ja 0x21fb43
movq 0x88(%rbx), %rax
movl $0x2, (%rax,%r12,4)
movq 0x30(%rbx), %rcx
movl (%rcx), %ecx
xorq $0x1, %rcx
movl $0x3, (%rax,%rcx,4)
incq %r12
cmpq %r15, %r12
jne 0x21faae
xorl %r13d, %r13d
xorl %r12d, %r12d
movq 0x88(%rbx), %rax
cmpl $0x2, (%rax,%r12,4)
jne 0x21fc60
movq 0x10(%rbx), %rax
movq 0xa8(%rbx), %rcx
movq 0x18(%rax), %rdi
movq %r13, 0x38(%rsp)
movl %r13d, 0x30(%rsp)
movl %r13d, 0x28(%rsp)
movq %r13, 0x20(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rsp)
movl %r13d, 0x8(%rsp)
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
xorl %esi, %esi
movl %r12d, %edx
movq %r14, %r8
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
callq 0xbf39f
testq %rax, %rax
je 0x21fc60
movq 0x50(%rbx), %rax
testq %rax, %rax
je 0x21fc48
movq 0x60(%rbx), %rcx
xorl %edx, %edx
movl (%rcx,%rdx,4), %esi
cmpq %rsi, %r12
je 0x21fc3e
movq 0x30(%rbx), %rdi
cmpl (%rdi), %esi
je 0x21fc3e
movq 0x80(%rbx), %r8
movl %r12d, (%r8,%rsi,4)
movl (%rdi), %esi
xorl $0x1, %esi
movl (%rcx,%rdx,4), %edi
xorq $0x1, %rdi
movl %esi, (%r8,%rdi,4)
incq %rdx
movl %edx, %esi
cmpq %rsi, %rax
ja 0x21fc13
movq 0x80(%rbx), %rax
movl %r12d, (%rax,%r12,4)
movq 0x30(%rbx), %rcx
movl (%rcx), %ecx
xorq $0x1, %rcx
movl %ecx, (%rax,%rcx,4)
incq %r12
cmpq %r15, %r12
jne 0x21fba3
movq 0x80(%rbx), %rsi
movq 0x88(%rbx), %rdi
shlq $0x2, %r15
movq %r15, %rdx
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2160