// File: /workspace/github_c_makefile_star2_O3/thegenemyers[P]DASCRUBBER/QV.c
// Function: Encode_Run
static void Encode_Run(HScheme *neme, HScheme *reme, FILE *out, uint8 *read, int rlen, int rchar)
{ uint32  x, c, ocode;
  int     n, h, k, olen, llen;
  int    *nlens, *rlens;
  uint32 *nbits, *rbits;
  uint32  nspec, rspec;
  int     nslen, rslen;

  nlens = neme->codelens;
  nbits = neme->codebits;
  rlens = reme->codelens;
  rbits = reme->codebits;

  if (neme->type == 2)
    { nspec = nbits[255];
      nslen = nlens[255];
    }
  else
    nspec = nslen = 0x7fffffff;

  rspec = rbits[255];
  rslen = rlens[255];

  llen  = 0;
  olen  = 0;
  ocode = 0;
  k     = 0;
  while (k < rlen)
    { h = k;
      while (k < rlen && read[k] == rchar)
        k += 1;
      if (k-h >= 255)
        x = 255;
      else
        x = k-h;
      n = rlens[x];
      c = rbits[x];
      OCODE(n,c);
      if (c == rspec && n == rslen)
        OCODE(16,k-h);
      if (k < rlen)
        { x = read[k];
          n = nlens[x];
          c = nbits[x];
          OCODE(n,c);
          if (c == nspec && n == nslen)
            OCODE(8,x);
          k += 1;
        }
    }

  if (olen > 0)
    { fwrite(&ocode,sizeof(uint32),1,out);
      if (llen > 16 && olen > llen)
        fwrite(&ocode,sizeof(uint32),1,out);
    }
  else if (llen > 16)
    fwrite(&ocode,sizeof(uint32),1,out);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r9d, %ebp
movl %r8d, %r12d
movq %rcx, %r8
movq %rdx, 0x20(%rsp)
movq %rsi, 0x48(%rsp)
movl $0x7fffffff, 0x1c(%rsp) # imm = 0x7FFFFFFF
movq %rdi, 0x40(%rsp)
cmpl $0x2, (%rdi)
movl $0x7fffffff, 0x18(%rsp) # imm = 0x7FFFFFFF
jne 0x947a
movq 0x40(%rsp), %rax
movl 0x400(%rax), %ecx
movl %ecx, 0x18(%rsp)
movl 0x800(%rax), %eax
movl %eax, 0x1c(%rsp)
testl %r12d, %r12d
jle 0x9822
movq 0x48(%rsp), %rax
movl 0x400(%rax), %ecx
movl %ecx, 0x38(%rsp)
movl 0x800(%rax), %eax
movl %eax, 0x34(%rsp)
movl %r12d, %esi
xorl %eax, %eax
xorl %ecx, %ecx
xorl %r9d, %r9d
movl %r12d, 0x3c(%rsp)
movq %r8, 0x10(%rsp)
movq %rsi, 0x50(%rsp)
movslq %ecx, %rdx
leal 0x1(%rdx), %edi
cmpl %edi, %r12d
cmovgl %r12d, %edi
movzbl (%r8,%rdx), %ebx
cmpl %ebp, %ebx
jne 0x94d5
incq %rdx
cmpq %rsi, %rdx
jl 0x94c2
jmp 0x94d7
movl %edx, %edi
movl %edi, %r12d
subl %ecx, %r12d
movl $0xff, %ecx
cmpl %ecx, %r12d
movl $0xff, %ecx
cmovll %r12d, %ecx
movq 0x48(%rsp), %rdx
movl 0x404(%rdx,%rcx,4), %r14d
movl 0x4(%rdx,%rcx,4), %r15d
leal (%r14,%r9), %r13d
cmpl $0x20, %r13d
jl 0x957b
movq %r9, 0x28(%rsp)
movl %edi, 0xc(%rsp)
movl %r15d, %edx
movl %r13d, %ecx
shrl %cl, %edx
orl %edx, %eax
movl %eax, 0x8(%rsp)
movl $0x4, %esi
movl $0x1, %edx
leaq 0x8(%rsp), %rdi
movq 0x20(%rsp), %rcx
callq 0x1280
cmpl $0x20, %r13d
jne 0x9589
movl $0x0, 0x8(%rsp)
xorl 0x38(%rsp), %r15d
xorl 0x34(%rsp), %r14d
xorl %eax, %eax
orl %r15d, %r14d
movl $0x0, %r13d
movl $0x0, %esi
movq 0x10(%rsp), %r8
movl 0xc(%rsp), %edi
movq 0x28(%rsp), %r9
je 0x9617
jmp 0x964d
movl %r13d, %ecx
negb %cl
movl %r15d, %edx
shll %cl, %edx
orl %edx, %eax
jmp 0x95a9
leal -0x20(%r13), %edx
negb %r13b
movl %r15d, %eax
movl %r13d, %ecx
shll %cl, %eax
movl %edx, %r13d
movq 0x10(%rsp), %r8
movl 0xc(%rsp), %edi
movq 0x28(%rsp), %r9
movl %eax, 0x8(%rsp)
xorl 0x38(%rsp), %r15d
xorl 0x34(%rsp), %r14d
orl %r15d, %r14d
jne 0x9612
cmpl $0x10, %r13d
jl 0x9617
movl %edi, %r14d
leal -0x10(%r13), %ecx
movl %r12d, %edx
movq %rcx, %r15
shrl %cl, %edx
orl %edx, %eax
movl %eax, 0x8(%rsp)
movl $0x4, %esi
movl $0x1, %edx
leaq 0x8(%rsp), %rdi
movq 0x20(%rsp), %rcx
callq 0x1280
cmpl $0x10, %r13d
jne 0x962f
movl $0x0, 0x8(%rsp)
movl $0x10, %r9d
xorl %eax, %eax
xorl %esi, %esi
movq 0x10(%rsp), %r8
movl %r14d, %edi
jmp 0x964d
movl %r13d, %esi
jmp 0x964d
movb $0x10, %cl
subb %r13b, %cl
shll %cl, %r12d
leal 0x10(%r13), %esi
orl %r12d, %eax
movl %eax, 0x8(%rsp)
movl %r13d, %r9d
jmp 0x964d
movb $0x30, %cl
subb %r13b, %cl
shll %cl, %r12d
movl %r12d, 0x8(%rsp)
movl %r12d, %eax
movl %r13d, %r9d
movq 0x10(%rsp), %r8
movl %r14d, %edi
movq %r15, %rsi
cmpl %ebp, %ebx
jne 0x9661
movl %r9d, %ebx
movl %esi, %r9d
movl 0x3c(%rsp), %r12d
jmp 0x97ce
movslq %edi, %rcx
movzbl (%r8,%rcx), %ebx
movq 0x40(%rsp), %rcx
movl 0x404(%rcx,%rbx,4), %r14d
movl 0x4(%rcx,%rbx,4), %r15d
leal (%r14,%rsi), %r13d
cmpl $0x20, %r13d
movl 0x3c(%rsp), %r12d
jl 0x96fc
movq %rsi, 0x28(%rsp)
movl %edi, 0xc(%rsp)
movl %r15d, %edx
movl %r13d, %ecx
shrl %cl, %edx
orl %edx, %eax
movl %eax, 0x8(%rsp)
movl $0x4, %esi
movl $0x1, %edx
leaq 0x8(%rsp), %rdi
movq 0x20(%rsp), %rcx
callq 0x1280
cmpl $0x20, %r13d
jne 0x970a
movl $0x0, 0x8(%rsp)
xorl 0x18(%rsp), %r15d
xorl 0x1c(%rsp), %r14d
xorl %eax, %eax
orl %r15d, %r14d
movl $0x0, %r13d
movl $0x0, %r9d
movq 0x10(%rsp), %r8
movl 0xc(%rsp), %edi
movq 0x28(%rsp), %rsi
je 0x9797
jmp 0x97ca
movl %r13d, %ecx
negb %cl
movl %r15d, %edx
shll %cl, %edx
orl %edx, %eax
jmp 0x972a
leal -0x20(%r13), %edx
negb %r13b
movl %r15d, %eax
movl %r13d, %ecx
shll %cl, %eax
movl %edx, %r13d
movq 0x10(%rsp), %r8
movl 0xc(%rsp), %edi
movq 0x28(%rsp), %rsi
movl %eax, 0x8(%rsp)
xorl 0x18(%rsp), %r15d
xorl 0x1c(%rsp), %r14d
orl %r15d, %r14d
jne 0x9792
cmpl $0x18, %r13d
jl 0x9797
movl %edi, %r14d
leal -0x18(%r13), %ecx
movl %ebx, %edx
movq %rcx, %r15
shrl %cl, %edx
orl %edx, %eax
movl %eax, 0x8(%rsp)
movl $0x4, %esi
movl $0x1, %edx
leaq 0x8(%rsp), %rdi
movq 0x20(%rsp), %rcx
callq 0x1280
cmpl $0x18, %r13d
jne 0x97af
movl $0x0, 0x8(%rsp)
movl $0x18, %esi
xorl %eax, %eax
xorl %r9d, %r9d
movq 0x10(%rsp), %r8
movl %r14d, %edi
jmp 0x97ca
movl %r13d, %r9d
jmp 0x97ca
leal 0x8(%r13), %r9d
movb $0x18, %cl
subb %r13b, %cl
shll %cl, %ebx
orl %eax, %ebx
movl %ebx, 0x8(%rsp)
movl %ebx, %eax
movl %r13d, %esi
jmp 0x97ca
movb $0x38, %cl
subb %r13b, %cl
shll %cl, %ebx
movl %ebx, 0x8(%rsp)
movl %ebx, %eax
movl %r13d, %esi
movq 0x10(%rsp), %r8
movl %r14d, %edi
movq %r15, %r9
incl %edi
movl %esi, %ebx
movl %edi, %ecx
cmpl %r12d, %edi
movq 0x50(%rsp), %rsi
jl 0x94b5
testl %r9d, %r9d
jle 0x9831
movq %r9, %r14
leaq 0x8(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq 0x20(%rsp), %rcx
callq 0x1280
cmpl $0x11, %ebx
jl 0x9822
cmpl %ebx, %r14d
jle 0x9822
leaq 0x8(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq 0x20(%rsp), %rcx
callq 0x1280
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x11, %ebx
jge 0x9809
jmp 0x9822