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

    /* fill output buffer up to end of deflate stream */
    had = strm->avail_out;
    do {
        /* get more input for inflate() */
        if (strm->avail_in == 0 && gz_avail(state) == -1)
            return -1;
        if (strm->avail_in == 0) {
            gz_error(state, Z_BUF_ERROR, "unexpected end of file");
            break;
        }

        /* decompress and handle errors */
        ret = inflate(strm, Z_NO_FLUSH);
        if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT) {
            gz_error(state, Z_STREAM_ERROR,
                     "internal error: inflate stream corrupt");
            return -1;
        }
        if (ret == Z_MEM_ERROR) {
            gz_error(state, Z_MEM_ERROR, "out of memory");
            return -1;
        }
        if (ret == Z_DATA_ERROR) {              /* deflate stream invalid */
            gz_error(state, Z_DATA_ERROR,
                     strm->msg == NULL ? "compressed data error" : strm->msg);
            return -1;
        }
    } while (strm->avail_out && ret != Z_STREAM_END);

    /* update available output */
    state->x.have = had - strm->avail_out;
    state->x.next = strm->next_out - state->x.have;

    /* if the gzip stream completed successfully, look for another */
    if (ret == Z_STREAM_END)
        state->how = LOOK;

    /* good decompression */
    return 0;
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x28(%rsp)
movl $0x0, 0x24(%rsp)
movq 0x28(%rsp), %rax
addq $0x80, %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movl 0x20(%rax), %eax
movl %eax, 0x20(%rsp)
movq 0x18(%rsp), %rax
cmpl $0x0, 0x8(%rax)
jne 0xce8a4
movq 0x28(%rsp), %rdi
callq 0xcea20
cmpl $-0x1, %eax
jne 0xce8a4
movl $0xffffffff, 0x34(%rsp) # imm = 0xFFFFFFFF
jmp 0xcea08
movq 0x18(%rsp), %rax
cmpl $0x0, 0x8(%rax)
jne 0xce8ca
movq 0x28(%rsp), %rdi
movl $0xfffffffb, %esi       # imm = 0xFFFFFFFB
leaq 0xa79c6(%rip), %rdx     # 0x176286
callq 0xcd150
jmp 0xce9b7
movq 0x18(%rsp), %rdi
xorl %esi, %esi
callq 0xda230
movl %eax, 0x24(%rsp)
cmpl $-0x2, 0x24(%rsp)
je 0xce8e8
cmpl $0x2, 0x24(%rsp)
jne 0xce90b
movq 0x28(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0xa79a4(%rip), %rdx     # 0x17629d
callq 0xcd150
movl $0xffffffff, 0x34(%rsp) # imm = 0xFFFFFFFF
jmp 0xcea08
cmpl $-0x4, 0x24(%rsp)
jne 0xce935
movq 0x28(%rsp), %rdi
movl $0xfffffffc, %esi       # imm = 0xFFFFFFFC
leaq 0xa331b(%rip), %rdx     # 0x171c3e
callq 0xcd150
movl $0xffffffff, 0x34(%rsp) # imm = 0xFFFFFFFF
jmp 0xcea08
cmpl $-0x3, 0x24(%rsp)
jne 0xce98c
movq 0x28(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x18(%rsp), %rax
cmpq $0x0, 0x30(%rax)
jne 0xce960
leaq 0xa796b(%rip), %rax     # 0x1762c4
movq %rax, 0x8(%rsp)
jmp 0xce96e
movq 0x18(%rsp), %rax
movq 0x30(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rdx
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0xcd150
movl $0xffffffff, 0x34(%rsp) # imm = 0xFFFFFFFF
jmp 0xcea08
jmp 0xce98e
movq 0x18(%rsp), %rcx
xorl %eax, %eax
cmpl $0x0, 0x20(%rcx)
movb %al, 0x7(%rsp)
je 0xce9ab
cmpl $0x1, 0x24(%rsp)
setne %al
movb %al, 0x7(%rsp)
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0xce87d
movl 0x20(%rsp), %ecx
movq 0x18(%rsp), %rax
subl 0x20(%rax), %ecx
movq 0x28(%rsp), %rax
movl %ecx, (%rax)
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rcx
movq 0x28(%rsp), %rax
movl (%rax), %eax
movl %eax, %edx
xorl %eax, %eax
subq %rdx, %rax
addq %rax, %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x8(%rax)
cmpl $0x1, 0x24(%rsp)
jne 0xcea00
movq 0x28(%rsp), %rax
movl $0x0, 0x44(%rax)
movl $0x0, 0x34(%rsp)
movl 0x34(%rsp), %eax
addq $0x38, %rsp
retq
nopw %cs:(%rax,%rax)