// File: /workspace/github_c_makefile_star2_O0/thegenemyers[P]DASCRUBBER/QV.c
// Function: Create_QVcoding
QVcoding *Create_QVcoding(int lossy)
{ static QVcoding coding;

  HScheme *delScheme, *insScheme, *mrgScheme, *subScheme;
  HScheme *dRunScheme, *sRunScheme;

  delScheme  = NULL;
  dRunScheme = NULL;
  insScheme  = NULL;
  mrgScheme  = NULL;
  subScheme  = NULL;
  sRunScheme = NULL;

  //  Check whether using a subtitution run char is a win

  if (totChar < 200000 || subHist[subChar] < .5*totChar)
    subChar = -1;

  //  If lossy encryption is enabled then scale insertions and merge QVs.

  if (lossy)
    { int k;

      for (k = 0; k < 256; k += 2)
        { insHist[k] += insHist[k+1];
          insHist[k+1] = 0;
        }

      for (k = 0; k < 256; k += 4)
        { mrgHist[k] += mrgHist[k+1];
          mrgHist[k] += mrgHist[k+2];
          mrgHist[k] += mrgHist[k+3];
          mrgHist[k+1] = 0;
          mrgHist[k+2] = 0;
          mrgHist[k+3] = 0;
        }
    }

  //  Build a Huffman scheme for each stream entity from the histograms

#define SCHEME_MACRO(meme,hist,label,bits)	\
  scheme = Huffman( (hist), NULL);		\
  if (scheme == NULL)				\
    goto error;					\
  if (scheme->type)				\
    { (meme) = Huffman( (hist), scheme);	\
      free(scheme);				\
    }						\
  else						\
    (meme) = scheme;

#ifdef DEBUG

#define MAKE_SCHEME(meme,hist,label,bits)	\
  SCHEME_MACRO(meme,hist,label,bits)		\
  printf("\n%s\n", (label) );			\
  Print_Histogram( (hist));			\
  Print_Table( (meme), (hist), (bits));	

#else

#define MAKE_SCHEME(meme,hist,label,bits)	\
  SCHEME_MACRO(meme,hist,label,bits)

#endif

  { HScheme *scheme;

    if (delChar < 0)
      { MAKE_SCHEME(delScheme,delHist, "Hisotgram of Deletion QVs", 8);
        dRunScheme = NULL;
      }
    else
      { delHist[delChar] = 0;
        MAKE_SCHEME(delScheme,delHist, "Hisotgram of Deletion QVs less run char", 8);
        MAKE_SCHEME(dRunScheme,delRun, "Histogram of Deletion Runs QVs", 16);
#ifdef DEBUG
        printf("\nRun char is '%c'\n",delChar);
#endif
      }

#ifdef DEBUG
    { int    k;
      uint64 count;

      count = 0;
      for (k = 0; k < 256; k++)
        count += delHist[k];
      printf("\nDelTag will require %lld bytes\n",count/4);
    }
#endif

    MAKE_SCHEME(insScheme,insHist, "Hisotgram of Insertion QVs", 8);
    MAKE_SCHEME(mrgScheme,mrgHist, "Hisotgram of Merge QVs", 8);

    if (subChar < 0)
      { MAKE_SCHEME(subScheme,subHist, "Hisotgram of Subsitution QVs", 8);
        sRunScheme = NULL;
      }
    else
      { subHist[subChar] = 0;
        MAKE_SCHEME(subScheme,subHist, "Hisotgram of Subsitution QVs less run char", 8);
        MAKE_SCHEME(sRunScheme,subRun, "Histogram of Substitution Run QVs", 16);
#ifdef DEBUG
        printf("\nRun char is '%c'\n",subChar);
#endif
      }
  }

  //  Setup endian handling

  Set_Endian(0);

  coding.delScheme  = delScheme;
  coding.insScheme  = insScheme;
  coding.mrgScheme  = mrgScheme;
  coding.subScheme  = subScheme;
  coding.dRunScheme = dRunScheme;
  coding.sRunScheme = sRunScheme;
  coding.delChar    = delChar;
  coding.subChar    = subChar;
  coding.prefix     = NULL;
  coding.flip       = 0;

  return (&coding);

error:
  if (delScheme != NULL)
    free(delScheme);
  if (dRunScheme != NULL)
    free(dRunScheme);
  if (insScheme != NULL)
    free(insScheme);
  if (mrgScheme != NULL)
    free(mrgScheme);
  if (subScheme != NULL)
    free(subScheme);
  if (sRunScheme != NULL)
    free(sRunScheme);
  EXIT(NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x4(%rbp)
movq $0x0, -0x10(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x38(%rbp)
cmpq $0x30d40, 0xd60a(%rip) # imm = 0x30D40
jb 0xa53a
movslq 0xd60d(%rip), %rcx      # 0x17aec
leaq 0xbdfa(%rip), %rax      # 0x162e0
movq (%rax,%rcx,8), %xmm1
movaps 0x4aae(%rip), %xmm3     # 0xefa0
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0x4ab2(%rip), %xmm0     # 0xefb0
subpd %xmm0, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
movq 0xd5cb(%rip), %xmm2     # 0x17ae0
punpckldq %xmm3, %xmm2    # xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1]
subpd %xmm0, %xmm2
movaps %xmm2, %xmm0
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
addsd %xmm0, %xmm2
movsd 0x4a60(%rip), %xmm0     # 0xef90
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0xa544
movl $0xffffffff, 0xd5a8(%rip) # imm = 0xFFFFFFFF
cmpl $0x0, -0x4(%rbp)
je 0xa6a5
movl $0x0, -0x3c(%rbp)
cmpl $0x100, -0x3c(%rbp)     # imm = 0x100
jge 0xa5af
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0xb572(%rip), %rax      # 0x15ae0
movq (%rax,%rcx,8), %rdx
movslq -0x3c(%rbp), %rcx
leaq 0xb563(%rip), %rax      # 0x15ae0
addq (%rax,%rcx,8), %rdx
leaq 0xb558(%rip), %rax      # 0x15ae0
movq %rdx, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0xb544(%rip), %rax      # 0x15ae0
movq $0x0, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x3c(%rbp)
jmp 0xa555
movl $0x0, -0x3c(%rbp)
cmpl $0x100, -0x3c(%rbp)     # imm = 0x100
jge 0xa6a3
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0xad0d(%rip), %rax      # 0x152e0
movq (%rax,%rcx,8), %rdx
movslq -0x3c(%rbp), %rcx
leaq 0xacfe(%rip), %rax      # 0x152e0
addq (%rax,%rcx,8), %rdx
leaq 0xacf3(%rip), %rax      # 0x152e0
movq %rdx, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x2, %eax
movslq %eax, %rcx
leaq 0xacdf(%rip), %rax      # 0x152e0
movq (%rax,%rcx,8), %rdx
movslq -0x3c(%rbp), %rcx
leaq 0xacd0(%rip), %rax      # 0x152e0
addq (%rax,%rcx,8), %rdx
leaq 0xacc5(%rip), %rax      # 0x152e0
movq %rdx, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x3, %eax
movslq %eax, %rcx
leaq 0xacb1(%rip), %rax      # 0x152e0
movq (%rax,%rcx,8), %rdx
movslq -0x3c(%rbp), %rcx
leaq 0xaca2(%rip), %rax      # 0x152e0
addq (%rax,%rcx,8), %rdx
leaq 0xac97(%rip), %rax      # 0x152e0
movq %rdx, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0xac83(%rip), %rax      # 0x152e0
movq $0x0, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x2, %eax
movslq %eax, %rcx
leaq 0xac6b(%rip), %rax      # 0x152e0
movq $0x0, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x3, %eax
movslq %eax, %rcx
leaq 0xac53(%rip), %rax      # 0x152e0
movq $0x0, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x3c(%rbp)
jmp 0xa5b6
jmp 0xa6a5
cmpl $0x0, 0xd43c(%rip)      # 0x17ae8
jge 0xa70b
leaq 0xa42b(%rip), %rdi      # 0x14ae0
xorl %eax, %eax
movl %eax, %esi
callq 0xaa70
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0xa6ce
jmp 0xaa04
movq -0x48(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa6f6
movq -0x48(%rbp), %rsi
leaq 0xa3fe(%rip), %rdi      # 0x14ae0
callq 0xaa70
movq %rax, -0x10(%rbp)
movq -0x48(%rbp), %rdi
callq 0x1030
jmp 0xa6fe
movq -0x48(%rbp), %rax
movq %rax, -0x10(%rbp)
movq $0x0, -0x30(%rbp)
jmp 0xa7c3
movslq 0xd3d6(%rip), %rcx      # 0x17ae8
leaq 0xa3c7(%rip), %rax      # 0x14ae0
movq $0x0, (%rax,%rcx,8)
leaq 0xa3b8(%rip), %rdi      # 0x14ae0
xorl %eax, %eax
movl %eax, %esi
callq 0xaa70
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0xa741
jmp 0xaa04
movq -0x48(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa769
movq -0x48(%rbp), %rsi
leaq 0xa38b(%rip), %rdi      # 0x14ae0
callq 0xaa70
movq %rax, -0x10(%rbp)
movq -0x48(%rbp), %rdi
callq 0x1030
jmp 0xa771
movq -0x48(%rbp), %rax
movq %rax, -0x10(%rbp)
leaq 0xcb68(%rip), %rdi      # 0x172e0
xorl %eax, %eax
movl %eax, %esi
callq 0xaa70
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0xa791
jmp 0xaa04
movq -0x48(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa7b9
movq -0x48(%rbp), %rsi
leaq 0xcb3b(%rip), %rdi      # 0x172e0
callq 0xaa70
movq %rax, -0x30(%rbp)
movq -0x48(%rbp), %rdi
callq 0x1030
jmp 0xa7c1
movq -0x48(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0xa7c3
leaq 0xb316(%rip), %rdi      # 0x15ae0
xorl %eax, %eax
movl %eax, %esi
callq 0xaa70
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0xa7e3
jmp 0xaa04
movq -0x48(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa80b
movq -0x48(%rbp), %rsi
leaq 0xb2e9(%rip), %rdi      # 0x15ae0
callq 0xaa70
movq %rax, -0x18(%rbp)
movq -0x48(%rbp), %rdi
callq 0x1030
jmp 0xa813
movq -0x48(%rbp), %rax
movq %rax, -0x18(%rbp)
leaq 0xaac6(%rip), %rdi      # 0x152e0
xorl %eax, %eax
movl %eax, %esi
callq 0xaa70
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0xa833
jmp 0xaa04
movq -0x48(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa85b
movq -0x48(%rbp), %rsi
leaq 0xaa99(%rip), %rdi      # 0x152e0
callq 0xaa70
movq %rax, -0x20(%rbp)
movq -0x48(%rbp), %rdi
callq 0x1030
jmp 0xa863
movq -0x48(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpl $0x0, 0xd282(%rip)      # 0x17aec
jge 0xa8c9
leaq 0xba6d(%rip), %rdi      # 0x162e0
xorl %eax, %eax
movl %eax, %esi
callq 0xaa70
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0xa88c
jmp 0xaa04
movq -0x48(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa8b4
movq -0x48(%rbp), %rsi
leaq 0xba40(%rip), %rdi      # 0x162e0
callq 0xaa70
movq %rax, -0x28(%rbp)
movq -0x48(%rbp), %rdi
callq 0x1030
jmp 0xa8bc
movq -0x48(%rbp), %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x38(%rbp)
jmp 0xa981
movslq 0xd21c(%rip), %rcx      # 0x17aec
leaq 0xba09(%rip), %rax      # 0x162e0
movq $0x0, (%rax,%rcx,8)
leaq 0xb9fa(%rip), %rdi      # 0x162e0
xorl %eax, %eax
movl %eax, %esi
callq 0xaa70
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0xa8ff
jmp 0xaa04
movq -0x48(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa927
movq -0x48(%rbp), %rsi
leaq 0xb9cd(%rip), %rdi      # 0x162e0
callq 0xaa70
movq %rax, -0x28(%rbp)
movq -0x48(%rbp), %rdi
callq 0x1030
jmp 0xa92f
movq -0x48(%rbp), %rax
movq %rax, -0x28(%rbp)
leaq 0xc1aa(%rip), %rdi      # 0x16ae0
xorl %eax, %eax
movl %eax, %esi
callq 0xaa70
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0xa94f
jmp 0xaa04
movq -0x48(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa977
movq -0x48(%rbp), %rsi
leaq 0xc17d(%rip), %rdi      # 0x16ae0
callq 0xaa70
movq %rax, -0x38(%rbp)
movq -0x48(%rbp), %rdi
callq 0x1030
jmp 0xa97f
movq -0x48(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0xa981
xorl %edi, %edi
callq 0xaf70
movq -0x10(%rbp), %rax
movq %rax, 0xd15d(%rip)      # 0x17af0
movq -0x18(%rbp), %rax
movq %rax, 0xd15a(%rip)      # 0x17af8
movq -0x20(%rbp), %rax
movq %rax, 0xd157(%rip)      # 0x17b00
movq -0x28(%rbp), %rax
movq %rax, 0xd154(%rip)      # 0x17b08
movq -0x30(%rbp), %rax
movq %rax, 0xd151(%rip)      # 0x17b10
movq -0x38(%rbp), %rax
movq %rax, 0xd14e(%rip)      # 0x17b18
movl 0xd118(%rip), %eax      # 0x17ae8
movl %eax, 0xd14a(%rip)      # 0x17b20
movl 0xd110(%rip), %eax      # 0x17aec
movl %eax, 0xd142(%rip)      # 0x17b24
movq $0x0, 0xd143(%rip) # 0x17b30
movl $0x0, 0xd131(%rip)      # 0x17b28
leaq 0xd0f2(%rip), %rax      # 0x17af0
addq $0x50, %rsp
popq %rbp
retq
cmpq $0x0, -0x10(%rbp)
je 0xaa14
movq -0x10(%rbp), %rdi
callq 0x1030
cmpq $0x0, -0x30(%rbp)
je 0xaa24
movq -0x30(%rbp), %rdi
callq 0x1030
cmpq $0x0, -0x18(%rbp)
je 0xaa34
movq -0x18(%rbp), %rdi
callq 0x1030
cmpq $0x0, -0x20(%rbp)
je 0xaa44
movq -0x20(%rbp), %rdi
callq 0x1030
cmpq $0x0, -0x28(%rbp)
je 0xaa54
movq -0x28(%rbp), %rdi
callq 0x1030
cmpq $0x0, -0x38(%rbp)
je 0xaa64
movq -0x38(%rbp), %rdi
callq 0x1030
movl $0x1, %edi
callq 0x1260
nop