// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/zlib-1.3.0.1/inflate.c
// Function: inflateSync
int ZEXPORT inflateSync(z_streamp strm) {
    unsigned len;               /* number of bytes to look at or looked at */
    int flags;                  /* temporary to save header status */
    unsigned long in, out;      /* temporary to save total_in and total_out */
    unsigned char buf[4];       /* to restore bit buffer to byte string */
    struct inflate_state FAR *state;

    /* check parameters */
    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
    state = (struct inflate_state FAR *)strm->state;
    if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;

    /* if first time, start search in bit buffer */
    if (state->mode != SYNC) {
        state->mode = SYNC;
        state->hold >>= state->bits & 7;
        state->bits -= state->bits & 7;
        len = 0;
        while (state->bits >= 8) {
            buf[len++] = (unsigned char)(state->hold);
            state->hold >>= 8;
            state->bits -= 8;
        }
        state->have = 0;
        syncsearch(&(state->have), buf, len);
    }

    /* search available input */
    len = syncsearch(&(state->have), strm->next_in, strm->avail_in);
    strm->avail_in -= len;
    strm->next_in += len;
    strm->total_in += len;

    /* return no joy or set up to restart inflate() on a new block */
    if (state->have != 4) return Z_DATA_ERROR;
    if (state->flags == -1)
        state->wrap = 0;    /* if no header yet, treat as raw */
    else
        state->wrap &= ~4;  /* no point in computing a check value now */
    flags = state->flags;
    in = strm->total_in;  out = strm->total_out;
    inflateReset(strm);
    strm->total_in = in;  strm->total_out = out;
    state->flags = flags;
    state->mode = TYPE;
    return Z_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x80350
testl %eax, %eax
je 0x8240f
pushq $-0x2
popq %rbp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x38(%rbx), %r14
movl 0x8(%rbx), %edx
testl %edx, %edx
jne 0x82425
cmpl $0x8, 0x58(%r14)
jae 0x82425
pushq $-0x5
jmp 0x823fd
cmpl $0x3f53, 0x8(%r14)      # imm = 0x3F53
je 0x8248c
movl $0x3f53, 0x8(%r14)      # imm = 0x3F53
movl 0x58(%r14), %eax
movq 0x50(%r14), %rsi
movl %eax, %ecx
andb $0x7, %cl
shrq %cl, %rsi
movq %rsi, 0x50(%r14)
andl $-0x8, %eax
negl %eax
xorl %edx, %edx
testl %eax, %eax
je 0x8246b
movb %sil, 0x4(%rsp,%rdx)
incq %rdx
shrq $0x8, %rsi
movq %rsi, 0x50(%r14)
addl $0x8, %eax
jmp 0x82452
andl $0x0, 0x58(%r14)
leaq 0x8c(%r14), %rdi
andl $0x0, 0x8c(%r14)
leaq 0x4(%rsp), %rsi
callq 0x824fe
movl 0x8(%rbx), %edx
leaq 0x8c(%r14), %rdi
movq (%rbx), %rsi
callq 0x824fe
subl %eax, 0x8(%rbx)
movl %eax, %r15d
addq %r15, (%rbx)
addq 0x10(%rbx), %r15
movq %r15, 0x10(%rbx)
cmpl $0x4, 0x8c(%r14)
jne 0x824f7
movl 0x18(%r14), %r12d
xorl %ebp, %ebp
movl $0x0, %eax
cmpl $-0x1, %r12d
je 0x824ce
movl 0x10(%r14), %eax
andl $-0x5, %eax
movl %eax, 0x10(%r14)
movq 0x28(%rbx), %r13
movq %rbx, %rdi
callq 0x80386
movq %r15, 0x10(%rbx)
movq %r13, 0x28(%rbx)
movl %r12d, 0x18(%r14)
movl $0x3f3f, 0x8(%r14)      # imm = 0x3F3F
jmp 0x823fe
pushq $-0x3
jmp 0x823fd