// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: worker_renew_u2g_cov(void*, long, int)
static void worker_renew_u2g_cov(void *data, long i, int tid) // callback for kt_for()
{
    ul_resolve_t *uidx = (ul_resolve_t *)data; 
    integer_t *buf = &(uidx->str_b.buf[tid]);
    ma_utg_t *iu = &(uidx->uovl.i_ug->u.a[i]);
    uint64_t z, ri, k, ul_n, ug_n, *a, a_n; ma_ug_t *raw = uidx->l1_ug;
    ul_cov_t *idx = &(uidx->uovl.cc); 

    idx->uc[i] = idx->raw_uc[i] = idx->hc[i] = ul_n = ug_n = 0; buf->u.n = buf->o.n = 0;
    for (z = 0; z < iu->n; z++) {
        ri = iu->a[z]>>33;
        if(ulg_type(uidx->uovl, ri)) {///ul
            clc_contain(uidx, ulg_id(uidx->uovl, ri), 1, buf); ul_n++;
        } else {///ug node
            clc_contain(uidx, ulg_id(uidx->uovl, ri), 0, buf); 
            ug_n += raw->u.a[ulg_id(uidx->uovl, ri)].n;///HiFi reads occ
        }
    }
    idx->raw_uc[i] = ul_n;

    ///buf->o: UL contained reads
    ///buf->u: HiFi reads
    if(buf->o.n > 0) {
        a = buf->o.a; a_n = buf->o.n;
        radix_sort_srt64(a, a + a_n);
        for (z = 0, k = 1; k <= a_n; k++) {
            if(k == a_n || a[z] != a[k]) {
                ul_n++; z = k;
            }
        }
    }
    if(buf->u.n > 0) {
        a = buf->u.a; a_n = buf->u.n;
        radix_sort_srt64(a, a + a_n);
        for (z = 0, k = 1; k <= a_n; k++) {
            if(k == a_n || a[z] != a[k]) {
                ug_n++; z = k;
            }
        }
    }
    idx->uc[i] = ul_n; idx->hc[i] = ug_n;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r12
movq %rdi, %r14
movq 0x18(%rdi), %rax
movq %rax, 0x10(%rsp)
movq 0x1d8(%rdi), %rsi
movslq %edx, %rax
imulq $0x328, %rax, %rdi      # imm = 0x328
leaq (%rsi,%rdi), %rcx
movq 0x230(%r14), %rax
movq 0x10(%rax), %rax
leaq (%r12,%r12,4), %r9
movq 0x250(%r14), %rdx
xorl %r10d, %r10d
movl %r10d, (%rdx,%r12,4)
movq 0x258(%r14), %rdx
movl %r10d, (%rdx,%r12,4)
movq 0x248(%r14), %r8
movl %r10d, (%r8,%r12,4)
movq %r10, 0x78(%rsi,%rdi)
movq %r10, 0x90(%rsi,%rdi)
cmpl %r10d, 0x10(%rax,%r9,8)
je 0x2290d3
movq %r12, (%rsp)
leaq (%rax,%r9,8), %rbx
xorl %r15d, %r15d
xorl %r13d, %r13d
xorl %ebp, %ebp
movq %rcx, 0x8(%rsp)
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %r12
shrq $0x21, %r12
movq %r12, %rsi
subq 0x208(%r14), %rsi
jae 0x229026
movl $0x1, %edx
movq %r14, %rdi
movq %r12, %rsi
callq 0x227f1f
incq %rbp
jmp 0x229058
movq %r14, %rdi
xorl %edx, %edx
callq 0x227f1f
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x208(%r14), %rcx
cmpq %rcx, %r12
movl $0x0, %edx
cmovbq %rdx, %rcx
subq %rcx, %r12
leaq (%r12,%r12,4), %rcx
addl 0x10(%rax,%rcx,8), %r13d
incq %r15
movl 0x10(%rbx), %eax
cmpq %rax, %r15
movq 0x8(%rsp), %rcx
jb 0x228ff9
movq 0x258(%r14), %rax
movq 0x78(%rcx), %rbx
movq (%rsp), %r12
movl %ebp, (%rax,%r12,4)
testq %rbx, %rbx
je 0x2290e0
movq 0x88(%rcx), %r12
leaq (%r12,%rbx,8), %rsi
movq %r12, %rdi
callq 0x1ee586
leaq 0x1(%rbx), %rcx
cmpq $0x3, %rcx
movl $0x2, %eax
cmovaeq %rcx, %rax
movl $0x1, %ecx
xorl %edx, %edx
cmpq %rcx, %rbx
je 0x2290ba
movq (%r12,%rdx,8), %rsi
cmpq (%r12,%rcx,8), %rsi
je 0x2290c0
incq %rbp
movq %rcx, %rdx
incq %rcx
cmpq %rcx, %rax
jne 0x2290ab
movq (%rsp), %r12
movq 0x8(%rsp), %rcx
jmp 0x2290e0
movl $0x0, (%rdx,%r12,4)
xorl %r13d, %r13d
xorl %ebp, %ebp
movq 0x90(%rcx), %rbx
testq %rbx, %rbx
je 0x229134
movq 0xa0(%rcx), %r15
leaq (%r15,%rbx,8), %rsi
movq %r15, %rdi
callq 0x1ee586
leaq 0x1(%rbx), %rcx
cmpq $0x3, %rcx
movl $0x2, %eax
cmovaeq %rcx, %rax
movl $0x1, %ecx
xorl %edx, %edx
cmpq %rcx, %rbx
je 0x229126
movq (%r15,%rdx,8), %rsi
cmpq (%r15,%rcx,8), %rsi
je 0x22912c
incl %r13d
movq %rcx, %rdx
incq %rcx
cmpq %rcx, %rax
jne 0x229117
movq 0x248(%r14), %rax
movl %ebp, (%rax,%r12,4)
movq 0x250(%r14), %rax
movl %r13d, (%rax,%r12,4)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq