// File: /workspace/github_c_makefile_star2_O1/Cyan4973[P]FiniteStateEntropy/programs/../lib/fse_compress.c
// Function: FSE_compress_usingCTable_generic
static size_t FSE_compress_usingCTable_generic (void* dst, size_t dstSize,
                           const void* src, size_t srcSize,
                           const FSE_CTable* ct, const unsigned fast)
{
    const BYTE* const istart = (const BYTE*) src;
    const BYTE* const iend = istart + srcSize;
    const BYTE* ip=iend;

    BIT_CStream_t bitC;
    FSE_CState_t CState1, CState2;

    /* init */
    if (srcSize <= 2) return 0;
    { size_t const initError = BIT_initCStream(&bitC, dst, dstSize);
      if (FSE_isError(initError)) return 0; /* not enough space available to write a bitstream */ }

#define FSE_FLUSHBITS(s)  (fast ? BIT_flushBitsFast(s) : BIT_flushBits(s))

    if (srcSize & 1) {
        FSE_initCState2(&CState1, ct, *--ip);
        FSE_initCState2(&CState2, ct, *--ip);
        FSE_encodeSymbol(&bitC, &CState1, *--ip);
        FSE_FLUSHBITS(&bitC);
    } else {
        FSE_initCState2(&CState2, ct, *--ip);
        FSE_initCState2(&CState1, ct, *--ip);
    }

    /* join to mod 4 */
    srcSize -= 2;
    if ((sizeof(bitC.bitContainer)*8 > FSE_MAX_TABLELOG*4+7 ) && (srcSize & 2)) {  /* test bit 2 */
        FSE_encodeSymbol(&bitC, &CState2, *--ip);
        FSE_encodeSymbol(&bitC, &CState1, *--ip);
        FSE_FLUSHBITS(&bitC);
    }

    /* 2 or 4 encoding per loop */
    while ( ip>istart ) {

        FSE_encodeSymbol(&bitC, &CState2, *--ip);

        if (sizeof(bitC.bitContainer)*8 < FSE_MAX_TABLELOG*2+7 )   /* this test must be static */
            FSE_FLUSHBITS(&bitC);

        FSE_encodeSymbol(&bitC, &CState1, *--ip);

        if (sizeof(bitC.bitContainer)*8 > FSE_MAX_TABLELOG*4+7 ) {  /* this test must be static */
            FSE_encodeSymbol(&bitC, &CState2, *--ip);
            FSE_encodeSymbol(&bitC, &CState1, *--ip);
        }

        FSE_FLUSHBITS(&bitC);
    }

    FSE_flushCState(&bitC, &CState2);
    FSE_flushCState(&bitC, &CState1);
    return BIT_closeCStream(&bitC);
}

// Assembly:
cmpq $0x3, %rcx
jb 0x8f2a
cmpq $0x9, %rsi
jb 0x8f2a
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %r10
movq %rdx, -0x20(%rsp)
leaq (%rdx,%rcx), %r14
leaq -0x8(%rdi,%rsi), %r15
movzbl -0x1(%r14), %eax
movzwl (%r8), %esi
leal -0x1(%rsi), %ecx
movl $0x1, %edx
shll %cl, %edx
movq %rsi, -0x10(%rsp)
testl %esi, %esi
movslq %edx, %rcx
movl $0x1, %edx
cmovneq %rcx, %rdx
leaq 0x4(%r8), %r13
leaq 0x4(%r8,%rdx,4), %r12
movl 0x4(%r12,%rax,8), %edx
leal 0x8000(%rdx), %esi
movl %esi, %ecx
shrl $0x10, %ecx
andl $0xffff0000, %esi       # imm = 0xFFFF0000
subl %edx, %esi
shrq %cl, %rsi
movslq (%r12,%rax,8), %rax
leaq (%r8,%rsi,2), %rcx
addq $0x4, %rcx
movzwl (%rcx,%rax,2), %ebx
testb $0x1, %r10b
movq %r15, -0x30(%rsp)
movl %r9d, -0x24(%rsp)
movq %r13, -0x18(%rsp)
jne 0x8f2d
movzbl -0x2(%r14), %eax
addq $-0x2, %r14
movslq (%r12,%rax,8), %rdx
movl 0x4(%r12,%rax,8), %eax
leal 0x8000(%rax), %esi
movl %esi, %ecx
shrl $0x10, %ecx
andl $0xffff0000, %esi       # imm = 0xFFFF0000
subl %eax, %esi
shrq %cl, %rsi
leaq (,%rsi,2), %rax
addq %r13, %rax
movzwl (%rax,%rdx,2), %edx
xorl %ebp, %ebp
xorl %eax, %eax
movq %rdi, %r11
jmp 0x8fd8
xorl %eax, %eax
retq
movzbl -0x2(%r14), %eax
movl 0x4(%r12,%rax,8), %edx
leal 0x8000(%rdx), %esi
movl %esi, %ecx
shrl $0x10, %ecx
andl $0xffff0000, %esi       # imm = 0xFFFF0000
subl %edx, %esi
shrq %cl, %rsi
movzwl %bx, %edx
movslq (%r12,%rax,8), %rax
leaq (,%rsi,2), %rcx
addq %r13, %rcx
movzwl (%rcx,%rax,2), %ebx
movzbl -0x3(%r14), %r11d
movl 0x4(%r12,%r11,8), %esi
addq %rdx, %rsi
movq %rsi, %rax
shrq $0x10, %rax
leaq 0xafd2(%rip), %rcx      # 0x13f50
movl (%rcx,%rax,4), %ebp
andl %edx, %ebp
movl %eax, %ecx
shrq %cl, %rdx
addq $-0x3, %r14
movslq (%r12,%r11,8), %rcx
leaq (,%rdx,2), %rdx
addq %r13, %rdx
movzwl (%rdx,%rcx,2), %edx
shrq $0x13, %rsi
leaq (%rdi,%rsi), %r11
movq %rbp, (%rdi)
testl %r9d, %r9d
je 0x8fc1
andl $0x7, %eax
shll $0x3, %esi
movl %esi, %ecx
shrq %cl, %rbp
movq -0x30(%rsp), %r15
jmp 0x8fd8
movq -0x30(%rsp), %r15
cmpq %r15, %r11
cmovaq %r15, %r11
andl $0x7, %eax
shll $0x3, %esi
movl %esi, %ecx
shrq %cl, %rbp
movq %rdi, -0x8(%rsp)
movzwl %bx, %ebx
movzwl %dx, %r13d
testb $0x2, %r10b
jne 0x908c
movzbl -0x1(%r14), %ecx
movslq (%r12,%rcx,8), %r9
movl 0x4(%r12,%rcx,8), %esi
addq %rbx, %rsi
shrq $0x10, %rsi
leaq 0xaf46(%rip), %rdi      # 0x13f50
movl (%rdi,%rsi,4), %edx
andl %ebx, %edx
movl %eax, %ecx
shlq %cl, %rdx
addl %esi, %eax
movl %esi, %ecx
shrq %cl, %rbx
leaq (%r8,%rbx,2), %rcx
addq $0x4, %rcx
movzwl (%rcx,%r9,2), %ebx
movzbl -0x2(%r14), %r9d
movl 0x4(%r12,%r9,8), %esi
addq %r13, %rsi
shrq $0x10, %rsi
movl (%rdi,%rsi,4), %edi
andl %r13d, %edi
movl %eax, %ecx
shlq %cl, %rdi
addq $-0x2, %r14
movslq (%r12,%r9,8), %r9
orq %rdx, %rdi
orq %rbp, %rdi
movl %esi, %ecx
shrq %cl, %r13
addl %esi, %eax
leaq (%r8,%r13,2), %rcx
addq $0x4, %rcx
movzwl (%rcx,%r9,2), %r13d
movl %eax, %ecx
shrl $0x3, %ecx
leaq (%r11,%rcx), %r8
movq %rdi, (%r11)
cmpl $0x0, -0x24(%rsp)
je 0x9091
andl $0x7, %eax
shll $0x3, %ecx
shrq %cl, %rdi
movq %rdi, %rbp
movq -0x30(%rsp), %r15
jmp 0x90a9
movq %r11, %r8
jmp 0x90a9
movq -0x30(%rsp), %r15
cmpq %r15, %r8
cmovaq %r15, %r8
andl $0x7, %eax
shll $0x3, %ecx
shrq %cl, %rdi
movq %rdi, %rbp
movq -0x20(%rsp), %rcx
cmpq %rcx, %r14
jbe 0x91f4
leaq 0xae92(%rip), %r11      # 0x13f50
movq -0x18(%rsp), %rdx
movq -0x30(%rsp), %r15
movzbl -0x1(%r14), %r9d
movl 0x4(%r12,%r9,8), %ecx
addq %rbx, %rcx
movq %rcx, %rsi
shrq $0xe, %rcx
movabsq $0x3fffffffc, %r10      # imm = 0x3FFFFFFFC
andq %r10, %rcx
movl (%rcx,%r11), %edi
andl %ebx, %edi
movl %eax, %ecx
shlq %cl, %rdi
movslq (%r12,%r9,8), %r9
shrq $0x10, %rsi
orq %rbp, %rdi
addl %esi, %eax
movl %esi, %ecx
shrq %cl, %rbx
leaq (%rdx,%rbx,2), %rcx
movzwl (%rcx,%r9,2), %r9d
movzbl -0x2(%r14), %ecx
movslq (%r12,%rcx,8), %rbx
movl 0x4(%r12,%rcx,8), %ecx
addq %r13, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
shrq $0xe, %rcx
andq %r10, %rcx
movl (%rcx,%r11), %r10d
andl %r13d, %r10d
movl %eax, %ecx
shlq %cl, %r10
movl %esi, %ecx
shrq %cl, %r13
orq %rdi, %r10
addl %esi, %eax
leaq (%rdx,%r13,2), %rcx
movzwl (%rcx,%rbx,2), %r13d
movzbl -0x3(%r14), %edi
movl 0x4(%r12,%rdi,8), %esi
addq %r9, %rsi
shrq $0x10, %rsi
movl %r9d, %ebx
andl (%r11,%rsi,4), %ebx
movl %eax, %ecx
shlq %cl, %rbx
orq %r10, %rbx
movl %esi, %ecx
shrq %cl, %r9
addl %esi, %eax
movzbl -0x4(%r14), %r10d
movl 0x4(%r12,%r10,8), %esi
addq %r13, %rsi
shrq $0x10, %rsi
movl %r13d, %ebp
andl (%r11,%rsi,4), %ebp
movl %eax, %ecx
shlq %cl, %rbp
movl %esi, %ecx
shrq %cl, %r13
orq %rbx, %rbp
leal (%rsi,%rax), %ecx
movslq (%r12,%rdi,8), %rax
leaq (%rdx,%r9,2), %rsi
movzwl (%rsi,%rax,2), %ebx
addq $-0x4, %r14
movslq (%r12,%r10,8), %rax
leaq (%rdx,%r13,2), %rsi
movzwl (%rsi,%rax,2), %r13d
movl %ecx, %eax
shrl $0x3, %eax
movl %eax, %eax
addq %r8, %rax
cmpq %r15, %rax
movq %rbp, (%r8)
movq %rax, %rsi
cmovaq %r15, %rsi
cmpl $0x0, -0x24(%rsp)
cmovneq %rax, %rsi
movl %ecx, %eax
andb $-0x8, %cl
shrq %cl, %rbp
andl $0x7, %eax
movq %rsi, %r8
cmpq -0x20(%rsp), %r14
ja 0x90c8
jmp 0x91f7
movq %r8, %rsi
leaq 0xad52(%rip), %r8       # 0x13f50
movq -0x10(%rsp), %r10
andl (%r8,%r10,4), %ebx
movl %eax, %ecx
shlq %cl, %rbx
orq %rbp, %rbx
addl %r10d, %eax
movl %eax, %edi
shrl $0x3, %edi
addq %rsi, %rdi
cmpq %r15, %rdi
cmovaq %r15, %rdi
movq %rbx, (%rsi)
movl %eax, %edx
andb $-0x8, %al
movl %eax, %ecx
shrq %cl, %rbx
andl $0x7, %edx
movl %r10d, %eax
andl (%r8,%rax,4), %r13d
movl %edx, %ecx
shlq %cl, %r13
orq %rbx, %r13
addl %r10d, %edx
movl %edx, %eax
shrl $0x3, %eax
movq %r13, (%rdi)
addq %rdi, %rax
cmpq %r15, %rax
cmovaq %r15, %rax
movl %edx, %esi
andl $0x7, %esi
andb $-0x8, %dl
movl %edx, %ecx
shrq %cl, %r13
btsq %rsi, %r13
incl %esi
movl %esi, %ecx
shrl $0x3, %ecx
addq %rax, %rcx
cmpq %r15, %rcx
cmovaq %r15, %rcx
movq %r13, (%rax)
andl $0x7, %esi
cmpl $0x1, %esi
movq -0x8(%rsp), %rax
adcq $-0x1, %rax
movq %rcx, %rdx
subq %rax, %rdx
xorl %eax, %eax
cmpq %r15, %rcx
cmovbq %rdx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq