// File: /workspace/github_cpp_makefile_star2_O1/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
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x230(%rdi), %rbp
movq 0x18(%rdi), %rax
movq %rax, 0x8(%rsp)
leaq 0x248(%rdi), %r12
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
movq %r14, 0x10(%rsp)
testq %r14, %r14
je 0x21d3e9
movq 0x2a8(%rbx), %rdi
callq 0x2220
movq $0x0, 0x2a8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%r12)
movups %xmm0, 0x10(%r12)
movups %xmm0, (%r12)
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)
cmpq $0x0, 0x10(%rsp)
je 0x21d44d
movq %r12, %rdi
callq 0x2280
movq %rax, 0x2a8(%rbx)
movl 0x1e0(%rbx), %edi
leaq 0x293(%rip), %rsi       # 0x21d6ed
movq %rbx, %rdx
movq %r12, %rcx
callq 0x1047b4
movq (%rbp), %rdi
movl $0x18, %esi
callq 0x2120
movq %rax, 0x260(%rbx)
movq 0x8(%rsp), %rax
movq (%rax), %rdi
incq %rdi
movl $0x4, %esi
callq 0x2120
movq %rax, 0x268(%rbx)
cmpq $0x0, (%rbp)
je 0x21d5c8
xorl %r13d, %r13d
xorl %r12d, %r12d
movq 0x1d0(%rbx), %rsi
leaq (,%r13,4), %rdx
addq %r13, %rdx
shlq $0x3, %rdx
movq %rbp, %r14
addq 0x10(%rbp), %rdx
leaq (,%r13,8), %rax
leaq (%rax,%rax,2), %r15
movq 0x260(%rbx), %r8
addq %r15, %r8
movq %rbx, %rdi
movq 0x8(%rsp), %rcx
callq 0x21cd75
movq 0x260(%rbx), %rax
leaq (%rax,%r15), %rdi
movq (%rax,%r15), %rax
testq %rax, %rax
je 0x21d51c
movq 0x268(%rbx), %rcx
movq 0x10(%rdi), %rdx
movq %rax, %rsi
movl (%rdx), %r8d
shrl %r8d
incl (%rcx,%r8,4)
addq $0x10, %rdx
decq %rsi
jne 0x21d509
cmpq $0x0, 0x10(%rsp)
je 0x21d5b4
movq 0x2a8(%rbx), %rcx
movb $0x0, (%rcx,%r13)
movq (%rdi), %rcx
testq %rcx, %rcx
setne %dl
je 0x21d5b4
movq 0x8(%rsp), %rsi
movq 0x10(%rsi), %rsi
movq 0x10(%rdi), %rdi
xorl %r8d, %r8d
movq %r8, %r9
shlq $0x4, %r9
movl (%rdi,%r9), %r9d
shrl %r9d
leaq (%r9,%r9,4), %r10
movl 0x10(%rsi,%r10,8), %r9d
testq %r9, %r9
je 0x21d596
leaq (%rsi,%r10,8), %r11
movq 0x10(%rsp), %r10
movq 0x10(%r10), %r10
movq 0x18(%r11), %r11
xorl %r15d, %r15d
movq (%r11,%r15,8), %rbp
shrq $0x21, %rbp
cmpb $0x0, (%r10,%rbp)
jne 0x21d5a3
incq %r15
cmpq %r15, %r9
jne 0x21d57f
incq %r8
cmpq %rcx, %r8
setb %dl
jne 0x21d54f
jmp 0x21d5b4
testb $0x1, %dl
je 0x21d5b4
movq 0x2a8(%rbx), %rcx
movb $0x1, (%rcx,%r13)
addq %rax, %r12
incq %r13
movq %r14, %rbp
cmpq (%r14), %r13
jb 0x21d4a7
jmp 0x21d5cb
xorl %r12d, %r12d
leaq (,%r12,8), %rdi
callq 0x2280
movq %rax, 0x270(%rbx)
movq 0x8(%rsp), %rcx
cmpq $-0x1, (%rcx)
je 0x21d621
movq 0x268(%rbx), %rcx
xorl %edx, %edx
xorl %esi, %esi
movl (%rcx,%rdx,4), %edi
movl %esi, (%rcx,%rdx,4)
addq %rdi, %rsi
testq %rdi, %rdi
je 0x21d60c
movq $0x0, -0x8(%rax,%rsi,8)
incq %rdx
movq 0x8(%rsp), %rdi
movq (%rdi), %rdi
incq %rdi
cmpq %rdi, %rdx
jb 0x21d5f5
jmp 0x21d623
xorl %esi, %esi
cmpq %r12, %rsi
jne 0x21d6ce
cmpq $0x0, (%rbp)
je 0x21d6bf
movq 0x260(%rbx), %rcx
xorl %edx, %edx
leaq (%rdx,%rdx,2), %rsi
cmpq $0x0, (%rcx,%rsi,8)
je 0x21d6b6
leaq (%rcx,%rsi,8), %rsi
movq 0x268(%rbx), %rdi
movq 0x10(%rsi), %r8
movq %rdx, %r9
shlq $0x20, %r9
xorl %r10d, %r10d
movl (%r8), %r11d
shrl %r11d
movl (%rdi,%r11,4), %r14d
movl 0x4(%rdi,%r11,4), %r11d
subl %r14d, %r11d
je 0x21d6aa
leaq (%rax,%r14,8), %r14
leaq -0x1(%r11), %r12
movq -0x8(%r14,%r11,8), %r15
cmpq %r12, %r15
jne 0x21d697
movq %r10, %r15
orq %r9, %r15
movq %r15, -0x8(%r14,%r11,8)
jmp 0x21d6aa
movq %r10, %r12
orq %r9, %r12
leaq 0x1(%r15), %r13
movq %r13, -0x8(%r14,%r11,8)
movq %r12, (%r14,%r15,8)
incq %r10
addq $0x10, %r8
cmpq (%rsi), %r10
jb 0x21d664
incq %rdx
cmpq (%rbp), %rdx
jb 0x21d640
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2075f(%rip), %rdi     # 0x23de34
leaq 0x1bc49(%rip), %rsi     # 0x239325
leaq 0x2075e(%rip), %rcx     # 0x23de41
movl $0x40db, %edx           # imm = 0x40DB
callq 0x2110