// File: /workspace/github_c_makefile_star2_O2/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:
cmpl $0x0, 0x10(%r8)
js 0xf0b6
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %r9, %rbx
movq %r8, %r14
movq %rcx, %r15
movq %rdx, %r13
movq %rdi, %r12
testq %r9, %r9
je 0xf0b9
movaps 0xb635(%rip), %xmm0     # 0x1a6d0
movups %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
andq $0x0, 0x28(%rbx)
andq $0x0, 0x40(%rbx)
andq $0x0, 0x58(%rbx)
xorl %ecx, %ecx
jmp 0xf0c1
xorl %eax, %eax
retq
movq 0x40, %rcx
cmpq 0x48(%rbx), %rcx
jne 0xf0f0
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
pushq $0x2
popq %rsi
cmovneq %rax, %rsi
movq %rsi, 0x48(%rbx)
movq 0x50(%rbx), %rdi
shlq $0x3, %rsi
callq 0x2350
movq %rax, 0x50(%rbx)
movq 0x40(%rbx), %rcx
jmp 0xf0f4
movq 0x50(%rbx), %rax
leaq 0x1(%rcx), %rdx
movq %rdx, 0x40(%rbx)
movq %r13, (%rax,%rcx,8)
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0xf11d
movl (%rbx), %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq