// File: /workspace/github_c_makefile_star2_O1/wkoszek[P]mini_gzip/miniz.c
// Function: tdefl_flush_block
static int tdefl_flush_block(tdefl_compressor *d, int flush)
{
  mz_uint saved_bit_buf, saved_bits_in;
  mz_uint8 *pSaved_output_buf;
  mz_bool comp_block_succeeded = MZ_FALSE;
  int n, use_raw_block = ((d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS) != 0) && (d->m_lookahead_pos - d->m_lz_code_buf_dict_pos) <= d->m_dict_size;
  mz_uint8 *pOutput_buf_start = ((d->m_pPut_buf_func == NULL) && ((*d->m_pOut_buf_size - d->m_out_buf_ofs) >= TDEFL_OUT_BUF_SIZE)) ? ((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs) : d->m_output_buf;

  d->m_pOutput_buf = pOutput_buf_start;
  d->m_pOutput_buf_end = d->m_pOutput_buf + TDEFL_OUT_BUF_SIZE - 16;

  MZ_ASSERT(!d->m_output_flush_remaining);
  d->m_output_flush_ofs = 0;
  d->m_output_flush_remaining = 0;

  *d->m_pLZ_flags = (mz_uint8)(*d->m_pLZ_flags >> d->m_num_flags_left);
  d->m_pLZ_code_buf -= (d->m_num_flags_left == 8);

  if ((d->m_flags & TDEFL_WRITE_ZLIB_HEADER) && (!d->m_block_index))
  {
    TDEFL_PUT_BITS(0x78, 8); TDEFL_PUT_BITS(0x01, 8);
  }

  TDEFL_PUT_BITS(flush == TDEFL_FINISH, 1);

  pSaved_output_buf = d->m_pOutput_buf; saved_bit_buf = d->m_bit_buffer; saved_bits_in = d->m_bits_in;

  if (!use_raw_block)
    comp_block_succeeded = tdefl_compress_block(d, (d->m_flags & TDEFL_FORCE_ALL_STATIC_BLOCKS) || (d->m_total_lz_bytes < 48));

  // If the block gets expanded, forget the current contents of the output buffer and send a raw block instead.
  if ( ((use_raw_block) || ((d->m_total_lz_bytes) && ((d->m_pOutput_buf - pSaved_output_buf + 1U) >= d->m_total_lz_bytes))) &&
       ((d->m_lookahead_pos - d->m_lz_code_buf_dict_pos) <= d->m_dict_size) )
  {
    mz_uint i; d->m_pOutput_buf = pSaved_output_buf; d->m_bit_buffer = saved_bit_buf, d->m_bits_in = saved_bits_in;
    TDEFL_PUT_BITS(0, 2);
    if (d->m_bits_in) { TDEFL_PUT_BITS(0, 8 - d->m_bits_in); }
    for (i = 2; i; --i, d->m_total_lz_bytes ^= 0xFFFF)
    {
      TDEFL_PUT_BITS(d->m_total_lz_bytes & 0xFFFF, 16);
    }
    for (i = 0; i < d->m_total_lz_bytes; ++i)
    {
      TDEFL_PUT_BITS(d->m_dict[(d->m_lz_code_buf_dict_pos + i) & TDEFL_LZ_DICT_SIZE_MASK], 8);
    }
  }
  // Check for the extremely unlikely (if not impossible) case of the compressed block not fitting into the output buffer when using dynamic codes.
  else if (!comp_block_succeeded)
  {
    d->m_pOutput_buf = pSaved_output_buf; d->m_bit_buffer = saved_bit_buf, d->m_bits_in = saved_bits_in;
    tdefl_compress_block(d, MZ_TRUE);
  }

  if (flush)
  {
    if (flush == TDEFL_FINISH)
    {
      if (d->m_bits_in) { TDEFL_PUT_BITS(0, 8 - d->m_bits_in); }
      if (d->m_flags & TDEFL_WRITE_ZLIB_HEADER) { mz_uint i, a = d->m_adler32; for (i = 0; i < 4; i++) { TDEFL_PUT_BITS((a >> 24) & 0xFF, 8); a <<= 8; } }
    }
    else
    {
      mz_uint i, z = 0; TDEFL_PUT_BITS(0, 3); if (d->m_bits_in) { TDEFL_PUT_BITS(0, 8 - d->m_bits_in); } for (i = 2; i; --i, z ^= 0xFFFF) { TDEFL_PUT_BITS(z & 0xFFFF, 16); }
    }
  }

  MZ_ASSERT(d->m_pOutput_buf < d->m_pOutput_buf_end);

  memset(&d->m_huff_count[0][0], 0, sizeof(d->m_huff_count[0][0]) * TDEFL_MAX_HUFF_SYMBOLS_0);
  memset(&d->m_huff_count[1][0], 0, sizeof(d->m_huff_count[1][0]) * TDEFL_MAX_HUFF_SYMBOLS_1);

  d->m_pLZ_code_buf = d->m_lz_code_buf + 1; d->m_pLZ_flags = d->m_lz_code_buf; d->m_num_flags_left = 8; d->m_lz_code_buf_dict_pos += d->m_total_lz_bytes; d->m_total_lz_bytes = 0; d->m_block_index++;

  if ((n = (int)(d->m_pOutput_buf - pOutput_buf_start)) != 0)
  {
    if (d->m_pPut_buf_func)
    {
      *d->m_pIn_buf_size = d->m_pSrc - (const mz_uint8 *)d->m_pIn_buf;
      if (!(*d->m_pPut_buf_func)(d->m_output_buf, n, d->m_pPut_buf_user))
        return (d->m_prev_return_status = TDEFL_STATUS_PUT_BUF_FAILED);
    }
    else if (pOutput_buf_start == d->m_output_buf) 
    {
      int bytes_to_copy = (int)MZ_MIN((size_t)n, (size_t)(*d->m_pOut_buf_size - d->m_out_buf_ofs));
      memcpy((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs, d->m_output_buf, bytes_to_copy);
      d->m_out_buf_ofs += bytes_to_copy;
      if ((n -= bytes_to_copy) != 0)
      {
        d->m_output_flush_ofs = bytes_to_copy;
        d->m_output_flush_remaining = n;
      }
    }
    else
    {
      d->m_out_buf_ofs += n;
    }
  }

  return d->m_output_flush_remaining;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
testb $0x10, 0x12(%rdi)
jne 0x543b
xorl %r12d, %r12d
jmp 0x5448
movl 0x28(%rbx), %eax
subl 0x60(%rbx), %eax
cmpl 0x30(%rbx), %eax
setbe %r12b
cmpq $0x0, (%rbx)
jne 0x5473
movq 0xa8(%rbx), %rax
movq 0xc8(%rbx), %rsi
movq (%rax), %rax
subq %rsi, %rax
cmpq $0x14ccc, %rax          # imm = 0x14CCC
jb 0x5473
addq 0x98(%rbx), %rsi
jmp 0x547a
leaq 0x392b2(%rbx), %rsi
movq %rsi, 0x48(%rbx)
leaq 0x14cbc(%rsi), %rax
movq %rax, 0x50(%rbx)
cmpl $0x0, 0x7c(%rbx)
jne 0x5997
movq $0x0, 0x78(%rbx)
movq 0x40(%rbx), %rax
movzbl (%rax), %edx
movb 0x58(%rbx), %cl
shrl %cl, %edx
movb %dl, (%rax)
xorl %eax, %eax
cmpl $0x8, 0x58(%rbx)
sete %al
subq %rax, 0x38(%rbx)
testb $0x10, 0x11(%rbx)
je 0x5540
cmpl $0x0, 0x84(%rbx)
jne 0x5540
movl 0x64(%rbx), %ecx
movl $0x78, %eax
shll %cl, %eax
orl %eax, 0x68(%rbx)
subl $-0x8, %ecx
movl %ecx, 0x64(%rbx)
jae 0x5507
movq 0x48(%rbx), %rax
cmpq 0x50(%rbx), %rax
jae 0x54f5
movb 0x68(%rbx), %cl
leaq 0x1(%rax), %rdx
movq %rdx, 0x48(%rbx)
movb %cl, (%rax)
shrl $0x8, 0x68(%rbx)
movl 0x64(%rbx), %ecx
addl $-0x8, %ecx
movl %ecx, 0x64(%rbx)
cmpl $0x7, %ecx
ja 0x54de
movl $0x1, %eax
shll %cl, %eax
orl %eax, 0x68(%rbx)
orl $0x8, %ecx
movl %ecx, 0x64(%rbx)
movq 0x48(%rbx), %rax
cmpq 0x50(%rbx), %rax
jae 0x552e
movb 0x68(%rbx), %cl
leaq 0x1(%rax), %rdx
movq %rdx, 0x48(%rbx)
movb %cl, (%rax)
shrl $0x8, 0x68(%rbx)
movl 0x64(%rbx), %eax
addl $-0x8, %eax
movl %eax, 0x64(%rbx)
cmpl $0x7, %eax
ja 0x5517
xorl %eax, %eax
cmpl $0x4, %ebp
sete %al
movl 0x64(%rbx), %r14d
movl %r14d, %ecx
shll %cl, %eax
orl %eax, 0x68(%rbx)
incl %r14d
movl %r14d, 0x64(%rbx)
cmpl $0x8, %r14d
jb 0x558e
movq 0x48(%rbx), %rax
cmpq 0x50(%rbx), %rax
jae 0x5578
movb 0x68(%rbx), %cl
leaq 0x1(%rax), %rdx
movq %rdx, 0x48(%rbx)
movb %cl, (%rax)
shrl $0x8, 0x68(%rbx)
movl 0x64(%rbx), %r14d
addl $-0x8, %r14d
movl %r14d, 0x64(%rbx)
cmpl $0x7, %r14d
ja 0x5561
movq %rsi, (%rsp)
movq 0x48(%rbx), %r15
movl 0x68(%rbx), %r13d
movb $0x1, %al
testb %r12b, %r12b
jne 0x55c3
movl $0x1, %esi
testb $0x8, 0x12(%rbx)
jne 0x55b6
xorl %esi, %esi
cmpl $0x30, 0x5c(%rbx)
setb %sil
movq %rbx, %rdi
callq 0x5f55
testl %eax, %eax
sete %al
testb %r12b, %r12b
jne 0x55df
movl 0x5c(%rbx), %ecx
testq %rcx, %rcx
je 0x55ea
movq 0x48(%rbx), %rdx
subq %r15, %rdx
incq %rdx
cmpq %rcx, %rdx
jl 0x55ea
movl 0x28(%rbx), %ecx
subl 0x60(%rbx), %ecx
cmpl 0x30(%rbx), %ecx
jbe 0x5610
testb %al, %al
je 0x572d
movq %r15, 0x48(%rbx)
movl %r13d, 0x68(%rbx)
movl %r14d, 0x64(%rbx)
movq %rbx, %rdi
movl $0x1, %esi
callq 0x5f55
jmp 0x572d
movq %r15, 0x48(%rbx)
movl %r13d, 0x68(%rbx)
leal 0x2(%r14), %eax
movl %eax, 0x64(%rbx)
cmpl $0x6, %r14d
jb 0x5652
movq 0x48(%rbx), %rax
cmpq 0x50(%rbx), %rax
jae 0x563c
movb 0x68(%rbx), %cl
leaq 0x1(%rax), %rdx
movq %rdx, 0x48(%rbx)
movb %cl, (%rax)
shrl $0x8, 0x68(%rbx)
movl 0x64(%rbx), %eax
addl $-0x8, %eax
movl %eax, 0x64(%rbx)
cmpl $0x7, %eax
ja 0x5625
testl %eax, %eax
je 0x5682
movl $0x8, 0x64(%rbx)
movq 0x48(%rbx), %rax
cmpq 0x50(%rbx), %rax
jae 0x5670
movb 0x68(%rbx), %cl
leaq 0x1(%rax), %rdx
movq %rdx, 0x48(%rbx)
movb %cl, (%rax)
shrl $0x8, 0x68(%rbx)
movl 0x64(%rbx), %eax
addl $-0x8, %eax
movl %eax, 0x64(%rbx)
cmpl $0x7, %eax
ja 0x5659
movl $0x2, %eax
movzwl 0x5c(%rbx), %edx
movl 0x64(%rbx), %ecx
shll %cl, %edx
orl %edx, 0x68(%rbx)
addl $0x10, %ecx
movl %ecx, 0x64(%rbx)
cmpl $0x8, %ecx
jb 0x56c7
movq 0x48(%rbx), %rcx
cmpq 0x50(%rbx), %rcx
jae 0x56b5
movb 0x68(%rbx), %dl
leaq 0x1(%rcx), %rsi
movq %rsi, 0x48(%rbx)
movb %dl, (%rcx)
shrl $0x8, 0x68(%rbx)
movl 0x64(%rbx), %ecx
addl $-0x8, %ecx
movl %ecx, 0x64(%rbx)
cmpl $0x7, %ecx
ja 0x569e
xorl $0xffff, 0x5c(%rbx)     # imm = 0xFFFF
decl %eax
jne 0x5687
cmpl $0x0, 0x5c(%rbx)
je 0x572d
xorl %eax, %eax
movl 0x60(%rbx), %ecx
addl %eax, %ecx
andl $0x7fff, %ecx           # imm = 0x7FFF
movzbl 0xd0(%rbx,%rcx), %edx
movl 0x64(%rbx), %ecx
shll %cl, %edx
orl %edx, 0x68(%rbx)
subl $-0x8, %ecx
movl %ecx, 0x64(%rbx)
jae 0x5726
movq 0x48(%rbx), %rcx
cmpq 0x50(%rbx), %rcx
jae 0x5714
movb 0x68(%rbx), %dl
leaq 0x1(%rcx), %rsi
movq %rsi, 0x48(%rbx)
movb %dl, (%rcx)
shrl $0x8, 0x68(%rbx)
movl 0x64(%rbx), %ecx
addl $-0x8, %ecx
movl %ecx, 0x64(%rbx)
cmpl $0x7, %ecx
ja 0x56fd
incl %eax
cmpl 0x5c(%rbx), %eax
jb 0x56da
testl %ebp, %ebp
je 0x588c
movl 0x64(%rbx), %eax
cmpl $0x4, %ebp
jne 0x57d3
testl %eax, %eax
je 0x5775
movl $0x8, 0x64(%rbx)
movq 0x48(%rbx), %rax
cmpq 0x50(%rbx), %rax
jae 0x5763
movb 0x68(%rbx), %cl
leaq 0x1(%rax), %rdx
movq %rdx, 0x48(%rbx)
movb %cl, (%rax)
shrl $0x8, 0x68(%rbx)
movl 0x64(%rbx), %eax
addl $-0x8, %eax
movl %eax, 0x64(%rbx)
cmpl $0x7, %eax
ja 0x574c
testb $0x10, 0x11(%rbx)
je 0x588c
movl 0x20(%rbx), %eax
xorl %edx, %edx
movl %eax, %esi
shrl $0x18, %esi
movl 0x64(%rbx), %ecx
shll %cl, %esi
orl %esi, 0x68(%rbx)
subl $-0x8, %ecx
movl %ecx, 0x64(%rbx)
jae 0x57c4
movq 0x48(%rbx), %rcx
cmpq 0x50(%rbx), %rcx
jae 0x57b2
movb 0x68(%rbx), %sil
leaq 0x1(%rcx), %rdi
movq %rdi, 0x48(%rbx)
movb %sil, (%rcx)
shrl $0x8, 0x68(%rbx)
movl 0x64(%rbx), %ecx
addl $-0x8, %ecx
movl %ecx, 0x64(%rbx)
cmpl $0x7, %ecx
ja 0x5799
shll $0x8, %eax
incl %edx
cmpl $0x4, %edx
jne 0x5784
jmp 0x588c
addl $0x3, %eax
movl %eax, 0x64(%rbx)
cmpl $0x8, %eax
jb 0x5807
movq 0x48(%rbx), %rax
cmpq 0x50(%rbx), %rax
jae 0x57f5
movb 0x68(%rbx), %cl
leaq 0x1(%rax), %rdx
movq %rdx, 0x48(%rbx)
movb %cl, (%rax)
shrl $0x8, 0x68(%rbx)
movl 0x64(%rbx), %eax
addl $-0x8, %eax
movl %eax, 0x64(%rbx)
cmpl $0x7, %eax
ja 0x57de
testl %eax, %eax
je 0x583b
movl $0x8, 0x64(%rbx)
movq 0x48(%rbx), %rax
cmpq 0x50(%rbx), %rax
jae 0x5829
movb 0x68(%rbx), %cl
leaq 0x1(%rax), %rdx
movq %rdx, 0x48(%rbx)
movb %cl, (%rax)
shrl $0x8, 0x68(%rbx)
movl 0x64(%rbx), %eax
addl $-0x8, %eax
movl %eax, 0x64(%rbx)
cmpl $0x7, %eax
ja 0x5812
xorl %eax, %eax
movl $0x2, %edx
movzwl %ax, %esi
movl 0x64(%rbx), %ecx
shll %cl, %esi
orl %esi, 0x68(%rbx)
addl $0x10, %ecx
movl %ecx, 0x64(%rbx)
cmpl $0x8, %ecx
jb 0x5883
movq 0x48(%rbx), %rcx
cmpq 0x50(%rbx), %rcx
jae 0x5871
movb 0x68(%rbx), %sil
leaq 0x1(%rcx), %rdi
movq %rdi, 0x48(%rbx)
movb %sil, (%rcx)
shrl $0x8, 0x68(%rbx)
movl 0x64(%rbx), %ecx
addl $-0x8, %ecx
movl %ecx, 0x64(%rbx)
cmpl $0x7, %ecx
ja 0x5858
xorl $0xffff, %eax           # imm = 0xFFFF
decl %edx
jne 0x5842
movq 0x48(%rbx), %r14
cmpq 0x50(%rbx), %r14
jae 0x59b6
leaq 0x81d2(%rbx), %rdi
leaq 0x92b2(%rbx), %r15
leaq 0x92b3(%rbx), %r12
movl $0x280, %edx            # imm = 0x280
xorl %esi, %esi
callq 0x10a0
movq %r12, 0x38(%rbx)
movq %r15, 0x40(%rbx)
movl 0x5c(%rbx), %eax
movq $0x8, 0x58(%rbx)
addl %eax, 0x60(%rbx)
incl 0x84(%rbx)
movq (%rsp), %rcx
subq %rcx, %r14
testl %r14d, %r14d
je 0x5985
movq (%rbx), %rax
testq %rax, %rax
je 0x592c
movq 0xb8(%rbx), %rcx
subq 0x90(%rbx), %rcx
movq 0xa0(%rbx), %rdx
movq %rcx, (%rdx)
leaq 0x392b2(%rbx), %rdi
movq 0x8(%rbx), %rdx
movl %r14d, %esi
callq *%rax
testl %eax, %eax
jne 0x5985
movl $0xffffffff, 0x8c(%rbx) # imm = 0xFFFFFFFF
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x5988
leaq 0x392b2(%rbx), %rsi
movslq %r14d, %rax
cmpq %rsi, %rcx
je 0x5944
addq %rax, 0xc8(%rbx)
jmp 0x5985
movq 0xa8(%rbx), %rcx
movq 0xc8(%rbx), %rdi
movq (%rcx), %r12
subq %rdi, %r12
cmpq %r12, %rax
cmovbq %rax, %r12
addq 0x98(%rbx), %rdi
movslq %r12d, %r15
movq %r15, %rdx
callq 0x10e0
addq %r15, 0xc8(%rbx)
subl %r15d, %r14d
je 0x5985
movl %r12d, 0x78(%rbx)
movl %r14d, 0x7c(%rbx)
movl 0x7c(%rbx), %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3799(%rip), %rdi      # 0x9137
leaq 0x3505(%rip), %rsi      # 0x8eaa
leaq 0x37a8(%rip), %rcx      # 0x9154
movl $0x723, %edx            # imm = 0x723
callq 0x1090
leaq 0x37e1(%rip), %rdi      # 0x919e
leaq 0x34e6(%rip), %rsi      # 0x8eaa
leaq 0x3789(%rip), %rcx      # 0x9154
movl $0x75a, %edx            # imm = 0x75A
callq 0x1090