// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/match/rdj-contigpaths.c
// Function: gt_contigpaths_to_fasta
int gt_contigpaths_to_fasta(const char *indexname,
    const char *contigpaths_suffix, const char *fasta_suffix,
    const GtEncseq *encseq, GtUword min_contig_length, bool showpaths,
    bool astat, double coverage, bool load_copynum, size_t buffersize,
    GtLogger *logger, GtError *err)
{
  GtUword nofchars, seqnum, contig_length = 0;
  GtFile *infp = NULL, *outfp = NULL;
  FILE *depthinfo_fp = NULL;
  int nvalues, i;
  GtContigsWriter *cw = NULL;
  GtContigpathElem *buffer = NULL;
  unsigned char *rcn = NULL;
  int had_err = 0;

  if (buffersize == 0)
  {
    buffersize = GT_CONTIGPATHS_BUFFERSIZE * sizeof (GtContigpathElem);
    gt_log_log("buffersize = default ("GT_ZU" bytes)", buffersize);
  }
  else
  {
    size_t bsmod = buffersize % sizeof (GtContigpathElem);
    buffersize -= bsmod;
    gt_log_log("buffersize = "GT_ZU" bytes", buffersize);
  }
  gt_assert(buffersize > 0);
  gt_assert(buffersize % sizeof (GtContigpathElem) == 0);
  buffer = gt_malloc(buffersize);

  gt_assert(encseq != NULL);
  gt_error_check(err);
  gt_assert(buffer != NULL);

  infp = gt_contigpaths_get_file(indexname, contigpaths_suffix, "r", err);
  if (infp == NULL)
    had_err = -1;
  if (!had_err)
  {
    outfp = gt_contigpaths_get_file(indexname, fasta_suffix, "w", err);
    if (outfp == NULL)
    {
      gt_file_delete(infp);
      had_err = -1;
    }
  }
  if (!had_err && load_copynum)
  {
    GtFile *rcnfp = NULL;
    size_t nbytes;
    rcnfp = gt_contigpaths_get_file(indexname,
        GT_READJOINER_SUFFIX_READSCOPYNUM, "r", err);
    if (rcnfp == NULL)
    {
      had_err = -1;
    }
    else
    {
      gt_log_log("load reads copy number from file");
      nbytes = sizeof (*rcn) * gt_encseq_num_of_sequences(encseq);
      if (gt_encseq_is_mirrored(encseq))
        nbytes = GT_DIV2(nbytes);
      rcn = gt_malloc(nbytes);
      (void)gt_file_xread(rcnfp, rcn, nbytes);
      gt_file_delete(rcnfp);
    }
  }
  if (!had_err)
  {
    cw = gt_contigs_writer_new(encseq, outfp);
    if (showpaths)
      gt_contigs_writer_enable_complete_path_output(cw);
    if (astat)
    {
      depthinfo_fp = gt_fa_fopen_with_suffix(indexname,
          GT_READJOINER_SUFFIX_DEPTHINFO, "w", err);
      if (depthinfo_fp == NULL)
      {
        had_err = -1;
      }
      if (!had_err)
      {
        gt_contigs_writer_enable_astat_calculation(cw, coverage, rcn,
            depthinfo_fp);
      }
    }
  }
  if (!had_err)
  {
    while ((nvalues = gt_file_xread(infp, buffer, buffersize)) > 0)
    {
      gt_assert((size_t)nvalues <= buffersize);
      nvalues /= (sizeof (GtContigpathElem) << 1);
      for (i = 0; i < nvalues; i++)
      {
        nofchars = (GtUword)buffer[(i << 1)];
        seqnum = (GtUword)buffer[(i << 1) + 1];
        if (nofchars == 0)
        {
          /* end of contig */
          if (contig_length >= min_contig_length)
            gt_contigs_writer_write(cw);
          else
            gt_contigs_writer_abort(cw);
          gt_contigs_writer_start(cw, seqnum);
          contig_length = gt_encseq_seqlength(encseq, seqnum);
        }
        else
        {
          contig_length += nofchars;
          gt_contigs_writer_append(cw, seqnum, nofchars);
        }
      }
    }

    if (contig_length >= min_contig_length)
      gt_contigs_writer_write(cw);
    else
      gt_contigs_writer_abort(cw);
    gt_contigs_writer_show_stats(cw, logger);
  }
  if (depthinfo_fp != NULL)
    gt_fa_fclose(depthinfo_fp);
  gt_contigs_writer_delete(cw);
  gt_file_delete(infp);
  gt_file_delete(outfp);
  gt_free(buffer);
  gt_free(rcn);
  return 0;
}

// Assembly:
subq $0xc8, %rsp
movl %r9d, %eax
movq %rcx, 0x8(%rsp)
movq %rdx, 0x10(%rsp)
movq %rsi, %r9
movq 0x8(%rsp), %rsi
movq %rdi, %r10
movq 0x10(%rsp), %rdi
movb %al, %dl
movq 0xf0(%rsp), %rax
movq 0xe8(%rsp), %rax
movq 0xe0(%rsp), %rax
movb 0xd8(%rsp), %al
movb 0xd0(%rsp), %cl
movq %r10, 0xc0(%rsp)
movq %r9, 0xb8(%rsp)
movq %rdi, 0xb0(%rsp)
movq %rsi, 0xa8(%rsp)
movq %r8, 0xa0(%rsp)
andb $0x1, %dl
movb %dl, 0x9f(%rsp)
andb $0x1, %cl
movb %cl, 0x9e(%rsp)
movsd %xmm0, 0x90(%rsp)
andb $0x1, %al
movb %al, 0x8f(%rsp)
movq $0x0, 0x70(%rsp)
movq $0x0, 0x68(%rsp)
movq $0x0, 0x60(%rsp)
movq $0x0, 0x58(%rsp)
movq $0x0, 0x48(%rsp)
movq $0x0, 0x40(%rsp)
movq $0x0, 0x38(%rsp)
movl $0x0, 0x34(%rsp)
cmpq $0x0, 0xe0(%rsp)
jne 0x27cb80
movq $0x40000, 0xe0(%rsp) # imm = 0x40000
movq 0xe0(%rsp), %rsi
leaq 0x3030a0(%rip), %rdi    # 0x57fc17
movb $0x0, %al
callq 0xe7740
jmp 0x27cbbf
movq 0xe0(%rsp), %rax
andq $0x3, %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rcx
movq 0xe0(%rsp), %rax
subq %rcx, %rax
movq %rax, 0xe0(%rsp)
movq 0xe0(%rsp), %rsi
leaq 0x303080(%rip), %rdi    # 0x57fc38
movb $0x0, %al
callq 0xe7740
jmp 0x27cbc1
cmpq $0x0, 0xe0(%rsp)
ja 0x27cc04
movq 0x3bf3cd(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x299436(%rip), %rsi    # 0x516013
leaq 0x30306b(%rip), %rdx    # 0x57fc4f
leaq 0x303073(%rip), %rcx    # 0x57fc5e
leaq 0x303084(%rip), %r8     # 0x57fc76
movl $0x46, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x27cc06
jmp 0x27cc08
movq 0xe0(%rsp), %rax
andq $0x3, %rax
cmpq $0x0, %rax
je 0x27cc52
movq 0x3bf37f(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2993e8(%rip), %rsi    # 0x516013
leaq 0x303060(%rip), %rdx    # 0x57fc92
leaq 0x303025(%rip), %rcx    # 0x57fc5e
leaq 0x303036(%rip), %r8     # 0x57fc76
movl $0x47, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x27cc54
movq 0xe0(%rsp), %rdi
leaq 0x303013(%rip), %rsi    # 0x57fc76
movl $0x48, %edx
callq 0xe80f0
movq %rax, 0x40(%rsp)
cmpq $0x0, 0xa8(%rsp)
jne 0x27ccb5
movq 0x3bf31c(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x299385(%rip), %rsi    # 0x516013
leaq 0x2f574d(%rip), %rdx    # 0x5723e2
leaq 0x302fc2(%rip), %rcx    # 0x57fc5e
leaq 0x302fd3(%rip), %r8     # 0x57fc76
movl $0x4a, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x27ccb7
jmp 0x27ccb9
cmpq $0x0, 0xf0(%rsp)
je 0x27cd0f
movq 0xf0(%rsp), %rdi
callq 0xd8a60
testb $0x1, %al
jne 0x27ccd7
jmp 0x27cd0f
movq 0x3bf2c2(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x29932b(%rip), %rsi    # 0x516013
leaq 0x2994d0(%rip), %rdx    # 0x5161bf
leaq 0x302f68(%rip), %rcx    # 0x57fc5e
leaq 0x302f79(%rip), %r8     # 0x57fc76
movl $0x4b, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x27cd11
jmp 0x27cd13
cmpq $0x0, 0x40(%rsp)
jne 0x27cd53
movq 0x3bf27e(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2992e7(%rip), %rsi    # 0x516013
leaq 0x2b856a(%rip), %rdx    # 0x53529d
leaq 0x302f24(%rip), %rcx    # 0x57fc5e
leaq 0x302f35(%rip), %r8     # 0x57fc76
movl $0x4c, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x27cd55
movq 0xc0(%rsp), %rdi
movq 0xb8(%rsp), %rsi
movq 0xf0(%rsp), %rcx
leaq 0x2af266(%rip), %rdx    # 0x52bfda
callq 0x27d170
movq %rax, 0x68(%rsp)
cmpq $0x0, 0x68(%rsp)
jne 0x27cd8e
movl $0xffffffff, 0x34(%rsp) # imm = 0xFFFFFFFF
cmpl $0x0, 0x34(%rsp)
jne 0x27cdda
movq 0xc0(%rsp), %rdi
movq 0xb0(%rsp), %rsi
movq 0xf0(%rsp), %rcx
leaq 0x2e9111(%rip), %rdx    # 0x565ec5
callq 0x27d170
movq %rax, 0x60(%rsp)
cmpq $0x0, 0x60(%rsp)
jne 0x27cdd8
movq 0x68(%rsp), %rdi
callq 0xde430
movl $0xffffffff, 0x34(%rsp) # imm = 0xFFFFFFFF
jmp 0x27cdda
cmpl $0x0, 0x34(%rsp)
jne 0x27ceb5
testb $0x1, 0x8f(%rsp)
je 0x27ceb5
movq $0x0, 0x20(%rsp)
movq 0xc0(%rsp), %rdi
movq 0xf0(%rsp), %rcx
leaq 0x2a8ad3(%rip), %rsi    # 0x5258e6
leaq 0x2af1c0(%rip), %rdx    # 0x52bfda
callq 0x27d170
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x20(%rsp)
jne 0x27ce36
movl $0xffffffff, 0x34(%rsp) # imm = 0xFFFFFFFF
jmp 0x27ceb3
leaq 0x302e81(%rip), %rdi    # 0x57fcbe
movb $0x0, %al
callq 0xe7740
movq 0xa8(%rsp), %rdi
callq 0xa9d50
shlq $0x0, %rax
movq %rax, 0x18(%rsp)
movq 0xa8(%rsp), %rdi
callq 0xc2ec0
testb $0x1, %al
jne 0x27ce6d
jmp 0x27ce7a
movq 0x18(%rsp), %rax
shrq %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rdi
leaq 0x302df0(%rip), %rsi    # 0x57fc76
movl $0x6a, %edx
callq 0xe80f0
movq %rax, 0x38(%rsp)
movq 0x20(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq 0x18(%rsp), %rdx
callq 0xde110
movq 0x20(%rsp), %rdi
callq 0xde430
jmp 0x27ceb5
cmpl $0x0, 0x34(%rsp)
jne 0x27cf62
movq 0xa8(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x281a00
movq %rax, 0x48(%rsp)
testb $0x1, 0x9f(%rsp)
je 0x27ceeb
movq 0x48(%rsp), %rdi
callq 0x281bd0
testb $0x1, 0x9e(%rsp)
je 0x27cf60
movq 0xc0(%rsp), %rdi
movq 0xf0(%rsp), %r9
leaq 0x2a7536(%rip), %rsi    # 0x524442
leaq 0x2e8fb2(%rip), %rdx    # 0x565ec5
leaq 0x302d5c(%rip), %rcx    # 0x57fc76
movl $0x77, %r8d
callq 0xd92c0
movq %rax, 0x58(%rsp)
cmpq $0x0, 0x58(%rsp)
jne 0x27cf3a
movl $0xffffffff, 0x34(%rsp) # imm = 0xFFFFFFFF
cmpl $0x0, 0x34(%rsp)
jne 0x27cf5e
movq 0x48(%rsp), %rdi
movsd 0x90(%rsp), %xmm0
movq 0x38(%rsp), %rsi
movq 0x58(%rsp), %rdx
callq 0x281be0
jmp 0x27cf60
jmp 0x27cf62
cmpl $0x0, 0x34(%rsp)
jne 0x27d102
jmp 0x27cf6f
movq 0x68(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq 0xe0(%rsp), %rdx
callq 0xde110
movl %eax, 0x54(%rsp)
cmpl $0x0, %eax
jle 0x27d0cb
jmp 0x27cf95
movslq 0x54(%rsp), %rax
cmpq 0xe0(%rsp), %rax
jbe 0x27cfdc
movq 0x3beff5(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x29905e(%rip), %rsi    # 0x516013
leaq 0x302d23(%rip), %rdx    # 0x57fcdf
leaq 0x302c9b(%rip), %rcx    # 0x57fc5e
leaq 0x302cac(%rip), %r8     # 0x57fc76
movl $0x87, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x27cfde
movslq 0x54(%rsp), %rax
shrq $0x3, %rax
movl %eax, 0x54(%rsp)
movl $0x0, 0x50(%rsp)
movl 0x50(%rsp), %eax
cmpl 0x54(%rsp), %eax
jge 0x27d0c6
movq 0x40(%rsp), %rax
movl 0x50(%rsp), %ecx
shll %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movq %rax, 0x80(%rsp)
movq 0x40(%rsp), %rax
movl 0x50(%rsp), %ecx
shll %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movq %rax, 0x78(%rsp)
cmpq $0x0, 0x80(%rsp)
jne 0x27d08b
movq 0x70(%rsp), %rax
cmpq 0xa0(%rsp), %rax
jb 0x27d059
movq 0x48(%rsp), %rdi
callq 0x281ed0
jmp 0x27d063
movq 0x48(%rsp), %rdi
callq 0x281da0
movq 0x48(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0x2827f0
movq 0xa8(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0xb09f0
movq %rax, 0x70(%rsp)
jmp 0x27d0b4
movq 0x80(%rsp), %rax
addq 0x70(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x48(%rsp), %rdi
movq 0x78(%rsp), %rsi
movq 0x80(%rsp), %rdx
callq 0x282450
jmp 0x27d0b6
movl 0x50(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x50(%rsp)
jmp 0x27cff3
jmp 0x27cf6f
movq 0x70(%rsp), %rax
cmpq 0xa0(%rsp), %rax
jb 0x27d0e6
movq 0x48(%rsp), %rdi
callq 0x281ed0
jmp 0x27d0f0
movq 0x48(%rsp), %rdi
callq 0x281da0
movq 0x48(%rsp), %rdi
movq 0xe8(%rsp), %rsi
callq 0x282b10
cmpq $0x0, 0x58(%rsp)
je 0x27d114
movq 0x58(%rsp), %rdi
callq 0xd9390
movq 0x48(%rsp), %rdi
callq 0x281cf0
movq 0x68(%rsp), %rdi
callq 0xde430
movq 0x60(%rsp), %rdi
callq 0xde430
movq 0x40(%rsp), %rdi
leaq 0x302b38(%rip), %rsi    # 0x57fc76
movl $0xaa, %edx
callq 0xe88c0
movq 0x38(%rsp), %rdi
leaq 0x302b22(%rip), %rsi    # 0x57fc76
movl $0xab, %edx
callq 0xe88c0
xorl %eax, %eax
addq $0xc8, %rsp
retq
nopl (%rax,%rax)