// File: /workspace/github_c_makefile_star2_O3/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 0x24960
movq %rax, %rbx
testq %rax, %rax
je 0x9209
movl 0xc8(%rsp), %eax
cmpl $0x2, %eax
jge 0x9230
testq %r14, %r14
je 0x902b
movq %r14, %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0xb758
movq %rax, %r15
jmp 0x902e
xorl %r15d, %r15d
testq %r12, %r12
movq %rbp, 0x38(%rsp)
je 0x904b
movq %r12, %rdi
movq %r15, %rsi
movl $0x2, %edx
callq 0xb758
movq %rax, %r15
movl 0x98(%rsp), %r13d
movl 0x90(%rsp), %ebp
movl 0xc8(%rsp), %eax
cmpl $0x3, %eax
jl 0x9078
movq 0x36f8b(%rip), %rax     # 0x3fff8
movq (%rax), %rsi
movq %r15, %rdi
callq 0xc342
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 0x275c6
addq $0x20, %rsp
testq %rax, %rax
je 0x9269
movq %rax, %r13
cmpl $0x2, %ebp
jl 0x90d8
movq 0x36f31(%rip), %rax     # 0x3fff8
movq (%rax), %rcx
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x29c66
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 0x9181
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 0x927c
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 0x91df
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 0x927c
addq $0x40, %rsp
movq %rbx, %rdi
callq 0x23a1c
movq %r15, %rdi
callq 0xb61c
movq %r13, %rdi
callq 0x259a6
movl %r14d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x36de8(%rip), %rax     # 0x3fff8
movq (%rax), %rdi
leaq 0x2c3c6(%rip), %rsi     # 0x355e0
leaq 0x2c44d(%rip), %rdx     # 0x3566e
xorl %r15d, %r15d
movq %r13, %rcx
xorl %eax, %eax
callq 0x3330
jmp 0x926e
je 0x923a
movq %rbx, %rdi
callq 0x3d72
movq 0x36db7(%rip), %r15     # 0x3fff8
movq (%r15), %rdi
leaq 0x2c444(%rip), %rsi     # 0x3568f
leaq 0x2c41c(%rip), %rdx     # 0x3566e
xorl %eax, %eax
callq 0x3330
movq (%r15), %rsi
movq %rbx, %rdi
callq 0x245fe
jmp 0x9012
callq 0x3dad
movl $0x1, %r14d
xorl %r13d, %r13d
jmp 0x91df