// File: /workspace/github_c_makefile_star2_O2/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testl %edi, %edi
je 0x6946
movq %r9, %rbx
movq %r8, %r14
movq %rcx, %r13
movq %rdx, %r12
movq %rsi, %r15
movl %edi, %ebp
leaq 0xa070(%rip), %rdi      # 0x10940
movl %ebp, %edx
callq 0x6a83
leaq 0xb062(%rip), %rdi      # 0x11940
movq %r13, %rsi
movl %ebp, %edx
callq 0x6a83
leaq 0xa851(%rip), %rdi      # 0x11140
movq %r14, %rsi
movl %ebp, %edx
callq 0x6a83
leaq 0xb840(%rip), %r14      # 0x12140
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %edx
callq 0x6a83
movl 0xd035(%rip), %ecx      # 0x13948
testl %ecx, %ecx
jns 0x69e6
xorl %eax, %eax
testl %ebp, %ebp
movl $0x0, %edx
cmovgl %ebp, %edx
cmpq %rax, %rdx
je 0x69e2
movzbl (%r12,%rax), %esi
orl $0x20, %esi
cmpl $0x6e, %esi
je 0x69d7
incq %rax
jmp 0x6927
leaq 0x9ff3(%rip), %rdi      # 0x10940
xorl %ebx, %ebx
movl $0x800, %edx            # imm = 0x800
xorl %esi, %esi
callq 0x1130
leaq 0xa7de(%rip), %rdi      # 0x11140
movl $0x800, %edx            # imm = 0x800
xorl %esi, %esi
callq 0x1130
leaq 0xafcb(%rip), %rdi      # 0x11940
movl $0x800, %edx            # imm = 0x800
xorl %esi, %esi
callq 0x1130
leaq 0xb7b8(%rip), %rdi      # 0x12140
movl $0x800, %edx            # imm = 0x800
xorl %esi, %esi
callq 0x1130
leaq 0xbfa5(%rip), %rax      # 0x12940
pushq $0x1
popq %rcx
leaq 0xc79b(%rip), %rdx      # 0x13140
cmpq $0x800, %rbx            # imm = 0x800
je 0x69bc
movq %rcx, (%rbx,%rax)
movq %rcx, (%rbx,%rdx)
addq $0x8, %rbx
jmp 0x69a5
andq $0x0, 0xcf7c(%rip)      # 0x13940
orl $-0x1, 0xcf7d(%rip)     # 0x13948
orl $-0x1, 0xcf7a(%rip)     # 0x1394c
jmp 0x6a74
movsbl (%r15,%rax), %ecx
movl %ecx, 0xcf66(%rip)      # 0x13948
testl %ecx, %ecx
js 0x69f7
leaq 0xc753(%rip), %rdi      # 0x13140
movq %r15, %rsi
movl %ebp, %edx
callq 0x6a9d
movslq %ebp, %rax
addq 0xcf3f(%rip), %rax      # 0x13940
movq %rax, 0xcf38(%rip)      # 0x13940
movl 0xcf3e(%rip), %ecx      # 0x1394c
testl %ecx, %ecx
sets %dl
cmpq $0x186a0, %rax          # imm = 0x186A0
setae %al
andb %dl, %al
cmpb $0x1, %al
jne 0x6a54
andl $0x0, 0xcf23(%rip)      # 0x1394c
pushq $0x1
popq %rax
xorl %ecx, %ecx
xorl %edx, %edx
cmpq $0x100, %rax            # imm = 0x100
je 0x6a54
movq (%r14,%rax,8), %rsi
movslq %edx, %rdi
cmpq (%r14,%rdi,8), %rsi
jbe 0x6a4f
movl %eax, 0xcf01(%rip)      # 0x1394c
movl %eax, %ecx
movl %eax, %edx
incq %rax
jmp 0x6a30
testl %ecx, %ecx
js 0x6a74
leaq 0xbee1(%rip), %rdi      # 0x12940
movq %rbx, %rsi
movl %ebp, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6a9d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq