// File: /workspace/github_c_makefile_star2_O1/c-zhou[P]oatk/path_finder.c
// Function: pathfinder
int pathfinder(char *asg_file, char *mito_annot, char *pltd_annot, int min_len, int ext_p, int ext_m, 
        int max_copy, int max_path, double max_eval, double min_score, double min_cf, double seq_cf,
        int no_trn, int no_rrn, int do_graph_clean, int bubble_size, int tip_size, double weak_cross,
        int out_opt, char *out_pref, int VERBOSE)
{
    asg_t *asg;
    hmm_annot_db_t *annot_db;
    og_component_v *og_components;
    int ret = 0;

    asg = 0;
    annot_db = 0;
    og_components = 0;

    asg = asg_read(asg_file);
    if (asg == 0) {
        fprintf(stderr, "[E::%s] failed to read the graph: %s\n", __func__, asg_file);
        ret = 1;
        goto do_clean;
    }
    
    if (VERBOSE > 1) {
        if (VERBOSE > 2) {
            fprintf(stderr, "[M::%s] graph loaded\n", __func__);
            asg_print(asg, stderr, 1);
        }
        fprintf(stderr, "[M::%s] graph stats\n", __func__);
        asg_stat(asg, stderr);
    }

    if (mito_annot) annot_db = hmm_annot_read(mito_annot, annot_db, OG_MITO);
    if (pltd_annot) annot_db = hmm_annot_read(pltd_annot, annot_db, OG_PLTD);
    
    if (VERBOSE > 2) hmm_annot_db_print(annot_db, stderr);

    // this is not necessary
    // if (do_graph_clean && min_cf > .0) clean_graph_by_sequence_coverage(asg, min_cf, max_copy, VERBOSE);
    og_components = asg_annotation(annot_db, asg, no_trn, no_rrn, max_eval, 0, min_len, min_score, 1, VERBOSE);
    // og_components = annot_subgraph_og_type(annot_db, asg, no_trn, no_rrn, max_eval, 0, min_len, min_score, 1, VERBOSE);
    if (!og_components) {
        fprintf(stderr, "[E::%s] no organelle component found\n", __func__);
        ret = 1;
        goto do_clean;
    }

    if (VERBOSE > 1) print_og_classification_summary(asg, annot_db, og_components, stderr);

    // graph will be changed with extra copies of sequences added
    if (mito_annot)
        parse_organelle_component(asg, annot_db, og_components, min_len, max_copy, max_path, ext_m, seq_cf, do_graph_clean, 
                min_cf, min_score, max_eval, bubble_size, tip_size, weak_cross, out_pref, out_opt, OG_MITO, VERBOSE);
    if (pltd_annot)
        parse_organelle_component(asg, annot_db, og_components, min_len, max_copy, max_path, ext_p, seq_cf, do_graph_clean, 
                min_cf, min_score, max_eval, bubble_size, tip_size, weak_cross, out_pref, out_opt, OG_PLTD, VERBOSE);

do_clean:
    asg_destroy(asg);
    hmm_annot_db_destroy(annot_db);
    og_component_v_destroy(og_components);

    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movsd %xmm4, 0x30(%rsp)
movsd %xmm3, 0x20(%rsp)
movsd %xmm2, 0x28(%rsp)
movsd %xmm1, 0x10(%rsp)
movsd %xmm0, 0x18(%rsp)
movq %r9, 0x40(%rsp)
movl %r8d, %ebp
movl %ecx, 0xc(%rsp)
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %r13
callq 0x237d8
movq %rax, %rbx
testq %rax, %rax
je 0x8cf1
movl 0xc8(%rsp), %eax
cmpl $0x2, %eax
jge 0x8d18
testq %r14, %r14
je 0x8b13
movq %r14, %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0xb164
movq %rax, %r15
jmp 0x8b16
xorl %r15d, %r15d
testq %r12, %r12
movq %rbp, 0x38(%rsp)
je 0x8b33
movq %r12, %rdi
movq %r15, %rsi
movl $0x2, %edx
callq 0xb164
movq %rax, %r15
movl 0x98(%rsp), %r13d
movl 0x90(%rsp), %ebp
movl 0xc8(%rsp), %eax
cmpl $0x3, %eax
jl 0x8b60
movq 0x354a3(%rip), %rax     # 0x3dff8
movq (%rax), %rsi
movq %r15, %rdi
callq 0xbd62
cvttsd2si 0x10(%rsp), %eax
subq $0x8, %rsp
movq %r15, %rdi
movq %rbx, %rsi
movl %ebp, %edx
movl %r13d, %ecx
movsd 0x20(%rsp), %xmm0
xorl %r8d, %r8d
movl 0x14(%rsp), %r9d
movl 0xd0(%rsp), %ebp
pushq %rbp
pushq $0x1
pushq %rax
callq 0x264b2
addq $0x20, %rsp
testq %rax, %rax
je 0x8d51
movq %rax, %r13
cmpl $0x2, %ebp
jl 0x8bc0
movq 0x35449(%rip), %rax     # 0x3dff8
movq (%rax), %rcx
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x28693
movl 0xb8(%rsp), %eax
movl 0xb0(%rsp), %ebp
movl 0xa8(%rsp), %r11d
movl 0xa0(%rsp), %r10d
movl 0x88(%rsp), %r9d
movl 0x80(%rsp), %r8d
testq %r14, %r14
je 0x8c69
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
movl 0xc(%rsp), %ecx
movsd 0x20(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
movsd 0x10(%rsp), %xmm2
movsd 0x18(%rsp), %xmm3
movsd 0x30(%rsp), %xmm4
movq %rax, %r14
movl 0xc8(%rsp), %eax
pushq %rax
pushq $0x1
pushq %r14
pushq 0xd8(%rsp)
pushq %rbp
pushq %r11
pushq %r10
pushq 0x78(%rsp)
movq %r10, %r14
movq %r11, %rbp
callq 0x8d64
movl 0xc0(%rsp), %r8d
movl 0xc8(%rsp), %r9d
movq %rbp, %r11
movl 0xf0(%rsp), %ebp
movq %r14, %r10
addq $0x40, %rsp
xorl %r14d, %r14d
testq %r12, %r12
je 0x8cc7
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
movl 0xc(%rsp), %ecx
movsd 0x20(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
movsd 0x10(%rsp), %xmm2
movsd 0x18(%rsp), %xmm3
movsd 0x30(%rsp), %xmm4
movl 0xc8(%rsp), %eax
pushq %rax
pushq $0x2
movl 0xc8(%rsp), %eax
pushq %rax
pushq 0xd8(%rsp)
pushq %rbp
pushq %r11
pushq %r10
pushq 0x70(%rsp)
callq 0x8d64
addq $0x40, %rsp
movq %rbx, %rdi
callq 0x228a6
movq %r15, %rdi
callq 0xb028
movq %r13, %rdi
callq 0x248e0
movl %r14d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x35300(%rip), %rax     # 0x3dff8
movq (%rax), %rdi
leaq 0x2a8ae(%rip), %rsi     # 0x335b0
leaq 0x2a935(%rip), %rdx     # 0x3363e
xorl %r15d, %r15d
movq %r13, %rcx
xorl %eax, %eax
callq 0x3330
jmp 0x8d56
je 0x8d22
movq %rbx, %rdi
callq 0x3de3
movq 0x352cf(%rip), %r15     # 0x3dff8
movq (%r15), %rdi
leaq 0x2a92c(%rip), %rsi     # 0x3365f
leaq 0x2a904(%rip), %rdx     # 0x3363e
xorl %eax, %eax
callq 0x3330
movq (%r15), %rsi
movq %rbx, %rdi
callq 0x23476
jmp 0x8afa
callq 0x3e1e
movl $0x1, %r14d
xorl %r13d, %r13d
jmp 0x8cc7