// File: /workspace/github_cpp_makefile_star2_O2/jimmiebergmann[P]fbx-file/miniz.c
// 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:
pushq $-0x2
popq %rax
testq %rdi, %rdi
je 0x5398
pushq %rbp
movq %rsp, %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 0x538a
cmpl $0x1, %esi
pushq $0x2
popq %r15
cmovnel %esi, %r15d
cmpl $0x4, %r15d
ja 0x538a
pushq $0x15
popq %rcx
btl %r15d, %ecx
jae 0x538a
xorl %edx, %edx
cmpl $0x0, 0x2b08(%rbx)
setg %dil
movl 0x8(%r14), %r10d
movl 0x2b00(%rbx), %ecx
andl $0x0, 0x2b00(%rbx)
pushq $-0x3
popq %rsi
cmpl $0x0, 0xab0c(%rbx)
js 0x51bc
cmpl $0x4, %r15d
setne %r8b
movl 0x2b04(%rbx), %esi
testl %esi, %esi
setne %r9b
testb %r9b, %r8b
jne 0x538a
movb %dil, %dl
orl $0x8, %edx
xorl %eax, %eax
cmpl $0x4, %r15d
sete %al
orl %eax, %esi
movl %esi, 0x2b04(%rbx)
cmpl $0x4, %r15d
jne 0x51c3
testl %ecx, %ecx
je 0x51c3
orl $0x4, %edx
leaq -0x40(%rbp), %r15
movq %r10, (%r15)
movl 0x20(%r14), %eax
leaq -0x38(%rbp), %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 0x53b1
movl %eax, %ecx
movl %eax, 0xab0c(%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)
pushq $-0x3
popq %rax
testl %ecx, %ecx
js 0x538a
je 0x5383
orl $-0x1, 0xab0c(%rbx)
pushq $-0x5
jmp 0x5389
movl %esi, %eax
jmp 0x538a
movl %edx, %r9d
orl $0x2, %r9d
cmpl $0x4, %r15d
cmovel %edx, %r9d
movl 0x2afc(%rbx), %eax
testl %eax, %eax
je 0x5251
movl 0x20(%r14), %r15d
cmpl %r15d, %eax
cmovbl %eax, %r15d
movq 0x18(%r14), %rdi
movl 0x2af8(%rbx), %eax
leaq (%rbx,%rax), %rsi
addq $0x2b0c, %rsi           # imm = 0x2B0C
movq %r15, %rdx
callq 0x31f0
addq %r15, 0x18(%r14)
subl %r15d, 0x20(%r14)
addq %r15, 0x28(%r14)
movl 0x2afc(%rbx), %ecx
movl %ecx, %eax
subl %r15d, %eax
movl %eax, 0x2afc(%rbx)
movl 0x2af8(%rbx), %eax
addl %r15d, %eax
andl $0x7fff, %eax           # imm = 0x7FFF
movl %eax, 0x2af8(%rbx)
xorl %eax, %eax
cmpl $0x0, 0xab0c(%rbx)
jne 0x538a
xorl %eax, %eax
cmpl %r15d, %ecx
sete %al
jmp 0x538a
leaq 0x2b0c(%rbx), %rax
movq %rax, -0x48(%rbp)
movl 0x2af8(%rbx), %ecx
movl %r10d, %edi
movq %r10, -0x50(%rbp)
movl %r9d, -0x2c(%rbp)
movl %edi, %eax
movq %rax, -0x40(%rbp)
movl $0x8000, %eax           # imm = 0x8000
subl %ecx, %eax
movq %rax, -0x38(%rbp)
movq (%r14), %rsi
movl %ecx, %r8d
movq -0x48(%rbp), %rcx
addq %rcx, %r8
movl %r9d, (%rsp)
movq %rbx, %rdi
leaq -0x40(%rbp), %rdx
leaq -0x38(%rbp), %r9
callq 0x53b1
movl %eax, %r13d
movl %eax, 0xab0c(%rbx)
movq -0x40(%rbp), %rax
movl %eax, %ecx
addq %rcx, (%r14)
subl %eax, 0x8(%r14)
addq %rcx, 0x10(%r14)
movl 0x1c(%rbx), %eax
movq %rax, 0x60(%r14)
movl -0x38(%rbp), %r12d
movl %r12d, 0x2afc(%rbx)
movl 0x20(%r14), %eax
cmpl %r12d, %eax
cmovbl %eax, %r12d
movq 0x18(%r14), %rdi
movl 0x2af8(%rbx), %esi
addq -0x48(%rbp), %rsi
movq %r12, %rdx
callq 0x31f0
addq %r12, 0x18(%r14)
movl 0x20(%r14), %esi
movl %esi, %eax
subl %r12d, %eax
movl %eax, 0x20(%r14)
addq %r12, 0x28(%r14)
movl 0x2afc(%rbx), %edx
movl %edx, %eax
subl %r12d, %eax
movl %eax, 0x2afc(%rbx)
movl 0x2af8(%rbx), %ecx
addl %r12d, %ecx
andl $0x7fff, %ecx           # imm = 0x7FFF
movl %ecx, 0x2af8(%rbx)
testl %r13d, %r13d
js 0x5387
movl %r13d, %eax
xorl $0x1, %eax
movq -0x50(%rbp), %r10
orl %r10d, %eax
je 0x51b5
cmpl $0x4, %r15d
jne 0x5360
testl %r13d, %r13d
je 0x5399
cmpl %r12d, %esi
je 0x51b5
movl 0x8(%r14), %edi
movl -0x2c(%rbp), %r9d
jmp 0x526d
testl %r13d, %r13d
je 0x53a7
movl 0x8(%r14), %edi
xorl %eax, %eax
testl %edi, %edi
je 0x538a
cmpl %r12d, %esi
je 0x538a
cmpl %r12d, %edx
movl -0x2c(%rbp), %r9d
je 0x526d
jmp 0x538a
pushq $0x1
jmp 0x5389
pushq $-0x3
popq %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl %r12d, %edx
pushq $0x1
popq %rcx
pushq $-0x5
popq %rax
cmovel %ecx, %eax
jmp 0x538a
xorl %eax, %eax
cmpl %r12d, %edx
jmp 0x5249