lz4hc.c:LZ4_isAligned:
  294|  57.7k|{
  295|  57.7k|    return ((size_t)ptr & (alignment -1)) == 0;
  296|  57.7k|}
lz4hc.c:LZ4_read32:
  395|  3.98G|static U32 LZ4_read32(const void* ptr) { return ((const LZ4_unalign32*)ptr)->u32; }
lz4hc.c:LZ4_isLittleEndian:
  365|   560M|{
  366|   560M|    const union { U32 u; BYTE c[4]; } one = { 1 };   /* don't use static : performance detrimental */
  367|   560M|    return one.c[0];
  368|   560M|}
lz4hc.c:LZ4_count:
  690|   251M|{
  691|   251M|    const BYTE* const pStart = pIn;
  692|       |
  693|   251M|    if (likely(pIn < pInLimit-(STEPSIZE-1))) {
  ------------------
  |  |  178|   251M|#define likely(expr)     expect((expr) != 0, 1)
  |  |  ------------------
  |  |  |  |  172|   251M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 251M, False: 221k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  694|   251M|        reg_t const diff = LZ4_read_ARCH(pMatch) ^ LZ4_read_ARCH(pIn);
  695|   251M|        if (!diff) {
  ------------------
  |  Branch (695:13): [True: 67.1M, False: 184M]
  ------------------
  696|  67.1M|            pIn+=STEPSIZE; pMatch+=STEPSIZE;
  ------------------
  |  |  687|  67.1M|#define STEPSIZE sizeof(reg_t)
  ------------------
                          pIn+=STEPSIZE; pMatch+=STEPSIZE;
  ------------------
  |  |  687|  67.1M|#define STEPSIZE sizeof(reg_t)
  ------------------
  697|   184M|        } else {
  698|   184M|            return LZ4_NbCommonBytes(diff);
  699|   184M|    }   }
  700|       |
  701|  1.18G|    while (likely(pIn < pInLimit-(STEPSIZE-1))) {
  702|  1.18G|        reg_t const diff = LZ4_read_ARCH(pMatch) ^ LZ4_read_ARCH(pIn);
  703|  1.18G|        if (!diff) { pIn+=STEPSIZE; pMatch+=STEPSIZE; continue; }
  ------------------
  |  |  687|  1.11G|#define STEPSIZE sizeof(reg_t)
  ------------------
                      if (!diff) { pIn+=STEPSIZE; pMatch+=STEPSIZE; continue; }
  ------------------
  |  |  687|  1.11G|#define STEPSIZE sizeof(reg_t)
  ------------------
  |  Branch (703:13): [True: 1.11G, False: 66.9M]
  ------------------
  704|  66.9M|        pIn += LZ4_NbCommonBytes(diff);
  705|  66.9M|        return (unsigned)(pIn - pStart);
  706|  1.18G|    }
  707|       |
  708|   475k|    if ((STEPSIZE==8) && (pIn<(pInLimit-3)) && (LZ4_read32(pMatch) == LZ4_read32(pIn))) { pIn+=4; pMatch+=4; }
  ------------------
  |  |  687|   475k|#define STEPSIZE sizeof(reg_t)
  ------------------
  |  Branch (708:9): [True: 475k, Folded]
  |  Branch (708:26): [True: 258k, False: 217k]
  |  Branch (708:48): [True: 145k, False: 113k]
  ------------------
  709|   475k|    if ((pIn<(pInLimit-1)) && (LZ4_read16(pMatch) == LZ4_read16(pIn))) { pIn+=2; pMatch+=2; }
  ------------------
  |  Branch (709:9): [True: 292k, False: 182k]
  |  Branch (709:31): [True: 172k, False: 120k]
  ------------------
  710|   475k|    if ((pIn<pInLimit) && (*pMatch == *pIn)) pIn++;
  ------------------
  |  Branch (710:9): [True: 309k, False: 166k]
  |  Branch (710:27): [True: 179k, False: 129k]
  ------------------
  711|   475k|    return (unsigned)(pIn - pStart);
  712|  67.3M|}
lz4hc.c:LZ4_read_ARCH:
  396|  3.11G|static reg_t LZ4_read_ARCH(const void* ptr) { return ((const LZ4_unalignST*)ptr)->uArch; }
lz4hc.c:LZ4_NbCommonBytes:
  589|   394M|{
  590|   394M|    assert(val != 0);
  ------------------
  |  Branch (590:5): [True: 0, False: 394M]
  |  Branch (590:5): [True: 394M, False: 0]
  ------------------
  591|   394M|    if (LZ4_isLittleEndian()) {
  ------------------
  |  Branch (591:9): [True: 394M, False: 0]
  ------------------
  592|   394M|        if (sizeof(val) == 8) {
  ------------------
  |  Branch (592:13): [True: 394M, Folded]
  ------------------
  593|       |#       if defined(_MSC_VER) && (_MSC_VER >= 1800) && (defined(_M_AMD64) && !defined(_M_ARM64EC)) && !defined(LZ4_FORCE_SW_BITCOUNT)
  594|       |/*-*************************************************************************************************
  595|       |* ARM64EC is a Microsoft-designed ARM64 ABI compatible with AMD64 applications on ARM64 Windows 11.
  596|       |* The ARM64EC ABI does not support AVX/AVX2/AVX512 instructions, nor their relevant intrinsics
  597|       |* including _tzcnt_u64. Therefore, we need to neuter the _tzcnt_u64 code path for ARM64EC.
  598|       |****************************************************************************************************/
  599|       |#         if defined(__clang__) && (__clang_major__ < 10)
  600|       |            /* Avoid undefined clang-cl intrinsics issue.
  601|       |             * See https://github.com/lz4/lz4/pull/1017 for details. */
  602|       |            return (unsigned)__builtin_ia32_tzcnt_u64(val) >> 3;
  603|       |#         else
  604|       |            /* x64 CPUS without BMI support interpret `TZCNT` as `REP BSF` */
  605|       |            return (unsigned)_tzcnt_u64(val) >> 3;
  606|       |#         endif
  607|       |#       elif defined(_MSC_VER) && defined(_WIN64) && !defined(LZ4_FORCE_SW_BITCOUNT)
  608|       |            unsigned long r = 0;
  609|       |            _BitScanForward64(&r, (U64)val);
  610|       |            return (unsigned)r >> 3;
  611|       |#       elif (defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 3) || \
  612|       |                            ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))))) && \
  613|       |                                        !defined(LZ4_FORCE_SW_BITCOUNT)
  614|       |            return (unsigned)__builtin_ctzll((U64)val) >> 3;
  615|       |#       else
  616|       |            const U64 m = 0x0101010101010101ULL;
  617|       |            val ^= val - 1;
  618|       |            return (unsigned)(((U64)((val & (m - 1)) * m)) >> 56);
  619|       |#       endif
  620|   394M|        } else /* 32 bits */ {
  621|       |#       if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(LZ4_FORCE_SW_BITCOUNT)
  622|       |            unsigned long r;
  623|       |            _BitScanForward(&r, (U32)val);
  624|       |            return (unsigned)r >> 3;
  625|       |#       elif (defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 3) || \
  626|       |                            ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))))) && \
  627|       |                        !defined(__TINYC__) && !defined(LZ4_FORCE_SW_BITCOUNT)
  628|       |            return (unsigned)__builtin_ctz((U32)val) >> 3;
  629|       |#       else
  630|       |            const U32 m = 0x01010101;
  631|       |            return (unsigned)((((val - 1) ^ val) & (m - 1)) * m) >> 24;
  632|       |#       endif
  633|      0|        }
  634|   394M|    } else   /* Big Endian CPU */ {
  635|      0|        if (sizeof(val)==8) {
  ------------------
  |  Branch (635:13): [True: 0, Folded]
  ------------------
  636|      0|#       if (defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 3) || \
  637|      0|                            ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))))) && \
  638|      0|                        !defined(__TINYC__) && !defined(LZ4_FORCE_SW_BITCOUNT)
  639|      0|            return (unsigned)__builtin_clzll((U64)val) >> 3;
  640|       |#       else
  641|       |#if 1
  642|       |            /* this method is probably faster,
  643|       |             * but adds a 128 bytes lookup table */
  644|       |            static const unsigned char ctz7_tab[128] = {
  645|       |                7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  646|       |                4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  647|       |                5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  648|       |                4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  649|       |                6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  650|       |                4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  651|       |                5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  652|       |                4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  653|       |            };
  654|       |            U64 const mask = 0x0101010101010101ULL;
  655|       |            U64 const t = (((val >> 8) - mask) | val) & mask;
  656|       |            return ctz7_tab[(t * 0x0080402010080402ULL) >> 57];
  657|       |#else
  658|       |            /* this method doesn't consume memory space like the previous one,
  659|       |             * but it contains several branches,
  660|       |             * that may end up slowing execution */
  661|       |            static const U32 by32 = sizeof(val)*4;  /* 32 on 64 bits (goal), 16 on 32 bits.
  662|       |            Just to avoid some static analyzer complaining about shift by 32 on 32-bits target.
  663|       |            Note that this code path is never triggered in 32-bits mode. */
  664|       |            unsigned r;
  665|       |            if (!(val>>by32)) { r=4; } else { r=0; val>>=by32; }
  666|       |            if (!(val>>16)) { r+=2; val>>=8; } else { val>>=24; }
  667|       |            r += (!val);
  668|       |            return r;
  669|       |#endif
  670|       |#       endif
  671|      0|        } else /* 32 bits */ {
  672|      0|#       if (defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 3) || \
  673|      0|                            ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))))) && \
  674|      0|                                        !defined(LZ4_FORCE_SW_BITCOUNT)
  675|      0|            return (unsigned)__builtin_clz((U32)val) >> 3;
  676|       |#       else
  677|       |            val >>= 8;
  678|       |            val = ((((val + 0x00FFFF00) | 0x00FFFFFF) + val) |
  679|       |              (val + 0x00FF0000)) >> 24;
  680|       |            return (unsigned)val ^ 3;
  681|       |#       endif
  682|      0|        }
  683|      0|    }
  684|   394M|}
lz4hc.c:LZ4_read16:
  394|  1.61G|static U16 LZ4_read16(const void* ptr) { return ((const LZ4_unalign16*)ptr)->u16; }
lz4hc.c:LZ4_wildCopy8:
  467|  7.67M|{
  468|  7.67M|    BYTE* d = (BYTE*)dstPtr;
  469|  7.67M|    const BYTE* s = (const BYTE*)srcPtr;
  470|  7.67M|    BYTE* const e = (BYTE*)dstEnd;
  471|       |
  472|  17.8M|    do { LZ4_memcpy(d,s,8); d+=8; s+=8; } while (d<e);
  ------------------
  |  |  350|  17.8M|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  |  Branch (472:50): [True: 10.1M, False: 7.67M]
  ------------------
  473|  7.67M|}
lz4hc.c:LZ4_writeLE16:
  454|  7.67M|{
  455|  7.67M|    if (LZ4_isLittleEndian()) {
  ------------------
  |  Branch (455:9): [True: 7.67M, False: 0]
  ------------------
  456|  7.67M|        LZ4_write16(memPtr, value);
  457|  7.67M|    } else {
  458|      0|        BYTE* p = (BYTE*)memPtr;
  459|      0|        p[0] = (BYTE) value;
  460|      0|        p[1] = (BYTE)(value>>8);
  461|      0|    }
  462|  7.67M|}
lz4hc.c:LZ4_write16:
  398|  7.67M|static void LZ4_write16(void* memPtr, U16 value) { ((LZ4_unalign16*)memPtr)->u16 = value; }
LZ4_compressBound:
  760|  68.8k|int LZ4_compressBound(int isize)  { return LZ4_COMPRESSBOUND(isize); }
  ------------------
  |  |  215|  68.8k|#define LZ4_COMPRESSBOUND(isize)  ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16)
  |  |  ------------------
  |  |  |  |  214|  68.8k|#define LZ4_MAX_INPUT_SIZE        0x7E000000   /* 2 113 929 216 bytes */
  |  |  ------------------
  |  |  |  Branch (215:36): [True: 0, False: 68.8k]
  |  |  ------------------
  ------------------
LZ4_compress_fast_extState_fastReset:
 1442|  9.63k|{
 1443|  9.63k|    LZ4_stream_t_internal* const ctx = &((LZ4_stream_t*)state)->internal_donotuse;
 1444|  9.63k|    acceleration = LZ4_clampAcceleration(acceleration);
 1445|  9.63k|    assert(ctx != NULL);
  ------------------
  |  Branch (1445:5): [True: 0, False: 9.63k]
  |  Branch (1445:5): [True: 9.63k, False: 0]
  ------------------
 1446|       |
 1447|  9.63k|    if (dstCapacity >= LZ4_compressBound(srcSize)) {
  ------------------
  |  Branch (1447:9): [True: 0, False: 9.63k]
  ------------------
 1448|      0|        if (srcSize < LZ4_64Klimit) {
  ------------------
  |  Branch (1448:13): [True: 0, False: 0]
  ------------------
 1449|      0|            const tableType_t tableType = byU16;
 1450|      0|            LZ4_prepareTable(ctx, srcSize, tableType);
 1451|      0|            if (ctx->currentOffset) {
  ------------------
  |  Branch (1451:17): [True: 0, False: 0]
  ------------------
 1452|      0|                return LZ4_compress_generic(ctx, src, dst, srcSize, NULL, 0, notLimited, tableType, noDict, dictSmall, acceleration);
 1453|      0|            } else {
 1454|      0|                return LZ4_compress_generic(ctx, src, dst, srcSize, NULL, 0, notLimited, tableType, noDict, noDictIssue, acceleration);
 1455|      0|            }
 1456|      0|        } else {
 1457|      0|            const tableType_t tableType = LZ4_largeInputTableType(src);
 1458|      0|            LZ4_prepareTable(ctx, srcSize, tableType);
 1459|      0|            return LZ4_compress_generic(ctx, src, dst, srcSize, NULL, 0, notLimited, tableType, noDict, noDictIssue, acceleration);
 1460|      0|        }
 1461|  9.63k|    } else {
 1462|  9.63k|        if (srcSize < LZ4_64Klimit) {
  ------------------
  |  Branch (1462:13): [True: 8.85k, False: 785]
  ------------------
 1463|  8.85k|            const tableType_t tableType = byU16;
 1464|  8.85k|            LZ4_prepareTable(ctx, srcSize, tableType);
 1465|  8.85k|            if (ctx->currentOffset) {
  ------------------
  |  Branch (1465:17): [True: 3.07k, False: 5.77k]
  ------------------
 1466|  3.07k|                return LZ4_compress_generic(ctx, src, dst, srcSize, NULL, dstCapacity, limitedOutput, tableType, noDict, dictSmall, acceleration);
 1467|  5.77k|            } else {
 1468|  5.77k|                return LZ4_compress_generic(ctx, src, dst, srcSize, NULL, dstCapacity, limitedOutput, tableType, noDict, noDictIssue, acceleration);
 1469|  5.77k|            }
 1470|  8.85k|        } else {
 1471|    785|            const tableType_t tableType = LZ4_largeInputTableType(src);
 1472|    785|            LZ4_prepareTable(ctx, srcSize, tableType);
 1473|       |            return LZ4_compress_generic(ctx, src, dst, srcSize, NULL, dstCapacity, limitedOutput, tableType, noDict, noDictIssue, acceleration);
 1474|    785|        }
 1475|  9.63k|    }
 1476|  9.63k|}
LZ4_initStream:
 1579|  51.4k|{
 1580|  51.4k|    DEBUGLOG(5, "LZ4_initStream");
  ------------------
  |  |  290|  51.4k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1581|  51.4k|    if (buffer == NULL) { return NULL; }
  ------------------
  |  Branch (1581:9): [True: 0, False: 51.4k]
  ------------------
 1582|  51.4k|    if (size < sizeof(LZ4_stream_t)) { return NULL; }
  ------------------
  |  Branch (1582:9): [True: 0, False: 51.4k]
  ------------------
 1583|  51.4k|    if (!LZ4_isAligned(buffer, LZ4_stream_t_alignment())) return NULL;
  ------------------
  |  Branch (1583:9): [True: 0, False: 51.4k]
  ------------------
 1584|  51.4k|    MEM_INIT(buffer, 0, sizeof(LZ4_stream_t_internal));
  ------------------
  |  |  237|  51.4k|#define MEM_INIT(p,v,s)   LZ4_memset((p),(v),(s))
  |  |  ------------------
  |  |  |  |  235|  51.4k|#  define LZ4_memset(p,v,s) memset((p),(v),(s))
  |  |  ------------------
  ------------------
 1585|  51.4k|    return (LZ4_stream_t*)buffer;
 1586|  51.4k|}
LZ4_compress_fast_continue:
 1749|  31.6k|{
 1750|  31.6k|    const tableType_t tableType = byU32;
 1751|  31.6k|    LZ4_stream_t_internal* const streamPtr = &LZ4_stream->internal_donotuse;
 1752|  31.6k|    const char* dictEnd = streamPtr->dictSize ? (const char*)streamPtr->dictionary + streamPtr->dictSize : NULL;
  ------------------
  |  Branch (1752:27): [True: 18.9k, False: 12.6k]
  ------------------
 1753|       |
 1754|  31.6k|    DEBUGLOG(5, "LZ4_compress_fast_continue (inputSize=%i, dictSize=%u)", inputSize, streamPtr->dictSize);
  ------------------
  |  |  290|  31.6k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1755|       |
 1756|       |    /* new stream (no history) : clear the table beyond LZ4_CLEAR_TABLE_THRESHOLD */
 1757|  31.6k|    if ((streamPtr->dictSize == 0) && (streamPtr->dictCtx == NULL) && (inputSize >= LZ4_CLEAR_TABLE_THRESHOLD))
  ------------------
  |  |  894|  12.6k|#define LZ4_CLEAR_TABLE_THRESHOLD (LZ4_HASHTABLESIZE / 16)
  |  |  ------------------
  |  |  |  |  700|  12.6k|#define LZ4_HASHTABLESIZE (1 << LZ4_MEMORY_USAGE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|  12.6k|# define LZ4_MEMORY_USAGE LZ4_MEMORY_USAGE_DEFAULT
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  163|  12.6k|#define LZ4_MEMORY_USAGE_DEFAULT 14
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1757:9): [True: 12.6k, False: 18.9k]
  |  Branch (1757:39): [True: 12.6k, False: 0]
  |  Branch (1757:71): [True: 1.45k, False: 11.2k]
  ------------------
 1758|  1.45k|        LZ4_prepareTable(streamPtr, inputSize, byU32);
 1759|       |
 1760|  31.6k|    LZ4_renormDictT(streamPtr, inputSize);   /* fix index overflow */
 1761|  31.6k|    acceleration = LZ4_clampAcceleration(acceleration);
 1762|       |
 1763|       |    /* invalidate tiny dictionaries */
 1764|  31.6k|    if ( (streamPtr->dictSize < 4)     /* tiny dictionary : not enough for a hash */
  ------------------
  |  Branch (1764:10): [True: 17.3k, False: 14.2k]
  ------------------
 1765|  17.3k|      && (dictEnd != source)           /* prefix mode */
  ------------------
  |  Branch (1765:10): [True: 17.1k, False: 237]
  ------------------
 1766|  17.1k|      && (inputSize > 0)               /* tolerance : don't lose history, in case next invocation would use prefix mode */
  ------------------
  |  Branch (1766:10): [True: 17.1k, False: 0]
  ------------------
 1767|  17.1k|      && (streamPtr->dictCtx == NULL)  /* usingDictCtx */
  ------------------
  |  Branch (1767:10): [True: 17.1k, False: 0]
  ------------------
 1768|  31.6k|      ) {
 1769|  17.1k|        DEBUGLOG(5, "LZ4_compress_fast_continue: dictSize(%u) at addr:%p is too small", streamPtr->dictSize, (void*)streamPtr->dictionary);
  ------------------
  |  |  290|  17.1k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1770|       |        /* remove dictionary existence from history, to employ faster prefix mode */
 1771|  17.1k|        streamPtr->dictSize = 0;
 1772|  17.1k|        streamPtr->dictionary = (const BYTE*)source;
 1773|  17.1k|        dictEnd = source;
 1774|  17.1k|    }
 1775|       |
 1776|       |    /* Check overlapping input/dictionary space */
 1777|  31.6k|    {   const char* const sourceEnd = source + inputSize;
 1778|  31.6k|        if ((sourceEnd > (const char*)streamPtr->dictionary) && (source < dictEnd)) {
  ------------------
  |  Branch (1778:13): [True: 25.4k, False: 6.22k]
  |  Branch (1778:65): [True: 0, False: 25.4k]
  ------------------
 1779|       |            /* only the part of the dictionary beyond input remains */
 1780|      0|            streamPtr->dictSize = (sourceEnd < dictEnd) ? (U32)(dictEnd - sourceEnd) : 0;
  ------------------
  |  Branch (1780:35): [True: 0, False: 0]
  ------------------
 1781|      0|            if (streamPtr->dictSize > 64 KB) streamPtr->dictSize = 64 KB;
  ------------------
  |  |  252|      0|#define KB *(1 <<10)
  ------------------
                          if (streamPtr->dictSize > 64 KB) streamPtr->dictSize = 64 KB;
  ------------------
  |  |  252|      0|#define KB *(1 <<10)
  ------------------
  |  Branch (1781:17): [True: 0, False: 0]
  ------------------
 1782|      0|            if (streamPtr->dictSize < 4) streamPtr->dictSize = 0;
  ------------------
  |  Branch (1782:17): [True: 0, False: 0]
  ------------------
 1783|      0|            streamPtr->dictionary = (const BYTE*)dictEnd - streamPtr->dictSize;
 1784|      0|        }
 1785|  31.6k|    }
 1786|       |
 1787|       |    /* prefix mode : source data follows dictionary */
 1788|  31.6k|    if (dictEnd == source) {
  ------------------
  |  Branch (1788:9): [True: 20.0k, False: 11.5k]
  ------------------
 1789|  20.0k|        if (LZ4_isDictSmall(streamPtr))
  ------------------
  |  Branch (1789:13): [True: 4.51k, False: 15.5k]
  ------------------
 1790|  4.51k|            return LZ4_compress_generic(streamPtr, source, dest, inputSize, NULL, maxOutputSize, limitedOutput, tableType, withPrefix64k, dictSmall, acceleration);
 1791|  15.5k|        else
 1792|  15.5k|            return LZ4_compress_generic(streamPtr, source, dest, inputSize, NULL, maxOutputSize, limitedOutput, tableType, withPrefix64k, noDictIssue, acceleration);
 1793|  20.0k|    }
 1794|       |
 1795|       |    /* external dictionary mode */
 1796|  11.5k|    {   int result;
 1797|  11.5k|        if (streamPtr->dictCtx) {
  ------------------
  |  Branch (1797:13): [True: 0, False: 11.5k]
  ------------------
 1798|       |            /* We depend here on the fact that dictCtx'es (produced by
 1799|       |             * LZ4_loadDict) guarantee that their tables contain no references
 1800|       |             * to offsets between dictCtx->currentOffset - 64 KB and
 1801|       |             * dictCtx->currentOffset - dictCtx->dictSize. This makes it safe
 1802|       |             * to use noDictIssue even when the dict isn't a full 64 KB.
 1803|       |             */
 1804|      0|            if (inputSize > 4 KB) {
  ------------------
  |  |  252|      0|#define KB *(1 <<10)
  ------------------
  |  Branch (1804:17): [True: 0, False: 0]
  ------------------
 1805|       |                /* For compressing large blobs, it is faster to pay the setup
 1806|       |                 * cost to copy the dictionary's tables into the active context,
 1807|       |                 * so that the compression loop is only looking into one table.
 1808|       |                 */
 1809|      0|                LZ4_memcpy(streamPtr, streamPtr->dictCtx, sizeof(*streamPtr));
  ------------------
  |  |  350|      0|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 1810|      0|                result = LZ4_compress_generic(streamPtr, source, dest, inputSize, NULL, maxOutputSize, limitedOutput, tableType, usingExtDict, noDictIssue, acceleration);
 1811|      0|            } else {
 1812|      0|                result = LZ4_compress_generic(streamPtr, source, dest, inputSize, NULL, maxOutputSize, limitedOutput, tableType, usingDictCtx, noDictIssue, acceleration);
 1813|      0|            }
 1814|  11.5k|        } else {  /* external dictionary in the current context */
 1815|  11.5k|            if (LZ4_isDictSmall(streamPtr)) {
  ------------------
  |  Branch (1815:17): [True: 6.15k, False: 5.39k]
  ------------------
 1816|  6.15k|                result = LZ4_compress_generic(streamPtr, source, dest, inputSize, NULL, maxOutputSize, limitedOutput, tableType, usingExtDict, dictSmall, acceleration);
 1817|  6.15k|            } else {
 1818|       |                result = LZ4_compress_generic(streamPtr, source, dest, inputSize, NULL, maxOutputSize, limitedOutput, tableType, usingExtDict, noDictIssue, acceleration);
 1819|  5.39k|            }
 1820|  11.5k|        }
 1821|  11.5k|        streamPtr->dictionary = (const BYTE*)source;
 1822|  11.5k|        streamPtr->dictSize = (U32)inputSize;
 1823|  11.5k|        return result;
 1824|  31.6k|    }
 1825|  31.6k|}
LZ4_saveDict:
 1857|  24.4k|{
 1858|  24.4k|    LZ4_stream_t_internal* const dict = &LZ4_dict->internal_donotuse;
 1859|       |
 1860|  24.4k|    DEBUGLOG(5, "LZ4_saveDict : dictSize=%i, safeBuffer=%p", dictSize, (void*)safeBuffer);
  ------------------
  |  |  290|  24.4k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1861|       |
 1862|  24.4k|    if ((U32)dictSize > 64 KB) { dictSize = 64 KB; } /* useless to define a dictionary > 64 KB */
  ------------------
  |  |  252|  24.4k|#define KB *(1 <<10)
  ------------------
                  if ((U32)dictSize > 64 KB) { dictSize = 64 KB; } /* useless to define a dictionary > 64 KB */
  ------------------
  |  |  252|      0|#define KB *(1 <<10)
  ------------------
  |  Branch (1862:9): [True: 0, False: 24.4k]
  ------------------
 1863|  24.4k|    if ((U32)dictSize > dict->dictSize) { dictSize = (int)dict->dictSize; }
  ------------------
  |  Branch (1863:9): [True: 22.9k, False: 1.48k]
  ------------------
 1864|       |
 1865|  24.4k|    if (safeBuffer == NULL) assert(dictSize == 0);
  ------------------
  |  Branch (1865:9): [True: 0, False: 24.4k]
  |  Branch (1865:29): [True: 0, False: 0]
  |  Branch (1865:29): [True: 0, False: 0]
  ------------------
 1866|  24.4k|    if (dictSize > 0) {
  ------------------
  |  Branch (1866:9): [True: 24.4k, False: 0]
  ------------------
 1867|  24.4k|        const BYTE* const previousDictEnd = dict->dictionary + dict->dictSize;
 1868|  24.4k|        assert(dict->dictionary);
  ------------------
  |  Branch (1868:9): [True: 0, False: 24.4k]
  |  Branch (1868:9): [True: 24.4k, False: 0]
  ------------------
 1869|  24.4k|        LZ4_memmove(safeBuffer, previousDictEnd - dictSize, (size_t)dictSize);
  ------------------
  |  |  358|  24.4k|#    define LZ4_memmove __builtin_memmove
  ------------------
 1870|  24.4k|    }
 1871|       |
 1872|  24.4k|    dict->dictionary = (const BYTE*)safeBuffer;
 1873|  24.4k|    dict->dictSize = (U32)dictSize;
 1874|       |
 1875|  24.4k|    return dictSize;
 1876|  24.4k|}
LZ4_decompress_safe:
 2504|  6.61k|{
 2505|  6.61k|    return LZ4_decompress_generic(source, dest, compressedSize, maxDecompressedSize,
 2506|  6.61k|                                  decode_full_block, noDict,
 2507|       |                                  (BYTE*)dest, NULL, 0);
 2508|  6.61k|}
LZ4_decompress_safe_withPrefix64k:
 2532|  1.07k|{
 2533|  1.07k|    return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize,
 2534|  1.07k|                                  decode_full_block, withPrefix64k,
 2535|  1.07k|                                  (BYTE*)dest - 64 KB, NULL, 0);
  ------------------
  |  |  252|  1.07k|#define KB *(1 <<10)
  ------------------
 2536|  1.07k|}
LZ4_decompress_safe_forceExtDict:
 2578|  5.26k|{
 2579|  5.26k|    DEBUGLOG(5, "LZ4_decompress_safe_forceExtDict");
  ------------------
  |  |  290|  5.26k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2580|  5.26k|    return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize,
 2581|  5.26k|                                  decode_full_block, usingExtDict,
 2582|  5.26k|                                  (BYTE*)dest, (const BYTE*)dictStart, dictSize);
 2583|  5.26k|}
LZ4_decompress_safe_usingDict:
 2774|  13.6k|{
 2775|  13.6k|    if (dictSize==0)
  ------------------
  |  Branch (2775:9): [True: 6.61k, False: 7.06k]
  ------------------
 2776|  6.61k|        return LZ4_decompress_safe(source, dest, compressedSize, maxOutputSize);
 2777|  7.06k|    if (dictStart+dictSize == dest) {
  ------------------
  |  Branch (2777:9): [True: 1.80k, False: 5.26k]
  ------------------
 2778|  1.80k|        if (dictSize >= 64 KB - 1) {
  ------------------
  |  |  252|  1.80k|#define KB *(1 <<10)
  ------------------
  |  Branch (2778:13): [True: 1.07k, False: 724]
  ------------------
 2779|  1.07k|            return LZ4_decompress_safe_withPrefix64k(source, dest, compressedSize, maxOutputSize);
 2780|  1.07k|        }
 2781|  1.80k|        assert(dictSize >= 0);
  ------------------
  |  Branch (2781:9): [True: 0, False: 724]
  |  Branch (2781:9): [True: 724, False: 0]
  ------------------
 2782|    724|        return LZ4_decompress_safe_withSmallPrefix(source, dest, compressedSize, maxOutputSize, (size_t)dictSize);
 2783|    724|    }
 2784|  7.06k|    assert(dictSize >= 0);
  ------------------
  |  Branch (2784:5): [True: 0, False: 5.26k]
  |  Branch (2784:5): [True: 5.26k, False: 0]
  ------------------
 2785|  5.26k|    return LZ4_decompress_safe_forceExtDict(source, dest, compressedSize, maxOutputSize, dictStart, (size_t)dictSize);
 2786|  5.26k|}
lz4.c:LZ4_clampAcceleration:
 1397|  41.2k|{
 1398|  41.2k|    if (acceleration < 1) return LZ4_ACCELERATION_DEFAULT;
  ------------------
  |  |   52|      0|#define LZ4_ACCELERATION_DEFAULT 1
  ------------------
  |  Branch (1398:9): [True: 0, False: 41.2k]
  ------------------
 1399|  41.2k|    if (acceleration > LZ4_ACCELERATION_MAX) return LZ4_ACCELERATION_MAX;
  ------------------
  |  |   58|  41.2k|#define LZ4_ACCELERATION_MAX 65537
  ------------------
                  if (acceleration > LZ4_ACCELERATION_MAX) return LZ4_ACCELERATION_MAX;
  ------------------
  |  |   58|      0|#define LZ4_ACCELERATION_MAX 65537
  ------------------
  |  Branch (1399:9): [True: 0, False: 41.2k]
  ------------------
 1400|  41.2k|    return acceleration;
 1401|  41.2k|}
lz4.c:LZ4_compress_generic:
 1369|  41.2k|{
 1370|  41.2k|    DEBUGLOG(5, "LZ4_compress_generic: srcSize=%i, dstCapacity=%i",
  ------------------
  |  |  290|  41.2k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1371|  41.2k|                srcSize, dstCapacity);
 1372|       |
 1373|  41.2k|    if ((U32)srcSize > (U32)LZ4_MAX_INPUT_SIZE) { return 0; }  /* Unsupported srcSize, too large (or negative) */
  ------------------
  |  |  214|  41.2k|#define LZ4_MAX_INPUT_SIZE        0x7E000000   /* 2 113 929 216 bytes */
  ------------------
  |  Branch (1373:9): [True: 0, False: 41.2k]
  ------------------
 1374|  41.2k|    if (srcSize == 0) {   /* src == NULL supported if srcSize == 0 */
  ------------------
  |  Branch (1374:9): [True: 0, False: 41.2k]
  ------------------
 1375|      0|        if (outputDirective != notLimited && dstCapacity <= 0) return 0;  /* no output, can't write anything */
  ------------------
  |  Branch (1375:13): [True: 0, False: 0]
  |  Branch (1375:46): [True: 0, False: 0]
  ------------------
 1376|      0|        DEBUGLOG(5, "Generating an empty block");
  ------------------
  |  |  290|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1377|      0|        assert(outputDirective == notLimited || dstCapacity >= 1);
  ------------------
  |  Branch (1377:9): [True: 0, False: 0]
  |  Branch (1377:9): [True: 0, False: 0]
  |  Branch (1377:9): [True: 0, False: 0]
  |  Branch (1377:9): [True: 0, False: 0]
  ------------------
 1378|      0|        assert(dst != NULL);
  ------------------
  |  Branch (1378:9): [True: 0, False: 0]
  |  Branch (1378:9): [True: 0, False: 0]
  ------------------
 1379|      0|        dst[0] = 0;
 1380|      0|        if (outputDirective == fillOutput) {
  ------------------
  |  Branch (1380:13): [True: 0, False: 0]
  ------------------
 1381|      0|            assert (inputConsumed != NULL);
  ------------------
  |  Branch (1381:13): [True: 0, False: 0]
  |  Branch (1381:13): [True: 0, False: 0]
  ------------------
 1382|      0|            *inputConsumed = 0;
 1383|      0|        }
 1384|      0|        return 1;
 1385|      0|    }
 1386|  41.2k|    assert(src != NULL);
  ------------------
  |  Branch (1386:5): [True: 0, False: 41.2k]
  |  Branch (1386:5): [True: 41.2k, False: 0]
  ------------------
 1387|       |
 1388|  41.2k|    return LZ4_compress_generic_validated(cctx, src, dst, srcSize,
 1389|  41.2k|                inputConsumed, /* only written into if outputDirective == fillOutput */
 1390|  41.2k|                dstCapacity, outputDirective,
 1391|  41.2k|                tableType, dictDirective, dictIssue, acceleration);
 1392|  41.2k|}
lz4.c:LZ4_compress_generic_validated:
  955|  41.2k|{
  956|  41.2k|    int result;
  957|  41.2k|    const BYTE* ip = (const BYTE*)source;
  958|       |
  959|  41.2k|    U32 const startIndex = cctx->currentOffset;
  960|  41.2k|    const BYTE* base = (const BYTE*)source - startIndex;
  961|  41.2k|    const BYTE* lowLimit;
  962|       |
  963|  41.2k|    const LZ4_stream_t_internal* dictCtx = (const LZ4_stream_t_internal*) cctx->dictCtx;
  964|  41.2k|    const BYTE* const dictionary =
  965|  41.2k|        dictDirective == usingDictCtx ? dictCtx->dictionary : cctx->dictionary;
  ------------------
  |  Branch (965:9): [True: 0, False: 41.2k]
  ------------------
  966|  41.2k|    const U32 dictSize =
  967|  41.2k|        dictDirective == usingDictCtx ? dictCtx->dictSize : cctx->dictSize;
  ------------------
  |  Branch (967:9): [True: 0, False: 41.2k]
  ------------------
  968|  41.2k|    const U32 dictDelta =
  969|  41.2k|        (dictDirective == usingDictCtx) ? startIndex - dictCtx->currentOffset : 0;   /* make indexes in dictCtx comparable with indexes in current context */
  ------------------
  |  Branch (969:9): [True: 0, False: 41.2k]
  ------------------
  970|       |
  971|  41.2k|    int const maybe_extMem = (dictDirective == usingExtDict) || (dictDirective == usingDictCtx);
  ------------------
  |  Branch (971:30): [True: 11.5k, False: 29.7k]
  |  Branch (971:65): [True: 0, False: 29.7k]
  ------------------
  972|  41.2k|    U32 const prefixIdxLimit = startIndex - dictSize;   /* used when dictDirective == dictSmall */
  973|  41.2k|    const BYTE* const dictEnd = dictionary ? dictionary + dictSize : dictionary;
  ------------------
  |  Branch (973:33): [True: 31.6k, False: 9.63k]
  ------------------
  974|  41.2k|    const BYTE* anchor = (const BYTE*) source;
  975|  41.2k|    const BYTE* const iend = ip + inputSize;
  976|  41.2k|    const BYTE* const mflimitPlusOne = iend - MFLIMIT + 1;
  ------------------
  |  |  247|  41.2k|#define MFLIMIT       12   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  977|  41.2k|    const BYTE* const matchlimit = iend - LASTLITERALS;
  ------------------
  |  |  246|  41.2k|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  978|       |
  979|       |    /* the dictCtx currentOffset is indexed on the start of the dictionary,
  980|       |     * while a dictionary in the current context precedes the currentOffset */
  981|  41.2k|    const BYTE* dictBase = (dictionary == NULL) ? NULL :
  ------------------
  |  Branch (981:28): [True: 9.63k, False: 31.6k]
  ------------------
  982|  41.2k|                           (dictDirective == usingDictCtx) ?
  ------------------
  |  Branch (982:28): [True: 0, False: 31.6k]
  ------------------
  983|      0|                            dictionary + dictSize - dictCtx->currentOffset :
  984|  31.6k|                            dictionary + dictSize - startIndex;
  985|       |
  986|  41.2k|    BYTE* op = (BYTE*) dest;
  987|  41.2k|    BYTE* const olimit = op + maxOutputSize;
  988|       |
  989|  41.2k|    U32 offset = 0;
  990|  41.2k|    U32 forwardH;
  991|       |
  992|  41.2k|    DEBUGLOG(5, "LZ4_compress_generic_validated: srcSize=%i, tableType=%u", inputSize, tableType);
  ------------------
  |  |  290|  41.2k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  993|  41.2k|    assert(ip != NULL);
  ------------------
  |  Branch (993:5): [True: 0, False: 41.2k]
  |  Branch (993:5): [True: 41.2k, False: 0]
  ------------------
  994|  41.2k|    if (tableType == byU16) assert(inputSize<LZ4_64Klimit);  /* Size too large (not within 64K limit) */
  ------------------
  |  Branch (994:9): [True: 8.85k, False: 32.4k]
  |  Branch (994:29): [True: 0, False: 8.85k]
  |  Branch (994:29): [True: 8.85k, False: 0]
  ------------------
  995|  41.2k|    if (tableType == byPtr) assert(dictDirective==noDict);   /* only supported use case with byPtr */
  ------------------
  |  Branch (995:9): [True: 0, False: 41.2k]
  |  Branch (995:29): [True: 0, False: 0]
  |  Branch (995:29): [True: 0, False: 0]
  ------------------
  996|       |    /* If init conditions are not met, we don't have to mark stream
  997|       |     * as having dirty context, since no action was taken yet */
  998|  41.2k|    if (outputDirective == fillOutput && maxOutputSize < 1) { return 0; } /* Impossible to store anything */
  ------------------
  |  Branch (998:9): [True: 0, False: 41.2k]
  |  Branch (998:42): [True: 0, False: 0]
  ------------------
  999|  41.2k|    assert(acceleration >= 1);
  ------------------
  |  Branch (999:5): [True: 0, False: 41.2k]
  |  Branch (999:5): [True: 41.2k, False: 0]
  ------------------
 1000|       |
 1001|  41.2k|    lowLimit = (const BYTE*)source - (dictDirective == withPrefix64k ? dictSize : 0);
  ------------------
  |  Branch (1001:39): [True: 20.0k, False: 21.1k]
  ------------------
 1002|       |
 1003|       |    /* Update context state */
 1004|  41.2k|    if (dictDirective == usingDictCtx) {
  ------------------
  |  Branch (1004:9): [True: 0, False: 41.2k]
  ------------------
 1005|       |        /* Subsequent linked blocks can't use the dictionary. */
 1006|       |        /* Instead, they use the block we just compressed. */
 1007|      0|        cctx->dictCtx = NULL;
 1008|      0|        cctx->dictSize = (U32)inputSize;
 1009|  41.2k|    } else {
 1010|  41.2k|        cctx->dictSize += (U32)inputSize;
 1011|  41.2k|    }
 1012|  41.2k|    cctx->currentOffset += (U32)inputSize;
 1013|  41.2k|    cctx->tableType = (U32)tableType;
 1014|       |
 1015|  41.2k|    if (inputSize<LZ4_minLength) goto _last_literals;        /* Input too small, no compression (all literals) */
  ------------------
  |  Branch (1015:9): [True: 14.7k, False: 26.5k]
  ------------------
 1016|       |
 1017|       |    /* First Byte */
 1018|  26.5k|    {   U32 const h = LZ4_hashPosition(ip, tableType);
 1019|  26.5k|        if (tableType == byPtr) {
  ------------------
  |  Branch (1019:13): [True: 0, False: 26.5k]
  ------------------
 1020|      0|            LZ4_putPositionOnHash(ip, h, cctx->hashTable, byPtr);
 1021|  26.5k|        } else {
 1022|  26.5k|            LZ4_putIndexOnHash(startIndex, h, cctx->hashTable, tableType);
 1023|  26.5k|    }   }
 1024|  26.5k|    ip++; forwardH = LZ4_hashPosition(ip, tableType);
 1025|       |
 1026|       |    /* Main Loop */
 1027|  3.26M|    for ( ; ; ) {
 1028|  3.26M|        const BYTE* match;
 1029|  3.26M|        BYTE* token;
 1030|  3.26M|        const BYTE* filledIp;
 1031|       |
 1032|       |        /* Find a match */
 1033|  3.26M|        if (tableType == byPtr) {
  ------------------
  |  Branch (1033:13): [True: 0, False: 3.26M]
  ------------------
 1034|      0|            const BYTE* forwardIp = ip;
 1035|      0|            int step = 1;
 1036|      0|            int searchMatchNb = acceleration << LZ4_skipTrigger;
 1037|      0|            do {
 1038|      0|                U32 const h = forwardH;
 1039|      0|                ip = forwardIp;
 1040|      0|                forwardIp += step;
 1041|      0|                step = (searchMatchNb++ >> LZ4_skipTrigger);
 1042|       |
 1043|      0|                if (unlikely(forwardIp > mflimitPlusOne)) goto _last_literals;
  ------------------
  |  |  181|      0|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|      0|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1044|      0|                assert(ip < mflimitPlusOne);
  ------------------
  |  Branch (1044:17): [True: 0, False: 0]
  |  Branch (1044:17): [True: 0, False: 0]
  ------------------
 1045|       |
 1046|      0|                match = LZ4_getPositionOnHash(h, cctx->hashTable, tableType);
 1047|      0|                forwardH = LZ4_hashPosition(forwardIp, tableType);
 1048|      0|                LZ4_putPositionOnHash(ip, h, cctx->hashTable, tableType);
 1049|       |
 1050|      0|            } while ( (match+LZ4_DISTANCE_MAX < ip)
  ------------------
  |  |  678|      0|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (1050:23): [True: 0, False: 0]
  ------------------
 1051|      0|                   || (LZ4_read32(match) != LZ4_read32(ip)) );
  ------------------
  |  Branch (1051:23): [True: 0, False: 0]
  ------------------
 1052|       |
 1053|  3.26M|        } else {   /* byU32, byU16 */
 1054|       |
 1055|  3.26M|            const BYTE* forwardIp = ip;
 1056|  3.26M|            int step = 1;
 1057|  3.26M|            int searchMatchNb = acceleration << LZ4_skipTrigger;
 1058|  30.6M|            do {
 1059|  30.6M|                U32 const h = forwardH;
 1060|  30.6M|                U32 const current = (U32)(forwardIp - base);
 1061|  30.6M|                U32 matchIndex = LZ4_getIndexOnHash(h, cctx->hashTable, tableType);
 1062|  30.6M|                assert(matchIndex <= current);
  ------------------
  |  Branch (1062:17): [True: 0, False: 30.6M]
  |  Branch (1062:17): [True: 30.6M, False: 0]
  ------------------
 1063|  30.6M|                assert(forwardIp - base < (ptrdiff_t)(2 GB - 1));
  ------------------
  |  Branch (1063:17): [True: 0, False: 30.6M]
  |  Branch (1063:17): [True: 30.6M, False: 0]
  ------------------
 1064|  30.6M|                ip = forwardIp;
 1065|  30.6M|                forwardIp += step;
 1066|  30.6M|                step = (searchMatchNb++ >> LZ4_skipTrigger);
 1067|       |
 1068|  30.6M|                if (unlikely(forwardIp > mflimitPlusOne)) goto _last_literals;
  ------------------
  |  |  181|  30.6M|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|  30.6M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 9.18k, False: 30.6M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1069|  30.6M|                assert(ip < mflimitPlusOne);
  ------------------
  |  Branch (1069:17): [True: 0, False: 30.6M]
  |  Branch (1069:17): [True: 30.6M, False: 0]
  ------------------
 1070|       |
 1071|  30.6M|                if (dictDirective == usingDictCtx) {
  ------------------
  |  Branch (1071:21): [True: 0, False: 30.6M]
  ------------------
 1072|      0|                    if (matchIndex < startIndex) {
  ------------------
  |  Branch (1072:25): [True: 0, False: 0]
  ------------------
 1073|       |                        /* there was no match, try the dictionary */
 1074|      0|                        assert(tableType == byU32);
  ------------------
  |  Branch (1074:25): [True: 0, False: 0]
  |  Branch (1074:25): [True: 0, False: 0]
  ------------------
 1075|      0|                        matchIndex = LZ4_getIndexOnHash(h, dictCtx->hashTable, byU32);
 1076|      0|                        match = dictBase + matchIndex;
 1077|      0|                        matchIndex += dictDelta;   /* make dictCtx index comparable with current context */
 1078|      0|                        lowLimit = dictionary;
 1079|      0|                    } else {
 1080|      0|                        match = base + matchIndex;
 1081|      0|                        lowLimit = (const BYTE*)source;
 1082|      0|                    }
 1083|  30.6M|                } else if (dictDirective == usingExtDict) {
  ------------------
  |  Branch (1083:28): [True: 8.31M, False: 22.3M]
  ------------------
 1084|  8.31M|                    if (matchIndex < startIndex) {
  ------------------
  |  Branch (1084:25): [True: 2.44M, False: 5.86M]
  ------------------
 1085|  2.44M|                        DEBUGLOG(7, "extDict candidate: matchIndex=%5u  <  startIndex=%5u", matchIndex, startIndex);
  ------------------
  |  |  290|  2.44M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1086|  2.44M|                        assert(startIndex - matchIndex >= MINMATCH);
  ------------------
  |  Branch (1086:25): [True: 0, False: 2.44M]
  |  Branch (1086:25): [True: 2.44M, False: 0]
  ------------------
 1087|  2.44M|                        assert(dictBase);
  ------------------
  |  Branch (1087:25): [True: 0, False: 2.44M]
  |  Branch (1087:25): [True: 2.44M, False: 0]
  ------------------
 1088|  2.44M|                        match = dictBase + matchIndex;
 1089|  2.44M|                        lowLimit = dictionary;
 1090|  5.86M|                    } else {
 1091|  5.86M|                        match = base + matchIndex;
 1092|  5.86M|                        lowLimit = (const BYTE*)source;
 1093|  5.86M|                    }
 1094|  22.3M|                } else {   /* single continuous memory segment */
 1095|  22.3M|                    match = base + matchIndex;
 1096|  22.3M|                }
 1097|  30.6M|                forwardH = LZ4_hashPosition(forwardIp, tableType);
 1098|  30.6M|                LZ4_putIndexOnHash(current, h, cctx->hashTable, tableType);
 1099|       |
 1100|  30.6M|                DEBUGLOG(7, "candidate at pos=%u  (offset=%u \n", matchIndex, current - matchIndex);
  ------------------
  |  |  290|  30.6M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1101|  30.6M|                if ((dictIssue == dictSmall) && (matchIndex < prefixIdxLimit)) { continue; }    /* match outside of valid area */
  ------------------
  |  Branch (1101:21): [True: 6.57M, False: 24.0M]
  |  Branch (1101:49): [True: 1.93M, False: 4.63M]
  ------------------
 1102|  30.6M|                assert(matchIndex < current);
  ------------------
  |  Branch (1102:17): [True: 0, False: 28.7M]
  |  Branch (1102:17): [True: 28.7M, False: 0]
  ------------------
 1103|  28.7M|                if ( ((tableType != byU16) || (LZ4_DISTANCE_MAX < LZ4_DISTANCE_ABSOLUTE_MAX))
  ------------------
  |  |  678|  4.47M|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
                              if ( ((tableType != byU16) || (LZ4_DISTANCE_MAX < LZ4_DISTANCE_ABSOLUTE_MAX))
  ------------------
  |  |  256|  4.47M|#define LZ4_DISTANCE_ABSOLUTE_MAX 65535
  ------------------
  |  Branch (1103:23): [True: 24.2M, False: 4.47M]
  |  Branch (1103:47): [Folded, False: 0]
  ------------------
 1104|  24.2M|                  && (matchIndex+LZ4_DISTANCE_MAX < current)) {
  ------------------
  |  |  678|  24.2M|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (1104:22): [True: 1.96M, False: 22.2M]
  ------------------
 1105|  1.96M|                    continue;
 1106|  1.96M|                } /* too far */
 1107|  28.7M|                assert((current - matchIndex) <= LZ4_DISTANCE_MAX);  /* match now expected within distance */
  ------------------
  |  Branch (1107:17): [True: 0, False: 26.7M]
  |  Branch (1107:17): [True: 26.7M, False: 0]
  ------------------
 1108|       |
 1109|  26.7M|                if (LZ4_read32(match) == LZ4_read32(ip)) {
  ------------------
  |  Branch (1109:21): [True: 3.25M, False: 23.4M]
  ------------------
 1110|  3.25M|                    if (maybe_extMem) offset = current - matchIndex;
  ------------------
  |  Branch (1110:25): [True: 1.00M, False: 2.25M]
  ------------------
 1111|  3.25M|                    break;   /* match found */
 1112|  3.25M|                }
 1113|       |
 1114|  27.3M|            } while(1);
  ------------------
  |  Branch (1114:21): [True: 27.3M, Folded]
  ------------------
 1115|  3.26M|        }
 1116|       |
 1117|       |        /* Catch up */
 1118|  3.25M|        filledIp = ip;
 1119|  3.25M|        assert(ip > anchor); /* this is always true as ip has been advanced before entering the main loop */
  ------------------
  |  Branch (1119:9): [True: 0, False: 3.25M]
  |  Branch (1119:9): [True: 3.25M, False: 0]
  ------------------
 1120|  3.25M|        if ((match > lowLimit) && unlikely(ip[-1] == match[-1])) {
  ------------------
  |  |  181|  3.24M|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|  3.24M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 910k, False: 2.32M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1120:13): [True: 3.24M, False: 16.6k]
  ------------------
 1121|  1.91M|            do { ip--; match--; } while (((ip > anchor) & (match > lowLimit)) && (unlikely(ip[-1] == match[-1])));
  ------------------
  |  |  181|  1.63M|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|  1.63M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  ------------------
  ------------------
  |  Branch (1121:42): [True: 1.63M, False: 276k]
  |  Branch (1121:82): [True: 1.00M, False: 634k]
  ------------------
 1122|   910k|        }
 1123|       |
 1124|       |        /* Encode Literals */
 1125|  3.25M|        {   unsigned const litLength = (unsigned)(ip - anchor);
 1126|  3.25M|            token = op++;
 1127|  3.25M|            if ((outputDirective == limitedOutput) &&  /* Check output buffer overflow */
  ------------------
  |  Branch (1127:17): [True: 3.25M, False: 0]
  ------------------
 1128|  3.25M|                (unlikely(op + litLength + (2 + 1 + LASTLITERALS) + (litLength/255) > olimit)) ) {
  ------------------
  |  |  181|  3.25M|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|  3.25M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  ------------------
  ------------------
  |  Branch (1128:17): [True: 1.41k, False: 3.25M]
  ------------------
 1129|  1.41k|                return 0;   /* cannot compress within `dst` budget. Stored indexes in hash table are nonetheless fine */
 1130|  1.41k|            }
 1131|  3.25M|            if ((outputDirective == fillOutput) &&
  ------------------
  |  Branch (1131:17): [True: 0, False: 3.25M]
  ------------------
 1132|      0|                (unlikely(op + (litLength+240)/255 /* litlen */ + litLength /* literals */ + 2 /* offset */ + 1 /* token */ + MFLIMIT - MINMATCH /* min last literals so last match is <= end - MFLIMIT */ > olimit))) {
  ------------------
  |  |  181|      0|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|      0|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  ------------------
  ------------------
  |  Branch (1132:17): [True: 0, False: 0]
  ------------------
 1133|      0|                op--;
 1134|      0|                goto _last_literals;
 1135|      0|            }
 1136|  3.25M|            if (litLength >= RUN_MASK) {
  ------------------
  |  |  264|  3.25M|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  263|  3.25M|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|  3.25M|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1136:17): [True: 538k, False: 2.71M]
  ------------------
 1137|   538k|                unsigned len = litLength - RUN_MASK;
  ------------------
  |  |  264|   538k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  263|   538k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|   538k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1138|   538k|                *token = (RUN_MASK<<ML_BITS);
  ------------------
  |  |  264|   538k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  263|   538k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|   538k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                              *token = (RUN_MASK<<ML_BITS);
  ------------------
  |  |  261|   538k|#define ML_BITS  4
  ------------------
 1139|   768k|                for(; len >= 255 ; len-=255) *op++ = 255;
  ------------------
  |  Branch (1139:23): [True: 230k, False: 538k]
  ------------------
 1140|   538k|                *op++ = (BYTE)len;
 1141|   538k|            }
 1142|  2.71M|            else *token = (BYTE)(litLength<<ML_BITS);
  ------------------
  |  |  261|  2.71M|#define ML_BITS  4
  ------------------
 1143|       |
 1144|       |            /* Copy Literals */
 1145|  3.25M|            LZ4_wildCopy8(op, anchor, op+litLength);
 1146|  3.25M|            op+=litLength;
 1147|  3.25M|            DEBUGLOG(6, "seq.start:%i, literals=%u, match.start:%i",
  ------------------
  |  |  290|  3.25M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1148|  3.25M|                        (int)(anchor-(const BYTE*)source), litLength, (int)(ip-(const BYTE*)source));
 1149|  3.25M|        }
 1150|       |
 1151|  7.09M|_next_match:
 1152|       |        /* at this stage, the following variables must be correctly set :
 1153|       |         * - ip : at start of LZ operation
 1154|       |         * - match : at start of previous pattern occurrence; can be within current prefix, or within extDict
 1155|       |         * - offset : if maybe_ext_memSegment==1 (constant)
 1156|       |         * - lowLimit : must be == dictionary to mean "match is within extDict"; must be == source otherwise
 1157|       |         * - token and *token : position to write 4-bits for match length; higher 4-bits for literal length supposed already written
 1158|       |         */
 1159|       |
 1160|  7.09M|        if ((outputDirective == fillOutput) &&
  ------------------
  |  Branch (1160:13): [True: 0, False: 7.09M]
  ------------------
 1161|      0|            (op + 2 /* offset */ + 1 /* token */ + MFLIMIT - MINMATCH /* min last literals so last match is <= end - MFLIMIT */ > olimit)) {
  ------------------
  |  |  247|      0|#define MFLIMIT       12   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
                          (op + 2 /* offset */ + 1 /* token */ + MFLIMIT - MINMATCH /* min last literals so last match is <= end - MFLIMIT */ > olimit)) {
  ------------------
  |  |  243|      0|#define MINMATCH 4
  ------------------
  |  Branch (1161:13): [True: 0, False: 0]
  ------------------
 1162|       |            /* the match was too close to the end, rewind and go to last literals */
 1163|      0|            op = token;
 1164|      0|            goto _last_literals;
 1165|      0|        }
 1166|       |
 1167|       |        /* Encode Offset */
 1168|  7.09M|        if (maybe_extMem) {   /* static test */
  ------------------
  |  Branch (1168:13): [True: 1.94M, False: 5.14M]
  ------------------
 1169|  1.94M|            DEBUGLOG(6, "             with offset=%u  (ext if > %i)", offset, (int)(ip - (const BYTE*)source));
  ------------------
  |  |  290|  1.94M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1170|  1.94M|            assert(offset <= LZ4_DISTANCE_MAX && offset > 0);
  ------------------
  |  Branch (1170:13): [True: 0, False: 1.94M]
  |  Branch (1170:13): [True: 0, False: 0]
  |  Branch (1170:13): [True: 1.94M, False: 0]
  |  Branch (1170:13): [True: 1.94M, False: 0]
  ------------------
 1171|  1.94M|            LZ4_writeLE16(op, (U16)offset); op+=2;
 1172|  5.14M|        } else  {
 1173|  5.14M|            DEBUGLOG(6, "             with offset=%u  (same segment)", (U32)(ip - match));
  ------------------
  |  |  290|  5.14M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1174|  5.14M|            assert(ip-match <= LZ4_DISTANCE_MAX);
  ------------------
  |  Branch (1174:13): [True: 0, False: 5.14M]
  |  Branch (1174:13): [True: 5.14M, False: 0]
  ------------------
 1175|  5.14M|            LZ4_writeLE16(op, (U16)(ip - match)); op+=2;
 1176|  5.14M|        }
 1177|       |
 1178|       |        /* Encode MatchLength */
 1179|  7.09M|        {   unsigned matchCode;
 1180|       |
 1181|  7.09M|            if ( (dictDirective==usingExtDict || dictDirective==usingDictCtx)
  ------------------
  |  Branch (1181:19): [True: 1.94M, False: 5.14M]
  |  Branch (1181:50): [True: 0, False: 5.14M]
  ------------------
 1182|  1.94M|              && (lowLimit==dictionary) /* match within extDict */ ) {
  ------------------
  |  Branch (1182:18): [True: 91.8k, False: 1.85M]
  ------------------
 1183|  91.8k|                const BYTE* limit = ip + (dictEnd-match);
 1184|  91.8k|                assert(dictEnd > match);
  ------------------
  |  Branch (1184:17): [True: 0, False: 91.8k]
  |  Branch (1184:17): [True: 91.8k, False: 0]
  ------------------
 1185|  91.8k|                if (limit > matchlimit) limit = matchlimit;
  ------------------
  |  Branch (1185:21): [True: 13.8k, False: 78.0k]
  ------------------
 1186|  91.8k|                matchCode = LZ4_count(ip+MINMATCH, match+MINMATCH, limit);
  ------------------
  |  |  243|  91.8k|#define MINMATCH 4
  ------------------
                              matchCode = LZ4_count(ip+MINMATCH, match+MINMATCH, limit);
  ------------------
  |  |  243|  91.8k|#define MINMATCH 4
  ------------------
 1187|  91.8k|                ip += (size_t)matchCode + MINMATCH;
  ------------------
  |  |  243|  91.8k|#define MINMATCH 4
  ------------------
 1188|  91.8k|                if (ip==limit) {
  ------------------
  |  Branch (1188:21): [True: 3.94k, False: 87.8k]
  ------------------
 1189|  3.94k|                    unsigned const more = LZ4_count(limit, (const BYTE*)source, matchlimit);
 1190|  3.94k|                    matchCode += more;
 1191|  3.94k|                    ip += more;
 1192|  3.94k|                }
 1193|  91.8k|                DEBUGLOG(6, "             with matchLength=%u starting in extDict", matchCode+MINMATCH);
  ------------------
  |  |  290|  91.8k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1194|  7.00M|            } else {
 1195|  7.00M|                matchCode = LZ4_count(ip+MINMATCH, match+MINMATCH, matchlimit);
  ------------------
  |  |  243|  7.00M|#define MINMATCH 4
  ------------------
                              matchCode = LZ4_count(ip+MINMATCH, match+MINMATCH, matchlimit);
  ------------------
  |  |  243|  7.00M|#define MINMATCH 4
  ------------------
 1196|  7.00M|                ip += (size_t)matchCode + MINMATCH;
  ------------------
  |  |  243|  7.00M|#define MINMATCH 4
  ------------------
 1197|  7.00M|                DEBUGLOG(6, "             with matchLength=%u", matchCode+MINMATCH);
  ------------------
  |  |  290|  7.00M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1198|  7.00M|            }
 1199|       |
 1200|  7.09M|            if ((outputDirective) &&    /* Check output buffer overflow */
  ------------------
  |  Branch (1200:17): [True: 7.09M, False: 0]
  ------------------
 1201|  7.09M|                (unlikely(op + (1 + LASTLITERALS) + (matchCode+240)/255 > olimit)) ) {
  ------------------
  |  |  181|  7.09M|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|  7.09M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  ------------------
  ------------------
  |  Branch (1201:17): [True: 522, False: 7.09M]
  ------------------
 1202|    522|                if (outputDirective == fillOutput) {
  ------------------
  |  Branch (1202:21): [True: 0, False: 522]
  ------------------
 1203|       |                    /* Match description too long : reduce it */
 1204|      0|                    U32 newMatchCode = 15 /* in token */ - 1 /* to avoid needing a zero byte */ + ((U32)(olimit - op) - 1 - LASTLITERALS) * 255;
  ------------------
  |  |  246|      0|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
 1205|      0|                    ip -= matchCode - newMatchCode;
 1206|      0|                    assert(newMatchCode < matchCode);
  ------------------
  |  Branch (1206:21): [True: 0, False: 0]
  |  Branch (1206:21): [True: 0, False: 0]
  ------------------
 1207|      0|                    matchCode = newMatchCode;
 1208|      0|                    if (unlikely(ip <= filledIp)) {
  ------------------
  |  |  181|      0|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|      0|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1209|       |                        /* We have already filled up to filledIp so if ip ends up less than filledIp
 1210|       |                         * we have positions in the hash table beyond the current position. This is
 1211|       |                         * a problem if we reuse the hash table. So we have to remove these positions
 1212|       |                         * from the hash table.
 1213|       |                         */
 1214|      0|                        const BYTE* ptr;
 1215|      0|                        DEBUGLOG(5, "Clearing %u positions", (U32)(filledIp - ip));
  ------------------
  |  |  290|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1216|      0|                        for (ptr = ip; ptr <= filledIp; ++ptr) {
  ------------------
  |  Branch (1216:40): [True: 0, False: 0]
  ------------------
 1217|      0|                            U32 const h = LZ4_hashPosition(ptr, tableType);
 1218|      0|                            LZ4_clearHash(h, cctx->hashTable, tableType);
 1219|      0|                        }
 1220|      0|                    }
 1221|    522|                } else {
 1222|    522|                    assert(outputDirective == limitedOutput);
  ------------------
  |  Branch (1222:21): [True: 0, False: 522]
  |  Branch (1222:21): [True: 522, False: 0]
  ------------------
 1223|    522|                    return 0;   /* cannot compress within `dst` budget. Stored indexes in hash table are nonetheless fine */
 1224|    522|                }
 1225|    522|            }
 1226|  7.09M|            if (matchCode >= ML_MASK) {
  ------------------
  |  |  262|  7.09M|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  261|  7.09M|#define ML_BITS  4
  |  |  ------------------
  ------------------
  |  Branch (1226:17): [True: 960k, False: 6.13M]
  ------------------
 1227|   960k|                *token += ML_MASK;
  ------------------
  |  |  262|   960k|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  261|   960k|#define ML_BITS  4
  |  |  ------------------
  ------------------
 1228|   960k|                matchCode -= ML_MASK;
  ------------------
  |  |  262|   960k|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  261|   960k|#define ML_BITS  4
  |  |  ------------------
  ------------------
 1229|   960k|                LZ4_write32(op, 0xFFFFFFFF);
 1230|  1.13M|                while (matchCode >= 4*255) {
  ------------------
  |  Branch (1230:24): [True: 179k, False: 960k]
  ------------------
 1231|   179k|                    op+=4;
 1232|   179k|                    LZ4_write32(op, 0xFFFFFFFF);
 1233|   179k|                    matchCode -= 4*255;
 1234|   179k|                }
 1235|   960k|                op += matchCode / 255;
 1236|   960k|                *op++ = (BYTE)(matchCode % 255);
 1237|   960k|            } else
 1238|  6.13M|                *token += (BYTE)(matchCode);
 1239|  7.09M|        }
 1240|       |        /* Ensure we have enough space for the last literals. */
 1241|  7.09M|        assert(!(outputDirective == fillOutput && op + 1 + LASTLITERALS > olimit));
  ------------------
  |  Branch (1241:9): [True: 0, False: 7.09M]
  |  Branch (1241:9): [True: 0, False: 0]
  |  Branch (1241:9): [True: 0, False: 7.09M]
  |  Branch (1241:9): [True: 0, False: 0]
  ------------------
 1242|       |
 1243|  7.09M|        anchor = ip;
 1244|       |
 1245|       |        /* Test end of chunk */
 1246|  7.09M|        if (ip >= mflimitPlusOne) break;
  ------------------
  |  Branch (1246:13): [True: 15.4k, False: 7.08M]
  ------------------
 1247|       |
 1248|       |        /* Fill table */
 1249|  7.08M|        {   U32 const h = LZ4_hashPosition(ip-2, tableType);
 1250|  7.08M|            if (tableType == byPtr) {
  ------------------
  |  Branch (1250:17): [True: 0, False: 7.08M]
  ------------------
 1251|      0|                LZ4_putPositionOnHash(ip-2, h, cctx->hashTable, byPtr);
 1252|  7.08M|            } else {
 1253|  7.08M|                U32 const idx = (U32)((ip-2) - base);
 1254|  7.08M|                LZ4_putIndexOnHash(idx, h, cctx->hashTable, tableType);
 1255|  7.08M|        }   }
 1256|       |
 1257|       |        /* Test next position */
 1258|  7.08M|        if (tableType == byPtr) {
  ------------------
  |  Branch (1258:13): [True: 0, False: 7.08M]
  ------------------
 1259|       |
 1260|      0|            match = LZ4_getPosition(ip, cctx->hashTable, tableType);
 1261|      0|            LZ4_putPosition(ip, cctx->hashTable, tableType);
 1262|      0|            if ( (match+LZ4_DISTANCE_MAX >= ip)
  ------------------
  |  |  678|      0|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (1262:18): [True: 0, False: 0]
  ------------------
 1263|      0|              && (LZ4_read32(match) == LZ4_read32(ip)) )
  ------------------
  |  Branch (1263:18): [True: 0, False: 0]
  ------------------
 1264|      0|            { token=op++; *token=0; goto _next_match; }
 1265|       |
 1266|  7.08M|        } else {   /* byU32, byU16 */
 1267|       |
 1268|  7.08M|            U32 const h = LZ4_hashPosition(ip, tableType);
 1269|  7.08M|            U32 const current = (U32)(ip-base);
 1270|  7.08M|            U32 matchIndex = LZ4_getIndexOnHash(h, cctx->hashTable, tableType);
 1271|  7.08M|            assert(matchIndex < current);
  ------------------
  |  Branch (1271:13): [True: 0, False: 7.08M]
  |  Branch (1271:13): [True: 7.08M, False: 0]
  ------------------
 1272|  7.08M|            if (dictDirective == usingDictCtx) {
  ------------------
  |  Branch (1272:17): [True: 0, False: 7.08M]
  ------------------
 1273|      0|                if (matchIndex < startIndex) {
  ------------------
  |  Branch (1273:21): [True: 0, False: 0]
  ------------------
 1274|       |                    /* there was no match, try the dictionary */
 1275|      0|                    assert(tableType == byU32);
  ------------------
  |  Branch (1275:21): [True: 0, False: 0]
  |  Branch (1275:21): [True: 0, False: 0]
  ------------------
 1276|      0|                    matchIndex = LZ4_getIndexOnHash(h, dictCtx->hashTable, byU32);
 1277|      0|                    match = dictBase + matchIndex;
 1278|      0|                    lowLimit = dictionary;   /* required for match length counter */
 1279|      0|                    matchIndex += dictDelta;
 1280|      0|                } else {
 1281|      0|                    match = base + matchIndex;
 1282|      0|                    lowLimit = (const BYTE*)source;  /* required for match length counter */
 1283|      0|                }
 1284|  7.08M|            } else if (dictDirective==usingExtDict) {
  ------------------
  |  Branch (1284:24): [True: 1.94M, False: 5.13M]
  ------------------
 1285|  1.94M|                if (matchIndex < startIndex) {
  ------------------
  |  Branch (1285:21): [True: 324k, False: 1.61M]
  ------------------
 1286|   324k|                    assert(dictBase);
  ------------------
  |  Branch (1286:21): [True: 0, False: 324k]
  |  Branch (1286:21): [True: 324k, False: 0]
  ------------------
 1287|   324k|                    match = dictBase + matchIndex;
 1288|   324k|                    lowLimit = dictionary;   /* required for match length counter */
 1289|  1.61M|                } else {
 1290|  1.61M|                    match = base + matchIndex;
 1291|  1.61M|                    lowLimit = (const BYTE*)source;   /* required for match length counter */
 1292|  1.61M|                }
 1293|  5.13M|            } else {   /* single memory segment */
 1294|  5.13M|                match = base + matchIndex;
 1295|  5.13M|            }
 1296|  7.08M|            LZ4_putIndexOnHash(current, h, cctx->hashTable, tableType);
 1297|  7.08M|            assert(matchIndex < current);
  ------------------
  |  Branch (1297:13): [True: 0, False: 7.08M]
  |  Branch (1297:13): [True: 7.08M, False: 0]
  ------------------
 1298|  7.08M|            if ( ((dictIssue==dictSmall) ? (matchIndex >= prefixIdxLimit) : 1)
  ------------------
  |  Branch (1298:18): [True: 6.86M, False: 219k]
  |  Branch (1298:19): [True: 1.50M, False: 5.57M]
  ------------------
 1299|  6.86M|              && (((tableType==byU16) && (LZ4_DISTANCE_MAX == LZ4_DISTANCE_ABSOLUTE_MAX)) ? 1 : (matchIndex+LZ4_DISTANCE_MAX >= current))
  ------------------
  |  |  678|  1.43M|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
                            && (((tableType==byU16) && (LZ4_DISTANCE_MAX == LZ4_DISTANCE_ABSOLUTE_MAX)) ? 1 : (matchIndex+LZ4_DISTANCE_MAX >= current))
  ------------------
  |  |  256|  1.43M|#define LZ4_DISTANCE_ABSOLUTE_MAX 65535
  ------------------
                            && (((tableType==byU16) && (LZ4_DISTANCE_MAX == LZ4_DISTANCE_ABSOLUTE_MAX)) ? 1 : (matchIndex+LZ4_DISTANCE_MAX >= current))
  ------------------
  |  |  678|  5.43M|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (1299:18): [True: 6.69M, False: 163k]
  |  Branch (1299:20): [True: 1.43M, False: 5.43M]
  |  Branch (1299:42): [True: 0, Folded]
  ------------------
 1300|  6.69M|              && (LZ4_read32(match) == LZ4_read32(ip)) ) {
  ------------------
  |  Branch (1300:18): [True: 3.84M, False: 2.85M]
  ------------------
 1301|  3.84M|                token=op++;
 1302|  3.84M|                *token=0;
 1303|  3.84M|                if (maybe_extMem) offset = current - matchIndex;
  ------------------
  |  Branch (1303:21): [True: 945k, False: 2.89M]
  ------------------
 1304|  3.84M|                DEBUGLOG(6, "seq.start:%i, literals=%u, match.start:%i",
  ------------------
  |  |  290|  3.84M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1305|  3.84M|                            (int)(anchor-(const BYTE*)source), 0, (int)(ip-(const BYTE*)source));
 1306|  3.84M|                goto _next_match;
 1307|  3.84M|            }
 1308|  7.08M|        }
 1309|       |
 1310|       |        /* Prepare next loop */
 1311|  3.23M|        forwardH = LZ4_hashPosition(++ip, tableType);
 1312|       |
 1313|  3.23M|    }
 1314|       |
 1315|  39.3k|_last_literals:
 1316|       |    /* Encode Last Literals */
 1317|  39.3k|    {   size_t lastRun = (size_t)(iend - anchor);
 1318|  39.3k|        if ( (outputDirective) &&  /* Check output buffer overflow */
  ------------------
  |  Branch (1318:14): [True: 39.3k, False: 0]
  ------------------
 1319|  39.3k|            (op + lastRun + 1 + ((lastRun+255-RUN_MASK)/255) > olimit)) {
  ------------------
  |  |  264|  39.3k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  263|  39.3k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|  39.3k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1319:13): [True: 20.0k, False: 19.2k]
  ------------------
 1320|  20.0k|            if (outputDirective == fillOutput) {
  ------------------
  |  Branch (1320:17): [True: 0, False: 20.0k]
  ------------------
 1321|       |                /* adapt lastRun to fill 'dst' */
 1322|      0|                assert(olimit >= op);
  ------------------
  |  Branch (1322:17): [True: 0, False: 0]
  |  Branch (1322:17): [True: 0, False: 0]
  ------------------
 1323|      0|                lastRun  = (size_t)(olimit-op) - 1/*token*/;
 1324|      0|                lastRun -= (lastRun + 256 - RUN_MASK) / 256;  /*additional length tokens*/
  ------------------
  |  |  264|      0|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  263|      0|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|      0|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1325|  20.0k|            } else {
 1326|  20.0k|                assert(outputDirective == limitedOutput);
  ------------------
  |  Branch (1326:17): [True: 0, False: 20.0k]
  |  Branch (1326:17): [True: 20.0k, False: 0]
  ------------------
 1327|  20.0k|                return 0;   /* cannot compress within `dst` budget. Stored indexes in hash table are nonetheless fine */
 1328|  20.0k|            }
 1329|  20.0k|        }
 1330|  19.2k|        DEBUGLOG(6, "Final literal run : %i literals", (int)lastRun);
  ------------------
  |  |  290|  19.2k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1331|  19.2k|        if (lastRun >= RUN_MASK) {
  ------------------
  |  |  264|  19.2k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  263|  19.2k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|  19.2k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1331:13): [True: 3.03k, False: 16.2k]
  ------------------
 1332|  3.03k|            size_t accumulator = lastRun - RUN_MASK;
  ------------------
  |  |  264|  3.03k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  263|  3.03k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|  3.03k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1333|  3.03k|            *op++ = RUN_MASK << ML_BITS;
  ------------------
  |  |  264|  3.03k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  263|  3.03k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|  3.03k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                          *op++ = RUN_MASK << ML_BITS;
  ------------------
  |  |  261|  3.03k|#define ML_BITS  4
  ------------------
 1334|   103k|            for(; accumulator >= 255 ; accumulator-=255) *op++ = 255;
  ------------------
  |  Branch (1334:19): [True: 100k, False: 3.03k]
  ------------------
 1335|  3.03k|            *op++ = (BYTE) accumulator;
 1336|  16.2k|        } else {
 1337|  16.2k|            *op++ = (BYTE)(lastRun<<ML_BITS);
  ------------------
  |  |  261|  16.2k|#define ML_BITS  4
  ------------------
 1338|  16.2k|        }
 1339|  19.2k|        LZ4_memcpy(op, anchor, lastRun);
  ------------------
  |  |  350|  19.2k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 1340|  19.2k|        ip = anchor + lastRun;
 1341|  19.2k|        op += lastRun;
 1342|  19.2k|    }
 1343|       |
 1344|  19.2k|    if (outputDirective == fillOutput) {
  ------------------
  |  Branch (1344:9): [True: 0, False: 19.2k]
  ------------------
 1345|      0|        *inputConsumed = (int) (((const char*)ip)-source);
 1346|      0|    }
 1347|  19.2k|    result = (int)(((char*)op) - dest);
 1348|  19.2k|    assert(result > 0);
  ------------------
  |  Branch (1348:5): [True: 0, False: 19.2k]
  |  Branch (1348:5): [True: 19.2k, False: 0]
  ------------------
 1349|  19.2k|    DEBUGLOG(5, "LZ4_compress_generic: compressed %i bytes into %i bytes", inputSize, result);
  ------------------
  |  |  290|  19.2k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1350|  19.2k|    return result;
 1351|  19.2k|}
lz4.c:LZ4_hashPosition:
  807|  48.0M|{
  808|  48.0M|    if ((sizeof(reg_t)==8) && (tableType != byU16)) return LZ4_hash5(LZ4_read_ARCH(p), tableType);
  ------------------
  |  Branch (808:9): [True: 48.0M, Folded]
  |  Branch (808:31): [True: 40.1M, False: 7.90M]
  ------------------
  809|       |
  810|       |#ifdef LZ4_STATIC_LINKING_ONLY_ENDIANNESS_INDEPENDENT_OUTPUT
  811|       |    return LZ4_hash4(LZ4_readLE32(p), tableType);
  812|       |#else
  813|  7.90M|    return LZ4_hash4(LZ4_read32(p), tableType);
  814|  48.0M|#endif
  815|  48.0M|}
lz4.c:LZ4_hash5:
  795|  40.1M|{
  796|  40.1M|    const U32 hashLog = (tableType == byU16) ? LZ4_HASHLOG+1 : LZ4_HASHLOG;
  ------------------
  |  |  699|      0|#define LZ4_HASHLOG   (LZ4_MEMORY_USAGE-2)
  |  |  ------------------
  |  |  |  |  158|      0|# define LZ4_MEMORY_USAGE LZ4_MEMORY_USAGE_DEFAULT
  |  |  |  |  ------------------
  |  |  |  |  |  |  163|      0|#define LZ4_MEMORY_USAGE_DEFAULT 14
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  const U32 hashLog = (tableType == byU16) ? LZ4_HASHLOG+1 : LZ4_HASHLOG;
  ------------------
  |  |  699|  80.3M|#define LZ4_HASHLOG   (LZ4_MEMORY_USAGE-2)
  |  |  ------------------
  |  |  |  |  158|  40.1M|# define LZ4_MEMORY_USAGE LZ4_MEMORY_USAGE_DEFAULT
  |  |  |  |  ------------------
  |  |  |  |  |  |  163|  40.1M|#define LZ4_MEMORY_USAGE_DEFAULT 14
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (796:25): [True: 0, False: 40.1M]
  ------------------
  797|  40.1M|    if (LZ4_isLittleEndian()) {
  ------------------
  |  Branch (797:9): [True: 40.1M, False: 0]
  ------------------
  798|  40.1M|        const U64 prime5bytes = 889523592379ULL;
  799|  40.1M|        return (U32)(((sequence << 24) * prime5bytes) >> (64 - hashLog));
  800|  40.1M|    } else {
  801|      0|        const U64 prime8bytes = 11400714785074694791ULL;
  802|      0|        return (U32)(((sequence >> 24) * prime8bytes) >> (64 - hashLog));
  803|      0|    }
  804|  40.1M|}
lz4.c:LZ4_isLittleEndian:
  365|  58.0M|{
  366|  58.0M|    const union { U32 u; BYTE c[4]; } one = { 1 };   /* don't use static : performance detrimental */
  367|  58.0M|    return one.c[0];
  368|  58.0M|}
lz4.c:LZ4_read_ARCH:
  396|   128M|static reg_t LZ4_read_ARCH(const void* ptr) { return ((const LZ4_unalignST*)ptr)->uArch; }
lz4.c:LZ4_hash4:
  787|  7.90M|{
  788|  7.90M|    if (tableType == byU16)
  ------------------
  |  Branch (788:9): [True: 7.90M, False: 0]
  ------------------
  789|  7.90M|        return ((sequence * 2654435761U) >> ((MINMATCH*8)-(LZ4_HASHLOG+1)));
  ------------------
  |  |  243|  7.90M|#define MINMATCH 4
  ------------------
                      return ((sequence * 2654435761U) >> ((MINMATCH*8)-(LZ4_HASHLOG+1)));
  ------------------
  |  |  699|  7.90M|#define LZ4_HASHLOG   (LZ4_MEMORY_USAGE-2)
  |  |  ------------------
  |  |  |  |  158|  7.90M|# define LZ4_MEMORY_USAGE LZ4_MEMORY_USAGE_DEFAULT
  |  |  |  |  ------------------
  |  |  |  |  |  |  163|  7.90M|#define LZ4_MEMORY_USAGE_DEFAULT 14
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  790|      0|    else
  791|      0|        return ((sequence * 2654435761U) >> ((MINMATCH*8)-LZ4_HASHLOG));
  ------------------
  |  |  243|      0|#define MINMATCH 4
  ------------------
                      return ((sequence * 2654435761U) >> ((MINMATCH*8)-LZ4_HASHLOG));
  ------------------
  |  |  699|      0|#define LZ4_HASHLOG   (LZ4_MEMORY_USAGE-2)
  |  |  ------------------
  |  |  |  |  158|      0|# define LZ4_MEMORY_USAGE LZ4_MEMORY_USAGE_DEFAULT
  |  |  |  |  ------------------
  |  |  |  |  |  |  163|      0|#define LZ4_MEMORY_USAGE_DEFAULT 14
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  792|  7.90M|}
lz4.c:LZ4_putIndexOnHash:
  830|  44.8M|{
  831|  44.8M|    switch (tableType)
  832|  44.8M|    {
  833|      0|    default: /* fallthrough */
  ------------------
  |  Branch (833:5): [True: 0, False: 44.8M]
  ------------------
  834|      0|    case clearedTable: /* fallthrough */
  ------------------
  |  Branch (834:5): [True: 0, False: 44.8M]
  ------------------
  835|      0|    case byPtr: { /* illegal! */ assert(0); return; }
  ------------------
  |  Branch (835:5): [True: 0, False: 44.8M]
  |  Branch (835:34): [Folded, False: 0]
  |  Branch (835:34): [Folded, False: 0]
  ------------------
  836|  37.4M|    case byU32: { U32* hashTable = (U32*) tableBase; hashTable[h] = idx; return; }
  ------------------
  |  Branch (836:5): [True: 37.4M, False: 7.39M]
  ------------------
  837|  7.39M|    case byU16: { U16* hashTable = (U16*) tableBase; assert(idx < 65536); hashTable[h] = (U16)idx; return; }
  ------------------
  |  Branch (837:5): [True: 7.39M, False: 37.4M]
  |  Branch (837:54): [True: 0, False: 7.39M]
  |  Branch (837:54): [True: 7.39M, False: 0]
  ------------------
  838|  44.8M|    }
  839|  44.8M|}
lz4.c:LZ4_read32:
  395|  74.8M|static U32 LZ4_read32(const void* ptr) { return ((const LZ4_unalign32*)ptr)->u32; }
lz4.c:LZ4_getIndexOnHash:
  863|  37.7M|{
  864|  37.7M|    LZ4_STATIC_ASSERT(LZ4_MEMORY_USAGE > 2);
  ------------------
  |  |  278|  37.7M|#define LZ4_STATIC_ASSERT(c)   { enum { LZ4_static_assert = 1/(int)(!!(c)) }; }   /* use after variable declarations */
  ------------------
  865|  37.7M|    if (tableType == byU32) {
  ------------------
  |  Branch (865:9): [True: 31.7M, False: 5.95M]
  ------------------
  866|  31.7M|        const U32* const hashTable = (const U32*) tableBase;
  867|  31.7M|        assert(h < (1U << (LZ4_MEMORY_USAGE-2)));
  ------------------
  |  Branch (867:9): [True: 0, False: 31.7M]
  |  Branch (867:9): [True: 31.7M, False: 0]
  ------------------
  868|  31.7M|        return hashTable[h];
  869|  31.7M|    }
  870|  5.95M|    if (tableType == byU16) {
  ------------------
  |  Branch (870:9): [True: 5.95M, False: 0]
  ------------------
  871|  5.95M|        const U16* const hashTable = (const U16*) tableBase;
  872|  5.95M|        assert(h < (1U << (LZ4_MEMORY_USAGE-1)));
  ------------------
  |  Branch (872:9): [True: 0, False: 5.95M]
  |  Branch (872:9): [True: 5.95M, False: 0]
  ------------------
  873|  5.95M|        return hashTable[h];
  874|  5.95M|    }
  875|  5.95M|    assert(0); return 0;  /* forbidden case */
  ------------------
  |  Branch (875:5): [Folded, False: 0]
  |  Branch (875:5): [Folded, False: 0]
  ------------------
  876|      0|}
lz4.c:LZ4_wildCopy8:
  467|  3.32M|{
  468|  3.32M|    BYTE* d = (BYTE*)dstPtr;
  469|  3.32M|    const BYTE* s = (const BYTE*)srcPtr;
  470|  3.32M|    BYTE* const e = (BYTE*)dstEnd;
  471|       |
  472|  15.6M|    do { LZ4_memcpy(d,s,8); d+=8; s+=8; } while (d<e);
  ------------------
  |  |  350|  15.6M|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  |  Branch (472:50): [True: 12.3M, False: 3.32M]
  ------------------
  473|  3.32M|}
lz4.c:LZ4_writeLE16:
  454|  7.09M|{
  455|  7.09M|    if (LZ4_isLittleEndian()) {
  ------------------
  |  Branch (455:9): [True: 7.09M, False: 0]
  ------------------
  456|  7.09M|        LZ4_write16(memPtr, value);
  457|  7.09M|    } else {
  458|      0|        BYTE* p = (BYTE*)memPtr;
  459|      0|        p[0] = (BYTE) value;
  460|      0|        p[1] = (BYTE)(value>>8);
  461|      0|    }
  462|  7.09M|}
lz4.c:LZ4_write16:
  398|  7.09M|static void LZ4_write16(void* memPtr, U16 value) { ((LZ4_unalign16*)memPtr)->u16 = value; }
lz4.c:LZ4_count:
  690|  7.10M|{
  691|  7.10M|    const BYTE* const pStart = pIn;
  692|       |
  693|  7.10M|    if (likely(pIn < pInLimit-(STEPSIZE-1))) {
  ------------------
  |  |  178|  7.10M|#define likely(expr)     expect((expr) != 0, 1)
  |  |  ------------------
  |  |  |  |  172|  7.10M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 7.09M, False: 10.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  694|  7.09M|        reg_t const diff = LZ4_read_ARCH(pMatch) ^ LZ4_read_ARCH(pIn);
  695|  7.09M|        if (!diff) {
  ------------------
  |  Branch (695:13): [True: 1.70M, False: 5.38M]
  ------------------
  696|  1.70M|            pIn+=STEPSIZE; pMatch+=STEPSIZE;
  ------------------
  |  |  687|  1.70M|#define STEPSIZE sizeof(reg_t)
  ------------------
                          pIn+=STEPSIZE; pMatch+=STEPSIZE;
  ------------------
  |  |  687|  1.70M|#define STEPSIZE sizeof(reg_t)
  ------------------
  697|  5.38M|        } else {
  698|  5.38M|            return LZ4_NbCommonBytes(diff);
  699|  5.38M|    }   }
  700|       |
  701|  37.0M|    while (likely(pIn < pInLimit-(STEPSIZE-1))) {
  702|  37.0M|        reg_t const diff = LZ4_read_ARCH(pMatch) ^ LZ4_read_ARCH(pIn);
  703|  37.0M|        if (!diff) { pIn+=STEPSIZE; pMatch+=STEPSIZE; continue; }
  ------------------
  |  |  687|  35.3M|#define STEPSIZE sizeof(reg_t)
  ------------------
                      if (!diff) { pIn+=STEPSIZE; pMatch+=STEPSIZE; continue; }
  ------------------
  |  |  687|  35.3M|#define STEPSIZE sizeof(reg_t)
  ------------------
  |  Branch (703:13): [True: 35.3M, False: 1.69M]
  ------------------
  704|  1.69M|        pIn += LZ4_NbCommonBytes(diff);
  705|  1.69M|        return (unsigned)(pIn - pStart);
  706|  37.0M|    }
  707|       |
  708|  20.5k|    if ((STEPSIZE==8) && (pIn<(pInLimit-3)) && (LZ4_read32(pMatch) == LZ4_read32(pIn))) { pIn+=4; pMatch+=4; }
  ------------------
  |  |  687|  20.5k|#define STEPSIZE sizeof(reg_t)
  ------------------
  |  Branch (708:9): [True: 20.5k, Folded]
  |  Branch (708:26): [True: 10.5k, False: 9.98k]
  |  Branch (708:48): [True: 6.21k, False: 4.30k]
  ------------------
  709|  20.5k|    if ((pIn<(pInLimit-1)) && (LZ4_read16(pMatch) == LZ4_read16(pIn))) { pIn+=2; pMatch+=2; }
  ------------------
  |  Branch (709:9): [True: 12.3k, False: 8.12k]
  |  Branch (709:31): [True: 7.58k, False: 4.80k]
  ------------------
  710|  20.5k|    if ((pIn<pInLimit) && (*pMatch == *pIn)) pIn++;
  ------------------
  |  Branch (710:9): [True: 13.1k, False: 7.37k]
  |  Branch (710:27): [True: 8.27k, False: 4.85k]
  ------------------
  711|  20.5k|    return (unsigned)(pIn - pStart);
  712|  1.71M|}
lz4.c:LZ4_NbCommonBytes:
  589|  7.08M|{
  590|  7.08M|    assert(val != 0);
  ------------------
  |  Branch (590:5): [True: 0, False: 7.08M]
  |  Branch (590:5): [True: 7.08M, False: 0]
  ------------------
  591|  7.08M|    if (LZ4_isLittleEndian()) {
  ------------------
  |  Branch (591:9): [True: 7.08M, False: 0]
  ------------------
  592|  7.08M|        if (sizeof(val) == 8) {
  ------------------
  |  Branch (592:13): [True: 7.08M, Folded]
  ------------------
  593|       |#       if defined(_MSC_VER) && (_MSC_VER >= 1800) && (defined(_M_AMD64) && !defined(_M_ARM64EC)) && !defined(LZ4_FORCE_SW_BITCOUNT)
  594|       |/*-*************************************************************************************************
  595|       |* ARM64EC is a Microsoft-designed ARM64 ABI compatible with AMD64 applications on ARM64 Windows 11.
  596|       |* The ARM64EC ABI does not support AVX/AVX2/AVX512 instructions, nor their relevant intrinsics
  597|       |* including _tzcnt_u64. Therefore, we need to neuter the _tzcnt_u64 code path for ARM64EC.
  598|       |****************************************************************************************************/
  599|       |#         if defined(__clang__) && (__clang_major__ < 10)
  600|       |            /* Avoid undefined clang-cl intrinsics issue.
  601|       |             * See https://github.com/lz4/lz4/pull/1017 for details. */
  602|       |            return (unsigned)__builtin_ia32_tzcnt_u64(val) >> 3;
  603|       |#         else
  604|       |            /* x64 CPUS without BMI support interpret `TZCNT` as `REP BSF` */
  605|       |            return (unsigned)_tzcnt_u64(val) >> 3;
  606|       |#         endif
  607|       |#       elif defined(_MSC_VER) && defined(_WIN64) && !defined(LZ4_FORCE_SW_BITCOUNT)
  608|       |            unsigned long r = 0;
  609|       |            _BitScanForward64(&r, (U64)val);
  610|       |            return (unsigned)r >> 3;
  611|       |#       elif (defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 3) || \
  612|       |                            ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))))) && \
  613|       |                                        !defined(LZ4_FORCE_SW_BITCOUNT)
  614|       |            return (unsigned)__builtin_ctzll((U64)val) >> 3;
  615|       |#       else
  616|       |            const U64 m = 0x0101010101010101ULL;
  617|       |            val ^= val - 1;
  618|       |            return (unsigned)(((U64)((val & (m - 1)) * m)) >> 56);
  619|       |#       endif
  620|  7.08M|        } else /* 32 bits */ {
  621|       |#       if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(LZ4_FORCE_SW_BITCOUNT)
  622|       |            unsigned long r;
  623|       |            _BitScanForward(&r, (U32)val);
  624|       |            return (unsigned)r >> 3;
  625|       |#       elif (defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 3) || \
  626|       |                            ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))))) && \
  627|       |                        !defined(__TINYC__) && !defined(LZ4_FORCE_SW_BITCOUNT)
  628|       |            return (unsigned)__builtin_ctz((U32)val) >> 3;
  629|       |#       else
  630|       |            const U32 m = 0x01010101;
  631|       |            return (unsigned)((((val - 1) ^ val) & (m - 1)) * m) >> 24;
  632|       |#       endif
  633|      0|        }
  634|  7.08M|    } else   /* Big Endian CPU */ {
  635|      0|        if (sizeof(val)==8) {
  ------------------
  |  Branch (635:13): [True: 0, Folded]
  ------------------
  636|      0|#       if (defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 3) || \
  637|      0|                            ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))))) && \
  638|      0|                        !defined(__TINYC__) && !defined(LZ4_FORCE_SW_BITCOUNT)
  639|      0|            return (unsigned)__builtin_clzll((U64)val) >> 3;
  640|       |#       else
  641|       |#if 1
  642|       |            /* this method is probably faster,
  643|       |             * but adds a 128 bytes lookup table */
  644|       |            static const unsigned char ctz7_tab[128] = {
  645|       |                7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  646|       |                4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  647|       |                5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  648|       |                4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  649|       |                6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  650|       |                4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  651|       |                5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  652|       |                4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  653|       |            };
  654|       |            U64 const mask = 0x0101010101010101ULL;
  655|       |            U64 const t = (((val >> 8) - mask) | val) & mask;
  656|       |            return ctz7_tab[(t * 0x0080402010080402ULL) >> 57];
  657|       |#else
  658|       |            /* this method doesn't consume memory space like the previous one,
  659|       |             * but it contains several branches,
  660|       |             * that may end up slowing execution */
  661|       |            static const U32 by32 = sizeof(val)*4;  /* 32 on 64 bits (goal), 16 on 32 bits.
  662|       |            Just to avoid some static analyzer complaining about shift by 32 on 32-bits target.
  663|       |            Note that this code path is never triggered in 32-bits mode. */
  664|       |            unsigned r;
  665|       |            if (!(val>>by32)) { r=4; } else { r=0; val>>=by32; }
  666|       |            if (!(val>>16)) { r+=2; val>>=8; } else { val>>=24; }
  667|       |            r += (!val);
  668|       |            return r;
  669|       |#endif
  670|       |#       endif
  671|      0|        } else /* 32 bits */ {
  672|      0|#       if (defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 3) || \
  673|      0|                            ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))))) && \
  674|      0|                                        !defined(LZ4_FORCE_SW_BITCOUNT)
  675|      0|            return (unsigned)__builtin_clz((U32)val) >> 3;
  676|       |#       else
  677|       |            val >>= 8;
  678|       |            val = ((((val + 0x00FFFF00) | 0x00FFFFFF) + val) |
  679|       |              (val + 0x00FF0000)) >> 24;
  680|       |            return (unsigned)val ^ 3;
  681|       |#       endif
  682|      0|        }
  683|      0|    }
  684|  7.08M|}
lz4.c:LZ4_read16:
  394|  3.67M|static U16 LZ4_read16(const void* ptr) { return ((const LZ4_unalign16*)ptr)->u16; }
lz4.c:LZ4_write32:
  399|  1.18M|static void LZ4_write32(void* memPtr, U32 value) { ((LZ4_unalign32*)memPtr)->u32 = value; }
lz4.c:LZ4_largeInputTableType:
 1407|    785|{
 1408|    785|    (void)src;   /* unused on 64-bit systems */
 1409|    785|    return ((sizeof(void*)==4) && ((uptrval)src > LZ4_DISTANCE_MAX)) ? byPtr : byU32;
  ------------------
  |  |  678|      0|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (1409:13): [Folded, False: 785]
  |  Branch (1409:35): [True: 0, False: 0]
  ------------------
 1410|    785|}
lz4.c:LZ4_prepareTable:
  899|  11.0k|           const tableType_t tableType) {
  900|       |    /* If the table hasn't been used, it's guaranteed to be zeroed out, and is
  901|       |     * therefore safe to use no matter what mode we're in. Otherwise, we figure
  902|       |     * out if it's safe to leave as is or whether it needs to be reset.
  903|       |     */
  904|  11.0k|    if ((tableType_t)cctx->tableType != clearedTable) {
  ------------------
  |  Branch (904:9): [True: 4.43k, False: 6.65k]
  ------------------
  905|  4.43k|        assert(inputSize >= 0);
  ------------------
  |  Branch (905:9): [True: 0, False: 4.43k]
  |  Branch (905:9): [True: 4.43k, False: 0]
  ------------------
  906|  4.43k|        if ((tableType_t)cctx->tableType != tableType
  ------------------
  |  Branch (906:13): [True: 294, False: 4.14k]
  ------------------
  907|  4.14k|          || ((tableType == byU16) && cctx->currentOffset + (unsigned)inputSize >= 0xFFFFU)
  ------------------
  |  Branch (907:15): [True: 4.05k, False: 89]
  |  Branch (907:39): [True: 543, False: 3.51k]
  ------------------
  908|  3.59k|          || ((tableType == byU32) && cctx->currentOffset > 1 GB)
  ------------------
  |  |  254|     89|#define GB *(1U<<30)
  ------------------
  |  Branch (908:15): [True: 89, False: 3.51k]
  |  Branch (908:39): [True: 0, False: 89]
  ------------------
  909|  3.59k|          || tableType == byPtr
  ------------------
  |  Branch (909:14): [True: 0, False: 3.59k]
  ------------------
  910|  3.59k|          || inputSize >= LZ4_CLEAR_TABLE_THRESHOLD)
  ------------------
  |  |  894|  3.59k|#define LZ4_CLEAR_TABLE_THRESHOLD (LZ4_HASHTABLESIZE / 16)
  |  |  ------------------
  |  |  |  |  700|  3.59k|#define LZ4_HASHTABLESIZE (1 << LZ4_MEMORY_USAGE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|  3.59k|# define LZ4_MEMORY_USAGE LZ4_MEMORY_USAGE_DEFAULT
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  163|  3.59k|#define LZ4_MEMORY_USAGE_DEFAULT 14
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (910:14): [True: 523, False: 3.07k]
  ------------------
  911|  1.36k|        {
  912|  1.36k|            DEBUGLOG(4, "LZ4_prepareTable: Resetting table in %p", (void*)cctx);
  ------------------
  |  |  290|  1.36k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  913|  1.36k|            MEM_INIT(cctx->hashTable, 0, LZ4_HASHTABLESIZE);
  ------------------
  |  |  237|  1.36k|#define MEM_INIT(p,v,s)   LZ4_memset((p),(v),(s))
  |  |  ------------------
  |  |  |  |  235|  1.36k|#  define LZ4_memset(p,v,s) memset((p),(v),(s))
  |  |  ------------------
  ------------------
  914|  1.36k|            cctx->currentOffset = 0;
  915|  1.36k|            cctx->tableType = (U32)clearedTable;
  916|  3.07k|        } else {
  917|  3.07k|            DEBUGLOG(4, "LZ4_prepareTable: Re-use hash table (no reset)");
  ------------------
  |  |  290|  3.07k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  918|  3.07k|        }
  919|  4.43k|    }
  920|       |
  921|       |    /* Adding a gap, so all previous entries are > LZ4_DISTANCE_MAX back,
  922|       |     * is faster than compressing without a gap.
  923|       |     * However, compressing with currentOffset == 0 is faster still,
  924|       |     * so we preserve that case.
  925|       |     */
  926|  11.0k|    if (cctx->currentOffset != 0 && tableType == byU32) {
  ------------------
  |  Branch (926:9): [True: 3.07k, False: 8.01k]
  |  Branch (926:37): [True: 0, False: 3.07k]
  ------------------
  927|      0|        DEBUGLOG(5, "LZ4_prepareTable: adding 64KB to currentOffset");
  ------------------
  |  |  290|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  928|      0|        cctx->currentOffset += 64 KB;
  ------------------
  |  |  252|      0|#define KB *(1 <<10)
  ------------------
  929|      0|    }
  930|       |
  931|       |    /* Finally, clear history */
  932|  11.0k|    cctx->dictCtx = NULL;
  933|       |    cctx->dictionary = NULL;
  934|  11.0k|    cctx->dictSize = 0;
  935|  11.0k|}
lz4.c:LZ4_isAligned:
  294|  51.4k|{
  295|  51.4k|    return ((size_t)ptr & (alignment -1)) == 0;
  296|  51.4k|}
lz4.c:LZ4_stream_t_alignment:
 1569|  51.4k|{
 1570|  51.4k|#if LZ4_ALIGN_TEST
 1571|  51.4k|    typedef struct { char c; LZ4_stream_t t; } t_a;
 1572|  51.4k|    return sizeof(t_a) - sizeof(LZ4_stream_t);
 1573|       |#else
 1574|       |    return 1;  /* effectively disabled */
 1575|       |#endif
 1576|  51.4k|}
lz4.c:LZ4_renormDictT:
 1718|  31.6k|{
 1719|  31.6k|    assert(nextSize >= 0);
  ------------------
  |  Branch (1719:5): [True: 0, False: 31.6k]
  |  Branch (1719:5): [True: 31.6k, False: 0]
  ------------------
 1720|  31.6k|    if (LZ4_dict->currentOffset + (unsigned)nextSize > 0x80000000) {   /* potential ptrdiff_t overflow (32-bits mode) */
  ------------------
  |  Branch (1720:9): [True: 0, False: 31.6k]
  ------------------
 1721|       |        /* rescale hash table */
 1722|      0|        U32 const delta = LZ4_dict->currentOffset - 64 KB;
  ------------------
  |  |  252|      0|#define KB *(1 <<10)
  ------------------
 1723|      0|        const BYTE* dictEnd = LZ4_dict->dictionary + LZ4_dict->dictSize;
 1724|      0|        int i;
 1725|      0|        DEBUGLOG(4, "LZ4_renormDictT");
  ------------------
  |  |  290|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1726|      0|        for (i=0; i<LZ4_HASH_SIZE_U32; i++) {
  ------------------
  |  |  701|      0|#define LZ4_HASH_SIZE_U32 (1 << LZ4_HASHLOG)       /* required as macro for static allocation */
  |  |  ------------------
  |  |  |  |  699|      0|#define LZ4_HASHLOG   (LZ4_MEMORY_USAGE-2)
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|      0|# define LZ4_MEMORY_USAGE LZ4_MEMORY_USAGE_DEFAULT
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  163|      0|#define LZ4_MEMORY_USAGE_DEFAULT 14
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1726:19): [True: 0, False: 0]
  ------------------
 1727|      0|            if (LZ4_dict->hashTable[i] < delta) LZ4_dict->hashTable[i]=0;
  ------------------
  |  Branch (1727:17): [True: 0, False: 0]
  ------------------
 1728|      0|            else LZ4_dict->hashTable[i] -= delta;
 1729|      0|        }
 1730|      0|        LZ4_dict->currentOffset = 64 KB;
  ------------------
  |  |  252|      0|#define KB *(1 <<10)
  ------------------
 1731|      0|        if (LZ4_dict->dictSize > 64 KB) LZ4_dict->dictSize = 64 KB;
  ------------------
  |  |  252|      0|#define KB *(1 <<10)
  ------------------
                      if (LZ4_dict->dictSize > 64 KB) LZ4_dict->dictSize = 64 KB;
  ------------------
  |  |  252|      0|#define KB *(1 <<10)
  ------------------
  |  Branch (1731:13): [True: 0, False: 0]
  ------------------
 1732|      0|        LZ4_dict->dictionary = dictEnd - LZ4_dict->dictSize;
 1733|      0|    }
 1734|  31.6k|}
lz4.c:LZ4_isDictSmall:
 1740|  31.6k|{
 1741|  31.6k|    return (streamPtr->dictSize < 64 KB) && (streamPtr->dictSize < streamPtr->currentOffset);
  ------------------
  |  |  252|  31.6k|#define KB *(1 <<10)
  ------------------
  |  Branch (1741:12): [True: 29.4k, False: 2.23k]
  |  Branch (1741:45): [True: 10.6k, False: 18.7k]
  ------------------
 1742|  31.6k|}
lz4.c:LZ4_decompress_generic:
 2067|  13.6k|{
 2068|  13.6k|    if ((src == NULL) || (outputSize < 0)) { return -1; }
  ------------------
  |  Branch (2068:9): [True: 0, False: 13.6k]
  |  Branch (2068:26): [True: 0, False: 13.6k]
  ------------------
 2069|       |
 2070|  13.6k|    {   const BYTE* ip = (const BYTE*) src;
 2071|  13.6k|        const BYTE* const iend = ip + srcSize;
 2072|       |
 2073|  13.6k|        BYTE* op = (BYTE*) dst;
 2074|  13.6k|        BYTE* const oend = op + outputSize;
 2075|  13.6k|        BYTE* cpy;
 2076|       |
 2077|  13.6k|        const BYTE* const dictEnd = (dictStart == NULL) ? NULL : dictStart + dictSize;
  ------------------
  |  Branch (2077:37): [True: 8.41k, False: 5.26k]
  ------------------
 2078|       |
 2079|  13.6k|        const int checkOffset = (dictSize < (int)(64 KB));
  ------------------
  |  |  252|  13.6k|#define KB *(1 <<10)
  ------------------
 2080|       |
 2081|       |
 2082|       |        /* Set up the "end" pointers for the shortcut. */
 2083|  13.6k|        const BYTE* const shortiend = iend - 14 /*maxLL*/ - 2 /*offset*/;
 2084|  13.6k|        const BYTE* const shortoend = oend - 14 /*maxLL*/ - 18 /*maxML*/;
 2085|       |
 2086|  13.6k|        const BYTE* match;
 2087|  13.6k|        size_t offset;
 2088|  13.6k|        unsigned token;
 2089|  13.6k|        size_t length;
 2090|       |
 2091|       |
 2092|  13.6k|        DEBUGLOG(5, "LZ4_decompress_generic (srcSize:%i, dstSize:%i)", srcSize, outputSize);
  ------------------
  |  |  290|  13.6k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2093|       |
 2094|       |        /* Special cases */
 2095|  13.6k|        assert(lowPrefix <= op);
  ------------------
  |  Branch (2095:9): [True: 0, False: 13.6k]
  |  Branch (2095:9): [True: 13.6k, False: 0]
  ------------------
 2096|  13.6k|        if (unlikely(outputSize==0)) {
  ------------------
  |  |  181|  13.6k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|  13.6k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 0, False: 13.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2097|       |            /* Empty output buffer */
 2098|      0|            if (partialDecoding) return 0;
  ------------------
  |  Branch (2098:17): [True: 0, False: 0]
  ------------------
 2099|      0|            return ((srcSize==1) && (*ip==0)) ? 0 : -1;
  ------------------
  |  Branch (2099:21): [True: 0, False: 0]
  |  Branch (2099:37): [True: 0, False: 0]
  ------------------
 2100|      0|        }
 2101|  13.6k|        if (unlikely(srcSize==0)) { return -1; }
  ------------------
  |  |  181|  13.6k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|  13.6k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 0, False: 13.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2102|       |
 2103|       |    /* LZ4_FAST_DEC_LOOP:
 2104|       |     * designed for modern OoO performance cpus,
 2105|       |     * where copying reliably 32-bytes is preferable to an unpredictable branch.
 2106|       |     * note : fast loop may show a regression for some client arm chips. */
 2107|  13.6k|#if LZ4_FAST_DEC_LOOP
 2108|  13.6k|        if ((oend - op) < FASTLOOP_SAFE_DISTANCE) {
  ------------------
  |  |  249|  13.6k|#define FASTLOOP_SAFE_DISTANCE 64
  ------------------
  |  Branch (2108:13): [True: 0, False: 13.6k]
  ------------------
 2109|      0|            DEBUGLOG(6, "move to safe decode loop");
  ------------------
  |  |  290|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2110|      0|            goto safe_decode;
 2111|      0|        }
 2112|       |
 2113|       |        /* Fast loop : decode sequences as long as output < oend-FASTLOOP_SAFE_DISTANCE */
 2114|  13.6k|        DEBUGLOG(6, "using fast decode loop");
  ------------------
  |  |  290|  13.6k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2115|  3.64M|        while (1) {
  ------------------
  |  Branch (2115:16): [True: 3.64M, Folded]
  ------------------
 2116|       |            /* Main fastloop assertion: We can always wildcopy FASTLOOP_SAFE_DISTANCE */
 2117|  3.64M|            assert(oend - op >= FASTLOOP_SAFE_DISTANCE);
  ------------------
  |  Branch (2117:13): [True: 0, False: 3.64M]
  |  Branch (2117:13): [True: 3.64M, False: 0]
  ------------------
 2118|  3.64M|            assert(ip < iend);
  ------------------
  |  Branch (2118:13): [True: 0, False: 3.64M]
  |  Branch (2118:13): [True: 3.64M, False: 0]
  ------------------
 2119|  3.64M|            token = *ip++;
 2120|  3.64M|            length = token >> ML_BITS;  /* literal length */
  ------------------
  |  |  261|  3.64M|#define ML_BITS  4
  ------------------
 2121|  3.64M|            DEBUGLOG(7, "blockPos%6u: litLength token = %u", (unsigned)(op-(BYTE*)dst), (unsigned)length);
  ------------------
  |  |  290|  3.64M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2122|       |
 2123|  3.64M|            if (ip > iend-(16 + 1/*max lit + offset + nextToken*/)) { goto safe_literal_copy_early; }
  ------------------
  |  Branch (2123:17): [True: 10.5k, False: 3.63M]
  ------------------
 2124|       |
 2125|       |            /* decode literal length */
 2126|  3.63M|            if (length == RUN_MASK) {
  ------------------
  |  |  264|  3.63M|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  263|  3.63M|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|  3.63M|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2126:17): [True: 260k, False: 3.37M]
  ------------------
 2127|       |                /* literal length >= RUN_MASK means >= RUN_MASK literal bytes follow the extension bytes,
 2128|       |                 * so extension bytes cannot reach the last RUN_MASK bytes of input */
 2129|   260k|                size_t const addl = read_variable_length(&ip, iend - RUN_MASK);
  ------------------
  |  |  264|   260k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  263|   260k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|   260k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2130|   260k|                if (addl == rvl_error) {
  ------------------
  |  Branch (2130:21): [True: 0, False: 260k]
  ------------------
 2131|      0|                    DEBUGLOG(6, "error reading long literal length");
  ------------------
  |  |  290|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2132|      0|                    goto _output_error;
 2133|      0|                }
 2134|   260k|                length += addl;
 2135|   260k|                cpy = op+length;
 2136|   260k|                if (unlikely((uptrval)(cpy)<(uptrval)(op))) { goto _output_error; } /* overflow detection */
  ------------------
  |  |  181|   260k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|   260k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 0, False: 260k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2137|   260k|                if (unlikely((uptrval)(ip)+length<(uptrval)(ip))) { goto _output_error; } /* overflow detection */
  ------------------
  |  |  181|   260k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|   260k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 0, False: 260k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2138|       |
 2139|       |                /* copy literals */
 2140|   260k|                LZ4_STATIC_ASSERT(MFLIMIT >= WILDCOPYLENGTH);
  ------------------
  |  |  278|   260k|#define LZ4_STATIC_ASSERT(c)   { enum { LZ4_static_assert = 1/(int)(!!(c)) }; }   /* use after variable declarations */
  ------------------
 2141|       |              #ifdef __aarch64__
 2142|       |                if ((cpy>oend-64) || (ip+length>iend-64)) { goto safe_literal_copy; }
 2143|       |                LZ4_wildCopy64(op, ip, cpy);
 2144|       |              #else
 2145|   260k|                if ((cpy>oend-32) || (ip+length>iend-32)) { goto safe_literal_copy; }
  ------------------
  |  Branch (2145:21): [True: 106, False: 260k]
  |  Branch (2145:38): [True: 2.08k, False: 258k]
  ------------------
 2146|   258k|                LZ4_wildCopy32(op, ip, cpy);
 2147|   258k|              #endif
 2148|   258k|                ip += length; op = cpy;
 2149|  3.37M|            } else {
 2150|  3.37M|                DEBUGLOG(7, "copy %u bytes in a 16-bytes stripe", (unsigned)length);
  ------------------
  |  |  290|  3.37M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2151|       |                /* Literals can only be <= 14, but hope compilers optimize better when copy by a register size */
 2152|  3.37M|                LZ4_memcpy(op, ip, 16);
  ------------------
  |  |  350|  3.37M|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2153|  3.37M|                ip += length; op += length;
 2154|  3.37M|            }
 2155|       |
 2156|       |            /* get offset */
 2157|  3.63M|            offset = LZ4_readLE16(ip); ip+=2;
 2158|  3.63M|            DEBUGLOG(6, "blockPos%6u: offset = %u", (unsigned)(op-(BYTE*)dst), (unsigned)offset);
  ------------------
  |  |  290|  3.63M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2159|  3.63M|            match = op - offset;
 2160|  3.63M|            assert(match <= op);  /* overflow check */
  ------------------
  |  Branch (2160:13): [True: 0, False: 3.63M]
  |  Branch (2160:13): [True: 3.63M, False: 0]
  ------------------
 2161|       |
 2162|       |            /* get matchlength */
 2163|  3.63M|            length = token & ML_MASK;
  ------------------
  |  |  262|  3.63M|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  261|  3.63M|#define ML_BITS  4
  |  |  ------------------
  ------------------
 2164|  3.63M|            DEBUGLOG(7, "  match length token = %u (len==%u)", (unsigned)length, (unsigned)length+MINMATCH);
  ------------------
  |  |  290|  3.63M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2165|       |
 2166|  3.63M|            if (length == ML_MASK) {
  ------------------
  |  |  262|  3.63M|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  261|  3.63M|#define ML_BITS  4
  |  |  ------------------
  ------------------
  |  Branch (2166:17): [True: 618k, False: 3.01M]
  ------------------
 2167|       |                /* after match length extension bytes, at least 1 token + LASTLITERALS literals must remain */
 2168|   618k|                size_t const addl = read_variable_length(&ip, iend - (1 + LASTLITERALS));
  ------------------
  |  |  246|   618k|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
 2169|   618k|                if (addl == rvl_error) {
  ------------------
  |  Branch (2169:21): [True: 0, False: 618k]
  ------------------
 2170|      0|                    DEBUGLOG(5, "error reading long match length");
  ------------------
  |  |  290|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2171|      0|                    goto _output_error;
 2172|      0|                }
 2173|   618k|                length += addl;
 2174|   618k|                length += MINMATCH;
  ------------------
  |  |  243|   618k|#define MINMATCH 4
  ------------------
 2175|   618k|                DEBUGLOG(7, "  long match length == %u", (unsigned)length);
  ------------------
  |  |  290|   618k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2176|   618k|                if (unlikely((uptrval)(op)+length<(uptrval)op)) { goto _output_error; } /* overflow detection */
  ------------------
  |  |  181|   618k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|   618k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 0, False: 618k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2177|   618k|                if (op + length >= oend - FASTLOOP_SAFE_DISTANCE) {
  ------------------
  |  |  249|   618k|#define FASTLOOP_SAFE_DISTANCE 64
  ------------------
  |  Branch (2177:21): [True: 590, False: 617k]
  ------------------
 2178|    590|                    goto safe_match_copy;
 2179|    590|                }
 2180|  3.01M|            } else {
 2181|  3.01M|                length += MINMATCH;
  ------------------
  |  |  243|  3.01M|#define MINMATCH 4
  ------------------
 2182|  3.01M|                if (op + length >= oend - FASTLOOP_SAFE_DISTANCE) {
  ------------------
  |  |  249|  3.01M|#define FASTLOOP_SAFE_DISTANCE 64
  ------------------
  |  Branch (2182:21): [True: 307, False: 3.01M]
  ------------------
 2183|    307|                    DEBUGLOG(7, "moving to safe_match_copy (ml==%u)", (unsigned)length);
  ------------------
  |  |  290|    307|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2184|    307|                    goto safe_match_copy;
 2185|    307|                }
 2186|       |
 2187|       |                /* Fastpath check: skip LZ4_wildCopy32 when true */
 2188|  3.01M|                if ((dict == withPrefix64k) || (match >= lowPrefix)) {
  ------------------
  |  Branch (2188:21): [True: 884k, False: 2.12M]
  |  Branch (2188:48): [True: 2.09M, False: 33.1k]
  ------------------
 2189|  2.97M|                    if (offset >= 8) {
  ------------------
  |  Branch (2189:25): [True: 2.73M, False: 248k]
  ------------------
 2190|  2.73M|                        assert(match >= lowPrefix);
  ------------------
  |  Branch (2190:25): [True: 0, False: 2.73M]
  |  Branch (2190:25): [True: 2.73M, False: 0]
  ------------------
 2191|  2.73M|                        assert(match <= op);
  ------------------
  |  Branch (2191:25): [True: 0, False: 2.73M]
  |  Branch (2191:25): [True: 2.73M, False: 0]
  ------------------
 2192|  2.73M|                        assert(op + 18 <= oend);
  ------------------
  |  Branch (2192:25): [True: 0, False: 2.73M]
  |  Branch (2192:25): [True: 2.73M, False: 0]
  ------------------
 2193|       |
 2194|  2.73M|                        LZ4_memcpy(op, match, 8);
  ------------------
  |  |  350|  2.73M|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2195|  2.73M|                        LZ4_memcpy(op+8, match+8, 8);
  ------------------
  |  |  350|  2.73M|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2196|  2.73M|                        LZ4_memcpy(op+16, match+16, 2);
  ------------------
  |  |  350|  2.73M|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2197|  2.73M|                        op += length;
 2198|  2.73M|                        continue;
 2199|  2.73M|            }   }   }
 2200|       |
 2201|   899k|            if ( checkOffset && (unlikely(match + dictSize < lowPrefix)) ) {
  ------------------
  |  |  181|   828k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|   828k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  ------------------
  ------------------
  |  Branch (2201:18): [True: 828k, False: 70.5k]
  |  Branch (2201:33): [True: 0, False: 828k]
  ------------------
 2202|      0|                DEBUGLOG(5, "Error : pos=%zi, offset=%zi => outside buffers", op-lowPrefix, op-match);
  ------------------
  |  |  290|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2203|      0|                goto _output_error;
 2204|      0|            }
 2205|       |            /* match starting within external dictionary */
 2206|   899k|            if ((dict==usingExtDict) && (match < lowPrefix)) {
  ------------------
  |  Branch (2206:17): [True: 195k, False: 704k]
  |  Branch (2206:41): [True: 41.9k, False: 153k]
  ------------------
 2207|  41.9k|                assert(dictEnd != NULL);
  ------------------
  |  Branch (2207:17): [True: 0, False: 41.9k]
  |  Branch (2207:17): [True: 41.9k, False: 0]
  ------------------
 2208|  41.9k|                if (unlikely(op+length > oend-LASTLITERALS)) {
  ------------------
  |  |  181|  41.9k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|  41.9k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 0, False: 41.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2209|      0|                    if (partialDecoding) {
  ------------------
  |  Branch (2209:25): [True: 0, False: 0]
  ------------------
 2210|      0|                        DEBUGLOG(7, "partialDecoding: dictionary match, close to dstEnd");
  ------------------
  |  |  290|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2211|      0|                        length = MIN(length, (size_t)(oend-op));
  ------------------
  |  | 1887|      0|#define MIN(a,b)    ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (1887:23): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2212|      0|                    } else {
 2213|      0|                        DEBUGLOG(6, "end-of-block condition violated")
  ------------------
  |  |  290|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2214|      0|                        goto _output_error;
 2215|      0|                }   }
 2216|       |
 2217|  41.9k|                if (length <= (size_t)(lowPrefix-match)) {
  ------------------
  |  Branch (2217:21): [True: 40.3k, False: 1.66k]
  ------------------
 2218|       |                    /* match fits entirely within external dictionary : just copy */
 2219|  40.3k|                    LZ4_memmove(op, dictEnd - (lowPrefix-match), length);
  ------------------
  |  |  358|  40.3k|#    define LZ4_memmove __builtin_memmove
  ------------------
 2220|  40.3k|                    op += length;
 2221|  40.3k|                } else {
 2222|       |                    /* match stretches into both external dictionary and current block */
 2223|  1.66k|                    size_t const copySize = (size_t)(lowPrefix - match);
 2224|  1.66k|                    size_t const restSize = length - copySize;
 2225|  1.66k|                    LZ4_memcpy(op, dictEnd - copySize, copySize);
  ------------------
  |  |  350|  1.66k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2226|  1.66k|                    op += copySize;
 2227|  1.66k|                    if (restSize > (size_t)(op - lowPrefix)) {  /* overlap copy */
  ------------------
  |  Branch (2227:25): [True: 647, False: 1.01k]
  ------------------
 2228|    647|                        BYTE* const endOfMatch = op + restSize;
 2229|    647|                        const BYTE* copyFrom = lowPrefix;
 2230|  3.99M|                        while (op < endOfMatch) { *op++ = *copyFrom++; }
  ------------------
  |  Branch (2230:32): [True: 3.99M, False: 647]
  ------------------
 2231|  1.01k|                    } else {
 2232|  1.01k|                        LZ4_memcpy(op, lowPrefix, restSize);
  ------------------
  |  |  350|  1.01k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2233|  1.01k|                        op += restSize;
 2234|  1.01k|                }   }
 2235|  41.9k|                continue;
 2236|  41.9k|            }
 2237|       |
 2238|       |            /* copy match within block */
 2239|   857k|            cpy = op + length;
 2240|       |
 2241|   857k|            assert((op <= oend) && (oend-op >= 64));
  ------------------
  |  Branch (2241:13): [True: 0, False: 857k]
  |  Branch (2241:13): [True: 0, False: 0]
  |  Branch (2241:13): [True: 857k, False: 0]
  |  Branch (2241:13): [True: 857k, False: 0]
  ------------------
 2242|   857k|            if (unlikely(offset<16)) {
  ------------------
  |  |  181|   857k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|   857k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 383k, False: 473k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2243|   383k|                LZ4_memcpy_using_offset(op, match, cpy, offset);
 2244|       |    #ifdef __aarch64__
 2245|       |            } else if (offset >= 64) {
 2246|       |                LZ4_wildCopy64(op, match, cpy);
 2247|       |    #endif
 2248|   473k|            } else {
 2249|   473k|                LZ4_wildCopy32(op, match, cpy);
 2250|   473k|            }
 2251|       |
 2252|   857k|            op = cpy;   /* wildcopy correction */
 2253|   857k|        }
 2254|      0|    safe_decode:
 2255|      0|#endif
 2256|       |
 2257|       |        /* Main Loop : decode remaining sequences where output < FASTLOOP_SAFE_DISTANCE */
 2258|      0|        DEBUGLOG(6, "using safe decode loop");
  ------------------
  |  |  290|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2259|  18.2k|        while (1) {
  ------------------
  |  Branch (2259:16): [True: 18.2k, Folded]
  ------------------
 2260|  18.2k|            assert(ip < iend);
  ------------------
  |  Branch (2260:13): [True: 0, False: 18.2k]
  |  Branch (2260:13): [True: 18.2k, False: 0]
  ------------------
 2261|  18.2k|            token = *ip++;
 2262|  18.2k|            length = token >> ML_BITS;  /* literal length */
  ------------------
  |  |  261|  18.2k|#define ML_BITS  4
  ------------------
 2263|  18.2k|            DEBUGLOG(7, "blockPos%6u: litLength token = %u", (unsigned)(op-(BYTE*)dst), (unsigned)length);
  ------------------
  |  |  290|  18.2k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2264|       |
 2265|       |            /* A two-stage shortcut for the most common case:
 2266|       |             * 1) If the literal length is 0..14, and there is enough space,
 2267|       |             * enter the shortcut and copy 16 bytes on behalf of the literals
 2268|       |             * (in the fast mode, only 8 bytes can be safely copied this way).
 2269|       |             * 2) Further if the match length is 4..18, copy 18 bytes in a similar
 2270|       |             * manner; but we ensure that there's enough space in the output for
 2271|       |             * those 18 bytes earlier, upon entering the shortcut (in other words,
 2272|       |             * there is a combined check for both stages).
 2273|       |             */
 2274|  18.2k|            if ( (length != RUN_MASK)
  ------------------
  |  |  264|  18.2k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  263|  18.2k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|  18.2k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2274:18): [True: 17.8k, False: 355]
  ------------------
 2275|       |                /* strictly "less than" on input, to re-enter the loop with at least one byte */
 2276|  17.8k|              && likely((ip < shortiend) & (op <= shortoend)) ) {
  ------------------
  |  |  178|  17.8k|#define likely(expr)     expect((expr) != 0, 1)
  |  |  ------------------
  |  |  |  |  172|  17.8k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 1.74k, False: 16.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2277|       |                /* Copy the literals */
 2278|  1.74k|                LZ4_memcpy(op, ip, 16);
  ------------------
  |  |  350|  1.74k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2279|  1.74k|                op += length; ip += length;
 2280|       |
 2281|       |                /* The second stage: prepare for match copying, decode full info.
 2282|       |                 * If it doesn't work out, the info won't be wasted. */
 2283|  1.74k|                length = token & ML_MASK; /* match length */
  ------------------
  |  |  262|  1.74k|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  261|  1.74k|#define ML_BITS  4
  |  |  ------------------
  ------------------
 2284|  1.74k|                DEBUGLOG(7, "blockPos%6u: matchLength token = %u (len=%u)", (unsigned)(op-(BYTE*)dst), (unsigned)length, (unsigned)length + 4);
  ------------------
  |  |  290|  1.74k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2285|  1.74k|                offset = LZ4_readLE16(ip); ip += 2;
 2286|  1.74k|                match = op - offset;
 2287|  1.74k|                assert(match <= op); /* check overflow */
  ------------------
  |  Branch (2287:17): [True: 0, False: 1.74k]
  |  Branch (2287:17): [True: 1.74k, False: 0]
  ------------------
 2288|       |
 2289|       |                /* Do not deal with overlapping matches. */
 2290|  1.74k|                if ( (length != ML_MASK)
  ------------------
  |  |  262|  1.74k|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  261|  1.74k|#define ML_BITS  4
  |  |  ------------------
  ------------------
  |  Branch (2290:22): [True: 1.40k, False: 343]
  ------------------
 2291|  1.40k|                  && (offset >= 8)
  ------------------
  |  Branch (2291:22): [True: 1.12k, False: 275]
  ------------------
 2292|  1.12k|                  && (dict==withPrefix64k || match >= lowPrefix) ) {
  ------------------
  |  Branch (2292:23): [True: 272, False: 856]
  |  Branch (2292:46): [True: 824, False: 32]
  ------------------
 2293|       |                    /* Copy the match. */
 2294|  1.09k|                    LZ4_memcpy(op + 0, match + 0, 8);
  ------------------
  |  |  350|  1.09k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2295|  1.09k|                    LZ4_memcpy(op + 8, match + 8, 8);
  ------------------
  |  |  350|  1.09k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2296|  1.09k|                    LZ4_memcpy(op +16, match +16, 2);
  ------------------
  |  |  350|  1.09k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2297|  1.09k|                    op += length + MINMATCH;
  ------------------
  |  |  243|  1.09k|#define MINMATCH 4
  ------------------
 2298|       |                    /* Both stages worked, load the next token. */
 2299|  1.09k|                    continue;
 2300|  1.09k|                }
 2301|       |
 2302|       |                /* The second stage didn't work out, but the info is ready.
 2303|       |                 * Propel it right to the point of match copying. */
 2304|    650|                goto _copy_match;
 2305|  1.74k|            }
 2306|       |
 2307|  16.4k|#if LZ4_FAST_DEC_LOOP
 2308|  27.0k|        safe_literal_copy_early:
 2309|  27.0k|#endif
 2310|       |
 2311|       |            /* decode literal length */
 2312|  27.0k|            if (length == RUN_MASK) {
  ------------------
  |  |  264|  27.0k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  263|  27.0k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|  27.0k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2312:17): [True: 541, False: 26.5k]
  ------------------
 2313|       |                /* literal length >= RUN_MASK means >= RUN_MASK literal bytes follow the extension bytes,
 2314|       |                 * so extension bytes cannot reach the last RUN_MASK bytes of input */
 2315|    541|                size_t const addl = read_variable_length(&ip, iend-RUN_MASK);
  ------------------
  |  |  264|    541|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  263|    541|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|    541|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2316|    541|                if (addl == rvl_error) { goto _output_error; }
  ------------------
  |  Branch (2316:21): [True: 0, False: 541]
  ------------------
 2317|    541|                length += addl;
 2318|    541|                if (unlikely((uptrval)(op)+length<(uptrval)(op))) { goto _output_error; } /* overflow detection */
  ------------------
  |  |  181|    541|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|    541|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 0, False: 541]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2319|    541|                if (unlikely((uptrval)(ip)+length<(uptrval)(ip))) { goto _output_error; } /* overflow detection */
  ------------------
  |  |  181|    541|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|    541|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 0, False: 541]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2320|    541|            }
 2321|       |
 2322|       |            /* copy literals */
 2323|  27.0k|            cpy = op+length;
 2324|       |
 2325|  27.0k|#if LZ4_FAST_DEC_LOOP
 2326|  29.2k|        safe_literal_copy:
 2327|  29.2k|#endif
 2328|       |
 2329|  29.2k|            LZ4_STATIC_ASSERT(MFLIMIT >= WILDCOPYLENGTH);
  ------------------
  |  |  278|  29.2k|#define LZ4_STATIC_ASSERT(c)   { enum { LZ4_static_assert = 1/(int)(!!(c)) }; }   /* use after variable declarations */
  ------------------
 2330|  29.2k|            if ((cpy>oend-MFLIMIT) || (ip+length>iend-(2+1+LASTLITERALS))) {
  ------------------
  |  |  247|  29.2k|#define MFLIMIT       12   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
                          if ((cpy>oend-MFLIMIT) || (ip+length>iend-(2+1+LASTLITERALS))) {
  ------------------
  |  |  246|  27.7k|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  |  Branch (2330:17): [True: 1.49k, False: 27.7k]
  |  Branch (2330:39): [True: 12.1k, False: 15.6k]
  ------------------
 2331|       |                /* We've either hit the input parsing restriction or the output parsing restriction.
 2332|       |                 * In the normal scenario, decoding a full block, it must be the last sequence,
 2333|       |                 * otherwise it's an error (invalid input or dimensions).
 2334|       |                 * In partialDecoding scenario, it's necessary to ensure there is no buffer overflow.
 2335|       |                 */
 2336|  13.6k|                if (partialDecoding) {
  ------------------
  |  Branch (2336:21): [True: 0, False: 13.6k]
  ------------------
 2337|       |                    /* Since we are partial decoding we may be in this block because of the output parsing
 2338|       |                     * restriction, which is not valid since the output buffer is allowed to be undersized.
 2339|       |                     */
 2340|      0|                    DEBUGLOG(7, "partialDecoding: copying literals, close to input or output end")
  ------------------
  |  |  290|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2341|      0|                    DEBUGLOG(7, "partialDecoding: literal length = %u", (unsigned)length);
  ------------------
  |  |  290|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2342|      0|                    DEBUGLOG(7, "partialDecoding: remaining space in dstBuffer : %i", (int)(oend - op));
  ------------------
  |  |  290|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2343|      0|                    DEBUGLOG(7, "partialDecoding: remaining space in srcBuffer : %i", (int)(iend - ip));
  ------------------
  |  |  290|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2344|       |                    /* Finishing in the middle of a literals segment,
 2345|       |                     * due to lack of input.
 2346|       |                     */
 2347|      0|                    if (ip+length > iend) {
  ------------------
  |  Branch (2347:25): [True: 0, False: 0]
  ------------------
 2348|      0|                        length = (size_t)(iend-ip);
 2349|      0|                        cpy = op + length;
 2350|      0|                    }
 2351|       |                    /* Finishing in the middle of a literals segment,
 2352|       |                     * due to lack of output space.
 2353|       |                     */
 2354|      0|                    if (cpy > oend) {
  ------------------
  |  Branch (2354:25): [True: 0, False: 0]
  ------------------
 2355|      0|                        cpy = oend;
 2356|      0|                        assert(op<=oend);
  ------------------
  |  Branch (2356:25): [True: 0, False: 0]
  |  Branch (2356:25): [True: 0, False: 0]
  ------------------
 2357|      0|                        length = (size_t)(oend-op);
 2358|      0|                    }
 2359|  13.6k|                } else {
 2360|       |                     /* We must be on the last sequence (or invalid) because of the parsing limitations
 2361|       |                      * so check that we exactly consume the input and don't overrun the output buffer.
 2362|       |                      */
 2363|  13.6k|                    if ((ip+length != iend) || (cpy > oend)) {
  ------------------
  |  Branch (2363:25): [True: 0, False: 13.6k]
  |  Branch (2363:48): [True: 0, False: 13.6k]
  ------------------
 2364|      0|                        DEBUGLOG(5, "should have been last run of literals")
  ------------------
  |  |  290|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2365|      0|                        DEBUGLOG(5, "ip(%p) + length(%i) = %p != iend (%p)", (void*)ip, (int)length, (void*)(ip+length), (void*)iend);
  ------------------
  |  |  290|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2366|      0|                        DEBUGLOG(5, "or cpy(%p) > (oend-MFLIMIT)(%p)", (void*)cpy, (void*)(oend-MFLIMIT));
  ------------------
  |  |  290|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2367|      0|                        DEBUGLOG(5, "after writing %u bytes / %i bytes available", (unsigned)(op-(BYTE*)dst), outputSize);
  ------------------
  |  |  290|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2368|      0|                        goto _output_error;
 2369|      0|                    }
 2370|  13.6k|                }
 2371|  13.6k|                LZ4_memmove(op, ip, length);  /* supports overlapping memory regions, for in-place decompression scenarios */
  ------------------
  |  |  358|  13.6k|#    define LZ4_memmove __builtin_memmove
  ------------------
 2372|  13.6k|                ip += length;
 2373|  13.6k|                op += length;
 2374|       |                /* Necessarily EOF when !partialDecoding.
 2375|       |                 * When partialDecoding, it is EOF if we've either
 2376|       |                 * filled the output buffer or
 2377|       |                 * can't proceed with reading an offset for following match.
 2378|       |                 */
 2379|  13.6k|                if (!partialDecoding || (cpy == oend) || (ip >= (iend-2))) {
  ------------------
  |  Branch (2379:21): [True: 13.6k, False: 0]
  |  Branch (2379:41): [True: 0, False: 0]
  |  Branch (2379:58): [True: 0, False: 0]
  ------------------
 2380|  13.6k|                    break;
 2381|  13.6k|                }
 2382|  15.6k|            } else {
 2383|  15.6k|                LZ4_wildCopy8(op, ip, cpy);   /* can overwrite up to 8 bytes beyond cpy */
 2384|  15.6k|                ip += length; op = cpy;
 2385|  15.6k|            }
 2386|       |
 2387|       |            /* get offset */
 2388|  15.6k|            offset = LZ4_readLE16(ip); ip+=2;
 2389|  15.6k|            match = op - offset;
 2390|       |
 2391|       |            /* get matchlength */
 2392|  15.6k|            length = token & ML_MASK;
  ------------------
  |  |  262|  15.6k|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  261|  15.6k|#define ML_BITS  4
  |  |  ------------------
  ------------------
 2393|  15.6k|            DEBUGLOG(7, "blockPos%6u: matchLength token = %u", (unsigned)(op-(BYTE*)dst), (unsigned)length);
  ------------------
  |  |  290|  15.6k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2394|       |
 2395|  16.2k|    _copy_match:
 2396|  16.2k|            if (length == ML_MASK) {
  ------------------
  |  |  262|  16.2k|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  261|  16.2k|#define ML_BITS  4
  |  |  ------------------
  ------------------
  |  Branch (2396:17): [True: 5.29k, False: 10.9k]
  ------------------
 2397|       |                /* after match length extension bytes, at least 1 token + LASTLITERALS literals must remain */
 2398|  5.29k|                size_t const addl = read_variable_length(&ip, iend - (1 + LASTLITERALS));
  ------------------
  |  |  246|  5.29k|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
 2399|  5.29k|                if (addl == rvl_error) { goto _output_error; }
  ------------------
  |  Branch (2399:21): [True: 0, False: 5.29k]
  ------------------
 2400|  5.29k|                length += addl;
 2401|  5.29k|                if (unlikely((uptrval)(op)+length<(uptrval)op)) goto _output_error;   /* overflow detection */
  ------------------
  |  |  181|  5.29k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|  5.29k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 0, False: 5.29k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2402|  5.29k|            }
 2403|  16.2k|            length += MINMATCH;
  ------------------
  |  |  243|  16.2k|#define MINMATCH 4
  ------------------
 2404|       |
 2405|  16.2k|#if LZ4_FAST_DEC_LOOP
 2406|  17.1k|        safe_match_copy:
 2407|  17.1k|#endif
 2408|  17.1k|            if ((checkOffset) && (unlikely(match + dictSize < lowPrefix))) goto _output_error;   /* Error : offset outside buffers */
  ------------------
  |  |  181|  16.4k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|  16.4k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  ------------------
  ------------------
  |  Branch (2408:17): [True: 16.4k, False: 730]
  |  Branch (2408:34): [True: 0, False: 16.4k]
  ------------------
 2409|       |            /* match starting within external dictionary */
 2410|  17.1k|            if ((dict==usingExtDict) && (match < lowPrefix)) {
  ------------------
  |  Branch (2410:17): [True: 6.46k, False: 10.6k]
  |  Branch (2410:41): [True: 2.20k, False: 4.26k]
  ------------------
 2411|  2.20k|                assert(dictEnd != NULL);
  ------------------
  |  Branch (2411:17): [True: 0, False: 2.20k]
  |  Branch (2411:17): [True: 2.20k, False: 0]
  ------------------
 2412|  2.20k|                if (unlikely(op+length > oend-LASTLITERALS)) {
  ------------------
  |  |  181|  2.20k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|  2.20k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 0, False: 2.20k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2413|      0|                    if (partialDecoding) length = MIN(length, (size_t)(oend-op));
  ------------------
  |  | 1887|      0|#define MIN(a,b)    ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (1887:23): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (2413:25): [True: 0, False: 0]
  ------------------
 2414|      0|                    else goto _output_error;   /* doesn't respect parsing restriction */
 2415|      0|                }
 2416|       |
 2417|  2.20k|                if (length <= (size_t)(lowPrefix-match)) {
  ------------------
  |  Branch (2417:21): [True: 1.39k, False: 816]
  ------------------
 2418|       |                    /* match fits entirely within external dictionary : just copy */
 2419|  1.39k|                    LZ4_memmove(op, dictEnd - (lowPrefix-match), length);
  ------------------
  |  |  358|  1.39k|#    define LZ4_memmove __builtin_memmove
  ------------------
 2420|  1.39k|                    op += length;
 2421|  1.39k|                } else {
 2422|       |                    /* match stretches into both external dictionary and current block */
 2423|    816|                    size_t const copySize = (size_t)(lowPrefix - match);
 2424|    816|                    size_t const restSize = length - copySize;
 2425|    816|                    LZ4_memcpy(op, dictEnd - copySize, copySize);
  ------------------
  |  |  350|    816|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2426|    816|                    op += copySize;
 2427|    816|                    if (restSize > (size_t)(op - lowPrefix)) {  /* overlap copy */
  ------------------
  |  Branch (2427:25): [True: 402, False: 414]
  ------------------
 2428|    402|                        BYTE* const endOfMatch = op + restSize;
 2429|    402|                        const BYTE* copyFrom = lowPrefix;
 2430|   183k|                        while (op < endOfMatch) *op++ = *copyFrom++;
  ------------------
  |  Branch (2430:32): [True: 183k, False: 402]
  ------------------
 2431|    414|                    } else {
 2432|    414|                        LZ4_memcpy(op, lowPrefix, restSize);
  ------------------
  |  |  350|    414|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2433|    414|                        op += restSize;
 2434|    414|                }   }
 2435|  2.20k|                continue;
 2436|  2.20k|            }
 2437|  17.1k|            assert(match >= lowPrefix);
  ------------------
  |  Branch (2437:13): [True: 0, False: 14.9k]
  |  Branch (2437:13): [True: 14.9k, False: 0]
  ------------------
 2438|       |
 2439|       |            /* copy match within block */
 2440|  14.9k|            cpy = op + length;
 2441|       |
 2442|       |            /* partialDecoding : may end anywhere within the block */
 2443|  14.9k|            assert(op<=oend);
  ------------------
  |  Branch (2443:13): [True: 0, False: 14.9k]
  |  Branch (2443:13): [True: 14.9k, False: 0]
  ------------------
 2444|  14.9k|            if (partialDecoding && (cpy > oend-MATCH_SAFEGUARD_DISTANCE)) {
  ------------------
  |  |  248|      0|#define MATCH_SAFEGUARD_DISTANCE  ((2*WILDCOPYLENGTH) - MINMATCH)   /* ensure it's possible to write 2 x wildcopyLength without overflowing output buffer */
  |  |  ------------------
  |  |  |  |  245|      0|#define WILDCOPYLENGTH 8
  |  |  ------------------
  |  |               #define MATCH_SAFEGUARD_DISTANCE  ((2*WILDCOPYLENGTH) - MINMATCH)   /* ensure it's possible to write 2 x wildcopyLength without overflowing output buffer */
  |  |  ------------------
  |  |  |  |  243|      0|#define MINMATCH 4
  |  |  ------------------
  ------------------
  |  Branch (2444:17): [True: 0, False: 14.9k]
  |  Branch (2444:36): [True: 0, False: 0]
  ------------------
 2445|      0|                size_t const mlen = MIN(length, (size_t)(oend-op));
  ------------------
  |  | 1887|      0|#define MIN(a,b)    ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (1887:23): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2446|      0|                const BYTE* const matchEnd = match + mlen;
 2447|      0|                BYTE* const copyEnd = op + mlen;
 2448|      0|                if (matchEnd > op) {   /* overlap copy */
  ------------------
  |  Branch (2448:21): [True: 0, False: 0]
  ------------------
 2449|      0|                    while (op < copyEnd) { *op++ = *match++; }
  ------------------
  |  Branch (2449:28): [True: 0, False: 0]
  ------------------
 2450|      0|                } else {
 2451|      0|                    LZ4_memcpy(op, match, mlen);
  ------------------
  |  |  350|      0|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2452|      0|                }
 2453|      0|                op = copyEnd;
 2454|      0|                if (op == oend) { break; }
  ------------------
  |  Branch (2454:21): [True: 0, False: 0]
  ------------------
 2455|      0|                continue;
 2456|      0|            }
 2457|       |
 2458|  14.9k|            if (unlikely(offset<8)) {
  ------------------
  |  |  181|  14.9k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|  14.9k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 5.88k, False: 9.05k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2459|  5.88k|                LZ4_write32(op, 0);   /* silence msan warning when offset==0 */
 2460|  5.88k|                op[0] = match[0];
 2461|  5.88k|                op[1] = match[1];
 2462|  5.88k|                op[2] = match[2];
 2463|  5.88k|                op[3] = match[3];
 2464|  5.88k|                match += inc32table[offset];
 2465|  5.88k|                LZ4_memcpy(op+4, match, 4);
  ------------------
  |  |  350|  5.88k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2466|  5.88k|                match -= dec64table[offset];
 2467|  9.05k|            } else {
 2468|  9.05k|                LZ4_memcpy(op, match, 8);
  ------------------
  |  |  350|  9.05k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2469|  9.05k|                match += 8;
 2470|  9.05k|            }
 2471|  14.9k|            op += 8;
 2472|       |
 2473|  14.9k|            if (unlikely(cpy > oend-MATCH_SAFEGUARD_DISTANCE)) {
  ------------------
  |  |  181|  14.9k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|  14.9k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 1.25k, False: 13.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2474|  1.25k|                BYTE* const oCopyLimit = oend - (WILDCOPYLENGTH-1);
  ------------------
  |  |  245|  1.25k|#define WILDCOPYLENGTH 8
  ------------------
 2475|  1.25k|                if (cpy > oend-LASTLITERALS) { goto _output_error; } /* Error : last LASTLITERALS bytes must be literals (uncompressed) */
  ------------------
  |  |  246|  1.25k|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  |  Branch (2475:21): [True: 0, False: 1.25k]
  ------------------
 2476|  1.25k|                if (op < oCopyLimit) {
  ------------------
  |  Branch (2476:21): [True: 1.07k, False: 179]
  ------------------
 2477|  1.07k|                    LZ4_wildCopy8(op, match, oCopyLimit);
 2478|  1.07k|                    match += oCopyLimit - op;
 2479|  1.07k|                    op = oCopyLimit;
 2480|  1.07k|                }
 2481|  3.14k|                while (op < cpy) { *op++ = *match++; }
  ------------------
  |  Branch (2481:24): [True: 1.89k, False: 1.25k]
  ------------------
 2482|  13.6k|            } else {
 2483|  13.6k|                LZ4_memcpy(op, match, 8);
  ------------------
  |  |  350|  13.6k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2484|  13.6k|                if (length > 16) { LZ4_wildCopy8(op+8, match+8, cpy); }
  ------------------
  |  Branch (2484:21): [True: 4.93k, False: 8.75k]
  ------------------
 2485|  13.6k|            }
 2486|  14.9k|            op = cpy;   /* wildcopy correction */
 2487|  14.9k|        }
 2488|       |
 2489|       |        /* end of decoding */
 2490|  13.6k|        DEBUGLOG(5, "decoded %i bytes", (int) (((char*)op)-dst));
  ------------------
  |  |  290|  13.6k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2491|  13.6k|        return (int) (((char*)op)-dst);     /* Nb of output bytes decoded */
 2492|       |
 2493|       |        /* Overflow error detected */
 2494|      0|    _output_error:
 2495|      0|        return (int) (-(((const char*)ip)-src))-1;
 2496|      0|    }
 2497|      0|}
lz4.c:read_variable_length:
 2020|   884k|{
 2021|   884k|    Rvl_t s, length = 0;
 2022|   884k|    assert(ipPtr != NULL);
  ------------------
  |  Branch (2022:5): [True: 0, False: 884k]
  |  Branch (2022:5): [True: 884k, False: 0]
  ------------------
 2023|   884k|    assert(*ipPtr !=  NULL);
  ------------------
  |  Branch (2023:5): [True: 0, False: 884k]
  |  Branch (2023:5): [True: 884k, False: 0]
  ------------------
 2024|   884k|    assert(ilimit != NULL);
  ------------------
  |  Branch (2024:5): [True: 0, False: 884k]
  |  Branch (2024:5): [True: 884k, False: 0]
  ------------------
 2025|   884k|    if (unlikely((*ipPtr) >= ilimit)) {    /* read limit reached */
  ------------------
  |  |  181|   884k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|   884k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 0, False: 884k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2026|      0|        return rvl_error;
 2027|      0|    }
 2028|   884k|    s = **ipPtr;
 2029|   884k|    (*ipPtr)++;
 2030|   884k|    length += s;
 2031|   884k|    if (likely(s != 255)) return length;
  ------------------
  |  |  178|   884k|#define likely(expr)     expect((expr) != 0, 1)
  |  |  ------------------
  |  |  |  |  172|   884k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 790k, False: 93.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2032|   913k|    do {
 2033|   913k|        if (unlikely((*ipPtr) >= ilimit)) {    /* read limit reached */
  ------------------
  |  |  181|   913k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|   913k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 0, False: 913k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2034|      0|            return rvl_error;
 2035|      0|        }
 2036|   913k|        s = **ipPtr;
 2037|   913k|        (*ipPtr)++;
 2038|   913k|        length += s;
 2039|       |        /* accumulator overflow detection (32-bit mode only) */
 2040|   913k|        if ((sizeof(length) < 8) && unlikely(length > ((Rvl_t)(-1)/2)) ) {
  ------------------
  |  |  181|      0|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|      0|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2040:13): [Folded, False: 913k]
  ------------------
 2041|      0|            return rvl_error;
 2042|      0|        }
 2043|   913k|    } while (s == 255);
  ------------------
  |  Branch (2043:14): [True: 819k, False: 93.3k]
  ------------------
 2044|       |
 2045|  93.3k|    return length;
 2046|  93.3k|}
lz4.c:LZ4_wildCopy32:
  532|   731k|{
  533|   731k|    BYTE* d = (BYTE*)dstPtr;
  534|   731k|    const BYTE* s = (const BYTE*)srcPtr;
  535|   731k|    BYTE* const e = (BYTE*)dstEnd;
  536|       |
  537|  5.39M|    do { LZ4_memcpy(d,s,16); LZ4_memcpy(d+16,s+16,16); d+=32; s+=32; } while (d<e);
  ------------------
  |  |  350|  5.39M|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
                  do { LZ4_memcpy(d,s,16); LZ4_memcpy(d+16,s+16,16); d+=32; s+=32; } while (d<e);
  ------------------
  |  |  350|  5.39M|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  |  Branch (537:79): [True: 4.66M, False: 731k]
  ------------------
  538|   731k|}
lz4.c:LZ4_readLE16:
  432|  3.64M|{
  433|  3.64M|    if (LZ4_isLittleEndian()) {
  ------------------
  |  Branch (433:9): [True: 3.64M, False: 0]
  ------------------
  434|  3.64M|        return LZ4_read16(memPtr);
  435|  3.64M|    } else {
  436|      0|        const BYTE* p = (const BYTE*)memPtr;
  437|      0|        return (U16)((U16)p[0] | (p[1]<<8));
  438|      0|    }
  439|  3.64M|}
lz4.c:LZ4_memcpy_using_offset:
  545|   383k|{
  546|   383k|    BYTE v[8];
  547|       |
  548|   383k|    assert(dstEnd >= dstPtr + MINMATCH);
  ------------------
  |  Branch (548:5): [True: 0, False: 383k]
  |  Branch (548:5): [True: 383k, False: 0]
  ------------------
  549|       |
  550|   383k|    switch(offset) {
  551|  75.1k|    case 1:
  ------------------
  |  Branch (551:5): [True: 75.1k, False: 308k]
  ------------------
  552|  75.1k|        MEM_INIT(v, *srcPtr, 8);
  ------------------
  |  |  237|  75.1k|#define MEM_INIT(p,v,s)   LZ4_memset((p),(v),(s))
  |  |  ------------------
  |  |  |  |  235|  75.1k|#  define LZ4_memset(p,v,s) memset((p),(v),(s))
  |  |  ------------------
  ------------------
  553|  75.1k|        break;
  554|   214k|    case 2:
  ------------------
  |  Branch (554:5): [True: 214k, False: 169k]
  ------------------
  555|   214k|        LZ4_memcpy(v, srcPtr, 2);
  ------------------
  |  |  350|   214k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  556|   214k|        LZ4_memcpy(&v[2], srcPtr, 2);
  ------------------
  |  |  350|   214k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  557|       |#if defined(_MSC_VER) && (_MSC_VER <= 1937) /* MSVC 2022 ver 17.7 or earlier */
  558|       |#  pragma warning(push)
  559|       |#  pragma warning(disable : 6385) /* warning C6385: Reading invalid data from 'v'. */
  560|       |#endif
  561|   214k|        LZ4_memcpy(&v[4], v, 4);
  ------------------
  |  |  350|   214k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  562|       |#if defined(_MSC_VER) && (_MSC_VER <= 1937) /* MSVC 2022 ver 17.7 or earlier */
  563|       |#  pragma warning(pop)
  564|       |#endif
  565|   214k|        break;
  566|  45.8k|    case 4:
  ------------------
  |  Branch (566:5): [True: 45.8k, False: 337k]
  ------------------
  567|  45.8k|        LZ4_memcpy(v, srcPtr, 4);
  ------------------
  |  |  350|  45.8k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  568|  45.8k|        LZ4_memcpy(&v[4], srcPtr, 4);
  ------------------
  |  |  350|  45.8k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  569|  45.8k|        break;
  570|  48.4k|    default:
  ------------------
  |  Branch (570:5): [True: 48.4k, False: 335k]
  ------------------
  571|  48.4k|        LZ4_memcpy_using_offset_base(dstPtr, srcPtr, dstEnd, offset);
  572|  48.4k|        return;
  573|   383k|    }
  574|       |
  575|   335k|    LZ4_memcpy(dstPtr, v, 8);
  ------------------
  |  |  350|   335k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  576|   335k|    dstPtr += 8;
  577|  12.2M|    while (dstPtr < dstEnd) {
  ------------------
  |  Branch (577:12): [True: 11.8M, False: 335k]
  ------------------
  578|  11.8M|        LZ4_memcpy(dstPtr, v, 8);
  ------------------
  |  |  350|  11.8M|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  579|  11.8M|        dstPtr += 8;
  580|  11.8M|    }
  581|   335k|}
lz4.c:LZ4_memcpy_using_offset_base:
  493|  48.4k|{
  494|  48.4k|    assert(srcPtr + offset == dstPtr);
  ------------------
  |  Branch (494:5): [True: 0, False: 48.4k]
  |  Branch (494:5): [True: 48.4k, False: 0]
  ------------------
  495|  48.4k|    if (offset < 8) {
  ------------------
  |  Branch (495:9): [True: 37.0k, False: 11.3k]
  ------------------
  496|  37.0k|        LZ4_write32(dstPtr, 0);   /* silence an msan warning when offset==0 */
  497|  37.0k|        assert(offset != 1);   /* offset==0 happens on testing */
  ------------------
  |  Branch (497:9): [True: 0, False: 37.0k]
  |  Branch (497:9): [True: 37.0k, False: 0]
  ------------------
  498|  37.0k|        LZ4_memcpy(dstPtr, srcPtr, 2);
  ------------------
  |  |  350|  37.0k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  499|  37.0k|        LZ4_memcpy(dstPtr + 2, srcPtr + 2, 2);
  ------------------
  |  |  350|  37.0k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  500|  37.0k|        srcPtr += inc32table[offset];
  501|  37.0k|        LZ4_memcpy(dstPtr+4, srcPtr, 4);
  ------------------
  |  |  350|  37.0k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  502|  37.0k|        srcPtr -= dec64table[offset];
  503|  37.0k|        dstPtr += 8;
  504|  37.0k|    } else {
  505|  11.3k|        LZ4_memcpy(dstPtr, srcPtr, 8);
  ------------------
  |  |  350|  11.3k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  506|  11.3k|        dstPtr += 8;
  507|  11.3k|        srcPtr += 8;
  508|  11.3k|    }
  509|       |
  510|  48.4k|    LZ4_wildCopy8(dstPtr, srcPtr, dstEnd);
  511|  48.4k|}
lz4.c:LZ4_decompress_safe_withSmallPrefix:
 2558|    724|{
 2559|    724|    return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize,
 2560|    724|                                  decode_full_block, noDict,
 2561|       |                                  (BYTE*)dest-prefixSize, NULL, 0);
 2562|    724|}

LZ4F_isError:
  296|   614k|{
  297|   614k|    return (code > (LZ4F_errorCode_t)(-LZ4F_ERROR_maxCode));
  298|   614k|}
LZ4F_getErrorCode:
  308|  69.5k|{
  309|  69.5k|    if (!LZ4F_isError(functionResult)) return LZ4F_OK_NoError;
  ------------------
  |  Branch (309:9): [True: 0, False: 69.5k]
  ------------------
  310|  69.5k|    return (LZ4F_errorCodes)(-(ptrdiff_t)functionResult);
  311|  69.5k|}
LZ4F_getBlockSize:
  336|   345k|{
  337|   345k|    static const size_t blockSizes[4] = { 64 KB, 256 KB, 1 MB, 4 MB };
  ------------------
  |  |  240|   345k|#  define KB *(1<<10)
  ------------------
                  static const size_t blockSizes[4] = { 64 KB, 256 KB, 1 MB, 4 MB };
  ------------------
  |  |  240|   345k|#  define KB *(1<<10)
  ------------------
                  static const size_t blockSizes[4] = { 64 KB, 256 KB, 1 MB, 4 MB };
  ------------------
  |  |  241|   345k|#  define MB *(1<<20)
  ------------------
                  static const size_t blockSizes[4] = { 64 KB, 256 KB, 1 MB, 4 MB };
  ------------------
  |  |  241|   345k|#  define MB *(1<<20)
  ------------------
  338|       |
  339|   345k|    if (blockSizeID == 0) blockSizeID = LZ4F_BLOCKSIZEID_DEFAULT;
  ------------------
  |  |  252|  63.9k|#define LZ4F_BLOCKSIZEID_DEFAULT LZ4F_max64KB
  ------------------
  |  Branch (339:9): [True: 63.9k, False: 281k]
  ------------------
  340|   345k|    if (blockSizeID < LZ4F_max64KB || blockSizeID > LZ4F_max4MB)
  ------------------
  |  Branch (340:9): [True: 0, False: 345k]
  |  Branch (340:39): [True: 0, False: 345k]
  ------------------
  341|      0|        RETURN_ERROR(maxBlockSize_invalid);
  ------------------
  |  |  320|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  342|   345k|    {   int const blockSizeIdx = (int)blockSizeID - (int)LZ4F_max64KB;
  343|   345k|        return blockSizes[blockSizeIdx];
  344|   345k|}   }
LZ4F_compressFrameBound:
  409|  19.1k|{
  410|  19.1k|    LZ4F_preferences_t prefs;
  411|  19.1k|    size_t const headerSize = maxFHSize;      /* max header size, including optional fields */
  412|       |
  413|  19.1k|    if (preferencesPtr!=NULL) prefs = *preferencesPtr;
  ------------------
  |  Branch (413:9): [True: 19.1k, False: 0]
  ------------------
  414|      0|    else MEM_INIT(&prefs, 0, sizeof(prefs));
  ------------------
  |  |   91|      0|#  define MEM_INIT(p,v,s)   memset((p),(v),(s))
  ------------------
  415|  19.1k|    prefs.autoFlush = 1;
  416|       |
  417|  19.1k|    return headerSize + LZ4F_compressBound_internal(srcSize, &prefs, 0);;
  418|      0|}
LZ4F_createCompressionContext_advanced:
  606|   107k|{
  607|   107k|    LZ4F_cctx* const cctxPtr =
  608|   107k|        (LZ4F_cctx*)LZ4F_calloc(sizeof(LZ4F_cctx), customMem);
  609|   107k|    if (cctxPtr==NULL) return NULL;
  ------------------
  |  Branch (609:9): [True: 0, False: 107k]
  ------------------
  610|       |
  611|   107k|    cctxPtr->cmem = customMem;
  612|   107k|    cctxPtr->version = version;
  613|   107k|    cctxPtr->cStage = 0;   /* Uninitialized. Next stage : init cctx */
  614|       |
  615|   107k|    return cctxPtr;
  616|   107k|}
LZ4F_createCompressionContext:
  628|   107k|{
  629|   107k|    assert(LZ4F_compressionContextPtr != NULL); /* considered a violation of narrow contract */
  ------------------
  |  Branch (629:5): [True: 0, False: 107k]
  |  Branch (629:5): [True: 107k, False: 0]
  ------------------
  630|       |    /* in case it nonetheless happen in production */
  631|   107k|    RETURN_ERROR_IF(LZ4F_compressionContextPtr == NULL, parameter_null);
  ------------------
  |  |  322|   107k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  323|   107k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (323:13): [True: 0, False: 107k]
  |  |  ------------------
  |  |  324|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  163|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  325|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  320|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  326|      0|        }                          \
  |  |  327|   107k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (327:14): [Folded, False: 107k]
  |  |  ------------------
  ------------------
  632|       |
  633|   107k|    *LZ4F_compressionContextPtr = LZ4F_createCompressionContext_advanced(LZ4F_defaultCMem, version);
  634|   107k|    RETURN_ERROR_IF(*LZ4F_compressionContextPtr==NULL, allocation_failed);
  ------------------
  |  |  322|   107k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  323|   107k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (323:13): [True: 0, False: 107k]
  |  |  ------------------
  |  |  324|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  163|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  325|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  320|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  326|      0|        }                          \
  |  |  327|   107k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (327:14): [Folded, False: 107k]
  |  |  ------------------
  ------------------
  635|   107k|    return LZ4F_OK_NoError;
  636|   107k|}
LZ4F_freeCompressionContext:
  639|   146k|{
  640|   146k|    if (cctxPtr != NULL) {  /* support free on NULL */
  ------------------
  |  Branch (640:9): [True: 107k, False: 38.2k]
  ------------------
  641|   107k|       LZ4F_free(cctxPtr->lz4CtxPtr, cctxPtr->cmem);  /* note: LZ4_streamHC_t and LZ4_stream_t are simple POD types */
  642|   107k|       LZ4F_free(cctxPtr->tmpBuff, cctxPtr->cmem);
  643|   107k|       LZ4F_free(cctxPtr, cctxPtr->cmem);
  644|   107k|    }
  645|   146k|    return LZ4F_OK_NoError;
  646|   146k|}
LZ4F_compressBegin:
  851|  98.2k|{
  852|  98.2k|    return LZ4F_compressBegin_internal(cctx, dstBuffer, dstCapacity,
  853|  98.2k|                                        NULL, 0,
  854|       |                                        NULL, preferencesPtr);
  855|  98.2k|}
LZ4F_compressBound:
  901|   129k|{
  902|   129k|    size_t bound;
  903|   129k|    size_t const blockCRCSize = preferencesPtr
  ------------------
  |  Branch (903:33): [True: 129k, False: 0]
  ------------------
  904|   129k|                             ? BFSize * preferencesPtr->frameInfo.blockChecksumFlag
  905|   129k|                             : BFSize;
  906|   129k|    if (preferencesPtr && preferencesPtr->autoFlush) {
  ------------------
  |  Branch (906:9): [True: 129k, False: 0]
  |  Branch (906:27): [True: 94.8k, False: 34.8k]
  ------------------
  907|  94.8k|        return LZ4F_compressBound_internal(srcSize, preferencesPtr, 0);
  908|  94.8k|    }
  909|  34.8k|    bound = LZ4F_compressBound_internal(srcSize+1, preferencesPtr, (size_t)-1);
  910|       |    /* A mode switch may emit buffered input as a separate partial block. */
  911|  34.8k|    return bound + BHSize + blockCRCSize;
  912|   129k|}
LZ4F_compressUpdate:
 1184|   120k|{
 1185|   120k|     return LZ4F_compressUpdateImpl(cctxPtr,
 1186|   120k|                                   dstBuffer, dstCapacity,
 1187|   120k|                                   srcBuffer, srcSize,
 1188|   120k|                                   compressOptionsPtr, LZ4B_COMPRESSED);
 1189|   120k|}
LZ4F_uncompressedUpdate:
 1205|  1.41k|{
 1206|  1.41k|    return LZ4F_compressUpdateImpl(cctxPtr,
 1207|  1.41k|                                   dstBuffer, dstCapacity,
 1208|  1.41k|                                   srcBuffer, srcSize,
 1209|  1.41k|                                   compressOptionsPtr, LZ4B_UNCOMPRESSED);
 1210|  1.41k|}
LZ4F_flush:
 1227|  98.2k|{
 1228|  98.2k|    compressFunc_t compress;
 1229|  98.2k|    size_t cSize;
 1230|       |
 1231|  98.2k|    DEBUGLOG(5, "LZ4F_flush: %zu buffered bytes (saved dict size = %i) (dstCapacity=%u)",
  ------------------
  |  |  163|  98.2k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 1232|  98.2k|            cctxPtr->tmpInSize, (int)(cctxPtr->tmpIn - cctxPtr->tmpBuff), (unsigned)dstCapacity);
 1233|  98.2k|    RETURN_ERROR_IF(cctxPtr->cStage != 1, compressionState_uninitialized);
  ------------------
  |  |  322|  98.2k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  323|  98.2k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (323:13): [True: 34.7k, False: 63.4k]
  |  |  ------------------
  |  |  324|  34.7k|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  163|  34.7k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  325|  34.7k|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  320|  34.7k|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  326|  34.7k|        }                          \
  |  |  327|  98.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (327:14): [Folded, False: 63.4k]
  |  |  ------------------
  ------------------
 1234|  63.4k|    if (cctxPtr->tmpInSize == 0) return 0;   /* nothing to flush */
  ------------------
  |  Branch (1234:9): [True: 49.7k, False: 13.6k]
  ------------------
 1235|  13.6k|    (void)compressOptionsPtr;   /* not useful (yet) */
 1236|       |
 1237|       |    /* select compression function */
 1238|  13.6k|    compress = LZ4F_selectCompression(cctxPtr->prefs.frameInfo.blockMode, cctxPtr->prefs.compressionLevel, cctxPtr->blockCompressMode);
 1239|       |
 1240|       |    /* compress tmp buffer */
 1241|  13.6k|    cSize = LZ4F_makeBlock(dstBuffer, dstCapacity,
 1242|  13.6k|                           cctxPtr->tmpIn, cctxPtr->tmpInSize,
 1243|  13.6k|                           compress, cctxPtr->lz4CtxPtr, cctxPtr->prefs.compressionLevel,
 1244|  13.6k|                           cctxPtr->cdict,
 1245|  13.6k|                           cctxPtr->prefs.frameInfo.blockChecksumFlag);
 1246|  13.6k|    FORWARD_IF_ERROR_INVALIDATE(cSize, cctxPtr);
  ------------------
  |  | 1028|  13.6k|#define FORWARD_IF_ERROR_INVALIDATE(r, cctx) do { \
  |  | 1029|  13.6k|        if (LZ4F_isError(r)) {                     \
  |  |  ------------------
  |  |  |  Branch (1029:13): [True: 1.03k, False: 12.6k]
  |  |  ------------------
  |  | 1030|  1.03k|            (cctx)->cStage = 0;                    \
  |  | 1031|  1.03k|            return (r);                            \
  |  | 1032|  1.03k|        }                                          \
  |  | 1033|  13.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (1033:14): [Folded, False: 12.6k]
  |  |  ------------------
  ------------------
 1247|  13.6k|    assert(((void)"flush overflows dstBuffer!", cSize <= dstCapacity));
  ------------------
  |  Branch (1247:5): [True: 0, False: 12.6k]
  |  Branch (1247:5): [True: 12.6k, False: 0]
  ------------------
 1248|       |
 1249|  12.6k|    if (cctxPtr->prefs.frameInfo.blockMode == LZ4F_blockLinked)
  ------------------
  |  Branch (1249:9): [True: 7.30k, False: 5.34k]
  ------------------
 1250|  7.30k|        cctxPtr->tmpIn += cctxPtr->tmpInSize;
 1251|  12.6k|    cctxPtr->tmpInSize = 0;
 1252|       |
 1253|       |    /* keep tmpIn within limits */
 1254|  12.6k|    if ((cctxPtr->tmpIn + cctxPtr->maxBlockSize) > (cctxPtr->tmpBuff + cctxPtr->tmpBuffCapacity)) {
  ------------------
  |  Branch (1254:9): [True: 379, False: 12.2k]
  ------------------
 1255|    379|        assert(cctxPtr->prefs.frameInfo.blockMode == LZ4F_blockLinked);
  ------------------
  |  Branch (1255:9): [True: 0, False: 379]
  |  Branch (1255:9): [True: 379, False: 0]
  ------------------
 1256|    379|        LZ4F_localSaveDict(cctxPtr);
 1257|    379|    }
 1258|       |
 1259|  12.6k|    return cSize;
 1260|  12.6k|}
LZ4F_compressEnd:
 1275|  79.1k|{
 1276|  79.1k|    BYTE* const dstStart = (BYTE*)dstBuffer;
 1277|  79.1k|    BYTE* dstPtr = dstStart;
 1278|       |
 1279|  79.1k|    size_t const flushSize = LZ4F_flush(cctxPtr, dstBuffer, dstCapacity, compressOptionsPtr);
 1280|  79.1k|    DEBUGLOG(5,"LZ4F_compressEnd: dstCapacity=%u", (unsigned)dstCapacity);
  ------------------
  |  |  163|  79.1k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 1281|  79.1k|    FORWARD_IF_ERROR(flushSize);   /* note : a failed flush invalidates the frame */
  ------------------
  |  |  329|  79.1k|#define FORWARD_IF_ERROR(r) do { if (LZ4F_isError(r)) return (r); } while (0)
  |  |  ------------------
  |  |  |  Branch (329:38): [True: 35.6k, False: 43.4k]
  |  |  |  Branch (329:76): [Folded, False: 43.4k]
  |  |  ------------------
  ------------------
 1282|  43.4k|    dstPtr += flushSize;
 1283|       |
 1284|  43.4k|    assert(flushSize <= dstCapacity);
  ------------------
  |  Branch (1284:5): [True: 0, False: 43.4k]
  |  Branch (1284:5): [True: 43.4k, False: 0]
  ------------------
 1285|  43.4k|    dstCapacity -= flushSize;
 1286|       |
 1287|       |    /* From now on, the frame is either completed, or failed : it can't be continued.
 1288|       |     * State is re-usable for a new frame (with identical preferences) */
 1289|  43.4k|    cctxPtr->cStage = 0;
 1290|       |
 1291|  43.4k|    RETURN_ERROR_IF(dstCapacity < 4, dstCapacity_tooSmall);
  ------------------
  |  |  322|  43.4k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  323|  43.4k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (323:13): [True: 4.90k, False: 38.5k]
  |  |  ------------------
  |  |  324|  4.90k|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  163|  4.90k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  325|  4.90k|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  320|  4.90k|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  326|  4.90k|        }                          \
  |  |  327|  43.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (327:14): [Folded, False: 38.5k]
  |  |  ------------------
  ------------------
 1292|  38.5k|    LZ4F_writeLE32(dstPtr, 0);
 1293|  38.5k|    dstPtr += 4;   /* endMark */
 1294|       |
 1295|  38.5k|    if (cctxPtr->prefs.frameInfo.contentChecksumFlag == LZ4F_contentChecksumEnabled) {
  ------------------
  |  Branch (1295:9): [True: 19.0k, False: 19.4k]
  ------------------
 1296|  19.0k|        U32 const xxh = XXH32_digest(&(cctxPtr->xxh));
  ------------------
  |  |  133|  19.0k|#  define XXH32_digest XXH_NAME2(XXH_NAMESPACE, XXH32_digest)
  |  |  ------------------
  |  |  |  |  126|  19.0k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  19.0k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1297|  19.0k|        RETURN_ERROR_IF(dstCapacity < 8, dstCapacity_tooSmall);
  ------------------
  |  |  322|  19.0k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  323|  19.0k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (323:13): [True: 2.08k, False: 16.9k]
  |  |  ------------------
  |  |  324|  2.08k|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  163|  2.08k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  325|  2.08k|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  320|  2.08k|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  326|  2.08k|        }                          \
  |  |  327|  19.0k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (327:14): [Folded, False: 16.9k]
  |  |  ------------------
  ------------------
 1298|  16.9k|        DEBUGLOG(5,"Writing 32-bit content checksum (0x%0X)", xxh);
  ------------------
  |  |  163|  16.9k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 1299|  16.9k|        LZ4F_writeLE32(dstPtr, xxh);
 1300|  16.9k|        dstPtr+=4;   /* content Checksum */
 1301|  16.9k|    }
 1302|       |
 1303|  36.4k|    if (cctxPtr->prefs.frameInfo.contentSize) {
  ------------------
  |  Branch (1303:9): [True: 0, False: 36.4k]
  ------------------
 1304|      0|        if (cctxPtr->prefs.frameInfo.contentSize != cctxPtr->totalInSize)
  ------------------
  |  Branch (1304:13): [True: 0, False: 0]
  ------------------
 1305|      0|            RETURN_ERROR(frameSize_wrong);
  ------------------
  |  |  320|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
 1306|      0|    }
 1307|       |
 1308|  36.4k|    return (size_t)(dstPtr - dstStart);
 1309|  36.4k|}
LZ4F_createDecompressionContext_advanced:
 1355|  14.3k|{
 1356|  14.3k|    LZ4F_dctx* const dctx = (LZ4F_dctx*)LZ4F_calloc(sizeof(LZ4F_dctx), customMem);
 1357|  14.3k|    if (dctx == NULL) return NULL;
  ------------------
  |  Branch (1357:9): [True: 0, False: 14.3k]
  ------------------
 1358|       |
 1359|  14.3k|    dctx->cmem = customMem;
 1360|  14.3k|    dctx->version = version;
 1361|  14.3k|    return dctx;
 1362|  14.3k|}
LZ4F_createDecompressionContext:
 1372|  14.3k|{
 1373|  14.3k|    assert(LZ4F_decompressionContextPtr != NULL);  /* violation of narrow contract */
  ------------------
  |  Branch (1373:5): [True: 0, False: 14.3k]
  |  Branch (1373:5): [True: 14.3k, False: 0]
  ------------------
 1374|  14.3k|    RETURN_ERROR_IF(LZ4F_decompressionContextPtr == NULL, parameter_null);  /* in case it nonetheless happen in production */
  ------------------
  |  |  322|  14.3k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  323|  14.3k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (323:13): [True: 0, False: 14.3k]
  |  |  ------------------
  |  |  324|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  163|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  325|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  320|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  326|      0|        }                          \
  |  |  327|  14.3k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (327:14): [Folded, False: 14.3k]
  |  |  ------------------
  ------------------
 1375|       |
 1376|  14.3k|    *LZ4F_decompressionContextPtr = LZ4F_createDecompressionContext_advanced(LZ4F_defaultCMem, versionNumber);
 1377|  14.3k|    if (*LZ4F_decompressionContextPtr == NULL) {  /* failed allocation */
  ------------------
  |  Branch (1377:9): [True: 0, False: 14.3k]
  ------------------
 1378|      0|        RETURN_ERROR(allocation_failed);
  ------------------
  |  |  320|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
 1379|      0|    }
 1380|  14.3k|    return LZ4F_OK_NoError;
 1381|  14.3k|}
LZ4F_freeDecompressionContext:
 1384|  14.3k|{
 1385|  14.3k|    LZ4F_errorCode_t result = LZ4F_OK_NoError;
 1386|  14.3k|    if (dctx != NULL) {   /* can accept NULL input, like free() */
  ------------------
  |  Branch (1386:9): [True: 14.3k, False: 0]
  ------------------
 1387|  14.3k|      result = (LZ4F_errorCode_t)dctx->dStage;
 1388|  14.3k|      LZ4F_free(dctx->tmpIn, dctx->cmem);
 1389|  14.3k|      LZ4F_free(dctx->tmpOutBuffer, dctx->cmem);
 1390|  14.3k|      LZ4F_free(dctx, dctx->cmem);
 1391|  14.3k|    }
 1392|  14.3k|    return result;
 1393|  14.3k|}
LZ4F_resetDecompressionContext:
 1405|  14.3k|{
 1406|  14.3k|    DEBUGLOG(5, "LZ4F_resetDecompressionContext");
  ------------------
  |  |  163|  14.3k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 1407|  14.3k|    dctx->dStage = dstage_getFrameHeader;
 1408|       |    dctx->dict = NULL;
 1409|  14.3k|    dctx->dictSize = 0;
 1410|  14.3k|    dctx->skipBlockChecksum = 0;
 1411|  14.3k|    dctx->skipContentChecksum = 0;
 1412|  14.3k|    dctx->frameRemainingSize = 0;
 1413|  14.3k|}
LZ4F_decompress:
 1699|  14.3k|{
 1700|  14.3k|    static const BYTE emptySrc = 0;   /* NULL srcBuffer (no input, used by LZ4F_getFrameInfo()) points here instead :
 1701|       |                                       * NULL+0 and memcpy(dst, NULL, 0) are UB */
 1702|  14.3k|    LZ4F_decompressOptions_t optionsNull;
 1703|  14.3k|    const BYTE* const srcStart = srcBuffer ? (const BYTE*)srcBuffer : &emptySrc;
  ------------------
  |  Branch (1703:34): [True: 14.3k, False: 0]
  ------------------
 1704|  14.3k|    const BYTE* const srcEnd = srcBuffer ? srcStart + *srcSizePtr : srcStart;
  ------------------
  |  Branch (1704:32): [True: 14.3k, False: 0]
  ------------------
 1705|  14.3k|    const BYTE* srcPtr = srcStart;
 1706|  14.3k|    BYTE* const dstStart = (BYTE*)dstBuffer;
 1707|  14.3k|    BYTE* const dstEnd = dstStart ? dstStart + *dstSizePtr : NULL;
  ------------------
  |  Branch (1707:26): [True: 14.3k, False: 0]
  ------------------
 1708|  14.3k|    BYTE* dstPtr = dstStart;
 1709|  14.3k|    const BYTE* selectedIn = NULL;
 1710|  14.3k|    unsigned doAnotherStage = 1;
 1711|  14.3k|    size_t nextSrcSizeHint = 1;
 1712|       |
 1713|       |
 1714|  14.3k|    DEBUGLOG(5, "LZ4F_decompress: src[%p](%u) => dst[%p](%u)",
  ------------------
  |  |  163|  14.3k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 1715|  14.3k|            srcBuffer, (unsigned)*srcSizePtr, dstBuffer, (unsigned)*dstSizePtr);
 1716|  14.3k|    if (dstBuffer == NULL) assert(*dstSizePtr == 0);
  ------------------
  |  Branch (1716:9): [True: 0, False: 14.3k]
  |  Branch (1716:28): [True: 0, False: 0]
  |  Branch (1716:28): [True: 0, False: 0]
  ------------------
 1717|  14.3k|    if (srcBuffer == NULL) assert(*srcSizePtr == 0);
  ------------------
  |  Branch (1717:9): [True: 0, False: 14.3k]
  |  Branch (1717:28): [True: 0, False: 0]
  |  Branch (1717:28): [True: 0, False: 0]
  ------------------
 1718|  14.3k|    MEM_INIT(&optionsNull, 0, sizeof(optionsNull));
  ------------------
  |  |   91|  14.3k|#  define MEM_INIT(p,v,s)   memset((p),(v),(s))
  ------------------
 1719|  14.3k|    if (decompressOptionsPtr==NULL) decompressOptionsPtr = &optionsNull;
  ------------------
  |  Branch (1719:9): [True: 0, False: 14.3k]
  ------------------
 1720|  14.3k|    *srcSizePtr = 0;
 1721|  14.3k|    *dstSizePtr = 0;
 1722|  14.3k|    assert(dctx != NULL);
  ------------------
  |  Branch (1722:5): [True: 0, False: 14.3k]
  |  Branch (1722:5): [True: 14.3k, False: 0]
  ------------------
 1723|  14.3k|    if (decompressOptionsPtr->skipChecksums) {   /* once set, disable for the remainder of the frame */
  ------------------
  |  Branch (1723:9): [True: 1.63k, False: 12.6k]
  ------------------
 1724|  1.63k|        dctx->skipBlockChecksum = 1;
 1725|  1.63k|        dctx->skipContentChecksum = 1;
 1726|  1.63k|    }
 1727|       |
 1728|       |    /* behaves as a state machine */
 1729|       |
 1730|   101k|    while (doAnotherStage) {
  ------------------
  |  Branch (1730:12): [True: 86.9k, False: 14.3k]
  ------------------
 1731|       |
 1732|  86.9k|        switch(dctx->dStage)
  ------------------
  |  Branch (1732:16): [True: 86.9k, False: 0]
  ------------------
 1733|  86.9k|        {
 1734|       |
 1735|  14.3k|        case dstage_getFrameHeader:
  ------------------
  |  Branch (1735:9): [True: 14.3k, False: 72.6k]
  ------------------
 1736|  14.3k|            DEBUGLOG(6, "dstage_getFrameHeader");
  ------------------
  |  |  163|  14.3k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 1737|  14.3k|            if ((size_t)(srcEnd-srcPtr) >= maxFHSize) {  /* enough to decode - shortcut */
  ------------------
  |  Branch (1737:17): [True: 9.44k, False: 4.86k]
  ------------------
 1738|  9.44k|                size_t const hSize = LZ4F_decodeHeader(dctx, srcPtr, (size_t)(srcEnd-srcPtr));  /* will update dStage appropriately */
 1739|  9.44k|                FORWARD_IF_ERROR(hSize);
  ------------------
  |  |  329|  9.44k|#define FORWARD_IF_ERROR(r) do { if (LZ4F_isError(r)) return (r); } while (0)
  |  |  ------------------
  |  |  |  Branch (329:38): [True: 0, False: 9.44k]
  |  |  |  Branch (329:76): [Folded, False: 9.44k]
  |  |  ------------------
  ------------------
 1740|  9.44k|                srcPtr += hSize;
 1741|  9.44k|                break;
 1742|  9.44k|            }
 1743|  4.86k|            dctx->tmpInSize = 0;
 1744|  4.86k|            if (srcEnd-srcPtr == 0) return minFHSize;   /* 0-size input */
  ------------------
  |  Branch (1744:17): [True: 0, False: 4.86k]
  ------------------
 1745|  4.86k|            dctx->tmpInTarget = minFHSize;   /* minimum size to decode header */
 1746|  4.86k|            dctx->dStage = dstage_storeFrameHeader;
 1747|       |            /* fall-through */
 1748|       |
 1749|  4.86k|        case dstage_storeFrameHeader:
  ------------------
  |  Branch (1749:9): [True: 0, False: 86.9k]
  ------------------
 1750|  4.86k|            DEBUGLOG(6, "dstage_storeFrameHeader");
  ------------------
  |  |  163|  4.86k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 1751|  4.86k|            {   size_t const sizeToCopy = MIN(dctx->tmpInTarget - dctx->tmpInSize, (size_t)(srcEnd - srcPtr));
  ------------------
  |  |  349|  4.86k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (349:22): [True: 4.86k, False: 0]
  |  |  ------------------
  ------------------
 1752|  4.86k|                memcpy(dctx->header + dctx->tmpInSize, srcPtr, sizeToCopy);
 1753|  4.86k|                dctx->tmpInSize += sizeToCopy;
 1754|  4.86k|                srcPtr += sizeToCopy;
 1755|  4.86k|            }
 1756|  4.86k|            if (dctx->tmpInSize < dctx->tmpInTarget) {
  ------------------
  |  Branch (1756:17): [True: 0, False: 4.86k]
  ------------------
 1757|      0|                nextSrcSizeHint = (dctx->tmpInTarget - dctx->tmpInSize) + BHSize;   /* rest of header + nextBlockHeader */
 1758|      0|                doAnotherStage = 0;   /* not enough src data, ask for some more */
 1759|      0|                break;
 1760|      0|            }
 1761|  4.86k|            FORWARD_IF_ERROR( LZ4F_decodeHeader(dctx, dctx->header, dctx->tmpInTarget) ); /* will update dStage appropriately */
  ------------------
  |  |  329|  4.86k|#define FORWARD_IF_ERROR(r) do { if (LZ4F_isError(r)) return (r); } while (0)
  |  |  ------------------
  |  |  |  Branch (329:38): [True: 0, False: 4.86k]
  |  |  |  Branch (329:76): [Folded, False: 4.86k]
  |  |  ------------------
  ------------------
 1762|  4.86k|            break;
 1763|       |
 1764|  14.3k|        case dstage_init:
  ------------------
  |  Branch (1764:9): [True: 14.3k, False: 72.6k]
  ------------------
 1765|  14.3k|            DEBUGLOG(6, "dstage_init");
  ------------------
  |  |  163|  14.3k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 1766|  14.3k|            if (dctx->frameInfo.contentChecksumFlag) (void)XXH32_reset(&(dctx->xxh), 0);
  ------------------
  |  |  131|  6.65k|#  define XXH32_reset XXH_NAME2(XXH_NAMESPACE, XXH32_reset)
  |  |  ------------------
  |  |  |  |  126|  6.65k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  6.65k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1766:17): [True: 6.65k, False: 7.65k]
  ------------------
 1767|       |            /* internal buffers allocation */
 1768|  14.3k|            {   size_t const tmpInNeeded = dctx->maxBlockSize + BFSize /* block checksum */;
 1769|  14.3k|                size_t const tmpOutNeeded = dctx->maxBlockSize
 1770|  14.3k|                    + ((dctx->frameInfo.blockMode==LZ4F_blockLinked) ? 128 KB : 0);
  ------------------
  |  |  240|  11.0k|#  define KB *(1<<10)
  ------------------
  |  Branch (1770:24): [True: 11.0k, False: 3.21k]
  ------------------
 1771|  14.3k|                if ( (tmpInNeeded > dctx->tmpInCapacity)
  ------------------
  |  Branch (1771:22): [True: 14.3k, False: 0]
  ------------------
 1772|  14.3k|                  || (tmpOutNeeded > dctx->tmpOutBufferCapacity) ) {   /* tmp buffers too small */
  ------------------
  |  Branch (1772:22): [True: 0, False: 0]
  ------------------
 1773|       |                    /* capacities remain 0 until allocation succeeds,
 1774|       |                     * so that allocation will be re-attempted on next entry */
 1775|  14.3k|                    LZ4F_free(dctx->tmpIn, dctx->cmem);
 1776|  14.3k|                    dctx->tmpInCapacity = 0;
 1777|  14.3k|                    dctx->tmpIn = (BYTE*)LZ4F_malloc(tmpInNeeded, dctx->cmem);
 1778|  14.3k|                    RETURN_ERROR_IF(dctx->tmpIn == NULL, allocation_failed);
  ------------------
  |  |  322|  14.3k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  323|  14.3k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (323:13): [True: 0, False: 14.3k]
  |  |  ------------------
  |  |  324|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  163|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  325|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  320|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  326|      0|        }                          \
  |  |  327|  14.3k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (327:14): [Folded, False: 14.3k]
  |  |  ------------------
  ------------------
 1779|  14.3k|                    dctx->tmpInCapacity = tmpInNeeded;
 1780|  14.3k|                    LZ4F_free(dctx->tmpOutBuffer, dctx->cmem);
 1781|  14.3k|                    dctx->tmpOutBufferCapacity = 0;
 1782|  14.3k|                    dctx->tmpOutBuffer= (BYTE*)LZ4F_malloc(tmpOutNeeded, dctx->cmem);
 1783|  14.3k|                    RETURN_ERROR_IF(dctx->tmpOutBuffer== NULL, allocation_failed);
  ------------------
  |  |  322|  14.3k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  323|  14.3k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (323:13): [True: 0, False: 14.3k]
  |  |  ------------------
  |  |  324|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  163|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  325|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  320|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  326|      0|        }                          \
  |  |  327|  14.3k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (327:14): [Folded, False: 14.3k]
  |  |  ------------------
  ------------------
 1784|  14.3k|                    dctx->tmpOutBufferCapacity = tmpOutNeeded;
 1785|  14.3k|            }   }
 1786|  14.3k|            dctx->tmpInSize = 0;
 1787|  14.3k|            dctx->tmpInTarget = 0;
 1788|  14.3k|            dctx->tmpOut = dctx->tmpOutBuffer;
 1789|  14.3k|            dctx->tmpOutStart = 0;
 1790|  14.3k|            dctx->tmpOutSize = 0;
 1791|       |
 1792|  14.3k|            dctx->dStage = dstage_getBlockHeader;
 1793|       |            /* fall-through */
 1794|       |
 1795|  34.4k|        case dstage_getBlockHeader:
  ------------------
  |  Branch (1795:9): [True: 20.0k, False: 66.8k]
  ------------------
 1796|  34.4k|            if ((size_t)(srcEnd - srcPtr) >= BHSize) {
  ------------------
  |  Branch (1796:17): [True: 34.4k, False: 0]
  ------------------
 1797|  34.4k|                selectedIn = srcPtr;
 1798|  34.4k|                srcPtr += BHSize;
 1799|  34.4k|            } else {
 1800|       |                /* not enough input to read cBlockSize field */
 1801|      0|                dctx->tmpInSize = 0;
 1802|      0|                dctx->dStage = dstage_storeBlockHeader;
 1803|      0|            }
 1804|       |
 1805|  34.4k|            if (dctx->dStage == dstage_storeBlockHeader)   /* can be skipped */
  ------------------
  |  Branch (1805:17): [True: 0, False: 34.4k]
  ------------------
 1806|      0|        case dstage_storeBlockHeader:
  ------------------
  |  Branch (1806:9): [True: 0, False: 86.9k]
  ------------------
 1807|      0|            {   size_t const remainingInput = (size_t)(srcEnd - srcPtr);
 1808|      0|                size_t const wantedData = BHSize - dctx->tmpInSize;
 1809|      0|                size_t const sizeToCopy = MIN(wantedData, remainingInput);
  ------------------
  |  |  349|      0|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (349:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1810|      0|                memcpy(dctx->tmpIn + dctx->tmpInSize, srcPtr, sizeToCopy);
 1811|      0|                srcPtr += sizeToCopy;
 1812|      0|                dctx->tmpInSize += sizeToCopy;
 1813|       |
 1814|      0|                if (dctx->tmpInSize < BHSize) {   /* not enough input for cBlockSize */
  ------------------
  |  Branch (1814:21): [True: 0, False: 0]
  ------------------
 1815|      0|                    nextSrcSizeHint = BHSize - dctx->tmpInSize;
 1816|      0|                    doAnotherStage  = 0;
 1817|      0|                    break;
 1818|      0|                }
 1819|      0|                selectedIn = dctx->tmpIn;
 1820|      0|            }   /* if (dctx->dStage == dstage_storeBlockHeader) */
 1821|       |
 1822|       |        /* decode block header */
 1823|  34.4k|            {   U32 const blockHeader = LZ4F_readLE32(selectedIn);
 1824|  34.4k|                size_t const nextCBlockSize = blockHeader & 0x7FFFFFFFU;
 1825|  34.4k|                size_t const crcSize = dctx->frameInfo.blockChecksumFlag * BFSize;
 1826|  34.4k|                if (blockHeader==0) {  /* frameEnd signal, no more block */
  ------------------
  |  Branch (1826:21): [True: 14.3k, False: 20.0k]
  ------------------
 1827|  14.3k|                    DEBUGLOG(5, "end of frame");
  ------------------
  |  |  163|  14.3k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 1828|  14.3k|                    dctx->dStage = dstage_getSuffix;
 1829|  14.3k|                    break;
 1830|  14.3k|                }
 1831|  20.0k|                if (nextCBlockSize > dctx->maxBlockSize) {
  ------------------
  |  Branch (1831:21): [True: 0, False: 20.0k]
  ------------------
 1832|      0|                    RETURN_ERROR(maxBlockSize_invalid);
  ------------------
  |  |  320|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
 1833|      0|                }
 1834|  20.0k|                if (blockHeader & LZ4F_BLOCKUNCOMPRESSED_FLAG) {
  ------------------
  |  |  251|  20.0k|#define LZ4F_BLOCKUNCOMPRESSED_FLAG 0x80000000U
  ------------------
  |  Branch (1834:21): [True: 6.42k, False: 13.6k]
  ------------------
 1835|       |                    /* next block is uncompressed */
 1836|  6.42k|                    dctx->tmpInTarget = nextCBlockSize;
 1837|  6.42k|                    DEBUGLOG(5, "next block is uncompressed (size %u)", (U32)nextCBlockSize);
  ------------------
  |  |  163|  6.42k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 1838|  6.42k|                    if (dctx->frameInfo.blockChecksumFlag) {
  ------------------
  |  Branch (1838:25): [True: 3.83k, False: 2.58k]
  ------------------
 1839|  3.83k|                        (void)XXH32_reset(&dctx->blockChecksum, 0);
  ------------------
  |  |  131|  3.83k|#  define XXH32_reset XXH_NAME2(XXH_NAMESPACE, XXH32_reset)
  |  |  ------------------
  |  |  |  |  126|  3.83k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  3.83k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1840|  3.83k|                    }
 1841|  6.42k|                    dctx->dStage = dstage_copyDirect;
 1842|  6.42k|                    break;
 1843|  6.42k|                }
 1844|       |                /* next block is a compressed block */
 1845|  13.6k|                dctx->tmpInTarget = nextCBlockSize + crcSize;
 1846|  13.6k|                dctx->dStage = dstage_getCBlock;
 1847|  13.6k|                if (dstPtr==dstEnd || srcPtr==srcEnd) {
  ------------------
  |  Branch (1847:21): [True: 0, False: 13.6k]
  |  Branch (1847:39): [True: 0, False: 13.6k]
  ------------------
 1848|      0|                    nextSrcSizeHint = BHSize + nextCBlockSize + crcSize;
 1849|      0|                    doAnotherStage = 0;
 1850|      0|                }
 1851|  13.6k|                break;
 1852|  20.0k|            }
 1853|       |
 1854|  6.42k|        case dstage_copyDirect:   /* uncompressed block */
  ------------------
  |  Branch (1854:9): [True: 6.42k, False: 80.5k]
  ------------------
 1855|  6.42k|            DEBUGLOG(6, "dstage_copyDirect");
  ------------------
  |  |  163|  6.42k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 1856|  6.42k|            {   size_t sizeToCopy;
 1857|  6.42k|                if (dstPtr == NULL) {
  ------------------
  |  Branch (1857:21): [True: 0, False: 6.42k]
  ------------------
 1858|      0|                    sizeToCopy = 0;
 1859|  6.42k|                } else {
 1860|  6.42k|                    size_t const minBuffSize = MIN((size_t)(srcEnd-srcPtr), (size_t)(dstEnd-dstPtr));
  ------------------
  |  |  349|  6.42k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (349:22): [True: 3.18k, False: 3.23k]
  |  |  ------------------
  ------------------
 1861|  6.42k|                    sizeToCopy = MIN(dctx->tmpInTarget, minBuffSize);
  ------------------
  |  |  349|  6.42k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (349:22): [True: 5.15k, False: 1.26k]
  |  |  ------------------
  ------------------
 1862|  6.42k|                    memcpy(dstPtr, srcPtr, sizeToCopy);
 1863|  6.42k|                    if (dctx->frameInfo.blockChecksumFlag && !dctx->skipBlockChecksum)
  ------------------
  |  Branch (1863:25): [True: 3.83k, False: 2.58k]
  |  Branch (1863:62): [True: 3.58k, False: 249]
  ------------------
 1864|  3.58k|                        (void)XXH32_update(&dctx->blockChecksum, srcPtr, sizeToCopy);
  ------------------
  |  |  132|  3.58k|#  define XXH32_update XXH_NAME2(XXH_NAMESPACE, XXH32_update)
  |  |  ------------------
  |  |  |  |  126|  3.58k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  3.58k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1865|  6.42k|                    if (dctx->frameInfo.contentChecksumFlag && !dctx->skipContentChecksum)
  ------------------
  |  Branch (1865:25): [True: 3.32k, False: 3.09k]
  |  Branch (1865:64): [True: 3.02k, False: 297]
  ------------------
 1866|  3.02k|                        (void)XXH32_update(&dctx->xxh, srcPtr, sizeToCopy);
  ------------------
  |  |  132|  3.02k|#  define XXH32_update XXH_NAME2(XXH_NAMESPACE, XXH32_update)
  |  |  ------------------
  |  |  |  |  126|  3.02k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  3.02k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1867|  6.42k|                    if (dctx->frameInfo.contentSize)
  ------------------
  |  Branch (1867:25): [True: 0, False: 6.42k]
  ------------------
 1868|      0|                        dctx->frameRemainingSize -= sizeToCopy;
 1869|       |
 1870|       |                    /* history management (linked blocks only)*/
 1871|  6.42k|                    if (dctx->frameInfo.blockMode == LZ4F_blockLinked) {
  ------------------
  |  Branch (1871:25): [True: 5.24k, False: 1.17k]
  ------------------
 1872|  5.24k|                        LZ4F_updateDict(dctx, dstPtr, sizeToCopy, dstStart, 0);
 1873|  5.24k|                    }
 1874|  6.42k|                    srcPtr += sizeToCopy;
 1875|  6.42k|                    dstPtr += sizeToCopy;
 1876|  6.42k|                }
 1877|  6.42k|                if (sizeToCopy == dctx->tmpInTarget) {   /* all done */
  ------------------
  |  Branch (1877:21): [True: 6.42k, False: 0]
  ------------------
 1878|  6.42k|                    if (dctx->frameInfo.blockChecksumFlag) {
  ------------------
  |  Branch (1878:25): [True: 3.83k, False: 2.58k]
  ------------------
 1879|  3.83k|                        dctx->tmpInSize = 0;
 1880|  3.83k|                        dctx->dStage = dstage_getBlockChecksum;
 1881|  3.83k|                    } else
 1882|  2.58k|                        dctx->dStage = dstage_getBlockHeader;  /* new block */
 1883|  6.42k|                    break;
 1884|  6.42k|                }
 1885|      0|                dctx->tmpInTarget -= sizeToCopy;  /* need to copy more */
 1886|      0|            }
 1887|      0|            nextSrcSizeHint = dctx->tmpInTarget +
 1888|      0|                            +(dctx->frameInfo.blockChecksumFlag ? BFSize : 0)
  ------------------
  |  Branch (1888:31): [True: 0, False: 0]
  ------------------
 1889|      0|                            + BHSize /* next header size */;
 1890|      0|            doAnotherStage = 0;
 1891|      0|            break;
 1892|       |
 1893|       |        /* check block checksum for recently transferred uncompressed block */
 1894|  3.83k|        case dstage_getBlockChecksum:
  ------------------
  |  Branch (1894:9): [True: 3.83k, False: 83.1k]
  ------------------
 1895|  3.83k|            DEBUGLOG(6, "dstage_getBlockChecksum");
  ------------------
  |  |  163|  3.83k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 1896|  3.83k|            {   const void* crcSrc;
 1897|  3.83k|                if ((srcEnd-srcPtr >= 4) && (dctx->tmpInSize==0)) {
  ------------------
  |  Branch (1897:21): [True: 3.83k, False: 0]
  |  Branch (1897:45): [True: 3.83k, False: 0]
  ------------------
 1898|  3.83k|                    crcSrc = srcPtr;
 1899|  3.83k|                    srcPtr += 4;
 1900|  3.83k|                } else {
 1901|      0|                    size_t const stillToCopy = 4 - dctx->tmpInSize;
 1902|      0|                    size_t const sizeToCopy = MIN(stillToCopy, (size_t)(srcEnd-srcPtr));
  ------------------
  |  |  349|      0|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (349:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1903|      0|                    memcpy(dctx->header + dctx->tmpInSize, srcPtr, sizeToCopy);
 1904|      0|                    dctx->tmpInSize += sizeToCopy;
 1905|      0|                    srcPtr += sizeToCopy;
 1906|      0|                    if (dctx->tmpInSize < 4) {  /* all input consumed */
  ------------------
  |  Branch (1906:25): [True: 0, False: 0]
  ------------------
 1907|      0|                        nextSrcSizeHint = (4 - dctx->tmpInSize) + BHSize /* next header size */;
 1908|      0|                        doAnotherStage = 0;
 1909|      0|                        break;
 1910|      0|                    }
 1911|      0|                    crcSrc = dctx->header;
 1912|      0|                }
 1913|  3.83k|                if (!dctx->skipBlockChecksum) {
  ------------------
  |  Branch (1913:21): [True: 3.58k, False: 249]
  ------------------
 1914|  3.58k|                    U32 const readCRC = LZ4F_readLE32(crcSrc);
 1915|  3.58k|                    U32 const calcCRC = XXH32_digest(&dctx->blockChecksum);
  ------------------
  |  |  133|  3.58k|#  define XXH32_digest XXH_NAME2(XXH_NAMESPACE, XXH32_digest)
  |  |  ------------------
  |  |  |  |  126|  3.58k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  3.58k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1916|       |#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
 1917|       |                    DEBUGLOG(6, "compare block checksum");
 1918|       |                    if (readCRC != calcCRC) {
 1919|       |                        DEBUGLOG(4, "incorrect block checksum: %08X != %08X",
 1920|       |                                readCRC, calcCRC);
 1921|       |                        RETURN_ERROR(blockChecksum_invalid);
 1922|       |                    }
 1923|       |#else
 1924|  3.58k|                    (void)readCRC;
 1925|  3.58k|                    (void)calcCRC;
 1926|  3.58k|#endif
 1927|  3.58k|            }   }
 1928|      0|            dctx->dStage = dstage_getBlockHeader;  /* new block */
 1929|  3.83k|            break;
 1930|       |
 1931|  13.6k|        case dstage_getCBlock:
  ------------------
  |  Branch (1931:9): [True: 13.6k, False: 73.2k]
  ------------------
 1932|  13.6k|            DEBUGLOG(6, "dstage_getCBlock");
  ------------------
  |  |  163|  13.6k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 1933|  13.6k|            if ((size_t)(srcEnd-srcPtr) < dctx->tmpInTarget) {
  ------------------
  |  Branch (1933:17): [True: 0, False: 13.6k]
  ------------------
 1934|      0|                dctx->tmpInSize = 0;
 1935|      0|                dctx->dStage = dstage_storeCBlock;
 1936|      0|                break;
 1937|      0|            }
 1938|       |            /* input large enough to read full block directly */
 1939|  13.6k|            selectedIn = srcPtr;
 1940|  13.6k|            srcPtr += dctx->tmpInTarget;
 1941|       |
 1942|  13.6k|            if (0)  /* always jump over next block */
  ------------------
  |  Branch (1942:17): [Folded, False: 13.6k]
  ------------------
 1943|      0|        case dstage_storeCBlock:
  ------------------
  |  Branch (1943:9): [True: 0, False: 86.9k]
  ------------------
 1944|      0|            {   size_t const wantedData = dctx->tmpInTarget - dctx->tmpInSize;
 1945|      0|                size_t const inputLeft = (size_t)(srcEnd-srcPtr);
 1946|      0|                size_t const sizeToCopy = MIN(wantedData, inputLeft);
  ------------------
  |  |  349|      0|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (349:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1947|      0|                memcpy(dctx->tmpIn + dctx->tmpInSize, srcPtr, sizeToCopy);
 1948|      0|                dctx->tmpInSize += sizeToCopy;
 1949|      0|                srcPtr += sizeToCopy;
 1950|      0|                if (dctx->tmpInSize < dctx->tmpInTarget) { /* need more input */
  ------------------
  |  Branch (1950:21): [True: 0, False: 0]
  ------------------
 1951|      0|                    nextSrcSizeHint = (dctx->tmpInTarget - dctx->tmpInSize)   /* block checksum included */
 1952|      0|                                    + BHSize /* next header size */;
 1953|      0|                    doAnotherStage = 0;
 1954|      0|                    break;
 1955|      0|                }
 1956|      0|                selectedIn = dctx->tmpIn;
 1957|      0|            }
 1958|       |
 1959|       |            /* At this stage, input is large enough to decode a block */
 1960|       |
 1961|       |            /* First, decode and control block checksum if it exists */
 1962|  13.6k|            if (dctx->frameInfo.blockChecksumFlag) {
  ------------------
  |  Branch (1962:17): [True: 7.63k, False: 6.04k]
  ------------------
 1963|  7.63k|                assert(dctx->tmpInTarget >= 4);
  ------------------
  |  Branch (1963:17): [True: 0, False: 7.63k]
  |  Branch (1963:17): [True: 7.63k, False: 0]
  ------------------
 1964|  7.63k|                dctx->tmpInTarget -= 4;
 1965|  7.63k|                assert(selectedIn != NULL);  /* selectedIn is defined at this stage (either srcPtr, or dctx->tmpIn) */
  ------------------
  |  Branch (1965:17): [True: 0, False: 7.63k]
  |  Branch (1965:17): [True: 7.63k, False: 0]
  ------------------
 1966|  7.63k|                if (!dctx->skipBlockChecksum) {
  ------------------
  |  Branch (1966:21): [True: 7.17k, False: 453]
  ------------------
 1967|  7.17k|                    U32 const readBlockCrc = LZ4F_readLE32(selectedIn + dctx->tmpInTarget);
 1968|  7.17k|                    U32 const calcBlockCrc = XXH32(selectedIn, dctx->tmpInTarget, 0);
  ------------------
  |  |  128|  7.17k|#  define XXH32 XXH_NAME2(XXH_NAMESPACE, XXH32)
  |  |  ------------------
  |  |  |  |  126|  7.17k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  7.17k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1969|       |#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
 1970|       |                    RETURN_ERROR_IF(readBlockCrc != calcBlockCrc, blockChecksum_invalid);
 1971|       |#else
 1972|  7.17k|                    (void)readBlockCrc;
 1973|  7.17k|                    (void)calcBlockCrc;
 1974|  7.17k|#endif
 1975|  7.17k|            }   }
 1976|       |
 1977|       |            /* decode directly into destination buffer if there is enough room */
 1978|  13.6k|            if ( ((size_t)(dstEnd-dstPtr) >= dctx->maxBlockSize)
  ------------------
  |  Branch (1978:18): [True: 3.08k, False: 10.5k]
  ------------------
 1979|       |                 /* unless the dictionary is stored in tmpOut:
 1980|       |                  * in which case it's faster to decode within tmpOut
 1981|       |                  * to benefit from prefix speedup */
 1982|  3.08k|              && !(dctx->dict!= NULL && (const BYTE*)dctx->dict + dctx->dictSize == dctx->tmpOut) )
  ------------------
  |  Branch (1982:20): [True: 1.80k, False: 1.28k]
  |  Branch (1982:41): [True: 0, False: 1.80k]
  ------------------
 1983|  3.08k|            {
 1984|  3.08k|                const char* dict = (const char*)dctx->dict;
 1985|  3.08k|                size_t dictSize = dctx->dictSize;
 1986|  3.08k|                int decodedSize;
 1987|  3.08k|                assert(dstPtr != NULL);
  ------------------
  |  Branch (1987:17): [True: 0, False: 3.08k]
  |  Branch (1987:17): [True: 3.08k, False: 0]
  ------------------
 1988|  3.08k|                if (dict && dictSize > 1 GB) {
  ------------------
  |  |  242|  1.80k|#  define GB *(1<<30)
  ------------------
  |  Branch (1988:21): [True: 1.80k, False: 1.28k]
  |  Branch (1988:29): [True: 0, False: 1.80k]
  ------------------
 1989|       |                    /* overflow control : dctx->dictSize is an int, avoid truncation / sign issues */
 1990|      0|                    dict += dictSize - 64 KB;
  ------------------
  |  |  240|      0|#  define KB *(1<<10)
  ------------------
 1991|      0|                    dictSize = 64 KB;
  ------------------
  |  |  240|      0|#  define KB *(1<<10)
  ------------------
 1992|      0|                }
 1993|  3.08k|                decodedSize = LZ4_decompress_safe_usingDict(
 1994|  3.08k|                        (const char*)selectedIn, (char*)dstPtr,
 1995|  3.08k|                        (int)dctx->tmpInTarget, (int)dctx->maxBlockSize,
 1996|  3.08k|                        dict, (int)dictSize);
 1997|  3.08k|                RETURN_ERROR_IF(decodedSize < 0, decompressionFailed);
  ------------------
  |  |  322|  3.08k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  323|  3.08k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (323:13): [True: 0, False: 3.08k]
  |  |  ------------------
  |  |  324|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  163|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  325|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  320|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  326|      0|        }                          \
  |  |  327|  3.08k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (327:14): [Folded, False: 3.08k]
  |  |  ------------------
  ------------------
 1998|  3.08k|                if ((dctx->frameInfo.contentChecksumFlag) && (!dctx->skipContentChecksum))
  ------------------
  |  Branch (1998:21): [True: 1.38k, False: 1.70k]
  |  Branch (1998:62): [True: 1.19k, False: 189]
  ------------------
 1999|  1.19k|                    XXH32_update(&(dctx->xxh), dstPtr, (size_t)decodedSize);
  ------------------
  |  |  132|  1.19k|#  define XXH32_update XXH_NAME2(XXH_NAMESPACE, XXH32_update)
  |  |  ------------------
  |  |  |  |  126|  1.19k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  1.19k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2000|  3.08k|                if (dctx->frameInfo.contentSize)
  ------------------
  |  Branch (2000:21): [True: 0, False: 3.08k]
  ------------------
 2001|      0|                    dctx->frameRemainingSize -= (size_t)decodedSize;
 2002|       |
 2003|       |                /* dictionary management */
 2004|  3.08k|                if (dctx->frameInfo.blockMode==LZ4F_blockLinked) {
  ------------------
  |  Branch (2004:21): [True: 2.45k, False: 626]
  ------------------
 2005|  2.45k|                    LZ4F_updateDict(dctx, dstPtr, (size_t)decodedSize, dstStart, 0);
 2006|  2.45k|                }
 2007|       |
 2008|  3.08k|                dstPtr += decodedSize;
 2009|  3.08k|                dctx->dStage = dstage_getBlockHeader;  /* end of block, let's get another one */
 2010|  3.08k|                break;
 2011|  3.08k|            }
 2012|       |
 2013|       |            /* not enough place into dst : decode into tmpOut */
 2014|       |
 2015|       |            /* manage dictionary */
 2016|  10.5k|            if (dctx->frameInfo.blockMode == LZ4F_blockLinked) {
  ------------------
  |  Branch (2016:17): [True: 8.43k, False: 2.16k]
  ------------------
 2017|  8.43k|                if (dctx->dict == dctx->tmpOutBuffer) {
  ------------------
  |  Branch (2017:21): [True: 0, False: 8.43k]
  ------------------
 2018|       |                    /* truncate dictionary to 64 KB if too big */
 2019|      0|                    if (dctx->dictSize > 128 KB) {
  ------------------
  |  |  240|      0|#  define KB *(1<<10)
  ------------------
  |  Branch (2019:25): [True: 0, False: 0]
  ------------------
 2020|      0|                        memcpy(dctx->tmpOutBuffer, dctx->dict + dctx->dictSize - 64 KB, 64 KB);
  ------------------
  |  |  240|      0|#  define KB *(1<<10)
  ------------------
                                      memcpy(dctx->tmpOutBuffer, dctx->dict + dctx->dictSize - 64 KB, 64 KB);
  ------------------
  |  |  240|      0|#  define KB *(1<<10)
  ------------------
 2021|      0|                        dctx->dictSize = 64 KB;
  ------------------
  |  |  240|      0|#  define KB *(1<<10)
  ------------------
 2022|      0|                    }
 2023|      0|                    dctx->tmpOut = dctx->tmpOutBuffer + dctx->dictSize;
 2024|  8.43k|                } else {  /* dict not within tmpOut */
 2025|  8.43k|                    size_t const reservedDictSpace = MIN(dctx->dictSize, 64 KB);
  ------------------
  |  |  349|  8.43k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (349:22): [True: 7.88k, False: 550]
  |  |  ------------------
  ------------------
 2026|  8.43k|                    dctx->tmpOut = dctx->tmpOutBuffer + reservedDictSpace;
 2027|  8.43k|            }   }
 2028|       |
 2029|       |            /* Decode block into tmpOut */
 2030|  10.5k|            {   const char* dict = (const char*)dctx->dict;
 2031|  10.5k|                size_t dictSize = dctx->dictSize;
 2032|  10.5k|                int decodedSize;
 2033|  10.5k|                if (dict && dictSize > 1 GB) {
  ------------------
  |  |  242|  5.26k|#  define GB *(1<<30)
  ------------------
  |  Branch (2033:21): [True: 5.26k, False: 5.32k]
  |  Branch (2033:29): [True: 0, False: 5.26k]
  ------------------
 2034|       |                    /* the dictSize param is an int, avoid truncation / sign issues */
 2035|      0|                    dict += dictSize - 64 KB;
  ------------------
  |  |  240|      0|#  define KB *(1<<10)
  ------------------
 2036|      0|                    dictSize = 64 KB;
  ------------------
  |  |  240|      0|#  define KB *(1<<10)
  ------------------
 2037|      0|                }
 2038|  10.5k|                decodedSize = LZ4_decompress_safe_usingDict(
 2039|  10.5k|                        (const char*)selectedIn, (char*)dctx->tmpOut,
 2040|  10.5k|                        (int)dctx->tmpInTarget, (int)dctx->maxBlockSize,
 2041|  10.5k|                        dict, (int)dictSize);
 2042|  10.5k|                RETURN_ERROR_IF(decodedSize < 0, decompressionFailed);
  ------------------
  |  |  322|  10.5k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  323|  10.5k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (323:13): [True: 0, False: 10.5k]
  |  |  ------------------
  |  |  324|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  163|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  325|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  320|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  326|      0|        }                          \
  |  |  327|  10.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (327:14): [Folded, False: 10.5k]
  |  |  ------------------
  ------------------
 2043|  10.5k|                if (dctx->frameInfo.contentChecksumFlag && !dctx->skipContentChecksum)
  ------------------
  |  Branch (2043:21): [True: 4.97k, False: 5.61k]
  |  Branch (2043:60): [True: 4.49k, False: 476]
  ------------------
 2044|  4.49k|                    XXH32_update(&(dctx->xxh), dctx->tmpOut, (size_t)decodedSize);
  ------------------
  |  |  132|  4.49k|#  define XXH32_update XXH_NAME2(XXH_NAMESPACE, XXH32_update)
  |  |  ------------------
  |  |  |  |  126|  4.49k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  4.49k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2045|  10.5k|                if (dctx->frameInfo.contentSize)
  ------------------
  |  Branch (2045:21): [True: 0, False: 10.5k]
  ------------------
 2046|      0|                    dctx->frameRemainingSize -= (size_t)decodedSize;
 2047|  10.5k|                dctx->tmpOutSize = (size_t)decodedSize;
 2048|  10.5k|                dctx->tmpOutStart = 0;
 2049|  10.5k|                dctx->dStage = dstage_flushOut;
 2050|  10.5k|            }
 2051|       |            /* fall-through */
 2052|       |
 2053|  10.5k|        case dstage_flushOut:  /* flush decoded data from tmpOut to dstBuffer */
  ------------------
  |  Branch (2053:9): [True: 0, False: 86.9k]
  ------------------
 2054|  10.5k|            DEBUGLOG(6, "dstage_flushOut");
  ------------------
  |  |  163|  10.5k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 2055|  10.5k|            if (dstPtr != NULL) {
  ------------------
  |  Branch (2055:17): [True: 10.5k, False: 0]
  ------------------
 2056|  10.5k|                size_t const sizeToCopy = MIN(dctx->tmpOutSize - dctx->tmpOutStart, (size_t)(dstEnd-dstPtr));
  ------------------
  |  |  349|  10.5k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (349:22): [True: 4.37k, False: 6.21k]
  |  |  ------------------
  ------------------
 2057|  10.5k|                memcpy(dstPtr, dctx->tmpOut + dctx->tmpOutStart, sizeToCopy);
 2058|       |
 2059|       |                /* dictionary management */
 2060|  10.5k|                if (dctx->frameInfo.blockMode == LZ4F_blockLinked)
  ------------------
  |  Branch (2060:21): [True: 8.43k, False: 2.16k]
  ------------------
 2061|  8.43k|                    LZ4F_updateDict(dctx, dstPtr, sizeToCopy, dstStart, 1 /*withinTmp*/);
 2062|       |
 2063|  10.5k|                dctx->tmpOutStart += sizeToCopy;
 2064|  10.5k|                dstPtr += sizeToCopy;
 2065|  10.5k|            }
 2066|  10.5k|            if (dctx->tmpOutStart == dctx->tmpOutSize) { /* all flushed */
  ------------------
  |  Branch (2066:17): [True: 10.5k, False: 0]
  ------------------
 2067|  10.5k|                dctx->dStage = dstage_getBlockHeader;  /* get next block */
 2068|  10.5k|                break;
 2069|  10.5k|            }
 2070|       |            /* could not flush everything : stop there, just request a block header */
 2071|      0|            doAnotherStage = 0;
 2072|      0|            nextSrcSizeHint = BHSize;
 2073|      0|            break;
 2074|       |
 2075|  14.3k|        case dstage_getSuffix:
  ------------------
  |  Branch (2075:9): [True: 14.3k, False: 72.6k]
  ------------------
 2076|  14.3k|            RETURN_ERROR_IF(dctx->frameRemainingSize, frameSize_wrong);   /* incorrect frame size decoded */
  ------------------
  |  |  322|  14.3k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  323|  14.3k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (323:13): [True: 0, False: 14.3k]
  |  |  ------------------
  |  |  324|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  163|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  325|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  320|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  326|      0|        }                          \
  |  |  327|  14.3k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (327:14): [Folded, False: 14.3k]
  |  |  ------------------
  ------------------
 2077|  14.3k|            if (!dctx->frameInfo.contentChecksumFlag) {  /* no checksum, frame is completed */
  ------------------
  |  Branch (2077:17): [True: 7.65k, False: 6.65k]
  ------------------
 2078|  7.65k|                nextSrcSizeHint = 0;
 2079|  7.65k|                LZ4F_resetDecompressionContext(dctx);
 2080|  7.65k|                doAnotherStage = 0;
 2081|  7.65k|                break;
 2082|  7.65k|            }
 2083|  6.65k|            if ((srcEnd - srcPtr) < 4) {  /* not enough size for entire CRC */
  ------------------
  |  Branch (2083:17): [True: 0, False: 6.65k]
  ------------------
 2084|      0|                dctx->tmpInSize = 0;
 2085|      0|                dctx->dStage = dstage_storeSuffix;
 2086|  6.65k|            } else {
 2087|  6.65k|                selectedIn = srcPtr;
 2088|  6.65k|                srcPtr += 4;
 2089|  6.65k|            }
 2090|       |
 2091|  6.65k|            if (dctx->dStage == dstage_storeSuffix)   /* can be skipped */
  ------------------
  |  Branch (2091:17): [True: 0, False: 6.65k]
  ------------------
 2092|      0|        case dstage_storeSuffix:
  ------------------
  |  Branch (2092:9): [True: 0, False: 86.9k]
  ------------------
 2093|      0|            {   size_t const remainingInput = (size_t)(srcEnd - srcPtr);
 2094|      0|                size_t const wantedData = 4 - dctx->tmpInSize;
 2095|      0|                size_t const sizeToCopy = MIN(wantedData, remainingInput);
  ------------------
  |  |  349|      0|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (349:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2096|      0|                memcpy(dctx->tmpIn + dctx->tmpInSize, srcPtr, sizeToCopy);
 2097|      0|                srcPtr += sizeToCopy;
 2098|      0|                dctx->tmpInSize += sizeToCopy;
 2099|      0|                if (dctx->tmpInSize < 4) { /* not enough input to read complete suffix */
  ------------------
  |  Branch (2099:21): [True: 0, False: 0]
  ------------------
 2100|      0|                    nextSrcSizeHint = 4 - dctx->tmpInSize;
 2101|      0|                    doAnotherStage=0;
 2102|      0|                    break;
 2103|      0|                }
 2104|      0|                selectedIn = dctx->tmpIn;
 2105|      0|            }   /* if (dctx->dStage == dstage_storeSuffix) */
 2106|       |
 2107|       |        /* case dstage_checkSuffix: */   /* no direct entry, avoid initialization risks */
 2108|  6.65k|            if (!dctx->skipContentChecksum) {
  ------------------
  |  Branch (2108:17): [True: 5.87k, False: 780]
  ------------------
 2109|  5.87k|                U32 const readCRC = LZ4F_readLE32(selectedIn);
 2110|  5.87k|                U32 const resultCRC = XXH32_digest(&(dctx->xxh));
  ------------------
  |  |  133|  5.87k|#  define XXH32_digest XXH_NAME2(XXH_NAMESPACE, XXH32_digest)
  |  |  ------------------
  |  |  |  |  126|  5.87k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  5.87k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2111|  5.87k|                DEBUGLOG(4, "frame checksum: stored 0x%0X vs 0x%0X processed", readCRC, resultCRC);
  ------------------
  |  |  163|  5.87k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 2112|       |#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
 2113|       |                RETURN_ERROR_IF(readCRC != resultCRC, contentChecksum_invalid);
 2114|       |#else
 2115|  5.87k|                (void)readCRC;
 2116|  5.87k|                (void)resultCRC;
 2117|  5.87k|#endif
 2118|  5.87k|            }
 2119|  6.65k|            nextSrcSizeHint = 0;
 2120|  6.65k|            LZ4F_resetDecompressionContext(dctx);
 2121|  6.65k|            doAnotherStage = 0;
 2122|  6.65k|            break;
 2123|       |
 2124|      0|        case dstage_getSFrameSize:
  ------------------
  |  Branch (2124:9): [True: 0, False: 86.9k]
  ------------------
 2125|      0|            if ((srcEnd - srcPtr) >= 4) {
  ------------------
  |  Branch (2125:17): [True: 0, False: 0]
  ------------------
 2126|      0|                selectedIn = srcPtr;
 2127|      0|                srcPtr += 4;
 2128|      0|            } else {
 2129|       |                /* not enough input to read cBlockSize field */
 2130|      0|                dctx->tmpInSize = 4;
 2131|      0|                dctx->tmpInTarget = 8;
 2132|      0|                dctx->dStage = dstage_storeSFrameSize;
 2133|      0|            }
 2134|       |
 2135|      0|            if (dctx->dStage == dstage_storeSFrameSize)
  ------------------
  |  Branch (2135:17): [True: 0, False: 0]
  ------------------
 2136|      0|        case dstage_storeSFrameSize:
  ------------------
  |  Branch (2136:9): [True: 0, False: 86.9k]
  ------------------
 2137|      0|            {   size_t const sizeToCopy = MIN(dctx->tmpInTarget - dctx->tmpInSize,
  ------------------
  |  |  349|      0|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (349:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2138|      0|                                             (size_t)(srcEnd - srcPtr) );
 2139|      0|                memcpy(dctx->header + dctx->tmpInSize, srcPtr, sizeToCopy);
 2140|      0|                srcPtr += sizeToCopy;
 2141|      0|                dctx->tmpInSize += sizeToCopy;
 2142|      0|                if (dctx->tmpInSize < dctx->tmpInTarget) {
  ------------------
  |  Branch (2142:21): [True: 0, False: 0]
  ------------------
 2143|       |                    /* not enough input to get full sBlockSize; wait for more */
 2144|      0|                    nextSrcSizeHint = dctx->tmpInTarget - dctx->tmpInSize;
 2145|      0|                    doAnotherStage = 0;
 2146|      0|                    break;
 2147|      0|                }
 2148|      0|                selectedIn = dctx->header + 4;
 2149|      0|            }   /* if (dctx->dStage == dstage_storeSFrameSize) */
 2150|       |
 2151|       |        /* case dstage_decodeSFrameSize: */   /* no direct entry */
 2152|      0|            {   size_t const SFrameSize = LZ4F_readLE32(selectedIn);
 2153|      0|                dctx->frameInfo.contentSize = SFrameSize;
 2154|      0|                dctx->tmpInTarget = SFrameSize;
 2155|      0|                dctx->dStage = dstage_skipSkippable;
 2156|      0|                break;
 2157|      0|            }
 2158|       |
 2159|      0|        case dstage_skipSkippable:
  ------------------
  |  Branch (2159:9): [True: 0, False: 86.9k]
  ------------------
 2160|      0|            {   size_t const skipSize = MIN(dctx->tmpInTarget, (size_t)(srcEnd-srcPtr));
  ------------------
  |  |  349|      0|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (349:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2161|      0|                srcPtr += skipSize;
 2162|      0|                dctx->tmpInTarget -= skipSize;
 2163|      0|                doAnotherStage = 0;
 2164|      0|                nextSrcSizeHint = dctx->tmpInTarget;
 2165|      0|                if (nextSrcSizeHint) break;  /* still more to skip */
  ------------------
  |  Branch (2165:21): [True: 0, False: 0]
  ------------------
 2166|       |                /* frame fully skipped : prepare context for a new frame */
 2167|      0|                LZ4F_resetDecompressionContext(dctx);
 2168|      0|                break;
 2169|      0|            }
 2170|  86.9k|        }   /* switch (dctx->dStage) */
 2171|  86.9k|    }   /* while (doAnotherStage) */
 2172|       |
 2173|       |    /* preserve history within tmpOut whenever necessary */
 2174|  14.3k|    LZ4F_STATIC_ASSERT((unsigned)dstage_init == 2);
  ------------------
  |  |  151|  14.3k|#define LZ4F_STATIC_ASSERT(c)    { enum { LZ4F_static_assert = 1/(int)(!!(c)) }; }   /* use only *after* variable declarations */
  ------------------
 2175|  14.3k|    if ( (dctx->frameInfo.blockMode==LZ4F_blockLinked)  /* next block will use up to 64KB from previous ones */
  ------------------
  |  Branch (2175:10): [True: 11.0k, False: 3.21k]
  ------------------
 2176|  11.0k|      && (dctx->dict != dctx->tmpOutBuffer)             /* dictionary is not already within tmp */
  ------------------
  |  Branch (2176:10): [True: 11.0k, False: 0]
  ------------------
 2177|  11.0k|      && (dctx->dict != NULL)                           /* dictionary exists */
  ------------------
  |  Branch (2177:10): [True: 0, False: 11.0k]
  ------------------
 2178|      0|      && (!decompressOptionsPtr->stableDst)             /* cannot rely on dst data to remain there for next call */
  ------------------
  |  Branch (2178:10): [True: 0, False: 0]
  ------------------
 2179|      0|      && ((unsigned)(dctx->dStage)-2 < (unsigned)(dstage_getSuffix)-2) )  /* valid stages : [init ... getSuffix[ */
  ------------------
  |  Branch (2179:10): [True: 0, False: 0]
  ------------------
 2180|      0|    {
 2181|      0|        if (dctx->dStage == dstage_flushOut) {
  ------------------
  |  Branch (2181:13): [True: 0, False: 0]
  ------------------
 2182|      0|            size_t const preserveSize = (size_t)(dctx->tmpOut - dctx->tmpOutBuffer);
 2183|      0|            size_t copySize = 64 KB - dctx->tmpOutSize;
  ------------------
  |  |  240|      0|#  define KB *(1<<10)
  ------------------
 2184|      0|            const BYTE* oldDictEnd = dctx->dict + dctx->dictSize - dctx->tmpOutStart;
 2185|      0|            if (dctx->tmpOutSize > 64 KB) copySize = 0;
  ------------------
  |  |  240|      0|#  define KB *(1<<10)
  ------------------
  |  Branch (2185:17): [True: 0, False: 0]
  ------------------
 2186|      0|            if (copySize > preserveSize) copySize = preserveSize;
  ------------------
  |  Branch (2186:17): [True: 0, False: 0]
  ------------------
 2187|      0|            assert(dctx->tmpOutBuffer != NULL);
  ------------------
  |  Branch (2187:13): [True: 0, False: 0]
  |  Branch (2187:13): [True: 0, False: 0]
  ------------------
 2188|       |
 2189|      0|            memcpy(dctx->tmpOutBuffer + preserveSize - copySize, oldDictEnd - copySize, copySize);
 2190|       |
 2191|      0|            dctx->dict = dctx->tmpOutBuffer;
 2192|      0|            dctx->dictSize = preserveSize + dctx->tmpOutStart;
 2193|      0|        } else {
 2194|      0|            const BYTE* const oldDictEnd = dctx->dict + dctx->dictSize;
 2195|      0|            size_t const newDictSize = MIN(dctx->dictSize, 64 KB);
  ------------------
  |  |  349|      0|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (349:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2196|       |
 2197|      0|            memcpy(dctx->tmpOutBuffer, oldDictEnd - newDictSize, newDictSize);
 2198|       |
 2199|      0|            dctx->dict = dctx->tmpOutBuffer;
 2200|      0|            dctx->dictSize = newDictSize;
 2201|      0|            dctx->tmpOut = dctx->tmpOutBuffer + newDictSize;
 2202|      0|        }
 2203|      0|    }
 2204|       |
 2205|  14.3k|    *srcSizePtr = (size_t)(srcPtr - srcStart);
 2206|  14.3k|    *dstSizePtr = (size_t)(dstPtr - dstStart);
 2207|  14.3k|    return nextSrcSizeHint;
 2208|  14.3k|}
lz4frame.c:LZ4F_returnErrorCode:
  314|  69.5k|{
  315|       |    /* A compilation error here means sizeof(ptrdiff_t) is not large enough */
  316|  69.5k|    LZ4F_STATIC_ASSERT(sizeof(ptrdiff_t) >= sizeof(size_t));
  ------------------
  |  |  151|  69.5k|#define LZ4F_STATIC_ASSERT(c)    { enum { LZ4F_static_assert = 1/(int)(!!(c)) }; }   /* use only *after* variable declarations */
  ------------------
  317|  69.5k|    return (LZ4F_errorCode_t)-(ptrdiff_t)code;
  318|  69.5k|}
lz4frame.c:LZ4F_compressBound_internal:
  384|   148k|{
  385|   148k|    LZ4F_preferences_t prefsNull = LZ4F_INIT_PREFERENCES;
  ------------------
  |  |  201|   148k|#define LZ4F_INIT_PREFERENCES   { LZ4F_INIT_FRAMEINFO, 0, 0u, 0u, { 0u, 0u, 0u } }    /* v1.8.3+ */
  |  |  ------------------
  |  |  |  |  186|   148k|#define LZ4F_INIT_FRAMEINFO   { LZ4F_max64KB, LZ4F_blockLinked, LZ4F_noContentChecksum, LZ4F_frame, 0ULL, 0U, LZ4F_noBlockChecksum }    /* v1.8.3+ */
  |  |  ------------------
  ------------------
  386|   148k|    prefsNull.frameInfo.contentChecksumFlag = LZ4F_contentChecksumEnabled;   /* worst case */
  387|   148k|    prefsNull.frameInfo.blockChecksumFlag = LZ4F_blockChecksumEnabled;   /* worst case */
  388|   148k|    {   const LZ4F_preferences_t* const prefsPtr = (preferencesPtr==NULL) ? &prefsNull : preferencesPtr;
  ------------------
  |  Branch (388:52): [True: 0, False: 148k]
  ------------------
  389|   148k|        U32 const flush = prefsPtr->autoFlush | (srcSize==0);
  390|   148k|        LZ4F_blockSizeID_t const blockID = prefsPtr->frameInfo.blockSizeID;
  391|   148k|        size_t const blockSize = LZ4F_getBlockSize(blockID);
  392|   148k|        size_t const maxBuffered = blockSize - 1;
  393|   148k|        size_t const bufferedSize = MIN(alreadyBuffered, maxBuffered);
  ------------------
  |  |  349|   148k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (349:22): [True: 113k, False: 34.8k]
  |  |  ------------------
  ------------------
  394|   148k|        size_t const maxSrcSize = srcSize + bufferedSize;
  395|   148k|        unsigned const nbFullBlocks = (unsigned)(maxSrcSize / blockSize);
  396|   148k|        size_t const partialBlockSize = maxSrcSize & (blockSize-1);
  397|   148k|        size_t const lastBlockSize = flush ? partialBlockSize : 0;
  ------------------
  |  Branch (397:38): [True: 113k, False: 34.8k]
  ------------------
  398|   148k|        unsigned const nbBlocks = nbFullBlocks + (lastBlockSize>0);
  399|       |
  400|   148k|        size_t const blockCRCSize = BFSize * prefsPtr->frameInfo.blockChecksumFlag;
  401|   148k|        size_t const frameEnd = BHSize + (prefsPtr->frameInfo.contentChecksumFlag*BFSize);
  402|       |
  403|   148k|        return ((BHSize + blockCRCSize) * nbBlocks) +
  404|   148k|               (blockSize * nbFullBlocks) + lastBlockSize + frameEnd;
  405|   148k|    }
  406|   148k|}
lz4frame.c:LZ4F_free:
  128|   538k|{
  129|   538k|    if (p == NULL) return;
  ------------------
  |  Branch (129:9): [True: 244k, False: 294k]
  ------------------
  130|   294k|    if (cmem.customFree != NULL) {
  ------------------
  |  Branch (130:9): [True: 0, False: 294k]
  ------------------
  131|       |        /* custom allocation defined : use it */
  132|      0|        cmem.customFree(cmem.opaqueState, p);
  133|      0|        return;
  134|      0|    }
  135|       |    /* nothing defined : use default <stdlib.h>'s free() */
  136|   294k|    FREEMEM(p);
  ------------------
  |  |   98|   294k|#  define FREEMEM(p)        free(p)
  ------------------
  137|   294k|}
lz4frame.c:LZ4F_malloc:
  118|   171k|{
  119|       |    /* custom malloc defined : use it */
  120|   171k|    if (cmem.customAlloc != NULL) {
  ------------------
  |  Branch (120:9): [True: 0, False: 171k]
  ------------------
  121|      0|        return cmem.customAlloc(cmem.opaqueState, s);
  122|      0|    }
  123|       |    /* nothing defined : use default <stdlib.h>'s malloc() */
  124|   171k|    return ALLOC(s);
  ------------------
  |  |   96|   171k|#  define ALLOC(s)          malloc(s)
  ------------------
  125|   171k|}
lz4frame.c:LZ4F_calloc:
  102|   122k|{
  103|       |    /* custom calloc defined : use it */
  104|   122k|    if (cmem.customCalloc != NULL) {
  ------------------
  |  Branch (104:9): [True: 0, False: 122k]
  ------------------
  105|      0|        return cmem.customCalloc(cmem.opaqueState, s);
  106|      0|    }
  107|       |    /* nothing defined : use default <stdlib.h>'s calloc() */
  108|   122k|    if (cmem.customAlloc == NULL) {
  ------------------
  |  Branch (108:9): [True: 122k, False: 0]
  ------------------
  109|   122k|        return ALLOC_AND_ZERO(s);
  ------------------
  |  |   97|   122k|#  define ALLOC_AND_ZERO(s) calloc(1,(s))
  ------------------
  110|   122k|    }
  111|       |    /* only custom alloc defined : use it, and combine it with memset() */
  112|      0|    {   void* const p = cmem.customAlloc(cmem.opaqueState, s);
  113|      0|        if (p != NULL) MEM_INIT(p, 0, s);
  ------------------
  |  |   91|      0|#  define MEM_INIT(p,v,s)   memset((p),(v),(s))
  ------------------
  |  Branch (113:13): [True: 0, False: 0]
  ------------------
  114|      0|        return p;
  115|   122k|}   }
lz4frame.c:LZ4F_sizeofLZ4State:
  696|   163k|{
  697|   163k|    switch (ctxType) {
  ------------------
  |  Branch (697:13): [True: 163k, False: 0]
  ------------------
  698|  77.9k|    case ctxNone: return 0;
  ------------------
  |  Branch (698:5): [True: 77.9k, False: 85.2k]
  ------------------
  699|  32.2k|    case ctxFast: return sizeof(LZ4_stream_t);
  ------------------
  |  Branch (699:5): [True: 32.2k, False: 130k]
  ------------------
  700|  53.0k|    case ctxHC:   return sizeof(LZ4_streamHC_t);
  ------------------
  |  Branch (700:5): [True: 53.0k, False: 110k]
  ------------------
  701|   163k|    }
  702|   163k|    assert(0);   /* invalid ctxType */
  ------------------
  |  Branch (702:5): [Folded, False: 0]
  |  Branch (702:5): [Folded, False: 0]
  ------------------
  703|      0|    return 0;
  704|      0|}
lz4frame.c:LZ4F_compressBegin_internal:
  721|  98.2k|{
  722|  98.2k|    LZ4F_preferences_t const prefNull = LZ4F_INIT_PREFERENCES;
  ------------------
  |  |  201|  98.2k|#define LZ4F_INIT_PREFERENCES   { LZ4F_INIT_FRAMEINFO, 0, 0u, 0u, { 0u, 0u, 0u } }    /* v1.8.3+ */
  |  |  ------------------
  |  |  |  |  186|  98.2k|#define LZ4F_INIT_FRAMEINFO   { LZ4F_max64KB, LZ4F_blockLinked, LZ4F_noContentChecksum, LZ4F_frame, 0ULL, 0U, LZ4F_noBlockChecksum }    /* v1.8.3+ */
  |  |  ------------------
  ------------------
  723|  98.2k|    BYTE* const dstStart = (BYTE*)dstBuffer;
  724|  98.2k|    BYTE* dstPtr = dstStart;
  725|       |
  726|  98.2k|    if (preferencesPtr == NULL) preferencesPtr = &prefNull;
  ------------------
  |  Branch (726:9): [True: 0, False: 98.2k]
  ------------------
  727|       |    /* validate before modifying @cctx */
  728|  98.2k|    {   size_t const headerSize = minFHSize
  729|  98.2k|                                + (preferencesPtr->frameInfo.contentSize ? 8 : 0)
  ------------------
  |  Branch (729:36): [True: 0, False: 98.2k]
  ------------------
  730|  98.2k|                                + (preferencesPtr->frameInfo.dictID ? 4 : 0);
  ------------------
  |  Branch (730:36): [True: 0, False: 98.2k]
  ------------------
  731|  98.2k|        RETURN_ERROR_IF(dstCapacity < headerSize, dstCapacity_tooSmall);
  ------------------
  |  |  322|  98.2k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  323|  98.2k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (323:13): [True: 16.6k, False: 81.6k]
  |  |  ------------------
  |  |  324|  16.6k|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  163|  16.6k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  325|  16.6k|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  320|  16.6k|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  326|  16.6k|        }                          \
  |  |  327|  98.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (327:14): [Folded, False: 81.6k]
  |  |  ------------------
  ------------------
  732|  98.2k|    }
  733|  81.6k|    FORWARD_IF_ERROR( LZ4F_getBlockSize(preferencesPtr->frameInfo.blockSizeID) );
  ------------------
  |  |  329|  81.6k|#define FORWARD_IF_ERROR(r) do { if (LZ4F_isError(r)) return (r); } while (0)
  |  |  ------------------
  |  |  |  Branch (329:38): [True: 0, False: 81.6k]
  |  |  |  Branch (329:76): [Folded, False: 81.6k]
  |  |  ------------------
  ------------------
  734|  81.6k|    cctx->prefs = *preferencesPtr;
  735|  81.6k|    DEBUGLOG(5, "LZ4F_compressBegin_internal: Independent_blocks=%u", cctx->prefs.frameInfo.blockMode);
  ------------------
  |  |  163|  81.6k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
  736|       |
  737|       |    /* cctx Management */
  738|  81.6k|    {   LZ4F_CtxType_e const ctxType = (cctx->prefs.compressionLevel < LZ4HC_CLEVEL_MIN) ? ctxFast : ctxHC;
  ------------------
  |  |   47|  81.6k|#define LZ4HC_CLEVEL_MIN         2
  ------------------
  |  Branch (738:40): [True: 31.1k, False: 50.4k]
  ------------------
  739|  81.6k|        size_t const requiredSize = LZ4F_sizeofLZ4State(ctxType);
  740|  81.6k|        size_t const allocatedSize = LZ4F_sizeofLZ4State((LZ4F_CtxType_e)cctx->lz4CtxAlloc);
  741|  81.6k|        if (allocatedSize < requiredSize) {
  ------------------
  |  Branch (741:13): [True: 77.9k, False: 3.64k]
  ------------------
  742|       |            /* not enough space allocated */
  743|  77.9k|            LZ4F_free(cctx->lz4CtxPtr, cctx->cmem);
  744|  77.9k|            if (cctx->prefs.compressionLevel < LZ4HC_CLEVEL_MIN) {
  ------------------
  |  |   47|  77.9k|#define LZ4HC_CLEVEL_MIN         2
  ------------------
  |  Branch (744:17): [True: 30.1k, False: 47.8k]
  ------------------
  745|       |                /* must take ownership of memory allocation,
  746|       |                 * in order to respect custom allocator contract */
  747|  30.1k|                cctx->lz4CtxPtr = LZ4F_malloc(sizeof(LZ4_stream_t), cctx->cmem);
  748|  30.1k|                if (cctx->lz4CtxPtr)
  ------------------
  |  Branch (748:21): [True: 30.1k, False: 0]
  ------------------
  749|  30.1k|                    LZ4_initStream(cctx->lz4CtxPtr, sizeof(LZ4_stream_t));
  750|  47.8k|            } else {
  751|  47.8k|                cctx->lz4CtxPtr = LZ4F_malloc(sizeof(LZ4_streamHC_t), cctx->cmem);
  752|  47.8k|                if (cctx->lz4CtxPtr)
  ------------------
  |  Branch (752:21): [True: 47.8k, False: 0]
  ------------------
  753|  47.8k|                    LZ4_initStreamHC(cctx->lz4CtxPtr, sizeof(LZ4_streamHC_t));
  754|  47.8k|            }
  755|  77.9k|            RETURN_ERROR_IF(cctx->lz4CtxPtr == NULL, allocation_failed);
  ------------------
  |  |  322|  77.9k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  323|  77.9k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (323:13): [True: 0, False: 77.9k]
  |  |  ------------------
  |  |  324|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  163|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  325|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  320|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  326|      0|        }                          \
  |  |  327|  77.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (327:14): [Folded, False: 77.9k]
  |  |  ------------------
  ------------------
  756|  77.9k|            cctx->lz4CtxAlloc = (U16)ctxType;
  757|  77.9k|            cctx->lz4CtxType = (U16)ctxType;
  758|  77.9k|        } else if (cctx->lz4CtxType != ctxType) {
  ------------------
  |  Branch (758:20): [True: 0, False: 3.64k]
  ------------------
  759|       |            /* otherwise, a sufficient buffer is already allocated,
  760|       |             * but we need to reset it to the correct context type */
  761|      0|            if (cctx->prefs.compressionLevel < LZ4HC_CLEVEL_MIN) {
  ------------------
  |  |   47|      0|#define LZ4HC_CLEVEL_MIN         2
  ------------------
  |  Branch (761:17): [True: 0, False: 0]
  ------------------
  762|      0|                LZ4_initStream((LZ4_stream_t*)cctx->lz4CtxPtr, sizeof(LZ4_stream_t));
  763|      0|            } else {
  764|      0|                LZ4_initStreamHC((LZ4_streamHC_t*)cctx->lz4CtxPtr, sizeof(LZ4_streamHC_t));
  765|      0|                LZ4_setCompressionLevel((LZ4_streamHC_t*)cctx->lz4CtxPtr, cctx->prefs.compressionLevel);
  766|      0|            }
  767|      0|            cctx->lz4CtxType = (U16)ctxType;
  768|      0|    }   }
  769|       |
  770|       |    /* Buffer Management */
  771|  81.6k|    if (cctx->prefs.frameInfo.blockSizeID == 0)
  ------------------
  |  Branch (771:9): [True: 21.0k, False: 60.5k]
  ------------------
  772|  21.0k|        cctx->prefs.frameInfo.blockSizeID = LZ4F_BLOCKSIZEID_DEFAULT;
  ------------------
  |  |  252|  21.0k|#define LZ4F_BLOCKSIZEID_DEFAULT LZ4F_max64KB
  ------------------
  773|  81.6k|    cctx->maxBlockSize = LZ4F_getBlockSize(cctx->prefs.frameInfo.blockSizeID);
  774|       |
  775|  81.6k|    {   size_t const requiredBuffSize = preferencesPtr->autoFlush ?
  ------------------
  |  Branch (775:41): [True: 65.9k, False: 15.6k]
  ------------------
  776|  65.9k|                ((cctx->prefs.frameInfo.blockMode == LZ4F_blockLinked) ? 64 KB : 0) :  /* only needs past data up to window size */
  ------------------
  |  |  240|  53.1k|#  define KB *(1<<10)
  ------------------
  |  Branch (776:18): [True: 53.1k, False: 12.8k]
  ------------------
  777|  81.6k|                cctx->maxBlockSize + ((cctx->prefs.frameInfo.blockMode == LZ4F_blockLinked) ? 128 KB : 0);
  ------------------
  |  |  240|  9.12k|#  define KB *(1<<10)
  ------------------
  |  Branch (777:39): [True: 9.12k, False: 6.54k]
  ------------------
  778|       |
  779|  81.6k|        if (cctx->tmpBuffCapacity < requiredBuffSize) {
  ------------------
  |  Branch (779:13): [True: 65.4k, False: 16.2k]
  ------------------
  780|  65.4k|            cctx->tmpBuffCapacity = 0;
  781|  65.4k|            LZ4F_free(cctx->tmpBuff, cctx->cmem);
  782|  65.4k|            cctx->tmpBuff = (BYTE*)LZ4F_malloc(requiredBuffSize, cctx->cmem);
  783|  65.4k|            RETURN_ERROR_IF(cctx->tmpBuff == NULL, allocation_failed);
  ------------------
  |  |  322|  65.4k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  323|  65.4k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (323:13): [True: 0, False: 65.4k]
  |  |  ------------------
  |  |  324|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  163|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  325|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  320|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  326|      0|        }                          \
  |  |  327|  65.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (327:14): [Folded, False: 65.4k]
  |  |  ------------------
  ------------------
  784|  65.4k|            cctx->tmpBuffCapacity = requiredBuffSize;
  785|  65.4k|    }   }
  786|  81.6k|    cctx->tmpIn = cctx->tmpBuff;
  787|  81.6k|    cctx->tmpInSize = 0;
  788|  81.6k|    (void)XXH32_reset(&(cctx->xxh), 0);
  ------------------
  |  |  131|  81.6k|#  define XXH32_reset XXH_NAME2(XXH_NAMESPACE, XXH32_reset)
  |  |  ------------------
  |  |  |  |  126|  81.6k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  81.6k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  789|       |
  790|       |    /* context init */
  791|  81.6k|    cctx->cdict = cdict;
  792|  81.6k|    if (cctx->prefs.frameInfo.blockMode == LZ4F_blockLinked) {
  ------------------
  |  Branch (792:9): [True: 62.2k, False: 19.3k]
  ------------------
  793|       |        /* frame init only for blockLinked : blockIndependent will be init at each block */
  794|  62.2k|        LZ4F_initStream(cctx->lz4CtxPtr, cdict, cctx->prefs.compressionLevel, LZ4F_blockLinked);
  795|  62.2k|    }
  796|  81.6k|    if (preferencesPtr->compressionLevel >= LZ4HC_CLEVEL_MIN) {
  ------------------
  |  |   47|  81.6k|#define LZ4HC_CLEVEL_MIN         2
  ------------------
  |  Branch (796:9): [True: 50.4k, False: 31.1k]
  ------------------
  797|  50.4k|        LZ4_favorDecompressionSpeed((LZ4_streamHC_t*)cctx->lz4CtxPtr, (int)preferencesPtr->favorDecSpeed);
  798|  50.4k|    }
  799|  81.6k|    if (dictBuffer) {
  ------------------
  |  Branch (799:9): [True: 0, False: 81.6k]
  ------------------
  800|      0|        assert(cdict == NULL);
  ------------------
  |  Branch (800:9): [True: 0, False: 0]
  |  Branch (800:9): [True: 0, False: 0]
  ------------------
  801|      0|        RETURN_ERROR_IF(dictSize > INT_MAX, parameter_invalid);
  ------------------
  |  |  322|      0|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  323|      0|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (323:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  324|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  163|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  325|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  320|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  326|      0|        }                          \
  |  |  327|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (327:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  802|      0|        if (cctx->lz4CtxType == ctxFast) {
  ------------------
  |  Branch (802:13): [True: 0, False: 0]
  ------------------
  803|       |            /* lz4 fast*/
  804|      0|            LZ4_loadDict((LZ4_stream_t*)cctx->lz4CtxPtr, (const char*)dictBuffer, (int)dictSize);
  805|      0|        } else {
  806|       |            /* lz4hc */
  807|      0|            assert(cctx->lz4CtxType == ctxHC);
  ------------------
  |  Branch (807:13): [True: 0, False: 0]
  |  Branch (807:13): [True: 0, False: 0]
  ------------------
  808|      0|            LZ4_loadDictHC((LZ4_streamHC_t*)cctx->lz4CtxPtr, (const char*)dictBuffer, (int)dictSize);
  809|      0|        }
  810|      0|    }
  811|       |
  812|       |    /* Stage 2 : Write Frame Header */
  813|       |
  814|       |    /* Magic Number */
  815|  81.6k|    LZ4F_writeLE32(dstPtr, LZ4F_MAGICNUMBER);
  ------------------
  |  |  417|  81.6k|#define LZ4F_MAGICNUMBER 0x184D2204U
  ------------------
  816|  81.6k|    dstPtr += 4;
  817|  81.6k|    {   BYTE* const headerStart = dstPtr;
  818|       |
  819|       |        /* FLG Byte */
  820|  81.6k|        *dstPtr++ = (BYTE)(((1 & _2BITS) << 6)    /* Version('01') */
  ------------------
  |  |  246|  81.6k|#define _2BITS 0x03
  ------------------
  821|  81.6k|            + ((cctx->prefs.frameInfo.blockMode & _1BIT ) << 5)
  ------------------
  |  |  245|  81.6k|#define _1BIT  0x01
  ------------------
  822|  81.6k|            + ((cctx->prefs.frameInfo.blockChecksumFlag & _1BIT ) << 4)
  ------------------
  |  |  245|  81.6k|#define _1BIT  0x01
  ------------------
  823|  81.6k|            + ((unsigned)(cctx->prefs.frameInfo.contentSize > 0) << 3)
  824|  81.6k|            + ((cctx->prefs.frameInfo.contentChecksumFlag & _1BIT ) << 2)
  ------------------
  |  |  245|  81.6k|#define _1BIT  0x01
  ------------------
  825|  81.6k|            +  (cctx->prefs.frameInfo.dictID > 0) );
  826|       |        /* BD Byte */
  827|  81.6k|        *dstPtr++ = (BYTE)((cctx->prefs.frameInfo.blockSizeID & _3BITS) << 4);
  ------------------
  |  |  247|  81.6k|#define _3BITS 0x07
  ------------------
  828|       |        /* Optional Frame content size field */
  829|  81.6k|        if (cctx->prefs.frameInfo.contentSize) {
  ------------------
  |  Branch (829:13): [True: 0, False: 81.6k]
  ------------------
  830|      0|            LZ4F_writeLE64(dstPtr, cctx->prefs.frameInfo.contentSize);
  831|      0|            dstPtr += 8;
  832|      0|            cctx->totalInSize = 0;
  833|      0|        }
  834|       |        /* Optional dictionary ID field */
  835|  81.6k|        if (cctx->prefs.frameInfo.dictID) {
  ------------------
  |  Branch (835:13): [True: 0, False: 81.6k]
  ------------------
  836|      0|            LZ4F_writeLE32(dstPtr, cctx->prefs.frameInfo.dictID);
  837|      0|            dstPtr += 4;
  838|      0|        }
  839|       |        /* Header CRC Byte */
  840|  81.6k|        *dstPtr = LZ4F_headerChecksum(headerStart, (size_t)(dstPtr - headerStart));
  841|  81.6k|        dstPtr++;
  842|  81.6k|    }
  843|       |
  844|  81.6k|    cctx->cStage = 1;   /* header written, now request input data block */
  845|  81.6k|    return (size_t)(dstPtr - dstStart);
  846|  81.6k|}
lz4frame.c:LZ4F_initStream:
  660|  80.7k|                            LZ4F_blockMode_t blockMode) {
  661|  80.7k|    if (level < LZ4HC_CLEVEL_MIN) {
  ------------------
  |  |   47|  80.7k|#define LZ4HC_CLEVEL_MIN         2
  ------------------
  |  Branch (661:9): [True: 30.9k, False: 49.8k]
  ------------------
  662|       |        /* In these cases, we will call LZ4_compress_fast_continue(),
  663|       |         * which needs an already reset context. Otherwise, we'll call a
  664|       |         * one-shot API. The non-continued APIs internally perform their own
  665|       |         * resets at the beginning of their calls, where they know what
  666|       |         * tableType they need the context to be in. So in that case this
  667|       |         * would be misguided / wasted work. */
  668|  30.9k|        if (cdict) {
  ------------------
  |  Branch (668:13): [True: 0, False: 30.9k]
  ------------------
  669|      0|            LZ4_resetStream_fast((LZ4_stream_t*)ctx);
  670|      0|            LZ4_attach_dictionary((LZ4_stream_t*)ctx, cdict->fastCtx);
  671|  30.9k|        } else if (blockMode == LZ4F_blockLinked) {
  ------------------
  |  Branch (671:20): [True: 21.2k, False: 9.63k]
  ------------------
  672|       |            /* Clear the table, rather than LZ4_resetStream_fast() :
  673|       |             * output doesn't depend on the context's history,
  674|       |             * and it's faster, unless the frame is tiny. */
  675|  21.2k|            LZ4_initStream(ctx, sizeof(LZ4_stream_t));
  676|  21.2k|        }
  677|       |        /* In these cases, we'll call a one-shot API.
  678|       |         * The non-continued APIs internally perform their own resets
  679|       |         * at the beginning of their calls, where they know
  680|       |         * which tableType they need the context to be in.
  681|       |         * Therefore, a reset here would be wasted work. */
  682|  49.8k|    } else {
  683|  49.8k|        LZ4_resetStreamHC_fast((LZ4_streamHC_t*)ctx, level);
  684|  49.8k|        if (cdict)
  ------------------
  |  Branch (684:13): [True: 0, False: 49.8k]
  ------------------
  685|      0|            LZ4_attach_HC_dictionary((LZ4_streamHC_t*)ctx, cdict->HCCtx);
  686|  49.8k|    }
  687|  80.7k|}
lz4frame.c:LZ4F_headerChecksum:
  352|  81.6k|{
  353|  81.6k|    U32 const xxh = XXH32(header, length, 0);
  ------------------
  |  |  128|  81.6k|#  define XXH32 XXH_NAME2(XXH_NAMESPACE, XXH32)
  |  |  ------------------
  |  |  |  |  126|  81.6k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  81.6k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  354|  81.6k|    return (BYTE)(xxh >> 8);
  355|  81.6k|}
lz4frame.c:LZ4F_compressUpdateImpl:
 1054|   121k|  {
 1055|   121k|    size_t const blockSize = cctxPtr->maxBlockSize;
 1056|   121k|    const BYTE* srcPtr = (const BYTE*)srcBuffer;
 1057|   121k|    const BYTE* const srcEnd = srcSize ? (assert(srcPtr!=NULL), srcPtr + srcSize) : srcPtr;
  ------------------
  |  Branch (1057:32): [True: 117k, False: 4.14k]
  |  Branch (1057:43): [True: 0, False: 117k]
  |  Branch (1057:43): [True: 117k, False: 0]
  ------------------
 1058|   121k|    BYTE* const dstStart = (BYTE*)dstBuffer;
 1059|   121k|    BYTE* const dstEnd = dstStart + dstCapacity;
 1060|   121k|    BYTE* dstPtr = dstStart;
 1061|   121k|    LZ4F_lastBlockStatus lastBlockCompressed = notDone;
 1062|   121k|    compressFunc_t const compress = LZ4F_selectCompression(cctxPtr->prefs.frameInfo.blockMode, cctxPtr->prefs.compressionLevel, blockCompression);
 1063|   121k|    size_t bytesWritten;
 1064|   121k|    DEBUGLOG(4, "LZ4F_compressUpdate (srcSize=%zu)", srcSize);
  ------------------
  |  |  163|   121k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 1065|       |
 1066|   121k|    RETURN_ERROR_IF(cctxPtr->cStage != 1, compressionState_uninitialized);   /* state must be initialized and waiting for next block */
  ------------------
  |  |  322|   121k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  323|   121k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (323:13): [True: 0, False: 121k]
  |  |  ------------------
  |  |  324|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  163|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  325|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  320|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  326|      0|        }                          \
  |  |  327|   121k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (327:14): [Folded, False: 121k]
  |  |  ------------------
  ------------------
 1067|       |
 1068|       |    /* flush currently written block, to continue with new block compression */
 1069|   121k|    if (cctxPtr->blockCompressMode != blockCompression) {
  ------------------
  |  Branch (1069:9): [True: 2.13k, False: 119k]
  ------------------
 1070|  2.13k|        bytesWritten = LZ4F_flush(cctxPtr, dstBuffer, dstCapacity, compressOptionsPtr);
 1071|  2.13k|        FORWARD_IF_ERROR(bytesWritten);   /* note : a failed flush invalidates the frame */
  ------------------
  |  |  329|  2.13k|#define FORWARD_IF_ERROR(r) do { if (LZ4F_isError(r)) return (r); } while (0)
  |  |  ------------------
  |  |  |  Branch (329:38): [True: 63, False: 2.06k]
  |  |  |  Branch (329:76): [Folded, False: 2.06k]
  |  |  ------------------
  ------------------
 1072|  2.06k|        dstPtr += bytesWritten;
 1073|  2.06k|        cctxPtr->blockCompressMode = blockCompression;
 1074|  2.06k|    }
 1075|       |
 1076|   121k|    if (compressOptionsPtr == NULL) compressOptionsPtr = &k_cOptionsNull;
  ------------------
  |  Branch (1076:9): [True: 0, False: 121k]
  ------------------
 1077|       |
 1078|       |    /* complete tmp buffer */
 1079|   121k|    if (cctxPtr->tmpInSize > 0) {   /* some data already within tmp buffer */
  ------------------
  |  Branch (1079:9): [True: 17.9k, False: 103k]
  ------------------
 1080|  17.9k|        size_t const sizeToCopy = blockSize - cctxPtr->tmpInSize;
 1081|  17.9k|        assert(blockSize > cctxPtr->tmpInSize);
  ------------------
  |  Branch (1081:9): [True: 0, False: 17.9k]
  |  Branch (1081:9): [True: 17.9k, False: 0]
  ------------------
 1082|  17.9k|        if (sizeToCopy > srcSize) {
  ------------------
  |  Branch (1082:13): [True: 16.6k, False: 1.32k]
  ------------------
 1083|       |            /* add src to tmpIn buffer */
 1084|  16.6k|            memcpy(cctxPtr->tmpIn + cctxPtr->tmpInSize, srcBuffer, srcSize);
 1085|  16.6k|            srcPtr = srcEnd;
 1086|  16.6k|            cctxPtr->tmpInSize += srcSize;
 1087|       |            /* still needs some CRC */
 1088|  16.6k|        } else {
 1089|       |            /* complete tmpIn block and then compress it */
 1090|  1.32k|            lastBlockCompressed = fromTmpBuffer;
 1091|  1.32k|            memcpy(cctxPtr->tmpIn + cctxPtr->tmpInSize, srcBuffer, sizeToCopy);
 1092|  1.32k|            srcPtr += sizeToCopy;
 1093|       |
 1094|  1.32k|            bytesWritten = LZ4F_makeBlock(dstPtr, (size_t)(dstEnd - dstPtr),
 1095|  1.32k|                                          cctxPtr->tmpIn, blockSize,
 1096|  1.32k|                                          compress, cctxPtr->lz4CtxPtr, cctxPtr->prefs.compressionLevel,
 1097|  1.32k|                                          cctxPtr->cdict,
 1098|  1.32k|                                          cctxPtr->prefs.frameInfo.blockChecksumFlag);
 1099|  1.32k|            FORWARD_IF_ERROR_INVALIDATE(bytesWritten, cctxPtr);
  ------------------
  |  | 1028|  1.32k|#define FORWARD_IF_ERROR_INVALIDATE(r, cctx) do { \
  |  | 1029|  1.32k|        if (LZ4F_isError(r)) {                     \
  |  |  ------------------
  |  |  |  Branch (1029:13): [True: 66, False: 1.26k]
  |  |  ------------------
  |  | 1030|     66|            (cctx)->cStage = 0;                    \
  |  | 1031|     66|            return (r);                            \
  |  | 1032|     66|        }                                          \
  |  | 1033|  1.32k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (1033:14): [Folded, False: 1.26k]
  |  |  ------------------
  ------------------
 1100|  1.26k|            dstPtr += bytesWritten;
 1101|  1.26k|            if (cctxPtr->prefs.frameInfo.blockMode==LZ4F_blockLinked) cctxPtr->tmpIn += blockSize;
  ------------------
  |  Branch (1101:17): [True: 816, False: 444]
  ------------------
 1102|  1.26k|            cctxPtr->tmpInSize = 0;
 1103|  1.26k|    }   }
 1104|       |
 1105|   125k|    while ((size_t)(srcEnd - srcPtr) >= blockSize) {
  ------------------
  |  Branch (1105:12): [True: 3.96k, False: 121k]
  ------------------
 1106|       |        /* compress full blocks */
 1107|  3.96k|        lastBlockCompressed = fromSrcBuffer;
 1108|  3.96k|        bytesWritten = LZ4F_makeBlock(dstPtr, (size_t)(dstEnd - dstPtr),
 1109|  3.96k|                                      srcPtr, blockSize,
 1110|  3.96k|                                      compress, cctxPtr->lz4CtxPtr, cctxPtr->prefs.compressionLevel,
 1111|  3.96k|                                      cctxPtr->cdict,
 1112|  3.96k|                                      cctxPtr->prefs.frameInfo.blockChecksumFlag);
 1113|  3.96k|        FORWARD_IF_ERROR_INVALIDATE(bytesWritten, cctxPtr);
  ------------------
  |  | 1028|  3.96k|#define FORWARD_IF_ERROR_INVALIDATE(r, cctx) do { \
  |  | 1029|  3.96k|        if (LZ4F_isError(r)) {                     \
  |  |  ------------------
  |  |  |  Branch (1029:13): [True: 218, False: 3.74k]
  |  |  ------------------
  |  | 1030|    218|            (cctx)->cStage = 0;                    \
  |  | 1031|    218|            return (r);                            \
  |  | 1032|    218|        }                                          \
  |  | 1033|  3.96k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (1033:14): [Folded, False: 3.74k]
  |  |  ------------------
  ------------------
 1114|  3.74k|        dstPtr += bytesWritten;
 1115|  3.74k|        srcPtr += blockSize;
 1116|  3.74k|    }
 1117|       |
 1118|   121k|    if ((cctxPtr->prefs.autoFlush) && (srcPtr < srcEnd)) {
  ------------------
  |  Branch (1118:9): [True: 88.7k, False: 32.6k]
  |  Branch (1118:39): [True: 85.5k, False: 3.21k]
  ------------------
 1119|       |        /* autoFlush : remaining input (< blockSize) is compressed */
 1120|  85.5k|        lastBlockCompressed = fromSrcBuffer;
 1121|  85.5k|        bytesWritten = LZ4F_makeBlock(dstPtr, (size_t)(dstEnd - dstPtr),
 1122|  85.5k|                                      srcPtr, (size_t)(srcEnd - srcPtr),
 1123|  85.5k|                                      compress, cctxPtr->lz4CtxPtr, cctxPtr->prefs.compressionLevel,
 1124|  85.5k|                                      cctxPtr->cdict,
 1125|  85.5k|                                      cctxPtr->prefs.frameInfo.blockChecksumFlag);
 1126|  85.5k|        FORWARD_IF_ERROR_INVALIDATE(bytesWritten, cctxPtr);
  ------------------
  |  | 1028|  85.5k|#define FORWARD_IF_ERROR_INVALIDATE(r, cctx) do { \
  |  | 1029|  85.5k|        if (LZ4F_isError(r)) {                     \
  |  |  ------------------
  |  |  |  Branch (1029:13): [True: 9.88k, False: 75.6k]
  |  |  ------------------
  |  | 1030|  9.88k|            (cctx)->cStage = 0;                    \
  |  | 1031|  9.88k|            return (r);                            \
  |  | 1032|  9.88k|        }                                          \
  |  | 1033|  85.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (1033:14): [Folded, False: 75.6k]
  |  |  ------------------
  ------------------
 1127|  75.6k|        dstPtr += bytesWritten;
 1128|  75.6k|        srcPtr = srcEnd;
 1129|  75.6k|    }
 1130|       |
 1131|       |    /* preserve dictionary within @tmpBuff whenever necessary */
 1132|   111k|    if ((cctxPtr->prefs.frameInfo.blockMode==LZ4F_blockLinked) && (lastBlockCompressed==fromSrcBuffer)) {
  ------------------
  |  Branch (1132:9): [True: 88.3k, False: 23.1k]
  |  Branch (1132:67): [True: 65.9k, False: 22.3k]
  ------------------
 1133|       |        /* linked blocks are only supported in compressed mode, see LZ4F_uncompressedUpdate */
 1134|  65.9k|        assert(blockCompression == LZ4B_COMPRESSED);
  ------------------
  |  Branch (1134:9): [True: 0, False: 65.9k]
  |  Branch (1134:9): [True: 65.9k, False: 0]
  ------------------
 1135|  65.9k|        if (compressOptionsPtr->stableSrc) {
  ------------------
  |  Branch (1135:13): [True: 6.08k, False: 59.8k]
  ------------------
 1136|  6.08k|            cctxPtr->tmpIn = cctxPtr->tmpBuff;  /* src is stable : dictionary remains in src across invocations */
 1137|  59.8k|        } else {
 1138|  59.8k|            LZ4F_localSaveDict(cctxPtr);
 1139|  59.8k|        }
 1140|  65.9k|    }
 1141|       |
 1142|       |    /* keep tmpIn within limits */
 1143|   111k|    if (!(cctxPtr->prefs.autoFlush)  /* no autoflush : there may be some data left within internal buffer */
  ------------------
  |  Branch (1143:9): [True: 32.6k, False: 78.8k]
  ------------------
 1144|  32.6k|      && (cctxPtr->tmpIn + blockSize) > (cctxPtr->tmpBuff + cctxPtr->tmpBuffCapacity) )  /* not enough room to store next block */
  ------------------
  |  Branch (1144:10): [True: 129, False: 32.4k]
  ------------------
 1145|    129|    {
 1146|       |        /* only preserve 64KB within internal buffer. Ensures there is enough room for next block.
 1147|       |         * note: this situation necessarily implies lastBlockCompressed==fromTmpBuffer */
 1148|    129|        LZ4F_localSaveDict(cctxPtr);
 1149|    129|        assert((cctxPtr->tmpIn + blockSize) <= (cctxPtr->tmpBuff + cctxPtr->tmpBuffCapacity));
  ------------------
  |  Branch (1149:9): [True: 0, False: 129]
  |  Branch (1149:9): [True: 129, False: 0]
  ------------------
 1150|    129|    }
 1151|       |
 1152|       |    /* some input data left, necessarily < blockSize */
 1153|   111k|    if (srcPtr < srcEnd) {
  ------------------
  |  Branch (1153:9): [True: 15.1k, False: 96.3k]
  ------------------
 1154|       |        /* fill tmp buffer */
 1155|  15.1k|        size_t const sizeToCopy = (size_t)(srcEnd - srcPtr);
 1156|  15.1k|        memcpy(cctxPtr->tmpIn, srcPtr, sizeToCopy);
 1157|  15.1k|        cctxPtr->tmpInSize = sizeToCopy;
 1158|  15.1k|    }
 1159|       |
 1160|   111k|    if (cctxPtr->prefs.frameInfo.contentChecksumFlag == LZ4F_contentChecksumEnabled)
  ------------------
  |  Branch (1160:9): [True: 53.4k, False: 57.9k]
  ------------------
 1161|  53.4k|        (void)XXH32_update(&(cctxPtr->xxh), srcBuffer, srcSize);
  ------------------
  |  |  132|  53.4k|#  define XXH32_update XXH_NAME2(XXH_NAMESPACE, XXH32_update)
  |  |  ------------------
  |  |  |  |  126|  53.4k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  53.4k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1162|       |
 1163|   111k|    cctxPtr->totalInSize += srcSize;
 1164|   111k|    return (size_t)(dstPtr - dstStart);
 1165|   111k|}
lz4frame.c:LZ4F_selectCompression:
 1002|   135k|{
 1003|   135k|    if (compressMode == LZ4B_UNCOMPRESSED)
  ------------------
  |  Branch (1003:9): [True: 1.92k, False: 133k]
  ------------------
 1004|  1.92k|        return LZ4F_doNotCompressBlock;
 1005|   133k|    if (level < LZ4HC_CLEVEL_MIN) {
  ------------------
  |  |   47|   133k|#define LZ4HC_CLEVEL_MIN         2
  ------------------
  |  Branch (1005:9): [True: 49.4k, False: 83.9k]
  ------------------
 1006|  49.4k|        if (blockMode == LZ4F_blockIndependent) return LZ4F_compressBlock;
  ------------------
  |  Branch (1006:13): [True: 13.4k, False: 36.0k]
  ------------------
 1007|  36.0k|        return LZ4F_compressBlock_continue;
 1008|  49.4k|    }
 1009|  83.9k|    if (blockMode == LZ4F_blockIndependent) return LZ4F_compressBlockHC;
  ------------------
  |  Branch (1009:9): [True: 16.0k, False: 67.9k]
  ------------------
 1010|  67.9k|    return LZ4F_compressBlockHC_continue;
 1011|  83.9k|}
lz4frame.c:LZ4F_doNotCompressBlock:
  996|  1.19k|{
  997|  1.19k|    (void)ctx; (void)src; (void)dst; (void)srcSize; (void)dstCapacity; (void)level; (void)cdict;
  998|  1.19k|    return 0;
  999|  1.19k|}
lz4frame.c:LZ4F_compressBlock:
  961|  9.63k|{
  962|  9.63k|    int const acceleration = (level < 0) ? -level + 1 : 1;
  ------------------
  |  Branch (962:30): [True: 4.41k, False: 5.22k]
  ------------------
  963|  9.63k|    DEBUGLOG(5, "LZ4F_compressBlock (srcSize=%i)", srcSize);
  ------------------
  |  |  163|  9.63k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
  964|  9.63k|    LZ4F_initStream(ctx, cdict, level, LZ4F_blockIndependent);
  965|  9.63k|    if (cdict) {
  ------------------
  |  Branch (965:9): [True: 0, False: 9.63k]
  ------------------
  966|      0|        return LZ4_compress_fast_continue((LZ4_stream_t*)ctx, src, dst, srcSize, dstCapacity, acceleration);
  967|  9.63k|    } else {
  968|  9.63k|        return LZ4_compress_fast_extState_fastReset(ctx, src, dst, srcSize, dstCapacity, acceleration);
  969|  9.63k|    }
  970|  9.63k|}
lz4frame.c:LZ4F_compressBlock_continue:
  973|  31.6k|{
  974|  31.6k|    int const acceleration = (level < 0) ? -level + 1 : 1;
  ------------------
  |  Branch (974:30): [True: 16.7k, False: 14.8k]
  ------------------
  975|  31.6k|    (void)cdict; /* init once at beginning of frame */
  976|  31.6k|    DEBUGLOG(5, "LZ4F_compressBlock_continue (srcSize=%i)", srcSize);
  ------------------
  |  |  163|  31.6k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
  977|  31.6k|    return LZ4_compress_fast_continue((LZ4_stream_t*)ctx, src, dst, srcSize, dstCapacity, acceleration);
  978|  31.6k|}
lz4frame.c:LZ4F_compressBlockHC:
  981|  8.88k|{
  982|  8.88k|    LZ4F_initStream(ctx, cdict, level, LZ4F_blockIndependent);
  983|  8.88k|    if (cdict) {
  ------------------
  |  Branch (983:9): [True: 0, False: 8.88k]
  ------------------
  984|      0|        return LZ4_compress_HC_continue((LZ4_streamHC_t*)ctx, src, dst, srcSize, dstCapacity);
  985|      0|    }
  986|  8.88k|    return LZ4_compress_HC_extStateHC_fastReset(ctx, src, dst, srcSize, dstCapacity, level);
  987|  8.88k|}
lz4frame.c:LZ4F_compressBlockHC_continue:
  990|  50.2k|{
  991|  50.2k|    (void)level; (void)cdict; /* init once at beginning of frame */
  992|  50.2k|    return LZ4_compress_HC_continue((LZ4_streamHC_t*)ctx, src, dst, srcSize, dstCapacity);
  993|  50.2k|}
lz4frame.c:LZ4F_makeBlock:
  930|   104k|{
  931|   104k|    BYTE* const cSizePtr = (BYTE*)dst;
  932|   104k|    size_t const overhead = BHSize + (size_t)crcFlag * BFSize;
  933|   104k|    int cCapacity = (srcSize > 1) ? (int)srcSize - 1 : 1;
  ------------------
  |  Branch (933:21): [True: 98.0k, False: 6.39k]
  ------------------
  934|   104k|    U32 cSize;
  935|   104k|    assert(compress != NULL);
  ------------------
  |  Branch (935:5): [True: 0, False: 104k]
  |  Branch (935:5): [True: 104k, False: 0]
  ------------------
  936|   104k|    assert(srcSize > 0);
  ------------------
  |  Branch (936:5): [True: 0, False: 104k]
  |  Branch (936:5): [True: 104k, False: 0]
  ------------------
  937|   104k|    RETURN_ERROR_IF(dstCapacity <= overhead, dstCapacity_tooSmall);
  ------------------
  |  |  322|   104k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  323|   104k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (323:13): [True: 2.82k, False: 101k]
  |  |  ------------------
  |  |  324|  2.82k|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  163|  2.82k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  325|  2.82k|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  320|  2.82k|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  326|  2.82k|        }                          \
  |  |  327|   104k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (327:14): [Folded, False: 101k]
  |  |  ------------------
  ------------------
  938|   101k|    if (dstCapacity - overhead < (size_t)cCapacity)
  ------------------
  |  Branch (938:9): [True: 24.6k, False: 76.9k]
  ------------------
  939|  24.6k|        cCapacity = (int)(dstCapacity - overhead);
  940|   101k|    cSize = (U32)compress(lz4ctx, (const char*)src, (char*)(cSizePtr+BHSize),
  941|   101k|                          (int)srcSize, cCapacity,
  942|   101k|                          level, cdict);
  943|       |
  944|   101k|    if (cSize == 0 || cSize >= srcSize) {
  ------------------
  |  Branch (944:9): [True: 45.5k, False: 56.1k]
  |  Branch (944:23): [True: 0, False: 56.1k]
  ------------------
  945|  45.5k|        RETURN_ERROR_IF(dstCapacity - overhead < srcSize, dstCapacity_tooSmall);
  ------------------
  |  |  322|  45.5k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  323|  45.5k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (323:13): [True: 8.37k, False: 37.1k]
  |  |  ------------------
  |  |  324|  8.37k|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  163|  8.37k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  325|  8.37k|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  320|  8.37k|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  326|  8.37k|        }                          \
  |  |  327|  45.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (327:14): [Folded, False: 37.1k]
  |  |  ------------------
  ------------------
  946|  37.1k|        cSize = (U32)srcSize;
  947|  37.1k|        LZ4F_writeLE32(cSizePtr, cSize | LZ4F_BLOCKUNCOMPRESSED_FLAG);
  ------------------
  |  |  251|  37.1k|#define LZ4F_BLOCKUNCOMPRESSED_FLAG 0x80000000U
  ------------------
  948|  37.1k|        memcpy(cSizePtr+BHSize, src, srcSize);
  949|  56.1k|    } else {
  950|  56.1k|        LZ4F_writeLE32(cSizePtr, cSize);
  951|  56.1k|    }
  952|  93.2k|    if (crcFlag) {
  ------------------
  |  Branch (952:9): [True: 48.2k, False: 45.0k]
  ------------------
  953|  48.2k|        U32 const crc32 = XXH32(cSizePtr+BHSize, cSize, 0);  /* checksum of compressed data */
  ------------------
  |  |  128|  48.2k|#  define XXH32 XXH_NAME2(XXH_NAMESPACE, XXH32)
  |  |  ------------------
  |  |  |  |  126|  48.2k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  48.2k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  954|  48.2k|        LZ4F_writeLE32(cSizePtr+BHSize+cSize, crc32);
  955|  48.2k|    }
  956|  93.2k|    return BHSize + cSize + ((U32)crcFlag)*BFSize;
  957|   101k|}
lz4frame.c:LZ4F_localSaveDict:
 1015|  60.3k|{
 1016|  60.3k|    int const dictSize = (cctxPtr->prefs.compressionLevel < LZ4HC_CLEVEL_MIN) ?
  ------------------
  |  |   47|  60.3k|#define LZ4HC_CLEVEL_MIN         2
  ------------------
  |  Branch (1016:26): [True: 24.4k, False: 35.9k]
  ------------------
 1017|  24.4k|                    LZ4_saveDict ((LZ4_stream_t*)(cctxPtr->lz4CtxPtr), (char*)(cctxPtr->tmpBuff), 64 KB) :
  ------------------
  |  |  240|  24.4k|#  define KB *(1<<10)
  ------------------
 1018|  60.3k|                    LZ4_saveDictHC ((LZ4_streamHC_t*)(cctxPtr->lz4CtxPtr), (char*)(cctxPtr->tmpBuff), 64 KB);
  ------------------
  |  |  240|  35.9k|#  define KB *(1<<10)
  ------------------
 1019|  60.3k|    cctxPtr->tmpIn = cctxPtr->tmpBuff + dictSize;
 1020|  60.3k|}
lz4frame.c:LZ4F_writeLE32:
  200|   278k|{
  201|   278k|    BYTE* const dstPtr = (BYTE*)dst;
  202|   278k|    dstPtr[0] = (BYTE)value32;
  203|   278k|    dstPtr[1] = (BYTE)(value32 >> 8);
  204|   278k|    dstPtr[2] = (BYTE)(value32 >> 16);
  205|   278k|    dstPtr[3] = (BYTE)(value32 >> 24);
  206|   278k|}
lz4frame.c:LZ4F_readLE32:
  190|  65.3k|{
  191|  65.3k|    const BYTE* const srcPtr = (const BYTE*)src;
  192|  65.3k|    U32 value32 = srcPtr[0];
  193|  65.3k|    value32 |= ((U32)srcPtr[1])<< 8;
  194|  65.3k|    value32 |= ((U32)srcPtr[2])<<16;
  195|  65.3k|    value32 |= ((U32)srcPtr[3])<<24;
  196|  65.3k|    return value32;
  197|  65.3k|}
lz4frame.c:LZ4F_decodeHeader:
 1425|  14.3k|{
 1426|  14.3k|    unsigned blockMode, blockChecksumFlag, contentSizeFlag, contentChecksumFlag, dictIDFlag, blockSizeID;
 1427|  14.3k|    size_t frameHeaderSize;
 1428|  14.3k|    const BYTE* srcPtr = (const BYTE*)src;
 1429|       |
 1430|  14.3k|    DEBUGLOG(5, "LZ4F_decodeHeader");
  ------------------
  |  |  163|  14.3k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 1431|       |    /* need to decode header to get frameInfo */
 1432|  14.3k|    RETURN_ERROR_IF(srcSize < minFHSize, frameHeader_incomplete);   /* minimal frame header size */
  ------------------
  |  |  322|  14.3k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  323|  14.3k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (323:13): [True: 0, False: 14.3k]
  |  |  ------------------
  |  |  324|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  163|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  325|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  320|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  326|      0|        }                          \
  |  |  327|  14.3k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (327:14): [Folded, False: 14.3k]
  |  |  ------------------
  ------------------
 1433|  14.3k|    MEM_INIT(&(dctx->frameInfo), 0, sizeof(dctx->frameInfo));
  ------------------
  |  |   91|  14.3k|#  define MEM_INIT(p,v,s)   memset((p),(v),(s))
  ------------------
 1434|       |
 1435|       |    /* special case : skippable frames */
 1436|  14.3k|    if ((LZ4F_readLE32(srcPtr) & 0xFFFFFFF0U) == LZ4F_MAGIC_SKIPPABLE_START) {
  ------------------
  |  |  418|  14.3k|#define LZ4F_MAGIC_SKIPPABLE_START 0x184D2A50U
  ------------------
  |  Branch (1436:9): [True: 0, False: 14.3k]
  ------------------
 1437|      0|        dctx->frameInfo.frameType = LZ4F_skippableFrame;
 1438|      0|        if (src == (void*)(dctx->header)) {
  ------------------
  |  Branch (1438:13): [True: 0, False: 0]
  ------------------
 1439|      0|            dctx->tmpInSize = srcSize;
 1440|      0|            dctx->tmpInTarget = 8;
 1441|      0|            dctx->dStage = dstage_storeSFrameSize;
 1442|      0|            return srcSize;
 1443|      0|        } else {
 1444|      0|            dctx->dStage = dstage_getSFrameSize;
 1445|      0|            return 4;
 1446|      0|    }   }
 1447|       |
 1448|       |    /* control magic number */
 1449|       |#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
 1450|       |    if (LZ4F_readLE32(srcPtr) != LZ4F_MAGICNUMBER) {
 1451|       |        DEBUGLOG(4, "frame header error : unknown magic number");
 1452|       |        RETURN_ERROR(frameType_unknown);
 1453|       |    }
 1454|       |#endif
 1455|  14.3k|    dctx->frameInfo.frameType = LZ4F_frame;
 1456|       |
 1457|       |    /* Flags */
 1458|  14.3k|    {   U32 const FLG = srcPtr[4];
 1459|  14.3k|        U32 const version = (FLG>>6) & _2BITS;
  ------------------
  |  |  246|  14.3k|#define _2BITS 0x03
  ------------------
 1460|  14.3k|        blockChecksumFlag = (FLG>>4) & _1BIT;
  ------------------
  |  |  245|  14.3k|#define _1BIT  0x01
  ------------------
 1461|  14.3k|        blockMode = (FLG>>5) & _1BIT;
  ------------------
  |  |  245|  14.3k|#define _1BIT  0x01
  ------------------
 1462|  14.3k|        contentSizeFlag = (FLG>>3) & _1BIT;
  ------------------
  |  |  245|  14.3k|#define _1BIT  0x01
  ------------------
 1463|  14.3k|        contentChecksumFlag = (FLG>>2) & _1BIT;
  ------------------
  |  |  245|  14.3k|#define _1BIT  0x01
  ------------------
 1464|  14.3k|        dictIDFlag = FLG & _1BIT;
  ------------------
  |  |  245|  14.3k|#define _1BIT  0x01
  ------------------
 1465|       |        /* validate */
 1466|  14.3k|        if (((FLG>>1)&_1BIT) != 0) RETURN_ERROR(reservedFlag_set); /* Reserved bit */
  ------------------
  |  |  245|  14.3k|#define _1BIT  0x01
  ------------------
                      if (((FLG>>1)&_1BIT) != 0) RETURN_ERROR(reservedFlag_set); /* Reserved bit */
  ------------------
  |  |  320|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  |  Branch (1466:13): [True: 0, False: 14.3k]
  ------------------
 1467|  14.3k|        if (version != 1) RETURN_ERROR(headerVersion_wrong);       /* Version Number, only supported value */
  ------------------
  |  |  320|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  |  Branch (1467:13): [True: 0, False: 14.3k]
  ------------------
 1468|  14.3k|    }
 1469|  14.3k|    DEBUGLOG(6, "contentSizeFlag: %u", contentSizeFlag);
  ------------------
  |  |  163|  14.3k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 1470|       |
 1471|       |    /* Frame Header Size */
 1472|  14.3k|    frameHeaderSize = minFHSize + (contentSizeFlag?8:0) + (dictIDFlag?4:0);
  ------------------
  |  Branch (1472:36): [True: 0, False: 14.3k]
  |  Branch (1472:60): [True: 0, False: 14.3k]
  ------------------
 1473|       |
 1474|  14.3k|    if (srcSize < frameHeaderSize) {
  ------------------
  |  Branch (1474:9): [True: 0, False: 14.3k]
  ------------------
 1475|       |        /* not enough input to fully decode frame header */
 1476|      0|        if (srcPtr != dctx->header)
  ------------------
  |  Branch (1476:13): [True: 0, False: 0]
  ------------------
 1477|      0|            memcpy(dctx->header, srcPtr, srcSize);
 1478|      0|        dctx->tmpInSize = srcSize;
 1479|      0|        dctx->tmpInTarget = frameHeaderSize;
 1480|      0|        dctx->dStage = dstage_storeFrameHeader;
 1481|      0|        return srcSize;
 1482|      0|    }
 1483|       |
 1484|  14.3k|    {   U32 const BD = srcPtr[5];
 1485|  14.3k|        blockSizeID = (BD>>4) & _3BITS;
  ------------------
  |  |  247|  14.3k|#define _3BITS 0x07
  ------------------
 1486|       |        /* validate */
 1487|  14.3k|        if (((BD>>7)&_1BIT) != 0) RETURN_ERROR(reservedFlag_set);   /* Reserved bit */
  ------------------
  |  |  245|  14.3k|#define _1BIT  0x01
  ------------------
                      if (((BD>>7)&_1BIT) != 0) RETURN_ERROR(reservedFlag_set);   /* Reserved bit */
  ------------------
  |  |  320|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  |  Branch (1487:13): [True: 0, False: 14.3k]
  ------------------
 1488|  14.3k|        if (blockSizeID < 4) RETURN_ERROR(maxBlockSize_invalid);    /* 4-7 only supported values for the time being */
  ------------------
  |  |  320|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  |  Branch (1488:13): [True: 0, False: 14.3k]
  ------------------
 1489|  14.3k|        if (((BD>>0)&_4BITS) != 0) RETURN_ERROR(reservedFlag_set);  /* Reserved bits */
  ------------------
  |  |  248|  14.3k|#define _4BITS 0x0F
  ------------------
                      if (((BD>>0)&_4BITS) != 0) RETURN_ERROR(reservedFlag_set);  /* Reserved bits */
  ------------------
  |  |  320|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  |  Branch (1489:13): [True: 0, False: 14.3k]
  ------------------
 1490|  14.3k|    }
 1491|       |
 1492|       |    /* check header */
 1493|  14.3k|    assert(frameHeaderSize > 5);
  ------------------
  |  Branch (1493:5): [True: 0, False: 14.3k]
  |  Branch (1493:5): [True: 14.3k, False: 0]
  ------------------
 1494|       |#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
 1495|       |    {   BYTE const HC = LZ4F_headerChecksum(srcPtr+4, frameHeaderSize-5);
 1496|       |        RETURN_ERROR_IF(HC != srcPtr[frameHeaderSize-1], headerChecksum_invalid);
 1497|       |    }
 1498|       |#endif
 1499|       |
 1500|       |    /* save */
 1501|  14.3k|    dctx->frameInfo.blockMode = (LZ4F_blockMode_t)blockMode;
 1502|  14.3k|    dctx->frameInfo.blockChecksumFlag = (LZ4F_blockChecksum_t)blockChecksumFlag;
 1503|  14.3k|    dctx->frameInfo.contentChecksumFlag = (LZ4F_contentChecksum_t)contentChecksumFlag;
 1504|  14.3k|    dctx->frameInfo.blockSizeID = (LZ4F_blockSizeID_t)blockSizeID;
 1505|  14.3k|    dctx->maxBlockSize = LZ4F_getBlockSize((LZ4F_blockSizeID_t)blockSizeID);
 1506|  14.3k|    if (contentSizeFlag) {
  ------------------
  |  Branch (1506:9): [True: 0, False: 14.3k]
  ------------------
 1507|      0|        dctx->frameRemainingSize = dctx->frameInfo.contentSize = LZ4F_readLE64(srcPtr+6);
 1508|      0|    }
 1509|  14.3k|    if (dictIDFlag)
  ------------------
  |  Branch (1509:9): [True: 0, False: 14.3k]
  ------------------
 1510|      0|        dctx->frameInfo.dictID = LZ4F_readLE32(srcPtr + frameHeaderSize - 5);
 1511|       |
 1512|  14.3k|    dctx->dStage = dstage_init;
 1513|       |
 1514|  14.3k|    return frameHeaderSize;
 1515|  14.3k|}
lz4frame.c:LZ4F_updateDict:
 1612|  16.1k|{
 1613|  16.1k|    assert(dstPtr != NULL);
  ------------------
  |  Branch (1613:5): [True: 0, False: 16.1k]
  |  Branch (1613:5): [True: 16.1k, False: 0]
  ------------------
 1614|  16.1k|    if (dctx->dictSize==0) dctx->dict = (const BYTE*)dstPtr;  /* will lead to prefix mode */
  ------------------
  |  Branch (1614:9): [True: 7.19k, False: 8.94k]
  ------------------
 1615|  16.1k|    assert(dctx->dict != NULL);
  ------------------
  |  Branch (1615:5): [True: 0, False: 16.1k]
  |  Branch (1615:5): [True: 16.1k, False: 0]
  ------------------
 1616|       |
 1617|  16.1k|    if (dctx->dict + dctx->dictSize == dstPtr) {  /* prefix mode, everything within dstBuffer */
  ------------------
  |  Branch (1617:9): [True: 16.1k, False: 0]
  ------------------
 1618|  16.1k|        dctx->dictSize += dstSize;
 1619|  16.1k|        return;
 1620|  16.1k|    }
 1621|       |
 1622|  16.1k|    assert(dstPtr >= dstBufferStart);
  ------------------
  |  Branch (1622:5): [True: 0, False: 0]
  |  Branch (1622:5): [True: 0, False: 0]
  ------------------
 1623|      0|    if ((size_t)(dstPtr - dstBufferStart) + dstSize >= 64 KB) {  /* history in dstBuffer becomes large enough to become dictionary */
  ------------------
  |  |  240|      0|#  define KB *(1<<10)
  ------------------
  |  Branch (1623:9): [True: 0, False: 0]
  ------------------
 1624|      0|        dctx->dict = (const BYTE*)dstBufferStart;
 1625|      0|        dctx->dictSize = (size_t)(dstPtr - dstBufferStart) + dstSize;
 1626|      0|        return;
 1627|      0|    }
 1628|       |
 1629|      0|    assert(dstSize < 64 KB);   /* if dstSize >= 64 KB, dictionary would be set into dstBuffer directly */
  ------------------
  |  Branch (1629:5): [True: 0, False: 0]
  |  Branch (1629:5): [True: 0, False: 0]
  ------------------
 1630|       |
 1631|       |    /* dstBuffer does not contain whole useful history (64 KB), so it must be saved within tmpOutBuffer */
 1632|      0|    assert(dctx->tmpOutBuffer != NULL);
  ------------------
  |  Branch (1632:5): [True: 0, False: 0]
  |  Branch (1632:5): [True: 0, False: 0]
  ------------------
 1633|       |
 1634|      0|    if (withinTmp && (dctx->dict == dctx->tmpOutBuffer)) {   /* continue history within tmpOutBuffer */
  ------------------
  |  Branch (1634:9): [True: 0, False: 0]
  |  Branch (1634:22): [True: 0, False: 0]
  ------------------
 1635|       |        /* withinTmp expectation : content of [dstPtr,dstSize] is same as [dict+dictSize,dstSize], so we just extend it */
 1636|      0|        assert(dctx->dict + dctx->dictSize == dctx->tmpOut + dctx->tmpOutStart);
  ------------------
  |  Branch (1636:9): [True: 0, False: 0]
  |  Branch (1636:9): [True: 0, False: 0]
  ------------------
 1637|      0|        dctx->dictSize += dstSize;
 1638|      0|        return;
 1639|      0|    }
 1640|       |
 1641|      0|    if (withinTmp) { /* copy relevant dict portion in front of tmpOut within tmpOutBuffer */
  ------------------
  |  Branch (1641:9): [True: 0, False: 0]
  ------------------
 1642|      0|        size_t const preserveSize = (size_t)(dctx->tmpOut - dctx->tmpOutBuffer);
 1643|      0|        size_t copySize = 64 KB - dctx->tmpOutSize;
  ------------------
  |  |  240|      0|#  define KB *(1<<10)
  ------------------
 1644|      0|        const BYTE* const oldDictEnd = dctx->dict + dctx->dictSize - dctx->tmpOutStart;
 1645|      0|        if (dctx->tmpOutSize > 64 KB) copySize = 0;
  ------------------
  |  |  240|      0|#  define KB *(1<<10)
  ------------------
  |  Branch (1645:13): [True: 0, False: 0]
  ------------------
 1646|      0|        if (copySize > preserveSize) copySize = preserveSize;
  ------------------
  |  Branch (1646:13): [True: 0, False: 0]
  ------------------
 1647|       |
 1648|      0|        memcpy(dctx->tmpOutBuffer + preserveSize - copySize, oldDictEnd - copySize, copySize);
 1649|       |
 1650|      0|        dctx->dict = dctx->tmpOutBuffer;
 1651|      0|        dctx->dictSize = preserveSize + dctx->tmpOutStart + dstSize;
 1652|      0|        return;
 1653|      0|    }
 1654|       |
 1655|      0|    if (dctx->dict == dctx->tmpOutBuffer) {    /* copy dst into tmp to complete dict */
  ------------------
  |  Branch (1655:9): [True: 0, False: 0]
  ------------------
 1656|      0|        if (dctx->dictSize + dstSize > dctx->tmpOutBufferCapacity) {  /* tmp buffer not large enough */
  ------------------
  |  Branch (1656:13): [True: 0, False: 0]
  ------------------
 1657|      0|            size_t const preserveSize = 64 KB - dstSize;
  ------------------
  |  |  240|      0|#  define KB *(1<<10)
  ------------------
 1658|      0|            memcpy(dctx->tmpOutBuffer, dctx->dict + dctx->dictSize - preserveSize, preserveSize);
 1659|      0|            dctx->dictSize = preserveSize;
 1660|      0|        }
 1661|      0|        memcpy(dctx->tmpOutBuffer + dctx->dictSize, dstPtr, dstSize);
 1662|      0|        dctx->dictSize += dstSize;
 1663|      0|        return;
 1664|      0|    }
 1665|       |
 1666|       |    /* join dict & dest into tmp */
 1667|      0|    {   size_t preserveSize = 64 KB - dstSize;
  ------------------
  |  |  240|      0|#  define KB *(1<<10)
  ------------------
 1668|      0|        if (preserveSize > dctx->dictSize) preserveSize = dctx->dictSize;
  ------------------
  |  Branch (1668:13): [True: 0, False: 0]
  ------------------
 1669|      0|        memcpy(dctx->tmpOutBuffer, dctx->dict + dctx->dictSize - preserveSize, preserveSize);
 1670|      0|        memcpy(dctx->tmpOutBuffer + preserveSize, dstPtr, dstSize);
 1671|      0|        dctx->dict = dctx->tmpOutBuffer;
 1672|      0|        dctx->dictSize = preserveSize + dstSize;
 1673|      0|    }
 1674|      0|}

LZ4_compress_HC_extStateHC_fastReset:
 1582|  8.88k|{
 1583|  8.88k|    LZ4HC_CCtx_internal* const ctx = &((LZ4_streamHC_t*)state)->internal_donotuse;
 1584|  8.88k|    if (!LZ4_isAligned(state, LZ4_streamHC_t_alignment())) return 0;
  ------------------
  |  Branch (1584:9): [True: 0, False: 8.88k]
  ------------------
 1585|  8.88k|    LZ4_resetStreamHC_fast((LZ4_streamHC_t*)state, compressionLevel);
 1586|  8.88k|    LZ4HC_init_internal (ctx, (const BYTE*)src);
 1587|  8.88k|    if (dstCapacity < LZ4_compressBound(srcSize))
  ------------------
  |  Branch (1587:9): [True: 8.88k, False: 0]
  ------------------
 1588|  8.88k|        return LZ4HC_compress_generic (ctx, src, dst, &srcSize, dstCapacity, compressionLevel, limitedOutput);
 1589|      0|    else
 1590|      0|        return LZ4HC_compress_generic (ctx, src, dst, &srcSize, dstCapacity, compressionLevel, notLimited);
 1591|  8.88k|}
LZ4_initStreamHC:
 1655|  48.8k|{
 1656|  48.8k|    LZ4_streamHC_t* const LZ4_streamHCPtr = (LZ4_streamHC_t*)buffer;
 1657|  48.8k|    DEBUGLOG(4, "LZ4_initStreamHC(%p, %u)", buffer, (unsigned)size);
  ------------------
  |  |  290|  48.8k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1658|       |    /* check conditions */
 1659|  48.8k|    if (buffer == NULL) return NULL;
  ------------------
  |  Branch (1659:9): [True: 0, False: 48.8k]
  ------------------
 1660|  48.8k|    if (size < sizeof(LZ4_streamHC_t)) return NULL;
  ------------------
  |  Branch (1660:9): [True: 0, False: 48.8k]
  ------------------
 1661|  48.8k|    if (!LZ4_isAligned(buffer, LZ4_streamHC_t_alignment())) return NULL;
  ------------------
  |  Branch (1661:9): [True: 0, False: 48.8k]
  ------------------
 1662|       |    /* init */
 1663|  48.8k|    { LZ4HC_CCtx_internal* const hcstate = &(LZ4_streamHCPtr->internal_donotuse);
 1664|  48.8k|      MEM_INIT(hcstate, 0, sizeof(*hcstate)); }
  ------------------
  |  |  237|  48.8k|#define MEM_INIT(p,v,s)   LZ4_memset((p),(v),(s))
  |  |  ------------------
  |  |  |  |  235|  48.8k|#  define LZ4_memset(p,v,s) memset((p),(v),(s))
  |  |  ------------------
  ------------------
 1665|  48.8k|    LZ4_setCompressionLevel(LZ4_streamHCPtr, LZ4HC_CLEVEL_DEFAULT);
  ------------------
  |  |   48|  48.8k|#define LZ4HC_CLEVEL_DEFAULT     9
  ------------------
 1666|  48.8k|    return LZ4_streamHCPtr;
 1667|  48.8k|}
LZ4_resetStreamHC_fast:
 1677|  58.7k|{
 1678|  58.7k|    LZ4HC_CCtx_internal* const s = &LZ4_streamHCPtr->internal_donotuse;
 1679|  58.7k|    DEBUGLOG(5, "LZ4_resetStreamHC_fast(%p, %d)", LZ4_streamHCPtr, compressionLevel);
  ------------------
  |  |  290|  58.7k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1680|  58.7k|    if (s->dirty) {
  ------------------
  |  Branch (1680:9): [True: 1.01k, False: 57.6k]
  ------------------
 1681|       |        /* a failed compression left the tables in an undefined state : start from scratch,
 1682|       |         * but preserve parameters, as a reset without prior failure would */
 1683|  1.01k|        LZ4_i8 const favorDecSpeed = s->favorDecSpeed;
 1684|  1.01k|        LZ4_initStreamHC(LZ4_streamHCPtr, sizeof(*LZ4_streamHCPtr));
 1685|  1.01k|        s->favorDecSpeed = favorDecSpeed;
 1686|  57.6k|    } else {
 1687|  57.6k|        assert(s->end >= s->prefixStart);
  ------------------
  |  Branch (1687:9): [True: 0, False: 57.6k]
  |  Branch (1687:9): [True: 57.6k, False: 0]
  ------------------
 1688|  57.6k|        s->dictLimit += (U32)(s->end - s->prefixStart);
 1689|  57.6k|        s->prefixStart = NULL;
 1690|  57.6k|        s->end = NULL;
 1691|  57.6k|        s->dictCtx = NULL;
 1692|  57.6k|    }
 1693|  58.7k|    LZ4_setCompressionLevel(LZ4_streamHCPtr, compressionLevel);
 1694|  58.7k|}
LZ4_setCompressionLevel:
 1697|   107k|{
 1698|   107k|    DEBUGLOG(5, "LZ4_setCompressionLevel(%p, %d)", LZ4_streamHCPtr, compressionLevel);
  ------------------
  |  |  290|   107k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1699|   107k|    if (compressionLevel < 1) compressionLevel = LZ4HC_CLEVEL_DEFAULT;
  ------------------
  |  |   48|      0|#define LZ4HC_CLEVEL_DEFAULT     9
  ------------------
  |  Branch (1699:9): [True: 0, False: 107k]
  ------------------
 1700|   107k|    if (compressionLevel > LZ4HC_CLEVEL_MAX) compressionLevel = LZ4HC_CLEVEL_MAX;
  ------------------
  |  |   50|   107k|#define LZ4HC_CLEVEL_MAX        12
  ------------------
                  if (compressionLevel > LZ4HC_CLEVEL_MAX) compressionLevel = LZ4HC_CLEVEL_MAX;
  ------------------
  |  |   50|      0|#define LZ4HC_CLEVEL_MAX        12
  ------------------
  |  Branch (1700:9): [True: 0, False: 107k]
  ------------------
 1701|   107k|    LZ4_streamHCPtr->internal_donotuse.compressionLevel = (short)compressionLevel;
 1702|   107k|}
LZ4_favorDecompressionSpeed:
 1705|  50.4k|{
 1706|  50.4k|    LZ4_streamHCPtr->internal_donotuse.favorDecSpeed = (favor!=0);
 1707|  50.4k|}
LZ4_compress_HC_continue:
 1816|  50.2k|{
 1817|  50.2k|    DEBUGLOG(5, "LZ4_compress_HC_continue");
  ------------------
  |  |  290|  50.2k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1818|  50.2k|    if (dstCapacity < LZ4_compressBound(srcSize))
  ------------------
  |  Branch (1818:9): [True: 50.2k, False: 0]
  ------------------
 1819|  50.2k|        return LZ4_compressHC_continue_generic (LZ4_streamHCPtr, src, dst, &srcSize, dstCapacity, limitedOutput);
 1820|      0|    else
 1821|      0|        return LZ4_compressHC_continue_generic (LZ4_streamHCPtr, src, dst, &srcSize, dstCapacity, notLimited);
 1822|  50.2k|}
LZ4_saveDictHC:
 1836|  35.9k|{
 1837|  35.9k|    LZ4HC_CCtx_internal* const streamPtr = &LZ4_streamHCPtr->internal_donotuse;
 1838|  35.9k|    int const prefixSize = (int)(streamPtr->end - streamPtr->prefixStart);
 1839|  35.9k|    DEBUGLOG(5, "LZ4_saveDictHC(%p, %p, %d)", LZ4_streamHCPtr, safeBuffer, dictSize);
  ------------------
  |  |  290|  35.9k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1840|  35.9k|    assert(prefixSize >= 0);
  ------------------
  |  Branch (1840:5): [True: 0, False: 35.9k]
  |  Branch (1840:5): [True: 35.9k, False: 0]
  ------------------
 1841|  35.9k|    if (dictSize > 64 KB) dictSize = 64 KB;
  ------------------
  |  |  252|  35.9k|#define KB *(1 <<10)
  ------------------
                  if (dictSize > 64 KB) dictSize = 64 KB;
  ------------------
  |  |  252|      0|#define KB *(1 <<10)
  ------------------
  |  Branch (1841:9): [True: 0, False: 35.9k]
  ------------------
 1842|  35.9k|    if (dictSize < 4) dictSize = 0;
  ------------------
  |  Branch (1842:9): [True: 0, False: 35.9k]
  ------------------
 1843|  35.9k|    if (dictSize > prefixSize) dictSize = prefixSize;
  ------------------
  |  Branch (1843:9): [True: 34.0k, False: 1.82k]
  ------------------
 1844|  35.9k|    if (safeBuffer == NULL) assert(dictSize == 0); /* a NULL buffer with !0 size is invalid */
  ------------------
  |  Branch (1844:9): [True: 0, False: 35.9k]
  |  Branch (1844:29): [True: 0, False: 0]
  |  Branch (1844:29): [True: 0, False: 0]
  ------------------
 1845|  35.9k|    if (dictSize > 0)
  ------------------
  |  Branch (1845:9): [True: 35.9k, False: 0]
  ------------------
 1846|  35.9k|        LZ4_memmove(safeBuffer, streamPtr->end - dictSize, (size_t)dictSize);
  ------------------
  |  |  358|  35.9k|#    define LZ4_memmove __builtin_memmove
  ------------------
 1847|  35.9k|    {   U32 const endIndex = (U32)(streamPtr->end - streamPtr->prefixStart) + streamPtr->dictLimit;
 1848|  35.9k|        streamPtr->end = (safeBuffer == NULL) ? NULL : (const BYTE*)safeBuffer + dictSize;
  ------------------
  |  Branch (1848:26): [True: 0, False: 35.9k]
  ------------------
 1849|  35.9k|        streamPtr->prefixStart = (const BYTE*)safeBuffer;
 1850|  35.9k|        streamPtr->dictLimit = endIndex - (U32)dictSize;
 1851|  35.9k|        streamPtr->lowLimit = endIndex - (U32)dictSize;
 1852|  35.9k|        streamPtr->dictStart = streamPtr->prefixStart;
 1853|  35.9k|        if (streamPtr->nextToUpdate < streamPtr->dictLimit)
  ------------------
  |  Branch (1853:13): [True: 511, False: 35.3k]
  ------------------
 1854|    511|            streamPtr->nextToUpdate = streamPtr->dictLimit;
 1855|  35.9k|    }
 1856|  35.9k|    return dictSize;
 1857|  35.9k|}
lz4hc.c:LZ4_streamHC_t_alignment:
 1570|  57.7k|{
 1571|  57.7k|#if LZ4_ALIGN_TEST
 1572|  57.7k|    typedef struct { char c; LZ4_streamHC_t t; } t_a;
 1573|  57.7k|    return sizeof(t_a) - sizeof(LZ4_streamHC_t);
 1574|       |#else
 1575|       |    return 1;  /* effectively disabled */
 1576|       |#endif
 1577|  57.7k|}
lz4hc.c:LZ4HC_init_internal:
  244|  33.7k|{
  245|  33.7k|    size_t const bufferSize = (size_t)(hc4->end - hc4->prefixStart);
  246|  33.7k|    size_t newStartingOffset = bufferSize + hc4->dictLimit;
  247|  33.7k|    DEBUGLOG(5, "LZ4HC_init_internal");
  ------------------
  |  |  290|  33.7k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  248|  33.7k|    assert(newStartingOffset >= bufferSize);  /* check overflow */
  ------------------
  |  Branch (248:5): [True: 0, False: 33.7k]
  |  Branch (248:5): [True: 33.7k, False: 0]
  ------------------
  249|  33.7k|    if (newStartingOffset > 1 GB) {
  ------------------
  |  |  254|  33.7k|#define GB *(1U<<30)
  ------------------
  |  Branch (249:9): [True: 0, False: 33.7k]
  ------------------
  250|      0|        LZ4HC_clearTables(hc4);
  251|      0|        newStartingOffset = 0;
  252|      0|    }
  253|  33.7k|    newStartingOffset += 64 KB;
  ------------------
  |  |  252|  33.7k|#define KB *(1 <<10)
  ------------------
  254|  33.7k|    hc4->nextToUpdate = (U32)newStartingOffset;
  255|  33.7k|    hc4->prefixStart = start;
  256|  33.7k|    hc4->end = start;
  257|  33.7k|    hc4->dictStart = start;
  258|  33.7k|    hc4->dictLimit = (U32)newStartingOffset;
  259|  33.7k|    hc4->lowLimit = (U32)newStartingOffset;
  260|  33.7k|}
lz4hc.c:LZ4HC_compress_generic:
 1558|  59.1k|{
 1559|  59.1k|    if (ctx->dictCtx == NULL) {
  ------------------
  |  Branch (1559:9): [True: 59.1k, False: 0]
  ------------------
 1560|  59.1k|        return LZ4HC_compress_generic_noDictCtx(ctx, src, dst, srcSizePtr, dstCapacity, cLevel, limit);
 1561|  59.1k|    } else {
 1562|      0|        return LZ4HC_compress_generic_dictCtx(ctx, src, dst, srcSizePtr, dstCapacity, cLevel, limit);
 1563|      0|    }
 1564|  59.1k|}
lz4hc.c:LZ4HC_compress_generic_noDictCtx:
 1507|  59.1k|{
 1508|  59.1k|    assert(ctx->dictCtx == NULL);
  ------------------
  |  Branch (1508:5): [True: 0, False: 59.1k]
  |  Branch (1508:5): [True: 59.1k, False: 0]
  ------------------
 1509|  59.1k|    return LZ4HC_compress_generic_internal(ctx, src, dst, srcSizePtr, dstCapacity, cLevel, limit, noDictCtx);
 1510|  59.1k|}
lz4hc.c:LZ4HC_compress_generic_internal:
 1459|  59.1k|{
 1460|  59.1k|    DEBUGLOG(5, "LZ4HC_compress_generic_internal(src=%p, srcSize=%d, dstCapacity=%d)",
  ------------------
  |  |  290|  59.1k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1461|  59.1k|                src, *srcSizePtr, dstCapacity);
 1462|       |
 1463|       |    /* input sanitization */
 1464|  59.1k|    if ((U32)*srcSizePtr > (U32)LZ4_MAX_INPUT_SIZE) return 0;  /* Unsupported input size (too large or negative) */
  ------------------
  |  |  214|  59.1k|#define LZ4_MAX_INPUT_SIZE        0x7E000000   /* 2 113 929 216 bytes */
  ------------------
  |  Branch (1464:9): [True: 0, False: 59.1k]
  ------------------
 1465|  59.1k|    if (dstCapacity < 1) return 0;   /* Invalid: impossible to store anything */
  ------------------
  |  Branch (1465:9): [True: 0, False: 59.1k]
  ------------------
 1466|  59.1k|    assert(dst); /* since dstCapacity >= 1, dst must be valid */
  ------------------
  |  Branch (1466:5): [True: 0, False: 59.1k]
  |  Branch (1466:5): [True: 59.1k, False: 0]
  ------------------
 1467|  59.1k|    if (*srcSizePtr == 0) { *dst = 0; return 1; }
  ------------------
  |  Branch (1467:9): [True: 0, False: 59.1k]
  ------------------
 1468|  59.1k|    assert(src != NULL); /* since *srcSizePtr >= 1, src must be valid */
  ------------------
  |  Branch (1468:5): [True: 0, False: 59.1k]
  |  Branch (1468:5): [True: 59.1k, False: 0]
  ------------------
 1469|       |
 1470|  59.1k|    ctx->end += *srcSizePtr;
 1471|  59.1k|    {   cParams_t const cParam = LZ4HC_getCLevelParams(cLevel);
 1472|  59.1k|        HCfavor_e const favor = ctx->favorDecSpeed ? favorDecompressionSpeed : favorCompressionRatio;
  ------------------
  |  Branch (1472:33): [True: 25.7k, False: 33.4k]
  ------------------
 1473|  59.1k|        int result;
 1474|       |
 1475|  59.1k|        if (cParam.strat == lz4mid) {
  ------------------
  |  Branch (1475:13): [True: 13.4k, False: 45.7k]
  ------------------
 1476|  13.4k|            result = LZ4MID_compress(ctx,
 1477|  13.4k|                                src, dst, srcSizePtr, dstCapacity,
 1478|  13.4k|                                limit, dict);
 1479|  45.7k|        } else if (cParam.strat == lz4hc) {
  ------------------
  |  Branch (1479:20): [True: 26.6k, False: 19.0k]
  ------------------
 1480|  26.6k|            result = LZ4HC_compress_hashChain(ctx,
 1481|  26.6k|                                src, dst, srcSizePtr, dstCapacity,
 1482|  26.6k|                                cParam.nbSearches, limit, dict);
 1483|  26.6k|        } else {
 1484|  19.0k|            assert(cParam.strat == lz4opt);
  ------------------
  |  Branch (1484:13): [True: 0, False: 19.0k]
  |  Branch (1484:13): [True: 19.0k, False: 0]
  ------------------
 1485|  19.0k|            result = LZ4HC_compress_optimal(ctx,
 1486|  19.0k|                                src, dst, srcSizePtr, dstCapacity,
 1487|  19.0k|                                cParam.nbSearches, cParam.nbSearchesSeq, (int)cParam.targetLength, limit,
 1488|  19.0k|                                dict, favor);
 1489|  19.0k|        }
 1490|  59.1k|        if (result <= 0) ctx->dirty = 1;
  ------------------
  |  Branch (1490:13): [True: 22.2k, False: 36.8k]
  ------------------
 1491|  59.1k|        return result;
 1492|  59.1k|    }
 1493|  59.1k|}
lz4hc.c:LZ4MID_compress:
  657|  13.4k|{
  658|  13.4k|    U32* const hash4Table = ctx->hashTable;
  659|  13.4k|    U32* const hash8Table = hash4Table + LZ4MID_HASHTABLESIZE;
  ------------------
  |  |  144|  13.4k|#define LZ4MID_HASHTABLESIZE (1 << LZ4MID_HASHLOG)
  |  |  ------------------
  |  |  |  |  143|  13.4k|#define LZ4MID_HASHLOG (LZ4HC_HASH_LOG-1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  233|  13.4k|#define LZ4HC_HASH_LOG 15
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  660|  13.4k|    const BYTE* ip = (const BYTE*)src;
  661|  13.4k|    const BYTE* anchor = ip;
  662|  13.4k|    const BYTE* const iend = ip + *srcSizePtr;
  663|  13.4k|    const BYTE* const mflimit = iend - MFLIMIT;
  ------------------
  |  |  247|  13.4k|#define MFLIMIT       12   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  664|  13.4k|    const BYTE* const matchlimit = (iend - LASTLITERALS);
  ------------------
  |  |  246|  13.4k|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  665|  13.4k|    const BYTE* const ilimit = (iend - LZ4MID_HASHSIZE);
  ------------------
  |  |  142|  13.4k|#define LZ4MID_HASHSIZE 8
  ------------------
  666|  13.4k|    BYTE* op = (BYTE*)dst;
  667|       |    /* fillOutput : keep room for the final run of literals (LZ4 format restriction) */
  668|  13.4k|    BYTE* const oend = op + maxOutputSize - ((limit == fillOutput) ? LASTLITERALS : 0);
  ------------------
  |  |  246|      0|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  |  Branch (668:46): [True: 0, False: 13.4k]
  ------------------
  669|       |
  670|  13.4k|    const BYTE* const prefixPtr = ctx->prefixStart;
  671|  13.4k|    const U32 prefixIdx = ctx->dictLimit;
  672|  13.4k|    const U32 ilimitIdx = (U32)(ilimit - prefixPtr) + prefixIdx;
  673|  13.4k|    const BYTE* const dictStart = ctx->dictStart;
  674|  13.4k|    const U32 dictIdx = ctx->lowLimit;
  675|  13.4k|    const U32 gDictEndIndex = ctx->lowLimit;
  676|  13.4k|    const LZ4MID_searchIntoDict_f searchIntoDict = (dict == usingDictCtxHc) ? select_searchDict_function(ctx->dictCtx) : NULL;
  ------------------
  |  Branch (676:52): [True: 0, False: 13.4k]
  ------------------
  677|  13.4k|    unsigned matchLength;
  678|  13.4k|    unsigned matchDistance;
  679|       |
  680|  13.4k|    DEBUGLOG(5, "LZ4MID_compress (%i bytes)", *srcSizePtr);
  ------------------
  |  |  290|  13.4k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  681|       |
  682|       |    /* preconditions verifications */
  683|  13.4k|    if (dict == usingDictCtxHc) DEBUGLOG(5, "usingDictCtxHc");
  ------------------
  |  |  290|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  |  Branch (683:9): [True: 0, False: 13.4k]
  ------------------
  684|  13.4k|    assert(*srcSizePtr > 0);
  ------------------
  |  Branch (684:5): [True: 0, False: 13.4k]
  |  Branch (684:5): [True: 13.4k, False: 0]
  ------------------
  685|  13.4k|    assert(*srcSizePtr <= LZ4_MAX_INPUT_SIZE);
  ------------------
  |  Branch (685:5): [True: 0, False: 13.4k]
  |  Branch (685:5): [True: 13.4k, False: 0]
  ------------------
  686|  13.4k|    assert(src != NULL);
  ------------------
  |  Branch (686:5): [True: 0, False: 13.4k]
  |  Branch (686:5): [True: 13.4k, False: 0]
  ------------------
  687|  13.4k|    assert(maxOutputSize >= 1);
  ------------------
  |  Branch (687:5): [True: 0, False: 13.4k]
  |  Branch (687:5): [True: 13.4k, False: 0]
  ------------------
  688|  13.4k|    assert(dst != NULL);
  ------------------
  |  Branch (688:5): [True: 0, False: 13.4k]
  |  Branch (688:5): [True: 13.4k, False: 0]
  ------------------
  689|       |
  690|  13.4k|    if (*srcSizePtr < LZ4_minLength)
  ------------------
  |  Branch (690:9): [True: 2.50k, False: 10.9k]
  ------------------
  691|  2.50k|        goto _lz4mid_last_literals;  /* Input too small, no compression (all literals) */
  692|       |
  693|       |    /* main loop */
  694|  22.2M|    while (ip <= mflimit) {
  ------------------
  |  Branch (694:12): [True: 22.2M, False: 10.4k]
  ------------------
  695|  22.2M|        const U32 ipIndex = (U32)(ip - prefixPtr) + prefixIdx;
  696|       |        /* search long match */
  697|  22.2M|        {   U32 const h8 = LZ4MID_hash8Ptr(ip);
  698|  22.2M|            U32 const pos8 = hash8Table[h8];
  699|  22.2M|            assert(h8 < LZ4MID_HASHTABLESIZE);
  ------------------
  |  Branch (699:13): [True: 0, False: 22.2M]
  |  Branch (699:13): [True: 22.2M, False: 0]
  ------------------
  700|  22.2M|            assert(pos8 < ipIndex);
  ------------------
  |  Branch (700:13): [True: 0, False: 22.2M]
  |  Branch (700:13): [True: 22.2M, False: 0]
  ------------------
  701|  22.2M|            LZ4MID_addPosition(hash8Table, h8, ipIndex);
  702|  22.2M|            if (ipIndex - pos8 <= LZ4_DISTANCE_MAX) {
  ------------------
  |  |  678|  22.2M|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (702:17): [True: 14.1M, False: 8.00M]
  ------------------
  703|       |                /* match candidate found */
  704|  14.1M|                if (pos8 >= prefixIdx) {
  ------------------
  |  Branch (704:21): [True: 12.7M, False: 1.43M]
  ------------------
  705|  12.7M|                    const BYTE* const matchPtr = prefixPtr + pos8 - prefixIdx;
  706|  12.7M|                    assert(matchPtr < ip);
  ------------------
  |  Branch (706:21): [True: 0, False: 12.7M]
  |  Branch (706:21): [True: 12.7M, False: 0]
  ------------------
  707|  12.7M|                    matchLength = LZ4_count(ip, matchPtr, matchlimit);
  708|  12.7M|                    if (matchLength >= MINMATCH) {
  ------------------
  |  |  243|  12.7M|#define MINMATCH 4
  ------------------
  |  Branch (708:25): [True: 1.28M, False: 11.4M]
  ------------------
  709|  1.28M|                        DEBUGLOG(7, "found long match at pos %u (len=%u)", pos8, matchLength);
  ------------------
  |  |  290|  1.28M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  710|  1.28M|                        matchDistance = ipIndex - pos8;
  711|  1.28M|                        goto _lz4mid_encode_sequence;
  712|  1.28M|                    }
  713|  12.7M|                } else {
  714|  1.43M|                    if (pos8 >= dictIdx) {
  ------------------
  |  Branch (714:25): [True: 777k, False: 654k]
  ------------------
  715|       |                        /* extDict match candidate */
  716|   777k|                        const BYTE* const matchPtr = dictStart + (pos8 - dictIdx);
  717|   777k|                        const size_t safeLen = MIN(prefixIdx - pos8, (size_t)(matchlimit - ip));
  ------------------
  |  |   81|   777k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (81:22): [True: 629k, False: 148k]
  |  |  ------------------
  ------------------
  718|   777k|                        matchLength = LZ4_count(ip, matchPtr, ip + safeLen);
  719|   777k|                        if (matchLength >= MINMATCH) {
  ------------------
  |  |  243|   777k|#define MINMATCH 4
  ------------------
  |  Branch (719:29): [True: 24.6k, False: 753k]
  ------------------
  720|  24.6k|                            DEBUGLOG(7, "found long match at ExtDict pos %u (len=%u)", pos8, matchLength);
  ------------------
  |  |  290|  24.6k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  721|  24.6k|                            matchDistance = ipIndex - pos8;
  722|  24.6k|                            goto _lz4mid_encode_sequence;
  723|  24.6k|                        }
  724|   777k|                    }
  725|  1.43M|                }
  726|  14.1M|        }   }
  727|       |        /* search short match */
  728|  20.8M|        {   U32 const h4 = LZ4MID_hash4Ptr(ip);
  729|  20.8M|            U32 const pos4 = hash4Table[h4];
  730|  20.8M|            assert(h4 < LZ4MID_HASHTABLESIZE);
  ------------------
  |  Branch (730:13): [True: 0, False: 20.8M]
  |  Branch (730:13): [True: 20.8M, False: 0]
  ------------------
  731|  20.8M|            assert(pos4 < ipIndex);
  ------------------
  |  Branch (731:13): [True: 0, False: 20.8M]
  |  Branch (731:13): [True: 20.8M, False: 0]
  ------------------
  732|  20.8M|            LZ4MID_addPosition(hash4Table, h4, ipIndex);
  733|  20.8M|            if (ipIndex - pos4 <= LZ4_DISTANCE_MAX) {
  ------------------
  |  |  678|  20.8M|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (733:17): [True: 12.9M, False: 7.95M]
  ------------------
  734|       |                /* match candidate found */
  735|  12.9M|                if (pos4 >= prefixIdx) {
  ------------------
  |  Branch (735:21): [True: 11.5M, False: 1.35M]
  ------------------
  736|       |                /* only search within prefix */
  737|  11.5M|                    const BYTE* const matchPtr = prefixPtr + (pos4 - prefixIdx);
  738|  11.5M|                    assert(matchPtr < ip);
  ------------------
  |  Branch (738:21): [True: 0, False: 11.5M]
  |  Branch (738:21): [True: 11.5M, False: 0]
  ------------------
  739|  11.5M|                    assert(matchPtr >= prefixPtr);
  ------------------
  |  Branch (739:21): [True: 0, False: 11.5M]
  |  Branch (739:21): [True: 11.5M, False: 0]
  ------------------
  740|  11.5M|                    matchLength = LZ4_count(ip, matchPtr, matchlimit);
  741|  11.5M|                    if (matchLength >= MINMATCH) {
  ------------------
  |  |  243|  11.5M|#define MINMATCH 4
  ------------------
  |  Branch (741:25): [True: 838k, False: 10.7M]
  ------------------
  742|       |                        /* short match found, let's just check ip+1 for longer */
  743|   838k|                        U32 const h8 = LZ4MID_hash8Ptr(ip+1);
  744|   838k|                        U32 const pos8 = hash8Table[h8];
  745|   838k|                        U32 const m2Distance = ipIndex + 1 - pos8;
  746|   838k|                        matchDistance = ipIndex - pos4;
  747|   838k|                        if ( m2Distance <= LZ4_DISTANCE_MAX
  ------------------
  |  |  678|  1.67M|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (747:30): [True: 562k, False: 275k]
  ------------------
  748|   562k|                        && pos8 >= prefixIdx /* only search within prefix */
  ------------------
  |  Branch (748:28): [True: 513k, False: 49.3k]
  ------------------
  749|   513k|                        && likely(ip < mflimit)
  ------------------
  |  |  178|   513k|#define likely(expr)     expect((expr) != 0, 1)
  |  |  ------------------
  |  |  |  |  172|   513k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 513k, False: 73]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  750|   838k|                        ) {
  751|   513k|                            const BYTE* const m2Ptr = prefixPtr + (pos8 - prefixIdx);
  752|   513k|                            unsigned ml2 = LZ4_count(ip+1, m2Ptr, matchlimit);
  753|   513k|                            if (ml2 > matchLength) {
  ------------------
  |  Branch (753:33): [True: 96.0k, False: 417k]
  ------------------
  754|  96.0k|                                LZ4MID_addPosition(hash8Table, h8, ipIndex+1);
  755|  96.0k|                                ip++;
  756|  96.0k|                                matchLength = ml2;
  757|  96.0k|                                matchDistance = m2Distance;
  758|  96.0k|                        }   }
  759|   838k|                        goto _lz4mid_encode_sequence;
  760|   838k|                    }
  761|  11.5M|                } else {
  762|  1.35M|                    if (pos4 >= dictIdx) {
  ------------------
  |  Branch (762:25): [True: 727k, False: 626k]
  ------------------
  763|       |                        /* extDict match candidate */
  764|   727k|                        const BYTE* const matchPtr = dictStart + (pos4 - dictIdx);
  765|   727k|                        const size_t safeLen = MIN(prefixIdx - pos4, (size_t)(matchlimit - ip));
  ------------------
  |  |   81|   727k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (81:22): [True: 588k, False: 138k]
  |  |  ------------------
  ------------------
  766|   727k|                        matchLength = LZ4_count(ip, matchPtr, ip + safeLen);
  767|   727k|                        if (matchLength >= MINMATCH) {
  ------------------
  |  |  243|   727k|#define MINMATCH 4
  ------------------
  |  Branch (767:29): [True: 31.9k, False: 695k]
  ------------------
  768|  31.9k|                            DEBUGLOG(7, "found match at ExtDict pos %u (len=%u)", pos4, matchLength);
  ------------------
  |  |  290|  31.9k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  769|  31.9k|                            matchDistance = ipIndex - pos4;
  770|  31.9k|                            goto _lz4mid_encode_sequence;
  771|  31.9k|                        }
  772|   727k|                    }
  773|  1.35M|                }
  774|  12.9M|        }   }
  775|       |        /* no match found in prefix */
  776|  20.0M|        if ( (dict == usingDictCtxHc)
  ------------------
  |  Branch (776:14): [True: 0, False: 20.0M]
  ------------------
  777|      0|          && (ipIndex - gDictEndIndex < LZ4_DISTANCE_MAX - 8) ) {
  ------------------
  |  |  678|      0|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (777:14): [True: 0, False: 0]
  ------------------
  778|       |            /* search a match into external dictionary */
  779|      0|            LZ4HC_match_t dMatch = searchIntoDict(ip, ipIndex,
  780|      0|                    matchlimit,
  781|      0|                    ctx->dictCtx, gDictEndIndex);
  782|      0|            if (dMatch.len >= MINMATCH) {
  ------------------
  |  |  243|      0|#define MINMATCH 4
  ------------------
  |  Branch (782:17): [True: 0, False: 0]
  ------------------
  783|      0|                DEBUGLOG(7, "found Dictionary match (offset=%i)", dMatch.off);
  ------------------
  |  |  290|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  784|      0|                assert(dMatch.back == 0);
  ------------------
  |  Branch (784:17): [True: 0, False: 0]
  |  Branch (784:17): [True: 0, False: 0]
  ------------------
  785|      0|                matchLength = (unsigned)dMatch.len;
  786|      0|                matchDistance = (unsigned)dMatch.off;
  787|      0|                goto _lz4mid_encode_sequence;
  788|      0|            }
  789|      0|        }
  790|       |        /* no match found */
  791|  20.0M|        ip += 1 + ((ip-anchor) >> 9);  /* skip faster over incompressible data */
  792|  20.0M|        continue;
  793|       |
  794|  2.17M|_lz4mid_encode_sequence:
  795|       |        /* catch back */
  796|  2.30M|        while (((ip > anchor) & ((U32)(ip-prefixPtr) > matchDistance)) && (unlikely(ip[-1] == ip[-(int)matchDistance-1]))) {
  ------------------
  |  |  181|  1.02M|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  172|  1.02M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  ------------------
  ------------------
  |  Branch (796:16): [True: 1.02M, False: 1.28M]
  |  Branch (796:75): [True: 130k, False: 891k]
  ------------------
  797|   130k|            ip--;  matchLength++;
  798|   130k|        };
  799|       |
  800|       |        /* fill table with beginning of match */
  801|  2.17M|        ADDPOS8(ip+1, ipIndex+1);
  ------------------
  |  |  602|  2.17M|#define ADDPOS8(_p, _idx) LZ4MID_addPosition(hash8Table, LZ4MID_hash8Ptr(_p), _idx)
  ------------------
  802|  2.17M|        ADDPOS8(ip+2, ipIndex+2);
  ------------------
  |  |  602|  2.17M|#define ADDPOS8(_p, _idx) LZ4MID_addPosition(hash8Table, LZ4MID_hash8Ptr(_p), _idx)
  ------------------
  803|  2.17M|        ADDPOS4(ip+1, ipIndex+1);
  ------------------
  |  |  603|  2.17M|#define ADDPOS4(_p, _idx) LZ4MID_addPosition(hash4Table, LZ4MID_hash4Ptr(_p), _idx)
  ------------------
  804|       |
  805|       |        /* encode */
  806|  2.17M|        if (LZ4HC_encodeSequence(UPDATABLE(ip, op, anchor),
  ------------------
  |  |  231|  2.17M|#define UPDATABLE(ip, op, anchor) &ip, &op, &anchor
  ------------------
  |  Branch (806:13): [True: 552, False: 2.17M]
  ------------------
  807|  2.17M|                (int)matchLength, (int)matchDistance,
  808|  2.17M|                limit, oend) )
  809|    552|            goto _lz4mid_dest_overflow;
  810|       |
  811|       |        /* fill table with end of match */
  812|  2.17M|        {   U32 endMatchIdx = (U32)(ip-prefixPtr) + prefixIdx;
  813|  2.17M|            U32 pos_m2 = endMatchIdx - 2;
  814|  2.17M|            if (pos_m2 < ilimitIdx) {
  ------------------
  |  Branch (814:17): [True: 2.17M, False: 4.77k]
  ------------------
  815|  2.17M|                if (likely(ip - prefixPtr > 5)) {
  ------------------
  |  |  178|  2.17M|#define likely(expr)     expect((expr) != 0, 1)
  |  |  ------------------
  |  |  |  |  172|  2.17M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 2.17M, False: 830]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  816|  2.17M|                    ADDPOS8(ip-5, endMatchIdx - 5);
  ------------------
  |  |  602|  2.17M|#define ADDPOS8(_p, _idx) LZ4MID_addPosition(hash8Table, LZ4MID_hash8Ptr(_p), _idx)
  ------------------
  817|  2.17M|                }
  818|  2.17M|                ADDPOS8(ip-3, endMatchIdx - 3);
  ------------------
  |  |  602|  2.17M|#define ADDPOS8(_p, _idx) LZ4MID_addPosition(hash8Table, LZ4MID_hash8Ptr(_p), _idx)
  ------------------
  819|  2.17M|                ADDPOS8(ip-2, endMatchIdx - 2);
  ------------------
  |  |  602|  2.17M|#define ADDPOS8(_p, _idx) LZ4MID_addPosition(hash8Table, LZ4MID_hash8Ptr(_p), _idx)
  ------------------
  820|  2.17M|                ADDPOS4(ip-2, endMatchIdx - 2);
  ------------------
  |  |  603|  2.17M|#define ADDPOS4(_p, _idx) LZ4MID_addPosition(hash4Table, LZ4MID_hash4Ptr(_p), _idx)
  ------------------
  821|  2.17M|                ADDPOS4(ip-1, endMatchIdx - 1);
  ------------------
  |  |  603|  2.17M|#define ADDPOS4(_p, _idx) LZ4MID_addPosition(hash4Table, LZ4MID_hash4Ptr(_p), _idx)
  ------------------
  822|  2.17M|            }
  823|  2.17M|        }
  824|  2.17M|    }
  825|       |
  826|  12.9k|_lz4mid_last_literals:
  827|  12.9k|    if (LZ4HC_encodeLastLiterals(UPDATABLE(ip, op, anchor), iend, limit, oend))
  ------------------
  |  |  231|  12.9k|#define UPDATABLE(ip, op, anchor) &ip, &op, &anchor
  ------------------
  |  Branch (827:9): [True: 3.97k, False: 8.93k]
  ------------------
  828|  3.97k|        return 0;  /* not enough space in @dst */
  829|       |
  830|       |    /* End */
  831|  8.93k|    DEBUGLOG(5, "compressed %i bytes into %i bytes", *srcSizePtr, (int)((char*)op - dst));
  ------------------
  |  |  290|  8.93k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  832|  8.93k|    assert(ip >= (const BYTE*)src);
  ------------------
  |  Branch (832:5): [True: 0, False: 8.93k]
  |  Branch (832:5): [True: 8.93k, False: 0]
  ------------------
  833|  8.93k|    assert(ip <= iend);
  ------------------
  |  Branch (833:5): [True: 0, False: 8.93k]
  |  Branch (833:5): [True: 8.93k, False: 0]
  ------------------
  834|  8.93k|    *srcSizePtr = (int)(ip - (const BYTE*)src);
  835|  8.93k|    assert((char*)op >= dst);
  ------------------
  |  Branch (835:5): [True: 0, False: 8.93k]
  |  Branch (835:5): [True: 8.93k, False: 0]
  ------------------
  836|  8.93k|    assert((char*)op - dst <= maxOutputSize);
  ------------------
  |  Branch (836:5): [True: 0, False: 8.93k]
  |  Branch (836:5): [True: 8.93k, False: 0]
  ------------------
  837|  8.93k|    assert((char*)op - dst < INT_MAX);
  ------------------
  |  Branch (837:5): [True: 0, False: 8.93k]
  |  Branch (837:5): [True: 8.93k, False: 0]
  ------------------
  838|  8.93k|    return (int)((char*)op - dst);
  839|       |
  840|    552|_lz4mid_dest_overflow:
  841|    552|    if (limit != fillOutput) return 0;  /* compression failed */
  ------------------
  |  Branch (841:9): [True: 552, False: 0]
  ------------------
  842|      0|    LZ4HC_encodeLastSequence_fillOutput(UPDATABLE(ip, op, anchor),
  ------------------
  |  |  231|      0|#define UPDATABLE(ip, op, anchor) &ip, &op, &anchor
  ------------------
  843|      0|                        (int)matchLength, (int)matchDistance, oend);
  844|      0|    goto _lz4mid_last_literals;
  845|    552|}
lz4hc.c:LZ4HC_hashPtr:
  123|   570M|static U32 LZ4HC_hashPtr(const void* ptr) { return HASH_FUNCTION(LZ4_read32(ptr)); }
  ------------------
  |  |  122|   570M|#define HASH_FUNCTION(i)      (((i) * 2654435761U) >> ((MINMATCH*8)-LZ4HC_HASH_LOG))
  |  |  ------------------
  |  |  |  |  243|   570M|#define MINMATCH 4
  |  |  ------------------
  |  |               #define HASH_FUNCTION(i)      (((i) * 2654435761U) >> ((MINMATCH*8)-LZ4HC_HASH_LOG))
  |  |  ------------------
  |  |  |  |  233|   570M|#define LZ4HC_HASH_LOG 15
  |  |  ------------------
  ------------------
lz4hc.c:LZ4HC_countBack:
  208|   144M|{
  209|   144M|    int back = 0;
  210|   144M|    int const min = (int)MAX(iMin - ip, mMin - match);
  ------------------
  |  |   82|   144M|#define MAX(a,b)   ( (a) > (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (82:22): [True: 144M, False: 281k]
  |  |  ------------------
  ------------------
  211|   144M|    assert(min <= 0);
  ------------------
  |  Branch (211:5): [True: 0, False: 144M]
  |  Branch (211:5): [True: 144M, False: 0]
  ------------------
  212|   144M|    assert(ip >= iMin); assert((size_t)(ip-iMin) < (1U<<31));
  ------------------
  |  Branch (212:5): [True: 0, False: 144M]
  |  Branch (212:5): [True: 144M, False: 0]
  |  Branch (212:25): [True: 0, False: 144M]
  |  Branch (212:25): [True: 144M, False: 0]
  ------------------
  213|   144M|    assert(match >= mMin); assert((size_t)(match - mMin) < (1U<<31));
  ------------------
  |  Branch (213:5): [True: 0, False: 144M]
  |  Branch (213:5): [True: 144M, False: 0]
  |  Branch (213:28): [True: 0, False: 144M]
  |  Branch (213:28): [True: 144M, False: 0]
  ------------------
  214|       |
  215|   544M|    while ((back - min) > 3) {
  ------------------
  |  Branch (215:12): [True: 524M, False: 19.8M]
  ------------------
  216|   524M|        U32 const v = LZ4_read32(ip + back - 4) ^ LZ4_read32(match + back - 4);
  217|   524M|        if (v) {
  ------------------
  |  Branch (217:13): [True: 124M, False: 399M]
  ------------------
  218|   124M|            return (back - (int)LZ4HC_NbCommonBytes32(v));
  219|   399M|        } else back -= 4; /* 4-byte step */
  220|   524M|    }
  221|       |    /* check remainder if any */
  222|  27.3M|    while ( (back > min)
  ------------------
  |  Branch (222:13): [True: 26.8M, False: 439k]
  ------------------
  223|  26.8M|         && (ip[back-1] == match[back-1]) )
  ------------------
  |  Branch (223:13): [True: 7.52M, False: 19.3M]
  ------------------
  224|  7.52M|            back--;
  225|  19.8M|    return back;
  226|   144M|}
lz4hc.c:LZ4HC_NbCommonBytes32:
  170|   124M|{
  171|   124M|    assert(val != 0);
  ------------------
  |  Branch (171:5): [True: 0, False: 124M]
  |  Branch (171:5): [True: 124M, False: 0]
  ------------------
  172|   124M|    if (LZ4_isLittleEndian()) {
  ------------------
  |  Branch (172:9): [True: 124M, False: 0]
  ------------------
  173|       |#     if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(LZ4_FORCE_SW_BITCOUNT)
  174|       |        unsigned long r;
  175|       |        _BitScanReverse(&r, val);
  176|       |        return (unsigned)((31 - r) >> 3);
  177|       |#     elif (defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 3) || \
  178|       |                            ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))))) && \
  179|       |                                        !defined(LZ4_FORCE_SW_BITCOUNT)
  180|       |        return (unsigned)__builtin_clz(val) >> 3;
  181|       |#     else
  182|       |        val >>= 8;
  183|       |        val = ((((val + 0x00FFFF00) | 0x00FFFFFF) + val) |
  184|       |              (val + 0x00FF0000)) >> 24;
  185|       |        return (unsigned)val ^ 3;
  186|       |#     endif
  187|   124M|    } else {
  188|       |#     if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(LZ4_FORCE_SW_BITCOUNT)
  189|       |        unsigned long r;
  190|       |        _BitScanForward(&r, val);
  191|       |        return (unsigned)(r >> 3);
  192|       |#     elif (defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 3) || \
  193|       |                            ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))))) && \
  194|       |                                        !defined(LZ4_FORCE_SW_BITCOUNT)
  195|       |        return (unsigned)__builtin_ctz(val) >> 3;
  196|       |#     else
  197|       |        const U32 m = 0x01010101;
  198|       |        return (unsigned)((((val - 1) ^ val) & (m - 1)) * m) >> 24;
  199|       |#     endif
  200|      0|    }
  201|   124M|}
lz4hc.c:LZ4MID_hash8Ptr:
  152|  33.9M|static U32 LZ4MID_hash8Ptr(const void* ptr) { return LZ4MID_hash7(LZ4_readLE64(ptr)); }
lz4hc.c:LZ4MID_hash7:
  150|  33.9M|static U32 LZ4MID_hash7(U64 v) { return (U32)(((v  << (64-56)) * 58295818150454627ULL) >> (64-LZ4MID_HASHLOG)) ; }
  ------------------
  |  |  143|  33.9M|#define LZ4MID_HASHLOG (LZ4HC_HASH_LOG-1)
  |  |  ------------------
  |  |  |  |  233|  33.9M|#define LZ4HC_HASH_LOG 15
  |  |  ------------------
  ------------------
lz4hc.c:LZ4_readLE64:
  155|  33.9M|{
  156|  33.9M|    if (LZ4_isLittleEndian()) {
  ------------------
  |  Branch (156:9): [True: 33.9M, False: 0]
  ------------------
  157|  33.9M|        return LZ4_read64(memPtr);
  158|  33.9M|    } else {
  159|      0|        const BYTE* p = (const BYTE*)memPtr;
  160|       |        /* note: relies on the compiler to simplify this expression */
  161|      0|        return (U64)p[0] | ((U64)p[1]<<8) | ((U64)p[2]<<16) | ((U64)p[3]<<24)
  162|      0|            | ((U64)p[4]<<32) | ((U64)p[5]<<40) | ((U64)p[6]<<48) | ((U64)p[7]<<56);
  163|      0|    }
  164|  33.9M|}
lz4hc.c:LZ4_read64:
  132|  33.9M|static U64 LZ4_read64(const void* ptr) { return ((const LZ4_unalign64*)ptr)->u64; }
lz4hc.c:LZ4MID_addPosition:
  598|  60.5M|{
  599|  60.5M|    hTable[hValue] = index;
  600|  60.5M|}
lz4hc.c:LZ4MID_hash4Ptr:
  147|  27.4M|static U32 LZ4MID_hash4Ptr(const void* ptr) { return LZ4MID_hash4(LZ4_read32(ptr)); }
lz4hc.c:LZ4MID_hash4:
  146|  27.4M|static U32 LZ4MID_hash4(U32 v) { return (v * 2654435761U) >> (32-LZ4MID_HASHLOG); }
  ------------------
  |  |  143|  27.4M|#define LZ4MID_HASHLOG (LZ4HC_HASH_LOG-1)
  |  |  ------------------
  |  |  |  |  233|  27.4M|#define LZ4HC_HASH_LOG 15
  |  |  ------------------
  ------------------
lz4hc.c:LZ4HC_encodeSequence:
  301|  7.67M|{
  302|  7.67M|#define ip      (*_ip)
  303|  7.67M|#define op      (*_op)
  304|  7.67M|#define anchor  (*_anchor)
  305|       |
  306|  7.67M|    BYTE* const token = op++;
  ------------------
  |  |  303|  7.67M|#define op      (*_op)
  ------------------
  307|       |
  308|       |#if defined(LZ4_DEBUG) && (LZ4_DEBUG >= 6)
  309|       |    static const BYTE* start = NULL;
  310|       |    static U32 totalCost = 0;
  311|       |    U32 const pos = (start==NULL) ? 0 : (U32)(anchor - start); /* only works for single segment */
  312|       |    U32 const ll = (U32)(ip - anchor);
  313|       |    U32 const llAdd = (ll>=15) ? ((ll-15) / 255) + 1 : 0;
  314|       |    U32 const mlAdd = (matchLength>=19) ? ((matchLength-19) / 255) + 1 : 0;
  315|       |    U32 const cost = 1 + llAdd + ll + 2 + mlAdd;
  316|       |    if (start==NULL) start = anchor;  /* only works for single segment */
  317|       |    DEBUGLOG(6, "pos:%7u -- literals:%4u, match:%4i, offset:%5i, cost:%4u + %5u",
  318|       |                pos,
  319|       |                (U32)(ip - anchor), matchLength, offset,
  320|       |                cost, totalCost);
  321|       |# if 1 /* only works on single segment data */
  322|       |    HEX_CMP(7, ip, ip-offset, matchLength);
  323|       |# endif
  324|       |    totalCost += cost;
  325|       |#endif
  326|       |
  327|       |    /* Encode Literal length */
  328|  7.67M|    {   size_t litLen = (size_t)(ip - anchor);
  ------------------
  |  |  302|  7.67M|#define ip      (*_ip)
  ------------------
                  {   size_t litLen = (size_t)(ip - anchor);
  ------------------
  |  |  304|  7.67M|#define anchor  (*_anchor)
  ------------------
  329|  7.67M|        LZ4_STATIC_ASSERT(notLimited == 0);
  ------------------
  |  |  278|  7.67M|#define LZ4_STATIC_ASSERT(c)   { enum { LZ4_static_assert = 1/(int)(!!(c)) }; }   /* use after variable declarations */
  ------------------
  330|       |        /* Check output limit */
  331|  7.67M|        if (limit && ((op + (litLen / 255) + litLen + (2 + 1 + LASTLITERALS)) > oend)) {
  ------------------
  |  |  303|  7.67M|#define op      (*_op)
  ------------------
                      if (limit && ((op + (litLen / 255) + litLen + (2 + 1 + LASTLITERALS)) > oend)) {
  ------------------
  |  |  246|  7.67M|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  |  Branch (331:13): [True: 7.67M, False: 0]
  |  Branch (331:22): [True: 2.52k, False: 7.67M]
  ------------------
  332|  2.52k|            DEBUGLOG(6, "Not enough room to write %i literals (%i bytes remaining)",
  ------------------
  |  |  290|  2.52k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  333|  2.52k|                    (int)litLen, (int)(oend - op));
  334|  2.52k|            op = token;
  ------------------
  |  |  303|  2.52k|#define op      (*_op)
  ------------------
  335|  2.52k|            return 1;
  336|  2.52k|        }
  337|  7.67M|        if (litLen >= RUN_MASK) {
  ------------------
  |  |  264|  7.67M|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  263|  7.67M|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|  7.67M|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (337:13): [True: 576k, False: 7.10M]
  ------------------
  338|   576k|            size_t len = litLen - RUN_MASK;
  ------------------
  |  |  264|   576k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  263|   576k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|   576k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  339|   576k|            *token = (RUN_MASK << ML_BITS);
  ------------------
  |  |  264|   576k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  263|   576k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|   576k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                          *token = (RUN_MASK << ML_BITS);
  ------------------
  |  |  261|   576k|#define ML_BITS  4
  ------------------
  340|   740k|            for(; len >= 255 ; len -= 255) *op++ = 255;
  ------------------
  |  |  303|   164k|#define op      (*_op)
  ------------------
  |  Branch (340:19): [True: 164k, False: 576k]
  ------------------
  341|   576k|            *op++ = (BYTE)len;
  ------------------
  |  |  303|   576k|#define op      (*_op)
  ------------------
  342|  7.10M|        } else {
  343|  7.10M|            *token = (BYTE)(litLen << ML_BITS);
  ------------------
  |  |  261|  7.10M|#define ML_BITS  4
  ------------------
  344|  7.10M|        }
  345|       |
  346|       |        /* Copy Literals */
  347|  7.67M|        LZ4_wildCopy8(op, anchor, op + litLen);
  ------------------
  |  |  303|  7.67M|#define op      (*_op)
  ------------------
                      LZ4_wildCopy8(op, anchor, op + litLen);
  ------------------
  |  |  304|  7.67M|#define anchor  (*_anchor)
  ------------------
                      LZ4_wildCopy8(op, anchor, op + litLen);
  ------------------
  |  |  303|  7.67M|#define op      (*_op)
  ------------------
  348|  7.67M|        op += litLen;
  ------------------
  |  |  303|  7.67M|#define op      (*_op)
  ------------------
  349|  7.67M|    }
  350|       |
  351|       |    /* Encode Offset */
  352|  7.67M|    assert(offset <= LZ4_DISTANCE_MAX );
  ------------------
  |  Branch (352:5): [True: 0, False: 7.67M]
  |  Branch (352:5): [True: 7.67M, False: 0]
  ------------------
  353|  7.67M|    assert(offset > 0);
  ------------------
  |  Branch (353:5): [True: 0, False: 7.67M]
  |  Branch (353:5): [True: 7.67M, False: 0]
  ------------------
  354|  7.67M|    LZ4_writeLE16(op, (U16)(offset)); op += 2;
  ------------------
  |  |  303|  7.67M|#define op      (*_op)
  ------------------
                  LZ4_writeLE16(op, (U16)(offset)); op += 2;
  ------------------
  |  |  303|  7.67M|#define op      (*_op)
  ------------------
  355|       |
  356|       |    /* Encode MatchLength */
  357|  7.67M|    assert(matchLength >= MINMATCH);
  ------------------
  |  Branch (357:5): [True: 0, False: 7.67M]
  |  Branch (357:5): [True: 7.67M, False: 0]
  ------------------
  358|  7.67M|    {   size_t mlCode = (size_t)matchLength - MINMATCH;
  ------------------
  |  |  243|  7.67M|#define MINMATCH 4
  ------------------
  359|  7.67M|        if (limit && (op + (mlCode / 255) + (1 + LASTLITERALS) > oend)) {
  ------------------
  |  |  303|  7.67M|#define op      (*_op)
  ------------------
                      if (limit && (op + (mlCode / 255) + (1 + LASTLITERALS) > oend)) {
  ------------------
  |  |  246|  7.67M|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  |  Branch (359:13): [True: 7.67M, False: 0]
  |  Branch (359:22): [True: 165, False: 7.67M]
  ------------------
  360|    165|            DEBUGLOG(6, "Not enough room to write match length");
  ------------------
  |  |  290|    165|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  361|    165|            op = token;
  ------------------
  |  |  303|    165|#define op      (*_op)
  ------------------
  362|    165|            return 1;
  363|    165|        }
  364|  7.67M|        if (mlCode >= ML_MASK) {
  ------------------
  |  |  262|  7.67M|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  261|  7.67M|#define ML_BITS  4
  |  |  ------------------
  ------------------
  |  Branch (364:13): [True: 1.44M, False: 6.23M]
  ------------------
  365|  1.44M|            *token += ML_MASK;
  ------------------
  |  |  262|  1.44M|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  261|  1.44M|#define ML_BITS  4
  |  |  ------------------
  ------------------
  366|  1.44M|            mlCode -= ML_MASK;
  ------------------
  |  |  262|  1.44M|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  261|  1.44M|#define ML_BITS  4
  |  |  ------------------
  ------------------
  367|  2.29M|            for(; mlCode >= 510 ; mlCode -= 510) { *op++ = 255; *op++ = 255; }
  ------------------
  |  |  303|   854k|#define op      (*_op)
  ------------------
                          for(; mlCode >= 510 ; mlCode -= 510) { *op++ = 255; *op++ = 255; }
  ------------------
  |  |  303|   854k|#define op      (*_op)
  ------------------
  |  Branch (367:19): [True: 854k, False: 1.44M]
  ------------------
  368|  1.44M|            if (mlCode >= 255) { mlCode -= 255; *op++ = 255; }
  ------------------
  |  |  303|   113k|#define op      (*_op)
  ------------------
  |  Branch (368:17): [True: 113k, False: 1.32M]
  ------------------
  369|  1.44M|            *op++ = (BYTE)mlCode;
  ------------------
  |  |  303|  1.44M|#define op      (*_op)
  ------------------
  370|  6.23M|        } else {
  371|  6.23M|            *token += (BYTE)(mlCode);
  372|  6.23M|    }   }
  373|       |
  374|       |    /* Prepare next loop */
  375|  7.67M|    ip += matchLength;
  ------------------
  |  |  302|  7.67M|#define ip      (*_ip)
  ------------------
  376|  7.67M|    anchor = ip;
  ------------------
  |  |  304|  7.67M|#define anchor  (*_anchor)
  ------------------
                  anchor = ip;
  ------------------
  |  |  302|  7.67M|#define ip      (*_ip)
  ------------------
  377|       |
  378|  7.67M|    return 0;
  379|       |
  380|  7.67M|#undef ip
  381|  7.67M|#undef op
  382|  7.67M|#undef anchor
  383|  7.67M|}
lz4hc.c:LZ4HC_encodeLastLiterals:
  398|  56.4k|{
  399|  56.4k|#define ip      (*_ip)
  400|  56.4k|#define op      (*_op)
  401|  56.4k|#define anchor  (*_anchor)
  402|       |
  403|  56.4k|    BYTE* const dstEnd = (limit == fillOutput) ? oend + LASTLITERALS : oend;
  ------------------
  |  |  246|      0|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  |  Branch (403:26): [True: 0, False: 56.4k]
  ------------------
  404|  56.4k|    size_t lastRunSize = (size_t)(iend - anchor);  /* literals */
  ------------------
  |  |  401|  56.4k|#define anchor  (*_anchor)
  ------------------
  405|  56.4k|    size_t llAdd = (lastRunSize + 255 - RUN_MASK) / 255;
  ------------------
  |  |  264|  56.4k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  263|  56.4k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|  56.4k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  406|  56.4k|    size_t const totalSize = 1 + llAdd + lastRunSize;
  407|  56.4k|    if (limit && (op + totalSize > dstEnd)) {
  ------------------
  |  |  400|  56.4k|#define op      (*_op)
  ------------------
  |  Branch (407:9): [True: 56.4k, False: 0]
  |  Branch (407:18): [True: 19.5k, False: 36.8k]
  ------------------
  408|  19.5k|        if (limit == limitedOutput) return 1;  /* not enough space in dst */
  ------------------
  |  Branch (408:13): [True: 19.5k, False: 0]
  ------------------
  409|       |        /* adapt lastRunSize to fill dst */
  410|      0|        lastRunSize  = (size_t)(dstEnd - op) - 1 /*token*/;
  ------------------
  |  |  400|      0|#define op      (*_op)
  ------------------
  411|      0|        llAdd = (lastRunSize + 256 - RUN_MASK) / 256;
  ------------------
  |  |  264|      0|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  263|      0|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|      0|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  412|      0|        lastRunSize -= llAdd;
  413|      0|    }
  414|  36.8k|    DEBUGLOG(6, "Final literal run : %i literals", (int)lastRunSize);
  ------------------
  |  |  290|  36.8k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  415|  36.8k|    ip = anchor + lastRunSize;  /* can be != iend if limit==fillOutput */
  ------------------
  |  |  399|  36.8k|#define ip      (*_ip)
  ------------------
                  ip = anchor + lastRunSize;  /* can be != iend if limit==fillOutput */
  ------------------
  |  |  401|  36.8k|#define anchor  (*_anchor)
  ------------------
  416|       |
  417|  36.8k|    if (lastRunSize >= RUN_MASK) {
  ------------------
  |  |  264|  36.8k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  263|  36.8k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|  36.8k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (417:9): [True: 2.98k, False: 33.9k]
  ------------------
  418|  2.98k|        size_t accumulator = lastRunSize - RUN_MASK;
  ------------------
  |  |  264|  2.98k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  263|  2.98k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|  2.98k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  419|  2.98k|        *op++ = (RUN_MASK << ML_BITS);
  ------------------
  |  |  400|  2.98k|#define op      (*_op)
  ------------------
                      *op++ = (RUN_MASK << ML_BITS);
  ------------------
  |  |  264|  2.98k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  263|  2.98k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|  2.98k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      *op++ = (RUN_MASK << ML_BITS);
  ------------------
  |  |  261|  2.98k|#define ML_BITS  4
  ------------------
  420|  27.9k|        for(; accumulator >= 255 ; accumulator -= 255) *op++ = 255;
  ------------------
  |  |  400|  24.9k|#define op      (*_op)
  ------------------
  |  Branch (420:15): [True: 24.9k, False: 2.98k]
  ------------------
  421|  2.98k|        *op++ = (BYTE) accumulator;
  ------------------
  |  |  400|  2.98k|#define op      (*_op)
  ------------------
  422|  33.9k|    } else {
  423|  33.9k|        *op++ = (BYTE)(lastRunSize << ML_BITS);
  ------------------
  |  |  400|  33.9k|#define op      (*_op)
  ------------------
                      *op++ = (BYTE)(lastRunSize << ML_BITS);
  ------------------
  |  |  261|  33.9k|#define ML_BITS  4
  ------------------
  424|  33.9k|    }
  425|  36.8k|    assert(lastRunSize <= (size_t)(dstEnd - op));
  ------------------
  |  Branch (425:5): [True: 0, False: 36.8k]
  |  Branch (425:5): [True: 36.8k, False: 0]
  ------------------
  426|  36.8k|    LZ4_memcpy(op, anchor, lastRunSize);
  ------------------
  |  |  350|  36.8k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  427|  36.8k|    op += lastRunSize;
  ------------------
  |  |  400|  36.8k|#define op      (*_op)
  ------------------
  428|  36.8k|    return 0;
  429|       |
  430|  36.8k|#undef ip
  431|  36.8k|#undef op
  432|  36.8k|#undef anchor
  433|  36.8k|}
lz4hc.c:LZ4HC_compress_hashChain:
 1265|  26.6k|{
 1266|  26.6k|    const int inputSize = *srcSizePtr;
 1267|  26.6k|    const int patternAnalysis = (maxNbAttempts > 128);   /* levels 9+ */
 1268|       |
 1269|  26.6k|    const BYTE* ip = (const BYTE*)src;
 1270|  26.6k|    const BYTE* anchor = ip;
 1271|  26.6k|    const BYTE* const iend = ip + inputSize;
 1272|  26.6k|    const BYTE* const mflimit = iend - MFLIMIT;
  ------------------
  |  |  247|  26.6k|#define MFLIMIT       12   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
 1273|  26.6k|    const BYTE* const matchlimit = (iend - LASTLITERALS);
  ------------------
  |  |  246|  26.6k|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
 1274|       |
 1275|  26.6k|    BYTE* op = (BYTE*) dst;
 1276|       |    /* fillOutput : keep room for the final run of literals (LZ4 format restriction) */
 1277|  26.6k|    BYTE* const oend = op + maxOutputSize - ((limit == fillOutput) ? LASTLITERALS : 0);
  ------------------
  |  |  246|      0|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  |  Branch (1277:46): [True: 0, False: 26.6k]
  ------------------
 1278|       |
 1279|  26.6k|    const BYTE* start0;
 1280|  26.6k|    const BYTE* start2 = NULL;
 1281|  26.6k|    const BYTE* start3 = NULL;
 1282|  26.6k|    LZ4HC_match_t m0, m1, m2, m3;
 1283|  26.6k|    const LZ4HC_match_t nomatch = {0, 0, 0};
 1284|       |
 1285|       |    /* init */
 1286|  26.6k|    DEBUGLOG(5, "LZ4HC_compress_hashChain (dict?=>%i)", dict);
  ------------------
  |  |  290|  26.6k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1287|       |
 1288|       |    /* preconditions verifications */
 1289|  26.6k|    assert(*srcSizePtr >= 1);
  ------------------
  |  Branch (1289:5): [True: 0, False: 26.6k]
  |  Branch (1289:5): [True: 26.6k, False: 0]
  ------------------
 1290|  26.6k|    assert(src != NULL);
  ------------------
  |  Branch (1290:5): [True: 0, False: 26.6k]
  |  Branch (1290:5): [True: 26.6k, False: 0]
  ------------------
 1291|  26.6k|    assert(maxOutputSize >= 1);
  ------------------
  |  Branch (1291:5): [True: 0, False: 26.6k]
  |  Branch (1291:5): [True: 26.6k, False: 0]
  ------------------
 1292|  26.6k|    assert(dst != NULL);
  ------------------
  |  Branch (1292:5): [True: 0, False: 26.6k]
  |  Branch (1292:5): [True: 26.6k, False: 0]
  ------------------
 1293|       |
 1294|  26.6k|    *srcSizePtr = 0;
 1295|  26.6k|    if (inputSize < LZ4_minLength) goto _last_literals;             /* Input too small, no compression (all literals) */
  ------------------
  |  Branch (1295:9): [True: 6.02k, False: 20.6k]
  ------------------
 1296|       |
 1297|       |    /* Main Loop */
 1298|  47.7M|    while (ip <= mflimit) {
  ------------------
  |  Branch (1298:12): [True: 47.7M, False: 19.3k]
  ------------------
 1299|  47.7M|        m1 = LZ4HC_InsertAndFindBestMatch(ctx, ip, matchlimit, maxNbAttempts, patternAnalysis, dict);
 1300|  47.7M|        if (m1.len<MINMATCH) { ip++; continue; }
  ------------------
  |  |  243|  47.7M|#define MINMATCH 4
  ------------------
  |  Branch (1300:13): [True: 44.4M, False: 3.32M]
  ------------------
 1301|       |
 1302|       |        /* saved, in case we would skip too much */
 1303|  3.32M|        start0 = ip; m0 = m1;
 1304|       |
 1305|  4.45M|_Search2:
 1306|  4.45M|        DEBUGLOG(7, "_Search2 (currently found match of size %i)", m1.len);
  ------------------
  |  |  290|  4.45M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1307|  4.45M|        if (ip+m1.len <= mflimit) {
  ------------------
  |  Branch (1307:13): [True: 4.44M, False: 13.0k]
  ------------------
 1308|  4.44M|            start2 = ip + m1.len - 2;
 1309|  4.44M|            m2 = LZ4HC_InsertAndGetWiderMatch(ctx,
 1310|  4.44M|                            start2, ip + 0, matchlimit, m1.len,
 1311|  4.44M|                            maxNbAttempts, patternAnalysis, 0, dict, favorCompressionRatio);
 1312|  4.44M|            start2 += m2.back;
 1313|  4.44M|        } else {
 1314|  13.0k|            m2 = nomatch;  /* do not search further */
 1315|  13.0k|        }
 1316|       |
 1317|  4.45M|        if (m2.len <= m1.len) { /* No better match => encode ML1 immediately */
  ------------------
  |  Branch (1317:13): [True: 2.93M, False: 1.52M]
  ------------------
 1318|  2.93M|            if (LZ4HC_encodeSequence(UPDATABLE(ip, op, anchor),
  ------------------
  |  |  231|  2.93M|#define UPDATABLE(ip, op, anchor) &ip, &op, &anchor
  ------------------
  |  Branch (1318:17): [True: 980, False: 2.93M]
  ------------------
 1319|  2.93M|                    m1.len, m1.off,
 1320|  2.93M|                    limit, oend) )
 1321|    980|                goto _dest_overflow;
 1322|  2.93M|            continue;
 1323|  2.93M|        }
 1324|       |
 1325|  1.52M|        if (start0 < ip) {   /* first match was skipped at least once */
  ------------------
  |  Branch (1325:13): [True: 226k, False: 1.29M]
  ------------------
 1326|   226k|            if (start2 < ip + m0.len) {  /* squeezing ML1 between ML0(original ML1) and ML2 */
  ------------------
  |  Branch (1326:17): [True: 156k, False: 69.8k]
  ------------------
 1327|   156k|                ip = start0; m1 = m0;  /* restore initial Match1 */
 1328|   156k|        }   }
 1329|       |
 1330|       |        /* Here, start0==ip */
 1331|  1.52M|        if ((start2 - ip) < 3) {  /* First Match too small : removed */
  ------------------
  |  Branch (1331:13): [True: 924k, False: 595k]
  ------------------
 1332|   924k|            ip = start2;
 1333|   924k|            m1 = m2;
 1334|   924k|            goto _Search2;
 1335|   924k|        }
 1336|       |
 1337|   749k|_Search3:
 1338|       |        /* m1.len itself is decided when encoding m1 */
 1339|   749k|        if ((start2 - ip) < OPTIMAL_ML)
  ------------------
  |  |   76|   749k|#define OPTIMAL_ML (int)((ML_MASK-1)+MINMATCH)
  |  |  ------------------
  |  |  |  |  262|   749k|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|   749k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define OPTIMAL_ML (int)((ML_MASK-1)+MINMATCH)
  |  |  ------------------
  |  |  |  |  243|   749k|#define MINMATCH 4
  |  |  ------------------
  ------------------
  |  Branch (1339:13): [True: 604k, False: 144k]
  ------------------
 1340|   604k|            (void)LZ4HC_splitOverlap(ip, m1.len, &start2, &m2);
 1341|       |
 1342|   749k|        if (start2 + m2.len <= mflimit) {
  ------------------
  |  Branch (1342:13): [True: 747k, False: 1.97k]
  ------------------
 1343|   747k|            start3 = start2 + m2.len - 3;
 1344|   747k|            m3 = LZ4HC_InsertAndGetWiderMatch(ctx,
 1345|   747k|                            start3, start2, matchlimit, m2.len,
 1346|   747k|                            maxNbAttempts, patternAnalysis, 0, dict, favorCompressionRatio);
 1347|   747k|            start3 += m3.back;
 1348|   747k|        } else {
 1349|  1.97k|            m3 = nomatch;  /* do not search further */
 1350|  1.97k|        }
 1351|       |
 1352|   749k|        if (m3.len <= m2.len) {  /* No better match => encode ML1 and ML2 */
  ------------------
  |  Branch (1352:13): [True: 391k, False: 357k]
  ------------------
 1353|       |            /* ip & ref are known; Now for ml */
 1354|   391k|            if (start2 < ip+m1.len) m1.len = (int)(start2 - ip);
  ------------------
  |  Branch (1354:17): [True: 135k, False: 255k]
  ------------------
 1355|       |            /* Now, encode 2 sequences */
 1356|   391k|            if (LZ4HC_encodeSequence(UPDATABLE(ip, op, anchor),
  ------------------
  |  |  231|   391k|#define UPDATABLE(ip, op, anchor) &ip, &op, &anchor
  ------------------
  |  Branch (1356:17): [True: 94, False: 391k]
  ------------------
 1357|   391k|                    m1.len, m1.off,
 1358|   391k|                    limit, oend) )
 1359|     94|                goto _dest_overflow;
 1360|   391k|            ip = start2;
 1361|   391k|            if (LZ4HC_encodeSequence(UPDATABLE(ip, op, anchor),
  ------------------
  |  |  231|   391k|#define UPDATABLE(ip, op, anchor) &ip, &op, &anchor
  ------------------
  |  Branch (1361:17): [True: 64, False: 391k]
  ------------------
 1362|   391k|                    m2.len, m2.off,
 1363|   391k|                    limit, oend) ) {
 1364|     64|                m1 = m2;
 1365|     64|                goto _dest_overflow;
 1366|     64|            }
 1367|   391k|            continue;
 1368|   391k|        }
 1369|       |
 1370|   357k|        if (start3 < ip+m1.len+3) {  /* Not enough space for match 2 : remove it */
  ------------------
  |  Branch (1370:13): [True: 224k, False: 132k]
  ------------------
 1371|   224k|            if (start3 >= (ip+m1.len)) {  /* can write Seq1 immediately ==> Seq2 is removed, so Seq3 becomes Seq1 */
  ------------------
  |  Branch (1371:17): [True: 203k, False: 20.6k]
  ------------------
 1372|   203k|                if (start2 < ip+m1.len) {
  ------------------
  |  Branch (1372:21): [True: 19.7k, False: 184k]
  ------------------
 1373|  19.7k|                    int correction = (int)(ip+m1.len - start2);
 1374|  19.7k|                    start2 += correction;
 1375|  19.7k|                    m2.len -= correction;
 1376|  19.7k|                    if (m2.len < MINMATCH) {
  ------------------
  |  |  243|  19.7k|#define MINMATCH 4
  ------------------
  |  Branch (1376:25): [True: 178, False: 19.6k]
  ------------------
 1377|    178|                        start2 = start3;
 1378|    178|                        m2 = m3;
 1379|    178|                    }
 1380|  19.7k|                }
 1381|       |
 1382|   203k|                if (LZ4HC_encodeSequence(UPDATABLE(ip, op, anchor),
  ------------------
  |  |  231|   203k|#define UPDATABLE(ip, op, anchor) &ip, &op, &anchor
  ------------------
  |  Branch (1382:21): [True: 95, False: 203k]
  ------------------
 1383|   203k|                        m1.len, m1.off,
 1384|   203k|                        limit, oend) )
 1385|     95|                    goto _dest_overflow;
 1386|   203k|                ip  = start3;
 1387|   203k|                m1 = m3;
 1388|       |
 1389|   203k|                start0 = start2;
 1390|   203k|                m0 = m2;
 1391|   203k|                goto _Search2;
 1392|   203k|            }
 1393|       |
 1394|  20.6k|            start2 = start3;
 1395|  20.6k|            m2 = m3;
 1396|  20.6k|            goto _Search3;
 1397|   224k|        }
 1398|       |
 1399|       |        /*
 1400|       |        * OK, now we have 3 ascending matches;
 1401|       |        * let's write the first one ML1.
 1402|       |        * ip & ref are known; Now decide ml.
 1403|       |        */
 1404|   132k|        if (start2 < ip+m1.len) {
  ------------------
  |  Branch (1404:13): [True: 68.1k, False: 64.8k]
  ------------------
 1405|  68.1k|            if ((start2 - ip) < OPTIMAL_ML)
  ------------------
  |  |   76|  68.1k|#define OPTIMAL_ML (int)((ML_MASK-1)+MINMATCH)
  |  |  ------------------
  |  |  |  |  262|  68.1k|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|  68.1k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define OPTIMAL_ML (int)((ML_MASK-1)+MINMATCH)
  |  |  ------------------
  |  |  |  |  243|  68.1k|#define MINMATCH 4
  |  |  ------------------
  ------------------
  |  Branch (1405:17): [True: 0, False: 68.1k]
  ------------------
 1406|      0|                m1.len = LZ4HC_splitOverlap(ip, m1.len, &start2, &m2);
 1407|  68.1k|            else
 1408|  68.1k|                m1.len = (int)(start2 - ip);
 1409|  68.1k|        }
 1410|   132k|        if ( LZ4HC_encodeSequence(UPDATABLE(ip, op, anchor),
  ------------------
  |  |  231|   132k|#define UPDATABLE(ip, op, anchor) &ip, &op, &anchor
  ------------------
  |  Branch (1410:14): [True: 82, False: 132k]
  ------------------
 1411|   132k|                m1.len, m1.off,
 1412|   132k|                limit, oend) )
 1413|     82|            goto _dest_overflow;
 1414|       |
 1415|       |        /* ML2 becomes ML1 */
 1416|   132k|        ip = start2; m1 = m2;
 1417|       |
 1418|       |        /* ML3 becomes ML2 */
 1419|   132k|        start2 = start3; m2 = m3;
 1420|       |
 1421|       |        /* let's find a new ML3 */
 1422|   132k|        goto _Search3;
 1423|   132k|    }
 1424|       |
 1425|  25.3k|_last_literals:
 1426|  25.3k|    if (LZ4HC_encodeLastLiterals(UPDATABLE(ip, op, anchor), iend, limit, oend))
  ------------------
  |  |  231|  25.3k|#define UPDATABLE(ip, op, anchor) &ip, &op, &anchor
  ------------------
  |  Branch (1426:9): [True: 8.59k, False: 16.7k]
  ------------------
 1427|  8.59k|        return 0;  /* not enough space in @dst */
 1428|       |
 1429|       |    /* End */
 1430|  16.7k|    *srcSizePtr = (int) (((const char*)ip) - src);
 1431|  16.7k|    return (int) (((char*)op)-dst);
 1432|       |
 1433|  1.31k|_dest_overflow:
 1434|  1.31k|    if (limit != fillOutput) return 0;  /* compression failed */
  ------------------
  |  Branch (1434:9): [True: 1.31k, False: 0]
  ------------------
 1435|      0|    LZ4HC_encodeLastSequence_fillOutput(UPDATABLE(ip, op, anchor), m1.len, m1.off, oend);
  ------------------
  |  |  231|      0|#define UPDATABLE(ip, op, anchor) &ip, &op, &anchor
  ------------------
 1436|      0|    goto _last_literals;
 1437|  1.31k|}
lz4hc.c:LZ4HC_InsertAndFindBestMatch:
 1220|  47.7M|{
 1221|  47.7M|    DEBUGLOG(7, "LZ4HC_InsertAndFindBestMatch");
  ------------------
  |  |  290|  47.7M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1222|       |    /* note : LZ4HC_InsertAndGetWiderMatch() is able to modify the starting position of a match (*startpos),
 1223|       |     * but this won't be the case here, as we define iLowLimit==ip,
 1224|       |     * so LZ4HC_InsertAndGetWiderMatch() won't be allowed to search past ip */
 1225|  47.7M|    return LZ4HC_InsertAndGetWiderMatch(hc4, ip, ip, iLimit, MINMATCH-1, maxNbAttempts, patternAnalysis, 0 /*chainSwap*/, dict, favorCompressionRatio);
  ------------------
  |  |  243|  47.7M|#define MINMATCH 4
  ------------------
 1226|  47.7M|}
lz4hc.c:LZ4HC_InsertAndGetWiderMatch:
 1032|  87.2M|{
 1033|  87.2M|    U16* const chainTable = hc4->chainTable;
 1034|  87.2M|    U32* const hashTable = hc4->hashTable;
 1035|  87.2M|    const LZ4HC_CCtx_internal* const dictCtx = hc4->dictCtx;
 1036|  87.2M|    const BYTE* const prefixPtr = hc4->prefixStart;
 1037|  87.2M|    const U32 prefixIdx = hc4->dictLimit;
 1038|  87.2M|    const U32 ipIndex = (U32)(ip - prefixPtr) + prefixIdx;
 1039|  87.2M|    const int withinStartDistance = (hc4->lowLimit + (LZ4_DISTANCE_MAX + 1) > ipIndex);
  ------------------
  |  |  678|  87.2M|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
 1040|  87.2M|    const U32 lowestMatchIndex = (withinStartDistance) ? hc4->lowLimit : ipIndex - LZ4_DISTANCE_MAX;
  ------------------
  |  |  678|  46.0M|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (1040:34): [True: 41.2M, False: 46.0M]
  ------------------
 1041|  87.2M|    const BYTE* const dictStart = hc4->dictStart;
 1042|  87.2M|    const U32 dictIdx = hc4->lowLimit;
 1043|  87.2M|    int const lookBackLength = (int)(ip-iLowLimit);
 1044|  87.2M|    int const maxLength = (int)(iHighLimit-iLowLimit);   /* no match can be longer */
 1045|  87.2M|    int nbAttempts = maxNbAttempts;
 1046|  87.2M|    U32 matchChainPos = 0;
 1047|  87.2M|    U32 const pattern = LZ4_read32(ip);
 1048|  87.2M|    U32 matchIndex;
 1049|  87.2M|    repeat_state_e repeat = rep_untested;
 1050|  87.2M|    size_t srcPatternLength = 0;
 1051|  87.2M|    int offset = 0, sBack = 0;
 1052|       |
 1053|  87.2M|    DEBUGLOG(7, "LZ4HC_InsertAndGetWiderMatch");
  ------------------
  |  |  290|  87.2M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1054|       |    /* First Match */
 1055|  87.2M|    LZ4HC_Insert(hc4, ip);  /* insert all prior positions up to ip (excluded) */
 1056|  87.2M|    matchIndex = hashTable[LZ4HC_hashPtr(ip)];
 1057|  87.2M|    DEBUGLOG(7, "First candidate match for pos %u found at index %u / %u (lowestMatchIndex)",
  ------------------
  |  |  290|  87.2M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1058|  87.2M|                ipIndex, matchIndex, lowestMatchIndex);
 1059|       |
 1060|       |    /* Candidates only replace the current match if strictly longer,
 1061|       |     * so stopping once @longest reaches @maxLength doesn't change the result. */
 1062|   960M|    while ((matchIndex>=lowestMatchIndex) && (nbAttempts>0) && (longest<maxLength)) {
  ------------------
  |  Branch (1062:12): [True: 875M, False: 84.7M]
  |  Branch (1062:46): [True: 872M, False: 2.46M]
  |  Branch (1062:64): [True: 872M, False: 13.7k]
  ------------------
 1063|   872M|        int matchLength=0;
 1064|   872M|        nbAttempts--;
 1065|   872M|        assert(matchIndex < ipIndex);
  ------------------
  |  Branch (1065:9): [True: 0, False: 872M]
  |  Branch (1065:9): [True: 872M, False: 0]
  ------------------
 1066|   872M|        if (favorDecSpeed && (ipIndex - matchIndex < 8)) {
  ------------------
  |  Branch (1066:13): [True: 247M, False: 625M]
  |  Branch (1066:30): [True: 901k, False: 246M]
  ------------------
 1067|       |            /* do nothing:
 1068|       |             * favorDecSpeed intentionally skips matches with offset < 8 */
 1069|   871M|        } else if (matchIndex >= prefixIdx) {   /* within current Prefix */
  ------------------
  |  Branch (1069:20): [True: 806M, False: 65.5M]
  ------------------
 1070|   806M|            const BYTE* const matchPtr = prefixPtr + (matchIndex - prefixIdx);
 1071|   806M|            assert(matchPtr < ip);
  ------------------
  |  Branch (1071:13): [True: 0, False: 806M]
  |  Branch (1071:13): [True: 806M, False: 0]
  ------------------
 1072|   806M|            assert(longest >= 1);
  ------------------
  |  Branch (1072:13): [True: 0, False: 806M]
  |  Branch (1072:13): [True: 806M, False: 0]
  ------------------
 1073|   806M|            if (LZ4_read16(iLowLimit + longest - 1) == LZ4_read16(matchPtr - lookBackLength + longest - 1)) {
  ------------------
  |  Branch (1073:17): [True: 182M, False: 624M]
  ------------------
 1074|   182M|                if (LZ4_read32(matchPtr) == pattern) {
  ------------------
  |  Branch (1074:21): [True: 172M, False: 10.3M]
  ------------------
 1075|   172M|                    int const back = lookBackLength ? LZ4HC_countBack(ip, matchPtr, iLowLimit, prefixPtr) : 0;
  ------------------
  |  Branch (1075:38): [True: 138M, False: 33.7M]
  ------------------
 1076|   172M|                    matchLength = MINMATCH + (int)LZ4_count(ip+MINMATCH, matchPtr+MINMATCH, iHighLimit);
  ------------------
  |  |  243|   172M|#define MINMATCH 4
  ------------------
                                  matchLength = MINMATCH + (int)LZ4_count(ip+MINMATCH, matchPtr+MINMATCH, iHighLimit);
  ------------------
  |  |  243|   172M|#define MINMATCH 4
  ------------------
                                  matchLength = MINMATCH + (int)LZ4_count(ip+MINMATCH, matchPtr+MINMATCH, iHighLimit);
  ------------------
  |  |  243|   172M|#define MINMATCH 4
  ------------------
 1077|   172M|                    matchLength -= back;
 1078|   172M|                    if (matchLength > longest) {
  ------------------
  |  Branch (1078:25): [True: 15.5M, False: 156M]
  ------------------
 1079|  15.5M|                        longest = matchLength;
 1080|  15.5M|                        offset = (int)(ipIndex - matchIndex);
 1081|  15.5M|                        sBack = back;
 1082|  15.5M|                        DEBUGLOG(7, "Found match of len=%i within prefix, offset=%i, back=%i", longest, offset, -back);
  ------------------
  |  |  290|  15.5M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1083|  15.5M|                        HEX_CMP(7, ip + back, ip + back - offset, (size_t)matchLength);
 1084|  15.5M|            }   }   }
 1085|   806M|        } else {   /* lowestMatchIndex <= matchIndex < dictLimit : within Ext Dict */
 1086|  65.5M|            const BYTE* const matchPtr = dictStart + (matchIndex - dictIdx);
 1087|  65.5M|            assert(matchIndex >= dictIdx);
  ------------------
  |  Branch (1087:13): [True: 0, False: 65.5M]
  |  Branch (1087:13): [True: 65.5M, False: 0]
  ------------------
 1088|  65.5M|            if ( likely(matchIndex <= prefixIdx - 4)
  ------------------
  |  |  178|  65.5M|#define likely(expr)     expect((expr) != 0, 1)
  |  |  ------------------
  |  |  |  |  172|   131M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (172:33): [True: 65.5M, False: 4.92k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1089|  65.5M|              && (LZ4_read32(matchPtr) == pattern) ) {
  ------------------
  |  Branch (1089:18): [True: 53.0M, False: 12.4M]
  ------------------
 1090|  53.0M|                int back = 0;
 1091|  53.0M|                const BYTE* vLimit = ip + (prefixIdx - matchIndex);
 1092|  53.0M|                if (vLimit > iHighLimit) vLimit = iHighLimit;
  ------------------
  |  Branch (1092:21): [True: 16.5M, False: 36.4M]
  ------------------
 1093|  53.0M|                matchLength = (int)LZ4_count(ip+MINMATCH, matchPtr+MINMATCH, vLimit) + MINMATCH;
  ------------------
  |  |  243|  53.0M|#define MINMATCH 4
  ------------------
                              matchLength = (int)LZ4_count(ip+MINMATCH, matchPtr+MINMATCH, vLimit) + MINMATCH;
  ------------------
  |  |  243|  53.0M|#define MINMATCH 4
  ------------------
                              matchLength = (int)LZ4_count(ip+MINMATCH, matchPtr+MINMATCH, vLimit) + MINMATCH;
  ------------------
  |  |  243|  53.0M|#define MINMATCH 4
  ------------------
 1094|  53.0M|                if ((ip+matchLength == vLimit) && (vLimit < iHighLimit))
  ------------------
  |  Branch (1094:21): [True: 217k, False: 52.8M]
  |  Branch (1094:51): [True: 212k, False: 5.64k]
  ------------------
 1095|   212k|                    matchLength += LZ4_count(ip+matchLength, prefixPtr, iHighLimit);
 1096|  53.0M|                back = lookBackLength ? LZ4HC_countBack(ip, matchPtr, iLowLimit, dictStart) : 0;
  ------------------
  |  Branch (1096:24): [True: 5.99M, False: 47.0M]
  ------------------
 1097|  53.0M|                matchLength -= back;
 1098|  53.0M|                if (matchLength > longest) {
  ------------------
  |  Branch (1098:21): [True: 340k, False: 52.7M]
  ------------------
 1099|   340k|                    longest = matchLength;
 1100|   340k|                    offset = (int)(ipIndex - matchIndex);
 1101|   340k|                    sBack = back;
 1102|   340k|                    DEBUGLOG(7, "Found match of len=%i within dict, offset=%i, back=%i", longest, offset, -back);
  ------------------
  |  |  290|   340k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1103|   340k|                    HEX_CMP(7, ip + back, matchPtr + back, (size_t)matchLength);
 1104|   340k|        }   }   }
 1105|       |
 1106|   872M|        if (chainSwap && matchLength==longest && matchIndex + (U32)longest <= ipIndex) {   /* better match => select a better chain */
  ------------------
  |  Branch (1106:13): [True: 532M, False: 339M]
  |  Branch (1106:26): [True: 13.3M, False: 519M]
  |  Branch (1106:50): [True: 12.6M, False: 686k]
  ------------------
 1107|  12.6M|            U32 const distanceToNextMatch = LZ4HC_sparsestChain(chainTable, matchIndex, longest, &matchChainPos);
 1108|  12.6M|            assert(lookBackLength==0);   /* search forward only */
  ------------------
  |  Branch (1108:13): [True: 0, False: 12.6M]
  |  Branch (1108:13): [True: 12.6M, False: 0]
  ------------------
 1109|  12.6M|            if (distanceToNextMatch > 1) {
  ------------------
  |  Branch (1109:17): [True: 9.41M, False: 3.23M]
  ------------------
 1110|  9.41M|                if (distanceToNextMatch > matchIndex) break;   /* avoid overflow */
  ------------------
  |  Branch (1110:21): [True: 0, False: 9.41M]
  ------------------
 1111|  9.41M|                matchIndex -= distanceToNextMatch;
 1112|  9.41M|                continue;
 1113|  9.41M|        }   }
 1114|       |
 1115|   863M|        {   U32 const distNextMatch = DELTANEXTU16(chainTable, matchIndex);
  ------------------
  |  |  229|   863M|#define DELTANEXTU16(table, pos) table[(U16)(pos)]   /* faster */
  ------------------
 1116|   863M|            if (patternAnalysis && distNextMatch==1 && matchChainPos==0) {
  ------------------
  |  Branch (1116:17): [True: 743M, False: 120M]
  |  Branch (1116:36): [True: 186M, False: 557M]
  |  Branch (1116:56): [True: 144M, False: 41.3M]
  ------------------
 1117|   144M|                U32 const matchCandidateIdx = matchIndex-1;
 1118|   144M|                size_t forwardPatternLength, backLength;
 1119|       |                /* may be a repeated pattern */
 1120|   144M|                if (repeat == rep_untested) {
  ------------------
  |  Branch (1120:21): [True: 1.48M, False: 143M]
  ------------------
 1121|  1.48M|                    if ( ((pattern & 0xFFFF) == (pattern >> 16))
  ------------------
  |  Branch (1121:26): [True: 1.47M, False: 16.2k]
  ------------------
 1122|  1.48M|                      &  ((pattern & 0xFF)   == (pattern >> 24)) ) {
 1123|  1.47M|                        DEBUGLOG(7, "Repeat pattern detected, char %02X", pattern >> 24);
  ------------------
  |  |  290|  1.47M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1124|  1.47M|                        repeat = rep_confirmed;
 1125|  1.47M|                        srcPatternLength = LZ4HC_countPattern(ip+sizeof(pattern), iHighLimit, pattern) + sizeof(pattern);
 1126|  1.47M|                    } else {
 1127|  16.2k|                        repeat = rep_not;
 1128|  16.2k|                }   }
 1129|   144M|                if ( (repeat == rep_confirmed) && (matchCandidateIdx >= lowestMatchIndex)
  ------------------
  |  Branch (1129:22): [True: 141M, False: 2.94M]
  |  Branch (1129:51): [True: 141M, False: 2.41k]
  ------------------
 1130|   141M|                  && LZ4HC_protectDictEnd(prefixIdx, matchCandidateIdx)
  ------------------
  |  Branch (1130:22): [True: 141M, False: 0]
  ------------------
 1131|   141M|                  && LZ4HC_patternSegment(hc4, matchCandidateIdx, pattern, iHighLimit, lowestMatchIndex,
  ------------------
  |  Branch (1131:22): [True: 141M, False: 9.44k]
  ------------------
 1132|   141M|                                          &forwardPatternLength, &backLength) ) {
 1133|   141M|                    size_t const currentSegmentLength = backLength + forwardPatternLength;
 1134|       |                    /* if the full source pattern fits (and hasn't been reached yet), jump to its best position :
 1135|       |                     * at the end of the segment, it might be followed by more match.
 1136|       |                     * Otherwise, jump to the farthest position in the segment : the longest match, plus maybe some back */
 1137|   141M|                    int const fullPatternFits = (currentSegmentLength >= srcPatternLength)
  ------------------
  |  Branch (1137:49): [True: 93.1M, False: 48.6M]
  ------------------
 1138|  93.1M|                                             && (forwardPatternLength <= srcPatternLength);
  ------------------
  |  Branch (1138:49): [True: 41.5M, False: 51.5M]
  ------------------
 1139|   141M|                    U32 const newMatchIndex = fullPatternFits ?
  ------------------
  |  Branch (1139:47): [True: 41.5M, False: 100M]
  ------------------
 1140|  41.5M|                                              matchCandidateIdx + (U32)forwardPatternLength - (U32)srcPatternLength :
 1141|   141M|                                              matchCandidateIdx - (U32)backLength;
 1142|   141M|                    if (!LZ4HC_protectDictEnd(prefixIdx, newMatchIndex)) {
  ------------------
  |  Branch (1142:25): [True: 16.6k, False: 141M]
  ------------------
 1143|       |                        /* Can only happen if started in the prefix */
 1144|  16.6k|                        assert(newMatchIndex >= prefixIdx - 3 && newMatchIndex < prefixIdx && matchCandidateIdx >= prefixIdx);
  ------------------
  |  Branch (1144:25): [True: 0, False: 16.6k]
  |  Branch (1144:25): [True: 0, False: 0]
  |  Branch (1144:25): [True: 0, False: 0]
  |  Branch (1144:25): [True: 16.6k, False: 0]
  |  Branch (1144:25): [True: 16.6k, False: 0]
  |  Branch (1144:25): [True: 16.6k, False: 0]
  ------------------
 1145|  16.6k|                        matchIndex = prefixIdx;
 1146|  16.6k|                        continue;
 1147|  16.6k|                    }
 1148|   141M|                    matchIndex = newMatchIndex;
 1149|   141M|                    if (!fullPatternFits && lookBackLength==0) {  /* no back possible : the match length is known */
  ------------------
  |  Branch (1149:25): [True: 100M, False: 41.5M]
  |  Branch (1149:45): [True: 84.7M, False: 15.4M]
  ------------------
 1150|  84.7M|                        size_t const maxML = MIN(currentSegmentLength, srcPatternLength);
  ------------------
  |  |   81|  84.7M|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (81:22): [True: 42.2M, False: 42.5M]
  |  |  ------------------
  ------------------
 1151|  84.7M|                        if ((size_t)longest < maxML) {
  ------------------
  |  Branch (1151:29): [True: 569k, False: 84.1M]
  ------------------
 1152|   569k|                            assert(prefixPtr - prefixIdx + matchIndex != ip);
  ------------------
  |  Branch (1152:29): [True: 0, False: 569k]
  |  Branch (1152:29): [True: 569k, False: 0]
  ------------------
 1153|   569k|                            if ((size_t)(ip - prefixPtr) + prefixIdx - matchIndex > LZ4_DISTANCE_MAX) break;
  ------------------
  |  |  678|   569k|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (1153:33): [True: 0, False: 569k]
  ------------------
 1154|   569k|                            assert(maxML < 2 GB);
  ------------------
  |  Branch (1154:29): [True: 0, False: 569k]
  |  Branch (1154:29): [True: 569k, False: 0]
  ------------------
 1155|   569k|                            longest = (int)maxML;
 1156|   569k|                            offset = (int)(ipIndex - matchIndex);
 1157|   569k|                            assert(sBack == 0);
  ------------------
  |  Branch (1157:29): [True: 0, False: 569k]
  |  Branch (1157:29): [True: 569k, False: 0]
  ------------------
 1158|   569k|                            DEBUGLOG(7, "Found repeat pattern match of len=%i, offset=%i", longest, offset);
  ------------------
  |  |  290|   569k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1159|   569k|                        }
 1160|  84.7M|                        {   U32 const distToNextPattern = DELTANEXTU16(chainTable, matchIndex);
  ------------------
  |  |  229|  84.7M|#define DELTANEXTU16(table, pos) table[(U16)(pos)]   /* faster */
  ------------------
 1161|  84.7M|                            if (distToNextPattern > matchIndex) break;  /* avoid overflow */
  ------------------
  |  Branch (1161:33): [True: 0, False: 84.7M]
  ------------------
 1162|  84.7M|                            matchIndex -= distToNextPattern;
 1163|  84.7M|                    }   }
 1164|   141M|                    continue;
 1165|   141M|                }
 1166|   144M|        }   }   /* PA optimization */
 1167|       |
 1168|       |        /* follow current chain */
 1169|   721M|        matchIndex -= DELTANEXTU16(chainTable, matchIndex + matchChainPos);
  ------------------
  |  |  229|   721M|#define DELTANEXTU16(table, pos) table[(U16)(pos)]   /* faster */
  ------------------
 1170|       |
 1171|   721M|    }  /* while ((matchIndex>=lowestMatchIndex) && (nbAttempts)) */
 1172|       |
 1173|  87.2M|    if ( dict == usingDictCtxHc
  ------------------
  |  Branch (1173:10): [True: 0, False: 87.2M]
  ------------------
 1174|      0|      && nbAttempts > 0
  ------------------
  |  Branch (1174:10): [True: 0, False: 0]
  ------------------
 1175|      0|      && longest < maxLength
  ------------------
  |  Branch (1175:10): [True: 0, False: 0]
  ------------------
 1176|      0|      && withinStartDistance) {
  ------------------
  |  Branch (1176:10): [True: 0, False: 0]
  ------------------
 1177|      0|        size_t const dictEndOffset = (size_t)(dictCtx->end - dictCtx->prefixStart) + dictCtx->dictLimit;
 1178|      0|        U32 dictMatchIndex = dictCtx->hashTable[LZ4HC_hashPtr(ip)];
 1179|      0|        assert(dictEndOffset <= 1 GB);
  ------------------
  |  Branch (1179:9): [True: 0, False: 0]
  |  Branch (1179:9): [True: 0, False: 0]
  ------------------
 1180|      0|        matchIndex = dictMatchIndex + lowestMatchIndex - (U32)dictEndOffset;
 1181|      0|        if (dictMatchIndex>0) DEBUGLOG(7, "dictEndOffset = %zu, dictMatchIndex = %u => relative matchIndex = %i", dictEndOffset, dictMatchIndex, (int)dictMatchIndex - (int)dictEndOffset);
  ------------------
  |  |  290|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  |  Branch (1181:13): [True: 0, False: 0]
  ------------------
 1182|      0|        while (ipIndex - matchIndex <= LZ4_DISTANCE_MAX && longest < maxLength && nbAttempts--) {
  ------------------
  |  |  678|      0|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (1182:16): [True: 0, False: 0]
  |  Branch (1182:60): [True: 0, False: 0]
  |  Branch (1182:83): [True: 0, False: 0]
  ------------------
 1183|      0|            const BYTE* const matchPtr = dictCtx->prefixStart - dictCtx->dictLimit + dictMatchIndex;
 1184|       |
 1185|      0|            if (LZ4_read32(matchPtr) == pattern) {
  ------------------
  |  Branch (1185:17): [True: 0, False: 0]
  ------------------
 1186|      0|                int mlt;
 1187|      0|                int back = 0;
 1188|      0|                const BYTE* vLimit = ip + (dictEndOffset - dictMatchIndex);
 1189|      0|                if (vLimit > iHighLimit) vLimit = iHighLimit;
  ------------------
  |  Branch (1189:21): [True: 0, False: 0]
  ------------------
 1190|      0|                mlt = (int)LZ4_count(ip+MINMATCH, matchPtr+MINMATCH, vLimit) + MINMATCH;
  ------------------
  |  |  243|      0|#define MINMATCH 4
  ------------------
                              mlt = (int)LZ4_count(ip+MINMATCH, matchPtr+MINMATCH, vLimit) + MINMATCH;
  ------------------
  |  |  243|      0|#define MINMATCH 4
  ------------------
                              mlt = (int)LZ4_count(ip+MINMATCH, matchPtr+MINMATCH, vLimit) + MINMATCH;
  ------------------
  |  |  243|      0|#define MINMATCH 4
  ------------------
 1191|      0|                back = lookBackLength ? LZ4HC_countBack(ip, matchPtr, iLowLimit, dictCtx->prefixStart) : 0;
  ------------------
  |  Branch (1191:24): [True: 0, False: 0]
  ------------------
 1192|      0|                mlt -= back;
 1193|      0|                if (mlt > longest) {
  ------------------
  |  Branch (1193:21): [True: 0, False: 0]
  ------------------
 1194|      0|                    longest = mlt;
 1195|      0|                    offset = (int)(ipIndex - matchIndex);
 1196|      0|                    sBack = back;
 1197|      0|                    DEBUGLOG(7, "found match of length %i within extDictCtx", longest);
  ------------------
  |  |  290|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1198|      0|            }   }
 1199|       |
 1200|      0|            {   U32 const nextOffset = DELTANEXTU16(dictCtx->chainTable, dictMatchIndex);
  ------------------
  |  |  229|      0|#define DELTANEXTU16(table, pos) table[(U16)(pos)]   /* faster */
  ------------------
 1201|      0|                dictMatchIndex -= nextOffset;
 1202|      0|                matchIndex -= nextOffset;
 1203|      0|    }   }   }
 1204|       |
 1205|  87.2M|    {   LZ4HC_match_t md;
 1206|  87.2M|        assert(longest >= 0);
  ------------------
  |  Branch (1206:9): [True: 0, False: 87.2M]
  |  Branch (1206:9): [True: 87.2M, False: 0]
  ------------------
 1207|  87.2M|        md.len = longest;
 1208|  87.2M|        md.off = offset;
 1209|  87.2M|        md.back = sBack;
 1210|  87.2M|        return md;
 1211|  87.2M|    }
 1212|  87.2M|}
lz4hc.c:LZ4HC_sparsestChain:
  961|  12.6M|{
  962|  12.6M|    int const kTrigger = 4;
  963|  12.6M|    U32 distanceToNextMatch = 1;
  964|  12.6M|    int const end = longest - MINMATCH + 1;
  ------------------
  |  |  243|  12.6M|#define MINMATCH 4
  ------------------
  965|  12.6M|    int step = 1;
  966|  12.6M|    int accel = 1 << kTrigger;
  967|  12.6M|    int pos;
  968|   253M|    for (pos = 0; pos < end; pos += step) {
  ------------------
  |  Branch (968:19): [True: 240M, False: 12.6M]
  ------------------
  969|   240M|        U32 const candidateDist = DELTANEXTU16(chainTable, matchIndex + (U32)pos);
  ------------------
  |  |  229|   240M|#define DELTANEXTU16(table, pos) table[(U16)(pos)]   /* faster */
  ------------------
  970|   240M|        step = (accel++ >> kTrigger);
  971|   240M|        if (candidateDist > distanceToNextMatch) {
  ------------------
  |  Branch (971:13): [True: 12.1M, False: 228M]
  ------------------
  972|  12.1M|            distanceToNextMatch = candidateDist;
  973|  12.1M|            *matchChainPosPtr = (U32)pos;
  974|  12.1M|            accel = 1 << kTrigger;
  975|  12.1M|    }   }
  976|  12.6M|    return distanceToNextMatch;
  977|  12.6M|}
lz4hc.c:LZ4HC_countPattern:
  894|   143M|{
  895|   143M|    const BYTE* const iStart = ip;
  896|   143M|    reg_t const pattern = (sizeof(pattern)==8) ?
  ------------------
  |  Branch (896:27): [True: 143M, Folded]
  ------------------
  897|   143M|        (reg_t)pattern32 + (((reg_t)pattern32) << (sizeof(pattern)*4)) : pattern32;
  898|       |
  899|   245M|    while (likely(ip < iEnd-(sizeof(pattern)-1))) {
  900|   245M|        reg_t const diff = LZ4_read_ARCH(ip) ^ pattern;
  901|   245M|        if (!diff) { ip+=sizeof(pattern); continue; }
  ------------------
  |  Branch (901:13): [True: 102M, False: 143M]
  ------------------
  902|   143M|        ip += LZ4_NbCommonBytes(diff);
  903|   143M|        return (unsigned)(ip - iStart);
  904|   245M|    }
  905|       |
  906|  84.6k|    if (LZ4_isLittleEndian()) {
  ------------------
  |  Branch (906:9): [True: 84.6k, False: 0]
  ------------------
  907|  84.6k|        reg_t patternByte = pattern;
  908|   255k|        while ((ip<iEnd) && (*ip == (BYTE)patternByte)) {
  ------------------
  |  Branch (908:16): [True: 202k, False: 52.3k]
  |  Branch (908:29): [True: 170k, False: 32.2k]
  ------------------
  909|   170k|            ip++; patternByte >>= 8;
  910|   170k|        }
  911|  84.6k|    } else {  /* big endian */
  912|      0|        U32 bitOffset = (sizeof(pattern)*8) - 8;
  913|      0|        while (ip < iEnd) {
  ------------------
  |  Branch (913:16): [True: 0, False: 0]
  ------------------
  914|      0|            BYTE const byte = (BYTE)(pattern >> bitOffset);
  915|      0|            if (*ip != byte) break;
  ------------------
  |  Branch (915:17): [True: 0, False: 0]
  ------------------
  916|      0|            ip ++; bitOffset -= 8;
  917|      0|    }   }
  918|       |
  919|  84.6k|    return (unsigned)(ip - iStart);
  920|   143M|}
lz4hc.c:LZ4HC_protectDictEnd:
  948|   283M|{
  949|   283M|    return ((U32)((dictLimit - 1) - matchIndex) >= 3);
  950|   283M|}
lz4hc.c:LZ4HC_patternSegment:
  988|   141M|{
  989|   141M|    const BYTE* const prefixPtr = hc4->prefixStart;
  990|   141M|    U32 const prefixIdx = hc4->dictLimit;
  991|   141M|    const BYTE* const dictStart = hc4->dictStart;
  992|   141M|    U32 const dictIdx = hc4->lowLimit;
  993|   141M|    const BYTE* const dictEnd = dictStart + prefixIdx - dictIdx;
  994|   141M|    int const extDict = candidateIdx < prefixIdx;
  995|   141M|    const BYTE* const matchPtr = extDict ? dictStart + (candidateIdx - dictIdx) : prefixPtr + (candidateIdx - prefixIdx);
  ------------------
  |  Branch (995:34): [True: 11.8M, False: 130M]
  ------------------
  996|   141M|    size_t forward, back;
  997|   141M|    if (LZ4_read32(matchPtr) != pattern) return 0;
  ------------------
  |  Branch (997:9): [True: 9.44k, False: 141M]
  ------------------
  998|       |
  999|   141M|    {   const BYTE* const iLimit = extDict ? dictEnd : iHighLimit;
  ------------------
  |  Branch (999:36): [True: 11.8M, False: 129M]
  ------------------
 1000|   141M|        forward = LZ4HC_countPattern(matchPtr+sizeof(pattern), iLimit, pattern) + sizeof(pattern);
 1001|   141M|        if (extDict && matchPtr + forward == iLimit) {   /* continues into the prefix */
  ------------------
  |  Branch (1001:13): [True: 11.8M, False: 129M]
  |  Branch (1001:24): [True: 32.0k, False: 11.7M]
  ------------------
 1002|  32.0k|            U32 const rotatedPattern = LZ4HC_rotatePattern(forward, pattern);
 1003|  32.0k|            forward += LZ4HC_countPattern(prefixPtr, iHighLimit, rotatedPattern);
 1004|  32.0k|    }   }
 1005|       |
 1006|   141M|    back = LZ4HC_reverseCountPattern(matchPtr, extDict ? dictStart : prefixPtr, pattern);
  ------------------
  |  Branch (1006:48): [True: 11.8M, False: 129M]
  ------------------
 1007|   141M|    if (!extDict && matchPtr - back == prefixPtr && dictIdx < prefixIdx) {   /* continues into the external dictionary */
  ------------------
  |  Branch (1007:9): [True: 129M, False: 11.8M]
  |  Branch (1007:21): [True: 197k, False: 129M]
  |  Branch (1007:53): [True: 81.4k, False: 115k]
  ------------------
 1008|  81.4k|        U32 const rotatedPattern = LZ4HC_rotatePattern((U32)(-(int)back), pattern);
 1009|  81.4k|        back += LZ4HC_reverseCountPattern(dictEnd, dictStart, rotatedPattern);
 1010|  81.4k|    }
 1011|       |    /* don't go below lowestMatchIndex */
 1012|   141M|    back = candidateIdx - MAX(candidateIdx - (U32)back, lowestMatchIndex);
  ------------------
  |  |   82|   141M|#define MAX(a,b)   ( (a) > (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (82:22): [True: 141M, False: 200k]
  |  |  ------------------
  ------------------
 1013|   141M|    assert(candidateIdx - back >= lowestMatchIndex);
  ------------------
  |  Branch (1013:5): [True: 0, False: 141M]
  |  Branch (1013:5): [True: 141M, False: 0]
  ------------------
 1014|       |
 1015|   141M|    *forwardPtr = forward;
 1016|   141M|    *backPtr = back;
 1017|   141M|    return 1;
 1018|   141M|}
lz4hc.c:LZ4HC_rotatePattern:
  884|   113k|{
  885|   113k|    size_t const bitsToRotate = (rotate & (sizeof(pattern) - 1)) << 3;
  886|   113k|    if (bitsToRotate == 0) return pattern;
  ------------------
  |  Branch (886:9): [True: 30.1k, False: 83.3k]
  ------------------
  887|  83.3k|    return LZ4HC_rotl32(pattern, (int)bitsToRotate);
  ------------------
  |  |  879|  83.3k|#  define LZ4HC_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  ------------------
  888|   113k|}
lz4hc.c:LZ4HC_reverseCountPattern:
  927|   141M|{
  928|   141M|    const BYTE* const iStart = ip;
  929|       |
  930|  1.85G|    while (likely(ip >= iLow+4)) {
  931|  1.85G|        if (LZ4_read32(ip-4) != pattern) break;
  ------------------
  |  Branch (931:13): [True: 141M, False: 1.71G]
  ------------------
  932|  1.71G|        ip -= 4;
  933|  1.71G|    }
  934|   141M|    {   const BYTE* bytePtr = (const BYTE*)(&pattern) + 3; /* works for any endianness */
  935|   357M|        while (likely(ip>iLow)) {
  936|   357M|            if (ip[-1] != *bytePtr) break;
  ------------------
  |  Branch (936:17): [True: 141M, False: 215M]
  ------------------
  937|   215M|            ip--; bytePtr--;
  938|   215M|    }   }
  939|   141M|    return (unsigned)(iStart - ip);
  940|   141M|}
lz4hc.c:LZ4HC_splitOverlap:
 1242|   604k|{
 1243|   604k|    int const gap = (int)(*start2 - ip);
 1244|   604k|    int newML = MIN(ml1, OPTIMAL_ML);
  ------------------
  |  |   81|   604k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (81:22): [True: 494k, False: 110k]
  |  |  ------------------
  ------------------
 1245|   604k|    assert(gap < OPTIMAL_ML);
  ------------------
  |  Branch (1245:5): [True: 0, False: 604k]
  |  Branch (1245:5): [True: 604k, False: 0]
  ------------------
 1246|   604k|    if (newML > gap + m2->len - MINMATCH)
  ------------------
  |  |  243|   604k|#define MINMATCH 4
  ------------------
  |  Branch (1246:9): [True: 634, False: 603k]
  ------------------
 1247|    634|        newML = gap + m2->len - MINMATCH;
  ------------------
  |  |  243|    634|#define MINMATCH 4
  ------------------
 1248|   604k|    if (newML > gap) {   /* shift m2 */
  ------------------
  |  Branch (1248:9): [True: 542k, False: 61.8k]
  ------------------
 1249|   542k|        *start2 += newML - gap;
 1250|   542k|        m2->len -= newML - gap;
 1251|   542k|    }
 1252|   604k|    return newML;
 1253|   604k|}
lz4hc.c:LZ4HC_compress_optimal:
 2164|  19.0k|{
 2165|  19.0k|#if defined(LZ4HC_HEAPMODE) && LZ4HC_HEAPMODE==1
 2166|  19.0k|    LZ4HC_optimal_t* const opt = (LZ4HC_optimal_t*)ALLOC(sizeof(LZ4HC_optimal_t) * (LZ4_OPT_NUM + TRAILING_LITERALS));
  ------------------
  |  |  226|  19.0k|# define ALLOC(s)          malloc(s)
  ------------------
 2167|  19.0k|    int result;
 2168|  19.0k|    if (opt == NULL) return 0;
  ------------------
  |  Branch (2168:9): [True: 0, False: 19.0k]
  ------------------
 2169|  19.0k|    result = LZ4HC_compress_optimal_internal(ctx, source, dst, srcSizePtr, dstCapacity,
 2170|  19.0k|                    nbSearches, nbSearchesSeq, targetLength, limit, dict, favorDecSpeed, opt);
 2171|  19.0k|    FREEMEM(opt);
  ------------------
  |  |  228|  19.0k|# define FREEMEM(p)        free(p)
  ------------------
 2172|  19.0k|    return result;
 2173|       |#else
 2174|       |    LZ4HC_optimal_t opt[LZ4_OPT_NUM + TRAILING_LITERALS];   /* ~64 KB, which can be a bit large for some stacks... */
 2175|       |    return LZ4HC_compress_optimal_internal(ctx, source, dst, srcSizePtr, dstCapacity,
 2176|       |                    nbSearches, nbSearchesSeq, targetLength, limit, dict, favorDecSpeed, opt);
 2177|       |#endif
 2178|  19.0k|}
lz4hc.c:LZ4HC_compress_optimal_internal:
 2021|  19.0k|{
 2022|  19.0k|    const BYTE* ip = (const BYTE*) source;
 2023|  19.0k|    const BYTE* anchor = ip;
 2024|  19.0k|    const BYTE* const iend = ip + *srcSizePtr;
 2025|  19.0k|    const BYTE* const mflimit = iend - MFLIMIT;
  ------------------
  |  |  247|  19.0k|#define MFLIMIT       12   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
 2026|  19.0k|    const BYTE* const matchlimit = iend - LASTLITERALS;
  ------------------
  |  |  246|  19.0k|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
 2027|  19.0k|    BYTE* op = (BYTE*) dst;
 2028|       |    /* fillOutput : keep room for the final run of literals (LZ4 format restriction) */
 2029|  19.0k|    BYTE* const oend = op + dstCapacity - ((limit == fillOutput) ? LASTLITERALS : 0);
  ------------------
  |  |  246|      0|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  |  Branch (2029:44): [True: 0, False: 19.0k]
  ------------------
 2030|  19.0k|    int const sufficientLen = MIN(targetLength, LZ4_OPT_NUM-1);
  ------------------
  |  |   81|  19.0k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (81:22): [True: 10.7k, False: 8.35k]
  |  |  ------------------
  ------------------
 2031|       |
 2032|  19.0k|    DEBUGLOG(5, "LZ4HC_compress_optimal(dst=%p, dstCapa=%u)", dst, (unsigned)dstCapacity);
  ------------------
  |  |  290|  19.0k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2033|       |
 2034|       |    /* preconditions verifications */
 2035|  19.0k|    assert(dstCapacity > 0);
  ------------------
  |  Branch (2035:5): [True: 0, False: 19.0k]
  |  Branch (2035:5): [True: 19.0k, False: 0]
  ------------------
 2036|  19.0k|    assert(dst != NULL);
  ------------------
  |  Branch (2036:5): [True: 0, False: 19.0k]
  |  Branch (2036:5): [True: 19.0k, False: 0]
  ------------------
 2037|  19.0k|    assert(*srcSizePtr > 0);
  ------------------
  |  Branch (2037:5): [True: 0, False: 19.0k]
  |  Branch (2037:5): [True: 19.0k, False: 0]
  ------------------
 2038|  19.0k|    assert(source != NULL);
  ------------------
  |  Branch (2038:5): [True: 0, False: 19.0k]
  |  Branch (2038:5): [True: 19.0k, False: 0]
  ------------------
 2039|  19.0k|    assert(opt != NULL);
  ------------------
  |  Branch (2039:5): [True: 0, False: 19.0k]
  |  Branch (2039:5): [True: 19.0k, False: 0]
  ------------------
 2040|  19.0k|    assert(nbSearchesSeq >= 1);
  ------------------
  |  Branch (2040:5): [True: 0, False: 19.0k]
  |  Branch (2040:5): [True: 19.0k, False: 0]
  ------------------
 2041|       |
 2042|  19.0k|    *srcSizePtr = 0;
 2043|       |
 2044|       |    /* Main Loop */
 2045|  30.4M|    while (ip <= mflimit) {
  ------------------
  |  Branch (2045:12): [True: 30.3M, False: 18.2k]
  ------------------
 2046|  30.3M|        int const llen = LZ4HC_pricedLitlen((int)(ip - anchor));
 2047|  30.3M|        int cur, lastPos;
 2048|  30.3M|        int lastSeqPos;         /* position of the last sequence to encode */
 2049|  30.3M|        LZ4HC_match_t lastSeq;
 2050|       |
 2051|  30.3M|        LZ4HC_match_t const firstMatch = LZ4HC_FindLongestMatch(ctx, ip, matchlimit, nbSearches, dict, favorDecSpeed);
 2052|  30.3M|        if (firstMatch.len==0) { ip++; continue; }
  ------------------
  |  Branch (2052:13): [True: 29.1M, False: 1.19M]
  ------------------
 2053|       |
 2054|  1.19M|        if (firstMatch.len > sufficientLen) {
  ------------------
  |  Branch (2054:13): [True: 38.8k, False: 1.15M]
  ------------------
 2055|       |            /* good enough solution : immediate encoding */
 2056|  38.8k|            lastSeqPos = 0;
 2057|  38.8k|            lastSeq = firstMatch;
 2058|  38.8k|            goto encode;
 2059|  38.8k|        }
 2060|       |
 2061|       |        /* set prices for first positions (literals) */
 2062|  1.15M|        {   int rPos;
 2063|  5.77M|            for (rPos = 0 ; rPos < MINMATCH ; rPos++)
  ------------------
  |  |  243|  5.77M|#define MINMATCH 4
  ------------------
  |  Branch (2063:29): [True: 4.62M, False: 1.15M]
  ------------------
 2064|  4.62M|                LZ4HC_setLiteral(opt, rPos, llen + rPos, LZ4HC_literalsPrice(llen + rPos));
 2065|  1.15M|        }
 2066|  1.15M|        lastPos = LZ4HC_addMatch(opt, 0, firstMatch, 0, favorDecSpeed);
 2067|       |
 2068|       |        /* check further positions */
 2069|  36.7M|        for (cur = 1; cur < lastPos; cur++) {
  ------------------
  |  Branch (2069:23): [True: 35.5M, False: 1.14M]
  ------------------
 2070|  35.5M|            const BYTE* const curPtr = ip + cur;
 2071|  35.5M|            LZ4HC_match_t newMatch;
 2072|  35.5M|            int nbS = nbSearches;
 2073|       |
 2074|  35.5M|            if (curPtr > mflimit) break;
  ------------------
  |  Branch (2074:17): [True: 8.29k, False: 35.5M]
  ------------------
 2075|  35.5M|            DEBUGLOG(7, "rPos:%u[%u] vs [%u]%u",
  ------------------
  |  |  290|  35.5M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2076|  35.5M|                    cur, opt[cur].price, opt[cur+1].price, cur+1);
 2077|       |            /* not useful to search here if next position has same (or lower) cost */
 2078|  35.5M|            if (opt[cur+1].price <= opt[cur].price) continue;
  ------------------
  |  Branch (2078:17): [True: 31.1M, False: 4.36M]
  ------------------
 2079|       |            /* favorDecSpeed : next position costs less than one more byte, the difference comes from sequences.
 2080|       |             * A match starting here might save some : worth a cheaper search, if close to lastPos */
 2081|  4.36M|            if (favorDecSpeed && (opt[cur+1].price < opt[cur].price + LZ4HC_PRICE_SCALE)) {
  ------------------
  |  | 1874|  2.55M|#define LZ4HC_PRICE_SCALE 4
  ------------------
  |  Branch (2081:17): [True: 2.55M, False: 1.80M]
  |  Branch (2081:34): [True: 747k, False: 1.81M]
  ------------------
 2082|   747k|                if (lastPos - cur > LZ4HC_SEQ_SEARCH_DIST) continue;
  ------------------
  |  | 1883|   747k|#define LZ4HC_SEQ_SEARCH_DIST  4
  ------------------
  |  Branch (2082:21): [True: 451k, False: 296k]
  ------------------
 2083|   296k|                nbS = nbSearchesSeq;
 2084|   296k|            }
 2085|       |
 2086|  3.91M|            newMatch = LZ4HC_FindLongestMatch(ctx, curPtr, matchlimit, nbS, dict, favorDecSpeed);
 2087|  3.91M|            if (!newMatch.len) continue;
  ------------------
  |  Branch (2087:17): [True: 779k, False: 3.13M]
  ------------------
 2088|       |
 2089|  3.13M|            if ( (newMatch.len > sufficientLen)
  ------------------
  |  Branch (2089:18): [True: 6.77k, False: 3.12M]
  ------------------
 2090|  3.12M|              || (newMatch.len + cur >= LZ4_OPT_NUM) ) {
  ------------------
  |  |   77|  3.12M|#define LZ4_OPT_NUM   (1<<12)
  ------------------
  |  Branch (2090:18): [True: 504, False: 3.12M]
  ------------------
 2091|       |                /* immediate encoding */
 2092|  7.27k|                lastSeqPos = cur;
 2093|  7.27k|                lastSeq = newMatch;
 2094|  7.27k|                goto encode;
 2095|  7.27k|            }
 2096|       |
 2097|  3.12M|            lastPos = LZ4HC_addMatch(opt, cur, newMatch, lastPos, favorDecSpeed);
 2098|  3.12M|        }  /* for (cur = 1; cur < lastPos; cur++) */
 2099|       |
 2100|  1.15M|        assert(lastPos < LZ4_OPT_NUM + TRAILING_LITERALS);
  ------------------
  |  Branch (2100:9): [True: 0, False: 1.14M]
  |  Branch (2100:9): [True: 1.14M, False: 0]
  ------------------
 2101|  1.14M|        lastSeq.len = opt[lastPos].mlen;
 2102|  1.14M|        lastSeq.off = opt[lastPos].off;
 2103|  1.14M|        lastSeqPos = lastPos - lastSeq.len;
 2104|       |
 2105|  1.19M|encode: /* lastSeqPos and lastSeq must be set */
 2106|  1.19M|        assert(0 <= lastSeqPos && lastSeqPos < LZ4_OPT_NUM);
  ------------------
  |  Branch (2106:9): [True: 0, False: 1.19M]
  |  Branch (2106:9): [True: 0, False: 0]
  |  Branch (2106:9): [True: 1.19M, False: 0]
  |  Branch (2106:9): [True: 1.19M, False: 0]
  ------------------
 2107|  1.19M|        DEBUGLOG(6, "reverse traversal, looking for shortest path (lastSeqPos=%i)", lastSeqPos);
  ------------------
  |  |  290|  1.19M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2108|       |        /* opt[pos] describes the step ending at pos.
 2109|       |         * Walk the path backward, moving each step to its starting position instead */
 2110|  1.19M|        {   int pos = lastSeqPos;
 2111|  1.19M|            int mlen = lastSeq.len;
 2112|  1.19M|            int off = lastSeq.off;
 2113|  1.78M|            while (pos > 0) {
  ------------------
  |  Branch (2113:20): [True: 592k, False: 1.19M]
  ------------------
 2114|   592k|                int const prevMlen = opt[pos].mlen;
 2115|   592k|                int const prevOff = opt[pos].off;
 2116|   592k|                opt[pos].mlen = mlen;
 2117|   592k|                opt[pos].off = off;
 2118|   592k|                mlen = prevMlen;
 2119|   592k|                off = prevOff;
 2120|   592k|                assert(0 < mlen && mlen <= pos);
  ------------------
  |  Branch (2120:17): [True: 0, False: 592k]
  |  Branch (2120:17): [True: 0, False: 0]
  |  Branch (2120:17): [True: 592k, False: 0]
  |  Branch (2120:17): [True: 592k, False: 0]
  ------------------
 2121|   592k|                pos -= mlen;
 2122|   592k|            }
 2123|       |            /* first step of the path; note : opt[0] isn't necessarily initialized */
 2124|  1.19M|            opt[0].mlen = mlen;
 2125|  1.19M|            opt[0].off = off;
 2126|  1.19M|        }
 2127|       |
 2128|       |        /* encode all recorded sequences in order */
 2129|  1.19M|        {   int rPos = 0;  /* relative position (to ip) */
 2130|  2.98M|            while (rPos <= lastSeqPos) {
  ------------------
  |  Branch (2130:20): [True: 1.78M, False: 1.19M]
  ------------------
 2131|  1.78M|                int const ml = opt[rPos].mlen;
 2132|  1.78M|                int const offset = opt[rPos].off;
 2133|  1.78M|                if (ml == 1) { ip++; rPos++; continue; }  /* literal */
  ------------------
  |  Branch (2133:21): [True: 340k, False: 1.44M]
  ------------------
 2134|  1.44M|                rPos += ml;
 2135|  1.44M|                assert(ml >= MINMATCH);
  ------------------
  |  Branch (2135:17): [True: 0, False: 1.44M]
  |  Branch (2135:17): [True: 1.44M, False: 0]
  ------------------
 2136|  1.44M|                assert((offset >= 1) && (offset <= LZ4_DISTANCE_MAX));
  ------------------
  |  Branch (2136:17): [True: 0, False: 1.44M]
  |  Branch (2136:17): [True: 0, False: 0]
  |  Branch (2136:17): [True: 1.44M, False: 0]
  |  Branch (2136:17): [True: 1.44M, False: 0]
  ------------------
 2137|  1.44M|                if ( LZ4HC_encodeSequence(UPDATABLE(ip, op, anchor), ml, offset, limit, oend) ) {  /* updates ip, op and anchor */
  ------------------
  |  |  231|  1.44M|#define UPDATABLE(ip, op, anchor) &ip, &op, &anchor
  ------------------
  |  Branch (2137:22): [True: 825, False: 1.44M]
  ------------------
 2138|    825|                    if (limit != fillOutput) return 0;  /* compression failed */
  ------------------
  |  Branch (2138:25): [True: 825, False: 0]
  ------------------
 2139|      0|                    LZ4HC_encodeLastSequence_fillOutput(UPDATABLE(ip, op, anchor), ml, offset, oend);
  ------------------
  |  |  231|      0|#define UPDATABLE(ip, op, anchor) &ip, &op, &anchor
  ------------------
 2140|      0|                    goto _last_literals;
 2141|    825|        }   }   }
 2142|  1.19M|    }  /* while (ip <= mflimit) */
 2143|       |
 2144|  18.2k|_last_literals:
 2145|  18.2k|    if (LZ4HC_encodeLastLiterals(UPDATABLE(ip, op, anchor), iend, limit, oend))
  ------------------
  |  |  231|  18.2k|#define UPDATABLE(ip, op, anchor) &ip, &op, &anchor
  ------------------
  |  Branch (2145:9): [True: 7.03k, False: 11.2k]
  ------------------
 2146|  7.03k|        return 0;  /* not enough space in @dst */
 2147|       |
 2148|       |    /* End */
 2149|  11.2k|    *srcSizePtr = (int) (((const char*)ip) - source);
 2150|  11.2k|    return (int) ((char*)op-dst);
 2151|  18.2k|}
lz4hc.c:LZ4HC_pricedLitlen:
 1913|  30.3M|{
 1914|  30.3M|    int const reduceFrom = (int)RUN_MASK + 255;
  ------------------
  |  |  264|  30.3M|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  263|  30.3M|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|  30.3M|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1915|  30.3M|    assert(llen >= 0);
  ------------------
  |  Branch (1915:5): [True: 0, False: 30.3M]
  |  Branch (1915:5): [True: 30.3M, False: 0]
  ------------------
 1916|  30.3M|    if (llen < reduceFrom) return llen;
  ------------------
  |  Branch (1916:9): [True: 17.0M, False: 13.3M]
  ------------------
 1917|  13.3M|    return reduceFrom + ((llen - (int)RUN_MASK) % 255);
  ------------------
  |  |  264|  13.3M|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  263|  13.3M|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|  13.3M|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1918|  30.3M|}
lz4hc.c:LZ4HC_FindLongestMatch:
 1926|  34.2M|{
 1927|  34.2M|    LZ4HC_match_t const match0 = { 0 , 0, 0 };
 1928|       |    /* note : LZ4HC_InsertAndGetWiderMatch() can extend a match backward (md.back < 0),
 1929|       |     * but not here, since iLowLimit == ip */
 1930|  34.2M|    LZ4HC_match_t md = LZ4HC_InsertAndGetWiderMatch(ctx, ip, ip, iHighLimit, MINMATCH-1, nbSearches, 1 /*patternAnalysis*/, 1 /*chainSwap*/, dict, favorDecSpeed);
  ------------------
  |  |  243|  34.2M|#define MINMATCH 4
  ------------------
 1931|  34.2M|    assert(md.back == 0);
  ------------------
  |  Branch (1931:5): [True: 0, False: 34.2M]
  |  Branch (1931:5): [True: 34.2M, False: 0]
  ------------------
 1932|  34.2M|    if (md.len < MINMATCH) return match0;
  ------------------
  |  |  243|  34.2M|#define MINMATCH 4
  ------------------
  |  Branch (1932:9): [True: 29.9M, False: 4.32M]
  ------------------
 1933|  4.32M|    if (favorDecSpeed) {
  ------------------
  |  Branch (1933:9): [True: 2.36M, False: 1.96M]
  ------------------
 1934|  2.36M|        if ((md.len>18) & (md.len<=36)) md.len=18;   /* favor dec.speed (shortcut) */
  ------------------
  |  Branch (1934:13): [True: 335k, False: 2.02M]
  ------------------
 1935|  2.36M|    }
 1936|  4.32M|    return md;
 1937|  34.2M|}
lz4hc.c:LZ4HC_setLiteral:
 1941|  17.4M|{
 1942|  17.4M|    opt[pos].mlen = 1;
 1943|  17.4M|    opt[pos].off = 0;
 1944|  17.4M|    opt[pos].litlen = litlen;
 1945|  17.4M|    opt[pos].price = price;
 1946|  17.4M|    DEBUGLOG(7, "rPos:%3i => price:%3i (litlen=%i)", pos, price, litlen);
  ------------------
  |  |  290|  17.4M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1947|  17.4M|}
lz4hc.c:LZ4HC_literalsPrice:
 1886|   180M|{
 1887|   180M|    int price = litlen;
 1888|   180M|    assert(litlen >= 0);
  ------------------
  |  Branch (1888:5): [True: 0, False: 180M]
  |  Branch (1888:5): [True: 180M, False: 0]
  ------------------
 1889|   180M|    if (litlen >= (int)RUN_MASK)
  ------------------
  |  |  264|   180M|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  263|   180M|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|   180M|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1889:9): [True: 6.63M, False: 173M]
  ------------------
 1890|  6.63M|        price += 1 + ((litlen-(int)RUN_MASK) / 255);
  ------------------
  |  |  264|  6.63M|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  263|  6.63M|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  261|  6.63M|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1891|   180M|    return price * LZ4HC_PRICE_SCALE;
  ------------------
  |  | 1874|   180M|#define LZ4HC_PRICE_SCALE 4
  ------------------
 1892|   180M|}
lz4hc.c:LZ4HC_addMatch:
 1974|  4.27M|{
 1975|  4.27M|    int const ll = opt[cur].litlen;
 1976|  4.27M|    int const basePrice = LZ4HC_runStartPrice(opt, cur) + (favorDecSpeed ? LZ4HC_SEQ_PRICE_FDS : 0);
  ------------------
  |  | 1882|  2.34M|#define LZ4HC_SEQ_PRICE_FDS    1
  ------------------
  |  Branch (1976:60): [True: 2.34M, False: 1.93M]
  ------------------
 1977|  4.27M|    int ml;
 1978|  4.27M|    assert(cur + match.len < LZ4_OPT_NUM);
  ------------------
  |  Branch (1978:5): [True: 0, False: 4.27M]
  |  Branch (1978:5): [True: 4.27M, False: 0]
  ------------------
 1979|  4.27M|    assert((U32)favorDecSpeed <= 1);
  ------------------
  |  Branch (1979:5): [True: 0, False: 4.27M]
  |  Branch (1979:5): [True: 4.27M, False: 0]
  ------------------
 1980|   167M|    for (ml = MINMATCH; ml <= match.len; ml++) {
  ------------------
  |  |  243|  4.27M|#define MINMATCH 4
  ------------------
  |  Branch (1980:25): [True: 162M, False: 4.27M]
  ------------------
 1981|   162M|        int const pos = cur + ml;
 1982|   162M|        int const price = basePrice + LZ4HC_sequencePrice(ll, ml);
 1983|       |        /* on equal price, favorDecSpeed keeps the existing solution */
 1984|   162M|        if ( pos > lastPos + TRAILING_LITERALS
  ------------------
  |  | 1870|   325M|#define TRAILING_LITERALS 3
  ------------------
  |  Branch (1984:14): [True: 32.7M, False: 130M]
  ------------------
 1985|   130M|          || price <= opt[pos].price - (int)favorDecSpeed) {
  ------------------
  |  Branch (1985:14): [True: 3.81M, False: 126M]
  ------------------
 1986|  36.5M|            LZ4HC_setMatch(opt, pos, ml, match.off, price);
 1987|  36.5M|            if ((ml == match.len) && (lastPos < pos)) lastPos = pos;
  ------------------
  |  Branch (1987:17): [True: 1.97M, False: 34.5M]
  |  Branch (1987:38): [True: 1.95M, False: 24.1k]
  ------------------
 1988|  36.5M|    }   }
 1989|       |
 1990|       |    /* complete following positions with literals */
 1991|  4.27M|    {   int addLit;
 1992|  4.27M|        assert(opt[lastPos].mlen >= MINMATCH);
  ------------------
  |  Branch (1992:9): [True: 0, False: 4.27M]
  |  Branch (1992:9): [True: 4.27M, False: 0]
  ------------------
 1993|  17.1M|        for (addLit = 1; addLit <= TRAILING_LITERALS; addLit++)
  ------------------
  |  | 1870|  17.1M|#define TRAILING_LITERALS 3
  ------------------
  |  Branch (1993:26): [True: 12.8M, False: 4.27M]
  ------------------
 1994|  12.8M|            LZ4HC_setLiteral(opt, lastPos + addLit, addLit,
 1995|  12.8M|                             opt[lastPos].price + LZ4HC_literalsPrice(addLit));
 1996|  4.27M|    }
 1997|  4.27M|    return lastPos;
 1998|  4.27M|}
lz4hc.c:LZ4HC_runStartPrice:
 1962|  4.27M|{
 1963|  4.27M|    int const ll = opt[pos].litlen;
 1964|  4.27M|    return (ll <= pos) ? opt[pos - ll].price : 0;
  ------------------
  |  Branch (1964:12): [True: 2.60M, False: 1.67M]
  ------------------
 1965|  4.27M|}
lz4hc.c:LZ4HC_sequencePrice:
 1896|   162M|{
 1897|   162M|    int price = 1 + 2 ; /* token + 16-bit offset */
 1898|   162M|    assert(litlen >= 0);
  ------------------
  |  Branch (1898:5): [True: 0, False: 162M]
  |  Branch (1898:5): [True: 162M, False: 0]
  ------------------
 1899|   162M|    assert(mlen >= MINMATCH);
  ------------------
  |  Branch (1899:5): [True: 0, False: 162M]
  |  Branch (1899:5): [True: 162M, False: 0]
  ------------------
 1900|       |
 1901|   162M|    if (mlen >= (int)(ML_MASK+MINMATCH))
  ------------------
  |  |  262|   162M|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  261|   162M|#define ML_BITS  4
  |  |  ------------------
  ------------------
                  if (mlen >= (int)(ML_MASK+MINMATCH))
  ------------------
  |  |  243|   162M|#define MINMATCH 4
  ------------------
  |  Branch (1901:9): [True: 130M, False: 32.2M]
  ------------------
 1902|   130M|        price += 1 + ((mlen-(int)(ML_MASK+MINMATCH)) / 255);
  ------------------
  |  |  262|   130M|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  261|   130M|#define ML_BITS  4
  |  |  ------------------
  ------------------
                      price += 1 + ((mlen-(int)(ML_MASK+MINMATCH)) / 255);
  ------------------
  |  |  243|   130M|#define MINMATCH 4
  ------------------
 1903|       |
 1904|   162M|    return price * LZ4HC_PRICE_SCALE + LZ4HC_literalsPrice(litlen);
  ------------------
  |  | 1874|   162M|#define LZ4HC_PRICE_SCALE 4
  ------------------
 1905|   162M|}
lz4hc.c:LZ4HC_setMatch:
 1951|  36.5M|{
 1952|  36.5M|    opt[pos].mlen = mlen;
 1953|  36.5M|    opt[pos].off = off;
 1954|  36.5M|    opt[pos].litlen = 0;
 1955|  36.5M|    opt[pos].price = price;
 1956|  36.5M|    DEBUGLOG(7, "rPos:%3i => price:%3i (matchlen=%i)", pos, price, mlen);
  ------------------
  |  |  290|  36.5M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1957|  36.5M|}
lz4hc.c:LZ4HC_setExternalDict:
 1749|  21.3k|{
 1750|  21.3k|    DEBUGLOG(4, "LZ4HC_setExternalDict(%p, %p)", ctxPtr, newBlock);
  ------------------
  |  |  290|  21.3k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1751|  21.3k|    if (LZ4HC_getCLevelParams(ctxPtr->compressionLevel).strat != lz4mid) {
  ------------------
  |  Branch (1751:9): [True: 15.9k, False: 5.42k]
  ------------------
 1752|  15.9k|        U32 const endIdx = ctxPtr->dictLimit + (U32)(ctxPtr->end - ctxPtr->prefixStart);
 1753|  15.9k|        U32 idx;
 1754|  15.9k|        if (ctxPtr->end >= ctxPtr->prefixStart + 4)
  ------------------
  |  Branch (1754:13): [True: 15.0k, False: 845]
  ------------------
 1755|  15.0k|            LZ4HC_Insert (ctxPtr, ctxPtr->end-3);  /* Referencing remaining dictionary content */
 1756|       |        /* last positions can't be inserted : don't leave stale chains from previous history */
 1757|  62.9k|        for (idx = ctxPtr->nextToUpdate; idx < endIdx; idx++)
  ------------------
  |  Branch (1757:42): [True: 46.9k, False: 15.9k]
  ------------------
 1758|  46.9k|            DELTANEXTU16(ctxPtr->chainTable, idx) = 0;
  ------------------
  |  |  229|  46.9k|#define DELTANEXTU16(table, pos) table[(U16)(pos)]   /* faster */
  ------------------
 1759|  15.9k|    }
 1760|       |
 1761|       |    /* Only one memory segment for extDict, so any previous extDict is lost at this stage */
 1762|  21.3k|    ctxPtr->lowLimit  = ctxPtr->dictLimit;
 1763|  21.3k|    ctxPtr->dictStart  = ctxPtr->prefixStart;
 1764|  21.3k|    ctxPtr->dictLimit += (U32)(ctxPtr->end - ctxPtr->prefixStart);
 1765|  21.3k|    ctxPtr->prefixStart = newBlock;
 1766|  21.3k|    ctxPtr->end  = newBlock;
 1767|  21.3k|    ctxPtr->nextToUpdate = ctxPtr->dictLimit;   /* match referencing will resume from there */
 1768|       |
 1769|       |    /* cannot reference an extDict and a dictCtx at the same time */
 1770|       |    ctxPtr->dictCtx = NULL;
 1771|  21.3k|}
lz4hc.c:LZ4HC_getCLevelParams:
  110|  80.5k|{
  111|       |    /* note : clevel convention is a bit different from lz4frame,
  112|       |     * possibly something worth revisiting for consistency */
  113|  80.5k|    if (cLevel < 1)
  ------------------
  |  Branch (113:9): [True: 0, False: 80.5k]
  ------------------
  114|      0|        cLevel = LZ4HC_CLEVEL_DEFAULT;
  ------------------
  |  |   48|      0|#define LZ4HC_CLEVEL_DEFAULT     9
  ------------------
  115|  80.5k|    cLevel = MIN(LZ4HC_CLEVEL_MAX, cLevel);
  ------------------
  |  |   81|  80.5k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (81:22): [True: 0, False: 80.5k]
  |  |  ------------------
  ------------------
  116|  80.5k|    return k_clTable[cLevel];
  117|  80.5k|}
lz4hc.c:LZ4HC_Insert:
  854|  87.2M|{
  855|  87.2M|    U16* const chainTable = hc4->chainTable;
  856|  87.2M|    U32* const hashTable  = hc4->hashTable;
  857|  87.2M|    const BYTE* const prefixPtr = hc4->prefixStart;
  858|  87.2M|    U32 const prefixIdx = hc4->dictLimit;
  859|  87.2M|    U32 const target = (U32)(ip - prefixPtr) + prefixIdx;
  860|  87.2M|    U32 idx = hc4->nextToUpdate;
  861|  87.2M|    assert(ip >= prefixPtr);
  ------------------
  |  Branch (861:5): [True: 0, False: 87.2M]
  |  Branch (861:5): [True: 87.2M, False: 0]
  ------------------
  862|  87.2M|    assert(target >= prefixIdx);
  ------------------
  |  Branch (862:5): [True: 0, False: 87.2M]
  |  Branch (862:5): [True: 87.2M, False: 0]
  ------------------
  863|       |
  864|   570M|    while (idx < target) {
  ------------------
  |  Branch (864:12): [True: 483M, False: 87.2M]
  ------------------
  865|   483M|        U32 const h = LZ4HC_hashPtr(prefixPtr+idx-prefixIdx);
  866|   483M|        size_t delta = idx - hashTable[h];
  867|   483M|        if (delta>LZ4_DISTANCE_MAX) delta = LZ4_DISTANCE_MAX;
  ------------------
  |  |  678|   483M|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
                      if (delta>LZ4_DISTANCE_MAX) delta = LZ4_DISTANCE_MAX;
  ------------------
  |  |  678|  37.5M|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (867:13): [True: 37.5M, False: 445M]
  ------------------
  868|   483M|        DELTANEXTU16(chainTable, idx) = (U16)delta;
  ------------------
  |  |  229|   483M|#define DELTANEXTU16(table, pos) table[(U16)(pos)]   /* faster */
  ------------------
  869|   483M|        hashTable[h] = idx;
  870|   483M|        idx++;
  871|   483M|    }
  872|       |
  873|  87.2M|    hc4->nextToUpdate = target;
  874|  87.2M|}
lz4hc.c:LZ4_compressHC_continue_generic:
 1778|  50.2k|{
 1779|  50.2k|    LZ4HC_CCtx_internal* const ctxPtr = &LZ4_streamHCPtr->internal_donotuse;
 1780|  50.2k|    DEBUGLOG(5, "LZ4_compressHC_continue_generic(ctx=%p, src=%p, srcSize=%d, limit=%d)",
  ------------------
  |  |  290|  50.2k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1781|  50.2k|                LZ4_streamHCPtr, src, *srcSizePtr, limit);
 1782|  50.2k|    assert(ctxPtr != NULL);
  ------------------
  |  Branch (1782:5): [True: 0, False: 50.2k]
  |  Branch (1782:5): [True: 50.2k, False: 0]
  ------------------
 1783|       |    /* auto-init if forgotten */
 1784|  50.2k|    if (ctxPtr->prefixStart == NULL)
  ------------------
  |  Branch (1784:9): [True: 24.8k, False: 25.4k]
  ------------------
 1785|  24.8k|        LZ4HC_init_internal (ctxPtr, (const BYTE*) src);
 1786|       |
 1787|       |    /* Check overflow */
 1788|  50.2k|    if ((size_t)(ctxPtr->end - ctxPtr->prefixStart) + ctxPtr->dictLimit > 2 GB) {
  ------------------
  |  |  254|  50.2k|#define GB *(1U<<30)
  ------------------
  |  Branch (1788:9): [True: 0, False: 50.2k]
  ------------------
 1789|      0|        size_t dictSize = (size_t)(ctxPtr->end - ctxPtr->prefixStart);
 1790|      0|        if (dictSize > 64 KB) dictSize = 64 KB;
  ------------------
  |  |  252|      0|#define KB *(1 <<10)
  ------------------
                      if (dictSize > 64 KB) dictSize = 64 KB;
  ------------------
  |  |  252|      0|#define KB *(1 <<10)
  ------------------
  |  Branch (1790:13): [True: 0, False: 0]
  ------------------
 1791|      0|        LZ4_loadDictHC(LZ4_streamHCPtr, (const char*)(ctxPtr->end) - dictSize, (int)dictSize);
 1792|      0|    }
 1793|       |
 1794|       |    /* Check if blocks follow each other */
 1795|  50.2k|    if ((const BYTE*)src != ctxPtr->end)
  ------------------
  |  Branch (1795:9): [True: 21.3k, False: 28.9k]
  ------------------
 1796|  21.3k|        LZ4HC_setExternalDict(ctxPtr, (const BYTE*)src);
 1797|       |
 1798|       |    /* Check overlapping input/dictionary space */
 1799|  50.2k|    {   const BYTE* sourceEnd = (const BYTE*) src + *srcSizePtr;
 1800|  50.2k|        const BYTE* const dictBegin = ctxPtr->dictStart;
 1801|  50.2k|        const BYTE* const dictEnd   = ctxPtr->dictStart + (ctxPtr->dictLimit - ctxPtr->lowLimit);
 1802|  50.2k|        if ((sourceEnd > dictBegin) && ((const BYTE*)src < dictEnd)) {
  ------------------
  |  Branch (1802:13): [True: 37.7k, False: 12.5k]
  |  Branch (1802:40): [True: 0, False: 37.7k]
  ------------------
 1803|      0|            if (sourceEnd > dictEnd) sourceEnd = dictEnd;
  ------------------
  |  Branch (1803:17): [True: 0, False: 0]
  ------------------
 1804|      0|            ctxPtr->lowLimit += (U32)(sourceEnd - ctxPtr->dictStart);
 1805|      0|            ctxPtr->dictStart += (U32)(sourceEnd - ctxPtr->dictStart);
 1806|       |            /* invalidate dictionary is it's too small */
 1807|      0|            if (ctxPtr->dictLimit - ctxPtr->lowLimit < LZ4HC_HASHSIZE) {
  ------------------
  |  |  121|      0|#define LZ4HC_HASHSIZE 4
  ------------------
  |  Branch (1807:17): [True: 0, False: 0]
  ------------------
 1808|      0|                ctxPtr->lowLimit = ctxPtr->dictLimit;
 1809|      0|                ctxPtr->dictStart = ctxPtr->prefixStart;
 1810|      0|    }   }   }
 1811|       |
 1812|  50.2k|    return LZ4HC_compress_generic (ctxPtr, src, dst, srcSizePtr, dstCapacity, ctxPtr->compressionLevel, limit);
 1813|  50.2k|}

LZ4_XXH32:
  393|   156k|{
  394|       |#if 0
  395|       |    /* Simple version, good for code maintenance, but unfortunately slow for small inputs */
  396|       |    XXH32_state_t state;
  397|       |    XXH32_reset(&state, seed);
  398|       |    XXH32_update(&state, input, len);
  399|       |    return XXH32_digest(&state);
  400|       |#else
  401|   156k|    XXH_endianness endian_detected = (XXH_endianness)XXH_CPU_LITTLE_ENDIAN;
  ------------------
  |  |  225|   156k|#   define XXH_CPU_LITTLE_ENDIAN   XXH_isLittleEndian()
  ------------------
  402|       |
  403|   156k|    if (XXH_FORCE_ALIGN_CHECK) {
  ------------------
  |  |   95|   156k|#    define XXH_FORCE_ALIGN_CHECK 0
  |  |  ------------------
  |  |  |  Branch (95:35): [Folded, False: 156k]
  |  |  ------------------
  ------------------
  404|      0|        if ((((size_t)input) & 3) == 0) {   /* Input is 4-bytes aligned, leverage the speed benefit */
  ------------------
  |  Branch (404:13): [True: 0, False: 0]
  ------------------
  405|      0|            if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
  ------------------
  |  |   83|      0|#  define XXH_FORCE_NATIVE_FORMAT 0
  |  |  ------------------
  |  |  |  Branch (83:35): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (405:17): [True: 0, False: 0]
  ------------------
  406|      0|                return XXH32_endian_align(input, len, seed, XXH_littleEndian, XXH_aligned);
  407|      0|            else
  408|      0|                return XXH32_endian_align(input, len, seed, XXH_bigEndian, XXH_aligned);
  409|      0|    }   }
  410|       |
  411|   156k|    if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
  ------------------
  |  |   83|      0|#  define XXH_FORCE_NATIVE_FORMAT 0
  |  |  ------------------
  |  |  |  Branch (83:35): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (411:9): [True: 156k, False: 0]
  ------------------
  412|   156k|        return XXH32_endian_align(input, len, seed, XXH_littleEndian, XXH_unaligned);
  413|      0|    else
  414|      0|        return XXH32_endian_align(input, len, seed, XXH_bigEndian, XXH_unaligned);
  415|   156k|#endif
  416|   156k|}
LZ4_XXH32_reset:
  438|  92.1k|{
  439|  92.1k|    XXH32_state_t state;   /* using a local state to memcpy() in order to avoid strict-aliasing warnings */
  440|  92.1k|    memset(&state, 0, sizeof(state));
  441|  92.1k|    state.v1 = seed + PRIME32_1 + PRIME32_2;
  442|  92.1k|    state.v2 = seed + PRIME32_2;
  443|  92.1k|    state.v3 = seed + 0;
  444|  92.1k|    state.v4 = seed - PRIME32_1;
  445|       |    /* do not write into reserved, planned to be removed in a future version */
  446|  92.1k|    memcpy(statePtr, &state, sizeof(state) - sizeof(state.reserved));
  447|  92.1k|    return XXH_OK;
  448|  92.1k|}
LZ4_XXH32_update:
  516|  65.7k|{
  517|  65.7k|    XXH_endianness endian_detected = (XXH_endianness)XXH_CPU_LITTLE_ENDIAN;
  ------------------
  |  |  225|  65.7k|#   define XXH_CPU_LITTLE_ENDIAN   XXH_isLittleEndian()
  ------------------
  518|       |
  519|  65.7k|    if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
  ------------------
  |  |   83|      0|#  define XXH_FORCE_NATIVE_FORMAT 0
  |  |  ------------------
  |  |  |  Branch (83:35): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (519:9): [True: 65.7k, False: 0]
  ------------------
  520|  65.7k|        return XXH32_update_endian(state_in, input, len, XXH_littleEndian);
  521|      0|    else
  522|      0|        return XXH32_update_endian(state_in, input, len, XXH_bigEndian);
  523|  65.7k|}
LZ4_XXH32_digest:
  547|  28.5k|{
  548|  28.5k|    XXH_endianness endian_detected = (XXH_endianness)XXH_CPU_LITTLE_ENDIAN;
  ------------------
  |  |  225|  28.5k|#   define XXH_CPU_LITTLE_ENDIAN   XXH_isLittleEndian()
  ------------------
  549|       |
  550|  28.5k|    if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
  ------------------
  |  |   83|      0|#  define XXH_FORCE_NATIVE_FORMAT 0
  |  |  ------------------
  |  |  |  Branch (83:35): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (550:9): [True: 28.5k, False: 0]
  ------------------
  551|  28.5k|        return XXH32_digest_endian(state_in, XXH_littleEndian);
  552|      0|    else
  553|      0|        return XXH32_digest_endian(state_in, XXH_bigEndian);
  554|  28.5k|}
xxhash.c:XXH_isLittleEndian:
  221|   250k|{
  222|   250k|    const union { U32 u; BYTE c[4]; } one = { 1 };   /* don't use static : performance detrimental  */
  223|   250k|    return one.c[0];
  224|   250k|}
xxhash.c:XXH32_endian_align:
  354|   156k|{
  355|   156k|    const BYTE* p = (const BYTE*)input;
  356|   156k|    const BYTE* bEnd = p + len;
  357|   156k|    U32 h32;
  358|       |
  359|       |#if defined(XXH_ACCEPT_NULL_INPUT_POINTER) && (XXH_ACCEPT_NULL_INPUT_POINTER>=1)
  360|       |    if (p==NULL) {
  361|       |        len=0;
  362|       |        bEnd=p=(const BYTE*)(size_t)16;
  363|       |    }
  364|       |#endif
  365|       |
  366|   156k|    if (len>=16) {
  ------------------
  |  Branch (366:9): [True: 32.8k, False: 123k]
  ------------------
  367|  32.8k|        const BYTE* const limit = bEnd - 15;
  368|  32.8k|        U32 v1 = seed + PRIME32_1 + PRIME32_2;
  369|  32.8k|        U32 v2 = seed + PRIME32_2;
  370|  32.8k|        U32 v3 = seed + 0;
  371|  32.8k|        U32 v4 = seed - PRIME32_1;
  372|       |
  373|  11.8M|        do {
  374|  11.8M|            v1 = XXH32_round(v1, XXH_get32bits(p)); p+=4;
  ------------------
  |  |  288|  11.8M|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  ------------------
  375|  11.8M|            v2 = XXH32_round(v2, XXH_get32bits(p)); p+=4;
  ------------------
  |  |  288|  11.8M|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  ------------------
  376|  11.8M|            v3 = XXH32_round(v3, XXH_get32bits(p)); p+=4;
  ------------------
  |  |  288|  11.8M|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  ------------------
  377|  11.8M|            v4 = XXH32_round(v4, XXH_get32bits(p)); p+=4;
  ------------------
  |  |  288|  11.8M|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  ------------------
  378|  11.8M|        } while (p < limit);
  ------------------
  |  Branch (378:18): [True: 11.8M, False: 32.8k]
  ------------------
  379|       |
  380|  32.8k|        h32 = XXH_rotl32(v1, 1)  + XXH_rotl32(v2, 7)
  ------------------
  |  |  194|  32.8k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  ------------------
                      h32 = XXH_rotl32(v1, 1)  + XXH_rotl32(v2, 7)
  ------------------
  |  |  194|  32.8k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  ------------------
  381|  32.8k|            + XXH_rotl32(v3, 12) + XXH_rotl32(v4, 18);
  ------------------
  |  |  194|  32.8k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  ------------------
                          + XXH_rotl32(v3, 12) + XXH_rotl32(v4, 18);
  ------------------
  |  |  194|  32.8k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  ------------------
  382|   123k|    } else {
  383|   123k|        h32  = seed + PRIME32_5;
  384|   123k|    }
  385|       |
  386|   156k|    h32 += (U32)len;
  387|       |
  388|   156k|    return XXH32_finalize(h32, p, len&15, endian, align);
  389|   156k|}
xxhash.c:XXH32_round:
  270|   212M|{
  271|   212M|    seed += input * PRIME32_2;
  272|   212M|    seed  = XXH_rotl32(seed, 13);
  ------------------
  |  |  194|   212M|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  ------------------
  273|   212M|    seed *= PRIME32_1;
  274|   212M|    return seed;
  275|   212M|}
xxhash.c:XXH_readLE32_align:
  235|   212M|{
  236|   212M|    if (align==XXH_unaligned)
  ------------------
  |  Branch (236:9): [True: 212M, False: 27.5k]
  ------------------
  237|   212M|        return endian==XXH_littleEndian ? XXH_read32(ptr) : XXH_swap32(XXH_read32(ptr));
  ------------------
  |  Branch (237:16): [True: 212M, False: 0]
  ------------------
  238|  27.5k|    else
  239|  27.5k|        return endian==XXH_littleEndian ? *(const U32*)ptr : XXH_swap32(*(const U32*)ptr);
  ------------------
  |  Branch (239:16): [True: 27.5k, False: 0]
  ------------------
  240|   212M|}
xxhash.c:XXH_read32:
  175|   212M|{
  176|   212M|    U32 val;
  177|   212M|    memcpy(&val, memPtr, sizeof(val));
  178|   212M|    return val;
  179|   212M|}
xxhash.c:XXH32_finalize:
  294|   184k|{
  295|   184k|    const BYTE* p = (const BYTE*)ptr;
  296|       |
  297|   184k|#define PROCESS1               \
  298|   184k|    h32 += (*p++) * PRIME32_5; \
  299|   184k|    h32 = XXH_rotl32(h32, 11) * PRIME32_1 ;
  300|       |
  301|   184k|#define PROCESS4                         \
  302|   184k|    h32 += XXH_get32bits(p) * PRIME32_3; \
  303|   184k|    p+=4;                                \
  304|   184k|    h32  = XXH_rotl32(h32, 17) * PRIME32_4 ;
  305|       |
  306|   184k|    switch(len&15)  /* or switch(bEnd - p) */
  ------------------
  |  Branch (306:12): [True: 184k, False: 0]
  ------------------
  307|   184k|    {
  308|  4.04k|      case 12:      PROCESS4;
  ------------------
  |  |  302|  4.04k|    h32 += XXH_get32bits(p) * PRIME32_3; \
  |  |  ------------------
  |  |  |  |  288|  4.04k|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  |  |  ------------------
  |  |  303|  4.04k|    p+=4;                                \
  |  |  304|  4.04k|    h32  = XXH_rotl32(h32, 17) * PRIME32_4 ;
  |  |  ------------------
  |  |  |  |  194|  4.04k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (308:7): [True: 4.04k, False: 180k]
  ------------------
  309|       |                    /* fallthrough */
  310|  7.41k|      case 8:       PROCESS4;
  ------------------
  |  |  302|  7.41k|    h32 += XXH_get32bits(p) * PRIME32_3; \
  |  |  ------------------
  |  |  |  |  288|  7.41k|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  |  |  ------------------
  |  |  303|  7.41k|    p+=4;                                \
  |  |  304|  7.41k|    h32  = XXH_rotl32(h32, 17) * PRIME32_4 ;
  |  |  ------------------
  |  |  |  |  194|  7.41k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (310:7): [True: 3.37k, False: 181k]
  ------------------
  311|       |                    /* fallthrough */
  312|  31.0k|      case 4:       PROCESS4;
  ------------------
  |  |  302|  31.0k|    h32 += XXH_get32bits(p) * PRIME32_3; \
  |  |  ------------------
  |  |  |  |  288|  31.0k|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  |  |  ------------------
  |  |  303|  31.0k|    p+=4;                                \
  |  |  304|  31.0k|    h32  = XXH_rotl32(h32, 17) * PRIME32_4 ;
  |  |  ------------------
  |  |  |  |  194|  31.0k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (312:7): [True: 23.6k, False: 161k]
  ------------------
  313|  31.0k|                    return XXH32_avalanche(h32);
  314|       |
  315|  4.17k|      case 13:      PROCESS4;
  ------------------
  |  |  302|  4.17k|    h32 += XXH_get32bits(p) * PRIME32_3; \
  |  |  ------------------
  |  |  |  |  288|  4.17k|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  |  |  ------------------
  |  |  303|  4.17k|    p+=4;                                \
  |  |  304|  4.17k|    h32  = XXH_rotl32(h32, 17) * PRIME32_4 ;
  |  |  ------------------
  |  |  |  |  194|  4.17k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (315:7): [True: 4.17k, False: 180k]
  ------------------
  316|       |                    /* fallthrough */
  317|  8.42k|      case 9:       PROCESS4;
  ------------------
  |  |  302|  8.42k|    h32 += XXH_get32bits(p) * PRIME32_3; \
  |  |  ------------------
  |  |  |  |  288|  8.42k|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  |  |  ------------------
  |  |  303|  8.42k|    p+=4;                                \
  |  |  304|  8.42k|    h32  = XXH_rotl32(h32, 17) * PRIME32_4 ;
  |  |  ------------------
  |  |  |  |  194|  8.42k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (317:7): [True: 4.25k, False: 180k]
  ------------------
  318|       |                    /* fallthrough */
  319|  13.2k|      case 5:       PROCESS4;
  ------------------
  |  |  302|  13.2k|    h32 += XXH_get32bits(p) * PRIME32_3; \
  |  |  ------------------
  |  |  |  |  288|  13.2k|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  |  |  ------------------
  |  |  303|  13.2k|    p+=4;                                \
  |  |  304|  13.2k|    h32  = XXH_rotl32(h32, 17) * PRIME32_4 ;
  |  |  ------------------
  |  |  |  |  194|  13.2k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (319:7): [True: 4.87k, False: 179k]
  ------------------
  320|  13.2k|                    PROCESS1;
  ------------------
  |  |  298|  13.2k|    h32 += (*p++) * PRIME32_5; \
  |  |  299|  13.2k|    h32 = XXH_rotl32(h32, 11) * PRIME32_1 ;
  |  |  ------------------
  |  |  |  |  194|  13.2k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  321|  13.2k|                    return XXH32_avalanche(h32);
  322|       |
  323|  4.16k|      case 14:      PROCESS4;
  ------------------
  |  |  302|  4.16k|    h32 += XXH_get32bits(p) * PRIME32_3; \
  |  |  ------------------
  |  |  |  |  288|  4.16k|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  |  |  ------------------
  |  |  303|  4.16k|    p+=4;                                \
  |  |  304|  4.16k|    h32  = XXH_rotl32(h32, 17) * PRIME32_4 ;
  |  |  ------------------
  |  |  |  |  194|  4.16k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (323:7): [True: 4.16k, False: 180k]
  ------------------
  324|       |                    /* fallthrough */
  325|  8.84k|      case 10:      PROCESS4;
  ------------------
  |  |  302|  8.84k|    h32 += XXH_get32bits(p) * PRIME32_3; \
  |  |  ------------------
  |  |  |  |  288|  8.84k|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  |  |  ------------------
  |  |  303|  8.84k|    p+=4;                                \
  |  |  304|  8.84k|    h32  = XXH_rotl32(h32, 17) * PRIME32_4 ;
  |  |  ------------------
  |  |  |  |  194|  8.84k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (325:7): [True: 4.67k, False: 180k]
  ------------------
  326|       |                    /* fallthrough */
  327|  13.2k|      case 6:       PROCESS4;
  ------------------
  |  |  302|  13.2k|    h32 += XXH_get32bits(p) * PRIME32_3; \
  |  |  ------------------
  |  |  |  |  288|  13.2k|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  |  |  ------------------
  |  |  303|  13.2k|    p+=4;                                \
  |  |  304|  13.2k|    h32  = XXH_rotl32(h32, 17) * PRIME32_4 ;
  |  |  ------------------
  |  |  |  |  194|  13.2k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (327:7): [True: 4.41k, False: 180k]
  ------------------
  328|  13.2k|                    PROCESS1;
  ------------------
  |  |  298|  13.2k|    h32 += (*p++) * PRIME32_5; \
  |  |  299|  13.2k|    h32 = XXH_rotl32(h32, 11) * PRIME32_1 ;
  |  |  ------------------
  |  |  |  |  194|  13.2k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  329|  13.2k|                    PROCESS1;
  ------------------
  |  |  298|  13.2k|    h32 += (*p++) * PRIME32_5; \
  |  |  299|  13.2k|    h32 = XXH_rotl32(h32, 11) * PRIME32_1 ;
  |  |  ------------------
  |  |  |  |  194|  13.2k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  330|  13.2k|                    return XXH32_avalanche(h32);
  331|       |
  332|  4.57k|      case 15:      PROCESS4;
  ------------------
  |  |  302|  4.57k|    h32 += XXH_get32bits(p) * PRIME32_3; \
  |  |  ------------------
  |  |  |  |  288|  4.57k|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  |  |  ------------------
  |  |  303|  4.57k|    p+=4;                                \
  |  |  304|  4.57k|    h32  = XXH_rotl32(h32, 17) * PRIME32_4 ;
  |  |  ------------------
  |  |  |  |  194|  4.57k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (332:7): [True: 4.57k, False: 180k]
  ------------------
  333|       |                    /* fallthrough */
  334|  9.28k|      case 11:      PROCESS4;
  ------------------
  |  |  302|  9.28k|    h32 += XXH_get32bits(p) * PRIME32_3; \
  |  |  ------------------
  |  |  |  |  288|  9.28k|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  |  |  ------------------
  |  |  303|  9.28k|    p+=4;                                \
  |  |  304|  9.28k|    h32  = XXH_rotl32(h32, 17) * PRIME32_4 ;
  |  |  ------------------
  |  |  |  |  194|  9.28k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (334:7): [True: 4.71k, False: 180k]
  ------------------
  335|       |                    /* fallthrough */
  336|  13.8k|      case 7:       PROCESS4;
  ------------------
  |  |  302|  13.8k|    h32 += XXH_get32bits(p) * PRIME32_3; \
  |  |  ------------------
  |  |  |  |  288|  13.8k|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  |  |  ------------------
  |  |  303|  13.8k|    p+=4;                                \
  |  |  304|  13.8k|    h32  = XXH_rotl32(h32, 17) * PRIME32_4 ;
  |  |  ------------------
  |  |  |  |  194|  13.8k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (336:7): [True: 4.52k, False: 180k]
  ------------------
  337|       |                    /* fallthrough */
  338|  18.7k|      case 3:       PROCESS1;
  ------------------
  |  |  298|  18.7k|    h32 += (*p++) * PRIME32_5; \
  |  |  299|  18.7k|    h32 = XXH_rotl32(h32, 11) * PRIME32_1 ;
  |  |  ------------------
  |  |  |  |  194|  18.7k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (338:7): [True: 4.96k, False: 179k]
  ------------------
  339|       |                    /* fallthrough */
  340|   106k|      case 2:       PROCESS1;
  ------------------
  |  |  298|   106k|    h32 += (*p++) * PRIME32_5; \
  |  |  299|   106k|    h32 = XXH_rotl32(h32, 11) * PRIME32_1 ;
  |  |  ------------------
  |  |  |  |  194|   106k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (340:7): [True: 87.8k, False: 96.9k]
  ------------------
  341|       |                    /* fallthrough */
  342|   115k|      case 1:       PROCESS1;
  ------------------
  |  |  298|   115k|    h32 += (*p++) * PRIME32_5; \
  |  |  299|   115k|    h32 = XXH_rotl32(h32, 11) * PRIME32_1 ;
  |  |  ------------------
  |  |  |  |  194|   115k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (342:7): [True: 8.69k, False: 176k]
  ------------------
  343|       |                    /* fallthrough */
  344|   127k|      case 0:       return XXH32_avalanche(h32);
  ------------------
  |  Branch (344:7): [True: 11.8k, False: 172k]
  ------------------
  345|   184k|    }
  346|   184k|    assert(0);
  ------------------
  |  Branch (346:5): [Folded, False: 0]
  |  Branch (346:5): [Folded, False: 0]
  ------------------
  347|      0|    return h32;   /* reaching this point is deemed impossible */
  348|      0|}
xxhash.c:XXH32_avalanche:
  279|   184k|{
  280|   184k|    h32 ^= h32 >> 15;
  281|   184k|    h32 *= PRIME32_2;
  282|   184k|    h32 ^= h32 >> 13;
  283|   184k|    h32 *= PRIME32_3;
  284|   184k|    h32 ^= h32 >> 16;
  285|   184k|    return(h32);
  286|   184k|}
xxhash.c:XXH32_update_endian:
  453|  65.7k|{
  454|  65.7k|    if (input==NULL)
  ------------------
  |  Branch (454:9): [True: 0, False: 65.7k]
  ------------------
  455|       |#if defined(XXH_ACCEPT_NULL_INPUT_POINTER) && (XXH_ACCEPT_NULL_INPUT_POINTER>=1)
  456|       |        return XXH_OK;
  457|       |#else
  458|      0|        return XXH_ERROR;
  459|  65.7k|#endif
  460|       |
  461|  65.7k|    {   const BYTE* p = (const BYTE*)input;
  462|  65.7k|        const BYTE* const bEnd = p + len;
  463|       |
  464|  65.7k|        state->total_len_32 += (unsigned)len;
  465|  65.7k|        state->large_len |= (len>=16) | (state->total_len_32>=16);
  466|       |
  467|  65.7k|        if (state->memsize + len < 16)  {   /* fill in tmp buffer */
  ------------------
  |  Branch (467:13): [True: 26.4k, False: 39.2k]
  ------------------
  468|  26.4k|            XXH_memcpy((BYTE*)(state->mem32) + state->memsize, input, len);
  469|  26.4k|            state->memsize += (unsigned)len;
  470|  26.4k|            return XXH_OK;
  471|  26.4k|        }
  472|       |
  473|  39.2k|        if (state->memsize) {   /* some data left from previous update */
  ------------------
  |  Branch (473:13): [True: 25.4k, False: 13.8k]
  ------------------
  474|  25.4k|            XXH_memcpy((BYTE*)(state->mem32) + state->memsize, input, 16-state->memsize);
  475|  25.4k|            {   const U32* p32 = state->mem32;
  476|  25.4k|                state->v1 = XXH32_round(state->v1, XXH_readLE32(p32, endian)); p32++;
  477|  25.4k|                state->v2 = XXH32_round(state->v2, XXH_readLE32(p32, endian)); p32++;
  478|  25.4k|                state->v3 = XXH32_round(state->v3, XXH_readLE32(p32, endian)); p32++;
  479|  25.4k|                state->v4 = XXH32_round(state->v4, XXH_readLE32(p32, endian));
  480|  25.4k|            }
  481|  25.4k|            p += 16-state->memsize;
  482|  25.4k|            state->memsize = 0;
  483|  25.4k|        }
  484|       |
  485|  39.2k|        if (p <= bEnd-16) {
  ------------------
  |  Branch (485:13): [True: 31.0k, False: 8.27k]
  ------------------
  486|  31.0k|            const BYTE* const limit = bEnd - 16;
  487|  31.0k|            U32 v1 = state->v1;
  488|  31.0k|            U32 v2 = state->v2;
  489|  31.0k|            U32 v3 = state->v3;
  490|  31.0k|            U32 v4 = state->v4;
  491|       |
  492|  41.1M|            do {
  493|  41.1M|                v1 = XXH32_round(v1, XXH_readLE32(p, endian)); p+=4;
  494|  41.1M|                v2 = XXH32_round(v2, XXH_readLE32(p, endian)); p+=4;
  495|  41.1M|                v3 = XXH32_round(v3, XXH_readLE32(p, endian)); p+=4;
  496|  41.1M|                v4 = XXH32_round(v4, XXH_readLE32(p, endian)); p+=4;
  497|  41.1M|            } while (p<=limit);
  ------------------
  |  Branch (497:22): [True: 41.1M, False: 31.0k]
  ------------------
  498|       |
  499|  31.0k|            state->v1 = v1;
  500|  31.0k|            state->v2 = v2;
  501|  31.0k|            state->v3 = v3;
  502|  31.0k|            state->v4 = v4;
  503|  31.0k|        }
  504|       |
  505|  39.2k|        if (p < bEnd) {
  ------------------
  |  Branch (505:13): [True: 35.1k, False: 4.12k]
  ------------------
  506|  35.1k|            XXH_memcpy(state->mem32, p, (size_t)(bEnd-p));
  507|  35.1k|            state->memsize = (unsigned)(bEnd-p);
  508|  35.1k|        }
  509|  39.2k|    }
  510|       |
  511|      0|    return XXH_OK;
  512|  65.7k|}
xxhash.c:XXH_memcpy:
  112|  87.1k|static void* XXH_memcpy(void* dest, const void* src, size_t size) { return memcpy(dest,src,size); }
xxhash.c:XXH_readLE32:
  243|   164M|{
  244|   164M|    return XXH_readLE32_align(ptr, endian, XXH_unaligned);
  245|   164M|}
xxhash.c:XXH32_digest_endian:
  528|  28.5k|{
  529|  28.5k|    U32 h32;
  530|       |
  531|  28.5k|    if (state->large_len) {
  ------------------
  |  Branch (531:9): [True: 15.5k, False: 12.9k]
  ------------------
  532|  15.5k|        h32 = XXH_rotl32(state->v1, 1)
  ------------------
  |  |  194|  15.5k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  ------------------
  533|  15.5k|            + XXH_rotl32(state->v2, 7)
  ------------------
  |  |  194|  15.5k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  ------------------
  534|  15.5k|            + XXH_rotl32(state->v3, 12)
  ------------------
  |  |  194|  15.5k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  ------------------
  535|  15.5k|            + XXH_rotl32(state->v4, 18);
  ------------------
  |  |  194|  15.5k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  ------------------
  536|  15.5k|    } else {
  537|  12.9k|        h32 = state->v3 /* == seed */ + PRIME32_5;
  538|  12.9k|    }
  539|       |
  540|  28.5k|    h32 += state->total_len_32;
  541|       |
  542|  28.5k|    return XXH32_finalize(h32, state->mem32, state->memsize, endian, XXH_aligned);
  543|  28.5k|}

LLVMFuzzerTestOneInput:
  133|  19.1k|{
  134|  19.1k|    uint32_t seed = FUZZ_seed(&data, &size);
  135|  19.1k|    LZ4F_preferences_t const prefs = FUZZ_randomPreferences(&seed);
  136|  19.1k|    int const allowUncompressed = prefs.frameInfo.blockMode == LZ4F_blockIndependent;
  137|  19.1k|    size_t const blockSize = LZ4F_getBlockSize(prefs.frameInfo.blockSizeID);
  138|  19.1k|    LZ4F_compressOptions_t cOpts;
  139|  19.1k|    state_t s;
  140|  19.1k|    size_t pos = 0, frameStart = 0;
  141|  19.1k|    int inFrame = 0;
  142|  19.1k|    unsigned nbOps;
  143|       |
  144|  19.1k|    memset(&cOpts, 0, sizeof(cOpts));
  145|  19.1k|    cOpts.stableSrc = FUZZ_rand32(&seed, 0, 1);
  146|       |
  147|  19.1k|    memset(&s, 0, sizeof(s));
  148|  19.1k|    s.prefs = &prefs;
  149|  19.1k|    s.cOpts = &cOpts;
  150|  19.1k|    s.refOutCapacity = MAX(LZ4F_compressBound(size, &prefs), LZ4F_HEADER_SIZE_MAX);
  ------------------
  |  |   34|  19.1k|#define MAX(a,b)   ( (a) > (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (34:22): [True: 18.9k, False: 166]
  |  |  ------------------
  ------------------
  151|  19.1k|    s.refOut = (char*)malloc(s.refOutCapacity);
  152|       |    /* each operation can add up to 2 partial blocks */
  153|  19.1k|    s.frameCapacity = LZ4F_compressFrameBound(size, &prefs)
  154|  19.1k|                    + 2 * MAX_OPS * (LZ4F_BLOCK_HEADER_SIZE + LZ4F_BLOCK_CHECKSUM_SIZE);
  ------------------
  |  |   23|  19.1k|#define MAX_OPS 64
  ------------------
                                  + 2 * MAX_OPS * (LZ4F_BLOCK_HEADER_SIZE + LZ4F_BLOCK_CHECKSUM_SIZE);
  ------------------
  |  |  287|  19.1k|#define LZ4F_BLOCK_HEADER_SIZE 4
  ------------------
                                  + 2 * MAX_OPS * (LZ4F_BLOCK_HEADER_SIZE + LZ4F_BLOCK_CHECKSUM_SIZE);
  ------------------
  |  |  290|  19.1k|#define LZ4F_BLOCK_CHECKSUM_SIZE 4
  ------------------
  155|  19.1k|    s.frame = (char*)malloc(s.frameCapacity);
  156|  19.1k|    char* const rt = (char*)malloc(size ? size : 1);
  ------------------
  |  Branch (156:36): [True: 19.0k, False: 70]
  ------------------
  157|  19.1k|    FUZZ_ASSERT(s.refOut != NULL);
  ------------------
  |  |   47|  19.1k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  19.1k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 19.1k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  19.1k|          : (fprintf(stderr, "%s: %u: Assertion: `%s' failed. %s\n", __FILE__, \
  |  |  |  |   45|      0|                     __LINE__, FUZZ_QUOTE(cond), (msg)),                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |   37|      0|#define FUZZ_QUOTE(str) FUZZ_QUOTE_IMPL(str)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   36|      0|#define FUZZ_QUOTE_IMPL(str) #str
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   46|      0|             abort()))
  |  |  ------------------
  ------------------
  158|  19.1k|    FUZZ_ASSERT(s.frame != NULL);
  ------------------
  |  |   47|  19.1k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  19.1k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 19.1k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  19.1k|          : (fprintf(stderr, "%s: %u: Assertion: `%s' failed. %s\n", __FILE__, \
  |  |  |  |   45|      0|                     __LINE__, FUZZ_QUOTE(cond), (msg)),                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |   37|      0|#define FUZZ_QUOTE(str) FUZZ_QUOTE_IMPL(str)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   36|      0|#define FUZZ_QUOTE_IMPL(str) #str
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   46|      0|             abort()))
  |  |  ------------------
  ------------------
  159|  19.1k|    FUZZ_ASSERT(rt != NULL);
  ------------------
  |  |   47|  19.1k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  19.1k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 19.1k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  19.1k|          : (fprintf(stderr, "%s: %u: Assertion: `%s' failed. %s\n", __FILE__, \
  |  |  |  |   45|      0|                     __LINE__, FUZZ_QUOTE(cond), (msg)),                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |   37|      0|#define FUZZ_QUOTE(str) FUZZ_QUOTE_IMPL(str)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   36|      0|#define FUZZ_QUOTE_IMPL(str) #str
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   46|      0|             abort()))
  |  |  ------------------
  ------------------
  160|  19.1k|    freshContexts(&s);
  161|       |
  162|   140k|    for (nbOps = 0; nbOps < MAX_OPS; nbOps++) {
  ------------------
  |  |   23|   140k|#define MAX_OPS 64
  ------------------
  |  Branch (162:21): [True: 140k, False: 12]
  ------------------
  163|   140k|        if (!inFrame) {
  ------------------
  |  Branch (163:13): [True: 49.1k, False: 91.5k]
  ------------------
  164|  49.1k|            frameStart = pos;
  165|  49.1k|            s.frameSize = 0;
  166|  49.1k|            inFrame = runBoth(&s, op_begin, NULL, 0, &seed);
  167|  49.1k|            continue;
  168|  49.1k|        }
  169|  91.5k|        if (pos == size || FUZZ_rand32(&seed, 0, 15) == 0) {
  ------------------
  |  Branch (169:13): [True: 19.1k, False: 72.3k]
  |  Branch (169:28): [True: 3.02k, False: 69.3k]
  ------------------
  170|  22.1k|            if (runBoth(&s, op_end, NULL, 0, &seed)) {
  ------------------
  |  Branch (170:17): [True: 14.3k, False: 7.84k]
  ------------------
  171|  14.3k|                size_t const rtSize = FUZZ_decompressFrame(rt, size, s.frame, s.frameSize,
  172|  14.3k|                                                           FUZZ_rand32(&seed, 0, 7) == 0 /* occasionally skip checksums */);
  173|  14.3k|                FUZZ_ASSERT_MSG(rtSize == pos - frameStart, "Incorrect regenerated size");
  ------------------
  |  |   43|  14.3k|  ((cond) ? (void)0                                                            \
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 14.3k, False: 0]
  |  |  ------------------
  |  |   44|  14.3k|          : (fprintf(stderr, "%s: %u: Assertion: `%s' failed. %s\n", __FILE__, \
  |  |   45|      0|                     __LINE__, FUZZ_QUOTE(cond), (msg)),                       \
  |  |  ------------------
  |  |  |  |   37|      0|#define FUZZ_QUOTE(str) FUZZ_QUOTE_IMPL(str)
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|      0|#define FUZZ_QUOTE_IMPL(str) #str
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   46|      0|             abort()))
  ------------------
  174|  14.3k|                FUZZ_ASSERT_MSG(!memcmp(data + frameStart, rt, rtSize), "Corruption!");
  ------------------
  |  |   43|  14.3k|  ((cond) ? (void)0                                                            \
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 14.3k, False: 0]
  |  |  ------------------
  |  |   44|  14.3k|          : (fprintf(stderr, "%s: %u: Assertion: `%s' failed. %s\n", __FILE__, \
  |  |   45|      0|                     __LINE__, FUZZ_QUOTE(cond), (msg)),                       \
  |  |  ------------------
  |  |  |  |   37|      0|#define FUZZ_QUOTE(str) FUZZ_QUOTE_IMPL(str)
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|      0|#define FUZZ_QUOTE_IMPL(str) #str
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   46|      0|             abort()))
  ------------------
  175|  14.3k|            }
  176|  22.1k|            inFrame = 0;
  177|  22.1k|            if (pos == size) break;
  ------------------
  |  Branch (177:17): [True: 19.1k, False: 3.02k]
  ------------------
  178|  3.02k|            continue;
  179|  22.1k|        }
  180|  69.3k|        {   uint32_t const t = FUZZ_rand32(&seed, 0, 7);
  181|  69.3k|            opType_e const type = (t == 0) ? op_flush
  ------------------
  |  Branch (181:35): [True: 8.50k, False: 60.8k]
  ------------------
  182|  69.3k|                                : ((t == 1) && allowUncompressed) ? op_uncompressedUpdate
  ------------------
  |  Branch (182:36): [True: 7.91k, False: 52.9k]
  |  Branch (182:48): [True: 709, False: 7.20k]
  ------------------
  183|  60.8k|                                : op_update;
  184|  69.3k|            size_t const remaining = size - pos;
  185|  69.3k|            size_t srcSize = 0;
  186|  69.3k|            if (type != op_flush) {
  ------------------
  |  Branch (186:17): [True: 60.8k, False: 8.50k]
  ------------------
  187|  60.8k|                switch (FUZZ_rand32(&seed, 0, 3)) {
  188|  18.1k|                case 0: srcSize = FUZZ_rand32(&seed, 0, 16); break;
  ------------------
  |  Branch (188:17): [True: 18.1k, False: 42.6k]
  ------------------
  189|  17.9k|                case 1: srcSize = blockSize - 1 + FUZZ_rand32(&seed, 0, 2); break;
  ------------------
  |  Branch (189:17): [True: 17.9k, False: 42.9k]
  ------------------
  190|  24.7k|                default: srcSize = FUZZ_rand32(&seed, 0, (uint32_t)MIN(remaining, 2 * blockSize)); break;
  ------------------
  |  |   33|  24.7k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (33:22): [True: 22.6k, False: 2.06k]
  |  |  ------------------
  ------------------
  |  Branch (190:17): [True: 24.7k, False: 36.1k]
  ------------------
  191|  60.8k|                }
  192|  60.8k|                srcSize = MIN(srcSize, remaining);
  ------------------
  |  |   33|  60.8k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (33:22): [True: 41.7k, False: 19.0k]
  |  |  ------------------
  ------------------
  193|  60.8k|            }
  194|  69.3k|            inFrame = runBoth(&s, type, data + pos, srcSize, &seed);
  195|  69.3k|            pos += srcSize;
  196|  69.3k|        }
  197|  69.3k|    }
  198|       |
  199|  19.1k|    free(s.refOut);
  200|  19.1k|    free(s.frame);
  201|  19.1k|    free(rt);
  202|  19.1k|    LZ4F_freeCompressionContext(s.refCtx);
  203|  19.1k|    LZ4F_freeCompressionContext(s.cctx);
  204|       |
  205|  19.1k|    return 0;
  206|  19.1k|}
compress_frame_stream_fuzzer.c:freshContexts:
   74|  53.9k|{
   75|  53.9k|    LZ4F_freeCompressionContext(s->refCtx);
   76|  53.9k|    LZ4F_freeCompressionContext(s->cctx);
   77|  53.9k|    FUZZ_ASSERT(!LZ4F_isError(LZ4F_createCompressionContext(&s->refCtx, LZ4F_VERSION)));
  ------------------
  |  |   47|  53.9k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  53.9k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 53.9k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  53.9k|          : (fprintf(stderr, "%s: %u: Assertion: `%s' failed. %s\n", __FILE__, \
  |  |  |  |   45|      0|                     __LINE__, FUZZ_QUOTE(cond), (msg)),                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |   37|      0|#define FUZZ_QUOTE(str) FUZZ_QUOTE_IMPL(str)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   36|      0|#define FUZZ_QUOTE_IMPL(str) #str
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   46|      0|             abort()))
  |  |  ------------------
  ------------------
   78|  53.9k|    FUZZ_ASSERT(!LZ4F_isError(LZ4F_createCompressionContext(&s->cctx, LZ4F_VERSION)));
  ------------------
  |  |   47|  53.9k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  53.9k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 53.9k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  53.9k|          : (fprintf(stderr, "%s: %u: Assertion: `%s' failed. %s\n", __FILE__, \
  |  |  |  |   45|      0|                     __LINE__, FUZZ_QUOTE(cond), (msg)),                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |   37|      0|#define FUZZ_QUOTE(str) FUZZ_QUOTE_IMPL(str)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   36|      0|#define FUZZ_QUOTE_IMPL(str) #str
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   46|      0|             abort()))
  |  |  ------------------
  ------------------
   79|  53.9k|}
compress_frame_stream_fuzzer.c:runBoth:
   92|   140k|{
   93|   140k|    size_t const bound = opBound(s, type, srcSize);
   94|   140k|    size_t capacity;
   95|   140k|    FUZZ_ASSERT(bound <= s->refOutCapacity);
  ------------------
  |  |   47|   140k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|   140k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 140k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|   140k|          : (fprintf(stderr, "%s: %u: Assertion: `%s' failed. %s\n", __FILE__, \
  |  |  |  |   45|      0|                     __LINE__, FUZZ_QUOTE(cond), (msg)),                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |   37|      0|#define FUZZ_QUOTE(str) FUZZ_QUOTE_IMPL(str)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   36|      0|#define FUZZ_QUOTE_IMPL(str) #str
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   46|      0|             abort()))
  |  |  ------------------
  ------------------
   96|       |
   97|   140k|    size_t const refSize = runOp(s, s->refCtx, type, s->refOut, bound, src, srcSize);
   98|   140k|    FUZZ_ASSERT_MSG(!LZ4F_isError(refSize), "Operation must succeed with a bound-sized buffer");
  ------------------
  |  |   43|   140k|  ((cond) ? (void)0                                                            \
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 140k, False: 0]
  |  |  ------------------
  |  |   44|   140k|          : (fprintf(stderr, "%s: %u: Assertion: `%s' failed. %s\n", __FILE__, \
  |  |   45|      0|                     __LINE__, FUZZ_QUOTE(cond), (msg)),                       \
  |  |  ------------------
  |  |  |  |   37|      0|#define FUZZ_QUOTE(str) FUZZ_QUOTE_IMPL(str)
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|      0|#define FUZZ_QUOTE_IMPL(str) #str
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   46|      0|             abort()))
  ------------------
   99|   140k|    FUZZ_ASSERT(refSize <= bound);
  ------------------
  |  |   47|   140k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|   140k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 140k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|   140k|          : (fprintf(stderr, "%s: %u: Assertion: `%s' failed. %s\n", __FILE__, \
  |  |  |  |   45|      0|                     __LINE__, FUZZ_QUOTE(cond), (msg)),                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |   37|      0|#define FUZZ_QUOTE(str) FUZZ_QUOTE_IMPL(str)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   36|      0|#define FUZZ_QUOTE_IMPL(str) #str
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   46|      0|             abort()))
  |  |  ------------------
  ------------------
  100|       |
  101|   140k|    switch (FUZZ_rand32(seed, 0, 7)) {
  102|  20.0k|    case 0:
  ------------------
  |  Branch (102:5): [True: 20.0k, False: 120k]
  ------------------
  103|  36.7k|    case 1: capacity = refSize; break;
  ------------------
  |  Branch (103:5): [True: 16.7k, False: 123k]
  ------------------
  104|  17.9k|    case 2:
  ------------------
  |  Branch (104:5): [True: 17.9k, False: 122k]
  ------------------
  105|  36.4k|    case 3: capacity = FUZZ_rand32(seed, (uint32_t)refSize, (uint32_t)bound); break;
  ------------------
  |  Branch (105:5): [True: 18.4k, False: 122k]
  ------------------
  106|  14.2k|    case 4: capacity = refSize ? refSize - 1 : 0; break;
  ------------------
  |  Branch (106:5): [True: 14.2k, False: 126k]
  |  Branch (106:24): [True: 11.7k, False: 2.53k]
  ------------------
  107|  15.2k|    case 5: capacity = FUZZ_rand32(seed, 0, (uint32_t)refSize); break;
  ------------------
  |  Branch (107:5): [True: 15.2k, False: 125k]
  ------------------
  108|  37.9k|    default: capacity = FUZZ_rand32(seed, 0, (uint32_t)bound); break;
  ------------------
  |  Branch (108:5): [True: 37.9k, False: 102k]
  ------------------
  109|   140k|    }
  110|       |
  111|       |    /* exact size, to detect overflows */
  112|   140k|    char* const dst = (char*)malloc(capacity ? capacity : 1);
  ------------------
  |  Branch (112:37): [True: 127k, False: 13.5k]
  ------------------
  113|   140k|    FUZZ_ASSERT(dst != NULL);
  ------------------
  |  |   47|   140k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|   140k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 140k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|   140k|          : (fprintf(stderr, "%s: %u: Assertion: `%s' failed. %s\n", __FILE__, \
  |  |  |  |   45|      0|                     __LINE__, FUZZ_QUOTE(cond), (msg)),                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |   37|      0|#define FUZZ_QUOTE(str) FUZZ_QUOTE_IMPL(str)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   36|      0|#define FUZZ_QUOTE_IMPL(str) #str
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   46|      0|             abort()))
  |  |  ------------------
  ------------------
  114|   140k|    size_t const r = runOp(s, s->cctx, type, dst, capacity, src, srcSize);
  115|   140k|    if (capacity < refSize) {
  ------------------
  |  Branch (115:9): [True: 34.7k, False: 105k]
  ------------------
  116|  34.7k|        FUZZ_ASSERT_MSG(LZ4F_getErrorCode(r) == LZ4F_ERROR_dstCapacity_tooSmall,
  ------------------
  |  |   43|  34.7k|  ((cond) ? (void)0                                                            \
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 34.7k, False: 0]
  |  |  ------------------
  |  |   44|  34.7k|          : (fprintf(stderr, "%s: %u: Assertion: `%s' failed. %s\n", __FILE__, \
  |  |   45|      0|                     __LINE__, FUZZ_QUOTE(cond), (msg)),                       \
  |  |  ------------------
  |  |  |  |   37|      0|#define FUZZ_QUOTE(str) FUZZ_QUOTE_IMPL(str)
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|      0|#define FUZZ_QUOTE_IMPL(str) #str
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   46|      0|             abort()))
  ------------------
  117|  34.7k|                        "Operation must fail when its output doesn't fit");
  118|  34.7k|        free(dst);
  119|  34.7k|        checkInvalidated(s->cctx);
  120|  34.7k|        freshContexts(s);
  121|  34.7k|        return 0;
  122|  34.7k|    }
  123|   105k|    FUZZ_ASSERT_MSG(r == refSize, "Operation must succeed when its output fits");
  ------------------
  |  |   43|   105k|  ((cond) ? (void)0                                                            \
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 105k, False: 0]
  |  |  ------------------
  |  |   44|   105k|          : (fprintf(stderr, "%s: %u: Assertion: `%s' failed. %s\n", __FILE__, \
  |  |   45|      0|                     __LINE__, FUZZ_QUOTE(cond), (msg)),                       \
  |  |  ------------------
  |  |  |  |   37|      0|#define FUZZ_QUOTE(str) FUZZ_QUOTE_IMPL(str)
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|      0|#define FUZZ_QUOTE_IMPL(str) #str
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   46|      0|             abort()))
  ------------------
  124|   105k|    FUZZ_ASSERT_MSG(!memcmp(dst, s->refOut, refSize), "Output must not depend on capacity");
  ------------------
  |  |   43|   105k|  ((cond) ? (void)0                                                            \
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 105k, False: 0]
  |  |  ------------------
  |  |   44|   105k|          : (fprintf(stderr, "%s: %u: Assertion: `%s' failed. %s\n", __FILE__, \
  |  |   45|      0|                     __LINE__, FUZZ_QUOTE(cond), (msg)),                       \
  |  |  ------------------
  |  |  |  |   37|      0|#define FUZZ_QUOTE(str) FUZZ_QUOTE_IMPL(str)
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|      0|#define FUZZ_QUOTE_IMPL(str) #str
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   46|      0|             abort()))
  ------------------
  125|   105k|    FUZZ_ASSERT(s->frameSize + refSize <= s->frameCapacity);
  ------------------
  |  |   47|   105k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|   105k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 105k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|   105k|          : (fprintf(stderr, "%s: %u: Assertion: `%s' failed. %s\n", __FILE__, \
  |  |  |  |   45|      0|                     __LINE__, FUZZ_QUOTE(cond), (msg)),                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |   37|      0|#define FUZZ_QUOTE(str) FUZZ_QUOTE_IMPL(str)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   36|      0|#define FUZZ_QUOTE_IMPL(str) #str
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   46|      0|             abort()))
  |  |  ------------------
  ------------------
  126|   105k|    memcpy(s->frame + s->frameSize, dst, refSize);
  127|   105k|    s->frameSize += refSize;
  128|   105k|    free(dst);
  129|   105k|    return 1;
  130|   105k|}
compress_frame_stream_fuzzer.c:opBound:
   59|   140k|{
   60|   140k|    switch (type) {
  ------------------
  |  Branch (60:13): [True: 140k, False: 0]
  ------------------
   61|  49.1k|    case op_begin:
  ------------------
  |  Branch (61:5): [True: 49.1k, False: 91.5k]
  ------------------
   62|  49.1k|        return LZ4F_HEADER_SIZE_MAX;
  ------------------
  |  |  284|  49.1k|#define LZ4F_HEADER_SIZE_MAX 19
  ------------------
   63|  60.1k|    case op_update:
  ------------------
  |  Branch (63:5): [True: 60.1k, False: 80.4k]
  ------------------
   64|  60.8k|    case op_uncompressedUpdate:
  ------------------
  |  Branch (64:5): [True: 709, False: 139k]
  ------------------
   65|  60.8k|        return LZ4F_compressBound(srcSize, s->prefs);
   66|  8.50k|    case op_flush:
  ------------------
  |  Branch (66:5): [True: 8.50k, False: 132k]
  ------------------
   67|  30.6k|    case op_end:
  ------------------
  |  Branch (67:5): [True: 22.1k, False: 118k]
  ------------------
   68|  30.6k|        return LZ4F_compressBound(0, s->prefs);
   69|   140k|    }
   70|      0|    return 0;
   71|   140k|}
compress_frame_stream_fuzzer.c:runOp:
   42|   281k|{
   43|   281k|    switch (type) {
  ------------------
  |  Branch (43:13): [True: 281k, False: 0]
  ------------------
   44|  98.2k|    case op_begin:
  ------------------
  |  Branch (44:5): [True: 98.2k, False: 183k]
  ------------------
   45|  98.2k|        return LZ4F_compressBegin(cctx, dst, dstCapacity, s->prefs);
   46|   120k|    case op_update:
  ------------------
  |  Branch (46:5): [True: 120k, False: 160k]
  ------------------
   47|   120k|        return LZ4F_compressUpdate(cctx, dst, dstCapacity, src, srcSize, s->cOpts);
   48|  1.41k|    case op_uncompressedUpdate:
  ------------------
  |  Branch (48:5): [True: 1.41k, False: 279k]
  ------------------
   49|  1.41k|        return LZ4F_uncompressedUpdate(cctx, dst, dstCapacity, src, srcSize, s->cOpts);
   50|  17.0k|    case op_flush:
  ------------------
  |  Branch (50:5): [True: 17.0k, False: 264k]
  ------------------
   51|  17.0k|        return LZ4F_flush(cctx, dst, dstCapacity, s->cOpts);
   52|  44.3k|    case op_end:
  ------------------
  |  Branch (52:5): [True: 44.3k, False: 236k]
  ------------------
   53|  44.3k|        return LZ4F_compressEnd(cctx, dst, dstCapacity, s->cOpts);
   54|   281k|    }
   55|      0|    return (size_t)-1;
   56|   281k|}
compress_frame_stream_fuzzer.c:checkInvalidated:
   82|  34.7k|{
   83|  34.7k|    char dst[LZ4F_HEADER_SIZE_MAX];
   84|  34.7k|    size_t const r = LZ4F_compressEnd(cctx, dst, sizeof(dst), NULL);
   85|       |    FUZZ_ASSERT_MSG(LZ4F_getErrorCode(r) == LZ4F_ERROR_compressionState_uninitialized,
  ------------------
  |  |   43|  34.7k|  ((cond) ? (void)0                                                            \
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 34.7k, False: 0]
  |  |  ------------------
  |  |   44|  34.7k|          : (fprintf(stderr, "%s: %u: Assertion: `%s' failed. %s\n", __FILE__, \
  |  |   45|      0|                     __LINE__, FUZZ_QUOTE(cond), (msg)),                       \
  |  |  ------------------
  |  |  |  |   37|      0|#define FUZZ_QUOTE(str) FUZZ_QUOTE_IMPL(str)
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|      0|#define FUZZ_QUOTE_IMPL(str) #str
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   46|      0|             abort()))
  ------------------
   86|  34.7k|                    "A failed operation must invalidate the frame");
   87|  34.7k|}

compress_frame_stream_fuzzer.c:FUZZ_seed:
   64|  19.1k|FUZZ_STATIC uint32_t FUZZ_seed(uint8_t const **src, size_t* size) {
   65|  19.1k|    uint8_t const *data = *src;
   66|  19.1k|    size_t const toHash = MIN(FUZZ_RNG_SEED_SIZE, *size);
  ------------------
  |  |   33|  19.1k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (33:22): [True: 19.0k, False: 70]
  |  |  ------------------
  ------------------
   67|  19.1k|    *size -= toHash;
   68|  19.1k|    *src += toHash;
   69|  19.1k|    return XXH32(data, toHash, 0);
  ------------------
  |  |  128|  19.1k|#  define XXH32 XXH_NAME2(XXH_NAMESPACE, XXH32)
  |  |  ------------------
  |  |  |  |  126|  19.1k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  19.1k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   70|  19.1k|}
compress_frame_stream_fuzzer.c:FUZZ_rand32:
   86|   527k|FUZZ_STATIC uint32_t FUZZ_rand32(uint32_t *state, uint32_t min, uint32_t max) {
   87|   527k|    uint32_t random = FUZZ_rand(state);
   88|   527k|    return min + (random % (max - min + 1));
   89|   527k|}
compress_frame_stream_fuzzer.c:FUZZ_rand:
   74|   527k|FUZZ_STATIC uint32_t FUZZ_rand(uint32_t *state) {
   75|   527k|    static const uint32_t prime1 = 2654435761U;
   76|   527k|    static const uint32_t prime2 = 2246822519U;
   77|   527k|    uint32_t rand32 = *state;
   78|   527k|    rand32 *= prime1;
   79|   527k|    rand32 += prime2;
   80|   527k|    rand32 = FUZZ_rotl32(rand32, 13);
  ------------------
  |  |   72|   527k|#define FUZZ_rotl32(x, r) (((x) << (r)) | ((x) >> (32 - (r))))
  ------------------
   81|   527k|    *state = rand32;
   82|   527k|    return rand32 >> 5;
   83|   527k|}
lz4_helpers.c:FUZZ_rand32:
   86|   133k|FUZZ_STATIC uint32_t FUZZ_rand32(uint32_t *state, uint32_t min, uint32_t max) {
   87|   133k|    uint32_t random = FUZZ_rand(state);
   88|   133k|    return min + (random % (max - min + 1));
   89|   133k|}
lz4_helpers.c:FUZZ_rand:
   74|   133k|FUZZ_STATIC uint32_t FUZZ_rand(uint32_t *state) {
   75|   133k|    static const uint32_t prime1 = 2654435761U;
   76|   133k|    static const uint32_t prime2 = 2246822519U;
   77|   133k|    uint32_t rand32 = *state;
   78|   133k|    rand32 *= prime1;
   79|   133k|    rand32 += prime2;
   80|   133k|    rand32 = FUZZ_rotl32(rand32, 13);
  ------------------
  |  |   72|   133k|#define FUZZ_rotl32(x, r) (((x) << (r)) | ((x) >> (32 - (r))))
  ------------------
   81|   133k|    *state = rand32;
   82|   133k|    return rand32 >> 5;
   83|   133k|}

FUZZ_randomFrameInfo:
    6|  19.1k|{
    7|  19.1k|    LZ4F_frameInfo_t info = LZ4F_INIT_FRAMEINFO;
  ------------------
  |  |  186|  19.1k|#define LZ4F_INIT_FRAMEINFO   { LZ4F_max64KB, LZ4F_blockLinked, LZ4F_noContentChecksum, LZ4F_frame, 0ULL, 0U, LZ4F_noBlockChecksum }    /* v1.8.3+ */
  ------------------
    8|  19.1k|    info.blockSizeID = FUZZ_rand32(seed, LZ4F_max64KB - 1, LZ4F_max4MB);
    9|  19.1k|    if (info.blockSizeID < LZ4F_max64KB) {
  ------------------
  |  Branch (9:9): [True: 4.63k, False: 14.5k]
  ------------------
   10|  4.63k|        info.blockSizeID = LZ4F_default;
   11|  4.63k|    }
   12|  19.1k|    info.blockMode = FUZZ_rand32(seed, LZ4F_blockLinked, LZ4F_blockIndependent);
   13|  19.1k|    info.contentChecksumFlag = FUZZ_rand32(seed, LZ4F_noContentChecksum,
   14|  19.1k|                                           LZ4F_contentChecksumEnabled);
   15|  19.1k|    info.blockChecksumFlag = FUZZ_rand32(seed, LZ4F_noBlockChecksum,
   16|  19.1k|                                         LZ4F_blockChecksumEnabled);
   17|  19.1k|    return info;
   18|  19.1k|}
FUZZ_randomPreferences:
   21|  19.1k|{
   22|  19.1k|    LZ4F_preferences_t prefs = LZ4F_INIT_PREFERENCES;
  ------------------
  |  |  201|  19.1k|#define LZ4F_INIT_PREFERENCES   { LZ4F_INIT_FRAMEINFO, 0, 0u, 0u, { 0u, 0u, 0u } }    /* v1.8.3+ */
  |  |  ------------------
  |  |  |  |  186|  19.1k|#define LZ4F_INIT_FRAMEINFO   { LZ4F_max64KB, LZ4F_blockLinked, LZ4F_noContentChecksum, LZ4F_frame, 0ULL, 0U, LZ4F_noBlockChecksum }    /* v1.8.3+ */
  |  |  ------------------
  ------------------
   23|  19.1k|    prefs.frameInfo = FUZZ_randomFrameInfo(seed);
   24|  19.1k|    prefs.compressionLevel = FUZZ_rand32(seed, 0, LZ4HC_CLEVEL_MAX + 3) - 3;
  ------------------
  |  |   50|  19.1k|#define LZ4HC_CLEVEL_MAX        12
  ------------------
   25|  19.1k|    prefs.autoFlush = FUZZ_rand32(seed, 0, 1);
   26|  19.1k|    prefs.favorDecSpeed = FUZZ_rand32(seed, 0, 1);
   27|  19.1k|    return prefs;
   28|  19.1k|}
FUZZ_decompressFrame:
   33|  14.3k|{
   34|  14.3k|    LZ4F_decompressOptions_t opts;
   35|  14.3k|    memset(&opts, 0, sizeof(opts));
   36|  14.3k|    opts.stableDst = 1;
   37|  14.3k|    opts.skipChecksums = (unsigned)skipChecksums;
   38|  14.3k|    LZ4F_dctx* dctx;
   39|  14.3k|    LZ4F_createDecompressionContext(&dctx, LZ4F_VERSION);
  ------------------
  |  |  259|  14.3k|#define LZ4F_VERSION 100    /* This number can be used to check for an incompatible API breaking change */
  ------------------
   40|  14.3k|    FUZZ_ASSERT(dctx);
  ------------------
  |  |   47|  14.3k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  14.3k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 14.3k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  14.3k|          : (fprintf(stderr, "%s: %u: Assertion: `%s' failed. %s\n", __FILE__, \
  |  |  |  |   45|      0|                     __LINE__, FUZZ_QUOTE(cond), (msg)),                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |   37|      0|#define FUZZ_QUOTE(str) FUZZ_QUOTE_IMPL(str)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   36|      0|#define FUZZ_QUOTE_IMPL(str) #str
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   46|      0|             abort()))
  |  |  ------------------
  ------------------
   41|       |
   42|  14.3k|    size_t dstSize = dstCapacity;
   43|  14.3k|    size_t srcConsumed = srcSize;
   44|  14.3k|    size_t const rc =
   45|  14.3k|            LZ4F_decompress(dctx, dst, &dstSize, src, &srcConsumed, &opts);
   46|  14.3k|    FUZZ_ASSERT(!LZ4F_isError(rc));
  ------------------
  |  |   47|  14.3k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  14.3k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 14.3k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  14.3k|          : (fprintf(stderr, "%s: %u: Assertion: `%s' failed. %s\n", __FILE__, \
  |  |  |  |   45|      0|                     __LINE__, FUZZ_QUOTE(cond), (msg)),                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |   37|      0|#define FUZZ_QUOTE(str) FUZZ_QUOTE_IMPL(str)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   36|      0|#define FUZZ_QUOTE_IMPL(str) #str
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   46|      0|             abort()))
  |  |  ------------------
  ------------------
   47|  14.3k|    FUZZ_ASSERT(rc == 0);
  ------------------
  |  |   47|  14.3k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  14.3k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 14.3k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  14.3k|          : (fprintf(stderr, "%s: %u: Assertion: `%s' failed. %s\n", __FILE__, \
  |  |  |  |   45|      0|                     __LINE__, FUZZ_QUOTE(cond), (msg)),                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |   37|      0|#define FUZZ_QUOTE(str) FUZZ_QUOTE_IMPL(str)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   36|      0|#define FUZZ_QUOTE_IMPL(str) #str
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   46|      0|             abort()))
  |  |  ------------------
  ------------------
   48|  14.3k|    FUZZ_ASSERT(srcConsumed == srcSize);
  ------------------
  |  |   47|  14.3k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  14.3k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 14.3k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  14.3k|          : (fprintf(stderr, "%s: %u: Assertion: `%s' failed. %s\n", __FILE__, \
  |  |  |  |   45|      0|                     __LINE__, FUZZ_QUOTE(cond), (msg)),                       \
  |  |  |  |  ------------------
  |  |  |  |  |  |   37|      0|#define FUZZ_QUOTE(str) FUZZ_QUOTE_IMPL(str)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   36|      0|#define FUZZ_QUOTE_IMPL(str) #str
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   46|      0|             abort()))
  |  |  ------------------
  ------------------
   49|       |
   50|  14.3k|    LZ4F_freeDecompressionContext(dctx);
   51|       |
   52|  14.3k|    return dstSize;
   53|  14.3k|}

