// File: /workspace/github_c_makefile_star2_O2/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, 0x1c(%rsp)
movq %rcx, %r15
movq %rdx, 0x20(%rsp)
movq %rsi, 0x50(%rsp)
movl $0x7fffffff, 0x34(%rsp) # imm = 0x7FFFFFFF
movq %rdi, 0x48(%rsp)
cmpl $0x2, (%rdi)
movl $0x7fffffff, 0x38(%rsp) # imm = 0x7FFFFFFF
jne 0x7eee
movq 0x48(%rsp), %rax
movl 0x400(%rax), %ecx
movl %ecx, 0x38(%rsp)
movl 0x800(%rax), %eax
movl %eax, 0x34(%rsp)
movq 0x50(%rsp), %rax
movl 0x400(%rax), %ecx
movl %ecx, 0x44(%rsp)
movl 0x800(%rax), %eax
movl %eax, 0x40(%rsp)
leaq 0x4(%rsp), %rax
andl $0x0, (%rax)
movslq 0x1c(%rsp), %r12
xorl %eax, %eax
xorl %r14d, %r14d
xorl %esi, %esi
xorl %r13d, %r13d
cmpl 0x1c(%rsp), %r13d
jge 0x81c8
movl %r13d, %ecx
movslq %r13d, %r13
cmpq %r13, %r12
je 0x7f42
movzbl (%r15,%r13), %edx
cmpl %ebp, %edx
jne 0x7f4d
incq %r13
jmp 0x7f2f
xorl %edi, %edi
movl 0x1c(%rsp), %edx
movl %edx, %r13d
jmp 0x7f54
cmpq %r12, %r13
setl %dil
movl %r13d, %r14d
subl %ecx, %r14d
movl $0xff, %ecx
cmpl %ecx, %r14d
movl $0xff, %ecx
cmovll %r14d, %ecx
movq 0x50(%rsp), %rdx
movl 0x404(%rdx,%rcx,4), %r8d
movl 0x4(%rdx,%rcx,4), %r9d
leal (%r8,%rsi), %ebx
cmpl $0x20, %ebx
jl 0x7fde
movq %r8, 0x28(%rsp)
movl %edi, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
movl %r9d, %edx
movl %ebx, %ecx
shrl %cl, %edx
orl %edx, %eax
movl %eax, 0x4(%rsp)
leaq 0x4(%rsp), %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq 0x20(%rsp), %rcx
movl %r9d, 0x3c(%rsp)
callq 0x1280
cmpl $0x20, %ebx
jne 0x7fef
andl $0x0, 0x4(%rsp)
xorl %eax, %eax
xorl %ebx, %ebx
movq 0x8(%rsp), %rsi
movl 0x10(%rsp), %edi
movq 0x28(%rsp), %r8
movl 0x3c(%rsp), %r9d
jmp 0x8014
movl %ebx, %ecx
negb %cl
movl %r9d, %edx
shll %cl, %edx
orl %edx, %eax
movl %eax, 0x4(%rsp)
jmp 0x8014
leal -0x20(%rbx), %edx
negb %bl
movl 0x3c(%rsp), %r9d
movl %r9d, %eax
movl %ebx, %ecx
shll %cl, %eax
movl %eax, 0x4(%rsp)
movl %edx, %ebx
movq 0x8(%rsp), %rsi
movl 0x10(%rsp), %edi
movq 0x28(%rsp), %r8
cmpl 0x44(%rsp), %r9d
jne 0x8067
cmpl 0x40(%rsp), %r8d
jne 0x8067
cmpl $0x10, %ebx
jl 0x806e
movl %edi, 0x10(%rsp)
leal -0x10(%rbx), %ecx
movl %r14d, %edx
movq %rcx, 0x8(%rsp)
shrl %cl, %edx
orl %edx, %eax
movl %eax, 0x4(%rsp)
leaq 0x4(%rsp), %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq 0x20(%rsp), %rcx
callq 0x1280
cmpl $0x10, %ebx
jne 0x8084
andl $0x0, 0x4(%rsp)
xorl %eax, %eax
pushq $0x10
popq %r14
xorl %esi, %esi
jmp 0x809b
movl %esi, %r14d
movl %ebx, %esi
jmp 0x809f
movb $0x10, %cl
subb %bl, %cl
shll %cl, %r14d
leal 0x10(%rbx), %esi
orl %r14d, %eax
movl %eax, 0x4(%rsp)
movl %ebx, %r14d
jmp 0x809f
movb $0x30, %cl
subb %bl, %cl
shll %cl, %r14d
movl %r14d, 0x4(%rsp)
movl %r14d, %eax
movl %ebx, %r14d
movq 0x8(%rsp), %rsi
movl 0x10(%rsp), %edi
testb %dil, %dil
je 0x7f1e
movslq %r13d, %rcx
movzbl (%r15,%rcx), %edi
movq 0x48(%rsp), %rcx
movl 0x404(%rcx,%rdi,4), %r8d
movl 0x4(%rcx,%rdi,4), %r14d
leal (%r8,%rsi), %ebx
cmpl $0x20, %ebx
jl 0x810c
movq %r8, 0x28(%rsp)
movq %rdi, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
movl %r14d, %edx
movl %ebx, %ecx
shrl %cl, %edx
orl %edx, %eax
movl %eax, 0x4(%rsp)
leaq 0x4(%rsp), %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq 0x20(%rsp), %rcx
callq 0x1280
cmpl $0x20, %ebx
jne 0x811d
andl $0x0, 0x4(%rsp)
xorl %eax, %eax
xorl %ebx, %ebx
jmp 0x812f
movl %ebx, %ecx
negb %cl
movl %r14d, %edx
shll %cl, %edx
orl %edx, %eax
movl %eax, 0x4(%rsp)
jmp 0x813e
leal -0x20(%rbx), %edx
negb %bl
movl %r14d, %eax
movl %ebx, %ecx
shll %cl, %eax
movl %eax, 0x4(%rsp)
movl %edx, %ebx
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdi
movq 0x28(%rsp), %r8
cmpl 0x38(%rsp), %r14d
jne 0x818f
cmpl 0x34(%rsp), %r8d
jne 0x818f
cmpl $0x18, %ebx
jl 0x8193
leal -0x18(%rbx), %ecx
movl %edi, %edx
movl %ecx, 0x8(%rsp)
shrl %cl, %edx
orl %edx, %eax
movl %eax, 0x4(%rsp)
movq %rdi, %r14
leaq 0x4(%rsp), %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq 0x20(%rsp), %rcx
callq 0x1280
cmpl $0x18, %ebx
jne 0x81a6
andl $0x0, 0x4(%rsp)
xorl %eax, %eax
pushq $0x18
popq %rcx
movl %ecx, %esi
xorl %ecx, %ecx
jmp 0x81bb
movl %ebx, %ecx
jmp 0x81bb
movb $0x18, %cl
subb %bl, %cl
shll %cl, %edi
leal 0x8(%rbx), %ecx
orl %edi, %eax
movl %eax, 0x4(%rsp)
movl %ebx, %esi
jmp 0x81bb
movb $0x38, %cl
subb %bl, %cl
shll %cl, %r14d
movl %r14d, 0x4(%rsp)
movl %r14d, %eax
movl %ebx, %esi
movl 0x8(%rsp), %ecx
incl %r13d
movl %esi, %r14d
movl %ecx, %esi
jmp 0x7f1e
testl %esi, %esi
jle 0x8213
movq %rsi, %rbx
leaq 0x4(%rsp), %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq 0x20(%rsp), %rcx
callq 0x1280
cmpl $0x11, %r14d
jl 0x8204
cmpl %r14d, %ebx
jle 0x8204
leaq 0x4(%rsp), %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq 0x20(%rsp), %rcx
callq 0x1280
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x11, %r14d
jge 0x81ef
jmp 0x8204