// File: /workspace/github_c_makefile_star2_O0/snej[P]zdelta/inflate.c
// Function: zd_inflate
int ZEXPORT zd_inflate(z, f)
     zd_streamp z;
     int f;
{
  int r;
  uInt b;

  if (z == ZD_NULL || z->state == ZD_NULL || z->next_in == ZD_NULL ||
      z->next_out == ZD_NULL || z->refnum<0 || z->refnum>REFNUM)
    return ZD_STREAM_ERROR;
  f = f == ZD_FINISH ? ZD_BUF_ERROR : ZD_OK;
  r = ZD_BUF_ERROR;
  while (1) switch (z->state->mode)
  {
  case METHOD:
    NEEDBYTE
    if (((z->state->sub.method = NEXTBYTE) & 0xf) != ZD_DEFLATED)
    {
      z->state->mode = BAD;
      z->msg = (char*)"unknown compression method";
      z->state->sub.marker = 5;       /* can't try inflateSync */
      break;
    }

    if ((z->state->sub.method >> 4) + 8 > z->state->wbits)
    {
      z->state->mode = BAD;
      z->msg = (char*)"invalid window size";
      z->state->sub.marker = 5;       /* can't try inflateSync */
      break;
    }

    z->state->mode = FLAG;
  case FLAG:
    NEEDBYTE
    b = NEXTBYTE;
    if (((z->state->sub.method << 8) + b) % 31)
    {
      z->state->mode = BAD;
      z->msg = (char*)"incorrect header check";
      z->state->sub.marker = 5;       /* can't try inflateSync */
      break;
    }
    /* zdelta: no dictionary */
    z->state->mode = BLOCKS;

  case BLOCKS:
    r = inflate_blocks(z->state->blocks, z, r);
    if (r == ZD_DATA_ERROR)
    {
      z->state->mode = BAD;
      z->state->sub.marker = 0;       /* can try inflateSync */
      break;
    }
    if (r == ZD_OK)
      r = f;
    if (r != ZD_STREAM_END)
      return r;
    r = f;
    inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was);
    if (z->state->nowrap)
    {
      z->state->mode = DONE;
      break;
    }
    z->state->mode = CHECK4;
  case CHECK4:
    NEEDBYTE
    z->state->sub.check.need = (uLong)NEXTBYTE << 24;
    z->state->mode = CHECK3;
  case CHECK3:
    NEEDBYTE
    z->state->sub.check.need += (uLong)NEXTBYTE << 16;
    z->state->mode = CHECK2;
  case CHECK2:
    NEEDBYTE
    z->state->sub.check.need += (uLong)NEXTBYTE << 8;
    z->state->mode = CHECK1;
  case CHECK1:
    NEEDBYTE
    z->state->sub.check.need += (uLong)NEXTBYTE;
    if (z->state->sub.check.was != z->state->sub.check.need)
    {
      z->state->mode = BAD;
      z->msg = (char*)"incorrect data check";
      z->state->sub.marker = 5;       /* can't try inflateSync */
      break;
    }
    Tracev((stderr, "inflate: zlib check ok\n"));
    z->state->mode = DONE;
  case DONE:
    return ZD_STREAM_END;
  case BAD:
    return ZD_DATA_ERROR;
  default:
    return ZD_STREAM_ERROR;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x6b6a
movq -0x10(%rbp), %rax
cmpq $0x0, 0x58(%rax)
je 0x6b6a
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x6b6a
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x6b6a
movq -0x10(%rbp), %rax
cmpl $0x0, 0x48(%rax)
jl 0x6b6a
movq -0x10(%rbp), %rax
cmpl $0x1, 0x48(%rax)
jle 0x6b76
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x702c
movl -0x14(%rbp), %edx
xorl %eax, %eax
movl $0xfffffffb, %ecx       # imm = 0xFFFFFFFB
cmpl $0x4, %edx
cmovel %ecx, %eax
movl %eax, -0x14(%rbp)
movl $0xfffffffb, -0x18(%rbp) # imm = 0xFFFFFFFB
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl (%rax), %eax
movq %rax, -0x28(%rbp)
subq $0xd, %rax
ja 0x701e
movq -0x28(%rbp), %rax
leaq 0x9585(%rip), %rcx      # 0x10138
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x6bd1
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x702c
movl -0x14(%rbp), %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rcx
movq (%rcx), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, (%rcx)
movzbl (%rax), %eax
movq -0x10(%rbp), %rcx
movq 0x58(%rcx), %rcx
movl %eax, 0x8(%rcx)
andl $0xf, %eax
cmpl $0x5, %eax
je 0x6c4c
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl $0xd, (%rax)
movq -0x10(%rbp), %rax
leaq 0x9540(%rip), %rcx      # 0x10174
movq %rcx, 0x50(%rax)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x5, 0x8(%rax)
jmp 0x7027
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x8(%rax), %eax
shrl $0x4, %eax
addl $0x8, %eax
movq -0x10(%rbp), %rcx
movq 0x58(%rcx), %rcx
cmpl 0x1c(%rcx), %eax
jbe 0x6c9b
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl $0xd, (%rax)
movq -0x10(%rbp), %rax
leaq 0x950c(%rip), %rcx      # 0x1018f
movq %rcx, 0x50(%rax)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x5, 0x8(%rax)
jmp 0x7027
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x1, (%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x6cbe
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x702c
movl -0x14(%rbp), %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rcx
movq (%rcx), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, (%rcx)
movzbl (%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x8(%rax), %eax
shll $0x8, %eax
addl -0x1c(%rbp), %eax
movl $0x1f, %ecx
xorl %edx, %edx
divl %ecx
cmpl $0x0, %edx
je 0x6d48
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl $0xd, (%rax)
movq -0x10(%rbp), %rax
leaq 0x9473(%rip), %rcx      # 0x101a3
movq %rcx, 0x50(%rax)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x5, 0x8(%rax)
jmp 0x7027
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x7, (%rax)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq 0x20(%rax), %rdi
movq -0x10(%rbp), %rsi
movl -0x18(%rbp), %edx
callq 0xb340
movl %eax, -0x18(%rbp)
cmpl $-0x3, -0x18(%rbp)
jne 0x6d99
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl $0xd, (%rax)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x0, 0x8(%rax)
jmp 0x7027
cmpl $0x0, -0x18(%rbp)
jne 0x6da5
movl -0x14(%rbp), %eax
movl %eax, -0x18(%rbp)
cmpl $0x1, -0x18(%rbp)
je 0x6db6
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x702c
movl -0x14(%rbp), %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq 0x20(%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rdx
addq $0x8, %rdx
callq 0xb0c0
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x0, 0x18(%rax)
je 0x6dfe
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl $0xc, (%rax)
jmp 0x7027
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x8, (%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x6e21
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x702c
movl -0x14(%rbp), %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rcx
movq (%rcx), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, (%rcx)
movzbl (%rax), %eax
movl %eax, %ecx
shlq $0x18, %rcx
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x9, (%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x6e8d
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x702c
movl -0x14(%rbp), %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rcx
movq (%rcx), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, (%rcx)
movzbl (%rax), %eax
movl %eax, %ecx
shlq $0x10, %rcx
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
addq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl $0xa, (%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x6efd
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x702c
movl -0x14(%rbp), %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rcx
movq (%rcx), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, (%rcx)
movzbl (%rax), %eax
movl %eax, %ecx
shlq $0x8, %rcx
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
addq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl $0xb, (%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x6f6d
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x702c
movl -0x14(%rbp), %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rcx
movq (%rcx), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, (%rcx)
movzbl (%rax), %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
addq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x58(%rcx), %rcx
cmpq 0x10(%rcx), %rax
je 0x6ffe
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl $0xd, (%rax)
movq -0x10(%rbp), %rax
leaq 0x91d1(%rip), %rcx      # 0x101ba
movq %rcx, 0x50(%rax)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x5, 0x8(%rax)
jmp 0x7027
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl $0xc, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x702c
movl $0xfffffffd, -0x4(%rbp) # imm = 0xFFFFFFFD
jmp 0x702c
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x702c
jmp 0x6b90
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)