// File: /workspace/github_cpp_makefile_star2_O1/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:
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
testq %rdi, %rdi
je 0x4408
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 0x43fa
cmpl $0x1, %esi
movl $0x2, %r15d
cmovnel %esi, %r15d
cmpl $0x4, %r15d
ja 0x43fa
movl $0x15, %ecx
btl %r15d, %ecx
jae 0x43fa
xorl %edx, %edx
cmpl $0x0, 0x2b08(%rbx)
setg %dil
movl 0x8(%r14), %r10d
movl 0x2b00(%rbx), %ecx
movl $0x0, 0x2b00(%rbx)
cmpl $0x0, 0xab0c(%rbx)
js 0x43f5
cmpl $0x4, %r15d
setne %r8b
movl 0x2b04(%rbx), %esi
testl %esi, %esi
setne %r9b
testb %r9b, %r8b
jne 0x43fa
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 0x4246
testl %ecx, %ecx
je 0x4246
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 0x4425
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)
movl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
testl %ecx, %ecx
js 0x43fa
je 0x4409
movl $0xffffffff, 0xab0c(%rbx) # imm = 0xFFFFFFFF
movl $0xfffffffb, %eax       # imm = 0xFFFFFFFB
jmp 0x43fa
movl %edx, %edi
orl $0x2, %edi
cmpl $0x4, %r15d
cmovel %edx, %edi
movl 0x2afc(%rbx), %eax
testl %eax, %eax
je 0x42d1
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 0x31e0
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 0x43fa
xorl %eax, %eax
cmpl %r15d, %ecx
sete %al
jmp 0x43fa
leaq 0x2b0c(%rbx), %rax
movq %rax, -0x48(%rbp)
movq %r10, -0x50(%rbp)
movl %edi, -0x2c(%rbp)
movl 0x8(%r14), %eax
movq %rax, -0x40(%rbp)
movl 0x2af8(%rbx), %r8d
movl $0x8000, %eax           # imm = 0x8000
subl %r8d, %eax
movq %rax, -0x38(%rbp)
movq (%r14), %rsi
movq -0x48(%rbp), %rcx
addq %rcx, %r8
movl %edi, (%rsp)
movq %rbx, %rdi
leaq -0x40(%rbp), %rdx
leaq -0x38(%rbp), %r9
callq 0x4425
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 0x31e0
addq %r12, 0x18(%r14)
movl 0x20(%r14), %edx
movl %edx, %eax
subl %r12d, %eax
movl %eax, 0x20(%r14)
addq %r12, 0x28(%r14)
movl 0x2afc(%rbx), %ecx
movl %ecx, %eax
subl %r12d, %eax
movl %eax, 0x2afc(%rbx)
movl 0x2af8(%rbx), %eax
addl %r12d, %eax
andl $0x7fff, %eax           # imm = 0x7FFF
movl %eax, 0x2af8(%rbx)
testl %r13d, %r13d
js 0x43f5
movl %r13d, %esi
xorl $0x1, %esi
movl $0xfffffffb, %eax       # imm = 0xFFFFFFFB
movq -0x50(%rbp), %r10
orl %r10d, %esi
je 0x43fa
cmpl $0x4, %r15d
jne 0x43d4
testl %r13d, %r13d
je 0x4410
cmpl %r12d, %edx
movl -0x2c(%rbp), %edi
jne 0x42e3
jmp 0x43fa
xorl %eax, %eax
testl %r13d, %r13d
je 0x441d
cmpl $0x0, 0x8(%r14)
je 0x43fa
cmpl %r12d, %edx
je 0x43fa
cmpl %r12d, %ecx
movl -0x2c(%rbp), %edi
je 0x42e3
jmp 0x43fa
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 0x43fa
cmpl %r12d, %ecx
movl $0x1, %ecx
cmovel %ecx, %eax
jmp 0x43fa
cmpl %r12d, %ecx
jmp 0x42c9