// File: /workspace/github_c_makefile_star2_O0/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:
subq $0xe8, %rsp
movl %edi, 0xe4(%rsp)
movq %rsi, 0xd8(%rsp)
movl %edx, 0xd4(%rsp)
movq %rcx, 0xc8(%rsp)
movq %r8, 0xc0(%rsp)
movq 0xc8(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq $0x0, 0xb0(%rsp)
movq $0x0, 0xa8(%rsp)
movq $0x0, 0x90(%rsp)
movq $0x0, 0x88(%rsp)
movq $0x0, 0x80(%rsp)
movq $0x0, 0x78(%rsp)
movq $0x0, 0x70(%rsp)
movl $0x0, 0x6c(%rsp)
cmpq $0x0, 0xc0(%rsp)
je 0x375d9
movq 0xc0(%rsp), %rdi
callq 0xd8a60
testb $0x1, %al
jne 0x375a1
jmp 0x375d9
movq 0x6049f8(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x4dea61(%rip), %rsi    # 0x516013
leaq 0x4dec06(%rip), %rdx    # 0x5161bf
leaq 0x4e6817(%rip), %rcx    # 0x51ddd7
leaq 0x4e6641(%rip), %r8     # 0x51dc08
movl $0xd6, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x375db
jmp 0x375dd
cmpq $0x0, 0xb8(%rsp)
jne 0x37620
movq 0x6049b1(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x4dea1a(%rip), %rsi    # 0x516013
leaq 0x54355f(%rip), %rdx    # 0x57ab5f
leaq 0x4e67d0(%rip), %rcx    # 0x51ddd7
leaq 0x4e65fa(%rip), %r8     # 0x51dc08
movl $0xd7, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x37622
cmpl $0x0, 0x6c(%rsp)
jne 0x376f8
movq 0xb8(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x11dee0
movq %rax, %rdi
leaq 0x51069b(%rip), %rsi    # 0x547ce3
callq 0x19980
cmpl $0x0, %eax
jne 0x376f6
movq 0xb8(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x11dee0
movq %rax, %rdi
callq 0xde820
testb $0x1, %al
jne 0x376af
movq 0xc0(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0xb8(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x11dee0
movq 0x30(%rsp), %rdi
movq %rax, %rdx
leaq 0x4e674e(%rip), %rsi    # 0x51ddee
movb $0x0, %al
callq 0xd88c0
movl $0xffffffff, 0x6c(%rsp) # imm = 0xFFFFFFFF
cmpl $0x0, 0x6c(%rsp)
jne 0x376f4
movq 0xb8(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x11dee0
movq %rax, %rdi
movq 0xc0(%rsp), %rsi
callq 0x1c4a80
movq %rax, 0x90(%rsp)
cmpq $0x0, 0x90(%rsp)
jne 0x376f2
movl $0xffffffff, 0x6c(%rsp) # imm = 0xFFFFFFFF
jmp 0x376f4
jmp 0x376f6
jmp 0x376f8
cmpl $0x0, 0x6c(%rsp)
jne 0x3770c
callq 0x1308b0
movq %rax, 0x88(%rsp)
cmpl $0x0, 0x6c(%rsp)
jne 0x37726
cmpq $0x0, 0x88(%rsp)
jne 0x37726
movl $0xffffffff, 0x6c(%rsp) # imm = 0xFFFFFFFF
cmpl $0x0, 0x6c(%rsp)
jne 0x3776c
movq 0x88(%rsp), %rdi
movq 0x90(%rsp), %rsi
movq 0xc0(%rsp), %rdx
callq 0x132b50
movq %rax, 0xb0(%rsp)
movq 0xb0(%rsp), %rdx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movl %eax, 0x6c(%rsp)
cmpl $0x0, 0x6c(%rsp)
jne 0x377e4
movq 0xb8(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x11dfa0
cmpq $0x0, %rax
jne 0x377e4
movq 0xb0(%rsp), %rdi
movq 0xc0(%rsp), %rsi
callq 0x169c20
movq %rax, 0x60(%rsp)
cmpq $0x0, 0x60(%rsp)
jne 0x377b6
movl $0xffffffff, 0x6c(%rsp) # imm = 0xFFFFFFFF
jmp 0x377e2
movq 0xb8(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x60(%rsp), %rsi
callq 0x11d550
movq 0x60(%rsp), %rdi
leaq 0x4e6430(%rip), %rsi    # 0x51dc08
movl $0x10b, %edx            # imm = 0x10B
callq 0xe88c0
jmp 0x377e4
cmpl $0x0, 0x6c(%rsp)
jne 0x37849
movq 0xb8(%rsp), %rax
movq 0x50(%rax), %rdi
callq 0xf74a0
testb $0x1, %al
jne 0x37849
movq 0xb0(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0xb8(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x11dee0
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq %rax, %rdx
movq 0xc0(%rsp), %rcx
callq 0x169e70
movl %eax, 0x6c(%rsp)
cmpl $0x0, 0x6c(%rsp)
jne 0x378b3
movl $0x8, %edi
callq 0x80990
movq %rax, 0xa8(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0xb8(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x11dee0
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %rax, %rdx
movq 0xb8(%rsp), %rcx
movq 0xc0(%rsp), %r8
callq 0x169af0
movl %eax, 0x6c(%rsp)
cmpl $0x0, 0x6c(%rsp)
jne 0x37925
xorl %eax, %eax
movl %eax, %edi
callq 0x180280
movq %rax, 0x80(%rsp)
movq 0xb8(%rsp), %rax
testb $0x1, 0x4d(%rax)
je 0x378e6
movq 0x80(%rsp), %rdi
callq 0x180420
movq 0xb0(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0xb8(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x11dee0
movq 0x8(%rsp), %rdi
movq %rax, %rdx
movq 0xc0(%rsp), %rcx
leaq 0x98(%rsp), %rsi
callq 0x169e70
movl %eax, 0x6c(%rsp)
cmpl $0x0, 0x6c(%rsp)
jne 0x37add
movq 0xb8(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x98(%rsp), %rsi
movq 0xa0(%rsp), %rdx
callq 0x1ca610
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rdi
movq 0x80(%rsp), %rsi
movq 0xc0(%rsp), %rdx
callq 0x171f90
movq 0x78(%rsp), %rdi
callq 0x173180
movq $0x0, 0x70(%rsp)
movq 0x70(%rsp), %rax
movq %rax, (%rsp)
movq 0xa8(%rsp), %rdi
callq 0x81370
movq %rax, %rcx
movq (%rsp), %rax
cmpq %rcx, %rax
jae 0x37adb
movq 0xa8(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0x80b60
movq (%rax), %rax
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rdi
callq 0x171cc0
movq %rax, 0x48(%rsp)
movq %rdx, 0x50(%rsp)
movq 0x58(%rsp), %rdi
callq 0x170450
cmpq $0x0, %rax
je 0x37aa4
movq 0x58(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0xb8(%rsp), %rax
testb $0x1, 0x4e(%rax)
je 0x37a3c
movq 0xb8(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x48(%rsp), %rdx
movq 0x50(%rsp), %rcx
leaq 0x4e100b(%rip), %rsi    # 0x518a2b
xorl %r8d, %r8d
callq 0x16c7e0
movq %rax, 0x38(%rsp)
movq 0x58(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x16d010
movq 0xb8(%rsp), %rax
testb $0x1, 0x4f(%rax)
je 0x37aa2
movq 0x40(%rsp), %rdi
leaq 0x506447(%rip), %rsi    # 0x53de9d
callq 0x16c040
cmpq $0x0, %rax
je 0x37a8a
movq 0x40(%rsp), %rdi
leaq 0x506430(%rip), %rsi    # 0x53de9d
leaq 0x4e6393(%rip), %rdx    # 0x51de07
callq 0x16d660
movq 0x40(%rsp), %rdi
leaq 0x506418(%rip), %rsi    # 0x53de9d
callq 0x16ef50
movq 0x40(%rsp), %rdi
leaq 0x506407(%rip), %rsi    # 0x53de9d
leaq 0x504735(%rip), %rdx    # 0x53c1d2
callq 0x16edb0
jmp 0x37aa4
movq 0x58(%rsp), %rdi
movq 0x80(%rsp), %rsi
movq 0xc0(%rsp), %rdx
callq 0x171f90
movq 0x58(%rsp), %rdi
callq 0x173180
movq 0x70(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x70(%rsp)
jmp 0x37983
jmp 0x37add
movq 0xa8(%rsp), %rdi
callq 0x81f80
movq 0x80(%rsp), %rdi
callq 0x1b29d0
movq 0x90(%rsp), %rdi
callq 0x1c3d40
movq 0x88(%rsp), %rdi
callq 0x132a00
movq 0xb0(%rsp), %rdi
callq 0x169460
movl 0x6c(%rsp), %eax
addq $0xe8, %rsp
retq
nopw (%rax,%rax)