// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: renew_u2g_cov(ul_resolve_t*, telo_end_t*)
void renew_u2g_cov(ul_resolve_t *uidx, telo_end_t *te)
{
    ul2ul_idx_t *idx = &(uidx->uovl); uinfo_srt_warp_t *x;
    ma_ug_t *i_ug = idx->i_ug, *raw = uidx->l1_ug; uint64_t k, z, iug_occ, m, l, *a, a_n; 
    free(idx->cc.uc); free(idx->cc.hc); free(idx->cc.raw_uc); 
    free(idx->cc.iug_idx); free(idx->cc.iug_b); free(idx->cc.iug_a); 
    if(te) {
        free(idx->telo); idx->telo = NULL;
    }
    memset(&(idx->cc), 0, sizeof(idx->cc));

    MALLOC(idx->cc.uc, i_ug->u.n); ///number of ul (contained+non-contained)
    MALLOC(idx->cc.raw_uc, i_ug->u.n); ///number of ul (non-contained)
    MALLOC(idx->cc.hc, i_ug->u.n); ///number of HiFi reads
    if(te) MALLOC(idx->telo, i_ug->u.n); ///is telo

    kt_for(uidx->str_b.n_thread, worker_renew_u2g_cov, uidx, i_ug->u.n);

    CALLOC(idx->cc.iug_a, i_ug->u.n); ///integer sequence of each integer unitig
    CALLOC(idx->cc.iug_idx, raw->u.n+1); ///idx for integer sequences
    // fprintf(stderr, "malloc::[M::%s::] i_ug->u.n:%u\n", __func__, (uint32_t)i_ug->u.n);
    for (k = iug_occ = 0; k < i_ug->u.n; k++) {
        // fprintf(stderr, "-[M::%s::] k::%lu, i_ug->u.n:%u\n", __func__, k, (uint32_t)i_ug->u.n);
        gen_raw_ug_seq(uidx, uidx->pstr.str.a, &(i_ug->u.a[k]), raw, &(idx->cc.iug_a[k]), k);
        iug_occ += idx->cc.iug_a[k].n; x = &(idx->cc.iug_a[k]);
        for (z = 0; z < x->n; z++) idx->cc.iug_idx[x->a[z].v>>1]++;

        if(te) {
            idx->telo[k] = 0;
            for (z = 0; z < x->n; z++) {
                if(gen_utg_telo(&(raw->u.a[x->a[z].v>>1]), te)) break;
            }
            if(z < x->n) idx->telo[k] = 1;
        }
    }

    MALLOC(idx->cc.iug_b, iug_occ); ///idx for integer sequences
    for (k = l = 0; k < raw->u.n+1; k++) {
        m = idx->cc.iug_idx[k];
        idx->cc.iug_idx[k] = l;
        l += m;
        if(m > 0) idx->cc.iug_b[l-1] = 0;
    }
    assert(l == iug_occ);

    for (k = 0; k < i_ug->u.n; k++) {
        x = &(idx->cc.iug_a[k]);
        for (z = 0; z < x->n; z++) {
            a = idx->cc.iug_b + idx->cc.iug_idx[x->a[z].v>>1];
            a_n = idx->cc.iug_idx[(x->a[z].v>>1)+1] - idx->cc.iug_idx[x->a[z].v>>1];
            if(a_n) {
                if(a[a_n-1] == a_n-1) a[a_n-1] = (k<<32)|z;///id of unitig | offset within the unitig
                else a[a[a_n-1]++] = (k<<32)|z;
            }        
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq 0x230(%rdi), %rbp
movq 0x18(%rdi), %rax
movq %rax, (%rsp)
leaq 0x248(%rdi), %r15
movq 0x248(%rdi), %rdi
callq 0x2220
movq 0x250(%rbx), %rdi
callq 0x2220
movq 0x258(%rbx), %rdi
callq 0x2220
movq 0x268(%rbx), %rdi
callq 0x2220
movq 0x270(%rbx), %rdi
callq 0x2220
movq 0x260(%rbx), %rdi
callq 0x2220
testq %r14, %r14
je 0x228c93
movq 0x2a8(%rbx), %rdi
callq 0x2220
movq $0x0, 0x2a8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%r15)
movups %xmm0, 0x10(%r15)
movups %xmm0, (%r15)
movq (%rbp), %r12
leaq (,%r12,4), %r13
movq %r13, %rdi
callq 0x2280
movq %rax, 0x248(%rbx)
movq %r13, %rdi
callq 0x2280
movq %rax, 0x258(%rbx)
movq %r13, %rdi
callq 0x2280
movq %rax, 0x250(%rbx)
testq %r14, %r14
je 0x228cf1
movq %r12, %rdi
callq 0x2280
movq %rax, 0x2a8(%rbx)
movl 0x1e0(%rbx), %edi
leaq 0x269(%rip), %rsi       # 0x228f67
movq %rbx, %rdx
movq %r12, %rcx
callq 0x108f2c
movq (%rbp), %r12
movl $0x18, %esi
movq %r12, %rdi
callq 0x2120
movq %rax, 0x260(%rbx)
movq (%rsp), %rax
movq (%rax), %r15
leaq 0x1(%r15), %rdi
movl $0x4, %esi
callq 0x2120
movq %rax, 0x268(%rbx)
testq %r12, %r12
je 0x228e51
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x1d0(%rbx), %rsi
leaq (%r15,%r15,4), %rdx
shlq $0x3, %rdx
addq 0x10(%rbp), %rdx
leaq (,%r15,8), %rax
leaq (%rax,%rax,2), %r13
movq 0x260(%rbx), %r8
addq %r13, %r8
movq %rbx, %rdi
movq (%rsp), %rcx
callq 0x2285b8
movq 0x260(%rbx), %rax
leaq (%rax,%r13), %rsi
movq (%rax,%r13), %rax
testq %rax, %rax
je 0x228db6
movq 0x268(%rbx), %rcx
movq 0x10(%rsi), %rdx
movq %rax, %rdi
movl (%rdx), %r8d
shrl %r8d
incl (%rcx,%r8,4)
addq $0x10, %rdx
decq %rdi
jne 0x228da3
testq %r14, %r14
je 0x228e35
movq 0x2a8(%rbx), %rcx
movb $0x0, (%rcx,%r15)
movq (%rsi), %rcx
testq %rcx, %rcx
je 0x228e35
movq (%rsp), %rdx
movq 0x10(%rdx), %rdx
movq 0x10(%rsi), %rsi
xorl %edi, %edi
movq %rdi, %r8
shlq $0x4, %r8
movl (%rsi,%r8), %r8d
shrl %r8d
leaq (%r8,%r8,4), %r9
movl 0x10(%rdx,%r9,8), %r8d
testq %r8, %r8
je 0x228e1f
leaq (%rdx,%r9,8), %r10
movq 0x10(%r14), %r9
movq 0x18(%r10), %r10
xorl %r11d, %r11d
movq (%r10,%r11,8), %r13
shrq $0x21, %r13
cmpb $0x0, (%r9,%r13)
jne 0x228e29
incq %r11
cmpq %r11, %r8
jne 0x228e08
incq %rdi
cmpq %rcx, %rdi
jne 0x228ddd
jmp 0x228e35
movq 0x2a8(%rbx), %rcx
movb $0x1, (%rcx,%r15)
addq %rax, %r12
incq %r15
movq (%rbp), %r13
cmpq %r13, %r15
jb 0x228d4c
movq (%rsp), %rax
movq (%rax), %r15
jmp 0x228e57
xorl %r13d, %r13d
xorl %r12d, %r12d
leaq (,%r12,8), %rdi
callq 0x2280
movq %rax, 0x270(%rbx)
cmpq $-0x1, %r15
je 0x228ea4
movq 0x268(%rbx), %rcx
movq $-0x1, %rdx
xorl %esi, %esi
movl 0x4(%rcx,%rdx,4), %edi
movl %esi, 0x4(%rcx,%rdx,4)
addq %rdi, %rsi
testq %rdi, %rdi
je 0x228e9a
movq $0x0, -0x8(%rax,%rsi,8)
incq %rdx
cmpq %r15, %rdx
jb 0x228e81
jmp 0x228ea6
xorl %esi, %esi
cmpq %r12, %rsi
jne 0x228f48
testq %r13, %r13
je 0x228f39
movq 0x260(%rbx), %rcx
xorl %edx, %edx
leaq (%rdx,%rdx,2), %rsi
cmpq $0x0, (%rcx,%rsi,8)
je 0x228f31
leaq (%rcx,%rsi,8), %rsi
movq 0x268(%rbx), %rdi
movq 0x10(%rsi), %r8
movq %rdx, %r9
shlq $0x20, %r9
xorl %r10d, %r10d
movl (%r8), %r14d
shrl %r14d
movl (%rdi,%r14,4), %r11d
movl 0x4(%rdi,%r14,4), %r14d
subl %r11d, %r14d
je 0x228f25
leaq (%rax,%r11,8), %r15
leaq (%r15,%r14,8), %r11
addq $-0x8, %r11
decq %r14
movq (%r11), %r12
cmpq %r14, %r12
je 0x228f1c
leaq 0x1(%r12), %r14
movq %r14, (%r11)
leaq (%r15,%r12,8), %r11
movq %r10, %r14
orq %r9, %r14
movq %r14, (%r11)
incq %r10
addq $0x10, %r8
cmpq (%rsi), %r10
jb 0x228ee5
incq %rdx
cmpq %r13, %rdx
jb 0x228ec1
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x211c9(%rip), %rdi     # 0x24a118
leaq 0x1c6b3(%rip), %rsi     # 0x245609
leaq 0x211c8(%rip), %rcx     # 0x24a125
movl $0x40db, %edx           # imm = 0x40DB
callq 0x2110