// File: /workspace/github_c_makefile_star2_O1/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, %r13d
movq %rcx, %r8
movq %rdx, 0x18(%rsp)
movq %rsi, 0x48(%rsp)
movl $0x7fffffff, 0x2c(%rsp) # imm = 0x7FFFFFFF
movq %rdi, 0x40(%rsp)
cmpl $0x2, (%rdi)
movl $0x7fffffff, 0x30(%rsp) # imm = 0x7FFFFFFF
jne 0x9099
movq 0x40(%rsp), %rax
movl 0x400(%rax), %ecx
movl %ecx, 0x30(%rsp)
movl 0x800(%rax), %eax
movl %eax, 0x2c(%rsp)
movq 0x48(%rsp), %rax
movl 0x400(%rax), %ecx
movl %ecx, 0x3c(%rsp)
movl 0x800(%rax), %eax
movl %eax, 0x38(%rsp)
movl $0x0, 0x4(%rsp)
testl %r13d, %r13d
jle 0x9382
movl %r13d, %eax
movq %rax, 0x50(%rsp)
xorl %eax, %eax
xorl %r14d, %r14d
movl %eax, %r12d
movq %r8, 0x8(%rsp)
movl %ebp, 0x14(%rsp)
movl %r13d, 0x34(%rsp)
movslq %eax, %rcx
leal 0x1(%rcx), %edx
cmpl %edx, %r13d
cmovgl %r13d, %edx
movzbl (%r8,%rcx), %esi
movb $0x1, %r13b
cmpl %ebp, %esi
movq 0x50(%rsp), %rdi
jne 0x9122
incq %rcx
movl %eax, %r12d
cmpq %rdi, %rcx
setl %r13b
jge 0x911f
movzbl (%r8,%rcx), %esi
incl %r12d
incq %rcx
cmpl %ebp, %esi
je 0x9105
jmp 0x9122
movl %edx, %r12d
movl %r12d, %ebp
subl %eax, %ebp
movl $0xff, %eax
cmpl %eax, %ebp
movl $0xff, %eax
cmovll %ebp, %eax
movq 0x48(%rsp), %rcx
movl 0x404(%rcx,%rax,4), %esi
movl 0x4(%rcx,%rax,4), %r15d
leal (%rsi,%r14), %ebx
movl 0x4(%rsp), %eax
cmpl $0x20, %ebx
jl 0x9190
movq %rsi, 0x20(%rsp)
movl %r15d, %edx
movl %ebx, %ecx
shrl %cl, %edx
orl %edx, %eax
movl %eax, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
leaq 0x4(%rsp), %rdi
movq 0x18(%rsp), %rcx
callq 0x1280
cmpl $0x20, %ebx
jne 0x91a1
movl $0x0, 0x4(%rsp)
xorl %ebx, %ebx
jmp 0x91b3
movl %ebx, %ecx
negb %cl
movl %r15d, %edx
shll %cl, %edx
orl %edx, %eax
movl %eax, 0x4(%rsp)
jmp 0x91bd
leal -0x20(%rbx), %eax
negb %bl
movl %r15d, %edx
movl %ebx, %ecx
shll %cl, %edx
movl %edx, 0x4(%rsp)
movl %eax, %ebx
movq 0x8(%rsp), %r8
movq 0x20(%rsp), %rsi
cmpl 0x3c(%rsp), %r15d
jne 0x920f
cmpl 0x38(%rsp), %esi
jne 0x920f
cmpl $0x10, %ebx
jl 0x9213
leal -0x10(%rbx), %ecx
movl %ebp, %eax
movq %rcx, %r15
shrl %cl, %eax
orl %eax, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
leaq 0x4(%rsp), %rdi
movq 0x18(%rsp), %rcx
callq 0x1280
cmpl $0x10, %ebx
jne 0x9225
movl $0x0, 0x4(%rsp)
xorl %esi, %esi
movl %ebx, %r14d
movq 0x8(%rsp), %r8
jmp 0x923a
movl %ebx, %esi
jmp 0x923a
leal 0x10(%rbx), %esi
movb $0x10, %cl
subb %bl, %cl
shll %cl, %ebp
orl %ebp, 0x4(%rsp)
movl %ebx, %r14d
jmp 0x923a
movb $0x30, %cl
subb %bl, %cl
shll %cl, %ebp
movl %ebp, 0x4(%rsp)
movl %ebx, %r14d
movq 0x8(%rsp), %r8
movq %r15, %rsi
testb %r13b, %r13b
je 0x92a6
movslq %r12d, %rax
movzbl (%r8,%rax), %r14d
movq 0x40(%rsp), %rax
movl 0x404(%rax,%r14,4), %r15d
movl 0x4(%rax,%r14,4), %ebp
leal (%r15,%rsi), %ebx
movl 0x4(%rsp), %eax
cmpl $0x20, %ebx
movl 0x34(%rsp), %r13d
jl 0x92b4
movq %rsi, 0x20(%rsp)
movl %ebp, %edx
movl %ebx, %ecx
shrl %cl, %edx
orl %edx, %eax
movl %eax, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
leaq 0x4(%rsp), %rdi
movq 0x18(%rsp), %rcx
callq 0x1280
cmpl $0x20, %ebx
jne 0x92c4
movl $0x0, 0x4(%rsp)
xorl %ebx, %ebx
jmp 0x92d5
movl 0x14(%rsp), %ebp
movl 0x34(%rsp), %r13d
jmp 0x936e
movl %ebx, %ecx
negb %cl
movl %ebp, %edx
shll %cl, %edx
orl %edx, %eax
movl %eax, 0x4(%rsp)
jmp 0x92df
leal -0x20(%rbx), %eax
negb %bl
movl %ebp, %edx
movl %ebx, %ecx
shll %cl, %edx
movl %edx, 0x4(%rsp)
movl %eax, %ebx
movq 0x8(%rsp), %r8
movq 0x20(%rsp), %rsi
cmpl 0x30(%rsp), %ebp
jne 0x9335
cmpl 0x2c(%rsp), %r15d
movl 0x14(%rsp), %ebp
jne 0x9330
cmpl $0x18, %ebx
jl 0x933e
leal -0x18(%rbx), %r15d
movl %r14d, %eax
movl %r15d, %ecx
shrl %cl, %eax
orl %eax, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
leaq 0x4(%rsp), %rdi
movq 0x18(%rsp), %rcx
callq 0x1280
cmpl $0x18, %ebx
jne 0x9352
movl $0x0, 0x4(%rsp)
xorl %r15d, %r15d
jmp 0x935e
movl %ebx, %r15d
jmp 0x9365
movl %ebx, %r15d
movl 0x14(%rsp), %ebp
jmp 0x9365
leal 0x8(%rbx), %r15d
movb $0x18, %cl
subb %bl, %cl
shll %cl, %r14d
orl %r14d, 0x4(%rsp)
movl %ebx, %esi
jmp 0x9365
movb $0x38, %cl
subb %bl, %cl
shll %cl, %r14d
movl %r14d, 0x4(%rsp)
movl %ebx, %esi
movq 0x8(%rsp), %r8
incl %r12d
movl %esi, %r14d
movl %r15d, %esi
movl %r14d, %ebx
movl %r12d, %eax
movl %esi, %r14d
cmpl %r13d, %r12d
jl 0x90e1
jmp 0x9386
xorl %ebx, %ebx
xorl %esi, %esi
testl %esi, %esi
jle 0x93d8
movq %rsi, %r14
leaq 0x4(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq 0x18(%rsp), %rcx
callq 0x1280
cmpl $0x11, %ebx
jl 0x93c9
cmpl %ebx, %r14d
jle 0x93c9
leaq 0x4(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq 0x18(%rsp), %rcx
callq 0x1280
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x11, %ebx
jge 0x93b0
jmp 0x93c9