// File: /workspace/github_c_makefile_star2_O3/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 0x978d
cmpq $0x9, %rsi
jb 0x978d
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), %rax
movq %rax, -0x28(%rsp)
movzbl -0x1(%r14), %eax
movzwl (%r8), %edx
leal -0x1(%rdx), %ecx
movl $0x1, %esi
shll %cl, %esi
movq %rdx, -0x8(%rsp)
testl %edx, %edx
movslq %esi, %rcx
movl $0x1, %esi
cmovneq %rcx, %rsi
leaq 0x4(%r8), %rdx
leaq 0x4(%r8,%rsi,4), %r12
movl 0x4(%r12,%rax,8), %esi
leal 0x8000(%rsi), %r11d
movl %r11d, %ecx
shrl $0x10, %ecx
andl $0xffff0000, %r11d      # imm = 0xFFFF0000
subl %esi, %r11d
shrq %cl, %r11
movslq (%r12,%rax,8), %rax
leaq (%r8,%r11,2), %rcx
addq $0x4, %rcx
movzwl (%rcx,%rax,2), %ebx
testb $0x1, %r10b
jne 0x9790
movzbl -0x2(%r14), %eax
addq $-0x2, %r14
movslq (%r12,%rax,8), %rsi
movl 0x4(%r12,%rax,8), %eax
leal 0x8000(%rax), %r11d
movl %r11d, %ecx
shrl $0x10, %ecx
andl $0xffff0000, %r11d      # imm = 0xFFFF0000
subl %eax, %r11d
shrq %cl, %r11
leaq (%rdx,%r11,2), %rax
movzwl (%rax,%rsi,2), %r13d
xorl %ebp, %ebp
xorl %eax, %eax
movq %rdi, %r15
jmp 0x9822
xorl %eax, %eax
retq
movzbl -0x2(%r14), %eax
movl 0x4(%r12,%rax,8), %esi
leal 0x8000(%rsi), %r11d
movl %r11d, %ecx
shrl $0x10, %ecx
andl $0xffff0000, %r11d      # imm = 0xFFFF0000
subl %esi, %r11d
shrq %cl, %r11
movzwl %bx, %r15d
movslq (%r12,%rax,8), %rax
leaq (%rdx,%r11,2), %rcx
movzwl (%rcx,%rax,2), %ebx
movzbl -0x3(%r14), %r11d
movl 0x4(%r12,%r11,8), %esi
addq %r15, %rsi
movq %rsi, %rax
shrq $0x10, %rax
leaq 0xb891(%rip), %rcx      # 0x15070
movl (%rcx,%rax,4), %ebp
andl %r15d, %ebp
movl %eax, %ecx
shrq %cl, %r15
addq $-0x3, %r14
movslq (%r12,%r11,8), %rcx
leaq (%rdx,%r15,2), %r11
movzwl (%r11,%rcx,2), %r13d
shrq $0x13, %rsi
leaq (%rdi,%rsi), %r15
movq %rbp, (%rdi)
testl %r9d, %r9d
jne 0x9817
movq -0x28(%rsp), %rcx
cmpq %rcx, %r15
cmovaq %rcx, %r15
andl $0x7, %eax
shll $0x3, %esi
movl %esi, %ecx
shrq %cl, %rbp
movzwl %bx, %ebx
movzwl %r13w, %r13d
testb $0x2, %r10b
movq %rdi, -0x10(%rsp)
jne 0x98e5
movzbl -0x1(%r14), %ecx
movslq (%r12,%rcx,8), %r10
movl 0x4(%r12,%rcx,8), %esi
addq %rbx, %rsi
shrq $0x10, %rsi
leaq 0xb81c(%rip), %rcx      # 0x15070
movl (%rcx,%rsi,4), %r11d
andl %ebx, %r11d
movl %eax, %ecx
shlq %cl, %r11
addl %esi, %eax
movl %esi, %ecx
shrq %cl, %rbx
leaq (%r8,%rbx,2), %rcx
addq $0x4, %rcx
movzwl (%rcx,%r10,2), %ebx
movzbl -0x2(%r14), %edi
movl 0x4(%r12,%rdi,8), %esi
addq %r13, %rsi
shrq $0x10, %rsi
leaq 0xb7e4(%rip), %rcx      # 0x15070
movl (%rcx,%rsi,4), %r10d
andl %r13d, %r10d
movl %eax, %ecx
shlq %cl, %r10
addq $-0x2, %r14
movslq (%r12,%rdi,8), %rdi
orq %r11, %r10
orq %rbp, %r10
movl %esi, %ecx
shrq %cl, %r13
addl %esi, %eax
leaq (%r8,%r13,2), %rcx
addq $0x4, %rcx
movzwl (%rcx,%rdi,2), %r13d
movl %eax, %ecx
shrl $0x3, %ecx
leaq (%r15,%rcx), %r8
movq %r10, (%r15)
testl %r9d, %r9d
jne 0x98d7
movq -0x28(%rsp), %rsi
cmpq %rsi, %r8
cmovaq %rsi, %r8
andl $0x7, %eax
shll $0x3, %ecx
shrq %cl, %r10
movq %r10, %rbp
jmp 0x98e8
movq %r15, %r8
movq -0x20(%rsp), %rcx
cmpq %rcx, %r14
jbe 0x9a18
leaq 0xb773(%rip), %r10      # 0x15070
movl %r9d, -0x14(%rsp)
movq -0x28(%rsp), %r15
movzbl -0x1(%r14), %edi
movl 0x4(%r12,%rdi,8), %esi
addq %rbx, %rsi
shrq $0x10, %rsi
movl (%r10,%rsi,4), %r11d
andl %ebx, %r11d
movl %eax, %ecx
shlq %cl, %r11
movslq (%r12,%rdi,8), %rdi
orq %rbp, %r11
addl %esi, %eax
movl %esi, %ecx
shrq %cl, %rbx
leaq (%rdx,%rbx,2), %rcx
movzwl (%rcx,%rdi,2), %r9d
movzbl -0x2(%r14), %ecx
movslq (%r12,%rcx,8), %rdi
movl 0x4(%r12,%rcx,8), %esi
addq %r13, %rsi
shrq $0x10, %rsi
movl (%r10,%rsi,4), %ebp
andl %r13d, %ebp
movl %eax, %ecx
shlq %cl, %rbp
movl %esi, %ecx
shrq %cl, %r13
orq %r11, %rbp
addl %esi, %eax
leaq (%rdx,%r13,2), %rcx
movzwl (%rcx,%rdi,2), %r13d
movzbl -0x3(%r14), %ebx
movl 0x4(%r12,%rbx,8), %esi
addq %r9, %rsi
shrq $0x10, %rsi
movl %r9d, %edi
andl (%r10,%rsi,4), %edi
movl %eax, %ecx
shlq %cl, %rdi
orq %rbp, %rdi
movl %esi, %ecx
shrq %cl, %r9
leal (%rsi,%rax), %ecx
movzbl -0x4(%r14), %r11d
movl 0x4(%r12,%r11,8), %eax
addq %r13, %rax
shrq $0x10, %rax
movl %r13d, %ebp
andl (%r10,%rax,4), %ebp
shlq %cl, %rbp
orq %rdi, %rbp
addq $-0x4, %r14
leal (%rax,%rcx), %esi
movl %eax, %ecx
shrq %cl, %r13
movl %esi, %eax
shrl $0x3, %eax
movl %eax, %eax
addq %r8, %rax
cmpq %r15, %rax
movslq (%r12,%rbx,8), %rcx
leaq (%rdx,%r9,2), %rdi
movzwl (%rdi,%rcx,2), %ebx
movq %rax, %rdi
cmovaq %r15, %rdi
cmpl $0x0, -0x14(%rsp)
cmovneq %rax, %rdi
movslq (%r12,%r11,8), %rax
leaq (%rdx,%r13,2), %rcx
movzwl (%rcx,%rax,2), %r13d
movq %rbp, (%r8)
movl %esi, %eax
andb $-0x8, %sil
movl %esi, %ecx
shrq %cl, %rbp
andl $0x7, %eax
movq %rdi, %r8
cmpq -0x20(%rsp), %r14
ja 0x9907
jmp 0x9a20
movq %r8, %rdi
movq -0x28(%rsp), %r15
movq -0x8(%rsp), %r9
movl %r9d, %ecx
leaq 0xb641(%rip), %rdx      # 0x15070
movl (%rdx,%rcx,4), %r8d
andl %r8d, %ebx
movl %eax, %ecx
shlq %cl, %rbx
orq %rbp, %rbx
addl %r9d, %eax
movl %eax, %esi
shrl $0x3, %esi
addq %rdi, %rsi
cmpq %r15, %rsi
cmovaq %r15, %rsi
movq %rbx, (%rdi)
movl %eax, %edx
andb $-0x8, %al
movl %eax, %ecx
shrq %cl, %rbx
andl $0x7, %edx
andl %r8d, %r13d
movl %edx, %ecx
shlq %cl, %r13
orq %rbx, %r13
addl %r9d, %edx
movl %edx, %edi
shrl $0x3, %edi
addq %rsi, %rdi
cmpq %r15, %rdi
cmovaq %r15, %rdi
movq %r13, (%rsi)
movl %edx, %esi
andb $-0x8, %dl
movl %edx, %ecx
shrq %cl, %r13
andl $0x7, %esi
btsq %rsi, %r13
incl %esi
movl %esi, %eax
shrl $0x3, %eax
movq %r13, (%rdi)
addq %rdi, %rax
cmpq %r15, %rax
cmovaq %r15, %rax
cmpq %r15, %rax
jae 0x9abd
andl $0x7, %esi
cmpl $0x1, %esi
movq -0x10(%rsp), %rcx
adcq $-0x1, %rcx
subq %rcx, %rax
jmp 0x9abf
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq