// File: /workspace/github_c_makefile_star2_O2/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, %r15
movq %rsi, %rbx
movq %rdi, %r14
andq $0x0, 0x8(%rsp)
callq 0x1c656c
movq %rax, %rdi
movq %r14, %rsi
callq 0x102dfe
testq %rax, %rax
je 0x1c6c10
movq %rax, %r14
testq %r15, %r15
je 0x1c6600
movq %r15, %rdi
callq 0x89eb7
testb %al, %al
jne 0x1c6c3a
movq %r15, 0x10(%rsp)
movq %r14, 0x20(%rsp)
callq 0xacb84
movq %rax, 0x18(%rsp)
movq %rbx, %rdi
callq 0xdc6f0
movq %rax, %r14
movl $0x0, %ebp
movl $0x0, 0x4(%rsp)
xorl %r12d, %r12d
xorl %r13d, %r13d
movq $0x0, 0x60(%rsp)
movq $0x0, 0x58(%rsp)
movq $0x0, 0x68(%rsp)
movq $0x0, 0x50(%rsp)
movq $0x0, 0x40(%rsp)
movq $0x0, 0x48(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
testl %r13d, %r13d
jne 0x1c67fd
movq %r14, %rdi
callq 0xdc92e
testq %rax, %rax
je 0x1c6816
movq %rax, %r15
movq %rax, %rdi
callq 0xda338
movq %rax, %rbx
movq %rax, %rdi
leaq 0x16e871(%rip), %rsi    # 0x334f26
callq 0x179e0
xorl %r13d, %r13d
testl %eax, %eax
jne 0x1c6700
movq %r15, %rdi
leaq 0x19ab63(%rip), %rsi    # 0x36122e
callq 0xd9628
testq %rax, %rax
je 0x1c66e4
leaq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x9bd05
jmp 0x1c66fb
movq 0x10(%rsp), %rdi
leaq 0x19ab49(%rip), %rsi    # 0x361239
xorl %eax, %eax
callq 0x89dbb
pushq $-0x1
popq %r13
movq %r15, 0x28(%rsp)
movq %rbx, %rdi
leaq 0x171107(%rip), %rsi    # 0x337811
callq 0x179e0
testl %eax, %eax
jne 0x1c6743
testl %ebp, %ebp
je 0x1c6723
cmpl $0x1, %ebp
jne 0x1c672a
movq %r15, 0x30(%rsp)
jmp 0x1c6741
movq %r15, 0x38(%rsp)
jmp 0x1c6741
movq 0x10(%rsp), %rdi
leaq 0x19ab22(%rip), %rsi    # 0x361258
xorl %eax, %eax
callq 0x89dbb
pushq $-0x1
popq %r13
incl %ebp
movq %rbx, %rdi
leaq 0x1705af(%rip), %rsi    # 0x336cfc
callq 0x179e0
testl %eax, %eax
jne 0x1c67a5
cmpl $0x3, %r12d
ja 0x1c678b
movl %r12d, %eax
leaq 0x19b17a(%rip), %rcx    # 0x3618e0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r15, 0x50(%rsp)
jmp 0x1c67a2
movq %r15, 0x58(%rsp)
jmp 0x1c67a2
movq %r15, 0x60(%rsp)
jmp 0x1c67a2
movq %r15, 0x68(%rsp)
jmp 0x1c67a2
movq 0x10(%rsp), %rdi
leaq 0x19b1f4(%rip), %rsi    # 0x36198b
xorl %eax, %eax
callq 0x89dbb
pushq $-0x1
popq %r13
incl %r12d
movq %rbx, %rdi
leaq 0x17051d(%rip), %rsi    # 0x336ccc
callq 0x179e0
testl %eax, %eax
jne 0x1c6683
movl 0x4(%rsp), %eax
testl %eax, %eax
je 0x1c67d0
cmpl $0x1, %eax
jne 0x1c67d7
movq %r15, 0x40(%rsp)
jmp 0x1c67f2
movq %r15, 0x48(%rsp)
jmp 0x1c67f2
movq 0x10(%rsp), %rdi
leaq 0x19b1d9(%rip), %rsi    # 0x3619bc
xorl %eax, %eax
callq 0x89dbb
movl 0x4(%rsp), %eax
pushq $-0x1
popq %r13
incl %eax
movl %eax, 0x4(%rsp)
jmp 0x1c6683
movq %r14, %rdi
callq 0xdc9f1
pushq $-0x1
popq %rax
xorl %ebx, %ebx
movq 0x18(%rsp), %r13
movq 0x20(%rsp), %r14
jmp 0x1c6842
movq %r14, %rdi
callq 0xdc9f1
cmpq $0x0, 0x38(%rsp)
setne %al
cmpq $0x0, 0x30(%rsp)
setne %cl
testb %cl, %al
movq 0x20(%rsp), %r14
je 0x1c6849
xorl %eax, %eax
movb $0x1, %bl
movq 0x18(%rsp), %r13
movq 0x10(%rsp), %r15
jmp 0x1c6869
leaq 0x19aa37(%rip), %rsi    # 0x361287
xorl %ebx, %ebx
movq 0x10(%rsp), %r15
movq %r15, %rdi
xorl %eax, %eax
callq 0x89dbb
pushq $-0x1
popq %rax
movq 0x18(%rsp), %r13
cmpb $0x1, 0x10(%r14)
jne 0x1c68c4
testl %r12d, %r12d
setg %cl
cmpl $0x4, %r12d
setne %dl
andb %cl, %dl
andb %dl, %bl
cmpb $0x1, %bl
jne 0x1c689a
leaq 0x19b15e(%rip), %rsi    # 0x3619eb
movq %r15, %rdi
xorl %eax, %eax
callq 0x89dbb
pushq $-0x1
popq %rax
testl %eax, %eax
sete %cl
testl $0x7ffffffd, 0x4(%rsp)  # imm = 0x7FFFFFFD
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x1c68c4
leaq 0x19b15d(%rip), %rsi    # 0x361a15
movq %r15, %rdi
xorl %eax, %eax
callq 0x89dbb
jmp 0x1c68c8
testl %eax, %eax
je 0x1c68d0
pushq $-0x1
popq %rbx
jmp 0x1c6bf4
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x1c6bf2
callq 0xdd1f4
movq %rax, %rbp
movq %rdx, %r13
leaq 0x70(%rsp), %r14
movq %rax, (%r14)
movq %rdx, 0x8(%r14)
movq %r14, %rdi
callq 0xa31ee
leaq 0x19b139(%rip), %r15    # 0x361a3d
leaq 0x80(%rsp), %rbx
movl $0x1fff, %esi           # imm = 0x1FFF
movq %rbx, %rdi
movq %r15, %rdx
movq %rbp, %rcx
movq %r13, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0x17bf0
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0xacbfb
movq 0x38(%rsp), %rdi
callq 0xdd1f4
movq %rax, %rbp
movq %rdx, %r13
movq %rax, (%r14)
movq %rdx, 0x8(%r14)
movq %r14, %rdi
callq 0xa31ee
movl $0x1fff, %esi           # imm = 0x1FFF
movq %rbx, %rdi
movq %r15, %rdx
movq 0x20(%rsp), %r14
movq %rbp, %rcx
movq %r13, %r8
movq 0x18(%rsp), %r13
movq %rax, %r9
xorl %eax, %eax
callq 0x17bf0
movq %r13, %rdi
movq %rbx, %rsi
callq 0xacbfb
movb 0x10(%r14), %al
movl 0x4(%rsp), %edx
testl %edx, %edx
setne %cl
andb %al, %cl
cmpb $0x1, %cl
movq 0x68(%rsp), %r15
jne 0x1c6a06
movq 0x48(%rsp), %rbp
testq %rbp, %rbp
je 0x1c6c70
movq 0x8(%rsp), %rcx
movq %r14, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x1c6e44
leaq 0x1b1b38(%rip), %rbx    # 0x3784fc
movq %r13, %rdi
movq %rbx, %rsi
callq 0xacbfb
movq %rbp, %rdi
callq 0xdd1f4
leaq 0x70(%rsp), %rdi
movq %rax, (%rdi)
movq %rdx, 0x8(%rdi)
callq 0xa31ee
movq %r13, %rdi
movq %rax, %rsi
callq 0xace26
movq %r13, %rdi
movq %rbx, %rsi
callq 0xacbfb
movb 0x10(%r14), %al
movl 0x4(%rsp), %edx
testl %r12d, %r12d
setg %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x1c6a6f
movq 0x50(%rsp), %rsi
testq %rsi, %rsi
je 0x1c6c9e
testq %r15, %r15
je 0x1c6c9e
movq 0x8(%rsp), %rcx
movq %r14, %rdi
movq %r13, %rdx
callq 0x1c6e44
leaq 0x1a2221(%rip), %rsi    # 0x368c62
movq %r13, %rdi
callq 0xacbfb
movq 0x8(%rsp), %rcx
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x1c6e44
leaq 0x1b1a99(%rip), %rsi    # 0x3784fc
movq %r13, %rdi
callq 0xacbfb
movl 0x4(%rsp), %edx
testl %edx, %edx
setne %bpl
movq 0x30(%rsp), %rdi
callq 0xdd1f4
movq %rax, %rbx
movq %rdx, %r14
leaq 0x70(%rsp), %rdi
movq %rax, (%rdi)
movq %rdx, 0x8(%rdi)
callq 0xa31ee
leaq 0x19afa0(%rip), %rdx    # 0x361a3d
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 0x17bf0
movq %r13, %rdi
movq %r15, %rsi
movq 0x20(%rsp), %r14
callq 0xacbfb
movb 0x10(%r14), %al
andb %al, %bpl
cmpb $0x1, %bpl
jne 0x1c6b40
movq 0x40(%rsp), %r15
testq %r15, %r15
je 0x1c6ccc
movq 0x8(%rsp), %rcx
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x1c6e44
leaq 0x1b19fa(%rip), %rbx    # 0x3784fc
movq %r13, %rdi
movq %rbx, %rsi
callq 0xacbfb
movq %r15, %rdi
callq 0xdd1f4
leaq 0x70(%rsp), %rdi
movq %rax, (%rdi)
movq %rdx, 0x8(%rdi)
callq 0xa31ee
movq %r13, %rdi
movq %rax, %rsi
callq 0xace26
movq %r13, %rdi
movq %rbx, %rsi
callq 0xacbfb
movb 0x10(%r14), %al
testl %r12d, %r12d
setg %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x1c6baa
movq 0x58(%rsp), %rsi
testq %rsi, %rsi
movq 0x60(%rsp), %rbx
je 0x1c6cfd
testq %rbx, %rbx
je 0x1c6cfd
movq 0x8(%rsp), %rcx
movq %r14, %rdi
movq %r13, %rdx
callq 0x1c6e44
leaq 0x1a20e2(%rip), %rsi    # 0x368c62
movq %r13, %rdi
callq 0xacbfb
movq 0x8(%rsp), %rcx
movq %r14, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x1c6e44
leaq 0x1b195a(%rip), %rsi    # 0x3784fc
movq %r13, %rdi
callq 0xacbfb
leaq 0x19a90c(%rip), %rsi    # 0x3614bd
movq 0x28(%rsp), %rdi
callq 0xd9628
movq %r13, %rdi
movq %rax, %rsi
callq 0xacbfb
leaq 0x1b192f(%rip), %rsi    # 0x3784fc
movq %r13, %rdi
callq 0xacbfb
movq 0x8(%rsp), %rsi
movq %r13, %rdi
callq 0xace26
movq %r13, %rdi
callq 0xad1fa
movq %rax, %rdi
callq 0x17b60
xorl %ebx, %ebx
movq %r13, %rdi
callq 0xae103
movl %ebx, %eax
addq $0x2088, %rsp           # imm = 0x2088
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x271351(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x11e3f2(%rip), %rsi    # 0x2e5013
leaq 0x199719(%rip), %rdx    # 0x360341
leaq 0x19ad32(%rip), %rcx    # 0x361961
leaq 0x19acdb(%rip), %r8     # 0x361911
pushq $0x59
jmp 0x1c6c62
movq 0x271327(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x11e3c8(%rip), %rsi    # 0x2e5013
leaq 0x11e56d(%rip), %rdx    # 0x2e51bf
leaq 0x19ad08(%rip), %rcx    # 0x361961
leaq 0x19acb1(%rip), %r8     # 0x361911
pushq $0x5a
popq %r9
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x2712f1(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x11e392(%rip), %rsi    # 0x2e5013
leaq 0x19adc5(%rip), %rdx    # 0x361a4d
leaq 0x19acd2(%rip), %rcx    # 0x361961
leaq 0x19ac7b(%rip), %r8     # 0x361911
movl $0xce, %r9d
jmp 0x1c6c64
movq 0x2712c3(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x11e364(%rip), %rsi    # 0x2e5013
leaq 0x19ad9f(%rip), %rdx    # 0x361a55
leaq 0x19aca4(%rip), %rcx    # 0x361961
leaq 0x19ac4d(%rip), %r8     # 0x361911
movl $0xd7, %r9d
jmp 0x1c6c64
movq 0x271295(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x11e336(%rip), %rsi    # 0x2e5013
leaq 0x19ad8c(%rip), %rdx    # 0x361a70
leaq 0x19ac76(%rip), %rcx    # 0x361961
leaq 0x19ac1f(%rip), %r8     # 0x361911
movl $0xe5, %r9d
jmp 0x1c6c64
movq 0x271264(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x11e305(%rip), %rsi    # 0x2e5013
leaq 0x19ad64(%rip), %rdx    # 0x361a79
leaq 0x19ac45(%rip), %rcx    # 0x361961
leaq 0x19abee(%rip), %r8     # 0x361911
movl $0xee, %r9d
jmp 0x1c6c64