// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]yahs/yahs.c
// Function: contig_error_break
int contig_error_break(char *agp, char *fai, char *link_file, uint32_t ml, char *out)
{
    uint32_t i, ec_round, err_no, bp_n;
    sdict_t *sdict;
    asm_dict_t *dict;
    int dist_thres;

    sdict = make_sdict_from_index(fai, ml);
    dict = agp? make_asm_dict_from_agp(sdict, agp, 1) : make_asm_dict_from_sdict(sdict);
    dist_thres = estimate_dist_thres_from_file(link_file, dict, ec_min_frac, ec_resolution, 0);
    dist_thres = MAX(dist_thres, ec_min_window);
    fprintf(stderr, "[I::%s] dist threshold for contig error break: %d\n", __func__, dist_thres);

    char* out1 = (char *) malloc(strlen(out) + 35);
    ec_round = err_no = 0;
    while (1) {
        if (ec_round) dict = make_asm_dict_from_agp(sdict, out1, 1);
        link_mat_t *link_mat = link_mat_from_file(link_file, dict, dist_thres, ec_bin, .0, ec_move_avg, 0);
#ifdef DEBUG_ERROR_BREAK
        fprintf(stderr, "[DEBUG_ERROR_BREAK::%s] ec_round %u link matrix\n", __func__, ec_round);
        print_link_mat(link_mat, dict, stderr);
#endif
        bp_n = 0;
        bp_t *breaks = detect_break_points(link_mat, ec_bin, ec_merge_thresh, ec_fold_thresh, ec_dual_break_thresh, &bp_n);
#ifdef DEBUG
        fprintf(stderr, "[DEBUG::%s] number contig breaks in round %u: %u\n", __func__, ec_round + 1, bp_n);
#endif
        sprintf(out1, "%s_%02d.agp", out, ++ec_round);
        FILE *agp_out = fopen(out1, "w");
        write_break_agp(dict, breaks, bp_n, agp_out);
        fclose(agp_out);
        
        link_mat_destroy(link_mat);
        asm_destroy(dict);
        for (i = 0; i < bp_n; ++i)
            free(breaks[i].p);
        free(breaks);
        
        err_no += bp_n;
#ifdef DEBUG_ERROR_BREAK
        fprintf(stderr, "[DEBUG_ERROR_BREAK::%s] bp_n %d\n", __func__, bp_n);
#endif
        if (!bp_n)
            break;
    }
    sd_destroy(sdict);
    free(out1);

    fprintf(stderr, "[I::%s] performed %u round assembly error correction. Made %u breaks \n", __func__, ec_round, err_no);

    return ec_round;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x17660
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x2c5cd
movq -0x40(%rbp), %rdi
movq -0x8(%rbp), %rsi
movl $0x1, %edx
callq 0x18560
movq %rax, -0x78(%rbp)
jmp 0x2c5da
movq -0x40(%rbp), %rdi
callq 0x17d00
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rsi
movsd 0xd616(%rip), %xmm0     # 0x39c08
movl 0xd618(%rip), %edx      # 0x39c10
xorl %ecx, %ecx
callq 0x46f0
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl 0xd609(%rip), %eax      # 0x39c14
jle 0x2c615
movl -0x4c(%rbp), %eax
movl %eax, -0x7c(%rbp)
jmp 0x2c61e
movl 0xd5f9(%rip), %eax      # 0x39c14
movl %eax, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq 0xc9cd(%rip), %rax      # 0x38ff8
movq (%rax), %rdi
movl -0x4c(%rbp), %ecx
leaq 0x69f1(%rip), %rsi      # 0x33029
leaq 0x6a1d(%rip), %rdx      # 0x3305c
movb $0x0, %al
callq 0x22c0
movq -0x28(%rbp), %rdi
callq 0x2160
movq %rax, %rdi
addq $0x23, %rdi
callq 0x2340
movq %rax, -0x58(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0x2c689
movq -0x40(%rbp), %rdi
movq -0x58(%rbp), %rsi
movl $0x1, %edx
callq 0x18560
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rsi
movl -0x4c(%rbp), %edx
movl 0xd57e(%rip), %ecx      # 0x39c18
movl 0xd723(%rip), %r8d      # 0x39dc4
xorps %xmm0, %xmm0
xorl %r9d, %r9d
callq 0x4aa0
movq %rax, -0x60(%rbp)
movl $0x0, -0x38(%rbp)
movq -0x60(%rbp), %rdi
movl 0xd557(%rip), %esi      # 0x39c18
movl 0xd555(%rip), %edx      # 0x39c1c
movsd 0xd551(%rip), %xmm0     # 0x39c20
movl 0xd553(%rip), %ecx      # 0x39c28
leaq -0x38(%rbp), %r8
callq 0x5700
movq %rax, -0x68(%rbp)
movq -0x58(%rbp), %rdi
movq -0x28(%rbp), %rdx
movl -0x30(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x30(%rbp)
leaq 0x6975(%rip), %rsi      # 0x3306f
movb $0x0, %al
callq 0x24b0
movq -0x58(%rbp), %rdi
leaq 0x4904(%rip), %rsi      # 0x31010
callq 0x23f0
movq %rax, -0x70(%rbp)
movq -0x48(%rbp), %rdi
movq -0x68(%rbp), %rsi
movl -0x38(%rbp), %edx
movq -0x70(%rbp), %rcx
callq 0x6380
movq -0x70(%rbp), %rdi
callq 0x2150
movq -0x60(%rbp), %rdi
callq 0x4680
movq -0x48(%rbp), %rdi
callq 0x16780
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x38(%rbp), %eax
jae 0x2c775
movq -0x68(%rbp), %rax
movl -0x2c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdi
callq 0x2050
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x2c74b
movq -0x68(%rbp), %rdi
callq 0x2050
movl -0x38(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x38(%rbp)
jne 0x2c78f
jmp 0x2c794
jmp 0x2c66d
movq -0x40(%rbp), %rdi
callq 0x16650
movq -0x58(%rbp), %rdi
callq 0x2050
movq 0xc84b(%rip), %rax      # 0x38ff8
movq (%rax), %rdi
movl -0x30(%rbp), %ecx
movl -0x34(%rbp), %r8d
leaq 0x68bd(%rip), %rsi      # 0x3307b
leaq 0x6897(%rip), %rdx      # 0x3305c
movb $0x0, %al
callq 0x22c0
movl -0x30(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)