// File: /workspace/github_c_makefile_star2_O2/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 0x1eace
movq %rax, %rbx
testq %rax, %rax
je 0x7313
movl 0xc8(%rsp), %eax
cmpl $0x2, %eax
jge 0x7341
testq %r14, %r14
je 0x7137
pushq $0x1
popq %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x965d
movq %rax, %r15
jmp 0x713a
xorl %r15d, %r15d
testq %r12, %r12
movq %rbp, 0x38(%rsp)
je 0x7155
pushq $0x2
popq %rdx
movq %r12, %rdi
movq %r15, %rsi
callq 0x965d
movq %rax, %r15
movl 0x98(%rsp), %ebp
movl 0x90(%rsp), %r13d
movl 0xc8(%rsp), %eax
cmpl $0x3, %eax
jl 0x7182
movq 0x31e81(%rip), %rax     # 0x38ff8
movq (%rax), %rsi
movq %r15, %rdi
callq 0xa062
cvttsd2si 0x10(%rsp), %eax
subq $0x8, %rsp
movq %r15, %rdi
movq %rbx, %rsi
movl %r13d, %edx
movl %ebp, %ecx
movsd 0x20(%rsp), %xmm0
xorl %r8d, %r8d
movl 0x14(%rsp), %r9d
movl 0xd0(%rsp), %ebp
pushq %rbp
pushq $0x1
pushq %rax
callq 0x2148a
addq $0x20, %rsp
testq %rax, %rax
je 0x739f
movq %rax, %r13
cmpl $0x2, %ebp
jl 0x71e2
movq 0x31e27(%rip), %rax     # 0x38ff8
movq (%rax), %rcx
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x23517
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 0x728b
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 0x73ca
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 0x72e9
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 0x73ca
addq $0x40, %rsp
movq %rbx, %rdi
callq 0x1dc50
movq %r15, %rdi
callq 0x9554
movq %r13, %rdi
callq 0x1f9f3
movl %r14d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x31cde(%rip), %rax     # 0x38ff8
movq (%rax), %rdi
leaq 0x2528c(%rip), %rsi     # 0x2c5b0
leaq 0x25313(%rip), %rdx     # 0x2c63e
xorl %r15d, %r15d
movq %r13, %rcx
xorl %eax, %eax
callq 0x3330
pushq $0x1
popq %r14
xorl %r13d, %r13d
jmp 0x72e9
je 0x7370
movq 0x31cae(%rip), %r15     # 0x38ff8
movq (%r15), %rdi
leaq 0x252f5(%rip), %rsi     # 0x2c649
leaq 0x252e3(%rip), %rdx     # 0x2c63e
xorl %eax, %eax
callq 0x3330
movq (%r15), %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x1e681
movq 0x31c81(%rip), %r15     # 0x38ff8
movq (%r15), %rdi
leaq 0x252de(%rip), %rsi     # 0x2c65f
leaq 0x252b6(%rip), %rdx     # 0x2c63e
xorl %eax, %eax
callq 0x3330
movq (%r15), %rsi
movq %rbx, %rdi
callq 0x1e7eb
jmp 0x7120
pushq $0x1
popq %r14
movq 0x31c4e(%rip), %rax     # 0x38ff8
movq (%rax), %rdi
leaq 0x25264(%rip), %rsi     # 0x2c618
leaq 0x25283(%rip), %rdx     # 0x2c63e
xorl %r13d, %r13d
xorl %eax, %eax
callq 0x3330
jmp 0x72e9