// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/extended/feature_in_stream.c
// Function: feature_in_stream_init
void feature_in_stream_init(GtFeatureInStream *stream)
{
  GtError *error;
  GtStrArray *seqids;
  GtUword i;

  error = gt_error_new();
  seqids = gt_feature_index_get_seqids(stream->fi, error);

  /* Load all region nodes into the cache */
  for (i = 0; i < gt_str_array_size(seqids); i++)
  {
    GtRange seqrange;
    GtGenomeNode *rn;
    GtStr *seqstr;
    const char *seqid;

    seqid = gt_str_array_get(seqids, i);
    if (stream->useorig)
    {
      gt_feature_index_get_orig_range_for_seqid(stream->fi, &seqrange, seqid,
                                                error);
    }
    else
    {
      gt_feature_index_get_range_for_seqid(stream->fi, &seqrange, seqid, error);
    }

    seqstr = gt_str_new_cstr(seqid);
    rn = gt_region_node_new(seqstr, seqrange.start, seqrange.end);
    gt_queue_add(stream->cache, rn);
    gt_str_delete(seqstr);
  }

  /* Load all feature nodes into the cache */
  for (i = 0; i < gt_str_array_size(seqids); i++)
  {
    GtArray *features;
    const char *seqid;

    seqid = gt_str_array_get(seqids, i);
    features = gt_feature_index_get_features_for_seqid(stream->fi, seqid,error);
    if (gt_array_size(features) > 0)
    {
      gt_array_sort(features, (GtCompare)gt_genome_node_compare);
      gt_array_reverse(features);
      while (gt_array_size(features) > 0)
      {
        GtGenomeNode **fn = gt_array_pop(features);
        gt_queue_add(stream->cache, *fn);
      }
    }
    gt_array_delete(features);
  }

  gt_error_delete(error);
  gt_str_array_delete(seqids);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
callq 0x1019b4
movq %rax, %r14
movq 0x10(%rbx), %rdi
movq %rax, %rsi
callq 0x147e36
movq %rax, %r15
movq %rax, %rdi
callq 0x121e78
testq %rax, %rax
je 0x1470e8
xorl %r12d, %r12d
leaq 0x8(%rsp), %r13
movq %r15, %rdi
movq %r12, %rsi
callq 0x121cfa
movq %rax, %rbp
movq 0x10(%rbx), %rdi
cmpb $0x1, 0x20(%rbx)
jne 0x147099
movq %r13, %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x147eeb
jmp 0x1470a7
movq %r13, %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x147e84
movq %rbp, %rdi
callq 0x120955
movq %rax, %rbp
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rax, %rdi
callq 0x176bac
movq 0x18(%rbx), %rdi
movq %rax, %rsi
callq 0x112923
movq %rbp, %rdi
callq 0x121b03
incq %r12
movq %r15, %rdi
callq 0x121e78
cmpq %rax, %r12
jb 0x147071
movq %r15, %rdi
callq 0x121e78
testq %rax, %rax
je 0x14717b
xorl %r12d, %r12d
leaq 0x48e3(%rip), %r13      # 0x14b9e6
movq %r15, %rdi
movq %r12, %rsi
callq 0x121cfa
movq 0x10(%rbx), %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x147c80
movq %rax, %rbp
movq %rax, %rdi
callq 0xd4a9a
testq %rax, %rax
je 0x147163
movq %rbp, %rdi
movq %r13, %rsi
callq 0xd4ae7
movq %rbp, %rdi
callq 0xd4906
movq %rbp, %rdi
callq 0xd4a9a
testq %rax, %rax
je 0x147163
movq %rbp, %rdi
callq 0xd47f5
movq 0x18(%rbx), %rdi
movq (%rax), %rsi
callq 0x112923
jmp 0x147140
movq %rbp, %rdi
callq 0xd4ef4
incq %r12
movq %r15, %rdi
callq 0x121e78
cmpq %rax, %r12
jb 0x147103
movq %r14, %rdi
callq 0x101b35
movq %r15, %rdi
callq 0x121e8b
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq