// File: /workspace/github_c_makefile_star2_O0/wkoszek[P]mini_gzip/miniz.c
// Function: tdefl_compress_lz_codes
static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d)
{
  mz_uint flags;
  mz_uint8 *pLZ_codes;
  mz_uint8 *pOutput_buf = d->m_pOutput_buf;
  mz_uint8 *pLZ_code_buf_end = d->m_pLZ_code_buf;
  mz_uint64 bit_buffer = d->m_bit_buffer;
  mz_uint bits_in = d->m_bits_in;

#define TDEFL_PUT_BITS_FAST(b, l) { bit_buffer |= (((mz_uint64)(b)) << bits_in); bits_in += (l); }

  flags = 1;
  for (pLZ_codes = d->m_lz_code_buf; pLZ_codes < pLZ_code_buf_end; flags >>= 1)
  {
    if (flags == 1)
      flags = *pLZ_codes++ | 0x100;

    if (flags & 1)
    {
      mz_uint s0, s1, n0, n1, sym, num_extra_bits;
      mz_uint match_len = pLZ_codes[0], match_dist = *(const mz_uint16 *)(pLZ_codes + 1); pLZ_codes += 3;

      MZ_ASSERT(d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]);
      TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][s_tdefl_len_sym[match_len]], d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]);
      TDEFL_PUT_BITS_FAST(match_len & mz_bitmasks[s_tdefl_len_extra[match_len]], s_tdefl_len_extra[match_len]);

      // This sequence coaxes MSVC into using cmov's vs. jmp's.
      s0 = s_tdefl_small_dist_sym[match_dist & 511];
      n0 = s_tdefl_small_dist_extra[match_dist & 511];
      s1 = s_tdefl_large_dist_sym[match_dist >> 8];
      n1 = s_tdefl_large_dist_extra[match_dist >> 8];
      sym = (match_dist < 512) ? s0 : s1;
      num_extra_bits = (match_dist < 512) ? n0 : n1;

      MZ_ASSERT(d->m_huff_code_sizes[1][sym]);
      TDEFL_PUT_BITS_FAST(d->m_huff_codes[1][sym], d->m_huff_code_sizes[1][sym]);
      TDEFL_PUT_BITS_FAST(match_dist & mz_bitmasks[num_extra_bits], num_extra_bits);
    }
    else
    {
      mz_uint lit = *pLZ_codes++;
      MZ_ASSERT(d->m_huff_code_sizes[0][lit]);
      TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]);

      if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end))
      {
        flags >>= 1;
        lit = *pLZ_codes++;
        MZ_ASSERT(d->m_huff_code_sizes[0][lit]);
        TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]);

        if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end))
        {
          flags >>= 1;
          lit = *pLZ_codes++;
          MZ_ASSERT(d->m_huff_code_sizes[0][lit]);
          TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]);
        }
      }
    }

    if (pOutput_buf >= d->m_pOutput_buf_end)
      return MZ_FALSE;

    *(mz_uint64*)pOutput_buf = bit_buffer;
    pOutput_buf += (bits_in >> 3);
    bit_buffer >>= (bits_in & ~7);
    bits_in &= 7;
  }

#undef TDEFL_PUT_BITS_FAST

  d->m_pOutput_buf = pOutput_buf;
  d->m_bits_in = 0;
  d->m_bit_buffer = 0;

  while (bits_in)
  {
    mz_uint32 n = MZ_MIN(bits_in, 16);
    TDEFL_PUT_BITS((mz_uint)bit_buffer & mz_bitmasks[n], n);
    bit_buffer >>= n;
    bits_in -= n;
  }

  TDEFL_PUT_BITS(d->m_huff_codes[0][256], d->m_huff_code_sizes[0][256]);

  return (d->m_pOutput_buf < d->m_pOutput_buf_end);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl 0x68(%rax), %eax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl 0x64(%rax), %eax
movl %eax, -0x3c(%rbp)
movl $0x1, -0x14(%rbp)
movq -0x10(%rbp), %rax
addq $0x92b2, %rax           # imm = 0x92B2
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0xae1b
cmpl $0x1, -0x14(%rbp)
jne 0xa9cf
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movzbl (%rax), %eax
orl $0x100, %eax            # imm = 0x100
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xac01
movq -0x20(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x58(%rbp)
movq -0x20(%rbp), %rax
movzwl 0x1(%rax), %eax
movl %eax, -0x5c(%rbp)
movq -0x20(%rbp), %rax
addq $0x3, %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl -0x58(%rbp), %ecx
movl %ecx, %edx
leaq 0x1dd1(%rip), %rcx      # 0xc7e0
movzwl (%rcx,%rdx,2), %ecx
cmpb $0x0, 0x8f52(%rax,%rcx)
je 0xaa1f
jmp 0xaa3e
leaq 0x27c5(%rip), %rdi      # 0xd1eb
leaq 0x241d(%rip), %rsi      # 0xce4a
movl $0x69f, %edx            # imm = 0x69F
leaq 0x27e6(%rip), %rcx      # 0xd21f
callq 0x1080
movq -0x10(%rbp), %rax
movl -0x58(%rbp), %ecx
movl %ecx, %edx
leaq 0x1d92(%rip), %rcx      # 0xc7e0
movzwl (%rcx,%rdx,2), %ecx
movzwl 0x8892(%rax,%rcx,2), %eax
movl -0x3c(%rbp), %ecx
shlq %cl, %rax
orq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl -0x58(%rbp), %ecx
movl %ecx, %edx
leaq 0x1d68(%rip), %rcx      # 0xc7e0
movzwl (%rcx,%rdx,2), %ecx
movzbl 0x8f52(%rax,%rcx), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x58(%rbp), %eax
movl -0x58(%rbp), %ecx
movl %ecx, %edx
leaq 0x1f97(%rip), %rcx      # 0xca30
movzbl (%rcx,%rdx), %ecx
movl %ecx, %edx
leaq 0x1f3a(%rip), %rcx      # 0xc9e0
andl (%rcx,%rdx,4), %eax
movl %eax, %eax
movl -0x3c(%rbp), %ecx
shlq %cl, %rax
orq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movl -0x58(%rbp), %eax
movl %eax, %ecx
leaq 0x1f6b(%rip), %rax      # 0xca30
movzbl (%rax,%rcx), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x5c(%rbp), %eax
andl $0x1ff, %eax            # imm = 0x1FF
movl %eax, %eax
movl %eax, %ecx
leaq 0x1a7e(%rip), %rax      # 0xc560
movzbl (%rax,%rcx), %eax
movl %eax, -0x40(%rbp)
movl -0x5c(%rbp), %eax
andl $0x1ff, %eax            # imm = 0x1FF
movl %eax, %eax
movl %eax, %ecx
leaq 0x2034(%rip), %rax      # 0xcb30
movzbl (%rax,%rcx), %eax
movl %eax, -0x48(%rbp)
movl -0x5c(%rbp), %eax
shrl $0x8, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x1c4c(%rip), %rax      # 0xc760
movzbl (%rax,%rcx), %eax
movl %eax, -0x44(%rbp)
movl -0x5c(%rbp), %eax
shrl $0x8, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x2204(%rip), %rax      # 0xcd30
movzbl (%rax,%rcx), %eax
movl %eax, -0x4c(%rbp)
cmpl $0x200, -0x5c(%rbp)     # imm = 0x200
jae 0xab44
movl -0x40(%rbp), %eax
movl %eax, -0x78(%rbp)
jmp 0xab4a
movl -0x44(%rbp), %eax
movl %eax, -0x78(%rbp)
movl -0x78(%rbp), %eax
movl %eax, -0x50(%rbp)
cmpl $0x200, -0x5c(%rbp)     # imm = 0x200
jae 0xab61
movl -0x48(%rbp), %eax
movl %eax, -0x7c(%rbp)
jmp 0xab67
movl -0x4c(%rbp), %eax
movl %eax, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rax
movl -0x50(%rbp), %ecx
cmpb $0x0, 0x9072(%rax,%rcx)
je 0xab80
jmp 0xab9f
leaq 0x26cc(%rip), %rdi      # 0xd253
leaq 0x22bc(%rip), %rsi      # 0xce4a
movl $0x6ab, %edx            # imm = 0x6AB
leaq 0x2685(%rip), %rcx      # 0xd21f
callq 0x1080
movq -0x10(%rbp), %rax
movl -0x50(%rbp), %ecx
movzwl 0x8ad2(%rax,%rcx,2), %eax
movl -0x3c(%rbp), %ecx
shlq %cl, %rax
orq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl -0x50(%rbp), %ecx
movzbl 0x9072(%rax,%rcx), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x5c(%rbp), %eax
movl -0x54(%rbp), %ecx
movl %ecx, %edx
leaq 0x1e00(%rip), %rcx      # 0xc9e0
andl (%rcx,%rdx,4), %eax
movl %eax, %eax
movl -0x3c(%rbp), %ecx
shlq %cl, %rax
orq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movl -0x54(%rbp), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
jmp 0xadba
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movzbl (%rax), %eax
movl %eax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movl -0x60(%rbp), %ecx
cmpb $0x0, 0x8f52(%rax,%rcx)
je 0xac29
jmp 0xac48
leaq 0x2640(%rip), %rdi      # 0xd270
leaq 0x2213(%rip), %rsi      # 0xce4a
movl $0x6b2, %edx            # imm = 0x6B2
leaq 0x25dc(%rip), %rcx      # 0xd21f
callq 0x1080
movq -0x10(%rbp), %rax
movl -0x60(%rbp), %ecx
movzwl 0x8892(%rax,%rcx,2), %eax
movl -0x3c(%rbp), %ecx
shlq %cl, %rax
orq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl -0x60(%rbp), %ecx
movzbl 0x8f52(%rax,%rcx), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x14(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0xadb8
movq -0x20(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0xadb8
movl -0x14(%rbp), %eax
shrl %eax
movl %eax, -0x14(%rbp)
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movzbl (%rax), %eax
movl %eax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movl -0x60(%rbp), %ecx
cmpb $0x0, 0x8f52(%rax,%rcx)
je 0xacc7
jmp 0xace6
leaq 0x25a2(%rip), %rdi      # 0xd270
leaq 0x2175(%rip), %rsi      # 0xce4a
movl $0x6b9, %edx            # imm = 0x6B9
leaq 0x253e(%rip), %rcx      # 0xd21f
callq 0x1080
movq -0x10(%rbp), %rax
movl -0x60(%rbp), %ecx
movzwl 0x8892(%rax,%rcx,2), %eax
movl -0x3c(%rbp), %ecx
shlq %cl, %rax
orq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl -0x60(%rbp), %ecx
movzbl 0x8f52(%rax,%rcx), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x14(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0xadb6
movq -0x20(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0xadb6
movl -0x14(%rbp), %eax
shrl %eax
movl %eax, -0x14(%rbp)
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movzbl (%rax), %eax
movl %eax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movl -0x60(%rbp), %ecx
cmpb $0x0, 0x8f52(%rax,%rcx)
je 0xad65
jmp 0xad84
leaq 0x2504(%rip), %rdi      # 0xd270
leaq 0x20d7(%rip), %rsi      # 0xce4a
movl $0x6c0, %edx            # imm = 0x6C0
leaq 0x24a0(%rip), %rcx      # 0xd21f
callq 0x1080
movq -0x10(%rbp), %rax
movl -0x60(%rbp), %ecx
movzwl 0x8892(%rax,%rcx,2), %eax
movl -0x3c(%rbp), %ecx
shlq %cl, %rax
orq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl -0x60(%rbp), %ecx
movzbl 0x8f52(%rax,%rcx), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
jmp 0xadb8
jmp 0xadba
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x50(%rcx), %rax
jb 0xadd4
movl $0x0, -0x4(%rbp)
jmp 0xb042
movq -0x38(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movl -0x3c(%rbp), %ecx
shrl $0x3, %ecx
movq -0x28(%rbp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movl -0x3c(%rbp), %ecx
andl $-0x8, %ecx
movq -0x38(%rbp), %rax
movl %ecx, %ecx
shrq %cl, %rax
movq %rax, -0x38(%rbp)
movl -0x3c(%rbp), %eax
andl $0x7, %eax
movl %eax, -0x3c(%rbp)
movl -0x14(%rbp), %eax
shrl %eax
movl %eax, -0x14(%rbp)
jmp 0xa9a1
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x64(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x68(%rax)
cmpl $0x0, -0x3c(%rbp)
je 0xaf55
cmpl $0x10, -0x3c(%rbp)
jae 0xae55
movl -0x3c(%rbp), %eax
movl %eax, -0x80(%rbp)
jmp 0xae5f
movl $0x10, %eax
movl %eax, -0x80(%rbp)
jmp 0xae5f
movl -0x80(%rbp), %eax
movl %eax, -0x64(%rbp)
movq -0x38(%rbp), %rax
movl -0x64(%rbp), %ecx
movl %ecx, %edx
leaq 0x1b6b(%rip), %rcx      # 0xc9e0
andl (%rcx,%rdx,4), %eax
movl %eax, -0x68(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x68(%rbp), %eax
movl -0x6c(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
ja 0xae99
jmp 0xaeb8
leaq 0x2283(%rip), %rdi      # 0xd123
leaq 0x1fa3(%rip), %rsi      # 0xce4a
movl $0x6d8, %edx            # imm = 0x6D8
leaq 0x236c(%rip), %rcx      # 0xd21f
callq 0x1080
movl -0x68(%rbp), %eax
movq -0x10(%rbp), %rcx
movl 0x64(%rcx), %ecx
shll %cl, %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
orl 0x68(%rax), %ecx
movl %ecx, 0x68(%rax)
movl -0x6c(%rbp), %ecx
movq -0x10(%rbp), %rax
addl 0x64(%rax), %ecx
movl %ecx, 0x64(%rax)
movq -0x10(%rbp), %rax
cmpl $0x8, 0x64(%rax)
jb 0xaf33
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x50(%rcx), %rax
jae 0xaf17
movq -0x10(%rbp), %rax
movl 0x68(%rax), %eax
movb %al, %cl
movq -0x10(%rbp), %rdx
movq 0x48(%rdx), %rax
movq %rax, %rsi
addq $0x1, %rsi
movq %rsi, 0x48(%rdx)
movb %cl, (%rax)
movq -0x10(%rbp), %rax
movl 0x68(%rax), %ecx
shrl $0x8, %ecx
movl %ecx, 0x68(%rax)
movq -0x10(%rbp), %rax
movl 0x64(%rax), %ecx
subl $0x8, %ecx
movl %ecx, 0x64(%rax)
jmp 0xaedd
jmp 0xaf35
movl -0x64(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, %ecx
shrq %cl, %rax
movq %rax, -0x38(%rbp)
movl -0x64(%rbp), %ecx
movl -0x3c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x3c(%rbp)
jmp 0xae3d
jmp 0xaf57
movq -0x10(%rbp), %rax
movzwl 0x8a92(%rax), %eax
movl %eax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x9052(%rax), %eax
movl %eax, -0x74(%rbp)
movl -0x70(%rbp), %eax
movl -0x74(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
ja 0xaf8b
jmp 0xafaa
leaq 0x2191(%rip), %rdi      # 0xd123
leaq 0x1eb1(%rip), %rsi      # 0xce4a
movl $0x6dd, %edx            # imm = 0x6DD
leaq 0x227a(%rip), %rcx      # 0xd21f
callq 0x1080
movl -0x70(%rbp), %eax
movq -0x10(%rbp), %rcx
movl 0x64(%rcx), %ecx
shll %cl, %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
orl 0x68(%rax), %ecx
movl %ecx, 0x68(%rax)
movl -0x74(%rbp), %ecx
movq -0x10(%rbp), %rax
addl 0x64(%rax), %ecx
movl %ecx, 0x64(%rax)
movq -0x10(%rbp), %rax
cmpl $0x8, 0x64(%rax)
jb 0xb025
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x50(%rcx), %rax
jae 0xb009
movq -0x10(%rbp), %rax
movl 0x68(%rax), %eax
movb %al, %cl
movq -0x10(%rbp), %rdx
movq 0x48(%rdx), %rax
movq %rax, %rsi
addq $0x1, %rsi
movq %rsi, 0x48(%rdx)
movb %cl, (%rax)
movq -0x10(%rbp), %rax
movl 0x68(%rax), %ecx
shrl $0x8, %ecx
movl %ecx, 0x68(%rax)
movq -0x10(%rbp), %rax
movl 0x64(%rax), %ecx
subl $0x8, %ecx
movl %ecx, 0x64(%rax)
jmp 0xafcf
jmp 0xb027
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x50(%rcx), %rax
setb %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nop