// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r13
movl %esi, %ebp
movq %rdi, %r15
leaq 0x9e26(%rip), %rdi      # 0x10940
xorl %ebx, %ebx
movl $0x800, %edx            # imm = 0x800
xorl %esi, %esi
callq 0x1130
leaq 0xa611(%rip), %rdi      # 0x11140
movl $0x800, %edx            # imm = 0x800
xorl %esi, %esi
callq 0x1130
leaq 0xadfe(%rip), %rdi      # 0x11940
movl $0x800, %edx            # imm = 0x800
xorl %esi, %esi
callq 0x1130
leaq 0xb5eb(%rip), %r12      # 0x12140
movl $0x800, %edx            # imm = 0x800
movq %r12, %rdi
xorl %esi, %esi
callq 0x1130
leaq 0xbdd5(%rip), %rax      # 0x12940
pushq $0x1
popq %rdx
leaq 0xc5cb(%rip), %rcx      # 0x13140
cmpq $0x800, %rbx            # imm = 0x800
je 0x6b8c
movq %rdx, (%rbx,%rax)
movq %rdx, (%rbx,%rcx)
addq $0x8, %rbx
jmp 0x6b75
andq $0x0, 0xcdac(%rip)      # 0x13940
orl $-0x1, 0xcdad(%rip)     # 0x13948
orl $-0x1, 0xcdaa(%rip)     # 0x1394c
xorl %eax, %eax
testl %ebp, %ebp
cmovlel %eax, %ebp
movl %ebp, (%rsp)
xorl %ebx, %ebx
movq %r15, 0x8(%rsp)
cmpl (%rsp), %ebx
je 0x6dfb
movq %r15, %rdi
pushq $0x1
popq %rsi
callq 0x66fe
cmpl $-0x2, %eax
je 0x6e75
testl %eax, %eax
js 0x6dfe
je 0x6e0f
movq 0x9d4b(%rip), %rdi      # 0x10930
cmpb $0x40, (%rdi)
jne 0x6e0f
incq %rdi
pushq $0x2f
popq %rsi
callq 0x1140
testq %rax, %rax
je 0x6e28
incq %rax
movq %rax, %rdi
leaq 0x366c(%rip), %rsi      # 0xa27b
leaq 0x24(%rsp), %rdx
leaq 0x20(%rsp), %rcx
leaq 0x1c(%rsp), %r8
leaq 0x18(%rsp), %r9
xorl %eax, %eax
callq 0x1200
cmpl $0x4, %eax
jne 0x6e28
testq %r13, %r13
je 0x6c47
movq 0x9cf1(%rip), %rdi      # 0x10930
movq %r13, %rsi
callq 0x1120
movq %r15, %rdi
pushq $0x5
popq %rsi
callq 0x66fe
movl %eax, %ebp
testl %eax, %eax
js 0x6e52
movl %ebx, 0x4(%rsp)
testq %r13, %r13
je 0x6cd7
movq 0x9cc4(%rip), %rdi      # 0x10930
movq %r13, %rsi
callq 0x1120
movslq 0x753d(%rip), %rdi      # 0xe1b8
addq 0x9cae(%rip), %rdi      # 0x10930
movq %r13, %rsi
callq 0x1120
movslq 0x7527(%rip), %rdi      # 0xe1b8
addq %rdi, %rdi
addq 0x9c95(%rip), %rdi      # 0x10930
movq %r13, %rsi
callq 0x1120
movslq 0x750e(%rip), %rax      # 0xe1b8
leaq (%rax,%rax,2), %rdi
addq 0x9c7b(%rip), %rdi      # 0x10930
movq %r13, %rsi
callq 0x1120
movslq 0x74f4(%rip), %rdi      # 0xe1b8
shlq $0x2, %rdi
addq 0x9c61(%rip), %rdi      # 0x10930
movq %r13, %rsi
callq 0x1120
movq 0x9c52(%rip), %r15      # 0x10930
leaq 0x9c5b(%rip), %rdi      # 0x10940
movq %r15, %rsi
movl %ebp, %edx
callq 0x6a83
movslq 0x74c2(%rip), %r14      # 0xe1b8
leaq (%r15,%r14,2), %rsi
leaq 0xac3f(%rip), %rdi      # 0x11940
movl %ebp, %edx
callq 0x6a83
leaq (%r14,%r14,2), %rsi
addq %r15, %rsi
leaq 0xa42a(%rip), %rdi      # 0x11140
movl %ebp, %edx
callq 0x6a83
leaq (%r15,%r14,4), %rsi
movq %r12, %rdi
movq %rsi, 0x10(%rsp)
movl %ebp, %edx
callq 0x6a83
movl 0xcc12(%rip), %ecx      # 0x13948
movl %ebp, %ebx
testl %ecx, %ecx
jns 0x6d67
movq %rbx, %rdx
movq %r15, %rax
subq $0x1, %rdx
jb 0x6d63
movzbl (%rax,%r14), %esi
orl $0x20, %esi
cmpl $0x6e, %esi
je 0x6d5a
incq %rax
jmp 0x6d42
movsbl (%rax), %ecx
movl %ecx, 0xcbe5(%rip)      # 0x13948
testl %ecx, %ecx
js 0x6d78
leaq 0xc3d2(%rip), %rdi      # 0x13140
movq %r15, %rsi
movl %ebp, %edx
callq 0x6a9d
addq 0xcbc1(%rip), %rbx      # 0x13940
movq %rbx, 0xcbba(%rip)      # 0x13940
movl 0xcbc0(%rip), %ecx      # 0x1394c
testl %ecx, %ecx
sets %al
cmpq $0x186a0, %rbx          # imm = 0x186A0
setae %dl
andb %al, %dl
cmpb $0x1, %dl
movq 0x8(%rsp), %r15
pushq $0x1
popq %rax
movl 0x4(%rsp), %ebx
jne 0x6ddd
andl $0x0, 0xcb97(%rip)      # 0x1394c
xorl %ecx, %ecx
xorl %edx, %edx
cmpq $0x100, %rax            # imm = 0x100
je 0x6ddd
movq (%r12,%rax,8), %rsi
movslq %edx, %rdi
cmpq (%r12,%rdi,8), %rsi
jbe 0x6dd8
movl %eax, 0xcb78(%rip)      # 0x1394c
movl %eax, %ecx
movl %eax, %edx
incq %rax
jmp 0x6db9
testl %ecx, %ecx
js 0x6df4
leaq 0xbb58(%rip), %rdi      # 0x12940
movq 0x10(%rsp), %rsi
movl %ebp, %edx
callq 0x6a9d
incl %ebx
jmp 0x6bb3
movl (%rsp), %ebx
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x71e2(%rip), %rax      # 0xdff8
movq (%rax), %rdi
movl 0x9b19(%rip), %edx      # 0x10938
leaq 0x33f9(%rip), %rsi      # 0xa21f
jmp 0x6e6e
movq 0x71c9(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x9aaf(%rip), %rax      # 0x108e8
movq (%rax), %rdx
movl 0x9af6(%rip), %ecx      # 0x10938
leaq 0x3400(%rip), %rsi      # 0xa249
xorl %eax, %eax
callq 0x11a0
jmp 0x6e75
cmpl $-0x1, %ebp
jne 0x6e75
movq 0x719a(%rip), %rax      # 0xdff8
movq (%rax), %rdi
movl 0x9ad1(%rip), %edx      # 0x10938
leaq 0x334e(%rip), %rsi      # 0xa1bc
xorl %eax, %eax
callq 0x11a0
pushq $0x1
popq %rdi
callq 0x1270