// File: /workspace/github_c_makefile_star2_O0/Cyan4973[P]FiniteStateEntropy/programs/../lib/fseU16.c
// Function: FSE_compressU16
size_t FSE_compressU16(void* dst, size_t maxDstSize,
       const unsigned short* src, size_t srcSize,
       unsigned maxSymbolValue, unsigned tableLog)
{
    const U16* const istart = src;
    const U16* ip = istart;

    BYTE* const ostart = (BYTE*) dst;
    BYTE* const omax = ostart + maxDstSize;
    BYTE* op = ostart;

    U32   counting[FSE_MAX_SYMBOL_VALUE+1] = {0};
    S16   norm[FSE_MAX_SYMBOL_VALUE+1];

    /* checks */
    if (srcSize <= 1) return srcSize;
    if (!maxSymbolValue) maxSymbolValue = FSE_MAX_SYMBOL_VALUE;
    if (!tableLog) tableLog = FSE_DEFAULT_TABLELOG;
    if (maxSymbolValue > FSE_MAX_SYMBOL_VALUE) return ERROR(maxSymbolValue_tooLarge);
    if (tableLog > FSE_MAX_TABLELOG) return ERROR(tableLog_tooLarge);

    /* Scan for stats */
    {   size_t const maxCount = FSE_countU16 (counting, &maxSymbolValue, ip, srcSize);
        if (FSE_isError(maxCount)) return maxCount;
        if (maxCount == srcSize) return 1;   /* src contains one constant element x srcSize times. Use RLE compression. */
    }
    /* Normalize */
    tableLog = FSE_optimalTableLog(tableLog, srcSize, maxSymbolValue);
    {   size_t const errorCode = FSE_normalizeCount (norm, tableLog, counting, srcSize, maxSymbolValue);
        if (FSE_isError(errorCode)) return errorCode;
    }
    /* Write table description header */
    {   size_t const NSize = FSE_writeNCount (op, omax-op, norm, maxSymbolValue, tableLog);
        if (FSE_isError(NSize)) return NSize;
        op += NSize;
    }
    /* Compress */
    {   FSE_CTable CTable[FSE_CTABLE_SIZE_U32(FSE_MAX_TABLELOG, FSE_MAX_SYMBOL_VALUE)];
        size_t const errorCode = FSE_buildCTableU16 (CTable, norm, maxSymbolValue, tableLog);
        if (FSE_isError(errorCode)) return errorCode;
        op += FSE_compressU16_usingCTable (op, omax - op, ip, srcSize, CTable);
    }

    /* check compressibility */
    if ( (size_t)(op-ostart) >= (size_t)(srcSize-1)*(sizeof(U16)) )
        return 0;   /* no compression */

    return op-ostart;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x5050, %rsp           # imm = 0x5050
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movl %r9d, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0x4e0(%rbp), %rdi
xorl %esi, %esi
movl $0x47c, %edx            # imm = 0x47C
callq 0x10c0
cmpq $0x1, -0x28(%rbp)
ja 0x13f56
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x14141
cmpl $0x0, -0x2c(%rbp)
jne 0x13f63
movl $0x11e, -0x2c(%rbp)     # imm = 0x11E
cmpl $0x0, -0x30(%rbp)
jne 0x13f70
movl $0xc, -0x30(%rbp)
cmpl $0x11e, -0x2c(%rbp)     # imm = 0x11E
jbe 0x13f86
movq $-0x6, -0x8(%rbp)
jmp 0x14141
cmpl $0xd, -0x30(%rbp)
jbe 0x13f99
movq $-0x5, -0x8(%rbp)
jmp 0x14141
leaq -0x4e0(%rbp), %rdi
movq -0x40(%rbp), %rdx
movq -0x28(%rbp), %rcx
leaq -0x2c(%rbp), %rsi
callq 0x138c0
movq %rax, -0x728(%rbp)
movq -0x728(%rbp), %rdi
callq 0x14150
cmpl $0x0, %eax
je 0x13fd9
movq -0x728(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x14141
movq -0x728(%rbp), %rax
cmpq -0x28(%rbp), %rax
jne 0x13ff3
movq $0x1, -0x8(%rbp)
jmp 0x14141
movl -0x30(%rbp), %edi
movq -0x28(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x118c0
movl %eax, -0x30(%rbp)
leaq -0x720(%rbp), %rdi
movl -0x30(%rbp), %esi
leaq -0x4e0(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl -0x2c(%rbp), %r8d
callq 0x118f0
movq %rax, -0x730(%rbp)
movq -0x730(%rbp), %rdi
callq 0x14150
cmpl $0x0, %eax
je 0x1404b
movq -0x730(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x14141
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x58(%rbp), %rax
subq %rax, %rsi
leaq -0x720(%rbp), %rdx
movl -0x2c(%rbp), %ecx
movl -0x30(%rbp), %r8d
callq 0x112c0
movq %rax, -0x738(%rbp)
movq -0x738(%rbp), %rdi
callq 0x14150
cmpl $0x0, %eax
je 0x14095
movq -0x738(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x14141
movq -0x738(%rbp), %rax
addq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0x5040(%rbp), %rdi
leaq -0x720(%rbp), %rsi
movl -0x2c(%rbp), %edx
movl -0x30(%rbp), %ecx
callq 0x13450
movq %rax, -0x5048(%rbp)
movq -0x5048(%rbp), %rdi
callq 0x14150
cmpl $0x0, %eax
je 0x140e2
movq -0x5048(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x14141
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x58(%rbp), %rax
subq %rax, %rsi
movq -0x40(%rbp), %rdx
movq -0x28(%rbp), %rcx
leaq -0x5040(%rbp), %r8
callq 0x13a00
addq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq -0x48(%rbp), %rcx
subq %rcx, %rax
movq -0x28(%rbp), %rcx
subq $0x1, %rcx
shlq %rcx
cmpq %rcx, %rax
jb 0x14132
movq $0x0, -0x8(%rbp)
jmp 0x14141
movq -0x58(%rbp), %rax
movq -0x48(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x5050, %rsp           # imm = 0x5050
popq %rbp
retq
nop