// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: worker_clean_usg(void*, long, int)
static void worker_clean_usg(void *data, long i, int tid) // callback for kt_for()
{
    usg_t *g = (usg_t *)data; usg_seq_t *z = g->a + i; uint32_t k, m, l, srt; 
    usg_arc_warp *x; usg_arc_mm_warp *y;
    if(z->del) z->arc[0].n = z->arc[1].n = 0;

    x = &(z->arc[0]); y = &(z->arc_mm[0]);
    for (k = m = srt = 0; k < x->n; k++) {
        if(x->a[k].del) continue;
        x->a[m] = x->a[k]; x->a[m].idx = 0;
        if(m > 0 && x->a[m].v < x->a[m-1].v) srt = 1;
        m++;
    }
    x->n = m; if(srt) radix_sort_usg_arc_srt(x->a, x->a + x->n);

    radix_sort_usg_arc_mm_srt(y->a, y->a + y->n); k = l = m = 0;
    while (k < y->n && l < x->n) {
        if(y->a[k].v < x->a[l].v) {
            k++;
        } else if(y->a[k].v > x->a[l].v) {
            l++;
        } else {
            y->a[m].v = y->a[k].v;
            if(m > 0 && y->a[m].v == y->a[m-1].v) {
                x->a[l].idx++;
            } else {
                x->a[l].idx = m; x->a[l].idx <<= 32; x->a[l].idx++;
            }
            m++; k++;
        }
    }
    y->n = m;    



    x = &(z->arc[1]); y = &(z->arc_mm[1]);
    for (k = m = srt = 0; k < x->n; k++) {
        if(x->a[k].del) continue;
        x->a[m] = x->a[k]; x->a[m].idx = 0;
        if(m > 0 && x->a[m].v < x->a[m-1].v) srt = 1;
        m++;
    }
    x->n = m; if(srt) radix_sort_usg_arc_srt(x->a, x->a + x->n);
    
    radix_sort_usg_arc_mm_srt(y->a, y->a + y->n); k = l = m = 0;
    while (k < y->n && l < x->n) {
        if(y->a[k].v < x->a[l].v) {
            k++;
        } else if(y->a[k].v > x->a[l].v) {
            l++;
        } else {
            y->a[m].v = y->a[k].v;
            if(m > 0 && y->a[m].v == y->a[m-1].v) {
                x->a[l].idx++;
            } else {
                x->a[l].idx = m; x->a[l].idx <<= 32; x->a[l].idx++;
            }
            m++; k++;
        }
    }
    y->n = m;    

}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq (%rdi), %rax
imulq $0x78, %rsi, %rcx
leaq (%rax,%rcx), %rbx
cmpb $0x0, 0x70(%rax,%rcx)
je 0x2139dc
movq $0x0, 0x28(%rbx)
movq $0x0, 0x10(%rbx)
movq 0x40(%rbx), %rax
movq 0x50(%rbx), %rdi
leaq (%rax,%rax,2), %rax
leaq (%rdi,%rax,4), %rsi
callq 0x1eea8d
movq 0x40(%rbx), %rcx
xorl %eax, %eax
testq %rcx, %rcx
je 0x2138a0
movq 0x10(%rbx), %rsi
xorl %r10d, %r10d
xorl %edx, %edx
xorl %edi, %edi
movl %eax, %r8d
cmpq %r8, %rsi
jbe 0x21389e
movq 0x20(%rbx), %r9
movq 0x50(%rbx), %r11
leaq (%r10,%r10,2), %r10
movl (%r11,%r10,4), %r10d
shlq $0x5, %r8
cmpl 0x8(%r9,%r8), %r10d
jb 0x213894
jbe 0x213862
incl %eax
jmp 0x213896
movl %edx, %r14d
leaq (%r14,%r14,2), %r15
movl %r10d, (%r11,%r15,4)
testl %edx, %edx
je 0x213886
leal -0x1(%rdx), %r15d
leaq (%r15,%r15,2), %r15
cmpl (%r11,%r15,4), %r10d
jne 0x213886
incq 0x18(%r9,%r8)
jmp 0x213892
shlq $0x20, %r14
incq %r14
movq %r14, 0x18(%r9,%r8)
incl %edx
incl %edi
movl %edi, %r10d
cmpq %r10, %rcx
ja 0x213839
movl %edx, %eax
movq %rax, 0x40(%rbx)
movq 0x28(%rbx), %r8
testq %r8, %r8
je 0x213940
movq 0x38(%rbx), %rax
xorl %r9d, %r9d
movl $0x1, %ecx
movl $0x1, %esi
xorl %edx, %edx
xorl %edi, %edi
shlq $0x5, %r9
cmpl $0x0, 0xc(%rax,%r9)
js 0x21391c
addq %rax, %r9
movl %edi, %r8d
shlq $0x5, %r8
movups (%r9), %xmm0
movups 0x10(%r9), %xmm1
movups %xmm1, 0x10(%rax,%r8)
movups %xmm0, (%rax,%r8)
movq 0x38(%rbx), %rax
movq $0x0, 0x18(%rax,%r8)
testl %edi, %edi
je 0x213916
movl 0x8(%rax,%r8), %r8d
leal -0x1(%rdi), %r9d
shlq $0x5, %r9
cmpl 0x8(%rax,%r9), %r8d
cmovbl %ecx, %edx
incl %edi
movq 0x28(%rbx), %r8
movl %esi, %r9d
incl %esi
cmpq %r9, %r8
ja 0x2138c6
movl %edi, %esi
movq %rsi, 0x28(%rbx)
testl %edx, %edx
je 0x213940
movq 0x38(%rbx), %rdi
shlq $0x5, %rsi
addq %rdi, %rsi
callq 0x1ee873
movq 0x58(%rbx), %rax
movq 0x68(%rbx), %rdi
leaq (%rax,%rax,2), %rax
leaq (%rdi,%rax,4), %rsi
callq 0x1eea8d
movq 0x58(%rbx), %rcx
xorl %eax, %eax
testq %rcx, %rcx
je 0x2139d2
movq 0x28(%rbx), %rsi
xorl %r10d, %r10d
xorl %edx, %edx
xorl %edi, %edi
movl %eax, %r8d
cmpq %r8, %rsi
jbe 0x2139d0
movq 0x38(%rbx), %r9
movq 0x68(%rbx), %r11
leaq (%r10,%r10,2), %r10
movl (%r11,%r10,4), %r10d
shlq $0x5, %r8
cmpl 0x8(%r9,%r8), %r10d
jb 0x2139c6
jbe 0x213994
incl %eax
jmp 0x2139c8
movl %edx, %r14d
leaq (%r14,%r14,2), %r15
movl %r10d, (%r11,%r15,4)
testl %edx, %edx
je 0x2139b8
leal -0x1(%rdx), %r15d
leaq (%r15,%r15,2), %r15
cmpl (%r11,%r15,4), %r10d
jne 0x2139b8
incq 0x18(%r9,%r8)
jmp 0x2139c4
shlq $0x20, %r14
incq %r14
movq %r14, 0x18(%r9,%r8)
incl %edx
incl %edi
movl %edi, %r10d
cmpq %r10, %rcx
ja 0x21396b
movl %edx, %eax
movq %rax, 0x58(%rbx)
popq %rbx
popq %r14
popq %r15
retq
movq 0x10(%rbx), %r8
testq %r8, %r8
je 0x213806
movq 0x20(%rbx), %rax
xorl %r9d, %r9d
movl $0x1, %ecx
movl $0x1, %esi
xorl %edx, %edx
xorl %edi, %edi
shlq $0x5, %r9
cmpl $0x0, 0xc(%rax,%r9)
js 0x213a54
addq %rax, %r9
movl %edi, %r8d
shlq $0x5, %r8
movups (%r9), %xmm0
movups 0x10(%r9), %xmm1
movups %xmm1, 0x10(%rax,%r8)
movups %xmm0, (%rax,%r8)
movq 0x20(%rbx), %rax
movq $0x0, 0x18(%rax,%r8)
testl %edi, %edi
je 0x213a4e
movl 0x8(%rax,%r8), %r8d
leal -0x1(%rdi), %r9d
shlq $0x5, %r9
cmpl 0x8(%rax,%r9), %r8d
cmovbl %ecx, %edx
incl %edi
movq 0x10(%rbx), %r8
movl %esi, %r9d
incl %esi
cmpq %r9, %r8
ja 0x2139fe
movl %edi, %esi
movq %rsi, 0x10(%rbx)
testl %edx, %edx
je 0x21380e
movq 0x20(%rbx), %rdi
shlq $0x5, %rsi
addq %rdi, %rsi
callq 0x1ee873
jmp 0x21380e