// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/extended/anno_db_gfflike.c
// Function: get_nodes_for_stmt
static int get_nodes_for_stmt(GtFeatureIndexGFFlike *fi,
                              GtArray *results,
                              GtRDBStmt *stmt,
                              GtError *err)
{
  GtRDBStmt *attr_stmt, *parent_stmt;
  int had_err = 0;
  GtUword i;
  GtArray *nodes;
  bool is_child;
  gt_assert(fi && results && stmt);
  attr_stmt = fi->stmts[GT_PSTMT_GET_ATTRIBUTE_SELECT];
  parent_stmt = fi->stmts[GT_PSTMT_GET_PARENTS_SELECT];
  nodes = gt_array_new(sizeof (GtUword));
  HashElemInfo node_hashtype = {
    gt_ht_ptr_elem_hash,
    { NULL },
    sizeof (GtGenomeNode*),
    gt_ht_ptr_elem_cmp,
    NULL,
    NULL };
  GtHashtable *seen_as_children = gt_hashtable_new(node_hashtype);

  while (!had_err && gt_rdb_stmt_exec(stmt, err) == 0) {
    GtUword id = GT_UNDEF_UWORD, multi_rep = GT_UNDEF_UWORD, *idp;
    int phase, is_multi = 0, strand = GT_STRAND_UNKNOWN;
    GtGenomeNode *newgn;
    GtFeatureNode *newfn;
    GtStr *seqid_str, *source_str, *type_str;
    double score;
    GtRange rng;

    seqid_str = gt_str_new();
    source_str = gt_str_new();
    type_str = gt_str_new();

    gt_rdb_stmt_get_ulong(stmt, 0, &id, err);
    gt_rdb_stmt_get_string(stmt, 1, seqid_str, err);
    gt_rdb_stmt_get_string(stmt, 2, source_str, err);
    gt_rdb_stmt_get_string(stmt, 3, type_str, err);
    gt_rdb_stmt_get_ulong(stmt, 4, &rng.start, err);
    gt_rdb_stmt_get_ulong(stmt, 5, &rng.end, err);
    gt_rdb_stmt_get_double(stmt, 6, &score, err);
    gt_rdb_stmt_get_int(stmt, 7, &strand, err);
    gt_rdb_stmt_get_int(stmt, 8, &phase, err);
    gt_rdb_stmt_get_int(stmt, 9, &is_multi, err);
    if (is_multi)
      gt_rdb_stmt_get_ulong(stmt, 10, &multi_rep, err);

    /* did we hand out or store this node already? -> reuse reference */
    if ((ul_node_gt_hashmap_get(fi->cache_id2node, id)) != NULL) {

      gt_array_add(nodes, id);

    } else {     /* otherwise build new nodes from database info */

      /* create new node */
      newgn = gt_feature_node_new(seqid_str, gt_str_get(type_str), rng.start,
                                  rng.end,strand);
      newfn = gt_feature_node_cast(newgn);
      gt_feature_node_set_phase(newfn, phase);
      gt_feature_node_set_source(newfn, source_str);
      if (score != GT_UNDEF_DOUBLE)
        gt_feature_node_set_score(newfn, score);

      /* cache node */
      ul_node_gt_hashmap_add(fi->cache_id2node, id, newfn);
      if (!(idp = node_ul_gt_hashmap_get(fi->cache_node2id, newfn)))
      {
        node_ul_gt_hashmap_add(fi->cache_node2id, newfn, id);
      }

      /* assign attributes */
      gt_rdb_stmt_reset(attr_stmt, err);
      gt_rdb_stmt_bind_ulong(attr_stmt, 0, id, err);
      while (gt_rdb_stmt_exec(attr_stmt, err) == 0) {
        GtStr *key, *value;
        key = gt_str_new();
        value = gt_str_new();
        gt_rdb_stmt_get_string(attr_stmt, 0, key, err);
        gt_rdb_stmt_get_string(attr_stmt, 1, value, err);
        gt_feature_node_set_attribute(newfn, gt_str_get(key),
                                      gt_str_get(value));
        gt_str_delete(key);
        gt_str_delete(value);
      }

      /* is this a multi-feature? */
      if (is_multi) {
        if (multi_rep == 0UL) {
          gt_feature_node_make_multi_representative(newfn);
        } else {
          GtFeatureNode *rep;
          rep = *(GtFeatureNode**) ul_node_gt_hashmap_get(fi->cache_id2node,
                                                          multi_rep);
          gt_assert(rep);
          gt_feature_node_set_multi_representative(newfn, rep);
        }
      }
      gt_array_add(nodes, id);
    }
    gt_str_delete(seqid_str);
    gt_str_delete(source_str);
    gt_str_delete(type_str);
  }

  /* rebuild DAG */
  for (i=0;i<gt_array_size(nodes);i++) {
    GtUword id = *(GtUword*) gt_array_get(nodes, i);
    is_child = false;
    GtFeatureNode *newfn = *(GtFeatureNode**)
                                  ul_node_gt_hashmap_get(fi->cache_id2node, id);
    gt_assert(newfn);
    /* assign parents */
    gt_rdb_stmt_reset(parent_stmt, err);
    gt_rdb_stmt_bind_ulong(parent_stmt, 0, id, err);
    while (gt_rdb_stmt_exec(parent_stmt, err) == 0) {
      GtUword par_id;
      GtFeatureNode *parent;
      is_child = true;
      gt_rdb_stmt_get_ulong(parent_stmt, 0, &par_id, err);
      parent = *(GtFeatureNode**) ul_node_gt_hashmap_get(fi->cache_id2node,
                                                       par_id);
      gt_assert(parent);
      /* if a child has multiple parents, increase refcount */
      if (gt_hashtable_get(seen_as_children, &newfn)) {
        gt_genome_node_ref((GtGenomeNode*) newfn);
      }
      gt_feature_node_add_child(parent, newfn);
      gt_hashtable_add(seen_as_children, &newfn);
    }
    if (!is_child) {
      GtGenomeNode *newgn = (GtGenomeNode*) newfn;
      gt_array_add(results, newgn);
    }
  }
  for (i=0;i<gt_array_size(nodes);i++) {
    GtUword id = *(GtUword*) gt_array_get(nodes, i);
    GtFeatureNode *newfn = *(GtFeatureNode**)
                                  ul_node_gt_hashmap_get(fi->cache_id2node, id);
    gt_feature_node_set_observer(newfn, fi->obs);
  }
  gt_array_delete(nodes);
  gt_hashtable_delete(seen_as_children);
  return had_err;
}

// Assembly:
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rdi, 0x1a0(%rsp)
movq %rsi, 0x198(%rsp)
movq %rdx, 0x190(%rsp)
movq %rcx, 0x188(%rsp)
movl $0x0, 0x174(%rsp)
cmpq $0x0, 0x1a0(%rsp)
je 0x12e1c3
cmpq $0x0, 0x198(%rsp)
je 0x12e1c3
cmpq $0x0, 0x190(%rsp)
jne 0x12e1fb
movq 0x50ddd6(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3e7e3f(%rip), %rsi    # 0x516013
leaq 0x41a4c5(%rip), %rdx    # 0x5486a0
leaq 0x41a4d4(%rip), %rcx    # 0x5486b6
leaq 0x419265(%rip), %r8     # 0x54744e
movl $0x51b, %r9d            # imm = 0x51B
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x12e1fd
movq 0x1a0(%rsp), %rax
movq 0xd0(%rax), %rax
movq %rax, 0x180(%rsp)
movq 0x1a0(%rsp), %rax
movq 0xd8(%rax), %rax
movq %rax, 0x178(%rsp)
movl $0x8, %edi
callq 0x80990
movq %rax, 0x160(%rsp)
leaq 0x128(%rsp), %rdi
leaq 0x508324(%rip), %rsi    # 0x636570
movl $0x30, %edx
callq 0x19610
movups 0x128(%rsp), %xmm0
movups 0x138(%rsp), %xmm1
movups 0x148(%rsp), %xmm2
movq %rsp, %rax
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0xe1ad0
movq %rax, 0x120(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x174(%rsp)
movb %al, 0x67(%rsp)
jne 0x12e2b8
movq 0x190(%rsp), %rdi
movq 0x188(%rsp), %rsi
callq 0x1c4650
cmpl $0x0, %eax
sete %al
movb %al, 0x67(%rsp)
movb 0x67(%rsp), %al
testb $0x1, %al
jne 0x12e2c5
jmp 0x12e7fa
movq $-0x1, 0x118(%rsp)
movq $-0x1, 0x110(%rsp)
movl $0x0, 0x100(%rsp)
movl $0x3, 0xfc(%rsp)
callq 0x11d4a0
movq %rax, 0xe0(%rsp)
callq 0x11d4a0
movq %rax, 0xd8(%rsp)
callq 0x11d4a0
movq %rax, 0xd0(%rsp)
movq 0x190(%rsp), %rdi
movq 0x188(%rsp), %rcx
xorl %eax, %eax
movl %eax, %esi
leaq 0x118(%rsp), %rdx
callq 0x1c4780
movq 0x190(%rsp), %rdi
movq 0xe0(%rsp), %rdx
movq 0x188(%rsp), %rcx
movl $0x1, %esi
callq 0x1c4900
movq 0x190(%rsp), %rdi
movq 0xd8(%rsp), %rdx
movq 0x188(%rsp), %rcx
movl $0x2, %esi
callq 0x1c4900
movq 0x190(%rsp), %rdi
movq 0xd0(%rsp), %rdx
movq 0x188(%rsp), %rcx
movl $0x3, %esi
callq 0x1c4900
movq 0x190(%rsp), %rdi
leaq 0xb8(%rsp), %rdx
movq 0x188(%rsp), %rcx
movl $0x4, %esi
callq 0x1c4780
movq 0x190(%rsp), %rdi
leaq 0xb8(%rsp), %rdx
addq $0x8, %rdx
movq 0x188(%rsp), %rcx
movl $0x5, %esi
callq 0x1c4780
movq 0x190(%rsp), %rdi
movq 0x188(%rsp), %rcx
movl $0x6, %esi
leaq 0xc8(%rsp), %rdx
callq 0x1c49c0
movq 0x190(%rsp), %rdi
movq 0x188(%rsp), %rcx
movl $0x7, %esi
leaq 0xfc(%rsp), %rdx
callq 0x1c4840
movq 0x190(%rsp), %rdi
movq 0x188(%rsp), %rcx
movl $0x8, %esi
leaq 0x104(%rsp), %rdx
callq 0x1c4840
movq 0x190(%rsp), %rdi
movq 0x188(%rsp), %rcx
movl $0x9, %esi
leaq 0x100(%rsp), %rdx
callq 0x1c4840
cmpl $0x0, 0x100(%rsp)
je 0x12e49d
movq 0x190(%rsp), %rdi
movq 0x188(%rsp), %rcx
movl $0xa, %esi
leaq 0x110(%rsp), %rdx
callq 0x1c4780
movq 0x1a0(%rsp), %rax
movq 0x58(%rax), %rdi
movq 0x118(%rsp), %rsi
callq 0x131bd0
cmpq $0x0, %rax
je 0x12e4db
movq 0x160(%rsp), %rdi
leaq 0x118(%rsp), %rsi
movl $0x8, %edx
callq 0x81100
jmp 0x12e7ce
movq 0xe0(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0xd0(%rsp), %rdi
callq 0x11dee0
movq 0x58(%rsp), %rdi
movq %rax, %rsi
movq 0xb8(%rsp), %rdx
movq 0xc0(%rsp), %rcx
movl 0xfc(%rsp), %r8d
callq 0x16c7e0
movq %rax, 0xf0(%rsp)
movq 0xf0(%rsp), %rdi
callq 0x16c9b0
movq %rax, 0xe8(%rsp)
movq 0xe8(%rsp), %rdi
movl 0x104(%rsp), %esi
callq 0x16c250
movq 0xe8(%rsp), %rdi
movq 0xd8(%rsp), %rsi
callq 0x16c170
movsd 0xc8(%rsp), %xmm0
movsd 0x3ea7df(%rip), %xmm1   # 0x518d50
ucomisd %xmm1, %xmm0
jne 0x12e57b
jp 0x12e57b
jmp 0x12e595
movq 0xe8(%rsp), %rdi
movsd 0xc8(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x16d590
movq 0x1a0(%rsp), %rax
movq 0x58(%rax), %rdi
movq 0x118(%rsp), %rsi
movq 0xe8(%rsp), %rdx
callq 0x131b70
movq 0x1a0(%rsp), %rax
movq 0x50(%rax), %rdi
movq 0xe8(%rsp), %rsi
callq 0x131830
movq %rax, 0x108(%rsp)
cmpq $0x0, %rax
jne 0x12e5fe
movq 0x1a0(%rsp), %rax
movq 0x50(%rax), %rdi
movq 0xe8(%rsp), %rsi
movq 0x118(%rsp), %rdx
callq 0x131b10
movq 0x180(%rsp), %rdi
movq 0x188(%rsp), %rsi
callq 0x1c42f0
movq 0x180(%rsp), %rdi
movq 0x118(%rsp), %rdx
movq 0x188(%rsp), %rcx
xorl %eax, %eax
movl %eax, %esi
callq 0x1c4440
movq 0x180(%rsp), %rdi
movq 0x188(%rsp), %rsi
callq 0x1c4650
cmpl $0x0, %eax
jne 0x12e70c
callq 0x11d4a0
movq %rax, 0xb0(%rsp)
callq 0x11d4a0
movq %rax, 0xa8(%rsp)
movq 0x180(%rsp), %rdi
movq 0xb0(%rsp), %rdx
movq 0x188(%rsp), %rcx
xorl %eax, %eax
movl %eax, %esi
callq 0x1c4900
movq 0x180(%rsp), %rdi
movq 0xa8(%rsp), %rdx
movq 0x188(%rsp), %rcx
movl $0x1, %esi
callq 0x1c4900
movq 0xe8(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0xb0(%rsp), %rdi
callq 0x11dee0
movq %rax, 0x50(%rsp)
movq 0xa8(%rsp), %rdi
callq 0x11dee0
movq 0x48(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq %rax, %rdx
callq 0x16d660
movq 0xb0(%rsp), %rdi
callq 0x11f560
movq 0xa8(%rsp), %rdi
callq 0x11f560
jmp 0x12e634
cmpl $0x0, 0x100(%rsp)
je 0x12e7b4
cmpq $0x0, 0x110(%rsp)
jne 0x12e734
movq 0xe8(%rsp), %rdi
callq 0x16dbb0
jmp 0x12e7b2
movq 0x1a0(%rsp), %rax
movq 0x58(%rax), %rdi
movq 0x110(%rsp), %rsi
callq 0x131bd0
movq (%rax), %rax
movq %rax, 0xa0(%rsp)
cmpq $0x0, 0xa0(%rsp)
jne 0x12e79b
movq 0x50d836(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3e789f(%rip), %rsi    # 0x516013
leaq 0x4854b4(%rip), %rdx    # 0x5b3c2f
leaq 0x419f34(%rip), %rcx    # 0x5486b6
leaq 0x418cc5(%rip), %r8     # 0x54744e
movl $0x570, %r9d            # imm = 0x570
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x12e79d
movq 0xe8(%rsp), %rdi
movq 0xa0(%rsp), %rsi
callq 0x16dcf0
jmp 0x12e7b4
movq 0x160(%rsp), %rdi
leaq 0x118(%rsp), %rsi
movl $0x8, %edx
callq 0x81100
movq 0xe0(%rsp), %rdi
callq 0x11f560
movq 0xd8(%rsp), %rdi
callq 0x11f560
movq 0xd0(%rsp), %rdi
callq 0x11f560
jmp 0x12e289
movq $0x0, 0x168(%rsp)
movq 0x168(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x160(%rsp), %rdi
callq 0x81370
movq %rax, %rcx
movq 0x40(%rsp), %rax
cmpq %rcx, %rax
jae 0x12ea48
movq 0x160(%rsp), %rdi
movq 0x168(%rsp), %rsi
callq 0x80b60
movq (%rax), %rax
movq %rax, 0x98(%rsp)
movb $0x0, 0x15f(%rsp)
movq 0x1a0(%rsp), %rax
movq 0x58(%rax), %rdi
movq 0x98(%rsp), %rsi
callq 0x131bd0
movq (%rax), %rax
movq %rax, 0x90(%rsp)
cmpq $0x0, 0x90(%rsp)
jne 0x12e8c0
movq 0x50d711(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3e777a(%rip), %rsi    # 0x516013
leaq 0x419e29(%rip), %rdx    # 0x5486c9
leaq 0x419e0f(%rip), %rcx    # 0x5486b6
leaq 0x418ba0(%rip), %r8     # 0x54744e
movl $0x581, %r9d            # imm = 0x581
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x12e8c2
movq 0x178(%rsp), %rdi
movq 0x188(%rsp), %rsi
callq 0x1c42f0
movq 0x178(%rsp), %rdi
movq 0x98(%rsp), %rdx
movq 0x188(%rsp), %rcx
xorl %eax, %eax
movl %eax, %esi
callq 0x1c4440
movq 0x178(%rsp), %rdi
movq 0x188(%rsp), %rsi
callq 0x1c4650
cmpl $0x0, %eax
jne 0x12e9ff
movb $0x1, 0x15f(%rsp)
movq 0x178(%rsp), %rdi
movq 0x188(%rsp), %rcx
xorl %eax, %eax
movl %eax, %esi
leaq 0x88(%rsp), %rdx
callq 0x1c4780
movq 0x1a0(%rsp), %rax
movq 0x58(%rax), %rdi
movq 0x88(%rsp), %rsi
callq 0x131bd0
movq (%rax), %rax
movq %rax, 0x80(%rsp)
cmpq $0x0, 0x80(%rsp)
jne 0x12e9a6
movq 0x50d62b(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3e7694(%rip), %rsi    # 0x516013
leaq 0x44197b(%rip), %rdx    # 0x570301
leaq 0x419d29(%rip), %rcx    # 0x5486b6
leaq 0x418aba(%rip), %r8     # 0x54744e
movl $0x58c, %r9d            # imm = 0x58C
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x12e9a8
movq 0x120(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0xe1bc0
cmpq $0x0, %rax
je 0x12e9d0
movq 0x90(%rsp), %rdi
callq 0x171410
movq 0x80(%rsp), %rdi
movq 0x90(%rsp), %rsi
callq 0x16d010
movq 0x120(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0xe1d80
jmp 0x12e8f8
testb $0x1, 0x15f(%rsp)
jne 0x12ea2d
movq 0x90(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x198(%rsp), %rdi
leaq 0x78(%rsp), %rsi
movl $0x8, %edx
callq 0x81100
jmp 0x12ea2f
movq 0x168(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x168(%rsp)
jmp 0x12e806
movq $0x0, 0x168(%rsp)
movq 0x168(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x160(%rsp), %rdi
callq 0x81370
movq %rax, %rcx
movq 0x38(%rsp), %rax
cmpq %rcx, %rax
jae 0x12eae8
movq 0x160(%rsp), %rdi
movq 0x168(%rsp), %rsi
callq 0x80b60
movq (%rax), %rax
movq %rax, 0x70(%rsp)
movq 0x1a0(%rsp), %rax
movq 0x58(%rax), %rdi
movq 0x70(%rsp), %rsi
callq 0x131bd0
movq (%rax), %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rdi
movq 0x1a0(%rsp), %rax
movq 0x160(%rax), %rsi
callq 0x16c320
movq 0x168(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x168(%rsp)
jmp 0x12ea54
movq 0x160(%rsp), %rdi
callq 0x81f80
movq 0x120(%rsp), %rdi
callq 0xe3360
movl 0x174(%rsp), %eax
addq $0x1a8, %rsp            # imm = 0x1A8
retq
nopw %cs:(%rax,%rax)