// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/tools/gt_seqstat.c
// Function: gt_seqstat_runner
static int gt_seqstat_runner(int argc, const char **argv, int parsed_args,
                             void *tool_arguments, GtError *err)
{
  SeqstatArguments *arguments = tool_arguments;
  GtStrArray *files;
  GtSeqIterator *seqit;
  const GtUchar *sequence;
  char *desc;
  GtUword len;
  int i, had_err = 0;
  off_t totalsize;
  GtDiscDistri *distseqlen = NULL;
  GtAssemblyStatsCalculator *asc = NULL;
  GtLogger *asc_logger = NULL;
  GtDiscDistri *distastretch = NULL;
  uint64_t numofseq = 0, sumlength = 0;
  GtUword minlength = 0, maxlength = 0;
  GtUint64 countA = 0;
  bool minlengthdefined = false;

  gt_error_check(err);
  gt_assert(arguments);

  files = gt_str_array_new();
  for (i = parsed_args; i < argc; i++)
  {
    gt_str_array_add_cstr(files, argv[i]);
  }
  totalsize = gt_files_estimate_total_size(files);
  if (arguments->showestimsize)
  {
    printf("# estimated total size is " Formatuint64_t "\n",
              PRINTuint64_tcast(totalsize));
  }
  if (!had_err) {
    /* read input using seqiterator */
    seqit = gt_seq_iterator_sequence_buffer_new(files, err);
    if (!seqit)
      had_err = -1;
    if (!had_err)
    {
      if (arguments->dodistlen)
      {
        distseqlen = gt_disc_distri_new();
        if (arguments->binarydistlen)
          arguments->bucketsize = 1U;
      }
      if (arguments->docstats)
      {
        asc = gt_assembly_stats_calculator_new();
        gt_assembly_stats_calculator_set_genome_length(asc,
            arguments->genome_length);
      }
      if (arguments->doastretch)
      {
        distastretch = gt_disc_distri_new();
      }
      if (arguments->verbose)
      {
        gt_progressbar_start(gt_seq_iterator_getcurrentcounter(seqit,
                                                            (GtUint64)
                                                            totalsize),
                             (GtUint64) totalsize);
      }
      while (true)
      {
        desc = NULL;
        had_err = gt_seq_iterator_next(seqit, &sequence, &len, &desc, err);
        if (had_err != 1) break; /* 0: finished; 1: error */
        if (arguments->dodistlen || arguments->docstats)
        {
          if (!minlengthdefined || minlength > len)
          {
            minlength = len;
            minlengthdefined = true;
          }
          if (maxlength < len)
          {
            maxlength = len;
          }
          sumlength += (uint64_t) len;
          numofseq++;
          if (arguments->dodistlen)
          {
            gt_disc_distri_add(distseqlen,len/arguments->bucketsize);
          }
          if (arguments->docstats)
          {
            gt_assembly_stats_calculator_add(asc, len);
          }
        }
        if (arguments->doastretch)
        {
          countA += accumulateastretch(distastretch,sequence,len);
        }
      }
      if (arguments->verbose)
      {
        gt_progressbar_stop();
      }
      gt_seq_iterator_delete(seqit);
    }
  }
  gt_str_array_delete(files);
  if (!had_err && arguments->dodistlen)
  {
    printf("# " Formatuint64_t " sequences of average length %.2f\n",
             PRINTuint64_tcast(numofseq),(double) sumlength/numofseq);
    printf("# total length " Formatuint64_t "\n",
             PRINTuint64_tcast(sumlength));
    printf("# minimum length "GT_WU"\n",minlength);
    printf("# maximum length "GT_WU"\n",maxlength);
    if (arguments->binarydistlen)
    {
      FILE *distlenoutfile;
      GtStr *distlenoutfilename = gt_str_new_cstr(argv[parsed_args]);
      gt_str_append_cstr(distlenoutfilename, GT_SEQSTAT_BINARY_DISTLEN_SUFFIX);
      distlenoutfile = gt_fa_fopen(gt_str_get(distlenoutfilename), "wb", err);
      if (distlenoutfile == NULL)
        had_err = -1;
      else
      {
        /*@ignore@*/
        gt_disc_distri_foreach(distseqlen, showdistseqlenbinary,
            distlenoutfile);
        /*@end@*/
        printf("# distribution of sequence length written to file: %s\n",
          gt_str_get(distlenoutfilename));
        gt_fa_fclose(distlenoutfile);
      }
      gt_str_delete(distlenoutfilename);
    }
    else
    {
      printf("# distribution of sequence length in buckets of size %u\n",
          arguments->bucketsize);
      gt_disc_distri_foreach(distseqlen, showdistseqlen,
          &(arguments->bucketsize));
    }
    gt_disc_distri_delete(distseqlen);
  }
  if (!had_err && arguments->docstats)
  {
    GtUword i;
    asc_logger = gt_logger_new(true, GT_LOGGER_DEFLT_PREFIX, stdout);
    if (gt_str_array_size(arguments->nstats) == 0) {
      had_err = gt_assembly_stats_calculator_register_nstat(asc, 50, err);
      gt_assert(!had_err); /* 50 and 80 are sane */
      had_err = gt_assembly_stats_calculator_register_nstat(asc, 80, err);
      gt_assert(!had_err); /* 50 and 80 are sane */
    }
    for (i = 0; !had_err && i < gt_str_array_size(arguments->nstats); i++) {
      GtUword val = GT_UNDEF_UWORD;
      if (gt_parse_uword(&val, gt_str_array_get(arguments->nstats, i)) != 0) {
        gt_error_set(err, "could not parse nstat value '%s'",
                     gt_str_array_get(arguments->nstats, i));
        had_err = -1;
        break;
      }
      gt_assert(val != GT_UNDEF_UWORD);
      had_err = gt_assembly_stats_calculator_register_nstat(asc, val, err);
      if (had_err) break;
    }
    if (!had_err)
      gt_assembly_stats_calculator_show(asc, asc_logger);
    gt_logger_delete(asc_logger);
  }
  if (asc != NULL)
    gt_assembly_stats_calculator_delete(asc);
  if (!had_err && arguments->doastretch)
  {
    processastretches(distastretch,countA);
    gt_disc_distri_delete(distastretch);
  }
  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %r8, %r12
movq %rcx, %rbx
movl %edx, %r13d
movq %rsi, %r15
movl %edi, %r14d
testq %r8, %r8
je 0xc4689
movq %r12, %rdi
callq 0xfcc32
testb %al, %al
jne 0xc4d5f
movq %rbx, 0x40(%rsp)
testq %rbx, %rbx
je 0xc4d55
callq 0x11be10
movq %rax, %rbp
cmpl %r14d, %r13d
jge 0xc46be
movslq %r13d, %rbx
movslq %r14d, %r14
movq (%r15,%rbx,8), %rsi
movq %rbp, %rdi
callq 0x11bee9
incq %rbx
cmpq %rbx, %r14
jne 0xc46aa
movq %rbp, %rdi
callq 0xff877
movq %rax, %r14
movq 0x40(%rsp), %rbx
cmpb $0x1, 0x5(%rbx)
jne 0xc46e5
leaq 0x29489b(%rip), %rdi    # 0x358f76
movq %r14, %rsi
xorl %eax, %eax
callq 0x17070
movq %rbp, %rdi
movq %r12, %rsi
callq 0x114f10
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0xc471c
movq %r15, 0x78(%rsp)
cmpb $0x1, 0x1(%rbx)
jne 0xc472f
callq 0xe54e0
movq %rax, %r15
cmpb $0x1, 0x2(%rbx)
jne 0xc4732
movl $0x1, 0x8(%rbx)
jmp 0xc4732
movq %rbp, %rdi
callq 0x11c144
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jmp 0xc4d25
xorl %r15d, %r15d
movq %rbp, 0x80(%rsp)
cmpb $0x1, 0x4(%rbx)
jne 0xc4756
callq 0x125aa8
movq %rax, %rbp
movq 0x10(%rbx), %rsi
movq %rax, %rdi
callq 0x125b8c
jmp 0xc4758
xorl %ebp, %ebp
cmpb $0x1, 0x3(%rbx)
jne 0xc476a
callq 0xe54e0
movq %rax, 0x18(%rsp)
jmp 0xc4773
movq $0x0, 0x18(%rsp)
movl %r13d, 0x5c(%rsp)
movq %r15, 0x38(%rsp)
cmpb $0x1, (%rbx)
jne 0xc479a
movq 0x20(%rsp), %rdi
movq %r14, %rsi
callq 0x11435e
movq %rax, %rdi
movq %r14, %rsi
callq 0x10ba28
leaq 0x68(%rsp), %rcx
movq $0x0, (%rcx)
leaq 0x70(%rsp), %rsi
leaq 0x30(%rsp), %rdx
movq 0x20(%rsp), %rdi
movq %r12, %r8
callq 0x11433d
cmpl $0x1, %eax
movq %r12, 0x10(%rsp)
movq %rbp, 0x8(%rsp)
jne 0xc491c
movq $0x0, 0x60(%rsp)
xorl %r14d, %r14d
movq $0x0, 0x28(%rsp)
xorl %r15d, %r15d
movq $0x0, 0x50(%rsp)
movq $0x0, 0x48(%rsp)
movb 0x1(%rbx), %al
testb %al, %al
jne 0xc4807
cmpb $0x1, 0x4(%rbx)
jne 0xc486d
movq 0x30(%rsp), %r13
cmpq %r13, %r15
cmovaeq %r13, %r15
testb $0x1, 0x60(%rsp)
cmoveq %r13, %r15
movq 0x28(%rsp), %rcx
cmpq %r13, %rcx
cmovbeq %r13, %rcx
movq %rcx, 0x28(%rsp)
testb %al, %al
je 0xc4849
movl 0x8(%rbx), %ecx
movq %r13, %rax
xorl %edx, %edx
divq %rcx
movq 0x38(%rsp), %rdi
movq %rax, %rsi
callq 0xe54fb
addq %r13, 0x50(%rsp)
incq 0x48(%rsp)
movb $0x1, %al
movq %rax, 0x60(%rsp)
cmpb $0x1, 0x4(%rbx)
jne 0xc486d
movq 0x30(%rsp), %rsi
movq %rbp, %rdi
callq 0x125b21
cmpb $0x1, 0x3(%rbx)
jne 0xc48e9
movq 0x30(%rsp), %r12
testq %r12, %r12
je 0xc48de
movq %r14, %rbp
movq 0x70(%rsp), %rbx
xorl %r13d, %r13d
xorl %esi, %esi
xorl %r14d, %r14d
movzbl (%rbx,%r14), %eax
orl $0x20, %eax
cmpl $0x61, %eax
jne 0xc48a2
incq %r13
incq %rsi
jmp 0xc48b3
testq %rsi, %rsi
je 0xc48b1
movq 0x18(%rsp), %rdi
callq 0xe54fb
xorl %esi, %esi
incq %r14
cmpq %r14, %r12
jne 0xc488d
testq %rsi, %rsi
movq %rbp, %r14
je 0xc48cd
movq 0x18(%rsp), %rdi
callq 0xe54fb
movq 0x40(%rsp), %rbx
movq 0x10(%rsp), %r12
movq 0x8(%rsp), %rbp
jmp 0xc48e6
xorl %r13d, %r13d
movq 0x10(%rsp), %r12
addq %r13, %r14
movq $0x0, 0x68(%rsp)
movq 0x20(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x30(%rsp), %rdx
leaq 0x68(%rsp), %rcx
movq %r12, %r8
callq 0x11433d
cmpl $0x1, %eax
je 0xc47fa
movl %eax, %r13d
jmp 0xc4940
movl %eax, %r13d
movq $0x0, 0x48(%rsp)
movq $0x0, 0x50(%rsp)
xorl %r15d, %r15d
movq $0x0, 0x28(%rsp)
xorl %r14d, %r14d
cmpb $0x1, (%rbx)
jne 0xc494a
callq 0x10bf8a
movq 0x20(%rsp), %rdi
callq 0x11437f
movq 0x80(%rsp), %rdi
callq 0x11c144
testl %r13d, %r13d
jne 0xc4c1f
cmpb $0x1, 0x1(%rbx)
jne 0xc4ae9
movq %r14, %rbp
movq 0x50(%rsp), %r14
movq %r14, %xmm1
movq 0x282f57(%rip), %xmm2   # 0x3478e0
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x282f5b(%rip), %xmm3   # 0x3478f0
subpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq 0x48(%rsp), %rsi
movq %rsi, %xmm1
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
subpd %xmm3, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
leaq 0x2945c7(%rip), %rdi    # 0x358f95
movb $0x1, %al
callq 0x17070
leaq 0x2945e1(%rip), %rdi    # 0x358fbd
movq %r14, %rsi
xorl %eax, %eax
callq 0x17070
leaq 0x2945e4(%rip), %rdi    # 0x358fd1
movq %r15, %rsi
xorl %eax, %eax
callq 0x17070
leaq 0x2945e9(%rip), %rdi    # 0x358fe7
movq 0x28(%rsp), %rsi
xorl %eax, %eax
callq 0x17070
cmpb $0x1, 0x2(%rbx)
jne 0xc4aad
movslq 0x5c(%rsp), %rax
movq 0x78(%rsp), %rcx
movq (%rcx,%rax,8), %rdi
callq 0x11acc9
movq %rax, %r14
leaq 0x2945cc(%rip), %rsi    # 0x358ffd
movq %rax, %rdi
callq 0x11acf3
movq %r14, %rdi
callq 0x11b0a1
leaq 0x291099(%rip), %rsi    # 0x355ae1
leaq 0x2942f4(%rip), %rdx    # 0x358d43
movq %rax, %rdi
movl $0x183, %ecx            # imm = 0x183
movq %r12, %r8
callq 0xfcdbb
testq %rax, %rax
movq 0x38(%rsp), %r13
je 0xc4d3a
movq %rax, %r15
leaq 0x2fc(%rip), %rsi       # 0xc4d73
movq %r13, %rdi
movq %rax, %rdx
callq 0xe56e5
movq %r14, %rdi
callq 0x11b0a1
leaq 0x294575(%rip), %rdi    # 0x359006
movq %rax, %rsi
xorl %eax, %eax
callq 0x17070
movq %r15, %rdi
callq 0xfd018
movq %r14, %rdi
callq 0x11bdbf
jmp 0xc4ad9
leaq 0x8(%rbx), %r14
movl 0x8(%rbx), %esi
leaq 0x294582(%rip), %rdi    # 0x35903d
xorl %eax, %eax
callq 0x17070
leaq 0x2f6(%rip), %rsi       # 0xc4dbf
movq 0x38(%rsp), %r13
movq %r13, %rdi
movq %r14, %rdx
callq 0xe56e5
movq %r13, %rdi
callq 0xe5a93
movq %rbp, %r14
movq 0x8(%rsp), %rbp
xorl %r13d, %r13d
cmpb $0x1, 0x4(%rbx)
jne 0xc4c1f
movq %r14, %rbp
movq 0x3f43d8(%rip), %rax    # 0x4b8ed8
movq (%rax), %rdx
leaq 0x281dca(%rip), %rsi    # 0x3468d4
movl $0x1, %edi
callq 0x103e40
movq %rax, %r14
movq 0x18(%rbx), %rdi
callq 0x11c131
testq %rax, %rax
jne 0xc4b5a
movl $0x32, %esi
movq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r12, %rdx
callq 0x125d57
testl %eax, %eax
jne 0xc4d69
movl $0x50, %esi
movq %r15, %rdi
movq %r12, %rdx
callq 0x125d57
testl %eax, %eax
jne 0xc4d6e
movq 0x18(%rbx), %rdi
callq 0x11c131
testq %rax, %rax
je 0xc4bd0
xorl %r15d, %r15d
leaq 0x88(%rsp), %r12
movq $-0x1, 0x88(%rsp)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0x11bfb3
movq %r12, %rdi
movq %rax, %rsi
callq 0x10b217
testl %eax, %eax
jne 0xc4be2
movq 0x88(%rsp), %rsi
cmpq $-0x1, %rsi
je 0xc4d5a
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rdx
callq 0x125d57
testl %eax, %eax
jne 0xc4c0c
incq %r15
movq 0x18(%rbx), %rdi
callq 0x11c131
cmpq %rax, %r15
jb 0xc4b73
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x125e25
xorl %r13d, %r13d
jmp 0xc4c0f
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0x11bfb3
leaq 0x294481(%rip), %rsi    # 0x359076
movq 0x10(%rsp), %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xfcb67
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jmp 0xc4c0f
movl %eax, %r13d
movq %r14, %rdi
callq 0x1040e0
movq %rbp, %r14
movq 0x8(%rsp), %rbp
testq %rbp, %rbp
je 0xc4c2c
movq %rbp, %rdi
callq 0x125af0
testl %r13d, %r13d
jne 0xc4d25
xorl %r13d, %r13d
cmpb $0x1, 0x3(%rbx)
jne 0xc4d25
movq %r14, %r15
xorl %eax, %eax
leaq 0x88(%rsp), %rbx
movq %rax, (%rbx)
movq %rax, 0x10(%rbx)
movq $0xa, 0x18(%rbx)
leaq 0x17c(%rip), %rsi       # 0xc4de1
movq 0x18(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rdx
callq 0xe56e5
movq 0x10(%rbx), %rax
leaq 0x8(,%rax,8), %rdi
leaq 0x2940bb(%rip), %rsi    # 0x358d43
movl $0xff, %edx
callq 0x104226
movq %rax, 0x8(%rbx)
movq 0x10(%rbx), %rcx
leaq 0x8(,%rcx,8), %rdx
movq %rax, %rdi
xorl %esi, %esi
callq 0x173a0
leaq 0x159(%rip), %rsi       # 0xc4e0c
movq %r14, %rdi
movq %rbx, %rdx
callq 0xe56e5
movq 0x18(%rbx), %r14
cmpq 0x10(%rbx), %r14
ja 0xc4cf5
leaq 0x2943ec(%rip), %rbx    # 0x3590bb
movq 0x90(%rsp), %rax
movq (%rax,%r14,8), %rdx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x17070
incq %r14
cmpq 0x98(%rsp), %r14
jbe 0xc4ccf
cmpq %r15, 0x88(%rsp)
jne 0xc4d64
movq 0x90(%rsp), %rdi
leaq 0x294035(%rip), %rsi    # 0x358d43
movl $0x10b, %edx            # imm = 0x10B
callq 0x1045eb
movq 0x18(%rsp), %rdi
callq 0xe5a93
xorl %r13d, %r13d
movl %r13d, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
callq 0x11bdbf
movq %r13, %rdi
callq 0xe5a93
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jmp 0xc4c17
callq 0x1f383
callq 0x1f311
callq 0x1f266
callq 0x1f34a
callq 0x1f29f
callq 0x1f2d8