// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/ltr/gt_ltrdigest.c
// Function: gt_ltrdigest_runner
static int gt_ltrdigest_runner(GT_UNUSED int argc, const char **argv,
                               int parsed_args, void *tool_arguments,
                               GtError *err)
{
  GtLTRdigestOptions *arguments = tool_arguments;
  GtNodeStream *gff3_in_stream  = NULL,
               *check_stream    = NULL,
               *gff3_out_stream = NULL,
               *pdom_stream     = NULL,
               *ppt_stream      = NULL,
               *pbs_stream      = NULL,
               *tab_out_stream  = NULL,
               *sa_stream       = NULL,
               *last_stream     = NULL;
  int had_err      = 0,
      tests_to_run = 0,
      arg = parsed_args;
  GtRegionMapping *rmap = NULL;
  GtPdomModelSet *ms = NULL;
  gt_error_check(err);
  gt_assert(arguments);

  /* determine and open sequence source */
  if (gt_seqid2file_option_used(arguments->s2fi)) {
    /* create region mapping */
    rmap = gt_seqid2file_region_mapping_new(arguments->s2fi, err);
    if (!rmap)
      had_err = -1;
  } else {
    GtEncseqLoader *el;
    GtEncseq *encseq;
    /* no new-style sequence source option given, fall back to legacy syntax */
    if (argc < 3) {
      gt_error_set(err, "missing mandatory argument(s)");
      had_err = -1;
    }
    if (!had_err) {
      el = gt_encseq_loader_new();
      gt_encseq_loader_disable_autosupport(el);
      gt_encseq_loader_require_md5_support(el);
      gt_encseq_loader_require_description_support(el);
      encseq = gt_encseq_loader_load(el, argv[argc-1], err);
      /* XXX: clip off terminal argument */
      gt_free((char*) argv[argc-1]);
      argv[argc-1] = NULL;
      argc--;
      gt_encseq_loader_delete(el);
      if (!encseq)
        had_err = -1;
      else {
        rmap = gt_region_mapping_new_encseq_seqno(encseq);
        gt_encseq_delete(encseq);
      }
    }
  }
  gt_assert(had_err || rmap);

  /* Always search for PPT. */
  tests_to_run |= GT_LTRDIGEST_RUN_PPT;

  /* Open tRNA library if given. */
  if (!had_err && arguments->trna_lib
        && gt_str_length(arguments->trna_lib) > 0)
  {
    tests_to_run |= GT_LTRDIGEST_RUN_PBS;
    arguments->trna_lib_bs = gt_bioseq_new(gt_str_get(arguments->trna_lib),
                                           err);
    if (gt_error_is_set(err))
      had_err = -1;
  }

  /* Set HMMER cutoffs. */
  if (!had_err && gt_str_array_size(arguments->hmm_files) > 0)
  {
    tests_to_run |= GT_LTRDIGEST_RUN_PDOM;
    if (!strcmp(gt_str_get(arguments->cutoffs), "GA")) {
      arguments->cutoff = GT_PHMM_CUTOFF_GA;
    } else if (!strcmp(gt_str_get(arguments->cutoffs), "TC")) {
      arguments->cutoff = GT_PHMM_CUTOFF_TC;
    } else if (!strcmp(gt_str_get(arguments->cutoffs), "NONE")) {
      arguments->cutoff = GT_PHMM_CUTOFF_NONE;
    } else {
      gt_error_set(err, "invalid cutoff setting!");
      had_err = -1;
    }
  }

  if (!had_err) {
    last_stream = gff3_in_stream  = gt_gff3_in_stream_new_sorted(argv[arg]);
  }

  if (!had_err) {
    GtNodeVisitor *check_v;
    check_v = gt_ltr_input_check_visitor_new();
    last_stream = check_stream = gt_visitor_stream_new(last_stream, check_v);
  }

  if (!had_err && gt_str_array_size(arguments->hmm_files) > 0) {
    GtNodeVisitor *pdom_v;
    ms = gt_pdom_model_set_new(arguments->hmm_files, arguments->force_recreate,
                               err);
    if (ms != NULL) {
      pdom_v = gt_ltrdigest_pdom_visitor_new(ms, arguments->evalue_cutoff,
                                             arguments->chain_max_gap_length,
                                             arguments->cutoff, rmap, err);
      if (pdom_v == NULL)
        had_err = -1;
      if (!had_err) {
        gt_ltrdigest_pdom_visitor_set_source_tag((GtLTRdigestPdomVisitor*)
                                                                        pdom_v,
                                                 GT_LTRDIGEST_TAG);
        if (arguments->output_all_chains)
          gt_ltrdigest_pdom_visitor_output_all_chains((GtLTRdigestPdomVisitor*)
                                                                        pdom_v);
        last_stream = pdom_stream = gt_visitor_stream_new(last_stream, pdom_v);
      }
    } else had_err = -1;
  }

  if (!had_err && arguments->trna_lib_bs) {
    GtNodeVisitor *pbs_v;
    pbs_v = gt_ltrdigest_pbs_visitor_new(rmap, arguments->pbs_radius,
                                         arguments->max_edist,
                                         arguments->alilen,
                                         arguments->offsetlen,
                                         arguments->trnaoffsetlen,
                                         arguments->ali_score_match,
                                         arguments->ali_score_mismatch,
                                         arguments->ali_score_insertion,
                                         arguments->ali_score_deletion,
                                         arguments->trna_lib_bs, err);
    if (pbs_v != NULL)
      last_stream = pbs_stream = gt_visitor_stream_new(last_stream, pbs_v);
    else
      had_err = -1;
  }

  if (!had_err) {
    GtNodeVisitor *ppt_v;
    ppt_v = gt_ltrdigest_ppt_visitor_new(rmap, arguments->ppt_len,
                                         arguments->ubox_len,
                                         arguments->ppt_pyrimidine_prob,
                                         arguments->ppt_purine_prob,
                                         arguments->bkg_a_prob,
                                         arguments->bkg_g_prob,
                                         arguments->bkg_t_prob,
                                         arguments->bkg_c_prob,
                                         arguments->ubox_u_prob,
                                         arguments->ppt_radius,
                                         arguments->max_ubox_dist, err);
    if (ppt_v != NULL)
      last_stream = ppt_stream = gt_visitor_stream_new(last_stream, ppt_v);
    else
      had_err = -1;
  }

  if (!had_err) {
    GtNodeVisitor *sa_v;
    sa_v = gt_ltrdigest_strand_assign_visitor_new();
    gt_assert(sa_v);
    last_stream = sa_stream = gt_visitor_stream_new(last_stream, sa_v);
  }

  if (!had_err)
  {
    /* attach tabular output stream, if requested */
    if (gt_str_length(arguments->prefix) > 0)
    {
      last_stream = tab_out_stream = gt_ltrdigest_file_out_stream_new(
                                                  last_stream,
                                                  tests_to_run,
                                                  rmap,
                                                  gt_str_get(arguments->prefix),
                                                  arguments->seqnamelen,
                                                  err);
      if (!tab_out_stream)
        had_err = -1;
      if (!had_err && arguments->print_metadata)
      {
        had_err = gt_ltrdigest_file_out_stream_write_metadata(
                                           (GtLTRdigestFileOutStream*)
                                                                 tab_out_stream,
                                           tests_to_run,
                                           gt_str_get(arguments->trna_lib),
                                           argv[arg],
                                           arguments->ppt_len,
                                           arguments->ubox_len,
                                           arguments->ppt_radius,
                                           arguments->alilen,
                                           arguments->max_edist,
                                           arguments->offsetlen,
                                           arguments->trnaoffsetlen,
                                           arguments->pbs_radius,
                                           arguments->hmm_files,
                                           arguments->chain_max_gap_length,
                                           arguments->evalue_cutoff,
                                           err);
      }
      if (!had_err)
      {
        if (arguments->write_alignments)
          gt_ltrdigest_file_out_stream_enable_pdom_alignment_output(
                                                                tab_out_stream);
        if (arguments->write_aaseqs)
          gt_ltrdigest_file_out_stream_enable_aa_sequence_output(
                                                                tab_out_stream);
      }
    }

    if (!had_err) {
      last_stream = gff3_out_stream = gt_gff3_out_stream_new(last_stream,
                                                             arguments->outfp);
      gt_assert(last_stream);

      /* pull the features through the stream and free them afterwards */
      had_err = gt_node_stream_pull(last_stream, err);
    }
  }

  gt_pdom_model_set_delete(ms);
  gt_node_stream_delete(gff3_out_stream);
  gt_node_stream_delete(ppt_stream);
  gt_node_stream_delete(pbs_stream);
  gt_node_stream_delete(sa_stream);
  gt_node_stream_delete(pdom_stream);
  gt_node_stream_delete(tab_out_stream);
  gt_node_stream_delete(check_stream);
  gt_node_stream_delete(gff3_in_stream);
  gt_bioseq_delete(arguments->trna_lib_bs);
  gt_region_mapping_delete(rmap);

  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %r8, %r13
movq %rcx, %rbx
movl %edx, %r14d
movq %rsi, %r15
movl %edi, %ebp
testq %r8, %r8
je 0x20e932
movq %r13, %rdi
callq 0x101a9a
testb %al, %al
jne 0x20f005
testq %rbx, %rbx
je 0x20effb
movq 0x38(%rbx), %rdi
callq 0x17b372
testb %al, %al
movq %r15, 0xa8(%rsp)
movl %r14d, 0x84(%rsp)
je 0x20e974
movq 0x38(%rbx), %rdi
movq %r13, %rsi
callq 0x17b3bd
movq %rax, 0x78(%rsp)
testq %rax, %rax
sete %al
jmp 0x20ea30
cmpl $0x2, %ebp
jle 0x20e9f7
callq 0xf36ef
movq %rax, %r14
movq %rax, %rdi
callq 0xf69cc
movq %r14, %rdi
callq 0xf69b7
movq %r14, %rdi
callq 0xf6ac6
movl %ebp, %r12d
movq -0x8(%r15,%r12,8), %rsi
movq %r14, %rdi
movq %r13, %rdx
callq 0xf374b
movq %r15, %rbp
movq %rax, %r15
movq -0x8(%rbp,%r12,8), %rdi
leaq 0x1b90fd(%rip), %rsi    # 0x3c7abb
movl $0x1db, %edx            # imm = 0x1DB
callq 0x109670
movq $0x0, -0x8(%rbp,%r12,8)
movq %r14, %rdi
callq 0xf424d
testq %r15, %r15
je 0x20ea15
movq %r15, %rdi
callq 0x175a20
movq %rax, 0x78(%rsp)
movq %r15, %rdi
callq 0xee90c
xorl %eax, %eax
jmp 0x20ea20
leaq 0x1b9858(%rip), %rsi    # 0x3c8256
movq $0x0, 0x78(%rsp)
movq %r13, %rdi
xorl %eax, %eax
callq 0x1019cf
movb $0x1, %al
jmp 0x20ea30
movb $0x1, %al
movq $0x0, 0x78(%rsp)
movq 0xa8(%rsp), %r15
movl 0x84(%rsp), %r14d
testb %al, %al
jne 0x20ea40
cmpq $0x0, 0x78(%rsp)
je 0x20f000
movl $0x1, %r12d
testb %al, %al
je 0x20ea4e
xorl %ebp, %ebp
jmp 0x20ea91
movq (%rbx), %rdi
movb $0x1, %bpl
testq %rdi, %rdi
je 0x20ea91
callq 0x120d4c
testq %rax, %rax
je 0x20ea91
movq (%rbx), %rdi
callq 0x120d23
movq %rax, %rdi
movq %r13, %rsi
callq 0xd69c0
movq %rax, 0x108(%rbx)
movq %r13, %rdi
callq 0x101a9a
movl %eax, %ebp
xorb $0x1, %bpl
movl $0x3, %r12d
testb %bpl, %bpl
je 0x20eb24
movq 0x30(%rbx), %rdi
callq 0x121e78
movb $0x1, %bpl
testq %rax, %rax
je 0x20eb26
orl $0x4, %r12d
movq 0x10(%rbx), %rdi
callq 0x120d23
leaq 0x15cc66(%rip), %rsi    # 0x36b725
movq %rax, %rdi
callq 0x17a40
testl %eax, %eax
je 0x20eed2
movq 0x10(%rbx), %rdi
callq 0x120d23
leaq 0x157b99(%rip), %rsi    # 0x366678
movq %rax, %rdi
callq 0x17a40
testl %eax, %eax
je 0x20efe3
movq 0x10(%rbx), %rdi
callq 0x120d23
leaq 0x157b74(%rip), %rsi    # 0x366673
movq %rax, %rdi
callq 0x17a40
testl %eax, %eax
je 0x20efef
leaq 0x1581ba(%rip), %rsi    # 0x366cd0
xorl %ebp, %ebp
movq %r13, %rdi
xorl %eax, %eax
callq 0x1019cf
jmp 0x20eb26
xorl %ebp, %ebp
testb %bpl, %bpl
je 0x20eb41
movslq %r14d, %rax
movq (%r15,%rax,8), %rdi
callq 0x14d0a8
movq %rax, 0xa0(%rsp)
jmp 0x20eb4d
movq $0x0, 0xa0(%rsp)
testb %bpl, %bpl
je 0x20eb74
callq 0x211f24
movq 0xa0(%rsp), %rdi
movq %rax, %rsi
callq 0x18c917
movq %rax, %r15
movq %rax, 0xb8(%rsp)
jmp 0x20eb88
movq $0x0, 0xb8(%rsp)
movq 0xa0(%rsp), %r15
movl %r12d, 0x94(%rsp)
testb %bpl, %bpl
je 0x20ec1a
movq 0x30(%rbx), %rdi
callq 0x121e78
movb $0x1, %r12b
testq %rax, %rax
je 0x20ec1d
movq 0x30(%rbx), %rdi
movzbl 0x1d(%rbx), %esi
movq %r13, %rdx
callq 0x21be50
movq %rax, %rbp
testq %rax, %rax
je 0x20ec21
movsd 0x48(%rbx), %xmm0
movl 0x58(%rbx), %esi
movl 0x40(%rbx), %edx
movq %rbp, %rdi
movq 0x78(%rsp), %rcx
movq %r13, %r8
callq 0x215b23
testq %rax, %rax
je 0x20ec21
movq %rax, %r14
leaq 0x1b9688(%rip), %rsi    # 0x3c8274
movq %rax, %rdi
callq 0x215ae3
cmpb $0x1, 0x1b(%rbx)
jne 0x20ec02
movq %r14, %rdi
callq 0x215aac
movq %r15, %rdi
movq %r14, %rsi
callq 0x18c917
movq %rax, %r15
movq %rax, 0x88(%rsp)
jmp 0x20ec30
xorl %r12d, %r12d
xorl %ebp, %ebp
jmp 0x20ec24
xorl %r12d, %r12d
movq $0x0, 0x88(%rsp)
testb %r12b, %r12b
je 0x20ecde
movq 0x108(%rbx), %rax
movb $0x1, %r14b
testq %rax, %rax
je 0x20ece1
movl 0xc0(%rbx), %esi
movl 0xc4(%rbx), %edx
movl 0xf8(%rbx), %r9d
movl 0xfc(%rbx), %edi
movl 0x100(%rbx), %r10d
movl 0x104(%rbx), %r11d
movq 0xc8(%rbx), %rcx
movq 0xd0(%rbx), %r8
movups 0xd8(%rbx), %xmm0
movups 0xe8(%rbx), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r13, 0x40(%rsp)
movq %rax, 0x38(%rsp)
movl %r11d, 0x30(%rsp)
movl %r10d, 0x28(%rsp)
movl %edi, 0x20(%rsp)
movq 0x78(%rsp), %rdi
callq 0x215014
testq %rax, %rax
setne %cl
je 0x20eede
movq %r15, %rdi
movq %rax, %rsi
callq 0x18c917
movq %rax, %r15
movq %rax, 0x98(%rsp)
jmp 0x20eced
xorl %r14d, %r14d
movq $0x0, 0x98(%rsp)
movq %rbp, 0xc0(%rsp)
testb %r14b, %r14b
je 0x20ed89
movsd 0x80(%rbx), %xmm0
movsd 0x88(%rbx), %xmm1
movsd 0x90(%rbx), %xmm2
movsd 0x98(%rbx), %xmm3
movsd 0xa0(%rbx), %xmm4
movsd 0xa8(%rbx), %xmm5
movsd 0xb0(%rbx), %xmm6
movl 0xb8(%rbx), %r9d
movl 0xbc(%rbx), %eax
movq 0x60(%rbx), %rsi
movq 0x68(%rbx), %rdx
movq 0x70(%rbx), %rcx
movq 0x78(%rbx), %r8
movq %r13, 0x8(%rsp)
movl %eax, (%rsp)
movq 0x78(%rsp), %rdi
callq 0x217f82
testq %rax, %rax
setne %bpl
je 0x20ed8b
movq %r15, %rdi
movq %rax, %rsi
callq 0x18c917
movq %rax, %r15
movb $0x1, %bpl
movq %rax, 0xb0(%rsp)
jmp 0x20ed97
xorl %ebp, %ebp
movq $0x0, 0xb0(%rsp)
testb %bpl, %bpl
je 0x20edc0
callq 0x2189b1
testq %rax, %rax
je 0x20f00a
movq %r13, %r12
movq %r15, %rdi
movq %rax, %rsi
callq 0x18c917
movq %rax, %r14
movq %rax, %r15
jmp 0x20edc6
movq %r13, %r12
xorl %r14d, %r14d
xorl %r13d, %r13d
testb %bpl, %bpl
je 0x20eec1
movq 0x8(%rbx), %rdi
callq 0x120d4c
testq %rax, %rax
je 0x20eece
movq 0x8(%rbx), %rdi
callq 0x120d23
movl 0x5c(%rbx), %r8d
movq %r15, %rdi
movl 0x94(%rsp), %esi
movq 0x78(%rsp), %rdx
movq %rax, %rcx
movq %r12, %r9
callq 0x2143f5
movq %rax, %r15
testq %rax, %rax
je 0x20eef2
xorl %eax, %eax
cmpb $0x1, 0x1c(%rbx)
jne 0x20eef7
movq (%rbx), %rdi
callq 0x120d23
movslq 0x84(%rsp), %rcx
movq 0xa8(%rsp), %rdx
movq (%rdx,%rcx,8), %rcx
movl 0xb8(%rbx), %edx
movl 0xc4(%rbx), %esi
movl 0xc0(%rbx), %edi
movq 0x30(%rbx), %r10
movl 0x58(%rbx), %r11d
movsd 0x48(%rbx), %xmm0
movq 0x60(%rbx), %r8
movq 0x68(%rbx), %r9
movups 0x70(%rbx), %xmm1
movups 0xc8(%rbx), %xmm2
movups 0xd8(%rbx), %xmm3
movups 0xe8(%rbx), %xmm4
movups %xmm4, 0x40(%rsp)
movups %xmm3, 0x30(%rsp)
movups %xmm2, 0x18(%rsp)
movups %xmm1, (%rsp)
movq %r12, 0x68(%rsp)
movl %r11d, 0x60(%rsp)
movq %r10, 0x58(%rsp)
movl %edi, 0x50(%rsp)
movl %esi, 0x28(%rsp)
movl %edx, 0x10(%rsp)
movq %r15, %rdi
movl 0x94(%rsp), %esi
movq %rax, %rdx
callq 0x21403e
jmp 0x20eef7
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
xorl %ebp, %ebp
jmp 0x20ef52
xorl %ebp, %ebp
jmp 0x20ef1f
movl $0x1, 0x40(%rbx)
jmp 0x20eb26
movq $0x0, 0x98(%rsp)
movl %ecx, %r14d
jmp 0x20eced
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %eax, %eax
je 0x20ef00
movl %eax, %r13d
jmp 0x20ef1c
cmpb $0x1, 0x19(%rbx)
jne 0x20ef0e
movq %r15, %rdi
callq 0x213ff0
cmpb $0x1, 0x1a(%rbx)
jne 0x20ef1c
movq %r15, %rdi
callq 0x214017
movq %r15, %rbp
testl %r13d, %r13d
je 0x20ef2c
movl %r13d, %r15d
xorl %r13d, %r13d
jmp 0x20ef52
movq 0x28(%rbx), %rsi
movq %r15, %rdi
callq 0x14e310
testq %rax, %rax
je 0x20f00f
movq %rax, %r13
movq %rax, %rdi
movq %r12, %rsi
callq 0x16adca
movl %eax, %r15d
movq 0xc0(%rsp), %rdi
callq 0x21c4a1
movq %r13, %rdi
callq 0x16ac6e
movq 0xb0(%rsp), %rdi
callq 0x16ac6e
movq 0x98(%rsp), %rdi
callq 0x16ac6e
movq %r14, %rdi
callq 0x16ac6e
movq 0x88(%rsp), %rdi
callq 0x16ac6e
movq %rbp, %rdi
callq 0x16ac6e
movq 0xb8(%rsp), %rdi
callq 0x16ac6e
movq 0xa0(%rsp), %rdi
callq 0x16ac6e
movq 0x108(%rbx), %rdi
callq 0xd6f28
movq 0x78(%rsp), %rdi
callq 0x1758da
movl %r15d, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x0, 0x40(%rbx)
jmp 0x20eb26
movl $0x2, 0x40(%rbx)
jmp 0x20eb26
callq 0x81f11
callq 0x81e66
callq 0x81e2d
callq 0x81ed8
callq 0x81e9f