// File: /workspace/github_c_makefile_star2_O2/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 $0x48, %rsp
movq %r8, %r13
movq %rcx, %r12
testq %r8, %r8
je 0x2a64c
movq %r13, %rdi
callq 0x89eb7
testb %al, %al
jne 0x2a9f3
testq %r12, %r12
je 0x2a9c5
movq 0x18(%r12), %rdi
callq 0xad1fa
leaq 0x2eaea9(%rip), %rsi    # 0x31550f
movq %rax, %rdi
callq 0x179e0
pushq $-0x1
popq %rbp
testl %eax, %eax
je 0x2a736
xorl %r14d, %r14d
callq 0xb9186
testq %rax, %rax
je 0x2a778
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0xba686
testq %rax, %rax
je 0x2a7a7
movq %rax, %rbx
movq 0x10(%r12), %rdi
callq 0xad289
testq %rax, %rax
jne 0x2a6f8
movq %rbx, 0x10(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
callq 0xd7d67
testq %rax, %rax
je 0x2a999
movq %rax, %rbx
movq 0x10(%r12), %rdi
movq %rax, %rsi
callq 0xacbfb
leaq 0x2c2485(%rip), %rsi    # 0x2ecb6b
movq %rbx, %rdi
movl $0x10b, %edx            # imm = 0x10B
callq 0x936f9
movq 0x10(%rsp), %rbx
movq 0x50(%r12), %rdi
callq 0x9b4cb
testb %al, %al
jne 0x2a7ed
movq 0x10(%r12), %rdi
callq 0xad1fa
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
movq %r13, %rcx
callq 0xd7f1c
testl %eax, %eax
je 0x2a7ed
movq %rax, (%rsp)
xorl %r12d, %r12d
jmp 0x2a7b0
movq 0x20(%r12), %rdi
callq 0xad1fa
movq %rax, %rdi
callq 0x8da98
movl %eax, %ebx
movq 0x20(%r12), %rdi
callq 0xad1fa
testb %bl, %bl
je 0x2a784
movq %rax, %rdi
movq %r13, %rsi
callq 0x10d8b0
movq %rax, %r14
testq %rax, %rax
jne 0x2a67c
movq %rbp, (%rsp)
xorl %r12d, %r12d
jmp 0x2a79f
movq %rbp, (%rsp)
xorl %r12d, %r12d
xorl %r15d, %r15d
jmp 0x2a7ae
movq %rbp, (%rsp)
leaq 0x2c25c2(%rip), %rsi    # 0x2ecd51
xorl %r12d, %r12d
movq %r13, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x89dbb
xorl %r15d, %r15d
xorl %r14d, %r14d
jmp 0x2a7ae
movq %rbp, (%rsp)
xorl %r12d, %r12d
xorl %ebx, %ebx
xorl %ebp, %ebp
movq %rbp, %rdi
callq 0x58eb9
movq %r12, %rdi
callq 0x10327a
movq %r14, %rdi
callq 0x10d1a6
movq %r15, %rdi
callq 0xba5a3
movq %rbx, %rdi
callq 0xd7777
movq (%rsp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x8
popq %rdi
callq 0x5809c
movq %rax, %rbp
movq 0x10(%r12), %rdi
callq 0xad1fa
movq %rbx, %rdi
movq %rbp, %rsi
movq %rax, %rdx
movq %r12, %rcx
movq %r13, %r8
callq 0xd7c52
movq %rax, (%rsp)
testl %eax, %eax
je 0x2a823
xorl %r12d, %r12d
jmp 0x2a7b2
xorl %edi, %edi
callq 0xe64a1
movq %rax, 0x8(%rsp)
cmpb $0x1, 0x4d(%r12)
jne 0x2a841
movq 0x8(%rsp), %rdi
callq 0xe65ab
movq 0x10(%r12), %rdi
callq 0xad1fa
leaq 0x38(%rsp), %rsi
movq %rbx, %rdi
movq %rax, %rdx
movq %r13, %rcx
callq 0xd7f1c
movq %rax, (%rsp)
testl %eax, %eax
jne 0x2a9bb
movq %rbp, 0x30(%rsp)
movq %rbx, 0x10(%rsp)
movq %r15, 0x18(%rsp)
movq %r14, 0x20(%rsp)
movq 0x10(%r12), %rdi
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
callq 0x1110cc
movq %rax, %rbx
movq %rax, %rdi
movq 0x8(%rsp), %rsi
movq %r13, 0x28(%rsp)
movq %r13, %rdx
callq 0xdd39c
movq %rbx, %rdi
callq 0xde013
movq $0x0, (%rsp)
xorl %r13d, %r13d
movq 0x30(%rsp), %rbp
movq %rbp, %rdi
callq 0x586a4
cmpq %rax, %r13
jae 0x2a9ac
movq %rbp, %rdi
movq %r13, %rsi
callq 0x581aa
movq (%rax), %r14
movq %r14, %rdi
callq 0xdd1f4
movq %rax, %rbx
movq %rdx, %r15
movq %r14, %rdi
callq 0xdc2f0
testq %rax, %rax
je 0x2a977
cmpb $0x1, 0x4e(%r12)
jne 0x2a929
movq 0x10(%r12), %rdi
leaq 0x2bd0d3(%rip), %rsi    # 0x2e79e3
movq %rbx, %rdx
movq %r15, %rcx
xorl %r8d, %r8d
callq 0xd9acb
movq %r14, %rdi
movq %rax, %rsi
callq 0xda055
cmpb $0x1, 0x4f(%r12)
jne 0x2a977
movq %r14, %rdi
leaq 0x2e1bf2(%rip), %rbx    # 0x30c52d
movq %rbx, %rsi
callq 0xd9628
testq %rax, %rax
je 0x2a965
movq %r14, %rdi
movq %rbx, %rsi
leaq 0x2c2415(%rip), %rdx    # 0x2ecd6a
callq 0xda48b
movq %r14, %rdi
movq %rbx, %rsi
callq 0xdb4c4
movq %r14, %rdi
movq %rbx, %rsi
leaq 0x2e0184(%rip), %rdx    # 0x30aaf6
callq 0xdb38d
movq %r14, %rdi
movq 0x8(%rsp), %rsi
movq 0x28(%rsp), %rdx
callq 0xdd39c
movq %r14, %rdi
callq 0xde013
incq %r13
jmp 0x2a8c2
movq %rbp, (%rsp)
xorl %r12d, %r12d
xorl %ebp, %ebp
movq 0x10(%rsp), %rbx
jmp 0x2a7b2
movq 0x20(%rsp), %r14
movq 0x18(%rsp), %r15
movq 0x10(%rsp), %rbx
movq 0x8(%rsp), %r12
jmp 0x2a7b2
movq 0x40d59c(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2ba63d(%rip), %rsi    # 0x2e5013
leaq 0x31dc76(%rip), %rdx    # 0x348653
leaq 0x2c2356(%rip), %rcx    # 0x2ecd3a
leaq 0x2c2180(%rip), %r8     # 0x2ecb6b
movl $0xd7, %r9d
jmp 0x2aa1f
movq 0x40d56e(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2ba60f(%rip), %rsi    # 0x2e5013
leaq 0x2ba7b4(%rip), %rdx    # 0x2e51bf
leaq 0x2c2328(%rip), %rcx    # 0x2ecd3a
leaq 0x2c2152(%rip), %r8     # 0x2ecb6b
movl $0xd6, %r9d
xorl %eax, %eax
callq 0x17a50
callq 0x17390
nop