// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/../foreign/miniz-c.h
// Function: mz_inflate
int mz_inflate(mz_streamp pStream, int flush)
{
    inflate_state *pState;
    mz_uint n, first_call, decomp_flags = TINFL_FLAG_COMPUTE_ADLER32;
    size_t in_bytes, out_bytes, orig_avail_in;
    tinfl_status status;

    if ((!pStream) || (!pStream->state))
        return MZ_STREAM_ERROR;
    if (flush == MZ_PARTIAL_FLUSH)
        flush = MZ_SYNC_FLUSH;
    if ((flush) && (flush != MZ_SYNC_FLUSH) && (flush != MZ_FINISH))
        return MZ_STREAM_ERROR;

    pState = (inflate_state *)pStream->state;
    if (pState->m_window_bits > 0)
        decomp_flags |= TINFL_FLAG_PARSE_ZLIB_HEADER;
    orig_avail_in = pStream->avail_in;

    first_call = pState->m_first_call;
    pState->m_first_call = 0;
    if (pState->m_last_status < 0)
        return MZ_DATA_ERROR;

    if (pState->m_has_flushed && (flush != MZ_FINISH))
        return MZ_STREAM_ERROR;
    pState->m_has_flushed |= (flush == MZ_FINISH);

    if ((flush == MZ_FINISH) && (first_call))
    {
        /* MZ_FINISH on the first call implies that the input and output buffers are large enough to hold the entire compressed/decompressed file. */
        decomp_flags |= TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF;
        in_bytes = pStream->avail_in;
        out_bytes = pStream->avail_out;
        status = tinfl_decompress(&pState->m_decomp, pStream->next_in, &in_bytes, pStream->next_out, pStream->next_out, &out_bytes, decomp_flags);
        pState->m_last_status = status;
        pStream->next_in += (mz_uint)in_bytes;
        pStream->avail_in -= (mz_uint)in_bytes;
        pStream->total_in += (mz_uint)in_bytes;
        pStream->adler = tinfl_get_adler32(&pState->m_decomp);
        pStream->next_out += (mz_uint)out_bytes;
        pStream->avail_out -= (mz_uint)out_bytes;
        pStream->total_out += (mz_uint)out_bytes;

        if (status < 0)
            return MZ_DATA_ERROR;
        else if (status != TINFL_STATUS_DONE)
        {
            pState->m_last_status = TINFL_STATUS_FAILED;
            return MZ_BUF_ERROR;
        }
        return MZ_STREAM_END;
    }
    /* flush != MZ_FINISH then we must assume there's more input. */
    if (flush != MZ_FINISH)
        decomp_flags |= TINFL_FLAG_HAS_MORE_INPUT;

    if (pState->m_dict_avail)
    {
        n = MZ_MIN(pState->m_dict_avail, pStream->avail_out);
        memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n);
        pStream->next_out += n;
        pStream->avail_out -= n;
        pStream->total_out += n;
        pState->m_dict_avail -= n;
        pState->m_dict_ofs = (pState->m_dict_ofs + n) & (TINFL_LZ_DICT_SIZE - 1);
        return ((pState->m_last_status == TINFL_STATUS_DONE) && (!pState->m_dict_avail)) ? MZ_STREAM_END : MZ_OK;
    }

    for (;;)
    {
        in_bytes = pStream->avail_in;
        out_bytes = TINFL_LZ_DICT_SIZE - pState->m_dict_ofs;

        status = tinfl_decompress(&pState->m_decomp, pStream->next_in, &in_bytes, pState->m_dict, pState->m_dict + pState->m_dict_ofs, &out_bytes, decomp_flags);
        pState->m_last_status = status;

        pStream->next_in += (mz_uint)in_bytes;
        pStream->avail_in -= (mz_uint)in_bytes;
        pStream->total_in += (mz_uint)in_bytes;
        pStream->adler = tinfl_get_adler32(&pState->m_decomp);

        pState->m_dict_avail = (mz_uint)out_bytes;

        n = MZ_MIN(pState->m_dict_avail, pStream->avail_out);
        memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n);
        pStream->next_out += n;
        pStream->avail_out -= n;
        pStream->total_out += n;
        pState->m_dict_avail -= n;
        pState->m_dict_ofs = (pState->m_dict_ofs + n) & (TINFL_LZ_DICT_SIZE - 1);

        if (status < 0)
            return MZ_DATA_ERROR; /* Stream is corrupted (there could be some uncompressed data left in the output dictionary - oh well). */
        else if ((status == TINFL_STATUS_NEEDS_MORE_INPUT) && (!orig_avail_in))
            return MZ_BUF_ERROR; /* Signal caller that we can't make forward progress without supplying more input or by setting flush to MZ_FINISH. */
        else if (flush == MZ_FINISH)
        {
            /* The output buffer MUST be large to hold the remaining uncompressed data when flush==MZ_FINISH. */
            if (status == TINFL_STATUS_DONE)
                return pState->m_dict_avail ? MZ_BUF_ERROR : MZ_STREAM_END;
            /* status here must be TINFL_STATUS_HAS_MORE_OUTPUT, which means there's at least 1 more byte on the way. If there's no more room left in the output buffer then something is wrong. */
            else if (!pStream->avail_out)
                return MZ_BUF_ERROR;
        }
        else if ((status == TINFL_STATUS_DONE) || (!pStream->avail_in) || (!pStream->avail_out) || (pState->m_dict_avail))
            break;
    }

    return ((status == TINFL_STATUS_DONE) && (!pState->m_dict_avail)) ? MZ_STREAM_END : MZ_OK;
}

// Assembly:
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
testq %rdi, %rdi
je 0x10aa41
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %r14
movq 0x38(%rdi), %rbx
testq %rbx, %rbx
je 0x10aa33
cmpl $0x1, %esi
movl $0x2, %r13d
cmovnel %esi, %r13d
cmpl $0x4, %r13d
ja 0x10aa33
movl $0x15, %ecx
btl %r13d, %ecx
jae 0x10aa33
xorl %edx, %edx
cmpl $0x0, 0x20c8(%rbx)
setg %dil
movl 0x8(%r14), %r10d
movl 0x20c0(%rbx), %ecx
movl $0x0, 0x20c0(%rbx)
cmpl $0x0, 0xa0cc(%rbx)
js 0x10aa2e
cmpl $0x4, %r13d
setne %r8b
movl 0x20c4(%rbx), %esi
testl %esi, %esi
setne %r9b
testb %r9b, %r8b
jne 0x10aa33
movb %dil, %dl
orl $0x8, %edx
xorl %eax, %eax
cmpl $0x4, %r13d
sete %al
orl %eax, %esi
movl %esi, 0x20c4(%rbx)
cmpl $0x4, %r13d
jne 0x10a87a
testl %ecx, %ecx
je 0x10a87a
orl $0x4, %edx
leaq 0x20(%rsp), %r15
movq %r10, (%r15)
movl 0x20(%r14), %eax
leaq 0x18(%rsp), %r12
movq %rax, (%r12)
movq (%r14), %rsi
movq 0x18(%r14), %rcx
movl %edx, (%rsp)
movq %rbx, %rdi
movq %r15, %rdx
movq %rcx, %r8
movq %r12, %r9
callq 0x10aa5c
movl %eax, %ecx
movl %eax, 0xa0cc(%rbx)
movq (%r15), %rax
movl %eax, %edx
addq %rdx, (%r14)
subl %eax, 0x8(%r14)
addq %rdx, 0x10(%r14)
movl 0x1c(%rbx), %eax
movq %rax, 0x60(%r14)
movq (%r12), %rax
movl %eax, %edx
addq %rdx, 0x18(%r14)
subl %eax, 0x20(%r14)
addq %rdx, 0x28(%r14)
movl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
testl %ecx, %ecx
js 0x10aa33
je 0x10aa42
movl $0xffffffff, 0xa0cc(%rbx) # imm = 0xFFFFFFFF
movl $0xfffffffb, %eax       # imm = 0xFFFFFFFB
jmp 0x10aa33
movl %edx, %ecx
orl $0x2, %ecx
cmpl $0x4, %r13d
cmovel %edx, %ecx
movl 0x20bc(%rbx), %eax
testl %eax, %eax
je 0x10a905
movl 0x20(%r14), %r15d
cmpl %r15d, %eax
cmovbl %eax, %r15d
movq 0x18(%r14), %rdi
movl 0x20b8(%rbx), %eax
leaq (%rbx,%rax), %rsi
addq $0x20cc, %rsi           # imm = 0x20CC
movq %r15, %rdx
callq 0x181e0
addq %r15, 0x18(%r14)
subl %r15d, 0x20(%r14)
addq %r15, 0x28(%r14)
movl 0x20bc(%rbx), %ecx
movl %ecx, %eax
subl %r15d, %eax
movl %eax, 0x20bc(%rbx)
movl 0x20b8(%rbx), %eax
addl %r15d, %eax
andl $0x7fff, %eax           # imm = 0x7FFF
movl %eax, 0x20b8(%rbx)
xorl %eax, %eax
cmpl $0x0, 0xa0cc(%rbx)
jne 0x10aa33
xorl %eax, %eax
cmpl %r15d, %ecx
sete %al
jmp 0x10aa33
leaq 0x20cc(%rbx), %rax
movq %rax, 0x30(%rsp)
movl %ecx, 0x14(%rsp)
movq %r10, 0x28(%rsp)
movq 0x30(%rsp), %r15
movl 0x8(%r14), %eax
movq %rax, 0x20(%rsp)
movl 0x20b8(%rbx), %r8d
movl $0x8000, %eax           # imm = 0x8000
subl %r8d, %eax
movq %rax, 0x18(%rsp)
movq (%r14), %rsi
addq %r15, %r8
movl %ecx, (%rsp)
movq %rbx, %rdi
leaq 0x20(%rsp), %rdx
movq %r15, %rcx
leaq 0x18(%rsp), %r9
callq 0x10aa5c
movl %eax, %r12d
movl %eax, 0xa0cc(%rbx)
movq 0x20(%rsp), %rax
movl %eax, %ecx
addq %rcx, (%r14)
subl %eax, 0x8(%r14)
addq %rcx, 0x10(%r14)
movl 0x1c(%rbx), %eax
movq %rax, 0x60(%r14)
movl 0x18(%rsp), %ebp
movl %ebp, 0x20bc(%rbx)
movl 0x20(%r14), %eax
cmpl %ebp, %eax
cmovbl %eax, %ebp
movq 0x18(%r14), %rdi
movl 0x20b8(%rbx), %esi
addq %r15, %rsi
movq %rbp, %rdx
callq 0x181e0
addq %rbp, 0x18(%r14)
movl 0x20(%r14), %edx
movl %edx, %eax
subl %ebp, %eax
movl %eax, 0x20(%r14)
addq %rbp, 0x28(%r14)
movl 0x20bc(%rbx), %ecx
movl %ecx, %eax
subl %ebp, %eax
movl %eax, 0x20bc(%rbx)
movl 0x20b8(%rbx), %eax
addl %ebp, %eax
andl $0x7fff, %eax           # imm = 0x7FFF
movl %eax, 0x20b8(%rbx)
testl %r12d, %r12d
js 0x10aa2e
movl %r12d, %esi
xorl $0x1, %esi
movl $0xfffffffb, %eax       # imm = 0xFFFFFFFB
movq 0x28(%rsp), %r10
orl %r10d, %esi
je 0x10aa33
cmpl $0x4, %r13d
jne 0x10aa0e
testl %r12d, %r12d
je 0x10aa49
cmpl %ebp, %edx
movl 0x14(%rsp), %ecx
jne 0x10a91f
jmp 0x10aa33
xorl %eax, %eax
testl %r12d, %r12d
je 0x10aa55
cmpl $0x0, 0x8(%r14)
je 0x10aa33
cmpl %ebp, %edx
je 0x10aa33
cmpl %ebp, %ecx
movl 0x14(%rsp), %ecx
je 0x10a91f
jmp 0x10aa33
movl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %eax
jmp 0x10aa33
cmpl %ebp, %ecx
movl $0x1, %ecx
cmovel %ecx, %eax
jmp 0x10aa33
cmpl %ebp, %ecx
jmp 0x10a8fd