// File: /workspace/github_c_makefile_star2_O3/thegenemyers[P]DASCRUBBER/QV.c
// Function: QVcoding_Scan1
void QVcoding_Scan1(int rlen, char *delQV, char *delTag, char *insQV, char *mergeQV, char *subQV)
{
  if (rlen == 0)   //  Initialization call
    { int   i;

      //  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;
      return;
    }

  //  Add streams to accumulating histograms and figure out the run chars
  //    for the deletion and substition streams

  Histogram_Seqs(delHist,(uint8 *) delQV,rlen);
  Histogram_Seqs(insHist,(uint8 *) insQV,rlen);
  Histogram_Seqs(mrgHist,(uint8 *) mergeQV,rlen);
  Histogram_Seqs(subHist,(uint8 *) subQV,rlen);

  if (delChar < 0)
    { int   k;

      for (k = 0; k < rlen; k++)
        if (delTag[k] == 'n' || delTag[k] == 'N')
          { delChar = delQV[k];
            break;
          }
    }
  if (delChar >= 0)
    Histogram_Runs( delRun,(uint8 *) delQV,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 *) subQV,rlen,subChar);
  return;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
testl %edi, %edi
je 0x7ee2
movq %r9, %rbx
movl %edi, %ebp
jle 0x7f7b
movl %ebp, %eax
xorl %edi, %edi
leaq 0xaaf5(%rip), %r9       # 0x12940
movzbl (%rsi,%rdi), %r10d
incq (%r9,%r10,8)
incq %rdi
cmpq %rdi, %rax
jne 0x7e4b
xorl %edi, %edi
leaq 0xbadb(%rip), %r9       # 0x13940
movzbl (%rcx,%rdi), %r10d
incq (%r9,%r10,8)
incq %rdi
cmpq %rdi, %rax
jne 0x7e65
xorl %ecx, %ecx
leaq 0xb2c1(%rip), %rdi      # 0x13140
movzbl (%r8,%rcx), %r9d
incq (%rdi,%r9,8)
incq %rcx
cmpq %rcx, %rax
jne 0x7e7f
xorl %ecx, %ecx
leaq 0xc2a7(%rip), %rdi      # 0x14140
movzbl (%rbx,%rcx), %r8d
incq (%rdi,%r8,8)
incq %rcx
cmpq %rcx, %rax
jne 0x7e99
movl 0xda98(%rip), %ecx      # 0x15948
testl %ecx, %ecx
jns 0x7f91
testl %ebp, %ebp
jle 0x7f9f
xorl %edi, %edi
movzbl (%rdx,%rdi), %r8d
orl $0x20, %r8d
cmpl $0x6e, %r8d
je 0x7f83
incq %rdi
cmpq %rdi, %rax
jne 0x7ec2
jmp 0x7f8d
leaq 0xaa57(%rip), %rdi      # 0x12940
xorl %ebx, %ebx
movl $0x800, %edx            # imm = 0x800
xorl %esi, %esi
callq 0x1130
leaq 0xb242(%rip), %rdi      # 0x13140
movl $0x800, %edx            # imm = 0x800
xorl %esi, %esi
callq 0x1130
leaq 0xba2f(%rip), %rdi      # 0x13940
movl $0x800, %edx            # imm = 0x800
xorl %esi, %esi
callq 0x1130
leaq 0xc21c(%rip), %rdi      # 0x14140
movl $0x800, %edx            # imm = 0x800
xorl %esi, %esi
callq 0x1130
leaq 0xca09(%rip), %rax      # 0x14940
movaps 0x4242(%rip), %xmm0     # 0xc180
leaq 0xd1fb(%rip), %rcx      # 0x15140
movaps %xmm0, (%rbx,%rax)
movaps %xmm0, (%rbx,%rcx)
addq $0x10, %rbx
cmpq $0x800, %rbx            # imm = 0x800
jne 0x7f45
movq $0x0, 0xd9db(%rip) # 0x15940
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0xd9d8(%rip)      # 0x15948
movl %eax, 0xd9d6(%rip)      # 0x1594c
jmp 0x801a
movl 0xd9c7(%rip), %ecx      # 0x15948
jmp 0x7f8d
movsbl (%rsi,%rdi), %ecx
movl %ecx, 0xd9bb(%rip)      # 0x15948
testl %ecx, %ecx
js 0x7f9f
leaq 0xd1a8(%rip), %rdi      # 0x15140
movl %ebp, %edx
callq 0x8021
movslq %ebp, %rax
addq 0xd997(%rip), %rax      # 0x15940
movq %rax, 0xd990(%rip)      # 0x15940
movl 0xd996(%rip), %ecx      # 0x1594c
testl %ecx, %ecx
sets %dl
cmpq $0x186a0, %rax          # imm = 0x186A0
setae %al
andb %dl, %al
cmpb $0x1, %al
jne 0x8002
movl $0x0, 0xd978(%rip)      # 0x1594c
xorl %ecx, %ecx
movl $0x1, %eax
leaq 0xc15e(%rip), %rdx      # 0x14140
movq (%rdx,%rax,8), %rsi
movslq %ecx, %rdi
cmpq (%rdx,%rdi,8), %rsi
jbe 0x7ff7
movl %eax, 0xd957(%rip)      # 0x1594c
movl %eax, %ecx
incq %rax
cmpq $0x100, %rax            # imm = 0x100
jne 0x7fe2
testl %ecx, %ecx
js 0x801a
leaq 0xc933(%rip), %rdi      # 0x14940
movq %rbx, %rsi
movl %ebp, %edx
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x8021
addq $0x8, %rsp
popq %rbx
popq %rbp
retq