// File: /workspace/github_cpp_makefile_star2_O1/jimmiebergmann[P]fbx-file/miniz.c
// Function: tdefl_compress_fast(tdefl_compressor*)
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_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) &&
                         (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++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, (mz_uint)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, (mz_uint)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
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
movl 0x24(%rdi), %r9d
movl 0x28(%rdi), %esi
movl 0x2c(%rdi), %r15d
movl 0x54(%rdi), %r11d
movl 0x50(%rdi), %r10d
movq 0x30(%rdi), %r13
movq 0x38(%rdi), %rdx
movl %r9d, %r12d
andl $0x7fff, %r12d          # imm = 0x7FFF
leaq 0xc8(%rdi), %rax
movq %rax, -0x70(%rbp)
leaq 0x80c8(%rdi), %rax
movq %rax, -0x90(%rbp)
leaq 0x81ca(%rdi), %rax
movq %rax, -0x68(%rbp)
leaq 0x192a2(%rdi), %rax
movq %rax, -0x80(%rbp)
leaq 0x1c8(%rdi), %rax
movq %rax, -0x88(%rbp)
movq 0xb8(%rbx), %rax
testq %rax, %rax
jne 0x5f88
cmpl $0x0, 0xa8(%rbx)
je 0x6514
testl %esi, %esi
je 0x6514
movl %r15d, -0x3c(%rbp)
movq %rdx, -0x48(%rbp)
movl %r10d, -0x30(%rbp)
movq %r13, -0x78(%rbp)
movl %r11d, -0x2c(%rbp)
movq %r9, -0x38(%rbp)
movl $0x1000, %ecx           # imm = 0x1000
movq %rsi, -0x58(%rbp)
subl %esi, %ecx
cmpq %rcx, %rax
movl %eax, %edx
cmovael %ecx, %edx
subq %rdx, %rax
movq %rax, 0xb8(%rbx)
movq %rdx, -0x50(%rbp)
testl %edx, %edx
je 0x6044
movq -0x38(%rbp), %rax
movq -0x58(%rbp), %rcx
leal (%rax,%rcx), %r14d
movq -0x50(%rbp), %rax
movl %eax, %r13d
andl $0x7fff, %r14d          # imm = 0x7FFF
movl $0x8000, %r15d          # imm = 0x8000
subl %r14d, %r15d
cmpl %r13d, %r15d
cmovael %r13d, %r15d
movq -0x70(%rbp), %rax
leaq (%rax,%r14), %rdi
movq 0xb0(%rbx), %rsi
movq %r15, %rdx
callq 0x31e0
cmpl $0x100, %r14d           # imm = 0x100
ja 0x6035
movq -0x90(%rbp), %rax
leaq (%rax,%r14), %rdi
movq 0xb0(%rbx), %rsi
movl $0x101, %edx            # imm = 0x101
subl %r14d, %edx
cmpl %edx, %r15d
cmovbl %r15d, %edx
callq 0x31e0
addq %r15, 0xb0(%rbx)
addl %r15d, %r14d
subl %r15d, %r13d
jne 0x5fd8
movq -0x50(%rbp), %rdx
addl -0x58(%rbp), %edx
movl $0x8000, %r15d          # imm = 0x8000
subl %edx, %r15d
movl -0x3c(%rbp), %eax
cmpl %eax, %r15d
cmovael %eax, %r15d
cmpl $0x0, 0xa8(%rbx)
jne 0x608b
movl $0x3, %eax
cmpl $0x1000, %edx           # imm = 0x1000
jae 0x608b
movl %edx, %esi
movq -0x38(%rbp), %r9
movl -0x2c(%rbp), %r11d
movq -0x78(%rbp), %r13
movl -0x30(%rbp), %r10d
jmp 0x64fb
movq -0x38(%rbp), %r9
movl -0x2c(%rbp), %r11d
movq -0x78(%rbp), %r13
movl -0x30(%rbp), %r10d
cmpl $0x3, %edx
jbe 0x6405
movq %rdx, -0x50(%rbp)
movl %r12d, %edi
movl 0xc8(%rbx,%rdi), %ecx
movl %ecx, %r8d
andl $0xffffff, %r8d         # imm = 0xFFFFFF
movl %r8d, %eax
shrl $0x11, %eax
movl %ecx, %esi
andl $0xfff, %esi            # imm = 0xFFF
xorl %eax, %esi
movzwl 0x292aa(%rbx,%rsi,2), %edx
movw %r9w, 0x292aa(%rbx,%rsi,2)
movq %r9, -0x38(%rbp)
movl %r9d, %esi
subl %edx, %esi
movzwl %si, %eax
cmpl %eax, %r15d
jb 0x61c4
movl %edx, %r9d
andl $0x7fff, %r9d           # imm = 0x7FFF
movl %r10d, -0x30(%rbp)
movq -0x70(%rbp), %r10
movl (%r10,%r9), %r10d
movl $0xffffff, %r14d        # imm = 0xFFFFFF
andl %r14d, %r10d
cmpl %r8d, %r10d
movl -0x30(%rbp), %r10d
jne 0x61c4
movl %r11d, -0x2c(%rbp)
movq -0x70(%rbp), %r8
addq %rdi, %r8
movq %r8, -0x58(%rbp)
movq -0x88(%rbp), %r8
leaq (%r8,%rdi), %r10
movl %edx, %r11d
andl $0x7fff, %r11d          # imm = 0x7FFF
addq %r8, %r11
addq %rbx, %rdi
addq %rbx, %r9
xorl %r14d, %r14d
movzwl 0xca(%rdi,%r14), %r8d
cmpw 0xca(%r9,%r14), %r8w
jne 0x62b2
movzwl 0xcc(%rdi,%r14), %r8d
cmpw 0xcc(%r9,%r14), %r8w
jne 0x62bd
movzwl 0xce(%rdi,%r14), %r8d
cmpw 0xce(%r9,%r14), %r8w
jne 0x62c8
movzwl 0xd0(%rdi,%r14), %r8d
cmpw 0xd0(%r9,%r14), %r8w
sete %r8b
jne 0x62df
addq $0x8, %r14
cmpl $0x100, %r14d           # imm = 0x100
jne 0x614e
jmp 0x62f7
movb %cl, (%r13)
movq -0x48(%rbp), %rdi
shrb (%rdi)
incq %r13
movzbl %cl, %eax
movq -0x68(%rbp), %rcx
leaq (%rcx,%rax,2), %rax
movl $0x1, %r14d
movq -0x38(%rbp), %r9
incw (%rax)
xorl %eax, %eax
decl %r10d
cmoveq %r13, %rdi
sete %cl
movl $0x8, %edx
cmovel %edx, %r10d
addl %r14d, %r15d
movl $0x8000, %edx           # imm = 0x8000
cmpl %edx, %r15d
cmovael %edx, %r15d
movq -0x50(%rbp), %rdx
subl %r14d, %edx
jb 0x6548
movb %cl, %al
addq %rax, %r13
addl %r14d, %r11d
addl %r14d, %r9d
movb $0x1, %cl
cmpq -0x80(%rbp), %r13
movq %rdi, -0x48(%rbp)
jbe 0x629b
movq %r9, -0x38(%rbp)
movl %r9d, 0x24(%rbx)
movq %rdx, -0x50(%rbp)
movl %edx, 0x28(%rbx)
movl %r15d, 0x2c(%rbx)
movl %r11d, -0x2c(%rbp)
movl %r11d, 0x54(%rbx)
movq %r13, 0x30(%rbx)
movq %rdi, 0x38(%rbx)
movl %r10d, -0x30(%rbp)
movl %r10d, 0x50(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x6ffc
testl %eax, %eax
sete %cl
je 0x627f
notl %eax
shrl $0x1f, %eax
movl %eax, -0x5c(%rbp)
movl -0x2c(%rbp), %r11d
movl -0x30(%rbp), %r10d
jmp 0x6293
movl 0x54(%rbx), %r11d
movq 0x30(%rbx), %r13
movq 0x38(%rbx), %rax
movq %rax, -0x48(%rbp)
movl 0x50(%rbx), %r10d
movq -0x38(%rbp), %r9
movq -0x50(%rbp), %rdx
addl %r14d, %r12d
andl $0x7fff, %r12d          # imm = 0x7FFF
testb %cl, %cl
jne 0x609b
jmp 0x64f4
addq %r14, %rdi
movl $0xca, %r8d
jmp 0x62d1
addq %r14, %rdi
movl $0xcc, %r8d
jmp 0x62d1
addq %r14, %rdi
movl $0xce, %r8d
addq %r8, %rdi
addq %r14, %r9
addq %r8, %r9
xorl %r8d, %r8d
jmp 0x62f1
addq %r14, %rdi
movl $0xd0, %r10d
addq %r10, %rdi
addq %r14, %r9
addq %r10, %r9
movq %rdi, %r10
movq %r9, %r11
movl %r10d, %edi
subl -0x58(%rbp), %edi
andl $-0x2, %edi
movb (%r10), %r9b
xorl %r10d, %r10d
cmpb (%r11), %r9b
sete %r10b
orl %edi, %r10d
movq -0x38(%rbp), %r9
cmpw %dx, %r9w
movl $0x102, %r14d           # imm = 0x102
movl $0x0, %edi
cmovel %edi, %r14d
testb %r8b, %r8b
cmovel %r10d, %r14d
cmpl $0x3, %r14d
jb 0x6341
cmpl $0x2000, %eax           # imm = 0x2000
jb 0x636c
cmpl $0x3, %r14d
jne 0x636c
movb %cl, (%r13)
movq -0x48(%rbp), %rdi
shrb (%rdi)
incq %r13
movzbl %cl, %eax
movq -0x68(%rbp), %rcx
leaq (%rcx,%rax,2), %rax
movl $0x1, %r14d
movl -0x2c(%rbp), %r11d
movl -0x30(%rbp), %r10d
jmp 0x61e6
cmpw %dx, %r9w
movl -0x2c(%rbp), %r11d
movl -0x30(%rbp), %r10d
movq -0x48(%rbp), %rdi
je 0x6567
movzwl %si, %ecx
cmpl $0x8001, %ecx           # imm = 0x8001
jae 0x6567
movq -0x50(%rbp), %rcx
cmpl %ecx, %r14d
cmovael %ecx, %r14d
decl %eax
leal -0x3(%r14), %ecx
movb %cl, (%r13)
movw %ax, 0x1(%r13)
addq $0x3, %r13
movb (%rdi), %dl
shrb %dl
orb $-0x80, %dl
movb %dl, (%rdi)
movl %eax, %edx
andl $0x1ff, %edx            # imm = 0x1FF
leaq 0x103c9(%rip), %rsi     # 0x16790
addq %rsi, %rdx
movl %eax, %esi
shrl $0x8, %esi
leaq 0x105ba(%rip), %r8      # 0x16990
addq %r8, %rsi
cmpl $0x200, %eax            # imm = 0x200
cmovbq %rdx, %rsi
movzbl (%rsi), %eax
incw 0x840a(%rbx,%rax,2)
leaq 0x1061c(%rip), %rax     # 0x16a10
movzwl (%rax,%rcx,2), %eax
movq -0x68(%rbp), %rcx
leaq (%rcx,%rax,2), %rax
jmp 0x61e6
movl %edx, %esi
movq -0x48(%rbp), %rdx
subl $0x1, %esi
jb 0x6509
movl %r12d, %eax
movzbl 0xc8(%rbx,%rax), %eax
movb %al, (%r13)
shrb (%rdx)
incl %r11d
leaq 0x1(%r13), %rcx
decl %r10d
addq $0x2, %r13
testl %r10d, %r10d
cmoveq %rcx, %rdx
cmovneq %rcx, %r13
movl $0x8, %ecx
cmovel %ecx, %r10d
incw 0x81ca(%rbx,%rax,2)
incl %r9d
incl %r15d
movl $0x8000, %eax           # imm = 0x8000
cmpl %eax, %r15d
cmovael %eax, %r15d
movb $0x1, %cl
cmpq -0x80(%rbp), %r13
jbe 0x64db
movq %r9, -0x38(%rbp)
movl %r9d, 0x24(%rbx)
movq %rsi, -0x58(%rbp)
movl %esi, 0x28(%rbx)
movl %r15d, -0x3c(%rbp)
movl %r15d, 0x2c(%rbx)
movl %r11d, -0x2c(%rbp)
movl %r11d, 0x54(%rbx)
movq %r13, 0x30(%rbx)
movq %rdx, %r14
movq %rdx, 0x38(%rbx)
movl %r10d, %r15d
movl %r10d, 0x50(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x6ffc
testl %eax, %eax
sete %cl
je 0x64bf
notl %eax
shrl $0x1f, %eax
movl %eax, -0x5c(%rbp)
movl -0x2c(%rbp), %r11d
movl %r15d, %r10d
movq %r14, %rdx
jmp 0x64cf
movl 0x54(%rbx), %r11d
movq 0x30(%rbx), %r13
movq 0x38(%rbx), %rdx
movl 0x50(%rbx), %r10d
movq -0x38(%rbp), %r9
movl -0x3c(%rbp), %r15d
movq -0x58(%rbp), %rsi
incl %r12d
andl $0x7fff, %r12d          # imm = 0x7FFF
testb %cl, %cl
jne 0x640b
movl $0x1, %eax
jmp 0x64ff
movl $0x1, %eax
movl %edx, %esi
movq -0x48(%rbp), %rdx
testl %eax, %eax
je 0x5f67
jmp 0x650f
xorl %eax, %eax
xorl %esi, %esi
jmp 0x64ff
cmpl $0x3, %eax
jne 0x6536
movl %r9d, 0x24(%rbx)
movl %esi, 0x28(%rbx)
movl %r15d, 0x2c(%rbx)
movl %r11d, 0x54(%rbx)
movq %r13, 0x30(%rbx)
movq %rdx, 0x38(%rbx)
movl %r10d, 0x50(%rbx)
movl $0x1, %eax
jmp 0x6539
movl -0x5c(%rbp), %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x112c3(%rip), %rdi     # 0x17812
leaq 0x10be8(%rip), %rsi     # 0x1713e
leaq 0x11285(%rip), %rcx     # 0x177e2
movl $0x613, %edx            # imm = 0x613
callq 0x3170
leaq 0x1120a(%rip), %rdi     # 0x17778
leaq 0x10bc9(%rip), %rsi     # 0x1713e
leaq 0x11266(%rip), %rcx     # 0x177e2
movl $0x5f2, %edx            # imm = 0x5F2
callq 0x3170