// File: /workspace/github_c_makefile_star2_O3/wkoszek[P]mini_gzip/miniz.c
// Function: tdefl_compress_fast
static mz_bool tdefl_compress_fast(tdefl_compressor *d)
{
  // Faster, minimally featured LZRW1-style match+parse loop with better register utilization. Intended for applications where raw throughput is valued more highly than ratio.
  mz_uint lookahead_pos = d->m_lookahead_pos, lookahead_size = d->m_lookahead_size, dict_size = d->m_dict_size, total_lz_bytes = d->m_total_lz_bytes, num_flags_left = d->m_num_flags_left;
  mz_uint8 *pLZ_code_buf = d->m_pLZ_code_buf, *pLZ_flags = d->m_pLZ_flags;
  mz_uint cur_pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK;

  while ((d->m_src_buf_left) || ((d->m_flush) && (lookahead_size)))
  {
    const mz_uint TDEFL_COMP_FAST_LOOKAHEAD_SIZE = 4096;
    mz_uint dst_pos = (lookahead_pos + lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK;
    mz_uint num_bytes_to_process = (mz_uint)MZ_MIN(d->m_src_buf_left, TDEFL_COMP_FAST_LOOKAHEAD_SIZE - lookahead_size);
    d->m_src_buf_left -= num_bytes_to_process;
    lookahead_size += num_bytes_to_process;

    while (num_bytes_to_process)
    {
      mz_uint32 n = MZ_MIN(TDEFL_LZ_DICT_SIZE - dst_pos, num_bytes_to_process);
      memcpy(d->m_dict + dst_pos, d->m_pSrc, n);
      if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1))
        memcpy(d->m_dict + TDEFL_LZ_DICT_SIZE + dst_pos, d->m_pSrc, MZ_MIN(n, (TDEFL_MAX_MATCH_LEN - 1) - dst_pos));
      d->m_pSrc += n;
      dst_pos = (dst_pos + n) & TDEFL_LZ_DICT_SIZE_MASK;
      num_bytes_to_process -= n;
    }

    dict_size = MZ_MIN(TDEFL_LZ_DICT_SIZE - lookahead_size, dict_size);
    if ((!d->m_flush) && (lookahead_size < TDEFL_COMP_FAST_LOOKAHEAD_SIZE)) break;

    while (lookahead_size >= 4)
    {
      mz_uint cur_match_dist, cur_match_len = 1;
      mz_uint8 *pCur_dict = d->m_dict + cur_pos;
      mz_uint first_trigram = (*(const mz_uint32 *)pCur_dict) & 0xFFFFFF;
      mz_uint hash = (first_trigram ^ (first_trigram >> (24 - (TDEFL_LZ_HASH_BITS - 8)))) & TDEFL_LEVEL1_HASH_SIZE_MASK;
      mz_uint probe_pos = d->m_hash[hash];
      d->m_hash[hash] = (mz_uint16)lookahead_pos;

      if (((cur_match_dist = (mz_uint16)(lookahead_pos - probe_pos)) <= dict_size) && ((*(const mz_uint32 *)(d->m_dict + (probe_pos &= TDEFL_LZ_DICT_SIZE_MASK)) & 0xFFFFFF) == first_trigram))
      {
        const mz_uint16 *p = (const mz_uint16 *)pCur_dict;
        const mz_uint16 *q = (const mz_uint16 *)(d->m_dict + probe_pos);
        mz_uint32 probe_len = 32;
        do { } while ( (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) &&
          (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0) );
        cur_match_len = ((mz_uint)(p - (const mz_uint16 *)pCur_dict) * 2) + (mz_uint)(*(const mz_uint8 *)p == *(const mz_uint8 *)q);
        if (!probe_len)
          cur_match_len = cur_match_dist ? TDEFL_MAX_MATCH_LEN : 0;

        if ((cur_match_len < TDEFL_MIN_MATCH_LEN) || ((cur_match_len == TDEFL_MIN_MATCH_LEN) && (cur_match_dist >= 8U*1024U)))
        {
          cur_match_len = 1;
          *pLZ_code_buf++ = (mz_uint8)first_trigram;
          *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1);
          d->m_huff_count[0][(mz_uint8)first_trigram]++;
        }
        else
        {
          mz_uint32 s0, s1;
          cur_match_len = MZ_MIN(cur_match_len, lookahead_size);

          MZ_ASSERT((cur_match_len >= TDEFL_MIN_MATCH_LEN) && (cur_match_dist >= 1) && (cur_match_dist <= TDEFL_LZ_DICT_SIZE));

          cur_match_dist--;

          pLZ_code_buf[0] = (mz_uint8)(cur_match_len - TDEFL_MIN_MATCH_LEN);
          *(mz_uint16 *)(&pLZ_code_buf[1]) = (mz_uint16)cur_match_dist;
          pLZ_code_buf += 3;
          *pLZ_flags = (mz_uint8)((*pLZ_flags >> 1) | 0x80);

          s0 = s_tdefl_small_dist_sym[cur_match_dist & 511];
          s1 = s_tdefl_large_dist_sym[cur_match_dist >> 8];
          d->m_huff_count[1][(cur_match_dist < 512) ? s0 : s1]++;

          d->m_huff_count[0][s_tdefl_len_sym[cur_match_len - TDEFL_MIN_MATCH_LEN]]++;
        }
      }
      else
      {
        *pLZ_code_buf++ = (mz_uint8)first_trigram;
        *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1);
        d->m_huff_count[0][(mz_uint8)first_trigram]++;
      }

      if (--num_flags_left == 0) { num_flags_left = 8; pLZ_flags = pLZ_code_buf++; }

      total_lz_bytes += cur_match_len;
      lookahead_pos += cur_match_len;
      dict_size = MZ_MIN(dict_size + cur_match_len, TDEFL_LZ_DICT_SIZE);
      cur_pos = (cur_pos + cur_match_len) & TDEFL_LZ_DICT_SIZE_MASK;
      MZ_ASSERT(lookahead_size >= cur_match_len);
      lookahead_size -= cur_match_len;

      if (pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8])
      {
        int n;
        d->m_lookahead_pos = lookahead_pos; d->m_lookahead_size = lookahead_size; d->m_dict_size = dict_size;
        d->m_total_lz_bytes = total_lz_bytes; d->m_pLZ_code_buf = pLZ_code_buf; d->m_pLZ_flags = pLZ_flags; d->m_num_flags_left = num_flags_left;
        if ((n = tdefl_flush_block(d, 0)) != 0)
          return (n < 0) ? MZ_FALSE : MZ_TRUE;
        total_lz_bytes = d->m_total_lz_bytes; pLZ_code_buf = d->m_pLZ_code_buf; pLZ_flags = d->m_pLZ_flags; num_flags_left = d->m_num_flags_left;
      }
    }

    while (lookahead_size)
    {
      mz_uint8 lit = d->m_dict[cur_pos];

      total_lz_bytes++;
      *pLZ_code_buf++ = lit;
      *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1);
      if (--num_flags_left == 0) { num_flags_left = 8; pLZ_flags = pLZ_code_buf++; }

      d->m_huff_count[0][lit]++;

      lookahead_pos++;
      dict_size = MZ_MIN(dict_size + 1, TDEFL_LZ_DICT_SIZE);
      cur_pos = (cur_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK;
      lookahead_size--;

      if (pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8])
      {
        int n;
        d->m_lookahead_pos = lookahead_pos; d->m_lookahead_size = lookahead_size; d->m_dict_size = dict_size;
        d->m_total_lz_bytes = total_lz_bytes; d->m_pLZ_code_buf = pLZ_code_buf; d->m_pLZ_flags = pLZ_flags; d->m_num_flags_left = num_flags_left;
        if ((n = tdefl_flush_block(d, 0)) != 0)
          return (n < 0) ? MZ_FALSE : MZ_TRUE;
        total_lz_bytes = d->m_total_lz_bytes; pLZ_code_buf = d->m_pLZ_code_buf; pLZ_flags = d->m_pLZ_flags; num_flags_left = d->m_num_flags_left;
      }
    }
  }

  d->m_lookahead_pos = lookahead_pos; d->m_lookahead_size = lookahead_size; d->m_dict_size = dict_size;
  d->m_total_lz_bytes = total_lz_bytes; d->m_pLZ_code_buf = pLZ_code_buf; d->m_pLZ_flags = pLZ_flags; d->m_num_flags_left = num_flags_left;
  return MZ_TRUE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
movl 0x28(%rdi), %r15d
movl 0x2c(%rdi), %eax
movq %rax, 0x10(%rsp)
movl 0x30(%rdi), %ebp
movl 0x5c(%rdi), %r9d
movl 0x58(%rdi), %esi
movq 0x38(%rdi), %r8
movq 0x40(%rdi), %r10
movl %r15d, %r12d
andl $0x7fff, %r12d          # imm = 0x7FFF
leaq 0xd0(%rdi), %rax
movq %rax, 0x40(%rsp)
leaq 0x80d0(%rdi), %rax
movq %rax, 0x60(%rsp)
leaq 0x192aa(%rdi), %r13
leaq 0x1d0(%rdi), %rax
movq %rax, 0x48(%rsp)
leaq 0xd8(%rdi), %rax
movq %rax, 0x58(%rsp)
movq %r13, 0x50(%rsp)
movq 0xc0(%rbx), %rax
testq %rax, %rax
movq 0x10(%rsp), %r11
jne 0x4809
cmpl $0x0, 0xb0(%rbx)
je 0x4d69
testl %r11d, %r11d
je 0x4d69
movl %esi, 0x3c(%rsp)
movq %r8, 0x18(%rsp)
movq %r10, 0x28(%rsp)
movl %r9d, 0xc(%rsp)
movq %r15, 0x30(%rsp)
movl $0x1000, %ecx           # imm = 0x1000
subl %r11d, %ecx
cmpq %rcx, %rax
movl %eax, %edx
cmovael %ecx, %edx
subq %rdx, %rax
movq %rax, 0xc0(%rbx)
movq %rdx, 0x20(%rsp)
testl %edx, %edx
je 0x48d3
movq 0x30(%rsp), %rax
movq 0x10(%rsp), %rcx
leal (%rax,%rcx), %r13d
movq 0xb8(%rbx), %rsi
movq 0x20(%rsp), %rax
movl %eax, %r15d
andl $0x7fff, %r13d          # imm = 0x7FFF
movl $0x8000, %r14d          # imm = 0x8000
subl %r13d, %r14d
cmpl %r15d, %r14d
cmovael %r15d, %r14d
movq 0x40(%rsp), %rax
leaq (%rax,%r13), %rdi
movq %r14, %rdx
callq 0x10e0
cmpl $0x100, %r13d           # imm = 0x100
ja 0x48ba
movq 0x60(%rsp), %rax
leaq (%rax,%r13), %rdi
movq 0xb8(%rbx), %rsi
movl $0x101, %edx            # imm = 0x101
subl %r13d, %edx
cmpl %edx, %r14d
cmovbl %r14d, %edx
callq 0x10e0
movq %r14, %rsi
addq 0xb8(%rbx), %rsi
movq %rsi, 0xb8(%rbx)
addl %r14d, %r13d
subl %r14d, %r15d
jne 0x4865
movq 0x20(%rsp), %r11
addl 0x10(%rsp), %r11d
movl $0x8000, %r14d          # imm = 0x8000
subl %r11d, %r14d
cmpl %ebp, %r14d
cmovael %ebp, %r14d
cmpl $0x0, 0xb0(%rbx)
jne 0x4903
cmpl $0x1000, %r11d          # imm = 0x1000
jb 0x4d4e
cmpl $0x4, %r11d
movq 0x30(%rsp), %r15
movq 0x50(%rsp), %r13
movl 0xc(%rsp), %r9d
movq 0x28(%rsp), %r10
movq 0x18(%rsp), %r8
movl 0x3c(%rsp), %esi
jb 0x4c6a
movl %esi, %ebp
movq %r11, 0x20(%rsp)
movl %r12d, %eax
movq %rax, 0x10(%rsp)
movl 0xd0(%rbx,%rax), %ecx
movl %ecx, %edi
andl $0xffffff, %edi         # imm = 0xFFFFFF
movl %edi, %eax
shrl $0x11, %eax
movl %ecx, %esi
andl $0xfff, %esi            # imm = 0xFFF
xorl %eax, %esi
movzwl 0x292b2(%rbx,%rsi,2), %edx
movw %r15w, 0x292b2(%rbx,%rsi,2)
movl %r15d, %esi
subl %edx, %esi
movzwl %si, %eax
cmpl %eax, %r14d
jb 0x4a67
movl %edx, %r11d
andl $0x7fff, %r11d          # imm = 0x7FFF
movq %r8, 0x18(%rsp)
movq 0x40(%rsp), %r8
movl (%r8,%r11), %r8d
movl $0xffffff, %r12d        # imm = 0xFFFFFF
andl %r12d, %r8d
cmpl %edi, %r8d
movq 0x18(%rsp), %r8
jne 0x4a67
movq %r10, 0x28(%rsp)
movl %r9d, 0xc(%rsp)
movq %r15, 0x30(%rsp)
movq 0x40(%rsp), %rdi
movq 0x10(%rsp), %r9
leaq (%rdi,%r9), %r8
movq 0x48(%rsp), %rdi
addq %r9, %rdi
movl %edx, %r12d
andl $0x7fff, %r12d          # imm = 0x7FFF
leaq (%rbx,%r9), %r15
addq 0x58(%rsp), %r11
xorl %r13d, %r13d
movzwl 0xd2(%r15,%r13), %r9d
movzwl -0x6(%r11,%r13), %r10d
cmpw %r10w, %r9w
jne 0x4b2e
movzwl 0xd4(%r15,%r13), %r9d
movzwl -0x4(%r11,%r13), %r10d
cmpw %r10w, %r9w
jne 0x4b3b
movzwl 0xd6(%r15,%r13), %r9d
movzwl -0x2(%r11,%r13), %r10d
cmpw %r10w, %r9w
jne 0x4b48
movzwl 0xd8(%r15,%r13), %r9d
movzwl (%r11,%r13), %r10d
cmpw %r10w, %r9w
jne 0x4b55
addq $0x8, %r13
cmpl $0x100, %r13d           # imm = 0x100
jne 0x49e3
movb (%rdi), %r9b
movq 0x48(%rsp), %r10
movb (%r10,%r12), %r10b
movb $0x1, %r11b
jmp 0x4b63
movb %cl, (%r8)
shrb (%r10)
incq %r8
movzbl %cl, %eax
movl $0x1, %r12d
movq 0x20(%rsp), %r11
incw 0x81d2(%rbx,%rax,2)
xorl %eax, %eax
movl %ebp, %esi
decl %esi
cmoveq %r8, %r10
sete %cl
movl $0x8, %edx
cmovel %edx, %esi
addl %r12d, %r14d
movl $0x8000, %edx           # imm = 0x8000
cmpl %edx, %r14d
cmovael %edx, %r14d
subl %r12d, %r11d
jb 0x4d87
movb %cl, %al
addq %rax, %r8
addl %r12d, %r9d
addl %r12d, %r15d
cmpq %r13, %r8
jbe 0x4b13
movq %r15, %rax
movq %r13, %r15
movq %rax, %rbp
movl %eax, 0x28(%rbx)
movq %r11, %r13
movl %r11d, 0x2c(%rbx)
movl %r14d, 0x30(%rbx)
movl %r9d, 0x5c(%rbx)
movq %r8, 0x38(%rbx)
movq %r10, 0x40(%rbx)
movl %esi, 0x58(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5556
testl %eax, %eax
jne 0x4d39
movl 0x5c(%rbx), %r9d
movq 0x38(%rbx), %r8
movq 0x40(%rbx), %r10
movl 0x58(%rbx), %esi
movq %r13, %r11
movq %r15, %r13
movq %rbp, %r15
addl 0x10(%rsp), %r12d
andl $0x7fff, %r12d          # imm = 0x7FFF
cmpl $0x3, %r11d
ja 0x492a
jmp 0x4c6a
leaq (%r15,%r13), %rdi
addq $0xd2, %rdi
jmp 0x4b60
leaq (%r15,%r13), %rdi
addq $0xd4, %rdi
jmp 0x4b60
leaq (%r15,%r13), %rdi
addq $0xd6, %rdi
jmp 0x4b60
leaq (%r15,%r13), %rdi
addq $0xd8, %rdi
xorl %r11d, %r11d
subl %r8d, %edi
andl $-0x2, %edi
xorl %r8d, %r8d
cmpb %r10b, %r9b
sete %r8b
orl %edi, %r8d
movq 0x30(%rsp), %r15
cmpw %dx, %r15w
movl $0x102, %r12d           # imm = 0x102
movl $0x0, %edi
cmovel %edi, %r12d
testb %r11b, %r11b
cmovel %r8d, %r12d
cmpl $0x3, %r12d
movq 0x50(%rsp), %r13
jb 0x4bad
cmpl $0x2000, %eax           # imm = 0x2000
jb 0x4bd3
cmpl $0x3, %r12d
jne 0x4bd3
movq 0x18(%rsp), %r8
movb %cl, (%r8)
movq 0x28(%rsp), %r10
shrb (%r10)
incq %r8
movzbl %cl, %eax
movl $0x1, %r12d
movl 0xc(%rsp), %r9d
jmp 0x4a79
cmpw %dx, %r15w
movl 0xc(%rsp), %r9d
movq 0x28(%rsp), %r10
movq 0x18(%rsp), %r8
movq 0x20(%rsp), %r11
je 0x4da6
movzwl %si, %ecx
cmpl $0x8001, %ecx           # imm = 0x8001
jae 0x4da6
cmpl %r11d, %r12d
cmovael %r11d, %r12d
decl %eax
leal -0x3(%r12), %ecx
movb %cl, (%r8)
movw %ax, 0x1(%r8)
addq $0x3, %r8
movb (%r10), %dl
shrb %dl
orb $-0x80, %dl
movb %dl, (%r10)
movl %eax, %edx
andl $0x1ff, %edx            # imm = 0x1FF
leaq 0x392c(%rip), %rsi      # 0x8560
addq %rsi, %rdx
movl %eax, %esi
shrl $0x8, %esi
leaq 0x3b1d(%rip), %rdi      # 0x8760
addq %rdi, %rsi
cmpl $0x200, %eax            # imm = 0x200
cmovbq %rdx, %rsi
movzbl (%rsi), %eax
incw 0x8412(%rbx,%rax,2)
leaq 0x3b7f(%rip), %rax      # 0x87e0
movzwl (%rax,%rcx,2), %eax
jmp 0x4a7e
movq $0x0, 0x10(%rsp)
movl %r14d, %ebp
testl %r11d, %r11d
je 0x47e2
decl %r11d
movl %r12d, %eax
movzbl 0xd0(%rbx,%rax), %eax
movb %al, (%r8)
shrb (%r10)
incl %r9d
leaq 0x1(%r8), %rcx
decl %esi
addq $0x2, %r8
testl %esi, %esi
cmoveq %rcx, %r10
cmovneq %rcx, %r8
movl $0x8, %ecx
cmovel %ecx, %esi
incw 0x81d2(%rbx,%rax,2)
incl %r15d
incl %r14d
movl $0x8000, %eax           # imm = 0x8000
cmpl %eax, %r14d
cmovael %eax, %r14d
cmpq %r13, %r8
jbe 0x4d1d
movq %r15, %rax
movq %r13, %r15
movq %rax, %rbp
movl %eax, 0x28(%rbx)
movq %r11, %r13
movl %r11d, 0x2c(%rbx)
movl %r14d, 0x30(%rbx)
movl %r9d, 0x5c(%rbx)
movq %r8, 0x38(%rbx)
movq %r10, 0x40(%rbx)
movl %esi, 0x58(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5556
testl %eax, %eax
jne 0x4d39
movl 0x5c(%rbx), %r9d
movq 0x38(%rbx), %r8
movq 0x40(%rbx), %r10
movl 0x58(%rbx), %esi
movq %r13, %r11
movq %r15, %r13
movq %rbp, %r15
incl %r12d
andl $0x7fff, %r12d          # imm = 0x7FFF
addl $-0x1, %r11d
jb 0x4c82
movl %r14d, %ebp
jmp 0x47e2
setns %al
movzbl %al, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r14d, %ebp
movq 0x30(%rsp), %r15
movl 0xc(%rsp), %r9d
movq 0x28(%rsp), %r10
movq 0x18(%rsp), %r8
movl 0x3c(%rsp), %esi
movl %r15d, 0x28(%rbx)
movl %r11d, 0x2c(%rbx)
movl %ebp, 0x30(%rbx)
movl %r9d, 0x5c(%rbx)
movq %r8, 0x38(%rbx)
movq %r10, 0x40(%rbx)
movl %esi, 0x58(%rbx)
movb $0x1, %al
jmp 0x4d3c
leaq 0x4288(%rip), %rdi      # 0x9016
leaq 0x4185(%rip), %rsi      # 0x8f1a
leaq 0x424a(%rip), %rcx      # 0x8fe6
movl $0x81a, %edx            # imm = 0x81A
callq 0x1090
leaq 0x41cf(%rip), %rdi      # 0x8f7c
leaq 0x4166(%rip), %rsi      # 0x8f1a
leaq 0x422b(%rip), %rcx      # 0x8fe6
movl $0x7fd, %edx            # imm = 0x7FD
callq 0x1090