// File: /workspace/github_cpp_makefile_star2_O3/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:
testq %rdi, %rdi
je 0x2b567
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %r9d, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, 0x88(%rdi)
movq %rdx, 0x98(%rdi)
movq %rcx, 0x90(%rdi)
movq %r8, 0xa0(%rdi)
movq %rsi, 0xb0(%rdi)
testq %rdx, %rdx
je 0x2b585
movq (%rdx), %rax
jmp 0x2b587
testq %rdx, %rdx
je 0x2b573
movq $0x0, (%rdx)
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
testq %r8, %r8
je 0x2b584
movq $0x0, (%r8)
retq
xorl %eax, %eax
movq %rax, 0xb8(%rbx)
movq $0x0, 0xc0(%rbx)
movl %ebp, 0xa8(%rbx)
movq %rcx, %rax
orq %r8, %rax
setne %al
cmpq $0x0, (%rbx)
sete %sil
xorb %al, %sil
jne 0x2b5d6
cmpl $0x0, 0x84(%rbx)
jne 0x2b5d6
movl 0x80(%rbx), %eax
testl %eax, %eax
setne %sil
cmpl $0x4, %ebp
setne %dil
testb %sil, %dil
je 0x2b608
testq %rdx, %rdx
je 0x2b5e2
movq $0x0, (%rdx)
testq %r8, %r8
je 0x2b5ee
movq $0x0, (%r8)
movl $0xfffffffe, 0x84(%rbx) # imm = 0xFFFFFFFE
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
testq %rdx, %rdx
je 0x2b618
testq %r14, %r14
jne 0x2b618
cmpq $0x0, (%rdx)
jne 0x2b5db
testq %r8, %r8
je 0x2b628
testq %rcx, %rcx
jne 0x2b628
cmpq $0x0, (%r8)
jne 0x2b5d6
xorl %r15d, %r15d
cmpl $0x4, %ebp
sete %r15b
orl %r15d, %eax
movl %eax, 0x80(%rbx)
cmpl $0x0, 0x74(%rbx)
jne 0x2b647
cmpl $0x0, 0x78(%rbx)
je 0x2b657
movq %rbx, %rdi
callq 0x2b6ff
movl %eax, 0x84(%rbx)
jmp 0x2b5fd
movl $0xb4fff, %eax          # imm = 0xB4FFF
andl 0x10(%rbx), %eax
movq %rbx, %rdi
cmpl $0x4001, %eax           # imm = 0x4001
jne 0x2b670
callq 0x2b79e
jmp 0x2b675
callq 0x2bdf6
testl %eax, %eax
je 0x2b6f4
testq %r14, %r14
je 0x2b6a0
movl $0x3000, %eax           # imm = 0x3000
andl 0x10(%rbx), %eax
je 0x2b6a0
movl 0x20(%rbx), %edi
movq 0xb0(%rbx), %rdx
subq %r14, %rdx
movq %r14, %rsi
callq 0x2b3fc
movl %eax, 0x20(%rbx)
testl %ebp, %ebp
je 0x2b647
cmpl $0x0, 0x28(%rbx)
jne 0x2b647
cmpq $0x0, 0xb8(%rbx)
jne 0x2b647
cmpl $0x0, 0x74(%rbx)
jne 0x2b647
movq %rbx, %rdi
movl %ebp, %esi
callq 0x2c811
testl %eax, %eax
js 0x2b6f4
movl %r15d, 0x78(%rbx)
cmpl $0x3, %ebp
jne 0x2b647
leaq 0x192aa(%rbx), %rdi
movl $0x0, 0x2c(%rbx)
movl $0x20000, %edx          # imm = 0x20000
xorl %esi, %esi
callq 0x3170
jmp 0x2b647
movl 0x84(%rbx), %eax
jmp 0x2b5fd