// File: /workspace/github_cpp_makefile_star2_O1/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 0x2828a6(%rip), %rax    # 0x28a758
cmpl $0x0, 0xd8(%rax)
jle 0x7f0d
movsd 0xe0(%rax), %xmm0
subq $0x30, %rsp
addq $0xd8, %rax
movq %rax, 0x18(%rsp)
andq $0x0, 0x20(%rsp)
movq %r15, (%rsp)
leaq 0x28334d(%rip), %rdx    # 0x28b230
movq %r12, %rbx
movq %rdi, %r12
movq %rsi, %rbp
movq %r13, %r8
movq 0x30(%rsp), %r9
callq 0xba811
movq %r12, %rdi
movq %rbx, %r12
leaq 0x282852(%rip), %rax    # 0x28a758
movq %rbp, %rsi
addq $0x30, %rsp
cmpl $0x0, 0xdc(%rax)
jle 0x7f68
leaq 0x28283b(%rip), %rax    # 0x28a758
movsd 0xe0(%rax), %xmm0
subq $0x30, %rsp
addq $0xdc, %rax
movq %rax, 0x20(%rsp)
andq $0x0, 0x18(%rsp)
movq %r15, (%rsp)
leaq 0x2832eb(%rip), %rdx    # 0x28b230
movq %r12, %rbx
movq %rdi, %r12
movq %rsi, %rbp
movq %r13, %r8
movq 0x30(%rsp), %r9
callq 0xba811
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 0xb5778
addq $0x20, %rsp
movq %r12, %rdi
callq 0x2090
leaq 0x23(%rax), %rdi
callq 0x2280
movq %r14, 0x38(%rsp)
movq %rax, %r15
leaq 0x223575(%rip), %rsi    # 0x22b53d
movq %rax, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2050
movq 0x282004(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
leaq 0x22289d(%rip), %rsi    # 0x22a883
movq %r15, %rdx
xorl %eax, %eax
callq 0x22b0
leaq 0x234407(%rip), %rsi    # 0x23c3fe
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 0x22287a(%rip), %rax    # 0x22a89b
leaq 0x283208(%rip), %rsi    # 0x28b230
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 0xb688e
addq $0x20, %rsp
movq %r12, %rdi
callq 0x2190
leaq 0x223507(%rip), %rsi    # 0x22b561
movq %r15, %rdi
movq %rbp, 0x28(%rsp)
movq %rbp, %rdx
xorl %eax, %eax
callq 0x2050
movq %r15, %rdi
leaq 0x234388(%rip), %rsi    # 0x23c3fe
callq 0x2210
movq %rax, %r12
movq 0x10(%rsp), %rax
movq (%rax), %rdi
leaq 0x22280e(%rip), %rax    # 0x22a89b
subq $0x8, %rsp
leaq 0x283198(%rip), %rsi    # 0x28b230
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 0xb688e
addq $0x20, %rsp
movq %r12, %rdi
callq 0x2190
leaq 0x28268f(%rip), %r12    # 0x28a758
cmpl $0x0, 0x150(%r12)
je 0x8142
leaq 0x22349c(%rip), %rsi    # 0x22b577
movq %r15, %rdi
movq 0x28(%rsp), %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x23430d(%rip), %rsi    # 0x23c3fe
movq %r15, %rdi
callq 0x2210
movq %rax, %rbx
movq 0x10(%rsp), %rax
movq (%rax), %rdi
movl 0x150(%r12), %eax
leaq 0x28311d(%rip), %rdx    # 0x28b230
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 0xb7f72
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