lz4hc.c:LZ4_isAligned:
  293|  15.7k|{
  294|  15.7k|    return ((size_t)ptr & (alignment -1)) == 0;
  295|  15.7k|}
lz4hc.c:LZ4_count:
  721|   379M|{
  722|   379M|    const BYTE* const pStart = pIn;
  723|       |
  724|   379M|    if (likely(pIn < pInLimit-(STEPSIZE-1))) {
  ------------------
  |  |  177|   379M|#define likely(expr)     expect((expr) != 0, 1)
  |  |  ------------------
  |  |  |  |  171|   379M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 379M, False: 101k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  725|   379M|        reg_t const diff = LZ4_read_ARCH(pMatch) ^ LZ4_read_ARCH(pIn);
  726|   379M|        if (!diff) {
  ------------------
  |  Branch (726:13): [True: 99.5M, False: 279M]
  ------------------
  727|  99.5M|            pIn+=STEPSIZE; pMatch+=STEPSIZE;
  ------------------
  |  |  718|  99.5M|#define STEPSIZE sizeof(reg_t)
  ------------------
                          pIn+=STEPSIZE; pMatch+=STEPSIZE;
  ------------------
  |  |  718|  99.5M|#define STEPSIZE sizeof(reg_t)
  ------------------
  728|   279M|        } else {
  729|   279M|            return LZ4_NbCommonBytes(diff);
  730|   279M|    }   }
  731|       |
  732|  3.43G|    while (likely(pIn < pInLimit-(STEPSIZE-1))) {
  733|  3.43G|        reg_t const diff = LZ4_read_ARCH(pMatch) ^ LZ4_read_ARCH(pIn);
  734|  3.43G|        if (!diff) { pIn+=STEPSIZE; pMatch+=STEPSIZE; continue; }
  ------------------
  |  |  718|  3.33G|#define STEPSIZE sizeof(reg_t)
  ------------------
                      if (!diff) { pIn+=STEPSIZE; pMatch+=STEPSIZE; continue; }
  ------------------
  |  |  718|  3.33G|#define STEPSIZE sizeof(reg_t)
  ------------------
  |  Branch (734:13): [True: 3.33G, False: 98.9M]
  ------------------
  735|  98.9M|        pIn += LZ4_NbCommonBytes(diff);
  736|  98.9M|        return (unsigned)(pIn - pStart);
  737|  3.43G|    }
  738|       |
  739|   705k|    if ((STEPSIZE==8) && (pIn<(pInLimit-3)) && (LZ4_read32(pMatch) == LZ4_read32(pIn))) { pIn+=4; pMatch+=4; }
  ------------------
  |  |  718|   705k|#define STEPSIZE sizeof(reg_t)
  ------------------
  |  Branch (739:9): [True: 705k, Folded]
  |  Branch (739:26): [True: 352k, False: 353k]
  |  Branch (739:48): [True: 295k, False: 57.0k]
  ------------------
  740|   705k|    if ((pIn<(pInLimit-1)) && (LZ4_read16(pMatch) == LZ4_read16(pIn))) { pIn+=2; pMatch+=2; }
  ------------------
  |  Branch (740:9): [True: 362k, False: 343k]
  |  Branch (740:31): [True: 303k, False: 58.6k]
  ------------------
  741|   705k|    if ((pIn<pInLimit) && (*pMatch == *pIn)) pIn++;
  ------------------
  |  Branch (741:9): [True: 349k, False: 356k]
  |  Branch (741:27): [True: 290k, False: 59.1k]
  ------------------
  742|   705k|    return (unsigned)(pIn - pStart);
  743|  99.6M|}
lz4hc.c:LZ4_read_ARCH:
  395|  8.23G|static reg_t LZ4_read_ARCH(const void* ptr) { return ((const LZ4_unalignST*)ptr)->uArch; }
lz4hc.c:LZ4_NbCommonBytes:
  620|   677M|{
  621|   677M|    assert(val != 0);
  ------------------
  |  Branch (621:5): [True: 0, False: 677M]
  |  Branch (621:5): [True: 677M, False: 0]
  ------------------
  622|   677M|    if (LZ4_isLittleEndian()) {
  ------------------
  |  Branch (622:9): [True: 677M, False: 0]
  ------------------
  623|   677M|        if (sizeof(val) == 8) {
  ------------------
  |  Branch (623:13): [True: 677M, Folded]
  ------------------
  624|       |#       if defined(_MSC_VER) && (_MSC_VER >= 1800) && (defined(_M_AMD64) && !defined(_M_ARM64EC)) && !defined(LZ4_FORCE_SW_BITCOUNT)
  625|       |/*-*************************************************************************************************
  626|       |* ARM64EC is a Microsoft-designed ARM64 ABI compatible with AMD64 applications on ARM64 Windows 11.
  627|       |* The ARM64EC ABI does not support AVX/AVX2/AVX512 instructions, nor their relevant intrinsics
  628|       |* including _tzcnt_u64. Therefore, we need to neuter the _tzcnt_u64 code path for ARM64EC.
  629|       |****************************************************************************************************/
  630|       |#         if defined(__clang__) && (__clang_major__ < 10)
  631|       |            /* Avoid undefined clang-cl intrinsics issue.
  632|       |             * See https://github.com/lz4/lz4/pull/1017 for details. */
  633|       |            return (unsigned)__builtin_ia32_tzcnt_u64(val) >> 3;
  634|       |#         else
  635|       |            /* x64 CPUS without BMI support interpret `TZCNT` as `REP BSF` */
  636|       |            return (unsigned)_tzcnt_u64(val) >> 3;
  637|       |#         endif
  638|       |#       elif defined(_MSC_VER) && defined(_WIN64) && !defined(LZ4_FORCE_SW_BITCOUNT)
  639|       |            unsigned long r = 0;
  640|       |            _BitScanForward64(&r, (U64)val);
  641|       |            return (unsigned)r >> 3;
  642|       |#       elif (defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 3) || \
  643|       |                            ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))))) && \
  644|       |                                        !defined(LZ4_FORCE_SW_BITCOUNT)
  645|       |            return (unsigned)__builtin_ctzll((U64)val) >> 3;
  646|       |#       else
  647|       |            const U64 m = 0x0101010101010101ULL;
  648|       |            val ^= val - 1;
  649|       |            return (unsigned)(((U64)((val & (m - 1)) * m)) >> 56);
  650|       |#       endif
  651|   677M|        } else /* 32 bits */ {
  652|       |#       if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(LZ4_FORCE_SW_BITCOUNT)
  653|       |            unsigned long r;
  654|       |            _BitScanForward(&r, (U32)val);
  655|       |            return (unsigned)r >> 3;
  656|       |#       elif (defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 3) || \
  657|       |                            ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))))) && \
  658|       |                        !defined(__TINYC__) && !defined(LZ4_FORCE_SW_BITCOUNT)
  659|       |            return (unsigned)__builtin_ctz((U32)val) >> 3;
  660|       |#       else
  661|       |            const U32 m = 0x01010101;
  662|       |            return (unsigned)((((val - 1) ^ val) & (m - 1)) * m) >> 24;
  663|       |#       endif
  664|      0|        }
  665|   677M|    } else   /* Big Endian CPU */ {
  666|      0|        if (sizeof(val)==8) {
  ------------------
  |  Branch (666:13): [True: 0, Folded]
  ------------------
  667|      0|#       if (defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 3) || \
  668|      0|                            ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))))) && \
  669|      0|                        !defined(__TINYC__) && !defined(LZ4_FORCE_SW_BITCOUNT)
  670|      0|            return (unsigned)__builtin_clzll((U64)val) >> 3;
  671|       |#       else
  672|       |#if 1
  673|       |            /* this method is probably faster,
  674|       |             * but adds a 128 bytes lookup table */
  675|       |            static const unsigned char ctz7_tab[128] = {
  676|       |                7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  677|       |                4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  678|       |                5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  679|       |                4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  680|       |                6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  681|       |                4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  682|       |                5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  683|       |                4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  684|       |            };
  685|       |            U64 const mask = 0x0101010101010101ULL;
  686|       |            U64 const t = (((val >> 8) - mask) | val) & mask;
  687|       |            return ctz7_tab[(t * 0x0080402010080402ULL) >> 57];
  688|       |#else
  689|       |            /* this method doesn't consume memory space like the previous one,
  690|       |             * but it contains several branches,
  691|       |             * that may end up slowing execution */
  692|       |            static const U32 by32 = sizeof(val)*4;  /* 32 on 64 bits (goal), 16 on 32 bits.
  693|       |            Just to avoid some static analyzer complaining about shift by 32 on 32-bits target.
  694|       |            Note that this code path is never triggered in 32-bits mode. */
  695|       |            unsigned r;
  696|       |            if (!(val>>by32)) { r=4; } else { r=0; val>>=by32; }
  697|       |            if (!(val>>16)) { r+=2; val>>=8; } else { val>>=24; }
  698|       |            r += (!val);
  699|       |            return r;
  700|       |#endif
  701|       |#       endif
  702|      0|        } else /* 32 bits */ {
  703|      0|#       if (defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 3) || \
  704|      0|                            ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))))) && \
  705|      0|                                        !defined(LZ4_FORCE_SW_BITCOUNT)
  706|      0|            return (unsigned)__builtin_clz((U32)val) >> 3;
  707|       |#       else
  708|       |            val >>= 8;
  709|       |            val = ((((val + 0x00FFFF00) | 0x00FFFFFF) + val) |
  710|       |              (val + 0x00FF0000)) >> 24;
  711|       |            return (unsigned)val ^ 3;
  712|       |#       endif
  713|      0|        }
  714|      0|    }
  715|   677M|}
lz4hc.c:LZ4_isLittleEndian:
  364|   897M|{
  365|   897M|    const union { U32 u; BYTE c[4]; } one = { 1 };   /* don't use static : performance detrimental */
  366|   897M|    return one.c[0];
  367|   897M|}
lz4hc.c:LZ4_read32:
  394|  6.70G|static U32 LZ4_read32(const void* ptr) { return ((const LZ4_unalign32*)ptr)->u32; }
lz4hc.c:LZ4_read16:
  393|  2.79G|static U16 LZ4_read16(const void* ptr) { return ((const LZ4_unalign16*)ptr)->u16; }
lz4hc.c:LZ4_wildCopy8:
  466|  9.02M|{
  467|  9.02M|    BYTE* d = (BYTE*)dstPtr;
  468|  9.02M|    const BYTE* s = (const BYTE*)srcPtr;
  469|  9.02M|    BYTE* const e = (BYTE*)dstEnd;
  470|       |
  471|  18.1M|    do { LZ4_memcpy(d,s,8); d+=8; s+=8; } while (d<e);
  ------------------
  |  |  349|  18.1M|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  |  Branch (471:50): [True: 9.14M, False: 9.02M]
  ------------------
  472|  9.02M|}
lz4hc.c:LZ4_writeLE16:
  453|  9.02M|{
  454|  9.02M|    if (LZ4_isLittleEndian()) {
  ------------------
  |  Branch (454:9): [True: 9.02M, False: 0]
  ------------------
  455|  9.02M|        LZ4_write16(memPtr, value);
  456|  9.02M|    } else {
  457|      0|        BYTE* p = (BYTE*)memPtr;
  458|      0|        p[0] = (BYTE) value;
  459|      0|        p[1] = (BYTE)(value>>8);
  460|      0|    }
  461|  9.02M|}
lz4hc.c:LZ4_write16:
  397|  9.02M|static void LZ4_write16(void* memPtr, U16 value) { ((LZ4_unalign16*)memPtr)->u16 = value; }
LZ4_compressBound:
  791|  23.5k|int LZ4_compressBound(int isize)  { return LZ4_COMPRESSBOUND(isize); }
  ------------------
  |  |  222|  23.5k|#define LZ4_COMPRESSBOUND(isize)  ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16)
  |  |  ------------------
  |  |  |  |  221|  23.5k|#define LZ4_MAX_INPUT_SIZE        0x7E000000   /* 2 113 929 216 bytes */
  |  |  ------------------
  |  |  |  Branch (222:36): [True: 0, False: 23.5k]
  |  |  ------------------
  ------------------
LZ4_compress_fast_extState_fastReset:
 1582|  3.69k|{
 1583|  3.69k|    LZ4_stream_t_internal* const ctx = &((LZ4_stream_t*)state)->internal_donotuse;
 1584|  3.69k|    acceleration = LZ4_clampAcceleration(acceleration);
 1585|  3.69k|    assert(ctx != NULL);
  ------------------
  |  Branch (1585:5): [True: 0, False: 3.69k]
  |  Branch (1585:5): [True: 3.69k, False: 0]
  ------------------
 1586|       |
 1587|  3.69k|    if (dstCapacity >= LZ4_compressBound(srcSize)) {
  ------------------
  |  Branch (1587:9): [True: 0, False: 3.69k]
  ------------------
 1588|      0|        return LZ4_compress_fastReset_generic(ctx, src, dst, srcSize, 0, notLimited, acceleration);
 1589|  3.69k|    } else {
 1590|  3.69k|        return LZ4_compress_fastReset_generic(ctx, src, dst, srcSize, dstCapacity, limitedOutput, acceleration);
 1591|  3.69k|    }
 1592|  3.69k|}
LZ4_initStream:
 1695|  8.33k|{
 1696|  8.33k|    DEBUGLOG(5, "LZ4_initStream");
  ------------------
  |  |  289|  8.33k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1697|  8.33k|    if (buffer == NULL) { return NULL; }
  ------------------
  |  Branch (1697:9): [True: 0, False: 8.33k]
  ------------------
 1698|  8.33k|    if (size < sizeof(LZ4_stream_t)) { return NULL; }
  ------------------
  |  Branch (1698:9): [True: 0, False: 8.33k]
  ------------------
 1699|  8.33k|    if (!LZ4_isAligned(buffer, LZ4_stream_t_alignment())) return NULL;
  ------------------
  |  Branch (1699:9): [True: 0, False: 8.33k]
  ------------------
 1700|  8.33k|    MEM_INIT(buffer, 0, sizeof(LZ4_stream_t_internal));
  ------------------
  |  |  236|  8.33k|#define MEM_INIT(p,v,s)   LZ4_memset((p),(v),(s))
  |  |  ------------------
  |  |  |  |  234|  8.33k|#  define LZ4_memset(p,v,s) memset((p),(v),(s))
  |  |  ------------------
  ------------------
 1701|  8.33k|    return (LZ4_stream_t*)buffer;
 1702|  8.33k|}
LZ4_compress_fast_continue:
 1870|  7.66k|{
 1871|  7.66k|    const tableType_t tableType = byU32;
 1872|  7.66k|    LZ4_stream_t_internal* const streamPtr = &LZ4_stream->internal_donotuse;
 1873|  7.66k|    const char* dictEnd = streamPtr->dictSize ? (const char*)streamPtr->dictionary + streamPtr->dictSize : NULL;
  ------------------
  |  Branch (1873:27): [True: 4.61k, False: 3.05k]
  ------------------
 1874|       |
 1875|  7.66k|    DEBUGLOG(5, "LZ4_compress_fast_continue (inputSize=%i, dictSize=%u)", inputSize, streamPtr->dictSize);
  ------------------
  |  |  289|  7.66k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1876|       |
 1877|       |    /* new stream (no history) : clear the table beyond LZ4_CLEAR_TABLE_THRESHOLD */
 1878|  7.66k|    if ((streamPtr->dictSize == 0) && (streamPtr->dictCtx == NULL) && (inputSize >= LZ4_CLEAR_TABLE_THRESHOLD))
  ------------------
  |  |  949|  3.05k|#define LZ4_CLEAR_TABLE_THRESHOLD (LZ4_HASHTABLESIZE / 16)
  |  |  ------------------
  |  |  |  |  713|  3.05k|#define LZ4_HASHTABLESIZE (1 << LZ4_MEMORY_USAGE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  162|  3.05k|# define LZ4_MEMORY_USAGE LZ4_MEMORY_USAGE_DEFAULT
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  167|  3.05k|#define LZ4_MEMORY_USAGE_DEFAULT 14
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1878:9): [True: 3.05k, False: 4.61k]
  |  Branch (1878:39): [True: 3.05k, False: 0]
  |  Branch (1878:71): [True: 1.35k, False: 1.69k]
  ------------------
 1879|  1.35k|        LZ4_prepareTable(streamPtr, inputSize, byU32);
 1880|       |
 1881|  7.66k|    LZ4_renormDictT(streamPtr, inputSize);   /* fix index overflow */
 1882|  7.66k|    acceleration = LZ4_clampAcceleration(acceleration);
 1883|       |
 1884|       |    /* invalidate tiny dictionaries */
 1885|  7.66k|    if ( (streamPtr->dictSize < 4)     /* tiny dictionary : not enough for a hash */
  ------------------
  |  Branch (1885:10): [True: 3.07k, False: 4.58k]
  ------------------
 1886|  3.07k|      && (dictEnd != source)           /* prefix mode */
  ------------------
  |  Branch (1886:10): [True: 3.05k, False: 22]
  ------------------
 1887|  3.05k|      && (inputSize > 0)               /* tolerance : don't lose history, in case next invocation would use prefix mode */
  ------------------
  |  Branch (1887:10): [True: 3.05k, False: 0]
  ------------------
 1888|  3.05k|      && (streamPtr->dictCtx == NULL)  /* usingDictCtx */
  ------------------
  |  Branch (1888:10): [True: 3.05k, False: 0]
  ------------------
 1889|  7.66k|      ) {
 1890|  3.05k|        DEBUGLOG(5, "LZ4_compress_fast_continue: dictSize(%u) at addr:%p is too small", streamPtr->dictSize, (void*)streamPtr->dictionary);
  ------------------
  |  |  289|  3.05k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1891|       |        /* remove dictionary existence from history, to employ faster prefix mode */
 1892|  3.05k|        streamPtr->dictSize = 0;
 1893|  3.05k|        streamPtr->dictionary = (const BYTE*)source;
 1894|  3.05k|        dictEnd = source;
 1895|  3.05k|    }
 1896|       |
 1897|       |    /* Check overlapping input/dictionary space */
 1898|  7.66k|    {   const char* const sourceEnd = source + inputSize;
 1899|  7.66k|        if ((sourceEnd > (const char*)streamPtr->dictionary) && (source < dictEnd)) {
  ------------------
  |  Branch (1899:13): [True: 5.91k, False: 1.75k]
  |  Branch (1899:65): [True: 0, False: 5.91k]
  ------------------
 1900|       |            /* only the part of the dictionary beyond input remains */
 1901|      0|            streamPtr->dictSize = (sourceEnd < dictEnd) ? (U32)(dictEnd - sourceEnd) : 0;
  ------------------
  |  Branch (1901:35): [True: 0, False: 0]
  ------------------
 1902|      0|            if (streamPtr->dictSize > 64 KB) streamPtr->dictSize = 64 KB;
  ------------------
  |  |  251|      0|#define KB *(1 <<10)
  ------------------
                          if (streamPtr->dictSize > 64 KB) streamPtr->dictSize = 64 KB;
  ------------------
  |  |  251|      0|#define KB *(1 <<10)
  ------------------
  |  Branch (1902:17): [True: 0, False: 0]
  ------------------
 1903|      0|            if (streamPtr->dictSize < 4) streamPtr->dictSize = 0;
  ------------------
  |  Branch (1903:17): [True: 0, False: 0]
  ------------------
 1904|      0|            streamPtr->dictionary = (const BYTE*)dictEnd - streamPtr->dictSize;
 1905|      0|        }
 1906|  7.66k|    }
 1907|       |
 1908|       |    /* prefix mode : source data follows dictionary */
 1909|  7.66k|    if (dictEnd == source) {
  ------------------
  |  Branch (1909:9): [True: 5.25k, False: 2.41k]
  ------------------
 1910|  5.25k|        if (LZ4_isDictSmall(streamPtr))
  ------------------
  |  Branch (1910:13): [True: 0, False: 5.25k]
  ------------------
 1911|      0|            return LZ4_compress_generic(streamPtr, source, dest, inputSize, NULL, maxOutputSize, limitedOutput, tableType, withPrefix64k, dictSmall, acceleration);
 1912|  5.25k|        else
 1913|  5.25k|            return LZ4_compress_generic(streamPtr, source, dest, inputSize, NULL, maxOutputSize, limitedOutput, tableType, withPrefix64k, noDictIssue, acceleration);
 1914|  5.25k|    }
 1915|       |
 1916|       |    /* external dictionary mode */
 1917|  2.41k|    {   int result;
 1918|  2.41k|        if (streamPtr->dictCtx) {
  ------------------
  |  Branch (1918:13): [True: 0, False: 2.41k]
  ------------------
 1919|       |            /* We depend here on the fact that dictCtx'es (produced by
 1920|       |             * LZ4_loadDict) guarantee that their tables contain no references
 1921|       |             * to offsets between dictCtx->currentOffset - 64 KB and
 1922|       |             * dictCtx->currentOffset - dictCtx->dictSize. This makes it safe
 1923|       |             * to use noDictIssue even when the dict isn't a full 64 KB.
 1924|       |             */
 1925|      0|            if (inputSize >= LZ4_DICTCTX_COPY_THRESHOLD) {
  ------------------
  |  | 1863|      0|#define LZ4_DICTCTX_COPY_THRESHOLD ((LZ4_HASHTABLESIZE / 8 < 4 KB) ? (LZ4_HASHTABLESIZE / 8) : 4 KB)
  |  |  ------------------
  |  |  |  |  713|      0|#define LZ4_HASHTABLESIZE (1 << LZ4_MEMORY_USAGE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  162|      0|# define LZ4_MEMORY_USAGE LZ4_MEMORY_USAGE_DEFAULT
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  167|      0|#define LZ4_MEMORY_USAGE_DEFAULT 14
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define LZ4_DICTCTX_COPY_THRESHOLD ((LZ4_HASHTABLESIZE / 8 < 4 KB) ? (LZ4_HASHTABLESIZE / 8) : 4 KB)
  |  |  ------------------
  |  |  |  |  251|      0|#define KB *(1 <<10)
  |  |  ------------------
  |  |               #define LZ4_DICTCTX_COPY_THRESHOLD ((LZ4_HASHTABLESIZE / 8 < 4 KB) ? (LZ4_HASHTABLESIZE / 8) : 4 KB)
  |  |  ------------------
  |  |  |  |  713|      0|#define LZ4_HASHTABLESIZE (1 << LZ4_MEMORY_USAGE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  162|      0|# define LZ4_MEMORY_USAGE LZ4_MEMORY_USAGE_DEFAULT
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  167|      0|#define LZ4_MEMORY_USAGE_DEFAULT 14
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define LZ4_DICTCTX_COPY_THRESHOLD ((LZ4_HASHTABLESIZE / 8 < 4 KB) ? (LZ4_HASHTABLESIZE / 8) : 4 KB)
  |  |  ------------------
  |  |  |  |  251|      0|#define KB *(1 <<10)
  |  |  ------------------
  |  |  |  Branch (1863:37): [True: 0, Folded]
  |  |  ------------------
  ------------------
  |  Branch (1925:17): [True: 0, False: 0]
  ------------------
 1926|       |                /* For compressing large blobs, it is faster to pay the setup
 1927|       |                 * cost to copy the dictionary's tables into the active context,
 1928|       |                 * so that the compression loop is only looking into one table.
 1929|       |                 */
 1930|      0|                LZ4_memcpy(streamPtr, streamPtr->dictCtx, sizeof(*streamPtr));
  ------------------
  |  |  349|      0|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 1931|      0|                result = LZ4_compress_generic(streamPtr, source, dest, inputSize, NULL, maxOutputSize, limitedOutput, tableType, usingExtDict, noDictIssue, acceleration);
 1932|      0|            } else {
 1933|      0|                result = LZ4_compress_generic(streamPtr, source, dest, inputSize, NULL, maxOutputSize, limitedOutput, tableType, usingDictCtx, noDictIssue, acceleration);
 1934|      0|            }
 1935|  2.41k|        } else {  /* external dictionary in the current context */
 1936|  2.41k|            if (LZ4_isDictSmall(streamPtr)) {
  ------------------
  |  Branch (1936:17): [True: 0, False: 2.41k]
  ------------------
 1937|      0|                result = LZ4_compress_generic(streamPtr, source, dest, inputSize, NULL, maxOutputSize, limitedOutput, tableType, usingExtDict, dictSmall, acceleration);
 1938|  2.41k|            } else {
 1939|       |                result = LZ4_compress_generic(streamPtr, source, dest, inputSize, NULL, maxOutputSize, limitedOutput, tableType, usingExtDict, noDictIssue, acceleration);
 1940|  2.41k|            }
 1941|  2.41k|        }
 1942|  2.41k|        streamPtr->dictionary = (const BYTE*)source;
 1943|  2.41k|        streamPtr->dictSize = (U32)inputSize;
 1944|  2.41k|        return result;
 1945|  7.66k|    }
 1946|  7.66k|}
LZ4_saveDict:
 1978|  3.94k|{
 1979|  3.94k|    LZ4_stream_t_internal* const dict = &LZ4_dict->internal_donotuse;
 1980|       |
 1981|  3.94k|    DEBUGLOG(5, "LZ4_saveDict : dictSize=%i, safeBuffer=%p", dictSize, (void*)safeBuffer);
  ------------------
  |  |  289|  3.94k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1982|       |
 1983|  3.94k|    if (dictSize < 0) dictSize = 0;   /* invalid : save nothing, like LZ4_saveDictHC() */
  ------------------
  |  Branch (1983:9): [True: 0, False: 3.94k]
  ------------------
 1984|  3.94k|    if ((U32)dictSize > 64 KB) { dictSize = 64 KB; } /* useless to define a dictionary > 64 KB */
  ------------------
  |  |  251|  3.94k|#define KB *(1 <<10)
  ------------------
                  if ((U32)dictSize > 64 KB) { dictSize = 64 KB; } /* useless to define a dictionary > 64 KB */
  ------------------
  |  |  251|      0|#define KB *(1 <<10)
  ------------------
  |  Branch (1984:9): [True: 0, False: 3.94k]
  ------------------
 1985|  3.94k|    if ((U32)dictSize > dict->dictSize) { dictSize = (int)dict->dictSize; }
  ------------------
  |  Branch (1985:9): [True: 0, False: 3.94k]
  ------------------
 1986|       |
 1987|  3.94k|    if (safeBuffer == NULL) assert(dictSize == 0);
  ------------------
  |  Branch (1987:9): [True: 0, False: 3.94k]
  |  Branch (1987:29): [True: 0, False: 0]
  |  Branch (1987:29): [True: 0, False: 0]
  ------------------
 1988|  3.94k|    if (dictSize > 0) {
  ------------------
  |  Branch (1988:9): [True: 3.94k, False: 0]
  ------------------
 1989|  3.94k|        const BYTE* const previousDictEnd = dict->dictionary + dict->dictSize;
 1990|  3.94k|        assert(dict->dictionary);
  ------------------
  |  Branch (1990:9): [True: 0, False: 3.94k]
  |  Branch (1990:9): [True: 3.94k, False: 0]
  ------------------
 1991|  3.94k|        LZ4_memmove(safeBuffer, previousDictEnd - dictSize, (size_t)dictSize);
  ------------------
  |  |  357|  3.94k|#    define LZ4_memmove __builtin_memmove
  ------------------
 1992|  3.94k|    }
 1993|       |
 1994|  3.94k|    dict->dictionary = (const BYTE*)safeBuffer;
 1995|  3.94k|    dict->dictSize = (U32)dictSize;
 1996|       |
 1997|  3.94k|    return dictSize;
 1998|  3.94k|}
LZ4_decompress_safe:
 2589|  30.0k|{
 2590|  30.0k|    return LZ4_decompress_generic(source, dest, compressedSize, maxDecompressedSize,
 2591|  30.0k|                                  decode_full_block, noDict,
 2592|       |                                  (BYTE*)dest, NULL, 0);
 2593|  30.0k|}
LZ4_decompress_safe_withPrefix64k:
 2617|  14.0k|{
 2618|  14.0k|    return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize,
 2619|  14.0k|                                  decode_full_block, withPrefix64k,
 2620|  14.0k|                                  (BYTE*)dest - 64 KB, NULL, 0);
  ------------------
  |  |  251|  14.0k|#define KB *(1 <<10)
  ------------------
 2621|  14.0k|}
LZ4_decompress_safe_forceExtDict:
 2663|  2.66k|{
 2664|  2.66k|    DEBUGLOG(5, "LZ4_decompress_safe_forceExtDict");
  ------------------
  |  |  289|  2.66k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2665|  2.66k|    return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize,
 2666|  2.66k|                                  decode_full_block, usingExtDict,
 2667|  2.66k|                                  (BYTE*)dest, (const BYTE*)dictStart, dictSize);
 2668|  2.66k|}
LZ4_decompress_safe_usingDict:
 2862|  52.0k|{
 2863|  52.0k|    if (dictSize < 0) return -1;
  ------------------
  |  Branch (2863:9): [True: 0, False: 52.0k]
  ------------------
 2864|  52.0k|    if (dictSize==0)
  ------------------
  |  Branch (2864:9): [True: 30.0k, False: 22.0k]
  ------------------
 2865|  30.0k|        return LZ4_decompress_safe(source, dest, compressedSize, maxOutputSize);
 2866|  22.0k|    if (dictStart+dictSize == dest) {
  ------------------
  |  Branch (2866:9): [True: 19.3k, False: 2.66k]
  ------------------
 2867|  19.3k|        if (dictSize >= 64 KB - 1) {
  ------------------
  |  |  251|  19.3k|#define KB *(1 <<10)
  ------------------
  |  Branch (2867:13): [True: 14.0k, False: 5.30k]
  ------------------
 2868|  14.0k|            return LZ4_decompress_safe_withPrefix64k(source, dest, compressedSize, maxOutputSize);
 2869|  14.0k|        }
 2870|  19.3k|        assert(dictSize >= 0);
  ------------------
  |  Branch (2870:9): [True: 0, False: 5.30k]
  |  Branch (2870:9): [True: 5.30k, False: 0]
  ------------------
 2871|  5.30k|        return LZ4_decompress_safe_withSmallPrefix(source, dest, compressedSize, maxOutputSize, (size_t)dictSize);
 2872|  5.30k|    }
 2873|  22.0k|    assert(dictSize >= 0);
  ------------------
  |  Branch (2873:5): [True: 0, False: 2.66k]
  |  Branch (2873:5): [True: 2.66k, False: 0]
  ------------------
 2874|  2.66k|    return LZ4_decompress_safe_forceExtDict(source, dest, compressedSize, maxOutputSize, dictStart, (size_t)dictSize);
 2875|  2.66k|}
lz4.c:LZ4_clampAcceleration:
 1525|  11.3k|{
 1526|  11.3k|    if (acceleration < 1) return LZ4_ACCELERATION_DEFAULT;
  ------------------
  |  |  614|      0|#define LZ4_ACCELERATION_DEFAULT 1
  ------------------
  |  Branch (1526:9): [True: 0, False: 11.3k]
  ------------------
 1527|  11.3k|    if (acceleration > LZ4_ACCELERATION_MAX) return LZ4_ACCELERATION_MAX;
  ------------------
  |  |  615|  11.3k|#define LZ4_ACCELERATION_MAX 65537
  ------------------
                  if (acceleration > LZ4_ACCELERATION_MAX) return LZ4_ACCELERATION_MAX;
  ------------------
  |  |  615|      0|#define LZ4_ACCELERATION_MAX 65537
  ------------------
  |  Branch (1527:9): [True: 0, False: 11.3k]
  ------------------
 1528|  11.3k|    return acceleration;
 1529|  11.3k|}
lz4.c:LZ4_compress_fastReset_generic:
 1549|  3.69k|{
 1550|  3.69k|    if (srcSize < LZ4_64Klimit) {
  ------------------
  |  Branch (1550:9): [True: 3.28k, False: 412]
  ------------------
 1551|  3.28k|        LZ4_prepareTable(ctx, srcSize, byU16);
 1552|  3.28k|        if (ctx->currentOffset) {  /* table re-used : stale entries must be rejected */
  ------------------
  |  Branch (1552:13): [True: 799, False: 2.48k]
  ------------------
 1553|    799|            return LZ4_compress_generic(ctx, src, dst, srcSize, NULL, dstCapacity, outputDirective, byU16, noDict, dictSmall, acceleration);
 1554|  2.48k|        } else {
 1555|  2.48k|            return LZ4_compress_generic(ctx, src, dst, srcSize, NULL, dstCapacity, outputDirective, byU16, noDict, noDictIssue, acceleration);
 1556|  2.48k|        }
 1557|  3.28k|    } else {
 1558|    412|        const tableType_t tableType = LZ4_largeInputTableType(src);
 1559|    412|        LZ4_prepareTable(ctx, srcSize, tableType);
 1560|       |        return LZ4_compress_generic(ctx, src, dst, srcSize, NULL, dstCapacity, outputDirective, tableType, noDict, noDictIssue, acceleration);
 1561|    412|    }
 1562|  3.69k|}
lz4.c:LZ4_largeInputTableType:
 1535|    412|{
 1536|    412|    (void)src;   /* unused on 64-bit systems */
 1537|    412|    return ((sizeof(void*)==4) && ((uptrval)src > LZ4_DISTANCE_MAX)) ? byPtr : byU32;
  ------------------
  |  |  691|      0|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (1537:13): [Folded, False: 412]
  |  Branch (1537:35): [True: 0, False: 0]
  ------------------
 1538|    412|}
lz4.c:LZ4_isAligned:
  293|  8.33k|{
  294|  8.33k|    return ((size_t)ptr & (alignment -1)) == 0;
  295|  8.33k|}
lz4.c:LZ4_stream_t_alignment:
 1685|  8.33k|{
 1686|  8.33k|#if LZ4_ALIGN_TEST
 1687|  8.33k|    typedef struct { char c; LZ4_stream_t t; } t_a;
 1688|  8.33k|    return sizeof(t_a) - sizeof(LZ4_stream_t);
 1689|       |#else
 1690|       |    return 1;  /* effectively disabled */
 1691|       |#endif
 1692|  8.33k|}
lz4.c:LZ4_prepareTable:
  954|  5.05k|           const tableType_t tableType) {
  955|       |    /* If the table hasn't been used, it's guaranteed to be zeroed out, and is
  956|       |     * therefore safe to use no matter what mode we're in. Otherwise, we figure
  957|       |     * out if it's safe to leave as is or whether it needs to be reset.
  958|       |     */
  959|  5.05k|    if ((tableType_t)cctx->tableType != clearedTable) {
  ------------------
  |  Branch (959:9): [True: 1.47k, False: 3.58k]
  ------------------
  960|  1.47k|        assert(inputSize >= 0);
  ------------------
  |  Branch (960:9): [True: 0, False: 1.47k]
  |  Branch (960:9): [True: 1.47k, False: 0]
  ------------------
  961|  1.47k|        if ((tableType_t)cctx->tableType != tableType
  ------------------
  |  Branch (961:13): [True: 8, False: 1.46k]
  ------------------
  962|  1.46k|          || ((tableType == byU16) && cctx->currentOffset + (unsigned)inputSize >= 0xFFFFU)
  ------------------
  |  Branch (962:15): [True: 1.34k, False: 119]
  |  Branch (962:39): [True: 497, False: 846]
  ------------------
  963|    965|          || ((tableType == byU32) && cctx->currentOffset > 1 GB)
  ------------------
  |  |  253|    119|#define GB *(1U<<30)
  ------------------
  |  Branch (963:15): [True: 119, False: 846]
  |  Branch (963:39): [True: 0, False: 119]
  ------------------
  964|    965|          || tableType == byPtr
  ------------------
  |  Branch (964:14): [True: 0, False: 965]
  ------------------
  965|    965|          || inputSize >= LZ4_CLEAR_TABLE_THRESHOLD)
  ------------------
  |  |  949|    965|#define LZ4_CLEAR_TABLE_THRESHOLD (LZ4_HASHTABLESIZE / 16)
  |  |  ------------------
  |  |  |  |  713|    965|#define LZ4_HASHTABLESIZE (1 << LZ4_MEMORY_USAGE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  162|    965|# define LZ4_MEMORY_USAGE LZ4_MEMORY_USAGE_DEFAULT
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  167|    965|#define LZ4_MEMORY_USAGE_DEFAULT 14
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (965:14): [True: 166, False: 799]
  ------------------
  966|    671|        {
  967|    671|            DEBUGLOG(4, "LZ4_prepareTable: Resetting table in %p", (void*)cctx);
  ------------------
  |  |  289|    671|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  968|    671|            MEM_INIT(cctx->hashTable, 0, LZ4_HASHTABLESIZE);
  ------------------
  |  |  236|    671|#define MEM_INIT(p,v,s)   LZ4_memset((p),(v),(s))
  |  |  ------------------
  |  |  |  |  234|    671|#  define LZ4_memset(p,v,s) memset((p),(v),(s))
  |  |  ------------------
  ------------------
  969|    671|            cctx->currentOffset = 0;
  970|    671|            cctx->tableType = (U32)clearedTable;
  971|    799|        } else {
  972|    799|            DEBUGLOG(4, "LZ4_prepareTable: Re-use hash table (no reset)");
  ------------------
  |  |  289|    799|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  973|    799|        }
  974|  1.47k|    }
  975|       |
  976|       |    /* Adding a gap, so all previous entries are > LZ4_DISTANCE_MAX back,
  977|       |     * is faster than compressing without a gap.
  978|       |     * However, compressing with currentOffset == 0 is faster still,
  979|       |     * so we preserve that case.
  980|       |     */
  981|  5.05k|    if (cctx->currentOffset != 0 && tableType == byU32) {
  ------------------
  |  Branch (981:9): [True: 799, False: 4.25k]
  |  Branch (981:37): [True: 0, False: 799]
  ------------------
  982|      0|        DEBUGLOG(5, "LZ4_prepareTable: adding 64KB to currentOffset");
  ------------------
  |  |  289|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  983|      0|        cctx->currentOffset += 64 KB;
  ------------------
  |  |  251|      0|#define KB *(1 <<10)
  ------------------
  984|      0|    }
  985|       |
  986|       |    /* Finally, clear history */
  987|  5.05k|    cctx->dictCtx = NULL;
  988|       |    cctx->dictionary = NULL;
  989|  5.05k|    cctx->dictSize = 0;
  990|  5.05k|}
lz4.c:LZ4_hashPosition:
  864|  45.0M|{
  865|  45.0M|    if ((sizeof(reg_t)==8) && (tableType != byU16)) return LZ4_hash5(LZ4_read_ARCH(p), tableType);
  ------------------
  |  Branch (865:9): [True: 45.0M, Folded]
  |  Branch (865:31): [True: 39.1M, False: 5.94M]
  ------------------
  866|       |
  867|       |#ifdef LZ4_STATIC_LINKING_ONLY_ENDIANNESS_INDEPENDENT_OUTPUT
  868|       |    return LZ4_hash4(LZ4_readLE32(p), tableType);
  869|       |#else
  870|  5.94M|    return LZ4_hash4(LZ4_read32(p), tableType);
  871|  45.0M|#endif
  872|  45.0M|}
lz4.c:LZ4_hash5:
  852|  39.1M|{
  853|  39.1M|    const U32 hashLog = (tableType == byU16) ? LZ4_HASHLOG+1 : LZ4_HASHLOG;
  ------------------
  |  |  712|      0|#define LZ4_HASHLOG   (LZ4_MEMORY_USAGE-2)
  |  |  ------------------
  |  |  |  |  162|      0|# define LZ4_MEMORY_USAGE LZ4_MEMORY_USAGE_DEFAULT
  |  |  |  |  ------------------
  |  |  |  |  |  |  167|      0|#define LZ4_MEMORY_USAGE_DEFAULT 14
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  const U32 hashLog = (tableType == byU16) ? LZ4_HASHLOG+1 : LZ4_HASHLOG;
  ------------------
  |  |  712|  78.2M|#define LZ4_HASHLOG   (LZ4_MEMORY_USAGE-2)
  |  |  ------------------
  |  |  |  |  162|  39.1M|# define LZ4_MEMORY_USAGE LZ4_MEMORY_USAGE_DEFAULT
  |  |  |  |  ------------------
  |  |  |  |  |  |  167|  39.1M|#define LZ4_MEMORY_USAGE_DEFAULT 14
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (853:25): [True: 0, False: 39.1M]
  ------------------
  854|  39.1M|    if (LZ4_isLittleEndian()) {
  ------------------
  |  Branch (854:9): [True: 39.1M, False: 0]
  ------------------
  855|  39.1M|        const U64 prime5bytes = 889523592379ULL;
  856|  39.1M|        return (U32)(((sequence << 24) * prime5bytes) >> (64 - hashLog));
  857|  39.1M|    } else {
  858|      0|        const U64 prime8bytes = 11400714785074694791ULL;
  859|      0|        return (U32)(((sequence >> 24) * prime8bytes) >> (64 - hashLog));
  860|      0|    }
  861|  39.1M|}
lz4.c:LZ4_isLittleEndian:
  364|  85.9M|{
  365|  85.9M|    const union { U32 u; BYTE c[4]; } one = { 1 };   /* don't use static : performance detrimental */
  366|  85.9M|    return one.c[0];
  367|  85.9M|}
lz4.c:LZ4_read_ARCH:
  395|   145M|static reg_t LZ4_read_ARCH(const void* ptr) { return ((const LZ4_unalignST*)ptr)->uArch; }
lz4.c:LZ4_hash4:
  846|  5.94M|{
  847|  5.94M|    const U32 hashLog = (tableType == byU16) ? LZ4_HASHLOG+1 : LZ4_HASHLOG;
  ------------------
  |  |  712|  5.94M|#define LZ4_HASHLOG   (LZ4_MEMORY_USAGE-2)
  |  |  ------------------
  |  |  |  |  162|  5.94M|# define LZ4_MEMORY_USAGE LZ4_MEMORY_USAGE_DEFAULT
  |  |  |  |  ------------------
  |  |  |  |  |  |  167|  5.94M|#define LZ4_MEMORY_USAGE_DEFAULT 14
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  const U32 hashLog = (tableType == byU16) ? LZ4_HASHLOG+1 : LZ4_HASHLOG;
  ------------------
  |  |  712|  5.94M|#define LZ4_HASHLOG   (LZ4_MEMORY_USAGE-2)
  |  |  ------------------
  |  |  |  |  162|      0|# define LZ4_MEMORY_USAGE LZ4_MEMORY_USAGE_DEFAULT
  |  |  |  |  ------------------
  |  |  |  |  |  |  167|      0|#define LZ4_MEMORY_USAGE_DEFAULT 14
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (847:25): [True: 5.94M, False: 0]
  ------------------
  848|  5.94M|    return ((sequence * 2654435761U) >> ((MINMATCH*8)-hashLog));
  ------------------
  |  |  242|  5.94M|#define MINMATCH 4
  ------------------
  849|  5.94M|}
lz4.c:LZ4_read32:
  394|  65.2M|static U32 LZ4_read32(const void* ptr) { return ((const LZ4_unalign32*)ptr)->u32; }
lz4.c:LZ4_putIndexOnHash:
  887|  41.1M|{
  888|  41.1M|    switch (tableType)
  889|  41.1M|    {
  890|      0|    default: /* fallthrough */
  ------------------
  |  Branch (890:5): [True: 0, False: 41.1M]
  ------------------
  891|      0|    case clearedTable: /* fallthrough */
  ------------------
  |  Branch (891:5): [True: 0, False: 41.1M]
  ------------------
  892|      0|    case byPtr: { /* illegal! */ assert(0); return; }
  ------------------
  |  Branch (892:5): [True: 0, False: 41.1M]
  |  Branch (892:34): [Folded, False: 0]
  |  Branch (892:34): [Folded, False: 0]
  ------------------
  893|  35.5M|    case byU32: { U32* hashTable = (U32*) tableBase; hashTable[h] = idx; return; }
  ------------------
  |  Branch (893:5): [True: 35.5M, False: 5.55M]
  ------------------
  894|  5.55M|    case byU16: { U16* hashTable = (U16*) tableBase; assert(idx < 65536); hashTable[h] = (U16)idx; return; }
  ------------------
  |  Branch (894:5): [True: 5.55M, False: 35.5M]
  |  Branch (894:54): [True: 0, False: 5.55M]
  |  Branch (894:54): [True: 5.55M, False: 0]
  ------------------
  895|  41.1M|    }
  896|  41.1M|}
lz4.c:LZ4_getIndexOnHash:
  926|  39.8M|{
  927|  39.8M|    LZ4_STATIC_ASSERT(LZ4_MEMORY_USAGE > 2);
  ------------------
  |  |  277|  39.8M|#define LZ4_STATIC_ASSERT(c)   { enum { LZ4_static_assert = 1/(int)(!!(c)) }; }   /* use after variable declarations */
  ------------------
  928|  39.8M|    if (tableType == byU32) {
  ------------------
  |  Branch (928:9): [True: 34.4M, False: 5.44M]
  ------------------
  929|  34.4M|        const U32* const hashTable = (const U32*) tableBase;
  930|  34.4M|        assert(h < (1U << (LZ4_MEMORY_USAGE-2)));
  ------------------
  |  Branch (930:9): [True: 0, False: 34.4M]
  |  Branch (930:9): [True: 34.4M, False: 0]
  ------------------
  931|  34.4M|        return hashTable[h];
  932|  34.4M|    }
  933|  5.44M|    if (tableType == byU16) {
  ------------------
  |  Branch (933:9): [True: 5.44M, False: 0]
  ------------------
  934|  5.44M|        const U16* const hashTable = (const U16*) tableBase;
  935|  5.44M|        assert(h < (1U << (LZ4_MEMORY_USAGE-1)));
  ------------------
  |  Branch (935:9): [True: 0, False: 5.44M]
  |  Branch (935:9): [True: 5.44M, False: 0]
  ------------------
  936|  5.44M|        return hashTable[h];
  937|  5.44M|    }
  938|  5.44M|    assert(0); return 0;  /* forbidden case */
  ------------------
  |  Branch (938:5): [Folded, False: 0]
  |  Branch (938:5): [Folded, False: 0]
  ------------------
  939|      0|}
lz4.c:LZ4_renormDictT:
 1834|  7.66k|{
 1835|  7.66k|    assert(nextSize >= 0);
  ------------------
  |  Branch (1835:5): [True: 0, False: 7.66k]
  |  Branch (1835:5): [True: 7.66k, False: 0]
  ------------------
 1836|  7.66k|    if (LZ4_dict->currentOffset + (unsigned)nextSize > 0x80000000) {   /* potential ptrdiff_t overflow (32-bits mode) */
  ------------------
  |  Branch (1836:9): [True: 0, False: 7.66k]
  ------------------
 1837|       |        /* rescale hash table */
 1838|      0|        U32 const delta = LZ4_dict->currentOffset - 64 KB;
  ------------------
  |  |  251|      0|#define KB *(1 <<10)
  ------------------
 1839|      0|        const BYTE* dictEnd = LZ4_dict->dictionary + LZ4_dict->dictSize;
 1840|      0|        int i;
 1841|      0|        DEBUGLOG(4, "LZ4_renormDictT");
  ------------------
  |  |  289|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1842|      0|        for (i=0; i<LZ4_HASH_SIZE_U32; i++) {
  ------------------
  |  |  714|      0|#define LZ4_HASH_SIZE_U32 (1 << LZ4_HASHLOG)       /* required as macro for static allocation */
  |  |  ------------------
  |  |  |  |  712|      0|#define LZ4_HASHLOG   (LZ4_MEMORY_USAGE-2)
  |  |  |  |  ------------------
  |  |  |  |  |  |  162|      0|# define LZ4_MEMORY_USAGE LZ4_MEMORY_USAGE_DEFAULT
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  167|      0|#define LZ4_MEMORY_USAGE_DEFAULT 14
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1842:19): [True: 0, False: 0]
  ------------------
 1843|      0|            if (LZ4_dict->hashTable[i] < delta) LZ4_dict->hashTable[i]=0;
  ------------------
  |  Branch (1843:17): [True: 0, False: 0]
  ------------------
 1844|      0|            else LZ4_dict->hashTable[i] -= delta;
 1845|      0|        }
 1846|      0|        LZ4_dict->currentOffset = 64 KB;
  ------------------
  |  |  251|      0|#define KB *(1 <<10)
  ------------------
 1847|      0|        if (LZ4_dict->dictSize > 64 KB) LZ4_dict->dictSize = 64 KB;
  ------------------
  |  |  251|      0|#define KB *(1 <<10)
  ------------------
                      if (LZ4_dict->dictSize > 64 KB) LZ4_dict->dictSize = 64 KB;
  ------------------
  |  |  251|      0|#define KB *(1 <<10)
  ------------------
  |  Branch (1847:13): [True: 0, False: 0]
  ------------------
 1848|      0|        LZ4_dict->dictionary = dictEnd - LZ4_dict->dictSize;
 1849|      0|    }
 1850|  7.66k|}
lz4.c:LZ4_isDictSmall:
 1856|  7.66k|{
 1857|  7.66k|    return (streamPtr->dictSize < 64 KB) && (streamPtr->dictSize < streamPtr->currentOffset);
  ------------------
  |  |  251|  7.66k|#define KB *(1 <<10)
  ------------------
  |  Branch (1857:12): [True: 3.55k, False: 4.10k]
  |  Branch (1857:45): [True: 0, False: 3.55k]
  ------------------
 1858|  7.66k|}
lz4.c:LZ4_compress_generic:
 1481|  11.3k|{
 1482|  11.3k|    DEBUGLOG(5, "LZ4_compress_generic: srcSize=%i, dstCapacity=%i",
  ------------------
  |  |  289|  11.3k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1483|  11.3k|                srcSize, dstCapacity);
 1484|       |
 1485|  11.3k|    if ((U32)srcSize > (U32)LZ4_MAX_INPUT_SIZE) { return 0; }  /* Unsupported srcSize, too large (or negative) */
  ------------------
  |  |  221|  11.3k|#define LZ4_MAX_INPUT_SIZE        0x7E000000   /* 2 113 929 216 bytes */
  ------------------
  |  Branch (1485:9): [True: 0, False: 11.3k]
  ------------------
 1486|  11.3k|    if (srcSize == 0) {   /* src == NULL supported if srcSize == 0 */
  ------------------
  |  Branch (1486:9): [True: 0, False: 11.3k]
  ------------------
 1487|      0|        if (outputDirective != notLimited && dstCapacity <= 0) return 0;  /* no output, can't write anything */
  ------------------
  |  Branch (1487:13): [True: 0, False: 0]
  |  Branch (1487:46): [True: 0, False: 0]
  ------------------
 1488|      0|        DEBUGLOG(5, "Generating an empty block");
  ------------------
  |  |  289|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1489|      0|        assert(outputDirective == notLimited || dstCapacity >= 1);
  ------------------
  |  Branch (1489:9): [True: 0, False: 0]
  |  Branch (1489:9): [True: 0, False: 0]
  |  Branch (1489:9): [True: 0, False: 0]
  |  Branch (1489:9): [True: 0, False: 0]
  ------------------
 1490|      0|        assert(dst != NULL);
  ------------------
  |  Branch (1490:9): [True: 0, False: 0]
  |  Branch (1490:9): [True: 0, False: 0]
  ------------------
 1491|      0|        dst[0] = 0;
 1492|      0|        if (outputDirective == fillOutput) {
  ------------------
  |  Branch (1492:13): [True: 0, False: 0]
  ------------------
 1493|      0|            assert (inputConsumed != NULL);
  ------------------
  |  Branch (1493:13): [True: 0, False: 0]
  |  Branch (1493:13): [True: 0, False: 0]
  ------------------
 1494|      0|            *inputConsumed = 0;
 1495|      0|        }
 1496|      0|        return 1;
 1497|      0|    }
 1498|  11.3k|    assert(src != NULL);
  ------------------
  |  Branch (1498:5): [True: 0, False: 11.3k]
  |  Branch (1498:5): [True: 11.3k, False: 0]
  ------------------
 1499|       |
 1500|  11.3k|    if ((dictDirective == usingExtDict) && (dictIssue == noDictIssue)) {
  ------------------
  |  Branch (1500:9): [True: 2.41k, False: 8.94k]
  |  Branch (1500:44): [True: 2.41k, False: 0]
  ------------------
 1501|       |        /* beyond LZ4_DISTANCE_MAX, the dictionary is out of reach : the rest of the input is compressed in prefix mode */
 1502|  2.41k|        LZ4_resume_t state;
 1503|  2.41k|        int result;
 1504|  2.41k|        assert(tableType == byU32);
  ------------------
  |  Branch (1504:9): [True: 0, False: 2.41k]
  |  Branch (1504:9): [True: 2.41k, False: 0]
  ------------------
 1505|  2.41k|        assert(outputDirective != fillOutput);
  ------------------
  |  Branch (1505:9): [True: 0, False: 2.41k]
  |  Branch (1505:9): [True: 2.41k, False: 0]
  ------------------
 1506|  2.41k|        state.ip = NULL;
 1507|  2.41k|        result = LZ4_compress_generic_validated(cctx, src, dst, srcSize, inputConsumed, dstCapacity, outputDirective,
 1508|  2.41k|                    tableType, usingExtDict, noDictIssue, acceleration, &state, NULL);
 1509|  2.41k|        if (state.ip == NULL) return result;   /* completed (or failed) in extDict mode */
  ------------------
  |  Branch (1509:13): [True: 1.82k, False: 590]
  ------------------
 1510|       |        /* notLimited : dst is presumed large enough for LZ4_compressBound() */
 1511|    590|        return LZ4_compress_resumeWithPrefix(cctx, src, dst, srcSize,
 1512|    590|                    (outputDirective == notLimited) ? LZ4_COMPRESSBOUND(srcSize) : dstCapacity,
  ------------------
  |  |  222|      0|#define LZ4_COMPRESSBOUND(isize)  ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16)
  |  |  ------------------
  |  |  |  |  221|      0|#define LZ4_MAX_INPUT_SIZE        0x7E000000   /* 2 113 929 216 bytes */
  |  |  ------------------
  |  |  |  Branch (222:36): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1512:21): [True: 0, False: 590]
  ------------------
 1513|    590|                    acceleration, &state);
 1514|  2.41k|    }
 1515|       |
 1516|  8.94k|    return LZ4_compress_generic_validated(cctx, src, dst, srcSize,
 1517|  8.94k|                inputConsumed, /* only written into if outputDirective == fillOutput */
 1518|  8.94k|                dstCapacity, outputDirective,
 1519|  8.94k|                tableType, dictDirective, dictIssue, acceleration, NULL, NULL);
 1520|  11.3k|}
lz4.c:LZ4_compress_generic_validated:
 1027|  11.9k|{
 1028|  11.9k|    int result;
 1029|  11.9k|    const BYTE* ip = resume ? resume->ip : (const BYTE*)source;
  ------------------
  |  Branch (1029:22): [True: 590, False: 11.3k]
  ------------------
 1030|       |
 1031|  11.9k|    U32 const startIndex = resume ? resume->startIndex : cctx->currentOffset;
  ------------------
  |  Branch (1031:28): [True: 590, False: 11.3k]
  ------------------
 1032|  11.9k|    const BYTE* base = (const BYTE*)source - startIndex;
 1033|  11.9k|    const BYTE* lowLimit;
 1034|       |
 1035|  11.9k|    const LZ4_stream_t_internal* dictCtx = (const LZ4_stream_t_internal*) cctx->dictCtx;
 1036|  11.9k|    const BYTE* const dictionary =
 1037|  11.9k|        dictDirective == usingDictCtx ? dictCtx->dictionary : cctx->dictionary;
  ------------------
  |  Branch (1037:9): [True: 0, False: 11.9k]
  ------------------
 1038|  11.9k|    const U32 dictSize =
 1039|  11.9k|        dictDirective == usingDictCtx ? dictCtx->dictSize : cctx->dictSize;
  ------------------
  |  Branch (1039:9): [True: 0, False: 11.9k]
  ------------------
 1040|  11.9k|    const U32 dictDelta =
 1041|  11.9k|        (dictDirective == usingDictCtx) ? startIndex - dictCtx->currentOffset : 0;   /* make indexes in dictCtx comparable with indexes in current context */
  ------------------
  |  Branch (1041:9): [True: 0, False: 11.9k]
  ------------------
 1042|       |
 1043|  11.9k|    int const maybe_extMem = (dictDirective == usingExtDict) || (dictDirective == usingDictCtx);
  ------------------
  |  Branch (1043:30): [True: 2.41k, False: 9.53k]
  |  Branch (1043:65): [True: 0, False: 9.53k]
  ------------------
 1044|  11.9k|    U32 const prefixIdxLimit = startIndex - dictSize;   /* used when dictDirective == dictSmall */
 1045|  11.9k|    const BYTE* const dictEnd = dictionary ? dictionary + dictSize : dictionary;
  ------------------
  |  Branch (1045:33): [True: 8.25k, False: 3.69k]
  ------------------
 1046|  11.9k|    const BYTE* anchor = resume ? resume->ip : (const BYTE*)source;
  ------------------
  |  Branch (1046:26): [True: 590, False: 11.3k]
  ------------------
 1047|  11.9k|    const BYTE* const iend = (const BYTE*)source + inputSize;
 1048|  11.9k|    const BYTE* mflimitPlusOne;   /* set after the size check : would precede a small input */
 1049|  11.9k|    const BYTE* matchlimit;
 1050|  11.9k|    const BYTE* seqLimit;   /* suspend : mflimitPlusOne, or earlier, where the dictionary gets out of reach */
 1051|       |
 1052|       |    /* the dictCtx currentOffset is indexed on the start of the dictionary,
 1053|       |     * while a dictionary in the current context precedes the currentOffset */
 1054|  11.9k|    const BYTE* dictBase = (dictionary == NULL) ? NULL :
  ------------------
  |  Branch (1054:28): [True: 3.69k, False: 8.25k]
  ------------------
 1055|  11.9k|                           (dictDirective == usingDictCtx) ?
  ------------------
  |  Branch (1055:28): [True: 0, False: 8.25k]
  ------------------
 1056|      0|                            dictionary + dictSize - dictCtx->currentOffset :
 1057|  8.25k|                            dictionary + dictSize - startIndex;
 1058|       |
 1059|  11.9k|    BYTE* op = resume ? resume->op : (BYTE*)dest;
  ------------------
  |  Branch (1059:16): [True: 590, False: 11.3k]
  ------------------
 1060|  11.9k|    BYTE* const olimit = (BYTE*)dest + maxOutputSize;
 1061|       |
 1062|  11.9k|    U32 offset = 0;
 1063|  11.9k|    U32 forwardH;
 1064|  11.9k|    const BYTE* filledIp = NULL;   /* fillOutput only ; set by catch up (resume : never with fillOutput) */
 1065|       |
 1066|  11.9k|    DEBUGLOG(5, "LZ4_compress_generic_validated: srcSize=%i, tableType=%u", inputSize, tableType);
  ------------------
  |  |  289|  11.9k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1067|  11.9k|    assert(ip != NULL);
  ------------------
  |  Branch (1067:5): [True: 0, False: 11.9k]
  |  Branch (1067:5): [True: 11.9k, False: 0]
  ------------------
 1068|  11.9k|    if (tableType == byU16) assert(inputSize<LZ4_64Klimit);  /* Size too large (not within 64K limit) */
  ------------------
  |  Branch (1068:9): [True: 3.28k, False: 8.66k]
  |  Branch (1068:29): [True: 0, False: 3.28k]
  |  Branch (1068:29): [True: 3.28k, False: 0]
  ------------------
 1069|  11.9k|    if (tableType == byPtr) assert(dictDirective==noDict);   /* only supported use case with byPtr */
  ------------------
  |  Branch (1069:9): [True: 0, False: 11.9k]
  |  Branch (1069:29): [True: 0, False: 0]
  |  Branch (1069:29): [True: 0, False: 0]
  ------------------
 1070|       |    /* If init conditions are not met, we don't have to mark stream
 1071|       |     * as having dirty context, since no action was taken yet */
 1072|  11.9k|    if (outputDirective == fillOutput && maxOutputSize < 1) { return 0; } /* Impossible to store anything */
  ------------------
  |  Branch (1072:9): [True: 0, False: 11.9k]
  |  Branch (1072:42): [True: 0, False: 0]
  ------------------
 1073|  11.9k|    assert(acceleration >= 1);
  ------------------
  |  Branch (1073:5): [True: 0, False: 11.9k]
  |  Branch (1073:5): [True: 11.9k, False: 0]
  ------------------
 1074|       |
 1075|       |    /* resume : candidates are within source (see LZ4_compress_generic()) */
 1076|  11.9k|    lowLimit = (const BYTE*)source - ((dictDirective == withPrefix64k) && !resume ? dictSize : 0);
  ------------------
  |  Branch (1076:39): [True: 5.84k, False: 6.10k]
  |  Branch (1076:75): [True: 5.25k, False: 590]
  ------------------
 1077|       |
 1078|  11.9k|    if (!resume) {   /* resume : context state already updated */
  ------------------
  |  Branch (1078:9): [True: 11.3k, False: 590]
  ------------------
 1079|       |        /* Update context state */
 1080|  11.3k|        if (dictDirective == usingDictCtx) {
  ------------------
  |  Branch (1080:13): [True: 0, False: 11.3k]
  ------------------
 1081|       |            /* Subsequent linked blocks can't use the dictionary. */
 1082|       |            /* Instead, they use the block we just compressed. */
 1083|      0|            cctx->dictCtx = NULL;
 1084|      0|            cctx->dictSize = (U32)inputSize;
 1085|  11.3k|        } else {
 1086|  11.3k|            cctx->dictSize += (U32)inputSize;
 1087|  11.3k|        }
 1088|  11.3k|        cctx->currentOffset += (U32)inputSize;
 1089|  11.3k|        cctx->tableType = (U32)tableType;
 1090|       |
 1091|  11.3k|        if (inputSize<LZ4_minLength) goto _last_literals;        /* Input too small, no compression (all literals) */
  ------------------
  |  Branch (1091:13): [True: 934, False: 10.4k]
  ------------------
 1092|  11.3k|    }
 1093|  11.0k|    mflimitPlusOne = iend - MFLIMIT + 1;
  ------------------
  |  |  246|  11.0k|#define MFLIMIT       12   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
 1094|  11.0k|    matchlimit = iend - LASTLITERALS;
  ------------------
  |  |  245|  11.0k|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
 1095|  11.0k|    seqLimit = mflimitPlusOne;
 1096|  11.0k|    if ((suspend != NULL) && (inputSize > LZ4_DISTANCE_MAX + MFLIMIT - 1))   /* source + LZ4_DISTANCE_MAX < mflimitPlusOne */
  ------------------
  |  |  691|  2.41k|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
                  if ((suspend != NULL) && (inputSize > LZ4_DISTANCE_MAX + MFLIMIT - 1))   /* source + LZ4_DISTANCE_MAX < mflimitPlusOne */
  ------------------
  |  |  246|  2.41k|#define MFLIMIT       12   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  |  Branch (1096:9): [True: 2.41k, False: 8.60k]
  |  Branch (1096:30): [True: 611, False: 1.80k]
  ------------------
 1097|    611|        seqLimit = (const BYTE*)source + LZ4_DISTANCE_MAX;
  ------------------
  |  |  691|    611|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
 1098|       |
 1099|  11.0k|    if (resume) goto _resume;
  ------------------
  |  Branch (1099:9): [True: 590, False: 10.4k]
  ------------------
 1100|       |
 1101|       |    /* First Byte */
 1102|  10.4k|    LZ4_putPosition(ip, cctx->hashTable, tableType, base);
 1103|  10.4k|    ip++; forwardH = LZ4_hashPosition(ip, tableType);
 1104|       |
 1105|       |    /* Main Loop */
 1106|  3.93M|    for ( ; ; ) {
 1107|  3.93M|        const BYTE* match;
 1108|  3.93M|        BYTE* token;
 1109|       |
 1110|       |        /* Find a match */
 1111|  3.93M|        if (tableType == byPtr) {
  ------------------
  |  Branch (1111:13): [True: 0, False: 3.93M]
  ------------------
 1112|      0|            const BYTE* forwardIp = ip;
 1113|      0|            int step = 1;
 1114|      0|            int searchMatchNb = acceleration << LZ4_skipTrigger;
 1115|      0|            do {
 1116|      0|                U32 const h = forwardH;
 1117|      0|                ip = forwardIp;
 1118|      0|                forwardIp += step;
 1119|      0|                step = (searchMatchNb++ >> LZ4_skipTrigger);
 1120|       |
 1121|      0|                if (unlikely(forwardIp > mflimitPlusOne)) goto _last_literals;
  ------------------
  |  |  180|      0|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|      0|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1122|      0|                assert(ip < mflimitPlusOne);
  ------------------
  |  Branch (1122:17): [True: 0, False: 0]
  |  Branch (1122:17): [True: 0, False: 0]
  ------------------
 1123|       |
 1124|      0|                match = LZ4_getPositionOnHash(h, cctx->hashTable, tableType);
 1125|      0|                forwardH = LZ4_hashPosition(forwardIp, tableType);
 1126|      0|                LZ4_putPositionOnHash(ip, h, cctx->hashTable, tableType);
 1127|       |
 1128|      0|            } while ( (match+LZ4_DISTANCE_MAX < ip)
  ------------------
  |  |  691|      0|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (1128:23): [True: 0, False: 0]
  ------------------
 1129|      0|                   || (LZ4_read32(match) != LZ4_read32(ip)) );
  ------------------
  |  Branch (1129:23): [True: 0, False: 0]
  ------------------
 1130|       |
 1131|  3.93M|        } else {   /* byU32, byU16 */
 1132|       |
 1133|  3.93M|            const BYTE* forwardIp = ip;
 1134|  3.93M|            int step = 1;
 1135|  3.93M|            int searchMatchNb = acceleration << LZ4_skipTrigger;
 1136|  23.4M|            do {
 1137|  23.4M|                U32 const h = forwardH;
 1138|  23.4M|                U32 const current = (U32)(forwardIp - base);
 1139|  23.4M|                U32 matchIndex = LZ4_getIndexOnHash(h, cctx->hashTable, tableType);
 1140|  23.4M|                assert(matchIndex <= current);
  ------------------
  |  Branch (1140:17): [True: 0, False: 23.4M]
  |  Branch (1140:17): [True: 23.4M, False: 0]
  ------------------
 1141|  23.4M|                assert(forwardIp - base < (ptrdiff_t)(2 GB - 1));
  ------------------
  |  Branch (1141:17): [True: 0, False: 23.4M]
  |  Branch (1141:17): [True: 23.4M, False: 0]
  ------------------
 1142|  23.4M|                ip = forwardIp;
 1143|  23.4M|                forwardIp += step;
 1144|  23.4M|                step = (searchMatchNb++ >> LZ4_skipTrigger);
 1145|       |
 1146|  23.4M|                if (unlikely(forwardIp > mflimitPlusOne)) goto _last_literals;
  ------------------
  |  |  180|  23.4M|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|  23.4M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 3.93k, False: 23.4M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1147|  23.4M|                assert(ip < mflimitPlusOne);
  ------------------
  |  Branch (1147:17): [True: 0, False: 23.4M]
  |  Branch (1147:17): [True: 23.4M, False: 0]
  ------------------
 1148|       |
 1149|  23.4M|                if (dictDirective == usingDictCtx) {
  ------------------
  |  Branch (1149:21): [True: 0, False: 23.4M]
  ------------------
 1150|      0|                    if (matchIndex < startIndex) {
  ------------------
  |  Branch (1150:25): [True: 0, False: 0]
  ------------------
 1151|       |                        /* there was no match, try the dictionary */
 1152|      0|                        assert(tableType == byU32);
  ------------------
  |  Branch (1152:25): [True: 0, False: 0]
  |  Branch (1152:25): [True: 0, False: 0]
  ------------------
 1153|      0|                        matchIndex = LZ4_getIndexOnHash(h, dictCtx->hashTable, byU32);
 1154|      0|                        match = dictBase + matchIndex;
 1155|      0|                        matchIndex += dictDelta;   /* make dictCtx index comparable with current context */
 1156|      0|                        lowLimit = dictionary;
 1157|      0|                    } else {
 1158|      0|                        match = base + matchIndex;
 1159|      0|                        lowLimit = (const BYTE*)source;
 1160|      0|                    }
 1161|  23.4M|                } else if (dictDirective == usingExtDict) {
  ------------------
  |  Branch (1161:28): [True: 7.42M, False: 15.9M]
  ------------------
 1162|       |                    /* select without branch : dictionary and prefix candidates alternate unpredictably.
 1163|       |                     * relative to dictEnd or source, within their buffers (base can be NULL) */
 1164|  7.42M|                    ptrdiff_t const relIdx = (ptrdiff_t)matchIndex - (ptrdiff_t)startIndex;   /* < 0 : within dictionary */
 1165|  7.42M|                    match = ((relIdx < 0) ? dictEnd : (const BYTE*)source) + relIdx;
  ------------------
  |  Branch (1165:30): [True: 2.54M, False: 4.88M]
  ------------------
 1166|  15.9M|                } else {   /* single continuous memory segment */
 1167|  15.9M|                    match = base + matchIndex;
 1168|  15.9M|                }
 1169|  23.4M|                forwardH = LZ4_hashPosition(forwardIp, tableType);
 1170|  23.4M|                LZ4_putIndexOnHash(current, h, cctx->hashTable, tableType);
 1171|       |
 1172|  23.4M|                DEBUGLOG(7, "candidate at pos=%u  (offset=%u \n", matchIndex, current - matchIndex);
  ------------------
  |  |  289|  23.4M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1173|  23.4M|                if ((dictIssue == dictSmall) && (matchIndex < prefixIdxLimit)) { continue; }    /* match outside of valid area */
  ------------------
  |  Branch (1173:21): [True: 16.5k, False: 23.3M]
  |  Branch (1173:49): [True: 13.4k, False: 3.02k]
  ------------------
 1174|  23.4M|                assert(matchIndex < current);
  ------------------
  |  Branch (1174:17): [True: 0, False: 23.4M]
  |  Branch (1174:17): [True: 23.4M, False: 0]
  ------------------
 1175|       |                /* noDict : the candidate is within input, so it is compared before checking its distance :
 1176|       |                 * this order is faster (better branch prediction) */
 1177|  23.4M|                assert((dictDirective != noDict) || (match >= (const BYTE*)source));
  ------------------
  |  Branch (1177:17): [True: 23.4M, False: 0]
  |  Branch (1177:17): [True: 0, False: 0]
  |  Branch (1177:17): [True: 16.3M, False: 7.06M]
  |  Branch (1177:17): [True: 7.06M, False: 0]
  ------------------
 1178|  23.4M|                if ( (dictDirective != noDict)
  ------------------
  |  Branch (1178:22): [True: 16.3M, False: 7.06M]
  ------------------
 1179|  16.3M|                  && ((tableType != byU16) || (LZ4_DISTANCE_MAX < LZ4_DISTANCE_ABSOLUTE_MAX))
  ------------------
  |  |  691|      0|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
                                && ((tableType != byU16) || (LZ4_DISTANCE_MAX < LZ4_DISTANCE_ABSOLUTE_MAX))
  ------------------
  |  |  255|      0|#define LZ4_DISTANCE_ABSOLUTE_MAX 65535
  ------------------
  |  Branch (1179:23): [True: 16.3M, False: 0]
  |  Branch (1179:47): [Folded, False: 0]
  ------------------
 1180|  16.3M|                  && (matchIndex+LZ4_DISTANCE_MAX < current)) {
  ------------------
  |  |  691|  16.3M|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (1180:22): [True: 2.10M, False: 14.2M]
  ------------------
 1181|  2.10M|                    continue;
 1182|  2.10M|                } /* too far */
 1183|       |
 1184|  21.2M|                if (LZ4_read32(match) == LZ4_read32(ip)) {
  ------------------
  |  Branch (1184:21): [True: 3.95M, False: 17.3M]
  ------------------
 1185|  3.95M|                    if ( (dictDirective == noDict)
  ------------------
  |  Branch (1185:26): [True: 1.06M, False: 2.89M]
  ------------------
 1186|  1.06M|                      && ((tableType != byU16) || (LZ4_DISTANCE_MAX < LZ4_DISTANCE_ABSOLUTE_MAX))
  ------------------
  |  |  691|   385k|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
                                    && ((tableType != byU16) || (LZ4_DISTANCE_MAX < LZ4_DISTANCE_ABSOLUTE_MAX))
  ------------------
  |  |  255|   385k|#define LZ4_DISTANCE_ABSOLUTE_MAX 65535
  ------------------
  |  Branch (1186:27): [True: 679k, False: 385k]
  |  Branch (1186:51): [Folded, False: 0]
  ------------------
 1187|   679k|                      && (matchIndex+LZ4_DISTANCE_MAX < current)) {
  ------------------
  |  |  691|   679k|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (1187:26): [True: 29.1k, False: 650k]
  ------------------
 1188|  29.1k|                        continue;
 1189|  29.1k|                    } /* too far */
 1190|  3.95M|                    assert((current - matchIndex) <= LZ4_DISTANCE_MAX);  /* match now expected within distance */
  ------------------
  |  Branch (1190:21): [True: 0, False: 3.92M]
  |  Branch (1190:21): [True: 3.92M, False: 0]
  ------------------
 1191|  3.92M|                    if (maybe_extMem) offset = current - matchIndex;
  ------------------
  |  Branch (1191:25): [True: 1.29M, False: 2.63M]
  ------------------
 1192|  3.92M|                    if (dictDirective == usingExtDict)   /* lowLimit : only needed once a match is found */
  ------------------
  |  Branch (1192:25): [True: 1.29M, False: 2.63M]
  ------------------
 1193|  1.29M|                        lowLimit = (matchIndex < startIndex) ? dictionary : (const BYTE*)source;
  ------------------
  |  Branch (1193:36): [True: 136k, False: 1.16M]
  ------------------
 1194|  3.92M|                    break;   /* match found */
 1195|  3.92M|                }
 1196|       |
 1197|  21.2M|            } while(1);
  ------------------
  |  Branch (1197:21): [True: 19.4M, Folded]
  ------------------
 1198|  3.93M|        }
 1199|       |
 1200|       |        /* Catch up */
 1201|  3.92M|        filledIp = ip;
 1202|  3.92M|        assert(ip > anchor); /* this is always true as ip has been advanced before entering the main loop */
  ------------------
  |  Branch (1202:9): [True: 0, False: 3.92M]
  |  Branch (1202:9): [True: 3.92M, False: 0]
  ------------------
 1203|  3.92M|        if ((match > lowLimit) && unlikely(ip[-1] == match[-1])) {
  ------------------
  |  |  180|  3.92M|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|  3.92M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 954k, False: 2.96M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1203:13): [True: 3.92M, False: 6.05k]
  ------------------
 1204|  1.59M|            do { ip--; match--; } while (((ip > anchor) & (match > lowLimit)) && (unlikely(ip[-1] == match[-1])));
  ------------------
  |  |  180|  1.36M|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|  1.36M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  ------------------
  ------------------
  |  Branch (1204:42): [True: 1.36M, False: 227k]
  |  Branch (1204:82): [True: 640k, False: 727k]
  ------------------
 1205|   954k|        }
 1206|       |
 1207|       |        /* Encode Literals */
 1208|  3.92M|        {   unsigned const litLength = (unsigned)(ip - anchor);
 1209|  3.92M|            token = op++;
 1210|  3.92M|            if ((outputDirective == limitedOutput) &&  /* Check output buffer overflow */
  ------------------
  |  Branch (1210:17): [True: 3.92M, False: 0]
  ------------------
 1211|  3.92M|                (unlikely(op + litLength + (2 + 1 + LASTLITERALS) + (litLength/255) > olimit)) ) {
  ------------------
  |  |  180|  3.92M|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|  3.92M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  ------------------
  ------------------
  |  Branch (1211:17): [True: 64, False: 3.92M]
  ------------------
 1212|     64|                return 0;   /* cannot compress within `dst` budget. Stored indexes in hash table are nonetheless fine */
 1213|     64|            }
 1214|  3.92M|            if ((outputDirective == fillOutput) &&
  ------------------
  |  Branch (1214:17): [True: 0, False: 3.92M]
  ------------------
 1215|      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))) {
  ------------------
  |  |  180|      0|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|      0|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  ------------------
  ------------------
  |  Branch (1215:17): [True: 0, False: 0]
  ------------------
 1216|      0|                op--;
 1217|      0|                goto _last_literals;
 1218|      0|            }
 1219|  3.92M|            if (litLength >= RUN_MASK) {
  ------------------
  |  |  263|  3.92M|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|  3.92M|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|  3.92M|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1219:17): [True: 451k, False: 3.47M]
  ------------------
 1220|   451k|                unsigned len = litLength - RUN_MASK;
  ------------------
  |  |  263|   451k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|   451k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|   451k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1221|   451k|                *token = (RUN_MASK<<ML_BITS);
  ------------------
  |  |  263|   451k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|   451k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|   451k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                              *token = (RUN_MASK<<ML_BITS);
  ------------------
  |  |  260|   451k|#define ML_BITS  4
  ------------------
 1222|   619k|                for(; len >= 255 ; len-=255) *op++ = 255;
  ------------------
  |  Branch (1222:23): [True: 167k, False: 451k]
  ------------------
 1223|   451k|                *op++ = (BYTE)len;
 1224|   451k|            }
 1225|  3.47M|            else *token = (BYTE)(litLength<<ML_BITS);
  ------------------
  |  |  260|  3.47M|#define ML_BITS  4
  ------------------
 1226|       |
 1227|       |            /* Copy Literals */
 1228|  3.92M|            LZ4_wildCopy8(op, anchor, op+litLength);
 1229|  3.92M|            op+=litLength;
 1230|  3.92M|            DEBUGLOG(6, "seq.start:%i, literals=%u, match.start:%i",
  ------------------
  |  |  289|  3.92M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1231|  3.92M|                        (int)(anchor-(const BYTE*)source), litLength, (int)(ip-(const BYTE*)source));
 1232|  3.92M|        }
 1233|       |
 1234|  8.86M|_next_match:
 1235|       |        /* at this stage, the following variables must be correctly set :
 1236|       |         * - ip : at start of LZ operation
 1237|       |         * - match : at start of previous pattern occurrence; can be within current prefix, or within extDict
 1238|       |         * - offset : if maybe_ext_memSegment==1 (constant)
 1239|       |         * - lowLimit : must be == dictionary to mean "match is within extDict"; must be == source otherwise
 1240|       |         * - token and *token : position to write 4-bits for match length; higher 4-bits for literal length supposed already written
 1241|       |         */
 1242|       |
 1243|  8.86M|        if ((outputDirective == fillOutput) &&
  ------------------
  |  Branch (1243:13): [True: 0, False: 8.86M]
  ------------------
 1244|      0|            (op + 2 /* offset */ + 1 /* token */ + MFLIMIT - MINMATCH /* min last literals so last match is <= end - MFLIMIT */ > olimit)) {
  ------------------
  |  |  246|      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)) {
  ------------------
  |  |  242|      0|#define MINMATCH 4
  ------------------
  |  Branch (1244:13): [True: 0, False: 0]
  ------------------
 1245|       |            /* the match was too close to the end, rewind and go to last literals */
 1246|      0|            op = token;
 1247|      0|            goto _last_literals;
 1248|      0|        }
 1249|       |
 1250|       |        /* Encode Offset */
 1251|  8.86M|        if (maybe_extMem) {   /* static test */
  ------------------
  |  Branch (1251:13): [True: 2.82M, False: 6.03M]
  ------------------
 1252|  2.82M|            DEBUGLOG(6, "             with offset=%u  (ext if > %i)", offset, (int)(ip - (const BYTE*)source));
  ------------------
  |  |  289|  2.82M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1253|  2.82M|            assert(offset <= LZ4_DISTANCE_MAX && offset > 0);
  ------------------
  |  Branch (1253:13): [True: 0, False: 2.82M]
  |  Branch (1253:13): [True: 0, False: 0]
  |  Branch (1253:13): [True: 2.82M, False: 0]
  |  Branch (1253:13): [True: 2.82M, False: 0]
  ------------------
 1254|  2.82M|            LZ4_writeLE16(op, (U16)offset); op+=2;
 1255|  6.03M|        } else  {
 1256|  6.03M|            DEBUGLOG(6, "             with offset=%u  (same segment)", (U32)(ip - match));
  ------------------
  |  |  289|  6.03M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1257|  6.03M|            assert(ip-match <= LZ4_DISTANCE_MAX);
  ------------------
  |  Branch (1257:13): [True: 0, False: 6.03M]
  |  Branch (1257:13): [True: 6.03M, False: 0]
  ------------------
 1258|  6.03M|            LZ4_writeLE16(op, (U16)(ip - match)); op+=2;
 1259|  6.03M|        }
 1260|       |
 1261|       |        /* Encode MatchLength */
 1262|  8.86M|        {   unsigned matchCode;
 1263|       |
 1264|  8.86M|            if ( (dictDirective==usingExtDict || dictDirective==usingDictCtx)
  ------------------
  |  Branch (1264:19): [True: 2.82M, False: 6.03M]
  |  Branch (1264:50): [True: 0, False: 6.03M]
  ------------------
 1265|  2.82M|              && (lowLimit==dictionary) /* match within extDict */ ) {
  ------------------
  |  Branch (1265:18): [True: 239k, False: 2.58M]
  ------------------
 1266|   239k|                const BYTE* limit = ip + (dictEnd-match);
 1267|   239k|                assert(dictEnd > match);
  ------------------
  |  Branch (1267:17): [True: 0, False: 239k]
  |  Branch (1267:17): [True: 239k, False: 0]
  ------------------
 1268|   239k|                if (limit > matchlimit) limit = matchlimit;
  ------------------
  |  Branch (1268:21): [True: 233, False: 239k]
  ------------------
 1269|   239k|                matchCode = LZ4_count(ip+MINMATCH, match+MINMATCH, limit);
  ------------------
  |  |  242|   239k|#define MINMATCH 4
  ------------------
                              matchCode = LZ4_count(ip+MINMATCH, match+MINMATCH, limit);
  ------------------
  |  |  242|   239k|#define MINMATCH 4
  ------------------
 1270|   239k|                ip += (size_t)matchCode + MINMATCH;
  ------------------
  |  |  242|   239k|#define MINMATCH 4
  ------------------
 1271|   239k|                if (ip==limit) {
  ------------------
  |  Branch (1271:21): [True: 1.28k, False: 238k]
  ------------------
 1272|  1.28k|                    unsigned const more = LZ4_count(limit, (const BYTE*)source, matchlimit);
 1273|  1.28k|                    matchCode += more;
 1274|  1.28k|                    ip += more;
 1275|  1.28k|                }
 1276|   239k|                DEBUGLOG(6, "             with matchLength=%u starting in extDict", matchCode+MINMATCH);
  ------------------
  |  |  289|   239k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1277|  8.62M|            } else {
 1278|  8.62M|                matchCode = LZ4_count(ip+MINMATCH, match+MINMATCH, matchlimit);
  ------------------
  |  |  242|  8.62M|#define MINMATCH 4
  ------------------
                              matchCode = LZ4_count(ip+MINMATCH, match+MINMATCH, matchlimit);
  ------------------
  |  |  242|  8.62M|#define MINMATCH 4
  ------------------
 1279|  8.62M|                ip += (size_t)matchCode + MINMATCH;
  ------------------
  |  |  242|  8.62M|#define MINMATCH 4
  ------------------
 1280|  8.62M|                DEBUGLOG(6, "             with matchLength=%u", matchCode+MINMATCH);
  ------------------
  |  |  289|  8.62M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1281|  8.62M|            }
 1282|       |
 1283|  8.86M|            if ((outputDirective) &&    /* Check output buffer overflow */
  ------------------
  |  Branch (1283:17): [True: 8.86M, False: 0]
  ------------------
 1284|  8.86M|                (unlikely(op + (1 + LASTLITERALS) + (matchCode+240)/255 > olimit)) ) {
  ------------------
  |  |  180|  8.86M|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|  8.86M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  ------------------
  ------------------
  |  Branch (1284:17): [True: 11, False: 8.86M]
  ------------------
 1285|     11|                if (outputDirective == fillOutput) {
  ------------------
  |  Branch (1285:21): [True: 0, False: 11]
  ------------------
 1286|       |                    /* Match description too long : reduce it */
 1287|      0|                    U32 newMatchCode = 15 /* in token */ - 1 /* to avoid needing a zero byte */ + ((U32)(olimit - op) - 1 - LASTLITERALS) * 255;
  ------------------
  |  |  245|      0|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
 1288|      0|                    ip -= matchCode - newMatchCode;
 1289|      0|                    assert(newMatchCode < matchCode);
  ------------------
  |  Branch (1289:21): [True: 0, False: 0]
  |  Branch (1289:21): [True: 0, False: 0]
  ------------------
 1290|      0|                    matchCode = newMatchCode;
 1291|      0|                    if (unlikely(ip <= filledIp)) {
  ------------------
  |  |  180|      0|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|      0|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1292|       |                        /* We have already filled up to filledIp so if ip ends up less than filledIp
 1293|       |                         * we have positions in the hash table beyond the current position. This is
 1294|       |                         * a problem if we reuse the hash table. So we have to remove these positions
 1295|       |                         * from the hash table.
 1296|       |                         */
 1297|      0|                        const BYTE* ptr;
 1298|      0|                        DEBUGLOG(5, "Clearing %u positions", (U32)(filledIp - ip));
  ------------------
  |  |  289|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1299|      0|                        for (ptr = ip; ptr <= filledIp; ++ptr) {
  ------------------
  |  Branch (1299:40): [True: 0, False: 0]
  ------------------
 1300|      0|                            U32 const h = LZ4_hashPosition(ptr, tableType);
 1301|      0|                            LZ4_clearHash(h, cctx->hashTable, tableType);
 1302|      0|                        }
 1303|      0|                    }
 1304|     11|                } else {
 1305|     11|                    assert(outputDirective == limitedOutput);
  ------------------
  |  Branch (1305:21): [True: 0, False: 11]
  |  Branch (1305:21): [True: 11, False: 0]
  ------------------
 1306|     11|                    return 0;   /* cannot compress within `dst` budget. Stored indexes in hash table are nonetheless fine */
 1307|     11|                }
 1308|     11|            }
 1309|  8.86M|            if (matchCode >= ML_MASK) {
  ------------------
  |  |  261|  8.86M|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|  8.86M|#define ML_BITS  4
  |  |  ------------------
  ------------------
  |  Branch (1309:17): [True: 1.37M, False: 7.49M]
  ------------------
 1310|  1.37M|                *token += ML_MASK;
  ------------------
  |  |  261|  1.37M|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|  1.37M|#define ML_BITS  4
  |  |  ------------------
  ------------------
 1311|  1.37M|                matchCode -= ML_MASK;
  ------------------
  |  |  261|  1.37M|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|  1.37M|#define ML_BITS  4
  |  |  ------------------
  ------------------
 1312|  1.37M|                LZ4_write32(op, 0xFFFFFFFF);
 1313|  1.52M|                while (matchCode >= 4*255) {
  ------------------
  |  Branch (1313:24): [True: 154k, False: 1.37M]
  ------------------
 1314|   154k|                    op+=4;
 1315|   154k|                    LZ4_write32(op, 0xFFFFFFFF);
 1316|   154k|                    matchCode -= 4*255;
 1317|   154k|                }
 1318|  1.37M|                op += matchCode / 255;
 1319|  1.37M|                *op++ = (BYTE)(matchCode % 255);
 1320|  1.37M|            } else
 1321|  7.49M|                *token += (BYTE)(matchCode);
 1322|  8.86M|        }
 1323|       |        /* Ensure we have enough space for the last literals. */
 1324|  8.86M|        assert(!(outputDirective == fillOutput && op + 1 + LASTLITERALS > olimit));
  ------------------
  |  Branch (1324:9): [True: 0, False: 8.86M]
  |  Branch (1324:9): [True: 0, False: 0]
  |  Branch (1324:9): [True: 0, False: 8.86M]
  |  Branch (1324:9): [True: 0, False: 0]
  ------------------
 1325|       |
 1326|  8.86M|        anchor = ip;
 1327|       |
 1328|       |        /* Test end of chunk */
 1329|  8.86M|        if (ip >= seqLimit) {
  ------------------
  |  Branch (1329:13): [True: 7.00k, False: 8.85M]
  ------------------
 1330|  7.00k|            if ((suspend == NULL) || (ip >= mflimitPlusOne)) break;
  ------------------
  |  Branch (1330:17): [True: 5.10k, False: 1.90k]
  |  Branch (1330:38): [True: 1.31k, False: 590]
  ------------------
 1331|       |            /* extDict : from ip, all candidates (and catch up) are beyond reach of the dictionary :
 1332|       |             * stop, to resume in prefix mode, which is faster */
 1333|    590|            suspend->ip = ip;
 1334|    590|            suspend->op = op;
 1335|    590|            suspend->startIndex = startIndex;
 1336|    590|            return 0;
 1337|  7.00k|        }
 1338|       |
 1339|  8.85M|_resume:
 1340|       |        /* Fill table, and test next position.
 1341|       |         * First, the position after the previous occurrence of ip-1, if it matches 8+ bytes :
 1342|       |         * it breaks chains of short matches, which the table alone can produce on periodic data. */
 1343|  8.85M|        if (tableType == byPtr) {
  ------------------
  |  Branch (1343:13): [True: 0, False: 8.85M]
  ------------------
 1344|       |
 1345|      0|            U32 const hPrev = LZ4_hashPosition(ip-1, tableType);
 1346|      0|            const BYTE* const prev = LZ4_getPositionOnHash(hPrev, cctx->hashTable, tableType);
 1347|      0|            U32 const h = LZ4_hashPosition(ip, tableType);
 1348|      0|            LZ4_putPositionOnHash(ip-1, hPrev, cctx->hashTable, tableType);
 1349|      0|            match = LZ4_getPositionOnHash(h, cctx->hashTable, tableType);
 1350|      0|            if ((prev+1+LZ4_DISTANCE_MAX >= ip) && LZ4_match8(prev+1, ip)) match = prev+1;
  ------------------
  |  |  691|      0|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (1350:17): [True: 0, False: 0]
  |  Branch (1350:52): [True: 0, False: 0]
  ------------------
 1351|      0|            LZ4_putPositionOnHash(ip, h, cctx->hashTable, tableType);
 1352|      0|            if ( (match+LZ4_DISTANCE_MAX >= ip)
  ------------------
  |  |  691|      0|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (1352:18): [True: 0, False: 0]
  ------------------
 1353|      0|              && (LZ4_read32(match) == LZ4_read32(ip)) )
  ------------------
  |  Branch (1353:18): [True: 0, False: 0]
  ------------------
 1354|      0|            { token=op++; *token=0; goto _next_match; }
 1355|       |
 1356|  8.85M|        } else {   /* byU32, byU16 */
 1357|       |
 1358|  8.85M|            U32 const h = LZ4_hashPosition(ip, tableType);
 1359|  8.85M|            U32 const current = (U32)(ip-base);
 1360|  8.85M|            U32 const hPrev = LZ4_hashPosition(ip-1, tableType);
 1361|  8.85M|            U32 prevIndex = LZ4_getIndexOnHash(hPrev, cctx->hashTable, tableType);
 1362|  8.85M|            U32 matchIndex;
 1363|  8.85M|            LZ4_putIndexOnHash(current-1, hPrev, cctx->hashTable, tableType);
 1364|  8.85M|            if ((dictDirective == usingDictCtx) && (prevIndex < startIndex)) {
  ------------------
  |  Branch (1364:17): [True: 0, False: 8.85M]
  |  Branch (1364:52): [True: 0, False: 0]
  ------------------
 1365|       |                /* no occurrence in the current context : try the dictionary */
 1366|      0|                prevIndex = LZ4_getIndexOnHash(hPrev, dictCtx->hashTable, byU32) + dictDelta;
 1367|      0|            }
 1368|  8.85M|            {   /* used table (small block, see LZ4_prepareTable()) : a stale entry yields the candidate of an empty slot
 1369|       |                 * of a cleared table (0), the position after the first one : the output doesn't depend on the table's history */
 1370|  8.85M|                int const usedTable = (dictDirective == noDict) && (dictIssue == dictSmall);
  ------------------
  |  Branch (1370:39): [True: 2.45M, False: 6.40M]
  |  Branch (1370:68): [True: 4.05k, False: 2.44M]
  ------------------
 1371|  8.85M|                U32 const ctxIndex = ((usedTable && (prevIndex < startIndex)) ? startIndex : prevIndex) + 1;
  ------------------
  |  Branch (1371:40): [True: 4.05k, False: 8.85M]
  |  Branch (1371:53): [True: 2.14k, False: 1.90k]
  ------------------
 1372|  8.85M|                int const inDict = (dictDirective == usingExtDict || dictDirective == usingDictCtx) && (ctxIndex < startIndex);
  ------------------
  |  Branch (1372:37): [True: 2.81M, False: 6.03M]
  |  Branch (1372:70): [True: 0, False: 6.03M]
  |  Branch (1372:104): [True: 617k, False: 2.20M]
  ------------------
 1373|  8.85M|                if ( ((dictIssue==dictSmall) ? (ctxIndex >= prefixIdxLimit) : 1)
  ------------------
  |  Branch (1373:22): [True: 8.85M, False: 0]
  |  Branch (1373:23): [True: 4.05k, False: 8.85M]
  ------------------
 1374|  8.85M|                  && (((tableType==byU16) && (LZ4_DISTANCE_MAX == LZ4_DISTANCE_ABSOLUTE_MAX)) ? 1 : (ctxIndex+LZ4_DISTANCE_MAX >= current))
  ------------------
  |  |  691|  1.29M|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
                                && (((tableType==byU16) && (LZ4_DISTANCE_MAX == LZ4_DISTANCE_ABSOLUTE_MAX)) ? 1 : (ctxIndex+LZ4_DISTANCE_MAX >= current))
  ------------------
  |  |  255|  1.29M|#define LZ4_DISTANCE_ABSOLUTE_MAX 65535
  ------------------
                                && (((tableType==byU16) && (LZ4_DISTANCE_MAX == LZ4_DISTANCE_ABSOLUTE_MAX)) ? 1 : (ctxIndex+LZ4_DISTANCE_MAX >= current))
  ------------------
  |  |  691|  7.55M|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (1374:22): [True: 8.29M, False: 561k]
  |  Branch (1374:24): [True: 1.29M, False: 7.55M]
  |  Branch (1374:46): [True: 0, Folded]
  ------------------
 1375|  8.29M|                  && (!inDict || (ctxIndex + 8 <= startIndex))   /* the 8 compared bytes are within the dictionary */
  ------------------
  |  Branch (1375:23): [True: 7.98M, False: 303k]
  |  Branch (1375:34): [True: 303k, False: 0]
  ------------------
 1376|  8.29M|                  && LZ4_match8(inDict ? dictBase + (ctxIndex - dictDelta) : base + ctxIndex, ip) ) {
  ------------------
  |  Branch (1376:22): [True: 1.24M, False: 7.04M]
  |  Branch (1376:33): [True: 303k, False: 7.98M]
  ------------------
 1377|  1.24M|                    matchIndex = ctxIndex;
 1378|  7.60M|                } else {
 1379|  7.60M|                    matchIndex = LZ4_getIndexOnHash(h, cctx->hashTable, tableType);
 1380|  7.60M|                    if ((dictDirective == usingDictCtx) && (matchIndex < startIndex))
  ------------------
  |  Branch (1380:25): [True: 0, False: 7.60M]
  |  Branch (1380:60): [True: 0, False: 0]
  ------------------
 1381|      0|                        matchIndex = LZ4_getIndexOnHash(h, dictCtx->hashTable, byU32) + dictDelta;
 1382|  7.60M|                }
 1383|  8.85M|            }
 1384|  8.85M|            assert(matchIndex < current);
  ------------------
  |  Branch (1384:13): [True: 0, False: 8.85M]
  |  Branch (1384:13): [True: 8.85M, False: 0]
  ------------------
 1385|  8.85M|            if (dictDirective == usingExtDict) {   /* select without branch */
  ------------------
  |  Branch (1385:17): [True: 2.81M, False: 6.03M]
  ------------------
 1386|  2.81M|                ptrdiff_t const relIdx = (ptrdiff_t)matchIndex - (ptrdiff_t)startIndex;   /* < 0 : within dictionary */
 1387|  2.81M|                match = ((relIdx < 0) ? dictEnd : (const BYTE*)source) + relIdx;
  ------------------
  |  Branch (1387:26): [True: 606k, False: 2.21M]
  ------------------
 1388|  6.03M|            } else if ((dictDirective == usingDictCtx) && (matchIndex < startIndex)) {
  ------------------
  |  Branch (1388:24): [True: 0, False: 6.03M]
  |  Branch (1388:59): [True: 0, False: 0]
  ------------------
 1389|      0|                match = dictBase + (matchIndex - dictDelta);
 1390|      0|                lowLimit = dictionary;   /* required for match length counter */
 1391|  6.03M|            } else {
 1392|  6.03M|                match = base + matchIndex;
 1393|  6.03M|                if (dictDirective == usingDictCtx)
  ------------------
  |  Branch (1393:21): [True: 0, False: 6.03M]
  ------------------
 1394|      0|                    lowLimit = (const BYTE*)source;   /* required for match length counter */
 1395|  6.03M|            }
 1396|  8.85M|            LZ4_putIndexOnHash(current, h, cctx->hashTable, tableType);
 1397|  8.85M|            assert(matchIndex < current);
  ------------------
  |  Branch (1397:13): [True: 0, False: 8.85M]
  |  Branch (1397:13): [True: 8.85M, False: 0]
  ------------------
 1398|  8.85M|            if ( ((dictIssue==dictSmall) ? (matchIndex >= prefixIdxLimit) : 1)
  ------------------
  |  Branch (1398:18): [True: 8.85M, False: 1.96k]
  |  Branch (1398:19): [True: 4.05k, False: 8.85M]
  ------------------
 1399|  8.85M|              && (((tableType==byU16) && (LZ4_DISTANCE_MAX == LZ4_DISTANCE_ABSOLUTE_MAX)) ? 1 : (matchIndex+LZ4_DISTANCE_MAX >= current))
  ------------------
  |  |  691|  1.29M|#  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))
  ------------------
  |  |  255|  1.29M|#define LZ4_DISTANCE_ABSOLUTE_MAX 65535
  ------------------
                            && (((tableType==byU16) && (LZ4_DISTANCE_MAX == LZ4_DISTANCE_ABSOLUTE_MAX)) ? 1 : (matchIndex+LZ4_DISTANCE_MAX >= current))
  ------------------
  |  |  691|  7.55M|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (1399:18): [True: 8.34M, False: 508k]
  |  Branch (1399:20): [True: 1.29M, False: 7.55M]
  |  Branch (1399:42): [True: 0, Folded]
  ------------------
 1400|  8.34M|              && (LZ4_read32(match) == LZ4_read32(ip)) ) {
  ------------------
  |  Branch (1400:18): [True: 4.93M, False: 3.41M]
  ------------------
 1401|  4.93M|                token=op++;
 1402|  4.93M|                *token=0;
 1403|  4.93M|                if (maybe_extMem) offset = current - matchIndex;
  ------------------
  |  Branch (1403:21): [True: 1.52M, False: 3.40M]
  ------------------
 1404|  4.93M|                if (dictDirective == usingExtDict)
  ------------------
  |  Branch (1404:21): [True: 1.52M, False: 3.40M]
  ------------------
 1405|  1.52M|                    lowLimit = (matchIndex < startIndex) ? dictionary : (const BYTE*)source;   /* required for match length counter */
  ------------------
  |  Branch (1405:32): [True: 103k, False: 1.42M]
  ------------------
 1406|  4.93M|                DEBUGLOG(6, "seq.start:%i, literals=%u, match.start:%i",
  ------------------
  |  |  289|  4.93M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1407|  4.93M|                            (int)(anchor-(const BYTE*)source), 0, (int)(ip-(const BYTE*)source));
 1408|  4.93M|                goto _next_match;
 1409|  4.93M|            }
 1410|  8.85M|        }
 1411|       |
 1412|       |        /* Prepare next loop */
 1413|  3.92M|        forwardH = LZ4_hashPosition(++ip, tableType);
 1414|       |
 1415|  3.92M|    }
 1416|       |
 1417|  11.2k|_last_literals:
 1418|       |    /* Encode Last Literals */
 1419|  11.2k|    {   size_t lastRun = (size_t)(iend - anchor);
 1420|  11.2k|        if ( (outputDirective) &&  /* Check output buffer overflow */
  ------------------
  |  Branch (1420:14): [True: 11.2k, False: 0]
  ------------------
 1421|  11.2k|            (op + lastRun + 1 + ((lastRun+255-RUN_MASK)/255) > olimit)) {
  ------------------
  |  |  263|  11.2k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|  11.2k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|  11.2k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1421:13): [True: 2.72k, False: 8.55k]
  ------------------
 1422|  2.72k|            if (outputDirective == fillOutput) {
  ------------------
  |  Branch (1422:17): [True: 0, False: 2.72k]
  ------------------
 1423|       |                /* adapt lastRun to fill 'dst' */
 1424|      0|                assert(olimit >= op);
  ------------------
  |  Branch (1424:17): [True: 0, False: 0]
  |  Branch (1424:17): [True: 0, False: 0]
  ------------------
 1425|      0|                lastRun  = (size_t)(olimit-op) - 1/*token*/;
 1426|      0|                lastRun -= (lastRun + 256 - RUN_MASK) / 256;  /*additional length tokens*/
  ------------------
  |  |  263|      0|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|      0|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|      0|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1427|  2.72k|            } else {
 1428|  2.72k|                assert(outputDirective == limitedOutput);
  ------------------
  |  Branch (1428:17): [True: 0, False: 2.72k]
  |  Branch (1428:17): [True: 2.72k, False: 0]
  ------------------
 1429|  2.72k|                return 0;   /* cannot compress within `dst` budget. Stored indexes in hash table are nonetheless fine */
 1430|  2.72k|            }
 1431|  2.72k|        }
 1432|  8.55k|        DEBUGLOG(6, "Final literal run : %i literals", (int)lastRun);
  ------------------
  |  |  289|  8.55k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1433|  8.55k|        if (lastRun >= RUN_MASK) {
  ------------------
  |  |  263|  8.55k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|  8.55k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|  8.55k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1433:13): [True: 1.70k, False: 6.85k]
  ------------------
 1434|  1.70k|            size_t accumulator = lastRun - RUN_MASK;
  ------------------
  |  |  263|  1.70k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|  1.70k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|  1.70k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1435|  1.70k|            *op++ = RUN_MASK << ML_BITS;
  ------------------
  |  |  263|  1.70k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|  1.70k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|  1.70k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                          *op++ = RUN_MASK << ML_BITS;
  ------------------
  |  |  260|  1.70k|#define ML_BITS  4
  ------------------
 1436|  40.2k|            for(; accumulator >= 255 ; accumulator-=255) *op++ = 255;
  ------------------
  |  Branch (1436:19): [True: 38.5k, False: 1.70k]
  ------------------
 1437|  1.70k|            *op++ = (BYTE) accumulator;
 1438|  6.85k|        } else {
 1439|  6.85k|            *op++ = (BYTE)(lastRun<<ML_BITS);
  ------------------
  |  |  260|  6.85k|#define ML_BITS  4
  ------------------
 1440|  6.85k|        }
 1441|  8.55k|        LZ4_memcpy(op, anchor, lastRun);
  ------------------
  |  |  349|  8.55k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 1442|  8.55k|        ip = anchor + lastRun;
 1443|  8.55k|        op += lastRun;
 1444|  8.55k|    }
 1445|       |
 1446|  8.55k|    if (outputDirective == fillOutput) {
  ------------------
  |  Branch (1446:9): [True: 0, False: 8.55k]
  ------------------
 1447|      0|        *inputConsumed = (int) (((const char*)ip)-source);
 1448|      0|    }
 1449|  8.55k|    result = (int)(((char*)op) - dest);
 1450|  8.55k|    assert(result > 0);
  ------------------
  |  Branch (1450:5): [True: 0, False: 8.55k]
  |  Branch (1450:5): [True: 8.55k, False: 0]
  ------------------
 1451|  8.55k|    DEBUGLOG(5, "LZ4_compress_generic: compressed %i bytes into %i bytes", inputSize, result);
  ------------------
  |  |  289|  8.55k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1452|  8.55k|    return result;
 1453|  8.55k|}
lz4.c:LZ4_putPosition:
  910|  10.4k|{
  911|  10.4k|    U32 const h = LZ4_hashPosition(p, tableType);
  912|  10.4k|    if (tableType == byPtr) {
  ------------------
  |  Branch (912:9): [True: 0, False: 10.4k]
  ------------------
  913|      0|        LZ4_putPositionOnHash(p, h, tableBase, byPtr);
  914|  10.4k|    } else {
  915|  10.4k|        LZ4_putIndexOnHash((U32)(p - base), h, tableBase, tableType);
  916|  10.4k|    }
  917|  10.4k|}
lz4.c:LZ4_wildCopy8:
  466|  4.11M|{
  467|  4.11M|    BYTE* d = (BYTE*)dstPtr;
  468|  4.11M|    const BYTE* s = (const BYTE*)srcPtr;
  469|  4.11M|    BYTE* const e = (BYTE*)dstEnd;
  470|       |
  471|  17.2M|    do { LZ4_memcpy(d,s,8); d+=8; s+=8; } while (d<e);
  ------------------
  |  |  349|  17.2M|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  |  Branch (471:50): [True: 13.1M, False: 4.11M]
  ------------------
  472|  4.11M|}
lz4.c:LZ4_writeLE16:
  453|  8.86M|{
  454|  8.86M|    if (LZ4_isLittleEndian()) {
  ------------------
  |  Branch (454:9): [True: 8.86M, False: 0]
  ------------------
  455|  8.86M|        LZ4_write16(memPtr, value);
  456|  8.86M|    } else {
  457|      0|        BYTE* p = (BYTE*)memPtr;
  458|      0|        p[0] = (BYTE) value;
  459|      0|        p[1] = (BYTE)(value>>8);
  460|      0|    }
  461|  8.86M|}
lz4.c:LZ4_write16:
  397|  8.86M|static void LZ4_write16(void* memPtr, U16 value) { ((LZ4_unalign16*)memPtr)->u16 = value; }
lz4.c:LZ4_count:
  721|  8.86M|{
  722|  8.86M|    const BYTE* const pStart = pIn;
  723|       |
  724|  8.86M|    if (likely(pIn < pInLimit-(STEPSIZE-1))) {
  ------------------
  |  |  177|  8.86M|#define likely(expr)     expect((expr) != 0, 1)
  |  |  ------------------
  |  |  |  |  171|  8.86M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 8.85M, False: 2.17k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  725|  8.85M|        reg_t const diff = LZ4_read_ARCH(pMatch) ^ LZ4_read_ARCH(pIn);
  726|  8.85M|        if (!diff) {
  ------------------
  |  Branch (726:13): [True: 1.98M, False: 6.87M]
  ------------------
  727|  1.98M|            pIn+=STEPSIZE; pMatch+=STEPSIZE;
  ------------------
  |  |  718|  1.98M|#define STEPSIZE sizeof(reg_t)
  ------------------
                          pIn+=STEPSIZE; pMatch+=STEPSIZE;
  ------------------
  |  |  718|  1.98M|#define STEPSIZE sizeof(reg_t)
  ------------------
  728|  6.87M|        } else {
  729|  6.87M|            return LZ4_NbCommonBytes(diff);
  730|  6.87M|    }   }
  731|       |
  732|  36.0M|    while (likely(pIn < pInLimit-(STEPSIZE-1))) {
  733|  36.0M|        reg_t const diff = LZ4_read_ARCH(pMatch) ^ LZ4_read_ARCH(pIn);
  734|  36.0M|        if (!diff) { pIn+=STEPSIZE; pMatch+=STEPSIZE; continue; }
  ------------------
  |  |  718|  34.0M|#define STEPSIZE sizeof(reg_t)
  ------------------
                      if (!diff) { pIn+=STEPSIZE; pMatch+=STEPSIZE; continue; }
  ------------------
  |  |  718|  34.0M|#define STEPSIZE sizeof(reg_t)
  ------------------
  |  Branch (734:13): [True: 34.0M, False: 1.97M]
  ------------------
  735|  1.97M|        pIn += LZ4_NbCommonBytes(diff);
  736|  1.97M|        return (unsigned)(pIn - pStart);
  737|  36.0M|    }
  738|       |
  739|  7.66k|    if ((STEPSIZE==8) && (pIn<(pInLimit-3)) && (LZ4_read32(pMatch) == LZ4_read32(pIn))) { pIn+=4; pMatch+=4; }
  ------------------
  |  |  718|  7.66k|#define STEPSIZE sizeof(reg_t)
  ------------------
  |  Branch (739:9): [True: 7.66k, Folded]
  |  Branch (739:26): [True: 4.65k, False: 3.00k]
  |  Branch (739:48): [True: 3.17k, False: 1.47k]
  ------------------
  740|  7.66k|    if ((pIn<(pInLimit-1)) && (LZ4_read16(pMatch) == LZ4_read16(pIn))) { pIn+=2; pMatch+=2; }
  ------------------
  |  Branch (740:9): [True: 5.22k, False: 2.43k]
  |  Branch (740:31): [True: 3.75k, False: 1.47k]
  ------------------
  741|  7.66k|    if ((pIn<pInLimit) && (*pMatch == *pIn)) pIn++;
  ------------------
  |  Branch (741:9): [True: 4.94k, False: 2.72k]
  |  Branch (741:27): [True: 3.58k, False: 1.35k]
  ------------------
  742|  7.66k|    return (unsigned)(pIn - pStart);
  743|  1.98M|}
lz4.c:LZ4_NbCommonBytes:
  620|  8.85M|{
  621|  8.85M|    assert(val != 0);
  ------------------
  |  Branch (621:5): [True: 0, False: 8.85M]
  |  Branch (621:5): [True: 8.85M, False: 0]
  ------------------
  622|  8.85M|    if (LZ4_isLittleEndian()) {
  ------------------
  |  Branch (622:9): [True: 8.85M, False: 0]
  ------------------
  623|  8.85M|        if (sizeof(val) == 8) {
  ------------------
  |  Branch (623:13): [True: 8.85M, Folded]
  ------------------
  624|       |#       if defined(_MSC_VER) && (_MSC_VER >= 1800) && (defined(_M_AMD64) && !defined(_M_ARM64EC)) && !defined(LZ4_FORCE_SW_BITCOUNT)
  625|       |/*-*************************************************************************************************
  626|       |* ARM64EC is a Microsoft-designed ARM64 ABI compatible with AMD64 applications on ARM64 Windows 11.
  627|       |* The ARM64EC ABI does not support AVX/AVX2/AVX512 instructions, nor their relevant intrinsics
  628|       |* including _tzcnt_u64. Therefore, we need to neuter the _tzcnt_u64 code path for ARM64EC.
  629|       |****************************************************************************************************/
  630|       |#         if defined(__clang__) && (__clang_major__ < 10)
  631|       |            /* Avoid undefined clang-cl intrinsics issue.
  632|       |             * See https://github.com/lz4/lz4/pull/1017 for details. */
  633|       |            return (unsigned)__builtin_ia32_tzcnt_u64(val) >> 3;
  634|       |#         else
  635|       |            /* x64 CPUS without BMI support interpret `TZCNT` as `REP BSF` */
  636|       |            return (unsigned)_tzcnt_u64(val) >> 3;
  637|       |#         endif
  638|       |#       elif defined(_MSC_VER) && defined(_WIN64) && !defined(LZ4_FORCE_SW_BITCOUNT)
  639|       |            unsigned long r = 0;
  640|       |            _BitScanForward64(&r, (U64)val);
  641|       |            return (unsigned)r >> 3;
  642|       |#       elif (defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 3) || \
  643|       |                            ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))))) && \
  644|       |                                        !defined(LZ4_FORCE_SW_BITCOUNT)
  645|       |            return (unsigned)__builtin_ctzll((U64)val) >> 3;
  646|       |#       else
  647|       |            const U64 m = 0x0101010101010101ULL;
  648|       |            val ^= val - 1;
  649|       |            return (unsigned)(((U64)((val & (m - 1)) * m)) >> 56);
  650|       |#       endif
  651|  8.85M|        } else /* 32 bits */ {
  652|       |#       if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(LZ4_FORCE_SW_BITCOUNT)
  653|       |            unsigned long r;
  654|       |            _BitScanForward(&r, (U32)val);
  655|       |            return (unsigned)r >> 3;
  656|       |#       elif (defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 3) || \
  657|       |                            ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))))) && \
  658|       |                        !defined(__TINYC__) && !defined(LZ4_FORCE_SW_BITCOUNT)
  659|       |            return (unsigned)__builtin_ctz((U32)val) >> 3;
  660|       |#       else
  661|       |            const U32 m = 0x01010101;
  662|       |            return (unsigned)((((val - 1) ^ val) & (m - 1)) * m) >> 24;
  663|       |#       endif
  664|      0|        }
  665|  8.85M|    } else   /* Big Endian CPU */ {
  666|      0|        if (sizeof(val)==8) {
  ------------------
  |  Branch (666:13): [True: 0, Folded]
  ------------------
  667|      0|#       if (defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 3) || \
  668|      0|                            ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))))) && \
  669|      0|                        !defined(__TINYC__) && !defined(LZ4_FORCE_SW_BITCOUNT)
  670|      0|            return (unsigned)__builtin_clzll((U64)val) >> 3;
  671|       |#       else
  672|       |#if 1
  673|       |            /* this method is probably faster,
  674|       |             * but adds a 128 bytes lookup table */
  675|       |            static const unsigned char ctz7_tab[128] = {
  676|       |                7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  677|       |                4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  678|       |                5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  679|       |                4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  680|       |                6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  681|       |                4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  682|       |                5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  683|       |                4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  684|       |            };
  685|       |            U64 const mask = 0x0101010101010101ULL;
  686|       |            U64 const t = (((val >> 8) - mask) | val) & mask;
  687|       |            return ctz7_tab[(t * 0x0080402010080402ULL) >> 57];
  688|       |#else
  689|       |            /* this method doesn't consume memory space like the previous one,
  690|       |             * but it contains several branches,
  691|       |             * that may end up slowing execution */
  692|       |            static const U32 by32 = sizeof(val)*4;  /* 32 on 64 bits (goal), 16 on 32 bits.
  693|       |            Just to avoid some static analyzer complaining about shift by 32 on 32-bits target.
  694|       |            Note that this code path is never triggered in 32-bits mode. */
  695|       |            unsigned r;
  696|       |            if (!(val>>by32)) { r=4; } else { r=0; val>>=by32; }
  697|       |            if (!(val>>16)) { r+=2; val>>=8; } else { val>>=24; }
  698|       |            r += (!val);
  699|       |            return r;
  700|       |#endif
  701|       |#       endif
  702|      0|        } else /* 32 bits */ {
  703|      0|#       if (defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 3) || \
  704|      0|                            ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))))) && \
  705|      0|                                        !defined(LZ4_FORCE_SW_BITCOUNT)
  706|      0|            return (unsigned)__builtin_clz((U32)val) >> 3;
  707|       |#       else
  708|       |            val >>= 8;
  709|       |            val = ((((val + 0x00FFFF00) | 0x00FFFFFF) + val) |
  710|       |              (val + 0x00FF0000)) >> 24;
  711|       |            return (unsigned)val ^ 3;
  712|       |#       endif
  713|      0|        }
  714|      0|    }
  715|  8.85M|}
lz4.c:LZ4_read16:
  393|  29.1M|static U16 LZ4_read16(const void* ptr) { return ((const LZ4_unalign16*)ptr)->u16; }
lz4.c:LZ4_write32:
  398|  1.88M|static void LZ4_write32(void* memPtr, U32 value) { ((LZ4_unalign32*)memPtr)->u32 = value; }
lz4.c:LZ4_match8:
  994|  8.29M|{
  995|  8.29M|    if (sizeof(reg_t) == 8) return LZ4_read_ARCH(p) == LZ4_read_ARCH(q);
  ------------------
  |  Branch (995:9): [True: 8.29M, Folded]
  ------------------
  996|      0|    return (LZ4_read32(p) == LZ4_read32(q))
  ------------------
  |  Branch (996:12): [True: 0, False: 0]
  ------------------
  997|      0|        && (LZ4_read32((const BYTE*)p + 4) == LZ4_read32((const BYTE*)q + 4));
  ------------------
  |  Branch (997:12): [True: 0, False: 0]
  ------------------
  998|  8.29M|}
lz4.c:LZ4_compress_resumeWithPrefix:
 1460|    590|{
 1461|    590|    return LZ4_compress_generic_validated(cctx, src, dst, srcSize, NULL, dstCapacity, limitedOutput,
 1462|       |                byU32, withPrefix64k, noDictIssue, acceleration, NULL, state);
 1463|    590|}
lz4.c:LZ4_decompress_generic:
 2237|  52.0k|{
 2238|  52.0k|    if ((src == NULL) || (outputSize < 0)) { return -1; }
  ------------------
  |  Branch (2238:9): [True: 0, False: 52.0k]
  |  Branch (2238:26): [True: 0, False: 52.0k]
  ------------------
 2239|       |
 2240|  52.0k|    {   const BYTE* ip = (const BYTE*) src;
 2241|  52.0k|        const BYTE* const iend = ip + srcSize;
 2242|       |
 2243|  52.0k|        BYTE* op = (BYTE*) dst;
 2244|  52.0k|        BYTE* const oend = op + outputSize;
 2245|       |
 2246|  52.0k|        const BYTE* const dictEnd = (dictStart == NULL) ? NULL : dictStart + dictSize;
  ------------------
  |  Branch (2246:37): [True: 49.4k, False: 2.66k]
  ------------------
 2247|       |
 2248|       |        /* withPrefix64k : offset <= 65535 can't reach beyond the 64 KB prefix */
 2249|  52.0k|        const int checkOffset = (dict != withPrefix64k) && (dictSize < (int)(64 KB));
  ------------------
  |  |  251|  38.0k|#define KB *(1 <<10)
  ------------------
  |  Branch (2249:33): [True: 38.0k, False: 14.0k]
  |  Branch (2249:60): [True: 36.1k, False: 1.87k]
  ------------------
 2250|       |
 2251|       |
 2252|       |        /* Set up the "end" pointers for the shortcut. */
 2253|  52.0k|        const BYTE* const shortiend = iend - 14 /*maxLL*/ - 2 /*offset*/;
 2254|  52.0k|        const BYTE* const shortoend = oend - 14 /*maxLL*/ - 18 /*maxML*/;
 2255|       |
 2256|       |        /* shared by both loops : the fast loop can hand over a decoded match (safe_match_copy) */
 2257|  52.0k|        const BYTE* match;
 2258|  52.0k|        size_t offset;
 2259|  52.0k|        size_t ml;   /* match length */
 2260|       |
 2261|       |
 2262|  52.0k|        DEBUGLOG(5, "LZ4_decompress_generic (srcSize:%i, dstSize:%i)", srcSize, outputSize);
  ------------------
  |  |  289|  52.0k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2263|       |
 2264|       |        /* Special cases */
 2265|  52.0k|        assert(lowPrefix <= op);
  ------------------
  |  Branch (2265:9): [True: 0, False: 52.0k]
  |  Branch (2265:9): [True: 52.0k, False: 0]
  ------------------
 2266|  52.0k|        if (unlikely(outputSize==0)) {
  ------------------
  |  |  180|  52.0k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|  52.0k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 52.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2267|       |            /* Empty output buffer */
 2268|      0|            if (partialDecoding) return 0;
  ------------------
  |  Branch (2268:17): [True: 0, False: 0]
  ------------------
 2269|      0|            if ((srcSize==1) && (*ip==0)) return 0;   /* empty block */
  ------------------
  |  Branch (2269:17): [True: 0, False: 0]
  |  Branch (2269:33): [True: 0, False: 0]
  ------------------
 2270|      0|            return (srcSize > 1) ? -2 : -1;   /* -2 : output buffer too small */
  ------------------
  |  Branch (2270:20): [True: 0, False: 0]
  ------------------
 2271|      0|        }
 2272|  52.0k|        if (unlikely(srcSize<=0)) { return -1; }
  ------------------
  |  |  180|  52.0k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|  52.0k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 52.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2273|       |
 2274|       |    /* LZ4_FAST_DEC_LOOP:
 2275|       |     * designed for modern OoO performance cpus,
 2276|       |     * where copying reliably 32-bytes is preferable to an unpredictable branch.
 2277|       |     * note : fast loop may show a regression for some client arm chips. */
 2278|  52.0k|#if LZ4_FAST_DEC_LOOP
 2279|  52.0k|        if ((oend - op) < FASTLOOP_SAFE_DISTANCE) {
  ------------------
  |  |  248|  52.0k|#define FASTLOOP_SAFE_DISTANCE 64
  ------------------
  |  Branch (2279:13): [True: 0, False: 52.0k]
  ------------------
 2280|      0|            DEBUGLOG(6, "move to safe decode loop");
  ------------------
  |  |  289|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2281|      0|            goto safe_decode;
 2282|      0|        }
 2283|       |        /* Ring buffer restarting at its beginning : the oldest referenced history (max distance behind op)
 2284|       |         * lies in the external dictionary, ahead of op, always at the same distance.
 2285|       |         * Rings sized with the former LZ4_DECODER_RING_BUFFER_SIZE() (margin 14, up to v1.10.0)
 2286|       |         * still work, but leave as little as 16 bytes :
 2287|       |         * the fast loop's wide copies could overwrite it, the safe loop's can't. */
 2288|  52.0k|        if ( (dict==usingExtDict)
  ------------------
  |  Branch (2288:14): [True: 2.66k, False: 49.4k]
  ------------------
 2289|  2.66k|          && ((uptrval)dictEnd - (uptrval)lowPrefix - LZ4_DISTANCE_ABSOLUTE_MAX < FASTLOOP_SAFE_DISTANCE) ) {
  ------------------
  |  |  255|  2.66k|#define LZ4_DISTANCE_ABSOLUTE_MAX 65535
  ------------------
                        && ((uptrval)dictEnd - (uptrval)lowPrefix - LZ4_DISTANCE_ABSOLUTE_MAX < FASTLOOP_SAFE_DISTANCE) ) {
  ------------------
  |  |  248|  2.66k|#define FASTLOOP_SAFE_DISTANCE 64
  ------------------
  |  Branch (2289:14): [True: 0, False: 2.66k]
  ------------------
 2290|      0|            DEBUGLOG(6, "history just ahead : move to safe decode loop");
  ------------------
  |  |  289|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2291|      0|            goto safe_decode;
 2292|      0|        }
 2293|       |
 2294|       |        /* Fast loop : decode sequences as long as output < oend-FASTLOOP_SAFE_DISTANCE,
 2295|       |         * and input is not too close to iend.
 2296|       |         * It hands over to the safe loop either at a sequence start (break),
 2297|       |         * or once a match is fully decoded (goto safe_match_copy). */
 2298|  52.0k|        DEBUGLOG(6, "using fast decode loop");
  ------------------
  |  |  289|  52.0k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2299|  29.0M|        while (1) {
  ------------------
  |  Branch (2299:16): [True: 29.0M, Folded]
  ------------------
 2300|  29.0M|            unsigned token;
 2301|  29.0M|            size_t ll;   /* literal length */
 2302|  29.0M|            BYTE* cpy;
 2303|       |            /* Main fastloop assertion: We can always wildcopy FASTLOOP_SAFE_DISTANCE */
 2304|  29.0M|            assert(oend - op >= FASTLOOP_SAFE_DISTANCE);
  ------------------
  |  Branch (2304:13): [True: 0, False: 29.0M]
  |  Branch (2304:13): [True: 29.0M, False: 0]
  ------------------
 2305|  29.0M|            assert(ip < iend);
  ------------------
  |  Branch (2305:13): [True: 0, False: 29.0M]
  |  Branch (2305:13): [True: 29.0M, False: 0]
  ------------------
 2306|  29.0M|            token = *ip++;
 2307|  29.0M|            ll = token >> ML_BITS;
  ------------------
  |  |  260|  29.0M|#define ML_BITS  4
  ------------------
 2308|  29.0M|            DEBUGLOG(7, "blockPos%6u: litLength token = %u", (unsigned)(op-(BYTE*)dst), (unsigned)ll);
  ------------------
  |  |  289|  29.0M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2309|       |
 2310|       |            /* too close to input end : the safe loop restarts this sequence */
 2311|  29.0M|            if (ip > iend-(16 + 1/*max lit + offset + nextToken*/)) { ip--; break; }
  ------------------
  |  Branch (2311:17): [True: 27.2k, False: 29.0M]
  ------------------
 2312|       |
 2313|       |            /* decode literal length */
 2314|  29.0M|            if (ll == RUN_MASK) {
  ------------------
  |  |  263|  29.0M|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|  29.0M|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|  29.0M|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2314:17): [True: 1.82M, False: 27.2M]
  ------------------
 2315|       |                /* literal length >= RUN_MASK means >= RUN_MASK literal bytes follow the extension bytes,
 2316|       |                 * so extension bytes cannot reach the last RUN_MASK bytes of input */
 2317|  1.82M|                const BYTE* const tokenPos = ip-1;
 2318|  1.82M|                size_t const addl = read_variable_length(&ip, iend - RUN_MASK);
  ------------------
  |  |  263|  1.82M|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|  1.82M|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|  1.82M|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2319|  1.82M|                if (addl == rvl_error) {
  ------------------
  |  Branch (2319:21): [True: 87, False: 1.82M]
  ------------------
 2320|     87|                    DEBUGLOG(6, "error reading long literal length");
  ------------------
  |  |  289|     87|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2321|     87|                    goto _output_error;
 2322|     87|                }
 2323|  1.82M|                ll += addl;
 2324|  1.82M|                if (unlikely((uptrval)(op)+ll<(uptrval)(op))) { goto _output_error; } /* overflow detection */
  ------------------
  |  |  180|  1.82M|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|  1.82M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 1.82M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2325|  1.82M|                if (unlikely((uptrval)(ip)+ll<(uptrval)(ip))) { goto _output_error; } /* overflow detection */
  ------------------
  |  |  180|  1.82M|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|  1.82M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 1.82M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2326|       |
 2327|       |                /* copy literals, unless too close to the end for a wild copy :
 2328|       |                 * nothing is written yet, so the safe loop can restart this sequence */
 2329|  1.82M|                cpy = op+ll;
 2330|  1.82M|                LZ4_STATIC_ASSERT(MFLIMIT >= WILDCOPYLENGTH);
  ------------------
  |  |  277|  1.82M|#define LZ4_STATIC_ASSERT(c)   { enum { LZ4_static_assert = 1/(int)(!!(c)) }; }   /* use after variable declarations */
  ------------------
 2331|  1.82M|              #if LZ4_WILDCOPY64
 2332|  1.82M|                if ((cpy>oend-64) || (ip+ll>iend-64)) { ip = tokenPos; break; }
  ------------------
  |  Branch (2332:21): [True: 3.50k, False: 1.82M]
  |  Branch (2332:38): [True: 13.9k, False: 1.80M]
  ------------------
 2333|  1.80M|                LZ4_wildCopy64(op, ip, cpy);
 2334|       |              #else
 2335|       |                if ((cpy>oend-32) || (ip+ll>iend-32)) { ip = tokenPos; break; }
 2336|       |                LZ4_wildCopy32(op, ip, cpy);
 2337|       |              #endif
 2338|  1.80M|                ip += ll; op = cpy;
 2339|  27.2M|            } else {
 2340|  27.2M|                DEBUGLOG(7, "copy %u bytes in a 16-bytes stripe", (unsigned)ll);
  ------------------
  |  |  289|  27.2M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2341|       |                /* Literals can only be <= 14, but hope compilers optimize better when copy by a register size */
 2342|  27.2M|                LZ4_memcpy(op, ip, 16);
  ------------------
  |  |  349|  27.2M|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2343|  27.2M|                ip += ll; op += ll;
 2344|  27.2M|            }
 2345|       |
 2346|       |            /* get offset */
 2347|  29.0M|            offset = LZ4_readLE16(ip); ip+=2;
 2348|  29.0M|            DEBUGLOG(6, "blockPos%6u: offset = %u", (unsigned)(op-(BYTE*)dst), (unsigned)offset);
  ------------------
  |  |  289|  29.0M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2349|  29.0M|            match = op - offset;
 2350|  29.0M|            assert(match <= op);  /* overflow check */
  ------------------
  |  Branch (2350:13): [True: 0, False: 29.0M]
  |  Branch (2350:13): [True: 29.0M, False: 0]
  ------------------
 2351|       |
 2352|       |            /* get matchlength */
 2353|  29.0M|            ml = token & ML_MASK;
  ------------------
  |  |  261|  29.0M|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|  29.0M|#define ML_BITS  4
  |  |  ------------------
  ------------------
 2354|  29.0M|            DEBUGLOG(7, "  match length token = %u (len==%u)", (unsigned)ml, (unsigned)ml+MINMATCH);
  ------------------
  |  |  289|  29.0M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2355|       |
 2356|  29.0M|            if (ml == ML_MASK) {
  ------------------
  |  |  261|  29.0M|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|  29.0M|#define ML_BITS  4
  |  |  ------------------
  ------------------
  |  Branch (2356:17): [True: 4.71M, False: 24.3M]
  ------------------
 2357|       |                /* after match length extension bytes, at least 1 token + LASTLITERALS literals must remain */
 2358|  4.71M|                size_t const addl = read_variable_length(&ip, iend - (1 + LASTLITERALS));
  ------------------
  |  |  245|  4.71M|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
 2359|  4.71M|                if (addl == rvl_error) {
  ------------------
  |  Branch (2359:21): [True: 131, False: 4.71M]
  ------------------
 2360|    131|                    DEBUGLOG(5, "error reading long match length");
  ------------------
  |  |  289|    131|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2361|    131|                    goto _output_error;
 2362|    131|                }
 2363|  4.71M|                ml += addl;
 2364|  4.71M|                DEBUGLOG(7, "  long match length == %u", (unsigned)ml + MINMATCH);
  ------------------
  |  |  289|  4.71M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2365|  4.71M|                if (unlikely((uptrval)(op)+ml<(uptrval)op)) { goto _output_error; } /* overflow detection */
  ------------------
  |  |  180|  4.71M|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|  4.71M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 4.71M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2366|  4.71M|            }
 2367|  29.0M|            ml += MINMATCH;
  ------------------
  |  |  242|  29.0M|#define MINMATCH 4
  ------------------
 2368|       |
 2369|  29.0M|            if (op + ml >= oend - FASTLOOP_SAFE_DISTANCE) {
  ------------------
  |  |  248|  29.0M|#define FASTLOOP_SAFE_DISTANCE 64
  ------------------
  |  Branch (2369:17): [True: 6.75k, False: 29.0M]
  ------------------
 2370|  6.75k|                DEBUGLOG(7, "moving to safe_match_copy (ml==%u)", (unsigned)ml);
  ------------------
  |  |  289|  6.75k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2371|  6.75k|                goto safe_match_copy;
 2372|  6.75k|            }
 2373|       |
 2374|       |            /* match length from token only (<= 18), no overlap, within prefix : copy 18 bytes */
 2375|  29.0M|            if ( ((token & ML_MASK) != ML_MASK) && (offset >= 8)
  ------------------
  |  |  261|  29.0M|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|  29.0M|#define ML_BITS  4
  |  |  ------------------
  ------------------
                          if ( ((token & ML_MASK) != ML_MASK) && (offset >= 8)
  ------------------
  |  |  261|  29.0M|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|  29.0M|#define ML_BITS  4
  |  |  ------------------
  ------------------
  |  Branch (2375:18): [True: 24.3M, False: 4.70M]
  |  Branch (2375:52): [True: 23.0M, False: 1.25M]
  ------------------
 2376|  23.0M|              && ((dict == withPrefix64k) || (match >= lowPrefix)) ) {
  ------------------
  |  Branch (2376:19): [True: 9.64M, False: 13.4M]
  |  Branch (2376:46): [True: 13.3M, False: 121k]
  ------------------
 2377|  22.9M|                assert(match >= lowPrefix);
  ------------------
  |  Branch (2377:17): [True: 0, False: 22.9M]
  |  Branch (2377:17): [True: 22.9M, False: 0]
  ------------------
 2378|  22.9M|                assert(match <= op);
  ------------------
  |  Branch (2378:17): [True: 0, False: 22.9M]
  |  Branch (2378:17): [True: 22.9M, False: 0]
  ------------------
 2379|  22.9M|                assert(op + 18 <= oend);
  ------------------
  |  Branch (2379:17): [True: 0, False: 22.9M]
  |  Branch (2379:17): [True: 22.9M, False: 0]
  ------------------
 2380|  22.9M|                LZ4_memcpy(op, match, 8);
  ------------------
  |  |  349|  22.9M|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2381|  22.9M|                LZ4_memcpy(op+8, match+8, 8);
  ------------------
  |  |  349|  22.9M|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2382|  22.9M|                LZ4_memcpy(op+16, match+16, 2);
  ------------------
  |  |  349|  22.9M|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2383|  22.9M|                op += ml;
 2384|  22.9M|                continue;
 2385|  22.9M|            }
 2386|       |
 2387|       |            /* match ends far from oend : no end-of-block condition to check */
 2388|  29.0M|            assert(op + ml < oend - FASTLOOP_SAFE_DISTANCE);
  ------------------
  |  Branch (2388:13): [True: 0, False: 6.08M]
  |  Branch (2388:13): [True: 6.08M, False: 0]
  ------------------
 2389|       |
 2390|  6.08M|            if ( checkOffset && (unlikely(match + dictSize < lowPrefix)) ) {
  ------------------
  |  |  180|  3.24M|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|  3.24M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  ------------------
  ------------------
  |  Branch (2390:18): [True: 3.24M, False: 2.83M]
  |  Branch (2390:33): [True: 359, False: 3.24M]
  ------------------
 2391|    359|                DEBUGLOG(5, "Error : pos=%zi, offset=%zi => outside buffers", op-lowPrefix, op-match);
  ------------------
  |  |  289|    359|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2392|    359|                goto _offset_error;
 2393|    359|            }
 2394|       |            /* match starting within external dictionary */
 2395|  6.08M|            if ((dict==usingExtDict) && (match < lowPrefix)) {
  ------------------
  |  Branch (2395:17): [True: 460k, False: 5.62M]
  |  Branch (2395:41): [True: 170k, False: 289k]
  ------------------
 2396|   170k|                size_t const inDict = (size_t)(lowPrefix - match);
 2397|   170k|                assert(dictEnd != NULL);
  ------------------
  |  Branch (2397:17): [True: 0, False: 170k]
  |  Branch (2397:17): [True: 170k, False: 0]
  ------------------
 2398|   170k|                if (ml + 16 <= inDict) {
  ------------------
  |  Branch (2398:21): [True: 168k, False: 2.75k]
  ------------------
 2399|       |                    /* match within dictionary, followed by 16 more bytes of dictionary : wild copy */
 2400|   168k|                    LZ4_wildCopy16(op, dictEnd - inDict, op + ml);
 2401|   168k|                    op += ml;
 2402|   168k|                    continue;
 2403|   168k|                }
 2404|  2.75k|                op = LZ4_copyExtDictMatch(op, match, ml, lowPrefix, dictEnd);
 2405|  2.75k|                continue;
 2406|   170k|            }
 2407|       |
 2408|       |            /* copy match within block */
 2409|  5.91M|            cpy = op + ml;
 2410|       |
 2411|  5.91M|            assert((op <= oend) && (oend-op >= 64));
  ------------------
  |  Branch (2411:13): [True: 0, False: 5.91M]
  |  Branch (2411:13): [True: 0, False: 0]
  |  Branch (2411:13): [True: 5.91M, False: 0]
  |  Branch (2411:13): [True: 5.91M, False: 0]
  ------------------
 2412|  5.91M|            if (unlikely(offset<16)) {
  ------------------
  |  |  180|  5.91M|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|  5.91M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 1.67M, False: 4.23M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2413|  1.67M|                LZ4_memcpy_using_offset(op, match, cpy, offset);
 2414|  1.67M|    #if LZ4_WILDCOPY64
 2415|  4.23M|            } else if (offset >= 64) {
  ------------------
  |  Branch (2415:24): [True: 3.91M, False: 319k]
  ------------------
 2416|  3.91M|                LZ4_wildCopy64(op, match, cpy);
 2417|  3.91M|    #endif
 2418|  3.91M|            } else {
 2419|   319k|                LZ4_wildCopy32(op, match, cpy);
 2420|   319k|            }
 2421|       |
 2422|  5.91M|            op = cpy;   /* wildcopy correction */
 2423|  5.91M|        }
 2424|  44.7k|    safe_decode:
 2425|  44.7k|#endif
 2426|       |
 2427|       |        /* Safe loop : decode remaining sequences, without writing beyond oend nor reading beyond iend.
 2428|       |         * With LZ4_FAST_DEC_LOOP, that's the end of the block (or a block too small for the fast loop),
 2429|       |         * entered at a sequence start, or at safe_match_copy with a decoded match.
 2430|       |         * Without it, that's the whole block. */
 2431|  44.7k|        DEBUGLOG(6, "using safe decode loop");
  ------------------
  |  |  289|  44.7k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2432|   142k|        while (1) {
  ------------------
  |  Branch (2432:16): [True: 142k, Folded]
  ------------------
 2433|   142k|            unsigned token;
 2434|   142k|            size_t ll;   /* literal length */
 2435|   142k|            BYTE* cpy;
 2436|   142k|            assert(ip < iend);
  ------------------
  |  Branch (2436:13): [True: 0, False: 142k]
  |  Branch (2436:13): [True: 142k, False: 0]
  ------------------
 2437|   142k|            token = *ip++;
 2438|   142k|            ll = token >> ML_BITS;
  ------------------
  |  |  260|   142k|#define ML_BITS  4
  ------------------
 2439|   142k|            DEBUGLOG(7, "blockPos%6u: litLength token = %u", (unsigned)(op-(BYTE*)dst), (unsigned)ll);
  ------------------
  |  |  289|   142k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2440|       |
 2441|       |            /* A two-stage shortcut for the most common case:
 2442|       |             * 1) If the literal length is 0..14, and there is enough space,
 2443|       |             * enter the shortcut and copy 16 bytes on behalf of the literals.
 2444|       |             * 2) Further if the match length is 4..18, copy 18 bytes in a similar
 2445|       |             * manner; but we ensure that there's enough space in the output for
 2446|       |             * those 18 bytes earlier, upon entering the shortcut (in other words,
 2447|       |             * there is a combined check for both stages).
 2448|       |             */
 2449|   142k|            if ( (ll != RUN_MASK)
  ------------------
  |  |  263|   142k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|   142k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|   142k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2449:18): [True: 120k, False: 22.4k]
  ------------------
 2450|       |                /* strictly "less than" on input, to re-enter the loop with at least one byte */
 2451|   120k|              && likely((ip < shortiend) & (op <= shortoend)) ) {
  ------------------
  |  |  177|   120k|#define likely(expr)     expect((expr) != 0, 1)
  |  |  ------------------
  |  |  |  |  171|   120k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 32.6k, False: 87.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2452|       |                /* Copy the literals */
 2453|  32.6k|                LZ4_memcpy(op, ip, 16);
  ------------------
  |  |  349|  32.6k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2454|  32.6k|                op += ll; ip += ll;
 2455|       |
 2456|       |                /* The second stage: prepare for match copying, decode full info.
 2457|       |                 * If it doesn't work out, the info won't be wasted. */
 2458|  32.6k|                offset = LZ4_readLE16(ip); ip += 2;
 2459|  32.6k|                match = op - offset;
 2460|  32.6k|                assert(match <= op); /* check overflow */
  ------------------
  |  Branch (2460:17): [True: 0, False: 32.6k]
  |  Branch (2460:17): [True: 32.6k, False: 0]
  ------------------
 2461|  32.6k|                ml = token & ML_MASK;
  ------------------
  |  |  261|  32.6k|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|  32.6k|#define ML_BITS  4
  |  |  ------------------
  ------------------
 2462|  32.6k|                DEBUGLOG(7, "blockPos%6u: matchLength token = %u (len=%u)", (unsigned)(op-(BYTE*)dst), (unsigned)ml, (unsigned)ml + 4);
  ------------------
  |  |  289|  32.6k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2463|       |
 2464|       |                /* Do not deal with overlapping matches. */
 2465|  32.6k|                if ( (ml != ML_MASK)
  ------------------
  |  |  261|  32.6k|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|  32.6k|#define ML_BITS  4
  |  |  ------------------
  ------------------
  |  Branch (2465:22): [True: 24.1k, False: 8.45k]
  ------------------
 2466|  24.1k|                  && (offset >= 8)
  ------------------
  |  Branch (2466:22): [True: 18.7k, False: 5.45k]
  ------------------
 2467|  18.7k|                  && (dict==withPrefix64k || match >= lowPrefix) ) {
  ------------------
  |  Branch (2467:23): [True: 6.30k, False: 12.4k]
  |  Branch (2467:46): [True: 12.1k, False: 220]
  ------------------
 2468|       |                    /* Copy the match. */
 2469|  18.5k|                    LZ4_memcpy(op + 0, match + 0, 8);
  ------------------
  |  |  349|  18.5k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2470|  18.5k|                    LZ4_memcpy(op + 8, match + 8, 8);
  ------------------
  |  |  349|  18.5k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2471|  18.5k|                    LZ4_memcpy(op +16, match +16, 2);
  ------------------
  |  |  349|  18.5k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2472|  18.5k|                    op += ml + MINMATCH;
  ------------------
  |  |  242|  18.5k|#define MINMATCH 4
  ------------------
 2473|       |                    /* Both stages worked, load the next token. */
 2474|  18.5k|                    continue;
 2475|  18.5k|                }
 2476|       |                /* The second stage didn't work out, but the info is ready for the match copy below. */
 2477|   110k|            } else {
 2478|       |                /* decode literal length */
 2479|   110k|                if (ll == RUN_MASK) {
  ------------------
  |  |  263|   110k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|   110k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|   110k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2479:21): [True: 22.4k, False: 87.8k]
  ------------------
 2480|       |                    /* literal length >= RUN_MASK means >= RUN_MASK literal bytes follow the extension bytes,
 2481|       |                     * so extension bytes cannot reach the last RUN_MASK bytes of input */
 2482|  22.4k|                    size_t const addl = read_variable_length(&ip, iend-RUN_MASK);
  ------------------
  |  |  263|  22.4k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|  22.4k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|  22.4k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2483|  22.4k|                    if (addl == rvl_error) { goto _output_error; }
  ------------------
  |  Branch (2483:25): [True: 300, False: 22.1k]
  ------------------
 2484|  22.1k|                    ll += addl;
 2485|  22.1k|                    if (unlikely((uptrval)(op)+ll<(uptrval)(op))) { goto _output_error; } /* overflow detection */
  ------------------
  |  |  180|  22.1k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|  22.1k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 22.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2486|  22.1k|                    if (unlikely((uptrval)(ip)+ll<(uptrval)(ip))) { goto _output_error; } /* overflow detection */
  ------------------
  |  |  180|  22.1k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|  22.1k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 22.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2487|  22.1k|                }
 2488|       |
 2489|       |                /* copy literals */
 2490|   109k|                cpy = op+ll;
 2491|   109k|                LZ4_STATIC_ASSERT(MFLIMIT >= WILDCOPYLENGTH);
  ------------------
  |  |  277|   109k|#define LZ4_STATIC_ASSERT(c)   { enum { LZ4_static_assert = 1/(int)(!!(c)) }; }   /* use after variable declarations */
  ------------------
 2492|   109k|                if ((cpy>oend-MFLIMIT) || (ip+ll>iend-(2+1+LASTLITERALS))) {
  ------------------
  |  |  246|   109k|#define MFLIMIT       12   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
                              if ((cpy>oend-MFLIMIT) || (ip+ll>iend-(2+1+LASTLITERALS))) {
  ------------------
  |  |  245|  94.0k|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  |  Branch (2492:21): [True: 15.8k, False: 94.0k]
  |  Branch (2492:43): [True: 34.7k, False: 59.3k]
  ------------------
 2493|       |                    /* close to input or output end : these must be the last literals of the block,
 2494|       |                     * except with partialDecoding, which can also stop within them */
 2495|  50.6k|                    if (partialDecoding) {
  ------------------
  |  Branch (2495:25): [True: 0, False: 50.6k]
  ------------------
 2496|       |                        /* stop at input end, or when output is full */
 2497|      0|                        ll = MIN(ll, (size_t)(iend-ip));
  ------------------
  |  | 2009|      0|#define MIN(a,b)    ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (2009:23): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2498|      0|                        ll = MIN(ll, (size_t)(oend-op));
  ------------------
  |  | 2009|      0|#define MIN(a,b)    ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (2009:23): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2499|  50.6k|                    } else if ((ip+ll != iend) || (cpy > oend)) {
  ------------------
  |  Branch (2499:32): [True: 1.14k, False: 49.5k]
  |  Branch (2499:51): [True: 58, False: 49.4k]
  ------------------
 2500|       |                        /* last literals must end exactly at input end, within output */
 2501|  1.19k|                        DEBUGLOG(5, "invalid last literals : they end at iend%+zi and oend%+zi", (ip+ll)-iend, cpy-oend);
  ------------------
  |  |  289|  1.19k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2502|  1.19k|                        if ((ip+ll <= iend) && (cpy > oend-MFLIMIT)) goto _dst_too_small;   /* output full, input left */
  ------------------
  |  |  246|    521|#define MFLIMIT       12   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  |  Branch (2502:29): [True: 521, False: 678]
  |  Branch (2502:48): [True: 177, False: 344]
  ------------------
 2503|  1.02k|                        goto _output_error;
 2504|  1.19k|                    }
 2505|  49.4k|                    LZ4_memmove(op, ip, ll);  /* supports overlapping memory regions, for in-place decompression scenarios */
  ------------------
  |  |  357|  49.4k|#    define LZ4_memmove __builtin_memmove
  ------------------
 2506|  49.4k|                    ip += ll;
 2507|  49.4k|                    op += ll;
 2508|       |                    /* end of block, unless partialDecoding can go on : output not full, input left for a match */
 2509|  49.4k|                    if (!partialDecoding || (op == oend) || (ip >= (iend-2))) {
  ------------------
  |  Branch (2509:25): [True: 49.4k, False: 0]
  |  Branch (2509:45): [True: 0, False: 0]
  |  Branch (2509:61): [True: 0, False: 0]
  ------------------
 2510|  49.4k|                        break;
 2511|  49.4k|                    }
 2512|  59.3k|                } else {
 2513|  59.3k|                    LZ4_wildCopy8(op, ip, cpy);   /* can overwrite up to 8 bytes beyond cpy */
 2514|  59.3k|                    ip += ll; op = cpy;
 2515|  59.3k|                }
 2516|       |
 2517|       |                /* get offset */
 2518|  59.3k|                offset = LZ4_readLE16(ip); ip+=2;
 2519|  59.3k|                match = op - offset;
 2520|       |
 2521|       |                /* get matchlength */
 2522|  59.3k|                ml = token & ML_MASK;
  ------------------
  |  |  261|  59.3k|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|  59.3k|#define ML_BITS  4
  |  |  ------------------
  ------------------
 2523|  59.3k|                DEBUGLOG(7, "blockPos%6u: matchLength token = %u", (unsigned)(op-(BYTE*)dst), (unsigned)ml);
  ------------------
  |  |  289|  59.3k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2524|  59.3k|            }
 2525|       |
 2526|       |            /* literals copied, offset decoded, ml == match length token */
 2527|  73.4k|            if (ml == ML_MASK) {
  ------------------
  |  |  261|  73.4k|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|  73.4k|#define ML_BITS  4
  |  |  ------------------
  ------------------
  |  Branch (2527:17): [True: 29.8k, False: 43.6k]
  ------------------
 2528|       |                /* after match length extension bytes, at least 1 token + LASTLITERALS literals must remain */
 2529|  29.8k|                size_t const addl = read_variable_length(&ip, iend - (1 + LASTLITERALS));
  ------------------
  |  |  245|  29.8k|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
 2530|  29.8k|                if (addl == rvl_error) { goto _output_error; }
  ------------------
  |  Branch (2530:21): [True: 159, False: 29.6k]
  ------------------
 2531|  29.6k|                ml += addl;
 2532|  29.6k|                if (unlikely((uptrval)(op)+ml<(uptrval)op)) goto _output_error;   /* overflow detection */
  ------------------
  |  |  180|  29.6k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|  29.6k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 29.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2533|  29.6k|            }
 2534|  73.2k|            ml += MINMATCH;
  ------------------
  |  |  242|  73.2k|#define MINMATCH 4
  ------------------
 2535|       |
 2536|  73.2k|#if LZ4_FAST_DEC_LOOP
 2537|  80.0k|        safe_match_copy:
 2538|  80.0k|#endif
 2539|       |            /* literals copied, match fully decoded (ml includes MINMATCH), offset not validated yet */
 2540|  80.0k|            if ((checkOffset) && (unlikely(match + dictSize < lowPrefix))) goto _offset_error;   /* Error : offset outside buffers */
  ------------------
  |  |  180|  51.3k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|  51.3k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  ------------------
  ------------------
  |  Branch (2540:17): [True: 51.3k, False: 28.7k]
  |  Branch (2540:34): [True: 307, False: 51.0k]
  ------------------
 2541|       |
 2542|       |            /* end of block : the last LASTLITERALS bytes must be literals */
 2543|  80.0k|            assert(op <= oend);
  ------------------
  |  Branch (2543:13): [True: 0, False: 79.7k]
  |  Branch (2543:13): [True: 79.7k, False: 0]
  ------------------
 2544|  79.7k|            if (unlikely(op+ml > oend-LASTLITERALS)) {
  ------------------
  |  |  180|  79.7k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|  79.7k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 85, False: 79.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2545|     85|                if (partialDecoding) ml = MIN(ml, (size_t)(oend-op));   /* partialDecoding : may end anywhere */
  ------------------
  |  | 2009|      0|#define MIN(a,b)    ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (2009:23): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (2545:21): [True: 0, False: 85]
  ------------------
 2546|     85|                else goto _dst_too_small;
 2547|     85|            }
 2548|       |
 2549|       |            /* match starting within external dictionary */
 2550|  79.6k|            if ((dict==usingExtDict) && (match < lowPrefix)) {
  ------------------
  |  Branch (2550:17): [True: 4.53k, False: 75.1k]
  |  Branch (2550:41): [True: 420, False: 4.11k]
  ------------------
 2551|    420|                assert(dictEnd != NULL);
  ------------------
  |  Branch (2551:17): [True: 0, False: 420]
  |  Branch (2551:17): [True: 420, False: 0]
  ------------------
 2552|    420|                op = LZ4_copyExtDictMatch(op, match, ml, lowPrefix, dictEnd);
 2553|    420|                continue;
 2554|    420|            }
 2555|  79.6k|            assert(match >= lowPrefix);
  ------------------
  |  Branch (2555:13): [True: 0, False: 79.2k]
  |  Branch (2555:13): [True: 79.2k, False: 0]
  ------------------
 2556|       |
 2557|       |            /* close to block end : no wild copy */
 2558|  79.2k|            if (unlikely(op+ml > oend-MATCH_SAFEGUARD_DISTANCE)) {
  ------------------
  |  |  180|  79.2k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|  79.2k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 11.8k, False: 67.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2559|  11.8k|                op = LZ4_copyMatchExact(op, match, ml);
 2560|  11.8k|                if (op == oend) { break; }   /* partialDecoding : output buffer full */
  ------------------
  |  Branch (2560:21): [True: 0, False: 11.8k]
  ------------------
 2561|  11.8k|                continue;
 2562|  11.8k|            }
 2563|       |
 2564|       |            /* copy match within block */
 2565|  67.3k|            cpy = op + ml;
 2566|  67.3k|            LZ4_memcpy_using_offset_base(op, match, cpy, offset);
 2567|  67.3k|            op = cpy;   /* wildcopy correction */
 2568|  67.3k|        }
 2569|       |
 2570|       |        /* end of decoding */
 2571|  49.4k|        DEBUGLOG(5, "decoded %i bytes", (int) (((char*)op)-dst));
  ------------------
  |  |  289|  49.4k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2572|  49.4k|        return (int) (((char*)op)-dst);     /* Nb of output bytes decoded */
 2573|       |
 2574|       |        /* errors : see LZ4_decompress_safe() in lz4.h */
 2575|  1.69k|    _output_error:
 2576|  1.69k|        return -1;
 2577|    262|    _dst_too_small:
 2578|    262|        return -2;
 2579|    666|    _offset_error:
 2580|    666|        return -3;
 2581|  44.7k|    }
 2582|  44.7k|}
lz4.c:read_variable_length:
 2144|  6.58M|{
 2145|  6.58M|    Rvl_t s, length = 0;
 2146|  6.58M|    assert(ipPtr != NULL);
  ------------------
  |  Branch (2146:5): [True: 0, False: 6.58M]
  |  Branch (2146:5): [True: 6.58M, False: 0]
  ------------------
 2147|  6.58M|    assert(*ipPtr !=  NULL);
  ------------------
  |  Branch (2147:5): [True: 0, False: 6.58M]
  |  Branch (2147:5): [True: 6.58M, False: 0]
  ------------------
 2148|  6.58M|    assert(ilimit != NULL);
  ------------------
  |  Branch (2148:5): [True: 0, False: 6.58M]
  |  Branch (2148:5): [True: 6.58M, False: 0]
  ------------------
 2149|  6.58M|    if (unlikely((*ipPtr) >= ilimit)) {    /* read limit reached */
  ------------------
  |  |  180|  6.58M|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|  6.58M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 315, False: 6.58M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2150|    315|        return rvl_error;
 2151|    315|    }
 2152|  6.58M|    s = **ipPtr;
 2153|  6.58M|    (*ipPtr)++;
 2154|  6.58M|    length += s;
 2155|  6.58M|    if (likely(s != 255)) return length;
  ------------------
  |  |  177|  6.58M|#define likely(expr)     expect((expr) != 0, 1)
  |  |  ------------------
  |  |  |  |  171|  6.58M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 5.83M, False: 754k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2156|  4.95M|    do {
 2157|  4.95M|        if (unlikely((*ipPtr) >= ilimit)) {    /* read limit reached */
  ------------------
  |  |  180|  4.95M|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|  4.95M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 362, False: 4.95M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2158|    362|            return rvl_error;
 2159|    362|        }
 2160|  4.95M|        s = **ipPtr;
 2161|  4.95M|        (*ipPtr)++;
 2162|  4.95M|        length += s;
 2163|       |        /* accumulator overflow detection (32-bit mode only) */
 2164|  4.95M|        if ((sizeof(length) < 8) && unlikely(length > ((Rvl_t)(-1)/2)) ) {
  ------------------
  |  |  180|      0|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|      0|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2164:13): [Folded, False: 4.95M]
  ------------------
 2165|      0|            return rvl_error;
 2166|      0|        }
 2167|  4.95M|    } while (s == 255);
  ------------------
  |  Branch (2167:14): [True: 4.20M, False: 754k]
  ------------------
 2168|       |
 2169|   754k|    return length;
 2170|   754k|}
lz4.c:LZ4_wildCopy64:
  537|  5.72M|{
  538|  5.72M|    BYTE* d = (BYTE*)dstPtr;
  539|  5.72M|    const BYTE* s = (const BYTE*)srcPtr;
  540|  5.72M|    BYTE* const e = (BYTE*)dstEnd;
  541|       |
  542|  19.6M|    do { LZ4_memcpy(d,s,64); d+=64; s+=64; } while (d<e);
  ------------------
  |  |  349|  19.6M|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  |  Branch (542:53): [True: 13.9M, False: 5.72M]
  ------------------
  543|  5.72M|}
lz4.c:LZ4_readLE16:
  431|  29.1M|{
  432|  29.1M|    if (LZ4_isLittleEndian()) {
  ------------------
  |  Branch (432:9): [True: 29.1M, False: 0]
  ------------------
  433|  29.1M|        return LZ4_read16(memPtr);
  434|  29.1M|    } else {
  435|      0|        const BYTE* p = (const BYTE*)memPtr;
  436|      0|        return (U16)((U16)p[0] | (p[1]<<8));
  437|      0|    }
  438|  29.1M|}
lz4.c:LZ4_wildCopy16:
  563|   168k|{
  564|   168k|    BYTE* d = (BYTE*)dstPtr;
  565|   168k|    const BYTE* s = (const BYTE*)srcPtr;
  566|   168k|    BYTE* const e = (BYTE*)dstEnd;
  567|       |
  568|  1.59M|    do { LZ4_memcpy(d,s,16); d+=16; s+=16; } while (d<e);
  ------------------
  |  |  349|  1.59M|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  |  Branch (568:53): [True: 1.42M, False: 168k]
  ------------------
  569|   168k|}
lz4.c:LZ4_copyExtDictMatch:
 2205|  3.17k|{
 2206|  3.17k|    if (length <= (size_t)(lowPrefix-match)) {
  ------------------
  |  Branch (2206:9): [True: 1.21k, False: 1.96k]
  ------------------
 2207|       |        /* match fits entirely within external dictionary : just copy */
 2208|  1.21k|        LZ4_memmove(op, dictEnd - (lowPrefix-match), length);
  ------------------
  |  |  357|  1.21k|#    define LZ4_memmove __builtin_memmove
  ------------------
 2209|  1.21k|        return op + length;
 2210|  1.96k|    } else {
 2211|       |        /* match stretches into both external dictionary and current block */
 2212|  1.96k|        size_t const copySize = (size_t)(lowPrefix - match);
 2213|  1.96k|        LZ4_memcpy(op, dictEnd - copySize, copySize);
  ------------------
  |  |  349|  1.96k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2214|  1.96k|        return LZ4_copyMatchExact(op + copySize, lowPrefix, length - copySize);
 2215|  1.96k|    }
 2216|  3.17k|}
lz4.c:LZ4_memcpy_using_offset:
  576|  1.67M|{
  577|  1.67M|    BYTE v[8];
  578|       |
  579|  1.67M|    assert(dstEnd >= dstPtr + MINMATCH);
  ------------------
  |  Branch (579:5): [True: 0, False: 1.67M]
  |  Branch (579:5): [True: 1.67M, False: 0]
  ------------------
  580|       |
  581|  1.67M|    switch(offset) {
  582|  1.00M|    case 1:
  ------------------
  |  Branch (582:5): [True: 1.00M, False: 676k]
  ------------------
  583|  1.00M|        MEM_INIT(v, *srcPtr, 8);
  ------------------
  |  |  236|  1.00M|#define MEM_INIT(p,v,s)   LZ4_memset((p),(v),(s))
  |  |  ------------------
  |  |  |  |  234|  1.00M|#  define LZ4_memset(p,v,s) memset((p),(v),(s))
  |  |  ------------------
  ------------------
  584|  1.00M|        break;
  585|   206k|    case 2:
  ------------------
  |  Branch (585:5): [True: 206k, False: 1.47M]
  ------------------
  586|   206k|        LZ4_memcpy(v, srcPtr, 2);
  ------------------
  |  |  349|   206k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  587|   206k|        LZ4_memcpy(&v[2], srcPtr, 2);
  ------------------
  |  |  349|   206k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  588|       |#if defined(_MSC_VER) && (_MSC_VER <= 1937) /* MSVC 2022 ver 17.7 or earlier */
  589|       |#  pragma warning(push)
  590|       |#  pragma warning(disable : 6385) /* warning C6385: Reading invalid data from 'v'. */
  591|       |#endif
  592|   206k|        LZ4_memcpy(&v[4], v, 4);
  ------------------
  |  |  349|   206k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  593|       |#if defined(_MSC_VER) && (_MSC_VER <= 1937) /* MSVC 2022 ver 17.7 or earlier */
  594|       |#  pragma warning(pop)
  595|       |#endif
  596|   206k|        break;
  597|  90.0k|    case 4:
  ------------------
  |  Branch (597:5): [True: 90.0k, False: 1.58M]
  ------------------
  598|  90.0k|        LZ4_memcpy(v, srcPtr, 4);
  ------------------
  |  |  349|  90.0k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  599|  90.0k|        LZ4_memcpy(&v[4], srcPtr, 4);
  ------------------
  |  |  349|  90.0k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  600|  90.0k|        break;
  601|   380k|    default:
  ------------------
  |  Branch (601:5): [True: 380k, False: 1.29M]
  ------------------
  602|   380k|        LZ4_memcpy_using_offset_base(dstPtr, srcPtr, dstEnd, offset);
  603|   380k|        return;
  604|  1.67M|    }
  605|       |
  606|  1.29M|    LZ4_memcpy(dstPtr, v, 8);
  ------------------
  |  |  349|  1.29M|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  607|  1.29M|    dstPtr += 8;
  608|  25.6M|    while (dstPtr < dstEnd) {
  ------------------
  |  Branch (608:12): [True: 24.3M, False: 1.29M]
  ------------------
  609|  24.3M|        LZ4_memcpy(dstPtr, v, 8);
  ------------------
  |  |  349|  24.3M|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  610|  24.3M|        dstPtr += 8;
  611|  24.3M|    }
  612|  1.29M|}
lz4.c:LZ4_wildCopy32:
  551|   319k|{
  552|   319k|    BYTE* d = (BYTE*)dstPtr;
  553|   319k|    const BYTE* s = (const BYTE*)srcPtr;
  554|   319k|    BYTE* const e = (BYTE*)dstEnd;
  555|       |
  556|  3.47M|    do { LZ4_memcpy(d,s,16); LZ4_memcpy(d+16,s+16,16); d+=32; s+=32; } while (d<e);
  ------------------
  |  |  349|  3.47M|#    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);
  ------------------
  |  |  349|  3.47M|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  |  Branch (556:79): [True: 3.15M, False: 319k]
  ------------------
  557|   319k|}
lz4.c:LZ4_copyMatchExact:
 2179|  13.8k|{
 2180|  13.8k|    if (unlikely(match == op)) {   /* invalid offset 0 : clear the match segment, see doc/lz4_Block_format.md */
  ------------------
  |  |  180|  13.8k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|  13.8k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 48, False: 13.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2181|     48|        MEM_INIT(op, 0, length);
  ------------------
  |  |  236|     48|#define MEM_INIT(p,v,s)   LZ4_memset((p),(v),(s))
  |  |  ------------------
  |  |  |  |  234|     48|#  define LZ4_memset(p,v,s) memset((p),(v),(s))
  |  |  ------------------
  ------------------
 2182|     48|        return op + length;
 2183|     48|    }
 2184|       |    /* bytes from match to op repeat with period (op-match) :
 2185|       |     * copy all of them, so the distance doubles at each round.
 2186|       |     * Beyond 2 KB, keep the distance : larger copies of just written data are slower */
 2187|  72.9k|    while (length > (size_t)(op - match)) {
  ------------------
  |  Branch (2187:12): [True: 59.1k, False: 13.8k]
  ------------------
 2188|  59.1k|        size_t const available = (size_t)(op - match);
 2189|  59.1k|        LZ4_memcpy(op, match, available);
  ------------------
  |  |  349|  59.1k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2190|  59.1k|        op += available;
 2191|  59.1k|        length -= available;
 2192|  59.1k|        if (available >= 2048) match += available;
  ------------------
  |  Branch (2192:13): [True: 35.0k, False: 24.1k]
  ------------------
 2193|  59.1k|    }
 2194|  13.8k|    LZ4_memcpy(op, match, length);
  ------------------
  |  |  349|  13.8k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2195|  13.8k|    return op + length;
 2196|  13.8k|}
lz4.c:LZ4_memcpy_using_offset_base:
  497|   447k|{
  498|   447k|    assert(srcPtr + offset == dstPtr);
  ------------------
  |  Branch (498:5): [True: 0, False: 447k]
  |  Branch (498:5): [True: 447k, False: 0]
  ------------------
  499|   447k|    if (unlikely(offset < 8)) {
  ------------------
  |  |  180|   447k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|   447k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 357k, False: 89.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  500|   357k|        LZ4_write32(dstPtr, 0);   /* silence an msan warning when offset==0 */
  501|   357k|        dstPtr[0] = srcPtr[0];
  502|   357k|        dstPtr[1] = srcPtr[1];
  503|   357k|        dstPtr[2] = srcPtr[2];
  504|   357k|        dstPtr[3] = srcPtr[3];
  505|   357k|        srcPtr += inc32table[offset];
  506|   357k|        LZ4_memcpy(dstPtr+4, srcPtr, 4);
  ------------------
  |  |  349|   357k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  507|   357k|        srcPtr -= dec64table[offset];
  508|   357k|    } else {
  509|  89.9k|        LZ4_memcpy(dstPtr, srcPtr, 8);
  ------------------
  |  |  349|  89.9k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  510|  89.9k|        srcPtr += 8;
  511|  89.9k|    }
  512|   447k|    dstPtr += 8;
  513|       |
  514|       |    /* srcPtr is now at least 8 bytes behind dstPtr */
  515|   447k|    LZ4_memcpy(dstPtr, srcPtr, 8);
  ------------------
  |  |  349|   447k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  516|   447k|    if (dstEnd > dstPtr + 8) { LZ4_wildCopy8(dstPtr + 8, srcPtr + 8, dstEnd); }
  ------------------
  |  Branch (516:9): [True: 123k, False: 323k]
  ------------------
  517|   447k|}
lz4.c:LZ4_decompress_safe_withSmallPrefix:
 2643|  5.30k|{
 2644|  5.30k|    return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize,
 2645|  5.30k|                                  decode_full_block, noDict,
 2646|       |                                  (BYTE*)dest-prefixSize, NULL, 0);
 2647|  5.30k|}

LZ4F_readOpen_advanced:
  181|  31.3k|{
  182|  31.3k|    LZ4_readFile_t* readFile;
  183|       |
  184|       |    /* Validate parameters */
  185|  31.3k|    if (lz4fRead == NULL) {
  ------------------
  |  Branch (185:9): [True: 0, False: 31.3k]
  ------------------
  186|      0|        RETURN_ERROR(parameter_null);
  ------------------
  |  |   74|      0|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  187|      0|    }
  188|  31.3k|    *lz4fRead = NULL;   /* in case of failure */
  189|  31.3k|    if (fp == NULL) {
  ------------------
  |  Branch (189:9): [True: 0, False: 31.3k]
  ------------------
  190|      0|        RETURN_ERROR(parameter_null);
  ------------------
  |  |   74|      0|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  191|      0|    }
  192|       |
  193|       |    /* Allocate read file structure */
  194|  31.3k|    readFile = (LZ4_readFile_t*)fileMalloc(sizeof(LZ4_readFile_t), customMem);
  195|  31.3k|    if (readFile == NULL) {
  ------------------
  |  Branch (195:9): [True: 0, False: 31.3k]
  ------------------
  196|      0|        RETURN_ERROR(allocation_failed);
  ------------------
  |  |   74|      0|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  197|      0|    }
  198|  31.3k|    memset(readFile, 0, sizeof(*readFile));
  199|  31.3k|    readFile->cmem = customMem;
  200|       |
  201|  31.3k|    readFile->fp = fp;
  202|  31.3k|    readFile->seekable = (ftell(fp) != -1L);   /* no position on pipes */
  203|       |
  204|       |    /* Initialize decompression context */
  205|  31.3k|    readFile->dctxPtr = LZ4F_createDecompressionContext_advanced(customMem, LZ4F_VERSION);
  ------------------
  |  |  336|  31.3k|#define LZ4F_VERSION 100    /* This number can be used to check for an incompatible API breaking change */
  ------------------
  206|  31.3k|    if (readFile->dctxPtr == NULL) {
  ------------------
  |  Branch (206:9): [True: 0, False: 31.3k]
  ------------------
  207|      0|        freeReadFileResources(readFile);
  208|      0|        RETURN_ERROR(allocation_failed);
  ------------------
  |  |   74|      0|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  209|      0|    }
  210|       |
  211|       |    /* Read and parse the header */
  212|  31.3k|    { LZ4F_errorCode_t const result = readAndParseHeader(readFile, fp);
  213|  31.3k|      if (LZ4F_isError(result)) {
  ------------------
  |  Branch (213:11): [True: 11.9k, False: 19.3k]
  ------------------
  214|  11.9k|          freeReadFileResources(readFile);
  215|  11.9k|          return result;
  216|  11.9k|    } }
  217|       |
  218|  19.3k|    *lz4fRead = readFile;
  219|  19.3k|    return LZ4F_OK_NoError;
  220|  31.3k|}
LZ4F_readOpen:
  223|  31.3k|{
  224|  31.3k|    return LZ4F_readOpen_advanced(lz4fRead, fp, LZ4F_defaultCMem);
  225|  31.3k|}
LZ4F_read:
  293|  66.3k|{
  294|  66.3k|  LZ4_byte* outPtr = (LZ4_byte*)buf;
  295|  66.3k|  size_t totalBytesRead = 0;
  296|       |
  297|  66.3k|  if (lz4fRead == NULL || buf == NULL)
  ------------------
  |  Branch (297:7): [True: 0, False: 66.3k]
  |  Branch (297:27): [True: 0, False: 66.3k]
  ------------------
  298|      0|    RETURN_ERROR(parameter_null);
  ------------------
  |  |   74|      0|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  299|  66.3k|  if (LZ4F_isError(lz4fRead->error))
  ------------------
  |  Branch (299:7): [True: 966, False: 65.3k]
  ------------------
  300|    966|    return lz4fRead->error;
  301|       |
  302|   225k|  while (totalBytesRead < size) {
  ------------------
  |  Branch (302:10): [True: 173k, False: 51.5k]
  ------------------
  303|   173k|    size_t srcBytes = lz4fRead->srcBufSize - lz4fRead->srcBufNext;
  304|   173k|    size_t dstBytes = size - totalBytesRead;
  305|   173k|    size_t provided;
  306|       |
  307|   173k|    if (srcBytes == 0) {
  ------------------
  |  Branch (307:9): [True: 46.6k, False: 127k]
  ------------------
  308|  46.6k|      size_t bytesRead;
  309|  46.6k|      lz4fRead->srcBufPos += lz4fRead->srcBufSize;
  310|  46.6k|      lz4fRead->srcBufSize = 0;
  311|  46.6k|      lz4fRead->srcBufNext = 0;
  312|  46.6k|      bytesRead = fread(lz4fRead->srcBuf, 1, lz4fRead->srcBufMaxSize, lz4fRead->fp);
  313|  46.6k|      if (bytesRead == 0) {
  ------------------
  |  Branch (313:11): [True: 10.1k, False: 36.5k]
  ------------------
  314|  10.1k|        if (ferror(lz4fRead->fp) || frameInProgress(lz4fRead)) {
  ------------------
  |  Branch (314:13): [True: 0, False: 10.1k]
  |  Branch (314:37): [True: 1.77k, False: 8.34k]
  ------------------
  315|  1.77k|          RETURN_ERROR(io_read);   /* read error, or input ends within a frame */
  ------------------
  |  |   74|  1.77k|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  316|  1.77k|        }
  317|  8.34k|        break; /* end of input reached */
  318|  10.1k|      }
  319|       |      /* success: ret > 0*/
  320|  36.5k|      lz4fRead->srcBufSize = bytesRead;
  321|  36.5k|      srcBytes = lz4fRead->srcBufSize;
  322|  36.5k|    }
  323|       |
  324|       |    /* provide at most the hinted amount : decoding then stops right after each block header */
  325|   163k|    if (srcBytes > inputLimit(lz4fRead)) srcBytes = inputLimit(lz4fRead);
  ------------------
  |  Branch (325:9): [True: 119k, False: 44.4k]
  ------------------
  326|   163k|    provided = srcBytes;
  327|       |
  328|   163k|    { size_t const decStatus = LZ4F_decompress(
  329|   163k|                          lz4fRead->dctxPtr,
  330|   163k|                          outPtr, &dstBytes,
  331|   163k|                          lz4fRead->srcBuf + lz4fRead->srcBufNext,
  332|   163k|                          &srcBytes,
  333|   163k|                          NULL);
  334|   163k|      if (LZ4F_isError(decStatus)) {
  ------------------
  |  Branch (334:11): [True: 3.72k, False: 159k]
  ------------------
  335|  3.72k|          lz4fRead->error = decStatus;   /* the dctx can't be used again before a reset */
  336|  3.72k|          return decStatus;
  337|  3.72k|      }
  338|   159k|      lz4fRead->srcBufNext += srcBytes;
  339|   159k|      lz4fRead->decodedPos += dstBytes;
  340|   159k|      totalBytesRead += dstBytes;
  341|   159k|      outPtr += dstBytes;
  342|   159k|      trackPosition(lz4fRead, decStatus, provided, srcBytes);
  343|   159k|    }
  344|   159k|  }
  345|       |
  346|  59.8k|  return totalBytesRead;
  347|  65.3k|}
LZ4F_seek:
  398|  27.7k|{
  399|  27.7k|  unsigned long long target;
  400|       |
  401|  27.7k|  if (lz4fRead == NULL)
  ------------------
  |  Branch (401:7): [True: 0, False: 27.7k]
  ------------------
  402|      0|    RETURN_ERROR(parameter_null);
  ------------------
  |  |   74|      0|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  403|       |
  404|  27.7k|  switch (origin) {
  405|  19.0k|  case SEEK_SET:
  ------------------
  |  Branch (405:3): [True: 19.0k, False: 8.75k]
  ------------------
  406|  19.0k|    if (offset < 0) RETURN_ERROR(parameter_invalid);
  ------------------
  |  |   74|    766|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  |  Branch (406:9): [True: 766, False: 18.2k]
  ------------------
  407|  18.2k|    target = (unsigned long long)offset;
  408|  18.2k|    break;
  409|  8.75k|  case SEEK_CUR:
  ------------------
  |  Branch (409:3): [True: 8.75k, False: 19.0k]
  ------------------
  410|  8.75k|    if (offset < 0 && (unsigned long long)-(offset + 1) >= lz4fRead->decodedPos)
  ------------------
  |  Branch (410:9): [True: 4.76k, False: 3.99k]
  |  Branch (410:23): [True: 412, False: 4.35k]
  ------------------
  411|    412|      RETURN_ERROR(parameter_invalid);   /* before start */
  ------------------
  |  |   74|    412|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  412|  8.34k|    target = lz4fRead->decodedPos + (unsigned long long)offset;
  413|  8.34k|    break;
  414|      0|  default:   /* SEEK_END is not supported */
  ------------------
  |  Branch (414:3): [True: 0, False: 27.7k]
  ------------------
  415|      0|    RETURN_ERROR(parameter_invalid);
  ------------------
  |  |   74|      0|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  416|  27.7k|  }
  417|       |
  418|       |  /* restart from closest resume point : required backward, and avoids decoding forward */
  419|  26.6k|  { const LZ4F_resumePoint* const p = findResumePoint(lz4fRead, target);
  420|  26.6k|    if (target < lz4fRead->decodedPos) {
  ------------------
  |  Branch (420:9): [True: 14.4k, False: 12.1k]
  ------------------
  421|  14.4k|      LZ4F_errorCode_t const result = restartFrom(lz4fRead, p);
  422|  14.4k|      if (LZ4F_isError(result)) return result;
  ------------------
  |  Branch (422:11): [True: 0, False: 14.4k]
  ------------------
  423|  14.4k|    } else if (p != NULL && p->dPos > lz4fRead->decodedPos && lz4fRead->seekable) {
  ------------------
  |  Branch (423:16): [True: 1.02k, False: 11.1k]
  |  Branch (423:29): [True: 759, False: 264]
  |  Branch (423:63): [True: 759, False: 0]
  ------------------
  424|    759|      LZ4F_errorCode_t const result = restartFrom(lz4fRead, p);
  425|    759|      if (LZ4F_isError(result)) return result;
  ------------------
  |  Branch (425:11): [True: 0, False: 759]
  ------------------
  426|    759|  } }
  427|       |
  428|       |  /* decode and discard up to target */
  429|  26.6k|  if (lz4fRead->decodedPos < target && lz4fRead->skipBuf == NULL) {
  ------------------
  |  Branch (429:7): [True: 20.6k, False: 5.96k]
  |  Branch (429:40): [True: 6.29k, False: 14.3k]
  ------------------
  430|  6.29k|    lz4fRead->skipBuf = (LZ4_byte*)fileMalloc(LZ4F_SKIP_BUFFER_SIZE, lz4fRead->cmem);
  ------------------
  |  |   87|  6.29k|#define LZ4F_SKIP_BUFFER_SIZE (64 << 10)
  ------------------
  431|  6.29k|    if (lz4fRead->skipBuf == NULL) RETURN_ERROR(allocation_failed);
  ------------------
  |  |   74|      0|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  |  Branch (431:9): [True: 0, False: 6.29k]
  ------------------
  432|  6.29k|  }
  433|  49.5k|  while (lz4fRead->decodedPos < target) {
  ------------------
  |  Branch (433:10): [True: 27.2k, False: 22.3k]
  ------------------
  434|  27.2k|    unsigned long long const remaining = target - lz4fRead->decodedPos;
  435|  27.2k|    size_t const toRead = (remaining < LZ4F_SKIP_BUFFER_SIZE) ? (size_t)remaining : LZ4F_SKIP_BUFFER_SIZE;
  ------------------
  |  |   87|  27.2k|#define LZ4F_SKIP_BUFFER_SIZE (64 << 10)
  ------------------
                  size_t const toRead = (remaining < LZ4F_SKIP_BUFFER_SIZE) ? (size_t)remaining : LZ4F_SKIP_BUFFER_SIZE;
  ------------------
  |  |   87|  10.0k|#define LZ4F_SKIP_BUFFER_SIZE (64 << 10)
  ------------------
  |  Branch (435:27): [True: 17.2k, False: 10.0k]
  ------------------
  436|  27.2k|    size_t const result = LZ4F_read(lz4fRead, lz4fRead->skipBuf, toRead);
  437|  27.2k|    if (LZ4F_isError(result)) return result;
  ------------------
  |  Branch (437:9): [True: 4.17k, False: 23.0k]
  ------------------
  438|  23.0k|    if (result == 0) RETURN_ERROR(parameter_invalid);   /* beyond end of decoded data */
  ------------------
  |  |   74|     98|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  |  Branch (438:9): [True: 98, False: 22.9k]
  ------------------
  439|  23.0k|  }
  440|  22.3k|  return LZ4F_OK_NoError;
  441|  26.6k|}
LZ4F_tell:
  444|  72.6k|{
  445|  72.6k|  return lz4fRead ? lz4fRead->decodedPos : 0;
  ------------------
  |  Branch (445:10): [True: 72.6k, False: 0]
  ------------------
  446|  72.6k|}
LZ4F_readClose:
  449|  19.3k|{
  450|  19.3k|  if (lz4fRead == NULL)
  ------------------
  |  Branch (450:7): [True: 0, False: 19.3k]
  ------------------
  451|      0|    RETURN_ERROR(parameter_null);
  ------------------
  |  |   74|      0|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  452|  19.3k|  freeReadFileResources(lz4fRead);
  453|  19.3k|  return LZ4F_OK_NoError;
  454|  19.3k|}
LZ4F_writeOpen_advanced:
  499|  15.6k|{
  500|  15.6k|  LZ4_writeFile_t* writeFile;
  501|  15.6k|  size_t blockSize;
  502|       |
  503|  15.6k|  if (lz4fWrite == NULL)
  ------------------
  |  Branch (503:7): [True: 0, False: 15.6k]
  ------------------
  504|      0|      RETURN_ERROR(parameter_null);
  ------------------
  |  |   74|      0|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  505|  15.6k|  *lz4fWrite = NULL;   /* in case of failure */
  506|  15.6k|  if (fp == NULL)
  ------------------
  |  Branch (506:7): [True: 0, False: 15.6k]
  ------------------
  507|      0|      RETURN_ERROR(parameter_null);
  ------------------
  |  |   74|      0|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  508|       |
  509|       |  /* Validate block size */
  510|  15.6k|  { LZ4F_blockSizeID_t const blockSizeID = prefsPtr ? prefsPtr->frameInfo.blockSizeID : LZ4F_default;
  ------------------
  |  Branch (510:44): [True: 15.6k, False: 0]
  ------------------
  511|  15.6k|    blockSize = LZ4F_getBlockSize(blockSizeID);
  512|  15.6k|    if (LZ4F_isError(blockSize)) {
  ------------------
  |  Branch (512:9): [True: 0, False: 15.6k]
  ------------------
  513|      0|        RETURN_ERROR(maxBlockSize_invalid);
  ------------------
  |  |   74|      0|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  514|      0|  } }
  515|       |
  516|       |  /* Allocate write file structure */
  517|  15.6k|  writeFile = (LZ4_writeFile_t*)fileMalloc(sizeof(LZ4_writeFile_t), customMem);
  518|  15.6k|  if (writeFile == NULL) {
  ------------------
  |  Branch (518:7): [True: 0, False: 15.6k]
  ------------------
  519|      0|    RETURN_ERROR(allocation_failed);
  ------------------
  |  |   74|      0|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  520|      0|  }
  521|  15.6k|  memset(writeFile, 0, sizeof(*writeFile));
  522|  15.6k|  writeFile->cmem = customMem;
  523|  15.6k|  writeFile->fp = fp;
  524|  15.6k|  writeFile->errCode = LZ4F_OK_NoError;
  525|  15.6k|  writeFile->maxWriteSize = blockSize;
  526|       |
  527|       |  /* Calculate and allocate destination buffer */
  528|  15.6k|  writeFile->dstBufMaxSize = LZ4F_compressBound(blockSize, prefsPtr);
  529|  15.6k|  writeFile->dstBuf = (LZ4_byte*)fileMalloc(writeFile->dstBufMaxSize, customMem);
  530|  15.6k|  if (writeFile->dstBuf == NULL) {
  ------------------
  |  Branch (530:7): [True: 0, False: 15.6k]
  ------------------
  531|      0|    freeWriteFileResources(writeFile);
  532|      0|    RETURN_ERROR(allocation_failed);
  ------------------
  |  |   74|      0|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  533|      0|  }
  534|       |
  535|       |  /* Initialize compression context */
  536|  15.6k|  writeFile->cctxPtr = LZ4F_createCompressionContext_advanced(customMem, LZ4F_VERSION);
  ------------------
  |  |  336|  15.6k|#define LZ4F_VERSION 100    /* This number can be used to check for an incompatible API breaking change */
  ------------------
  537|  15.6k|  if (writeFile->cctxPtr == NULL) {
  ------------------
  |  Branch (537:7): [True: 0, False: 15.6k]
  ------------------
  538|      0|    freeWriteFileResources(writeFile);
  539|      0|    RETURN_ERROR(allocation_failed);
  ------------------
  |  |   74|      0|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  540|      0|  }
  541|       |
  542|       |    /* Write header to file */
  543|  15.6k|  { LZ4F_errorCode_t const writeStatus = writeHeader(writeFile, fp, prefsPtr);
  544|  15.6k|    if (LZ4F_isError(writeStatus)) {
  ------------------
  |  Branch (544:9): [True: 0, False: 15.6k]
  ------------------
  545|      0|        freeWriteFileResources(writeFile);
  546|      0|        return writeStatus;
  547|      0|  } }
  548|       |
  549|  15.6k|  *lz4fWrite = writeFile;
  550|  15.6k|  return LZ4F_OK_NoError;
  551|  15.6k|}
LZ4F_writeOpen:
  554|  15.6k|{
  555|  15.6k|  return LZ4F_writeOpen_advanced(lz4fWrite, fp, prefsPtr, LZ4F_defaultCMem);
  556|  15.6k|}
LZ4F_write:
  559|  31.3k|{
  560|  31.3k|  const LZ4_byte* p = (const LZ4_byte*)buf;
  561|  31.3k|  size_t remainingBytes = size;
  562|       |
  563|       |  /* Validate parameters */
  564|  31.3k|  if (lz4fWrite == NULL || buf == NULL)
  ------------------
  |  Branch (564:7): [True: 0, False: 31.3k]
  |  Branch (564:28): [True: 0, False: 31.3k]
  ------------------
  565|      0|    RETURN_ERROR(parameter_null);
  ------------------
  |  |   74|      0|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  566|       |
  567|  71.1k|  while (remainingBytes) {
  ------------------
  |  Branch (567:10): [True: 39.8k, False: 31.3k]
  ------------------
  568|  39.8k|    size_t const chunkSize = (remainingBytes > lz4fWrite->maxWriteSize) ? lz4fWrite->maxWriteSize : remainingBytes;
  ------------------
  |  Branch (568:30): [True: 8.62k, False: 31.2k]
  ------------------
  569|       |
  570|       |    /* Compress and write chunk */
  571|  39.8k|    size_t cSize = LZ4F_compressUpdate(lz4fWrite->cctxPtr,
  572|  39.8k|                              lz4fWrite->dstBuf, lz4fWrite->dstBufMaxSize,
  573|  39.8k|                              p, chunkSize,
  574|  39.8k|                              NULL);
  575|  39.8k|    if (LZ4F_isError(cSize)) {
  ------------------
  |  Branch (575:9): [True: 0, False: 39.8k]
  ------------------
  576|      0|      lz4fWrite->errCode = cSize;
  577|      0|      return cSize;
  578|      0|    }
  579|       |
  580|  39.8k|    if (cSize != 0 && cSize != fwrite(lz4fWrite->dstBuf, 1, cSize, lz4fWrite->fp)) {
  ------------------
  |  Branch (580:9): [True: 22.0k, False: 17.7k]
  |  Branch (580:23): [True: 0, False: 22.0k]
  ------------------
  581|      0|      lz4fWrite->errCode = returnErrorCode(LZ4F_ERROR_io_write);
  582|      0|      RETURN_ERROR(io_write);
  ------------------
  |  |   74|      0|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  583|      0|    }
  584|       |
  585|       |    /* Update positions */
  586|  39.8k|    p += chunkSize;
  587|  39.8k|    remainingBytes -= chunkSize;
  588|  39.8k|  }
  589|       |
  590|  31.3k|  return size;
  591|  31.3k|}
LZ4F_writeClose:
  594|  15.6k|{
  595|  15.6k|  LZ4F_errorCode_t ret;
  596|       |
  597|  15.6k|  if (lz4fWrite == NULL) {
  ------------------
  |  Branch (597:7): [True: 0, False: 15.6k]
  ------------------
  598|      0|    RETURN_ERROR(parameter_null);
  ------------------
  |  |   74|      0|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  599|      0|  }
  600|       |
  601|  15.6k|  ret = lz4fWrite->errCode;   /* a previous LZ4F_write() failure leaves the frame incomplete */
  602|  15.6k|  if (ret == LZ4F_OK_NoError) {
  ------------------
  |  Branch (602:7): [True: 15.6k, False: 0]
  ------------------
  603|  15.6k|    size_t endSize;
  604|  15.6k|    do {   /* dstBuf >= LZ4F_compressBound(0) : a single invocation completes the frame */
  605|  15.6k|      endSize = LZ4F_compressEnd(lz4fWrite->cctxPtr,
  606|  15.6k|                                 lz4fWrite->dstBuf, lz4fWrite->dstBufMaxSize,
  607|  15.6k|                                 NULL);
  608|  15.6k|      if (LZ4F_isError(endSize)) {
  ------------------
  |  Branch (608:11): [True: 0, False: 15.6k]
  ------------------
  609|      0|        ret = endSize;
  610|      0|        break;
  611|      0|      }
  612|  15.6k|      if (endSize != fwrite(lz4fWrite->dstBuf, 1, endSize, lz4fWrite->fp)) {
  ------------------
  |  Branch (612:11): [True: 0, False: 15.6k]
  ------------------
  613|      0|        ret = returnErrorCode(LZ4F_ERROR_io_write);
  614|      0|        break;
  615|      0|      }
  616|  15.6k|    } while (endSize == lz4fWrite->dstBufMaxSize);
  ------------------
  |  Branch (616:14): [True: 0, False: 15.6k]
  ------------------
  617|  15.6k|  }
  618|       |
  619|  15.6k|  freeWriteFileResources(lz4fWrite);
  620|  15.6k|  return ret;
  621|  15.6k|}
lz4file.c:returnErrorCode:
   69|  3.30k|{
   70|  3.30k|    return (LZ4F_errorCode_t)-(ptrdiff_t)code;
   71|  3.30k|}
lz4file.c:fileMalloc:
   55|  95.8k|{
   56|  95.8k|  if (cmem.customAlloc != NULL) return cmem.customAlloc(cmem.opaqueState, s);
  ------------------
  |  Branch (56:7): [True: 0, False: 95.8k]
  ------------------
   57|  95.8k|  return LZ4FILE_MALLOC(s);
  ------------------
  |  |   50|  95.8k|#  define LZ4FILE_MALLOC(s)    malloc(s)
  ------------------
   58|  95.8k|}
lz4file.c:freeReadFileResources:
  119|  31.3k|{
  120|  31.3k|  if (lz4fRead==NULL) return;
  ------------------
  |  Branch (120:7): [True: 0, False: 31.3k]
  ------------------
  121|  31.3k|  LZ4F_freeDecompressionContext(lz4fRead->dctxPtr);
  122|  31.3k|  fileFree(lz4fRead->srcBuf, lz4fRead->cmem);
  123|  31.3k|  fileFree(lz4fRead->points, lz4fRead->cmem);
  124|  31.3k|  fileFree(lz4fRead->skipBuf, lz4fRead->cmem);
  125|  31.3k|  fileFree(lz4fRead, lz4fRead->cmem);
  126|  31.3k|}
lz4file.c:fileFree:
   61|   164k|{
   62|   164k|  if (p == NULL) return;
  ------------------
  |  Branch (62:7): [True: 68.3k, False: 95.8k]
  ------------------
   63|  95.8k|  if (cmem.customFree != NULL) cmem.customFree(cmem.opaqueState, p);
  ------------------
  |  Branch (63:7): [True: 0, False: 95.8k]
  ------------------
   64|  95.8k|  else LZ4FILE_FREE(p);
  ------------------
  |  |   51|  95.8k|#  define LZ4FILE_FREE(p)      free(p)
  ------------------
   65|  95.8k|}
lz4file.c:readAndParseHeader:
  129|  31.3k|{
  130|  31.3k|    char headerBuf[LZ4F_HEADER_SIZE_MAX];
  131|  31.3k|    LZ4F_frameInfo_t frameInfo;
  132|  31.3k|    size_t consumedSize;
  133|       |
  134|       |    /* Read the header from file */
  135|  31.3k|    const size_t bytesRead = fread(headerBuf, 1, sizeof(headerBuf), fp);
  136|  31.3k|    if (bytesRead < LZ4F_SKIPPABLE_HEADER_SIZE) {
  ------------------
  |  |   88|  31.3k|#define LZ4F_SKIPPABLE_HEADER_SIZE 8   /* magic number, frame size : the shortest complete frame */
  ------------------
  |  Branch (136:9): [True: 255, False: 31.0k]
  ------------------
  137|    255|        RETURN_ERROR(io_read);
  ------------------
  |  |   74|    255|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  138|    255|    }
  139|       |
  140|       |    /* Parse frame information */
  141|  31.0k|    consumedSize = bytesRead;
  142|  31.0k|    { const size_t result = LZ4F_getFrameInfo(readFile->dctxPtr, &frameInfo, headerBuf, &consumedSize);
  143|  31.0k|      if (LZ4F_isError(result)) {
  ------------------
  |  Branch (143:11): [True: 11.7k, False: 19.3k]
  ------------------
  144|  11.7k|          return result;
  145|  11.7k|      }
  146|  19.3k|      readFile->hint = result;
  147|  19.3k|    }
  148|       |    /* A normal frame needs an end mark, while an empty skippable frame is only its header. */
  149|  19.3k|    if (frameInfo.frameType != LZ4F_skippableFrame
  ------------------
  |  Branch (149:9): [True: 19.0k, False: 342]
  ------------------
  150|  19.0k|      && bytesRead < LZ4F_HEADER_SIZE_MIN + LZ4F_ENDMARK_SIZE) {
  ------------------
  |  |  360|  19.0k|#define LZ4F_HEADER_SIZE_MIN  7   /* LZ4 Frame header size can vary, depending on selected parameters */
  ------------------
                    && bytesRead < LZ4F_HEADER_SIZE_MIN + LZ4F_ENDMARK_SIZE) {
  ------------------
  |  |  373|  19.0k|#define LZ4F_ENDMARK_SIZE 4
  ------------------
  |  Branch (150:10): [True: 1, False: 19.0k]
  ------------------
  151|      1|        RETURN_ERROR(io_read);
  ------------------
  |  |   74|      1|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  152|      1|    }
  153|       |
  154|       |    /* Determine buffer size based on block size */
  155|  19.3k|    { const size_t blockSize = LZ4F_getBlockSize(frameInfo.blockSizeID);
  156|  19.3k|      if (LZ4F_isError(blockSize)) {
  ------------------
  |  Branch (156:11): [True: 0, False: 19.3k]
  ------------------
  157|      0|          RETURN_ERROR(maxBlockSize_invalid);
  ------------------
  |  |   74|      0|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  158|      0|      }
  159|  19.3k|      readFile->srcBufMaxSize = blockSize;
  160|  19.3k|    }
  161|       |
  162|       |    /* Allocate source buffer */
  163|  19.3k|    assert(readFile->srcBuf == NULL); /* Should be NULL from creation */
  ------------------
  |  Branch (163:5): [True: 0, False: 19.3k]
  |  Branch (163:5): [True: 19.3k, False: 0]
  ------------------
  164|  19.3k|    readFile->srcBuf = (LZ4_byte*)fileMalloc(readFile->srcBufMaxSize, readFile->cmem);
  165|  19.3k|    if (readFile->srcBuf == NULL) {
  ------------------
  |  Branch (165:9): [True: 0, False: 19.3k]
  ------------------
  166|      0|        RETURN_ERROR(allocation_failed);
  ------------------
  |  |   74|      0|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  167|      0|    }
  168|       |
  169|       |    /* Store remaining header data in buffer */
  170|  19.3k|    readFile->srcBufPos = consumedSize;
  171|  19.3k|    readFile->srcBufSize = bytesRead - consumedSize;
  172|  19.3k|    if (readFile->srcBufSize > 0) {
  ------------------
  |  Branch (172:9): [True: 18.6k, False: 750]
  ------------------
  173|  18.6k|        memcpy(readFile->srcBuf, headerBuf + consumedSize, readFile->srcBufSize);
  174|  18.6k|    }
  175|  19.3k|    readFile->srcBufNext = 0;
  176|       |
  177|  19.3k|    return LZ4F_OK_NoError;
  178|  19.3k|}
lz4file.c:frameInProgress:
  256|   412k|{
  257|   412k|  return lz4fRead->hint != 0;
  258|   412k|}
lz4file.c:inputLimit:
  263|   402k|{
  264|   402k|  return frameInProgress(lz4fRead) ? lz4fRead->hint : LZ4F_HEADER_SIZE_MIN;
  ------------------
  |  |  360|  54.3k|#define LZ4F_HEADER_SIZE_MIN  7   /* LZ4 Frame header size can vary, depending on selected parameters */
  ------------------
  |  Branch (264:10): [True: 347k, False: 54.3k]
  ------------------
  265|   402k|}
lz4file.c:trackPosition:
  270|   159k|{
  271|   159k|  unsigned long long const cPos = lz4fRead->srcBufPos + lz4fRead->srcBufNext;
  272|   159k|  if (decStatus == 0) {   /* end of frame : next frame starts here */
  ------------------
  |  Branch (272:7): [True: 18.3k, False: 141k]
  ------------------
  273|  18.3k|    lz4fRead->hint = 0;
  274|  18.3k|    lz4fRead->frameDPos = lz4fRead->decodedPos;
  275|  18.3k|    addResumePoint(lz4fRead, cPos, NULL);
  276|  18.3k|    return;
  277|  18.3k|  }
  278|       |  /* exactly the hinted input was consumed, and next hint covers a block :
  279|       |   * decoding stopped right after a block header */
  280|   141k|  if (consumed == provided && provided == inputLimit(lz4fRead) && decStatus > LZ4F_BLOCK_HEADER_SIZE) {
  ------------------
  |  |  364|  96.7k|#define LZ4F_BLOCK_HEADER_SIZE 4
  ------------------
  |  Branch (280:7): [True: 119k, False: 22.2k]
  |  Branch (280:31): [True: 96.7k, False: 22.5k]
  |  Branch (280:67): [True: 67.8k, False: 28.9k]
  ------------------
  281|  67.8k|    LZ4F_frameInfo_t frameInfo;
  282|  67.8k|    size_t noInput = 0;
  283|       |    /* fails within a frame header, which isn't followed by a block header yet */
  284|  67.8k|    if (!LZ4F_isError(LZ4F_getFrameInfo(lz4fRead->dctxPtr, &frameInfo, NULL, &noInput))
  ------------------
  |  Branch (284:9): [True: 66.6k, False: 1.18k]
  ------------------
  285|  66.6k|      && frameInfo.frameType == LZ4F_frame
  ------------------
  |  Branch (285:10): [True: 66.2k, False: 365]
  ------------------
  286|  66.2k|      && frameInfo.blockMode == LZ4F_blockIndependent)
  ------------------
  |  Branch (286:10): [True: 17.8k, False: 48.4k]
  ------------------
  287|  17.8k|      addResumePoint(lz4fRead, cPos - LZ4F_BLOCK_HEADER_SIZE, &frameInfo);
  ------------------
  |  |  364|  17.8k|#define LZ4F_BLOCK_HEADER_SIZE 4
  ------------------
  288|  67.8k|  }
  289|   141k|  lz4fRead->hint = decStatus;
  290|   141k|}
lz4file.c:addResumePoint:
  232|  36.1k|{
  233|  36.1k|  unsigned long long const lastDPos = lz4fRead->nbPoints ? lz4fRead->points[lz4fRead->nbPoints-1].dPos : 0;
  ------------------
  |  Branch (233:39): [True: 10.1k, False: 26.0k]
  ------------------
  234|  36.1k|  LZ4F_resumePoint* p;
  235|  36.1k|  if (lz4fRead->decodedPos < lastDPos + LZ4F_RESUME_SPAN) return;
  ------------------
  |  |   83|  36.1k|#  define LZ4F_RESUME_SPAN 64           /* resume points within small fuzzing inputs */
  ------------------
  |  Branch (235:7): [True: 26.6k, False: 9.55k]
  ------------------
  236|  9.55k|  if (lz4fRead->nbPoints == lz4fRead->pointsCapacity) {
  ------------------
  |  Branch (236:7): [True: 7.50k, False: 2.05k]
  ------------------
  237|  7.50k|    size_t const newCapacity = lz4fRead->pointsCapacity ? 2 * lz4fRead->pointsCapacity : 64;
  ------------------
  |  Branch (237:32): [True: 0, False: 7.50k]
  ------------------
  238|  7.50k|    LZ4F_resumePoint* const newPoints = (LZ4F_resumePoint*)fileMalloc(newCapacity * sizeof(*newPoints), lz4fRead->cmem);   /* no realloc() among user functions */
  239|  7.50k|    if (newPoints == NULL) return;
  ------------------
  |  Branch (239:9): [True: 0, False: 7.50k]
  ------------------
  240|  7.50k|    if (lz4fRead->nbPoints) memcpy(newPoints, lz4fRead->points, lz4fRead->nbPoints * sizeof(*newPoints));
  ------------------
  |  Branch (240:9): [True: 0, False: 7.50k]
  ------------------
  241|  7.50k|    fileFree(lz4fRead->points, lz4fRead->cmem);
  242|  7.50k|    lz4fRead->points = newPoints;
  243|  7.50k|    lz4fRead->pointsCapacity = newCapacity;
  244|  7.50k|  }
  245|  9.55k|  p = lz4fRead->points + lz4fRead->nbPoints++;
  246|  9.55k|  memset(p, 0, sizeof(*p));
  247|  9.55k|  p->cPos = cPos;
  248|  9.55k|  p->dPos = lz4fRead->decodedPos;
  249|  9.55k|  p->frameDPos = lz4fRead->frameDPos;
  250|  9.55k|  p->isBlockStart = (frameInfo != NULL);
  251|  9.55k|  if (frameInfo != NULL) p->frameInfo = *frameInfo;
  ------------------
  |  Branch (251:7): [True: 2.60k, False: 6.94k]
  ------------------
  252|  9.55k|}
lz4file.c:findResumePoint:
  363|  26.6k|{
  364|  26.6k|  size_t lo = 0, hi = lz4fRead->nbPoints;
  365|  42.5k|  while (lo < hi) {   /* first point beyond @pos is within [lo, hi] */
  ------------------
  |  Branch (365:10): [True: 15.9k, False: 26.6k]
  ------------------
  366|  15.9k|    size_t const mid = lo + (hi - lo) / 2;
  367|  15.9k|    if (lz4fRead->points[mid].dPos <= pos) lo = mid + 1; else hi = mid;
  ------------------
  |  Branch (367:9): [True: 1.63k, False: 14.2k]
  ------------------
  368|  15.9k|  }
  369|  26.6k|  return lo ? lz4fRead->points + lo - 1 : NULL;
  ------------------
  |  Branch (369:10): [True: 1.52k, False: 25.0k]
  ------------------
  370|  26.6k|}
lz4file.c:restartFrom:
  374|  15.2k|{
  375|  15.2k|  unsigned long long const cPos = p ? p->cPos : 0;
  ------------------
  |  Branch (375:35): [True: 1.26k, False: 13.9k]
  ------------------
  376|  15.2k|  unsigned long long const filePos = lz4fRead->srcBufPos + lz4fRead->srcBufSize;
  377|  15.2k|  if (!lz4fRead->seekable || fseekRelative(lz4fRead->fp, (long long)cPos - (long long)filePos))
  ------------------
  |  Branch (377:7): [True: 0, False: 15.2k]
  |  Branch (377:30): [True: 0, False: 15.2k]
  ------------------
  378|      0|    RETURN_ERROR(io_read);
  ------------------
  |  |   74|      0|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  379|  15.2k|  lz4fRead->srcBufPos = cPos;
  380|  15.2k|  lz4fRead->srcBufSize = 0;
  381|  15.2k|  lz4fRead->srcBufNext = 0;
  382|  15.2k|  lz4fRead->decodedPos = p ? p->dPos : 0;
  ------------------
  |  Branch (382:26): [True: 1.26k, False: 13.9k]
  ------------------
  383|  15.2k|  if (p && p->isBlockStart) {
  ------------------
  |  Branch (383:7): [True: 1.26k, False: 13.9k]
  |  Branch (383:12): [True: 1.20k, False: 54]
  ------------------
  384|  1.20k|    size_t const result = LZ4F_resumeFrame(lz4fRead->dctxPtr, &p->frameInfo, p->dPos - p->frameDPos, NULL, 0);
  385|  1.20k|    if (LZ4F_isError(result)) return result;
  ------------------
  |  Branch (385:9): [True: 0, False: 1.20k]
  ------------------
  386|  1.20k|    lz4fRead->hint = LZ4F_BLOCK_HEADER_SIZE;
  ------------------
  |  |  364|  1.20k|#define LZ4F_BLOCK_HEADER_SIZE 4
  ------------------
  387|  1.20k|    lz4fRead->frameDPos = p->frameDPos;
  388|  14.0k|  } else {
  389|  14.0k|    LZ4F_resetDecompressionContext(lz4fRead->dctxPtr);
  390|  14.0k|    lz4fRead->hint = 0;
  391|  14.0k|    lz4fRead->frameDPos = lz4fRead->decodedPos;
  392|  14.0k|  }
  393|  15.2k|  lz4fRead->error = LZ4F_OK_NoError;
  394|  15.2k|  return LZ4F_OK_NoError;
  395|  15.2k|}
lz4file.c:fseekRelative:
  351|  15.2k|{
  352|  15.2k|  long const stepMax = 1L << 30;
  353|  30.4k|  while (delta != 0) {
  ------------------
  |  Branch (353:10): [True: 15.2k, False: 15.2k]
  ------------------
  354|  15.2k|    long const step = (delta > stepMax) ? stepMax : (delta < -stepMax) ? -stepMax : (long)delta;
  ------------------
  |  Branch (354:23): [True: 0, False: 15.2k]
  |  Branch (354:53): [True: 0, False: 15.2k]
  ------------------
  355|  15.2k|    if (fseek(fp, step, SEEK_CUR) != 0) return -1;
  ------------------
  |  Branch (355:9): [True: 0, False: 15.2k]
  ------------------
  356|  15.2k|    delta -= step;
  357|  15.2k|  }
  358|  15.2k|  return 0;
  359|  15.2k|}
lz4file.c:freeWriteFileResources:
  469|  15.6k|{
  470|  15.6k|  if (state == NULL) return;
  ------------------
  |  Branch (470:7): [True: 0, False: 15.6k]
  ------------------
  471|  15.6k|  LZ4F_freeCompressionContext(state->cctxPtr);
  472|  15.6k|  fileFree(state->dstBuf, state->cmem);
  473|  15.6k|  fileFree(state, state->cmem);
  474|  15.6k|}
lz4file.c:writeHeader:
  479|  15.6k|{
  480|  15.6k|  LZ4_byte headerBuf[LZ4F_HEADER_SIZE_MAX];
  481|       |
  482|       |  /* Generate header */
  483|  15.6k|  LZ4F_errorCode_t const headerSize = LZ4F_compressBegin(writeFile->cctxPtr,
  484|  15.6k|                                  headerBuf, LZ4F_HEADER_SIZE_MAX, prefsPtr);
  ------------------
  |  |  361|  15.6k|#define LZ4F_HEADER_SIZE_MAX 19
  ------------------
  485|  15.6k|  if (LZ4F_isError(headerSize)) {
  ------------------
  |  Branch (485:7): [True: 0, False: 15.6k]
  ------------------
  486|      0|    return headerSize;
  487|      0|  }
  488|       |
  489|       |  /* Write header to file */
  490|  15.6k|  if (headerSize != fwrite(headerBuf, 1, headerSize, fp)) {
  ------------------
  |  Branch (490:7): [True: 0, False: 15.6k]
  ------------------
  491|      0|    RETURN_ERROR(io_write);
  ------------------
  |  |   74|      0|#define RETURN_ERROR(e) return returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  492|      0|  }
  493|       |
  494|  15.6k|  return LZ4F_OK_NoError;
  495|  15.6k|}

LZ4F_isError:
  351|   952k|{
  352|   952k|    return (code > (LZ4F_errorCode_t)(-LZ4F_ERROR_maxCode));
  353|   952k|}
LZ4F_getBlockSize:
  412|   116k|{
  413|   116k|    static const size_t blockSizes[4] = { 64 KB, 256 KB, 1 MB, 4 MB };
  ------------------
  |  |  268|   116k|#  define KB *(1<<10)
  ------------------
                  static const size_t blockSizes[4] = { 64 KB, 256 KB, 1 MB, 4 MB };
  ------------------
  |  |  268|   116k|#  define KB *(1<<10)
  ------------------
                  static const size_t blockSizes[4] = { 64 KB, 256 KB, 1 MB, 4 MB };
  ------------------
  |  |  269|   116k|#  define MB *(1<<20)
  ------------------
                  static const size_t blockSizes[4] = { 64 KB, 256 KB, 1 MB, 4 MB };
  ------------------
  |  |  269|   116k|#  define MB *(1<<20)
  ------------------
  414|       |
  415|   116k|    if (blockSizeID == 0) blockSizeID = LZ4F_BLOCKSIZEID_DEFAULT;
  ------------------
  |  |  280|  17.6k|#define LZ4F_BLOCKSIZEID_DEFAULT LZ4F_max64KB
  ------------------
  |  Branch (415:9): [True: 17.6k, False: 98.8k]
  ------------------
  416|   116k|    if (blockSizeID < LZ4F_max64KB || blockSizeID > LZ4F_max4MB)
  ------------------
  |  Branch (416:9): [True: 0, False: 116k]
  |  Branch (416:39): [True: 0, False: 116k]
  ------------------
  417|      0|        RETURN_ERROR(maxBlockSize_invalid);
  ------------------
  |  |  375|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  418|   116k|    {   int const blockSizeIdx = (int)blockSizeID - (int)LZ4F_max64KB;
  419|   116k|        return blockSizes[blockSizeIdx];
  420|   116k|}   }
LZ4F_createCompressionContext_advanced:
  764|  15.6k|{
  765|  15.6k|    LZ4F_cctx* const cctxPtr =
  766|  15.6k|        (LZ4F_cctx*)LZ4F_calloc(sizeof(LZ4F_cctx), customMem);
  767|  15.6k|    if (cctxPtr==NULL) return NULL;
  ------------------
  |  Branch (767:9): [True: 0, False: 15.6k]
  ------------------
  768|       |
  769|  15.6k|    cctxPtr->cmem = customMem;
  770|  15.6k|    cctxPtr->version = version;
  771|  15.6k|    cctxPtr->cStage = 0;   /* Uninitialized. Next stage : init cctx */
  772|       |
  773|  15.6k|    return cctxPtr;
  774|  15.6k|}
LZ4F_freeCompressionContext:
  797|  15.6k|{
  798|  15.6k|    if (cctxPtr != NULL) {  /* support free on NULL */
  ------------------
  |  Branch (798:9): [True: 15.6k, False: 0]
  ------------------
  799|  15.6k|       LZ4F_mt_free(cctxPtr->mt, cctxPtr->cmem);   /* first : waits for jobs still in flight */
  800|  15.6k|       LZ4F_free(cctxPtr->lz4CtxPtr, cctxPtr->cmem);  /* note: LZ4_streamHC_t and LZ4_stream_t are simple POD types */
  801|  15.6k|       LZ4F_free(cctxPtr->tmpBuff, cctxPtr->cmem);
  802|  15.6k|       LZ4F_free(cctxPtr->stageBuff, cctxPtr->cmem);
  803|  15.6k|       LZ4F_free(cctxPtr->rawDictFast, cctxPtr->cmem);
  804|  15.6k|       LZ4F_free(cctxPtr->rawDictHC, cctxPtr->cmem);
  805|  15.6k|       LZ4F_free(cctxPtr, cctxPtr->cmem);
  806|  15.6k|    }
  807|  15.6k|    return LZ4F_OK_NoError;
  808|  15.6k|}
LZ4F_compressBegin:
 1096|  15.6k|{
 1097|  15.6k|    return LZ4F_compressBegin_internal(cctx, dstBuffer, dstCapacity,
 1098|  15.6k|                                        NULL, 0,
 1099|       |                                        NULL, preferencesPtr);
 1100|  15.6k|}
LZ4F_compressBound:
 1129|  15.6k|{
 1130|  15.6k|    size_t bound;
 1131|  15.6k|    size_t const blockCRCSize = preferencesPtr
  ------------------
  |  Branch (1131:33): [True: 15.6k, False: 0]
  ------------------
 1132|  15.6k|                             ? BFSize * preferencesPtr->frameInfo.blockChecksumFlag
 1133|  15.6k|                             : BFSize;
 1134|  15.6k|    if (preferencesPtr && !preferencesPtr->autoFlush && LZ4F_mtEligible(preferencesPtr)) {
  ------------------
  |  Branch (1134:9): [True: 15.6k, False: 0]
  |  Branch (1134:27): [True: 9.12k, False: 6.54k]
  |  Branch (1134:57): [True: 0, False: 9.12k]
  ------------------
 1135|       |        /* frame cut into jobs : output can lag behind input */
 1136|      0|        return LZ4F_mtCompressBound(srcSize, preferencesPtr);
 1137|      0|    }
 1138|  15.6k|    if (preferencesPtr && preferencesPtr->autoFlush) {
  ------------------
  |  Branch (1138:9): [True: 15.6k, False: 0]
  |  Branch (1138:27): [True: 6.54k, False: 9.12k]
  ------------------
 1139|       |        /* + 1 : output of LZ4F_flush() and LZ4F_compressEnd() remains strictly below LZ4F_compressBound(0),
 1140|       |         * since a filled dstBuffer means more output may remain */
 1141|  6.54k|        return LZ4F_compressBound_autoFlush(srcSize, preferencesPtr) + (srcSize == 0);
 1142|  6.54k|    }
 1143|       |    /* single-threaded : full blocks only, each one stored uncompressed in worst case.
 1144|       |     * Up to (blockSize-1) bytes can already be buffered : srcSize completes at most srcSize/blockSize + 1 blocks.
 1145|       |     * The buffered block can also be emitted separately (mode switch), or remain from an incomplete LZ4F_flush() :
 1146|       |     * then, srcSize completes at most srcSize/blockSize blocks.
 1147|       |     * @srcSize == 0 : LZ4F_flush() and LZ4F_compressEnd() emit the buffered block (< blockSize bytes : output
 1148|       |     * remains strictly below the bound, so that a single invocation completes them), then the frame footer.
 1149|       |     * The frame footer is always included, so that the bound grows with @srcSize. */
 1150|  9.12k|    {   size_t const bs = LZ4F_getBlockSize(preferencesPtr ? preferencesPtr->frameInfo.blockSizeID : LZ4F_default);
  ------------------
  |  Branch (1150:45): [True: 9.12k, False: 0]
  ------------------
 1151|  9.12k|        size_t const blockSize = LZ4F_isError(bs) ? 4 MB : bs;
  ------------------
  |  |  269|      0|#  define MB *(1<<20)
  ------------------
  |  Branch (1151:34): [True: 0, False: 9.12k]
  ------------------
 1152|  9.12k|        size_t const contentCRCSize = preferencesPtr
  ------------------
  |  Branch (1152:39): [True: 9.12k, False: 0]
  ------------------
 1153|  9.12k|                                    ? BFSize * preferencesPtr->frameInfo.contentChecksumFlag
 1154|  9.12k|                                    : BFSize;
 1155|  9.12k|        size_t const nbBlocks = srcSize / blockSize + 1;
 1156|  9.12k|        bound = nbBlocks * (blockSize + BHSize + blockCRCSize) + BHSize + contentCRCSize;
 1157|  9.12k|    }
 1158|  9.12k|    return bound;
 1159|  15.6k|}
LZ4F_compressUpdate:
 2542|  39.8k|{
 2543|  39.8k|    LZ4F_BlockCompressMode_e mode;
 2544|  39.8k|    if (compressOptionsPtr == NULL) compressOptionsPtr = &k_cOptionsNull;
  ------------------
  |  Branch (2544:9): [True: 39.8k, False: 0]
  ------------------
 2545|  39.8k|    mode = (compressOptionsPtr->uncompressed == 1) ? LZ4B_UNCOMPRESSED : LZ4B_COMPRESSED;
  ------------------
  |  Branch (2545:12): [True: 0, False: 39.8k]
  ------------------
 2546|  39.8k|    if (cctxPtr->mtActive)
  ------------------
  |  Branch (2546:9): [True: 0, False: 39.8k]
  ------------------
 2547|      0|        return LZ4F_mt_update(cctxPtr, dstBuffer, dstCapacity, srcBuffer, srcSize, compressOptionsPtr, mode);
 2548|  39.8k|    return LZ4F_st_update(cctxPtr, dstBuffer, dstCapacity, srcBuffer, srcSize, compressOptionsPtr, mode);
 2549|  39.8k|}
LZ4F_compressEnd:
 2659|  15.6k|{
 2660|  15.6k|    BYTE* const dst = (BYTE*)dstBuffer;
 2661|  15.6k|    size_t pos = 0;
 2662|  15.6k|    DEBUGLOG(5,"LZ4F_compressEnd: dstCapacity=%u", (unsigned)dstCapacity);
  ------------------
  |  |  191|  15.6k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 2663|  15.6k|    (void)compressOptionsPtr;   /* not useful (yet) */
 2664|  15.6k|    RETURN_ERROR_IF((cctxPtr->cStage != 1) && (cctxPtr->cStage != 2), compressionState_uninitialized);
  ------------------
  |  |  377|  15.6k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  378|  31.3k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (378:13): [True: 0, False: 15.6k]
  |  |  |  Branch (378:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  379|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  191|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  380|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  375|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  381|      0|        }                          \
  |  |  382|  15.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (382:14): [Folded, False: 15.6k]
  |  |  ------------------
  ------------------
 2665|  15.6k|    RETURN_ERROR_IF(dstCapacity == 0, dstCapacity_tooSmall);   /* no progress possible : rejected, the frame continues */
  ------------------
  |  |  377|  15.6k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  378|  15.6k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (378:13): [True: 0, False: 15.6k]
  |  |  ------------------
  |  |  379|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  191|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  380|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  375|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  381|      0|        }                          \
  |  |  382|  15.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (382:14): [Folded, False: 15.6k]
  |  |  ------------------
  ------------------
 2666|       |
 2667|  15.6k|    if (cctxPtr->cStage == 1) {
  ------------------
  |  Branch (2667:9): [True: 15.6k, False: 0]
  ------------------
 2668|       |        /* end of frame : no more input */
 2669|  15.6k|        if (cctxPtr->prefs.frameInfo.contentSize && (cctxPtr->prefs.frameInfo.contentSize != cctxPtr->totalInSize)) {
  ------------------
  |  Branch (2669:13): [True: 0, False: 15.6k]
  |  Branch (2669:53): [True: 0, False: 0]
  ------------------
 2670|      0|            LZ4F_invalidateFrame(cctxPtr);
 2671|      0|            RETURN_ERROR(frameSize_wrong);
  ------------------
  |  |  375|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
 2672|      0|        }
 2673|  15.6k|        cctxPtr->cStage = 2;
 2674|  15.6k|        if (cctxPtr->flushStage == 0) {
  ------------------
  |  Branch (2674:13): [True: 15.6k, False: 0]
  ------------------
 2675|  15.6k|            pos = LZ4F_flushPoint(cctxPtr, dst, dstCapacity);
 2676|  15.6k|            FORWARD_IF_ERROR(pos);   /* already invalidated */
  ------------------
  |  |  385|  15.6k|#define FORWARD_IF_ERROR(r) do {                     \
  |  |  386|  15.6k|        size_t const err_code = (r);                 \
  |  |  387|  15.6k|        if (LZ4F_isError(err_code)) return err_code; \
  |  |  ------------------
  |  |  |  Branch (387:13): [True: 0, False: 15.6k]
  |  |  ------------------
  |  |  388|  15.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (388:14): [Folded, False: 15.6k]
  |  |  ------------------
  ------------------
 2677|  15.6k|    }   }
 2678|       |
 2679|  15.6k|    if (cctxPtr->flushStage == 1) {
  ------------------
  |  Branch (2679:9): [True: 15.6k, False: 0]
  ------------------
 2680|  15.6k|        pos = LZ4F_emitPending(cctxPtr, dst, dstCapacity, pos);
 2681|  15.6k|        FORWARD_IF_ERROR(pos);   /* already invalidated */
  ------------------
  |  |  385|  15.6k|#define FORWARD_IF_ERROR(r) do {                     \
  |  |  386|  15.6k|        size_t const err_code = (r);                 \
  |  |  387|  15.6k|        if (LZ4F_isError(err_code)) return err_code; \
  |  |  ------------------
  |  |  |  Branch (387:13): [True: 0, False: 15.6k]
  |  |  ------------------
  |  |  388|  15.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (388:14): [Folded, False: 15.6k]
  |  |  ------------------
  ------------------
 2682|  15.6k|        if (LZ4F_outputPending(cctxPtr)) return pos;   /* dstBuffer is full */
  ------------------
  |  Branch (2682:13): [True: 0, False: 15.6k]
  ------------------
 2683|       |        /* footer : endMark, then optional content checksum */
 2684|  15.6k|        LZ4F_writeLE32(cctxPtr->footer, 0);
 2685|  15.6k|        cctxPtr->pendingSize = 4;
 2686|  15.6k|        if (cctxPtr->prefs.frameInfo.contentChecksumFlag == LZ4F_contentChecksumEnabled) {
  ------------------
  |  Branch (2686:13): [True: 6.36k, False: 9.31k]
  ------------------
 2687|  6.36k|            U32 const xxh = XXH32_digest(&(cctxPtr->xxh));
  ------------------
  |  |  133|  6.36k|#  define XXH32_digest XXH_NAME2(XXH_NAMESPACE, XXH32_digest)
  |  |  ------------------
  |  |  |  |  126|  6.36k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  6.36k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2688|  6.36k|            DEBUGLOG(5,"Writing 32-bit content checksum (0x%0X)", xxh);
  ------------------
  |  |  191|  6.36k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 2689|  6.36k|            LZ4F_writeLE32(cctxPtr->footer + 4, xxh);
 2690|  6.36k|            cctxPtr->pendingSize = 8;
 2691|  6.36k|        }
 2692|  15.6k|        cctxPtr->pending = cctxPtr->footer;
 2693|  15.6k|        cctxPtr->flushStage = 2;
 2694|  15.6k|    }
 2695|       |
 2696|  15.6k|    if (cctxPtr->flushStage == 2) {
  ------------------
  |  Branch (2696:9): [True: 15.6k, False: 0]
  ------------------
 2697|  15.6k|        pos += LZ4F_copyPending(cctxPtr, dst, dstCapacity, pos);
 2698|  15.6k|        if (cctxPtr->pendingSize) return pos;   /* dstBuffer is full */
  ------------------
  |  Branch (2698:13): [True: 0, False: 15.6k]
  ------------------
 2699|  15.6k|        cctxPtr->flushStage = 3;
 2700|  15.6k|    }
 2701|       |
 2702|  15.6k|    assert(cctxPtr->flushStage == 3);
  ------------------
  |  Branch (2702:5): [True: 0, False: 15.6k]
  |  Branch (2702:5): [True: 15.6k, False: 0]
  ------------------
 2703|  15.6k|    if (pos < dstCapacity) {
  ------------------
  |  Branch (2703:9): [True: 15.6k, False: 0]
  ------------------
 2704|       |        /* completed : the context is available for a new frame */
 2705|  15.6k|        cctxPtr->cStage = 0;
 2706|  15.6k|        cctxPtr->flushStage = 0;
 2707|  15.6k|    }   /* otherwise, completed, but dstBuffer is full : next invocation returns 0 */
 2708|  15.6k|    return pos;
 2709|  15.6k|}
LZ4F_createDecompressionContext_advanced:
 2755|  31.3k|{
 2756|  31.3k|    LZ4F_dctx* const dctx = (LZ4F_dctx*)LZ4F_calloc(sizeof(LZ4F_dctx), customMem);
 2757|  31.3k|    if (dctx == NULL) return NULL;
  ------------------
  |  Branch (2757:9): [True: 0, False: 31.3k]
  ------------------
 2758|       |
 2759|  31.3k|    dctx->cmem = customMem;
 2760|  31.3k|    dctx->version = version;
 2761|  31.3k|    return dctx;
 2762|  31.3k|}
LZ4F_freeDecompressionContext:
 2784|  31.3k|{
 2785|  31.3k|    LZ4F_errorCode_t result = LZ4F_OK_NoError;
 2786|  31.3k|    if (dctx != NULL) {   /* can accept NULL input, like free() */
  ------------------
  |  Branch (2786:9): [True: 31.3k, False: 0]
  ------------------
 2787|  31.3k|      result = (LZ4F_errorCode_t)dctx->dStage;
 2788|  31.3k|      LZ4F_free(dctx->tmpIn, dctx->cmem);
 2789|  31.3k|      LZ4F_free(dctx->tmpOutBuffer, dctx->cmem);
 2790|  31.3k|      LZ4F_free(dctx, dctx->cmem);
 2791|  31.3k|    }
 2792|  31.3k|    return result;
 2793|  31.3k|}
LZ4F_resetDecompressionContext:
 2805|  33.5k|{
 2806|  33.5k|    DEBUGLOG(5, "LZ4F_resetDecompressionContext");
  ------------------
  |  |  191|  33.5k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 2807|  33.5k|    dctx->dStage = dstage_getFrameHeader;
 2808|       |    dctx->dict = NULL;
 2809|  33.5k|    dctx->dictSize = 0;
 2810|  33.5k|    dctx->skipBlockChecksum = 0;
 2811|  33.5k|    dctx->skipContentChecksum = 0;
 2812|  33.5k|    dctx->frameRemainingSize = 0;
 2813|  33.5k|}
LZ4F_headerSize:
 2921|  31.0k|{
 2922|  31.0k|    RETURN_ERROR_IF(src == NULL, srcPtr_wrong);
  ------------------
  |  |  377|  31.0k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  378|  31.0k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (378:13): [True: 0, False: 31.0k]
  |  |  ------------------
  |  |  379|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  191|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  380|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  375|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  381|      0|        }                          \
  |  |  382|  31.0k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (382:14): [Folded, False: 31.0k]
  |  |  ------------------
  ------------------
 2923|       |
 2924|       |    /* minimal srcSize to determine header size */
 2925|  31.0k|    if (srcSize < LZ4F_MIN_SIZE_TO_KNOW_HEADER_LENGTH)
  ------------------
  |  |  510|  31.0k|#define LZ4F_MIN_SIZE_TO_KNOW_HEADER_LENGTH 5
  ------------------
  |  Branch (2925:9): [True: 0, False: 31.0k]
  ------------------
 2926|      0|        RETURN_ERROR(frameHeader_incomplete);
  ------------------
  |  |  375|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
 2927|       |
 2928|       |    /* special case : skippable frames */
 2929|  31.0k|    if ((LZ4F_readLE32(src) & 0xFFFFFFF0U) == LZ4F_MAGIC_SKIPPABLE_START)
  ------------------
  |  |  509|  31.0k|#define LZ4F_MAGIC_SKIPPABLE_START 0x184D2A50U
  ------------------
  |  Branch (2929:9): [True: 342, False: 30.7k]
  ------------------
 2930|    342|        return 8;
 2931|       |
 2932|       |    /* control magic number */
 2933|       |#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
 2934|       |    if (LZ4F_readLE32(src) != LZ4F_MAGICNUMBER)
 2935|       |        RETURN_ERROR(frameType_unknown);
 2936|       |#endif
 2937|       |
 2938|       |    /* Frame Header Size */
 2939|  30.7k|    {   BYTE const FLG = ((const BYTE*)src)[4];
 2940|  30.7k|        U32 const contentSizeFlag = (FLG>>3) & _1BIT;
  ------------------
  |  |  273|  30.7k|#define _1BIT  0x01
  ------------------
 2941|  30.7k|        U32 const dictIDFlag = FLG & _1BIT;
  ------------------
  |  |  273|  30.7k|#define _1BIT  0x01
  ------------------
 2942|  30.7k|        return minFHSize + (contentSizeFlag?8:0) + (dictIDFlag?4:0);
  ------------------
  |  Branch (2942:29): [True: 4.32k, False: 26.4k]
  |  Branch (2942:53): [True: 3.82k, False: 26.9k]
  ------------------
 2943|  31.0k|    }
 2944|  31.0k|}
LZ4F_getFrameInfo:
 2964|  98.9k|{
 2965|  98.9k|    assert(dctx != NULL);
  ------------------
  |  Branch (2965:5): [True: 0, False: 98.9k]
  |  Branch (2965:5): [True: 98.9k, False: 0]
  ------------------
 2966|  98.9k|    RETURN_ERROR_IF(frameInfoPtr == NULL, parameter_null);
  ------------------
  |  |  377|  98.9k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  378|  98.9k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (378:13): [True: 0, False: 98.9k]
  |  |  ------------------
  |  |  379|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  191|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  380|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  375|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  381|      0|        }                          \
  |  |  382|  98.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (382:14): [Folded, False: 98.9k]
  |  |  ------------------
  ------------------
 2967|  98.9k|    RETURN_ERROR_IF(srcSizePtr == NULL, parameter_null);
  ------------------
  |  |  377|  98.9k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  378|  98.9k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (378:13): [True: 0, False: 98.9k]
  |  |  ------------------
  |  |  379|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  191|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  380|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  375|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  381|      0|        }                          \
  |  |  382|  98.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (382:14): [Folded, False: 98.9k]
  |  |  ------------------
  ------------------
 2968|       |
 2969|  98.9k|    LZ4F_STATIC_ASSERT(dstage_getFrameHeader < dstage_storeFrameHeader);
  ------------------
  |  |  178|  98.9k|#define LZ4F_STATIC_ASSERT(c)    { enum { LZ4F_static_assert = 1/(int)(!!(c)) }; }   /* use only *after* variable declarations */
  ------------------
 2970|  98.9k|    if (dctx->dStage > dstage_storeFrameHeader) {
  ------------------
  |  Branch (2970:9): [True: 66.6k, False: 32.2k]
  ------------------
 2971|       |        /* frameInfo already decoded */
 2972|  66.6k|        size_t o=0, i=0;
 2973|  66.6k|        *srcSizePtr = 0;
 2974|  66.6k|        *frameInfoPtr = dctx->frameInfo;
 2975|       |        /* returns : recommended nb of bytes for LZ4F_decompress() */
 2976|  66.6k|        return LZ4F_decompress(dctx, NULL, &o, NULL, &i, NULL);
 2977|  66.6k|    } else {
 2978|  32.2k|        if (dctx->dStage == dstage_storeFrameHeader) {
  ------------------
  |  Branch (2978:13): [True: 1.18k, False: 31.0k]
  ------------------
 2979|       |            /* frame decoding already started, in the middle of header => automatic fail */
 2980|  1.18k|            *srcSizePtr = 0;
 2981|  1.18k|            RETURN_ERROR(frameDecoding_alreadyStarted);
  ------------------
  |  |  375|  1.18k|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
 2982|  31.0k|        } else {
 2983|  31.0k|            size_t const hSize = LZ4F_headerSize(srcBuffer, *srcSizePtr);
 2984|  31.0k|            if (LZ4F_isError(hSize)) { *srcSizePtr=0; return hSize; }
  ------------------
  |  Branch (2984:17): [True: 0, False: 31.0k]
  ------------------
 2985|  31.0k|            if (*srcSizePtr < hSize) {
  ------------------
  |  Branch (2985:17): [True: 314, False: 30.7k]
  ------------------
 2986|    314|                *srcSizePtr=0;
 2987|    314|                RETURN_ERROR(frameHeader_incomplete);
  ------------------
  |  |  375|    314|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
 2988|    314|            }
 2989|       |
 2990|  30.7k|            {   size_t decodeResult = LZ4F_decodeHeader(dctx, srcBuffer, hSize);
 2991|  30.7k|                if (LZ4F_isError(decodeResult)) {
  ------------------
  |  Branch (2991:21): [True: 11.3k, False: 19.3k]
  ------------------
 2992|  11.3k|                    *srcSizePtr = 0;
 2993|  19.3k|                } else {
 2994|  19.3k|                    *srcSizePtr = decodeResult;
 2995|  19.3k|                    decodeResult = BHSize;   /* block header size */
 2996|  19.3k|                }
 2997|  30.7k|                *frameInfoPtr = dctx->frameInfo;
 2998|  30.7k|                return decodeResult;
 2999|  31.0k|    }   }   }
 3000|  98.9k|}
LZ4F_decompress:
 3175|   230k|{
 3176|   230k|    static const BYTE emptySrc = 0;   /* NULL srcBuffer (no input, used by LZ4F_getFrameInfo()) points here instead :
 3177|       |                                       * NULL+0 and memcpy(dst, NULL, 0) are UB */
 3178|   230k|    LZ4F_decompressOptions_t optionsNull;
 3179|   230k|    const BYTE* const srcStart = srcBuffer ? (const BYTE*)srcBuffer : &emptySrc;
  ------------------
  |  Branch (3179:34): [True: 163k, False: 66.6k]
  ------------------
 3180|   230k|    const BYTE* const srcEnd = srcBuffer ? srcStart + *srcSizePtr : srcStart;
  ------------------
  |  Branch (3180:32): [True: 163k, False: 66.6k]
  ------------------
 3181|   230k|    const BYTE* srcPtr = srcStart;
 3182|   230k|    BYTE* const dstStart = (BYTE*)dstBuffer;
 3183|   230k|    BYTE* const dstEnd = dstStart ? dstStart + *dstSizePtr : NULL;
  ------------------
  |  Branch (3183:26): [True: 163k, False: 66.6k]
  ------------------
 3184|   230k|    BYTE* dstPtr = dstStart;
 3185|   230k|    const BYTE* selectedIn = NULL;
 3186|   230k|    unsigned doAnotherStage = 1;
 3187|   230k|    size_t nextSrcSizeHint = 1;
 3188|       |
 3189|       |
 3190|   230k|    DEBUGLOG(5, "LZ4F_decompress: src[%p](%u) => dst[%p](%u)",
  ------------------
  |  |  191|   230k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 3191|   230k|            srcBuffer, (unsigned)*srcSizePtr, dstBuffer, (unsigned)*dstSizePtr);
 3192|   230k|    if (dstBuffer == NULL) assert(*dstSizePtr == 0);
  ------------------
  |  Branch (3192:9): [True: 66.6k, False: 163k]
  |  Branch (3192:28): [True: 0, False: 66.6k]
  |  Branch (3192:28): [True: 66.6k, False: 0]
  ------------------
 3193|   230k|    if (srcBuffer == NULL) assert(*srcSizePtr == 0);
  ------------------
  |  Branch (3193:9): [True: 66.6k, False: 163k]
  |  Branch (3193:28): [True: 0, False: 66.6k]
  |  Branch (3193:28): [True: 66.6k, False: 0]
  ------------------
 3194|   230k|    MEM_INIT(&optionsNull, 0, sizeof(optionsNull));
  ------------------
  |  |  109|   230k|#  define MEM_INIT(p,v,s)   memset((p),(v),(s))
  ------------------
 3195|   230k|    if (decompressOptionsPtr==NULL) decompressOptionsPtr = &optionsNull;
  ------------------
  |  Branch (3195:9): [True: 230k, False: 0]
  ------------------
 3196|   230k|    *srcSizePtr = 0;
 3197|   230k|    *dstSizePtr = 0;
 3198|   230k|    assert(dctx != NULL);
  ------------------
  |  Branch (3198:5): [True: 0, False: 230k]
  |  Branch (3198:5): [True: 230k, False: 0]
  ------------------
 3199|   230k|    if (decompressOptionsPtr->skipChecksums) {   /* once set, disable for the remainder of the frame */
  ------------------
  |  Branch (3199:9): [True: 0, False: 230k]
  ------------------
 3200|      0|        dctx->skipBlockChecksum = 1;
 3201|      0|        dctx->skipContentChecksum = 1;
 3202|      0|    }
 3203|       |
 3204|       |    /* behaves as a state machine */
 3205|       |
 3206|   571k|    while (doAnotherStage) {
  ------------------
  |  Branch (3206:12): [True: 345k, False: 226k]
  ------------------
 3207|       |
 3208|   345k|        switch(dctx->dStage)
  ------------------
  |  Branch (3208:16): [True: 345k, False: 0]
  ------------------
 3209|   345k|        {
 3210|       |
 3211|  18.2k|        case dstage_getFrameHeader:
  ------------------
  |  Branch (3211:9): [True: 18.2k, False: 326k]
  ------------------
 3212|  18.2k|            DEBUGLOG(6, "dstage_getFrameHeader");
  ------------------
  |  |  191|  18.2k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 3213|  18.2k|            if ((size_t)(srcEnd-srcPtr) >= maxFHSize) {  /* enough to decode - shortcut */
  ------------------
  |  Branch (3213:17): [True: 0, False: 18.2k]
  ------------------
 3214|      0|                size_t const hSize = LZ4F_decodeHeader(dctx, srcPtr, (size_t)(srcEnd-srcPtr));  /* will update dStage appropriately */
 3215|      0|                if (LZ4F_isError(hSize)) { nextSrcSizeHint = hSize; goto _output; }
  ------------------
  |  Branch (3215:21): [True: 0, False: 0]
  ------------------
 3216|      0|                srcPtr += hSize;
 3217|      0|                break;
 3218|      0|            }
 3219|  18.2k|            dctx->tmpInSize = 0;
 3220|  18.2k|            if (srcEnd-srcPtr == 0) return minFHSize;   /* 0-size input */
  ------------------
  |  Branch (3220:17): [True: 0, False: 18.2k]
  ------------------
 3221|  18.2k|            dctx->tmpInTarget = minFHSize;   /* minimum size to decode header */
 3222|  18.2k|            dctx->dStage = dstage_storeFrameHeader;
 3223|       |            /* fall-through */
 3224|       |
 3225|  20.8k|        case dstage_storeFrameHeader:
  ------------------
  |  Branch (3225:9): [True: 2.54k, False: 342k]
  ------------------
 3226|  20.8k|            DEBUGLOG(6, "dstage_storeFrameHeader");
  ------------------
  |  |  191|  20.8k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 3227|  20.8k|            {   size_t const sizeToCopy = MIN(dctx->tmpInTarget - dctx->tmpInSize, (size_t)(srcEnd - srcPtr));
  ------------------
  |  |  426|  20.8k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (426:22): [True: 1.29k, False: 19.5k]
  |  |  ------------------
  ------------------
 3228|  20.8k|                memcpy(dctx->header + dctx->tmpInSize, srcPtr, sizeToCopy);
 3229|  20.8k|                dctx->tmpInSize += sizeToCopy;
 3230|  20.8k|                srcPtr += sizeToCopy;
 3231|  20.8k|            }
 3232|  20.8k|            if (dctx->tmpInSize < dctx->tmpInTarget) {
  ------------------
  |  Branch (3232:17): [True: 1.44k, False: 19.3k]
  ------------------
 3233|  1.44k|                nextSrcSizeHint = (dctx->tmpInTarget - dctx->tmpInSize) + BHSize;   /* rest of header + nextBlockHeader */
 3234|  1.44k|                doAnotherStage = 0;   /* not enough src data, ask for some more */
 3235|  1.44k|                break;
 3236|  1.44k|            }
 3237|  19.3k|            {   size_t const hSize = LZ4F_decodeHeader(dctx, dctx->header, dctx->tmpInTarget); /* will update dStage appropriately */
 3238|  19.3k|                if (LZ4F_isError(hSize)) { nextSrcSizeHint = hSize; goto _output; }
  ------------------
  |  Branch (3238:21): [True: 243, False: 19.1k]
  ------------------
 3239|  19.3k|            }
 3240|  19.1k|            break;
 3241|       |
 3242|  33.9k|        case dstage_init:
  ------------------
  |  Branch (3242:9): [True: 33.9k, False: 311k]
  ------------------
 3243|  33.9k|            DEBUGLOG(6, "dstage_init");
  ------------------
  |  |  191|  33.9k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 3244|  33.9k|            if (dctx->frameInfo.contentChecksumFlag) (void)XXH32_reset(&(dctx->xxh), 0);
  ------------------
  |  |  131|  13.9k|#  define XXH32_reset XXH_NAME2(XXH_NAMESPACE, XXH32_reset)
  |  |  ------------------
  |  |  |  |  126|  13.9k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  13.9k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (3244:17): [True: 13.9k, False: 19.9k]
  ------------------
 3245|       |            /* internal buffers allocation */
 3246|  33.9k|            {   size_t const tmpInNeeded = dctx->maxBlockSize + BFSize /* block checksum */;
 3247|  33.9k|                size_t const tmpOutNeeded = dctx->maxBlockSize
 3248|  33.9k|                    + ((dctx->frameInfo.blockMode==LZ4F_blockLinked) ? 128 KB : 0);
  ------------------
  |  |  268|  22.7k|#  define KB *(1<<10)
  ------------------
  |  Branch (3248:24): [True: 22.7k, False: 11.1k]
  ------------------
 3249|  33.9k|                if ( (tmpInNeeded > dctx->tmpInCapacity)
  ------------------
  |  Branch (3249:22): [True: 18.7k, False: 15.2k]
  ------------------
 3250|  18.7k|                  || (tmpOutNeeded > dctx->tmpOutBufferCapacity) ) {   /* tmp buffers too small */
  ------------------
  |  Branch (3250:22): [True: 9, False: 15.2k]
  ------------------
 3251|       |                    /* capacities remain 0 until allocation succeeds,
 3252|       |                     * so that allocation will be re-attempted on next entry */
 3253|  18.7k|                    LZ4F_free(dctx->tmpIn, dctx->cmem);
 3254|  18.7k|                    dctx->tmpInCapacity = 0;
 3255|  18.7k|                    dctx->tmpIn = (BYTE*)LZ4F_malloc(tmpInNeeded, dctx->cmem);
 3256|  18.7k|                    if (dctx->tmpIn == NULL) {
  ------------------
  |  Branch (3256:25): [True: 0, False: 18.7k]
  ------------------
 3257|      0|                        nextSrcSizeHint = LZ4F_returnErrorCode(LZ4F_ERROR_allocation_failed);
 3258|      0|                        goto _output;
 3259|      0|                    }
 3260|  18.7k|                    dctx->tmpInCapacity = tmpInNeeded;
 3261|  18.7k|                    LZ4F_free(dctx->tmpOutBuffer, dctx->cmem);
 3262|  18.7k|                    dctx->tmpOutBufferCapacity = 0;
 3263|  18.7k|                    dctx->tmpOutBuffer= (BYTE*)LZ4F_malloc(tmpOutNeeded, dctx->cmem);
 3264|  18.7k|                    if (dctx->tmpOutBuffer== NULL) {
  ------------------
  |  Branch (3264:25): [True: 0, False: 18.7k]
  ------------------
 3265|      0|                        nextSrcSizeHint = LZ4F_returnErrorCode(LZ4F_ERROR_allocation_failed);
 3266|      0|                        goto _output;
 3267|      0|                    }
 3268|  18.7k|                    dctx->tmpOutBufferCapacity = tmpOutNeeded;
 3269|  18.7k|            }   }
 3270|  33.9k|            dctx->tmpInSize = 0;
 3271|  33.9k|            dctx->tmpInTarget = 0;
 3272|  33.9k|            dctx->tmpOut = dctx->tmpOutBuffer;
 3273|  33.9k|            dctx->tmpOutStart = 0;
 3274|  33.9k|            dctx->tmpOutSize = 0;
 3275|       |
 3276|  33.9k|            dctx->dStage = dstage_getBlockHeader;
 3277|       |            /* fall-through */
 3278|       |
 3279|   100k|        case dstage_getBlockHeader:
  ------------------
  |  Branch (3279:9): [True: 66.9k, False: 278k]
  ------------------
 3280|   100k|            selectedIn = LZ4F_gatherInput(dctx, dctx->tmpIn, BHSize, &srcPtr, srcEnd);
 3281|   100k|            if (selectedIn == NULL) {   /* not enough input for cBlockSize */
  ------------------
  |  Branch (3281:17): [True: 14.0k, False: 86.8k]
  ------------------
 3282|  14.0k|                nextSrcSizeHint = BHSize - dctx->tmpInSize;
 3283|  14.0k|                doAnotherStage = 0;
 3284|  14.0k|                break;
 3285|  14.0k|            }
 3286|       |
 3287|       |            /* decode block header */
 3288|  86.8k|            {   U32 const blockHeader = LZ4F_readLE32(selectedIn);
 3289|  86.8k|                size_t const nextCBlockSize = blockHeader & 0x7FFFFFFFU;
 3290|  86.8k|                size_t const crcSize = dctx->frameInfo.blockChecksumFlag * BFSize;
 3291|  86.8k|                if (blockHeader==0) {  /* frameEnd signal, no more block */
  ------------------
  |  Branch (3291:21): [True: 19.5k, False: 67.3k]
  ------------------
 3292|  19.5k|                    DEBUGLOG(5, "end of frame");
  ------------------
  |  |  191|  19.5k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 3293|  19.5k|                    dctx->dStage = dstage_getSuffix;
 3294|  19.5k|                    break;
 3295|  19.5k|                }
 3296|  67.3k|                if (nextCBlockSize > dctx->maxBlockSize) {
  ------------------
  |  Branch (3296:21): [True: 669, False: 66.6k]
  ------------------
 3297|    669|                    nextSrcSizeHint = LZ4F_returnErrorCode(LZ4F_ERROR_maxBlockSize_invalid);
 3298|    669|                    goto _output;
 3299|    669|                }
 3300|  66.6k|                if (blockHeader & LZ4F_BLOCKUNCOMPRESSED_FLAG) {
  ------------------
  |  |  279|  66.6k|#define LZ4F_BLOCKUNCOMPRESSED_FLAG 0x80000000U
  ------------------
  |  Branch (3300:21): [True: 14.2k, False: 52.4k]
  ------------------
 3301|       |                    /* next block is uncompressed */
 3302|  14.2k|                    if (dctx->frameInfo.contentSize && nextCBlockSize > dctx->frameRemainingSize) {
  ------------------
  |  Branch (3302:25): [True: 869, False: 13.3k]
  |  Branch (3302:56): [True: 33, False: 836]
  ------------------
 3303|     33|                        nextSrcSizeHint = LZ4F_returnErrorCode(LZ4F_ERROR_frameSize_wrong);
 3304|     33|                        goto _output;
 3305|     33|                    }
 3306|  14.2k|                    dctx->tmpInTarget = nextCBlockSize;
 3307|  14.2k|                    DEBUGLOG(5, "next block is uncompressed (size %u)", (U32)nextCBlockSize);
  ------------------
  |  |  191|  14.2k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 3308|  14.2k|                    if (dctx->frameInfo.blockChecksumFlag) {
  ------------------
  |  Branch (3308:25): [True: 5.20k, False: 9.00k]
  ------------------
 3309|  5.20k|                        (void)XXH32_reset(&dctx->blockChecksum, 0);
  ------------------
  |  |  131|  5.20k|#  define XXH32_reset XXH_NAME2(XXH_NAMESPACE, XXH32_reset)
  |  |  ------------------
  |  |  |  |  126|  5.20k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  5.20k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3310|  5.20k|                    }
 3311|  14.2k|                    dctx->dStage = dstage_copyDirect;
 3312|  14.2k|                    break;
 3313|  14.2k|                }
 3314|       |                /* next block is a compressed block */
 3315|  52.4k|                dctx->tmpInTarget = nextCBlockSize + crcSize;
 3316|  52.4k|                dctx->dStage = dstage_getCBlock;
 3317|  52.4k|                if (dstPtr==dstEnd || srcPtr==srcEnd) {
  ------------------
  |  Branch (3317:21): [True: 2.96k, False: 49.4k]
  |  Branch (3317:39): [True: 49.4k, False: 0]
  ------------------
 3318|  52.4k|                    nextSrcSizeHint = BHSize + nextCBlockSize + crcSize;
 3319|  52.4k|                    doAnotherStage = 0;
 3320|  52.4k|                }
 3321|  52.4k|                break;
 3322|  66.6k|            }
 3323|       |
 3324|  49.0k|        case dstage_copyDirect:   /* uncompressed block */
  ------------------
  |  Branch (3324:9): [True: 49.0k, False: 296k]
  ------------------
 3325|  49.0k|            DEBUGLOG(6, "dstage_copyDirect");
  ------------------
  |  |  191|  49.0k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 3326|  49.0k|            {   size_t sizeToCopy;
 3327|  49.0k|                if (dstPtr == NULL) {
  ------------------
  |  Branch (3327:21): [True: 13.7k, False: 35.3k]
  ------------------
 3328|  13.7k|                    sizeToCopy = 0;
 3329|  35.3k|                } else {
 3330|  35.3k|                    size_t const minBuffSize = MIN((size_t)(srcEnd-srcPtr), (size_t)(dstEnd-dstPtr));
  ------------------
  |  |  426|  35.3k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (426:22): [True: 26.3k, False: 8.94k]
  |  |  ------------------
  ------------------
 3331|  35.3k|                    sizeToCopy = MIN(dctx->tmpInTarget, minBuffSize);
  ------------------
  |  |  426|  35.3k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (426:22): [True: 7.28k, False: 28.0k]
  |  |  ------------------
  ------------------
 3332|  35.3k|                    memcpy(dstPtr, srcPtr, sizeToCopy);
 3333|  35.3k|                    if (dctx->frameInfo.blockChecksumFlag && !dctx->skipBlockChecksum)
  ------------------
  |  Branch (3333:25): [True: 13.3k, False: 22.0k]
  |  Branch (3333:62): [True: 13.3k, False: 0]
  ------------------
 3334|  13.3k|                        (void)XXH32_update(&dctx->blockChecksum, srcPtr, sizeToCopy);
  ------------------
  |  |  132|  13.3k|#  define XXH32_update XXH_NAME2(XXH_NAMESPACE, XXH32_update)
  |  |  ------------------
  |  |  |  |  126|  13.3k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  13.3k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3335|  35.3k|                    if (dctx->frameInfo.contentChecksumFlag && !dctx->skipContentChecksum)
  ------------------
  |  Branch (3335:25): [True: 15.1k, False: 20.2k]
  |  Branch (3335:64): [True: 14.8k, False: 238]
  ------------------
 3336|  14.8k|                        (void)XXH32_update(&dctx->xxh, srcPtr, sizeToCopy);
  ------------------
  |  |  132|  14.8k|#  define XXH32_update XXH_NAME2(XXH_NAMESPACE, XXH32_update)
  |  |  ------------------
  |  |  |  |  126|  14.8k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  14.8k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3337|  35.3k|                    if (dctx->frameInfo.contentSize)
  ------------------
  |  Branch (3337:25): [True: 1.60k, False: 33.7k]
  ------------------
 3338|  1.60k|                        dctx->frameRemainingSize -= sizeToCopy;
 3339|       |
 3340|       |                    /* history management (linked blocks only), unless the frame ends with this block */
 3341|  35.3k|                    if ( (dctx->frameInfo.blockMode == LZ4F_blockLinked)
  ------------------
  |  Branch (3341:26): [True: 25.1k, False: 10.1k]
  ------------------
 3342|  25.1k|                      && !( (sizeToCopy == dctx->tmpInTarget)
  ------------------
  |  Branch (3342:29): [True: 8.89k, False: 16.2k]
  ------------------
 3343|  22.5k|                         && LZ4F_endMarkFollows(srcPtr + sizeToCopy, srcEnd, dctx->frameInfo.blockChecksumFlag * BFSize) ) ) {
  ------------------
  |  Branch (3343:29): [True: 2.67k, False: 6.22k]
  ------------------
 3344|  22.5k|                        LZ4F_updateDict(dctx, dstPtr, sizeToCopy, dstStart, 0);
 3345|  22.5k|                    }
 3346|  35.3k|                    srcPtr += sizeToCopy;
 3347|  35.3k|                    dstPtr += sizeToCopy;
 3348|  35.3k|                }
 3349|  49.0k|                if (sizeToCopy == dctx->tmpInTarget) {   /* all done */
  ------------------
  |  Branch (3349:21): [True: 12.3k, False: 36.7k]
  ------------------
 3350|  12.3k|                    if (dctx->frameInfo.blockChecksumFlag)
  ------------------
  |  Branch (3350:25): [True: 4.44k, False: 7.93k]
  ------------------
 3351|  4.44k|                        dctx->dStage = dstage_getBlockChecksum;
 3352|  7.93k|                    else
 3353|  7.93k|                        dctx->dStage = dstage_getBlockHeader;  /* new block */
 3354|  12.3k|                    break;
 3355|  12.3k|                }
 3356|  36.7k|                dctx->tmpInTarget -= sizeToCopy;  /* need to copy more */
 3357|  36.7k|            }
 3358|      0|            nextSrcSizeHint = dctx->tmpInTarget
 3359|  36.7k|                            + (dctx->frameInfo.blockChecksumFlag ? BFSize : 0)
  ------------------
  |  Branch (3359:32): [True: 13.9k, False: 22.7k]
  ------------------
 3360|  36.7k|                            + BHSize /* next header size */;
 3361|  36.7k|            doAnotherStage = 0;
 3362|  36.7k|            break;
 3363|       |
 3364|       |        /* check block checksum for recently transferred uncompressed block */
 3365|  4.85k|        case dstage_getBlockChecksum:
  ------------------
  |  Branch (3365:9): [True: 4.85k, False: 340k]
  ------------------
 3366|  4.85k|            DEBUGLOG(6, "dstage_getBlockChecksum");
  ------------------
  |  |  191|  4.85k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 3367|  4.85k|            selectedIn = LZ4F_gatherInput(dctx, dctx->tmpIn, BFSize, &srcPtr, srcEnd);
 3368|  4.85k|            if (selectedIn == NULL) {   /* all input consumed */
  ------------------
  |  Branch (3368:17): [True: 444, False: 4.40k]
  ------------------
 3369|    444|                nextSrcSizeHint = (BFSize - dctx->tmpInSize) + BHSize /* next header size */;
 3370|    444|                doAnotherStage = 0;
 3371|    444|                break;
 3372|    444|            }
 3373|  4.40k|            if (!dctx->skipBlockChecksum) {
  ------------------
  |  Branch (3373:17): [True: 4.40k, False: 0]
  ------------------
 3374|  4.40k|                U32 const readCRC = LZ4F_readLE32(selectedIn);
 3375|  4.40k|                U32 const calcCRC = XXH32_digest(&dctx->blockChecksum);
  ------------------
  |  |  133|  4.40k|#  define XXH32_digest XXH_NAME2(XXH_NAMESPACE, XXH32_digest)
  |  |  ------------------
  |  |  |  |  126|  4.40k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  4.40k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3376|       |#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
 3377|       |                DEBUGLOG(6, "compare block checksum");
 3378|       |                if (readCRC != calcCRC) {
 3379|       |                    DEBUGLOG(4, "incorrect block checksum: %08X != %08X",
 3380|       |                            readCRC, calcCRC);
 3381|       |                    nextSrcSizeHint = LZ4F_returnErrorCode(LZ4F_ERROR_blockChecksum_invalid);
 3382|       |                    goto _output;
 3383|       |                }
 3384|       |#else
 3385|  4.40k|                (void)readCRC;
 3386|  4.40k|                (void)calcCRC;
 3387|  4.40k|#endif
 3388|  4.40k|            }
 3389|  4.40k|            dctx->dStage = dstage_getBlockHeader;  /* new block */
 3390|  4.40k|            break;
 3391|       |
 3392|   119k|        case dstage_getCBlock:
  ------------------
  |  Branch (3392:9): [True: 119k, False: 225k]
  ------------------
 3393|   119k|            DEBUGLOG(6, "dstage_getCBlock");
  ------------------
  |  |  191|   119k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 3394|   119k|            selectedIn = LZ4F_gatherInput(dctx, dctx->tmpIn, dctx->tmpInTarget, &srcPtr, srcEnd);
 3395|   119k|            if (selectedIn == NULL) {   /* need more input */
  ------------------
  |  Branch (3395:17): [True: 67.6k, False: 52.0k]
  ------------------
 3396|  67.6k|                nextSrcSizeHint = (dctx->tmpInTarget - dctx->tmpInSize)   /* block checksum included */
 3397|  67.6k|                                + BHSize /* next header size */;
 3398|  67.6k|                doAnotherStage = 0;
 3399|  67.6k|                break;
 3400|  67.6k|            }
 3401|       |
 3402|       |            /* At this stage, input is large enough to decode a block */
 3403|       |
 3404|       |            /* First, decode and control block checksum if it exists */
 3405|  52.0k|            if (dctx->frameInfo.blockChecksumFlag) {
  ------------------
  |  Branch (3405:17): [True: 21.0k, False: 31.0k]
  ------------------
 3406|  21.0k|                assert(dctx->tmpInTarget >= 4);
  ------------------
  |  Branch (3406:17): [True: 0, False: 21.0k]
  |  Branch (3406:17): [True: 21.0k, False: 0]
  ------------------
 3407|  21.0k|                dctx->tmpInTarget -= 4;
 3408|  21.0k|                if (!dctx->skipBlockChecksum) {
  ------------------
  |  Branch (3408:21): [True: 21.0k, False: 0]
  ------------------
 3409|  21.0k|                    U32 const readBlockCrc = LZ4F_readLE32(selectedIn + dctx->tmpInTarget);
 3410|  21.0k|                    U32 const calcBlockCrc = XXH32(selectedIn, dctx->tmpInTarget, 0);
  ------------------
  |  |  128|  21.0k|#  define XXH32 XXH_NAME2(XXH_NAMESPACE, XXH32)
  |  |  ------------------
  |  |  |  |  126|  21.0k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  21.0k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3411|       |#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
 3412|       |                    if (readBlockCrc != calcBlockCrc) {
 3413|       |                        nextSrcSizeHint = LZ4F_returnErrorCode(LZ4F_ERROR_blockChecksum_invalid);
 3414|       |                        goto _output;
 3415|       |                    }
 3416|       |#else
 3417|  21.0k|                    (void)readBlockCrc;
 3418|  21.0k|                    (void)calcBlockCrc;
 3419|  21.0k|#endif
 3420|  21.0k|            }   }
 3421|       |
 3422|       |            /* decode directly into destination buffer if there is enough room */
 3423|  52.0k|            if ( ((size_t)(dstEnd-dstPtr) >= dctx->maxBlockSize)
  ------------------
  |  Branch (3423:18): [True: 14.6k, False: 37.4k]
  ------------------
 3424|       |                 /* unless the dictionary is stored in tmpOut:
 3425|       |                  * in which case it's faster to decode within tmpOut
 3426|       |                  * to benefit from prefix speedup */
 3427|  14.6k|              && !(dctx->dict!= NULL && (const BYTE*)dctx->dict + dctx->dictSize == dctx->tmpOut) )
  ------------------
  |  Branch (3427:20): [True: 8.95k, False: 5.72k]
  |  Branch (3427:41): [True: 6.28k, False: 2.66k]
  ------------------
 3428|  8.39k|            {   size_t const decodedSize = LZ4F_decodeBlock(dctx, selectedIn, dctx->tmpInTarget, dstPtr);
 3429|  8.39k|                if (LZ4F_isError(decodedSize)) { nextSrcSizeHint = decodedSize; goto _output; }
  ------------------
  |  Branch (3429:21): [True: 713, False: 7.68k]
  ------------------
 3430|       |
 3431|       |                /* dictionary management, unless the frame ends with this block */
 3432|  7.68k|                if ( (dctx->frameInfo.blockMode==LZ4F_blockLinked)
  ------------------
  |  Branch (3432:22): [True: 5.52k, False: 2.15k]
  ------------------
 3433|  5.52k|                  && !LZ4F_endMarkFollows(srcPtr, srcEnd, 0) ) {
  ------------------
  |  Branch (3433:22): [True: 5.40k, False: 118]
  ------------------
 3434|  5.40k|                    LZ4F_updateDict(dctx, dstPtr, decodedSize, dstStart, 0);
 3435|  5.40k|                }
 3436|       |
 3437|  7.68k|                dstPtr += decodedSize;
 3438|  7.68k|                dctx->dStage = dstage_getBlockHeader;  /* end of block, let's get another one */
 3439|  7.68k|                break;
 3440|  8.39k|            }
 3441|       |
 3442|       |            /* not enough place into dst : decode into tmpOut */
 3443|       |
 3444|       |            /* manage dictionary */
 3445|  43.6k|            if (dctx->frameInfo.blockMode == LZ4F_blockLinked) {
  ------------------
  |  Branch (3445:17): [True: 32.4k, False: 11.2k]
  ------------------
 3446|  32.4k|                if (dctx->dict == dctx->tmpOutBuffer) {
  ------------------
  |  Branch (3446:21): [True: 19.9k, False: 12.5k]
  ------------------
 3447|       |                    /* truncate dictionary to 64 KB if too big */
 3448|  19.9k|                    if (dctx->dictSize > 128 KB) {
  ------------------
  |  |  268|  19.9k|#  define KB *(1<<10)
  ------------------
  |  Branch (3448:25): [True: 1.18k, False: 18.7k]
  ------------------
 3449|  1.18k|                        memcpy(dctx->tmpOutBuffer, dctx->dict + dctx->dictSize - 64 KB, 64 KB);
  ------------------
  |  |  268|  1.18k|#  define KB *(1<<10)
  ------------------
                                      memcpy(dctx->tmpOutBuffer, dctx->dict + dctx->dictSize - 64 KB, 64 KB);
  ------------------
  |  |  268|  1.18k|#  define KB *(1<<10)
  ------------------
 3450|  1.18k|                        dctx->dictSize = 64 KB;
  ------------------
  |  |  268|  1.18k|#  define KB *(1<<10)
  ------------------
 3451|  1.18k|                    }
 3452|  19.9k|                    dctx->tmpOut = dctx->tmpOutBuffer + dctx->dictSize;
 3453|  19.9k|                } else {  /* dict not within tmpOut */
 3454|  12.5k|                    size_t const reservedDictSpace = MIN(dctx->dictSize, 64 KB);
  ------------------
  |  |  426|  12.5k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (426:22): [True: 12.5k, False: 0]
  |  |  ------------------
  ------------------
 3455|  12.5k|                    dctx->tmpOut = dctx->tmpOutBuffer + reservedDictSpace;
 3456|  12.5k|            }   }
 3457|       |
 3458|       |            /* Decode block into tmpOut */
 3459|  43.6k|            {   size_t const decodedSize = LZ4F_decodeBlock(dctx, selectedIn, dctx->tmpInTarget, dctx->tmpOut);
 3460|  43.6k|                if (LZ4F_isError(decodedSize)) { nextSrcSizeHint = decodedSize; goto _output; }
  ------------------
  |  Branch (3460:21): [True: 1.91k, False: 41.7k]
  ------------------
 3461|  41.7k|                dctx->tmpOutSize = decodedSize;
 3462|  41.7k|                dctx->tmpOutStart = 0;
 3463|  41.7k|                dctx->dStage = dstage_flushOut;
 3464|  41.7k|            }
 3465|       |            /* fall-through */
 3466|       |
 3467|  52.2k|        case dstage_flushOut:  /* flush decoded data from tmpOut to dstBuffer */
  ------------------
  |  Branch (3467:9): [True: 10.4k, False: 334k]
  ------------------
 3468|  52.2k|            DEBUGLOG(6, "dstage_flushOut");
  ------------------
  |  |  191|  52.2k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 3469|  52.2k|            if (dstPtr != NULL) {
  ------------------
  |  Branch (3469:17): [True: 52.2k, False: 0]
  ------------------
 3470|  52.2k|                size_t const sizeToCopy = MIN(dctx->tmpOutSize - dctx->tmpOutStart, (size_t)(dstEnd-dstPtr));
  ------------------
  |  |  426|  52.2k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (426:22): [True: 19.9k, False: 32.2k]
  |  |  ------------------
  ------------------
 3471|  52.2k|                memcpy(dstPtr, dctx->tmpOut + dctx->tmpOutStart, sizeToCopy);
 3472|       |
 3473|       |                /* dictionary management, unless the frame ends with this block */
 3474|  52.2k|                if ( (dctx->frameInfo.blockMode == LZ4F_blockLinked)
  ------------------
  |  Branch (3474:22): [True: 39.5k, False: 12.7k]
  ------------------
 3475|  39.5k|                  && !( (dctx->tmpOutStart + sizeToCopy == dctx->tmpOutSize)
  ------------------
  |  Branch (3475:25): [True: 25.3k, False: 14.1k]
  ------------------
 3476|  25.3k|                     && LZ4F_endMarkFollows(srcPtr, srcEnd, 0) ) )
  ------------------
  |  Branch (3476:25): [True: 9.86k, False: 15.5k]
  ------------------
 3477|  29.6k|                    LZ4F_updateDict(dctx, dstPtr, sizeToCopy, dstStart, 1 /*withinTmp*/);
 3478|       |
 3479|  52.2k|                dctx->tmpOutStart += sizeToCopy;
 3480|  52.2k|                dstPtr += sizeToCopy;
 3481|  52.2k|            }
 3482|  52.2k|            if (dctx->tmpOutStart == dctx->tmpOutSize) { /* all flushed */
  ------------------
  |  Branch (3482:17): [True: 33.4k, False: 18.7k]
  ------------------
 3483|  33.4k|                dctx->dStage = dstage_getBlockHeader;  /* get next block */
 3484|  33.4k|                break;
 3485|  33.4k|            }
 3486|       |            /* could not flush everything : stop there, just request a block header */
 3487|  18.7k|            doAnotherStage = 0;
 3488|  18.7k|            nextSrcSizeHint = BHSize;
 3489|  18.7k|            break;
 3490|       |
 3491|  23.0k|        case dstage_getSuffix:
  ------------------
  |  Branch (3491:9): [True: 23.0k, False: 322k]
  ------------------
 3492|  23.0k|            if (dctx->frameRemainingSize) {   /* incorrect frame size decoded */
  ------------------
  |  Branch (3492:17): [True: 154, False: 22.8k]
  ------------------
 3493|    154|                nextSrcSizeHint = LZ4F_returnErrorCode(LZ4F_ERROR_frameSize_wrong);
 3494|    154|                goto _output;
 3495|    154|            }
 3496|  22.8k|            if (!dctx->frameInfo.contentChecksumFlag) {  /* no checksum, frame is completed */
  ------------------
  |  Branch (3496:17): [True: 10.9k, False: 11.9k]
  ------------------
 3497|  10.9k|                nextSrcSizeHint = 0;
 3498|  10.9k|                LZ4F_resetDecompressionContext(dctx);
 3499|  10.9k|                doAnotherStage = 0;
 3500|  10.9k|                break;
 3501|  10.9k|            }
 3502|  11.9k|            selectedIn = LZ4F_gatherInput(dctx, dctx->tmpIn, 4, &srcPtr, srcEnd);
 3503|  11.9k|            if (selectedIn == NULL) {   /* not enough input to read complete suffix */
  ------------------
  |  Branch (3503:17): [True: 8.47k, False: 3.47k]
  ------------------
 3504|  8.47k|                nextSrcSizeHint = 4 - dctx->tmpInSize;
 3505|  8.47k|                doAnotherStage = 0;
 3506|  8.47k|                break;
 3507|  8.47k|            }
 3508|  3.47k|            if (!dctx->skipContentChecksum) {
  ------------------
  |  Branch (3508:17): [True: 3.37k, False: 95]
  ------------------
 3509|  3.37k|                U32 const readCRC = LZ4F_readLE32(selectedIn);
 3510|  3.37k|                U32 const resultCRC = XXH32_digest(&(dctx->xxh));
  ------------------
  |  |  133|  3.37k|#  define XXH32_digest XXH_NAME2(XXH_NAMESPACE, XXH32_digest)
  |  |  ------------------
  |  |  |  |  126|  3.37k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  3.37k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3511|  3.37k|                DEBUGLOG(4, "frame checksum: stored 0x%0X vs 0x%0X processed", readCRC, resultCRC);
  ------------------
  |  |  191|  3.37k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 3512|       |#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
 3513|       |                if (readCRC != resultCRC) {
 3514|       |                    nextSrcSizeHint = LZ4F_returnErrorCode(LZ4F_ERROR_contentChecksum_invalid);
 3515|       |                    goto _output;
 3516|       |                }
 3517|       |#else
 3518|  3.37k|                (void)readCRC;
 3519|  3.37k|                (void)resultCRC;
 3520|  3.37k|#endif
 3521|  3.37k|            }
 3522|  3.47k|            nextSrcSizeHint = 0;
 3523|  3.47k|            LZ4F_resetDecompressionContext(dctx);
 3524|  3.47k|            doAnotherStage = 0;
 3525|  3.47k|            break;
 3526|       |
 3527|  7.79k|        case dstage_getSFrameSize:
  ------------------
  |  Branch (3527:9): [True: 7.79k, False: 337k]
  ------------------
 3528|  7.79k|            selectedIn = LZ4F_gatherInput(dctx, dctx->header + 4, 4, &srcPtr, srcEnd);
 3529|  7.79k|            if (selectedIn == NULL) {   /* not enough input to read the skippable frame size */
  ------------------
  |  Branch (3529:17): [True: 3.70k, False: 4.08k]
  ------------------
 3530|  3.70k|                nextSrcSizeHint = 4 - dctx->tmpInSize;
 3531|  3.70k|                doAnotherStage = 0;
 3532|  3.70k|                break;
 3533|  3.70k|            }
 3534|  4.08k|            {   size_t const SFrameSize = LZ4F_readLE32(selectedIn);
 3535|  4.08k|                dctx->frameInfo.contentSize = SFrameSize;
 3536|  4.08k|                dctx->tmpInTarget = SFrameSize;
 3537|  4.08k|                dctx->dStage = dstage_skipSkippable;
 3538|  4.08k|                break;
 3539|  7.79k|            }
 3540|       |
 3541|  8.39k|        case dstage_skipSkippable:
  ------------------
  |  Branch (3541:9): [True: 8.39k, False: 336k]
  ------------------
 3542|  8.39k|            {   size_t const skipSize = MIN(dctx->tmpInTarget, (size_t)(srcEnd-srcPtr));
  ------------------
  |  |  426|  8.39k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (426:22): [True: 91, False: 8.30k]
  |  |  ------------------
  ------------------
 3543|  8.39k|                srcPtr += skipSize;
 3544|  8.39k|                dctx->tmpInTarget -= skipSize;
 3545|  8.39k|                doAnotherStage = 0;
 3546|  8.39k|                nextSrcSizeHint = dctx->tmpInTarget;
 3547|  8.39k|                if (nextSrcSizeHint) break;  /* still more to skip */
  ------------------
  |  Branch (3547:21): [True: 4.47k, False: 3.92k]
  ------------------
 3548|       |                /* frame fully skipped : prepare context for a new frame */
 3549|  3.92k|                LZ4F_resetDecompressionContext(dctx);
 3550|  3.92k|                break;
 3551|  8.39k|            }
 3552|   345k|        }   /* switch (dctx->dStage) */
 3553|   345k|    }   /* while (doAnotherStage) */
 3554|       |
 3555|       |    /* preserve history within tmpOut whenever necessary */
 3556|   226k|    LZ4F_STATIC_ASSERT((unsigned)dstage_init == 2);
  ------------------
  |  |  178|   226k|#define LZ4F_STATIC_ASSERT(c)    { enum { LZ4F_static_assert = 1/(int)(!!(c)) }; }   /* use only *after* variable declarations */
  ------------------
 3557|   226k|    if ( (dctx->frameInfo.blockMode==LZ4F_blockLinked)  /* next block will use up to 64KB from previous ones */
  ------------------
  |  Branch (3557:10): [True: 167k, False: 59.4k]
  ------------------
 3558|   167k|      && (dctx->dict != dctx->tmpOutBuffer)             /* dictionary is not already within tmp */
  ------------------
  |  Branch (3558:10): [True: 103k, False: 63.1k]
  ------------------
 3559|   103k|      && (dctx->dict != NULL)                           /* dictionary exists */
  ------------------
  |  Branch (3559:10): [True: 31.2k, False: 72.6k]
  ------------------
 3560|  31.2k|      && (!decompressOptionsPtr->stableDst)             /* cannot rely on dst data to remain there for next call */
  ------------------
  |  Branch (3560:10): [True: 31.2k, False: 0]
  ------------------
 3561|  31.2k|      && ((unsigned)(dctx->dStage)-2 < (unsigned)(dstage_getSuffix)-2) )  /* valid stages : [init ... getSuffix[ */
  ------------------
  |  Branch (3561:10): [True: 31.2k, False: 0]
  ------------------
 3562|  31.2k|    {
 3563|  31.2k|        if (dctx->dStage == dstage_flushOut) {
  ------------------
  |  Branch (3563:13): [True: 5.50k, False: 25.7k]
  ------------------
 3564|  5.50k|            LZ4F_moveDictBeforeTmpOut(dctx, 0);
 3565|  25.7k|        } else {
 3566|  25.7k|            const BYTE* const oldDictEnd = dctx->dict + dctx->dictSize;
 3567|  25.7k|            size_t const newDictSize = MIN(dctx->dictSize, 64 KB);
  ------------------
  |  |  426|  25.7k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (426:22): [True: 14.8k, False: 10.8k]
  |  |  ------------------
  ------------------
 3568|       |
 3569|  25.7k|            memcpy(dctx->tmpOutBuffer, oldDictEnd - newDictSize, newDictSize);
 3570|       |
 3571|  25.7k|            dctx->dict = dctx->tmpOutBuffer;
 3572|  25.7k|            dctx->dictSize = newDictSize;
 3573|  25.7k|            dctx->tmpOut = dctx->tmpOutBuffer + newDictSize;
 3574|  25.7k|        }
 3575|  31.2k|    }
 3576|       |
 3577|   230k|_output:   /* also on error : report progress, but do not preserve history for reuse */
 3578|   230k|    *srcSizePtr = (size_t)(srcPtr - srcStart);
 3579|   230k|    *dstSizePtr = dstStart ? (size_t)(dstPtr - dstStart) : 0;
  ------------------
  |  Branch (3579:19): [True: 163k, False: 66.6k]
  ------------------
 3580|   230k|    return nextSrcSizeHint;
 3581|   226k|}
LZ4F_resumeFrame:
 3608|  1.20k|{
 3609|  1.20k|    assert(dctx != NULL);
  ------------------
  |  Branch (3609:5): [True: 0, False: 1.20k]
  |  Branch (3609:5): [True: 1.20k, False: 0]
  ------------------
 3610|  1.20k|    RETURN_ERROR_IF(frameInfo == NULL, parameter_null);
  ------------------
  |  |  377|  1.20k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  378|  1.20k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (378:13): [True: 0, False: 1.20k]
  |  |  ------------------
  |  |  379|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  191|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  380|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  375|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  381|      0|        }                          \
  |  |  382|  1.20k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (382:14): [Folded, False: 1.20k]
  |  |  ------------------
  ------------------
 3611|  1.20k|    RETURN_ERROR_IF(dict == NULL && dictSize > 0, parameter_null);
  ------------------
  |  |  377|  1.20k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  378|  3.62k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (378:13): [True: 1.20k, False: 0]
  |  |  |  Branch (378:13): [True: 0, False: 1.20k]
  |  |  ------------------
  |  |  379|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  191|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  380|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  375|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  381|      0|        }                          \
  |  |  382|  1.20k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (382:14): [Folded, False: 1.20k]
  |  |  ------------------
  ------------------
 3612|  1.20k|    RETURN_ERROR_IF(frameInfo->frameType != LZ4F_frame, frameType_unknown);
  ------------------
  |  |  377|  1.20k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  378|  1.20k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (378:13): [True: 0, False: 1.20k]
  |  |  ------------------
  |  |  379|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  191|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  380|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  375|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  381|      0|        }                          \
  |  |  382|  1.20k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (382:14): [Folded, False: 1.20k]
  |  |  ------------------
  ------------------
 3613|  1.20k|    RETURN_ERROR_IF(frameInfo->blockSizeID < LZ4F_max64KB || frameInfo->blockSizeID > LZ4F_max4MB, maxBlockSize_invalid);
  ------------------
  |  |  377|  1.20k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  378|  3.62k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (378:13): [True: 0, False: 1.20k]
  |  |  |  Branch (378:13): [True: 0, False: 1.20k]
  |  |  ------------------
  |  |  379|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  191|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  380|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  375|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  381|      0|        }                          \
  |  |  382|  1.20k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (382:14): [Folded, False: 1.20k]
  |  |  ------------------
  ------------------
 3614|  1.20k|    RETURN_ERROR_IF((unsigned)frameInfo->blockMode > 1, blockMode_invalid);
  ------------------
  |  |  377|  1.20k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  378|  1.20k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (378:13): [True: 0, False: 1.20k]
  |  |  ------------------
  |  |  379|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  191|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  380|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  375|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  381|      0|        }                          \
  |  |  382|  1.20k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (382:14): [Folded, False: 1.20k]
  |  |  ------------------
  ------------------
 3615|  1.20k|    RETURN_ERROR_IF((unsigned)frameInfo->blockChecksumFlag > 1, parameter_invalid);
  ------------------
  |  |  377|  1.20k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  378|  1.20k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (378:13): [True: 0, False: 1.20k]
  |  |  ------------------
  |  |  379|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  191|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  380|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  375|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  381|      0|        }                          \
  |  |  382|  1.20k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (382:14): [Folded, False: 1.20k]
  |  |  ------------------
  ------------------
 3616|  1.20k|    RETURN_ERROR_IF((unsigned)frameInfo->contentChecksumFlag > 1, parameter_invalid);
  ------------------
  |  |  377|  1.20k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  378|  1.20k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (378:13): [True: 0, False: 1.20k]
  |  |  ------------------
  |  |  379|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  191|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  380|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  375|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  381|      0|        }                          \
  |  |  382|  1.20k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (382:14): [Folded, False: 1.20k]
  |  |  ------------------
  ------------------
 3617|  1.20k|    RETURN_ERROR_IF(frameInfo->contentSize && decodedPos > frameInfo->contentSize, frameSize_wrong);
  ------------------
  |  |  377|  1.20k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  378|  2.58k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (378:13): [True: 168, False: 1.04k]
  |  |  |  Branch (378:13): [True: 0, False: 168]
  |  |  ------------------
  |  |  379|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  191|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  380|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  375|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  381|      0|        }                          \
  |  |  382|  1.20k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (382:14): [Folded, False: 1.20k]
  |  |  ------------------
  ------------------
 3618|       |
 3619|  1.20k|    LZ4F_resetDecompressionContext(dctx);
 3620|  1.20k|    dctx->frameInfo = *frameInfo;
 3621|  1.20k|    dctx->maxBlockSize = LZ4F_getBlockSize(frameInfo->blockSizeID);
 3622|  1.20k|    if (frameInfo->contentSize)
  ------------------
  |  Branch (3622:9): [True: 168, False: 1.04k]
  ------------------
 3623|    168|        dctx->frameRemainingSize = frameInfo->contentSize - decodedPos;
 3624|  1.20k|    dctx->dict = (const BYTE*)dict;
 3625|  1.20k|    dctx->dictSize = dictSize;
 3626|  1.20k|    dctx->skipContentChecksum = 1;   /* content checksum covers the whole frame : can't be verified */
 3627|  1.20k|    dctx->dStage = dstage_init;
 3628|  1.20k|    return 0;
 3629|  1.20k|}
lz4frame.c:LZ4F_returnErrorCode:
  369|  16.6k|{
  370|       |    /* A compilation error here means sizeof(ptrdiff_t) is not large enough */
  371|  16.6k|    LZ4F_STATIC_ASSERT(sizeof(ptrdiff_t) >= sizeof(size_t));
  ------------------
  |  |  178|  16.6k|#define LZ4F_STATIC_ASSERT(c)    { enum { LZ4F_static_assert = 1/(int)(!!(c)) }; }   /* use only *after* variable declarations */
  ------------------
  372|  16.6k|    return (LZ4F_errorCode_t)-(ptrdiff_t)code;
  373|  16.6k|}
lz4frame.c:LZ4F_compressBound_autoFlush:
  458|  6.54k|{
  459|  6.54k|    size_t const blockSize = LZ4F_getBlockSize(prefsPtr->frameInfo.blockSizeID);
  460|  6.54k|    size_t const nbFullBlocks = srcSize / blockSize;
  461|  6.54k|    size_t const lastBlockSize = srcSize & (blockSize-1);
  462|  6.54k|    size_t const nbBlocks = nbFullBlocks + (lastBlockSize>0);
  463|  6.54k|    size_t const blockCRCSize = BFSize * prefsPtr->frameInfo.blockChecksumFlag;
  464|  6.54k|    size_t const frameEnd = BHSize + (prefsPtr->frameInfo.contentChecksumFlag*BFSize);
  465|  6.54k|    assert(prefsPtr->autoFlush);
  ------------------
  |  Branch (465:5): [True: 0, False: 6.54k]
  |  Branch (465:5): [True: 6.54k, False: 0]
  ------------------
  466|  6.54k|    return ((BHSize + blockCRCSize) * nbBlocks) +
  467|  6.54k|           (blockSize * nbFullBlocks) + lastBlockSize + frameEnd;
  468|  6.54k|}
lz4frame.c:LZ4F_mtEligible:
  521|  24.8k|{
  522|  24.8k|    if (prefs->nbWorkers == 0) return 0;
  ------------------
  |  Branch (522:9): [True: 24.8k, False: 0]
  ------------------
  523|       |    /* linked blocks : jobs define the output, so frames are cut into jobs even without threads */
  524|      0|    if (prefs->frameInfo.blockMode == LZ4F_blockLinked) return 1;
  ------------------
  |  Branch (524:9): [True: 0, False: 0]
  ------------------
  525|       |#if LZ4F_MULTITHREAD
  526|       |    return (prefs->frameInfo.blockMode == LZ4F_blockIndependent);
  527|       |#else
  528|       |    /* independent blocks : the output is identical to single-threaded mode, which is faster without threads */
  529|      0|    return 0;
  530|      0|#endif
  531|      0|}
lz4frame.c:LZ4F_invalidateFrame:
  394|  15.6k|{
  395|  15.6k|    if (cctx->mtActive) LZ4F_mt_abort(cctx->mt);
  ------------------
  |  Branch (395:9): [True: 0, False: 15.6k]
  ------------------
  396|  15.6k|    cctx->cStage = 0;
  397|  15.6k|}
lz4frame.c:LZ4F_free:
  155|   254k|{
  156|   254k|    if (p == NULL) return;
  ------------------
  |  Branch (156:9): [True: 141k, False: 113k]
  ------------------
  157|   113k|    if (cmem.customFree != NULL) {
  ------------------
  |  Branch (157:9): [True: 0, False: 113k]
  ------------------
  158|       |        /* custom allocation defined : use it */
  159|      0|        cmem.customFree(cmem.opaqueState, p);
  160|      0|        return;
  161|      0|    }
  162|       |    /* nothing defined : use default <stdlib.h>'s free() */
  163|   113k|    FREEMEM(p);
  ------------------
  |  |  124|   113k|#    define FREEMEM(p)        free(p)
  ------------------
  164|   113k|}
lz4frame.c:LZ4F_malloc:
  145|  66.8k|{
  146|       |    /* custom malloc defined : use it */
  147|  66.8k|    if (cmem.customAlloc != NULL) {
  ------------------
  |  Branch (147:9): [True: 0, False: 66.8k]
  ------------------
  148|      0|        return cmem.customAlloc(cmem.opaqueState, s);
  149|      0|    }
  150|       |    /* nothing defined : use default <stdlib.h>'s malloc() */
  151|  66.8k|    return ALLOC(s);
  ------------------
  |  |  122|  66.8k|#    define ALLOC(s)          malloc(s)
  ------------------
  152|  66.8k|}
lz4frame.c:LZ4F_calloc:
  129|  47.0k|{
  130|       |    /* custom calloc defined : use it */
  131|  47.0k|    if (cmem.customCalloc != NULL) {
  ------------------
  |  Branch (131:9): [True: 0, False: 47.0k]
  ------------------
  132|      0|        return cmem.customCalloc(cmem.opaqueState, s);
  133|      0|    }
  134|       |    /* nothing defined : use default <stdlib.h>'s calloc() */
  135|  47.0k|    if (cmem.customAlloc == NULL) {
  ------------------
  |  Branch (135:9): [True: 47.0k, False: 0]
  ------------------
  136|  47.0k|        return ALLOC_AND_ZERO(s);
  ------------------
  |  |  123|  47.0k|#    define ALLOC_AND_ZERO(s) calloc(1,(s))
  ------------------
  137|  47.0k|    }
  138|       |    /* only custom alloc defined : use it, and combine it with memset() */
  139|      0|    {   void* const p = cmem.customAlloc(cmem.opaqueState, s);
  140|      0|        if (p != NULL) MEM_INIT(p, 0, s);
  ------------------
  |  |  109|      0|#  define MEM_INIT(p,v,s)   memset((p),(v),(s))
  ------------------
  |  Branch (140:13): [True: 0, False: 0]
  ------------------
  141|      0|        return p;
  142|  47.0k|}   }
lz4frame.c:LZ4F_sizeofLZ4State:
  882|  31.3k|{
  883|  31.3k|    switch (ctxType) {
  ------------------
  |  Branch (883:13): [True: 31.3k, False: 0]
  ------------------
  884|  15.6k|    case ctxNone: return 0;
  ------------------
  |  Branch (884:5): [True: 15.6k, False: 15.6k]
  ------------------
  885|  5.27k|    case ctxFast: return sizeof(LZ4_stream_t);
  ------------------
  |  Branch (885:5): [True: 5.27k, False: 26.0k]
  ------------------
  886|  10.3k|    case ctxHC:   return LZ4_STREAMHC_EXTSIZE;   /* extended : levels >= 10 allocate nothing */
  ------------------
  |  |  378|  10.3k|#define LZ4_STREAMHC_EXTSIZE (LZ4_STREAMHC_MINSIZE + 65584)
  |  |  ------------------
  |  |  |  |  262|  10.3k|#define LZ4_STREAMHC_MINSIZE  262200  /* static size, for inter-version compatibility */
  |  |  ------------------
  ------------------
  |  Branch (886:5): [True: 10.3k, False: 20.9k]
  ------------------
  887|  31.3k|    }
  888|  31.3k|    assert(0);   /* invalid ctxType */
  ------------------
  |  Branch (888:5): [Folded, False: 0]
  |  Branch (888:5): [Folded, False: 0]
  ------------------
  889|      0|    return 0;
  890|      0|}
lz4frame.c:LZ4F_compressBegin_internal:
  957|  15.6k|{
  958|  15.6k|    LZ4F_preferences_t const prefNull = LZ4F_INIT_PREFERENCES;
  ------------------
  |  |  218|  15.6k|#define LZ4F_INIT_PREFERENCES   { LZ4F_INIT_FRAMEINFO, 0, 0u, 0u, 0u, 0u, 0u }    /* v1.8.3+ */
  |  |  ------------------
  |  |  |  |  199|  15.6k|#define LZ4F_INIT_FRAMEINFO   { LZ4F_max64KB, LZ4F_blockLinked, LZ4F_noContentChecksum, LZ4F_frame, 0ULL, 0U, LZ4F_noBlockChecksum }    /* v1.8.3+ */
  |  |  ------------------
  ------------------
  959|  15.6k|    BYTE* const dstStart = (BYTE*)dstBuffer;
  960|  15.6k|    BYTE* dstPtr = dstStart;
  961|  15.6k|    int mtFrame;   /* frame cut into jobs (multi-threaded compression) */
  962|       |
  963|  15.6k|    if (preferencesPtr == NULL) preferencesPtr = &prefNull;
  ------------------
  |  Branch (963:9): [True: 0, False: 15.6k]
  ------------------
  964|       |    /* validate arguments before modifying @cctx : when they are rejected, a frame in progress continues */
  965|  15.6k|    {   size_t const headerSize = minFHSize
  966|  15.6k|                                + (preferencesPtr->frameInfo.contentSize ? 8 : 0)
  ------------------
  |  Branch (966:36): [True: 0, False: 15.6k]
  ------------------
  967|  15.6k|                                + (preferencesPtr->frameInfo.dictID ? 4 : 0);
  ------------------
  |  Branch (967:36): [True: 0, False: 15.6k]
  ------------------
  968|  15.6k|        RETURN_ERROR_IF(dstCapacity < headerSize, dstCapacity_tooSmall);
  ------------------
  |  |  377|  15.6k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  378|  15.6k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (378:13): [True: 0, False: 15.6k]
  |  |  ------------------
  |  |  379|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  191|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  380|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  375|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  381|      0|        }                          \
  |  |  382|  15.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (382:14): [Folded, False: 15.6k]
  |  |  ------------------
  ------------------
  969|  15.6k|    }
  970|  15.6k|    FORWARD_IF_ERROR( LZ4F_getBlockSize(preferencesPtr->frameInfo.blockSizeID) );
  ------------------
  |  |  385|  15.6k|#define FORWARD_IF_ERROR(r) do {                     \
  |  |  386|  15.6k|        size_t const err_code = (r);                 \
  |  |  387|  15.6k|        if (LZ4F_isError(err_code)) return err_code; \
  |  |  ------------------
  |  |  |  Branch (387:13): [True: 0, False: 15.6k]
  |  |  ------------------
  |  |  388|  15.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (388:14): [Folded, False: 15.6k]
  |  |  ------------------
  ------------------
  971|  15.6k|    RETURN_ERROR_IF(dictSize > INT_MAX, parameter_invalid);
  ------------------
  |  |  377|  15.6k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  378|  15.6k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (378:13): [True: 0, False: 15.6k]
  |  |  ------------------
  |  |  379|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  191|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  380|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  375|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  381|      0|        }                          \
  |  |  382|  15.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (382:14): [Folded, False: 15.6k]
  |  |  ------------------
  ------------------
  972|       |    /* from now on, a failure (allocation) leaves no frame in progress */
  973|  15.6k|    LZ4F_invalidateFrame(cctx);   /* jobs of an abandoned frame : must complete before @cctx is modified */
  974|  15.6k|    cctx->mtActive = 0;
  975|  15.6k|    cctx->flushStage = 0;
  976|  15.6k|    cctx->pendingSize = 0;
  977|  15.6k|    cctx->prefs = *preferencesPtr;
  978|  15.6k|    mtFrame = LZ4F_mtEligible(&cctx->prefs);
  979|  15.6k|    DEBUGLOG(5, "LZ4F_compressBegin_internal: Independent_blocks=%u", cctx->prefs.frameInfo.blockMode);
  ------------------
  |  |  191|  15.6k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
  980|       |
  981|       |    /* cctx Management */
  982|  15.6k|    {   LZ4F_CtxType_e const ctxType = (cctx->prefs.compressionLevel < LZ4HC_CLEVEL_MIN) ? ctxFast : ctxHC;
  ------------------
  |  |   46|  15.6k|#define LZ4HC_CLEVEL_MIN         2
  ------------------
  |  Branch (982:40): [True: 5.27k, False: 10.3k]
  ------------------
  983|  15.6k|        size_t const requiredSize = LZ4F_sizeofLZ4State(ctxType);
  984|  15.6k|        size_t const allocatedSize = LZ4F_sizeofLZ4State((LZ4F_CtxType_e)cctx->lz4CtxAlloc);
  985|  15.6k|        if (allocatedSize < requiredSize) {
  ------------------
  |  Branch (985:13): [True: 15.6k, False: 0]
  ------------------
  986|       |            /* not enough space allocated : must take ownership of memory allocation,
  987|       |             * in order to respect custom allocator contract */
  988|  15.6k|            LZ4F_free(cctx->lz4CtxPtr, cctx->cmem);
  989|  15.6k|            cctx->lz4CtxAlloc = (U16)ctxNone;   /* in case allocation fails */
  990|  15.6k|            cctx->lz4CtxPtr = LZ4F_malloc(requiredSize, cctx->cmem);
  991|  15.6k|            RETURN_ERROR_IF(cctx->lz4CtxPtr == NULL, allocation_failed);
  ------------------
  |  |  377|  15.6k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  378|  15.6k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (378:13): [True: 0, False: 15.6k]
  |  |  ------------------
  |  |  379|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  191|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  380|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  375|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  381|      0|        }                          \
  |  |  382|  15.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (382:14): [Folded, False: 15.6k]
  |  |  ------------------
  ------------------
  992|  15.6k|            cctx->lz4CtxAlloc = (U16)ctxType;
  993|  15.6k|            cctx->lz4CtxType = (U16)ctxNone;    /* not initialized yet */
  994|  15.6k|        }
  995|  15.6k|        if (cctx->lz4CtxType != ctxType) {
  ------------------
  |  Branch (995:13): [True: 15.6k, False: 0]
  ------------------
  996|       |            /* initialize the state for the correct context type */
  997|  15.6k|            LZ4F_initLZ4State(cctx->lz4CtxPtr, ctxType, cctx->prefs.compressionLevel);
  998|  15.6k|            cctx->lz4CtxType = (U16)ctxType;
  999|  15.6k|    }   }
 1000|       |
 1001|       |    /* raw dictionary : employed by each block as a CDict (independent blocks, or jobs of multi-threaded frames) ;
 1002|       |     * single-threaded linked blocks keep the historical behavior : dictionary loaded as history, preceding the first block,
 1003|       |     * from a copy within @tmpBuff (see below) */
 1004|  15.6k|    if ( dictBuffer
  ------------------
  |  Branch (1004:10): [True: 0, False: 15.6k]
  ------------------
 1005|      0|      && ((cctx->prefs.frameInfo.blockMode == LZ4F_blockIndependent) || mtFrame) ) {
  ------------------
  |  Branch (1005:11): [True: 0, False: 0]
  |  Branch (1005:73): [True: 0, False: 0]
  ------------------
 1006|      0|        assert(cdict == NULL);
  ------------------
  |  Branch (1006:9): [True: 0, False: 0]
  |  Branch (1006:9): [True: 0, False: 0]
  ------------------
 1007|      0|        cdict = LZ4F_digestRawDict(cctx, dictBuffer, dictSize);
 1008|      0|        RETURN_ERROR_IF(cdict == NULL, allocation_failed);
  ------------------
  |  |  377|      0|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  378|      0|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (378:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  379|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  191|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  380|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  375|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  381|      0|        }                          \
  |  |  382|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (382:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1009|      0|        dictBuffer = NULL;
 1010|      0|        dictSize = 0;
 1011|      0|    }
 1012|       |
 1013|       |    /* Buffer Management */
 1014|  15.6k|    if (cctx->prefs.frameInfo.blockSizeID == 0)
  ------------------
  |  Branch (1014:9): [True: 5.76k, False: 9.91k]
  ------------------
 1015|  5.76k|        cctx->prefs.frameInfo.blockSizeID = LZ4F_BLOCKSIZEID_DEFAULT;
  ------------------
  |  |  280|  5.76k|#define LZ4F_BLOCKSIZEID_DEFAULT LZ4F_max64KB
  ------------------
 1016|  15.6k|    cctx->maxBlockSize = LZ4F_getBlockSize(cctx->prefs.frameInfo.blockSizeID);
 1017|       |
 1018|  15.6k|    {   size_t const requiredBuffSize = mtFrame ? 0 :   /* jobs employ their own buffers */
  ------------------
  |  Branch (1018:41): [True: 0, False: 15.6k]
  ------------------
 1019|  15.6k|                preferencesPtr->autoFlush ?
  ------------------
  |  Branch (1019:17): [True: 6.54k, False: 9.12k]
  ------------------
 1020|  6.54k|                ((cctx->prefs.frameInfo.blockMode == LZ4F_blockLinked) ? 128 KB : 0) :  /* history, then inputs < 64 KB (see LZ4F_st_update()) */
  ------------------
  |  |  268|  4.51k|#  define KB *(1<<10)
  ------------------
  |  Branch (1020:18): [True: 4.51k, False: 2.03k]
  ------------------
 1021|  15.6k|                cctx->maxBlockSize + ((cctx->prefs.frameInfo.blockMode == LZ4F_blockLinked) ? 128 KB : 0);
  ------------------
  |  |  268|  5.43k|#  define KB *(1<<10)
  ------------------
  |  Branch (1021:39): [True: 5.43k, False: 3.69k]
  ------------------
 1022|       |
 1023|  15.6k|        if (cctx->tmpBuffCapacity < requiredBuffSize) {
  ------------------
  |  Branch (1023:13): [True: 13.6k, False: 2.03k]
  ------------------
 1024|  13.6k|            cctx->tmpBuffCapacity = 0;
 1025|  13.6k|            LZ4F_free(cctx->tmpBuff, cctx->cmem);
 1026|  13.6k|            cctx->tmpBuff = (BYTE*)LZ4F_malloc(requiredBuffSize, cctx->cmem);
 1027|  13.6k|            RETURN_ERROR_IF(cctx->tmpBuff == NULL, allocation_failed);
  ------------------
  |  |  377|  13.6k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  378|  13.6k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (378:13): [True: 0, False: 13.6k]
  |  |  ------------------
  |  |  379|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  191|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  380|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  375|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  381|      0|        }                          \
  |  |  382|  13.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (382:14): [Folded, False: 13.6k]
  |  |  ------------------
  ------------------
 1028|  13.6k|            cctx->tmpBuffCapacity = requiredBuffSize;
 1029|  13.6k|    }   }
 1030|  15.6k|    cctx->tmpIn = cctx->tmpBuff;
 1031|  15.6k|    cctx->tmpInSize = 0;
 1032|  15.6k|    if (dictBuffer) {
  ------------------
  |  Branch (1032:9): [True: 0, False: 15.6k]
  ------------------
 1033|       |        /* single-threaded linked blocks : the dictionary is copied into @tmpBuff, as saved history :
 1034|       |         * buffered input follows it, and references it in prefix mode
 1035|       |         * (faster than an external dictionary, which fast levels also lose after the first block) */
 1036|      0|        if (dictSize > 64 KB) {
  ------------------
  |  |  268|      0|#  define KB *(1<<10)
  ------------------
  |  Branch (1036:13): [True: 0, False: 0]
  ------------------
 1037|      0|            dictBuffer = (const BYTE*)dictBuffer + dictSize - 64 KB;
  ------------------
  |  |  268|      0|#  define KB *(1<<10)
  ------------------
 1038|      0|            dictSize = 64 KB;
  ------------------
  |  |  268|      0|#  define KB *(1<<10)
  ------------------
 1039|      0|        }
 1040|      0|        assert(cctx->tmpBuffCapacity >= 128 KB);
  ------------------
  |  Branch (1040:9): [True: 0, False: 0]
  |  Branch (1040:9): [True: 0, False: 0]
  ------------------
 1041|      0|        memcpy(cctx->tmpBuff, dictBuffer, dictSize);
 1042|      0|        dictBuffer = cctx->tmpBuff;
 1043|      0|        cctx->tmpIn = cctx->tmpBuff + dictSize;
 1044|      0|    }
 1045|  15.6k|    (void)XXH32_reset(&(cctx->xxh), 0);
  ------------------
  |  |  131|  15.6k|#  define XXH32_reset XXH_NAME2(XXH_NAMESPACE, XXH32_reset)
  |  |  ------------------
  |  |  |  |  126|  15.6k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  15.6k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1046|       |
 1047|       |    /* context init */
 1048|  15.6k|    cctx->cdict = cdict;
 1049|  15.6k|    cctx->blockCompressMode = LZ4B_COMPRESSED;   /* a frame starts with the LZ4 state just initialized (dictionary included) */
 1050|  15.6k|    LZ4F_startStream(cctx->lz4CtxPtr, &cctx->prefs, cdict, dictBuffer, dictSize);
 1051|       |
 1052|       |    /* Stage 2 : Write Frame Header */
 1053|       |
 1054|       |    /* Magic Number */
 1055|  15.6k|    LZ4F_writeLE32(dstPtr, LZ4F_MAGICNUMBER);
  ------------------
  |  |  508|  15.6k|#define LZ4F_MAGICNUMBER 0x184D2204U
  ------------------
 1056|  15.6k|    dstPtr += 4;
 1057|  15.6k|    {   BYTE* const headerStart = dstPtr;
 1058|       |
 1059|       |        /* FLG Byte */
 1060|  15.6k|        *dstPtr++ = (BYTE)(((1 & _2BITS) << 6)    /* Version('01') */
  ------------------
  |  |  274|  15.6k|#define _2BITS 0x03
  ------------------
 1061|  15.6k|            + ((cctx->prefs.frameInfo.blockMode & _1BIT ) << 5)
  ------------------
  |  |  273|  15.6k|#define _1BIT  0x01
  ------------------
 1062|  15.6k|            + ((cctx->prefs.frameInfo.blockChecksumFlag & _1BIT ) << 4)
  ------------------
  |  |  273|  15.6k|#define _1BIT  0x01
  ------------------
 1063|  15.6k|            + ((unsigned)(cctx->prefs.frameInfo.contentSize > 0) << 3)
 1064|  15.6k|            + ((cctx->prefs.frameInfo.contentChecksumFlag & _1BIT ) << 2)
  ------------------
  |  |  273|  15.6k|#define _1BIT  0x01
  ------------------
 1065|  15.6k|            +  (cctx->prefs.frameInfo.dictID > 0) );
 1066|       |        /* BD Byte */
 1067|  15.6k|        *dstPtr++ = (BYTE)((cctx->prefs.frameInfo.blockSizeID & _3BITS) << 4);
  ------------------
  |  |  275|  15.6k|#define _3BITS 0x07
  ------------------
 1068|       |        /* Optional Frame content size field */
 1069|  15.6k|        if (cctx->prefs.frameInfo.contentSize) {
  ------------------
  |  Branch (1069:13): [True: 0, False: 15.6k]
  ------------------
 1070|      0|            LZ4F_writeLE64(dstPtr, cctx->prefs.frameInfo.contentSize);
 1071|      0|            dstPtr += 8;
 1072|      0|            cctx->totalInSize = 0;
 1073|      0|        }
 1074|       |        /* Optional dictionary ID field */
 1075|  15.6k|        if (cctx->prefs.frameInfo.dictID) {
  ------------------
  |  Branch (1075:13): [True: 0, False: 15.6k]
  ------------------
 1076|      0|            LZ4F_writeLE32(dstPtr, cctx->prefs.frameInfo.dictID);
 1077|      0|            dstPtr += 4;
 1078|      0|        }
 1079|       |        /* Header CRC Byte */
 1080|  15.6k|        *dstPtr = LZ4F_headerChecksum(headerStart, (size_t)(dstPtr - headerStart));
 1081|  15.6k|        dstPtr++;
 1082|  15.6k|    }
 1083|       |
 1084|  15.6k|    if (mtFrame) {
  ------------------
  |  Branch (1084:9): [True: 0, False: 15.6k]
  ------------------
 1085|      0|        assert(dictBuffer == NULL);
  ------------------
  |  Branch (1085:9): [True: 0, False: 0]
  |  Branch (1085:9): [True: 0, False: 0]
  ------------------
 1086|      0|        FORWARD_IF_ERROR( LZ4F_mt_begin(cctx) );
  ------------------
  |  |  385|      0|#define FORWARD_IF_ERROR(r) do {                     \
  |  |  386|      0|        size_t const err_code = (r);                 \
  |  |  387|      0|        if (LZ4F_isError(err_code)) return err_code; \
  |  |  ------------------
  |  |  |  Branch (387:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  388|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (388:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1087|      0|    }
 1088|       |
 1089|  15.6k|    cctx->cStage = 1;   /* header written, now request input data block */
 1090|  15.6k|    return (size_t)(dstPtr - dstStart);
 1091|  15.6k|}
lz4frame.c:LZ4F_initLZ4State:
  895|  15.6k|{
  896|  15.6k|    if (ctxType == ctxFast) {
  ------------------
  |  Branch (896:9): [True: 5.27k, False: 10.3k]
  ------------------
  897|  5.27k|        LZ4_initStream(state, sizeof(LZ4_stream_t));
  898|  10.3k|    } else {
  899|  10.3k|        assert(ctxType == ctxHC);
  ------------------
  |  Branch (899:9): [True: 0, False: 10.3k]
  |  Branch (899:9): [True: 10.3k, False: 0]
  ------------------
  900|  10.3k|        LZ4_initStreamHC(state, LZ4_STREAMHC_EXTSIZE);
  ------------------
  |  |  378|  10.3k|#define LZ4_STREAMHC_EXTSIZE (LZ4_STREAMHC_MINSIZE + 65584)
  |  |  ------------------
  |  |  |  |  262|  10.3k|#define LZ4_STREAMHC_MINSIZE  262200  /* static size, for inter-version compatibility */
  |  |  ------------------
  ------------------
  901|  10.3k|        LZ4_setCompressionLevel((LZ4_streamHC_t*)state, level);
  902|  10.3k|    }
  903|  15.6k|}
lz4frame.c:LZ4F_startStream:
  857|  15.6k|{
  858|  15.6k|    int const level = prefs->compressionLevel;
  859|  15.6k|    if (prefs->frameInfo.blockMode == LZ4F_blockLinked)
  ------------------
  |  Branch (859:9): [True: 9.94k, False: 5.73k]
  ------------------
  860|  9.94k|        LZ4F_initStream(ctx, cdict, level, LZ4F_blockLinked);
  861|  15.6k|    if (level >= LZ4HC_CLEVEL_MIN)
  ------------------
  |  |   46|  15.6k|#define LZ4HC_CLEVEL_MIN         2
  ------------------
  |  Branch (861:9): [True: 10.3k, False: 5.27k]
  ------------------
  862|  10.3k|        LZ4_favorDecompressionSpeed((LZ4_streamHC_t*)ctx, (int)prefs->favorDecSpeed);
  863|  15.6k|    if (dict) {
  ------------------
  |  Branch (863:9): [True: 0, False: 15.6k]
  ------------------
  864|      0|        assert(cdict == NULL);
  ------------------
  |  Branch (864:9): [True: 0, False: 0]
  |  Branch (864:9): [True: 0, False: 0]
  ------------------
  865|      0|        assert(prefs->frameInfo.blockMode == LZ4F_blockLinked);
  ------------------
  |  Branch (865:9): [True: 0, False: 0]
  |  Branch (865:9): [True: 0, False: 0]
  ------------------
  866|      0|        assert(dictSize <= INT_MAX);
  ------------------
  |  Branch (866:9): [True: 0, False: 0]
  |  Branch (866:9): [True: 0, False: 0]
  ------------------
  867|      0|        if (level < LZ4HC_CLEVEL_MIN) {
  ------------------
  |  |   46|      0|#define LZ4HC_CLEVEL_MIN         2
  ------------------
  |  Branch (867:13): [True: 0, False: 0]
  ------------------
  868|      0|            LZ4_loadDict((LZ4_stream_t*)ctx, (const char*)dict, (int)dictSize);
  869|      0|        } else {
  870|      0|            LZ4_loadDictHC((LZ4_streamHC_t*)ctx, (const char*)dict, (int)dictSize);
  871|      0|        }
  872|      0|    }
  873|  15.6k|}
lz4frame.c:LZ4F_initStream:
  822|  19.0k|                            LZ4F_blockMode_t blockMode) {
  823|  19.0k|    if (level < LZ4HC_CLEVEL_MIN) {
  ------------------
  |  |   46|  19.0k|#define LZ4HC_CLEVEL_MIN         2
  ------------------
  |  Branch (823:9): [True: 6.74k, False: 12.2k]
  ------------------
  824|       |        /* In these cases, we will call LZ4_compress_fast_continue(),
  825|       |         * which needs an already reset context. Otherwise, we'll call a
  826|       |         * one-shot API. The non-continued APIs internally perform their own
  827|       |         * resets at the beginning of their calls, where they know what
  828|       |         * tableType they need the context to be in. So in that case this
  829|       |         * would be misguided / wasted work. */
  830|  6.74k|        if (cdict) {
  ------------------
  |  Branch (830:13): [True: 0, False: 6.74k]
  ------------------
  831|      0|            LZ4_resetStream_fast((LZ4_stream_t*)ctx);
  832|      0|            LZ4_attach_dictionary((LZ4_stream_t*)ctx, cdict->fastCtx);
  833|  6.74k|        } else if (blockMode == LZ4F_blockLinked) {
  ------------------
  |  Branch (833:20): [True: 3.05k, False: 3.69k]
  ------------------
  834|       |            /* Clear the table, rather than LZ4_resetStream_fast() :
  835|       |             * output doesn't depend on the context's history,
  836|       |             * and it's faster, unless the frame is tiny. */
  837|  3.05k|            LZ4_initStream(ctx, sizeof(LZ4_stream_t));
  838|  3.05k|        }
  839|       |        /* In these cases, we'll call a one-shot API.
  840|       |         * The non-continued APIs internally perform their own resets
  841|       |         * at the beginning of their calls, where they know
  842|       |         * which tableType they need the context to be in.
  843|       |         * Therefore, a reset here would be wasted work. */
  844|  12.2k|    } else {
  845|  12.2k|        LZ4_resetStreamHC_fast((LZ4_streamHC_t*)ctx, level);
  846|  12.2k|        if (cdict)
  ------------------
  |  Branch (846:13): [True: 0, False: 12.2k]
  ------------------
  847|      0|            LZ4_attach_HC_dictionary((LZ4_streamHC_t*)ctx, cdict->HCCtx);
  848|  12.2k|    }
  849|  19.0k|}
lz4frame.c:LZ4F_headerChecksum:
  429|  15.6k|{
  430|  15.6k|    U32 const xxh = XXH32(header, length, 0);
  ------------------
  |  |  128|  15.6k|#  define XXH32 XXH_NAME2(XXH_NAMESPACE, XXH32)
  |  |  ------------------
  |  |  |  |  126|  15.6k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  15.6k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  431|  15.6k|    return (BYTE)(xxh >> 8);
  432|  15.6k|}
lz4frame.c:LZ4F_mt_free:
 2100|  15.6k|{
 2101|  15.6k|    if (mt == NULL) return;
  ------------------
  |  Branch (2101:9): [True: 15.6k, False: 0]
  ------------------
 2102|      0|    LZ4F_mt_abort(mt);
 2103|      0|    LZ4F_pool_free(mt->pool, cmem);
 2104|      0|    LZ4F_mt_freeStates(mt, cmem);
 2105|      0|    LZ4F_mt_freeJobs(mt, cmem);
 2106|      0|    LZ4F_mt_freeInBuffs(mt, cmem);
 2107|      0|    LZ4F_free(mt->history, cmem);
 2108|      0|    LZ4F_free(mt, cmem);
 2109|      0|}
lz4frame.c:LZ4F_compressBlocks_internal:
 1220|  14.1k|{
 1221|  14.1k|    const BYTE* ip = (const BYTE*)src;
 1222|  14.1k|    const BYTE* const iend = srcSize ? ip + srcSize : ip;
  ------------------
  |  Branch (1222:30): [True: 14.1k, False: 0]
  ------------------
 1223|  14.1k|    BYTE* const ostart = (BYTE*)dst;
 1224|  14.1k|    BYTE* op = ostart;
 1225|  14.1k|    BYTE* const oend = dstCapacity ? ostart + dstCapacity : ostart;
  ------------------
  |  Branch (1225:24): [True: 14.1k, False: 0]
  ------------------
 1226|       |
 1227|  28.2k|    while (ip < iend) {
  ------------------
  |  Branch (1227:12): [True: 14.1k, False: 14.1k]
  ------------------
 1228|  14.1k|        size_t const bSize = MIN(blockSize, (size_t)(iend - ip));
  ------------------
  |  |  426|  14.1k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (426:22): [True: 0, False: 14.1k]
  |  |  ------------------
  ------------------
 1229|  14.1k|        size_t const cSize = LZ4F_makeBlock(op, (size_t)(oend - op),
 1230|  14.1k|                                            ip, bSize,
 1231|  14.1k|                                            compress, lz4ctx, level,
 1232|  14.1k|                                            cdict, crcFlag);
 1233|  14.1k|        FORWARD_IF_ERROR(cSize);
  ------------------
  |  |  385|  14.1k|#define FORWARD_IF_ERROR(r) do {                     \
  |  |  386|  14.1k|        size_t const err_code = (r);                 \
  |  |  387|  14.1k|        if (LZ4F_isError(err_code)) return err_code; \
  |  |  ------------------
  |  |  |  Branch (387:13): [True: 0, False: 14.1k]
  |  |  ------------------
  |  |  388|  14.1k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (388:14): [Folded, False: 14.1k]
  |  |  ------------------
  ------------------
 1234|  14.1k|        ip += bSize;
 1235|  14.1k|        op += cSize;
 1236|  14.1k|    }
 1237|  14.1k|    return (size_t)(op - ostart);
 1238|  14.1k|}
lz4frame.c:LZ4F_makeBlock:
 1177|  31.2k|{
 1178|  31.2k|    BYTE* const cSizePtr = (BYTE*)dst;
 1179|  31.2k|    size_t const overhead = BHSize + (size_t)crcFlag * BFSize;
 1180|  31.2k|    int cCapacity = (srcSize > 1) ? (int)srcSize - 1 : 1;
  ------------------
  |  Branch (1180:21): [True: 30.7k, False: 443]
  ------------------
 1181|  31.2k|    U32 cSize;
 1182|  31.2k|    assert(compress != NULL);
  ------------------
  |  Branch (1182:5): [True: 0, False: 31.2k]
  |  Branch (1182:5): [True: 31.2k, False: 0]
  ------------------
 1183|  31.2k|    assert(srcSize > 0);
  ------------------
  |  Branch (1183:5): [True: 0, False: 31.2k]
  |  Branch (1183:5): [True: 31.2k, False: 0]
  ------------------
 1184|  31.2k|    RETURN_ERROR_IF(dstCapacity <= overhead, dstCapacity_tooSmall);
  ------------------
  |  |  377|  31.2k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  378|  31.2k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (378:13): [True: 0, False: 31.2k]
  |  |  ------------------
  |  |  379|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  191|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  380|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  375|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  381|      0|        }                          \
  |  |  382|  31.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (382:14): [Folded, False: 31.2k]
  |  |  ------------------
  ------------------
 1185|  31.2k|    if (dstCapacity - overhead < (size_t)cCapacity)
  ------------------
  |  Branch (1185:9): [True: 0, False: 31.2k]
  ------------------
 1186|      0|        cCapacity = (int)(dstCapacity - overhead);
 1187|  31.2k|    cSize = (U32)compress(lz4ctx, (const char*)src, (char*)(cSizePtr+BHSize),
 1188|  31.2k|                          (int)srcSize, cCapacity,
 1189|  31.2k|                          level, cdict);
 1190|       |
 1191|  31.2k|    if (cSize == 0 || cSize >= srcSize) {
  ------------------
  |  Branch (1191:9): [True: 5.65k, False: 25.5k]
  |  Branch (1191:23): [True: 0, False: 25.5k]
  ------------------
 1192|  5.65k|        RETURN_ERROR_IF(dstCapacity - overhead < srcSize, dstCapacity_tooSmall);
  ------------------
  |  |  377|  5.65k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  378|  5.65k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (378:13): [True: 0, False: 5.65k]
  |  |  ------------------
  |  |  379|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  191|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  380|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  375|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  381|      0|        }                          \
  |  |  382|  5.65k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (382:14): [Folded, False: 5.65k]
  |  |  ------------------
  ------------------
 1193|  5.65k|        cSize = (U32)srcSize;
 1194|  5.65k|        LZ4F_writeLE32(cSizePtr, cSize | LZ4F_BLOCKUNCOMPRESSED_FLAG);
  ------------------
  |  |  279|  5.65k|#define LZ4F_BLOCKUNCOMPRESSED_FLAG 0x80000000U
  ------------------
 1195|  5.65k|        memcpy(cSizePtr+BHSize, src, srcSize);
 1196|  25.5k|    } else {
 1197|  25.5k|        LZ4F_writeLE32(cSizePtr, cSize);
 1198|  25.5k|    }
 1199|  31.2k|    if (crcFlag) {
  ------------------
  |  Branch (1199:9): [True: 11.4k, False: 19.7k]
  ------------------
 1200|  11.4k|        U32 const crc32 = XXH32(cSizePtr+BHSize, cSize, 0);  /* checksum of compressed data */
  ------------------
  |  |  128|  11.4k|#  define XXH32 XXH_NAME2(XXH_NAMESPACE, XXH32)
  |  |  ------------------
  |  |  |  |  126|  11.4k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  11.4k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1201|  11.4k|        LZ4F_writeLE32(cSizePtr+BHSize+cSize, crc32);
 1202|  11.4k|    }
 1203|  31.2k|    return BHSize + cSize + ((U32)crcFlag)*BFSize;
 1204|  31.2k|}
lz4frame.c:LZ4F_selectCompression:
 1293|  48.9k|{
 1294|  48.9k|    if (compressMode == LZ4B_UNCOMPRESSED)
  ------------------
  |  Branch (1294:9): [True: 0, False: 48.9k]
  ------------------
 1295|      0|        return LZ4F_doNotCompressBlock;
 1296|  48.9k|    if (level < LZ4HC_CLEVEL_MIN) {
  ------------------
  |  |   46|  48.9k|#define LZ4HC_CLEVEL_MIN         2
  ------------------
  |  Branch (1296:9): [True: 16.8k, False: 32.1k]
  ------------------
 1297|  16.8k|        if (blockMode == LZ4F_blockIndependent) return LZ4F_compressBlock;
  ------------------
  |  Branch (1297:13): [True: 6.15k, False: 10.6k]
  ------------------
 1298|  10.6k|        return LZ4F_compressBlock_continue;
 1299|  16.8k|    }
 1300|  32.1k|    if (blockMode == LZ4F_blockIndependent) return LZ4F_compressBlockHC;
  ------------------
  |  Branch (1300:9): [True: 10.2k, False: 21.9k]
  ------------------
 1301|  21.9k|    return LZ4F_compressBlockHC_continue;
 1302|  32.1k|}
lz4frame.c:LZ4F_compressBlock:
 1252|  3.69k|{
 1253|  3.69k|    int const acceleration = LZ4F_levelToAcceleration(level);
 1254|  3.69k|    DEBUGLOG(5, "LZ4F_compressBlock (srcSize=%i)", srcSize);
  ------------------
  |  |  191|  3.69k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 1255|  3.69k|    LZ4F_initStream(ctx, cdict, level, LZ4F_blockIndependent);
 1256|  3.69k|    if (cdict) {
  ------------------
  |  Branch (1256:9): [True: 0, False: 3.69k]
  ------------------
 1257|      0|        return LZ4_compress_fast_continue((LZ4_stream_t*)ctx, src, dst, srcSize, dstCapacity, acceleration);
 1258|  3.69k|    } else {
 1259|  3.69k|        return LZ4_compress_fast_extState_fastReset(ctx, src, dst, srcSize, dstCapacity, acceleration);
 1260|  3.69k|    }
 1261|  3.69k|}
lz4frame.c:LZ4F_levelToAcceleration:
 1245|  11.3k|{
 1246|  11.3k|    if (level >= 0) return 1;
  ------------------
  |  Branch (1246:9): [True: 1.85k, False: 9.50k]
  ------------------
 1247|  9.50k|    if (level < 1 - LZ4_ACCELERATION_MAX) return LZ4_ACCELERATION_MAX;
  ------------------
  |  |  615|  9.50k|#define LZ4_ACCELERATION_MAX 65537
  ------------------
                  if (level < 1 - LZ4_ACCELERATION_MAX) return LZ4_ACCELERATION_MAX;
  ------------------
  |  |  615|      0|#define LZ4_ACCELERATION_MAX 65537
  ------------------
  |  Branch (1247:9): [True: 0, False: 9.50k]
  ------------------
 1248|  9.50k|    return -level + 1;
 1249|  9.50k|}
lz4frame.c:LZ4F_compressBlock_continue:
 1264|  7.66k|{
 1265|  7.66k|    int const acceleration = LZ4F_levelToAcceleration(level);
 1266|  7.66k|    (void)cdict; /* init once at beginning of frame */
 1267|  7.66k|    DEBUGLOG(5, "LZ4F_compressBlock_continue (srcSize=%i)", srcSize);
  ------------------
  |  |  191|  7.66k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 1268|  7.66k|    return LZ4_compress_fast_continue((LZ4_stream_t*)ctx, src, dst, srcSize, dstCapacity, acceleration);
 1269|  7.66k|}
lz4frame.c:LZ4F_compressBlockHC:
 1272|  5.36k|{
 1273|  5.36k|    LZ4F_initStream(ctx, cdict, level, LZ4F_blockIndependent);
 1274|  5.36k|    if (cdict) {
  ------------------
  |  Branch (1274:9): [True: 0, False: 5.36k]
  ------------------
 1275|      0|        return LZ4_compress_HC_continue((LZ4_streamHC_t*)ctx, src, dst, srcSize, dstCapacity);
 1276|      0|    }
 1277|  5.36k|    return LZ4_compress_HC_extStateHC_fastReset(ctx, src, dst, srcSize, dstCapacity, level);
 1278|  5.36k|}
lz4frame.c:LZ4F_compressBlockHC_continue:
 1281|  14.4k|{
 1282|  14.4k|    (void)level; (void)cdict; /* init once at beginning of frame */
 1283|  14.4k|    return LZ4_compress_HC_continue((LZ4_streamHC_t*)ctx, src, dst, srcSize, dstCapacity);
 1284|  14.4k|}
lz4frame.c:LZ4F_st_update:
 2392|  39.8k|  {
 2393|  39.8k|    size_t const blockSize = cctxPtr->maxBlockSize;
 2394|  39.8k|    const BYTE* srcPtr = (const BYTE*)srcBuffer;
 2395|  39.8k|    const BYTE* const srcEnd = srcSize ? (assert(srcPtr!=NULL), srcPtr + srcSize) : srcPtr;
  ------------------
  |  Branch (2395:32): [True: 39.8k, False: 0]
  |  Branch (2395:43): [True: 0, False: 39.8k]
  |  Branch (2395:43): [True: 39.8k, False: 0]
  ------------------
 2396|  39.8k|    BYTE* const dstStart = (BYTE*)dstBuffer;
 2397|  39.8k|    BYTE* const dstEnd = dstStart + dstCapacity;
 2398|  39.8k|    BYTE* dstPtr = dstStart;
 2399|  39.8k|    LZ4F_lastBlockStatus lastBlockCompressed = notDone;
 2400|  39.8k|    compressFunc_t const compress = LZ4F_selectCompression(cctxPtr->prefs.frameInfo.blockMode, cctxPtr->prefs.compressionLevel, blockCompression);
 2401|  39.8k|    size_t bytesWritten;
 2402|  39.8k|    DEBUGLOG(4, "LZ4F_compressUpdate (srcSize=%zu)", srcSize);
  ------------------
  |  |  191|  39.8k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 2403|       |
 2404|  39.8k|    RETURN_ERROR_IF(cctxPtr->cStage != 1, compressionState_uninitialized);   /* state must be initialized and waiting for next block */
  ------------------
  |  |  377|  39.8k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  378|  39.8k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (378:13): [True: 0, False: 39.8k]
  |  |  ------------------
  |  |  379|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  191|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  380|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  375|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  381|      0|        }                          \
  |  |  382|  39.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (382:14): [Folded, False: 39.8k]
  |  |  ------------------
  ------------------
 2405|       |
 2406|       |    /* output left pending by an incomplete LZ4F_flush() */
 2407|  39.8k|    bytesWritten = LZ4F_emitPendingWhole(cctxPtr, dstPtr, dstCapacity);
 2408|  39.8k|    FORWARD_IF_ERROR_INVALIDATE(bytesWritten, cctxPtr);
  ------------------
  |  |  399|  39.8k|#define FORWARD_IF_ERROR_INVALIDATE(r, cctx) do { \
  |  |  400|  39.8k|        size_t const err_code = (r);               \
  |  |  401|  39.8k|        if (LZ4F_isError(err_code)) {              \
  |  |  ------------------
  |  |  |  Branch (401:13): [True: 0, False: 39.8k]
  |  |  ------------------
  |  |  402|      0|            LZ4F_invalidateFrame(cctx);            \
  |  |  403|      0|            return err_code;                       \
  |  |  404|      0|        }                                          \
  |  |  405|  39.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (405:14): [Folded, False: 39.8k]
  |  |  ------------------
  ------------------
 2409|  39.8k|    dstPtr += bytesWritten;
 2410|       |
 2411|       |    /* flush currently written block, to continue with new block compression */
 2412|  39.8k|    if (cctxPtr->blockCompressMode != blockCompression) {
  ------------------
  |  Branch (2412:9): [True: 0, False: 39.8k]
  ------------------
 2413|      0|        bytesWritten = LZ4F_flushBlock(cctxPtr, dstPtr, (size_t)(dstEnd - dstPtr));
 2414|      0|        FORWARD_IF_ERROR(bytesWritten);   /* note : a failed flush invalidates the frame */
  ------------------
  |  |  385|      0|#define FORWARD_IF_ERROR(r) do {                     \
  |  |  386|      0|        size_t const err_code = (r);                 \
  |  |  387|      0|        if (LZ4F_isError(err_code)) return err_code; \
  |  |  ------------------
  |  |  |  Branch (387:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  388|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (388:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2415|      0|        dstPtr += bytesWritten;
 2416|      0|        cctxPtr->blockCompressMode = blockCompression;
 2417|      0|        if ((blockCompression == LZ4B_UNCOMPRESSED) && (cctxPtr->prefs.frameInfo.blockMode == LZ4F_blockLinked)) {
  ------------------
  |  Branch (2417:13): [True: 0, False: 0]
  |  Branch (2417:56): [True: 0, False: 0]
  ------------------
 2418|       |            /* linked blocks : the decoder's history will contain uncompressed data, unknown to the LZ4 state :
 2419|       |             * history is dropped, blocks compressed next don't reference anything before them */
 2420|      0|            LZ4F_startStream(cctxPtr->lz4CtxPtr, &cctxPtr->prefs, NULL, NULL, 0);
 2421|      0|        }
 2422|      0|    }
 2423|       |
 2424|       |    /* complete tmp buffer */
 2425|  39.8k|    if (cctxPtr->tmpInSize > 0) {   /* some data already within tmp buffer */
  ------------------
  |  Branch (2425:9): [True: 9.90k, False: 29.9k]
  ------------------
 2426|  9.90k|        size_t const sizeToCopy = blockSize - cctxPtr->tmpInSize;
 2427|  9.90k|        assert(blockSize > cctxPtr->tmpInSize);
  ------------------
  |  Branch (2427:9): [True: 0, False: 9.90k]
  |  Branch (2427:9): [True: 9.90k, False: 0]
  ------------------
 2428|  9.90k|        if (sizeToCopy > srcSize) {
  ------------------
  |  Branch (2428:13): [True: 8.63k, False: 1.27k]
  ------------------
 2429|       |            /* add src to tmpIn buffer */
 2430|  8.63k|            memcpy(cctxPtr->tmpIn + cctxPtr->tmpInSize, srcBuffer, srcSize);
 2431|  8.63k|            srcPtr = srcEnd;
 2432|  8.63k|            cctxPtr->tmpInSize += srcSize;
 2433|       |            /* still needs some CRC */
 2434|  8.63k|        } else {
 2435|       |            /* complete tmpIn block and then compress it */
 2436|  1.27k|            lastBlockCompressed = fromTmpBuffer;
 2437|  1.27k|            memcpy(cctxPtr->tmpIn + cctxPtr->tmpInSize, srcBuffer, sizeToCopy);
 2438|  1.27k|            srcPtr += sizeToCopy;
 2439|       |
 2440|  1.27k|            bytesWritten = LZ4F_makeBlock(dstPtr, (size_t)(dstEnd - dstPtr),
 2441|  1.27k|                                          cctxPtr->tmpIn, blockSize,
 2442|  1.27k|                                          compress, cctxPtr->lz4CtxPtr, cctxPtr->prefs.compressionLevel,
 2443|  1.27k|                                          cctxPtr->cdict,
 2444|  1.27k|                                          cctxPtr->prefs.frameInfo.blockChecksumFlag);
 2445|  1.27k|            FORWARD_IF_ERROR_INVALIDATE(bytesWritten, cctxPtr);
  ------------------
  |  |  399|  1.27k|#define FORWARD_IF_ERROR_INVALIDATE(r, cctx) do { \
  |  |  400|  1.27k|        size_t const err_code = (r);               \
  |  |  401|  1.27k|        if (LZ4F_isError(err_code)) {              \
  |  |  ------------------
  |  |  |  Branch (401:13): [True: 0, False: 1.27k]
  |  |  ------------------
  |  |  402|      0|            LZ4F_invalidateFrame(cctx);            \
  |  |  403|      0|            return err_code;                       \
  |  |  404|      0|        }                                          \
  |  |  405|  1.27k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (405:14): [Folded, False: 1.27k]
  |  |  ------------------
  ------------------
 2446|  1.27k|            dstPtr += bytesWritten;
 2447|  1.27k|            if (cctxPtr->prefs.frameInfo.blockMode==LZ4F_blockLinked) cctxPtr->tmpIn += blockSize;
  ------------------
  |  Branch (2447:17): [True: 1.03k, False: 237]
  ------------------
 2448|  1.27k|            cctxPtr->tmpInSize = 0;
 2449|  1.27k|    }   }
 2450|       |
 2451|       |    /* compress full blocks; with autoFlush, remaining input (< blockSize) is compressed too */
 2452|  39.8k|    {   size_t const remaining = (size_t)(srcEnd - srcPtr);
 2453|  39.8k|        size_t const toCompress = cctxPtr->prefs.autoFlush ? remaining : remaining - (remaining % blockSize);
  ------------------
  |  Branch (2453:35): [True: 19.6k, False: 20.2k]
  ------------------
 2454|       |        /* autoFlush, linked blocks, unstable input smaller than the history window (64 KB) :
 2455|       |         * compressed from @srcBuffer, it would become the only history of next blocks.
 2456|       |         * It's compressed from tmpBuff instead, right after the history, which remains whole. */
 2457|  39.8k|        int const viaTmp = cctxPtr->prefs.autoFlush
  ------------------
  |  Branch (2457:28): [True: 19.6k, False: 20.2k]
  ------------------
 2458|  19.6k|                        && (cctxPtr->prefs.frameInfo.blockMode == LZ4F_blockLinked)
  ------------------
  |  Branch (2458:28): [True: 14.6k, False: 4.94k]
  ------------------
 2459|  14.6k|                        && !compressOptionsPtr->stableSrc
  ------------------
  |  Branch (2459:28): [True: 14.6k, False: 0]
  ------------------
 2460|  14.6k|                        && (blockCompression == LZ4B_COMPRESSED)
  ------------------
  |  Branch (2460:28): [True: 14.6k, False: 0]
  ------------------
 2461|  14.6k|                        && (toCompress > 0) && (toCompress < 64 KB);
  ------------------
  |  |  268|  14.6k|#  define KB *(1<<10)
  ------------------
  |  Branch (2461:28): [True: 14.6k, False: 0]
  |  Branch (2461:48): [True: 6.69k, False: 7.99k]
  ------------------
 2462|  39.8k|        if (viaTmp) {
  ------------------
  |  Branch (2462:13): [True: 6.69k, False: 33.1k]
  ------------------
 2463|  6.69k|            if (cctxPtr->tmpIn + toCompress > cctxPtr->tmpBuff + cctxPtr->tmpBuffCapacity)
  ------------------
  |  Branch (2463:17): [True: 0, False: 6.69k]
  ------------------
 2464|      0|                LZ4F_localSaveDict(cctxPtr);   /* tmpBuff >= 128 KB : room after the history */
 2465|  6.69k|            memcpy(cctxPtr->tmpIn, srcPtr, toCompress);
 2466|  6.69k|            lastBlockCompressed = fromTmpBuffer;
 2467|  6.69k|            bytesWritten = LZ4F_makeBlock(dstPtr, (size_t)(dstEnd - dstPtr),
 2468|  6.69k|                                          cctxPtr->tmpIn, toCompress,
 2469|  6.69k|                                          compress, cctxPtr->lz4CtxPtr, cctxPtr->prefs.compressionLevel,
 2470|  6.69k|                                          cctxPtr->cdict,
 2471|  6.69k|                                          cctxPtr->prefs.frameInfo.blockChecksumFlag);
 2472|  6.69k|            FORWARD_IF_ERROR_INVALIDATE(bytesWritten, cctxPtr);
  ------------------
  |  |  399|  6.69k|#define FORWARD_IF_ERROR_INVALIDATE(r, cctx) do { \
  |  |  400|  6.69k|        size_t const err_code = (r);               \
  |  |  401|  6.69k|        if (LZ4F_isError(err_code)) {              \
  |  |  ------------------
  |  |  |  Branch (401:13): [True: 0, False: 6.69k]
  |  |  ------------------
  |  |  402|      0|            LZ4F_invalidateFrame(cctx);            \
  |  |  403|      0|            return err_code;                       \
  |  |  404|      0|        }                                          \
  |  |  405|  6.69k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (405:14): [Folded, False: 6.69k]
  |  |  ------------------
  ------------------
 2473|  6.69k|            dstPtr += bytesWritten;
 2474|  6.69k|            srcPtr += toCompress;
 2475|  6.69k|            cctxPtr->tmpIn += toCompress;
 2476|  33.1k|        } else if (toCompress) {
  ------------------
  |  Branch (2476:20): [True: 14.1k, False: 19.0k]
  ------------------
 2477|  14.1k|            lastBlockCompressed = fromSrcBuffer;
 2478|  14.1k|            bytesWritten = LZ4F_compressBlocks_internal(dstPtr, (size_t)(dstEnd - dstPtr),
 2479|  14.1k|                                          srcPtr, toCompress, blockSize,
 2480|  14.1k|                                          compress, cctxPtr->lz4CtxPtr, cctxPtr->prefs.compressionLevel,
 2481|  14.1k|                                          cctxPtr->cdict,
 2482|  14.1k|                                          cctxPtr->prefs.frameInfo.blockChecksumFlag);
 2483|  14.1k|            FORWARD_IF_ERROR_INVALIDATE(bytesWritten, cctxPtr);
  ------------------
  |  |  399|  14.1k|#define FORWARD_IF_ERROR_INVALIDATE(r, cctx) do { \
  |  |  400|  14.1k|        size_t const err_code = (r);               \
  |  |  401|  14.1k|        if (LZ4F_isError(err_code)) {              \
  |  |  ------------------
  |  |  |  Branch (401:13): [True: 0, False: 14.1k]
  |  |  ------------------
  |  |  402|      0|            LZ4F_invalidateFrame(cctx);            \
  |  |  403|      0|            return err_code;                       \
  |  |  404|      0|        }                                          \
  |  |  405|  14.1k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (405:14): [Folded, False: 14.1k]
  |  |  ------------------
  ------------------
 2484|  14.1k|            dstPtr += bytesWritten;
 2485|  14.1k|            srcPtr += toCompress;
 2486|  14.1k|    }   }
 2487|       |
 2488|       |    /* preserve dictionary within @tmpBuff whenever necessary */
 2489|  39.8k|    if ((cctxPtr->prefs.frameInfo.blockMode==LZ4F_blockLinked) && (lastBlockCompressed==fromSrcBuffer)) {
  ------------------
  |  Branch (2489:9): [True: 27.1k, False: 12.6k]
  |  Branch (2489:67): [True: 8.99k, False: 18.1k]
  ------------------
 2490|       |        /* note : after uncompressed blocks, the LZ4 state is empty (history dropped), so is the saved dictionary */
 2491|  8.99k|        if (compressOptionsPtr->stableSrc) {
  ------------------
  |  Branch (2491:13): [True: 0, False: 8.99k]
  ------------------
 2492|      0|            cctxPtr->tmpIn = cctxPtr->tmpBuff;  /* src is stable : dictionary remains in src across invocations */
 2493|  8.99k|        } else {
 2494|  8.99k|            LZ4F_localSaveDict(cctxPtr);
 2495|  8.99k|        }
 2496|  8.99k|    }
 2497|       |
 2498|       |    /* keep tmpIn within limits */
 2499|  39.8k|    if (!(cctxPtr->prefs.autoFlush)  /* no autoflush : there may be some data left within internal buffer */
  ------------------
  |  Branch (2499:9): [True: 20.2k, False: 19.6k]
  ------------------
 2500|  20.2k|      && (cctxPtr->tmpIn + blockSize) > (cctxPtr->tmpBuff + cctxPtr->tmpBuffCapacity) )  /* not enough room to store next block */
  ------------------
  |  Branch (2500:10): [True: 444, False: 19.7k]
  ------------------
 2501|    444|    {
 2502|       |        /* only preserve 64KB within internal buffer. Ensures there is enough room for next block.
 2503|       |         * note: this situation necessarily implies lastBlockCompressed==fromTmpBuffer */
 2504|    444|        LZ4F_localSaveDict(cctxPtr);
 2505|    444|        assert((cctxPtr->tmpIn + blockSize) <= (cctxPtr->tmpBuff + cctxPtr->tmpBuffCapacity));
  ------------------
  |  Branch (2505:9): [True: 0, False: 444]
  |  Branch (2505:9): [True: 444, False: 0]
  ------------------
 2506|    444|    }
 2507|       |
 2508|       |    /* some input data left, necessarily < blockSize */
 2509|  39.8k|    if (srcPtr < srcEnd) {
  ------------------
  |  Branch (2509:9): [True: 10.3k, False: 29.4k]
  ------------------
 2510|       |        /* fill tmp buffer */
 2511|  10.3k|        size_t const sizeToCopy = (size_t)(srcEnd - srcPtr);
 2512|  10.3k|        memcpy(cctxPtr->tmpIn, srcPtr, sizeToCopy);
 2513|  10.3k|        cctxPtr->tmpInSize = sizeToCopy;
 2514|  10.3k|    }
 2515|       |
 2516|  39.8k|    if (cctxPtr->prefs.frameInfo.contentChecksumFlag == LZ4F_contentChecksumEnabled)
  ------------------
  |  Branch (2516:9): [True: 15.8k, False: 24.0k]
  ------------------
 2517|  15.8k|        (void)XXH32_update(&(cctxPtr->xxh), srcBuffer, srcSize);
  ------------------
  |  |  132|  15.8k|#  define XXH32_update XXH_NAME2(XXH_NAMESPACE, XXH32_update)
  |  |  ------------------
  |  |  |  |  126|  15.8k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  15.8k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2518|       |
 2519|  39.8k|    cctxPtr->totalInSize += srcSize;
 2520|  39.8k|    return (size_t)(dstPtr - dstStart);
 2521|  39.8k|}
lz4frame.c:LZ4F_emitPendingWhole:
 1353|  39.8k|{
 1354|  39.8k|    cctx->flushStage = 0;
 1355|  39.8k|    RETURN_ERROR_IF(cctx->pendingSize > dstCapacity, dstCapacity_tooSmall);
  ------------------
  |  |  377|  39.8k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  378|  39.8k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (378:13): [True: 0, False: 39.8k]
  |  |  ------------------
  |  |  379|      0|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  191|      0|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  380|      0|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  375|      0|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  381|      0|        }                          \
  |  |  382|  39.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (382:14): [Folded, False: 39.8k]
  |  |  ------------------
  ------------------
 1356|  39.8k|    return LZ4F_copyPending(cctx, dst, dstCapacity, 0);
 1357|  39.8k|}
lz4frame.c:LZ4F_flushBlock:
 1363|  15.6k|{
 1364|  15.6k|    compressFunc_t compress;
 1365|  15.6k|    size_t cSize;
 1366|       |
 1367|  15.6k|    DEBUGLOG(5, "LZ4F_flushBlock: %zu buffered bytes (saved dict size = %i) (dstCapacity=%u)",
  ------------------
  |  |  191|  15.6k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 1368|  15.6k|            cctxPtr->tmpInSize, (int)(cctxPtr->tmpIn - cctxPtr->tmpBuff), (unsigned)dstCapacity);
 1369|  15.6k|    if (cctxPtr->tmpInSize == 0) return 0;   /* nothing to flush */
  ------------------
  |  Branch (1369:9): [True: 6.56k, False: 9.11k]
  ------------------
 1370|       |
 1371|       |    /* select compression function */
 1372|  9.11k|    compress = LZ4F_selectCompression(cctxPtr->prefs.frameInfo.blockMode, cctxPtr->prefs.compressionLevel, cctxPtr->blockCompressMode);
 1373|       |
 1374|       |    /* compress tmp buffer */
 1375|  9.11k|    cSize = LZ4F_makeBlock(dstBuffer, dstCapacity,
 1376|  9.11k|                           cctxPtr->tmpIn, cctxPtr->tmpInSize,
 1377|  9.11k|                           compress, cctxPtr->lz4CtxPtr, cctxPtr->prefs.compressionLevel,
 1378|  9.11k|                           cctxPtr->cdict,
 1379|  9.11k|                           cctxPtr->prefs.frameInfo.blockChecksumFlag);
 1380|  9.11k|    FORWARD_IF_ERROR_INVALIDATE(cSize, cctxPtr);
  ------------------
  |  |  399|  9.11k|#define FORWARD_IF_ERROR_INVALIDATE(r, cctx) do { \
  |  |  400|  9.11k|        size_t const err_code = (r);               \
  |  |  401|  9.11k|        if (LZ4F_isError(err_code)) {              \
  |  |  ------------------
  |  |  |  Branch (401:13): [True: 0, False: 9.11k]
  |  |  ------------------
  |  |  402|      0|            LZ4F_invalidateFrame(cctx);            \
  |  |  403|      0|            return err_code;                       \
  |  |  404|      0|        }                                          \
  |  |  405|  9.11k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (405:14): [Folded, False: 9.11k]
  |  |  ------------------
  ------------------
 1381|  9.11k|    assert(((void)"flush overflows dstBuffer!", cSize <= dstCapacity));
  ------------------
  |  Branch (1381:5): [True: 0, False: 9.11k]
  |  Branch (1381:5): [True: 9.11k, False: 0]
  ------------------
 1382|       |
 1383|  9.11k|    if (cctxPtr->prefs.frameInfo.blockMode == LZ4F_blockLinked)
  ------------------
  |  Branch (1383:9): [True: 5.41k, False: 3.69k]
  ------------------
 1384|  5.41k|        cctxPtr->tmpIn += cctxPtr->tmpInSize;
 1385|  9.11k|    cctxPtr->tmpInSize = 0;
 1386|       |
 1387|       |    /* keep tmpIn within limits */
 1388|  9.11k|    if ((cctxPtr->tmpIn + cctxPtr->maxBlockSize) > (cctxPtr->tmpBuff + cctxPtr->tmpBuffCapacity)) {
  ------------------
  |  Branch (1388:9): [True: 179, False: 8.93k]
  ------------------
 1389|    179|        assert(cctxPtr->prefs.frameInfo.blockMode == LZ4F_blockLinked);
  ------------------
  |  Branch (1389:9): [True: 0, False: 179]
  |  Branch (1389:9): [True: 179, False: 0]
  ------------------
 1390|    179|        LZ4F_localSaveDict(cctxPtr);
 1391|    179|    }
 1392|       |
 1393|  9.11k|    return cSize;
 1394|  9.11k|}
lz4frame.c:LZ4F_localSaveDict:
 1306|  9.62k|{
 1307|  9.62k|    int const dictSize = (cctxPtr->prefs.compressionLevel < LZ4HC_CLEVEL_MIN) ?
  ------------------
  |  |   46|  9.62k|#define LZ4HC_CLEVEL_MIN         2
  ------------------
  |  Branch (1307:26): [True: 3.94k, False: 5.68k]
  ------------------
 1308|  3.94k|                    LZ4_saveDict ((LZ4_stream_t*)(cctxPtr->lz4CtxPtr), (char*)(cctxPtr->tmpBuff), 64 KB) :
  ------------------
  |  |  268|  3.94k|#  define KB *(1<<10)
  ------------------
 1309|  9.62k|                    LZ4_saveDictHC ((LZ4_streamHC_t*)(cctxPtr->lz4CtxPtr), (char*)(cctxPtr->tmpBuff), 64 KB);
  ------------------
  |  |  268|  5.68k|#  define KB *(1<<10)
  ------------------
 1310|  9.62k|    cctxPtr->tmpIn = cctxPtr->tmpBuff + dictSize;
 1311|  9.62k|}
lz4frame.c:LZ4F_flushPoint:
 2595|  15.6k|{
 2596|  15.6k|    size_t r = 0;
 2597|  15.6k|    if (cctx->mtActive) {
  ------------------
  |  Branch (2597:9): [True: 0, False: 15.6k]
  ------------------
 2598|      0|        LZ4F_mt_flushPoint(cctx->mt);
 2599|  15.6k|    } else {
 2600|  15.6k|        r = LZ4F_flushBlockPartial(cctx, dst, dstCapacity);
 2601|  15.6k|    }
 2602|  15.6k|    if (!LZ4F_isError(r)) cctx->flushStage = 1;
  ------------------
  |  Branch (2602:9): [True: 15.6k, False: 0]
  ------------------
 2603|  15.6k|    return r;
 2604|  15.6k|}
lz4frame.c:LZ4F_flushBlockPartial:
 1400|  15.6k|{
 1401|  15.6k|    size_t const worstCase = cctx->tmpInSize + BHSize + (size_t)cctx->prefs.frameInfo.blockChecksumFlag * BFSize;
 1402|  15.6k|    size_t cSize;
 1403|  15.6k|    if ((cctx->tmpInSize == 0) || (dstCapacity >= worstCase))
  ------------------
  |  Branch (1403:9): [True: 6.56k, False: 9.11k]
  |  Branch (1403:35): [True: 9.11k, False: 0]
  ------------------
 1404|  15.6k|        return LZ4F_flushBlock(cctx, dst, dstCapacity);
 1405|      0|    FORWARD_IF_ERROR_INVALIDATE(LZ4F_reserveStage(cctx), cctx);
  ------------------
  |  |  399|      0|#define FORWARD_IF_ERROR_INVALIDATE(r, cctx) do { \
  |  |  400|      0|        size_t const err_code = (r);               \
  |  |  401|      0|        if (LZ4F_isError(err_code)) {              \
  |  |  ------------------
  |  |  |  Branch (401:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  402|      0|            LZ4F_invalidateFrame(cctx);            \
  |  |  403|      0|            return err_code;                       \
  |  |  404|      0|        }                                          \
  |  |  405|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (405:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1406|      0|    cSize = LZ4F_flushBlock(cctx, cctx->stageBuff, cctx->stageCapacity);
 1407|      0|    FORWARD_IF_ERROR(cSize);   /* already invalidated */
  ------------------
  |  |  385|      0|#define FORWARD_IF_ERROR(r) do {                     \
  |  |  386|      0|        size_t const err_code = (r);                 \
  |  |  387|      0|        if (LZ4F_isError(err_code)) return err_code; \
  |  |  ------------------
  |  |  |  Branch (387:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  388|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (388:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1408|      0|    cctx->pending = cctx->stageBuff;
 1409|      0|    cctx->pendingSize = cSize;
 1410|      0|    return 0;
 1411|      0|}
lz4frame.c:LZ4F_emitPending:
 2569|  15.6k|{
 2570|  15.6k|    pos += LZ4F_copyPending(cctx, dst, dstCapacity, pos);
 2571|  15.6k|    if (cctx->mtActive && (cctx->pendingSize == 0)) {
  ------------------
  |  Branch (2571:9): [True: 0, False: 15.6k]
  |  Branch (2571:27): [True: 0, False: 0]
  ------------------
 2572|      0|        size_t const r = LZ4F_mt_emitPartial(cctx->mt, dst, dstCapacity, pos);
 2573|      0|        FORWARD_IF_ERROR_INVALIDATE(r, cctx);
  ------------------
  |  |  399|      0|#define FORWARD_IF_ERROR_INVALIDATE(r, cctx) do { \
  |  |  400|      0|        size_t const err_code = (r);               \
  |  |  401|      0|        if (LZ4F_isError(err_code)) {              \
  |  |  ------------------
  |  |  |  Branch (401:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  402|      0|            LZ4F_invalidateFrame(cctx);            \
  |  |  403|      0|            return err_code;                       \
  |  |  404|      0|        }                                          \
  |  |  405|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (405:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2574|      0|        pos += r;
 2575|      0|    }
 2576|  15.6k|    return pos;
 2577|  15.6k|}
lz4frame.c:LZ4F_outputPending:
 2580|  15.6k|{
 2581|  15.6k|    return (cctx->pendingSize > 0) || (cctx->mtActive && (cctx->mt->nbSubmitted > 0));
  ------------------
  |  Branch (2581:12): [True: 0, False: 15.6k]
  |  Branch (2581:40): [True: 0, False: 15.6k]
  |  Branch (2581:58): [True: 0, False: 0]
  ------------------
 2582|  15.6k|}
lz4frame.c:LZ4F_writeLE32:
  228|  80.4k|{
  229|  80.4k|    BYTE* const dstPtr = (BYTE*)dst;
  230|  80.4k|    dstPtr[0] = (BYTE)value32;
  231|  80.4k|    dstPtr[1] = (BYTE)(value32 >> 8);
  232|  80.4k|    dstPtr[2] = (BYTE)(value32 >> 16);
  233|  80.4k|    dstPtr[3] = (BYTE)(value32 >> 24);
  234|  80.4k|}
lz4frame.c:LZ4F_copyPending:
 1338|  71.1k|{
 1339|  71.1k|    size_t const n = MIN(cctx->pendingSize, dstCapacity - pos);
  ------------------
  |  |  426|  71.1k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (426:22): [True: 71.1k, False: 0]
  |  |  ------------------
  ------------------
 1340|  71.1k|    assert(pos <= dstCapacity);
  ------------------
  |  Branch (1340:5): [True: 0, False: 71.1k]
  |  Branch (1340:5): [True: 71.1k, False: 0]
  ------------------
 1341|  71.1k|    if (n) {
  ------------------
  |  Branch (1341:9): [True: 15.6k, False: 55.5k]
  ------------------
 1342|  15.6k|        memcpy(dst + pos, cctx->pending, n);
 1343|  15.6k|        cctx->pending += n;
 1344|  15.6k|    }
 1345|  71.1k|    cctx->pendingSize -= n;
 1346|  71.1k|    return n;
 1347|  71.1k|}
lz4frame.c:LZ4F_readLE32:
  218|   241k|{
  219|   241k|    const BYTE* const srcPtr = (const BYTE*)src;
  220|   241k|    U32 value32 = srcPtr[0];
  221|   241k|    value32 |= ((U32)srcPtr[1])<< 8;
  222|   241k|    value32 |= ((U32)srcPtr[2])<<16;
  223|   241k|    value32 |= ((U32)srcPtr[3])<<24;
  224|   241k|    return value32;
  225|   241k|}
lz4frame.c:LZ4F_decodeHeader:
 2824|  50.1k|{
 2825|  50.1k|    unsigned blockMode, blockChecksumFlag, contentSizeFlag, contentChecksumFlag, dictIDFlag, blockSizeID;
 2826|  50.1k|    size_t frameHeaderSize;
 2827|  50.1k|    const BYTE* srcPtr = (const BYTE*)src;
 2828|       |
 2829|  50.1k|    DEBUGLOG(5, "LZ4F_decodeHeader");
  ------------------
  |  |  191|  50.1k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 2830|  50.1k|    assert(srcSize >= minFHSize);   /* minimal frame header size */
  ------------------
  |  Branch (2830:5): [True: 0, False: 50.1k]
  |  Branch (2830:5): [True: 50.1k, False: 0]
  ------------------
 2831|  50.1k|    MEM_INIT(&(dctx->frameInfo), 0, sizeof(dctx->frameInfo));
  ------------------
  |  |  109|  50.1k|#  define MEM_INIT(p,v,s)   memset((p),(v),(s))
  ------------------
 2832|       |
 2833|       |    /* special case : skippable frames */
 2834|  50.1k|    if ((LZ4F_readLE32(srcPtr) & 0xFFFFFFF0U) == LZ4F_MAGIC_SKIPPABLE_START) {
  ------------------
  |  |  509|  50.1k|#define LZ4F_MAGIC_SKIPPABLE_START 0x184D2A50U
  ------------------
  |  Branch (2834:9): [True: 4.15k, False: 45.9k]
  ------------------
 2835|  4.15k|        dctx->frameInfo.frameType = LZ4F_skippableFrame;
 2836|  4.15k|        dctx->dStage = dstage_getSFrameSize;
 2837|  4.15k|        if (src == (void*)(dctx->header)) {
  ------------------
  |  Branch (2837:13): [True: 3.81k, False: 342]
  ------------------
 2838|       |            /* the beginning of the frame size field is already gathered in header+4 */
 2839|  3.81k|            assert(srcSize <= 8);
  ------------------
  |  Branch (2839:13): [True: 0, False: 3.81k]
  |  Branch (2839:13): [True: 3.81k, False: 0]
  ------------------
 2840|  3.81k|            dctx->tmpInSize = srcSize - 4;
 2841|  3.81k|            return srcSize;
 2842|  3.81k|        } else {
 2843|    342|            dctx->tmpInSize = 0;
 2844|    342|            return 4;
 2845|    342|    }   }
 2846|       |
 2847|       |    /* control magic number */
 2848|       |#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
 2849|       |    if (LZ4F_readLE32(srcPtr) != LZ4F_MAGICNUMBER) {
 2850|       |        DEBUGLOG(4, "frame header error : unknown magic number");
 2851|       |        RETURN_ERROR(frameType_unknown);
 2852|       |    }
 2853|       |#endif
 2854|  45.9k|    dctx->frameInfo.frameType = LZ4F_frame;
 2855|       |
 2856|       |    /* Flags */
 2857|  45.9k|    {   U32 const FLG = srcPtr[4];
 2858|  45.9k|        U32 const version = (FLG>>6) & _2BITS;
  ------------------
  |  |  274|  45.9k|#define _2BITS 0x03
  ------------------
 2859|  45.9k|        blockChecksumFlag = (FLG>>4) & _1BIT;
  ------------------
  |  |  273|  45.9k|#define _1BIT  0x01
  ------------------
 2860|  45.9k|        blockMode = (FLG>>5) & _1BIT;
  ------------------
  |  |  273|  45.9k|#define _1BIT  0x01
  ------------------
 2861|  45.9k|        contentSizeFlag = (FLG>>3) & _1BIT;
  ------------------
  |  |  273|  45.9k|#define _1BIT  0x01
  ------------------
 2862|  45.9k|        contentChecksumFlag = (FLG>>2) & _1BIT;
  ------------------
  |  |  273|  45.9k|#define _1BIT  0x01
  ------------------
 2863|  45.9k|        dictIDFlag = FLG & _1BIT;
  ------------------
  |  |  273|  45.9k|#define _1BIT  0x01
  ------------------
 2864|       |        /* validate */
 2865|  45.9k|        if (((FLG>>1)&_1BIT) != 0) RETURN_ERROR(reservedFlag_set); /* Reserved bit */
  ------------------
  |  |  273|  45.9k|#define _1BIT  0x01
  ------------------
                      if (((FLG>>1)&_1BIT) != 0) RETURN_ERROR(reservedFlag_set); /* Reserved bit */
  ------------------
  |  |  375|  2.55k|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  |  Branch (2865:13): [True: 2.55k, False: 43.4k]
  ------------------
 2866|  43.4k|        if (version != 1) RETURN_ERROR(headerVersion_wrong);       /* Version Number, only supported value */
  ------------------
  |  |  375|  8.42k|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  |  Branch (2866:13): [True: 8.42k, False: 35.0k]
  ------------------
 2867|  43.4k|    }
 2868|  35.0k|    DEBUGLOG(6, "contentSizeFlag: %u", contentSizeFlag);
  ------------------
  |  |  191|  35.0k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  ------------------
 2869|       |
 2870|       |    /* Frame Header Size */
 2871|  35.0k|    frameHeaderSize = minFHSize + (contentSizeFlag?8:0) + (dictIDFlag?4:0);
  ------------------
  |  Branch (2871:36): [True: 1.99k, False: 33.0k]
  |  Branch (2871:60): [True: 3.46k, False: 31.5k]
  ------------------
 2872|       |
 2873|  35.0k|    if (srcSize < frameHeaderSize) {
  ------------------
  |  Branch (2873:9): [True: 1.20k, False: 33.8k]
  ------------------
 2874|       |        /* only the minimal header is gathered into dctx->header : gather the rest */
 2875|  1.20k|        assert(srcPtr == dctx->header);
  ------------------
  |  Branch (2875:9): [True: 0, False: 1.20k]
  |  Branch (2875:9): [True: 1.20k, False: 0]
  ------------------
 2876|  1.20k|        assert(dctx->dStage == dstage_storeFrameHeader);
  ------------------
  |  Branch (2876:9): [True: 0, False: 1.20k]
  |  Branch (2876:9): [True: 1.20k, False: 0]
  ------------------
 2877|  1.20k|        assert(dctx->tmpInSize == srcSize);
  ------------------
  |  Branch (2877:9): [True: 0, False: 1.20k]
  |  Branch (2877:9): [True: 1.20k, False: 0]
  ------------------
 2878|  1.20k|        dctx->tmpInTarget = frameHeaderSize;
 2879|  1.20k|        return srcSize;
 2880|  1.20k|    }
 2881|       |
 2882|  33.8k|    {   U32 const BD = srcPtr[5];
 2883|  33.8k|        blockSizeID = (BD>>4) & _3BITS;
  ------------------
  |  |  275|  33.8k|#define _3BITS 0x07
  ------------------
 2884|       |        /* validate */
 2885|  33.8k|        if (((BD>>7)&_1BIT) != 0) RETURN_ERROR(reservedFlag_set);   /* Reserved bit */
  ------------------
  |  |  273|  33.8k|#define _1BIT  0x01
  ------------------
                      if (((BD>>7)&_1BIT) != 0) RETURN_ERROR(reservedFlag_set);   /* Reserved bit */
  ------------------
  |  |  375|    189|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  |  Branch (2885:13): [True: 189, False: 33.6k]
  ------------------
 2886|  33.6k|        if (blockSizeID < 4) RETURN_ERROR(maxBlockSize_invalid);    /* 4-7 only supported values for the time being */
  ------------------
  |  |  375|    252|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  |  Branch (2886:13): [True: 252, False: 33.3k]
  ------------------
 2887|  33.3k|        if (((BD>>0)&_4BITS) != 0) RETURN_ERROR(reservedFlag_set);  /* Reserved bits */
  ------------------
  |  |  276|  33.3k|#define _4BITS 0x0F
  ------------------
                      if (((BD>>0)&_4BITS) != 0) RETURN_ERROR(reservedFlag_set);  /* Reserved bits */
  ------------------
  |  |  375|    221|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  ------------------
  |  Branch (2887:13): [True: 221, False: 33.1k]
  ------------------
 2888|  33.3k|    }
 2889|       |
 2890|       |    /* check header */
 2891|  33.3k|    assert(frameHeaderSize > 5);
  ------------------
  |  Branch (2891:5): [True: 0, False: 33.1k]
  |  Branch (2891:5): [True: 33.1k, False: 0]
  ------------------
 2892|       |#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
 2893|       |    {   BYTE const HC = LZ4F_headerChecksum(srcPtr+4, frameHeaderSize-5);
 2894|       |        RETURN_ERROR_IF(HC != srcPtr[frameHeaderSize-1], headerChecksum_invalid);
 2895|       |    }
 2896|       |#endif
 2897|       |
 2898|       |    /* save */
 2899|  33.1k|    dctx->frameInfo.blockMode = (LZ4F_blockMode_t)blockMode;
 2900|  33.1k|    dctx->frameInfo.blockChecksumFlag = (LZ4F_blockChecksum_t)blockChecksumFlag;
 2901|  33.1k|    dctx->frameInfo.contentChecksumFlag = (LZ4F_contentChecksum_t)contentChecksumFlag;
 2902|  33.1k|    dctx->frameInfo.blockSizeID = (LZ4F_blockSizeID_t)blockSizeID;
 2903|  33.1k|    dctx->maxBlockSize = LZ4F_getBlockSize((LZ4F_blockSizeID_t)blockSizeID);
 2904|  33.1k|    if (contentSizeFlag) {
  ------------------
  |  Branch (2904:9): [True: 1.37k, False: 31.7k]
  ------------------
 2905|  1.37k|        dctx->frameRemainingSize = dctx->frameInfo.contentSize = LZ4F_readLE64(srcPtr+6);
 2906|  1.37k|    }
 2907|  33.1k|    if (dictIDFlag)
  ------------------
  |  Branch (2907:9): [True: 1.91k, False: 31.2k]
  ------------------
 2908|  1.91k|        dctx->frameInfo.dictID = LZ4F_readLE32(srcPtr + frameHeaderSize - 5);
 2909|       |
 2910|  33.1k|    dctx->dStage = dstage_init;
 2911|       |
 2912|  33.1k|    return frameHeaderSize;
 2913|  33.1k|}
lz4frame.c:LZ4F_readLE64:
  237|  1.37k|{
  238|  1.37k|    const BYTE* const srcPtr = (const BYTE*)src;
  239|  1.37k|    U64 value64 = srcPtr[0];
  240|  1.37k|    value64 |= ((U64)srcPtr[1]<<8);
  241|  1.37k|    value64 |= ((U64)srcPtr[2]<<16);
  242|  1.37k|    value64 |= ((U64)srcPtr[3]<<24);
  243|  1.37k|    value64 |= ((U64)srcPtr[4]<<32);
  244|  1.37k|    value64 |= ((U64)srcPtr[5]<<40);
  245|  1.37k|    value64 |= ((U64)srcPtr[6]<<48);
  246|  1.37k|    value64 |= ((U64)srcPtr[7]<<56);
  247|  1.37k|    return value64;
  248|  1.37k|}
lz4frame.c:LZ4F_gatherInput:
 3135|   245k|{
 3136|   245k|    const BYTE* const srcPtr = *srcPtrPtr;
 3137|   245k|    size_t const available = (size_t)(srcEnd - srcPtr);
 3138|   245k|    if ((dctx->tmpInSize == 0) && (available >= wanted)) {
  ------------------
  |  Branch (3138:9): [True: 222k, False: 22.8k]
  |  Branch (3138:35): [True: 131k, False: 90.5k]
  ------------------
 3139|   131k|        *srcPtrPtr = srcPtr + wanted;
 3140|   131k|        return srcPtr;
 3141|   131k|    }
 3142|   113k|    {   size_t const sizeToCopy = MIN(wanted - dctx->tmpInSize, available);
  ------------------
  |  |  426|   113k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (426:22): [True: 15.1k, False: 98.2k]
  |  |  ------------------
  ------------------
 3143|   113k|        memcpy(buffer + dctx->tmpInSize, srcPtr, sizeToCopy);
 3144|   113k|        dctx->tmpInSize += sizeToCopy;
 3145|   113k|        *srcPtrPtr = srcPtr + sizeToCopy;
 3146|   113k|    }
 3147|   113k|    if (dctx->tmpInSize < wanted) return NULL;
  ------------------
  |  Branch (3147:9): [True: 94.3k, False: 19.1k]
  ------------------
 3148|  19.1k|    dctx->tmpInSize = 0;   /* ready for next gathering */
 3149|  19.1k|    return buffer;
 3150|   113k|}
lz4frame.c:LZ4F_endMarkFollows:
 3092|  39.7k|{
 3093|  39.7k|    return ((size_t)(srcEnd - srcPtr) >= skip + BHSize) && (LZ4F_readLE32(srcPtr + skip) == 0);
  ------------------
  |  Branch (3093:12): [True: 38.7k, False: 1.00k]
  |  Branch (3093:60): [True: 12.6k, False: 26.1k]
  ------------------
 3094|  39.7k|}
lz4frame.c:LZ4F_updateDict:
 3031|  57.5k|{
 3032|  57.5k|    assert(dstPtr != NULL);
  ------------------
  |  Branch (3032:5): [True: 0, False: 57.5k]
  |  Branch (3032:5): [True: 57.5k, False: 0]
  ------------------
 3033|  57.5k|    if (dctx->dictSize==0) dctx->dict = (const BYTE*)dstPtr;  /* will lead to prefix mode */
  ------------------
  |  Branch (3033:9): [True: 24.1k, False: 33.4k]
  ------------------
 3034|  57.5k|    assert(dctx->dict != NULL);
  ------------------
  |  Branch (3034:5): [True: 0, False: 57.5k]
  |  Branch (3034:5): [True: 57.5k, False: 0]
  ------------------
 3035|       |
 3036|  57.5k|    if (dctx->dict + dctx->dictSize == dstPtr) {  /* prefix mode, everything within dstBuffer */
  ------------------
  |  Branch (3036:9): [True: 25.7k, False: 31.8k]
  ------------------
 3037|  25.7k|        dctx->dictSize += dstSize;
 3038|  25.7k|        return;
 3039|  25.7k|    }
 3040|       |
 3041|  57.5k|    assert(dstPtr >= dstBufferStart);
  ------------------
  |  Branch (3041:5): [True: 0, False: 31.8k]
  |  Branch (3041:5): [True: 31.8k, False: 0]
  ------------------
 3042|  31.8k|    if ((size_t)(dstPtr - dstBufferStart) + dstSize >= 64 KB) {  /* history in dstBuffer becomes large enough to become dictionary */
  ------------------
  |  |  268|  31.8k|#  define KB *(1<<10)
  ------------------
  |  Branch (3042:9): [True: 7.33k, False: 24.4k]
  ------------------
 3043|  7.33k|        dctx->dict = (const BYTE*)dstBufferStart;
 3044|  7.33k|        dctx->dictSize = (size_t)(dstPtr - dstBufferStart) + dstSize;
 3045|  7.33k|        return;
 3046|  7.33k|    }
 3047|       |
 3048|  31.8k|    assert(dstSize < 64 KB);   /* if dstSize >= 64 KB, dictionary would be set into dstBuffer directly */
  ------------------
  |  Branch (3048:5): [True: 0, False: 24.4k]
  |  Branch (3048:5): [True: 24.4k, False: 0]
  ------------------
 3049|       |
 3050|       |    /* dstBuffer does not contain whole useful history (64 KB), so it must be saved within tmpOutBuffer */
 3051|  24.4k|    assert(dctx->tmpOutBuffer != NULL);
  ------------------
  |  Branch (3051:5): [True: 0, False: 24.4k]
  |  Branch (3051:5): [True: 24.4k, False: 0]
  ------------------
 3052|       |
 3053|  24.4k|    if (withinTmp && (dctx->dict == dctx->tmpOutBuffer)) {   /* continue history within tmpOutBuffer */
  ------------------
  |  Branch (3053:9): [True: 15.5k, False: 8.98k]
  |  Branch (3053:22): [True: 15.5k, False: 0]
  ------------------
 3054|       |        /* withinTmp expectation : content of [dstPtr,dstSize] is same as [dict+dictSize,dstSize], so we just extend it */
 3055|  15.5k|        assert(dctx->dict + dctx->dictSize == dctx->tmpOut + dctx->tmpOutStart);
  ------------------
  |  Branch (3055:9): [True: 0, False: 15.5k]
  |  Branch (3055:9): [True: 15.5k, False: 0]
  ------------------
 3056|  15.5k|        dctx->dictSize += dstSize;
 3057|  15.5k|        return;
 3058|  15.5k|    }
 3059|       |
 3060|  8.98k|    if (withinTmp) { /* copy relevant dict portion in front of tmpOut within tmpOutBuffer */
  ------------------
  |  Branch (3060:9): [True: 0, False: 8.98k]
  ------------------
 3061|      0|        LZ4F_moveDictBeforeTmpOut(dctx, dstSize);
 3062|      0|        return;
 3063|      0|    }
 3064|       |
 3065|  8.98k|    if (dctx->dict == dctx->tmpOutBuffer) {    /* copy dst into tmp to complete dict */
  ------------------
  |  Branch (3065:9): [True: 8.98k, False: 0]
  ------------------
 3066|  8.98k|        if (dctx->dictSize + dstSize > dctx->tmpOutBufferCapacity) {  /* tmp buffer not large enough */
  ------------------
  |  Branch (3066:13): [True: 353, False: 8.63k]
  ------------------
 3067|    353|            size_t const preserveSize = 64 KB - dstSize;
  ------------------
  |  |  268|    353|#  define KB *(1<<10)
  ------------------
 3068|    353|            memcpy(dctx->tmpOutBuffer, dctx->dict + dctx->dictSize - preserveSize, preserveSize);
 3069|    353|            dctx->dictSize = preserveSize;
 3070|    353|        }
 3071|  8.98k|        memcpy(dctx->tmpOutBuffer + dctx->dictSize, dstPtr, dstSize);
 3072|  8.98k|        dctx->dictSize += dstSize;
 3073|  8.98k|        return;
 3074|  8.98k|    }
 3075|       |
 3076|       |    /* join dict & dest into tmp */
 3077|      0|    {   size_t preserveSize = 64 KB - dstSize;
  ------------------
  |  |  268|      0|#  define KB *(1<<10)
  ------------------
 3078|      0|        if (preserveSize > dctx->dictSize) preserveSize = dctx->dictSize;
  ------------------
  |  Branch (3078:13): [True: 0, False: 0]
  ------------------
 3079|      0|        memcpy(dctx->tmpOutBuffer, dctx->dict + dctx->dictSize - preserveSize, preserveSize);
 3080|      0|        memcpy(dctx->tmpOutBuffer + preserveSize, dstPtr, dstSize);
 3081|      0|        dctx->dict = dctx->tmpOutBuffer;
 3082|      0|        dctx->dictSize = preserveSize + dstSize;
 3083|      0|    }
 3084|      0|}
lz4frame.c:LZ4F_decodeBlock:
 3102|  52.0k|{
 3103|  52.0k|    const char* dict = (const char*)dctx->dict;
 3104|  52.0k|    size_t dictSize = dctx->dictSize;
 3105|  52.0k|    int decodedSize;
 3106|  52.0k|    assert(dst != NULL);
  ------------------
  |  Branch (3106:5): [True: 0, False: 52.0k]
  |  Branch (3106:5): [True: 52.0k, False: 0]
  ------------------
 3107|  52.0k|    if (dict && dictSize > 1 GB) {
  ------------------
  |  |  270|  22.5k|#  define GB *(1<<30)
  ------------------
  |  Branch (3107:9): [True: 22.5k, False: 29.5k]
  |  Branch (3107:17): [True: 0, False: 22.5k]
  ------------------
 3108|       |        /* the dictSize param is an int, avoid truncation / sign issues */
 3109|      0|        dict += dictSize - 64 KB;
  ------------------
  |  |  268|      0|#  define KB *(1<<10)
  ------------------
 3110|      0|        dictSize = 64 KB;
  ------------------
  |  |  268|      0|#  define KB *(1<<10)
  ------------------
 3111|      0|    }
 3112|  52.0k|    decodedSize = LZ4_decompress_safe_usingDict(
 3113|  52.0k|            (const char*)src, (char*)dst,
 3114|  52.0k|            (int)srcSize, (int)dctx->maxBlockSize,
 3115|  52.0k|            dict, (int)dictSize);
 3116|  52.0k|    RETURN_ERROR_IF(decodedSize < 0, decompressionFailed);
  ------------------
  |  |  377|  52.0k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  378|  52.0k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (378:13): [True: 2.62k, False: 49.4k]
  |  |  ------------------
  |  |  379|  2.62k|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  191|  2.62k|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  380|  2.62k|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  375|  2.62k|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  381|  2.62k|        }                          \
  |  |  382|  52.0k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (382:14): [Folded, False: 49.4k]
  |  |  ------------------
  ------------------
 3117|  49.4k|    RETURN_ERROR_IF(dctx->frameInfo.contentSize && (U64)decodedSize > dctx->frameRemainingSize, frameSize_wrong);
  ------------------
  |  |  377|  49.4k|#define RETURN_ERROR_IF(c,e) do {  \
  |  |  378|   101k|        if (c) {                   \
  |  |  ------------------
  |  |  |  Branch (378:13): [True: 2.51k, False: 46.9k]
  |  |  |  Branch (378:13): [True: 2, False: 2.51k]
  |  |  ------------------
  |  |  379|      2|            DEBUGLOG(3, "Error: " #c); \
  |  |  ------------------
  |  |  |  |  191|      2|#  define DEBUGLOG(l, ...)      {}    /* disabled */
  |  |  ------------------
  |  |  380|      2|            RETURN_ERROR(e);       \
  |  |  ------------------
  |  |  |  |  375|      2|#define RETURN_ERROR(e) return LZ4F_returnErrorCode(LZ4F_ERROR_ ## e)
  |  |  ------------------
  |  |  381|      2|        }                          \
  |  |  382|  49.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (382:14): [Folded, False: 49.4k]
  |  |  ------------------
  ------------------
 3118|  49.4k|    if (dctx->frameInfo.contentChecksumFlag && !dctx->skipContentChecksum)
  ------------------
  |  Branch (3118:9): [True: 22.6k, False: 26.8k]
  |  Branch (3118:48): [True: 21.4k, False: 1.20k]
  ------------------
 3119|  21.4k|        XXH32_update(&(dctx->xxh), dst, (size_t)decodedSize);
  ------------------
  |  |  132|  21.4k|#  define XXH32_update XXH_NAME2(XXH_NAMESPACE, XXH32_update)
  |  |  ------------------
  |  |  |  |  126|  21.4k|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  125|  21.4k|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3120|  49.4k|    if (dctx->frameInfo.contentSize)
  ------------------
  |  Branch (3120:9): [True: 2.51k, False: 46.9k]
  ------------------
 3121|  2.51k|        dctx->frameRemainingSize -= (size_t)decodedSize;
 3122|  49.4k|    return (size_t)decodedSize;
 3123|  49.4k|}
lz4frame.c:LZ4F_moveDictBeforeTmpOut:
 3010|  5.50k|{
 3011|  5.50k|    size_t const preserveSize = (size_t)(dctx->tmpOut - dctx->tmpOutBuffer);
 3012|  5.50k|    size_t copySize = 64 KB - dctx->tmpOutSize;
  ------------------
  |  |  268|  5.50k|#  define KB *(1<<10)
  ------------------
 3013|  5.50k|    const BYTE* const oldDictEnd = dctx->dict + dctx->dictSize - dctx->tmpOutStart;
 3014|  5.50k|    if (dctx->tmpOutSize > 64 KB) copySize = 0;
  ------------------
  |  |  268|  5.50k|#  define KB *(1<<10)
  ------------------
  |  Branch (3014:9): [True: 1.68k, False: 3.82k]
  ------------------
 3015|  5.50k|    if (copySize > preserveSize) copySize = preserveSize;
  ------------------
  |  Branch (3015:9): [True: 2.88k, False: 2.62k]
  ------------------
 3016|  5.50k|    assert(dctx->tmpOutBuffer != NULL);
  ------------------
  |  Branch (3016:5): [True: 0, False: 5.50k]
  |  Branch (3016:5): [True: 5.50k, False: 0]
  ------------------
 3017|       |
 3018|  5.50k|    memcpy(dctx->tmpOutBuffer + preserveSize - copySize, oldDictEnd - copySize, copySize);
 3019|       |
 3020|  5.50k|    dctx->dict = dctx->tmpOutBuffer;
 3021|  5.50k|    dctx->dictSize = preserveSize + dctx->tmpOutStart + flushSize;
 3022|  5.50k|}

LZ4_compress_HC_extStateHC_fastReset:
 1601|  5.36k|{
 1602|  5.36k|    LZ4HC_CCtx_internal* const ctx = &((LZ4_streamHC_t*)state)->internal_donotuse;
 1603|  5.36k|    if (!LZ4_isAligned(state, LZ4_streamHC_t_alignment())) return 0;
  ------------------
  |  Branch (1603:9): [True: 0, False: 5.36k]
  ------------------
 1604|  5.36k|    LZ4_resetStreamHC_fast((LZ4_streamHC_t*)state, compressionLevel);
 1605|  5.36k|    LZ4HC_init_internal (ctx, (const BYTE*)src);
 1606|  5.36k|    if (dstCapacity < LZ4_compressBound(srcSize))
  ------------------
  |  Branch (1606:9): [True: 5.36k, False: 0]
  ------------------
 1607|  5.36k|        return LZ4HC_compress_generic (ctx, src, dst, &srcSize, dstCapacity, compressionLevel, limitedOutput);
 1608|      0|    else
 1609|      0|        return LZ4HC_compress_generic (ctx, src, dst, &srcSize, dstCapacity, compressionLevel, notLimited);
 1610|  5.36k|}
LZ4_initStreamHC:
 1676|  10.3k|{
 1677|  10.3k|    LZ4_streamHC_t* const LZ4_streamHCPtr = (LZ4_streamHC_t*)buffer;
 1678|  10.3k|    DEBUGLOG(4, "LZ4_initStreamHC(%p, %u)", buffer, (unsigned)size);
  ------------------
  |  |  289|  10.3k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1679|       |    /* check conditions */
 1680|  10.3k|    if (buffer == NULL) return NULL;
  ------------------
  |  Branch (1680:9): [True: 0, False: 10.3k]
  ------------------
 1681|  10.3k|    if (size < sizeof(LZ4_streamHC_t)) return NULL;
  ------------------
  |  Branch (1681:9): [True: 0, False: 10.3k]
  ------------------
 1682|  10.3k|    if (!LZ4_isAligned(buffer, LZ4_streamHC_t_alignment())) return NULL;
  ------------------
  |  Branch (1682:9): [True: 0, False: 10.3k]
  ------------------
 1683|       |    /* init */
 1684|  10.3k|    { LZ4HC_CCtx_internal* const hcstate = &(LZ4_streamHCPtr->internal_donotuse);
 1685|  10.3k|      MEM_INIT(hcstate, 0, sizeof(*hcstate));
  ------------------
  |  |  236|  10.3k|#define MEM_INIT(p,v,s)   LZ4_memset((p),(v),(s))
  |  |  ------------------
  |  |  |  |  234|  10.3k|#  define LZ4_memset(p,v,s) memset((p),(v),(s))
  |  |  ------------------
  ------------------
 1686|  10.3k|      hcstate->hasWorkspace = (size >= LZ4_STREAMHC_EXTSIZE); }
  ------------------
  |  |  378|  10.3k|#define LZ4_STREAMHC_EXTSIZE (LZ4_STREAMHC_MINSIZE + 65584)
  |  |  ------------------
  |  |  |  |  262|  10.3k|#define LZ4_STREAMHC_MINSIZE  262200  /* static size, for inter-version compatibility */
  |  |  ------------------
  ------------------
 1687|  10.3k|    LZ4_setCompressionLevel(LZ4_streamHCPtr, LZ4HC_CLEVEL_DEFAULT);
  ------------------
  |  |   47|  10.3k|#define LZ4HC_CLEVEL_DEFAULT     9
  ------------------
 1688|  10.3k|    return LZ4_streamHCPtr;
 1689|  10.3k|}
LZ4_resetStreamHC_fast:
 1705|  17.6k|{
 1706|  17.6k|    LZ4HC_CCtx_internal* const s = &LZ4_streamHCPtr->internal_donotuse;
 1707|  17.6k|    DEBUGLOG(5, "LZ4_resetStreamHC_fast(%p, %d)", LZ4_streamHCPtr, compressionLevel);
  ------------------
  |  |  289|  17.6k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1708|       |    /* also after a failed compression : its positions are below @end, hence out of reach of the next stream */
 1709|  17.6k|    assert(s->end >= s->prefixStart);
  ------------------
  |  Branch (1709:5): [True: 0, False: 17.6k]
  |  Branch (1709:5): [True: 17.6k, False: 0]
  ------------------
 1710|  17.6k|    s->dictLimit += (U32)(s->end - s->prefixStart);
 1711|  17.6k|    s->prefixStart = NULL;
 1712|  17.6k|    s->end = NULL;
 1713|       |    s->dictCtx = NULL;
 1714|  17.6k|    LZ4_setCompressionLevel(LZ4_streamHCPtr, compressionLevel);
 1715|  17.6k|}
LZ4_setCompressionLevel:
 1718|  38.4k|{
 1719|  38.4k|    DEBUGLOG(5, "LZ4_setCompressionLevel(%p, %d)", LZ4_streamHCPtr, compressionLevel);
  ------------------
  |  |  289|  38.4k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1720|  38.4k|    if (compressionLevel < 1) compressionLevel = LZ4HC_CLEVEL_DEFAULT;
  ------------------
  |  |   47|      0|#define LZ4HC_CLEVEL_DEFAULT     9
  ------------------
  |  Branch (1720:9): [True: 0, False: 38.4k]
  ------------------
 1721|  38.4k|    if (compressionLevel > LZ4HC_CLEVEL_MAX) compressionLevel = LZ4HC_CLEVEL_MAX;
  ------------------
  |  |   49|  38.4k|#define LZ4HC_CLEVEL_MAX        12
  ------------------
                  if (compressionLevel > LZ4HC_CLEVEL_MAX) compressionLevel = LZ4HC_CLEVEL_MAX;
  ------------------
  |  |   49|      0|#define LZ4HC_CLEVEL_MAX        12
  ------------------
  |  Branch (1721:9): [True: 0, False: 38.4k]
  ------------------
 1722|  38.4k|    LZ4_streamHCPtr->internal_donotuse.compressionLevel = (short)compressionLevel;
 1723|  38.4k|}
LZ4_favorDecompressionSpeed:
 1726|  10.3k|{
 1727|  10.3k|    LZ4_streamHCPtr->internal_donotuse.favorDecSpeed = (favor!=0);
 1728|  10.3k|}
LZ4_compress_HC_continue:
 1837|  14.4k|{
 1838|  14.4k|    DEBUGLOG(5, "LZ4_compress_HC_continue");
  ------------------
  |  |  289|  14.4k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1839|  14.4k|    if (dstCapacity < LZ4_compressBound(srcSize))
  ------------------
  |  Branch (1839:9): [True: 14.4k, False: 0]
  ------------------
 1840|  14.4k|        return LZ4_compressHC_continue_generic (LZ4_streamHCPtr, src, dst, &srcSize, dstCapacity, limitedOutput);
 1841|      0|    else
 1842|      0|        return LZ4_compressHC_continue_generic (LZ4_streamHCPtr, src, dst, &srcSize, dstCapacity, notLimited);
 1843|  14.4k|}
LZ4_saveDictHC:
 1857|  5.68k|{
 1858|  5.68k|    LZ4HC_CCtx_internal* const streamPtr = &LZ4_streamHCPtr->internal_donotuse;
 1859|  5.68k|    int const prefixSize = (int)(streamPtr->end - streamPtr->prefixStart);
 1860|  5.68k|    DEBUGLOG(5, "LZ4_saveDictHC(%p, %p, %d)", LZ4_streamHCPtr, safeBuffer, dictSize);
  ------------------
  |  |  289|  5.68k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1861|       |    /* nothing compressed yet (new or reset stream) : nothing to save,
 1862|       |     * the stream remains to be initialized by next compression (attached dictionary included) */
 1863|  5.68k|    if (streamPtr->prefixStart == NULL) return 0;
  ------------------
  |  Branch (1863:9): [True: 0, False: 5.68k]
  ------------------
 1864|  5.68k|    assert(prefixSize >= 0);
  ------------------
  |  Branch (1864:5): [True: 0, False: 5.68k]
  |  Branch (1864:5): [True: 5.68k, False: 0]
  ------------------
 1865|  5.68k|    if (dictSize > 64 KB) dictSize = 64 KB;
  ------------------
  |  |  251|  5.68k|#define KB *(1 <<10)
  ------------------
                  if (dictSize > 64 KB) dictSize = 64 KB;
  ------------------
  |  |  251|      0|#define KB *(1 <<10)
  ------------------
  |  Branch (1865:9): [True: 0, False: 5.68k]
  ------------------
 1866|  5.68k|    if (dictSize < 4) dictSize = 0;
  ------------------
  |  Branch (1866:9): [True: 0, False: 5.68k]
  ------------------
 1867|  5.68k|    if (dictSize > prefixSize) dictSize = prefixSize;
  ------------------
  |  Branch (1867:9): [True: 0, False: 5.68k]
  ------------------
 1868|  5.68k|    if (safeBuffer == NULL) assert(dictSize == 0); /* a NULL buffer with !0 size is invalid */
  ------------------
  |  Branch (1868:9): [True: 0, False: 5.68k]
  |  Branch (1868:29): [True: 0, False: 0]
  |  Branch (1868:29): [True: 0, False: 0]
  ------------------
 1869|  5.68k|    if (dictSize > 0)
  ------------------
  |  Branch (1869:9): [True: 5.68k, False: 0]
  ------------------
 1870|  5.68k|        LZ4_memmove(safeBuffer, streamPtr->end - dictSize, (size_t)dictSize);
  ------------------
  |  |  357|  5.68k|#    define LZ4_memmove __builtin_memmove
  ------------------
 1871|  5.68k|    {   U32 const endIndex = (U32)(streamPtr->end - streamPtr->prefixStart) + streamPtr->dictLimit;
 1872|  5.68k|        streamPtr->end = (safeBuffer == NULL) ? NULL : (const BYTE*)safeBuffer + dictSize;
  ------------------
  |  Branch (1872:26): [True: 0, False: 5.68k]
  ------------------
 1873|  5.68k|        streamPtr->prefixStart = (const BYTE*)safeBuffer;
 1874|  5.68k|        streamPtr->dictLimit = endIndex - (U32)dictSize;
 1875|  5.68k|        streamPtr->lowLimit = endIndex - (U32)dictSize;
 1876|  5.68k|        streamPtr->dictStart = streamPtr->prefixStart;
 1877|  5.68k|        if (streamPtr->nextToUpdate < streamPtr->dictLimit)
  ------------------
  |  Branch (1877:13): [True: 196, False: 5.48k]
  ------------------
 1878|    196|            streamPtr->nextToUpdate = streamPtr->dictLimit;
 1879|  5.68k|    }
 1880|  5.68k|    return dictSize;
 1881|  5.68k|}
lz4hc.c:LZ4_streamHC_t_alignment:
 1589|  15.7k|{
 1590|  15.7k|#if LZ4_ALIGN_TEST
 1591|  15.7k|    typedef struct { char c; LZ4_streamHC_t t; } t_a;
 1592|  15.7k|    return sizeof(t_a) - sizeof(LZ4_streamHC_t);
 1593|       |#else
 1594|       |    return 1;  /* effectively disabled */
 1595|       |#endif
 1596|  15.7k|}
lz4hc.c:LZ4HC_init_internal:
  254|  12.2k|{
  255|  12.2k|    size_t const bufferSize = (size_t)(hc4->end - hc4->prefixStart);
  256|  12.2k|    size_t newStartingOffset = bufferSize + hc4->dictLimit;
  257|  12.2k|    DEBUGLOG(5, "LZ4HC_init_internal");
  ------------------
  |  |  289|  12.2k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  258|  12.2k|    assert(newStartingOffset >= bufferSize);  /* check overflow */
  ------------------
  |  Branch (258:5): [True: 0, False: 12.2k]
  |  Branch (258:5): [True: 12.2k, False: 0]
  ------------------
  259|  12.2k|    if (newStartingOffset > 1 GB) {
  ------------------
  |  |  253|  12.2k|#define GB *(1U<<30)
  ------------------
  |  Branch (259:9): [True: 0, False: 12.2k]
  ------------------
  260|      0|        LZ4HC_clearTables(hc4);
  261|      0|        newStartingOffset = 0;
  262|      0|    }
  263|  12.2k|    newStartingOffset += 64 KB;
  ------------------
  |  |  251|  12.2k|#define KB *(1 <<10)
  ------------------
  264|  12.2k|    hc4->nextToUpdate = (U32)newStartingOffset;
  265|  12.2k|    hc4->prefixStart = start;
  266|  12.2k|    hc4->end = start;
  267|  12.2k|    hc4->dictStart = start;
  268|  12.2k|    hc4->dictLimit = (U32)newStartingOffset;
  269|  12.2k|    hc4->lowLimit = (U32)newStartingOffset;
  270|  12.2k|}
lz4hc.c:LZ4HC_compress_generic:
 1577|  19.8k|{
 1578|  19.8k|    if (ctx->dictCtx == NULL) {
  ------------------
  |  Branch (1578:9): [True: 19.8k, False: 0]
  ------------------
 1579|  19.8k|        return LZ4HC_compress_generic_noDictCtx(ctx, src, dst, srcSizePtr, dstCapacity, cLevel, limit);
 1580|  19.8k|    } else {
 1581|      0|        return LZ4HC_compress_generic_dictCtx(ctx, src, dst, srcSizePtr, dstCapacity, cLevel, limit);
 1582|      0|    }
 1583|  19.8k|}
lz4hc.c:LZ4HC_compress_generic_noDictCtx:
 1524|  19.8k|{
 1525|  19.8k|    assert(ctx->dictCtx == NULL);
  ------------------
  |  Branch (1525:5): [True: 0, False: 19.8k]
  |  Branch (1525:5): [True: 19.8k, False: 0]
  ------------------
 1526|  19.8k|    return LZ4HC_compress_generic_internal(ctx, src, dst, srcSizePtr, dstCapacity, cLevel, limit, noDictCtx);
 1527|  19.8k|}
lz4hc.c:LZ4HC_compress_generic_internal:
 1462|  19.8k|{
 1463|  19.8k|    DEBUGLOG(5, "LZ4HC_compress_generic_internal(src=%p, srcSize=%d, dstCapacity=%d)",
  ------------------
  |  |  289|  19.8k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1464|  19.8k|                src, *srcSizePtr, dstCapacity);
 1465|       |
 1466|       |    /* input sanitization */
 1467|  19.8k|    if ((U32)*srcSizePtr > (U32)LZ4_MAX_INPUT_SIZE) return 0;  /* Unsupported input size (too large or negative) */
  ------------------
  |  |  221|  19.8k|#define LZ4_MAX_INPUT_SIZE        0x7E000000   /* 2 113 929 216 bytes */
  ------------------
  |  Branch (1467:9): [True: 0, False: 19.8k]
  ------------------
 1468|  19.8k|    if (dstCapacity < 1) return 0;   /* Invalid: impossible to store anything */
  ------------------
  |  Branch (1468:9): [True: 0, False: 19.8k]
  ------------------
 1469|  19.8k|    assert(dst); /* since dstCapacity >= 1, dst must be valid */
  ------------------
  |  Branch (1469:5): [True: 0, False: 19.8k]
  |  Branch (1469:5): [True: 19.8k, False: 0]
  ------------------
 1470|  19.8k|    if (*srcSizePtr == 0) { *dst = 0; return 1; }
  ------------------
  |  Branch (1470:9): [True: 0, False: 19.8k]
  ------------------
 1471|  19.8k|    assert(src != NULL); /* since *srcSizePtr >= 1, src must be valid */
  ------------------
  |  Branch (1471:5): [True: 0, False: 19.8k]
  |  Branch (1471:5): [True: 19.8k, False: 0]
  ------------------
 1472|       |
 1473|  19.8k|    ctx->end += *srcSizePtr;
 1474|  19.8k|    {   cParams_t const cParam = LZ4HC_getCLevelParams(cLevel);
 1475|  19.8k|        HCfavor_e const favor = ctx->favorDecSpeed ? favorDecompressionSpeed : favorCompressionRatio;
  ------------------
  |  Branch (1475:33): [True: 6.98k, False: 12.8k]
  ------------------
 1476|  19.8k|        int const srcSize = *srcSizePtr;
 1477|  19.8k|        int result;
 1478|       |
 1479|  19.8k|        if (cParam.strat == lz4mid) {
  ------------------
  |  Branch (1479:13): [True: 4.04k, False: 15.8k]
  ------------------
 1480|  4.04k|            result = LZ4MID_compress(ctx,
 1481|  4.04k|                                src, dst, srcSizePtr, dstCapacity,
 1482|  4.04k|                                limit, dict);
 1483|  15.8k|        } else if (cParam.strat == lz4hc) {
  ------------------
  |  Branch (1483:20): [True: 8.91k, False: 6.88k]
  ------------------
 1484|  8.91k|            result = LZ4HC_compress_hashChain(ctx,
 1485|  8.91k|                                src, dst, srcSizePtr, dstCapacity,
 1486|  8.91k|                                cParam.nbSearches, limit, dict);
 1487|  8.91k|        } else {
 1488|  6.88k|            assert(cParam.strat == lz4opt);
  ------------------
  |  Branch (1488:13): [True: 0, False: 6.88k]
  |  Branch (1488:13): [True: 6.88k, False: 0]
  ------------------
 1489|  6.88k|            result = LZ4HC_compress_optimal(ctx,
 1490|  6.88k|                                src, dst, srcSizePtr, dstCapacity,
 1491|  6.88k|                                cParam.nbSearches, cParam.nbSearchesSeq, (int)cParam.targetLength, limit,
 1492|  6.88k|                                dict, favor);
 1493|  6.88k|        }
 1494|  19.8k|        if ((limit == fillOutput) && (result > 0) && (*srcSizePtr < srcSize)) {
  ------------------
  |  Branch (1494:13): [True: 0, False: 19.8k]
  |  Branch (1494:38): [True: 0, False: 0]
  |  Branch (1494:54): [True: 0, False: 0]
  ------------------
 1495|       |            /* fillOutput : compression stopped before the end of input.
 1496|       |             * The rest of input is left to the next block : it isn't history yet,
 1497|       |             * and the positions already inserted into it are dropped (lz4mid drops its own).
 1498|       |             * Note : a failed compression is different : lz4frame stores its block uncompressed,
 1499|       |             * and the next block still references it. */
 1500|      0|            const BYTE* const consumedEnd = (const BYTE*)src + *srcSizePtr;
 1501|      0|            U32 const consumedIdx = ctx->dictLimit + (U32)(consumedEnd - ctx->prefixStart);
 1502|      0|            if ((cParam.strat != lz4mid) && (ctx->nextToUpdate > consumedIdx)) {
  ------------------
  |  Branch (1502:17): [True: 0, False: 0]
  |  Branch (1502:45): [True: 0, False: 0]
  ------------------
 1503|      0|                LZ4HC_dropPositions(ctx, consumedEnd, consumedEnd + (ctx->nextToUpdate - consumedIdx), cParam.strat);
 1504|      0|                ctx->nextToUpdate = consumedIdx;
 1505|      0|            }
 1506|      0|            ctx->end = consumedEnd;
 1507|      0|        }
 1508|  19.8k|        return result;
 1509|  19.8k|    }
 1510|  19.8k|}
lz4hc.c:LZ4MID_compress:
  720|  4.04k|{
  721|  4.04k|    U32* const hash4Table = ctx->hashTable;
  722|  4.04k|    U32* const hash8Table = hash4Table + LZ4MID_HASHTABLESIZE;
  ------------------
  |  |  154|  4.04k|#define LZ4MID_HASHTABLESIZE (1 << LZ4MID_HASHLOG)
  |  |  ------------------
  |  |  |  |  153|  4.04k|#define LZ4MID_HASHLOG (LZ4HC_HASH_LOG-1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  236|  4.04k|#define LZ4HC_HASH_LOG 15
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  723|  4.04k|    const BYTE* ip = (const BYTE*)src;
  724|  4.04k|    const BYTE* anchor = ip;
  725|  4.04k|    const BYTE* const iend = ip + *srcSizePtr;
  726|  4.04k|    const BYTE* mflimit;      /* set after the size check : would precede a small input */
  727|  4.04k|    const BYTE* matchlimit;
  728|  4.04k|    const BYTE* ilimit;
  729|  4.04k|    BYTE* op = (BYTE*)dst;
  730|       |    /* fillOutput : keep room for the final run of literals (LZ4 format restriction) */
  731|  4.04k|    BYTE* const oend = op + maxOutputSize - ((limit == fillOutput) ? LASTLITERALS : 0);
  ------------------
  |  |  245|      0|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  |  Branch (731:46): [True: 0, False: 4.04k]
  ------------------
  732|       |
  733|  4.04k|    const BYTE* const prefixPtr = ctx->prefixStart;
  734|  4.04k|    const U32 prefixIdx = ctx->dictLimit;
  735|  4.04k|    U32 ilimitIdx;
  736|  4.04k|    const BYTE* const dictStart = ctx->dictStart;
  737|  4.04k|    const U32 dictIdx = ctx->lowLimit;
  738|  4.04k|    const U32 gDictEndIndex = ctx->lowLimit;
  739|  4.04k|    const LZ4MID_searchIntoDict_f searchIntoDict = (dict == usingDictCtxHc) ? select_searchDict_function(ctx->dictCtx) : NULL;
  ------------------
  |  Branch (739:52): [True: 0, False: 4.04k]
  ------------------
  740|  4.04k|    const BYTE* refEnd = ip;   /* fillOutput : the hash tables reference positions before MAX(refEnd, ip) */
  741|       |
  742|  4.04k|    DEBUGLOG(5, "LZ4MID_compress (%i bytes)", *srcSizePtr);
  ------------------
  |  |  289|  4.04k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  743|       |
  744|       |    /* preconditions verifications */
  745|  4.04k|    if (dict == usingDictCtxHc) DEBUGLOG(5, "usingDictCtxHc");
  ------------------
  |  |  289|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  |  Branch (745:9): [True: 0, False: 4.04k]
  ------------------
  746|  4.04k|    assert(*srcSizePtr > 0);
  ------------------
  |  Branch (746:5): [True: 0, False: 4.04k]
  |  Branch (746:5): [True: 4.04k, False: 0]
  ------------------
  747|  4.04k|    assert(*srcSizePtr <= LZ4_MAX_INPUT_SIZE);
  ------------------
  |  Branch (747:5): [True: 0, False: 4.04k]
  |  Branch (747:5): [True: 4.04k, False: 0]
  ------------------
  748|  4.04k|    assert(src != NULL);
  ------------------
  |  Branch (748:5): [True: 0, False: 4.04k]
  |  Branch (748:5): [True: 4.04k, False: 0]
  ------------------
  749|  4.04k|    assert(maxOutputSize >= 1);
  ------------------
  |  Branch (749:5): [True: 0, False: 4.04k]
  |  Branch (749:5): [True: 4.04k, False: 0]
  ------------------
  750|  4.04k|    assert(dst != NULL);
  ------------------
  |  Branch (750:5): [True: 0, False: 4.04k]
  |  Branch (750:5): [True: 4.04k, False: 0]
  ------------------
  751|       |
  752|  4.04k|    if (*srcSizePtr < LZ4_minLength)
  ------------------
  |  Branch (752:9): [True: 189, False: 3.85k]
  ------------------
  753|    189|        goto _lz4mid_last_literals;  /* Input too small, no compression (all literals) */
  754|  3.85k|    mflimit = iend - MFLIMIT;
  ------------------
  |  |  246|  3.85k|#define MFLIMIT       12   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  755|  3.85k|    matchlimit = (iend - LASTLITERALS);
  ------------------
  |  |  245|  3.85k|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  756|  3.85k|    ilimit = (iend - LZ4MID_HASHSIZE);
  ------------------
  |  |  152|  3.85k|#define LZ4MID_HASHSIZE 8
  ------------------
  757|  3.85k|    ilimitIdx = (U32)(ilimit - prefixPtr) + prefixIdx;
  758|       |
  759|       |    /* main loop */
  760|  19.8M|    while (ip <= mflimit) {
  ------------------
  |  Branch (760:12): [True: 19.8M, False: 3.84k]
  ------------------
  761|  19.8M|        const U32 ipIndex = (U32)(ip - prefixPtr) + prefixIdx;
  762|  19.8M|        unsigned matchLength;
  763|  19.8M|        unsigned matchDistance;
  764|       |        /* search long match */
  765|  19.8M|        {   U32 const h8 = LZ4MID_hash8Ptr(ip);
  766|  19.8M|            U32 const pos8 = hash8Table[h8];
  767|  19.8M|            assert(h8 < LZ4MID_HASHTABLESIZE);
  ------------------
  |  Branch (767:13): [True: 0, False: 19.8M]
  |  Branch (767:13): [True: 19.8M, False: 0]
  ------------------
  768|  19.8M|            assert(pos8 < ipIndex);
  ------------------
  |  Branch (768:13): [True: 0, False: 19.8M]
  |  Branch (768:13): [True: 19.8M, False: 0]
  ------------------
  769|  19.8M|            LZ4MID_addPosition(hash8Table, h8, ipIndex);
  770|  19.8M|            matchLength = LZ4MID_countMatch(ip, ipIndex, pos8, matchlimit, prefixPtr, prefixIdx, dictStart, dictIdx);
  771|  19.8M|            matchDistance = ipIndex - pos8;
  772|  19.8M|        }
  773|       |        /* search short match */
  774|  19.8M|        if (matchLength < MINMATCH) {
  ------------------
  |  |  242|  19.8M|#define MINMATCH 4
  ------------------
  |  Branch (774:13): [True: 18.0M, False: 1.77M]
  ------------------
  775|  18.0M|            U32 const h4 = LZ4MID_hash4Ptr(ip);
  776|  18.0M|            U32 const pos4 = hash4Table[h4];
  777|  18.0M|            assert(h4 < LZ4MID_HASHTABLESIZE);
  ------------------
  |  Branch (777:13): [True: 0, False: 18.0M]
  |  Branch (777:13): [True: 18.0M, False: 0]
  ------------------
  778|  18.0M|            assert(pos4 < ipIndex);
  ------------------
  |  Branch (778:13): [True: 0, False: 18.0M]
  |  Branch (778:13): [True: 18.0M, False: 0]
  ------------------
  779|  18.0M|            LZ4MID_addPosition(hash4Table, h4, ipIndex);
  780|  18.0M|            matchLength = LZ4MID_countMatch(ip, ipIndex, pos4, matchlimit, prefixPtr, prefixIdx, dictStart, dictIdx);
  781|  18.0M|            matchDistance = ipIndex - pos4;
  782|  18.0M|        }
  783|  19.8M|        if (matchLength >= MINMATCH) {
  ------------------
  |  |  242|  19.8M|#define MINMATCH 4
  ------------------
  |  Branch (783:13): [True: 4.07M, False: 15.7M]
  ------------------
  784|  4.07M|            if ((matchLength < 8) && likely(ip < mflimit)) {
  ------------------
  |  |  177|  2.81M|#define likely(expr)     expect((expr) != 0, 1)
  |  |  ------------------
  |  |  |  |  171|  2.81M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 2.81M, False: 283]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (784:17): [True: 2.81M, False: 1.26M]
  ------------------
  785|       |                /* short match : check ip+1 for longer, except ip itself */
  786|  2.81M|                U32 const h8 = LZ4MID_hash8Ptr(ip+1);
  787|  2.81M|                U32 const pos8 = hash8Table[h8];
  788|  2.81M|                unsigned const ml2 = LZ4MID_countMatch(ip+1, ipIndex+1, pos8, matchlimit, prefixPtr, prefixIdx, dictStart, dictIdx);
  789|  2.81M|                if ((ml2 > matchLength) && (pos8 != ipIndex)) {
  ------------------
  |  Branch (789:21): [True: 514k, False: 2.29M]
  |  Branch (789:44): [True: 488k, False: 26.5k]
  ------------------
  790|   488k|                    LZ4MID_addPosition(hash8Table, h8, ipIndex+1);
  791|   488k|                    ip++;
  792|   488k|                    matchLength = ml2;
  793|   488k|                    matchDistance = ipIndex + 1 - pos8;
  794|   488k|            }   }
  795|  4.07M|            goto _lz4mid_encode_sequence;
  796|  4.07M|        }
  797|       |        /* no match found in prefix nor extDict : search into the attached dictionary */
  798|  15.7M|        if ( (dict == usingDictCtxHc)
  ------------------
  |  Branch (798:14): [True: 0, False: 15.7M]
  ------------------
  799|      0|          && (ipIndex - gDictEndIndex < LZ4_DISTANCE_MAX - 8) ) {
  ------------------
  |  |  691|      0|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (799:14): [True: 0, False: 0]
  ------------------
  800|      0|            LZ4HC_match_t const dMatch = searchIntoDict(ip, ipIndex,
  801|      0|                    matchlimit,
  802|      0|                    ctx->dictCtx, gDictEndIndex);
  803|      0|            assert(dMatch.back == 0);
  ------------------
  |  Branch (803:13): [True: 0, False: 0]
  |  Branch (803:13): [True: 0, False: 0]
  ------------------
  804|      0|            matchLength = (unsigned)dMatch.len;
  805|      0|            matchDistance = (unsigned)dMatch.off;
  806|      0|            if (matchLength >= MINMATCH) goto _lz4mid_encode_sequence;
  ------------------
  |  |  242|      0|#define MINMATCH 4
  ------------------
  |  Branch (806:17): [True: 0, False: 0]
  ------------------
  807|      0|        }
  808|       |        /* no match found */
  809|  15.7M|        ip += 1 + ((ip-anchor) >> 9);  /* skip faster over incompressible data */
  810|  15.7M|        continue;
  811|       |
  812|  4.07M|_lz4mid_encode_sequence:
  813|       |        /* match found at ip : matchLength, matchDistance */
  814|  4.07M|        DEBUGLOG(7, "found match at pos %u (len=%u, distance=%u)",
  ------------------
  |  |  289|  4.07M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  815|  4.07M|                    (U32)(ip - prefixPtr) + prefixIdx, matchLength, matchDistance);
  816|       |
  817|       |        /* catch back */
  818|  4.26M|        while (((ip > anchor) & ((U32)(ip-prefixPtr) > matchDistance)) && (unlikely(ip[-1] == ip[-(int)matchDistance-1]))) {
  ------------------
  |  |  180|  1.67M|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|  1.67M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  ------------------
  ------------------
  |  Branch (818:16): [True: 1.67M, False: 2.58M]
  |  Branch (818:75): [True: 189k, False: 1.48M]
  ------------------
  819|   189k|            ip--;  matchLength++;
  820|   189k|        };
  821|       |
  822|       |        /* fill table with beginning of match
  823|       |         * note : ip may have moved since ipIndex (longer match at ip+1, catch back) */
  824|  4.07M|        {   U32 const startMatchIdx = (U32)(ip-prefixPtr) + prefixIdx;
  825|  4.07M|            ADDPOS8(ip+1, startMatchIdx+1);
  ------------------
  |  |  643|  4.07M|#define ADDPOS8(_p, _idx) LZ4MID_addPosition(hash8Table, LZ4MID_hash8Ptr(_p), _idx)
  ------------------
  826|  4.07M|            ADDPOS8(ip+2, startMatchIdx+2);
  ------------------
  |  |  643|  4.07M|#define ADDPOS8(_p, _idx) LZ4MID_addPosition(hash8Table, LZ4MID_hash8Ptr(_p), _idx)
  ------------------
  827|  4.07M|            ADDPOS4(ip+1, startMatchIdx+1);
  ------------------
  |  |  644|  4.07M|#define ADDPOS4(_p, _idx) LZ4MID_addPosition(hash4Table, LZ4MID_hash4Ptr(_p), _idx)
  ------------------
  828|  4.07M|        }
  829|       |
  830|       |        /* encode */
  831|  4.07M|        if (LZ4HC_encodeSequence(UPDATABLE(ip, op, anchor),
  ------------------
  |  |  241|  4.07M|#define UPDATABLE(ip, op, anchor) &ip, &op, &anchor
  ------------------
  |  Branch (831:13): [True: 12, False: 4.07M]
  ------------------
  832|  4.07M|                (int)matchLength, (int)matchDistance,
  833|  4.07M|                limit, oend) ) {
  834|     12|            if (limit != fillOutput) return 0;  /* compression failed */
  ------------------
  |  Branch (834:17): [True: 12, False: 0]
  ------------------
  835|      0|            refEnd = ip + matchLength;
  836|      0|            LZ4HC_encodeLastSequence_fillOutput(UPDATABLE(ip, op, anchor),
  ------------------
  |  |  241|      0|#define UPDATABLE(ip, op, anchor) &ip, &op, &anchor
  ------------------
  837|      0|                                (int)matchLength, (int)matchDistance, oend);
  838|      0|            break;
  839|     12|        }
  840|       |
  841|       |        /* fill table with end of match */
  842|  4.07M|        {   U32 endMatchIdx = (U32)(ip-prefixPtr) + prefixIdx;
  843|  4.07M|            U32 pos_m2 = endMatchIdx - 2;
  844|  4.07M|            if (pos_m2 < ilimitIdx) {
  ------------------
  |  Branch (844:17): [True: 4.07M, False: 1.81k]
  ------------------
  845|  4.07M|                if (likely(ip - prefixPtr > 5)) {
  ------------------
  |  |  177|  4.07M|#define likely(expr)     expect((expr) != 0, 1)
  |  |  ------------------
  |  |  |  |  171|  4.07M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 4.07M, False: 277]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  846|  4.07M|                    ADDPOS8(ip-5, endMatchIdx - 5);
  ------------------
  |  |  643|  4.07M|#define ADDPOS8(_p, _idx) LZ4MID_addPosition(hash8Table, LZ4MID_hash8Ptr(_p), _idx)
  ------------------
  847|  4.07M|                }
  848|  4.07M|                ADDPOS8(ip-3, endMatchIdx - 3);
  ------------------
  |  |  643|  4.07M|#define ADDPOS8(_p, _idx) LZ4MID_addPosition(hash8Table, LZ4MID_hash8Ptr(_p), _idx)
  ------------------
  849|  4.07M|                ADDPOS8(ip-2, endMatchIdx - 2);
  ------------------
  |  |  643|  4.07M|#define ADDPOS8(_p, _idx) LZ4MID_addPosition(hash8Table, LZ4MID_hash8Ptr(_p), _idx)
  ------------------
  850|  4.07M|                ADDPOS4(ip-2, endMatchIdx - 2);
  ------------------
  |  |  644|  4.07M|#define ADDPOS4(_p, _idx) LZ4MID_addPosition(hash4Table, LZ4MID_hash4Ptr(_p), _idx)
  ------------------
  851|  4.07M|                ADDPOS4(ip-1, endMatchIdx - 1);
  ------------------
  |  |  644|  4.07M|#define ADDPOS4(_p, _idx) LZ4MID_addPosition(hash4Table, LZ4MID_hash4Ptr(_p), _idx)
  ------------------
  852|  4.07M|            }
  853|  4.07M|        }
  854|  4.07M|    }
  855|       |
  856|  4.03k|_lz4mid_last_literals:
  857|  4.03k|    if (refEnd < ip) refEnd = ip;
  ------------------
  |  Branch (857:9): [True: 3.84k, False: 189]
  ------------------
  858|  4.03k|    if (LZ4HC_encodeLastLiterals(UPDATABLE(ip, op, anchor), iend, limit, oend))
  ------------------
  |  |  241|  4.03k|#define UPDATABLE(ip, op, anchor) &ip, &op, &anchor
  ------------------
  |  Branch (858:9): [True: 526, False: 3.50k]
  ------------------
  859|    526|        return 0;  /* not enough space in @dst */
  860|  3.50k|    if (ip < refEnd)   /* fillOutput : the rest of input is left to the next block (input >= LZ4_minLength) */
  ------------------
  |  Branch (860:9): [True: 45, False: 3.46k]
  ------------------
  861|     45|        LZ4HC_dropPositions(ctx, ip, MIN(refEnd, iend - LZ4MID_HASHSIZE), lz4mid);
  ------------------
  |  |   88|     45|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (88:22): [True: 0, False: 45]
  |  |  ------------------
  ------------------
  862|       |
  863|       |    /* End */
  864|  3.50k|    DEBUGLOG(5, "compressed %i bytes into %i bytes", *srcSizePtr, (int)((char*)op - dst));
  ------------------
  |  |  289|  3.50k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  865|  3.50k|    assert(ip >= (const BYTE*)src);
  ------------------
  |  Branch (865:5): [True: 0, False: 3.50k]
  |  Branch (865:5): [True: 3.50k, False: 0]
  ------------------
  866|  3.50k|    assert(ip <= iend);
  ------------------
  |  Branch (866:5): [True: 0, False: 3.50k]
  |  Branch (866:5): [True: 3.50k, False: 0]
  ------------------
  867|  3.50k|    *srcSizePtr = (int)(ip - (const BYTE*)src);
  868|  3.50k|    assert((char*)op >= dst);
  ------------------
  |  Branch (868:5): [True: 0, False: 3.50k]
  |  Branch (868:5): [True: 3.50k, False: 0]
  ------------------
  869|  3.50k|    assert((char*)op - dst <= maxOutputSize);
  ------------------
  |  Branch (869:5): [True: 0, False: 3.50k]
  |  Branch (869:5): [True: 3.50k, False: 0]
  ------------------
  870|  3.50k|    assert((char*)op - dst < INT_MAX);
  ------------------
  |  Branch (870:5): [True: 0, False: 3.50k]
  |  Branch (870:5): [True: 3.50k, False: 0]
  ------------------
  871|  3.50k|    return (int)((char*)op - dst);
  872|  3.50k|}
lz4hc.c:LZ4HC_hashPtr:
  133|   550M|static U32 LZ4HC_hashPtr(const void* ptr) { return HASH_FUNCTION(LZ4_read32(ptr)); }
  ------------------
  |  |  132|   550M|#define HASH_FUNCTION(i)      (((i) * 2654435761U) >> ((MINMATCH*8)-LZ4HC_HASH_LOG))
  |  |  ------------------
  |  |  |  |  242|   550M|#define MINMATCH 4
  |  |  ------------------
  |  |               #define HASH_FUNCTION(i)      (((i) * 2654435761U) >> ((MINMATCH*8)-LZ4HC_HASH_LOG))
  |  |  ------------------
  |  |  |  |  236|   550M|#define LZ4HC_HASH_LOG 15
  |  |  ------------------
  ------------------
lz4hc.c:LZ4HC_countBack:
  218|   191M|{
  219|   191M|    int back = 0;
  220|   191M|    int const min = (int)MAX(iMin - ip, mMin - match);
  ------------------
  |  |   90|   191M|#define MAX(a,b)   ( (a) > (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (90:22): [True: 191M, False: 260k]
  |  |  ------------------
  ------------------
  221|   191M|    assert(min <= 0);
  ------------------
  |  Branch (221:5): [True: 0, False: 191M]
  |  Branch (221:5): [True: 191M, False: 0]
  ------------------
  222|   191M|    assert(ip >= iMin); assert((size_t)(ip-iMin) < (1U<<31));
  ------------------
  |  Branch (222:5): [True: 0, False: 191M]
  |  Branch (222:5): [True: 191M, False: 0]
  |  Branch (222:25): [True: 0, False: 191M]
  |  Branch (222:25): [True: 191M, False: 0]
  ------------------
  223|   191M|    assert(match >= mMin); assert((size_t)(match - mMin) < (1U<<31));
  ------------------
  |  Branch (223:5): [True: 0, False: 191M]
  |  Branch (223:5): [True: 191M, False: 0]
  |  Branch (223:28): [True: 0, False: 191M]
  |  Branch (223:28): [True: 191M, False: 0]
  ------------------
  224|       |
  225|   447M|    while ((back - min) > 3) {
  ------------------
  |  Branch (225:12): [True: 423M, False: 24.0M]
  ------------------
  226|   423M|        U32 const v = LZ4_read32(ip + back - 4) ^ LZ4_read32(match + back - 4);
  227|   423M|        if (v) {
  ------------------
  |  Branch (227:13): [True: 167M, False: 255M]
  ------------------
  228|   167M|            return (back - (int)LZ4HC_NbCommonBytes32(v));
  229|   255M|        } else back -= 4; /* 4-byte step */
  230|   423M|    }
  231|       |    /* check remainder if any */
  232|  34.8M|    while ( (back > min)
  ------------------
  |  Branch (232:13): [True: 34.1M, False: 713k]
  ------------------
  233|  34.1M|         && (ip[back-1] == match[back-1]) )
  ------------------
  |  Branch (233:13): [True: 10.8M, False: 23.3M]
  ------------------
  234|  10.8M|            back--;
  235|  24.0M|    return back;
  236|   191M|}
lz4hc.c:LZ4HC_NbCommonBytes32:
  180|   167M|{
  181|   167M|    assert(val != 0);
  ------------------
  |  Branch (181:5): [True: 0, False: 167M]
  |  Branch (181:5): [True: 167M, False: 0]
  ------------------
  182|   167M|    if (LZ4_isLittleEndian()) {
  ------------------
  |  Branch (182:9): [True: 167M, False: 0]
  ------------------
  183|       |#     if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(LZ4_FORCE_SW_BITCOUNT)
  184|       |        unsigned long r;
  185|       |        _BitScanReverse(&r, val);
  186|       |        return (unsigned)((31 - r) >> 3);
  187|       |#     elif (defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 3) || \
  188|       |                            ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))))) && \
  189|       |                                        !defined(LZ4_FORCE_SW_BITCOUNT)
  190|       |        return (unsigned)__builtin_clz(val) >> 3;
  191|       |#     else
  192|       |        val >>= 8;
  193|       |        val = ((((val + 0x00FFFF00) | 0x00FFFFFF) + val) |
  194|       |              (val + 0x00FF0000)) >> 24;
  195|       |        return (unsigned)val ^ 3;
  196|       |#     endif
  197|   167M|    } else {
  198|       |#     if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(LZ4_FORCE_SW_BITCOUNT)
  199|       |        unsigned long r;
  200|       |        _BitScanForward(&r, val);
  201|       |        return (unsigned)(r >> 3);
  202|       |#     elif (defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 3) || \
  203|       |                            ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))))) && \
  204|       |                                        !defined(LZ4_FORCE_SW_BITCOUNT)
  205|       |        return (unsigned)__builtin_ctz(val) >> 3;
  206|       |#     else
  207|       |        const U32 m = 0x01010101;
  208|       |        return (unsigned)((((val - 1) ^ val) & (m - 1)) * m) >> 24;
  209|       |#     endif
  210|      0|    }
  211|   167M|}
lz4hc.c:LZ4MID_hash8Ptr:
  162|  43.0M|static U32 LZ4MID_hash8Ptr(const void* ptr) { return LZ4MID_hash7(LZ4_readLE64(ptr)); }
lz4hc.c:LZ4MID_hash7:
  160|  43.0M|static U32 LZ4MID_hash7(U64 v) { return (U32)(((v  << (64-56)) * 58295818150454627ULL) >> (64-LZ4MID_HASHLOG)) ; }
  ------------------
  |  |  153|  43.0M|#define LZ4MID_HASHLOG (LZ4HC_HASH_LOG-1)
  |  |  ------------------
  |  |  |  |  236|  43.0M|#define LZ4HC_HASH_LOG 15
  |  |  ------------------
  ------------------
lz4hc.c:LZ4_readLE64:
  165|  43.0M|{
  166|  43.0M|    if (LZ4_isLittleEndian()) {
  ------------------
  |  Branch (166:9): [True: 43.0M, False: 0]
  ------------------
  167|  43.0M|        return LZ4_read64(memPtr);
  168|  43.0M|    } else {
  169|      0|        const BYTE* p = (const BYTE*)memPtr;
  170|       |        /* note: relies on the compiler to simplify this expression */
  171|      0|        return (U64)p[0] | ((U64)p[1]<<8) | ((U64)p[2]<<16) | ((U64)p[3]<<24)
  172|      0|            | ((U64)p[4]<<32) | ((U64)p[5]<<40) | ((U64)p[6]<<48) | ((U64)p[7]<<56);
  173|      0|    }
  174|  43.0M|}
lz4hc.c:LZ4_read64:
  142|  43.0M|static U64 LZ4_read64(const void* ptr) { return ((const LZ4_unalign64*)ptr)->u64; }
lz4hc.c:LZ4MID_addPosition:
  639|  70.9M|{
  640|  70.9M|    hTable[hValue] = index;
  641|  70.9M|}
lz4hc.c:LZ4MID_countMatch:
  689|  40.6M|{
  690|  40.6M|    if (ipIndex - pos > LZ4_DISTANCE_MAX) return 0;
  ------------------
  |  |  691|  40.6M|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (690:9): [True: 11.5M, False: 29.1M]
  ------------------
  691|  29.1M|    if (pos >= prefixIdx) {
  ------------------
  |  Branch (691:9): [True: 25.7M, False: 3.40M]
  ------------------
  692|  25.7M|        const BYTE* const matchPtr = prefixPtr + (pos - prefixIdx);
  693|  25.7M|        assert(matchPtr < ip);
  ------------------
  |  Branch (693:9): [True: 0, False: 25.7M]
  |  Branch (693:9): [True: 25.7M, False: 0]
  ------------------
  694|  25.7M|        return LZ4_count(ip, matchPtr, matchlimit);
  695|  25.7M|    }
  696|  3.40M|    if (pos >= dictIdx) {
  ------------------
  |  Branch (696:9): [True: 3.40M, False: 0]
  ------------------
  697|       |        /* extDict : the match stops at the end of the dictionary */
  698|  3.40M|        const BYTE* const matchPtr = dictStart + (pos - dictIdx);
  699|  3.40M|        size_t const safeLen = MIN(prefixIdx - pos, (size_t)(matchlimit - ip));
  ------------------
  |  |   88|  3.40M|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (88:22): [True: 3.39M, False: 1.52k]
  |  |  ------------------
  ------------------
  700|  3.40M|        return LZ4_count(ip, matchPtr, ip + safeLen);
  701|  3.40M|    }
  702|      0|    return 0;
  703|  3.40M|}
lz4hc.c:LZ4MID_hash4Ptr:
  157|  30.2M|static U32 LZ4MID_hash4Ptr(const void* ptr) { return LZ4MID_hash4(LZ4_read32(ptr)); }
lz4hc.c:LZ4MID_hash4:
  156|  30.2M|static U32 LZ4MID_hash4(U32 v) { return (v * 2654435761U) >> (32-LZ4MID_HASHLOG); }
  ------------------
  |  |  153|  30.2M|#define LZ4MID_HASHLOG (LZ4HC_HASH_LOG-1)
  |  |  ------------------
  |  |  |  |  236|  30.2M|#define LZ4HC_HASH_LOG 15
  |  |  ------------------
  ------------------
lz4hc.c:LZ4HC_encodeSequence:
  311|  9.02M|{
  312|  9.02M|#define ip      (*_ip)
  313|  9.02M|#define op      (*_op)
  314|  9.02M|#define anchor  (*_anchor)
  315|       |
  316|  9.02M|    BYTE* const token = op++;
  ------------------
  |  |  313|  9.02M|#define op      (*_op)
  ------------------
  317|       |
  318|       |#if defined(LZ4_DEBUG) && (LZ4_DEBUG >= 6)
  319|       |    static const BYTE* start = NULL;
  320|       |    static U32 totalCost = 0;
  321|       |    U32 const pos = (start==NULL) ? 0 : (U32)(anchor - start); /* only works for single segment */
  322|       |    U32 const ll = (U32)(ip - anchor);
  323|       |    U32 const llAdd = (ll>=15) ? ((ll-15) / 255) + 1 : 0;
  324|       |    U32 const mlAdd = (matchLength>=19) ? ((matchLength-19) / 255) + 1 : 0;
  325|       |    U32 const cost = 1 + llAdd + ll + 2 + mlAdd;
  326|       |    if (start==NULL) start = anchor;  /* only works for single segment */
  327|       |    DEBUGLOG(6, "pos:%7u -- literals:%4u, match:%4i, offset:%5i, cost:%4u + %5u",
  328|       |                pos,
  329|       |                (U32)(ip - anchor), matchLength, offset,
  330|       |                cost, totalCost);
  331|       |# if 1 /* only works on single segment data */
  332|       |    HEX_CMP(7, ip, ip-offset, matchLength);
  333|       |# endif
  334|       |    totalCost += cost;
  335|       |#endif
  336|       |
  337|       |    /* Encode Literal length */
  338|  9.02M|    {   size_t litLen = (size_t)(ip - anchor);
  ------------------
  |  |  312|  9.02M|#define ip      (*_ip)
  ------------------
                  {   size_t litLen = (size_t)(ip - anchor);
  ------------------
  |  |  314|  9.02M|#define anchor  (*_anchor)
  ------------------
  339|  9.02M|        LZ4_STATIC_ASSERT(notLimited == 0);
  ------------------
  |  |  277|  9.02M|#define LZ4_STATIC_ASSERT(c)   { enum { LZ4_static_assert = 1/(int)(!!(c)) }; }   /* use after variable declarations */
  ------------------
  340|       |        /* Check output limit */
  341|  9.02M|        if (limit && ((op + (litLen / 255) + litLen + (2 + 1 + LASTLITERALS)) > oend)) {
  ------------------
  |  |  313|  9.02M|#define op      (*_op)
  ------------------
                      if (limit && ((op + (litLen / 255) + litLen + (2 + 1 + LASTLITERALS)) > oend)) {
  ------------------
  |  |  245|  9.02M|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  |  Branch (341:13): [True: 9.02M, False: 0]
  |  Branch (341:22): [True: 55, False: 9.02M]
  ------------------
  342|     55|            DEBUGLOG(6, "Not enough room to write %i literals (%i bytes remaining)",
  ------------------
  |  |  289|     55|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  343|     55|                    (int)litLen, (int)(oend - op));
  344|     55|            op = token;
  ------------------
  |  |  313|     55|#define op      (*_op)
  ------------------
  345|     55|            return 1;
  346|     55|        }
  347|  9.02M|        if (litLen >= RUN_MASK) {
  ------------------
  |  |  263|  9.02M|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|  9.02M|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|  9.02M|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (347:13): [True: 413k, False: 8.61M]
  ------------------
  348|   413k|            size_t len = litLen - RUN_MASK;
  ------------------
  |  |  263|   413k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|   413k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|   413k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  349|   413k|            *token = (RUN_MASK << ML_BITS);
  ------------------
  |  |  263|   413k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|   413k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|   413k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                          *token = (RUN_MASK << ML_BITS);
  ------------------
  |  |  260|   413k|#define ML_BITS  4
  ------------------
  350|   610k|            for(; len >= 255 ; len -= 255) *op++ = 255;
  ------------------
  |  |  313|   196k|#define op      (*_op)
  ------------------
  |  Branch (350:19): [True: 196k, False: 413k]
  ------------------
  351|   413k|            *op++ = (BYTE)len;
  ------------------
  |  |  313|   413k|#define op      (*_op)
  ------------------
  352|  8.61M|        } else {
  353|  8.61M|            *token = (BYTE)(litLen << ML_BITS);
  ------------------
  |  |  260|  8.61M|#define ML_BITS  4
  ------------------
  354|  8.61M|        }
  355|       |
  356|       |        /* Copy Literals */
  357|  9.02M|        LZ4_wildCopy8(op, anchor, op + litLen);
  ------------------
  |  |  313|  9.02M|#define op      (*_op)
  ------------------
                      LZ4_wildCopy8(op, anchor, op + litLen);
  ------------------
  |  |  314|  9.02M|#define anchor  (*_anchor)
  ------------------
                      LZ4_wildCopy8(op, anchor, op + litLen);
  ------------------
  |  |  313|  9.02M|#define op      (*_op)
  ------------------
  358|  9.02M|        op += litLen;
  ------------------
  |  |  313|  9.02M|#define op      (*_op)
  ------------------
  359|  9.02M|    }
  360|       |
  361|       |    /* Encode Offset */
  362|  9.02M|    assert(offset <= LZ4_DISTANCE_MAX );
  ------------------
  |  Branch (362:5): [True: 0, False: 9.02M]
  |  Branch (362:5): [True: 9.02M, False: 0]
  ------------------
  363|  9.02M|    assert(offset > 0);
  ------------------
  |  Branch (363:5): [True: 0, False: 9.02M]
  |  Branch (363:5): [True: 9.02M, False: 0]
  ------------------
  364|  9.02M|    LZ4_writeLE16(op, (U16)(offset)); op += 2;
  ------------------
  |  |  313|  9.02M|#define op      (*_op)
  ------------------
                  LZ4_writeLE16(op, (U16)(offset)); op += 2;
  ------------------
  |  |  313|  9.02M|#define op      (*_op)
  ------------------
  365|       |
  366|       |    /* Encode MatchLength */
  367|  9.02M|    assert(matchLength >= MINMATCH);
  ------------------
  |  Branch (367:5): [True: 0, False: 9.02M]
  |  Branch (367:5): [True: 9.02M, False: 0]
  ------------------
  368|  9.02M|    {   size_t mlCode = (size_t)matchLength - MINMATCH;
  ------------------
  |  |  242|  9.02M|#define MINMATCH 4
  ------------------
  369|  9.02M|        if (limit && (op + (mlCode / 255) + (1 + LASTLITERALS) > oend)) {
  ------------------
  |  |  313|  9.02M|#define op      (*_op)
  ------------------
                      if (limit && (op + (mlCode / 255) + (1 + LASTLITERALS) > oend)) {
  ------------------
  |  |  245|  9.02M|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  |  Branch (369:13): [True: 9.02M, False: 0]
  |  Branch (369:22): [True: 11, False: 9.02M]
  ------------------
  370|     11|            DEBUGLOG(6, "Not enough room to write match length");
  ------------------
  |  |  289|     11|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  371|     11|            op = token;
  ------------------
  |  |  313|     11|#define op      (*_op)
  ------------------
  372|     11|            return 1;
  373|     11|        }
  374|  9.02M|        if (mlCode >= ML_MASK) {
  ------------------
  |  |  261|  9.02M|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|  9.02M|#define ML_BITS  4
  |  |  ------------------
  ------------------
  |  Branch (374:13): [True: 1.53M, False: 7.49M]
  ------------------
  375|  1.53M|            *token += ML_MASK;
  ------------------
  |  |  261|  1.53M|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|  1.53M|#define ML_BITS  4
  |  |  ------------------
  ------------------
  376|  1.53M|            mlCode -= ML_MASK;
  ------------------
  |  |  261|  1.53M|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|  1.53M|#define ML_BITS  4
  |  |  ------------------
  ------------------
  377|  2.17M|            for(; mlCode >= 510 ; mlCode -= 510) { *op++ = 255; *op++ = 255; }
  ------------------
  |  |  313|   639k|#define op      (*_op)
  ------------------
                          for(; mlCode >= 510 ; mlCode -= 510) { *op++ = 255; *op++ = 255; }
  ------------------
  |  |  313|   639k|#define op      (*_op)
  ------------------
  |  Branch (377:19): [True: 639k, False: 1.53M]
  ------------------
  378|  1.53M|            if (mlCode >= 255) { mlCode -= 255; *op++ = 255; }
  ------------------
  |  |  313|   132k|#define op      (*_op)
  ------------------
  |  Branch (378:17): [True: 132k, False: 1.40M]
  ------------------
  379|  1.53M|            *op++ = (BYTE)mlCode;
  ------------------
  |  |  313|  1.53M|#define op      (*_op)
  ------------------
  380|  7.49M|        } else {
  381|  7.49M|            *token += (BYTE)(mlCode);
  382|  7.49M|    }   }
  383|       |
  384|       |    /* Prepare next loop */
  385|  9.02M|    ip += matchLength;
  ------------------
  |  |  312|  9.02M|#define ip      (*_ip)
  ------------------
  386|  9.02M|    anchor = ip;
  ------------------
  |  |  314|  9.02M|#define anchor  (*_anchor)
  ------------------
                  anchor = ip;
  ------------------
  |  |  312|  9.02M|#define ip      (*_ip)
  ------------------
  387|       |
  388|  9.02M|    return 0;
  389|       |
  390|  9.02M|#undef ip
  391|  9.02M|#undef op
  392|  9.02M|#undef anchor
  393|  9.02M|}
lz4hc.c:LZ4HC_encodeLastLiterals:
  408|  19.7k|{
  409|  19.7k|#define ip      (*_ip)
  410|  19.7k|#define op      (*_op)
  411|  19.7k|#define anchor  (*_anchor)
  412|       |
  413|  19.7k|    BYTE* const dstEnd = (limit == fillOutput) ? oend + LASTLITERALS : oend;
  ------------------
  |  |  245|      0|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  |  Branch (413:26): [True: 0, False: 19.7k]
  ------------------
  414|  19.7k|    size_t lastRunSize = (size_t)(iend - anchor);  /* literals */
  ------------------
  |  |  411|  19.7k|#define anchor  (*_anchor)
  ------------------
  415|  19.7k|    size_t llAdd = (lastRunSize + 255 - RUN_MASK) / 255;
  ------------------
  |  |  263|  19.7k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|  19.7k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|  19.7k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  416|  19.7k|    size_t const totalSize = 1 + llAdd + lastRunSize;
  417|  19.7k|    if (limit && (op + totalSize > dstEnd)) {
  ------------------
  |  |  410|  19.7k|#define op      (*_op)
  ------------------
  |  Branch (417:9): [True: 19.7k, False: 0]
  |  Branch (417:18): [True: 2.79k, False: 16.9k]
  ------------------
  418|  2.79k|        if (limit == limitedOutput) return 1;  /* not enough space in dst */
  ------------------
  |  Branch (418:13): [True: 2.79k, False: 0]
  ------------------
  419|       |        /* adapt lastRunSize to fill dst */
  420|      0|        lastRunSize  = (size_t)(dstEnd - op) - 1 /*token*/;
  ------------------
  |  |  410|      0|#define op      (*_op)
  ------------------
  421|      0|        llAdd = (lastRunSize + 256 - RUN_MASK) / 256;
  ------------------
  |  |  263|      0|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|      0|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|      0|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  422|      0|        lastRunSize -= llAdd;
  423|      0|    }
  424|  16.9k|    DEBUGLOG(6, "Final literal run : %i literals", (int)lastRunSize);
  ------------------
  |  |  289|  16.9k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  425|  16.9k|    ip = anchor + lastRunSize;  /* can be != iend if limit==fillOutput */
  ------------------
  |  |  409|  16.9k|#define ip      (*_ip)
  ------------------
                  ip = anchor + lastRunSize;  /* can be != iend if limit==fillOutput */
  ------------------
  |  |  411|  16.9k|#define anchor  (*_anchor)
  ------------------
  426|       |
  427|  16.9k|    if (lastRunSize >= RUN_MASK) {
  ------------------
  |  |  263|  16.9k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|  16.9k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|  16.9k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (427:9): [True: 1.44k, False: 15.5k]
  ------------------
  428|  1.44k|        size_t accumulator = lastRunSize - RUN_MASK;
  ------------------
  |  |  263|  1.44k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|  1.44k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|  1.44k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  429|  1.44k|        *op++ = (RUN_MASK << ML_BITS);
  ------------------
  |  |  410|  1.44k|#define op      (*_op)
  ------------------
                      *op++ = (RUN_MASK << ML_BITS);
  ------------------
  |  |  263|  1.44k|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|  1.44k|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|  1.44k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      *op++ = (RUN_MASK << ML_BITS);
  ------------------
  |  |  260|  1.44k|#define ML_BITS  4
  ------------------
  430|  26.5k|        for(; accumulator >= 255 ; accumulator -= 255) *op++ = 255;
  ------------------
  |  |  410|  25.1k|#define op      (*_op)
  ------------------
  |  Branch (430:15): [True: 25.1k, False: 1.44k]
  ------------------
  431|  1.44k|        *op++ = (BYTE) accumulator;
  ------------------
  |  |  410|  1.44k|#define op      (*_op)
  ------------------
  432|  15.5k|    } else {
  433|  15.5k|        *op++ = (BYTE)(lastRunSize << ML_BITS);
  ------------------
  |  |  410|  15.5k|#define op      (*_op)
  ------------------
                      *op++ = (BYTE)(lastRunSize << ML_BITS);
  ------------------
  |  |  260|  15.5k|#define ML_BITS  4
  ------------------
  434|  15.5k|    }
  435|  16.9k|    assert(lastRunSize <= (size_t)(dstEnd - op));
  ------------------
  |  Branch (435:5): [True: 0, False: 16.9k]
  |  Branch (435:5): [True: 16.9k, False: 0]
  ------------------
  436|  16.9k|    LZ4_memcpy(op, anchor, lastRunSize);
  ------------------
  |  |  349|  16.9k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  437|  16.9k|    op += lastRunSize;
  ------------------
  |  |  410|  16.9k|#define op      (*_op)
  ------------------
  438|  16.9k|    return 0;
  439|       |
  440|  16.9k|#undef ip
  441|  16.9k|#undef op
  442|  16.9k|#undef anchor
  443|  16.9k|}
lz4hc.c:LZ4HC_compress_hashChain:
 1272|  8.91k|{
 1273|  8.91k|    const int inputSize = *srcSizePtr;
 1274|  8.91k|    const int patternAnalysis = (maxNbAttempts > 128);   /* levels 9+ */
 1275|       |
 1276|  8.91k|    const BYTE* ip = (const BYTE*)src;
 1277|  8.91k|    const BYTE* anchor = ip;
 1278|  8.91k|    const BYTE* const iend = ip + inputSize;
 1279|  8.91k|    const BYTE* mflimit;      /* set after the size check : would precede a small input */
 1280|  8.91k|    const BYTE* matchlimit;
 1281|       |
 1282|  8.91k|    BYTE* op = (BYTE*) dst;
 1283|       |    /* fillOutput : keep room for the final run of literals (LZ4 format restriction) */
 1284|  8.91k|    BYTE* const oend = op + maxOutputSize - ((limit == fillOutput) ? LASTLITERALS : 0);
  ------------------
  |  |  245|      0|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  |  Branch (1284:46): [True: 0, False: 8.91k]
  ------------------
 1285|       |
 1286|  8.91k|    const BYTE* start0;
 1287|  8.91k|    const BYTE* start2 = NULL;
 1288|  8.91k|    const BYTE* start3 = NULL;
 1289|  8.91k|    LZ4HC_match_t m0, m1, m2, m3;
 1290|  8.91k|    const LZ4HC_match_t nomatch = {0, 0, 0};
 1291|       |
 1292|       |    /* init */
 1293|  8.91k|    DEBUGLOG(5, "LZ4HC_compress_hashChain (dict?=>%i)", dict);
  ------------------
  |  |  289|  8.91k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1294|       |
 1295|       |    /* preconditions verifications */
 1296|  8.91k|    assert(*srcSizePtr >= 1);
  ------------------
  |  Branch (1296:5): [True: 0, False: 8.91k]
  |  Branch (1296:5): [True: 8.91k, False: 0]
  ------------------
 1297|  8.91k|    assert(src != NULL);
  ------------------
  |  Branch (1297:5): [True: 0, False: 8.91k]
  |  Branch (1297:5): [True: 8.91k, False: 0]
  ------------------
 1298|  8.91k|    assert(maxOutputSize >= 1);
  ------------------
  |  Branch (1298:5): [True: 0, False: 8.91k]
  |  Branch (1298:5): [True: 8.91k, False: 0]
  ------------------
 1299|  8.91k|    assert(dst != NULL);
  ------------------
  |  Branch (1299:5): [True: 0, False: 8.91k]
  |  Branch (1299:5): [True: 8.91k, False: 0]
  ------------------
 1300|       |
 1301|  8.91k|    *srcSizePtr = 0;
 1302|  8.91k|    if (inputSize < LZ4_minLength) goto _last_literals;             /* Input too small, no compression (all literals) */
  ------------------
  |  Branch (1302:9): [True: 411, False: 8.50k]
  ------------------
 1303|  8.50k|    mflimit = iend - MFLIMIT;
  ------------------
  |  |  246|  8.50k|#define MFLIMIT       12   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
 1304|  8.50k|    matchlimit = (iend - LASTLITERALS);
  ------------------
  |  |  245|  8.50k|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
 1305|       |
 1306|       |    /* Main Loop */
 1307|  45.7M|    while (ip <= mflimit) {
  ------------------
  |  Branch (1307:12): [True: 45.7M, False: 8.47k]
  ------------------
 1308|  45.7M|        m1 = LZ4HC_InsertAndFindBestMatch(ctx, ip, matchlimit, maxNbAttempts, patternAnalysis, dict);
 1309|  45.7M|        if (m1.len<MINMATCH) { ip++; continue; }
  ------------------
  |  |  242|  45.7M|#define MINMATCH 4
  ------------------
  |  Branch (1309:13): [True: 42.9M, False: 2.75M]
  ------------------
 1310|       |
 1311|       |        /* saved, in case we would skip too much */
 1312|  2.75M|        start0 = ip; m0 = m1;
 1313|       |
 1314|  3.90M|_Search2:
 1315|       |        /* m1 (at ip) is the next match to encode, m0 (at start0 <= ip) its fallback.
 1316|       |         * Search a longer match m2, starting before the end of m1. */
 1317|  3.90M|        DEBUGLOG(7, "_Search2 (currently found match of size %i)", m1.len);
  ------------------
  |  |  289|  3.90M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1318|  3.90M|        if (ip+m1.len <= mflimit) {
  ------------------
  |  Branch (1318:13): [True: 3.90M, False: 5.75k]
  ------------------
 1319|  3.90M|            start2 = ip + m1.len - 2;
 1320|  3.90M|            m2 = LZ4HC_InsertAndGetWiderMatch(ctx,
 1321|  3.90M|                            start2, ip + 0, matchlimit, m1.len,
 1322|  3.90M|                            maxNbAttempts, patternAnalysis, 0, dict, favorCompressionRatio);
 1323|  3.90M|            start2 += m2.back;
 1324|  3.90M|        } else {
 1325|  5.75k|            m2 = nomatch;  /* do not search further */
 1326|  5.75k|        }
 1327|       |
 1328|  3.90M|        if (m2.len <= m1.len) { /* No better match => encode m1 immediately */
  ------------------
  |  Branch (1328:13): [True: 2.43M, False: 1.47M]
  ------------------
 1329|  2.43M|            if (LZ4HC_encodeSequence(UPDATABLE(ip, op, anchor),
  ------------------
  |  |  241|  2.43M|#define UPDATABLE(ip, op, anchor) &ip, &op, &anchor
  ------------------
  |  Branch (1329:17): [True: 22, False: 2.43M]
  ------------------
 1330|  2.43M|                    m1.len, m1.off,
 1331|  2.43M|                    limit, oend) )
 1332|     22|                goto _dest_overflow;
 1333|  2.43M|            continue;
 1334|  2.43M|        }
 1335|       |
 1336|  1.47M|        if ((start0 < ip) && (start2 < ip + m0.len)) {
  ------------------
  |  Branch (1336:13): [True: 253k, False: 1.21M]
  |  Branch (1336:30): [True: 161k, False: 92.2k]
  ------------------
 1337|       |            /* m1 was skipped at least once, and m2 starts early enough : restore m0 */
 1338|   161k|            ip = start0; m1 = m0;
 1339|   161k|        }
 1340|       |
 1341|  1.47M|        if ((start2 - ip) < 3) {  /* m1 too short before m2 : removed */
  ------------------
  |  Branch (1341:13): [True: 847k, False: 622k]
  ------------------
 1342|   847k|            ip = start2;
 1343|   847k|            m1 = m2;
 1344|   847k|            goto _Search2;
 1345|   847k|        }
 1346|       |
 1347|       |        /* m2 (at start2) is the candidate after m1.
 1348|       |         * Search a longer match m3, starting before the end of m2. */
 1349|   810k|        while (1) {
  ------------------
  |  Branch (1349:16): [True: 810k, Folded]
  ------------------
 1350|       |            /* m1 will be cut where m2 starts, but keeps up to OPTIMAL_ML bytes (no extra length byte) :
 1351|       |             * m2 is shifted after them, as long as it keeps at least MINMATCH bytes. */
 1352|   810k|            if ((start2 - ip) < OPTIMAL_ML) {
  ------------------
  |  |   82|   810k|#define OPTIMAL_ML (int)((ML_MASK-1)+MINMATCH)
  |  |  ------------------
  |  |  |  |  261|   810k|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|   810k|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define OPTIMAL_ML (int)((ML_MASK-1)+MINMATCH)
  |  |  ------------------
  |  |  |  |  242|   810k|#define MINMATCH 4
  |  |  ------------------
  ------------------
  |  Branch (1352:17): [True: 728k, False: 82.6k]
  ------------------
 1353|   728k|                int const gap = (int)(start2 - ip);
 1354|   728k|                int newML = MIN(m1.len, OPTIMAL_ML);
  ------------------
  |  |   88|   728k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (88:22): [True: 612k, False: 115k]
  |  |  ------------------
  ------------------
 1355|   728k|                if (newML > gap + m2.len - MINMATCH)
  ------------------
  |  |  242|   728k|#define MINMATCH 4
  ------------------
  |  Branch (1355:21): [True: 520, False: 727k]
  ------------------
 1356|    520|                    newML = gap + m2.len - MINMATCH;
  ------------------
  |  |  242|    520|#define MINMATCH 4
  ------------------
 1357|   728k|                if (newML > gap) {   /* shift m2 */
  ------------------
  |  Branch (1357:21): [True: 652k, False: 75.3k]
  ------------------
 1358|   652k|                    start2 += newML - gap;
 1359|   652k|                    m2.len -= newML - gap;
 1360|   652k|                }
 1361|   728k|            }
 1362|       |
 1363|   810k|            if (start2 + m2.len <= mflimit) {
  ------------------
  |  Branch (1363:17): [True: 809k, False: 1.05k]
  ------------------
 1364|   809k|                start3 = start2 + m2.len - 3;
 1365|   809k|                m3 = LZ4HC_InsertAndGetWiderMatch(ctx,
 1366|   809k|                                start3, start2, matchlimit, m2.len,
 1367|   809k|                                maxNbAttempts, patternAnalysis, 0, dict, favorCompressionRatio);
 1368|   809k|                start3 += m3.back;
 1369|   809k|            } else {
 1370|  1.05k|                m3 = nomatch;  /* do not search further */
 1371|  1.05k|            }
 1372|       |
 1373|   810k|            if ((m3.len > m2.len) && (start3 < ip+m1.len+3)) {  /* not enough room for m2 between m1 and m3 */
  ------------------
  |  Branch (1373:17): [True: 494k, False: 316k]
  |  Branch (1373:38): [True: 327k, False: 166k]
  ------------------
 1374|   327k|                if (start3 >= (ip+m1.len)) {
  ------------------
  |  Branch (1374:21): [True: 306k, False: 21.4k]
  ------------------
 1375|       |                    /* m3 starts after m1 : encode m1, then m3 becomes m1,
 1376|       |                     * and m2, moved after m1 if needed (replaced by m3 if too short), becomes the fallback m0 */
 1377|   306k|                    if (start2 < ip+m1.len) {
  ------------------
  |  Branch (1377:25): [True: 20.7k, False: 285k]
  ------------------
 1378|  20.7k|                        int correction = (int)(ip+m1.len - start2);
 1379|  20.7k|                        start2 += correction;
 1380|  20.7k|                        m2.len -= correction;
 1381|  20.7k|                        if (m2.len < MINMATCH) {
  ------------------
  |  |  242|  20.7k|#define MINMATCH 4
  ------------------
  |  Branch (1381:29): [True: 196, False: 20.6k]
  ------------------
 1382|    196|                            start2 = start3;
 1383|    196|                            m2 = m3;
 1384|    196|                        }
 1385|  20.7k|                    }
 1386|       |
 1387|   306k|                    if (LZ4HC_encodeSequence(UPDATABLE(ip, op, anchor),
  ------------------
  |  |  241|   306k|#define UPDATABLE(ip, op, anchor) &ip, &op, &anchor
  ------------------
  |  Branch (1387:25): [True: 2, False: 306k]
  ------------------
 1388|   306k|                            m1.len, m1.off,
 1389|   306k|                            limit, oend) )
 1390|      2|                        goto _dest_overflow;
 1391|   306k|                    ip  = start3;
 1392|   306k|                    m1 = m3;
 1393|       |
 1394|   306k|                    start0 = start2;
 1395|   306k|                    m0 = m2;
 1396|   306k|                    goto _Search2;
 1397|   306k|                }
 1398|       |
 1399|       |                /* m3 starts within m1 : m3 replaces m2 */
 1400|  21.4k|                start2 = start3;
 1401|  21.4k|                m2 = m3;
 1402|  21.4k|                continue;
 1403|   327k|            }
 1404|       |
 1405|       |            /* encode m1, cut where m2 starts */
 1406|   483k|            if (start2 < ip+m1.len) m1.len = (int)(start2 - ip);
  ------------------
  |  Branch (1406:17): [True: 144k, False: 338k]
  ------------------
 1407|   483k|            if (LZ4HC_encodeSequence(UPDATABLE(ip, op, anchor),
  ------------------
  |  |  241|   483k|#define UPDATABLE(ip, op, anchor) &ip, &op, &anchor
  ------------------
  |  Branch (1407:17): [True: 2, False: 483k]
  ------------------
 1408|   483k|                    m1.len, m1.off,
 1409|   483k|                    limit, oend) )
 1410|      2|                goto _dest_overflow;
 1411|       |
 1412|       |            /* m2 becomes m1 */
 1413|   483k|            ip = start2; m1 = m2;
 1414|       |
 1415|   483k|            if (m3.len <= m1.len) {  /* No better match => encode m1 (former m2) */
  ------------------
  |  Branch (1415:17): [True: 316k, False: 166k]
  ------------------
 1416|   316k|                if (LZ4HC_encodeSequence(UPDATABLE(ip, op, anchor),
  ------------------
  |  |  241|   316k|#define UPDATABLE(ip, op, anchor) &ip, &op, &anchor
  ------------------
  |  Branch (1416:21): [True: 3, False: 316k]
  ------------------
 1417|   316k|                        m1.len, m1.off,
 1418|   316k|                        limit, oend) )
 1419|      3|                    goto _dest_overflow;
 1420|   316k|                break;
 1421|   316k|            }
 1422|       |
 1423|       |            /* m3 becomes m2 */
 1424|   166k|            start2 = start3; m2 = m3;
 1425|   166k|        }
 1426|   622k|    }
 1427|       |
 1428|  8.89k|_last_literals:
 1429|  8.89k|    if (LZ4HC_encodeLastLiterals(UPDATABLE(ip, op, anchor), iend, limit, oend))
  ------------------
  |  |  241|  8.89k|#define UPDATABLE(ip, op, anchor) &ip, &op, &anchor
  ------------------
  |  Branch (1429:9): [True: 1.07k, False: 7.81k]
  ------------------
 1430|  1.07k|        return 0;  /* not enough space in @dst */
 1431|       |
 1432|       |    /* End */
 1433|  7.81k|    *srcSizePtr = (int) (((const char*)ip) - src);
 1434|  7.81k|    return (int) (((char*)op)-dst);
 1435|       |
 1436|     29|_dest_overflow:
 1437|     29|    if (limit != fillOutput) return 0;  /* compression failed */
  ------------------
  |  Branch (1437:9): [True: 29, False: 0]
  ------------------
 1438|      0|    LZ4HC_encodeLastSequence_fillOutput(UPDATABLE(ip, op, anchor), m1.len, m1.off, oend);
  ------------------
  |  |  241|      0|#define UPDATABLE(ip, op, anchor) &ip, &op, &anchor
  ------------------
 1439|      0|    goto _last_literals;
 1440|     29|}
lz4hc.c:LZ4HC_InsertAndFindBestMatch:
 1247|  45.7M|{
 1248|  45.7M|    DEBUGLOG(7, "LZ4HC_InsertAndFindBestMatch");
  ------------------
  |  |  289|  45.7M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1249|       |    /* note : LZ4HC_InsertAndGetWiderMatch() is able to modify the starting position of a match (*startpos),
 1250|       |     * but this won't be the case here, as we define iLowLimit==ip,
 1251|       |     * so LZ4HC_InsertAndGetWiderMatch() won't be allowed to search past ip */
 1252|  45.7M|    return LZ4HC_InsertAndGetWiderMatch(hc4, ip, ip, iLimit, MINMATCH-1, maxNbAttempts, patternAnalysis, 0 /*chainSwap*/, dict, favorCompressionRatio);
  ------------------
  |  |  242|  45.7M|#define MINMATCH 4
  ------------------
 1253|  45.7M|}
lz4hc.c:LZ4HC_InsertAndGetWiderMatch:
 1059|  86.5M|{
 1060|  86.5M|    U16* const chainTable = hc4->chainTable;
 1061|  86.5M|    U32* const hashTable = hc4->hashTable;
 1062|  86.5M|    const LZ4HC_CCtx_internal* const dictCtx = hc4->dictCtx;
 1063|  86.5M|    const BYTE* const prefixPtr = hc4->prefixStart;
 1064|  86.5M|    const U32 prefixIdx = hc4->dictLimit;
 1065|  86.5M|    const U32 ipIndex = (U32)(ip - prefixPtr) + prefixIdx;
 1066|  86.5M|    const int withinStartDistance = (hc4->lowLimit + (LZ4_DISTANCE_MAX + 1) > ipIndex);
  ------------------
  |  |  691|  86.5M|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
 1067|  86.5M|    const U32 lowestMatchIndex = (withinStartDistance) ? hc4->lowLimit : ipIndex - LZ4_DISTANCE_MAX;
  ------------------
  |  |  691|  51.2M|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (1067:34): [True: 35.2M, False: 51.2M]
  ------------------
 1068|  86.5M|    const BYTE* const dictStart = hc4->dictStart;
 1069|  86.5M|    const U32 dictIdx = hc4->lowLimit;
 1070|  86.5M|    int const lookBackLength = (int)(ip-iLowLimit);
 1071|  86.5M|    int const maxLength = (int)(iHighLimit-iLowLimit);   /* no match can be longer */
 1072|  86.5M|    int nbAttempts = maxNbAttempts;
 1073|  86.5M|    U32 matchChainPos = 0;
 1074|  86.5M|    U32 const pattern = LZ4_read32(ip);
 1075|  86.5M|    U32 matchIndex;
 1076|  86.5M|    repeat_state_e repeat = rep_untested;
 1077|  86.5M|    size_t srcPatternLength = 0;
 1078|  86.5M|    int offset = 0, sBack = 0;
 1079|       |
 1080|  86.5M|    DEBUGLOG(7, "LZ4HC_InsertAndGetWiderMatch");
  ------------------
  |  |  289|  86.5M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1081|       |    /* First Match */
 1082|  86.5M|    LZ4HC_Insert(hc4, ip);  /* insert all prior positions up to ip (excluded) */
 1083|  86.5M|    matchIndex = hashTable[LZ4HC_hashPtr(ip)];
 1084|  86.5M|    DEBUGLOG(7, "First candidate match for pos %u found at index %u / %u (lowestMatchIndex)",
  ------------------
  |  |  289|  86.5M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1085|  86.5M|                ipIndex, matchIndex, lowestMatchIndex);
 1086|       |
 1087|       |    /* Candidates only replace the current match if strictly longer,
 1088|       |     * so stopping once @longest reaches @maxLength doesn't change the result. */
 1089|  1.64G|    while ((matchIndex>=lowestMatchIndex) && (nbAttempts>0) && (longest<maxLength)) {
  ------------------
  |  Branch (1089:12): [True: 1.56G, False: 83.4M]
  |  Branch (1089:46): [True: 1.55G, False: 3.08M]
  |  Branch (1089:64): [True: 1.55G, False: 12.2k]
  ------------------
 1090|  1.55G|        int matchLength=0;
 1091|  1.55G|        nbAttempts--;
 1092|  1.55G|        assert(matchIndex < ipIndex);
  ------------------
  |  Branch (1092:9): [True: 0, False: 1.55G]
  |  Branch (1092:9): [True: 1.55G, False: 0]
  ------------------
 1093|  1.55G|        if (favorDecSpeed && (ipIndex - matchIndex < 8)) {
  ------------------
  |  Branch (1093:13): [True: 550M, False: 1.00G]
  |  Branch (1093:30): [True: 579k, False: 549M]
  ------------------
 1094|       |            /* do nothing:
 1095|       |             * favorDecSpeed intentionally skips matches with offset < 8 */
 1096|  1.55G|        } else if (matchIndex >= prefixIdx) {   /* within current Prefix */
  ------------------
  |  Branch (1096:20): [True: 1.39G, False: 160M]
  ------------------
 1097|  1.39G|            const BYTE* const matchPtr = prefixPtr + (matchIndex - prefixIdx);
 1098|  1.39G|            assert(matchPtr < ip);
  ------------------
  |  Branch (1098:13): [True: 0, False: 1.39G]
  |  Branch (1098:13): [True: 1.39G, False: 0]
  ------------------
 1099|  1.39G|            assert(longest >= 1);
  ------------------
  |  Branch (1099:13): [True: 0, False: 1.39G]
  |  Branch (1099:13): [True: 1.39G, False: 0]
  ------------------
 1100|  1.39G|            if (LZ4_read16(iLowLimit + longest - 1) == LZ4_read16(matchPtr - lookBackLength + longest - 1)) {
  ------------------
  |  Branch (1100:17): [True: 245M, False: 1.15G]
  ------------------
 1101|   245M|                if (LZ4_read32(matchPtr) == pattern) {
  ------------------
  |  Branch (1101:21): [True: 227M, False: 17.7M]
  ------------------
 1102|   227M|                    int const back = lookBackLength ? LZ4HC_countBack(ip, matchPtr, iLowLimit, prefixPtr) : 0;
  ------------------
  |  Branch (1102:38): [True: 180M, False: 46.9M]
  ------------------
 1103|   227M|                    matchLength = MINMATCH + (int)LZ4_count(ip+MINMATCH, matchPtr+MINMATCH, iHighLimit);
  ------------------
  |  |  242|   227M|#define MINMATCH 4
  ------------------
                                  matchLength = MINMATCH + (int)LZ4_count(ip+MINMATCH, matchPtr+MINMATCH, iHighLimit);
  ------------------
  |  |  242|   227M|#define MINMATCH 4
  ------------------
                                  matchLength = MINMATCH + (int)LZ4_count(ip+MINMATCH, matchPtr+MINMATCH, iHighLimit);
  ------------------
  |  |  242|   227M|#define MINMATCH 4
  ------------------
 1104|   227M|                    matchLength -= back;
 1105|   227M|                    if (matchLength > longest) {
  ------------------
  |  Branch (1105:25): [True: 16.3M, False: 210M]
  ------------------
 1106|  16.3M|                        longest = matchLength;
 1107|  16.3M|                        offset = (int)(ipIndex - matchIndex);
 1108|  16.3M|                        sBack = back;
 1109|  16.3M|                        DEBUGLOG(7, "Found match of len=%i within prefix, offset=%i, back=%i", longest, offset, -back);
  ------------------
  |  |  289|  16.3M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1110|  16.3M|                        HEX_CMP(7, ip + back, ip + back - offset, (size_t)matchLength);
 1111|  16.3M|            }   }   }
 1112|  1.39G|        } else {   /* lowestMatchIndex <= matchIndex < dictLimit : within Ext Dict */
 1113|   160M|            const BYTE* const matchPtr = dictStart + (matchIndex - dictIdx);
 1114|   160M|            assert(matchIndex >= dictIdx);
  ------------------
  |  Branch (1114:13): [True: 0, False: 160M]
  |  Branch (1114:13): [True: 160M, False: 0]
  ------------------
 1115|   160M|            if ( likely(matchIndex <= prefixIdx - 4)
  ------------------
  |  |  177|   160M|#define likely(expr)     expect((expr) != 0, 1)
  |  |  ------------------
  |  |  |  |  171|   320M|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 160M, False: 4.07k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1116|   160M|              && (LZ4_read32(matchPtr) == pattern) ) {
  ------------------
  |  Branch (1116:18): [True: 122M, False: 37.7M]
  ------------------
 1117|   122M|                int back = 0;
 1118|   122M|                const BYTE* vLimit = ip + (prefixIdx - matchIndex);
 1119|   122M|                if (vLimit > iHighLimit) vLimit = iHighLimit;
  ------------------
  |  Branch (1119:21): [True: 15.0k, False: 122M]
  ------------------
 1120|   122M|                matchLength = (int)LZ4_count(ip+MINMATCH, matchPtr+MINMATCH, vLimit) + MINMATCH;
  ------------------
  |  |  242|   122M|#define MINMATCH 4
  ------------------
                              matchLength = (int)LZ4_count(ip+MINMATCH, matchPtr+MINMATCH, vLimit) + MINMATCH;
  ------------------
  |  |  242|   122M|#define MINMATCH 4
  ------------------
                              matchLength = (int)LZ4_count(ip+MINMATCH, matchPtr+MINMATCH, vLimit) + MINMATCH;
  ------------------
  |  |  242|   122M|#define MINMATCH 4
  ------------------
 1121|   122M|                if ((ip+matchLength == vLimit) && (vLimit < iHighLimit))
  ------------------
  |  Branch (1121:21): [True: 568k, False: 121M]
  |  Branch (1121:51): [True: 568k, False: 151]
  ------------------
 1122|   568k|                    matchLength += LZ4_count(ip+matchLength, prefixPtr, iHighLimit);
 1123|   122M|                back = lookBackLength ? LZ4HC_countBack(ip, matchPtr, iLowLimit, dictStart) : 0;
  ------------------
  |  Branch (1123:24): [True: 11.6M, False: 110M]
  ------------------
 1124|   122M|                matchLength -= back;
 1125|   122M|                if (matchLength > longest) {
  ------------------
  |  Branch (1125:21): [True: 469k, False: 121M]
  ------------------
 1126|   469k|                    longest = matchLength;
 1127|   469k|                    offset = (int)(ipIndex - matchIndex);
 1128|   469k|                    sBack = back;
 1129|   469k|                    DEBUGLOG(7, "Found match of len=%i within dict, offset=%i, back=%i", longest, offset, -back);
  ------------------
  |  |  289|   469k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1130|   469k|                    HEX_CMP(7, ip + back, matchPtr + back, (size_t)matchLength);
 1131|   469k|        }   }   }
 1132|       |
 1133|  1.55G|        if (chainSwap && matchLength==longest && matchIndex + (U32)longest <= ipIndex) {   /* better match => select a better chain */
  ------------------
  |  Branch (1133:13): [True: 1.11G, False: 443M]
  |  Branch (1133:26): [True: 23.6M, False: 1.09G]
  |  Branch (1133:50): [True: 22.9M, False: 668k]
  ------------------
 1134|  22.9M|            U32 const distanceToNextMatch = LZ4HC_sparsestChain(chainTable, matchIndex, longest, &matchChainPos);
 1135|  22.9M|            assert(lookBackLength==0);   /* search forward only */
  ------------------
  |  Branch (1135:13): [True: 0, False: 22.9M]
  |  Branch (1135:13): [True: 22.9M, False: 0]
  ------------------
 1136|  22.9M|            if (distanceToNextMatch > 1) {
  ------------------
  |  Branch (1136:17): [True: 14.5M, False: 8.45M]
  ------------------
 1137|  14.5M|                if (distanceToNextMatch > matchIndex) break;   /* avoid overflow */
  ------------------
  |  Branch (1137:21): [True: 0, False: 14.5M]
  ------------------
 1138|  14.5M|                matchIndex -= distanceToNextMatch;
 1139|  14.5M|                continue;
 1140|  14.5M|        }   }
 1141|       |
 1142|  1.54G|        {   U32 const distNextMatch = DELTANEXTU16(chainTable, matchIndex);
  ------------------
  |  |  239|  1.54G|#define DELTANEXTU16(table, pos) table[(U16)(pos)]   /* faster */
  ------------------
 1143|  1.54G|            if (patternAnalysis && distNextMatch==1 && matchChainPos==0) {
  ------------------
  |  Branch (1143:17): [True: 1.44G, False: 101M]
  |  Branch (1143:36): [True: 433M, False: 1.00G]
  |  Branch (1143:56): [True: 301M, False: 132M]
  ------------------
 1144|   301M|                U32 const matchCandidateIdx = matchIndex-1;
 1145|   301M|                size_t forwardPatternLength, backLength;
 1146|       |                /* may be a repeated pattern */
 1147|   301M|                if (repeat == rep_untested) {
  ------------------
  |  Branch (1147:21): [True: 2.01M, False: 299M]
  ------------------
 1148|  2.01M|                    if ( ((pattern & 0xFFFF) == (pattern >> 16))
  ------------------
  |  Branch (1148:26): [True: 1.99M, False: 16.5k]
  ------------------
 1149|  2.01M|                      &  ((pattern & 0xFF)   == (pattern >> 24)) ) {
 1150|  1.99M|                        DEBUGLOG(7, "Repeat pattern detected, char %02X", pattern >> 24);
  ------------------
  |  |  289|  1.99M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1151|  1.99M|                        repeat = rep_confirmed;
 1152|  1.99M|                        srcPatternLength = LZ4HC_countPattern(ip+sizeof(pattern), iHighLimit, pattern) + sizeof(pattern);
 1153|  1.99M|                    } else {
 1154|  16.5k|                        repeat = rep_not;
 1155|  16.5k|                }   }
 1156|   301M|                if ( (repeat == rep_confirmed) && (matchCandidateIdx >= lowestMatchIndex)
  ------------------
  |  Branch (1156:22): [True: 297M, False: 4.58M]
  |  Branch (1156:51): [True: 297M, False: 8.40k]
  ------------------
 1157|   297M|                  && LZ4HC_protectDictEnd(prefixIdx, matchCandidateIdx)
  ------------------
  |  Branch (1157:22): [True: 297M, False: 0]
  ------------------
 1158|   297M|                  && LZ4HC_patternSegment(hc4, matchCandidateIdx, pattern, iHighLimit, lowestMatchIndex,
  ------------------
  |  Branch (1158:22): [True: 296M, False: 135k]
  ------------------
 1159|   297M|                                          &forwardPatternLength, &backLength) ) {
 1160|   296M|                    size_t const currentSegmentLength = backLength + forwardPatternLength;
 1161|       |                    /* if the full source pattern fits (and hasn't been reached yet), jump to its best position :
 1162|       |                     * at the end of the segment, it might be followed by more match.
 1163|       |                     * Otherwise, jump to the farthest position in the segment : the longest match, plus maybe some back */
 1164|   296M|                    int const fullPatternFits = (currentSegmentLength >= srcPatternLength)
  ------------------
  |  Branch (1164:49): [True: 176M, False: 120M]
  ------------------
 1165|   176M|                                             && (forwardPatternLength <= srcPatternLength);
  ------------------
  |  Branch (1165:49): [True: 79.0M, False: 97.3M]
  ------------------
 1166|   296M|                    U32 const newMatchIndex = fullPatternFits ?
  ------------------
  |  Branch (1166:47): [True: 79.0M, False: 217M]
  ------------------
 1167|  79.0M|                                              matchCandidateIdx + (U32)forwardPatternLength - (U32)srcPatternLength :
 1168|   296M|                                              matchCandidateIdx - (U32)backLength;
 1169|   296M|                    if (!LZ4HC_protectDictEnd(prefixIdx, newMatchIndex)) {
  ------------------
  |  Branch (1169:25): [True: 8.62k, False: 296M]
  ------------------
 1170|       |                        /* Can only happen if started in the prefix */
 1171|  8.62k|                        assert(newMatchIndex >= prefixIdx - 3 && newMatchIndex < prefixIdx && matchCandidateIdx >= prefixIdx);
  ------------------
  |  Branch (1171:25): [True: 0, False: 8.62k]
  |  Branch (1171:25): [True: 0, False: 0]
  |  Branch (1171:25): [True: 0, False: 0]
  |  Branch (1171:25): [True: 8.62k, False: 0]
  |  Branch (1171:25): [True: 8.62k, False: 0]
  |  Branch (1171:25): [True: 8.62k, False: 0]
  ------------------
 1172|  8.62k|                        matchIndex = prefixIdx;
 1173|  8.62k|                        continue;
 1174|  8.62k|                    }
 1175|   296M|                    matchIndex = newMatchIndex;
 1176|   296M|                    if (!fullPatternFits && lookBackLength==0) {  /* no back possible : the match length is known */
  ------------------
  |  Branch (1176:25): [True: 217M, False: 79.0M]
  |  Branch (1176:45): [True: 199M, False: 18.0M]
  ------------------
 1177|   199M|                        size_t const maxML = MIN(currentSegmentLength, srcPatternLength);
  ------------------
  |  |   88|   199M|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (88:22): [True: 113M, False: 85.7M]
  |  |  ------------------
  ------------------
 1178|   199M|                        if ((size_t)longest < maxML) {
  ------------------
  |  Branch (1178:29): [True: 716k, False: 199M]
  ------------------
 1179|   716k|                            assert(prefixPtr - prefixIdx + matchIndex != ip);
  ------------------
  |  Branch (1179:29): [True: 0, False: 716k]
  |  Branch (1179:29): [True: 716k, False: 0]
  ------------------
 1180|   716k|                            if ((size_t)(ip - prefixPtr) + prefixIdx - matchIndex > LZ4_DISTANCE_MAX) break;
  ------------------
  |  |  691|   716k|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (1180:33): [True: 0, False: 716k]
  ------------------
 1181|   716k|                            assert(maxML < 2 GB);
  ------------------
  |  Branch (1181:29): [True: 0, False: 716k]
  |  Branch (1181:29): [True: 716k, False: 0]
  ------------------
 1182|   716k|                            longest = (int)maxML;
 1183|   716k|                            offset = (int)(ipIndex - matchIndex);
 1184|   716k|                            assert(sBack == 0);
  ------------------
  |  Branch (1184:29): [True: 0, False: 716k]
  |  Branch (1184:29): [True: 716k, False: 0]
  ------------------
 1185|   716k|                            DEBUGLOG(7, "Found repeat pattern match of len=%i, offset=%i", longest, offset);
  ------------------
  |  |  289|   716k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1186|   716k|                        }
 1187|   199M|                        {   U32 const distToNextPattern = DELTANEXTU16(chainTable, matchIndex);
  ------------------
  |  |  239|   199M|#define DELTANEXTU16(table, pos) table[(U16)(pos)]   /* faster */
  ------------------
 1188|   199M|                            if (distToNextPattern > matchIndex) break;  /* avoid overflow */
  ------------------
  |  Branch (1188:33): [True: 0, False: 199M]
  ------------------
 1189|   199M|                            matchIndex -= distToNextPattern;
 1190|   199M|                    }   }
 1191|   296M|                    continue;
 1192|   296M|                }
 1193|   301M|        }   }   /* PA optimization */
 1194|       |
 1195|       |        /* follow current chain */
 1196|  1.24G|        matchIndex -= DELTANEXTU16(chainTable, matchIndex + matchChainPos);
  ------------------
  |  |  239|  1.24G|#define DELTANEXTU16(table, pos) table[(U16)(pos)]   /* faster */
  ------------------
 1197|       |
 1198|  1.24G|    }  /* while ((matchIndex>=lowestMatchIndex) && (nbAttempts)) */
 1199|       |
 1200|  86.5M|    if ( dict == usingDictCtxHc
  ------------------
  |  Branch (1200:10): [True: 0, False: 86.5M]
  ------------------
 1201|      0|      && nbAttempts > 0
  ------------------
  |  Branch (1201:10): [True: 0, False: 0]
  ------------------
 1202|      0|      && longest < maxLength
  ------------------
  |  Branch (1202:10): [True: 0, False: 0]
  ------------------
 1203|      0|      && withinStartDistance) {
  ------------------
  |  Branch (1203:10): [True: 0, False: 0]
  ------------------
 1204|      0|        size_t const dictEndOffset = (size_t)(dictCtx->end - dictCtx->prefixStart) + dictCtx->dictLimit;
 1205|      0|        U32 dictMatchIndex = dictCtx->hashTable[LZ4HC_hashPtr(ip)];
 1206|      0|        assert(dictEndOffset <= 1 GB);
  ------------------
  |  Branch (1206:9): [True: 0, False: 0]
  |  Branch (1206:9): [True: 0, False: 0]
  ------------------
 1207|      0|        matchIndex = dictMatchIndex + lowestMatchIndex - (U32)dictEndOffset;
 1208|      0|        if (dictMatchIndex>0) DEBUGLOG(7, "dictEndOffset = %zu, dictMatchIndex = %u => relative matchIndex = %i", dictEndOffset, dictMatchIndex, (int)dictMatchIndex - (int)dictEndOffset);
  ------------------
  |  |  289|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
  |  Branch (1208:13): [True: 0, False: 0]
  ------------------
 1209|      0|        while (ipIndex - matchIndex <= LZ4_DISTANCE_MAX && longest < maxLength && nbAttempts--) {
  ------------------
  |  |  691|      0|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (1209:16): [True: 0, False: 0]
  |  Branch (1209:60): [True: 0, False: 0]
  |  Branch (1209:83): [True: 0, False: 0]
  ------------------
 1210|      0|            const BYTE* const matchPtr = dictCtx->prefixStart - dictCtx->dictLimit + dictMatchIndex;
 1211|       |
 1212|      0|            if (LZ4_read32(matchPtr) == pattern) {
  ------------------
  |  Branch (1212:17): [True: 0, False: 0]
  ------------------
 1213|      0|                int mlt;
 1214|      0|                int back = 0;
 1215|      0|                const BYTE* vLimit = ip + (dictEndOffset - dictMatchIndex);
 1216|      0|                if (vLimit > iHighLimit) vLimit = iHighLimit;
  ------------------
  |  Branch (1216:21): [True: 0, False: 0]
  ------------------
 1217|      0|                mlt = (int)LZ4_count(ip+MINMATCH, matchPtr+MINMATCH, vLimit) + MINMATCH;
  ------------------
  |  |  242|      0|#define MINMATCH 4
  ------------------
                              mlt = (int)LZ4_count(ip+MINMATCH, matchPtr+MINMATCH, vLimit) + MINMATCH;
  ------------------
  |  |  242|      0|#define MINMATCH 4
  ------------------
                              mlt = (int)LZ4_count(ip+MINMATCH, matchPtr+MINMATCH, vLimit) + MINMATCH;
  ------------------
  |  |  242|      0|#define MINMATCH 4
  ------------------
 1218|      0|                back = lookBackLength ? LZ4HC_countBack(ip, matchPtr, iLowLimit, dictCtx->prefixStart) : 0;
  ------------------
  |  Branch (1218:24): [True: 0, False: 0]
  ------------------
 1219|      0|                mlt -= back;
 1220|      0|                if (mlt > longest) {
  ------------------
  |  Branch (1220:21): [True: 0, False: 0]
  ------------------
 1221|      0|                    longest = mlt;
 1222|      0|                    offset = (int)(ipIndex - matchIndex);
 1223|      0|                    sBack = back;
 1224|      0|                    DEBUGLOG(7, "found match of length %i within extDictCtx", longest);
  ------------------
  |  |  289|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1225|      0|            }   }
 1226|       |
 1227|      0|            {   U32 const nextOffset = DELTANEXTU16(dictCtx->chainTable, dictMatchIndex);
  ------------------
  |  |  239|      0|#define DELTANEXTU16(table, pos) table[(U16)(pos)]   /* faster */
  ------------------
 1228|      0|                dictMatchIndex -= nextOffset;
 1229|      0|                matchIndex -= nextOffset;
 1230|      0|    }   }   }
 1231|       |
 1232|  86.5M|    {   LZ4HC_match_t md;
 1233|  86.5M|        assert(longest >= 0);
  ------------------
  |  Branch (1233:9): [True: 0, False: 86.5M]
  |  Branch (1233:9): [True: 86.5M, False: 0]
  ------------------
 1234|  86.5M|        md.len = longest;
 1235|  86.5M|        md.off = offset;
 1236|  86.5M|        md.back = sBack;
 1237|  86.5M|        return md;
 1238|  86.5M|    }
 1239|  86.5M|}
lz4hc.c:LZ4HC_sparsestChain:
  988|  22.9M|{
  989|  22.9M|    int const kTrigger = 4;
  990|  22.9M|    U32 distanceToNextMatch = 1;
  991|  22.9M|    int const end = longest - MINMATCH + 1;
  ------------------
  |  |  242|  22.9M|#define MINMATCH 4
  ------------------
  992|  22.9M|    int step = 1;
  993|  22.9M|    int accel = 1 << kTrigger;
  994|  22.9M|    int pos;
  995|  1.16G|    for (pos = 0; pos < end; pos += step) {
  ------------------
  |  Branch (995:19): [True: 1.13G, False: 22.9M]
  ------------------
  996|  1.13G|        U32 const candidateDist = DELTANEXTU16(chainTable, matchIndex + (U32)pos);
  ------------------
  |  |  239|  1.13G|#define DELTANEXTU16(table, pos) table[(U16)(pos)]   /* faster */
  ------------------
  997|  1.13G|        step = (accel++ >> kTrigger);
  998|  1.13G|        if (candidateDist > distanceToNextMatch) {
  ------------------
  |  Branch (998:13): [True: 18.6M, False: 1.12G]
  ------------------
  999|  18.6M|            distanceToNextMatch = candidateDist;
 1000|  18.6M|            *matchChainPosPtr = (U32)pos;
 1001|  18.6M|            accel = 1 << kTrigger;
 1002|  18.6M|    }   }
 1003|  22.9M|    return distanceToNextMatch;
 1004|  22.9M|}
lz4hc.c:LZ4HC_countPattern:
  921|   298M|{
  922|   298M|    const BYTE* const iStart = ip;
  923|   298M|    reg_t const pattern = (sizeof(pattern)==8) ?
  ------------------
  |  Branch (923:27): [True: 298M, Folded]
  ------------------
  924|   298M|        (reg_t)pattern32 + (((reg_t)pattern32) << (sizeof(pattern)*4)) : pattern32;
  925|       |
  926|   610M|    while (likely(ip < iEnd-(sizeof(pattern)-1))) {
  927|   610M|        reg_t const diff = LZ4_read_ARCH(ip) ^ pattern;
  928|   610M|        if (!diff) { ip+=sizeof(pattern); continue; }
  ------------------
  |  Branch (928:13): [True: 312M, False: 298M]
  ------------------
  929|   298M|        ip += LZ4_NbCommonBytes(diff);
  930|   298M|        return (unsigned)(ip - iStart);
  931|   610M|    }
  932|       |
  933|  61.3k|    if (LZ4_isLittleEndian()) {
  ------------------
  |  Branch (933:9): [True: 61.3k, False: 0]
  ------------------
  934|  61.3k|        reg_t patternByte = pattern;
  935|   203k|        while ((ip<iEnd) && (*ip == (BYTE)patternByte)) {
  ------------------
  |  Branch (935:16): [True: 160k, False: 43.0k]
  |  Branch (935:29): [True: 141k, False: 18.3k]
  ------------------
  936|   141k|            ip++; patternByte >>= 8;
  937|   141k|        }
  938|  61.3k|    } else {  /* big endian */
  939|      0|        U32 bitOffset = (sizeof(pattern)*8) - 8;
  940|      0|        while (ip < iEnd) {
  ------------------
  |  Branch (940:16): [True: 0, False: 0]
  ------------------
  941|      0|            BYTE const byte = (BYTE)(pattern >> bitOffset);
  942|      0|            if (*ip != byte) break;
  ------------------
  |  Branch (942:17): [True: 0, False: 0]
  ------------------
  943|      0|            ip ++; bitOffset -= 8;
  944|      0|    }   }
  945|       |
  946|  61.3k|    return (unsigned)(ip - iStart);
  947|   298M|}
lz4hc.c:LZ4HC_protectDictEnd:
  975|   593M|{
  976|   593M|    return ((U32)((dictLimit - 1) - matchIndex) >= 3);
  977|   593M|}
lz4hc.c:LZ4HC_patternSegment:
 1015|   297M|{
 1016|   297M|    const BYTE* const prefixPtr = hc4->prefixStart;
 1017|   297M|    U32 const prefixIdx = hc4->dictLimit;
 1018|   297M|    const BYTE* const dictStart = hc4->dictStart;
 1019|   297M|    U32 const dictIdx = hc4->lowLimit;
 1020|   297M|    const BYTE* const dictEnd = dictStart + prefixIdx - dictIdx;
 1021|   297M|    int const extDict = candidateIdx < prefixIdx;
 1022|   297M|    const BYTE* const matchPtr = extDict ? dictStart + (candidateIdx - dictIdx) : prefixPtr + (candidateIdx - prefixIdx);
  ------------------
  |  Branch (1022:34): [True: 29.1M, False: 267M]
  ------------------
 1023|   297M|    size_t forward, back;
 1024|   297M|    if (LZ4_read32(matchPtr) != pattern) return 0;
  ------------------
  |  Branch (1024:9): [True: 135k, False: 296M]
  ------------------
 1025|       |
 1026|   296M|    {   const BYTE* const iLimit = extDict ? dictEnd : iHighLimit;
  ------------------
  |  Branch (1026:36): [True: 29.1M, False: 267M]
  ------------------
 1027|   296M|        forward = LZ4HC_countPattern(matchPtr+sizeof(pattern), iLimit, pattern) + sizeof(pattern);
 1028|   296M|        if (extDict && matchPtr + forward == iLimit) {   /* continues into the prefix */
  ------------------
  |  Branch (1028:13): [True: 29.1M, False: 267M]
  |  Branch (1028:24): [True: 30.9k, False: 29.0M]
  ------------------
 1029|  30.9k|            U32 const rotatedPattern = LZ4HC_rotatePattern(forward, pattern);
 1030|  30.9k|            forward += LZ4HC_countPattern(prefixPtr, iHighLimit, rotatedPattern);
 1031|  30.9k|    }   }
 1032|       |
 1033|   296M|    back = LZ4HC_reverseCountPattern(matchPtr, extDict ? dictStart : prefixPtr, pattern);
  ------------------
  |  Branch (1033:48): [True: 29.1M, False: 267M]
  ------------------
 1034|   296M|    if (!extDict && matchPtr - back == prefixPtr && dictIdx < prefixIdx) {   /* continues into the external dictionary */
  ------------------
  |  Branch (1034:9): [True: 267M, False: 29.1M]
  |  Branch (1034:21): [True: 186k, False: 267M]
  |  Branch (1034:53): [True: 124k, False: 62.3k]
  ------------------
 1035|   124k|        U32 const rotatedPattern = LZ4HC_rotatePattern((U32)(-(int)back), pattern);
 1036|   124k|        back += LZ4HC_reverseCountPattern(dictEnd, dictStart, rotatedPattern);
 1037|   124k|    }
 1038|       |    /* don't go below lowestMatchIndex */
 1039|   296M|    back = candidateIdx - MAX(candidateIdx - (U32)back, lowestMatchIndex);
  ------------------
  |  |   90|   296M|#define MAX(a,b)   ( (a) > (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (90:22): [True: 296M, False: 194k]
  |  |  ------------------
  ------------------
 1040|   296M|    assert(candidateIdx - back >= lowestMatchIndex);
  ------------------
  |  Branch (1040:5): [True: 0, False: 296M]
  |  Branch (1040:5): [True: 296M, False: 0]
  ------------------
 1041|       |
 1042|   296M|    *forwardPtr = forward;
 1043|   296M|    *backPtr = back;
 1044|   296M|    return 1;
 1045|   296M|}
lz4hc.c:LZ4HC_rotatePattern:
  911|   155k|{
  912|   155k|    size_t const bitsToRotate = (rotate & (sizeof(pattern) - 1)) << 3;
  913|   155k|    if (bitsToRotate == 0) return pattern;
  ------------------
  |  Branch (913:9): [True: 37.0k, False: 118k]
  ------------------
  914|   118k|    return LZ4HC_rotl32(pattern, (int)bitsToRotate);
  ------------------
  |  |  906|   118k|#  define LZ4HC_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  ------------------
  915|   155k|}
lz4hc.c:LZ4HC_reverseCountPattern:
  954|   297M|{
  955|   297M|    const BYTE* const iStart = ip;
  956|       |
  957|  4.49G|    while (likely(ip >= iLow+4)) {
  958|  4.49G|        if (LZ4_read32(ip-4) != pattern) break;
  ------------------
  |  Branch (958:13): [True: 296M, False: 4.19G]
  ------------------
  959|  4.19G|        ip -= 4;
  960|  4.19G|    }
  961|   297M|    {   const BYTE* bytePtr = (const BYTE*)(&pattern) + 3; /* works for any endianness */
  962|   758M|        while (likely(ip>iLow)) {
  963|   758M|            if (ip[-1] != *bytePtr) break;
  ------------------
  |  Branch (963:17): [True: 296M, False: 462M]
  ------------------
  964|   462M|            ip--; bytePtr--;
  965|   462M|    }   }
  966|   297M|    return (unsigned)(iStart - ip);
  967|   297M|}
lz4hc.c:LZ4HC_compress_optimal:
 2192|  6.88k|{
 2193|  6.88k|    LZ4_STATIC_ASSERT(LZ4_STREAMHC_EXTSIZE == sizeof(LZ4_streamHC_t) + sizeof(LZ4HC_optimal_t) * (LZ4_OPT_NUM + TRAILING_LITERALS));
  ------------------
  |  |  277|  6.88k|#define LZ4_STATIC_ASSERT(c)   { enum { LZ4_static_assert = 1/(int)(!!(c)) }; }   /* use after variable declarations */
  ------------------
 2194|  6.88k|    if (ctx->hasWorkspace) {   /* extended state : the buffer follows it */
  ------------------
  |  Branch (2194:9): [True: 6.88k, False: 0]
  ------------------
 2195|  6.88k|        LZ4HC_optimal_t* const opt = (LZ4HC_optimal_t*)(void*)((BYTE*)ctx + sizeof(LZ4_streamHC_t));
 2196|  6.88k|        return LZ4HC_compress_optimal_internal(ctx, source, dst, srcSizePtr, dstCapacity,
 2197|  6.88k|                    nbSearches, nbSearchesSeq, targetLength, limit, dict, favorDecSpeed, opt);
 2198|  6.88k|    }
 2199|      0|  { /* plain state */
 2200|      0|#if defined(LZ4HC_HEAPMODE) && LZ4HC_HEAPMODE==1
 2201|      0|    LZ4HC_optimal_t* const opt = (LZ4HC_optimal_t*)ALLOC(sizeof(LZ4HC_optimal_t) * (LZ4_OPT_NUM + TRAILING_LITERALS));
  ------------------
  |  |  225|      0|# define ALLOC(s)          malloc(s)
  ------------------
 2202|      0|    int result;
 2203|      0|    if (opt == NULL) return 0;
  ------------------
  |  Branch (2203:9): [True: 0, False: 0]
  ------------------
 2204|      0|    result = LZ4HC_compress_optimal_internal(ctx, source, dst, srcSizePtr, dstCapacity,
 2205|      0|                    nbSearches, nbSearchesSeq, targetLength, limit, dict, favorDecSpeed, opt);
 2206|      0|    FREEMEM(opt);
  ------------------
  |  |  227|      0|# define FREEMEM(p)        free(p)
  ------------------
 2207|      0|    return result;
 2208|       |#else
 2209|       |    LZ4HC_optimal_t opt[LZ4_OPT_NUM + TRAILING_LITERALS];   /* ~64 KB, which can be a bit large for some stacks... */
 2210|       |    return LZ4HC_compress_optimal_internal(ctx, source, dst, srcSizePtr, dstCapacity,
 2211|       |                    nbSearches, nbSearchesSeq, targetLength, limit, dict, favorDecSpeed, opt);
 2212|       |#endif
 2213|      0|  }
 2214|      0|}
lz4hc.c:LZ4HC_compress_optimal_internal:
 2045|  6.88k|{
 2046|  6.88k|    const BYTE* ip = (const BYTE*) source;
 2047|  6.88k|    const BYTE* anchor = ip;
 2048|  6.88k|    const int inputSize = *srcSizePtr;
 2049|  6.88k|    const BYTE* const iend = ip + inputSize;
 2050|  6.88k|    const BYTE* mflimit;      /* set after the size check : would precede a small input */
 2051|  6.88k|    const BYTE* matchlimit;
 2052|  6.88k|    BYTE* op = (BYTE*) dst;
 2053|       |    /* fillOutput : keep room for the final run of literals (LZ4 format restriction) */
 2054|  6.88k|    BYTE* const oend = op + dstCapacity - ((limit == fillOutput) ? LASTLITERALS : 0);
  ------------------
  |  |  245|      0|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  |  Branch (2054:44): [True: 0, False: 6.88k]
  ------------------
 2055|  6.88k|    int const sufficientLen = MIN(targetLength, LZ4_OPT_NUM-1);
  ------------------
  |  |   88|  6.88k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (88:22): [True: 1.90k, False: 4.97k]
  |  |  ------------------
  ------------------
 2056|       |
 2057|  6.88k|    DEBUGLOG(5, "LZ4HC_compress_optimal(dst=%p, dstCapa=%u)", dst, (unsigned)dstCapacity);
  ------------------
  |  |  289|  6.88k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2058|       |
 2059|       |    /* preconditions verifications */
 2060|  6.88k|    assert(dstCapacity > 0);
  ------------------
  |  Branch (2060:5): [True: 0, False: 6.88k]
  |  Branch (2060:5): [True: 6.88k, False: 0]
  ------------------
 2061|  6.88k|    assert(dst != NULL);
  ------------------
  |  Branch (2061:5): [True: 0, False: 6.88k]
  |  Branch (2061:5): [True: 6.88k, False: 0]
  ------------------
 2062|  6.88k|    assert(*srcSizePtr > 0);
  ------------------
  |  Branch (2062:5): [True: 0, False: 6.88k]
  |  Branch (2062:5): [True: 6.88k, False: 0]
  ------------------
 2063|  6.88k|    assert(source != NULL);
  ------------------
  |  Branch (2063:5): [True: 0, False: 6.88k]
  |  Branch (2063:5): [True: 6.88k, False: 0]
  ------------------
 2064|  6.88k|    assert(opt != NULL);
  ------------------
  |  Branch (2064:5): [True: 0, False: 6.88k]
  |  Branch (2064:5): [True: 6.88k, False: 0]
  ------------------
 2065|  6.88k|    assert(nbSearchesSeq >= 1);
  ------------------
  |  Branch (2065:5): [True: 0, False: 6.88k]
  |  Branch (2065:5): [True: 6.88k, False: 0]
  ------------------
 2066|       |
 2067|  6.88k|    *srcSizePtr = 0;
 2068|  6.88k|    if (inputSize < LZ4_minLength) goto _last_literals;
  ------------------
  |  Branch (2068:9): [True: 572, False: 6.31k]
  ------------------
 2069|  6.31k|    mflimit = iend - MFLIMIT;
  ------------------
  |  |  246|  6.31k|#define MFLIMIT       12   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
 2070|  6.31k|    matchlimit = iend - LASTLITERALS;
  ------------------
  |  |  245|  6.31k|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
 2071|       |
 2072|       |    /* Main Loop */
 2073|  32.1M|    while (ip <= mflimit) {
  ------------------
  |  Branch (2073:12): [True: 32.1M, False: 6.28k]
  ------------------
 2074|  32.1M|        int const llen = LZ4HC_pricedLitlen((int)(ip - anchor));
 2075|  32.1M|        int cur, lastPos;
 2076|  32.1M|        int lastSeqPos;         /* position of the last sequence to encode */
 2077|  32.1M|        LZ4HC_match_t lastSeq;
 2078|       |
 2079|  32.1M|        LZ4HC_match_t const firstMatch = LZ4HC_FindLongestMatch(ctx, ip, matchlimit, nbSearches, dict, favorDecSpeed);
 2080|  32.1M|        if (firstMatch.len==0) { ip++; continue; }
  ------------------
  |  Branch (2080:13): [True: 31.0M, False: 1.12M]
  ------------------
 2081|       |
 2082|  1.12M|        if (firstMatch.len > sufficientLen) {
  ------------------
  |  Branch (2082:13): [True: 33.2k, False: 1.09M]
  ------------------
 2083|       |            /* good enough solution : immediate encoding */
 2084|  33.2k|            lastSeqPos = 0;
 2085|  33.2k|            lastSeq = firstMatch;
 2086|  33.2k|            goto encode;
 2087|  33.2k|        }
 2088|       |
 2089|       |        /* set prices for first positions (literals) */
 2090|  1.09M|        {   int rPos;
 2091|  5.48M|            for (rPos = 0 ; rPos < MINMATCH ; rPos++)
  ------------------
  |  |  242|  5.48M|#define MINMATCH 4
  ------------------
  |  Branch (2091:29): [True: 4.38M, False: 1.09M]
  ------------------
 2092|  4.38M|                LZ4HC_setLiteral(opt, rPos, llen + rPos, LZ4HC_literalsPrice(llen + rPos));
 2093|  1.09M|        }
 2094|  1.09M|        lastPos = LZ4HC_addMatch(opt, 0, firstMatch, 0, favorDecSpeed);
 2095|       |
 2096|       |        /* check further positions */
 2097|  65.6M|        for (cur = 1; cur < lastPos; cur++) {
  ------------------
  |  Branch (2097:23): [True: 64.5M, False: 1.08M]
  ------------------
 2098|  64.5M|            const BYTE* const curPtr = ip + cur;
 2099|  64.5M|            LZ4HC_match_t newMatch;
 2100|  64.5M|            int nbS = nbSearches;
 2101|       |
 2102|  64.5M|            if (curPtr > mflimit) break;
  ------------------
  |  Branch (2102:17): [True: 4.10k, False: 64.5M]
  ------------------
 2103|  64.5M|            DEBUGLOG(7, "rPos:%u[%u] vs [%u]%u",
  ------------------
  |  |  289|  64.5M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2104|  64.5M|                    cur, opt[cur].price, opt[cur+1].price, cur+1);
 2105|       |            /* not useful to search here if next position has same (or lower) cost */
 2106|  64.5M|            if (opt[cur+1].price <= opt[cur].price) continue;
  ------------------
  |  Branch (2106:17): [True: 60.1M, False: 4.38M]
  ------------------
 2107|       |            /* favorDecSpeed : next position costs less than one more byte, the difference comes from sequences.
 2108|       |             * A match starting here might save some : worth a cheaper search, if close to lastPos */
 2109|  4.38M|            if (favorDecSpeed && (opt[cur+1].price < opt[cur].price + LZ4HC_PRICE_SCALE)) {
  ------------------
  |  | 1898|  2.13M|#define LZ4HC_PRICE_SCALE 4
  ------------------
  |  Branch (2109:17): [True: 2.13M, False: 2.24M]
  |  Branch (2109:34): [True: 617k, False: 1.51M]
  ------------------
 2110|   617k|                if (lastPos - cur > LZ4HC_SEQ_SEARCH_DIST) continue;
  ------------------
  |  | 1907|   617k|#define LZ4HC_SEQ_SEARCH_DIST  4
  ------------------
  |  Branch (2110:21): [True: 426k, False: 191k]
  ------------------
 2111|   191k|                nbS = nbSearchesSeq;
 2112|   191k|            }
 2113|       |
 2114|  3.95M|            newMatch = LZ4HC_FindLongestMatch(ctx, curPtr, matchlimit, nbS, dict, favorDecSpeed);
 2115|  3.95M|            if (!newMatch.len) continue;
  ------------------
  |  Branch (2115:17): [True: 700k, False: 3.25M]
  ------------------
 2116|       |
 2117|  3.25M|            if ( (newMatch.len > sufficientLen)
  ------------------
  |  Branch (2117:18): [True: 4.96k, False: 3.25M]
  ------------------
 2118|  3.25M|              || (newMatch.len + cur >= LZ4_OPT_NUM) ) {
  ------------------
  |  |   83|  3.25M|#define LZ4_OPT_NUM   (1<<12)
  ------------------
  |  Branch (2118:18): [True: 1.14k, False: 3.25M]
  ------------------
 2119|       |                /* immediate encoding */
 2120|  6.11k|                lastSeqPos = cur;
 2121|  6.11k|                lastSeq = newMatch;
 2122|  6.11k|                goto encode;
 2123|  6.11k|            }
 2124|       |
 2125|  3.25M|            lastPos = LZ4HC_addMatch(opt, cur, newMatch, lastPos, favorDecSpeed);
 2126|  3.25M|        }  /* for (cur = 1; cur < lastPos; cur++) */
 2127|       |
 2128|  1.09M|        assert(lastPos < LZ4_OPT_NUM + TRAILING_LITERALS);
  ------------------
  |  Branch (2128:9): [True: 0, False: 1.09M]
  |  Branch (2128:9): [True: 1.09M, False: 0]
  ------------------
 2129|  1.09M|        lastSeq.len = opt[lastPos].mlen;
 2130|  1.09M|        lastSeq.off = opt[lastPos].off;
 2131|  1.09M|        lastSeqPos = lastPos - lastSeq.len;
 2132|       |
 2133|  1.12M|encode: /* lastSeqPos and lastSeq must be set */
 2134|  1.12M|        assert(0 <= lastSeqPos && lastSeqPos < LZ4_OPT_NUM);
  ------------------
  |  Branch (2134:9): [True: 0, False: 1.12M]
  |  Branch (2134:9): [True: 0, False: 0]
  |  Branch (2134:9): [True: 1.12M, False: 0]
  |  Branch (2134:9): [True: 1.12M, False: 0]
  ------------------
 2135|  1.12M|        DEBUGLOG(6, "reverse traversal, looking for shortest path (lastSeqPos=%i)", lastSeqPos);
  ------------------
  |  |  289|  1.12M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2136|       |        /* opt[pos] describes the step ending at pos.
 2137|       |         * Walk the path backward, moving each step to its starting position instead */
 2138|  1.12M|        {   int pos = lastSeqPos;
 2139|  1.12M|            int mlen = lastSeq.len;
 2140|  1.12M|            int off = lastSeq.off;
 2141|  1.79M|            while (pos > 0) {
  ------------------
  |  Branch (2141:20): [True: 662k, False: 1.12M]
  ------------------
 2142|   662k|                int const prevMlen = opt[pos].mlen;
 2143|   662k|                int const prevOff = opt[pos].off;
 2144|   662k|                opt[pos].mlen = mlen;
 2145|   662k|                opt[pos].off = off;
 2146|   662k|                mlen = prevMlen;
 2147|   662k|                off = prevOff;
 2148|   662k|                assert(0 < mlen && mlen <= pos);
  ------------------
  |  Branch (2148:17): [True: 0, False: 662k]
  |  Branch (2148:17): [True: 0, False: 0]
  |  Branch (2148:17): [True: 662k, False: 0]
  |  Branch (2148:17): [True: 662k, False: 0]
  ------------------
 2149|   662k|                pos -= mlen;
 2150|   662k|            }
 2151|       |            /* first step of the path; note : opt[0] isn't necessarily initialized */
 2152|  1.12M|            opt[0].mlen = mlen;
 2153|  1.12M|            opt[0].off = off;
 2154|  1.12M|        }
 2155|       |
 2156|       |        /* encode all recorded sequences in order */
 2157|  1.12M|        {   int rPos = 0;  /* relative position (to ip) */
 2158|  2.92M|            while (rPos <= lastSeqPos) {
  ------------------
  |  Branch (2158:20): [True: 1.79M, False: 1.12M]
  ------------------
 2159|  1.79M|                int const ml = opt[rPos].mlen;
 2160|  1.79M|                int const offset = opt[rPos].off;
 2161|  1.79M|                if (ml == 1) { ip++; rPos++; continue; }  /* literal */
  ------------------
  |  Branch (2161:21): [True: 387k, False: 1.40M]
  ------------------
 2162|  1.40M|                rPos += ml;
 2163|  1.40M|                assert(ml >= MINMATCH);
  ------------------
  |  Branch (2163:17): [True: 0, False: 1.40M]
  |  Branch (2163:17): [True: 1.40M, False: 0]
  ------------------
 2164|  1.40M|                assert((offset >= 1) && (offset <= LZ4_DISTANCE_MAX));
  ------------------
  |  Branch (2164:17): [True: 0, False: 1.40M]
  |  Branch (2164:17): [True: 0, False: 0]
  |  Branch (2164:17): [True: 1.40M, False: 0]
  |  Branch (2164:17): [True: 1.40M, False: 0]
  ------------------
 2165|  1.40M|                if ( LZ4HC_encodeSequence(UPDATABLE(ip, op, anchor), ml, offset, limit, oend) ) {  /* updates ip, op and anchor */
  ------------------
  |  |  241|  1.40M|#define UPDATABLE(ip, op, anchor) &ip, &op, &anchor
  ------------------
  |  Branch (2165:22): [True: 25, False: 1.40M]
  ------------------
 2166|     25|                    if (limit != fillOutput) return 0;  /* compression failed */
  ------------------
  |  Branch (2166:25): [True: 25, False: 0]
  ------------------
 2167|      0|                    LZ4HC_encodeLastSequence_fillOutput(UPDATABLE(ip, op, anchor), ml, offset, oend);
  ------------------
  |  |  241|      0|#define UPDATABLE(ip, op, anchor) &ip, &op, &anchor
  ------------------
 2168|      0|                    goto _last_literals;
 2169|     25|        }   }   }
 2170|  1.12M|    }  /* while (ip <= mflimit) */
 2171|       |
 2172|  6.86k|_last_literals:
 2173|  6.86k|    if (LZ4HC_encodeLastLiterals(UPDATABLE(ip, op, anchor), iend, limit, oend))
  ------------------
  |  |  241|  6.86k|#define UPDATABLE(ip, op, anchor) &ip, &op, &anchor
  ------------------
  |  Branch (2173:9): [True: 1.19k, False: 5.67k]
  ------------------
 2174|  1.19k|        return 0;  /* not enough space in @dst */
 2175|       |
 2176|       |    /* End */
 2177|  5.67k|    *srcSizePtr = (int) (((const char*)ip) - source);
 2178|  5.67k|    return (int) ((char*)op-dst);
 2179|  6.86k|}
lz4hc.c:LZ4HC_pricedLitlen:
 1937|  32.1M|{
 1938|  32.1M|    int const reduceFrom = (int)RUN_MASK + 255;
  ------------------
  |  |  263|  32.1M|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|  32.1M|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|  32.1M|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1939|  32.1M|    assert(llen >= 0);
  ------------------
  |  Branch (1939:5): [True: 0, False: 32.1M]
  |  Branch (1939:5): [True: 32.1M, False: 0]
  ------------------
 1940|  32.1M|    if (llen < reduceFrom) return llen;
  ------------------
  |  Branch (1940:9): [True: 8.92M, False: 23.2M]
  ------------------
 1941|  23.2M|    return reduceFrom + ((llen - (int)RUN_MASK) % 255);
  ------------------
  |  |  263|  23.2M|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|  23.2M|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|  23.2M|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1942|  32.1M|}
lz4hc.c:LZ4HC_FindLongestMatch:
 1950|  36.0M|{
 1951|  36.0M|    LZ4HC_match_t const match0 = { 0 , 0, 0 };
 1952|       |    /* note : LZ4HC_InsertAndGetWiderMatch() can extend a match backward (md.back < 0),
 1953|       |     * but not here, since iLowLimit == ip */
 1954|  36.0M|    LZ4HC_match_t md = LZ4HC_InsertAndGetWiderMatch(ctx, ip, ip, iHighLimit, MINMATCH-1, nbSearches, 1 /*patternAnalysis*/, 1 /*chainSwap*/, dict, favorDecSpeed);
  ------------------
  |  |  242|  36.0M|#define MINMATCH 4
  ------------------
 1955|  36.0M|    assert(md.back == 0);
  ------------------
  |  Branch (1955:5): [True: 0, False: 36.0M]
  |  Branch (1955:5): [True: 36.0M, False: 0]
  ------------------
 1956|  36.0M|    if (md.len < MINMATCH) return match0;
  ------------------
  |  |  242|  36.0M|#define MINMATCH 4
  ------------------
  |  Branch (1956:9): [True: 31.7M, False: 4.38M]
  ------------------
 1957|  4.38M|    if (favorDecSpeed) {
  ------------------
  |  Branch (1957:9): [True: 1.95M, False: 2.43M]
  ------------------
 1958|  1.95M|        if ((md.len>18) & (md.len<=36)) md.len=18;   /* favor dec.speed (shortcut) */
  ------------------
  |  Branch (1958:13): [True: 429k, False: 1.52M]
  ------------------
 1959|  1.95M|    }
 1960|  4.38M|    return md;
 1961|  36.0M|}
lz4hc.c:LZ4HC_setLiteral:
 1965|  17.4M|{
 1966|  17.4M|    opt[pos].mlen = 1;
 1967|  17.4M|    opt[pos].off = 0;
 1968|  17.4M|    opt[pos].litlen = litlen;
 1969|  17.4M|    opt[pos].price = price;
 1970|  17.4M|    DEBUGLOG(7, "rPos:%3i => price:%3i (litlen=%i)", pos, price, litlen);
  ------------------
  |  |  289|  17.4M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1971|  17.4M|}
lz4hc.c:LZ4HC_literalsPrice:
 1910|   382M|{
 1911|   382M|    int price = litlen;
 1912|   382M|    assert(litlen >= 0);
  ------------------
  |  Branch (1912:5): [True: 0, False: 382M]
  |  Branch (1912:5): [True: 382M, False: 0]
  ------------------
 1913|   382M|    if (litlen >= (int)RUN_MASK)
  ------------------
  |  |  263|   382M|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|   382M|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|   382M|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1913:9): [True: 4.20M, False: 378M]
  ------------------
 1914|  4.20M|        price += 1 + ((litlen-(int)RUN_MASK) / 255);
  ------------------
  |  |  263|  4.20M|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|  4.20M|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|  4.20M|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1915|   382M|    return price * LZ4HC_PRICE_SCALE;
  ------------------
  |  | 1898|   382M|#define LZ4HC_PRICE_SCALE 4
  ------------------
 1916|   382M|}
lz4hc.c:LZ4HC_addMatch:
 1998|  4.34M|{
 1999|  4.34M|    int const ll = opt[cur].litlen;
 2000|  4.34M|    int const basePrice = LZ4HC_runStartPrice(opt, cur) + (favorDecSpeed ? LZ4HC_SEQ_PRICE_FDS : 0);
  ------------------
  |  | 1906|  1.92M|#define LZ4HC_SEQ_PRICE_FDS    1
  ------------------
  |  Branch (2000:60): [True: 1.92M, False: 2.42M]
  ------------------
 2001|  4.34M|    int ml;
 2002|  4.34M|    assert(cur + match.len < LZ4_OPT_NUM);
  ------------------
  |  Branch (2002:5): [True: 0, False: 4.34M]
  |  Branch (2002:5): [True: 4.34M, False: 0]
  ------------------
 2003|  4.34M|    assert((U32)favorDecSpeed <= 1);
  ------------------
  |  Branch (2003:5): [True: 0, False: 4.34M]
  |  Branch (2003:5): [True: 4.34M, False: 0]
  ------------------
 2004|   369M|    for (ml = MINMATCH; ml <= match.len; ml++) {
  ------------------
  |  |  242|  4.34M|#define MINMATCH 4
  ------------------
  |  Branch (2004:25): [True: 365M, False: 4.34M]
  ------------------
 2005|   365M|        int const pos = cur + ml;
 2006|   365M|        int const price = basePrice + LZ4HC_sequencePrice(ll, ml);
 2007|       |        /* on equal price, favorDecSpeed keeps the existing solution */
 2008|   365M|        if ( pos > lastPos + TRAILING_LITERALS
  ------------------
  |  | 1894|   730M|#define TRAILING_LITERALS 3
  ------------------
  |  Branch (2008:14): [True: 62.7M, False: 302M]
  ------------------
 2009|   302M|          || price <= opt[pos].price - (int)favorDecSpeed) {
  ------------------
  |  Branch (2009:14): [True: 8.16M, False: 294M]
  ------------------
 2010|  70.8M|            LZ4HC_setMatch(opt, pos, ml, match.off, price);
 2011|  70.8M|            if ((ml == match.len) && (lastPos < pos)) lastPos = pos;
  ------------------
  |  Branch (2011:17): [True: 2.01M, False: 68.8M]
  |  Branch (2011:38): [True: 1.98M, False: 31.1k]
  ------------------
 2012|  70.8M|    }   }
 2013|       |
 2014|       |    /* complete following positions with literals */
 2015|  4.34M|    {   int addLit;
 2016|  4.34M|        assert(opt[lastPos].mlen >= MINMATCH);
  ------------------
  |  Branch (2016:9): [True: 0, False: 4.34M]
  |  Branch (2016:9): [True: 4.34M, False: 0]
  ------------------
 2017|  17.3M|        for (addLit = 1; addLit <= TRAILING_LITERALS; addLit++)
  ------------------
  |  | 1894|  17.3M|#define TRAILING_LITERALS 3
  ------------------
  |  Branch (2017:26): [True: 13.0M, False: 4.34M]
  ------------------
 2018|  13.0M|            LZ4HC_setLiteral(opt, lastPos + addLit, addLit,
 2019|  13.0M|                             opt[lastPos].price + LZ4HC_literalsPrice(addLit));
 2020|  4.34M|    }
 2021|  4.34M|    return lastPos;
 2022|  4.34M|}
lz4hc.c:LZ4HC_runStartPrice:
 1986|  4.34M|{
 1987|  4.34M|    int const ll = opt[pos].litlen;
 1988|  4.34M|    return (ll <= pos) ? opt[pos - ll].price : 0;
  ------------------
  |  Branch (1988:12): [True: 2.67M, False: 1.67M]
  ------------------
 1989|  4.34M|}
lz4hc.c:LZ4HC_sequencePrice:
 1920|   365M|{
 1921|   365M|    int price = 1 + 2 ; /* token + 16-bit offset */
 1922|   365M|    assert(litlen >= 0);
  ------------------
  |  Branch (1922:5): [True: 0, False: 365M]
  |  Branch (1922:5): [True: 365M, False: 0]
  ------------------
 1923|   365M|    assert(mlen >= MINMATCH);
  ------------------
  |  Branch (1923:5): [True: 0, False: 365M]
  |  Branch (1923:5): [True: 365M, False: 0]
  ------------------
 1924|       |
 1925|   365M|    if (mlen >= (int)(ML_MASK+MINMATCH))
  ------------------
  |  |  261|   365M|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|   365M|#define ML_BITS  4
  |  |  ------------------
  ------------------
                  if (mlen >= (int)(ML_MASK+MINMATCH))
  ------------------
  |  |  242|   365M|#define MINMATCH 4
  ------------------
  |  Branch (1925:9): [True: 327M, False: 38.2M]
  ------------------
 1926|   327M|        price += 1 + ((mlen-(int)(ML_MASK+MINMATCH)) / 255);
  ------------------
  |  |  261|   327M|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|   327M|#define ML_BITS  4
  |  |  ------------------
  ------------------
                      price += 1 + ((mlen-(int)(ML_MASK+MINMATCH)) / 255);
  ------------------
  |  |  242|   327M|#define MINMATCH 4
  ------------------
 1927|       |
 1928|   365M|    return price * LZ4HC_PRICE_SCALE + LZ4HC_literalsPrice(litlen);
  ------------------
  |  | 1898|   365M|#define LZ4HC_PRICE_SCALE 4
  ------------------
 1929|   365M|}
lz4hc.c:LZ4HC_setMatch:
 1975|  70.8M|{
 1976|  70.8M|    opt[pos].mlen = mlen;
 1977|  70.8M|    opt[pos].off = off;
 1978|  70.8M|    opt[pos].litlen = 0;
 1979|  70.8M|    opt[pos].price = price;
 1980|  70.8M|    DEBUGLOG(7, "rPos:%3i => price:%3i (matchlen=%i)", pos, price, mlen);
  ------------------
  |  |  289|  70.8M|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1981|  70.8M|}
lz4hc.c:LZ4HC_dropPositions:
  609|     45|{
  610|     45|    U32* const hashTable = ctx->hashTable;
  611|     45|    U32 const startIdx = ctx->dictLimit + (U32)(start - ctx->prefixStart);
  612|     45|    if (end - start > LZ4HC_HASHTABLESIZE) {
  ------------------
  |  |  237|     45|#define LZ4HC_HASHTABLESIZE (1 << LZ4HC_HASH_LOG)
  |  |  ------------------
  |  |  |  |  236|     45|#define LZ4HC_HASH_LOG 15
  |  |  ------------------
  ------------------
  |  Branch (612:9): [True: 0, False: 45]
  ------------------
  613|      0|        int i;
  614|      0|        for (i = 0; i < LZ4HC_HASHTABLESIZE; i++) {
  ------------------
  |  |  237|      0|#define LZ4HC_HASHTABLESIZE (1 << LZ4HC_HASH_LOG)
  |  |  ------------------
  |  |  |  |  236|      0|#define LZ4HC_HASH_LOG 15
  |  |  ------------------
  ------------------
  |  Branch (614:21): [True: 0, False: 0]
  ------------------
  615|       |            /* branchless, so that it can be vectorized */
  616|      0|            hashTable[i] = (hashTable[i] >= startIdx) ? 0 : hashTable[i];
  ------------------
  |  Branch (616:28): [True: 0, False: 0]
  ------------------
  617|      0|        }
  618|     45|    } else {
  619|     45|        U32 idx = startIdx;
  620|     45|        const BYTE* p;
  621|     45|        for (p = start; p < end; p++, idx++) {
  ------------------
  |  Branch (621:25): [True: 0, False: 45]
  ------------------
  622|      0|            if (strat == lz4mid) {
  ------------------
  |  Branch (622:17): [True: 0, False: 0]
  ------------------
  623|      0|                U32 const h4 = LZ4MID_hash4Ptr(p);
  624|      0|                U32 const h8 = LZ4MID_HASHTABLESIZE + LZ4MID_hash8Ptr(p);
  ------------------
  |  |  154|      0|#define LZ4MID_HASHTABLESIZE (1 << LZ4MID_HASHLOG)
  |  |  ------------------
  |  |  |  |  153|      0|#define LZ4MID_HASHLOG (LZ4HC_HASH_LOG-1)
  |  |  |  |  ------------------
  |  |  |  |  |  |  236|      0|#define LZ4HC_HASH_LOG 15
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  625|      0|                if (hashTable[h4] == idx) hashTable[h4] = 0;
  ------------------
  |  Branch (625:21): [True: 0, False: 0]
  ------------------
  626|      0|                if (hashTable[h8] == idx) hashTable[h8] = 0;
  ------------------
  |  Branch (626:21): [True: 0, False: 0]
  ------------------
  627|      0|            } else {
  628|      0|                U32 const h = LZ4HC_hashPtr(p);
  629|      0|                if (hashTable[h] == idx) hashTable[h] = 0;
  ------------------
  |  Branch (629:21): [True: 0, False: 0]
  ------------------
  630|      0|    }   }   }
  631|     45|}
lz4hc.c:LZ4HC_setExternalDict:
 1770|  3.52k|{
 1771|  3.52k|    DEBUGLOG(4, "LZ4HC_setExternalDict(%p, %p)", ctxPtr, newBlock);
  ------------------
  |  |  289|  3.52k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1772|  3.52k|    if (LZ4HC_getCLevelParams(ctxPtr->compressionLevel).strat != lz4mid) {
  ------------------
  |  Branch (1772:9): [True: 2.57k, False: 952]
  ------------------
 1773|  2.57k|        U32 const endIdx = ctxPtr->dictLimit + (U32)(ctxPtr->end - ctxPtr->prefixStart);
 1774|  2.57k|        U32 idx;
 1775|  2.57k|        if (ctxPtr->end >= ctxPtr->prefixStart + 4)
  ------------------
  |  Branch (1775:13): [True: 2.57k, False: 0]
  ------------------
 1776|  2.57k|            LZ4HC_Insert (ctxPtr, ctxPtr->end-3);  /* Referencing remaining dictionary content */
 1777|       |        /* last positions can't be inserted : don't leave stale chains from previous history */
 1778|  10.2k|        for (idx = ctxPtr->nextToUpdate; idx < endIdx; idx++)
  ------------------
  |  Branch (1778:42): [True: 7.71k, False: 2.57k]
  ------------------
 1779|  7.71k|            DELTANEXTU16(ctxPtr->chainTable, idx) = 0;
  ------------------
  |  |  239|  7.71k|#define DELTANEXTU16(table, pos) table[(U16)(pos)]   /* faster */
  ------------------
 1780|  2.57k|    }
 1781|       |
 1782|       |    /* Only one memory segment for extDict, so any previous extDict is lost at this stage */
 1783|  3.52k|    ctxPtr->lowLimit  = ctxPtr->dictLimit;
 1784|  3.52k|    ctxPtr->dictStart  = ctxPtr->prefixStart;
 1785|  3.52k|    ctxPtr->dictLimit += (U32)(ctxPtr->end - ctxPtr->prefixStart);
 1786|  3.52k|    ctxPtr->prefixStart = newBlock;
 1787|  3.52k|    ctxPtr->end  = newBlock;
 1788|  3.52k|    ctxPtr->nextToUpdate = ctxPtr->dictLimit;   /* match referencing will resume from there */
 1789|       |
 1790|       |    /* cannot reference an extDict and a dictCtx at the same time */
 1791|       |    ctxPtr->dictCtx = NULL;
 1792|  3.52k|}
lz4hc.c:LZ4HC_getCLevelParams:
  120|  23.3k|{
  121|       |    /* note : clevel convention is a bit different from lz4frame,
  122|       |     * possibly something worth revisiting for consistency */
  123|  23.3k|    if (cLevel < 1)
  ------------------
  |  Branch (123:9): [True: 0, False: 23.3k]
  ------------------
  124|      0|        cLevel = LZ4HC_CLEVEL_DEFAULT;
  ------------------
  |  |   47|      0|#define LZ4HC_CLEVEL_DEFAULT     9
  ------------------
  125|  23.3k|    cLevel = MIN(LZ4HC_CLEVEL_MAX, cLevel);
  ------------------
  |  |   88|  23.3k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (88:22): [True: 0, False: 23.3k]
  |  |  ------------------
  ------------------
  126|  23.3k|    return k_clTable[cLevel];
  127|  23.3k|}
lz4hc.c:LZ4HC_Insert:
  881|  86.5M|{
  882|  86.5M|    U16* const chainTable = hc4->chainTable;
  883|  86.5M|    U32* const hashTable  = hc4->hashTable;
  884|  86.5M|    const BYTE* const prefixPtr = hc4->prefixStart;
  885|  86.5M|    U32 const prefixIdx = hc4->dictLimit;
  886|  86.5M|    U32 const target = (U32)(ip - prefixPtr) + prefixIdx;
  887|  86.5M|    U32 idx = hc4->nextToUpdate;
  888|  86.5M|    assert(ip >= prefixPtr);
  ------------------
  |  Branch (888:5): [True: 0, False: 86.5M]
  |  Branch (888:5): [True: 86.5M, False: 0]
  ------------------
  889|  86.5M|    assert(target >= prefixIdx);
  ------------------
  |  Branch (889:5): [True: 0, False: 86.5M]
  |  Branch (889:5): [True: 86.5M, False: 0]
  ------------------
  890|       |
  891|   550M|    while (idx < target) {
  ------------------
  |  Branch (891:12): [True: 464M, False: 86.5M]
  ------------------
  892|   464M|        U32 const h = LZ4HC_hashPtr(prefixPtr+idx-prefixIdx);
  893|   464M|        size_t delta = idx - hashTable[h];
  894|   464M|        if (delta>LZ4_DISTANCE_MAX) delta = LZ4_DISTANCE_MAX;
  ------------------
  |  |  691|   464M|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
                      if (delta>LZ4_DISTANCE_MAX) delta = LZ4_DISTANCE_MAX;
  ------------------
  |  |  691|  32.9M|#  define LZ4_DISTANCE_MAX 65535   /* set to maximum value by default */
  ------------------
  |  Branch (894:13): [True: 32.9M, False: 431M]
  ------------------
  895|   464M|        DELTANEXTU16(chainTable, idx) = (U16)delta;
  ------------------
  |  |  239|   464M|#define DELTANEXTU16(table, pos) table[(U16)(pos)]   /* faster */
  ------------------
  896|   464M|        hashTable[h] = idx;
  897|   464M|        idx++;
  898|   464M|    }
  899|       |
  900|  86.5M|    hc4->nextToUpdate = target;
  901|  86.5M|}
lz4hc.c:LZ4_compressHC_continue_generic:
 1799|  14.4k|{
 1800|  14.4k|    LZ4HC_CCtx_internal* const ctxPtr = &LZ4_streamHCPtr->internal_donotuse;
 1801|  14.4k|    DEBUGLOG(5, "LZ4_compressHC_continue_generic(ctx=%p, src=%p, srcSize=%d, limit=%d)",
  ------------------
  |  |  289|  14.4k|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 1802|  14.4k|                LZ4_streamHCPtr, src, *srcSizePtr, limit);
 1803|  14.4k|    assert(ctxPtr != NULL);
  ------------------
  |  Branch (1803:5): [True: 0, False: 14.4k]
  |  Branch (1803:5): [True: 14.4k, False: 0]
  ------------------
 1804|       |    /* auto-init if forgotten */
 1805|  14.4k|    if (ctxPtr->prefixStart == NULL)
  ------------------
  |  Branch (1805:9): [True: 6.88k, False: 7.59k]
  ------------------
 1806|  6.88k|        LZ4HC_init_internal (ctxPtr, (const BYTE*) src);
 1807|       |
 1808|       |    /* Check overflow */
 1809|  14.4k|    if ((size_t)(ctxPtr->end - ctxPtr->prefixStart) + ctxPtr->dictLimit > 2 GB) {
  ------------------
  |  |  253|  14.4k|#define GB *(1U<<30)
  ------------------
  |  Branch (1809:9): [True: 0, False: 14.4k]
  ------------------
 1810|      0|        size_t dictSize = (size_t)(ctxPtr->end - ctxPtr->prefixStart);
 1811|      0|        if (dictSize > 64 KB) dictSize = 64 KB;
  ------------------
  |  |  251|      0|#define KB *(1 <<10)
  ------------------
                      if (dictSize > 64 KB) dictSize = 64 KB;
  ------------------
  |  |  251|      0|#define KB *(1 <<10)
  ------------------
  |  Branch (1811:13): [True: 0, False: 0]
  ------------------
 1812|      0|        LZ4_loadDictHC(LZ4_streamHCPtr, (const char*)(ctxPtr->end) - dictSize, (int)dictSize);
 1813|      0|    }
 1814|       |
 1815|       |    /* Check if blocks follow each other */
 1816|  14.4k|    if ((const BYTE*)src != ctxPtr->end)
  ------------------
  |  Branch (1816:9): [True: 3.52k, False: 10.9k]
  ------------------
 1817|  3.52k|        LZ4HC_setExternalDict(ctxPtr, (const BYTE*)src);
 1818|       |
 1819|       |    /* Check overlapping input/dictionary space */
 1820|  14.4k|    {   const BYTE* sourceEnd = (const BYTE*) src + *srcSizePtr;
 1821|  14.4k|        const BYTE* const dictBegin = ctxPtr->dictStart;
 1822|  14.4k|        const BYTE* const dictEnd   = ctxPtr->dictStart + (ctxPtr->dictLimit - ctxPtr->lowLimit);
 1823|  14.4k|        if ((sourceEnd > dictBegin) && ((const BYTE*)src < dictEnd)) {
  ------------------
  |  Branch (1823:13): [True: 11.9k, False: 2.53k]
  |  Branch (1823:40): [True: 0, False: 11.9k]
  ------------------
 1824|      0|            if (sourceEnd > dictEnd) sourceEnd = dictEnd;
  ------------------
  |  Branch (1824:17): [True: 0, False: 0]
  ------------------
 1825|      0|            ctxPtr->lowLimit += (U32)(sourceEnd - ctxPtr->dictStart);
 1826|      0|            ctxPtr->dictStart += (U32)(sourceEnd - ctxPtr->dictStart);
 1827|       |            /* invalidate dictionary is it's too small */
 1828|      0|            if (ctxPtr->dictLimit - ctxPtr->lowLimit < LZ4HC_HASHSIZE) {
  ------------------
  |  |  131|      0|#define LZ4HC_HASHSIZE 4
  ------------------
  |  Branch (1828:17): [True: 0, False: 0]
  ------------------
 1829|      0|                ctxPtr->lowLimit = ctxPtr->dictLimit;
 1830|      0|                ctxPtr->dictStart = ctxPtr->prefixStart;
 1831|      0|    }   }   }
 1832|       |
 1833|  14.4k|    return LZ4HC_compress_generic (ctxPtr, src, dst, srcSizePtr, dstCapacity, ctxPtr->compressionLevel, limit);
 1834|  14.4k|}

LZ4_XXH32:
  393|  48.1k|{
  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|  48.1k|    XXH_endianness endian_detected = (XXH_endianness)XXH_CPU_LITTLE_ENDIAN;
  ------------------
  |  |  225|  48.1k|#   define XXH_CPU_LITTLE_ENDIAN   XXH_isLittleEndian()
  ------------------
  402|       |
  403|  48.1k|    if (XXH_FORCE_ALIGN_CHECK) {
  ------------------
  |  |   95|  48.1k|#    define XXH_FORCE_ALIGN_CHECK 0
  |  |  ------------------
  |  |  |  Branch (95:35): [Folded, False: 48.1k]
  |  |  ------------------
  ------------------
  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|  48.1k|    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: 48.1k, False: 0]
  ------------------
  412|  48.1k|        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|  48.1k|#endif
  416|  48.1k|}
LZ4_XXH32_reset:
  438|  34.8k|{
  439|  34.8k|    XXH32_state_t state;   /* using a local state to memcpy() in order to avoid strict-aliasing warnings */
  440|  34.8k|    memset(&state, 0, sizeof(state));
  441|  34.8k|    state.v1 = seed + PRIME32_1 + PRIME32_2;
  442|  34.8k|    state.v2 = seed + PRIME32_2;
  443|  34.8k|    state.v3 = seed + 0;
  444|  34.8k|    state.v4 = seed - PRIME32_1;
  445|       |    /* do not write into reserved, planned to be removed in a future version */
  446|  34.8k|    memcpy(statePtr, &state, sizeof(state) - sizeof(state.reserved));
  447|  34.8k|    return XXH_OK;
  448|  34.8k|}
LZ4_XXH32_update:
  516|  65.4k|{
  517|  65.4k|    XXH_endianness endian_detected = (XXH_endianness)XXH_CPU_LITTLE_ENDIAN;
  ------------------
  |  |  225|  65.4k|#   define XXH_CPU_LITTLE_ENDIAN   XXH_isLittleEndian()
  ------------------
  518|       |
  519|  65.4k|    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.4k, False: 0]
  ------------------
  520|  65.4k|        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.4k|}
LZ4_XXH32_digest:
  547|  14.1k|{
  548|  14.1k|    XXH_endianness endian_detected = (XXH_endianness)XXH_CPU_LITTLE_ENDIAN;
  ------------------
  |  |  225|  14.1k|#   define XXH_CPU_LITTLE_ENDIAN   XXH_isLittleEndian()
  ------------------
  549|       |
  550|  14.1k|    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: 14.1k, False: 0]
  ------------------
  551|  14.1k|        return XXH32_digest_endian(state_in, XXH_littleEndian);
  552|      0|    else
  553|      0|        return XXH32_digest_endian(state_in, XXH_bigEndian);
  554|  14.1k|}
xxhash.c:XXH_isLittleEndian:
  221|   127k|{
  222|   127k|    const union { U32 u; BYTE c[4]; } one = { 1 };   /* don't use static : performance detrimental  */
  223|   127k|    return one.c[0] ? XXH_littleEndian : XXH_bigEndian;
  ------------------
  |  Branch (223:12): [True: 127k, False: 0]
  ------------------
  224|   127k|}
xxhash.c:XXH32_endian_align:
  354|  48.1k|{
  355|  48.1k|    const BYTE* p = (const BYTE*)input;
  356|  48.1k|    const BYTE* bEnd = p + len;
  357|  48.1k|    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|  48.1k|    if (len>=16) {
  ------------------
  |  Branch (366:9): [True: 27.5k, False: 20.6k]
  ------------------
  367|  27.5k|        const BYTE* const limit = bEnd - 15;
  368|  27.5k|        U32 v1 = seed + PRIME32_1 + PRIME32_2;
  369|  27.5k|        U32 v2 = seed + PRIME32_2;
  370|  27.5k|        U32 v3 = seed + 0;
  371|  27.5k|        U32 v4 = seed - PRIME32_1;
  372|       |
  373|  20.7M|        do {
  374|  20.7M|            v1 = XXH32_round(v1, XXH_get32bits(p)); p+=4;
  ------------------
  |  |  288|  20.7M|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  ------------------
  375|  20.7M|            v2 = XXH32_round(v2, XXH_get32bits(p)); p+=4;
  ------------------
  |  |  288|  20.7M|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  ------------------
  376|  20.7M|            v3 = XXH32_round(v3, XXH_get32bits(p)); p+=4;
  ------------------
  |  |  288|  20.7M|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  ------------------
  377|  20.7M|            v4 = XXH32_round(v4, XXH_get32bits(p)); p+=4;
  ------------------
  |  |  288|  20.7M|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  ------------------
  378|  20.7M|        } while (p < limit);
  ------------------
  |  Branch (378:18): [True: 20.7M, False: 27.5k]
  ------------------
  379|       |
  380|  27.5k|        h32 = XXH_rotl32(v1, 1)  + XXH_rotl32(v2, 7)
  ------------------
  |  |  194|  27.5k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  ------------------
                      h32 = XXH_rotl32(v1, 1)  + XXH_rotl32(v2, 7)
  ------------------
  |  |  194|  27.5k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  ------------------
  381|  27.5k|            + XXH_rotl32(v3, 12) + XXH_rotl32(v4, 18);
  ------------------
  |  |  194|  27.5k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  ------------------
                          + XXH_rotl32(v3, 12) + XXH_rotl32(v4, 18);
  ------------------
  |  |  194|  27.5k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  ------------------
  382|  27.5k|    } else {
  383|  20.6k|        h32  = seed + PRIME32_5;
  384|  20.6k|    }
  385|       |
  386|  48.1k|    h32 += (U32)len;
  387|       |
  388|  48.1k|    return XXH32_finalize(h32, p, len&15, endian, align);
  389|  48.1k|}
xxhash.c:XXH32_round:
  270|   404M|{
  271|   404M|    seed += input * PRIME32_2;
  272|   404M|    seed  = XXH_rotl32(seed, 13);
  ------------------
  |  |  194|   404M|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  ------------------
  273|   404M|    seed *= PRIME32_1;
  274|   404M|    return seed;
  275|   404M|}
xxhash.c:XXH_readLE32_align:
  235|   404M|{
  236|   404M|    if (align==XXH_unaligned)
  ------------------
  |  Branch (236:9): [True: 404M, False: 17.3k]
  ------------------
  237|   404M|        return endian==XXH_littleEndian ? XXH_read32(ptr) : XXH_swap32(XXH_read32(ptr));
  ------------------
  |  Branch (237:16): [True: 404M, False: 0]
  ------------------
  238|  17.3k|    else
  239|  17.3k|        return endian==XXH_littleEndian ? *(const U32*)ptr : XXH_swap32(*(const U32*)ptr);
  ------------------
  |  Branch (239:16): [True: 17.3k, False: 0]
  ------------------
  240|   404M|}
xxhash.c:XXH_read32:
  175|   404M|{
  176|   404M|    U32 val;
  177|   404M|    memcpy(&val, memPtr, sizeof(val));
  178|   404M|    return val;
  179|   404M|}
xxhash.c:XXH32_finalize:
  294|  62.3k|{
  295|  62.3k|    const BYTE* p = (const BYTE*)ptr;
  296|       |
  297|  62.3k|#define PROCESS1               \
  298|  62.3k|    h32 += (*p++) * PRIME32_5; \
  299|  62.3k|    h32 = XXH_rotl32(h32, 11) * PRIME32_1 ;
  300|       |
  301|  62.3k|#define PROCESS4                         \
  302|  62.3k|    h32 += XXH_get32bits(p) * PRIME32_3; \
  303|  62.3k|    p+=4;                                \
  304|  62.3k|    h32  = XXH_rotl32(h32, 17) * PRIME32_4 ;
  305|       |
  306|  62.3k|    switch(len&15)  /* or switch(bEnd - p) */
  ------------------
  |  Branch (306:12): [True: 62.3k, False: 0]
  ------------------
  307|  62.3k|    {
  308|  2.51k|      case 12:      PROCESS4;
  ------------------
  |  |  302|  2.51k|    h32 += XXH_get32bits(p) * PRIME32_3; \
  |  |  ------------------
  |  |  |  |  288|  2.51k|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  |  |  ------------------
  |  |  303|  2.51k|    p+=4;                                \
  |  |  304|  2.51k|    h32  = XXH_rotl32(h32, 17) * PRIME32_4 ;
  |  |  ------------------
  |  |  |  |  194|  2.51k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (308:7): [True: 2.51k, False: 59.8k]
  ------------------
  309|       |                    /* fallthrough */
  310|  4.95k|      case 8:       PROCESS4;
  ------------------
  |  |  302|  4.95k|    h32 += XXH_get32bits(p) * PRIME32_3; \
  |  |  ------------------
  |  |  |  |  288|  4.95k|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  |  |  ------------------
  |  |  303|  4.95k|    p+=4;                                \
  |  |  304|  4.95k|    h32  = XXH_rotl32(h32, 17) * PRIME32_4 ;
  |  |  ------------------
  |  |  |  |  194|  4.95k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (310:7): [True: 2.44k, False: 59.8k]
  ------------------
  311|       |                    /* fallthrough */
  312|  7.29k|      case 4:       PROCESS4;
  ------------------
  |  |  302|  7.29k|    h32 += XXH_get32bits(p) * PRIME32_3; \
  |  |  ------------------
  |  |  |  |  288|  7.29k|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  |  |  ------------------
  |  |  303|  7.29k|    p+=4;                                \
  |  |  304|  7.29k|    h32  = XXH_rotl32(h32, 17) * PRIME32_4 ;
  |  |  ------------------
  |  |  |  |  194|  7.29k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (312:7): [True: 2.34k, False: 59.9k]
  ------------------
  313|  7.29k|                    return XXH32_avalanche(h32);
  314|       |
  315|  2.44k|      case 13:      PROCESS4;
  ------------------
  |  |  302|  2.44k|    h32 += XXH_get32bits(p) * PRIME32_3; \
  |  |  ------------------
  |  |  |  |  288|  2.44k|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  |  |  ------------------
  |  |  303|  2.44k|    p+=4;                                \
  |  |  304|  2.44k|    h32  = XXH_rotl32(h32, 17) * PRIME32_4 ;
  |  |  ------------------
  |  |  |  |  194|  2.44k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (315:7): [True: 2.44k, False: 59.8k]
  ------------------
  316|       |                    /* fallthrough */
  317|  4.68k|      case 9:       PROCESS4;
  ------------------
  |  |  302|  4.68k|    h32 += XXH_get32bits(p) * PRIME32_3; \
  |  |  ------------------
  |  |  |  |  288|  4.68k|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  |  |  ------------------
  |  |  303|  4.68k|    p+=4;                                \
  |  |  304|  4.68k|    h32  = XXH_rotl32(h32, 17) * PRIME32_4 ;
  |  |  ------------------
  |  |  |  |  194|  4.68k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (317:7): [True: 2.23k, False: 60.0k]
  ------------------
  318|       |                    /* fallthrough */
  319|  7.67k|      case 5:       PROCESS4;
  ------------------
  |  |  302|  7.67k|    h32 += XXH_get32bits(p) * PRIME32_3; \
  |  |  ------------------
  |  |  |  |  288|  7.67k|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  |  |  ------------------
  |  |  303|  7.67k|    p+=4;                                \
  |  |  304|  7.67k|    h32  = XXH_rotl32(h32, 17) * PRIME32_4 ;
  |  |  ------------------
  |  |  |  |  194|  7.67k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (319:7): [True: 2.99k, False: 59.3k]
  ------------------
  320|  7.67k|                    PROCESS1;
  ------------------
  |  |  298|  7.67k|    h32 += (*p++) * PRIME32_5; \
  |  |  299|  7.67k|    h32 = XXH_rotl32(h32, 11) * PRIME32_1 ;
  |  |  ------------------
  |  |  |  |  194|  7.67k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  321|  7.67k|                    return XXH32_avalanche(h32);
  322|       |
  323|  2.52k|      case 14:      PROCESS4;
  ------------------
  |  |  302|  2.52k|    h32 += XXH_get32bits(p) * PRIME32_3; \
  |  |  ------------------
  |  |  |  |  288|  2.52k|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  |  |  ------------------
  |  |  303|  2.52k|    p+=4;                                \
  |  |  304|  2.52k|    h32  = XXH_rotl32(h32, 17) * PRIME32_4 ;
  |  |  ------------------
  |  |  |  |  194|  2.52k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (323:7): [True: 2.52k, False: 59.8k]
  ------------------
  324|       |                    /* fallthrough */
  325|  5.42k|      case 10:      PROCESS4;
  ------------------
  |  |  302|  5.42k|    h32 += XXH_get32bits(p) * PRIME32_3; \
  |  |  ------------------
  |  |  |  |  288|  5.42k|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  |  |  ------------------
  |  |  303|  5.42k|    p+=4;                                \
  |  |  304|  5.42k|    h32  = XXH_rotl32(h32, 17) * PRIME32_4 ;
  |  |  ------------------
  |  |  |  |  194|  5.42k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (325:7): [True: 2.90k, False: 59.4k]
  ------------------
  326|       |                    /* fallthrough */
  327|  7.83k|      case 6:       PROCESS4;
  ------------------
  |  |  302|  7.83k|    h32 += XXH_get32bits(p) * PRIME32_3; \
  |  |  ------------------
  |  |  |  |  288|  7.83k|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  |  |  ------------------
  |  |  303|  7.83k|    p+=4;                                \
  |  |  304|  7.83k|    h32  = XXH_rotl32(h32, 17) * PRIME32_4 ;
  |  |  ------------------
  |  |  |  |  194|  7.83k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (327:7): [True: 2.41k, False: 59.9k]
  ------------------
  328|  7.83k|                    PROCESS1;
  ------------------
  |  |  298|  7.83k|    h32 += (*p++) * PRIME32_5; \
  |  |  299|  7.83k|    h32 = XXH_rotl32(h32, 11) * PRIME32_1 ;
  |  |  ------------------
  |  |  |  |  194|  7.83k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  329|  7.83k|                    PROCESS1;
  ------------------
  |  |  298|  7.83k|    h32 += (*p++) * PRIME32_5; \
  |  |  299|  7.83k|    h32 = XXH_rotl32(h32, 11) * PRIME32_1 ;
  |  |  ------------------
  |  |  |  |  194|  7.83k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  330|  7.83k|                    return XXH32_avalanche(h32);
  331|       |
  332|  2.60k|      case 15:      PROCESS4;
  ------------------
  |  |  302|  2.60k|    h32 += XXH_get32bits(p) * PRIME32_3; \
  |  |  ------------------
  |  |  |  |  288|  2.60k|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  |  |  ------------------
  |  |  303|  2.60k|    p+=4;                                \
  |  |  304|  2.60k|    h32  = XXH_rotl32(h32, 17) * PRIME32_4 ;
  |  |  ------------------
  |  |  |  |  194|  2.60k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (332:7): [True: 2.60k, False: 59.7k]
  ------------------
  333|       |                    /* fallthrough */
  334|  5.43k|      case 11:      PROCESS4;
  ------------------
  |  |  302|  5.43k|    h32 += XXH_get32bits(p) * PRIME32_3; \
  |  |  ------------------
  |  |  |  |  288|  5.43k|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  |  |  ------------------
  |  |  303|  5.43k|    p+=4;                                \
  |  |  304|  5.43k|    h32  = XXH_rotl32(h32, 17) * PRIME32_4 ;
  |  |  ------------------
  |  |  |  |  194|  5.43k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (334:7): [True: 2.83k, False: 59.5k]
  ------------------
  335|       |                    /* fallthrough */
  336|  8.21k|      case 7:       PROCESS4;
  ------------------
  |  |  302|  8.21k|    h32 += XXH_get32bits(p) * PRIME32_3; \
  |  |  ------------------
  |  |  |  |  288|  8.21k|#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
  |  |  ------------------
  |  |  303|  8.21k|    p+=4;                                \
  |  |  304|  8.21k|    h32  = XXH_rotl32(h32, 17) * PRIME32_4 ;
  |  |  ------------------
  |  |  |  |  194|  8.21k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (336:7): [True: 2.78k, False: 59.5k]
  ------------------
  337|       |                    /* fallthrough */
  338|  10.8k|      case 3:       PROCESS1;
  ------------------
  |  |  298|  10.8k|    h32 += (*p++) * PRIME32_5; \
  |  |  299|  10.8k|    h32 = XXH_rotl32(h32, 11) * PRIME32_1 ;
  |  |  ------------------
  |  |  |  |  194|  10.8k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (338:7): [True: 2.59k, False: 59.7k]
  ------------------
  339|       |                    /* fallthrough */
  340|  29.2k|      case 2:       PROCESS1;
  ------------------
  |  |  298|  29.2k|    h32 += (*p++) * PRIME32_5; \
  |  |  299|  29.2k|    h32 = XXH_rotl32(h32, 11) * PRIME32_1 ;
  |  |  ------------------
  |  |  |  |  194|  29.2k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (340:7): [True: 18.4k, False: 43.8k]
  ------------------
  341|       |                    /* fallthrough */
  342|  35.2k|      case 1:       PROCESS1;
  ------------------
  |  |  298|  35.2k|    h32 += (*p++) * PRIME32_5; \
  |  |  299|  35.2k|    h32 = XXH_rotl32(h32, 11) * PRIME32_1 ;
  |  |  ------------------
  |  |  |  |  194|  35.2k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  |  |  ------------------
  ------------------
  |  Branch (342:7): [True: 5.98k, False: 56.3k]
  ------------------
  343|       |                    /* fallthrough */
  344|  39.5k|      case 0:       return XXH32_avalanche(h32);
  ------------------
  |  Branch (344:7): [True: 4.27k, False: 58.0k]
  ------------------
  345|  62.3k|    }
  346|  62.3k|    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|  62.3k|{
  280|  62.3k|    h32 ^= h32 >> 15;
  281|  62.3k|    h32 *= PRIME32_2;
  282|  62.3k|    h32 ^= h32 >> 13;
  283|  62.3k|    h32 *= PRIME32_3;
  284|  62.3k|    h32 ^= h32 >> 16;
  285|  62.3k|    return(h32);
  286|  62.3k|}
xxhash.c:XXH32_update_endian:
  453|  65.4k|{
  454|  65.4k|    if (input==NULL)
  ------------------
  |  Branch (454:9): [True: 0, False: 65.4k]
  ------------------
  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.4k|#endif
  460|       |
  461|  65.4k|    {   const BYTE* p = (const BYTE*)input;
  462|  65.4k|        const BYTE* const bEnd = p + len;
  463|       |
  464|  65.4k|        state->total_len_32 += (unsigned)len;
  465|  65.4k|        state->large_len |= (len>=16) | (state->total_len_32>=16);
  466|       |
  467|  65.4k|        if (state->memsize + len < 16)  {   /* fill in tmp buffer */
  ------------------
  |  Branch (467:13): [True: 22.4k, False: 43.0k]
  ------------------
  468|  22.4k|            XXH_memcpy((BYTE*)(state->mem32) + state->memsize, input, len);
  469|  22.4k|            state->memsize += (unsigned)len;
  470|  22.4k|            return XXH_OK;
  471|  22.4k|        }
  472|       |
  473|  43.0k|        if (state->memsize) {   /* some data left from previous update */
  ------------------
  |  Branch (473:13): [True: 18.5k, False: 24.5k]
  ------------------
  474|  18.5k|            XXH_memcpy((BYTE*)(state->mem32) + state->memsize, input, 16-state->memsize);
  475|  18.5k|            {   const U32* p32 = state->mem32;
  476|  18.5k|                state->v1 = XXH32_round(state->v1, XXH_readLE32(p32, endian)); p32++;
  477|  18.5k|                state->v2 = XXH32_round(state->v2, XXH_readLE32(p32, endian)); p32++;
  478|  18.5k|                state->v3 = XXH32_round(state->v3, XXH_readLE32(p32, endian)); p32++;
  479|  18.5k|                state->v4 = XXH32_round(state->v4, XXH_readLE32(p32, endian));
  480|  18.5k|            }
  481|  18.5k|            p += 16-state->memsize;
  482|  18.5k|            state->memsize = 0;
  483|  18.5k|        }
  484|       |
  485|  43.0k|        if (p <= bEnd-16) {
  ------------------
  |  Branch (485:13): [True: 39.0k, False: 3.91k]
  ------------------
  486|  39.0k|            const BYTE* const limit = bEnd - 16;
  487|  39.0k|            U32 v1 = state->v1;
  488|  39.0k|            U32 v2 = state->v2;
  489|  39.0k|            U32 v3 = state->v3;
  490|  39.0k|            U32 v4 = state->v4;
  491|       |
  492|  80.2M|            do {
  493|  80.2M|                v1 = XXH32_round(v1, XXH_readLE32(p, endian)); p+=4;
  494|  80.2M|                v2 = XXH32_round(v2, XXH_readLE32(p, endian)); p+=4;
  495|  80.2M|                v3 = XXH32_round(v3, XXH_readLE32(p, endian)); p+=4;
  496|  80.2M|                v4 = XXH32_round(v4, XXH_readLE32(p, endian)); p+=4;
  497|  80.2M|            } while (p<=limit);
  ------------------
  |  Branch (497:22): [True: 80.1M, False: 39.0k]
  ------------------
  498|       |
  499|  39.0k|            state->v1 = v1;
  500|  39.0k|            state->v2 = v2;
  501|  39.0k|            state->v3 = v3;
  502|  39.0k|            state->v4 = v4;
  503|  39.0k|        }
  504|       |
  505|  43.0k|        if (p < bEnd) {
  ------------------
  |  Branch (505:13): [True: 32.3k, False: 10.6k]
  ------------------
  506|  32.3k|            XXH_memcpy(state->mem32, p, (size_t)(bEnd-p));
  507|  32.3k|            state->memsize = (unsigned)(bEnd-p);
  508|  32.3k|        }
  509|  43.0k|    }
  510|       |
  511|      0|    return XXH_OK;
  512|  65.4k|}
xxhash.c:XXH_memcpy:
  112|  73.2k|static void* XXH_memcpy(void* dest, const void* src, size_t size) { return memcpy(dest,src,size); }
xxhash.c:XXH_readLE32:
  243|   320M|{
  244|   320M|    return XXH_readLE32_align(ptr, endian, XXH_unaligned);
  245|   320M|}
xxhash.c:XXH32_digest_endian:
  528|  14.1k|{
  529|  14.1k|    U32 h32;
  530|       |
  531|  14.1k|    if (state->large_len) {
  ------------------
  |  Branch (531:9): [True: 11.3k, False: 2.78k]
  ------------------
  532|  11.3k|        h32 = XXH_rotl32(state->v1, 1)
  ------------------
  |  |  194|  11.3k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  ------------------
  533|  11.3k|            + XXH_rotl32(state->v2, 7)
  ------------------
  |  |  194|  11.3k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  ------------------
  534|  11.3k|            + XXH_rotl32(state->v3, 12)
  ------------------
  |  |  194|  11.3k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  ------------------
  535|  11.3k|            + XXH_rotl32(state->v4, 18);
  ------------------
  |  |  194|  11.3k|#  define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
  ------------------
  536|  11.3k|    } else {
  537|  2.78k|        h32 = state->v3 /* == seed */ + PRIME32_5;
  538|  2.78k|    }
  539|       |
  540|  14.1k|    h32 += state->total_len_32;
  541|       |
  542|  14.1k|    return XXH32_finalize(h32, state->mem32, state->memsize, endian, XXH_aligned);
  543|  14.1k|}

LLVMFuzzerTestOneInput:
  164|  15.7k|{
  165|  15.7k|    FUZZ_dataProducer_t *producer = FUZZ_dataProducer_create(data, size);
  166|       |
  167|       |    /* consume the op script and preferences first; the front remainder of the
  168|       |     * input is the file contents both phases operate on */
  169|  15.7k|    LZ4F_preferences_t const prefs = FUZZ_dataProducer_preferences(producer);
  170|  15.7k|    file_op_t ops[FILE_FUZZ_MAX_OPS];
  171|  15.7k|    unsigned const nbOps = FUZZ_dataProducer_range32(producer, 1, FILE_FUZZ_MAX_OPS);
  ------------------
  |  |   28|  15.7k|#define FILE_FUZZ_MAX_OPS 16
  ------------------
  172|  15.7k|    unsigned op;
  173|       |
  174|  15.7k|    memset(ops, 0, sizeof(ops));
  175|  69.9k|    for (op = 0; op < nbOps; op++) {
  ------------------
  |  Branch (175:18): [True: 54.2k, False: 15.7k]
  ------------------
  176|  54.2k|        ops[op].kind = FUZZ_dataProducer_range32(producer, 0, 2);
  177|  54.2k|        if (ops[op].kind == 0) {
  ------------------
  |  Branch (177:13): [True: 19.6k, False: 34.5k]
  ------------------
  178|  19.6k|            ops[op].want = FUZZ_dataProducer_range32(producer, 0, FILE_FUZZ_BUF_CAP);
  ------------------
  |  |   29|  19.6k|#define FILE_FUZZ_BUF_CAP (64 * 1024)
  ------------------
  179|  34.5k|        } else if (ops[op].kind == 1) {
  ------------------
  |  Branch (179:20): [True: 18.6k, False: 15.9k]
  ------------------
  180|  18.6k|            long long const forward =
  181|  18.6k|                (long long)FUZZ_dataProducer_range32(producer, 0, 1u << 20);
  182|  18.6k|            long long const backward =
  183|  18.6k|                (long long)FUZZ_dataProducer_range32(producer, 0, 1u << 20);
  184|  18.6k|            ops[op].offset = forward - backward;
  185|  18.6k|            ops[op].origin = (FUZZ_dataProducer_range32(producer, 0, 1) == 0)
  ------------------
  |  Branch (185:30): [True: 12.0k, False: 6.56k]
  ------------------
  186|  18.6k|                           ? SEEK_SET : SEEK_CUR;
  187|  18.6k|        }
  188|  54.2k|    }
  189|       |
  190|  15.7k|    size = FUZZ_dataProducer_remainingBytes(producer);
  191|       |
  192|  15.7k|    if (size > 0) {
  ------------------
  |  Branch (192:9): [True: 15.6k, False: 56]
  ------------------
  193|  15.6k|        FILE* const fp = fmemopen((void*)data, size, "rb");
  194|  15.6k|        FUZZ_ASSERT(fp);
  ------------------
  |  |   47|  15.6k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  15.6k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 15.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  15.6k|          : (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()))
  |  |  ------------------
  ------------------
  195|  15.6k|        readFileOps(fp, ops, nbOps);
  196|  15.6k|        fclose(fp);
  197|       |
  198|  15.6k|        writeReadRoundTrip(&prefs, data, size, ops, nbOps);
  199|  15.6k|    }
  200|       |
  201|  15.7k|    FUZZ_dataProducer_free(producer);
  202|  15.7k|    return 0;
  203|  15.7k|}
file_fuzzer.c:readFileOps:
   58|  15.6k|{
   59|  15.6k|    LZ4_readFile_t* rf = NULL;
   60|  15.6k|    uint8_t* buf;
   61|  15.6k|    unsigned op;
   62|       |
   63|  15.6k|    if (LZ4F_isError(LZ4F_readOpen(&rf, fp)))
  ------------------
  |  Branch (63:9): [True: 11.9k, False: 3.71k]
  ------------------
   64|  11.9k|        return;
   65|       |
   66|  3.71k|    buf = (uint8_t*)malloc(FILE_FUZZ_BUF_CAP);
  ------------------
  |  |   29|  3.71k|#define FILE_FUZZ_BUF_CAP (64 * 1024)
  ------------------
   67|  3.71k|    FUZZ_ASSERT(buf);
  ------------------
  |  |   47|  3.71k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  3.71k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 3.71k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  3.71k|          : (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()))
  |  |  ------------------
  ------------------
   68|       |
   69|  17.8k|    for (op = 0; op < nbOps; op++) {
  ------------------
  |  Branch (69:18): [True: 16.3k, False: 1.41k]
  ------------------
   70|  16.3k|        if (!runFileOp(rf, buf, &ops[op]))
  ------------------
  |  Branch (70:13): [True: 2.29k, False: 14.0k]
  ------------------
   71|  2.29k|            break;
   72|  16.3k|    }
   73|       |
   74|  3.71k|    free(buf);
   75|       |    FUZZ_ASSERT(!LZ4F_isError(LZ4F_readClose(rf)));
  ------------------
  |  |   47|  3.71k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  3.71k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 3.71k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  3.71k|          : (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()))
  |  |  ------------------
  ------------------
   76|  3.71k|}
file_fuzzer.c:runFileOp:
   41|  16.3k|{
   42|  16.3k|    if (op->kind == 0) {
  ------------------
  |  Branch (42:9): [True: 4.05k, False: 12.3k]
  ------------------
   43|  4.05k|        size_t const got = LZ4F_read(rf, buf, op->want);
   44|  4.05k|        return !LZ4F_isError(got);
   45|  4.05k|    }
   46|  12.3k|    if (op->kind == 1) {
  ------------------
  |  Branch (46:9): [True: 9.18k, False: 3.15k]
  ------------------
   47|       |        /* errors are expected: seeking past the end or before the start */
   48|  9.18k|        (void)LZ4F_seek(rf, op->offset, op->origin);
   49|  9.18k|        return 1;
   50|  9.18k|    }
   51|  3.15k|    (void)LZ4F_tell(rf);
   52|  3.15k|    return 1;
   53|  12.3k|}
file_fuzzer.c:writeReadRoundTrip:
  112|  15.6k|{
  113|  15.6k|    char* compressed = NULL;
  114|  15.6k|    size_t compressedSize = 0;
  115|  15.6k|    FILE* const wfp = open_memstream(&compressed, &compressedSize);
  116|  15.6k|    FILE* rfp;
  117|  15.6k|    LZ4_writeFile_t* wf = NULL;
  118|  15.6k|    LZ4_readFile_t* rf;
  119|  15.6k|    uint8_t* back;
  120|  15.6k|    size_t first;
  121|  15.6k|    size_t total;
  122|       |
  123|  15.6k|    FUZZ_ASSERT(wfp);
  ------------------
  |  |   47|  15.6k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  15.6k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 15.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  15.6k|          : (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|       |
  125|  15.6k|    if (!LZ4F_isError(LZ4F_writeOpen(&wf, wfp, prefs))) {
  ------------------
  |  Branch (125:9): [True: 15.6k, False: 0]
  ------------------
  126|       |        /* split in two writes to exercise the internal buffering */
  127|  15.6k|        first = size / 2;
  128|  15.6k|        if (!LZ4F_isError(LZ4F_write(wf, data, first)))
  ------------------
  |  Branch (128:13): [True: 15.6k, False: 0]
  ------------------
  129|  15.6k|            (void)LZ4F_write(wf, data + first, size - first);
  130|  15.6k|        FUZZ_ASSERT(!LZ4F_isError(LZ4F_writeClose(wf)));
  ------------------
  |  |   47|  15.6k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  15.6k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 15.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  15.6k|          : (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()))
  |  |  ------------------
  ------------------
  131|  15.6k|    }
  132|       |
  133|  15.6k|    fclose(wfp);   /* flushes and finalizes compressed/compressedSize */
  134|  15.6k|    FUZZ_ASSERT(compressed != NULL);
  ------------------
  |  |   47|  15.6k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  15.6k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 15.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  15.6k|          : (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()))
  |  |  ------------------
  ------------------
  135|  15.6k|    FUZZ_ASSERT(compressedSize > 0);
  ------------------
  |  |   47|  15.6k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  15.6k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 15.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  15.6k|          : (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()))
  |  |  ------------------
  ------------------
  136|       |
  137|  15.6k|    rfp = fmemopen(compressed, compressedSize, "rb");
  138|  15.6k|    FUZZ_ASSERT(rfp);
  ------------------
  |  |   47|  15.6k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  15.6k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 15.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  15.6k|          : (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()))
  |  |  ------------------
  ------------------
  139|       |
  140|  15.6k|    FUZZ_ASSERT(!LZ4F_isError(LZ4F_readOpen(&rf, rfp)));
  ------------------
  |  |   47|  15.6k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  15.6k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 15.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  15.6k|          : (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()))
  |  |  ------------------
  ------------------
  141|  15.6k|    back = (uint8_t*)malloc(size);
  142|  15.6k|    FUZZ_ASSERT(back);
  ------------------
  |  |   47|  15.6k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  15.6k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 15.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  15.6k|          : (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()))
  |  |  ------------------
  ------------------
  143|  15.6k|    total = 0;
  144|  31.3k|    while (total < size) {
  ------------------
  |  Branch (144:12): [True: 15.6k, False: 15.6k]
  ------------------
  145|  15.6k|        size_t const got = LZ4F_read(rf, back + total, size - total);
  146|       |        /* the frame was just written by this process: it must decode */
  147|  15.6k|        FUZZ_ASSERT(!LZ4F_isError(got));
  ------------------
  |  |   47|  15.6k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  15.6k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 15.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  15.6k|          : (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()))
  |  |  ------------------
  ------------------
  148|  15.6k|        if (got == 0)
  ------------------
  |  Branch (148:13): [True: 0, False: 15.6k]
  ------------------
  149|      0|            break;
  150|  15.6k|        total += got;
  151|  15.6k|    }
  152|  15.6k|    FUZZ_ASSERT_MSG(total == size, "lz4file round trip truncated the data");
  ------------------
  |  |   43|  15.6k|  ((cond) ? (void)0                                                            \
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 15.6k, False: 0]
  |  |  ------------------
  |  |   44|  15.6k|          : (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()))
  ------------------
  153|  15.6k|    FUZZ_ASSERT_MSG(memcmp(back, data, size) == 0,
  ------------------
  |  |   43|  15.6k|  ((cond) ? (void)0                                                            \
  |  |  ------------------
  |  |  |  Branch (43:4): [True: 15.6k, False: 0]
  |  |  ------------------
  |  |   44|  15.6k|          : (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()))
  ------------------
  154|  15.6k|                    "lz4file round trip corrupted the data");
  155|  15.6k|    checkFileOps(rf, data, size, ops, nbOps);
  156|  15.6k|    free(back);
  157|  15.6k|    FUZZ_ASSERT(!LZ4F_isError(LZ4F_readClose(rf)));
  ------------------
  |  |   47|  15.6k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  15.6k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 15.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  15.6k|          : (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|       |
  159|  15.6k|    fclose(rfp);
  160|  15.6k|    free(compressed);
  161|  15.6k|}
file_fuzzer.c:checkFileOps:
   82|  15.6k|{
   83|  15.6k|    uint8_t* const buf = (uint8_t*)malloc(FILE_FUZZ_BUF_CAP);
  ------------------
  |  |   29|  15.6k|#define FILE_FUZZ_BUF_CAP (64 * 1024)
  ------------------
   84|  15.6k|    unsigned long long pos = LZ4F_tell(rf);
   85|  15.6k|    unsigned op;
   86|       |
   87|  15.6k|    FUZZ_ASSERT(buf);
  ------------------
  |  |   47|  15.6k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  15.6k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 15.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  15.6k|          : (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()))
  |  |  ------------------
  ------------------
   88|  69.5k|    for (op = 0; op < nbOps; op++) {
  ------------------
  |  Branch (88:18): [True: 53.8k, False: 15.6k]
  ------------------
   89|  53.8k|        if (ops[op].kind == 0) {
  ------------------
  |  Branch (89:13): [True: 19.3k, False: 34.4k]
  ------------------
   90|  19.3k|            size_t const expected = MIN(ops[op].want, (size_t)(size - pos));
  ------------------
  |  |   33|  19.3k|#define MIN(a,b)   ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (33:22): [True: 5.78k, False: 13.6k]
  |  |  ------------------
  ------------------
   91|  19.3k|            FUZZ_ASSERT(LZ4F_read(rf, buf, ops[op].want) == expected);
  ------------------
  |  |   47|  19.3k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  19.3k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 19.3k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  19.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()))
  |  |  ------------------
  ------------------
   92|  19.3k|            FUZZ_ASSERT(memcmp(buf, data + pos, expected) == 0);
  ------------------
  |  |   47|  19.3k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  19.3k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 19.3k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  19.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()))
  |  |  ------------------
  ------------------
   93|  19.3k|            pos += expected;
   94|  34.4k|        } else if (ops[op].kind == 1) {
  ------------------
  |  Branch (94:20): [True: 18.6k, False: 15.8k]
  ------------------
   95|  18.6k|            long long const magnitude = (ops[op].offset < 0) ? -ops[op].offset : ops[op].offset;
  ------------------
  |  Branch (95:41): [True: 4.98k, False: 13.6k]
  ------------------
   96|  18.6k|            unsigned long long const target = (unsigned long long)magnitude % (size + 1);
   97|  18.6k|            long long const offset = (ops[op].origin == SEEK_SET) ? (long long)target
  ------------------
  |  Branch (97:38): [True: 12.0k, False: 6.54k]
  ------------------
   98|  18.6k|                                                                  : (long long)target - (long long)pos;
   99|  18.6k|            FUZZ_ASSERT(!LZ4F_isError(LZ4F_seek(rf, offset, ops[op].origin)));
  ------------------
  |  |   47|  18.6k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  18.6k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 18.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  18.6k|          : (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|  18.6k|            pos = target;
  101|  18.6k|        }
  102|  53.8k|        FUZZ_ASSERT(LZ4F_tell(rf) == pos);
  ------------------
  |  |   47|  53.8k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  53.8k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 53.8k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  53.8k|          : (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()))
  |  |  ------------------
  ------------------
  103|  53.8k|    }
  104|  15.6k|    free(buf);
  105|  15.6k|}

FUZZ_dataProducer_create:
    8|  15.7k|FUZZ_dataProducer_t* FUZZ_dataProducer_create(const uint8_t* data, size_t size) {
    9|  15.7k|  FUZZ_dataProducer_t* const producer = malloc(sizeof(FUZZ_dataProducer_t));
   10|       |
   11|  15.7k|  FUZZ_ASSERT(producer != NULL);
  ------------------
  |  |   47|  15.7k|#define FUZZ_ASSERT(cond) FUZZ_ASSERT_MSG((cond), "")
  |  |  ------------------
  |  |  |  |   43|  15.7k|  ((cond) ? (void)0                                                            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:4): [True: 15.7k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   44|  15.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()))
  |  |  ------------------
  ------------------
   12|       |
   13|  15.7k|  producer->data = data;
   14|  15.7k|  producer->size = size;
   15|  15.7k|  return producer;
   16|  15.7k|}
FUZZ_dataProducer_free:
   18|  15.7k|void FUZZ_dataProducer_free(FUZZ_dataProducer_t *producer) { free(producer); }
FUZZ_dataProducer_retrieve32:
   20|   255k|uint32_t FUZZ_dataProducer_retrieve32(FUZZ_dataProducer_t *producer) {
   21|   255k|    const uint8_t* data = producer->data;
   22|   255k|    const size_t size = producer->size;
   23|   255k|    if (size == 0) {
  ------------------
  |  Branch (23:9): [True: 595, False: 255k]
  ------------------
   24|    595|        return 0;
   25|   255k|    } else if (size < 4) {
  ------------------
  |  Branch (25:16): [True: 356, False: 254k]
  ------------------
   26|    356|        producer->size -= 1;
   27|    356|        return (uint32_t)data[size - 1];
   28|   254k|    } else {
   29|   254k|        const uint8_t* const p = data + size - 4;
   30|   254k|        producer->size -= 4;
   31|   254k|        return (uint32_t)p[0] | ((uint32_t)p[1] << 8)
   32|   254k|            | ((uint32_t)p[2] << 16) | ((uint32_t)p[3] << 24);
   33|   254k|    }
   34|   255k|}
FUZZ_getRange_from_uint32:
   37|   255k|{
   38|   255k|    uint32_t range = max - min;
   39|   255k|    if (range == 0xffffffff) {
  ------------------
  |  Branch (39:9): [True: 0, False: 255k]
  ------------------
   40|      0|      return seed;
   41|      0|    }
   42|   255k|    return min + seed % (range + 1);
   43|   255k|}
FUZZ_dataProducer_range32:
   47|   255k|{
   48|   255k|    uint32_t const seed = FUZZ_dataProducer_retrieve32(producer);
   49|   255k|    return FUZZ_getRange_from_uint32(seed, min, max);
   50|   255k|}
FUZZ_dataProducer_frameInfo:
   53|  15.7k|{
   54|  15.7k|    LZ4F_frameInfo_t info = LZ4F_INIT_FRAMEINFO;
  ------------------
  |  |  199|  15.7k|#define LZ4F_INIT_FRAMEINFO   { LZ4F_max64KB, LZ4F_blockLinked, LZ4F_noContentChecksum, LZ4F_frame, 0ULL, 0U, LZ4F_noBlockChecksum }    /* v1.8.3+ */
  ------------------
   55|  15.7k|    info.blockSizeID = FUZZ_dataProducer_range32(producer, LZ4F_max64KB - 1, LZ4F_max4MB);
   56|  15.7k|    if (info.blockSizeID < LZ4F_max64KB) {
  ------------------
  |  Branch (56:9): [True: 5.78k, False: 9.94k]
  ------------------
   57|  5.78k|        info.blockSizeID = LZ4F_default;
   58|  5.78k|    }
   59|  15.7k|    info.blockMode = FUZZ_dataProducer_range32(producer, LZ4F_blockLinked, LZ4F_blockIndependent);
   60|  15.7k|    info.contentChecksumFlag = FUZZ_dataProducer_range32(producer, LZ4F_noContentChecksum,
   61|  15.7k|                                           LZ4F_contentChecksumEnabled);
   62|  15.7k|    info.blockChecksumFlag = FUZZ_dataProducer_range32(producer, LZ4F_noBlockChecksum,
   63|  15.7k|                                         LZ4F_blockChecksumEnabled);
   64|  15.7k|    return info;
   65|  15.7k|}
FUZZ_dataProducer_preferences:
   68|  15.7k|{
   69|  15.7k|    LZ4F_preferences_t prefs = LZ4F_INIT_PREFERENCES;
  ------------------
  |  |  218|  15.7k|#define LZ4F_INIT_PREFERENCES   { LZ4F_INIT_FRAMEINFO, 0, 0u, 0u, 0u, 0u, 0u }    /* v1.8.3+ */
  |  |  ------------------
  |  |  |  |  199|  15.7k|#define LZ4F_INIT_FRAMEINFO   { LZ4F_max64KB, LZ4F_blockLinked, LZ4F_noContentChecksum, LZ4F_frame, 0ULL, 0U, LZ4F_noBlockChecksum }    /* v1.8.3+ */
  |  |  ------------------
  ------------------
   70|  15.7k|    prefs.frameInfo = FUZZ_dataProducer_frameInfo(producer);
   71|  15.7k|    prefs.compressionLevel = FUZZ_dataProducer_range32(producer, 0, LZ4HC_CLEVEL_MAX + 3) - 3;
  ------------------
  |  |   49|  15.7k|#define LZ4HC_CLEVEL_MAX        12
  ------------------
   72|  15.7k|    prefs.autoFlush = FUZZ_dataProducer_range32(producer, 0, 1);
   73|  15.7k|    prefs.favorDecSpeed = FUZZ_dataProducer_range32(producer, 0, 1);
   74|  15.7k|    return prefs;
   75|  15.7k|}
FUZZ_dataProducer_remainingBytes:
   77|  15.7k|size_t FUZZ_dataProducer_remainingBytes(FUZZ_dataProducer_t *producer){
   78|  15.7k|  return producer->size;
   79|  15.7k|}

