// File: /workspace/github_c_makefile_star2_O1/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, %rbp
testq %r8, %r8
movq %rcx, 0x8(%rsp)
je 0xaa5b4
movq %rbp, %rdi
callq 0x101a9a
testb %al, %al
movq 0x8(%rsp), %rcx
jne 0xaa91c
testq %rcx, %rcx
je 0xaa917
movq 0x18(%rcx), %rdi
movq %rcx, %r15
callq 0x120d23
leaq 0x2d3eaf(%rip), %rsi    # 0x37e47f
movq %rax, %rdi
callq 0x17a40
movb $0x1, %r14b
testl %eax, %eax
je 0xaa5e3
xorl %ebx, %ebx
jmp 0xaa63a
movq 0x20(%r15), %rdi
callq 0x120d23
movq %rax, %rdi
callq 0x10415c
movl %eax, %ebx
movq 0x20(%r15), %rdi
callq 0x120d23
testb %bl, %bl
je 0xaa61a
movq %rax, %rdi
movq %rbp, %rsi
callq 0x1742c4
testq %rax, %rax
je 0xaa635
movq %rax, %r15
xorl %ebx, %ebx
jmp 0xaa63d
leaq 0x2ab75f(%rip), %rsi    # 0x355d80
xorl %r14d, %r14d
movq %rbp, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1019cf
movb $0x1, %bl
jmp 0xaa63a
movb $0x1, %bl
xorl %r14d, %r14d
xorl %r15d, %r15d
testb %bl, %bl
je 0xaa645
xorl %eax, %eax
jmp 0xaa64a
callq 0x12a404
testq %rax, %rax
setne %cl
orb %cl, %bl
andb %bl, %r14b
cmpb $0x1, %r14b
movq %rax, 0x28(%rsp)
jne 0xaa679
movq %rax, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x12b644
movq %rax, %r12
testq %rax, %rax
setne %al
jmp 0xaa67e
xorl %eax, %eax
xorl %r12d, %r12d
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testb %al, %al
je 0xaa705
movq 0x8(%rsp), %r14
movq 0x10(%r14), %rdi
callq 0x120d4c
testq %rax, %rax
jne 0xaa6d3
movq %r12, %rdi
movq %rbp, %rsi
callq 0x147d91
testq %rax, %rax
je 0xaa705
movq %rax, %rbx
movq 0x8(%rsp), %r14
movq 0x10(%r14), %rdi
movq %rax, %rsi
callq 0x12097f
leaq 0x2ab4d4(%rip), %rsi    # 0x355b9a
movq %rbx, %rdi
movl $0x10b, %edx            # imm = 0x10B
callq 0x109670
movq 0x50(%r14), %rdi
callq 0x10fe52
xorl %r13d, %r13d
testb %al, %al
jne 0xaa705
movq 0x8(%rsp), %rbx
movq 0x10(%rbx), %rdi
callq 0x120d23
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movq %rbp, %rcx
callq 0x147e84
movl %eax, %r13d
movq %r15, 0x30(%rsp)
testl %r13d, %r13d
je 0xaa714
xorl %r15d, %r15d
jmp 0xaa746
movl $0x8, %edi
callq 0xd46fc
movq %rax, %r15
movq 0x8(%rsp), %rbx
movq 0x10(%rbx), %rdi
callq 0x120d23
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
movq %rbx, %rcx
movq %rbp, %r8
callq 0x147cd8
movl %eax, %r13d
testl %r13d, %r13d
movq %r12, 0x20(%rsp)
je 0xaa75b
movq $0x0, 0x10(%rsp)
jmp 0xaa7a0
xorl %edi, %edi
callq 0x1530bc
movq %rax, 0x10(%rsp)
movq 0x8(%rsp), %rax
cmpb $0x1, 0x4d(%rax)
jne 0xaa781
movq 0x10(%rsp), %rdi
callq 0x1531cf
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x120d23
leaq 0x38(%rsp), %rsi
movq %r12, %rdi
movq %rax, %rdx
movq %rbp, %rcx
callq 0x147e84
movl %eax, %r13d
movl %r13d, 0x1c(%rsp)
testl %r13d, %r13d
jne 0xaa8d4
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
callq 0x176bac
movq %rax, %rbx
movq %rax, %rdi
movq 0x10(%rsp), %rsi
movq %rbp, %rdx
callq 0x14b992
movq %rbx, %rdi
callq 0x14c43a
movq %r15, %rdi
callq 0xd4a9a
testq %rax, %rax
je 0xaa8d4
xorl %r13d, %r13d
movq %rbp, %r12
movq %r15, %rdi
movq %r13, %rsi
callq 0xd47ba
movq (%rax), %rbx
movq %rbx, %rdi
callq 0x14b8df
movq %rax, %rbp
movq %rdx, %r14
movq %rbx, %rdi
callq 0x14aefc
testq %rax, %rax
je 0xaa8a5
movq 0x8(%rsp), %rax
cmpb $0x1, 0x4e(%rax)
jne 0xaa859
movq 0x10(%rax), %rdi
leaq 0x2a61a8(%rip), %rsi    # 0x3509e3
movq %rbp, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x14952c
movq %rbx, %rdi
movq %rax, %rsi
callq 0x149997
movq 0x8(%rsp), %rax
cmpb $0x1, 0x4f(%rax)
jne 0xaa8a5
movq %rbx, %rdi
leaq 0x2cac34(%rip), %r14    # 0x37549d
movq %r14, %rsi
callq 0x14918c
testq %rax, %rax
je 0xaa893
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x2ab516(%rip), %rdx    # 0x355d99
callq 0x149c3c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x14a57e
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x2c9546(%rip), %rdx    # 0x373de6
callq 0x14a4d2
movq %rbx, %rdi
movq 0x10(%rsp), %rsi
movq %r12, %rbp
movq %r12, %rdx
callq 0x14b992
movq %rbx, %rdi
callq 0x14c43a
incq %r13
movq %r15, %rdi
callq 0xd4a9a
cmpq %rax, %r13
jb 0xaa7f5
movq %r15, %rdi
callq 0xd4ef4
movq 0x10(%rsp), %rdi
callq 0x16b162
movq 0x30(%rsp), %rdi
callq 0x173fb0
movq 0x28(%rsp), %rdi
callq 0x12b5bf
movq 0x20(%rsp), %rdi
callq 0x147952
movl 0x1c(%rsp), %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1b000
callq 0x1afc7
nopl (%rax)