// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/ltr/ltrdigest_file_out_stream.c
// Function: gt_ltrdigest_file_out_stream_new
GtNodeStream* gt_ltrdigest_file_out_stream_new(GtNodeStream *in_stream,
                                        int tests_to_run,
                                        GtRegionMapping *rmap,
                                        char *file_prefix,
                                        unsigned int seqnamelen,
                                        GtError* err)
{
  GtNodeStream *ns;
  GtLTRdigestFileOutStream *ls;
  char fn[GT_MAXFILENAMELEN];
  int had_err = 0;
  gt_error_check(err);

  gt_assert(file_prefix && in_stream && rmap);

  ns = gt_node_stream_create(gt_ltrdigest_file_out_stream_class(), false);
  ls = gt_ltrdigest_file_out_stream_cast(ns);

  /* ref GFF input stream and sequences*/
  ls->in_stream = gt_node_stream_ref(in_stream);
  ls->rmap = rmap;
  ls->tests_to_run = tests_to_run;
  ls->seqnamelen = seqnamelen;
  ls->write_pdom_alignments = false;
  ls->write_pdom_aaseqs = false;
  ls->tabout_file = ls->pptout_file = ls->pbsout_file = ls->ltr3out_file =
    ls->ltr5out_file = ls->elemout_file = NULL;

  /* open outfiles */
  ls->fileprefix = file_prefix;
  (void) snprintf(fn, (size_t) (GT_MAXFILENAMELEN-1),
                  "%s_tabout.csv", file_prefix);
  ls->tabout_file = gt_file_open(GT_FILE_MODE_UNCOMPRESSED, fn, "w+", err);
  if (!ls->tabout_file)
    had_err = -1;
  if (!had_err && (tests_to_run & GT_LTRDIGEST_RUN_PPT))
  {
    (void) snprintf(fn, (size_t) (GT_MAXFILENAMELEN-1),
                    "%s_ppt.fas", file_prefix);
    ls->pptout_file = gt_file_open(GT_FILE_MODE_UNCOMPRESSED, fn, "w+", err);
    if (!ls->pptout_file)
      had_err = -1;
  }
  if (!had_err && (tests_to_run & GT_LTRDIGEST_RUN_PBS))
  {
    (void) snprintf(fn, (size_t) (GT_MAXFILENAMELEN-1),
                    "%s_pbs.fas", file_prefix);
    ls->pbsout_file = gt_file_open(GT_FILE_MODE_UNCOMPRESSED, fn, "w+", err);
    if (!ls->pbsout_file)
      had_err = -1;
  }
  if (!had_err) {
    (void) snprintf(fn, (size_t) (GT_MAXFILENAMELEN-1),
                     "%s_5ltr.fas", file_prefix);
    ls->ltr5out_file = gt_file_open(GT_FILE_MODE_UNCOMPRESSED, fn, "w+", err);
    if (!ls->ltr5out_file)
      had_err = -1;
  }
  if (!had_err) {
    (void) snprintf(fn, (size_t) (GT_MAXFILENAMELEN-1),
                    "%s_3ltr.fas", file_prefix);
    ls->ltr3out_file = gt_file_open(GT_FILE_MODE_UNCOMPRESSED, fn, "w+", err);
    if (!ls->ltr3out_file)
      had_err = -1;
  }
  if (!had_err) {
    (void) snprintf(fn, (size_t) (GT_MAXFILENAMELEN-1),
                    "%s_complete.fas", file_prefix);
    ls->elemout_file = gt_file_open(GT_FILE_MODE_UNCOMPRESSED, fn, "w+", err);
    if (!ls->elemout_file)
      had_err = -1;
  }

  if (!had_err) {
    /* print tabular outfile headline */
    gt_file_xprintf(ls->tabout_file,
                "element start\telement end\telement length\tsequence\t"
                "lLTR start\tlLTR end\tlLTR length\t"
                "rLTR start\trLTR end\trLTR length\t"
                "lTSD start\tlTSD end\tlTSD motif\t"
                "rTSD start\trTSD end\trTSD motif\t"
                "PPT start\tPPT end\tPPT motif\tPPT strand\tPPT offset");
    gt_file_xprintf(ls->tabout_file,
                "\tPBS start\tPBS end\tPBS strand\ttRNA\ttRNA motif\tPBS "
                "offset\t"
                "tRNA offset\tPBS/tRNA edist");
  #ifdef HAVE_HMMER
    gt_file_xprintf(ls->tabout_file, "\tProtein domain hits");
  #endif
    gt_file_xprintf(ls->tabout_file, "\n");

    /* create visitor */
    ls->lv = (GtLTRVisitor*) gt_ltr_visitor_new(&ls->element);
    gt_assert(ls->lv);
  }

  if (had_err) {
    gt_node_stream_delete(ns);
    ns = NULL;
  }
  return ns;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %r9, %r14
movl %r8d, %r13d
movq %rcx, %r12
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r15
testq %r9, %r9
je 0x1bf179
movq %r14, %rdi
callq 0x89eb7
testb %al, %al
jne 0x1bf46b
movq %r14, 0x8(%rsp)
testq %rbx, %rbx
je 0x1bf43d
testq %r15, %r15
je 0x1bf43d
testq %r12, %r12
je 0x1bf43d
callq 0x1bec19
movq %rax, %rdi
xorl %esi, %esi
callq 0x10289f
movq %rax, %r14
callq 0x1bec19
movq %rax, %rdi
movq %r14, (%rsp)
movq %r14, %rsi
callq 0x102c81
movq %rax, %r14
movq %r15, %rdi
callq 0x102934
movq %rax, 0x10(%r14)
movq %rbx, 0x18(%r14)
movl %ebp, 0x60(%r14)
movl %r13d, 0x64(%r14)
andw $0x0, 0xd8(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%r14)
movups %xmm0, 0x38(%r14)
movups %xmm0, 0x48(%r14)
movq %r12, 0x20(%r14)
leaq 0x1a0fbb(%rip), %rdx    # 0x3601bb
leaq 0x10(%rsp), %rbx
movl $0xff, %esi
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x17bf0
leaq 0x12644b(%rip), %rdx    # 0x2e5669
xorl %edi, %edi
movq %rbx, %rsi
movq 0x8(%rsp), %r15
movq %r15, %rcx
callq 0x8cea6
movq %rax, 0x28(%r14)
testq %rax, %rax
je 0x1bf420
testb $0x1, %bpl
je 0x1bf282
leaq 0x1a0f7f(%rip), %rdx    # 0x3601c9
leaq 0x10(%rsp), %rbx
movl $0xff, %esi
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x17bf0
leaq 0x126401(%rip), %rdx    # 0x2e5669
xorl %edi, %edi
movq %rbx, %rsi
movq %r15, %rcx
callq 0x8cea6
movq %rax, 0x38(%r14)
testq %rax, %rax
je 0x1bf420
testb $0x2, %bpl
je 0x1bf2c7
leaq 0x1a0f45(%rip), %rdx    # 0x3601d4
leaq 0x10(%rsp), %rbx
movl $0xff, %esi
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x17bf0
leaq 0x1263bc(%rip), %rdx    # 0x2e5669
xorl %edi, %edi
movq %rbx, %rsi
movq %r15, %rcx
callq 0x8cea6
movq %rax, 0x30(%r14)
testq %rax, %rax
je 0x1bf420
leaq 0x1a0f11(%rip), %rdx    # 0x3601df
leaq 0x10(%rsp), %rbx
movl $0xff, %esi
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x17bf0
leaq 0x12637d(%rip), %rdx    # 0x2e5669
xorl %edi, %edi
movq %rbx, %rsi
movq %r15, %rcx
callq 0x8cea6
movq %rax, 0x40(%r14)
testq %rax, %rax
je 0x1bf420
leaq 0x1a0ede(%rip), %rdx    # 0x3601eb
leaq 0x10(%rsp), %rbx
movl $0xff, %esi
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x17bf0
leaq 0x12633e(%rip), %rdx    # 0x2e5669
xorl %edi, %edi
movq %rbx, %rsi
movq %r15, %rcx
callq 0x8cea6
movq %rax, 0x48(%r14)
testq %rax, %rax
je 0x1bf420
leaq 0x1a0eab(%rip), %rdx    # 0x3601f7
leaq 0x10(%rsp), %rbx
movl $0xff, %esi
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x17bf0
leaq 0x1262ff(%rip), %rdx    # 0x2e5669
xorl %edi, %edi
movq %rbx, %rsi
movq %r15, %rcx
callq 0x8cea6
movq %rax, 0x50(%r14)
testq %rax, %rax
je 0x1bf420
movq 0x28(%r14), %rdi
leaq 0x1a0e78(%rip), %rsi    # 0x360207
xorl %eax, %eax
callq 0x8d432
movq 0x28(%r14), %rdi
leaq 0x1a0f48(%rip), %rsi    # 0x3602e9
xorl %eax, %eax
callq 0x8d432
movq 0x28(%r14), %rdi
leaq 0x1a113c(%rip), %rsi    # 0x3604ef
xorl %eax, %eax
callq 0x8d432
movq %r14, %r15
addq $0x68, %r15
callq 0x1bd90c
movq %rax, %rdi
callq 0x102da0
movq %rax, %rbx
callq 0x1bd90c
movq %rax, %rdi
movq %rbx, %rsi
callq 0x102dfe
movq %r15, 0x10(%rax)
movq %rbx, 0x58(%r14)
testq %rbx, %rbx
movq (%rsp), %rax
jne 0x1bf42b
movq 0x278b6f(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x125c10(%rip), %rsi    # 0x2e5013
leaq 0x1a0f33(%rip), %rdx    # 0x36033d
leaq 0x1a0d68(%rip), %rcx    # 0x360179
leaq 0x1a0983(%rip), %r8     # 0x35fd9b
movl $0x386, %r9d            # imm = 0x386
jmp 0x1bf497
movq (%rsp), %rdi
callq 0x10297b
xorl %eax, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x278b24(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x125bc5(%rip), %rsi    # 0x2e5013
leaq 0x1a0d45(%rip), %rdx    # 0x36019a
leaq 0x1a0d1d(%rip), %rcx    # 0x360179
leaq 0x1a0938(%rip), %r8     # 0x35fd9b
movl $0x336, %r9d            # imm = 0x336
jmp 0x1bf497
movq 0x278af6(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x125b97(%rip), %rsi    # 0x2e5013
leaq 0x125d3c(%rip), %rdx    # 0x2e51bf
leaq 0x1a0cef(%rip), %rcx    # 0x360179
leaq 0x1a090a(%rip), %r8     # 0x35fd9b
movl $0x334, %r9d            # imm = 0x334
xorl %eax, %eax
callq 0x17a50
callq 0x17390
nop