// File: /workspace/github_c_makefile_star2_O1/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 0x7af5
movq %r9, %rbx
movl %edi, %ebp
movl %edi, %eax
jle 0x7abd
xorl %edi, %edi
leaq 0xaeee(%rip), %r9       # 0x12940
movzbl (%rsi,%rdi), %r10d
incq (%r9,%r10,8)
incq %rdi
cmpq %rdi, %rax
jne 0x7a52
testl %ebp, %ebp
jle 0x7abd
xorl %edi, %edi
leaq 0xbed0(%rip), %r9       # 0x13940
movzbl (%rcx,%rdi), %r10d
incq (%r9,%r10,8)
incq %rdi
cmpq %rdi, %rax
jne 0x7a70
testl %ebp, %ebp
jle 0x7abd
xorl %ecx, %ecx
leaq 0xb6b2(%rip), %rdi      # 0x13140
movzbl (%r8,%rcx), %r9d
incq (%rdi,%r9,8)
incq %rcx
cmpq %rcx, %rax
jne 0x7a8e
testl %ebp, %ebp
jle 0x7abd
xorl %ecx, %ecx
leaq 0xc694(%rip), %rdi      # 0x14140
movzbl (%rbx,%rcx), %r8d
incq (%rdi,%r8,8)
incq %rcx
cmpq %rcx, %rax
jne 0x7aac
cmpl $0x0, 0xde84(%rip)      # 0x15948
setns %cl
testl %ebp, %ebp
setle %dil
orb %cl, %dil
jne 0x7b96
xorl %ecx, %ecx
movzbl (%rdx,%rcx), %edi
orl $0x20, %edi
cmpl $0x6e, %edi
je 0x7b8c
incq %rcx
cmpq %rcx, %rax
jne 0x7ad8
jmp 0x7b96
leaq 0xae44(%rip), %rdi      # 0x12940
xorl %ebx, %ebx
movl $0x800, %edx            # imm = 0x800
xorl %esi, %esi
callq 0x1130
leaq 0xb62f(%rip), %rdi      # 0x13140
movl $0x800, %edx            # imm = 0x800
xorl %esi, %esi
callq 0x1130
leaq 0xbe1c(%rip), %rdi      # 0x13940
movl $0x800, %edx            # imm = 0x800
xorl %esi, %esi
callq 0x1130
leaq 0xc609(%rip), %rdi      # 0x14140
movl $0x800, %edx            # imm = 0x800
xorl %esi, %esi
callq 0x1130
leaq 0xcdf6(%rip), %rax      # 0x14940
movl $0x1, %ecx
leaq 0xd5ea(%rip), %rdx      # 0x15140
movq %rcx, (%rbx,%rax)
movq %rcx, (%rbx,%rdx)
addq $0x8, %rbx
cmpq $0x800, %rbx            # imm = 0x800
jne 0x7b56
movq $0x0, 0xddca(%rip) # 0x15940
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0xddc7(%rip)      # 0x15948
movl %eax, 0xddc5(%rip)      # 0x1594c
jmp 0x7c2e
movsbl (%rsi,%rcx), %eax
movl %eax, 0xddb2(%rip)      # 0x15948
movl 0xddac(%rip), %ecx      # 0x15948
testl %ecx, %ecx
js 0x7bae
leaq 0xd599(%rip), %rdi      # 0x15140
movl %ebp, %edx
callq 0x7c35
movslq %ebp, %rax
addq 0xdd88(%rip), %rax      # 0x15940
movq %rax, 0xdd81(%rip)      # 0x15940
cmpl $0x0, 0xdd86(%rip)      # 0x1594c
sets %cl
cmpq $0x186a0, %rax          # imm = 0x186A0
setae %al
andb %cl, %al
cmpb $0x1, %al
jne 0x7c10
movl $0x0, 0xdd6a(%rip)      # 0x1594c
xorl %edx, %edx
movl $0x1, %eax
leaq 0xc550(%rip), %rcx      # 0x14140
movq (%rcx,%rax,8), %rsi
movslq %edx, %rdi
cmpq (%rcx,%rdi,8), %rsi
jbe 0x7c05
movl %eax, 0xdd49(%rip)      # 0x1594c
movl %eax, %edx
incq %rax
cmpq $0x100, %rax            # imm = 0x100
jne 0x7bf0
movl 0xdd36(%rip), %ecx      # 0x1594c
testl %ecx, %ecx
js 0x7c2e
leaq 0xcd1f(%rip), %rdi      # 0x14940
movq %rbx, %rsi
movl %ebp, %edx
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x7c35
addq $0x8, %rsp
popq %rbx
popq %rbp
retq