// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: gen_ul2ul(ul_resolve_t*, ug_opt_t*, ulg_opt_t*, unsigned int, unsigned long)
ul2ul_idx_t *gen_ul2ul(ul_resolve_t *uidx, ug_opt_t *uopt, ulg_opt_t *ulopt, uint32_t keep_raw_utg, uint64_t is_bridg)
{
    uint64_t k, m;
    ma_ug_t *ug = uidx->l1_ug; all_ul_t *uls = uidx->idx; 
    ul2ul_idx_t *z = &(uidx->uovl); ul_str_idx_t *str_idx = &(uidx->pstr);
    z->uln = uls->n; z->gn = ug->g->n_seq; 
    z->tot = uls->n + ug->g->n_seq; MALLOC(z->item_idx, z->tot);
    for (k = m = 0; k < z->tot; k++) {
        z->item_idx[k] = (uint32_t)-1;
        if(k < z->uln) {///is a ul read
            if(str_idx->str.a[k].cn > 1) {
                z->item_idx[k] = m; m++;
            }
        } else {//is a node in graph
            z->item_idx[k] = m; m++;
        }
    }
    CALLOC(z->a, m); z->n = z->m = m;

    kt_for(uidx->str_b.n_thread, worker_integer_postprecess, uidx, uls->n);
    gen_integer_normalize(uidx);

    chimeric_integer_deal(uidx);
    append_utg_es(uidx);


    kt_for(uidx->str_b.n_thread, worker_integert_debug_sym, uidx, z->tot);///all ul + ug
    print_integert_ovlp_stat(z);
    remove_integert_containment(uidx, keep_raw_utg);

    kt_for(uidx->str_b.n_thread, worker_integert_debug_sym, uidx, z->tot);///all ul + ug
    print_integert_ovlp_stat(z);
    // print_uls_seq(uidx, asm_opt.output_file_name);
    // print_uls_ovs(uidx, asm_opt.output_file_name);
    
    z->i_g = integer_sg_gen(uidx, uopt->min_ovlp);
    asg_arc_del_trans(z->i_g, uopt->gap_fuzz);

    z->i_ug = ma_ug_gen(z->i_g);
    // CALLOC(z->i_ug->g->seq_vis, z->i_ug->g->n_seq*2);
    renew_u2g_cov(uidx, uidx->uopt->te); 
    renew_u2g_bg(uidx);
    
    // output_integer_graph(uidx, z->i_ug, asm_opt.output_file_name);
    u2g_clean(uidx, ulopt, keep_raw_utg, is_bridg);
    // renew_ul2_utg(uidx);

    // output_integer_graph(uidx, z->i_ug, asm_opt.output_file_name, 0);
    return z;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, 0x10(%rsp)
movl %ecx, %ebp
movq %rdx, 0x8(%rsp)
movq %rsi, %r12
movq %rdi, %r15
movq 0x18(%rdi), %rax
movq 0x30(%rdi), %rcx
movq 0x50(%rcx), %rbx
movq %rbx, 0x208(%rdi)
movq 0x18(%rax), %rax
movl 0x14(%rax), %ecx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andq %rdx, %rcx
movq %rcx, 0x210(%rdi)
movl 0x14(%rax), %r13d
andq %rdx, %r13
addq %rbx, %r13
movq %r13, 0x218(%rdi)
leaq (,%r13,4), %rdi
callq 0x2280
movq %rax, 0x220(%r15)
pushq $0x18
popq %rcx
xorl %r14d, %r14d
xorl %edx, %edx
cmpq %rdx, %r13
je 0x1da294
orl $-0x1, (%rax,%rdx,4)
cmpq %rbx, %rdx
jae 0x1da284
movq 0x1d0(%r15), %rsi
testl $0x7ffffffe, (%rsi,%rcx) # imm = 0x7FFFFFFE
je 0x1da28b
movl %r14d, (%rax,%rdx,4)
incq %r14
incq %rdx
addq $0x20, %rcx
jmp 0x1da266
leaq 0x1f0(%r15), %r13
pushq $0x20
popq %rsi
movq %r14, %rdi
callq 0x2120
movq %rax, 0x1f0(%r15)
movq %r14, 0x200(%r15)
movq %r14, 0x1f8(%r15)
movl 0x1e0(%r15), %edi
leaq 0xe7(%rip), %rsi        # 0x1da3b0
movq %r15, %rdx
movq %rbx, %rcx
callq 0xc67c0
movq %r15, %rdi
callq 0x1bb732
movq %r15, %rdi
callq 0x1bbdbb
movq %r15, %rdi
callq 0x1bde3b
movl 0x1e0(%r15), %edi
movq 0x218(%r15), %rcx
leaq 0x12c(%rip), %rbx       # 0x1da42d
movq %rbx, %rsi
movq %r15, %rdx
callq 0xc67c0
movq %r13, %rdi
callq 0x1be04d
movq %r15, %rdi
movl %ebp, %esi
callq 0x1bdfb7
movl 0x1e0(%r15), %edi
movq 0x218(%r15), %rcx
movq %rbx, %rsi
movq %r15, %rdx
callq 0xc67c0
movq %r13, %rdi
callq 0x1be04d
movslq 0x44(%r12), %rsi
movq %r15, %rdi
callq 0x1be0ea
movq %rax, 0x228(%r15)
movl 0x50(%r12), %esi
movq %rax, %rdi
callq 0x701c4
movq 0x228(%r15), %rdi
callq 0x76d91
movq %rax, 0x230(%r15)
movq (%r15), %rax
movq 0x70(%rax), %rsi
movq %r15, %rdi
callq 0x1d91ce
movq %r15, %rdi
callq 0x1d96a2
movq %r15, %rdi
movq 0x8(%rsp), %rsi
movl %ebp, %edx
movq 0x10(%rsp), %rcx
callq 0x1d84fc
movq %r13, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq