// File: /workspace/github_cpp_makefile_star2_O1/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 %rdi, %r14
movq 0x18(%rdi), %rax
movq %rax, 0x10(%rsp)
movq 0x1d8(%rdi), %r8
movslq %edx, %rax
imulq $0x328, %rax, %rdx      # imm = 0x328
leaq (%r8,%rdx), %r9
movq 0x230(%rdi), %rax
movq 0x10(%rax), %rax
leaq (%rsi,%rsi,4), %rcx
movq 0x250(%rdi), %rdi
xorl %r13d, %r13d
movl %r13d, (%rdi,%rsi,4)
movq 0x258(%r14), %rdi
movl %r13d, (%rdi,%rsi,4)
movq 0x248(%r14), %rdi
movq %rsi, (%rsp)
movl %r13d, (%rdi,%rsi,4)
movq %r13, 0x78(%r8,%rdx)
movq %r13, 0x90(%r8,%rdx)
movl $0x0, %ebp
cmpl %r13d, 0x10(%rax,%rcx,8)
movq %r9, 0x8(%rsp)
je 0x21d7f8
leaq (%rax,%rcx,8), %rbx
xorl %r15d, %r15d
xorl %ebp, %ebp
xorl %r13d, %r13d
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %r12
shrq $0x21, %r12
movq %r12, %rsi
subq 0x208(%r14), %rsi
jae 0x21d7b1
movl $0x1, %edx
movq %r14, %rdi
movq %r12, %rsi
movq %r9, %rcx
callq 0x21c9be
incq %r13
jmp 0x21d7e8
movq %r14, %rdi
xorl %edx, %edx
movq %r9, %rcx
callq 0x21c9be
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
movl 0x10(%rax,%rcx,8), %eax
addq %rax, %rbp
incq %r15
movl 0x10(%rbx), %eax
cmpq %rax, %r15
movq 0x8(%rsp), %r9
jb 0x21d781
movq 0x258(%r14), %rax
movq (%rsp), %rcx
movl %r13d, (%rax,%rcx,4)
movq 0x78(%r9), %rbx
testq %rbx, %rbx
je 0x21d85d
movq 0x88(%r9), %r12
leaq (%r12,%rbx,8), %rsi
movq %r12, %rdi
callq 0x1e3b6a
movq 0x8(%rsp), %r9
leaq 0x1(%rbx), %rcx
cmpq $0x3, %rcx
movl $0x2, %eax
cmovaeq %rcx, %rax
movl $0x1, %ecx
xorl %edx, %edx
cmpq %rcx, %rbx
je 0x21d84f
movq (%r12,%rdx,8), %rsi
cmpq (%r12,%rcx,8), %rsi
je 0x21d855
incq %r13
movq %rcx, %rdx
incq %rcx
cmpq %rcx, %rax
jne 0x21d840
movq 0x90(%r9), %rbx
testq %rbx, %rbx
je 0x21d8b1
movq 0xa0(%r9), %r15
leaq (%r15,%rbx,8), %rsi
movq %r15, %rdi
callq 0x1e3b6a
leaq 0x1(%rbx), %rcx
cmpq $0x3, %rcx
movl $0x2, %eax
cmovaeq %rcx, %rax
movl $0x1, %ecx
xorl %edx, %edx
cmpq %rcx, %rbx
je 0x21d8a3
movq (%r15,%rdx,8), %rsi
cmpq (%r15,%rcx,8), %rsi
je 0x21d8a9
incq %rbp
movq %rcx, %rdx
incq %rcx
cmpq %rcx, %rax
jne 0x21d894
movq 0x248(%r14), %rax
movq (%rsp), %rcx
movl %r13d, (%rax,%rcx,4)
movq 0x250(%r14), %rax
movl %ebp, (%rax,%rcx,4)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq