// File: /workspace/github_c_makefile_star2_O3/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 0xa0909
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
testl %eax, %eax
je 0xa290c
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 0xa2923
movl $0xfffffffb, %ebp       # imm = 0xFFFFFFFB
cmpl $0x8, 0x58(%r14)
jb 0xa28fb
cmpl $0x3f53, 0x8(%r14)      # imm = 0x3F53
je 0xa2992
movl $0x3f53, 0x8(%r14)      # imm = 0x3F53
movl 0x58(%r14), %esi
movq 0x50(%r14), %rax
movl %esi, %ecx
andb $0x7, %cl
shrq %cl, %rax
movq %rax, 0x50(%r14)
xorl %ecx, %ecx
movl $0x0, %edx
testl $0xfffffff8, %esi       # imm = 0xFFFFFFF8
je 0xa2973
andl $-0x8, %esi
negl %esi
xorl %edx, %edx
movb %al, 0x4(%rsp,%rdx)
incq %rdx
shrq $0x8, %rax
addl $0x8, %esi
jne 0xa295f
movq %rax, 0x50(%r14)
movl %ecx, 0x58(%r14)
leaq 0x8c(%r14), %rdi
movl %ecx, 0x8c(%r14)
leaq 0x4(%rsp), %rsi
callq 0xa2a06
movl 0x8(%rbx), %edx
leaq 0x8c(%r14), %rdi
movq (%rbx), %rsi
callq 0xa2a06
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 0xa28fb
movl 0x18(%r14), %r12d
xorl %ebp, %ebp
movl $0x0, %eax
cmpl $-0x1, %r12d
je 0xa29dd
movl 0x10(%r14), %eax
andl $-0x5, %eax
movl %eax, 0x10(%r14)
movq 0x28(%rbx), %r13
movq %rbx, %rdi
callq 0xa0941
movq %r15, 0x10(%rbx)
movq %r13, 0x28(%rbx)
movl %r12d, 0x18(%r14)
movl $0x3f3f, 0x8(%r14)      # imm = 0x3F3F
jmp 0xa28fb