// File: /workspace/github_c_makefile_star2_O3/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
movq $0x0, 0x10(%rsp)
callq 0x21194c
movq %rax, %rdi
movq %r14, %rsi
callq 0x1630b1
testq %rax, %rax
je 0x21200c
movq %rax, 0x20(%rsp)
testq %r15, %r15
je 0x2119ea
movq %r15, %rdi
callq 0xfcc32
testb %al, %al
jne 0x212011
movq %r15, 0x18(%rsp)
callq 0x11ac6c
movq %rax, 0x8(%rsp)
movq %rbx, %rdi
callq 0x143f54
movq %rax, %rbx
movq $0x0, 0x38(%rsp)
movq $0x0, 0x30(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x60(%rsp)
movq $0x0, 0x68(%rsp)
movq $0x0, 0x40(%rsp)
movq $0x0, 0x58(%rsp)
movq $0x0, 0x48(%rsp)
movq $0x0, 0x50(%rsp)
movl $0x0, 0x4(%rsp)
xorl %r15d, %r15d
xorl %r12d, %r12d
movq %rbx, %rdi
callq 0x1440ea
testq %rax, %rax
je 0x211bfb
movq %rax, %rbp
movl %r15d, %r13d
movq %rax, %rdi
callq 0x142988
movq %rax, %r15
movq %rax, %rdi
leaq 0x183128(%rip), %rsi    # 0x394bb7
callq 0x17a40
xorl %r14d, %r14d
testl %eax, %eax
jne 0x211adc
movq %rbp, %rdi
leaq 0x1af379(%rip), %rsi    # 0x3c0e1e
callq 0x141f50
testq %rax, %rax
je 0x211abe
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x10b217
jmp 0x211ad7
movq 0x18(%rsp), %rdi
leaq 0x1af35f(%rip), %rsi    # 0x3c0e29
xorl %eax, %eax
callq 0xfcb67
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movq %rbp, 0x28(%rsp)
movq %r15, %rdi
leaq 0x1859d2(%rip), %rsi    # 0x3974b8
callq 0x17a40
testl %eax, %eax
jne 0x211b24
testl %r12d, %r12d
je 0x211b01
cmpl $0x1, %r12d
jne 0x211b08
movq %rbp, 0x30(%rsp)
jmp 0x211b21
movq %rbp, 0x38(%rsp)
jmp 0x211b21
movq 0x18(%rsp), %rdi
leaq 0x1af334(%rip), %rsi    # 0x3c0e48
xorl %eax, %eax
callq 0xfcb67
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
incl %r12d
movq %r15, %rdi
leaq 0x184e75(%rip), %rsi    # 0x3969a3
callq 0x17a40
testl %eax, %eax
jne 0x211b91
movl 0x4(%rsp), %ecx
cmpl $0x3, %ecx
ja 0x211b6e
movl %ecx, %eax
leaq 0x1af987(%rip), %rdx    # 0x3c14d0
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
movq %rbp, 0x40(%rsp)
jmp 0x211b8b
movq %rbp, 0x48(%rsp)
jmp 0x211b8b
movq %rbp, 0x50(%rsp)
jmp 0x211b8b
movq %rbp, 0x58(%rsp)
jmp 0x211b8b
movq 0x18(%rsp), %rdi
leaq 0x1afa01(%rip), %rsi    # 0x3c157b
xorl %eax, %eax
callq 0xfcb67
movl 0x4(%rsp), %ecx
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
incl %ecx
movl %ecx, 0x4(%rsp)
movq %r15, %rdi
leaq 0x184dd8(%rip), %rsi    # 0x396973
callq 0x17a40
testl %eax, %eax
je 0x211ba9
movl %r13d, %r15d
jmp 0x211be1
movl %r13d, %r15d
testl %r13d, %r13d
je 0x211bbe
cmpl $0x1, %r15d
jne 0x211bc5
movq %rbp, 0x68(%rsp)
jmp 0x211bde
movq %rbp, 0x60(%rsp)
jmp 0x211bde
movq 0x18(%rsp), %rdi
leaq 0x1af9db(%rip), %rsi    # 0x3c15ac
xorl %eax, %eax
callq 0xfcb67
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
incl %r15d
testl %r14d, %r14d
je 0x211a63
movq %rbx, %rdi
callq 0x14417c
xorl %ebp, %ebp
movq 0x20(%rsp), %rbx
jmp 0x211c36
movq %rbx, %rdi
callq 0x14417c
cmpq $0x0, 0x38(%rsp)
setne %al
cmpq $0x0, 0x30(%rsp)
setne %cl
movb $0x1, %bpl
testb %cl, %al
movq 0x20(%rsp), %rbx
jne 0x211c36
leaq 0x1af24f(%rip), %rsi    # 0x3c0e77
xorl %ebp, %ebp
movq 0x18(%rsp), %rdi
xorl %eax, %eax
callq 0xfcb67
movl 0x4(%rsp), %r13d
cmpb $0x1, 0x10(%rbx)
jne 0x211c95
testl %r13d, %r13d
setg %al
cmpl $0x4, %r13d
setne %cl
andb %al, %cl
andb %bpl, %cl
cmpb $0x1, %cl
jne 0x211c61
leaq 0x1af97c(%rip), %rsi    # 0x3c15db
jmp 0x211c7f
testl %r15d, %r15d
setg %al
cmpl $0x2, %r15d
setne %cl
andb %al, %cl
andb %bpl, %cl
cmpb $0x1, %cl
jne 0x211c95
leaq 0x1af986(%rip), %rsi    # 0x3c1605
movq 0x18(%rsp), %rdi
xorl %eax, %eax
callq 0xfcb67
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x211fee
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testb %bpl, %bpl
je 0x211fee
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x211fec
movl %r13d, 0x4(%rsp)
callq 0x144679
movq %rax, %r12
movl %r15d, %r13d
movq %rdx, %r15
leaq 0x70(%rsp), %rbp
movq %rax, (%rbp)
movq %rdx, 0x8(%rbp)
movq %rbp, %rdi
callq 0x112233
leaq 0x1af94d(%rip), %rdx    # 0x3c162d
leaq 0x80(%rsp), %rbx
movl $0x1fff, %esi           # imm = 0x1FFF
movq %rbx, %rdi
movq %r12, %rcx
movq %r15, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0x17c60
movq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x11acf3
movq 0x38(%rsp), %rdi
callq 0x144679
movq %rax, %r12
movq %rdx, %r15
movq %rax, (%rbp)
movq %rdx, 0x8(%rbp)
movq %rbp, %rdi
callq 0x112233
movl $0x1fff, %esi           # imm = 0x1FFF
movq %rbx, %rdi
leaq 0x1af8ee(%rip), %rdx    # 0x3c162d
movq %r12, %rcx
movq 0x20(%rsp), %r12
movq %r15, %r8
movl %r13d, %ebp
movq %rax, %r9
xorl %eax, %eax
callq 0x17c60
movq %r14, %rdi
movq %rbx, %rsi
callq 0x11acf3
movb 0x10(%r12), %al
testl %r13d, %r13d
setg %cl
andb %al, %cl
cmpb $0x1, %cl
movq 0x58(%rsp), %r15
jne 0x211de8
movq 0x60(%rsp), %rbx
testq %rbx, %rbx
je 0x212016
movq 0x10(%rsp), %rcx
movq %r12, %rdi
movq %rbx, %rsi
movq 0x8(%rsp), %r14
movq %r14, %rdx
callq 0x2120b4
movq %rbx, %r13
leaq 0x1c6333(%rip), %rbx    # 0x3d80dc
movq %r14, %rdi
movq %rbx, %rsi
callq 0x11acf3
movq %r13, %rdi
callq 0x144679
leaq 0x70(%rsp), %rdi
movq %rax, (%rdi)
movq %rdx, 0x8(%rdi)
callq 0x112233
movq %r14, %rdi
movq %rax, %rsi
callq 0x11ae72
movq %r14, %rdi
movq %rbx, %rsi
callq 0x11acf3
movb 0x10(%r12), %al
cmpl $0x0, 0x4(%rsp)
setg %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x211e54
movq 0x40(%rsp), %rsi
testq %rsi, %rsi
je 0x21201b
testq %r15, %r15
je 0x21201b
movq 0x10(%rsp), %rcx
movq %r12, %rdi
movq 0x8(%rsp), %rbx
movq %rbx, %rdx
callq 0x2120b4
leaq 0x1b6a38(%rip), %rsi    # 0x3c8862
movq %rbx, %rdi
callq 0x11acf3
movq 0x10(%rsp), %rcx
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x2120b4
leaq 0x1c6290(%rip), %rsi    # 0x3d80dc
movq %rbx, %rdi
callq 0x11acf3
testl %ebp, %ebp
setg %bpl
movq 0x30(%rsp), %rdi
callq 0x144679
movq %rax, %rbx
movq %rdx, %r12
leaq 0x70(%rsp), %rdi
movq %rax, (%rdi)
movq %rdx, 0x8(%rdi)
callq 0x112233
leaq 0x1af7ab(%rip), %rdx    # 0x3c162d
leaq 0x80(%rsp), %r15
movl $0x1fff, %esi           # imm = 0x1FFF
movq %r15, %rdi
movq %rbx, %rcx
movq %r12, %r8
movq 0x20(%rsp), %r12
movq %rax, %r9
xorl %eax, %eax
callq 0x17c60
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x11acf3
movb 0x10(%r12), %al
andb %al, %bpl
cmpb $0x1, %bpl
movq 0x50(%rsp), %r15
jne 0x211f33
movq 0x68(%rsp), %rbp
testq %rbp, %rbp
je 0x212020
movq 0x10(%rsp), %rcx
movq %r12, %rdi
movq %rbp, %rsi
movq 0x8(%rsp), %r14
movq %r14, %rdx
callq 0x2120b4
leaq 0x1c61e8(%rip), %rbx    # 0x3d80dc
movq %r14, %rdi
movq %rbx, %rsi
callq 0x11acf3
movq %rbp, %rdi
callq 0x144679
leaq 0x70(%rsp), %rdi
movq %rax, (%rdi)
movq %rdx, 0x8(%rdi)
callq 0x112233
movq %r14, %rdi
movq %rax, %rsi
callq 0x11ae72
movq %r14, %rdi
movq %rbx, %rsi
callq 0x11acf3
movb 0x10(%r12), %al
cmpl $0x0, 0x4(%rsp)
setg %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x211f9f
movq 0x48(%rsp), %rsi
testq %rsi, %rsi
je 0x212025
testq %r15, %r15
je 0x212025
movq 0x10(%rsp), %rcx
movq %r12, %rdi
movq 0x8(%rsp), %rbx
movq %rbx, %rdx
callq 0x2120b4
leaq 0x1b68ed(%rip), %rsi    # 0x3c8862
movq %rbx, %rdi
callq 0x11acf3
movq 0x10(%rsp), %rcx
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x2120b4
leaq 0x1c6145(%rip), %rsi    # 0x3d80dc
movq %rbx, %rdi
callq 0x11acf3
leaq 0x1af107(%rip), %rsi    # 0x3c10ad
movq 0x28(%rsp), %rdi
callq 0x141f50
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x11acf3
leaq 0x1c6115(%rip), %rsi    # 0x3d80dc
movq %rbx, %rdi
callq 0x11acf3
movq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x11ae72
movq %rbx, %rdi
callq 0x11b0a1
movq %rax, %rdi
callq 0x17bd0
xorl %ebx, %ebx
movq 0x8(%rsp), %rdi
callq 0x11bdbf
movl %ebx, %eax
addq $0x2088, %rsp           # imm = 0x2088
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x81f4a
callq 0x81e2f
callq 0x81f11
callq 0x81e66
callq 0x81ed8
callq 0x81e9f