// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Overlaps.cpp
// Function: print_utg(ma_ug_t**, asg_t*, ma_sub_t*, char*, ma_hit_t_alloc*, R_to_U*, int, int, kvec_asg_arc_t_warp*)
void print_utg(ma_ug_t **ug, asg_t *sg, ma_sub_t* coverage_cut, char* output_file_name, 
ma_hit_t_alloc* sources, R_to_U* ruIndex, int max_hang, int min_ovlp, kvec_asg_arc_t_warp* new_rtg_edges)
{
    if(asm_opt.b_low_cov > 0)
    {
        break_ug_contig(ug, sg, &R_INF, coverage_cut, sources, ruIndex, new_rtg_edges, max_hang, min_ovlp, 
        &asm_opt.b_low_cov, NULL, asm_opt.m_rate);
    }

    if(asm_opt.b_high_cov > 0)
    {
        break_ug_contig(ug, sg, &R_INF, coverage_cut, sources, ruIndex, new_rtg_edges, max_hang, min_ovlp, 
        NULL, &asm_opt.b_high_cov, asm_opt.m_rate);
    }

    ma_ug_seq(*ug, sg, coverage_cut, sources, new_rtg_edges, max_hang, min_ovlp, 0, 1);

    
    char* gfa_name = (char*)malloc(strlen(output_file_name)+35);
    sprintf(gfa_name, "%s.p_ctg.gfa", output_file_name);
    fprintf(stderr, "Writing %s to disk... \n", gfa_name);
    FILE* output_file = fopen(gfa_name, "w");
    ma_ug_print(*ug, sg, coverage_cut, sources, ruIndex, "ptg", output_file);
    fclose(output_file);

    sprintf(gfa_name, "%s.p_ctg.noseq.gfa", output_file_name);
    output_file = fopen(gfa_name, "w");
    ma_ug_print_simple(*ug, sg, coverage_cut, sources, ruIndex, "ptg", output_file);
    fclose(output_file);
    if(asm_opt.bed_inconsist_rate != 0)
    {
        sprintf(gfa_name, "%s.p_ctg.lowQ.bed", output_file_name);
        output_file = fopen(gfa_name, "w");
        ma_ug_print_bed(*ug, sg, &R_INF, coverage_cut, sources, new_rtg_edges, 
        max_hang, min_ovlp, asm_opt.bed_inconsist_rate, "ptg", output_file, NULL);
        fclose(output_file);
    }
    free(gfa_name);

    /*******************************for debug************************************/
    // uint32_t i;
    // for (i = 0; i < sg->n_seq; i++)
    // {
    //     if(R_INF.trio_flag[i] == FATHER || R_INF.trio_flag[i] == MOTHER) fprintf(stderr, "ERROR\n");
    // }
    /*******************************for debug************************************/
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, (%rsp)
movq %r8, %r12
movq %rcx, %rbx
movq %rdx, 0x8(%rsp)
movq %rsi, %rbp
movq %rdi, %r13
movq 0x90(%rsp), %r8
movl 0x88(%rsp), %r15d
movl 0x80(%rsp), %eax
movq %rax, 0x10(%rsp)
leaq 0x1cf922(%rip), %rax    # 0x253758
cmpl $0x0, 0xd8(%rax)
jle 0x83e91
leaq 0x1cf912(%rip), %rax    # 0x253758
movsd 0xe0(%rax), %xmm0
subq $0x30, %rsp
addq $0xd8, %rax
movq %rax, 0x18(%rsp)
andq $0x0, 0x20(%rsp)
movq %r8, (%rsp)
leaq 0x1d03c2(%rip), %rdx    # 0x254230
movq %r13, %rdi
movq %rbp, %rsi
movq %rbx, %r14
movq %r8, %rbx
movq %r12, %r8
movq 0x30(%rsp), %r9
callq 0x80454
movq %rbx, %r8
movq %r14, %rbx
addq $0x30, %rsp
leaq 0x1cf8c0(%rip), %rax    # 0x253758
cmpl $0x0, 0xdc(%rax)
jle 0x83ef3
leaq 0x1cf8b0(%rip), %rax    # 0x253758
movsd 0xe0(%rax), %xmm0
subq $0x30, %rsp
addq $0xdc, %rax
movq %rax, 0x20(%rsp)
andq $0x0, 0x18(%rsp)
movq %r8, (%rsp)
leaq 0x1d0360(%rip), %rdx    # 0x254230
movq %r13, %rdi
movq %rbp, %rsi
movq %rbx, %r14
movq %r8, %rbx
movq %r12, %r8
movq 0x30(%rsp), %r9
callq 0x80454
movq %rbx, %r8
movq %r14, %rbx
addq $0x30, %rsp
movq %r12, 0x18(%rsp)
movq (%r13), %rdi
subq $0x8, %rsp
movq %rbp, %rsi
movq 0x10(%rsp), %rdx
movq %r12, %rcx
movq %r8, 0x48(%rsp)
movq 0x18(%rsp), %r9
pushq $0x1
pushq $0x0
pushq %r15
callq 0x7b888
addq $0x20, %rsp
movq %rbx, %rdi
callq 0x2090
leaq 0x23(%rax), %rdi
callq 0x2280
movq %r15, 0x38(%rsp)
movq %rax, %r15
leaq 0x1656e9(%rip), %rsi    # 0x1e962d
movq %rax, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2050
movq 0x1cf088(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
leaq 0x164a11(%rip), %rsi    # 0x1e8973
movq %r15, %rdx
xorl %eax, %eax
callq 0x22b0
leaq 0x17672e(%rip), %rsi    # 0x1fa6a1
movq %r15, %rdi
callq 0x2210
movq %rbx, %r12
movq %rax, %rbx
movq (%r13), %rdi
subq $0x8, %rsp
leaq 0x1649fb(%rip), %r9     # 0x1e898b
movq %rbp, %rsi
movq 0x10(%rsp), %rdx
movq 0x20(%rsp), %r14
movq %r14, %rcx
movq 0x8(%rsp), %r8
pushq %rax
callq 0x7cd23
popq %rax
popq %rcx
movq %rbx, %rdi
callq 0x2190
leaq 0x165695(%rip), %rsi    # 0x1e9651
movq %r15, %rdi
movq %r12, 0x20(%rsp)
movq %r12, %rdx
xorl %eax, %eax
callq 0x2050
movq %r15, %rdi
leaq 0x1766c9(%rip), %rsi    # 0x1fa6a1
movq 0x8(%rsp), %r12
callq 0x2210
movq %rax, %rbx
movq %r13, 0x28(%rsp)
movq (%r13), %rdi
subq $0x8, %rsp
movq %rbp, 0x38(%rsp)
movq %rbp, %rsi
movq %r12, %rdx
movq %r14, %rcx
leaq 0x164984(%rip), %r14    # 0x1e898b
movq 0x8(%rsp), %r8
movq %r14, %r9
pushq %rax
callq 0x7de8f
popq %rax
popq %rcx
movq %rbx, %rdi
callq 0x2190
leaq 0x1cf732(%rip), %rax    # 0x253758
cmpl $0x0, 0x150(%rax)
je 0x840a4
leaq 0x165631(%rip), %rsi    # 0x1e9667
movq %r15, %rdi
movq 0x20(%rsp), %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x176655(%rip), %rsi    # 0x1fa6a1
movq %r15, %rdi
callq 0x2210
movq %rax, %rbx
movq 0x28(%rsp), %rax
movq (%rax), %rdi
leaq 0x1cf6f2(%rip), %rax    # 0x253758
movl 0x150(%rax), %eax
leaq 0x1d01bd(%rip), %rdx    # 0x254230
movq 0x30(%rsp), %rsi
movq %r12, %rcx
movq 0x18(%rsp), %r8
movq 0x40(%rsp), %r9
pushq $0x0
pushq %rbx
pushq %r14
pushq %rax
pushq 0x58(%rsp)
pushq 0x38(%rsp)
callq 0x7debc
addq $0x30, %rsp
movq %rbx, %rdi
callq 0x2190
movq %r15, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2220