// File: /workspace/github_c_makefile_star2_O3/wkoszek[P]mini_gzip/miniz.c
// Function: mz_inflate
int mz_inflate(mz_streamp pStream, int flush)
{
  inflate_state* pState;
  mz_uint n, first_call, decomp_flags = TINFL_FLAG_COMPUTE_ADLER32;
  size_t in_bytes, out_bytes, orig_avail_in;
  tinfl_status status;

  if ((!pStream) || (!pStream->state)) return MZ_STREAM_ERROR;
  if (flush == MZ_PARTIAL_FLUSH) flush = MZ_SYNC_FLUSH;
  if ((flush) && (flush != MZ_SYNC_FLUSH) && (flush != MZ_FINISH)) return MZ_STREAM_ERROR;

  pState = (inflate_state*)pStream->state;
  if (pState->m_window_bits > 0) decomp_flags |= TINFL_FLAG_PARSE_ZLIB_HEADER;
  orig_avail_in = pStream->avail_in;

  first_call = pState->m_first_call; pState->m_first_call = 0;
  if (pState->m_last_status < 0) return MZ_DATA_ERROR;

  if (pState->m_has_flushed && (flush != MZ_FINISH)) return MZ_STREAM_ERROR;
  pState->m_has_flushed |= (flush == MZ_FINISH);

  if ((flush == MZ_FINISH) && (first_call))
  {
    // MZ_FINISH on the first call implies that the input and output buffers are large enough to hold the entire compressed/decompressed file.
    decomp_flags |= TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF;
    in_bytes = pStream->avail_in; out_bytes = pStream->avail_out;
    status = tinfl_decompress(&pState->m_decomp, pStream->next_in, &in_bytes, pStream->next_out, pStream->next_out, &out_bytes, decomp_flags);
    pState->m_last_status = status;
    pStream->next_in += (mz_uint)in_bytes; pStream->avail_in -= (mz_uint)in_bytes; pStream->total_in += (mz_uint)in_bytes;
    pStream->adler = tinfl_get_adler32(&pState->m_decomp);
    pStream->crc32 = tinfl_get_crc32(&pState->m_decomp);
    pStream->next_out += (mz_uint)out_bytes; pStream->avail_out -= (mz_uint)out_bytes; pStream->total_out += (mz_uint)out_bytes;

    if (status < 0)
      return MZ_DATA_ERROR;
    else if (status != TINFL_STATUS_DONE)
    {
      pState->m_last_status = TINFL_STATUS_FAILED;
      return MZ_BUF_ERROR;
    }
    return MZ_STREAM_END;
  }
  // flush != MZ_FINISH then we must assume there's more input.
  if (flush != MZ_FINISH) decomp_flags |= TINFL_FLAG_HAS_MORE_INPUT;

  if (pState->m_dict_avail)
  {
    n = MZ_MIN(pState->m_dict_avail, pStream->avail_out);
    memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n);
    pStream->next_out += n; pStream->avail_out -= n; pStream->total_out += n;
    pState->m_dict_avail -= n; pState->m_dict_ofs = (pState->m_dict_ofs + n) & (TINFL_LZ_DICT_SIZE - 1);
    return ((pState->m_last_status == TINFL_STATUS_DONE) && (!pState->m_dict_avail)) ? MZ_STREAM_END : MZ_OK;
  }

  for ( ; ; )
  {
    in_bytes = pStream->avail_in;
    out_bytes = TINFL_LZ_DICT_SIZE - pState->m_dict_ofs;

    status = tinfl_decompress(&pState->m_decomp, pStream->next_in, &in_bytes, pState->m_dict, pState->m_dict + pState->m_dict_ofs, &out_bytes, decomp_flags);
    pState->m_last_status = status;

    pStream->next_in += (mz_uint)in_bytes; pStream->avail_in -= (mz_uint)in_bytes;
    pStream->total_in += (mz_uint)in_bytes; pStream->adler = tinfl_get_adler32(&pState->m_decomp); pStream->crc32 = tinfl_get_crc32(&pState->m_decomp);

    pState->m_dict_avail = (mz_uint)out_bytes;

    n = MZ_MIN(pState->m_dict_avail, pStream->avail_out);
    memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n);
    pStream->next_out += n; pStream->avail_out -= n; pStream->total_out += n;
    pState->m_dict_avail -= n; pState->m_dict_ofs = (pState->m_dict_ofs + n) & (TINFL_LZ_DICT_SIZE - 1);

    if (status < 0)
       return MZ_DATA_ERROR; // Stream is corrupted (there could be some uncompressed data left in the output dictionary - oh well).
    else if ((status == TINFL_STATUS_NEEDS_MORE_INPUT) && (!orig_avail_in))
      return MZ_BUF_ERROR; // Signal caller that we can't make forward progress without supplying more input or by setting flush to MZ_FINISH.
    else if (flush == MZ_FINISH)
    {
       // The output buffer MUST be large to hold the remaining uncompressed data when flush==MZ_FINISH.
       if (status == TINFL_STATUS_DONE)
          return pState->m_dict_avail ? MZ_BUF_ERROR : MZ_STREAM_END;
       // status here must be TINFL_STATUS_HAS_MORE_OUTPUT, which means there's at least 1 more byte on the way. If there's no more room left in the output buffer then something is wrong.
       else if (!pStream->avail_out)
          return MZ_BUF_ERROR;
    }
    else if ((status == TINFL_STATUS_DONE) || (!pStream->avail_in) || (!pStream->avail_out) || (pState->m_dict_avail))
      break;
  }

  return ((status == TINFL_STATUS_DONE) && (!pState->m_dict_avail)) ? MZ_STREAM_END : MZ_OK;
}

// Assembly:
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
testq %rdi, %rdi
je 0x24f0
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %r14
movq 0x38(%rdi), %rbx
testq %rbx, %rbx
je 0x24e2
cmpl $0x1, %esi
movl $0x2, %r13d
cmovnel %esi, %r13d
cmpl $0x4, %r13d
ja 0x24e2
movl $0x15, %ecx
btl %r13d, %ecx
jae 0x24e2
xorl %edx, %edx
cmpl $0x0, 0x2b10(%rbx)
setg %dil
movl 0x8(%r14), %r10d
movl 0x2b08(%rbx), %ecx
movl $0x0, 0x2b08(%rbx)
cmpl $0x0, 0xab14(%rbx)
js 0x24dd
cmpl $0x4, %r13d
setne %r8b
movl 0x2b0c(%rbx), %esi
testl %esi, %esi
setne %r9b
testb %r9b, %r8b
jne 0x24e2
movb %dil, %dl
orl $0x8, %edx
xorl %eax, %eax
cmpl $0x4, %r13d
sete %al
orl %eax, %esi
movl %esi, 0x2b0c(%rbx)
cmpl $0x4, %r13d
jne 0x2311
testl %ecx, %ecx
je 0x2311
orl $0x4, %edx
leaq 0x20(%rsp), %r15
movq %r10, (%r15)
movl 0x20(%r14), %eax
leaq 0x18(%rsp), %r12
movq %rax, (%r12)
movq (%r14), %rsi
movq 0x18(%r14), %rcx
movl %edx, (%rsp)
movq %rbx, %rdi
movq %r15, %rdx
movq %rcx, %r8
movq %r12, %r9
callq 0x250d
movl %eax, %ecx
movl %eax, 0xab14(%rbx)
movq (%r15), %rax
movl %eax, %edx
addq %rdx, (%r14)
subl %eax, 0x8(%r14)
addq %rdx, 0x10(%r14)
movsd 0x20(%rbx), %xmm0
xorps %xmm1, %xmm1
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movups %xmm0, 0x60(%r14)
movq (%r12), %rax
movl %eax, %edx
addq %rdx, 0x18(%r14)
subl %eax, 0x20(%r14)
addq %rdx, 0x28(%r14)
movl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
testl %ecx, %ecx
js 0x24e2
je 0x24f1
movl $0xffffffff, 0xab14(%rbx) # imm = 0xFFFFFFFF
movl $0xfffffffb, %eax       # imm = 0xFFFFFFFB
jmp 0x24e2
movl %edx, %r9d
orl $0x2, %r9d
cmpl $0x4, %r13d
cmovel %edx, %r9d
movl 0x2b04(%rbx), %eax
testl %eax, %eax
je 0x239f
movl 0x20(%r14), %r15d
cmpl %r15d, %eax
cmovbl %eax, %r15d
movq 0x18(%r14), %rdi
movl 0x2b00(%rbx), %eax
leaq (%rbx,%rax), %rsi
addq $0x2b14, %rsi           # imm = 0x2B14
movq %r15, %rdx
callq 0x10e0
addq %r15, 0x18(%r14)
subl %r15d, 0x20(%r14)
addq %r15, 0x28(%r14)
movl 0x2b04(%rbx), %ecx
movl %ecx, %eax
subl %r15d, %eax
movl %eax, 0x2b04(%rbx)
movl 0x2b00(%rbx), %eax
addl %r15d, %eax
andl $0x7fff, %eax           # imm = 0x7FFF
movl %eax, 0x2b00(%rbx)
xorl %eax, %eax
cmpl $0x0, 0xab14(%rbx)
jne 0x24e2
xorl %eax, %eax
cmpl %r15d, %ecx
sete %al
jmp 0x24e2
leaq 0x2b14(%rbx), %rax
movq %rax, 0x30(%rsp)
movl 0x2b00(%rbx), %ecx
movl %r10d, %edi
movl %r9d, 0x14(%rsp)
movq %r10, 0x28(%rsp)
movq 0x30(%rsp), %r15
movl %edi, %eax
movq %rax, 0x20(%rsp)
movl $0x8000, %eax           # imm = 0x8000
subl %ecx, %eax
movq %rax, 0x18(%rsp)
movq (%r14), %rsi
movl %ecx, %r8d
addq %r15, %r8
movl %r9d, (%rsp)
movq %rbx, %rdi
leaq 0x20(%rsp), %rdx
movq %r15, %rcx
leaq 0x18(%rsp), %r9
callq 0x250d
movl %eax, %r12d
movl %eax, 0xab14(%rbx)
movq 0x20(%rsp), %rax
movl %eax, %ecx
addq %rcx, (%r14)
subl %eax, 0x8(%r14)
addq %rcx, 0x10(%r14)
movsd 0x20(%rbx), %xmm0
unpcklps 0x69c1(%rip), %xmm0     # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
movups %xmm0, 0x60(%r14)
movl 0x18(%rsp), %ebp
movl %ebp, 0x2b04(%rbx)
movl 0x20(%r14), %eax
cmpl %ebp, %eax
cmovbl %eax, %ebp
movq 0x18(%r14), %rdi
movl 0x2b00(%rbx), %esi
addq %r15, %rsi
movq %rbp, %rdx
callq 0x10e0
addq %rbp, 0x18(%r14)
movl 0x20(%r14), %esi
movl %esi, %eax
subl %ebp, %eax
movl %eax, 0x20(%r14)
addq %rbp, 0x28(%r14)
movl 0x2b04(%rbx), %edx
movl %edx, %eax
subl %ebp, %eax
movl %eax, 0x2b04(%rbx)
movl 0x2b00(%rbx), %ecx
addl %ebp, %ecx
andl $0x7fff, %ecx           # imm = 0x7FFF
movl %ecx, 0x2b00(%rbx)
testl %r12d, %r12d
js 0x24dd
movl %r12d, %edi
xorl $0x1, %edi
movl $0xfffffffb, %eax       # imm = 0xFFFFFFFB
movq 0x28(%rsp), %r10
orl %r10d, %edi
je 0x24e2
cmpl $0x4, %r13d
jne 0x24bb
testl %r12d, %r12d
je 0x24f8
cmpl %ebp, %esi
movl 0x14(%rsp), %r9d
je 0x24e2
movl 0x8(%r14), %edi
jmp 0x23c3
testl %r12d, %r12d
je 0x2504
movl 0x8(%r14), %edi
xorl %eax, %eax
testl %edi, %edi
je 0x24e2
cmpl %ebp, %esi
je 0x24e2
cmpl %ebp, %edx
movl 0x14(%rsp), %r9d
je 0x23c3
jmp 0x24e2
movl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %eax
jmp 0x24e2
cmpl %ebp, %edx
movl $0x1, %ecx
cmovel %ecx, %eax
jmp 0x24e2
xorl %eax, %eax
cmpl %ebp, %edx
jmp 0x2397