// File: 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
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl $0x0, -0x3c(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x417f
movq -0x10(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x417f
cmpl $0x0, -0x14(%rbp)
jl 0x417f
cmpl $0x4, -0x14(%rbp)
jg 0x417f
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x418b
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x433c
movq -0x10(%rbp), %rax
cmpl $0x0, 0x20(%rax)
jne 0x41a1
movl $0xfffffffb, -0x4(%rbp) # imm = 0xFFFFFFFB
jmp 0x433c
cmpl $0x1, -0x14(%rbp)
jne 0x41ae
movl $0x2, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
cmpl $0x1, 0x84(%rax)
jne 0x41da
movl -0x14(%rbp), %edx
movl $0xfffffffb, %eax       # imm = 0xFFFFFFFB
movl $0x1, %ecx
cmpl $0x4, %edx
cmovel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0x433c
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rcx
movl -0x14(%rbp), %r9d
leaq -0x20(%rbp), %rdx
leaq -0x28(%rbp), %r8
callq 0x4350
movl %eax, -0x40(%rbp)
movq -0x20(%rbp), %rax
movl %eax, %edx
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movl %edx, %edx
addq %rdx, %rcx
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movl %eax, %edx
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x8(%rax)
movq -0x20(%rbp), %rax
movl %eax, %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
addq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0x46d0
movl %eax, %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x28(%rbp), %rax
movl %eax, %edx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rcx
movl %edx, %edx
addq %rdx, %rcx
movq %rcx, 0x18(%rax)
movq -0x28(%rbp), %rax
movl %eax, %edx
movq -0x10(%rbp), %rax
movl 0x20(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x20(%rax)
movq -0x28(%rbp), %rax
movl %eax, %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
addq 0x28(%rax), %rcx
movq %rcx, 0x28(%rax)
cmpl $0x0, -0x40(%rbp)
jge 0x42d3
movl $0xfffffffe, -0x3c(%rbp) # imm = 0xFFFFFFFE
jmp 0x4336
cmpl $0x1, -0x40(%rbp)
jne 0x42e2
movl $0x1, -0x3c(%rbp)
jmp 0x4336
movq -0x10(%rbp), %rax
cmpl $0x0, 0x20(%rax)
jne 0x42ee
jmp 0x4336
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x432b
cmpl $0x4, -0x14(%rbp)
je 0x432b
cmpl $0x0, -0x14(%rbp)
jne 0x4320
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
cmpq -0x30(%rbp), %rax
jne 0x4320
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
cmpq -0x38(%rbp), %rax
je 0x4322
jmp 0x4336
movl $0xfffffffb, -0x4(%rbp) # imm = 0xFFFFFFFB
jmp 0x433c
jmp 0x432d
jmp 0x432f
jmp 0x4331
jmp 0x41f2
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)