// File: 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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movl %eax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x18(%rax), %rdi
movq -0x8(%rbp), %rsi
addq $0x18, %rsi
callq 0xfde50
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0xa8(%rax)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq 0x18(%rcx), %rcx
movl 0x14(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl %ecx, %eax
jae 0x379c73
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rax
movl -0x10(%rbp), %ecx
shll %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rax
movl -0x10(%rbp), %ecx
shll %ecx
movl %ecx, %ecx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
movl -0x10(%rbp), %ecx
shll %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
movl -0x10(%rbp), %ecx
shll %ecx
movl %ecx, %ecx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movl -0x10(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x379c4d
jmp 0x379c65
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movl -0x10(%rbp), %ecx
movb $0x0, 0x4(%rax,%rcx,8)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x379ba3
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x18(%rbp), %eax
jae 0x379e47
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movl -0xc(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x379cad
jmp 0x379e39
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movl -0xc(%rbp), %ecx
movq (%rax,%rcx,8), %rax
cmpl $0x2, %eax
jae 0x379cce
jmp 0x379e39
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rax
movl -0xc(%rbp), %ecx
cmpl $-0x1, (%rax,%rcx,4)
je 0x379ce7
jmp 0x379e39
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x18(%rax), %rdi
movl -0xc(%rbp), %edx
movq -0x8(%rbp), %rax
movq 0xa8(%rax), %rcx
movq -0x8(%rbp), %r8
addq $0x18, %r8
xorl %eax, %eax
movl %eax, %esi
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
movl $0x0, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x0, 0x28(%rsp)
movl $0x0, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
callq 0xfe040
cmpq $0x0, %rax
je 0x379e37
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpq 0x50(%rcx), %rax
jae 0x379e01
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
movl -0x14(%rbp), %ecx
movl (%rax,%rcx,4), %eax
cmpl -0xc(%rbp), %eax
je 0x379dac
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
movl -0x14(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movq -0x8(%rbp), %rcx
movq 0x30(%rcx), %rcx
cmpl (%rcx), %eax
jne 0x379dae
jmp 0x379df3
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x60(%rcx), %rcx
movl -0x14(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
xorl $0x1, %ecx
movl %ecx, %ecx
movl $0x1, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x60(%rcx), %rcx
movl -0x14(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
movl $0x1, (%rax,%rcx,4)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x379d6e
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rax
movl -0xc(%rbp), %ecx
movl $0x2, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x30(%rcx), %rcx
movl (%rcx), %ecx
xorl $0x1, %ecx
movl %ecx, %ecx
movl $0x3, (%rax,%rcx,4)
jmp 0x379e39
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x379c7a
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x18(%rbp), %eax
jae 0x379fe3
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rax
movl -0xc(%rbp), %ecx
cmpl $0x2, (%rax,%rcx,4)
je 0x379e73
jmp 0x379fd5
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x18(%rax), %rdi
movl -0xc(%rbp), %edx
movq -0x8(%rbp), %rax
movq 0xa8(%rax), %rcx
movq -0x8(%rbp), %r8
addq $0x18, %r8
xorl %eax, %eax
movl %eax, %esi
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
movl $0x0, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x0, 0x28(%rsp)
movl $0x0, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
callq 0xfe040
cmpq $0x0, %rax
je 0x379fd3
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpq 0x50(%rcx), %rax
jae 0x379f95
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
movl -0x14(%rbp), %ecx
movl (%rax,%rcx,4), %eax
cmpl -0xc(%rbp), %eax
je 0x379f38
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
movl -0x14(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movq -0x8(%rbp), %rcx
movq 0x30(%rcx), %rcx
cmpl (%rcx), %eax
jne 0x379f3a
jmp 0x379f87
movl -0xc(%rbp), %edx
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x60(%rcx), %rcx
movl -0x14(%rbp), %esi
movl (%rcx,%rsi,4), %ecx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movl (%rax), %edx
xorl $0x1, %edx
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x60(%rcx), %rcx
movl -0x14(%rbp), %esi
movl (%rcx,%rsi,4), %ecx
xorl $0x1, %ecx
movl %ecx, %ecx
movl %edx, (%rax,%rcx,4)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x379efa
movl -0xc(%rbp), %edx
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
movl -0xc(%rbp), %ecx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movl (%rax), %edx
xorl $0x1, %edx
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x30(%rcx), %rcx
movl (%rcx), %ecx
xorl $0x1, %ecx
movl %ecx, %ecx
movl %edx, (%rax,%rcx,4)
jmp 0x379fd5
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x379e4e
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rsi
movl -0x18(%rbp), %eax
movl %eax, %edx
shlq $0x2, %rdx
callq 0x2180
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)