// File: 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
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x78, %rsp
movq 0x20(%rbp), %rax
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x20(%rbp)
movq %rsi, -0x28(%rbp)
movq %rdx, -0x30(%rbp)
movq %rcx, -0x38(%rbp)
movq %r8, -0x40(%rbp)
movq %r9, -0x48(%rbp)
leaq 0x2c7a52(%rip), %rax    # 0x3c47f8
cmpl $0x0, 0xd8(%rax)
jle 0xfce16
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rcx
movq -0x40(%rbp), %r8
movq -0x48(%rbp), %r9
movq 0x20(%rbp), %rbx
movl 0x10(%rbp), %r11d
movl 0x18(%rbp), %r10d
leaq 0x2c7a22(%rip), %rax    # 0x3c47f8
movsd 0xe0(%rax), %xmm0
leaq 0x2c84eb(%rip), %rdx    # 0x3c52d0
leaq 0x2c7a0c(%rip), %rax    # 0x3c47f8
addq $0xd8, %rax
xorl %r14d, %r14d
movq %rbx, (%rsp)
movl %r11d, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
callq 0xf6220
leaq 0x2c79db(%rip), %rax    # 0x3c47f8
cmpl $0x0, 0xdc(%rax)
jle 0xfce8c
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rcx
movq -0x40(%rbp), %r8
movq -0x48(%rbp), %r9
movq 0x20(%rbp), %rbx
movl 0x10(%rbp), %r11d
movl 0x18(%rbp), %r10d
leaq 0x2c79ab(%rip), %rax    # 0x3c47f8
movsd 0xe0(%rax), %xmm0
leaq 0x2c8474(%rip), %rdx    # 0x3c52d0
xorl %eax, %eax
leaq 0x2c7993(%rip), %rax    # 0x3c47f8
addq $0xdc, %rax
movq %rbx, (%rsp)
movl %r11d, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0xf6220
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x40(%rbp), %rcx
movq 0x20(%rbp), %r8
movl 0x10(%rbp), %r9d
movl 0x18(%rbp), %eax
xorl %r10d, %r10d
movl %eax, (%rsp)
movq $0x0, 0x8(%rsp)
movl $0x1, 0x10(%rsp)
callq 0xed140
movq -0x38(%rbp), %rdi
callq 0x20a0
movq %rax, %rdi
addq $0x23, %rdi
callq 0x2270
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
movq -0x38(%rbp), %rdx
leaq 0x28b42a(%rip), %rsi    # 0x388318
movb $0x0, %al
callq 0x2050
movq 0x2c70e4(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movq -0x50(%rbp), %rdx
leaq 0x28a597(%rip), %rsi    # 0x3874a1
movb $0x0, %al
callq 0x22a0
movq -0x50(%rbp), %rdi
leaq 0x29c4b6(%rip), %rsi    # 0x3993d2
callq 0x2200
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x40(%rbp), %rcx
movq -0x48(%rbp), %r8
movq -0x58(%rbp), %rax
leaq 0x28a572(%rip), %r9     # 0x3874b9
movq %rax, (%rsp)
callq 0xefa60
movq -0x58(%rbp), %rdi
callq 0x21a0
movq -0x50(%rbp), %rdi
movq -0x38(%rbp), %rdx
leaq 0x28b3d4(%rip), %rsi    # 0x38833c
movb $0x0, %al
callq 0x2050
movq -0x50(%rbp), %rdi
leaq 0x29c458(%rip), %rsi    # 0x3993d2
callq 0x2200
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x40(%rbp), %rcx
movq -0x48(%rbp), %r8
movq -0x58(%rbp), %rax
leaq 0x28a514(%rip), %r9     # 0x3874b9
movq %rax, (%rsp)
callq 0xf1c10
movq -0x58(%rbp), %rdi
callq 0x21a0
leaq 0x2c783a(%rip), %rax    # 0x3c47f8
cmpl $0x0, 0x150(%rax)
je 0xfd064
movq -0x50(%rbp), %rdi
movq -0x38(%rbp), %rdx
leaq 0x28b378(%rip), %rsi    # 0x388352
movb $0x0, %al
callq 0x2050
movq -0x50(%rbp), %rdi
leaq 0x29c3e6(%rip), %rsi    # 0x3993d2
callq 0x2200
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rcx
movq -0x40(%rbp), %r8
movq 0x20(%rbp), %r9
movl 0x10(%rbp), %r14d
movl 0x18(%rbp), %ebx
leaq 0x2c77de(%rip), %rax    # 0x3c47f8
movl 0x150(%rax), %r11d
movq -0x58(%rbp), %rax
leaq 0x2c82a4(%rip), %rdx    # 0x3c52d0
leaq 0x28a486(%rip), %r10    # 0x3874b9
xorl %r15d, %r15d
movl %r14d, (%rsp)
movl %ebx, 0x8(%rsp)
movl %r11d, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
callq 0xf1c80
movq -0x58(%rbp), %rdi
callq 0x21a0
movq -0x50(%rbp), %rdi
callq 0x2210
addq $0x78, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax,%rax)