// File: /workspace/github_cpp_makefile_star2_O1/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 0xc93c
movl %esi, %r14d
leaq 0x3f00a(%rip), %rcx     # 0x4b7d8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
testl %r14d, %r14d
jns 0xc7e8
leaq 0x42805(%rip), %rdi     # 0x4efe8
callq 0x455c
leal 0x1(%r14), %eax
movl %eax, (%rbx)
cmpl $0x2, %r14d
jl 0xc800
leaq 0x427fc(%rip), %rdi     # 0x4eff7
callq 0x455c
cmpl $0x1, (%rbx)
jne 0xc93c
leaq 0x10(%rbx), %rdi
callq 0x9b54
jmp 0xc93c
testl %r14d, %r14d
jns 0xc828
leaq 0x427c5(%rip), %rdi     # 0x4efe8
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 0xc93c
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 0x9dc8
movl $0x5, (%rbx)
jmp 0xc93c
testl %r14d, %r14d
jns 0xc895
leaq 0x42758(%rip), %rdi     # 0x4efe8
callq 0x455c
movl %r14d, 0x4(%rbx)
movl $0x3, (%rbx)
jmp 0xc93c
testl %r14d, %r14d
jns 0xc8b5
leaq 0x42738(%rip), %rdi     # 0x4efe8
callq 0x455c
shll $0x8, %r14d
addl %r14d, 0x4(%rbx)
jg 0xc8cb
leaq 0x4274e(%rip), %rdi     # 0x4f014
callq 0x455c
leaq 0x20(%rbx), %rdi
movslq 0x4(%rbx), %rsi
addq $0x12c, %rsi            # imm = 0x12C
xorl %edx, %edx
callq 0x4a126
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 0xc93c
leaq 0x10(%rbx), %rdi
movl %r14d, %esi
callq 0x4a3d4
jmp 0xc93c
leaq 0x10(%rbx), %r15
movq %r15, %rdi
movl %r14d, %esi
callq 0xc1f6
testl %r14d, %r14d
jns 0xc93c
movq %r15, %rdi
callq 0x9e54
movl (%rbx), %eax
popq %rbx
popq %r14
popq %r15
retq