// File: /workspace/github_cpp_makefile_star2_O2/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, %r14
movq 0x10(%rdi), %rax
movq 0x18(%rax), %rdi
movl 0x14(%rdi), %ebx
leaq 0x18(%r14), %r15
movq %r15, %rsi
callq 0x84975
movq %rax, 0xa8(%r14)
movq 0x10(%r14), %rax
movq 0x18(%rax), %rax
xorl %ecx, %ecx
movl 0x14(%rax), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
cmpq %rdx, %rcx
jae 0x1dd3d7
movq 0x88(%r14), %rdx
orq $-0x1, (%rdx,%rcx,8)
movq 0x80(%r14), %rdx
orq $-0x1, (%rdx,%rcx,8)
movq 0x20(%rax), %rdx
cmpl $0x0, (%rdx,%rcx,8)
js 0x1dd3d2
movb $0x0, 0x4(%rdx,%rcx,8)
incq %rcx
jmp 0x1dd39d
addl %ebx, %ebx
xorl %r12d, %r12d
pushq $-0x1
popq %rbp
pushq $0x1
popq %r13
cmpq %rbx, %r12
je 0x1dd4d1
movq 0x10(%r14), %rax
movq 0x18(%rax), %rdi
movq 0x20(%rdi), %rax
movl %r12d, %ecx
shrl %ecx
cmpl $0x0, (%rax,%rcx,8)
js 0x1dd4c9
movq 0x28(%rdi), %rax
testl $0xfffffffe, (%rax,%r12,8) # imm = 0xFFFFFFFE
je 0x1dd4c9
movq 0x88(%r14), %rax
cmpl $-0x1, (%rax,%r12,4)
jne 0x1dd4c9
movq 0xa8(%r14), %rcx
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rsp)
andq $0x0, 0x38(%rsp)
andl $0x0, 0x30(%rsp)
andl $0x0, 0x28(%rsp)
andq $0x0, 0x20(%rsp)
andl $0x0, 0x8(%rsp)
orl $-0x1, (%rsp)
xorl %esi, %esi
movl %r12d, %edx
movq %r15, %r8
movl %ebp, %r9d
callq 0x84a86
testq %rax, %rax
je 0x1dd4c9
movq 0x50(%r14), %rax
xorl %ecx, %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
jbe 0x1dd4a9
movq 0x60(%r14), %rdx
movl (%rdx,%rcx,4), %esi
cmpq %rsi, %r12
je 0x1dd4a5
movq 0x30(%r14), %rdi
cmpl (%rdi), %esi
je 0x1dd4a5
movq 0x88(%r14), %rdi
xorq $0x1, %rsi
movl %r13d, (%rdi,%rsi,4)
movl (%rdx,%rcx,4), %edx
movl %r13d, (%rdi,%rdx,4)
incl %ecx
jmp 0x1dd474
movq 0x88(%r14), %rax
movl $0x2, (%rax,%r12,4)
movq 0x30(%r14), %rcx
movl (%rcx), %ecx
xorq $0x1, %rcx
movl $0x3, (%rax,%rcx,4)
incq %r12
jmp 0x1dd3e3
xorl %r12d, %r12d
pushq $-0x1
popq %rbp
movq 0x88(%r14), %rdi
cmpq %rbx, %r12
je 0x1dd59d
cmpl $0x2, (%rdi,%r12,4)
jne 0x1dd595
movq 0x10(%r14), %rax
movq 0xa8(%r14), %rcx
movq 0x18(%rax), %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rsp)
andq $0x0, 0x38(%rsp)
andl $0x0, 0x30(%rsp)
andl $0x0, 0x28(%rsp)
andq $0x0, 0x20(%rsp)
andl $0x0, 0x8(%rsp)
orl $-0x1, (%rsp)
xorl %esi, %esi
movl %r12d, %edx
movq %r15, %r8
movl %ebp, %r9d
callq 0x84a86
testq %rax, %rax
je 0x1dd595
movq 0x50(%r14), %rax
xorl %ecx, %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
jbe 0x1dd57d
movq 0x60(%r14), %rdx
movl (%rdx,%rcx,4), %esi
cmpq %rsi, %r12
je 0x1dd579
movq 0x30(%r14), %rdi
cmpl (%rdi), %esi
je 0x1dd579
movq 0x80(%r14), %r8
movl %r12d, (%r8,%rsi,4)
movl (%rdi), %esi
xorl $0x1, %esi
movl (%rdx,%rcx,4), %edx
xorq $0x1, %rdx
movl %esi, (%r8,%rdx,4)
incl %ecx
jmp 0x1dd543
movq 0x80(%r14), %rax
movl %r12d, (%rax,%r12,4)
movq 0x30(%r14), %rcx
movl (%rcx), %ecx
xorq $0x1, %rcx
movl %ecx, (%rax,%rcx,4)
incq %r12
jmp 0x1dd4d7
movq 0x80(%r14), %rsi
shlq $0x2, %rbx
movq %rbx, %rdx
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2160