// File: /workspace/github_cpp_makefile_star2_O1/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), %r13
movq 0x138(%rsp), %r14
movq 0x120(%rsp), %rax
movq %rax, 0x58(%rsp)
testq %r14, %r14
jne 0xba9a0
testq %r13, %r13
jne 0xba9ad
xorps %xmm0, %xmm0
movaps %xmm0, 0xc0(%rsp)
xorl %ebp, %ebp
movq %rbp, 0xd0(%rsp)
movq %rbp, 0xb0(%rsp)
movaps %xmm0, 0xa0(%rsp)
movq %rbp, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movl 0x14(%rbx), %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movl $0x1, %esi
callq 0x2120
movq %rax, %r12
movq (%r15), %rax
cmpq %rbp, (%rax)
je 0xba949
movl $0x1, %ebp
xorl %ecx, %ecx
movq 0x10(%rax), %rax
leaq (%rcx,%rcx,4), %rcx
cmpl $0x0, 0xc(%rax,%rcx,8)
je 0xba93d
leaq (%rax,%rcx,8), %rdi
cmpl $0x2, 0x10(%rdi)
jb 0xba93d
leal -0x1(%rbp), %esi
movq %r13, 0x48(%rsp)
movq %r14, 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 %r12, 0x20(%rsp)
movq 0x70(%rsp), %rax
movq %rax, (%rsp)
movq %rbx, %rdx
movq 0x60(%rsp), %rcx
movq 0x68(%rsp), %r9
movsd 0x78(%rsp), %xmm0
callq 0xb905c
movl %ebp, %ecx
movq (%r15), %rax
incl %ebp
cmpq %rcx, (%rax)
ja 0xba8ca
leaq 0xa0(%rsp), %r14
movq %r15, %rdi
movq %rbx, %rsi
movq 0x58(%rsp), %rdx
movq %r14, %rcx
callq 0xba0fc
movq 0xd0(%rsp), %rdi
callq 0x2220
movq 0x10(%r14), %rdi
callq 0x2220
movq 0x90(%rsp), %rdi
callq 0x2220
movq %r12, %rdi
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2220
movq %r14, %rdi
callq 0x105ee
jmp 0xba863
movq %r13, %rdi
callq 0x10612
jmp 0xba86c