// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/ltr/ltr_refseq_match_stream.c
// Function: gt_ltr_refseq_match_stream_extract_sequences
static int gt_ltr_refseq_match_stream_extract_sequences(
                                                    GtLTRRefseqMatchStream *rms,
                                                    GtUword *n_to_check,
                                                    GtError *err)
{
  GtStr *seqid;
  GtGenomeNode *gn;
  GtFeatureNode *curnode;
  GtFeatureNodeIterator *fni;
  GtRange range;
  GtFile *outfp;
  GtEncseqLoader *el = NULL;
  GtEncseq *encseq = NULL;
  char header[BUFSIZ];
  const char *attr;
  int had_err = 0;
  GtUword i, seqnum, startpos;

  gt_assert(rms);
  gt_error_check(err);
  outfp = gt_file_new(rms->seq_file, "w", err);
  if (!outfp)
    had_err = -1;

  if (!had_err && !rms->rmap) {
    el = gt_encseq_loader_new();
    encseq = gt_encseq_loader_load(el, rms->indexname, err);
    if (!encseq)
      had_err = -1;
  }

  if (!had_err) {
    for (i = 0; i < gt_array_size(rms->nodes); i++) {
      gn = *(GtGenomeNode**) gt_array_get(rms->nodes, i);
      if (!gt_feature_node_try_cast(gn))
        continue;
      fni = gt_feature_node_iterator_new((GtFeatureNode*) gn);
      curnode = gt_feature_node_iterator_next(fni);
      seqid = gt_genome_node_get_seqid((GtGenomeNode*) curnode);
      range = gt_genome_node_get_range((GtGenomeNode*) curnode);
      if (rms->flcands) {
        attr = gt_feature_node_get_attribute(curnode, ATTR_FLCAND);
        if (!attr) {
          gt_feature_node_iterator_delete(fni);
          continue;
        }
      }
      attr = gt_feature_node_get_attribute(curnode, ATTR_LTRFAM);
      if (attr != NULL)
        (void) snprintf(header, BUFSIZ, "%s_%s_"GT_WU"_"GT_WU"", attr,
                        gt_str_get(seqid), range.start, range.end);
      else
        (void) snprintf(header, BUFSIZ, "%s_"GT_WU"_"GT_WU"", gt_str_get(seqid),
                        range.start, range.end);
      gt_cstr_rep(header, ' ', '+');
      gt_hashmap_add(rms->header_to_fn, (void*) gt_cstr_dup(header),
                     (void*) curnode);

      if (rms->rmap) {
        GtStr *seq = gt_str_new();
        had_err = gt_extract_feature_sequence(seq, (GtGenomeNode*) curnode,
                                              gt_feature_node_get_type(curnode),
                                              false, NULL, NULL,
                                              rms->rmap, err);
        if (!had_err) {
        gt_fasta_show_entry(header, gt_str_get(seq),
                            gt_str_length(seq), 50UL, outfp);
        }
        gt_str_delete(seq);
      } else {
        char *buffer = NULL;
        (void) sscanf(gt_str_get(seqid), "seq"GT_WU"", &seqnum);
        /* XXX errorcheck?! */
        buffer = gt_calloc((size_t) gt_range_length(&range) + 1, sizeof (char));
        startpos = gt_encseq_seqstartpos(encseq, seqnum);
        gt_encseq_extract_decoded(encseq, buffer, startpos + range.start - 1,
                                  startpos + range.end - 1);
        gt_fasta_show_entry(header, buffer, gt_range_length(&range), 50UL,
                            outfp);
        gt_free(buffer);
      }
      (*n_to_check)++;

      gt_feature_node_iterator_delete(fni);
    }
    gt_file_delete(outfp);
  }

  return had_err;
}

// Assembly:
subq $0x2118, %rsp           # imm = 0x2118
movq %rdi, 0x2110(%rsp)
movq %rsi, 0x2108(%rsp)
movq %rdx, 0x2100(%rsp)
movq $0x0, 0x20c0(%rsp)
movq $0x0, 0x20b8(%rsp)
movl $0x0, 0xa4(%rsp)
cmpq $0x0, 0x2110(%rsp)
jne 0x301615
movq 0x33a9bc(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x214a25(%rip), %rsi    # 0x516013
leaq 0x2abe79(%rip), %rdx    # 0x5ad46e
leaq 0x291381(%rip), %rcx    # 0x59297d
leaq 0x291358(%rip), %r8     # 0x59295b
movl $0x64, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x301617
jmp 0x301619
cmpq $0x0, 0x2100(%rsp)
je 0x30166f
movq 0x2100(%rsp), %rdi
callq 0xd8a60
testb $0x1, %al
jne 0x301637
jmp 0x30166f
movq 0x33a962(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2149cb(%rip), %rsi    # 0x516013
leaq 0x214b70(%rip), %rdx    # 0x5161bf
leaq 0x291327(%rip), %rcx    # 0x59297d
leaq 0x2912fe(%rip), %r8     # 0x59295b
movl $0x65, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x301671
movq 0x2110(%rsp), %rax
movq 0x38(%rax), %rdi
movq 0x2100(%rsp), %rdx
leaq 0x264839(%rip), %rsi    # 0x565ec5
callq 0xdd320
movq %rax, 0x20c8(%rsp)
cmpq $0x0, 0x20c8(%rsp)
jne 0x3016af
movl $0xffffffff, 0xa4(%rsp) # imm = 0xFFFFFFFF
cmpl $0x0, 0xa4(%rsp)
jne 0x301716
movq 0x2110(%rsp), %rax
cmpq $0x0, 0x48(%rax)
jne 0x301716
callq 0xb7a40
movq %rax, 0x20c0(%rsp)
movq 0x20c0(%rsp), %rdi
movq 0x2110(%rsp), %rax
movq 0x28(%rax), %rsi
movq 0x2100(%rsp), %rdx
callq 0xb7aa0
movq %rax, 0x20b8(%rsp)
cmpq $0x0, 0x20b8(%rsp)
jne 0x301714
movl $0xffffffff, 0xa4(%rsp) # imm = 0xFFFFFFFF
jmp 0x301716
cmpl $0x0, 0xa4(%rsp)
jne 0x301ba0
movq $0x0, 0x98(%rsp)
movq 0x98(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x2110(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x81370
movq %rax, %rcx
movq 0x60(%rsp), %rax
cmpq %rcx, %rax
jae 0x301b93
movq 0x2110(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x98(%rsp), %rsi
callq 0x80b60
movq (%rax), %rax
movq %rax, 0x20f0(%rsp)
movq 0x20f0(%rsp), %rdi
callq 0x170450
cmpq $0x0, %rax
jne 0x30179b
jmp 0x301b7a
movq 0x20f0(%rsp), %rdi
callq 0x170b00
movq %rax, 0x20e0(%rsp)
movq 0x20e0(%rsp), %rdi
callq 0x170e30
movq %rax, 0x20e8(%rsp)
movq 0x20e8(%rsp), %rdi
callq 0x171b70
movq %rax, 0x20f8(%rsp)
movq 0x20e8(%rsp), %rdi
callq 0x171cc0
movq %rax, 0x78(%rsp)
movq %rdx, 0x80(%rsp)
movq 0x78(%rsp), %rax
movq %rax, 0x20d0(%rsp)
movq 0x80(%rsp), %rax
movq %rax, 0x20d8(%rsp)
movq 0x2110(%rsp), %rax
testb $0x1, 0x62(%rax)
je 0x30185a
movq 0x20e8(%rsp), %rdi
leaq 0x29117c(%rip), %rsi    # 0x5929aa
callq 0x16c040
movq %rax, 0xa8(%rsp)
cmpq $0x0, 0xa8(%rsp)
jne 0x301858
movq 0x20e0(%rsp), %rdi
callq 0x170f50
jmp 0x301b7a
jmp 0x30185a
movq 0x20e8(%rsp), %rdi
leaq 0x290dcb(%rip), %rsi    # 0x592634
callq 0x16c040
movq %rax, 0xa8(%rsp)
cmpq $0x0, 0xa8(%rsp)
je 0x3018de
leaq 0xb0(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x20f8(%rsp), %rdi
callq 0x11dee0
movq 0x50(%rsp), %rdi
movq 0x58(%rsp), %rcx
movq %rax, %r8
movq 0x20d0(%rsp), %r9
movq 0x20d8(%rsp), %rax
movl $0x2000, %esi           # imm = 0x2000
leaq 0x2910e0(%rip), %rdx    # 0x5929b1
movq %rax, (%rsp)
movb $0x0, %al
callq 0x19b90
jmp 0x301923
leaq 0xb0(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x20f8(%rsp), %rdi
callq 0x11dee0
movq 0x48(%rsp), %rdi
movq %rax, %rcx
movq 0x20d0(%rsp), %r8
movq 0x20d8(%rsp), %r9
movl $0x2000, %esi           # imm = 0x2000
leaq 0x291098(%rip), %rdx    # 0x5929b4
movb $0x0, %al
callq 0x19b90
leaq 0xb0(%rsp), %rdi
movl $0x20, %esi
movl $0x2b, %edx
callq 0xa2ef0
movq 0x2110(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x40(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0xa2db0
movq 0x40(%rsp), %rdi
movq %rax, %rsi
movq 0x20e8(%rsp), %rdx
callq 0xe0fc0
movq 0x2110(%rsp), %rax
cmpq $0x0, 0x48(%rax)
je 0x301a4d
callq 0x11d4a0
movq %rax, 0x70(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x20e8(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x20e8(%rsp), %rdi
callq 0x16d430
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq %rax, %rdx
movq 0x2110(%rsp), %rax
movq 0x48(%rax), %r10
movq 0x2100(%rsp), %rax
xorl %ecx, %ecx
xorl %r8d, %r8d
movl %r8d, %r9d
movq %r9, %r8
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x48f4f0
movl %eax, 0xa4(%rsp)
cmpl $0x0, 0xa4(%rsp)
jne 0x301a3e
leaq 0xb0(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x70(%rsp), %rdi
callq 0x11dee0
movq %rax, 0x28(%rsp)
movq 0x70(%rsp), %rdi
callq 0x11dfa0
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq %rax, %rdx
movq 0x20c8(%rsp), %r8
movl $0x32, %ecx
callq 0xdbd10
movq 0x70(%rsp), %rdi
callq 0x11f560
jmp 0x301b5b
movq $0x0, 0x68(%rsp)
movq 0x20f8(%rsp), %rdi
callq 0x11dee0
movq %rax, %rdi
leaq 0x260d0b(%rip), %rsi    # 0x562778
leaq 0x90(%rsp), %rdx
movb $0x0, %al
callq 0x19770
leaq 0x20d0(%rsp), %rdi
callq 0x107320
movq %rax, %rdi
addq $0x1, %rdi
movl $0x1, %esi
leaq 0x290ebf(%rip), %rdx    # 0x59295b
movl $0x9b, %ecx
callq 0xe83c0
movq %rax, 0x68(%rsp)
movq 0x20b8(%rsp), %rdi
movq 0x90(%rsp), %rsi
callq 0xb0530
movq %rax, 0x88(%rsp)
movq 0x20b8(%rsp), %rdi
movq 0x68(%rsp), %rsi
movq 0x88(%rsp), %rdx
addq 0x20d0(%rsp), %rdx
subq $0x1, %rdx
movq 0x88(%rsp), %rcx
addq 0x20d8(%rsp), %rcx
subq $0x1, %rcx
callq 0xac570
leaq 0xb0(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0x20d0(%rsp), %rdi
callq 0x107320
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %rax, %rdx
movq 0x20c8(%rsp), %r8
movl $0x32, %ecx
callq 0xdbd10
movq 0x68(%rsp), %rdi
leaq 0x290e0a(%rip), %rsi    # 0x59295b
movl $0xa1, %edx
callq 0xe88c0
movq 0x2108(%rsp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq 0x20e0(%rsp), %rdi
callq 0x170f50
movq 0x98(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x98(%rsp)
jmp 0x301730
movq 0x20c8(%rsp), %rdi
callq 0xde430
movl 0xa4(%rsp), %eax
addq $0x2118, %rsp           # imm = 0x2118
retq
nop