adler32_ssse3.c:adler32_copy_tail:
  134|  1.40k|                                                uint32_t sum2, const int REBASE, const int MAX_LEN, const int COPY) {
  135|  1.40k|    if (len) {
  ------------------
  |  Branch (135:9): [True: 1.31k, False: 84]
  ------------------
  136|  1.31k|        Z_UNUSED(MAX_LEN);
  ------------------
  |  |  154|  1.31k|#define Z_UNUSED(var) (void)(var)
  ------------------
  137|       |        /* Process using packed 64-bit arithmetic when source is aligned */
  138|  1.88k|        while (len >= 8 && ((uintptr_t)buf & 7) == 0) {
  ------------------
  |  Branch (138:16): [True: 568, False: 1.31k]
  |  Branch (138:28): [True: 568, False: 0]
  ------------------
  139|    568|            size_t chunk = MIN(ALIGN_DOWN(len, (size_t)8), (size_t)ADLER32_SWAR_MAX_BYTES);
  ------------------
  |  |  148|    568|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 568]
  |  |  ------------------
  ------------------
  140|    568|            adler32_swar(&adler, dst, buf, chunk, &sum2, COPY);
  141|    568|            buf += chunk;
  142|    568|            if (COPY)
  ------------------
  |  Branch (142:17): [True: 0, False: 568]
  ------------------
  143|      0|                dst += chunk;
  144|    568|            len -= chunk;
  145|    568|        }
  146|       |        /* DO4 loop avoids GCC x86 register pressure from hoisted DO8/DO16 loads. */
  147|  1.94k|        while (len >= 4) {
  ------------------
  |  Branch (147:16): [True: 629, False: 1.31k]
  ------------------
  148|    629|            if (COPY) {
  ------------------
  |  Branch (148:17): [True: 0, False: 629]
  ------------------
  149|      0|                memcpy(dst, buf, 4);
  150|      0|                dst += 4;
  151|      0|            }
  152|    629|            len -= 4;
  153|    629|            ADLER_DO4(adler, sum2, buf, 0);
  ------------------
  |  |   21|    629|#define ADLER_DO4(sum1, sum2, buf, i)  {ADLER_DO2(sum1, sum2, buf, i); ADLER_DO2(sum1, sum2, buf, i+2);}
  |  |  ------------------
  |  |  |  |   20|    629|#define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    629|#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|    629|#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|    629|#define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|    629|#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|    629|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  154|    629|            buf += 4;
  155|    629|        }
  156|  1.31k|        if (len & 2) {
  ------------------
  |  Branch (156:13): [True: 687, False: 632]
  ------------------
  157|    687|            if (COPY) {
  ------------------
  |  Branch (157:17): [True: 0, False: 687]
  ------------------
  158|      0|                memcpy(dst, buf, 2);
  159|      0|                dst += 2;
  160|      0|            }
  161|    687|            ADLER_DO2(adler, sum2, buf, 0);
  ------------------
  |  |   20|    687|#define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
  |  |  ------------------
  |  |  |  |   19|    687|#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|    687|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  |  |  ------------------
  ------------------
  162|    687|            buf += 2;
  163|    687|        }
  164|  1.31k|        if (len & 1) {
  ------------------
  |  Branch (164:13): [True: 695, False: 624]
  ------------------
  165|    695|            if (COPY)
  ------------------
  |  Branch (165:17): [True: 0, False: 695]
  ------------------
  166|      0|                *dst = *buf;
  167|    695|            ADLER_DO1(adler, sum2, buf, 0);
  ------------------
  |  |   19|    695|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  ------------------
  168|    695|        }
  169|  1.31k|    }
  170|  1.40k|    if (REBASE) {
  ------------------
  |  Branch (170:9): [True: 1.31k, False: 84]
  ------------------
  171|  1.31k|        adler %= BASE;
  ------------------
  |  |   13|  1.31k|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  172|  1.31k|        sum2 %= BASE;
  ------------------
  |  |   13|  1.31k|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  173|  1.31k|    }
  174|       |    /* D = B * 65536 + A, see: https://en.wikipedia.org/wiki/Adler-32. */
  175|  1.40k|    return adler | (sum2 << 16);
  176|  1.40k|}
adler32_ssse3.c:adler32_swar:
   66|    568|                                       uint32_t *sum2, const int COPY) {
   67|    568|    uint64_t sum_even = 0, sum_odd = 0, prefix_even = 0, prefix_odd = 0;
   68|       |
   69|    568|    *sum2 += *adler * (uint32_t)len;
   70|       |
   71|    568|    const uint64_t *src64 = (const uint64_t *)buf;
   72|       |
   73|    568|    while (len >= 16) {
  ------------------
  |  Branch (73:12): [True: 0, False: 568]
  ------------------
   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|    568|    if (len >= 8) {
  ------------------
  |  Branch (97:9): [True: 568, False: 0]
  ------------------
   98|    568|        uint64_t v = *src64;
   99|    568|        if (COPY)
  ------------------
  |  Branch (99:13): [True: 0, False: 568]
  ------------------
  100|      0|            memcpy(dst, &v, sizeof(v));
  101|       |
  102|    568|        prefix_even += sum_even;
  103|    568|        prefix_odd += sum_odd;
  104|    568|        sum_even +=  v       & ADLER32_SWAR_EVEN_MASK;
  ------------------
  |  |   62|    568|#define ADLER32_SWAR_EVEN_MASK   0x00FF00FF00FF00FFULL
  ------------------
  105|    568|        sum_odd  += (v >> 8) & ADLER32_SWAR_EVEN_MASK;
  ------------------
  |  |   62|    568|#define ADLER32_SWAR_EVEN_MASK   0x00FF00FF00FF00FFULL
  ------------------
  106|    568|    }
  107|       |
  108|       |    /* Horizontal sum of 4x16-bit lanes for s1 */
  109|    568|    *adler += (uint32_t)(((sum_even + sum_odd) * ADLER32_SWAR_HSUM) >> 48);
  ------------------
  |  |   63|    568|#define ADLER32_SWAR_HSUM        0x1000100010001ULL
  ------------------
  110|       |
  111|       |    /* Widen prefix sums to 32-bit pairs and horizontal sum for s2 */
  112|    568|    uint64_t pe_lo = prefix_even & 0xFFFF0000FFFFULL;
  113|    568|    uint64_t pe_hi = (prefix_even >> 16) & 0xFFFF0000FFFFULL;
  114|    568|    uint64_t po_lo = prefix_odd & 0xFFFF0000FFFFULL;
  115|    568|    uint64_t po_hi = (prefix_odd >> 16) & 0xFFFF0000FFFFULL;
  116|       |
  117|    568|    *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|    568|#if BYTE_ORDER == LITTLE_ENDIAN
  123|    568|    *sum2 += 2 * (uint32_t)((sum_even * 0x4000300020001ULL) >> 48)
  124|    568|           +     (uint32_t)((sum_odd  * ADLER32_SWAR_HSUM) >> 48)
  ------------------
  |  |   63|    568|#define ADLER32_SWAR_HSUM        0x1000100010001ULL
  ------------------
  125|    568|           + 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|    568|}
adler32_sse42.c:adler32_copy_tail:
  134|  3.31k|                                                uint32_t sum2, const int REBASE, const int MAX_LEN, const int COPY) {
  135|  3.31k|    if (len) {
  ------------------
  |  Branch (135:9): [True: 3.31k, False: 0]
  ------------------
  136|  3.31k|        Z_UNUSED(MAX_LEN);
  ------------------
  |  |  154|  3.31k|#define Z_UNUSED(var) (void)(var)
  ------------------
  137|       |        /* Process using packed 64-bit arithmetic when source is aligned */
  138|  4.86k|        while (len >= 8 && ((uintptr_t)buf & 7) == 0) {
  ------------------
  |  Branch (138:16): [True: 1.70k, False: 3.16k]
  |  Branch (138:28): [True: 1.54k, False: 155]
  ------------------
  139|  1.54k|            size_t chunk = MIN(ALIGN_DOWN(len, (size_t)8), (size_t)ADLER32_SWAR_MAX_BYTES);
  ------------------
  |  |  148|  1.54k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 1.54k]
  |  |  ------------------
  ------------------
  140|  1.54k|            adler32_swar(&adler, dst, buf, chunk, &sum2, COPY);
  141|  1.54k|            buf += chunk;
  142|  1.54k|            if (COPY)
  ------------------
  |  Branch (142:17): [True: 1.54k, False: 0]
  ------------------
  143|  1.54k|                dst += chunk;
  144|  1.54k|            len -= chunk;
  145|  1.54k|        }
  146|       |        /* DO4 loop avoids GCC x86 register pressure from hoisted DO8/DO16 loads. */
  147|  5.32k|        while (len >= 4) {
  ------------------
  |  Branch (147:16): [True: 2.01k, False: 3.31k]
  ------------------
  148|  2.01k|            if (COPY) {
  ------------------
  |  Branch (148:17): [True: 2.01k, False: 0]
  ------------------
  149|  2.01k|                memcpy(dst, buf, 4);
  150|  2.01k|                dst += 4;
  151|  2.01k|            }
  152|  2.01k|            len -= 4;
  153|  2.01k|            ADLER_DO4(adler, sum2, buf, 0);
  ------------------
  |  |   21|  2.01k|#define ADLER_DO4(sum1, sum2, buf, i)  {ADLER_DO2(sum1, sum2, buf, i); ADLER_DO2(sum1, sum2, buf, i+2);}
  |  |  ------------------
  |  |  |  |   20|  2.01k|#define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|  2.01k|#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.01k|#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.01k|#define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|  2.01k|#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.01k|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  154|  2.01k|            buf += 4;
  155|  2.01k|        }
  156|  3.31k|        if (len & 2) {
  ------------------
  |  Branch (156:13): [True: 1.83k, False: 1.48k]
  ------------------
  157|  1.83k|            if (COPY) {
  ------------------
  |  Branch (157:17): [True: 1.83k, False: 0]
  ------------------
  158|  1.83k|                memcpy(dst, buf, 2);
  159|  1.83k|                dst += 2;
  160|  1.83k|            }
  161|  1.83k|            ADLER_DO2(adler, sum2, buf, 0);
  ------------------
  |  |   20|  1.83k|#define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
  |  |  ------------------
  |  |  |  |   19|  1.83k|#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.83k|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  |  |  ------------------
  ------------------
  162|  1.83k|            buf += 2;
  163|  1.83k|        }
  164|  3.31k|        if (len & 1) {
  ------------------
  |  Branch (164:13): [True: 1.81k, False: 1.50k]
  ------------------
  165|  1.81k|            if (COPY)
  ------------------
  |  Branch (165:17): [True: 1.81k, False: 0]
  ------------------
  166|  1.81k|                *dst = *buf;
  167|  1.81k|            ADLER_DO1(adler, sum2, buf, 0);
  ------------------
  |  |   19|  1.81k|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  ------------------
  168|  1.81k|        }
  169|  3.31k|    }
  170|  3.31k|    if (REBASE) {
  ------------------
  |  Branch (170:9): [True: 3.31k, False: 0]
  ------------------
  171|  3.31k|        adler %= BASE;
  ------------------
  |  |   13|  3.31k|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  172|  3.31k|        sum2 %= BASE;
  ------------------
  |  |   13|  3.31k|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  173|  3.31k|    }
  174|       |    /* D = B * 65536 + A, see: https://en.wikipedia.org/wiki/Adler-32. */
  175|  3.31k|    return adler | (sum2 << 16);
  176|  3.31k|}
adler32_sse42.c:adler32_swar:
   66|  1.54k|                                       uint32_t *sum2, const int COPY) {
   67|  1.54k|    uint64_t sum_even = 0, sum_odd = 0, prefix_even = 0, prefix_odd = 0;
   68|       |
   69|  1.54k|    *sum2 += *adler * (uint32_t)len;
   70|       |
   71|  1.54k|    const uint64_t *src64 = (const uint64_t *)buf;
   72|       |
   73|  1.54k|    while (len >= 16) {
  ------------------
  |  Branch (73:12): [True: 0, False: 1.54k]
  ------------------
   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.54k|    if (len >= 8) {
  ------------------
  |  Branch (97:9): [True: 1.54k, False: 0]
  ------------------
   98|  1.54k|        uint64_t v = *src64;
   99|  1.54k|        if (COPY)
  ------------------
  |  Branch (99:13): [True: 1.54k, False: 0]
  ------------------
  100|  1.54k|            memcpy(dst, &v, sizeof(v));
  101|       |
  102|  1.54k|        prefix_even += sum_even;
  103|  1.54k|        prefix_odd += sum_odd;
  104|  1.54k|        sum_even +=  v       & ADLER32_SWAR_EVEN_MASK;
  ------------------
  |  |   62|  1.54k|#define ADLER32_SWAR_EVEN_MASK   0x00FF00FF00FF00FFULL
  ------------------
  105|  1.54k|        sum_odd  += (v >> 8) & ADLER32_SWAR_EVEN_MASK;
  ------------------
  |  |   62|  1.54k|#define ADLER32_SWAR_EVEN_MASK   0x00FF00FF00FF00FFULL
  ------------------
  106|  1.54k|    }
  107|       |
  108|       |    /* Horizontal sum of 4x16-bit lanes for s1 */
  109|  1.54k|    *adler += (uint32_t)(((sum_even + sum_odd) * ADLER32_SWAR_HSUM) >> 48);
  ------------------
  |  |   63|  1.54k|#define ADLER32_SWAR_HSUM        0x1000100010001ULL
  ------------------
  110|       |
  111|       |    /* Widen prefix sums to 32-bit pairs and horizontal sum for s2 */
  112|  1.54k|    uint64_t pe_lo = prefix_even & 0xFFFF0000FFFFULL;
  113|  1.54k|    uint64_t pe_hi = (prefix_even >> 16) & 0xFFFF0000FFFFULL;
  114|  1.54k|    uint64_t po_lo = prefix_odd & 0xFFFF0000FFFFULL;
  115|  1.54k|    uint64_t po_hi = (prefix_odd >> 16) & 0xFFFF0000FFFFULL;
  116|       |
  117|  1.54k|    *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.54k|#if BYTE_ORDER == LITTLE_ENDIAN
  123|  1.54k|    *sum2 += 2 * (uint32_t)((sum_even * 0x4000300020001ULL) >> 48)
  124|  1.54k|           +     (uint32_t)((sum_odd  * ADLER32_SWAR_HSUM) >> 48)
  ------------------
  |  |   63|  1.54k|#define ADLER32_SWAR_HSUM        0x1000100010001ULL
  ------------------
  125|  1.54k|           + 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.54k|}
adler32_avx2.c:adler32_copy_tail:
  134|  4.68k|                                                uint32_t sum2, const int REBASE, const int MAX_LEN, const int COPY) {
  135|  4.68k|    if (len) {
  ------------------
  |  Branch (135:9): [True: 4.68k, False: 0]
  ------------------
  136|  4.68k|        Z_UNUSED(MAX_LEN);
  ------------------
  |  |  154|  4.68k|#define Z_UNUSED(var) (void)(var)
  ------------------
  137|       |        /* Process using packed 64-bit arithmetic when source is aligned */
  138|  6.80k|        while (len >= 8 && ((uintptr_t)buf & 7) == 0) {
  ------------------
  |  Branch (138:16): [True: 2.30k, False: 4.50k]
  |  Branch (138:28): [True: 2.12k, False: 181]
  ------------------
  139|  2.12k|            size_t chunk = MIN(ALIGN_DOWN(len, (size_t)8), (size_t)ADLER32_SWAR_MAX_BYTES);
  ------------------
  |  |  148|  2.12k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 2.12k]
  |  |  ------------------
  ------------------
  140|  2.12k|            adler32_swar(&adler, dst, buf, chunk, &sum2, COPY);
  141|  2.12k|            buf += chunk;
  142|  2.12k|            if (COPY)
  ------------------
  |  Branch (142:17): [True: 1.42k, False: 701]
  ------------------
  143|  1.42k|                dst += chunk;
  144|  2.12k|            len -= chunk;
  145|  2.12k|        }
  146|       |        /* DO4 loop avoids GCC x86 register pressure from hoisted DO8/DO16 loads. */
  147|  7.20k|        while (len >= 4) {
  ------------------
  |  Branch (147:16): [True: 2.52k, False: 4.68k]
  ------------------
  148|  2.52k|            if (COPY) {
  ------------------
  |  Branch (148:17): [True: 1.89k, False: 624]
  ------------------
  149|  1.89k|                memcpy(dst, buf, 4);
  150|  1.89k|                dst += 4;
  151|  1.89k|            }
  152|  2.52k|            len -= 4;
  153|  2.52k|            ADLER_DO4(adler, sum2, buf, 0);
  ------------------
  |  |   21|  2.52k|#define ADLER_DO4(sum1, sum2, buf, i)  {ADLER_DO2(sum1, sum2, buf, i); ADLER_DO2(sum1, sum2, buf, i+2);}
  |  |  ------------------
  |  |  |  |   20|  2.52k|#define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|  2.52k|#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.52k|#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.52k|#define ADLER_DO2(sum1, sum2, buf, i)  {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
  |  |  |  |  ------------------
  |  |  |  |  |  |   19|  2.52k|#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.52k|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  154|  2.52k|            buf += 4;
  155|  2.52k|        }
  156|  4.68k|        if (len & 2) {
  ------------------
  |  Branch (156:13): [True: 2.64k, False: 2.03k]
  ------------------
  157|  2.64k|            if (COPY) {
  ------------------
  |  Branch (157:17): [True: 1.83k, False: 809]
  ------------------
  158|  1.83k|                memcpy(dst, buf, 2);
  159|  1.83k|                dst += 2;
  160|  1.83k|            }
  161|  2.64k|            ADLER_DO2(adler, sum2, buf, 0);
  ------------------
  |  |   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);}
  |  |  ------------------
  ------------------
  162|  2.64k|            buf += 2;
  163|  2.64k|        }
  164|  4.68k|        if (len & 1) {
  ------------------
  |  Branch (164:13): [True: 2.59k, False: 2.08k]
  ------------------
  165|  2.59k|            if (COPY)
  ------------------
  |  Branch (165:17): [True: 1.81k, False: 784]
  ------------------
  166|  1.81k|                *dst = *buf;
  167|  2.59k|            ADLER_DO1(adler, sum2, buf, 0);
  ------------------
  |  |   19|  2.59k|#define ADLER_DO1(sum1, sum2, buf, i)  {(sum1) += buf[(i)]; (sum2) += (sum1);}
  ------------------
  168|  2.59k|        }
  169|  4.68k|    }
  170|  4.68k|    if (REBASE) {
  ------------------
  |  Branch (170:9): [True: 4.68k, False: 0]
  ------------------
  171|  4.68k|        adler %= BASE;
  ------------------
  |  |   13|  4.68k|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  172|  4.68k|        sum2 %= BASE;
  ------------------
  |  |   13|  4.68k|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  173|  4.68k|    }
  174|       |    /* D = B * 65536 + A, see: https://en.wikipedia.org/wiki/Adler-32. */
  175|  4.68k|    return adler | (sum2 << 16);
  176|  4.68k|}
adler32_avx2.c:adler32_swar:
   66|  2.12k|                                       uint32_t *sum2, const int COPY) {
   67|  2.12k|    uint64_t sum_even = 0, sum_odd = 0, prefix_even = 0, prefix_odd = 0;
   68|       |
   69|  2.12k|    *sum2 += *adler * (uint32_t)len;
   70|       |
   71|  2.12k|    const uint64_t *src64 = (const uint64_t *)buf;
   72|       |
   73|  2.12k|    while (len >= 16) {
  ------------------
  |  Branch (73:12): [True: 0, False: 2.12k]
  ------------------
   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.12k|    if (len >= 8) {
  ------------------
  |  Branch (97:9): [True: 2.12k, False: 0]
  ------------------
   98|  2.12k|        uint64_t v = *src64;
   99|  2.12k|        if (COPY)
  ------------------
  |  Branch (99:13): [True: 1.42k, False: 701]
  ------------------
  100|  1.42k|            memcpy(dst, &v, sizeof(v));
  101|       |
  102|  2.12k|        prefix_even += sum_even;
  103|  2.12k|        prefix_odd += sum_odd;
  104|  2.12k|        sum_even +=  v       & ADLER32_SWAR_EVEN_MASK;
  ------------------
  |  |   62|  2.12k|#define ADLER32_SWAR_EVEN_MASK   0x00FF00FF00FF00FFULL
  ------------------
  105|  2.12k|        sum_odd  += (v >> 8) & ADLER32_SWAR_EVEN_MASK;
  ------------------
  |  |   62|  2.12k|#define ADLER32_SWAR_EVEN_MASK   0x00FF00FF00FF00FFULL
  ------------------
  106|  2.12k|    }
  107|       |
  108|       |    /* Horizontal sum of 4x16-bit lanes for s1 */
  109|  2.12k|    *adler += (uint32_t)(((sum_even + sum_odd) * ADLER32_SWAR_HSUM) >> 48);
  ------------------
  |  |   63|  2.12k|#define ADLER32_SWAR_HSUM        0x1000100010001ULL
  ------------------
  110|       |
  111|       |    /* Widen prefix sums to 32-bit pairs and horizontal sum for s2 */
  112|  2.12k|    uint64_t pe_lo = prefix_even & 0xFFFF0000FFFFULL;
  113|  2.12k|    uint64_t pe_hi = (prefix_even >> 16) & 0xFFFF0000FFFFULL;
  114|  2.12k|    uint64_t po_lo = prefix_odd & 0xFFFF0000FFFFULL;
  115|  2.12k|    uint64_t po_hi = (prefix_odd >> 16) & 0xFFFF0000FFFFULL;
  116|       |
  117|  2.12k|    *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.12k|#if BYTE_ORDER == LITTLE_ENDIAN
  123|  2.12k|    *sum2 += 2 * (uint32_t)((sum_even * 0x4000300020001ULL) >> 48)
  124|  2.12k|           +     (uint32_t)((sum_odd  * ADLER32_SWAR_HSUM) >> 48)
  ------------------
  |  |   63|  2.12k|#define ADLER32_SWAR_HSUM        0x1000100010001ULL
  ------------------
  125|  2.12k|           + 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.12k|}

adler32_avx2:
  164|  2.92k|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|  2.92k|}
adler32_copy_avx2:
  168|  19.4k|Z_INTERNAL uint32_t adler32_copy_avx2(uint32_t adler, uint8_t *dst, const uint8_t *src, size_t len) {
  169|  19.4k|    return adler32_copy_impl(adler, dst, src, len, 1);
  170|  19.4k|}
adler32_avx2.c:adler32_copy_impl:
   21|  22.3k|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|  22.3k|    uint32_t adler0, adler1;
   23|  22.3k|    adler1 = (adler >> 16) & 0xffff;
   24|  22.3k|    adler0 = adler & 0xffff;
   25|       |
   26|  30.6k|rem_peel:
   27|  30.6k|    if (len < 16) {
  ------------------
  |  Branch (27:9): [True: 4.68k, False: 26.0k]
  ------------------
   28|  4.68k|        return adler32_copy_tail(adler0, dst, src, len, adler1, 1, 15, COPY);
   29|  26.0k|    } else if (len < 32) {
  ------------------
  |  Branch (29:16): [True: 4.91k, False: 21.0k]
  ------------------
   30|  4.91k|        if (COPY) {
  ------------------
  |  Branch (30:13): [True: 3.51k, False: 1.40k]
  ------------------
   31|  3.51k|            return adler32_copy_sse42(adler, dst, src, len);
   32|  3.51k|        } else {
   33|  1.40k|            return adler32_ssse3(adler, src, len);
   34|  1.40k|        }
   35|  4.91k|    }
   36|       |
   37|  21.0k|    __m256i vs1, vs2, vs2_0;
   38|       |
   39|  21.0k|    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|  21.0k|                                           46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33);
   41|  21.0k|    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|  21.0k|                                             14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1);
   43|  21.0k|    const __m256i dot3v = _mm256_set1_epi16(1);
   44|  21.0k|    const __m256i zero = _mm256_setzero_si256();
   45|       |
   46|   183k|    while (len >= 32) {
  ------------------
  |  Branch (46:12): [True: 162k, False: 21.0k]
  ------------------
   47|   162k|        vs1 = _mm256_zextsi128_si256(_mm_cvtsi32_si128(adler0));
   48|   162k|        vs2 = _mm256_zextsi128_si256(_mm_cvtsi32_si128(adler1));
   49|   162k|        __m256i vs1_0 = vs1;
   50|   162k|        __m256i vs3 = _mm256_setzero_si256();
   51|   162k|        vs2_0 = vs3;
   52|       |
   53|   162k|        size_t k = ALIGN_DOWN(MIN(len, NMAX), 32);
  ------------------
  |  |  293|   325k|    ((value) & ~((align) - 1))
  |  |  ------------------
  |  |  |  Branch (293:7): [True: 141k, False: 21.0k]
  |  |  ------------------
  ------------------
   54|   162k|        len -= k;
   55|       |
   56|  13.5M|        while (k >= 64) {
  ------------------
  |  Branch (56:16): [True: 13.4M, False: 162k]
  ------------------
   57|  13.4M|            __m256i vbuf = _mm256_loadu_si256((__m256i*)src);
   58|  13.4M|            __m256i vbuf_0 = _mm256_loadu_si256((__m256i*)(src + 32));
   59|  13.4M|            src += 64;
   60|  13.4M|            k -= 64;
   61|       |
   62|  13.4M|            __m256i vs1_sad = _mm256_sad_epu8(vbuf, zero);
   63|  13.4M|            __m256i vs1_sad2 = _mm256_sad_epu8(vbuf_0, zero);
   64|       |
   65|  13.4M|            if (COPY) {
  ------------------
  |  Branch (65:17): [True: 7.63M, False: 5.79M]
  ------------------
   66|  7.63M|                _mm256_storeu_si256((__m256i*)dst, vbuf);
   67|  7.63M|                _mm256_storeu_si256((__m256i*)(dst + 32), vbuf_0);
   68|  7.63M|                dst += 64;
   69|  7.63M|            }
   70|       |
   71|  13.4M|            vs1 = _mm256_add_epi32(vs1, vs1_sad);
   72|  13.4M|            vs3 = _mm256_add_epi32(vs3, vs1_0);
   73|  13.4M|            __m256i v_short_sum2 = _mm256_maddubs_epi16(vbuf, dot2v); // sum 32 uint8s to 16 shorts
   74|  13.4M|            __m256i v_short_sum2_0 = _mm256_maddubs_epi16(vbuf_0, dot2v_0); // sum 32 uint8s to 16 shorts
   75|  13.4M|            __m256i vsum2 = _mm256_madd_epi16(v_short_sum2, dot3v); // sum 16 shorts to 8 uint32s
   76|  13.4M|            __m256i vsum2_0 = _mm256_madd_epi16(v_short_sum2_0, dot3v); // sum 16 shorts to 8 uint32s
   77|  13.4M|            vs1 = _mm256_add_epi32(vs1_sad2, vs1);
   78|  13.4M|            vs2 = _mm256_add_epi32(vsum2, vs2);
   79|  13.4M|            vs2_0 = _mm256_add_epi32(vsum2_0, vs2_0);
   80|  13.4M|            vs1_0 = vs1;
   81|  13.4M|        }
   82|       |
   83|   162k|        vs2 = _mm256_add_epi32(vs2_0, vs2);
   84|   162k|        vs3 = _mm256_slli_epi32(vs3, 6);
   85|   162k|        vs2 = _mm256_add_epi32(vs3, vs2);
   86|   162k|        vs3 = _mm256_setzero_si256();
   87|       |
   88|   320k|        while (k >= 32) {
  ------------------
  |  Branch (88:16): [True: 158k, False: 162k]
  ------------------
   89|       |            /*
   90|       |               vs1 = adler + sum(c[i])
   91|       |               vs2 = sum2 + 32 vs1 + sum( (32-i+1) c[i] )
   92|       |            */
   93|   158k|            __m256i vbuf = _mm256_loadu_si256((__m256i*)src);
   94|   158k|            src += 32;
   95|   158k|            k -= 32;
   96|       |
   97|   158k|            __m256i vs1_sad = _mm256_sad_epu8(vbuf, zero); // Sum of abs diff, resulting in 2 x int32's
   98|       |
   99|   158k|            if (COPY) {
  ------------------
  |  Branch (99:17): [True: 90.4k, False: 67.8k]
  ------------------
  100|  90.4k|                _mm256_storeu_si256((__m256i*)dst, vbuf);
  101|  90.4k|                dst += 32;
  102|  90.4k|            }
  103|       |
  104|   158k|            vs1 = _mm256_add_epi32(vs1, vs1_sad);
  105|   158k|            vs3 = _mm256_add_epi32(vs3, vs1_0);
  106|   158k|            __m256i v_short_sum2 = _mm256_maddubs_epi16(vbuf, dot2v_0); // sum 32 uint8s to 16 shorts
  107|   158k|            __m256i vsum2 = _mm256_madd_epi16(v_short_sum2, dot3v); // sum 16 shorts to 8 uint32s
  108|   158k|            vs2 = _mm256_add_epi32(vsum2, vs2);
  109|   158k|            vs1_0 = vs1;
  110|   158k|        }
  111|       |
  112|       |        /* Defer the multiplication with 32 to outside of the loop */
  113|   162k|        vs3 = _mm256_slli_epi32(vs3, 5);
  114|   162k|        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|   162k|         adler0 = partial_hsum256(vs1) % BASE;
  ------------------
  |  |   13|   162k|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  152|   162k|         adler1 = hsum256(vs2) % BASE;
  ------------------
  |  |   13|   162k|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  153|   162k|    }
  154|       |
  155|  21.0k|    adler = adler0 | (adler1 << 16);
  156|       |
  157|  21.0k|    if (len) {
  ------------------
  |  Branch (157:9): [True: 8.30k, False: 12.7k]
  ------------------
  158|  8.30k|        goto rem_peel;
  159|  8.30k|    }
  160|       |
  161|  12.7k|    return adler;
  162|  21.0k|}

adler32_avx2.c:partial_hsum256:
   20|   162k|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|   162k|    const __m256i perm_vec = _mm256_setr_epi32(0, 2, 4, 6, 1, 1, 1, 1);
   24|   162k|    __m256i non_zero = _mm256_permutevar8x32_epi32(x, perm_vec);
   25|   162k|    __m128i non_zero_sse = _mm256_castsi256_si128(non_zero);
   26|   162k|    __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|   162k|    return (uint32_t)_mm_cvtsi128_si32(sum3);
   29|   162k|}
adler32_avx2.c:hsum256:
   12|   162k|static inline uint32_t hsum256(__m256i x) {
   13|   162k|    __m128i sum1  = _mm_add_epi32(_mm256_extracti128_si256(x, 1),
   14|   162k|                                  _mm256_castsi256_si128(x));
   15|   162k|    __m128i sum2  = _mm_add_epi32(sum1, _mm_unpackhi_epi64(sum1, sum1));
   16|       |    __m128i sum3  = _mm_add_epi32(sum2, _mm_shuffle_epi32(sum2, 1));
   17|   162k|    return (uint32_t)_mm_cvtsi128_si32(sum3);
   18|   162k|}

adler32_copy_sse42:
   17|  3.51k|Z_INTERNAL uint32_t adler32_copy_sse42(uint32_t adler, uint8_t *dst, const uint8_t *src, size_t len) {
   18|  3.51k|    uint32_t adler0, adler1;
   19|  3.51k|    adler1 = (adler >> 16) & 0xffff;
   20|  3.51k|    adler0 = adler & 0xffff;
   21|       |
   22|  6.82k|rem_peel:
   23|  6.82k|    if (UNLIKELY(len < 16))
  ------------------
  |  |  258|  6.82k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 3.31k, False: 3.51k]
  |  |  ------------------
  ------------------
   24|  3.31k|       return adler32_copy_tail(adler0, dst, src, len, adler1, 1, 15, 1);
   25|       |
   26|  3.51k|    __m128i vbuf, vbuf_0;
   27|  3.51k|    __m128i vs1_0, vs3, vs1, vs2, vs2_0, v_sad_sum1, v_short_sum2, v_short_sum2_0,
   28|  3.51k|            v_sad_sum2, vsum2, vsum2_0;
   29|  3.51k|    __m128i zero = _mm_setzero_si128();
   30|  3.51k|    const __m128i dot2v = _mm_setr_epi8(32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17);
   31|  3.51k|    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.51k|    const __m128i dot3v = _mm_set1_epi16(1);
   33|       |
   34|  7.02k|    while (len >= 16) {
  ------------------
  |  Branch (34:12): [True: 3.51k, False: 3.51k]
  ------------------
   35|  3.51k|        size_t k = ALIGN_DOWN(MIN(len, NMAX), 16);
  ------------------
  |  |  293|  7.02k|    ((value) & ~((align) - 1))
  |  |  ------------------
  |  |  |  Branch (293:7): [True: 0, False: 3.51k]
  |  |  ------------------
  ------------------
   36|  3.51k|        len -= k;
   37|       |
   38|  3.51k|        vs1 = _mm_cvtsi32_si128(adler0);
   39|  3.51k|        vs2 = _mm_cvtsi32_si128(adler1);
   40|       |
   41|  3.51k|        vs3 = _mm_setzero_si128();
   42|  3.51k|        vs2_0 = _mm_setzero_si128();
   43|  3.51k|        vs1_0 = vs1;
   44|       |
   45|  3.51k|        while (k >= 32) {
  ------------------
  |  Branch (45:16): [True: 0, False: 3.51k]
  ------------------
   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.51k|        vs2 = _mm_add_epi32(vs2_0, vs2);
   76|  3.51k|        vs3 = _mm_slli_epi32(vs3, 5);
   77|  3.51k|        vs2 = _mm_add_epi32(vs3, vs2);
   78|  3.51k|        vs3 = _mm_setzero_si128();
   79|       |
   80|  7.02k|        while (k >= 16) {
  ------------------
  |  Branch (80:16): [True: 3.51k, False: 3.51k]
  ------------------
   81|       |            /*
   82|       |               vs1 = adler + sum(c[i])
   83|       |               vs2 = sum2 + 16 vs1 + sum( (16-i+1) c[i] )
   84|       |            */
   85|  3.51k|            vbuf = _mm_loadu_si128((__m128i*)src);
   86|  3.51k|            src += 16;
   87|  3.51k|            k -= 16;
   88|       |
   89|  3.51k|            v_sad_sum1 = _mm_sad_epu8(vbuf, zero);
   90|  3.51k|            v_short_sum2 = _mm_maddubs_epi16(vbuf, dot2v_0);
   91|       |
   92|  3.51k|            vs1 = _mm_add_epi32(v_sad_sum1, vs1);
   93|  3.51k|            vs3 = _mm_add_epi32(vs1_0, vs3);
   94|  3.51k|            vsum2 = _mm_madd_epi16(v_short_sum2, dot3v);
   95|  3.51k|            vs2 = _mm_add_epi32(vsum2, vs2);
   96|  3.51k|            vs1_0 = vs1;
   97|       |
   98|  3.51k|            _mm_storeu_si128((__m128i*)dst, vbuf);
   99|  3.51k|            dst += 16;
  100|  3.51k|        }
  101|       |
  102|  3.51k|        vs3 = _mm_slli_epi32(vs3, 4);
  103|  3.51k|        vs2 = _mm_add_epi32(vs2, vs3);
  104|       |
  105|  3.51k|        adler0 = partial_hsum(vs1) % BASE;
  ------------------
  |  |   13|  3.51k|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  106|  3.51k|        adler1 = hsum(vs2) % BASE;
  ------------------
  |  |   13|  3.51k|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  107|  3.51k|    }
  108|       |
  109|       |    /* If this is true, there's fewer than 16 elements remaining */
  110|  3.51k|    if (len) {
  ------------------
  |  Branch (110:9): [True: 3.31k, False: 193]
  ------------------
  111|  3.31k|        goto rem_peel;
  112|  3.31k|    }
  113|       |
  114|    193|    return adler0 | (adler1 << 16);
  115|  3.51k|}

adler32_ssse3:
   17|  1.40k|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.40k|    uint32_t sum2 = (adler >> 16) & 0xffff;
   20|  1.40k|    adler &= 0xffff;
   21|       |
   22|       |    /* in case user likes doing a byte at a time, keep it fast */
   23|  1.40k|    if (UNLIKELY(len == 1))
  ------------------
  |  |  258|  1.40k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 1.40k]
  |  |  ------------------
  ------------------
   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.40k|    if (UNLIKELY(len < 16))
  ------------------
  |  |  258|  1.40k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 1.40k]
  |  |  ------------------
  ------------------
   28|      0|        return adler32_copy_tail(adler, NULL, buf, len, sum2, 1, 15, 0);
   29|       |
   30|  1.40k|    const __m128i dot2v = _mm_setr_epi8(32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17);
   31|  1.40k|    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.40k|    const __m128i dot3v = _mm_set1_epi16(1);
   33|  1.40k|    const __m128i zero = _mm_setzero_si128();
   34|       |
   35|  1.40k|    __m128i vbuf, vs1_0, vs3, vs1, vs2, vs2_0, v_sad_sum1, v_short_sum2, v_short_sum2_0,
   36|  1.40k|            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.40k|    size_t n = NMAX;
  ------------------
  |  |   14|  1.40k|#define NMAX 5552
  ------------------
   43|  1.40k|    size_t k = 0;
   44|       |
   45|  1.40k|    if (len < 32) {
  ------------------
  |  Branch (45:9): [True: 1.40k, 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.40k|        vbuf = _mm_loadu_si128((__m128i*)buf);
   51|  1.40k|        len -= 16;
   52|  1.40k|        buf += 16;
   53|  1.40k|        vs1 = _mm_cvtsi32_si128(adler);
   54|  1.40k|        vs2 = _mm_cvtsi32_si128(sum2);
   55|  1.40k|        vs3 = _mm_setzero_si128();
   56|  1.40k|        vs1_0 = vs1;
   57|  1.40k|        goto unaligned_jmp;
   58|  1.40k|    }
   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.40k|    while (len >= 16) {
  ------------------
  |  Branch (71:12): [True: 0, False: 1.40k]
  ------------------
   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.40k|        while (k >= 16) {
  ------------------
  |  Branch (111:16): [True: 0, False: 1.40k]
  ------------------
  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.40k|unaligned_jmp:
  121|  1.40k|            v_sad_sum1 = _mm_sad_epu8(vbuf, zero);
  122|  1.40k|            vs1 = _mm_add_epi32(v_sad_sum1, vs1);
  123|  1.40k|            vs3 = _mm_add_epi32(vs1_0, vs3);
  124|  1.40k|            v_short_sum2 = _mm_maddubs_epi16(vbuf, dot2v_0);
  125|  1.40k|            vsum2 = _mm_madd_epi16(v_short_sum2, dot3v);
  126|  1.40k|            vs2 = _mm_add_epi32(vsum2, vs2);
  127|  1.40k|            vs1_0 = vs1;
  128|  1.40k|        }
  129|       |
  130|  1.40k|        vs3 = _mm_slli_epi32(vs3, 4);
  131|  1.40k|        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.40k|        adler = partial_hsum(vs1) % BASE;
  ------------------
  |  |   13|  1.40k|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  137|  1.40k|        sum2 = hsum(vs2) % BASE;
  ------------------
  |  |   13|  1.40k|#define BASE 65521U     /* largest prime smaller than 65536 */
  ------------------
  138|  1.40k|        n = NMAX;
  ------------------
  |  |   14|  1.40k|#define NMAX 5552
  ------------------
  139|  1.40k|    }
  140|       |
  141|       |    /* Process tail (len < 16).  */
  142|  1.40k|    return adler32_copy_tail(adler, NULL, buf, len, sum2, len != 0, 15, 0);
  143|      0|}

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

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

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

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

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.01k|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.01k|    len = MIN(len, left);
  ------------------
  |  |  148|  3.01k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 3.01k]
  |  |  ------------------
  ------------------
  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.01k|#ifndef HAVE_MASKED_READWRITE
  270|  3.01k|    if (UNLIKELY(left < sizeof(chunk_t))) {
  ------------------
  |  |  258|  3.01k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 231, False: 2.78k]
  |  |  ------------------
  ------------------
  271|  3.38k|        while (len > 0) {
  ------------------
  |  Branch (271:16): [True: 3.14k, False: 231]
  ------------------
  272|  3.14k|            *out++ = *from++;
  273|  3.14k|            --len;
  274|  3.14k|        }
  275|       |
  276|    231|        return out;
  277|    231|    }
  278|  2.78k|#endif
  279|       |
  280|  2.78k|    if (len)
  ------------------
  |  Branch (280:9): [True: 2.78k, False: 0]
  ------------------
  281|  2.78k|        out = CHUNKMEMSET(out, from, len);
  ------------------
  |  |  125|  2.78k|#define CHUNKMEMSET      chunkmemset_avx2
  ------------------
  282|       |
  283|  2.78k|    return out;
  284|  3.01k|}
chunkset_avx2.c:chunkmemset_avx2:
  111|  1.67M|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.67M|    Assert(from != out, "chunkmemset cannot have a distance 0");
  115|       |
  116|  1.67M|    chunk_t chunk_load;
  117|  1.67M|    size_t chunk_mod = 0;
  118|  1.67M|    size_t adv_amount;
  119|  1.67M|    size_t dist = (size_t)ABS(out - from);
  ------------------
  |  |  152|  1.67M|#define ABS(a) ((a) < 0 ? -(a) : (a))
  |  |  ------------------
  |  |  |  Branch (152:17): [True: 1.12k, False: 1.67M]
  |  |  ------------------
  ------------------
  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.67M|    if (out < from && dist < len) {
  ------------------
  |  Branch (125:9): [True: 1.12k, False: 1.67M]
  |  Branch (125:23): [True: 0, False: 1.12k]
  ------------------
  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.67M|    if (dist >= len || dist >= sizeof(chunk_t)) {
  ------------------
  |  Branch (145:9): [True: 1.12k, False: 1.67M]
  |  Branch (145:24): [True: 0, False: 1.67M]
  ------------------
  146|  1.12k|        return CHUNKCOPY(out, from, len);
  ------------------
  |  |  123|  1.12k|#define CHUNKCOPY        chunkcopy_avx2
  ------------------
  147|  1.12k|    }
  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.67M|#ifdef HAVE_HALF_CHUNK
  157|  1.67M|    if (dist > 1 && len <= sizeof(halfchunk_t)) {
  ------------------
  |  Branch (157:9): [True: 0, False: 1.67M]
  |  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.67M|#endif
  175|       |
  176|  1.67M|#ifdef HAVE_CHUNKMEMSET_1
  177|       |    /* Broadcast + chunk store beats memset on NEON/AVX2/AVX-512 */
  178|  1.67M|    if (dist == 1) {
  ------------------
  |  Branch (178:9): [True: 1.67M, False: 0]
  ------------------
  179|  1.67M|        chunkmemset_1(from, &chunk_load);
  180|  1.67M|    } 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.67M|    if (len <= sizeof(chunk_t)) {
  ------------------
  |  Branch (204:9): [True: 968, False: 1.67M]
  ------------------
  205|       |#ifdef HAVE_MASKED_READWRITE
  206|       |        storechunk_masked(out, &chunk_load, len);
  207|       |#else
  208|    968|        storechunk(out, &chunk_load);
  209|    968|#endif
  210|    968|        return out + len;
  211|    968|    }
  212|       |
  213|  1.67M|    adv_amount = sizeof(chunk_t) - chunk_mod;
  214|       |
  215|  8.36M|    while (len >= (2 * sizeof(chunk_t))) {
  ------------------
  |  Branch (215:12): [True: 6.69M, False: 1.67M]
  ------------------
  216|  6.69M|        storechunk(out, &chunk_load);
  217|  6.69M|        storechunk(out + adv_amount, &chunk_load);
  218|  6.69M|        out += 2 * adv_amount;
  219|  6.69M|        len -= 2 * adv_amount;
  220|  6.69M|    }
  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.67M|    while (len >= sizeof(chunk_t)) {
  ------------------
  |  Branch (226:12): [True: 1.40k, False: 1.67M]
  ------------------
  227|  1.40k|        storechunk(out, &chunk_load);
  228|  1.40k|        len -= adv_amount;
  229|  1.40k|        out += adv_amount;
  230|  1.40k|    }
  231|       |
  232|  1.67M|#ifdef HAVE_HALF_CHUNK
  233|  1.67M|rem_bytes:
  234|  1.67M|#endif
  235|  1.67M|    if (len) {
  ------------------
  |  Branch (235:9): [True: 1.67M, False: 82]
  ------------------
  236|       |#ifdef HAVE_MASKED_READWRITE
  237|       |        storechunk_masked(out, &chunk_load, len);
  238|       |        out += len;
  239|       |#else
  240|  1.67M|        uint8_t *chunk_p = (uint8_t *)&chunk_load;
  241|  1.67M|        if (len & 16) { memcpy(out, chunk_p, 16); out += 16; chunk_p += 16; }
  ------------------
  |  Branch (241:13): [True: 1.11k, False: 1.67M]
  ------------------
  242|  1.67M|        if (len & 8) { memcpy(out, chunk_p, 8); out += 8; chunk_p += 8; }
  ------------------
  |  Branch (242:13): [True: 965, False: 1.67M]
  ------------------
  243|  1.67M|        if (len & 4) { memcpy(out, chunk_p, 4); out += 4; chunk_p += 4; }
  ------------------
  |  Branch (243:13): [True: 1.06k, False: 1.67M]
  ------------------
  244|  1.67M|        if (len & 2) { memcpy(out, chunk_p, 2); out += 2; chunk_p += 2; }
  ------------------
  |  Branch (244:13): [True: 1.67M, False: 1.14k]
  ------------------
  245|  1.67M|        if (len & 1) { *out++ = *chunk_p; }
  ------------------
  |  Branch (245:13): [True: 1.20k, False: 1.67M]
  ------------------
  246|  1.67M|#endif
  247|  1.67M|    }
  248|       |
  249|  1.67M|    return out;
  250|  1.67M|}
chunkset_avx2.c:CHUNKCOPY_SAFE:
  287|  1.12k|{
  288|  1.12k|    if (out == from)
  ------------------
  |  Branch (288:9): [True: 0, False: 1.12k]
  ------------------
  289|      0|        return out + len;
  290|       |
  291|  1.12k|    size_t safelen = (safe - out);
  292|  1.12k|    len = MIN(len, safelen);
  ------------------
  |  |  148|  1.12k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 1.12k]
  |  |  ------------------
  ------------------
  293|       |
  294|  1.12k|#ifndef HAVE_MASKED_READWRITE
  295|  1.12k|    size_t from_dist = (size_t)ABS(safe - from);
  ------------------
  |  |  152|  1.12k|#define ABS(a) ((a) < 0 ? -(a) : (a))
  |  |  ------------------
  |  |  |  Branch (152:17): [True: 1.12k, False: 0]
  |  |  ------------------
  ------------------
  296|  1.12k|    if (UNLIKELY(from_dist < sizeof(chunk_t) || safelen < sizeof(chunk_t))) {
  ------------------
  |  |  258|  2.24k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 1.12k]
  |  |  |  Branch (258:53): [True: 0, False: 1.12k]
  |  |  |  Branch (258:53): [True: 0, False: 1.12k]
  |  |  ------------------
  ------------------
  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.12k|#endif
  304|       |
  305|  1.12k|    return CHUNKMEMSET(out, from, len);
  ------------------
  |  |  125|  1.12k|#define CHUNKMEMSET      chunkmemset_avx2
  ------------------
  306|  1.12k|}
chunkset_avx2.c:chunksize_avx2:
    9|  1.67M|static inline size_t CHUNKSIZE(void) {
   10|  1.67M|    return sizeof(chunk_t);
   11|  1.67M|}
chunkset_avx2.c:chunkcopy_avx2:
   24|  1.33k|static inline uint8_t* CHUNKCOPY(uint8_t *out, uint8_t const *from, size_t len) {
   25|  1.33k|    Assert(len > 0, "chunkcopy should never have a length 0");
   26|  1.33k|    chunk_t chunk;
   27|  1.33k|    size_t align = ((len - 1) % sizeof(chunk_t)) + 1;
   28|  1.33k|    loadchunk(from, &chunk);
   29|  1.33k|    storechunk(out, &chunk);
   30|  1.33k|    out += align;
   31|  1.33k|    from += align;
   32|  1.33k|    len -= align;
   33|  11.9k|    while (len > 0) {
  ------------------
  |  Branch (33:12): [True: 10.6k, False: 1.33k]
  ------------------
   34|  10.6k|        loadchunk(from, &chunk);
   35|  10.6k|        storechunk(out, &chunk);
   36|  10.6k|        out += sizeof(chunk_t);
   37|  10.6k|        from += sizeof(chunk_t);
   38|  10.6k|        len -= sizeof(chunk_t);
   39|  10.6k|    }
   40|  1.33k|    return out;
   41|  1.33k|}

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

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

deflate.c:flush_pending_inline:
  122|  10.6k|Z_FORCEINLINE static void flush_pending_inline(PREFIX3(stream) *strm) {
  123|  10.6k|    uint32_t len;
  124|  10.6k|    deflate_state *s = strm->state;
  125|       |
  126|  10.6k|    zng_tr_flush_bits(s);
  127|  10.6k|    len = MIN(s->pending, strm->avail_out);
  ------------------
  |  |  148|  10.6k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 10.6k]
  |  |  ------------------
  ------------------
  128|  10.6k|    if (len == 0)
  ------------------
  |  Branch (128:9): [True: 3.04k, False: 7.60k]
  ------------------
  129|  3.04k|        return;
  130|       |
  131|  7.60k|    Tracev((stderr, "[FLUSH]"));
  132|  7.60k|    memcpy(strm->next_out, s->pending_out, len);
  133|  7.60k|    strm->next_out  += len;
  134|  7.60k|    s->pending_out  += len;
  135|  7.60k|    strm->total_out += len;
  136|  7.60k|    strm->avail_out -= len;
  137|  7.60k|    s->pending      -= len;
  138|  7.60k|    if (s->pending == 0)
  ------------------
  |  Branch (138:9): [True: 7.60k, False: 0]
  ------------------
  139|  7.60k|        s->pending_out = s->pending_buf;
  140|  7.60k|}
deflate.c:read_buf:
  158|  14.7k|Z_FORCEINLINE static unsigned read_buf(PREFIX3(stream) *strm, unsigned char *buf, unsigned size) {
  159|  14.7k|    deflate_state *s = strm->state;
  160|  14.7k|    uint32_t len = MIN(strm->avail_in, size);
  ------------------
  |  |  148|  14.7k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 11.7k, False: 3.04k]
  |  |  ------------------
  ------------------
  161|       |
  162|  14.7k|    if (len == 0)
  ------------------
  |  Branch (162:9): [True: 0, False: 14.7k]
  ------------------
  163|      0|        return 0;
  164|       |
  165|  14.7k|    if (!DEFLATE_NEED_CHECKSUM(strm)) {
  ------------------
  |  |  487|  14.7k|#  define DEFLATE_NEED_CHECKSUM(strm) 1
  ------------------
  |  Branch (165:9): [Folded, False: 14.7k]
  ------------------
  166|      0|        memcpy(buf, strm->next_in, len);
  167|      0|#ifdef GZIP
  168|  14.7k|    } else if (s->wrap == 2) {
  ------------------
  |  Branch (168:16): [True: 0, False: 14.7k]
  ------------------
  169|      0|        strm->adler = FUNCTABLE_CALL(crc32_copy)(strm->adler, buf, strm->next_in, len);
  ------------------
  |  |   45|      0|#  define FUNCTABLE_CALL(name) functable.name
  ------------------
  170|      0|#endif
  171|  14.7k|    } else if (s->wrap == 1) {
  ------------------
  |  Branch (171:16): [True: 14.7k, False: 0]
  ------------------
  172|  14.7k|        strm->adler = FUNCTABLE_CALL(adler32_copy)(strm->adler, buf, strm->next_in, len);
  ------------------
  |  |   45|  14.7k|#  define FUNCTABLE_CALL(name) functable.name
  ------------------
  173|  14.7k|    } else {
  174|      0|        memcpy(buf, strm->next_in, len);
  175|      0|    }
  176|       |
  177|  14.7k|    strm->avail_in -= len;
  178|  14.7k|    strm->next_in  += len;
  179|  14.7k|    strm->total_in += len;
  180|  14.7k|    return len;
  181|  14.7k|}
deflate_slow.c:zng_tr_tally_dist:
   87|  1.67M|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.67M|    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.67M|#  if OPTIMAL_CMP >= 32
   99|  1.67M|    zng_memwrite_4(&s->sym_buf[sym_next], Z_U32_TO_LE(dist | ((uint32_t)len << 16)));
  ------------------
  |  |   84|  1.67M|#  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.67M|    s->sym_next = sym_next + 3;
  106|  1.67M|#endif
  107|  1.67M|    dist--;
  108|  1.67M|    Assert(dist < MAX_DIST(s) && (uint16_t)d_code(dist) < (uint16_t)D_CODES,
  109|  1.67M|        "zng_tr_tally: bad match");
  110|       |
  111|  1.67M|    s->dyn_ltree[zng_length_code[len] + LITERALS + 1].Freq++;
  ------------------
  |  |   45|  1.67M|#define LITERALS  256
  ------------------
                  s->dyn_ltree[zng_length_code[len] + LITERALS + 1].Freq++;
  ------------------
  |  |  125|  1.67M|#define Freq fc.freq
  ------------------
  112|  1.67M|    s->dyn_dtree[d_code(dist)].Freq++;
  ------------------
  |  |  434|  1.67M|#define d_code(dist) ((dist) < 256 ? zng_dist_code[dist] : zng_dist_code[256+((dist)>>7)])
  |  |  ------------------
  |  |  |  Branch (434:23): [True: 1.67M, False: 1.32k]
  |  |  ------------------
  ------------------
                  s->dyn_dtree[d_code(dist)].Freq++;
  ------------------
  |  |  125|  1.67M|#define Freq fc.freq
  ------------------
  113|  1.67M|    return (s->sym_next == s->sym_end);
  114|  1.67M|}
deflate_slow.c:zng_tr_tally_lit:
   64|  3.81k|static inline int zng_tr_tally_lit(deflate_state *s, unsigned char c) {
   65|       |    /* c is the unmatched char */
   66|  3.81k|    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|  3.81k|#  if OPTIMAL_CMP >= 32
   73|  3.81k|    zng_memwrite_4(&s->sym_buf[sym_next], Z_U32_TO_LE((uint32_t)c << 16));
  ------------------
  |  |   84|  3.81k|#  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|  3.81k|    s->sym_next = sym_next + 3;
   80|  3.81k|#endif
   81|  3.81k|    s->dyn_ltree[c].Freq++;
  ------------------
  |  |  125|  3.81k|#define Freq fc.freq
  ------------------
   82|  3.81k|    Tracevv((stderr, "%c", c));
   83|  3.81k|    Assert(c <= (STD_MAX_MATCH-STD_MIN_MATCH), "zng_tr_tally: bad literal");
   84|  3.81k|    return (s->sym_next == s->sym_end);
   85|  3.81k|}
deflate_stored.c:read_buf:
  158|  1.52k|Z_FORCEINLINE static unsigned read_buf(PREFIX3(stream) *strm, unsigned char *buf, unsigned size) {
  159|  1.52k|    deflate_state *s = strm->state;
  160|  1.52k|    uint32_t len = MIN(strm->avail_in, size);
  ------------------
  |  |  148|  1.52k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 1.52k]
  |  |  ------------------
  ------------------
  161|       |
  162|  1.52k|    if (len == 0)
  ------------------
  |  Branch (162:9): [True: 0, False: 1.52k]
  ------------------
  163|      0|        return 0;
  164|       |
  165|  1.52k|    if (!DEFLATE_NEED_CHECKSUM(strm)) {
  ------------------
  |  |  487|  1.52k|#  define DEFLATE_NEED_CHECKSUM(strm) 1
  ------------------
  |  Branch (165:9): [Folded, False: 1.52k]
  ------------------
  166|      0|        memcpy(buf, strm->next_in, len);
  167|      0|#ifdef GZIP
  168|  1.52k|    } else if (s->wrap == 2) {
  ------------------
  |  Branch (168:16): [True: 0, False: 1.52k]
  ------------------
  169|      0|        strm->adler = FUNCTABLE_CALL(crc32_copy)(strm->adler, buf, strm->next_in, len);
  ------------------
  |  |   45|      0|#  define FUNCTABLE_CALL(name) functable.name
  ------------------
  170|      0|#endif
  171|  1.52k|    } else if (s->wrap == 1) {
  ------------------
  |  Branch (171:16): [True: 1.52k, False: 0]
  ------------------
  172|  1.52k|        strm->adler = FUNCTABLE_CALL(adler32_copy)(strm->adler, buf, strm->next_in, len);
  ------------------
  |  |   45|  1.52k|#  define FUNCTABLE_CALL(name) functable.name
  ------------------
  173|  1.52k|    } else {
  174|      0|        memcpy(buf, strm->next_in, len);
  175|      0|    }
  176|       |
  177|  1.52k|    strm->avail_in -= len;
  178|  1.52k|    strm->next_in  += len;
  179|  1.52k|    strm->total_in += len;
  180|  1.52k|    return len;
  181|  1.52k|}
trees.c:bi_reverse:
  145|  28.7k|Z_FORCEINLINE static uint16_t bi_reverse(uint16_t code, int len) {
  146|       |    /* code: the value to invert */
  147|       |    /* len: its bit length */
  148|  28.7k|    Assert(len >= 1 && len <= 15, "code length must be 1-15");
  149|  28.7k|    return zng_bitreverse16(code) >> (16 - len);
  150|  28.7k|}

deflate_slow:
   18|  6.08k|Z_INTERNAL block_state deflate_slow(deflate_state *s, int flush) {
   19|  6.08k|    match_func longest_match;
   20|  6.08k|    insert_batch_func insert_batch;
   21|  6.08k|    unsigned char *window = s->window;
   22|  6.08k|    int bflush;              /* set if current block must be flushed */
   23|  6.08k|    int level = s->level;
   24|       |
   25|  6.08k|    if (level >= 9) {
  ------------------
  |  Branch (25:9): [True: 6.08k, False: 0]
  ------------------
   26|  6.08k|        longest_match = FUNCTABLE_FPTR(longest_match_roll);
  ------------------
  |  |   46|  6.08k|#  define FUNCTABLE_FPTR(name) functable.name
  ------------------
   27|  6.08k|        insert_batch = insert_roll_batch;
   28|  6.08k|    } else {
   29|      0|        longest_match = FUNCTABLE_FPTR(longest_match);
  ------------------
  |  |   46|      0|#  define FUNCTABLE_FPTR(name) functable.name
  ------------------
   30|      0|        insert_batch = insert_knuth_batch;
   31|      0|    }
   32|       |
   33|       |    /* Process the input block. */
   34|  3.36M|    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.36M|        if (UNLIKELY(s->lookahead < MIN_LOOKAHEAD)) {
  ------------------
  |  |  258|  3.36M|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 27.5k, False: 3.33M]
  |  |  ------------------
  ------------------
   41|  27.5k|            PREFIX(fill_window)(s);
  ------------------
  |  |  121|  27.5k|#  define PREFIX(x) zng_ ## x
  ------------------
   42|  27.5k|            if (UNLIKELY(s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH)) {
  ------------------
  |  |  258|  40.4k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 3.04k, False: 24.4k]
  |  |  |  Branch (258:53): [True: 12.9k, False: 14.5k]
  |  |  |  Branch (258:53): [True: 3.04k, False: 9.87k]
  |  |  ------------------
  ------------------
   43|  3.04k|                return need_more;
   44|  3.04k|            }
   45|  24.4k|            if (UNLIKELY(s->lookahead == 0))
  ------------------
  |  |  258|  24.4k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 3.04k, False: 21.4k]
  |  |  ------------------
  ------------------
   46|  3.04k|                break; /* flush the current block */
   47|  24.4k|        }
   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.35M|        uint32_t hash_head = 0;
   53|  3.35M|        if (LIKELY(s->lookahead >= WANT_MIN_MATCH)) {
  ------------------
  |  |  257|  3.35M|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 3.35M, False: 656]
  |  |  ------------------
  ------------------
   54|  3.35M|            if (level >= 9)
  ------------------
  |  Branch (54:17): [True: 3.35M, False: 0]
  ------------------
   55|  3.35M|                hash_head = insert_roll(s, window, s->strstart);
   56|      0|            else
   57|      0|                hash_head = insert_knuth(s, window, s->strstart);
   58|  3.35M|        }
   59|       |
   60|       |        /* Find the longest match, discarding those <= prev_length.
   61|       |         */
   62|  3.35M|        s->prev_match = s->match_start;
   63|  3.35M|        uint32_t match_len = STD_MIN_MATCH - 1;
  ------------------
  |  |   59|  3.35M|#define STD_MIN_MATCH  3
  ------------------
   64|  3.35M|        int64_t dist = (int64_t)s->strstart - hash_head;
   65|       |
   66|  3.35M|        if (dist <= MAX_DIST(s) && dist > 0 && s->prev_length < s->max_lazy_match && hash_head != 0) {
  ------------------
  |  |  408|  6.71M|#define MAX_DIST(s)  ((s)->w_size - MIN_LOOKAHEAD)
  |  |  ------------------
  |  |  |  |  403|  3.35M|#define MIN_LOOKAHEAD (STD_MAX_MATCH + STD_MIN_MATCH + 1)
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  3.35M|#define STD_MAX_MATCH  258
  |  |  |  |  ------------------
  |  |  |  |               #define MIN_LOOKAHEAD (STD_MAX_MATCH + STD_MIN_MATCH + 1)
  |  |  |  |  ------------------
  |  |  |  |  |  |   59|  3.35M|#define STD_MIN_MATCH  3
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (66:13): [True: 3.35M, False: 414]
  |  Branch (66:36): [True: 3.35M, False: 1.52k]
  |  Branch (66:48): [True: 1.68M, False: 1.67M]
  |  Branch (66:86): [True: 1.67M, False: 1.76k]
  ------------------
   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.67M|            match_len = longest_match(s, hash_head);
   72|       |            /* longest_match() sets match_start */
   73|       |
   74|  1.67M|            if (match_len <= 5 && (s->strategy == Z_FILTERED)) {
  ------------------
  |  |  199|    295|#define Z_FILTERED            1
  ------------------
  |  Branch (74:17): [True: 295, False: 1.67M]
  |  Branch (74:35): [True: 121, False: 174]
  ------------------
   75|       |                /* If prev_match is also WANT_MIN_MATCH, match_start is garbage
   76|       |                 * but we will ignore the current match anyway.
   77|       |                 */
   78|    121|                match_len = STD_MIN_MATCH - 1;
  ------------------
  |  |   59|    121|#define STD_MIN_MATCH  3
  ------------------
   79|    121|            }
   80|  1.67M|        }
   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.35M|        if (s->prev_length >= STD_MIN_MATCH && match_len <= s->prev_length) {
  ------------------
  |  |   59|  6.71M|#define STD_MIN_MATCH  3
  ------------------
  |  Branch (84:13): [True: 1.67M, False: 1.68M]
  |  Branch (84:48): [True: 1.67M, False: 0]
  ------------------
   85|  1.67M|            unsigned int max_insert = s->strstart + s->lookahead - STD_MIN_MATCH;
  ------------------
  |  |   59|  1.67M|#define STD_MIN_MATCH  3
  ------------------
   86|       |            /* Do not insert strings in hash table beyond this. */
   87|       |
   88|  1.67M|            Assert((s->strstart-1) <= UINT16_MAX, "strstart-1 should fit in uint16_t");
   89|  1.67M|            check_match(s, s->strstart - 1, s->prev_match, s->prev_length);
   90|       |
   91|  1.67M|            bflush = zng_tr_tally_dist(s, s->strstart -1 - s->prev_match, s->prev_length - STD_MIN_MATCH);
  ------------------
  |  |   59|  1.67M|#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.67M|            s->prev_length -= 1;
   99|  1.67M|            s->lookahead -= s->prev_length;
  100|       |
  101|  1.67M|            unsigned int mov_fwd = s->prev_length - 1;
  102|  1.67M|            if (max_insert > s->strstart) {
  ------------------
  |  Branch (102:17): [True: 1.67M, False: 0]
  ------------------
  103|  1.67M|                unsigned int insert_cnt = mov_fwd;
  104|  1.67M|                if (UNLIKELY(insert_cnt > max_insert - s->strstart))
  ------------------
  |  |  258|  1.67M|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 2.80k, False: 1.67M]
  |  |  ------------------
  ------------------
  105|  2.80k|                    insert_cnt = max_insert - s->strstart;
  106|  1.67M|                insert_batch(s, window, s->strstart + 1, insert_cnt);
  107|  1.67M|            }
  108|  1.67M|            s->prev_length = 0;
  109|  1.67M|            s->match_available = 0;
  110|  1.67M|            s->strstart += mov_fwd + 1;
  111|       |
  112|  1.67M|            if (UNLIKELY(bflush))
  ------------------
  |  |  258|  1.67M|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 1.67M]
  |  |  ------------------
  ------------------
  113|  1.67M|                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.68M|        } else if (s->match_available) {
  ------------------
  |  Branch (115:20): [True: 3.52k, False: 1.67M]
  ------------------
  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.52k|            bflush = zng_tr_tally_lit(s, window[s->strstart-1]);
  121|  3.52k|            if (UNLIKELY(bflush))
  ------------------
  |  |  258|  3.52k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 3.52k]
  |  |  ------------------
  ------------------
  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.52k|            s->prev_length = match_len;
  124|  3.52k|            s->strstart++;
  125|  3.52k|            s->lookahead--;
  126|  3.52k|            if (UNLIKELY(s->strm->avail_out == 0))
  ------------------
  |  |  258|  3.52k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 3.52k]
  |  |  ------------------
  ------------------
  127|      0|                return need_more;
  128|  1.67M|        } else {
  129|       |            /* There is no previous match to compare with, wait for
  130|       |             * the next step to decide.
  131|       |             */
  132|  1.67M|            s->prev_length = match_len;
  133|  1.67M|            s->match_available = 1;
  134|  1.67M|            s->strstart++;
  135|  1.67M|            s->lookahead--;
  136|  1.67M|        }
  137|  3.35M|    }
  138|  3.04k|    Assert(flush != Z_NO_FLUSH, "no flush?");
  139|  3.04k|    if (UNLIKELY(s->match_available)) {
  ------------------
  |  |  258|  3.04k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 293, False: 2.74k]
  |  |  ------------------
  ------------------
  140|    293|        Z_UNUSED(zng_tr_tally_lit(s, window[s->strstart-1]));
  ------------------
  |  |  154|    293|#define Z_UNUSED(var) (void)(var)
  ------------------
  141|    293|        s->match_available = 0;
  142|    293|    }
  143|  3.04k|    s->insert = s->strstart < (STD_MIN_MATCH - 1) ? s->strstart : (STD_MIN_MATCH - 1);
  ------------------
  |  |   59|  3.04k|#define STD_MIN_MATCH  3
  ------------------
                  s->insert = s->strstart < (STD_MIN_MATCH - 1) ? s->strstart : (STD_MIN_MATCH - 1);
  ------------------
  |  |   59|  3.04k|#define STD_MIN_MATCH  3
  ------------------
  |  Branch (143:17): [True: 0, False: 3.04k]
  ------------------
  144|  3.04k|    if (UNLIKELY(flush == Z_FINISH)) {
  ------------------
  |  |  258|  3.04k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 1.52k, False: 1.52k]
  |  |  ------------------
  ------------------
  145|  1.52k|        FLUSH_BLOCK(s, window, 1);
  ------------------
  |  |  199|  1.52k|#define FLUSH_BLOCK(s, window, last) { \
  |  |  200|  1.52k|    FLUSH_BLOCK_ONLY(s, window, last); \
  |  |  ------------------
  |  |  |  |  187|  1.52k|#define FLUSH_BLOCK_ONLY(s, window, last) { \
  |  |  |  |  188|  1.52k|    int block_start = s->block_start; \
  |  |  |  |  189|  1.52k|    zng_tr_flush_block(s, (block_start >= 0 ? \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (189:28): [True: 985, False: 536]
  |  |  |  |  ------------------
  |  |  |  |  190|  1.52k|                   &window[(unsigned)block_start] : \
  |  |  |  |  191|  1.52k|                   NULL), \
  |  |  |  |  192|  1.52k|                   (uint32_t)((int)s->strstart - block_start), \
  |  |  |  |  193|  1.52k|                   (last)); \
  |  |  |  |  194|  1.52k|    s->block_start = (int)s->strstart; \
  |  |  |  |  195|  1.52k|    PREFIX(flush_pending)(s->strm); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  121|  1.52k|#  define PREFIX(x) zng_ ## x
  |  |  |  |  ------------------
  |  |  |  |  196|  1.52k|}
  |  |  ------------------
  |  |  201|  1.52k|    if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \
  |  |  ------------------
  |  |  |  Branch (201:9): [True: 0, False: 1.52k]
  |  |  |  Branch (201:41): [True: 0, Folded]
  |  |  ------------------
  |  |  202|  1.52k|}
  ------------------
  146|  1.52k|        return finish_done;
  147|  1.52k|    }
  148|  1.52k|    if (UNLIKELY(s->sym_next))
  ------------------
  |  |  258|  1.52k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 1.52k, False: 0]
  |  |  ------------------
  ------------------
  149|  1.52k|        FLUSH_BLOCK(s, window, 0);
  ------------------
  |  |  199|  1.52k|#define FLUSH_BLOCK(s, window, last) { \
  |  |  200|  1.52k|    FLUSH_BLOCK_ONLY(s, window, last); \
  |  |  ------------------
  |  |  |  |  187|  1.52k|#define FLUSH_BLOCK_ONLY(s, window, last) { \
  |  |  |  |  188|  1.52k|    int block_start = s->block_start; \
  |  |  |  |  189|  1.52k|    zng_tr_flush_block(s, (block_start >= 0 ? \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (189:28): [True: 1.06k, False: 455]
  |  |  |  |  ------------------
  |  |  |  |  190|  1.52k|                   &window[(unsigned)block_start] : \
  |  |  |  |  191|  1.52k|                   NULL), \
  |  |  |  |  192|  1.52k|                   (uint32_t)((int)s->strstart - block_start), \
  |  |  |  |  193|  1.52k|                   (last)); \
  |  |  |  |  194|  1.52k|    s->block_start = (int)s->strstart; \
  |  |  |  |  195|  1.52k|    PREFIX(flush_pending)(s->strm); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  121|  1.52k|#  define PREFIX(x) zng_ ## x
  |  |  |  |  ------------------
  |  |  |  |  196|  1.52k|}
  |  |  ------------------
  |  |  201|  1.52k|    if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \
  |  |  ------------------
  |  |  |  Branch (201:9): [True: 0, False: 1.52k]
  |  |  |  Branch (201:41): [Folded, False: 0]
  |  |  ------------------
  |  |  202|  1.52k|}
  ------------------
  150|  1.52k|    return block_done;
  151|  1.52k|}

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

deflate.c:zng_ctz32:
   20|  1.52k|Z_FORCEINLINE static uint32_t zng_ctz32(uint32_t value) {
   21|  1.52k|    Assert(value != 0, "Invalid input value: 0");
   22|  1.52k|#if __has_builtin(__builtin_ctz)
   23|  1.52k|    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.52k|}
inftrees.c:zng_bitreverse16:
  141|  23.1k|Z_FORCEINLINE static uint16_t zng_bitreverse16(uint16_t value) {
  142|  23.1k|#if __has_builtin(__builtin_bitreverse16)
  143|  23.1k|    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|  23.1k|}
trees.c:zng_bitreverse16:
  141|  28.7k|Z_FORCEINLINE static uint16_t zng_bitreverse16(uint16_t value) {
  142|  28.7k|#if __has_builtin(__builtin_bitreverse16)
  143|  28.7k|    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|  28.7k|}
compare256_avx2.c:zng_ctz32:
   20|   362k|Z_FORCEINLINE static uint32_t zng_ctz32(uint32_t value) {
   21|   362k|    Assert(value != 0, "Invalid input value: 0");
   22|   362k|#if __has_builtin(__builtin_ctz)
   23|   362k|    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|   362k|}
compare256_avx2.c:zng_ctz64:
   44|  6.64k|Z_FORCEINLINE static uint32_t zng_ctz64(uint64_t value) {
   45|  6.64k|    Assert(value != 0, "Invalid input value: 0");
   46|  6.64k|#if __has_builtin(__builtin_ctzll)
   47|  6.64k|    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.64k|}

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

inflate_fast_avx2:
   52|  7.36k|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.36k|    struct inflate_state *state;
   55|  7.36k|    z_const unsigned char *in;  /* local strm->next_in */
  ------------------
  |  |   23|  7.36k|#define z_const const
  ------------------
   56|  7.36k|    const unsigned char *last;  /* have enough input while in < last */
   57|  7.36k|    unsigned char *out;         /* local strm->next_out */
   58|  7.36k|    unsigned char *beg;         /* inflate()'s initial strm->next_out */
   59|  7.36k|    unsigned char *end;         /* while out < end, enough space available */
   60|  7.36k|    unsigned char *safe;        /* can use chunkcopy provided out < safe */
   61|  7.36k|    unsigned char *window;      /* allocated sliding window, if wsize != 0 */
   62|  7.36k|    unsigned wsize;             /* window size or zero if not using window */
   63|  7.36k|    unsigned whave;             /* valid bytes in the window */
   64|  7.36k|    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.36k|    bits_t bits;                /* local strm->bits */
  104|  7.36k|    uint64_t hold;              /* local strm->hold */
  105|  7.36k|    unsigned lmask;             /* mask for first level of length codes */
  106|  7.36k|    unsigned dmask;             /* mask for first level of distance codes */
  107|  7.36k|    code const *lcode;          /* local strm->lencode */
  108|  7.36k|    code const *dcode;          /* local strm->distcode */
  109|  7.36k|    code here;                  /* retrieved table entry */
  110|  7.36k|    unsigned op;                /* code bits, operation, extra bits, or */
  111|       |                                /*  window position, window bytes to copy */
  112|  7.36k|    unsigned len;               /* match length, unused bytes */
  113|  7.36k|    unsigned char *from;        /* where to copy match from */
  114|  7.36k|    unsigned dist;              /* match distance */
  115|  7.36k|    uint64_t old;               /* look-behind buffer for extra bits */
  116|       |
  117|       |    /* copy state to local variables */
  118|  7.36k|    state = (struct inflate_state *)strm->state;
  119|  7.36k|    in = strm->next_in;
  120|  7.36k|    last = in + (strm->avail_in - (INFLATE_FAST_MIN_HAVE - 1));
  ------------------
  |  |  201|  7.36k|#define INFLATE_FAST_MIN_HAVE 15
  ------------------
  121|  7.36k|    out = strm->next_out;
  122|  7.36k|    beg = out - (start - strm->avail_out);
  123|  7.36k|    safe = out + strm->avail_out;
  124|  7.36k|    end = safe - (safe_mode ? INFLATE_FAST_MIN_SAFE : INFLATE_FAST_MIN_LEFT) + 1;
  ------------------
  |  |  203|  2.94k|#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.42k|#define INFLATE_FAST_MIN_LEFT 260  /* max output per token (258) + 2 */
  ------------------
  |  Branch (124:19): [True: 2.94k, False: 4.42k]
  ------------------
  125|  7.36k|    wsize = state->wsize;
  126|  7.36k|    whave = state->whave;
  127|  7.36k|    wnext = state->wnext;
  128|  7.36k|    window = state->window;
  129|  7.36k|    hold = state->hold;
  130|  7.36k|    bits = (bits_t)state->bits;
  131|  7.36k|    lcode = state->lencode;
  132|  7.36k|    dcode = state->distcode;
  133|  7.36k|    lmask = (1U << state->lenbits) - 1;
  134|  7.36k|    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.36k|    REFILL();
  ------------------
  |  |  104|  7.36k|#define REFILL() do { \
  |  |  105|  7.36k|        hold |= load_64_bits(in, bits); \
  |  |  106|  7.36k|        in += (63 ^ bits) >> 3; \
  |  |  107|  7.36k|        bits |= 56; \
  |  |  108|  7.36k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (108:14): [Folded, False: 7.36k]
  |  |  ------------------
  ------------------
  141|       |
  142|       |    /* decode literals and length/distances until end-of-block or not enough
  143|       |       input data or output space */
  144|  1.67M|    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.67M|        here = lcode[hold & lmask];
  151|  1.67M|        Z_TOUCH(here);
  ------------------
  |  |  161|  1.67M|#  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.67M|        REFILL();
  ------------------
  |  |  104|  1.67M|#define REFILL() do { \
  |  |  105|  1.67M|        hold |= load_64_bits(in, bits); \
  |  |  106|  1.67M|        in += (63 ^ bits) >> 3; \
  |  |  107|  1.67M|        bits |= 56; \
  |  |  108|  1.67M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (108:14): [Folded, False: 1.67M]
  |  |  ------------------
  ------------------
  156|  1.67M|        old = hold;
  157|  1.67M|        DROPBITS(here.bits);
  ------------------
  |  |  132|  1.67M|    do { \
  |  |  133|  1.67M|        unsigned u = (unsigned)(n); \
  |  |  134|  1.67M|        hold >>= u; \
  |  |  135|  1.67M|        bits -= (bits_t)u; \
  |  |  136|  1.67M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 1.67M]
  |  |  ------------------
  ------------------
  158|  1.67M|        if (LIKELY(here.op == 0)) {
  ------------------
  |  |  257|  1.67M|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 1.81k, False: 1.67M]
  |  |  ------------------
  ------------------
  159|  1.81k|            TRACE_LITERAL(here.val);
  160|  1.81k|            *out++ = (unsigned char)(here.val);
  161|  1.81k|            here = lcode[hold & lmask];
  162|  1.81k|            Z_TOUCH(here);
  ------------------
  |  |  161|  1.81k|#  define Z_TOUCH(var) __asm__ ("" : "+r"(var))
  ------------------
  163|  1.81k|            old = hold;
  164|  1.81k|            DROPBITS(here.bits);
  ------------------
  |  |  132|  1.81k|    do { \
  |  |  133|  1.81k|        unsigned u = (unsigned)(n); \
  |  |  134|  1.81k|        hold >>= u; \
  |  |  135|  1.81k|        bits -= (bits_t)u; \
  |  |  136|  1.81k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 1.81k]
  |  |  ------------------
  ------------------
  165|  1.81k|            if (LIKELY(here.op == 0)) {
  ------------------
  |  |  257|  1.81k|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 1.64k, False: 172]
  |  |  ------------------
  ------------------
  166|  1.64k|                TRACE_LITERAL(here.val);
  167|  1.64k|                *out++ = (unsigned char)(here.val);
  168|  1.64k|                here = lcode[hold & lmask];
  169|  1.64k|                Z_TOUCH(here);
  ------------------
  |  |  161|  1.64k|#  define Z_TOUCH(var) __asm__ ("" : "+r"(var))
  ------------------
  170|  1.64k|            dolen:
  171|  1.64k|                old = hold;
  172|  1.64k|                DROPBITS(here.bits);
  ------------------
  |  |  132|  1.64k|    do { \
  |  |  133|  1.64k|        unsigned u = (unsigned)(n); \
  |  |  134|  1.64k|        hold >>= u; \
  |  |  135|  1.64k|        bits -= (bits_t)u; \
  |  |  136|  1.64k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 1.64k]
  |  |  ------------------
  ------------------
  173|  1.64k|                if (LIKELY(here.op == 0)) {
  ------------------
  |  |  257|  1.64k|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 121, False: 1.52k]
  |  |  ------------------
  ------------------
  174|    121|                    TRACE_LITERAL(here.val);
  175|    121|                    *out++ = (unsigned char)(here.val);
  176|    121|                    continue;
  177|    121|                }
  178|  1.64k|            }
  179|  1.81k|        }
  180|  1.67M|        op = here.op;
  181|  1.67M|        if (LIKELY(op & 16)) {                  /* length base */
  ------------------
  |  |  257|  1.67M|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 1.67M, False: 1.52k]
  |  |  ------------------
  ------------------
  182|  1.67M|            len = here.val + EXTRA_BITS(old, here, op);
  ------------------
  |  |  170|  1.67M|    ((old & (((uint64_t)1 << here.bits) - 1)) >> (op & MAX_BITS))
  |  |  ------------------
  |  |  |  |   39|  1.67M|#define MAX_BITS 15
  |  |  ------------------
  ------------------
  183|  1.67M|            TRACE_LENGTH(len);
  184|  1.67M|            here = dcode[hold & dmask];
  185|  1.67M|            Z_TOUCH(here);
  ------------------
  |  |  161|  1.67M|#  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.67M|            if (UNLIKELY(bits < MAX_BITS + MAX_DIST_EXTRA_BITS + MAX_LEN_ROOT_BITS)) {
  ------------------
  |  |  258|  1.67M|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 298, False: 1.67M]
  |  |  ------------------
  ------------------
  190|    298|                REFILL();
  ------------------
  |  |  104|    298|#define REFILL() do { \
  |  |  105|    298|        hold |= load_64_bits(in, bits); \
  |  |  106|    298|        in += (63 ^ bits) >> 3; \
  |  |  107|    298|        bits |= 56; \
  |  |  108|    298|    } while (0)
  |  |  ------------------
  |  |  |  Branch (108:14): [Folded, False: 298]
  |  |  ------------------
  ------------------
  191|    298|            }
  192|  1.67M|          dodist:
  193|  1.67M|            old = hold;
  194|  1.67M|            DROPBITS(here.bits);
  ------------------
  |  |  132|  1.67M|    do { \
  |  |  133|  1.67M|        unsigned u = (unsigned)(n); \
  |  |  134|  1.67M|        hold >>= u; \
  |  |  135|  1.67M|        bits -= (bits_t)u; \
  |  |  136|  1.67M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (136:14): [Folded, False: 1.67M]
  |  |  ------------------
  ------------------
  195|  1.67M|            op = here.op;
  196|  1.67M|            if (LIKELY(op & 16)) {              /* distance base */
  ------------------
  |  |  257|  1.67M|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 1.67M, False: 0]
  |  |  ------------------
  ------------------
  197|  1.67M|                dist = here.val + EXTRA_BITS(old, here, op);
  ------------------
  |  |  170|  1.67M|    ((old & (((uint64_t)1 << here.bits) - 1)) >> (op & MAX_BITS))
  |  |  ------------------
  |  |  |  |   39|  1.67M|#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.67M|                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.67M|                if (UNLIKELY(safe_mode && len > (unsigned)(safe - out))) {
  ------------------
  |  |  258|  1.67M|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 1.46k, False: 1.67M]
  |  |  |  Branch (258:53): [True: 2.89k, False: 1.67M]
  |  |  |  Branch (258:53): [True: 1.46k, False: 1.43k]
  |  |  ------------------
  ------------------
  209|  1.46k|                    state->mode = MATCH;
  210|  1.46k|                    state->length = len;
  211|  1.46k|                    state->offset = dist;
  212|  1.46k|                    break;
  213|  1.46k|                }
  214|       |
  215|  1.67M|                op = (unsigned)(out - beg);     /* max distance in output */
  216|  1.67M|                if (UNLIKELY(dist > op)) {      /* see if copy from window */
  ------------------
  |  |  258|  1.67M|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 1.12k, False: 1.67M]
  |  |  ------------------
  ------------------
  217|  1.12k|                    op = dist - op;             /* distance back in window */
  218|  1.12k|                    if (UNLIKELY(op > whave)) {
  ------------------
  |  |  258|  1.12k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 1.12k]
  |  |  ------------------
  ------------------
  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 = (char *)errmsg; \
  |  |  150|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (150:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  238|      0|                        break;
  239|      0|#endif
  240|      0|                    }
  241|  1.12k|                    from = window;
  242|  1.12k|                    if (LIKELY(wnext == 0)) {           /* very common case */
  ------------------
  |  |  257|  1.12k|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 488, False: 635]
  |  |  ------------------
  ------------------
  243|    488|                        from += wsize - op;
  244|    635|                    } else if (LIKELY(wnext >= op)) {   /* contiguous in window */
  ------------------
  |  |  257|    635|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 635, False: 0]
  |  |  ------------------
  ------------------
  245|    635|                        from += wnext - op;
  246|    635|                    } 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.12k|                    if (UNLIKELY(op < len)) {           /* still need some from output */
  ------------------
  |  |  258|  1.12k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 1.12k]
  |  |  ------------------
  ------------------
  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.12k|                    } else {
  275|       |#ifdef HAVE_MASKED_READWRITE
  276|       |                        out = CHUNKCOPY_SAFE(out, from, len, safe);
  277|       |#else
  278|  1.12k|                        if (LIKELY(!safe_mode))
  ------------------
  |  |  257|  1.12k|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 1.12k, False: 0]
  |  |  ------------------
  ------------------
  279|  1.12k|                            out = CHUNKCOPY_SAFE(out, from, len, safe);
  280|      0|                        else
  281|      0|                            out = chunkcopy_safe(out, from, len, safe);
  282|  1.12k|#endif
  283|  1.12k|                    }
  284|  1.67M|                } else if (LIKELY(!safe_mode)) {
  ------------------
  |  |  257|  1.67M|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 1.67M, False: 1.43k]
  |  |  ------------------
  ------------------
  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.67M|                    if (LIKELY(dist >= len || dist >= CHUNKSIZE()))
  ------------------
  |  |  257|  3.34M|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 204, False: 1.67M]
  |  |  |  Branch (257:53): [True: 204, False: 1.67M]
  |  |  |  Branch (257:53): [True: 0, False: 1.67M]
  |  |  ------------------
  ------------------
  291|    204|                        out = CHUNKCOPY(out, out - dist, len);
  ------------------
  |  |  123|    204|#define CHUNKCOPY        chunkcopy_avx2
  ------------------
  292|  1.67M|                    else
  293|  1.67M|                        out = CHUNKMEMSET(out, out - dist, len);
  ------------------
  |  |  125|  1.67M|#define CHUNKMEMSET      chunkmemset_avx2
  ------------------
  294|  1.67M|                } else {
  295|       |#ifdef HAVE_MASKED_READWRITE
  296|       |                    out = CHUNKCOPY_SAFE(out, out - dist, len, safe);
  297|       |#else
  298|  1.43k|                    out = chunkcopy_safe(out, out - dist, len, safe);
  299|  1.43k|#endif
  300|  1.43k|                }
  301|  1.67M|            } 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 = (char *)errmsg; \
  |  |  150|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (150:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  307|      0|                break;
  308|      0|            }
  309|  1.67M|        } else if (UNLIKELY((op & 64) == 0)) {              /* 2nd level length code */
  ------------------
  |  |  258|  1.52k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 1.52k]
  |  |  ------------------
  ------------------
  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.52k|        } else if (UNLIKELY(op & 32)) {                     /* end-of-block */
  ------------------
  |  |  258|  1.52k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 1.52k, False: 0]
  |  |  ------------------
  ------------------
  314|  1.52k|            TRACE_END_OF_BLOCK();
  315|  1.52k|            state->mode = TYPE;
  316|  1.52k|            break;
  317|  1.52k|        } else {
  318|      0|            SET_BAD("invalid literal/length code");
  ------------------
  |  |  147|      0|    do { \
  |  |  148|      0|        state->mode = BAD; \
  |  |  149|      0|        strm->msg = (char *)errmsg; \
  |  |  150|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (150:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  319|      0|            break;
  320|      0|        }
  321|  1.67M|    } while (in < last && out < end);
  ------------------
  |  Branch (321:14): [True: 1.67M, False: 0]
  |  Branch (321:27): [True: 1.67M, False: 4.37k]
  ------------------
  322|       |
  323|       |    /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
  324|  7.36k|    len = bits >> 3;
  325|  7.36k|    in -= len;
  326|  7.36k|    bits -= (bits_t)(len << 3);
  327|  7.36k|    hold &= (UINT64_C(1) << bits) - 1;
  328|       |
  329|       |    /* update state and return */
  330|  7.36k|    strm->next_in = in;
  331|  7.36k|    strm->next_out = out;
  332|  7.36k|    strm->avail_in = (unsigned)(in < last ? (INFLATE_FAST_MIN_HAVE - 1) + (last - in)
  ------------------
  |  |  201|  7.36k|#define INFLATE_FAST_MIN_HAVE 15
  ------------------
  |  Branch (332:33): [True: 7.36k, False: 0]
  ------------------
  333|  7.36k|                                          : (INFLATE_FAST_MIN_HAVE - 1) - (in - last));
  ------------------
  |  |  201|      0|#define INFLATE_FAST_MIN_HAVE 15
  ------------------
  334|  7.36k|    strm->avail_out = (unsigned)(safe - out);
  335|       |
  336|  7.36k|    Assert(bits <= 32, "Remaining bits greater than 32");
  337|  7.36k|    state->hold = (uint32_t)hold;
  338|  7.36k|    state->bits = bits;
  339|  7.36k|    return;
  340|  7.36k|}

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

inflate.c:chunkcopy_safe:
  212|  1.52k|static inline uint8_t* chunkcopy_safe(uint8_t *out, uint8_t *from, size_t len, uint8_t *safe) {
  213|  1.52k|    size_t safelen = safe - out;
  214|  1.52k|    len = MIN(len, safelen);
  ------------------
  |  |  148|  1.52k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 1.52k]
  |  |  ------------------
  ------------------
  215|  1.52k|    int32_t olap_src = from >= out && from < out + len;
  ------------------
  |  Branch (215:24): [True: 1.45k, False: 71]
  |  Branch (215:39): [True: 0, False: 1.45k]
  ------------------
  216|  1.52k|    int32_t olap_dst = out >= from && out < from + len;
  ------------------
  |  Branch (216:24): [True: 71, False: 1.45k]
  |  Branch (216:39): [True: 0, False: 71]
  ------------------
  217|  1.52k|    size_t tocopy;
  218|       |
  219|       |    /* For all cases without overlap, memcpy is ideal */
  220|  1.52k|    if (!(olap_src || olap_dst)) {
  ------------------
  |  Branch (220:11): [True: 0, False: 1.52k]
  |  Branch (220:23): [True: 0, False: 1.52k]
  ------------------
  221|  1.52k|        memcpy(out, from, len);
  222|  1.52k|        return out + len;
  223|  1.52k|    }
  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.68M|static inline uint64_t load_64_bits(const unsigned char *in, unsigned bits) {
  207|  1.68M|    uint64_t chunk = zng_memread_8(in);
  208|  1.68M|    return Z_U64_FROM_LE(chunk) << bits;
  ------------------
  |  |   88|  1.68M|#  define Z_U64_FROM_LE(x)  (x)
  ------------------
  209|  1.68M|}
chunkset_avx2.c:chunkcopy_safe:
  212|  1.43k|static inline uint8_t* chunkcopy_safe(uint8_t *out, uint8_t *from, size_t len, uint8_t *safe) {
  213|  1.43k|    size_t safelen = safe - out;
  214|  1.43k|    len = MIN(len, safelen);
  ------------------
  |  |  148|  1.43k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 1.43k]
  |  |  ------------------
  ------------------
  215|  1.43k|    int32_t olap_src = from >= out && from < out + len;
  ------------------
  |  Branch (215:24): [True: 0, False: 1.43k]
  |  Branch (215:39): [True: 0, False: 0]
  ------------------
  216|  1.43k|    int32_t olap_dst = out >= from && out < from + len;
  ------------------
  |  Branch (216:24): [True: 1.43k, False: 0]
  |  Branch (216:39): [True: 1.43k, False: 0]
  ------------------
  217|  1.43k|    size_t tocopy;
  218|       |
  219|       |    /* For all cases without overlap, memcpy is ideal */
  220|  1.43k|    if (!(olap_src || olap_dst)) {
  ------------------
  |  Branch (220:11): [True: 0, False: 1.43k]
  |  Branch (220:23): [True: 1.43k, False: 0]
  ------------------
  221|      0|        memcpy(out, from, len);
  222|      0|        return out + len;
  223|      0|    }
  224|       |
  225|       |    /* Complete overlap: Source == destination */
  226|  1.43k|    if (out == from) {
  ------------------
  |  Branch (226:9): [True: 0, False: 1.43k]
  ------------------
  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.43k|    size_t non_olap_size = (size_t)ABS(from - out);
  ------------------
  |  |  152|  1.43k|#define ABS(a) ((a) < 0 ? -(a) : (a))
  |  |  ------------------
  |  |  |  Branch (152:17): [True: 1.43k, 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|   173k|    while (len) {
  ------------------
  |  Branch (242:12): [True: 171k, False: 1.43k]
  ------------------
  243|   171k|        tocopy = MIN(non_olap_size, len);
  ------------------
  |  |  148|   171k|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (148:20): [True: 0, False: 171k]
  |  |  ------------------
  ------------------
  244|   171k|        len -= tocopy;
  245|       |
  246|   171k|        while (tocopy >= 16) {
  ------------------
  |  Branch (246:16): [True: 0, False: 171k]
  ------------------
  247|      0|            memcpy(out, from, 16);
  248|      0|            out += 16;
  249|      0|            from += 16;
  250|      0|            tocopy -= 16;
  251|      0|        }
  252|       |
  253|   171k|        if (tocopy >= 8) {
  ------------------
  |  Branch (253:13): [True: 0, False: 171k]
  ------------------
  254|      0|            memcpy(out, from, 8);
  255|      0|            out += 8;
  256|      0|            from += 8;
  257|      0|            tocopy -= 8;
  258|      0|        }
  259|       |
  260|   171k|        if (tocopy >= 4) {
  ------------------
  |  Branch (260:13): [True: 0, False: 171k]
  ------------------
  261|      0|            memcpy(out, from, 4);
  262|      0|            out += 4;
  263|      0|            from += 4;
  264|      0|            tocopy -= 4;
  265|      0|        }
  266|       |
  267|   343k|        while (tocopy--) {
  ------------------
  |  Branch (267:16): [True: 171k, False: 171k]
  ------------------
  268|   171k|            *out++ = *from++;
  269|   171k|        }
  270|   171k|    }
  271|       |
  272|  1.43k|    return out;
  273|  1.43k|}

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

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

deflate.c:update_hash_roll:
   26|  14.7k|Z_FORCEINLINE static uint32_t update_hash_roll(uint32_t h, uint32_t val) {
   27|  14.7k|    UPDATE_HASH_ROLL(h, val);
  ------------------
  |  |   18|  14.7k|#define UPDATE_HASH_ROLL(h,val) h = (((h << 5) ^ ((uint8_t)(val))) & ROLL_MASK
  |  |  ------------------
  |  |  |  |   17|  14.7k|#define ROLL_MASK ((HASH_SIZE / 2) - 1u))
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  14.7k|#  define HASH_SIZE 65536u         /* number of elements in hash table */
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   28|  14.7k|    return h;
   29|  14.7k|}
deflate_slow.c:insert_roll:
   69|  3.35M|Z_FORCEINLINE static uint32_t insert_roll(deflate_state *const s, unsigned char *window, uint32_t str) {
   70|  3.35M|    uint8_t *strstart = window + str + (STD_MIN_MATCH-1);
  ------------------
  |  |   59|  3.35M|#define STD_MIN_MATCH  3
  ------------------
   71|  3.35M|    uint32_t h, head;
   72|       |
   73|  3.35M|    h = s->ins_h;
   74|  3.35M|    UPDATE_HASH_ROLL(h, strstart[0]);
  ------------------
  |  |   18|  3.35M|#define UPDATE_HASH_ROLL(h,val) h = (((h << 5) ^ ((uint8_t)(val))) & ROLL_MASK
  |  |  ------------------
  |  |  |  |   17|  3.35M|#define ROLL_MASK ((HASH_SIZE / 2) - 1u))
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  3.35M|#  define HASH_SIZE 65536u         /* number of elements in hash table */
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   75|  3.35M|    s->ins_h = h;
   76|       |
   77|  3.35M|    head = s->head[h];
   78|  3.35M|    if (LIKELY(head != str)) {
  ------------------
  |  |  257|  3.35M|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 3.35M, False: 1.52k]
  |  |  ------------------
  ------------------
   79|  3.35M|        s->prev[str & W_MASK(s)] = (Pos)head;
  ------------------
  |  |  413|  3.35M|#define W_MASK(s)  ((s)->w_size - 1)
  ------------------
   80|  3.35M|        s->head[h] = (Pos)str;
   81|  3.35M|    }
   82|  3.35M|    return head;
   83|  3.35M|}
insert_string.c:insert_roll_batch_static:
  116|  1.67M|Z_FORCEINLINE static void insert_roll_batch_static(deflate_state *const s, unsigned char *window, uint32_t str, uint32_t count) {
  117|  1.67M|    uint8_t *strstart = window + str + (STD_MIN_MATCH-1);
  ------------------
  |  |   59|  1.67M|#define STD_MIN_MATCH  3
  ------------------
  118|  1.67M|    uint8_t *strend = strstart + count;
  119|       |
  120|       |    /* Local pointers to avoid indirection */
  121|  1.67M|    Pos *headp = s->head;
  122|  1.67M|    Pos *prevp = s->prev;
  123|  1.67M|    uint32_t h = s->ins_h;
  124|  1.67M|    const unsigned int w_mask = W_MASK(s);
  ------------------
  |  |  413|  1.67M|#define W_MASK(s)  ((s)->w_size - 1)
  ------------------
  125|       |
  126|   460M|    for (uint32_t idx = str; strstart < strend; idx++, strstart++) {
  ------------------
  |  Branch (126:30): [True: 458M, False: 1.67M]
  ------------------
  127|   458M|        uint32_t head;
  128|       |
  129|   458M|        UPDATE_HASH_ROLL(h, strstart[0]);
  ------------------
  |  |   18|   458M|#define UPDATE_HASH_ROLL(h,val) h = (((h << 5) ^ ((uint8_t)(val))) & ROLL_MASK
  |  |  ------------------
  |  |  |  |   17|   458M|#define ROLL_MASK ((HASH_SIZE / 2) - 1u))
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   458M|#  define HASH_SIZE 65536u         /* number of elements in hash table */
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  130|       |
  131|   458M|        head = headp[h];
  132|   458M|        if (LIKELY(head != idx)) {
  ------------------
  |  |  257|   458M|#  define LIKELY(x)             __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (257:33): [True: 458M, False: 847]
  |  |  ------------------
  ------------------
  133|   458M|            prevp[idx & w_mask] = (Pos)head;
  134|   458M|            headp[h] = (Pos)idx;
  135|   458M|        }
  136|   458M|    }
  137|  1.67M|    s->ins_h = h;
  138|  1.67M|}
compare256_avx2.c:update_hash_roll:
   26|  1.01M|Z_FORCEINLINE static uint32_t update_hash_roll(uint32_t h, uint32_t val) {
   27|  1.01M|    UPDATE_HASH_ROLL(h, val);
  ------------------
  |  |   18|  1.01M|#define UPDATE_HASH_ROLL(h,val) h = (((h << 5) ^ ((uint8_t)(val))) & ROLL_MASK
  |  |  ------------------
  |  |  |  |   17|  1.01M|#define ROLL_MASK ((HASH_SIZE / 2) - 1u))
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  1.01M|#  define HASH_SIZE 65536u         /* number of elements in hash table */
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   28|  1.01M|    return h;
   29|  1.01M|}

longest_match_roll_avx2:
   28|  1.67M|Z_INTERNAL uint32_t LONGEST_MATCH(deflate_state *const s, uint32_t cur_match) {
   29|  1.67M|    const unsigned wmask = W_MASK(s);
  ------------------
  |  |  413|  1.67M|#define W_MASK(s)  ((s)->w_size - 1)
  ------------------
   30|  1.67M|    unsigned int strstart = s->strstart;
   31|  1.67M|    const unsigned char *window = s->window;
   32|  1.67M|    const Pos *prev = s->prev;
   33|  1.67M|#ifdef LONGEST_MATCH_ROLL
   34|  1.67M|    const Pos *head = s->head;
   35|  1.67M|#endif
   36|  1.67M|    const unsigned char *scan;
   37|  1.67M|    const unsigned char *mbase_start = window;
   38|  1.67M|    const unsigned char *mbase_end;
   39|  1.67M|    uint32_t limit;
   40|  1.67M|#ifdef LONGEST_MATCH_ROLL
   41|  1.67M|    uint32_t limit_base;
   42|       |#else
   43|       |    int32_t early_exit;
   44|       |#endif
   45|  1.67M|    uint32_t chain_length = s->max_chain_length;
   46|  1.67M|    uint32_t nice_match = (uint32_t)s->nice_match;
   47|  1.67M|    uint32_t best_len, offset;
   48|  1.67M|    uint32_t lookahead = s->lookahead;
   49|  1.67M|    uint32_t match_offset = 0;
   50|  1.67M|    uint64_t scan_start;
   51|  1.67M|    uint64_t scan_end;
   52|       |
   53|       |    /* The code is optimized for STD_MAX_MATCH-2 multiple of 16. */
   54|  1.67M|    Assert(STD_MAX_MATCH == 258, "Code too clever");
   55|       |
   56|  1.67M|    best_len = s->prev_length ? s->prev_length : STD_MIN_MATCH-1;
  ------------------
  |  |   59|  1.67M|#define STD_MIN_MATCH  3
  ------------------
  |  Branch (56:16): [True: 4.39k, False: 1.67M]
  ------------------
   57|  1.67M|    if (UNLIKELY(best_len >= lookahead))
  ------------------
  |  |  258|  1.67M|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 2.74k, False: 1.67M]
  |  |  ------------------
  ------------------
   58|  2.74k|        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.67M|    offset = best_len >= sizeof(uint64_t) ? best_len - 7 : 0;
  ------------------
  |  Branch (64:14): [True: 0, False: 1.67M]
  ------------------
   65|       |
   66|  1.67M|    scan = window + strstart;
   67|  1.67M|    scan_start = zng_memread_8(scan);
   68|  1.67M|    scan_end = zng_memread_8(scan+offset);
   69|  1.67M|    mbase_end = (mbase_start+offset);
   70|       |
   71|       |    /* Do not waste too much time if we already have a good match */
   72|  1.67M|    if (UNLIKELY(best_len >= s->good_match))
  ------------------
  |  |  258|  1.67M|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 1.67M]
  |  |  ------------------
  ------------------
   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.67M|    limit = strstart > MAX_DIST(s) ? (strstart - MAX_DIST(s)) : 0;
  ------------------
  |  |  408|  1.67M|#define MAX_DIST(s)  ((s)->w_size - MIN_LOOKAHEAD)
  |  |  ------------------
  |  |  |  |  403|  1.67M|#define MIN_LOOKAHEAD (STD_MAX_MATCH + STD_MIN_MATCH + 1)
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  1.67M|#define STD_MAX_MATCH  258
  |  |  |  |  ------------------
  |  |  |  |               #define MIN_LOOKAHEAD (STD_MAX_MATCH + STD_MIN_MATCH + 1)
  |  |  |  |  ------------------
  |  |  |  |  |  |   59|  1.67M|#define STD_MIN_MATCH  3
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  limit = strstart > MAX_DIST(s) ? (strstart - MAX_DIST(s)) : 0;
  ------------------
  |  |  408|  1.54M|#define MAX_DIST(s)  ((s)->w_size - MIN_LOOKAHEAD)
  |  |  ------------------
  |  |  |  |  403|  1.54M|#define MIN_LOOKAHEAD (STD_MAX_MATCH + STD_MIN_MATCH + 1)
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  1.54M|#define STD_MAX_MATCH  258
  |  |  |  |  ------------------
  |  |  |  |               #define MIN_LOOKAHEAD (STD_MAX_MATCH + STD_MIN_MATCH + 1)
  |  |  |  |  ------------------
  |  |  |  |  |  |   59|  1.54M|#define STD_MIN_MATCH  3
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (78:13): [True: 1.54M, False: 132k]
  ------------------
   79|  1.67M|#ifdef LONGEST_MATCH_ROLL
   80|  1.67M|    limit_base = limit;
   81|  1.67M|    if (best_len >= STD_MIN_MATCH) {
  ------------------
  |  |   59|  1.67M|#define STD_MIN_MATCH  3
  ------------------
  |  Branch (81:9): [True: 0, False: 1.67M]
  ------------------
   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.67M|    Assert((unsigned long)strstart <= s->window_size - MIN_LOOKAHEAD, "need lookahead");
  116|  2.04M|    for (;;) {
  117|  2.04M|        if (UNLIKELY(cur_match >= strstart))
  ------------------
  |  |  258|  2.04M|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 2.04M]
  |  |  ------------------
  ------------------
  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.04M|        uint32_t len;
  128|  2.04M|        if (best_len < sizeof(uint64_t)) {
  ------------------
  |  Branch (128:13): [True: 1.68M, False: 362k]
  ------------------
  129|  1.68M|            uint64_t cand_start = zng_memread_8(mbase_start + cur_match);
  130|  1.68M|            if (scan_start != cand_start) {
  ------------------
  |  Branch (130:17): [True: 6.68k, False: 1.67M]
  ------------------
  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.68k|                uint64_t first_mask = zng_first_bytes_mask64(best_len + 1);
  ------------------
  |  |  138|  6.68k|#  define zng_first_bytes_mask64(n) (UINT64_MAX >> ((8 - (n)) * 8))
  ------------------
  135|  6.68k|                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.68k|                if (UNLIKELY((diff & first_mask) == 0)) {
  ------------------
  |  |  258|  6.68k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 6.20k, False: 481]
  |  |  ------------------
  ------------------
  139|  6.20k|                    len = zng_first_diff_byte64(diff);
  ------------------
  |  |  130|  6.20k|#  define zng_first_diff_byte64(diff) (zng_ctz64(diff) / 8)
  ------------------
  140|  6.20k|                    goto short_match_accept;
  141|  6.20k|                }
  142|    481|                if (--chain_length == 0 || (cur_match = prev[cur_match & wmask]) <= limit)
  ------------------
  |  Branch (142:21): [True: 0, False: 481]
  |  Branch (142:44): [True: 0, False: 481]
  ------------------
  143|      0|                    return best_len;
  144|    481|                cand_start = zng_memread_8(mbase_start + cur_match);
  145|    481|                if (scan_start != cand_start) {
  ------------------
  |  Branch (145:21): [True: 481, False: 0]
  ------------------
  146|       |                    /* Walk the remaining candidates with the chain advance kept inline. */
  147|  1.01k|                    for (;;) {
  148|  1.01k|                        diff = scan_start ^ cand_start;
  149|  1.01k|                        if (UNLIKELY((diff & first_mask) == 0)) {
  ------------------
  |  |  258|  1.01k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 433, False: 585]
  |  |  ------------------
  ------------------
  150|    433|                            len = zng_first_diff_byte64(diff);
  ------------------
  |  |  130|    433|#  define zng_first_diff_byte64(diff) (zng_ctz64(diff) / 8)
  ------------------
  151|    433|                            goto short_match_accept;
  152|    433|                        }
  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: 48, False: 537]
  ------------------
  157|     48|                            break;
  158|    585|                    }
  159|    481|                }
  160|    481|            }
  161|       |            /* All 8 bytes match, fallthrough to compare256 for the tail. */
  162|  1.68M|        } 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|   382k|            for (;;) {
  166|       |                /* First check the end of the candidate at best_len+1 due to the higher
  167|       |                 * likelihood of a mismatch. */
  168|   382k|                if (zng_memcmp_8(mbase_end+cur_match, &scan_end) == 0 &&
  ------------------
  |  Branch (168:21): [True: 366k, False: 16.0k]
  ------------------
  169|   366k|                    zng_memcmp_8(mbase_start+cur_match, &scan_start) == 0)
  ------------------
  |  Branch (169:21): [True: 362k, False: 3.78k]
  ------------------
  170|   362k|                    break;
  171|  19.8k|                GOTO_NEXT_CHAIN;
  ------------------
  |  |   16|  19.8k|    if (--chain_length && (cur_match = prev[cur_match & wmask]) > limit) \
  |  |  ------------------
  |  |  |  Branch (16:9): [True: 19.8k, False: 0]
  |  |  |  Branch (16:27): [True: 19.8k, False: 0]
  |  |  ------------------
  |  |   17|  19.8k|        continue; \
  |  |   18|      0|    return best_len;
  ------------------
  172|  19.8k|            }
  173|   362k|        }
  174|  2.03M|        len = COMPARE256(scan+2, mbase_start+cur_match+2) + 2;
  ------------------
  |  |   57|  2.03M|#define COMPARE256          compare256_avx2_static
  ------------------
  175|  2.03M|        Assert(scan+len <= window+(unsigned)(s->window_size-1), "wild scan");
  176|       |
  177|  2.03M|        if (len > best_len)
  ------------------
  |  Branch (177:13): [True: 2.00M, False: 30.7k]
  ------------------
  178|  4.02M|short_match_accept:
  179|  4.02M|        {
  180|  4.02M|            uint32_t match_start = cur_match - match_offset;
  181|  4.02M|            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.02M|            if (UNLIKELY(len >= lookahead))
  ------------------
  |  |  258|  2.01M|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 2.87k, False: 2.01M]
  |  |  ------------------
  ------------------
  187|  2.87k|                return lookahead;
  188|  2.01M|            if (UNLIKELY(len >= nice_match))
  ------------------
  |  |  258|  2.01M|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 1.67M, False: 338k]
  |  |  ------------------
  ------------------
  189|  1.67M|                return len;
  190|       |
  191|   338k|            best_len = len;
  192|       |
  193|   338k|            offset = best_len >= sizeof(uint64_t) ? best_len - 7 : 0;
  ------------------
  |  Branch (193:22): [True: 332k, False: 6.64k]
  ------------------
  194|       |
  195|   338k|            scan_end = zng_memread_8(scan+offset);
  196|       |
  197|   338k|#ifdef LONGEST_MATCH_ROLL
  198|       |            /* Look for a better string offset */
  199|   338k|            if (UNLIKELY(len > STD_MIN_MATCH && match_start + len < strstart)) {
  ------------------
  |  |  258|   675k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 337k, False: 1.32k]
  |  |  |  Branch (258:53): [True: 337k, False: 1.32k]
  |  |  |  Branch (258:53): [True: 337k, False: 0]
  |  |  ------------------
  ------------------
  200|   337k|                const unsigned char *scan_endstr;
  201|   337k|                uint32_t hash;
  202|   337k|                uint32_t pos, next_pos;
  203|       |
  204|       |                /* Go back to offset 0 */
  205|   337k|                cur_match -= match_offset;
  206|   337k|                match_offset = 0;
  207|   337k|                next_pos = cur_match;
  208|  43.6M|                for (uint32_t i = 0; i <= len - STD_MIN_MATCH; i++) {
  ------------------
  |  |   59|  43.6M|#define STD_MIN_MATCH  3
  ------------------
  |  Branch (208:38): [True: 43.3M, False: 337k]
  ------------------
  209|  43.3M|                    pos = prev[(cur_match + i) & wmask];
  210|  43.3M|                    if (UNLIKELY(pos < next_pos)) {
  ------------------
  |  |  258|  43.3M|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 337k, False: 43.0M]
  |  |  ------------------
  ------------------
  211|       |                        /* Hash chain is more distant, use it */
  212|   337k|                        if (UNLIKELY(pos <= limit_base + i))
  ------------------
  |  |  258|   337k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 337k]
  |  |  ------------------
  ------------------
  213|      0|                            return best_len;
  214|   337k|                        next_pos = pos;
  215|   337k|                        match_offset = i;
  216|   337k|                    }
  217|  43.3M|                }
  218|       |                /* Switch cur_match to next_pos chain */
  219|   337k|                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|   337k|                scan_endstr = scan + len - (STD_MIN_MATCH-1);
  ------------------
  |  |   59|   337k|#define STD_MIN_MATCH  3
  ------------------
  227|       |
  228|   337k|                hash = update_hash_roll(0, scan_endstr[0]);
  229|   337k|                hash = update_hash_roll(hash, scan_endstr[1]);
  230|   337k|                hash = update_hash_roll(hash, scan_endstr[2]);
  231|       |
  232|   337k|                pos = head[hash];
  233|   337k|                if (UNLIKELY(pos < cur_match)) {
  ------------------
  |  |  258|   337k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 337k]
  |  |  ------------------
  ------------------
  234|      0|                    match_offset = len - (STD_MIN_MATCH-1);
  ------------------
  |  |   59|      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|   337k|                limit = limit_base+match_offset;
  242|   337k|                mbase_start = window-match_offset;
  243|   337k|                mbase_end = (mbase_start+offset);
  244|   337k|                continue;
  245|   337k|            }
  246|  1.32k|#endif
  247|  1.32k|            mbase_end = (mbase_start+offset);
  248|  1.32k|        }
  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|  32.0k|        GOTO_NEXT_CHAIN;
  ------------------
  |  |   16|  32.0k|    if (--chain_length && (cur_match = prev[cur_match & wmask]) > limit) \
  |  |  ------------------
  |  |  |  Branch (16:9): [True: 32.0k, False: 0]
  |  |  |  Branch (16:27): [True: 32.0k, False: 0]
  |  |  ------------------
  |  |   17|  32.0k|        continue; \
  |  |   18|      0|    return best_len;
  ------------------
  258|  32.0k|    }
  259|      0|    return best_len;
  260|  1.67M|}

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

zng_tr_init:
   83|  1.52k|void Z_INTERNAL zng_tr_init(deflate_state *s) {
   84|  1.52k|    s->l_desc.dyn_tree = s->dyn_ltree;
   85|  1.52k|    s->l_desc.stat_desc = &static_l_desc;
   86|       |
   87|  1.52k|    s->d_desc.dyn_tree = s->dyn_dtree;
   88|  1.52k|    s->d_desc.stat_desc = &static_d_desc;
   89|       |
   90|  1.52k|    s->bl_desc.dyn_tree = s->bl_tree;
   91|  1.52k|    s->bl_desc.stat_desc = &static_bl_desc;
   92|       |
   93|  1.52k|    s->bi_buf = 0;
   94|  1.52k|    s->bi_valid = 0;
   95|       |#ifdef ZLIB_DEBUG
   96|       |    s->compressed_len = 0L;
   97|       |    s->bits_sent = 0L;
   98|       |#endif
   99|       |
  100|       |    /* Initialize the first block of the first file: */
  101|  1.52k|    init_block(s);
  102|  1.52k|}
gen_codes:
  376|  9.12k|Z_INTERNAL void gen_codes(ct_data *tree, int max_code, uint16_t *bl_count) {
  377|       |    /* tree: the tree to decorate */
  378|       |    /* max_code: largest code with non zero frequency */
  379|       |    /* bl_count: number of codes at each bit length */
  380|  9.12k|    uint16_t next_code[MAX_BITS+1];  /* next code value for each bit length */
  381|  9.12k|    uint16_t code = 0;               /* running code value */
  382|  9.12k|    int bits;                        /* bit index */
  383|  9.12k|    int n;                           /* code index */
  384|       |
  385|       |    /* The distribution counts are first used to generate the code values
  386|       |     * without bit reversal.
  387|       |     */
  388|   146k|    for (bits = 1; bits <= MAX_BITS; bits++) {
  ------------------
  |  |   39|   146k|#define MAX_BITS 15
  ------------------
  |  Branch (388:20): [True: 136k, False: 9.12k]
  ------------------
  389|   136k|        code = (code + bl_count[bits-1]) << 1;
  390|   136k|        next_code[bits] = code;
  391|   136k|    }
  392|       |    /* Check that the bit counts in bl_count are consistent. The last code
  393|       |     * must be all ones.
  394|       |     */
  395|  9.12k|    Assert(code + bl_count[MAX_BITS]-1 == (1 << MAX_BITS)-1, "inconsistent bit counts");
  396|  9.12k|    Tracev((stderr, "\ngen_codes: max_code %d ", max_code));
  397|       |
  398|   962k|    for (n = 0;  n <= max_code; n++) {
  ------------------
  |  Branch (398:18): [True: 953k, False: 9.12k]
  ------------------
  399|   953k|        int len = tree[n].Len;
  ------------------
  |  |  128|   953k|#define Len  dl.len
  ------------------
  400|   953k|        if (len == 0)
  ------------------
  |  Branch (400:13): [True: 925k, False: 28.7k]
  ------------------
  401|   925k|            continue;
  402|       |        /* Now reverse the bits */
  403|  28.7k|        tree[n].Code = bi_reverse(next_code[len]++, len);
  ------------------
  |  |  126|  28.7k|#define Code fc.code
  ------------------
  404|       |
  405|  28.7k|        Tracecv(tree != static_ltree, (stderr, "\nn %3d %c l %2d c %4x (%x) ",
  406|  28.7k|             n, (isgraph(n & 0xff) ? n : ' '), len, tree[n].Code, next_code[len]-1));
  407|  28.7k|    }
  408|  9.12k|}
zng_tr_stored_block:
  595|  1.52k|void Z_INTERNAL zng_tr_stored_block(deflate_state *s, unsigned char *buf, uint32_t stored_len, int last) {
  596|       |    /* buf: input block */
  597|       |    /* stored_len: length of input block */
  598|       |    /* last: one if this is the last block for a file */
  599|  1.52k|    zng_tr_emit_tree(s, STORED_BLOCK, last); /* send block type */
  ------------------
  |  |   54|  1.52k|#define STORED_BLOCK 0
  ------------------
  600|  1.52k|    zng_tr_emit_align(s);                    /* align on byte boundary */
  601|  1.52k|    cmpr_bits_align(s);
  602|  1.52k|    put_short(s, (uint16_t)stored_len);
  603|  1.52k|    put_short(s, (uint16_t)~stored_len);
  604|  1.52k|    cmpr_bits_add(s, 32);
  ------------------
  |  |  447|  1.52k|#  define cmpr_bits_add(s, len)     Z_UNUSED(len)
  |  |  ------------------
  |  |  |  |  154|  1.52k|#define Z_UNUSED(var) (void)(var)
  |  |  ------------------
  ------------------
  605|  1.52k|    sent_bits_add(s, 32);
  ------------------
  |  |  449|  1.52k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  ------------------
  |  |  |  |  154|  1.52k|#define Z_UNUSED(var) (void)(var)
  |  |  ------------------
  ------------------
  606|  1.52k|    if (stored_len) {
  ------------------
  |  Branch (606:9): [True: 0, False: 1.52k]
  ------------------
  607|      0|        memcpy(s->pending_buf + s->pending, buf, stored_len);
  608|      0|        s->pending += stored_len;
  609|      0|        cmpr_bits_add(s, stored_len << 3);
  ------------------
  |  |  447|      0|#  define cmpr_bits_add(s, len)     Z_UNUSED(len)
  |  |  ------------------
  |  |  |  |  154|      0|#define Z_UNUSED(var) (void)(var)
  |  |  ------------------
  ------------------
  610|      0|        sent_bits_add(s, stored_len << 3);
  ------------------
  |  |  449|      0|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  ------------------
  |  |  |  |  154|      0|#define Z_UNUSED(var) (void)(var)
  |  |  ------------------
  ------------------
  611|      0|    }
  612|  1.52k|}
zng_tr_flush_block:
  628|  3.04k|void Z_INTERNAL zng_tr_flush_block(deflate_state *s, unsigned char *buf, uint32_t stored_len, int last) {
  629|       |    /* buf: input block, or NULL if too old */
  630|       |    /* stored_len: length of input block */
  631|       |    /* last: one if this is the last block for a file */
  632|  3.04k|    unsigned int opt_lenb, static_lenb; /* opt_len and static_len in bytes */
  633|  3.04k|    int max_blindex = 0;  /* index of last bit length code of non zero freq */
  634|       |
  635|       |    /* Build the Huffman trees unless a stored block is forced */
  636|  3.04k|    if (UNLIKELY(s->sym_next == 0)) {
  ------------------
  |  |  258|  3.04k|#  define UNLIKELY(x)           __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (258:33): [True: 0, False: 3.04k]
  |  |  ------------------
  ------------------
  637|       |        /* Emit an empty static tree block with no codes */
  638|      0|        opt_lenb = static_lenb = 0;
  639|      0|        s->static_len = 7;
  640|  3.04k|    } else if (s->level > 0) {
  ------------------
  |  Branch (640:16): [True: 3.04k, False: 0]
  ------------------
  641|       |        /* Check if the file is binary or text */
  642|  3.04k|        if (s->strm->data_type == Z_UNKNOWN)
  ------------------
  |  |  209|  3.04k|#define Z_UNKNOWN  2
  ------------------
  |  Branch (642:13): [True: 1.52k, False: 1.52k]
  ------------------
  643|  1.52k|            s->strm->data_type = detect_data_type(s);
  644|       |
  645|       |        /* Construct the literal and distance trees */
  646|  3.04k|        build_tree(s, (tree_desc *)(&(s->l_desc)));
  647|  3.04k|        Tracev((stderr, "\nlit data: dyn %u, stat %u", s->opt_len, s->static_len));
  648|       |
  649|  3.04k|        build_tree(s, (tree_desc *)(&(s->d_desc)));
  650|  3.04k|        Tracev((stderr, "\ndist data: dyn %u, stat %u", s->opt_len, s->static_len));
  651|       |        /* At this point, opt_len and static_len are the total bit lengths of
  652|       |         * the compressed block data, excluding the tree representations.
  653|       |         */
  654|       |
  655|       |        /* Build the bit length tree for the above two trees, and get the index
  656|       |         * in bl_order of the last bit length code to send.
  657|       |         */
  658|  3.04k|        max_blindex = build_bl_tree(s);
  659|       |
  660|       |        /* Determine the best encoding. Compute the block lengths in bytes. */
  661|  3.04k|        opt_lenb = (s->opt_len + 3 + 7) >> 3;
  662|  3.04k|        static_lenb = (s->static_len + 3 + 7) >> 3;
  663|       |
  664|  3.04k|        Tracev((stderr, "\nopt %u(%u) stat %u(%u) stored %u lit %u ",
  665|  3.04k|                opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
  666|  3.04k|                s->sym_next / 3));
  667|       |
  668|  3.04k|        if (static_lenb <= opt_lenb || s->strategy == Z_FIXED)
  ------------------
  |  |  202|  2.41k|#define Z_FIXED               4
  ------------------
  |  Branch (668:13): [True: 630, False: 2.41k]
  |  Branch (668:40): [True: 0, False: 2.41k]
  ------------------
  669|    630|            opt_lenb = static_lenb;
  670|       |
  671|  3.04k|    } else {
  672|      0|        Assert(buf != NULL, "lost buf");
  673|      0|        opt_lenb = static_lenb = stored_len + 5; /* force a stored block */
  674|      0|    }
  675|       |
  676|  3.04k|    if (stored_len+4 <= opt_lenb && buf != NULL) {
  ------------------
  |  Branch (676:9): [True: 0, False: 3.04k]
  |  Branch (676:37): [True: 0, False: 0]
  ------------------
  677|       |        /* 4: two words for the lengths
  678|       |         * The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
  679|       |         * Otherwise we can't have processed more than WSIZE input bytes since
  680|       |         * the last block flush, because compression would have been
  681|       |         * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
  682|       |         * transform a block into a stored block.
  683|       |         */
  684|      0|        zng_tr_stored_block(s, buf, stored_len, last);
  685|       |
  686|  3.04k|    } else if (static_lenb == opt_lenb) {
  ------------------
  |  Branch (686:16): [True: 630, False: 2.41k]
  ------------------
  687|    630|        zng_tr_emit_tree(s, STATIC_TREES, last);
  ------------------
  |  |   55|    630|#define STATIC_TREES 1
  ------------------
  688|    630|        compress_block(s, (const ct_data *)static_ltree, (const ct_data *)static_dtree);
  689|    630|        cmpr_bits_add(s, s->static_len);
  ------------------
  |  |  447|    630|#  define cmpr_bits_add(s, len)     Z_UNUSED(len)
  |  |  ------------------
  |  |  |  |  154|    630|#define Z_UNUSED(var) (void)(var)
  |  |  ------------------
  ------------------
  690|  2.41k|    } else {
  691|  2.41k|        zng_tr_emit_tree(s, DYN_TREES, last);
  ------------------
  |  |   56|  2.41k|#define DYN_TREES    2
  ------------------
  692|  2.41k|        send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, max_blindex+1);
  693|  2.41k|        compress_block(s, (const ct_data *)s->dyn_ltree, (const ct_data *)s->dyn_dtree);
  694|  2.41k|        cmpr_bits_add(s, s->opt_len);
  ------------------
  |  |  447|  2.41k|#  define cmpr_bits_add(s, len)     Z_UNUSED(len)
  |  |  ------------------
  |  |  |  |  154|  2.41k|#define Z_UNUSED(var) (void)(var)
  |  |  ------------------
  ------------------
  695|  2.41k|    }
  696|  3.04k|    Assert(s->compressed_len == s->bits_sent, "bad compressed size");
  697|       |    /* The above check is made mod 2^32, for files larger than 512 MB
  698|       |     * and unsigned long implemented on 32 bits.
  699|       |     */
  700|  3.04k|    init_block(s);
  701|       |
  702|  3.04k|    if (last) {
  ------------------
  |  Branch (702:9): [True: 1.52k, False: 1.52k]
  ------------------
  703|  1.52k|        zng_tr_emit_align(s);
  704|  1.52k|    }
  705|  3.04k|    Tracev((stderr, "\ncomprlen %lu(%lu) ", s->compressed_len>>3, s->compressed_len-7*last));
  706|  3.04k|}
zng_tr_flush_bits:
  811|  10.6k|void Z_INTERNAL zng_tr_flush_bits(deflate_state *s) {
  812|  10.6k|    if (s->bi_valid >= 48) {
  ------------------
  |  Branch (812:9): [True: 500, False: 10.1k]
  ------------------
  813|    500|        put_uint32(s, (uint32_t)s->bi_buf);
  814|    500|        put_short(s, (uint16_t)(s->bi_buf >> 32));
  815|    500|        s->bi_buf >>= 48;
  816|    500|        s->bi_valid -= 48;
  817|  10.1k|    } else if (s->bi_valid >= 32) {
  ------------------
  |  Branch (817:16): [True: 358, False: 9.78k]
  ------------------
  818|    358|        put_uint32(s, (uint32_t)s->bi_buf);
  819|    358|        s->bi_buf >>= 32;
  820|    358|        s->bi_valid -= 32;
  821|    358|    }
  822|  10.6k|    if (s->bi_valid >= 16) {
  ------------------
  |  Branch (822:9): [True: 283, False: 10.3k]
  ------------------
  823|    283|        put_short(s, (uint16_t)s->bi_buf);
  824|    283|        s->bi_buf >>= 16;
  825|    283|        s->bi_valid -= 16;
  826|    283|    }
  827|  10.6k|    if (s->bi_valid >= 8) {
  ------------------
  |  Branch (827:9): [True: 727, False: 9.92k]
  ------------------
  828|    727|        put_byte(s, s->bi_buf);
  ------------------
  |  |  349|    727|#define put_byte(s, c) { \
  |  |  350|    727|    s->pending_buf[s->pending++] = (unsigned char)(c); \
  |  |  351|    727|}
  ------------------
  829|    727|        s->bi_buf >>= 8;
  830|    727|        s->bi_valid -= 8;
  831|    727|    }
  832|  10.6k|}
trees.c:init_block:
  107|  4.56k|static void init_block(deflate_state *s) {
  108|  4.56k|    int n; /* iterates over tree elements */
  109|       |
  110|       |    /* Initialize the trees. */
  111|  1.30M|    for (n = 0; n < L_CODES;  n++)
  ------------------
  |  |   48|  1.30M|#define L_CODES (LITERALS+1+LENGTH_CODES)
  |  |  ------------------
  |  |  |  |   45|  1.30M|#define LITERALS  256
  |  |  ------------------
  |  |               #define L_CODES (LITERALS+1+LENGTH_CODES)
  |  |  ------------------
  |  |  |  |   42|  1.30M|#define LENGTH_CODES 29
  |  |  ------------------
  ------------------
  |  Branch (111:17): [True: 1.30M, False: 4.56k]
  ------------------
  112|  1.30M|        s->dyn_ltree[n].Freq = 0;
  ------------------
  |  |  125|  1.30M|#define Freq fc.freq
  ------------------
  113|   141k|    for (n = 0; n < D_CODES;  n++)
  ------------------
  |  |   51|   141k|#define D_CODES   30
  ------------------
  |  Branch (113:17): [True: 136k, False: 4.56k]
  ------------------
  114|   136k|        s->dyn_dtree[n].Freq = 0;
  ------------------
  |  |  125|   136k|#define Freq fc.freq
  ------------------
  115|  91.2k|    for (n = 0; n < BL_CODES; n++)
  ------------------
  |  |   54|  91.2k|#define BL_CODES  19
  ------------------
  |  Branch (115:17): [True: 86.6k, False: 4.56k]
  ------------------
  116|  86.6k|        s->bl_tree[n].Freq = 0;
  ------------------
  |  |  125|  86.6k|#define Freq fc.freq
  ------------------
  117|       |
  118|  4.56k|    s->dyn_ltree[END_BLOCK].Freq = 1;
  ------------------
  |  |   63|  4.56k|#define END_BLOCK 256
  ------------------
                  s->dyn_ltree[END_BLOCK].Freq = 1;
  ------------------
  |  |  125|  4.56k|#define Freq fc.freq
  ------------------
  119|  4.56k|    s->opt_len = s->static_len = 0;
  120|  4.56k|    s->sym_next = 0;
  121|  4.56k|}
trees.c:build_tree:
  184|  9.12k|static void build_tree(deflate_state *s, tree_desc *desc) {
  185|       |    /* desc: the tree descriptor */
  186|  9.12k|    unsigned char *depth  = s->depth;
  187|  9.12k|    int *heap             = s->heap;
  188|  9.12k|    ct_data *tree         = desc->dyn_tree;
  189|  9.12k|    const ct_data *stree  = desc->stat_desc->static_tree;
  190|  9.12k|    int elems             = desc->stat_desc->elems;
  191|  9.12k|    int n, m;          /* iterate over heap elements */
  192|  9.12k|    int max_code = -1; /* largest code with non zero frequency */
  193|  9.12k|    int node;          /* new node being created */
  194|       |
  195|       |    /* Construct the initial heap, with least frequent element in
  196|       |     * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
  197|       |     * heap[0] is not used.
  198|       |     */
  199|  9.12k|    s->heap_len = 0;
  200|  9.12k|    s->heap_max = HEAP_SIZE;
  ------------------
  |  |   57|  9.12k|#define HEAP_SIZE (2*L_CODES+1)
  |  |  ------------------
  |  |  |  |   48|  9.12k|#define L_CODES (LITERALS+1+LENGTH_CODES)
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  9.12k|#define LITERALS  256
  |  |  |  |  ------------------
  |  |  |  |               #define L_CODES (LITERALS+1+LENGTH_CODES)
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|  9.12k|#define LENGTH_CODES 29
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  201|       |
  202|  1.02M|    for (n = 0; n < elems; n++) {
  ------------------
  |  Branch (202:17): [True: 1.01M, False: 9.12k]
  ------------------
  203|  1.01M|        if (tree[n].Freq != 0) {
  ------------------
  |  |  125|  1.01M|#define Freq fc.freq
  ------------------
  |  Branch (203:13): [True: 27.0k, False: 992k]
  ------------------
  204|  27.0k|            heap[++(s->heap_len)] = max_code = n;
  205|  27.0k|            depth[n] = 0;
  206|   992k|        } else {
  207|   992k|            tree[n].Len = 0;
  ------------------
  |  |  128|   992k|#define Len  dl.len
  ------------------
  208|   992k|        }
  209|  1.01M|    }
  210|       |
  211|       |    /* The pkzip format requires that at least one distance code exists,
  212|       |     * and that at least one bit should be sent even if there is only one
  213|       |     * possible code. So to avoid special checks later on we force at least
  214|       |     * two codes of non zero frequency.
  215|       |     */
  216|  10.8k|    while (s->heap_len < 2) {
  ------------------
  |  Branch (216:12): [True: 1.71k, False: 9.12k]
  ------------------
  217|  1.71k|        node = heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0);
  ------------------
  |  Branch (217:41): [True: 1.71k, False: 1]
  ------------------
  218|  1.71k|        tree[node].Freq = 1;
  ------------------
  |  |  125|  1.71k|#define Freq fc.freq
  ------------------
  219|  1.71k|        depth[node] = 0;
  220|  1.71k|        s->opt_len--;
  221|  1.71k|        if (stree)
  ------------------
  |  Branch (221:13): [True: 1.71k, False: 0]
  ------------------
  222|  1.71k|            s->static_len -= stree[node].Len;
  ------------------
  |  |  128|  1.71k|#define Len  dl.len
  ------------------
  223|       |        /* node is 0 or 1 so it does not have extra bits */
  224|  1.71k|    }
  225|  9.12k|    desc->max_code = max_code;
  226|       |
  227|       |    /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
  228|       |     * establish sub-heaps of increasing lengths:
  229|       |     */
  230|  21.8k|    for (n = s->heap_len/2; n >= 1; n--)
  ------------------
  |  Branch (230:29): [True: 12.7k, False: 9.12k]
  ------------------
  231|  12.7k|        pqdownheap(depth, heap, s->heap_len, tree, n);
  232|       |
  233|       |    /* Construct the Huffman tree by repeatedly combining the least two
  234|       |     * frequent nodes.
  235|       |     */
  236|  9.12k|    node = elems;              /* next internal node of the tree */
  237|  19.5k|    do {
  238|  19.5k|        pqremove(s, depth, heap, tree, n);  /* n = node of least frequency */
  ------------------
  |  |  139|  19.5k|#define pqremove(s, depth, heap, tree, top) { \
  |  |  140|  19.5k|    top = heap[SMALLEST]; \
  |  |  ------------------
  |  |  |  |  123|  19.5k|#define SMALLEST 1
  |  |  ------------------
  |  |  141|  19.5k|    heap[SMALLEST] = heap[s->heap_len--]; \
  |  |  ------------------
  |  |  |  |  123|  19.5k|#define SMALLEST 1
  |  |  ------------------
  |  |  142|  19.5k|    pqdownheap(depth, heap, s->heap_len, tree, SMALLEST); \
  |  |  ------------------
  |  |  |  |  123|  19.5k|#define SMALLEST 1
  |  |  ------------------
  |  |  143|  19.5k|}
  ------------------
  239|  19.5k|        m = heap[SMALLEST]; /* m = node of next least frequency */
  ------------------
  |  |  123|  19.5k|#define SMALLEST 1
  ------------------
  240|       |
  241|  19.5k|        heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */
  242|  19.5k|        heap[--(s->heap_max)] = m;
  243|       |
  244|       |        /* Create a new node father of n and m */
  245|  19.5k|        tree[node].Freq = tree[n].Freq + tree[m].Freq;
  ------------------
  |  |  125|  19.5k|#define Freq fc.freq
  ------------------
                      tree[node].Freq = tree[n].Freq + tree[m].Freq;
  ------------------
  |  |  125|  19.5k|#define Freq fc.freq
  ------------------
                      tree[node].Freq = tree[n].Freq + tree[m].Freq;
  ------------------
  |  |  125|  19.5k|#define Freq fc.freq
  ------------------
  246|  19.5k|        depth[node] = (unsigned char)((depth[n] >= depth[m] ?
  ------------------
  |  Branch (246:40): [True: 14.3k, False: 5.26k]
  ------------------
  247|  14.3k|                                          depth[n] : depth[m]) + 1);
  248|  19.5k|        tree[n].Dad = tree[m].Dad = (uint16_t)node;
  ------------------
  |  |  127|  19.5k|#define Dad  dl.dad
  ------------------
                      tree[n].Dad = tree[m].Dad = (uint16_t)node;
  ------------------
  |  |  127|  19.5k|#define Dad  dl.dad
  ------------------
  249|       |#ifdef DUMP_BL_TREE
  250|       |        if (tree == s->bl_tree) {
  251|       |            fprintf(stderr, "\nnode %d(%d), sons %d(%d) %d(%d)",
  252|       |                    node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq);
  253|       |        }
  254|       |#endif
  255|       |        /* and insert the new node in the heap */
  256|  19.5k|        heap[SMALLEST] = node++;
  ------------------
  |  |  123|  19.5k|#define SMALLEST 1
  ------------------
  257|  19.5k|        pqdownheap(depth, heap, s->heap_len, tree, SMALLEST);
  ------------------
  |  |  123|  19.5k|#define SMALLEST 1
  ------------------
  258|  19.5k|    } while (s->heap_len >= 2);
  ------------------
  |  Branch (258:14): [True: 10.4k, False: 9.12k]
  ------------------
  259|       |
  260|  9.12k|    heap[--(s->heap_max)] = heap[SMALLEST];
  ------------------
  |  |  123|  9.12k|#define SMALLEST 1
  ------------------
  261|       |
  262|       |    /* At this point, the fields freq and dad are set. We can now
  263|       |     * generate the bit lengths.
  264|       |     */
  265|  9.12k|    gen_bitlen(s, (tree_desc *)desc);
  266|       |
  267|       |    /* The field len is now set, we can generate the bit codes */
  268|  9.12k|    gen_codes((ct_data *)tree, max_code, s->bl_count);
  269|  9.12k|}
trees.c:pqdownheap:
  151|  51.9k|static inline void pqdownheap(unsigned char *depth, int *heap, const int heap_len, ct_data *tree, int k) {
  152|       |    /* tree: the tree to restore */
  153|       |    /* k: node to move down */
  154|  51.9k|    int j = k << 1;  /* left son of k */
  155|  51.9k|    const int v = heap[k];
  156|       |
  157|  75.7k|    while (j <= heap_len) {
  ------------------
  |  Branch (157:12): [True: 35.4k, False: 40.2k]
  ------------------
  158|       |        /* Set j to the smallest of the two sons: */
  159|  35.4k|        if (j < heap_len && smaller(tree, heap[j+1], heap[j], depth)) {
  ------------------
  |  |  132|  16.3k|    (tree[n].Freq < tree[m].Freq || \
  |  |  ------------------
  |  |  |  |  125|  16.3k|#define Freq fc.freq
  |  |  ------------------
  |  |                   (tree[n].Freq < tree[m].Freq || \
  |  |  ------------------
  |  |  |  |  125|  32.7k|#define Freq fc.freq
  |  |  ------------------
  |  |  |  Branch (132:6): [True: 5.10k, False: 11.2k]
  |  |  ------------------
  |  |  133|  16.3k|    (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
  |  |  ------------------
  |  |  |  |  125|  11.2k|#define Freq fc.freq
  |  |  ------------------
  |  |                   (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
  |  |  ------------------
  |  |  |  |  125|  22.5k|#define Freq fc.freq
  |  |  ------------------
  |  |  |  Branch (133:6): [True: 3.08k, False: 8.17k]
  |  |  |  Branch (133:38): [True: 2.89k, False: 194]
  |  |  ------------------
  ------------------
  |  Branch (159:13): [True: 16.3k, False: 19.0k]
  ------------------
  160|  7.99k|            j++;
  161|  7.99k|        }
  162|       |        /* Exit if v is smaller than both sons */
  163|  35.4k|        if (smaller(tree, v, heap[j], depth))
  ------------------
  |  |  132|  35.4k|    (tree[n].Freq < tree[m].Freq || \
  |  |  ------------------
  |  |  |  |  125|  35.4k|#define Freq fc.freq
  |  |  ------------------
  |  |                   (tree[n].Freq < tree[m].Freq || \
  |  |  ------------------
  |  |  |  |  125|  70.9k|#define Freq fc.freq
  |  |  ------------------
  |  |  |  Branch (132:6): [True: 7.82k, False: 27.6k]
  |  |  ------------------
  |  |  133|  35.4k|    (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
  |  |  ------------------
  |  |  |  |  125|  27.6k|#define Freq fc.freq
  |  |  ------------------
  |  |                   (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
  |  |  ------------------
  |  |  |  |  125|  55.2k|#define Freq fc.freq
  |  |  ------------------
  |  |  |  Branch (133:6): [True: 7.98k, False: 19.6k]
  |  |  |  Branch (133:38): [True: 3.81k, False: 4.17k]
  |  |  ------------------
  ------------------
  164|  11.6k|            break;
  165|       |
  166|       |        /* Exchange v with the smallest son */
  167|  23.8k|        heap[k] = heap[j];
  168|  23.8k|        k = j;
  169|       |
  170|       |        /* And continue down the tree, setting j to the left son of k */
  171|  23.8k|        j <<= 1;
  172|  23.8k|    }
  173|  51.9k|    heap[k] = v;
  174|  51.9k|}
trees.c:gen_bitlen:
  281|  9.12k|static void gen_bitlen(deflate_state *s, tree_desc *desc) {
  282|       |    /* desc: the tree descriptor */
  283|  9.12k|    ct_data *tree           = desc->dyn_tree;
  284|  9.12k|    int max_code            = desc->max_code;
  285|  9.12k|    const ct_data *stree    = desc->stat_desc->static_tree;
  286|  9.12k|    const int *extra        = desc->stat_desc->extra_bits;
  287|  9.12k|    int base                = desc->stat_desc->extra_base;
  288|  9.12k|    unsigned int max_length = desc->stat_desc->max_length;
  289|  9.12k|    int h;              /* heap index */
  290|  9.12k|    int n, m;           /* iterate over the tree elements */
  291|  9.12k|    unsigned int bits;  /* bit length */
  292|  9.12k|    int xbits;          /* extra bits */
  293|  9.12k|    uint16_t f;         /* frequency */
  294|  9.12k|    int overflow = 0;   /* number of elements with bit length too large */
  295|       |
  296|   155k|    for (bits = 0; bits <= MAX_BITS; bits++)
  ------------------
  |  |   39|   155k|#define MAX_BITS 15
  ------------------
  |  Branch (296:20): [True: 146k, False: 9.12k]
  ------------------
  297|   146k|        s->bl_count[bits] = 0;
  298|       |
  299|       |    /* In a first pass, compute the optimal bit lengths (which may
  300|       |     * overflow in the case of the bit length tree).
  301|       |     */
  302|  9.12k|    tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */
  ------------------
  |  |  128|  9.12k|#define Len  dl.len
  ------------------
  303|       |
  304|  48.3k|    for (h = s->heap_max + 1; h < HEAP_SIZE; h++) {
  ------------------
  |  |   57|  48.3k|#define HEAP_SIZE (2*L_CODES+1)
  |  |  ------------------
  |  |  |  |   48|  48.3k|#define L_CODES (LITERALS+1+LENGTH_CODES)
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  48.3k|#define LITERALS  256
  |  |  |  |  ------------------
  |  |  |  |               #define L_CODES (LITERALS+1+LENGTH_CODES)
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|  48.3k|#define LENGTH_CODES 29
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (304:31): [True: 39.1k, False: 9.12k]
  ------------------
  305|  39.1k|        n = s->heap[h];
  306|  39.1k|        bits = tree[tree[n].Dad].Len + 1u;
  ------------------
  |  |  127|  39.1k|#define Dad  dl.dad
  ------------------
                      bits = tree[tree[n].Dad].Len + 1u;
  ------------------
  |  |  128|  39.1k|#define Len  dl.len
  ------------------
  307|  39.1k|        if (bits > max_length){
  ------------------
  |  Branch (307:13): [True: 0, False: 39.1k]
  ------------------
  308|      0|            bits = max_length;
  309|      0|            overflow++;
  310|      0|        }
  311|  39.1k|        tree[n].Len = (uint16_t)bits;
  ------------------
  |  |  128|  39.1k|#define Len  dl.len
  ------------------
  312|       |        /* We overwrite tree[n].Dad which is no longer needed */
  313|       |
  314|  39.1k|        if (n > max_code) /* not a leaf node */
  ------------------
  |  Branch (314:13): [True: 10.4k, False: 28.7k]
  ------------------
  315|  10.4k|            continue;
  316|       |
  317|  28.7k|        s->bl_count[bits]++;
  318|  28.7k|        xbits = 0;
  319|  28.7k|        if (n >= base)
  ------------------
  |  Branch (319:13): [True: 23.9k, False: 4.73k]
  ------------------
  320|  23.9k|            xbits = extra[n-base];
  321|  28.7k|        f = tree[n].Freq;
  ------------------
  |  |  125|  28.7k|#define Freq fc.freq
  ------------------
  322|  28.7k|        s->opt_len += (unsigned int)f * (unsigned int)(bits + xbits);
  323|  28.7k|        if (stree)
  ------------------
  |  Branch (323:13): [True: 16.5k, False: 12.2k]
  ------------------
  324|  16.5k|            s->static_len += (unsigned int)f * (unsigned int)(stree[n].Len + xbits);
  ------------------
  |  |  128|  16.5k|#define Len  dl.len
  ------------------
  325|  28.7k|    }
  326|  9.12k|    if (overflow == 0)
  ------------------
  |  Branch (326:9): [True: 9.12k, False: 0]
  ------------------
  327|  9.12k|        return;
  328|       |
  329|      0|    Tracev((stderr, "\nbit length overflow\n"));
  330|       |    /* This happens for example on obj2 and pic of the Calgary corpus */
  331|       |
  332|       |    /* Find the first bit length which could increase: */
  333|      0|    do {
  334|      0|        bits = max_length - 1;
  335|      0|        while (s->bl_count[bits] == 0)
  ------------------
  |  Branch (335:16): [True: 0, False: 0]
  ------------------
  336|      0|            bits--;
  337|      0|        s->bl_count[bits]--;       /* move one leaf down the tree */
  338|      0|        s->bl_count[bits+1] += 2u; /* move one overflow item as its brother */
  339|      0|        s->bl_count[max_length]--;
  340|       |        /* The brother of the overflow item also moves one step up,
  341|       |         * but this does not affect bl_count[max_length]
  342|       |         */
  343|      0|        overflow -= 2;
  344|      0|    } while (overflow > 0);
  ------------------
  |  Branch (344:14): [True: 0, False: 0]
  ------------------
  345|       |
  346|       |    /* Now recompute all bit lengths, scanning in increasing frequency.
  347|       |     * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
  348|       |     * lengths instead of fixing only the wrong ones. This idea is taken
  349|       |     * from 'ar' written by Haruhiko Okumura.)
  350|       |     */
  351|      0|    for (bits = max_length; bits != 0; bits--) {
  ------------------
  |  Branch (351:29): [True: 0, False: 0]
  ------------------
  352|      0|        n = s->bl_count[bits];
  353|      0|        while (n != 0) {
  ------------------
  |  Branch (353:16): [True: 0, False: 0]
  ------------------
  354|      0|            m = s->heap[--h];
  355|      0|            if (m > max_code)
  ------------------
  |  Branch (355:17): [True: 0, False: 0]
  ------------------
  356|      0|                continue;
  357|      0|            if (tree[m].Len != bits) {
  ------------------
  |  |  128|      0|#define Len  dl.len
  ------------------
  |  Branch (357:17): [True: 0, False: 0]
  ------------------
  358|      0|                Tracev((stderr, "code %d bits %d->%u\n", m, tree[m].Len, bits));
  359|      0|                s->opt_len += (unsigned int)(bits * tree[m].Freq);
  ------------------
  |  |  125|      0|#define Freq fc.freq
  ------------------
  360|      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
  ------------------
  361|      0|                tree[m].Len = (uint16_t)bits;
  ------------------
  |  |  128|      0|#define Len  dl.len
  ------------------
  362|      0|            }
  363|      0|            n--;
  364|      0|        }
  365|      0|    }
  366|      0|}
trees.c:build_bl_tree:
  528|  3.04k|static int build_bl_tree(deflate_state *s) {
  529|  3.04k|    int max_blindex;  /* index of last bit length code of non zero freq */
  530|       |
  531|       |    /* Determine the bit length frequencies for literal and distance trees */
  532|  3.04k|    scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code);
  533|  3.04k|    scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code);
  534|       |
  535|       |    /* Build the bit length tree: */
  536|  3.04k|    build_tree(s, (tree_desc *)(&(s->bl_desc)));
  537|       |    /* opt_len now includes the length of the tree representations, except
  538|       |     * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
  539|       |     */
  540|       |
  541|       |    /* Determine the number of bit length codes to send. The pkzip format
  542|       |     * requires that at least 4 bit length codes be sent. (appnote.txt says
  543|       |     * 3 but the actual value used is 4.)
  544|       |     */
  545|  6.08k|    for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {
  ------------------
  |  |   54|  3.04k|#define BL_CODES  19
  ------------------
  |  Branch (545:36): [True: 6.08k, False: 0]
  ------------------
  546|  6.08k|        if (s->bl_tree[bl_order[max_blindex]].Len != 0)
  ------------------
  |  |  128|  6.08k|#define Len  dl.len
  ------------------
  |  Branch (546:13): [True: 3.04k, False: 3.04k]
  ------------------
  547|  3.04k|            break;
  548|  6.08k|    }
  549|       |    /* Update opt_len to include the bit length tree and counts */
  550|  3.04k|    s->opt_len += 3*((unsigned int)max_blindex+1) + 5+5+4;
  551|  3.04k|    Tracev((stderr, "\ndyn trees: dyn %u, stat %u", s->opt_len, s->static_len));
  552|       |
  553|  3.04k|    return max_blindex;
  554|  3.04k|}
trees.c:scan_tree:
  414|  6.08k|static void scan_tree(deflate_state *s, ct_data *tree, int max_code) {
  415|       |    /* tree: the tree to be scanned */
  416|       |    /* max_code: and its largest code of non zero frequency */
  417|  6.08k|    int n;                     /* iterates over all tree elements */
  418|  6.08k|    int prevlen = -1;          /* last emitted length */
  419|  6.08k|    int curlen;                /* length of current code */
  420|  6.08k|    int nextlen = tree[0].Len; /* length of next code */
  ------------------
  |  |  128|  6.08k|#define Len  dl.len
  ------------------
  421|  6.08k|    uint16_t count = 0;        /* repeat count of the current code */
  422|  6.08k|    uint16_t max_count = 7;    /* max repeat count */
  423|  6.08k|    uint16_t min_count = 4;    /* min repeat count */
  424|       |
  425|  6.08k|    if (nextlen == 0)
  ------------------
  |  Branch (425:9): [True: 1.34k, False: 4.73k]
  ------------------
  426|  1.34k|        max_count = 138, min_count = 3;
  427|       |
  428|  6.08k|    tree[max_code+1].Len = (uint16_t)0xffff; /* guard */
  ------------------
  |  |  128|  6.08k|#define Len  dl.len
  ------------------
  429|       |
  430|   902k|    for (n = 0; n <= max_code; n++) {
  ------------------
  |  Branch (430:17): [True: 895k, False: 6.08k]
  ------------------
  431|   895k|        curlen = nextlen;
  432|   895k|        nextlen = tree[n+1].Len;
  ------------------
  |  |  128|   895k|#define Len  dl.len
  ------------------
  433|   895k|        if (++count < max_count && curlen == nextlen) {
  ------------------
  |  Branch (433:13): [True: 892k, False: 3.04k]
  |  Branch (433:36): [True: 868k, False: 24.5k]
  ------------------
  434|   868k|            continue;
  435|   868k|        } else if (count < min_count) {
  ------------------
  |  Branch (435:20): [True: 15.3k, False: 12.1k]
  ------------------
  436|  15.3k|            s->bl_tree[curlen].Freq += count;
  ------------------
  |  |  125|  15.3k|#define Freq fc.freq
  ------------------
  437|  15.3k|        } else if (curlen != 0) {
  ------------------
  |  Branch (437:20): [True: 0, False: 12.1k]
  ------------------
  438|      0|            if (curlen != prevlen)
  ------------------
  |  Branch (438:17): [True: 0, False: 0]
  ------------------
  439|      0|                s->bl_tree[curlen].Freq++;
  ------------------
  |  |  125|      0|#define Freq fc.freq
  ------------------
  440|      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
  ------------------
  441|  12.1k|        } else if (count <= 10) {
  ------------------
  |  Branch (441:20): [True: 1.29k, False: 10.8k]
  ------------------
  442|  1.29k|            s->bl_tree[REPZ_3_10].Freq++;
  ------------------
  |  |   15|  1.29k|#define REPZ_3_10    17
  ------------------
                          s->bl_tree[REPZ_3_10].Freq++;
  ------------------
  |  |  125|  1.29k|#define Freq fc.freq
  ------------------
  443|  10.8k|        } else {
  444|  10.8k|            s->bl_tree[REPZ_11_138].Freq++;
  ------------------
  |  |   18|  10.8k|#define REPZ_11_138  18
  ------------------
                          s->bl_tree[REPZ_11_138].Freq++;
  ------------------
  |  |  125|  10.8k|#define Freq fc.freq
  ------------------
  445|  10.8k|        }
  446|  27.5k|        count = 0;
  447|  27.5k|        prevlen = curlen;
  448|  27.5k|        if (nextlen == 0) {
  ------------------
  |  Branch (448:13): [True: 11.4k, False: 16.1k]
  ------------------
  449|  11.4k|            max_count = 138, min_count = 3;
  450|  16.1k|        } else if (curlen == nextlen) {
  ------------------
  |  Branch (450:20): [True: 0, False: 16.1k]
  ------------------
  451|      0|            max_count = 6, min_count = 3;
  452|  16.1k|        } else {
  453|  16.1k|            max_count = 7, min_count = 4;
  454|  16.1k|        }
  455|  27.5k|    }
  456|  6.08k|}
trees.c:send_all_trees:
  561|  2.41k|static void send_all_trees(deflate_state *s, int lcodes, int dcodes, int blcodes) {
  562|  2.41k|    int rank;                    /* index in bl_order */
  563|       |
  564|  2.41k|    Assert(lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
  565|  2.41k|    Assert(lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, "too many codes");
  566|       |
  567|       |    // Temp local variables
  568|  2.41k|    uint32_t bi_valid = s->bi_valid;
  569|  2.41k|    uint64_t bi_buf = s->bi_buf;
  570|       |
  571|  2.41k|    Tracev((stderr, "\nbl counts: "));
  572|  2.41k|    send_bits(s, lcodes-257, 5, bi_buf, bi_valid); /* not +255 as stated in appnote.txt */
  ------------------
  |  |   47|  2.41k|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) {\
  |  |   48|  2.41k|    uint64_t val = (uint64_t)t_val;\
  |  |   49|  2.41k|    uint32_t len = (uint32_t)t_len;\
  |  |   50|  2.41k|    uint32_t total_bits = bi_valid + len;\
  |  |   51|  2.41k|    send_bits_trace(s, val, len);\
  |  |   52|  2.41k|    sent_bits_add(s, len);\
  |  |  ------------------
  |  |  |  |  449|  2.41k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  2.41k|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   53|  2.41k|    if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|  4.82k|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |                   if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|  2.41k|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |  |  Branch (53:9): [True: 2.41k, False: 0]
  |  |  |  Branch (53:38): [True: 2.41k, False: 0]
  |  |  ------------------
  |  |   54|  2.41k|        bi_buf |= val << bi_valid;\
  |  |   55|  2.41k|        bi_valid = total_bits;\
  |  |   56|  2.41k|    } else if (bi_valid >= BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |  |  Branch (56:16): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |   58|      0|        bi_buf = val;\
  |  |   59|      0|        bi_valid = len;\
  |  |   60|      0|    } else {\
  |  |   61|      0|        bi_buf |= val << bi_valid;\
  |  |   62|      0|        put_uint64(s, bi_buf);\
  |  |   63|      0|        bi_buf = val >> (BIT_BUF_SIZE - bi_valid);\
  |  |  ------------------
  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |   64|      0|        bi_valid = total_bits - BIT_BUF_SIZE;\
  |  |  ------------------
  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |   65|      0|    }\
  |  |   66|  2.41k|}
  ------------------
  573|  2.41k|    send_bits(s, dcodes-1,   5, bi_buf, bi_valid);
  ------------------
  |  |   47|  2.41k|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) {\
  |  |   48|  2.41k|    uint64_t val = (uint64_t)t_val;\
  |  |   49|  2.41k|    uint32_t len = (uint32_t)t_len;\
  |  |   50|  2.41k|    uint32_t total_bits = bi_valid + len;\
  |  |   51|  2.41k|    send_bits_trace(s, val, len);\
  |  |   52|  2.41k|    sent_bits_add(s, len);\
  |  |  ------------------
  |  |  |  |  449|  2.41k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  2.41k|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   53|  2.41k|    if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|  4.82k|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |                   if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|  2.41k|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |  |  Branch (53:9): [True: 2.41k, False: 0]
  |  |  |  Branch (53:38): [True: 2.41k, False: 0]
  |  |  ------------------
  |  |   54|  2.41k|        bi_buf |= val << bi_valid;\
  |  |   55|  2.41k|        bi_valid = total_bits;\
  |  |   56|  2.41k|    } else if (bi_valid >= BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |  |  Branch (56:16): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |   58|      0|        bi_buf = val;\
  |  |   59|      0|        bi_valid = len;\
  |  |   60|      0|    } else {\
  |  |   61|      0|        bi_buf |= val << bi_valid;\
  |  |   62|      0|        put_uint64(s, bi_buf);\
  |  |   63|      0|        bi_buf = val >> (BIT_BUF_SIZE - bi_valid);\
  |  |  ------------------
  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |   64|      0|        bi_valid = total_bits - BIT_BUF_SIZE;\
  |  |  ------------------
  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |   65|      0|    }\
  |  |   66|  2.41k|}
  ------------------
  574|  2.41k|    send_bits(s, blcodes-4,  4, bi_buf, bi_valid); /* not -3 as stated in appnote.txt */
  ------------------
  |  |   47|  2.41k|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) {\
  |  |   48|  2.41k|    uint64_t val = (uint64_t)t_val;\
  |  |   49|  2.41k|    uint32_t len = (uint32_t)t_len;\
  |  |   50|  2.41k|    uint32_t total_bits = bi_valid + len;\
  |  |   51|  2.41k|    send_bits_trace(s, val, len);\
  |  |   52|  2.41k|    sent_bits_add(s, len);\
  |  |  ------------------
  |  |  |  |  449|  2.41k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  2.41k|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   53|  2.41k|    if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|  4.82k|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |                   if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|  2.41k|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |  |  Branch (53:9): [True: 2.41k, False: 0]
  |  |  |  Branch (53:38): [True: 2.41k, False: 0]
  |  |  ------------------
  |  |   54|  2.41k|        bi_buf |= val << bi_valid;\
  |  |   55|  2.41k|        bi_valid = total_bits;\
  |  |   56|  2.41k|    } else if (bi_valid >= BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |  |  Branch (56:16): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |   58|      0|        bi_buf = val;\
  |  |   59|      0|        bi_valid = len;\
  |  |   60|      0|    } else {\
  |  |   61|      0|        bi_buf |= val << bi_valid;\
  |  |   62|      0|        put_uint64(s, bi_buf);\
  |  |   63|      0|        bi_buf = val >> (BIT_BUF_SIZE - bi_valid);\
  |  |  ------------------
  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |   64|      0|        bi_valid = total_bits - BIT_BUF_SIZE;\
  |  |  ------------------
  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |   65|      0|    }\
  |  |   66|  2.41k|}
  ------------------
  575|  45.8k|    for (rank = 0; rank < blcodes; rank++) {
  ------------------
  |  Branch (575:20): [True: 43.4k, False: 2.41k]
  ------------------
  576|  43.4k|        Tracev((stderr, "\nbl code %2u ", bl_order[rank]));
  577|  43.4k|        send_bits(s, s->bl_tree[bl_order[rank]].Len, 3, bi_buf, bi_valid);
  ------------------
  |  |   47|  43.4k|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) {\
  |  |   48|  43.4k|    uint64_t val = (uint64_t)t_val;\
  |  |   49|  43.4k|    uint32_t len = (uint32_t)t_len;\
  |  |   50|  43.4k|    uint32_t total_bits = bi_valid + len;\
  |  |   51|  43.4k|    send_bits_trace(s, val, len);\
  |  |   52|  43.4k|    sent_bits_add(s, len);\
  |  |  ------------------
  |  |  |  |  449|  43.4k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  43.4k|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   53|  43.4k|    if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|  86.8k|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |                   if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|  41.0k|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |  |  Branch (53:9): [True: 41.0k, False: 2.41k]
  |  |  |  Branch (53:38): [True: 41.0k, False: 0]
  |  |  ------------------
  |  |   54|  41.0k|        bi_buf |= val << bi_valid;\
  |  |   55|  41.0k|        bi_valid = total_bits;\
  |  |   56|  41.0k|    } else if (bi_valid >= BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|  4.82k|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |  |  Branch (56:16): [True: 0, False: 2.41k]
  |  |  ------------------
  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |   58|      0|        bi_buf = val;\
  |  |   59|      0|        bi_valid = len;\
  |  |   60|  2.41k|    } else {\
  |  |   61|  2.41k|        bi_buf |= val << bi_valid;\
  |  |   62|  2.41k|        put_uint64(s, bi_buf);\
  |  |   63|  2.41k|        bi_buf = val >> (BIT_BUF_SIZE - bi_valid);\
  |  |  ------------------
  |  |  |  |   60|  2.41k|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |   64|  2.41k|        bi_valid = total_bits - BIT_BUF_SIZE;\
  |  |  ------------------
  |  |  |  |   60|  2.41k|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |   65|  2.41k|    }\
  |  |   66|  43.4k|}
  ------------------
  578|  43.4k|    }
  579|  2.41k|    Tracev((stderr, "\nbl tree: sent %lu", s->bits_sent));
  580|       |
  581|       |    // Store back temp variables
  582|  2.41k|    s->bi_buf = bi_buf;
  583|  2.41k|    s->bi_valid = bi_valid;
  584|       |
  585|  2.41k|    send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */
  586|  2.41k|    Tracev((stderr, "\nlit tree: sent %lu", s->bits_sent));
  587|       |
  588|  2.41k|    send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */
  589|  2.41k|    Tracev((stderr, "\ndist tree: sent %lu", s->bits_sent));
  590|  2.41k|}
trees.c:send_tree:
  462|  4.82k|static void send_tree(deflate_state *s, ct_data *tree, int max_code) {
  463|       |    /* tree: the tree to be scanned */
  464|       |    /* max_code and its largest code of non zero frequency */
  465|  4.82k|    int n;                     /* iterates over all tree elements */
  466|  4.82k|    int prevlen = -1;          /* last emitted length */
  467|  4.82k|    int curlen;                /* length of current code */
  468|  4.82k|    int nextlen = tree[0].Len; /* length of next code */
  ------------------
  |  |  128|  4.82k|#define Len  dl.len
  ------------------
  469|  4.82k|    int count = 0;             /* repeat count of the current code */
  470|  4.82k|    int max_count = 7;         /* max repeat count */
  471|  4.82k|    int min_count = 4;         /* min repeat count */
  472|       |
  473|       |    /* tree[max_code+1].Len = -1; */  /* guard already set */
  474|  4.82k|    if (nextlen == 0)
  ------------------
  |  Branch (474:9): [True: 1.03k, False: 3.79k]
  ------------------
  475|  1.03k|        max_count = 138, min_count = 3;
  476|       |
  477|       |    // Temp local variables
  478|  4.82k|    uint32_t bi_valid = s->bi_valid;
  479|  4.82k|    uint64_t bi_buf = s->bi_buf;
  480|       |
  481|   717k|    for (n = 0; n <= max_code; n++) {
  ------------------
  |  Branch (481:17): [True: 712k, False: 4.82k]
  ------------------
  482|   712k|        curlen = nextlen;
  483|   712k|        nextlen = tree[n+1].Len;
  ------------------
  |  |  128|   712k|#define Len  dl.len
  ------------------
  484|   712k|        if (++count < max_count && curlen == nextlen) {
  ------------------
  |  Branch (484:13): [True: 710k, False: 2.41k]
  |  Branch (484:36): [True: 690k, False: 19.8k]
  ------------------
  485|   690k|            continue;
  486|   690k|        } else if (count < min_count) {
  ------------------
  |  Branch (486:20): [True: 12.4k, False: 9.79k]
  ------------------
  487|  13.9k|            do {
  488|  13.9k|                send_code(s, curlen, s->bl_tree, bi_buf, bi_valid);
  ------------------
  |  |   76|  13.9k|    send_bits(s, tree[c].Code, tree[c].Len, bi_buf, bi_valid)
  |  |  ------------------
  |  |  |  |   47|  13.9k|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) {\
  |  |  |  |   48|  13.9k|    uint64_t val = (uint64_t)t_val;\
  |  |  |  |   49|  13.9k|    uint32_t len = (uint32_t)t_len;\
  |  |  |  |   50|  13.9k|    uint32_t total_bits = bi_valid + len;\
  |  |  |  |   51|  13.9k|    send_bits_trace(s, val, len);\
  |  |  |  |   52|  13.9k|    sent_bits_add(s, len);\
  |  |  |  |  ------------------
  |  |  |  |  |  |  449|  13.9k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  154|  13.9k|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   53|  13.9k|    if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  27.9k|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |                   if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  13.9k|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (53:9): [True: 13.9k, False: 0]
  |  |  |  |  |  Branch (53:38): [True: 13.9k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   54|  13.9k|        bi_buf |= val << bi_valid;\
  |  |  |  |   55|  13.9k|        bi_valid = total_bits;\
  |  |  |  |   56|  13.9k|    } else if (bi_valid >= BIT_BUF_SIZE) {\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (56:16): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |  |  |   58|      0|        bi_buf = val;\
  |  |  |  |   59|      0|        bi_valid = len;\
  |  |  |  |   60|      0|    } else {\
  |  |  |  |   61|      0|        bi_buf |= val << bi_valid;\
  |  |  |  |   62|      0|        put_uint64(s, bi_buf);\
  |  |  |  |   63|      0|        bi_buf = val >> (BIT_BUF_SIZE - bi_valid);\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |   64|      0|        bi_valid = total_bits - BIT_BUF_SIZE;\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |   65|      0|    }\
  |  |  |  |   66|  13.9k|}
  |  |  ------------------
  ------------------
  489|  13.9k|            } while (--count != 0);
  ------------------
  |  Branch (489:22): [True: 1.51k, False: 12.4k]
  ------------------
  490|       |
  491|  12.4k|        } else if (curlen != 0) {
  ------------------
  |  Branch (491:20): [True: 0, False: 9.79k]
  ------------------
  492|      0|            if (curlen != prevlen) {
  ------------------
  |  Branch (492:17): [True: 0, False: 0]
  ------------------
  493|      0|                send_code(s, curlen, s->bl_tree, bi_buf, bi_valid);
  ------------------
  |  |   76|      0|    send_bits(s, tree[c].Code, tree[c].Len, bi_buf, bi_valid)
  |  |  ------------------
  |  |  |  |   47|      0|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) {\
  |  |  |  |   48|      0|    uint64_t val = (uint64_t)t_val;\
  |  |  |  |   49|      0|    uint32_t len = (uint32_t)t_len;\
  |  |  |  |   50|      0|    uint32_t total_bits = bi_valid + len;\
  |  |  |  |   51|      0|    send_bits_trace(s, val, len);\
  |  |  |  |   52|      0|    sent_bits_add(s, len);\
  |  |  |  |  ------------------
  |  |  |  |  |  |  449|      0|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  154|      0|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   53|      0|    if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |                   if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (53:9): [True: 0, False: 0]
  |  |  |  |  |  Branch (53:38): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   54|      0|        bi_buf |= val << bi_valid;\
  |  |  |  |   55|      0|        bi_valid = total_bits;\
  |  |  |  |   56|      0|    } else if (bi_valid >= BIT_BUF_SIZE) {\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (56:16): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |  |  |   58|      0|        bi_buf = val;\
  |  |  |  |   59|      0|        bi_valid = len;\
  |  |  |  |   60|      0|    } else {\
  |  |  |  |   61|      0|        bi_buf |= val << bi_valid;\
  |  |  |  |   62|      0|        put_uint64(s, bi_buf);\
  |  |  |  |   63|      0|        bi_buf = val >> (BIT_BUF_SIZE - bi_valid);\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |   64|      0|        bi_valid = total_bits - BIT_BUF_SIZE;\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |   65|      0|    }\
  |  |  |  |   66|      0|}
  |  |  ------------------
  ------------------
  494|      0|                count--;
  495|      0|            }
  496|      0|            Assert(count >= 3 && count <= 6, " 3_6?");
  497|      0|            send_code(s, REP_3_6, s->bl_tree, bi_buf, bi_valid);
  ------------------
  |  |   76|      0|    send_bits(s, tree[c].Code, tree[c].Len, bi_buf, bi_valid)
  |  |  ------------------
  |  |  |  |   47|      0|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) {\
  |  |  |  |   48|      0|    uint64_t val = (uint64_t)t_val;\
  |  |  |  |   49|      0|    uint32_t len = (uint32_t)t_len;\
  |  |  |  |   50|      0|    uint32_t total_bits = bi_valid + len;\
  |  |  |  |   51|      0|    send_bits_trace(s, val, len);\
  |  |  |  |   52|      0|    sent_bits_add(s, len);\
  |  |  |  |  ------------------
  |  |  |  |  |  |  449|      0|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  154|      0|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   53|      0|    if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |                   if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (53:9): [True: 0, False: 0]
  |  |  |  |  |  Branch (53:38): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   54|      0|        bi_buf |= val << bi_valid;\
  |  |  |  |   55|      0|        bi_valid = total_bits;\
  |  |  |  |   56|      0|    } else if (bi_valid >= BIT_BUF_SIZE) {\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (56:16): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |  |  |   58|      0|        bi_buf = val;\
  |  |  |  |   59|      0|        bi_valid = len;\
  |  |  |  |   60|      0|    } else {\
  |  |  |  |   61|      0|        bi_buf |= val << bi_valid;\
  |  |  |  |   62|      0|        put_uint64(s, bi_buf);\
  |  |  |  |   63|      0|        bi_buf = val >> (BIT_BUF_SIZE - bi_valid);\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |   64|      0|        bi_valid = total_bits - BIT_BUF_SIZE;\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |   65|      0|    }\
  |  |  |  |   66|      0|}
  |  |  ------------------
  ------------------
  498|      0|            send_bits(s, count-3, 2, bi_buf, bi_valid);
  ------------------
  |  |   47|      0|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) {\
  |  |   48|      0|    uint64_t val = (uint64_t)t_val;\
  |  |   49|      0|    uint32_t len = (uint32_t)t_len;\
  |  |   50|      0|    uint32_t total_bits = bi_valid + len;\
  |  |   51|      0|    send_bits_trace(s, val, len);\
  |  |   52|      0|    sent_bits_add(s, len);\
  |  |  ------------------
  |  |  |  |  449|      0|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   53|      0|    if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |                   if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |  |  Branch (53:9): [True: 0, False: 0]
  |  |  |  Branch (53:38): [True: 0, False: 0]
  |  |  ------------------
  |  |   54|      0|        bi_buf |= val << bi_valid;\
  |  |   55|      0|        bi_valid = total_bits;\
  |  |   56|      0|    } else if (bi_valid >= BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |  |  Branch (56:16): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |   58|      0|        bi_buf = val;\
  |  |   59|      0|        bi_valid = len;\
  |  |   60|      0|    } else {\
  |  |   61|      0|        bi_buf |= val << bi_valid;\
  |  |   62|      0|        put_uint64(s, bi_buf);\
  |  |   63|      0|        bi_buf = val >> (BIT_BUF_SIZE - bi_valid);\
  |  |  ------------------
  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |   64|      0|        bi_valid = total_bits - BIT_BUF_SIZE;\
  |  |  ------------------
  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |   65|      0|    }\
  |  |   66|      0|}
  ------------------
  499|       |
  500|  9.79k|        } else if (count <= 10) {
  ------------------
  |  Branch (500:20): [True: 1.08k, False: 8.71k]
  ------------------
  501|  1.08k|            send_code(s, REPZ_3_10, s->bl_tree, bi_buf, bi_valid);
  ------------------
  |  |   76|  1.08k|    send_bits(s, tree[c].Code, tree[c].Len, bi_buf, bi_valid)
  |  |  ------------------
  |  |  |  |   47|  1.08k|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) {\
  |  |  |  |   48|  1.08k|    uint64_t val = (uint64_t)t_val;\
  |  |  |  |   49|  1.08k|    uint32_t len = (uint32_t)t_len;\
  |  |  |  |   50|  1.08k|    uint32_t total_bits = bi_valid + len;\
  |  |  |  |   51|  1.08k|    send_bits_trace(s, val, len);\
  |  |  |  |   52|  1.08k|    sent_bits_add(s, len);\
  |  |  |  |  ------------------
  |  |  |  |  |  |  449|  1.08k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  154|  1.08k|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   53|  1.08k|    if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  2.16k|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |                   if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  1.08k|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (53:9): [True: 1.08k, False: 0]
  |  |  |  |  |  Branch (53:38): [True: 1.08k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   54|  1.08k|        bi_buf |= val << bi_valid;\
  |  |  |  |   55|  1.08k|        bi_valid = total_bits;\
  |  |  |  |   56|  1.08k|    } else if (bi_valid >= BIT_BUF_SIZE) {\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (56:16): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |  |  |   58|      0|        bi_buf = val;\
  |  |  |  |   59|      0|        bi_valid = len;\
  |  |  |  |   60|      0|    } else {\
  |  |  |  |   61|      0|        bi_buf |= val << bi_valid;\
  |  |  |  |   62|      0|        put_uint64(s, bi_buf);\
  |  |  |  |   63|      0|        bi_buf = val >> (BIT_BUF_SIZE - bi_valid);\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |   64|      0|        bi_valid = total_bits - BIT_BUF_SIZE;\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |   65|      0|    }\
  |  |  |  |   66|  1.08k|}
  |  |  ------------------
  ------------------
  502|  1.08k|            send_bits(s, count-3, 3, bi_buf, bi_valid);
  ------------------
  |  |   47|  1.08k|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) {\
  |  |   48|  1.08k|    uint64_t val = (uint64_t)t_val;\
  |  |   49|  1.08k|    uint32_t len = (uint32_t)t_len;\
  |  |   50|  1.08k|    uint32_t total_bits = bi_valid + len;\
  |  |   51|  1.08k|    send_bits_trace(s, val, len);\
  |  |   52|  1.08k|    sent_bits_add(s, len);\
  |  |  ------------------
  |  |  |  |  449|  1.08k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  1.08k|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   53|  1.08k|    if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|  2.16k|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |                   if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|  1.08k|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |  |  Branch (53:9): [True: 1.08k, False: 0]
  |  |  |  Branch (53:38): [True: 1.08k, False: 0]
  |  |  ------------------
  |  |   54|  1.08k|        bi_buf |= val << bi_valid;\
  |  |   55|  1.08k|        bi_valid = total_bits;\
  |  |   56|  1.08k|    } else if (bi_valid >= BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |  |  Branch (56:16): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |   58|      0|        bi_buf = val;\
  |  |   59|      0|        bi_valid = len;\
  |  |   60|      0|    } else {\
  |  |   61|      0|        bi_buf |= val << bi_valid;\
  |  |   62|      0|        put_uint64(s, bi_buf);\
  |  |   63|      0|        bi_buf = val >> (BIT_BUF_SIZE - bi_valid);\
  |  |  ------------------
  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |   64|      0|        bi_valid = total_bits - BIT_BUF_SIZE;\
  |  |  ------------------
  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |   65|      0|    }\
  |  |   66|  1.08k|}
  ------------------
  503|       |
  504|  8.71k|        } else {
  505|  8.71k|            send_code(s, REPZ_11_138, s->bl_tree, bi_buf, bi_valid);
  ------------------
  |  |   76|  8.71k|    send_bits(s, tree[c].Code, tree[c].Len, bi_buf, bi_valid)
  |  |  ------------------
  |  |  |  |   47|  8.71k|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) {\
  |  |  |  |   48|  8.71k|    uint64_t val = (uint64_t)t_val;\
  |  |  |  |   49|  8.71k|    uint32_t len = (uint32_t)t_len;\
  |  |  |  |   50|  8.71k|    uint32_t total_bits = bi_valid + len;\
  |  |  |  |   51|  8.71k|    send_bits_trace(s, val, len);\
  |  |  |  |   52|  8.71k|    sent_bits_add(s, len);\
  |  |  |  |  ------------------
  |  |  |  |  |  |  449|  8.71k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  154|  8.71k|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   53|  8.71k|    if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  17.4k|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |                   if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  8.71k|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (53:9): [True: 8.71k, False: 0]
  |  |  |  |  |  Branch (53:38): [True: 8.71k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   54|  8.71k|        bi_buf |= val << bi_valid;\
  |  |  |  |   55|  8.71k|        bi_valid = total_bits;\
  |  |  |  |   56|  8.71k|    } else if (bi_valid >= BIT_BUF_SIZE) {\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (56:16): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |  |  |   58|      0|        bi_buf = val;\
  |  |  |  |   59|      0|        bi_valid = len;\
  |  |  |  |   60|      0|    } else {\
  |  |  |  |   61|      0|        bi_buf |= val << bi_valid;\
  |  |  |  |   62|      0|        put_uint64(s, bi_buf);\
  |  |  |  |   63|      0|        bi_buf = val >> (BIT_BUF_SIZE - bi_valid);\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |   64|      0|        bi_valid = total_bits - BIT_BUF_SIZE;\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |   65|      0|    }\
  |  |  |  |   66|  8.71k|}
  |  |  ------------------
  ------------------
  506|  8.71k|            send_bits(s, count-11, 7, bi_buf, bi_valid);
  ------------------
  |  |   47|  8.71k|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) {\
  |  |   48|  8.71k|    uint64_t val = (uint64_t)t_val;\
  |  |   49|  8.71k|    uint32_t len = (uint32_t)t_len;\
  |  |   50|  8.71k|    uint32_t total_bits = bi_valid + len;\
  |  |   51|  8.71k|    send_bits_trace(s, val, len);\
  |  |   52|  8.71k|    sent_bits_add(s, len);\
  |  |  ------------------
  |  |  |  |  449|  8.71k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.71k|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   53|  8.71k|    if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|  17.4k|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |                   if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|  8.71k|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |  |  Branch (53:9): [True: 8.71k, False: 0]
  |  |  |  Branch (53:38): [True: 8.71k, False: 0]
  |  |  ------------------
  |  |   54|  8.71k|        bi_buf |= val << bi_valid;\
  |  |   55|  8.71k|        bi_valid = total_bits;\
  |  |   56|  8.71k|    } else if (bi_valid >= BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |  |  Branch (56:16): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |   58|      0|        bi_buf = val;\
  |  |   59|      0|        bi_valid = len;\
  |  |   60|      0|    } else {\
  |  |   61|      0|        bi_buf |= val << bi_valid;\
  |  |   62|      0|        put_uint64(s, bi_buf);\
  |  |   63|      0|        bi_buf = val >> (BIT_BUF_SIZE - bi_valid);\
  |  |  ------------------
  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |   64|      0|        bi_valid = total_bits - BIT_BUF_SIZE;\
  |  |  ------------------
  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |   65|      0|    }\
  |  |   66|  8.71k|}
  ------------------
  507|  8.71k|        }
  508|  22.2k|        count = 0;
  509|  22.2k|        prevlen = curlen;
  510|  22.2k|        if (nextlen == 0) {
  ------------------
  |  Branch (510:13): [True: 9.27k, False: 12.9k]
  ------------------
  511|  9.27k|            max_count = 138, min_count = 3;
  512|  12.9k|        } else if (curlen == nextlen) {
  ------------------
  |  Branch (512:20): [True: 0, False: 12.9k]
  ------------------
  513|      0|            max_count = 6, min_count = 3;
  514|  12.9k|        } else {
  515|  12.9k|            max_count = 7, min_count = 4;
  516|  12.9k|        }
  517|  22.2k|    }
  518|       |
  519|       |    // Store back temp variables
  520|  4.82k|    s->bi_buf = bi_buf;
  521|  4.82k|    s->bi_valid = bi_valid;
  522|  4.82k|}
trees.c:compress_block:
  711|  3.04k|static void compress_block(deflate_state *s, const ct_data *ltree, const ct_data *dtree) {
  712|       |    /* ltree: literal tree */
  713|       |    /* dtree: distance tree */
  714|  3.04k|    unsigned dist;      /* distance of matched string */
  715|  3.04k|    int lc;             /* match length or unmatched char (if dist == 0) */
  716|  3.04k|    unsigned sx = 0;    /* running index in symbol buffers */
  717|       |
  718|       |    /* Local pointers to avoid indirection */
  719|  3.04k|    const unsigned int sym_next = s->sym_next;
  720|       |#ifdef LIT_MEM
  721|       |    uint16_t *d_buf = s->d_buf;
  722|       |    unsigned char *l_buf = s->l_buf;
  723|       |#else
  724|  3.04k|    unsigned char *sym_buf = s->sym_buf;
  725|  3.04k|#endif
  726|       |
  727|       |    /* Keep bi_buf and bi_valid in registers across the entire loop */
  728|  3.04k|    uint64_t bi_buf = s->bi_buf;
  729|  3.04k|    uint32_t bi_valid = s->bi_valid;
  730|       |
  731|  3.04k|    if (sym_next != 0) {
  ------------------
  |  Branch (731:9): [True: 3.04k, False: 0]
  ------------------
  732|  1.68M|        do {
  733|       |#ifdef LIT_MEM
  734|       |            dist = d_buf[sx];
  735|       |            lc = l_buf[sx++];
  736|       |#else
  737|  1.68M|#  if OPTIMAL_CMP >= 32
  738|  1.68M|            uint32_t val = Z_U32_FROM_LE(zng_memread_4(&sym_buf[sx]));
  ------------------
  |  |   87|  1.68M|#  define Z_U32_FROM_LE(x)  (x)
  ------------------
  739|  1.68M|            dist = val & 0xffff;
  740|  1.68M|            lc = (val >> 16) & 0xff;
  741|       |#  else
  742|       |            dist = sym_buf[sx] + ((unsigned)sym_buf[sx + 1] << 8);
  743|       |            lc = sym_buf[sx + 2];
  744|       |#  endif
  745|  1.68M|            sx += 3;
  746|  1.68M|#endif
  747|  1.68M|            if (dist == 0) {
  ------------------
  |  Branch (747:17): [True: 3.81k, False: 1.67M]
  ------------------
  748|  3.81k|                zng_emit_lit(s, ltree, lc, &bi_buf, &bi_valid);
  749|  1.67M|            } else {
  750|  1.67M|                zng_emit_dist(s, ltree, dtree, lc, dist, &bi_buf, &bi_valid);
  751|  1.67M|            } /* literal or match pair ? */
  752|       |
  753|       |            /* Check for no overlay of pending_buf on needed symbols */
  754|       |#ifdef LIT_MEM
  755|       |            Assert(s->pending < 2 * (s->lit_bufsize + sx), "pending_buf overflow");
  756|       |#else
  757|  1.68M|            Assert(s->pending < s->lit_bufsize + sx, "pending_buf overflow");
  758|  1.68M|#endif
  759|  1.68M|        } while (sx < sym_next);
  ------------------
  |  Branch (759:18): [True: 1.67M, False: 3.04k]
  ------------------
  760|  3.04k|    }
  761|       |
  762|  3.04k|    zng_emit_end_block(s, ltree, 0, &bi_buf, &bi_valid);
  763|       |
  764|       |    /* Write back to state */
  765|  3.04k|    s->bi_buf = bi_buf;
  766|  3.04k|    s->bi_valid = bi_valid;
  767|  3.04k|}
trees.c:detect_data_type:
  782|  1.52k|static int detect_data_type(deflate_state *s) {
  783|       |    /* block_mask is the bit mask of block-listed bytes
  784|       |     * set bits 0..6, 14..25, and 28..31
  785|       |     * 0xf3ffc07f = binary 11110011111111111100000001111111
  786|       |     */
  787|  1.52k|    unsigned long block_mask = 0xf3ffc07fUL;
  788|  1.52k|    int n;
  789|       |
  790|       |    /* Check for non-textual ("block-listed") bytes. */
  791|  1.52k|    for (n = 0; n <= 31; n++, block_mask >>= 1)
  ------------------
  |  Branch (791:17): [True: 1.52k, False: 0]
  ------------------
  792|  1.52k|        if ((block_mask & 1) && (s->dyn_ltree[n].Freq != 0))
  ------------------
  |  |  125|  1.52k|#define Freq fc.freq
  ------------------
  |  Branch (792:13): [True: 1.52k, False: 0]
  |  Branch (792:33): [True: 1.52k, False: 0]
  ------------------
  793|  1.52k|            return Z_BINARY;
  ------------------
  |  |  206|  1.52k|#define Z_BINARY   0
  ------------------
  794|       |
  795|       |    /* Check for textual ("allow-listed") bytes. */
  796|      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 (796:9): [True: 0, False: 0]
  |  Branch (796:38): [True: 0, False: 0]
  |  Branch (796:68): [True: 0, False: 0]
  ------------------
  797|      0|        return Z_TEXT;
  ------------------
  |  |  207|      0|#define Z_TEXT     1
  ------------------
  798|      0|    for (n = 32; n < LITERALS; n++)
  ------------------
  |  |   45|      0|#define LITERALS  256
  ------------------
  |  Branch (798:18): [True: 0, False: 0]
  ------------------
  799|      0|        if (s->dyn_ltree[n].Freq != 0)
  ------------------
  |  |  125|      0|#define Freq fc.freq
  ------------------
  |  Branch (799:13): [True: 0, False: 0]
  ------------------
  800|      0|            return Z_TEXT;
  ------------------
  |  |  207|      0|#define Z_TEXT     1
  ------------------
  801|       |
  802|       |    /* There are no "block-listed" or "allow-listed" bytes:
  803|       |     * this stream either is empty or has tolerated ("gray-listed") bytes only.
  804|       |     */
  805|      0|    return Z_BINARY;
  ------------------
  |  |  206|      0|#define Z_BINARY   0
  ------------------
  806|      0|}

trees.c:zng_tr_emit_tree:
  197|  4.56k|static inline void zng_tr_emit_tree(deflate_state *s, int type, const int last) {
  198|  4.56k|    uint32_t bi_valid = s->bi_valid;
  199|  4.56k|    uint64_t bi_buf = s->bi_buf;
  200|  4.56k|    uint32_t header_bits = (type << 1) + last;
  201|  4.56k|    send_bits(s, header_bits, 3, bi_buf, bi_valid);
  ------------------
  |  |   47|  4.56k|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) {\
  |  |   48|  4.56k|    uint64_t val = (uint64_t)t_val;\
  |  |   49|  4.56k|    uint32_t len = (uint32_t)t_len;\
  |  |   50|  4.56k|    uint32_t total_bits = bi_valid + len;\
  |  |   51|  4.56k|    send_bits_trace(s, val, len);\
  |  |   52|  4.56k|    sent_bits_add(s, len);\
  |  |  ------------------
  |  |  |  |  449|  4.56k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  4.56k|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   53|  4.56k|    if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|  9.12k|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |                   if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|  4.56k|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |  |  Branch (53:9): [True: 4.56k, False: 0]
  |  |  |  Branch (53:38): [True: 4.56k, False: 0]
  |  |  ------------------
  |  |   54|  4.56k|        bi_buf |= val << bi_valid;\
  |  |   55|  4.56k|        bi_valid = total_bits;\
  |  |   56|  4.56k|    } else if (bi_valid >= BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |  |  Branch (56:16): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |   58|      0|        bi_buf = val;\
  |  |   59|      0|        bi_valid = len;\
  |  |   60|      0|    } else {\
  |  |   61|      0|        bi_buf |= val << bi_valid;\
  |  |   62|      0|        put_uint64(s, bi_buf);\
  |  |   63|      0|        bi_buf = val >> (BIT_BUF_SIZE - bi_valid);\
  |  |  ------------------
  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |   64|      0|        bi_valid = total_bits - BIT_BUF_SIZE;\
  |  |  ------------------
  |  |  |  |   60|      0|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |   65|      0|    }\
  |  |   66|  4.56k|}
  ------------------
  202|  4.56k|    cmpr_bits_add(s, 3);
  ------------------
  |  |  447|  4.56k|#  define cmpr_bits_add(s, len)     Z_UNUSED(len)
  |  |  ------------------
  |  |  |  |  154|  4.56k|#define Z_UNUSED(var) (void)(var)
  |  |  ------------------
  ------------------
  203|  4.56k|    s->bi_valid = bi_valid;
  204|  4.56k|    s->bi_buf = bi_buf;
  205|  4.56k|    Tracev((stderr, "\n--- Emit Tree: Last: %u\n", last));
  206|  4.56k|}
trees.c:zng_tr_emit_align:
  211|  3.04k|static inline void zng_tr_emit_align(deflate_state *s) {
  212|  3.04k|    bi_windup(s); /* align on byte boundary */
  213|  3.04k|    sent_bits_align(s);
  214|  3.04k|}
trees.c:bi_windup:
   82|  3.04k|static inline void bi_windup(deflate_state *s) {
   83|  3.04k|    if (s->bi_valid > 56) {
  ------------------
  |  Branch (83:9): [True: 225, False: 2.81k]
  ------------------
   84|    225|        put_uint64(s, s->bi_buf);
   85|  2.81k|    } else {
   86|  2.81k|        if (s->bi_valid > 24) {
  ------------------
  |  Branch (86:13): [True: 720, False: 2.09k]
  ------------------
   87|    720|            put_uint32(s, (uint32_t)s->bi_buf);
   88|    720|            s->bi_buf >>= 32;
   89|    720|            s->bi_valid -= 32;
   90|    720|        }
   91|  2.81k|        if (s->bi_valid > 8) {
  ------------------
  |  Branch (91:13): [True: 875, False: 1.94k]
  ------------------
   92|    875|            put_short(s, (uint16_t)s->bi_buf);
   93|    875|            s->bi_buf >>= 16;
   94|    875|            s->bi_valid -= 16;
   95|    875|        }
   96|  2.81k|        if (s->bi_valid > 0) {
  ------------------
  |  Branch (96:13): [True: 2.01k, False: 800]
  ------------------
   97|  2.01k|            put_byte(s, s->bi_buf);
  ------------------
  |  |  349|  2.01k|#define put_byte(s, c) { \
  |  |  350|  2.01k|    s->pending_buf[s->pending++] = (unsigned char)(c); \
  |  |  351|  2.01k|}
  ------------------
   98|  2.01k|        }
   99|  2.81k|    }
  100|  3.04k|    s->bi_buf = 0;
  101|  3.04k|    s->bi_valid = 0;
  102|  3.04k|}
trees.c:zng_emit_end_block:
  162|  3.04k|                                      uint64_t *bi_buf, uint32_t *bi_valid) {
  163|  3.04k|    send_code(s, END_BLOCK, ltree, *bi_buf, *bi_valid);
  ------------------
  |  |   76|  3.04k|    send_bits(s, tree[c].Code, tree[c].Len, bi_buf, bi_valid)
  |  |  ------------------
  |  |  |  |   47|  3.04k|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) {\
  |  |  |  |   48|  3.04k|    uint64_t val = (uint64_t)t_val;\
  |  |  |  |   49|  3.04k|    uint32_t len = (uint32_t)t_len;\
  |  |  |  |   50|  3.04k|    uint32_t total_bits = bi_valid + len;\
  |  |  |  |   51|  3.04k|    send_bits_trace(s, val, len);\
  |  |  |  |   52|  3.04k|    sent_bits_add(s, len);\
  |  |  |  |  ------------------
  |  |  |  |  |  |  449|  3.04k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  154|  3.04k|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   53|  3.04k|    if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  6.08k|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |                   if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  2.74k|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (53:9): [True: 2.74k, False: 299]
  |  |  |  |  |  Branch (53:38): [True: 2.74k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   54|  2.74k|        bi_buf |= val << bi_valid;\
  |  |  |  |   55|  2.74k|        bi_valid = total_bits;\
  |  |  |  |   56|  2.74k|    } else if (bi_valid >= BIT_BUF_SIZE) {\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|    598|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (56:16): [True: 0, False: 299]
  |  |  |  |  ------------------
  |  |  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |  |  |   58|      0|        bi_buf = val;\
  |  |  |  |   59|      0|        bi_valid = len;\
  |  |  |  |   60|    299|    } else {\
  |  |  |  |   61|    299|        bi_buf |= val << bi_valid;\
  |  |  |  |   62|    299|        put_uint64(s, bi_buf);\
  |  |  |  |   63|    299|        bi_buf = val >> (BIT_BUF_SIZE - bi_valid);\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|    299|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |   64|    299|        bi_valid = total_bits - BIT_BUF_SIZE;\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|    299|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |   65|    299|    }\
  |  |  |  |   66|  3.04k|}
  |  |  ------------------
  ------------------
  164|  3.04k|    Tracev((stderr, "\n+++ Emit End Block: Last: %u Pending: %u Total Out: %" PRIu64 "\n",
  165|  3.04k|        last, s->pending, (uint64_t)s->strm->total_out));
  166|  3.04k|    Z_UNUSED(last);
  ------------------
  |  |  154|  3.04k|#define Z_UNUSED(var) (void)(var)
  ------------------
  167|  3.04k|}
trees.c:zng_emit_lit:
  108|  3.81k|                                uint64_t *bi_buf, uint32_t *bi_valid) {
  109|  3.81k|    send_code(s, c, ltree, *bi_buf, *bi_valid);
  ------------------
  |  |   76|  3.81k|    send_bits(s, tree[c].Code, tree[c].Len, bi_buf, bi_valid)
  |  |  ------------------
  |  |  |  |   47|  3.81k|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) {\
  |  |  |  |   48|  3.81k|    uint64_t val = (uint64_t)t_val;\
  |  |  |  |   49|  3.81k|    uint32_t len = (uint32_t)t_len;\
  |  |  |  |   50|  3.81k|    uint32_t total_bits = bi_valid + len;\
  |  |  |  |   51|  3.81k|    send_bits_trace(s, val, len);\
  |  |  |  |   52|  3.81k|    sent_bits_add(s, len);\
  |  |  |  |  ------------------
  |  |  |  |  |  |  449|  3.81k|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  154|  3.81k|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   53|  3.81k|    if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  7.63k|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |                   if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|  3.79k|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (53:9): [True: 3.79k, False: 24]
  |  |  |  |  |  Branch (53:38): [True: 3.79k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   54|  3.79k|        bi_buf |= val << bi_valid;\
  |  |  |  |   55|  3.79k|        bi_valid = total_bits;\
  |  |  |  |   56|  3.79k|    } else if (bi_valid >= BIT_BUF_SIZE) {\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|     48|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (56:16): [True: 0, False: 24]
  |  |  |  |  ------------------
  |  |  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |  |  |   58|      0|        bi_buf = val;\
  |  |  |  |   59|      0|        bi_valid = len;\
  |  |  |  |   60|     24|    } else {\
  |  |  |  |   61|     24|        bi_buf |= val << bi_valid;\
  |  |  |  |   62|     24|        put_uint64(s, bi_buf);\
  |  |  |  |   63|     24|        bi_buf = val >> (BIT_BUF_SIZE - bi_valid);\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|     24|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |   64|     24|        bi_valid = total_bits - BIT_BUF_SIZE;\
  |  |  |  |  ------------------
  |  |  |  |  |  |   60|     24|#define BIT_BUF_SIZE 64
  |  |  |  |  ------------------
  |  |  |  |   65|     24|    }\
  |  |  |  |   66|  3.81k|}
  |  |  ------------------
  ------------------
  110|  3.81k|    Tracecv(isgraph(c & 0xff), (stderr, " '%c' ", c));
  111|  3.81k|}
trees.c:zng_emit_dist:
  117|  1.67M|                                     uint32_t lc, uint32_t dist, uint64_t *bi_buf, uint32_t *bi_valid) {
  118|  1.67M|    uint32_t c, extra, lext;
  119|  1.67M|    uint8_t code;
  120|  1.67M|    uint64_t match_bits;
  121|  1.67M|    uint32_t match_bits_len;
  122|       |
  123|       |    /* Send the length code, len is the match length - STD_MIN_MATCH */
  124|  1.67M|    code = zng_length_code[lc];
  125|  1.67M|    c = code+LITERALS+1;
  ------------------
  |  |   45|  1.67M|#define LITERALS  256
  ------------------
  126|  1.67M|    Assert(c < L_CODES, "bad l_code");
  127|  1.67M|    send_code_trace(s, c);
  128|       |
  129|  1.67M|    match_bits = ltree[c].Code;
  ------------------
  |  |  126|  1.67M|#define Code fc.code
  ------------------
  130|  1.67M|    match_bits_len = ltree[c].Len;
  ------------------
  |  |  128|  1.67M|#define Len  dl.len
  ------------------
  131|       |    /* Get extra bits count and subtract base length from match length */
  132|  1.67M|    lext = lbase_extra[code];
  133|  1.67M|    extra = lext >> 8;
  134|  1.67M|    lc -= lext & 0xff;
  135|  1.67M|    match_bits |= ((uint64_t)(lc & ((1U << extra) - 1)) << match_bits_len);
  136|  1.67M|    match_bits_len += extra;
  137|       |
  138|  1.67M|    dist--; /* dist is now the match distance - 1 */
  139|  1.67M|    code = d_code(dist);
  ------------------
  |  |  434|  1.67M|#define d_code(dist) ((dist) < 256 ? zng_dist_code[dist] : zng_dist_code[256+((dist)>>7)])
  |  |  ------------------
  |  |  |  Branch (434:23): [True: 1.67M, False: 1.32k]
  |  |  ------------------
  ------------------
  140|  1.67M|    Assert(code < D_CODES, "bad d_code");
  141|  1.67M|    send_code_trace(s, code);
  142|       |
  143|       |    /* Send the distance code */
  144|  1.67M|    match_bits |= ((uint64_t)dtree[code].Code << match_bits_len);
  ------------------
  |  |  126|  1.67M|#define Code fc.code
  ------------------
  145|  1.67M|    match_bits_len += dtree[code].Len;
  ------------------
  |  |  128|  1.67M|#define Len  dl.len
  ------------------
  146|       |    /* Get extra bits count and subtract base distance */
  147|  1.67M|    lext = dbase_extra[code];
  148|  1.67M|    extra = lext >> 16;
  149|  1.67M|    dist -= lext & 0xffff;
  150|  1.67M|    match_bits |= ((uint64_t)(dist & ((1U << extra) - 1)) << match_bits_len);
  151|  1.67M|    match_bits_len += extra;
  152|       |
  153|  1.67M|    send_bits(s, match_bits, match_bits_len, *bi_buf, *bi_valid);
  ------------------
  |  |   47|  1.67M|#define send_bits(s, t_val, t_len, bi_buf, bi_valid) {\
  |  |   48|  1.67M|    uint64_t val = (uint64_t)t_val;\
  |  |   49|  1.67M|    uint32_t len = (uint32_t)t_len;\
  |  |   50|  1.67M|    uint32_t total_bits = bi_valid + len;\
  |  |   51|  1.67M|    send_bits_trace(s, val, len);\
  |  |   52|  1.67M|    sent_bits_add(s, len);\
  |  |  ------------------
  |  |  |  |  449|  1.67M|#  define sent_bits_add(s, bits)    Z_UNUSED(bits)
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  1.67M|#define Z_UNUSED(var) (void)(var)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   53|  1.67M|    if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|  3.35M|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |                   if (total_bits < BIT_BUF_SIZE && bi_valid < BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|  1.62M|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |  |  Branch (53:9): [True: 1.62M, False: 53.6k]
  |  |  |  Branch (53:38): [True: 1.62M, False: 0]
  |  |  ------------------
  |  |   54|  1.62M|        bi_buf |= val << bi_valid;\
  |  |   55|  1.62M|        bi_valid = total_bits;\
  |  |   56|  1.62M|    } else if (bi_valid >= BIT_BUF_SIZE) {\
  |  |  ------------------
  |  |  |  |   60|   107k|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |  |  Branch (56:16): [True: 0, False: 53.6k]
  |  |  ------------------
  |  |   57|      0|        put_uint64(s, bi_buf);\
  |  |   58|      0|        bi_buf = val;\
  |  |   59|      0|        bi_valid = len;\
  |  |   60|  53.6k|    } else {\
  |  |   61|  53.6k|        bi_buf |= val << bi_valid;\
  |  |   62|  53.6k|        put_uint64(s, bi_buf);\
  |  |   63|  53.6k|        bi_buf = val >> (BIT_BUF_SIZE - bi_valid);\
  |  |  ------------------
  |  |  |  |   60|  53.6k|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |   64|  53.6k|        bi_valid = total_bits - BIT_BUF_SIZE;\
  |  |  ------------------
  |  |  |  |   60|  53.6k|#define BIT_BUF_SIZE 64
  |  |  ------------------
  |  |   65|  53.6k|    }\
  |  |   66|  1.67M|}
  ------------------
  154|       |
  155|  1.67M|    return match_bits_len;
  156|  1.67M|}

deflate.c:zng_memwrite_2:
   45|  1.52k|static inline void zng_memwrite_2(void *ptr, uint16_t val) {
   46|  1.52k|#if defined(HAVE_MAY_ALIAS)
   47|  1.52k|    typedef struct { uint16_t val; } __attribute__ ((__packed__, __may_alias__)) unaligned_uint16_t;
   48|  1.52k|    ((unaligned_uint16_t *)ptr)->val = val;
   49|       |#else
   50|       |    memcpy(ptr, &val, sizeof(val));
   51|       |#endif
   52|  1.52k|}
deflate.c:zng_memwrite_4:
   54|  1.52k|static inline void zng_memwrite_4(void *ptr, uint32_t val) {
   55|  1.52k|#if defined(HAVE_MAY_ALIAS)
   56|  1.52k|    typedef struct { uint32_t val; } __attribute__ ((__packed__, __may_alias__)) unaligned_uint32_t;
   57|  1.52k|    ((unaligned_uint32_t *)ptr)->val = val;
   58|       |#else
   59|       |    memcpy(ptr, &val, sizeof(val));
   60|       |#endif
   61|  1.52k|}
deflate_slow.c:zng_memwrite_4:
   54|  1.68M|static inline void zng_memwrite_4(void *ptr, uint32_t val) {
   55|  1.68M|#if defined(HAVE_MAY_ALIAS)
   56|  1.68M|    typedef struct { uint32_t val; } __attribute__ ((__packed__, __may_alias__)) unaligned_uint32_t;
   57|  1.68M|    ((unaligned_uint32_t *)ptr)->val = val;
   58|       |#else
   59|       |    memcpy(ptr, &val, sizeof(val));
   60|       |#endif
   61|  1.68M|}
deflate_stored.c:zng_memwrite_2:
   45|  3.04k|static inline void zng_memwrite_2(void *ptr, uint16_t val) {
   46|  3.04k|#if defined(HAVE_MAY_ALIAS)
   47|  3.04k|    typedef struct { uint16_t val; } __attribute__ ((__packed__, __may_alias__)) unaligned_uint16_t;
   48|  3.04k|    ((unaligned_uint16_t *)ptr)->val = val;
   49|       |#else
   50|       |    memcpy(ptr, &val, sizeof(val));
   51|       |#endif
   52|  3.04k|}
trees.c:zng_memwrite_8:
   63|  56.6k|static inline void zng_memwrite_8(void *ptr, uint64_t val) {
   64|  56.6k|#if defined(HAVE_MAY_ALIAS)
   65|  56.6k|    typedef struct { uint64_t val; } __attribute__ ((__packed__, __may_alias__)) unaligned_uint64_t;
   66|  56.6k|    ((unaligned_uint64_t *)ptr)->val = val;
   67|       |#else
   68|       |    memcpy(ptr, &val, sizeof(val));
   69|       |#endif
   70|  56.6k|}
trees.c:zng_memwrite_2:
   45|  4.70k|static inline void zng_memwrite_2(void *ptr, uint16_t val) {
   46|  4.70k|#if defined(HAVE_MAY_ALIAS)
   47|  4.70k|    typedef struct { uint16_t val; } __attribute__ ((__packed__, __may_alias__)) unaligned_uint16_t;
   48|  4.70k|    ((unaligned_uint16_t *)ptr)->val = val;
   49|       |#else
   50|       |    memcpy(ptr, &val, sizeof(val));
   51|       |#endif
   52|  4.70k|}
trees.c:zng_memread_4:
   23|  1.68M|static inline uint32_t zng_memread_4(const void *ptr) {
   24|  1.68M|#if defined(HAVE_MAY_ALIAS)
   25|  1.68M|    typedef struct { uint32_t val; } __attribute__ ((__packed__, __may_alias__)) unaligned_uint32_t;
   26|  1.68M|    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.68M|}
trees.c:zng_memwrite_4:
   54|  1.57k|static inline void zng_memwrite_4(void *ptr, uint32_t val) {
   55|  1.57k|#if defined(HAVE_MAY_ALIAS)
   56|  1.57k|    typedef struct { uint32_t val; } __attribute__ ((__packed__, __may_alias__)) unaligned_uint32_t;
   57|  1.57k|    ((unaligned_uint32_t *)ptr)->val = val;
   58|       |#else
   59|       |    memcpy(ptr, &val, sizeof(val));
   60|       |#endif
   61|  1.57k|}
chunkset_avx2.c:zng_memread_8:
   34|  1.68M|static inline uint64_t zng_memread_8(const void *ptr) {
   35|  1.68M|#if defined(HAVE_MAY_ALIAS)
   36|  1.68M|    typedef struct { uint64_t val; } __attribute__ ((__packed__, __may_alias__)) unaligned_uint64_t;
   37|  1.68M|    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.68M|}
compare256_avx2.c:zng_memread_8:
   34|  6.87M|static inline uint64_t zng_memread_8(const void *ptr) {
   35|  6.87M|#if defined(HAVE_MAY_ALIAS)
   36|  6.87M|    typedef struct { uint64_t val; } __attribute__ ((__packed__, __may_alias__)) unaligned_uint64_t;
   37|  6.87M|    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|  6.87M|}
compare256_avx2.c:zng_memcmp_8:
   91|   749k|static inline int32_t zng_memcmp_8(const void * Z_RESTRICT src0, const void * Z_RESTRICT src1) {
   92|   749k|#if defined(HAVE_MAY_ALIAS) || defined(_MSC_VER)
   93|   749k|    return zng_memread_8(src0) != zng_memread_8(src1);
   94|       |#else
   95|       |    return memcmp(src0, src1, 8);
   96|       |#endif
   97|   749k|}

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

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

