adler32_ssse3.c:adler32_copy_tail:
  134|  1.49k|                                                uint32_t sum2, const int REBASE, const int MAX_LEN, const int COPY) {
  135|  1.49k|    if (len) {
  ------------------
  |  Branch (135:9): [True: 1.40k, False: 95]
  ------------------
  136|  1.40k|        Z_UNUSED(MAX_LEN);
  ------------------
  |  |  154|  1.40k|#define Z_UNUSED(var) (void)(var)
  ------------------
  137|       |        /* Process using packed 64-bit arithmetic when source is aligned */
  138|  2.02k|        while (len >= 8 && ((uintptr_t)buf & 7) == 0) {
  ------------------
  |  Branch (138:16): [True: 620, False: 1.40k]
  |  Branch (138:28): [True: 620, False: 0]
  ------------------
  139|    620|            size_t chunk = MIN(ALIGN_DOWN(len, (size_t)8), (size_t)ADLER32_SWAR_MAX_BYTES);
  ------------------
  |  |  148|    620|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 620]
  |  |  ------------------
  ------------------
  140|    620|            adler32_swar(&adler, dst, buf, chunk, &sum2, COPY);
  141|    620|            buf += chunk;
  142|    620|            if (COPY)
  ------------------
  |  Branch (142:17): [True: 0, False: 620]
  ------------------
  143|      0|                dst += chunk;
  144|    620|            len -= chunk;
  145|    620|        }
  146|       |        /* DO4 loop avoids GCC x86 register pressure from hoisted DO8/DO16 loads. */
  147|  2.05k|        while (len >= 4) {
  ------------------
  |  Branch (147:16): [True: 653, False: 1.40k]
  ------------------
  148|    653|            if (COPY) {
  ------------------
  |  Branch (148:17): [True: 0, False: 653]
  ------------------
  149|      0|                memcpy(dst, buf, 4);
  150|      0|                dst += 4;
  151|      0|            }
  152|    653|            len -= 4;
  153|    653|            ADLER_DO4(adler, sum2, buf, 0);
  ------------------
  |  |   21|    653|#define ADLER_DO4(sum1, sum2, buf, i)  {ADLER_DO2(sum1, sum2, buf, i); ADLER_DO2(sum1, sum2, buf, i+2);}
  |  |  ------------------
  |  |  |  |   20|    653|#define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    653|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  |  |  |  |  ------------------
  |  |  |  |               #define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    653|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define ADLER_DO4(sum1, sum2, buf, i)  {ADLER_DO2(sum1, sum2, buf, i); ADLER_DO2(sum1, sum2, buf, i+2);}
  |  |  ------------------
  |  |  |  |   20|    653|#define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    653|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  |  |  |  |  ------------------
  |  |  |  |               #define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    653|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  154|    653|            buf += 4;
  155|    653|        }
  156|  1.40k|        if (len & 2) {
  ------------------
  |  Branch (156:13): [True: 752, False: 652]
  ------------------
  157|    752|            if (COPY) {
  ------------------
  |  Branch (157:17): [True: 0, False: 752]
  ------------------
  158|      0|                memcpy(dst, buf, 2);
  159|      0|                dst += 2;
  160|      0|            }
  161|    752|            ADLER_DO2(adler, sum2, buf, 0);
  ------------------
  |  |   20|    752|#define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
  |  |  ------------------
  |  |  |  |   19|    752|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  |  |  ------------------
  |  |               #define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
  |  |  ------------------
  |  |  |  |   19|    752|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  |  |  ------------------
  ------------------
  162|    752|            buf += 2;
  163|    752|        }
  164|  1.40k|        if (len & 1) {
  ------------------
  |  Branch (164:13): [True: 759, False: 645]
  ------------------
  165|    759|            if (COPY)
  ------------------
  |  Branch (165:17): [True: 0, False: 759]
  ------------------
  166|      0|                *dst = *buf;
  167|    759|            ADLER_DO1(adler, sum2, buf, 0);
  ------------------
  |  |   19|    759|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  ------------------
  168|    759|        }
  169|  1.40k|    }
  170|  1.49k|    if (REBASE) {
  ------------------
  |  Branch (170:9): [True: 1.40k, False: 95]
  ------------------
  171|  1.40k|        adler %= BASE;
  ------------------
  |  |   13|  1.40k|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  172|  1.40k|        sum2 %= BASE;
  ------------------
  |  |   13|  1.40k|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  173|  1.40k|    }
  174|       |    /* D = B * 65536 + A, see: https://en.wikipedia.org/wiki/Adler-32. */
  175|  1.49k|    return adler | (sum2 << 16);
  176|  1.49k|}
adler32_ssse3.c:adler32_swar:
   66|    620|                                       uint32_t *sum2, const int COPY) {
   67|    620|    uint64_t sum_even = 0, sum_odd = 0, prefix_even = 0, prefix_odd = 0;
   68|       |
   69|    620|    *sum2 += *adler * (uint32_t)len;
   70|       |
   71|    620|    const uint64_t *src64 = (const uint64_t *)buf;
   72|       |
   73|    620|    while (len >= 16) {
  ------------------
  |  Branch (73:12): [True: 0, False: 620]
  ------------------
   74|      0|        uint64_t v0 = src64[0];
   75|      0|        uint64_t v1 = src64[1];
   76|      0|        if (COPY) {
  ------------------
  |  Branch (76:13): [True: 0, False: 0]
  ------------------
   77|      0|            memcpy(dst, &v0, sizeof(v0));
   78|      0|            memcpy(dst + 8, &v1, sizeof(v1));
   79|      0|            dst += 16;
   80|      0|        }
   81|       |
   82|      0|        prefix_even += sum_even;
   83|      0|        prefix_odd += sum_odd;
   84|      0|        sum_even +=  v0       & ADLER32_SWAR_EVEN_MASK;
  ------------------
  |  |   62|      0|#define ADLER32_SWAR_EVEN_MASK   0x00FF00FF00FF00FFULL
  ------------------
   85|      0|        sum_odd  += (v0 >> 8) & ADLER32_SWAR_EVEN_MASK;
  ------------------
  |  |   62|      0|#define ADLER32_SWAR_EVEN_MASK   0x00FF00FF00FF00FFULL
  ------------------
   86|       |
   87|      0|        prefix_even += sum_even;
   88|      0|        prefix_odd += sum_odd;
   89|      0|        sum_even +=  v1       & ADLER32_SWAR_EVEN_MASK;
  ------------------
  |  |   62|      0|#define ADLER32_SWAR_EVEN_MASK   0x00FF00FF00FF00FFULL
  ------------------
   90|      0|        sum_odd  += (v1 >> 8) & ADLER32_SWAR_EVEN_MASK;
  ------------------
  |  |   62|      0|#define ADLER32_SWAR_EVEN_MASK   0x00FF00FF00FF00FFULL
  ------------------
   91|       |
   92|      0|        src64 += 2;
   93|      0|        len -= 16;
   94|      0|    }
   95|       |
   96|       |    /* Handle remaining 8 bytes if present */
   97|    620|    if (len >= 8) {
  ------------------
  |  Branch (97:9): [True: 620, False: 0]
  ------------------
   98|    620|        uint64_t v = *src64;
   99|    620|        if (COPY)
  ------------------
  |  Branch (99:13): [True: 0, False: 620]
  ------------------
  100|      0|            memcpy(dst, &v, sizeof(v));
  101|       |
  102|    620|        prefix_even += sum_even;
  103|    620|        prefix_odd += sum_odd;
  104|    620|        sum_even +=  v       & ADLER32_SWAR_EVEN_MASK;
  ------------------
  |  |   62|    620|#define ADLER32_SWAR_EVEN_MASK   0x00FF00FF00FF00FFULL
  ------------------
  105|    620|        sum_odd  += (v >> 8) & ADLER32_SWAR_EVEN_MASK;
  ------------------
  |  |   62|    620|#define ADLER32_SWAR_EVEN_MASK   0x00FF00FF00FF00FFULL
  ------------------
  106|    620|    }
  107|       |
  108|       |    /* Horizontal sum of 4x16-bit lanes for s1 */
  109|    620|    *adler += (uint32_t)(((sum_even + sum_odd) * ADLER32_SWAR_HSUM) >> 48);
  ------------------
  |  |   63|    620|#define ADLER32_SWAR_HSUM        0x1000100010001ULL
  ------------------
  110|       |
  111|       |    /* Widen prefix sums to 32-bit pairs and horizontal sum for s2 */
  112|    620|    uint64_t pe_lo = prefix_even & 0xFFFF0000FFFFULL;
  113|    620|    uint64_t pe_hi = (prefix_even >> 16) & 0xFFFF0000FFFFULL;
  114|    620|    uint64_t po_lo = prefix_odd & 0xFFFF0000FFFFULL;
  115|    620|    uint64_t po_hi = (prefix_odd >> 16) & 0xFFFF0000FFFFULL;
  116|       |
  117|    620|    *sum2 += (uint32_t)(((pe_lo + po_lo + pe_hi + po_hi) * 0x800000008ULL) >> 32);
  118|       |
  119|       |    /* Positional weights [8,7,6,5,4,3,2,1] per 8-byte group for s2.
  120|       |     * On big-endian the even mask captures odd-index memory bytes (b1,b3,b5,b7)
  121|       |     * so HSUM (+1 per odd-index byte) must be applied to sum_even, not sum_odd. */
  122|    620|#if BYTE_ORDER == LITTLE_ENDIAN
  123|    620|    *sum2 += 2 * (uint32_t)((sum_even * 0x4000300020001ULL) >> 48)
  124|    620|           +     (uint32_t)((sum_odd  * ADLER32_SWAR_HSUM) >> 48)
  ------------------
  |  |   63|    620|#define ADLER32_SWAR_HSUM        0x1000100010001ULL
  ------------------
  125|    620|           + 2 * (uint32_t)((sum_odd  * 0x3000200010000ULL) >> 48);
  126|       |#else
  127|       |    *sum2 += 2 * (uint32_t)((sum_even * 0x0000100020003ULL) >> 48)
  128|       |           +     (uint32_t)((sum_even * ADLER32_SWAR_HSUM) >> 48)
  129|       |           + 2 * (uint32_t)((sum_odd  * 0x1000200030004ULL) >> 48);
  130|       |#endif
  131|    620|}
adler32_sse42.c:adler32_copy_tail:
  134|  3.49k|                                                uint32_t sum2, const int REBASE, const int MAX_LEN, const int COPY) {
  135|  3.49k|    if (len) {
  ------------------
  |  Branch (135:9): [True: 3.49k, False: 0]
  ------------------
  136|  3.49k|        Z_UNUSED(MAX_LEN);
  ------------------
  |  |  154|  3.49k|#define Z_UNUSED(var) (void)(var)
  ------------------
  137|       |        /* Process using packed 64-bit arithmetic when source is aligned */
  138|  5.13k|        while (len >= 8 && ((uintptr_t)buf & 7) == 0) {
  ------------------
  |  Branch (138:16): [True: 1.80k, False: 3.32k]
  |  Branch (138:28): [True: 1.63k, False: 173]
  ------------------
  139|  1.63k|            size_t chunk = MIN(ALIGN_DOWN(len, (size_t)8), (size_t)ADLER32_SWAR_MAX_BYTES);
  ------------------
  |  |  148|  1.63k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 1.63k]
  |  |  ------------------
  ------------------
  140|  1.63k|            adler32_swar(&adler, dst, buf, chunk, &sum2, COPY);
  141|  1.63k|            buf += chunk;
  142|  1.63k|            if (COPY)
  ------------------
  |  Branch (142:17): [True: 1.63k, False: 0]
  ------------------
  143|  1.63k|                dst += chunk;
  144|  1.63k|            len -= chunk;
  145|  1.63k|        }
  146|       |        /* DO4 loop avoids GCC x86 register pressure from hoisted DO8/DO16 loads. */
  147|  5.62k|        while (len >= 4) {
  ------------------
  |  Branch (147:16): [True: 2.13k, False: 3.49k]
  ------------------
  148|  2.13k|            if (COPY) {
  ------------------
  |  Branch (148:17): [True: 2.13k, False: 0]
  ------------------
  149|  2.13k|                memcpy(dst, buf, 4);
  150|  2.13k|                dst += 4;
  151|  2.13k|            }
  152|  2.13k|            len -= 4;
  153|  2.13k|            ADLER_DO4(adler, sum2, buf, 0);
  ------------------
  |  |   21|  2.13k|#define ADLER_DO4(sum1, sum2, buf, i)  {ADLER_DO2(sum1, sum2, buf, i); ADLER_DO2(sum1, sum2, buf, i+2);}
  |  |  ------------------
  |  |  |  |   20|  2.13k|#define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|  2.13k|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  |  |  |  |  ------------------
  |  |  |  |               #define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|  2.13k|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define ADLER_DO4(sum1, sum2, buf, i)  {ADLER_DO2(sum1, sum2, buf, i); ADLER_DO2(sum1, sum2, buf, i+2);}
  |  |  ------------------
  |  |  |  |   20|  2.13k|#define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|  2.13k|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  |  |  |  |  ------------------
  |  |  |  |               #define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|  2.13k|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  154|  2.13k|            buf += 4;
  155|  2.13k|        }
  156|  3.49k|        if (len & 2) {
  ------------------
  |  Branch (156:13): [True: 1.92k, False: 1.57k]
  ------------------
  157|  1.92k|            if (COPY) {
  ------------------
  |  Branch (157:17): [True: 1.92k, False: 0]
  ------------------
  158|  1.92k|                memcpy(dst, buf, 2);
  159|  1.92k|                dst += 2;
  160|  1.92k|            }
  161|  1.92k|            ADLER_DO2(adler, sum2, buf, 0);
  ------------------
  |  |   20|  1.92k|#define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
  |  |  ------------------
  |  |  |  |   19|  1.92k|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  |  |  ------------------
  |  |               #define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
  |  |  ------------------
  |  |  |  |   19|  1.92k|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  |  |  ------------------
  ------------------
  162|  1.92k|            buf += 2;
  163|  1.92k|        }
  164|  3.49k|        if (len & 1) {
  ------------------
  |  Branch (164:13): [True: 1.89k, False: 1.60k]
  ------------------
  165|  1.89k|            if (COPY)
  ------------------
  |  Branch (165:17): [True: 1.89k, False: 0]
  ------------------
  166|  1.89k|                *dst = *buf;
  167|  1.89k|            ADLER_DO1(adler, sum2, buf, 0);
  ------------------
  |  |   19|  1.89k|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  ------------------
  168|  1.89k|        }
  169|  3.49k|    }
  170|  3.49k|    if (REBASE) {
  ------------------
  |  Branch (170:9): [True: 3.49k, False: 0]
  ------------------
  171|  3.49k|        adler %= BASE;
  ------------------
  |  |   13|  3.49k|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  172|  3.49k|        sum2 %= BASE;
  ------------------
  |  |   13|  3.49k|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  173|  3.49k|    }
  174|       |    /* D = B * 65536 + A, see: https://en.wikipedia.org/wiki/Adler-32. */
  175|  3.49k|    return adler | (sum2 << 16);
  176|  3.49k|}
adler32_sse42.c:adler32_swar:
   66|  1.63k|                                       uint32_t *sum2, const int COPY) {
   67|  1.63k|    uint64_t sum_even = 0, sum_odd = 0, prefix_even = 0, prefix_odd = 0;
   68|       |
   69|  1.63k|    *sum2 += *adler * (uint32_t)len;
   70|       |
   71|  1.63k|    const uint64_t *src64 = (const uint64_t *)buf;
   72|       |
   73|  1.63k|    while (len >= 16) {
  ------------------
  |  Branch (73:12): [True: 0, False: 1.63k]
  ------------------
   74|      0|        uint64_t v0 = src64[0];
   75|      0|        uint64_t v1 = src64[1];
   76|      0|        if (COPY) {
  ------------------
  |  Branch (76:13): [True: 0, False: 0]
  ------------------
   77|      0|            memcpy(dst, &v0, sizeof(v0));
   78|      0|            memcpy(dst + 8, &v1, sizeof(v1));
   79|      0|            dst += 16;
   80|      0|        }
   81|       |
   82|      0|        prefix_even += sum_even;
   83|      0|        prefix_odd += sum_odd;
   84|      0|        sum_even +=  v0       & ADLER32_SWAR_EVEN_MASK;
  ------------------
  |  |   62|      0|#define ADLER32_SWAR_EVEN_MASK   0x00FF00FF00FF00FFULL
  ------------------
   85|      0|        sum_odd  += (v0 >> 8) & ADLER32_SWAR_EVEN_MASK;
  ------------------
  |  |   62|      0|#define ADLER32_SWAR_EVEN_MASK   0x00FF00FF00FF00FFULL
  ------------------
   86|       |
   87|      0|        prefix_even += sum_even;
   88|      0|        prefix_odd += sum_odd;
   89|      0|        sum_even +=  v1       & ADLER32_SWAR_EVEN_MASK;
  ------------------
  |  |   62|      0|#define ADLER32_SWAR_EVEN_MASK   0x00FF00FF00FF00FFULL
  ------------------
   90|      0|        sum_odd  += (v1 >> 8) & ADLER32_SWAR_EVEN_MASK;
  ------------------
  |  |   62|      0|#define ADLER32_SWAR_EVEN_MASK   0x00FF00FF00FF00FFULL
  ------------------
   91|       |
   92|      0|        src64 += 2;
   93|      0|        len -= 16;
   94|      0|    }
   95|       |
   96|       |    /* Handle remaining 8 bytes if present */
   97|  1.63k|    if (len >= 8) {
  ------------------
  |  Branch (97:9): [True: 1.63k, False: 0]
  ------------------
   98|  1.63k|        uint64_t v = *src64;
   99|  1.63k|        if (COPY)
  ------------------
  |  Branch (99:13): [True: 1.63k, False: 0]
  ------------------
  100|  1.63k|            memcpy(dst, &v, sizeof(v));
  101|       |
  102|  1.63k|        prefix_even += sum_even;
  103|  1.63k|        prefix_odd += sum_odd;
  104|  1.63k|        sum_even +=  v       & ADLER32_SWAR_EVEN_MASK;
  ------------------
  |  |   62|  1.63k|#define ADLER32_SWAR_EVEN_MASK   0x00FF00FF00FF00FFULL
  ------------------
  105|  1.63k|        sum_odd  += (v >> 8) & ADLER32_SWAR_EVEN_MASK;
  ------------------
  |  |   62|  1.63k|#define ADLER32_SWAR_EVEN_MASK   0x00FF00FF00FF00FFULL
  ------------------
  106|  1.63k|    }
  107|       |
  108|       |    /* Horizontal sum of 4x16-bit lanes for s1 */
  109|  1.63k|    *adler += (uint32_t)(((sum_even + sum_odd) * ADLER32_SWAR_HSUM) >> 48);
  ------------------
  |  |   63|  1.63k|#define ADLER32_SWAR_HSUM        0x1000100010001ULL
  ------------------
  110|       |
  111|       |    /* Widen prefix sums to 32-bit pairs and horizontal sum for s2 */
  112|  1.63k|    uint64_t pe_lo = prefix_even & 0xFFFF0000FFFFULL;
  113|  1.63k|    uint64_t pe_hi = (prefix_even >> 16) & 0xFFFF0000FFFFULL;
  114|  1.63k|    uint64_t po_lo = prefix_odd & 0xFFFF0000FFFFULL;
  115|  1.63k|    uint64_t po_hi = (prefix_odd >> 16) & 0xFFFF0000FFFFULL;
  116|       |
  117|  1.63k|    *sum2 += (uint32_t)(((pe_lo + po_lo + pe_hi + po_hi) * 0x800000008ULL) >> 32);
  118|       |
  119|       |    /* Positional weights [8,7,6,5,4,3,2,1] per 8-byte group for s2.
  120|       |     * On big-endian the even mask captures odd-index memory bytes (b1,b3,b5,b7)
  121|       |     * so HSUM (+1 per odd-index byte) must be applied to sum_even, not sum_odd. */
  122|  1.63k|#if BYTE_ORDER == LITTLE_ENDIAN
  123|  1.63k|    *sum2 += 2 * (uint32_t)((sum_even * 0x4000300020001ULL) >> 48)
  124|  1.63k|           +     (uint32_t)((sum_odd  * ADLER32_SWAR_HSUM) >> 48)
  ------------------
  |  |   63|  1.63k|#define ADLER32_SWAR_HSUM        0x1000100010001ULL
  ------------------
  125|  1.63k|           + 2 * (uint32_t)((sum_odd  * 0x3000200010000ULL) >> 48);
  126|       |#else
  127|       |    *sum2 += 2 * (uint32_t)((sum_even * 0x0000100020003ULL) >> 48)
  128|       |           +     (uint32_t)((sum_even * ADLER32_SWAR_HSUM) >> 48)
  129|       |           + 2 * (uint32_t)((sum_odd  * 0x1000200030004ULL) >> 48);
  130|       |#endif
  131|  1.63k|}
adler32_avx2.c:adler32_copy_tail:
  134|  4.74k|                                                uint32_t sum2, const int REBASE, const int MAX_LEN, const int COPY) {
  135|  4.74k|    if (len) {
  ------------------
  |  Branch (135:9): [True: 4.74k, False: 0]
  ------------------
  136|  4.74k|        Z_UNUSED(MAX_LEN);
  ------------------
  |  |  154|  4.74k|#define Z_UNUSED(var) (void)(var)
  ------------------
  137|       |        /* Process using packed 64-bit arithmetic when source is aligned */
  138|  6.92k|        while (len >= 8 && ((uintptr_t)buf & 7) == 0) {
  ------------------
  |  Branch (138:16): [True: 2.36k, False: 4.55k]
  |  Branch (138:28): [True: 2.17k, False: 190]
  ------------------
  139|  2.17k|            size_t chunk = MIN(ALIGN_DOWN(len, (size_t)8), (size_t)ADLER32_SWAR_MAX_BYTES);
  ------------------
  |  |  148|  2.17k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 2.17k]
  |  |  ------------------
  ------------------
  140|  2.17k|            adler32_swar(&adler, dst, buf, chunk, &sum2, COPY);
  141|  2.17k|            buf += chunk;
  142|  2.17k|            if (COPY)
  ------------------
  |  Branch (142:17): [True: 1.43k, False: 744]
  ------------------
  143|  1.43k|                dst += chunk;
  144|  2.17k|            len -= chunk;
  145|  2.17k|        }
  146|       |        /* DO4 loop avoids GCC x86 register pressure from hoisted DO8/DO16 loads. */
  147|  7.39k|        while (len >= 4) {
  ------------------
  |  Branch (147:16): [True: 2.64k, False: 4.74k]
  ------------------
  148|  2.64k|            if (COPY) {
  ------------------
  |  Branch (148:17): [True: 1.99k, False: 655]
  ------------------
  149|  1.99k|                memcpy(dst, buf, 4);
  150|  1.99k|                dst += 4;
  151|  1.99k|            }
  152|  2.64k|            len -= 4;
  153|  2.64k|            ADLER_DO4(adler, sum2, buf, 0);
  ------------------
  |  |   21|  2.64k|#define ADLER_DO4(sum1, sum2, buf, i)  {ADLER_DO2(sum1, sum2, buf, i); ADLER_DO2(sum1, sum2, buf, i+2);}
  |  |  ------------------
  |  |  |  |   20|  2.64k|#define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|  2.64k|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  |  |  |  |  ------------------
  |  |  |  |               #define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|  2.64k|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define ADLER_DO4(sum1, sum2, buf, i)  {ADLER_DO2(sum1, sum2, buf, i); ADLER_DO2(sum1, sum2, buf, i+2);}
  |  |  ------------------
  |  |  |  |   20|  2.64k|#define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|  2.64k|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  |  |  |  |  ------------------
  |  |  |  |               #define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|  2.64k|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  154|  2.64k|            buf += 4;
  155|  2.64k|        }
  156|  4.74k|        if (len & 2) {
  ------------------
  |  Branch (156:13): [True: 2.70k, False: 2.04k]
  ------------------
  157|  2.70k|            if (COPY) {
  ------------------
  |  Branch (157:17): [True: 1.87k, False: 834]
  ------------------
  158|  1.87k|                memcpy(dst, buf, 2);
  159|  1.87k|                dst += 2;
  160|  1.87k|            }
  161|  2.70k|            ADLER_DO2(adler, sum2, buf, 0);
  ------------------
  |  |   20|  2.70k|#define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
  |  |  ------------------
  |  |  |  |   19|  2.70k|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  |  |  ------------------
  |  |               #define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
  |  |  ------------------
  |  |  |  |   19|  2.70k|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  |  |  ------------------
  ------------------
  162|  2.70k|            buf += 2;
  163|  2.70k|        }
  164|  4.74k|        if (len & 1) {
  ------------------
  |  Branch (164:13): [True: 2.54k, False: 2.20k]
  ------------------
  165|  2.54k|            if (COPY)
  ------------------
  |  Branch (165:17): [True: 1.76k, False: 783]
  ------------------
  166|  1.76k|                *dst = *buf;
  167|  2.54k|            ADLER_DO1(adler, sum2, buf, 0);
  ------------------
  |  |   19|  2.54k|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  ------------------
  168|  2.54k|        }
  169|  4.74k|    }
  170|  4.74k|    if (REBASE) {
  ------------------
  |  Branch (170:9): [True: 4.74k, False: 0]
  ------------------
  171|  4.74k|        adler %= BASE;
  ------------------
  |  |   13|  4.74k|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  172|  4.74k|        sum2 %= BASE;
  ------------------
  |  |   13|  4.74k|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  173|  4.74k|    }
  174|       |    /* D = B * 65536 + A, see: https://en.wikipedia.org/wiki/Adler-32. */
  175|  4.74k|    return adler | (sum2 << 16);
  176|  4.74k|}
adler32_avx2.c:adler32_swar:
   66|  2.17k|                                       uint32_t *sum2, const int COPY) {
   67|  2.17k|    uint64_t sum_even = 0, sum_odd = 0, prefix_even = 0, prefix_odd = 0;
   68|       |
   69|  2.17k|    *sum2 += *adler * (uint32_t)len;
   70|       |
   71|  2.17k|    const uint64_t *src64 = (const uint64_t *)buf;
   72|       |
   73|  2.17k|    while (len >= 16) {
  ------------------
  |  Branch (73:12): [True: 0, False: 2.17k]
  ------------------
   74|      0|        uint64_t v0 = src64[0];
   75|      0|        uint64_t v1 = src64[1];
   76|      0|        if (COPY) {
  ------------------
  |  Branch (76:13): [True: 0, False: 0]
  ------------------
   77|      0|            memcpy(dst, &v0, sizeof(v0));
   78|      0|            memcpy(dst + 8, &v1, sizeof(v1));
   79|      0|            dst += 16;
   80|      0|        }
   81|       |
   82|      0|        prefix_even += sum_even;
   83|      0|        prefix_odd += sum_odd;
   84|      0|        sum_even +=  v0       & ADLER32_SWAR_EVEN_MASK;
  ------------------
  |  |   62|      0|#define ADLER32_SWAR_EVEN_MASK   0x00FF00FF00FF00FFULL
  ------------------
   85|      0|        sum_odd  += (v0 >> 8) & ADLER32_SWAR_EVEN_MASK;
  ------------------
  |  |   62|      0|#define ADLER32_SWAR_EVEN_MASK   0x00FF00FF00FF00FFULL
  ------------------
   86|       |
   87|      0|        prefix_even += sum_even;
   88|      0|        prefix_odd += sum_odd;
   89|      0|        sum_even +=  v1       & ADLER32_SWAR_EVEN_MASK;
  ------------------
  |  |   62|      0|#define ADLER32_SWAR_EVEN_MASK   0x00FF00FF00FF00FFULL
  ------------------
   90|      0|        sum_odd  += (v1 >> 8) & ADLER32_SWAR_EVEN_MASK;
  ------------------
  |  |   62|      0|#define ADLER32_SWAR_EVEN_MASK   0x00FF00FF00FF00FFULL
  ------------------
   91|       |
   92|      0|        src64 += 2;
   93|      0|        len -= 16;
   94|      0|    }
   95|       |
   96|       |    /* Handle remaining 8 bytes if present */
   97|  2.17k|    if (len >= 8) {
  ------------------
  |  Branch (97:9): [True: 2.17k, False: 0]
  ------------------
   98|  2.17k|        uint64_t v = *src64;
   99|  2.17k|        if (COPY)
  ------------------
  |  Branch (99:13): [True: 1.43k, False: 744]
  ------------------
  100|  1.43k|            memcpy(dst, &v, sizeof(v));
  101|       |
  102|  2.17k|        prefix_even += sum_even;
  103|  2.17k|        prefix_odd += sum_odd;
  104|  2.17k|        sum_even +=  v       & ADLER32_SWAR_EVEN_MASK;
  ------------------
  |  |   62|  2.17k|#define ADLER32_SWAR_EVEN_MASK   0x00FF00FF00FF00FFULL
  ------------------
  105|  2.17k|        sum_odd  += (v >> 8) & ADLER32_SWAR_EVEN_MASK;
  ------------------
  |  |   62|  2.17k|#define ADLER32_SWAR_EVEN_MASK   0x00FF00FF00FF00FFULL
  ------------------
  106|  2.17k|    }
  107|       |
  108|       |    /* Horizontal sum of 4x16-bit lanes for s1 */
  109|  2.17k|    *adler += (uint32_t)(((sum_even + sum_odd) * ADLER32_SWAR_HSUM) >> 48);
  ------------------
  |  |   63|  2.17k|#define ADLER32_SWAR_HSUM        0x1000100010001ULL
  ------------------
  110|       |
  111|       |    /* Widen prefix sums to 32-bit pairs and horizontal sum for s2 */
  112|  2.17k|    uint64_t pe_lo = prefix_even & 0xFFFF0000FFFFULL;
  113|  2.17k|    uint64_t pe_hi = (prefix_even >> 16) & 0xFFFF0000FFFFULL;
  114|  2.17k|    uint64_t po_lo = prefix_odd & 0xFFFF0000FFFFULL;
  115|  2.17k|    uint64_t po_hi = (prefix_odd >> 16) & 0xFFFF0000FFFFULL;
  116|       |
  117|  2.17k|    *sum2 += (uint32_t)(((pe_lo + po_lo + pe_hi + po_hi) * 0x800000008ULL) >> 32);
  118|       |
  119|       |    /* Positional weights [8,7,6,5,4,3,2,1] per 8-byte group for s2.
  120|       |     * On big-endian the even mask captures odd-index memory bytes (b1,b3,b5,b7)
  121|       |     * so HSUM (+1 per odd-index byte) must be applied to sum_even, not sum_odd. */
  122|  2.17k|#if BYTE_ORDER == LITTLE_ENDIAN
  123|  2.17k|    *sum2 += 2 * (uint32_t)((sum_even * 0x4000300020001ULL) >> 48)
  124|  2.17k|           +     (uint32_t)((sum_odd  * ADLER32_SWAR_HSUM) >> 48)
  ------------------
  |  |   63|  2.17k|#define ADLER32_SWAR_HSUM        0x1000100010001ULL
  ------------------
  125|  2.17k|           + 2 * (uint32_t)((sum_odd  * 0x3000200010000ULL) >> 48);
  126|       |#else
  127|       |    *sum2 += 2 * (uint32_t)((sum_even * 0x0000100020003ULL) >> 48)
  128|       |           +     (uint32_t)((sum_even * ADLER32_SWAR_HSUM) >> 48)
  129|       |           + 2 * (uint32_t)((sum_odd  * 0x1000200030004ULL) >> 48);
  130|       |#endif
  131|  2.17k|}

adler32_avx2:
  164|  3.05k|Z_INTERNAL uint32_t adler32_avx2(uint32_t adler, const uint8_t *src, size_t len) {
  165|       |    return adler32_copy_impl(adler, NULL, src, len, 0);
  166|  3.05k|}
adler32_copy_avx2:
  168|  20.9k|Z_INTERNAL uint32_t adler32_copy_avx2(uint32_t adler, uint8_t *dst, const uint8_t *src, size_t len) {
  169|  20.9k|    return adler32_copy_impl(adler, dst, src, len, 1);
  170|  20.9k|}
adler32_avx2.c:adler32_copy_impl:
   21|  24.0k|Z_FORCEINLINE static uint32_t adler32_copy_impl(uint32_t adler, uint8_t *dst, const uint8_t *src, size_t len, const int COPY) {
   22|  24.0k|    uint32_t adler0, adler1;
   23|  24.0k|    adler1 = (adler >> 16) & 0xffff;
   24|  24.0k|    adler0 = adler & 0xffff;
   25|       |
   26|  32.6k|rem_peel:
   27|  32.6k|    if (len < 16) {
  ------------------
  |  Branch (27:9): [True: 4.74k, False: 27.9k]
  ------------------
   28|  4.74k|        return adler32_copy_tail(adler0, dst, src, len, adler1, 1, 15, COPY);
   29|  27.9k|    } else if (len < 32) {
  ------------------
  |  Branch (29:16): [True: 5.20k, False: 22.7k]
  ------------------
   30|  5.20k|        if (COPY) {
  ------------------
  |  Branch (30:13): [True: 3.71k, False: 1.49k]
  ------------------
   31|  3.71k|            return adler32_copy_sse42(adler, dst, src, len);
   32|  3.71k|        } else {
   33|  1.49k|            return adler32_ssse3(adler, src, len);
   34|  1.49k|        }
   35|  5.20k|    }
   36|       |
   37|  22.7k|    __m256i vs1, vs2, vs2_0;
   38|       |
   39|  22.7k|    const __m256i dot2v = _mm256_setr_epi8(64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47,
   40|  22.7k|                                           46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33);
   41|  22.7k|    const __m256i dot2v_0 = _mm256_setr_epi8(32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15,
   42|  22.7k|                                             14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1);
   43|  22.7k|    const __m256i dot3v = _mm256_set1_epi16(1);
   44|  22.7k|    const __m256i zero = _mm256_setzero_si256();
   45|       |
   46|   200k|    while (len >= 32) {
  ------------------
  |  Branch (46:12): [True: 178k, False: 22.7k]
  ------------------
   47|   178k|        vs1 = _mm256_zextsi128_si256(_mm_cvtsi32_si128(adler0));
   48|   178k|        vs2 = _mm256_zextsi128_si256(_mm_cvtsi32_si128(adler1));
   49|   178k|        __m256i vs1_0 = vs1;
   50|   178k|        __m256i vs3 = _mm256_setzero_si256();
   51|   178k|        vs2_0 = vs3;
   52|       |
   53|   178k|        size_t k = ALIGN_DOWN(MIN(len, NMAX), 32);
  ------------------
  |  |  293|   356k|    ((value) & ~((align) - 1))
  |  |  ------------------
  |  |  |  Branch (293:7): [True: 155k, False: 22.6k]
  |  |  ------------------
  ------------------
   54|   178k|        len -= k;
   55|       |
   56|  14.9M|        while (k >= 64) {
  ------------------
  |  Branch (56:16): [True: 14.7M, False: 178k]
  ------------------
   57|  14.7M|            __m256i vbuf = _mm256_loadu_si256((__m256i*)src);
   58|  14.7M|            __m256i vbuf_0 = _mm256_loadu_si256((__m256i*)(src + 32));
   59|  14.7M|            src += 64;
   60|  14.7M|            k -= 64;
   61|       |
   62|  14.7M|            __m256i vs1_sad = _mm256_sad_epu8(vbuf, zero);
   63|  14.7M|            __m256i vs1_sad2 = _mm256_sad_epu8(vbuf_0, zero);
   64|       |
   65|  14.7M|            if (COPY) {
  ------------------
  |  Branch (65:17): [True: 8.34M, False: 6.39M]
  ------------------
   66|  8.34M|                _mm256_storeu_si256((__m256i*)dst, vbuf);
   67|  8.34M|                _mm256_storeu_si256((__m256i*)(dst + 32), vbuf_0);
   68|  8.34M|                dst += 64;
   69|  8.34M|            }
   70|       |
   71|  14.7M|            vs1 = _mm256_add_epi32(vs1, vs1_sad);
   72|  14.7M|            vs3 = _mm256_add_epi32(vs3, vs1_0);
   73|  14.7M|            __m256i v_short_sum2 = _mm256_maddubs_epi16(vbuf, dot2v); // sum 32 uint8s to 16 shorts
   74|  14.7M|            __m256i v_short_sum2_0 = _mm256_maddubs_epi16(vbuf_0, dot2v_0); // sum 32 uint8s to 16 shorts
   75|  14.7M|            __m256i vsum2 = _mm256_madd_epi16(v_short_sum2, dot3v); // sum 16 shorts to 8 uint32s
   76|  14.7M|            __m256i vsum2_0 = _mm256_madd_epi16(v_short_sum2_0, dot3v); // sum 16 shorts to 8 uint32s
   77|  14.7M|            vs1 = _mm256_add_epi32(vs1_sad2, vs1);
   78|  14.7M|            vs2 = _mm256_add_epi32(vsum2, vs2);
   79|  14.7M|            vs2_0 = _mm256_add_epi32(vsum2_0, vs2_0);
   80|  14.7M|            vs1_0 = vs1;
   81|  14.7M|        }
   82|       |
   83|   178k|        vs2 = _mm256_add_epi32(vs2_0, vs2);
   84|   178k|        vs3 = _mm256_slli_epi32(vs3, 6);
   85|   178k|        vs2 = _mm256_add_epi32(vs3, vs2);
   86|   178k|        vs3 = _mm256_setzero_si256();
   87|       |
   88|   351k|        while (k >= 32) {
  ------------------
  |  Branch (88:16): [True: 173k, False: 178k]
  ------------------
   89|       |            /*
   90|       |               vs1 = adler + sum(c[i])
   91|       |               vs2 = sum2 + 32 vs1 + sum( (32-i+1) c[i] )
   92|       |            */
   93|   173k|            __m256i vbuf = _mm256_loadu_si256((__m256i*)src);
   94|   173k|            src += 32;
   95|   173k|            k -= 32;
   96|       |
   97|   173k|            __m256i vs1_sad = _mm256_sad_epu8(vbuf, zero); // Sum of abs diff, resulting in 2 x int32's
   98|       |
   99|   173k|            if (COPY) {
  ------------------
  |  Branch (99:17): [True: 98.7k, False: 74.8k]
  ------------------
  100|  98.7k|                _mm256_storeu_si256((__m256i*)dst, vbuf);
  101|  98.7k|                dst += 32;
  102|  98.7k|            }
  103|       |
  104|   173k|            vs1 = _mm256_add_epi32(vs1, vs1_sad);
  105|   173k|            vs3 = _mm256_add_epi32(vs3, vs1_0);
  106|   173k|            __m256i v_short_sum2 = _mm256_maddubs_epi16(vbuf, dot2v_0); // sum 32 uint8s to 16 shorts
  107|   173k|            __m256i vsum2 = _mm256_madd_epi16(v_short_sum2, dot3v); // sum 16 shorts to 8 uint32s
  108|   173k|            vs2 = _mm256_add_epi32(vsum2, vs2);
  109|   173k|            vs1_0 = vs1;
  110|   173k|        }
  111|       |
  112|       |        /* Defer the multiplication with 32 to outside of the loop */
  113|   178k|        vs3 = _mm256_slli_epi32(vs3, 5);
  114|   178k|        vs2 = _mm256_add_epi32(vs2, vs3);
  115|       |
  116|       |        /* The compiler is generating the following sequence for this integer modulus
  117|       |         * when done the scalar way, in GPRs:
  118|       |
  119|       |         adler = (s1_unpack[0] % BASE) + (s1_unpack[1] % BASE) + (s1_unpack[2] % BASE) + (s1_unpack[3] % BASE) +
  120|       |                 (s1_unpack[4] % BASE) + (s1_unpack[5] % BASE) + (s1_unpack[6] % BASE) + (s1_unpack[7] % BASE);
  121|       |
  122|       |         mov    $0x80078071,%edi // move magic constant into 32 bit register %edi
  123|       |         ...
  124|       |         vmovd  %xmm1,%esi // move vector lane 0 to 32 bit register %esi
  125|       |         mov    %rsi,%rax  // zero-extend this value to 64 bit precision in %rax
  126|       |         imul   %rdi,%rsi // do a signed multiplication with magic constant and vector element
  127|       |         shr    $0x2f,%rsi // shift right by 47
  128|       |         imul   $0xfff1,%esi,%esi // do a signed multiplication with value truncated to 32 bits with 0xfff1
  129|       |         sub    %esi,%eax // subtract lower 32 bits of original vector value from modified one above
  130|       |         ...
  131|       |         // repeats for each element with vpextract instructions
  132|       |
  133|       |         This is tricky with AVX2 for a number of reasons:
  134|       |             1.) There's no 64 bit multiplication instruction, but there is a sequence to get there
  135|       |             2.) There's ways to extend vectors to 64 bit precision, but no simple way to truncate
  136|       |                 back down to 32 bit precision later (there is in AVX512)
  137|       |             3.) Full width integer multiplications aren't cheap
  138|       |
  139|       |         We can, however, do a relatively cheap sequence for horizontal sums.
  140|       |         Then, we simply do the integer modulus on the resulting 64 bit GPR, on a scalar value. It was
  141|       |         previously thought that casting to 64 bit precision was needed prior to the horizontal sum, but
  142|       |         that is simply not the case, as NMAX is defined as the maximum number of scalar sums that can be
  143|       |         performed on the maximum possible inputs before overflow
  144|       |         */
  145|       |
  146|       |
  147|       |         /* In AVX2-land, this trip through GPRs will probably be unavoidable, as there's no cheap and easy
  148|       |          * conversion from 64 bit integer to 32 bit (needed for the inexpensive modulus with a constant).
  149|       |          * This casting to 32 bit is cheap through GPRs (just register aliasing). See above for exactly
  150|       |          * what the compiler is doing to avoid integer divisions. */
  151|   178k|         adler0 = partial_hsum256(vs1) % BASE;
  ------------------
  |  |   13|   178k|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  152|   178k|         adler1 = hsum256(vs2) % BASE;
  ------------------
  |  |   13|   178k|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  153|   178k|    }
  154|       |
  155|  22.7k|    adler = adler0 | (adler1 << 16);
  156|       |
  157|  22.7k|    if (len) {
  ------------------
  |  Branch (157:9): [True: 8.64k, False: 14.0k]
  ------------------
  158|  8.64k|        goto rem_peel;
  159|  8.64k|    }
  160|       |
  161|  14.0k|    return adler;
  162|  22.7k|}

adler32_avx2.c:partial_hsum256:
   20|   178k|static inline uint32_t partial_hsum256(__m256i x) {
   21|       |    /* We need a permutation vector to extract every other integer. The
   22|       |     * rest are going to be zeros */
   23|   178k|    const __m256i perm_vec = _mm256_setr_epi32(0, 2, 4, 6, 1, 1, 1, 1);
   24|   178k|    __m256i non_zero = _mm256_permutevar8x32_epi32(x, perm_vec);
   25|   178k|    __m128i non_zero_sse = _mm256_castsi256_si128(non_zero);
   26|   178k|    __m128i sum2  = _mm_add_epi32(non_zero_sse,_mm_unpackhi_epi64(non_zero_sse, non_zero_sse));
   27|       |    __m128i sum3  = _mm_add_epi32(sum2, _mm_shuffle_epi32(sum2, 1));
   28|   178k|    return (uint32_t)_mm_cvtsi128_si32(sum3);
   29|   178k|}
adler32_avx2.c:hsum256:
   12|   178k|static inline uint32_t hsum256(__m256i x) {
   13|   178k|    __m128i sum1  = _mm_add_epi32(_mm256_extracti128_si256(x, 1),
   14|   178k|                                  _mm256_castsi256_si128(x));
   15|   178k|    __m128i sum2  = _mm_add_epi32(sum1, _mm_unpackhi_epi64(sum1, sum1));
   16|       |    __m128i sum3  = _mm_add_epi32(sum2, _mm_shuffle_epi32(sum2, 1));
   17|   178k|    return (uint32_t)_mm_cvtsi128_si32(sum3);
   18|   178k|}

adler32_copy_sse42:
   17|  3.71k|Z_INTERNAL uint32_t adler32_copy_sse42(uint32_t adler, uint8_t *dst, const uint8_t *src, size_t len) {
   18|  3.71k|    uint32_t adler0, adler1;
   19|  3.71k|    adler1 = (adler >> 16) & 0xffff;
   20|  3.71k|    adler0 = adler & 0xffff;
   21|       |
   22|  7.20k|rem_peel:
   23|  7.20k|    if (UNLIKELY(len < 16))
  ------------------
  |  |  258|  7.20k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 3.49k, False: 3.71k]
  |  |  ------------------
  ------------------
   24|  3.49k|       return adler32_copy_tail(adler0, dst, src, len, adler1, 1, 15, 1);
   25|       |
   26|  3.71k|    __m128i vbuf, vbuf_0;
   27|  3.71k|    __m128i vs1_0, vs3, vs1, vs2, vs2_0, v_sad_sum1, v_short_sum2, v_short_sum2_0,
   28|  3.71k|            v_sad_sum2, vsum2, vsum2_0;
   29|  3.71k|    __m128i zero = _mm_setzero_si128();
   30|  3.71k|    const __m128i dot2v = _mm_setr_epi8(32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17);
   31|  3.71k|    const __m128i dot2v_0 = _mm_setr_epi8(16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1);
   32|  3.71k|    const __m128i dot3v = _mm_set1_epi16(1);
   33|       |
   34|  7.42k|    while (len >= 16) {
  ------------------
  |  Branch (34:12): [True: 3.71k, False: 3.71k]
  ------------------
   35|  3.71k|        size_t k = ALIGN_DOWN(MIN(len, NMAX), 16);
  ------------------
  |  |  293|  7.42k|    ((value) & ~((align) - 1))
  |  |  ------------------
  |  |  |  Branch (293:7): [True: 0, False: 3.71k]
  |  |  ------------------
  ------------------
   36|  3.71k|        len -= k;
   37|       |
   38|  3.71k|        vs1 = _mm_cvtsi32_si128(adler0);
   39|  3.71k|        vs2 = _mm_cvtsi32_si128(adler1);
   40|       |
   41|  3.71k|        vs3 = _mm_setzero_si128();
   42|  3.71k|        vs2_0 = _mm_setzero_si128();
   43|  3.71k|        vs1_0 = vs1;
   44|       |
   45|  3.71k|        while (k >= 32) {
  ------------------
  |  Branch (45:16): [True: 0, False: 3.71k]
  ------------------
   46|       |            /*
   47|       |               vs1 = adler + sum(c[i])
   48|       |               vs2 = sum2 + 16 vs1 + sum( (16-i+1) c[i] )
   49|       |            */
   50|      0|            vbuf = _mm_loadu_si128((__m128i*)src);
   51|      0|            vbuf_0 = _mm_loadu_si128((__m128i*)(src + 16));
   52|      0|            src += 32;
   53|      0|            k -= 32;
   54|       |
   55|      0|            v_sad_sum1 = _mm_sad_epu8(vbuf, zero);
   56|      0|            v_sad_sum2 = _mm_sad_epu8(vbuf_0, zero);
   57|      0|            _mm_storeu_si128((__m128i*)dst, vbuf);
   58|      0|            _mm_storeu_si128((__m128i*)(dst + 16), vbuf_0);
   59|      0|            dst += 32;
   60|       |
   61|      0|            v_short_sum2 = _mm_maddubs_epi16(vbuf, dot2v);
   62|      0|            v_short_sum2_0 = _mm_maddubs_epi16(vbuf_0, dot2v_0);
   63|       |
   64|      0|            vs1 = _mm_add_epi32(v_sad_sum1, vs1);
   65|      0|            vs3 = _mm_add_epi32(vs1_0, vs3);
   66|       |
   67|      0|            vsum2 = _mm_madd_epi16(v_short_sum2, dot3v);
   68|      0|            vsum2_0 = _mm_madd_epi16(v_short_sum2_0, dot3v);
   69|      0|            vs1 = _mm_add_epi32(v_sad_sum2, vs1);
   70|      0|            vs2 = _mm_add_epi32(vsum2, vs2);
   71|      0|            vs2_0 = _mm_add_epi32(vsum2_0, vs2_0);
   72|      0|            vs1_0 = vs1;
   73|      0|        }
   74|       |
   75|  3.71k|        vs2 = _mm_add_epi32(vs2_0, vs2);
   76|  3.71k|        vs3 = _mm_slli_epi32(vs3, 5);
   77|  3.71k|        vs2 = _mm_add_epi32(vs3, vs2);
   78|  3.71k|        vs3 = _mm_setzero_si128();
   79|       |
   80|  7.42k|        while (k >= 16) {
  ------------------
  |  Branch (80:16): [True: 3.71k, False: 3.71k]
  ------------------
   81|       |            /*
   82|       |               vs1 = adler + sum(c[i])
   83|       |               vs2 = sum2 + 16 vs1 + sum( (16-i+1) c[i] )
   84|       |            */
   85|  3.71k|            vbuf = _mm_loadu_si128((__m128i*)src);
   86|  3.71k|            src += 16;
   87|  3.71k|            k -= 16;
   88|       |
   89|  3.71k|            v_sad_sum1 = _mm_sad_epu8(vbuf, zero);
   90|  3.71k|            v_short_sum2 = _mm_maddubs_epi16(vbuf, dot2v_0);
   91|       |
   92|  3.71k|            vs1 = _mm_add_epi32(v_sad_sum1, vs1);
   93|  3.71k|            vs3 = _mm_add_epi32(vs1_0, vs3);
   94|  3.71k|            vsum2 = _mm_madd_epi16(v_short_sum2, dot3v);
   95|  3.71k|            vs2 = _mm_add_epi32(vsum2, vs2);
   96|  3.71k|            vs1_0 = vs1;
   97|       |
   98|  3.71k|            _mm_storeu_si128((__m128i*)dst, vbuf);
   99|  3.71k|            dst += 16;
  100|  3.71k|        }
  101|       |
  102|  3.71k|        vs3 = _mm_slli_epi32(vs3, 4);
  103|  3.71k|        vs2 = _mm_add_epi32(vs2, vs3);
  104|       |
  105|  3.71k|        adler0 = partial_hsum(vs1) % BASE;
  ------------------
  |  |   13|  3.71k|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  106|  3.71k|        adler1 = hsum(vs2) % BASE;
  ------------------
  |  |   13|  3.71k|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  107|  3.71k|    }
  108|       |
  109|       |    /* If this is true, there's fewer than 16 elements remaining */
  110|  3.71k|    if (len) {
  ------------------
  |  Branch (110:9): [True: 3.49k, False: 213]
  ------------------
  111|  3.49k|        goto rem_peel;
  112|  3.49k|    }
  113|       |
  114|    213|    return adler0 | (adler1 << 16);
  115|  3.71k|}

adler32_ssse3:
   17|  1.49k|Z_INTERNAL uint32_t adler32_ssse3(uint32_t adler, const uint8_t *buf, size_t len) {
   18|       |    /* split Adler-32 into component sums */
   19|  1.49k|    uint32_t sum2 = (adler >> 16) & 0xffff;
   20|  1.49k|    adler &= 0xffff;
   21|       |
   22|       |    /* in case user likes doing a byte at a time, keep it fast */
   23|  1.49k|    if (UNLIKELY(len == 1))
  ------------------
  |  |  258|  1.49k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 1.49k]
  |  |  ------------------
  ------------------
   24|      0|        return adler32_copy_tail(adler, NULL, buf, 1, sum2, 1, 1, 0);
   25|       |
   26|       |    /* in case short lengths are provided, keep it somewhat fast */
   27|  1.49k|    if (UNLIKELY(len < 16))
  ------------------
  |  |  258|  1.49k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 1.49k]
  |  |  ------------------
  ------------------
   28|      0|        return adler32_copy_tail(adler, NULL, buf, len, sum2, 1, 15, 0);
   29|       |
   30|  1.49k|    const __m128i dot2v = _mm_setr_epi8(32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17);
   31|  1.49k|    const __m128i dot2v_0 = _mm_setr_epi8(16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1);
   32|  1.49k|    const __m128i dot3v = _mm_set1_epi16(1);
   33|  1.49k|    const __m128i zero = _mm_setzero_si128();
   34|       |
   35|  1.49k|    __m128i vbuf, vs1_0, vs3, vs1, vs2, vs2_0, v_sad_sum1, v_short_sum2, v_short_sum2_0,
   36|  1.49k|            vbuf_0, v_sad_sum2, vsum2, vsum2_0;
   37|       |
   38|       |    /* If our buffer is unaligned (likely), make the determination whether
   39|       |     * or not there's enough of a buffer to consume to make the scalar, aligning
   40|       |     * additions worthwhile or if it's worth it to just eat the cost of an unaligned
   41|       |     * load. This is a pretty simple test, just test if len < 32 */
   42|  1.49k|    size_t n = NMAX;
  ------------------
  |  |   14|  1.49k|#define NMAX 5552
  ------------------
   43|  1.49k|    size_t k = 0;
   44|       |
   45|  1.49k|    if (len < 32) {
  ------------------
  |  Branch (45:9): [True: 1.49k, False: 0]
  ------------------
   46|       |        /* Let's eat the cost of this one unaligned load so that
   47|       |         * we don't completely skip over the vectorization. Doing
   48|       |         * 16 bytes at a time unaligned is better than 16 + <= 15
   49|       |         * sums */
   50|  1.49k|        vbuf = _mm_loadu_si128((__m128i*)buf);
   51|  1.49k|        len -= 16;
   52|  1.49k|        buf += 16;
   53|  1.49k|        vs1 = _mm_cvtsi32_si128(adler);
   54|  1.49k|        vs2 = _mm_cvtsi32_si128(sum2);
   55|  1.49k|        vs3 = _mm_setzero_si128();
   56|  1.49k|        vs1_0 = vs1;
   57|  1.49k|        goto unaligned_jmp;
   58|  1.49k|    }
   59|       |
   60|      0|    {
   61|      0|        size_t align_diff = MIN(ALIGN_DIFF(buf, 16), len);
  ------------------
  |  |  148|      0|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
   62|      0|        if (align_diff) {
  ------------------
  |  Branch (62:13): [True: 0, False: 0]
  ------------------
   63|      0|            adler32_copy_align(&adler, NULL, buf, align_diff, &sum2, 15, 0);
   64|       |
   65|      0|            buf += align_diff;
   66|      0|            len -= align_diff;
   67|      0|            n -= align_diff;
   68|      0|        }
   69|      0|    }
   70|       |
   71|  1.49k|    while (len >= 16) {
  ------------------
  |  Branch (71:12): [True: 0, False: 1.49k]
  ------------------
   72|      0|        vs1 = _mm_cvtsi32_si128(adler);
   73|      0|        vs2 = _mm_cvtsi32_si128(sum2);
   74|      0|        vs3 = _mm_setzero_si128();
   75|      0|        vs2_0 = _mm_setzero_si128();
   76|      0|        vs1_0 = vs1;
   77|       |
   78|      0|        k = ALIGN_DOWN(MIN(len, n), 16);
  ------------------
  |  |  293|      0|    ((value) & ~((align) - 1))
  |  |  ------------------
  |  |  |  Branch (293:7): [True: 0, False: 0]
  |  |  ------------------
  ------------------
   79|      0|        len -= k;
   80|       |
   81|      0|        while (k >= 32) {
  ------------------
  |  Branch (81:16): [True: 0, False: 0]
  ------------------
   82|       |            /*
   83|       |               vs1 = adler + sum(c[i])
   84|       |               vs2 = sum2 + 16 vs1 + sum( (16-i+1) c[i] )
   85|       |            */
   86|      0|            vbuf = _mm_load_si128((__m128i*)buf);
   87|      0|            vbuf_0 = _mm_load_si128((__m128i*)(buf + 16));
   88|      0|            buf += 32;
   89|      0|            k -= 32;
   90|       |
   91|      0|            v_sad_sum1 = _mm_sad_epu8(vbuf, zero);
   92|      0|            v_sad_sum2 = _mm_sad_epu8(vbuf_0, zero);
   93|      0|            vs1 = _mm_add_epi32(v_sad_sum1, vs1);
   94|      0|            vs3 = _mm_add_epi32(vs1_0, vs3);
   95|       |
   96|      0|            vs1 = _mm_add_epi32(v_sad_sum2, vs1);
   97|      0|            v_short_sum2 = _mm_maddubs_epi16(vbuf, dot2v);
   98|      0|            vsum2 = _mm_madd_epi16(v_short_sum2, dot3v);
   99|      0|            v_short_sum2_0 = _mm_maddubs_epi16(vbuf_0, dot2v_0);
  100|      0|            vs2 = _mm_add_epi32(vsum2, vs2);
  101|      0|            vsum2_0 = _mm_madd_epi16(v_short_sum2_0, dot3v);
  102|      0|            vs2_0 = _mm_add_epi32(vsum2_0, vs2_0);
  103|      0|            vs1_0 = vs1;
  104|      0|        }
  105|       |
  106|      0|        vs2 = _mm_add_epi32(vs2_0, vs2);
  107|      0|        vs3 = _mm_slli_epi32(vs3, 5);
  108|      0|        vs2 = _mm_add_epi32(vs3, vs2);
  109|      0|        vs3 = _mm_setzero_si128();
  110|       |
  111|  1.49k|        while (k >= 16) {
  ------------------
  |  Branch (111:16): [True: 0, False: 1.49k]
  ------------------
  112|       |            /*
  113|       |               vs1 = adler + sum(c[i])
  114|       |               vs2 = sum2 + 16 vs1 + sum( (16-i+1) c[i] )
  115|       |            */
  116|      0|            vbuf = _mm_load_si128((__m128i*)buf);
  117|      0|            buf += 16;
  118|      0|            k -= 16;
  119|       |
  120|  1.49k|unaligned_jmp:
  121|  1.49k|            v_sad_sum1 = _mm_sad_epu8(vbuf, zero);
  122|  1.49k|            vs1 = _mm_add_epi32(v_sad_sum1, vs1);
  123|  1.49k|            vs3 = _mm_add_epi32(vs1_0, vs3);
  124|  1.49k|            v_short_sum2 = _mm_maddubs_epi16(vbuf, dot2v_0);
  125|  1.49k|            vsum2 = _mm_madd_epi16(v_short_sum2, dot3v);
  126|  1.49k|            vs2 = _mm_add_epi32(vsum2, vs2);
  127|  1.49k|            vs1_0 = vs1;
  128|  1.49k|        }
  129|       |
  130|  1.49k|        vs3 = _mm_slli_epi32(vs3, 4);
  131|  1.49k|        vs2 = _mm_add_epi32(vs2, vs3);
  132|       |
  133|       |        /* We don't actually need to do a full horizontal sum, since psadbw is actually doing
  134|       |         * a partial reduction sum implicitly and only summing to integers in vector positions
  135|       |         * 0 and 2. This saves us some contention on the shuffle port(s) */
  136|  1.49k|        adler = partial_hsum(vs1) % BASE;
  ------------------
  |  |   13|  1.49k|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  137|  1.49k|        sum2 = hsum(vs2) % BASE;
  ------------------
  |  |   13|  1.49k|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  138|  1.49k|        n = NMAX;
  ------------------
  |  |   14|  1.49k|#define NMAX 5552
  ------------------
  139|  1.49k|    }
  140|       |
  141|       |    /* Process tail (len < 16).  */
  142|  1.49k|    return adler32_copy_tail(adler, NULL, buf, len, sum2, len != 0, 15, 0);
  143|      0|}

adler32_ssse3.c:partial_hsum:
   14|  1.49k|static inline uint32_t partial_hsum(__m128i x) {
   15|       |    __m128i second_int = _mm_srli_si128(x, 8);
   16|  1.49k|    __m128i sum = _mm_add_epi32(x, second_int);
   17|  1.49k|    return _mm_cvtsi128_si32(sum);
   18|  1.49k|}
adler32_ssse3.c:hsum:
   20|  1.49k|static inline uint32_t hsum(__m128i x) {
   21|  1.49k|    __m128i sum1 = _mm_unpackhi_epi64(x, x);
   22|  1.49k|    __m128i sum2 = _mm_add_epi32(x, sum1);
   23|       |    __m128i sum3 = _mm_shuffle_epi32(sum2, 0x01);
   24|  1.49k|    __m128i sum4 = _mm_add_epi32(sum2, sum3);
   25|  1.49k|    return _mm_cvtsi128_si32(sum4);
   26|  1.49k|}
adler32_sse42.c:partial_hsum:
   14|  3.71k|static inline uint32_t partial_hsum(__m128i x) {
   15|       |    __m128i second_int = _mm_srli_si128(x, 8);
   16|  3.71k|    __m128i sum = _mm_add_epi32(x, second_int);
   17|  3.71k|    return _mm_cvtsi128_si32(sum);
   18|  3.71k|}
adler32_sse42.c:hsum:
   20|  3.71k|static inline uint32_t hsum(__m128i x) {
   21|  3.71k|    __m128i sum1 = _mm_unpackhi_epi64(x, x);
   22|  3.71k|    __m128i sum2 = _mm_add_epi32(x, sum1);
   23|       |    __m128i sum3 = _mm_shuffle_epi32(sum2, 0x01);
   24|  3.71k|    __m128i sum4 = _mm_add_epi32(sum2, sum3);
   25|  3.71k|    return _mm_cvtsi128_si32(sum4);
   26|  3.71k|}

chunkset_avx2.c:chunkmemset_1:
   26|  1.83M|static inline void chunkmemset_1(uint8_t *from, chunk_t *chunk) {
   27|  1.83M|    *chunk = _mm256_set1_epi8(*from);
   28|  1.83M|}
chunkset_avx2.c:storechunk:
   56|  14.6M|static inline void storechunk(uint8_t *out, chunk_t *chunk) {
   57|  14.6M|    _mm256_storeu_si256((__m256i *)out, *chunk);
   58|  14.6M|}
chunkset_avx2.c:loadchunk:
   52|  12.4k|static inline void loadchunk(uint8_t const *s, chunk_t *chunk) {
   53|  12.4k|    *chunk = _mm256_loadu_si256((__m256i *)s);
   54|  12.4k|}

compare256_avx2.c:compare256_avx2_static:
   19|  2.21M|Z_FORCEINLINE static uint32_t compare256_avx2_static(const uint8_t *src0, const uint8_t *src1) {
   20|  2.21M|    uint32_t len = 0;
   21|       |
   22|  8.28M|    do {
   23|  8.28M|        __m256i ymm_src0, ymm_src1, ymm_cmp;
   24|  8.28M|        ymm_src0 = _mm256_loadu_si256((__m256i*)src0);
   25|  8.28M|        ymm_src1 = _mm256_loadu_si256((__m256i*)src1);
   26|  8.28M|        ymm_cmp = _mm256_cmpeq_epi8(ymm_src0, ymm_src1); /* non-identical bytes = 00, identical bytes = FF */
   27|  8.28M|        unsigned mask = (unsigned)_mm256_movemask_epi8(ymm_cmp);
   28|  8.28M|        if (mask != 0xFFFFFFFF)
  ------------------
  |  Branch (28:13): [True: 187k, False: 8.10M]
  ------------------
   29|   187k|            return len + zng_ctz32(~mask); /* Invert bits so identical = 0 */
   30|       |
   31|  8.10M|        src0 += 32, src1 += 32, len += 32;
   32|       |
   33|  8.10M|        ymm_src0 = _mm256_loadu_si256((__m256i*)src0);
   34|  8.10M|        ymm_src1 = _mm256_loadu_si256((__m256i*)src1);
   35|  8.10M|        ymm_cmp = _mm256_cmpeq_epi8(ymm_src0, ymm_src1);
   36|  8.10M|        mask = (unsigned)_mm256_movemask_epi8(ymm_cmp);
   37|  8.10M|        if (mask != 0xFFFFFFFF)
  ------------------
  |  Branch (37:13): [True: 189k, False: 7.91M]
  ------------------
   38|   189k|            return len + zng_ctz32(~mask);
   39|       |
   40|  7.91M|        src0 += 32, src1 += 32, len += 32;
   41|  7.91M|    } while (len < 256);
  ------------------
  |  Branch (41:14): [True: 6.07M, False: 1.83M]
  ------------------
   42|       |
   43|  1.83M|    return 256;
   44|  2.21M|}

slide_hash_avx2:
   39|  13.0k|Z_INTERNAL void slide_hash_avx2(deflate_state *s) {
   40|  13.0k|    Assert(s->w_size <= UINT16_MAX, "w_size should fit in uint16_t");
   41|  13.0k|    uint16_t wsize = (uint16_t)s->w_size;
   42|  13.0k|    const __m256i ymm_wsize = _mm256_set1_epi16((short)wsize);
   43|       |
   44|  13.0k|    slide_hash_chain(s->head, HASH_SIZE, ymm_wsize);
  ------------------
  |  |   84|  13.0k|#  define HASH_SIZE 65536u         /* number of elements in hash table */
  ------------------
   45|  13.0k|    slide_hash_chain(s->prev, wsize, ymm_wsize);
   46|  13.0k|}
slide_hash_avx2.c:slide_hash_chain:
   20|  26.0k|static inline void slide_hash_chain(Pos *table, uint32_t entries, const __m256i wsize) {
   21|  26.0k|    table += entries;
   22|  26.0k|    table -= 32;
   23|       |
   24|  40.0M|    do {
   25|  40.0M|        __m256i value1, value2, result1, result2;
   26|       |
   27|  40.0M|        value1 = _mm256_load_si256((__m256i *)table);
   28|  40.0M|        value2 = _mm256_load_si256((__m256i *)(table+16));
   29|  40.0M|        result1 = _mm256_subs_epu16(value1, wsize);
   30|  40.0M|        result2 = _mm256_subs_epu16(value2, wsize);
   31|  40.0M|        _mm256_store_si256((__m256i *)table, result1);
   32|  40.0M|        _mm256_store_si256((__m256i *)(table+16), result2);
   33|       |
   34|  40.0M|        table -= 32;
   35|  40.0M|        entries -= 32;
   36|  40.0M|    } while (entries > 0);
  ------------------
  |  Branch (36:14): [True: 40.0M, False: 26.0k]
  ------------------
   37|  26.0k|}

x86_check_features:
   78|      2|void Z_INTERNAL x86_check_features(struct x86_cpu_features *features) {
   79|      2|    unsigned eax, ebx, ecx, edx;
   80|      2|    unsigned maxbasic;
   81|       |
   82|      2|    cpuid(0, &maxbasic, &ebx, &ecx, &edx);
   83|      2|    cpuid(1 /*CPU_PROCINFO_AND_FEATUREBITS*/, &eax, &ebx, &ecx, &edx);
   84|       |
   85|      2|    features->has_sse2 = edx & 0x4000000;
   86|      2|    features->has_ssse3 = ecx & 0x200;
   87|      2|    features->has_sse41 = ecx & 0x80000;
   88|      2|    features->has_sse42 = ecx & 0x100000;
   89|      2|    features->has_pclmulqdq = ecx & 0x2;
   90|       |
   91|      2|    if (ecx & 0x08000000) {
  ------------------
  |  Branch (91:9): [True: 2, False: 0]
  ------------------
   92|      2|        uint64_t xfeature = xgetbv(0);
   93|       |
   94|      2|        features->has_os_save_ymm = ((xfeature & 0x06) == 0x06);
   95|      2|        features->has_os_save_zmm = ((xfeature & 0xe6) == 0xe6);
   96|      2|    }
   97|       |
   98|      2|    if (maxbasic >= 7) {
  ------------------
  |  Branch (98:9): [True: 2, False: 0]
  ------------------
   99|       |        // Reference: https://software.intel.com/sites/default/files/article/405250/how-to-detect-new-instruction-support-in-the-4th-generation-intel-core-processor-family.pdf
  100|      2|        cpuidex(7, 0, &eax, &ebx, &ecx, &edx);
  101|       |
  102|       |        // check BMI2 bit
  103|      2|        features->has_bmi2 = ebx & 0x100;
  104|       |
  105|       |        // check AVX2 bit if the OS supports saving YMM registers
  106|      2|        if (features->has_os_save_ymm) {
  ------------------
  |  Branch (106:13): [True: 2, False: 0]
  ------------------
  107|      2|            features->has_avx2 = ebx & 0x20;
  108|      2|            features->has_vpclmulqdq = ecx & 0x400;
  109|      2|        }
  110|       |
  111|       |        // check AVX512 bits if the OS supports saving ZMM registers
  112|      2|        if (features->has_os_save_zmm) {
  ------------------
  |  Branch (112:13): [True: 0, False: 2]
  ------------------
  113|      0|            features->has_avx512f = ebx & 0x00010000;
  114|      0|            if (features->has_avx512f) {
  ------------------
  |  Branch (114:17): [True: 0, False: 0]
  ------------------
  115|       |                // According to the Intel Software Developer's Manual, AVX512F must be enabled too in order to enable
  116|       |                // AVX512(DQ,BW,VL).
  117|      0|                features->has_avx512dq = ebx & 0x00020000;
  118|      0|                features->has_avx512bw = ebx & 0x40000000;
  119|      0|                features->has_avx512vl = ebx & 0x80000000;
  120|      0|            }
  121|      0|            features->has_avx512_common = features->has_avx512f && features->has_avx512dq && features->has_avx512bw \
  ------------------
  |  Branch (121:43): [True: 0, False: 0]
  |  Branch (121:68): [True: 0, False: 0]
  |  Branch (121:94): [True: 0, False: 0]
  ------------------
  122|      0|              && features->has_avx512vl && features->has_bmi2;
  ------------------
  |  Branch (122:18): [True: 0, False: 0]
  |  Branch (122:44): [True: 0, False: 0]
  ------------------
  123|      0|            features->has_avx512vnni = ecx & 0x800;
  124|      0|        }
  125|       |
  126|      2|        if (features->has_os_save_ymm) {
  ------------------
  |  Branch (126:13): [True: 2, False: 0]
  ------------------
  127|      2|            cpuidex(7, 1, &eax, &ebx, &ecx, &edx);
  128|      2|            features->has_avx2vnni = eax & 0x10;
  129|      2|        }
  130|       |
  131|      2|    }
  132|      2|}
x86_features.c:cpuid:
   29|      4|static inline void cpuid(int info, unsigned* eax, unsigned* ebx, unsigned* ecx, unsigned* edx) {
   30|       |#if defined(HAVE_CPUID_MS)
   31|       |    unsigned int registers[4];
   32|       |    __cpuid((int *)registers, info);
   33|       |
   34|       |    *eax = registers[0];
   35|       |    *ebx = registers[1];
   36|       |    *ecx = registers[2];
   37|       |    *edx = registers[3];
   38|       |#elif defined(HAVE_CPUID_GNU)
   39|       |    *eax = *ebx = *ecx = *edx = 0;
   40|      4|    __cpuid(info, *eax, *ebx, *ecx, *edx);
   41|       |#else
   42|       |    /* When using this fallback, the faster SSE/AVX code is disabled */
   43|       |    *eax = *ebx = *ecx = *edx = 0;
   44|       |#endif
   45|      4|}
x86_features.c:xgetbv:
   65|      2|static inline uint64_t xgetbv(unsigned int xcr) {
   66|      2|#if defined(_MSC_VER) || defined(X86_HAVE_XSAVE_INTRIN)
   67|      2|    return _xgetbv(xcr);
   68|       |#elif defined(__GNUC__)
   69|       |    uint32_t eax, edx;
   70|       |    __asm__ ( ".byte 0x0f, 0x01, 0xd0" : "=a"(eax), "=d"(edx) : "c"(xcr));
   71|       |    return (uint64_t)(edx) << 32 | eax;
   72|       |#else
   73|       |    /* When using this fallback, some of the faster code is disabled */
   74|       |    return 0;
   75|       |#endif
   76|      2|}
x86_features.c:cpuidex:
   47|      4|static inline void cpuidex(int info, int subinfo, unsigned* eax, unsigned* ebx, unsigned* ecx, unsigned* edx) {
   48|       |#if defined(HAVE_CPUID_MS)
   49|       |    unsigned int registers[4];
   50|       |    __cpuidex((int *)registers, info, subinfo);
   51|       |
   52|       |    *eax = registers[0];
   53|       |    *ebx = registers[1];
   54|       |    *ecx = registers[2];
   55|       |    *edx = registers[3];
   56|       |#elif defined(HAVE_CPUID_GNU)
   57|       |    *eax = *ebx = *ecx = *edx = 0;
   58|      4|    __cpuid_count(info, subinfo, *eax, *ebx, *ecx, *edx);
   59|       |#else
   60|       |    /* When using this fallback, the faster SSE/AVX code is disabled */
   61|       |    *eax = *ebx = *ecx = *edx = 0;
   62|       |#endif
   63|      4|}

chunkmemset_safe_avx2:
  252|  3.12k|Z_INTERNAL uint8_t* CHUNKMEMSET_SAFE(uint8_t *out, uint8_t *from, size_t len, size_t left) {
  253|       |#if OPTIMAL_CMP < 32
  254|       |    static const uintptr_t align_mask = 7;
  255|       |#elif OPTIMAL_CMP == 32
  256|       |    static const uintptr_t align_mask = 3;
  257|       |#endif
  258|       |
  259|  3.12k|    len = MIN(len, left);
  ------------------
  |  |  148|  3.12k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 3.12k]
  |  |  ------------------
  ------------------
  260|       |
  261|       |#if OPTIMAL_CMP < 64
  262|       |    while (((uintptr_t)out & align_mask) && (len > 0)) {
  263|       |        *out++ = *from++;
  264|       |        --len;
  265|       |        --left;
  266|       |    }
  267|       |#endif
  268|       |
  269|  3.12k|#ifndef HAVE_MASKED_READWRITE
  270|  3.12k|    if (UNLIKELY(left < sizeof(chunk_t))) {
  ------------------
  |  |  258|  3.12k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 227, False: 2.89k]
  |  |  ------------------
  ------------------
  271|  3.34k|        while (len > 0) {
  ------------------
  |  Branch (271:16): [True: 3.11k, False: 227]
  ------------------
  272|  3.11k|            *out++ = *from++;
  273|  3.11k|            --len;
  274|  3.11k|        }
  275|       |
  276|    227|        return out;
  277|    227|    }
  278|  2.89k|#endif
  279|       |
  280|  2.89k|    if (len)
  ------------------
  |  Branch (280:9): [True: 2.89k, False: 0]
  ------------------
  281|  2.89k|        out = CHUNKMEMSET(out, from, len);
  ------------------
  |  |  125|  2.89k|#define CHUNKMEMSET      chunkmemset_avx2
  ------------------
  282|       |
  283|  2.89k|    return out;
  284|  3.12k|}
chunkset_avx2.c:chunkmemset_avx2:
  111|  1.83M|static inline uint8_t* CHUNKMEMSET(uint8_t *out, uint8_t *from, size_t len) {
  112|       |    /* Debug performance related issues when len < sizeof(uint64_t):
  113|       |       Assert(len >= sizeof(uint64_t), "chunkmemset should be called on larger chunks"); */
  114|  1.83M|    Assert(from != out, "chunkmemset cannot have a distance 0");
  115|       |
  116|  1.83M|    chunk_t chunk_load;
  117|  1.83M|    size_t chunk_mod = 0;
  118|  1.83M|    size_t adv_amount;
  119|  1.83M|    size_t dist = (size_t)ABS(out - from);
  ------------------
  |  |  152|  1.83M|#define ABS(a) ((a) < 0 ? -(a) : (a))
  |  |  ------------------
  |  |  |  Branch (152:17): [True: 1.15k, False: 1.83M]
  |  |  ------------------
  ------------------
  120|       |
  121|       |    /* We are supporting the case for when we are reading bytes from ahead in the buffer.
  122|       |     * We now have to handle this, though it wasn't _quite_ clear if this rare circumstance
  123|       |     * always needed to be handled here or if we're just now seeing it because we are
  124|       |     * dispatching to this function, more */
  125|  1.83M|    if (out < from && dist < len) {
  ------------------
  |  Branch (125:9): [True: 1.15k, False: 1.83M]
  |  Branch (125:23): [True: 0, False: 1.15k]
  ------------------
  126|       |#ifdef HAVE_MASKED_READWRITE
  127|       |        if (len <= sizeof(chunk_t)) {
  128|       |            loadchunk_masked(from, &chunk_load, len);
  129|       |            storechunk_masked(out, &chunk_load, len);
  130|       |            return out + len;
  131|       |        }
  132|       |#endif
  133|       |        /* Here the memmove semantics match perfectly, as when this happens we are
  134|       |         * effectively sliding down the contents of memory by dist bytes */
  135|      0|        memmove(out, from, len);
  136|      0|        return out + len;
  137|      0|    }
  138|       |
  139|       |#ifndef HAVE_CHUNKMEMSET_1
  140|       |    if (dist == 1) {
  141|       |        memset(out, *from, len);
  142|       |        return out + len;
  143|       |    } else
  144|       |#endif
  145|  1.83M|    if (dist >= len || dist >= sizeof(chunk_t)) {
  ------------------
  |  Branch (145:9): [True: 1.16k, False: 1.83M]
  |  Branch (145:24): [True: 0, False: 1.83M]
  ------------------
  146|  1.16k|        return CHUNKCOPY(out, from, len);
  ------------------
  |  |  123|  1.16k|#define CHUNKCOPY        chunkcopy_avx2
  ------------------
  147|  1.16k|    }
  148|       |
  149|       |    /* Only AVX2+ as there's 128 bit vectors and 256 bit. We allow for shorter vector
  150|       |     * lengths because they serve to allow more cases to fall into chunkcopy, as the
  151|       |     * distance of the shorter length is still deemed a safe distance. We rewrite this
  152|       |     * here rather than calling the ssse3 variant directly now because doing so required
  153|       |     * dispatching to another function and broke inlining for this function entirely. We
  154|       |     * also can merge an assert and some remainder peeling behavior into the same code blocks,
  155|       |     * making the code a little smaller.  */
  156|  1.83M|#ifdef HAVE_HALF_CHUNK
  157|  1.83M|    if (dist > 1 && len <= sizeof(halfchunk_t)) {
  ------------------
  |  Branch (157:9): [True: 0, False: 1.83M]
  |  Branch (157:21): [True: 0, False: 0]
  ------------------
  158|      0|        if (dist >= sizeof(halfchunk_t))
  ------------------
  |  Branch (158:13): [True: 0, False: 0]
  ------------------
  159|      0|            return HALFCHUNKCOPY(out, from, len);
  160|       |
  161|      0|        if ((dist % 2) != 0 || dist == 6) {
  ------------------
  |  Branch (161:13): [True: 0, False: 0]
  |  Branch (161:32): [True: 0, False: 0]
  ------------------
  162|      0|            halfchunk_t halfchunk_load = GET_HALFCHUNK_MAG(from, &chunk_mod, dist);
  163|       |
  164|      0|            if (len == sizeof(halfchunk_t)) {
  ------------------
  |  Branch (164:17): [True: 0, False: 0]
  ------------------
  165|      0|                storehalfchunk(out, &halfchunk_load);
  166|      0|                len -= sizeof(halfchunk_t);
  167|      0|                out += sizeof(halfchunk_t);
  168|      0|            }
  169|       |
  170|      0|            chunk_load = halfchunk2whole(&halfchunk_load);
  171|      0|            goto rem_bytes;
  172|      0|        }
  173|      0|    }
  174|  1.83M|#endif
  175|       |
  176|  1.83M|#ifdef HAVE_CHUNKMEMSET_1
  177|       |    /* Broadcast + chunk store beats memset on NEON/AVX2/AVX-512 */
  178|  1.83M|    if (dist == 1) {
  ------------------
  |  Branch (178:9): [True: 1.83M, False: 0]
  ------------------
  179|  1.83M|        chunkmemset_1(from, &chunk_load);
  180|  1.83M|    } else
  181|      0|#endif
  182|      0|#ifdef HAVE_CHUNKMEMSET_2
  183|      0|    if (dist == 2) {
  ------------------
  |  Branch (183:9): [True: 0, False: 0]
  ------------------
  184|      0|        chunkmemset_2(from, &chunk_load);
  185|      0|    } else
  186|      0|#endif
  187|      0|#ifdef HAVE_CHUNKMEMSET_4
  188|      0|    if (dist == 4) {
  ------------------
  |  Branch (188:9): [True: 0, False: 0]
  ------------------
  189|      0|        chunkmemset_4(from, &chunk_load);
  190|      0|    } else
  191|      0|#endif
  192|      0|#ifdef HAVE_CHUNKMEMSET_8
  193|      0|    if (dist == 8) {
  ------------------
  |  Branch (193:9): [True: 0, False: 0]
  ------------------
  194|      0|        chunkmemset_8(from, &chunk_load);
  195|      0|    } else
  196|      0|#endif
  197|      0|#ifdef HAVE_CHUNKMEMSET_16
  198|      0|    if (dist == 16) {
  ------------------
  |  Branch (198:9): [True: 0, False: 0]
  ------------------
  199|      0|        chunkmemset_16(from, &chunk_load);
  200|      0|    } else
  201|      0|#endif
  202|      0|    chunk_load = GET_CHUNK_MAG(from, &chunk_mod, dist);
  203|       |
  204|  1.83M|    if (len <= sizeof(chunk_t)) {
  ------------------
  |  Branch (204:9): [True: 993, False: 1.83M]
  ------------------
  205|       |#ifdef HAVE_MASKED_READWRITE
  206|       |        storechunk_masked(out, &chunk_load, len);
  207|       |#else
  208|    993|        storechunk(out, &chunk_load);
  209|    993|#endif
  210|    993|        return out + len;
  211|    993|    }
  212|       |
  213|  1.83M|    adv_amount = sizeof(chunk_t) - chunk_mod;
  214|       |
  215|  9.17M|    while (len >= (2 * sizeof(chunk_t))) {
  ------------------
  |  Branch (215:12): [True: 7.34M, False: 1.83M]
  ------------------
  216|  7.34M|        storechunk(out, &chunk_load);
  217|  7.34M|        storechunk(out + adv_amount, &chunk_load);
  218|  7.34M|        out += 2 * adv_amount;
  219|  7.34M|        len -= 2 * adv_amount;
  220|  7.34M|    }
  221|       |
  222|       |    /* If we don't have a "dist" length that divides evenly into a vector
  223|       |     * register, we can write the whole vector register but we need only
  224|       |     * advance by the amount of the whole string that fits in our chunk_t.
  225|       |     * If we do divide evenly into the vector length, adv_amount = chunk_t size*/
  226|  1.83M|    while (len >= sizeof(chunk_t)) {
  ------------------
  |  Branch (226:12): [True: 1.48k, False: 1.83M]
  ------------------
  227|  1.48k|        storechunk(out, &chunk_load);
  228|  1.48k|        len -= adv_amount;
  229|  1.48k|        out += adv_amount;
  230|  1.48k|    }
  231|       |
  232|  1.83M|#ifdef HAVE_HALF_CHUNK
  233|  1.83M|rem_bytes:
  234|  1.83M|#endif
  235|  1.83M|    if (len) {
  ------------------
  |  Branch (235:9): [True: 1.83M, False: 94]
  ------------------
  236|       |#ifdef HAVE_MASKED_READWRITE
  237|       |        storechunk_masked(out, &chunk_load, len);
  238|       |        out += len;
  239|       |#else
  240|  1.83M|        uint8_t *chunk_p = (uint8_t *)&chunk_load;
  241|  1.83M|        if (len & 16) { memcpy(out, chunk_p, 16); out += 16; chunk_p += 16; }
  ------------------
  |  Branch (241:13): [True: 1.16k, False: 1.83M]
  ------------------
  242|  1.83M|        if (len & 8) { memcpy(out, chunk_p, 8); out += 8; chunk_p += 8; }
  ------------------
  |  Branch (242:13): [True: 1.02k, False: 1.83M]
  ------------------
  243|  1.83M|        if (len & 4) { memcpy(out, chunk_p, 4); out += 4; chunk_p += 4; }
  ------------------
  |  Branch (243:13): [True: 1.10k, False: 1.83M]
  ------------------
  244|  1.83M|        if (len & 2) { memcpy(out, chunk_p, 2); out += 2; chunk_p += 2; }
  ------------------
  |  Branch (244:13): [True: 1.83M, False: 1.21k]
  ------------------
  245|  1.83M|        if (len & 1) { *out++ = *chunk_p; }
  ------------------
  |  Branch (245:13): [True: 1.24k, False: 1.83M]
  ------------------
  246|  1.83M|#endif
  247|  1.83M|    }
  248|       |
  249|  1.83M|    return out;
  250|  1.83M|}
chunkset_avx2.c:CHUNKCOPY_SAFE:
  287|  1.15k|{
  288|  1.15k|    if (out == from)
  ------------------
  |  Branch (288:9): [True: 0, False: 1.15k]
  ------------------
  289|      0|        return out + len;
  290|       |
  291|  1.15k|    size_t safelen = (safe - out);
  292|  1.15k|    len = MIN(len, safelen);
  ------------------
  |  |  148|  1.15k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 1.15k]
  |  |  ------------------
  ------------------
  293|       |
  294|  1.15k|#ifndef HAVE_MASKED_READWRITE
  295|  1.15k|    size_t from_dist = (size_t)ABS(safe - from);
  ------------------
  |  |  152|  1.15k|#define ABS(a) ((a) < 0 ? -(a) : (a))
  |  |  ------------------
  |  |  |  Branch (152:17): [True: 1.15k, False: 0]
  |  |  ------------------
  ------------------
  296|  1.15k|    if (UNLIKELY(from_dist < sizeof(chunk_t) || safelen < sizeof(chunk_t))) {
  ------------------
  |  |  258|  2.30k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 1.15k]
  |  |  |  Branch (258:53): [True: 0, False: 1.15k]
  |  |  |  Branch (258:53): [True: 0, False: 1.15k]
  |  |  ------------------
  ------------------
  297|      0|        while (len--) {
  ------------------
  |  Branch (297:16): [True: 0, False: 0]
  ------------------
  298|      0|            *out++ = *from++;
  299|      0|        }
  300|       |
  301|      0|        return out;
  302|      0|    }
  303|  1.15k|#endif
  304|       |
  305|  1.15k|    return CHUNKMEMSET(out, from, len);
  ------------------
  |  |  125|  1.15k|#define CHUNKMEMSET      chunkmemset_avx2
  ------------------
  306|  1.15k|}
chunkset_avx2.c:chunksize_avx2:
    9|  1.83M|static inline size_t CHUNKSIZE(void) {
   10|  1.83M|    return sizeof(chunk_t);
   11|  1.83M|}
chunkset_avx2.c:chunkcopy_avx2:
   24|  1.38k|static inline uint8_t* CHUNKCOPY(uint8_t *out, uint8_t const *from, size_t len) {
   25|  1.38k|    Assert(len > 0, "chunkcopy should never have a length 0");
   26|  1.38k|    chunk_t chunk;
   27|  1.38k|    size_t align = ((len - 1) % sizeof(chunk_t)) + 1;
   28|  1.38k|    loadchunk(from, &chunk);
   29|  1.38k|    storechunk(out, &chunk);
   30|  1.38k|    out += align;
   31|  1.38k|    from += align;
   32|  1.38k|    len -= align;
   33|  12.4k|    while (len > 0) {
  ------------------
  |  Branch (33:12): [True: 11.0k, False: 1.38k]
  ------------------
   34|  11.0k|        loadchunk(from, &chunk);
   35|  11.0k|        storechunk(out, &chunk);
   36|  11.0k|        out += sizeof(chunk_t);
   37|  11.0k|        from += sizeof(chunk_t);
   38|  11.0k|        len -= sizeof(chunk_t);
   39|  11.0k|    }
   40|  1.38k|    return out;
   41|  1.38k|}

cpu_check_features:
   10|      2|Z_INTERNAL void cpu_check_features(struct cpu_features *features) {
   11|      2|    memset(features, 0, sizeof(struct cpu_features));
   12|      2|#if defined(X86_FEATURES)
   13|      2|    x86_check_features(&features->x86);
   14|       |#elif defined(ARM_FEATURES)
   15|       |    arm_check_features(&features->arm);
   16|       |#elif defined(PPC_FEATURES) || defined(POWER_FEATURES)
   17|       |    power_check_features(&features->power);
   18|       |#elif defined(S390_FEATURES)
   19|       |    s390_check_features(&features->s390);
   20|       |#elif defined(RISCV_FEATURES)
   21|       |    riscv_check_features(&features->riscv);
   22|       |#elif defined(LOONGARCH_FEATURES)
   23|       |    loongarch_check_features(&features->loongarch);
   24|       |#endif
   25|      2|}

alloc_deflate:
  174|  1.58k|Z_INTERNAL deflate_allocs* alloc_deflate(PREFIX3(stream) *strm, int windowBits, int lit_bufsize) {
  175|  1.58k|    int curr_size = 0;
  176|       |
  177|       |    /* Define sizes */
  178|  1.58k|    int window_size = DEFLATE_ADJUST_WINDOW_SIZE((1 << windowBits) * 2);
  ------------------
  |  |  469|  1.58k|#  define DEFLATE_ADJUST_WINDOW_SIZE(n) (n)
  ------------------
  179|  1.58k|    int prev_size = (1 << windowBits) * (int)sizeof(Pos);
  180|  1.58k|    int head_size = HASH_SIZE * sizeof(Pos);
  ------------------
  |  |   84|  1.58k|#  define HASH_SIZE 65536u         /* number of elements in hash table */
  ------------------
  181|  1.58k|    int pending_size = (lit_bufsize * LIT_BUFS) + 1;
  ------------------
  |  |  293|  1.58k|#   define LIT_BUFS 4
  ------------------
  182|  1.58k|    int state_size = sizeof(deflate_state);
  183|  1.58k|    int alloc_size = sizeof(deflate_allocs);
  184|       |
  185|       |    /* Calculate relative buffer positions and paddings */
  186|  1.58k|    LOGSZP("window", window_size, PAD_WINDOW(curr_size), PADSZ(curr_size,WINDOW_PAD_SIZE));
  187|  1.58k|    int window_pos = PAD_WINDOW(curr_size);
  ------------------
  |  |  465|  1.58k|#  define PAD_WINDOW            PAD_64
  |  |  ------------------
  |  |  |  |  301|  1.58k|#define PAD_64(bpos) ((bpos) + PADSZ((bpos),64))
  |  |  |  |  ------------------
  |  |  |  |  |  |  299|  1.58k|#define PADSZ(bpos, pad) (((pad) - ((uintptr_t)(bpos) % (pad))) % (pad))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  188|  1.58k|    curr_size = window_pos + window_size;
  189|       |
  190|  1.58k|    LOGSZP("prev", prev_size, PAD_64(curr_size), PADSZ(curr_size,64));
  191|  1.58k|    int prev_pos = PAD_64(curr_size);
  ------------------
  |  |  301|  1.58k|#define PAD_64(bpos) ((bpos) + PADSZ((bpos),64))
  |  |  ------------------
  |  |  |  |  299|  1.58k|#define PADSZ(bpos, pad) (((pad) - ((uintptr_t)(bpos) % (pad))) % (pad))
  |  |  ------------------
  ------------------
  192|  1.58k|    curr_size = prev_pos + prev_size;
  193|       |
  194|  1.58k|    LOGSZP("head", head_size, PAD_64(curr_size), PADSZ(curr_size,64));
  195|  1.58k|    int head_pos = PAD_64(curr_size);
  ------------------
  |  |  301|  1.58k|#define PAD_64(bpos) ((bpos) + PADSZ((bpos),64))
  |  |  ------------------
  |  |  |  |  299|  1.58k|#define PADSZ(bpos, pad) (((pad) - ((uintptr_t)(bpos) % (pad))) % (pad))
  |  |  ------------------
  ------------------
  196|  1.58k|    curr_size = head_pos + head_size;
  197|       |
  198|  1.58k|    LOGSZP("pending", pending_size, PAD_64(curr_size), PADSZ(curr_size,64));
  199|  1.58k|    int pending_pos = PAD_64(curr_size);
  ------------------
  |  |  301|  1.58k|#define PAD_64(bpos) ((bpos) + PADSZ((bpos),64))
  |  |  ------------------
  |  |  |  |  299|  1.58k|#define PADSZ(bpos, pad) (((pad) - ((uintptr_t)(bpos) % (pad))) % (pad))
  |  |  ------------------
  ------------------
  200|  1.58k|    curr_size = pending_pos + pending_size;
  201|       |
  202|  1.58k|    LOGSZP("state", state_size, PAD_64(curr_size), PADSZ(curr_size,64));
  203|  1.58k|    int state_pos = PAD_64(curr_size);
  ------------------
  |  |  301|  1.58k|#define PAD_64(bpos) ((bpos) + PADSZ((bpos),64))
  |  |  ------------------
  |  |  |  |  299|  1.58k|#define PADSZ(bpos, pad) (((pad) - ((uintptr_t)(bpos) % (pad))) % (pad))
  |  |  ------------------
  ------------------
  204|  1.58k|    curr_size = state_pos + state_size;
  205|       |
  206|  1.58k|    LOGSZP("alloc", alloc_size, PAD_16(curr_size), PADSZ(curr_size,16));
  207|  1.58k|    int alloc_pos = PAD_16(curr_size);
  ------------------
  |  |  300|  1.58k|#define PAD_16(bpos) ((bpos) + PADSZ((bpos),16))
  |  |  ------------------
  |  |  |  |  299|  1.58k|#define PADSZ(bpos, pad) (((pad) - ((uintptr_t)(bpos) % (pad))) % (pad))
  |  |  ------------------
  ------------------
  208|  1.58k|    curr_size = alloc_pos + alloc_size;
  209|       |
  210|       |    /* Add 64-1 or 4096-1 to allow window alignment, and round size of buffer up to multiple of 64 */
  211|  1.58k|    int total_size = PAD_64(curr_size + (WINDOW_PAD_SIZE - 1));
  ------------------
  |  |  301|  1.58k|#define PAD_64(bpos) ((bpos) + PADSZ((bpos),64))
  |  |  ------------------
  |  |  |  |  299|  1.58k|#define PADSZ(bpos, pad) (((pad) - ((uintptr_t)(bpos) % (pad))) % (pad))
  |  |  ------------------
  ------------------
  212|       |
  213|       |    /* Allocate buffer, align to 64-byte cacheline, and zerofill the resulting buffer */
  214|  1.58k|    char *original_buf = (char *)strm->zalloc(strm->opaque, 1, total_size);
  215|  1.58k|    if (original_buf == NULL)
  ------------------
  |  Branch (215:9): [True: 0, False: 1.58k]
  ------------------
  216|      0|        return NULL;
  217|       |
  218|  1.58k|    char *buff = (char *)HINT_ALIGNED_WINDOW((char *)PAD_WINDOW(original_buf));
  ------------------
  |  |  467|  1.58k|#  define HINT_ALIGNED_WINDOW   HINT_ALIGNED_64
  |  |  ------------------
  |  |  |  |  280|  1.58k|#define HINT_ALIGNED_64(p) HINT_ALIGNED((p),64)
  |  |  |  |  ------------------
  |  |  |  |  |  |  275|  1.58k|#  define HINT_ALIGNED(p,n) __builtin_assume_aligned((void *)(p),(n))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  219|  1.58k|    LOGSZPL("Buffer alloc", total_size, PADSZ((uintptr_t)original_buf,WINDOW_PAD_SIZE), PADSZ(curr_size,WINDOW_PAD_SIZE));
  220|       |
  221|       |    /* Initialize alloc_bufs */
  222|  1.58k|    deflate_allocs *alloc_bufs  = (struct deflate_allocs_s *)(buff + alloc_pos);
  223|  1.58k|    alloc_bufs->buf_start = original_buf;
  224|  1.58k|    alloc_bufs->zfree = strm->zfree;
  225|       |
  226|       |    /* Assign buffers */
  227|  1.58k|    alloc_bufs->window = (unsigned char *)HINT_ALIGNED_WINDOW(buff + window_pos);
  ------------------
  |  |  467|  1.58k|#  define HINT_ALIGNED_WINDOW   HINT_ALIGNED_64
  |  |  ------------------
  |  |  |  |  280|  1.58k|#define HINT_ALIGNED_64(p) HINT_ALIGNED((p),64)
  |  |  |  |  ------------------
  |  |  |  |  |  |  275|  1.58k|#  define HINT_ALIGNED(p,n) __builtin_assume_aligned((void *)(p),(n))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  228|  1.58k|    alloc_bufs->prev = (Pos *)HINT_ALIGNED_64(buff + prev_pos);
  ------------------
  |  |  280|  1.58k|#define HINT_ALIGNED_64(p) HINT_ALIGNED((p),64)
  |  |  ------------------
  |  |  |  |  275|  1.58k|#  define HINT_ALIGNED(p,n) __builtin_assume_aligned((void *)(p),(n))
  |  |  ------------------
  ------------------
  229|  1.58k|    alloc_bufs->head = (Pos *)HINT_ALIGNED_64(buff + head_pos);
  ------------------
  |  |  280|  1.58k|#define HINT_ALIGNED_64(p) HINT_ALIGNED((p),64)
  |  |  ------------------
  |  |  |  |  275|  1.58k|#  define HINT_ALIGNED(p,n) __builtin_assume_aligned((void *)(p),(n))
  |  |  ------------------
  ------------------
  230|  1.58k|    alloc_bufs->pending_buf = (unsigned char *)HINT_ALIGNED_64(buff + pending_pos);
  ------------------
  |  |  280|  1.58k|#define HINT_ALIGNED_64(p) HINT_ALIGNED((p),64)
  |  |  ------------------
  |  |  |  |  275|  1.58k|#  define HINT_ALIGNED(p,n) __builtin_assume_aligned((void *)(p),(n))
  |  |  ------------------
  ------------------
  231|  1.58k|    alloc_bufs->state = (deflate_state *)HINT_ALIGNED_16(buff + state_pos);
  ------------------
  |  |  279|  1.58k|#define HINT_ALIGNED_16(p) HINT_ALIGNED((p),16)
  |  |  ------------------
  |  |  |  |  275|  1.58k|#  define HINT_ALIGNED(p,n) __builtin_assume_aligned((void *)(p),(n))
  |  |  ------------------
  ------------------
  232|       |
  233|  1.58k|    memset(alloc_bufs->prev, 0, prev_size);
  234|       |
  235|  1.58k|    return alloc_bufs;
  236|  1.58k|}
zng_deflateInit2:
  256|  1.58k|                                            int32_t memLevel, int32_t strategy) {
  257|       |    /* Todo: ignore strm->next_in if we use it as window */
  258|  1.58k|    deflate_state *s;
  259|  1.58k|    int wrap = 1;
  260|       |
  261|       |    /* Initialize functable */
  262|  1.58k|    FUNCTABLE_INIT;
  ------------------
  |  |   45|  1.58k|#  define FUNCTABLE_INIT if (functable.force_init()) {return Z_VERSION_ERROR;}
  |  |  ------------------
  |  |  |  |  188|      0|#define Z_VERSION_ERROR (-6)
  |  |  ------------------
  |  |  |  Branch (45:30): [True: 0, False: 1.58k]
  |  |  ------------------
  ------------------
  263|       |
  264|  1.58k|    if (strm == NULL)
  ------------------
  |  Branch (264:9): [True: 0, False: 1.58k]
  ------------------
  265|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  266|       |
  267|  1.58k|    strm->msg = NULL;
  268|  1.58k|    if (strm->zalloc == NULL) {
  ------------------
  |  Branch (268:9): [True: 1.58k, False: 0]
  ------------------
  269|  1.58k|        strm->zalloc = PREFIX(zcalloc);
  ------------------
  |  |  121|  1.58k|#  define PREFIX(x) zng_ ## x
  ------------------
  270|  1.58k|        strm->opaque = NULL;
  271|  1.58k|    }
  272|  1.58k|    if (strm->zfree == NULL)
  ------------------
  |  Branch (272:9): [True: 1.58k, False: 0]
  ------------------
  273|  1.58k|        strm->zfree = PREFIX(zcfree);
  ------------------
  |  |  121|  1.58k|#  define PREFIX(x) zng_ ## x
  ------------------
  274|       |
  275|  1.58k|    if (level == Z_DEFAULT_COMPRESSION)
  ------------------
  |  |  196|  1.58k|#define Z_DEFAULT_COMPRESSION  (-1)
  ------------------
  |  Branch (275:9): [True: 0, False: 1.58k]
  ------------------
  276|      0|        level = 6;
  277|       |
  278|  1.58k|    if (windowBits < 0) { /* suppress zlib wrapper */
  ------------------
  |  Branch (278:9): [True: 0, False: 1.58k]
  ------------------
  279|      0|        wrap = 0;
  280|      0|        if (windowBits < -MAX_WBITS)
  ------------------
  |  |   40|      0|#  define MAX_WBITS   15 /* 32K LZ77 window */
  ------------------
  |  Branch (280:13): [True: 0, False: 0]
  ------------------
  281|      0|            return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  282|      0|        windowBits = -windowBits;
  283|      0|#ifdef GZIP
  284|  1.58k|    } else if (windowBits > MAX_WBITS) {
  ------------------
  |  |   40|  1.58k|#  define MAX_WBITS   15 /* 32K LZ77 window */
  ------------------
  |  Branch (284:16): [True: 0, False: 1.58k]
  ------------------
  285|      0|        wrap = 2;       /* write gzip wrapper instead */
  286|      0|        windowBits -= 16;
  287|      0|#endif
  288|      0|    }
  289|  1.58k|    if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || windowBits < MIN_WBITS ||
  ------------------
  |  |   28|  3.16k|#  define MAX_MEM_LEVEL 9
  ------------------
                  if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || windowBits < MIN_WBITS ||
  ------------------
  |  |  212|  3.16k|#define Z_DEFLATED   8
  ------------------
                  if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || windowBits < MIN_WBITS ||
  ------------------
  |  |   37|  3.16k|#  define MIN_WBITS   8  /* 256 LZ77 window */
  ------------------
  |  Branch (289:9): [True: 0, False: 1.58k]
  |  Branch (289:25): [True: 0, False: 1.58k]
  |  Branch (289:53): [True: 0, False: 1.58k]
  |  Branch (289:77): [True: 0, False: 1.58k]
  ------------------
  290|  1.58k|        windowBits > MAX_WBITS || level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED ||
  ------------------
  |  |   40|  3.16k|#  define MAX_WBITS   15 /* 32K LZ77 window */
  ------------------
                      windowBits > MAX_WBITS || level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED ||
  ------------------
  |  |  202|  3.16k|#define Z_FIXED               4
  ------------------
  |  Branch (290:9): [True: 0, False: 1.58k]
  |  Branch (290:35): [True: 0, False: 1.58k]
  |  Branch (290:48): [True: 0, False: 1.58k]
  |  Branch (290:61): [True: 0, False: 1.58k]
  |  Branch (290:77): [True: 0, False: 1.58k]
  ------------------
  291|  1.58k|        (windowBits == 8 && wrap != 1)) {
  ------------------
  |  Branch (291:10): [True: 0, False: 1.58k]
  |  Branch (291:29): [True: 0, False: 0]
  ------------------
  292|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  293|      0|    }
  294|  1.58k|    if (windowBits == 8)
  ------------------
  |  Branch (294:9): [True: 0, False: 1.58k]
  ------------------
  295|      0|        windowBits = 9;  /* until 256-byte window bug fixed */
  296|       |
  297|       |    /* Allocate buffers */
  298|  1.58k|    int lit_bufsize = 1 << (memLevel + 6);
  299|  1.58k|    deflate_allocs *alloc_bufs = alloc_deflate(strm, windowBits, lit_bufsize);
  300|  1.58k|    if (alloc_bufs == NULL)
  ------------------
  |  Branch (300:9): [True: 0, False: 1.58k]
  ------------------
  301|      0|        return Z_MEM_ERROR;
  ------------------
  |  |  186|      0|#define Z_MEM_ERROR    (-4)
  ------------------
  302|       |
  303|  1.58k|    s = alloc_bufs->state;
  304|  1.58k|    s->alloc_bufs = alloc_bufs;
  305|  1.58k|    s->window = alloc_bufs->window;
  306|  1.58k|    s->prev = alloc_bufs->prev;
  307|  1.58k|    s->head = alloc_bufs->head;
  308|  1.58k|    s->pending_buf = alloc_bufs->pending_buf;
  309|       |
  310|  1.58k|    strm->state = (struct internal_state *)s;
  311|  1.58k|    s->strm = strm;
  312|  1.58k|    s->status = INIT_STATE;     /* to pass state test in deflateReset() */
  ------------------
  |  |   66|  1.58k|#define INIT_STATE      1    /* zlib header -> BUSY_STATE */
  ------------------
  313|       |
  314|  1.58k|    s->wrap = wrap;
  315|  1.58k|    s->gzhead = NULL;
  316|  1.58k|    s->w_size = 1 << windowBits;
  317|       |
  318|  1.58k|    s->high_water = 0;      /* nothing written to s->window yet */
  319|       |
  320|  1.58k|    s->lit_bufsize = lit_bufsize; /* 16K elements by default */
  321|       |
  322|       |    /* We overlay pending_buf and sym_buf. This works since the average size
  323|       |     * for length/distance pairs over any compressed block is assured to be 31
  324|       |     * bits or less.
  325|       |     *
  326|       |     * Analysis: The longest fixed codes are a length code of 8 bits plus 5
  327|       |     * extra bits, for lengths 131 to 257. The longest fixed distance codes are
  328|       |     * 5 bits plus 13 extra bits, for distances 16385 to 32768. The longest
  329|       |     * possible fixed-codes length/distance pair is then 31 bits total.
  330|       |     *
  331|       |     * sym_buf starts one-fourth of the way into pending_buf. So there are
  332|       |     * three bytes in sym_buf for every four bytes in pending_buf. Each symbol
  333|       |     * in sym_buf is three bytes -- two for the distance and one for the
  334|       |     * literal/length. As each symbol is consumed, the pointer to the next
  335|       |     * sym_buf value to read moves forward three bytes. From that symbol, up to
  336|       |     * 31 bits are written to pending_buf. The closest the written pending_buf
  337|       |     * bits gets to the next sym_buf symbol to read is just before the last
  338|       |     * code is written. At that time, 31*(n-2) bits have been written, just
  339|       |     * after 24*(n-2) bits have been consumed from sym_buf. sym_buf starts at
  340|       |     * 8*n bits into pending_buf. (Note that the symbol buffer fills when n-1
  341|       |     * symbols are written.) The closest the writing gets to what is unread is
  342|       |     * then n+14 bits. Here n is lit_bufsize, which is 16384 by default, and
  343|       |     * can range from 128 to 32768.
  344|       |     *
  345|       |     * Therefore, at a minimum, there are 142 bits of space between what is
  346|       |     * written and what is read in the overlain buffers, so the symbols cannot
  347|       |     * be overwritten by the compressed data. That space is actually 139 bits,
  348|       |     * due to the three-bit fixed-code block header.
  349|       |     *
  350|       |     * That covers the case where either Z_FIXED is specified, forcing fixed
  351|       |     * codes, or when the use of fixed codes is chosen, because that choice
  352|       |     * results in a smaller compressed block than dynamic codes. That latter
  353|       |     * condition then assures that the above analysis also covers all dynamic
  354|       |     * blocks. A dynamic-code block will only be chosen to be emitted if it has
  355|       |     * fewer bits than a fixed-code block would for the same set of symbols.
  356|       |     * Therefore its average symbol length is assured to be less than 31. So
  357|       |     * the compressed data for a dynamic block also cannot overwrite the
  358|       |     * symbols from which it is being constructed.
  359|       |     */
  360|       |
  361|  1.58k|    s->pending_buf_size = s->lit_bufsize * 4;
  362|       |
  363|       |#ifdef LIT_MEM
  364|       |    s->d_buf = (uint16_t *)(s->pending_buf + (s->lit_bufsize << 1));
  365|       |    s->l_buf = s->pending_buf + (s->lit_bufsize << 2);
  366|       |    s->sym_end = s->lit_bufsize - 1;
  367|       |#else
  368|  1.58k|    s->sym_buf = s->pending_buf + s->lit_bufsize;
  369|  1.58k|    s->sym_end = (s->lit_bufsize - 1) * 3;
  370|  1.58k|#endif
  371|       |    /* We avoid equality with lit_bufsize*3 because of wraparound at 64K
  372|       |     * on 16 bit machines and because stored blocks are restricted to
  373|       |     * 64K-1 bytes.
  374|       |     */
  375|       |
  376|  1.58k|    s->level = level;
  377|  1.58k|    s->strategy = strategy;
  378|  1.58k|    s->block_open = 0;
  379|  1.58k|    s->reproducible = 0;
  380|       |
  381|  1.58k|    return PREFIX(deflateReset)(strm);
  ------------------
  |  |  121|  1.58k|#  define PREFIX(x) zng_ ## x
  ------------------
  382|  1.58k|}
zng_deflateInit:
  385|  1.58k|int32_t Z_EXPORT PREFIX(deflateInit)(PREFIX3(stream) *strm, int32_t level) {
  386|  1.58k|    return PREFIX(deflateInit2)(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);
  ------------------
  |  |  121|  1.58k|#  define PREFIX(x) zng_ ## x
  ------------------
                  return PREFIX(deflateInit2)(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);
  ------------------
  |  |  212|  1.58k|#define Z_DEFLATED   8
  ------------------
                  return PREFIX(deflateInit2)(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);
  ------------------
  |  |   40|  1.58k|#  define MAX_WBITS   15 /* 32K LZ77 window */
  ------------------
                  return PREFIX(deflateInit2)(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);
  ------------------
  |  |   50|  1.58k|#  define DEF_MEM_LEVEL 8
  ------------------
                  return PREFIX(deflateInit2)(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);
  ------------------
  |  |  203|  1.58k|#define Z_DEFAULT_STRATEGY    0
  ------------------
  387|  1.58k|}
zng_deflateResetKeep:
  503|  1.58k|int32_t Z_EXPORT PREFIX(deflateResetKeep)(PREFIX3(stream) *strm) {
  504|  1.58k|    deflate_state *s;
  505|       |
  506|  1.58k|    if (deflateStateCheck(strm))
  ------------------
  |  Branch (506:9): [True: 0, False: 1.58k]
  ------------------
  507|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  508|       |
  509|  1.58k|    strm->total_in = strm->total_out = 0;
  510|  1.58k|    strm->msg = NULL; /* use zfree if we ever allocate msg dynamically */
  511|  1.58k|    strm->data_type = Z_UNKNOWN;
  ------------------
  |  |  209|  1.58k|#define Z_UNKNOWN  2
  ------------------
  512|       |
  513|  1.58k|    s = (deflate_state *)strm->state;
  514|  1.58k|    s->pending = 0;
  515|  1.58k|    s->pending_out = s->pending_buf;
  516|       |
  517|  1.58k|    if (s->wrap < 0)
  ------------------
  |  Branch (517:9): [True: 0, False: 1.58k]
  ------------------
  518|      0|        s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */
  519|       |
  520|  1.58k|    s->status =
  521|  1.58k|#ifdef GZIP
  522|  1.58k|        s->wrap == 2 ? GZIP_STATE :
  ------------------
  |  |   68|      0|#  define GZIP_STATE    4    /* gzip header -> BUSY_STATE | EXTRA_STATE */
  ------------------
  |  Branch (522:9): [True: 0, False: 1.58k]
  ------------------
  523|  1.58k|#endif
  524|  1.58k|        INIT_STATE;
  ------------------
  |  |   66|  3.16k|#define INIT_STATE      1    /* zlib header -> BUSY_STATE */
  ------------------
  525|       |
  526|  1.58k|#ifdef GZIP
  527|  1.58k|    if (s->wrap == 2) {
  ------------------
  |  Branch (527:9): [True: 0, False: 1.58k]
  ------------------
  528|      0|        strm->adler = CRC32_INITIAL_VALUE;
  ------------------
  |  |   71|      0|#define CRC32_INITIAL_VALUE   0 /* initial crc-32 hash value */
  ------------------
  529|      0|    } else
  530|  1.58k|#endif
  531|  1.58k|        strm->adler = ADLER32_INITIAL_VALUE;
  ------------------
  |  |   70|  1.58k|#define ADLER32_INITIAL_VALUE 1 /* initial adler-32 hash value */
  ------------------
  532|  1.58k|    s->last_flush = -2;
  533|       |
  534|  1.58k|    zng_tr_init(s);
  535|       |
  536|  1.58k|    DEFLATE_RESET_KEEP_HOOK(strm);  /* hook for IBM Z DFLTCC */
  ------------------
  |  |  475|  1.58k|#  define DEFLATE_RESET_KEEP_HOOK(strm) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (475:54): [Folded, False: 1.58k]
  |  |  ------------------
  ------------------
  537|       |
  538|  1.58k|    return Z_OK;
  ------------------
  |  |  180|  1.58k|#define Z_OK            0
  ------------------
  539|  1.58k|}
zng_deflateReset:
  542|  1.58k|int32_t Z_EXPORT PREFIX(deflateReset)(PREFIX3(stream) *strm) {
  543|  1.58k|    int ret = PREFIX(deflateResetKeep)(strm);
  ------------------
  |  |  121|  1.58k|#  define PREFIX(x) zng_ ## x
  ------------------
  544|  1.58k|    if (ret == Z_OK)
  ------------------
  |  |  180|  1.58k|#define Z_OK            0
  ------------------
  |  Branch (544:9): [True: 1.58k, False: 0]
  ------------------
  545|  1.58k|        lm_init(strm->state);
  546|  1.58k|    return ret;
  547|  1.58k|}
zng_deflateParams:
  614|  3.16k|int32_t Z_EXPORT PREFIX(deflateParams)(PREFIX3(stream) *strm, int32_t level, int32_t strategy) {
  615|  3.16k|    deflate_state *s;
  616|  3.16k|    compress_func func;
  617|  3.16k|    int hook_flush = Z_NO_FLUSH;
  ------------------
  |  |  171|  3.16k|#define Z_NO_FLUSH      0
  ------------------
  618|       |
  619|  3.16k|    if (deflateStateCheck(strm))
  ------------------
  |  Branch (619:9): [True: 0, False: 3.16k]
  ------------------
  620|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  621|  3.16k|    s = strm->state;
  622|       |
  623|  3.16k|    if (level == Z_DEFAULT_COMPRESSION)
  ------------------
  |  |  196|  3.16k|#define Z_DEFAULT_COMPRESSION  (-1)
  ------------------
  |  Branch (623:9): [True: 0, False: 3.16k]
  ------------------
  624|      0|        level = 6;
  625|  3.16k|    if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED)
  ------------------
  |  |  202|  3.16k|#define Z_FIXED               4
  ------------------
  |  Branch (625:9): [True: 0, False: 3.16k]
  |  Branch (625:22): [True: 0, False: 3.16k]
  |  Branch (625:35): [True: 0, False: 3.16k]
  |  Branch (625:51): [True: 0, False: 3.16k]
  ------------------
  626|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  627|  3.16k|    DEFLATE_PARAMS_HOOK(strm, level, strategy, &hook_flush);  /* hook for IBM Z DFLTCC */
  ------------------
  |  |  477|  3.16k|#  define DEFLATE_PARAMS_HOOK(strm, level, strategy, hook_flush) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (477:79): [Folded, False: 3.16k]
  |  |  ------------------
  ------------------
  628|  3.16k|    func = configuration_table[s->level].func;
  629|       |
  630|  3.16k|    if (((strategy != s->strategy || func != configuration_table[level].func) && s->last_flush != -2)
  ------------------
  |  Branch (630:11): [True: 1.58k, False: 1.58k]
  |  Branch (630:38): [True: 1.58k, False: 0]
  |  Branch (630:82): [True: 3.16k, False: 0]
  ------------------
  631|  3.16k|        || hook_flush != Z_NO_FLUSH) {
  ------------------
  |  |  171|      0|#define Z_NO_FLUSH      0
  ------------------
  |  Branch (631:12): [True: 0, False: 0]
  ------------------
  632|       |        /* Flush the last buffer. Use Z_BLOCK mode, unless the hook requests a "stronger" one. */
  633|  3.16k|        int flush = RANK(hook_flush) > RANK(Z_BLOCK) ? hook_flush : Z_BLOCK;
  ------------------
  |  |  148|  3.16k|#define RANK(f) (((f) * 2) - ((f) > 4 ? 9 : 0))
  |  |  ------------------
  |  |  |  Branch (148:31): [True: 0, False: 3.16k]
  |  |  ------------------
  ------------------
                      int flush = RANK(hook_flush) > RANK(Z_BLOCK) ? hook_flush : Z_BLOCK;
  ------------------
  |  |  148|  3.16k|#define RANK(f) (((f) * 2) - ((f) > 4 ? 9 : 0))
  |  |  ------------------
  |  |  |  Branch (148:31): [True: 3.16k, Folded]
  |  |  ------------------
  ------------------
                      int flush = RANK(hook_flush) > RANK(Z_BLOCK) ? hook_flush : Z_BLOCK;
  ------------------
  |  |  176|  3.16k|#define Z_BLOCK         5
  ------------------
  |  Branch (633:21): [True: 0, False: 3.16k]
  ------------------
  634|  3.16k|        int err = PREFIX(deflate)(strm, flush);
  ------------------
  |  |  121|  3.16k|#  define PREFIX(x) zng_ ## x
  ------------------
  635|  3.16k|        if (err == Z_STREAM_ERROR)
  ------------------
  |  |  184|  3.16k|#define Z_STREAM_ERROR (-2)
  ------------------
  |  Branch (635:13): [True: 0, False: 3.16k]
  ------------------
  636|      0|            return err;
  637|  3.16k|        if (strm->avail_in || ((int)s->strstart - s->block_start) + s->lookahead || !DEFLATE_DONE(strm, flush))
  ------------------
  |  |  479|      0|#  define DEFLATE_DONE(strm, flush) 1
  ------------------
  |  Branch (637:13): [True: 0, False: 3.16k]
  |  Branch (637:31): [True: 0, False: 3.16k]
  |  Branch (637:85): [Folded, False: 0]
  ------------------
  638|      0|            return Z_BUF_ERROR;
  ------------------
  |  |  187|      0|#define Z_BUF_ERROR    (-5)
  ------------------
  639|  3.16k|    }
  640|       |
  641|  3.16k|    int hashless = level == 0 || strategy == Z_HUFFMAN_ONLY || strategy == Z_RLE;
  ------------------
  |  |  200|  4.74k|#define Z_HUFFMAN_ONLY        2
  ------------------
                  int hashless = level == 0 || strategy == Z_HUFFMAN_ONLY || strategy == Z_RLE;
  ------------------
  |  |  201|  1.58k|#define Z_RLE                 3
  ------------------
  |  Branch (641:20): [True: 1.58k, False: 1.58k]
  |  Branch (641:34): [True: 0, False: 1.58k]
  |  Branch (641:64): [True: 0, False: 1.58k]
  ------------------
  642|  3.16k|    int was_hashless = s->level == 0 || s->strategy == Z_HUFFMAN_ONLY || s->strategy == Z_RLE;
  ------------------
  |  |  200|  4.74k|#define Z_HUFFMAN_ONLY        2
  ------------------
                  int was_hashless = s->level == 0 || s->strategy == Z_HUFFMAN_ONLY || s->strategy == Z_RLE;
  ------------------
  |  |  201|  1.58k|#define Z_RLE                 3
  ------------------
  |  Branch (642:24): [True: 1.58k, False: 1.58k]
  |  Branch (642:41): [True: 0, False: 1.58k]
  |  Branch (642:74): [True: 0, False: 1.58k]
  ------------------
  643|       |
  644|       |    /* Stale if the hash usage flipped (to/from huffman/rle/stored), the hash
  645|       |     * function changed at level 9, or quick at level 1 left prev unmaintained. */
  646|  3.16k|    int stale_chain = (hashless != was_hashless) || (level >= 9) != (s->level >= 9) ||
  ------------------
  |  Branch (646:23): [True: 3.16k, False: 0]
  |  Branch (646:53): [True: 0, False: 0]
  ------------------
  647|      0|                      (HAVE_QUICK_STRATEGY && s->level == 1 && level != 1);
  ------------------
  |  |  144|      0|#  define HAVE_QUICK_STRATEGY 1
  |  |  ------------------
  |  |  |  Branch (144:31): [True: 0, Folded]
  |  |  ------------------
  ------------------
  |  Branch (647:47): [True: 0, False: 0]
  |  Branch (647:64): [True: 0, False: 0]
  ------------------
  648|       |
  649|       |    /* Rebuild the hash chains when fill_window is called. */
  650|  3.16k|    if (stale_chain && !hashless) {
  ------------------
  |  Branch (650:9): [True: 3.16k, False: 0]
  |  Branch (650:24): [True: 1.58k, False: 1.58k]
  ------------------
  651|  1.58k|        CLEAR_HASH(s);
  ------------------
  |  |  154|  1.58k|#define CLEAR_HASH(s) do { \
  |  |  155|  1.58k|    memset((unsigned char *)s->head, 0, HASH_SIZE * sizeof(*s->head)); \
  |  |  ------------------
  |  |  |  |   84|  1.58k|#  define HASH_SIZE 65536u         /* number of elements in hash table */
  |  |  ------------------
  |  |  156|  1.58k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (156:12): [Folded, False: 1.58k]
  |  |  ------------------
  ------------------
  652|  1.58k|        s->ins_h = 0;
  653|  1.58k|        s->insert = MIN(s->strstart, s->w_size);
  ------------------
  |  |  148|  1.58k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 731, False: 849]
  |  |  ------------------
  ------------------
  654|  1.58k|    }
  655|       |
  656|  3.16k|    if (s->level != level)
  ------------------
  |  Branch (656:9): [True: 3.16k, False: 0]
  ------------------
  657|  3.16k|        lm_set_level(s, level);
  658|  3.16k|    s->strategy = strategy;
  659|  3.16k|    return Z_OK;
  ------------------
  |  |  180|  3.16k|#define Z_OK            0
  ------------------
  660|  3.16k|}
zng_flush_pending:
  773|  9.48k|Z_INTERNAL void PREFIX(flush_pending)(PREFIX3(stream) *strm) {
  774|  9.48k|    flush_pending_inline(strm);
  775|  9.48k|}
zng_deflate:
  959|  9.48k|int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) {
  960|  9.48k|    int32_t old_flush; /* value of flush param for previous deflate call */
  961|  9.48k|    deflate_state *s;
  962|       |
  963|  9.48k|    if (deflateStateCheck(strm) || flush > Z_BLOCK || flush < 0)
  ------------------
  |  |  176|  18.9k|#define Z_BLOCK         5
  ------------------
  |  Branch (963:9): [True: 0, False: 9.48k]
  |  Branch (963:36): [True: 0, False: 9.48k]
  |  Branch (963:55): [True: 0, False: 9.48k]
  ------------------
  964|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  965|  9.48k|    s = strm->state;
  966|       |
  967|  9.48k|    if (strm->next_out == NULL || (strm->avail_in != 0 && strm->next_in == NULL)
  ------------------
  |  Branch (967:9): [True: 0, False: 9.48k]
  |  Branch (967:36): [True: 4.74k, False: 4.74k]
  |  Branch (967:59): [True: 0, False: 4.74k]
  ------------------
  968|  9.48k|        || (s->status == FINISH_STATE && flush != Z_FINISH)) {
  ------------------
  |  |   75|  18.9k|#define FINISH_STATE    3    /* stream complete */
  ------------------
                      || (s->status == FINISH_STATE && flush != Z_FINISH)) {
  ------------------
  |  |  175|      0|#define Z_FINISH        4
  ------------------
  |  Branch (968:13): [True: 0, False: 9.48k]
  |  Branch (968:42): [True: 0, False: 0]
  ------------------
  969|      0|        ERR_RETURN(strm, Z_STREAM_ERROR);
  ------------------
  |  |   29|      0|#define ERR_RETURN(strm, err) return (strm->msg = ERR_MSG(err), (err))
  |  |  ------------------
  |  |  |  |   27|      0|#define ERR_MSG(err) PREFIX(z_errmsg)[(err) < -6 || (err) > 2 ? 9 : 2 - (err)]
  |  |  |  |  ------------------
  |  |  |  |  |  |  121|      0|#  define PREFIX(x) zng_ ## x
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (27:39): [Folded, False: 0]
  |  |  |  |  |  Branch (27:53): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  970|      0|    }
  971|  9.48k|    if (strm->avail_out == 0) {
  ------------------
  |  Branch (971:9): [True: 0, False: 9.48k]
  ------------------
  972|      0|        ERR_RETURN(strm, Z_BUF_ERROR);
  ------------------
  |  |   29|      0|#define ERR_RETURN(strm, err) return (strm->msg = ERR_MSG(err), (err))
  |  |  ------------------
  |  |  |  |   27|      0|#define ERR_MSG(err) PREFIX(z_errmsg)[(err) < -6 || (err) > 2 ? 9 : 2 - (err)]
  |  |  |  |  ------------------
  |  |  |  |  |  |  121|      0|#  define PREFIX(x) zng_ ## x
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (27:39): [Folded, False: 0]
  |  |  |  |  |  Branch (27:53): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  973|      0|    }
  974|       |
  975|  9.48k|    old_flush = s->last_flush;
  976|  9.48k|    s->last_flush = flush;
  977|       |
  978|       |    /* Flush as much pending output as possible */
  979|  9.48k|    if (s->pending != 0) {
  ------------------
  |  Branch (979:9): [True: 0, False: 9.48k]
  ------------------
  980|      0|        flush_pending_inline(strm);
  981|      0|        if (strm->avail_out == 0) {
  ------------------
  |  Branch (981:13): [True: 0, False: 0]
  ------------------
  982|       |            /* Since avail_out is 0, deflate will be called again with
  983|       |             * more output space, but possibly with both pending and
  984|       |             * avail_in equal to zero. There won't be anything to do,
  985|       |             * but this is not an error situation so make sure we
  986|       |             * return OK instead of BUF_ERROR at next call of deflate:
  987|       |             */
  988|      0|            s->last_flush = -1;
  989|      0|            return Z_OK;
  ------------------
  |  |  180|      0|#define Z_OK            0
  ------------------
  990|      0|        }
  991|       |
  992|       |        /* Make sure there is something to do and avoid duplicate consecutive
  993|       |         * flushes. For repeated and useless calls with Z_FINISH, we keep
  994|       |         * returning Z_STREAM_END instead of Z_BUF_ERROR.
  995|       |         */
  996|  9.48k|    } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) && flush != Z_FINISH) {
  ------------------
  |  |  148|  4.74k|#define RANK(f) (((f) * 2) - ((f) > 4 ? 9 : 0))
  |  |  ------------------
  |  |  |  Branch (148:31): [True: 3.16k, False: 1.58k]
  |  |  ------------------
  ------------------
                  } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) && flush != Z_FINISH) {
  ------------------
  |  |  148|  14.2k|#define RANK(f) (((f) * 2) - ((f) > 4 ? 9 : 0))
  |  |  ------------------
  |  |  |  Branch (148:31): [True: 0, False: 4.74k]
  |  |  ------------------
  ------------------
                  } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) && flush != Z_FINISH) {
  ------------------
  |  |  175|      0|#define Z_FINISH        4
  ------------------
  |  Branch (996:16): [True: 4.74k, False: 4.74k]
  |  Branch (996:39): [True: 0, False: 4.74k]
  |  Branch (996:73): [True: 0, False: 0]
  ------------------
  997|      0|        ERR_RETURN(strm, Z_BUF_ERROR);
  ------------------
  |  |   29|      0|#define ERR_RETURN(strm, err) return (strm->msg = ERR_MSG(err), (err))
  |  |  ------------------
  |  |  |  |   27|      0|#define ERR_MSG(err) PREFIX(z_errmsg)[(err) < -6 || (err) > 2 ? 9 : 2 - (err)]
  |  |  |  |  ------------------
  |  |  |  |  |  |  121|      0|#  define PREFIX(x) zng_ ## x
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (27:39): [Folded, False: 0]
  |  |  |  |  |  Branch (27:53): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  998|      0|    }
  999|       |
 1000|       |    /* User must not provide more input after the first FINISH: */
 1001|  9.48k|    if (s->status == FINISH_STATE && strm->avail_in != 0)   {
  ------------------
  |  |   75|  18.9k|#define FINISH_STATE    3    /* stream complete */
  ------------------
  |  Branch (1001:9): [True: 0, False: 9.48k]
  |  Branch (1001:38): [True: 0, False: 0]
  ------------------
 1002|      0|        ERR_RETURN(strm, Z_BUF_ERROR);
  ------------------
  |  |   29|      0|#define ERR_RETURN(strm, err) return (strm->msg = ERR_MSG(err), (err))
  |  |  ------------------
  |  |  |  |   27|      0|#define ERR_MSG(err) PREFIX(z_errmsg)[(err) < -6 || (err) > 2 ? 9 : 2 - (err)]
  |  |  |  |  ------------------
  |  |  |  |  |  |  121|      0|#  define PREFIX(x) zng_ ## x
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (27:39): [Folded, False: 0]
  |  |  |  |  |  Branch (27:53): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1003|      0|    }
 1004|       |
 1005|       |    /* Skip headers if raw deflate stream was requested */
 1006|  9.48k|    if (s->status == INIT_STATE && s->wrap == 0) {
  ------------------
  |  |   66|  18.9k|#define INIT_STATE      1    /* zlib header -> BUSY_STATE */
  ------------------
  |  Branch (1006:9): [True: 1.58k, False: 7.90k]
  |  Branch (1006:36): [True: 0, False: 1.58k]
  ------------------
 1007|      0|        s->status = BUSY_STATE;
  ------------------
  |  |   74|      0|#define BUSY_STATE      2    /* deflate -> FINISH_STATE */
  ------------------
 1008|      0|    }
 1009|       |
 1010|  9.48k|    if (s->status != BUSY_STATE && s->status != FINISH_STATE && s->wrap != 0) {
  ------------------
  |  |   74|  18.9k|#define BUSY_STATE      2    /* deflate -> FINISH_STATE */
  ------------------
                  if (s->status != BUSY_STATE && s->status != FINISH_STATE && s->wrap != 0) {
  ------------------
  |  |   75|  11.0k|#define FINISH_STATE    3    /* stream complete */
  ------------------
  |  Branch (1010:9): [True: 1.58k, False: 7.90k]
  |  Branch (1010:36): [True: 1.58k, False: 0]
  |  Branch (1010:65): [True: 1.58k, False: 0]
  ------------------
 1011|       |        /* Write the header */
 1012|  1.58k|        if (deflateHeaders(s, strm) == Z_OK) {
  ------------------
  |  |  180|  1.58k|#define Z_OK            0
  ------------------
  |  Branch (1012:13): [True: 0, False: 1.58k]
  ------------------
 1013|      0|            return Z_OK;
  ------------------
  |  |  180|      0|#define Z_OK            0
  ------------------
 1014|      0|        }
 1015|  1.58k|    }
 1016|       |
 1017|       |    /* Start a new block or continue the current one. */
 1018|  9.48k|    if (strm->avail_in != 0 || s->lookahead != 0 || (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
  ------------------
  |  |  171|  3.16k|#define Z_NO_FLUSH      0
  ------------------
                  if (strm->avail_in != 0 || s->lookahead != 0 || (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
  ------------------
  |  |   75|  1.58k|#define FINISH_STATE    3    /* stream complete */
  ------------------
  |  Branch (1018:9): [True: 4.74k, False: 4.74k]
  |  Branch (1018:32): [True: 3.16k, False: 1.58k]
  |  Branch (1018:54): [True: 1.58k, False: 0]
  |  Branch (1018:77): [True: 1.58k, False: 0]
  ------------------
 1019|  9.48k|        block_state bstate;
 1020|       |
 1021|  9.48k|#ifndef _MSC_VER
 1022|  9.48k|        if (DEFLATE_HOOK(strm, flush, &bstate) == 0) /* hook for IBM Z DFLTCC */
  ------------------
  |  |  487|  9.48k|#  define DEFLATE_HOOK(strm, flush, bstate) 0
  ------------------
  |  Branch (1022:13): [True: 9.48k, Folded]
  ------------------
 1023|  9.48k|#endif
 1024|  9.48k|            bstate = s->level == 0 ? deflate_stored(s, flush) :
  ------------------
  |  Branch (1024:22): [True: 3.16k, False: 6.32k]
  ------------------
 1025|  9.48k|                 s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) :
  ------------------
  |  |  200|  6.32k|#define Z_HUFFMAN_ONLY        2
  ------------------
  |  Branch (1025:18): [True: 0, False: 6.32k]
  ------------------
 1026|  6.32k|                 s->strategy == Z_RLE ? deflate_rle(s, flush) :
  ------------------
  |  |  201|  6.32k|#define Z_RLE                 3
  ------------------
  |  Branch (1026:18): [True: 0, False: 6.32k]
  ------------------
 1027|  6.32k|                 (*(configuration_table[s->level].func))(s, flush);
 1028|       |
 1029|  9.48k|        if (bstate == finish_started || bstate == finish_done) {
  ------------------
  |  Branch (1029:13): [True: 0, False: 9.48k]
  |  Branch (1029:41): [True: 1.58k, False: 7.90k]
  ------------------
 1030|  1.58k|            s->status = FINISH_STATE;
  ------------------
  |  |   75|  1.58k|#define FINISH_STATE    3    /* stream complete */
  ------------------
 1031|  1.58k|        }
 1032|  9.48k|        if (bstate == need_more || bstate == finish_started) {
  ------------------
  |  Branch (1032:13): [True: 4.74k, False: 4.74k]
  |  Branch (1032:36): [True: 0, False: 4.74k]
  ------------------
 1033|  4.74k|            if (strm->avail_out == 0) {
  ------------------
  |  Branch (1033:17): [True: 0, False: 4.74k]
  ------------------
 1034|      0|                s->last_flush = -1; /* avoid BUF_ERROR next call, see above */
 1035|      0|            }
 1036|  4.74k|            return Z_OK;
  ------------------
  |  |  180|  4.74k|#define Z_OK            0
  ------------------
 1037|       |            /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
 1038|       |             * of deflate should use the same flush parameter to make sure
 1039|       |             * that the flush is complete. So we don't have to output an
 1040|       |             * empty block here, this will be done at next call. This also
 1041|       |             * ensures that for a very small output buffer, we emit at most
 1042|       |             * one empty block.
 1043|       |             */
 1044|  4.74k|        }
 1045|  4.74k|        if (bstate == block_done) {
  ------------------
  |  Branch (1045:13): [True: 3.16k, False: 1.58k]
  ------------------
 1046|  3.16k|            if (flush == Z_PARTIAL_FLUSH) {
  ------------------
  |  |  172|  3.16k|#define Z_PARTIAL_FLUSH 1
  ------------------
  |  Branch (1046:17): [True: 0, False: 3.16k]
  ------------------
 1047|      0|                zng_tr_align(s);
 1048|  3.16k|            } else if (flush != Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */
  ------------------
  |  |  176|  3.16k|#define Z_BLOCK         5
  ------------------
  |  Branch (1048:24): [True: 0, False: 3.16k]
  ------------------
 1049|      0|                zng_tr_stored_block(s, NULL, 0L, 0);
 1050|       |                /* For a full flush, this empty block will be recognized
 1051|       |                 * as a special marker by inflate_sync().
 1052|       |                 */
 1053|      0|                if (flush == Z_FULL_FLUSH) {
  ------------------
  |  |  174|      0|#define Z_FULL_FLUSH    3
  ------------------
  |  Branch (1053:21): [True: 0, False: 0]
  ------------------
 1054|      0|                    CLEAR_HASH(s);             /* forget history */
  ------------------
  |  |  154|      0|#define CLEAR_HASH(s) do { \
  |  |  155|      0|    memset((unsigned char *)s->head, 0, HASH_SIZE * sizeof(*s->head)); \
  |  |  ------------------
  |  |  |  |   84|      0|#  define HASH_SIZE 65536u         /* number of elements in hash table */
  |  |  ------------------
  |  |  156|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (156:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1055|      0|                    if (s->lookahead == 0) {
  ------------------
  |  Branch (1055:25): [True: 0, False: 0]
  ------------------
 1056|      0|                        s->strstart = 0;
 1057|      0|                        s->block_start = 0;
 1058|      0|                        s->insert = 0;
 1059|      0|                    }
 1060|      0|                }
 1061|      0|            }
 1062|  3.16k|            PREFIX(flush_pending)(strm);
  ------------------
  |  |  121|  3.16k|#  define PREFIX(x) zng_ ## x
  ------------------
 1063|  3.16k|            if (strm->avail_out == 0) {
  ------------------
  |  Branch (1063:17): [True: 0, False: 3.16k]
  ------------------
 1064|      0|                s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
 1065|      0|                return Z_OK;
  ------------------
  |  |  180|      0|#define Z_OK            0
  ------------------
 1066|      0|            }
 1067|  3.16k|        }
 1068|  4.74k|    }
 1069|       |
 1070|  4.74k|    if (flush != Z_FINISH)
  ------------------
  |  |  175|  4.74k|#define Z_FINISH        4
  ------------------
  |  Branch (1070:9): [True: 3.16k, False: 1.58k]
  ------------------
 1071|  3.16k|        return Z_OK;
  ------------------
  |  |  180|  3.16k|#define Z_OK            0
  ------------------
 1072|       |
 1073|       |    /* Write the trailer */
 1074|  1.58k|#ifdef GZIP
 1075|  1.58k|    if (s->wrap == 2) {
  ------------------
  |  Branch (1075:9): [True: 0, False: 1.58k]
  ------------------
 1076|      0|        put_uint32(s, strm->adler);
 1077|      0|        put_uint32(s, (uint32_t)strm->total_in);
 1078|      0|    } else
 1079|  1.58k|#endif
 1080|  1.58k|    {
 1081|  1.58k|        if (s->wrap == 1)
  ------------------
  |  Branch (1081:13): [True: 1.58k, False: 0]
  ------------------
 1082|  1.58k|            put_uint32_msb(s, strm->adler);
 1083|  1.58k|    }
 1084|  1.58k|    flush_pending_inline(strm);
 1085|       |    /* If avail_out is zero, the application will call deflate again
 1086|       |     * to flush the rest.
 1087|       |     */
 1088|  1.58k|    if (s->wrap > 0)
  ------------------
  |  Branch (1088:9): [True: 1.58k, False: 0]
  ------------------
 1089|  1.58k|        s->wrap = -s->wrap; /* write the trailer only once! */
 1090|  1.58k|    if (s->pending == 0) {
  ------------------
  |  Branch (1090:9): [True: 1.58k, False: 0]
  ------------------
 1091|  1.58k|        Assert(s->bi_valid == 0, "bi_buf not flushed");
 1092|  1.58k|        return Z_STREAM_END;
  ------------------
  |  |  181|  1.58k|#define Z_STREAM_END    1
  ------------------
 1093|  1.58k|    }
 1094|      0|    return Z_OK;
  ------------------
  |  |  180|      0|#define Z_OK            0
  ------------------
 1095|  1.58k|}
zng_deflateEnd:
 1098|  1.58k|int32_t Z_EXPORT PREFIX(deflateEnd)(PREFIX3(stream) *strm) {
 1099|  1.58k|    if (deflateStateCheck(strm))
  ------------------
  |  Branch (1099:9): [True: 0, False: 1.58k]
  ------------------
 1100|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
 1101|       |
 1102|  1.58k|    int32_t status = strm->state->status;
 1103|       |
 1104|       |    /* Free allocated buffers */
 1105|  1.58k|    free_deflate(strm);
 1106|       |
 1107|  1.58k|    return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
  ------------------
  |  |   74|  1.58k|#define BUSY_STATE      2    /* deflate -> FINISH_STATE */
  ------------------
                  return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
  ------------------
  |  |  185|      0|#define Z_DATA_ERROR   (-3)
  ------------------
                  return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
  ------------------
  |  |  180|  1.58k|#define Z_OK            0
  ------------------
  |  Branch (1107:12): [True: 0, False: 1.58k]
  ------------------
 1108|  1.58k|}
zng_fill_window:
 1209|  29.3k|void Z_INTERNAL PREFIX(fill_window)(deflate_state *s) {
 1210|  29.3k|    PREFIX3(stream) *strm = s->strm;
  ------------------
  |  |  123|  29.3k|#  define PREFIX3(x) zng_ ## x
  ------------------
 1211|  29.3k|    insert_batch_func insert_batch;
 1212|  29.3k|    unsigned char *window = s->window;
 1213|  29.3k|    unsigned n;
 1214|  29.3k|    unsigned int more;    /* Amount of free space at the end of the window. */
 1215|  29.3k|    unsigned int wsize = s->w_size;
 1216|  29.3k|    int level = s->level;
 1217|       |
 1218|  29.3k|    Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
 1219|       |
 1220|  29.3k|    if (level >= 9)
  ------------------
  |  Branch (1220:9): [True: 29.3k, False: 0]
  ------------------
 1221|  29.3k|        insert_batch = insert_roll_batch;
 1222|      0|    else if (HAVE_QUICK_STRATEGY && level == 1)
  ------------------
  |  |  144|      0|#  define HAVE_QUICK_STRATEGY 1
  |  |  ------------------
  |  |  |  Branch (144:31): [True: 0, Folded]
  |  |  ------------------
  ------------------
  |  Branch (1222:37): [True: 0, False: 0]
  ------------------
 1223|      0|        insert_batch = insert_knuth_batch_head;
 1224|      0|    else
 1225|      0|        insert_batch = insert_knuth_batch;
 1226|       |
 1227|  29.3k|    do {
 1228|  29.3k|        more = s->window_size - s->lookahead - s->strstart;
 1229|       |
 1230|       |        /* If the window is almost full and there is insufficient lookahead,
 1231|       |         * move the upper half to the lower one to make room in the upper half.
 1232|       |         */
 1233|  29.3k|        if (s->strstart >= wsize+MAX_DIST(s)) {
  ------------------
  |  |  409|  29.3k|#define MAX_DIST(s)  ((s)->w_size - MIN_LOOKAHEAD)
  |  |  ------------------
  |  |  |  |  404|  29.3k|#define MIN_LOOKAHEAD (STD_MAX_MATCH + STD_MIN_MATCH + 1)
  |  |  |  |  ------------------
  |  |  |  |  |  |   62|  29.3k|#define STD_MAX_MATCH  258
  |  |  |  |  ------------------
  |  |  |  |               #define MIN_LOOKAHEAD (STD_MAX_MATCH + STD_MIN_MATCH + 1)
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|  29.3k|#define STD_MIN_MATCH  3
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1233:13): [True: 13.0k, False: 16.3k]
  ------------------
 1234|  13.0k|            memcpy(window, window + wsize, (unsigned)wsize);
 1235|  13.0k|            if (s->match_start >= wsize) {
  ------------------
  |  Branch (1235:17): [True: 13.0k, False: 0]
  ------------------
 1236|  13.0k|                s->match_start -= wsize;
 1237|  13.0k|            } else {
 1238|      0|                s->match_start = 0;
 1239|      0|                s->prev_length = 0;
 1240|      0|            }
 1241|  13.0k|            s->strstart    -= wsize; /* we now have strstart >= MAX_DIST */
 1242|  13.0k|            s->block_start -= (int)wsize;
 1243|  13.0k|            if (s->insert > s->strstart)
  ------------------
  |  Branch (1243:17): [True: 14, False: 13.0k]
  ------------------
 1244|     14|                s->insert = s->strstart;
 1245|  13.0k|            if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) {
  ------------------
  |  |  200|  26.0k|#define Z_HUFFMAN_ONLY        2
  ------------------
                          if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) {
  ------------------
  |  |  201|  13.0k|#define Z_RLE                 3
  ------------------
  |  Branch (1245:17): [True: 13.0k, False: 0]
  |  Branch (1245:50): [True: 13.0k, False: 0]
  ------------------
 1246|       |                /* Z_HUFFMAN_ONLY and Z_RLE never read the hash chain. deflate_quick
 1247|       |                 * reads the chain head but never walks prev, so it slides head only. */
 1248|  13.0k|                if (HAVE_QUICK_STRATEGY && level == 1)
  ------------------
  |  |  144|  26.0k|#  define HAVE_QUICK_STRATEGY 1
  |  |  ------------------
  |  |  |  Branch (144:31): [True: 13.0k, Folded]
  |  |  ------------------
  ------------------
  |  Branch (1248:44): [True: 0, False: 13.0k]
  ------------------
 1249|      0|                    FUNCTABLE_CALL(slide_hash_head)(s);
  ------------------
  |  |   46|      0|#  define FUNCTABLE_CALL(name) functable.name
  ------------------
 1250|  13.0k|                else
 1251|  13.0k|                    FUNCTABLE_CALL(slide_hash)(s);
  ------------------
  |  |   46|  13.0k|#  define FUNCTABLE_CALL(name) functable.name
  ------------------
 1252|  13.0k|            }
 1253|  13.0k|            more += wsize;
 1254|  13.0k|        }
 1255|  29.3k|        if (strm->avail_in == 0)
  ------------------
  |  Branch (1255:13): [True: 13.2k, False: 16.0k]
  ------------------
 1256|  13.2k|            break;
 1257|       |
 1258|       |        /* If there was no sliding:
 1259|       |         *    strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
 1260|       |         *    more == window_size - lookahead - strstart
 1261|       |         * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
 1262|       |         * => more >= window_size - 2*WSIZE + 2
 1263|       |         * In the BIG_MEM or MMAP case (not yet supported),
 1264|       |         *   window_size == input_size + MIN_LOOKAHEAD  &&
 1265|       |         *   strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
 1266|       |         * Otherwise, window_size == 2*WSIZE so more >= 2.
 1267|       |         * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
 1268|       |         */
 1269|  16.0k|        Assert(more >= 2, "more < 2");
 1270|       |
 1271|  16.0k|        n = read_buf(strm, window + s->strstart + s->lookahead, more);
 1272|  16.0k|        s->lookahead += n;
 1273|       |
 1274|       |        /* Initialize the hash value now that we have some input: */
 1275|  16.0k|        if (s->lookahead + s->insert >= STD_MIN_MATCH) {
  ------------------
  |  |   61|  16.0k|#define STD_MIN_MATCH  3
  ------------------
  |  Branch (1275:13): [True: 16.0k, False: 0]
  ------------------
 1276|  16.0k|            unsigned int str = s->strstart - s->insert;
 1277|  16.0k|            if (UNLIKELY(level >= 9)) {
  ------------------
  |  |  258|  16.0k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 16.0k, False: 0]
  |  |  ------------------
  ------------------
 1278|  16.0k|                s->ins_h = update_hash_roll(window[str], window[str+1]);
 1279|  16.0k|            } else if (str >= 1) {
  ------------------
  |  Branch (1279:24): [True: 0, False: 0]
  ------------------
 1280|      0|                if (HAVE_QUICK_STRATEGY && level == 1)
  ------------------
  |  |  144|      0|#  define HAVE_QUICK_STRATEGY 1
  |  |  ------------------
  |  |  |  Branch (144:31): [True: 0, Folded]
  |  |  ------------------
  ------------------
  |  Branch (1280:44): [True: 0, False: 0]
  ------------------
 1281|      0|                    insert_knuth_head(s, window, str + 2 - STD_MIN_MATCH);
  ------------------
  |  |   61|      0|#define STD_MIN_MATCH  3
  ------------------
 1282|      0|                else
 1283|      0|                    insert_knuth(s, window, str + 2 - STD_MIN_MATCH);
  ------------------
  |  |   61|      0|#define STD_MIN_MATCH  3
  ------------------
 1284|      0|            }
 1285|  16.0k|            unsigned int count = s->insert;
 1286|  16.0k|            if (UNLIKELY(s->lookahead == 1)) {
  ------------------
  |  |  258|  16.0k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 16.0k]
  |  |  ------------------
  ------------------
 1287|      0|                count -= 1;
 1288|      0|            }
 1289|  16.0k|            if (count > 0) {
  ------------------
  |  Branch (1289:17): [True: 1.58k, False: 14.4k]
  ------------------
 1290|  1.58k|                insert_batch(s, window, str, count);
 1291|  1.58k|                s->insert -= count;
 1292|  1.58k|            }
 1293|  16.0k|        }
 1294|       |        /* If the whole input has less than STD_MIN_MATCH bytes, ins_h is garbage,
 1295|       |         * but this is not important since only literal bytes will be emitted.
 1296|       |         */
 1297|  16.0k|    } while (s->lookahead < MIN_LOOKAHEAD && strm->avail_in != 0);
  ------------------
  |  |  404|  32.1k|#define MIN_LOOKAHEAD (STD_MAX_MATCH + STD_MIN_MATCH + 1)
  |  |  ------------------
  |  |  |  |   62|  16.0k|#define STD_MAX_MATCH  258
  |  |  ------------------
  |  |               #define MIN_LOOKAHEAD (STD_MAX_MATCH + STD_MIN_MATCH + 1)
  |  |  ------------------
  |  |  |  |   61|  16.0k|#define STD_MIN_MATCH  3
  |  |  ------------------
  ------------------
  |  Branch (1297:14): [True: 165, False: 15.8k]
  |  Branch (1297:46): [True: 0, False: 165]
  ------------------
 1298|       |
 1299|       |    /* If the WIN_INIT bytes after the end of the current data have never been
 1300|       |     * written, then zero those bytes in order to avoid memory check reports of
 1301|       |     * the use of uninitialized (or uninitialised as Julian writes) bytes by
 1302|       |     * the longest match routines.  Update the high water mark for the next
 1303|       |     * time through here.  WIN_INIT is set to STD_MAX_MATCH since the longest match
 1304|       |     * routines allow scanning to strstart + STD_MAX_MATCH, ignoring lookahead.
 1305|       |     */
 1306|  29.3k|    if (s->high_water < s->window_size) {
  ------------------
  |  Branch (1306:9): [True: 10.6k, False: 18.6k]
  ------------------
 1307|  10.6k|        unsigned int curr = s->strstart + s->lookahead;
 1308|  10.6k|        unsigned int init;
 1309|       |
 1310|  10.6k|        if (s->high_water < curr) {
  ------------------
  |  Branch (1310:13): [True: 2.62k, False: 8.03k]
  ------------------
 1311|       |            /* Previous high water mark below current data -- zero WIN_INIT
 1312|       |             * bytes or up to end of window, whichever is less.
 1313|       |             */
 1314|  2.62k|            init = s->window_size - curr;
 1315|  2.62k|            if (init > WIN_INIT)
  ------------------
  |  |  420|  2.62k|#define WIN_INIT STD_MAX_MATCH
  |  |  ------------------
  |  |  |  |   62|  2.62k|#define STD_MAX_MATCH  258
  |  |  ------------------
  ------------------
  |  Branch (1315:17): [True: 1.86k, False: 767]
  ------------------
 1316|  1.86k|                init = WIN_INIT;
  ------------------
  |  |  420|  1.86k|#define WIN_INIT STD_MAX_MATCH
  |  |  ------------------
  |  |  |  |   62|  1.86k|#define STD_MAX_MATCH  258
  |  |  ------------------
  ------------------
 1317|  2.62k|            memset(window + curr, 0, init);
 1318|  2.62k|            s->high_water = curr + init;
 1319|  8.03k|        } else if (s->high_water < curr + WIN_INIT) {
  ------------------
  |  |  420|  8.03k|#define WIN_INIT STD_MAX_MATCH
  |  |  ------------------
  |  |  |  |   62|  8.03k|#define STD_MAX_MATCH  258
  |  |  ------------------
  ------------------
  |  Branch (1319:20): [True: 43, False: 7.98k]
  ------------------
 1320|       |            /* High water mark at or above current data, but below current data
 1321|       |             * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
 1322|       |             * to end of window, whichever is less.
 1323|       |             */
 1324|     43|            init = curr + WIN_INIT - s->high_water;
  ------------------
  |  |  420|     43|#define WIN_INIT STD_MAX_MATCH
  |  |  ------------------
  |  |  |  |   62|     43|#define STD_MAX_MATCH  258
  |  |  ------------------
  ------------------
 1325|     43|            if (init > s->window_size - s->high_water)
  ------------------
  |  Branch (1325:17): [True: 0, False: 43]
  ------------------
 1326|      0|                init = s->window_size - s->high_water;
 1327|     43|            memset(window + s->high_water, 0, init);
 1328|     43|            s->high_water += init;
 1329|     43|        }
 1330|  10.6k|    }
 1331|       |
 1332|  29.3k|    Assert((unsigned long)s->strstart <= s->window_size - MIN_LOOKAHEAD,
 1333|  29.3k|           "not enough room for search");
 1334|  29.3k|}
deflate.c:deflateStateCheck:
  408|  15.8k|static int deflateStateCheck(PREFIX3(stream) *strm) {
  409|  15.8k|    deflate_state *s;
  410|  15.8k|    if (strm == NULL || strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
  ------------------
  |  Branch (410:9): [True: 0, False: 15.8k]
  |  Branch (410:25): [True: 0, False: 15.8k]
  |  Branch (410:58): [True: 0, False: 15.8k]
  ------------------
  411|      0|        return 1;
  412|  15.8k|    s = strm->state;
  413|  15.8k|    if (s == NULL || s->alloc_bufs == NULL || s->strm != strm || (s->status < INIT_STATE || s->status > MAX_STATE))
  ------------------
  |  |   66|  31.6k|#define INIT_STATE      1    /* zlib header -> BUSY_STATE */
  ------------------
                  if (s == NULL || s->alloc_bufs == NULL || s->strm != strm || (s->status < INIT_STATE || s->status > MAX_STATE))
  ------------------
  |  |   77|  15.8k|#  define MAX_STATE     HCRC_STATE
  |  |  ------------------
  |  |  |  |   72|  15.8k|#  define HCRC_STATE    8    /* gzip header CRC -> BUSY_STATE */
  |  |  ------------------
  ------------------
  |  Branch (413:9): [True: 0, False: 15.8k]
  |  Branch (413:22): [True: 0, False: 15.8k]
  |  Branch (413:47): [True: 0, False: 15.8k]
  |  Branch (413:67): [True: 0, False: 15.8k]
  |  Branch (413:93): [True: 0, False: 15.8k]
  ------------------
  414|      0|        return 1;
  415|  15.8k|    return 0;
  416|  15.8k|}
deflate.c:deflateHeaders:
  789|  1.58k|static int deflateHeaders(deflate_state *s, PREFIX3(stream) *strm) {
  790|  1.58k|    if (s->status == INIT_STATE) {
  ------------------
  |  |   66|  1.58k|#define INIT_STATE      1    /* zlib header -> BUSY_STATE */
  ------------------
  |  Branch (790:9): [True: 1.58k, False: 0]
  ------------------
  791|       |        /* zlib header */
  792|  1.58k|        unsigned int header = (Z_DEFLATED + ((W_BITS(s)-8)<<4)) << 8;
  ------------------
  |  |  212|  1.58k|#define Z_DEFLATED   8
  ------------------
                      unsigned int header = (Z_DEFLATED + ((W_BITS(s)-8)<<4)) << 8;
  ------------------
  |  |  417|  1.58k|#define W_BITS(s)  zng_ctz32((s)->w_size)
  ------------------
  793|  1.58k|        unsigned int level_flags;
  794|       |
  795|  1.58k|        if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
  ------------------
  |  |  200|  3.16k|#define Z_HUFFMAN_ONLY        2
  ------------------
  |  Branch (795:13): [True: 0, False: 1.58k]
  |  Branch (795:46): [True: 0, False: 1.58k]
  ------------------
  796|      0|            level_flags = 0;
  797|  1.58k|        else if (s->level < 6)
  ------------------
  |  Branch (797:18): [True: 0, False: 1.58k]
  ------------------
  798|      0|            level_flags = 1;
  799|  1.58k|        else if (s->level == 6)
  ------------------
  |  Branch (799:18): [True: 0, False: 1.58k]
  ------------------
  800|      0|            level_flags = 2;
  801|  1.58k|        else
  802|  1.58k|            level_flags = 3;
  803|  1.58k|        header |= (level_flags << 6);
  804|  1.58k|        if (s->strstart != 0)
  ------------------
  |  Branch (804:13): [True: 0, False: 1.58k]
  ------------------
  805|      0|            header |= PRESET_DICT;
  ------------------
  |  |   68|      0|#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
  ------------------
  806|  1.58k|        header += 31 - (header % 31);
  807|       |
  808|  1.58k|        put_short_msb(s, (uint16_t)header);
  809|       |
  810|       |        /* Save the adler32 of the preset dictionary: */
  811|  1.58k|        if (s->strstart != 0)
  ------------------
  |  Branch (811:13): [True: 0, False: 1.58k]
  ------------------
  812|      0|            put_uint32_msb(s, strm->adler);
  813|  1.58k|        strm->adler = ADLER32_INITIAL_VALUE;
  ------------------
  |  |   70|  1.58k|#define ADLER32_INITIAL_VALUE 1 /* initial adler-32 hash value */
  ------------------
  814|  1.58k|        s->status = BUSY_STATE;
  ------------------
  |  |   74|  1.58k|#define BUSY_STATE      2    /* deflate -> FINISH_STATE */
  ------------------
  815|       |
  816|       |        /* Compression must start with an empty pending buffer */
  817|  1.58k|        PREFIX(flush_pending)(strm);
  ------------------
  |  |  121|  1.58k|#  define PREFIX(x) zng_ ## x
  ------------------
  818|  1.58k|        if (s->pending != 0) {
  ------------------
  |  Branch (818:13): [True: 0, False: 1.58k]
  ------------------
  819|      0|            s->last_flush = -1;
  820|      0|            return Z_OK;
  ------------------
  |  |  180|      0|#define Z_OK            0
  ------------------
  821|      0|        }
  822|  1.58k|    }
  823|  1.58k|#ifdef GZIP
  824|  1.58k|    if (s->status == GZIP_STATE) {
  ------------------
  |  |   68|  1.58k|#  define GZIP_STATE    4    /* gzip header -> BUSY_STATE | EXTRA_STATE */
  ------------------
  |  Branch (824:9): [True: 0, False: 1.58k]
  ------------------
  825|       |        /* gzip header */
  826|      0|        strm->adler = CRC32_INITIAL_VALUE;
  ------------------
  |  |   71|      0|#define CRC32_INITIAL_VALUE   0 /* initial crc-32 hash value */
  ------------------
  827|      0|        put_byte(s, 31);
  ------------------
  |  |  350|      0|#define put_byte(s, c) { \
  |  |  351|      0|    s->pending_buf[s->pending++] = (unsigned char)(c); \
  |  |  352|      0|}
  ------------------
  828|      0|        put_byte(s, 139);
  ------------------
  |  |  350|      0|#define put_byte(s, c) { \
  |  |  351|      0|    s->pending_buf[s->pending++] = (unsigned char)(c); \
  |  |  352|      0|}
  ------------------
  829|      0|        put_byte(s, 8);
  ------------------
  |  |  350|      0|#define put_byte(s, c) { \
  |  |  351|      0|    s->pending_buf[s->pending++] = (unsigned char)(c); \
  |  |  352|      0|}
  ------------------
  830|      0|        if (s->gzhead == NULL) {
  ------------------
  |  Branch (830:13): [True: 0, False: 0]
  ------------------
  831|      0|            put_uint32(s, 0);
  832|      0|            put_byte(s, 0);
  ------------------
  |  |  350|      0|#define put_byte(s, c) { \
  |  |  351|      0|    s->pending_buf[s->pending++] = (unsigned char)(c); \
  |  |  352|      0|}
  ------------------
  833|      0|            put_byte(s, s->level == 9 ? 2 :
  ------------------
  |  |  350|      0|#define put_byte(s, c) { \
  |  |  351|      0|    s->pending_buf[s->pending++] = (unsigned char)(c); \
  |  |  ------------------
  |  |  |  Branch (351:52): [True: 0, False: 0]
  |  |  |  Branch (351:52): [True: 0, False: 0]
  |  |  |  Branch (351:52): [True: 0, False: 0]
  |  |  ------------------
  |  |  352|      0|}
  ------------------
  834|      0|                     (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? 4 : 0));
  835|      0|            put_byte(s, OS_CODE);
  ------------------
  |  |  350|      0|#define put_byte(s, c) { \
  |  |  351|      0|    s->pending_buf[s->pending++] = (unsigned char)(c); \
  |  |  352|      0|}
  ------------------
  836|      0|            s->status = BUSY_STATE;
  ------------------
  |  |   74|      0|#define BUSY_STATE      2    /* deflate -> FINISH_STATE */
  ------------------
  837|       |
  838|       |            /* Compression must start with an empty pending buffer */
  839|      0|            PREFIX(flush_pending)(strm);
  ------------------
  |  |  121|      0|#  define PREFIX(x) zng_ ## x
  ------------------
  840|      0|            if (s->pending != 0) {
  ------------------
  |  Branch (840:17): [True: 0, False: 0]
  ------------------
  841|      0|                s->last_flush = -1;
  842|      0|                return Z_OK;
  ------------------
  |  |  180|      0|#define Z_OK            0
  ------------------
  843|      0|            }
  844|      0|        } else {
  845|      0|            put_byte(s, (s->gzhead->text ? 1 : 0) +
  ------------------
  |  |  350|      0|#define put_byte(s, c) { \
  |  |  351|      0|    s->pending_buf[s->pending++] = (unsigned char)(c); \
  |  |  ------------------
  |  |  |  Branch (351:52): [True: 0, False: 0]
  |  |  |  Branch (351:52): [True: 0, False: 0]
  |  |  |  Branch (351:52): [True: 0, False: 0]
  |  |  |  Branch (351:52): [True: 0, False: 0]
  |  |  |  Branch (351:52): [True: 0, False: 0]
  |  |  ------------------
  |  |  352|      0|}
  ------------------
  846|      0|                     (s->gzhead->hcrc ? 2 : 0) +
  847|      0|                     (s->gzhead->extra == NULL ? 0 : 4) +
  848|      0|                     (s->gzhead->name == NULL ? 0 : 8) +
  849|      0|                     (s->gzhead->comment == NULL ? 0 : 16)
  850|      0|                     );
  851|      0|            put_uint32(s, s->gzhead->time);
  852|      0|            put_byte(s, s->level == 9 ? 2 : (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? 4 : 0));
  ------------------
  |  |  350|      0|#define put_byte(s, c) { \
  |  |  351|      0|    s->pending_buf[s->pending++] = (unsigned char)(c); \
  |  |  ------------------
  |  |  |  Branch (351:52): [True: 0, False: 0]
  |  |  |  Branch (351:52): [True: 0, False: 0]
  |  |  |  Branch (351:52): [True: 0, False: 0]
  |  |  ------------------
  |  |  352|      0|}
  ------------------
  853|      0|            put_byte(s, s->gzhead->os & 0xff);
  ------------------
  |  |  350|      0|#define put_byte(s, c) { \
  |  |  351|      0|    s->pending_buf[s->pending++] = (unsigned char)(c); \
  |  |  352|      0|}
  ------------------
  854|      0|            if (s->gzhead->extra != NULL)
  ------------------
  |  Branch (854:17): [True: 0, False: 0]
  ------------------
  855|      0|                put_short(s, (uint16_t)s->gzhead->extra_len);
  856|      0|            if (s->gzhead->hcrc)
  ------------------
  |  Branch (856:17): [True: 0, False: 0]
  ------------------
  857|      0|                strm->adler = crc32_small((uint32_t)strm->adler, s->pending_buf, s->pending);
  858|      0|            s->gzindex = 0;
  859|      0|            s->status = EXTRA_STATE;
  ------------------
  |  |   69|      0|#  define EXTRA_STATE   5    /* gzip extra block -> NAME_STATE */
  ------------------
  860|      0|        }
  861|      0|    }
  862|  1.58k|    if (s->status == EXTRA_STATE) {
  ------------------
  |  |   69|  1.58k|#  define EXTRA_STATE   5    /* gzip extra block -> NAME_STATE */
  ------------------
  |  Branch (862:9): [True: 0, False: 1.58k]
  ------------------
  863|      0|        if (s->gzhead->extra != NULL) {
  ------------------
  |  Branch (863:13): [True: 0, False: 0]
  ------------------
  864|      0|            uint32_t beg = s->pending;   /* start of bytes to update crc */
  865|      0|            uint32_t left = (s->gzhead->extra_len & 0xffff) - s->gzindex;
  866|       |
  867|      0|            while (s->pending + left > s->pending_buf_size) {
  ------------------
  |  Branch (867:20): [True: 0, False: 0]
  ------------------
  868|      0|                uint32_t copy = s->pending_buf_size - s->pending;
  869|      0|                memcpy(s->pending_buf + s->pending, s->gzhead->extra + s->gzindex, copy);
  870|      0|                s->pending = s->pending_buf_size;
  871|      0|                HCRC_UPDATE(beg);
  ------------------
  |  |  781|      0|    do { \
  |  |  782|      0|        if (s->gzhead->hcrc && s->pending > (beg)) \
  |  |  ------------------
  |  |  |  Branch (782:13): [True: 0, False: 0]
  |  |  |  Branch (782:32): [True: 0, False: 0]
  |  |  ------------------
  |  |  783|      0|            strm->adler = crc32_small((uint32_t)strm->adler, s->pending_buf + (beg), s->pending - (beg)); \
  |  |  784|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (784:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  872|      0|                s->gzindex += copy;
  873|      0|                PREFIX(flush_pending)(strm);
  ------------------
  |  |  121|      0|#  define PREFIX(x) zng_ ## x
  ------------------
  874|      0|                if (s->pending != 0) {
  ------------------
  |  Branch (874:21): [True: 0, False: 0]
  ------------------
  875|      0|                    s->last_flush = -1;
  876|      0|                    return Z_OK;
  ------------------
  |  |  180|      0|#define Z_OK            0
  ------------------
  877|      0|                }
  878|      0|                beg = 0;
  879|      0|                left -= copy;
  880|      0|            }
  881|      0|            memcpy(s->pending_buf + s->pending, s->gzhead->extra + s->gzindex, left);
  882|      0|            s->pending += left;
  883|      0|            HCRC_UPDATE(beg);
  ------------------
  |  |  781|      0|    do { \
  |  |  782|      0|        if (s->gzhead->hcrc && s->pending > (beg)) \
  |  |  ------------------
  |  |  |  Branch (782:13): [True: 0, False: 0]
  |  |  |  Branch (782:32): [True: 0, False: 0]
  |  |  ------------------
  |  |  783|      0|            strm->adler = crc32_small((uint32_t)strm->adler, s->pending_buf + (beg), s->pending - (beg)); \
  |  |  784|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (784:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  884|      0|            s->gzindex = 0;
  885|      0|        }
  886|      0|        s->status = NAME_STATE;
  ------------------
  |  |   70|      0|#  define NAME_STATE    6    /* gzip file name -> COMMENT_STATE */
  ------------------
  887|      0|    }
  888|  1.58k|    if (s->status == NAME_STATE) {
  ------------------
  |  |   70|  1.58k|#  define NAME_STATE    6    /* gzip file name -> COMMENT_STATE */
  ------------------
  |  Branch (888:9): [True: 0, False: 1.58k]
  ------------------
  889|      0|        if (s->gzhead->name != NULL) {
  ------------------
  |  Branch (889:13): [True: 0, False: 0]
  ------------------
  890|      0|            uint32_t beg = s->pending;   /* start of bytes to update crc */
  891|      0|            unsigned char val;
  892|       |
  893|      0|            do {
  894|      0|                if (s->pending == s->pending_buf_size) {
  ------------------
  |  Branch (894:21): [True: 0, False: 0]
  ------------------
  895|      0|                    HCRC_UPDATE(beg);
  ------------------
  |  |  781|      0|    do { \
  |  |  782|      0|        if (s->gzhead->hcrc && s->pending > (beg)) \
  |  |  ------------------
  |  |  |  Branch (782:13): [True: 0, False: 0]
  |  |  |  Branch (782:32): [True: 0, False: 0]
  |  |  ------------------
  |  |  783|      0|            strm->adler = crc32_small((uint32_t)strm->adler, s->pending_buf + (beg), s->pending - (beg)); \
  |  |  784|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (784:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  896|      0|                    PREFIX(flush_pending)(strm);
  ------------------
  |  |  121|      0|#  define PREFIX(x) zng_ ## x
  ------------------
  897|      0|                    if (s->pending != 0) {
  ------------------
  |  Branch (897:25): [True: 0, False: 0]
  ------------------
  898|      0|                        s->last_flush = -1;
  899|      0|                        return Z_OK;
  ------------------
  |  |  180|      0|#define Z_OK            0
  ------------------
  900|      0|                    }
  901|      0|                    beg = 0;
  902|      0|                }
  903|      0|                val = s->gzhead->name[s->gzindex++];
  904|      0|                put_byte(s, val);
  ------------------
  |  |  350|      0|#define put_byte(s, c) { \
  |  |  351|      0|    s->pending_buf[s->pending++] = (unsigned char)(c); \
  |  |  352|      0|}
  ------------------
  905|      0|            } while (val != 0);
  ------------------
  |  Branch (905:22): [True: 0, False: 0]
  ------------------
  906|      0|            HCRC_UPDATE(beg);
  ------------------
  |  |  781|      0|    do { \
  |  |  782|      0|        if (s->gzhead->hcrc && s->pending > (beg)) \
  |  |  ------------------
  |  |  |  Branch (782:13): [True: 0, False: 0]
  |  |  |  Branch (782:32): [True: 0, False: 0]
  |  |  ------------------
  |  |  783|      0|            strm->adler = crc32_small((uint32_t)strm->adler, s->pending_buf + (beg), s->pending - (beg)); \
  |  |  784|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (784:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  907|      0|            s->gzindex = 0;
  908|      0|        }
  909|      0|        s->status = COMMENT_STATE;
  ------------------
  |  |   71|      0|#  define COMMENT_STATE 7    /* gzip comment -> HCRC_STATE */
  ------------------
  910|      0|    }
  911|  1.58k|    if (s->status == COMMENT_STATE) {
  ------------------
  |  |   71|  1.58k|#  define COMMENT_STATE 7    /* gzip comment -> HCRC_STATE */
  ------------------
  |  Branch (911:9): [True: 0, False: 1.58k]
  ------------------
  912|      0|        if (s->gzhead->comment != NULL) {
  ------------------
  |  Branch (912:13): [True: 0, False: 0]
  ------------------
  913|      0|            uint32_t beg = s->pending;  /* start of bytes to update crc */
  914|      0|            unsigned char val;
  915|       |
  916|      0|            do {
  917|      0|                if (s->pending == s->pending_buf_size) {
  ------------------
  |  Branch (917:21): [True: 0, False: 0]
  ------------------
  918|      0|                    HCRC_UPDATE(beg);
  ------------------
  |  |  781|      0|    do { \
  |  |  782|      0|        if (s->gzhead->hcrc && s->pending > (beg)) \
  |  |  ------------------
  |  |  |  Branch (782:13): [True: 0, False: 0]
  |  |  |  Branch (782:32): [True: 0, False: 0]
  |  |  ------------------
  |  |  783|      0|            strm->adler = crc32_small((uint32_t)strm->adler, s->pending_buf + (beg), s->pending - (beg)); \
  |  |  784|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (784:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  919|      0|                    PREFIX(flush_pending)(strm);
  ------------------
  |  |  121|      0|#  define PREFIX(x) zng_ ## x
  ------------------
  920|      0|                    if (s->pending != 0) {
  ------------------
  |  Branch (920:25): [True: 0, False: 0]
  ------------------
  921|      0|                        s->last_flush = -1;
  922|      0|                        return Z_OK;
  ------------------
  |  |  180|      0|#define Z_OK            0
  ------------------
  923|      0|                    }
  924|      0|                    beg = 0;
  925|      0|                }
  926|      0|                val = s->gzhead->comment[s->gzindex++];
  927|      0|                put_byte(s, val);
  ------------------
  |  |  350|      0|#define put_byte(s, c) { \
  |  |  351|      0|    s->pending_buf[s->pending++] = (unsigned char)(c); \
  |  |  352|      0|}
  ------------------
  928|      0|            } while (val != 0);
  ------------------
  |  Branch (928:22): [True: 0, False: 0]
  ------------------
  929|      0|            HCRC_UPDATE(beg);
  ------------------
  |  |  781|      0|    do { \
  |  |  782|      0|        if (s->gzhead->hcrc && s->pending > (beg)) \
  |  |  ------------------
  |  |  |  Branch (782:13): [True: 0, False: 0]
  |  |  |  Branch (782:32): [True: 0, False: 0]
  |  |  ------------------
  |  |  783|      0|            strm->adler = crc32_small((uint32_t)strm->adler, s->pending_buf + (beg), s->pending - (beg)); \
  |  |  784|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (784:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  930|      0|        }
  931|      0|        s->status = HCRC_STATE;
  ------------------
  |  |   72|      0|#  define HCRC_STATE    8    /* gzip header CRC -> BUSY_STATE */
  ------------------
  932|      0|    }
  933|  1.58k|    if (s->status == HCRC_STATE) {
  ------------------
  |  |   72|  1.58k|#  define HCRC_STATE    8    /* gzip header CRC -> BUSY_STATE */
  ------------------
  |  Branch (933:9): [True: 0, False: 1.58k]
  ------------------
  934|      0|        if (s->gzhead->hcrc) {
  ------------------
  |  Branch (934:13): [True: 0, False: 0]
  ------------------
  935|      0|            if (s->pending + 2 > s->pending_buf_size) {
  ------------------
  |  Branch (935:17): [True: 0, False: 0]
  ------------------
  936|      0|                PREFIX(flush_pending)(strm);
  ------------------
  |  |  121|      0|#  define PREFIX(x) zng_ ## x
  ------------------
  937|      0|                if (s->pending != 0) {
  ------------------
  |  Branch (937:21): [True: 0, False: 0]
  ------------------
  938|      0|                    s->last_flush = -1;
  939|      0|                    return Z_OK;
  ------------------
  |  |  180|      0|#define Z_OK            0
  ------------------
  940|      0|                }
  941|      0|            }
  942|      0|            put_short(s, (uint16_t)strm->adler);
  943|      0|            strm->adler = CRC32_INITIAL_VALUE;
  ------------------
  |  |   71|      0|#define CRC32_INITIAL_VALUE   0 /* initial crc-32 hash value */
  ------------------
  944|      0|        }
  945|      0|        s->status = BUSY_STATE;
  ------------------
  |  |   74|      0|#define BUSY_STATE      2    /* deflate -> FINISH_STATE */
  ------------------
  946|       |
  947|       |        /* Compression must start with an empty pending buffer */
  948|      0|        flush_pending_inline(strm);
  949|      0|        if (s->pending != 0) {
  ------------------
  |  Branch (949:13): [True: 0, False: 0]
  ------------------
  950|      0|            s->last_flush = -1;
  951|      0|            return Z_OK;
  ------------------
  |  |  180|      0|#define Z_OK            0
  ------------------
  952|      0|        }
  953|      0|    }
  954|  1.58k|#endif
  955|  1.58k|    return -1;
  956|  1.58k|}
deflate.c:free_deflate:
  241|  1.58k|static inline void free_deflate(PREFIX3(stream) *strm) {
  242|  1.58k|    deflate_state *state = (deflate_state *)strm->state;
  243|       |
  244|  1.58k|    if (state->alloc_bufs != NULL) {
  ------------------
  |  Branch (244:9): [True: 1.58k, False: 0]
  ------------------
  245|  1.58k|        deflate_allocs *alloc_bufs = state->alloc_bufs;
  246|  1.58k|        alloc_bufs->zfree(strm->opaque, alloc_bufs->buf_start);
  247|       |        strm->state = NULL;
  248|  1.58k|    }
  249|  1.58k|}
deflate.c:lm_set_level:
 1168|  4.74k|static void lm_set_level(deflate_state *s, int level) {
 1169|  4.74k|    s->max_lazy_match   = configuration_table[level].max_lazy;
 1170|  4.74k|    s->good_match       = configuration_table[level].good_length;
 1171|  4.74k|    s->nice_match       = configuration_table[level].nice_length;
 1172|  4.74k|    s->max_chain_length = configuration_table[level].max_chain;
 1173|  4.74k|    s->level = level;
 1174|  4.74k|}
deflate.c:lm_init:
 1179|  1.58k|static void lm_init(deflate_state *s) {
 1180|  1.58k|    s->window_size = 2 * s->w_size;
 1181|       |
 1182|  1.58k|    CLEAR_HASH(s);
  ------------------
  |  |  154|  1.58k|#define CLEAR_HASH(s) do { \
  |  |  155|  1.58k|    memset((unsigned char *)s->head, 0, HASH_SIZE * sizeof(*s->head)); \
  |  |  ------------------
  |  |  |  |   84|  1.58k|#  define HASH_SIZE 65536u         /* number of elements in hash table */
  |  |  ------------------
  |  |  156|  1.58k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (156:12): [Folded, False: 1.58k]
  |  |  ------------------
  ------------------
 1183|       |
 1184|       |    /* Set the default configuration parameters:
 1185|       |     */
 1186|  1.58k|    lm_set_level(s, s->level);
 1187|       |
 1188|  1.58k|    s->strstart = 0;
 1189|  1.58k|    s->block_start = 0;
 1190|  1.58k|    s->lookahead = 0;
 1191|  1.58k|    s->insert = 0;
 1192|  1.58k|    s->prev_length = 0;
 1193|  1.58k|    s->match_available = 0;
 1194|  1.58k|    s->match_start = 0;
 1195|  1.58k|    s->ins_h = 0;
 1196|  1.58k|}

deflate.c:put_short_msb:
  368|  1.58k|static inline void put_short_msb(deflate_state *s, uint16_t w) {
  369|  1.58k|    w = Z_U16_TO_BE(w);
  ------------------
  |  |   89|  1.58k|#  define Z_U16_TO_BE(x)    ZSWAP16(x)
  |  |  ------------------
  |  |  |  |  213|  1.58k|#  define ZSWAP16(q) __builtin_bswap16(q)
  |  |  ------------------
  ------------------
  370|  1.58k|    zng_memwrite_2(&s->pending_buf[s->pending], w);
  371|  1.58k|    s->pending += 2;
  372|  1.58k|}
deflate.c:put_uint32_msb:
  388|  1.58k|static inline void put_uint32_msb(deflate_state *s, uint32_t dw) {
  389|  1.58k|    dw = Z_U32_TO_BE(dw);
  ------------------
  |  |   90|  1.58k|#  define Z_U32_TO_BE(x)    ZSWAP32(x)
  |  |  ------------------
  |  |  |  |  214|  1.58k|#  define ZSWAP32(q) __builtin_bswap32(q)
  |  |  ------------------
  ------------------
  390|  1.58k|    zng_memwrite_4(&s->pending_buf[s->pending], dw);
  391|  1.58k|    s->pending += 4;
  392|  1.58k|}
deflate_stored.c:put_short:
  358|  3.16k|static inline void put_short(deflate_state *s, uint16_t w) {
  359|  3.16k|    w = Z_U16_TO_LE(w);
  ------------------
  |  |   83|  3.16k|#  define Z_U16_TO_LE(x)    (x)
  ------------------
  360|  3.16k|    zng_memwrite_2(&s->pending_buf[s->pending], w);
  361|  3.16k|    s->pending += 2;
  362|  3.16k|}
trees.c:put_uint64:
  398|  61.9k|static inline void put_uint64(deflate_state *s, uint64_t lld) {
  399|  61.9k|    lld = Z_U64_TO_LE(lld);
  ------------------
  |  |   85|  61.9k|#  define Z_U64_TO_LE(x)    (x)
  ------------------
  400|  61.9k|    zng_memwrite_8(&s->pending_buf[s->pending], lld);
  401|  61.9k|    s->pending += 8;
  402|  61.9k|}
trees.c:put_short:
  358|  4.88k|static inline void put_short(deflate_state *s, uint16_t w) {
  359|  4.88k|    w = Z_U16_TO_LE(w);
  ------------------
  |  |   83|  4.88k|#  define Z_U16_TO_LE(x)    (x)
  ------------------
  360|  4.88k|    zng_memwrite_2(&s->pending_buf[s->pending], w);
  361|  4.88k|    s->pending += 2;
  362|  4.88k|}
trees.c:put_uint32:
  378|  1.65k|static inline void put_uint32(deflate_state *s, uint32_t dw) {
  379|  1.65k|    dw = Z_U32_TO_LE(dw);
  ------------------
  |  |   84|  1.65k|#  define Z_U32_TO_LE(x)    (x)
  ------------------
  380|  1.65k|    zng_memwrite_4(&s->pending_buf[s->pending], dw);
  381|  1.65k|    s->pending += 4;
  382|  1.65k|}

deflate.c:flush_pending_inline:
  122|  11.0k|Z_FORCEINLINE static void flush_pending_inline(PREFIX3(stream) *strm) {
  123|  11.0k|    uint32_t len;
  124|  11.0k|    deflate_state *s = strm->state;
  125|       |
  126|  11.0k|    zng_tr_flush_bits(s);
  127|  11.0k|    len = MIN(s->pending, strm->avail_out);
  ------------------
  |  |  148|  11.0k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 11.0k]
  |  |  ------------------
  ------------------
  128|  11.0k|    if (len == 0)
  ------------------
  |  Branch (128:9): [True: 3.16k, False: 7.90k]
  ------------------
  129|  3.16k|        return;
  130|       |
  131|  7.90k|    Tracev((stderr, "[FLUSH]"));
  132|  7.90k|    memcpy(strm->next_out, s->pending_out, len);
  133|  7.90k|    strm->next_out  += len;
  134|  7.90k|    s->pending_out  += len;
  135|  7.90k|    strm->total_out += len;
  136|  7.90k|    strm->avail_out -= len;
  137|  7.90k|    s->pending      -= len;
  138|  7.90k|    if (s->pending == 0)
  ------------------
  |  Branch (138:9): [True: 7.90k, False: 0]
  ------------------
  139|  7.90k|        s->pending_out = s->pending_buf;
  140|  7.90k|}
deflate.c:read_buf:
  158|  16.0k|Z_FORCEINLINE static unsigned read_buf(PREFIX3(stream) *strm, unsigned char *buf, unsigned size) {
  159|  16.0k|    deflate_state *s = strm->state;
  160|  16.0k|    uint32_t len = MIN(strm->avail_in, size);
  ------------------
  |  |  148|  16.0k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 12.8k, False: 3.16k]
  |  |  ------------------
  ------------------
  161|       |
  162|  16.0k|    if (len == 0)
  ------------------
  |  Branch (162:9): [True: 0, False: 16.0k]
  ------------------
  163|      0|        return 0;
  164|       |
  165|  16.0k|    if (!DEFLATE_NEED_CHECKSUM(strm)) {
  ------------------
  |  |  489|  16.0k|#  define DEFLATE_NEED_CHECKSUM(strm) 1
  ------------------
  |  Branch (165:9): [Folded, False: 16.0k]
  ------------------
  166|      0|        memcpy(buf, strm->next_in, len);
  167|      0|#ifdef GZIP
  168|  16.0k|    } else if (s->wrap == 2) {
  ------------------
  |  Branch (168:16): [True: 0, False: 16.0k]
  ------------------
  169|      0|        strm->adler = FUNCTABLE_CALL(crc32_copy)(strm->adler, buf, strm->next_in, len);
  ------------------
  |  |   46|      0|#  define FUNCTABLE_CALL(name) functable.name
  ------------------
  170|      0|#endif
  171|  16.0k|    } else if (s->wrap == 1) {
  ------------------
  |  Branch (171:16): [True: 16.0k, False: 0]
  ------------------
  172|  16.0k|        strm->adler = FUNCTABLE_CALL(adler32_copy)(strm->adler, buf, strm->next_in, len);
  ------------------
  |  |   46|  16.0k|#  define FUNCTABLE_CALL(name) functable.name
  ------------------
  173|  16.0k|    } else {
  174|      0|        memcpy(buf, strm->next_in, len);
  175|      0|    }
  176|       |
  177|  16.0k|    strm->avail_in -= len;
  178|  16.0k|    strm->next_in  += len;
  179|  16.0k|    strm->total_in += len;
  180|  16.0k|    return len;
  181|  16.0k|}
deflate_slow.c:zng_tr_tally_dist:
   87|  1.83M|static inline int zng_tr_tally_dist(deflate_state* s, uint32_t dist, uint32_t len) {
   88|       |    /* dist: distance of matched string */
   89|       |    /* len: match length-STD_MIN_MATCH */
   90|  1.83M|    unsigned int sym_next = s->sym_next;
   91|       |#ifdef LIT_MEM
   92|       |    Assert(dist <= UINT16_MAX, "dist should fit in uint16_t");
   93|       |    Assert(len <= UINT8_MAX, "len should fit in uint8_t");
   94|       |    s->d_buf[sym_next] = (uint16_t)dist;
   95|       |    s->l_buf[sym_next] = (uint8_t)len;
   96|       |    s->sym_next = sym_next + 1;
   97|       |#else
   98|  1.83M|#  if OPTIMAL_CMP >= 32
   99|  1.83M|    zng_memwrite_4(&s->sym_buf[sym_next], Z_U32_TO_LE(dist | ((uint32_t)len << 16)));
  ------------------
  |  |   84|  1.83M|#  define Z_U32_TO_LE(x)    (x)
  ------------------
  100|       |#  else
  101|       |    s->sym_buf[sym_next] = (uint8_t)(dist);
  102|       |    s->sym_buf[sym_next+1] = (uint8_t)(dist >> 8);
  103|       |    s->sym_buf[sym_next+2] = (uint8_t)len;
  104|       |#  endif
  105|  1.83M|    s->sym_next = sym_next + 3;
  106|  1.83M|#endif
  107|  1.83M|    dist--;
  108|  1.83M|    Assert(dist < MAX_DIST(s) && (uint16_t)d_code(dist) < (uint16_t)D_CODES,
  109|  1.83M|        "zng_tr_tally: bad match");
  110|       |
  111|  1.83M|    s->dyn_ltree[zng_length_code[len] + LITERALS + 1].Freq++;
  ------------------
  |  |   45|  1.83M|#define LITERALS  256
  ------------------
                  s->dyn_ltree[zng_length_code[len] + LITERALS + 1].Freq++;
  ------------------
  |  |  125|  1.83M|#define Freq fc.freq
  ------------------
  112|  1.83M|    s->dyn_dtree[d_code(dist)].Freq++;
  ------------------
  |  |  436|  1.83M|#define d_code(dist) ((dist) < 256 ? zng_dist_code[dist] : zng_dist_code[256+((dist)>>7)])
  |  |  ------------------
  |  |  |  Branch (436:23): [True: 1.83M, False: 1.37k]
  |  |  ------------------
  ------------------
                  s->dyn_dtree[d_code(dist)].Freq++;
  ------------------
  |  |  125|  1.83M|#define Freq fc.freq
  ------------------
  113|  1.83M|    return (s->sym_next == s->sym_end);
  114|  1.83M|}
deflate_slow.c:zng_tr_tally_lit:
   64|  4.02k|static inline int zng_tr_tally_lit(deflate_state *s, unsigned char c) {
   65|       |    /* c is the unmatched char */
   66|  4.02k|    unsigned int sym_next = s->sym_next;
   67|       |#ifdef LIT_MEM
   68|       |    s->d_buf[sym_next] = 0;
   69|       |    s->l_buf[sym_next] = c;
   70|       |    s->sym_next = sym_next + 1;
   71|       |#else
   72|  4.02k|#  if OPTIMAL_CMP >= 32
   73|  4.02k|    zng_memwrite_4(&s->sym_buf[sym_next], Z_U32_TO_LE((uint32_t)c << 16));
  ------------------
  |  |   84|  4.02k|#  define Z_U32_TO_LE(x)    (x)
  ------------------
   74|       |#  else
   75|       |    s->sym_buf[sym_next] = 0;
   76|       |    s->sym_buf[sym_next+1] = 0;
   77|       |    s->sym_buf[sym_next+2] = c;
   78|       |#  endif
   79|  4.02k|    s->sym_next = sym_next + 3;
   80|  4.02k|#endif
   81|  4.02k|    s->dyn_ltree[c].Freq++;
  ------------------
  |  |  125|  4.02k|#define Freq fc.freq
  ------------------
   82|  4.02k|    Tracevv((stderr, "%c", c));
   83|  4.02k|    Assert(c <= (STD_MAX_MATCH-STD_MIN_MATCH), "zng_tr_tally: bad literal");
   84|  4.02k|    return (s->sym_next == s->sym_end);
   85|  4.02k|}
deflate_stored.c:read_buf:
  158|  1.58k|Z_FORCEINLINE static unsigned read_buf(PREFIX3(stream) *strm, unsigned char *buf, unsigned size) {
  159|  1.58k|    deflate_state *s = strm->state;
  160|  1.58k|    uint32_t len = MIN(strm->avail_in, size);
  ------------------
  |  |  148|  1.58k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 1.58k]
  |  |  ------------------
  ------------------
  161|       |
  162|  1.58k|    if (len == 0)
  ------------------
  |  Branch (162:9): [True: 0, False: 1.58k]
  ------------------
  163|      0|        return 0;
  164|       |
  165|  1.58k|    if (!DEFLATE_NEED_CHECKSUM(strm)) {
  ------------------
  |  |  489|  1.58k|#  define DEFLATE_NEED_CHECKSUM(strm) 1
  ------------------
  |  Branch (165:9): [Folded, False: 1.58k]
  ------------------
  166|      0|        memcpy(buf, strm->next_in, len);
  167|      0|#ifdef GZIP
  168|  1.58k|    } else if (s->wrap == 2) {
  ------------------
  |  Branch (168:16): [True: 0, False: 1.58k]
  ------------------
  169|      0|        strm->adler = FUNCTABLE_CALL(crc32_copy)(strm->adler, buf, strm->next_in, len);
  ------------------
  |  |   46|      0|#  define FUNCTABLE_CALL(name) functable.name
  ------------------
  170|      0|#endif
  171|  1.58k|    } else if (s->wrap == 1) {
  ------------------
  |  Branch (171:16): [True: 1.58k, False: 0]
  ------------------
  172|  1.58k|        strm->adler = FUNCTABLE_CALL(adler32_copy)(strm->adler, buf, strm->next_in, len);
  ------------------
  |  |   46|  1.58k|#  define FUNCTABLE_CALL(name) functable.name
  ------------------
  173|  1.58k|    } else {
  174|      0|        memcpy(buf, strm->next_in, len);
  175|      0|    }
  176|       |
  177|  1.58k|    strm->avail_in -= len;
  178|  1.58k|    strm->next_in  += len;
  179|  1.58k|    strm->total_in += len;
  180|  1.58k|    return len;
  181|  1.58k|}
trees.c:bi_reverse:
  145|  29.8k|Z_FORCEINLINE static uint16_t bi_reverse(uint16_t code, int len) {
  146|       |    /* code: the value to invert */
  147|       |    /* len: its bit length */
  148|  29.8k|    Assert(len >= 1 && len <= 15, "code length must be 1-15");
  149|  29.8k|    return zng_bitreverse16(code) >> (16 - len);
  150|  29.8k|}

deflate_slow:
   18|  6.32k|Z_INTERNAL block_state deflate_slow(deflate_state *s, int flush) {
   19|  6.32k|    match_func longest_match;
   20|  6.32k|    insert_batch_func insert_batch;
   21|  6.32k|    unsigned char *window = s->window;
   22|  6.32k|    int bflush;              /* set if current block must be flushed */
   23|  6.32k|    int level = s->level;
   24|       |
   25|  6.32k|    if (level >= 9) {
  ------------------
  |  Branch (25:9): [True: 6.32k, False: 0]
  ------------------
   26|  6.32k|        longest_match = FUNCTABLE_FPTR(longest_match_roll);
  ------------------
  |  |   47|  6.32k|#  define FUNCTABLE_FPTR(name) functable.name
  ------------------
   27|  6.32k|        insert_batch = insert_roll_batch;
   28|  6.32k|    } else {
   29|      0|        longest_match = FUNCTABLE_FPTR(longest_match);
  ------------------
  |  |   47|      0|#  define FUNCTABLE_FPTR(name) functable.name
  ------------------
   30|      0|        insert_batch = insert_knuth_batch;
   31|      0|    }
   32|       |
   33|       |    /* Process the input block. */
   34|  3.68M|    for (;;) {
   35|       |        /* Make sure that we always have enough lookahead, except
   36|       |         * at the end of the input file. We need STD_MAX_MATCH bytes
   37|       |         * for the next match, plus WANT_MIN_MATCH bytes to insert the
   38|       |         * string following the next match.
   39|       |         */
   40|  3.68M|        if (UNLIKELY(s->lookahead < MIN_LOOKAHEAD)) {
  ------------------
  |  |  258|  3.68M|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 29.3k, False: 3.66M]
  |  |  ------------------
  ------------------
   41|  29.3k|            PREFIX(fill_window)(s);
  ------------------
  |  |  121|  29.3k|#  define PREFIX(x) zng_ ## x
  ------------------
   42|  29.3k|            if (UNLIKELY(s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH)) {
  ------------------
  |  |  258|  42.8k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 3.16k, False: 26.1k]
  |  |  |  Branch (258:53): [True: 13.4k, False: 15.8k]
  |  |  |  Branch (258:53): [True: 3.16k, False: 10.3k]
  |  |  ------------------
  ------------------
   43|  3.16k|                return need_more;
   44|  3.16k|            }
   45|  26.1k|            if (UNLIKELY(s->lookahead == 0))
  ------------------
  |  |  258|  26.1k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 3.16k, False: 23.0k]
  |  |  ------------------
  ------------------
   46|  3.16k|                break; /* flush the current block */
   47|  26.1k|        }
   48|       |
   49|       |        /* Insert the string window[strstart .. strstart+2] in the
   50|       |         * dictionary, and set hash_head to the head of the hash chain:
   51|       |         */
   52|  3.68M|        uint32_t hash_head = 0;
   53|  3.68M|        if (LIKELY(s->lookahead >= WANT_MIN_MATCH)) {
  ------------------
  |  |  257|  3.68M|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 3.68M, False: 730]
  |  |  ------------------
  ------------------
   54|  3.68M|            if (level >= 9)
  ------------------
  |  Branch (54:17): [True: 3.68M, False: 0]
  ------------------
   55|  3.68M|                hash_head = insert_roll(s, window, s->strstart);
   56|      0|            else
   57|      0|                hash_head = insert_knuth(s, window, s->strstart);
   58|  3.68M|        }
   59|       |
   60|       |        /* Find the longest match, discarding those <= prev_length.
   61|       |         */
   62|  3.68M|        s->prev_match = s->match_start;
   63|  3.68M|        uint32_t match_len = STD_MIN_MATCH - 1;
  ------------------
  |  |   61|  3.68M|#define STD_MIN_MATCH  3
  ------------------
   64|  3.68M|        int64_t dist = (int64_t)s->strstart - hash_head;
   65|       |
   66|  3.68M|        if (dist <= MAX_DIST(s) && dist > 0 && s->prev_length < s->max_lazy_match && hash_head != 0) {
  ------------------
  |  |  409|  7.36M|#define MAX_DIST(s)  ((s)->w_size - MIN_LOOKAHEAD)
  |  |  ------------------
  |  |  |  |  404|  3.68M|#define MIN_LOOKAHEAD (STD_MAX_MATCH + STD_MIN_MATCH + 1)
  |  |  |  |  ------------------
  |  |  |  |  |  |   62|  3.68M|#define STD_MAX_MATCH  258
  |  |  |  |  ------------------
  |  |  |  |               #define MIN_LOOKAHEAD (STD_MAX_MATCH + STD_MIN_MATCH + 1)
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|  3.68M|#define STD_MIN_MATCH  3
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (66:13): [True: 3.68M, False: 485]
  |  Branch (66:36): [True: 3.68M, False: 1.58k]
  |  Branch (66:48): [True: 1.84M, False: 1.83M]
  |  Branch (66:86): [True: 1.84M, False: 1.82k]
  ------------------
   67|       |            /* To simplify the code, we prevent matches with the string
   68|       |             * of window index 0 (in particular we have to avoid a match
   69|       |             * of the string with itself at the start of the input file).
   70|       |             */
   71|  1.84M|            match_len = longest_match(s, hash_head);
   72|       |            /* longest_match() sets match_start */
   73|       |
   74|  1.84M|            if (match_len <= 5 && (s->strategy == Z_FILTERED)) {
  ------------------
  |  |  199|    322|#define Z_FILTERED            1
  ------------------
  |  Branch (74:17): [True: 322, False: 1.84M]
  |  Branch (74:35): [True: 136, False: 186]
  ------------------
   75|       |                /* If prev_match is also WANT_MIN_MATCH, match_start is garbage
   76|       |                 * but we will ignore the current match anyway.
   77|       |                 */
   78|    136|                match_len = STD_MIN_MATCH - 1;
  ------------------
  |  |   61|    136|#define STD_MIN_MATCH  3
  ------------------
   79|    136|            }
   80|  1.84M|        }
   81|       |        /* If there was a match at the previous step and the current
   82|       |         * match is not better, output the previous match:
   83|       |         */
   84|  3.68M|        if (s->prev_length >= STD_MIN_MATCH && match_len <= s->prev_length) {
  ------------------
  |  |   61|  7.36M|#define STD_MIN_MATCH  3
  ------------------
  |  Branch (84:13): [True: 1.83M, False: 1.84M]
  |  Branch (84:48): [True: 1.83M, False: 0]
  ------------------
   85|  1.83M|            unsigned int max_insert = s->strstart + s->lookahead - STD_MIN_MATCH;
  ------------------
  |  |   61|  1.83M|#define STD_MIN_MATCH  3
  ------------------
   86|       |            /* Do not insert strings in hash table beyond this. */
   87|       |
   88|  1.83M|            Assert((s->strstart-1) <= UINT16_MAX, "strstart-1 should fit in uint16_t");
   89|  1.83M|            check_match(s, s->strstart - 1, s->prev_match, s->prev_length);
   90|       |
   91|  1.83M|            bflush = zng_tr_tally_dist(s, s->strstart -1 - s->prev_match, s->prev_length - STD_MIN_MATCH);
  ------------------
  |  |   61|  1.83M|#define STD_MIN_MATCH  3
  ------------------
   92|       |
   93|       |            /* Insert in hash table all strings up to the end of the match.
   94|       |             * strstart-1 and strstart are already inserted. If there is not
   95|       |             * enough lookahead, the last two strings are not inserted in
   96|       |             * the hash table.
   97|       |             */
   98|  1.83M|            s->prev_length -= 1;
   99|  1.83M|            s->lookahead -= s->prev_length;
  100|       |
  101|  1.83M|            unsigned int mov_fwd = s->prev_length - 1;
  102|  1.83M|            if (max_insert > s->strstart) {
  ------------------
  |  Branch (102:17): [True: 1.83M, False: 0]
  ------------------
  103|  1.83M|                unsigned int insert_cnt = mov_fwd;
  104|  1.83M|                if (UNLIKELY(insert_cnt > max_insert - s->strstart))
  ------------------
  |  |  258|  1.83M|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 2.88k, False: 1.83M]
  |  |  ------------------
  ------------------
  105|  2.88k|                    insert_cnt = max_insert - s->strstart;
  106|  1.83M|                insert_batch(s, window, s->strstart + 1, insert_cnt);
  107|  1.83M|            }
  108|  1.83M|            s->prev_length = 0;
  109|  1.83M|            s->match_available = 0;
  110|  1.83M|            s->strstart += mov_fwd + 1;
  111|       |
  112|  1.83M|            if (UNLIKELY(bflush))
  ------------------
  |  |  258|  1.83M|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 1.83M]
  |  |  ------------------
  ------------------
  113|  1.83M|                FLUSH_BLOCK(s, window, 0);
  ------------------
  |  |  199|      0|#define FLUSH_BLOCK(s, window, last) { \
  |  |  200|      0|    FLUSH_BLOCK_ONLY(s, window, last); \
  |  |  ------------------
  |  |  |  |  187|      0|#define FLUSH_BLOCK_ONLY(s, window, last) { \
  |  |  |  |  188|      0|    int block_start = s->block_start; \
  |  |  |  |  189|      0|    zng_tr_flush_block(s, (block_start >= 0 ? \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (189:28): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  190|      0|                   &window[(unsigned)block_start] : \
  |  |  |  |  191|      0|                   NULL), \
  |  |  |  |  192|      0|                   (uint32_t)((int)s->strstart - block_start), \
  |  |  |  |  193|      0|                   (last)); \
  |  |  |  |  194|      0|    s->block_start = (int)s->strstart; \
  |  |  |  |  195|      0|    PREFIX(flush_pending)(s->strm); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  121|      0|#  define PREFIX(x) zng_ ## x
  |  |  |  |  ------------------
  |  |  |  |  196|      0|}
  |  |  ------------------
  |  |  201|      0|    if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \
  |  |  ------------------
  |  |  |  Branch (201:9): [True: 0, False: 0]
  |  |  |  Branch (201:41): [Folded, False: 0]
  |  |  ------------------
  |  |  202|      0|}
  ------------------
  114|       |
  115|  1.84M|        } else if (s->match_available) {
  ------------------
  |  Branch (115:20): [True: 3.70k, False: 1.83M]
  ------------------
  116|       |            /* If there was no match at the previous position, output a
  117|       |             * single literal. If there was a match but the current match
  118|       |             * is longer, truncate the previous match to a single literal.
  119|       |             */
  120|  3.70k|            bflush = zng_tr_tally_lit(s, window[s->strstart-1]);
  121|  3.70k|            if (UNLIKELY(bflush))
  ------------------
  |  |  258|  3.70k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 3.70k]
  |  |  ------------------
  ------------------
  122|      0|                FLUSH_BLOCK_ONLY(s, window, 0);
  ------------------
  |  |  187|      0|#define FLUSH_BLOCK_ONLY(s, window, last) { \
  |  |  188|      0|    int block_start = s->block_start; \
  |  |  189|      0|    zng_tr_flush_block(s, (block_start >= 0 ? \
  |  |  ------------------
  |  |  |  Branch (189:28): [True: 0, False: 0]
  |  |  ------------------
  |  |  190|      0|                   &window[(unsigned)block_start] : \
  |  |  191|      0|                   NULL), \
  |  |  192|      0|                   (uint32_t)((int)s->strstart - block_start), \
  |  |  193|      0|                   (last)); \
  |  |  194|      0|    s->block_start = (int)s->strstart; \
  |  |  195|      0|    PREFIX(flush_pending)(s->strm); \
  |  |  ------------------
  |  |  |  |  121|      0|#  define PREFIX(x) zng_ ## x
  |  |  ------------------
  |  |  196|      0|}
  ------------------
  123|  3.70k|            s->prev_length = match_len;
  124|  3.70k|            s->strstart++;
  125|  3.70k|            s->lookahead--;
  126|  3.70k|            if (UNLIKELY(s->strm->avail_out == 0))
  ------------------
  |  |  258|  3.70k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 3.70k]
  |  |  ------------------
  ------------------
  127|      0|                return need_more;
  128|  1.83M|        } else {
  129|       |            /* There is no previous match to compare with, wait for
  130|       |             * the next step to decide.
  131|       |             */
  132|  1.83M|            s->prev_length = match_len;
  133|  1.83M|            s->match_available = 1;
  134|  1.83M|            s->strstart++;
  135|  1.83M|            s->lookahead--;
  136|  1.83M|        }
  137|  3.68M|    }
  138|  3.16k|    Assert(flush != Z_NO_FLUSH, "no flush?");
  139|  3.16k|    if (UNLIKELY(s->match_available)) {
  ------------------
  |  |  258|  3.16k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 322, False: 2.83k]
  |  |  ------------------
  ------------------
  140|    322|        Z_UNUSED(zng_tr_tally_lit(s, window[s->strstart-1]));
  ------------------
  |  |  154|    322|#define Z_UNUSED(var) (void)(var)
  ------------------
  141|    322|        s->match_available = 0;
  142|    322|    }
  143|  3.16k|    s->insert = s->strstart < (STD_MIN_MATCH - 1) ? s->strstart : (STD_MIN_MATCH - 1);
  ------------------
  |  |   61|  3.16k|#define STD_MIN_MATCH  3
  ------------------
                  s->insert = s->strstart < (STD_MIN_MATCH - 1) ? s->strstart : (STD_MIN_MATCH - 1);
  ------------------
  |  |   61|  3.16k|#define STD_MIN_MATCH  3
  ------------------
  |  Branch (143:17): [True: 0, False: 3.16k]
  ------------------
  144|  3.16k|    if (UNLIKELY(flush == Z_FINISH)) {
  ------------------
  |  |  258|  3.16k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 1.58k, False: 1.58k]
  |  |  ------------------
  ------------------
  145|  1.58k|        FLUSH_BLOCK(s, window, 1);
  ------------------
  |  |  199|  1.58k|#define FLUSH_BLOCK(s, window, last) { \
  |  |  200|  1.58k|    FLUSH_BLOCK_ONLY(s, window, last); \
  |  |  ------------------
  |  |  |  |  187|  1.58k|#define FLUSH_BLOCK_ONLY(s, window, last) { \
  |  |  |  |  188|  1.58k|    int block_start = s->block_start; \
  |  |  |  |  189|  1.58k|    zng_tr_flush_block(s, (block_start >= 0 ? \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (189:28): [True: 1.01k, False: 569]
  |  |  |  |  ------------------
  |  |  |  |  190|  1.58k|                   &window[(unsigned)block_start] : \
  |  |  |  |  191|  1.58k|                   NULL), \
  |  |  |  |  192|  1.58k|                   (uint32_t)((int)s->strstart - block_start), \
  |  |  |  |  193|  1.58k|                   (last)); \
  |  |  |  |  194|  1.58k|    s->block_start = (int)s->strstart; \
  |  |  |  |  195|  1.58k|    PREFIX(flush_pending)(s->strm); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  121|  1.58k|#  define PREFIX(x) zng_ ## x
  |  |  |  |  ------------------
  |  |  |  |  196|  1.58k|}
  |  |  ------------------
  |  |  201|  1.58k|    if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \
  |  |  ------------------
  |  |  |  Branch (201:9): [True: 0, False: 1.58k]
  |  |  |  Branch (201:41): [True: 0, Folded]
  |  |  ------------------
  |  |  202|  1.58k|}
  ------------------
  146|  1.58k|        return finish_done;
  147|  1.58k|    }
  148|  1.58k|    if (UNLIKELY(s->sym_next))
  ------------------
  |  |  258|  1.58k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 1.58k, False: 0]
  |  |  ------------------
  ------------------
  149|  1.58k|        FLUSH_BLOCK(s, window, 0);
  ------------------
  |  |  199|  1.58k|#define FLUSH_BLOCK(s, window, last) { \
  |  |  200|  1.58k|    FLUSH_BLOCK_ONLY(s, window, last); \
  |  |  ------------------
  |  |  |  |  187|  1.58k|#define FLUSH_BLOCK_ONLY(s, window, last) { \
  |  |  |  |  188|  1.58k|    int block_start = s->block_start; \
  |  |  |  |  189|  1.58k|    zng_tr_flush_block(s, (block_start >= 0 ? \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (189:28): [True: 1.09k, False: 489]
  |  |  |  |  ------------------
  |  |  |  |  190|  1.58k|                   &window[(unsigned)block_start] : \
  |  |  |  |  191|  1.58k|                   NULL), \
  |  |  |  |  192|  1.58k|                   (uint32_t)((int)s->strstart - block_start), \
  |  |  |  |  193|  1.58k|                   (last)); \
  |  |  |  |  194|  1.58k|    s->block_start = (int)s->strstart; \
  |  |  |  |  195|  1.58k|    PREFIX(flush_pending)(s->strm); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  121|  1.58k|#  define PREFIX(x) zng_ ## x
  |  |  |  |  ------------------
  |  |  |  |  196|  1.58k|}
  |  |  ------------------
  |  |  201|  1.58k|    if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \
  |  |  ------------------
  |  |  |  Branch (201:9): [True: 0, False: 1.58k]
  |  |  |  Branch (201:41): [Folded, False: 0]
  |  |  ------------------
  |  |  202|  1.58k|}
  ------------------
  150|  1.58k|    return block_done;
  151|  1.58k|}

deflate_stored:
   20|  3.16k|Z_INTERNAL block_state deflate_stored(deflate_state *s, int flush) {
   21|  3.16k|    unsigned char *window = s->window;
   22|       |    /* Smallest worthy block size when not flushing or finishing. By default
   23|       |     * this is 32K. This can be as small as 507 bytes for memLevel == 1. For
   24|       |     * large input and output buffers, the stored block size will be larger.
   25|       |     */
   26|  3.16k|    unsigned int w_size = s->w_size;
   27|  3.16k|    unsigned min_block = MIN(s->pending_buf_size - 5, w_size);
  ------------------
  |  |  148|  3.16k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 3.16k, False: 0]
  |  |  ------------------
  ------------------
   28|       |
   29|       |    /* Copy as many min_block or larger stored blocks directly to next_out as
   30|       |     * possible. If flushing, copy the remaining available input to next_out as
   31|       |     * stored blocks, if there is enough space.
   32|       |     */
   33|  3.16k|    int last = 0;
   34|  3.16k|    unsigned len, left, have;
   35|  3.16k|    unsigned used = s->strm->avail_in;
   36|  4.74k|    do {
   37|       |        /* Set len to the maximum size block that we can copy directly with the
   38|       |         * available input data and output space. Set left to how much of that
   39|       |         * would be copied from what's left in the window.
   40|       |         */
   41|  4.74k|        len = MAX_STORED;       /* maximum deflate stored block length */
  ------------------
  |  |  205|  4.74k|#define MAX_STORED 65535
  ------------------
   42|  4.74k|        have = (s->bi_valid + 42) >> 3;         /* number of header bytes */
   43|  4.74k|        if (s->strm->avail_out < have)          /* need room for header */
  ------------------
  |  Branch (43:13): [True: 0, False: 4.74k]
  ------------------
   44|      0|            break;
   45|       |            /* maximum stored block length that will fit in avail_out: */
   46|  4.74k|        have = s->strm->avail_out - have;
   47|  4.74k|        left = (int)s->strstart - s->block_start;    /* bytes left in window */
   48|  4.74k|        if (len > (unsigned long)left + s->strm->avail_in)
  ------------------
  |  Branch (48:13): [True: 4.74k, False: 0]
  ------------------
   49|  4.74k|            len = left + s->strm->avail_in;     /* limit len to the input */
   50|  4.74k|        len = MIN(len, have);                   /* limit len to the output */
  ------------------
  |  |  148|  4.74k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 4.74k]
  |  |  ------------------
  ------------------
   51|       |
   52|       |        /* If the stored block would be less than min_block in length, or if
   53|       |         * unable to copy all of the available input when flushing, then try
   54|       |         * copying to the window and the pending buffer instead. Also don't
   55|       |         * write an empty block when flushing -- deflate() does that.
   56|       |         */
   57|  4.74k|        if (len < min_block && ((len == 0 && flush != Z_FINISH) || flush == Z_NO_FLUSH || len != left + s->strm->avail_in))
  ------------------
  |  |  175|  1.58k|#define Z_FINISH        4
  ------------------
                      if (len < min_block && ((len == 0 && flush != Z_FINISH) || flush == Z_NO_FLUSH || len != left + s->strm->avail_in))
  ------------------
  |  |  171|  7.90k|#define Z_NO_FLUSH      0
  ------------------
  |  Branch (57:13): [True: 4.74k, False: 0]
  |  Branch (57:34): [True: 1.58k, False: 3.16k]
  |  Branch (57:46): [True: 1.58k, False: 0]
  |  Branch (57:68): [True: 1.58k, False: 1.58k]
  |  Branch (57:91): [True: 0, False: 1.58k]
  ------------------
   58|  3.16k|            break;
   59|       |
   60|       |        /* Make a dummy stored block in pending to get the header bytes,
   61|       |         * including any pending bits. This also updates the debugging counts.
   62|       |         */
   63|  1.58k|        last = flush == Z_FINISH && len == left + s->strm->avail_in ? 1 : 0;
  ------------------
  |  |  175|  3.16k|#define Z_FINISH        4
  ------------------
  |  Branch (63:16): [True: 0, False: 1.58k]
  |  Branch (63:37): [True: 0, False: 0]
  ------------------
   64|  1.58k|        zng_tr_stored_block(s, NULL, 0L, last);
   65|       |
   66|       |        /* Replace the lengths in the dummy stored block with len. */
   67|  1.58k|        s->pending -= 4;
   68|  1.58k|        put_short(s, (uint16_t)len);
   69|  1.58k|        put_short(s, (uint16_t)~len);
   70|       |
   71|       |        /* Write the stored block header bytes. */
   72|  1.58k|        PREFIX(flush_pending)(s->strm);
  ------------------
  |  |  121|  1.58k|#  define PREFIX(x) zng_ ## x
  ------------------
   73|       |
   74|       |        /* Update debugging counts for the data about to be copied. */
   75|  1.58k|        cmpr_bits_add(s, len << 3);
  ------------------
  |  |  449|  1.58k|#  define cmpr_bits_add(s, len)     Z_UNUSED(len)
  |  |  ------------------
  |  |  |  |  154|  1.58k|#define Z_UNUSED(var) (void)(var)
  |  |  ------------------
  ------------------
   76|  1.58k|        sent_bits_add(s, len << 3);
  ------------------
  |  |  451|  1.58k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  ------------------
  |  |  |  |  154|  1.58k|#define Z_UNUSED(var) (void)(var)
  |  |  ------------------
  ------------------
   77|       |
   78|       |        /* Copy uncompressed bytes from the window to next_out. */
   79|  1.58k|        if (left) {
  ------------------
  |  Branch (79:13): [True: 1.58k, False: 0]
  ------------------
   80|  1.58k|            left = MIN(left, len);
  ------------------
  |  |  148|  1.58k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 1.58k]
  |  |  ------------------
  ------------------
   81|  1.58k|            memcpy(s->strm->next_out, window + s->block_start, left);
   82|  1.58k|            s->strm->next_out += left;
   83|  1.58k|            s->strm->avail_out -= left;
   84|  1.58k|            s->strm->total_out += left;
   85|  1.58k|            s->block_start += (int)left;
   86|  1.58k|            len -= left;
   87|  1.58k|        }
   88|       |
   89|       |        /* Copy uncompressed bytes directly from next_in to next_out, updating
   90|       |         * the check value.
   91|       |         */
   92|  1.58k|        if (len) {
  ------------------
  |  Branch (92:13): [True: 0, False: 1.58k]
  ------------------
   93|      0|            read_buf(s->strm, s->strm->next_out, len);
   94|      0|            s->strm->next_out += len;
   95|      0|            s->strm->avail_out -= len;
   96|      0|            s->strm->total_out += len;
   97|      0|        }
   98|  1.58k|    } while (last == 0);
  ------------------
  |  Branch (98:14): [True: 1.58k, False: 0]
  ------------------
   99|       |
  100|       |    /* Update the sliding window with the last s->w_size bytes of the copied
  101|       |     * data, or append all of the copied data to the existing window if less
  102|       |     * than s->w_size bytes were copied. Also update the number of bytes to
  103|       |     * insert in the hash tables, in the event that deflateParams() switches to
  104|       |     * a non-zero compression level.
  105|       |     */
  106|  3.16k|    used -= s->strm->avail_in;      /* number of input bytes directly copied */
  107|  3.16k|    if (used) {
  ------------------
  |  Branch (107:9): [True: 0, False: 3.16k]
  ------------------
  108|       |        /* If any input was used, then no unused input remains in the window,
  109|       |         * therefore s->block_start == s->strstart.
  110|       |         */
  111|      0|        if (used >= w_size) {    /* supplant the previous history */
  ------------------
  |  Branch (111:13): [True: 0, False: 0]
  ------------------
  112|      0|            memcpy(window, s->strm->next_in - w_size, w_size);
  113|      0|            s->strstart = w_size;
  114|      0|            s->insert = s->strstart;
  115|      0|        } else {
  116|      0|            if (s->window_size - s->strstart <= used) {
  ------------------
  |  Branch (116:17): [True: 0, False: 0]
  ------------------
  117|       |                /* Slide the window down. */
  118|      0|                s->strstart -= w_size;
  119|      0|                memcpy(window, window + w_size, s->strstart);
  120|      0|                s->insert = MIN(s->insert, s->strstart);
  ------------------
  |  |  148|      0|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  121|      0|            }
  122|      0|            memcpy(window + s->strstart, s->strm->next_in - used, used);
  123|      0|            s->strstart += used;
  124|      0|            s->insert += MIN(used, w_size - s->insert);
  ------------------
  |  |  148|      0|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  125|      0|        }
  126|      0|        s->block_start = (int)s->strstart;
  127|      0|    }
  128|  3.16k|    s->high_water = MAX(s->high_water, s->strstart);
  ------------------
  |  |  150|  3.16k|#define MAX(a, b) ((a) < (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (150:20): [True: 0, False: 3.16k]
  |  |  ------------------
  ------------------
  129|       |
  130|       |    /* If the last block was written to next_out, then done. */
  131|  3.16k|    if (last) {
  ------------------
  |  Branch (131:9): [True: 0, False: 3.16k]
  ------------------
  132|      0|        s->bi_used = 8;
  133|      0|        return finish_done;
  134|      0|    }
  135|       |
  136|       |    /* If flushing and all input has been consumed, then done. */
  137|  3.16k|    if (flush != Z_NO_FLUSH && flush != Z_FINISH && s->strm->avail_in == 0 && (int)s->strstart == s->block_start)
  ------------------
  |  |  171|  6.32k|#define Z_NO_FLUSH      0
  ------------------
                  if (flush != Z_NO_FLUSH && flush != Z_FINISH && s->strm->avail_in == 0 && (int)s->strstart == s->block_start)
  ------------------
  |  |  175|  4.74k|#define Z_FINISH        4
  ------------------
  |  Branch (137:9): [True: 1.58k, False: 1.58k]
  |  Branch (137:32): [True: 1.58k, False: 0]
  |  Branch (137:53): [True: 1.58k, False: 0]
  |  Branch (137:79): [True: 1.58k, False: 0]
  ------------------
  138|  1.58k|        return block_done;
  139|       |
  140|       |    /* Fill the window with any remaining input. */
  141|  1.58k|    have = s->window_size - s->strstart;
  142|  1.58k|    if (s->strm->avail_in > have && s->block_start >= (int)w_size) {
  ------------------
  |  Branch (142:9): [True: 39, False: 1.54k]
  |  Branch (142:37): [True: 39, False: 0]
  ------------------
  143|       |        /* Slide the window down. */
  144|     39|        s->block_start -= (int)w_size;
  145|     39|        s->strstart -= w_size;
  146|     39|        memcpy(window, window + w_size, s->strstart);
  147|     39|        have += w_size;          /* more space now */
  148|     39|        s->insert = MIN(s->insert, s->strstart);
  ------------------
  |  |  148|     39|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 39]
  |  |  ------------------
  ------------------
  149|     39|    }
  150|       |
  151|  1.58k|    have = MIN(have, s->strm->avail_in);
  ------------------
  |  |  148|  1.58k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 1.57k, False: 1]
  |  |  ------------------
  ------------------
  152|  1.58k|    if (have) {
  ------------------
  |  Branch (152:9): [True: 1.58k, False: 0]
  ------------------
  153|  1.58k|        read_buf(s->strm, window + s->strstart, have);
  154|  1.58k|        s->strstart += have;
  155|  1.58k|        s->insert += MIN(have, w_size - s->insert);
  ------------------
  |  |  148|  1.58k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 1.58k]
  |  |  ------------------
  ------------------
  156|  1.58k|    }
  157|  1.58k|    s->high_water = MAX(s->high_water, s->strstart);
  ------------------
  |  |  150|  1.58k|#define MAX(a, b) ((a) < (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (150:20): [True: 0, False: 1.58k]
  |  |  ------------------
  ------------------
  158|       |
  159|       |    /* There was not enough avail_out to write a complete worthy or flushed
  160|       |     * stored block to next_out. Write a stored block to pending instead, if we
  161|       |     * have enough input for a worthy block, or if flushing and there is enough
  162|       |     * room for the remaining input as a stored block in the pending buffer.
  163|       |     */
  164|  1.58k|    have = (s->bi_valid + 42) >> 3;         /* number of header bytes */
  165|       |        /* maximum stored block length that will fit in pending: */
  166|  1.58k|    have = MIN(s->pending_buf_size - have, MAX_STORED);
  ------------------
  |  |  148|  1.58k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 1.58k]
  |  |  ------------------
  ------------------
  167|  1.58k|    min_block = MIN(have, w_size);
  ------------------
  |  |  148|  1.58k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 1.58k, False: 0]
  |  |  ------------------
  ------------------
  168|  1.58k|    left = (int)s->strstart - s->block_start;
  169|  1.58k|    if (left >= min_block || ((left || flush == Z_FINISH) && flush != Z_NO_FLUSH && s->strm->avail_in == 0 && left <= have)) {
  ------------------
  |  |  175|      0|#define Z_FINISH        4
  ------------------
                  if (left >= min_block || ((left || flush == Z_FINISH) && flush != Z_NO_FLUSH && s->strm->avail_in == 0 && left <= have)) {
  ------------------
  |  |  171|  3.16k|#define Z_NO_FLUSH      0
  ------------------
  |  Branch (169:9): [True: 0, False: 1.58k]
  |  Branch (169:32): [True: 1.58k, False: 0]
  |  Branch (169:40): [True: 0, False: 0]
  |  Branch (169:62): [True: 0, False: 1.58k]
  |  Branch (169:85): [True: 0, False: 0]
  |  Branch (169:111): [True: 0, False: 0]
  ------------------
  170|      0|        len = MIN(left, have);
  ------------------
  |  |  148|      0|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  171|      0|        last = flush == Z_FINISH && s->strm->avail_in == 0 && len == left ? 1 : 0;
  ------------------
  |  |  175|      0|#define Z_FINISH        4
  ------------------
  |  Branch (171:16): [True: 0, False: 0]
  |  Branch (171:37): [True: 0, False: 0]
  |  Branch (171:63): [True: 0, False: 0]
  ------------------
  172|      0|        zng_tr_stored_block(s, window + s->block_start, len, last);
  173|      0|        s->block_start += (int)len;
  174|      0|        PREFIX(flush_pending)(s->strm);
  ------------------
  |  |  121|      0|#  define PREFIX(x) zng_ ## x
  ------------------
  175|      0|    }
  176|       |
  177|       |    /* We've done all we can with the available input and output. */
  178|  1.58k|    if (last) {
  ------------------
  |  Branch (178:9): [True: 0, False: 1.58k]
  ------------------
  179|      0|        s->bi_used = 8;
  180|      0|        return finish_started;
  181|      0|    }
  182|  1.58k|    return need_more;
  183|  1.58k|}

deflate.c:zng_ctz32:
   20|  1.58k|Z_FORCEINLINE static uint32_t zng_ctz32(uint32_t value) {
   21|  1.58k|    Assert(value != 0, "Invalid input value: 0");
   22|  1.58k|#if __has_builtin(__builtin_ctz)
   23|  1.58k|    return (uint32_t)__builtin_ctz(value);
   24|       |#elif defined(_MSC_VER) && !defined(__clang__)
   25|       |#  if defined(X86_FEATURES) && !(_MSC_VER < 1700)
   26|       |    /* tzcnt falls back to bsf on cpus without BMI1, and is equal or faster on all x86 cpus. */
   27|       |    return (uint32_t)_tzcnt_u32(value);
   28|       |#  else
   29|       |    unsigned long trailing_zero;
   30|       |    _BitScanForward(&trailing_zero, value);
   31|       |    return (uint32_t)trailing_zero;
   32|       |#  endif
   33|       |#else
   34|       |    /* De Bruijn CTZ for 32-bit values */
   35|       |    static const uint8_t debruijn_ctz32[32] = {
   36|       |        0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
   37|       |        31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
   38|       |    };
   39|       |    uint32_t lsb = value & (~value + 1u);
   40|       |    return debruijn_ctz32[(lsb * 0x077CB531U) >> 27];
   41|       |#endif
   42|  1.58k|}
inftrees.c:zng_bitreverse16:
  141|  24.2k|Z_FORCEINLINE static uint16_t zng_bitreverse16(uint16_t value) {
  142|  24.2k|#if __has_builtin(__builtin_bitreverse16)
  143|  24.2k|    return (uint16_t)__builtin_bitreverse16(value);
  144|       |#elif defined(ARCH_ARM) && defined(ARCH_64BIT) && !defined(_MSC_VER)
  145|       |    /* ARM bit reversal for 16-bit values using rbit instruction */
  146|       |    uint32_t res;
  147|       |#    if __has_builtin(__builtin_rbit)
  148|       |    res = __builtin_rbit((uint32_t)value);
  149|       |#    else
  150|       |    __asm__ volatile("rbit %w0, %w1" : "=r"(res) : "r"((uint32_t)value));
  151|       |#    endif
  152|       |    return (uint16_t)(res >> 16);
  153|       |#elif defined(ARCH_LOONGARCH)
  154|       |    /* LoongArch bit reversal for 16-bit values */
  155|       |    uint32_t res;
  156|       |    __asm__ volatile("bitrev.w %0, %1" : "=r"(res) : "r"(value));
  157|       |    return (uint16_t)(res >> 16);
  158|       |#else
  159|       |    /* Bit reversal for 8-bit values using multiplication method */
  160|       |#  define bitrev8(value) \
  161|       |    (uint8_t)((((uint8_t)(value) * 0x80200802ULL) & 0x0884422110ULL) * 0x0101010101ULL >> 32)
  162|       |    /* General purpose bit reversal for 16-bit values */
  163|       |    return ((bitrev8(value >> 8) | (uint16_t)bitrev8(value) << 8));
  164|       |#  undef bitrev8
  165|       |#endif
  166|  24.2k|}
trees.c:zng_bitreverse16:
  141|  29.8k|Z_FORCEINLINE static uint16_t zng_bitreverse16(uint16_t value) {
  142|  29.8k|#if __has_builtin(__builtin_bitreverse16)
  143|  29.8k|    return (uint16_t)__builtin_bitreverse16(value);
  144|       |#elif defined(ARCH_ARM) && defined(ARCH_64BIT) && !defined(_MSC_VER)
  145|       |    /* ARM bit reversal for 16-bit values using rbit instruction */
  146|       |    uint32_t res;
  147|       |#    if __has_builtin(__builtin_rbit)
  148|       |    res = __builtin_rbit((uint32_t)value);
  149|       |#    else
  150|       |    __asm__ volatile("rbit %w0, %w1" : "=r"(res) : "r"((uint32_t)value));
  151|       |#    endif
  152|       |    return (uint16_t)(res >> 16);
  153|       |#elif defined(ARCH_LOONGARCH)
  154|       |    /* LoongArch bit reversal for 16-bit values */
  155|       |    uint32_t res;
  156|       |    __asm__ volatile("bitrev.w %0, %1" : "=r"(res) : "r"(value));
  157|       |    return (uint16_t)(res >> 16);
  158|       |#else
  159|       |    /* Bit reversal for 8-bit values using multiplication method */
  160|       |#  define bitrev8(value) \
  161|       |    (uint8_t)((((uint8_t)(value) * 0x80200802ULL) & 0x0884422110ULL) * 0x0101010101ULL >> 32)
  162|       |    /* General purpose bit reversal for 16-bit values */
  163|       |    return ((bitrev8(value >> 8) | (uint16_t)bitrev8(value) << 8));
  164|       |#  undef bitrev8
  165|       |#endif
  166|  29.8k|}
compare256_avx2.c:zng_ctz32:
   20|   376k|Z_FORCEINLINE static uint32_t zng_ctz32(uint32_t value) {
   21|   376k|    Assert(value != 0, "Invalid input value: 0");
   22|   376k|#if __has_builtin(__builtin_ctz)
   23|   376k|    return (uint32_t)__builtin_ctz(value);
   24|       |#elif defined(_MSC_VER) && !defined(__clang__)
   25|       |#  if defined(X86_FEATURES) && !(_MSC_VER < 1700)
   26|       |    /* tzcnt falls back to bsf on cpus without BMI1, and is equal or faster on all x86 cpus. */
   27|       |    return (uint32_t)_tzcnt_u32(value);
   28|       |#  else
   29|       |    unsigned long trailing_zero;
   30|       |    _BitScanForward(&trailing_zero, value);
   31|       |    return (uint32_t)trailing_zero;
   32|       |#  endif
   33|       |#else
   34|       |    /* De Bruijn CTZ for 32-bit values */
   35|       |    static const uint8_t debruijn_ctz32[32] = {
   36|       |        0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
   37|       |        31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
   38|       |    };
   39|       |    uint32_t lsb = value & (~value + 1u);
   40|       |    return debruijn_ctz32[(lsb * 0x077CB531U) >> 27];
   41|       |#endif
   42|   376k|}
compare256_avx2.c:zng_ctz64:
   44|  6.89k|Z_FORCEINLINE static uint32_t zng_ctz64(uint64_t value) {
   45|  6.89k|    Assert(value != 0, "Invalid input value: 0");
   46|  6.89k|#if __has_builtin(__builtin_ctzll)
   47|  6.89k|    return (uint32_t)__builtin_ctzll(value);
   48|       |#elif defined(_MSC_VER) && !defined(__clang__) && defined(ARCH_64BIT)
   49|       |#  if defined(X86_FEATURES) && !(_MSC_VER < 1700)
   50|       |    /* tzcnt falls back to bsf on cpus without BMI1, and is equal or faster on all x86 cpus. */
   51|       |    return (uint32_t)_tzcnt_u64(value);
   52|       |#  else
   53|       |    unsigned long trailing_zero;
   54|       |    _BitScanForward64(&trailing_zero, value);
   55|       |    return (uint32_t)trailing_zero;
   56|       |#  endif
   57|       |#else
   58|       |    /* De Bruijn CTZ for 64-bit values */
   59|       |    static const uint8_t debruijn_ctz64[64] = {
   60|       |        63, 0, 1, 52, 2, 6, 53, 26, 3, 37, 40, 7, 33, 54, 47, 27,
   61|       |        61, 4, 38, 45, 43, 41, 21, 8, 23, 34, 58, 55, 48, 17, 28, 10,
   62|       |        62, 51, 5, 25, 36, 39, 32, 46, 60, 44, 42, 20, 22, 57, 16, 9,
   63|       |        50, 24, 35, 31, 59, 19, 56, 15, 49, 30, 18, 14, 29, 13, 12, 11
   64|       |    };
   65|       |    uint64_t lsb = value & (~value + 1ull);
   66|       |    return debruijn_ctz64[(lsb * 0x045FBAC7992A70DAULL) >> 58];
   67|       |#endif
   68|  6.89k|}

functable.c:functable_constructor:
  469|      2|static void __attribute__((constructor)) functable_constructor(void) {
  470|      2|    FUNCTABLE_INIT_ABORT;
  ------------------
  |  |   57|      2|    if (init_functable()) { \
  |  |  ------------------
  |  |  |  Branch (57:9): [True: 0, False: 2]
  |  |  ------------------
  |  |   58|      0|        fprintf(stderr, "Zlib-ng functable failed initialization!\n"); \
  |  |   59|      0|        abort(); \
  |  |   60|      2|    };
  ------------------
  471|      2|}
functable.c:init_functable:
   70|      2|static int init_functable(void) {
   71|      2|    struct functable_s ft;
   72|      2|    struct cpu_features cf;
   73|       |
   74|      2|    memset(&ft, 0, sizeof(struct functable_s));
   75|      2|    cpu_check_features(&cf);
   76|      2|    ft.force_init = &force_init_empty;
   77|       |
   78|       |    // Only use necessary generic functions when no suitable simd versions are available.
   79|      2|#ifdef ADLER32_FALLBACK
   80|      2|    ft.adler32 = &adler32_c;
   81|      2|    ft.adler32_copy = &adler32_copy_c;
   82|      2|#endif
   83|       |#ifdef CHUNKSET_FALLBACK
   84|       |    ft.chunkmemset_safe = &chunkmemset_safe_c;
   85|       |    ft.inflate_fast = &inflate_fast_c;
   86|       |#endif
   87|       |#ifdef COMPARE256_FALLBACK
   88|       |    ft.compare256 = &compare256_c;
   89|       |    ft.longest_match = &longest_match_c;
   90|       |    ft.longest_match_roll = &longest_match_roll_c;
   91|       |#endif
   92|      2|#ifdef CRC32_BRAID_FALLBACK
   93|      2|    ft.crc32 = &crc32_braid;
   94|      2|    ft.crc32_copy = &crc32_copy_braid;
   95|      2|#endif
   96|       |#ifdef SLIDE_HASH_FALLBACK
   97|       |    ft.slide_hash = &slide_hash_c;
   98|       |    ft.slide_hash_head = &slide_hash_head_c;
   99|       |#endif
  100|       |
  101|       |    // Select arch-optimized functions
  102|      2|#ifdef WITH_OPTIM
  103|       |
  104|       |    // Chorba generic C fallback
  105|      2|#ifdef CRC32_CHORBA_FALLBACK
  106|      2|    ft.crc32 = &crc32_chorba;
  107|      2|    ft.crc32_copy = &crc32_copy_chorba;
  108|      2|#endif
  109|       |
  110|       |    // X86 - SSE2
  111|      2|#ifdef X86_SSE2
  112|       |#  ifndef X86_SSE2_NATIVE
  113|       |    if (cf.x86.has_sse2)
  114|       |#  endif
  115|      2|    {
  116|      2|#  ifndef X86_AVX2_NATIVE
  117|      2|        ft.chunkmemset_safe = &chunkmemset_safe_sse2;
  118|      2|        ft.compare256 = &compare256_sse2;
  119|      2|        ft.inflate_fast = &inflate_fast_sse2;
  120|      2|        ft.longest_match = &longest_match_sse2;
  121|      2|        ft.longest_match_roll = &longest_match_roll_sse2;
  122|      2|        ft.slide_hash = &slide_hash_sse2;
  123|      2|        ft.slide_hash_head = &slide_hash_head_sse2;
  124|      2|#  endif
  125|      2|#  if defined(CRC32_CHORBA_SSE_FALLBACK) && !defined(X86_SSE41_NATIVE) && !defined(X86_PCLMULQDQ_NATIVE)
  126|      2|        ft.crc32 = &crc32_chorba_sse2;
  127|      2|        ft.crc32_copy = &crc32_copy_chorba_sse2;
  128|      2|#  endif
  129|      2|    }
  130|      2|#endif
  131|       |    // X86 - SSSE3
  132|      2|#ifdef X86_SSSE3
  133|      2|#  ifndef X86_SSSE3_NATIVE
  134|      2|    if (cf.x86.has_ssse3)
  ------------------
  |  Branch (134:9): [True: 2, False: 0]
  ------------------
  135|      2|#  endif
  136|      2|    {
  137|      2|        ft.adler32 = &adler32_ssse3;
  138|      2|        ft.adler32_copy = &adler32_copy_ssse3;
  139|      2|#  ifndef X86_AVX2_NATIVE
  140|      2|        ft.chunkmemset_safe = &chunkmemset_safe_ssse3;
  141|      2|        ft.inflate_fast = &inflate_fast_ssse3;
  142|      2|#  endif
  143|      2|    }
  144|      2|#endif
  145|       |
  146|       |    // X86 - SSE4.1
  147|      2|#if defined(X86_SSE41) && !defined(X86_PCLMULQDQ_NATIVE)
  148|      2|#  ifndef X86_SSE41_NATIVE
  149|      2|    if (cf.x86.has_sse41)
  ------------------
  |  Branch (149:9): [True: 2, False: 0]
  ------------------
  150|      2|#  endif
  151|      2|    {
  152|      2|#  ifdef CRC32_CHORBA_SSE_FALLBACK
  153|      2|        ft.crc32 = &crc32_chorba_sse41;
  154|      2|        ft.crc32_copy = &crc32_copy_chorba_sse41;
  155|      2|#  endif
  156|      2|    }
  157|      2|#endif
  158|       |
  159|       |    // X86 - SSE4.2
  160|      2|#if defined(X86_SSE42) && !defined(X86_AVX512_NATIVE)
  161|      2|#  ifndef X86_SSE42_NATIVE
  162|      2|    if (cf.x86.has_sse42)
  ------------------
  |  Branch (162:9): [True: 2, False: 0]
  ------------------
  163|      2|#  endif
  164|      2|    {
  165|      2|        ft.adler32_copy = &adler32_copy_sse42;
  166|      2|    }
  167|      2|#endif
  168|       |    // X86 - PCLMUL
  169|      2|#if defined(X86_PCLMULQDQ_CRC) && !defined(X86_VPCLMULQDQ_NATIVE)
  170|      2|#  ifndef X86_PCLMULQDQ_NATIVE
  171|      2|    if (cf.x86.has_pclmulqdq)
  ------------------
  |  Branch (171:9): [True: 2, False: 0]
  ------------------
  172|      2|#  endif
  173|      2|    {
  174|      2|        ft.crc32 = &crc32_pclmulqdq;
  175|      2|        ft.crc32_copy = &crc32_copy_pclmulqdq;
  176|      2|    }
  177|      2|#endif
  178|       |    // X86 - AVX2
  179|      2|#ifdef X86_AVX2
  180|       |    /* BMI2 support is all but implicit with AVX2 but let's sanity check this just in case. Enabling BMI2 allows for
  181|       |     * flagless shifts, resulting in fewer flag stalls for the pipeline, and allows us to set destination registers
  182|       |     * for the shift results as an operand, eliminating several register-register moves when the original value needs
  183|       |     * to remain intact. They also allow for a count operand that isn't the CL register, avoiding contention there */
  184|      2|#  ifndef X86_AVX2_NATIVE
  185|      2|    if (cf.x86.has_avx2 && cf.x86.has_bmi2)
  ------------------
  |  Branch (185:9): [True: 2, False: 0]
  |  Branch (185:28): [True: 2, False: 0]
  ------------------
  186|      2|#  endif
  187|      2|    {
  188|      2|#  ifndef X86_AVX512_NATIVE
  189|      2|        ft.adler32 = &adler32_avx2;
  190|      2|        ft.adler32_copy = &adler32_copy_avx2;
  191|      2|        ft.chunkmemset_safe = &chunkmemset_safe_avx2;
  192|      2|        ft.compare256 = &compare256_avx2;
  193|      2|        ft.inflate_fast = &inflate_fast_avx2;
  194|      2|        ft.longest_match = &longest_match_avx2;
  195|      2|        ft.longest_match_roll = &longest_match_roll_avx2;
  196|      2|#  endif
  197|      2|        ft.slide_hash = &slide_hash_avx2;
  198|      2|        ft.slide_hash_head = &slide_hash_head_avx2;
  199|      2|    }
  200|      2|#endif
  201|      2|#ifdef X86_AVX2VNNI
  202|      2|    if (cf.x86.has_avx2vnni) {
  ------------------
  |  Branch (202:9): [True: 0, False: 2]
  ------------------
  203|      0|        ft.adler32 = &adler32_avx2_vnni;
  204|       |        //ft.adler32_copy = &adler32_copy_avx2_vnni;
  205|      0|    }
  206|      2|#endif
  207|       |    // X86 - AVX512 (F,DQ,BW,Vl)
  208|      2|#ifdef X86_AVX512
  209|      2|#  ifndef X86_AVX512_NATIVE
  210|      2|    if (cf.x86.has_avx512_common)
  ------------------
  |  Branch (210:9): [True: 0, False: 2]
  ------------------
  211|      0|#  endif
  212|      0|    {
  213|      0|#  ifndef X86_AVX512VNNI_NATIVE
  214|      0|        ft.adler32 = &adler32_avx512;
  215|      0|        ft.adler32_copy = &adler32_copy_avx512;
  216|      0|#  endif
  217|      0|        ft.chunkmemset_safe = &chunkmemset_safe_avx512;
  218|      0|        ft.compare256 = &compare256_avx512;
  219|      0|        ft.inflate_fast = &inflate_fast_avx512;
  220|      0|        ft.longest_match = &longest_match_avx512;
  221|      0|        ft.longest_match_roll = &longest_match_roll_avx512;
  222|      0|    }
  223|      2|#endif
  224|      2|#ifdef X86_AVX512VNNI
  225|      2|#  ifndef X86_AVX512VNNI_NATIVE
  226|      2|    if (cf.x86.has_avx512vnni)
  ------------------
  |  Branch (226:9): [True: 0, False: 2]
  ------------------
  227|      0|#  endif
  228|      0|    {
  229|      0|        ft.adler32 = &adler32_avx512_vnni;
  230|      0|        ft.adler32_copy = &adler32_copy_avx512_vnni;
  231|      0|    }
  232|      2|#endif
  233|       |    // X86 - VPCLMULQDQ (AVX2)
  234|      2|#ifdef X86_VPCLMULQDQ_AVX2
  235|      2|#  ifndef X86_VPCLMULQDQ_AVX2_NATIVE
  236|      2|    if (cf.x86.has_pclmulqdq && cf.x86.has_avx2 && cf.x86.has_vpclmulqdq)
  ------------------
  |  Branch (236:9): [True: 2, False: 0]
  |  Branch (236:33): [True: 2, False: 0]
  |  Branch (236:52): [True: 0, False: 2]
  ------------------
  237|      0|#  endif
  238|      0|    {
  239|      0|        ft.crc32 = &crc32_vpclmulqdq_avx2;
  240|      0|        ft.crc32_copy = &crc32_copy_vpclmulqdq_avx2;
  241|      0|    }
  242|      2|#endif
  243|       |    // X86 - VPCLMULQDQ (AVX-512)
  244|      2|#ifdef X86_VPCLMULQDQ_AVX512
  245|      2|#  ifndef X86_VPCLMULQDQ_AVX512_NATIVE
  246|      2|    if (cf.x86.has_pclmulqdq && cf.x86.has_avx512_common && cf.x86.has_vpclmulqdq)
  ------------------
  |  Branch (246:9): [True: 2, False: 0]
  |  Branch (246:33): [True: 0, False: 2]
  |  Branch (246:61): [True: 0, False: 0]
  ------------------
  247|      0|#  endif
  248|      0|    {
  249|      0|        ft.crc32 = &crc32_vpclmulqdq_avx512;
  250|      0|        ft.crc32_copy = &crc32_copy_vpclmulqdq_avx512;
  251|      0|    }
  252|      2|#endif
  253|       |
  254|       |
  255|       |    // ARM - SIMD
  256|       |#if defined(ARM_SIMD) && !defined(ARM_NEON_NATIVE)
  257|       |#  ifndef ARM_SIMD_NATIVE
  258|       |    if (cf.arm.has_simd)
  259|       |#  endif
  260|       |    {
  261|       |        ft.slide_hash = &slide_hash_armv6;
  262|       |        ft.slide_hash_head = &slide_hash_head_armv6;
  263|       |    }
  264|       |#endif
  265|       |    // ARM - NEON
  266|       |#ifdef ARM_NEON
  267|       |#  ifndef ARM_NEON_NATIVE
  268|       |    if (cf.arm.has_neon)
  269|       |#  endif
  270|       |    {
  271|       |        ft.adler32 = &adler32_neon;
  272|       |        ft.adler32_copy = &adler32_copy_neon;
  273|       |        ft.chunkmemset_safe = &chunkmemset_safe_neon;
  274|       |        ft.compare256 = &compare256_neon;
  275|       |        ft.inflate_fast = &inflate_fast_neon;
  276|       |        ft.longest_match = &longest_match_neon;
  277|       |        ft.longest_match_roll = &longest_match_roll_neon;
  278|       |        ft.slide_hash = &slide_hash_neon;
  279|       |        ft.slide_hash_head = &slide_hash_head_neon;
  280|       |    }
  281|       |#endif
  282|       |    // ARM - NEON DotProd
  283|       |#ifdef ARM_NEON_DOTPROD
  284|       |#  ifndef ARM_NEON_DOTPROD_NATIVE
  285|       |    if (cf.arm.has_neon && cf.arm.has_dotprod)
  286|       |#  endif
  287|       |    {
  288|       |        ft.adler32 = &adler32_neon_dotprod;
  289|       |        ft.adler32_copy = &adler32_copy_neon_dotprod;
  290|       |    }
  291|       |#endif
  292|       |    // ARM - CRC32
  293|       |#if defined(ARM_CRC32) && !defined(ARM_PMULL_EOR3_NATIVE)
  294|       |#  ifndef ARM_CRC32_NATIVE
  295|       |    if (cf.arm.has_crc32)
  296|       |#  endif
  297|       |    {
  298|       |        ft.crc32 = &crc32_armv8;
  299|       |        ft.crc32_copy = &crc32_copy_armv8;
  300|       |    }
  301|       |#endif
  302|       |    // ARM - PMULL EOR3
  303|       |#ifdef ARM_PMULL_EOR3
  304|       |#  ifndef ARM_PMULL_EOR3_NATIVE
  305|       |    if (cf.arm.has_crc32 && cf.arm.has_pmull && cf.arm.has_eor3 && cf.arm.has_fast_pmull)
  306|       |#  endif
  307|       |    {
  308|       |        ft.crc32 = &crc32_armv8_pmull_eor3;
  309|       |        ft.crc32_copy = &crc32_copy_armv8_pmull_eor3;
  310|       |    }
  311|       |#endif
  312|       |
  313|       |    // Power - VMX
  314|       |#ifdef PPC_VMX
  315|       |#  ifndef PPC_VMX_NATIVE
  316|       |    if (cf.power.has_altivec)
  317|       |#  endif
  318|       |    {
  319|       |        ft.adler32 = &adler32_vmx;
  320|       |        ft.adler32_copy = &adler32_copy_vmx;
  321|       |        ft.slide_hash = &slide_hash_vmx;
  322|       |        ft.slide_hash_head = &slide_hash_head_vmx;
  323|       |    }
  324|       |#endif
  325|       |    // Power8 - VSX
  326|       |#ifdef POWER8_VSX
  327|       |#  ifndef POWER8_VSX_NATIVE
  328|       |    if (cf.power.has_arch_2_07)
  329|       |#  endif
  330|       |    {
  331|       |        ft.adler32 = &adler32_power8;
  332|       |        ft.adler32_copy = &adler32_copy_power8;
  333|       |        ft.chunkmemset_safe = &chunkmemset_safe_power8;
  334|       |        ft.inflate_fast = &inflate_fast_power8;
  335|       |        ft.slide_hash = &slide_hash_power8;
  336|       |        ft.slide_hash_head = &slide_hash_head_power8;
  337|       |    }
  338|       |#endif
  339|       |#ifdef POWER8_VSX_CRC32
  340|       |#  ifndef POWER8_VSX_CRC32_NATIVE
  341|       |    if (cf.power.has_arch_2_07)
  342|       |#  endif
  343|       |    {
  344|       |        ft.crc32 = &crc32_power8;
  345|       |        ft.crc32_copy = &crc32_copy_power8;
  346|       |    }
  347|       |#endif
  348|       |    // Power9
  349|       |#ifdef POWER9
  350|       |#  ifndef POWER9_NATIVE
  351|       |    if (cf.power.has_arch_3_00)
  352|       |#  endif
  353|       |    {
  354|       |        ft.compare256 = &compare256_power9;
  355|       |        ft.longest_match = &longest_match_power9;
  356|       |        ft.longest_match_roll = &longest_match_roll_power9;
  357|       |    }
  358|       |#endif
  359|       |
  360|       |
  361|       |    // RISCV - RVV
  362|       |#ifdef RISCV_RVV
  363|       |#  ifndef RISCV_RVV_NATIVE
  364|       |    if (cf.riscv.has_rvv)
  365|       |#  endif
  366|       |    {
  367|       |        ft.adler32 = &adler32_rvv;
  368|       |        ft.adler32_copy = &adler32_copy_rvv;
  369|       |        ft.chunkmemset_safe = &chunkmemset_safe_rvv;
  370|       |        ft.compare256 = &compare256_rvv;
  371|       |        ft.inflate_fast = &inflate_fast_rvv;
  372|       |        ft.longest_match = &longest_match_rvv;
  373|       |        ft.longest_match_roll = &longest_match_roll_rvv;
  374|       |        ft.slide_hash = &slide_hash_rvv;
  375|       |        ft.slide_hash_head = &slide_hash_head_rvv;
  376|       |    }
  377|       |#endif
  378|       |
  379|       |    // RISCV - ZBC
  380|       |#ifdef RISCV_CRC32_ZBC
  381|       |#  ifndef RISCV_ZBC_NATIVE
  382|       |    if (cf.riscv.has_zbc)
  383|       |#  endif
  384|       |    {
  385|       |        ft.crc32 = &crc32_riscv64_zbc;
  386|       |        ft.crc32_copy = &crc32_copy_riscv64_zbc;
  387|       |    }
  388|       |#endif
  389|       |
  390|       |    // S390
  391|       |#ifdef S390_VX
  392|       |#  ifndef S390_VX_NATIVE
  393|       |    if (cf.s390.has_vx)
  394|       |#  endif
  395|       |    {
  396|       |        ft.crc32 = &crc32_s390_vx;
  397|       |        ft.crc32_copy = &crc32_copy_s390_vx;
  398|       |        ft.slide_hash = &slide_hash_vx;
  399|       |        ft.slide_hash_head = &slide_hash_head_vx;
  400|       |    }
  401|       |#endif
  402|       |
  403|       |    // LOONGARCH
  404|       |#ifdef LOONGARCH_CRC
  405|       |#  ifndef LOONGARCH_CRC_NATIVE
  406|       |    if (cf.loongarch.has_crc)
  407|       |#  endif
  408|       |    {
  409|       |        ft.crc32 = &crc32_loongarch64;
  410|       |        ft.crc32_copy = &crc32_copy_loongarch64;
  411|       |    }
  412|       |#endif
  413|       |#if defined(LOONGARCH_LSX) && !defined(LOONGARCH_LASX_NATIVE)
  414|       |#  ifndef LOONGARCH_LSX_NATIVE
  415|       |    if (cf.loongarch.has_lsx)
  416|       |#  endif
  417|       |    {
  418|       |        ft.adler32 = &adler32_lsx;
  419|       |        ft.adler32_copy = &adler32_copy_lsx;
  420|       |        ft.chunkmemset_safe = &chunkmemset_safe_lsx;
  421|       |        ft.compare256 = &compare256_lsx;
  422|       |        ft.inflate_fast = &inflate_fast_lsx;
  423|       |        ft.longest_match = &longest_match_lsx;
  424|       |        ft.longest_match_roll = &longest_match_roll_lsx;
  425|       |        ft.slide_hash = &slide_hash_lsx;
  426|       |        ft.slide_hash_head = &slide_hash_head_lsx;
  427|       |    }
  428|       |#endif
  429|       |#ifdef LOONGARCH_LASX
  430|       |#  ifndef LOONGARCH_LASX_NATIVE
  431|       |    if (cf.loongarch.has_lasx)
  432|       |#  endif
  433|       |    {
  434|       |        ft.adler32 = &adler32_lasx;
  435|       |        ft.adler32_copy = &adler32_copy_lasx;
  436|       |        ft.chunkmemset_safe = &chunkmemset_safe_lasx;
  437|       |        ft.compare256 = &compare256_lasx;
  438|       |        ft.inflate_fast = &inflate_fast_lasx;
  439|       |        ft.longest_match = &longest_match_lasx;
  440|       |        ft.longest_match_roll = &longest_match_roll_lasx;
  441|       |        ft.slide_hash = &slide_hash_lasx;
  442|       |        ft.slide_hash_head = &slide_hash_head_lasx;
  443|       |    }
  444|       |#endif
  445|       |
  446|      2|#endif // WITH_OPTIM
  447|       |
  448|       |    // Assign function pointers individually for atomic operation
  449|      2|    FUNCTABLE_ASSIGN(ft, force_init);
  ------------------
  |  |   20|      2|    __atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
  ------------------
  450|      2|    FUNCTABLE_VERIFY_ASSIGN(ft, adler32);
  ------------------
  |  |   46|      2|    if (!VAR.FUNC_NAME) { \
  |  |  ------------------
  |  |  |  Branch (46:9): [True: 0, False: 2]
  |  |  ------------------
  |  |   47|      0|        fprintf(stderr, "Zlib-ng functable failed initialization!\n"); \
  |  |   48|      0|        return 1; \
  |  |   49|      0|    } \
  |  |   50|      2|    FUNCTABLE_ASSIGN(VAR, FUNC_NAME);
  |  |  ------------------
  |  |  |  |   20|      2|    __atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
  |  |  ------------------
  ------------------
  451|      2|    FUNCTABLE_VERIFY_ASSIGN(ft, adler32_copy);
  ------------------
  |  |   46|      2|    if (!VAR.FUNC_NAME) { \
  |  |  ------------------
  |  |  |  Branch (46:9): [True: 0, False: 2]
  |  |  ------------------
  |  |   47|      0|        fprintf(stderr, "Zlib-ng functable failed initialization!\n"); \
  |  |   48|      0|        return 1; \
  |  |   49|      0|    } \
  |  |   50|      2|    FUNCTABLE_ASSIGN(VAR, FUNC_NAME);
  |  |  ------------------
  |  |  |  |   20|      2|    __atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
  |  |  ------------------
  ------------------
  452|      2|    FUNCTABLE_VERIFY_ASSIGN(ft, chunkmemset_safe);
  ------------------
  |  |   46|      2|    if (!VAR.FUNC_NAME) { \
  |  |  ------------------
  |  |  |  Branch (46:9): [True: 0, False: 2]
  |  |  ------------------
  |  |   47|      0|        fprintf(stderr, "Zlib-ng functable failed initialization!\n"); \
  |  |   48|      0|        return 1; \
  |  |   49|      0|    } \
  |  |   50|      2|    FUNCTABLE_ASSIGN(VAR, FUNC_NAME);
  |  |  ------------------
  |  |  |  |   20|      2|    __atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
  |  |  ------------------
  ------------------
  453|      2|    FUNCTABLE_VERIFY_ASSIGN(ft, compare256);
  ------------------
  |  |   46|      2|    if (!VAR.FUNC_NAME) { \
  |  |  ------------------
  |  |  |  Branch (46:9): [True: 0, False: 2]
  |  |  ------------------
  |  |   47|      0|        fprintf(stderr, "Zlib-ng functable failed initialization!\n"); \
  |  |   48|      0|        return 1; \
  |  |   49|      0|    } \
  |  |   50|      2|    FUNCTABLE_ASSIGN(VAR, FUNC_NAME);
  |  |  ------------------
  |  |  |  |   20|      2|    __atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
  |  |  ------------------
  ------------------
  454|      2|    FUNCTABLE_VERIFY_ASSIGN(ft, crc32);
  ------------------
  |  |   46|      2|    if (!VAR.FUNC_NAME) { \
  |  |  ------------------
  |  |  |  Branch (46:9): [True: 0, False: 2]
  |  |  ------------------
  |  |   47|      0|        fprintf(stderr, "Zlib-ng functable failed initialization!\n"); \
  |  |   48|      0|        return 1; \
  |  |   49|      0|    } \
  |  |   50|      2|    FUNCTABLE_ASSIGN(VAR, FUNC_NAME);
  |  |  ------------------
  |  |  |  |   20|      2|    __atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
  |  |  ------------------
  ------------------
  455|      2|    FUNCTABLE_VERIFY_ASSIGN(ft, crc32_copy);
  ------------------
  |  |   46|      2|    if (!VAR.FUNC_NAME) { \
  |  |  ------------------
  |  |  |  Branch (46:9): [True: 0, False: 2]
  |  |  ------------------
  |  |   47|      0|        fprintf(stderr, "Zlib-ng functable failed initialization!\n"); \
  |  |   48|      0|        return 1; \
  |  |   49|      0|    } \
  |  |   50|      2|    FUNCTABLE_ASSIGN(VAR, FUNC_NAME);
  |  |  ------------------
  |  |  |  |   20|      2|    __atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
  |  |  ------------------
  ------------------
  456|      2|    FUNCTABLE_VERIFY_ASSIGN(ft, inflate_fast);
  ------------------
  |  |   46|      2|    if (!VAR.FUNC_NAME) { \
  |  |  ------------------
  |  |  |  Branch (46:9): [True: 0, False: 2]
  |  |  ------------------
  |  |   47|      0|        fprintf(stderr, "Zlib-ng functable failed initialization!\n"); \
  |  |   48|      0|        return 1; \
  |  |   49|      0|    } \
  |  |   50|      2|    FUNCTABLE_ASSIGN(VAR, FUNC_NAME);
  |  |  ------------------
  |  |  |  |   20|      2|    __atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
  |  |  ------------------
  ------------------
  457|      2|    FUNCTABLE_VERIFY_ASSIGN(ft, longest_match);
  ------------------
  |  |   46|      2|    if (!VAR.FUNC_NAME) { \
  |  |  ------------------
  |  |  |  Branch (46:9): [True: 0, False: 2]
  |  |  ------------------
  |  |   47|      0|        fprintf(stderr, "Zlib-ng functable failed initialization!\n"); \
  |  |   48|      0|        return 1; \
  |  |   49|      0|    } \
  |  |   50|      2|    FUNCTABLE_ASSIGN(VAR, FUNC_NAME);
  |  |  ------------------
  |  |  |  |   20|      2|    __atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
  |  |  ------------------
  ------------------
  458|      2|    FUNCTABLE_VERIFY_ASSIGN(ft, longest_match_roll);
  ------------------
  |  |   46|      2|    if (!VAR.FUNC_NAME) { \
  |  |  ------------------
  |  |  |  Branch (46:9): [True: 0, False: 2]
  |  |  ------------------
  |  |   47|      0|        fprintf(stderr, "Zlib-ng functable failed initialization!\n"); \
  |  |   48|      0|        return 1; \
  |  |   49|      0|    } \
  |  |   50|      2|    FUNCTABLE_ASSIGN(VAR, FUNC_NAME);
  |  |  ------------------
  |  |  |  |   20|      2|    __atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
  |  |  ------------------
  ------------------
  459|      2|    FUNCTABLE_VERIFY_ASSIGN(ft, slide_hash);
  ------------------
  |  |   46|      2|    if (!VAR.FUNC_NAME) { \
  |  |  ------------------
  |  |  |  Branch (46:9): [True: 0, False: 2]
  |  |  ------------------
  |  |   47|      0|        fprintf(stderr, "Zlib-ng functable failed initialization!\n"); \
  |  |   48|      0|        return 1; \
  |  |   49|      0|    } \
  |  |   50|      2|    FUNCTABLE_ASSIGN(VAR, FUNC_NAME);
  |  |  ------------------
  |  |  |  |   20|      2|    __atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
  |  |  ------------------
  ------------------
  460|      2|    FUNCTABLE_VERIFY_ASSIGN(ft, slide_hash_head);
  ------------------
  |  |   46|      2|    if (!VAR.FUNC_NAME) { \
  |  |  ------------------
  |  |  |  Branch (46:9): [True: 0, False: 2]
  |  |  ------------------
  |  |   47|      0|        fprintf(stderr, "Zlib-ng functable failed initialization!\n"); \
  |  |   48|      0|        return 1; \
  |  |   49|      0|    } \
  |  |   50|      2|    FUNCTABLE_ASSIGN(VAR, FUNC_NAME);
  |  |  ------------------
  |  |  |  |   20|      2|    __atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
  |  |  ------------------
  ------------------
  461|       |
  462|       |    // Memory barrier for weak memory order CPUs
  463|      2|    FUNCTABLE_BARRIER();
  ------------------
  |  |   21|      2|#  define FUNCTABLE_BARRIER() __atomic_thread_fence(__ATOMIC_SEQ_CST)
  ------------------
  464|       |
  465|      2|    return Z_OK;
  ------------------
  |  |  180|      2|#define Z_OK            0
  ------------------
  466|      2|}
functable.c:force_init_empty:
   63|  3.16k|static int force_init_empty(void) {
   64|  3.16k|    return 0;
   65|  3.16k|}

inflate_fast_avx2:
   52|  7.65k|void Z_INTERNAL INFLATE_FAST(PREFIX3(stream) *strm, uint32_t start, int safe_mode) {
   53|       |    /* start: inflate()'s starting value for strm->avail_out */
   54|  7.65k|    struct inflate_state *state;
   55|  7.65k|    z_const unsigned char *in;  /* local strm->next_in */
  ------------------
  |  |   24|  7.65k|#define z_const const
  ------------------
   56|  7.65k|    const unsigned char *last;  /* have enough input while in < last */
   57|  7.65k|    unsigned char *out;         /* local strm->next_out */
   58|  7.65k|    unsigned char *beg;         /* inflate()'s initial strm->next_out */
   59|  7.65k|    unsigned char *end;         /* while out < end, enough space available */
   60|  7.65k|    unsigned char *safe;        /* can use chunkcopy provided out < safe */
   61|  7.65k|    unsigned char *window;      /* allocated sliding window, if wsize != 0 */
   62|  7.65k|    unsigned wsize;             /* window size or zero if not using window */
   63|  7.65k|    unsigned whave;             /* valid bytes in the window */
   64|  7.65k|    unsigned wnext;             /* window write index */
   65|       |
   66|       |    /* hold is a local copy of strm->hold. By default, hold satisfies the same
   67|       |       invariants that strm->hold does, namely that (hold >> bits) == 0. This
   68|       |       invariant is kept by loading bits into hold one byte at a time, like:
   69|       |
   70|       |       hold |= next_byte_of_input << bits; in++; bits += 8;
   71|       |
   72|       |       If we need to ensure that bits >= 15 then this code snippet is simply
   73|       |       repeated. Over one iteration of the outermost do/while loop, this
   74|       |       happens up to six times (48 bits of input), as described in the NOTES
   75|       |       above.
   76|       |
   77|       |       However, on some little endian architectures, it can be significantly
   78|       |       faster to load 64 bits once instead of 8 bits six times:
   79|       |
   80|       |       if (bits <= 16) {
   81|       |         hold |= next_8_bytes_of_input << bits; in += 6; bits += 48;
   82|       |       }
   83|       |
   84|       |       Unlike the simpler one byte load, shifting the next_8_bytes_of_input
   85|       |       by bits will overflow and lose those high bits, up to 2 bytes' worth.
   86|       |       The conservative estimate is therefore that we have read only 6 bytes
   87|       |       (48 bits). Again, as per the NOTES above, 48 bits is sufficient for the
   88|       |       rest of the iteration, and we will not need to load another 8 bytes.
   89|       |
   90|       |       Inside this function, we no longer satisfy (hold >> bits) == 0, but
   91|       |       this is not problematic, even if that overflow does not land on an 8 bit
   92|       |       byte boundary. Those excess bits will eventually shift down lower as the
   93|       |       Huffman decoder consumes input, and when new input bits need to be loaded
   94|       |       into the bits variable, the same input bits will be or'ed over those
   95|       |       existing bits. A bitwise or is idempotent: (a | b | b) equals (a | b).
   96|       |       Note that we therefore write that load operation as "hold |= etc" and not
   97|       |       "hold += etc".
   98|       |
   99|       |       Outside that loop, at the end of the function, hold is bitwise and'ed
  100|       |       with (1<<bits)-1 to drop those excess bits so that, on function exit, we
  101|       |       keep the invariant that (state->hold >> state->bits) == 0.
  102|       |    */
  103|  7.65k|    bits_t bits;                /* local strm->bits */
  104|  7.65k|    uint64_t hold;              /* local strm->hold */
  105|  7.65k|    unsigned lmask;             /* mask for first level of length codes */
  106|  7.65k|    unsigned dmask;             /* mask for first level of distance codes */
  107|  7.65k|    code const *lcode;          /* local strm->lencode */
  108|  7.65k|    code const *dcode;          /* local strm->distcode */
  109|  7.65k|    code here;                  /* retrieved table entry */
  110|  7.65k|    unsigned op;                /* code bits, operation, extra bits, or */
  111|       |                                /*  window position, window bytes to copy */
  112|  7.65k|    unsigned len;               /* match length, unused bytes */
  113|  7.65k|    unsigned char *from;        /* where to copy match from */
  114|  7.65k|    unsigned dist;              /* match distance */
  115|  7.65k|    uint64_t old;               /* look-behind buffer for extra bits */
  116|       |
  117|       |    /* copy state to local variables */
  118|  7.65k|    state = (struct inflate_state *)strm->state;
  119|  7.65k|    in = strm->next_in;
  120|  7.65k|    last = in + (strm->avail_in - (INFLATE_FAST_MIN_HAVE - 1));
  ------------------
  |  |  201|  7.65k|#define INFLATE_FAST_MIN_HAVE 15
  ------------------
  121|  7.65k|    out = strm->next_out;
  122|  7.65k|    beg = out - (start - strm->avail_out);
  123|  7.65k|    safe = out + strm->avail_out;
  124|  7.65k|    end = safe - (safe_mode ? INFLATE_FAST_MIN_SAFE : INFLATE_FAST_MIN_LEFT) + 1;
  ------------------
  |  |  203|  3.05k|#define INFLATE_FAST_MIN_SAFE 3    /* max unchecked literal writes per iteration */
  ------------------
                  end = safe - (safe_mode ? INFLATE_FAST_MIN_SAFE : INFLATE_FAST_MIN_LEFT) + 1;
  ------------------
  |  |  202|  4.59k|#define INFLATE_FAST_MIN_LEFT 260  /* max output per token (258) + 2 */
  ------------------
  |  Branch (124:19): [True: 3.05k, False: 4.59k]
  ------------------
  125|  7.65k|    wsize = state->wsize;
  126|  7.65k|    whave = state->whave;
  127|  7.65k|    wnext = state->wnext;
  128|  7.65k|    window = state->window;
  129|  7.65k|    hold = state->hold;
  130|  7.65k|    bits = (bits_t)state->bits;
  131|  7.65k|    lcode = state->lencode;
  132|  7.65k|    dcode = state->distcode;
  133|  7.65k|    lmask = (1U << state->lenbits) - 1;
  134|  7.65k|    dmask = (1U << state->distbits) - 1;
  135|       |
  136|       |    /* Ensure enough bits for the first length table lookup. Every refill after
  137|       |       this one is issued behind a table lookup that only needs bits already in
  138|       |       hold, so the refill's load latency overlaps with the table load instead
  139|       |       of feeding it. */
  140|  7.65k|    REFILL();
  ------------------
  |  |  104|  7.65k|#define REFILL() do { \
  |  |  105|  7.65k|        hold |= load_64_bits(in, bits); \
  |  |  106|  7.65k|        in += (63 ^ bits) >> 3; \
  |  |  107|  7.65k|        bits |= 56; \
  |  |  108|  7.65k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (108:14): [Folded, False: 7.65k]
  |  |  ------------------
  ------------------
  141|       |
  142|       |    /* decode literals and length/distances until end-of-block or not enough
  143|       |       input data or output space */
  144|  1.84M|    do {
  145|       |        /* This lookup needs bits >= MAX_LEN_ROOT_BITS, which every path here
  146|       |           guarantees: each refill leaves bits >= 56, the literal-only paths
  147|       |           loop after consuming at most 35 bits, and the distance path refills
  148|       |           to at least MAX_BITS + MAX_DIST_EXTRA_BITS + MAX_LEN_ROOT_BITS
  149|       |           before consuming at most MAX_BITS + MAX_DIST_EXTRA_BITS. */
  150|  1.84M|        here = lcode[hold & lmask];
  151|  1.84M|        Z_TOUCH(here);
  ------------------
  |  |  161|  1.84M|#  define Z_TOUCH(var) __asm__ ("" : "+r"(var))
  ------------------
  152|       |        /* No-op on the first iteration: the pre-loop refill already filled hold
  153|       |           and the lookup above consumes nothing, so bits is still >= 56. Tops
  154|       |           hold back up on every later iteration. */
  155|  1.84M|        REFILL();
  ------------------
  |  |  104|  1.84M|#define REFILL() do { \
  |  |  105|  1.84M|        hold |= load_64_bits(in, bits); \
  |  |  106|  1.84M|        in += (63 ^ bits) >> 3; \
  |  |  107|  1.84M|        bits |= 56; \
  |  |  108|  1.84M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (108:14): [Folded, False: 1.84M]
  |  |  ------------------
  ------------------
  156|  1.84M|        old = hold;
  157|  1.84M|        DROPBITS(here.bits);
  ------------------
  |  |  132|  1.84M|    do { \
  |  |  133|  1.84M|        unsigned u = (unsigned)(n); \
  |  |  134|  1.84M|        hold >>= u; \
  |  |  135|  1.84M|        bits -= (bits_t)u; \
  |  |  136|  1.84M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 1.84M]
  |  |  ------------------
  ------------------
  158|  1.84M|        if (LIKELY(here.op == 0)) {
  ------------------
  |  |  257|  1.84M|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 1.90k, False: 1.83M]
  |  |  ------------------
  ------------------
  159|  1.90k|            TRACE_LITERAL(here.val);
  160|  1.90k|            *out++ = (unsigned char)(here.val);
  161|  1.90k|            here = lcode[hold & lmask];
  162|  1.90k|            Z_TOUCH(here);
  ------------------
  |  |  161|  1.90k|#  define Z_TOUCH(var) __asm__ ("" : "+r"(var))
  ------------------
  163|  1.90k|            old = hold;
  164|  1.90k|            DROPBITS(here.bits);
  ------------------
  |  |  132|  1.90k|    do { \
  |  |  133|  1.90k|        unsigned u = (unsigned)(n); \
  |  |  134|  1.90k|        hold >>= u; \
  |  |  135|  1.90k|        bits -= (bits_t)u; \
  |  |  136|  1.90k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 1.90k]
  |  |  ------------------
  ------------------
  165|  1.90k|            if (LIKELY(here.op == 0)) {
  ------------------
  |  |  257|  1.90k|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 1.71k, False: 186]
  |  |  ------------------
  ------------------
  166|  1.71k|                TRACE_LITERAL(here.val);
  167|  1.71k|                *out++ = (unsigned char)(here.val);
  168|  1.71k|                here = lcode[hold & lmask];
  169|  1.71k|                Z_TOUCH(here);
  ------------------
  |  |  161|  1.71k|#  define Z_TOUCH(var) __asm__ ("" : "+r"(var))
  ------------------
  170|  1.71k|            dolen:
  171|  1.71k|                old = hold;
  172|  1.71k|                DROPBITS(here.bits);
  ------------------
  |  |  132|  1.71k|    do { \
  |  |  133|  1.71k|        unsigned u = (unsigned)(n); \
  |  |  134|  1.71k|        hold >>= u; \
  |  |  135|  1.71k|        bits -= (bits_t)u; \
  |  |  136|  1.71k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 1.71k]
  |  |  ------------------
  ------------------
  173|  1.71k|                if (LIKELY(here.op == 0)) {
  ------------------
  |  |  257|  1.71k|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 136, False: 1.58k]
  |  |  ------------------
  ------------------
  174|    136|                    TRACE_LITERAL(here.val);
  175|    136|                    *out++ = (unsigned char)(here.val);
  176|    136|                    continue;
  177|    136|                }
  178|  1.71k|            }
  179|  1.90k|        }
  180|  1.84M|        op = here.op;
  181|  1.84M|        if (LIKELY(op & 16)) {                  /* length base */
  ------------------
  |  |  257|  1.84M|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 1.83M, False: 1.58k]
  |  |  ------------------
  ------------------
  182|  1.83M|            len = here.val + EXTRA_BITS(old, here, op);
  ------------------
  |  |  170|  1.83M|    ((old & (((uint64_t)1 << here.bits) - 1)) >> (op & MAX_BITS))
  |  |  ------------------
  |  |  |  |   41|  1.83M|#define MAX_BITS 15
  |  |  ------------------
  ------------------
  183|  1.83M|            TRACE_LENGTH(len);
  184|  1.83M|            here = dcode[hold & dmask];
  185|  1.83M|            Z_TOUCH(here);
  ------------------
  |  |  161|  1.83M|#  define Z_TOUCH(var) __asm__ ("" : "+r"(var))
  ------------------
  186|       |            /* Reserve bits for the distance code and its extra bits, plus the
  187|       |               next iteration's length table lookup, which happens before the
  188|       |               next refill. */
  189|  1.83M|            if (UNLIKELY(bits < MAX_BITS + MAX_DIST_EXTRA_BITS + MAX_LEN_ROOT_BITS)) {
  ------------------
  |  |  258|  1.83M|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 295, False: 1.83M]
  |  |  ------------------
  ------------------
  190|    295|                REFILL();
  ------------------
  |  |  104|    295|#define REFILL() do { \
  |  |  105|    295|        hold |= load_64_bits(in, bits); \
  |  |  106|    295|        in += (63 ^ bits) >> 3; \
  |  |  107|    295|        bits |= 56; \
  |  |  108|    295|    } while (0)
  |  |  ------------------
  |  |  |  Branch (108:14): [Folded, False: 295]
  |  |  ------------------
  ------------------
  191|    295|            }
  192|  1.83M|          dodist:
  193|  1.83M|            old = hold;
  194|  1.83M|            DROPBITS(here.bits);
  ------------------
  |  |  132|  1.83M|    do { \
  |  |  133|  1.83M|        unsigned u = (unsigned)(n); \
  |  |  134|  1.83M|        hold >>= u; \
  |  |  135|  1.83M|        bits -= (bits_t)u; \
  |  |  136|  1.83M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 1.83M]
  |  |  ------------------
  ------------------
  195|  1.83M|            op = here.op;
  196|  1.83M|            if (LIKELY(op & 16)) {              /* distance base */
  ------------------
  |  |  257|  1.83M|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 1.83M, False: 0]
  |  |  ------------------
  ------------------
  197|  1.83M|                dist = here.val + EXTRA_BITS(old, here, op);
  ------------------
  |  |  170|  1.83M|    ((old & (((uint64_t)1 << here.bits) - 1)) >> (op & MAX_BITS))
  |  |  ------------------
  |  |  |  |   41|  1.83M|#define MAX_BITS 15
  |  |  ------------------
  ------------------
  198|       |#ifdef INFLATE_STRICT
  199|       |                if (UNLIKELY(dist > state->dmax)) {
  200|       |                    SET_BAD("invalid distance too far back");
  201|       |                    break;
  202|       |                }
  203|       |#endif
  204|  1.83M|                TRACE_DISTANCE(dist);
  205|       |
  206|       |                /* In safe mode, if there isn't enough output space for the full copy,
  207|       |                   bail to the slow path's MATCH state which handles partial copies. */
  208|  1.83M|                if (UNLIKELY(safe_mode && len > (unsigned)(safe - out))) {
  ------------------
  |  |  258|  1.84M|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 1.53k, False: 1.83M]
  |  |  |  Branch (258:53): [True: 3.00k, False: 1.83M]
  |  |  |  Branch (258:53): [True: 1.53k, False: 1.47k]
  |  |  ------------------
  ------------------
  209|  1.53k|                    state->mode = MATCH;
  210|  1.53k|                    state->length = len;
  211|  1.53k|                    state->offset = dist;
  212|  1.53k|                    break;
  213|  1.53k|                }
  214|       |
  215|  1.83M|                op = (unsigned)(out - beg);     /* max distance in output */
  216|  1.83M|                if (UNLIKELY(dist > op)) {      /* see if copy from window */
  ------------------
  |  |  258|  1.83M|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 1.15k, False: 1.83M]
  |  |  ------------------
  ------------------
  217|  1.15k|                    op = dist - op;             /* distance back in window */
  218|  1.15k|                    if (UNLIKELY(op > whave)) {
  ------------------
  |  |  258|  1.15k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 1.15k]
  |  |  ------------------
  ------------------
  219|       |#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
  220|       |                        if (LIKELY(state->sane)) {
  221|       |                            SET_BAD("invalid distance too far back");
  222|       |                            break;
  223|       |                        }
  224|       |                        unsigned gap = op - whave;
  225|       |                        unsigned zeros = MIN(len, gap);
  226|       |                        memset(out, 0, zeros);  /* fill missing bytes with zeros */
  227|       |                        out += zeros;
  228|       |                        len -= zeros;
  229|       |                        if (UNLIKELY(len == 0))
  230|       |                            continue;
  231|       |                        op = whave;
  232|       |                        if (UNLIKELY(op == 0)) {/* copy from already-decoded output */
  233|       |                            out = chunkcopy_safe(out, out - dist, len, safe);
  234|       |                            continue;
  235|       |                        }
  236|       |#else
  237|      0|                        SET_BAD("invalid distance too far back");
  ------------------
  |  |  147|      0|    do { \
  |  |  148|      0|        state->mode = BAD; \
  |  |  149|      0|        strm->msg = (z_const char *)errmsg; \
  |  |  150|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (150:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  238|      0|                        break;
  239|      0|#endif
  240|      0|                    }
  241|  1.15k|                    from = window;
  242|  1.15k|                    if (LIKELY(wnext == 0)) {           /* very common case */
  ------------------
  |  |  257|  1.15k|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 499, False: 654]
  |  |  ------------------
  ------------------
  243|    499|                        from += wsize - op;
  244|    654|                    } else if (LIKELY(wnext >= op)) {   /* contiguous in window */
  ------------------
  |  |  257|    654|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 654, False: 0]
  |  |  ------------------
  ------------------
  245|    654|                        from += wnext - op;
  246|    654|                    } else {                            /* wrap around window */
  247|      0|                        op -= wnext;
  248|      0|                        from += wsize - op;
  249|      0|                        if (UNLIKELY(op < len)) {       /* some from end of window */
  ------------------
  |  |  258|      0|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  250|      0|                            len -= op;
  251|      0|                            out = CHUNKCOPY_SAFE(out, from, op, safe);
  252|      0|                            from = window;              /* more from start of window */
  253|      0|                            op = wnext;
  254|       |                            /* This (rare) case can create a situation where
  255|       |                               the first chunkcopy below must be checked.
  256|       |                             */
  257|      0|                        }
  258|      0|                    }
  259|  1.15k|                    if (UNLIKELY(op < len)) {           /* still need some from output */
  ------------------
  |  |  258|  1.15k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 1.15k]
  |  |  ------------------
  ------------------
  260|      0|                        len -= op;
  261|      0|                        if (LIKELY(!safe_mode)) {
  ------------------
  |  |  257|      0|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  262|      0|                            out = CHUNKCOPY_SAFE(out, from, op, safe);
  263|      0|                            out = CHUNKUNROLL(out, &dist, &len);
  ------------------
  |  |  124|      0|#define CHUNKUNROLL      chunkunroll_avx2
  ------------------
  264|      0|                            out = CHUNKCOPY_SAFE(out, out - dist, len, safe);
  265|      0|                        } else {
  266|       |#ifdef HAVE_MASKED_READWRITE
  267|       |                            out = CHUNKCOPY_SAFE(out, from, op, safe);
  268|       |                            out = CHUNKCOPY_SAFE(out, out - dist, len, safe);
  269|       |#else
  270|      0|                            out = chunkcopy_safe(out, from, op, safe);
  271|      0|                            out = chunkcopy_safe(out, out - dist, len, safe);
  272|      0|#endif
  273|      0|                        }
  274|  1.15k|                    } else {
  275|       |#ifdef HAVE_MASKED_READWRITE
  276|       |                        out = CHUNKCOPY_SAFE(out, from, len, safe);
  277|       |#else
  278|  1.15k|                        if (LIKELY(!safe_mode))
  ------------------
  |  |  257|  1.15k|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 1.15k, False: 0]
  |  |  ------------------
  ------------------
  279|  1.15k|                            out = CHUNKCOPY_SAFE(out, from, len, safe);
  280|      0|                        else
  281|      0|                            out = chunkcopy_safe(out, from, len, safe);
  282|  1.15k|#endif
  283|  1.15k|                    }
  284|  1.83M|                } else if (LIKELY(!safe_mode)) {
  ------------------
  |  |  257|  1.83M|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 1.83M, False: 1.47k]
  |  |  ------------------
  ------------------
  285|       |                    /* Whole reference is in range of current output.  No range checks are
  286|       |                       necessary because we start with room for at least 258 bytes of output,
  287|       |                       so unroll and roundoff operations can write beyond `out+len` so long
  288|       |                       as they stay within 258 bytes of `out`.
  289|       |                    */
  290|  1.83M|                    if (LIKELY(dist >= len || dist >= CHUNKSIZE()))
  ------------------
  |  |  257|  3.67M|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 225, False: 1.83M]
  |  |  |  Branch (257:53): [True: 225, False: 1.83M]
  |  |  |  Branch (257:53): [True: 0, False: 1.83M]
  |  |  ------------------
  ------------------
  291|    225|                        out = CHUNKCOPY(out, out - dist, len);
  ------------------
  |  |  123|    225|#define CHUNKCOPY        chunkcopy_avx2
  ------------------
  292|  1.83M|                    else
  293|  1.83M|                        out = CHUNKMEMSET(out, out - dist, len);
  ------------------
  |  |  125|  1.83M|#define CHUNKMEMSET      chunkmemset_avx2
  ------------------
  294|  1.83M|                } else {
  295|       |#ifdef HAVE_MASKED_READWRITE
  296|       |                    out = CHUNKCOPY_SAFE(out, out - dist, len, safe);
  297|       |#else
  298|  1.47k|                    out = chunkcopy_safe(out, out - dist, len, safe);
  299|  1.47k|#endif
  300|  1.47k|                }
  301|  1.83M|            } else if (UNLIKELY((op & 64) == 0)) {          /* 2nd level distance code */
  ------------------
  |  |  258|      0|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  302|      0|                here = dcode[here.val + BITS(op)];
  ------------------
  |  |  128|      0|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  303|      0|                Z_TOUCH(here);
  ------------------
  |  |  161|      0|#  define Z_TOUCH(var) __asm__ ("" : "+r"(var))
  ------------------
  304|      0|                goto dodist;
  305|      0|            } else {
  306|      0|                SET_BAD("invalid distance code");
  ------------------
  |  |  147|      0|    do { \
  |  |  148|      0|        state->mode = BAD; \
  |  |  149|      0|        strm->msg = (z_const char *)errmsg; \
  |  |  150|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (150:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  307|      0|                break;
  308|      0|            }
  309|  1.83M|        } else if (UNLIKELY((op & 64) == 0)) {              /* 2nd level length code */
  ------------------
  |  |  258|  1.58k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 1.58k]
  |  |  ------------------
  ------------------
  310|      0|            here = lcode[here.val + BITS(op)];
  ------------------
  |  |  128|      0|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  311|      0|            Z_TOUCH(here);
  ------------------
  |  |  161|      0|#  define Z_TOUCH(var) __asm__ ("" : "+r"(var))
  ------------------
  312|      0|            goto dolen;
  313|  1.58k|        } else if (UNLIKELY(op & 32)) {                     /* end-of-block */
  ------------------
  |  |  258|  1.58k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 1.58k, False: 0]
  |  |  ------------------
  ------------------
  314|  1.58k|            TRACE_END_OF_BLOCK();
  315|  1.58k|            state->mode = TYPE;
  316|  1.58k|            break;
  317|  1.58k|        } else {
  318|      0|            SET_BAD("invalid literal/length code");
  ------------------
  |  |  147|      0|    do { \
  |  |  148|      0|        state->mode = BAD; \
  |  |  149|      0|        strm->msg = (z_const char *)errmsg; \
  |  |  150|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (150:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  319|      0|            break;
  320|      0|        }
  321|  1.84M|    } while (in < last && out < end);
  ------------------
  |  Branch (321:14): [True: 1.83M, False: 0]
  |  Branch (321:27): [True: 1.83M, False: 4.54k]
  ------------------
  322|       |
  323|       |    /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
  324|  7.65k|    len = bits >> 3;
  325|  7.65k|    in -= len;
  326|  7.65k|    bits -= (bits_t)(len << 3);
  327|  7.65k|    hold &= (UINT64_C(1) << bits) - 1;
  328|       |
  329|       |    /* update state and return */
  330|  7.65k|    strm->next_in = in;
  331|  7.65k|    strm->next_out = out;
  332|  7.65k|    strm->avail_in = (unsigned)(in < last ? (INFLATE_FAST_MIN_HAVE - 1) + (last - in)
  ------------------
  |  |  201|  7.65k|#define INFLATE_FAST_MIN_HAVE 15
  ------------------
  |  Branch (332:33): [True: 7.65k, False: 0]
  ------------------
  333|  7.65k|                                          : (INFLATE_FAST_MIN_HAVE - 1) - (in - last));
  ------------------
  |  |  201|      0|#define INFLATE_FAST_MIN_HAVE 15
  ------------------
  334|  7.65k|    strm->avail_out = (unsigned)(safe - out);
  335|       |
  336|  7.65k|    Assert(bits <= 32, "Remaining bits greater than 32");
  337|  7.65k|    state->hold = (uint32_t)hold;
  338|  7.65k|    state->bits = bits;
  339|  7.65k|    return;
  340|  7.65k|}

zng_inflateResetKeep:
   63|  1.58k|int32_t Z_EXPORT PREFIX(inflateResetKeep)(PREFIX3(stream) *strm) {
   64|  1.58k|    struct inflate_state *state;
   65|       |
   66|  1.58k|    if (inflateStateCheck(strm))
  ------------------
  |  Branch (66:9): [True: 0, False: 1.58k]
  ------------------
   67|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
   68|  1.58k|    state = (struct inflate_state *)strm->state;
   69|  1.58k|    strm->total_in = strm->total_out = state->total = 0;
   70|  1.58k|    strm->msg = NULL;
   71|  1.58k|    strm->data_type = 0;
   72|  1.58k|    if (state->wrap)        /* to support ill-conceived Java test suite */
  ------------------
  |  Branch (72:9): [True: 1.58k, False: 0]
  ------------------
   73|  1.58k|        strm->adler = state->wrap & 1;
   74|  1.58k|    state->mode = HEAD;
   75|  1.58k|    state->check = ADLER32_INITIAL_VALUE;
  ------------------
  |  |   70|  1.58k|#define ADLER32_INITIAL_VALUE 1 /* initial adler-32 hash value */
  ------------------
   76|  1.58k|    state->last = 0;
   77|  1.58k|    state->havedict = 0;
   78|  1.58k|    state->flags = -1;
   79|  1.58k|    state->head = NULL;
   80|  1.58k|    state->hold = 0;
   81|  1.58k|    state->bits = 0;
   82|  1.58k|    state->lencode = state->distcode = state->next = state->codes;
   83|  1.58k|    state->back = -1;
   84|       |#ifdef INFLATE_STRICT
   85|       |    state->dmax = 32768U;
   86|       |#endif
   87|       |#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
   88|       |    state->sane = 1;
   89|       |#endif
   90|  1.58k|    INFLATE_RESET_KEEP_HOOK(strm);  /* hook for IBM Z DFLTCC */
  ------------------
  |  |   28|  1.58k|#  define INFLATE_RESET_KEEP_HOOK(strm) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (28:54): [Folded, False: 1.58k]
  |  |  ------------------
  ------------------
   91|  1.58k|    Tracev((stderr, "inflate: reset\n"));
   92|  1.58k|    return Z_OK;
  ------------------
  |  |  180|  1.58k|#define Z_OK            0
  ------------------
   93|  1.58k|}
zng_inflateReset:
   95|  1.58k|int32_t Z_EXPORT PREFIX(inflateReset)(PREFIX3(stream) *strm) {
   96|  1.58k|    struct inflate_state *state;
   97|       |
   98|  1.58k|    if (inflateStateCheck(strm))
  ------------------
  |  Branch (98:9): [True: 0, False: 1.58k]
  ------------------
   99|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  100|  1.58k|    state = (struct inflate_state *)strm->state;
  101|  1.58k|    state->wsize = 0;
  102|  1.58k|    state->whave = 0;
  103|  1.58k|    state->wnext = 0;
  104|  1.58k|    return PREFIX(inflateResetKeep)(strm);
  ------------------
  |  |  121|  1.58k|#  define PREFIX(x) zng_ ## x
  ------------------
  105|  1.58k|}
zng_inflateReset2:
  107|  1.58k|int32_t Z_EXPORT PREFIX(inflateReset2)(PREFIX3(stream) *strm, int32_t windowBits) {
  108|  1.58k|    int wrap;
  109|  1.58k|    struct inflate_state *state;
  110|       |
  111|       |    /* get the state */
  112|  1.58k|    if (inflateStateCheck(strm))
  ------------------
  |  Branch (112:9): [True: 0, False: 1.58k]
  ------------------
  113|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  114|  1.58k|    state = (struct inflate_state *)strm->state;
  115|       |
  116|       |    /* extract wrap request from windowBits parameter */
  117|  1.58k|    if (windowBits < 0) {
  ------------------
  |  Branch (117:9): [True: 0, False: 1.58k]
  ------------------
  118|      0|        wrap = 0;
  119|      0|        if (windowBits < -MAX_WBITS)
  ------------------
  |  |   40|      0|#  define MAX_WBITS   15 /* 32K LZ77 window */
  ------------------
  |  Branch (119:13): [True: 0, False: 0]
  ------------------
  120|      0|            return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  121|      0|        windowBits = -windowBits;
  122|  1.58k|    } else {
  123|  1.58k|        wrap = (windowBits >> 4) + 5;
  124|  1.58k|#ifdef GUNZIP
  125|  1.58k|        if (windowBits < 48)
  ------------------
  |  Branch (125:13): [True: 1.58k, False: 0]
  ------------------
  126|  1.58k|            windowBits &= MAX_WBITS;
  ------------------
  |  |   40|  1.58k|#  define MAX_WBITS   15 /* 32K LZ77 window */
  ------------------
  127|  1.58k|#endif
  128|  1.58k|    }
  129|       |
  130|       |    /* set number of window bits */
  131|  1.58k|    if (windowBits && (windowBits < MIN_WBITS || windowBits > MAX_WBITS))
  ------------------
  |  |   37|  3.16k|#  define MIN_WBITS   8  /* 256 LZ77 window */
  ------------------
                  if (windowBits && (windowBits < MIN_WBITS || windowBits > MAX_WBITS))
  ------------------
  |  |   40|  1.58k|#  define MAX_WBITS   15 /* 32K LZ77 window */
  ------------------
  |  Branch (131:9): [True: 1.58k, False: 0]
  |  Branch (131:24): [True: 0, False: 1.58k]
  |  Branch (131:50): [True: 0, False: 1.58k]
  ------------------
  132|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  133|       |
  134|       |    /* update state and reset the rest of it */
  135|  1.58k|    state->wrap = wrap;
  136|  1.58k|    state->wbits = (unsigned)windowBits;
  137|  1.58k|    return PREFIX(inflateReset)(strm);
  ------------------
  |  |  121|  1.58k|#  define PREFIX(x) zng_ ## x
  ------------------
  138|  1.58k|}
alloc_inflate:
  155|  1.58k|Z_INTERNAL inflate_allocs* alloc_inflate(PREFIX3(stream) *strm) {
  156|  1.58k|    int curr_size = 0;
  157|       |
  158|       |    /* Define sizes */
  159|  1.58k|    int window_size = INFLATE_ADJUST_WINDOW_SIZE((1 << MAX_WBITS) + 64); /* 64B padding for chunksize */
  ------------------
  |  |   26|  1.58k|#  define INFLATE_ADJUST_WINDOW_SIZE(n) (n)
  ------------------
  160|  1.58k|    int state_size = sizeof(inflate_state);
  161|  1.58k|    int alloc_size = sizeof(inflate_allocs);
  162|       |
  163|       |    /* Calculate relative buffer positions and paddings */
  164|  1.58k|    LOGSZP("window", window_size, PAD_WINDOW(curr_size), PADSZ(curr_size,WINDOW_PAD_SIZE));
  165|  1.58k|    int window_pos = PAD_WINDOW(curr_size);
  ------------------
  |  |  465|  1.58k|#  define PAD_WINDOW            PAD_64
  |  |  ------------------
  |  |  |  |  301|  1.58k|#define PAD_64(bpos) ((bpos) + PADSZ((bpos),64))
  |  |  |  |  ------------------
  |  |  |  |  |  |  299|  1.58k|#define PADSZ(bpos, pad) (((pad) - ((uintptr_t)(bpos) % (pad))) % (pad))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  166|  1.58k|    curr_size = window_pos + window_size;
  167|       |
  168|  1.58k|    LOGSZP("state", state_size, PAD_64(curr_size), PADSZ(curr_size,64));
  169|  1.58k|    int state_pos = PAD_64(curr_size);
  ------------------
  |  |  301|  1.58k|#define PAD_64(bpos) ((bpos) + PADSZ((bpos),64))
  |  |  ------------------
  |  |  |  |  299|  1.58k|#define PADSZ(bpos, pad) (((pad) - ((uintptr_t)(bpos) % (pad))) % (pad))
  |  |  ------------------
  ------------------
  170|  1.58k|    curr_size = state_pos + state_size;
  171|       |
  172|  1.58k|    LOGSZP("alloc", alloc_size, PAD_16(curr_size), PADSZ(curr_size,16));
  173|  1.58k|    int alloc_pos = PAD_16(curr_size);
  ------------------
  |  |  300|  1.58k|#define PAD_16(bpos) ((bpos) + PADSZ((bpos),16))
  |  |  ------------------
  |  |  |  |  299|  1.58k|#define PADSZ(bpos, pad) (((pad) - ((uintptr_t)(bpos) % (pad))) % (pad))
  |  |  ------------------
  ------------------
  174|  1.58k|    curr_size = alloc_pos + alloc_size;
  175|       |
  176|       |    /* Add 64-1 or 4096-1 to allow window alignment, and round size of buffer up to multiple of 64 */
  177|  1.58k|    int total_size = PAD_64(curr_size + (WINDOW_PAD_SIZE - 1));
  ------------------
  |  |  301|  1.58k|#define PAD_64(bpos) ((bpos) + PADSZ((bpos),64))
  |  |  ------------------
  |  |  |  |  299|  1.58k|#define PADSZ(bpos, pad) (((pad) - ((uintptr_t)(bpos) % (pad))) % (pad))
  |  |  ------------------
  ------------------
  178|       |
  179|       |    /* Allocate buffer, align to 64-byte cacheline, and zerofill the resulting buffer */
  180|  1.58k|    char *original_buf = (char *)strm->zalloc(strm->opaque, 1, total_size);
  181|  1.58k|    if (original_buf == NULL)
  ------------------
  |  Branch (181:9): [True: 0, False: 1.58k]
  ------------------
  182|      0|        return NULL;
  183|       |
  184|  1.58k|    char *buff = (char *)HINT_ALIGNED_WINDOW((char *)PAD_WINDOW(original_buf));
  ------------------
  |  |  467|  1.58k|#  define HINT_ALIGNED_WINDOW   HINT_ALIGNED_64
  |  |  ------------------
  |  |  |  |  280|  1.58k|#define HINT_ALIGNED_64(p) HINT_ALIGNED((p),64)
  |  |  |  |  ------------------
  |  |  |  |  |  |  275|  1.58k|#  define HINT_ALIGNED(p,n) __builtin_assume_aligned((void *)(p),(n))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  185|  1.58k|    LOGSZPL("Buffer alloc", total_size, PADSZ((uintptr_t)original_buf,WINDOW_PAD_SIZE), PADSZ(curr_size,WINDOW_PAD_SIZE));
  186|       |
  187|       |    /* Initialize alloc_bufs */
  188|  1.58k|    inflate_allocs *alloc_bufs  = (struct inflate_allocs_s *)(buff + alloc_pos);
  189|  1.58k|    alloc_bufs->buf_start = original_buf;
  190|  1.58k|    alloc_bufs->zfree = strm->zfree;
  191|       |
  192|  1.58k|    alloc_bufs->window =  (unsigned char *)HINT_ALIGNED_WINDOW((buff + window_pos));
  ------------------
  |  |  467|  1.58k|#  define HINT_ALIGNED_WINDOW   HINT_ALIGNED_64
  |  |  ------------------
  |  |  |  |  280|  1.58k|#define HINT_ALIGNED_64(p) HINT_ALIGNED((p),64)
  |  |  |  |  ------------------
  |  |  |  |  |  |  275|  1.58k|#  define HINT_ALIGNED(p,n) __builtin_assume_aligned((void *)(p),(n))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  193|  1.58k|    alloc_bufs->state = (inflate_state *)HINT_ALIGNED_64((buff + state_pos));
  ------------------
  |  |  280|  1.58k|#define HINT_ALIGNED_64(p) HINT_ALIGNED((p),64)
  |  |  ------------------
  |  |  |  |  275|  1.58k|#  define HINT_ALIGNED(p,n) __builtin_assume_aligned((void *)(p),(n))
  |  |  ------------------
  ------------------
  194|       |
  195|       |#ifdef Z_MEMORY_SANITIZER
  196|       |    /* This is _not_ to subvert the memory sanitizer but to instead unposion some
  197|       |       data we willingly and purposefully load uninitialized into vector registers
  198|       |       in order to safely read the last < chunksize bytes of the window. */
  199|       |    __msan_unpoison(alloc_bufs->window + window_size, 64);
  200|       |#endif
  201|       |
  202|  1.58k|    return alloc_bufs;
  203|  1.58k|}
free_inflate:
  208|  1.58k|Z_INTERNAL void free_inflate(PREFIX3(stream) *strm) {
  209|  1.58k|    struct inflate_state *state = (struct inflate_state *)strm->state;
  210|       |
  211|  1.58k|    if (state->alloc_bufs != NULL) {
  ------------------
  |  Branch (211:9): [True: 1.58k, False: 0]
  ------------------
  212|  1.58k|        inflate_allocs *alloc_bufs = state->alloc_bufs;
  213|  1.58k|        alloc_bufs->zfree(strm->opaque, alloc_bufs->buf_start);
  214|       |        strm->state = NULL;
  215|  1.58k|    }
  216|  1.58k|}
zng_inflateInit2:
  222|  1.58k|int32_t ZNG_CONDEXPORT PREFIX(inflateInit2)(PREFIX3(stream) *strm, int32_t windowBits) {
  223|  1.58k|    struct inflate_state *state;
  224|  1.58k|    int32_t ret;
  225|       |
  226|       |    /* Initialize functable */
  227|  1.58k|    FUNCTABLE_INIT;
  ------------------
  |  |   45|  1.58k|#  define FUNCTABLE_INIT if (functable.force_init()) {return Z_VERSION_ERROR;}
  |  |  ------------------
  |  |  |  |  188|      0|#define Z_VERSION_ERROR (-6)
  |  |  ------------------
  |  |  |  Branch (45:30): [True: 0, False: 1.58k]
  |  |  ------------------
  ------------------
  228|       |
  229|  1.58k|    if (strm == NULL)
  ------------------
  |  Branch (229:9): [True: 0, False: 1.58k]
  ------------------
  230|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  231|  1.58k|    strm->msg = NULL;                   /* in case we return an error */
  232|  1.58k|    if (strm->zalloc == NULL) {
  ------------------
  |  Branch (232:9): [True: 1.58k, False: 0]
  ------------------
  233|  1.58k|        strm->zalloc = PREFIX(zcalloc);
  ------------------
  |  |  121|  1.58k|#  define PREFIX(x) zng_ ## x
  ------------------
  234|  1.58k|        strm->opaque = NULL;
  235|  1.58k|    }
  236|  1.58k|    if (strm->zfree == NULL)
  ------------------
  |  Branch (236:9): [True: 1.58k, False: 0]
  ------------------
  237|  1.58k|        strm->zfree = PREFIX(zcfree);
  ------------------
  |  |  121|  1.58k|#  define PREFIX(x) zng_ ## x
  ------------------
  238|       |
  239|  1.58k|    inflate_allocs *alloc_bufs = alloc_inflate(strm);
  240|  1.58k|    if (alloc_bufs == NULL)
  ------------------
  |  Branch (240:9): [True: 0, False: 1.58k]
  ------------------
  241|      0|        return Z_MEM_ERROR;
  ------------------
  |  |  186|      0|#define Z_MEM_ERROR    (-4)
  ------------------
  242|       |
  243|  1.58k|    state = alloc_bufs->state;
  244|  1.58k|    state->window = alloc_bufs->window;
  245|  1.58k|    state->alloc_bufs = alloc_bufs;
  246|  1.58k|    state->wbufsize = INFLATE_ADJUST_WINDOW_SIZE((1 << MAX_WBITS) + 64);
  ------------------
  |  |   26|  1.58k|#  define INFLATE_ADJUST_WINDOW_SIZE(n) (n)
  ------------------
  247|  1.58k|    Tracev((stderr, "inflate: allocated\n"));
  248|       |
  249|  1.58k|    strm->state = (struct internal_state *)state;
  250|  1.58k|    state->strm = strm;
  251|  1.58k|    state->mode = HEAD;     /* to pass state test in inflateReset2() */
  252|  1.58k|    ret = PREFIX(inflateReset2)(strm, windowBits);
  ------------------
  |  |  121|  1.58k|#  define PREFIX(x) zng_ ## x
  ------------------
  253|  1.58k|    if (ret != Z_OK) {
  ------------------
  |  |  180|  1.58k|#define Z_OK            0
  ------------------
  |  Branch (253:9): [True: 0, False: 1.58k]
  ------------------
  254|      0|        free_inflate(strm);
  255|      0|    }
  256|  1.58k|    return ret;
  257|  1.58k|}
zng_inflateInit:
  260|  1.58k|int32_t Z_EXPORT PREFIX(inflateInit)(PREFIX3(stream) *strm) {
  261|  1.58k|    return PREFIX(inflateInit2)(strm, DEF_WBITS);
  ------------------
  |  |  121|  1.58k|#  define PREFIX(x) zng_ ## x
  ------------------
                  return PREFIX(inflateInit2)(strm, DEF_WBITS);
  ------------------
  |  |   37|  1.58k|#  define DEF_WBITS MAX_WBITS
  |  |  ------------------
  |  |  |  |   40|  1.58k|#  define MAX_WBITS   15 /* 32K LZ77 window */
  |  |  ------------------
  ------------------
  262|  1.58k|}
zng_fixedtables:
  306|    619|void Z_INTERNAL PREFIX(fixedtables)(struct inflate_state *state) {
  307|    619|    state->lencode = lenfix;
  308|    619|    state->lenbits = 9;
  309|    619|    state->distcode = distfix;
  310|    619|    state->distbits = 5;
  311|    619|}
zng_inflate:
  478|  4.74k|int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) {
  479|  4.74k|    struct inflate_state *state;
  480|  4.74k|    const unsigned char *next;  /* next input */
  481|  4.74k|    unsigned char *put;         /* next output */
  482|  4.74k|    unsigned char *from;        /* where to copy match bytes from */
  483|  4.74k|    unsigned have, left;        /* available input and output */
  484|  4.74k|    uint64_t hold;              /* bit buffer */
  485|  4.74k|    bits_t bits;                /* bits in bit buffer */
  486|  4.74k|    uint32_t in, out;           /* save starting available input and output */
  487|  4.74k|    unsigned copy;              /* number of stored or match bytes to copy */
  488|  4.74k|    code here;                  /* current decoding table entry */
  489|  4.74k|    code last;                  /* parent table entry */
  490|  4.74k|    unsigned len;               /* length to copy for repeats, bits to drop */
  491|  4.74k|    unsigned code_bits;         /* bits in current/parent code */
  492|  4.74k|    int32_t ret;                /* return code */
  493|  4.74k|    static const uint16_t order[19] = /* permutation of code lengths */
  494|  4.74k|        {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
  495|       |
  496|  4.74k|    if (inflateStateCheck(strm) || strm->next_out == NULL ||
  ------------------
  |  Branch (496:9): [True: 0, False: 4.74k]
  |  Branch (496:36): [True: 0, False: 4.74k]
  ------------------
  497|  4.74k|        (strm->next_in == NULL && strm->avail_in != 0))
  ------------------
  |  Branch (497:10): [True: 0, False: 4.74k]
  |  Branch (497:35): [True: 0, False: 0]
  ------------------
  498|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  499|       |
  500|  4.74k|    state = (struct inflate_state *)strm->state;
  501|  4.74k|    if (state->mode == TYPE)      /* skip check */
  ------------------
  |  Branch (501:9): [True: 0, False: 4.74k]
  ------------------
  502|      0|        state->mode = TYPEDO;
  503|  4.74k|    LOAD();
  ------------------
  |  |   83|  4.74k|    do { \
  |  |   84|  4.74k|        put = strm->next_out; \
  |  |   85|  4.74k|        left = strm->avail_out; \
  |  |   86|  4.74k|        next = strm->next_in; \
  |  |   87|  4.74k|        have = strm->avail_in; \
  |  |   88|  4.74k|        hold = state->hold; \
  |  |   89|  4.74k|        bits = (bits_t)state->bits; \
  |  |   90|  4.74k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (90:14): [Folded, False: 4.74k]
  |  |  ------------------
  ------------------
  504|  4.74k|    in = have;
  505|  4.74k|    out = left;
  506|  4.74k|    ret = Z_OK;
  ------------------
  |  |  180|  4.74k|#define Z_OK            0
  ------------------
  507|  4.74k|    for (;;)
  508|  30.2k|        switch (state->mode) {
  509|  1.58k|        case HEAD:
  ------------------
  |  Branch (509:9): [True: 1.58k, False: 28.7k]
  ------------------
  510|  1.58k|            if (state->wrap == 0) {
  ------------------
  |  Branch (510:17): [True: 0, False: 1.58k]
  ------------------
  511|      0|                state->mode = TYPEDO;
  512|      0|                break;
  513|      0|            }
  514|  1.58k|            NEEDBITS(16);
  ------------------
  |  |  120|  1.58k|    do { \
  |  |  121|  1.58k|        unsigned u = (unsigned)(n); \
  |  |  122|  4.74k|        while (bits < (bits_t)u) \
  |  |  ------------------
  |  |  |  Branch (122:16): [True: 3.16k, False: 1.58k]
  |  |  ------------------
  |  |  123|  3.16k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  389|  3.16k|    do { \
  |  |  |  |  390|  3.16k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:13): [True: 0, False: 3.16k]
  |  |  |  |  ------------------
  |  |  |  |  391|  3.16k|        have--; \
  |  |  |  |  392|  3.16k|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  393|  3.16k|        bits += 8; \
  |  |  |  |  394|  3.16k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (394:14): [Folded, False: 3.16k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  124|  1.58k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (124:14): [Folded, False: 1.58k]
  |  |  ------------------
  ------------------
  515|  1.58k|#ifdef GUNZIP
  516|  1.58k|            if ((state->wrap & 2) && hold == 0x8b1f) {  /* gzip header */
  ------------------
  |  Branch (516:17): [True: 0, False: 1.58k]
  |  Branch (516:38): [True: 0, False: 0]
  ------------------
  517|      0|                if (state->wbits == 0)
  ------------------
  |  Branch (517:21): [True: 0, False: 0]
  ------------------
  518|      0|                    state->wbits = MAX_WBITS;
  ------------------
  |  |   40|      0|#  define MAX_WBITS   15 /* 32K LZ77 window */
  ------------------
  519|      0|                state->check = CRC32_INITIAL_VALUE;
  ------------------
  |  |   71|      0|#define CRC32_INITIAL_VALUE   0 /* initial crc-32 hash value */
  ------------------
  520|      0|                CRC2(state->check, hold);
  ------------------
  |  |   56|      0|    do { \
  |  |   57|      0|        uint32_t crc = ~(uint32_t)(check); \
  |  |   58|      0|        CRC_DO1_B(crc, (word)     ); \
  |  |  ------------------
  |  |  |  |   53|      0|#  define CRC_DO1_B(c, b)    c = crc_table[(c ^ (b)) & 0xff] ^ (c >> 8)
  |  |  ------------------
  |  |   59|      0|        CRC_DO1_B(crc, (word) >> 8); \
  |  |  ------------------
  |  |  |  |   53|      0|#  define CRC_DO1_B(c, b)    c = crc_table[(c ^ (b)) & 0xff] ^ (c >> 8)
  |  |  ------------------
  |  |   60|      0|        (check) = ~crc; \
  |  |   61|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (61:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  521|      0|                INITBITS();
  ------------------
  |  |  112|      0|    do { \
  |  |  113|      0|        hold = 0; \
  |  |  114|      0|        bits = 0; \
  |  |  115|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (115:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  522|      0|                state->mode = FLAGS;
  523|      0|                break;
  524|      0|            }
  525|  1.58k|            if (state->head != NULL)
  ------------------
  |  Branch (525:17): [True: 0, False: 1.58k]
  ------------------
  526|      0|                state->head->done = -1;
  527|  1.58k|            if (!(state->wrap & 1) ||   /* check if zlib header allowed */
  ------------------
  |  Branch (527:17): [True: 0, False: 1.58k]
  ------------------
  528|       |#else
  529|       |            if (
  530|       |#endif
  531|  1.58k|                ((BITS(8) << 8) + (hold >> 8)) % 31) {
  ------------------
  |  |  128|  1.58k|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  |  Branch (531:17): [True: 0, False: 1.58k]
  ------------------
  532|      0|                SET_BAD("incorrect header check");
  ------------------
  |  |  147|      0|    do { \
  |  |  148|      0|        state->mode = BAD; \
  |  |  149|      0|        strm->msg = (z_const char *)errmsg; \
  |  |  150|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (150:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  533|      0|                break;
  534|      0|            }
  535|  1.58k|            if (BITS(4) != Z_DEFLATED) {
  ------------------
  |  |  128|  1.58k|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
                          if (BITS(4) != Z_DEFLATED) {
  ------------------
  |  |  212|  1.58k|#define Z_DEFLATED   8
  ------------------
  |  Branch (535:17): [True: 0, False: 1.58k]
  ------------------
  536|      0|                SET_BAD("unknown compression method");
  ------------------
  |  |  147|      0|    do { \
  |  |  148|      0|        state->mode = BAD; \
  |  |  149|      0|        strm->msg = (z_const char *)errmsg; \
  |  |  150|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (150:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  537|      0|                break;
  538|      0|            }
  539|  1.58k|            DROPBITS(4);
  ------------------
  |  |  132|  1.58k|    do { \
  |  |  133|  1.58k|        unsigned u = (unsigned)(n); \
  |  |  134|  1.58k|        hold >>= u; \
  |  |  135|  1.58k|        bits -= (bits_t)u; \
  |  |  136|  1.58k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 1.58k]
  |  |  ------------------
  ------------------
  540|  1.58k|            len = BITS(4) + 8;
  ------------------
  |  |  128|  1.58k|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  541|  1.58k|            if (state->wbits == 0)
  ------------------
  |  Branch (541:17): [True: 0, False: 1.58k]
  ------------------
  542|      0|                state->wbits = len;
  543|  1.58k|            if (len > MAX_WBITS || len > state->wbits) {
  ------------------
  |  |   40|  3.16k|#  define MAX_WBITS   15 /* 32K LZ77 window */
  ------------------
  |  Branch (543:17): [True: 0, False: 1.58k]
  |  Branch (543:36): [True: 0, False: 1.58k]
  ------------------
  544|      0|                SET_BAD("invalid window size");
  ------------------
  |  |  147|      0|    do { \
  |  |  148|      0|        state->mode = BAD; \
  |  |  149|      0|        strm->msg = (z_const char *)errmsg; \
  |  |  150|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (150:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  545|      0|                break;
  546|      0|            }
  547|       |#ifdef INFLATE_STRICT
  548|       |            state->dmax = 1U << len;
  549|       |#endif
  550|  1.58k|            state->flags = 0;               /* indicate zlib header */
  551|  1.58k|            Tracev((stderr, "inflate:   zlib header ok\n"));
  552|  1.58k|            strm->adler = state->check = ADLER32_INITIAL_VALUE;
  ------------------
  |  |   70|  1.58k|#define ADLER32_INITIAL_VALUE 1 /* initial adler-32 hash value */
  ------------------
  553|  1.58k|            state->mode = hold & 0x200 ? DICTID : TYPE;
  ------------------
  |  Branch (553:27): [True: 0, False: 1.58k]
  ------------------
  554|  1.58k|            INITBITS();
  ------------------
  |  |  112|  1.58k|    do { \
  |  |  113|  1.58k|        hold = 0; \
  |  |  114|  1.58k|        bits = 0; \
  |  |  115|  1.58k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (115:14): [Folded, False: 1.58k]
  |  |  ------------------
  ------------------
  555|  1.58k|            break;
  556|      0|#ifdef GUNZIP
  557|       |
  558|      0|        case FLAGS:
  ------------------
  |  Branch (558:9): [True: 0, False: 30.2k]
  ------------------
  559|      0|            NEEDBITS(16);
  ------------------
  |  |  120|      0|    do { \
  |  |  121|      0|        unsigned u = (unsigned)(n); \
  |  |  122|      0|        while (bits < (bits_t)u) \
  |  |  ------------------
  |  |  |  Branch (122:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  123|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  389|      0|    do { \
  |  |  |  |  390|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  391|      0|        have--; \
  |  |  |  |  392|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  393|      0|        bits += 8; \
  |  |  |  |  394|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (394:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  124|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (124:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  560|      0|            state->flags = (int)(hold);
  561|      0|            if ((state->flags & 0xff) != Z_DEFLATED) {
  ------------------
  |  |  212|      0|#define Z_DEFLATED   8
  ------------------
  |  Branch (561:17): [True: 0, False: 0]
  ------------------
  562|      0|                SET_BAD("unknown compression method");
  ------------------
  |  |  147|      0|    do { \
  |  |  148|      0|        state->mode = BAD; \
  |  |  149|      0|        strm->msg = (z_const char *)errmsg; \
  |  |  150|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (150:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  563|      0|                break;
  564|      0|            }
  565|      0|            if (state->flags & 0xe000) {
  ------------------
  |  Branch (565:17): [True: 0, False: 0]
  ------------------
  566|      0|                SET_BAD("unknown header flags set");
  ------------------
  |  |  147|      0|    do { \
  |  |  148|      0|        state->mode = BAD; \
  |  |  149|      0|        strm->msg = (z_const char *)errmsg; \
  |  |  150|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (150:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  567|      0|                break;
  568|      0|            }
  569|      0|            if (state->head != NULL)
  ------------------
  |  Branch (569:17): [True: 0, False: 0]
  ------------------
  570|      0|                state->head->text = (int)((hold >> 8) & 1);
  571|      0|            if ((state->flags & 0x0200) && (state->wrap & 4))
  ------------------
  |  Branch (571:17): [True: 0, False: 0]
  |  Branch (571:44): [True: 0, False: 0]
  ------------------
  572|      0|                CRC2(state->check, hold);
  ------------------
  |  |   56|      0|    do { \
  |  |   57|      0|        uint32_t crc = ~(uint32_t)(check); \
  |  |   58|      0|        CRC_DO1_B(crc, (word)     ); \
  |  |  ------------------
  |  |  |  |   53|      0|#  define CRC_DO1_B(c, b)    c = crc_table[(c ^ (b)) & 0xff] ^ (c >> 8)
  |  |  ------------------
  |  |   59|      0|        CRC_DO1_B(crc, (word) >> 8); \
  |  |  ------------------
  |  |  |  |   53|      0|#  define CRC_DO1_B(c, b)    c = crc_table[(c ^ (b)) & 0xff] ^ (c >> 8)
  |  |  ------------------
  |  |   60|      0|        (check) = ~crc; \
  |  |   61|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (61:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  573|      0|            INITBITS();
  ------------------
  |  |  112|      0|    do { \
  |  |  113|      0|        hold = 0; \
  |  |  114|      0|        bits = 0; \
  |  |  115|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (115:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  574|      0|            state->mode = TIME;
  575|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   54|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  576|       |
  577|      0|        case TIME:
  ------------------
  |  Branch (577:9): [True: 0, False: 30.2k]
  ------------------
  578|      0|            NEEDBITS(32);
  ------------------
  |  |  120|      0|    do { \
  |  |  121|      0|        unsigned u = (unsigned)(n); \
  |  |  122|      0|        while (bits < (bits_t)u) \
  |  |  ------------------
  |  |  |  Branch (122:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  123|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  389|      0|    do { \
  |  |  |  |  390|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  391|      0|        have--; \
  |  |  |  |  392|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  393|      0|        bits += 8; \
  |  |  |  |  394|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (394:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  124|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (124:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  579|      0|            if (state->head != NULL)
  ------------------
  |  Branch (579:17): [True: 0, False: 0]
  ------------------
  580|      0|                state->head->time = (unsigned)(hold);
  581|      0|            if ((state->flags & 0x0200) && (state->wrap & 4))
  ------------------
  |  Branch (581:17): [True: 0, False: 0]
  |  Branch (581:44): [True: 0, False: 0]
  ------------------
  582|      0|                CRC4(state->check, hold);
  ------------------
  |  |   64|      0|    do { \
  |  |   65|      0|        uint32_t crc = ~(uint32_t)(check); \
  |  |   66|      0|        CRC_DO1_B(crc, (word)      ); \
  |  |  ------------------
  |  |  |  |   53|      0|#  define CRC_DO1_B(c, b)    c = crc_table[(c ^ (b)) & 0xff] ^ (c >> 8)
  |  |  ------------------
  |  |   67|      0|        CRC_DO1_B(crc, (word) >>  8); \
  |  |  ------------------
  |  |  |  |   53|      0|#  define CRC_DO1_B(c, b)    c = crc_table[(c ^ (b)) & 0xff] ^ (c >> 8)
  |  |  ------------------
  |  |   68|      0|        CRC_DO1_B(crc, (word) >> 16); \
  |  |  ------------------
  |  |  |  |   53|      0|#  define CRC_DO1_B(c, b)    c = crc_table[(c ^ (b)) & 0xff] ^ (c >> 8)
  |  |  ------------------
  |  |   69|      0|        CRC_DO1_B(crc, (word) >> 24); \
  |  |  ------------------
  |  |  |  |   53|      0|#  define CRC_DO1_B(c, b)    c = crc_table[(c ^ (b)) & 0xff] ^ (c >> 8)
  |  |  ------------------
  |  |   70|      0|        (check) = ~crc; \
  |  |   71|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (71:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  583|      0|            INITBITS();
  ------------------
  |  |  112|      0|    do { \
  |  |  113|      0|        hold = 0; \
  |  |  114|      0|        bits = 0; \
  |  |  115|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (115:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  584|      0|            state->mode = OS;
  585|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   54|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  586|       |
  587|      0|        case OS:
  ------------------
  |  Branch (587:9): [True: 0, False: 30.2k]
  ------------------
  588|      0|            NEEDBITS(16);
  ------------------
  |  |  120|      0|    do { \
  |  |  121|      0|        unsigned u = (unsigned)(n); \
  |  |  122|      0|        while (bits < (bits_t)u) \
  |  |  ------------------
  |  |  |  Branch (122:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  123|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  389|      0|    do { \
  |  |  |  |  390|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  391|      0|        have--; \
  |  |  |  |  392|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  393|      0|        bits += 8; \
  |  |  |  |  394|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (394:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  124|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (124:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  589|      0|            if (state->head != NULL) {
  ------------------
  |  Branch (589:17): [True: 0, False: 0]
  ------------------
  590|      0|                state->head->xflags = (int)(hold & 0xff);
  591|      0|                state->head->os = (int)(hold >> 8);
  592|      0|            }
  593|      0|            if ((state->flags & 0x0200) && (state->wrap & 4))
  ------------------
  |  Branch (593:17): [True: 0, False: 0]
  |  Branch (593:44): [True: 0, False: 0]
  ------------------
  594|      0|                CRC2(state->check, hold);
  ------------------
  |  |   56|      0|    do { \
  |  |   57|      0|        uint32_t crc = ~(uint32_t)(check); \
  |  |   58|      0|        CRC_DO1_B(crc, (word)     ); \
  |  |  ------------------
  |  |  |  |   53|      0|#  define CRC_DO1_B(c, b)    c = crc_table[(c ^ (b)) & 0xff] ^ (c >> 8)
  |  |  ------------------
  |  |   59|      0|        CRC_DO1_B(crc, (word) >> 8); \
  |  |  ------------------
  |  |  |  |   53|      0|#  define CRC_DO1_B(c, b)    c = crc_table[(c ^ (b)) & 0xff] ^ (c >> 8)
  |  |  ------------------
  |  |   60|      0|        (check) = ~crc; \
  |  |   61|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (61:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  595|      0|            INITBITS();
  ------------------
  |  |  112|      0|    do { \
  |  |  113|      0|        hold = 0; \
  |  |  114|      0|        bits = 0; \
  |  |  115|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (115:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  596|      0|            state->mode = EXLEN;
  597|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   54|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  598|       |
  599|      0|        case EXLEN:
  ------------------
  |  Branch (599:9): [True: 0, False: 30.2k]
  ------------------
  600|      0|            if (state->flags & 0x0400) {
  ------------------
  |  Branch (600:17): [True: 0, False: 0]
  ------------------
  601|      0|                NEEDBITS(16);
  ------------------
  |  |  120|      0|    do { \
  |  |  121|      0|        unsigned u = (unsigned)(n); \
  |  |  122|      0|        while (bits < (bits_t)u) \
  |  |  ------------------
  |  |  |  Branch (122:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  123|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  389|      0|    do { \
  |  |  |  |  390|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  391|      0|        have--; \
  |  |  |  |  392|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  393|      0|        bits += 8; \
  |  |  |  |  394|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (394:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  124|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (124:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  602|      0|                state->length = (uint16_t)hold;
  603|      0|                if (state->head != NULL)
  ------------------
  |  Branch (603:21): [True: 0, False: 0]
  ------------------
  604|      0|                    state->head->extra_len = (uint16_t)hold;
  605|      0|                if ((state->flags & 0x0200) && (state->wrap & 4))
  ------------------
  |  Branch (605:21): [True: 0, False: 0]
  |  Branch (605:48): [True: 0, False: 0]
  ------------------
  606|      0|                    CRC2(state->check, hold);
  ------------------
  |  |   56|      0|    do { \
  |  |   57|      0|        uint32_t crc = ~(uint32_t)(check); \
  |  |   58|      0|        CRC_DO1_B(crc, (word)     ); \
  |  |  ------------------
  |  |  |  |   53|      0|#  define CRC_DO1_B(c, b)    c = crc_table[(c ^ (b)) & 0xff] ^ (c >> 8)
  |  |  ------------------
  |  |   59|      0|        CRC_DO1_B(crc, (word) >> 8); \
  |  |  ------------------
  |  |  |  |   53|      0|#  define CRC_DO1_B(c, b)    c = crc_table[(c ^ (b)) & 0xff] ^ (c >> 8)
  |  |  ------------------
  |  |   60|      0|        (check) = ~crc; \
  |  |   61|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (61:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  607|      0|                INITBITS();
  ------------------
  |  |  112|      0|    do { \
  |  |  113|      0|        hold = 0; \
  |  |  114|      0|        bits = 0; \
  |  |  115|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (115:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  608|      0|            } else if (state->head != NULL) {
  ------------------
  |  Branch (608:24): [True: 0, False: 0]
  ------------------
  609|      0|                state->head->extra = NULL;
  610|      0|            }
  611|      0|            state->mode = EXTRA;
  612|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   54|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  613|       |
  614|      0|        case EXTRA:
  ------------------
  |  Branch (614:9): [True: 0, False: 30.2k]
  ------------------
  615|      0|            if (state->flags & 0x0400) {
  ------------------
  |  Branch (615:17): [True: 0, False: 0]
  ------------------
  616|      0|                copy = state->length;
  617|      0|                if (copy > have)
  ------------------
  |  Branch (617:21): [True: 0, False: 0]
  ------------------
  618|      0|                    copy = have;
  619|      0|                if (copy) {
  ------------------
  |  Branch (619:21): [True: 0, False: 0]
  ------------------
  620|      0|                    if (state->head != NULL && state->head->extra != NULL) {
  ------------------
  |  Branch (620:25): [True: 0, False: 0]
  |  Branch (620:48): [True: 0, False: 0]
  ------------------
  621|      0|                        len = state->head->extra_len - state->length;
  622|      0|                        if (len < state->head->extra_max) {
  ------------------
  |  Branch (622:29): [True: 0, False: 0]
  ------------------
  623|      0|                            memcpy(state->head->extra + len, next,
  624|      0|                                    len + copy > state->head->extra_max ?
  ------------------
  |  Branch (624:37): [True: 0, False: 0]
  ------------------
  625|      0|                                    state->head->extra_max - len : copy);
  626|      0|                        }
  627|      0|                    }
  628|      0|                    if ((state->flags & 0x0200) && (state->wrap & 4)) {
  ------------------
  |  Branch (628:25): [True: 0, False: 0]
  |  Branch (628:52): [True: 0, False: 0]
  ------------------
  629|      0|                        state->check = crc32_small((uint32_t)state->check, next, copy);
  630|      0|                    }
  631|      0|                    have -= copy;
  632|      0|                    next += copy;
  633|      0|                    state->length -= copy;
  634|      0|                }
  635|      0|                if (state->length)
  ------------------
  |  Branch (635:21): [True: 0, False: 0]
  ------------------
  636|      0|                    goto inf_leave;
  637|      0|            }
  638|      0|            state->length = 0;
  639|      0|            state->mode = NAME;
  640|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   54|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  641|       |
  642|      0|        case NAME:
  ------------------
  |  Branch (642:9): [True: 0, False: 30.2k]
  ------------------
  643|      0|            if (state->flags & 0x0800) {
  ------------------
  |  Branch (643:17): [True: 0, False: 0]
  ------------------
  644|      0|                if (have == 0) goto inf_leave;
  ------------------
  |  Branch (644:21): [True: 0, False: 0]
  ------------------
  645|      0|                copy = 0;
  646|      0|                do {
  647|      0|                    len = (unsigned)(next[copy++]);
  648|      0|                    if (state->head != NULL && state->head->name != NULL && state->length < state->head->name_max)
  ------------------
  |  Branch (648:25): [True: 0, False: 0]
  |  Branch (648:48): [True: 0, False: 0]
  |  Branch (648:77): [True: 0, False: 0]
  ------------------
  649|      0|                        state->head->name[state->length++] = (unsigned char)len;
  650|      0|                } while (len && copy < have);
  ------------------
  |  Branch (650:26): [True: 0, False: 0]
  |  Branch (650:33): [True: 0, False: 0]
  ------------------
  651|      0|                if ((state->flags & 0x0200) && (state->wrap & 4))
  ------------------
  |  Branch (651:21): [True: 0, False: 0]
  |  Branch (651:48): [True: 0, False: 0]
  ------------------
  652|      0|                    state->check = crc32_small((uint32_t)state->check, next, copy);
  653|      0|                have -= copy;
  654|      0|                next += copy;
  655|      0|                if (len)
  ------------------
  |  Branch (655:21): [True: 0, False: 0]
  ------------------
  656|      0|                    goto inf_leave;
  657|      0|            } else if (state->head != NULL) {
  ------------------
  |  Branch (657:24): [True: 0, False: 0]
  ------------------
  658|      0|                state->head->name = NULL;
  659|      0|            }
  660|      0|            state->length = 0;
  661|      0|            state->mode = COMMENT;
  662|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   54|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  663|       |
  664|      0|        case COMMENT:
  ------------------
  |  Branch (664:9): [True: 0, False: 30.2k]
  ------------------
  665|      0|            if (state->flags & 0x1000) {
  ------------------
  |  Branch (665:17): [True: 0, False: 0]
  ------------------
  666|      0|                if (have == 0) goto inf_leave;
  ------------------
  |  Branch (666:21): [True: 0, False: 0]
  ------------------
  667|      0|                copy = 0;
  668|      0|                do {
  669|      0|                    len = (unsigned)(next[copy++]);
  670|      0|                    if (state->head != NULL && state->head->comment != NULL
  ------------------
  |  Branch (670:25): [True: 0, False: 0]
  |  Branch (670:48): [True: 0, False: 0]
  ------------------
  671|      0|                        && state->length < state->head->comm_max)
  ------------------
  |  Branch (671:28): [True: 0, False: 0]
  ------------------
  672|      0|                        state->head->comment[state->length++] = (unsigned char)len;
  673|      0|                } while (len && copy < have);
  ------------------
  |  Branch (673:26): [True: 0, False: 0]
  |  Branch (673:33): [True: 0, False: 0]
  ------------------
  674|      0|                if ((state->flags & 0x0200) && (state->wrap & 4))
  ------------------
  |  Branch (674:21): [True: 0, False: 0]
  |  Branch (674:48): [True: 0, False: 0]
  ------------------
  675|      0|                    state->check = crc32_small((uint32_t)state->check, next, copy);
  676|      0|                have -= copy;
  677|      0|                next += copy;
  678|      0|                if (len)
  ------------------
  |  Branch (678:21): [True: 0, False: 0]
  ------------------
  679|      0|                    goto inf_leave;
  680|      0|            } else if (state->head != NULL) {
  ------------------
  |  Branch (680:24): [True: 0, False: 0]
  ------------------
  681|      0|                state->head->comment = NULL;
  682|      0|            }
  683|      0|            state->mode = HCRC;
  684|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   54|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  685|       |
  686|      0|        case HCRC:
  ------------------
  |  Branch (686:9): [True: 0, False: 30.2k]
  ------------------
  687|      0|            if (state->flags & 0x0200) {
  ------------------
  |  Branch (687:17): [True: 0, False: 0]
  ------------------
  688|      0|                NEEDBITS(16);
  ------------------
  |  |  120|      0|    do { \
  |  |  121|      0|        unsigned u = (unsigned)(n); \
  |  |  122|      0|        while (bits < (bits_t)u) \
  |  |  ------------------
  |  |  |  Branch (122:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  123|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  389|      0|    do { \
  |  |  |  |  390|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  391|      0|        have--; \
  |  |  |  |  392|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  393|      0|        bits += 8; \
  |  |  |  |  394|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (394:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  124|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (124:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  689|      0|                if ((state->wrap & 4) && hold != (state->check & 0xffff)) {
  ------------------
  |  Branch (689:21): [True: 0, False: 0]
  |  Branch (689:42): [True: 0, False: 0]
  ------------------
  690|      0|                    SET_BAD("header crc mismatch");
  ------------------
  |  |  147|      0|    do { \
  |  |  148|      0|        state->mode = BAD; \
  |  |  149|      0|        strm->msg = (z_const char *)errmsg; \
  |  |  150|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (150:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  691|      0|                    break;
  692|      0|                }
  693|      0|                INITBITS();
  ------------------
  |  |  112|      0|    do { \
  |  |  113|      0|        hold = 0; \
  |  |  114|      0|        bits = 0; \
  |  |  115|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (115:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  694|      0|            }
  695|      0|            if (state->head != NULL) {
  ------------------
  |  Branch (695:17): [True: 0, False: 0]
  ------------------
  696|      0|                state->head->hcrc = (int)((state->flags >> 9) & 1);
  697|      0|                state->head->done = 1;
  698|      0|            }
  699|       |            /* compute crc32 checksum if not in raw mode */
  700|      0|            if ((state->wrap & 4) && state->flags)
  ------------------
  |  Branch (700:17): [True: 0, False: 0]
  |  Branch (700:38): [True: 0, False: 0]
  ------------------
  701|      0|                strm->adler = state->check = CRC32_INITIAL_VALUE;
  ------------------
  |  |   71|      0|#define CRC32_INITIAL_VALUE   0 /* initial crc-32 hash value */
  ------------------
  702|      0|            state->mode = TYPE;
  703|      0|            break;
  704|      0|#endif
  705|      0|        case DICTID:
  ------------------
  |  Branch (705:9): [True: 0, False: 30.2k]
  ------------------
  706|      0|            NEEDBITS(32);
  ------------------
  |  |  120|      0|    do { \
  |  |  121|      0|        unsigned u = (unsigned)(n); \
  |  |  122|      0|        while (bits < (bits_t)u) \
  |  |  ------------------
  |  |  |  Branch (122:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  123|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  389|      0|    do { \
  |  |  |  |  390|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  391|      0|        have--; \
  |  |  |  |  392|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  393|      0|        bits += 8; \
  |  |  |  |  394|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (394:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  124|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (124:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  707|      0|            strm->adler = state->check = ZSWAP32((unsigned)hold);
  ------------------
  |  |  214|      0|#  define ZSWAP32(q) __builtin_bswap32(q)
  ------------------
  708|      0|            INITBITS();
  ------------------
  |  |  112|      0|    do { \
  |  |  113|      0|        hold = 0; \
  |  |  114|      0|        bits = 0; \
  |  |  115|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (115:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  709|      0|            state->mode = DICT;
  710|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   54|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  711|       |
  712|      0|        case DICT:
  ------------------
  |  Branch (712:9): [True: 0, False: 30.2k]
  ------------------
  713|      0|            if (state->havedict == 0) {
  ------------------
  |  Branch (713:17): [True: 0, False: 0]
  ------------------
  714|      0|                RESTORE();
  ------------------
  |  |   94|      0|    do { \
  |  |   95|      0|        strm->next_out = put; \
  |  |   96|      0|        strm->avail_out = left; \
  |  |   97|      0|        strm->next_in = (z_const unsigned char *)next; \
  |  |   98|      0|        strm->avail_in = have; \
  |  |   99|      0|        state->hold = hold; \
  |  |  100|      0|        state->bits = bits; \
  |  |  101|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (101:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  715|      0|                return Z_NEED_DICT;
  ------------------
  |  |  182|      0|#define Z_NEED_DICT     2
  ------------------
  716|      0|            }
  717|      0|            strm->adler = state->check = ADLER32_INITIAL_VALUE;
  ------------------
  |  |   70|      0|#define ADLER32_INITIAL_VALUE 1 /* initial adler-32 hash value */
  ------------------
  718|      0|            state->mode = TYPE;
  719|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   54|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  720|       |
  721|  6.32k|        case TYPE:
  ------------------
  |  Branch (721:9): [True: 6.32k, False: 23.9k]
  ------------------
  722|  6.32k|            if (flush == Z_BLOCK || flush == Z_TREES)
  ------------------
  |  |  176|  12.6k|#define Z_BLOCK         5
  ------------------
                          if (flush == Z_BLOCK || flush == Z_TREES)
  ------------------
  |  |  177|  6.32k|#define Z_TREES         6
  ------------------
  |  Branch (722:17): [True: 0, False: 6.32k]
  |  Branch (722:37): [True: 0, False: 6.32k]
  ------------------
  723|      0|                goto inf_leave;
  724|  6.32k|            Z_FALLTHROUGH;
  ------------------
  |  |   54|  6.32k|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  725|       |
  726|  6.32k|        case TYPEDO:
  ------------------
  |  Branch (726:9): [True: 0, False: 30.2k]
  ------------------
  727|       |            /* determine and dispatch block type */
  728|  6.32k|            INFLATE_TYPEDO_HOOK(strm, flush);  /* hook for IBM Z DFLTCC */
  ------------------
  |  |   32|  6.32k|#  define INFLATE_TYPEDO_HOOK(strm, flush) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (32:57): [Folded, False: 6.32k]
  |  |  ------------------
  ------------------
  729|  6.32k|            if (state->last) {
  ------------------
  |  Branch (729:17): [True: 1.58k, False: 4.74k]
  ------------------
  730|  1.58k|                BYTEBITS();
  ------------------
  |  |  140|  1.58k|    do { \
  |  |  141|  1.58k|        hold >>= bits & 7; \
  |  |  142|  1.58k|        bits -= bits & 7; \
  |  |  143|  1.58k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (143:14): [Folded, False: 1.58k]
  |  |  ------------------
  ------------------
  731|  1.58k|                state->mode = CHECK;
  732|  1.58k|                break;
  733|  1.58k|            }
  734|  4.74k|            NEEDBITS(3);
  ------------------
  |  |  120|  4.74k|    do { \
  |  |  121|  4.74k|        unsigned u = (unsigned)(n); \
  |  |  122|  8.55k|        while (bits < (bits_t)u) \
  |  |  ------------------
  |  |  |  Branch (122:16): [True: 3.81k, False: 4.74k]
  |  |  ------------------
  |  |  123|  4.74k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  389|  3.81k|    do { \
  |  |  |  |  390|  3.81k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:13): [True: 0, False: 3.81k]
  |  |  |  |  ------------------
  |  |  |  |  391|  3.81k|        have--; \
  |  |  |  |  392|  3.81k|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  393|  3.81k|        bits += 8; \
  |  |  |  |  394|  3.81k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (394:14): [Folded, False: 3.81k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  124|  4.74k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (124:14): [Folded, False: 4.74k]
  |  |  ------------------
  ------------------
  735|  4.74k|            state->last = BITS(1);
  ------------------
  |  |  128|  4.74k|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  736|  4.74k|            DROPBITS(1);
  ------------------
  |  |  132|  4.74k|    do { \
  |  |  133|  4.74k|        unsigned u = (unsigned)(n); \
  |  |  134|  4.74k|        hold >>= u; \
  |  |  135|  4.74k|        bits -= (bits_t)u; \
  |  |  136|  4.74k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 4.74k]
  |  |  ------------------
  ------------------
  737|  4.74k|            switch (BITS(2)) {
  ------------------
  |  |  128|  4.74k|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  738|  1.58k|            case 0:                             /* stored block */
  ------------------
  |  Branch (738:13): [True: 1.58k, False: 3.16k]
  ------------------
  739|  1.58k|                Tracev((stderr, "inflate:     stored block%s\n", state->last ? " (last)" : ""));
  740|  1.58k|                state->mode = STORED;
  741|  1.58k|                break;
  742|    619|            case 1:                             /* fixed block */
  ------------------
  |  Branch (742:13): [True: 619, False: 4.12k]
  ------------------
  743|    619|                PREFIX(fixedtables)(state);
  ------------------
  |  |  121|    619|#  define PREFIX(x) zng_ ## x
  ------------------
  744|    619|                Tracev((stderr, "inflate:     fixed codes block%s\n", state->last ? " (last)" : ""));
  745|    619|                state->mode = LEN_;             /* decode codes */
  746|    619|                if (flush == Z_TREES) {
  ------------------
  |  |  177|    619|#define Z_TREES         6
  ------------------
  |  Branch (746:21): [True: 0, False: 619]
  ------------------
  747|      0|                    DROPBITS(2);
  ------------------
  |  |  132|      0|    do { \
  |  |  133|      0|        unsigned u = (unsigned)(n); \
  |  |  134|      0|        hold >>= u; \
  |  |  135|      0|        bits -= (bits_t)u; \
  |  |  136|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  748|      0|                    goto inf_leave;
  749|      0|                }
  750|    619|                break;
  751|  2.54k|            case 2:                             /* dynamic block */
  ------------------
  |  Branch (751:13): [True: 2.54k, False: 2.19k]
  ------------------
  752|  2.54k|                Tracev((stderr, "inflate:     dynamic codes block%s\n", state->last ? " (last)" : ""));
  753|  2.54k|                state->mode = TABLE;
  754|  2.54k|                break;
  755|      0|            default:
  ------------------
  |  Branch (755:13): [True: 0, False: 4.74k]
  ------------------
  756|      0|                SET_BAD("invalid block type");
  ------------------
  |  |  147|      0|    do { \
  |  |  148|      0|        state->mode = BAD; \
  |  |  149|      0|        strm->msg = (z_const char *)errmsg; \
  |  |  150|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (150:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  757|  4.74k|            }
  758|  4.74k|            DROPBITS(2);
  ------------------
  |  |  132|  4.74k|    do { \
  |  |  133|  4.74k|        unsigned u = (unsigned)(n); \
  |  |  134|  4.74k|        hold >>= u; \
  |  |  135|  4.74k|        bits -= (bits_t)u; \
  |  |  136|  4.74k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 4.74k]
  |  |  ------------------
  ------------------
  759|  4.74k|            break;
  760|       |
  761|  1.58k|        case STORED:
  ------------------
  |  Branch (761:9): [True: 1.58k, False: 28.7k]
  ------------------
  762|       |            /* get and verify stored block length */
  763|  1.58k|            BYTEBITS();                         /* go to byte boundary */
  ------------------
  |  |  140|  1.58k|    do { \
  |  |  141|  1.58k|        hold >>= bits & 7; \
  |  |  142|  1.58k|        bits -= bits & 7; \
  |  |  143|  1.58k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (143:14): [Folded, False: 1.58k]
  |  |  ------------------
  ------------------
  764|  1.58k|            NEEDBITS(32);
  ------------------
  |  |  120|  1.58k|    do { \
  |  |  121|  1.58k|        unsigned u = (unsigned)(n); \
  |  |  122|  7.90k|        while (bits < (bits_t)u) \
  |  |  ------------------
  |  |  |  Branch (122:16): [True: 6.32k, False: 1.58k]
  |  |  ------------------
  |  |  123|  6.32k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  389|  6.32k|    do { \
  |  |  |  |  390|  6.32k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:13): [True: 0, False: 6.32k]
  |  |  |  |  ------------------
  |  |  |  |  391|  6.32k|        have--; \
  |  |  |  |  392|  6.32k|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  393|  6.32k|        bits += 8; \
  |  |  |  |  394|  6.32k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (394:14): [Folded, False: 6.32k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  124|  1.58k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (124:14): [Folded, False: 1.58k]
  |  |  ------------------
  ------------------
  765|  1.58k|            if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
  ------------------
  |  Branch (765:17): [True: 0, False: 1.58k]
  ------------------
  766|      0|                SET_BAD("invalid stored block lengths");
  ------------------
  |  |  147|      0|    do { \
  |  |  148|      0|        state->mode = BAD; \
  |  |  149|      0|        strm->msg = (z_const char *)errmsg; \
  |  |  150|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (150:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  767|      0|                break;
  768|      0|            }
  769|  1.58k|            state->length = (uint16_t)hold;
  770|  1.58k|            Tracev((stderr, "inflate:       stored length %u\n", state->length));
  771|  1.58k|            INITBITS();
  ------------------
  |  |  112|  1.58k|    do { \
  |  |  113|  1.58k|        hold = 0; \
  |  |  114|  1.58k|        bits = 0; \
  |  |  115|  1.58k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (115:14): [Folded, False: 1.58k]
  |  |  ------------------
  ------------------
  772|  1.58k|            state->mode = COPY_;
  773|  1.58k|            if (flush == Z_TREES)
  ------------------
  |  |  177|  1.58k|#define Z_TREES         6
  ------------------
  |  Branch (773:17): [True: 0, False: 1.58k]
  ------------------
  774|      0|                goto inf_leave;
  775|  1.58k|            Z_FALLTHROUGH;
  ------------------
  |  |   54|  1.58k|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  776|       |
  777|  1.58k|        case COPY_:
  ------------------
  |  Branch (777:9): [True: 0, False: 30.2k]
  ------------------
  778|  1.58k|            state->mode = COPY;
  779|  1.58k|            Z_FALLTHROUGH;
  ------------------
  |  |   54|  1.58k|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  780|       |
  781|  4.74k|        case COPY:
  ------------------
  |  Branch (781:9): [True: 3.16k, False: 27.1k]
  ------------------
  782|       |            /* copy stored block from input to output */
  783|  4.74k|            copy = state->length;
  784|  4.74k|            if (copy) {
  ------------------
  |  Branch (784:17): [True: 3.16k, False: 1.58k]
  ------------------
  785|  3.16k|                copy = MIN(copy, have);
  ------------------
  |  |  148|  3.16k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 3.16k]
  |  |  ------------------
  ------------------
  786|  3.16k|                copy = MIN(copy, left);
  ------------------
  |  |  148|  3.16k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 1.58k, False: 1.58k]
  |  |  ------------------
  ------------------
  787|  3.16k|                if (copy == 0)
  ------------------
  |  Branch (787:21): [True: 1.58k, False: 1.58k]
  ------------------
  788|  1.58k|                    goto inf_leave;
  789|  1.58k|                memcpy(put, next, copy);
  790|  1.58k|                have -= copy;
  791|  1.58k|                next += copy;
  792|  1.58k|                left -= copy;
  793|  1.58k|                put += copy;
  794|  1.58k|                state->length -= copy;
  795|  1.58k|                break;
  796|  3.16k|            }
  797|  1.58k|            Tracev((stderr, "inflate:       stored end\n"));
  798|  1.58k|            state->mode = TYPE;
  799|  1.58k|            break;
  800|       |
  801|  2.54k|        case TABLE:
  ------------------
  |  Branch (801:9): [True: 2.54k, False: 27.7k]
  ------------------
  802|       |            /* get dynamic table entries descriptor */
  803|  2.54k|            NEEDBITS(14);
  ------------------
  |  |  120|  2.54k|    do { \
  |  |  121|  2.54k|        unsigned u = (unsigned)(n); \
  |  |  122|  7.62k|        while (bits < (bits_t)u) \
  |  |  ------------------
  |  |  |  Branch (122:16): [True: 5.08k, False: 2.54k]
  |  |  ------------------
  |  |  123|  5.08k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  389|  5.08k|    do { \
  |  |  |  |  390|  5.08k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:13): [True: 0, False: 5.08k]
  |  |  |  |  ------------------
  |  |  |  |  391|  5.08k|        have--; \
  |  |  |  |  392|  5.08k|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  393|  5.08k|        bits += 8; \
  |  |  |  |  394|  5.08k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (394:14): [Folded, False: 5.08k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  124|  2.54k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (124:14): [Folded, False: 2.54k]
  |  |  ------------------
  ------------------
  804|  2.54k|            state->nlen = BITS(5) + 257;
  ------------------
  |  |  128|  2.54k|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  805|  2.54k|            DROPBITS(5);
  ------------------
  |  |  132|  2.54k|    do { \
  |  |  133|  2.54k|        unsigned u = (unsigned)(n); \
  |  |  134|  2.54k|        hold >>= u; \
  |  |  135|  2.54k|        bits -= (bits_t)u; \
  |  |  136|  2.54k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 2.54k]
  |  |  ------------------
  ------------------
  806|  2.54k|            state->ndist = BITS(5) + 1;
  ------------------
  |  |  128|  2.54k|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  807|  2.54k|            DROPBITS(5);
  ------------------
  |  |  132|  2.54k|    do { \
  |  |  133|  2.54k|        unsigned u = (unsigned)(n); \
  |  |  134|  2.54k|        hold >>= u; \
  |  |  135|  2.54k|        bits -= (bits_t)u; \
  |  |  136|  2.54k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 2.54k]
  |  |  ------------------
  ------------------
  808|  2.54k|            state->ncode = BITS(4) + 4;
  ------------------
  |  |  128|  2.54k|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  809|  2.54k|            DROPBITS(4);
  ------------------
  |  |  132|  2.54k|    do { \
  |  |  133|  2.54k|        unsigned u = (unsigned)(n); \
  |  |  134|  2.54k|        hold >>= u; \
  |  |  135|  2.54k|        bits -= (bits_t)u; \
  |  |  136|  2.54k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 2.54k]
  |  |  ------------------
  ------------------
  810|  2.54k|#ifndef PKZIP_BUG_WORKAROUND
  811|  2.54k|            if (state->nlen > 286 || state->ndist > 30) {
  ------------------
  |  Branch (811:17): [True: 0, False: 2.54k]
  |  Branch (811:38): [True: 0, False: 2.54k]
  ------------------
  812|      0|                SET_BAD("too many length or distance symbols");
  ------------------
  |  |  147|      0|    do { \
  |  |  148|      0|        state->mode = BAD; \
  |  |  149|      0|        strm->msg = (z_const char *)errmsg; \
  |  |  150|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (150:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  813|      0|                break;
  814|      0|            }
  815|  2.54k|#endif
  816|  2.54k|            Tracev((stderr, "inflate:       table sizes ok\n"));
  817|  2.54k|            state->have = 0;
  818|  2.54k|            state->mode = LENLENS;
  819|  2.54k|            Z_FALLTHROUGH;
  ------------------
  |  |   54|  2.54k|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  820|       |
  821|  2.54k|        case LENLENS:
  ------------------
  |  Branch (821:9): [True: 0, False: 30.2k]
  ------------------
  822|       |            /* get code length code lengths (not a typo) */
  823|  48.2k|            while (state->have < state->ncode) {
  ------------------
  |  Branch (823:20): [True: 45.7k, False: 2.54k]
  ------------------
  824|  45.7k|                NEEDBITS(3);
  ------------------
  |  |  120|  45.7k|    do { \
  |  |  121|  45.7k|        unsigned u = (unsigned)(n); \
  |  |  122|  60.9k|        while (bits < (bits_t)u) \
  |  |  ------------------
  |  |  |  Branch (122:16): [True: 15.2k, False: 45.7k]
  |  |  ------------------
  |  |  123|  45.7k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  389|  15.2k|    do { \
  |  |  |  |  390|  15.2k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:13): [True: 0, False: 15.2k]
  |  |  |  |  ------------------
  |  |  |  |  391|  15.2k|        have--; \
  |  |  |  |  392|  15.2k|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  393|  15.2k|        bits += 8; \
  |  |  |  |  394|  15.2k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (394:14): [Folded, False: 15.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  124|  45.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (124:14): [Folded, False: 45.7k]
  |  |  ------------------
  ------------------
  825|  45.7k|                state->lens[order[state->have++]] = (uint16_t)BITS(3);
  ------------------
  |  |  128|  45.7k|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  826|  45.7k|                DROPBITS(3);
  ------------------
  |  |  132|  45.7k|    do { \
  |  |  133|  45.7k|        unsigned u = (unsigned)(n); \
  |  |  134|  45.7k|        hold >>= u; \
  |  |  135|  45.7k|        bits -= (bits_t)u; \
  |  |  136|  45.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 45.7k]
  |  |  ------------------
  ------------------
  827|  45.7k|            }
  828|  5.08k|            while (state->have < 19)
  ------------------
  |  Branch (828:20): [True: 2.54k, False: 2.54k]
  ------------------
  829|  2.54k|                state->lens[order[state->have++]] = 0;
  830|  2.54k|            state->next = state->codes;
  831|  2.54k|            state->lencode = state->distcode = (const code *)(state->next);
  832|  2.54k|            state->lenbits = 7;
  833|  2.54k|            ret = zng_inflate_table(CODES, state->lens, 19, &(state->next), &(state->lenbits), state->work);
  834|  2.54k|            if (ret) {
  ------------------
  |  Branch (834:17): [True: 0, False: 2.54k]
  ------------------
  835|      0|                SET_BAD("invalid code lengths set");
  ------------------
  |  |  147|      0|    do { \
  |  |  148|      0|        state->mode = BAD; \
  |  |  149|      0|        strm->msg = (z_const char *)errmsg; \
  |  |  150|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (150:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  836|      0|                break;
  837|      0|            }
  838|  2.54k|            Tracev((stderr, "inflate:       code lengths ok\n"));
  839|  2.54k|            state->have = 0;
  840|  2.54k|            state->mode = CODELENS;
  841|  2.54k|            Z_FALLTHROUGH;
  ------------------
  |  |   54|  2.54k|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  842|       |
  843|  2.54k|        case CODELENS:
  ------------------
  |  Branch (843:9): [True: 0, False: 30.2k]
  ------------------
  844|       |            /* get length and distance code code lengths */
  845|  27.5k|            while (state->have < state->nlen + state->ndist) {
  ------------------
  |  Branch (845:20): [True: 24.9k, False: 2.54k]
  ------------------
  846|  31.3k|                for (;;) {
  847|  31.3k|                    here = state->lencode[BITS(state->lenbits)];
  ------------------
  |  |  128|  31.3k|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  848|  31.3k|                    if (here.bits <= bits) break;
  ------------------
  |  Branch (848:25): [True: 24.9k, False: 6.40k]
  ------------------
  849|  6.40k|                    PULLBYTE();
  ------------------
  |  |  389|  6.40k|    do { \
  |  |  390|  6.40k|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (390:13): [True: 0, False: 6.40k]
  |  |  ------------------
  |  |  391|  6.40k|        have--; \
  |  |  392|  6.40k|        hold += ((uint64_t)(*next++) << bits); \
  |  |  393|  6.40k|        bits += 8; \
  |  |  394|  6.40k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (394:14): [Folded, False: 6.40k]
  |  |  ------------------
  ------------------
  850|  6.40k|                }
  851|  24.9k|                if (here.val < 16) {
  ------------------
  |  Branch (851:21): [True: 14.6k, False: 10.3k]
  ------------------
  852|  14.6k|                    DROPBITS(here.bits);
  ------------------
  |  |  132|  14.6k|    do { \
  |  |  133|  14.6k|        unsigned u = (unsigned)(n); \
  |  |  134|  14.6k|        hold >>= u; \
  |  |  135|  14.6k|        bits -= (bits_t)u; \
  |  |  136|  14.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 14.6k]
  |  |  ------------------
  ------------------
  853|  14.6k|                    state->lens[state->have++] = here.val;
  854|  14.6k|                } else {
  855|  10.3k|                    if (here.val == 16) {
  ------------------
  |  Branch (855:25): [True: 0, False: 10.3k]
  ------------------
  856|      0|                        NEEDBITS(here.bits + 2);
  ------------------
  |  |  120|      0|    do { \
  |  |  121|      0|        unsigned u = (unsigned)(n); \
  |  |  122|      0|        while (bits < (bits_t)u) \
  |  |  ------------------
  |  |  |  Branch (122:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  123|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  389|      0|    do { \
  |  |  |  |  390|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  391|      0|        have--; \
  |  |  |  |  392|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  393|      0|        bits += 8; \
  |  |  |  |  394|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (394:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  124|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (124:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  857|      0|                        DROPBITS(here.bits);
  ------------------
  |  |  132|      0|    do { \
  |  |  133|      0|        unsigned u = (unsigned)(n); \
  |  |  134|      0|        hold >>= u; \
  |  |  135|      0|        bits -= (bits_t)u; \
  |  |  136|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  858|      0|                        if (state->have == 0) {
  ------------------
  |  Branch (858:29): [True: 0, False: 0]
  ------------------
  859|      0|                            SET_BAD("invalid bit length repeat");
  ------------------
  |  |  147|      0|    do { \
  |  |  148|      0|        state->mode = BAD; \
  |  |  149|      0|        strm->msg = (z_const char *)errmsg; \
  |  |  150|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (150:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  860|      0|                            break;
  861|      0|                        }
  862|      0|                        len = state->lens[state->have - 1];
  863|      0|                        copy = 3 + BITS(2);
  ------------------
  |  |  128|      0|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  864|      0|                        DROPBITS(2);
  ------------------
  |  |  132|      0|    do { \
  |  |  133|      0|        unsigned u = (unsigned)(n); \
  |  |  134|      0|        hold >>= u; \
  |  |  135|      0|        bits -= (bits_t)u; \
  |  |  136|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  865|  10.3k|                    } else if (here.val == 17) {
  ------------------
  |  Branch (865:32): [True: 1.11k, False: 9.18k]
  ------------------
  866|  1.11k|                        NEEDBITS(here.bits + 3);
  ------------------
  |  |  120|  1.11k|    do { \
  |  |  121|  1.11k|        unsigned u = (unsigned)(n); \
  |  |  122|  1.56k|        while (bits < (bits_t)u) \
  |  |  ------------------
  |  |  |  Branch (122:16): [True: 453, False: 1.11k]
  |  |  ------------------
  |  |  123|  1.11k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  389|    453|    do { \
  |  |  |  |  390|    453|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:13): [True: 0, False: 453]
  |  |  |  |  ------------------
  |  |  |  |  391|    453|        have--; \
  |  |  |  |  392|    453|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  393|    453|        bits += 8; \
  |  |  |  |  394|    453|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (394:14): [Folded, False: 453]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  124|  1.11k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (124:14): [Folded, False: 1.11k]
  |  |  ------------------
  ------------------
  867|  1.11k|                        DROPBITS(here.bits);
  ------------------
  |  |  132|  1.11k|    do { \
  |  |  133|  1.11k|        unsigned u = (unsigned)(n); \
  |  |  134|  1.11k|        hold >>= u; \
  |  |  135|  1.11k|        bits -= (bits_t)u; \
  |  |  136|  1.11k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 1.11k]
  |  |  ------------------
  ------------------
  868|  1.11k|                        len = 0;
  869|  1.11k|                        copy = 3 + BITS(3);
  ------------------
  |  |  128|  1.11k|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  870|  1.11k|                        DROPBITS(3);
  ------------------
  |  |  132|  1.11k|    do { \
  |  |  133|  1.11k|        unsigned u = (unsigned)(n); \
  |  |  134|  1.11k|        hold >>= u; \
  |  |  135|  1.11k|        bits -= (bits_t)u; \
  |  |  136|  1.11k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 1.11k]
  |  |  ------------------
  ------------------
  871|  9.18k|                    } else {
  872|  9.18k|                        NEEDBITS(here.bits + 7);
  ------------------
  |  |  120|  9.18k|    do { \
  |  |  121|  9.18k|        unsigned u = (unsigned)(n); \
  |  |  122|  18.1k|        while (bits < (bits_t)u) \
  |  |  ------------------
  |  |  |  Branch (122:16): [True: 8.91k, False: 9.18k]
  |  |  ------------------
  |  |  123|  9.18k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  389|  8.91k|    do { \
  |  |  |  |  390|  8.91k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:13): [True: 0, False: 8.91k]
  |  |  |  |  ------------------
  |  |  |  |  391|  8.91k|        have--; \
  |  |  |  |  392|  8.91k|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  393|  8.91k|        bits += 8; \
  |  |  |  |  394|  8.91k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (394:14): [Folded, False: 8.91k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  124|  9.18k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (124:14): [Folded, False: 9.18k]
  |  |  ------------------
  ------------------
  873|  9.18k|                        DROPBITS(here.bits);
  ------------------
  |  |  132|  9.18k|    do { \
  |  |  133|  9.18k|        unsigned u = (unsigned)(n); \
  |  |  134|  9.18k|        hold >>= u; \
  |  |  135|  9.18k|        bits -= (bits_t)u; \
  |  |  136|  9.18k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 9.18k]
  |  |  ------------------
  ------------------
  874|  9.18k|                        len = 0;
  875|  9.18k|                        copy = 11 + BITS(7);
  ------------------
  |  |  128|  9.18k|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  876|  9.18k|                        DROPBITS(7);
  ------------------
  |  |  132|  9.18k|    do { \
  |  |  133|  9.18k|        unsigned u = (unsigned)(n); \
  |  |  134|  9.18k|        hold >>= u; \
  |  |  135|  9.18k|        bits -= (bits_t)u; \
  |  |  136|  9.18k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 9.18k]
  |  |  ------------------
  ------------------
  877|  9.18k|                    }
  878|  10.3k|                    if (state->have + copy > state->nlen + state->ndist) {
  ------------------
  |  Branch (878:25): [True: 0, False: 10.3k]
  ------------------
  879|      0|                        SET_BAD("invalid bit length repeat");
  ------------------
  |  |  147|      0|    do { \
  |  |  148|      0|        state->mode = BAD; \
  |  |  149|      0|        strm->msg = (z_const char *)errmsg; \
  |  |  150|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (150:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  880|      0|                        break;
  881|      0|                    }
  882|   746k|                    while (copy) {
  ------------------
  |  Branch (882:28): [True: 735k, False: 10.3k]
  ------------------
  883|   735k|                        --copy;
  884|   735k|                        state->lens[state->have++] = (uint16_t)len;
  885|   735k|                    }
  886|  10.3k|                }
  887|  24.9k|            }
  888|       |
  889|       |            /* handle error breaks in while */
  890|  2.54k|            if (state->mode == BAD)
  ------------------
  |  Branch (890:17): [True: 0, False: 2.54k]
  ------------------
  891|      0|                break;
  892|       |
  893|       |            /* check for end-of-block code (better have one) */
  894|  2.54k|            if (state->lens[256] == 0) {
  ------------------
  |  Branch (894:17): [True: 0, False: 2.54k]
  ------------------
  895|      0|                SET_BAD("invalid code -- missing end-of-block");
  ------------------
  |  |  147|      0|    do { \
  |  |  148|      0|        state->mode = BAD; \
  |  |  149|      0|        strm->msg = (z_const char *)errmsg; \
  |  |  150|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (150:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  896|      0|                break;
  897|      0|            }
  898|       |
  899|       |            /* build code tables -- note: do not change the lenbits or distbits
  900|       |               values here (MAX_LEN_ROOT_BITS and 9) without reading the comments
  901|       |               in inftrees.h concerning the ENOUGH constants, which depend on
  902|       |               those values, and the refill comments in inffast_tpl.h, which
  903|       |               depend on lenbits never exceeding MAX_LEN_ROOT_BITS */
  904|  2.54k|            state->next = state->codes;
  905|  2.54k|            state->lencode = (const code *)(state->next);
  906|  2.54k|            state->lenbits = MAX_LEN_ROOT_BITS;
  ------------------
  |  |   45|  2.54k|#define MAX_LEN_ROOT_BITS 10
  ------------------
  907|  2.54k|            ret = zng_inflate_table(LENS, state->lens, state->nlen, &(state->next), &(state->lenbits), state->work);
  908|  2.54k|            if (ret) {
  ------------------
  |  Branch (908:17): [True: 0, False: 2.54k]
  ------------------
  909|      0|                SET_BAD("invalid literal/lengths set");
  ------------------
  |  |  147|      0|    do { \
  |  |  148|      0|        state->mode = BAD; \
  |  |  149|      0|        strm->msg = (z_const char *)errmsg; \
  |  |  150|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (150:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  910|      0|                break;
  911|      0|            }
  912|  2.54k|            state->distcode = (const code *)(state->next);
  913|  2.54k|            state->distbits = 9;
  914|  2.54k|            ret = zng_inflate_table(DISTS, state->lens + state->nlen, state->ndist,
  915|  2.54k|                            &(state->next), &(state->distbits), state->work);
  916|  2.54k|            if (ret) {
  ------------------
  |  Branch (916:17): [True: 0, False: 2.54k]
  ------------------
  917|      0|                SET_BAD("invalid distances set");
  ------------------
  |  |  147|      0|    do { \
  |  |  148|      0|        state->mode = BAD; \
  |  |  149|      0|        strm->msg = (z_const char *)errmsg; \
  |  |  150|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (150:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  918|      0|                break;
  919|      0|            }
  920|  2.54k|            Tracev((stderr, "inflate:       codes ok\n"));
  921|  2.54k|            state->mode = LEN_;
  922|  2.54k|            if (flush == Z_TREES)
  ------------------
  |  |  177|  2.54k|#define Z_TREES         6
  ------------------
  |  Branch (922:17): [True: 0, False: 2.54k]
  ------------------
  923|      0|                goto inf_leave;
  924|  2.54k|            Z_FALLTHROUGH;
  ------------------
  |  |   54|  2.54k|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  925|       |
  926|  3.16k|        case LEN_:
  ------------------
  |  Branch (926:9): [True: 619, False: 29.6k]
  ------------------
  927|  3.16k|            state->mode = LEN;
  928|  3.16k|            Z_FALLTHROUGH;
  ------------------
  |  |   54|  3.16k|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  929|       |
  930|  9.55k|        case LEN:
  ------------------
  |  Branch (930:9): [True: 6.39k, False: 23.8k]
  ------------------
  931|       |            /* use inflate_fast() if we have enough input and output */
  932|  9.55k|            if (have >= INFLATE_FAST_MIN_HAVE && left >= INFLATE_FAST_MIN_SAFE) {
  ------------------
  |  |  201|  19.1k|#define INFLATE_FAST_MIN_HAVE 15
  ------------------
                          if (have >= INFLATE_FAST_MIN_HAVE && left >= INFLATE_FAST_MIN_SAFE) {
  ------------------
  |  |  203|  9.55k|#define INFLATE_FAST_MIN_SAFE 3    /* max unchecked literal writes per iteration */
  ------------------
  |  Branch (932:17): [True: 9.55k, False: 0]
  |  Branch (932:50): [True: 7.65k, False: 1.90k]
  ------------------
  933|  7.65k|                RESTORE();
  ------------------
  |  |   94|  7.65k|    do { \
  |  |   95|  7.65k|        strm->next_out = put; \
  |  |   96|  7.65k|        strm->avail_out = left; \
  |  |   97|  7.65k|        strm->next_in = (z_const unsigned char *)next; \
  |  |   98|  7.65k|        strm->avail_in = have; \
  |  |   99|  7.65k|        state->hold = hold; \
  |  |  100|  7.65k|        state->bits = bits; \
  |  |  101|  7.65k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (101:14): [Folded, False: 7.65k]
  |  |  ------------------
  ------------------
  934|  7.65k|                FUNCTABLE_CALL(inflate_fast)(strm, out, left < INFLATE_FAST_MIN_LEFT);
  ------------------
  |  |   46|  7.65k|#  define FUNCTABLE_CALL(name) functable.name
  ------------------
                              FUNCTABLE_CALL(inflate_fast)(strm, out, left < INFLATE_FAST_MIN_LEFT);
  ------------------
  |  |  202|  7.65k|#define INFLATE_FAST_MIN_LEFT 260  /* max output per token (258) + 2 */
  ------------------
  935|  7.65k|                LOAD();
  ------------------
  |  |   83|  7.65k|    do { \
  |  |   84|  7.65k|        put = strm->next_out; \
  |  |   85|  7.65k|        left = strm->avail_out; \
  |  |   86|  7.65k|        next = strm->next_in; \
  |  |   87|  7.65k|        have = strm->avail_in; \
  |  |   88|  7.65k|        hold = state->hold; \
  |  |   89|  7.65k|        bits = (bits_t)state->bits; \
  |  |   90|  7.65k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (90:14): [Folded, False: 7.65k]
  |  |  ------------------
  ------------------
  936|  7.65k|                if (state->mode == TYPE)
  ------------------
  |  Branch (936:21): [True: 1.58k, False: 6.07k]
  ------------------
  937|  1.58k|                    state->back = -1;
  938|  7.65k|                break;
  939|  7.65k|            }
  940|  1.90k|            state->back = 0;
  941|       |
  942|       |            /* get a literal, length, or end-of-block code */
  943|  2.70k|            for (;;) {
  944|  2.70k|                here = state->lencode[BITS(state->lenbits)];
  ------------------
  |  |  128|  2.70k|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  945|  2.70k|                if (CODE_BITS(here) <= bits)
  ------------------
  |  |  162|  2.70k|    ((unsigned)((here.op & 16) ? (here.op & 15) : here.bits))
  |  |  ------------------
  |  |  |  Branch (162:17): [True: 188, False: 2.52k]
  |  |  ------------------
  ------------------
  |  Branch (945:21): [True: 1.90k, False: 807]
  ------------------
  946|  1.90k|                    break;
  947|    807|                PULLBYTE();
  ------------------
  |  |  389|    807|    do { \
  |  |  390|    807|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (390:13): [True: 0, False: 807]
  |  |  ------------------
  |  |  391|    807|        have--; \
  |  |  392|    807|        hold += ((uint64_t)(*next++) << bits); \
  |  |  393|    807|        bits += 8; \
  |  |  394|    807|    } while (0)
  |  |  ------------------
  |  |  |  Branch (394:14): [Folded, False: 807]
  |  |  ------------------
  ------------------
  948|    807|            }
  949|  1.90k|            if (here.op && (here.op & 0xf0) == 0) {
  ------------------
  |  Branch (949:17): [True: 1.63k, False: 272]
  |  Branch (949:28): [True: 0, False: 1.63k]
  ------------------
  950|      0|                unsigned last_bits;
  951|      0|                last = here;
  952|      0|                last_bits = CODE_BITS(last);
  ------------------
  |  |  162|      0|    ((unsigned)((here.op & 16) ? (here.op & 15) : here.bits))
  |  |  ------------------
  |  |  |  Branch (162:17): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  953|      0|                for (;;) {
  954|      0|                    here = state->lencode[last.val + (BITS(last_bits + (last.op & 15)) >> last_bits)];
  ------------------
  |  |  128|      0|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  955|      0|                    if (last_bits + CODE_BITS(here) <= bits)
  ------------------
  |  |  162|      0|    ((unsigned)((here.op & 16) ? (here.op & 15) : here.bits))
  |  |  ------------------
  |  |  |  Branch (162:17): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (955:25): [True: 0, False: 0]
  ------------------
  956|      0|                        break;
  957|      0|                    PULLBYTE();
  ------------------
  |  |  389|      0|    do { \
  |  |  390|      0|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (390:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  391|      0|        have--; \
  |  |  392|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  393|      0|        bits += 8; \
  |  |  394|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (394:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  958|      0|                }
  959|      0|                DROPBITS(last_bits);
  ------------------
  |  |  132|      0|    do { \
  |  |  133|      0|        unsigned u = (unsigned)(n); \
  |  |  134|      0|        hold >>= u; \
  |  |  135|      0|        bits -= (bits_t)u; \
  |  |  136|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  960|      0|                state->back += last_bits;
  961|      0|            }
  962|  1.90k|            code_bits = CODE_BITS(here);
  ------------------
  |  |  162|  1.90k|    ((unsigned)((here.op & 16) ? (here.op & 15) : here.bits))
  |  |  ------------------
  |  |  |  Branch (162:17): [True: 50, False: 1.85k]
  |  |  ------------------
  ------------------
  963|  1.90k|            DROPBITS(code_bits);
  ------------------
  |  |  132|  1.90k|    do { \
  |  |  133|  1.90k|        unsigned u = (unsigned)(n); \
  |  |  134|  1.90k|        hold >>= u; \
  |  |  135|  1.90k|        bits -= (bits_t)u; \
  |  |  136|  1.90k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 1.90k]
  |  |  ------------------
  ------------------
  964|  1.90k|            state->back += code_bits;
  965|  1.90k|            state->length = here.val;
  966|       |
  967|       |            /* process literal */
  968|  1.90k|            if ((int)(here.op) == 0) {
  ------------------
  |  Branch (968:17): [True: 272, False: 1.63k]
  ------------------
  969|    272|                TRACE_LITERAL(here.val);
  970|    272|                state->mode = LIT;
  971|    272|                break;
  972|    272|            }
  973|       |
  974|       |            /* process end of block */
  975|  1.63k|            if (here.op & 32) {
  ------------------
  |  Branch (975:17): [True: 1.58k, False: 50]
  ------------------
  976|  1.58k|                TRACE_END_OF_BLOCK();
  977|  1.58k|                state->back = -1;
  978|  1.58k|                state->mode = TYPE;
  979|  1.58k|                break;
  980|  1.58k|            }
  981|       |
  982|       |            /* invalid code */
  983|     50|            if (here.op & 64) {
  ------------------
  |  Branch (983:17): [True: 0, False: 50]
  ------------------
  984|      0|                SET_BAD("invalid literal/length code");
  ------------------
  |  |  147|      0|    do { \
  |  |  148|      0|        state->mode = BAD; \
  |  |  149|      0|        strm->msg = (z_const char *)errmsg; \
  |  |  150|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (150:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  985|      0|                break;
  986|      0|            }
  987|       |
  988|       |            /* length code */
  989|     50|            state->extra = CODE_EXTRA(here);
  ------------------
  |  |  166|     50|    ((unsigned)((here.op & 16) ? (here.bits - (here.op & 15)) : 0))
  |  |  ------------------
  |  |  |  Branch (166:17): [True: 50, False: 0]
  |  |  ------------------
  ------------------
  990|     50|            state->mode = LENEXT;
  991|     50|            Z_FALLTHROUGH;
  ------------------
  |  |   54|     50|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  992|       |
  993|     50|        case LENEXT:
  ------------------
  |  Branch (993:9): [True: 0, False: 30.2k]
  ------------------
  994|       |            /* get extra bits, if any */
  995|     50|            if (state->extra) {
  ------------------
  |  Branch (995:17): [True: 38, False: 12]
  ------------------
  996|     38|                NEEDBITS(state->extra);
  ------------------
  |  |  120|     38|    do { \
  |  |  121|     38|        unsigned u = (unsigned)(n); \
  |  |  122|     60|        while (bits < (bits_t)u) \
  |  |  ------------------
  |  |  |  Branch (122:16): [True: 22, False: 38]
  |  |  ------------------
  |  |  123|     38|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  389|     22|    do { \
  |  |  |  |  390|     22|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:13): [True: 0, False: 22]
  |  |  |  |  ------------------
  |  |  |  |  391|     22|        have--; \
  |  |  |  |  392|     22|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  393|     22|        bits += 8; \
  |  |  |  |  394|     22|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (394:14): [Folded, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  124|     38|    } while (0)
  |  |  ------------------
  |  |  |  Branch (124:14): [Folded, False: 38]
  |  |  ------------------
  ------------------
  997|     38|                state->length += BITS(state->extra);
  ------------------
  |  |  128|     38|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  998|     38|                DROPBITS(state->extra);
  ------------------
  |  |  132|     38|    do { \
  |  |  133|     38|        unsigned u = (unsigned)(n); \
  |  |  134|     38|        hold >>= u; \
  |  |  135|     38|        bits -= (bits_t)u; \
  |  |  136|     38|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 38]
  |  |  ------------------
  ------------------
  999|     38|                state->back += state->extra;
 1000|     38|            }
 1001|     50|            TRACE_LENGTH(state->length);
 1002|     50|            state->was = state->length;
 1003|     50|            state->mode = DIST;
 1004|     50|            Z_FALLTHROUGH;
  ------------------
  |  |   54|     50|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 1005|       |
 1006|     50|        case DIST:
  ------------------
  |  Branch (1006:9): [True: 0, False: 30.2k]
  ------------------
 1007|       |            /* get distance code */
 1008|     63|            for (;;) {
 1009|     63|                here = state->distcode[BITS(state->distbits)];
  ------------------
  |  |  128|     63|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
 1010|     63|                if (CODE_BITS(here) <= bits)
  ------------------
  |  |  162|     63|    ((unsigned)((here.op & 16) ? (here.op & 15) : here.bits))
  |  |  ------------------
  |  |  |  Branch (162:17): [True: 63, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1010:21): [True: 50, False: 13]
  ------------------
 1011|     50|                    break;
 1012|     13|                PULLBYTE();
  ------------------
  |  |  389|     13|    do { \
  |  |  390|     13|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (390:13): [True: 0, False: 13]
  |  |  ------------------
  |  |  391|     13|        have--; \
  |  |  392|     13|        hold += ((uint64_t)(*next++) << bits); \
  |  |  393|     13|        bits += 8; \
  |  |  394|     13|    } while (0)
  |  |  ------------------
  |  |  |  Branch (394:14): [Folded, False: 13]
  |  |  ------------------
  ------------------
 1013|     13|            }
 1014|     50|            if ((here.op & 0xf0) == 0) {
  ------------------
  |  Branch (1014:17): [True: 0, False: 50]
  ------------------
 1015|      0|                unsigned last_bits;
 1016|      0|                last = here;
 1017|      0|                last_bits = CODE_BITS(last);
  ------------------
  |  |  162|      0|    ((unsigned)((here.op & 16) ? (here.op & 15) : here.bits))
  |  |  ------------------
  |  |  |  Branch (162:17): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1018|      0|                for (;;) {
 1019|      0|                    here = state->distcode[last.val + (BITS(last_bits + (last.op & 15)) >> last_bits)];
  ------------------
  |  |  128|      0|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
 1020|      0|                    if (last_bits + CODE_BITS(here) <= bits)
  ------------------
  |  |  162|      0|    ((unsigned)((here.op & 16) ? (here.op & 15) : here.bits))
  |  |  ------------------
  |  |  |  Branch (162:17): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1020:25): [True: 0, False: 0]
  ------------------
 1021|      0|                        break;
 1022|      0|                    PULLBYTE();
  ------------------
  |  |  389|      0|    do { \
  |  |  390|      0|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (390:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  391|      0|        have--; \
  |  |  392|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  393|      0|        bits += 8; \
  |  |  394|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (394:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1023|      0|                }
 1024|      0|                DROPBITS(last_bits);
  ------------------
  |  |  132|      0|    do { \
  |  |  133|      0|        unsigned u = (unsigned)(n); \
  |  |  134|      0|        hold >>= u; \
  |  |  135|      0|        bits -= (bits_t)u; \
  |  |  136|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1025|      0|                state->back += last_bits;
 1026|      0|            }
 1027|     50|            code_bits = CODE_BITS(here);
  ------------------
  |  |  162|     50|    ((unsigned)((here.op & 16) ? (here.op & 15) : here.bits))
  |  |  ------------------
  |  |  |  Branch (162:17): [True: 50, False: 0]
  |  |  ------------------
  ------------------
 1028|     50|            DROPBITS(code_bits);
  ------------------
  |  |  132|     50|    do { \
  |  |  133|     50|        unsigned u = (unsigned)(n); \
  |  |  134|     50|        hold >>= u; \
  |  |  135|     50|        bits -= (bits_t)u; \
  |  |  136|     50|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 50]
  |  |  ------------------
  ------------------
 1029|     50|            state->back += code_bits;
 1030|     50|            if (here.op & 64) {
  ------------------
  |  Branch (1030:17): [True: 0, False: 50]
  ------------------
 1031|      0|                SET_BAD("invalid distance code");
  ------------------
  |  |  147|      0|    do { \
  |  |  148|      0|        state->mode = BAD; \
  |  |  149|      0|        strm->msg = (z_const char *)errmsg; \
  |  |  150|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (150:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1032|      0|                break;
 1033|      0|            }
 1034|     50|            state->offset = here.val;
 1035|     50|            state->extra = CODE_EXTRA(here);
  ------------------
  |  |  166|     50|    ((unsigned)((here.op & 16) ? (here.bits - (here.op & 15)) : 0))
  |  |  ------------------
  |  |  |  Branch (166:17): [True: 50, False: 0]
  |  |  ------------------
  ------------------
 1036|     50|            state->mode = DISTEXT;
 1037|     50|            Z_FALLTHROUGH;
  ------------------
  |  |   54|     50|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 1038|       |
 1039|     50|        case DISTEXT:
  ------------------
  |  Branch (1039:9): [True: 0, False: 30.2k]
  ------------------
 1040|       |            /* get distance extra bits, if any */
 1041|     50|            if (state->extra) {
  ------------------
  |  Branch (1041:17): [True: 0, False: 50]
  ------------------
 1042|      0|                NEEDBITS(state->extra);
  ------------------
  |  |  120|      0|    do { \
  |  |  121|      0|        unsigned u = (unsigned)(n); \
  |  |  122|      0|        while (bits < (bits_t)u) \
  |  |  ------------------
  |  |  |  Branch (122:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  123|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  389|      0|    do { \
  |  |  |  |  390|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  391|      0|        have--; \
  |  |  |  |  392|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  393|      0|        bits += 8; \
  |  |  |  |  394|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (394:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  124|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (124:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1043|      0|                state->offset += BITS(state->extra);
  ------------------
  |  |  128|      0|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
 1044|      0|                DROPBITS(state->extra);
  ------------------
  |  |  132|      0|    do { \
  |  |  133|      0|        unsigned u = (unsigned)(n); \
  |  |  134|      0|        hold >>= u; \
  |  |  135|      0|        bits -= (bits_t)u; \
  |  |  136|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1045|      0|                state->back += state->extra;
 1046|      0|            }
 1047|       |#ifdef INFLATE_STRICT
 1048|       |            if (state->offset > state->dmax) {
 1049|       |                SET_BAD("invalid distance too far back");
 1050|       |                break;
 1051|       |            }
 1052|       |#endif
 1053|     50|            TRACE_DISTANCE(state->offset);
 1054|     50|            state->mode = MATCH;
 1055|     50|            Z_FALLTHROUGH;
  ------------------
  |  |   54|     50|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 1056|       |
 1057|  6.28k|        case MATCH:
  ------------------
  |  Branch (1057:9): [True: 6.23k, False: 24.0k]
  ------------------
 1058|       |            /* copy match from window to output */
 1059|  6.28k|            if (left == 0)
  ------------------
  |  Branch (1059:17): [True: 1.58k, False: 4.70k]
  ------------------
 1060|  1.58k|                goto inf_leave;
 1061|  4.70k|            copy = out - left;
 1062|  4.70k|            if (state->offset > copy) {         /* copy from window */
  ------------------
  |  Branch (1062:17): [True: 1.58k, False: 3.12k]
  ------------------
 1063|  1.58k|                copy = state->offset - copy;
 1064|  1.58k|                if (copy > state->whave) {
  ------------------
  |  Branch (1064:21): [True: 0, False: 1.58k]
  ------------------
 1065|       |#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
 1066|       |                    if (state->sane) {
 1067|       |                        SET_BAD("invalid distance too far back");
 1068|       |                        break;
 1069|       |                    }
 1070|       |                    Trace((stderr, "inflate.c too far\n"));
 1071|       |                    copy -= state->whave;
 1072|       |                    copy = MIN(copy, state->length);
 1073|       |                    copy = MIN(copy, left);
 1074|       |                    left -= copy;
 1075|       |                    state->length -= copy;
 1076|       |                    do {
 1077|       |                        *put++ = 0;
 1078|       |                    } while (--copy);
 1079|       |                    if (state->length == 0)
 1080|       |                        state->mode = LEN;
 1081|       |#else
 1082|      0|                    SET_BAD("invalid distance too far back");
  ------------------
  |  |  147|      0|    do { \
  |  |  148|      0|        state->mode = BAD; \
  |  |  149|      0|        strm->msg = (z_const char *)errmsg; \
  |  |  150|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (150:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1083|      0|#endif
 1084|      0|                    break;
 1085|      0|                }
 1086|  1.58k|                if (copy > state->wnext) {
  ------------------
  |  Branch (1086:21): [True: 739, False: 842]
  ------------------
 1087|    739|                    copy -= state->wnext;
 1088|    739|                    from = state->window + (state->wsize - copy);
 1089|    842|                } else {
 1090|    842|                    from = state->window + (state->wnext - copy);
 1091|    842|                }
 1092|  1.58k|                copy = MIN(copy, state->length);
  ------------------
  |  |  148|  1.58k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 1, False: 1.58k]
  |  |  ------------------
  ------------------
 1093|  1.58k|                copy = MIN(copy, left);
  ------------------
  |  |  148|  1.58k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 1, False: 1.58k]
  |  |  ------------------
  ------------------
 1094|       |
 1095|  1.58k|                put = chunkcopy_safe(put, from, copy, put + left);
 1096|  3.12k|            } else {
 1097|  3.12k|                copy = MIN(state->length, left);
  ------------------
  |  |  148|  3.12k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 1.56k, False: 1.56k]
  |  |  ------------------
  ------------------
 1098|       |
 1099|  3.12k|                put = FUNCTABLE_CALL(chunkmemset_safe)(put, put - state->offset, copy, left);
  ------------------
  |  |   46|  3.12k|#  define FUNCTABLE_CALL(name) functable.name
  ------------------
 1100|  3.12k|            }
 1101|  4.70k|            left -= copy;
 1102|  4.70k|            state->length -= copy;
 1103|  4.70k|            if (state->length == 0)
  ------------------
  |  Branch (1103:17): [True: 1.58k, False: 3.12k]
  ------------------
 1104|  1.58k|                state->mode = LEN;
 1105|  4.70k|            break;
 1106|       |
 1107|    272|        case LIT:
  ------------------
  |  Branch (1107:9): [True: 272, False: 30.0k]
  ------------------
 1108|    272|            if (left == 0)
  ------------------
  |  Branch (1108:17): [True: 0, False: 272]
  ------------------
 1109|      0|                goto inf_leave;
 1110|    272|            *put++ = (unsigned char)(state->length);
 1111|    272|            left--;
 1112|    272|            state->mode = LEN;
 1113|    272|            break;
 1114|       |
 1115|  1.58k|        case CHECK:
  ------------------
  |  Branch (1115:9): [True: 1.58k, False: 28.7k]
  ------------------
 1116|  1.58k|            if (state->wrap) {
  ------------------
  |  Branch (1116:17): [True: 1.58k, False: 0]
  ------------------
 1117|  1.58k|                NEEDBITS(32);
  ------------------
  |  |  120|  1.58k|    do { \
  |  |  121|  1.58k|        unsigned u = (unsigned)(n); \
  |  |  122|  7.90k|        while (bits < (bits_t)u) \
  |  |  ------------------
  |  |  |  Branch (122:16): [True: 6.32k, False: 1.58k]
  |  |  ------------------
  |  |  123|  6.32k|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  389|  6.32k|    do { \
  |  |  |  |  390|  6.32k|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:13): [True: 0, False: 6.32k]
  |  |  |  |  ------------------
  |  |  |  |  391|  6.32k|        have--; \
  |  |  |  |  392|  6.32k|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  393|  6.32k|        bits += 8; \
  |  |  |  |  394|  6.32k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (394:14): [Folded, False: 6.32k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  124|  1.58k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (124:14): [Folded, False: 1.58k]
  |  |  ------------------
  ------------------
 1118|  1.58k|                out -= left;
 1119|  1.58k|                strm->total_out += out;
 1120|  1.58k|                state->total += out;
 1121|       |
 1122|       |                /* compute crc32 checksum if not in raw mode */
 1123|  1.58k|                if (INFLATE_NEED_CHECKSUM(strm) && state->wrap & 4) {
  ------------------
  |  |   34|  3.16k|#  define INFLATE_NEED_CHECKSUM(strm) 1
  |  |  ------------------
  |  |  |  Branch (34:39): [True: 1.58k, Folded]
  |  |  ------------------
  ------------------
  |  Branch (1123:52): [True: 1.58k, False: 0]
  ------------------
 1124|  1.58k|                    if (out) {
  ------------------
  |  Branch (1124:25): [True: 1.58k, False: 0]
  ------------------
 1125|  1.58k|                        inf_chksum(strm, put - out, out);
 1126|  1.58k|                    }
 1127|  1.58k|                }
 1128|  1.58k|                out = left;
 1129|  1.58k|                if ((state->wrap & 4) && (
  ------------------
  |  Branch (1129:21): [True: 1.58k, False: 0]
  |  Branch (1129:42): [True: 0, False: 1.58k]
  ------------------
 1130|  1.58k|#ifdef GUNZIP
 1131|  1.58k|                     state->flags ? hold :
  ------------------
  |  Branch (1131:22): [True: 0, False: 1.58k]
  ------------------
 1132|  1.58k|#endif
 1133|  1.58k|                     ZSWAP32((unsigned)hold)) != state->check) {
  ------------------
  |  |  214|  1.58k|#  define ZSWAP32(q) __builtin_bswap32(q)
  ------------------
 1134|      0|                    SET_BAD("incorrect data check");
  ------------------
  |  |  147|      0|    do { \
  |  |  148|      0|        state->mode = BAD; \
  |  |  149|      0|        strm->msg = (z_const char *)errmsg; \
  |  |  150|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (150:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1135|      0|                    break;
 1136|      0|                }
 1137|  1.58k|                INITBITS();
  ------------------
  |  |  112|  1.58k|    do { \
  |  |  113|  1.58k|        hold = 0; \
  |  |  114|  1.58k|        bits = 0; \
  |  |  115|  1.58k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (115:14): [Folded, False: 1.58k]
  |  |  ------------------
  ------------------
 1138|  1.58k|                Tracev((stderr, "inflate:   check matches trailer\n"));
 1139|  1.58k|            }
 1140|  1.58k|#ifdef GUNZIP
 1141|  1.58k|            state->mode = LENGTH;
 1142|  1.58k|            Z_FALLTHROUGH;
  ------------------
  |  |   54|  1.58k|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 1143|       |
 1144|  1.58k|        case LENGTH:
  ------------------
  |  Branch (1144:9): [True: 0, False: 30.2k]
  ------------------
 1145|  1.58k|            if (state->wrap && state->flags) {
  ------------------
  |  Branch (1145:17): [True: 1.58k, False: 0]
  |  Branch (1145:32): [True: 0, False: 1.58k]
  ------------------
 1146|      0|                NEEDBITS(32);
  ------------------
  |  |  120|      0|    do { \
  |  |  121|      0|        unsigned u = (unsigned)(n); \
  |  |  122|      0|        while (bits < (bits_t)u) \
  |  |  ------------------
  |  |  |  Branch (122:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  123|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  389|      0|    do { \
  |  |  |  |  390|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (390:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  391|      0|        have--; \
  |  |  |  |  392|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  393|      0|        bits += 8; \
  |  |  |  |  394|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (394:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  124|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (124:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1147|      0|                if ((state->wrap & 4) && hold != (state->total & 0xffffffff)) {
  ------------------
  |  Branch (1147:21): [True: 0, False: 0]
  |  Branch (1147:42): [True: 0, False: 0]
  ------------------
 1148|      0|                    SET_BAD("incorrect length check");
  ------------------
  |  |  147|      0|    do { \
  |  |  148|      0|        state->mode = BAD; \
  |  |  149|      0|        strm->msg = (z_const char *)errmsg; \
  |  |  150|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (150:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1149|      0|                    break;
 1150|      0|                }
 1151|      0|                INITBITS();
  ------------------
  |  |  112|      0|    do { \
  |  |  113|      0|        hold = 0; \
  |  |  114|      0|        bits = 0; \
  |  |  115|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (115:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1152|      0|                Tracev((stderr, "inflate:   length matches trailer\n"));
 1153|      0|            }
 1154|  1.58k|#endif
 1155|  1.58k|            state->mode = DONE;
 1156|  1.58k|            Z_FALLTHROUGH;
  ------------------
  |  |   54|  1.58k|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 1157|       |
 1158|  1.58k|        case DONE:
  ------------------
  |  Branch (1158:9): [True: 0, False: 30.2k]
  ------------------
 1159|       |            /* inflate stream terminated properly */
 1160|  1.58k|            ret = Z_STREAM_END;
  ------------------
  |  |  181|  1.58k|#define Z_STREAM_END    1
  ------------------
 1161|  1.58k|            goto inf_leave;
 1162|       |
 1163|      0|        case BAD:
  ------------------
  |  Branch (1163:9): [True: 0, False: 30.2k]
  ------------------
 1164|      0|            ret = Z_DATA_ERROR;
  ------------------
  |  |  185|      0|#define Z_DATA_ERROR   (-3)
  ------------------
 1165|      0|            goto inf_leave;
 1166|       |
 1167|      0|        case SYNC:
  ------------------
  |  Branch (1167:9): [True: 0, False: 30.2k]
  ------------------
 1168|       |
 1169|      0|        default:                 /* can't happen, but makes compilers happy */
  ------------------
  |  Branch (1169:9): [True: 0, False: 30.2k]
  ------------------
 1170|      0|            return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
 1171|  30.2k|        }
 1172|       |
 1173|       |    /*
 1174|       |       Return from inflate(), updating the total counts and the check value.
 1175|       |       If there was no progress during the inflate() call, return a buffer
 1176|       |       error.  Call updatewindow() to create and/or update the window state.
 1177|       |     */
 1178|  4.74k|  inf_leave:
 1179|  4.74k|    RESTORE();
  ------------------
  |  |   94|  4.74k|    do { \
  |  |   95|  4.74k|        strm->next_out = put; \
  |  |   96|  4.74k|        strm->avail_out = left; \
  |  |   97|  4.74k|        strm->next_in = (z_const unsigned char *)next; \
  |  |   98|  4.74k|        strm->avail_in = have; \
  |  |   99|  4.74k|        state->hold = hold; \
  |  |  100|  4.74k|        state->bits = bits; \
  |  |  101|  4.74k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (101:14): [Folded, False: 4.74k]
  |  |  ------------------
  ------------------
 1180|  4.74k|    uint32_t check_bytes = out - strm->avail_out;
 1181|  4.74k|    if (INFLATE_NEED_UPDATEWINDOW(strm) &&
  ------------------
  |  |   36|  9.48k|#  define INFLATE_NEED_UPDATEWINDOW(strm) 1
  |  |  ------------------
  |  |  |  Branch (36:43): [True: 4.74k, Folded]
  |  |  ------------------
  ------------------
 1182|  4.74k|            (state->wsize || (out != strm->avail_out && state->mode < BAD &&
  ------------------
  |  Branch (1182:14): [True: 3.16k, False: 1.58k]
  |  Branch (1182:31): [True: 1.58k, False: 0]
  |  Branch (1182:57): [True: 1.58k, False: 0]
  ------------------
 1183|  4.74k|                 (state->mode < CHECK || flush != Z_FINISH)))) {
  ------------------
  |  |  175|      0|#define Z_FINISH        4
  ------------------
  |  Branch (1183:19): [True: 1.58k, False: 0]
  |  Branch (1183:42): [True: 0, False: 0]
  ------------------
 1184|       |        /* update sliding window with respective checksum if not in "raw" mode */
 1185|  4.74k|        updatewindow(strm, strm->next_out, check_bytes, state->wrap & 4);
 1186|  4.74k|    }
 1187|  4.74k|    in -= strm->avail_in;
 1188|  4.74k|    out -= strm->avail_out;
 1189|  4.74k|    strm->total_in += in;
 1190|  4.74k|    strm->total_out += out;
 1191|  4.74k|    state->total += out;
 1192|       |
 1193|  4.74k|    strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
  ------------------
  |  Branch (1193:43): [True: 3.16k, False: 1.58k]
  ------------------
 1194|  4.74k|                      (state->mode == TYPE ? 128 : 0) + (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
  ------------------
  |  Branch (1194:24): [True: 0, False: 4.74k]
  |  Branch (1194:58): [True: 0, False: 4.74k]
  |  Branch (1194:81): [True: 0, False: 4.74k]
  ------------------
 1195|  4.74k|    if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) {
  ------------------
  |  |  175|  4.74k|#define Z_FINISH        4
  ------------------
                  if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) {
  ------------------
  |  |  180|      0|#define Z_OK            0
  ------------------
  |  Branch (1195:11): [True: 0, False: 4.74k]
  |  Branch (1195:22): [True: 0, False: 0]
  |  Branch (1195:35): [True: 0, False: 4.74k]
  |  Branch (1195:57): [True: 0, False: 0]
  ------------------
 1196|       |        /* when no sliding window is used, hash the output bytes if no CHECK state */
 1197|      0|        if (INFLATE_NEED_CHECKSUM(strm) && !state->wsize && flush == Z_FINISH) {
  ------------------
  |  |   34|      0|#  define INFLATE_NEED_CHECKSUM(strm) 1
  |  |  ------------------
  |  |  |  Branch (34:39): [True: 0, Folded]
  |  |  ------------------
  ------------------
                      if (INFLATE_NEED_CHECKSUM(strm) && !state->wsize && flush == Z_FINISH) {
  ------------------
  |  |  175|      0|#define Z_FINISH        4
  ------------------
  |  Branch (1197:44): [True: 0, False: 0]
  |  Branch (1197:61): [True: 0, False: 0]
  ------------------
 1198|      0|            inf_chksum(strm, put - check_bytes, check_bytes);
 1199|      0|        }
 1200|      0|        ret = Z_BUF_ERROR;
  ------------------
  |  |  187|      0|#define Z_BUF_ERROR    (-5)
  ------------------
 1201|      0|    }
 1202|  4.74k|    return ret;
 1203|  4.74k|}
zng_inflateEnd:
 1205|  1.58k|int32_t Z_EXPORT PREFIX(inflateEnd)(PREFIX3(stream) *strm) {
 1206|  1.58k|    if (inflateStateCheck(strm))
  ------------------
  |  Branch (1206:9): [True: 0, False: 1.58k]
  ------------------
 1207|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
 1208|       |
 1209|       |    /* Free allocated buffers */
 1210|  1.58k|    free_inflate(strm);
 1211|       |
 1212|  1.58k|    Tracev((stderr, "inflate: end\n"));
 1213|  1.58k|    return Z_OK;
  ------------------
  |  |  180|  1.58k|#define Z_OK            0
  ------------------
 1214|  1.58k|}
inflate.c:inflateStateCheck:
   53|  11.0k|static int inflateStateCheck(PREFIX3(stream) *strm) {
   54|  11.0k|    struct inflate_state *state;
   55|  11.0k|    if (strm == NULL || strm->zalloc == NULL || strm->zfree == NULL)
  ------------------
  |  Branch (55:9): [True: 0, False: 11.0k]
  |  Branch (55:25): [True: 0, False: 11.0k]
  |  Branch (55:49): [True: 0, False: 11.0k]
  ------------------
   56|      0|        return 1;
   57|  11.0k|    state = (struct inflate_state *)strm->state;
   58|  11.0k|    if (state == NULL || state->alloc_bufs == NULL || state->strm != strm || state->mode < HEAD || state->mode > SYNC)
  ------------------
  |  Branch (58:9): [True: 0, False: 11.0k]
  |  Branch (58:26): [True: 0, False: 11.0k]
  |  Branch (58:55): [True: 0, False: 11.0k]
  |  Branch (58:78): [True: 0, False: 11.0k]
  |  Branch (58:100): [True: 0, False: 11.0k]
  ------------------
   59|      0|        return 1;
   60|  11.0k|    return 0;
   61|  11.0k|}
inflate.c:inf_chksum:
   41|  3.05k|static inline void inf_chksum(PREFIX3(stream) *strm, const uint8_t *src, uint32_t len) {
   42|  3.05k|    struct inflate_state *state = (struct inflate_state*)strm->state;
   43|  3.05k|#ifdef GUNZIP
   44|  3.05k|    if (state->flags) {
  ------------------
  |  Branch (44:9): [True: 0, False: 3.05k]
  ------------------
   45|      0|        strm->adler = state->check = FUNCTABLE_CALL(crc32)(state->check, src, len);
  ------------------
  |  |   46|      0|#  define FUNCTABLE_CALL(name) functable.name
  ------------------
   46|      0|    } else
   47|  3.05k|#endif
   48|  3.05k|    {
   49|  3.05k|        strm->adler = state->check = FUNCTABLE_CALL(adler32)(state->check, src, len);
  ------------------
  |  |   46|  3.05k|#  define FUNCTABLE_CALL(name) functable.name
  ------------------
   50|  3.05k|    }
   51|  3.05k|}
inflate.c:updatewindow:
  327|  4.74k|static void updatewindow(PREFIX3(stream) *strm, const uint8_t *end, uint32_t len, int32_t cksum) {
  328|  4.74k|    struct inflate_state *state;
  329|  4.74k|    uint32_t dist;
  330|       |
  331|  4.74k|    state = (struct inflate_state *)strm->state;
  332|       |
  333|       |    /* if window not in use yet, initialize */
  334|  4.74k|    if (state->wsize == 0)
  ------------------
  |  Branch (334:9): [True: 1.58k, False: 3.16k]
  ------------------
  335|  1.58k|        state->wsize = 1U << state->wbits;
  336|       |
  337|       |    /* len state->wsize or less output bytes into the circular window */
  338|  4.74k|    if (len >= state->wsize) {
  ------------------
  |  Branch (338:9): [True: 1.47k, False: 3.26k]
  ------------------
  339|       |        /* Only do this if the caller specifies to checksum bytes AND the platform requires
  340|       |         * it (s/390 being the primary exception to this) */
  341|  1.47k|        if (INFLATE_NEED_CHECKSUM(strm) && cksum) {
  ------------------
  |  |   34|  2.94k|#  define INFLATE_NEED_CHECKSUM(strm) 1
  |  |  ------------------
  |  |  |  Branch (34:39): [True: 1.47k, Folded]
  |  |  ------------------
  ------------------
  |  Branch (341:44): [True: 1.47k, False: 0]
  ------------------
  342|       |            /* We have to split the checksum over non-copied and copied bytes */
  343|  1.47k|            if (len > state->wsize)
  ------------------
  |  Branch (343:17): [True: 1.47k, False: 0]
  ------------------
  344|  1.47k|                inf_chksum(strm, end - len, len - state->wsize);
  345|  1.47k|            inf_chksum_cpy(strm, state->window, end - state->wsize, state->wsize);
  346|  1.47k|        } else {
  347|      0|            memcpy(state->window, end - state->wsize, state->wsize);
  348|      0|        }
  349|       |
  350|  1.47k|        state->wnext = 0;
  351|  1.47k|        state->whave = state->wsize;
  352|  3.26k|    } else {
  353|  3.26k|        dist = state->wsize - state->wnext;
  354|       |        /* Only do this if the caller specifies to checksum bytes AND the platform requires
  355|       |         * We need to maintain the correct order here for the checksum */
  356|  3.26k|        dist = MIN(dist, len);
  ------------------
  |  |  148|  3.26k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 3.08k, False: 180]
  |  |  ------------------
  ------------------
  357|  3.26k|        if (INFLATE_NEED_CHECKSUM(strm) && cksum) {
  ------------------
  |  |   34|  6.53k|#  define INFLATE_NEED_CHECKSUM(strm) 1
  |  |  ------------------
  |  |  |  Branch (34:39): [True: 3.26k, Folded]
  |  |  ------------------
  ------------------
  |  Branch (357:44): [True: 3.26k, False: 0]
  ------------------
  358|  3.26k|            inf_chksum_cpy(strm, state->window + state->wnext, end - len, dist);
  359|  3.26k|        } else {
  360|      0|            memcpy(state->window + state->wnext, end - len, dist);
  361|      0|        }
  362|  3.26k|        len -= dist;
  363|  3.26k|        if (len) {
  ------------------
  |  Branch (363:13): [True: 178, False: 3.08k]
  ------------------
  364|    178|            if (INFLATE_NEED_CHECKSUM(strm) && cksum) {
  ------------------
  |  |   34|    356|#  define INFLATE_NEED_CHECKSUM(strm) 1
  |  |  ------------------
  |  |  |  Branch (34:39): [True: 178, Folded]
  |  |  ------------------
  ------------------
  |  Branch (364:48): [True: 178, False: 0]
  ------------------
  365|    178|                inf_chksum_cpy(strm, state->window, end - len, len);
  366|    178|            } else {
  367|      0|                memcpy(state->window, end - len, len);
  368|      0|            }
  369|       |
  370|    178|            state->wnext = len;
  371|    178|            state->whave = state->wsize;
  372|  3.08k|        } else {
  373|  3.08k|            state->wnext += dist;
  374|  3.08k|            if (state->wnext == state->wsize)
  ------------------
  |  Branch (374:17): [True: 2, False: 3.08k]
  ------------------
  375|      2|                state->wnext = 0;
  376|  3.08k|            if (state->whave < state->wsize)
  ------------------
  |  Branch (376:17): [True: 2.17k, False: 917]
  ------------------
  377|  2.17k|                state->whave += dist;
  378|  3.08k|        }
  379|  3.26k|    }
  380|  4.74k|}
inflate.c:inf_chksum_cpy:
   28|  4.91k|                           const uint8_t *src, uint32_t copy) {
   29|  4.91k|    if (!copy) return;
  ------------------
  |  Branch (29:9): [True: 1.58k, False: 3.33k]
  ------------------
   30|  3.33k|    struct inflate_state *state = (struct inflate_state*)strm->state;
   31|  3.33k|#ifdef GUNZIP
   32|  3.33k|    if (state->flags) {
  ------------------
  |  Branch (32:9): [True: 0, False: 3.33k]
  ------------------
   33|      0|        strm->adler = state->check = FUNCTABLE_CALL(crc32_copy)(state->check, dst, src, copy);
  ------------------
  |  |   46|      0|#  define FUNCTABLE_CALL(name) functable.name
  ------------------
   34|      0|    } else
   35|  3.33k|#endif
   36|  3.33k|    {
   37|  3.33k|        strm->adler = state->check = FUNCTABLE_CALL(adler32_copy)(state->check, dst, src, copy);
  ------------------
  |  |   46|  3.33k|#  define FUNCTABLE_CALL(name) functable.name
  ------------------
   38|  3.33k|    }
   39|  3.33k|}

inflate.c:chunkcopy_safe:
  212|  1.58k|static inline uint8_t* chunkcopy_safe(uint8_t *out, uint8_t *from, size_t len, uint8_t *safe) {
  213|  1.58k|    size_t safelen = safe - out;
  214|  1.58k|    len = MIN(len, safelen);
  ------------------
  |  |  148|  1.58k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 1.58k]
  |  |  ------------------
  ------------------
  215|  1.58k|    int32_t olap_src = from >= out && from < out + len;
  ------------------
  |  Branch (215:24): [True: 1.50k, False: 74]
  |  Branch (215:39): [True: 0, False: 1.50k]
  ------------------
  216|  1.58k|    int32_t olap_dst = out >= from && out < from + len;
  ------------------
  |  Branch (216:24): [True: 74, False: 1.50k]
  |  Branch (216:39): [True: 0, False: 74]
  ------------------
  217|  1.58k|    size_t tocopy;
  218|       |
  219|       |    /* For all cases without overlap, memcpy is ideal */
  220|  1.58k|    if (!(olap_src || olap_dst)) {
  ------------------
  |  Branch (220:11): [True: 0, False: 1.58k]
  |  Branch (220:23): [True: 0, False: 1.58k]
  ------------------
  221|  1.58k|        memcpy(out, from, len);
  222|  1.58k|        return out + len;
  223|  1.58k|    }
  224|       |
  225|       |    /* Complete overlap: Source == destination */
  226|      0|    if (out == from) {
  ------------------
  |  Branch (226:9): [True: 0, False: 0]
  ------------------
  227|      0|        return out + len;
  228|      0|    }
  229|       |
  230|       |    /* We are emulating a self-modifying copy loop here. To do this in a way that doesn't produce undefined behavior,
  231|       |     * we have to get a bit clever. First if the overlap is such that src falls between dst and dst+len, we can do the
  232|       |     * initial bulk memcpy of the nonoverlapping region. Then, we can leverage the size of this to determine the safest
  233|       |     * atomic memcpy size we can pick such that we have non-overlapping regions. This effectively becomes a safe look
  234|       |     * behind or lookahead distance. */
  235|      0|    size_t non_olap_size = (size_t)ABS(from - out);
  ------------------
  |  |  152|      0|#define ABS(a) ((a) < 0 ? -(a) : (a))
  |  |  ------------------
  |  |  |  Branch (152:17): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  236|       |
  237|       |    /* So this doesn't give use a worst case scenario of function calls in a loop,
  238|       |     * we want to instead break this down into copy blocks of fixed lengths
  239|       |     *
  240|       |     * TODO: The memcpy calls aren't inlined on architectures with strict memory alignment
  241|       |     */
  242|      0|    while (len) {
  ------------------
  |  Branch (242:12): [True: 0, False: 0]
  ------------------
  243|      0|        tocopy = MIN(non_olap_size, len);
  ------------------
  |  |  148|      0|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  244|      0|        len -= tocopy;
  245|       |
  246|      0|        while (tocopy >= 16) {
  ------------------
  |  Branch (246:16): [True: 0, False: 0]
  ------------------
  247|      0|            memcpy(out, from, 16);
  248|      0|            out += 16;
  249|      0|            from += 16;
  250|      0|            tocopy -= 16;
  251|      0|        }
  252|       |
  253|      0|        if (tocopy >= 8) {
  ------------------
  |  Branch (253:13): [True: 0, False: 0]
  ------------------
  254|      0|            memcpy(out, from, 8);
  255|      0|            out += 8;
  256|      0|            from += 8;
  257|      0|            tocopy -= 8;
  258|      0|        }
  259|       |
  260|      0|        if (tocopy >= 4) {
  ------------------
  |  Branch (260:13): [True: 0, False: 0]
  ------------------
  261|      0|            memcpy(out, from, 4);
  262|      0|            out += 4;
  263|      0|            from += 4;
  264|      0|            tocopy -= 4;
  265|      0|        }
  266|       |
  267|      0|        while (tocopy--) {
  ------------------
  |  Branch (267:16): [True: 0, False: 0]
  ------------------
  268|      0|            *out++ = *from++;
  269|      0|        }
  270|      0|    }
  271|       |
  272|      0|    return out;
  273|      0|}
chunkset_avx2.c:load_64_bits:
  206|  1.84M|static inline uint64_t load_64_bits(const unsigned char *in, unsigned bits) {
  207|  1.84M|    uint64_t chunk = zng_memread_8(in);
  208|  1.84M|    return Z_U64_FROM_LE(chunk) << bits;
  ------------------
  |  |   88|  1.84M|#  define Z_U64_FROM_LE(x)  (x)
  ------------------
  209|  1.84M|}
chunkset_avx2.c:chunkcopy_safe:
  212|  1.47k|static inline uint8_t* chunkcopy_safe(uint8_t *out, uint8_t *from, size_t len, uint8_t *safe) {
  213|  1.47k|    size_t safelen = safe - out;
  214|  1.47k|    len = MIN(len, safelen);
  ------------------
  |  |  148|  1.47k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 1.47k]
  |  |  ------------------
  ------------------
  215|  1.47k|    int32_t olap_src = from >= out && from < out + len;
  ------------------
  |  Branch (215:24): [True: 0, False: 1.47k]
  |  Branch (215:39): [True: 0, False: 0]
  ------------------
  216|  1.47k|    int32_t olap_dst = out >= from && out < from + len;
  ------------------
  |  Branch (216:24): [True: 1.47k, False: 0]
  |  Branch (216:39): [True: 1.47k, False: 0]
  ------------------
  217|  1.47k|    size_t tocopy;
  218|       |
  219|       |    /* For all cases without overlap, memcpy is ideal */
  220|  1.47k|    if (!(olap_src || olap_dst)) {
  ------------------
  |  Branch (220:11): [True: 0, False: 1.47k]
  |  Branch (220:23): [True: 1.47k, False: 0]
  ------------------
  221|      0|        memcpy(out, from, len);
  222|      0|        return out + len;
  223|      0|    }
  224|       |
  225|       |    /* Complete overlap: Source == destination */
  226|  1.47k|    if (out == from) {
  ------------------
  |  Branch (226:9): [True: 0, False: 1.47k]
  ------------------
  227|      0|        return out + len;
  228|      0|    }
  229|       |
  230|       |    /* We are emulating a self-modifying copy loop here. To do this in a way that doesn't produce undefined behavior,
  231|       |     * we have to get a bit clever. First if the overlap is such that src falls between dst and dst+len, we can do the
  232|       |     * initial bulk memcpy of the nonoverlapping region. Then, we can leverage the size of this to determine the safest
  233|       |     * atomic memcpy size we can pick such that we have non-overlapping regions. This effectively becomes a safe look
  234|       |     * behind or lookahead distance. */
  235|  1.47k|    size_t non_olap_size = (size_t)ABS(from - out);
  ------------------
  |  |  152|  1.47k|#define ABS(a) ((a) < 0 ? -(a) : (a))
  |  |  ------------------
  |  |  |  Branch (152:17): [True: 1.47k, False: 0]
  |  |  ------------------
  ------------------
  236|       |
  237|       |    /* So this doesn't give use a worst case scenario of function calls in a loop,
  238|       |     * we want to instead break this down into copy blocks of fixed lengths
  239|       |     *
  240|       |     * TODO: The memcpy calls aren't inlined on architectures with strict memory alignment
  241|       |     */
  242|   179k|    while (len) {
  ------------------
  |  Branch (242:12): [True: 177k, False: 1.47k]
  ------------------
  243|   177k|        tocopy = MIN(non_olap_size, len);
  ------------------
  |  |  148|   177k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 177k]
  |  |  ------------------
  ------------------
  244|   177k|        len -= tocopy;
  245|       |
  246|   177k|        while (tocopy >= 16) {
  ------------------
  |  Branch (246:16): [True: 0, False: 177k]
  ------------------
  247|      0|            memcpy(out, from, 16);
  248|      0|            out += 16;
  249|      0|            from += 16;
  250|      0|            tocopy -= 16;
  251|      0|        }
  252|       |
  253|   177k|        if (tocopy >= 8) {
  ------------------
  |  Branch (253:13): [True: 0, False: 177k]
  ------------------
  254|      0|            memcpy(out, from, 8);
  255|      0|            out += 8;
  256|      0|            from += 8;
  257|      0|            tocopy -= 8;
  258|      0|        }
  259|       |
  260|   177k|        if (tocopy >= 4) {
  ------------------
  |  Branch (260:13): [True: 0, False: 177k]
  ------------------
  261|      0|            memcpy(out, from, 4);
  262|      0|            out += 4;
  263|      0|            from += 4;
  264|      0|            tocopy -= 4;
  265|      0|        }
  266|       |
  267|   355k|        while (tocopy--) {
  ------------------
  |  Branch (267:16): [True: 177k, False: 177k]
  ------------------
  268|   177k|            *out++ = *from++;
  269|   177k|        }
  270|   177k|    }
  271|       |
  272|  1.47k|    return out;
  273|  1.47k|}

zng_inflate_table:
  146|  7.62k|                                 code * *table, unsigned *bits, uint16_t *work) {
  147|  7.62k|    unsigned len;                 /* a code's length in bits */
  148|  7.62k|    unsigned sym;                 /* index of code symbols */
  149|  7.62k|    unsigned min, max;            /* minimum and maximum code lengths */
  150|  7.62k|    unsigned root;                /* number of index bits for root table */
  151|  7.62k|    unsigned curr;                /* number of index bits for current table */
  152|  7.62k|    unsigned drop;                /* code bits to drop for sub-table */
  153|  7.62k|    int left;                     /* number of prefix codes available */
  154|  7.62k|    unsigned used;                /* code entries in table used */
  155|  7.62k|    uint16_t rhuff;               /* Reversed huffman code */
  156|  7.62k|    unsigned huff;                /* Huffman code */
  157|  7.62k|    unsigned incr;                /* for incrementing code, index */
  158|  7.62k|    unsigned fill;                /* index for replicating entries */
  159|  7.62k|    unsigned low;                 /* low bits for current root entry */
  160|  7.62k|    unsigned mask;                /* mask for low root bits */
  161|  7.62k|    code here;                    /* table entry for duplication */
  162|  7.62k|    code *next;                   /* next available space in table */
  163|  7.62k|    const uint16_t *base = NULL;  /* base value table to use */
  164|  7.62k|    const uint16_t *extra = NULL; /* extra bits table to use */
  165|  7.62k|    unsigned match = 0;           /* use base and extra for symbol >= match */
  166|  7.62k|    uint16_t ALIGNED_(16) count[MAX_BITS+1]; /* number of codes of each length */
  167|  7.62k|    uint16_t offs[MAX_BITS+1];    /* offsets in table for each length */
  168|  7.62k|    static const uint16_t lbase[31] = { /* Length codes 257..285 base */
  169|  7.62k|        3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
  170|  7.62k|        35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
  171|  7.62k|    static const uint16_t lext[31] = { /* Length codes 257..285 extra */
  172|  7.62k|        16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
  173|  7.62k|        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 203, 77};
  174|  7.62k|    static const uint16_t dbase[32] = { /* Distance codes 0..29 base */
  175|  7.62k|        1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
  176|  7.62k|        257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
  177|  7.62k|        8193, 12289, 16385, 24577, 0, 0};
  178|  7.62k|    static const uint16_t dext[32] = { /* Distance codes 0..29 extra */
  179|  7.62k|        16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
  180|  7.62k|        23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
  181|  7.62k|        28, 28, 29, 29, 64, 64};
  182|       |
  183|       |    /*
  184|       |       Process a set of code lengths to create a canonical Huffman code.  The
  185|       |       code lengths are lens[0..codes-1].  Each length corresponds to the
  186|       |       symbols 0..codes-1.  The Huffman code is generated by first sorting the
  187|       |       symbols by length from short to long, and retaining the symbol order
  188|       |       for codes with equal lengths.  Then the code starts with all zero bits
  189|       |       for the first code of the shortest length, and the codes are integer
  190|       |       increments for the same length, and zeros are appended as the length
  191|       |       increases.  For the deflate format, these bits are stored backwards
  192|       |       from their more natural integer increment ordering, and so when the
  193|       |       decoding tables are built in the large loop below, the integer codes
  194|       |       are incremented backwards.
  195|       |
  196|       |       This routine assumes, but does not check, that all of the entries in
  197|       |       lens[] are in the range 0..MAXBITS.  The caller must assure this.
  198|       |       1..MAXBITS is interpreted as that code length.  zero means that that
  199|       |       symbol does not occur in this code.
  200|       |
  201|       |       The codes are sorted by computing a count of codes for each length,
  202|       |       creating from that a table of starting indices for each length in the
  203|       |       sorted table, and then entering the symbols in order in the sorted
  204|       |       table.  The sorted table is work[], with that space being provided by
  205|       |       the caller.
  206|       |
  207|       |       The length counts are used for other purposes as well, i.e. finding
  208|       |       the minimum and maximum length codes, determining if there are any
  209|       |       codes at all, checking for a valid set of lengths, and looking ahead
  210|       |       at length counts to determine sub-table sizes when building the
  211|       |       decoding tables.
  212|       |     */
  213|       |
  214|       |    /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
  215|  7.62k|    count_lengths(lens, codes, count);
  216|       |
  217|       |    /* bound code lengths, force root to be within code lengths */
  218|  7.62k|    root = *bits;
  219|   106k|    for (max = MAX_BITS; max >= 1; max--)
  ------------------
  |  |   41|  7.62k|#define MAX_BITS 15
  ------------------
  |  Branch (219:26): [True: 106k, False: 0]
  ------------------
  220|   106k|        if (count[max] != 0) break;
  ------------------
  |  Branch (220:13): [True: 7.62k, False: 98.7k]
  ------------------
  221|  7.62k|    root = MIN(root, max);
  ------------------
  |  |  148|  7.62k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 7.62k, False: 0]
  |  |  ------------------
  ------------------
  222|  7.62k|    if (UNLIKELY(max == 0)) {           /* no symbols to code at all */
  ------------------
  |  |  258|  7.62k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 7.62k]
  |  |  ------------------
  ------------------
  223|      0|        here.op = (unsigned char)64;    /* invalid code marker */
  224|      0|        here.bits = (unsigned char)1;
  225|      0|        here.val = (uint16_t)0;
  226|      0|        *(*table)++ = here;             /* make a table to force an error */
  227|      0|        *(*table)++ = here;
  228|      0|        *bits = 1;
  229|      0|        return 0;     /* no symbols, but wait for decoding to report error */
  230|      0|    }
  231|  8.70k|    for (min = 1; min < max; min++)
  ------------------
  |  Branch (231:19): [True: 5.89k, False: 2.80k]
  ------------------
  232|  5.89k|        if (count[min] != 0) break;
  ------------------
  |  Branch (232:13): [True: 4.81k, False: 1.08k]
  ------------------
  233|  7.62k|    root = MAX(root, min);
  ------------------
  |  |  150|  7.62k|#define MAX(a, b) ((a) < (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (150:20): [True: 0, False: 7.62k]
  |  |  ------------------
  ------------------
  234|       |
  235|       |    /* check for an over-subscribed or incomplete set of lengths */
  236|  7.62k|    left = 1;
  237|   121k|    for (len = 1; len <= MAX_BITS; len++) {
  ------------------
  |  |   41|   121k|#define MAX_BITS 15
  ------------------
  |  Branch (237:19): [True: 114k, False: 7.62k]
  ------------------
  238|   114k|        left <<= 1;
  239|   114k|        left -= count[len];
  240|   114k|        if (left < 0) return -1;        /* over-subscribed */
  ------------------
  |  Branch (240:13): [True: 0, False: 114k]
  ------------------
  241|   114k|    }
  242|  7.62k|    if (left > 0 && (type == CODES || max != 1))
  ------------------
  |  Branch (242:9): [True: 0, False: 7.62k]
  |  Branch (242:22): [True: 0, False: 0]
  |  Branch (242:39): [True: 0, False: 0]
  ------------------
  243|      0|        return -1;                      /* incomplete set */
  244|       |
  245|       |    /* generate offsets into symbol table for each length for sorting */
  246|  7.62k|    offs[1] = 0;
  247|   114k|    for (len = 1; len < MAX_BITS; len++)
  ------------------
  |  |   41|   114k|#define MAX_BITS 15
  ------------------
  |  Branch (247:19): [True: 106k, False: 7.62k]
  ------------------
  248|   106k|        offs[len + 1] = offs[len] + count[len];
  249|       |
  250|       |    /* sort symbols by length, by symbol order within each length */
  251|   806k|    for (sym = 0; sym < codes; sym++)
  ------------------
  |  Branch (251:19): [True: 798k, False: 7.62k]
  ------------------
  252|   798k|        if (lens[sym] != 0) work[offs[lens[sym]]++] = (uint16_t)sym;
  ------------------
  |  Branch (252:13): [True: 24.2k, False: 774k]
  ------------------
  253|       |
  254|       |    /*
  255|       |       Create and fill in decoding tables.  In this loop, the table being
  256|       |       filled is at next and has curr index bits.  The code being used is huff
  257|       |       with length len.  That code is converted to an index by dropping drop
  258|       |       bits off of the bottom.  For codes where len is less than drop + curr,
  259|       |       those top drop + curr - len bits are incremented through all values to
  260|       |       fill the table with replicated entries.
  261|       |
  262|       |       root is the number of index bits for the root table.  When len exceeds
  263|       |       root, sub-tables are created pointed to by the root entry with an index
  264|       |       of the low root bits of huff.  This is saved in low to check for when a
  265|       |       new sub-table should be started.  drop is zero when the root table is
  266|       |       being filled, and drop is root when sub-tables are being filled.
  267|       |
  268|       |       When a new sub-table is needed, it is necessary to look ahead in the
  269|       |       code lengths to determine what size sub-table is needed.  The length
  270|       |       counts are used for this, and so count[] is decremented as codes are
  271|       |       entered in the tables.
  272|       |
  273|       |       used keeps track of how many table entries have been allocated from the
  274|       |       provided *table space.  It is checked for LENS and DIST tables against
  275|       |       the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in
  276|       |       the initial root table size constants.  See the comments in inftrees.h
  277|       |       for more information.
  278|       |
  279|       |       sym increments through all symbols, and the loop terminates when
  280|       |       all codes of length max, i.e. all codes, have been processed.  This
  281|       |       routine permits incomplete codes, so another loop after this one fills
  282|       |       in the rest of the decoding tables with invalid code markers.
  283|       |     */
  284|       |
  285|       |    /* The packed table fill below reads and writes each entry as a single uint32_t. */
  286|  7.62k|    Assert(sizeof(code) == 4, "code entry must be exactly 4 bytes");
  287|       |
  288|       |    /* set up for code type */
  289|  7.62k|    switch (type) {
  ------------------
  |  Branch (289:13): [True: 7.62k, False: 0]
  ------------------
  290|  2.54k|    case CODES:
  ------------------
  |  Branch (290:5): [True: 2.54k, False: 5.08k]
  ------------------
  291|  2.54k|        base = extra = work;    /* dummy value--not used */
  292|  2.54k|        match = 20;
  293|  2.54k|        break;
  294|  2.54k|    case LENS:
  ------------------
  |  Branch (294:5): [True: 2.54k, False: 5.08k]
  ------------------
  295|  2.54k|        base = lbase;
  296|  2.54k|        extra = lext;
  297|  2.54k|        match = 257;
  298|  2.54k|        break;
  299|  2.54k|    case DISTS:
  ------------------
  |  Branch (299:5): [True: 2.54k, False: 5.08k]
  ------------------
  300|  2.54k|        base = dbase;
  301|  2.54k|        extra = dext;
  302|  7.62k|    }
  303|       |
  304|       |    /* initialize state for loop */
  305|  7.62k|    rhuff = 0;                  /* starting code, reversed */
  306|  7.62k|    huff = 0;                   /* starting code */
  307|  7.62k|    sym = 0;                    /* starting code symbol */
  308|  7.62k|    len = min;                  /* starting code length */
  309|  7.62k|    next = *table;              /* current table to fill in */
  310|  7.62k|    curr = root;                /* current table index bits */
  311|  7.62k|    drop = 0;                   /* current bits to drop from code for index */
  312|  7.62k|    low = (unsigned)(-1);       /* trigger new sub-table when len > root */
  313|  7.62k|    used = 1U << root;          /* use root table entries */
  314|  7.62k|    mask = used - 1;            /* mask for comparing low */
  315|       |
  316|       |    /* check available table space */
  317|  7.62k|    if ((type == LENS && used > ENOUGH_LENS) ||
  ------------------
  |  |   52|  2.54k|#define ENOUGH_LENS 1332
  ------------------
  |  Branch (317:10): [True: 2.54k, False: 5.08k]
  |  Branch (317:26): [True: 0, False: 2.54k]
  ------------------
  318|  7.62k|        (type == DISTS && used > ENOUGH_DISTS))
  ------------------
  |  |   53|  2.54k|#define ENOUGH_DISTS 592
  ------------------
  |  Branch (318:10): [True: 2.54k, False: 5.08k]
  |  Branch (318:27): [True: 0, False: 2.54k]
  ------------------
  319|      0|        return 1;
  320|       |
  321|       |    /* process all codes and make table entries */
  322|  24.2k|    for (;;) {
  323|       |        /* create table entry */
  324|  24.2k|        here.bits = (unsigned char)(len - drop);
  325|  24.2k|        if (LIKELY(work[sym] >= match)) {
  ------------------
  |  |  257|  24.2k|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 9.86k, False: 14.4k]
  |  |  ------------------
  ------------------
  326|  9.86k|            unsigned op = extra[work[sym] - match];
  327|  9.86k|            here.op = COMBINE_OP(op, here.bits);
  ------------------
  |  |  174|  9.86k|    ((unsigned char)((extra) & 16 ? (code_bits) | 16 : (extra)))
  |  |  ------------------
  |  |  |  Branch (174:22): [True: 9.86k, False: 0]
  |  |  ------------------
  ------------------
  328|  9.86k|            here.bits = COMBINE_BITS(here.bits, op);
  ------------------
  |  |  178|  9.86k|    ((unsigned char)((code_bits) + ((extra) & 15)))
  ------------------
  329|  9.86k|            here.val = base[work[sym] - match];
  330|  14.4k|        } else if (work[sym] + 1U < match) {
  ------------------
  |  Branch (330:20): [True: 11.8k, False: 2.54k]
  ------------------
  331|  11.8k|            here.op = (unsigned char)0;
  332|  11.8k|            here.val = work[sym];
  333|  11.8k|        } else {
  334|  2.54k|            here.op = (unsigned char)(32 + 64);         /* end of block */
  335|  2.54k|            here.val = 0;
  336|  2.54k|        }
  337|       |
  338|       |        /* replicate for those indices with low len bits equal to huff */
  339|  24.2k|        incr = 1U << (len - drop);
  340|  24.2k|        fill = 1U << curr;
  341|  24.2k|        min = fill;                 /* save offset to next table */
  342|  24.2k|        {
  343|       |            /* `here` is a 4-byte struct that the compiler writes one field at a time.
  344|       |               Read it as a packed uint32_t so each slot is filled by a single store. */
  345|  24.2k|            uint32_t here_u32 = zng_memread_4(&here);
  346|  24.2k|            code *base_ptr = next + (huff >> drop);
  347|  24.2k|            unsigned step4 = incr << 2;
  348|       |            /* Unroll by four so the slot addresses are independent. */
  349|  26.3k|            while (fill >= step4) {
  ------------------
  |  Branch (349:20): [True: 2.04k, False: 24.2k]
  ------------------
  350|  2.04k|                zng_memwrite_4(&base_ptr[fill - 1 * incr], here_u32);
  351|  2.04k|                zng_memwrite_4(&base_ptr[fill - 2 * incr], here_u32);
  352|  2.04k|                zng_memwrite_4(&base_ptr[fill - 3 * incr], here_u32);
  353|  2.04k|                zng_memwrite_4(&base_ptr[fill - 4 * incr], here_u32);
  354|  2.04k|                fill -= step4;
  355|  2.04k|            }
  356|  52.9k|            while (fill != 0) {
  ------------------
  |  Branch (356:20): [True: 28.6k, False: 24.2k]
  ------------------
  357|  28.6k|                fill -= incr;
  358|  28.6k|                zng_memwrite_4(&base_ptr[fill], here_u32);
  359|  28.6k|            }
  360|  24.2k|        }
  361|       |
  362|       |        /* backwards increment the len-bit code huff */
  363|  24.2k|        rhuff = (uint16_t)(rhuff + (0x8000u >> (len - 1)));
  364|  24.2k|        huff = zng_bitreverse16(rhuff);
  365|       |
  366|       |        /* go to next symbol, update count, len */
  367|  24.2k|        sym++;
  368|  24.2k|        if (--(count[len]) == 0) {
  ------------------
  |  Branch (368:13): [True: 14.4k, False: 9.78k]
  ------------------
  369|  14.4k|            if (len == max)
  ------------------
  |  Branch (369:17): [True: 7.62k, False: 6.85k]
  ------------------
  370|  7.62k|                break;
  371|  6.85k|            len = lens[work[sym]];
  372|  6.85k|        }
  373|       |
  374|       |        /* create new sub-table if needed */
  375|  16.6k|        if (len > root && (huff & mask) != low) {
  ------------------
  |  Branch (375:13): [True: 0, False: 16.6k]
  |  Branch (375:27): [True: 0, False: 0]
  ------------------
  376|       |            /* if first time, transition to sub-tables */
  377|      0|            if (drop == 0)
  ------------------
  |  Branch (377:17): [True: 0, False: 0]
  ------------------
  378|      0|                drop = root;
  379|       |
  380|       |            /* increment past last table */
  381|      0|            next += min;            /* here min is 1 << curr */
  382|       |
  383|       |            /* determine length of next table */
  384|      0|            curr = len - drop;
  385|      0|            left = (int)(1 << curr);
  386|      0|            while (curr + drop < max) {
  ------------------
  |  Branch (386:20): [True: 0, False: 0]
  ------------------
  387|      0|                left -= count[curr + drop];
  388|      0|                if (left <= 0)
  ------------------
  |  Branch (388:21): [True: 0, False: 0]
  ------------------
  389|      0|                    break;
  390|      0|                curr++;
  391|      0|                left <<= 1;
  392|      0|            }
  393|       |
  394|       |            /* check for enough space */
  395|      0|            used += 1U << curr;
  396|      0|            if ((type == LENS && used > ENOUGH_LENS) || (type == DISTS && used > ENOUGH_DISTS))
  ------------------
  |  |   52|      0|#define ENOUGH_LENS 1332
  ------------------
                          if ((type == LENS && used > ENOUGH_LENS) || (type == DISTS && used > ENOUGH_DISTS))
  ------------------
  |  |   53|      0|#define ENOUGH_DISTS 592
  ------------------
  |  Branch (396:18): [True: 0, False: 0]
  |  Branch (396:34): [True: 0, False: 0]
  |  Branch (396:58): [True: 0, False: 0]
  |  Branch (396:75): [True: 0, False: 0]
  ------------------
  397|      0|                return 1;
  398|       |
  399|       |            /* point entry in root table to sub-table */
  400|      0|            low = huff & mask;
  401|      0|            (*table)[low].op = (unsigned char)curr;
  402|      0|            (*table)[low].bits = (unsigned char)root;
  403|      0|            (*table)[low].val = (uint16_t)(next - *table);
  404|      0|        }
  405|  16.6k|    }
  406|       |
  407|       |    /* fill in remaining table entry if code is incomplete (guaranteed to have
  408|       |       at most one remaining entry, since if the code is incomplete, the
  409|       |       maximum code length that was allowed to get this far is one bit) */
  410|  7.62k|    if (UNLIKELY(huff != 0)) {
  ------------------
  |  |  258|  7.62k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 7.62k]
  |  |  ------------------
  ------------------
  411|      0|        here.op = (unsigned char)64;            /* invalid code marker */
  412|      0|        here.bits = (unsigned char)(len - drop);
  413|      0|        here.val = (uint16_t)0;
  414|      0|        next[huff] = here;
  415|      0|    }
  416|       |
  417|       |    /* set return parameters */
  418|  7.62k|    *table += used;
  419|  7.62k|    *bits = root;
  420|  7.62k|    return 0;
  421|  7.62k|}
inftrees.c:count_lengths:
   30|  7.62k|static inline void count_lengths(uint16_t *lens, int codes, uint16_t *count) {
   31|       |    /* IBM...made some weird choices for VSX/VMX. Basically vec_ld has an inherent
   32|       |     * endianness but we don't want to force VSX to be needed */
   33|  7.62k|    static const ALIGNED_(16) uint8_t one[256] = {
   34|  7.62k|        1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   35|  7.62k|        0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   36|  7.62k|        0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   37|  7.62k|        0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   38|  7.62k|        0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   39|  7.62k|        0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   40|  7.62k|        0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   41|  7.62k|        0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
   42|  7.62k|        0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
   43|  7.62k|        0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
   44|  7.62k|        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
   45|  7.62k|        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
   46|  7.62k|        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
   47|  7.62k|        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
   48|  7.62k|        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
   49|  7.62k|        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
   50|  7.62k|    };
   51|       |
   52|       |#if defined(__ALTIVEC__)
   53|       |    vector unsigned char s1 = vec_splat_u8(0);
   54|       |    vector unsigned char s2 = vec_splat_u8(0);
   55|       |
   56|       |    if (codes & 1) {
   57|       |        s1 = vec_ld(16 * lens[0], one);
   58|       |        --codes;
   59|       |        ++lens;
   60|       |    }
   61|       |
   62|       |    while (codes) {
   63|       |        s1 = vec_add(s1, vec_ld(16 * lens[0], one));
   64|       |        s2 = vec_add(s2, vec_ld(16 * lens[1], one));
   65|       |        codes -= 2;
   66|       |        lens += 2;
   67|       |    }
   68|       |
   69|       |    vector unsigned short sum_lo = vec_add(vec_unpackh(s1), vec_unpackh(s2));
   70|       |    vector unsigned short sum_hi = vec_add(vec_unpackl(s1), vec_unpackl(s2));
   71|       |
   72|       |    vec_st(sum_lo, 0, &count[0]);
   73|       |    vec_st(sum_hi, 0, &count[8]);
   74|       |
   75|       |#elif defined(__ARM_NEON) || defined(__ARM_NEON__)
   76|       |    int sym;
   77|       |    uint8x16_t s1 = vdupq_n_u8(0);
   78|       |    uint8x16_t s2 = vdupq_n_u8(0);
   79|       |
   80|       |    if (codes & 1) {
   81|       |        s1 = vld1q_u8(&one[16 * lens[0]]);
   82|       |    }
   83|       |    for (sym = codes & 1; sym < codes; sym += 2) {
   84|       |        s1 = vaddq_u8(s1, vld1q_u8(&one[16 * lens[sym]]));
   85|       |        s2 = vaddq_u8(s2, vld1q_u8(&one[16 * lens[sym+1]]));
   86|       |    }
   87|       |
   88|       |    vst1q_u16(&count[0], vaddl_u8(vget_low_u8(s1), vget_low_u8(s2)));
   89|       |    vst1q_u16(&count[8], vaddl_u8(vget_high_u8(s1), vget_high_u8(s2)));
   90|       |
   91|       |#elif defined(__SSE2__)
   92|       |    int sym;
   93|  7.62k|    __m128i s1 = _mm_setzero_si128();
   94|  7.62k|    __m128i s2 = _mm_setzero_si128();
   95|       |
   96|  7.62k|    if (codes & 1) {
  ------------------
  |  Branch (96:9): [True: 3.65k, False: 3.96k]
  ------------------
   97|  3.65k|        s1 = _mm_load_si128((const __m128i*)&one[16 * lens[0]]);
   98|  3.65k|    }
   99|   405k|    for (sym = codes & 1; sym < codes; sym += 2) {
  ------------------
  |  Branch (99:27): [True: 397k, False: 7.62k]
  ------------------
  100|   397k|        s1 = _mm_add_epi8(s1, _mm_load_si128((const __m128i*)&one[16 * lens[sym]]));  // vaddq_u8
  101|   397k|        s2 = _mm_add_epi8(s2, _mm_load_si128((const __m128i*)&one[16 * lens[sym+1]]));
  102|   397k|    }
  103|       |
  104|       |#  if defined(__AVX2__)
  105|       |    __m256i w1 = _mm256_cvtepu8_epi16(s1);
  106|       |    __m256i w2 = _mm256_cvtepu8_epi16(s2);
  107|       |    __m256i sum = _mm256_add_epi16(w1, w2);
  108|       |
  109|       |    _mm256_storeu_si256((__m256i*)&count[0], sum);
  110|       |#  else
  111|  7.62k|    __m128i zero = _mm_setzero_si128();
  112|       |
  113|  7.62k|    __m128i s1_lo = _mm_unpacklo_epi8(s1, zero);
  114|  7.62k|    __m128i s2_lo = _mm_unpacklo_epi8(s2, zero);
  115|  7.62k|    __m128i sum_lo = _mm_add_epi16(s1_lo, s2_lo);
  116|  7.62k|    _mm_storeu_si128((__m128i*)&count[0], sum_lo);
  117|       |
  118|  7.62k|    __m128i s1_hi = _mm_unpackhi_epi8(s1, zero);
  119|  7.62k|    __m128i s2_hi = _mm_unpackhi_epi8(s2, zero);
  120|  7.62k|    __m128i sum_hi = _mm_add_epi16(s1_hi, s2_hi);
  121|  7.62k|    _mm_storeu_si128((__m128i*)&count[8], sum_hi);
  122|  7.62k|#  endif
  123|       |#else
  124|       |    int len, sym;
  125|       |    for (len = 0; len <= MAX_BITS; len++)
  126|       |        count[len] = 0;
  127|       |    for (sym = 0; sym < codes; sym++)
  128|       |        count[lens[sym]]++;
  129|       |    Z_UNUSED(one);
  130|       |#endif
  131|  7.62k|}

insert_roll_batch:
   16|  1.84M|Z_INTERNAL void insert_roll_batch(deflate_state *const s, unsigned char *window, uint32_t str, uint32_t count) {
   17|  1.84M|    insert_roll_batch_static(s, window, str, count);
   18|  1.84M|}

deflate.c:update_hash_roll:
   26|  16.0k|Z_FORCEINLINE static uint32_t update_hash_roll(uint32_t h, uint32_t val) {
   27|  16.0k|    UPDATE_HASH_ROLL(h, val);
  ------------------
  |  |   18|  16.0k|#define UPDATE_HASH_ROLL(h,val) h = (((h << 5) ^ ((uint8_t)(val))) & ROLL_MASK
  |  |  ------------------
  |  |  |  |   17|  16.0k|#define ROLL_MASK ((HASH_SIZE / 2) - 1u))
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  16.0k|#  define HASH_SIZE 65536u         /* number of elements in hash table */
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   28|  16.0k|    return h;
   29|  16.0k|}
deflate_slow.c:insert_roll:
  101|  3.68M|Z_FORCEINLINE static uint32_t insert_roll(deflate_state *const s, unsigned char *window, uint32_t str) {
  102|  3.68M|    uint8_t *strstart = window + str + (STD_MIN_MATCH-1);
  ------------------
  |  |   61|  3.68M|#define STD_MIN_MATCH  3
  ------------------
  103|  3.68M|    uint32_t h, head;
  104|       |
  105|  3.68M|    h = s->ins_h;
  106|  3.68M|    UPDATE_HASH_ROLL(h, strstart[0]);
  ------------------
  |  |   18|  3.68M|#define UPDATE_HASH_ROLL(h,val) h = (((h << 5) ^ ((uint8_t)(val))) & ROLL_MASK
  |  |  ------------------
  |  |  |  |   17|  3.68M|#define ROLL_MASK ((HASH_SIZE / 2) - 1u))
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  3.68M|#  define HASH_SIZE 65536u         /* number of elements in hash table */
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  107|  3.68M|    s->ins_h = h;
  108|       |
  109|  3.68M|    head = s->head[h];
  110|  3.68M|    if (LIKELY(head != str)) {
  ------------------
  |  |  257|  3.68M|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 3.68M, False: 1.58k]
  |  |  ------------------
  ------------------
  111|  3.68M|        s->prev[str & W_MASK(s)] = (Pos)head;
  ------------------
  |  |  414|  3.68M|#define W_MASK(s)  ((s)->w_size - 1)
  ------------------
  112|  3.68M|        s->head[h] = (Pos)str;
  113|  3.68M|    }
  114|  3.68M|    return head;
  115|  3.68M|}
insert_string.c:insert_roll_batch_static:
  167|  1.84M|Z_FORCEINLINE static void insert_roll_batch_static(deflate_state *const s, unsigned char *window, uint32_t str, uint32_t count) {
  168|  1.84M|    uint8_t *strstart = window + str + (STD_MIN_MATCH-1);
  ------------------
  |  |   61|  1.84M|#define STD_MIN_MATCH  3
  ------------------
  169|  1.84M|    uint8_t *strend = strstart + count;
  170|       |
  171|       |    /* Local pointers to avoid indirection */
  172|  1.84M|    Pos *headp = s->head;
  173|  1.84M|    Pos *prevp = s->prev;
  174|  1.84M|    uint32_t h = s->ins_h;
  175|  1.84M|    const unsigned int w_mask = W_MASK(s);
  ------------------
  |  |  414|  1.84M|#define W_MASK(s)  ((s)->w_size - 1)
  ------------------
  176|       |
  177|   503M|    for (uint32_t idx = str; strstart < strend; idx++, strstart++) {
  ------------------
  |  Branch (177:30): [True: 501M, False: 1.84M]
  ------------------
  178|   501M|        uint32_t head;
  179|       |
  180|   501M|        UPDATE_HASH_ROLL(h, strstart[0]);
  ------------------
  |  |   18|   501M|#define UPDATE_HASH_ROLL(h,val) h = (((h << 5) ^ ((uint8_t)(val))) & ROLL_MASK
  |  |  ------------------
  |  |  |  |   17|   501M|#define ROLL_MASK ((HASH_SIZE / 2) - 1u))
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   501M|#  define HASH_SIZE 65536u         /* number of elements in hash table */
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  181|       |
  182|   501M|        head = headp[h];
  183|   501M|        if (LIKELY(head != idx)) {
  ------------------
  |  |  257|   501M|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 501M, False: 864]
  |  |  ------------------
  ------------------
  184|   501M|            prevp[idx & w_mask] = (Pos)head;
  185|   501M|            headp[h] = (Pos)idx;
  186|   501M|        }
  187|   501M|    }
  188|  1.84M|    s->ins_h = h;
  189|  1.84M|}
compare256_avx2.c:update_hash_roll:
   26|  1.05M|Z_FORCEINLINE static uint32_t update_hash_roll(uint32_t h, uint32_t val) {
   27|  1.05M|    UPDATE_HASH_ROLL(h, val);
  ------------------
  |  |   18|  1.05M|#define UPDATE_HASH_ROLL(h,val) h = (((h << 5) ^ ((uint8_t)(val))) & ROLL_MASK
  |  |  ------------------
  |  |  |  |   17|  1.05M|#define ROLL_MASK ((HASH_SIZE / 2) - 1u))
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  1.05M|#  define HASH_SIZE 65536u         /* number of elements in hash table */
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   28|  1.05M|    return h;
   29|  1.05M|}

longest_match_roll_avx2:
   28|  1.84M|Z_INTERNAL uint32_t LONGEST_MATCH(deflate_state *const s, uint32_t cur_match) {
   29|  1.84M|    const unsigned wmask = W_MASK(s);
  ------------------
  |  |  414|  1.84M|#define W_MASK(s)  ((s)->w_size - 1)
  ------------------
   30|  1.84M|    unsigned int strstart = s->strstart;
   31|  1.84M|    const unsigned char *window = s->window;
   32|  1.84M|    const Pos *prev = s->prev;
   33|  1.84M|#ifdef LONGEST_MATCH_ROLL
   34|  1.84M|    const Pos *head = s->head;
   35|  1.84M|#endif
   36|  1.84M|    const unsigned char *scan;
   37|  1.84M|    const unsigned char *mbase_start = window;
   38|  1.84M|    const unsigned char *mbase_end;
   39|  1.84M|    uint32_t limit;
   40|  1.84M|#ifdef LONGEST_MATCH_ROLL
   41|  1.84M|    uint32_t limit_base;
   42|       |#else
   43|       |    int32_t early_exit;
   44|       |#endif
   45|  1.84M|    uint32_t chain_length = s->max_chain_length;
   46|  1.84M|    uint32_t nice_match = (uint32_t)s->nice_match;
   47|  1.84M|    uint32_t best_len, offset;
   48|  1.84M|    uint32_t lookahead = s->lookahead;
   49|  1.84M|    uint32_t match_offset = 0;
   50|  1.84M|    uint64_t scan_start;
   51|  1.84M|    uint64_t scan_end;
   52|       |
   53|       |    /* The code is optimized for STD_MAX_MATCH-2 multiple of 16. */
   54|  1.84M|    Assert(STD_MAX_MATCH == 258, "Code too clever");
   55|       |
   56|  1.84M|    best_len = s->prev_length ? s->prev_length : STD_MIN_MATCH-1;
  ------------------
  |  |   61|  1.83M|#define STD_MIN_MATCH  3
  ------------------
  |  Branch (56:16): [True: 4.55k, False: 1.83M]
  ------------------
   57|  1.84M|    if (UNLIKELY(best_len >= lookahead))
  ------------------
  |  |  258|  1.84M|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 2.83k, False: 1.83M]
  |  |  ------------------
  ------------------
   58|  2.83k|        return lookahead;
   59|       |
   60|       |    /* Calculate read offset which should only extend an extra byte to find the
   61|       |     * next best match length. When best_len is shorter than the read width, we
   62|       |     * diff the mismatched bytes instead.
   63|       |     */
   64|  1.83M|    offset = best_len >= sizeof(uint64_t) ? best_len - 7 : 0;
  ------------------
  |  Branch (64:14): [True: 0, False: 1.83M]
  ------------------
   65|       |
   66|  1.83M|    scan = window + strstart;
   67|  1.83M|    scan_start = zng_memread_8(scan);
   68|  1.83M|    scan_end = zng_memread_8(scan+offset);
   69|  1.83M|    mbase_end = (mbase_start+offset);
   70|       |
   71|       |    /* Do not waste too much time if we already have a good match */
   72|  1.83M|    if (UNLIKELY(best_len >= s->good_match))
  ------------------
  |  |  258|  1.83M|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 1.83M]
  |  |  ------------------
  ------------------
   73|      0|        chain_length >>= 2;
   74|       |
   75|       |    /* Stop when cur_match becomes <= limit. To simplify the code,
   76|       |     * we prevent matches with the string of window index 0
   77|       |     */
   78|  1.83M|    limit = strstart > MAX_DIST(s) ? (strstart - MAX_DIST(s)) : 0;
  ------------------
  |  |  409|  1.83M|#define MAX_DIST(s)  ((s)->w_size - MIN_LOOKAHEAD)
  |  |  ------------------
  |  |  |  |  404|  1.83M|#define MIN_LOOKAHEAD (STD_MAX_MATCH + STD_MIN_MATCH + 1)
  |  |  |  |  ------------------
  |  |  |  |  |  |   62|  1.83M|#define STD_MAX_MATCH  258
  |  |  |  |  ------------------
  |  |  |  |               #define MIN_LOOKAHEAD (STD_MAX_MATCH + STD_MIN_MATCH + 1)
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|  1.83M|#define STD_MIN_MATCH  3
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  limit = strstart > MAX_DIST(s) ? (strstart - MAX_DIST(s)) : 0;
  ------------------
  |  |  409|  1.70M|#define MAX_DIST(s)  ((s)->w_size - MIN_LOOKAHEAD)
  |  |  ------------------
  |  |  |  |  404|  1.70M|#define MIN_LOOKAHEAD (STD_MAX_MATCH + STD_MIN_MATCH + 1)
  |  |  |  |  ------------------
  |  |  |  |  |  |   62|  1.70M|#define STD_MAX_MATCH  258
  |  |  |  |  ------------------
  |  |  |  |               #define MIN_LOOKAHEAD (STD_MAX_MATCH + STD_MIN_MATCH + 1)
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|  1.70M|#define STD_MIN_MATCH  3
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (78:13): [True: 1.70M, False: 139k]
  ------------------
   79|  1.83M|#ifdef LONGEST_MATCH_ROLL
   80|  1.83M|    limit_base = limit;
   81|  1.83M|    if (best_len >= STD_MIN_MATCH) {
  ------------------
  |  |   61|  1.83M|#define STD_MIN_MATCH  3
  ------------------
  |  Branch (81:9): [True: 0, False: 1.83M]
  ------------------
   82|       |        /* We're continuing search (lazy evaluation). */
   83|      0|        uint32_t hash;
   84|      0|        uint32_t pos;
   85|       |
   86|       |        /* Find a most distant chain starting from scan with index=1 (index=0 corresponds
   87|       |         * to cur_match). We cannot use s->prev[strstart+1,...] immediately, because
   88|       |         * these strings are not yet inserted into the hash table.
   89|       |         */
   90|       |        // use update_hash_roll for deflate_slow
   91|      0|        hash = update_hash_roll(0, scan[1]);
   92|      0|        hash = update_hash_roll(hash, scan[2]);
   93|       |
   94|      0|        for (uint32_t i = 3; i <= best_len; i++) {
  ------------------
  |  Branch (94:30): [True: 0, False: 0]
  ------------------
   95|       |            // use update_hash_roll for deflate_slow
   96|      0|            hash = update_hash_roll(hash, scan[i]);
   97|       |            /* If we're starting with best_len >= 3, we can use offset search. */
   98|      0|            pos = head[hash];
   99|      0|            if (UNLIKELY(pos < cur_match)) {
  ------------------
  |  |  258|      0|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  100|      0|                match_offset = i - 2;
  101|      0|                cur_match = pos;
  102|      0|            }
  103|      0|        }
  104|       |
  105|       |        /* Update offset-dependent variables */
  106|      0|        limit = limit_base+match_offset;
  107|      0|        if (UNLIKELY(cur_match <= limit))
  ------------------
  |  |  258|      0|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  108|      0|            return best_len;
  109|      0|        mbase_start -= match_offset;
  110|      0|        mbase_end -= match_offset;
  111|      0|    }
  112|       |#else
  113|       |    early_exit = s->level < EARLY_EXIT_TRIGGER_LEVEL;
  114|       |#endif
  115|  1.83M|    Assert((unsigned long)strstart <= s->window_size - MIN_LOOKAHEAD, "need lookahead");
  116|  2.22M|    for (;;) {
  117|  2.22M|        if (UNLIKELY(cur_match >= strstart))
  ------------------
  |  |  258|  2.22M|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 2.22M]
  |  |  ------------------
  ------------------
  118|      0|            break;
  119|       |
  120|       |        /* Skip to next match if the match length cannot increase or if the match length is
  121|       |         * less than 2. Note that the checks below for insufficient lookahead only occur
  122|       |         * occasionally for performance reasons.
  123|       |         * Therefore uninitialized memory will be accessed and conditional jumps will be made
  124|       |         * that depend on those values. However the length of the match is limited to the
  125|       |         * lookahead, so the output of deflate is not affected by the uninitialized values.
  126|       |         */
  127|  2.22M|        uint32_t len;
  128|  2.22M|        if (best_len < sizeof(uint64_t)) {
  ------------------
  |  Branch (128:13): [True: 1.84M, False: 376k]
  ------------------
  129|  1.84M|            uint64_t cand_start = zng_memread_8(mbase_start + cur_match);
  130|  1.84M|            if (scan_start != cand_start) {
  ------------------
  |  Branch (130:17): [True: 6.94k, False: 1.83M]
  ------------------
  131|       |                /* Peel the first candidate out of the loop. A full 8-byte match falls straight
  132|       |                 * through to compare256, and single-candidate chains (barely-compressible data)
  133|       |                 * run with no loop overhead. */
  134|  6.94k|                uint64_t first_mask = zng_first_bytes_mask64(best_len + 1);
  ------------------
  |  |  138|  6.94k|#  define zng_first_bytes_mask64(n) (UINT64_MAX >> ((8 - (n)) * 8))
  ------------------
  135|  6.94k|                uint64_t diff = scan_start ^ cand_start;
  136|       |                /* A candidate beats best_len only when its first best_len+1 bytes match, i.e.
  137|       |                 * those bytes of the XOR are zero. The masked test rejects without running ctz. */
  138|  6.94k|                if (UNLIKELY((diff & first_mask) == 0)) {
  ------------------
  |  |  258|  6.94k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 6.43k, False: 508]
  |  |  ------------------
  ------------------
  139|  6.43k|                    len = zng_first_diff_byte64(diff);
  ------------------
  |  |  130|  6.43k|#  define zng_first_diff_byte64(diff) (zng_ctz64(diff) / 8)
  ------------------
  140|  6.43k|                    goto short_match_accept;
  141|  6.43k|                }
  142|    508|                if (--chain_length == 0 || (cur_match = prev[cur_match & wmask]) <= limit)
  ------------------
  |  Branch (142:21): [True: 0, False: 508]
  |  Branch (142:44): [True: 0, False: 508]
  ------------------
  143|      0|                    return best_len;
  144|    508|                cand_start = zng_memread_8(mbase_start + cur_match);
  145|    508|                if (scan_start != cand_start) {
  ------------------
  |  Branch (145:21): [True: 508, False: 0]
  ------------------
  146|       |                    /* Walk the remaining candidates with the chain advance kept inline. */
  147|  1.04k|                    for (;;) {
  148|  1.04k|                        diff = scan_start ^ cand_start;
  149|  1.04k|                        if (UNLIKELY((diff & first_mask) == 0)) {
  ------------------
  |  |  258|  1.04k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 461, False: 585]
  |  |  ------------------
  ------------------
  150|    461|                            len = zng_first_diff_byte64(diff);
  ------------------
  |  |  130|    461|#  define zng_first_diff_byte64(diff) (zng_ctz64(diff) / 8)
  ------------------
  151|    461|                            goto short_match_accept;
  152|    461|                        }
  153|    585|                        if (--chain_length == 0 || (cur_match = prev[cur_match & wmask]) <= limit)
  ------------------
  |  Branch (153:29): [True: 0, False: 585]
  |  Branch (153:52): [True: 0, False: 585]
  ------------------
  154|      0|                            return best_len;
  155|    585|                        cand_start = zng_memread_8(mbase_start + cur_match);
  156|    585|                        if (scan_start == cand_start)
  ------------------
  |  Branch (156:29): [True: 47, False: 538]
  ------------------
  157|     47|                            break;
  158|    585|                    }
  159|    508|                }
  160|    508|            }
  161|       |            /* All 8 bytes match, fallthrough to compare256 for the tail. */
  162|  1.84M|        } else {
  163|       |            /* Pre-filter the candidate on the start and end sentinels before compare256 using
  164|       |             * simple 8-byte comparison since best_len >= 8. */
  165|   397k|            for (;;) {
  166|       |                /* First check the end of the candidate at best_len+1 due to the higher
  167|       |                 * likelihood of a mismatch. */
  168|   397k|                if (zng_memcmp_8(mbase_end+cur_match, &scan_end) == 0 &&
  ------------------
  |  Branch (168:21): [True: 380k, False: 16.7k]
  ------------------
  169|   380k|                    zng_memcmp_8(mbase_start+cur_match, &scan_start) == 0)
  ------------------
  |  Branch (169:21): [True: 376k, False: 3.90k]
  ------------------
  170|   376k|                    break;
  171|  20.6k|                GOTO_NEXT_CHAIN;
  ------------------
  |  |   16|  20.6k|    if (--chain_length && (cur_match = prev[cur_match & wmask]) > limit) \
  |  |  ------------------
  |  |  |  Branch (16:9): [True: 20.6k, False: 0]
  |  |  |  Branch (16:27): [True: 20.6k, False: 0]
  |  |  ------------------
  |  |   17|  20.6k|        continue; \
  |  |   18|      0|    return best_len;
  ------------------
  172|  20.6k|            }
  173|   376k|        }
  174|  2.21M|        len = COMPARE256(scan+2, mbase_start+cur_match+2) + 2;
  ------------------
  |  |   57|  2.21M|#define COMPARE256          compare256_avx2_static
  ------------------
  175|  2.21M|        Assert(scan+len <= window+(unsigned)(s->window_size-1), "wild scan");
  176|       |
  177|  2.21M|        if (len > best_len)
  ------------------
  |  Branch (177:13): [True: 2.18M, False: 32.0k]
  ------------------
  178|  4.37M|short_match_accept:
  179|  4.37M|        {
  180|  4.37M|            uint32_t match_start = cur_match - match_offset;
  181|  4.37M|            s->match_start = match_start;
  182|       |
  183|       |            /* Do not look for better matches if the current match reaches
  184|       |             * or exceeds the end of the input.
  185|       |             */
  186|  4.37M|            if (UNLIKELY(len >= lookahead))
  ------------------
  |  |  258|  2.19M|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 2.97k, False: 2.18M]
  |  |  ------------------
  ------------------
  187|  2.97k|                return lookahead;
  188|  2.18M|            if (UNLIKELY(len >= nice_match))
  ------------------
  |  |  258|  2.18M|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 1.83M, False: 351k]
  |  |  ------------------
  ------------------
  189|  1.83M|                return len;
  190|       |
  191|   351k|            best_len = len;
  192|       |
  193|   351k|            offset = best_len >= sizeof(uint64_t) ? best_len - 7 : 0;
  ------------------
  |  Branch (193:22): [True: 344k, False: 6.89k]
  ------------------
  194|       |
  195|   351k|            scan_end = zng_memread_8(scan+offset);
  196|       |
  197|   351k|#ifdef LONGEST_MATCH_ROLL
  198|       |            /* Look for a better string offset */
  199|   351k|            if (UNLIKELY(len > STD_MIN_MATCH && match_start + len < strstart)) {
  ------------------
  |  |  258|   701k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 350k, False: 1.37k]
  |  |  |  Branch (258:53): [True: 350k, False: 1.37k]
  |  |  |  Branch (258:53): [True: 350k, False: 0]
  |  |  ------------------
  ------------------
  200|   350k|                const unsigned char *scan_endstr;
  201|   350k|                uint32_t hash;
  202|   350k|                uint32_t pos, next_pos;
  203|       |
  204|       |                /* Go back to offset 0 */
  205|   350k|                cur_match -= match_offset;
  206|   350k|                match_offset = 0;
  207|   350k|                next_pos = cur_match;
  208|  45.3M|                for (uint32_t i = 0; i <= len - STD_MIN_MATCH; i++) {
  ------------------
  |  |   61|  45.3M|#define STD_MIN_MATCH  3
  ------------------
  |  Branch (208:38): [True: 45.0M, False: 350k]
  ------------------
  209|  45.0M|                    pos = prev[(cur_match + i) & wmask];
  210|  45.0M|                    if (UNLIKELY(pos < next_pos)) {
  ------------------
  |  |  258|  45.0M|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 350k, False: 44.6M]
  |  |  ------------------
  ------------------
  211|       |                        /* Hash chain is more distant, use it */
  212|   350k|                        if (UNLIKELY(pos <= limit_base + i))
  ------------------
  |  |  258|   350k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 350k]
  |  |  ------------------
  ------------------
  213|      0|                            return best_len;
  214|   350k|                        next_pos = pos;
  215|   350k|                        match_offset = i;
  216|   350k|                    }
  217|  45.0M|                }
  218|       |                /* Switch cur_match to next_pos chain */
  219|   350k|                cur_match = next_pos;
  220|       |
  221|       |                /* Try hash head at len-(STD_MIN_MATCH-1) position to see if we could get
  222|       |                 * a better cur_match at the end of string. Using (STD_MIN_MATCH-1) lets
  223|       |                 * us include one more byte into hash - the byte which will be checked
  224|       |                 * in main loop now, and which allows to grow match by 1.
  225|       |                 */
  226|   350k|                scan_endstr = scan + len - (STD_MIN_MATCH-1);
  ------------------
  |  |   61|   350k|#define STD_MIN_MATCH  3
  ------------------
  227|       |
  228|   350k|                hash = update_hash_roll(0, scan_endstr[0]);
  229|   350k|                hash = update_hash_roll(hash, scan_endstr[1]);
  230|   350k|                hash = update_hash_roll(hash, scan_endstr[2]);
  231|       |
  232|   350k|                pos = head[hash];
  233|   350k|                if (UNLIKELY(pos < cur_match)) {
  ------------------
  |  |  258|   350k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 350k]
  |  |  ------------------
  ------------------
  234|      0|                    match_offset = len - (STD_MIN_MATCH-1);
  ------------------
  |  |   61|      0|#define STD_MIN_MATCH  3
  ------------------
  235|      0|                    if (pos <= limit_base + match_offset)
  ------------------
  |  Branch (235:25): [True: 0, False: 0]
  ------------------
  236|      0|                        return best_len;
  237|      0|                    cur_match = pos;
  238|      0|                }
  239|       |
  240|       |                /* Update offset-dependent variables */
  241|   350k|                limit = limit_base+match_offset;
  242|   350k|                mbase_start = window-match_offset;
  243|   350k|                mbase_end = (mbase_start+offset);
  244|   350k|                continue;
  245|   350k|            }
  246|  1.37k|#endif
  247|  1.37k|            mbase_end = (mbase_start+offset);
  248|  1.37k|        }
  249|       |#ifndef LONGEST_MATCH_ROLL
  250|       |        else if (UNLIKELY(early_exit)) {
  251|       |            /* The probability of finding a match later if we here is pretty low, so for
  252|       |             * performance it's best to outright stop here for the lower compression levels
  253|       |             */
  254|       |            break;
  255|       |        }
  256|       |#endif
  257|  33.3k|        GOTO_NEXT_CHAIN;
  ------------------
  |  |   16|  33.3k|    if (--chain_length && (cur_match = prev[cur_match & wmask]) > limit) \
  |  |  ------------------
  |  |  |  Branch (16:9): [True: 33.3k, False: 0]
  |  |  |  Branch (16:27): [True: 33.3k, False: 0]
  |  |  ------------------
  |  |   17|  33.3k|        continue; \
  |  |   18|      0|    return best_len;
  ------------------
  258|  33.3k|    }
  259|      0|    return best_len;
  260|  1.83M|}

test_large_deflate:
   24|  1.58k|void test_large_deflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) {
   25|  1.58k|    PREFIX3(stream) c_stream; /* compression stream */
  ------------------
  |  |  123|  1.58k|#  define PREFIX3(x) zng_ ## x
  ------------------
   26|  1.58k|    int err;
   27|       |
   28|  1.58k|    c_stream.zalloc = zalloc;
   29|  1.58k|    c_stream.zfree = zfree;
   30|  1.58k|    c_stream.opaque = (void *)0;
   31|       |
   32|  1.58k|    err = PREFIX(deflateInit)(&c_stream, Z_BEST_COMPRESSION);
  ------------------
  |  |  121|  1.58k|#  define PREFIX(x) zng_ ## x
  ------------------
                  err = PREFIX(deflateInit)(&c_stream, Z_BEST_COMPRESSION);
  ------------------
  |  |  195|  1.58k|#define Z_BEST_COMPRESSION       9
  ------------------
   33|  1.58k|    CHECK_ERR(err, "deflateInit");
  ------------------
  |  |   10|  1.58k|#define CHECK_ERR(err, msg) { \
  |  |   11|  1.58k|    if (err != Z_OK) { \
  |  |  ------------------
  |  |  |  |  180|  3.16k|#define Z_OK            0
  |  |  ------------------
  |  |  |  Branch (11:9): [True: 0, False: 1.58k]
  |  |  ------------------
  |  |   12|      0|        fprintf(stderr, "%s error: %d\n", msg, err); \
  |  |   13|      0|        exit(1); \
  |  |   14|      0|    } \
  |  |   15|  1.58k|}
  ------------------
   34|       |
   35|  1.58k|    c_stream.next_out = compr;
   36|  1.58k|    c_stream.avail_out = (unsigned int)comprLen;
   37|       |
   38|       |    /* At this point, uncompr is still mostly zeroes, so it should compress
   39|       |     * very well:
   40|       |     */
   41|  1.58k|    c_stream.next_in = uncompr;
   42|  1.58k|    c_stream.avail_in = (unsigned int)uncomprLen;
   43|  1.58k|    err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH);
  ------------------
  |  |  121|  1.58k|#  define PREFIX(x) zng_ ## x
  ------------------
                  err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH);
  ------------------
  |  |  171|  1.58k|#define Z_NO_FLUSH      0
  ------------------
   44|  1.58k|    CHECK_ERR(err, "deflate large 1");
  ------------------
  |  |   10|  1.58k|#define CHECK_ERR(err, msg) { \
  |  |   11|  1.58k|    if (err != Z_OK) { \
  |  |  ------------------
  |  |  |  |  180|  3.16k|#define Z_OK            0
  |  |  ------------------
  |  |  |  Branch (11:9): [True: 0, False: 1.58k]
  |  |  ------------------
  |  |   12|      0|        fprintf(stderr, "%s error: %d\n", msg, err); \
  |  |   13|      0|        exit(1); \
  |  |   14|      0|    } \
  |  |   15|  1.58k|}
  ------------------
   45|  1.58k|    if (c_stream.avail_in != 0) {
  ------------------
  |  Branch (45:9): [True: 0, False: 1.58k]
  ------------------
   46|      0|        fprintf(stderr, "deflate not greedy\n");
   47|      0|        exit(1);
   48|      0|    }
   49|       |
   50|       |    /* Feed in already compressed data and switch to no compression: */
   51|  1.58k|    PREFIX(deflateParams)(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY);
  ------------------
  |  |  121|  1.58k|#  define PREFIX(x) zng_ ## x
  ------------------
                  PREFIX(deflateParams)(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY);
  ------------------
  |  |  193|  1.58k|#define Z_NO_COMPRESSION         0
  ------------------
                  PREFIX(deflateParams)(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY);
  ------------------
  |  |  203|  1.58k|#define Z_DEFAULT_STRATEGY    0
  ------------------
   52|  1.58k|    c_stream.next_in = compr;
   53|  1.58k|    diff = (unsigned int)(c_stream.next_out - compr);
   54|  1.58k|    c_stream.avail_in = diff;
   55|  1.58k|    err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH);
  ------------------
  |  |  121|  1.58k|#  define PREFIX(x) zng_ ## x
  ------------------
                  err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH);
  ------------------
  |  |  171|  1.58k|#define Z_NO_FLUSH      0
  ------------------
   56|  1.58k|    CHECK_ERR(err, "deflate large 2");
  ------------------
  |  |   10|  1.58k|#define CHECK_ERR(err, msg) { \
  |  |   11|  1.58k|    if (err != Z_OK) { \
  |  |  ------------------
  |  |  |  |  180|  3.16k|#define Z_OK            0
  |  |  ------------------
  |  |  |  Branch (11:9): [True: 0, False: 1.58k]
  |  |  ------------------
  |  |   12|      0|        fprintf(stderr, "%s error: %d\n", msg, err); \
  |  |   13|      0|        exit(1); \
  |  |   14|      0|    } \
  |  |   15|  1.58k|}
  ------------------
   57|       |
   58|       |    /* Switch back to compressing mode: */
   59|  1.58k|    PREFIX(deflateParams)(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED);
  ------------------
  |  |  121|  1.58k|#  define PREFIX(x) zng_ ## x
  ------------------
                  PREFIX(deflateParams)(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED);
  ------------------
  |  |  195|  1.58k|#define Z_BEST_COMPRESSION       9
  ------------------
                  PREFIX(deflateParams)(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED);
  ------------------
  |  |  199|  1.58k|#define Z_FILTERED            1
  ------------------
   60|  1.58k|    c_stream.next_in = uncompr;
   61|  1.58k|    c_stream.avail_in = (unsigned int)uncomprLen;
   62|  1.58k|    err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH);
  ------------------
  |  |  121|  1.58k|#  define PREFIX(x) zng_ ## x
  ------------------
                  err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH);
  ------------------
  |  |  171|  1.58k|#define Z_NO_FLUSH      0
  ------------------
   63|  1.58k|    CHECK_ERR(err, "deflate large 3");
  ------------------
  |  |   10|  1.58k|#define CHECK_ERR(err, msg) { \
  |  |   11|  1.58k|    if (err != Z_OK) { \
  |  |  ------------------
  |  |  |  |  180|  3.16k|#define Z_OK            0
  |  |  ------------------
  |  |  |  Branch (11:9): [True: 0, False: 1.58k]
  |  |  ------------------
  |  |   12|      0|        fprintf(stderr, "%s error: %d\n", msg, err); \
  |  |   13|      0|        exit(1); \
  |  |   14|      0|    } \
  |  |   15|  1.58k|}
  ------------------
   64|       |
   65|  1.58k|    err = PREFIX(deflate)(&c_stream, Z_FINISH);
  ------------------
  |  |  121|  1.58k|#  define PREFIX(x) zng_ ## x
  ------------------
                  err = PREFIX(deflate)(&c_stream, Z_FINISH);
  ------------------
  |  |  175|  1.58k|#define Z_FINISH        4
  ------------------
   66|  1.58k|    if (err != Z_STREAM_END) {
  ------------------
  |  |  181|  1.58k|#define Z_STREAM_END    1
  ------------------
  |  Branch (66:9): [True: 0, False: 1.58k]
  ------------------
   67|      0|        fprintf(stderr, "deflate large should report Z_STREAM_END\n");
   68|      0|        exit(1);
   69|      0|    }
   70|  1.58k|    err = PREFIX(deflateEnd)(&c_stream);
  ------------------
  |  |  121|  1.58k|#  define PREFIX(x) zng_ ## x
  ------------------
   71|  1.58k|    CHECK_ERR(err, "deflateEnd");
  ------------------
  |  |   10|  1.58k|#define CHECK_ERR(err, msg) { \
  |  |   11|  1.58k|    if (err != Z_OK) { \
  |  |  ------------------
  |  |  |  |  180|  3.16k|#define Z_OK            0
  |  |  ------------------
  |  |  |  Branch (11:9): [True: 0, False: 1.58k]
  |  |  ------------------
  |  |   12|      0|        fprintf(stderr, "%s error: %d\n", msg, err); \
  |  |   13|      0|        exit(1); \
  |  |   14|      0|    } \
  |  |   15|  1.58k|}
  ------------------
   72|  1.58k|}
test_large_inflate:
   77|  1.58k|void test_large_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) {
   78|  1.58k|    int err;
   79|  1.58k|    PREFIX3(stream) d_stream; /* decompression stream */
  ------------------
  |  |  123|  1.58k|#  define PREFIX3(x) zng_ ## x
  ------------------
   80|       |
   81|  1.58k|    d_stream.zalloc = zalloc;
   82|  1.58k|    d_stream.zfree = zfree;
   83|  1.58k|    d_stream.opaque = (void *)0;
   84|       |
   85|  1.58k|    d_stream.next_in = compr;
   86|  1.58k|    d_stream.avail_in = (unsigned int)comprLen;
   87|       |
   88|  1.58k|    err = PREFIX(inflateInit)(&d_stream);
  ------------------
  |  |  121|  1.58k|#  define PREFIX(x) zng_ ## x
  ------------------
   89|  1.58k|    CHECK_ERR(err, "inflateInit");
  ------------------
  |  |   10|  1.58k|#define CHECK_ERR(err, msg) { \
  |  |   11|  1.58k|    if (err != Z_OK) { \
  |  |  ------------------
  |  |  |  |  180|  3.16k|#define Z_OK            0
  |  |  ------------------
  |  |  |  Branch (11:9): [True: 0, False: 1.58k]
  |  |  ------------------
  |  |   12|      0|        fprintf(stderr, "%s error: %d\n", msg, err); \
  |  |   13|      0|        exit(1); \
  |  |   14|      0|    } \
  |  |   15|  1.58k|}
  ------------------
   90|       |
   91|  4.74k|    for (;;) {
   92|  4.74k|        d_stream.next_out = uncompr; /* discard the output */
   93|  4.74k|        d_stream.avail_out = (unsigned int)uncomprLen;
   94|  4.74k|        err = PREFIX(inflate)(&d_stream, Z_NO_FLUSH);
  ------------------
  |  |  121|  4.74k|#  define PREFIX(x) zng_ ## x
  ------------------
                      err = PREFIX(inflate)(&d_stream, Z_NO_FLUSH);
  ------------------
  |  |  171|  4.74k|#define Z_NO_FLUSH      0
  ------------------
   95|  4.74k|        if (err == Z_STREAM_END)
  ------------------
  |  |  181|  4.74k|#define Z_STREAM_END    1
  ------------------
  |  Branch (95:13): [True: 1.58k, False: 3.16k]
  ------------------
   96|  1.58k|            break;
   97|  3.16k|        CHECK_ERR(err, "large inflate");
  ------------------
  |  |   10|  3.16k|#define CHECK_ERR(err, msg) { \
  |  |   11|  3.16k|    if (err != Z_OK) { \
  |  |  ------------------
  |  |  |  |  180|  6.32k|#define Z_OK            0
  |  |  ------------------
  |  |  |  Branch (11:9): [True: 0, False: 3.16k]
  |  |  ------------------
  |  |   12|      0|        fprintf(stderr, "%s error: %d\n", msg, err); \
  |  |   13|      0|        exit(1); \
  |  |   14|      0|    } \
  |  |   15|  3.16k|}
  ------------------
   98|  3.16k|    }
   99|       |
  100|  1.58k|    err = PREFIX(inflateEnd)(&d_stream);
  ------------------
  |  |  121|  1.58k|#  define PREFIX(x) zng_ ## x
  ------------------
  101|  1.58k|    CHECK_ERR(err, "inflateEnd");
  ------------------
  |  |   10|  1.58k|#define CHECK_ERR(err, msg) { \
  |  |   11|  1.58k|    if (err != Z_OK) { \
  |  |  ------------------
  |  |  |  |  180|  3.16k|#define Z_OK            0
  |  |  ------------------
  |  |  |  Branch (11:9): [True: 0, False: 1.58k]
  |  |  ------------------
  |  |   12|      0|        fprintf(stderr, "%s error: %d\n", msg, err); \
  |  |   13|      0|        exit(1); \
  |  |   14|      0|    } \
  |  |   15|  1.58k|}
  ------------------
  102|       |
  103|  1.58k|    if (d_stream.total_out != 2 * uncomprLen + diff) {
  ------------------
  |  Branch (103:9): [True: 0, False: 1.58k]
  ------------------
  104|       |        fprintf(stderr, "bad large inflate: %" PRIu64 "\n", (uint64_t)d_stream.total_out);
  105|      0|        exit(1);
  106|      0|    }
  107|  1.58k|}
LLVMFuzzerTestOneInput:
  109|  1.58k|int LLVMFuzzerTestOneInput(const uint8_t *d, size_t size) {
  110|  1.58k|    Z_UNUSED(d);
  ------------------
  |  |  154|  1.58k|#define Z_UNUSED(var) (void)(var)
  ------------------
  111|  1.58k|    size_t comprLen = 100 + 3 * size;
  112|  1.58k|    size_t uncomprLen = comprLen;
  113|  1.58k|    uint8_t *compr, *uncompr;
  114|       |
  115|       |    /* Discard inputs larger than 512Kb. */
  116|  1.58k|    static size_t kMaxSize = 512 * 1024;
  117|       |
  118|  1.58k|    if (size < 1 || size > kMaxSize)
  ------------------
  |  Branch (118:9): [True: 0, False: 1.58k]
  |  Branch (118:21): [True: 4, False: 1.58k]
  ------------------
  119|      4|        return 0;
  120|       |
  121|  1.58k|    compr = (uint8_t *)calloc(1, comprLen);
  122|  1.58k|    uncompr = (uint8_t *)calloc(1, uncomprLen);
  123|       |
  124|  1.58k|    test_large_deflate(compr, comprLen, uncompr, uncomprLen);
  125|  1.58k|    test_large_inflate(compr, comprLen, uncompr, uncomprLen);
  126|       |
  127|  1.58k|    free(compr);
  128|  1.58k|    free(uncompr);
  129|       |
  130|       |    /* This function must return 0. */
  131|  1.58k|    return 0;
  132|  1.58k|}

zng_tr_init:
   83|  1.58k|void Z_INTERNAL zng_tr_init(deflate_state *s) {
   84|  1.58k|    s->l_desc.dyn_tree = s->dyn_ltree;
   85|  1.58k|    s->l_desc.stat_desc = &static_l_desc;
   86|       |
   87|  1.58k|    s->d_desc.dyn_tree = s->dyn_dtree;
   88|  1.58k|    s->d_desc.stat_desc = &static_d_desc;
   89|       |
   90|  1.58k|    s->bl_desc.dyn_tree = s->bl_tree;
   91|  1.58k|    s->bl_desc.stat_desc = &static_bl_desc;
   92|       |
   93|  1.58k|    s->bi_buf = 0;
   94|  1.58k|    s->bi_valid = 0;
   95|  1.58k|    s->bi_used = 0;
   96|       |#ifdef ZLIB_DEBUG
   97|       |    s->compressed_len = 0L;
   98|       |    s->bits_sent = 0L;
   99|       |#endif
  100|       |
  101|       |    /* Initialize the first block of the first file: */
  102|  1.58k|    init_block(s);
  103|  1.58k|}
gen_codes:
  377|  9.48k|Z_INTERNAL void gen_codes(ct_data *tree, int max_code, uint16_t *bl_count) {
  378|       |    /* tree: the tree to decorate */
  379|       |    /* max_code: largest code with non zero frequency */
  380|       |    /* bl_count: number of codes at each bit length */
  381|  9.48k|    uint16_t next_code[MAX_BITS+1];  /* next code value for each bit length */
  382|  9.48k|    uint16_t code = 0;               /* running code value */
  383|  9.48k|    int bits;                        /* bit index */
  384|  9.48k|    int n;                           /* code index */
  385|       |
  386|       |    /* The distribution counts are first used to generate the code values
  387|       |     * without bit reversal.
  388|       |     */
  389|   151k|    for (bits = 1; bits <= MAX_BITS; bits++) {
  ------------------
  |  |   41|   151k|#define MAX_BITS 15
  ------------------
  |  Branch (389:20): [True: 142k, False: 9.48k]
  ------------------
  390|   142k|        code = (code + bl_count[bits-1]) << 1;
  391|   142k|        next_code[bits] = code;
  392|   142k|    }
  393|       |    /* Check that the bit counts in bl_count are consistent. The last code
  394|       |     * must be all ones.
  395|       |     */
  396|  9.48k|    Assert(code + bl_count[MAX_BITS]-1 == (1 << MAX_BITS)-1, "inconsistent bit counts");
  397|  9.48k|    Tracev((stderr, "\ngen_codes: max_code %d ", max_code));
  398|       |
  399|  1.00M|    for (n = 0;  n <= max_code; n++) {
  ------------------
  |  Branch (399:18): [True: 990k, False: 9.48k]
  ------------------
  400|   990k|        int len = tree[n].Len;
  ------------------
  |  |  128|   990k|#define Len  dl.len
  ------------------
  401|   990k|        if (len == 0)
  ------------------
  |  Branch (401:13): [True: 960k, False: 29.8k]
  ------------------
  402|   960k|            continue;
  403|       |        /* Now reverse the bits */
  404|  29.8k|        tree[n].Code = bi_reverse(next_code[len]++, len);
  ------------------
  |  |  126|  29.8k|#define Code fc.code
  ------------------
  405|       |
  406|  29.8k|        Tracecv(tree != static_ltree, (stderr, "\nn %3d %c l %2d c %4x (%x) ",
  407|  29.8k|             n, (isgraph(n & 0xff) ? n : ' '), len, tree[n].Code, next_code[len]-1));
  408|  29.8k|    }
  409|  9.48k|}
zng_tr_stored_block:
  596|  1.58k|void Z_INTERNAL zng_tr_stored_block(deflate_state *s, unsigned char *buf, uint32_t stored_len, int last) {
  597|       |    /* buf: input block */
  598|       |    /* stored_len: length of input block */
  599|       |    /* last: one if this is the last block for a file */
  600|  1.58k|    zng_tr_emit_tree(s, STORED_BLOCK, last); /* send block type */
  ------------------
  |  |   56|  1.58k|#define STORED_BLOCK 0
  ------------------
  601|  1.58k|    zng_tr_emit_align(s);                    /* align on byte boundary */
  602|  1.58k|    cmpr_bits_align(s);
  603|  1.58k|    put_short(s, (uint16_t)stored_len);
  604|  1.58k|    put_short(s, (uint16_t)~stored_len);
  605|  1.58k|    cmpr_bits_add(s, 32);
  ------------------
  |  |  449|  1.58k|#  define cmpr_bits_add(s, len)     Z_UNUSED(len)
  |  |  ------------------
  |  |  |  |  154|  1.58k|#define Z_UNUSED(var) (void)(var)
  |  |  ------------------
  ------------------
  606|  1.58k|    sent_bits_add(s, 32);
  ------------------
  |  |  451|  1.58k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  ------------------
  |  |  |  |  154|  1.58k|#define Z_UNUSED(var) (void)(var)
  |  |  ------------------
  ------------------
  607|  1.58k|    if (stored_len) {
  ------------------
  |  Branch (607:9): [True: 0, False: 1.58k]
  ------------------
  608|      0|        memcpy(s->pending_buf + s->pending, buf, stored_len);
  609|      0|        s->pending += stored_len;
  610|      0|        cmpr_bits_add(s, stored_len << 3);
  ------------------
  |  |  449|      0|#  define cmpr_bits_add(s, len)     Z_UNUSED(len)
  |  |  ------------------
  |  |  |  |  154|      0|#define Z_UNUSED(var) (void)(var)
  |  |  ------------------
  ------------------
  611|      0|        sent_bits_add(s, stored_len << 3);
  ------------------
  |  |  451|      0|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  ------------------
  |  |  |  |  154|      0|#define Z_UNUSED(var) (void)(var)
  |  |  ------------------
  ------------------
  612|      0|    }
  613|  1.58k|}
zng_tr_flush_block:
  629|  3.16k|void Z_INTERNAL zng_tr_flush_block(deflate_state *s, unsigned char *buf, uint32_t stored_len, int last) {
  630|       |    /* buf: input block, or NULL if too old */
  631|       |    /* stored_len: length of input block */
  632|       |    /* last: one if this is the last block for a file */
  633|  3.16k|    unsigned int opt_lenb, static_lenb; /* opt_len and static_len in bytes */
  634|  3.16k|    int max_blindex = 0;  /* index of last bit length code of non zero freq */
  635|       |
  636|       |    /* Build the Huffman trees unless a stored block is forced */
  637|  3.16k|    if (UNLIKELY(s->sym_next == 0)) {
  ------------------
  |  |  258|  3.16k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 3.16k]
  |  |  ------------------
  ------------------
  638|       |        /* Emit an empty static tree block with no codes */
  639|      0|        opt_lenb = static_lenb = 0;
  640|      0|        s->static_len = 7;
  641|  3.16k|    } else if (s->level > 0) {
  ------------------
  |  Branch (641:16): [True: 3.16k, False: 0]
  ------------------
  642|       |        /* Check if the file is binary or text */
  643|  3.16k|        if (s->strm->data_type == Z_UNKNOWN)
  ------------------
  |  |  209|  3.16k|#define Z_UNKNOWN  2
  ------------------
  |  Branch (643:13): [True: 1.58k, False: 1.58k]
  ------------------
  644|  1.58k|            s->strm->data_type = detect_data_type(s);
  645|       |
  646|       |        /* Construct the literal and distance trees */
  647|  3.16k|        build_tree(s, (tree_desc *)(&(s->l_desc)));
  648|  3.16k|        Tracev((stderr, "\nlit data: dyn %u, stat %u", s->opt_len, s->static_len));
  649|       |
  650|  3.16k|        build_tree(s, (tree_desc *)(&(s->d_desc)));
  651|  3.16k|        Tracev((stderr, "\ndist data: dyn %u, stat %u", s->opt_len, s->static_len));
  652|       |        /* At this point, opt_len and static_len are the total bit lengths of
  653|       |         * the compressed block data, excluding the tree representations.
  654|       |         */
  655|       |
  656|       |        /* Build the bit length tree for the above two trees, and get the index
  657|       |         * in bl_order of the last bit length code to send.
  658|       |         */
  659|  3.16k|        max_blindex = build_bl_tree(s);
  660|       |
  661|       |        /* Determine the best encoding. Compute the block lengths in bytes. */
  662|  3.16k|        opt_lenb = (s->opt_len + 3 + 7) >> 3;
  663|  3.16k|        static_lenb = (s->static_len + 3 + 7) >> 3;
  664|       |
  665|  3.16k|        Tracev((stderr, "\nopt %u(%u) stat %u(%u) stored %u lit %u ",
  666|  3.16k|                opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
  667|  3.16k|                s->sym_next / 3));
  668|       |
  669|  3.16k|        if (static_lenb <= opt_lenb || s->strategy == Z_FIXED)
  ------------------
  |  |  202|  2.54k|#define Z_FIXED               4
  ------------------
  |  Branch (669:13): [True: 619, False: 2.54k]
  |  Branch (669:40): [True: 0, False: 2.54k]
  ------------------
  670|    619|            opt_lenb = static_lenb;
  671|       |
  672|  3.16k|    } else {
  673|      0|        Assert(buf != NULL, "lost buf");
  674|      0|        opt_lenb = static_lenb = stored_len + 5; /* force a stored block */
  675|      0|    }
  676|       |
  677|  3.16k|    if (stored_len+4 <= opt_lenb && buf != NULL) {
  ------------------
  |  Branch (677:9): [True: 0, False: 3.16k]
  |  Branch (677:37): [True: 0, False: 0]
  ------------------
  678|       |        /* 4: two words for the lengths
  679|       |         * The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
  680|       |         * Otherwise we can't have processed more than WSIZE input bytes since
  681|       |         * the last block flush, because compression would have been
  682|       |         * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
  683|       |         * transform a block into a stored block.
  684|       |         */
  685|      0|        zng_tr_stored_block(s, buf, stored_len, last);
  686|       |
  687|  3.16k|    } else if (static_lenb == opt_lenb) {
  ------------------
  |  Branch (687:16): [True: 619, False: 2.54k]
  ------------------
  688|    619|        zng_tr_emit_tree(s, STATIC_TREES, last);
  ------------------
  |  |   57|    619|#define STATIC_TREES 1
  ------------------
  689|    619|        compress_block(s, (const ct_data *)static_ltree, (const ct_data *)static_dtree);
  690|    619|        cmpr_bits_add(s, s->static_len);
  ------------------
  |  |  449|    619|#  define cmpr_bits_add(s, len)     Z_UNUSED(len)
  |  |  ------------------
  |  |  |  |  154|    619|#define Z_UNUSED(var) (void)(var)
  |  |  ------------------
  ------------------
  691|  2.54k|    } else {
  692|  2.54k|        zng_tr_emit_tree(s, DYN_TREES, last);
  ------------------
  |  |   58|  2.54k|#define DYN_TREES    2
  ------------------
  693|  2.54k|        send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, max_blindex+1);
  694|  2.54k|        compress_block(s, (const ct_data *)s->dyn_ltree, (const ct_data *)s->dyn_dtree);
  695|  2.54k|        cmpr_bits_add(s, s->opt_len);
  ------------------
  |  |  449|  2.54k|#  define cmpr_bits_add(s, len)     Z_UNUSED(len)
  |  |  ------------------
  |  |  |  |  154|  2.54k|#define Z_UNUSED(var) (void)(var)
  |  |  ------------------
  ------------------
  696|  2.54k|    }
  697|  3.16k|    Assert(s->compressed_len == s->bits_sent, "bad compressed size");
  698|       |    /* The above check is made mod 2^32, for files larger than 512 MB
  699|       |     * and unsigned long implemented on 32 bits.
  700|       |     */
  701|  3.16k|    init_block(s);
  702|       |
  703|  3.16k|    if (last) {
  ------------------
  |  Branch (703:9): [True: 1.58k, False: 1.58k]
  ------------------
  704|  1.58k|        zng_tr_emit_align(s);
  705|  1.58k|    }
  706|  3.16k|    Tracev((stderr, "\ncomprlen %lu(%lu) ", s->compressed_len>>3, s->compressed_len-7*last));
  707|  3.16k|}
zng_tr_flush_bits:
  865|  11.0k|void Z_INTERNAL zng_tr_flush_bits(deflate_state *s) {
  866|  11.0k|    if (s->bi_valid >= 48) {
  ------------------
  |  Branch (866:9): [True: 507, False: 10.5k]
  ------------------
  867|    507|        put_uint32(s, (uint32_t)s->bi_buf);
  868|    507|        put_short(s, (uint16_t)(s->bi_buf >> 32));
  869|    507|        s->bi_buf >>= 48;
  870|    507|        s->bi_valid -= 48;
  871|  10.5k|    } else if (s->bi_valid >= 32) {
  ------------------
  |  Branch (871:16): [True: 387, False: 10.1k]
  ------------------
  872|    387|        put_uint32(s, (uint32_t)s->bi_buf);
  873|    387|        s->bi_buf >>= 32;
  874|    387|        s->bi_valid -= 32;
  875|    387|    }
  876|  11.0k|    if (s->bi_valid >= 16) {
  ------------------
  |  Branch (876:9): [True: 301, False: 10.7k]
  ------------------
  877|    301|        put_short(s, (uint16_t)s->bi_buf);
  878|    301|        s->bi_buf >>= 16;
  879|    301|        s->bi_valid -= 16;
  880|    301|    }
  881|  11.0k|    if (s->bi_valid >= 8) {
  ------------------
  |  Branch (881:9): [True: 772, False: 10.2k]
  ------------------
  882|    772|        put_byte(s, s->bi_buf);
  ------------------
  |  |  350|    772|#define put_byte(s, c) { \
  |  |  351|    772|    s->pending_buf[s->pending++] = (unsigned char)(c); \
  |  |  352|    772|}
  ------------------
  883|    772|        s->bi_buf >>= 8;
  884|    772|        s->bi_valid -= 8;
  885|    772|    }
  886|  11.0k|}
trees.c:init_block:
  108|  4.74k|static void init_block(deflate_state *s) {
  109|  4.74k|    int n; /* iterates over tree elements */
  110|       |
  111|       |    /* Initialize the trees. */
  112|  1.36M|    for (n = 0; n < L_CODES;  n++)
  ------------------
  |  |   48|  1.36M|#define L_CODES (LITERALS+1+LENGTH_CODES)
  |  |  ------------------
  |  |  |  |   45|  1.36M|#define LITERALS  256
  |  |  ------------------
  |  |               #define L_CODES (LITERALS+1+LENGTH_CODES)
  |  |  ------------------
  |  |  |  |   42|  1.36M|#define LENGTH_CODES 29
  |  |  ------------------
  ------------------
  |  Branch (112:17): [True: 1.35M, False: 4.74k]
  ------------------
  113|  1.35M|        s->dyn_ltree[n].Freq = 0;
  ------------------
  |  |  125|  1.35M|#define Freq fc.freq
  ------------------
  114|   146k|    for (n = 0; n < D_CODES;  n++)
  ------------------
  |  |   51|   146k|#define D_CODES   30
  ------------------
  |  Branch (114:17): [True: 142k, False: 4.74k]
  ------------------
  115|   142k|        s->dyn_dtree[n].Freq = 0;
  ------------------
  |  |  125|   142k|#define Freq fc.freq
  ------------------
  116|  94.8k|    for (n = 0; n < BL_CODES; n++)
  ------------------
  |  |   54|  94.8k|#define BL_CODES  19
  ------------------
  |  Branch (116:17): [True: 90.0k, False: 4.74k]
  ------------------
  117|  90.0k|        s->bl_tree[n].Freq = 0;
  ------------------
  |  |  125|  90.0k|#define Freq fc.freq
  ------------------
  118|       |
  119|  4.74k|    s->dyn_ltree[END_BLOCK].Freq = 1;
  ------------------
  |  |   63|  4.74k|#define END_BLOCK 256
  ------------------
                  s->dyn_ltree[END_BLOCK].Freq = 1;
  ------------------
  |  |  125|  4.74k|#define Freq fc.freq
  ------------------
  120|  4.74k|    s->opt_len = s->static_len = 0;
  121|  4.74k|    s->sym_next = 0;
  122|  4.74k|}
trees.c:build_tree:
  185|  9.48k|static void build_tree(deflate_state *s, tree_desc *desc) {
  186|       |    /* desc: the tree descriptor */
  187|  9.48k|    unsigned char *depth  = s->depth;
  188|  9.48k|    int *heap             = s->heap;
  189|  9.48k|    ct_data *tree         = desc->dyn_tree;
  190|  9.48k|    const ct_data *stree  = desc->stat_desc->static_tree;
  191|  9.48k|    int elems             = desc->stat_desc->elems;
  192|  9.48k|    int n, m;          /* iterate over heap elements */
  193|  9.48k|    int max_code = -1; /* largest code with non zero frequency */
  194|  9.48k|    int node;          /* new node being created */
  195|       |
  196|       |    /* Construct the initial heap, with least frequent element in
  197|       |     * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
  198|       |     * heap[0] is not used.
  199|       |     */
  200|  9.48k|    s->heap_len = 0;
  201|  9.48k|    s->heap_max = HEAP_SIZE;
  ------------------
  |  |   57|  9.48k|#define HEAP_SIZE (2*L_CODES+1)
  |  |  ------------------
  |  |  |  |   48|  9.48k|#define L_CODES (LITERALS+1+LENGTH_CODES)
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  9.48k|#define LITERALS  256
  |  |  |  |  ------------------
  |  |  |  |               #define L_CODES (LITERALS+1+LENGTH_CODES)
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|  9.48k|#define LENGTH_CODES 29
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  202|       |
  203|  1.06M|    for (n = 0; n < elems; n++) {
  ------------------
  |  Branch (203:17): [True: 1.05M, False: 9.48k]
  ------------------
  204|  1.05M|        if (tree[n].Freq != 0) {
  ------------------
  |  |  125|  1.05M|#define Freq fc.freq
  ------------------
  |  Branch (204:13): [True: 28.0k, False: 1.03M]
  ------------------
  205|  28.0k|            heap[++(s->heap_len)] = max_code = n;
  206|  28.0k|            depth[n] = 0;
  207|  1.03M|        } else {
  208|  1.03M|            tree[n].Len = 0;
  ------------------
  |  |  128|  1.03M|#define Len  dl.len
  ------------------
  209|  1.03M|        }
  210|  1.05M|    }
  211|       |
  212|       |    /* The pkzip format requires that at least one distance code exists,
  213|       |     * and that at least one bit should be sent even if there is only one
  214|       |     * possible code. So to avoid special checks later on we force at least
  215|       |     * two codes of non zero frequency.
  216|       |     */
  217|  11.2k|    while (s->heap_len < 2) {
  ------------------
  |  Branch (217:12): [True: 1.78k, False: 9.48k]
  ------------------
  218|  1.78k|        node = heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0);
  ------------------
  |  Branch (218:41): [True: 1.78k, False: 1]
  ------------------
  219|  1.78k|        tree[node].Freq = 1;
  ------------------
  |  |  125|  1.78k|#define Freq fc.freq
  ------------------
  220|  1.78k|        depth[node] = 0;
  221|  1.78k|        s->opt_len--;
  222|  1.78k|        if (stree)
  ------------------
  |  Branch (222:13): [True: 1.78k, False: 0]
  ------------------
  223|  1.78k|            s->static_len -= stree[node].Len;
  ------------------
  |  |  128|  1.78k|#define Len  dl.len
  ------------------
  224|       |        /* node is 0 or 1 so it does not have extra bits */
  225|  1.78k|    }
  226|  9.48k|    desc->max_code = max_code;
  227|       |
  228|       |    /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
  229|       |     * establish sub-heaps of increasing lengths:
  230|       |     */
  231|  22.6k|    for (n = s->heap_len/2; n >= 1; n--)
  ------------------
  |  Branch (231:29): [True: 13.2k, False: 9.48k]
  ------------------
  232|  13.2k|        pqdownheap(depth, heap, s->heap_len, tree, n);
  233|       |
  234|       |    /* Construct the Huffman tree by repeatedly combining the least two
  235|       |     * frequent nodes.
  236|       |     */
  237|  9.48k|    node = elems;              /* next internal node of the tree */
  238|  20.3k|    do {
  239|  20.3k|        pqremove(s, depth, heap, tree, n);  /* n = node of least frequency */
  ------------------
  |  |  140|  20.3k|#define pqremove(s, depth, heap, tree, top) { \
  |  |  141|  20.3k|    top = heap[SMALLEST]; \
  |  |  ------------------
  |  |  |  |  124|  20.3k|#define SMALLEST 1
  |  |  ------------------
  |  |  142|  20.3k|    heap[SMALLEST] = heap[s->heap_len--]; \
  |  |  ------------------
  |  |  |  |  124|  20.3k|#define SMALLEST 1
  |  |  ------------------
  |  |  143|  20.3k|    pqdownheap(depth, heap, s->heap_len, tree, SMALLEST); \
  |  |  ------------------
  |  |  |  |  124|  20.3k|#define SMALLEST 1
  |  |  ------------------
  |  |  144|  20.3k|}
  ------------------
  240|  20.3k|        m = heap[SMALLEST]; /* m = node of next least frequency */
  ------------------
  |  |  124|  20.3k|#define SMALLEST 1
  ------------------
  241|       |
  242|  20.3k|        heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */
  243|  20.3k|        heap[--(s->heap_max)] = m;
  244|       |
  245|       |        /* Create a new node father of n and m */
  246|  20.3k|        tree[node].Freq = tree[n].Freq + tree[m].Freq;
  ------------------
  |  |  125|  20.3k|#define Freq fc.freq
  ------------------
                      tree[node].Freq = tree[n].Freq + tree[m].Freq;
  ------------------
  |  |  125|  20.3k|#define Freq fc.freq
  ------------------
                      tree[node].Freq = tree[n].Freq + tree[m].Freq;
  ------------------
  |  |  125|  20.3k|#define Freq fc.freq
  ------------------
  247|  20.3k|        depth[node] = (unsigned char)((depth[n] >= depth[m] ?
  ------------------
  |  Branch (247:40): [True: 14.8k, False: 5.45k]
  ------------------
  248|  14.8k|                                          depth[n] : depth[m]) + 1);
  249|  20.3k|        tree[n].Dad = tree[m].Dad = (uint16_t)node;
  ------------------
  |  |  127|  20.3k|#define Dad  dl.dad
  ------------------
                      tree[n].Dad = tree[m].Dad = (uint16_t)node;
  ------------------
  |  |  127|  20.3k|#define Dad  dl.dad
  ------------------
  250|       |#ifdef DUMP_BL_TREE
  251|       |        if (tree == s->bl_tree) {
  252|       |            fprintf(stderr, "\nnode %d(%d), sons %d(%d) %d(%d)",
  253|       |                    node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq);
  254|       |        }
  255|       |#endif
  256|       |        /* and insert the new node in the heap */
  257|  20.3k|        heap[SMALLEST] = node++;
  ------------------
  |  |  124|  20.3k|#define SMALLEST 1
  ------------------
  258|  20.3k|        pqdownheap(depth, heap, s->heap_len, tree, SMALLEST);
  ------------------
  |  |  124|  20.3k|#define SMALLEST 1
  ------------------
  259|  20.3k|    } while (s->heap_len >= 2);
  ------------------
  |  Branch (259:14): [True: 10.8k, False: 9.48k]
  ------------------
  260|       |
  261|  9.48k|    heap[--(s->heap_max)] = heap[SMALLEST];
  ------------------
  |  |  124|  9.48k|#define SMALLEST 1
  ------------------
  262|       |
  263|       |    /* At this point, the fields freq and dad are set. We can now
  264|       |     * generate the bit lengths.
  265|       |     */
  266|  9.48k|    gen_bitlen(s, (tree_desc *)desc);
  267|       |
  268|       |    /* The field len is now set, we can generate the bit codes */
  269|  9.48k|    gen_codes((ct_data *)tree, max_code, s->bl_count);
  270|  9.48k|}
trees.c:pqdownheap:
  152|  53.8k|static inline void pqdownheap(unsigned char *depth, int *heap, const int heap_len, ct_data *tree, int k) {
  153|       |    /* tree: the tree to restore */
  154|       |    /* k: node to move down */
  155|  53.8k|    int j = k << 1;  /* left son of k */
  156|  53.8k|    const int v = heap[k];
  157|       |
  158|  78.6k|    while (j <= heap_len) {
  ------------------
  |  Branch (158:12): [True: 36.7k, False: 41.8k]
  ------------------
  159|       |        /* Set j to the smallest of the two sons: */
  160|  36.7k|        if (j < heap_len && smaller(tree, heap[j+1], heap[j], depth)) {
  ------------------
  |  |  133|  16.9k|    (tree[n].Freq < tree[m].Freq || \
  |  |  ------------------
  |  |  |  |  125|  16.9k|#define Freq fc.freq
  |  |  ------------------
  |  |                   (tree[n].Freq < tree[m].Freq || \
  |  |  ------------------
  |  |  |  |  125|  33.8k|#define Freq fc.freq
  |  |  ------------------
  |  |  |  Branch (133:6): [True: 5.27k, False: 11.6k]
  |  |  ------------------
  |  |  134|  16.9k|    (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
  |  |  ------------------
  |  |  |  |  125|  11.6k|#define Freq fc.freq
  |  |  ------------------
  |  |                   (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
  |  |  ------------------
  |  |  |  |  125|  23.3k|#define Freq fc.freq
  |  |  ------------------
  |  |  |  Branch (134:6): [True: 3.16k, False: 8.49k]
  |  |  |  Branch (134:38): [True: 2.96k, False: 199]
  |  |  ------------------
  ------------------
  |  Branch (160:13): [True: 16.9k, False: 19.8k]
  ------------------
  161|  8.24k|            j++;
  162|  8.24k|        }
  163|       |        /* Exit if v is smaller than both sons */
  164|  36.7k|        if (smaller(tree, v, heap[j], depth))
  ------------------
  |  |  133|  36.7k|    (tree[n].Freq < tree[m].Freq || \
  |  |  ------------------
  |  |  |  |  125|  36.7k|#define Freq fc.freq
  |  |  ------------------
  |  |                   (tree[n].Freq < tree[m].Freq || \
  |  |  ------------------
  |  |  |  |  125|  73.5k|#define Freq fc.freq
  |  |  ------------------
  |  |  |  Branch (133:6): [True: 8.12k, False: 28.6k]
  |  |  ------------------
  |  |  134|  36.7k|    (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
  |  |  ------------------
  |  |  |  |  125|  28.6k|#define Freq fc.freq
  |  |  ------------------
  |  |                   (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
  |  |  ------------------
  |  |  |  |  125|  57.2k|#define Freq fc.freq
  |  |  ------------------
  |  |  |  Branch (134:6): [True: 8.21k, False: 20.4k]
  |  |  |  Branch (134:38): [True: 3.88k, False: 4.33k]
  |  |  ------------------
  ------------------
  165|  12.0k|            break;
  166|       |
  167|       |        /* Exchange v with the smallest son */
  168|  24.7k|        heap[k] = heap[j];
  169|  24.7k|        k = j;
  170|       |
  171|       |        /* And continue down the tree, setting j to the left son of k */
  172|  24.7k|        j <<= 1;
  173|  24.7k|    }
  174|  53.8k|    heap[k] = v;
  175|  53.8k|}
trees.c:gen_bitlen:
  282|  9.48k|static void gen_bitlen(deflate_state *s, tree_desc *desc) {
  283|       |    /* desc: the tree descriptor */
  284|  9.48k|    ct_data *tree           = desc->dyn_tree;
  285|  9.48k|    int max_code            = desc->max_code;
  286|  9.48k|    const ct_data *stree    = desc->stat_desc->static_tree;
  287|  9.48k|    const int *extra        = desc->stat_desc->extra_bits;
  288|  9.48k|    int base                = desc->stat_desc->extra_base;
  289|  9.48k|    unsigned int max_length = desc->stat_desc->max_length;
  290|  9.48k|    int h;              /* heap index */
  291|  9.48k|    int n, m;           /* iterate over the tree elements */
  292|  9.48k|    unsigned int bits;  /* bit length */
  293|  9.48k|    int xbits;          /* extra bits */
  294|  9.48k|    uint16_t f;         /* frequency */
  295|  9.48k|    int overflow = 0;   /* number of elements with bit length too large */
  296|       |
  297|   161k|    for (bits = 0; bits <= MAX_BITS; bits++)
  ------------------
  |  |   41|   161k|#define MAX_BITS 15
  ------------------
  |  Branch (297:20): [True: 151k, False: 9.48k]
  ------------------
  298|   151k|        s->bl_count[bits] = 0;
  299|       |
  300|       |    /* In a first pass, compute the optimal bit lengths (which may
  301|       |     * overflow in the case of the bit length tree).
  302|       |     */
  303|  9.48k|    tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */
  ------------------
  |  |  128|  9.48k|#define Len  dl.len
  ------------------
  304|       |
  305|  50.1k|    for (h = s->heap_max + 1; h < HEAP_SIZE; h++) {
  ------------------
  |  |   57|  50.1k|#define HEAP_SIZE (2*L_CODES+1)
  |  |  ------------------
  |  |  |  |   48|  50.1k|#define L_CODES (LITERALS+1+LENGTH_CODES)
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  50.1k|#define LITERALS  256
  |  |  |  |  ------------------
  |  |  |  |               #define L_CODES (LITERALS+1+LENGTH_CODES)
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|  50.1k|#define LENGTH_CODES 29
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (305:31): [True: 40.6k, False: 9.48k]
  ------------------
  306|  40.6k|        n = s->heap[h];
  307|  40.6k|        bits = tree[tree[n].Dad].Len + 1u;
  ------------------
  |  |  127|  40.6k|#define Dad  dl.dad
  ------------------
                      bits = tree[tree[n].Dad].Len + 1u;
  ------------------
  |  |  128|  40.6k|#define Len  dl.len
  ------------------
  308|  40.6k|        if (bits > max_length){
  ------------------
  |  Branch (308:13): [True: 0, False: 40.6k]
  ------------------
  309|      0|            bits = max_length;
  310|      0|            overflow++;
  311|      0|        }
  312|  40.6k|        tree[n].Len = (uint16_t)bits;
  ------------------
  |  |  128|  40.6k|#define Len  dl.len
  ------------------
  313|       |        /* We overwrite tree[n].Dad which is no longer needed */
  314|       |
  315|  40.6k|        if (n > max_code) /* not a leaf node */
  ------------------
  |  Branch (315:13): [True: 10.8k, False: 29.8k]
  ------------------
  316|  10.8k|            continue;
  317|       |
  318|  29.8k|        s->bl_count[bits]++;
  319|  29.8k|        xbits = 0;
  320|  29.8k|        if (n >= base)
  ------------------
  |  Branch (320:13): [True: 24.8k, False: 4.92k]
  ------------------
  321|  24.8k|            xbits = extra[n-base];
  322|  29.8k|        f = tree[n].Freq;
  ------------------
  |  |  125|  29.8k|#define Freq fc.freq
  ------------------
  323|  29.8k|        s->opt_len += (unsigned int)f * (unsigned int)(bits + xbits);
  324|  29.8k|        if (stree)
  ------------------
  |  Branch (324:13): [True: 17.1k, False: 12.6k]
  ------------------
  325|  17.1k|            s->static_len += (unsigned int)f * (unsigned int)(stree[n].Len + xbits);
  ------------------
  |  |  128|  17.1k|#define Len  dl.len
  ------------------
  326|  29.8k|    }
  327|  9.48k|    if (overflow == 0)
  ------------------
  |  Branch (327:9): [True: 9.48k, False: 0]
  ------------------
  328|  9.48k|        return;
  329|       |
  330|      0|    Tracev((stderr, "\nbit length overflow\n"));
  331|       |    /* This happens for example on obj2 and pic of the Calgary corpus */
  332|       |
  333|       |    /* Find the first bit length which could increase: */
  334|      0|    do {
  335|      0|        bits = max_length - 1;
  336|      0|        while (s->bl_count[bits] == 0)
  ------------------
  |  Branch (336:16): [True: 0, False: 0]
  ------------------
  337|      0|            bits--;
  338|      0|        s->bl_count[bits]--;       /* move one leaf down the tree */
  339|      0|        s->bl_count[bits+1] += 2u; /* move one overflow item as its brother */
  340|      0|        s->bl_count[max_length]--;
  341|       |        /* The brother of the overflow item also moves one step up,
  342|       |         * but this does not affect bl_count[max_length]
  343|       |         */
  344|      0|        overflow -= 2;
  345|      0|    } while (overflow > 0);
  ------------------
  |  Branch (345:14): [True: 0, False: 0]
  ------------------
  346|       |
  347|       |    /* Now recompute all bit lengths, scanning in increasing frequency.
  348|       |     * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
  349|       |     * lengths instead of fixing only the wrong ones. This idea is taken
  350|       |     * from 'ar' written by Haruhiko Okumura.)
  351|       |     */
  352|      0|    for (bits = max_length; bits != 0; bits--) {
  ------------------
  |  Branch (352:29): [True: 0, False: 0]
  ------------------
  353|      0|        n = s->bl_count[bits];
  354|      0|        while (n != 0) {
  ------------------
  |  Branch (354:16): [True: 0, False: 0]
  ------------------
  355|      0|            m = s->heap[--h];
  356|      0|            if (m > max_code)
  ------------------
  |  Branch (356:17): [True: 0, False: 0]
  ------------------
  357|      0|                continue;
  358|      0|            if (tree[m].Len != bits) {
  ------------------
  |  |  128|      0|#define Len  dl.len
  ------------------
  |  Branch (358:17): [True: 0, False: 0]
  ------------------
  359|      0|                Tracev((stderr, "code %d bits %d->%u\n", m, tree[m].Len, bits));
  360|      0|                s->opt_len += (unsigned int)(bits * tree[m].Freq);
  ------------------
  |  |  125|      0|#define Freq fc.freq
  ------------------
  361|      0|                s->opt_len -= (unsigned int)(tree[m].Len * tree[m].Freq);
  ------------------
  |  |  128|      0|#define Len  dl.len
  ------------------
                              s->opt_len -= (unsigned int)(tree[m].Len * tree[m].Freq);
  ------------------
  |  |  125|      0|#define Freq fc.freq
  ------------------
  362|      0|                tree[m].Len = (uint16_t)bits;
  ------------------
  |  |  128|      0|#define Len  dl.len
  ------------------
  363|      0|            }
  364|      0|            n--;
  365|      0|        }
  366|      0|    }
  367|      0|}
trees.c:build_bl_tree:
  529|  3.16k|static int build_bl_tree(deflate_state *s) {
  530|  3.16k|    int max_blindex;  /* index of last bit length code of non zero freq */
  531|       |
  532|       |    /* Determine the bit length frequencies for literal and distance trees */
  533|  3.16k|    scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code);
  534|  3.16k|    scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code);
  535|       |
  536|       |    /* Build the bit length tree: */
  537|  3.16k|    build_tree(s, (tree_desc *)(&(s->bl_desc)));
  538|       |    /* opt_len now includes the length of the tree representations, except
  539|       |     * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
  540|       |     */
  541|       |
  542|       |    /* Determine the number of bit length codes to send. The pkzip format
  543|       |     * requires that at least 4 bit length codes be sent. (appnote.txt says
  544|       |     * 3 but the actual value used is 4.)
  545|       |     */
  546|  6.32k|    for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {
  ------------------
  |  |   54|  3.16k|#define BL_CODES  19
  ------------------
  |  Branch (546:36): [True: 6.32k, False: 0]
  ------------------
  547|  6.32k|        if (s->bl_tree[bl_order[max_blindex]].Len != 0)
  ------------------
  |  |  128|  6.32k|#define Len  dl.len
  ------------------
  |  Branch (547:13): [True: 3.16k, False: 3.16k]
  ------------------
  548|  3.16k|            break;
  549|  6.32k|    }
  550|       |    /* Update opt_len to include the bit length tree and counts */
  551|  3.16k|    s->opt_len += 3*((unsigned int)max_blindex+1) + 5+5+4;
  552|  3.16k|    Tracev((stderr, "\ndyn trees: dyn %u, stat %u", s->opt_len, s->static_len));
  553|       |
  554|  3.16k|    return max_blindex;
  555|  3.16k|}
trees.c:scan_tree:
  415|  6.32k|static void scan_tree(deflate_state *s, ct_data *tree, int max_code) {
  416|       |    /* tree: the tree to be scanned */
  417|       |    /* max_code: and its largest code of non zero frequency */
  418|  6.32k|    int n;                     /* iterates over all tree elements */
  419|  6.32k|    int prevlen = -1;          /* last emitted length */
  420|  6.32k|    int curlen;                /* length of current code */
  421|  6.32k|    int nextlen = tree[0].Len; /* length of next code */
  ------------------
  |  |  128|  6.32k|#define Len  dl.len
  ------------------
  422|  6.32k|    uint16_t count = 0;        /* repeat count of the current code */
  423|  6.32k|    uint16_t max_count = 7;    /* max repeat count */
  424|  6.32k|    uint16_t min_count = 4;    /* min repeat count */
  425|       |
  426|  6.32k|    if (nextlen == 0)
  ------------------
  |  Branch (426:9): [True: 1.39k, False: 4.92k]
  ------------------
  427|  1.39k|        max_count = 138, min_count = 3;
  428|       |
  429|  6.32k|    tree[max_code+1].Len = (uint16_t)0xffff; /* guard */
  ------------------
  |  |  128|  6.32k|#define Len  dl.len
  ------------------
  430|       |
  431|   937k|    for (n = 0; n <= max_code; n++) {
  ------------------
  |  Branch (431:17): [True: 930k, False: 6.32k]
  ------------------
  432|   930k|        curlen = nextlen;
  433|   930k|        nextlen = tree[n+1].Len;
  ------------------
  |  |  128|   930k|#define Len  dl.len
  ------------------
  434|   930k|        if (++count < max_count && curlen == nextlen) {
  ------------------
  |  Branch (434:13): [True: 927k, False: 3.16k]
  |  Branch (434:36): [True: 902k, False: 25.4k]
  ------------------
  435|   902k|            continue;
  436|   902k|        } else if (count < min_count) {
  ------------------
  |  Branch (436:20): [True: 15.9k, False: 12.6k]
  ------------------
  437|  15.9k|            s->bl_tree[curlen].Freq += count;
  ------------------
  |  |  125|  15.9k|#define Freq fc.freq
  ------------------
  438|  15.9k|        } else if (curlen != 0) {
  ------------------
  |  Branch (438:20): [True: 0, False: 12.6k]
  ------------------
  439|      0|            if (curlen != prevlen)
  ------------------
  |  Branch (439:17): [True: 0, False: 0]
  ------------------
  440|      0|                s->bl_tree[curlen].Freq++;
  ------------------
  |  |  125|      0|#define Freq fc.freq
  ------------------
  441|      0|            s->bl_tree[REP_3_6].Freq++;
  ------------------
  |  |   12|      0|#define REP_3_6      16
  ------------------
                          s->bl_tree[REP_3_6].Freq++;
  ------------------
  |  |  125|      0|#define Freq fc.freq
  ------------------
  442|  12.6k|        } else if (count <= 10) {
  ------------------
  |  Branch (442:20): [True: 1.33k, False: 11.2k]
  ------------------
  443|  1.33k|            s->bl_tree[REPZ_3_10].Freq++;
  ------------------
  |  |   15|  1.33k|#define REPZ_3_10    17
  ------------------
                          s->bl_tree[REPZ_3_10].Freq++;
  ------------------
  |  |  125|  1.33k|#define Freq fc.freq
  ------------------
  444|  11.2k|        } else {
  445|  11.2k|            s->bl_tree[REPZ_11_138].Freq++;
  ------------------
  |  |   18|  11.2k|#define REPZ_11_138  18
  ------------------
                          s->bl_tree[REPZ_11_138].Freq++;
  ------------------
  |  |  125|  11.2k|#define Freq fc.freq
  ------------------
  446|  11.2k|        }
  447|  28.5k|        count = 0;
  448|  28.5k|        prevlen = curlen;
  449|  28.5k|        if (nextlen == 0) {
  ------------------
  |  Branch (449:13): [True: 11.8k, False: 16.7k]
  ------------------
  450|  11.8k|            max_count = 138, min_count = 3;
  451|  16.7k|        } else if (curlen == nextlen) {
  ------------------
  |  Branch (451:20): [True: 0, False: 16.7k]
  ------------------
  452|      0|            max_count = 6, min_count = 3;
  453|  16.7k|        } else {
  454|  16.7k|            max_count = 7, min_count = 4;
  455|  16.7k|        }
  456|  28.5k|    }
  457|  6.32k|}
trees.c:send_all_trees:
  562|  2.54k|static void send_all_trees(deflate_state *s, int lcodes, int dcodes, int blcodes) {
  563|  2.54k|    int rank;                    /* index in bl_order */
  564|       |
  565|  2.54k|    Assert(lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
  566|  2.54k|    Assert(lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, "too many codes");
  567|       |
  568|       |    // Temp local variables
  569|  2.54k|    uint32_t bi_valid = s->bi_valid;
  570|  2.54k|    uint64_t bi_buf = s->bi_buf;
  571|       |
  572|  2.54k|    Tracev((stderr, "\nbl counts: "));
  573|  2.54k|    send_bits(s, lcodes-257, 5, bi_buf, bi_valid); /* not +255 as stated in appnote.txt */
  ------------------
  |  |   43|  2.54k|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) do {\
  |  |   44|  2.54k|    Assert(bi_valid <= 64, "Too many bits in bi_valid");\
  |  |   45|  2.54k|    uint64_t val = (uint64_t)t_val;\
  |  |   46|  2.54k|    uint32_t len = (uint32_t)t_len;\
  |  |   47|  2.54k|    uint32_t total_bits = bi_valid + len;\
  |  |   48|  2.54k|    trace_bits(s, val, len);\
  |  |   49|  2.54k|    sent_bits_add(s, len);\
  |  |  ------------------
  |  |  |  |  451|  2.54k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  2.54k|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   50|  2.54k|    \
  |  |   51|  2.54k|    /* Unconditionally shift and merge values into the buffer */\
  |  |   52|  2.54k|    bi_buf |= val << bi_valid;\
  |  |   53|  2.54k|    \
  |  |   54|  2.54k|    /* Check if the 64-bit boundary was crossed */\
  |  |   55|  2.54k|    if (total_bits >= 64) {\
  |  |  ------------------
  |  |  |  Branch (55:9): [True: 0, False: 2.54k]
  |  |  ------------------
  |  |   56|      0|        total_bits -= 64;\
  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |   58|      0|        \
  |  |   59|      0|        /* Secure shift: prevent Undefined Behavior when bi_valid is 0 */\
  |  |   60|      0|        /* If bi_valid is 0, we shift by 0 (via the mask) and overwrite bi_buf completely */\
  |  |   61|      0|        bi_buf = (val >> 1) >> (~bi_valid & 63);\
  |  |   62|      0|    }\
  |  |   63|  2.54k|    bi_valid = total_bits;\
  |  |   64|  2.54k|} while (0)
  |  |  ------------------
  |  |  |  Branch (64:10): [Folded, False: 2.54k]
  |  |  ------------------
  ------------------
  574|  2.54k|    send_bits(s, dcodes-1,   5, bi_buf, bi_valid);
  ------------------
  |  |   43|  2.54k|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) do {\
  |  |   44|  2.54k|    Assert(bi_valid <= 64, "Too many bits in bi_valid");\
  |  |   45|  2.54k|    uint64_t val = (uint64_t)t_val;\
  |  |   46|  2.54k|    uint32_t len = (uint32_t)t_len;\
  |  |   47|  2.54k|    uint32_t total_bits = bi_valid + len;\
  |  |   48|  2.54k|    trace_bits(s, val, len);\
  |  |   49|  2.54k|    sent_bits_add(s, len);\
  |  |  ------------------
  |  |  |  |  451|  2.54k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  2.54k|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   50|  2.54k|    \
  |  |   51|  2.54k|    /* Unconditionally shift and merge values into the buffer */\
  |  |   52|  2.54k|    bi_buf |= val << bi_valid;\
  |  |   53|  2.54k|    \
  |  |   54|  2.54k|    /* Check if the 64-bit boundary was crossed */\
  |  |   55|  2.54k|    if (total_bits >= 64) {\
  |  |  ------------------
  |  |  |  Branch (55:9): [True: 0, False: 2.54k]
  |  |  ------------------
  |  |   56|      0|        total_bits -= 64;\
  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |   58|      0|        \
  |  |   59|      0|        /* Secure shift: prevent Undefined Behavior when bi_valid is 0 */\
  |  |   60|      0|        /* If bi_valid is 0, we shift by 0 (via the mask) and overwrite bi_buf completely */\
  |  |   61|      0|        bi_buf = (val >> 1) >> (~bi_valid & 63);\
  |  |   62|      0|    }\
  |  |   63|  2.54k|    bi_valid = total_bits;\
  |  |   64|  2.54k|} while (0)
  |  |  ------------------
  |  |  |  Branch (64:10): [Folded, False: 2.54k]
  |  |  ------------------
  ------------------
  575|  2.54k|    send_bits(s, blcodes-4,  4, bi_buf, bi_valid); /* not -3 as stated in appnote.txt */
  ------------------
  |  |   43|  2.54k|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) do {\
  |  |   44|  2.54k|    Assert(bi_valid <= 64, "Too many bits in bi_valid");\
  |  |   45|  2.54k|    uint64_t val = (uint64_t)t_val;\
  |  |   46|  2.54k|    uint32_t len = (uint32_t)t_len;\
  |  |   47|  2.54k|    uint32_t total_bits = bi_valid + len;\
  |  |   48|  2.54k|    trace_bits(s, val, len);\
  |  |   49|  2.54k|    sent_bits_add(s, len);\
  |  |  ------------------
  |  |  |  |  451|  2.54k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  2.54k|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   50|  2.54k|    \
  |  |   51|  2.54k|    /* Unconditionally shift and merge values into the buffer */\
  |  |   52|  2.54k|    bi_buf |= val << bi_valid;\
  |  |   53|  2.54k|    \
  |  |   54|  2.54k|    /* Check if the 64-bit boundary was crossed */\
  |  |   55|  2.54k|    if (total_bits >= 64) {\
  |  |  ------------------
  |  |  |  Branch (55:9): [True: 0, False: 2.54k]
  |  |  ------------------
  |  |   56|      0|        total_bits -= 64;\
  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |   58|      0|        \
  |  |   59|      0|        /* Secure shift: prevent Undefined Behavior when bi_valid is 0 */\
  |  |   60|      0|        /* If bi_valid is 0, we shift by 0 (via the mask) and overwrite bi_buf completely */\
  |  |   61|      0|        bi_buf = (val >> 1) >> (~bi_valid & 63);\
  |  |   62|      0|    }\
  |  |   63|  2.54k|    bi_valid = total_bits;\
  |  |   64|  2.54k|} while (0)
  |  |  ------------------
  |  |  |  Branch (64:10): [Folded, False: 2.54k]
  |  |  ------------------
  ------------------
  576|  48.2k|    for (rank = 0; rank < blcodes; rank++) {
  ------------------
  |  Branch (576:20): [True: 45.7k, False: 2.54k]
  ------------------
  577|  45.7k|        Tracev((stderr, "\nbl code %2u ", bl_order[rank]));
  578|  45.7k|        send_bits(s, s->bl_tree[bl_order[rank]].Len, 3, bi_buf, bi_valid);
  ------------------
  |  |   43|  45.7k|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) do {\
  |  |   44|  45.7k|    Assert(bi_valid <= 64, "Too many bits in bi_valid");\
  |  |   45|  45.7k|    uint64_t val = (uint64_t)t_val;\
  |  |   46|  45.7k|    uint32_t len = (uint32_t)t_len;\
  |  |   47|  45.7k|    uint32_t total_bits = bi_valid + len;\
  |  |   48|  45.7k|    trace_bits(s, val, len);\
  |  |   49|  45.7k|    sent_bits_add(s, len);\
  |  |  ------------------
  |  |  |  |  451|  45.7k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  45.7k|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   50|  45.7k|    \
  |  |   51|  45.7k|    /* Unconditionally shift and merge values into the buffer */\
  |  |   52|  45.7k|    bi_buf |= val << bi_valid;\
  |  |   53|  45.7k|    \
  |  |   54|  45.7k|    /* Check if the 64-bit boundary was crossed */\
  |  |   55|  45.7k|    if (total_bits >= 64) {\
  |  |  ------------------
  |  |  |  Branch (55:9): [True: 2.54k, False: 43.1k]
  |  |  ------------------
  |  |   56|  2.54k|        total_bits -= 64;\
  |  |   57|  2.54k|        put_uint64(s, bi_buf);\
  |  |   58|  2.54k|        \
  |  |   59|  2.54k|        /* Secure shift: prevent Undefined Behavior when bi_valid is 0 */\
  |  |   60|  2.54k|        /* If bi_valid is 0, we shift by 0 (via the mask) and overwrite bi_buf completely */\
  |  |   61|  2.54k|        bi_buf = (val >> 1) >> (~bi_valid & 63);\
  |  |   62|  2.54k|    }\
  |  |   63|  45.7k|    bi_valid = total_bits;\
  |  |   64|  45.7k|} while (0)
  |  |  ------------------
  |  |  |  Branch (64:10): [Folded, False: 45.7k]
  |  |  ------------------
  ------------------
  579|  45.7k|    }
  580|  2.54k|    Tracev((stderr, "\nbl tree: sent %lu", s->bits_sent));
  581|       |
  582|       |    // Store back temp variables
  583|  2.54k|    s->bi_buf = bi_buf;
  584|  2.54k|    s->bi_valid = bi_valid;
  585|       |
  586|  2.54k|    send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */
  587|  2.54k|    Tracev((stderr, "\nlit tree: sent %lu", s->bits_sent));
  588|       |
  589|  2.54k|    send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */
  590|  2.54k|    Tracev((stderr, "\ndist tree: sent %lu", s->bits_sent));
  591|  2.54k|}
trees.c:send_tree:
  463|  5.08k|static void send_tree(deflate_state *s, ct_data *tree, int max_code) {
  464|       |    /* tree: the tree to be scanned */
  465|       |    /* max_code and its largest code of non zero frequency */
  466|  5.08k|    int n;                     /* iterates over all tree elements */
  467|  5.08k|    int prevlen = -1;          /* last emitted length */
  468|  5.08k|    int curlen;                /* length of current code */
  469|  5.08k|    int nextlen = tree[0].Len; /* length of next code */
  ------------------
  |  |  128|  5.08k|#define Len  dl.len
  ------------------
  470|  5.08k|    int count = 0;             /* repeat count of the current code */
  471|  5.08k|    int max_count = 7;         /* max repeat count */
  472|  5.08k|    int min_count = 4;         /* min repeat count */
  473|       |
  474|       |    /* tree[max_code+1].Len = -1; */  /* guard already set */
  475|  5.08k|    if (nextlen == 0)
  ------------------
  |  Branch (475:9): [True: 1.08k, False: 3.99k]
  ------------------
  476|  1.08k|        max_count = 138, min_count = 3;
  477|       |
  478|       |    // Temp local variables
  479|  5.08k|    uint32_t bi_valid = s->bi_valid;
  480|  5.08k|    uint64_t bi_buf = s->bi_buf;
  481|       |
  482|   755k|    for (n = 0; n <= max_code; n++) {
  ------------------
  |  Branch (482:17): [True: 750k, False: 5.08k]
  ------------------
  483|   750k|        curlen = nextlen;
  484|   750k|        nextlen = tree[n+1].Len;
  ------------------
  |  |  128|   750k|#define Len  dl.len
  ------------------
  485|   750k|        if (++count < max_count && curlen == nextlen) {
  ------------------
  |  Branch (485:13): [True: 747k, False: 2.54k]
  |  Branch (485:36): [True: 727k, False: 20.8k]
  ------------------
  486|   727k|            continue;
  487|   727k|        } else if (count < min_count) {
  ------------------
  |  Branch (487:20): [True: 13.0k, False: 10.3k]
  ------------------
  488|  14.6k|            do {
  489|  14.6k|                send_code(s, curlen, s->bl_tree, bi_buf, bi_valid);
  ------------------
  |  |   74|  14.6k|    send_bits(s, tree[c].Code, tree[c].Len, bi_buf, bi_valid)
  |  |  ------------------
  |  |  |  |   43|  14.6k|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) do {\
  |  |  |  |   44|  14.6k|    Assert(bi_valid <= 64, "Too many bits in bi_valid");\
  |  |  |  |   45|  14.6k|    uint64_t val = (uint64_t)t_val;\
  |  |  |  |   46|  14.6k|    uint32_t len = (uint32_t)t_len;\
  |  |  |  |   47|  14.6k|    uint32_t total_bits = bi_valid + len;\
  |  |  |  |   48|  14.6k|    trace_bits(s, val, len);\
  |  |  |  |   49|  14.6k|    sent_bits_add(s, len);\
  |  |  |  |  ------------------
  |  |  |  |  |  |  451|  14.6k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  154|  14.6k|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   50|  14.6k|    \
  |  |  |  |   51|  14.6k|    /* Unconditionally shift and merge values into the buffer */\
  |  |  |  |   52|  14.6k|    bi_buf |= val << bi_valid;\
  |  |  |  |   53|  14.6k|    \
  |  |  |  |   54|  14.6k|    /* Check if the 64-bit boundary was crossed */\
  |  |  |  |   55|  14.6k|    if (total_bits >= 64) {\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (55:9): [True: 0, False: 14.6k]
  |  |  |  |  ------------------
  |  |  |  |   56|      0|        total_bits -= 64;\
  |  |  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |  |  |   58|      0|        \
  |  |  |  |   59|      0|        /* Secure shift: prevent Undefined Behavior when bi_valid is 0 */\
  |  |  |  |   60|      0|        /* If bi_valid is 0, we shift by 0 (via the mask) and overwrite bi_buf completely */\
  |  |  |  |   61|      0|        bi_buf = (val >> 1) >> (~bi_valid & 63);\
  |  |  |  |   62|      0|    }\
  |  |  |  |   63|  14.6k|    bi_valid = total_bits;\
  |  |  |  |   64|  14.6k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (64:10): [Folded, False: 14.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  490|  14.6k|            } while (--count != 0);
  ------------------
  |  Branch (490:22): [True: 1.59k, False: 13.0k]
  ------------------
  491|       |
  492|  13.0k|        } else if (curlen != 0) {
  ------------------
  |  Branch (492:20): [True: 0, False: 10.3k]
  ------------------
  493|      0|            if (curlen != prevlen) {
  ------------------
  |  Branch (493:17): [True: 0, False: 0]
  ------------------
  494|      0|                send_code(s, curlen, s->bl_tree, bi_buf, bi_valid);
  ------------------
  |  |   74|      0|    send_bits(s, tree[c].Code, tree[c].Len, bi_buf, bi_valid)
  |  |  ------------------
  |  |  |  |   43|      0|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) do {\
  |  |  |  |   44|      0|    Assert(bi_valid <= 64, "Too many bits in bi_valid");\
  |  |  |  |   45|      0|    uint64_t val = (uint64_t)t_val;\
  |  |  |  |   46|      0|    uint32_t len = (uint32_t)t_len;\
  |  |  |  |   47|      0|    uint32_t total_bits = bi_valid + len;\
  |  |  |  |   48|      0|    trace_bits(s, val, len);\
  |  |  |  |   49|      0|    sent_bits_add(s, len);\
  |  |  |  |  ------------------
  |  |  |  |  |  |  451|      0|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  154|      0|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   50|      0|    \
  |  |  |  |   51|      0|    /* Unconditionally shift and merge values into the buffer */\
  |  |  |  |   52|      0|    bi_buf |= val << bi_valid;\
  |  |  |  |   53|      0|    \
  |  |  |  |   54|      0|    /* Check if the 64-bit boundary was crossed */\
  |  |  |  |   55|      0|    if (total_bits >= 64) {\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (55:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   56|      0|        total_bits -= 64;\
  |  |  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |  |  |   58|      0|        \
  |  |  |  |   59|      0|        /* Secure shift: prevent Undefined Behavior when bi_valid is 0 */\
  |  |  |  |   60|      0|        /* If bi_valid is 0, we shift by 0 (via the mask) and overwrite bi_buf completely */\
  |  |  |  |   61|      0|        bi_buf = (val >> 1) >> (~bi_valid & 63);\
  |  |  |  |   62|      0|    }\
  |  |  |  |   63|      0|    bi_valid = total_bits;\
  |  |  |  |   64|      0|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (64:10): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  495|      0|                count--;
  496|      0|            }
  497|      0|            Assert(count >= 3 && count <= 6, " 3_6?");
  498|      0|            send_code(s, REP_3_6, s->bl_tree, bi_buf, bi_valid);
  ------------------
  |  |   74|      0|    send_bits(s, tree[c].Code, tree[c].Len, bi_buf, bi_valid)
  |  |  ------------------
  |  |  |  |   43|      0|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) do {\
  |  |  |  |   44|      0|    Assert(bi_valid <= 64, "Too many bits in bi_valid");\
  |  |  |  |   45|      0|    uint64_t val = (uint64_t)t_val;\
  |  |  |  |   46|      0|    uint32_t len = (uint32_t)t_len;\
  |  |  |  |   47|      0|    uint32_t total_bits = bi_valid + len;\
  |  |  |  |   48|      0|    trace_bits(s, val, len);\
  |  |  |  |   49|      0|    sent_bits_add(s, len);\
  |  |  |  |  ------------------
  |  |  |  |  |  |  451|      0|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  154|      0|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   50|      0|    \
  |  |  |  |   51|      0|    /* Unconditionally shift and merge values into the buffer */\
  |  |  |  |   52|      0|    bi_buf |= val << bi_valid;\
  |  |  |  |   53|      0|    \
  |  |  |  |   54|      0|    /* Check if the 64-bit boundary was crossed */\
  |  |  |  |   55|      0|    if (total_bits >= 64) {\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (55:9): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   56|      0|        total_bits -= 64;\
  |  |  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |  |  |   58|      0|        \
  |  |  |  |   59|      0|        /* Secure shift: prevent Undefined Behavior when bi_valid is 0 */\
  |  |  |  |   60|      0|        /* If bi_valid is 0, we shift by 0 (via the mask) and overwrite bi_buf completely */\
  |  |  |  |   61|      0|        bi_buf = (val >> 1) >> (~bi_valid & 63);\
  |  |  |  |   62|      0|    }\
  |  |  |  |   63|      0|    bi_valid = total_bits;\
  |  |  |  |   64|      0|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (64:10): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  499|      0|            send_bits(s, count-3, 2, bi_buf, bi_valid);
  ------------------
  |  |   43|      0|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) do {\
  |  |   44|      0|    Assert(bi_valid <= 64, "Too many bits in bi_valid");\
  |  |   45|      0|    uint64_t val = (uint64_t)t_val;\
  |  |   46|      0|    uint32_t len = (uint32_t)t_len;\
  |  |   47|      0|    uint32_t total_bits = bi_valid + len;\
  |  |   48|      0|    trace_bits(s, val, len);\
  |  |   49|      0|    sent_bits_add(s, len);\
  |  |  ------------------
  |  |  |  |  451|      0|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   50|      0|    \
  |  |   51|      0|    /* Unconditionally shift and merge values into the buffer */\
  |  |   52|      0|    bi_buf |= val << bi_valid;\
  |  |   53|      0|    \
  |  |   54|      0|    /* Check if the 64-bit boundary was crossed */\
  |  |   55|      0|    if (total_bits >= 64) {\
  |  |  ------------------
  |  |  |  Branch (55:9): [True: 0, False: 0]
  |  |  ------------------
  |  |   56|      0|        total_bits -= 64;\
  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |   58|      0|        \
  |  |   59|      0|        /* Secure shift: prevent Undefined Behavior when bi_valid is 0 */\
  |  |   60|      0|        /* If bi_valid is 0, we shift by 0 (via the mask) and overwrite bi_buf completely */\
  |  |   61|      0|        bi_buf = (val >> 1) >> (~bi_valid & 63);\
  |  |   62|      0|    }\
  |  |   63|      0|    bi_valid = total_bits;\
  |  |   64|      0|} while (0)
  |  |  ------------------
  |  |  |  Branch (64:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  500|       |
  501|  10.3k|        } else if (count <= 10) {
  ------------------
  |  Branch (501:20): [True: 1.11k, False: 9.18k]
  ------------------
  502|  1.11k|            send_code(s, REPZ_3_10, s->bl_tree, bi_buf, bi_valid);
  ------------------
  |  |   74|  1.11k|    send_bits(s, tree[c].Code, tree[c].Len, bi_buf, bi_valid)
  |  |  ------------------
  |  |  |  |   43|  1.11k|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) do {\
  |  |  |  |   44|  1.11k|    Assert(bi_valid <= 64, "Too many bits in bi_valid");\
  |  |  |  |   45|  1.11k|    uint64_t val = (uint64_t)t_val;\
  |  |  |  |   46|  1.11k|    uint32_t len = (uint32_t)t_len;\
  |  |  |  |   47|  1.11k|    uint32_t total_bits = bi_valid + len;\
  |  |  |  |   48|  1.11k|    trace_bits(s, val, len);\
  |  |  |  |   49|  1.11k|    sent_bits_add(s, len);\
  |  |  |  |  ------------------
  |  |  |  |  |  |  451|  1.11k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  154|  1.11k|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   50|  1.11k|    \
  |  |  |  |   51|  1.11k|    /* Unconditionally shift and merge values into the buffer */\
  |  |  |  |   52|  1.11k|    bi_buf |= val << bi_valid;\
  |  |  |  |   53|  1.11k|    \
  |  |  |  |   54|  1.11k|    /* Check if the 64-bit boundary was crossed */\
  |  |  |  |   55|  1.11k|    if (total_bits >= 64) {\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (55:9): [True: 0, False: 1.11k]
  |  |  |  |  ------------------
  |  |  |  |   56|      0|        total_bits -= 64;\
  |  |  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |  |  |   58|      0|        \
  |  |  |  |   59|      0|        /* Secure shift: prevent Undefined Behavior when bi_valid is 0 */\
  |  |  |  |   60|      0|        /* If bi_valid is 0, we shift by 0 (via the mask) and overwrite bi_buf completely */\
  |  |  |  |   61|      0|        bi_buf = (val >> 1) >> (~bi_valid & 63);\
  |  |  |  |   62|      0|    }\
  |  |  |  |   63|  1.11k|    bi_valid = total_bits;\
  |  |  |  |   64|  1.11k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (64:10): [Folded, False: 1.11k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  503|  1.11k|            send_bits(s, count-3, 3, bi_buf, bi_valid);
  ------------------
  |  |   43|  1.11k|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) do {\
  |  |   44|  1.11k|    Assert(bi_valid <= 64, "Too many bits in bi_valid");\
  |  |   45|  1.11k|    uint64_t val = (uint64_t)t_val;\
  |  |   46|  1.11k|    uint32_t len = (uint32_t)t_len;\
  |  |   47|  1.11k|    uint32_t total_bits = bi_valid + len;\
  |  |   48|  1.11k|    trace_bits(s, val, len);\
  |  |   49|  1.11k|    sent_bits_add(s, len);\
  |  |  ------------------
  |  |  |  |  451|  1.11k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  1.11k|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   50|  1.11k|    \
  |  |   51|  1.11k|    /* Unconditionally shift and merge values into the buffer */\
  |  |   52|  1.11k|    bi_buf |= val << bi_valid;\
  |  |   53|  1.11k|    \
  |  |   54|  1.11k|    /* Check if the 64-bit boundary was crossed */\
  |  |   55|  1.11k|    if (total_bits >= 64) {\
  |  |  ------------------
  |  |  |  Branch (55:9): [True: 0, False: 1.11k]
  |  |  ------------------
  |  |   56|      0|        total_bits -= 64;\
  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |   58|      0|        \
  |  |   59|      0|        /* Secure shift: prevent Undefined Behavior when bi_valid is 0 */\
  |  |   60|      0|        /* If bi_valid is 0, we shift by 0 (via the mask) and overwrite bi_buf completely */\
  |  |   61|      0|        bi_buf = (val >> 1) >> (~bi_valid & 63);\
  |  |   62|      0|    }\
  |  |   63|  1.11k|    bi_valid = total_bits;\
  |  |   64|  1.11k|} while (0)
  |  |  ------------------
  |  |  |  Branch (64:10): [Folded, False: 1.11k]
  |  |  ------------------
  ------------------
  504|       |
  505|  9.18k|        } else {
  506|  9.18k|            send_code(s, REPZ_11_138, s->bl_tree, bi_buf, bi_valid);
  ------------------
  |  |   74|  9.18k|    send_bits(s, tree[c].Code, tree[c].Len, bi_buf, bi_valid)
  |  |  ------------------
  |  |  |  |   43|  9.18k|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) do {\
  |  |  |  |   44|  9.18k|    Assert(bi_valid <= 64, "Too many bits in bi_valid");\
  |  |  |  |   45|  9.18k|    uint64_t val = (uint64_t)t_val;\
  |  |  |  |   46|  9.18k|    uint32_t len = (uint32_t)t_len;\
  |  |  |  |   47|  9.18k|    uint32_t total_bits = bi_valid + len;\
  |  |  |  |   48|  9.18k|    trace_bits(s, val, len);\
  |  |  |  |   49|  9.18k|    sent_bits_add(s, len);\
  |  |  |  |  ------------------
  |  |  |  |  |  |  451|  9.18k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  154|  9.18k|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   50|  9.18k|    \
  |  |  |  |   51|  9.18k|    /* Unconditionally shift and merge values into the buffer */\
  |  |  |  |   52|  9.18k|    bi_buf |= val << bi_valid;\
  |  |  |  |   53|  9.18k|    \
  |  |  |  |   54|  9.18k|    /* Check if the 64-bit boundary was crossed */\
  |  |  |  |   55|  9.18k|    if (total_bits >= 64) {\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (55:9): [True: 0, False: 9.18k]
  |  |  |  |  ------------------
  |  |  |  |   56|      0|        total_bits -= 64;\
  |  |  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |  |  |   58|      0|        \
  |  |  |  |   59|      0|        /* Secure shift: prevent Undefined Behavior when bi_valid is 0 */\
  |  |  |  |   60|      0|        /* If bi_valid is 0, we shift by 0 (via the mask) and overwrite bi_buf completely */\
  |  |  |  |   61|      0|        bi_buf = (val >> 1) >> (~bi_valid & 63);\
  |  |  |  |   62|      0|    }\
  |  |  |  |   63|  9.18k|    bi_valid = total_bits;\
  |  |  |  |   64|  9.18k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (64:10): [Folded, False: 9.18k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  507|  9.18k|            send_bits(s, count-11, 7, bi_buf, bi_valid);
  ------------------
  |  |   43|  9.18k|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) do {\
  |  |   44|  9.18k|    Assert(bi_valid <= 64, "Too many bits in bi_valid");\
  |  |   45|  9.18k|    uint64_t val = (uint64_t)t_val;\
  |  |   46|  9.18k|    uint32_t len = (uint32_t)t_len;\
  |  |   47|  9.18k|    uint32_t total_bits = bi_valid + len;\
  |  |   48|  9.18k|    trace_bits(s, val, len);\
  |  |   49|  9.18k|    sent_bits_add(s, len);\
  |  |  ------------------
  |  |  |  |  451|  9.18k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  9.18k|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   50|  9.18k|    \
  |  |   51|  9.18k|    /* Unconditionally shift and merge values into the buffer */\
  |  |   52|  9.18k|    bi_buf |= val << bi_valid;\
  |  |   53|  9.18k|    \
  |  |   54|  9.18k|    /* Check if the 64-bit boundary was crossed */\
  |  |   55|  9.18k|    if (total_bits >= 64) {\
  |  |  ------------------
  |  |  |  Branch (55:9): [True: 0, False: 9.18k]
  |  |  ------------------
  |  |   56|      0|        total_bits -= 64;\
  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |   58|      0|        \
  |  |   59|      0|        /* Secure shift: prevent Undefined Behavior when bi_valid is 0 */\
  |  |   60|      0|        /* If bi_valid is 0, we shift by 0 (via the mask) and overwrite bi_buf completely */\
  |  |   61|      0|        bi_buf = (val >> 1) >> (~bi_valid & 63);\
  |  |   62|      0|    }\
  |  |   63|  9.18k|    bi_valid = total_bits;\
  |  |   64|  9.18k|} while (0)
  |  |  ------------------
  |  |  |  Branch (64:10): [Folded, False: 9.18k]
  |  |  ------------------
  ------------------
  508|  9.18k|        }
  509|  23.3k|        count = 0;
  510|  23.3k|        prevlen = curlen;
  511|  23.3k|        if (nextlen == 0) {
  ------------------
  |  Branch (511:13): [True: 9.73k, False: 13.6k]
  ------------------
  512|  9.73k|            max_count = 138, min_count = 3;
  513|  13.6k|        } else if (curlen == nextlen) {
  ------------------
  |  Branch (513:20): [True: 0, False: 13.6k]
  ------------------
  514|      0|            max_count = 6, min_count = 3;
  515|  13.6k|        } else {
  516|  13.6k|            max_count = 7, min_count = 4;
  517|  13.6k|        }
  518|  23.3k|    }
  519|       |
  520|       |    // Store back temp variables
  521|  5.08k|    s->bi_buf = bi_buf;
  522|  5.08k|    s->bi_valid = bi_valid;
  523|  5.08k|}
trees.c:compress_block:
  729|  3.16k|static void compress_block(deflate_state *s, const ct_data *ltree, const ct_data *dtree) {
  730|       |    /* ltree: literal tree */
  731|       |    /* dtree: distance tree */
  732|  3.16k|    unsigned dist;      /* distance of matched string */
  733|  3.16k|    int lc;             /* match length or unmatched char (if dist == 0) */
  734|  3.16k|    unsigned sx = 0;    /* running index in symbol buffers */
  735|       |
  736|       |    /* Local pointers to avoid indirection */
  737|  3.16k|    const unsigned int sym_next = s->sym_next;
  738|       |#ifdef LIT_MEM
  739|       |    uint16_t *d_buf = s->d_buf;
  740|       |    unsigned char *l_buf = s->l_buf;
  741|       |#else
  742|  3.16k|    unsigned char *sym_buf = s->sym_buf;
  743|  3.16k|#endif
  744|       |
  745|       |    /* Keep bi_buf and bi_valid in registers across the entire loop */
  746|  3.16k|    uint64_t bi_buf = s->bi_buf;
  747|  3.16k|    uint32_t bi_valid = s->bi_valid;
  748|       |
  749|  3.16k|    if (sym_next != 0) {
  ------------------
  |  Branch (749:9): [True: 3.16k, False: 0]
  ------------------
  750|  1.84M|        do {
  751|       |#ifdef LIT_MEM
  752|       |            dist = d_buf[sx];
  753|       |            lc = l_buf[sx++];
  754|       |#else
  755|  1.84M|#  if OPTIMAL_CMP >= 32
  756|  1.84M|            uint32_t dist_lc = Z_U32_FROM_LE(zng_memread_4(&sym_buf[sx]));
  ------------------
  |  |   87|  1.84M|#  define Z_U32_FROM_LE(x)  (x)
  ------------------
  757|  1.84M|            dist = dist_lc & 0xffff;
  758|  1.84M|            lc = (dist_lc >> 16) & 0xff;
  759|       |#  else
  760|       |            dist = sym_buf[sx] + ((unsigned)sym_buf[sx + 1] << 8);
  761|       |            lc = sym_buf[sx + 2];
  762|       |#  endif
  763|  1.84M|            sx += 3;
  764|  1.84M|#endif
  765|  1.84M|            if (dist == 0) {
  ------------------
  |  Branch (765:17): [True: 2.08k, False: 1.83M]
  ------------------
  766|  2.08k|#if !defined(LIT_MEM) && OPTIMAL_CMP >= 64
  767|       |                /* Pack up to 4 consecutive literals into a single send_bits. Their codes are
  768|       |                 * at most 15 bits each, so 4 fit inside the 64-bit bit buffer. */
  769|  2.08k|                uint64_t bits = ltree[lc].Code;
  ------------------
  |  |  126|  2.08k|#define Code fc.code
  ------------------
  770|  2.08k|                uint32_t nbits = ltree[lc].Len;
  ------------------
  |  |  128|  2.08k|#define Len  dl.len
  ------------------
  771|       |
  772|  2.08k|                if (sx + 9 <= sym_next) {
  ------------------
  |  Branch (772:21): [True: 1.67k, False: 414]
  ------------------
  773|  1.67k|                    uint64_t v = Z_U64_FROM_LE(zng_memread_8(&sym_buf[sx]));
  ------------------
  |  |   88|  1.67k|#  define Z_U64_FROM_LE(x)  (x)
  ------------------
  774|  1.67k|                    uint64_t dist_bits = v & LIT3_DIST_MASK;
  ------------------
  |  |  715|  1.67k|#define LIT3_DIST_MASK 0xFFFF00FFFF00FFFFULL
  ------------------
  775|       |
  776|       |                    /* A dist field is zero exactly when that symbol is a literal, so the first
  777|       |                     * nonzero one ends the run. There are only three fields, so three tests
  778|       |                     * locate it and no bit scan is needed. */
  779|  1.67k|                    if (dist_bits == 0 || (uint16_t)v == 0) {
  ------------------
  |  Branch (779:25): [True: 136, False: 1.53k]
  |  Branch (779:43): [True: 1.53k, False: 0]
  ------------------
  780|  1.67k|                        unsigned nextra = dist_bits == 0 ? 3 : (v & LIT3_DIST1_MASK) ? 1 : 2;
  ------------------
  |  |  719|  1.53k|#define LIT3_DIST1_MASK 0x000000FFFF000000ULL
  ------------------
  |  Branch (780:43): [True: 136, False: 1.53k]
  |  Branch (780:64): [True: 1.53k, False: 0]
  ------------------
  781|  1.67k|                        uint64_t tail = 0;
  782|  1.67k|                        uint32_t tbits = 0;
  783|       |
  784|  1.67k|                        switch (nextra) {
  785|    136|                        case 3:
  ------------------
  |  Branch (785:25): [True: 136, False: 1.53k]
  ------------------
  786|    136|                            lit_prepend(ltree, sym_buf[sx + 8], &tail, &tbits);
  787|    136|                            Z_FALLTHROUGH;
  ------------------
  |  |   54|    136|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  788|    136|                        case 2:
  ------------------
  |  Branch (788:25): [True: 0, False: 1.67k]
  ------------------
  789|    136|                            lit_prepend(ltree, (v >> 40) & 0xff, &tail, &tbits);
  790|    136|                            Z_FALLTHROUGH;
  ------------------
  |  |   54|    136|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  791|  1.67k|                        default:
  ------------------
  |  Branch (791:25): [True: 1.53k, False: 136]
  ------------------
  792|  1.67k|                            lit_prepend(ltree, (v >> 16) & 0xff, &tail, &tbits);
  793|  1.67k|                        }
  794|  1.67k|                        bits |= tail << nbits;
  795|  1.67k|                        nbits += tbits;
  796|  1.67k|                        sx += 3 * nextra;
  797|  1.67k|                    }
  798|  1.67k|                }
  799|  2.08k|                send_bits(s, bits, nbits, bi_buf, bi_valid);
  ------------------
  |  |   43|  2.08k|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) do {\
  |  |   44|  2.08k|    Assert(bi_valid <= 64, "Too many bits in bi_valid");\
  |  |   45|  2.08k|    uint64_t val = (uint64_t)t_val;\
  |  |   46|  2.08k|    uint32_t len = (uint32_t)t_len;\
  |  |   47|  2.08k|    uint32_t total_bits = bi_valid + len;\
  |  |   48|  2.08k|    trace_bits(s, val, len);\
  |  |   49|  2.08k|    sent_bits_add(s, len);\
  |  |  ------------------
  |  |  |  |  451|  2.08k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  2.08k|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   50|  2.08k|    \
  |  |   51|  2.08k|    /* Unconditionally shift and merge values into the buffer */\
  |  |   52|  2.08k|    bi_buf |= val << bi_valid;\
  |  |   53|  2.08k|    \
  |  |   54|  2.08k|    /* Check if the 64-bit boundary was crossed */\
  |  |   55|  2.08k|    if (total_bits >= 64) {\
  |  |  ------------------
  |  |  |  Branch (55:9): [True: 22, False: 2.06k]
  |  |  ------------------
  |  |   56|     22|        total_bits -= 64;\
  |  |   57|     22|        put_uint64(s, bi_buf);\
  |  |   58|     22|        \
  |  |   59|     22|        /* Secure shift: prevent Undefined Behavior when bi_valid is 0 */\
  |  |   60|     22|        /* If bi_valid is 0, we shift by 0 (via the mask) and overwrite bi_buf completely */\
  |  |   61|     22|        bi_buf = (val >> 1) >> (~bi_valid & 63);\
  |  |   62|     22|    }\
  |  |   63|  2.08k|    bi_valid = total_bits;\
  |  |   64|  2.08k|} while (0)
  |  |  ------------------
  |  |  |  Branch (64:10): [Folded, False: 2.08k]
  |  |  ------------------
  ------------------
  800|       |#else
  801|       |                zng_emit_lit(s, ltree, lc, &bi_buf, &bi_valid);
  802|       |#endif
  803|  1.83M|            } else {
  804|  1.83M|                zng_emit_dist(s, ltree, dtree, lc, dist, &bi_buf, &bi_valid);
  805|  1.83M|            } /* literal or match pair ? */
  806|       |
  807|       |            /* Check for no overlay of pending_buf on needed symbols */
  808|       |#ifdef LIT_MEM
  809|       |            Assert(s->pending < 2 * (s->lit_bufsize + sx), "pending_buf overflow");
  810|       |#else
  811|  1.84M|            Assert(s->pending < s->lit_bufsize + sx, "pending_buf overflow");
  812|  1.84M|#endif
  813|  1.84M|        } while (sx < sym_next);
  ------------------
  |  Branch (813:18): [True: 1.83M, False: 3.16k]
  ------------------
  814|  3.16k|    }
  815|       |
  816|  3.16k|    zng_emit_end_block(s, ltree, 0, &bi_buf, &bi_valid);
  817|       |
  818|       |    /* Write back to state */
  819|  3.16k|    s->bi_buf = bi_buf;
  820|  3.16k|    s->bi_valid = bi_valid;
  821|  3.16k|}
trees.c:lit_prepend:
  723|  1.94k|Z_FORCEINLINE static void lit_prepend(const ct_data *ltree, unsigned lc, uint64_t *tail, uint32_t *tbits) {
  724|  1.94k|    *tail = (uint64_t)ltree[lc].Code | (*tail << ltree[lc].Len);
  ------------------
  |  |  126|  1.94k|#define Code fc.code
  ------------------
                  *tail = (uint64_t)ltree[lc].Code | (*tail << ltree[lc].Len);
  ------------------
  |  |  128|  1.94k|#define Len  dl.len
  ------------------
  725|  1.94k|    *tbits += ltree[lc].Len;
  ------------------
  |  |  128|  1.94k|#define Len  dl.len
  ------------------
  726|  1.94k|}
trees.c:detect_data_type:
  836|  1.58k|static int detect_data_type(deflate_state *s) {
  837|       |    /* block_mask is the bit mask of block-listed bytes
  838|       |     * set bits 0..6, 14..25, and 28..31
  839|       |     * 0xf3ffc07f = binary 11110011111111111100000001111111
  840|       |     */
  841|  1.58k|    unsigned long block_mask = 0xf3ffc07fUL;
  842|  1.58k|    int n;
  843|       |
  844|       |    /* Check for non-textual ("block-listed") bytes. */
  845|  1.58k|    for (n = 0; n <= 31; n++, block_mask >>= 1)
  ------------------
  |  Branch (845:17): [True: 1.58k, False: 0]
  ------------------
  846|  1.58k|        if ((block_mask & 1) && (s->dyn_ltree[n].Freq != 0))
  ------------------
  |  |  125|  1.58k|#define Freq fc.freq
  ------------------
  |  Branch (846:13): [True: 1.58k, False: 0]
  |  Branch (846:33): [True: 1.58k, False: 0]
  ------------------
  847|  1.58k|            return Z_BINARY;
  ------------------
  |  |  206|  1.58k|#define Z_BINARY   0
  ------------------
  848|       |
  849|       |    /* Check for textual ("allow-listed") bytes. */
  850|      0|    if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0 || s->dyn_ltree[13].Freq != 0)
  ------------------
  |  |  125|      0|#define Freq fc.freq
  ------------------
                  if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0 || s->dyn_ltree[13].Freq != 0)
  ------------------
  |  |  125|      0|#define Freq fc.freq
  ------------------
                  if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0 || s->dyn_ltree[13].Freq != 0)
  ------------------
  |  |  125|      0|#define Freq fc.freq
  ------------------
  |  Branch (850:9): [True: 0, False: 0]
  |  Branch (850:38): [True: 0, False: 0]
  |  Branch (850:68): [True: 0, False: 0]
  ------------------
  851|      0|        return Z_TEXT;
  ------------------
  |  |  207|      0|#define Z_TEXT     1
  ------------------
  852|      0|    for (n = 32; n < LITERALS; n++)
  ------------------
  |  |   45|      0|#define LITERALS  256
  ------------------
  |  Branch (852:18): [True: 0, False: 0]
  ------------------
  853|      0|        if (s->dyn_ltree[n].Freq != 0)
  ------------------
  |  |  125|      0|#define Freq fc.freq
  ------------------
  |  Branch (853:13): [True: 0, False: 0]
  ------------------
  854|      0|            return Z_TEXT;
  ------------------
  |  |  207|      0|#define Z_TEXT     1
  ------------------
  855|       |
  856|       |    /* There are no "block-listed" or "allow-listed" bytes:
  857|       |     * this stream either is empty or has tolerated ("gray-listed") bytes only.
  858|       |     */
  859|      0|    return Z_BINARY;
  ------------------
  |  |  206|      0|#define Z_BINARY   0
  ------------------
  860|      0|}

trees.c:zng_tr_emit_tree:
  204|  4.74k|static inline void zng_tr_emit_tree(deflate_state *s, int type, const int last) {
  205|  4.74k|    uint32_t bi_valid = s->bi_valid;
  206|  4.74k|    uint64_t bi_buf = s->bi_buf;
  207|  4.74k|    uint32_t header_bits = (type << 1) + last;
  208|  4.74k|    send_bits(s, header_bits, 3, bi_buf, bi_valid);
  ------------------
  |  |   43|  4.74k|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) do {\
  |  |   44|  4.74k|    Assert(bi_valid <= 64, "Too many bits in bi_valid");\
  |  |   45|  4.74k|    uint64_t val = (uint64_t)t_val;\
  |  |   46|  4.74k|    uint32_t len = (uint32_t)t_len;\
  |  |   47|  4.74k|    uint32_t total_bits = bi_valid + len;\
  |  |   48|  4.74k|    trace_bits(s, val, len);\
  |  |   49|  4.74k|    sent_bits_add(s, len);\
  |  |  ------------------
  |  |  |  |  451|  4.74k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  4.74k|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   50|  4.74k|    \
  |  |   51|  4.74k|    /* Unconditionally shift and merge values into the buffer */\
  |  |   52|  4.74k|    bi_buf |= val << bi_valid;\
  |  |   53|  4.74k|    \
  |  |   54|  4.74k|    /* Check if the 64-bit boundary was crossed */\
  |  |   55|  4.74k|    if (total_bits >= 64) {\
  |  |  ------------------
  |  |  |  Branch (55:9): [True: 0, False: 4.74k]
  |  |  ------------------
  |  |   56|      0|        total_bits -= 64;\
  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |   58|      0|        \
  |  |   59|      0|        /* Secure shift: prevent Undefined Behavior when bi_valid is 0 */\
  |  |   60|      0|        /* If bi_valid is 0, we shift by 0 (via the mask) and overwrite bi_buf completely */\
  |  |   61|      0|        bi_buf = (val >> 1) >> (~bi_valid & 63);\
  |  |   62|      0|    }\
  |  |   63|  4.74k|    bi_valid = total_bits;\
  |  |   64|  4.74k|} while (0)
  |  |  ------------------
  |  |  |  Branch (64:10): [Folded, False: 4.74k]
  |  |  ------------------
  ------------------
  209|  4.74k|    cmpr_bits_add(s, 3);
  ------------------
  |  |  449|  4.74k|#  define cmpr_bits_add(s, len)     Z_UNUSED(len)
  |  |  ------------------
  |  |  |  |  154|  4.74k|#define Z_UNUSED(var) (void)(var)
  |  |  ------------------
  ------------------
  210|  4.74k|    s->bi_valid = bi_valid;
  211|  4.74k|    s->bi_buf = bi_buf;
  212|  4.74k|    Tracev((stderr, "\n--- Emit Tree: Last: %u\n", last));
  213|  4.74k|}
trees.c:zng_tr_emit_align:
  218|  3.16k|static inline void zng_tr_emit_align(deflate_state *s) {
  219|  3.16k|    bi_windup(s); /* align on byte boundary */
  220|  3.16k|    sent_bits_align(s);
  221|  3.16k|}
trees.c:bi_windup:
   80|  3.16k|static inline void bi_windup(deflate_state *s) {
   81|  3.16k|    if (s->bi_valid > 56) {
  ------------------
  |  Branch (81:9): [True: 219, False: 2.94k]
  ------------------
   82|    219|        put_uint64(s, s->bi_buf);
   83|  2.94k|    } else {
   84|  2.94k|        if (s->bi_valid > 24) {
  ------------------
  |  Branch (84:13): [True: 756, False: 2.18k]
  ------------------
   85|    756|            put_uint32(s, (uint32_t)s->bi_buf);
   86|    756|            s->bi_buf >>= 32;
   87|    756|            s->bi_valid -= 32;
   88|    756|        }
   89|  2.94k|        if (s->bi_valid > 8) {
  ------------------
  |  Branch (89:13): [True: 915, False: 2.02k]
  ------------------
   90|    915|            put_short(s, (uint16_t)s->bi_buf);
   91|    915|            s->bi_buf >>= 16;
   92|    915|            s->bi_valid -= 16;
   93|    915|        }
   94|  2.94k|        if (s->bi_valid > 0) {
  ------------------
  |  Branch (94:13): [True: 2.11k, False: 828]
  ------------------
   95|  2.11k|            put_byte(s, s->bi_buf);
  ------------------
  |  |  350|  2.11k|#define put_byte(s, c) { \
  |  |  351|  2.11k|    s->pending_buf[s->pending++] = (unsigned char)(c); \
  |  |  352|  2.11k|}
  ------------------
   96|  2.11k|        }
   97|  2.94k|    }
   98|  3.16k|    s->bi_used = ((s->bi_valid - 1) & 7) + 1;
   99|  3.16k|    s->bi_buf = 0;
  100|  3.16k|    s->bi_valid = 0;
  101|  3.16k|}
trees.c:zng_emit_end_block:
  169|  3.16k|                                      uint64_t *bi_buf, uint32_t *bi_valid) {
  170|  3.16k|    send_code(s, END_BLOCK, ltree, *bi_buf, *bi_valid);
  ------------------
  |  |   74|  3.16k|    send_bits(s, tree[c].Code, tree[c].Len, bi_buf, bi_valid)
  |  |  ------------------
  |  |  |  |   43|  3.16k|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) do {\
  |  |  |  |   44|  3.16k|    Assert(bi_valid <= 64, "Too many bits in bi_valid");\
  |  |  |  |   45|  3.16k|    uint64_t val = (uint64_t)t_val;\
  |  |  |  |   46|  3.16k|    uint32_t len = (uint32_t)t_len;\
  |  |  |  |   47|  3.16k|    uint32_t total_bits = bi_valid + len;\
  |  |  |  |   48|  3.16k|    trace_bits(s, val, len);\
  |  |  |  |   49|  3.16k|    sent_bits_add(s, len);\
  |  |  |  |  ------------------
  |  |  |  |  |  |  451|  3.16k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  154|  3.16k|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   50|  3.16k|    \
  |  |  |  |   51|  3.16k|    /* Unconditionally shift and merge values into the buffer */\
  |  |  |  |   52|  3.16k|    bi_buf |= val << bi_valid;\
  |  |  |  |   53|  3.16k|    \
  |  |  |  |   54|  3.16k|    /* Check if the 64-bit boundary was crossed */\
  |  |  |  |   55|  3.16k|    if (total_bits >= 64) {\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (55:9): [True: 299, False: 2.86k]
  |  |  |  |  ------------------
  |  |  |  |   56|    299|        total_bits -= 64;\
  |  |  |  |   57|    299|        put_uint64(s, bi_buf);\
  |  |  |  |   58|    299|        \
  |  |  |  |   59|    299|        /* Secure shift: prevent Undefined Behavior when bi_valid is 0 */\
  |  |  |  |   60|    299|        /* If bi_valid is 0, we shift by 0 (via the mask) and overwrite bi_buf completely */\
  |  |  |  |   61|    299|        bi_buf = (val >> 1) >> (~bi_valid & 63);\
  |  |  |  |   62|    299|    }\
  |  |  |  |   63|  3.16k|    bi_valid = total_bits;\
  |  |  |  |   64|  3.16k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (64:10): [Folded, False: 3.16k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  171|  3.16k|    Tracev((stderr, "\n+++ Emit End Block: Last: %u Pending: %u Total Out: %" PRIu64 "\n",
  172|  3.16k|        last, s->pending, (uint64_t)s->strm->total_out));
  173|  3.16k|    Z_UNUSED(last);
  ------------------
  |  |  154|  3.16k|#define Z_UNUSED(var) (void)(var)
  ------------------
  174|  3.16k|}
trees.c:zng_emit_dist:
  116|  1.83M|                                     uint32_t lc, uint32_t dist, uint64_t *bi_buf, uint32_t *bi_valid) {
  117|  1.83M|    uint64_t match_bits;
  118|  1.83M|    uint32_t match_bits_len;
  119|  1.83M|    uint32_t mask_ext;  // Contains both mask and extra, can safely be used directly as mask
  120|       |                        // due to extra bits being outside the range of lc and dist data.
  121|  1.83M|    uint32_t c, extra;
  122|  1.83M|    uint8_t code;
  123|       |
  124|       |    /* 1. Process Length Code */
  125|  1.83M|    code = zng_length_code[lc];
  126|  1.83M|    c = code + LITERALS + 1;
  ------------------
  |  |   45|  1.83M|#define LITERALS  256
  ------------------
  127|  1.83M|    Assert(c < L_CODES, "bad l_code");
  128|  1.83M|    trace_code(s, c);
  129|       |
  130|       |    /*    Send length code, len is the match length - STD_MIN_MATCH */
  131|  1.83M|    match_bits = ltree[c].Code;
  ------------------
  |  |  126|  1.83M|#define Code fc.code
  ------------------
  132|  1.83M|    match_bits_len = ltree[c].Len;
  ------------------
  |  |  128|  1.83M|#define Len  dl.len
  ------------------
  133|       |
  134|       |    /* 2. Get extra bits count and mask */
  135|  1.83M|    mask_ext = lmask_extra[code];
  136|  1.83M|    extra = mask_ext >> 8;
  137|       |
  138|       |    /*    Send length extra bits */
  139|  1.83M|    match_bits |= (uint64_t)(lc & mask_ext) << match_bits_len;
  140|  1.83M|    match_bits_len += extra;
  141|       |
  142|       |    /* 3. Process Distance Code */
  143|  1.83M|    dist--; /* dist is now the match distance - 1 */
  144|  1.83M|    code = d_code(dist);
  ------------------
  |  |  436|  1.83M|#define d_code(dist) ((dist) < 256 ? zng_dist_code[dist] : zng_dist_code[256+((dist)>>7)])
  |  |  ------------------
  |  |  |  Branch (436:23): [True: 1.83M, False: 1.37k]
  |  |  ------------------
  ------------------
  145|  1.83M|    Assert(code < D_CODES, "bad d_code");
  146|  1.83M|    trace_code(s, code);
  147|       |
  148|       |    /*    Send distance code */
  149|  1.83M|    match_bits |= ((uint64_t)dtree[code].Code << match_bits_len);
  ------------------
  |  |  126|  1.83M|#define Code fc.code
  ------------------
  150|  1.83M|    match_bits_len += dtree[code].Len;
  ------------------
  |  |  128|  1.83M|#define Len  dl.len
  ------------------
  151|       |
  152|       |    /* 4. Get extra bits count and mask */
  153|  1.83M|    mask_ext = dmask_extra[code];
  154|  1.83M|    extra = mask_ext >> 16;
  155|       |
  156|       |    /*    Send dist extra bits */
  157|  1.83M|    match_bits |= ((uint64_t)(dist & mask_ext) << match_bits_len);
  158|  1.83M|    match_bits_len += extra;
  159|       |
  160|  1.83M|    send_bits(s, match_bits, match_bits_len, *bi_buf, *bi_valid);
  ------------------
  |  |   43|  1.83M|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) do {\
  |  |   44|  1.83M|    Assert(bi_valid <= 64, "Too many bits in bi_valid");\
  |  |   45|  1.83M|    uint64_t val = (uint64_t)t_val;\
  |  |   46|  1.83M|    uint32_t len = (uint32_t)t_len;\
  |  |   47|  1.83M|    uint32_t total_bits = bi_valid + len;\
  |  |   48|  1.83M|    trace_bits(s, val, len);\
  |  |   49|  1.83M|    sent_bits_add(s, len);\
  |  |  ------------------
  |  |  |  |  451|  1.83M|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  1.83M|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   50|  1.83M|    \
  |  |   51|  1.83M|    /* Unconditionally shift and merge values into the buffer */\
  |  |   52|  1.83M|    bi_buf |= val << bi_valid;\
  |  |   53|  1.83M|    \
  |  |   54|  1.83M|    /* Check if the 64-bit boundary was crossed */\
  |  |   55|  1.83M|    if (total_bits >= 64) {\
  |  |  ------------------
  |  |  |  Branch (55:9): [True: 58.8k, False: 1.78M]
  |  |  ------------------
  |  |   56|  58.8k|        total_bits -= 64;\
  |  |   57|  58.8k|        put_uint64(s, bi_buf);\
  |  |   58|  58.8k|        \
  |  |   59|  58.8k|        /* Secure shift: prevent Undefined Behavior when bi_valid is 0 */\
  |  |   60|  58.8k|        /* If bi_valid is 0, we shift by 0 (via the mask) and overwrite bi_buf completely */\
  |  |   61|  58.8k|        bi_buf = (val >> 1) >> (~bi_valid & 63);\
  |  |   62|  58.8k|    }\
  |  |   63|  1.83M|    bi_valid = total_bits;\
  |  |   64|  1.83M|} while (0)
  |  |  ------------------
  |  |  |  Branch (64:10): [Folded, False: 1.83M]
  |  |  ------------------
  ------------------
  161|       |
  162|  1.83M|    return match_bits_len;
  163|  1.83M|}

deflate.c:zng_memwrite_2:
   45|  1.58k|static inline void zng_memwrite_2(void *ptr, uint16_t val) {
   46|  1.58k|#if defined(HAVE_MAY_ALIAS)
   47|  1.58k|    typedef struct { uint16_t val; } __attribute__ ((__packed__, __may_alias__)) unaligned_uint16_t;
   48|  1.58k|    ((unaligned_uint16_t *)ptr)->val = val;
   49|       |#else
   50|       |    memcpy(ptr, &val, sizeof(val));
   51|       |#endif
   52|  1.58k|}
deflate.c:zng_memwrite_4:
   54|  1.58k|static inline void zng_memwrite_4(void *ptr, uint32_t val) {
   55|  1.58k|#if defined(HAVE_MAY_ALIAS)
   56|  1.58k|    typedef struct { uint32_t val; } __attribute__ ((__packed__, __may_alias__)) unaligned_uint32_t;
   57|  1.58k|    ((unaligned_uint32_t *)ptr)->val = val;
   58|       |#else
   59|       |    memcpy(ptr, &val, sizeof(val));
   60|       |#endif
   61|  1.58k|}
deflate_slow.c:zng_memwrite_4:
   54|  1.84M|static inline void zng_memwrite_4(void *ptr, uint32_t val) {
   55|  1.84M|#if defined(HAVE_MAY_ALIAS)
   56|  1.84M|    typedef struct { uint32_t val; } __attribute__ ((__packed__, __may_alias__)) unaligned_uint32_t;
   57|  1.84M|    ((unaligned_uint32_t *)ptr)->val = val;
   58|       |#else
   59|       |    memcpy(ptr, &val, sizeof(val));
   60|       |#endif
   61|  1.84M|}
deflate_stored.c:zng_memwrite_2:
   45|  3.16k|static inline void zng_memwrite_2(void *ptr, uint16_t val) {
   46|  3.16k|#if defined(HAVE_MAY_ALIAS)
   47|  3.16k|    typedef struct { uint16_t val; } __attribute__ ((__packed__, __may_alias__)) unaligned_uint16_t;
   48|  3.16k|    ((unaligned_uint16_t *)ptr)->val = val;
   49|       |#else
   50|       |    memcpy(ptr, &val, sizeof(val));
   51|       |#endif
   52|  3.16k|}
inftrees.c:zng_memread_4:
   23|  24.2k|static inline uint32_t zng_memread_4(const void *ptr) {
   24|  24.2k|#if defined(HAVE_MAY_ALIAS)
   25|  24.2k|    typedef struct { uint32_t val; } __attribute__ ((__packed__, __may_alias__)) unaligned_uint32_t;
   26|  24.2k|    return ((const unaligned_uint32_t *)ptr)->val;
   27|       |#else
   28|       |    uint32_t val;
   29|       |    memcpy(&val, ptr, sizeof(val));
   30|       |    return val;
   31|       |#endif
   32|  24.2k|}
inftrees.c:zng_memwrite_4:
   54|  36.8k|static inline void zng_memwrite_4(void *ptr, uint32_t val) {
   55|  36.8k|#if defined(HAVE_MAY_ALIAS)
   56|  36.8k|    typedef struct { uint32_t val; } __attribute__ ((__packed__, __may_alias__)) unaligned_uint32_t;
   57|  36.8k|    ((unaligned_uint32_t *)ptr)->val = val;
   58|       |#else
   59|       |    memcpy(ptr, &val, sizeof(val));
   60|       |#endif
   61|  36.8k|}
trees.c:zng_memwrite_8:
   63|  61.9k|static inline void zng_memwrite_8(void *ptr, uint64_t val) {
   64|  61.9k|#if defined(HAVE_MAY_ALIAS)
   65|  61.9k|    typedef struct { uint64_t val; } __attribute__ ((__packed__, __may_alias__)) unaligned_uint64_t;
   66|  61.9k|    ((unaligned_uint64_t *)ptr)->val = val;
   67|       |#else
   68|       |    memcpy(ptr, &val, sizeof(val));
   69|       |#endif
   70|  61.9k|}
trees.c:zng_memwrite_2:
   45|  4.88k|static inline void zng_memwrite_2(void *ptr, uint16_t val) {
   46|  4.88k|#if defined(HAVE_MAY_ALIAS)
   47|  4.88k|    typedef struct { uint16_t val; } __attribute__ ((__packed__, __may_alias__)) unaligned_uint16_t;
   48|  4.88k|    ((unaligned_uint16_t *)ptr)->val = val;
   49|       |#else
   50|       |    memcpy(ptr, &val, sizeof(val));
   51|       |#endif
   52|  4.88k|}
trees.c:zng_memread_4:
   23|  1.84M|static inline uint32_t zng_memread_4(const void *ptr) {
   24|  1.84M|#if defined(HAVE_MAY_ALIAS)
   25|  1.84M|    typedef struct { uint32_t val; } __attribute__ ((__packed__, __may_alias__)) unaligned_uint32_t;
   26|  1.84M|    return ((const unaligned_uint32_t *)ptr)->val;
   27|       |#else
   28|       |    uint32_t val;
   29|       |    memcpy(&val, ptr, sizeof(val));
   30|       |    return val;
   31|       |#endif
   32|  1.84M|}
trees.c:zng_memread_8:
   34|  1.67k|static inline uint64_t zng_memread_8(const void *ptr) {
   35|  1.67k|#if defined(HAVE_MAY_ALIAS)
   36|  1.67k|    typedef struct { uint64_t val; } __attribute__ ((__packed__, __may_alias__)) unaligned_uint64_t;
   37|  1.67k|    return ((const unaligned_uint64_t *)ptr)->val;
   38|       |#else
   39|       |    uint64_t val;
   40|       |    memcpy(&val, ptr, sizeof(val));
   41|       |    return val;
   42|       |#endif
   43|  1.67k|}
trees.c:zng_memwrite_4:
   54|  1.65k|static inline void zng_memwrite_4(void *ptr, uint32_t val) {
   55|  1.65k|#if defined(HAVE_MAY_ALIAS)
   56|  1.65k|    typedef struct { uint32_t val; } __attribute__ ((__packed__, __may_alias__)) unaligned_uint32_t;
   57|  1.65k|    ((unaligned_uint32_t *)ptr)->val = val;
   58|       |#else
   59|       |    memcpy(ptr, &val, sizeof(val));
   60|       |#endif
   61|  1.65k|}
chunkset_avx2.c:zng_memread_8:
   34|  1.84M|static inline uint64_t zng_memread_8(const void *ptr) {
   35|  1.84M|#if defined(HAVE_MAY_ALIAS)
   36|  1.84M|    typedef struct { uint64_t val; } __attribute__ ((__packed__, __may_alias__)) unaligned_uint64_t;
   37|  1.84M|    return ((const unaligned_uint64_t *)ptr)->val;
   38|       |#else
   39|       |    uint64_t val;
   40|       |    memcpy(&val, ptr, sizeof(val));
   41|       |    return val;
   42|       |#endif
   43|  1.84M|}
compare256_avx2.c:zng_memread_8:
   34|  7.43M|static inline uint64_t zng_memread_8(const void *ptr) {
   35|  7.43M|#if defined(HAVE_MAY_ALIAS)
   36|  7.43M|    typedef struct { uint64_t val; } __attribute__ ((__packed__, __may_alias__)) unaligned_uint64_t;
   37|  7.43M|    return ((const unaligned_uint64_t *)ptr)->val;
   38|       |#else
   39|       |    uint64_t val;
   40|       |    memcpy(&val, ptr, sizeof(val));
   41|       |    return val;
   42|       |#endif
   43|  7.43M|}
compare256_avx2.c:zng_memcmp_8:
   91|   778k|static inline int32_t zng_memcmp_8(const void * Z_RESTRICT src0, const void * Z_RESTRICT src1) {
   92|   778k|#if defined(HAVE_MAY_ALIAS) || defined(_MSC_VER)
   93|   778k|    return zng_memread_8(src0) != zng_memread_8(src1);
   94|       |#else
   95|       |    return memcmp(src0, src1, 8);
   96|       |#endif
   97|   778k|}

zng_zcalloc:
  105|  3.16k|void Z_INTERNAL *PREFIX(zcalloc)(void *opaque, unsigned items, unsigned size) {
  106|  3.16k|    Z_UNUSED(opaque);
  ------------------
  |  |  154|  3.16k|#define Z_UNUSED(var) (void)(var)
  ------------------
  107|  3.16k|    return zng_alloc((size_t)items * (size_t)size);
  108|  3.16k|}
zng_zcfree:
  110|  3.16k|void Z_INTERNAL PREFIX(zcfree)(void *opaque, void *ptr) {
  111|  3.16k|    Z_UNUSED(opaque);
  ------------------
  |  |  154|  3.16k|#define Z_UNUSED(var) (void)(var)
  ------------------
  112|  3.16k|    zng_free(ptr);
  113|  3.16k|}

zutil.c:zng_alloc:
   12|  3.16k|static inline void *zng_alloc(size_t size) {
   13|  3.16k|    return malloc(size);
   14|  3.16k|}
zutil.c:zng_free:
   16|  3.16k|static inline void zng_free(void *ptr) {
   17|  3.16k|    free(ptr);
   18|  3.16k|}

