// File: Alcaro[P]bridges/arlib/deps/miniz.c
// Function: tdefl_compress
tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, size_t *pIn_buf_size, void *pOut_buf, size_t *pOut_buf_size, tdefl_flush flush)
{
  if (!d)
  {
    if (pIn_buf_size) *pIn_buf_size = 0;
    if (pOut_buf_size) *pOut_buf_size = 0;
    return TDEFL_STATUS_BAD_PARAM;
  }

  d->m_pIn_buf = pIn_buf; d->m_pIn_buf_size = pIn_buf_size;
  d->m_pOut_buf = pOut_buf; d->m_pOut_buf_size = pOut_buf_size;
  d->m_pSrc = (const mz_uint8 *)(pIn_buf); d->m_src_buf_left = pIn_buf_size ? *pIn_buf_size : 0;
  d->m_out_buf_ofs = 0;
  d->m_flush = flush;

  if ( ((d->m_pPut_buf_func != NULL) == ((pOut_buf != NULL) || (pOut_buf_size != NULL))) || (d->m_prev_return_status != TDEFL_STATUS_OKAY) ||
        (d->m_wants_to_finish && (flush != TDEFL_FINISH)) || (pIn_buf_size && *pIn_buf_size && !pIn_buf) || (pOut_buf_size && *pOut_buf_size && !pOut_buf) )
  {
    if (pIn_buf_size) *pIn_buf_size = 0;
    if (pOut_buf_size) *pOut_buf_size = 0;
    return (d->m_prev_return_status = TDEFL_STATUS_BAD_PARAM);
  }
  d->m_wants_to_finish |= (flush == TDEFL_FINISH);

  if ((d->m_output_flush_remaining) || (d->m_finished))
    return (d->m_prev_return_status = tdefl_flush_output_buffer(d));

#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN
  if (((d->m_flags & TDEFL_MAX_PROBES_MASK) == 1) &&
      ((d->m_flags & TDEFL_GREEDY_PARSING_FLAG) != 0) &&
      ((d->m_flags & (TDEFL_FILTER_MATCHES | TDEFL_FORCE_ALL_RAW_BLOCKS | TDEFL_RLE_MATCHES)) == 0))
  {
    if (!tdefl_compress_fast(d))
      return d->m_prev_return_status;
  }
  else
#endif // #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN
  {
    if (!tdefl_compress_normal(d))
      return d->m_prev_return_status;
  }

  if ((d->m_flags & (TDEFL_WRITE_ZLIB_HEADER | TDEFL_COMPUTE_ADLER32)) && (pIn_buf))
    d->m_adler32 = (mz_uint32)mz_adler32(d->m_adler32, (const mz_uint8 *)pIn_buf, d->m_pSrc - (const mz_uint8 *)pIn_buf);

  if ((flush) && (!d->m_lookahead_size) && (!d->m_src_buf_left) && (!d->m_output_flush_remaining))
  {
    if (tdefl_flush_block(d, flush) < 0)
      return d->m_prev_return_status;
    d->m_finished = (flush == TDEFL_FINISH);
    if (flush == TDEFL_FULL_FLUSH) { MZ_CLEAR_OBJ(d->m_hash); MZ_CLEAR_OBJ(d->m_next); d->m_dict_size = 0; }
  }

  return (d->m_prev_return_status = tdefl_flush_output_buffer(d));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl %r9d, -0x34(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x5c727
cmpq $0x0, -0x20(%rbp)
je 0x5c709
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
cmpq $0x0, -0x30(%rbp)
je 0x5c71b
movq -0x30(%rbp), %rax
movq $0x0, (%rax)
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x5ca42
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x88(%rax)
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x98(%rax)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x90(%rax)
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xa0(%rax)
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xb0(%rax)
cmpq $0x0, -0x20(%rbp)
je 0x5c786
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x5c78e
xorl %eax, %eax
movq %rax, -0x40(%rbp)
jmp 0x5c78e
movq -0x40(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xb8(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0xc0(%rax)
movl -0x34(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xa8(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x48(%rbp)
movb $0x1, %al
cmpq $0x0, -0x28(%rbp)
movb %al, -0x41(%rbp)
jne 0x5c7e3
cmpq $0x0, -0x30(%rbp)
setne %al
movb %al, -0x41(%rbp)
movl -0x48(%rbp), %eax
movb -0x41(%rbp), %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
je 0x5c843
movq -0x10(%rbp), %rax
cmpl $0x0, 0x84(%rax)
jne 0x5c843
movq -0x10(%rbp), %rax
cmpl $0x0, 0x80(%rax)
je 0x5c813
cmpl $0x4, -0x34(%rbp)
jne 0x5c843
cmpq $0x0, -0x20(%rbp)
je 0x5c82b
movq -0x20(%rbp), %rax
cmpq $0x0, (%rax)
je 0x5c82b
cmpq $0x0, -0x18(%rbp)
je 0x5c843
cmpq $0x0, -0x30(%rbp)
je 0x5c881
movq -0x30(%rbp), %rax
cmpq $0x0, (%rax)
je 0x5c881
cmpq $0x0, -0x28(%rbp)
jne 0x5c881
cmpq $0x0, -0x20(%rbp)
je 0x5c855
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
cmpq $0x0, -0x30(%rbp)
je 0x5c867
movq -0x30(%rbp), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rax
movl $0xfffffffe, 0x84(%rax) # imm = 0xFFFFFFFE
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x5ca42
cmpl $0x4, -0x34(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %ecx
movq -0x10(%rbp), %rax
orl 0x80(%rax), %ecx
movl %ecx, 0x80(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x74(%rax)
jne 0x5c8b1
movq -0x10(%rbp), %rax
cmpl $0x0, 0x78(%rax)
je 0x5c8cc
movq -0x10(%rbp), %rdi
callq 0x5ca50
movq -0x10(%rbp), %rcx
movl %eax, 0x84(%rcx)
movl %eax, -0x4(%rbp)
jmp 0x5ca42
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
andl $0xfff, %eax            # imm = 0xFFF
cmpl $0x1, %eax
jne 0x5c921
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
je 0x5c921
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
andl $0xb0000, %eax          # imm = 0xB0000
cmpl $0x0, %eax
jne 0x5c921
movq -0x10(%rbp), %rdi
callq 0x5cbc0
cmpl $0x0, %eax
jne 0x5c91f
movq -0x10(%rbp), %rax
movl 0x84(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x5ca42
jmp 0x5c943
movq -0x10(%rbp), %rdi
callq 0x5d600
cmpl $0x0, %eax
jne 0x5c941
movq -0x10(%rbp), %rax
movl 0x84(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x5ca42
jmp 0x5c943
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x3000, %eax           # imm = 0x3000
cmpl $0x0, %eax
je 0x5c988
cmpq $0x0, -0x18(%rbp)
je 0x5c988
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, %edi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0xb0(%rax), %rdx
movq -0x18(%rbp), %rax
subq %rax, %rdx
callq 0x5c4e0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x20(%rax)
cmpl $0x0, -0x34(%rbp)
je 0x5ca2c
movq -0x10(%rbp), %rax
cmpl $0x0, 0x28(%rax)
jne 0x5ca2c
movq -0x10(%rbp), %rax
cmpq $0x0, 0xb8(%rax)
jne 0x5ca2c
movq -0x10(%rbp), %rax
cmpl $0x0, 0x74(%rax)
jne 0x5ca2c
movq -0x10(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x5ec60
cmpl $0x0, %eax
jge 0x5c9d8
movq -0x10(%rbp), %rax
movl 0x84(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x5ca42
cmpl $0x4, -0x34(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x78(%rax)
cmpl $0x3, -0x34(%rbp)
jne 0x5ca2a
movq -0x10(%rbp), %rdi
addq $0x292aa, %rdi          # imm = 0x292AA
xorl %esi, %esi
movl $0x10000, %edx          # imm = 0x10000
callq 0x4170
movq -0x10(%rbp), %rdi
addq $0x192aa, %rdi          # imm = 0x192AA
xorl %esi, %esi
movl $0x10000, %edx          # imm = 0x10000
callq 0x4170
movq -0x10(%rbp), %rax
movl $0x0, 0x2c(%rax)
jmp 0x5ca2c
movq -0x10(%rbp), %rdi
callq 0x5ca50
movq -0x10(%rbp), %rcx
movl %eax, 0x84(%rcx)
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)