// File: /workspace/github_cpp_makefile_star2_O3/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, %r13
movq %rcx, %r12
movq %rdx, 0x20(%rsp)
movq 0x90(%rsp), %r15
movl 0x88(%rsp), %r14d
movl 0x80(%rsp), %eax
movq %rax, 0x8(%rsp)
leaq 0x28d7d4(%rip), %rax    # 0x295758
cmpl $0x0, 0xd8(%rax)
jle 0x7fdf
movsd 0xe0(%rax), %xmm0
subq $0x30, %rsp
addq $0xd8, %rax
movq %rax, 0x18(%rsp)
andq $0x0, 0x20(%rsp)
movq %r15, (%rsp)
leaq 0x28e27b(%rip), %rdx    # 0x296230
movq %r12, %rbx
movq %rdi, %r12
movq %rsi, %rbp
movq %r13, %r8
movq 0x30(%rsp), %r9
callq 0xbb86f
movq %r12, %rdi
movq %rbx, %r12
leaq 0x28d780(%rip), %rax    # 0x295758
movq %rbp, %rsi
addq $0x30, %rsp
cmpl $0x0, 0xdc(%rax)
jle 0x803a
leaq 0x28d769(%rip), %rax    # 0x295758
movsd 0xe0(%rax), %xmm0
subq $0x30, %rsp
addq $0xdc, %rax
movq %rax, 0x20(%rsp)
andq $0x0, 0x18(%rsp)
movq %r15, (%rsp)
leaq 0x28e219(%rip), %rdx    # 0x296230
movq %r12, %rbx
movq %rdi, %r12
movq %rsi, %rbp
movq %r13, %r8
movq 0x30(%rsp), %r9
callq 0xbb86f
movq %r12, %rdi
movq %rbx, %r12
movq %rbp, %rsi
addq $0x30, %rsp
movq %r13, %rbp
movq %rdi, %rax
movq (%rdi), %rdi
movq %rax, %r13
movq %rax, 0x10(%rsp)
subq $0x8, %rsp
pushq $0x1
popq %rax
movq %rsi, 0x20(%rsp)
movq %r15, 0x38(%rsp)
movq 0x28(%rsp), %rdx
movq %rbp, %rcx
movq %r15, %r8
movq 0x10(%rsp), %r9
pushq %rax
pushq $0x0
pushq %r14
callq 0xb67c4
addq $0x20, %rsp
movq %r12, %rdi
callq 0x2090
leaq 0x23(%rax), %rdi
callq 0x2280
movq %r14, 0x38(%rsp)
movq %rax, %r15
leaq 0x22f693(%rip), %rsi    # 0x23772d
movq %rax, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2050
movq 0x28cf32(%rip), %rax    # 0x294fe0
movq (%rax), %rdi
leaq 0x22e9bb(%rip), %rsi    # 0x236a73
movq %r15, %rdx
xorl %eax, %eax
callq 0x22b0
leaq 0x240619(%rip), %rsi    # 0x2486e2
movq %r15, %rdi
callq 0x2210
movq %rbp, %r8
movq %rbp, 0x40(%rsp)
movq 0x20(%rsp), %r14
movq %r12, %rbp
movq %rax, %r12
movq (%r13), %rdi
subq $0x8, %rsp
leaq 0x22e998(%rip), %rax    # 0x236a8b
leaq 0x28e136(%rip), %rsi    # 0x296230
movq 0x20(%rsp), %r13
movq %r13, %rdx
movq %r14, %rcx
movq 0x8(%rsp), %rbx
movq %rbx, %r9
pushq %r12
pushq %rax
pushq $0x1
popq %rax
pushq %rax
callq 0xb7823
addq $0x20, %rsp
movq %r12, %rdi
callq 0x2190
leaq 0x22f625(%rip), %rsi    # 0x237751
movq %r15, %rdi
movq %rbp, 0x28(%rsp)
movq %rbp, %rdx
xorl %eax, %eax
callq 0x2050
movq %r15, %rdi
leaq 0x24059a(%rip), %rsi    # 0x2486e2
callq 0x2210
movq %rax, %r12
movq 0x10(%rsp), %rax
movq (%rax), %rdi
leaq 0x22e92c(%rip), %rax    # 0x236a8b
subq $0x8, %rsp
leaq 0x28e0c6(%rip), %rsi    # 0x296230
movq %r13, %rdx
movq 0x48(%rsp), %rbp
movq %r14, %rcx
movq %rbp, %r8
movq %rbx, %r9
pushq %r12
movq %rax, %r13
pushq %rax
pushq $0x0
callq 0xb7823
addq $0x20, %rsp
movq %r12, %rdi
callq 0x2190
leaq 0x28d5bd(%rip), %r12    # 0x295758
cmpl $0x0, 0x150(%r12)
je 0x8214
leaq 0x22f5ba(%rip), %rsi    # 0x237767
movq %r15, %rdi
movq 0x28(%rsp), %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x24051f(%rip), %rsi    # 0x2486e2
movq %r15, %rdi
callq 0x2210
movq %rax, %rbx
movq 0x10(%rsp), %rax
movq (%rax), %rdi
movl 0x150(%r12), %eax
leaq 0x28e04b(%rip), %rdx    # 0x296230
movq 0x18(%rsp), %rsi
movq %r14, %rcx
movq %rbp, %r8
movq 0x30(%rsp), %r9
pushq $0x0
pushq %rbx
pushq %r13
pushq %rax
pushq 0x58(%rsp)
pushq 0x30(%rsp)
callq 0xb8f0d
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