// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/tools/gt_featureindex.c
// Function: gt_featureindex_runner
static int gt_featureindex_runner(GT_UNUSED int argc,
                                  GT_UNUSED const char **argv,
                                  GT_UNUSED int parsed_args,
                                  void *tool_arguments,
                                  GtError *err)
{
  GtFeatureindexArguments *arguments = tool_arguments;
  GtFeatureIndex *fi = NULL;
  GtArray *results = NULL;
  GtRange rng;
  GtRDB *rdb = NULL;
  GtAnnoDBSchema *adbs = NULL;
  GtNodeVisitor *gff3visitor = NULL;
  GtGenomeNode *regn = NULL;
  GtUword i = 0;
  int had_err = 0;

  gt_error_check(err);
  gt_assert(arguments);

#ifdef HAVE_SQLITE
  if (!had_err) {
    if (strcmp(gt_str_get(arguments->backend),
               GT_SQLITE_BACKEND_STRING) == 0) {
      if (!gt_file_exists(gt_str_get(arguments->filename))) {
        gt_error_set(err, "file '%s' does not exist",
                     gt_str_get(arguments->filename));
        had_err = -1;
      }
      if (!had_err) {
        rdb = gt_rdb_sqlite_new(gt_str_get(arguments->filename), err);
        if (!rdb)
          had_err = -1;
      }
    }
  }
#endif
#ifdef HAVE_MYSQL
  if (!had_err) {
    if (strcmp(gt_str_get(arguments->backend),
                      GT_MYSQL_BACKEND_STRING) == 0) {
      arguments->pass = gt_get_password("password: ", err);
      rdb = gt_rdb_mysql_new(gt_str_get(arguments->host),
                             arguments->port,
                             gt_str_get(arguments->database),
                             gt_str_get(arguments->user),
                             gt_str_get(arguments->pass),
                             err);
      if (!rdb)
        had_err = -1;
    }
  }
#endif
  if (!had_err)
    adbs = gt_anno_db_gfflike_new();

  if (!had_err && !adbs)
    had_err = -1;

  if (!had_err) {
    fi = gt_anno_db_schema_get_feature_index(adbs, rdb, err);
    had_err = fi ? 0 : -1;
  }

  if (!had_err && gt_str_length(arguments->seqid) == 0) {
    char *firstseqid = gt_feature_index_get_first_seqid(fi, err);
    if (firstseqid == NULL)
      had_err = -1;
    else {
      gt_str_append_cstr(arguments->seqid, firstseqid);
      gt_free(firstseqid);
    }
  }

  if (!had_err && !gt_option_is_set(arguments->rngopt)) {
    had_err = gt_feature_index_get_range_for_seqid(fi, &arguments->qry_rng,
                                                   gt_str_get(arguments->seqid),
                                                   err);
  }

  if (!had_err) {
    results = gt_array_new(sizeof (GtFeatureNode*));
    had_err = gt_feature_index_get_features_for_range(fi, results,
                                                   gt_str_get(arguments->seqid),
                                                   &arguments->qry_rng, err);
  }
  if (!had_err) {
    gff3visitor = gt_gff3_visitor_new(NULL);
    if (arguments->retain)
      gt_gff3_visitor_retain_id_attributes((GtGFF3Visitor*) gff3visitor);

    had_err = gt_feature_index_get_range_for_seqid(fi, &rng,
                                                   gt_str_get(arguments->seqid),
                                                   err);
  }
  if (!had_err) {
    regn = gt_region_node_new(arguments->seqid, rng.start, rng.end);
    gt_genome_node_accept(regn, gff3visitor, err);
    gt_genome_node_delete(regn);

    for (i=0; i<gt_array_size(results); i++) {
      GtGenomeNode *gn = *(GtGenomeNode**) gt_array_get(results, i);
      GtRange nrng = gt_genome_node_get_range(gn);

      if (gt_feature_node_try_cast(gn)) {
        GtFeatureNode *fgn = (GtFeatureNode*) gn;
        if (arguments->child_callback_check) {
          GtFeatureNode *fn;
          fn = (GtFeatureNode*) gt_feature_node_new(arguments->seqid, "test",
                                                    nrng.start, nrng.end,
                                                    GT_STRAND_FORWARD);
          gt_feature_node_add_child((GtFeatureNode*) gn, fn);
        }
        if (arguments->attributes_callback_check) {
          if (gt_feature_node_get_attribute(fgn, "foo")) {
            gt_feature_node_set_attribute(fgn, "foo", "boooo");
            gt_feature_node_remove_attribute(fgn, "foo");
          }
          gt_feature_node_add_attribute(fgn, "foo", "bar");
        }
      }
      gt_genome_node_accept(gn, gff3visitor, err);
      gt_genome_node_delete(gn);
    }
  }

  gt_array_delete(results);
  gt_node_visitor_delete(gff3visitor);
  gt_rdb_delete(rdb);
  gt_anno_db_schema_delete(adbs);

  gt_feature_index_delete(fi);
  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r8, %r14
movq %rcx, %r13
testq %r8, %r8
je 0xa824d
movq %r14, %rdi
callq 0xfcc32
testb %al, %al
jne 0xa85a5
testq %r13, %r13
je 0xa85a0
movq 0x18(%r13), %rdi
callq 0x11b0a1
leaq 0x2ccf99(%rip), %rsi    # 0x3751ff
movq %rax, %rdi
callq 0x17a40
testl %eax, %eax
je 0xa832e
xorl %r15d, %r15d
callq 0x1245a8
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
testq %rax, %rax
je 0xa8370
movq %rax, %rbp
movq %rax, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x125824
movq %rax, (%rsp)
testq %rax, %rax
je 0xa839b
movq 0x10(%r13), %rdi
callq 0x11b0ca
testq %rax, %rax
jne 0xa82ed
movq (%rsp), %rdi
movq %r14, %rsi
callq 0x140b4d
testq %rax, %rax
je 0xa8324
movq %rax, %rbx
movq 0x10(%r13), %rdi
movq %rax, %rsi
callq 0x11acf3
leaq 0x2a488b(%rip), %rsi    # 0x34cb6b
movq %rbx, %rdi
movl $0x10b, %edx            # imm = 0x10B
callq 0x1045eb
movq 0x50(%r13), %rdi
callq 0x10ac3f
testb %al, %al
jne 0xa83a8
movq 0x10(%r13), %rdi
callq 0x11b0a1
movq (%rsp), %rdi
movq %r13, %rsi
movq %rax, %rdx
movq %r14, %rcx
callq 0x140c40
testl %eax, %eax
je 0xa83a8
movl %eax, %r12d
xorl %r13d, %r13d
xorl %ebx, %ebx
jmp 0xa83dd
movq 0x20(%r13), %rdi
callq 0x11b0a1
movq %rax, %rdi
callq 0xff28c
movl %eax, %ebx
movq 0x20(%r13), %rdi
callq 0x11b0a1
testb %bl, %bl
je 0xa8377
movq %rax, %rdi
movq %r14, %rsi
callq 0x16c0b4
movq %rax, %r15
testq %rax, %rax
jne 0xa8279
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
xorl %r13d, %r13d
jmp 0xa8394
xorl %r13d, %r13d
xorl %ebp, %ebp
jmp 0xa839e
leaq 0x2a49d3(%rip), %rsi    # 0x34cd51
xorl %r13d, %r13d
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xfcb67
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
xorl %ebp, %ebp
xorl %r15d, %r15d
jmp 0xa839e
xorl %r13d, %r13d
xorl %r14d, %r14d
xorl %ebx, %ebx
jmp 0xa8566
movl $0x8, %edi
callq 0xd214c
movq %rax, %rbx
movq 0x10(%r13), %rdi
callq 0x11b0a1
movq (%rsp), %rdi
movq %rbx, %rsi
movq %rax, %rdx
movq %r13, %rcx
movq %r14, %r8
callq 0x140a94
testl %eax, %eax
je 0xa83e6
movl %eax, %r12d
xorl %r13d, %r13d
movq (%rsp), %r14
jmp 0xa8566
xorl %edi, %edi
callq 0x14badb
movq %rax, 0x8(%rsp)
cmpb $0x1, 0x4d(%r13)
jne 0xa8403
movq 0x8(%rsp), %rdi
callq 0x14bbee
movq 0x10(%r13), %rdi
callq 0x11b0a1
leaq 0x28(%rsp), %rsi
movq (%rsp), %rdi
movq %rax, %rdx
movq %r14, %rcx
callq 0x140c40
testl %eax, %eax
je 0xa842c
movl %eax, %r12d
jmp 0xa855d
movq 0x10(%r13), %rdi
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
callq 0x16e820
movq %r14, %rdx
movq %rax, %r14
movq %rax, %rdi
movq 0x8(%rsp), %rsi
movq %rdx, 0x20(%rsp)
callq 0x14472c
movq %r14, %rdi
callq 0x1451a0
movq %rbx, %rdi
callq 0xd24e0
testq %rax, %rax
je 0xa855a
movq %rbp, 0x10(%rsp)
movq %r15, 0x18(%rsp)
xorl %ebp, %ebp
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xd2207
movq (%rax), %r12
movq %r12, %rdi
callq 0x144679
movq %rax, %r14
movq %rdx, %r15
movq %r12, %rdi
callq 0x143cab
testq %rax, %rax
je 0xa851d
cmpb $0x1, 0x4e(%r13)
jne 0xa84d0
movq 0x10(%r13), %rdi
leaq 0x29f52c(%rip), %rsi    # 0x3479e3
movq %r14, %rdx
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x1422f4
movq %r12, %rdi
movq %rax, %rsi
callq 0x14275f
cmpb $0x1, 0x4f(%r13)
jne 0xa851d
movq %r12, %rdi
leaq 0x2c3d6c(%rip), %r14    # 0x36c24d
movq %r14, %rsi
callq 0x141f50
testq %rax, %rax
je 0xa850b
movq %r12, %rdi
movq %r14, %rsi
leaq 0x2a486f(%rip), %rdx    # 0x34cd6a
callq 0x142a0f
movq %r12, %rdi
movq %r14, %rsi
callq 0x143349
movq %r12, %rdi
movq %r14, %rsi
leaq 0x2c267e(%rip), %rdx    # 0x36ab96
callq 0x14329d
movq %r12, %rdi
movq 0x8(%rsp), %rsi
movq 0x20(%rsp), %rdx
callq 0x14472c
movq %r12, %rdi
callq 0x1451a0
incq %rbp
movq %rbx, %rdi
callq 0xd24e0
xorl %r12d, %r12d
cmpq %rax, %rbp
jb 0xa847c
movq 0x18(%rsp), %r15
movq 0x10(%rsp), %rbp
jmp 0xa855d
xorl %r12d, %r12d
movq (%rsp), %r14
movq 0x8(%rsp), %r13
movq %rbx, %rdi
callq 0xd2938
movq %r13, %rdi
callq 0x1632f2
movq %r15, %rdi
callq 0x16bda0
movq %rbp, %rdi
callq 0x12579f
movq %r14, %rdi
callq 0x14070e
movl %r12d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1af3d
callq 0x1af04
nop