// File: /workspace/github_c_makefile_star2_O0/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:
subq $0xf8, %rsp
movl %edi, 0xf4(%rsp)
movq %rsi, 0xe8(%rsp)
movl %edx, 0xe4(%rsp)
movq %rcx, 0xd8(%rsp)
movq %r8, 0xd0(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0xc8(%rsp)
movl $0x0, 0x98(%rsp)
movq $0x0, 0x88(%rsp)
movq $0x0, 0x80(%rsp)
movq $0x0, 0x78(%rsp)
movq $0x0, 0x70(%rsp)
movq $0x0, 0x68(%rsp)
movq $0x0, 0x60(%rsp)
movq $0x0, 0x58(%rsp)
movq $0x0, 0x50(%rsp)
movq $0x0, 0x48(%rsp)
movb $0x0, 0x47(%rsp)
cmpq $0x0, 0xd0(%rsp)
je 0x66c0a
movq 0xd0(%rsp), %rdi
callq 0xd8a60
testb $0x1, %al
jne 0x66bd2
jmp 0x66c0a
movq 0x5d53c7(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x4af430(%rip), %rsi    # 0x516013
leaq 0x4af5d5(%rip), %rdx    # 0x5161bf
leaq 0x4c3447(%rip), %rcx    # 0x52a038
leaq 0x4c3226(%rip), %r8     # 0x529e1e
movl $0x122, %r9d            # imm = 0x122
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x66c0c
jmp 0x66c0e
cmpq $0x0, 0xc8(%rsp)
jne 0x66c51
movq 0x5d5380(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x4af3e9(%rip), %rsi    # 0x516013
leaq 0x513f2e(%rip), %rdx    # 0x57ab5f
leaq 0x4c3400(%rip), %rcx    # 0x52a038
leaq 0x4c31df(%rip), %r8     # 0x529e1e
movl $0x123, %r9d            # imm = 0x123
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x66c53
callq 0x11f5c0
movq %rax, 0xc0(%rsp)
movl 0xe4(%rsp), %eax
movl %eax, 0x9c(%rsp)
movl 0x9c(%rsp), %eax
cmpl 0xf4(%rsp), %eax
jge 0x66cb2
movq 0xc0(%rsp), %rdi
movq 0xe8(%rsp), %rax
movslq 0x9c(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x11f720
movl 0x9c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x9c(%rsp)
jmp 0x66c6e
movq 0xc0(%rsp), %rdi
callq 0xdf4c0
movq %rax, 0x90(%rsp)
movq 0xc8(%rsp), %rax
testb $0x1, 0x5(%rax)
je 0x66ceb
movq 0x90(%rsp), %rsi
leaq 0x4c3366(%rip), %rdi    # 0x52a04a
movb $0x0, %al
callq 0x19070
cmpl $0x0, 0x98(%rsp)
jne 0x66f7a
movq 0xc0(%rsp), %rdi
movq 0xd0(%rsp), %rsi
callq 0x113240
movq %rax, 0xb8(%rsp)
cmpq $0x0, 0xb8(%rsp)
jne 0x66d2c
movl $0xffffffff, 0x98(%rsp) # imm = 0xFFFFFFFF
cmpl $0x0, 0x98(%rsp)
jne 0x66f78
movq 0xc8(%rsp), %rax
testb $0x1, 0x1(%rax)
je 0x66d74
callq 0xa5080
movq %rax, 0x88(%rsp)
movq 0xc8(%rsp), %rax
testb $0x1, 0x2(%rax)
je 0x66d72
movq 0xc8(%rsp), %rax
movl $0x1, 0x8(%rax)
jmp 0x66d74
movq 0xc8(%rsp), %rax
testb $0x1, 0x4(%rax)
je 0x66da8
callq 0x1330e0
movq %rax, 0x80(%rsp)
movq 0x80(%rsp), %rdi
movq 0xc8(%rsp), %rax
movq 0x10(%rax), %rsi
callq 0x1332d0
movq 0xc8(%rsp), %rax
testb $0x1, 0x3(%rax)
je 0x66dc0
callq 0xa5080
movq %rax, 0x70(%rsp)
movq 0xc8(%rsp), %rax
testb $0x1, (%rax)
je 0x66df2
movq 0xb8(%rsp), %rdi
movq 0x90(%rsp), %rsi
callq 0x111b70
movq %rax, %rdi
movq 0x90(%rsp), %rsi
callq 0xf9830
jmp 0x66df4
movq $0x0, 0xa8(%rsp)
movq 0xb8(%rsp), %rdi
movq 0xd0(%rsp), %r8
leaq 0xb0(%rsp), %rsi
leaq 0xa0(%rsp), %rdx
leaq 0xa8(%rsp), %rcx
callq 0x111ab0
movl %eax, 0x98(%rsp)
cmpl $0x1, 0x98(%rsp)
je 0x66e43
jmp 0x66f59
movq 0xc8(%rsp), %rax
testb $0x1, 0x1(%rax)
jne 0x66e63
movq 0xc8(%rsp), %rax
testb $0x1, 0x4(%rax)
je 0x66f22
testb $0x1, 0x47(%rsp)
je 0x66e79
movq 0x58(%rsp), %rax
cmpq 0xa0(%rsp), %rax
jbe 0x66e8b
movq 0xa0(%rsp), %rax
movq %rax, 0x58(%rsp)
movb $0x1, 0x47(%rsp)
movq 0x50(%rsp), %rax
cmpq 0xa0(%rsp), %rax
jae 0x66ea7
movq 0xa0(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0xa0(%rsp), %rax
addq 0x60(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x68(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x68(%rsp)
movq 0xc8(%rsp), %rax
testb $0x1, 0x1(%rax)
je 0x66efd
movq 0x88(%rsp), %rdi
movq 0xa0(%rsp), %rax
movq 0xc8(%rsp), %rcx
movl 0x8(%rcx), %ecx
xorl %edx, %edx
divq %rcx
movq %rax, %rsi
callq 0xa50a0
movq 0xc8(%rsp), %rax
testb $0x1, 0x4(%rax)
je 0x66f20
movq 0x80(%rsp), %rdi
movq 0xa0(%rsp), %rsi
callq 0x1331b0
jmp 0x66f22
movq 0xc8(%rsp), %rax
testb $0x1, 0x3(%rax)
je 0x66f54
movq 0x70(%rsp), %rdi
movq 0xb0(%rsp), %rsi
movq 0xa0(%rsp), %rdx
callq 0x67450
addq 0x48(%rsp), %rax
movq %rax, 0x48(%rsp)
jmp 0x66df4
movq 0xc8(%rsp), %rax
testb $0x1, (%rax)
je 0x66f6b
callq 0xfa220
movq 0xb8(%rsp), %rdi
callq 0x111c10
jmp 0x66f7a
movq 0xc0(%rsp), %rdi
callq 0x11fd20
cmpl $0x0, 0x98(%rsp)
jne 0x6714f
movq 0xc8(%rsp), %rax
testb $0x1, 0x1(%rax)
je 0x6714f
movq 0x68(%rsp), %rsi
movaps 0x4b197d(%rip), %xmm3   # 0x518930
movq 0x60(%rsp), %xmm0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x4b197b(%rip), %xmm2   # 0x518940
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq %rsi, %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
leaq 0x4c3072(%rip), %rdi    # 0x52a069
movb $0x1, %al
callq 0x19070
movq 0x60(%rsp), %rsi
leaq 0x4c3087(%rip), %rdi    # 0x52a091
movb $0x0, %al
callq 0x19070
movq 0x58(%rsp), %rsi
leaq 0x4c3088(%rip), %rdi    # 0x52a0a5
movb $0x0, %al
callq 0x19070
movq 0x50(%rsp), %rsi
leaq 0x4c308b(%rip), %rdi    # 0x52a0bb
movb $0x0, %al
callq 0x19070
movq 0xc8(%rsp), %rax
testb $0x1, 0x2(%rax)
je 0x67109
movq 0xe8(%rsp), %rax
movslq 0xe4(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x11d510
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rdi
leaq 0x4c305e(%rip), %rsi    # 0x52a0d1
callq 0x11d550
movq 0x30(%rsp), %rdi
callq 0x11dee0
movq %rax, %rdi
movq 0xd0(%rsp), %r8
leaq 0x4bfb09(%rip), %rsi    # 0x526b9d
leaq 0x4c2d83(%rip), %rdx    # 0x529e1e
movl $0x183, %ecx            # imm = 0x183
callq 0xd8df0
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x38(%rsp)
jne 0x670bf
movl $0xffffffff, 0x98(%rsp) # imm = 0xFFFFFFFF
jmp 0x670fd
movq 0x88(%rsp), %rdi
movq 0x38(%rsp), %rdx
leaq 0x45d(%rip), %rsi       # 0x67530
callq 0xa55e0
movq 0x30(%rsp), %rdi
callq 0x11dee0
movq %rax, %rsi
leaq 0x4c2fee(%rip), %rdi    # 0x52a0da
movb $0x0, %al
callq 0x19070
movq 0x38(%rsp), %rdi
callq 0xd9390
movq 0x30(%rsp), %rdi
callq 0x11f560
jmp 0x67142
movq 0xc8(%rsp), %rax
movl 0x8(%rax), %esi
leaq 0x4c2ff6(%rip), %rdi    # 0x52a111
movb $0x0, %al
callq 0x19070
movq 0x88(%rsp), %rdi
movq 0xc8(%rsp), %rdx
addq $0x8, %rdx
leaq 0x493(%rip), %rsi       # 0x675d0
callq 0xa55e0
movq 0x88(%rsp), %rdi
callq 0xa5bf0
cmpl $0x0, 0x98(%rsp)
jne 0x673ef
movq 0xc8(%rsp), %rax
testb $0x1, 0x4(%rax)
je 0x673ef
movq 0x5d4dc2(%rip), %rax    # 0x63bf38
movq (%rax), %rdx
movl $0x1, %edi
leaq 0x4b0767(%rip), %rsi    # 0x5178ec
callq 0xe7870
movq %rax, 0x78(%rsp)
movq 0xc8(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x11fcc0
cmpq $0x0, %rax
jne 0x67276
movq 0x80(%rsp), %rdi
movq 0xd0(%rsp), %rdx
movl $0x32, %esi
callq 0x133770
movl %eax, 0x98(%rsp)
cmpl $0x0, 0x98(%rsp)
je 0x6720d
movq 0x5d4dc4(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x4aee2d(%rip), %rsi    # 0x516013
leaq 0x4e5a1a(%rip), %rdx    # 0x54cc07
leaq 0x4c2e44(%rip), %rcx    # 0x52a038
leaq 0x4c2c23(%rip), %r8     # 0x529e1e
movl $0x1a1, %r9d            # imm = 0x1A1
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x6720f
movq 0x80(%rsp), %rdi
movq 0xd0(%rsp), %rdx
movl $0x50, %esi
callq 0x133770
movl %eax, 0x98(%rsp)
cmpl $0x0, 0x98(%rsp)
je 0x67272
movq 0x5d4d5f(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x4aedc8(%rip), %rsi    # 0x516013
leaq 0x4e59b5(%rip), %rdx    # 0x54cc07
leaq 0x4c2ddf(%rip), %rcx    # 0x52a038
leaq 0x4c2bbe(%rip), %r8     # 0x529e1e
movl $0x1a3, %r9d            # imm = 0x1A3
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x67274
jmp 0x67276
movq $0x0, 0x28(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x98(%rsp)
movb %al, 0x1f(%rsp)
jne 0x672bc
movq 0x28(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0xc8(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x11fcc0
movq %rax, %rcx
movq 0x10(%rsp), %rax
cmpq %rcx, %rax
setb %al
movb %al, 0x1f(%rsp)
movb 0x1f(%rsp), %al
testb $0x1, %al
jne 0x672c9
jmp 0x673c9
movq $-0x1, 0x20(%rsp)
movq 0xc8(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x28(%rsp), %rsi
callq 0x11f8c0
movq %rax, %rsi
leaq 0x20(%rsp), %rdi
callq 0xf86d0
cmpl $0x0, %eax
je 0x67343
movq 0xd0(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0xc8(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x28(%rsp), %rsi
callq 0x11f8c0
movq 0x8(%rsp), %rdi
movq %rax, %rdx
leaq 0x4c2e1e(%rip), %rsi    # 0x52a14a
movb $0x0, %al
callq 0xd88c0
movl $0xffffffff, 0x98(%rsp) # imm = 0xFFFFFFFF
jmp 0x673c9
jmp 0x67345
cmpq $-0x1, 0x20(%rsp)
jne 0x67385
movq 0x5d4c4c(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x4aecb5(%rip), %rsi    # 0x516013
leaq 0x4c2e06(%rip), %rdx    # 0x52a16b
leaq 0x4c2ccc(%rip), %rcx    # 0x52a038
leaq 0x4c2aab(%rip), %r8     # 0x529e1e
movl $0x1ad, %r9d            # imm = 0x1AD
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x67387
movq 0x80(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0xd0(%rsp), %rdx
callq 0x133770
movl %eax, 0x98(%rsp)
cmpl $0x0, 0x98(%rsp)
je 0x673b4
jmp 0x673c9
jmp 0x673b6
movq 0x28(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x28(%rsp)
jmp 0x6727f
cmpl $0x0, 0x98(%rsp)
jne 0x673e5
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0x1338d0
movq 0x78(%rsp), %rdi
callq 0xe7ed0
cmpq $0x0, 0x80(%rsp)
je 0x67407
movq 0x80(%rsp), %rdi
callq 0x133170
cmpl $0x0, 0x98(%rsp)
jne 0x67438
movq 0xc8(%rsp), %rax
testb $0x1, 0x3(%rax)
je 0x67438
movq 0x70(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq 0x67680
movq 0x70(%rsp), %rdi
callq 0xa5bf0
movl 0x98(%rsp), %eax
addq $0xf8, %rsp
retq
nopw (%rax,%rax)