// File: /workspace/github_cpp_makefile_star2_O1/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 %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl $0xfffffffe, %ebx       # imm = 0xFFFFFFFE
testq %rdi, %rdi
je 0x3c85
movq %rdi, %r14
movq 0x38(%rdi), %rax
testq %rax, %rax
sete %cl
cmpl $0x5, %esi
setae %dl
orb %cl, %dl
jne 0x3c85
cmpq $0x0, 0x18(%r14)
je 0x3c85
movl $0xfffffffb, %ebx       # imm = 0xFFFFFFFB
cmpl $0x0, 0x20(%r14)
je 0x3c85
cmpl $0x1, %esi
movl $0x2, %r15d
cmovnel %esi, %r15d
cmpl $0x1, 0x84(%rax)
jne 0x3b93
cmpl $0x4, %r15d
movl $0x1, %eax
cmovel %eax, %ebx
jmp 0x3c85
movq 0x10(%r14), %rax
movq %rax, -0x48(%rbp)
movq 0x28(%r14), %rax
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %r12
leaq -0x30(%rbp), %r13
xorl %ebx, %ebx
movl 0x8(%r14), %eax
movq %rax, -0x38(%rbp)
movl 0x20(%r14), %eax
movq %rax, -0x30(%rbp)
movq 0x38(%r14), %rdi
movq (%r14), %rsi
movq 0x18(%r14), %rcx
movq %r12, %rdx
movq %r13, %r8
movl %r15d, %r9d
callq 0x3c96
movq -0x38(%rbp), %rdi
movl %edi, %ecx
addq %rcx, (%r14)
movl 0x8(%r14), %r8d
movl 0x20(%r14), %r9d
movl %r8d, %edx
subl %edi, %edx
movl %edx, 0x8(%r14)
addq 0x10(%r14), %rcx
movq %rcx, 0x10(%r14)
movq 0x38(%r14), %rdx
movl 0x20(%rdx), %edx
movq %rdx, 0x60(%r14)
movq -0x30(%rbp), %r10
movl %r10d, %esi
addq %rsi, 0x18(%r14)
movl %r9d, %edx
subl %r10d, %edx
movl %edx, 0x20(%r14)
addq 0x28(%r14), %rsi
movq %rsi, 0x28(%r14)
movl $0x2, %edx
testl %eax, %eax
js 0x3c35
cmpl $0x1, %eax
jne 0x3c3c
movl $0x1, %ebx
jmp 0x3c73
movl $0xfffffffe, %ebx       # imm = 0xFFFFFFFE
jmp 0x3c73
cmpl %r10d, %r9d
je 0x3c73
movl %r8d, %eax
xorl %edi, %eax
xorl %edx, %edx
cmpl %edi, %r8d
sete %dl
addl %edx, %edx
cmpl $0x4, %r15d
movl $0x0, %edi
cmovel %edi, %edx
orl %r15d, %eax
jne 0x3c73
xorq -0x48(%rbp), %rcx
xorq -0x40(%rbp), %rsi
xorl %edx, %edx
orq %rcx, %rsi
setne %dl
incl %edx
testl %edx, %edx
je 0x3bad
cmpl $0x2, %edx
je 0x3c85
movl $0xfffffffb, %ebx       # imm = 0xFFFFFFFB
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq