// File: /workspace/github_c_makefile_star2_O0/thegenemyers[P]DASCRUBBER/REPcover.c
// Function: main
int main(int argc, char *argv[])
{ int c;

  //  Process arguments

  Prog_Name = Strdup("REPcover","");

  if (argc < 2)
    { fprintf(stderr,"Usage: %s %s\n",Prog_Name,Usage);
      exit (1);
    }

  //  Open trimmed DB and the qual-track

  for (c = 1; c < argc; c++)
    { DAZZ_DB    _DB, *DB  = &_DB;
      DAZZ_EXTRA  ex_hgap, ex_covr;

      //  Load DB

      { int status;

        status = Open_DB(argv[c],DB);
        if (status < 0)
          exit (1);
        if (status == 1)
          { fprintf(stderr,"%s: Cannot be called on a .dam index: %s\n",Prog_Name,argv[1]);
            exit (1);
          }
        Trim_DB(DB);
      }

      //  Get .covr track extras

      { FILE *afile;
        char *aname;
        int   extra;

        afile = NULL;
        if (DB->part)
          { aname = Strdup(Catenate(DB->path,Numbered_Suffix(".",DB->part,"."),"covr",".anno"),
                           "Allocating anno file");
            if (aname == NULL)
              exit (1);
            afile  = fopen(aname,"r");
            if (afile == NULL)
             { fprintf(stderr,"%s: Must have a 'covr.%d' track, run DAScover\n",Prog_Name,DB->part);
               exit (1);
             }
          }
        else
          { aname = Strdup(Catenate(DB->path,".","covr",".anno"),"Allocating anno file");
            if (aname == NULL)
              exit (1);
            afile  = fopen(aname,"r");
            if (afile == NULL)
              { fprintf(stderr,"%s: Must have a 'covr' track, run DAScover\n",Prog_Name);
                exit (1);
              }
          }

        fseeko(afile,0,SEEK_END);
        extra = ftell(afile) - sizeof(int)*2;
        fseeko(afile,-extra,SEEK_END);
        ex_covr.nelem = 0;
        if (Read_Extra(afile,aname,&ex_covr) != 0)
          { fprintf(stderr,"%s: Histogram extra missing from .covr track?\n",Prog_Name);
            exit (1);
          }
        ex_hgap.nelem = 0;
        if (Read_Extra(afile,aname,&ex_hgap) != 0)
          { fprintf(stderr,"%s: Hgap threshold extra missing from .covr track?\n",Prog_Name);
            exit (1);
          }
        fclose(afile);
      }

      //  Generate display

      { char       *root;
        int         i, cmax, hgap_min, cover;
        int64       nreads, totlen;
        int64      *cgram;
        int64       ssum, stotal;

        root   = Root(argv[c],".db");
        nreads = DB->nreads;
        totlen = DB->totlen;

        hgap_min = (int) ((int64 *) (ex_hgap.value))[0];
        cgram    = (int64 *) (ex_covr.value);
        cmax     = ex_covr.nelem - 1;

        printf("\nDAScover");
        if (hgap_min > 0)
          printf(" -H%d",hgap_min);
        printf(" %s\n\n",root);

        if (hgap_min > 0) 
          { for (i = 0; i < DB->nreads; i++)
              if (DB->reads[i].rlen < hgap_min)
                { nreads -= 1;
                  totlen -= DB->reads[i].rlen;
                }
          }

        // Display histogram

        printf("\nInput:  ");
        Print_Number(nreads,7,stdout);
        printf(" reads,  ");
        Print_Number(totlen,12,stdout);
        printf(" bases");
        if (hgap_min > 0)
          { printf(" (another ");
            Print_Number(DB->nreads-nreads,0,stdout);
            printf(" were < H-length)");
          }
        printf("\n");

        stotal = 0;
        for (i = 0; i <= cmax; i++)
          stotal += cgram[i];

        printf("\nCoverage Histogram\n\n");
        ssum = cgram[cmax];
        if (ssum > 0)
          printf("    %4d:  %9lld  %5.1f%%\n\n",
                 cmax,cgram[cmax],(100.*ssum)/stotal);
        stotal -= ssum;
        ssum    = 0;
        for (i = cmax-1; i >= 0; i--)
          if (cgram[i] > 0)
            { ssum += cgram[i];
              printf("    %4d:  %9lld  %5.1f%%\n",
                     i,cgram[i],(100.*ssum)/stotal);
            }

        i = 0;
        while (cgram[i+1] < cgram[i])
          i += 1;
        for (cover = i++; i < cmax; i++)
          if (cgram[cover] < cgram[i])
            cover = i;

        printf("\n  Coverage is estimated at %d\n\n",cover);

        free(root);
        Close_DB(DB);
      }
    }

  free(Prog_Name);
  exit (0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq 0xcc50(%rip), %rdi      # 0xe010
leaq 0xcdea(%rip), %rsi      # 0xe1b1
callq 0x1da0
movq %rax, %rcx
leaq 0x10f62(%rip), %rax     # 0x12338
movq %rcx, (%rax)
cmpl $0x2, -0x8(%rbp)
jge 0x1412
movq 0x10c12(%rip), %rax     # 0x11ff8
movq (%rax), %rdi
leaq 0x10f48(%rip), %rax     # 0x12338
movq (%rax), %rdx
movq 0x10d66(%rip), %rcx     # 0x12160
leaq 0xcc18(%rip), %rsi      # 0xe019
movb $0x0, %al
callq 0x1180
movl $0x1, %edi
callq 0x1260
movl $0x1, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x1bcc
leaq -0x88(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x90(%rbp), %rsi
callq 0x3430
movl %eax, -0xd4(%rbp)
cmpl $0x0, -0xd4(%rbp)
jge 0x1464
movl $0x1, %edi
callq 0x1260
cmpl $0x1, -0xd4(%rbp)
jne 0x14a1
movq 0x10b84(%rip), %rax     # 0x11ff8
movq (%rax), %rdi
leaq 0x10eba(%rip), %rax     # 0x12338
movq (%rax), %rdx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
leaq 0xcb97(%rip), %rsi      # 0xe027
movb $0x0, %al
callq 0x1180
movl $0x1, %edi
callq 0x1260
movq -0x90(%rbp), %rdi
callq 0x4060
movq $0x0, -0xe0(%rbp)
movq -0x90(%rbp), %rax
cmpl $0x0, 0x38(%rax)
je 0x159a
movq -0x90(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x138(%rbp)
movq -0x90(%rbp), %rax
movl 0x38(%rax), %esi
leaq 0xcd0f(%rip), %rdx      # 0xe1fb
movq %rdx, %rdi
callq 0x21e0
movq -0x138(%rbp), %rdi
movq %rax, %rsi
leaq 0xcb4c(%rip), %rdx      # 0xe051
leaq 0xcb4a(%rip), %rcx      # 0xe056
callq 0x2090
movq %rax, %rdi
leaq 0xcb41(%rip), %rsi      # 0xe05c
callq 0x1da0
movq %rax, -0xe8(%rbp)
cmpq $0x0, -0xe8(%rbp)
jne 0x153b
movl $0x1, %edi
callq 0x1260
movq -0xe8(%rbp), %rdi
leaq 0xd7de(%rip), %rsi      # 0xed27
callq 0x1230
movq %rax, -0xe0(%rbp)
cmpq $0x0, -0xe0(%rbp)
jne 0x1595
movq 0x10a92(%rip), %rax     # 0x11ff8
movq (%rax), %rdi
leaq 0x10dc8(%rip), %rax     # 0x12338
movq (%rax), %rdx
movq -0x90(%rbp), %rax
movl 0x38(%rax), %ecx
leaq 0xcaed(%rip), %rsi      # 0xe071
movb $0x0, %al
callq 0x1180
movl $0x1, %edi
callq 0x1260
jmp 0x163b
movq -0x90(%rbp), %rax
movq 0x48(%rax), %rdi
leaq 0xcc4f(%rip), %rsi      # 0xe1fb
leaq 0xca9e(%rip), %rdx      # 0xe051
leaq 0xca9c(%rip), %rcx      # 0xe056
callq 0x2090
movq %rax, %rdi
leaq 0xca93(%rip), %rsi      # 0xe05c
callq 0x1da0
movq %rax, -0xe8(%rbp)
cmpq $0x0, -0xe8(%rbp)
jne 0x15e9
movl $0x1, %edi
callq 0x1260
movq -0xe8(%rbp), %rdi
leaq 0xd730(%rip), %rsi      # 0xed27
callq 0x1230
movq %rax, -0xe0(%rbp)
cmpq $0x0, -0xe0(%rbp)
jne 0x1639
movq 0x109e4(%rip), %rax     # 0x11ff8
movq (%rax), %rdi
leaq 0x10d1a(%rip), %rax     # 0x12338
movq (%rax), %rdx
leaq 0xca78(%rip), %rsi      # 0xe0a0
movb $0x0, %al
callq 0x1180
movl $0x1, %edi
callq 0x1260
jmp 0x163b
movq -0xe0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x2, %edx
callq 0x1220
movq -0xe0(%rbp), %rdi
callq 0x1190
subq $0x8, %rax
movl %eax, -0xec(%rbp)
movq -0xe0(%rbp), %rdi
xorl %eax, %eax
subl -0xec(%rbp), %eax
movslq %eax, %rsi
movl $0x2, %edx
callq 0x1220
movl $0x0, -0xcc(%rbp)
movq -0xe0(%rbp), %rdi
movq -0xe8(%rbp), %rsi
leaq -0xd0(%rbp), %rdx
callq 0x73e0
cmpl $0x0, %eax
je 0x16d7
movq 0x10946(%rip), %rax     # 0x11ff8
movq (%rax), %rdi
leaq 0x10c7c(%rip), %rax     # 0x12338
movq (%rax), %rdx
leaq 0xca06(%rip), %rsi      # 0xe0cc
movb $0x0, %al
callq 0x1180
movl $0x1, %edi
callq 0x1260
movl $0x0, -0xac(%rbp)
movq -0xe0(%rbp), %rdi
movq -0xe8(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
callq 0x73e0
cmpl $0x0, %eax
je 0x172c
movq 0x108f1(%rip), %rax     # 0x11ff8
movq (%rax), %rdi
leaq 0x10c27(%rip), %rax     # 0x12338
movq (%rax), %rdx
leaq 0xc9e0(%rip), %rsi      # 0xe0fb
movb $0x0, %al
callq 0x1180
movl $0x1, %edi
callq 0x1260
movq -0xe0(%rbp), %rdi
callq 0x10b0
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xc9e4(%rip), %rsi      # 0xe12f
callq 0x1f50
movq %rax, -0xf8(%rbp)
movq -0x90(%rbp), %rax
movslq 0x30(%rax), %rax
movq %rax, -0x110(%rbp)
movq -0x90(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x118(%rbp)
movq -0x98(%rbp), %rax
movq (%rax), %rax
movl %eax, -0x104(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0x120(%rbp)
movl -0xcc(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x100(%rbp)
leaq 0xc984(%rip), %rdi      # 0xe133
movb $0x0, %al
callq 0x10f0
cmpl $0x0, -0x104(%rbp)
jle 0x17d3
movl -0x104(%rbp), %esi
leaq 0xc971(%rip), %rdi      # 0xe13d
movb $0x0, %al
callq 0x10f0
movq -0xf8(%rbp), %rsi
leaq 0xc962(%rip), %rdi      # 0xe143
movb $0x0, %al
callq 0x10f0
cmpl $0x0, -0x104(%rbp)
jle 0x188d
movl $0x0, -0xfc(%rbp)
movl -0xfc(%rbp), %eax
movq -0x90(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jge 0x188b
movq -0x90(%rbp), %rax
movq 0x60(%rax), %rax
movslq -0xfc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
cmpl -0x104(%rbp), %eax
jge 0x1875
movq -0x110(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x110(%rbp)
movq -0x90(%rbp), %rax
movq 0x60(%rax), %rax
movslq -0xfc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movslq 0x4(%rax), %rcx
movq -0x118(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x118(%rbp)
jmp 0x1877
movl -0xfc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xfc(%rbp)
jmp 0x17ff
jmp 0x188d
leaq 0xc8b5(%rip), %rdi      # 0xe149
movb $0x0, %al
callq 0x10f0
movq -0x110(%rbp), %rdi
movq 0x1072f(%rip), %rax     # 0x11fd8
movq (%rax), %rdx
movl $0x7, %esi
callq 0x22f0
leaq 0xc896(%rip), %rdi      # 0xe153
movb $0x0, %al
callq 0x10f0
movq -0x118(%rbp), %rdi
movq 0x10706(%rip), %rax     # 0x11fd8
movq (%rax), %rdx
movl $0xc, %esi
callq 0x22f0
leaq 0xc877(%rip), %rdi      # 0xe15d
movb $0x0, %al
callq 0x10f0
cmpl $0x0, -0x104(%rbp)
jle 0x1935
leaq 0xc867(%rip), %rdi      # 0xe164
movb $0x0, %al
callq 0x10f0
movq -0x90(%rbp), %rax
movslq 0x30(%rax), %rdi
subq -0x110(%rbp), %rdi
movq 0x106bb(%rip), %rax     # 0x11fd8
movq (%rax), %rdx
xorl %esi, %esi
callq 0x22f0
leaq 0xc841(%rip), %rdi      # 0xe16f
movb $0x0, %al
callq 0x10f0
leaq 0xc874(%rip), %rdi      # 0xe1b0
movb $0x0, %al
callq 0x10f0
movq $0x0, -0x130(%rbp)
movl $0x0, -0xfc(%rbp)
movl -0xfc(%rbp), %eax
cmpl -0x100(%rbp), %eax
jg 0x1997
movq -0x120(%rbp), %rax
movslq -0xfc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
addq -0x130(%rbp), %rax
movq %rax, -0x130(%rbp)
movl -0xfc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xfc(%rbp)
jmp 0x1958
leaq 0xc7e3(%rip), %rdi      # 0xe181
movb $0x0, %al
callq 0x10f0
movq -0x120(%rbp), %rax
movslq -0x100(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x128(%rbp)
cmpq $0x0, -0x128(%rbp)
jle 0x1a10
movl -0x100(%rbp), %esi
movq -0x120(%rbp), %rax
movslq -0x100(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
cvtsi2sdq -0x128(%rbp), %xmm1
movsd 0xc617(%rip), %xmm0     # 0xe008
mulsd %xmm1, %xmm0
cvtsi2sdq -0x130(%rbp), %xmm1
divsd %xmm1, %xmm0
leaq 0xc78e(%rip), %rdi      # 0xe197
movb $0x1, %al
callq 0x10f0
movq -0x128(%rbp), %rcx
movq -0x130(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x130(%rbp)
movq $0x0, -0x128(%rbp)
movl -0x100(%rbp), %eax
subl $0x1, %eax
movl %eax, -0xfc(%rbp)
cmpl $0x0, -0xfc(%rbp)
jl 0x1ae2
movq -0x120(%rbp), %rax
movslq -0xfc(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jle 0x1acc
movq -0x120(%rbp), %rax
movslq -0xfc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
addq -0x128(%rbp), %rax
movq %rax, -0x128(%rbp)
movl -0xfc(%rbp), %esi
movq -0x120(%rbp), %rax
movslq -0xfc(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
cvtsi2sdq -0x128(%rbp), %xmm1
movsd 0xc55b(%rip), %xmm0     # 0xe008
mulsd %xmm1, %xmm0
cvtsi2sdq -0x130(%rbp), %xmm1
divsd %xmm1, %xmm0
leaq 0xc6ed(%rip), %rdi      # 0xe1b2
movb $0x1, %al
callq 0x10f0
jmp 0x1ace
movl -0xfc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xfc(%rbp)
jmp 0x1a42
movl $0x0, -0xfc(%rbp)
movq -0x120(%rbp), %rax
movl -0xfc(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq -0x120(%rbp), %rcx
movslq -0xfc(%rbp), %rdx
cmpq (%rcx,%rdx,8), %rax
jge 0x1b28
movl -0xfc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xfc(%rbp)
jmp 0x1aec
movl -0xfc(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0xfc(%rbp)
movl %eax, -0x108(%rbp)
movl -0xfc(%rbp), %eax
cmpl -0x100(%rbp), %eax
jge 0x1b92
movq -0x120(%rbp), %rax
movslq -0x108(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x120(%rbp), %rcx
movslq -0xfc(%rbp), %rdx
cmpq (%rcx,%rdx,8), %rax
jge 0x1b7f
movl -0xfc(%rbp), %eax
movl %eax, -0x108(%rbp)
jmp 0x1b81
movl -0xfc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xfc(%rbp)
jmp 0x1b3f
movl -0x108(%rbp), %esi
leaq 0xc62d(%rip), %rdi      # 0xe1cc
movb $0x0, %al
callq 0x10f0
movq -0xf8(%rbp), %rdi
callq 0x1030
movq -0x90(%rbp), %rdi
callq 0x4d80
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1419
leaq 0x10765(%rip), %rax     # 0x12338
movq (%rax), %rdi
callq 0x1030
xorl %edi, %edi
callq 0x1260
nopw %cs:(%rax,%rax)
nopl (%rax)