// File: /workspace/github_cpp_makefile_star2_O3/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 0xc0162
movq %rax, 0xa8(%rbx)
movq 0x10(%rbx), %rax
movq 0x18(%rax), %rax
testl $0x7fffffff, 0x14(%rax) # imm = 0x7FFFFFFF
je 0x22b276
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 0x22b263
movb $0x0, 0x4(%rsi,%rdi,8)
incq %rdi
movl 0x14(%rax), %r9d
andl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
cmpq %r9, %rdi
jb 0x22b250
xorl %r15d, %r15d
testl %ebp, %ebp
je 0x22b460
movl %ebp, 0x44(%rsp)
movl %ebp, %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 0x22b373
movq 0x28(%rdi), %rax
testl $0xfffffffe, (%rax,%r12,8) # imm = 0xFFFFFFFE
je 0x22b373
movq 0x88(%rbx), %rax
cmpl $-0x1, (%rax,%r12,4)
jne 0x22b373
movq 0xa8(%rbx), %rcx
movq %r15, 0x38(%rsp)
movl %r15d, 0x30(%rsp)
movl %r15d, 0x28(%rsp)
movq %r15, 0x20(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rsp)
movl %r15d, 0x8(%rsp)
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
xorl %esi, %esi
movl %r12d, %edx
movq %r14, %r8
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
callq 0xc02d6
testq %rax, %rax
je 0x22b373
movq 0x50(%rbx), %rax
testq %rax, %rax
je 0x22b353
movq 0x60(%rbx), %rcx
xorl %edx, %edx
movl (%rcx,%rdx,4), %esi
cmpq %rsi, %r12
je 0x22b349
movq 0x30(%rbx), %rdi
cmpl (%rdi), %esi
je 0x22b349
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 0x22b325
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 %r13, %r12
jne 0x22b290
xorl %r15d, %r15d
cmpl $0x0, 0x44(%rsp)
je 0x22b460
xorl %r12d, %r12d
movq 0x88(%rbx), %rax
cmpl $0x2, (%rax,%r12,4)
jne 0x22b44d
movq 0x10(%rbx), %rax
movq 0xa8(%rbx), %rcx
movq 0x18(%rax), %rdi
movq %r15, 0x38(%rsp)
movl %r15d, 0x30(%rsp)
movl %r15d, 0x28(%rsp)
movq %r15, 0x20(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rsp)
movl %r15d, 0x8(%rsp)
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
xorl %esi, %esi
movl %r12d, %edx
movq %r14, %r8
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
callq 0xc02d6
testq %rax, %rax
je 0x22b44d
movq 0x50(%rbx), %rax
testq %rax, %rax
je 0x22b435
movq 0x60(%rbx), %rcx
xorl %edx, %edx
movl (%rcx,%rdx,4), %esi
cmpq %rsi, %r12
je 0x22b42b
movq 0x30(%rbx), %rdi
cmpl (%rdi), %esi
je 0x22b42b
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 0x22b400
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 %r13, %r12
jne 0x22b390
shlq $0x2, %r13
movq %r13, %r15
movq 0x80(%rbx), %rsi
movq 0x88(%rbx), %rdi
movq %r15, %rdx
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2160