// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/ltr/ltrharvest_fasta_out_visitor.c
// Function: gt_ltrharvest_fasta_out_visitor_feature_node
static int gt_ltrharvest_fasta_out_visitor_feature_node(GtNodeVisitor *nv,
                                                        GtFeatureNode *fn,
                                                        GT_UNUSED GtError *err)
{
  GtLTRharvestFastaOutVisitor *lv;
  GtFeatureNodeIterator *fni;
  GtFeatureNode *curnode = NULL,
                *leftltr = NULL,
                *rightltr = NULL,
                *ltr_retrotrans = NULL;
  int had_err = 0,
      added_ltr = 0;
  GtRange rng,
          outrng;
  GtUword seqnum = GT_UNDEF_UWORD;
  const char *fnt;
  lv = gt_ltrharvest_fasta_out_visitor_cast(nv);
  gt_assert(lv);
  gt_error_check(err);

  /* traverse annotation subgraph and collect info */
  fni = gt_feature_node_iterator_new(fn);
  while (!had_err && (curnode = gt_feature_node_iterator_next(fni))) {
    fnt = gt_feature_node_get_type(curnode);

    if (strcmp(fnt, gt_ft_LTR_retrotransposon) == 0)
    {
      const char *val;
      ltr_retrotrans = curnode;
      val = gt_feature_node_get_attribute(curnode, "seq_number");
      if (val == NULL) {
        gt_error_set(err, "missing attribute \"seq_number\"");
        had_err = -1;
      }
      if (!had_err) {
        (void) gt_parse_uword(&seqnum, val);
      }
    }
    if (strcmp(fnt, gt_ft_long_terminal_repeat) == 0)
    {
      switch (added_ltr) {
        case 0:
          leftltr = curnode;
          break;
        case 1:
          rightltr = curnode;
          break;
        default:
          gt_error_set(err,
                       "invalid number of LTR annotations: more than 2");
          had_err = -1;
      }
      added_ltr++;
    }
  }
  gt_feature_node_iterator_delete(fni);

  /* check for invalid annotations */
  if (!had_err && (!leftltr || !rightltr)) {
    gt_error_set(err, "missing LTR annotations");
    had_err = -1;
  }

  /* determine sequence interval to output */
  if (lv->inner) {
    gt_assert(leftltr && rightltr);
    rng = gt_genome_node_get_range((GtGenomeNode*) leftltr);
    outrng.start = rng.end + 1;
    rng = gt_genome_node_get_range((GtGenomeNode*) rightltr);
    outrng.end = rng.start - 1;
  } else {
    gt_assert(ltr_retrotrans);
    rng = gt_genome_node_get_range((GtGenomeNode*) ltr_retrotrans);
    outrng = rng;
  }

  /* output FASTA sequences */
  if (!had_err && ltr_retrotrans != NULL) {
    if (outrng.start < outrng.end) {
      char *buf;
      const char *seqdesc;
      GtStr *desc;
      GtUword startpos,
                    seqdesclen;
      gt_assert(seqnum != GT_UNDEF_UWORD
                  && seqnum < gt_encseq_num_of_sequences(lv->encseq));
      seqdesc = gt_encseq_description(lv->encseq, &seqdesclen, seqnum);
      desc = gt_str_new();
      gt_str_append_cstr_nt(desc, seqdesc, seqdesclen);
      gt_str_append_cstr(desc, " (dbseq-nr ");
      gt_str_append_uword(desc, seqnum);
      gt_str_append_cstr(desc, ") [");
      gt_str_append_uword(desc, outrng.start);
      gt_str_append_cstr(desc, ",");
      gt_str_append_uword(desc, outrng.end);
      gt_str_append_cstr(desc, "]");
      buf = gt_calloc((size_t) gt_range_length(&outrng) + 1, sizeof (char));
      startpos = gt_encseq_seqstartpos(lv->encseq, seqnum);
      gt_encseq_extract_decoded(lv->encseq, buf,
                                startpos + outrng.start - 1,
                                startpos + outrng.end - 1);
      gt_fasta_show_entry(gt_str_get(desc), buf, gt_range_length(&outrng),
                          lv->width, lv->outfp);
      gt_free(buf);
      gt_str_delete(desc);
    } else {
      GtRange rootrng;
      rootrng = gt_genome_node_get_range((GtGenomeNode*) ltr_retrotrans);
      gt_warning("trying to output empty%s sequence for candidate at "
                 ""GT_WU"-"GT_WU" on sequence "GT_WU"",
                 (lv->inner ? " inner" : ""),
                 rootrng.start,
                 rootrng.end,
                 seqnum);
    }
  }

  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
orq $-0x1, 0x8(%rsp)
callq 0x1c37a8
movq %rax, %rdi
movq %r14, %rsi
callq 0x102dfe
testq %rax, %rax
je 0x1c3ba8
movq %rax, 0x18(%rsp)
testq %r15, %r15
je 0x1c383b
movq %r15, %rdi
callq 0x89eb7
testb %al, %al
jne 0x1c3bd2
movq %r15, 0x10(%rsp)
movq %rbx, %rdi
callq 0xdc6f0
movq %rax, %rbp
xorl %r13d, %r13d
xorl %r12d, %r12d
xorl %ebx, %ebx
movq $0x0, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
testl %r12d, %r12d
jne 0x1c392f
movq %rbp, %rdi
callq 0xdc92e
testq %rax, %rax
je 0x1c394f
movq %rax, %r14
movq %rax, %rdi
callq 0xda338
movq %rax, %r15
movq %rax, %rdi
leaq 0x17168f(%rip), %rsi    # 0x334f26
callq 0x179e0
xorl %r12d, %r12d
testl %eax, %eax
jne 0x1c38e0
movq %r14, %rdi
leaq 0x19d981(%rip), %rsi    # 0x36122e
callq 0xd9628
testq %rax, %rax
je 0x1c38c6
leaq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x9bd05
jmp 0x1c38dd
movq 0x10(%rsp), %rdi
leaq 0x19d967(%rip), %rsi    # 0x361239
xorl %eax, %eax
callq 0x89dbb
pushq $-0x1
popq %r12
movq %r14, %rbx
movq %r15, %rdi
leaq 0x173f27(%rip), %rsi    # 0x337811
callq 0x179e0
testl %eax, %eax
jne 0x1c3865
testl %r13d, %r13d
je 0x1c3909
cmpl $0x1, %r13d
jne 0x1c3910
movq %r14, 0x28(%rsp)
jmp 0x1c3927
movq %r14, 0x20(%rsp)
jmp 0x1c3927
movq 0x10(%rsp), %rdi
leaq 0x19d93c(%rip), %rsi    # 0x361258
xorl %eax, %eax
callq 0x89dbb
pushq $-0x1
popq %r12
incl %r13d
jmp 0x1c3865
movq %rbp, %rdi
callq 0xdc9f1
pushq $-0x1
popq %r12
xorl %r14d, %r14d
movq 0x18(%rsp), %rbp
movq 0x28(%rsp), %r15
movq 0x20(%rsp), %r13
jmp 0x1c3998
movq %rbp, %rdi
callq 0xdc9f1
movq 0x20(%rsp), %r13
testq %r13, %r13
setne %al
movq 0x28(%rsp), %r15
testq %r15, %r15
setne %cl
testb %cl, %al
je 0x1c3979
xorl %r12d, %r12d
movb $0x1, %r14b
jmp 0x1c3993
leaq 0x19d907(%rip), %rsi    # 0x361287
xorl %r14d, %r14d
movq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x89dbb
pushq $-0x1
popq %r12
movq 0x18(%rsp), %rbp
cmpb $0x1, 0x20(%rbp)
jne 0x1c39d0
testq %r13, %r13
je 0x1c3c26
testq %r15, %r15
je 0x1c3c26
movq %r13, %rdi
callq 0xdd1f4
incq %rdx
movq %rdx, 0x30(%rsp)
movq %r15, %rdi
callq 0xdd1f4
movq %rax, %r15
decq %r15
jmp 0x1c39e9
testq %rbx, %rbx
je 0x1c3bfc
movq %rbx, %rdi
callq 0xdd1f4
movq %rdx, %r15
movq %rax, 0x30(%rsp)
movq %r15, 0x38(%rsp)
testq %rbx, %rbx
setne %al
andb %al, %r14b
cmpb $0x1, %r14b
jne 0x1c3b96
movq 0x30(%rsp), %r14
cmpq %r15, %r14
jae 0x1c3b5f
movl %r12d, 0x10(%rsp)
movq 0x8(%rsp), %rbx
cmpq $-0x1, %rbx
je 0x1c3c5c
movq 0x28(%rbp), %rdi
callq 0x705a1
cmpq %rax, %rbx
jae 0x1c3c5c
movq 0x28(%rbp), %rdi
movq 0x8(%rsp), %rdx
leaq 0x40(%rsp), %r12
movq %r12, %rsi
callq 0x75b24
movq %rax, %r13
callq 0xacb84
movq %rax, %rbx
movq (%r12), %rdx
movq %rax, %rdi
movq %r13, %rsi
callq 0xacd9e
leaq 0x19d8a2(%rip), %rsi    # 0x36130e
movq %rbx, %rdi
callq 0xacbfb
movq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0xace26
leaq 0x19d892(%rip), %rsi    # 0x36131a
movq %rbx, %rdi
callq 0xacbfb
movq %rbx, %rdi
movq %r14, %rsi
callq 0xace26
leaq 0x17d989(%rip), %rsi    # 0x34142b
movq %rbx, %rdi
callq 0xacbfb
movq %rbx, %rdi
movq %r15, %rsi
callq 0xace26
leaq 0x1a4726(%rip), %rsi    # 0x3681e2
movq %rbx, %rdi
callq 0xacbfb
leaq 0x30(%rsp), %r15
movq %r15, %rdi
callq 0xa31ee
leaq 0x1(%rax), %rdi
leaq 0x19d6fe(%rip), %r14    # 0x3611da
pushq $0x1
popq %rsi
movq %r14, %rdx
movl $0x90, %ecx
callq 0x9334a
movq %rax, %r12
movq 0x28(%rbp), %rdi
movq 0x8(%rsp), %rsi
callq 0x74d9c
movq 0x28(%rbp), %rdi
leaq -0x1(%rax), %rcx
movq (%r15), %rdx
addq %rcx, %rdx
addq 0x8(%r15), %rcx
movq %r12, %rsi
callq 0x7239d
movq %rbx, %rdi
callq 0xad1fa
movq %rax, %r13
movq %r15, %rdi
callq 0xa31ee
movq 0x10(%rbp), %r8
movq 0x18(%rbp), %rcx
movq %r13, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x8c0bc
movq %r12, %rdi
movq %r14, %rsi
movl $0x97, %edx
callq 0x936f9
movq %rbx, %rdi
callq 0xae103
movl 0x10(%rsp), %r12d
jmp 0x1c3b96
movq %rbx, %rdi
callq 0xdd1f4
movq %rdx, %rcx
leaq 0x19d7f8(%rip), %rdx    # 0x361369
cmpb $0x0, 0x20(%rbp)
leaq 0x1a69f4(%rip), %rsi    # 0x36a570
cmovneq %rdx, %rsi
movq 0x8(%rsp), %r8
leaq 0x19d792(%rip), %rdi    # 0x36131e
movq %rax, %rdx
xorl %eax, %eax
callq 0xb2cd0
movl %r12d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2743b9(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x12145a(%rip), %rsi    # 0x2e5013
leaq 0x19c781(%rip), %rdx    # 0x360341
leaq 0x19d63a(%rip), %rcx    # 0x361201
leaq 0x19d60c(%rip), %r8     # 0x3611da
pushq $0x41
jmp 0x1c3c4e
movq 0x27438f(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x121430(%rip), %rsi    # 0x2e5013
leaq 0x1215d5(%rip), %rdx    # 0x2e51bf
leaq 0x19d610(%rip), %rcx    # 0x361201
leaq 0x19d5e2(%rip), %r8     # 0x3611da
pushq $0x42
jmp 0x1c3c4e
movq 0x274365(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x121406(%rip), %rsi    # 0x2e5013
leaq 0x19d69f(%rip), %rdx    # 0x3612b3
leaq 0x19d5e6(%rip), %rcx    # 0x361201
leaq 0x19d5b8(%rip), %r8     # 0x3611da
pushq $0x77
jmp 0x1c3c4e
movq 0x27433b(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1213dc(%rip), %rsi    # 0x2e5013
leaq 0x19d661(%rip), %rdx    # 0x36129f
leaq 0x19d5bc(%rip), %rcx    # 0x361201
leaq 0x19d58e(%rip), %r8     # 0x3611da
pushq $0x71
popq %r9
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x274305(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1213a6(%rip), %rsi    # 0x2e5013
leaq 0x19d64e(%rip), %rdx    # 0x3612c2
leaq 0x19d586(%rip), %rcx    # 0x361201
leaq 0x19d558(%rip), %r8     # 0x3611da
movl $0x85, %r9d
jmp 0x1c3c50