// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Overlaps.cpp
// Function: break_ug_contig(ma_ug_t**, asg_t*, All_reads*, ma_sub_t*, ma_hit_t_alloc*, R_to_U*, kvec_asg_arc_t_warp*, int, int, int*, int*, double)
void break_ug_contig(ma_ug_t **ug, asg_t *read_g, All_reads *RNF, ma_sub_t *coverage_cut,
ma_hit_t_alloc* sources, R_to_U* ruIndex, kvec_asg_arc_t_warp* edge, int max_hang, int min_ovlp, 
int* b_low_cov, int* b_high_cov, double m_rate)
{
    if(b_low_cov)
    {
        fprintf(stderr, "[M::%s] break potential misassemblies with <%d-fold coverage\n", 
        __func__, *b_low_cov);
    }

    if(b_high_cov)
    {
        fprintf(stderr, "[M::%s] break potential misassemblies with >%d-fold coverage\n", 
        __func__, *b_high_cov);
    }

    kvec_t_u64_warp depth;
    kv_init(depth.a);
    kvec_t_u64_warp break_points;
    kv_init(break_points.a);
    kv_in_sub_t depth_i;
    kv_init(depth_i);
    uint32_t i;
    uint8_t* primary_flag = (uint8_t*)calloc(read_g->n_seq, sizeof(uint8_t));
    ma_utg_t *u = NULL;

    for (i = 0; i < (*ug)->u.n; ++i) 
    {
        u = &((*ug)->u.a[i]);
        if(u->m == 0) continue;
        if(u->n < 2) continue;
        // detect_break_point(u, i, read_g, RNF, coverage_cut, sources, ruIndex, edge, max_hang, min_ovlp, primary_flag, &depth, &break_points, b_low_cov);
        // debug_break_point(u, i, read_g, RNF, coverage_cut, sources, ruIndex, edge, max_hang, min_ovlp, primary_flag, &depth, &break_points, b_low_cov);
        detect_break_point_advance(u, i, read_g, RNF, coverage_cut, sources, ruIndex, edge, max_hang, min_ovlp,
        primary_flag, &depth, &depth_i, &break_points, b_low_cov, b_high_cov, m_rate);
        
    }

    break_all_contigs(ug, read_g, edge, &break_points);

    kv_destroy(depth.a);
    kv_destroy(break_points.a);
    kv_destroy(depth_i);
    free(primary_flag);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movsd %xmm0, 0x78(%rsp)
movq %r9, 0x70(%rsp)
movq %r8, 0x68(%rsp)
movq %rdx, 0x60(%rsp)
movq %rsi, %rbx
movq %rdi, %r15
movq 0x140(%rsp), %r12
movq 0x138(%rsp), %rbp
movq 0x120(%rsp), %rax
movq %rax, 0x58(%rsp)
testq %rbp, %rbp
jne 0x805d5
testq %r12, %r12
jne 0x805fc
xorps %xmm0, %xmm0
leaq 0xc0(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
leaq 0xa0(%rsp), %rax
andq $0x0, 0x10(%rax)
leaq 0x80(%rsp), %rcx
andq $0x0, 0x10(%rcx)
movaps %xmm0, (%rax)
movaps %xmm0, (%rcx)
movl 0x14(%rbx), %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
pushq $0x1
popq %rsi
callq 0x2120
movq %rax, %r13
xorl %r14d, %r14d
movl %r14d, %r14d
movq (%r15), %rax
cmpq %r14, (%rax)
jbe 0x8057e
movq 0x10(%rax), %rdi
imulq $0x28, %r14, %rax
cmpl $0x0, 0xc(%rdi,%rax)
je 0x80576
addq %rax, %rdi
cmpl $0x2, 0x10(%rdi)
jb 0x80576
movq %r12, 0x48(%rsp)
movq %rbp, 0x40(%rsp)
leaq 0xa0(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x80(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0xc0(%rsp), %rax
movq %rax, 0x28(%rsp)
movq %r13, 0x20(%rsp)
movq 0x70(%rsp), %rax
movq %rax, (%rsp)
movl %r14d, %esi
movq %rbx, %rdx
movq 0x60(%rsp), %rcx
movq 0x68(%rsp), %r9
movsd 0x78(%rsp), %xmm0
callq 0x7edba
incl %r14d
jmp 0x804f9
leaq 0xa0(%rsp), %r14
movq %r15, %rdi
movq %rbx, %rsi
movq 0x58(%rsp), %rdx
movq %r14, %rcx
callq 0x7fd38
movq 0xd0(%rsp), %rdi
callq 0x2220
movq 0x10(%r14), %rdi
callq 0x2220
movq 0x90(%rsp), %rdi
callq 0x2220
movq %r13, %rdi
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2220
movq 0x1d2a04(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
movl (%rbp), %ecx
leaq 0x16822b(%rip), %rsi    # 0x1e8814
leaq 0x168262(%rip), %rdx    # 0x1e8852
xorl %eax, %eax
callq 0x22b0
jmp 0x804a6
movq 0x1d29dd(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
movl (%r12), %ecx
leaq 0x168251(%rip), %rsi    # 0x1e8862
leaq 0x16823a(%rip), %rdx    # 0x1e8852
xorl %eax, %eax
callq 0x22b0
jmp 0x804af