// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/zlib-1.3.0.1/gzread.c
// Function: gz_look
local int gz_look(gz_statep state) {
    z_streamp strm = &(state->strm);

    /* allocate read buffers and inflate memory */
    if (state->size == 0) {
        /* allocate buffers */
        state->in = (unsigned char *)malloc(state->want);
        state->out = (unsigned char *)malloc(state->want << 1);
        if (state->in == NULL || state->out == NULL) {
            free(state->out);
            free(state->in);
            gz_error(state, Z_MEM_ERROR, "out of memory");
            return -1;
        }
        state->size = state->want;

        /* allocate inflate memory */
        state->strm.zalloc = Z_NULL;
        state->strm.zfree = Z_NULL;
        state->strm.opaque = Z_NULL;
        state->strm.avail_in = 0;
        state->strm.next_in = Z_NULL;
        if (inflateInit2(&(state->strm), 15 + 16) != Z_OK) {    /* gunzip */
            free(state->out);
            free(state->in);
            state->size = 0;
            gz_error(state, Z_MEM_ERROR, "out of memory");
            return -1;
        }
    }

    /* get at least the magic bytes in the input buffer */
    if (strm->avail_in < 2) {
        if (gz_avail(state) == -1)
            return -1;
        if (strm->avail_in == 0)
            return 0;
    }

    /* look for gzip magic bytes -- if there, do gzip decoding (note: there is
       a logical dilemma here when considering the case of a partially written
       gzip file, to wit, if a single 31 byte is written, then we cannot tell
       whether this is a single-byte file, or just a partially written gzip
       file -- for here we assume that if a gzip file is being written, then
       the header will be written in a single operation, so that reading a
       single byte is sufficient indication that it is not a gzip file) */
    if (strm->avail_in > 1 &&
            strm->next_in[0] == 31 && strm->next_in[1] == 139) {
        inflateReset(strm);
        state->how = GZIP;
        state->direct = 0;
        return 0;
    }

    /* no gzip header -- if we were decoding gzip before, then this is trailing
       garbage.  Ignore the trailing garbage and finish. */
    if (state->direct == 0) {
        strm->avail_in = 0;
        state->eof = 1;
        state->x.have = 0;
        return 0;
    }

    /* doing raw i/o, copy any leftover input to output -- this assumes that
       the output buffer is larger than the input buffer, which also assures
       space for gzungetc() */
    state->x.next = state->out;
    memcpy(state->x.next, strm->next_in, strm->avail_in);
    state->x.have = strm->avail_in;
    strm->avail_in = 0;
    state->how = COPY;
    state->direct = 1;
    return 0;
}

// Assembly:
subq $0x18, %rsp
movq %rdi, 0x8(%rsp)
movq 0x8(%rsp), %rax
addq $0x80, %rax
movq %rax, (%rsp)
movq 0x8(%rsp), %rax
cmpl $0x0, 0x28(%rax)
jne 0xcdfeb
movq 0x8(%rsp), %rax
movl 0x2c(%rax), %eax
movl %eax, %edi
callq 0xbcb8
movq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x30(%rax)
movq 0x8(%rsp), %rax
movl 0x2c(%rax), %eax
shll %eax
movl %eax, %eax
movl %eax, %edi
callq 0xbcb8
movq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x38(%rax)
movq 0x8(%rsp), %rax
cmpq $0x0, 0x30(%rax)
je 0xcded9
movq 0x8(%rsp), %rax
cmpq $0x0, 0x38(%rax)
jne 0xcdf18
movq 0x8(%rsp), %rax
movq 0x38(%rax), %rdi
callq 0xb760
movq 0x8(%rsp), %rax
movq 0x30(%rax), %rdi
callq 0xb760
movq 0x8(%rsp), %rdi
movl $0xfffffffc, %esi       # imm = 0xFFFFFFFC
leaq 0xa3d38(%rip), %rdx     # 0x171c3e
callq 0xcd150
movl $0xffffffff, 0x14(%rsp) # imm = 0xFFFFFFFF
jmp 0xce123
movq 0x8(%rsp), %rax
movl 0x2c(%rax), %ecx
movq 0x8(%rsp), %rax
movl %ecx, 0x28(%rax)
movq 0x8(%rsp), %rax
movq $0x0, 0xc0(%rax)
movq 0x8(%rsp), %rax
movq $0x0, 0xc8(%rax)
movq 0x8(%rsp), %rax
movq $0x0, 0xd0(%rax)
movq 0x8(%rsp), %rax
movl $0x0, 0x88(%rax)
movq 0x8(%rsp), %rax
movq $0x0, 0x80(%rax)
movq 0x8(%rsp), %rdi
addq $0x80, %rdi
movl $0x1f, %esi
leaq 0xa834b(%rip), %rdx     # 0x1762da
movl $0x70, %ecx
callq 0xd9f90
cmpl $0x0, %eax
je 0xcdfe9
movq 0x8(%rsp), %rax
movq 0x38(%rax), %rdi
callq 0xb760
movq 0x8(%rsp), %rax
movq 0x30(%rax), %rdi
callq 0xb760
movq 0x8(%rsp), %rax
movl $0x0, 0x28(%rax)
movq 0x8(%rsp), %rdi
movl $0xfffffffc, %esi       # imm = 0xFFFFFFFC
leaq 0xa3c67(%rip), %rdx     # 0x171c3e
callq 0xcd150
movl $0xffffffff, 0x14(%rsp) # imm = 0xFFFFFFFF
jmp 0xce123
jmp 0xcdfeb
movq (%rsp), %rax
cmpl $0x2, 0x8(%rax)
jae 0xce02a
movq 0x8(%rsp), %rdi
callq 0xcea20
cmpl $-0x1, %eax
jne 0xce011
movl $0xffffffff, 0x14(%rsp) # imm = 0xFFFFFFFF
jmp 0xce123
movq (%rsp), %rax
cmpl $0x0, 0x8(%rax)
jne 0xce028
movl $0x0, 0x14(%rsp)
jmp 0xce123
jmp 0xce02a
movq (%rsp), %rax
cmpl $0x1, 0x8(%rax)
jbe 0xce083
movq (%rsp), %rax
movq (%rax), %rax
movzbl (%rax), %eax
cmpl $0x1f, %eax
jne 0xce083
movq (%rsp), %rax
movq (%rax), %rax
movzbl 0x1(%rax), %eax
cmpl $0x8b, %eax
jne 0xce083
movq (%rsp), %rdi
callq 0xd9e00
movq 0x8(%rsp), %rax
movl $0x2, 0x44(%rax)
movq 0x8(%rsp), %rax
movl $0x0, 0x40(%rax)
movl $0x0, 0x14(%rsp)
jmp 0xce123
movq 0x8(%rsp), %rax
cmpl $0x0, 0x40(%rax)
jne 0xce0ba
movq (%rsp), %rax
movl $0x0, 0x8(%rax)
movq 0x8(%rsp), %rax
movl $0x1, 0x50(%rax)
movq 0x8(%rsp), %rax
movl $0x0, (%rax)
movl $0x0, 0x14(%rsp)
jmp 0xce123
movq 0x8(%rsp), %rax
movq 0x38(%rax), %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
movq (%rsp), %rax
movq (%rax), %rsi
movq (%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, %edx
callq 0xb500
movq (%rsp), %rax
movl 0x8(%rax), %ecx
movq 0x8(%rsp), %rax
movl %ecx, (%rax)
movq (%rsp), %rax
movl $0x0, 0x8(%rax)
movq 0x8(%rsp), %rax
movl $0x1, 0x44(%rax)
movq 0x8(%rsp), %rax
movl $0x1, 0x40(%rax)
movl $0x0, 0x14(%rsp)
movl 0x14(%rsp), %eax
addq $0x18, %rsp
retq
nopl (%rax)