// File: /workspace/github_cpp_makefile_star2_O3/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:
testq %rdi, %rdi
je 0x3b8c
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 0x3c6f
movq 0x18(%rbx), %rcx
testq %rcx, %rcx
je 0x3c6f
movl 0x20(%rbx), %r9d
testl %r9d, %r9d
je 0x3b92
cmpl $0x1, %esi
movl $0x2, %r14d
cmovnel %esi, %r14d
cmpl $0x1, 0x84(%rdi)
jne 0x3b9c
cmpl $0x4, %r14d
movl $0x1, %ecx
movl $0xfffffffb, %eax       # imm = 0xFFFFFFFB
cmovel %ecx, %eax
jmp 0x3c74
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
retq
movl $0xfffffffb, %eax       # imm = 0xFFFFFFFB
jmp 0x3c74
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 0x3c8a
movq -0x38(%rbp), %r11
movl %r11d, %edx
movq (%rbx), %rsi
addq %rdx, %rsi
movq %rsi, (%rbx)
movl 0x8(%rbx), %r13d
movl 0x20(%rbx), %r15d
movl %r13d, %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), %r12
movl %r12d, %r10d
movq 0x18(%rbx), %rcx
addq %r10, %rcx
movq %rcx, 0x18(%rbx)
movl %r15d, %r9d
subl %r12d, %r9d
movl %r9d, 0x20(%rbx)
addq 0x28(%rbx), %r10
movq %r10, 0x28(%rbx)
testl %eax, %eax
js 0x3c6f
cmpl $0x1, %eax
je 0x3c83
xorl %eax, %eax
cmpl %r12d, %r15d
je 0x3c74
cmpl $0x4, %r14d
sete %r15b
cmpl %r11d, %r13d
setne %r11b
orb %r15b, %r11b
jne 0x3bb3
testl %r14d, %r14d
jne 0x3c74
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 0x3c74
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %eax
jmp 0x3c74