// File: /workspace/github_cpp_makefile_star2_O2/jimmiebergmann[P]fbx-file/miniz.c
// Function: mz_deflate
int mz_deflate(mz_streamp pStream, int flush)
{
    size_t in_bytes, out_bytes;
    mz_ulong orig_total_in, orig_total_out;
    int mz_status = MZ_OK;

    if ((!pStream) || (!pStream->state) || (flush < 0) || (flush > MZ_FINISH) || (!pStream->next_out))
        return MZ_STREAM_ERROR;
    if (!pStream->avail_out)
        return MZ_BUF_ERROR;

    if (flush == MZ_PARTIAL_FLUSH)
        flush = MZ_SYNC_FLUSH;

    if (((tdefl_compressor *)pStream->state)->m_prev_return_status == TDEFL_STATUS_DONE)
        return (flush == MZ_FINISH) ? MZ_STREAM_END : MZ_BUF_ERROR;

    orig_total_in = pStream->total_in;
    orig_total_out = pStream->total_out;
    for (;;)
    {
        tdefl_status defl_status;
        in_bytes = pStream->avail_in;
        out_bytes = pStream->avail_out;

        defl_status = tdefl_compress((tdefl_compressor *)pStream->state, pStream->next_in, &in_bytes, pStream->next_out, &out_bytes, (tdefl_flush)flush);
        pStream->next_in += (mz_uint)in_bytes;
        pStream->avail_in -= (mz_uint)in_bytes;
        pStream->total_in += (mz_uint)in_bytes;
        pStream->adler = tdefl_get_adler32((tdefl_compressor *)pStream->state);

        pStream->next_out += (mz_uint)out_bytes;
        pStream->avail_out -= (mz_uint)out_bytes;
        pStream->total_out += (mz_uint)out_bytes;

        if (defl_status < 0)
        {
            mz_status = MZ_STREAM_ERROR;
            break;
        }
        else if (defl_status == TDEFL_STATUS_DONE)
        {
            mz_status = MZ_STREAM_END;
            break;
        }
        else if (!pStream->avail_out)
            break;
        else if ((!pStream->avail_in) && (flush != MZ_FINISH))
        {
            if ((flush) || (pStream->total_in != orig_total_in) || (pStream->total_out != orig_total_out))
                break;
            return MZ_BUF_ERROR; /* Can't make forward progress without some input.
 */
        }
    }
    return mz_status;
}

// Assembly:
pushq $-0x2
popq %rdx
testq %rdi, %rdi
je 0x3b41
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq 0x38(%rdi), %rdi
testq %rdi, %rdi
sete %al
cmpl $0x5, %esi
setae %cl
orb %al, %cl
jne 0x3b30
movq 0x18(%rbx), %rcx
testq %rcx, %rcx
je 0x3b30
movl 0x20(%rbx), %r9d
testl %r9d, %r9d
je 0x3b44
cmpl $0x1, %esi
pushq $0x2
popq %r14
cmovnel %esi, %r14d
cmpl $0x1, 0x84(%rdi)
jne 0x3b49
cmpl $0x4, %r14d
pushq $0x1
popq %rcx
pushq $-0x5
popq %rax
cmovel %ecx, %eax
jmp 0x3b32
movl %edx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %edx, %eax
retq
pushq $-0x5
popq %rax
jmp 0x3b32
movq 0x10(%rbx), %rax
movq %rax, -0x40(%rbp)
movq 0x28(%rbx), %rax
movq %rax, -0x48(%rbp)
movl 0x8(%rbx), %r8d
movq (%rbx), %rsi
movl %r8d, %eax
movq %rax, -0x38(%rbp)
movl %r9d, %eax
movq %rax, -0x30(%rbp)
leaq -0x38(%rbp), %rdx
leaq -0x30(%rbp), %r8
movl %r14d, %r9d
callq 0x3c35
movq -0x38(%rbp), %r11
movl %r11d, %edx
movq (%rbx), %rsi
addq %rdx, %rsi
movq %rsi, (%rbx)
movl 0x8(%rbx), %r15d
movl 0x20(%rbx), %r12d
movl %r15d, %r8d
subl %r11d, %r8d
movl %r8d, 0x8(%rbx)
addq 0x10(%rbx), %rdx
movq %rdx, 0x10(%rbx)
movq 0x38(%rbx), %rdi
movl 0x20(%rdi), %ecx
movq %rcx, 0x60(%rbx)
movq -0x30(%rbp), %r13
movl %r13d, %r10d
movq 0x18(%rbx), %rcx
addq %r10, %rcx
movq %rcx, 0x18(%rbx)
movl %r12d, %r9d
subl %r13d, %r9d
movl %r9d, 0x20(%rbx)
addq 0x28(%rbx), %r10
movq %r10, 0x28(%rbx)
testl %eax, %eax
js 0x3c27
cmpl $0x1, %eax
je 0x3c2e
xorl %eax, %eax
cmpl %r13d, %r12d
je 0x3b32
cmpl $0x4, %r14d
sete %r12b
cmpl %r11d, %r15d
setne %r11b
orb %r12b, %r11b
jne 0x3b60
testl %r14d, %r14d
jne 0x3b32
xorq -0x40(%rbp), %rdx
xorq -0x48(%rbp), %r10
xorl %eax, %eax
orq %rdx, %r10
setne %al
leal (%rax,%rax,4), %eax
addl $-0x5, %eax
jmp 0x3b32
pushq $-0x2
jmp 0x3b46
pushq $0x1
jmp 0x3b46