// File: /workspace/github_cpp_makefile_star2_O2/twekkel[P]mzpq/libzpaq.cpp
// Function: libzpaq::PostProcessor::write(int)
int PostProcessor::write(int c) {
  assert(c>=-1 && c<=255);
  switch (state) {
    case 0:  // initial state
      if (c<0) error("Unexpected EOS");
      state=c+1;  // 1=PASS, 2=PROG
      if (state>2) error("unknown post processing type");
      if (state==1) z.clear();
      break;
    case 1:  // PASS
      z.outc(c);
      break;
    case 2: // PROG
      if (c<0) error("Unexpected EOS");
      hsize=c;  // low byte of size
      state=3;
      break;
    case 3:  // PROG psize[0]
      if (c<0) error("Unexpected EOS");
      hsize+=c*256;  // high byte of psize
      if (hsize<1) error("Empty PCOMP");
      z.header.resize(hsize+300);
      z.cend=8;
      z.hbegin=z.hend=z.cend+128;
      z.header[4]=ph;
      z.header[5]=pm;
      state=4;
      break;
    case 4:  // PROG psize[0..1] pcomp[0...]
      if (c<0) error("Unexpected EOS");
      assert(z.hend<z.header.isize());
      z.header[z.hend++]=c;  // one byte of pcomp
      if (z.hend-z.hbegin==hsize) {  // last byte of pcomp?
        hsize=z.cend-2+z.hend-z.hbegin;
        z.header[0]=hsize&255;  // header size with empty COMP
        z.header[1]=hsize>>8;
        z.initp();
        state=5;
      }
      break;
    case 5:  // PROG ... data
      z.run(c);
      if (c<0) z.flush();
      break;
  }
  return state;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl (%rdi), %eax
cmpq $0x5, %rax
ja 0xc279
movl %esi, %r14d
leaq 0x12706(%rip), %rcx     # 0x1e808
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
testl %r14d, %r14d
js 0xc267
leal 0x1(%r14), %eax
movl %eax, (%rbx)
cmpl $0x2, %r14d
jb 0xc12e
leaq 0x15f00(%rip), %rdi     # 0x22027
callq 0x44dc
movl (%rbx), %eax
cmpl $0x1, %eax
jne 0xc279
leaq 0x10(%rbx), %rdi
callq 0x96e0
jmp 0xc279
testl %r14d, %r14d
jns 0xc156
leaq 0x15ec7(%rip), %rdi     # 0x22018
callq 0x44dc
movslq 0x40(%rbx), %rax
leal 0x1(%rax), %ecx
movl %ecx, 0x40(%rbx)
movq 0x20(%rbx), %rcx
movb %r14b, (%rcx,%rax)
movl 0x40(%rbx), %eax
subl 0x3c(%rbx), %eax
cmpl 0x4(%rbx), %eax
jne 0xc279
leaq 0x10(%rbx), %rdi
movl 0x38(%rbx), %ecx
addl %ecx, %eax
addl $-0x2, %eax
movl %eax, 0x4(%rbx)
movq 0x20(%rbx), %rcx
movb %al, (%rcx)
movb 0x5(%rbx), %al
movq 0x20(%rbx), %rcx
movb %al, 0x1(%rcx)
callq 0x992a
movl $0x5, (%rbx)
jmp 0xc279
testl %r14d, %r14d
jns 0xc1b7
leaq 0x15e66(%rip), %rdi     # 0x22018
callq 0x44dc
movl %r14d, 0x4(%rbx)
movl $0x3, (%rbx)
jmp 0xc279
testl %r14d, %r14d
jns 0xc1d7
leaq 0x15e46(%rip), %rdi     # 0x22018
callq 0x44dc
shll $0x8, %r14d
addl 0x4(%rbx), %r14d
movl %r14d, 0x4(%rbx)
jg 0xc1f5
leaq 0x15e58(%rip), %rdi     # 0x22044
callq 0x44dc
movl 0x4(%rbx), %r14d
leaq 0x20(%rbx), %rdi
addl $0x12c, %r14d           # imm = 0x12C
movslq %r14d, %rsi
xorl %edx, %edx
callq 0x1c46e
movabsq $0x8800000008, %rax     # imm = 0x8800000008
movq %rax, 0x38(%rbx)
movl $0x88, 0x40(%rbx)
movb 0x8(%rbx), %al
movq 0x20(%rbx), %rcx
movb %al, 0x4(%rcx)
movb 0xc(%rbx), %al
movq 0x20(%rbx), %rcx
movb %al, 0x5(%rcx)
movl $0x4, (%rbx)
jmp 0xc279
leaq 0x10(%rbx), %rdi
movl %r14d, %esi
callq 0x1c736
jmp 0xc279
leaq 0x10(%rbx), %r15
movq %r15, %rdi
movl %r14d, %esi
callq 0xbb08
testl %r14d, %r14d
jns 0xc279
movq %r15, %rdi
callq 0x993c
jmp 0xc279
leaq 0x15daa(%rip), %rdi     # 0x22018
callq 0x44dc
incl %r14d
movl %r14d, (%rbx)
movl (%rbx), %eax
popq %rbx
popq %r14
popq %r15
retq
nop