// File: /workspace/github_c_makefile_star2_O2/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, %ebp
movq %rsi, %r15
movl %edi, %r14d
testq %r8, %r8
je 0x488fa
movq %r12, %rdi
callq 0x89eb7
testb %al, %al
jne 0x48fe0
movq %rbx, 0x48(%rsp)
testq %rbx, %rbx
je 0x48faf
callq 0xae154
movq %rax, %r13
movslq %ebp, %rax
movslq %r14d, %rbx
movq %rax, 0x58(%rsp)
movq %rax, %r14
cmpq %rbx, %r14
jge 0x48934
movq (%r15,%r14,8), %rsi
movq %r13, %rdi
callq 0xae22f
incq %r14
jmp 0x4891e
movq %r13, %rdi
callq 0x8e240
movq %rax, %r14
movq 0x48(%rsp), %rbx
cmpb $0x1, 0x5(%rbx)
jne 0x4895b
leaq 0x2b05fd(%rip), %rdi    # 0x2f8f4e
movq %r14, %rsi
xorl %eax, %eax
callq 0x17070
movq %r13, %rdi
movq %r12, %rsi
callq 0xa70d0
movq %rax, 0x38(%rsp)
testq %rax, %rax
movq %r15, 0x60(%rsp)
movq %r13, 0x70(%rsp)
je 0x48994
cmpb $0x1, 0x1(%rbx)
jne 0x489d2
callq 0x6d958
cmpb $0x1, 0x2(%rbx)
jne 0x489d4
movl $0x1, 0x8(%rbx)
jmp 0x489d4
pushq $-0x1
popq %r14
movq $0x0, 0x8(%rsp)
xorl %ebp, %ebp
movq $0x0, 0x18(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
xorl %r15d, %r15d
movq $0x0, 0x10(%rsp)
xorl %r13d, %r13d
jmp 0x48b92
xorl %eax, %eax
movq %rax, 0x8(%rsp)
cmpb $0x1, 0x4(%rbx)
jne 0x489f5
callq 0xba9f0
movq %rax, %r15
movq 0x10(%rbx), %rsi
movq %rax, %rdi
callq 0xbab1f
jmp 0x489f8
xorl %r15d, %r15d
cmpb $0x1, 0x3(%rbx)
jne 0x48a0a
callq 0x6d958
movq %rax, 0x18(%rsp)
jmp 0x48a13
movq $0x0, 0x18(%rsp)
movq %r15, 0x50(%rsp)
cmpb $0x1, (%rbx)
jne 0x48a35
movq 0x38(%rsp), %rdi
movq %r14, %rsi
callq 0xa6337
movq %rax, %rdi
movq %r14, %rsi
callq 0x9c79c
movq $0x0, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
xorl %r15d, %r15d
movq $0x0, 0x10(%rsp)
xorl %r13d, %r13d
xorl %ebp, %ebp
andq $0x0, 0x78(%rsp)
movq 0x38(%rsp), %rdi
leaq 0x80(%rsp), %rsi
leaq 0x40(%rsp), %rdx
leaq 0x78(%rsp), %rcx
movq %r12, %r8
callq 0xa62e5
cmpl $0x1, %eax
jne 0x48b76
movb 0x1(%rbx), %al
testb %al, %al
jne 0x48a93
cmpb $0x1, 0x4(%rbx)
jne 0x48af6
movq 0x40(%rsp), %r14
cmpq %r14, %r15
cmovaeq %r14, %r15
testb $0x1, %bpl
cmoveq %r14, %r15
movq 0x10(%rsp), %rcx
cmpq %r14, %rcx
cmovbeq %r14, %rcx
movq %rcx, 0x10(%rsp)
testb %al, %al
je 0x48ad4
movl 0x8(%rbx), %ecx
movq %r14, %rax
xorl %edx, %edx
divq %rcx
movq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x6d96d
addq %r14, 0x30(%rsp)
incq 0x28(%rsp)
movb $0x1, %bpl
cmpb $0x1, 0x4(%rbx)
jne 0x48af6
movq 0x40(%rsp), %rsi
movq 0x50(%rsp), %rdi
callq 0xbaa5e
cmpb $0x1, 0x3(%rbx)
jne 0x48a58
movq %r13, 0x20(%rsp)
movq %r12, 0x68(%rsp)
movq 0x80(%rsp), %r13
movq 0x40(%rsp), %rbx
xorl %r12d, %r12d
xorl %esi, %esi
xorl %r14d, %r14d
cmpq %r12, %rbx
je 0x48b50
movzbl (%r13,%r12), %eax
orl $0x20, %eax
cmpl $0x61, %eax
jne 0x48b3a
incq %r14
incq %rsi
jmp 0x48b4b
testq %rsi, %rsi
je 0x48b49
movq 0x18(%rsp), %rdi
callq 0x6d96d
xorl %esi, %esi
incq %r12
jmp 0x48b1f
testq %rsi, %rsi
je 0x48b5f
movq 0x18(%rsp), %rdi
callq 0x6d96d
movq 0x20(%rsp), %r13
addq %r14, %r13
movq 0x48(%rsp), %rbx
movq 0x68(%rsp), %r12
jmp 0x48a58
movl %eax, %r14d
cmpb $0x1, (%rbx)
jne 0x48b83
callq 0x9cce9
movq 0x38(%rsp), %rdi
callq 0xa6389
movq 0x50(%rsp), %rbp
movq 0x70(%rsp), %rdi
callq 0xae662
testl %r14d, %r14d
jne 0x48e51
cmpb $0x1, 0x1(%rbx)
jne 0x48d20
movq 0x30(%rsp), %r14
movq %r14, %xmm1
movq 0x29ed1f(%rip), %xmm2   # 0x2e78e0
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x29ed23(%rip), %xmm3   # 0x2e78f0
subpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq 0x28(%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 0x2b0367(%rip), %rdi    # 0x2f8f6d
movb $0x1, %al
callq 0x17070
leaq 0x2b0381(%rip), %rdi    # 0x2f8f95
movq %r14, %rsi
xorl %eax, %eax
callq 0x17070
leaq 0x2b0384(%rip), %rdi    # 0x2f8fa9
movq %r15, %rsi
xorl %eax, %eax
callq 0x17070
leaq 0x2b0389(%rip), %rdi    # 0x2f8fbf
movq 0x10(%rsp), %rsi
xorl %eax, %eax
callq 0x17070
cmpb $0x1, 0x2(%rbx)
jne 0x48cec
movq 0x60(%rsp), %rax
movq 0x58(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xacbd1
movq %rax, %r14
leaq 0x2b036c(%rip), %rsi    # 0x2f8fd5
movq %rax, %rdi
callq 0xacbfb
movq %r14, %rdi
callq 0xad1fa
leaq 0x2ace71(%rip), %rsi    # 0x2f5af1
leaq 0x2b0094(%rip), %rdx    # 0x2f8d1b
movq %rax, %rdi
movl $0x183, %ecx            # imm = 0x183
movq %r12, %r8
callq 0x8a156
testq %rax, %rax
je 0x48f63
movq %rax, %r15
leaq 0x3fb(%rip), %rsi       # 0x490a5
movq 0x8(%rsp), %rdi
movq %rdi, 0x8(%rsp)
movq %rax, %rdx
callq 0x6dc7c
movq %r14, %rdi
callq 0xad1fa
leaq 0x2b0313(%rip), %rdi    # 0x2f8fde
movq %rax, %rsi
xorl %eax, %eax
callq 0x17070
movq %r15, %rdi
movq 0x8(%rsp), %r15
callq 0x8a4fd
movq %r14, %rdi
callq 0xae103
jmp 0x48d18
leaq 0x8(%rbx), %r14
movl 0x8(%rbx), %esi
leaq 0x2b031b(%rip), %rdi    # 0x2f9015
xorl %eax, %eax
callq 0x17070
leaq 0x3f1(%rip), %rsi       # 0x490f9
movq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
callq 0x6dc7c
movq %r15, %rdi
callq 0x6e064
xorl %r14d, %r14d
cmpb $0x1, 0x4(%rbx)
jne 0x48e51
movq 0x3ef17c(%rip), %rax    # 0x437eb0
movq (%rax), %rdx
leaq 0x29db96(%rip), %rsi    # 0x2e68d4
pushq $0x1
popq %rdi
callq 0x92b50
movq %rax, %r14
movq 0x18(%rbx), %rdi
callq 0xae61c
testq %rax, %rax
jne 0x48d83
pushq $0x32
popq %rsi
movq %rbp, %rdi
movq %r12, %rdx
callq 0xbad79
testl %eax, %eax
jne 0x4903f
pushq $0x50
popq %rsi
movq %rbp, %rdi
movq %r12, %rdx
callq 0xbad79
testl %eax, %eax
jne 0x4906d
movq %r14, 0x10(%rsp)
movq %rbp, %r15
movq %r13, 0x20(%rsp)
movq %r12, %rbp
xorl %r12d, %r12d
leaq 0x88(%rsp), %r13
movq 0x18(%rbx), %rdi
callq 0xae61c
cmpq %rax, %r12
jae 0x48df6
orq $-0x1, 0x88(%rsp)
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xae386
movq %r13, %rdi
movq %rax, %rsi
callq 0x9bd05
testl %eax, %eax
jne 0x48e13
movq 0x88(%rsp), %rsi
cmpq $-0x1, %rsi
je 0x48f7e
movq %r15, %rdi
movq %rbp, %rdx
callq 0xbad79
testl %eax, %eax
jne 0x48e39
incq %r12
jmp 0x48d9e
movq %r15, %rbp
movq %r15, %rdi
movq 0x10(%rsp), %r15
movq %r15, %rsi
callq 0xbae5e
xorl %r14d, %r14d
movq 0x20(%rsp), %r13
jmp 0x48e49
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xae386
leaq 0x2b0228(%rip), %rsi    # 0x2f904e
movq %rbp, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x89dbb
pushq $-0x1
popq %r14
jmp 0x48e3c
movl %eax, %r14d
movq 0x20(%rsp), %r13
movq %r15, %rbp
movq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x92fd0
testq %rbp, %rbp
je 0x48e5e
movq %rbp, %rdi
callq 0xbaa2f
testl %r14d, %r14d
jne 0x48f4e
cmpb $0x1, 0x3(%rbx)
jne 0x48f4e
leaq 0x88(%rsp), %rbx
andq $0x0, (%rbx)
andq $0x0, 0x10(%rbx)
movq $0xa, 0x18(%rbx)
leaq 0x28a(%rip), %rsi       # 0x4911b
movq 0x18(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rdx
callq 0x6dc7c
movq 0x10(%rbx), %rax
leaq 0x8(,%rax,8), %rdi
leaq 0x2afe67(%rip), %rsi    # 0x2f8d1b
movl $0xff, %edx
callq 0x93160
movq %rax, 0x8(%rbx)
movq 0x10(%rbx), %rcx
leaq 0x8(,%rcx,8), %rdx
movq %rax, %rdi
xorl %esi, %esi
callq 0x17380
leaq 0x267(%rip), %rsi       # 0x49146
movq %r15, %rdi
movq %rbx, %rdx
callq 0x6dc7c
movq 0x18(%rbx), %rbx
leaq 0x2b019e(%rip), %r15    # 0x2f9093
cmpq 0x98(%rsp), %rbx
ja 0x48f1d
movq 0x90(%rsp), %rax
movq (%rax,%rbx,8), %rdx
movq %r15, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x17070
incq %rbx
jmp 0x48ef5
cmpq %r13, 0x88(%rsp)
jne 0x49011
movq 0x90(%rsp), %rdi
leaq 0x2afde1(%rip), %rsi    # 0x2f8d1b
movl $0x10b, %edx            # imm = 0x10B
callq 0x936f9
movq 0x18(%rsp), %rdi
callq 0x6e064
movl %r14d, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
callq 0xae103
movq 0x8(%rsp), %rdi
callq 0x6e064
pushq $-0x1
popq %r14
jmp 0x48e51
movq 0x3eefe3(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x29c084(%rip), %rsi    # 0x2e5013
leaq 0x2b00d9(%rip), %rdx    # 0x2f906f
leaq 0x2aff9f(%rip), %rcx    # 0x2f8f3c
leaq 0x2afd77(%rip), %r8     # 0x2f8d1b
movl $0x1ad, %r9d            # imm = 0x1AD
jmp 0x49099
movq 0x3eefb2(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x29c053(%rip), %rsi    # 0x2e5013
leaq 0x2ff68c(%rip), %rdx    # 0x348653
leaq 0x2aff6e(%rip), %rcx    # 0x2f8f3c
leaq 0x2afd46(%rip), %r8     # 0x2f8d1b
movl $0x123, %r9d            # imm = 0x123
jmp 0x49099
movq 0x3eef81(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x29c022(%rip), %rsi    # 0x2e5013
leaq 0x29c1c7(%rip), %rdx    # 0x2e51bf
leaq 0x2aff3d(%rip), %rcx    # 0x2f8f3c
leaq 0x2afd15(%rip), %r8     # 0x2f8d1b
movl $0x122, %r9d            # imm = 0x122
jmp 0x49099
movq 0x3eef50(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x29bff1(%rip), %rsi    # 0x2e5013
leaq 0x2b0085(%rip), %rdx    # 0x2f90ae
leaq 0x2b009a(%rip), %rcx    # 0x2f90ca
leaq 0x2afce4(%rip), %r8     # 0x2f8d1b
movl $0x10a, %r9d            # imm = 0x10A
jmp 0x49099
movq 0x3eef22(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x29bfc3(%rip), %rsi    # 0x2e5013
leaq 0x29c628(%rip), %rdx    # 0x2e567f
leaq 0x2afede(%rip), %rcx    # 0x2f8f3c
leaq 0x2afcb6(%rip), %r8     # 0x2f8d1b
movl $0x1a1, %r9d            # imm = 0x1A1
jmp 0x49099
movq 0x3eeef4(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x29bf95(%rip), %rsi    # 0x2e5013
leaq 0x29c5fa(%rip), %rdx    # 0x2e567f
leaq 0x2afeb0(%rip), %rcx    # 0x2f8f3c
leaq 0x2afc88(%rip), %r8     # 0x2f8d1b
movl $0x1a3, %r9d            # imm = 0x1A3
xorl %eax, %eax
callq 0x17a50
callq 0x17390