// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]oatk/syncerr.c
// Function: error_correction_by_graph_path_search
int error_correction_by_graph_path_search(asmg_t *asmg, syncmer_t *scms, uint64_t source, uint64_t sink, wf_config_t *conf, dfs_info_t *dfs_info) {
    
    if (conf->tl < 0) return 0;
    
    dfs_info_reset(dfs_info);
    kv_push(uint64_t, dfs_info->c_path, source);
    dfs_search(asmg, scms, dfs_info, sink, conf);

#ifdef DEBUG_SYNCMER_CORRECTION
    if (dfs_info->n_path >= MAX_DFS_PATH)
        fprintf(stderr, "[DEBUG_SYNCMER_CORRECTION::WARN::%s] exceeds DFS path limit %d - error correction might not be accurate\n",
                __func__, MAX_DFS_PATH);

    // print debug information even when error correction failed
    fprintf(stderr, "[DEBUG_SYNCMER_CORRECTION::%s] ERROR CORRECTION RESULT - %s; N_PATH: %d; EDIST: %d [%.6f]; S_EDIST: %d [%.6f]\n",
            __func__, EC_STATUS[dfs_info->status], dfs_info->n_path, dfs_info->edist, 
            (double) dfs_info->edist/conf->tl, dfs_info->s_edist, (double) dfs_info->s_edist/conf->tl);
    fprintf(stderr, "[DEBUG_SYNCMER_CORRECTION::%s] ERROR CORRECTION RESULT - OPT PATH:", __func__);
    size_t i;
    for (i = 0; i < dfs_info->opt_path.n; ++i) fprintf(stderr, " u%lu%c", dfs_info->opt_path.a[i]>>1, "+-"[dfs_info->opt_path.a[i]&1]);
    fputc('\n', stderr);
#ifdef DEBUG_TRACE_ED_ALIGNMENT
    if (dfs_info->opt_seq.l > 0) {
        int score = 0, t_end = 0, q_end = 0, n_cigar = 0;
        // keep in mind that when error correction failed the bandwidth parameter does not apply
        uint32_t *cigar = wf_ed(conf->tl, conf->ts, dfs_info->opt_seq.l, dfs_info->opt_seq.s, 1, dfs_info->status? conf->bw : -1, &score, &t_end, &q_end, &n_cigar);
        fprintf(stderr, "[DEBUG_SYNCMER_CORRECTION::%s] ERROR CORRECTION RESULT - ", __func__);
        wf_print_cigar(cigar, n_cigar, stderr);
        fprintf(stderr, "[DEBUG_SYNCMER_CORRECTION::%s] ED_ALIGNMENT: ED=%d BW=%d tL=%d t_EN=%d qL=%d q_EN=%d\n",
                __func__, score, dfs_info->status? conf->bw : -1, conf->tl, t_end, (int) dfs_info->opt_seq.l, q_end);
        wf_print_alignment(conf->ts, conf->tl, dfs_info->opt_seq.s, dfs_info->opt_seq.l, cigar, n_cigar, 0, stderr);
        free(cigar);
    }
#else
    fprintf(stderr, "[DEBUG_SYNCMER_CORRECTION::%s] ERROR CORRECTION RESULT - ORIGINAL  SEQ: %.*s\n",
            __func__, conf->tl, conf->ts);
    fprintf(stderr, "[DEBUG_SYNCMER_CORRECTION::%s] ERROR CORRECTION RESULT - CORRECTED SEQ: %.*s\n",
            __func__, (int) dfs_info->opt_seq.l, dfs_info->opt_seq.s);
#endif
#endif

    return dfs_info->status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jge 0x1a3b6
movl $0x0, -0x4(%rbp)
jmp 0x1a46d
movq -0x38(%rbp), %rdi
callq 0x1a480
movq -0x38(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x38(%rbp), %rcx
cmpq 0x48(%rcx), %rax
jne 0x1a428
movq -0x38(%rbp), %rax
cmpq $0x0, 0x48(%rax)
je 0x1a3ed
movq -0x38(%rbp), %rax
movq 0x48(%rax), %rax
shlq %rax
movq %rax, -0x40(%rbp)
jmp 0x1a3f8
movl $0x2, %eax
movq %rax, -0x40(%rbp)
jmp 0x1a3f8
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x38(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x38(%rbp), %rax
movq 0x48(%rax), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x20(%rbp), %rdx
movq -0x38(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x38(%rbp), %rsi
movq 0x40(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x40(%rsi)
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x1a4f0
movq -0x38(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)