BrotliGetDictionary:
 5893|  6.02k|const BrotliDictionary* BrotliGetDictionary() {
 5894|  6.02k|  return &kBrotliDictionary;
 5895|  6.02k|}

decode.c:BrotliUnalignedRead64:
  216|  1.01M|static BROTLI_INLINE uint64_t BrotliUnalignedRead64(const void* p) {
  217|  1.01M|  return *(const uint64_t*)p;
  218|  1.01M|}
decode.c:BrotliUnalignedRead32:
  213|  3.76M|static BROTLI_INLINE uint32_t BrotliUnalignedRead32(const void* p) {
  214|  3.76M|  return *(const uint32_t*)p;
  215|  3.76M|}
state.c:BrotliDefaultAllocFunc:
  395|   106k|static void* BrotliDefaultAllocFunc(void* opaque, size_t size) {
  396|   106k|  BROTLI_UNUSED(opaque);
  ------------------
  |  |  377|   106k|#define BROTLI_UNUSED(X) (void)(X)
  ------------------
  397|   106k|  return malloc(size);
  398|   106k|}
state.c:BrotliDefaultFreeFunc:
  401|  1.03M|static void BrotliDefaultFreeFunc(void* opaque, void* address) {
  402|  1.03M|  BROTLI_UNUSED(opaque);
  ------------------
  |  |  377|  1.03M|#define BROTLI_UNUSED(X) (void)(X)
  ------------------
  403|  1.03M|  free(address);
  404|  1.03M|}

BrotliGetTransforms:
  173|  6.02k|const BrotliTransforms* BrotliGetTransforms(void) {
  174|  6.02k|  return &kBrotliTransforms;
  175|  6.02k|}
BrotliTransformDictionaryWord:
  195|  11.9k|    const BrotliTransforms* BROTLI_RESTRICT transforms, int transfom_idx) {
  196|  11.9k|  int idx = 0;
  197|  11.9k|  const uint8_t* prefix = BROTLI_TRANSFORM_PREFIX(transforms, transfom_idx);
  ------------------
  |  |   65|  11.9k|#define BROTLI_TRANSFORM_PREFIX(T, I) (&(T)->prefix_suffix[ \
  |  |   66|  11.9k|    (T)->prefix_suffix_map[BROTLI_TRANSFORM_PREFIX_ID(T, I)]])
  |  |  ------------------
  |  |  |  |   60|  11.9k|#define BROTLI_TRANSFORM_PREFIX_ID(T, I) ((T)->transforms[((I) * 3) + 0])
  |  |  ------------------
  ------------------
  198|  11.9k|  uint8_t type = BROTLI_TRANSFORM_TYPE(transforms, transfom_idx);
  ------------------
  |  |   61|  11.9k|#define BROTLI_TRANSFORM_TYPE(T, I)      ((T)->transforms[((I) * 3) + 1])
  ------------------
  199|  11.9k|  const uint8_t* suffix = BROTLI_TRANSFORM_SUFFIX(transforms, transfom_idx);
  ------------------
  |  |   67|  11.9k|#define BROTLI_TRANSFORM_SUFFIX(T, I) (&(T)->prefix_suffix[ \
  |  |   68|  11.9k|    (T)->prefix_suffix_map[BROTLI_TRANSFORM_SUFFIX_ID(T, I)]])
  |  |  ------------------
  |  |  |  |   62|  11.9k|#define BROTLI_TRANSFORM_SUFFIX_ID(T, I) ((T)->transforms[((I) * 3) + 2])
  |  |  ------------------
  ------------------
  200|  11.9k|  {
  201|  11.9k|    int prefix_len = *prefix++;
  202|  18.8k|    while (prefix_len--) { dst[idx++] = *prefix++; }
  ------------------
  |  Branch (202:12): [True: 6.91k, False: 11.9k]
  ------------------
  203|  11.9k|  }
  204|  11.9k|  {
  205|  11.9k|    const int t = type;
  206|  11.9k|    int i = 0;
  207|  11.9k|    if (t <= BROTLI_TRANSFORM_OMIT_LAST_9) {
  ------------------
  |  Branch (207:9): [True: 7.66k, False: 4.25k]
  ------------------
  208|  7.66k|      len -= t;
  209|  7.66k|    } else if (t >= BROTLI_TRANSFORM_OMIT_FIRST_1
  ------------------
  |  Branch (209:16): [True: 1.07k, False: 3.18k]
  ------------------
  210|  4.25k|        && t <= BROTLI_TRANSFORM_OMIT_FIRST_9) {
  ------------------
  |  Branch (210:12): [True: 1.07k, False: 0]
  ------------------
  211|  1.07k|      int skip = t - (BROTLI_TRANSFORM_OMIT_FIRST_1 - 1);
  212|  1.07k|      word += skip;
  213|  1.07k|      len -= skip;
  214|  1.07k|    }
  215|  88.1k|    while (i < len) { dst[idx++] = word[i++]; }
  ------------------
  |  Branch (215:12): [True: 76.2k, False: 11.9k]
  ------------------
  216|  11.9k|    if (t == BROTLI_TRANSFORM_UPPERCASE_FIRST) {
  ------------------
  |  Branch (216:9): [True: 2.63k, False: 9.28k]
  ------------------
  217|  2.63k|      ToUpperCase(&dst[idx - len]);
  218|  9.28k|    } else if (t == BROTLI_TRANSFORM_UPPERCASE_ALL) {
  ------------------
  |  Branch (218:16): [True: 549, False: 8.74k]
  ------------------
  219|    549|      uint8_t* uppercase = &dst[idx - len];
  220|  5.18k|      while (len > 0) {
  ------------------
  |  Branch (220:14): [True: 4.63k, False: 549]
  ------------------
  221|  4.63k|        int step = ToUpperCase(uppercase);
  222|  4.63k|        uppercase += step;
  223|  4.63k|        len -= step;
  224|  4.63k|      }
  225|    549|    }
  226|  11.9k|  }
  227|  11.9k|  {
  228|  11.9k|    int suffix_len = *suffix++;
  229|  29.8k|    while (suffix_len--) { dst[idx++] = *suffix++; }
  ------------------
  |  Branch (229:12): [True: 17.9k, False: 11.9k]
  ------------------
  230|  11.9k|    return idx;
  231|  11.9k|  }
  232|  11.9k|}
transform.c:ToUpperCase:
  177|  7.26k|static int ToUpperCase(uint8_t* p) {
  178|  7.26k|  if (p[0] < 0xC0) {
  ------------------
  |  Branch (178:7): [True: 5.05k, False: 2.21k]
  ------------------
  179|  5.05k|    if (p[0] >= 'a' && p[0] <= 'z') {
  ------------------
  |  Branch (179:9): [True: 3.89k, False: 1.16k]
  |  Branch (179:24): [True: 3.42k, False: 465]
  ------------------
  180|  3.42k|      p[0] ^= 32;
  181|  3.42k|    }
  182|  5.05k|    return 1;
  183|  5.05k|  }
  184|       |  /* An overly simplified uppercasing model for UTF-8. */
  185|  2.21k|  if (p[0] < 0xE0) {
  ------------------
  |  Branch (185:7): [True: 738, False: 1.47k]
  ------------------
  186|    738|    p[1] ^= 32;
  187|    738|    return 2;
  188|    738|  }
  189|       |  /* An arbitrary transform for three byte characters. */
  190|  1.47k|  p[2] ^= 5;
  191|  1.47k|  return 3;
  192|  2.21k|}

BrotliInitBitReader:
   18|  6.02k|void BrotliInitBitReader(BrotliBitReader* const br) {
   19|  6.02k|  br->val_ = 0;
   20|  6.02k|  br->bit_pos_ = sizeof(br->val_) << 3;
   21|  6.02k|}
BrotliWarmupBitReader:
   23|  49.9k|BROTLI_BOOL BrotliWarmupBitReader(BrotliBitReader* const br) {
   24|  49.9k|  size_t aligned_read_mask = (sizeof(br->val_) >> 1) - 1;
   25|       |  /* Fixing alignment after unaligned BrotliFillWindow would result accumulator
   26|       |     overflow. If unalignment is caused by BrotliSafeReadBits, then there is
   27|       |     enough space in accumulator to fix alignment. */
   28|  49.9k|  if (!BROTLI_ALIGNED_READ) {
  ------------------
  |  |  183|  49.9k|#define BROTLI_ALIGNED_READ (!!0)
  ------------------
  |  Branch (28:7): [Folded - Ignored]
  ------------------
   29|  49.9k|    aligned_read_mask = 0;
   30|  49.9k|  }
   31|  49.9k|  if (BrotliGetAvailableBits(br) == 0) {
  ------------------
  |  Branch (31:7): [True: 14.8k, False: 35.0k]
  ------------------
   32|  14.8k|    if (!BrotliPullByte(br)) {
  ------------------
  |  Branch (32:9): [True: 1.75k, False: 13.1k]
  ------------------
   33|  1.75k|      return BROTLI_FALSE;
  ------------------
  |  |   53|  1.75k|#define BROTLI_FALSE 0
  ------------------
   34|  1.75k|    }
   35|  14.8k|  }
   36|       |
   37|  48.1k|  while ((((size_t)br->next_in) & aligned_read_mask) != 0) {
  ------------------
  |  Branch (37:10): [True: 0, False: 48.1k]
  ------------------
   38|      0|    if (!BrotliPullByte(br)) {
  ------------------
  |  Branch (38:9): [True: 0, False: 0]
  ------------------
   39|       |      /* If we consumed all the input, we don't care about the alignment. */
   40|      0|      return BROTLI_TRUE;
  ------------------
  |  |   51|      0|#define BROTLI_TRUE 1
  ------------------
   41|      0|    }
   42|      0|  }
   43|  48.1k|  return BROTLI_TRUE;
  ------------------
  |  |   51|  48.1k|#define BROTLI_TRUE 1
  ------------------
   44|  48.1k|}

decode.c:BrotliBitReaderUnload:
  222|  2.55k|static BROTLI_INLINE void BrotliBitReaderUnload(BrotliBitReader* br) {
  223|  2.55k|  uint32_t unused_bytes = BrotliGetAvailableBits(br) >> 3;
  224|  2.55k|  uint32_t unused_bits = unused_bytes << 3;
  225|  2.55k|  br->avail_in += unused_bytes;
  226|  2.55k|  br->next_in -= unused_bytes;
  227|  2.55k|  if (unused_bits == sizeof(br->val_) << 3) {
  ------------------
  |  Branch (227:7): [True: 9, False: 2.54k]
  ------------------
  228|      9|    br->val_ = 0;
  229|  2.54k|  } else {
  230|  2.54k|    br->val_ <<= unused_bits;
  231|  2.54k|  }
  232|  2.55k|  br->bit_pos_ += unused_bits;
  233|  2.55k|}
decode.c:BrotliTakeBits:
  238|  36.3M|  BrotliBitReader* const br, uint32_t n_bits, uint32_t* val) {
  239|  36.3M|  *val = (uint32_t)BrotliGetBitsUnmasked(br) & BitMask(n_bits);
  240|  36.3M|  BROTLI_LOG(("[BrotliReadBits]  %d %d %d val: %6x\n",
  241|  36.3M|      (int)br->avail_in, (int)br->bit_pos_, n_bits, (int)*val));
  242|  36.3M|  BrotliDropBits(br, n_bits);
  243|  36.3M|}
decode.c:BrotliGetBitsUnmasked:
  183|  1.55G|    BrotliBitReader* const br) {
  184|  1.55G|  return br->val_ >> br->bit_pos_;
  185|  1.55G|}
decode.c:BrotliDropBits:
  218|  1.55G|    BrotliBitReader* const br, uint32_t n_bits) {
  219|  1.55G|  br->bit_pos_ += n_bits;
  220|  1.55G|}
decode.c:BrotliSafeReadBits:
  268|  2.57M|    BrotliBitReader* const br, uint32_t n_bits, uint32_t* val) {
  269|  4.12M|  while (BrotliGetAvailableBits(br) < n_bits) {
  ------------------
  |  Branch (269:10): [True: 1.54M, False: 2.57M]
  ------------------
  270|  1.54M|    if (!BrotliPullByte(br)) {
  ------------------
  |  Branch (270:9): [True: 1.06k, False: 1.54M]
  ------------------
  271|  1.06k|      return BROTLI_FALSE;
  ------------------
  |  |   53|  1.06k|#define BROTLI_FALSE 0
  ------------------
  272|  1.06k|    }
  273|  1.54M|  }
  274|  2.57M|  BrotliTakeBits(br, n_bits, val);
  275|  2.57M|  return BROTLI_TRUE;
  ------------------
  |  |   51|  2.57M|#define BROTLI_TRUE 1
  ------------------
  276|  2.57M|}
decode.c:BrotliPullByte:
  164|  59.3M|static BROTLI_INLINE BROTLI_BOOL BrotliPullByte(BrotliBitReader* const br) {
  165|  59.3M|  if (br->avail_in == 0) {
  ------------------
  |  Branch (165:7): [True: 57.6M, False: 1.72M]
  ------------------
  166|  57.6M|    return BROTLI_FALSE;
  ------------------
  |  |   53|  57.6M|#define BROTLI_FALSE 0
  ------------------
  167|  57.6M|  }
  168|  1.72M|  br->val_ >>= 8;
  169|  1.72M|#if (BROTLI_64_BITS)
  170|  1.72M|  br->val_ |= ((uint64_t)*br->next_in) << 56;
  171|       |#else
  172|       |  br->val_ |= ((uint32_t)*br->next_in) << 24;
  173|       |#endif
  174|  1.72M|  br->bit_pos_ -= 8;
  175|  1.72M|  --br->avail_in;
  176|  1.72M|  ++br->next_in;
  177|  1.72M|  return BROTLI_TRUE;
  ------------------
  |  |   51|  1.72M|#define BROTLI_TRUE 1
  ------------------
  178|  59.3M|}
decode.c:BrotliJumpToByteBoundary:
  280|   150k|static BROTLI_INLINE BROTLI_BOOL BrotliJumpToByteBoundary(BrotliBitReader* br) {
  281|   150k|  uint32_t pad_bits_count = BrotliGetAvailableBits(br) & 0x7;
  282|   150k|  uint32_t pad_bits = 0;
  283|   150k|  if (pad_bits_count != 0) {
  ------------------
  |  Branch (283:7): [True: 150k, False: 426]
  ------------------
  284|   150k|    BrotliTakeBits(br, pad_bits_count, &pad_bits);
  285|   150k|  }
  286|   150k|  return TO_BROTLI_BOOL(pad_bits == 0);
  ------------------
  |  |   55|   150k|#define TO_BROTLI_BOOL(X) (!!(X) ? BROTLI_TRUE : BROTLI_FALSE)
  |  |  ------------------
  |  |  |  |   51|   150k|#define BROTLI_TRUE 1
  |  |  ------------------
  |  |               #define TO_BROTLI_BOOL(X) (!!(X) ? BROTLI_TRUE : BROTLI_FALSE)
  |  |  ------------------
  |  |  |  |   53|     51|#define BROTLI_FALSE 0
  |  |  ------------------
  |  |  |  Branch (55:28): [True: 150k, False: 51]
  |  |  ------------------
  ------------------
  287|   150k|}
decode.c:BrotliGetRemainingBytes:
   91|  6.45k|static BROTLI_INLINE size_t BrotliGetRemainingBytes(BrotliBitReader* br) {
   92|  6.45k|  return br->avail_in + (BrotliGetAvailableBits(br) >> 3);
   93|  6.45k|}
decode.c:BrotliCopyBytes:
  293|  6.45k|                                          BrotliBitReader* br, size_t num) {
  294|  11.2k|  while (BrotliGetAvailableBits(br) >= 8 && num > 0) {
  ------------------
  |  Branch (294:10): [True: 5.17k, False: 6.11k]
  |  Branch (294:45): [True: 4.84k, False: 332]
  ------------------
  295|  4.84k|    *dest = (uint8_t)BrotliGetBitsUnmasked(br);
  296|  4.84k|    BrotliDropBits(br, 8);
  297|  4.84k|    ++dest;
  298|  4.84k|    --num;
  299|  4.84k|  }
  300|  6.45k|  memcpy(dest, br->next_in, num);
  301|  6.45k|  br->avail_in -= num;
  302|  6.45k|  br->next_in += num;
  303|  6.45k|}
decode.c:BrotliSafeGetBits:
  206|   915M|    BrotliBitReader* const br, uint32_t n_bits, uint32_t* val) {
  207|   915M|  while (BrotliGetAvailableBits(br) < n_bits) {
  ------------------
  |  Branch (207:10): [True: 57.8M, False: 857M]
  ------------------
  208|  57.8M|    if (!BrotliPullByte(br)) {
  ------------------
  |  Branch (208:9): [True: 57.6M, False: 178k]
  ------------------
  209|  57.6M|      return BROTLI_FALSE;
  ------------------
  |  |   53|  57.6M|#define BROTLI_FALSE 0
  ------------------
  210|  57.6M|    }
  211|  57.8M|  }
  212|   857M|  *val = (uint32_t)BrotliGetBitsUnmasked(br) & BitMask(n_bits);
  213|   857M|  return BROTLI_TRUE;
  ------------------
  |  |   51|   857M|#define BROTLI_TRUE 1
  ------------------
  214|   915M|}
decode.c:BrotliCheckInputAmount:
   98|   596M|    BrotliBitReader* const br, size_t num) {
   99|   596M|  return TO_BROTLI_BOOL(br->avail_in >= num);
  ------------------
  |  |   55|   596M|#define TO_BROTLI_BOOL(X) (!!(X) ? BROTLI_TRUE : BROTLI_FALSE)
  |  |  ------------------
  |  |  |  |   51|   596M|#define BROTLI_TRUE 1
  |  |  ------------------
  |  |               #define TO_BROTLI_BOOL(X) (!!(X) ? BROTLI_TRUE : BROTLI_FALSE)
  |  |  ------------------
  |  |  |  |   53|  4.14k|#define BROTLI_FALSE 0
  |  |  ------------------
  |  |  |  Branch (55:28): [True: 596M, False: 4.14k]
  |  |  ------------------
  ------------------
  100|   596M|}
decode.c:BrotliFillBitWindow16:
  158|  1.79M|static BROTLI_INLINE void BrotliFillBitWindow16(BrotliBitReader* const br) {
  159|  1.79M|  BrotliFillBitWindow(br, 17);
  160|  1.79M|}
decode.c:BrotliFillBitWindow:
  107|   647M|    BrotliBitReader* const br, uint32_t n_bits) {
  108|   647M|#if (BROTLI_64_BITS)
  109|   647M|  if (!BROTLI_ALIGNED_READ && BROTLI_IS_CONSTANT(n_bits) && (n_bits <= 8)) {
  ------------------
  |  |  183|  1.29G|#define BROTLI_ALIGNED_READ (!!0)
  ------------------
                if (!BROTLI_ALIGNED_READ && BROTLI_IS_CONSTANT(n_bits) && (n_bits <= 8)) {
  ------------------
  |  |  326|  1.29G|#define BROTLI_IS_CONSTANT(x) (!!__builtin_constant_p(x))
  |  |  ------------------
  |  |  |  Branch (326:31): [True: 613M, False: 33.6M]
  |  |  ------------------
  ------------------
  |  Branch (109:7): [Folded - Ignored]
  |  Branch (109:61): [True: 548M, False: 65.4M]
  ------------------
  110|   548M|    if (br->bit_pos_ >= 56) {
  ------------------
  |  Branch (110:9): [True: 4.63k, False: 548M]
  ------------------
  111|  4.63k|      br->val_ >>= 56;
  112|  4.63k|      br->bit_pos_ ^= 56;  /* here same as -= 56 because of the if condition */
  113|  4.63k|      br->val_ |= BROTLI_UNALIGNED_LOAD64LE(br->next_in) << 8;
  ------------------
  |  |  228|  4.63k|#define BROTLI_UNALIGNED_LOAD64LE BrotliUnalignedRead64
  ------------------
  114|  4.63k|      br->avail_in -= 7;
  115|  4.63k|      br->next_in += 7;
  116|  4.63k|    }
  117|   548M|  } else if (
  118|  99.0M|      !BROTLI_ALIGNED_READ && BROTLI_IS_CONSTANT(n_bits) && (n_bits <= 16)) {
  ------------------
  |  |  183|   198M|#define BROTLI_ALIGNED_READ (!!0)
  ------------------
                    !BROTLI_ALIGNED_READ && BROTLI_IS_CONSTANT(n_bits) && (n_bits <= 16)) {
  ------------------
  |  |  326|   198M|#define BROTLI_IS_CONSTANT(x) (!!__builtin_constant_p(x))
  |  |  ------------------
  |  |  |  Branch (326:31): [True: 65.4M, False: 33.6M]
  |  |  ------------------
  ------------------
  |  Branch (118:7): [Folded - Ignored]
  |  Branch (118:61): [True: 63.6M, False: 1.79M]
  ------------------
  119|  63.6M|    if (br->bit_pos_ >= 48) {
  ------------------
  |  Branch (119:9): [True: 1.01M, False: 62.6M]
  ------------------
  120|  1.01M|      br->val_ >>= 48;
  121|  1.01M|      br->bit_pos_ ^= 48;  /* here same as -= 48 because of the if condition */
  122|  1.01M|      br->val_ |= BROTLI_UNALIGNED_LOAD64LE(br->next_in) << 16;
  ------------------
  |  |  228|  1.01M|#define BROTLI_UNALIGNED_LOAD64LE BrotliUnalignedRead64
  ------------------
  123|  1.01M|      br->avail_in -= 6;
  124|  1.01M|      br->next_in += 6;
  125|  1.01M|    }
  126|  63.6M|  } else {
  127|  35.4M|    if (br->bit_pos_ >= 32) {
  ------------------
  |  Branch (127:9): [True: 3.76M, False: 31.6M]
  ------------------
  128|  3.76M|      br->val_ >>= 32;
  129|  3.76M|      br->bit_pos_ ^= 32;  /* here same as -= 32 because of the if condition */
  130|  3.76M|      br->val_ |= ((uint64_t)BROTLI_UNALIGNED_LOAD32LE(br->next_in)) << 32;
  ------------------
  |  |  227|  3.76M|#define BROTLI_UNALIGNED_LOAD32LE BrotliUnalignedRead32
  ------------------
  131|  3.76M|      br->avail_in -= BROTLI_SHORT_FILL_BIT_WINDOW_READ;
  ------------------
  |  |   21|  3.76M|#define BROTLI_SHORT_FILL_BIT_WINDOW_READ (sizeof(brotli_reg_t) >> 1)
  ------------------
  132|  3.76M|      br->next_in += BROTLI_SHORT_FILL_BIT_WINDOW_READ;
  ------------------
  |  |   21|  3.76M|#define BROTLI_SHORT_FILL_BIT_WINDOW_READ (sizeof(brotli_reg_t) >> 1)
  ------------------
  133|  3.76M|    }
  134|  35.4M|  }
  135|       |#else
  136|       |  if (!BROTLI_ALIGNED_READ && BROTLI_IS_CONSTANT(n_bits) && (n_bits <= 8)) {
  137|       |    if (br->bit_pos_ >= 24) {
  138|       |      br->val_ >>= 24;
  139|       |      br->bit_pos_ ^= 24;  /* here same as -= 24 because of the if condition */
  140|       |      br->val_ |= BROTLI_UNALIGNED_LOAD32LE(br->next_in) << 8;
  141|       |      br->avail_in -= 3;
  142|       |      br->next_in += 3;
  143|       |    }
  144|       |  } else {
  145|       |    if (br->bit_pos_ >= 16) {
  146|       |      br->val_ >>= 16;
  147|       |      br->bit_pos_ ^= 16;  /* here same as -= 16 because of the if condition */
  148|       |      br->val_ |= ((uint32_t)BROTLI_UNALIGNED_LOAD16LE(br->next_in)) << 16;
  149|       |      br->avail_in -= BROTLI_SHORT_FILL_BIT_WINDOW_READ;
  150|       |      br->next_in += BROTLI_SHORT_FILL_BIT_WINDOW_READ;
  151|       |    }
  152|       |  }
  153|       |#endif
  154|   647M|}
decode.c:BitMask:
   34|  1.44G|static BROTLI_INLINE uint32_t BitMask(uint32_t n) {
   35|  1.44G|  if (BROTLI_IS_CONSTANT(n) || BROTLI_HAS_UBFX) {
  ------------------
  |  |  326|  2.89G|#define BROTLI_IS_CONSTANT(x) (!!__builtin_constant_p(x))
  |  |  ------------------
  |  |  |  Branch (326:31): [True: 1.41G, False: 35.0M]
  |  |  ------------------
  ------------------
                if (BROTLI_IS_CONSTANT(n) || BROTLI_HAS_UBFX) {
  ------------------
  |  |  334|  35.0M|#define BROTLI_HAS_UBFX (!!0)
  |  |  ------------------
  |  |  |  Branch (334:25): [Folded - Ignored]
  |  |  ------------------
  ------------------
   36|       |    /* Masking with this expression turns to a single
   37|       |       "Unsigned Bit Field Extract" UBFX instruction on ARM. */
   38|  1.41G|    return ~((0xFFFFFFFFu) << n);
   39|  1.41G|  } else {
   40|  35.0M|    return kBitMask[n];
   41|  35.0M|  }
   42|  1.44G|}
decode.c:BrotliReadBits:
  248|  33.6M|    BrotliBitReader* const br, uint32_t n_bits) {
  249|  33.6M|  if (BROTLI_64_BITS || (n_bits <= 16)) {
  ------------------
  |  |  132|  67.2M|#define BROTLI_64_BITS 1
  |  |  ------------------
  |  |  |  Branch (132:24): [Folded - Ignored]
  |  |  ------------------
  ------------------
  |  Branch (249:25): [True: 0, False: 0]
  ------------------
  250|  33.6M|    uint32_t val;
  251|  33.6M|    BrotliFillBitWindow(br, n_bits);
  252|  33.6M|    BrotliTakeBits(br, n_bits, &val);
  253|  33.6M|    return val;
  254|  33.6M|  } else {
  255|      0|    uint32_t low_val;
  256|      0|    uint32_t high_val;
  257|      0|    BrotliFillBitWindow(br, 16);
  258|      0|    BrotliTakeBits(br, 16, &low_val);
  259|      0|    BrotliFillBitWindow(br, 8);
  260|      0|    BrotliTakeBits(br, n_bits - 16, &high_val);
  261|      0|    return low_val | (high_val << 16);
  262|      0|  }
  263|  33.6M|}
decode.c:BrotliBitReaderSaveState:
   69|  59.6M|    BrotliBitReader* const from, BrotliBitReaderState* to) {
   70|  59.6M|  to->val_ = from->val_;
   71|  59.6M|  to->bit_pos_ = from->bit_pos_;
   72|  59.6M|  to->next_in = from->next_in;
   73|  59.6M|  to->avail_in = from->avail_in;
   74|  59.6M|}
decode.c:BrotliBitReaderRestoreState:
   77|    629|    BrotliBitReader* const to, BrotliBitReaderState* from) {
   78|    629|  to->val_ = from->val_;
   79|    629|  to->bit_pos_ = from->bit_pos_;
   80|    629|  to->next_in = from->next_in;
   81|    629|  to->avail_in = from->avail_in;
   82|    629|}
decode.c:BrotliGetBits:
  198|   548M|    BrotliBitReader* const br, uint32_t n_bits) {
  199|   548M|  BrotliFillBitWindow(br, n_bits);
  200|   548M|  return (uint32_t)BrotliGetBitsUnmasked(br) & BitMask(n_bits);
  201|   548M|}
decode.c:BrotliGet16BitsUnmasked:
  190|  63.6M|    BrotliBitReader* const br) {
  191|  63.6M|  BrotliFillBitWindow(br, 16);
  192|  63.6M|  return (uint32_t)BrotliGetBitsUnmasked(br);
  193|  63.6M|}
decode.c:BrotliGetAvailableBits:
   85|   977M|    const BrotliBitReader* br) {
   86|   977M|  return (BROTLI_64_BITS ? 64 : 32) - br->bit_pos_;
  ------------------
  |  |  132|   977M|#define BROTLI_64_BITS 1
  |  |  ------------------
  |  |  |  Branch (132:24): [Folded - Ignored]
  |  |  ------------------
  ------------------
   87|   977M|}
bit_reader.c:BrotliGetAvailableBits:
   85|  49.9k|    const BrotliBitReader* br) {
   86|  49.9k|  return (BROTLI_64_BITS ? 64 : 32) - br->bit_pos_;
  ------------------
  |  |  132|  49.9k|#define BROTLI_64_BITS 1
  |  |  ------------------
  |  |  |  Branch (132:24): [Folded - Ignored]
  |  |  ------------------
  ------------------
   87|  49.9k|}
bit_reader.c:BrotliPullByte:
  164|  14.8k|static BROTLI_INLINE BROTLI_BOOL BrotliPullByte(BrotliBitReader* const br) {
  165|  14.8k|  if (br->avail_in == 0) {
  ------------------
  |  Branch (165:7): [True: 1.75k, False: 13.1k]
  ------------------
  166|  1.75k|    return BROTLI_FALSE;
  ------------------
  |  |   53|  1.75k|#define BROTLI_FALSE 0
  ------------------
  167|  1.75k|  }
  168|  13.1k|  br->val_ >>= 8;
  169|  13.1k|#if (BROTLI_64_BITS)
  170|  13.1k|  br->val_ |= ((uint64_t)*br->next_in) << 56;
  171|       |#else
  172|       |  br->val_ |= ((uint32_t)*br->next_in) << 24;
  173|       |#endif
  174|  13.1k|  br->bit_pos_ -= 8;
  175|  13.1k|  --br->avail_in;
  176|  13.1k|  ++br->next_in;
  177|  13.1k|  return BROTLI_TRUE;
  ------------------
  |  |   51|  13.1k|#define BROTLI_TRUE 1
  ------------------
  178|  14.8k|}

BrotliDecoderDecompress:
 1945|  6.02k|    uint8_t* decoded_buffer) {
 1946|  6.02k|  BrotliDecoderState s;
  ------------------
  |  |  235|  6.02k|#define BrotliDecoderState BrotliDecoderStateInternal
  ------------------
 1947|  6.02k|  BrotliDecoderResult result;
 1948|  6.02k|  size_t total_out = 0;
 1949|  6.02k|  size_t available_in = encoded_size;
 1950|  6.02k|  const uint8_t* next_in = encoded_buffer;
 1951|  6.02k|  size_t available_out = *decoded_size;
 1952|  6.02k|  uint8_t* next_out = decoded_buffer;
 1953|  6.02k|  if (!BrotliDecoderStateInit(&s, 0, 0, 0)) {
  ------------------
  |  Branch (1953:7): [True: 0, False: 6.02k]
  ------------------
 1954|      0|    return BROTLI_DECODER_RESULT_ERROR;
 1955|      0|  }
 1956|  6.02k|  result = BrotliDecoderDecompressStream(
 1957|  6.02k|      &s, &available_in, &next_in, &available_out, &next_out, &total_out);
 1958|  6.02k|  *decoded_size = total_out;
 1959|  6.02k|  BrotliDecoderStateCleanup(&s);
 1960|  6.02k|  if (result != BROTLI_DECODER_RESULT_SUCCESS) {
  ------------------
  |  Branch (1960:7): [True: 4.72k, False: 1.30k]
  ------------------
 1961|  4.72k|    result = BROTLI_DECODER_RESULT_ERROR;
 1962|  4.72k|  }
 1963|  6.02k|  return result;
 1964|  6.02k|}
BrotliDecoderDecompressStream:
 1979|  6.02k|    size_t* available_out, uint8_t** next_out, size_t* total_out) {
 1980|  6.02k|  BrotliDecoderErrorCode result = BROTLI_DECODER_SUCCESS;
 1981|  6.02k|  BrotliBitReader* br = &s->br;
 1982|       |  /* Ensure that |total_out| is set, even if no data will ever be pushed out. */
 1983|  6.02k|  if (total_out) {
  ------------------
  |  Branch (1983:7): [True: 6.02k, False: 0]
  ------------------
 1984|  6.02k|    *total_out = s->partial_pos_out;
 1985|  6.02k|  }
 1986|       |  /* Do not try to process further in a case of unrecoverable error. */
 1987|  6.02k|  if ((int)s->error_code < 0) {
  ------------------
  |  Branch (1987:7): [True: 0, False: 6.02k]
  ------------------
 1988|      0|    return BROTLI_DECODER_RESULT_ERROR;
 1989|      0|  }
 1990|  6.02k|  if (*available_out && (!next_out || !*next_out)) {
  ------------------
  |  Branch (1990:7): [True: 6.02k, False: 0]
  |  Branch (1990:26): [True: 0, False: 6.02k]
  |  Branch (1990:39): [True: 0, False: 6.02k]
  ------------------
 1991|      0|    return SaveErrorCode(
 1992|      0|        s, BROTLI_FAILURE(BROTLI_DECODER_ERROR_INVALID_ARGUMENTS));
  ------------------
  |  |   31|      0|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|      0|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
 1993|      0|  }
 1994|  6.02k|  if (!*available_out) next_out = 0;
  ------------------
  |  Branch (1994:7): [True: 0, False: 6.02k]
  ------------------
 1995|  6.02k|  if (s->buffer_length == 0) {  /* Just connect bit reader to input stream. */
  ------------------
  |  Branch (1995:7): [True: 6.02k, False: 0]
  ------------------
 1996|  6.02k|    br->avail_in = *available_in;
 1997|  6.02k|    br->next_in = *next_in;
 1998|  6.02k|  } else {
 1999|       |    /* At least one byte of input is required. More than one byte of input may
 2000|       |       be required to complete the transaction -> reading more data must be
 2001|       |       done in a loop -> do it in a main loop. */
 2002|      0|    result = BROTLI_DECODER_NEEDS_MORE_INPUT;
 2003|      0|    br->next_in = &s->buffer.u8[0];
 2004|      0|  }
 2005|       |  /* State machine */
 2006|   631k|  for (;;) {
 2007|   631k|    if (result != BROTLI_DECODER_SUCCESS) {
  ------------------
  |  Branch (2007:9): [True: 4.72k, False: 627k]
  ------------------
 2008|       |      /* Error, needs more input/output. */
 2009|  4.72k|      if (result == BROTLI_DECODER_NEEDS_MORE_INPUT) {
  ------------------
  |  Branch (2009:11): [True: 3.47k, False: 1.24k]
  ------------------
 2010|  3.47k|        if (s->ringbuffer != 0) {  /* Pro-actively push output. */
  ------------------
  |  Branch (2010:13): [True: 1.05k, False: 2.42k]
  ------------------
 2011|  1.05k|          BrotliDecoderErrorCode intermediate_result = WriteRingBuffer(s,
 2012|  1.05k|              available_out, next_out, total_out, BROTLI_TRUE);
  ------------------
  |  |   51|  1.05k|#define BROTLI_TRUE 1
  ------------------
 2013|       |          /* WriteRingBuffer checks s->meta_block_remaining_len validity. */
 2014|  1.05k|          if ((int)intermediate_result < 0) {
  ------------------
  |  Branch (2014:15): [True: 17, False: 1.04k]
  ------------------
 2015|     17|            result = intermediate_result;
 2016|     17|            break;
 2017|     17|          }
 2018|  1.05k|        }
 2019|  3.46k|        if (s->buffer_length != 0) {  /* Used with internal buffer. */
  ------------------
  |  Branch (2019:13): [True: 0, False: 3.46k]
  ------------------
 2020|      0|          if (br->avail_in == 0) {
  ------------------
  |  Branch (2020:15): [True: 0, False: 0]
  ------------------
 2021|       |            /* Successfully finished read transaction.
 2022|       |               Accumulator contains less than 8 bits, because internal buffer
 2023|       |               is expanded byte-by-byte until it is enough to complete read. */
 2024|      0|            s->buffer_length = 0;
 2025|       |            /* Switch to input stream and restart. */
 2026|      0|            result = BROTLI_DECODER_SUCCESS;
 2027|      0|            br->avail_in = *available_in;
 2028|      0|            br->next_in = *next_in;
 2029|      0|            continue;
 2030|      0|          } else if (*available_in != 0) {
  ------------------
  |  Branch (2030:22): [True: 0, False: 0]
  ------------------
 2031|       |            /* Not enough data in buffer, but can take one more byte from
 2032|       |               input stream. */
 2033|      0|            result = BROTLI_DECODER_SUCCESS;
 2034|      0|            s->buffer.u8[s->buffer_length] = **next_in;
 2035|      0|            s->buffer_length++;
 2036|      0|            br->avail_in = s->buffer_length;
 2037|      0|            (*next_in)++;
 2038|      0|            (*available_in)--;
 2039|       |            /* Retry with more data in buffer. */
 2040|      0|            continue;
 2041|      0|          }
 2042|       |          /* Can't finish reading and no more input. */
 2043|      0|          break;
 2044|  3.46k|        } else {  /* Input stream doesn't contain enough input. */
 2045|       |          /* Copy tail to internal buffer and return. */
 2046|  3.46k|          *next_in = br->next_in;
 2047|  3.46k|          *available_in = br->avail_in;
 2048|  3.49k|          while (*available_in) {
  ------------------
  |  Branch (2048:18): [True: 29, False: 3.46k]
  ------------------
 2049|     29|            s->buffer.u8[s->buffer_length] = **next_in;
 2050|     29|            s->buffer_length++;
 2051|     29|            (*next_in)++;
 2052|     29|            (*available_in)--;
 2053|     29|          }
 2054|  3.46k|          break;
 2055|  3.46k|        }
 2056|       |        /* Unreachable. */
 2057|  3.46k|      }
 2058|       |
 2059|       |      /* Fail or needs more output. */
 2060|       |
 2061|  1.24k|      if (s->buffer_length != 0) {
  ------------------
  |  Branch (2061:11): [True: 0, False: 1.24k]
  ------------------
 2062|       |        /* Just consumed the buffered input and produced some output. Otherwise
 2063|       |           it would result in "needs more input". Reset internal buffer. */
 2064|      0|        s->buffer_length = 0;
 2065|  1.24k|      } else {
 2066|       |        /* Using input stream in last iteration. When decoder switches to input
 2067|       |           stream it has less than 8 bits in accumulator, so it is safe to
 2068|       |           return unused accumulator bits there. */
 2069|  1.24k|        BrotliBitReaderUnload(br);
 2070|  1.24k|        *available_in = br->avail_in;
 2071|  1.24k|        *next_in = br->next_in;
 2072|  1.24k|      }
 2073|  1.24k|      break;
 2074|  4.72k|    }
 2075|   627k|    switch (s->state) {
  ------------------
  |  Branch (2075:13): [True: 0, False: 627k]
  ------------------
 2076|  6.02k|      case BROTLI_STATE_UNINITED:
  ------------------
  |  Branch (2076:7): [True: 6.02k, False: 621k]
  ------------------
 2077|       |        /* Prepare to the first read. */
 2078|  6.02k|        if (!BrotliWarmupBitReader(br)) {
  ------------------
  |  Branch (2078:13): [True: 1.73k, False: 4.28k]
  ------------------
 2079|  1.73k|          result = BROTLI_DECODER_NEEDS_MORE_INPUT;
 2080|  1.73k|          break;
 2081|  1.73k|        }
 2082|       |        /* Decode window size. */
 2083|  4.28k|        result = DecodeWindowBits(s, br);  /* Reads 1..8 bits. */
 2084|  4.28k|        if (result != BROTLI_DECODER_SUCCESS) {
  ------------------
  |  Branch (2084:13): [True: 1, False: 4.28k]
  ------------------
 2085|      1|          break;
 2086|      1|        }
 2087|  4.28k|        if (s->large_window) {
  ------------------
  |  Branch (2087:13): [True: 0, False: 4.28k]
  ------------------
 2088|      0|          s->state = BROTLI_STATE_LARGE_WINDOW_BITS;
 2089|      0|          break;
 2090|      0|        }
 2091|  4.28k|        s->state = BROTLI_STATE_INITIALIZE;
 2092|  4.28k|        break;
 2093|       |
 2094|      0|      case BROTLI_STATE_LARGE_WINDOW_BITS:
  ------------------
  |  Branch (2094:7): [True: 0, False: 627k]
  ------------------
 2095|      0|        if (!BrotliSafeReadBits(br, 6, &s->window_bits)) {
  ------------------
  |  Branch (2095:13): [True: 0, False: 0]
  ------------------
 2096|      0|          result = BROTLI_DECODER_NEEDS_MORE_INPUT;
 2097|      0|          break;
 2098|      0|        }
 2099|      0|        if (s->window_bits < BROTLI_LARGE_MIN_WBITS ||
  ------------------
  |  |   33|      0|#define BROTLI_LARGE_MIN_WBITS 10
  ------------------
  |  Branch (2099:13): [True: 0, False: 0]
  ------------------
 2100|      0|            s->window_bits > BROTLI_LARGE_MAX_WBITS) {
  ------------------
  |  |   34|      0|#define BROTLI_LARGE_MAX_WBITS 30
  ------------------
  |  Branch (2100:13): [True: 0, False: 0]
  ------------------
 2101|      0|          result = BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS);
  ------------------
  |  |   31|      0|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|      0|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
 2102|      0|          break;
 2103|      0|        }
 2104|      0|        s->state = BROTLI_STATE_INITIALIZE;
 2105|       |        /* No break, continue to next state */
 2106|       |
 2107|  4.28k|      case BROTLI_STATE_INITIALIZE:
  ------------------
  |  Branch (2107:7): [True: 4.28k, False: 622k]
  ------------------
 2108|  4.28k|        BROTLI_LOG_UINT(s->window_bits);
 2109|       |        /* Maximum distance, see section 9.1. of the spec. */
 2110|  4.28k|        s->max_backward_distance = (1 << s->window_bits) - BROTLI_WINDOW_GAP;
  ------------------
  |  |   61|  4.28k|#define BROTLI_WINDOW_GAP 16
  ------------------
 2111|       |
 2112|       |        /* Allocate memory for both block_type_trees and block_len_trees. */
 2113|  4.28k|        s->block_type_trees = (HuffmanCode*)BROTLI_DECODER_ALLOC(s,
  ------------------
  |  |  247|  4.28k|#define BROTLI_DECODER_ALLOC(S, L) S->alloc_func(S->memory_manager_opaque, L)
  ------------------
 2114|  4.28k|            sizeof(HuffmanCode) * 3 *
 2115|  4.28k|                (BROTLI_HUFFMAN_MAX_SIZE_258 + BROTLI_HUFFMAN_MAX_SIZE_26));
 2116|  4.28k|        if (s->block_type_trees == 0) {
  ------------------
  |  Branch (2116:13): [True: 0, False: 4.28k]
  ------------------
 2117|      0|          result = BROTLI_FAILURE(BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES);
  ------------------
  |  |   31|      0|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|      0|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
 2118|      0|          break;
 2119|      0|        }
 2120|  4.28k|        s->block_len_trees =
 2121|  4.28k|            s->block_type_trees + 3 * BROTLI_HUFFMAN_MAX_SIZE_258;
  ------------------
  |  |   30|  4.28k|#define BROTLI_HUFFMAN_MAX_SIZE_258 632
  ------------------
 2122|       |
 2123|  4.28k|        s->state = BROTLI_STATE_METABLOCK_BEGIN;
 2124|       |        /* No break, continue to next state. */
 2125|       |
 2126|   166k|      case BROTLI_STATE_METABLOCK_BEGIN:
  ------------------
  |  Branch (2126:7): [True: 162k, False: 464k]
  ------------------
 2127|   166k|        BrotliDecoderStateMetablockBegin(s);
 2128|   166k|        BROTLI_LOG_UINT(s->pos);
 2129|   166k|        s->state = BROTLI_STATE_METABLOCK_HEADER;
 2130|       |        /* No break, continue to next state. */
 2131|       |
 2132|   166k|      case BROTLI_STATE_METABLOCK_HEADER:
  ------------------
  |  Branch (2132:7): [True: 0, False: 627k]
  ------------------
 2133|   166k|        result = DecodeMetaBlockLength(s, br);  /* Reads 2 - 31 bits. */
 2134|   166k|        if (result != BROTLI_DECODER_SUCCESS) {
  ------------------
  |  Branch (2134:13): [True: 176, False: 166k]
  ------------------
 2135|    176|          break;
 2136|    176|        }
 2137|   166k|        BROTLI_LOG_UINT(s->is_last_metablock);
 2138|   166k|        BROTLI_LOG_UINT(s->meta_block_remaining_len);
 2139|   166k|        BROTLI_LOG_UINT(s->is_metadata);
 2140|   166k|        BROTLI_LOG_UINT(s->is_uncompressed);
 2141|   166k|        if (s->is_metadata || s->is_uncompressed) {
  ------------------
  |  Branch (2141:13): [True: 142k, False: 23.6k]
  |  Branch (2141:31): [True: 6.31k, False: 17.3k]
  ------------------
 2142|   149k|          if (!BrotliJumpToByteBoundary(br)) {
  ------------------
  |  Branch (2142:15): [True: 31, False: 149k]
  ------------------
 2143|     31|            result = BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_PADDING_1);
  ------------------
  |  |   31|     31|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|     31|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
 2144|     31|            break;
 2145|     31|          }
 2146|   149k|        }
 2147|   166k|        if (s->is_metadata) {
  ------------------
  |  Branch (2147:13): [True: 142k, False: 23.6k]
  ------------------
 2148|   142k|          s->state = BROTLI_STATE_METADATA;
 2149|   142k|          break;
 2150|   142k|        }
 2151|  23.6k|        if (s->meta_block_remaining_len == 0) {
  ------------------
  |  Branch (2151:13): [True: 492, False: 23.1k]
  ------------------
 2152|    492|          s->state = BROTLI_STATE_METABLOCK_DONE;
 2153|    492|          break;
 2154|    492|        }
 2155|  23.1k|        BrotliCalculateRingBufferSize(s);
 2156|  23.1k|        if (s->is_uncompressed) {
  ------------------
  |  Branch (2156:13): [True: 6.30k, False: 16.8k]
  ------------------
 2157|  6.30k|          s->state = BROTLI_STATE_UNCOMPRESSED;
 2158|  6.30k|          break;
 2159|  6.30k|        }
 2160|  16.8k|        s->loop_counter = 0;
 2161|  16.8k|        s->state = BROTLI_STATE_HUFFMAN_CODE_0;
 2162|  16.8k|        break;
 2163|       |
 2164|  6.30k|      case BROTLI_STATE_UNCOMPRESSED: {
  ------------------
  |  Branch (2164:7): [True: 6.30k, False: 620k]
  ------------------
 2165|  6.30k|        result = CopyUncompressedBlockToOutput(
 2166|  6.30k|            available_out, next_out, total_out, s);
 2167|  6.30k|        if (result != BROTLI_DECODER_SUCCESS) {
  ------------------
  |  Branch (2167:13): [True: 130, False: 6.17k]
  ------------------
 2168|    130|          break;
 2169|    130|        }
 2170|  6.17k|        s->state = BROTLI_STATE_METABLOCK_DONE;
 2171|  6.17k|        break;
 2172|  6.30k|      }
 2173|       |
 2174|   142k|      case BROTLI_STATE_METADATA:
  ------------------
  |  Branch (2174:7): [True: 142k, False: 484k]
  ------------------
 2175|  1.42M|        for (; s->meta_block_remaining_len > 0; --s->meta_block_remaining_len) {
  ------------------
  |  Branch (2175:16): [True: 1.28M, False: 142k]
  ------------------
 2176|  1.28M|          uint32_t bits;
 2177|       |          /* Read one byte and ignore it. */
 2178|  1.28M|          if (!BrotliSafeReadBits(br, 8, &bits)) {
  ------------------
  |  Branch (2178:15): [True: 48, False: 1.28M]
  ------------------
 2179|     48|            result = BROTLI_DECODER_NEEDS_MORE_INPUT;
 2180|     48|            break;
 2181|     48|          }
 2182|  1.28M|        }
 2183|   142k|        if (result == BROTLI_DECODER_SUCCESS) {
  ------------------
  |  Branch (2183:13): [True: 142k, False: 48]
  ------------------
 2184|   142k|          s->state = BROTLI_STATE_METABLOCK_DONE;
 2185|   142k|        }
 2186|   142k|        break;
 2187|       |
 2188|  66.7k|      case BROTLI_STATE_HUFFMAN_CODE_0:
  ------------------
  |  Branch (2188:7): [True: 66.7k, False: 560k]
  ------------------
 2189|  66.7k|        if (s->loop_counter >= 3) {
  ------------------
  |  Branch (2189:13): [True: 16.5k, False: 50.2k]
  ------------------
 2190|  16.5k|          s->state = BROTLI_STATE_METABLOCK_HEADER_2;
 2191|  16.5k|          break;
 2192|  16.5k|        }
 2193|       |        /* Reads 1..11 bits. */
 2194|  50.2k|        result = DecodeVarLenUint8(s, br, &s->num_block_types[s->loop_counter]);
 2195|  50.2k|        if (result != BROTLI_DECODER_SUCCESS) {
  ------------------
  |  Branch (2195:13): [True: 21, False: 50.1k]
  ------------------
 2196|     21|          break;
 2197|     21|        }
 2198|  50.1k|        s->num_block_types[s->loop_counter]++;
 2199|  50.1k|        BROTLI_LOG_UINT(s->num_block_types[s->loop_counter]);
 2200|  50.1k|        if (s->num_block_types[s->loop_counter] < 2) {
  ------------------
  |  Branch (2200:13): [True: 39.6k, False: 10.5k]
  ------------------
 2201|  39.6k|          s->loop_counter++;
 2202|  39.6k|          break;
 2203|  39.6k|        }
 2204|  10.5k|        s->state = BROTLI_STATE_HUFFMAN_CODE_1;
 2205|       |        /* No break, continue to next state. */
 2206|       |
 2207|  10.5k|      case BROTLI_STATE_HUFFMAN_CODE_1: {
  ------------------
  |  Branch (2207:7): [True: 0, False: 627k]
  ------------------
 2208|  10.5k|        uint32_t alphabet_size = s->num_block_types[s->loop_counter] + 2;
 2209|  10.5k|        int tree_offset = s->loop_counter * BROTLI_HUFFMAN_MAX_SIZE_258;
  ------------------
  |  |   30|  10.5k|#define BROTLI_HUFFMAN_MAX_SIZE_258 632
  ------------------
 2210|  10.5k|        result = ReadHuffmanCode(alphabet_size, alphabet_size,
 2211|  10.5k|            &s->block_type_trees[tree_offset], NULL, s);
 2212|  10.5k|        if (result != BROTLI_DECODER_SUCCESS) break;
  ------------------
  |  Branch (2212:13): [True: 175, False: 10.3k]
  ------------------
 2213|  10.3k|        s->state = BROTLI_STATE_HUFFMAN_CODE_2;
 2214|       |        /* No break, continue to next state. */
 2215|  10.3k|      }
 2216|       |
 2217|  10.3k|      case BROTLI_STATE_HUFFMAN_CODE_2: {
  ------------------
  |  Branch (2217:7): [True: 0, False: 627k]
  ------------------
 2218|  10.3k|        uint32_t alphabet_size = BROTLI_NUM_BLOCK_LEN_SYMBOLS;
  ------------------
  |  |   19|  10.3k|#define BROTLI_NUM_BLOCK_LEN_SYMBOLS 26
  ------------------
 2219|  10.3k|        int tree_offset = s->loop_counter * BROTLI_HUFFMAN_MAX_SIZE_26;
  ------------------
  |  |   28|  10.3k|#define BROTLI_HUFFMAN_MAX_SIZE_26 396
  ------------------
 2220|  10.3k|        result = ReadHuffmanCode(alphabet_size, alphabet_size,
 2221|  10.3k|            &s->block_len_trees[tree_offset], NULL, s);
 2222|  10.3k|        if (result != BROTLI_DECODER_SUCCESS) break;
  ------------------
  |  Branch (2222:13): [True: 75, False: 10.2k]
  ------------------
 2223|  10.2k|        s->state = BROTLI_STATE_HUFFMAN_CODE_3;
 2224|       |        /* No break, continue to next state. */
 2225|  10.2k|      }
 2226|       |
 2227|  10.2k|      case BROTLI_STATE_HUFFMAN_CODE_3: {
  ------------------
  |  Branch (2227:7): [True: 0, False: 627k]
  ------------------
 2228|  10.2k|        int tree_offset = s->loop_counter * BROTLI_HUFFMAN_MAX_SIZE_26;
  ------------------
  |  |   28|  10.2k|#define BROTLI_HUFFMAN_MAX_SIZE_26 396
  ------------------
 2229|  10.2k|        if (!SafeReadBlockLength(s, &s->block_length[s->loop_counter],
  ------------------
  |  Branch (2229:13): [True: 29, False: 10.2k]
  ------------------
 2230|  10.2k|            &s->block_len_trees[tree_offset], br)) {
 2231|     29|          result = BROTLI_DECODER_NEEDS_MORE_INPUT;
 2232|     29|          break;
 2233|     29|        }
 2234|  10.2k|        BROTLI_LOG_UINT(s->block_length[s->loop_counter]);
 2235|  10.2k|        s->loop_counter++;
 2236|  10.2k|        s->state = BROTLI_STATE_HUFFMAN_CODE_0;
 2237|  10.2k|        break;
 2238|  10.2k|      }
 2239|       |
 2240|  16.5k|      case BROTLI_STATE_METABLOCK_HEADER_2: {
  ------------------
  |  Branch (2240:7): [True: 16.5k, False: 610k]
  ------------------
 2241|  16.5k|        uint32_t bits;
 2242|  16.5k|        if (!BrotliSafeReadBits(br, 6, &bits)) {
  ------------------
  |  Branch (2242:13): [True: 18, False: 16.5k]
  ------------------
 2243|     18|          result = BROTLI_DECODER_NEEDS_MORE_INPUT;
 2244|     18|          break;
 2245|     18|        }
 2246|  16.5k|        s->distance_postfix_bits = bits & BitMask(2);
 2247|  16.5k|        bits >>= 2;
 2248|  16.5k|        s->num_direct_distance_codes = BROTLI_NUM_DISTANCE_SHORT_CODES +
  ------------------
  |  |   37|  16.5k|#define BROTLI_NUM_DISTANCE_SHORT_CODES 16
  ------------------
 2249|  16.5k|            (bits << s->distance_postfix_bits);
 2250|  16.5k|        BROTLI_LOG_UINT(s->num_direct_distance_codes);
 2251|  16.5k|        BROTLI_LOG_UINT(s->distance_postfix_bits);
 2252|  16.5k|        s->distance_postfix_mask = (int)BitMask(s->distance_postfix_bits);
 2253|  16.5k|        s->context_modes =
 2254|  16.5k|            (uint8_t*)BROTLI_DECODER_ALLOC(s, (size_t)s->num_block_types[0]);
  ------------------
  |  |  247|  16.5k|#define BROTLI_DECODER_ALLOC(S, L) S->alloc_func(S->memory_manager_opaque, L)
  ------------------
 2255|  16.5k|        if (s->context_modes == 0) {
  ------------------
  |  Branch (2255:13): [True: 0, False: 16.5k]
  ------------------
 2256|      0|          result = BROTLI_FAILURE(BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES);
  ------------------
  |  |   31|      0|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|      0|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
 2257|      0|          break;
 2258|      0|        }
 2259|  16.5k|        s->loop_counter = 0;
 2260|  16.5k|        s->state = BROTLI_STATE_CONTEXT_MODES;
 2261|       |        /* No break, continue to next state. */
 2262|  16.5k|      }
 2263|       |
 2264|  16.5k|      case BROTLI_STATE_CONTEXT_MODES:
  ------------------
  |  Branch (2264:7): [True: 0, False: 627k]
  ------------------
 2265|  16.5k|        result = ReadContextModes(s);
 2266|  16.5k|        if (result != BROTLI_DECODER_SUCCESS) {
  ------------------
  |  Branch (2266:13): [True: 20, False: 16.5k]
  ------------------
 2267|     20|          break;
 2268|     20|        }
 2269|  16.5k|        s->state = BROTLI_STATE_CONTEXT_MAP_1;
 2270|       |        /* No break, continue to next state. */
 2271|       |
 2272|  16.5k|      case BROTLI_STATE_CONTEXT_MAP_1:
  ------------------
  |  Branch (2272:7): [True: 0, False: 627k]
  ------------------
 2273|  16.5k|        result = DecodeContextMap(
 2274|  16.5k|            s->num_block_types[0] << BROTLI_LITERAL_CONTEXT_BITS,
  ------------------
  |  |   53|  16.5k|#define BROTLI_LITERAL_CONTEXT_BITS 6
  ------------------
 2275|  16.5k|            &s->num_literal_htrees, &s->context_map, s);
 2276|  16.5k|        if (result != BROTLI_DECODER_SUCCESS) {
  ------------------
  |  Branch (2276:13): [True: 152, False: 16.3k]
  ------------------
 2277|    152|          break;
 2278|    152|        }
 2279|  16.3k|        DetectTrivialLiteralBlockTypes(s);
 2280|  16.3k|        s->state = BROTLI_STATE_CONTEXT_MAP_2;
 2281|       |        /* No break, continue to next state. */
 2282|       |
 2283|  16.3k|      case BROTLI_STATE_CONTEXT_MAP_2: {
  ------------------
  |  Branch (2283:7): [True: 0, False: 627k]
  ------------------
 2284|  16.3k|        uint32_t num_direct_codes =
 2285|  16.3k|            s->num_direct_distance_codes - BROTLI_NUM_DISTANCE_SHORT_CODES;
  ------------------
  |  |   37|  16.3k|#define BROTLI_NUM_DISTANCE_SHORT_CODES 16
  ------------------
 2286|  16.3k|        uint32_t num_distance_codes = BROTLI_DISTANCE_ALPHABET_SIZE(
  ------------------
  |  |   41|  16.3k|#define BROTLI_DISTANCE_ALPHABET_SIZE(NDIRECT, NPOSTFIX, MAXNBITS) ( \
  |  |   42|  16.3k|    BROTLI_NUM_DISTANCE_SHORT_CODES + (NDIRECT) +                    \
  |  |  ------------------
  |  |  |  |   37|  16.3k|#define BROTLI_NUM_DISTANCE_SHORT_CODES 16
  |  |  ------------------
  |  |   43|  32.7k|    ((MAXNBITS) << ((NPOSTFIX) + 1)))
  |  |  ------------------
  |  |  |  Branch (43:7): [True: 0, False: 16.3k]
  |  |  ------------------
  ------------------
 2287|  16.3k|            num_direct_codes, s->distance_postfix_bits,
 2288|  16.3k|            (s->large_window ? BROTLI_LARGE_MAX_DISTANCE_BITS :
 2289|  16.3k|                               BROTLI_MAX_DISTANCE_BITS));
 2290|  16.3k|        uint32_t max_distance_symbol = (s->large_window ?
  ------------------
  |  Branch (2290:41): [True: 0, False: 16.3k]
  ------------------
 2291|      0|            BrotliMaxDistanceSymbol(
 2292|      0|                num_direct_codes, s->distance_postfix_bits) :
 2293|  16.3k|            num_distance_codes);
 2294|  16.3k|        BROTLI_BOOL allocation_success = BROTLI_TRUE;
  ------------------
  |  |   49|  16.3k|#define BROTLI_BOOL int
  ------------------
                      BROTLI_BOOL allocation_success = BROTLI_TRUE;
  ------------------
  |  |   51|  16.3k|#define BROTLI_TRUE 1
  ------------------
 2295|  16.3k|        result = DecodeContextMap(
 2296|  16.3k|            s->num_block_types[2] << BROTLI_DISTANCE_CONTEXT_BITS,
  ------------------
  |  |   56|  16.3k|#define BROTLI_DISTANCE_CONTEXT_BITS 2
  ------------------
 2297|  16.3k|            &s->num_dist_htrees, &s->dist_context_map, s);
 2298|  16.3k|        if (result != BROTLI_DECODER_SUCCESS) {
  ------------------
  |  Branch (2298:13): [True: 92, False: 16.2k]
  ------------------
 2299|     92|          break;
 2300|     92|        }
 2301|  16.2k|        allocation_success &= BrotliDecoderHuffmanTreeGroupInit(
 2302|  16.2k|            s, &s->literal_hgroup, BROTLI_NUM_LITERAL_SYMBOLS,
  ------------------
  |  |   17|  16.2k|#define BROTLI_NUM_LITERAL_SYMBOLS 256
  ------------------
 2303|  16.2k|            BROTLI_NUM_LITERAL_SYMBOLS, s->num_literal_htrees);
  ------------------
  |  |   17|  16.2k|#define BROTLI_NUM_LITERAL_SYMBOLS 256
  ------------------
 2304|  16.2k|        allocation_success &= BrotliDecoderHuffmanTreeGroupInit(
 2305|  16.2k|            s, &s->insert_copy_hgroup, BROTLI_NUM_COMMAND_SYMBOLS,
  ------------------
  |  |   18|  16.2k|#define BROTLI_NUM_COMMAND_SYMBOLS 704
  ------------------
 2306|  16.2k|            BROTLI_NUM_COMMAND_SYMBOLS, s->num_block_types[1]);
  ------------------
  |  |   18|  16.2k|#define BROTLI_NUM_COMMAND_SYMBOLS 704
  ------------------
 2307|  16.2k|        allocation_success &= BrotliDecoderHuffmanTreeGroupInit(
 2308|  16.2k|            s, &s->distance_hgroup, num_distance_codes,
 2309|  16.2k|            max_distance_symbol, s->num_dist_htrees);
 2310|  16.2k|        if (!allocation_success) {
  ------------------
  |  Branch (2310:13): [True: 0, False: 16.2k]
  ------------------
 2311|      0|          return SaveErrorCode(s,
 2312|      0|              BROTLI_FAILURE(BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS));
  ------------------
  |  |   31|      0|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|      0|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
 2313|      0|        }
 2314|  16.2k|        s->loop_counter = 0;
 2315|  16.2k|        s->state = BROTLI_STATE_TREE_GROUP;
 2316|       |        /* No break, continue to next state. */
 2317|  16.2k|      }
 2318|       |
 2319|  48.3k|      case BROTLI_STATE_TREE_GROUP: {
  ------------------
  |  Branch (2319:7): [True: 32.0k, False: 594k]
  ------------------
 2320|  48.3k|        HuffmanTreeGroup* hgroup = NULL;
 2321|  48.3k|        switch (s->loop_counter) {
 2322|  16.2k|          case 0: hgroup = &s->literal_hgroup; break;
  ------------------
  |  Branch (2322:11): [True: 16.2k, False: 32.0k]
  ------------------
 2323|  16.1k|          case 1: hgroup = &s->insert_copy_hgroup; break;
  ------------------
  |  Branch (2323:11): [True: 16.1k, False: 32.2k]
  ------------------
 2324|  15.9k|          case 2: hgroup = &s->distance_hgroup; break;
  ------------------
  |  Branch (2324:11): [True: 15.9k, False: 32.3k]
  ------------------
 2325|      0|          default: return SaveErrorCode(s, BROTLI_FAILURE(
  ------------------
  |  |   31|      0|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|      0|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
  |  Branch (2325:11): [True: 0, False: 48.3k]
  ------------------
 2326|      0|              BROTLI_DECODER_ERROR_UNREACHABLE));
 2327|  48.3k|        }
 2328|  48.3k|        result = HuffmanTreeGroupDecode(hgroup, s);
 2329|  48.3k|        if (result != BROTLI_DECODER_SUCCESS) break;
  ------------------
  |  Branch (2329:13): [True: 409, False: 47.9k]
  ------------------
 2330|  47.9k|        s->loop_counter++;
 2331|  47.9k|        if (s->loop_counter >= 3) {
  ------------------
  |  Branch (2331:13): [True: 15.8k, False: 32.0k]
  ------------------
 2332|  15.8k|          PrepareLiteralDecoding(s);
 2333|  15.8k|          s->dist_context_map_slice = s->dist_context_map;
 2334|  15.8k|          s->htree_command = s->insert_copy_hgroup.htrees[0];
 2335|  15.8k|          if (!BrotliEnsureRingBuffer(s)) {
  ------------------
  |  Branch (2335:15): [True: 0, False: 15.8k]
  ------------------
 2336|      0|            result = BROTLI_FAILURE(BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2);
  ------------------
  |  |   31|      0|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|      0|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
 2337|      0|            break;
 2338|      0|          }
 2339|  15.8k|          s->state = BROTLI_STATE_COMMAND_BEGIN;
 2340|  15.8k|        }
 2341|  47.9k|        break;
 2342|  47.9k|      }
 2343|       |
 2344|  47.9k|      case BROTLI_STATE_COMMAND_BEGIN:
  ------------------
  |  Branch (2344:7): [True: 16.4k, False: 610k]
  ------------------
 2345|  17.7k|      case BROTLI_STATE_COMMAND_INNER:
  ------------------
  |  Branch (2345:7): [True: 1.31k, False: 625k]
  ------------------
 2346|  18.2k|      case BROTLI_STATE_COMMAND_POST_DECODE_LITERALS:
  ------------------
  |  Branch (2346:7): [True: 514, False: 626k]
  ------------------
 2347|  20.5k|      case BROTLI_STATE_COMMAND_POST_WRAP_COPY:
  ------------------
  |  Branch (2347:7): [True: 2.32k, False: 624k]
  ------------------
 2348|  20.5k|        result = ProcessCommands(s);
 2349|  20.5k|        if (result == BROTLI_DECODER_NEEDS_MORE_INPUT) {
  ------------------
  |  Branch (2349:13): [True: 3.64k, False: 16.9k]
  ------------------
 2350|  3.64k|          result = SafeProcessCommands(s);
 2351|  3.64k|        }
 2352|  20.5k|        break;
 2353|       |
 2354|  1.96k|      case BROTLI_STATE_COMMAND_INNER_WRITE:
  ------------------
  |  Branch (2354:7): [True: 1.96k, False: 625k]
  ------------------
 2355|  2.52k|      case BROTLI_STATE_COMMAND_POST_WRITE_1:
  ------------------
  |  Branch (2355:7): [True: 564, False: 626k]
  ------------------
 2356|  4.98k|      case BROTLI_STATE_COMMAND_POST_WRITE_2:
  ------------------
  |  Branch (2356:7): [True: 2.45k, False: 624k]
  ------------------
 2357|  4.98k|        result = WriteRingBuffer(
 2358|  4.98k|            s, available_out, next_out, total_out, BROTLI_FALSE);
  ------------------
  |  |   53|  4.98k|#define BROTLI_FALSE 0
  ------------------
 2359|  4.98k|        if (result != BROTLI_DECODER_SUCCESS) {
  ------------------
  |  Branch (2359:13): [True: 264, False: 4.72k]
  ------------------
 2360|    264|          break;
 2361|    264|        }
 2362|  4.72k|        WrapRingBuffer(s);
 2363|  4.72k|        if (s->ringbuffer_size == 1 << s->window_bits) {
  ------------------
  |  Branch (2363:13): [True: 4.68k, False: 40]
  ------------------
 2364|  4.68k|          s->max_distance = s->max_backward_distance;
 2365|  4.68k|        }
 2366|  4.72k|        if (s->state == BROTLI_STATE_COMMAND_POST_WRITE_1) {
  ------------------
  |  Branch (2366:13): [True: 531, False: 4.19k]
  ------------------
 2367|    531|          if (s->meta_block_remaining_len == 0) {
  ------------------
  |  Branch (2367:15): [True: 2, False: 529]
  ------------------
 2368|       |            /* Next metablock, if any. */
 2369|      2|            s->state = BROTLI_STATE_METABLOCK_DONE;
 2370|    529|          } else {
 2371|    529|            s->state = BROTLI_STATE_COMMAND_BEGIN;
 2372|    529|          }
 2373|    531|          break;
 2374|  4.19k|        } else if (s->state == BROTLI_STATE_COMMAND_POST_WRITE_2) {
  ------------------
  |  Branch (2374:20): [True: 2.32k, False: 1.87k]
  ------------------
 2375|  2.32k|          s->state = BROTLI_STATE_COMMAND_POST_WRAP_COPY;
 2376|  2.32k|        } else {  /* BROTLI_STATE_COMMAND_INNER_WRITE */
 2377|  1.87k|          if (s->loop_counter == 0) {
  ------------------
  |  Branch (2377:15): [True: 556, False: 1.31k]
  ------------------
 2378|    556|            if (s->meta_block_remaining_len == 0) {
  ------------------
  |  Branch (2378:17): [True: 42, False: 514]
  ------------------
 2379|     42|              s->state = BROTLI_STATE_METABLOCK_DONE;
 2380|    514|            } else {
 2381|    514|              s->state = BROTLI_STATE_COMMAND_POST_DECODE_LITERALS;
 2382|    514|            }
 2383|    556|            break;
 2384|    556|          }
 2385|  1.31k|          s->state = BROTLI_STATE_COMMAND_INNER;
 2386|  1.31k|        }
 2387|  3.63k|        break;
 2388|       |
 2389|   164k|      case BROTLI_STATE_METABLOCK_DONE:
  ------------------
  |  Branch (2389:7): [True: 164k, False: 462k]
  ------------------
 2390|   164k|        if (s->meta_block_remaining_len < 0) {
  ------------------
  |  Branch (2390:13): [True: 240, False: 163k]
  ------------------
 2391|    240|          result = BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2);
  ------------------
  |  |   31|    240|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|    240|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
 2392|    240|          break;
 2393|    240|        }
 2394|   163k|        BrotliDecoderStateCleanupAfterMetablock(s);
 2395|   163k|        if (!s->is_last_metablock) {
  ------------------
  |  Branch (2395:13): [True: 162k, False: 1.32k]
  ------------------
 2396|   162k|          s->state = BROTLI_STATE_METABLOCK_BEGIN;
 2397|   162k|          break;
 2398|   162k|        }
 2399|  1.32k|        if (!BrotliJumpToByteBoundary(br)) {
  ------------------
  |  Branch (2399:13): [True: 20, False: 1.30k]
  ------------------
 2400|     20|          result = BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_PADDING_2);
  ------------------
  |  |   31|     20|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|     20|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
 2401|     20|          break;
 2402|     20|        }
 2403|  1.30k|        if (s->buffer_length == 0) {
  ------------------
  |  Branch (2403:13): [True: 1.30k, False: 0]
  ------------------
 2404|  1.30k|          BrotliBitReaderUnload(br);
 2405|  1.30k|          *available_in = br->avail_in;
 2406|  1.30k|          *next_in = br->next_in;
 2407|  1.30k|        }
 2408|  1.30k|        s->state = BROTLI_STATE_DONE;
 2409|       |        /* No break, continue to next state. */
 2410|       |
 2411|  1.30k|      case BROTLI_STATE_DONE:
  ------------------
  |  Branch (2411:7): [True: 0, False: 627k]
  ------------------
 2412|  1.30k|        if (s->ringbuffer != 0) {
  ------------------
  |  Branch (2412:13): [True: 1.28k, False: 22]
  ------------------
 2413|  1.28k|          result = WriteRingBuffer(
 2414|  1.28k|              s, available_out, next_out, total_out, BROTLI_TRUE);
  ------------------
  |  |   51|  1.28k|#define BROTLI_TRUE 1
  ------------------
 2415|  1.28k|          if (result != BROTLI_DECODER_SUCCESS) {
  ------------------
  |  Branch (2415:15): [True: 7, False: 1.27k]
  ------------------
 2416|      7|            break;
 2417|      7|          }
 2418|  1.28k|        }
 2419|  1.30k|        return SaveErrorCode(s, result);
 2420|   627k|    }
 2421|   627k|  }
 2422|  4.72k|  return SaveErrorCode(s, result);
 2423|  6.02k|}
decode.c:SaveErrorCode:
  114|  6.02k|    BrotliDecoderState* s, BrotliDecoderErrorCode e) {
  115|  6.02k|  s->error_code = (int)e;
  116|  6.02k|  switch (e) {
  117|  1.30k|    case BROTLI_DECODER_SUCCESS:
  ------------------
  |  Branch (117:5): [True: 1.30k, False: 4.72k]
  ------------------
  118|  1.30k|      return BROTLI_DECODER_RESULT_SUCCESS;
  119|       |
  120|  3.46k|    case BROTLI_DECODER_NEEDS_MORE_INPUT:
  ------------------
  |  Branch (120:5): [True: 3.46k, False: 2.56k]
  ------------------
  121|  3.46k|      return BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT;
  122|       |
  123|    155|    case BROTLI_DECODER_NEEDS_MORE_OUTPUT:
  ------------------
  |  Branch (123:5): [True: 155, False: 5.86k]
  ------------------
  124|    155|      return BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT;
  125|       |
  126|  1.10k|    default:
  ------------------
  |  Branch (126:5): [True: 1.10k, False: 4.91k]
  ------------------
  127|  1.10k|      return BROTLI_DECODER_RESULT_ERROR;
  128|  6.02k|  }
  129|  6.02k|}
decode.c:WriteRingBuffer:
 1249|  7.48k|    size_t* total_out, BROTLI_BOOL force) {
 1250|  7.48k|  uint8_t* start =
 1251|  7.48k|      s->ringbuffer + (s->partial_pos_out & (size_t)s->ringbuffer_mask);
 1252|  7.48k|  size_t to_write = UnwrittenBytes(s, BROTLI_TRUE);
  ------------------
  |  |   51|  7.48k|#define BROTLI_TRUE 1
  ------------------
 1253|  7.48k|  size_t num_written = *available_out;
 1254|  7.48k|  if (num_written > to_write) {
  ------------------
  |  Branch (1254:7): [True: 5.15k, False: 2.33k]
  ------------------
 1255|  5.15k|    num_written = to_write;
 1256|  5.15k|  }
 1257|  7.48k|  if (s->meta_block_remaining_len < 0) {
  ------------------
  |  Branch (1257:7): [True: 142, False: 7.34k]
  ------------------
 1258|    142|    return BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1);
  ------------------
  |  |   31|    142|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|    142|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
 1259|    142|  }
 1260|  7.34k|  if (next_out && !*next_out) {
  ------------------
  |  Branch (1260:7): [True: 7.34k, False: 0]
  |  Branch (1260:19): [True: 0, False: 7.34k]
  ------------------
 1261|      0|    *next_out = start;
 1262|  7.34k|  } else {
 1263|  7.34k|    if (next_out) {
  ------------------
  |  Branch (1263:9): [True: 7.34k, False: 0]
  ------------------
 1264|  7.34k|      memcpy(*next_out, start, num_written);
 1265|  7.34k|      *next_out += num_written;
 1266|  7.34k|    }
 1267|  7.34k|  }
 1268|  7.34k|  *available_out -= num_written;
 1269|  7.34k|  BROTLI_LOG_UINT(to_write);
 1270|  7.34k|  BROTLI_LOG_UINT(num_written);
 1271|  7.34k|  s->partial_pos_out += num_written;
 1272|  7.34k|  if (total_out) {
  ------------------
  |  Branch (1272:7): [True: 7.34k, False: 0]
  ------------------
 1273|  7.34k|    *total_out = s->partial_pos_out;
 1274|  7.34k|  }
 1275|  7.34k|  if (num_written < to_write) {
  ------------------
  |  Branch (1275:7): [True: 920, False: 6.42k]
  ------------------
 1276|    920|    if (s->ringbuffer_size == (1 << s->window_bits) || force) {
  ------------------
  |  Branch (1276:9): [True: 493, False: 427]
  |  Branch (1276:56): [True: 402, False: 25]
  ------------------
 1277|    895|      return BROTLI_DECODER_NEEDS_MORE_OUTPUT;
 1278|    895|    } else {
 1279|     25|      return BROTLI_DECODER_SUCCESS;
 1280|     25|    }
 1281|    920|  }
 1282|       |  /* Wrap ring buffer only if it has reached its maximal size. */
 1283|  6.42k|  if (s->ringbuffer_size == (1 << s->window_bits) &&
  ------------------
  |  Branch (1283:7): [True: 5.01k, False: 1.41k]
  ------------------
 1284|  6.42k|      s->pos >= s->ringbuffer_size) {
  ------------------
  |  Branch (1284:7): [True: 4.83k, False: 181]
  ------------------
 1285|  4.83k|    s->pos -= s->ringbuffer_size;
 1286|  4.83k|    s->rb_roundtrips++;
 1287|  4.83k|    s->should_wrap_ringbuffer = (size_t)s->pos != 0 ? 1 : 0;
  ------------------
  |  Branch (1287:33): [True: 484, False: 4.34k]
  ------------------
 1288|  4.83k|  }
 1289|  6.42k|  return BROTLI_DECODER_SUCCESS;
 1290|  7.34k|}
decode.c:DecodeWindowBits:
  134|  4.28k|                                               BrotliBitReader* br) {
  135|  4.28k|  uint32_t n;
  136|  4.28k|  BROTLI_BOOL large_window = s->large_window;
  ------------------
  |  |   49|  4.28k|#define BROTLI_BOOL int
  ------------------
  137|  4.28k|  s->large_window = BROTLI_FALSE;
  ------------------
  |  |   53|  4.28k|#define BROTLI_FALSE 0
  ------------------
  138|  4.28k|  BrotliTakeBits(br, 1, &n);
  139|  4.28k|  if (n == 0) {
  ------------------
  |  Branch (139:7): [True: 2.48k, False: 1.80k]
  ------------------
  140|  2.48k|    s->window_bits = 16;
  141|  2.48k|    return BROTLI_DECODER_SUCCESS;
  142|  2.48k|  }
  143|  1.80k|  BrotliTakeBits(br, 3, &n);
  144|  1.80k|  if (n != 0) {
  ------------------
  |  Branch (144:7): [True: 1.39k, False: 412]
  ------------------
  145|  1.39k|    s->window_bits = 17 + n;
  146|  1.39k|    return BROTLI_DECODER_SUCCESS;
  147|  1.39k|  }
  148|    412|  BrotliTakeBits(br, 3, &n);
  149|    412|  if (n == 1) {
  ------------------
  |  Branch (149:7): [True: 1, False: 411]
  ------------------
  150|      1|    if (large_window) {
  ------------------
  |  Branch (150:9): [True: 0, False: 1]
  ------------------
  151|      0|      BrotliTakeBits(br, 1, &n);
  152|      0|      if (n == 1) {
  ------------------
  |  Branch (152:11): [True: 0, False: 0]
  ------------------
  153|      0|        return BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS);
  ------------------
  |  |   31|      0|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|      0|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
  154|      0|      }
  155|      0|      s->large_window = BROTLI_TRUE;
  ------------------
  |  |   51|      0|#define BROTLI_TRUE 1
  ------------------
  156|      0|      return BROTLI_DECODER_SUCCESS;
  157|      1|    } else {
  158|      1|      return BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS);
  ------------------
  |  |   31|      1|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|      1|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
  159|      1|    }
  160|      1|  }
  161|    411|  if (n != 0) {
  ------------------
  |  Branch (161:7): [True: 346, False: 65]
  ------------------
  162|    346|    s->window_bits = 8 + n;
  163|    346|    return BROTLI_DECODER_SUCCESS;
  164|    346|  }
  165|     65|  s->window_bits = 17;
  166|     65|  return BROTLI_DECODER_SUCCESS;
  167|    411|}
decode.c:DecodeMetaBlockLength:
  225|   166k|    BrotliDecoderState* s, BrotliBitReader* br) {
  226|   166k|  uint32_t bits;
  227|   166k|  int i;
  228|   474k|  for (;;) {
  229|   474k|    switch (s->substate_metablock_header) {
  230|   166k|      case BROTLI_STATE_METABLOCK_HEADER_NONE:
  ------------------
  |  Branch (230:7): [True: 166k, False: 307k]
  ------------------
  231|   166k|        if (!BrotliSafeReadBits(br, 1, &bits)) {
  ------------------
  |  Branch (231:13): [True: 16, False: 166k]
  ------------------
  232|     16|          return BROTLI_DECODER_NEEDS_MORE_INPUT;
  233|     16|        }
  234|   166k|        s->is_last_metablock = bits ? 1 : 0;
  ------------------
  |  Branch (234:32): [True: 1.98k, False: 164k]
  ------------------
  235|   166k|        s->meta_block_remaining_len = 0;
  236|   166k|        s->is_uncompressed = 0;
  237|   166k|        s->is_metadata = 0;
  238|   166k|        if (!s->is_last_metablock) {
  ------------------
  |  Branch (238:13): [True: 164k, False: 1.98k]
  ------------------
  239|   164k|          s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_NIBBLES;
  240|   164k|          break;
  241|   164k|        }
  242|  1.98k|        s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_EMPTY;
  243|       |        /* No break, transit to the next state. */
  244|       |
  245|  1.98k|      case BROTLI_STATE_METABLOCK_HEADER_EMPTY:
  ------------------
  |  Branch (245:7): [True: 0, False: 474k]
  ------------------
  246|  1.98k|        if (!BrotliSafeReadBits(br, 1, &bits)) {
  ------------------
  |  Branch (246:13): [True: 9, False: 1.98k]
  ------------------
  247|      9|          return BROTLI_DECODER_NEEDS_MORE_INPUT;
  248|      9|        }
  249|  1.98k|        if (bits) {
  ------------------
  |  Branch (249:13): [True: 492, False: 1.48k]
  ------------------
  250|    492|          s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_NONE;
  251|    492|          return BROTLI_DECODER_SUCCESS;
  252|    492|        }
  253|  1.48k|        s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_NIBBLES;
  254|       |        /* No break, transit to the next state. */
  255|       |
  256|   166k|      case BROTLI_STATE_METABLOCK_HEADER_NIBBLES:
  ------------------
  |  Branch (256:7): [True: 164k, False: 309k]
  ------------------
  257|   166k|        if (!BrotliSafeReadBits(br, 2, &bits)) {
  ------------------
  |  Branch (257:13): [True: 17, False: 166k]
  ------------------
  258|     17|          return BROTLI_DECODER_NEEDS_MORE_INPUT;
  259|     17|        }
  260|   166k|        s->size_nibbles = (uint8_t)(bits + 4);
  261|   166k|        s->loop_counter = 0;
  262|   166k|        if (bits == 3) {
  ------------------
  |  Branch (262:13): [True: 142k, False: 23.2k]
  ------------------
  263|   142k|          s->is_metadata = 1;
  264|   142k|          s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_RESERVED;
  265|   142k|          break;
  266|   142k|        }
  267|  23.2k|        s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_SIZE;
  268|       |        /* No break, transit to the next state. */
  269|       |
  270|  23.2k|      case BROTLI_STATE_METABLOCK_HEADER_SIZE:
  ------------------
  |  Branch (270:7): [True: 0, False: 474k]
  ------------------
  271|  23.2k|        i = s->loop_counter;
  272|   117k|        for (; i < (int)s->size_nibbles; ++i) {
  ------------------
  |  Branch (272:16): [True: 94.3k, False: 23.1k]
  ------------------
  273|  94.3k|          if (!BrotliSafeReadBits(br, 4, &bits)) {
  ------------------
  |  Branch (273:15): [True: 76, False: 94.2k]
  ------------------
  274|     76|            s->loop_counter = i;
  275|     76|            return BROTLI_DECODER_NEEDS_MORE_INPUT;
  276|     76|          }
  277|  94.2k|          if (i + 1 == s->size_nibbles && s->size_nibbles > 4 && bits == 0) {
  ------------------
  |  Branch (277:15): [True: 23.2k, False: 71.0k]
  |  Branch (277:43): [True: 881, False: 22.3k]
  |  Branch (277:66): [True: 10, False: 871]
  ------------------
  278|     10|            return BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE);
  ------------------
  |  |   31|     10|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|     10|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
  279|     10|          }
  280|  94.2k|          s->meta_block_remaining_len |= (int)(bits << (i * 4));
  281|  94.2k|        }
  282|  23.1k|        s->substate_metablock_header =
  283|  23.1k|            BROTLI_STATE_METABLOCK_HEADER_UNCOMPRESSED;
  284|       |        /* No break, transit to the next state. */
  285|       |
  286|  23.1k|      case BROTLI_STATE_METABLOCK_HEADER_UNCOMPRESSED:
  ------------------
  |  Branch (286:7): [True: 0, False: 474k]
  ------------------
  287|  23.1k|        if (!s->is_last_metablock) {
  ------------------
  |  Branch (287:13): [True: 21.8k, False: 1.32k]
  ------------------
  288|  21.8k|          if (!BrotliSafeReadBits(br, 1, &bits)) {
  ------------------
  |  Branch (288:15): [True: 6, False: 21.8k]
  ------------------
  289|      6|            return BROTLI_DECODER_NEEDS_MORE_INPUT;
  290|      6|          }
  291|  21.8k|          s->is_uncompressed = bits ? 1 : 0;
  ------------------
  |  Branch (291:32): [True: 6.31k, False: 15.5k]
  ------------------
  292|  21.8k|        }
  293|  23.1k|        ++s->meta_block_remaining_len;
  294|  23.1k|        s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_NONE;
  295|  23.1k|        return BROTLI_DECODER_SUCCESS;
  296|       |
  297|   142k|      case BROTLI_STATE_METABLOCK_HEADER_RESERVED:
  ------------------
  |  Branch (297:7): [True: 142k, False: 331k]
  ------------------
  298|   142k|        if (!BrotliSafeReadBits(br, 1, &bits)) {
  ------------------
  |  Branch (298:13): [True: 8, False: 142k]
  ------------------
  299|      8|          return BROTLI_DECODER_NEEDS_MORE_INPUT;
  300|      8|        }
  301|   142k|        if (bits != 0) {
  ------------------
  |  Branch (301:13): [True: 8, False: 142k]
  ------------------
  302|      8|          return BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_RESERVED);
  ------------------
  |  |   31|      8|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|      8|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
  303|      8|        }
  304|   142k|        s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_BYTES;
  305|       |        /* No break, transit to the next state. */
  306|       |
  307|   142k|      case BROTLI_STATE_METABLOCK_HEADER_BYTES:
  ------------------
  |  Branch (307:7): [True: 0, False: 474k]
  ------------------
  308|   142k|        if (!BrotliSafeReadBits(br, 2, &bits)) {
  ------------------
  |  Branch (308:13): [True: 12, False: 142k]
  ------------------
  309|     12|          return BROTLI_DECODER_NEEDS_MORE_INPUT;
  310|     12|        }
  311|   142k|        if (bits == 0) {
  ------------------
  |  Branch (311:13): [True: 111k, False: 31.1k]
  ------------------
  312|   111k|          s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_NONE;
  313|   111k|          return BROTLI_DECODER_SUCCESS;
  314|   111k|        }
  315|  31.1k|        s->size_nibbles = (uint8_t)bits;
  316|  31.1k|        s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_METADATA;
  317|       |        /* No break, transit to the next state. */
  318|       |
  319|  31.1k|      case BROTLI_STATE_METABLOCK_HEADER_METADATA:
  ------------------
  |  Branch (319:7): [True: 0, False: 474k]
  ------------------
  320|  31.1k|        i = s->loop_counter;
  321|  62.4k|        for (; i < (int)s->size_nibbles; ++i) {
  ------------------
  |  Branch (321:16): [True: 31.3k, False: 31.1k]
  ------------------
  322|  31.3k|          if (!BrotliSafeReadBits(br, 8, &bits)) {
  ------------------
  |  Branch (322:15): [True: 12, False: 31.3k]
  ------------------
  323|     12|            s->loop_counter = i;
  324|     12|            return BROTLI_DECODER_NEEDS_MORE_INPUT;
  325|     12|          }
  326|  31.3k|          if (i + 1 == s->size_nibbles && s->size_nibbles > 1 && bits == 0) {
  ------------------
  |  Branch (326:15): [True: 31.1k, False: 213]
  |  Branch (326:43): [True: 175, False: 30.9k]
  |  Branch (326:66): [True: 2, False: 173]
  ------------------
  327|      2|            return BROTLI_FAILURE(
  ------------------
  |  |   31|      2|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|      2|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
  328|      2|                BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE);
  329|      2|          }
  330|  31.3k|          s->meta_block_remaining_len |= (int)(bits << (i * 8));
  331|  31.3k|        }
  332|  31.1k|        ++s->meta_block_remaining_len;
  333|  31.1k|        s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_NONE;
  334|  31.1k|        return BROTLI_DECODER_SUCCESS;
  335|       |
  336|      0|      default:
  ------------------
  |  Branch (336:7): [True: 0, False: 474k]
  ------------------
  337|      0|        return
  338|      0|            BROTLI_FAILURE(BROTLI_DECODER_ERROR_UNREACHABLE);
  ------------------
  |  |   31|      0|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|      0|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
  339|   474k|    }
  340|   474k|  }
  341|   166k|}
decode.c:BrotliCalculateRingBufferSize:
 1393|  23.1k|    BrotliDecoderState* s) {
 1394|  23.1k|  int window_size = 1 << s->window_bits;
 1395|  23.1k|  int new_ringbuffer_size = window_size;
 1396|       |  /* We need at least 2 bytes of ring buffer size to get the last two
 1397|       |     bytes for context from there */
 1398|  23.1k|  int min_size = s->ringbuffer_size ? s->ringbuffer_size : 1024;
  ------------------
  |  Branch (1398:18): [True: 19.1k, False: 4.07k]
  ------------------
 1399|  23.1k|  int output_size;
 1400|       |
 1401|       |  /* If maximum is already reached, no further extension is retired. */
 1402|  23.1k|  if (s->ringbuffer_size == window_size) {
  ------------------
  |  Branch (1402:7): [True: 4.61k, False: 18.5k]
  ------------------
 1403|  4.61k|    return;
 1404|  4.61k|  }
 1405|       |
 1406|       |  /* Metadata blocks does not touch ring buffer. */
 1407|  18.5k|  if (s->is_metadata) {
  ------------------
  |  Branch (1407:7): [True: 0, False: 18.5k]
  ------------------
 1408|      0|    return;
 1409|      0|  }
 1410|       |
 1411|  18.5k|  if (!s->ringbuffer) {
  ------------------
  |  Branch (1411:7): [True: 4.07k, False: 14.4k]
  ------------------
 1412|  4.07k|    output_size = 0;
 1413|  14.4k|  } else {
 1414|  14.4k|    output_size = s->pos;
 1415|  14.4k|  }
 1416|  18.5k|  output_size += s->meta_block_remaining_len;
 1417|  18.5k|  min_size = min_size < output_size ? output_size : min_size;
  ------------------
  |  Branch (1417:14): [True: 3.02k, False: 15.5k]
  ------------------
 1418|       |
 1419|  18.5k|  if (!!s->canny_ringbuffer_allocation) {
  ------------------
  |  Branch (1419:7): [True: 18.5k, False: 0]
  ------------------
 1420|       |    /* Reduce ring buffer size to save memory when server is unscrupulous.
 1421|       |       In worst case memory usage might be 1.5x bigger for a short period of
 1422|       |       ring buffer reallocation. */
 1423|  92.1k|    while ((new_ringbuffer_size >> 1) >= min_size) {
  ------------------
  |  Branch (1423:12): [True: 73.6k, False: 18.5k]
  ------------------
 1424|  73.6k|      new_ringbuffer_size >>= 1;
 1425|  73.6k|    }
 1426|  18.5k|  }
 1427|       |
 1428|  18.5k|  s->new_ringbuffer_size = new_ringbuffer_size;
 1429|  18.5k|}
decode.c:CopyUncompressedBlockToOutput:
 1337|  6.30k|    BrotliDecoderState* s) {
 1338|       |  /* TODO: avoid allocation for single uncompressed block. */
 1339|  6.30k|  if (!BrotliEnsureRingBuffer(s)) {
  ------------------
  |  Branch (1339:7): [True: 0, False: 6.30k]
  ------------------
 1340|      0|    return BROTLI_FAILURE(BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1);
  ------------------
  |  |   31|      0|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|      0|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
 1341|      0|  }
 1342|       |
 1343|       |  /* State machine */
 1344|  6.45k|  for (;;) {
 1345|  6.45k|    switch (s->substate_uncompressed) {
  ------------------
  |  Branch (1345:13): [True: 0, False: 6.45k]
  ------------------
 1346|  6.45k|      case BROTLI_STATE_UNCOMPRESSED_NONE: {
  ------------------
  |  Branch (1346:7): [True: 6.45k, False: 0]
  ------------------
 1347|  6.45k|        int nbytes = (int)BrotliGetRemainingBytes(&s->br);
 1348|  6.45k|        if (nbytes > s->meta_block_remaining_len) {
  ------------------
  |  Branch (1348:13): [True: 6.18k, False: 264]
  ------------------
 1349|  6.18k|          nbytes = s->meta_block_remaining_len;
 1350|  6.18k|        }
 1351|  6.45k|        if (s->pos + nbytes > s->ringbuffer_size) {
  ------------------
  |  Branch (1351:13): [True: 153, False: 6.29k]
  ------------------
 1352|    153|          nbytes = s->ringbuffer_size - s->pos;
 1353|    153|        }
 1354|       |        /* Copy remaining bytes from s->br.buf_ to ring-buffer. */
 1355|  6.45k|        BrotliCopyBytes(&s->ringbuffer[s->pos], &s->br, (size_t)nbytes);
 1356|  6.45k|        s->pos += nbytes;
 1357|  6.45k|        s->meta_block_remaining_len -= nbytes;
 1358|  6.45k|        if (s->pos < 1 << s->window_bits) {
  ------------------
  |  Branch (1358:13): [True: 6.29k, False: 156]
  ------------------
 1359|  6.29k|          if (s->meta_block_remaining_len == 0) {
  ------------------
  |  Branch (1359:15): [True: 6.17k, False: 121]
  ------------------
 1360|  6.17k|            return BROTLI_DECODER_SUCCESS;
 1361|  6.17k|          }
 1362|    121|          return BROTLI_DECODER_NEEDS_MORE_INPUT;
 1363|  6.29k|        }
 1364|    156|        s->substate_uncompressed = BROTLI_STATE_UNCOMPRESSED_WRITE;
 1365|       |        /* No break, continue to next state. */
 1366|    156|      }
 1367|       |
 1368|    156|      case BROTLI_STATE_UNCOMPRESSED_WRITE: {
  ------------------
  |  Branch (1368:7): [True: 0, False: 6.45k]
  ------------------
 1369|    156|        BrotliDecoderErrorCode result;
 1370|    156|        result = WriteRingBuffer(
 1371|    156|            s, available_out, next_out, total_out, BROTLI_FALSE);
  ------------------
  |  |   53|    156|#define BROTLI_FALSE 0
  ------------------
 1372|    156|        if (result != BROTLI_DECODER_SUCCESS) {
  ------------------
  |  Branch (1372:13): [True: 9, False: 147]
  ------------------
 1373|      9|          return result;
 1374|      9|        }
 1375|    147|        if (s->ringbuffer_size == 1 << s->window_bits) {
  ------------------
  |  Branch (1375:13): [True: 147, False: 0]
  ------------------
 1376|    147|          s->max_distance = s->max_backward_distance;
 1377|    147|        }
 1378|    147|        s->substate_uncompressed = BROTLI_STATE_UNCOMPRESSED_NONE;
 1379|    147|        break;
 1380|    156|      }
 1381|  6.45k|    }
 1382|  6.45k|  }
 1383|      0|  BROTLI_DCHECK(0);  /* Unreachable */
 1384|      0|}
decode.c:DecodeVarLenUint8:
  181|  83.1k|    BrotliDecoderState* s, BrotliBitReader* br, uint32_t* value) {
  182|  83.1k|  uint32_t bits;
  183|  83.1k|  switch (s->substate_decode_uint8) {
  184|  83.1k|    case BROTLI_STATE_DECODE_UINT8_NONE:
  ------------------
  |  Branch (184:5): [True: 83.1k, False: 0]
  ------------------
  185|  83.1k|      if (BROTLI_PREDICT_FALSE(!BrotliSafeReadBits(br, 1, &bits))) {
  ------------------
  |  |  318|  83.1k|#define BROTLI_PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (318:33): [True: 21, False: 83.1k]
  |  |  ------------------
  ------------------
  186|     21|        return BROTLI_DECODER_NEEDS_MORE_INPUT;
  187|     21|      }
  188|  83.1k|      if (bits == 0) {
  ------------------
  |  Branch (188:11): [True: 71.2k, False: 11.8k]
  ------------------
  189|  71.2k|        *value = 0;
  190|  71.2k|        return BROTLI_DECODER_SUCCESS;
  191|  71.2k|      }
  192|       |      /* No break, transit to the next state. */
  193|       |
  194|  11.8k|    case BROTLI_STATE_DECODE_UINT8_SHORT:
  ------------------
  |  Branch (194:5): [True: 0, False: 83.1k]
  ------------------
  195|  11.8k|      if (BROTLI_PREDICT_FALSE(!BrotliSafeReadBits(br, 3, &bits))) {
  ------------------
  |  |  318|  11.8k|#define BROTLI_PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (318:33): [True: 9, False: 11.8k]
  |  |  ------------------
  ------------------
  196|      9|        s->substate_decode_uint8 = BROTLI_STATE_DECODE_UINT8_SHORT;
  197|      9|        return BROTLI_DECODER_NEEDS_MORE_INPUT;
  198|      9|      }
  199|  11.8k|      if (bits == 0) {
  ------------------
  |  Branch (199:11): [True: 934, False: 10.9k]
  ------------------
  200|    934|        *value = 1;
  201|    934|        s->substate_decode_uint8 = BROTLI_STATE_DECODE_UINT8_NONE;
  202|    934|        return BROTLI_DECODER_SUCCESS;
  203|    934|      }
  204|       |      /* Use output value as a temporary storage. It MUST be persisted. */
  205|  10.9k|      *value = bits;
  206|       |      /* No break, transit to the next state. */
  207|       |
  208|  10.9k|    case BROTLI_STATE_DECODE_UINT8_LONG:
  ------------------
  |  Branch (208:5): [True: 0, False: 83.1k]
  ------------------
  209|  10.9k|      if (BROTLI_PREDICT_FALSE(!BrotliSafeReadBits(br, *value, &bits))) {
  ------------------
  |  |  318|  10.9k|#define BROTLI_PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (318:33): [True: 19, False: 10.9k]
  |  |  ------------------
  ------------------
  210|     19|        s->substate_decode_uint8 = BROTLI_STATE_DECODE_UINT8_LONG;
  211|     19|        return BROTLI_DECODER_NEEDS_MORE_INPUT;
  212|     19|      }
  213|  10.9k|      *value = (1U << *value) + bits;
  214|  10.9k|      s->substate_decode_uint8 = BROTLI_STATE_DECODE_UINT8_NONE;
  215|  10.9k|      return BROTLI_DECODER_SUCCESS;
  216|       |
  217|      0|    default:
  ------------------
  |  Branch (217:5): [True: 0, False: 83.1k]
  ------------------
  218|      0|      return
  219|      0|          BROTLI_FAILURE(BROTLI_DECODER_ERROR_UNREACHABLE);
  ------------------
  |  |   31|      0|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|      0|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
  220|  83.1k|  }
  221|  83.1k|}
decode.c:ReadHuffmanCode:
  734|  89.9k|                                              BrotliDecoderState* s) {
  735|  89.9k|  BrotliBitReader* br = &s->br;
  736|       |  /* Unnecessary masking, but might be good for safety. */
  737|  89.9k|  alphabet_size &= 0x7FF;
  738|       |  /* State machine. */
  739|   116k|  for (;;) {
  740|   116k|    switch (s->substate_huffman) {
  741|  89.9k|      case BROTLI_STATE_HUFFMAN_NONE:
  ------------------
  |  Branch (741:7): [True: 89.9k, False: 26.4k]
  ------------------
  742|  89.9k|        if (!BrotliSafeReadBits(br, 2, &s->sub_loop_counter)) {
  ------------------
  |  Branch (742:13): [True: 47, False: 89.8k]
  ------------------
  743|     47|          return BROTLI_DECODER_NEEDS_MORE_INPUT;
  744|     47|        }
  745|  89.8k|        BROTLI_LOG_UINT(s->sub_loop_counter);
  746|       |        /* The value is used as follows:
  747|       |           1 for simple code;
  748|       |           0 for no skipping, 2 skips 2 code lengths, 3 skips 3 code lengths */
  749|  89.8k|        if (s->sub_loop_counter != 1) {
  ------------------
  |  Branch (749:13): [True: 26.4k, False: 63.4k]
  ------------------
  750|  26.4k|          s->space = 32;
  751|  26.4k|          s->repeat = 0;  /* num_codes */
  752|  26.4k|          memset(&s->code_length_histo[0], 0, sizeof(s->code_length_histo[0]) *
  753|  26.4k|              (BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH + 1));
  ------------------
  |  |   34|  26.4k|#define BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH 5
  ------------------
  754|  26.4k|          memset(&s->code_length_code_lengths[0], 0,
  755|  26.4k|              sizeof(s->code_length_code_lengths));
  756|  26.4k|          s->substate_huffman = BROTLI_STATE_HUFFMAN_COMPLEX;
  757|  26.4k|          continue;
  758|  26.4k|        }
  759|       |        /* No break, transit to the next state. */
  760|       |
  761|  63.4k|      case BROTLI_STATE_HUFFMAN_SIMPLE_SIZE:
  ------------------
  |  Branch (761:7): [True: 0, False: 116k]
  ------------------
  762|       |        /* Read symbols, codes & code lengths directly. */
  763|  63.4k|        if (!BrotliSafeReadBits(br, 2, &s->symbol)) {  /* num_symbols */
  ------------------
  |  Branch (763:13): [True: 21, False: 63.4k]
  ------------------
  764|     21|          s->substate_huffman = BROTLI_STATE_HUFFMAN_SIMPLE_SIZE;
  765|     21|          return BROTLI_DECODER_NEEDS_MORE_INPUT;
  766|     21|        }
  767|  63.4k|        s->sub_loop_counter = 0;
  768|       |        /* No break, transit to the next state. */
  769|       |
  770|  63.4k|      case BROTLI_STATE_HUFFMAN_SIMPLE_READ: {
  ------------------
  |  Branch (770:7): [True: 0, False: 116k]
  ------------------
  771|  63.4k|        BrotliDecoderErrorCode result =
  772|  63.4k|            ReadSimpleHuffmanSymbols(alphabet_size, max_symbol, s);
  773|  63.4k|        if (result != BROTLI_DECODER_SUCCESS) {
  ------------------
  |  Branch (773:13): [True: 76, False: 63.3k]
  ------------------
  774|     76|          return result;
  775|     76|        }
  776|       |        /* No break, transit to the next state. */
  777|  63.4k|      }
  778|       |
  779|  63.3k|      case BROTLI_STATE_HUFFMAN_SIMPLE_BUILD: {
  ------------------
  |  Branch (779:7): [True: 0, False: 116k]
  ------------------
  780|  63.3k|        uint32_t table_size;
  781|  63.3k|        if (s->symbol == 3) {
  ------------------
  |  Branch (781:13): [True: 1.87k, False: 61.4k]
  ------------------
  782|  1.87k|          uint32_t bits;
  783|  1.87k|          if (!BrotliSafeReadBits(br, 1, &bits)) {
  ------------------
  |  Branch (783:15): [True: 6, False: 1.86k]
  ------------------
  784|      6|            s->substate_huffman = BROTLI_STATE_HUFFMAN_SIMPLE_BUILD;
  785|      6|            return BROTLI_DECODER_NEEDS_MORE_INPUT;
  786|      6|          }
  787|  1.86k|          s->symbol += bits;
  788|  1.86k|        }
  789|  63.3k|        BROTLI_LOG_UINT(s->symbol);
  790|  63.3k|        table_size = BrotliBuildSimpleHuffmanTable(
  791|  63.3k|            table, HUFFMAN_TABLE_BITS, s->symbols_lists_array, s->symbol);
  ------------------
  |  |   39|  63.3k|#define HUFFMAN_TABLE_BITS 8U
  ------------------
  792|  63.3k|        if (opt_table_size) {
  ------------------
  |  Branch (792:13): [True: 43.2k, False: 20.0k]
  ------------------
  793|  43.2k|          *opt_table_size = table_size;
  794|  43.2k|        }
  795|  63.3k|        s->substate_huffman = BROTLI_STATE_HUFFMAN_NONE;
  796|  63.3k|        return BROTLI_DECODER_SUCCESS;
  797|  63.3k|      }
  798|       |
  799|       |      /* Decode Huffman-coded code lengths. */
  800|  26.4k|      case BROTLI_STATE_HUFFMAN_COMPLEX: {
  ------------------
  |  Branch (800:7): [True: 26.4k, False: 89.9k]
  ------------------
  801|  26.4k|        uint32_t i;
  802|  26.4k|        BrotliDecoderErrorCode result = ReadCodeLengthCodeLengths(s);
  803|  26.4k|        if (result != BROTLI_DECODER_SUCCESS) {
  ------------------
  |  Branch (803:13): [True: 268, False: 26.1k]
  ------------------
  804|    268|          return result;
  805|    268|        }
  806|  26.1k|        BrotliBuildCodeLengthsHuffmanTable(s->table,
  807|  26.1k|                                           s->code_length_code_lengths,
  808|  26.1k|                                           s->code_length_histo);
  809|  26.1k|        memset(&s->code_length_histo[0], 0, sizeof(s->code_length_histo));
  810|   444k|        for (i = 0; i <= BROTLI_HUFFMAN_MAX_CODE_LENGTH; ++i) {
  ------------------
  |  |   19|   444k|#define BROTLI_HUFFMAN_MAX_CODE_LENGTH 15
  ------------------
  |  Branch (810:21): [True: 418k, False: 26.1k]
  ------------------
  811|   418k|          s->next_symbol[i] = (int)i - (BROTLI_HUFFMAN_MAX_CODE_LENGTH + 1);
  ------------------
  |  |   19|   418k|#define BROTLI_HUFFMAN_MAX_CODE_LENGTH 15
  ------------------
  812|   418k|          s->symbol_lists[s->next_symbol[i]] = 0xFFFF;
  813|   418k|        }
  814|       |
  815|  26.1k|        s->symbol = 0;
  816|  26.1k|        s->prev_code_len = BROTLI_INITIAL_REPEATED_CODE_LENGTH;
  ------------------
  |  |   29|  26.1k|#define BROTLI_INITIAL_REPEATED_CODE_LENGTH 8
  ------------------
  817|  26.1k|        s->repeat = 0;
  818|  26.1k|        s->repeat_code_len = 0;
  819|  26.1k|        s->space = 32768;
  820|  26.1k|        s->substate_huffman = BROTLI_STATE_HUFFMAN_LENGTH_SYMBOLS;
  821|       |        /* No break, transit to the next state. */
  822|  26.1k|      }
  823|       |
  824|  26.1k|      case BROTLI_STATE_HUFFMAN_LENGTH_SYMBOLS: {
  ------------------
  |  Branch (824:7): [True: 0, False: 116k]
  ------------------
  825|  26.1k|        uint32_t table_size;
  826|  26.1k|        BrotliDecoderErrorCode result = ReadSymbolCodeLengths(max_symbol, s);
  827|  26.1k|        if (result == BROTLI_DECODER_NEEDS_MORE_INPUT) {
  ------------------
  |  Branch (827:13): [True: 519, False: 25.6k]
  ------------------
  828|    519|          result = SafeReadSymbolCodeLengths(max_symbol, s);
  829|    519|        }
  830|  26.1k|        if (result != BROTLI_DECODER_SUCCESS) {
  ------------------
  |  Branch (830:13): [True: 126, False: 26.0k]
  ------------------
  831|    126|          return result;
  832|    126|        }
  833|       |
  834|  26.0k|        if (s->space != 0) {
  ------------------
  |  Branch (834:13): [True: 191, False: 25.8k]
  ------------------
  835|    191|          BROTLI_LOG(("[ReadHuffmanCode] space = %d\n", s->space));
  836|    191|          return BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE);
  ------------------
  |  |   31|    191|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|    191|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
  837|    191|        }
  838|  25.8k|        table_size = BrotliBuildHuffmanTable(
  839|  25.8k|            table, HUFFMAN_TABLE_BITS, s->symbol_lists, s->code_length_histo);
  ------------------
  |  |   39|  25.8k|#define HUFFMAN_TABLE_BITS 8U
  ------------------
  840|  25.8k|        if (opt_table_size) {
  ------------------
  |  Branch (840:13): [True: 24.0k, False: 1.79k]
  ------------------
  841|  24.0k|          *opt_table_size = table_size;
  842|  24.0k|        }
  843|  25.8k|        s->substate_huffman = BROTLI_STATE_HUFFMAN_NONE;
  844|  25.8k|        return BROTLI_DECODER_SUCCESS;
  845|  26.0k|      }
  846|       |
  847|      0|      default:
  ------------------
  |  Branch (847:7): [True: 0, False: 116k]
  ------------------
  848|      0|        return
  849|      0|            BROTLI_FAILURE(BROTLI_DECODER_ERROR_UNREACHABLE);
  ------------------
  |  |   31|      0|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|      0|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
  850|   116k|    }
  851|   116k|  }
  852|  89.9k|}
decode.c:ReadSimpleHuffmanSymbols:
  468|  63.4k|    uint32_t alphabet_size, uint32_t max_symbol, BrotliDecoderState* s) {
  469|       |  /* max_bits == 1..11; symbol == 0..3; 1..44 bits will be read. */
  470|  63.4k|  BrotliBitReader* br = &s->br;
  471|  63.4k|  uint32_t max_bits = Log2Floor(alphabet_size - 1);
  472|  63.4k|  uint32_t i = s->sub_loop_counter;
  473|  63.4k|  uint32_t num_symbols = s->symbol;
  474|   174k|  while (i <= num_symbols) {
  ------------------
  |  Branch (474:10): [True: 110k, False: 63.3k]
  ------------------
  475|   110k|    uint32_t v;
  476|   110k|    if (BROTLI_PREDICT_FALSE(!BrotliSafeReadBits(br, max_bits, &v))) {
  ------------------
  |  |  318|   110k|#define BROTLI_PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (318:33): [True: 43, False: 110k]
  |  |  ------------------
  ------------------
  477|     43|      s->sub_loop_counter = i;
  478|     43|      s->substate_huffman = BROTLI_STATE_HUFFMAN_SIMPLE_READ;
  479|     43|      return BROTLI_DECODER_NEEDS_MORE_INPUT;
  480|     43|    }
  481|   110k|    if (v >= max_symbol) {
  ------------------
  |  Branch (481:9): [True: 20, False: 110k]
  ------------------
  482|     20|      return
  483|     20|          BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET);
  ------------------
  |  |   31|     20|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|     20|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
  484|     20|    }
  485|   110k|    s->symbols_lists_array[i] = (uint16_t)v;
  486|   110k|    BROTLI_LOG_UINT(s->symbols_lists_array[i]);
  487|   110k|    ++i;
  488|   110k|  }
  489|       |
  490|   110k|  for (i = 0; i < num_symbols; ++i) {
  ------------------
  |  Branch (490:15): [True: 47.2k, False: 63.3k]
  ------------------
  491|  47.2k|    uint32_t k = i + 1;
  492|   114k|    for (; k <= num_symbols; ++k) {
  ------------------
  |  Branch (492:12): [True: 67.4k, False: 47.2k]
  ------------------
  493|  67.4k|      if (s->symbols_lists_array[i] == s->symbols_lists_array[k]) {
  ------------------
  |  Branch (493:11): [True: 13, False: 67.4k]
  ------------------
  494|     13|        return BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME);
  ------------------
  |  |   31|     13|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|     13|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
  495|     13|      }
  496|  67.4k|    }
  497|  47.2k|  }
  498|       |
  499|  63.3k|  return BROTLI_DECODER_SUCCESS;
  500|  63.3k|}
decode.c:Log2Floor:
  455|  63.4k|static BROTLI_INLINE uint32_t Log2Floor(uint32_t x) {
  456|  63.4k|  uint32_t result = 0;
  457|   493k|  while (x) {
  ------------------
  |  Branch (457:10): [True: 430k, False: 63.4k]
  ------------------
  458|   430k|    x >>= 1;
  459|   430k|    ++result;
  460|   430k|  }
  461|  63.4k|  return result;
  462|  63.4k|}
decode.c:ReadCodeLengthCodeLengths:
  675|  26.4k|static BrotliDecoderErrorCode ReadCodeLengthCodeLengths(BrotliDecoderState* s) {
  676|  26.4k|  BrotliBitReader* br = &s->br;
  677|  26.4k|  uint32_t num_codes = s->repeat;
  678|  26.4k|  unsigned space = s->space;
  679|  26.4k|  uint32_t i = s->sub_loop_counter;
  680|   222k|  for (; i < BROTLI_CODE_LENGTH_CODES; ++i) {
  ------------------
  |  |   27|   222k|#define BROTLI_CODE_LENGTH_CODES (BROTLI_REPEAT_ZERO_CODE_LENGTH + 1)
  |  |  ------------------
  |  |  |  |   26|   222k|#define BROTLI_REPEAT_ZERO_CODE_LENGTH 17
  |  |  ------------------
  ------------------
  |  Branch (680:10): [True: 221k, False: 562]
  ------------------
  681|   221k|    const uint8_t code_len_idx = kCodeLengthCodeOrder[i];
  682|   221k|    uint32_t ix;
  683|   221k|    uint32_t v;
  684|   221k|    if (BROTLI_PREDICT_FALSE(!BrotliSafeGetBits(br, 4, &ix))) {
  ------------------
  |  |  318|   221k|#define BROTLI_PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (318:33): [True: 256, False: 221k]
  |  |  ------------------
  ------------------
  685|    256|      uint32_t available_bits = BrotliGetAvailableBits(br);
  686|    256|      if (available_bits != 0) {
  ------------------
  |  Branch (686:11): [True: 192, False: 64]
  ------------------
  687|    192|        ix = BrotliGetBitsUnmasked(br) & 0xF;
  688|    192|      } else {
  689|     64|        ix = 0;
  690|     64|      }
  691|    256|      if (kCodeLengthPrefixLength[ix] > available_bits) {
  ------------------
  |  Branch (691:11): [True: 141, False: 115]
  ------------------
  692|    141|        s->sub_loop_counter = i;
  693|    141|        s->repeat = num_codes;
  694|    141|        s->space = space;
  695|    141|        s->substate_huffman = BROTLI_STATE_HUFFMAN_COMPLEX;
  696|    141|        return BROTLI_DECODER_NEEDS_MORE_INPUT;
  697|    141|      }
  698|    256|    }
  699|   221k|    v = kCodeLengthPrefixValue[ix];
  700|   221k|    BrotliDropBits(br, kCodeLengthPrefixLength[ix]);
  701|   221k|    s->code_length_code_lengths[code_len_idx] = (uint8_t)v;
  702|   221k|    BROTLI_LOG_ARRAY_INDEX(s->code_length_code_lengths, code_len_idx);
  703|   221k|    if (v != 0) {
  ------------------
  |  Branch (703:9): [True: 179k, False: 42.6k]
  ------------------
  704|   179k|      space = space - (32U >> v);
  705|   179k|      ++num_codes;
  706|   179k|      ++s->code_length_histo[v];
  707|   179k|      if (space - 1U >= 32U) {
  ------------------
  |  Branch (707:11): [True: 25.7k, False: 153k]
  ------------------
  708|       |        /* space is 0 or wrapped around. */
  709|  25.7k|        break;
  710|  25.7k|      }
  711|   179k|    }
  712|   221k|  }
  713|  26.2k|  if (!(num_codes == 1 || space == 0)) {
  ------------------
  |  Branch (713:9): [True: 483, False: 25.7k]
  |  Branch (713:27): [True: 25.6k, False: 127]
  ------------------
  714|    127|    return BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_CL_SPACE);
  ------------------
  |  |   31|    127|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|    127|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
  715|    127|  }
  716|  26.1k|  return BROTLI_DECODER_SUCCESS;
  717|  26.2k|}
decode.c:ReadSymbolCodeLengths:
  583|  26.1k|    uint32_t alphabet_size, BrotliDecoderState* s) {
  584|  26.1k|  BrotliBitReader* br = &s->br;
  585|  26.1k|  uint32_t symbol = s->symbol;
  586|  26.1k|  uint32_t repeat = s->repeat;
  587|  26.1k|  uint32_t space = s->space;
  588|  26.1k|  uint32_t prev_code_len = s->prev_code_len;
  589|  26.1k|  uint32_t repeat_code_len = s->repeat_code_len;
  590|  26.1k|  uint16_t* symbol_lists = s->symbol_lists;
  591|  26.1k|  uint16_t* code_length_histo = s->code_length_histo;
  592|  26.1k|  int* next_symbol = s->next_symbol;
  593|  26.1k|  if (!BrotliWarmupBitReader(br)) {
  ------------------
  |  Branch (593:7): [True: 21, False: 26.1k]
  ------------------
  594|     21|    return BROTLI_DECODER_NEEDS_MORE_INPUT;
  595|     21|  }
  596|  1.82M|  while (symbol < alphabet_size && space > 0) {
  ------------------
  |  Branch (596:10): [True: 1.82M, False: 3.40k]
  |  Branch (596:36): [True: 1.79M, False: 22.2k]
  ------------------
  597|  1.79M|    const HuffmanCode* p = s->table;
  598|  1.79M|    uint32_t code_len;
  599|  1.79M|    if (!BrotliCheckInputAmount(br, BROTLI_SHORT_FILL_BIT_WINDOW_READ)) {
  ------------------
  |  |   21|  1.79M|#define BROTLI_SHORT_FILL_BIT_WINDOW_READ (sizeof(brotli_reg_t) >> 1)
  ------------------
  |  Branch (599:9): [True: 498, False: 1.79M]
  ------------------
  600|    498|      s->symbol = symbol;
  601|    498|      s->repeat = repeat;
  602|    498|      s->prev_code_len = prev_code_len;
  603|    498|      s->repeat_code_len = repeat_code_len;
  604|    498|      s->space = space;
  605|    498|      return BROTLI_DECODER_NEEDS_MORE_INPUT;
  606|    498|    }
  607|  1.79M|    BrotliFillBitWindow16(br);
  608|  1.79M|    p += BrotliGetBitsUnmasked(br) &
  609|  1.79M|        BitMask(BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH);
  ------------------
  |  |   34|  1.79M|#define BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH 5
  ------------------
  610|  1.79M|    BrotliDropBits(br, p->bits);  /* Use 1..5 bits. */
  611|  1.79M|    code_len = p->value;  /* code_len == 0..17 */
  612|  1.79M|    if (code_len < BROTLI_REPEAT_PREVIOUS_CODE_LENGTH) {
  ------------------
  |  |   25|  1.79M|#define BROTLI_REPEAT_PREVIOUS_CODE_LENGTH 16
  ------------------
  |  Branch (612:9): [True: 1.55M, False: 240k]
  ------------------
  613|  1.55M|      ProcessSingleCodeLength(code_len, &symbol, &repeat, &space,
  614|  1.55M|          &prev_code_len, symbol_lists, code_length_histo, next_symbol);
  615|  1.55M|    } else {  /* code_len == 16..17, extra_bits == 2..3 */
  616|   240k|      uint32_t extra_bits =
  617|   240k|          (code_len == BROTLI_REPEAT_PREVIOUS_CODE_LENGTH) ? 2 : 3;
  ------------------
  |  |   25|   240k|#define BROTLI_REPEAT_PREVIOUS_CODE_LENGTH 16
  ------------------
  |  Branch (617:11): [True: 138k, False: 102k]
  ------------------
  618|   240k|      uint32_t repeat_delta =
  619|   240k|          (uint32_t)BrotliGetBitsUnmasked(br) & BitMask(extra_bits);
  620|   240k|      BrotliDropBits(br, extra_bits);
  621|   240k|      ProcessRepeatedCodeLength(code_len, repeat_delta, alphabet_size,
  622|   240k|          &symbol, &repeat, &space, &prev_code_len, &repeat_code_len,
  623|   240k|          symbol_lists, code_length_histo, next_symbol);
  624|   240k|    }
  625|  1.79M|  }
  626|  25.6k|  s->space = space;
  627|  25.6k|  return BROTLI_DECODER_SUCCESS;
  628|  26.1k|}
decode.c:ProcessSingleCodeLength:
  511|  1.57M|    uint16_t* code_length_histo, int* next_symbol) {
  512|  1.57M|  *repeat = 0;
  513|  1.57M|  if (code_len != 0) {  /* code_len == 1..15 */
  ------------------
  |  Branch (513:7): [True: 860k, False: 714k]
  ------------------
  514|   860k|    symbol_lists[next_symbol[code_len]] = (uint16_t)(*symbol);
  515|   860k|    next_symbol[code_len] = (int)(*symbol);
  516|   860k|    *prev_code_len = code_len;
  517|   860k|    *space -= 32768U >> code_len;
  518|   860k|    code_length_histo[code_len]++;
  519|   860k|    BROTLI_LOG(("[ReadHuffmanCode] code_length[%d] = %d\n", *symbol, code_len));
  520|   860k|  }
  521|  1.57M|  (*symbol)++;
  522|  1.57M|}
decode.c:ProcessRepeatedCodeLength:
  538|   241k|    uint16_t* code_length_histo, int* next_symbol) {
  539|   241k|  uint32_t old_repeat;
  540|   241k|  uint32_t extra_bits = 3;  /* for BROTLI_REPEAT_ZERO_CODE_LENGTH */
  541|   241k|  uint32_t new_len = 0;  /* for BROTLI_REPEAT_ZERO_CODE_LENGTH */
  542|   241k|  if (code_len == BROTLI_REPEAT_PREVIOUS_CODE_LENGTH) {
  ------------------
  |  |   25|   241k|#define BROTLI_REPEAT_PREVIOUS_CODE_LENGTH 16
  ------------------
  |  Branch (542:7): [True: 139k, False: 102k]
  ------------------
  543|   139k|    new_len = *prev_code_len;
  544|   139k|    extra_bits = 2;
  545|   139k|  }
  546|   241k|  if (*repeat_code_len != new_len) {
  ------------------
  |  Branch (546:7): [True: 97.5k, False: 144k]
  ------------------
  547|  97.5k|    *repeat = 0;
  548|  97.5k|    *repeat_code_len = new_len;
  549|  97.5k|  }
  550|   241k|  old_repeat = *repeat;
  551|   241k|  if (*repeat > 0) {
  ------------------
  |  Branch (551:7): [True: 74.2k, False: 167k]
  ------------------
  552|  74.2k|    *repeat -= 2;
  553|  74.2k|    *repeat <<= extra_bits;
  554|  74.2k|  }
  555|   241k|  *repeat += repeat_delta + 3U;
  556|   241k|  repeat_delta = *repeat - old_repeat;
  557|   241k|  if (*symbol + repeat_delta > alphabet_size) {
  ------------------
  |  Branch (557:7): [True: 75, False: 241k]
  ------------------
  558|     75|    BROTLI_DUMP();
  ------------------
  |  |  352|     75|#define BROTLI_DUMP() (void)(0)
  ------------------
  559|     75|    *symbol = alphabet_size;
  560|     75|    *space = 0xFFFFF;
  561|     75|    return;
  562|     75|  }
  563|   241k|  BROTLI_LOG(("[ReadHuffmanCode] code_length[%d..%d] = %d\n",
  564|   241k|              *symbol, *symbol + repeat_delta - 1, *repeat_code_len));
  565|   241k|  if (*repeat_code_len != 0) {
  ------------------
  |  Branch (565:7): [True: 139k, False: 102k]
  ------------------
  566|   139k|    unsigned last = *symbol + repeat_delta;
  567|   139k|    int next = next_symbol[*repeat_code_len];
  568|   915k|    do {
  569|   915k|      symbol_lists[next] = (uint16_t)*symbol;
  570|   915k|      next = (int)*symbol;
  571|   915k|    } while (++(*symbol) != last);
  ------------------
  |  Branch (571:14): [True: 776k, False: 139k]
  ------------------
  572|   139k|    next_symbol[*repeat_code_len] = next;
  573|   139k|    *space -= repeat_delta << (15 - *repeat_code_len);
  574|   139k|    code_length_histo[*repeat_code_len] =
  575|   139k|        (uint16_t)(code_length_histo[*repeat_code_len] + repeat_delta);
  576|   139k|  } else {
  577|   102k|    *symbol += repeat_delta;
  578|   102k|  }
  579|   241k|}
decode.c:SafeReadSymbolCodeLengths:
  631|    519|    uint32_t alphabet_size, BrotliDecoderState* s) {
  632|    519|  BrotliBitReader* br = &s->br;
  633|    519|  BROTLI_BOOL get_byte = BROTLI_FALSE;
  ------------------
  |  |   49|    519|#define BROTLI_BOOL int
  ------------------
                BROTLI_BOOL get_byte = BROTLI_FALSE;
  ------------------
  |  |   53|    519|#define BROTLI_FALSE 0
  ------------------
  634|  18.1k|  while (s->symbol < alphabet_size && s->space > 0) {
  ------------------
  |  Branch (634:10): [True: 18.0k, False: 143]
  |  Branch (634:39): [True: 17.8k, False: 250]
  ------------------
  635|  17.8k|    const HuffmanCode* p = s->table;
  636|  17.8k|    uint32_t code_len;
  637|  17.8k|    uint32_t available_bits;
  638|  17.8k|    uint32_t bits = 0;
  639|  17.8k|    if (get_byte && !BrotliPullByte(br)) return BROTLI_DECODER_NEEDS_MORE_INPUT;
  ------------------
  |  Branch (639:9): [True: 379, False: 17.4k]
  |  Branch (639:21): [True: 126, False: 253]
  ------------------
  640|  17.6k|    get_byte = BROTLI_FALSE;
  ------------------
  |  |   53|  17.6k|#define BROTLI_FALSE 0
  ------------------
  641|  17.6k|    available_bits = BrotliGetAvailableBits(br);
  642|  17.6k|    if (available_bits != 0) {
  ------------------
  |  Branch (642:9): [True: 15.7k, False: 1.96k]
  ------------------
  643|  15.7k|      bits = (uint32_t)BrotliGetBitsUnmasked(br);
  644|  15.7k|    }
  645|  17.6k|    p += bits & BitMask(BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH);
  ------------------
  |  |   34|  17.6k|#define BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH 5
  ------------------
  646|  17.6k|    if (p->bits > available_bits) {
  ------------------
  |  Branch (646:9): [True: 281, False: 17.3k]
  ------------------
  647|    281|      get_byte = BROTLI_TRUE;
  ------------------
  |  |   51|    281|#define BROTLI_TRUE 1
  ------------------
  648|    281|      continue;
  649|    281|    }
  650|  17.3k|    code_len = p->value;  /* code_len == 0..17 */
  651|  17.3k|    if (code_len < BROTLI_REPEAT_PREVIOUS_CODE_LENGTH) {
  ------------------
  |  |   25|  17.3k|#define BROTLI_REPEAT_PREVIOUS_CODE_LENGTH 16
  ------------------
  |  Branch (651:9): [True: 16.3k, False: 1.01k]
  ------------------
  652|  16.3k|      BrotliDropBits(br, p->bits);
  653|  16.3k|      ProcessSingleCodeLength(code_len, &s->symbol, &s->repeat, &s->space,
  654|  16.3k|          &s->prev_code_len, s->symbol_lists, s->code_length_histo,
  655|  16.3k|          s->next_symbol);
  656|  16.3k|    } else {  /* code_len == 16..17, extra_bits == 2..3 */
  657|  1.01k|      uint32_t extra_bits = code_len - 14U;
  658|  1.01k|      uint32_t repeat_delta = (bits >> p->bits) & BitMask(extra_bits);
  659|  1.01k|      if (available_bits < p->bits + extra_bits) {
  ------------------
  |  Branch (659:11): [True: 98, False: 920]
  ------------------
  660|     98|        get_byte = BROTLI_TRUE;
  ------------------
  |  |   51|     98|#define BROTLI_TRUE 1
  ------------------
  661|     98|        continue;
  662|     98|      }
  663|    920|      BrotliDropBits(br, p->bits + extra_bits);
  664|    920|      ProcessRepeatedCodeLength(code_len, repeat_delta, alphabet_size,
  665|    920|          &s->symbol, &s->repeat, &s->space, &s->prev_code_len,
  666|    920|          &s->repeat_code_len, s->symbol_lists, s->code_length_histo,
  667|    920|          s->next_symbol);
  668|    920|    }
  669|  17.3k|  }
  670|    393|  return BROTLI_DECODER_SUCCESS;
  671|    519|}
decode.c:SafeReadBlockLength:
  868|  26.5k|    BrotliBitReader* br) {
  869|  26.5k|  uint32_t index;
  870|  26.5k|  if (s->substate_read_block_length == BROTLI_STATE_READ_BLOCK_LENGTH_NONE) {
  ------------------
  |  Branch (870:7): [True: 26.5k, False: 0]
  ------------------
  871|  26.5k|    if (!SafeReadSymbol(table, br, &index)) {
  ------------------
  |  Branch (871:9): [True: 42, False: 26.5k]
  ------------------
  872|     42|      return BROTLI_FALSE;
  ------------------
  |  |   53|     42|#define BROTLI_FALSE 0
  ------------------
  873|     42|    }
  874|  26.5k|  } else {
  875|      0|    index = s->block_length_index;
  876|      0|  }
  877|  26.5k|  {
  878|  26.5k|    uint32_t bits;
  879|  26.5k|    uint32_t nbits = kBlockLengthPrefixCode[index].nbits;  /* nbits == 2..24 */
  880|  26.5k|    if (!BrotliSafeReadBits(br, nbits, &bits)) {
  ------------------
  |  Branch (880:9): [True: 211, False: 26.3k]
  ------------------
  881|    211|      s->block_length_index = index;
  882|    211|      s->substate_read_block_length = BROTLI_STATE_READ_BLOCK_LENGTH_SUFFIX;
  883|    211|      return BROTLI_FALSE;
  ------------------
  |  |   53|    211|#define BROTLI_FALSE 0
  ------------------
  884|    211|    }
  885|  26.3k|    *result = kBlockLengthPrefixCode[index].offset + bits;
  886|  26.3k|    s->substate_read_block_length = BROTLI_STATE_READ_BLOCK_LENGTH_NONE;
  887|  26.3k|    return BROTLI_TRUE;
  ------------------
  |  |   51|  26.3k|#define BROTLI_TRUE 1
  ------------------
  888|  26.5k|  }
  889|  26.5k|}
decode.c:SafeReadSymbol:
  410|   915M|    const HuffmanCode* table, BrotliBitReader* br, uint32_t* result) {
  411|   915M|  uint32_t val;
  412|   915M|  if (BROTLI_PREDICT_TRUE(BrotliSafeGetBits(br, 15, &val))) {
  ------------------
  |  |  317|   915M|#define BROTLI_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
  |  |  ------------------
  |  |  |  Branch (317:32): [True: 857M, False: 57.6M]
  |  |  ------------------
  ------------------
  413|   857M|    *result = DecodeSymbol(val, table, br);
  414|   857M|    return BROTLI_TRUE;
  ------------------
  |  |   51|   857M|#define BROTLI_TRUE 1
  ------------------
  415|   857M|  }
  416|  57.6M|  return SafeDecodeSymbol(table, br, result);
  417|   915M|}
decode.c:DecodeSymbol:
  349|   921M|                                           BrotliBitReader* br) {
  350|   921M|  table += bits & HUFFMAN_TABLE_MASK;
  ------------------
  |  |   40|   921M|#define HUFFMAN_TABLE_MASK 0xFF
  ------------------
  351|   921M|  if (table->bits > HUFFMAN_TABLE_BITS) {
  ------------------
  |  |   39|   921M|#define HUFFMAN_TABLE_BITS 8U
  ------------------
  |  Branch (351:7): [True: 647k, False: 920M]
  ------------------
  352|   647k|    uint32_t nbits = table->bits - HUFFMAN_TABLE_BITS;
  ------------------
  |  |   39|   647k|#define HUFFMAN_TABLE_BITS 8U
  ------------------
  353|   647k|    BrotliDropBits(br, HUFFMAN_TABLE_BITS);
  ------------------
  |  |   39|   647k|#define HUFFMAN_TABLE_BITS 8U
  ------------------
  354|   647k|    table += table->value;
  355|   647k|    table += (bits >> HUFFMAN_TABLE_BITS) & BitMask(nbits);
  ------------------
  |  |   39|   647k|#define HUFFMAN_TABLE_BITS 8U
  ------------------
  356|   647k|  }
  357|   921M|  BrotliDropBits(br, table->bits);
  358|   921M|  return table->value;
  359|   921M|}
decode.c:SafeDecodeSymbol:
  371|  57.6M|    const HuffmanCode* table, BrotliBitReader* br, uint32_t* result) {
  372|  57.6M|  uint32_t val;
  373|  57.6M|  uint32_t available_bits = BrotliGetAvailableBits(br);
  374|  57.6M|  if (available_bits == 0) {
  ------------------
  |  Branch (374:7): [True: 6.74M, False: 50.9M]
  ------------------
  375|  6.74M|    if (table->bits == 0) {
  ------------------
  |  Branch (375:9): [True: 6.74M, False: 162]
  ------------------
  376|  6.74M|      *result = table->value;
  377|  6.74M|      return BROTLI_TRUE;
  ------------------
  |  |   51|  6.74M|#define BROTLI_TRUE 1
  ------------------
  378|  6.74M|    }
  379|    162|    return BROTLI_FALSE;  /* No valid bits at all. */
  ------------------
  |  |   53|    162|#define BROTLI_FALSE 0
  ------------------
  380|  6.74M|  }
  381|  50.9M|  val = (uint32_t)BrotliGetBitsUnmasked(br);
  382|  50.9M|  table += val & HUFFMAN_TABLE_MASK;
  ------------------
  |  |   40|  50.9M|#define HUFFMAN_TABLE_MASK 0xFF
  ------------------
  383|  50.9M|  if (table->bits <= HUFFMAN_TABLE_BITS) {
  ------------------
  |  |   39|  50.9M|#define HUFFMAN_TABLE_BITS 8U
  ------------------
  |  Branch (383:7): [True: 50.9M, False: 27]
  ------------------
  384|  50.9M|    if (table->bits <= available_bits) {
  ------------------
  |  Branch (384:9): [True: 50.9M, False: 101]
  ------------------
  385|  50.9M|      BrotliDropBits(br, table->bits);
  386|  50.9M|      *result = table->value;
  387|  50.9M|      return BROTLI_TRUE;
  ------------------
  |  |   51|  50.9M|#define BROTLI_TRUE 1
  ------------------
  388|  50.9M|    } else {
  389|    101|      return BROTLI_FALSE;  /* Not enough bits for the first level. */
  ------------------
  |  |   53|    101|#define BROTLI_FALSE 0
  ------------------
  390|    101|    }
  391|  50.9M|  }
  392|     27|  if (available_bits <= HUFFMAN_TABLE_BITS) {
  ------------------
  |  |   39|     27|#define HUFFMAN_TABLE_BITS 8U
  ------------------
  |  Branch (392:7): [True: 14, False: 13]
  ------------------
  393|     14|    return BROTLI_FALSE;  /* Not enough bits to move to the second level. */
  ------------------
  |  |   53|     14|#define BROTLI_FALSE 0
  ------------------
  394|     14|  }
  395|       |
  396|       |  /* Speculatively drop HUFFMAN_TABLE_BITS. */
  397|     13|  val = (val & BitMask(table->bits)) >> HUFFMAN_TABLE_BITS;
  ------------------
  |  |   39|     13|#define HUFFMAN_TABLE_BITS 8U
  ------------------
  398|     13|  available_bits -= HUFFMAN_TABLE_BITS;
  ------------------
  |  |   39|     13|#define HUFFMAN_TABLE_BITS 8U
  ------------------
  399|     13|  table += table->value + val;
  400|     13|  if (available_bits < table->bits) {
  ------------------
  |  Branch (400:7): [True: 1, False: 12]
  ------------------
  401|      1|    return BROTLI_FALSE;  /* Not enough bits for the second level. */
  ------------------
  |  |   53|      1|#define BROTLI_FALSE 0
  ------------------
  402|      1|  }
  403|       |
  404|     12|  BrotliDropBits(br, HUFFMAN_TABLE_BITS + table->bits);
  ------------------
  |  |   39|     12|#define HUFFMAN_TABLE_BITS 8U
  ------------------
  405|     12|  *result = table->value;
  406|     12|  return BROTLI_TRUE;
  ------------------
  |  |   51|     12|#define BROTLI_TRUE 1
  ------------------
  407|     13|}
decode.c:ReadContextModes:
 1432|  16.5k|static BrotliDecoderErrorCode ReadContextModes(BrotliDecoderState* s) {
 1433|  16.5k|  BrotliBitReader* br = &s->br;
 1434|  16.5k|  int i = s->loop_counter;
 1435|       |
 1436|  68.4k|  while (i < (int)s->num_block_types[0]) {
  ------------------
  |  Branch (1436:10): [True: 51.9k, False: 16.5k]
  ------------------
 1437|  51.9k|    uint32_t bits;
 1438|  51.9k|    if (!BrotliSafeReadBits(br, 2, &bits)) {
  ------------------
  |  Branch (1438:9): [True: 20, False: 51.8k]
  ------------------
 1439|     20|      s->loop_counter = i;
 1440|     20|      return BROTLI_DECODER_NEEDS_MORE_INPUT;
 1441|     20|    }
 1442|  51.8k|    s->context_modes[i] = (uint8_t)bits;
 1443|  51.8k|    BROTLI_LOG_ARRAY_INDEX(s->context_modes, i);
 1444|  51.8k|    i++;
 1445|  51.8k|  }
 1446|  16.5k|  return BROTLI_DECODER_SUCCESS;
 1447|  16.5k|}
decode.c:DecodeContextMap:
  975|  32.9k|                                               BrotliDecoderState* s) {
  976|  32.9k|  BrotliBitReader* br = &s->br;
  977|  32.9k|  BrotliDecoderErrorCode result = BROTLI_DECODER_SUCCESS;
  978|       |
  979|  32.9k|  switch ((int)s->substate_context_map) {
  980|  32.9k|    case BROTLI_STATE_CONTEXT_MAP_NONE:
  ------------------
  |  Branch (980:5): [True: 32.9k, False: 0]
  ------------------
  981|  32.9k|      result = DecodeVarLenUint8(s, br, num_htrees);
  982|  32.9k|      if (result != BROTLI_DECODER_SUCCESS) {
  ------------------
  |  Branch (982:11): [True: 28, False: 32.8k]
  ------------------
  983|     28|        return result;
  984|     28|      }
  985|  32.8k|      (*num_htrees)++;
  986|  32.8k|      s->context_index = 0;
  987|  32.8k|      BROTLI_LOG_UINT(context_map_size);
  988|  32.8k|      BROTLI_LOG_UINT(*num_htrees);
  989|  32.8k|      *context_map_arg =
  990|  32.8k|          (uint8_t*)BROTLI_DECODER_ALLOC(s, (size_t)context_map_size);
  ------------------
  |  |  247|  32.8k|#define BROTLI_DECODER_ALLOC(S, L) S->alloc_func(S->memory_manager_opaque, L)
  ------------------
  991|  32.8k|      if (*context_map_arg == 0) {
  ------------------
  |  Branch (991:11): [True: 0, False: 32.8k]
  ------------------
  992|      0|        return BROTLI_FAILURE(BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP);
  ------------------
  |  |   31|      0|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|      0|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
  993|      0|      }
  994|  32.8k|      if (*num_htrees <= 1) {
  ------------------
  |  Branch (994:11): [True: 31.5k, False: 1.32k]
  ------------------
  995|  31.5k|        memset(*context_map_arg, 0, (size_t)context_map_size);
  996|  31.5k|        return BROTLI_DECODER_SUCCESS;
  997|  31.5k|      }
  998|  1.32k|      s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_READ_PREFIX;
  999|       |      /* No break, continue to next state. */
 1000|       |
 1001|  1.32k|    case BROTLI_STATE_CONTEXT_MAP_READ_PREFIX: {
  ------------------
  |  Branch (1001:5): [True: 0, False: 32.9k]
  ------------------
 1002|  1.32k|      uint32_t bits;
 1003|       |      /* In next stage ReadHuffmanCode uses at least 4 bits, so it is safe
 1004|       |         to peek 4 bits ahead. */
 1005|  1.32k|      if (!BrotliSafeGetBits(br, 5, &bits)) {
  ------------------
  |  Branch (1005:11): [True: 11, False: 1.31k]
  ------------------
 1006|     11|        return BROTLI_DECODER_NEEDS_MORE_INPUT;
 1007|     11|      }
 1008|  1.31k|      if ((bits & 1) != 0) { /* Use RLE for zeros. */
  ------------------
  |  Branch (1008:11): [True: 978, False: 334]
  ------------------
 1009|    978|        s->max_run_length_prefix = (bits >> 1) + 1;
 1010|    978|        BrotliDropBits(br, 5);
 1011|    978|      } else {
 1012|    334|        s->max_run_length_prefix = 0;
 1013|    334|        BrotliDropBits(br, 1);
 1014|    334|      }
 1015|  1.31k|      BROTLI_LOG_UINT(s->max_run_length_prefix);
 1016|  1.31k|      s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_HUFFMAN;
 1017|       |      /* No break, continue to next state. */
 1018|  1.31k|    }
 1019|       |
 1020|  1.31k|    case BROTLI_STATE_CONTEXT_MAP_HUFFMAN: {
  ------------------
  |  Branch (1020:5): [True: 0, False: 32.9k]
  ------------------
 1021|  1.31k|      uint32_t alphabet_size = *num_htrees + s->max_run_length_prefix;
 1022|  1.31k|      result = ReadHuffmanCode(alphabet_size, alphabet_size,
 1023|  1.31k|                               s->context_map_table, NULL, s);
 1024|  1.31k|      if (result != BROTLI_DECODER_SUCCESS) return result;
  ------------------
  |  Branch (1024:11): [True: 76, False: 1.23k]
  ------------------
 1025|  1.23k|      s->code = 0xFFFF;
 1026|  1.23k|      s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_DECODE;
 1027|       |      /* No break, continue to next state. */
 1028|  1.23k|    }
 1029|       |
 1030|  1.23k|    case BROTLI_STATE_CONTEXT_MAP_DECODE: {
  ------------------
  |  Branch (1030:5): [True: 0, False: 32.9k]
  ------------------
 1031|  1.23k|      uint32_t context_index = s->context_index;
 1032|  1.23k|      uint32_t max_run_length_prefix = s->max_run_length_prefix;
 1033|  1.23k|      uint8_t* context_map = *context_map_arg;
 1034|  1.23k|      uint32_t code = s->code;
 1035|  1.23k|      BROTLI_BOOL skip_preamble = (code != 0xFFFF);
  ------------------
  |  |   49|  1.23k|#define BROTLI_BOOL int
  ------------------
 1036|   259k|      while (context_index < context_map_size || skip_preamble) {
  ------------------
  |  Branch (1036:14): [True: 258k, False: 1.11k]
  |  Branch (1036:50): [True: 0, False: 1.11k]
  ------------------
 1037|   258k|        if (!skip_preamble) {
  ------------------
  |  Branch (1037:13): [True: 258k, False: 0]
  ------------------
 1038|   258k|          if (!SafeReadSymbol(s->context_map_table, br, &code)) {
  ------------------
  |  Branch (1038:15): [True: 37, False: 258k]
  ------------------
 1039|     37|            s->code = 0xFFFF;
 1040|     37|            s->context_index = context_index;
 1041|     37|            return BROTLI_DECODER_NEEDS_MORE_INPUT;
 1042|     37|          }
 1043|   258k|          BROTLI_LOG_UINT(code);
 1044|       |
 1045|   258k|          if (code == 0) {
  ------------------
  |  Branch (1045:15): [True: 27.3k, False: 230k]
  ------------------
 1046|  27.3k|            context_map[context_index++] = 0;
 1047|  27.3k|            continue;
 1048|  27.3k|          }
 1049|   230k|          if (code > max_run_length_prefix) {
  ------------------
  |  Branch (1049:15): [True: 198k, False: 32.7k]
  ------------------
 1050|   198k|            context_map[context_index++] =
 1051|   198k|                (uint8_t)(code - max_run_length_prefix);
 1052|   198k|            continue;
 1053|   198k|          }
 1054|   230k|        } else {
 1055|      0|          skip_preamble = BROTLI_FALSE;
  ------------------
  |  |   53|      0|#define BROTLI_FALSE 0
  ------------------
 1056|      0|        }
 1057|       |        /* RLE sub-stage. */
 1058|  32.7k|        {
 1059|  32.7k|          uint32_t reps;
 1060|  32.7k|          if (!BrotliSafeReadBits(br, code, &reps)) {
  ------------------
  |  Branch (1060:15): [True: 36, False: 32.7k]
  ------------------
 1061|     36|            s->code = code;
 1062|     36|            s->context_index = context_index;
 1063|     36|            return BROTLI_DECODER_NEEDS_MORE_INPUT;
 1064|     36|          }
 1065|  32.7k|          reps += 1U << code;
 1066|  32.7k|          BROTLI_LOG_UINT(reps);
 1067|  32.7k|          if (context_index + reps > context_map_size) {
  ------------------
  |  Branch (1067:15): [True: 49, False: 32.6k]
  ------------------
 1068|     49|            return
 1069|     49|                BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT);
  ------------------
  |  |   31|     49|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|     49|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
 1070|     49|          }
 1071|   472k|          do {
 1072|   472k|            context_map[context_index++] = 0;
 1073|   472k|          } while (--reps);
  ------------------
  |  Branch (1073:20): [True: 440k, False: 32.6k]
  ------------------
 1074|  32.6k|        }
 1075|  32.6k|      }
 1076|       |      /* No break, continue to next state. */
 1077|  1.23k|    }
 1078|       |
 1079|  1.11k|    case BROTLI_STATE_CONTEXT_MAP_TRANSFORM: {
  ------------------
  |  Branch (1079:5): [True: 0, False: 32.9k]
  ------------------
 1080|  1.11k|      uint32_t bits;
 1081|  1.11k|      if (!BrotliSafeReadBits(br, 1, &bits)) {
  ------------------
  |  Branch (1081:11): [True: 7, False: 1.10k]
  ------------------
 1082|      7|        s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_TRANSFORM;
 1083|      7|        return BROTLI_DECODER_NEEDS_MORE_INPUT;
 1084|      7|      }
 1085|  1.10k|      if (bits != 0) {
  ------------------
  |  Branch (1085:11): [True: 983, False: 124]
  ------------------
 1086|    983|        InverseMoveToFrontTransform(*context_map_arg, context_map_size, s);
 1087|    983|      }
 1088|  1.10k|      s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_NONE;
 1089|  1.10k|      return BROTLI_DECODER_SUCCESS;
 1090|  1.11k|    }
 1091|       |
 1092|      0|    default:
  ------------------
  |  Branch (1092:5): [True: 0, False: 32.9k]
  ------------------
 1093|      0|      return
 1094|      0|          BROTLI_FAILURE(BROTLI_DECODER_ERROR_UNREACHABLE);
  ------------------
  |  |   31|      0|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|      0|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
 1095|  32.9k|  }
 1096|  32.9k|}
decode.c:InverseMoveToFrontTransform:
  906|    983|    uint8_t* v, uint32_t v_len, BrotliDecoderState* state) {
  907|       |  /* Reinitialize elements that could have been changed. */
  908|    983|  uint32_t i = 1;
  909|    983|  uint32_t upper_bound = state->mtf_upper_bound;
  910|    983|  uint32_t* mtf = &state->mtf[1];  /* Make mtf[-1] addressable. */
  911|    983|  uint8_t* mtf_u8 = (uint8_t*)mtf;
  912|       |  /* Load endian-aware constant. */
  913|    983|  const uint8_t b0123[4] = {0, 1, 2, 3};
  914|    983|  uint32_t pattern;
  915|    983|  memcpy(&pattern, &b0123, 4);
  916|       |
  917|       |  /* Initialize list using 4 consequent values pattern. */
  918|    983|  mtf[0] = pattern;
  919|  52.2k|  do {
  920|  52.2k|    pattern += 0x04040404;  /* Advance all 4 values by 4. */
  921|  52.2k|    mtf[i] = pattern;
  922|  52.2k|    i++;
  923|  52.2k|  } while (i <= upper_bound);
  ------------------
  |  Branch (923:12): [True: 51.2k, False: 983]
  ------------------
  924|       |
  925|       |  /* Transform the input. */
  926|    983|  upper_bound = 0;
  927|   456k|  for (i = 0; i < v_len; ++i) {
  ------------------
  |  Branch (927:15): [True: 455k, False: 983]
  ------------------
  928|   455k|    int index = v[i];
  929|   455k|    uint8_t value = mtf_u8[index];
  930|   455k|    upper_bound |= v[i];
  931|   455k|    v[i] = value;
  932|   455k|    mtf_u8[-1] = value;
  933|  2.74M|    do {
  934|  2.74M|      index--;
  935|  2.74M|      mtf_u8[index + 1] = mtf_u8[index];
  936|  2.74M|    } while (index >= 0);
  ------------------
  |  Branch (936:14): [True: 2.29M, False: 455k]
  ------------------
  937|   455k|  }
  938|       |  /* Remember amount of elements to be reinitialized. */
  939|    983|  state->mtf_upper_bound = upper_bound >> 2;
  940|    983|}
decode.c:DetectTrivialLiteralBlockTypes:
 1145|  16.3k|    BrotliDecoderState* s) {
 1146|  16.3k|  size_t i;
 1147|   147k|  for (i = 0; i < 8; ++i) s->trivial_literal_contexts[i] = 0;
  ------------------
  |  Branch (1147:15): [True: 131k, False: 16.3k]
  ------------------
 1148|  64.4k|  for (i = 0; i < s->num_block_types[0]; i++) {
  ------------------
  |  Branch (1148:15): [True: 48.0k, False: 16.3k]
  ------------------
 1149|  48.0k|    size_t offset = i << BROTLI_LITERAL_CONTEXT_BITS;
  ------------------
  |  |   53|  48.0k|#define BROTLI_LITERAL_CONTEXT_BITS 6
  ------------------
 1150|  48.0k|    size_t error = 0;
 1151|  48.0k|    size_t sample = s->context_map[offset];
 1152|  48.0k|    size_t j;
 1153|   816k|    for (j = 0; j < (1u << BROTLI_LITERAL_CONTEXT_BITS);) {
  ------------------
  |  |   53|   816k|#define BROTLI_LITERAL_CONTEXT_BITS 6
  ------------------
  |  Branch (1153:17): [True: 768k, False: 48.0k]
  ------------------
 1154|   768k|      BROTLI_REPEAT(4, error |= s->context_map[offset + j++] ^ sample;)
  ------------------
  |  |  371|   768k|#define BROTLI_REPEAT(N, X) {     \
  |  |  372|   768k|  if ((N & 1) != 0) {X;}          \
  |  |  ------------------
  |  |  |  Branch (372:7): [Folded - Ignored]
  |  |  ------------------
  |  |  373|   768k|  if ((N & 2) != 0) {X; X;}       \
  |  |  ------------------
  |  |  |  Branch (373:7): [Folded - Ignored]
  |  |  ------------------
  |  |  374|   768k|  if ((N & 4) != 0) {X; X; X; X;} \
  |  |  ------------------
  |  |  |  Branch (374:7): [Folded - Ignored]
  |  |  ------------------
  |  |  375|   768k|}
  ------------------
 1155|   768k|    }
 1156|  48.0k|    if (error == 0) {
  ------------------
  |  Branch (1156:9): [True: 41.0k, False: 6.96k]
  ------------------
 1157|  41.0k|      s->trivial_literal_contexts[i >> 5] |= 1u << (i & 31);
 1158|  41.0k|    }
 1159|  48.0k|  }
 1160|  16.3k|}
decode.c:HuffmanTreeGroupDecode:
  944|  48.3k|    HuffmanTreeGroup* group, BrotliDecoderState* s) {
  945|  48.3k|  if (s->substate_tree_group != BROTLI_STATE_TREE_GROUP_LOOP) {
  ------------------
  |  Branch (945:7): [True: 48.3k, False: 0]
  ------------------
  946|  48.3k|    s->next = group->codes;
  947|  48.3k|    s->htree_index = 0;
  948|  48.3k|    s->substate_tree_group = BROTLI_STATE_TREE_GROUP_LOOP;
  949|  48.3k|  }
  950|   115k|  while (s->htree_index < group->num_htrees) {
  ------------------
  |  Branch (950:10): [True: 67.7k, False: 47.9k]
  ------------------
  951|  67.7k|    uint32_t table_size;
  952|  67.7k|    BrotliDecoderErrorCode result =
  953|  67.7k|        ReadHuffmanCode(group->alphabet_size, group->max_symbol,
  954|  67.7k|                        s->next, &table_size, s);
  955|  67.7k|    if (result != BROTLI_DECODER_SUCCESS) return result;
  ------------------
  |  Branch (955:9): [True: 409, False: 67.2k]
  ------------------
  956|  67.2k|    group->htrees[s->htree_index] = s->next;
  957|  67.2k|    s->next += table_size;
  958|  67.2k|    ++s->htree_index;
  959|  67.2k|  }
  960|  47.9k|  s->substate_tree_group = BROTLI_STATE_TREE_GROUP_NONE;
  961|  47.9k|  return BROTLI_DECODER_SUCCESS;
  962|  48.3k|}
decode.c:PrepareLiteralDecoding:
 1162|   101k|static BROTLI_INLINE void PrepareLiteralDecoding(BrotliDecoderState* s) {
 1163|   101k|  uint8_t context_mode;
 1164|   101k|  size_t trivial;
 1165|   101k|  uint32_t block_type = s->block_type_rb[1];
 1166|   101k|  uint32_t context_offset = block_type << BROTLI_LITERAL_CONTEXT_BITS;
  ------------------
  |  |   53|   101k|#define BROTLI_LITERAL_CONTEXT_BITS 6
  ------------------
 1167|   101k|  s->context_map_slice = s->context_map + context_offset;
 1168|   101k|  trivial = s->trivial_literal_contexts[block_type >> 5];
 1169|   101k|  s->trivial_literal_context = (trivial >> (block_type & 31)) & 1;
 1170|   101k|  s->literal_htree = s->literal_hgroup.htrees[s->context_map_slice[0]];
 1171|   101k|  context_mode = s->context_modes[block_type] & 3;
 1172|   101k|  s->context_lookup = BROTLI_CONTEXT_LUT(context_mode);
  ------------------
  |  |  256|   101k|#define BROTLI_CONTEXT_LUT(MODE) (&kContextLookup[(MODE) << 9])
  ------------------
 1173|   101k|}
decode.c:BrotliEnsureRingBuffer:
 1307|  22.1k|    BrotliDecoderState* s) {
 1308|  22.1k|  uint8_t* old_ringbuffer = s->ringbuffer;
 1309|  22.1k|  if (s->ringbuffer_size == s->new_ringbuffer_size) {
  ------------------
  |  Branch (1309:7): [True: 18.5k, False: 3.63k]
  ------------------
 1310|  18.5k|    return BROTLI_TRUE;
  ------------------
  |  |   51|  18.5k|#define BROTLI_TRUE 1
  ------------------
 1311|  18.5k|  }
 1312|       |
 1313|  3.63k|  s->ringbuffer = (uint8_t*)BROTLI_DECODER_ALLOC(s,
  ------------------
  |  |  247|  3.63k|#define BROTLI_DECODER_ALLOC(S, L) S->alloc_func(S->memory_manager_opaque, L)
  ------------------
 1314|  3.63k|      (size_t)(s->new_ringbuffer_size) + kRingBufferWriteAheadSlack);
 1315|  3.63k|  if (s->ringbuffer == 0) {
  ------------------
  |  Branch (1315:7): [True: 0, False: 3.63k]
  ------------------
 1316|       |    /* Restore previous value. */
 1317|      0|    s->ringbuffer = old_ringbuffer;
 1318|      0|    return BROTLI_FALSE;
  ------------------
  |  |   53|      0|#define BROTLI_FALSE 0
  ------------------
 1319|      0|  }
 1320|  3.63k|  s->ringbuffer[s->new_ringbuffer_size - 2] = 0;
 1321|  3.63k|  s->ringbuffer[s->new_ringbuffer_size - 1] = 0;
 1322|       |
 1323|  3.63k|  if (!!old_ringbuffer) {
  ------------------
  |  Branch (1323:7): [True: 407, False: 3.23k]
  ------------------
 1324|    407|    memcpy(s->ringbuffer, old_ringbuffer, (size_t)s->pos);
 1325|    407|    BROTLI_DECODER_FREE(s, old_ringbuffer);
  ------------------
  |  |  249|    407|#define BROTLI_DECODER_FREE(S, X) {          \
  |  |  250|    407|  S->free_func(S->memory_manager_opaque, X); \
  |  |  251|    407|  X = NULL;                                  \
  |  |  252|    407|}
  ------------------
 1326|    407|  }
 1327|       |
 1328|  3.63k|  s->ringbuffer_size = s->new_ringbuffer_size;
 1329|  3.63k|  s->ringbuffer_mask = s->new_ringbuffer_size - 1;
 1330|  3.63k|  s->ringbuffer_end = s->ringbuffer + s->ringbuffer_size;
 1331|       |
 1332|  3.63k|  return BROTLI_TRUE;
  ------------------
  |  |   51|  3.63k|#define BROTLI_TRUE 1
  ------------------
 1333|  3.63k|}
decode.c:ProcessCommands:
 1919|  20.5k|    BrotliDecoderState* s) {
 1920|  20.5k|  return ProcessCommandsInternal(0, s);
 1921|  20.5k|}
decode.c:ProcessCommandsInternal:
 1628|  24.2k|    int safe, BrotliDecoderState* s) {
 1629|  24.2k|  int pos = s->pos;
 1630|  24.2k|  int i = s->loop_counter;
 1631|  24.2k|  BrotliDecoderErrorCode result = BROTLI_DECODER_SUCCESS;
 1632|  24.2k|  BrotliBitReader* br = &s->br;
 1633|       |
 1634|  24.2k|  if (!CheckInputAmount(safe, br, 28)) {
  ------------------
  |  Branch (1634:7): [True: 2.79k, False: 21.4k]
  ------------------
 1635|  2.79k|    result = BROTLI_DECODER_NEEDS_MORE_INPUT;
 1636|  2.79k|    goto saveStateAndReturn;
 1637|  2.79k|  }
 1638|  21.4k|  if (!safe) {
  ------------------
  |  Branch (1638:7): [True: 17.7k, False: 3.64k]
  ------------------
 1639|  17.7k|    BROTLI_UNUSED(BrotliWarmupBitReader(br));
  ------------------
  |  |  377|  17.7k|#define BROTLI_UNUSED(X) (void)(X)
  ------------------
 1640|  17.7k|  }
 1641|       |
 1642|       |  /* Jump into state machine. */
 1643|  21.4k|  if (s->state == BROTLI_STATE_COMMAND_BEGIN) {
  ------------------
  |  Branch (1643:7): [True: 16.8k, False: 4.58k]
  ------------------
 1644|  16.8k|    goto CommandBegin;
 1645|  16.8k|  } else if (s->state == BROTLI_STATE_COMMAND_INNER) {
  ------------------
  |  Branch (1645:14): [True: 1.75k, False: 2.83k]
  ------------------
 1646|  1.75k|    goto CommandInner;
 1647|  2.83k|  } else if (s->state == BROTLI_STATE_COMMAND_POST_DECODE_LITERALS) {
  ------------------
  |  Branch (1647:14): [True: 514, False: 2.32k]
  ------------------
 1648|    514|    goto CommandPostDecodeLiterals;
 1649|  2.32k|  } else if (s->state == BROTLI_STATE_COMMAND_POST_WRAP_COPY) {
  ------------------
  |  Branch (1649:14): [True: 2.32k, False: 0]
  ------------------
 1650|  2.32k|    goto CommandPostWrapCopy;
 1651|  2.32k|  } else {
 1652|      0|    return BROTLI_FAILURE(BROTLI_DECODER_ERROR_UNREACHABLE);
  ------------------
  |  |   31|      0|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|      0|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
 1653|      0|  }
 1654|       |
 1655|  79.4M|CommandBegin:
 1656|  79.4M|  if (safe) {
  ------------------
  |  Branch (1656:7): [True: 49.6M, False: 29.8M]
  ------------------
 1657|  49.6M|    s->state = BROTLI_STATE_COMMAND_BEGIN;
 1658|  49.6M|  }
 1659|  79.4M|  if (!CheckInputAmount(safe, br, 28)) {  /* 156 bits + 7 bytes */
  ------------------
  |  Branch (1659:7): [True: 410, False: 79.4M]
  ------------------
 1660|    410|    s->state = BROTLI_STATE_COMMAND_BEGIN;
 1661|    410|    result = BROTLI_DECODER_NEEDS_MORE_INPUT;
 1662|    410|    goto saveStateAndReturn;
 1663|    410|  }
 1664|  79.4M|  if (BROTLI_PREDICT_FALSE(s->block_length[1] == 0)) {
  ------------------
  |  |  318|  79.4M|#define BROTLI_PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (318:33): [True: 511k, False: 78.9M]
  |  |  ------------------
  ------------------
 1665|   511k|    BROTLI_SAFE(DecodeCommandBlockSwitch(s));
  ------------------
  |  | 1616|   511k|  {                                               \
  |  | 1617|   511k|    if (safe) {                                   \
  |  |  ------------------
  |  |  |  Branch (1617:9): [True: 4.57k, False: 506k]
  |  |  ------------------
  |  | 1618|  4.57k|      if (!Safe##METHOD) {                        \
  |  |  ------------------
  |  |  |  Branch (1618:11): [True: 76, False: 4.49k]
  |  |  ------------------
  |  | 1619|     76|        result = BROTLI_DECODER_NEEDS_MORE_INPUT; \
  |  | 1620|     76|        goto saveStateAndReturn;                  \
  |  | 1621|     76|      }                                           \
  |  | 1622|   506k|    } else {                                      \
  |  | 1623|   506k|      METHOD;                                     \
  |  | 1624|   506k|    }                                             \
  |  | 1625|   511k|  }
  ------------------
 1666|   511k|    goto CommandBegin;
 1667|   511k|  }
 1668|       |  /* Read the insert/copy length in the command. */
 1669|  78.9M|  BROTLI_SAFE(ReadCommand(s, br, &i));
  ------------------
  |  | 1616|  78.9M|  {                                               \
  |  | 1617|  78.9M|    if (safe) {                                   \
  |  |  ------------------
  |  |  |  Branch (1617:9): [True: 49.5M, False: 29.3M]
  |  |  ------------------
  |  | 1618|  49.5M|      if (!Safe##METHOD) {                        \
  |  |  ------------------
  |  |  |  Branch (1618:11): [True: 231, False: 49.5M]
  |  |  ------------------
  |  | 1619|    231|        result = BROTLI_DECODER_NEEDS_MORE_INPUT; \
  |  | 1620|    231|        goto saveStateAndReturn;                  \
  |  | 1621|    231|      }                                           \
  |  | 1622|  49.5M|    } else {                                      \
  |  | 1623|  29.3M|      METHOD;                                     \
  |  | 1624|  29.3M|    }                                             \
  |  | 1625|  78.9M|  }
  ------------------
 1670|  78.9M|  BROTLI_LOG(("[ProcessCommandsInternal] pos = %d insert = %d copy = %d\n",
 1671|  78.9M|              pos, i, s->copy_length));
 1672|  78.9M|  if (i == 0) {
  ------------------
  |  Branch (1672:7): [True: 17.5M, False: 61.4M]
  ------------------
 1673|  17.5M|    goto CommandPostDecodeLiterals;
 1674|  17.5M|  }
 1675|  61.4M|  s->meta_block_remaining_len -= i;
 1676|       |
 1677|  61.4M|CommandInner:
 1678|  61.4M|  if (safe) {
  ------------------
  |  Branch (1678:7): [True: 45.0M, False: 16.4M]
  ------------------
 1679|  45.0M|    s->state = BROTLI_STATE_COMMAND_INNER;
 1680|  45.0M|  }
 1681|       |  /* Read the literals in the command. */
 1682|  61.4M|  if (s->trivial_literal_context) {
  ------------------
  |  Branch (1682:7): [True: 54.2M, False: 7.22M]
  ------------------
 1683|  54.2M|    uint32_t bits;
 1684|  54.2M|    uint32_t value;
 1685|  54.2M|    PreloadSymbol(safe, s->literal_htree, br, &bits, &value);
 1686|  1.37G|    do {
 1687|  1.37G|      if (!CheckInputAmount(safe, br, 28)) {  /* 162 bits + 7 bytes */
  ------------------
  |  Branch (1687:11): [True: 305, False: 1.37G]
  ------------------
 1688|    305|        s->state = BROTLI_STATE_COMMAND_INNER;
 1689|    305|        result = BROTLI_DECODER_NEEDS_MORE_INPUT;
 1690|    305|        goto saveStateAndReturn;
 1691|    305|      }
 1692|  1.37G|      if (BROTLI_PREDICT_FALSE(s->block_length[0] == 0)) {
  ------------------
  |  |  318|  1.37G|#define BROTLI_PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (318:33): [True: 20.8k, False: 1.37G]
  |  |  ------------------
  ------------------
 1693|  20.8k|        BROTLI_SAFE(DecodeLiteralBlockSwitch(s));
  ------------------
  |  | 1616|  20.8k|  {                                               \
  |  | 1617|  20.8k|    if (safe) {                                   \
  |  |  ------------------
  |  |  |  Branch (1617:9): [True: 5.14k, False: 15.7k]
  |  |  ------------------
  |  | 1618|  5.14k|      if (!Safe##METHOD) {                        \
  |  |  ------------------
  |  |  |  Branch (1618:11): [True: 89, False: 5.05k]
  |  |  ------------------
  |  | 1619|     89|        result = BROTLI_DECODER_NEEDS_MORE_INPUT; \
  |  | 1620|     89|        goto saveStateAndReturn;                  \
  |  | 1621|     89|      }                                           \
  |  | 1622|  15.7k|    } else {                                      \
  |  | 1623|  15.7k|      METHOD;                                     \
  |  | 1624|  15.7k|    }                                             \
  |  | 1625|  20.8k|  }
  ------------------
 1694|  20.8k|        PreloadSymbol(safe, s->literal_htree, br, &bits, &value);
 1695|  20.8k|        if (!s->trivial_literal_context) goto CommandInner;
  ------------------
  |  Branch (1695:13): [True: 6.51k, False: 14.2k]
  ------------------
 1696|  20.8k|      }
 1697|  1.37G|      if (!safe) {
  ------------------
  |  Branch (1697:11): [True: 539M, False: 837M]
  ------------------
 1698|   539M|        s->ringbuffer[pos] =
 1699|   539M|            (uint8_t)ReadPreloadedSymbol(s->literal_htree, br, &bits, &value);
 1700|   837M|      } else {
 1701|   837M|        uint32_t literal;
 1702|   837M|        if (!SafeReadSymbol(s->literal_htree, br, &literal)) {
  ------------------
  |  Branch (1702:13): [True: 66, False: 837M]
  ------------------
 1703|     66|          result = BROTLI_DECODER_NEEDS_MORE_INPUT;
 1704|     66|          goto saveStateAndReturn;
 1705|     66|        }
 1706|   837M|        s->ringbuffer[pos] = (uint8_t)literal;
 1707|   837M|      }
 1708|  1.37G|      --s->block_length[0];
 1709|  1.37G|      BROTLI_LOG_ARRAY_INDEX(s->ringbuffer, pos);
 1710|  1.37G|      ++pos;
 1711|  1.37G|      if (BROTLI_PREDICT_FALSE(pos == s->ringbuffer_size)) {
  ------------------
  |  |  318|  1.37G|#define BROTLI_PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (318:33): [True: 1.13k, False: 1.37G]
  |  |  ------------------
  ------------------
 1712|  1.13k|        s->state = BROTLI_STATE_COMMAND_INNER_WRITE;
 1713|  1.13k|        --i;
 1714|  1.13k|        goto saveStateAndReturn;
 1715|  1.13k|      }
 1716|  1.37G|    } while (--i != 0);
  ------------------
  |  Branch (1716:14): [True: 1.32G, False: 54.2M]
  ------------------
 1717|  54.2M|  } else {
 1718|  7.22M|    uint8_t p1 = s->ringbuffer[(pos - 1) & s->ringbuffer_mask];
 1719|  7.22M|    uint8_t p2 = s->ringbuffer[(pos - 2) & s->ringbuffer_mask];
 1720|  42.5M|    do {
 1721|  42.5M|      const HuffmanCode* hc;
 1722|  42.5M|      uint8_t context;
 1723|  42.5M|      if (!CheckInputAmount(safe, br, 28)) {  /* 162 bits + 7 bytes */
  ------------------
  |  Branch (1723:11): [True: 132, False: 42.5M]
  ------------------
 1724|    132|        s->state = BROTLI_STATE_COMMAND_INNER;
 1725|    132|        result = BROTLI_DECODER_NEEDS_MORE_INPUT;
 1726|    132|        goto saveStateAndReturn;
 1727|    132|      }
 1728|  42.5M|      if (BROTLI_PREDICT_FALSE(s->block_length[0] == 0)) {
  ------------------
  |  |  318|  42.5M|#define BROTLI_PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (318:33): [True: 64.4k, False: 42.5M]
  |  |  ------------------
  ------------------
 1729|  64.4k|        BROTLI_SAFE(DecodeLiteralBlockSwitch(s));
  ------------------
  |  | 1616|  64.4k|  {                                               \
  |  | 1617|  64.4k|    if (safe) {                                   \
  |  |  ------------------
  |  |  |  Branch (1617:9): [True: 1.33k, False: 63.0k]
  |  |  ------------------
  |  | 1618|  1.33k|      if (!Safe##METHOD) {                        \
  |  |  ------------------
  |  |  |  Branch (1618:11): [True: 15, False: 1.32k]
  |  |  ------------------
  |  | 1619|     15|        result = BROTLI_DECODER_NEEDS_MORE_INPUT; \
  |  | 1620|     15|        goto saveStateAndReturn;                  \
  |  | 1621|     15|      }                                           \
  |  | 1622|  63.0k|    } else {                                      \
  |  | 1623|  63.0k|      METHOD;                                     \
  |  | 1624|  63.0k|    }                                             \
  |  | 1625|  64.4k|  }
  ------------------
 1730|  64.3k|        if (s->trivial_literal_context) goto CommandInner;
  ------------------
  |  Branch (1730:13): [True: 6.51k, False: 57.8k]
  ------------------
 1731|  64.3k|      }
 1732|  42.5M|      context = BROTLI_CONTEXT(p1, p2, s->context_lookup);
  ------------------
  |  |  259|  42.5M|#define BROTLI_CONTEXT(P1, P2, LUT) ((LUT)[P1] | ((LUT) + 256)[P2])
  ------------------
 1733|  42.5M|      BROTLI_LOG_UINT(context);
 1734|  42.5M|      hc = s->literal_hgroup.htrees[s->context_map_slice[context]];
 1735|  42.5M|      p2 = p1;
 1736|  42.5M|      if (!safe) {
  ------------------
  |  Branch (1736:11): [True: 25.1M, False: 17.4M]
  ------------------
 1737|  25.1M|        p1 = (uint8_t)ReadSymbol(hc, br);
 1738|  25.1M|      } else {
 1739|  17.4M|        uint32_t literal;
 1740|  17.4M|        if (!SafeReadSymbol(hc, br, &literal)) {
  ------------------
  |  Branch (1740:13): [True: 13, False: 17.4M]
  ------------------
 1741|     13|          result = BROTLI_DECODER_NEEDS_MORE_INPUT;
 1742|     13|          goto saveStateAndReturn;
 1743|     13|        }
 1744|  17.4M|        p1 = (uint8_t)literal;
 1745|  17.4M|      }
 1746|  42.5M|      s->ringbuffer[pos] = p1;
 1747|  42.5M|      --s->block_length[0];
 1748|  42.5M|      BROTLI_LOG_UINT(s->context_map_slice[context]);
 1749|  42.5M|      BROTLI_LOG_ARRAY_INDEX(s->ringbuffer, pos & s->ringbuffer_mask);
 1750|  42.5M|      ++pos;
 1751|  42.5M|      if (BROTLI_PREDICT_FALSE(pos == s->ringbuffer_size)) {
  ------------------
  |  |  318|  42.5M|#define BROTLI_PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (318:33): [True: 833, False: 42.5M]
  |  |  ------------------
  ------------------
 1752|    833|        s->state = BROTLI_STATE_COMMAND_INNER_WRITE;
 1753|    833|        --i;
 1754|    833|        goto saveStateAndReturn;
 1755|    833|      }
 1756|  42.5M|    } while (--i != 0);
  ------------------
  |  Branch (1756:14): [True: 35.3M, False: 7.21M]
  ------------------
 1757|  7.22M|  }
 1758|  61.4M|  BROTLI_LOG_UINT(s->meta_block_remaining_len);
 1759|  61.4M|  if (BROTLI_PREDICT_FALSE(s->meta_block_remaining_len <= 0)) {
  ------------------
  |  |  318|  61.4M|#define BROTLI_PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (318:33): [True: 5.25k, False: 61.4M]
  |  |  ------------------
  ------------------
 1760|  5.25k|    s->state = BROTLI_STATE_METABLOCK_DONE;
 1761|  5.25k|    goto saveStateAndReturn;
 1762|  5.25k|  }
 1763|       |
 1764|  78.9M|CommandPostDecodeLiterals:
 1765|  78.9M|  if (safe) {
  ------------------
  |  Branch (1765:7): [True: 49.5M, False: 29.3M]
  ------------------
 1766|  49.5M|    s->state = BROTLI_STATE_COMMAND_POST_DECODE_LITERALS;
 1767|  49.5M|  }
 1768|  78.9M|  if (s->distance_code >= 0) {
  ------------------
  |  Branch (1768:7): [True: 61.1M, False: 17.8M]
  ------------------
 1769|       |    /* Implicit distance case. */
 1770|  61.1M|    s->distance_context = s->distance_code ? 0 : 1;
  ------------------
  |  Branch (1770:27): [True: 0, False: 61.1M]
  ------------------
 1771|  61.1M|    --s->dist_rb_idx;
 1772|  61.1M|    s->distance_code = s->dist_rb[s->dist_rb_idx & 3];
 1773|  61.1M|  } else {
 1774|       |    /* Read distance code in the command, unless it was implicitly zero. */
 1775|  17.8M|    if (BROTLI_PREDICT_FALSE(s->block_length[2] == 0)) {
  ------------------
  |  |  318|  17.8M|#define BROTLI_PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (318:33): [True: 43.4k, False: 17.8M]
  |  |  ------------------
  ------------------
 1776|  43.4k|      BROTLI_SAFE(DecodeDistanceBlockSwitch(s));
  ------------------
  |  | 1616|  43.4k|  {                                               \
  |  | 1617|  43.4k|    if (safe) {                                   \
  |  |  ------------------
  |  |  |  Branch (1617:9): [True: 5.27k, False: 38.1k]
  |  |  ------------------
  |  | 1618|  5.27k|      if (!Safe##METHOD) {                        \
  |  |  ------------------
  |  |  |  Branch (1618:11): [True: 97, False: 5.17k]
  |  |  ------------------
  |  | 1619|     97|        result = BROTLI_DECODER_NEEDS_MORE_INPUT; \
  |  | 1620|     97|        goto saveStateAndReturn;                  \
  |  | 1621|     97|      }                                           \
  |  | 1622|  38.1k|    } else {                                      \
  |  | 1623|  38.1k|      METHOD;                                     \
  |  | 1624|  38.1k|    }                                             \
  |  | 1625|  43.4k|  }
  ------------------
 1777|  43.3k|    }
 1778|  17.8M|    BROTLI_SAFE(ReadDistance(s, br));
  ------------------
  |  | 1616|  17.8M|  {                                               \
  |  | 1617|  17.8M|    if (safe) {                                   \
  |  |  ------------------
  |  |  |  Branch (1617:9): [True: 10.0M, False: 7.83M]
  |  |  ------------------
  |  | 1618|  10.0M|      if (!Safe##METHOD) {                        \
  |  |  ------------------
  |  |  |  Branch (1618:11): [True: 241, False: 10.0M]
  |  |  ------------------
  |  | 1619|    241|        result = BROTLI_DECODER_NEEDS_MORE_INPUT; \
  |  | 1620|    241|        goto saveStateAndReturn;                  \
  |  | 1621|    241|      }                                           \
  |  | 1622|  10.0M|    } else {                                      \
  |  | 1623|  7.83M|      METHOD;                                     \
  |  | 1624|  7.83M|    }                                             \
  |  | 1625|  17.8M|  }
  ------------------
 1779|  17.8M|  }
 1780|  78.9M|  BROTLI_LOG(("[ProcessCommandsInternal] pos = %d distance = %d\n",
 1781|  78.9M|              pos, s->distance_code));
 1782|  78.9M|  if (s->max_distance != s->max_backward_distance) {
  ------------------
  |  Branch (1782:7): [True: 77.7M, False: 1.18M]
  ------------------
 1783|  77.7M|    s->max_distance =
 1784|  77.7M|        (pos < s->max_backward_distance) ? pos : s->max_backward_distance;
  ------------------
  |  Branch (1784:9): [True: 77.7M, False: 185]
  ------------------
 1785|  77.7M|  }
 1786|  78.9M|  i = s->copy_length;
 1787|       |  /* Apply copy of LZ77 back-reference, or static dictionary reference if
 1788|       |     the distance is larger than the max LZ77 distance */
 1789|  78.9M|  if (s->distance_code > s->max_distance) {
  ------------------
  |  Branch (1789:7): [True: 146k, False: 78.8M]
  ------------------
 1790|       |    /* The maximum allowed distance is BROTLI_MAX_ALLOWED_DISTANCE = 0x7FFFFFFC.
 1791|       |       With this choice, no signed overflow can occur after decoding
 1792|       |       a special distance code (e.g., after adding 3 to the last distance). */
 1793|   146k|    if (s->distance_code > BROTLI_MAX_ALLOWED_DISTANCE) {
  ------------------
  |  |   49|   146k|#define BROTLI_MAX_ALLOWED_DISTANCE 0x7FFFFFFC
  ------------------
  |  Branch (1793:9): [True: 37, False: 146k]
  ------------------
 1794|     37|      BROTLI_LOG(("Invalid backward reference. pos: %d distance: %d "
 1795|     37|          "len: %d bytes left: %d\n",
 1796|     37|          pos, s->distance_code, i, s->meta_block_remaining_len));
 1797|     37|      return BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_DISTANCE);
  ------------------
  |  |   31|     37|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|     37|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
 1798|     37|    }
 1799|   146k|    if (i >= BROTLI_MIN_DICTIONARY_WORD_LENGTH &&
  ------------------
  |  |   57|   293k|#define BROTLI_MIN_DICTIONARY_WORD_LENGTH 4
  ------------------
  |  Branch (1799:9): [True: 146k, False: 21]
  ------------------
 1800|   146k|        i <= BROTLI_MAX_DICTIONARY_WORD_LENGTH) {
  ------------------
  |  |   58|   146k|#define BROTLI_MAX_DICTIONARY_WORD_LENGTH 24
  ------------------
  |  Branch (1800:9): [True: 146k, False: 90]
  ------------------
 1801|   146k|      int address = s->distance_code - s->max_distance - 1;
 1802|   146k|      const BrotliDictionary* words = s->dictionary;
 1803|   146k|      const BrotliTransforms* transforms = s->transforms;
 1804|   146k|      int offset = (int)s->dictionary->offsets_by_length[i];
 1805|   146k|      uint32_t shift = s->dictionary->size_bits_by_length[i];
 1806|       |
 1807|   146k|      int mask = (int)BitMask(shift);
 1808|   146k|      int word_idx = address & mask;
 1809|   146k|      int transform_idx = address >> shift;
 1810|       |      /* Compensate double distance-ring-buffer roll. */
 1811|   146k|      s->dist_rb_idx += s->distance_context;
 1812|   146k|      offset += word_idx * i;
 1813|   146k|      if (BROTLI_PREDICT_FALSE(!words->data)) {
  ------------------
  |  |  318|   146k|#define BROTLI_PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (318:33): [True: 0, False: 146k]
  |  |  ------------------
  ------------------
 1814|      0|        return BROTLI_FAILURE(BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET);
  ------------------
  |  |   31|      0|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|      0|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
 1815|      0|      }
 1816|   146k|      if (transform_idx < (int)transforms->num_transforms) {
  ------------------
  |  Branch (1816:11): [True: 146k, False: 103]
  ------------------
 1817|   146k|        const uint8_t* word = &words->data[offset];
 1818|   146k|        int len = i;
 1819|   146k|        if (transform_idx == transforms->cutOffTransforms[0]) {
  ------------------
  |  Branch (1819:13): [True: 134k, False: 11.9k]
  ------------------
 1820|   134k|          memcpy(&s->ringbuffer[pos], word, (size_t)len);
 1821|   134k|          BROTLI_LOG(("[ProcessCommandsInternal] dictionary word: [%.*s]\n",
 1822|   134k|                      len, word));
 1823|   134k|        } else {
 1824|  11.9k|          len = BrotliTransformDictionaryWord(&s->ringbuffer[pos], word, len,
 1825|  11.9k|              transforms, transform_idx);
 1826|  11.9k|          BROTLI_LOG(("[ProcessCommandsInternal] dictionary word: [%.*s],"
 1827|  11.9k|                      " transform_idx = %d, transformed: [%.*s]\n",
 1828|  11.9k|                      i, word, transform_idx, len, &s->ringbuffer[pos]));
 1829|  11.9k|        }
 1830|   146k|        pos += len;
 1831|   146k|        s->meta_block_remaining_len -= len;
 1832|   146k|        if (pos >= s->ringbuffer_size) {
  ------------------
  |  Branch (1832:13): [True: 564, False: 145k]
  ------------------
 1833|    564|          s->state = BROTLI_STATE_COMMAND_POST_WRITE_1;
 1834|    564|          goto saveStateAndReturn;
 1835|    564|        }
 1836|   146k|      } else {
 1837|    103|        BROTLI_LOG(("Invalid backward reference. pos: %d distance: %d "
 1838|    103|            "len: %d bytes left: %d\n",
 1839|    103|            pos, s->distance_code, i, s->meta_block_remaining_len));
 1840|    103|        return BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_TRANSFORM);
  ------------------
  |  |   31|    103|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|    103|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
 1841|    103|      }
 1842|   146k|    } else {
 1843|    111|      BROTLI_LOG(("Invalid backward reference. pos: %d distance: %d "
 1844|    111|          "len: %d bytes left: %d\n",
 1845|    111|          pos, s->distance_code, i, s->meta_block_remaining_len));
 1846|    111|      return BROTLI_FAILURE(BROTLI_DECODER_ERROR_FORMAT_DICTIONARY);
  ------------------
  |  |   31|    111|#define BROTLI_FAILURE(CODE) (BROTLI_DUMP(), CODE)
  |  |  ------------------
  |  |  |  |  352|    111|#define BROTLI_DUMP() (void)(0)
  |  |  ------------------
  ------------------
 1847|    111|    }
 1848|  78.8M|  } else {
 1849|  78.8M|    int src_start = (pos - s->distance_code) & s->ringbuffer_mask;
 1850|  78.8M|    uint8_t* copy_dst = &s->ringbuffer[pos];
 1851|  78.8M|    uint8_t* copy_src = &s->ringbuffer[src_start];
 1852|  78.8M|    int dst_end = pos + i;
 1853|  78.8M|    int src_end = src_start + i;
 1854|       |    /* Update the recent distances cache. */
 1855|  78.8M|    s->dist_rb[s->dist_rb_idx & 3] = s->distance_code;
 1856|  78.8M|    ++s->dist_rb_idx;
 1857|  78.8M|    s->meta_block_remaining_len -= i;
 1858|       |    /* There are 32+ bytes of slack in the ring-buffer allocation.
 1859|       |       Also, we have 16 short codes, that make these 16 bytes irrelevant
 1860|       |       in the ring-buffer. Let's copy over them as a first guess. */
 1861|  78.8M|    memmove16(copy_dst, copy_src);
 1862|  78.8M|    if (src_end > pos && dst_end > src_start) {
  ------------------
  |  Branch (1862:9): [True: 16.6M, False: 62.2M]
  |  Branch (1862:26): [True: 16.5M, False: 36.7k]
  ------------------
 1863|       |      /* Regions intersect. */
 1864|  16.5M|      goto CommandPostWrapCopy;
 1865|  16.5M|    }
 1866|  62.2M|    if (dst_end >= s->ringbuffer_size || src_end >= s->ringbuffer_size) {
  ------------------
  |  Branch (1866:9): [True: 1.23k, False: 62.2M]
  |  Branch (1866:42): [True: 3.12k, False: 62.2M]
  ------------------
 1867|       |      /* At least one region wraps. */
 1868|  4.35k|      goto CommandPostWrapCopy;
 1869|  4.35k|    }
 1870|  62.2M|    pos += i;
 1871|  62.2M|    if (i > 16) {
  ------------------
  |  Branch (1871:9): [True: 107k, False: 62.1M]
  ------------------
 1872|   107k|      if (i > 32) {
  ------------------
  |  Branch (1872:11): [True: 55.6k, False: 52.2k]
  ------------------
 1873|  55.6k|        memcpy(copy_dst + 16, copy_src + 16, (size_t)(i - 16));
 1874|  55.6k|      } else {
 1875|       |        /* This branch covers about 45% cases.
 1876|       |           Fixed size short copy allows more compiler optimizations. */
 1877|  52.2k|        memmove16(copy_dst + 16, copy_src + 16);
 1878|  52.2k|      }
 1879|   107k|    }
 1880|  62.2M|  }
 1881|  62.3M|  BROTLI_LOG_UINT(s->meta_block_remaining_len);
 1882|  62.3M|  if (s->meta_block_remaining_len <= 0) {
  ------------------
  |  Branch (1882:7): [True: 6.34k, False: 62.3M]
  ------------------
 1883|       |    /* Next metablock, if any. */
 1884|  6.34k|    s->state = BROTLI_STATE_METABLOCK_DONE;
 1885|  6.34k|    goto saveStateAndReturn;
 1886|  62.3M|  } else {
 1887|  62.3M|    goto CommandBegin;
 1888|  62.3M|  }
 1889|  16.5M|CommandPostWrapCopy:
 1890|  16.5M|  {
 1891|  16.5M|    int wrap_guard = s->ringbuffer_size - pos;
 1892|   480M|    while (--i >= 0) {
  ------------------
  |  Branch (1892:12): [True: 464M, False: 16.5M]
  ------------------
 1893|   464M|      s->ringbuffer[pos] =
 1894|   464M|          s->ringbuffer[(pos - s->distance_code) & s->ringbuffer_mask];
 1895|   464M|      ++pos;
 1896|   464M|      if (BROTLI_PREDICT_FALSE(--wrap_guard == 0)) {
  ------------------
  |  |  318|   464M|#define BROTLI_PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (318:33): [True: 2.45k, False: 464M]
  |  |  ------------------
  ------------------
 1897|  2.45k|        s->state = BROTLI_STATE_COMMAND_POST_WRITE_2;
 1898|  2.45k|        goto saveStateAndReturn;
 1899|  2.45k|      }
 1900|   464M|    }
 1901|  16.5M|  }
 1902|  16.5M|  if (s->meta_block_remaining_len <= 0) {
  ------------------
  |  Branch (1902:7): [True: 2.89k, False: 16.5M]
  ------------------
 1903|       |    /* Next metablock, if any. */
 1904|  2.89k|    s->state = BROTLI_STATE_METABLOCK_DONE;
 1905|  2.89k|    goto saveStateAndReturn;
 1906|  16.5M|  } else {
 1907|  16.5M|    goto CommandBegin;
 1908|  16.5M|  }
 1909|       |
 1910|  23.9k|saveStateAndReturn:
 1911|  23.9k|  s->pos = pos;
 1912|  23.9k|  s->loop_counter = i;
 1913|  23.9k|  return result;
 1914|  16.5M|}
decode.c:CheckInputAmount:
 1608|  1.49G|    int safe, BrotliBitReader* const br, size_t num) {
 1609|  1.49G|  if (safe) {
  ------------------
  |  Branch (1609:7): [True: 904M, False: 594M]
  ------------------
 1610|   904M|    return BROTLI_TRUE;
  ------------------
  |  |   51|   904M|#define BROTLI_TRUE 1
  ------------------
 1611|   904M|  }
 1612|   594M|  return BrotliCheckInputAmount(br, num);
 1613|  1.49G|}
decode.c:SafeDecodeCommandBlockSwitch:
 1211|  4.57k|    BrotliDecoderState* s) {
 1212|  4.57k|  return DecodeCommandBlockSwitchInternal(1, s);
 1213|  4.57k|}
decode.c:DecodeCommandBlockSwitchInternal:
 1198|   511k|    int safe, BrotliDecoderState* s) {
 1199|   511k|  if (!DecodeBlockTypeAndLength(safe, s, 1)) {
  ------------------
  |  Branch (1199:7): [True: 76, False: 511k]
  ------------------
 1200|     76|    return BROTLI_FALSE;
  ------------------
  |  |   53|     76|#define BROTLI_FALSE 0
  ------------------
 1201|     76|  }
 1202|   511k|  s->htree_command = s->insert_copy_hgroup.htrees[s->block_type_rb[3]];
 1203|   511k|  return BROTLI_TRUE;
  ------------------
  |  |   51|   511k|#define BROTLI_TRUE 1
  ------------------
 1204|   511k|}
decode.c:DecodeBlockTypeAndLength:
 1101|   640k|    int safe, BrotliDecoderState* s, int tree_type) {
 1102|   640k|  uint32_t max_block_type = s->num_block_types[tree_type];
 1103|   640k|  const HuffmanCode* type_tree = &s->block_type_trees[
 1104|   640k|      tree_type * BROTLI_HUFFMAN_MAX_SIZE_258];
  ------------------
  |  |   30|   640k|#define BROTLI_HUFFMAN_MAX_SIZE_258 632
  ------------------
 1105|   640k|  const HuffmanCode* len_tree = &s->block_len_trees[
 1106|   640k|      tree_type * BROTLI_HUFFMAN_MAX_SIZE_26];
  ------------------
  |  |   28|   640k|#define BROTLI_HUFFMAN_MAX_SIZE_26 396
  ------------------
 1107|   640k|  BrotliBitReader* br = &s->br;
 1108|   640k|  uint32_t* ringbuffer = &s->block_type_rb[tree_type * 2];
 1109|   640k|  uint32_t block_type;
 1110|   640k|  if (max_block_type <= 1) {
  ------------------
  |  Branch (1110:7): [True: 0, False: 640k]
  ------------------
 1111|      0|    return BROTLI_FALSE;
  ------------------
  |  |   53|      0|#define BROTLI_FALSE 0
  ------------------
 1112|      0|  }
 1113|       |
 1114|       |  /* Read 0..15 + 3..39 bits. */
 1115|   640k|  if (!safe) {
  ------------------
  |  Branch (1115:7): [True: 623k, False: 16.3k]
  ------------------
 1116|   623k|    block_type = ReadSymbol(type_tree, br);
 1117|   623k|    s->block_length[tree_type] = ReadBlockLength(len_tree, br);
 1118|   623k|  } else {
 1119|  16.3k|    BrotliBitReaderState memento;
 1120|  16.3k|    BrotliBitReaderSaveState(br, &memento);
 1121|  16.3k|    if (!SafeReadSymbol(type_tree, br, &block_type)) return BROTLI_FALSE;
  ------------------
  |  |   53|     53|#define BROTLI_FALSE 0
  ------------------
  |  Branch (1121:9): [True: 53, False: 16.2k]
  ------------------
 1122|  16.2k|    if (!SafeReadBlockLength(s, &s->block_length[tree_type], len_tree, br)) {
  ------------------
  |  Branch (1122:9): [True: 224, False: 16.0k]
  ------------------
 1123|    224|      s->substate_read_block_length = BROTLI_STATE_READ_BLOCK_LENGTH_NONE;
 1124|    224|      BrotliBitReaderRestoreState(br, &memento);
 1125|    224|      return BROTLI_FALSE;
  ------------------
  |  |   53|    224|#define BROTLI_FALSE 0
  ------------------
 1126|    224|    }
 1127|  16.2k|  }
 1128|       |
 1129|   639k|  if (block_type == 1) {
  ------------------
  |  Branch (1129:7): [True: 49.3k, False: 590k]
  ------------------
 1130|  49.3k|    block_type = ringbuffer[1] + 1;
 1131|   590k|  } else if (block_type == 0) {
  ------------------
  |  Branch (1131:14): [True: 561k, False: 29.1k]
  ------------------
 1132|   561k|    block_type = ringbuffer[0];
 1133|   561k|  } else {
 1134|  29.1k|    block_type -= 2;
 1135|  29.1k|  }
 1136|   639k|  if (block_type >= max_block_type) {
  ------------------
  |  Branch (1136:7): [True: 16.5k, False: 623k]
  ------------------
 1137|  16.5k|    block_type -= max_block_type;
 1138|  16.5k|  }
 1139|   639k|  ringbuffer[0] = ringbuffer[1];
 1140|   639k|  ringbuffer[1] = block_type;
 1141|   639k|  return BROTLI_TRUE;
  ------------------
  |  |   51|   639k|#define BROTLI_TRUE 1
  ------------------
 1142|   640k|}
decode.c:ReadBlockLength:
  856|   623k|                                              BrotliBitReader* br) {
  857|   623k|  uint32_t code;
  858|   623k|  uint32_t nbits;
  859|   623k|  code = ReadSymbol(table, br);
  860|   623k|  nbits = kBlockLengthPrefixCode[code].nbits;  /* nbits == 2..24 */
  861|   623k|  return kBlockLengthPrefixCode[code].offset + BrotliReadBits(br, nbits);
  862|   623k|}
decode.c:DecodeCommandBlockSwitch:
 1206|   506k|static void BROTLI_NOINLINE DecodeCommandBlockSwitch(BrotliDecoderState* s) {
 1207|   506k|  DecodeCommandBlockSwitchInternal(0, s);
 1208|   506k|}
decode.c:SafeReadCommand:
 1603|  49.5M|    BrotliDecoderState* s, BrotliBitReader* br, int* insert_length) {
 1604|  49.5M|  return ReadCommandInternal(1, s, br, insert_length);
 1605|  49.5M|}
decode.c:ReadCommandInternal:
 1560|  78.9M|    int safe, BrotliDecoderState* s, BrotliBitReader* br, int* insert_length) {
 1561|  78.9M|  uint32_t cmd_code;
 1562|  78.9M|  uint32_t insert_len_extra = 0;
 1563|  78.9M|  uint32_t copy_length;
 1564|  78.9M|  CmdLutElement v;
 1565|  78.9M|  BrotliBitReaderState memento;
 1566|  78.9M|  if (!safe) {
  ------------------
  |  Branch (1566:7): [True: 29.3M, False: 49.5M]
  ------------------
 1567|  29.3M|    cmd_code = ReadSymbol(s->htree_command, br);
 1568|  49.5M|  } else {
 1569|  49.5M|    BrotliBitReaderSaveState(br, &memento);
 1570|  49.5M|    if (!SafeReadSymbol(s->htree_command, br, &cmd_code)) {
  ------------------
  |  Branch (1570:9): [True: 39, False: 49.5M]
  ------------------
 1571|     39|      return BROTLI_FALSE;
  ------------------
  |  |   53|     39|#define BROTLI_FALSE 0
  ------------------
 1572|     39|    }
 1573|  49.5M|  }
 1574|  78.9M|  v = kCmdLut[cmd_code];
 1575|  78.9M|  s->distance_code = v.distance_code;
 1576|  78.9M|  s->distance_context = v.context;
 1577|  78.9M|  s->dist_htree_index = s->dist_context_map_slice[s->distance_context];
 1578|  78.9M|  *insert_length = v.insert_len_offset;
 1579|  78.9M|  if (!safe) {
  ------------------
  |  Branch (1579:7): [True: 29.3M, False: 49.5M]
  ------------------
 1580|  29.3M|    if (BROTLI_PREDICT_FALSE(v.insert_len_extra_bits != 0)) {
  ------------------
  |  |  318|  29.3M|#define BROTLI_PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (318:33): [True: 867k, False: 28.5M]
  |  |  ------------------
  ------------------
 1581|   867k|      insert_len_extra = BrotliReadBits(br, v.insert_len_extra_bits);
 1582|   867k|    }
 1583|  29.3M|    copy_length = BrotliReadBits(br, v.copy_len_extra_bits);
 1584|  49.5M|  } else {
 1585|  49.5M|    if (!SafeReadBits(br, v.insert_len_extra_bits, &insert_len_extra) ||
  ------------------
  |  Branch (1585:9): [True: 80, False: 49.5M]
  ------------------
 1586|  49.5M|        !SafeReadBits(br, v.copy_len_extra_bits, &copy_length)) {
  ------------------
  |  Branch (1586:9): [True: 112, False: 49.5M]
  ------------------
 1587|    192|      BrotliBitReaderRestoreState(br, &memento);
 1588|    192|      return BROTLI_FALSE;
  ------------------
  |  |   53|    192|#define BROTLI_FALSE 0
  ------------------
 1589|    192|    }
 1590|  49.5M|  }
 1591|  78.9M|  s->copy_length = (int)copy_length + v.copy_len_offset;
 1592|  78.9M|  --s->block_length[1];
 1593|  78.9M|  *insert_length += (int)insert_len_extra;
 1594|  78.9M|  return BROTLI_TRUE;
  ------------------
  |  |   51|  78.9M|#define BROTLI_TRUE 1
  ------------------
 1595|  78.9M|}
decode.c:SafeReadBits:
 1481|  99.2M|    BrotliBitReader* const br, uint32_t n_bits, uint32_t* val) {
 1482|  99.2M|  if (n_bits != 0) {
  ------------------
  |  Branch (1482:7): [True: 23.1k, False: 99.1M]
  ------------------
 1483|  23.1k|    return BrotliSafeReadBits(br, n_bits, val);
 1484|  99.1M|  } else {
 1485|  99.1M|    *val = 0;
 1486|  99.1M|    return BROTLI_TRUE;
  ------------------
  |  |   51|  99.1M|#define BROTLI_TRUE 1
  ------------------
 1487|  99.1M|  }
 1488|  99.2M|}
decode.c:ReadCommand:
 1598|  29.3M|    BrotliDecoderState* s, BrotliBitReader* br, int* insert_length) {
 1599|  29.3M|  ReadCommandInternal(0, s, br, insert_length);
 1600|  29.3M|}
decode.c:PreloadSymbol:
  424|   593M|                                        uint32_t* value) {
  425|   593M|  if (safe) {
  ------------------
  |  Branch (425:7): [True: 44.9M, False: 548M]
  ------------------
  426|  44.9M|    return;
  427|  44.9M|  }
  428|   548M|  table += BrotliGetBits(br, HUFFMAN_TABLE_BITS);
  ------------------
  |  |   39|   548M|#define HUFFMAN_TABLE_BITS 8U
  ------------------
  429|   548M|  *bits = table->bits;
  430|   548M|  *value = table->value;
  431|   548M|}
decode.c:SafeDecodeLiteralBlockSwitch:
 1191|  6.47k|    BrotliDecoderState* s) {
 1192|  6.47k|  return DecodeLiteralBlockSwitchInternal(1, s);
 1193|  6.47k|}
decode.c:DecodeLiteralBlockSwitchInternal:
 1178|  85.2k|    int safe, BrotliDecoderState* s) {
 1179|  85.2k|  if (!DecodeBlockTypeAndLength(safe, s, 0)) {
  ------------------
  |  Branch (1179:7): [True: 104, False: 85.1k]
  ------------------
 1180|    104|    return BROTLI_FALSE;
  ------------------
  |  |   53|    104|#define BROTLI_FALSE 0
  ------------------
 1181|    104|  }
 1182|  85.1k|  PrepareLiteralDecoding(s);
 1183|  85.1k|  return BROTLI_TRUE;
  ------------------
  |  |   51|  85.1k|#define BROTLI_TRUE 1
  ------------------
 1184|  85.2k|}
decode.c:DecodeLiteralBlockSwitch:
 1186|  78.8k|static void BROTLI_NOINLINE DecodeLiteralBlockSwitch(BrotliDecoderState* s) {
 1187|  78.8k|  DecodeLiteralBlockSwitchInternal(0, s);
 1188|  78.8k|}
decode.c:ReadPreloadedSymbol:
  438|   539M|                                                  uint32_t* value) {
  439|   539M|  uint32_t result = *value;
  440|   539M|  if (BROTLI_PREDICT_FALSE(*bits > HUFFMAN_TABLE_BITS)) {
  ------------------
  |  |  318|   539M|#define BROTLI_PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (318:33): [True: 5.68k, False: 539M]
  |  |  ------------------
  ------------------
  441|  5.68k|    uint32_t val = BrotliGet16BitsUnmasked(br);
  442|  5.68k|    const HuffmanCode* ext = table + (val & HUFFMAN_TABLE_MASK) + *value;
  ------------------
  |  |   40|  5.68k|#define HUFFMAN_TABLE_MASK 0xFF
  ------------------
  443|  5.68k|    uint32_t mask = BitMask((*bits - HUFFMAN_TABLE_BITS));
  ------------------
  |  |   39|  5.68k|#define HUFFMAN_TABLE_BITS 8U
  ------------------
  444|  5.68k|    BrotliDropBits(br, HUFFMAN_TABLE_BITS);
  ------------------
  |  |   39|  5.68k|#define HUFFMAN_TABLE_BITS 8U
  ------------------
  445|  5.68k|    ext += (val >> HUFFMAN_TABLE_BITS) & mask;
  ------------------
  |  |   39|  5.68k|#define HUFFMAN_TABLE_BITS 8U
  ------------------
  446|  5.68k|    BrotliDropBits(br, ext->bits);
  447|  5.68k|    result = ext->value;
  448|   539M|  } else {
  449|   539M|    BrotliDropBits(br, *bits);
  450|   539M|  }
  451|   539M|  PreloadSymbol(0, table, br, bits, value);
  452|   539M|  return result;
  453|   539M|}
decode.c:ReadSymbol:
  364|  63.6M|                                         BrotliBitReader* br) {
  365|  63.6M|  return DecodeSymbol(BrotliGet16BitsUnmasked(br), table, br);
  366|  63.6M|}
decode.c:SafeDecodeDistanceBlockSwitch:
 1233|  5.27k|    BrotliDecoderState* s) {
 1234|  5.27k|  return DecodeDistanceBlockSwitchInternal(1, s);
 1235|  5.27k|}
decode.c:DecodeDistanceBlockSwitchInternal:
 1218|  43.4k|    int safe, BrotliDecoderState* s) {
 1219|  43.4k|  if (!DecodeBlockTypeAndLength(safe, s, 2)) {
  ------------------
  |  Branch (1219:7): [True: 97, False: 43.3k]
  ------------------
 1220|     97|    return BROTLI_FALSE;
  ------------------
  |  |   53|     97|#define BROTLI_FALSE 0
  ------------------
 1221|     97|  }
 1222|  43.3k|  s->dist_context_map_slice = s->dist_context_map +
 1223|  43.3k|      (s->block_type_rb[5] << BROTLI_DISTANCE_CONTEXT_BITS);
  ------------------
  |  |   56|  43.3k|#define BROTLI_DISTANCE_CONTEXT_BITS 2
  ------------------
 1224|  43.3k|  s->dist_htree_index = s->dist_context_map_slice[s->distance_context];
 1225|  43.3k|  return BROTLI_TRUE;
  ------------------
  |  |   51|  43.3k|#define BROTLI_TRUE 1
  ------------------
 1226|  43.4k|}
decode.c:DecodeDistanceBlockSwitch:
 1228|  38.1k|static void BROTLI_NOINLINE DecodeDistanceBlockSwitch(BrotliDecoderState* s) {
 1229|  38.1k|  DecodeDistanceBlockSwitchInternal(0, s);
 1230|  38.1k|}
decode.c:SafeReadDistance:
 1555|  10.0M|    BrotliDecoderState* s, BrotliBitReader* br) {
 1556|  10.0M|  return ReadDistanceInternal(1, s, br);
 1557|  10.0M|}
decode.c:ReadDistanceInternal:
 1492|  17.8M|    int safe, BrotliDecoderState* s, BrotliBitReader* br) {
 1493|  17.8M|  int distval;
 1494|  17.8M|  BrotliBitReaderState memento;
 1495|  17.8M|  HuffmanCode* distance_tree = s->distance_hgroup.htrees[s->dist_htree_index];
 1496|  17.8M|  if (!safe) {
  ------------------
  |  Branch (1496:7): [True: 7.83M, False: 10.0M]
  ------------------
 1497|  7.83M|    s->distance_code = (int)ReadSymbol(distance_tree, br);
 1498|  10.0M|  } else {
 1499|  10.0M|    uint32_t code;
 1500|  10.0M|    BrotliBitReaderSaveState(br, &memento);
 1501|  10.0M|    if (!SafeReadSymbol(distance_tree, br, &code)) {
  ------------------
  |  Branch (1501:9): [True: 28, False: 10.0M]
  ------------------
 1502|     28|      return BROTLI_FALSE;
  ------------------
  |  |   53|     28|#define BROTLI_FALSE 0
  ------------------
 1503|     28|    }
 1504|  10.0M|    s->distance_code = (int)code;
 1505|  10.0M|  }
 1506|       |  /* Convert the distance code to the actual distance by possibly
 1507|       |     looking up past distances from the s->ringbuffer. */
 1508|  17.8M|  s->distance_context = 0;
 1509|  17.8M|  if ((s->distance_code & ~0xF) == 0) {
  ------------------
  |  Branch (1509:7): [True: 10.3M, False: 7.50M]
  ------------------
 1510|  10.3M|    TakeDistanceFromRingBuffer(s);
 1511|  10.3M|    --s->block_length[2];
 1512|  10.3M|    return BROTLI_TRUE;
  ------------------
  |  |   51|  10.3M|#define BROTLI_TRUE 1
  ------------------
 1513|  10.3M|  }
 1514|  7.50M|  distval = s->distance_code - (int)s->num_direct_distance_codes;
 1515|  7.50M|  if (distval >= 0) {
  ------------------
  |  Branch (1515:7): [True: 2.75M, False: 4.74M]
  ------------------
 1516|  2.75M|    uint32_t nbits;
 1517|  2.75M|    int postfix;
 1518|  2.75M|    int offset;
 1519|  2.75M|    if (!safe && (s->distance_postfix_bits == 0)) {
  ------------------
  |  Branch (1519:9): [True: 2.74M, False: 7.20k]
  |  Branch (1519:18): [True: 7.92k, False: 2.74M]
  ------------------
 1520|  7.92k|      nbits = ((uint32_t)distval >> 1) + 1;
 1521|  7.92k|      offset = ((2 + (distval & 1)) << nbits) - 4;
 1522|  7.92k|      s->distance_code = (int)s->num_direct_distance_codes + offset +
 1523|  7.92k|                         (int)BrotliReadBits(br, nbits);
 1524|  2.74M|    } else {
 1525|       |      /* This branch also works well when s->distance_postfix_bits == 0. */
 1526|  2.74M|      uint32_t bits;
 1527|  2.74M|      postfix = distval & s->distance_postfix_mask;
 1528|  2.74M|      distval >>= s->distance_postfix_bits;
 1529|  2.74M|      nbits = ((uint32_t)distval >> 1) + 1;
 1530|  2.74M|      if (safe) {
  ------------------
  |  Branch (1530:11): [True: 7.20k, False: 2.74M]
  ------------------
 1531|  7.20k|        if (!SafeReadBits(br, nbits, &bits)) {
  ------------------
  |  Branch (1531:13): [True: 213, False: 6.99k]
  ------------------
 1532|    213|          s->distance_code = -1;  /* Restore precondition. */
 1533|    213|          BrotliBitReaderRestoreState(br, &memento);
 1534|    213|          return BROTLI_FALSE;
  ------------------
  |  |   53|    213|#define BROTLI_FALSE 0
  ------------------
 1535|    213|        }
 1536|  2.74M|      } else {
 1537|  2.74M|        bits = BrotliReadBits(br, nbits);
 1538|  2.74M|      }
 1539|  2.74M|      offset = ((2 + (distval & 1)) << nbits) - 4;
 1540|  2.74M|      s->distance_code = (int)s->num_direct_distance_codes +
 1541|  2.74M|          ((offset + (int)bits) << s->distance_postfix_bits) + postfix;
 1542|  2.74M|    }
 1543|  2.75M|  }
 1544|  7.50M|  s->distance_code = s->distance_code - BROTLI_NUM_DISTANCE_SHORT_CODES + 1;
  ------------------
  |  |   37|  7.50M|#define BROTLI_NUM_DISTANCE_SHORT_CODES 16
  ------------------
 1545|  7.50M|  --s->block_length[2];
 1546|  7.50M|  return BROTLI_TRUE;
  ------------------
  |  |   51|  7.50M|#define BROTLI_TRUE 1
  ------------------
 1547|  7.50M|}
decode.c:TakeDistanceFromRingBuffer:
 1449|  10.3M|static BROTLI_INLINE void TakeDistanceFromRingBuffer(BrotliDecoderState* s) {
 1450|  10.3M|  if (s->distance_code == 0) {
  ------------------
  |  Branch (1450:7): [True: 4.90M, False: 5.44M]
  ------------------
 1451|  4.90M|    --s->dist_rb_idx;
 1452|  4.90M|    s->distance_code = s->dist_rb[s->dist_rb_idx & 3];
 1453|       |    /* Compensate double distance-ring-buffer roll for dictionary items. */
 1454|  4.90M|    s->distance_context = 1;
 1455|  5.44M|  } else {
 1456|  5.44M|    int distance_code = s->distance_code << 1;
 1457|       |    /* kDistanceShortCodeIndexOffset has 2-bit values from LSB:
 1458|       |        3, 2, 1, 0, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2 */
 1459|  5.44M|    const uint32_t kDistanceShortCodeIndexOffset = 0xAAAFFF1B;
 1460|       |    /* kDistanceShortCodeValueOffset has 2-bit values from LSB:
 1461|       |       -0, 0,-0, 0,-1, 1,-2, 2,-3, 3,-1, 1,-2, 2,-3, 3 */
 1462|  5.44M|    const uint32_t kDistanceShortCodeValueOffset = 0xFA5FA500;
 1463|  5.44M|    int v = (s->dist_rb_idx +
 1464|  5.44M|        (int)(kDistanceShortCodeIndexOffset >> distance_code)) & 0x3;
 1465|  5.44M|    s->distance_code = s->dist_rb[v];
 1466|  5.44M|    v = (int)(kDistanceShortCodeValueOffset >> distance_code) & 0x3;
 1467|  5.44M|    if ((distance_code & 0x3) != 0) {
  ------------------
  |  Branch (1467:9): [True: 1.87M, False: 3.57M]
  ------------------
 1468|  1.87M|      s->distance_code += v;
 1469|  3.57M|    } else {
 1470|  3.57M|      s->distance_code -= v;
 1471|  3.57M|      if (s->distance_code <= 0) {
  ------------------
  |  Branch (1471:11): [True: 37, False: 3.57M]
  ------------------
 1472|       |        /* A huge distance will cause a BROTLI_FAILURE() soon.
 1473|       |           This is a little faster than failing here. */
 1474|     37|        s->distance_code = 0x7FFFFFFF;
 1475|     37|      }
 1476|  3.57M|    }
 1477|  5.44M|  }
 1478|  10.3M|}
decode.c:ReadDistance:
 1550|  7.83M|    BrotliDecoderState* s, BrotliBitReader* br) {
 1551|  7.83M|  ReadDistanceInternal(0, s, br);
 1552|  7.83M|}
decode.c:memmove16:
  169|  78.8M|static BROTLI_INLINE void memmove16(uint8_t* dst, uint8_t* src) {
  170|       |#if defined(__ARM_NEON__)
  171|       |  vst1q_u8(dst, vld1q_u8(src));
  172|       |#else
  173|  78.8M|  uint32_t buffer[4];
  174|  78.8M|  memcpy(buffer, src, 16);
  175|  78.8M|  memcpy(dst, buffer, 16);
  176|  78.8M|#endif
  177|  78.8M|}
decode.c:SafeProcessCommands:
 1924|  3.64k|    BrotliDecoderState* s) {
 1925|  3.64k|  return ProcessCommandsInternal(1, s);
 1926|  3.64k|}
decode.c:WrapRingBuffer:
 1292|  4.72k|static void BROTLI_NOINLINE WrapRingBuffer(BrotliDecoderState* s) {
 1293|  4.72k|  if (s->should_wrap_ringbuffer) {
  ------------------
  |  Branch (1293:7): [True: 484, False: 4.23k]
  ------------------
 1294|    484|    memcpy(s->ringbuffer, s->ringbuffer_end, (size_t)s->pos);
 1295|    484|    s->should_wrap_ringbuffer = 0;
 1296|    484|  }
 1297|  4.72k|}
decode.c:UnwrittenBytes:
 1237|  7.48k|static size_t UnwrittenBytes(const BrotliDecoderState* s, BROTLI_BOOL wrap) {
 1238|  7.48k|  size_t pos = wrap && s->pos > s->ringbuffer_size ?
  ------------------
  |  Branch (1238:16): [True: 7.48k, False: 0]
  |  Branch (1238:24): [True: 509, False: 6.97k]
  ------------------
 1239|  6.97k|      (size_t)s->ringbuffer_size : (size_t)(s->pos);
 1240|  7.48k|  size_t partial_pos_rb = (s->rb_roundtrips * (size_t)s->ringbuffer_size) + pos;
 1241|  7.48k|  return partial_pos_rb - s->partial_pos_out;
 1242|  7.48k|}

BrotliBuildCodeLengthsHuffmanTable:
  106|  26.1k|                                        uint16_t* count) {
  107|  26.1k|  HuffmanCode code;       /* current table entry */
  108|  26.1k|  int symbol;             /* symbol index in original or sorted table */
  109|  26.1k|  brotli_reg_t key;       /* prefix code */
  ------------------
  |  |  138|  26.1k|#define brotli_reg_t uint64_t
  ------------------
  110|  26.1k|  brotli_reg_t key_step;  /* prefix code addend */
  ------------------
  |  |  138|  26.1k|#define brotli_reg_t uint64_t
  ------------------
  111|  26.1k|  int step;               /* step size to replicate values in current table */
  112|  26.1k|  int table_size;         /* size of current table */
  113|  26.1k|  int sorted[BROTLI_CODE_LENGTH_CODES];  /* symbols sorted by code length */
  114|       |  /* offsets in sorted table for each length */
  115|  26.1k|  int offset[BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH + 1];
  116|  26.1k|  int bits;
  117|  26.1k|  int bits_count;
  118|  26.1k|  BROTLI_DCHECK(BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH <=
  119|  26.1k|                BROTLI_REVERSE_BITS_MAX);
  120|       |
  121|       |  /* Generate offsets into sorted symbol table by code length. */
  122|  26.1k|  symbol = -1;
  123|  26.1k|  bits = 1;
  124|  26.1k|  BROTLI_REPEAT(BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH, {
  ------------------
  |  |  371|  26.1k|#define BROTLI_REPEAT(N, X) {     \
  |  |  372|  26.1k|  if ((N & 1) != 0) {X;}          \
  |  |  ------------------
  |  |  |  Branch (372:7): [Folded - Ignored]
  |  |  ------------------
  |  |  373|  26.1k|  if ((N & 2) != 0) {X; X;}       \
  |  |  ------------------
  |  |  |  Branch (373:7): [Folded - Ignored]
  |  |  ------------------
  |  |  374|  26.1k|  if ((N & 4) != 0) {X; X; X; X;} \
  |  |  ------------------
  |  |  |  Branch (374:7): [Folded - Ignored]
  |  |  ------------------
  |  |  375|  26.1k|}
  ------------------
  125|  26.1k|    symbol += count[bits];
  126|  26.1k|    offset[bits] = symbol;
  127|  26.1k|    bits++;
  128|  26.1k|  });
  129|       |  /* Symbols with code length 0 are placed after all other symbols. */
  130|  26.1k|  offset[0] = BROTLI_CODE_LENGTH_CODES - 1;
  ------------------
  |  |   27|  26.1k|#define BROTLI_CODE_LENGTH_CODES (BROTLI_REPEAT_ZERO_CODE_LENGTH + 1)
  |  |  ------------------
  |  |  |  |   26|  26.1k|#define BROTLI_REPEAT_ZERO_CODE_LENGTH 17
  |  |  ------------------
  ------------------
  131|       |
  132|       |  /* Sort symbols by length, by symbol order within each length. */
  133|  26.1k|  symbol = BROTLI_CODE_LENGTH_CODES;
  ------------------
  |  |   27|  26.1k|#define BROTLI_CODE_LENGTH_CODES (BROTLI_REPEAT_ZERO_CODE_LENGTH + 1)
  |  |  ------------------
  |  |  |  |   26|  26.1k|#define BROTLI_REPEAT_ZERO_CODE_LENGTH 17
  |  |  ------------------
  ------------------
  134|  78.4k|  do {
  135|  78.4k|    BROTLI_REPEAT(6, {
  ------------------
  |  |  371|  78.4k|#define BROTLI_REPEAT(N, X) {     \
  |  |  372|  78.4k|  if ((N & 1) != 0) {X;}          \
  |  |  ------------------
  |  |  |  Branch (372:7): [Folded - Ignored]
  |  |  ------------------
  |  |  373|  78.4k|  if ((N & 2) != 0) {X; X;}       \
  |  |  ------------------
  |  |  |  Branch (373:7): [Folded - Ignored]
  |  |  ------------------
  |  |  374|  78.4k|  if ((N & 4) != 0) {X; X; X; X;} \
  |  |  ------------------
  |  |  |  Branch (374:7): [Folded - Ignored]
  |  |  ------------------
  |  |  375|  78.4k|}
  ------------------
  136|  78.4k|      symbol--;
  137|  78.4k|      sorted[offset[code_lengths[symbol]]--] = symbol;
  138|  78.4k|    });
  139|  78.4k|  } while (symbol != 0);
  ------------------
  |  Branch (139:12): [True: 52.3k, False: 26.1k]
  ------------------
  140|       |
  141|  26.1k|  table_size = 1 << BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH;
  ------------------
  |  |   34|  26.1k|#define BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH 5
  ------------------
  142|       |
  143|       |  /* Special case: all symbols but one have 0 code length. */
  144|  26.1k|  if (offset[0] == 0) {
  ------------------
  |  Branch (144:7): [True: 483, False: 25.6k]
  ------------------
  145|    483|    code.bits = 0;
  146|    483|    code.value = (uint16_t)sorted[0];
  147|  15.9k|    for (key = 0; key < (brotli_reg_t)table_size; ++key) {
  ------------------
  |  Branch (147:19): [True: 15.4k, False: 483]
  ------------------
  148|  15.4k|      table[key] = code;
  149|  15.4k|    }
  150|    483|    return;
  151|    483|  }
  152|       |
  153|       |  /* Fill in table. */
  154|  25.6k|  key = 0;
  155|  25.6k|  key_step = BROTLI_REVERSE_BITS_LOWEST;
  ------------------
  |  |   65|  25.6k|  ((brotli_reg_t)1 << (BROTLI_REVERSE_BITS_MAX - 1 + BROTLI_REVERSE_BITS_BASE))
  |  |  ------------------
  |  |  |  |   21|  25.6k|#define BROTLI_REVERSE_BITS_MAX 8
  |  |  ------------------
  |  |                 ((brotli_reg_t)1 << (BROTLI_REVERSE_BITS_MAX - 1 + BROTLI_REVERSE_BITS_BASE))
  |  |  ------------------
  |  |  |  |   27|  25.6k|#define BROTLI_REVERSE_BITS_BASE 0
  |  |  ------------------
  ------------------
  156|  25.6k|  symbol = 0;
  157|  25.6k|  bits = 1;
  158|  25.6k|  step = 2;
  159|   128k|  do {
  160|   128k|    code.bits = (uint8_t)bits;
  161|   305k|    for (bits_count = count[bits]; bits_count != 0; --bits_count) {
  ------------------
  |  Branch (161:36): [True: 177k, False: 128k]
  ------------------
  162|   177k|      code.value = (uint16_t)sorted[symbol++];
  163|   177k|      ReplicateValue(&table[BrotliReverseBits(key)], step, table_size, code);
  164|   177k|      key += key_step;
  165|   177k|    }
  166|   128k|    step <<= 1;
  167|   128k|    key_step >>= 1;
  168|   128k|  } while (++bits <= BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH);
  ------------------
  |  |   34|   128k|#define BROTLI_HUFFMAN_MAX_CODE_LENGTH_CODE_LENGTH 5
  ------------------
  |  Branch (168:12): [True: 102k, False: 25.6k]
  ------------------
  169|  25.6k|}
BrotliBuildHuffmanTable:
  174|  25.8k|                                 uint16_t* count) {
  175|  25.8k|  HuffmanCode code;       /* current table entry */
  176|  25.8k|  HuffmanCode* table;     /* next available space in table */
  177|  25.8k|  int len;                /* current code length */
  178|  25.8k|  int symbol;             /* symbol index in original or sorted table */
  179|  25.8k|  brotli_reg_t key;       /* prefix code */
  ------------------
  |  |  138|  25.8k|#define brotli_reg_t uint64_t
  ------------------
  180|  25.8k|  brotli_reg_t key_step;  /* prefix code addend */
  ------------------
  |  |  138|  25.8k|#define brotli_reg_t uint64_t
  ------------------
  181|  25.8k|  brotli_reg_t sub_key;   /* 2nd level table prefix code */
  ------------------
  |  |  138|  25.8k|#define brotli_reg_t uint64_t
  ------------------
  182|  25.8k|  brotli_reg_t sub_key_step;  /* 2nd level table prefix code addend */
  ------------------
  |  |  138|  25.8k|#define brotli_reg_t uint64_t
  ------------------
  183|  25.8k|  int step;               /* step size to replicate values in current table */
  184|  25.8k|  int table_bits;         /* key length of current table */
  185|  25.8k|  int table_size;         /* size of current table */
  186|  25.8k|  int total_size;         /* sum of root table size and 2nd level table sizes */
  187|  25.8k|  int max_length = -1;
  188|  25.8k|  int bits;
  189|  25.8k|  int bits_count;
  190|       |
  191|  25.8k|  BROTLI_DCHECK(root_bits <= BROTLI_REVERSE_BITS_MAX);
  192|  25.8k|  BROTLI_DCHECK(BROTLI_HUFFMAN_MAX_CODE_LENGTH - root_bits <=
  193|  25.8k|                BROTLI_REVERSE_BITS_MAX);
  194|       |
  195|   234k|  while (symbol_lists[max_length] == 0xFFFF) max_length--;
  ------------------
  |  Branch (195:10): [True: 208k, False: 25.8k]
  ------------------
  196|  25.8k|  max_length += BROTLI_HUFFMAN_MAX_CODE_LENGTH + 1;
  ------------------
  |  |   19|  25.8k|#define BROTLI_HUFFMAN_MAX_CODE_LENGTH 15
  ------------------
  197|       |
  198|  25.8k|  table = root_table;
  199|  25.8k|  table_bits = root_bits;
  200|  25.8k|  table_size = 1 << table_bits;
  201|  25.8k|  total_size = table_size;
  202|       |
  203|       |  /* Fill in the root table. Reduce the table size to if possible,
  204|       |     and create the repetitions by memcpy. */
  205|  25.8k|  if (table_bits > max_length) {
  ------------------
  |  Branch (205:7): [True: 15.1k, False: 10.6k]
  ------------------
  206|  15.1k|    table_bits = max_length;
  207|  15.1k|    table_size = 1 << table_bits;
  208|  15.1k|  }
  209|  25.8k|  key = 0;
  210|  25.8k|  key_step = BROTLI_REVERSE_BITS_LOWEST;
  ------------------
  |  |   65|  25.8k|  ((brotli_reg_t)1 << (BROTLI_REVERSE_BITS_MAX - 1 + BROTLI_REVERSE_BITS_BASE))
  |  |  ------------------
  |  |  |  |   21|  25.8k|#define BROTLI_REVERSE_BITS_MAX 8
  |  |  ------------------
  |  |                 ((brotli_reg_t)1 << (BROTLI_REVERSE_BITS_MAX - 1 + BROTLI_REVERSE_BITS_BASE))
  |  |  ------------------
  |  |  |  |   27|  25.8k|#define BROTLI_REVERSE_BITS_BASE 0
  |  |  ------------------
  ------------------
  211|  25.8k|  bits = 1;
  212|  25.8k|  step = 2;
  213|   157k|  do {
  214|   157k|    code.bits = (uint8_t)bits;
  215|   157k|    symbol = bits - (BROTLI_HUFFMAN_MAX_CODE_LENGTH + 1);
  ------------------
  |  |   19|   157k|#define BROTLI_HUFFMAN_MAX_CODE_LENGTH 15
  ------------------
  216|  1.18M|    for (bits_count = count[bits]; bits_count != 0; --bits_count) {
  ------------------
  |  Branch (216:36): [True: 1.02M, False: 157k]
  ------------------
  217|  1.02M|      symbol = symbol_lists[symbol];
  218|  1.02M|      code.value = (uint16_t)symbol;
  219|  1.02M|      ReplicateValue(&table[BrotliReverseBits(key)], step, table_size, code);
  220|  1.02M|      key += key_step;
  221|  1.02M|    }
  222|   157k|    step <<= 1;
  223|   157k|    key_step >>= 1;
  224|   157k|  } while (++bits <= table_bits);
  ------------------
  |  Branch (224:12): [True: 131k, False: 25.8k]
  ------------------
  225|       |
  226|       |  /* If root_bits != table_bits then replicate to fill the remaining slots. */
  227|  74.8k|  while (total_size != table_size) {
  ------------------
  |  Branch (227:10): [True: 49.0k, False: 25.8k]
  ------------------
  228|  49.0k|    memcpy(&table[table_size], &table[0],
  229|  49.0k|           (size_t)table_size * sizeof(table[0]));
  230|  49.0k|    table_size <<= 1;
  231|  49.0k|  }
  232|       |
  233|       |  /* Fill in 2nd level tables and add pointers to root table. */
  234|  25.8k|  key_step = BROTLI_REVERSE_BITS_LOWEST >> (root_bits - 1);
  ------------------
  |  |   65|  25.8k|  ((brotli_reg_t)1 << (BROTLI_REVERSE_BITS_MAX - 1 + BROTLI_REVERSE_BITS_BASE))
  |  |  ------------------
  |  |  |  |   21|  25.8k|#define BROTLI_REVERSE_BITS_MAX 8
  |  |  ------------------
  |  |                 ((brotli_reg_t)1 << (BROTLI_REVERSE_BITS_MAX - 1 + BROTLI_REVERSE_BITS_BASE))
  |  |  ------------------
  |  |  |  |   27|  25.8k|#define BROTLI_REVERSE_BITS_BASE 0
  |  |  ------------------
  ------------------
  235|  25.8k|  sub_key = (BROTLI_REVERSE_BITS_LOWEST << 1);
  ------------------
  |  |   65|  25.8k|  ((brotli_reg_t)1 << (BROTLI_REVERSE_BITS_MAX - 1 + BROTLI_REVERSE_BITS_BASE))
  |  |  ------------------
  |  |  |  |   21|  25.8k|#define BROTLI_REVERSE_BITS_MAX 8
  |  |  ------------------
  |  |                 ((brotli_reg_t)1 << (BROTLI_REVERSE_BITS_MAX - 1 + BROTLI_REVERSE_BITS_BASE))
  |  |  ------------------
  |  |  |  |   27|  25.8k|#define BROTLI_REVERSE_BITS_BASE 0
  |  |  ------------------
  ------------------
  236|  25.8k|  sub_key_step = BROTLI_REVERSE_BITS_LOWEST;
  ------------------
  |  |   65|  25.8k|  ((brotli_reg_t)1 << (BROTLI_REVERSE_BITS_MAX - 1 + BROTLI_REVERSE_BITS_BASE))
  |  |  ------------------
  |  |  |  |   21|  25.8k|#define BROTLI_REVERSE_BITS_MAX 8
  |  |  ------------------
  |  |                 ((brotli_reg_t)1 << (BROTLI_REVERSE_BITS_MAX - 1 + BROTLI_REVERSE_BITS_BASE))
  |  |  ------------------
  |  |  |  |   27|  25.8k|#define BROTLI_REVERSE_BITS_BASE 0
  |  |  ------------------
  ------------------
  237|  47.1k|  for (len = root_bits + 1, step = 2; len <= max_length; ++len) {
  ------------------
  |  Branch (237:39): [True: 21.3k, False: 25.8k]
  ------------------
  238|  21.3k|    symbol = len - (BROTLI_HUFFMAN_MAX_CODE_LENGTH + 1);
  ------------------
  |  |   19|  21.3k|#define BROTLI_HUFFMAN_MAX_CODE_LENGTH 15
  ------------------
  239|   737k|    for (; count[len] != 0; --count[len]) {
  ------------------
  |  Branch (239:12): [True: 716k, False: 21.3k]
  ------------------
  240|   716k|      if (sub_key == (BROTLI_REVERSE_BITS_LOWEST << 1U)) {
  ------------------
  |  |   65|   716k|  ((brotli_reg_t)1 << (BROTLI_REVERSE_BITS_MAX - 1 + BROTLI_REVERSE_BITS_BASE))
  |  |  ------------------
  |  |  |  |   21|   716k|#define BROTLI_REVERSE_BITS_MAX 8
  |  |  ------------------
  |  |                 ((brotli_reg_t)1 << (BROTLI_REVERSE_BITS_MAX - 1 + BROTLI_REVERSE_BITS_BASE))
  |  |  ------------------
  |  |  |  |   27|   716k|#define BROTLI_REVERSE_BITS_BASE 0
  |  |  ------------------
  ------------------
  |  Branch (240:11): [True: 229k, False: 486k]
  ------------------
  241|   229k|        table += table_size;
  242|   229k|        table_bits = NextTableBitSize(count, len, root_bits);
  243|   229k|        table_size = 1 << table_bits;
  244|   229k|        total_size += table_size;
  245|   229k|        sub_key = BrotliReverseBits(key);
  246|   229k|        key += key_step;
  247|   229k|        root_table[sub_key].bits = (uint8_t)(table_bits + root_bits);
  248|   229k|        root_table[sub_key].value =
  249|   229k|            (uint16_t)(((size_t)(table - root_table)) - sub_key);
  250|   229k|        sub_key = 0;
  251|   229k|      }
  252|   716k|      code.bits = (uint8_t)(len - root_bits);
  253|   716k|      symbol = symbol_lists[symbol];
  254|   716k|      code.value = (uint16_t)symbol;
  255|   716k|      ReplicateValue(
  256|   716k|          &table[BrotliReverseBits(sub_key)], step, table_size, code);
  257|   716k|      sub_key += sub_key_step;
  258|   716k|    }
  259|  21.3k|    step <<= 1;
  260|  21.3k|    sub_key_step >>= 1;
  261|  21.3k|  }
  262|  25.8k|  return (uint32_t)total_size;
  263|  25.8k|}
BrotliBuildSimpleHuffmanTable:
  268|  63.3k|                                       uint32_t num_symbols) {
  269|  63.3k|  uint32_t table_size = 1;
  270|  63.3k|  const uint32_t goal_size = 1U << root_bits;
  271|  63.3k|  switch (num_symbols) {
  ------------------
  |  Branch (271:11): [True: 0, False: 63.3k]
  ------------------
  272|  34.3k|    case 0:
  ------------------
  |  Branch (272:5): [True: 34.3k, False: 28.9k]
  ------------------
  273|  34.3k|      table[0].bits = 0;
  274|  34.3k|      table[0].value = val[0];
  275|  34.3k|      break;
  276|  12.5k|    case 1:
  ------------------
  |  Branch (276:5): [True: 12.5k, False: 50.7k]
  ------------------
  277|  12.5k|      table[0].bits = 1;
  278|  12.5k|      table[1].bits = 1;
  279|  12.5k|      if (val[1] > val[0]) {
  ------------------
  |  Branch (279:11): [True: 11.1k, False: 1.45k]
  ------------------
  280|  11.1k|        table[0].value = val[0];
  281|  11.1k|        table[1].value = val[1];
  282|  11.1k|      } else {
  283|  1.45k|        table[0].value = val[1];
  284|  1.45k|        table[1].value = val[0];
  285|  1.45k|      }
  286|  12.5k|      table_size = 2;
  287|  12.5k|      break;
  288|  14.5k|    case 2:
  ------------------
  |  Branch (288:5): [True: 14.5k, False: 48.8k]
  ------------------
  289|  14.5k|      table[0].bits = 1;
  290|  14.5k|      table[0].value = val[0];
  291|  14.5k|      table[2].bits = 1;
  292|  14.5k|      table[2].value = val[0];
  293|  14.5k|      if (val[2] > val[1]) {
  ------------------
  |  Branch (293:11): [True: 7.54k, False: 6.97k]
  ------------------
  294|  7.54k|        table[1].value = val[1];
  295|  7.54k|        table[3].value = val[2];
  296|  7.54k|      } else {
  297|  6.97k|        table[1].value = val[2];
  298|  6.97k|        table[3].value = val[1];
  299|  6.97k|      }
  300|  14.5k|      table[1].bits = 2;
  301|  14.5k|      table[3].bits = 2;
  302|  14.5k|      table_size = 4;
  303|  14.5k|      break;
  304|    988|    case 3: {
  ------------------
  |  Branch (304:5): [True: 988, False: 62.3k]
  ------------------
  305|    988|      int i, k;
  306|  3.95k|      for (i = 0; i < 3; ++i) {
  ------------------
  |  Branch (306:19): [True: 2.96k, False: 988]
  ------------------
  307|  8.89k|        for (k = i + 1; k < 4; ++k) {
  ------------------
  |  Branch (307:25): [True: 5.92k, False: 2.96k]
  ------------------
  308|  5.92k|          if (val[k] < val[i]) {
  ------------------
  |  Branch (308:15): [True: 2.49k, False: 3.43k]
  ------------------
  309|  2.49k|            uint16_t t = val[k];
  310|  2.49k|            val[k] = val[i];
  311|  2.49k|            val[i] = t;
  312|  2.49k|          }
  313|  5.92k|        }
  314|  2.96k|      }
  315|  4.94k|      for (i = 0; i < 4; ++i) {
  ------------------
  |  Branch (315:19): [True: 3.95k, False: 988]
  ------------------
  316|  3.95k|        table[i].bits = 2;
  317|  3.95k|      }
  318|    988|      table[0].value = val[0];
  319|    988|      table[2].value = val[1];
  320|    988|      table[1].value = val[2];
  321|    988|      table[3].value = val[3];
  322|    988|      table_size = 4;
  323|    988|      break;
  324|      0|    }
  325|    881|    case 4: {
  ------------------
  |  Branch (325:5): [True: 881, False: 62.4k]
  ------------------
  326|    881|      int i;
  327|    881|      if (val[3] < val[2]) {
  ------------------
  |  Branch (327:11): [True: 432, False: 449]
  ------------------
  328|    432|        uint16_t t = val[3];
  329|    432|        val[3] = val[2];
  330|    432|        val[2] = t;
  331|    432|      }
  332|  7.04k|      for (i = 0; i < 7; ++i) {
  ------------------
  |  Branch (332:19): [True: 6.16k, False: 881]
  ------------------
  333|  6.16k|        table[i].value = val[0];
  334|  6.16k|        table[i].bits = (uint8_t)(1 + (i & 1));
  335|  6.16k|      }
  336|    881|      table[1].value = val[1];
  337|    881|      table[3].value = val[2];
  338|    881|      table[5].value = val[1];
  339|    881|      table[7].value = val[3];
  340|    881|      table[3].bits = 3;
  341|    881|      table[7].bits = 3;
  342|    881|      table_size = 8;
  343|    881|      break;
  344|      0|    }
  345|  63.3k|  }
  346|   523k|  while (table_size != goal_size) {
  ------------------
  |  Branch (346:10): [True: 460k, False: 63.3k]
  ------------------
  347|   460k|    memcpy(&table[table_size], &table[0],
  348|   460k|           (size_t)table_size * sizeof(table[0]));
  349|   460k|    table_size <<= 1;
  350|   460k|  }
  351|  63.3k|  return goal_size;
  352|  63.3k|}
huffman.c:ReplicateValue:
   82|  1.91M|                                         HuffmanCode code) {
   83|  4.66M|  do {
   84|  4.66M|    end -= step;
   85|  4.66M|    table[end] = code;
   86|  4.66M|  } while (end > 0);
  ------------------
  |  Branch (86:12): [True: 2.74M, False: 1.91M]
  ------------------
   87|  1.91M|}
huffman.c:BrotliReverseBits:
   70|  2.14M|static BROTLI_INLINE brotli_reg_t BrotliReverseBits(brotli_reg_t num) {
   71|       |#ifdef BROTLI_RBIT
   72|       |  return BROTLI_RBIT(num);
   73|       |#else
   74|  2.14M|  return kReverseBits[num];
   75|  2.14M|#endif
   76|  2.14M|}
huffman.c:NextTableBitSize:
   93|   229k|                                          int len, int root_bits) {
   94|   229k|  int left = 1 << (len - root_bits);
   95|   237k|  while (len < BROTLI_HUFFMAN_MAX_CODE_LENGTH) {
  ------------------
  |  |   19|   237k|#define BROTLI_HUFFMAN_MAX_CODE_LENGTH 15
  ------------------
  |  Branch (95:10): [True: 237k, False: 91]
  ------------------
   96|   237k|    left -= count[len];
   97|   237k|    if (left <= 0) break;
  ------------------
  |  Branch (97:9): [True: 229k, False: 8.31k]
  ------------------
   98|  8.31k|    ++len;
   99|  8.31k|    left <<= 1;
  100|  8.31k|  }
  101|   229k|  return len - root_bits;
  102|   229k|}

BrotliDecoderStateInit:
   19|  6.02k|    brotli_alloc_func alloc_func, brotli_free_func free_func, void* opaque) {
   20|  6.02k|  if (!alloc_func) {
  ------------------
  |  Branch (20:7): [True: 6.02k, False: 0]
  ------------------
   21|  6.02k|    s->alloc_func = BrotliDefaultAllocFunc;
   22|  6.02k|    s->free_func = BrotliDefaultFreeFunc;
   23|  6.02k|    s->memory_manager_opaque = 0;
   24|  6.02k|  } else {
   25|      0|    s->alloc_func = alloc_func;
   26|      0|    s->free_func = free_func;
   27|      0|    s->memory_manager_opaque = opaque;
   28|      0|  }
   29|       |
   30|  6.02k|  s->error_code = 0; /* BROTLI_DECODER_NO_ERROR */
   31|       |
   32|  6.02k|  BrotliInitBitReader(&s->br);
   33|  6.02k|  s->state = BROTLI_STATE_UNINITED;
   34|  6.02k|  s->large_window = 0;
   35|  6.02k|  s->substate_metablock_header = BROTLI_STATE_METABLOCK_HEADER_NONE;
   36|  6.02k|  s->substate_tree_group = BROTLI_STATE_TREE_GROUP_NONE;
   37|  6.02k|  s->substate_context_map = BROTLI_STATE_CONTEXT_MAP_NONE;
   38|  6.02k|  s->substate_uncompressed = BROTLI_STATE_UNCOMPRESSED_NONE;
   39|  6.02k|  s->substate_huffman = BROTLI_STATE_HUFFMAN_NONE;
   40|  6.02k|  s->substate_decode_uint8 = BROTLI_STATE_DECODE_UINT8_NONE;
   41|  6.02k|  s->substate_read_block_length = BROTLI_STATE_READ_BLOCK_LENGTH_NONE;
   42|       |
   43|  6.02k|  s->buffer_length = 0;
   44|  6.02k|  s->loop_counter = 0;
   45|  6.02k|  s->pos = 0;
   46|  6.02k|  s->rb_roundtrips = 0;
   47|  6.02k|  s->partial_pos_out = 0;
   48|       |
   49|  6.02k|  s->block_type_trees = NULL;
   50|  6.02k|  s->block_len_trees = NULL;
   51|  6.02k|  s->ringbuffer = NULL;
   52|  6.02k|  s->ringbuffer_size = 0;
   53|  6.02k|  s->new_ringbuffer_size = 0;
   54|  6.02k|  s->ringbuffer_mask = 0;
   55|       |
   56|  6.02k|  s->context_map = NULL;
   57|  6.02k|  s->context_modes = NULL;
   58|  6.02k|  s->dist_context_map = NULL;
   59|  6.02k|  s->context_map_slice = NULL;
   60|  6.02k|  s->dist_context_map_slice = NULL;
   61|       |
   62|  6.02k|  s->sub_loop_counter = 0;
   63|       |
   64|  6.02k|  s->literal_hgroup.codes = NULL;
   65|  6.02k|  s->literal_hgroup.htrees = NULL;
   66|  6.02k|  s->insert_copy_hgroup.codes = NULL;
   67|  6.02k|  s->insert_copy_hgroup.htrees = NULL;
   68|  6.02k|  s->distance_hgroup.codes = NULL;
   69|  6.02k|  s->distance_hgroup.htrees = NULL;
   70|       |
   71|  6.02k|  s->is_last_metablock = 0;
   72|  6.02k|  s->is_uncompressed = 0;
   73|  6.02k|  s->is_metadata = 0;
   74|  6.02k|  s->should_wrap_ringbuffer = 0;
   75|  6.02k|  s->canny_ringbuffer_allocation = 1;
   76|       |
   77|  6.02k|  s->window_bits = 0;
   78|  6.02k|  s->max_distance = 0;
   79|  6.02k|  s->dist_rb[0] = 16;
   80|  6.02k|  s->dist_rb[1] = 15;
   81|  6.02k|  s->dist_rb[2] = 11;
   82|  6.02k|  s->dist_rb[3] = 4;
   83|  6.02k|  s->dist_rb_idx = 0;
   84|  6.02k|  s->block_type_trees = NULL;
   85|  6.02k|  s->block_len_trees = NULL;
   86|       |
   87|       |  /* Make small negative indexes addressable. */
   88|  6.02k|  s->symbol_lists = &s->symbols_lists_array[BROTLI_HUFFMAN_MAX_CODE_LENGTH + 1];
  ------------------
  |  |   19|  6.02k|#define BROTLI_HUFFMAN_MAX_CODE_LENGTH 15
  ------------------
   89|       |
   90|  6.02k|  s->mtf_upper_bound = 63;
   91|       |
   92|  6.02k|  s->dictionary = BrotliGetDictionary();
   93|  6.02k|  s->transforms = BrotliGetTransforms();
   94|       |
   95|  6.02k|  return BROTLI_TRUE;
  ------------------
  |  |   51|  6.02k|#define BROTLI_TRUE 1
  ------------------
   96|  6.02k|}
BrotliDecoderStateMetablockBegin:
   98|   166k|void BrotliDecoderStateMetablockBegin(BrotliDecoderState* s) {
   99|   166k|  s->meta_block_remaining_len = 0;
  100|   166k|  s->block_length[0] = 1U << 24;
  101|   166k|  s->block_length[1] = 1U << 24;
  102|   166k|  s->block_length[2] = 1U << 24;
  103|   166k|  s->num_block_types[0] = 1;
  104|   166k|  s->num_block_types[1] = 1;
  105|   166k|  s->num_block_types[2] = 1;
  106|   166k|  s->block_type_rb[0] = 1;
  107|   166k|  s->block_type_rb[1] = 0;
  108|   166k|  s->block_type_rb[2] = 1;
  109|   166k|  s->block_type_rb[3] = 0;
  110|   166k|  s->block_type_rb[4] = 1;
  111|   166k|  s->block_type_rb[5] = 0;
  112|   166k|  s->context_map = NULL;
  113|   166k|  s->context_modes = NULL;
  114|   166k|  s->dist_context_map = NULL;
  115|   166k|  s->context_map_slice = NULL;
  116|   166k|  s->literal_htree = NULL;
  117|   166k|  s->dist_context_map_slice = NULL;
  118|   166k|  s->dist_htree_index = 0;
  119|   166k|  s->context_lookup = NULL;
  120|   166k|  s->literal_hgroup.codes = NULL;
  121|   166k|  s->literal_hgroup.htrees = NULL;
  122|   166k|  s->insert_copy_hgroup.codes = NULL;
  123|   166k|  s->insert_copy_hgroup.htrees = NULL;
  124|   166k|  s->distance_hgroup.codes = NULL;
  125|   166k|  s->distance_hgroup.htrees = NULL;
  126|   166k|}
BrotliDecoderStateCleanupAfterMetablock:
  128|   169k|void BrotliDecoderStateCleanupAfterMetablock(BrotliDecoderState* s) {
  129|   169k|  BROTLI_DECODER_FREE(s, s->context_modes);
  ------------------
  |  |  249|   169k|#define BROTLI_DECODER_FREE(S, X) {          \
  |  |  250|   169k|  S->free_func(S->memory_manager_opaque, X); \
  |  |  251|   169k|  X = NULL;                                  \
  |  |  252|   169k|}
  ------------------
  130|   169k|  BROTLI_DECODER_FREE(s, s->context_map);
  ------------------
  |  |  249|   169k|#define BROTLI_DECODER_FREE(S, X) {          \
  |  |  250|   169k|  S->free_func(S->memory_manager_opaque, X); \
  |  |  251|   169k|  X = NULL;                                  \
  |  |  252|   169k|}
  ------------------
  131|   169k|  BROTLI_DECODER_FREE(s, s->dist_context_map);
  ------------------
  |  |  249|   169k|#define BROTLI_DECODER_FREE(S, X) {          \
  |  |  250|   169k|  S->free_func(S->memory_manager_opaque, X); \
  |  |  251|   169k|  X = NULL;                                  \
  |  |  252|   169k|}
  ------------------
  132|   169k|  BROTLI_DECODER_FREE(s, s->literal_hgroup.htrees);
  ------------------
  |  |  249|   169k|#define BROTLI_DECODER_FREE(S, X) {          \
  |  |  250|   169k|  S->free_func(S->memory_manager_opaque, X); \
  |  |  251|   169k|  X = NULL;                                  \
  |  |  252|   169k|}
  ------------------
  133|   169k|  BROTLI_DECODER_FREE(s, s->insert_copy_hgroup.htrees);
  ------------------
  |  |  249|   169k|#define BROTLI_DECODER_FREE(S, X) {          \
  |  |  250|   169k|  S->free_func(S->memory_manager_opaque, X); \
  |  |  251|   169k|  X = NULL;                                  \
  |  |  252|   169k|}
  ------------------
  134|   169k|  BROTLI_DECODER_FREE(s, s->distance_hgroup.htrees);
  ------------------
  |  |  249|   169k|#define BROTLI_DECODER_FREE(S, X) {          \
  |  |  250|   169k|  S->free_func(S->memory_manager_opaque, X); \
  |  |  251|   169k|  X = NULL;                                  \
  |  |  252|   169k|}
  ------------------
  135|   169k|}
BrotliDecoderStateCleanup:
  137|  6.02k|void BrotliDecoderStateCleanup(BrotliDecoderState* s) {
  138|  6.02k|  BrotliDecoderStateCleanupAfterMetablock(s);
  139|       |
  140|  6.02k|  BROTLI_DECODER_FREE(s, s->ringbuffer);
  ------------------
  |  |  249|  6.02k|#define BROTLI_DECODER_FREE(S, X) {          \
  |  |  250|  6.02k|  S->free_func(S->memory_manager_opaque, X); \
  |  |  251|  6.02k|  X = NULL;                                  \
  |  |  252|  6.02k|}
  ------------------
  141|  6.02k|  BROTLI_DECODER_FREE(s, s->block_type_trees);
  ------------------
  |  |  249|  6.02k|#define BROTLI_DECODER_FREE(S, X) {          \
  |  |  250|  6.02k|  S->free_func(S->memory_manager_opaque, X); \
  |  |  251|  6.02k|  X = NULL;                                  \
  |  |  252|  6.02k|}
  ------------------
  142|  6.02k|}
BrotliDecoderHuffmanTreeGroupInit:
  146|  48.8k|    uint32_t ntrees) {
  147|       |  /* Pack two allocations into one */
  148|  48.8k|  const size_t max_table_size = kMaxHuffmanTableSize[(alphabet_size + 31) >> 5];
  149|  48.8k|  const size_t code_size = sizeof(HuffmanCode) * ntrees * max_table_size;
  150|  48.8k|  const size_t htree_size = sizeof(HuffmanCode*) * ntrees;
  151|       |  /* Pointer alignment is, hopefully, wider than sizeof(HuffmanCode). */
  152|  48.8k|  HuffmanCode** p = (HuffmanCode**)BROTLI_DECODER_ALLOC(s,
  ------------------
  |  |  247|  48.8k|#define BROTLI_DECODER_ALLOC(S, L) S->alloc_func(S->memory_manager_opaque, L)
  ------------------
  153|  48.8k|      code_size + htree_size);
  154|  48.8k|  group->alphabet_size = (uint16_t)alphabet_size;
  155|  48.8k|  group->max_symbol = (uint16_t)max_symbol;
  156|  48.8k|  group->num_htrees = (uint16_t)ntrees;
  157|  48.8k|  group->htrees = p;
  158|  48.8k|  group->codes = (HuffmanCode*)(&p[ntrees]);
  159|  48.8k|  return !!p;
  160|  48.8k|}

_ZN5woff28WOFF2OutD2Ev:
   33|  7.82k|  virtual ~WOFF2Out(void) {}
_ZN5woff214WOFF2StringOut4SizeEv:
   58|   451k|  size_t Size() override { return offset_; }

_ZN5woff26BufferC2EPKhm:
   61|  79.4k|      : buffer_(data),
   62|  79.4k|        length_(len),
   63|  79.4k|        offset_(0) { }
_ZN5woff26Buffer4SkipEm:
   65|   152k|  bool Skip(size_t n_bytes) {
   66|   152k|    return Read(NULL, n_bytes);
   67|   152k|  }
_ZN5woff26Buffer4ReadEPhm:
   69|   220k|  bool Read(uint8_t *data, size_t n_bytes) {
   70|   220k|    if (n_bytes > 1024 * 1024 * 1024) {
  ------------------
  |  Branch (70:9): [True: 0, False: 220k]
  ------------------
   71|      0|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
   72|      0|    }
   73|   220k|    if ((offset_ + n_bytes > length_) ||
  ------------------
  |  Branch (73:9): [True: 189, False: 220k]
  ------------------
   74|   220k|        (offset_ > length_ - n_bytes)) {
  ------------------
  |  Branch (74:9): [True: 0, False: 220k]
  ------------------
   75|    189|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|    189|#define FONT_COMPRESSION_FAILURE() false
  ------------------
   76|    189|    }
   77|   220k|    if (data) {
  ------------------
  |  Branch (77:9): [True: 67.6k, False: 152k]
  ------------------
   78|  67.6k|      std::memcpy(data, buffer_ + offset_, n_bytes);
   79|  67.6k|    }
   80|   220k|    offset_ += n_bytes;
   81|   220k|    return true;
   82|   220k|  }
_ZN5woff26Buffer7ReadU32EPj:
  118|  88.7k|  bool ReadU32(uint32_t *value) {
  119|  88.7k|    if (offset_ + 4 > length_) {
  ------------------
  |  Branch (119:9): [True: 91, False: 88.6k]
  ------------------
  120|     91|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     91|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  121|     91|    }
  122|  88.6k|    std::memcpy(value, buffer_ + offset_, sizeof(uint32_t));
  123|  88.6k|    *value = ntohl(*value);
  124|  88.6k|    offset_ += 4;
  125|  88.6k|    return true;
  126|  88.7k|  }
_ZN5woff26Buffer7ReadU16EPt:
   93|   162k|  bool ReadU16(uint16_t *value) {
   94|   162k|    if (offset_ + 2 > length_) {
  ------------------
  |  Branch (94:9): [True: 68, False: 162k]
  ------------------
   95|     68|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     68|#define FONT_COMPRESSION_FAILURE() false
  ------------------
   96|     68|    }
   97|   162k|    std::memcpy(value, buffer_ + offset_, sizeof(uint16_t));
   98|   162k|    *value = ntohs(*value);
   99|   162k|    offset_ += 2;
  100|   162k|    return true;
  101|   162k|  }
_ZN5woff26Buffer6ReadU8EPh:
   84|  2.78M|  inline bool ReadU8(uint8_t *value) {
   85|  2.78M|    if (offset_ + 1 > length_) {
  ------------------
  |  Branch (85:9): [True: 495, False: 2.78M]
  ------------------
   86|    495|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|    495|#define FONT_COMPRESSION_FAILURE() false
  ------------------
   87|    495|    }
   88|  2.78M|    *value = buffer_[offset_];
   89|  2.78M|    ++offset_;
   90|  2.78M|    return true;
   91|  2.78M|  }
_ZNK5woff26Buffer6offsetEv:
  151|   272k|  size_t offset() const { return offset_; }
_ZNK5woff26Buffer6bufferEv:
  150|   132k|  const uint8_t *buffer() const { return buffer_; }
_ZNK5woff26Buffer6lengthEv:
  152|   132k|  size_t length() const { return length_; }
_ZN5woff26Buffer7ReadS16EPs:
  103|  66.5k|  bool ReadS16(int16_t *value) {
  104|  66.5k|    return ReadU16(reinterpret_cast<uint16_t*>(value));
  105|  66.5k|  }

LLVMFuzzerTestOneInput:
    7|  7.82k|extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
    8|  7.82k|  std::string buf;
    9|  7.82k|  woff2::WOFF2StringOut out(&buf);
   10|  7.82k|  out.SetMaxSize(30 * 1024 * 1024);
   11|  7.82k|  woff2::ConvertWOFF2ToTTF(data, size, &out);
   12|  7.82k|  return 0;
   13|  7.82k|}

_ZN5woff26Round4ImEET_S1_:
   18|   101k|template<typename T> T Round4(T value) {
   19|   101k|  if (std::numeric_limits<T>::max() - value < 3) {
  ------------------
  |  Branch (19:7): [True: 0, False: 101k]
  ------------------
   20|      0|    return value;
   21|      0|  }
   22|   101k|  return (value + 3) & ~3;
   23|   101k|}
_ZN5woff26Round4IjEET_S1_:
   18|     43|template<typename T> T Round4(T value) {
   19|     43|  if (std::numeric_limits<T>::max() - value < 3) {
  ------------------
  |  Branch (19:7): [True: 0, False: 43]
  ------------------
   20|      0|    return value;
   21|      0|  }
   22|     43|  return (value + 3) & ~3;
   23|     43|}

_ZN5woff28StoreU32EPhmj:
   21|  1.25M|inline size_t StoreU32(uint8_t* dst, size_t offset, uint32_t x) {
   22|  1.25M|  dst[offset] = x >> 24;
   23|  1.25M|  dst[offset + 1] = x >> 16;
   24|  1.25M|  dst[offset + 2] = x >> 8;
   25|  1.25M|  dst[offset + 3] = x;
   26|  1.25M|  return offset + 4;
   27|  1.25M|}
_ZN5woff27Store16EPhmi:
   29|  1.95M|inline size_t Store16(uint8_t* dst, size_t offset, int x) {
   30|  1.95M|  dst[offset] = x >> 8;
   31|  1.95M|  dst[offset + 1] = x;
   32|  1.95M|  return offset + 2;
   33|  1.95M|}
_ZN5woff27Store16EiPmPh:
   42|    366|inline void Store16(int val, size_t* offset, uint8_t* dst) {
   43|    366|  dst[(*offset)++] = val >> 8;
   44|    366|  dst[(*offset)++] = val;
   45|    366|}

_ZN5woff213Read255UShortEPNS_6BufferEPj:
   50|   813k|bool Read255UShort(Buffer* buf, unsigned int* value) {
   51|   813k|  static const int kWordCode = 253;
   52|   813k|  static const int kOneMoreByteCode2 = 254;
   53|   813k|  static const int kOneMoreByteCode1 = 255;
   54|   813k|  static const int kLowestUCode = 253;
   55|   813k|  uint8_t code = 0;
   56|   813k|  if (!buf->ReadU8(&code)) {
  ------------------
  |  Branch (56:7): [True: 271, False: 813k]
  ------------------
   57|    271|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|    271|#define FONT_COMPRESSION_FAILURE() false
  ------------------
   58|    271|  }
   59|   813k|  if (code == kWordCode) {
  ------------------
  |  Branch (59:7): [True: 1.29k, False: 812k]
  ------------------
   60|  1.29k|    uint16_t result = 0;
   61|  1.29k|    if (!buf->ReadU16(&result)) {
  ------------------
  |  Branch (61:9): [True: 9, False: 1.28k]
  ------------------
   62|      9|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      9|#define FONT_COMPRESSION_FAILURE() false
  ------------------
   63|      9|    }
   64|  1.28k|    *value = result;
   65|  1.28k|    return true;
   66|   812k|  } else if (code == kOneMoreByteCode1) {
  ------------------
  |  Branch (66:14): [True: 4.37k, False: 807k]
  ------------------
   67|  4.37k|    uint8_t result = 0;
   68|  4.37k|    if (!buf->ReadU8(&result)) {
  ------------------
  |  Branch (68:9): [True: 3, False: 4.37k]
  ------------------
   69|      3|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      3|#define FONT_COMPRESSION_FAILURE() false
  ------------------
   70|      3|    }
   71|  4.37k|    *value = result + kLowestUCode;
   72|  4.37k|    return true;
   73|   807k|  } else if (code == kOneMoreByteCode2) {
  ------------------
  |  Branch (73:14): [True: 9.21k, False: 798k]
  ------------------
   74|  9.21k|    uint8_t result = 0;
   75|  9.21k|    if (!buf->ReadU8(&result)) {
  ------------------
  |  Branch (75:9): [True: 5, False: 9.21k]
  ------------------
   76|      5|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      5|#define FONT_COMPRESSION_FAILURE() false
  ------------------
   77|      5|    }
   78|  9.21k|    *value = result + kLowestUCode * 2;
   79|  9.21k|    return true;
   80|   798k|  } else {
   81|   798k|    *value = code;
   82|   798k|    return true;
   83|   798k|  }
   84|   813k|}
_ZN5woff211ReadBase128EPNS_6BufferEPj:
   86|   992k|bool ReadBase128(Buffer* buf, uint32_t* value) {
   87|   992k|  uint32_t result = 0;
   88|  1.03M|  for (size_t i = 0; i < 5; ++i) {
  ------------------
  |  Branch (88:22): [True: 1.03M, False: 9]
  ------------------
   89|  1.03M|    uint8_t code = 0;
   90|  1.03M|    if (!buf->ReadU8(&code)) {
  ------------------
  |  Branch (90:9): [True: 121, False: 1.03M]
  ------------------
   91|    121|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|    121|#define FONT_COMPRESSION_FAILURE() false
  ------------------
   92|    121|    }
   93|       |    // Leading zeros are invalid.
   94|  1.03M|    if (i == 0 && code == 0x80) {
  ------------------
  |  Branch (94:9): [True: 992k, False: 44.6k]
  |  Branch (94:19): [True: 4, False: 992k]
  ------------------
   95|      4|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      4|#define FONT_COMPRESSION_FAILURE() false
  ------------------
   96|      4|    }
   97|       |    // If any of the top seven bits are set then we're about to overflow.
   98|  1.03M|    if (result & 0xfe000000) {
  ------------------
  |  Branch (98:9): [True: 12, False: 1.03M]
  ------------------
   99|     12|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     12|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  100|     12|    }
  101|  1.03M|    result = (result << 7) | (code & 0x7f);
  102|  1.03M|    if ((code & 0x80) == 0) {
  ------------------
  |  Branch (102:9): [True: 992k, False: 44.6k]
  ------------------
  103|   992k|      *value = result;
  104|   992k|      return true;
  105|   992k|    }
  106|  1.03M|  }
  107|       |  // Make sure not to exceed the size bound
  108|      9|  return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      9|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  109|   992k|}

_ZN5woff215ComputeULongSumEPKhm:
   18|   105k|uint32_t ComputeULongSum(const uint8_t* buf, size_t size) {
   19|   105k|  uint32_t checksum = 0;
   20|   105k|  size_t aligned_size = size & ~3;
   21|  6.75M|  for (size_t i = 0; i < aligned_size; i += 4) {
  ------------------
  |  Branch (21:22): [True: 6.65M, False: 105k]
  ------------------
   22|  6.65M|    checksum +=
   23|  6.65M|        (buf[i] << 24) | (buf[i + 1] << 16) | (buf[i + 2] << 8) | buf[i + 3];
   24|  6.65M|  }
   25|       |
   26|       |  // treat size not aligned on 4 as if it were padded to 4 with 0's
   27|   105k|  if (size != aligned_size) {
  ------------------
  |  Branch (27:7): [True: 50.6k, False: 54.6k]
  ------------------
   28|  50.6k|    uint32_t v = 0;
   29|   151k|    for (size_t i = aligned_size; i < size; ++i) {
  ------------------
  |  Branch (29:35): [True: 101k, False: 50.6k]
  ------------------
   30|   101k|      v |= buf[i] << (24 - 8 * (i & 3));
   31|   101k|    }
   32|  50.6k|    checksum += v;
   33|  50.6k|  }
   34|       |
   35|   105k|  return checksum;
   36|   105k|}
_ZN5woff220CollectionHeaderSizeEjj:
   38|    558|size_t CollectionHeaderSize(uint32_t header_version, uint32_t num_fonts) {
   39|    558|  size_t size = 0;
   40|    558|  if (header_version == 0x00020000) {
  ------------------
  |  Branch (40:7): [True: 381, False: 177]
  ------------------
   41|    381|    size += 12;  // ulDsig{Tag,Length,Offset}
   42|    381|  }
   43|    558|  if (header_version == 0x00010000 || header_version == 0x00020000) {
  ------------------
  |  Branch (43:7): [True: 177, False: 381]
  |  Branch (43:39): [True: 381, False: 0]
  ------------------
   44|    558|    size += 12   // TTCTag, Version, numFonts
   45|    558|      + 4 * num_fonts;  // OffsetTable[numFonts]
   46|    558|  }
   47|    558|  return size;
   48|    558|}

_ZNK5woff25TableltERKS0_:
   48|  2.04M|  bool operator<(const Table& other) const {
   49|  2.04M|    return tag < other.tag;
   50|  2.04M|  }

_ZN5woff217ConvertWOFF2ToTTFEPKhmPNS_8WOFF2OutE:
 1357|  7.82k|                       WOFF2Out* out) {
 1358|  7.82k|  RebuildMetadata metadata;
 1359|  7.82k|  WOFF2Header hdr;
 1360|  7.82k|  if (!ReadWOFF2Header(data, length, &hdr)) {
  ------------------
  |  Branch (1360:7): [True: 1.31k, False: 6.51k]
  ------------------
 1361|  1.31k|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|  1.31k|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1362|  1.31k|  }
 1363|       |
 1364|  6.51k|  if (!WriteHeaders(data, length, &metadata, &hdr, out)) {
  ------------------
  |  Branch (1364:7): [True: 0, False: 6.51k]
  ------------------
 1365|      0|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1366|      0|  }
 1367|       |
 1368|  6.51k|  const float compression_ratio = (float) hdr.uncompressed_size / length;
 1369|  6.51k|  if (compression_ratio > kMaxPlausibleCompressionRatio) {
  ------------------
  |  Branch (1369:7): [True: 432, False: 6.08k]
  ------------------
 1370|       |#ifdef FONT_COMPRESSION_BIN
 1371|       |    fprintf(stderr, "Implausible compression ratio %.01f\n", compression_ratio);
 1372|       |#endif
 1373|    432|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|    432|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1374|    432|  }
 1375|       |
 1376|  6.08k|  const uint8_t* src_buf = data + hdr.compressed_offset;
 1377|  6.08k|  std::vector<uint8_t> uncompressed_buf(hdr.uncompressed_size);
 1378|  6.08k|  if (PREDICT_FALSE(hdr.uncompressed_size < 1)) {
  ------------------
  |  |   48|  6.08k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 59, False: 6.02k]
  |  |  ------------------
  ------------------
 1379|     59|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     59|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1380|     59|  }
 1381|  6.02k|  if (PREDICT_FALSE(!Woff2Uncompress(&uncompressed_buf[0],
  ------------------
  |  |   48|  6.02k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 4.75k, False: 1.27k]
  |  |  ------------------
  ------------------
 1382|  6.02k|                                     hdr.uncompressed_size, src_buf,
 1383|  6.02k|                                     hdr.compressed_length))) {
 1384|  4.75k|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|  4.75k|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1385|  4.75k|  }
 1386|       |
 1387|  2.08k|  for (size_t i = 0; i < metadata.font_infos.size(); i++) {
  ------------------
  |  Branch (1387:22): [True: 1.68k, False: 400]
  ------------------
 1388|  1.68k|    if (PREDICT_FALSE(!ReconstructFont(&uncompressed_buf[0],
  ------------------
  |  |   48|  1.68k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 870, False: 811]
  |  |  ------------------
  ------------------
 1389|  1.68k|                                       hdr.uncompressed_size,
 1390|  1.68k|                                       &metadata, &hdr, i, out))) {
 1391|    870|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|    870|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1392|    870|    }
 1393|  1.68k|  }
 1394|       |
 1395|    400|  return true;
 1396|  1.27k|}
woff2_dec.cc:_ZN5woff212_GLOBAL__N_115ReadWOFF2HeaderEPKhmPNS0_11WOFF2HeaderE:
 1073|  7.82k|bool ReadWOFF2Header(const uint8_t* data, size_t length, WOFF2Header* hdr) {
 1074|  7.82k|  Buffer file(data, length);
 1075|       |
 1076|  7.82k|  uint32_t signature;
 1077|  7.82k|  if (PREDICT_FALSE(!file.ReadU32(&signature) || signature != kWoff2Signature ||
  ------------------
  |  |   48|  31.2k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 55, False: 7.77k]
  |  |  |  Branch (48:44): [True: 3, False: 7.82k]
  |  |  |  Branch (48:44): [True: 49, False: 7.77k]
  |  |  |  Branch (48:44): [True: 3, False: 7.77k]
  |  |  ------------------
  ------------------
 1078|  7.82k|      !file.ReadU32(&hdr->flavor))) {
 1079|     55|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     55|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1080|     55|  }
 1081|       |
 1082|       |  // TODO(user): Should call IsValidVersionTag() here.
 1083|       |
 1084|  7.77k|  uint32_t reported_length;
 1085|  7.77k|  if (PREDICT_FALSE(
  ------------------
  |  |   48|  15.5k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 67, False: 7.70k]
  |  |  |  Branch (48:44): [True: 3, False: 7.77k]
  |  |  |  Branch (48:44): [True: 64, False: 7.70k]
  |  |  ------------------
  ------------------
 1086|  7.77k|      !file.ReadU32(&reported_length) || length != reported_length)) {
 1087|     67|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     67|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1088|     67|  }
 1089|  7.70k|  if (PREDICT_FALSE(!file.ReadU16(&hdr->num_tables) || !hdr->num_tables)) {
  ------------------
  |  |   48|  15.4k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 3, False: 7.70k]
  |  |  |  Branch (48:44): [True: 2, False: 7.70k]
  |  |  |  Branch (48:44): [True: 1, False: 7.70k]
  |  |  ------------------
  ------------------
 1090|      3|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      3|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1091|      3|  }
 1092|       |
 1093|       |  // We don't care about these fields of the header:
 1094|       |  //   uint16_t reserved
 1095|       |  //   uint32_t total_sfnt_size, we don't believe this, will compute later
 1096|  7.70k|  if (PREDICT_FALSE(!file.Skip(6))) {
  ------------------
  |  |   48|  7.70k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 21, False: 7.68k]
  |  |  ------------------
  ------------------
 1097|     21|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     21|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1098|     21|  }
 1099|  7.68k|  if (PREDICT_FALSE(!file.ReadU32(&hdr->compressed_length))) {
  ------------------
  |  |   48|  7.68k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 4, False: 7.67k]
  |  |  ------------------
  ------------------
 1100|      4|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      4|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1101|      4|  }
 1102|       |  // We don't care about these fields of the header:
 1103|       |  //   uint16_t major_version, minor_version
 1104|  7.67k|  if (PREDICT_FALSE(!file.Skip(2 * 2))) {
  ------------------
  |  |   48|  7.67k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 3, False: 7.67k]
  |  |  ------------------
  ------------------
 1105|      3|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      3|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1106|      3|  }
 1107|  7.67k|  uint32_t meta_offset;
 1108|  7.67k|  uint32_t meta_length;
 1109|  7.67k|  uint32_t meta_length_orig;
 1110|  7.67k|  if (PREDICT_FALSE(!file.ReadU32(&meta_offset) ||
  ------------------
  |  |   48|  30.6k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 9, False: 7.66k]
  |  |  |  Branch (48:44): [True: 3, False: 7.67k]
  |  |  |  Branch (48:44): [True: 3, False: 7.67k]
  |  |  |  Branch (48:44): [True: 3, False: 7.66k]
  |  |  ------------------
  ------------------
 1111|  7.67k|      !file.ReadU32(&meta_length) ||
 1112|  7.67k|      !file.ReadU32(&meta_length_orig))) {
 1113|      9|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      9|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1114|      9|  }
 1115|  7.66k|  if (meta_offset) {
  ------------------
  |  Branch (1115:7): [True: 379, False: 7.28k]
  ------------------
 1116|    379|    if (PREDICT_FALSE(
  ------------------
  |  |   48|    680|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 106, False: 273]
  |  |  |  Branch (48:44): [True: 78, False: 301]
  |  |  |  Branch (48:44): [True: 28, False: 273]
  |  |  ------------------
  ------------------
 1117|    379|        meta_offset >= length || length - meta_offset < meta_length)) {
 1118|    106|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|    106|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1119|    106|    }
 1120|    379|  }
 1121|  7.56k|  uint32_t priv_offset;
 1122|  7.56k|  uint32_t priv_length;
 1123|  7.56k|  if (PREDICT_FALSE(!file.ReadU32(&priv_offset) ||
  ------------------
  |  |   48|  15.1k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 12, False: 7.54k]
  |  |  |  Branch (48:44): [True: 9, False: 7.55k]
  |  |  |  Branch (48:44): [True: 3, False: 7.54k]
  |  |  ------------------
  ------------------
 1124|  7.56k|      !file.ReadU32(&priv_length))) {
 1125|     12|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     12|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1126|     12|  }
 1127|  7.54k|  if (priv_offset) {
  ------------------
  |  Branch (1127:7): [True: 274, False: 7.27k]
  ------------------
 1128|    274|    if (PREDICT_FALSE(
  ------------------
  |  |   48|    475|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 105, False: 169]
  |  |  |  Branch (48:44): [True: 73, False: 201]
  |  |  |  Branch (48:44): [True: 32, False: 169]
  |  |  ------------------
  ------------------
 1129|    274|        priv_offset >= length || length - priv_offset < priv_length)) {
 1130|    105|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|    105|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1131|    105|    }
 1132|    274|  }
 1133|  7.44k|  hdr->tables.resize(hdr->num_tables);
 1134|  7.44k|  if (PREDICT_FALSE(!ReadTableDirectory(
  ------------------
  |  |   48|  7.44k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 316, False: 7.12k]
  |  |  ------------------
  ------------------
 1135|  7.44k|          &file, &hdr->tables, hdr->num_tables))) {
 1136|    316|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|    316|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1137|    316|  }
 1138|       |
 1139|       |  // Before we sort for output the last table end is the uncompressed size.
 1140|  7.12k|  Table& last_table = hdr->tables.back();
 1141|  7.12k|  hdr->uncompressed_size = last_table.src_offset + last_table.src_length;
 1142|  7.12k|  if (PREDICT_FALSE(hdr->uncompressed_size < last_table.src_offset)) {
  ------------------
  |  |   48|  7.12k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 7.12k]
  |  |  ------------------
  ------------------
 1143|      0|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1144|      0|  }
 1145|       |
 1146|  7.12k|  hdr->header_version = 0;
 1147|       |
 1148|  7.12k|  if (hdr->flavor == kTtcFontFlavor) {
  ------------------
  |  Branch (1148:7): [True: 641, False: 6.48k]
  ------------------
 1149|    641|    if (PREDICT_FALSE(!file.ReadU32(&hdr->header_version))) {
  ------------------
  |  |   48|    641|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 15, False: 626]
  |  |  ------------------
  ------------------
 1150|     15|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     15|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1151|     15|    }
 1152|    626|    if (PREDICT_FALSE(hdr->header_version != 0x00010000
  ------------------
  |  |   48|    934|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 64, False: 562]
  |  |  |  Branch (48:44): [True: 308, False: 318]
  |  |  |  Branch (48:44): [True: 64, False: 244]
  |  |  ------------------
  ------------------
 1153|    626|                   && hdr->header_version != 0x00020000)) {
 1154|     64|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     64|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1155|     64|    }
 1156|    562|    uint32_t num_fonts;
 1157|    562|    if (PREDICT_FALSE(!Read255UShort(&file, &num_fonts) || !num_fonts)) {
  ------------------
  |  |   48|  1.11k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 7, False: 555]
  |  |  |  Branch (48:44): [True: 6, False: 556]
  |  |  |  Branch (48:44): [True: 1, False: 555]
  |  |  ------------------
  ------------------
 1158|      7|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      7|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1159|      7|    }
 1160|    555|    hdr->ttc_fonts.resize(num_fonts);
 1161|       |
 1162|  6.42k|    for (uint32_t i = 0; i < num_fonts; i++) {
  ------------------
  |  Branch (1162:26): [True: 6.14k, False: 284]
  ------------------
 1163|  6.14k|      TtcFont& ttc_font = hdr->ttc_fonts[i];
 1164|  6.14k|      uint32_t num_tables;
 1165|  6.14k|      if (PREDICT_FALSE(!Read255UShort(&file, &num_tables) || !num_tables)) {
  ------------------
  |  |   48|  12.2k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 62, False: 6.07k]
  |  |  |  Branch (48:44): [True: 51, False: 6.08k]
  |  |  |  Branch (48:44): [True: 11, False: 6.07k]
  |  |  ------------------
  ------------------
 1166|     62|        return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     62|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1167|     62|      }
 1168|  6.07k|      if (PREDICT_FALSE(!file.ReadU32(&ttc_font.flavor))) {
  ------------------
  |  |   48|  6.07k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 34, False: 6.04k]
  |  |  ------------------
  ------------------
 1169|     34|        return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     34|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1170|     34|      }
 1171|       |
 1172|  6.04k|      ttc_font.table_indices.resize(num_tables);
 1173|       |
 1174|       |
 1175|  6.04k|      unsigned int glyf_idx = 0;
 1176|  6.04k|      unsigned int loca_idx = 0;
 1177|       |
 1178|   193k|      for (uint32_t j = 0; j < num_tables; j++) {
  ------------------
  |  Branch (1178:28): [True: 187k, False: 5.88k]
  ------------------
 1179|   187k|        unsigned int table_idx;
 1180|   187k|        if (PREDICT_FALSE(!Read255UShort(&file, &table_idx)) ||
  ------------------
  |  |   48|   374k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 127, False: 187k]
  |  |  ------------------
  ------------------
 1181|   187k|            table_idx >= hdr->tables.size()) {
  ------------------
  |  Branch (1181:13): [True: 30, False: 187k]
  ------------------
 1182|    157|          return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|    157|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1183|    157|        }
 1184|   187k|        ttc_font.table_indices[j] = table_idx;
 1185|       |
 1186|   187k|        const Table& table = hdr->tables[table_idx];
 1187|   187k|        if (table.tag == kLocaTableTag) {
  ------------------
  |  Branch (1187:13): [True: 10.9k, False: 176k]
  ------------------
 1188|  10.9k|          loca_idx = table_idx;
 1189|  10.9k|        }
 1190|   187k|        if (table.tag == kGlyfTableTag) {
  ------------------
  |  Branch (1190:13): [True: 3.59k, False: 183k]
  ------------------
 1191|  3.59k|          glyf_idx = table_idx;
 1192|  3.59k|        }
 1193|       |
 1194|   187k|      }
 1195|       |
 1196|       |      // if we have both glyf and loca make sure they are consecutive
 1197|       |      // if we have just one we'll reject the font elsewhere
 1198|  5.88k|      if (glyf_idx > 0 || loca_idx > 0) {
  ------------------
  |  Branch (1198:11): [True: 33, False: 5.85k]
  |  Branch (1198:27): [True: 234, False: 5.62k]
  ------------------
 1199|    267|        if (PREDICT_FALSE(glyf_idx > loca_idx || loca_idx - glyf_idx != 1)) {
  ------------------
  |  |   48|    518|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 18, False: 249]
  |  |  |  Branch (48:44): [True: 16, False: 251]
  |  |  |  Branch (48:44): [True: 2, False: 249]
  |  |  ------------------
  ------------------
 1200|       |#ifdef FONT_COMPRESSION_BIN
 1201|       |        fprintf(stderr, "TTC font %d has non-consecutive glyf/loca\n", i);
 1202|       |#endif
 1203|     18|          return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     18|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1204|     18|        }
 1205|    267|      }
 1206|  5.88k|    }
 1207|    555|  }
 1208|       |
 1209|  6.77k|  const uint64_t first_table_offset = ComputeOffsetToFirstTable(*hdr);
 1210|       |
 1211|  6.77k|  hdr->compressed_offset = file.offset();
 1212|  6.77k|  if (PREDICT_FALSE(hdr->compressed_offset >
  ------------------
  |  |   48|  6.77k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 6.77k]
  |  |  ------------------
  ------------------
 1213|  6.77k|                    std::numeric_limits<uint32_t>::max())) {
 1214|      0|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1215|      0|  }
 1216|  6.77k|  uint64_t src_offset = Round4(hdr->compressed_offset + hdr->compressed_length);
 1217|  6.77k|  uint64_t dst_offset = first_table_offset;
 1218|       |
 1219|       |
 1220|  6.77k|  if (PREDICT_FALSE(src_offset > length)) {
  ------------------
  |  |   48|  6.77k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 134, False: 6.63k]
  |  |  ------------------
  ------------------
 1221|       |#ifdef FONT_COMPRESSION_BIN
 1222|       |    fprintf(stderr, "offset fail; src_offset %" PRIu64 " length %lu "
 1223|       |      "dst_offset %" PRIu64 "\n",
 1224|       |      src_offset, length, dst_offset);
 1225|       |#endif
 1226|    134|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|    134|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1227|    134|  }
 1228|  6.63k|  if (meta_offset) {
  ------------------
  |  Branch (1228:7): [True: 77, False: 6.56k]
  ------------------
 1229|     77|    if (PREDICT_FALSE(src_offset != meta_offset)) {
  ------------------
  |  |   48|     77|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 36, False: 41]
  |  |  ------------------
  ------------------
 1230|     36|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     36|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1231|     36|    }
 1232|     41|    src_offset = Round4(meta_offset + meta_length);
 1233|     41|    if (PREDICT_FALSE(src_offset > std::numeric_limits<uint32_t>::max())) {
  ------------------
  |  |   48|     41|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 41]
  |  |  ------------------
  ------------------
 1234|      0|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1235|      0|    }
 1236|     41|  }
 1237|       |
 1238|  6.60k|  if (priv_offset) {
  ------------------
  |  Branch (1238:7): [True: 39, False: 6.56k]
  ------------------
 1239|     39|    if (PREDICT_FALSE(src_offset != priv_offset)) {
  ------------------
  |  |   48|     39|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 37, False: 2]
  |  |  ------------------
  ------------------
 1240|     37|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     37|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1241|     37|    }
 1242|      2|    src_offset = Round4(priv_offset + priv_length);
 1243|      2|    if (PREDICT_FALSE(src_offset > std::numeric_limits<uint32_t>::max())) {
  ------------------
  |  |   48|      2|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 2]
  |  |  ------------------
  ------------------
 1244|      0|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1245|      0|    }
 1246|      2|  }
 1247|       |
 1248|  6.56k|  if (PREDICT_FALSE(src_offset != Round4(length))) {
  ------------------
  |  |   48|  6.56k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 51, False: 6.51k]
  |  |  ------------------
  ------------------
 1249|     51|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     51|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1250|     51|  }
 1251|       |
 1252|  6.51k|  return true;
 1253|  6.56k|}
woff2_dec.cc:_ZN5woff212_GLOBAL__N_118ReadTableDirectoryEPNS_6BufferEPNSt3__16vectorINS_5TableENS3_9allocatorIS5_EEEEm:
  811|  7.44k|    size_t num_tables) {
  812|  7.44k|  uint32_t src_offset = 0;
  813|   928k|  for (size_t i = 0; i < num_tables; ++i) {
  ------------------
  |  Branch (813:22): [True: 921k, False: 7.12k]
  ------------------
  814|   921k|    Table* table = &(*tables)[i];
  815|   921k|    uint8_t flag_byte;
  816|   921k|    if (PREDICT_FALSE(!file->ReadU8(&flag_byte))) {
  ------------------
  |  |   48|   921k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 94, False: 921k]
  |  |  ------------------
  ------------------
  817|     94|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     94|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  818|     94|    }
  819|   921k|    uint32_t tag;
  820|   921k|    if ((flag_byte & 0x3f) == 0x3f) {
  ------------------
  |  Branch (820:9): [True: 8.98k, False: 912k]
  ------------------
  821|  8.98k|      if (PREDICT_FALSE(!file->ReadU32(&tag))) {
  ------------------
  |  |   48|  8.98k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 8, False: 8.97k]
  |  |  ------------------
  ------------------
  822|      8|        return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      8|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  823|      8|      }
  824|   912k|    } else {
  825|   912k|      tag = kKnownTags[flag_byte & 0x3f];
  826|   912k|    }
  827|   921k|    uint32_t flags = 0;
  828|   921k|    uint8_t xform_version = (flag_byte >> 6) & 0x03;
  829|       |
  830|       |    // 0 means xform for glyph/loca, non-0 for others
  831|   921k|    if (tag == kGlyfTableTag || tag == kLocaTableTag) {
  ------------------
  |  Branch (831:9): [True: 4.55k, False: 916k]
  |  Branch (831:33): [True: 12.0k, False: 904k]
  ------------------
  832|  16.5k|      if (xform_version == 0) {
  ------------------
  |  Branch (832:11): [True: 4.78k, False: 11.7k]
  ------------------
  833|  4.78k|        flags |= kWoff2FlagsTransform;
  834|  4.78k|      }
  835|   904k|    } else if (xform_version != 0) {
  ------------------
  |  Branch (835:16): [True: 67.0k, False: 837k]
  ------------------
  836|  67.0k|      flags |= kWoff2FlagsTransform;
  837|  67.0k|    }
  838|   921k|    flags |= xform_version;
  839|       |
  840|   921k|    uint32_t dst_length;
  841|   921k|    if (PREDICT_FALSE(!ReadBase128(file, &dst_length))) {
  ------------------
  |  |   48|   921k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 131, False: 921k]
  |  |  ------------------
  ------------------
  842|    131|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|    131|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  843|    131|    }
  844|   921k|    uint32_t transform_length = dst_length;
  845|   921k|    if ((flags & kWoff2FlagsTransform) != 0) {
  ------------------
  |  Branch (845:9): [True: 71.7k, False: 849k]
  ------------------
  846|  71.7k|      if (PREDICT_FALSE(!ReadBase128(file, &transform_length))) {
  ------------------
  |  |   48|  71.7k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 15, False: 71.7k]
  |  |  ------------------
  ------------------
  847|     15|        return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     15|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  848|     15|      }
  849|  71.7k|      if (PREDICT_FALSE(tag == kLocaTableTag && transform_length)) {
  ------------------
  |  |   48|  73.9k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 66, False: 71.6k]
  |  |  |  Branch (48:44): [True: 2.24k, False: 69.4k]
  |  |  |  Branch (48:44): [True: 66, False: 2.17k]
  |  |  ------------------
  ------------------
  850|     66|        return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     66|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  851|     66|      }
  852|  71.7k|    }
  853|   920k|    if (PREDICT_FALSE(src_offset + transform_length < src_offset)) {
  ------------------
  |  |   48|   920k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 2, False: 920k]
  |  |  ------------------
  ------------------
  854|      2|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      2|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  855|      2|    }
  856|   920k|    table->src_offset = src_offset;
  857|   920k|    table->src_length = transform_length;
  858|   920k|    src_offset += transform_length;
  859|       |
  860|   920k|    table->tag = tag;
  861|   920k|    table->flags = flags;
  862|   920k|    table->transform_length = transform_length;
  863|   920k|    table->dst_length = dst_length;
  864|   920k|  }
  865|  7.12k|  return true;
  866|  7.44k|}
woff2_dec.cc:_ZN5woff212_GLOBAL__N_125ComputeOffsetToFirstTableERKNS0_11WOFF2HeaderE:
  894|  13.2k|uint64_t ComputeOffsetToFirstTable(const WOFF2Header& hdr) {
  895|  13.2k|  uint64_t offset = kSfntHeaderSize +
  896|  13.2k|    kSfntEntrySize * static_cast<uint64_t>(hdr.num_tables);
  897|  13.2k|  if (hdr.header_version) {
  ------------------
  |  Branch (897:7): [True: 558, False: 12.7k]
  ------------------
  898|    558|    offset = CollectionHeaderSize(hdr.header_version, hdr.ttc_fonts.size())
  899|    558|      + kSfntHeaderSize * hdr.ttc_fonts.size();
  900|  8.65k|    for (const auto& ttc_font : hdr.ttc_fonts) {
  ------------------
  |  Branch (900:31): [True: 8.65k, False: 558]
  ------------------
  901|  8.65k|      offset += kSfntEntrySize * ttc_font.table_indices.size();
  902|  8.65k|    }
  903|    558|  }
  904|  13.2k|  return offset;
  905|  13.2k|}
woff2_dec.cc:_ZN5woff212_GLOBAL__N_112WriteHeadersEPKhmPNS0_15RebuildMetadataEPNS0_11WOFF2HeaderEPNS_8WOFF2OutE:
 1257|  6.51k|                  WOFF2Header* hdr, WOFF2Out* out) {
 1258|  6.51k|  std::vector<uint8_t> output(ComputeOffsetToFirstTable(*hdr), 0);
 1259|       |
 1260|       |  // Re-order tables in output (OTSpec) order
 1261|  6.51k|  std::vector<Table> sorted_tables(hdr->tables);
 1262|  6.51k|  if (hdr->header_version) {
  ------------------
  |  Branch (1262:7): [True: 274, False: 6.23k]
  ------------------
 1263|       |    // collection; we have to sort the table offset vector in each font
 1264|  3.83k|    for (auto& ttc_font : hdr->ttc_fonts) {
  ------------------
  |  Branch (1264:25): [True: 3.83k, False: 274]
  ------------------
 1265|  3.83k|      std::map<uint32_t, uint16_t> sorted_index_by_tag;
 1266|   107k|      for (auto table_index : ttc_font.table_indices) {
  ------------------
  |  Branch (1266:29): [True: 107k, False: 3.83k]
  ------------------
 1267|   107k|        sorted_index_by_tag[hdr->tables[table_index].tag] = table_index;
 1268|   107k|      }
 1269|  3.83k|      uint16_t index = 0;
 1270|  29.1k|      for (auto& i : sorted_index_by_tag) {
  ------------------
  |  Branch (1270:20): [True: 29.1k, False: 3.83k]
  ------------------
 1271|  29.1k|        ttc_font.table_indices[index++] = i.second;
 1272|  29.1k|      }
 1273|  3.83k|    }
 1274|  6.23k|  } else {
 1275|       |    // non-collection; we can just sort the tables
 1276|  6.23k|    std::sort(sorted_tables.begin(), sorted_tables.end());
 1277|  6.23k|  }
 1278|       |
 1279|       |  // Start building the font
 1280|  6.51k|  uint8_t* result = &output[0];
 1281|  6.51k|  size_t offset = 0;
 1282|  6.51k|  if (hdr->header_version) {
  ------------------
  |  Branch (1282:7): [True: 274, False: 6.23k]
  ------------------
 1283|       |    // TTC header
 1284|    274|    offset = StoreU32(result, offset, hdr->flavor);  // TAG TTCTag
 1285|    274|    offset = StoreU32(result, offset, hdr->header_version);  // FIXED Version
 1286|    274|    offset = StoreU32(result, offset, hdr->ttc_fonts.size());  // ULONG numFonts
 1287|       |    // Space for ULONG OffsetTable[numFonts] (zeroed initially)
 1288|    274|    size_t offset_table = offset;  // keep start of offset table for later
 1289|  4.10k|    for (size_t i = 0; i < hdr->ttc_fonts.size(); i++) {
  ------------------
  |  Branch (1289:24): [True: 3.83k, False: 274]
  ------------------
 1290|  3.83k|      offset = StoreU32(result, offset, 0);  // will fill real values in later
 1291|  3.83k|    }
 1292|       |    // space for DSIG fields for header v2
 1293|    274|    if (hdr->header_version == 0x00020000) {
  ------------------
  |  Branch (1293:9): [True: 189, False: 85]
  ------------------
 1294|    189|      offset = StoreU32(result, offset, 0);  // ULONG ulDsigTag
 1295|    189|      offset = StoreU32(result, offset, 0);  // ULONG ulDsigLength
 1296|    189|      offset = StoreU32(result, offset, 0);  // ULONG ulDsigOffset
 1297|    189|    }
 1298|       |
 1299|       |    // write Offset Tables and store the location of each in TTC Header
 1300|    274|    metadata->font_infos.resize(hdr->ttc_fonts.size());
 1301|  4.10k|    for (size_t i = 0; i < hdr->ttc_fonts.size(); i++) {
  ------------------
  |  Branch (1301:24): [True: 3.83k, False: 274]
  ------------------
 1302|  3.83k|      TtcFont& ttc_font = hdr->ttc_fonts[i];
 1303|       |
 1304|       |      // write Offset Table location into TTC Header
 1305|  3.83k|      offset_table = StoreU32(result, offset_table, offset);
 1306|       |
 1307|       |      // write the actual offset table so our header doesn't lie
 1308|  3.83k|      ttc_font.dst_offset = offset;
 1309|  3.83k|      offset = StoreOffsetTable(result, offset, ttc_font.flavor,
 1310|  3.83k|                                ttc_font.table_indices.size());
 1311|       |
 1312|   107k|      for (const auto table_index : ttc_font.table_indices) {
  ------------------
  |  Branch (1312:35): [True: 107k, False: 3.83k]
  ------------------
 1313|   107k|        uint32_t tag = hdr->tables[table_index].tag;
 1314|   107k|        metadata->font_infos[i].table_entry_by_tag[tag] = offset;
 1315|   107k|        offset = StoreTableEntry(result, offset, tag);
 1316|   107k|      }
 1317|       |
 1318|  3.83k|      ttc_font.header_checksum = ComputeULongSum(&output[ttc_font.dst_offset],
 1319|  3.83k|                                                 offset - ttc_font.dst_offset);
 1320|  3.83k|    }
 1321|  6.23k|  } else {
 1322|  6.23k|    metadata->font_infos.resize(1);
 1323|  6.23k|    offset = StoreOffsetTable(result, offset, hdr->flavor, hdr->num_tables);
 1324|   187k|    for (uint16_t i = 0; i < hdr->num_tables; ++i) {
  ------------------
  |  Branch (1324:26): [True: 181k, False: 6.23k]
  ------------------
 1325|   181k|      metadata->font_infos[0].table_entry_by_tag[sorted_tables[i].tag] = offset;
 1326|   181k|      offset = StoreTableEntry(result, offset, sorted_tables[i].tag);
 1327|   181k|    }
 1328|  6.23k|  }
 1329|       |
 1330|  6.51k|  if (PREDICT_FALSE(!out->Write(&output[0], output.size()))) {
  ------------------
  |  |   48|  6.51k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 6.51k]
  |  |  ------------------
  ------------------
 1331|      0|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1332|      0|  }
 1333|  6.51k|  metadata->header_checksum = ComputeULongSum(&output[0], output.size());
 1334|  6.51k|  return true;
 1335|  6.51k|}
woff2_dec.cc:_ZN5woff212_GLOBAL__N_116StoreOffsetTableEPhmjt:
  870|  10.0k|                        uint16_t num_tables) {
  871|  10.0k|  offset = StoreU32(result, offset, flavor);  // sfnt version
  872|  10.0k|  offset = Store16(result, offset, num_tables);  // num_tables
  873|  10.0k|  unsigned max_pow2 = 0;
  874|  34.8k|  while (1u << (max_pow2 + 1) <= num_tables) {
  ------------------
  |  Branch (874:10): [True: 24.7k, False: 10.0k]
  ------------------
  875|  24.7k|    max_pow2++;
  876|  24.7k|  }
  877|  10.0k|  const uint16_t output_search_range = (1u << max_pow2) << 4;
  878|  10.0k|  offset = Store16(result, offset, output_search_range);  // searchRange
  879|  10.0k|  offset = Store16(result, offset, max_pow2);  // entrySelector
  880|       |  // rangeShift
  881|  10.0k|  offset = Store16(result, offset, (num_tables << 4) - output_search_range);
  882|  10.0k|  return offset;
  883|  10.0k|}
woff2_dec.cc:_ZN5woff212_GLOBAL__N_115StoreTableEntryEPhjj:
  885|   289k|size_t StoreTableEntry(uint8_t* result, uint32_t offset, uint32_t tag) {
  886|   289k|  offset = StoreU32(result, offset, tag);
  887|   289k|  offset = StoreU32(result, offset, 0);
  888|   289k|  offset = StoreU32(result, offset, 0);
  889|   289k|  offset = StoreU32(result, offset, 0);
  890|   289k|  return offset;
  891|   289k|}
woff2_dec.cc:_ZN5woff212_GLOBAL__N_115Woff2UncompressEPhmPKhm:
  799|  6.02k|  const uint8_t* src_buf, size_t src_size) {
  800|  6.02k|  size_t uncompressed_size = dst_size;
  801|  6.02k|  BrotliDecoderResult result = BrotliDecoderDecompress(
  802|  6.02k|      src_size, src_buf, &uncompressed_size, dst_buf);
  803|  6.02k|  if (PREDICT_FALSE(result != BROTLI_DECODER_RESULT_SUCCESS ||
  ------------------
  |  |   48|  7.32k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 4.75k, False: 1.27k]
  |  |  |  Branch (48:44): [True: 4.72k, False: 1.30k]
  |  |  |  Branch (48:44): [True: 30, False: 1.27k]
  |  |  ------------------
  ------------------
  804|  6.02k|                    uncompressed_size != dst_size)) {
  805|  4.75k|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|  4.75k|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  806|  4.75k|  }
  807|  1.27k|  return true;
  808|  6.02k|}
woff2_dec.cc:_ZN5woff212_GLOBAL__N_115ReconstructFontEPhjPNS0_15RebuildMetadataEPNS0_11WOFF2HeaderEmPNS_8WOFF2OutE:
  928|  1.68k|                     WOFF2Out* out) {
  929|  1.68k|  size_t dest_offset = out->Size();
  930|  1.68k|  uint8_t table_entry[12];
  931|  1.68k|  WOFF2FontInfo* info = &metadata->font_infos[font_index];
  932|  1.68k|  std::vector<Table*> tables = Tables(hdr, font_index);
  933|       |
  934|       |  // 'glyf' without 'loca' doesn't make sense
  935|  1.68k|  const Table* glyf_table = FindTable(&tables, kGlyfTableTag);
  936|  1.68k|  const Table* loca_table = FindTable(&tables, kLocaTableTag);
  937|  1.68k|  if (PREDICT_FALSE(static_cast<bool>(glyf_table) !=
  ------------------
  |  |   48|  1.68k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 1, False: 1.68k]
  |  |  ------------------
  ------------------
  938|  1.68k|                    static_cast<bool>(loca_table))) {
  939|       |#ifdef FONT_COMPRESSION_BIN
  940|       |      fprintf(stderr, "Cannot have just one of glyf/loca\n");
  941|       |#endif
  942|      1|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      1|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  943|      1|  }
  944|       |
  945|  1.68k|  if (glyf_table != NULL) {
  ------------------
  |  Branch (945:7): [True: 704, False: 976]
  ------------------
  946|    704|    if (PREDICT_FALSE((glyf_table->flags & kWoff2FlagsTransform)
  ------------------
  |  |   48|    704|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 1, False: 703]
  |  |  ------------------
  ------------------
  947|    704|                      != (loca_table->flags & kWoff2FlagsTransform))) {
  948|       |#ifdef FONT_COMPRESSION_BIN
  949|       |      fprintf(stderr, "Cannot transform just one of glyf/loca\n");
  950|       |#endif
  951|      1|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      1|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  952|      1|    }
  953|    704|  }
  954|       |
  955|  1.67k|  uint32_t font_checksum = metadata->header_checksum;
  956|  1.67k|  if (hdr->header_version) {
  ------------------
  |  Branch (956:7): [True: 556, False: 1.12k]
  ------------------
  957|    556|    font_checksum = hdr->ttc_fonts[font_index].header_checksum;
  958|    556|  }
  959|       |
  960|  1.67k|  uint32_t loca_checksum = 0;
  961|  10.8k|  for (size_t i = 0; i < tables.size(); i++) {
  ------------------
  |  Branch (961:22): [True: 10.0k, False: 812]
  ------------------
  962|  10.0k|    Table& table = *tables[i];
  963|       |
  964|  10.0k|    std::pair<uint32_t, uint32_t> checksum_key = {table.tag, table.src_offset};
  965|  10.0k|    bool reused = metadata->checksums.find(checksum_key)
  966|  10.0k|               != metadata->checksums.end();
  967|  10.0k|    if (PREDICT_FALSE(font_index == 0 && reused)) {
  ------------------
  |  |   48|  17.6k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 35, False: 10.0k]
  |  |  |  Branch (48:44): [True: 7.56k, False: 2.48k]
  |  |  |  Branch (48:44): [True: 35, False: 7.52k]
  |  |  ------------------
  ------------------
  968|     35|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     35|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  969|     35|    }
  970|       |
  971|       |    // TODO(user) a collection with optimized hmtx that reused glyf/loca
  972|       |    // would fail. We don't optimize hmtx for collections yet.
  973|  10.0k|    if (PREDICT_FALSE(static_cast<uint64_t>(table.src_offset) + table.src_length
  ------------------
  |  |   48|  10.0k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 10.0k]
  |  |  ------------------
  ------------------
  974|  10.0k|        > transformed_buf_size)) {
  975|      0|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  976|      0|    }
  977|       |
  978|  10.0k|    if (table.tag == kHheaTableTag) {
  ------------------
  |  Branch (978:9): [True: 659, False: 9.35k]
  ------------------
  979|    659|      if (!ReadNumHMetrics(transformed_buf + table.src_offset,
  ------------------
  |  Branch (979:11): [True: 17, False: 642]
  ------------------
  980|    659|          table.src_length, &info->num_hmetrics)) {
  981|     17|        return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     17|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  982|     17|      }
  983|    659|    }
  984|       |
  985|  9.99k|    uint32_t checksum = 0;
  986|  9.99k|    if (!reused) {
  ------------------
  |  Branch (986:9): [True: 7.78k, False: 2.21k]
  ------------------
  987|  7.78k|      if ((table.flags & kWoff2FlagsTransform) != kWoff2FlagsTransform) {
  ------------------
  |  Branch (987:11): [True: 6.80k, False: 976]
  ------------------
  988|  6.80k|        if (table.tag == kHeadTableTag) {
  ------------------
  |  Branch (988:13): [True: 148, False: 6.65k]
  ------------------
  989|    148|          if (PREDICT_FALSE(table.src_length < 12)) {
  ------------------
  |  |   48|    148|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 10, False: 138]
  |  |  ------------------
  ------------------
  990|     10|            return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     10|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  991|     10|          }
  992|       |          // checkSumAdjustment = 0
  993|    138|          StoreU32(transformed_buf + table.src_offset, 8, 0);
  994|    138|        }
  995|  6.79k|        table.dst_offset = dest_offset;
  996|  6.79k|        checksum = ComputeULongSum(transformed_buf + table.src_offset,
  997|  6.79k|                                   table.src_length);
  998|  6.79k|        if (PREDICT_FALSE(!out->Write(transformed_buf + table.src_offset,
  ------------------
  |  |   48|  6.79k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 6.79k]
  |  |  ------------------
  ------------------
  999|  6.79k|            table.src_length))) {
 1000|      0|          return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1001|      0|        }
 1002|  6.79k|      } else {
 1003|    976|        if (table.tag == kGlyfTableTag) {
  ------------------
  |  Branch (1003:13): [True: 671, False: 305]
  ------------------
 1004|    671|          table.dst_offset = dest_offset;
 1005|       |
 1006|    671|          Table* loca_table = FindTable(&tables, kLocaTableTag);
 1007|    671|          if (PREDICT_FALSE(!ReconstructGlyf(transformed_buf + table.src_offset,
  ------------------
  |  |   48|    671|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 589, False: 82]
  |  |  ------------------
  ------------------
 1008|    671|              &table, &checksum, loca_table, &loca_checksum, info, out))) {
 1009|    589|            return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|    589|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1010|    589|          }
 1011|    671|        } else if (table.tag == kLocaTableTag) {
  ------------------
  |  Branch (1011:20): [True: 90, False: 215]
  ------------------
 1012|       |          // All the work was done by ReconstructGlyf. We already know checksum.
 1013|     90|          checksum = loca_checksum;
 1014|    215|        } else if (table.tag == kHmtxTableTag) {
  ------------------
  |  Branch (1014:20): [True: 63, False: 152]
  ------------------
 1015|     63|          table.dst_offset = dest_offset;
 1016|       |          // Tables are sorted so all the info we need has been gathered.
 1017|     63|          if (PREDICT_FALSE(!ReconstructTransformedHmtx(
  ------------------
  |  |   48|     63|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 34, False: 29]
  |  |  ------------------
  ------------------
 1018|     63|              transformed_buf + table.src_offset, table.src_length,
 1019|     63|              info->num_glyphs, info->num_hmetrics, info->x_mins, &checksum,
 1020|     63|              out))) {
 1021|     34|            return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     34|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1022|     34|          }
 1023|    152|        } else {
 1024|    152|          return FONT_COMPRESSION_FAILURE();  // transform unknown
  ------------------
  |  |   40|    152|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1025|    152|        }
 1026|    976|      }
 1027|  6.99k|      metadata->checksums[checksum_key] = checksum;
 1028|  6.99k|    } else {
 1029|  2.21k|      checksum = metadata->checksums[checksum_key];
 1030|  2.21k|    }
 1031|  9.21k|    font_checksum += checksum;
 1032|       |
 1033|       |    // update the table entry with real values.
 1034|  9.21k|    StoreU32(table_entry, 0, checksum);
 1035|  9.21k|    StoreU32(table_entry, 4, table.dst_offset);
 1036|  9.21k|    StoreU32(table_entry, 8, table.dst_length);
 1037|  9.21k|    if (PREDICT_FALSE(!out->Write(table_entry,
  ------------------
  |  |   48|  9.21k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 9.21k]
  |  |  ------------------
  ------------------
 1038|  9.21k|        info->table_entry_by_tag[table.tag] + 4, 12))) {
 1039|      0|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1040|      0|    }
 1041|       |
 1042|       |    // We replaced 0's. Update overall checksum.
 1043|  9.21k|    font_checksum += ComputeULongSum(table_entry, 12);
 1044|       |
 1045|  9.21k|    if (PREDICT_FALSE(!Pad4(out))) {
  ------------------
  |  |   48|  9.21k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 9.21k]
  |  |  ------------------
  ------------------
 1046|      0|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1047|      0|    }
 1048|       |
 1049|  9.21k|    if (PREDICT_FALSE(static_cast<uint64_t>(table.dst_offset + table.dst_length)
  ------------------
  |  |   48|  9.21k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 30, False: 9.18k]
  |  |  ------------------
  ------------------
 1050|  9.21k|        > out->Size())) {
 1051|     30|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     30|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1052|     30|    }
 1053|  9.18k|    dest_offset = out->Size();
 1054|  9.18k|  }
 1055|       |
 1056|       |  // Update 'head' checkSumAdjustment. We already set it to 0 and summed font.
 1057|    812|  Table* head_table = FindTable(&tables, kHeadTableTag);
 1058|    812|  if (head_table) {
  ------------------
  |  Branch (1058:7): [True: 168, False: 644]
  ------------------
 1059|    168|    if (PREDICT_FALSE(head_table->dst_length < 12)) {
  ------------------
  |  |   48|    168|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 1, False: 167]
  |  |  ------------------
  ------------------
 1060|      1|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      1|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1061|      1|    }
 1062|    167|    uint8_t checksum_adjustment[4];
 1063|    167|    StoreU32(checksum_adjustment, 0, 0xB1B0AFBA - font_checksum);
 1064|    167|    if (PREDICT_FALSE(!out->Write(checksum_adjustment,
  ------------------
  |  |   48|    167|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 167]
  |  |  ------------------
  ------------------
 1065|    167|                                  head_table->dst_offset + 8, 4))) {
 1066|      0|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
 1067|      0|    }
 1068|    167|  }
 1069|       |
 1070|    811|  return true;
 1071|    812|}
woff2_dec.cc:_ZN5woff212_GLOBAL__N_16TablesEPNS0_11WOFF2HeaderEm:
  907|  1.68k|std::vector<Table*> Tables(WOFF2Header* hdr, size_t font_index) {
  908|  1.68k|  std::vector<Table*> tables;
  909|  1.68k|  if (PREDICT_FALSE(hdr->header_version)) {
  ------------------
  |  |   48|  1.68k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 556, False: 1.12k]
  |  |  ------------------
  ------------------
  910|  2.83k|    for (auto index : hdr->ttc_fonts[font_index].table_indices) {
  ------------------
  |  Branch (910:21): [True: 2.83k, False: 556]
  ------------------
  911|  2.83k|      tables.push_back(&hdr->tables[index]);
  912|  2.83k|    }
  913|  1.12k|  } else {
  914|  11.3k|    for (auto& table : hdr->tables) {
  ------------------
  |  Branch (914:22): [True: 11.3k, False: 1.12k]
  ------------------
  915|  11.3k|      tables.push_back(&table);
  916|  11.3k|    }
  917|  1.12k|  }
  918|  1.68k|  return tables;
  919|  1.68k|}
woff2_dec.cc:_ZN5woff212_GLOBAL__N_19FindTableEPNSt3__16vectorIPNS_5TableENS1_9allocatorIS4_EEEEj:
  680|  4.84k|Table* FindTable(std::vector<Table*>* tables, uint32_t tag) {
  681|  29.2k|  for (Table* table : *tables) {
  ------------------
  |  Branch (681:21): [True: 29.2k, False: 2.59k]
  ------------------
  682|  29.2k|    if (table->tag == tag) {
  ------------------
  |  Branch (682:9): [True: 2.24k, False: 27.0k]
  ------------------
  683|  2.24k|      return table;
  684|  2.24k|    }
  685|  29.2k|  }
  686|  2.59k|  return NULL;
  687|  4.84k|}
woff2_dec.cc:_ZN5woff212_GLOBAL__N_115ReadNumHMetricsEPKhmPt:
  691|    659|                     uint16_t* num_hmetrics) {
  692|       |  // Skip 34 to reach 'hhea' numberOfHMetrics
  693|    659|  Buffer buffer(data, data_size);
  694|    659|  if (PREDICT_FALSE(!buffer.Skip(34) || !buffer.ReadU16(num_hmetrics))) {
  ------------------
  |  |   48|  1.30k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 17, False: 642]
  |  |  |  Branch (48:44): [True: 16, False: 643]
  |  |  |  Branch (48:44): [True: 1, False: 642]
  |  |  ------------------
  ------------------
  695|     17|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     17|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  696|     17|  }
  697|    642|  return true;
  698|    659|}
woff2_dec.cc:_ZN5woff212_GLOBAL__N_115ReconstructGlyfEPKhPNS_5TableEPjS4_S5_PNS0_13WOFF2FontInfoEPNS_8WOFF2OutE:
  409|    671|                     WOFF2Out* out) {
  410|    671|  static const int kNumSubStreams = 7;
  411|    671|  Buffer file(data, glyf_table->transform_length);
  412|    671|  uint16_t version;
  413|    671|  std::vector<std::pair<const uint8_t*, size_t> > substreams(kNumSubStreams);
  414|    671|  const size_t glyf_start = out->Size();
  415|       |
  416|    671|  if (PREDICT_FALSE(!file.ReadU16(&version))) {
  ------------------
  |  |   48|    671|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 8, False: 663]
  |  |  ------------------
  ------------------
  417|      8|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      8|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  418|      8|  }
  419|       |
  420|    663|  uint16_t flags;
  421|    663|  if (PREDICT_FALSE(!file.ReadU16(&flags))) {
  ------------------
  |  |   48|    663|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 4, False: 659]
  |  |  ------------------
  ------------------
  422|      4|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      4|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  423|      4|  }
  424|    659|  bool has_overlap_bitmap = (flags & FLAG_OVERLAP_SIMPLE_BITMAP);
  425|       |
  426|    659|  if (PREDICT_FALSE(!file.ReadU16(&info->num_glyphs) ||
  ------------------
  |  |   48|  1.31k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 15, False: 644]
  |  |  |  Branch (48:44): [True: 5, False: 654]
  |  |  |  Branch (48:44): [True: 10, False: 644]
  |  |  ------------------
  ------------------
  427|    659|      !file.ReadU16(&info->index_format))) {
  428|     15|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     15|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  429|     15|  }
  430|       |
  431|       |  // https://dev.w3.org/webfonts/WOFF2/spec/#conform-mustRejectLoca
  432|       |  // dst_length here is origLength in the spec
  433|    644|  uint32_t expected_loca_dst_length = (info->index_format ? 4 : 2)
  ------------------
  |  Branch (433:40): [True: 392, False: 252]
  ------------------
  434|    644|    * (static_cast<uint32_t>(info->num_glyphs) + 1);
  435|    644|  if (PREDICT_FALSE(loca_table->dst_length != expected_loca_dst_length)) {
  ------------------
  |  |   48|    644|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 58, False: 586]
  |  |  ------------------
  ------------------
  436|     58|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     58|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  437|     58|  }
  438|       |
  439|    586|  unsigned int offset = (2 + kNumSubStreams) * 4;
  440|    586|  if (PREDICT_FALSE(offset > glyf_table->transform_length)) {
  ------------------
  |  |   48|    586|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 1, False: 585]
  |  |  ------------------
  ------------------
  441|      1|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      1|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  442|      1|  }
  443|       |  // Invariant from here on: data_size >= offset
  444|  4.36k|  for (int i = 0; i < kNumSubStreams; ++i) {
  ------------------
  |  Branch (444:19): [True: 3.83k, False: 538]
  ------------------
  445|  3.83k|    uint32_t substream_size;
  446|  3.83k|    if (PREDICT_FALSE(!file.ReadU32(&substream_size))) {
  ------------------
  |  |   48|  3.83k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 3.83k]
  |  |  ------------------
  ------------------
  447|      0|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  448|      0|    }
  449|  3.83k|    if (PREDICT_FALSE(substream_size > glyf_table->transform_length - offset)) {
  ------------------
  |  |   48|  3.83k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 47, False: 3.78k]
  |  |  ------------------
  ------------------
  450|     47|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     47|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  451|     47|    }
  452|  3.78k|    substreams[i] = std::make_pair(data + offset, substream_size);
  453|  3.78k|    offset += substream_size;
  454|  3.78k|  }
  455|    538|  Buffer n_contour_stream(substreams[0].first, substreams[0].second);
  456|    538|  Buffer n_points_stream(substreams[1].first, substreams[1].second);
  457|    538|  Buffer flag_stream(substreams[2].first, substreams[2].second);
  458|    538|  Buffer glyph_stream(substreams[3].first, substreams[3].second);
  459|    538|  Buffer composite_stream(substreams[4].first, substreams[4].second);
  460|    538|  Buffer bbox_stream(substreams[5].first, substreams[5].second);
  461|    538|  Buffer instruction_stream(substreams[6].first, substreams[6].second);
  462|       |
  463|    538|  const uint8_t* overlap_bitmap = nullptr;
  464|    538|  unsigned int overlap_bitmap_length = 0;
  465|    538|  if (has_overlap_bitmap) {
  ------------------
  |  Branch (465:7): [True: 160, False: 378]
  ------------------
  466|    160|    overlap_bitmap_length = (info->num_glyphs + 7) >> 3;
  467|    160|    overlap_bitmap = data + offset;
  468|    160|    if (PREDICT_FALSE(overlap_bitmap_length >
  ------------------
  |  |   48|    160|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 5, False: 155]
  |  |  ------------------
  ------------------
  469|    160|                           glyf_table->transform_length - offset)) {
  470|      5|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      5|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  471|      5|    }
  472|    160|  }
  473|       |
  474|    533|  std::vector<uint32_t> loca_values(info->num_glyphs + 1);
  475|    533|  std::vector<unsigned int> n_points_vec;
  476|    533|  std::unique_ptr<Point[]> points;
  477|    533|  size_t points_size = 0;
  478|    533|  const uint8_t* bbox_bitmap = bbox_stream.buffer();
  479|       |  // Safe because num_glyphs is bounded
  480|    533|  unsigned int bitmap_length = ((info->num_glyphs + 31) >> 5) << 2;
  481|    533|  if (!bbox_stream.Skip(bitmap_length)) {
  ------------------
  |  Branch (481:7): [True: 1, False: 532]
  ------------------
  482|      1|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      1|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  483|      1|  }
  484|       |
  485|       |  // Temp buffer for glyph's.
  486|    532|  size_t glyph_buf_size = kDefaultGlyphBuf;
  487|    532|  std::unique_ptr<uint8_t[]> glyph_buf(new uint8_t[glyph_buf_size]);
  488|       |
  489|    532|  info->x_mins.resize(info->num_glyphs);
  490|  79.3k|  for (unsigned int i = 0; i < info->num_glyphs; ++i) {
  ------------------
  |  Branch (490:28): [True: 79.2k, False: 82]
  ------------------
  491|  79.2k|    size_t glyph_size = 0;
  492|  79.2k|    uint16_t n_contours = 0;
  493|  79.2k|    bool have_bbox = false;
  494|  79.2k|    if (bbox_bitmap[i >> 3] & (0x80 >> (i & 7))) {
  ------------------
  |  Branch (494:9): [True: 1.07k, False: 78.1k]
  ------------------
  495|  1.07k|      have_bbox = true;
  496|  1.07k|    }
  497|  79.2k|    if (PREDICT_FALSE(!n_contour_stream.ReadU16(&n_contours))) {
  ------------------
  |  |   48|  79.2k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 15, False: 79.2k]
  |  |  ------------------
  ------------------
  498|     15|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     15|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  499|     15|    }
  500|       |
  501|  79.2k|    if (n_contours == 0xffff) {
  ------------------
  |  Branch (501:9): [True: 635, False: 78.5k]
  ------------------
  502|       |      // composite glyph
  503|    635|      bool have_instructions = false;
  504|    635|      unsigned int instruction_size = 0;
  505|    635|      if (PREDICT_FALSE(!have_bbox)) {
  ------------------
  |  |   48|    635|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 22, False: 613]
  |  |  ------------------
  ------------------
  506|       |        // composite glyphs must have an explicit bbox
  507|     22|        return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     22|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  508|     22|      }
  509|       |
  510|    613|      size_t composite_size;
  511|    613|      if (PREDICT_FALSE(!SizeOfComposite(composite_stream, &composite_size,
  ------------------
  |  |   48|    613|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 22, False: 591]
  |  |  ------------------
  ------------------
  512|    613|                                         &have_instructions))) {
  513|     22|        return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     22|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  514|     22|      }
  515|    591|      if (have_instructions) {
  ------------------
  |  Branch (515:11): [True: 235, False: 356]
  ------------------
  516|    235|        if (PREDICT_FALSE(!Read255UShort(&glyph_stream, &instruction_size))) {
  ------------------
  |  |   48|    235|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 1, False: 234]
  |  |  ------------------
  ------------------
  517|      1|          return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      1|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  518|      1|        }
  519|    235|      }
  520|       |
  521|    590|      size_t size_needed = 12 + composite_size + instruction_size;
  522|    590|      if (PREDICT_FALSE(glyph_buf_size < size_needed)) {
  ------------------
  |  |   48|    590|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 7, False: 583]
  |  |  ------------------
  ------------------
  523|      7|        glyph_buf.reset(new uint8_t[size_needed]);
  524|      7|        glyph_buf_size = size_needed;
  525|      7|      }
  526|       |
  527|    590|      glyph_size = Store16(glyph_buf.get(), glyph_size, n_contours);
  528|    590|      if (PREDICT_FALSE(!bbox_stream.Read(glyph_buf.get() + glyph_size, 8))) {
  ------------------
  |  |   48|    590|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 13, False: 577]
  |  |  ------------------
  ------------------
  529|     13|        return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     13|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  530|     13|      }
  531|    577|      glyph_size += 8;
  532|       |
  533|    577|      if (PREDICT_FALSE(!composite_stream.Read(glyph_buf.get() + glyph_size,
  ------------------
  |  |   48|    577|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 577]
  |  |  ------------------
  ------------------
  534|    577|            composite_size))) {
  535|      0|        return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  536|      0|      }
  537|    577|      glyph_size += composite_size;
  538|    577|      if (have_instructions) {
  ------------------
  |  Branch (538:11): [True: 224, False: 353]
  ------------------
  539|    224|        glyph_size = Store16(glyph_buf.get(), glyph_size, instruction_size);
  540|    224|        if (PREDICT_FALSE(!instruction_stream.Read(glyph_buf.get() + glyph_size,
  ------------------
  |  |   48|    224|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 25, False: 199]
  |  |  ------------------
  ------------------
  541|    224|              instruction_size))) {
  542|     25|          return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     25|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  543|     25|        }
  544|    199|        glyph_size += instruction_size;
  545|    199|      }
  546|  78.5k|    } else if (n_contours > 0) {
  ------------------
  |  Branch (546:16): [True: 66.2k, False: 12.3k]
  ------------------
  547|       |      // simple glyph
  548|  66.2k|      n_points_vec.clear();
  549|  66.2k|      unsigned int total_n_points = 0;
  550|  66.2k|      unsigned int n_points_contour;
  551|   619k|      for (unsigned int j = 0; j < n_contours; ++j) {
  ------------------
  |  Branch (551:32): [True: 553k, False: 66.1k]
  ------------------
  552|   553k|        if (PREDICT_FALSE(
  ------------------
  |  |   48|   553k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 88, False: 553k]
  |  |  ------------------
  ------------------
  553|   553k|            !Read255UShort(&n_points_stream, &n_points_contour))) {
  554|     88|          return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     88|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  555|     88|        }
  556|   553k|        n_points_vec.push_back(n_points_contour);
  557|   553k|        if (PREDICT_FALSE(total_n_points + n_points_contour < total_n_points)) {
  ------------------
  |  |   48|   553k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 553k]
  |  |  ------------------
  ------------------
  558|      0|          return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  559|      0|        }
  560|   553k|        total_n_points += n_points_contour;
  561|   553k|      }
  562|  66.1k|      unsigned int flag_size = total_n_points;
  563|  66.1k|      if (PREDICT_FALSE(
  ------------------
  |  |   48|  66.1k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 60, False: 66.0k]
  |  |  ------------------
  ------------------
  564|  66.1k|          flag_size > flag_stream.length() - flag_stream.offset())) {
  565|     60|        return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     60|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  566|     60|      }
  567|  66.0k|      const uint8_t* flags_buf = flag_stream.buffer() + flag_stream.offset();
  568|  66.0k|      const uint8_t* triplet_buf = glyph_stream.buffer() +
  569|  66.0k|        glyph_stream.offset();
  570|  66.0k|      size_t triplet_size = glyph_stream.length() - glyph_stream.offset();
  571|  66.0k|      size_t triplet_bytes_consumed = 0;
  572|  66.0k|      if (points_size < total_n_points) {
  ------------------
  |  Branch (572:11): [True: 1.07k, False: 65.0k]
  ------------------
  573|  1.07k|        points_size = total_n_points;
  574|  1.07k|        points.reset(new Point[points_size]);
  575|  1.07k|      }
  576|  66.0k|      if (PREDICT_FALSE(!TripletDecode(flags_buf, triplet_buf, triplet_size,
  ------------------
  |  |   48|  66.0k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 72, False: 66.0k]
  |  |  ------------------
  ------------------
  577|  66.0k|          total_n_points, points.get(), &triplet_bytes_consumed))) {
  578|     72|        return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     72|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  579|     72|      }
  580|  66.0k|      if (PREDICT_FALSE(!flag_stream.Skip(flag_size))) {
  ------------------
  |  |   48|  66.0k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 66.0k]
  |  |  ------------------
  ------------------
  581|      0|        return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  582|      0|      }
  583|  66.0k|      if (PREDICT_FALSE(!glyph_stream.Skip(triplet_bytes_consumed))) {
  ------------------
  |  |   48|  66.0k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 66.0k]
  |  |  ------------------
  ------------------
  584|      0|        return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  585|      0|      }
  586|  66.0k|      unsigned int instruction_size;
  587|  66.0k|      if (PREDICT_FALSE(!Read255UShort(&glyph_stream, &instruction_size))) {
  ------------------
  |  |   48|  66.0k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 15, False: 65.9k]
  |  |  ------------------
  ------------------
  588|     15|        return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     15|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  589|     15|      }
  590|       |
  591|  65.9k|      if (PREDICT_FALSE(total_n_points >= (1 << 27)
  ------------------
  |  |   48|   131k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 65.9k]
  |  |  |  Branch (48:44): [True: 0, False: 65.9k]
  |  |  |  Branch (48:44): [True: 0, False: 65.9k]
  |  |  ------------------
  ------------------
  592|  65.9k|                        || instruction_size >= (1 << 30))) {
  593|      0|        return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  594|      0|      }
  595|  65.9k|      size_t size_needed = 12 + 2 * n_contours + 5 * total_n_points
  596|  65.9k|                           + instruction_size;
  597|  65.9k|      if (PREDICT_FALSE(glyph_buf_size < size_needed)) {
  ------------------
  |  |   48|  65.9k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 155, False: 65.8k]
  |  |  ------------------
  ------------------
  598|    155|        glyph_buf.reset(new uint8_t[size_needed]);
  599|    155|        glyph_buf_size = size_needed;
  600|    155|      }
  601|       |
  602|  65.9k|      glyph_size = Store16(glyph_buf.get(), glyph_size, n_contours);
  603|  65.9k|      if (have_bbox) {
  ------------------
  |  Branch (603:11): [True: 394, False: 65.5k]
  ------------------
  604|    394|        if (PREDICT_FALSE(!bbox_stream.Read(glyph_buf.get() + glyph_size, 8))) {
  ------------------
  |  |   48|    394|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 18, False: 376]
  |  |  ------------------
  ------------------
  605|     18|          return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     18|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  606|     18|        }
  607|  65.5k|      } else {
  608|  65.5k|        ComputeBbox(total_n_points, points.get(), glyph_buf.get());
  609|  65.5k|      }
  610|  65.9k|      glyph_size = kEndPtsOfContoursOffset;
  611|  65.9k|      int end_point = -1;
  612|   285k|      for (unsigned int contour_ix = 0; contour_ix < n_contours; ++contour_ix) {
  ------------------
  |  Branch (612:41): [True: 219k, False: 65.9k]
  ------------------
  613|   219k|        end_point += n_points_vec[contour_ix];
  614|   219k|        if (PREDICT_FALSE(end_point >= 65536)) {
  ------------------
  |  |   48|   219k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 9, False: 219k]
  |  |  ------------------
  ------------------
  615|      9|          return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      9|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  616|      9|        }
  617|   219k|        glyph_size = Store16(glyph_buf.get(), glyph_size, end_point);
  618|   219k|      }
  619|       |
  620|  65.9k|      glyph_size = Store16(glyph_buf.get(), glyph_size, instruction_size);
  621|  65.9k|      if (PREDICT_FALSE(!instruction_stream.Read(glyph_buf.get() + glyph_size,
  ------------------
  |  |   48|  65.9k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 79, False: 65.8k]
  |  |  ------------------
  ------------------
  622|  65.9k|                                                 instruction_size))) {
  623|     79|        return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     79|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  624|     79|      }
  625|  65.8k|      glyph_size += instruction_size;
  626|       |
  627|  65.8k|      bool has_overlap_bit =
  628|  65.8k|          has_overlap_bitmap && overlap_bitmap[i >> 3] & (0x80 >> (i & 7));
  ------------------
  |  Branch (628:11): [True: 1.36k, False: 64.5k]
  |  Branch (628:33): [True: 386, False: 979]
  ------------------
  629|       |
  630|  65.8k|      if (PREDICT_FALSE(!StorePoints(
  ------------------
  |  |   48|  65.8k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 65.8k]
  |  |  ------------------
  ------------------
  631|  65.8k|              total_n_points, points.get(), n_contours, instruction_size,
  632|  65.8k|              has_overlap_bit, glyph_buf.get(), glyph_buf_size, &glyph_size))) {
  633|      0|        return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  634|      0|      }
  635|  65.8k|    } else {
  636|       |      // n_contours == 0; empty glyph. Must NOT have a bbox.
  637|  12.3k|      if (PREDICT_FALSE(have_bbox)) {
  ------------------
  |  |   48|  12.3k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 11, False: 12.3k]
  |  |  ------------------
  ------------------
  638|       |#ifdef FONT_COMPRESSION_BIN
  639|       |        fprintf(stderr, "Empty glyph has a bbox\n");
  640|       |#endif
  641|     11|        return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     11|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  642|     11|      }
  643|  12.3k|    }
  644|       |
  645|  78.7k|    loca_values[i] = out->Size() - glyf_start;
  646|  78.7k|    if (PREDICT_FALSE(!out->Write(glyph_buf.get(), glyph_size))) {
  ------------------
  |  |   48|  78.7k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 78.7k]
  |  |  ------------------
  ------------------
  647|      0|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  648|      0|    }
  649|       |
  650|       |    // TODO(user) Old code aligned glyphs ... but do we actually need to?
  651|  78.7k|    if (PREDICT_FALSE(!Pad4(out))) {
  ------------------
  |  |   48|  78.7k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 78.7k]
  |  |  ------------------
  ------------------
  652|      0|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  653|      0|    }
  654|       |
  655|  78.7k|    *glyf_checksum += ComputeULongSum(glyph_buf.get(), glyph_size);
  656|       |
  657|       |    // We may need x_min to reconstruct 'hmtx'
  658|  78.7k|    if (n_contours > 0) {
  ------------------
  |  Branch (658:9): [True: 66.4k, False: 12.3k]
  ------------------
  659|  66.4k|      Buffer x_min_buf(glyph_buf.get() + 2, 2);
  660|  66.4k|      if (PREDICT_FALSE(!x_min_buf.ReadS16(&info->x_mins[i]))) {
  ------------------
  |  |   48|  66.4k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 66.4k]
  |  |  ------------------
  ------------------
  661|      0|        return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  662|      0|      }
  663|  66.4k|    }
  664|  78.7k|  }
  665|       |
  666|       |  // glyf_table dst_offset was set by ReconstructFont
  667|     82|  glyf_table->dst_length = out->Size() - glyf_table->dst_offset;
  668|     82|  loca_table->dst_offset = out->Size();
  669|       |  // loca[n] will be equal the length of the glyph data ('glyf') table
  670|     82|  loca_values[info->num_glyphs] = glyf_table->dst_length;
  671|     82|  if (PREDICT_FALSE(!StoreLoca(loca_values, info->index_format, loca_checksum,
  ------------------
  |  |   48|     82|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 82]
  |  |  ------------------
  ------------------
  672|     82|      out))) {
  673|      0|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  674|      0|  }
  675|     82|  loca_table->dst_length = out->Size() - loca_table->dst_offset;
  676|       |
  677|     82|  return true;
  678|     82|}
woff2_dec.cc:_ZN5woff212_GLOBAL__N_115SizeOfCompositeENS_6BufferEPmPb:
  329|    613|                     bool* have_instructions) {
  330|    613|  size_t start_offset = composite_stream.offset();
  331|    613|  bool we_have_instructions = false;
  332|       |
  333|    613|  uint16_t flags = FLAG_MORE_COMPONENTS;
  334|  4.76k|  while (flags & FLAG_MORE_COMPONENTS) {
  ------------------
  |  Branch (334:10): [True: 4.17k, False: 591]
  ------------------
  335|  4.17k|    if (PREDICT_FALSE(!composite_stream.ReadU16(&flags))) {
  ------------------
  |  |   48|  4.17k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 9, False: 4.16k]
  |  |  ------------------
  ------------------
  336|      9|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      9|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  337|      9|    }
  338|  4.16k|    we_have_instructions |= (flags & FLAG_WE_HAVE_INSTRUCTIONS) != 0;
  339|  4.16k|    size_t arg_size = 2;  // glyph index
  340|  4.16k|    if (flags & FLAG_ARG_1_AND_2_ARE_WORDS) {
  ------------------
  |  Branch (340:9): [True: 1.94k, False: 2.22k]
  ------------------
  341|  1.94k|      arg_size += 4;
  342|  2.22k|    } else {
  343|  2.22k|      arg_size += 2;
  344|  2.22k|    }
  345|  4.16k|    if (flags & FLAG_WE_HAVE_A_SCALE) {
  ------------------
  |  Branch (345:9): [True: 1.80k, False: 2.36k]
  ------------------
  346|  1.80k|      arg_size += 2;
  347|  2.36k|    } else if (flags & FLAG_WE_HAVE_AN_X_AND_Y_SCALE) {
  ------------------
  |  Branch (347:16): [True: 383, False: 1.97k]
  ------------------
  348|    383|      arg_size += 4;
  349|  1.97k|    } else if (flags & FLAG_WE_HAVE_A_TWO_BY_TWO) {
  ------------------
  |  Branch (349:16): [True: 666, False: 1.31k]
  ------------------
  350|    666|      arg_size += 8;
  351|    666|    }
  352|  4.16k|    if (PREDICT_FALSE(!composite_stream.Skip(arg_size))) {
  ------------------
  |  |   48|  4.16k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 13, False: 4.15k]
  |  |  ------------------
  ------------------
  353|     13|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     13|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  354|     13|    }
  355|  4.16k|  }
  356|       |
  357|    591|  *size = composite_stream.offset() - start_offset;
  358|    591|  *have_instructions = we_have_instructions;
  359|       |
  360|    591|  return true;
  361|    613|}
woff2_dec.cc:_ZN5woff212_GLOBAL__N_113TripletDecodeEPKhS2_mjPNS_5PointEPm:
  125|  66.0k|    unsigned int n_points, Point* result, size_t* in_bytes_consumed) {
  126|  66.0k|  int x = 0;
  127|  66.0k|  int y = 0;
  128|       |
  129|  66.0k|  if (PREDICT_FALSE(n_points > in_size)) {
  ------------------
  |  |   48|  66.0k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 11, False: 66.0k]
  |  |  ------------------
  ------------------
  130|     11|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     11|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  131|     11|  }
  132|  66.0k|  unsigned int triplet_index = 0;
  133|       |
  134|  11.2M|  for (unsigned int i = 0; i < n_points; ++i) {
  ------------------
  |  Branch (134:28): [True: 11.2M, False: 66.0k]
  ------------------
  135|  11.2M|    uint8_t flag = flags_in[i];
  136|  11.2M|    bool on_curve = !(flag >> 7);
  137|  11.2M|    flag &= 0x7f;
  138|  11.2M|    unsigned int n_data_bytes;
  139|  11.2M|    if (flag < 84) {
  ------------------
  |  Branch (139:9): [True: 7.72M, False: 3.50M]
  ------------------
  140|  7.72M|      n_data_bytes = 1;
  141|  7.72M|    } else if (flag < 120) {
  ------------------
  |  Branch (141:16): [True: 1.00M, False: 2.50M]
  ------------------
  142|  1.00M|      n_data_bytes = 2;
  143|  2.50M|    } else if (flag < 124) {
  ------------------
  |  Branch (143:16): [True: 66.2k, False: 2.43M]
  ------------------
  144|  66.2k|      n_data_bytes = 3;
  145|  2.43M|    } else {
  146|  2.43M|      n_data_bytes = 4;
  147|  2.43M|    }
  148|  11.2M|    if (PREDICT_FALSE(triplet_index + n_data_bytes > in_size ||
  ------------------
  |  |   48|  22.4M|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 28, False: 11.2M]
  |  |  |  Branch (48:44): [True: 28, False: 11.2M]
  |  |  |  Branch (48:44): [True: 0, False: 11.2M]
  |  |  ------------------
  ------------------
  149|  11.2M|        triplet_index + n_data_bytes < triplet_index)) {
  150|     28|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     28|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  151|     28|    }
  152|  11.2M|    int dx, dy;
  153|  11.2M|    if (flag < 10) {
  ------------------
  |  Branch (153:9): [True: 3.74M, False: 7.48M]
  ------------------
  154|  3.74M|      dx = 0;
  155|  3.74M|      dy = WithSign(flag, ((flag & 14) << 7) + in[triplet_index]);
  156|  7.48M|    } else if (flag < 20) {
  ------------------
  |  Branch (156:16): [True: 918k, False: 6.56M]
  ------------------
  157|   918k|      dx = WithSign(flag, (((flag - 10) & 14) << 7) + in[triplet_index]);
  158|   918k|      dy = 0;
  159|  6.56M|    } else if (flag < 84) {
  ------------------
  |  Branch (159:16): [True: 3.06M, False: 3.50M]
  ------------------
  160|  3.06M|      int b0 = flag - 20;
  161|  3.06M|      int b1 = in[triplet_index];
  162|  3.06M|      dx = WithSign(flag, 1 + (b0 & 0x30) + (b1 >> 4));
  163|  3.06M|      dy = WithSign(flag >> 1, 1 + ((b0 & 0x0c) << 2) + (b1 & 0x0f));
  164|  3.50M|    } else if (flag < 120) {
  ------------------
  |  Branch (164:16): [True: 1.00M, False: 2.50M]
  ------------------
  165|  1.00M|      int b0 = flag - 84;
  166|  1.00M|      dx = WithSign(flag, 1 + ((b0 / 12) << 8) + in[triplet_index]);
  167|  1.00M|      dy = WithSign(flag >> 1,
  168|  1.00M|                    1 + (((b0 % 12) >> 2) << 8) + in[triplet_index + 1]);
  169|  2.50M|    } else if (flag < 124) {
  ------------------
  |  Branch (169:16): [True: 66.2k, False: 2.43M]
  ------------------
  170|  66.2k|      int b2 = in[triplet_index + 1];
  171|  66.2k|      dx = WithSign(flag, (in[triplet_index] << 4) + (b2 >> 4));
  172|  66.2k|      dy = WithSign(flag >> 1, ((b2 & 0x0f) << 8) + in[triplet_index + 2]);
  173|  2.43M|    } else {
  174|  2.43M|      dx = WithSign(flag, (in[triplet_index] << 8) + in[triplet_index + 1]);
  175|  2.43M|      dy = WithSign(flag >> 1,
  176|  2.43M|          (in[triplet_index + 2] << 8) + in[triplet_index + 3]);
  177|  2.43M|    }
  178|  11.2M|    triplet_index += n_data_bytes;
  179|  11.2M|    if (!_SafeIntAddition(x, dx, &x)) {
  ------------------
  |  Branch (179:9): [True: 16, False: 11.2M]
  ------------------
  180|     16|      return false;
  181|     16|    }
  182|  11.2M|    if (!_SafeIntAddition(y, dy, &y)) {
  ------------------
  |  Branch (182:9): [True: 17, False: 11.2M]
  ------------------
  183|     17|      return false;
  184|     17|    }
  185|  11.2M|    *result++ = {x, y, on_curve};
  186|  11.2M|  }
  187|  66.0k|  *in_bytes_consumed = triplet_index;
  188|  66.0k|  return true;
  189|  66.0k|}
woff2_dec.cc:_ZN5woff212_GLOBAL__N_18WithSignEii:
  109|  17.8M|int WithSign(int flag, int baseval) {
  110|       |  // Precondition: 0 <= baseval < 65536 (to avoid integer overflow)
  111|  17.8M|  return (flag & 1) ? baseval : -baseval;
  ------------------
  |  Branch (111:10): [True: 7.70M, False: 10.0M]
  ------------------
  112|  17.8M|}
woff2_dec.cc:_ZN5woff212_GLOBAL__N_116_SafeIntAdditionEiiPi:
  114|  22.4M|bool _SafeIntAddition(int a, int b, int* result) {
  115|  22.4M|  if (PREDICT_FALSE(
  ------------------
  |  |   48|   111M|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 33, False: 22.4M]
  |  |  |  Branch (48:44): [True: 8.84M, False: 13.6M]
  |  |  |  Branch (48:44): [True: 2, False: 8.84M]
  |  |  |  Branch (48:44): [True: 12.4M, False: 10.0M]
  |  |  |  Branch (48:44): [True: 31, False: 12.4M]
  |  |  ------------------
  ------------------
  116|  22.4M|          ((a > 0) && (b > std::numeric_limits<int>::max() - a)) ||
  117|  22.4M|          ((a < 0) && (b < std::numeric_limits<int>::min() - a)))) {
  118|     33|    return false;
  119|     33|  }
  120|  22.4M|  *result = a + b;
  121|  22.4M|  return true;
  122|  22.4M|}
woff2_dec.cc:_ZN5woff212_GLOBAL__N_111ComputeBboxEjPKNS_5PointEPh:
  300|  65.5k|void ComputeBbox(unsigned int n_points, const Point* points, uint8_t* dst) {
  301|  65.5k|  int x_min = 0;
  302|  65.5k|  int y_min = 0;
  303|  65.5k|  int x_max = 0;
  304|  65.5k|  int y_max = 0;
  305|       |
  306|  65.5k|  if (n_points > 0) {
  ------------------
  |  Branch (306:7): [True: 63.7k, False: 1.80k]
  ------------------
  307|  63.7k|    x_min = points[0].x;
  308|  63.7k|    x_max = points[0].x;
  309|  63.7k|    y_min = points[0].y;
  310|  63.7k|    y_max = points[0].y;
  311|  63.7k|  }
  312|  6.40M|  for (unsigned int i = 1; i < n_points; ++i) {
  ------------------
  |  Branch (312:28): [True: 6.34M, False: 65.5k]
  ------------------
  313|  6.34M|    int x = points[i].x;
  314|  6.34M|    int y = points[i].y;
  315|  6.34M|    x_min = std::min(x, x_min);
  316|  6.34M|    x_max = std::max(x, x_max);
  317|  6.34M|    y_min = std::min(y, y_min);
  318|  6.34M|    y_max = std::max(y, y_max);
  319|  6.34M|  }
  320|  65.5k|  size_t offset = 2;
  321|  65.5k|  offset = Store16(dst, offset, x_min);
  322|  65.5k|  offset = Store16(dst, offset, y_min);
  323|  65.5k|  offset = Store16(dst, offset, x_max);
  324|  65.5k|  offset = Store16(dst, offset, y_max);
  325|  65.5k|}
woff2_dec.cc:_ZN5woff212_GLOBAL__N_111StorePointsEjPKNS_5PointEjjbPhmPm:
  196|  65.8k|                 size_t* glyph_size) {
  197|       |  // I believe that n_contours < 65536, in which case this is safe. However, a
  198|       |  // comment and/or an assert would be good.
  199|  65.8k|  unsigned int flag_offset = kEndPtsOfContoursOffset + 2 * n_contours + 2 +
  200|  65.8k|    instruction_length;
  201|  65.8k|  int last_flag = -1;
  202|  65.8k|  int repeat_count = 0;
  203|  65.8k|  int last_x = 0;
  204|  65.8k|  int last_y = 0;
  205|  65.8k|  unsigned int x_bytes = 0;
  206|  65.8k|  unsigned int y_bytes = 0;
  207|       |
  208|  4.89M|  for (unsigned int i = 0; i < n_points; ++i) {
  ------------------
  |  Branch (208:28): [True: 4.82M, False: 65.8k]
  ------------------
  209|  4.82M|    const Point& point = points[i];
  210|  4.82M|    int flag = point.on_curve ? kGlyfOnCurve : 0;
  ------------------
  |  Branch (210:16): [True: 3.73M, False: 1.08M]
  ------------------
  211|  4.82M|    if (has_overlap_bit && i == 0) {
  ------------------
  |  Branch (211:9): [True: 1.05k, False: 4.82M]
  |  Branch (211:28): [True: 151, False: 903]
  ------------------
  212|    151|      flag |= kOverlapSimple;
  213|    151|    }
  214|       |
  215|  4.82M|    int dx = point.x - last_x;
  216|  4.82M|    int dy = point.y - last_y;
  217|  4.82M|    if (dx == 0) {
  ------------------
  |  Branch (217:9): [True: 2.85M, False: 1.97M]
  ------------------
  218|  2.85M|      flag |= kGlyfThisXIsSame;
  219|  2.85M|    } else if (dx > -256 && dx < 256) {
  ------------------
  |  Branch (219:16): [True: 1.78M, False: 189k]
  |  Branch (219:29): [True: 1.50M, False: 279k]
  ------------------
  220|  1.50M|      flag |= kGlyfXShort | (dx > 0 ? kGlyfThisXIsSame : 0);
  ------------------
  |  Branch (220:30): [True: 665k, False: 840k]
  ------------------
  221|  1.50M|      x_bytes += 1;
  222|  1.50M|    } else {
  223|   468k|      x_bytes += 2;
  224|   468k|    }
  225|  4.82M|    if (dy == 0) {
  ------------------
  |  Branch (225:9): [True: 2.28M, False: 2.54M]
  ------------------
  226|  2.28M|      flag |= kGlyfThisYIsSame;
  227|  2.54M|    } else if (dy > -256 && dy < 256) {
  ------------------
  |  Branch (227:16): [True: 2.09M, False: 455k]
  |  Branch (227:29): [True: 1.73M, False: 355k]
  ------------------
  228|  1.73M|      flag |= kGlyfYShort | (dy > 0 ? kGlyfThisYIsSame : 0);
  ------------------
  |  Branch (228:30): [True: 658k, False: 1.07M]
  ------------------
  229|  1.73M|      y_bytes += 1;
  230|  1.73M|    } else {
  231|   811k|      y_bytes += 2;
  232|   811k|    }
  233|       |
  234|  4.82M|    if (flag == last_flag && repeat_count != 255) {
  ------------------
  |  Branch (234:9): [True: 1.87M, False: 2.94M]
  |  Branch (234:30): [True: 1.87M, False: 853]
  ------------------
  235|  1.87M|      dst[flag_offset - 1] |= kGlyfRepeat;
  236|  1.87M|      repeat_count++;
  237|  2.95M|    } else {
  238|  2.95M|      if (repeat_count != 0) {
  ------------------
  |  Branch (238:11): [True: 402k, False: 2.54M]
  ------------------
  239|   402k|        if (PREDICT_FALSE(flag_offset >= dst_size)) {
  ------------------
  |  |   48|   402k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 402k]
  |  |  ------------------
  ------------------
  240|      0|          return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  241|      0|        }
  242|   402k|        dst[flag_offset++] = repeat_count;
  243|   402k|      }
  244|  2.95M|      if (PREDICT_FALSE(flag_offset >= dst_size)) {
  ------------------
  |  |   48|  2.95M|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 2.95M]
  |  |  ------------------
  ------------------
  245|      0|        return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  246|      0|      }
  247|  2.95M|      dst[flag_offset++] = flag;
  248|  2.95M|      repeat_count = 0;
  249|  2.95M|    }
  250|  4.82M|    last_x = point.x;
  251|  4.82M|    last_y = point.y;
  252|  4.82M|    last_flag = flag;
  253|  4.82M|  }
  254|       |
  255|  65.8k|  if (repeat_count != 0) {
  ------------------
  |  Branch (255:7): [True: 20.7k, False: 45.1k]
  ------------------
  256|  20.7k|    if (PREDICT_FALSE(flag_offset >= dst_size)) {
  ------------------
  |  |   48|  20.7k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 20.7k]
  |  |  ------------------
  ------------------
  257|      0|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  258|      0|    }
  259|  20.7k|    dst[flag_offset++] = repeat_count;
  260|  20.7k|  }
  261|  65.8k|  unsigned int xy_bytes = x_bytes + y_bytes;
  262|  65.8k|  if (PREDICT_FALSE(xy_bytes < x_bytes ||
  ------------------
  |  |   48|   263k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 65.8k]
  |  |  |  Branch (48:44): [True: 0, False: 65.8k]
  |  |  |  Branch (48:44): [True: 0, False: 65.8k]
  |  |  |  Branch (48:44): [True: 0, False: 65.8k]
  |  |  ------------------
  ------------------
  263|  65.8k|      flag_offset + xy_bytes < flag_offset ||
  264|  65.8k|      flag_offset + xy_bytes > dst_size)) {
  265|      0|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  266|      0|  }
  267|       |
  268|  65.8k|  int x_offset = flag_offset;
  269|  65.8k|  int y_offset = flag_offset + x_bytes;
  270|  65.8k|  last_x = 0;
  271|  65.8k|  last_y = 0;
  272|  4.89M|  for (unsigned int i = 0; i < n_points; ++i) {
  ------------------
  |  Branch (272:28): [True: 4.82M, False: 65.8k]
  ------------------
  273|  4.82M|    int dx = points[i].x - last_x;
  274|  4.82M|    if (dx == 0) {
  ------------------
  |  Branch (274:9): [True: 2.85M, False: 1.97M]
  ------------------
  275|       |      // pass
  276|  2.85M|    } else if (dx > -256 && dx < 256) {
  ------------------
  |  Branch (276:16): [True: 1.78M, False: 189k]
  |  Branch (276:29): [True: 1.50M, False: 279k]
  ------------------
  277|  1.50M|      dst[x_offset++] = std::abs(dx);
  278|  1.50M|    } else {
  279|       |      // will always fit for valid input, but overflow is harmless
  280|   468k|      x_offset = Store16(dst, x_offset, dx);
  281|   468k|    }
  282|  4.82M|    last_x += dx;
  283|  4.82M|    int dy = points[i].y - last_y;
  284|  4.82M|    if (dy == 0) {
  ------------------
  |  Branch (284:9): [True: 2.28M, False: 2.54M]
  ------------------
  285|       |      // pass
  286|  2.54M|    } else if (dy > -256 && dy < 256) {
  ------------------
  |  Branch (286:16): [True: 2.09M, False: 455k]
  |  Branch (286:29): [True: 1.73M, False: 355k]
  ------------------
  287|  1.73M|      dst[y_offset++] = std::abs(dy);
  288|  1.73M|    } else {
  289|   811k|      y_offset = Store16(dst, y_offset, dy);
  290|   811k|    }
  291|  4.82M|    last_y += dy;
  292|  4.82M|  }
  293|  65.8k|  *glyph_size = y_offset;
  294|  65.8k|  return true;
  295|  65.8k|}
woff2_dec.cc:_ZN5woff212_GLOBAL__N_19StoreLocaERKNSt3__16vectorIjNS1_9allocatorIjEEEEiPjPNS_8WOFF2OutE:
  379|     82|               uint32_t* checksum, WOFF2Out* out) {
  380|       |  // TODO(user) figure out what index format to use based on whether max
  381|       |  // offset fits into uint16_t or not
  382|     82|  const uint64_t loca_size = loca_values.size();
  383|     82|  const uint64_t offset_size = index_format ? 4 : 2;
  ------------------
  |  Branch (383:32): [True: 36, False: 46]
  ------------------
  384|     82|  if (PREDICT_FALSE((loca_size << 2) >> 2 != loca_size)) {
  ------------------
  |  |   48|     82|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 82]
  |  |  ------------------
  ------------------
  385|      0|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  386|      0|  }
  387|     82|  std::vector<uint8_t> loca_content(loca_size * offset_size);
  388|     82|  uint8_t* dst = &loca_content[0];
  389|     82|  size_t offset = 0;
  390|  66.8k|  for (size_t i = 0; i < loca_values.size(); ++i) {
  ------------------
  |  Branch (390:22): [True: 66.7k, False: 82]
  ------------------
  391|  66.7k|    uint32_t value = loca_values[i];
  392|  66.7k|    if (index_format) {
  ------------------
  |  Branch (392:9): [True: 50.3k, False: 16.3k]
  ------------------
  393|  50.3k|      offset = StoreU32(dst, offset, value);
  394|  50.3k|    } else {
  395|  16.3k|      offset = Store16(dst, offset, value >> 1);
  396|  16.3k|    }
  397|  66.7k|  }
  398|     82|  *checksum = ComputeULongSum(&loca_content[0], loca_content.size());
  399|     82|  if (PREDICT_FALSE(!out->Write(&loca_content[0], loca_content.size()))) {
  ------------------
  |  |   48|     82|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 82]
  |  |  ------------------
  ------------------
  400|      0|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  401|      0|  }
  402|     82|  return true;
  403|     82|}
woff2_dec.cc:_ZN5woff212_GLOBAL__N_126ReconstructTransformedHmtxEPKhmttRKNSt3__16vectorIsNS3_9allocatorIsEEEEPjPNS_8WOFF2OutE:
  707|     63|                                WOFF2Out* out) {
  708|     63|  Buffer hmtx_buff_in(transformed_buf, transformed_size);
  709|       |
  710|     63|  uint8_t hmtx_flags;
  711|     63|  if (PREDICT_FALSE(!hmtx_buff_in.ReadU8(&hmtx_flags))) {
  ------------------
  |  |   48|     63|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 1, False: 62]
  |  |  ------------------
  ------------------
  712|      1|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      1|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  713|      1|  }
  714|       |
  715|     62|  std::vector<uint16_t> advance_widths;
  716|     62|  std::vector<int16_t> lsbs;
  717|     62|  bool has_proportional_lsbs = (hmtx_flags & 1) == 0;
  718|     62|  bool has_monospace_lsbs = (hmtx_flags & 2) == 0;
  719|       |
  720|       |  // Bits 2-7 are reserved and MUST be zero.
  721|     62|  if ((hmtx_flags & 0xFC) != 0) {
  ------------------
  |  Branch (721:7): [True: 2, False: 60]
  ------------------
  722|       |#ifdef FONT_COMPRESSION_BIN
  723|       |    fprintf(stderr, "Illegal hmtx flags; bits 2-7 must be 0\n");
  724|       |#endif
  725|      2|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      2|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  726|      2|  }
  727|       |
  728|       |  // you say you transformed but there is little evidence of it
  729|     60|  if (has_proportional_lsbs && has_monospace_lsbs) {
  ------------------
  |  Branch (729:7): [True: 27, False: 33]
  |  Branch (729:32): [True: 4, False: 23]
  ------------------
  730|      4|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      4|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  731|      4|  }
  732|       |
  733|     56|  assert(x_mins.size() == num_glyphs);
  734|       |
  735|       |  // num_glyphs 0 is OK if there is no 'glyf' but cannot then xform 'hmtx'.
  736|     56|  if (PREDICT_FALSE(num_hmetrics > num_glyphs)) {
  ------------------
  |  |   48|     56|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 19, False: 37]
  |  |  ------------------
  ------------------
  737|     19|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|     19|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  738|     19|  }
  739|       |
  740|       |  // https://www.microsoft.com/typography/otspec/hmtx.htm
  741|       |  // "...only one entry need be in the array, but that entry is required."
  742|     37|  if (PREDICT_FALSE(num_hmetrics < 1)) {
  ------------------
  |  |   48|     37|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 3, False: 34]
  |  |  ------------------
  ------------------
  743|      3|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      3|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  744|      3|  }
  745|       |
  746|    175|  for (uint16_t i = 0; i < num_hmetrics; i++) {
  ------------------
  |  Branch (746:24): [True: 142, False: 33]
  ------------------
  747|    142|    uint16_t advance_width;
  748|    142|    if (PREDICT_FALSE(!hmtx_buff_in.ReadU16(&advance_width))) {
  ------------------
  |  |   48|    142|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 1, False: 141]
  |  |  ------------------
  ------------------
  749|      1|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      1|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  750|      1|    }
  751|    141|    advance_widths.push_back(advance_width);
  752|    141|  }
  753|       |
  754|    161|  for (uint16_t i = 0; i < num_hmetrics; i++) {
  ------------------
  |  Branch (754:24): [True: 131, False: 30]
  ------------------
  755|    131|    int16_t lsb;
  756|    131|    if (has_proportional_lsbs) {
  ------------------
  |  Branch (756:9): [True: 58, False: 73]
  ------------------
  757|     58|      if (PREDICT_FALSE(!hmtx_buff_in.ReadS16(&lsb))) {
  ------------------
  |  |   48|     58|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 3, False: 55]
  |  |  ------------------
  ------------------
  758|      3|        return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      3|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  759|      3|      }
  760|     73|    } else {
  761|     73|      lsb = x_mins[i];
  762|     73|    }
  763|    128|    lsbs.push_back(lsb);
  764|    128|  }
  765|       |
  766|    160|  for (uint16_t i = num_hmetrics; i < num_glyphs; i++) {
  ------------------
  |  Branch (766:35): [True: 131, False: 29]
  ------------------
  767|    131|    int16_t lsb;
  768|    131|    if (has_monospace_lsbs) {
  ------------------
  |  Branch (768:9): [True: 74, False: 57]
  ------------------
  769|     74|      if (PREDICT_FALSE(!hmtx_buff_in.ReadS16(&lsb))) {
  ------------------
  |  |   48|     74|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 1, False: 73]
  |  |  ------------------
  ------------------
  770|      1|        return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      1|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  771|      1|      }
  772|     74|    } else {
  773|     57|      lsb = x_mins[i];
  774|     57|    }
  775|    130|    lsbs.push_back(lsb);
  776|    130|  }
  777|       |
  778|       |  // bake me a shiny new hmtx table
  779|     29|  uint32_t hmtx_output_size = 2 * num_glyphs + 2 * num_hmetrics;
  780|     29|  std::vector<uint8_t> hmtx_table(hmtx_output_size);
  781|     29|  uint8_t* dst = &hmtx_table[0];
  782|     29|  size_t dst_offset = 0;
  783|    276|  for (uint32_t i = 0; i < num_glyphs; i++) {
  ------------------
  |  Branch (783:24): [True: 247, False: 29]
  ------------------
  784|    247|    if (i < num_hmetrics) {
  ------------------
  |  Branch (784:9): [True: 119, False: 128]
  ------------------
  785|    119|      Store16(advance_widths[i], &dst_offset, dst);
  786|    119|    }
  787|    247|    Store16(lsbs[i], &dst_offset, dst);
  788|    247|  }
  789|       |
  790|     29|  *checksum = ComputeULongSum(&hmtx_table[0], hmtx_output_size);
  791|     29|  if (PREDICT_FALSE(!out->Write(&hmtx_table[0], hmtx_output_size))) {
  ------------------
  |  |   48|     29|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 29]
  |  |  ------------------
  ------------------
  792|      0|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  793|      0|  }
  794|       |
  795|     29|  return true;
  796|     29|}
woff2_dec.cc:_ZN5woff212_GLOBAL__N_14Pad4EPNS_8WOFF2OutE:
  363|  87.9k|bool Pad4(WOFF2Out* out) {
  364|  87.9k|  uint8_t zeroes[] = {0, 0, 0};
  365|  87.9k|  if (PREDICT_FALSE(out->Size() + 3 < out->Size())) {
  ------------------
  |  |   48|  87.9k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 87.9k]
  |  |  ------------------
  ------------------
  366|      0|    return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  367|      0|  }
  368|  87.9k|  uint32_t pad_bytes = Round4(out->Size()) - out->Size();
  369|  87.9k|  if (pad_bytes > 0) {
  ------------------
  |  Branch (369:7): [True: 50.6k, False: 37.3k]
  ------------------
  370|  50.6k|    if (PREDICT_FALSE(!out->Write(&zeroes, pad_bytes))) {
  ------------------
  |  |   48|  50.6k|#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
  |  |  ------------------
  |  |  |  Branch (48:26): [True: 0, False: 50.6k]
  |  |  ------------------
  ------------------
  371|      0|      return FONT_COMPRESSION_FAILURE();
  ------------------
  |  |   40|      0|#define FONT_COMPRESSION_FAILURE() false
  ------------------
  372|      0|    }
  373|  50.6k|  }
  374|  87.9k|  return true;
  375|  87.9k|}

_ZN5woff214WOFF2StringOutC2EPNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
   14|  7.82k|    : buf_(buf), max_size_(kDefaultMaxSize), offset_(0) {}
_ZN5woff214WOFF2StringOut5WriteEPKvm:
   16|   142k|bool WOFF2StringOut::Write(const void *buf, size_t n) {
   17|   142k|  return Write(buf, offset_, n);
   18|   142k|}
_ZN5woff214WOFF2StringOut5WriteEPKvmm:
   20|   152k|bool WOFF2StringOut::Write(const void *buf, size_t offset, size_t n) {
   21|   152k|  if (offset > max_size_ || n > max_size_ - offset) {
  ------------------
  |  Branch (21:7): [True: 0, False: 152k]
  |  Branch (21:29): [True: 0, False: 152k]
  ------------------
   22|      0|    return false;
   23|      0|  }
   24|   152k|  if (offset == buf_->size()) {
  ------------------
  |  Branch (24:7): [True: 142k, False: 9.37k]
  ------------------
   25|   142k|    buf_->append(static_cast<const char*>(buf), n);
   26|   142k|  } else {
   27|  9.37k|    if (offset + n > buf_->size()) {
  ------------------
  |  Branch (27:9): [True: 0, False: 9.37k]
  ------------------
   28|      0|      buf_->append(offset + n - buf_->size(), 0);
   29|      0|    }
   30|  9.37k|    buf_->replace(offset, n, static_cast<const char*>(buf), n);
   31|  9.37k|  }
   32|   152k|  offset_ = std::max(offset_, offset + n);
   33|       |
   34|   152k|  return true;
   35|   152k|}
_ZN5woff214WOFF2StringOut10SetMaxSizeEm:
   37|  7.82k|void WOFF2StringOut::SetMaxSize(size_t max_size) {
   38|  7.82k|  max_size_ = max_size;
   39|  7.82k|  if (offset_ > max_size_) {
  ------------------
  |  Branch (39:7): [True: 0, False: 7.82k]
  ------------------
   40|      0|    offset_ = max_size_;
   41|      0|  }
   42|  7.82k|}

