// File: /workspace/github_cpp_makefile_star2_O3/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 0xce4d
movl %esi, %r14d
leaq 0x292de(%rip), %rcx     # 0x35fa8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
testl %r14d, %r14d
js 0xce3b
leal 0x1(%r14), %eax
movl %eax, (%rbx)
cmpl $0x2, %r14d
jb 0xccf6
leaq 0x2cad8(%rip), %rdi     # 0x397c7
callq 0x455c
movl (%rbx), %eax
cmpl $0x1, %eax
jne 0xce4d
leaq 0x10(%rbx), %rdi
callq 0x9b6c
jmp 0xce4d
testl %r14d, %r14d
jns 0xcd1e
leaq 0x2ca9f(%rip), %rdi     # 0x397b8
callq 0x455c
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 0xce4d
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)
movq 0x20(%rbx), %rax
movzbl 0x4(%rax), %esi
movzbl 0x5(%rax), %edx
callq 0x9de0
movl $0x5, (%rbx)
jmp 0xce4d
testl %r14d, %r14d
jns 0xcd8b
leaq 0x2ca32(%rip), %rdi     # 0x397b8
callq 0x455c
movl %r14d, 0x4(%rbx)
movl $0x3, (%rbx)
jmp 0xce4d
testl %r14d, %r14d
jns 0xcdab
leaq 0x2ca12(%rip), %rdi     # 0x397b8
callq 0x455c
shll $0x8, %r14d
addl 0x4(%rbx), %r14d
movl %r14d, 0x4(%rbx)
jg 0xcdc9
leaq 0x2ca24(%rip), %rdi     # 0x397e4
callq 0x455c
movl 0x4(%rbx), %r14d
leaq 0x20(%rbx), %rdi
addl $0x12c, %r14d           # imm = 0x12C
movslq %r14d, %rsi
xorl %edx, %edx
callq 0x3386a
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 0xce4d
leaq 0x10(%rbx), %rdi
movl %r14d, %esi
callq 0x33b18
jmp 0xce4d
leaq 0x10(%rbx), %r15
movq %r15, %rdi
movl %r14d, %esi
callq 0xc6e2
testl %r14d, %r14d
jns 0xce4d
movq %r15, %rdi
callq 0x9e6c
jmp 0xce4d
leaq 0x2c976(%rip), %rdi     # 0x397b8
callq 0x455c
incl %r14d
movl %r14d, (%rbx)
movl (%rbx), %eax
popq %rbx
popq %r14
popq %r15
retq
nop