// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/../foreign/miniz-c.h
// 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 0x109c9d
pushq %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 0x109d8b
movq 0x18(%rbx), %rcx
testq %rcx, %rcx
je 0x109d8b
movl 0x20(%rbx), %r9d
testl %r9d, %r9d
je 0x109ca3
cmpl $0x1, %esi
movl $0x2, %ebp
cmovnel %esi, %ebp
cmpl $0x1, 0x84(%rdi)
jne 0x109cad
cmpl $0x4, %ebp
movl $0x1, %ecx
movl $0xfffffffb, %eax       # imm = 0xFFFFFFFB
cmovel %ecx, %eax
jmp 0x109d90
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
retq
movl $0xfffffffb, %eax       # imm = 0xFFFFFFFB
jmp 0x109d90
movq 0x10(%rbx), %rax
movq %rax, 0x18(%rsp)
movq 0x28(%rbx), %rax
movq %rax, 0x20(%rsp)
movl 0x8(%rbx), %r8d
movq (%rbx), %rsi
leaq 0x8(%rsp), %r15
movl %r8d, %eax
movq %rax, 0x10(%rsp)
movl %r9d, %eax
movq %rax, 0x8(%rsp)
leaq 0x10(%rsp), %rdx
movq %r15, %r8
movl %ebp, %r9d
callq 0x109da6
movq 0x10(%rsp), %r11
movl %r11d, %edx
movq (%rbx), %rsi
addq %rdx, %rsi
movq %rsi, (%rbx)
movl 0x8(%rbx), %r12d
movl 0x20(%rbx), %r13d
movl %r12d, %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 0x8(%rsp), %r14
movl %r14d, %r10d
movq 0x18(%rbx), %rcx
addq %r10, %rcx
movq %rcx, 0x18(%rbx)
movl %r13d, %r9d
subl %r14d, %r9d
movl %r9d, 0x20(%rbx)
addq 0x28(%rbx), %r10
movq %r10, 0x28(%rbx)
testl %eax, %eax
js 0x109d8b
cmpl $0x1, %eax
je 0x109d9f
xorl %eax, %eax
cmpl %r14d, %r13d
je 0x109d90
cmpl $0x4, %ebp
sete %r14b
cmpl %r11d, %r12d
setne %r11b
orb %r14b, %r11b
jne 0x109ccb
testl %ebp, %ebp
jne 0x109d90
xorq 0x18(%rsp), %rdx
xorq 0x20(%rsp), %r10
xorl %eax, %eax
orq %rdx, %r10
setne %al
leal (%rax,%rax,4), %eax
addl $-0x5, %eax
jmp 0x109d90
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 0x109d90