// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/tools/gt_speck.c
// Function: gt_speck_runner
static int gt_speck_runner(int argc, const char **argv, int parsed_args,
                               void *tool_arguments, GtError *err)
{
  GtNodeStream *gff3_in_stream = NULL, *checker_stream = NULL,
               *a_in_stream = NULL, *a_out_stream = NULL,
               *feature_stream = NULL, *sort_stream = NULL,
               *last_stream = NULL;
  GtNodeVisitor *spec_visitor = NULL;
  GtSpecResults *res = NULL;
  GtFeatureIndex *fi = NULL;
  GtTypeChecker *type_checker = NULL;
  GtTimer *t = NULL;
  GtRegionMapping *rm = NULL;
  GtArray *arr = gt_array_new(sizeof (GtFeatureNode*));
  GtStr *prog, *speclib;
  SpeccheckArguments *arguments = tool_arguments;

  int had_err = 0;
  gt_error_check(err);

  res = gt_spec_results_new();
  gt_assert(res);

  if (gt_file_exists(gt_str_get(arguments->format))) {
    speclib = gt_str_ref(arguments->format);
  } else {
    prog = gt_str_new();
    gt_str_append_cstr_nt(prog, gt_error_get_progname(err),
                    gt_cstr_length_up_to_char(gt_error_get_progname(err), ' '));
    speclib = gt_get_gtdata_path(gt_str_get(prog), NULL);
    gt_str_delete(prog);
    gt_str_append_cstr(speclib, "/spec/output_drivers/");
    gt_str_append_str(speclib, arguments->format);

    if (!gt_file_exists(gt_str_get(speclib))) {
      gt_error_set(err, "output driver file \"%s\" does not exist",
                   gt_str_get(speclib));
      had_err = -1;
    }
  }

  if (!had_err) {
    spec_visitor = gt_spec_visitor_new(gt_str_get(arguments->specfile), res,
                                       err);
    if (!spec_visitor) {
      gt_spec_results_delete(res);
      return -1;
    }
  }

  t = gt_timer_new();
  gt_assert(t);

  /* add region mapping if given */
  if (!had_err && gt_seqid2file_option_used(arguments->s2fi)) {
    rm = gt_seqid2file_region_mapping_new(arguments->s2fi, err);
    if (!rm)
      had_err = -1;
    if (!had_err)
      gt_spec_visitor_add_region_mapping((GtSpecVisitor*) spec_visitor, rm);
  }

  /* set type checker if necessary */
  if (!had_err && gt_typecheck_info_option_used(arguments->tci)) {
    type_checker = gt_typecheck_info_create_type_checker(arguments->tci, err);
    if (!type_checker)
      had_err = -1;
    if (!had_err)
      gt_spec_visitor_add_type_checker((GtSpecVisitor*) spec_visitor,
                                       type_checker);
  }

  if (!had_err) {
    /* set runtime error behaviour */
    if (arguments->fail_hard)
      gt_spec_visitor_fail_on_runtime_error((GtSpecVisitor*) spec_visitor);
    else
      gt_spec_visitor_report_runtime_errors((GtSpecVisitor*) spec_visitor);

    /* redirect warnings */
    gt_warning_set_handler(gt_speck_record_warning, res);

    last_stream = gff3_in_stream = gt_gff3_in_stream_new_unsorted(
                                                            argc - parsed_args,
                                                            argv + parsed_args);
    gt_assert(gff3_in_stream);
    gt_gff3_in_stream_enable_tidy_mode((GtGFF3InStream*) gff3_in_stream);

    /* insert sort stream if requested */
    if (arguments->sort) {
      last_stream = sort_stream = gt_sort_stream_new(last_stream);
    }

    /* if -provideindex is given, collect input features and index them first */
    if (arguments->provideindex) {
      fi = gt_feature_index_memory_new();
      gt_assert(fi);

      last_stream = feature_stream = gt_feature_stream_new(last_stream, fi);
      gt_assert(feature_stream);

      last_stream = a_out_stream = gt_array_out_stream_all_new(last_stream, arr,
                                                               err);
      if (!a_out_stream)
        had_err = -1;

      gt_timer_start(t);

      if (!had_err)
        had_err = gt_node_stream_pull(last_stream, err);

      if (!had_err) {
        gt_spec_visitor_add_feature_index((GtSpecVisitor*) spec_visitor,
                                          gt_feature_index_ref(fi));
        last_stream = a_in_stream = gt_array_in_stream_new(arr, NULL, err);
        if (!a_in_stream)
          had_err = -1;
      }
    } else {
      gt_timer_start(t);
    }

    if (!had_err) {
      checker_stream = gt_visitor_stream_new(last_stream, spec_visitor);
      gt_assert(checker_stream);
    }

    /* perform checking  */
    if (!had_err)
      had_err = gt_node_stream_pull(checker_stream, err);

    gt_timer_stop(t);

    /* reset warnings output */
    gt_warning_set_handler(gt_warning_default_handler, NULL);

    /* output results */
    if (!had_err) {
      GtStr *runtime = gt_str_new();
      gt_timer_get_formatted(t, GT_WD ".%06ld", runtime);
      had_err = gt_spec_results_render_template(res, gt_str_get(speclib),
                                                arguments->outfp,
                                                gt_str_get(arguments->specfile),
                                                arguments->verbose,
                                                arguments->colored,
                                                gt_str_get(runtime), err);
      gt_str_delete(runtime);
    }

    if (!had_err && (gt_spec_results_has_runtime_errors(res)
          || gt_spec_results_has_failures(res))) {
      had_err = -2;
    }
  }

  /* free */
  gt_node_stream_delete(gff3_in_stream);
  gt_node_stream_delete(a_in_stream);
  gt_node_stream_delete(a_out_stream);
  gt_node_stream_delete(checker_stream);
  gt_node_stream_delete(feature_stream);
  gt_node_stream_delete(sort_stream);
  gt_spec_results_delete(res);
  gt_feature_index_delete(fi);
  gt_type_checker_delete(type_checker);
  gt_timer_delete(t);
  gt_array_delete(arr);
  gt_str_delete(speclib);

  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r8, %r12
movq %rcx, %r13
movl %edx, %ebp
movq %rsi, %r15
movl %edi, %ebx
movl $0x8, %edi
callq 0xd46fc
movq %rax, 0x48(%rsp)
testq %r12, %r12
je 0xcec57
movq %r12, %rdi
callq 0x101a9a
testb %al, %al
jne 0xcf157
callq 0x17e244
testq %rax, %rax
je 0xcf14d
movq %rax, %r14
movl %ebp, (%rsp)
movq %r15, 0x8(%rsp)
movq 0x8(%r13), %rdi
callq 0x120d23
movq %rax, %rdi
callq 0x10415c
testb %al, %al
movq %r14, 0x10(%rsp)
je 0xcec9e
movq 0x8(%r13), %rdi
callq 0x120e79
movq %rax, %r15
movb $0x1, %bpl
jmp 0xced46
callq 0x1208f8
movq %rax, %r14
movq %r12, %rdi
callq 0x101b22
movq %rax, %r15
movq %r12, %rdi
callq 0x101b22
movq %rax, %rdi
movl $0x20, %esi
callq 0xe885c
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x120a9d
movq %r14, %rdi
callq 0x120d23
movq %rax, %rdi
xorl %esi, %esi
callq 0x105688
movq %rax, %r15
movq %r14, %rdi
callq 0x121b03
leaq 0x295f0d(%rip), %rsi    # 0x364c05
movq %r15, %rdi
callq 0x12097f
movq 0x8(%r13), %rsi
movq %r15, %rdi
callq 0x120a43
movq %r15, %rdi
callq 0x120d23
movq %rax, %rdi
callq 0x10415c
movb $0x1, %bpl
testb %al, %al
jne 0xced41
movq %r15, %rdi
callq 0x120d23
leaq 0x295ee9(%rip), %rsi    # 0x364c1b
xorl %ebp, %ebp
movq %r12, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1019cf
movq 0x10(%rsp), %r14
movq %r15, 0x50(%rsp)
testb %bpl, %bpl
je 0xced81
movq (%r13), %rdi
callq 0x120d23
movq %rax, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x17f8ff
movq %rax, %r15
testq %rax, %rax
jne 0xced84
movq %r14, %rdi
callq 0x17f003
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0xcf0fc
xorl %r15d, %r15d
callq 0x1226a4
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0xcf152
testb %bpl, %bpl
je 0xcedf6
movq 0x18(%r13), %rdi
callq 0x17b372
testb %al, %al
je 0xcedc5
movq 0x18(%r13), %rdi
movq %r12, %rsi
callq 0x17b3bd
testq %rax, %rax
je 0xcedf6
movq %r15, %rdi
movq %rax, %rsi
callq 0x17f8b3
movq 0x28(%r13), %rdi
callq 0x18bace
movb $0x1, %r14b
testb %al, %al
je 0xcedfd
movq 0x28(%r13), %rdi
movq %r12, %rsi
callq 0x18baf7
movq %rax, %rbp
testq %rax, %rax
je 0xcedf8
movq %r15, %rdi
movq %rbp, %rsi
callq 0x17f8ea
jmp 0xcedff
xorl %ebp, %ebp
xorl %r14d, %r14d
jmp 0xcedff
xorl %ebp, %ebp
testb %r14b, %r14b
movq %rbp, 0x60(%rsp)
je 0xcee1f
cmpb $0x1, 0x12(%r13)
movq 0x10(%rsp), %r14
movq %r15, %rdi
jne 0xcee49
callq 0x17f86c
jmp 0xcee4e
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
xorl %r14d, %r14d
xorl %r13d, %r13d
xorl %ebp, %ebp
movq $0x0, 0x8(%rsp)
xorl %r12d, %r12d
xorl %r15d, %r15d
xorl %edi, %edi
movq 0x10(%rsp), %rbx
jmp 0xcf092
callq 0x17f85c
leaq 0x31b(%rip), %rdi       # 0xcf170
movq %r14, %rsi
callq 0x1254fc
movl (%rsp), %eax
subl %eax, %ebx
cltq
movq 0x8(%rsp), %rcx
leaq (%rcx,%rax,8), %rsi
movl %ebx, %edi
callq 0x14d00b
testq %rax, %rax
je 0xcf15c
movq %rax, %rbx
movq %rax, %rdi
callq 0x14cfc0
cmpb $0x1, 0x14(%r13)
movq %rbx, 0x38(%rsp)
jne 0xceea6
movq %rbx, %rdi
callq 0x17e1d7
movq %rax, %rbx
movq %rax, 0x40(%rsp)
jmp 0xceeaf
movq $0x0, 0x40(%rsp)
cmpb $0x1, 0x13(%r13)
jne 0xcef13
callq 0x148ed1
testq %rax, %rax
je 0xcf161
movq %rbx, %rdi
movq %rax, 0x8(%rsp)
movq %rax, %rsi
callq 0x14b480
testq %rax, %rax
je 0xcf166
movq %rax, 0x28(%rsp)
movq %rax, %rdi
movq 0x48(%rsp), %rsi
movq %r12, %rdx
callq 0x12b8c1
movq %rax, %rbx
movq 0x18(%rsp), %rdi
callq 0x122733
testq %rbx, %rbx
je 0xcef3e
movq %rbx, %rdi
movq %r12, %rsi
callq 0x16adca
movl %eax, %ebp
jmp 0xcef43
movq 0x18(%rsp), %rdi
callq 0x122733
movq $0x0, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x8(%rsp)
xorl %ecx, %ecx
xorl %ebp, %ebp
jmp 0xcef52
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
testl %ebp, %ebp
movq %rbx, 0x20(%rsp)
je 0xcf10b
movq %rcx, 0x30(%rsp)
testl %ebp, %ebp
je 0xcef60
xorl %r15d, %r15d
jmp 0xcef77
movq %rbx, %rdi
movq %r15, %rsi
callq 0x18c917
movq %rax, %r15
testq %rax, %rax
je 0xcf16b
testl %ebp, %ebp
jne 0xcef88
movq %r15, %rdi
movq %r12, %rsi
callq 0x16adca
movl %eax, %ebp
movq 0x18(%rsp), %rdi
callq 0x122778
leaq -0x956f8(%rip), %rdi    # 0x398a1
xorl %esi, %esi
callq 0x1254fc
testl %ebp, %ebp
jne 0xcf02b
callq 0x1208f8
movq %rax, %rbx
leaq 0x295c8b(%rip), %rsi    # 0x364c42
movq 0x18(%rsp), %rdi
movq %rax, %rdx
callq 0x122914
movq 0x50(%rsp), %rdi
callq 0x120d23
movq %rax, (%rsp)
movq (%r13), %rdi
movq 0x30(%r13), %rax
movq %rax, 0x58(%rsp)
callq 0x120d23
movq %rax, %rbp
movzbl 0x10(%r13), %r14d
movzbl 0x11(%r13), %r13d
movq %rbx, %rdi
callq 0x120d23
movq 0x10(%rsp), %rdi
movq (%rsp), %rsi
movq 0x58(%rsp), %rdx
movq %rbp, %rcx
movl %r14d, %r8d
movq 0x10(%rsp), %r14
movl %r13d, %r9d
pushq %r12
pushq %rax
callq 0x17e747
addq $0x10, %rsp
movl %eax, %ebp
movq %rbx, %rdi
callq 0x121b03
testl %ebp, %ebp
je 0xcf050
movl %ebp, (%rsp)
movq 0x40(%rsp), %rbp
movq 0x38(%rsp), %rdi
movq 0x28(%rsp), %r13
movq %r14, %rbx
movq 0x20(%rsp), %r14
movq 0x30(%rsp), %r12
jmp 0xcf092
movq %r14, %rdi
callq 0x17e729
testb %al, %al
movq 0x40(%rsp), %rbp
jne 0xcf074
movq %r14, %rdi
callq 0x17e738
movl $0x0, (%rsp)
testb %al, %al
je 0xcf07b
movl $0xfffffffe, (%rsp)     # imm = 0xFFFFFFFE
movq 0x38(%rsp), %rdi
movq %r14, %rbx
movq 0x20(%rsp), %r14
movq 0x30(%rsp), %r12
movq 0x28(%rsp), %r13
callq 0x16ac6e
movq %r12, %rdi
callq 0x16ac6e
movq %r14, %rdi
callq 0x16ac6e
movq %r15, %rdi
callq 0x16ac6e
movq %r13, %rdi
callq 0x16ac6e
movq %rbp, %rdi
callq 0x16ac6e
movq %rbx, %rdi
callq 0x17f003
movq 0x8(%rsp), %rdi
callq 0x147952
movq 0x60(%rsp), %rdi
callq 0x18b883
movq 0x18(%rsp), %rdi
callq 0x122d79
movq 0x48(%rsp), %rdi
callq 0xd4ef4
movq 0x50(%rsp), %rdi
callq 0x121b03
movl (%rsp), %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %rdi
callq 0x147923
movq %r15, %rdi
movq %rax, %rsi
callq 0x17f87c
movq 0x48(%rsp), %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x12b71a
testq %rax, %rax
je 0xcf13f
movq %rax, %rbx
movq %rax, %rcx
jmp 0xcef3a
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
xorl %ebx, %ebx
xorl %ecx, %ecx
jmp 0xcef52
callq 0x21462
callq 0x21429
callq 0x2130c
callq 0x213f0
callq 0x213b7
callq 0x2137e
callq 0x21345