// File: /workspace/github_c_makefile_star2_O0/snej[P]zdelta/inflate.c
// Function: zd_inflateSync
int ZEXPORT zd_inflateSync(z)
zd_streamp z;
{
  uInt n;       /* number of bytes to look at */
  Bytef *p;     /* pointer to bytes */
  uInt m;       /* number of marker bytes found in a row */
  uLong r, w;   /* temporaries to save total_in and total_out */

  /* set up */
  if (z == ZD_NULL || z->state == ZD_NULL)
    return ZD_STREAM_ERROR;
  if (z->state->mode != BAD)
  {
    z->state->mode = BAD;
    z->state->sub.marker = 0;
  }
  if ((n = z->avail_in) == 0)
    return ZD_BUF_ERROR;
  p = z->next_in;
  m = z->state->sub.marker;

  /* search */
  while (n && m < 4)
  {
    static const Byte mark[4] = {0, 0, 0xff, 0xff};
    if (*p == mark[m])
      m++;
    else if (*p)
      m = 0;
    else
      m = 4 - m;
    p++, n--;
  }

  /* restore */
  z->total_in += p - z->next_in;
  z->next_in = p;
  z->avail_in = n;
  z->state->sub.marker = m;

  /* return no joy or set up to restart on a new block */
  if (m != 4)
    return ZD_DATA_ERROR;
  r = z->total_in;  w = z->total_out;
  zd_inflateReset(z);
  z->total_in = r;  z->total_out = w;
  z->state->mode = BLOCKS;
  return ZD_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x705e
movq -0x10(%rbp), %rax
cmpq $0x0, 0x58(%rax)
jne 0x706a
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x71dc
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0xd, (%rax)
je 0x7094
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl $0xd, (%rax)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x0, 0x8(%rax)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x14(%rbp)
cmpl $0x0, %eax
jne 0x70af
movl $0xfffffffb, -0x4(%rbp) # imm = 0xFFFFFFFB
jmp 0x71dc
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x8(%rax), %eax
movl %eax, -0x24(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x14(%rbp)
movb %al, -0x39(%rbp)
je 0x70dd
cmpl $0x4, -0x24(%rbp)
setb %al
movb %al, -0x39(%rbp)
movb -0x39(%rbp), %al
testb $0x1, %al
jne 0x70e6
jmp 0x7142
movq -0x20(%rbp), %rax
movzbl (%rax), %eax
movl -0x24(%rbp), %ecx
movl %ecx, %edx
leaq 0x9077(%rip), %rcx      # 0x10170
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0x710c
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x712b
movq -0x20(%rbp), %rax
cmpb $0x0, (%rax)
je 0x711e
movl $0x0, -0x24(%rbp)
jmp 0x7129
movl $0x4, %eax
subl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x712b
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x70c8
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
subq %rax, %rcx
movq -0x10(%rbp), %rax
addq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movl -0x14(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl %ecx, 0x8(%rax)
cmpl $0x4, -0x24(%rbp)
je 0x718e
movl $0xfffffffd, -0x4(%rbp) # imm = 0xFFFFFFFD
jmp 0x71dc
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
callq 0x67e0
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movl $0x7, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop