// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/ltr/ltrharvest_tabout_visitor.c
// Function: gt_ltrharvest_tabout_visitor_feature_node
static int gt_ltrharvest_tabout_visitor_feature_node(GtNodeVisitor *nv,
                                                     GtFeatureNode *fn,
                                                     GT_UNUSED GtError *err)
{
  GtLTRharvestTaboutVisitor *lv;
  GtFeatureNodeIterator *fni;
  GtFeatureNode *curnode = NULL,
                *leftltr = NULL,
                *rightltr = NULL,
                *ltr_retrotrans = NULL,
                *lefttsd = NULL,
                *righttsd = NULL,
                *leftmotif_5 = NULL,
                *leftmotif_3 = NULL,
                *rightmotif_5 = NULL,
                *rightmotif_3 = NULL;
  int had_err = 0,
      added_motifs = 0,
      added_tsd = 0,
      added_ltr = 0;
  GtStr *line;
  GtRange rng;
  bool no_element = false;
  GtUword seqnum = 0;
  const char *fnt;
  char buf[BUFSIZ];
  lv = gt_ltrharvest_tabout_visitor_cast(nv);
  gt_assert(lv);
  gt_error_check(err);

  line = gt_str_new();
  /* 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++;
    }
    if (strcmp(fnt, gt_ft_inverted_repeat) == 0)
    {
      switch (added_motifs) {
        case 0:
          leftmotif_5 = curnode;
          break;
        case 1:
          leftmotif_3 = curnode;
          break;
        case 2:
          rightmotif_5 = curnode;
          break;
        case 3:
          rightmotif_3 = curnode;
          break;
        default:
          gt_error_set(err,
                       "invalid number of motif annotations: more than 4");
          had_err = -1;
          break;
      }
      added_motifs++;
    }
    if (strcmp(fnt, gt_ft_target_site_duplication) == 0)
    {
      switch (added_tsd) {
        case 0:
          lefttsd = curnode;
          break;
        case 1:
          righttsd = curnode;
          break;
        default:
          gt_error_set(err,
                       "invalid number of TSD annotations: more than 2");
          had_err = -1;
      }
      added_tsd++;
    }
  }
  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;
  }
  if (lv->longoutput) {
    if (!had_err && added_motifs > 0 && added_motifs != 4) {
      gt_error_set(err, "invalid number of motif annotations, != 4");
      had_err = -1;
    }
    if (!had_err && added_tsd > 0 && added_tsd != 2) {
      gt_error_set(err, "invalid number of TSD annotations, != 2");
      had_err = -1;
    }
  }

  /* output in tabular format */
  if (!had_err) {
    if (ltr_retrotrans != NULL) {
      /* whole element */
      rng = gt_genome_node_get_range((GtGenomeNode*) ltr_retrotrans);
      (void) snprintf(buf, BUFSIZ-1, ""GT_WU"  "GT_WU"  "GT_WU"  ", rng.start,
                      rng.end, gt_range_length(&rng));
      gt_str_append_cstr(line, buf);
    } else {
      no_element = true;
    }
  }

  if (!had_err && !no_element) {
    /* left LTR */
    rng = gt_genome_node_get_range((GtGenomeNode*) leftltr);
    (void) snprintf(buf, BUFSIZ-1, ""GT_WU"  "GT_WU"  "GT_WU"  ", rng.start,
                    rng.end, gt_range_length(&rng));
    gt_str_append_cstr(line, buf);
    /* left TSD */
    if (lv->longoutput && added_tsd > 0 ) {
      gt_assert(lefttsd);
      gt_ltrharvest_tabout_visitor_seq4feat(lv, lefttsd, line, seqnum);
      gt_str_append_cstr(line, "  ");
      rng = gt_genome_node_get_range((GtGenomeNode*) lefttsd);
      gt_str_append_uword(line, gt_range_length(&rng));
      gt_str_append_cstr(line, "  ");
    }
    /* left motif */
    if (lv->longoutput && added_motifs > 0 ) {
      gt_assert(leftmotif_5 && leftmotif_3);
      gt_ltrharvest_tabout_visitor_seq4feat(lv, leftmotif_5, line, seqnum);
      gt_str_append_cstr(line, "..");
      gt_ltrharvest_tabout_visitor_seq4feat(lv, leftmotif_3, line, seqnum);
      gt_str_append_cstr(line, "  ");
    }

    /* right LTR */
    rng = gt_genome_node_get_range((GtGenomeNode*) rightltr);
    (void) snprintf(buf, BUFSIZ-1, ""GT_WU"  "GT_WU"  "GT_WU"  ", rng.start,
                    rng.end, gt_range_length(&rng));
    gt_str_append_cstr(line, buf);
    /* right TSD */
    if (lv->longoutput && added_tsd > 0 ) {
      gt_assert(righttsd);
      gt_ltrharvest_tabout_visitor_seq4feat(lv, righttsd, line, seqnum);
      gt_str_append_cstr(line, "  ");
      rng = gt_genome_node_get_range((GtGenomeNode*) righttsd);
      gt_str_append_uword(line, gt_range_length(&rng));
      gt_str_append_cstr(line, "  ");
    }
    /* right motif */
    if (lv->longoutput && added_motifs > 0 ) {
      gt_assert(rightmotif_5 && rightmotif_3);
      gt_ltrharvest_tabout_visitor_seq4feat(lv, rightmotif_5, line, seqnum);
      gt_str_append_cstr(line, "..");
      gt_ltrharvest_tabout_visitor_seq4feat(lv, rightmotif_3, line, seqnum);
      gt_str_append_cstr(line, "  ");
    }

    gt_str_append_cstr(line, gt_feature_node_get_attribute(ltr_retrotrans,
                                                           "ltr_similarity"));
    gt_str_append_cstr(line, "  ");
    gt_str_append_uword(line, seqnum);
    printf("%s\n", gt_str_get(line));
  }
  gt_str_delete(line);
  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2088, %rsp           # imm = 0x2088
movq %rdx, %r13
movq %rsi, %rbx
movq %rdi, %r14
movq $0x0, 0x10(%rsp)
callq 0x21b60c
movq %rax, %rdi
movq %r14, %rsi
callq 0x16af21
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x21bcf3
testq %r13, %r13
je 0x21b6aa
movq %r13, %rdi
callq 0x101a9a
testb %al, %al
jne 0x21bcf8
callq 0x1208f8
movq %rax, 0x8(%rsp)
movq %rbx, %rdi
callq 0x14b1a8
movq %rax, 0x38(%rsp)
movq $0x0, 0x30(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
movq $0x0, 0x68(%rsp)
movq $0x0, 0x60(%rsp)
movq $0x0, 0x50(%rsp)
movq $0x0, 0x58(%rsp)
movq $0x0, 0x40(%rsp)
movq $0x0, 0x48(%rsp)
movl $0x0, 0x4(%rsp)
xorl %r14d, %r14d
xorl %eax, %eax
movl %eax, %ebx
movq 0x38(%rsp), %rdi
callq 0x14b33e
testq %rax, %rax
je 0x21b8c5
movq %rax, %r15
movq %rax, %rdi
callq 0x149bb2
movq %rax, %rbp
movq %rax, %rdi
leaq 0x182912(%rip), %rsi    # 0x39e05e
callq 0x17a40
xorl %r12d, %r12d
testl %eax, %eax
jne 0x21b7a8
movl %r14d, (%rsp)
movq %r15, %rdi
leaq 0x1aed7c(%rip), %rsi    # 0x3ca4e2
callq 0x14918c
movq %rax, %r14
xorl %r12d, %r12d
testq %rax, %rax
jne 0x21b78d
movq %r13, %rdi
leaq 0x1aed6d(%rip), %rsi    # 0x3ca4ed
xorl %eax, %eax
callq 0x1019cf
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
testq %r14, %r14
je 0x21b79f
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x11043f
movq %r15, 0x20(%rsp)
movl (%rsp), %r14d
movq %rbp, %rdi
leaq 0x1851cc(%rip), %rsi    # 0x3a097e
callq 0x17a40
testl %eax, %eax
jne 0x21b7f1
movl %ebx, %ecx
testl %ebx, %ebx
je 0x21b7cd
cmpl $0x1, %ecx
jne 0x21b7d4
movq %r15, 0x28(%rsp)
jmp 0x21b7ed
movq %r15, 0x30(%rsp)
jmp 0x21b7ed
movq %r13, %rdi
leaq 0x1aed2e(%rip), %rsi    # 0x3ca50c
xorl %eax, %eax
callq 0x1019cf
movl %ebx, %ecx
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
incl %ecx
movl %ecx, %ebx
movq %rbp, %rdi
leaq 0x184658(%rip), %rsi    # 0x39fe53
callq 0x17a40
testl %eax, %eax
jne 0x21b856
movl 0x4(%rsp), %eax
cmpl $0x3, %eax
ja 0x21b83b
movl %eax, %eax
leaq 0x1af3e6(%rip), %rcx    # 0x3cabfc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r15, 0x50(%rsp)
jmp 0x21b852
movq %r15, 0x40(%rsp)
jmp 0x21b852
movq %r15, 0x48(%rsp)
jmp 0x21b852
movq %r15, 0x58(%rsp)
jmp 0x21b852
movq %r13, %rdi
leaq 0x1af462(%rip), %rsi    # 0x3caca7
xorl %eax, %eax
callq 0x1019cf
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
incl 0x4(%rsp)
movq %rbp, %rdi
leaq 0x1845c3(%rip), %rsi    # 0x39fe23
callq 0x17a40
testl %eax, %eax
je 0x21b86d
movl %ebx, %eax
jmp 0x21b8a4
testl %r14d, %r14d
movl %ebx, %eax
je 0x21b881
cmpl $0x1, %r14d
jne 0x21b888
movq %r15, 0x60(%rsp)
jmp 0x21b8a1
movq %r15, 0x68(%rsp)
jmp 0x21b8a1
movq %r13, %rdi
leaq 0x1af446(%rip), %rsi    # 0x3cacd8
xorl %eax, %eax
callq 0x1019cf
movl %ebx, %eax
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
incl %r14d
testl %r12d, %r12d
je 0x21b71f
movl %r14d, (%rsp)
movq 0x38(%rsp), %rdi
callq 0x14b3d0
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
xorl %ebx, %ebx
jmp 0x21b909
movl %r14d, (%rsp)
movq 0x38(%rsp), %rdi
callq 0x14b3d0
cmpq $0x0, 0x30(%rsp)
setne %al
cmpq $0x0, 0x28(%rsp)
setne %cl
testb %cl, %al
je 0x21b8f0
xorl %r12d, %r12d
movb $0x1, %bl
jmp 0x21b909
leaq 0x1aec44(%rip), %rsi    # 0x3ca53b
xorl %ebx, %ebx
movq %r13, %rdi
xorl %eax, %eax
callq 0x1019cf
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movq 0x18(%rsp), %rax
cmpb $0x1, 0x10(%rax)
jne 0x21b972
movl 0x4(%rsp), %ecx
testl %ecx, %ecx
setg %al
cmpl $0x4, %ecx
setne %cl
andb %al, %cl
andb %cl, %bl
cmpb $0x1, %bl
jne 0x21b943
leaq 0x1af3d4(%rip), %rsi    # 0x3cad07
movq %r13, %rdi
xorl %eax, %eax
callq 0x1019cf
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
testl %r12d, %r12d
movq 0x20(%rsp), %rbx
jne 0x21b977
movl (%rsp), %eax
testl %eax, %eax
jle 0x21b977
cmpl $0x2, %eax
je 0x21b977
leaq 0x1af3d1(%rip), %rsi    # 0x3cad31
movq %r13, %rdi
xorl %eax, %eax
callq 0x1019cf
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jmp 0x21b977
movq 0x20(%rsp), %rbx
testl %r12d, %r12d
je 0x21b980
xorl %ebp, %ebp
jmp 0x21b9df
testq %rbx, %rbx
je 0x21b9dc
movq %rbx, %rdi
callq 0x14b8df
movq %rax, %rbx
movq %rdx, %r14
leaq 0x70(%rsp), %rdi
movq %rax, (%rdi)
movq %rdx, 0x8(%rdi)
callq 0x117813
leaq 0x1af3ae(%rip), %rdx    # 0x3cad59
xorl %ebp, %ebp
leaq 0x80(%rsp), %r15
movl $0x1fff, %esi           # imm = 0x1FFF
movq %r15, %rdi
movq %rbx, %rcx
movq %r14, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0x17c60
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x12097f
jmp 0x21b9df
movb $0x1, %bpl
testl %r12d, %r12d
setne %al
orb %bpl, %al
jne 0x21bcd4
movq 0x30(%rsp), %rdi
callq 0x14b8df
movq %rax, %rbx
movq %rdx, %r14
leaq 0x70(%rsp), %rdi
movq %rax, (%rdi)
movq %rdx, 0x8(%rdi)
callq 0x117813
leaq 0x1af343(%rip), %rdx    # 0x3cad59
leaq 0x80(%rsp), %r15
movl $0x1fff, %esi           # imm = 0x1FFF
movq %r15, %rdi
movq %rbx, %rcx
movq %r14, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0x17c60
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x12097f
movl (%rsp), %ecx
testl %ecx, %ecx
setg %al
movq 0x18(%rsp), %r13
andb 0x10(%r13), %al
cmpb $0x1, %al
jne 0x21baca
movq 0x68(%rsp), %rbx
testq %rbx, %rbx
je 0x21bcfd
movq 0x10(%rsp), %rcx
movq %r13, %rdi
movq %rbx, %rsi
movq 0x8(%rsp), %r14
movq %r14, %rdx
callq 0x21bd9b
movq %rbx, %r15
leaq 0x1c5da9(%rip), %rbx    # 0x3e1831
movq %r14, %rdi
movq %rbx, %rsi
callq 0x12097f
movq %r15, %rdi
callq 0x14b8df
leaq 0x70(%rsp), %rdi
movq %rax, (%rdi)
movq %rdx, 0x8(%rdi)
callq 0x117813
movq %r14, %rdi
movq %rax, %rsi
callq 0x120af4
movq %r14, %rdi
movq %rbx, %rsi
movq 0x18(%rsp), %r13
callq 0x12097f
movl (%rsp), %ecx
cmpl $0x0, 0x4(%rsp)
setg %al
andb 0x10(%r13), %al
cmpb $0x1, %al
jne 0x21bb44
movq 0x50(%rsp), %rsi
testq %rsi, %rsi
movq 0x58(%rsp), %r14
je 0x21bd02
testq %r14, %r14
je 0x21bd02
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %r13
movq %r13, %rdi
movq 0x8(%rsp), %rbx
movq %rbx, %rdx
callq 0x21bd9b
leaq 0x1b6473(%rip), %rsi    # 0x3d1f8a
movq %rbx, %rdi
callq 0x12097f
movq 0x10(%rsp), %rcx
movq %r13, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x21bd9b
leaq 0x1c5cf8(%rip), %rsi    # 0x3e1831
movq %rbx, %rdi
callq 0x12097f
movl (%rsp), %ecx
testl %ecx, %ecx
setg %bpl
movq 0x28(%rsp), %rdi
callq 0x14b8df
movq %rax, %rbx
movq %rdx, %r14
leaq 0x70(%rsp), %rdi
movq %rax, (%rdi)
movq %rdx, 0x8(%rdi)
callq 0x117813
leaq 0x1af1e7(%rip), %rdx    # 0x3cad59
leaq 0x80(%rsp), %r15
movl $0x1fff, %esi           # imm = 0x1FFF
movq %r15, %rdi
movq %rbx, %rcx
movq %r14, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0x17c60
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x12097f
andb 0x10(%r13), %bpl
cmpb $0x1, %bpl
jne 0x21bc15
movq 0x60(%rsp), %rsi
testq %rsi, %rsi
je 0x21bd07
movq 0x10(%rsp), %rcx
movq %r13, %rdi
movq %rsi, %r15
movq 0x8(%rsp), %r14
movq %r14, %rdx
callq 0x21bd9b
leaq 0x1c5c5b(%rip), %rbx    # 0x3e1831
movq %r14, %rdi
movq %rbx, %rsi
callq 0x12097f
movq %r15, %rdi
callq 0x14b8df
leaq 0x70(%rsp), %rdi
movq %rax, (%rdi)
movq %rdx, 0x8(%rdi)
callq 0x117813
movq %r14, %rdi
movq %rax, %rsi
callq 0x120af4
movq %r14, %rdi
movq %rbx, %rsi
movq 0x18(%rsp), %r13
callq 0x12097f
cmpl $0x0, 0x4(%rsp)
setg %al
andb 0x10(%r13), %al
cmpb $0x1, %al
jne 0x21bc87
movq 0x40(%rsp), %rsi
testq %rsi, %rsi
movq 0x48(%rsp), %r14
je 0x21bd0c
testq %r14, %r14
je 0x21bd0c
movq 0x10(%rsp), %rcx
movq %r13, %rdi
movq 0x8(%rsp), %rbx
movq %rbx, %rdx
callq 0x21bd9b
leaq 0x1b632d(%rip), %rsi    # 0x3d1f8a
movq %rbx, %rdi
callq 0x12097f
movq 0x10(%rsp), %rcx
movq %r13, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x21bd9b
leaq 0x1c5bb2(%rip), %rsi    # 0x3e1831
movq %rbx, %rdi
callq 0x12097f
leaq 0x1aeae3(%rip), %rsi    # 0x3ca771
movq 0x20(%rsp), %rdi
callq 0x14918c
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x12097f
leaq 0x1c5b82(%rip), %rsi    # 0x3e1831
movq %rbx, %rdi
callq 0x12097f
movq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x120af4
movq %rbx, %rdi
callq 0x120d23
movq %rax, %rdi
callq 0x17bd0
movq 0x8(%rsp), %rdi
callq 0x121b03
movl %r12d, %eax
addq $0x2088, %rsp           # imm = 0x2088
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x84037
callq 0x83f1c
callq 0x83ffe
callq 0x83f53
callq 0x83fc5
callq 0x83f8c