// File: /workspace/github_c_makefile_star2_O0/thegenemyers[P]DASCRUBBER/QV.c
// Function: QVcoding_Scan
int QVcoding_Scan(FILE *input, int num, FILE *temp)
{ char *slash;
  int   rlen;
  int   i, r;

  //  Zero histograms

  bzero(delHist,sizeof(uint64)*256);
  bzero(mrgHist,sizeof(uint64)*256);
  bzero(insHist,sizeof(uint64)*256);
  bzero(subHist,sizeof(uint64)*256);

  for (i = 0; i < 256; i++)
    delRun[i] = subRun[i] = 1;

  totChar    = 0;
  delChar    = -1;
  subChar    = -1;

  //  Make a sweep through the .quiva entries, histogramming the relevant things
  //    and figuring out the run chars for the deletion and substition streams

  r = 0;
  for (i = 0; i < num; i++)
    { int well, beg, end, qv;

      rlen = Read_Lines(input,1);
      if (rlen == -2)
        EXIT(-1);
      if (rlen < 0)
        break;

      if (rlen == 0 || Read[0] != '@')
        { EPRINTF(EPLACE,"Line %d: Header in quiva file is missing\n",Nline);
          EXIT(-1);
        }
      slash = index(Read+1,'/');
      if (slash == NULL)
  	{ EPRINTF(EPLACE,"%s: Line %d: Header line incorrectly formatted ?\n",
                         Prog_Name,Nline);
          EXIT(-1);
        }
      if (sscanf(slash+1,"%d/%d_%d RQ=0.%d\n",&well,&beg,&end,&qv) != 4)
        { EPRINTF(EPLACE,"%s: Line %d: Header line incorrectly formatted ?\n",
                         Prog_Name,Nline);
          EXIT(-1);
        }

      if (temp != NULL)
        fputs(Read,temp);

      rlen = Read_Lines(input,5);
      if (rlen < 0)
        { if (rlen == -1)
            EPRINTF(EPLACE,"Line %d: incomplete last entry of .quiv file\n",Nline);
          EXIT(-1);
        }

      if (temp != NULL)
        { fputs(Read,temp);
          fputs(Read+Rmax,temp);
          fputs(Read+2*Rmax,temp);
          fputs(Read+3*Rmax,temp);
          fputs(Read+4*Rmax,temp);
        }

      Histogram_Seqs(delHist,(uint8 *) (Read),rlen);
      Histogram_Seqs(insHist,(uint8 *) (Read+2*Rmax),rlen);
      Histogram_Seqs(mrgHist,(uint8 *) (Read+3*Rmax),rlen);
      Histogram_Seqs(subHist,(uint8 *) (Read+4*Rmax),rlen);

      if (delChar < 0)
        { int   k;
          char *del = Read+Rmax;

          for (k = 0; k < rlen; k++)
            if (del[k] == 'n' || del[k] == 'N')
              { delChar = Read[k];
                break;
              }
        }
      if (delChar >= 0)
        Histogram_Runs( delRun,(uint8 *) (Read),rlen,delChar);
      totChar += rlen;
      if (subChar < 0)
        { if (totChar >= 100000)
            { int k;

              subChar = 0;
              for (k = 1; k < 256; k++)
                if (subHist[k] > subHist[subChar])
                  subChar = k;
            }
        }
      if (subChar >= 0)
        Histogram_Runs( subRun,(uint8 *) (Read+4*Rmax),rlen,subChar);

      r += 1;
    }

  return (r);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
leaq 0xab06(%rip), %rdi      # 0x14ae0
xorl %esi, %esi
movl $0x800, %edx            # imm = 0x800
callq 0x1120
leaq 0xb2f3(%rip), %rdi      # 0x152e0
xorl %esi, %esi
movl $0x800, %edx            # imm = 0x800
callq 0x1120
leaq 0xbae0(%rip), %rdi      # 0x15ae0
xorl %esi, %esi
movl $0x800, %edx            # imm = 0x800
callq 0x1120
leaq 0xc2cd(%rip), %rdi      # 0x162e0
xorl %esi, %esi
movl $0x800, %edx            # imm = 0x800
callq 0x1120
movl $0x0, -0x28(%rbp)
cmpl $0x100, -0x28(%rbp)     # imm = 0x100
jge 0xa060
movslq -0x28(%rbp), %rcx
leaq 0xcaa6(%rip), %rax      # 0x16ae0
movq $0x1, (%rax,%rcx,8)
movslq -0x28(%rbp), %rcx
leaq 0xd293(%rip), %rax      # 0x172e0
movq $0x1, (%rax,%rcx,8)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xa026
movq $0x0, 0xda75(%rip) # 0x17ae0
movl $0xffffffff, 0xda73(%rip) # imm = 0xFFFFFFFF
movl $0xffffffff, 0xda6d(%rip) # imm = 0xFFFFFFFF
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0xa47b
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x99f0
movl %eax, -0x24(%rbp)
cmpl $-0x2, -0x24(%rbp)
jne 0xa0ba
movl $0x1, %edi
callq 0x1260
cmpl $0x0, -0x24(%rbp)
jge 0xa0c5
jmp 0xa47b
cmpl $0x0, -0x24(%rbp)
je 0xa0da
movq 0xa9fe(%rip), %rax      # 0x14ad0
movsbl (%rax), %eax
cmpl $0x40, %eax
je 0xa102
movq 0x7f17(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movl 0xa9ee(%rip), %edx      # 0x14ad8
leaq 0x4fa6(%rip), %rsi      # 0xf097
movb $0x0, %al
callq 0x1180
movl $0x1, %edi
callq 0x1260
movq 0xa9c7(%rip), %rdi      # 0x14ad0
addq $0x1, %rdi
movl $0x2f, %esi
callq 0x1130
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0xa154
movq 0x7ecf(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
leaq 0xa955(%rip), %rax      # 0x14a88
movq (%rax), %rdx
movl 0xa99c(%rip), %ecx      # 0x14ad8
leaq 0x4f7e(%rip), %rsi      # 0xf0c1
movb $0x0, %al
callq 0x1180
movl $0x1, %edi
callq 0x1260
movq -0x20(%rbp), %rdi
addq $0x1, %rdi
leaq 0x4f90(%rip), %rsi      # 0xf0f3
leaq -0x30(%rbp), %rdx
leaq -0x34(%rbp), %rcx
leaq -0x38(%rbp), %r8
leaq -0x3c(%rbp), %r9
movb $0x0, %al
callq 0x11f0
cmpl $0x4, %eax
je 0xa1b1
movq 0x7e72(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
leaq 0xa8f8(%rip), %rax      # 0x14a88
movq (%rax), %rdx
movl 0xa93f(%rip), %ecx      # 0x14ad8
leaq 0x4f21(%rip), %rsi      # 0xf0c1
movb $0x0, %al
callq 0x1180
movl $0x1, %edi
callq 0x1260
cmpq $0x0, -0x18(%rbp)
je 0xa1c8
movq 0xa911(%rip), %rdi      # 0x14ad0
movq -0x18(%rbp), %rsi
callq 0x1110
movq -0x8(%rbp), %rdi
movl $0x5, %esi
callq 0x99f0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jge 0xa20d
cmpl $-0x1, -0x24(%rbp)
jne 0xa203
movq 0x7e0c(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movl 0xa8e3(%rip), %edx      # 0x14ad8
leaq 0x4e38(%rip), %rsi      # 0xf034
movb $0x0, %al
callq 0x1180
movl $0x1, %edi
callq 0x1260
cmpq $0x0, -0x18(%rbp)
je 0xa299
movq 0xa8b1(%rip), %rdi      # 0x14ad0
movq -0x18(%rbp), %rsi
callq 0x1110
movq 0xa8a1(%rip), %rdi      # 0x14ad0
movslq 0x8122(%rip), %rax      # 0x12358
addq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x1110
movq 0xa887(%rip), %rdi      # 0x14ad0
movl 0x8109(%rip), %eax      # 0x12358
shll %eax
cltq
addq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x1110
movq 0xa86a(%rip), %rdi      # 0x14ad0
imull $0x3, 0x80eb(%rip), %eax # 0x12358
cltq
addq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x1110
movq 0xa84e(%rip), %rdi      # 0x14ad0
movl 0x80d0(%rip), %eax      # 0x12358
shll $0x2, %eax
cltq
addq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x1110
movq 0xa830(%rip), %rsi      # 0x14ad0
movl -0x24(%rbp), %edx
leaq 0xa836(%rip), %rdi      # 0x14ae0
callq 0x9eb0
movq 0xa81a(%rip), %rsi      # 0x14ad0
movl 0x809c(%rip), %eax      # 0x12358
shll %eax
cltq
addq %rax, %rsi
movl -0x24(%rbp), %edx
leaq 0xb813(%rip), %rdi      # 0x15ae0
callq 0x9eb0
movq 0xa7f7(%rip), %rsi      # 0x14ad0
imull $0x3, 0x8078(%rip), %eax # 0x12358
cltq
addq %rax, %rsi
movl -0x24(%rbp), %edx
leaq 0xaff1(%rip), %rdi      # 0x152e0
callq 0x9eb0
movq 0xa7d5(%rip), %rsi      # 0x14ad0
movl 0x8057(%rip), %eax      # 0x12358
shll $0x2, %eax
cltq
addq %rax, %rsi
movl -0x24(%rbp), %edx
leaq 0xbfcd(%rip), %rdi      # 0x162e0
callq 0x9eb0
cmpl $0x0, 0xd7c9(%rip)      # 0x17ae8
jge 0xa38d
movq 0xa7a8(%rip), %rax      # 0x14ad0
movslq 0x8029(%rip), %rcx      # 0x12358
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0xa38b
movq -0x48(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x6e, %eax
je 0xa367
movq -0x48(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x4e, %eax
jne 0xa37e
movq 0xa762(%rip), %rax      # 0x14ad0
movslq -0x40(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, 0xd76c(%rip)      # 0x17ae8
jmp 0xa38b
jmp 0xa380
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0xa33d
jmp 0xa38d
cmpl $0x0, 0xd754(%rip)      # 0x17ae8
jl 0xa3b2
movq 0xa733(%rip), %rsi      # 0x14ad0
movl -0x24(%rbp), %edx
movl 0xd742(%rip), %ecx      # 0x17ae8
leaq 0xcf33(%rip), %rdi      # 0x172e0
callq 0x9f00
movslq -0x24(%rbp), %rax
addq 0xd723(%rip), %rax      # 0x17ae0
movq %rax, 0xd71c(%rip)      # 0x17ae0
cmpl $0x0, 0xd721(%rip)      # 0x17aec
jge 0xa431
cmpq $0x186a0, 0xd708(%rip) # imm = 0x186A0
jb 0xa42f
movl $0x0, 0xd708(%rip)      # 0x17aec
movl $0x1, -0x4c(%rbp)
cmpl $0x100, -0x4c(%rbp)     # imm = 0x100
jge 0xa42d
movslq -0x4c(%rbp), %rcx
leaq 0xbee1(%rip), %rax      # 0x162e0
movq (%rax,%rcx,8), %rax
movslq 0xd6e2(%rip), %rdx      # 0x17aec
leaq 0xbecf(%rip), %rcx      # 0x162e0
cmpq (%rcx,%rdx,8), %rax
jbe 0xa420
movl -0x4c(%rbp), %eax
movl %eax, 0xd6cc(%rip)      # 0x17aec
jmp 0xa422
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0xa3eb
jmp 0xa42f
jmp 0xa431
cmpl $0x0, 0xd6b4(%rip)      # 0x17aec
jl 0xa464
movq 0xa68f(%rip), %rsi      # 0x14ad0
movl 0x7f11(%rip), %eax      # 0x12358
shll $0x2, %eax
cltq
addq %rax, %rsi
movl -0x24(%rbp), %edx
movl 0xd694(%rip), %ecx      # 0x17aec
leaq 0xc681(%rip), %rdi      # 0x16ae0
callq 0x9f00
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xa08d
movl -0x2c(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)