// File: /workspace/github_c_makefile_star2_O1/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 0xa1339
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
testl %eax, %eax
je 0xa3153
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x38(%rbx), %r14
cmpl $0x0, 0x8(%rbx)
jne 0xa3169
movl $0xfffffffb, %ebp       # imm = 0xFFFFFFFB
cmpl $0x8, 0x58(%r14)
jb 0xa3142
cmpl $0x3f53, 0x8(%r14)      # imm = 0x3F53
je 0xa31cb
movl $0x3f53, 0x8(%r14)      # imm = 0x3F53
movl 0x58(%r14), %eax
movl %eax, %ecx
andb $0x7, %cl
shrq %cl, 0x50(%r14)
andl $-0x8, %eax
je 0xa31a9
movq 0x50(%r14), %rcx
xorl %edx, %edx
movb %cl, 0x4(%rsp,%rdx)
incq %rdx
shrq $0x8, %rcx
addl $-0x8, %eax
jne 0xa3193
movq %rcx, 0x50(%r14)
jmp 0xa31ab
xorl %edx, %edx
movl %eax, 0x58(%r14)
leaq 0x8c(%r14), %rdi
movl $0x0, 0x8c(%r14)
leaq 0x4(%rsp), %rsi
callq 0xa3242
leaq 0x8c(%r14), %rdi
movq (%rbx), %rsi
movl 0x8(%rbx), %edx
callq 0xa3242
subl %eax, 0x8(%rbx)
movl %eax, %r15d
addq %r15, (%rbx)
addq 0x10(%rbx), %r15
movq %r15, 0x10(%rbx)
movl $0xfffffffd, %ebp       # imm = 0xFFFFFFFD
cmpl $0x4, 0x8c(%r14)
jne 0xa3142
movl 0x18(%r14), %r12d
xorl %ebp, %ebp
movl $0x0, %eax
cmpl $-0x1, %r12d
je 0xa3219
movl 0x10(%r14), %eax
andl $-0x5, %eax
movl %eax, 0x10(%r14)
movq 0x28(%rbx), %r13
movq %rbx, %rdi
callq 0xa1371
movq %r15, 0x10(%rbx)
movq %r13, 0x28(%rbx)
movl %r12d, 0x18(%r14)
movl $0x3f3f, 0x8(%r14)      # imm = 0x3F3F
jmp 0xa3142