_ZN3ada4idna13utf8_to_utf32EPKcmPDi:
  172|  11.3k|size_t utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_output) {
  173|  11.3k|  const uint8_t* data = reinterpret_cast<const uint8_t*>(buf);
  174|  11.3k|  size_t pos = 0;
  175|  11.3k|  const char32_t* start{utf32_output};
  176|   184k|  while (pos < len) {
  ------------------
  |  Branch (176:10): [True: 174k, False: 10.4k]
  ------------------
  177|       |    // try to convert the next block of 16 ASCII bytes
  178|   174k|    if (pos + 16 <= len) {  // if it is safe to read 16 more
  ------------------
  |  Branch (178:9): [True: 111k, False: 62.9k]
  ------------------
  179|       |                            // bytes, check that they are ascii
  180|   111k|      uint64_t v1;
  181|   111k|      std::memcpy(&v1, data + pos, sizeof(uint64_t));
  182|   111k|      uint64_t v2;
  183|   111k|      std::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  184|   111k|      uint64_t v{v1 | v2};
  185|   111k|      if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (185:11): [True: 8.22k, False: 102k]
  ------------------
  186|  8.22k|        size_t final_pos = pos + 16;
  187|   139k|        while (pos < final_pos) {
  ------------------
  |  Branch (187:16): [True: 131k, False: 8.22k]
  ------------------
  188|   131k|          *utf32_output++ = char32_t(buf[pos]);
  189|   131k|          pos++;
  190|   131k|        }
  191|  8.22k|        continue;
  192|  8.22k|      }
  193|   111k|    }
  194|   165k|    uint8_t leading_byte = data[pos];  // leading byte
  195|   165k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (195:9): [True: 92.8k, False: 72.9k]
  ------------------
  196|       |      // converting one ASCII byte !!!
  197|  92.8k|      *utf32_output++ = char32_t(leading_byte);
  198|  92.8k|      pos++;
  199|  92.8k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (199:16): [True: 18.8k, False: 54.1k]
  ------------------
  200|       |      // We have a two-byte UTF-8
  201|  18.8k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (201:11): [True: 168, False: 18.6k]
  ------------------
  202|    168|        return 0;
  203|    168|      }  // minimal bound checking
  204|  18.6k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (204:11): [True: 150, False: 18.5k]
  ------------------
  205|    150|        return 0;
  206|    150|      }
  207|       |      // range check
  208|  18.5k|      uint32_t code_point =
  209|  18.5k|          (leading_byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111);
  210|  18.5k|      if (code_point < 0x80 || 0x7ff < code_point) {
  ------------------
  |  Branch (210:11): [True: 9, False: 18.5k]
  |  Branch (210:32): [True: 0, False: 18.5k]
  ------------------
  211|      9|        return 0;
  212|      9|      }
  213|  18.5k|      *utf32_output++ = char32_t(code_point);
  214|  18.5k|      pos += 2;
  215|  54.1k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (215:16): [True: 52.0k, False: 2.04k]
  ------------------
  216|       |      // We have a three-byte UTF-8
  217|  52.0k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (217:11): [True: 57, False: 52.0k]
  ------------------
  218|     57|        return 0;
  219|     57|      }  // minimal bound checking
  220|       |
  221|  52.0k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (221:11): [True: 33, False: 52.0k]
  ------------------
  222|     33|        return 0;
  223|     33|      }
  224|  52.0k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (224:11): [True: 21, False: 51.9k]
  ------------------
  225|     21|        return 0;
  226|     21|      }
  227|       |      // range check
  228|  51.9k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
  229|  51.9k|                            (data[pos + 1] & 0b00111111) << 6 |
  230|  51.9k|                            (data[pos + 2] & 0b00111111);
  231|  51.9k|      if (code_point < 0x800 || 0xffff < code_point ||
  ------------------
  |  Branch (231:11): [True: 24, False: 51.9k]
  |  Branch (231:33): [True: 0, False: 51.9k]
  ------------------
  232|  51.9k|          (0xd7ff < code_point && code_point < 0xe000)) {
  ------------------
  |  Branch (232:12): [True: 9.03k, False: 42.9k]
  |  Branch (232:35): [True: 9, False: 9.02k]
  ------------------
  233|     33|        return 0;
  234|     33|      }
  235|  51.9k|      *utf32_output++ = char32_t(code_point);
  236|  51.9k|      pos += 3;
  237|  51.9k|    } else if ((leading_byte & 0b11111000) == 0b11110000) {  // 0b11110000
  ------------------
  |  Branch (237:16): [True: 1.76k, False: 288]
  ------------------
  238|       |      // we have a 4-byte UTF-8 word.
  239|  1.76k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (239:11): [True: 18, False: 1.74k]
  ------------------
  240|     18|        return 0;
  241|     18|      }  // minimal bound checking
  242|  1.74k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (242:11): [True: 42, False: 1.70k]
  ------------------
  243|     42|        return 0;
  244|     42|      }
  245|  1.70k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (245:11): [True: 18, False: 1.68k]
  ------------------
  246|     18|        return 0;
  247|     18|      }
  248|  1.68k|      if ((data[pos + 3] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (248:11): [True: 15, False: 1.66k]
  ------------------
  249|     15|        return 0;
  250|     15|      }
  251|       |
  252|       |      // range check
  253|  1.66k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  254|  1.66k|                            (data[pos + 1] & 0b00111111) << 12 |
  255|  1.66k|                            (data[pos + 2] & 0b00111111) << 6 |
  256|  1.66k|                            (data[pos + 3] & 0b00111111);
  257|  1.66k|      if (code_point <= 0xffff || 0x10ffff < code_point) {
  ------------------
  |  Branch (257:11): [True: 9, False: 1.65k]
  |  Branch (257:35): [True: 9, False: 1.65k]
  ------------------
  258|     18|        return 0;
  259|     18|      }
  260|  1.65k|      *utf32_output++ = char32_t(code_point);
  261|  1.65k|      pos += 4;
  262|  1.65k|    } else {
  263|    288|      return 0;
  264|    288|    }
  265|   165k|  }
  266|  10.4k|  return utf32_output - start;
  267|  11.3k|}
_ZN3ada4idna22utf32_length_from_utf8EPKcm:
  282|  11.4k|size_t utf32_length_from_utf8(const char* buf, size_t len) {
  283|  11.4k|  const int8_t* p = reinterpret_cast<const int8_t*>(buf);
  284|  11.4k|  return std::count_if(p, std::next(p, len), [](int8_t c) {
  285|       |    // -65 is 0b10111111, anything larger in two-complement's
  286|       |    // should start a new code point.
  287|  11.4k|    return c > -65;
  288|  11.4k|  });
  289|  11.4k|}
_ZN3ada4idna9ascii_mapEPcm:
 5133|  7.14k|void ascii_map(char* input, size_t length) {
 5134|  7.14k|  auto broadcast = [](uint8_t v) -> uint64_t {
 5135|  7.14k|    return 0x101010101010101ull * v;
 5136|  7.14k|  };
 5137|  7.14k|  uint64_t broadcast_80 = broadcast(0x80);
 5138|  7.14k|  uint64_t broadcast_Ap = broadcast(128 - 'A');
 5139|  7.14k|  uint64_t broadcast_Zp = broadcast(128 - 'Z' - 1);
 5140|  7.14k|  size_t i = 0;
 5141|       |
 5142|  50.4k|  for (; i + 7 < length; i += 8) {
  ------------------
  |  Branch (5142:10): [True: 43.3k, False: 7.14k]
  ------------------
 5143|  43.3k|    uint64_t word{};
 5144|  43.3k|    std::memcpy(&word, input + i, sizeof(word));
 5145|  43.3k|    word ^=
 5146|  43.3k|        (((word + broadcast_Ap) ^ (word + broadcast_Zp)) & broadcast_80) >> 2;
 5147|  43.3k|    std::memcpy(input + i, &word, sizeof(word));
 5148|  43.3k|  }
 5149|  7.14k|  if (i < length) {
  ------------------
  |  Branch (5149:7): [True: 6.29k, False: 851]
  ------------------
 5150|  6.29k|    uint64_t word{};
 5151|  6.29k|    std::memcpy(&word, input + i, length - i);
 5152|  6.29k|    word ^=
 5153|  6.29k|        (((word + broadcast_Ap) ^ (word + broadcast_Zp)) & broadcast_80) >> 2;
 5154|  6.29k|    std::memcpy(input + i, &word, length - i);
 5155|  6.29k|  }
 5156|  7.14k|}
_ZN3ada4idna3mapENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEERNS1_12basic_stringIDiS4_NS1_9allocatorIDiEEEE:
 5160|  14.3k|bool map(std::u32string_view input, std::u32string& out) {
 5161|       |  //  [Map](https://www.unicode.org/reports/tr46/#ProcessingStepMap).
 5162|  14.3k|  out.clear();
 5163|  14.3k|  if (!ensure_tables()) {
  ------------------
  |  Branch (5163:7): [True: 0, False: 14.3k]
  ------------------
 5164|      0|    return false;
 5165|      0|  }
 5166|       |
 5167|       |  // Pass 1: validate and compute exact output length.
 5168|  14.3k|  size_t out_size = 0;
 5169|   361k|  for (char32_t x : input) {
  ------------------
  |  Branch (5169:19): [True: 361k, False: 13.7k]
  ------------------
 5170|   361k|    uint16_t status = idna_lookup(static_cast<uint32_t>(x));
 5171|   361k|    if (status == IDNA_DISALLOWED) {
  ------------------
  |  Branch (5171:9): [True: 660, False: 361k]
  ------------------
 5172|    660|      return false;
 5173|    660|    }
 5174|   361k|    if (status == IDNA_VALID) {
  ------------------
  |  Branch (5174:9): [True: 246k, False: 114k]
  ------------------
 5175|   246k|      ++out_size;
 5176|   246k|      continue;
 5177|   246k|    }
 5178|   114k|    if (static_cast<size_t>(status) >= idna_utf8_mappings_size) {
  ------------------
  |  Branch (5178:9): [True: 0, False: 114k]
  ------------------
 5179|      0|      return false;
 5180|      0|    }
 5181|   114k|    out_size += utf8_count_codepoints(idna_utf8_mappings + status);
 5182|   114k|  }
 5183|       |
 5184|       |  // Pass 2: write into a single allocation.
 5185|  13.7k|  out.resize(out_size);
 5186|  13.7k|  size_t w = 0;
 5187|   359k|  for (char32_t x : input) {
  ------------------
  |  Branch (5187:19): [True: 359k, False: 13.7k]
  ------------------
 5188|   359k|    uint16_t status = idna_lookup(static_cast<uint32_t>(x));
 5189|   359k|    if (status == IDNA_VALID) {
  ------------------
  |  Branch (5189:9): [True: 245k, False: 114k]
  ------------------
 5190|   245k|      out[w++] = x;
 5191|   245k|      continue;
 5192|   245k|    }
 5193|       |    // IGNORED or mapped (status already validated in pass 1).
 5194|   114k|    const uint8_t* ptr = idna_utf8_mappings + status;
 5195|   577k|    while (*ptr != 0) {
  ------------------
  |  Branch (5195:12): [True: 463k, False: 114k]
  ------------------
 5196|   463k|      out[w++] = utf8_next(ptr);
 5197|   463k|    }
 5198|   114k|  }
 5199|  13.7k|  return true;
 5200|  14.3k|}
_ZN3ada4idna28compute_decomposition_lengthENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 5293|  1.89k|    const std::u32string_view input) noexcept {
 5294|  1.89k|  bool decomposition_needed{false};
 5295|  1.89k|  size_t additional_elements{0};
 5296|  73.8k|  for (char32_t current_character : input) {
  ------------------
  |  Branch (5296:35): [True: 73.8k, False: 1.89k]
  ------------------
 5297|  73.8k|    size_t decomposition_length{0};
 5298|       |
 5299|  73.8k|    if (current_character >= hangul_sbase &&
  ------------------
  |  Branch (5299:9): [True: 9.66k, False: 64.1k]
  ------------------
 5300|  9.66k|        current_character < hangul_sbase + hangul_scount) {
  ------------------
  |  Branch (5300:9): [True: 5.66k, False: 4.00k]
  ------------------
 5301|       |      // Full NFD-style Hangul decomp for the decompose() step.
 5302|  5.66k|      decomposition_length = 2;
 5303|  5.66k|      if ((current_character - hangul_sbase) % hangul_tcount) {
  ------------------
  |  Branch (5303:11): [True: 4.64k, False: 1.01k]
  ------------------
 5304|  4.64k|        decomposition_length = 3;
 5305|  4.64k|      }
 5306|  68.1k|    } else if (current_character < 0x110000) {
  ------------------
  |  Branch (5306:16): [True: 68.1k, False: 0]
  ------------------
 5307|  68.1k|      const uint8_t di = decomposition_index[current_character >> 8];
 5308|  68.1k|      const uint16_t* const decomposition =
 5309|  68.1k|          decomposition_block_row(di) + (current_character % 256);
 5310|  68.1k|      decomposition_length = (decomposition[1] >> 2) - (decomposition[0] >> 2);
 5311|  68.1k|      if ((decomposition_length > 0) && (decomposition[0] & 1)) {
  ------------------
  |  Branch (5311:11): [True: 1.87k, False: 66.3k]
  |  Branch (5311:41): [True: 0, False: 1.87k]
  ------------------
 5312|      0|        decomposition_length = 0;
 5313|      0|      }
 5314|  68.1k|    }
 5315|  73.8k|    if (decomposition_length != 0) {
  ------------------
  |  Branch (5315:9): [True: 7.53k, False: 66.3k]
  ------------------
 5316|  7.53k|      decomposition_needed = true;
 5317|  7.53k|      additional_elements += decomposition_length - 1;
 5318|  7.53k|    }
 5319|  73.8k|  }
 5320|  1.89k|  return {decomposition_needed, additional_elements};
 5321|  1.89k|}
_ZN3ada4idna9decomposeERNSt3__112basic_stringIDiNS1_11char_traitsIDiEENS1_9allocatorIDiEEEEm:
 5323|    837|void decompose(std::u32string& input, size_t additional_elements) {
 5324|    837|  input.resize(input.size() + additional_elements);
 5325|    837|  for (size_t descending_idx = input.size(),
 5326|    837|              input_count = descending_idx - additional_elements;
 5327|  49.4k|       input_count--;) {
  ------------------
  |  Branch (5327:8): [True: 48.6k, False: 837]
  ------------------
 5328|  48.6k|    if (input[input_count] >= hangul_sbase &&
  ------------------
  |  Branch (5328:9): [True: 7.25k, False: 41.3k]
  ------------------
 5329|  7.25k|        input[input_count] < hangul_sbase + hangul_scount) {
  ------------------
  |  Branch (5329:9): [True: 5.66k, False: 1.59k]
  ------------------
 5330|       |      // Hangul decomposition.
 5331|  5.66k|      char32_t s_index = input[input_count] - hangul_sbase;
 5332|  5.66k|      if (s_index % hangul_tcount != 0) {
  ------------------
  |  Branch (5332:11): [True: 4.64k, False: 1.01k]
  ------------------
 5333|  4.64k|        input[--descending_idx] = hangul_tbase + s_index % hangul_tcount;
 5334|  4.64k|      }
 5335|  5.66k|      input[--descending_idx] =
 5336|  5.66k|          hangul_vbase + (s_index % hangul_ncount) / hangul_tcount;
 5337|  5.66k|      input[--descending_idx] = hangul_lbase + s_index / hangul_ncount;
 5338|  42.9k|    } else if (input[input_count] < 0x110000) {
  ------------------
  |  Branch (5338:16): [True: 42.9k, False: 0]
  ------------------
 5339|  42.9k|      const uint16_t* decomposition =
 5340|  42.9k|          decomposition_block_row(
 5341|  42.9k|              decomposition_index[input[input_count] >> 8]) +
 5342|  42.9k|          (input[input_count] % 256);
 5343|  42.9k|      uint16_t decomposition_length =
 5344|  42.9k|          (decomposition[1] >> 2) - (decomposition[0] >> 2);
 5345|  42.9k|      if (decomposition_length > 0 && (decomposition[0] & 1)) {
  ------------------
  |  Branch (5345:11): [True: 1.87k, False: 41.1k]
  |  Branch (5345:39): [True: 0, False: 1.87k]
  ------------------
 5346|      0|        decomposition_length = 0;
 5347|      0|      }
 5348|  42.9k|      if (decomposition_length > 0) {
  ------------------
  |  Branch (5348:11): [True: 1.87k, False: 41.1k]
  ------------------
 5349|  1.87k|        const size_t base = static_cast<size_t>(decomposition[0] >> 2);
 5350|  1.87k|        if (base + decomposition_length > decomposition_data_size) {
  ------------------
  |  Branch (5350:13): [True: 0, False: 1.87k]
  ------------------
 5351|      0|          input[--descending_idx] = input[input_count];
 5352|  1.87k|        } else {
 5353|  5.85k|          while (decomposition_length-- > 0) {
  ------------------
  |  Branch (5353:18): [True: 3.98k, False: 1.87k]
  ------------------
 5354|  3.98k|            input[--descending_idx] =
 5355|  3.98k|                decomposition_data[base + decomposition_length];
 5356|  3.98k|          }
 5357|  1.87k|        }
 5358|  41.1k|      } else {
 5359|  41.1k|        input[--descending_idx] = input[input_count];
 5360|  41.1k|      }
 5361|  42.9k|    } else {
 5362|      0|      input[--descending_idx] = input[input_count];
 5363|      0|    }
 5364|  48.6k|  }
 5365|    837|}
_ZN3ada4idna7get_cccEDi:
 5367|  1.18M|uint8_t get_ccc(char32_t c) noexcept {
 5368|  1.18M|  if (c >= 0x110000) {
  ------------------
  |  Branch (5368:7): [True: 0, False: 1.18M]
  ------------------
 5369|      0|    return 0;
 5370|      0|  }
 5371|  1.18M|  return ccc_block_row(ccc_index[c >> 8])[c % 256];
 5372|  1.18M|}
_ZN3ada4idna10sort_marksERNSt3__112basic_stringIDiNS1_11char_traitsIDiEENS1_9allocatorIDiEEEE:
 5374|  1.89k|void sort_marks(std::u32string& input) {
 5375|  86.2k|  for (size_t idx = 1; idx < input.size(); idx++) {
  ------------------
  |  Branch (5375:24): [True: 84.3k, False: 1.89k]
  ------------------
 5376|  84.3k|    uint8_t ccc = get_ccc(input[idx]);
 5377|  84.3k|    if (ccc == 0) {
  ------------------
  |  Branch (5377:9): [True: 70.9k, False: 13.4k]
  ------------------
 5378|  70.9k|      continue;
 5379|  70.9k|    }
 5380|  13.4k|    auto current_character = input[idx];
 5381|  13.4k|    size_t back_idx = idx;
 5382|  27.0k|    while (back_idx != 0 && get_ccc(input[back_idx - 1]) > ccc) {
  ------------------
  |  Branch (5382:12): [True: 26.6k, False: 342]
  |  Branch (5382:29): [True: 13.5k, False: 13.1k]
  ------------------
 5383|  13.5k|      input[back_idx] = input[back_idx - 1];
 5384|  13.5k|      back_idx--;
 5385|  13.5k|    }
 5386|  13.4k|    input[back_idx] = current_character;
 5387|  13.4k|  }
 5388|  1.89k|}
_ZN3ada4idna13decompose_nfcERNSt3__112basic_stringIDiNS1_11char_traitsIDiEENS1_9allocatorIDiEEEE:
 5390|  1.89k|void decompose_nfc(std::u32string& input) {
 5391|       |  /**
 5392|       |   * Decompose the domain_name string to Unicode Normalization Form C.
 5393|       |   * @see https://www.unicode.org/reports/tr46/#ProcessingStepDecompose
 5394|       |   */
 5395|  1.89k|  auto [decomposition_needed, additional_elements] =
 5396|  1.89k|      compute_decomposition_length(input);
 5397|  1.89k|  if (decomposition_needed) {
  ------------------
  |  Branch (5397:7): [True: 837, False: 1.05k]
  ------------------
 5398|    837|    decompose(input, additional_elements);
 5399|    837|  }
 5400|  1.89k|  sort_marks(input);
 5401|  1.89k|}
_ZN3ada4idna14is_already_nfcENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 5468|  13.3k|bool is_already_nfc(std::u32string_view input) noexcept {
 5469|  13.3k|  if (input.empty()) {
  ------------------
  |  Branch (5469:7): [True: 0, False: 13.3k]
  ------------------
 5470|      0|    return true;
 5471|      0|  }
 5472|  13.3k|  if (!tables_are_ready() && !ensure_tables()) {
  ------------------
  |  Branch (5472:7): [True: 0, False: 13.3k]
  |  Branch (5472:30): [True: 0, False: 0]
  ------------------
 5473|      0|    return false;
 5474|      0|  }
 5475|       |  // 1) Singleton decompositions are never NFC (e.g. U+212B ANGSTROM SIGN).
 5476|       |  //    Multi-code-point decomps are primary composites that are NFC as-is.
 5477|   580k|  for (char32_t c : input) {
  ------------------
  |  Branch (5477:19): [True: 580k, False: 13.3k]
  ------------------
 5478|   580k|    if (canonical_decomp_length(c) == 1) {
  ------------------
  |  Branch (5478:9): [True: 0, False: 580k]
  ------------------
 5479|      0|      return false;
 5480|      0|    }
 5481|   580k|  }
 5482|       |  // 2) Combining marks already in canonical order.
 5483|  13.3k|  uint8_t prev_ccc = 0;
 5484|   552k|  for (char32_t c : input) {
  ------------------
  |  Branch (5484:19): [True: 552k, False: 12.3k]
  ------------------
 5485|   552k|    uint8_t ccc = get_ccc(c);
 5486|   552k|    if (ccc != 0 && prev_ccc > ccc) {
  ------------------
  |  Branch (5486:9): [True: 18.4k, False: 534k]
  |  Branch (5486:21): [True: 1.05k, False: 17.4k]
  ------------------
 5487|  1.05k|      return false;
 5488|  1.05k|    }
 5489|   551k|    prev_ccc = ccc;
 5490|   551k|  }
 5491|       |  // 3) No pairwise composition would apply (including Hangul L+V / LV+T).
 5492|  12.3k|  return !would_compose(input);
 5493|  13.3k|}
_ZN3ada4idna7composeERNSt3__112basic_stringIDiNS1_11char_traitsIDiEENS1_9allocatorIDiEEEE:
 5495|  1.89k|void compose(std::u32string& input) {
 5496|       |  /**
 5497|       |   * Compose the domain_name string to Unicode Normalization Form C.
 5498|       |   * @see https://www.unicode.org/reports/tr46/#ProcessingStepCompose
 5499|       |   */
 5500|  1.89k|  size_t input_count{0};
 5501|  1.89k|  size_t composition_count{0};
 5502|  63.8k|  for (; input_count < input.size(); input_count++, composition_count++) {
  ------------------
  |  Branch (5502:10): [True: 61.9k, False: 1.89k]
  ------------------
 5503|  61.9k|    input[composition_count] = input[input_count];
 5504|  61.9k|    if (input[input_count] >= hangul_lbase &&
  ------------------
  |  Branch (5504:9): [True: 19.5k, False: 42.3k]
  ------------------
 5505|  19.5k|        input[input_count] < hangul_lbase + hangul_lcount) {
  ------------------
  |  Branch (5505:9): [True: 10.5k, False: 9.04k]
  ------------------
 5506|  10.5k|      if (input_count + 1 < input.size() &&
  ------------------
  |  Branch (5506:11): [True: 10.4k, False: 45]
  ------------------
 5507|  10.4k|          input[input_count + 1] >= hangul_vbase &&
  ------------------
  |  Branch (5507:11): [True: 7.11k, False: 3.37k]
  ------------------
 5508|  7.11k|          input[input_count + 1] < hangul_vbase + hangul_vcount) {
  ------------------
  |  Branch (5508:11): [True: 6.34k, False: 771]
  ------------------
 5509|  6.34k|        input[composition_count] =
 5510|  6.34k|            hangul_sbase +
 5511|  6.34k|            ((input[input_count] - hangul_lbase) * hangul_vcount +
 5512|  6.34k|             input[input_count + 1] - hangul_vbase) *
 5513|  6.34k|                hangul_tcount;
 5514|  6.34k|        input_count++;
 5515|  6.34k|        if (input_count + 1 < input.size() &&
  ------------------
  |  Branch (5515:13): [True: 6.23k, False: 114]
  ------------------
 5516|  6.23k|            input[input_count + 1] > hangul_tbase &&
  ------------------
  |  Branch (5516:13): [True: 4.96k, False: 1.26k]
  ------------------
 5517|  4.96k|            input[input_count + 1] < hangul_tbase + hangul_tcount) {
  ------------------
  |  Branch (5517:13): [True: 4.65k, False: 315]
  ------------------
 5518|  4.65k|          input[composition_count] += input[++input_count] - hangul_tbase;
 5519|  4.65k|        }
 5520|  6.34k|      }
 5521|  51.4k|    } else if (input[input_count] >= hangul_sbase &&
  ------------------
  |  Branch (5521:16): [True: 2.60k, False: 48.8k]
  ------------------
 5522|  2.60k|               input[input_count] < hangul_sbase + hangul_scount) {
  ------------------
  |  Branch (5522:16): [True: 0, False: 2.60k]
  ------------------
 5523|      0|      if ((input[input_count] - hangul_sbase) % hangul_tcount &&
  ------------------
  |  Branch (5523:11): [True: 0, False: 0]
  ------------------
 5524|      0|          input_count + 1 < input.size() &&
  ------------------
  |  Branch (5524:11): [True: 0, False: 0]
  ------------------
 5525|      0|          input[input_count + 1] > hangul_tbase &&
  ------------------
  |  Branch (5525:11): [True: 0, False: 0]
  ------------------
 5526|      0|          input[input_count + 1] < hangul_tbase + hangul_tcount) {
  ------------------
  |  Branch (5526:11): [True: 0, False: 0]
  ------------------
 5527|      0|        input[composition_count] += input[++input_count] - hangul_tbase;
 5528|      0|      }
 5529|  51.4k|    } else if (input[input_count] < 0x110000) {
  ------------------
  |  Branch (5529:16): [True: 51.4k, False: 0]
  ------------------
 5530|  51.4k|      const uint16_t* composition =
 5531|  51.4k|          composition_block_row(composition_index[input[input_count] >> 8]) +
 5532|  51.4k|          (input[input_count] % 256);
 5533|  51.4k|      size_t initial_composition_count = composition_count;
 5534|  64.7k|      for (int32_t previous_ccc = -1; input_count + 1 < input.size();
  ------------------
  |  Branch (5534:39): [True: 63.0k, False: 1.64k]
  ------------------
 5535|  63.0k|           input_count++) {
 5536|  63.0k|        uint8_t ccc = get_ccc(input[input_count + 1]);
 5537|       |
 5538|  63.0k|        if (composition[1] != composition[0] && previous_ccc < ccc) {
  ------------------
  |  Branch (5538:13): [True: 21.3k, False: 41.7k]
  |  Branch (5538:49): [True: 16.4k, False: 4.91k]
  ------------------
 5539|  16.4k|          int left = composition[0];
 5540|  16.4k|          int right = composition[1];
 5541|  16.4k|          if (left < 0 || right < left ||
  ------------------
  |  Branch (5541:15): [True: 0, False: 16.4k]
  |  Branch (5541:27): [True: 0, False: 16.4k]
  ------------------
 5542|  16.4k|              static_cast<size_t>(right) > composition_data_size) {
  ------------------
  |  Branch (5542:15): [True: 0, False: 16.4k]
  ------------------
 5543|      0|            break;
 5544|      0|          }
 5545|  41.0k|          while (left + 2 < right) {
  ------------------
  |  Branch (5545:18): [True: 24.6k, False: 16.4k]
  ------------------
 5546|  24.6k|            int middle = left + (((right - left) >> 1) & ~1);
 5547|  24.6k|            if (composition_data[static_cast<size_t>(middle)] <=
  ------------------
  |  Branch (5547:17): [True: 7.43k, False: 17.1k]
  ------------------
 5548|  24.6k|                input[input_count + 1]) {
 5549|  7.43k|              left = middle;
 5550|  7.43k|            }
 5551|  24.6k|            if (composition_data[static_cast<size_t>(middle)] >=
  ------------------
  |  Branch (5551:17): [True: 19.5k, False: 5.12k]
  ------------------
 5552|  24.6k|                input[input_count + 1]) {
 5553|  19.5k|              right = middle;
 5554|  19.5k|            }
 5555|  24.6k|          }
 5556|  16.4k|          if (static_cast<size_t>(left + 1) < composition_data_size &&
  ------------------
  |  Branch (5556:15): [True: 16.4k, False: 0]
  ------------------
 5557|  16.4k|              composition_data[static_cast<size_t>(left)] ==
  ------------------
  |  Branch (5557:15): [True: 3.16k, False: 13.2k]
  ------------------
 5558|  16.4k|                  input[input_count + 1]) {
 5559|  3.16k|            char32_t composed = composition_data[static_cast<size_t>(left + 1)];
 5560|  3.16k|            input[initial_composition_count] = composed;
 5561|  3.16k|            composition =
 5562|  3.16k|                composition_block_row(composition_index[composed >> 8]) +
 5563|  3.16k|                (composed % 256);
 5564|  3.16k|            continue;
 5565|  3.16k|          }
 5566|  16.4k|        }
 5567|       |
 5568|  59.9k|        if (ccc == 0) {
  ------------------
  |  Branch (5568:13): [True: 49.7k, False: 10.1k]
  ------------------
 5569|  49.7k|          break;
 5570|  49.7k|        }
 5571|  10.1k|        previous_ccc = ccc;
 5572|  10.1k|        input[++composition_count] = input[input_count + 1];
 5573|  10.1k|      }
 5574|  51.4k|    }
 5575|  61.9k|  }
 5576|       |
 5577|  1.89k|  if (composition_count < input_count) {
  ------------------
  |  Branch (5577:7): [True: 1.53k, False: 360]
  ------------------
 5578|  1.53k|    input.resize(composition_count);
 5579|  1.53k|  }
 5580|  1.89k|}
_ZN3ada4idna9normalizeERNSt3__112basic_stringIDiNS1_11char_traitsIDiEENS1_9allocatorIDiEEEE:
 5582|  1.89k|bool normalize(std::u32string& input) {
 5583|       |  /**
 5584|       |   * Normalize the characters according to IDNA (Unicode Normalization Form C).
 5585|       |   * @see https://www.unicode.org/reports/tr46/#ProcessingStepNormalize
 5586|       |   */
 5587|  1.89k|  if (!ensure_tables() || decomposition_index == nullptr ||
  ------------------
  |  Branch (5587:7): [True: 0, False: 1.89k]
  |  Branch (5587:27): [True: 0, False: 1.89k]
  ------------------
 5588|  1.89k|      composition_index == nullptr) {
  ------------------
  |  Branch (5588:7): [True: 0, False: 1.89k]
  ------------------
 5589|      0|    return false;
 5590|      0|  }
 5591|  1.89k|  if (is_already_nfc(input)) {
  ------------------
  |  Branch (5591:7): [True: 0, False: 1.89k]
  ------------------
 5592|      0|    return true;
 5593|      0|  }
 5594|  1.89k|  decompose_nfc(input);
 5595|  1.89k|  compose(input);
 5596|  1.89k|  return true;
 5597|  1.89k|}
_ZN3ada4idna17punycode_to_utf32ENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEERNS1_12basic_stringIDiNS3_IDiEENS1_9allocatorIDiEEEE:
 5657|  4.41k|bool punycode_to_utf32(std::string_view input, std::u32string &out) {
 5658|  4.41k|  int32_t written_out{0};
 5659|  4.41k|  out.reserve(out.size() + input.size());
 5660|  4.41k|  uint32_t n = initial_n;
 5661|  4.41k|  int32_t i = 0;
 5662|  4.41k|  int32_t bias = initial_bias;
 5663|       |  // grab ascii content
 5664|  4.41k|  size_t end_of_ascii = input.find_last_of('-');
 5665|  4.41k|  if (end_of_ascii != std::string_view::npos) {
  ------------------
  |  Branch (5665:7): [True: 1.19k, False: 3.21k]
  ------------------
 5666|  9.00k|    for (uint8_t c : input.substr(0, end_of_ascii)) {
  ------------------
  |  Branch (5666:20): [True: 9.00k, False: 1.19k]
  ------------------
 5667|  9.00k|      if (c >= 0x80) {
  ------------------
  |  Branch (5667:11): [True: 0, False: 9.00k]
  ------------------
 5668|      0|        return false;
 5669|      0|      }
 5670|  9.00k|      out.push_back(c);
 5671|  9.00k|      written_out++;
 5672|  9.00k|    }
 5673|  1.19k|    input.remove_prefix(end_of_ascii + 1);
 5674|  1.19k|  }
 5675|  74.9k|  while (!input.empty()) {
  ------------------
  |  Branch (5675:10): [True: 70.8k, False: 4.08k]
  ------------------
 5676|  70.8k|    int32_t oldi = i;
 5677|  70.8k|    int32_t w = 1;
 5678|  96.8k|    for (int32_t k = base;; k += base) {
 5679|  96.8k|      if (input.empty()) {
  ------------------
  |  Branch (5679:11): [True: 138, False: 96.6k]
  ------------------
 5680|    138|        return false;
 5681|    138|      }
 5682|  96.6k|      uint8_t code_point = input.front();
 5683|  96.6k|      input.remove_prefix(1);
 5684|  96.6k|      int32_t digit = char_to_digit_value(code_point);
 5685|  96.6k|      if (digit < 0) {
  ------------------
  |  Branch (5685:11): [True: 75, False: 96.5k]
  ------------------
 5686|     75|        return false;
 5687|     75|      }
 5688|  96.5k|      if (digit > (0x7fffffff - i) / w) {
  ------------------
  |  Branch (5688:11): [True: 15, False: 96.5k]
  ------------------
 5689|     15|        return false;
 5690|     15|      }
 5691|  96.5k|      i = i + digit * w;
 5692|  96.5k|      int32_t t = k <= bias ? tmin : k >= bias + tmax ? tmax : k - bias;
  ------------------
  |  Branch (5692:19): [True: 16.0k, False: 80.5k]
  |  Branch (5692:38): [True: 73.2k, False: 7.24k]
  ------------------
 5693|  96.5k|      if (digit < t) {
  ------------------
  |  Branch (5693:11): [True: 70.6k, False: 25.9k]
  ------------------
 5694|  70.6k|        break;
 5695|  70.6k|      }
 5696|  25.9k|      if (w > 0x7fffffff / (base - t)) {
  ------------------
  |  Branch (5696:11): [True: 0, False: 25.9k]
  ------------------
 5697|      0|        return false;
 5698|      0|      }
 5699|  25.9k|      w = w * (base - t);
 5700|  25.9k|    }
 5701|  70.6k|    bias = adapt(i - oldi, written_out + 1, oldi == 0);
 5702|  70.6k|    if (i / (written_out + 1) > int32_t(0x7fffffff - n)) {
  ------------------
  |  Branch (5702:9): [True: 96, False: 70.5k]
  ------------------
 5703|     96|      return false;
 5704|     96|    }
 5705|  70.5k|    n = n + i / (written_out + 1);
 5706|  70.5k|    i = i % (written_out + 1);
 5707|  70.5k|    if (n < 0x80) {
  ------------------
  |  Branch (5707:9): [True: 0, False: 70.5k]
  ------------------
 5708|      0|      return false;
 5709|      0|    }
 5710|  70.5k|    out.insert(out.begin() + i, n);
 5711|  70.5k|    written_out++;
 5712|  70.5k|    ++i;
 5713|  70.5k|  }
 5714|       |  // See https://github.com/whatwg/url/issues/803
 5715|       |  // Reject labels whose decoded form begins with "xn--" (double-encoded ACE).
 5716|  4.08k|  if (out.size() >= 4 && out[0] == U'x' && out[1] == U'n' && out[2] == U'-' &&
  ------------------
  |  Branch (5716:7): [True: 2.22k, False: 1.86k]
  |  Branch (5716:26): [True: 528, False: 1.69k]
  |  Branch (5716:44): [True: 321, False: 207]
  |  Branch (5716:62): [True: 162, False: 159]
  ------------------
 5717|    162|      out[3] == U'-') {
  ------------------
  |  Branch (5717:7): [True: 15, False: 147]
  ------------------
 5718|     15|    return false;
 5719|     15|  }
 5720|  4.07k|  return true;
 5721|  4.08k|}
_ZN3ada4idna17utf32_to_punycodeENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEERNS1_12basic_stringIcNS3_IcEENS1_9allocatorIcEEEE:
 5801|  36.9k|bool utf32_to_punycode(std::u32string_view input, std::string &out) {
 5802|  36.9k|  out.reserve(input.size() + out.size());
 5803|  36.9k|  uint32_t n = initial_n;
 5804|  36.9k|  int32_t d = 0;
 5805|  36.9k|  int32_t bias = initial_bias;
 5806|  36.9k|  size_t h = 0;
 5807|       |  // first push the ascii content
 5808|   270k|  for (uint32_t c : input) {
  ------------------
  |  Branch (5808:19): [True: 270k, False: 36.9k]
  ------------------
 5809|   270k|    if (c < 0x80) {
  ------------------
  |  Branch (5809:9): [True: 44.8k, False: 225k]
  ------------------
 5810|  44.8k|      ++h;
 5811|  44.8k|      out.push_back(char(c));
 5812|  44.8k|    }
 5813|   270k|    if (c > 0x10ffff || (c >= 0xd800 && c < 0xe000)) {
  ------------------
  |  Branch (5813:9): [True: 0, False: 270k]
  |  Branch (5813:26): [True: 2.17k, False: 268k]
  |  Branch (5813:41): [True: 0, False: 2.17k]
  ------------------
 5814|      0|      return false;
 5815|      0|    }
 5816|   270k|  }
 5817|  36.9k|  size_t b = h;
 5818|  36.9k|  if (b > 0) {
  ------------------
  |  Branch (5818:7): [True: 6.78k, False: 30.1k]
  ------------------
 5819|  6.78k|    out.push_back('-');
 5820|  6.78k|  }
 5821|   160k|  while (h < input.size()) {
  ------------------
  |  Branch (5821:10): [True: 123k, False: 36.9k]
  ------------------
 5822|   123k|    uint32_t m = 0x10FFFF;
 5823|  2.27M|    for (auto code_point : input) {
  ------------------
  |  Branch (5823:26): [True: 2.27M, False: 123k]
  ------------------
 5824|  2.27M|      if (code_point >= n && code_point < m) m = code_point;
  ------------------
  |  Branch (5824:11): [True: 1.03M, False: 1.23M]
  |  Branch (5824:30): [True: 210k, False: 825k]
  ------------------
 5825|  2.27M|    }
 5826|       |
 5827|   123k|    if ((m - n) > (0x7fffffff - d) / (h + 1)) {
  ------------------
  |  Branch (5827:9): [True: 0, False: 123k]
  ------------------
 5828|      0|      return false;
 5829|      0|    }
 5830|   123k|    d = d + int32_t((m - n) * (h + 1));
 5831|   123k|    n = m;
 5832|  2.27M|    for (auto c : input) {
  ------------------
  |  Branch (5832:17): [True: 2.27M, False: 123k]
  ------------------
 5833|  2.27M|      if (c < n) {
  ------------------
  |  Branch (5833:11): [True: 1.23M, False: 1.03M]
  ------------------
 5834|  1.23M|        if (d == 0x7fffffff) {
  ------------------
  |  Branch (5834:13): [True: 0, False: 1.23M]
  ------------------
 5835|      0|          return false;
 5836|      0|        }
 5837|  1.23M|        ++d;
 5838|  1.23M|      }
 5839|  2.27M|      if (c == n) {
  ------------------
  |  Branch (5839:11): [True: 225k, False: 2.04M]
  ------------------
 5840|   225k|        int32_t q = d;
 5841|   510k|        for (int32_t k = base;; k += base) {
 5842|   510k|          int32_t t = k <= bias ? tmin : k >= bias + tmax ? tmax : k - bias;
  ------------------
  |  Branch (5842:23): [True: 129k, False: 381k]
  |  Branch (5842:42): [True: 299k, False: 81.8k]
  ------------------
 5843|       |
 5844|   510k|          if (q < t) {
  ------------------
  |  Branch (5844:15): [True: 225k, False: 285k]
  ------------------
 5845|   225k|            break;
 5846|   225k|          }
 5847|   285k|          out.push_back(digit_to_char(t + ((q - t) % (base - t))));
 5848|   285k|          q = (q - t) / (base - t);
 5849|   285k|        }
 5850|   225k|        out.push_back(digit_to_char(q));
 5851|   225k|        bias = adapt(d, int32_t(h + 1), h == b);
 5852|   225k|        d = 0;
 5853|   225k|        ++h;
 5854|   225k|      }
 5855|  2.27M|    }
 5856|   123k|    ++d;
 5857|   123k|    ++n;
 5858|   123k|  }
 5859|  36.9k|  return true;
 5860|  36.9k|}
_ZN3ada4idna14is_label_validENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 5944|  41.5k|bool is_label_valid(const std::u32string_view label) {
 5945|  41.5k|  if (label.empty()) {
  ------------------
  |  Branch (5945:7): [True: 0, False: 41.5k]
  ------------------
 5946|      0|    return true;
 5947|      0|  }
 5948|  41.5k|  if (!ensure_tables() || combining_ranges == nullptr || dir_start == nullptr ||
  ------------------
  |  Branch (5948:7): [True: 0, False: 41.5k]
  |  Branch (5948:27): [True: 0, False: 41.5k]
  |  Branch (5948:58): [True: 0, False: 41.5k]
  ------------------
 5949|  41.5k|      dir_final == nullptr || dir_value == nullptr) {
  ------------------
  |  Branch (5949:7): [True: 0, False: 41.5k]
  |  Branch (5949:31): [True: 0, False: 41.5k]
  ------------------
 5950|      0|    return false;
 5951|      0|  }
 5952|       |
 5953|       |  ///////////////
 5954|       |  // We have a normalization step which ensures that we are in NFC.
 5955|       |  // If we receive punycode, we normalize and check that the normalized
 5956|       |  // version matches the original.
 5957|       |  // --------------------------------------
 5958|       |  // The label must be in Unicode Normalization Form NFC.
 5959|       |
 5960|       |  // Current URL standard indicatest that CheckHyphens is set to false.
 5961|       |  // ---------------------------------------
 5962|       |  // If CheckHyphens, the label must not contain a U+002D HYPHEN-MINUS character
 5963|       |  // in both the third and fourth positions. If CheckHyphens, the label must
 5964|       |  // neither begin nor end with a U+002D HYPHEN-MINUS character.
 5965|       |
 5966|       |  // This is not necessary because we segment the
 5967|       |  // labels by '.'.
 5968|       |  // ---------------------------------------
 5969|       |  // The label must not contain a U+002E ( . ) FULL STOP.
 5970|       |  // if (label.find('.') != std::string_view::npos) return false;
 5971|       |
 5972|       |  // The label must not begin with a combining mark.
 5973|       |  // Range membership via lower_bound on range end.
 5974|  41.5k|  const std::span<const uint32_t[2]> comb_span{combining_ranges,
 5975|  41.5k|                                               combining_range_count};
 5976|  41.5k|  const auto comb_it = std::ranges::lower_bound(
 5977|  41.5k|      comb_span, label.front(), {}, [](const auto& range) { return range[1]; });
 5978|  41.5k|  if (comb_it != comb_span.end() && label.front() >= (*comb_it)[0]) {
  ------------------
  |  Branch (5978:7): [True: 41.5k, False: 0]
  |  Branch (5978:7): [True: 210, False: 41.3k]
  |  Branch (5978:37): [True: 210, False: 41.3k]
  ------------------
 5979|    210|    return false;
 5980|    210|  }
 5981|       |  // We verify this next step as part of the mapping:
 5982|       |  // ---------------------------------------------
 5983|       |  // Each code point in the label must only have certain status values
 5984|       |  // according to Section 5, IDNA Mapping Table:
 5985|       |  // - For Transitional Processing, each value must be valid.
 5986|       |  // - For Nontransitional Processing, each value must be either valid or
 5987|       |  // deviation.
 5988|       |
 5989|       |  // If CheckJoiners, the label must satisfy the ContextJ rules from Appendix
 5990|       |  // A, in The Unicode Code Points and Internationalized Domain Names for
 5991|       |  // Applications (IDNA) [IDNA2008].
 5992|  41.3k|  constexpr static uint32_t virama[] = {
 5993|  41.3k|      0x094D,  0x09CD,  0x0A4D,  0x0ACD,  0x0B4D,  0x0BCD,  0x0C4D,  0x0CCD,
 5994|  41.3k|      0x0D3B,  0x0D3C,  0x0D4D,  0x0DCA,  0x0E3A,  0x0EBA,  0x0F84,  0x1039,
 5995|  41.3k|      0x103A,  0x1714,  0x1734,  0x17D2,  0x1A60,  0x1B44,  0x1BAA,  0x1BAB,
 5996|  41.3k|      0x1BF2,  0x1BF3,  0x2D7F,  0xA806,  0xA82C,  0xA8C4,  0xA953,  0xA9C0,
 5997|  41.3k|      0xAAF6,  0xABED,  0x10A3F, 0x11046, 0x1107F, 0x110B9, 0x11133, 0x11134,
 5998|  41.3k|      0x111C0, 0x11235, 0x112EA, 0x1134D, 0x11442, 0x114C2, 0x115BF, 0x1163F,
 5999|  41.3k|      0x116B6, 0x1172B, 0x11839, 0x1193D, 0x1193E, 0x119E0, 0x11A34, 0x11A47,
 6000|  41.3k|      0x11A99, 0x11C3F, 0x11D44, 0x11D45, 0x11D97};
 6001|  41.3k|  constexpr static uint32_t R[] = {
 6002|  41.3k|      0x622, 0x623, 0x624, 0x625, 0x627, 0x629, 0x62f, 0x630, 0x631,
 6003|  41.3k|      0x632, 0x648, 0x671, 0x672, 0x673, 0x675, 0x676, 0x677, 0x688,
 6004|  41.3k|      0x689, 0x68a, 0x68b, 0x68c, 0x68d, 0x68e, 0x68f, 0x690, 0x691,
 6005|  41.3k|      0x692, 0x693, 0x694, 0x695, 0x696, 0x697, 0x698, 0x699, 0x6c0,
 6006|  41.3k|      0x6c3, 0x6c4, 0x6c5, 0x6c6, 0x6c7, 0x6c8, 0x6c9, 0x6ca, 0x6cb,
 6007|  41.3k|      0x6cd, 0x6cf, 0x6d2, 0x6d3, 0x6d5, 0x6ee, 0x6ef, 0x710, 0x715,
 6008|  41.3k|      0x716, 0x717, 0x718, 0x719, 0x71e, 0x728, 0x72a, 0x72c, 0x72f,
 6009|  41.3k|      0x74d, 0x759, 0x75a, 0x75b, 0x854, 0x8aa, 0x8ab, 0x8ac};
 6010|  41.3k|  constexpr static uint32_t L[] = {0xa872};
 6011|  41.3k|  constexpr static uint32_t D[] = {
 6012|  41.3k|      0x620,  0x626,  0x628,  0x62a,  0x62b,  0x62c,  0x62d,  0x62e,  0x633,
 6013|  41.3k|      0x634,  0x635,  0x636,  0x637,  0x638,  0x639,  0x63a,  0x63b,  0x63c,
 6014|  41.3k|      0x63d,  0x63e,  0x63f,  0x641,  0x642,  0x643,  0x644,  0x645,  0x646,
 6015|  41.3k|      0x647,  0x649,  0x64a,  0x66e,  0x66f,  0x678,  0x679,  0x67a,  0x67b,
 6016|  41.3k|      0x67c,  0x67d,  0x67e,  0x67f,  0x680,  0x681,  0x682,  0x683,  0x684,
 6017|  41.3k|      0x685,  0x686,  0x687,  0x69a,  0x69b,  0x69c,  0x69d,  0x69e,  0x69f,
 6018|  41.3k|      0x6a0,  0x6a1,  0x6a2,  0x6a3,  0x6a4,  0x6a5,  0x6a6,  0x6a7,  0x6a8,
 6019|  41.3k|      0x6a9,  0x6aa,  0x6ab,  0x6ac,  0x6ad,  0x6ae,  0x6af,  0x6b0,  0x6b1,
 6020|  41.3k|      0x6b2,  0x6b3,  0x6b4,  0x6b5,  0x6b6,  0x6b7,  0x6b8,  0x6b9,  0x6ba,
 6021|  41.3k|      0x6bb,  0x6bc,  0x6bd,  0x6be,  0x6bf,  0x6c1,  0x6c2,  0x6cc,  0x6ce,
 6022|  41.3k|      0x6d0,  0x6d1,  0x6fa,  0x6fb,  0x6fc,  0x6ff,  0x712,  0x713,  0x714,
 6023|  41.3k|      0x71a,  0x71b,  0x71c,  0x71d,  0x71f,  0x720,  0x721,  0x722,  0x723,
 6024|  41.3k|      0x724,  0x725,  0x726,  0x727,  0x729,  0x72b,  0x72d,  0x72e,  0x74e,
 6025|  41.3k|      0x74f,  0x750,  0x751,  0x752,  0x753,  0x754,  0x755,  0x756,  0x757,
 6026|  41.3k|      0x758,  0x75c,  0x75d,  0x75e,  0x75f,  0x760,  0x761,  0x762,  0x763,
 6027|  41.3k|      0x764,  0x765,  0x766,  0x850,  0x851,  0x852,  0x853,  0x855,  0x8a0,
 6028|  41.3k|      0x8a2,  0x8a3,  0x8a4,  0x8a5,  0x8a6,  0x8a7,  0x8a8,  0x8a9,  0x1807,
 6029|  41.3k|      0x1820, 0x1821, 0x1822, 0x1823, 0x1824, 0x1825, 0x1826, 0x1827, 0x1828,
 6030|  41.3k|      0x1829, 0x182a, 0x182b, 0x182c, 0x182d, 0x182e, 0x182f, 0x1830, 0x1831,
 6031|  41.3k|      0x1832, 0x1833, 0x1834, 0x1835, 0x1836, 0x1837, 0x1838, 0x1839, 0x183a,
 6032|  41.3k|      0x183b, 0x183c, 0x183d, 0x183e, 0x183f, 0x1840, 0x1841, 0x1842, 0x1843,
 6033|  41.3k|      0x1844, 0x1845, 0x1846, 0x1847, 0x1848, 0x1849, 0x184a, 0x184b, 0x184c,
 6034|  41.3k|      0x184d, 0x184e, 0x184f, 0x1850, 0x1851, 0x1852, 0x1853, 0x1854, 0x1855,
 6035|  41.3k|      0x1856, 0x1857, 0x1858, 0x1859, 0x185a, 0x185b, 0x185c, 0x185d, 0x185e,
 6036|  41.3k|      0x185f, 0x1860, 0x1861, 0x1862, 0x1863, 0x1864, 0x1865, 0x1866, 0x1867,
 6037|  41.3k|      0x1868, 0x1869, 0x186a, 0x186b, 0x186c, 0x186d, 0x186e, 0x186f, 0x1870,
 6038|  41.3k|      0x1871, 0x1872, 0x1873, 0x1874, 0x1875, 0x1876, 0x1877, 0x1887, 0x1888,
 6039|  41.3k|      0x1889, 0x188a, 0x188b, 0x188c, 0x188d, 0x188e, 0x188f, 0x1890, 0x1891,
 6040|  41.3k|      0x1892, 0x1893, 0x1894, 0x1895, 0x1896, 0x1897, 0x1898, 0x1899, 0x189a,
 6041|  41.3k|      0x189b, 0x189c, 0x189d, 0x189e, 0x189f, 0x18a0, 0x18a1, 0x18a2, 0x18a3,
 6042|  41.3k|      0x18a4, 0x18a5, 0x18a6, 0x18a7, 0x18a8, 0x18aa, 0xa840, 0xa841, 0xa842,
 6043|  41.3k|      0xa843, 0xa844, 0xa845, 0xa846, 0xa847, 0xa848, 0xa849, 0xa84a, 0xa84b,
 6044|  41.3k|      0xa84c, 0xa84d, 0xa84e, 0xa84f, 0xa850, 0xa851, 0xa852, 0xa853, 0xa854,
 6045|  41.3k|      0xa855, 0xa856, 0xa857, 0xa858, 0xa859, 0xa85a, 0xa85b, 0xa85c, 0xa85d,
 6046|  41.3k|      0xa85e, 0xa85f, 0xa860, 0xa861, 0xa862, 0xa863, 0xa864, 0xa865, 0xa866,
 6047|  41.3k|      0xa867, 0xa868, 0xa869, 0xa86a, 0xa86b, 0xa86c, 0xa86d, 0xa86e, 0xa86f,
 6048|  41.3k|      0xa870, 0xa871};
 6049|       |
 6050|   310k|  for (size_t i = 0; i < label.size(); i++) {
  ------------------
  |  Branch (6050:22): [True: 272k, False: 38.7k]
  ------------------
 6051|   272k|    uint32_t c = label[i];
 6052|   272k|    if (c == 0x200c) {
  ------------------
  |  Branch (6052:9): [True: 2.14k, False: 269k]
  ------------------
 6053|  2.14k|      if (i > 0) {
  ------------------
  |  Branch (6053:11): [True: 2.13k, False: 9]
  ------------------
 6054|  2.13k|        if (std::ranges::binary_search(virama, label[i - 1])) {
  ------------------
  |  Branch (6054:13): [True: 243, False: 1.89k]
  ------------------
 6055|    243|          return true;
 6056|    243|        }
 6057|  2.13k|      }
 6058|  1.90k|      if ((i == 0) || (i + 1 >= label.size())) {
  ------------------
  |  Branch (6058:11): [True: 9, False: 1.89k]
  |  Branch (6058:23): [True: 135, False: 1.75k]
  ------------------
 6059|    144|        return false;
 6060|    144|      }
 6061|       |      // we go backward looking for L or D
 6062|  1.75k|      auto is_l_or_d = [](uint32_t code) {
 6063|  1.75k|        return std::ranges::binary_search(L, code) ||
 6064|  1.75k|               std::ranges::binary_search(D, code);
 6065|  1.75k|      };
 6066|  1.75k|      auto is_r_or_d = [](uint32_t code) {
 6067|  1.75k|        return std::ranges::binary_search(R, code) ||
 6068|  1.75k|               std::ranges::binary_search(D, code);
 6069|  1.75k|      };
 6070|  1.75k|      std::u32string_view before = label.substr(0, i);
 6071|  1.75k|      std::u32string_view after = label.substr(i + 1);
 6072|  1.75k|      return (std::find_if(before.begin(), before.end(), is_l_or_d) !=
  ------------------
  |  Branch (6072:14): [True: 1.58k, False: 171]
  ------------------
 6073|  1.75k|              before.end()) &&
 6074|  1.58k|             (std::find_if(after.begin(), after.end(), is_r_or_d) !=
  ------------------
  |  Branch (6074:14): [True: 1.34k, False: 246]
  ------------------
 6075|  1.58k|              after.end());
 6076|   269k|    } else if (c == 0x200d) {
  ------------------
  |  Branch (6076:16): [True: 456, False: 269k]
  ------------------
 6077|    456|      if (i > 0) {
  ------------------
  |  Branch (6077:11): [True: 444, False: 12]
  ------------------
 6078|    444|        if (std::ranges::binary_search(virama, label[i - 1])) {
  ------------------
  |  Branch (6078:13): [True: 357, False: 87]
  ------------------
 6079|    357|          return true;
 6080|    357|        }
 6081|    444|      }
 6082|     99|      return false;
 6083|    456|    }
 6084|   272k|  }
 6085|       |
 6086|       |  // If CheckBidi, and if the domain name is a  Bidi domain name, then the label
 6087|       |  // must satisfy all six of the numbered conditions in [IDNA2008] RFC 5893,
 6088|       |  // Section 2.
 6089|       |
 6090|       |  // The following rule, consisting of six conditions, applies to labels
 6091|       |  // in Bidi domain names.  The requirements that this rule satisfies are
 6092|       |  // described in Section 3.  All of the conditions must be satisfied for
 6093|       |  // the rule to be satisfied.
 6094|       |  //
 6095|       |  //  1.  The first character must be a character with Bidi property L, R,
 6096|       |  //     or AL.  If it has the R or AL property, it is an RTL label; if it
 6097|       |  //     has the L property, it is an LTR label.
 6098|       |  //
 6099|       |  //  2.  In an RTL label, only characters with the Bidi properties R, AL,
 6100|       |  //      AN, EN, ES, CS, ET, ON, BN, or NSM are allowed.
 6101|       |  //
 6102|       |  //   3.  In an RTL label, the end of the label must be a character with
 6103|       |  //       Bidi property R, AL, EN, or AN, followed by zero or more
 6104|       |  //       characters with Bidi property NSM.
 6105|       |  //
 6106|       |  //   4.  In an RTL label, if an EN is present, no AN may be present, and
 6107|       |  //       vice versa.
 6108|       |  //
 6109|       |  //  5.  In an LTR label, only characters with the Bidi properties L, EN,
 6110|       |  //       ES, CS, ET, ON, BN, or NSM are allowed.
 6111|       |  //
 6112|       |  //   6.  In an LTR label, the end of the label must be a character with
 6113|       |  //       Bidi property L or EN, followed by zero or more characters with
 6114|       |  //       Bidi property NSM.
 6115|       |
 6116|  38.7k|  size_t last_non_nsm_char = find_last_not_of_nsm(label);
 6117|  38.7k|  if (last_non_nsm_char == std::u32string_view::npos) {
  ------------------
  |  Branch (6117:7): [True: 0, False: 38.7k]
  ------------------
 6118|      0|    return false;
 6119|      0|  }
 6120|       |
 6121|       |  // A "Bidi domain name" is a domain name that contains at least one RTL label.
 6122|       |  // The following rule, consisting of six conditions, applies to labels in Bidi
 6123|       |  // domain names.
 6124|  38.7k|  if (is_rtl_label(label)) {
  ------------------
  |  Branch (6124:7): [True: 3.30k, False: 35.4k]
  ------------------
 6125|       |    // The first character must be a character with Bidi property L, R,
 6126|       |    // or AL. If it has the R or AL property, it is an RTL label; if it
 6127|       |    // has the L property, it is an LTR label.
 6128|       |
 6129|  3.30k|    if (find_direction(label[0]) == direction::L) {
  ------------------
  |  Branch (6129:9): [True: 525, False: 2.78k]
  ------------------
 6130|       |      // Eval as LTR
 6131|       |
 6132|       |      // In an LTR label, only characters with the Bidi properties L, EN,
 6133|       |      // ES, CS, ET, ON, BN, or NSM are allowed.
 6134|  13.2k|      for (size_t i = 0; i <= last_non_nsm_char; i++) {
  ------------------
  |  Branch (6134:26): [True: 13.2k, False: 0]
  ------------------
 6135|  13.2k|        const direction d = find_direction(label[i]);
 6136|  13.2k|        if (!(d == direction::L || d == direction::EN || d == direction::ES ||
  ------------------
  |  Branch (6136:15): [True: 2.59k, False: 10.6k]
  |  Branch (6136:36): [True: 1.03k, False: 9.65k]
  |  Branch (6136:58): [True: 1.05k, False: 8.60k]
  ------------------
 6137|  8.60k|              d == direction::CS || d == direction::ET || d == direction::ON ||
  ------------------
  |  Branch (6137:15): [True: 1.02k, False: 7.57k]
  |  Branch (6137:37): [True: 1.56k, False: 6.00k]
  |  Branch (6137:59): [True: 1.48k, False: 4.52k]
  ------------------
 6138|  4.52k|              d == direction::BN || d == direction::NSM)) {
  ------------------
  |  Branch (6138:15): [True: 2.20k, False: 2.31k]
  |  Branch (6138:37): [True: 1.79k, False: 525]
  ------------------
 6139|    525|          return false;
 6140|    525|        }
 6141|  13.2k|      }
 6142|       |
 6143|      0|      const direction last_dir = find_direction(label[last_non_nsm_char]);
 6144|      0|      if (!(last_dir == direction::L || last_dir == direction::EN)) {
  ------------------
  |  Branch (6144:13): [True: 0, False: 0]
  |  Branch (6144:41): [True: 0, False: 0]
  ------------------
 6145|      0|        return false;
 6146|      0|      }
 6147|       |
 6148|      0|      return true;
 6149|       |
 6150|  2.78k|    } else {
 6151|       |      // Eval as RTL
 6152|       |
 6153|       |      // The first character must be R or AL; a leading AN (or any other
 6154|       |      // direction) does not start a valid RTL label.
 6155|  2.78k|      const direction first_dir = find_direction(label[0]);
 6156|  2.78k|      if (first_dir != direction::R && first_dir != direction::AL) {
  ------------------
  |  Branch (6156:11): [True: 1.41k, False: 1.36k]
  |  Branch (6156:40): [True: 99, False: 1.32k]
  ------------------
 6157|     99|        return false;
 6158|     99|      }
 6159|       |
 6160|  2.68k|      bool has_an = false;
 6161|  2.68k|      bool has_en = false;
 6162|  19.0k|      for (size_t i = 0; i <= last_non_nsm_char; i++) {
  ------------------
  |  Branch (6162:26): [True: 16.7k, False: 2.30k]
  ------------------
 6163|  16.7k|        const direction d = find_direction(label[i]);
 6164|       |
 6165|       |        // In an RTL label, if an EN is present, no AN may be present, and vice
 6166|       |        // versa.
 6167|  16.7k|        if ((d == direction::EN && ((has_en = true) && has_an)) ||
  ------------------
  |  Branch (6167:14): [True: 1.65k, False: 15.0k]
  |  Branch (6167:37): [True: 1.65k, False: 0]
  |  Branch (6167:56): [True: 9, False: 1.64k]
  ------------------
 6168|  16.7k|            (d == direction::AN && ((has_an = true) && has_en))) {
  ------------------
  |  Branch (6168:14): [True: 726, False: 15.9k]
  |  Branch (6168:37): [True: 726, False: 0]
  |  Branch (6168:56): [True: 9, False: 717]
  ------------------
 6169|     18|          return false;
 6170|     18|        }
 6171|       |
 6172|  16.7k|        if (!(d == direction::R || d == direction::AL || d == direction::AN ||
  ------------------
  |  Branch (6172:15): [True: 2.48k, False: 14.2k]
  |  Branch (6172:36): [True: 2.75k, False: 11.4k]
  |  Branch (6172:58): [True: 717, False: 10.7k]
  ------------------
 6173|  10.7k|              d == direction::EN || d == direction::ES || d == direction::CS ||
  ------------------
  |  Branch (6173:15): [True: 1.64k, False: 9.12k]
  |  Branch (6173:37): [True: 1.42k, False: 7.69k]
  |  Branch (6173:59): [True: 1.36k, False: 6.32k]
  ------------------
 6174|  6.32k|              d == direction::ET || d == direction::ON || d == direction::BN ||
  ------------------
  |  Branch (6174:15): [True: 1.17k, False: 5.15k]
  |  Branch (6174:37): [True: 1.38k, False: 3.77k]
  |  Branch (6174:59): [True: 2.49k, False: 1.28k]
  ------------------
 6175|  1.28k|              d == direction::NSM)) {
  ------------------
  |  Branch (6175:15): [True: 1.10k, False: 174]
  ------------------
 6176|    174|          return false;
 6177|    174|        }
 6178|       |
 6179|  16.5k|        if (i == last_non_nsm_char &&
  ------------------
  |  Branch (6179:13): [True: 2.49k, False: 14.0k]
  ------------------
 6180|  2.49k|            !(d == direction::R || d == direction::AL || d == direction::AN ||
  ------------------
  |  Branch (6180:15): [True: 708, False: 1.78k]
  |  Branch (6180:36): [True: 774, False: 1.01k]
  |  Branch (6180:58): [True: 237, False: 774]
  ------------------
 6181|    774|              d == direction::EN)) {
  ------------------
  |  Branch (6181:15): [True: 585, False: 189]
  ------------------
 6182|    189|          return false;
 6183|    189|        }
 6184|  16.5k|      }
 6185|       |
 6186|  2.30k|      return true;
 6187|  2.68k|    }
 6188|  3.30k|  }
 6189|       |
 6190|  35.4k|  return true;
 6191|  38.7k|}
_ZN3ada4idna8to_asciiENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEERNS1_12basic_stringIcS4_NS1_9allocatorIcEEEE:
 6348|  18.5k|[[nodiscard]] bool to_ascii(std::string_view ut8_string, std::string& out) {
 6349|  18.5k|  out.clear();
 6350|  18.5k|  if (ut8_string.size() > max_domain_input_bytes) {
  ------------------
  |  Branch (6350:7): [True: 0, False: 18.5k]
  ------------------
 6351|      0|    return false;
 6352|      0|  }
 6353|  18.5k|  if (is_ascii(ut8_string)) {
  ------------------
  |  Branch (6353:7): [True: 7.14k, False: 11.4k]
  ------------------
 6354|  7.14k|    from_ascii_to_ascii(ut8_string, out);
 6355|  7.14k|    return true;
 6356|  7.14k|  }
 6357|       |
 6358|       |#ifdef ADA_USE_SIMDUTF
 6359|       |  size_t utf32_length =
 6360|       |      simdutf::utf32_length_from_utf8(ut8_string.data(), ut8_string.size());
 6361|       |  if (utf32_length == 0 && !ut8_string.empty()) {
 6362|       |    return false;
 6363|       |  }
 6364|       |  std::u32string working(utf32_length, U'\0');
 6365|       |  size_t actual_utf32_length = simdutf::convert_utf8_to_utf32(
 6366|       |      ut8_string.data(), ut8_string.size(), working.data());
 6367|       |#else
 6368|  11.4k|  size_t utf32_length =
 6369|  11.4k|      ada::idna::utf32_length_from_utf8(ut8_string.data(), ut8_string.size());
 6370|  11.4k|  if (utf32_length == 0 && !ut8_string.empty()) {
  ------------------
  |  Branch (6370:7): [True: 81, False: 11.3k]
  |  Branch (6370:28): [True: 81, False: 0]
  ------------------
 6371|     81|    return false;
 6372|     81|  }
 6373|  11.3k|  std::u32string working(utf32_length, U'\0');
 6374|  11.3k|  size_t actual_utf32_length = ada::idna::utf8_to_utf32(
 6375|  11.3k|      ut8_string.data(), ut8_string.size(), working.data());
 6376|  11.3k|#endif
 6377|  11.3k|  if (actual_utf32_length == 0 || actual_utf32_length != utf32_length) {
  ------------------
  |  Branch (6377:7): [True: 870, False: 10.4k]
  |  Branch (6377:35): [True: 0, False: 10.4k]
  ------------------
 6378|    870|    return false;
 6379|    870|  }
 6380|  10.4k|  working.resize(actual_utf32_length);
 6381|       |
 6382|       |  // Map into a second buffer with exact sizing (no growth reallocs).
 6383|  10.4k|  std::u32string mapped;
 6384|  10.4k|  if (!ada::idna::map(working, mapped)) {
  ------------------
  |  Branch (6384:7): [True: 147, False: 10.3k]
  ------------------
 6385|    147|    return false;
 6386|    147|  }
 6387|       |  // Drop UTF-32 input; reuse `working` as scratch for ACE validation below.
 6388|  10.3k|  working.clear();
 6389|       |
 6390|       |  // Skip NFC when already normalized (ASCII is a fast subset of this check).
 6391|  10.3k|  if (!is_ascii(mapped) && !is_already_nfc(mapped)) {
  ------------------
  |  Branch (6391:7): [True: 8.28k, False: 2.03k]
  |  Branch (6391:28): [True: 1.32k, False: 6.96k]
  ------------------
 6392|  1.32k|    if (!normalize(mapped)) {
  ------------------
  |  Branch (6392:9): [True: 0, False: 1.32k]
  ------------------
 6393|      0|      return false;
 6394|      0|    }
 6395|  1.32k|  }
 6396|       |
 6397|       |  // Estimate ASCII output size (punycode may expand non-ASCII labels).
 6398|  10.3k|  out.reserve(mapped.size() + 8);
 6399|       |
 6400|       |  // Walk labels with a single pointer scan (no repeated string::find).
 6401|  10.3k|  const char32_t* p = mapped.data();
 6402|  10.3k|  const char32_t* const end = p + mapped.size();
 6403|  10.3k|  std::u32string post_map;
 6404|       |
 6405|  57.7k|  while (p < end) {
  ------------------
  |  Branch (6405:10): [True: 50.9k, False: 6.78k]
  ------------------
 6406|  50.9k|    const char32_t* label_begin = p;
 6407|   544k|    while (p < end && *p != U'.') {
  ------------------
  |  Branch (6407:12): [True: 534k, False: 9.51k]
  |  Branch (6407:23): [True: 493k, False: 41.4k]
  ------------------
 6408|   493k|      ++p;
 6409|   493k|    }
 6410|  50.9k|    const size_t label_size = static_cast<size_t>(p - label_begin);
 6411|  50.9k|    std::u32string_view label_view(label_begin, label_size);
 6412|  50.9k|    const bool is_last_label = (p == end);
 6413|  50.9k|    if (p < end) {
  ------------------
  |  Branch (6413:9): [True: 41.4k, False: 9.51k]
  ------------------
 6414|  41.4k|      ++p;  // skip dot
 6415|  41.4k|    }
 6416|       |
 6417|  50.9k|    if (label_size == 0) {
  ------------------
  |  Branch (6417:9): [True: 3.00k, False: 47.9k]
  ------------------
 6418|       |      // empty label
 6419|  47.9k|    } else if (is_ace_prefix(label_view)) {
  ------------------
  |  Branch (6419:16): [True: 4.46k, False: 43.5k]
  ------------------
 6420|   127k|      for (char32_t c : label_view) {
  ------------------
  |  Branch (6420:23): [True: 127k, False: 4.41k]
  ------------------
 6421|   127k|        if (c >= 0x80) {
  ------------------
  |  Branch (6421:13): [True: 51, False: 127k]
  ------------------
 6422|     51|          out.clear();
 6423|     51|          return false;
 6424|     51|        }
 6425|   127k|      }
 6426|  4.41k|      append_ascii_label(out, label_view);
 6427|  4.41k|      std::string_view puny_segment_ascii(
 6428|  4.41k|          out.data() + (out.size() - label_size) + 4, label_size - 4);
 6429|  4.41k|      working.clear();
 6430|  4.41k|      if (!ada::idna::punycode_to_utf32(puny_segment_ascii, working)) {
  ------------------
  |  Branch (6430:11): [True: 339, False: 4.07k]
  ------------------
 6431|    339|        out.clear();
 6432|    339|        return false;
 6433|    339|      }
 6434|  4.07k|      if (is_ascii(working)) {
  ------------------
  |  Branch (6434:11): [True: 171, False: 3.90k]
  ------------------
 6435|    171|        out.clear();
 6436|    171|        return false;
 6437|    171|      }
 6438|  3.90k|      if (!ada::idna::map(working, post_map) || working != post_map) {
  ------------------
  |  Branch (6438:11): [True: 513, False: 3.38k]
  |  Branch (6438:49): [True: 192, False: 3.19k]
  ------------------
 6439|    705|        out.clear();
 6440|    705|        return false;
 6441|    705|      }
 6442|       |      // Mapping must be stable; NFC must not change the mapped form either.
 6443|  3.19k|      if (!is_ascii(post_map) && !is_already_nfc(post_map)) {
  ------------------
  |  Branch (6443:11): [True: 3.19k, False: 0]
  |  Branch (6443:34): [True: 576, False: 2.61k]
  ------------------
 6444|    576|        if (!normalize(post_map) || post_map != working) {
  ------------------
  |  Branch (6444:13): [True: 0, False: 576]
  |  Branch (6444:37): [True: 396, False: 180]
  ------------------
 6445|    396|          out.clear();
 6446|    396|          return false;
 6447|    396|        }
 6448|    576|      }
 6449|  2.79k|      if (post_map.empty() || !is_label_valid(post_map)) {
  ------------------
  |  Branch (6449:11): [True: 0, False: 2.79k]
  |  Branch (6449:31): [True: 105, False: 2.69k]
  ------------------
 6450|    105|        out.clear();
 6451|    105|        return false;
 6452|    105|      }
 6453|  43.5k|    } else if (is_ascii(label_view)) {
  ------------------
  |  Branch (6453:16): [True: 4.76k, False: 38.7k]
  ------------------
 6454|  4.76k|      append_ascii_label(out, label_view);
 6455|  38.7k|    } else {
 6456|  38.7k|      if (!is_label_valid(label_view)) {
  ------------------
  |  Branch (6456:11): [True: 1.77k, False: 36.9k]
  ------------------
 6457|  1.77k|        out.clear();
 6458|  1.77k|        return false;
 6459|  1.77k|      }
 6460|  36.9k|      out.append("xn--");
 6461|  36.9k|      if (!ada::idna::utf32_to_punycode(label_view, out)) {
  ------------------
  |  Branch (6461:11): [True: 0, False: 36.9k]
  ------------------
 6462|      0|        out.clear();
 6463|      0|        return false;
 6464|      0|      }
 6465|  36.9k|    }
 6466|  47.4k|    if (!is_last_label) {
  ------------------
  |  Branch (6466:9): [True: 41.1k, False: 6.27k]
  ------------------
 6467|  41.1k|      out.push_back('.');
 6468|  41.1k|    }
 6469|  47.4k|  }
 6470|  6.78k|  return true;
 6471|  10.3k|}
_ZN3ada4idna8to_asciiENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 6473|  18.5k|std::string to_ascii(std::string_view ut8_string) {
 6474|  18.5k|  std::string out;
 6475|  18.5k|  if (!to_ascii(ut8_string, out)) {
  ------------------
  |  Branch (6475:7): [True: 4.63k, False: 13.9k]
  ------------------
 6476|  4.63k|    return {};
 6477|  4.63k|  }
 6478|  13.9k|  return out;
 6479|  18.5k|}
_ZN3ada7unicode14percent_decodeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEm:
 7165|  1.01k|std::string percent_decode(const std::string_view input, size_t first_percent) {
 7166|       |  // next line is for safety only, we expect users to avoid calling
 7167|       |  // percent_decode when first_percent is outside the range.
 7168|  1.01k|  if (first_percent == std::string_view::npos) {
  ------------------
  |  Branch (7168:7): [True: 0, False: 1.01k]
  ------------------
 7169|      0|    return std::string(input);
 7170|      0|  }
 7171|  1.01k|  std::string dest;
 7172|  1.01k|  dest.reserve(input.length());
 7173|  1.01k|  dest.append(input.substr(0, first_percent));
 7174|  1.01k|  const char* pointer = input.data() + first_percent;
 7175|  1.01k|  const char* end = input.data() + input.size();
 7176|       |  // Optimization opportunity: if the following code gets
 7177|       |  // called often, it can be optimized quite a bit.
 7178|  18.5k|  while (pointer < end) {
  ------------------
  |  Branch (7178:10): [True: 17.5k, False: 1.01k]
  ------------------
 7179|  17.5k|    const char ch = pointer[0];
 7180|  17.5k|    size_t remaining = end - pointer - 1;
 7181|  17.5k|    if (ch != '%' || remaining < 2 ||
  ------------------
  |  Branch (7181:9): [True: 11.5k, False: 6.00k]
  |  Branch (7181:22): [True: 258, False: 5.74k]
  ------------------
 7182|  5.74k|        (  // ch == '%' && // It is unnecessary to check that ch == '%'.
 7183|  5.74k|            (!is_ascii_hex_digit(pointer[1]) ||
  ------------------
  |  Branch (7183:14): [True: 2.30k, False: 3.44k]
  ------------------
 7184|  15.6k|             !is_ascii_hex_digit(pointer[2])))) {
  ------------------
  |  Branch (7184:14): [True: 1.56k, False: 1.87k]
  ------------------
 7185|  15.6k|      dest += ch;
 7186|  15.6k|      pointer++;
 7187|  15.6k|    } else {
 7188|  1.87k|      unsigned a = convert_hex_to_binary(pointer[1]);
 7189|  1.87k|      unsigned b = convert_hex_to_binary(pointer[2]);
 7190|  1.87k|      char c = static_cast<char>(a * 16 + b);
 7191|  1.87k|      dest += c;
 7192|  1.87k|      pointer += 3;
 7193|  1.87k|    }
 7194|  17.5k|  }
 7195|  1.01k|  return dest;
 7196|  1.01k|}
_ZN3ada7unicode14percent_encodeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKh:
 7281|  20.3k|                           const uint8_t character_set[]) {
 7282|  20.3k|  auto pointer = std::ranges::find_if(input, [character_set](const char c) {
 7283|  20.3k|    return character_sets::bit_at(character_set, c);
 7284|  20.3k|  });
 7285|       |  // Optimization: Don't iterate if percent encode is not required
 7286|  20.3k|  if (pointer == input.end()) {
  ------------------
  |  Branch (7286:7): [True: 17.2k, False: 3.07k]
  ------------------
 7287|  17.2k|    return std::string(input);
 7288|  17.2k|  }
 7289|       |
 7290|  3.07k|  std::string result;
 7291|  3.07k|  result.reserve(input.length());  // in the worst case, percent encoding might
 7292|       |                                   // produce 3 characters.
 7293|  3.07k|  result.append(input.substr(0, std::distance(input.begin(), pointer)));
 7294|       |
 7295|  56.7k|  for (; pointer != input.end(); pointer++) {
  ------------------
  |  Branch (7295:10): [True: 53.7k, False: 3.07k]
  ------------------
 7296|  53.7k|    if (character_sets::bit_at(character_set, *pointer)) {
  ------------------
  |  Branch (7296:9): [True: 48.1k, False: 5.53k]
  ------------------
 7297|  48.1k|      result.append(character_sets::hex + uint8_t(*pointer) * 4, 3);
 7298|  48.1k|    } else {
 7299|  5.53k|      result += *pointer;
 7300|  5.53k|    }
 7301|  53.7k|  }
 7302|       |
 7303|  3.07k|  return result;
 7304|  20.3k|}
_ZN3ada7unicode8to_asciiERNSt3__18optionalINS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEENS1_17basic_string_viewIcS5_EEm:
 7342|  18.5k|              size_t first_percent) {
 7343|  18.5k|  std::string percent_decoded_buffer;
 7344|  18.5k|  std::string_view input = plain;
 7345|  18.5k|  if (first_percent != std::string_view::npos) {
  ------------------
  |  Branch (7345:7): [True: 1.01k, False: 17.5k]
  ------------------
 7346|  1.01k|    percent_decoded_buffer = unicode::percent_decode(plain, first_percent);
 7347|  1.01k|    input = percent_decoded_buffer;
 7348|  1.01k|  }
 7349|       |  // input is a non-empty UTF-8 string, must be percent decoded
 7350|  18.5k|  std::string idna_ascii = ada::idna::to_ascii(input);
 7351|  18.5k|  if (idna_ascii.empty() || contains_forbidden_domain_code_point(
  ------------------
  |  Branch (7351:7): [True: 4.69k, False: 13.8k]
  |  Branch (7351:29): [True: 1.42k, False: 12.4k]
  ------------------
 7352|  13.8k|                                idna_ascii.data(), idna_ascii.size())) {
 7353|  6.12k|    return false;
 7354|  6.12k|  }
 7355|  12.4k|  out = std::move(idna_ascii);
 7356|  12.4k|  return true;
 7357|  18.5k|}
_ZN3ada7unicode14percent_encodeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKhm:
 7360|    312|                           const uint8_t character_set[], size_t index) {
 7361|    312|  std::string out;
 7362|       |  // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
 7363|    312|  out.append(input.data(), index);
 7364|    312|  auto pointer = input.begin() + index;
 7365|  7.68k|  for (; pointer != input.end(); pointer++) {
  ------------------
  |  Branch (7365:10): [True: 7.37k, False: 312]
  ------------------
 7366|  7.37k|    if (character_sets::bit_at(character_set, *pointer)) {
  ------------------
  |  Branch (7366:9): [True: 6.44k, False: 926]
  ------------------
 7367|  6.44k|      out.append(character_sets::hex + uint8_t(*pointer) * 4, 3);
 7368|  6.44k|    } else {
 7369|    926|      out += *pointer;
 7370|    926|    }
 7371|  7.37k|  }
 7372|    312|  return out;
 7373|    312|}
_ZN3ada11serializers36find_longest_sequence_of_ipv6_piecesERKNSt3__15arrayItLm8EEERmS6_:
 7437|  1.03k|    size_t& compress_length) noexcept {
 7438|  1.03k|  compress = 0;
 7439|  1.03k|  compress_length = 0;
 7440|  1.03k|  size_t i = 0;
 7441|  4.23k|  while (i < 8) {
  ------------------
  |  Branch (7441:10): [True: 3.19k, False: 1.03k]
  ------------------
 7442|  3.19k|    if (address[i] != 0) {
  ------------------
  |  Branch (7442:9): [True: 1.99k, False: 1.19k]
  ------------------
 7443|  1.99k|      ++i;
 7444|  1.99k|      continue;
 7445|  1.99k|    }
 7446|  1.19k|    size_t next = i + 1;
 7447|  6.30k|    while (next < 8 && address[next] == 0) {
  ------------------
  |  Branch (7447:12): [True: 5.71k, False: 591]
  |  Branch (7447:24): [True: 5.11k, False: 606]
  ------------------
 7448|  5.11k|      ++next;
 7449|  5.11k|    }
 7450|  1.19k|    const size_t count = next - i;
 7451|  1.19k|    if (count > compress_length) {
  ------------------
  |  Branch (7451:9): [True: 1.05k, False: 147]
  ------------------
 7452|  1.05k|      compress_length = count;
 7453|  1.05k|      compress = i;
 7454|  1.05k|    }
 7455|  1.19k|    i = next;
 7456|  1.19k|  }
 7457|  1.03k|}
_ZN3ada11serializers4ipv6ERKNSt3__15arrayItLm8EEE:
 7459|  1.03k|std::string ipv6(const std::array<uint16_t, 8>& address) {
 7460|  1.03k|  size_t compress = 0;
 7461|  1.03k|  size_t compress_length = 0;
 7462|  1.03k|  find_longest_sequence_of_ipv6_pieces(address, compress, compress_length);
 7463|       |
 7464|       |  // Skip compression when the longest zero run is a single piece.
 7465|  1.03k|  if (compress_length <= 1) {
  ------------------
  |  Branch (7465:7): [True: 96, False: 942]
  ------------------
 7466|     96|    compress = compress_length = 8;
 7467|     96|  }
 7468|       |
 7469|       |  // Max: '[' + 8*4 hex + 7 ':' + ']' = 41
 7470|  1.03k|  std::string output(4 * 8 + 7 + 2, '\0');
 7471|  1.03k|  char* point = output.data();
 7472|  1.03k|  *point++ = '[';
 7473|  1.03k|  size_t piece_index = 0;
 7474|  2.80k|  while (true) {
  ------------------
  |  Branch (7474:10): [True: 2.80k, Folded]
  ------------------
 7475|  2.80k|    if (piece_index == compress) {
  ------------------
  |  Branch (7475:9): [True: 942, False: 1.86k]
  ------------------
 7476|    942|      *point++ = ':';
 7477|       |      // If we skip a value initially, we need to write '::'.
 7478|    942|      if (piece_index == 0) {
  ------------------
  |  Branch (7478:11): [True: 579, False: 363]
  ------------------
 7479|    579|        *point++ = ':';
 7480|    579|      }
 7481|    942|      piece_index += compress_length;
 7482|    942|      if (piece_index == 8) {
  ------------------
  |  Branch (7482:11): [True: 522, False: 420]
  ------------------
 7483|    522|        break;
 7484|    522|      }
 7485|    942|    }
 7486|  2.28k|    point = write_hex_u16(point, address[piece_index]);
 7487|  2.28k|    ++piece_index;
 7488|  2.28k|    if (piece_index == 8) {
  ------------------
  |  Branch (7488:9): [True: 516, False: 1.76k]
  ------------------
 7489|    516|      break;
 7490|    516|    }
 7491|  1.76k|    *point++ = ':';
 7492|  1.76k|  }
 7493|  1.03k|  *point++ = ']';
 7494|  1.03k|  output.resize(static_cast<size_t>(point - output.data()));
 7495|  1.03k|  return output;
 7496|  1.03k|}
_ZN3ada11serializers4ipv4Em:
 7498|  3.08k|std::string ipv4(const uint64_t address) {
 7499|  3.08k|  std::string output(15, '\0');
 7500|  3.08k|  char* point = output.data();
 7501|  3.08k|  point = write_u8(point, static_cast<uint8_t>(address >> 24));
 7502|  3.08k|  *point++ = '.';
 7503|  3.08k|  point = write_u8(point, static_cast<uint8_t>(address >> 16));
 7504|  3.08k|  *point++ = '.';
 7505|  3.08k|  point = write_u8(point, static_cast<uint8_t>(address >> 8));
 7506|  3.08k|  *point++ = '.';
 7507|  3.08k|  point = write_u8(point, static_cast<uint8_t>(address));
 7508|  3.08k|  output.resize(static_cast<size_t>(point - output.data()));
 7509|  3.08k|  return output;
 7510|  3.08k|}
_ZN3ada5parseINS_3urlEEEN2tl8expectedIT_NS_6errorsEEENSt3__117basic_string_viewIcNS7_11char_traitsIcEEEEPKS4_:
 7782|  34.6k|    std::string_view input, const result_type* base_url) {
 7783|  34.6k|  result_type u = ada::parser::parse_url_impl<result_type>(input, base_url);
 7784|  34.6k|  if (!u.is_valid) {
  ------------------
  |  Branch (7784:7): [True: 19.0k, False: 15.6k]
  ------------------
 7785|  19.0k|    return tl::unexpected(errors::type_error);
 7786|  19.0k|  }
 7787|  15.6k|  return u;
 7788|  34.6k|}
_ZN3ada5parseINS_14url_aggregatorEEEN2tl8expectedIT_NS_6errorsEEENSt3__117basic_string_viewIcNS7_11char_traitsIcEEEEPKS4_:
 7782|  34.6k|    std::string_view input, const result_type* base_url) {
 7783|  34.6k|  result_type u = ada::parser::parse_url_impl<result_type>(input, base_url);
 7784|  34.6k|  if (!u.is_valid) {
  ------------------
  |  Branch (7784:7): [True: 19.0k, False: 15.6k]
  ------------------
 7785|  19.0k|    return tl::unexpected(errors::type_error);
 7786|  19.0k|  }
 7787|  15.6k|  return u;
 7788|  34.6k|}
_ZN3ada20get_max_input_lengthEv:
 7531|   114k|uint32_t get_max_input_length() {
 7532|   114k|  return max_input_length_.load(std::memory_order_relaxed);
 7533|   114k|}
_ZN3ada9can_parseENSt3__117basic_string_viewIcNS0_11char_traitsIcEEEEPKS4_:
 7818|  31.5k|bool can_parse(std::string_view input, const std::string_view* base_input) {
 7819|       |  // Must match parse().has_value(), including post-normalization max length.
 7820|       |  // Percent-encoding expands a byte by at most 3x. When the input (plus base,
 7821|       |  // if any) fits in max_length/3, the normalized href cannot exceed
 7822|       |  // max_length, so validation-only parsing (store_values=false) is safe.
 7823|       |
 7824|       |  // Hot path first: absolute special URLs, no base. Avoid loading max_length
 7825|       |  // until we need it (common absolute-fast true/false cases).
 7826|  31.5k|  if (base_input == nullptr) {
  ------------------
  |  Branch (7826:7): [True: 22.7k, False: 8.82k]
  ------------------
 7827|  22.7k|    if (const auto r = try_can_parse_absolute_fast(input)) {
  ------------------
  |  Branch (7827:20): [True: 11.2k, False: 11.5k]
  ------------------
 7828|  11.2k|      if (!*r) {
  ------------------
  |  Branch (7828:11): [True: 9.91k, False: 1.30k]
  ------------------
 7829|  9.91k|        return false;
 7830|  9.91k|      }
 7831|       |      // size <= max/3 => normalized href cannot exceed max (3x expansion).
 7832|       |      // Check this first: default max is ~4GB so almost all URLs return true.
 7833|  1.30k|      const uint32_t max_length = ada::get_max_input_length();
 7834|  1.30k|      if (input.size() <= static_cast<size_t>(max_length) / 3) {
  ------------------
  |  Branch (7834:11): [True: 1.30k, False: 0]
  ------------------
 7835|  1.30k|        return true;
 7836|  1.30k|      }
 7837|      0|      if (input.size() > max_length) {
  ------------------
  |  Branch (7837:11): [True: 0, False: 0]
  ------------------
 7838|      0|        return false;
 7839|      0|      }
 7840|      0|      return ada::parser::parse_url_impl<ada::url_aggregator, true>(input,
 7841|      0|                                                                    nullptr)
 7842|      0|          .is_valid;
 7843|      0|    }
 7844|  22.7k|  }
 7845|       |
 7846|  20.3k|  const uint32_t max_length = ada::get_max_input_length();
 7847|  20.3k|  if (input.size() > max_length) {
  ------------------
  |  Branch (7847:7): [True: 0, False: 20.3k]
  ------------------
 7848|      0|    return false;
 7849|      0|  }
 7850|  20.3k|  if (base_input != nullptr && base_input->size() > max_length) {
  ------------------
  |  Branch (7850:7): [True: 8.82k, False: 11.5k]
  |  Branch (7850:32): [True: 0, False: 8.82k]
  ------------------
 7851|      0|    return false;
 7852|      0|  }
 7853|       |
 7854|       |  // Relative resolution combines base + input; bound the sum so 3x expansion
 7855|       |  // of either side cannot push the final href past max_length.
 7856|  20.3k|  const size_t combined =
 7857|  20.3k|      input.size() + (base_input == nullptr ? 0 : base_input->size());
  ------------------
  |  Branch (7857:23): [True: 11.5k, False: 8.82k]
  ------------------
 7858|  20.3k|  const bool size_safe = combined <= static_cast<size_t>(max_length) / 3;
 7859|       |
 7860|  20.3k|  if (size_safe) {
  ------------------
  |  Branch (7860:7): [True: 20.3k, False: 0]
  ------------------
 7861|       |    // Validation-only: no buffer build, host still fully checked.
 7862|  20.3k|    ada::url_aggregator base_agg;
 7863|  20.3k|    ada::url_aggregator* base_ptr = nullptr;
 7864|  20.3k|    if (base_input != nullptr) {
  ------------------
  |  Branch (7864:9): [True: 8.82k, False: 11.5k]
  ------------------
 7865|  8.82k|      base_agg = ada::parser::parse_url_impl<ada::url_aggregator, false>(
 7866|  8.82k|          *base_input, nullptr);
 7867|  8.82k|      if (!base_agg.is_valid) {
  ------------------
  |  Branch (7867:11): [True: 5.77k, False: 3.04k]
  ------------------
 7868|  5.77k|        return false;
 7869|  5.77k|      }
 7870|  3.04k|      base_ptr = &base_agg;
 7871|  3.04k|    }
 7872|  14.5k|    return ada::parser::parse_url_impl<ada::url_aggregator, false>(input,
 7873|  14.5k|                                                                   base_ptr)
 7874|  14.5k|        .is_valid;
 7875|  20.3k|  }
 7876|       |
 7877|       |  // Near the limit: full parse so post-normalization length matches parse().
 7878|      0|  if (base_input == nullptr) {
  ------------------
  |  Branch (7878:7): [True: 0, False: 0]
  ------------------
 7879|      0|    return ada::parser::parse_url_impl<ada::url_aggregator, true>(input,
 7880|      0|                                                                  nullptr)
 7881|      0|        .is_valid;
 7882|      0|  }
 7883|      0|  ada::url_aggregator base_agg =
 7884|      0|      ada::parser::parse_url_impl<ada::url_aggregator, true>(*base_input,
 7885|      0|                                                             nullptr);
 7886|      0|  if (!base_agg.is_valid) {
  ------------------
  |  Branch (7886:7): [True: 0, False: 0]
  ------------------
 7887|      0|    return false;
 7888|      0|  }
 7889|      0|  return ada::parser::parse_url_impl<ada::url_aggregator, true>(input,
 7890|      0|                                                                &base_agg)
 7891|      0|      .is_valid;
 7892|      0|}
_ZN3ada7helpers18trim_c0_whitespaceERNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8724|  91.6k|void trim_c0_whitespace(std::string_view& input) noexcept {
 8725|  93.8k|  while (!input.empty() &&
  ------------------
  |  Branch (8725:10): [True: 57.9k, False: 35.8k]
  ------------------
 8726|  57.9k|         ada::unicode::is_c0_control_or_space(input.front())) {
  ------------------
  |  Branch (8726:10): [True: 2.21k, False: 55.7k]
  ------------------
 8727|  2.21k|    input.remove_prefix(1);
 8728|  2.21k|  }
 8729|  94.8k|  while (!input.empty() && ada::unicode::is_c0_control_or_space(input.back())) {
  ------------------
  |  Branch (8729:10): [True: 58.9k, False: 35.8k]
  |  Branch (8729:28): [True: 3.16k, False: 55.7k]
  ------------------
 8730|  3.16k|    input.remove_suffix(1);
 8731|  3.16k|  }
 8732|  91.6k|}
_ZN3ada3url17parse_opaque_hostENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9179|    411|bool url::parse_opaque_host(std::string_view input) {
 9180|    411|  ada_log("parse_opaque_host ", input, " [", input.size(), " bytes]");
 9181|    411|  if (std::ranges::any_of(input, ada::unicode::is_forbidden_host_code_point)) {
  ------------------
  |  Branch (9181:7): [True: 9, False: 402]
  ------------------
 9182|      9|    return is_valid = false;
 9183|      9|  }
 9184|       |
 9185|       |  // Return the result of running UTF-8 percent-encode on input using the C0
 9186|       |  // control percent-encode set.
 9187|    402|  host = ada::unicode::percent_encode(
 9188|    402|      input, ada::character_sets::C0_CONTROL_PERCENT_ENCODE);
 9189|    402|  return true;
 9190|    411|}
_ZN3ada3url10parse_ipv4ENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9192|  1.28k|bool url::parse_ipv4(std::string_view input) {
 9193|  1.28k|  ada_log("parse_ipv4 ", input, " [", input.size(), " bytes]");
 9194|  1.28k|  if (input.empty()) {
  ------------------
  |  Branch (9194:7): [True: 0, False: 1.28k]
  ------------------
 9195|      0|    return is_valid = false;
 9196|      0|  }
 9197|  1.28k|  std::string_view original_input = input;
 9198|  1.28k|  if (original_input.back() == '.') {
  ------------------
  |  Branch (9198:7): [True: 32, False: 1.25k]
  ------------------
 9199|     32|    original_input.remove_suffix(1);
 9200|     32|  }
 9201|  1.28k|  if (input.back() == '.') {
  ------------------
  |  Branch (9201:7): [True: 32, False: 1.25k]
  ------------------
 9202|     32|    input.remove_suffix(1);
 9203|     32|    if (input.empty()) {
  ------------------
  |  Branch (9203:9): [True: 0, False: 32]
  ------------------
 9204|      0|      return is_valid = false;
 9205|      0|    }
 9206|     32|  }
 9207|       |
 9208|  1.28k|  const uint64_t fast = checkers::try_parse_ipv4_fast(input);
 9209|  1.28k|  if (fast < checkers::ipv4_fast_fail) [[likely]] {
  ------------------
  |  Branch (9209:7): [True: 9, False: 1.27k]
  ------------------
 9210|      9|    host = original_input;
 9211|      9|    host_type = IPV4;
 9212|      9|    return true;
 9213|      9|  }
 9214|       |
 9215|  1.27k|  const char* p = input.data();
 9216|  1.27k|  const char* end = p + input.size();
 9217|  1.27k|  uint64_t ipv4 = 0;
 9218|  1.27k|  int digit_count = 0;
 9219|  1.27k|  int pure_decimal_count = 0;
 9220|       |
 9221|  1.72k|  for (; digit_count < 4 && p < end; ++digit_count) {
  ------------------
  |  Branch (9221:10): [True: 1.71k, False: 13]
  |  Branch (9221:29): [True: 1.71k, False: 0]
  ------------------
 9222|  1.71k|    uint64_t segment = 0;
 9223|  1.71k|    bool pure = false;
 9224|  1.71k|    if (!detail::parse_ipv4_number(p, end, segment, pure)) {
  ------------------
  |  Branch (9224:9): [True: 179, False: 1.53k]
  ------------------
 9225|    179|      return is_valid = false;
 9226|    179|    }
 9227|  1.53k|    if (pure) {
  ------------------
  |  Branch (9227:9): [True: 1.10k, False: 434]
  ------------------
 9228|  1.10k|      ++pure_decimal_count;
 9229|  1.10k|    }
 9230|  1.53k|    if (p >= end) {
  ------------------
  |  Branch (9230:9): [True: 1.05k, False: 481]
  ------------------
 9231|  1.05k|      const unsigned shift = static_cast<unsigned>(32 - digit_count * 8);
 9232|  1.05k|      if (segment >= (uint64_t{1} << shift)) {
  ------------------
  |  Branch (9232:11): [True: 26, False: 1.02k]
  ------------------
 9233|     26|        return is_valid = false;
 9234|     26|      }
 9235|  1.02k|      ipv4 = (ipv4 << shift) | segment;
 9236|  1.02k|      host = (pure_decimal_count == 4) ? std::string(original_input)
  ------------------
  |  Branch (9236:14): [True: 0, False: 1.02k]
  ------------------
 9237|  1.02k|                                       : ada::serializers::ipv4(ipv4);
 9238|  1.02k|      host_type = IPV4;
 9239|  1.02k|      return true;
 9240|  1.05k|    }
 9241|    481|    if (segment > 255 || *p != '.') {
  ------------------
  |  Branch (9241:9): [True: 30, False: 451]
  |  Branch (9241:26): [True: 0, False: 451]
  ------------------
 9242|     30|      return is_valid = false;
 9243|     30|    }
 9244|    451|    ipv4 = (ipv4 << 8) | segment;
 9245|    451|    ++p;
 9246|    451|  }
 9247|     13|  if (digit_count != 4 || p != end) {
  ------------------
  |  Branch (9247:7): [True: 0, False: 13]
  |  Branch (9247:27): [True: 13, False: 0]
  ------------------
 9248|     13|    return is_valid = false;
 9249|     13|  }
 9250|      0|  host = (pure_decimal_count == 4) ? std::string(original_input)
  ------------------
  |  Branch (9250:10): [True: 0, False: 0]
  ------------------
 9251|      0|                                   : ada::serializers::ipv4(ipv4);
 9252|      0|  host_type = IPV4;
 9253|      0|  return true;
 9254|     13|}
_ZN3ada3url10parse_ipv6ENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9256|    573|bool url::parse_ipv6(std::string_view input) {
 9257|    573|  ada_log("parse_ipv6 ", input, " [", input.size(), " bytes]");
 9258|    573|  if (input.empty() || input.size() > 45) [[unlikely]] {
  ------------------
  |  Branch (9258:7): [True: 16, False: 557]
  |  Branch (9258:24): [True: 17, False: 540]
  ------------------
 9259|     33|    return is_valid = false;
 9260|     33|  }
 9261|       |#if defined(ADA_AVX512)
 9262|       |  // One masked load classifies colon/dot shape; rejects impossible inputs
 9263|       |  // before the piece parser (free on AVX-512BW+VL builds).
 9264|       |  if (!detail::ipv6_structure_plausible(input.data(), input.size()))
 9265|       |      [[unlikely]] {
 9266|       |    return is_valid = false;
 9267|       |  }
 9268|       |#endif
 9269|       |
 9270|    540|  std::array<uint16_t, 8> address{};
 9271|    540|  const char* pointer = input.data();
 9272|    540|  const char* const end = pointer + input.size();
 9273|    540|  int piece_index = 0;
 9274|    540|  int compress = -1;
 9275|       |
 9276|    540|  if (*pointer == ':') {
  ------------------
  |  Branch (9276:7): [True: 203, False: 337]
  ------------------
 9277|    203|    if (input.size() == 1 || pointer[1] != ':') [[unlikely]] {
  ------------------
  |  Branch (9277:9): [True: 3, False: 200]
  |  Branch (9277:30): [True: 9, False: 191]
  ------------------
 9278|     12|      return is_valid = false;
 9279|     12|    }
 9280|    191|    pointer += 2;
 9281|    191|    compress = ++piece_index;
 9282|    191|  }
 9283|       |
 9284|  1.48k|  while (pointer != end) {
  ------------------
  |  Branch (9284:10): [True: 1.13k, False: 356]
  ------------------
 9285|  1.13k|    if (piece_index == 8) [[unlikely]] {
  ------------------
  |  Branch (9285:9): [True: 3, False: 1.13k]
  ------------------
 9286|      3|      return is_valid = false;
 9287|      3|    }
 9288|  1.13k|    if (*pointer == ':') {
  ------------------
  |  Branch (9288:9): [True: 150, False: 980]
  ------------------
 9289|    150|      if (compress != -1) [[unlikely]] {
  ------------------
  |  Branch (9289:11): [True: 3, False: 147]
  ------------------
 9290|      3|        return is_valid = false;
 9291|      3|      }
 9292|    147|      ++pointer;
 9293|    147|      compress = ++piece_index;
 9294|    147|      continue;
 9295|    150|    }
 9296|       |
 9297|    980|    uint16_t value = 0;
 9298|    980|    const int length = detail::parse_hex_piece(pointer, end, value);
 9299|       |
 9300|    980|    if (pointer != end && *pointer == '.') {
  ------------------
  |  Branch (9300:9): [True: 792, False: 188]
  |  Branch (9300:27): [True: 101, False: 691]
  ------------------
 9301|    101|      if (length == 0) [[unlikely]] {
  ------------------
  |  Branch (9301:11): [True: 4, False: 97]
  ------------------
 9302|      4|        return is_valid = false;
 9303|      4|      }
 9304|     97|      pointer -= length;
 9305|     97|      if (piece_index > 6) [[unlikely]] {
  ------------------
  |  Branch (9305:11): [True: 3, False: 94]
  ------------------
 9306|      3|        return is_valid = false;
 9307|      3|      }
 9308|       |
 9309|     94|      int numbers_seen = 0;
 9310|    272|      while (pointer != end) {
  ------------------
  |  Branch (9310:14): [True: 245, False: 27]
  ------------------
 9311|    245|        int ipv4_piece = -1;
 9312|    245|        if (numbers_seen > 0) {
  ------------------
  |  Branch (9312:13): [True: 151, False: 94]
  ------------------
 9313|    151|          if (*pointer == '.' && numbers_seen < 4) {
  ------------------
  |  Branch (9313:15): [True: 130, False: 21]
  |  Branch (9313:34): [True: 125, False: 5]
  ------------------
 9314|    125|            ++pointer;
 9315|    125|          } else {
 9316|     26|            return is_valid = false;
 9317|     26|          }
 9318|    151|        }
 9319|    219|        if (pointer == end || *pointer < '0' || *pointer > '9') [[unlikely]] {
  ------------------
  |  Branch (9319:13): [True: 20, False: 199]
  |  Branch (9319:31): [True: 6, False: 193]
  |  Branch (9319:49): [True: 6, False: 187]
  ------------------
 9320|     32|          return is_valid = false;
 9321|     32|        }
 9322|    187|        ipv4_piece = *pointer - '0';
 9323|    187|        ++pointer;
 9324|    187|        if (pointer != end && *pointer >= '0' && *pointer <= '9') {
  ------------------
  |  Branch (9324:13): [True: 169, False: 18]
  |  Branch (9324:31): [True: 69, False: 100]
  |  Branch (9324:50): [True: 66, False: 3]
  ------------------
 9325|     66|          if (ipv4_piece == 0) [[unlikely]] {
  ------------------
  |  Branch (9325:15): [True: 3, False: 63]
  ------------------
 9326|      3|            return is_valid = false;
 9327|      3|          }
 9328|     63|          ipv4_piece = ipv4_piece * 10 + (*pointer - '0');
 9329|     63|          ++pointer;
 9330|     63|          if (pointer != end && *pointer >= '0' && *pointer <= '9') {
  ------------------
  |  Branch (9330:15): [True: 60, False: 3]
  |  Branch (9330:33): [True: 31, False: 29]
  |  Branch (9330:52): [True: 28, False: 3]
  ------------------
 9331|     28|            ipv4_piece = ipv4_piece * 10 + (*pointer - '0');
 9332|     28|            ++pointer;
 9333|     28|            if (ipv4_piece > 255) [[unlikely]] {
  ------------------
  |  Branch (9333:17): [True: 6, False: 22]
  ------------------
 9334|      6|              return is_valid = false;
 9335|      6|            }
 9336|     28|          }
 9337|     63|        }
 9338|    178|        address[static_cast<size_t>(piece_index)] = static_cast<uint16_t>(
 9339|    178|            address[static_cast<size_t>(piece_index)] * 0x100 +
 9340|    178|            static_cast<uint16_t>(ipv4_piece));
 9341|    178|        ++numbers_seen;
 9342|    178|        if (numbers_seen == 2 || numbers_seen == 4) {
  ------------------
  |  Branch (9342:13): [True: 54, False: 124]
  |  Branch (9342:34): [True: 17, False: 107]
  ------------------
 9343|     71|          ++piece_index;
 9344|     71|        }
 9345|    178|      }
 9346|     27|      if (numbers_seen != 4) [[unlikely]] {
  ------------------
  |  Branch (9346:11): [True: 16, False: 11]
  ------------------
 9347|     16|        return is_valid = false;
 9348|     16|      }
 9349|     11|      break;
 9350|     27|    }
 9351|       |
 9352|    879|    if (length == 0) [[unlikely]] {
  ------------------
  |  Branch (9352:9): [True: 50, False: 829]
  ------------------
 9353|     50|      return is_valid = false;
 9354|     50|    }
 9355|       |
 9356|    829|    if (pointer != end && *pointer == ':') {
  ------------------
  |  Branch (9356:9): [True: 641, False: 188]
  |  Branch (9356:27): [True: 630, False: 11]
  ------------------
 9357|    630|      ++pointer;
 9358|    630|      if (pointer == end) [[unlikely]] {
  ------------------
  |  Branch (9358:11): [True: 4, False: 626]
  ------------------
 9359|      4|        return is_valid = false;
 9360|      4|      }
 9361|    630|    } else if (pointer != end) [[unlikely]] {
  ------------------
  |  Branch (9361:16): [True: 11, False: 188]
  ------------------
 9362|     11|      return is_valid = false;
 9363|     11|    }
 9364|       |
 9365|    814|    address[static_cast<size_t>(piece_index)] = value;
 9366|    814|    ++piece_index;
 9367|    814|  }
 9368|       |
 9369|    367|  if (compress != -1) {
  ------------------
  |  Branch (9369:7): [True: 328, False: 39]
  ------------------
 9370|    328|    const int right = piece_index - compress;
 9371|    328|    if (right > 0) {
  ------------------
  |  Branch (9371:9): [True: 160, False: 168]
  ------------------
 9372|    160|      const size_t dest = static_cast<size_t>(8 - right);
 9373|    160|      const size_t src = static_cast<size_t>(compress);
 9374|    160|      if (dest != src) {
  ------------------
  |  Branch (9374:11): [True: 146, False: 14]
  ------------------
 9375|    430|        for (size_t i = static_cast<size_t>(right); i-- > 0;) {
  ------------------
  |  Branch (9375:53): [True: 284, False: 146]
  ------------------
 9376|    284|          address[dest + i] = address[src + i];
 9377|    284|          address[src + i] = 0;
 9378|    284|        }
 9379|    146|      }
 9380|    160|    }
 9381|    328|  } else if (piece_index != 8) [[unlikely]] {
  ------------------
  |  Branch (9381:14): [True: 21, False: 18]
  ------------------
 9382|     21|    return is_valid = false;
 9383|     21|  }
 9384|       |
 9385|    346|  host = ada::serializers::ipv6(address);
 9386|    346|  ada_log("parse_ipv6 ", *host);
 9387|    346|  host_type = IPV6;
 9388|    346|  return true;
 9389|    367|}
_ZN3ada6parser14parse_url_implINS_3urlELb1EEET_NSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEPKS3_:
10361|  34.6k|                           const result_type* base_url) {
10362|       |  // We can specialize the implementation per type.
10363|       |  // Important: result_type_is_ada_url is evaluated at *compile time*. This
10364|       |  // means that doing if constexpr(result_type_is_ada_url) { something } else {
10365|       |  // something else } is free (at runtime). This means that ada::url_aggregator
10366|       |  // and ada::url **do not have to support the exact same API**.
10367|  34.6k|  constexpr bool result_type_is_ada_url = std::is_same_v<url, result_type>;
10368|  34.6k|  constexpr bool result_type_is_ada_url_aggregator =
10369|  34.6k|      std::is_same_v<url_aggregator, result_type>;
10370|  34.6k|  static_assert(result_type_is_ada_url ||
10371|  34.6k|                result_type_is_ada_url_aggregator);  // We don't support
10372|       |                                                     // anything else for now.
10373|       |
10374|  34.6k|  ada_log("ada::parser::parse_url('", user_input, "' [", user_input.size(),
10375|  34.6k|          " bytes],", (base_url != nullptr ? base_url->to_string() : "null"),
10376|  34.6k|          ")");
10377|       |
10378|  34.6k|  state state = state::SCHEME_START;
10379|  34.6k|  result_type url{};
10380|       |
10381|  34.6k|  const uint32_t max_input_length = ada::get_max_input_length();
10382|       |
10383|       |  // We refuse to parse URL strings that exceed the maximum input length.
10384|       |  // By default, this is 4GB but can be configured via
10385|       |  // ada::set_max_input_length().
10386|  34.6k|  if (user_input.size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (10386:7): [True: 0, False: 34.6k]
  ------------------
10387|      0|    url.is_valid = false;
10388|      0|  }
10389|       |  // Going forward, user_input.size() is in [0,
10390|       |  // std::numeric_limits<uint32_t>::max). If we are provided with an invalid
10391|       |  // base, or the optional_url was invalid, we must return.
10392|  34.6k|  if (base_url != nullptr) {
  ------------------
  |  Branch (10392:7): [True: 3.04k, False: 31.5k]
  ------------------
10393|  3.04k|    url.is_valid &= base_url->is_valid;
10394|  3.04k|  }
10395|  34.6k|  if (!url.is_valid) {
  ------------------
  |  Branch (10395:7): [True: 0, False: 34.6k]
  ------------------
10396|      0|    return url;
10397|      0|  }
10398|       |
10399|       |  // Simple absolute http(s) fast path (before tabs/newline scan).
10400|       |  // Skip digit-led hosts (IPv4) with a cheap peek.
10401|  34.6k|  if constexpr (store_values) {
10402|  34.6k|    if (base_url == nullptr) {
  ------------------
  |  Branch (10402:9): [True: 31.5k, False: 3.04k]
  ------------------
10403|  31.5k|      const auto* p = reinterpret_cast<const uint8_t*>(user_input.data());
10404|  31.5k|      const size_t n = user_input.size();
10405|  31.5k|      const bool digit_led_host = (n >= 8 && p[4] == ':' && p[5] == '/' &&
  ------------------
  |  Branch (10405:36): [True: 11.3k, False: 20.1k]
  |  Branch (10405:46): [True: 2.82k, False: 8.57k]
  |  Branch (10405:61): [True: 2.14k, False: 681]
  ------------------
10406|  2.14k|                                   p[6] == '/' && p[7] >= '0' && p[7] <= '9') ||
  ------------------
  |  Branch (10406:36): [True: 2.09k, False: 49]
  |  Branch (10406:51): [True: 1.45k, False: 635]
  |  Branch (10406:66): [True: 495, False: 964]
  ------------------
10407|  31.0k|                                  (n >= 9 && p[5] == ':' && p[6] == '/' &&
  ------------------
  |  Branch (10407:36): [True: 9.92k, False: 21.1k]
  |  Branch (10407:46): [True: 416, False: 9.51k]
  |  Branch (10407:61): [True: 177, False: 239]
  ------------------
10408|    177|                                   p[7] == '/' && p[8] >= '0' && p[8] <= '9');
  ------------------
  |  Branch (10408:36): [True: 148, False: 29]
  |  Branch (10408:51): [True: 101, False: 47]
  |  Branch (10408:66): [True: 6, False: 95]
  ------------------
10409|  31.5k|      if (!digit_led_host && try_parse_simple_absolute(user_input, url)) {
  ------------------
  |  Branch (10409:11): [True: 31.0k, False: 501]
  |  Branch (10409:30): [True: 508, False: 30.5k]
  ------------------
10410|       |        if constexpr (result_type_is_ada_url_aggregator) {
10411|       |          if (url.buffer.size() > max_input_length) [[unlikely]] {
10412|       |            url.is_valid = false;
10413|       |          }
10414|    508|        } else {
10415|    508|          if (url.get_href_size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (10415:15): [True: 0, False: 508]
  ------------------
10416|      0|            url.is_valid = false;
10417|      0|          }
10418|    508|        }
10419|    508|        return url;
10420|    508|      }
10421|  31.5k|    }
10422|  34.6k|  }
10423|       |
10424|  34.1k|  std::string tmp_buffer;
10425|  34.6k|  std::string_view url_data;
10426|  34.6k|  if (unicode::has_tabs_or_newline(user_input)) [[unlikely]] {
  ------------------
  |  Branch (10426:7): [True: 303, False: 34.3k]
  ------------------
10427|    303|    tmp_buffer = user_input;
10428|       |    // Optimization opportunity: Instead of copying and then pruning, we could
10429|       |    // just directly build the string from user_input.
10430|    303|    helpers::remove_ascii_tab_or_newline(tmp_buffer);
10431|    303|    url_data = tmp_buffer;
10432|  34.3k|  } else [[likely]] {
10433|  34.3k|    url_data = user_input;
10434|  34.3k|  }
10435|       |
10436|       |  // Leading and trailing control characters are uncommon and easy to deal with
10437|       |  // (no performance concern).
10438|  34.6k|  helpers::trim_c0_whitespace(url_data);
10439|       |
10440|       |  if constexpr (result_type_is_ada_url_aggregator && store_values) {
10441|       |    // Most of the time, we just need user_input.size().
10442|       |    // In some instances, we may need a bit more.
10443|       |    ///////////////////////////
10444|       |    // This is *very* important. This line should *not* be removed
10445|       |    // hastily. There are principled reasons why reserve is important
10446|       |    // for performance. If you have a benchmark with small inputs,
10447|       |    // it may not matter, but in other instances, it could.
10448|       |    ////
10449|       |    // This rounds up to the next power of two.
10450|       |    // We know that user_input.size() is in [0,
10451|       |    // std::numeric_limits<uint32_t>::max).
10452|       |    uint32_t reserve_capacity =
10453|       |        (0xFFFFFFFF >>
10454|       |         helpers::leading_zeroes(uint32_t(1 | user_input.size()))) +
10455|       |        1;
10456|       |    url.reserve(reserve_capacity);
10457|       |  }
10458|       |
10459|       |  // Optimization opportunity. Most websites do not have fragment.
10460|  34.6k|  std::optional<std::string_view> fragment = helpers::prune_hash(url_data);
10461|       |  // We add it last so that an implementation like ada::url_aggregator
10462|       |  // can append it last to its internal buffer, thus improving performance.
10463|       |
10464|       |  // Here url_data no longer has its fragment.
10465|       |  // We are going to access the data from url_data (it is immutable).
10466|       |  // At any given time, we are pointing at byte 'input_position' in url_data.
10467|       |  // The input_position variable should range from 0 to input_size.
10468|       |  // It is illegal to access url_data at input_size.
10469|  34.6k|  size_t input_position = 0;
10470|  34.6k|  const size_t input_size = url_data.size();
10471|       |  // Keep running the following state machine by switching on state.
10472|       |  // If after a run pointer points to the EOF code point, go to the next step.
10473|       |  // Otherwise, increase pointer by 1 and continue with the state machine.
10474|       |  // We never decrement input_position.
10475|   141k|  while (input_position <= input_size) {
  ------------------
  |  Branch (10475:10): [True: 130k, False: 10.2k]
  ------------------
10476|   130k|    ada_log("In parsing at ", input_position, " out of ", input_size,
10477|   130k|            " in state ", ada::to_string(state));
10478|   130k|    switch (state) {
10479|  34.1k|      case state::SCHEME_START: {
  ------------------
  |  Branch (10479:7): [True: 34.1k, False: 96.7k]
  ------------------
10480|  34.1k|        ada_log("SCHEME_START ", helpers::substring(url_data, input_position));
10481|       |        // If c is an ASCII alpha, append c, lowercased, to buffer, and set
10482|       |        // state to scheme state.
10483|  34.1k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (10483:13): [True: 18.9k, False: 15.1k]
  ------------------
10484|  18.9k|            checkers::is_alpha(url_data[input_position])) {
  ------------------
  |  Branch (10484:13): [True: 17.9k, False: 951]
  ------------------
10485|  17.9k|          state = state::SCHEME;
10486|  17.9k|          input_position++;
10487|  17.9k|        } else {
10488|       |          // Otherwise, if state override is not given, set state to no scheme
10489|       |          // state and decrease pointer by 1.
10490|  16.1k|          state = state::NO_SCHEME;
10491|  16.1k|        }
10492|  34.1k|        break;
10493|      0|      }
10494|  17.9k|      case state::SCHEME: {
  ------------------
  |  Branch (10494:7): [True: 17.9k, False: 112k]
  ------------------
10495|  17.9k|        ada_log("SCHEME ", helpers::substring(url_data, input_position));
10496|       |        // If c is an ASCII alphanumeric, U+002B (+), U+002D (-), or U+002E (.),
10497|       |        // append c, lowercased, to buffer.
10498|  45.2k|        while ((input_position != input_size) &&
  ------------------
  |  Branch (10498:16): [True: 44.9k, False: 319]
  ------------------
10499|  44.9k|               (unicode::is_alnum_plus(url_data[input_position]))) {
  ------------------
  |  Branch (10499:16): [True: 27.2k, False: 17.6k]
  ------------------
10500|  27.2k|          input_position++;
10501|  27.2k|        }
10502|       |        // Otherwise, if c is U+003A (:), then:
10503|  17.9k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (10503:13): [True: 17.6k, False: 319]
  ------------------
10504|  17.6k|            (url_data[input_position] == ':')) {
  ------------------
  |  Branch (10504:13): [True: 17.4k, False: 249]
  ------------------
10505|  17.4k|          ada_log("SCHEME the scheme should be ",
10506|  17.4k|                  url_data.substr(0, input_position));
10507|  17.4k|          if constexpr (result_type_is_ada_url) {
10508|  17.4k|            if (!url.parse_scheme(url_data.substr(0, input_position))) {
  ------------------
  |  Branch (10508:17): [True: 0, False: 17.4k]
  ------------------
10509|      0|              return url;
10510|      0|            }
10511|       |          } else {
10512|       |            // we pass the colon along instead of painfully adding it back.
10513|       |            if (!url.parse_scheme_with_colon(
10514|       |                    url_data.substr(0, input_position + 1))) {
10515|       |              return url;
10516|       |            }
10517|       |          }
10518|  17.4k|          ada_log("SCHEME the scheme is ", url.get_protocol());
10519|       |
10520|       |          // If url's scheme is "file", then:
10521|       |          // NOLINTNEXTLINE(bugprone-branch-clone)
10522|  17.4k|          if (url.type == scheme::type::FILE) {
  ------------------
  |  Branch (10522:15): [True: 2.40k, False: 15.0k]
  ------------------
10523|       |            // Set state to file state.
10524|  2.40k|            state = state::FILE;
10525|  2.40k|          }
10526|       |          // Otherwise, if url is special, base is non-null, and base's scheme
10527|       |          // is url's scheme: Note: Doing base_url->scheme is unsafe if base_url
10528|       |          // != nullptr is false.
10529|  15.0k|          else if (url.is_special() && base_url != nullptr &&
  ------------------
  |  Branch (10529:20): [True: 10.5k, False: 4.43k]
  |  Branch (10529:40): [True: 1.49k, False: 9.08k]
  ------------------
10530|  1.49k|                   base_url->type == url.type) {
  ------------------
  |  Branch (10530:20): [True: 144, False: 1.34k]
  ------------------
10531|       |            // Set state to special relative or authority state.
10532|    144|            state = state::SPECIAL_RELATIVE_OR_AUTHORITY;
10533|    144|          }
10534|       |          // Otherwise, if url is special, set state to special authority
10535|       |          // slashes state.
10536|  14.8k|          else if (url.is_special()) {
  ------------------
  |  Branch (10536:20): [True: 10.4k, False: 4.43k]
  ------------------
10537|  10.4k|            state = state::SPECIAL_AUTHORITY_SLASHES;
10538|  10.4k|          }
10539|       |          // Otherwise, if remaining starts with an U+002F (/), set state to
10540|       |          // path or authority state and increase pointer by 1.
10541|  4.43k|          else if (input_position + 1 < input_size &&
  ------------------
  |  Branch (10541:20): [True: 2.68k, False: 1.75k]
  ------------------
10542|  2.68k|                   url_data[input_position + 1] == '/') {
  ------------------
  |  Branch (10542:20): [True: 1.83k, False: 853]
  ------------------
10543|  1.83k|            state = state::PATH_OR_AUTHORITY;
10544|  1.83k|            input_position++;
10545|  1.83k|          }
10546|       |          // Otherwise, set url's path to the empty string and set state to
10547|       |          // opaque path state.
10548|  2.60k|          else {
10549|  2.60k|            state = state::OPAQUE_PATH;
10550|  2.60k|          }
10551|  17.4k|        }
10552|       |        // Otherwise, if state override is not given, set buffer to the empty
10553|       |        // string, state to no scheme state, and start over (from the first code
10554|       |        // point in input).
10555|    568|        else {
10556|    568|          state = state::NO_SCHEME;
10557|    568|          input_position = 0;
10558|    568|          break;
10559|    568|        }
10560|  17.4k|        input_position++;
10561|  17.4k|        break;
10562|  17.9k|      }
10563|  16.7k|      case state::NO_SCHEME: {
  ------------------
  |  Branch (10563:7): [True: 16.7k, False: 114k]
  ------------------
10564|  16.7k|        ada_log("NO_SCHEME ", helpers::substring(url_data, input_position));
10565|       |        // If base is null, or base has an opaque path and c is not U+0023 (#),
10566|       |        // validation error, return failure.
10567|  16.7k|        if (base_url == nullptr ||
  ------------------
  |  Branch (10567:13): [True: 15.7k, False: 919]
  ------------------
10568|  15.8k|            (base_url->has_opaque_path && !fragment.has_value())) {
  ------------------
  |  Branch (10568:14): [True: 212, False: 707]
  |  Branch (10568:43): [True: 45, False: 167]
  ------------------
10569|  15.8k|          ada_log("NO_SCHEME validation error");
10570|  15.8k|          url.is_valid = false;
10571|  15.8k|          return url;
10572|  15.8k|        }
10573|       |        // Otherwise, if base has an opaque path and c is U+0023 (#),
10574|       |        // set url's scheme to base's scheme, url's path to base's path, url's
10575|       |        // query to base's query, and set state to fragment state.
10576|    874|        else if (base_url->has_opaque_path && fragment.has_value() &&
  ------------------
  |  Branch (10576:18): [True: 167, False: 707]
  |  Branch (10576:47): [True: 167, False: 0]
  ------------------
10577|    167|                 input_position == input_size) {
  ------------------
  |  Branch (10577:18): [True: 86, False: 81]
  ------------------
10578|     86|          ada_log("NO_SCHEME opaque base with fragment");
10579|     86|          url.copy_scheme(*base_url);
10580|     86|          url.has_opaque_path = base_url->has_opaque_path;
10581|       |
10582|     86|          if constexpr (result_type_is_ada_url) {
10583|     86|            url.path = base_url->path;
10584|     86|            url.query = base_url->query;
10585|       |          } else {
10586|       |            url.update_base_pathname(base_url->get_pathname());
10587|       |            if (base_url->has_search()) {
10588|       |              // get_search() returns "" for an empty query string (URL ends
10589|       |              // with '?'). update_base_search("") would incorrectly clear the
10590|       |              // query, so pass "?" to preserve the empty query distinction.
10591|       |              auto s = base_url->get_search();
10592|       |              url.update_base_search(s.empty() ? std::string_view("?") : s);
10593|       |            }
10594|       |          }
10595|     86|          url.update_unencoded_base_hash(*fragment);
10596|     86|          return url;
10597|     86|        }
10598|       |        // Otherwise, if base's scheme is not "file", set state to relative
10599|       |        // state and decrease pointer by 1.
10600|       |        // NOLINTNEXTLINE(bugprone-branch-clone)
10601|    788|        else if (base_url->type != scheme::type::FILE) {
  ------------------
  |  Branch (10601:18): [True: 480, False: 308]
  ------------------
10602|    480|          ada_log("NO_SCHEME non-file relative path");
10603|    480|          state = state::RELATIVE_SCHEME;
10604|    480|        }
10605|       |        // Otherwise, set state to file state and decrease pointer by 1.
10606|    308|        else {
10607|    308|          ada_log("NO_SCHEME file base type");
10608|    308|          state = state::FILE;
10609|    308|        }
10610|    788|        break;
10611|  16.7k|      }
10612|  11.1k|      case state::AUTHORITY: {
  ------------------
  |  Branch (10612:7): [True: 11.1k, False: 119k]
  ------------------
10613|  11.1k|        ada_log("AUTHORITY ", helpers::substring(url_data, input_position));
10614|       |        // most URLs have no @. Having no @ tells us that we don't have to worry
10615|       |        // about AUTHORITY. Of course, we could have @ and still not have to
10616|       |        // worry about AUTHORITY.
10617|       |        // TODO: Instead of just collecting a bool, collect the location of the
10618|       |        // '@' and do something useful with it.
10619|       |        // TODO: We could do various processing early on, using a single pass
10620|       |        // over the string to collect information about it, e.g., telling us
10621|       |        // whether there is a @ and if so, where (or how many).
10622|       |
10623|       |        // Check if url data contains an @.
10624|  11.1k|        if (url_data.find('@', input_position) == std::string_view::npos) {
  ------------------
  |  Branch (10624:13): [True: 10.1k, False: 976]
  ------------------
10625|  10.1k|          state = state::HOST;
10626|  10.1k|          break;
10627|  10.1k|        }
10628|    976|        bool at_sign_seen{false};
10629|    976|        bool password_token_seen{false};
10630|       |        /**
10631|       |         * We expect something of the sort...
10632|       |         * https://user:pass@example.com:1234/foo/bar?baz#quux
10633|       |         * --------^
10634|       |         */
10635|  7.21k|        do {
10636|  7.21k|          std::string_view view = url_data.substr(input_position);
10637|       |          // The delimiters are @, /, ? \\.
10638|  7.21k|          size_t location =
10639|  7.21k|              url.is_special() ? helpers::find_authority_delimiter_special(view)
  ------------------
  |  Branch (10639:15): [True: 6.45k, False: 758]
  ------------------
10640|  7.21k|                               : helpers::find_authority_delimiter(view);
10641|  7.21k|          std::string_view authority_view = view.substr(0, location);
10642|  7.21k|          size_t end_of_authority = input_position + authority_view.size();
10643|       |          // If c is U+0040 (@), then:
10644|  7.21k|          if ((end_of_authority != input_size) &&
  ------------------
  |  Branch (10644:15): [True: 6.56k, False: 643]
  ------------------
10645|  6.56k|              (url_data[end_of_authority] == '@')) {
  ------------------
  |  Branch (10645:15): [True: 6.23k, False: 333]
  ------------------
10646|       |            // If atSignSeen is true, then prepend "%40" to buffer.
10647|  6.23k|            if (at_sign_seen) {
  ------------------
  |  Branch (10647:17): [True: 5.32k, False: 909]
  ------------------
10648|  5.32k|              if (password_token_seen) {
  ------------------
  |  Branch (10648:19): [True: 2.22k, False: 3.09k]
  ------------------
10649|  2.22k|                if constexpr (result_type_is_ada_url) {
10650|  2.22k|                  url.password += "%40";
10651|       |                } else {
10652|       |                  url.append_base_password("%40");
10653|       |                }
10654|  3.09k|              } else {
10655|  3.09k|                if constexpr (result_type_is_ada_url) {
10656|  3.09k|                  url.username += "%40";
10657|       |                } else {
10658|       |                  url.append_base_username("%40");
10659|       |                }
10660|  3.09k|              }
10661|  5.32k|            }
10662|       |
10663|  6.23k|            at_sign_seen = true;
10664|       |
10665|  6.23k|            if (!password_token_seen) {
  ------------------
  |  Branch (10665:17): [True: 4.00k, False: 2.22k]
  ------------------
10666|  4.00k|              size_t password_token_location = authority_view.find(':');
10667|  4.00k|              password_token_seen =
10668|  4.00k|                  password_token_location != std::string_view::npos;
10669|       |
10670|  4.00k|              if constexpr (store_values) {
10671|  4.00k|                if (!password_token_seen) {
  ------------------
  |  Branch (10671:21): [True: 3.63k, False: 374]
  ------------------
10672|  3.63k|                  if constexpr (result_type_is_ada_url) {
10673|  3.63k|                    url.username += unicode::percent_encode(
10674|  3.63k|                        authority_view,
10675|  3.63k|                        character_sets::USERINFO_PERCENT_ENCODE);
10676|       |                  } else {
10677|       |                    url.append_base_username(unicode::percent_encode(
10678|       |                        authority_view,
10679|       |                        character_sets::USERINFO_PERCENT_ENCODE));
10680|       |                  }
10681|  3.63k|                } else {
10682|    374|                  if constexpr (result_type_is_ada_url) {
10683|    374|                    url.username += unicode::percent_encode(
10684|    374|                        authority_view.substr(0, password_token_location),
10685|    374|                        character_sets::USERINFO_PERCENT_ENCODE);
10686|    374|                    url.password += unicode::percent_encode(
10687|    374|                        authority_view.substr(password_token_location + 1),
10688|    374|                        character_sets::USERINFO_PERCENT_ENCODE);
10689|       |                  } else {
10690|       |                    url.append_base_username(unicode::percent_encode(
10691|       |                        authority_view.substr(0, password_token_location),
10692|       |                        character_sets::USERINFO_PERCENT_ENCODE));
10693|       |                    url.append_base_password(unicode::percent_encode(
10694|       |                        authority_view.substr(password_token_location + 1),
10695|       |                        character_sets::USERINFO_PERCENT_ENCODE));
10696|       |                  }
10697|    374|                }
10698|  4.00k|              }
10699|  4.00k|            } else if constexpr (store_values) {
10700|  2.22k|              if constexpr (result_type_is_ada_url) {
10701|  2.22k|                url.password += unicode::percent_encode(
10702|  2.22k|                    authority_view, character_sets::USERINFO_PERCENT_ENCODE);
10703|       |              } else {
10704|       |                url.append_base_password(unicode::percent_encode(
10705|       |                    authority_view, character_sets::USERINFO_PERCENT_ENCODE));
10706|       |              }
10707|  2.22k|            }
10708|  6.23k|          }
10709|       |          // Otherwise, if one of the following is true:
10710|       |          // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
10711|       |          // - url is special and c is U+005C (\)
10712|    976|          else if (end_of_authority == input_size ||
  ------------------
  |  Branch (10712:20): [True: 643, False: 333]
  ------------------
10713|    333|                   url_data[end_of_authority] == '/' ||
  ------------------
  |  Branch (10713:20): [True: 295, False: 38]
  ------------------
10714|     38|                   url_data[end_of_authority] == '?' ||
  ------------------
  |  Branch (10714:20): [True: 30, False: 8]
  ------------------
10715|    976|                   (url.is_special() && url_data[end_of_authority] == '\\')) {
  ------------------
  |  Branch (10715:21): [True: 8, False: 0]
  |  Branch (10715:41): [True: 8, False: 0]
  ------------------
10716|       |            // If atSignSeen is true and authority_view is the empty string,
10717|       |            // validation error, return failure.
10718|    976|            if (at_sign_seen && authority_view.empty()) {
  ------------------
  |  Branch (10718:17): [True: 909, False: 67]
  |  Branch (10718:33): [True: 283, False: 626]
  ------------------
10719|    283|              url.is_valid = false;
10720|    283|              return url;
10721|    283|            }
10722|    693|            state = state::HOST;
10723|    693|            break;
10724|    976|          }
10725|  6.23k|          if (end_of_authority == input_size) {
  ------------------
  |  Branch (10725:15): [True: 0, False: 6.23k]
  ------------------
10726|      0|            if constexpr (store_values) {
10727|      0|              if (fragment.has_value()) {
  ------------------
  |  Branch (10727:19): [True: 0, False: 0]
  ------------------
10728|      0|                url.update_unencoded_base_hash(*fragment);
10729|      0|              }
10730|      0|            }
10731|      0|            return url;
10732|      0|          }
10733|  6.23k|          input_position = end_of_authority + 1;
10734|  6.23k|        } while (true);
  ------------------
  |  Branch (10734:18): [True: 6.23k, Folded]
  ------------------
10735|       |
10736|    693|        break;
10737|    976|      }
10738|    693|      case state::SPECIAL_RELATIVE_OR_AUTHORITY: {
  ------------------
  |  Branch (10738:7): [True: 144, False: 130k]
  ------------------
10739|    144|        ada_log("SPECIAL_RELATIVE_OR_AUTHORITY ",
10740|    144|                helpers::substring(url_data, input_position));
10741|       |
10742|       |        // If c is U+002F (/) and remaining starts with U+002F (/),
10743|       |        // then set state to special authority ignore slashes state and increase
10744|       |        // pointer by 1.
10745|    144|        if (url_data.substr(input_position, 2) == "//") {
  ------------------
  |  Branch (10745:13): [True: 53, False: 91]
  ------------------
10746|     53|          state = state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
10747|     53|          input_position += 2;
10748|     91|        } else {
10749|       |          // Otherwise, validation error, set state to relative state and
10750|       |          // decrease pointer by 1.
10751|     91|          state = state::RELATIVE_SCHEME;
10752|     91|        }
10753|       |
10754|    144|        break;
10755|    976|      }
10756|  1.83k|      case state::PATH_OR_AUTHORITY: {
  ------------------
  |  Branch (10756:7): [True: 1.83k, False: 129k]
  ------------------
10757|  1.83k|        ada_log("PATH_OR_AUTHORITY ",
10758|  1.83k|                helpers::substring(url_data, input_position));
10759|       |
10760|       |        // If c is U+002F (/), then set state to authority state.
10761|  1.83k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (10761:13): [True: 1.72k, False: 105]
  ------------------
10762|  1.72k|            (url_data[input_position] == '/')) {
  ------------------
  |  Branch (10762:13): [True: 652, False: 1.07k]
  ------------------
10763|    652|          state = state::AUTHORITY;
10764|    652|          input_position++;
10765|  1.18k|        } else {
10766|       |          // Otherwise, set state to path state, and decrease pointer by 1.
10767|  1.18k|          state = state::PATH;
10768|  1.18k|        }
10769|       |
10770|  1.83k|        break;
10771|    976|      }
10772|    571|      case state::RELATIVE_SCHEME: {
  ------------------
  |  Branch (10772:7): [True: 571, False: 130k]
  ------------------
10773|    571|        ada_log("RELATIVE_SCHEME ",
10774|    571|                helpers::substring(url_data, input_position));
10775|       |
10776|       |        // Set url's scheme to base's scheme.
10777|    571|        url.copy_scheme(*base_url);
10778|       |
10779|       |        // If c is U+002F (/), then set state to relative slash state.
10780|    571|        if ((input_position != input_size) &&
  ------------------
  |  Branch (10780:13): [True: 439, False: 132]
  ------------------
10781|       |            // NOLINTNEXTLINE(bugprone-branch-clone)
10782|    439|            (url_data[input_position] == '/')) {
  ------------------
  |  Branch (10782:13): [True: 68, False: 371]
  ------------------
10783|     68|          ada_log(
10784|     68|              "RELATIVE_SCHEME if c is U+002F (/), then set state to relative "
10785|     68|              "slash state");
10786|     68|          state = state::RELATIVE_SLASH;
10787|    503|        } else if (url.is_special() && (input_position != input_size) &&
  ------------------
  |  Branch (10787:20): [True: 315, False: 188]
  |  Branch (10787:40): [True: 223, False: 92]
  ------------------
10788|    223|                   (url_data[input_position] == '\\')) {
  ------------------
  |  Branch (10788:20): [True: 4, False: 219]
  ------------------
10789|       |          // Otherwise, if url is special and c is U+005C (\), validation error,
10790|       |          // set state to relative slash state.
10791|      4|          ada_log(
10792|      4|              "RELATIVE_SCHEME  if url is special and c is U+005C, validation "
10793|      4|              "error, set state to relative slash state");
10794|      4|          state = state::RELATIVE_SLASH;
10795|    499|        } else {
10796|    499|          ada_log("RELATIVE_SCHEME otherwise");
10797|       |          // Set url's username to base's username, url's password to base's
10798|       |          // password, url's host to base's host, url's port to base's port,
10799|       |          // url's path to a clone of base's path, and url's query to base's
10800|       |          // query.
10801|    499|          if constexpr (result_type_is_ada_url) {
10802|    499|            url.username = base_url->username;
10803|    499|            url.password = base_url->password;
10804|    499|            url.host = base_url->host;
10805|    499|            url.port = base_url->port;
10806|       |            // cloning the base path includes cloning the has_opaque_path flag
10807|    499|            url.has_opaque_path = base_url->has_opaque_path;
10808|    499|            url.path = base_url->path;
10809|    499|            url.query = base_url->query;
10810|       |          } else {
10811|       |            url.update_base_authority(base_url->get_href(),
10812|       |                                      base_url->get_components());
10813|       |            url.update_host_to_base_host(base_url->get_hostname());
10814|       |            url.update_base_port(base_url->retrieve_base_port());
10815|       |            // cloning the base path includes cloning the has_opaque_path flag
10816|       |            url.has_opaque_path = base_url->has_opaque_path;
10817|       |            url.update_base_pathname(base_url->get_pathname());
10818|       |            if (base_url->has_search()) {
10819|       |              // get_search() returns "" for an empty query string (URL ends
10820|       |              // with '?'). update_base_search("") would incorrectly clear the
10821|       |              // query, so pass "?" to preserve the empty query distinction.
10822|       |              auto s = base_url->get_search();
10823|       |              url.update_base_search(s.empty() ? std::string_view("?") : s);
10824|       |            }
10825|       |          }
10826|       |
10827|    499|          url.has_opaque_path = base_url->has_opaque_path;
10828|       |
10829|       |          // If c is U+003F (?), then set url's query to the empty string, and
10830|       |          // state to query state.
10831|    499|          if ((input_position != input_size) &&
  ------------------
  |  Branch (10831:15): [True: 367, False: 132]
  ------------------
10832|    367|              (url_data[input_position] == '?')) {
  ------------------
  |  Branch (10832:15): [True: 27, False: 340]
  ------------------
10833|     27|            state = state::QUERY;
10834|     27|          }
10835|       |          // Otherwise, if c is not the EOF code point:
10836|    472|          else if (input_position != input_size) {
  ------------------
  |  Branch (10836:20): [True: 340, False: 132]
  ------------------
10837|       |            // Set url's query to null.
10838|    340|            url.clear_search();
10839|    340|            if constexpr (result_type_is_ada_url) {
10840|       |              // Shorten url's path.
10841|    340|              helpers::shorten_path(url.path, url.type);
10842|       |            } else {
10843|       |              std::string_view path = url.get_pathname();
10844|       |              if (helpers::shorten_path(path, url.type)) {
10845|       |                url.update_base_pathname(std::move(std::string(path)));
10846|       |              }
10847|       |            }
10848|       |            // Set state to path state and decrease pointer by 1.
10849|    340|            state = state::PATH;
10850|    340|            break;
10851|    340|          }
10852|    499|        }
10853|    231|        input_position++;
10854|    231|        break;
10855|    571|      }
10856|     72|      case state::RELATIVE_SLASH: {
  ------------------
  |  Branch (10856:7): [True: 72, False: 130k]
  ------------------
10857|     72|        ada_log("RELATIVE_SLASH ",
10858|     72|                helpers::substring(url_data, input_position));
10859|       |
10860|       |        // If url is special and c is U+002F (/) or U+005C (\), then:
10861|       |        // NOLINTNEXTLINE(bugprone-branch-clone)
10862|     72|        if (url.is_special() && (input_position != input_size) &&
  ------------------
  |  Branch (10862:13): [True: 50, False: 22]
  |  Branch (10862:33): [True: 35, False: 15]
  ------------------
10863|     35|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (10863:14): [True: 4, False: 31]
  ------------------
10864|     31|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (10864:14): [True: 1, False: 30]
  ------------------
10865|       |          // Set state to special authority ignore slashes state.
10866|      5|          state = state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
10867|      5|        }
10868|       |        // Otherwise, if c is U+002F (/), then set state to authority state.
10869|     67|        else if ((input_position != input_size) &&
  ------------------
  |  Branch (10869:18): [True: 45, False: 22]
  ------------------
10870|     45|                 (url_data[input_position] == '/')) {
  ------------------
  |  Branch (10870:18): [True: 6, False: 39]
  ------------------
10871|      6|          state = state::AUTHORITY;
10872|      6|        }
10873|       |        // Otherwise, set
10874|       |        // - url's username to base's username,
10875|       |        // - url's password to base's password,
10876|       |        // - url's host to base's host,
10877|       |        // - url's port to base's port,
10878|       |        // - state to path state, and then, decrease pointer by 1.
10879|     61|        else {
10880|     61|          if constexpr (result_type_is_ada_url) {
10881|     61|            url.username = base_url->username;
10882|     61|            url.password = base_url->password;
10883|     61|            url.host = base_url->host;
10884|     61|            url.port = base_url->port;
10885|       |          } else {
10886|       |            url.update_base_authority(base_url->get_href(),
10887|       |                                      base_url->get_components());
10888|       |            url.update_host_to_base_host(base_url->get_hostname());
10889|       |            url.update_base_port(base_url->retrieve_base_port());
10890|       |          }
10891|     61|          state = state::PATH;
10892|     61|          break;
10893|     61|        }
10894|       |
10895|     11|        input_position++;
10896|     11|        break;
10897|     72|      }
10898|  10.4k|      case state::SPECIAL_AUTHORITY_SLASHES: {
  ------------------
  |  Branch (10898:7): [True: 10.4k, False: 120k]
  ------------------
10899|  10.4k|        ada_log("SPECIAL_AUTHORITY_SLASHES ",
10900|  10.4k|                helpers::substring(url_data, input_position));
10901|       |
10902|       |        // If c is U+002F (/) and remaining starts with U+002F (/),
10903|       |        // then set state to special authority ignore slashes state and increase
10904|       |        // pointer by 1.
10905|  10.4k|        if (url_data.substr(input_position, 2) == "//") {
  ------------------
  |  Branch (10905:13): [True: 3.26k, False: 7.16k]
  ------------------
10906|  3.26k|          input_position += 2;
10907|  3.26k|        }
10908|       |
10909|  10.4k|        [[fallthrough]];
10910|  10.4k|      }
10911|  10.4k|      case state::SPECIAL_AUTHORITY_IGNORE_SLASHES: {
  ------------------
  |  Branch (10911:7): [True: 58, False: 130k]
  ------------------
10912|  10.4k|        ada_log("SPECIAL_AUTHORITY_IGNORE_SLASHES ",
10913|  10.4k|                helpers::substring(url_data, input_position));
10914|       |
10915|       |        // If c is neither U+002F (/) nor U+005C (\), then set state to
10916|       |        // authority state and decrease pointer by 1.
10917|  11.5k|        while ((input_position != input_size) &&
  ------------------
  |  Branch (10917:16): [True: 11.4k, False: 73]
  ------------------
10918|  11.4k|               ((url_data[input_position] == '/') ||
  ------------------
  |  Branch (10918:17): [True: 655, False: 10.8k]
  ------------------
10919|  10.8k|                (url_data[input_position] == '\\'))) {
  ------------------
  |  Branch (10919:17): [True: 419, False: 10.4k]
  ------------------
10920|  1.07k|          input_position++;
10921|  1.07k|        }
10922|  10.4k|        state = state::AUTHORITY;
10923|       |
10924|  10.4k|        break;
10925|  10.4k|      }
10926|    819|      case state::QUERY: {
  ------------------
  |  Branch (10926:7): [True: 819, False: 130k]
  ------------------
10927|    819|        ada_log("QUERY ", helpers::substring(url_data, input_position));
10928|    819|        if constexpr (store_values) {
10929|       |          // Let queryPercentEncodeSet be the special-query percent-encode set
10930|       |          // if url is special; otherwise the query percent-encode set.
10931|    819|          const uint8_t* query_percent_encode_set =
10932|    819|              url.is_special() ? character_sets::SPECIAL_QUERY_PERCENT_ENCODE
  ------------------
  |  Branch (10932:15): [True: 393, False: 426]
  ------------------
10933|    819|                               : character_sets::QUERY_PERCENT_ENCODE;
10934|       |
10935|       |          // Percent-encode after encoding, with encoding, buffer, and
10936|       |          // queryPercentEncodeSet, and append the result to url's query.
10937|    819|          url.update_base_search(url_data.substr(input_position),
10938|    819|                                 query_percent_encode_set);
10939|    819|          ada_log("QUERY update_base_search completed ");
10940|    819|          if (fragment.has_value()) {
  ------------------
  |  Branch (10940:15): [True: 132, False: 687]
  ------------------
10941|    132|            url.update_unencoded_base_hash(*fragment);
10942|    132|          }
10943|    819|        }
10944|    819|        return url;
10945|  10.4k|      }
10946|  10.8k|      case state::HOST: {
  ------------------
  |  Branch (10946:7): [True: 10.8k, False: 120k]
  ------------------
10947|  10.8k|        ada_log("HOST ", helpers::substring(url_data, input_position));
10948|       |
10949|  10.8k|        std::string_view host_view = url_data.substr(input_position);
10950|  10.8k|        auto [location, found_colon] =
10951|  10.8k|            helpers::get_host_delimiter_location(url.is_special(), host_view);
10952|  10.8k|        input_position = (location != std::string_view::npos)
  ------------------
  |  Branch (10952:26): [True: 10.8k, False: 0]
  ------------------
10953|  10.8k|                             ? input_position + location
10954|  10.8k|                             : input_size;
10955|       |        // Otherwise, if c is U+003A (:) and insideBrackets is false, then:
10956|       |        // Note: the 'found_colon' value is true if and only if a colon was
10957|       |        // encountered while not inside brackets.
10958|  10.8k|        if (found_colon) {
  ------------------
  |  Branch (10958:13): [True: 1.55k, False: 9.30k]
  ------------------
10959|       |          // If buffer is the empty string, validation error, return failure.
10960|       |          // Let host be the result of host parsing buffer with url is not
10961|       |          // special.
10962|  1.55k|          ada_log("HOST parsing ", host_view);
10963|  1.55k|          if (!url.parse_host(host_view)) {
  ------------------
  |  Branch (10963:15): [True: 153, False: 1.40k]
  ------------------
10964|    153|            return url;
10965|    153|          }
10966|  1.40k|          ada_log("HOST parsing results in ", url.get_hostname());
10967|       |          // Set url's host to host, buffer to the empty string, and state to
10968|       |          // port state.
10969|  1.40k|          state = state::PORT;
10970|  1.40k|          input_position++;
10971|  1.40k|        }
10972|       |        // Otherwise, if one of the following is true:
10973|       |        // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
10974|       |        // - url is special and c is U+005C (\)
10975|       |        // The get_host_delimiter_location function either brings us to
10976|       |        // the colon outside of the bracket, or to one of those characters.
10977|  9.30k|        else {
10978|       |          // If url is special and host_view is the empty string, validation
10979|       |          // error, return failure.
10980|  9.30k|          if (host_view.empty() && url.is_special()) {
  ------------------
  |  Branch (10980:15): [True: 143, False: 9.15k]
  |  Branch (10980:36): [True: 76, False: 67]
  ------------------
10981|     76|            url.is_valid = false;
10982|     76|            return url;
10983|     76|          }
10984|  9.22k|          ada_log("HOST parsing ", host_view, " href=", url.get_href());
10985|       |          // Let host be the result of host parsing host_view with url is not
10986|       |          // special.
10987|  9.22k|          if (host_view.empty()) {
  ------------------
  |  Branch (10987:15): [True: 67, False: 9.15k]
  ------------------
10988|     67|            url.update_base_hostname("");
10989|  9.15k|          } else if (!url.parse_host(host_view)) {
  ------------------
  |  Branch (10989:22): [True: 2.39k, False: 6.75k]
  ------------------
10990|  2.39k|            return url;
10991|  2.39k|          }
10992|  6.82k|          ada_log("HOST parsing results in ", url.get_hostname(),
10993|  6.82k|                  " href=", url.get_href());
10994|       |
10995|       |          // Set url's host to host, and state to path start state.
10996|  6.82k|          state = state::PATH_START;
10997|  6.82k|        }
10998|       |
10999|  8.23k|        break;
11000|  10.8k|      }
11001|  8.23k|      case state::OPAQUE_PATH: {
  ------------------
  |  Branch (11001:7): [True: 2.60k, False: 128k]
  ------------------
11002|  2.60k|        ada_log("OPAQUE_PATH ", helpers::substring(url_data, input_position));
11003|       |        // Opaque path, query, and fragment are structurally always valid:
11004|       |        // the parser would just percent-encode whatever is there. When we
11005|       |        // are not storing values (can_parse), we can return immediately.
11006|       |        // We must set has_opaque_path = true before returning so that when
11007|       |        // this URL is used as an internal base inside can_parse, NO_SCHEME
11008|       |        // correctly rejects relative inputs against an opaque-path base
11009|       |        // (e.g. can_parse("", &"W:") must return false).
11010|       |        if constexpr (!store_values) {
11011|       |          url.has_opaque_path = true;
11012|       |          return url;
11013|       |        }
11014|  2.60k|        std::string_view view = url_data.substr(input_position);
11015|       |        // If c is U+003F (?), then set url's query to the empty string and
11016|       |        // state to query state.
11017|  2.60k|        size_t location = view.find('?');
11018|  2.60k|        if (location != std::string_view::npos) {
  ------------------
  |  Branch (11018:13): [True: 280, False: 2.32k]
  ------------------
11019|    280|          view.remove_suffix(view.size() - location);
11020|    280|          state = state::QUERY;
11021|    280|          input_position += location + 1;
11022|  2.32k|        } else {
11023|  2.32k|          input_position = input_size + 1;
11024|  2.32k|        }
11025|  2.60k|        url.has_opaque_path = true;
11026|       |
11027|       |        // This is a really unlikely scenario in real world. We should not seek
11028|       |        // to optimize it.
11029|  2.60k|        if (view.ends_with(' ')) {
  ------------------
  |  Branch (11029:13): [True: 75, False: 2.53k]
  ------------------
11030|     75|          std::string modified_view =
11031|     75|              std::string(view.substr(0, view.size() - 1)) + "%20";
11032|     75|          url.update_base_pathname(unicode::percent_encode(
11033|     75|              modified_view, character_sets::C0_CONTROL_PERCENT_ENCODE));
11034|  2.53k|        } else {
11035|  2.53k|          url.update_base_pathname(unicode::percent_encode(
11036|  2.53k|              view, character_sets::C0_CONTROL_PERCENT_ENCODE));
11037|  2.53k|        }
11038|  2.60k|        break;
11039|  10.8k|      }
11040|  1.40k|      case state::PORT: {
  ------------------
  |  Branch (11040:7): [True: 1.40k, False: 129k]
  ------------------
11041|  1.40k|        ada_log("PORT ", helpers::substring(url_data, input_position));
11042|  1.40k|        std::string_view port_view = url_data.substr(input_position);
11043|  1.40k|        input_position += url.parse_port(port_view, true);
11044|  1.40k|        if (!url.is_valid) {
  ------------------
  |  Branch (11044:13): [True: 100, False: 1.30k]
  ------------------
11045|    100|          return url;
11046|    100|        }
11047|  1.30k|        state = state::PATH_START;
11048|  1.30k|        [[fallthrough]];
11049|  1.30k|      }
11050|  9.70k|      case state::PATH_START: {
  ------------------
  |  Branch (11050:7): [True: 8.39k, False: 122k]
  ------------------
11051|  9.70k|        ada_log("PATH_START ", helpers::substring(url_data, input_position));
11052|       |        // Path, query, and fragment are structurally always valid: the
11053|       |        // parser would just percent-encode whatever is there. When we are
11054|       |        // not storing values (can_parse), we can return immediately since
11055|       |        // no subsequent state can invalidate the URL.
11056|       |        if constexpr (!store_values) {
11057|       |          return url;
11058|       |        }
11059|       |
11060|       |        // If url is special, then:
11061|  9.70k|        if (url.is_special()) {
  ------------------
  |  Branch (11061:13): [True: 9.19k, False: 509]
  ------------------
11062|       |          // Set state to path state.
11063|  9.19k|          state = state::PATH;
11064|       |
11065|       |          // Optimization: Avoiding going into PATH state improves the
11066|       |          // performance of urls ending with /.
11067|  9.19k|          if (input_position == input_size) {
  ------------------
  |  Branch (11067:15): [True: 4.43k, False: 4.76k]
  ------------------
11068|  4.43k|            if constexpr (store_values) {
11069|  4.43k|              url.update_base_pathname("/");
11070|  4.43k|              if (fragment.has_value()) {
  ------------------
  |  Branch (11070:19): [True: 91, False: 4.33k]
  ------------------
11071|     91|                url.update_unencoded_base_hash(*fragment);
11072|     91|              }
11073|  4.43k|            }
11074|  4.43k|            return url;
11075|  4.43k|          }
11076|       |          // If c is neither U+002F (/) nor U+005C (\), then decrease pointer
11077|       |          // by 1. We know that (input_position == input_size) is impossible
11078|       |          // here, because of the previous if-check.
11079|  4.76k|          if ((url_data[input_position] != '/') &&
  ------------------
  |  Branch (11079:15): [True: 214, False: 4.55k]
  ------------------
11080|    214|              (url_data[input_position] != '\\')) {
  ------------------
  |  Branch (11080:15): [True: 188, False: 26]
  ------------------
11081|    188|            break;
11082|    188|          }
11083|  4.76k|        }
11084|       |        // Otherwise, if state override is not given and c is U+003F (?),
11085|       |        // set url's query to the empty string and state to query state.
11086|    509|        else if ((input_position != input_size) &&
  ------------------
  |  Branch (11086:18): [True: 152, False: 357]
  ------------------
11087|    152|                 (url_data[input_position] == '?')) {
  ------------------
  |  Branch (11087:18): [True: 51, False: 101]
  ------------------
11088|     51|          state = state::QUERY;
11089|     51|        }
11090|       |        // Otherwise, if c is not the EOF code point:
11091|    458|        else if (input_position != input_size) {
  ------------------
  |  Branch (11091:18): [True: 101, False: 357]
  ------------------
11092|       |          // Set state to path state.
11093|    101|          state = state::PATH;
11094|       |
11095|       |          // If c is not U+002F (/), then decrease pointer by 1.
11096|    101|          if (url_data[input_position] != '/') {
  ------------------
  |  Branch (11096:15): [True: 0, False: 101]
  ------------------
11097|      0|            break;
11098|      0|          }
11099|    101|        }
11100|       |
11101|  5.08k|        input_position++;
11102|  5.08k|        break;
11103|  9.70k|      }
11104|  7.36k|      case state::PATH: {
  ------------------
  |  Branch (11104:7): [True: 7.36k, False: 123k]
  ------------------
11105|  7.36k|        ada_log("PATH ", helpers::substring(url_data, input_position));
11106|       |        // Path, query, and fragment are structurally always valid: the
11107|       |        // parser would just percent-encode whatever is there. When we are
11108|       |        // not storing values (can_parse), we can return immediately since
11109|       |        // no subsequent state can invalidate the URL.
11110|       |        if constexpr (!store_values) {
11111|       |          return url;
11112|       |        }
11113|  7.36k|        std::string_view view = url_data.substr(input_position);
11114|       |
11115|       |        // Most time, we do not need percent encoding.
11116|       |        // Furthermore, we can immediately locate the '?'.
11117|  7.36k|        size_t locofquestionmark = view.find('?');
11118|  7.36k|        if (locofquestionmark != std::string_view::npos) {
  ------------------
  |  Branch (11118:13): [True: 453, False: 6.90k]
  ------------------
11119|    453|          state = state::QUERY;
11120|    453|          view.remove_suffix(view.size() - locofquestionmark);
11121|    453|          input_position += locofquestionmark + 1;
11122|  6.90k|        } else {
11123|  6.90k|          input_position = input_size + 1;
11124|  6.90k|        }
11125|  7.36k|        if constexpr (store_values) {
11126|  7.36k|          if constexpr (result_type_is_ada_url) {
11127|  7.36k|            helpers::parse_prepared_path(view, url.type, url.path);
11128|       |          } else {
11129|       |            url.consume_prepared_path(view);
11130|       |            ADA_ASSERT_TRUE(url.validate());
11131|       |          }
11132|  7.36k|        }
11133|  7.36k|        break;
11134|  9.70k|      }
11135|  1.91k|      case state::FILE_SLASH: {
  ------------------
  |  Branch (11135:7): [True: 1.91k, False: 128k]
  ------------------
11136|  1.91k|        ada_log("FILE_SLASH ", helpers::substring(url_data, input_position));
11137|       |
11138|       |        // If c is U+002F (/) or U+005C (\), then:
11139|  1.91k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (11139:13): [True: 1.82k, False: 85]
  ------------------
11140|  1.82k|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (11140:14): [True: 1.73k, False: 88]
  ------------------
11141|  1.74k|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (11141:14): [True: 6, False: 82]
  ------------------
11142|  1.74k|          ada_log("FILE_SLASH c is U+002F or U+005C");
11143|       |          // Set state to file host state.
11144|  1.74k|          state = state::FILE_HOST;
11145|  1.74k|          input_position++;
11146|  1.74k|        } else {
11147|    167|          ada_log("FILE_SLASH otherwise");
11148|       |          // If base is non-null and base's scheme is "file", then:
11149|       |          // Note: it is unsafe to do base_url->scheme unless you know that
11150|       |          // base_url_has_value() is true.
11151|    167|          if (base_url != nullptr && base_url->type == scheme::type::FILE) {
  ------------------
  |  Branch (11151:15): [True: 128, False: 39]
  |  Branch (11151:38): [True: 122, False: 6]
  ------------------
11152|       |            // Set url's host to base's host.
11153|    122|            if constexpr (result_type_is_ada_url) {
11154|    122|              url.host = base_url->host;
11155|       |            } else {
11156|       |              url.update_host_to_base_host(base_url->get_host());
11157|       |            }
11158|       |            // If the code point substring from pointer to the end of input does
11159|       |            // not start with a Windows drive letter and base's path[0] is a
11160|       |            // normalized Windows drive letter, then append base's path[0] to
11161|       |            // url's path.
11162|    122|            if (!base_url->get_pathname().empty()) {
  ------------------
  |  Branch (11162:17): [True: 122, False: 0]
  ------------------
11163|    122|              if (!checkers::is_windows_drive_letter(
  ------------------
  |  Branch (11163:19): [True: 117, False: 5]
  ------------------
11164|    122|                      url_data.substr(input_position))) {
11165|    117|                std::string_view first_base_url_path =
11166|    117|                    base_url->get_pathname().substr(1);
11167|    117|                size_t loc = first_base_url_path.find('/');
11168|    117|                if (loc != std::string_view::npos) {
  ------------------
  |  Branch (11168:21): [True: 17, False: 100]
  ------------------
11169|     17|                  helpers::resize(first_base_url_path, loc);
11170|     17|                }
11171|    117|                if (checkers::is_normalized_windows_drive_letter(
  ------------------
  |  Branch (11171:21): [True: 2, False: 115]
  ------------------
11172|    117|                        first_base_url_path)) {
11173|      2|                  if constexpr (result_type_is_ada_url) {
11174|      2|                    url.path += '/';
11175|      2|                    url.path += first_base_url_path;
11176|       |                  } else {
11177|       |                    url.append_base_pathname(
11178|       |                        helpers::concat("/", first_base_url_path));
11179|       |                  }
11180|      2|                }
11181|    117|              }
11182|    122|            }
11183|    122|          }
11184|       |
11185|       |          // Set state to path state, and decrease pointer by 1.
11186|    167|          state = state::PATH;
11187|    167|        }
11188|       |
11189|  1.91k|        break;
11190|  9.70k|      }
11191|  1.74k|      case state::FILE_HOST: {
  ------------------
  |  Branch (11191:7): [True: 1.74k, False: 129k]
  ------------------
11192|  1.74k|        ada_log("FILE_HOST ", helpers::substring(url_data, input_position));
11193|  1.74k|        std::string_view view = url_data.substr(input_position);
11194|       |
11195|  1.74k|        size_t location = view.find_first_of("/\\?");
11196|  1.74k|        std::string_view file_host_buffer = view.substr(
11197|  1.74k|            0, (location != std::string_view::npos) ? location : view.size());
  ------------------
  |  Branch (11197:16): [True: 828, False: 917]
  ------------------
11198|       |
11199|  1.74k|        if (checkers::is_windows_drive_letter(file_host_buffer)) {
  ------------------
  |  Branch (11199:13): [True: 12, False: 1.73k]
  ------------------
11200|     12|          state = state::PATH;
11201|  1.73k|        } else if (file_host_buffer.empty()) {
  ------------------
  |  Branch (11201:20): [True: 330, False: 1.40k]
  ------------------
11202|       |          // Set url's host to the empty string.
11203|    330|          if constexpr (result_type_is_ada_url) {
11204|    330|            url.host = "";
11205|       |          } else {
11206|       |            url.update_base_hostname("");
11207|       |          }
11208|       |          // Set state to path start state.
11209|    330|          state = state::PATH_START;
11210|  1.40k|        } else {
11211|  1.40k|          size_t consumed_bytes = file_host_buffer.size();
11212|  1.40k|          input_position += consumed_bytes;
11213|       |          // Let host be the result of host parsing buffer with url is not
11214|       |          // special.
11215|  1.40k|          if (!url.parse_host(file_host_buffer)) {
  ------------------
  |  Branch (11215:15): [True: 160, False: 1.24k]
  ------------------
11216|    160|            return url;
11217|    160|          }
11218|       |
11219|  1.24k|          if constexpr (result_type_is_ada_url) {
11220|       |            // If host is "localhost", then set host to the empty string.
11221|  1.24k|            if (url.host.has_value() && url.host.value() == "localhost") {
  ------------------
  |  Branch (11221:17): [True: 1.24k, False: 0]
  |  Branch (11221:41): [True: 6, False: 1.23k]
  ------------------
11222|      6|              url.host = "";
11223|      6|            }
11224|       |          } else {
11225|       |            if (url.get_hostname() == "localhost") {
11226|       |              url.update_base_hostname("");
11227|       |            }
11228|       |          }
11229|       |
11230|       |          // Set buffer to the empty string and state to path start state.
11231|  1.24k|          state = state::PATH_START;
11232|  1.24k|        }
11233|       |
11234|  1.58k|        break;
11235|  1.74k|      }
11236|  2.71k|      case state::FILE: {
  ------------------
  |  Branch (11236:7): [True: 2.71k, False: 128k]
  ------------------
11237|  2.71k|        ada_log("FILE ", helpers::substring(url_data, input_position));
11238|  2.71k|        std::string_view file_view = url_data.substr(input_position);
11239|       |
11240|  2.71k|        url.set_protocol_as_file();
11241|  2.71k|        if constexpr (result_type_is_ada_url) {
11242|       |          // Set url's host to the empty string.
11243|  2.71k|          url.host = "";
11244|       |        } else {
11245|       |          url.update_base_hostname("");
11246|       |        }
11247|       |        // If c is U+002F (/) or U+005C (\), then:
11248|  2.71k|        if (input_position != input_size &&
  ------------------
  |  Branch (11248:13): [True: 2.55k, False: 154]
  ------------------
11249|  2.55k|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (11249:14): [True: 1.90k, False: 653]
  ------------------
11250|  1.91k|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (11250:14): [True: 6, False: 647]
  ------------------
11251|  1.91k|          ada_log("FILE c is U+002F or U+005C");
11252|       |          // Set state to file slash state.
11253|  1.91k|          state = state::FILE_SLASH;
11254|  1.91k|        }
11255|       |        // Otherwise, if base is non-null and base's scheme is "file":
11256|    801|        else if (base_url != nullptr && base_url->type == scheme::type::FILE) {
  ------------------
  |  Branch (11256:18): [True: 289, False: 512]
  |  Branch (11256:41): [True: 212, False: 77]
  ------------------
11257|       |          // Set url's host to base's host, url's path to a clone of base's
11258|       |          // path, and url's query to base's query.
11259|    212|          ada_log("FILE base non-null");
11260|    212|          if constexpr (result_type_is_ada_url) {
11261|    212|            url.host = base_url->host;
11262|    212|            url.path = base_url->path;
11263|    212|            url.query = base_url->query;
11264|       |          } else {
11265|       |            url.update_host_to_base_host(base_url->get_hostname());
11266|       |            url.update_base_pathname(base_url->get_pathname());
11267|       |            if (base_url->has_search()) {
11268|       |              // get_search() returns "" for an empty query string (URL ends
11269|       |              // with '?'). update_base_search("") would incorrectly clear the
11270|       |              // query, so pass "?" to preserve the empty query distinction.
11271|       |              auto s = base_url->get_search();
11272|       |              url.update_base_search(s.empty() ? std::string_view("?") : s);
11273|       |            }
11274|       |          }
11275|    212|          url.has_opaque_path = base_url->has_opaque_path;
11276|       |
11277|       |          // If c is U+003F (?), then set url's query to the empty string and
11278|       |          // state to query state.
11279|    212|          if (input_position != input_size && url_data[input_position] == '?') {
  ------------------
  |  Branch (11279:15): [True: 152, False: 60]
  |  Branch (11279:47): [True: 8, False: 144]
  ------------------
11280|      8|            state = state::QUERY;
11281|      8|          }
11282|       |          // Otherwise, if c is not the EOF code point:
11283|    204|          else if (input_position != input_size) {
  ------------------
  |  Branch (11283:20): [True: 144, False: 60]
  ------------------
11284|       |            // Set url's query to null.
11285|    144|            url.clear_search();
11286|       |            // If the code point substring from pointer to the end of input does
11287|       |            // not start with a Windows drive letter, then shorten url's path.
11288|    144|            if (!checkers::is_windows_drive_letter(file_view)) {
  ------------------
  |  Branch (11288:17): [True: 124, False: 20]
  ------------------
11289|    124|              if constexpr (result_type_is_ada_url) {
11290|    124|                helpers::shorten_path(url.path, url.type);
11291|       |              } else {
11292|       |                std::string_view path = url.get_pathname();
11293|       |                if (helpers::shorten_path(path, url.type)) {
11294|       |                  url.update_base_pathname(std::move(std::string(path)));
11295|       |                }
11296|       |              }
11297|    124|            }
11298|       |            // Otherwise:
11299|     20|            else {
11300|       |              // Set url's path to an empty list.
11301|     20|              url.clear_pathname();
11302|     20|              url.has_opaque_path = true;
11303|     20|            }
11304|       |
11305|       |            // Set state to path state and decrease pointer by 1.
11306|    144|            state = state::PATH;
11307|    144|            break;
11308|    144|          }
11309|    212|        }
11310|       |        // Otherwise, set state to path state, and decrease pointer by 1.
11311|    589|        else {
11312|    589|          ada_log("FILE go to path");
11313|    589|          state = state::PATH;
11314|    589|          break;
11315|    589|        }
11316|       |
11317|  1.98k|        input_position++;
11318|  1.98k|        break;
11319|  2.71k|      }
11320|      0|      default:
  ------------------
  |  Branch (11320:7): [True: 0, False: 130k]
  ------------------
11321|      0|        unreachable();
11322|   130k|    }
11323|   130k|  }
11324|  10.2k|  if constexpr (store_values) {
11325|  10.2k|    if (fragment.has_value()) {
  ------------------
  |  Branch (11325:9): [True: 349, False: 9.94k]
  ------------------
11326|    349|      url.update_unencoded_base_hash(*fragment);
11327|    349|    }
11328|  10.2k|  }
11329|       |  // Check the resulting (normalized) URL size against the maximum input length.
11330|       |  // Normalization (percent-encoding, IDNA, etc.) can expand the URL beyond the
11331|       |  // original input size.
11332|  10.2k|  if constexpr (store_values) {
11333|  10.2k|    if (url.is_valid) {
  ------------------
  |  Branch (11333:9): [True: 9.78k, False: 508]
  ------------------
11334|       |      if constexpr (result_type_is_ada_url_aggregator) {
11335|       |        if (url.buffer.size() > max_input_length) {
11336|       |          url.is_valid = false;
11337|       |        }
11338|  9.78k|      } else {
11339|  9.78k|        if (url.get_href_size() > max_input_length) {
  ------------------
  |  Branch (11339:13): [True: 0, False: 9.78k]
  ------------------
11340|      0|          url.is_valid = false;
11341|      0|        }
11342|  9.78k|      }
11343|  9.78k|    }
11344|  10.2k|  }
11345|  10.2k|  return url;
11346|  34.6k|}
_ZN3ada6parser14parse_url_implINS_14url_aggregatorELb1EEET_NSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEPKS3_:
10361|  34.6k|                           const result_type* base_url) {
10362|       |  // We can specialize the implementation per type.
10363|       |  // Important: result_type_is_ada_url is evaluated at *compile time*. This
10364|       |  // means that doing if constexpr(result_type_is_ada_url) { something } else {
10365|       |  // something else } is free (at runtime). This means that ada::url_aggregator
10366|       |  // and ada::url **do not have to support the exact same API**.
10367|  34.6k|  constexpr bool result_type_is_ada_url = std::is_same_v<url, result_type>;
10368|  34.6k|  constexpr bool result_type_is_ada_url_aggregator =
10369|  34.6k|      std::is_same_v<url_aggregator, result_type>;
10370|  34.6k|  static_assert(result_type_is_ada_url ||
10371|  34.6k|                result_type_is_ada_url_aggregator);  // We don't support
10372|       |                                                     // anything else for now.
10373|       |
10374|  34.6k|  ada_log("ada::parser::parse_url('", user_input, "' [", user_input.size(),
10375|  34.6k|          " bytes],", (base_url != nullptr ? base_url->to_string() : "null"),
10376|  34.6k|          ")");
10377|       |
10378|  34.6k|  state state = state::SCHEME_START;
10379|  34.6k|  result_type url{};
10380|       |
10381|  34.6k|  const uint32_t max_input_length = ada::get_max_input_length();
10382|       |
10383|       |  // We refuse to parse URL strings that exceed the maximum input length.
10384|       |  // By default, this is 4GB but can be configured via
10385|       |  // ada::set_max_input_length().
10386|  34.6k|  if (user_input.size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (10386:7): [True: 0, False: 34.6k]
  ------------------
10387|      0|    url.is_valid = false;
10388|      0|  }
10389|       |  // Going forward, user_input.size() is in [0,
10390|       |  // std::numeric_limits<uint32_t>::max). If we are provided with an invalid
10391|       |  // base, or the optional_url was invalid, we must return.
10392|  34.6k|  if (base_url != nullptr) {
  ------------------
  |  Branch (10392:7): [True: 3.04k, False: 31.5k]
  ------------------
10393|  3.04k|    url.is_valid &= base_url->is_valid;
10394|  3.04k|  }
10395|  34.6k|  if (!url.is_valid) {
  ------------------
  |  Branch (10395:7): [True: 0, False: 34.6k]
  ------------------
10396|      0|    return url;
10397|      0|  }
10398|       |
10399|       |  // Simple absolute http(s) fast path (before tabs/newline scan).
10400|       |  // Skip digit-led hosts (IPv4) with a cheap peek.
10401|  34.6k|  if constexpr (store_values) {
10402|  34.6k|    if (base_url == nullptr) {
  ------------------
  |  Branch (10402:9): [True: 31.5k, False: 3.04k]
  ------------------
10403|  31.5k|      const auto* p = reinterpret_cast<const uint8_t*>(user_input.data());
10404|  31.5k|      const size_t n = user_input.size();
10405|  31.5k|      const bool digit_led_host = (n >= 8 && p[4] == ':' && p[5] == '/' &&
  ------------------
  |  Branch (10405:36): [True: 11.3k, False: 20.1k]
  |  Branch (10405:46): [True: 2.82k, False: 8.57k]
  |  Branch (10405:61): [True: 2.14k, False: 681]
  ------------------
10406|  2.14k|                                   p[6] == '/' && p[7] >= '0' && p[7] <= '9') ||
  ------------------
  |  Branch (10406:36): [True: 2.09k, False: 49]
  |  Branch (10406:51): [True: 1.45k, False: 635]
  |  Branch (10406:66): [True: 495, False: 964]
  ------------------
10407|  31.0k|                                  (n >= 9 && p[5] == ':' && p[6] == '/' &&
  ------------------
  |  Branch (10407:36): [True: 9.92k, False: 21.1k]
  |  Branch (10407:46): [True: 416, False: 9.51k]
  |  Branch (10407:61): [True: 177, False: 239]
  ------------------
10408|    177|                                   p[7] == '/' && p[8] >= '0' && p[8] <= '9');
  ------------------
  |  Branch (10408:36): [True: 148, False: 29]
  |  Branch (10408:51): [True: 101, False: 47]
  |  Branch (10408:66): [True: 6, False: 95]
  ------------------
10409|  31.5k|      if (!digit_led_host && try_parse_simple_absolute(user_input, url)) {
  ------------------
  |  Branch (10409:11): [True: 31.0k, False: 501]
  |  Branch (10409:30): [True: 508, False: 30.5k]
  ------------------
10410|    508|        if constexpr (result_type_is_ada_url_aggregator) {
10411|    508|          if (url.buffer.size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (10411:15): [True: 0, False: 508]
  ------------------
10412|      0|            url.is_valid = false;
10413|      0|          }
10414|       |        } else {
10415|       |          if (url.get_href_size() > max_input_length) [[unlikely]] {
10416|       |            url.is_valid = false;
10417|       |          }
10418|       |        }
10419|    508|        return url;
10420|    508|      }
10421|  31.5k|    }
10422|  34.6k|  }
10423|       |
10424|  34.1k|  std::string tmp_buffer;
10425|  34.6k|  std::string_view url_data;
10426|  34.6k|  if (unicode::has_tabs_or_newline(user_input)) [[unlikely]] {
  ------------------
  |  Branch (10426:7): [True: 303, False: 34.3k]
  ------------------
10427|    303|    tmp_buffer = user_input;
10428|       |    // Optimization opportunity: Instead of copying and then pruning, we could
10429|       |    // just directly build the string from user_input.
10430|    303|    helpers::remove_ascii_tab_or_newline(tmp_buffer);
10431|    303|    url_data = tmp_buffer;
10432|  34.3k|  } else [[likely]] {
10433|  34.3k|    url_data = user_input;
10434|  34.3k|  }
10435|       |
10436|       |  // Leading and trailing control characters are uncommon and easy to deal with
10437|       |  // (no performance concern).
10438|  34.6k|  helpers::trim_c0_whitespace(url_data);
10439|       |
10440|  34.6k|  if constexpr (result_type_is_ada_url_aggregator && store_values) {
10441|       |    // Most of the time, we just need user_input.size().
10442|       |    // In some instances, we may need a bit more.
10443|       |    ///////////////////////////
10444|       |    // This is *very* important. This line should *not* be removed
10445|       |    // hastily. There are principled reasons why reserve is important
10446|       |    // for performance. If you have a benchmark with small inputs,
10447|       |    // it may not matter, but in other instances, it could.
10448|       |    ////
10449|       |    // This rounds up to the next power of two.
10450|       |    // We know that user_input.size() is in [0,
10451|       |    // std::numeric_limits<uint32_t>::max).
10452|  34.6k|    uint32_t reserve_capacity =
10453|  34.6k|        (0xFFFFFFFF >>
10454|  34.6k|         helpers::leading_zeroes(uint32_t(1 | user_input.size()))) +
10455|  34.6k|        1;
10456|  34.6k|    url.reserve(reserve_capacity);
10457|  34.6k|  }
10458|       |
10459|       |  // Optimization opportunity. Most websites do not have fragment.
10460|  34.6k|  std::optional<std::string_view> fragment = helpers::prune_hash(url_data);
10461|       |  // We add it last so that an implementation like ada::url_aggregator
10462|       |  // can append it last to its internal buffer, thus improving performance.
10463|       |
10464|       |  // Here url_data no longer has its fragment.
10465|       |  // We are going to access the data from url_data (it is immutable).
10466|       |  // At any given time, we are pointing at byte 'input_position' in url_data.
10467|       |  // The input_position variable should range from 0 to input_size.
10468|       |  // It is illegal to access url_data at input_size.
10469|  34.6k|  size_t input_position = 0;
10470|  34.6k|  const size_t input_size = url_data.size();
10471|       |  // Keep running the following state machine by switching on state.
10472|       |  // If after a run pointer points to the EOF code point, go to the next step.
10473|       |  // Otherwise, increase pointer by 1 and continue with the state machine.
10474|       |  // We never decrement input_position.
10475|   141k|  while (input_position <= input_size) {
  ------------------
  |  Branch (10475:10): [True: 130k, False: 10.2k]
  ------------------
10476|   130k|    ada_log("In parsing at ", input_position, " out of ", input_size,
10477|   130k|            " in state ", ada::to_string(state));
10478|   130k|    switch (state) {
10479|  34.1k|      case state::SCHEME_START: {
  ------------------
  |  Branch (10479:7): [True: 34.1k, False: 96.7k]
  ------------------
10480|  34.1k|        ada_log("SCHEME_START ", helpers::substring(url_data, input_position));
10481|       |        // If c is an ASCII alpha, append c, lowercased, to buffer, and set
10482|       |        // state to scheme state.
10483|  34.1k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (10483:13): [True: 18.9k, False: 15.1k]
  ------------------
10484|  18.9k|            checkers::is_alpha(url_data[input_position])) {
  ------------------
  |  Branch (10484:13): [True: 17.9k, False: 951]
  ------------------
10485|  17.9k|          state = state::SCHEME;
10486|  17.9k|          input_position++;
10487|  17.9k|        } else {
10488|       |          // Otherwise, if state override is not given, set state to no scheme
10489|       |          // state and decrease pointer by 1.
10490|  16.1k|          state = state::NO_SCHEME;
10491|  16.1k|        }
10492|  34.1k|        break;
10493|      0|      }
10494|  17.9k|      case state::SCHEME: {
  ------------------
  |  Branch (10494:7): [True: 17.9k, False: 112k]
  ------------------
10495|  17.9k|        ada_log("SCHEME ", helpers::substring(url_data, input_position));
10496|       |        // If c is an ASCII alphanumeric, U+002B (+), U+002D (-), or U+002E (.),
10497|       |        // append c, lowercased, to buffer.
10498|  45.2k|        while ((input_position != input_size) &&
  ------------------
  |  Branch (10498:16): [True: 44.9k, False: 319]
  ------------------
10499|  44.9k|               (unicode::is_alnum_plus(url_data[input_position]))) {
  ------------------
  |  Branch (10499:16): [True: 27.2k, False: 17.6k]
  ------------------
10500|  27.2k|          input_position++;
10501|  27.2k|        }
10502|       |        // Otherwise, if c is U+003A (:), then:
10503|  17.9k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (10503:13): [True: 17.6k, False: 319]
  ------------------
10504|  17.6k|            (url_data[input_position] == ':')) {
  ------------------
  |  Branch (10504:13): [True: 17.4k, False: 249]
  ------------------
10505|  17.4k|          ada_log("SCHEME the scheme should be ",
10506|  17.4k|                  url_data.substr(0, input_position));
10507|       |          if constexpr (result_type_is_ada_url) {
10508|       |            if (!url.parse_scheme(url_data.substr(0, input_position))) {
10509|       |              return url;
10510|       |            }
10511|  17.4k|          } else {
10512|       |            // we pass the colon along instead of painfully adding it back.
10513|  17.4k|            if (!url.parse_scheme_with_colon(
  ------------------
  |  Branch (10513:17): [True: 0, False: 17.4k]
  ------------------
10514|  17.4k|                    url_data.substr(0, input_position + 1))) {
10515|      0|              return url;
10516|      0|            }
10517|  17.4k|          }
10518|  17.4k|          ada_log("SCHEME the scheme is ", url.get_protocol());
10519|       |
10520|       |          // If url's scheme is "file", then:
10521|       |          // NOLINTNEXTLINE(bugprone-branch-clone)
10522|  17.4k|          if (url.type == scheme::type::FILE) {
  ------------------
  |  Branch (10522:15): [True: 2.40k, False: 15.0k]
  ------------------
10523|       |            // Set state to file state.
10524|  2.40k|            state = state::FILE;
10525|  2.40k|          }
10526|       |          // Otherwise, if url is special, base is non-null, and base's scheme
10527|       |          // is url's scheme: Note: Doing base_url->scheme is unsafe if base_url
10528|       |          // != nullptr is false.
10529|  15.0k|          else if (url.is_special() && base_url != nullptr &&
  ------------------
  |  Branch (10529:20): [True: 10.5k, False: 4.43k]
  |  Branch (10529:40): [True: 1.49k, False: 9.08k]
  ------------------
10530|  1.49k|                   base_url->type == url.type) {
  ------------------
  |  Branch (10530:20): [True: 144, False: 1.34k]
  ------------------
10531|       |            // Set state to special relative or authority state.
10532|    144|            state = state::SPECIAL_RELATIVE_OR_AUTHORITY;
10533|    144|          }
10534|       |          // Otherwise, if url is special, set state to special authority
10535|       |          // slashes state.
10536|  14.8k|          else if (url.is_special()) {
  ------------------
  |  Branch (10536:20): [True: 10.4k, False: 4.43k]
  ------------------
10537|  10.4k|            state = state::SPECIAL_AUTHORITY_SLASHES;
10538|  10.4k|          }
10539|       |          // Otherwise, if remaining starts with an U+002F (/), set state to
10540|       |          // path or authority state and increase pointer by 1.
10541|  4.43k|          else if (input_position + 1 < input_size &&
  ------------------
  |  Branch (10541:20): [True: 2.68k, False: 1.75k]
  ------------------
10542|  2.68k|                   url_data[input_position + 1] == '/') {
  ------------------
  |  Branch (10542:20): [True: 1.83k, False: 853]
  ------------------
10543|  1.83k|            state = state::PATH_OR_AUTHORITY;
10544|  1.83k|            input_position++;
10545|  1.83k|          }
10546|       |          // Otherwise, set url's path to the empty string and set state to
10547|       |          // opaque path state.
10548|  2.60k|          else {
10549|  2.60k|            state = state::OPAQUE_PATH;
10550|  2.60k|          }
10551|  17.4k|        }
10552|       |        // Otherwise, if state override is not given, set buffer to the empty
10553|       |        // string, state to no scheme state, and start over (from the first code
10554|       |        // point in input).
10555|    568|        else {
10556|    568|          state = state::NO_SCHEME;
10557|    568|          input_position = 0;
10558|    568|          break;
10559|    568|        }
10560|  17.4k|        input_position++;
10561|  17.4k|        break;
10562|  17.9k|      }
10563|  16.7k|      case state::NO_SCHEME: {
  ------------------
  |  Branch (10563:7): [True: 16.7k, False: 114k]
  ------------------
10564|  16.7k|        ada_log("NO_SCHEME ", helpers::substring(url_data, input_position));
10565|       |        // If base is null, or base has an opaque path and c is not U+0023 (#),
10566|       |        // validation error, return failure.
10567|  16.7k|        if (base_url == nullptr ||
  ------------------
  |  Branch (10567:13): [True: 15.7k, False: 919]
  ------------------
10568|  15.8k|            (base_url->has_opaque_path && !fragment.has_value())) {
  ------------------
  |  Branch (10568:14): [True: 212, False: 707]
  |  Branch (10568:43): [True: 45, False: 167]
  ------------------
10569|  15.8k|          ada_log("NO_SCHEME validation error");
10570|  15.8k|          url.is_valid = false;
10571|  15.8k|          return url;
10572|  15.8k|        }
10573|       |        // Otherwise, if base has an opaque path and c is U+0023 (#),
10574|       |        // set url's scheme to base's scheme, url's path to base's path, url's
10575|       |        // query to base's query, and set state to fragment state.
10576|    874|        else if (base_url->has_opaque_path && fragment.has_value() &&
  ------------------
  |  Branch (10576:18): [True: 167, False: 707]
  |  Branch (10576:47): [True: 167, False: 0]
  ------------------
10577|    167|                 input_position == input_size) {
  ------------------
  |  Branch (10577:18): [True: 86, False: 81]
  ------------------
10578|     86|          ada_log("NO_SCHEME opaque base with fragment");
10579|     86|          url.copy_scheme(*base_url);
10580|     86|          url.has_opaque_path = base_url->has_opaque_path;
10581|       |
10582|       |          if constexpr (result_type_is_ada_url) {
10583|       |            url.path = base_url->path;
10584|       |            url.query = base_url->query;
10585|     86|          } else {
10586|     86|            url.update_base_pathname(base_url->get_pathname());
10587|     86|            if (base_url->has_search()) {
  ------------------
  |  Branch (10587:17): [True: 41, False: 45]
  ------------------
10588|       |              // get_search() returns "" for an empty query string (URL ends
10589|       |              // with '?'). update_base_search("") would incorrectly clear the
10590|       |              // query, so pass "?" to preserve the empty query distinction.
10591|     41|              auto s = base_url->get_search();
10592|     41|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (10592:38): [True: 12, False: 29]
  ------------------
10593|     41|            }
10594|     86|          }
10595|     86|          url.update_unencoded_base_hash(*fragment);
10596|     86|          return url;
10597|     86|        }
10598|       |        // Otherwise, if base's scheme is not "file", set state to relative
10599|       |        // state and decrease pointer by 1.
10600|       |        // NOLINTNEXTLINE(bugprone-branch-clone)
10601|    788|        else if (base_url->type != scheme::type::FILE) {
  ------------------
  |  Branch (10601:18): [True: 480, False: 308]
  ------------------
10602|    480|          ada_log("NO_SCHEME non-file relative path");
10603|    480|          state = state::RELATIVE_SCHEME;
10604|    480|        }
10605|       |        // Otherwise, set state to file state and decrease pointer by 1.
10606|    308|        else {
10607|    308|          ada_log("NO_SCHEME file base type");
10608|    308|          state = state::FILE;
10609|    308|        }
10610|    788|        break;
10611|  16.7k|      }
10612|  11.1k|      case state::AUTHORITY: {
  ------------------
  |  Branch (10612:7): [True: 11.1k, False: 119k]
  ------------------
10613|  11.1k|        ada_log("AUTHORITY ", helpers::substring(url_data, input_position));
10614|       |        // most URLs have no @. Having no @ tells us that we don't have to worry
10615|       |        // about AUTHORITY. Of course, we could have @ and still not have to
10616|       |        // worry about AUTHORITY.
10617|       |        // TODO: Instead of just collecting a bool, collect the location of the
10618|       |        // '@' and do something useful with it.
10619|       |        // TODO: We could do various processing early on, using a single pass
10620|       |        // over the string to collect information about it, e.g., telling us
10621|       |        // whether there is a @ and if so, where (or how many).
10622|       |
10623|       |        // Check if url data contains an @.
10624|  11.1k|        if (url_data.find('@', input_position) == std::string_view::npos) {
  ------------------
  |  Branch (10624:13): [True: 10.1k, False: 976]
  ------------------
10625|  10.1k|          state = state::HOST;
10626|  10.1k|          break;
10627|  10.1k|        }
10628|    976|        bool at_sign_seen{false};
10629|    976|        bool password_token_seen{false};
10630|       |        /**
10631|       |         * We expect something of the sort...
10632|       |         * https://user:pass@example.com:1234/foo/bar?baz#quux
10633|       |         * --------^
10634|       |         */
10635|  7.21k|        do {
10636|  7.21k|          std::string_view view = url_data.substr(input_position);
10637|       |          // The delimiters are @, /, ? \\.
10638|  7.21k|          size_t location =
10639|  7.21k|              url.is_special() ? helpers::find_authority_delimiter_special(view)
  ------------------
  |  Branch (10639:15): [True: 6.45k, False: 758]
  ------------------
10640|  7.21k|                               : helpers::find_authority_delimiter(view);
10641|  7.21k|          std::string_view authority_view = view.substr(0, location);
10642|  7.21k|          size_t end_of_authority = input_position + authority_view.size();
10643|       |          // If c is U+0040 (@), then:
10644|  7.21k|          if ((end_of_authority != input_size) &&
  ------------------
  |  Branch (10644:15): [True: 6.56k, False: 643]
  ------------------
10645|  6.56k|              (url_data[end_of_authority] == '@')) {
  ------------------
  |  Branch (10645:15): [True: 6.23k, False: 333]
  ------------------
10646|       |            // If atSignSeen is true, then prepend "%40" to buffer.
10647|  6.23k|            if (at_sign_seen) {
  ------------------
  |  Branch (10647:17): [True: 5.32k, False: 909]
  ------------------
10648|  5.32k|              if (password_token_seen) {
  ------------------
  |  Branch (10648:19): [True: 2.22k, False: 3.09k]
  ------------------
10649|       |                if constexpr (result_type_is_ada_url) {
10650|       |                  url.password += "%40";
10651|  2.22k|                } else {
10652|  2.22k|                  url.append_base_password("%40");
10653|  2.22k|                }
10654|  3.09k|              } else {
10655|       |                if constexpr (result_type_is_ada_url) {
10656|       |                  url.username += "%40";
10657|  3.09k|                } else {
10658|  3.09k|                  url.append_base_username("%40");
10659|  3.09k|                }
10660|  3.09k|              }
10661|  5.32k|            }
10662|       |
10663|  6.23k|            at_sign_seen = true;
10664|       |
10665|  6.23k|            if (!password_token_seen) {
  ------------------
  |  Branch (10665:17): [True: 4.00k, False: 2.22k]
  ------------------
10666|  4.00k|              size_t password_token_location = authority_view.find(':');
10667|  4.00k|              password_token_seen =
10668|  4.00k|                  password_token_location != std::string_view::npos;
10669|       |
10670|  4.00k|              if constexpr (store_values) {
10671|  4.00k|                if (!password_token_seen) {
  ------------------
  |  Branch (10671:21): [True: 3.63k, False: 374]
  ------------------
10672|       |                  if constexpr (result_type_is_ada_url) {
10673|       |                    url.username += unicode::percent_encode(
10674|       |                        authority_view,
10675|       |                        character_sets::USERINFO_PERCENT_ENCODE);
10676|  3.63k|                  } else {
10677|  3.63k|                    url.append_base_username(unicode::percent_encode(
10678|  3.63k|                        authority_view,
10679|  3.63k|                        character_sets::USERINFO_PERCENT_ENCODE));
10680|  3.63k|                  }
10681|  3.63k|                } else {
10682|       |                  if constexpr (result_type_is_ada_url) {
10683|       |                    url.username += unicode::percent_encode(
10684|       |                        authority_view.substr(0, password_token_location),
10685|       |                        character_sets::USERINFO_PERCENT_ENCODE);
10686|       |                    url.password += unicode::percent_encode(
10687|       |                        authority_view.substr(password_token_location + 1),
10688|       |                        character_sets::USERINFO_PERCENT_ENCODE);
10689|    374|                  } else {
10690|    374|                    url.append_base_username(unicode::percent_encode(
10691|    374|                        authority_view.substr(0, password_token_location),
10692|    374|                        character_sets::USERINFO_PERCENT_ENCODE));
10693|    374|                    url.append_base_password(unicode::percent_encode(
10694|    374|                        authority_view.substr(password_token_location + 1),
10695|    374|                        character_sets::USERINFO_PERCENT_ENCODE));
10696|    374|                  }
10697|    374|                }
10698|  4.00k|              }
10699|  4.00k|            } else if constexpr (store_values) {
10700|       |              if constexpr (result_type_is_ada_url) {
10701|       |                url.password += unicode::percent_encode(
10702|       |                    authority_view, character_sets::USERINFO_PERCENT_ENCODE);
10703|  2.22k|              } else {
10704|  2.22k|                url.append_base_password(unicode::percent_encode(
10705|  2.22k|                    authority_view, character_sets::USERINFO_PERCENT_ENCODE));
10706|  2.22k|              }
10707|  2.22k|            }
10708|  6.23k|          }
10709|       |          // Otherwise, if one of the following is true:
10710|       |          // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
10711|       |          // - url is special and c is U+005C (\)
10712|    976|          else if (end_of_authority == input_size ||
  ------------------
  |  Branch (10712:20): [True: 643, False: 333]
  ------------------
10713|    333|                   url_data[end_of_authority] == '/' ||
  ------------------
  |  Branch (10713:20): [True: 295, False: 38]
  ------------------
10714|     38|                   url_data[end_of_authority] == '?' ||
  ------------------
  |  Branch (10714:20): [True: 30, False: 8]
  ------------------
10715|    976|                   (url.is_special() && url_data[end_of_authority] == '\\')) {
  ------------------
  |  Branch (10715:21): [True: 8, False: 0]
  |  Branch (10715:41): [True: 8, False: 0]
  ------------------
10716|       |            // If atSignSeen is true and authority_view is the empty string,
10717|       |            // validation error, return failure.
10718|    976|            if (at_sign_seen && authority_view.empty()) {
  ------------------
  |  Branch (10718:17): [True: 909, False: 67]
  |  Branch (10718:33): [True: 283, False: 626]
  ------------------
10719|    283|              url.is_valid = false;
10720|    283|              return url;
10721|    283|            }
10722|    693|            state = state::HOST;
10723|    693|            break;
10724|    976|          }
10725|  6.23k|          if (end_of_authority == input_size) {
  ------------------
  |  Branch (10725:15): [True: 0, False: 6.23k]
  ------------------
10726|      0|            if constexpr (store_values) {
10727|      0|              if (fragment.has_value()) {
  ------------------
  |  Branch (10727:19): [True: 0, False: 0]
  ------------------
10728|      0|                url.update_unencoded_base_hash(*fragment);
10729|      0|              }
10730|      0|            }
10731|      0|            return url;
10732|      0|          }
10733|  6.23k|          input_position = end_of_authority + 1;
10734|  6.23k|        } while (true);
  ------------------
  |  Branch (10734:18): [True: 6.23k, Folded]
  ------------------
10735|       |
10736|    693|        break;
10737|    976|      }
10738|    693|      case state::SPECIAL_RELATIVE_OR_AUTHORITY: {
  ------------------
  |  Branch (10738:7): [True: 144, False: 130k]
  ------------------
10739|    144|        ada_log("SPECIAL_RELATIVE_OR_AUTHORITY ",
10740|    144|                helpers::substring(url_data, input_position));
10741|       |
10742|       |        // If c is U+002F (/) and remaining starts with U+002F (/),
10743|       |        // then set state to special authority ignore slashes state and increase
10744|       |        // pointer by 1.
10745|    144|        if (url_data.substr(input_position, 2) == "//") {
  ------------------
  |  Branch (10745:13): [True: 53, False: 91]
  ------------------
10746|     53|          state = state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
10747|     53|          input_position += 2;
10748|     91|        } else {
10749|       |          // Otherwise, validation error, set state to relative state and
10750|       |          // decrease pointer by 1.
10751|     91|          state = state::RELATIVE_SCHEME;
10752|     91|        }
10753|       |
10754|    144|        break;
10755|    976|      }
10756|  1.83k|      case state::PATH_OR_AUTHORITY: {
  ------------------
  |  Branch (10756:7): [True: 1.83k, False: 129k]
  ------------------
10757|  1.83k|        ada_log("PATH_OR_AUTHORITY ",
10758|  1.83k|                helpers::substring(url_data, input_position));
10759|       |
10760|       |        // If c is U+002F (/), then set state to authority state.
10761|  1.83k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (10761:13): [True: 1.72k, False: 105]
  ------------------
10762|  1.72k|            (url_data[input_position] == '/')) {
  ------------------
  |  Branch (10762:13): [True: 652, False: 1.07k]
  ------------------
10763|    652|          state = state::AUTHORITY;
10764|    652|          input_position++;
10765|  1.18k|        } else {
10766|       |          // Otherwise, set state to path state, and decrease pointer by 1.
10767|  1.18k|          state = state::PATH;
10768|  1.18k|        }
10769|       |
10770|  1.83k|        break;
10771|    976|      }
10772|    571|      case state::RELATIVE_SCHEME: {
  ------------------
  |  Branch (10772:7): [True: 571, False: 130k]
  ------------------
10773|    571|        ada_log("RELATIVE_SCHEME ",
10774|    571|                helpers::substring(url_data, input_position));
10775|       |
10776|       |        // Set url's scheme to base's scheme.
10777|    571|        url.copy_scheme(*base_url);
10778|       |
10779|       |        // If c is U+002F (/), then set state to relative slash state.
10780|    571|        if ((input_position != input_size) &&
  ------------------
  |  Branch (10780:13): [True: 439, False: 132]
  ------------------
10781|       |            // NOLINTNEXTLINE(bugprone-branch-clone)
10782|    439|            (url_data[input_position] == '/')) {
  ------------------
  |  Branch (10782:13): [True: 68, False: 371]
  ------------------
10783|     68|          ada_log(
10784|     68|              "RELATIVE_SCHEME if c is U+002F (/), then set state to relative "
10785|     68|              "slash state");
10786|     68|          state = state::RELATIVE_SLASH;
10787|    503|        } else if (url.is_special() && (input_position != input_size) &&
  ------------------
  |  Branch (10787:20): [True: 315, False: 188]
  |  Branch (10787:40): [True: 223, False: 92]
  ------------------
10788|    223|                   (url_data[input_position] == '\\')) {
  ------------------
  |  Branch (10788:20): [True: 4, False: 219]
  ------------------
10789|       |          // Otherwise, if url is special and c is U+005C (\), validation error,
10790|       |          // set state to relative slash state.
10791|      4|          ada_log(
10792|      4|              "RELATIVE_SCHEME  if url is special and c is U+005C, validation "
10793|      4|              "error, set state to relative slash state");
10794|      4|          state = state::RELATIVE_SLASH;
10795|    499|        } else {
10796|    499|          ada_log("RELATIVE_SCHEME otherwise");
10797|       |          // Set url's username to base's username, url's password to base's
10798|       |          // password, url's host to base's host, url's port to base's port,
10799|       |          // url's path to a clone of base's path, and url's query to base's
10800|       |          // query.
10801|       |          if constexpr (result_type_is_ada_url) {
10802|       |            url.username = base_url->username;
10803|       |            url.password = base_url->password;
10804|       |            url.host = base_url->host;
10805|       |            url.port = base_url->port;
10806|       |            // cloning the base path includes cloning the has_opaque_path flag
10807|       |            url.has_opaque_path = base_url->has_opaque_path;
10808|       |            url.path = base_url->path;
10809|       |            url.query = base_url->query;
10810|    499|          } else {
10811|    499|            url.update_base_authority(base_url->get_href(),
10812|    499|                                      base_url->get_components());
10813|    499|            url.update_host_to_base_host(base_url->get_hostname());
10814|    499|            url.update_base_port(base_url->retrieve_base_port());
10815|       |            // cloning the base path includes cloning the has_opaque_path flag
10816|    499|            url.has_opaque_path = base_url->has_opaque_path;
10817|    499|            url.update_base_pathname(base_url->get_pathname());
10818|    499|            if (base_url->has_search()) {
  ------------------
  |  Branch (10818:17): [True: 85, False: 414]
  ------------------
10819|       |              // get_search() returns "" for an empty query string (URL ends
10820|       |              // with '?'). update_base_search("") would incorrectly clear the
10821|       |              // query, so pass "?" to preserve the empty query distinction.
10822|     85|              auto s = base_url->get_search();
10823|     85|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (10823:38): [True: 41, False: 44]
  ------------------
10824|     85|            }
10825|    499|          }
10826|       |
10827|    499|          url.has_opaque_path = base_url->has_opaque_path;
10828|       |
10829|       |          // If c is U+003F (?), then set url's query to the empty string, and
10830|       |          // state to query state.
10831|    499|          if ((input_position != input_size) &&
  ------------------
  |  Branch (10831:15): [True: 367, False: 132]
  ------------------
10832|    367|              (url_data[input_position] == '?')) {
  ------------------
  |  Branch (10832:15): [True: 27, False: 340]
  ------------------
10833|     27|            state = state::QUERY;
10834|     27|          }
10835|       |          // Otherwise, if c is not the EOF code point:
10836|    472|          else if (input_position != input_size) {
  ------------------
  |  Branch (10836:20): [True: 340, False: 132]
  ------------------
10837|       |            // Set url's query to null.
10838|    340|            url.clear_search();
10839|       |            if constexpr (result_type_is_ada_url) {
10840|       |              // Shorten url's path.
10841|       |              helpers::shorten_path(url.path, url.type);
10842|    340|            } else {
10843|    340|              std::string_view path = url.get_pathname();
10844|    340|              if (helpers::shorten_path(path, url.type)) {
  ------------------
  |  Branch (10844:19): [True: 279, False: 61]
  ------------------
10845|    279|                url.update_base_pathname(std::move(std::string(path)));
10846|    279|              }
10847|    340|            }
10848|       |            // Set state to path state and decrease pointer by 1.
10849|    340|            state = state::PATH;
10850|    340|            break;
10851|    340|          }
10852|    499|        }
10853|    231|        input_position++;
10854|    231|        break;
10855|    571|      }
10856|     72|      case state::RELATIVE_SLASH: {
  ------------------
  |  Branch (10856:7): [True: 72, False: 130k]
  ------------------
10857|     72|        ada_log("RELATIVE_SLASH ",
10858|     72|                helpers::substring(url_data, input_position));
10859|       |
10860|       |        // If url is special and c is U+002F (/) or U+005C (\), then:
10861|       |        // NOLINTNEXTLINE(bugprone-branch-clone)
10862|     72|        if (url.is_special() && (input_position != input_size) &&
  ------------------
  |  Branch (10862:13): [True: 50, False: 22]
  |  Branch (10862:33): [True: 35, False: 15]
  ------------------
10863|     35|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (10863:14): [True: 4, False: 31]
  ------------------
10864|     31|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (10864:14): [True: 1, False: 30]
  ------------------
10865|       |          // Set state to special authority ignore slashes state.
10866|      5|          state = state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
10867|      5|        }
10868|       |        // Otherwise, if c is U+002F (/), then set state to authority state.
10869|     67|        else if ((input_position != input_size) &&
  ------------------
  |  Branch (10869:18): [True: 45, False: 22]
  ------------------
10870|     45|                 (url_data[input_position] == '/')) {
  ------------------
  |  Branch (10870:18): [True: 6, False: 39]
  ------------------
10871|      6|          state = state::AUTHORITY;
10872|      6|        }
10873|       |        // Otherwise, set
10874|       |        // - url's username to base's username,
10875|       |        // - url's password to base's password,
10876|       |        // - url's host to base's host,
10877|       |        // - url's port to base's port,
10878|       |        // - state to path state, and then, decrease pointer by 1.
10879|     61|        else {
10880|       |          if constexpr (result_type_is_ada_url) {
10881|       |            url.username = base_url->username;
10882|       |            url.password = base_url->password;
10883|       |            url.host = base_url->host;
10884|       |            url.port = base_url->port;
10885|     61|          } else {
10886|     61|            url.update_base_authority(base_url->get_href(),
10887|     61|                                      base_url->get_components());
10888|     61|            url.update_host_to_base_host(base_url->get_hostname());
10889|     61|            url.update_base_port(base_url->retrieve_base_port());
10890|     61|          }
10891|     61|          state = state::PATH;
10892|     61|          break;
10893|     61|        }
10894|       |
10895|     11|        input_position++;
10896|     11|        break;
10897|     72|      }
10898|  10.4k|      case state::SPECIAL_AUTHORITY_SLASHES: {
  ------------------
  |  Branch (10898:7): [True: 10.4k, False: 120k]
  ------------------
10899|  10.4k|        ada_log("SPECIAL_AUTHORITY_SLASHES ",
10900|  10.4k|                helpers::substring(url_data, input_position));
10901|       |
10902|       |        // If c is U+002F (/) and remaining starts with U+002F (/),
10903|       |        // then set state to special authority ignore slashes state and increase
10904|       |        // pointer by 1.
10905|  10.4k|        if (url_data.substr(input_position, 2) == "//") {
  ------------------
  |  Branch (10905:13): [True: 3.26k, False: 7.16k]
  ------------------
10906|  3.26k|          input_position += 2;
10907|  3.26k|        }
10908|       |
10909|  10.4k|        [[fallthrough]];
10910|  10.4k|      }
10911|  10.4k|      case state::SPECIAL_AUTHORITY_IGNORE_SLASHES: {
  ------------------
  |  Branch (10911:7): [True: 58, False: 130k]
  ------------------
10912|  10.4k|        ada_log("SPECIAL_AUTHORITY_IGNORE_SLASHES ",
10913|  10.4k|                helpers::substring(url_data, input_position));
10914|       |
10915|       |        // If c is neither U+002F (/) nor U+005C (\), then set state to
10916|       |        // authority state and decrease pointer by 1.
10917|  11.5k|        while ((input_position != input_size) &&
  ------------------
  |  Branch (10917:16): [True: 11.4k, False: 73]
  ------------------
10918|  11.4k|               ((url_data[input_position] == '/') ||
  ------------------
  |  Branch (10918:17): [True: 655, False: 10.8k]
  ------------------
10919|  10.8k|                (url_data[input_position] == '\\'))) {
  ------------------
  |  Branch (10919:17): [True: 419, False: 10.4k]
  ------------------
10920|  1.07k|          input_position++;
10921|  1.07k|        }
10922|  10.4k|        state = state::AUTHORITY;
10923|       |
10924|  10.4k|        break;
10925|  10.4k|      }
10926|    819|      case state::QUERY: {
  ------------------
  |  Branch (10926:7): [True: 819, False: 130k]
  ------------------
10927|    819|        ada_log("QUERY ", helpers::substring(url_data, input_position));
10928|    819|        if constexpr (store_values) {
10929|       |          // Let queryPercentEncodeSet be the special-query percent-encode set
10930|       |          // if url is special; otherwise the query percent-encode set.
10931|    819|          const uint8_t* query_percent_encode_set =
10932|    819|              url.is_special() ? character_sets::SPECIAL_QUERY_PERCENT_ENCODE
  ------------------
  |  Branch (10932:15): [True: 393, False: 426]
  ------------------
10933|    819|                               : character_sets::QUERY_PERCENT_ENCODE;
10934|       |
10935|       |          // Percent-encode after encoding, with encoding, buffer, and
10936|       |          // queryPercentEncodeSet, and append the result to url's query.
10937|    819|          url.update_base_search(url_data.substr(input_position),
10938|    819|                                 query_percent_encode_set);
10939|    819|          ada_log("QUERY update_base_search completed ");
10940|    819|          if (fragment.has_value()) {
  ------------------
  |  Branch (10940:15): [True: 132, False: 687]
  ------------------
10941|    132|            url.update_unencoded_base_hash(*fragment);
10942|    132|          }
10943|    819|        }
10944|    819|        return url;
10945|  10.4k|      }
10946|  10.8k|      case state::HOST: {
  ------------------
  |  Branch (10946:7): [True: 10.8k, False: 120k]
  ------------------
10947|  10.8k|        ada_log("HOST ", helpers::substring(url_data, input_position));
10948|       |
10949|  10.8k|        std::string_view host_view = url_data.substr(input_position);
10950|  10.8k|        auto [location, found_colon] =
10951|  10.8k|            helpers::get_host_delimiter_location(url.is_special(), host_view);
10952|  10.8k|        input_position = (location != std::string_view::npos)
  ------------------
  |  Branch (10952:26): [True: 10.8k, False: 0]
  ------------------
10953|  10.8k|                             ? input_position + location
10954|  10.8k|                             : input_size;
10955|       |        // Otherwise, if c is U+003A (:) and insideBrackets is false, then:
10956|       |        // Note: the 'found_colon' value is true if and only if a colon was
10957|       |        // encountered while not inside brackets.
10958|  10.8k|        if (found_colon) {
  ------------------
  |  Branch (10958:13): [True: 1.55k, False: 9.30k]
  ------------------
10959|       |          // If buffer is the empty string, validation error, return failure.
10960|       |          // Let host be the result of host parsing buffer with url is not
10961|       |          // special.
10962|  1.55k|          ada_log("HOST parsing ", host_view);
10963|  1.55k|          if (!url.parse_host(host_view)) {
  ------------------
  |  Branch (10963:15): [True: 153, False: 1.40k]
  ------------------
10964|    153|            return url;
10965|    153|          }
10966|  1.40k|          ada_log("HOST parsing results in ", url.get_hostname());
10967|       |          // Set url's host to host, buffer to the empty string, and state to
10968|       |          // port state.
10969|  1.40k|          state = state::PORT;
10970|  1.40k|          input_position++;
10971|  1.40k|        }
10972|       |        // Otherwise, if one of the following is true:
10973|       |        // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
10974|       |        // - url is special and c is U+005C (\)
10975|       |        // The get_host_delimiter_location function either brings us to
10976|       |        // the colon outside of the bracket, or to one of those characters.
10977|  9.30k|        else {
10978|       |          // If url is special and host_view is the empty string, validation
10979|       |          // error, return failure.
10980|  9.30k|          if (host_view.empty() && url.is_special()) {
  ------------------
  |  Branch (10980:15): [True: 143, False: 9.15k]
  |  Branch (10980:36): [True: 76, False: 67]
  ------------------
10981|     76|            url.is_valid = false;
10982|     76|            return url;
10983|     76|          }
10984|  9.22k|          ada_log("HOST parsing ", host_view, " href=", url.get_href());
10985|       |          // Let host be the result of host parsing host_view with url is not
10986|       |          // special.
10987|  9.22k|          if (host_view.empty()) {
  ------------------
  |  Branch (10987:15): [True: 67, False: 9.15k]
  ------------------
10988|     67|            url.update_base_hostname("");
10989|  9.15k|          } else if (!url.parse_host(host_view)) {
  ------------------
  |  Branch (10989:22): [True: 2.39k, False: 6.75k]
  ------------------
10990|  2.39k|            return url;
10991|  2.39k|          }
10992|  6.82k|          ada_log("HOST parsing results in ", url.get_hostname(),
10993|  6.82k|                  " href=", url.get_href());
10994|       |
10995|       |          // Set url's host to host, and state to path start state.
10996|  6.82k|          state = state::PATH_START;
10997|  6.82k|        }
10998|       |
10999|  8.23k|        break;
11000|  10.8k|      }
11001|  8.23k|      case state::OPAQUE_PATH: {
  ------------------
  |  Branch (11001:7): [True: 2.60k, False: 128k]
  ------------------
11002|  2.60k|        ada_log("OPAQUE_PATH ", helpers::substring(url_data, input_position));
11003|       |        // Opaque path, query, and fragment are structurally always valid:
11004|       |        // the parser would just percent-encode whatever is there. When we
11005|       |        // are not storing values (can_parse), we can return immediately.
11006|       |        // We must set has_opaque_path = true before returning so that when
11007|       |        // this URL is used as an internal base inside can_parse, NO_SCHEME
11008|       |        // correctly rejects relative inputs against an opaque-path base
11009|       |        // (e.g. can_parse("", &"W:") must return false).
11010|       |        if constexpr (!store_values) {
11011|       |          url.has_opaque_path = true;
11012|       |          return url;
11013|       |        }
11014|  2.60k|        std::string_view view = url_data.substr(input_position);
11015|       |        // If c is U+003F (?), then set url's query to the empty string and
11016|       |        // state to query state.
11017|  2.60k|        size_t location = view.find('?');
11018|  2.60k|        if (location != std::string_view::npos) {
  ------------------
  |  Branch (11018:13): [True: 280, False: 2.32k]
  ------------------
11019|    280|          view.remove_suffix(view.size() - location);
11020|    280|          state = state::QUERY;
11021|    280|          input_position += location + 1;
11022|  2.32k|        } else {
11023|  2.32k|          input_position = input_size + 1;
11024|  2.32k|        }
11025|  2.60k|        url.has_opaque_path = true;
11026|       |
11027|       |        // This is a really unlikely scenario in real world. We should not seek
11028|       |        // to optimize it.
11029|  2.60k|        if (view.ends_with(' ')) {
  ------------------
  |  Branch (11029:13): [True: 75, False: 2.53k]
  ------------------
11030|     75|          std::string modified_view =
11031|     75|              std::string(view.substr(0, view.size() - 1)) + "%20";
11032|     75|          url.update_base_pathname(unicode::percent_encode(
11033|     75|              modified_view, character_sets::C0_CONTROL_PERCENT_ENCODE));
11034|  2.53k|        } else {
11035|  2.53k|          url.update_base_pathname(unicode::percent_encode(
11036|  2.53k|              view, character_sets::C0_CONTROL_PERCENT_ENCODE));
11037|  2.53k|        }
11038|  2.60k|        break;
11039|  10.8k|      }
11040|  1.40k|      case state::PORT: {
  ------------------
  |  Branch (11040:7): [True: 1.40k, False: 129k]
  ------------------
11041|  1.40k|        ada_log("PORT ", helpers::substring(url_data, input_position));
11042|  1.40k|        std::string_view port_view = url_data.substr(input_position);
11043|  1.40k|        input_position += url.parse_port(port_view, true);
11044|  1.40k|        if (!url.is_valid) {
  ------------------
  |  Branch (11044:13): [True: 100, False: 1.30k]
  ------------------
11045|    100|          return url;
11046|    100|        }
11047|  1.30k|        state = state::PATH_START;
11048|  1.30k|        [[fallthrough]];
11049|  1.30k|      }
11050|  9.70k|      case state::PATH_START: {
  ------------------
  |  Branch (11050:7): [True: 8.39k, False: 122k]
  ------------------
11051|  9.70k|        ada_log("PATH_START ", helpers::substring(url_data, input_position));
11052|       |        // Path, query, and fragment are structurally always valid: the
11053|       |        // parser would just percent-encode whatever is there. When we are
11054|       |        // not storing values (can_parse), we can return immediately since
11055|       |        // no subsequent state can invalidate the URL.
11056|       |        if constexpr (!store_values) {
11057|       |          return url;
11058|       |        }
11059|       |
11060|       |        // If url is special, then:
11061|  9.70k|        if (url.is_special()) {
  ------------------
  |  Branch (11061:13): [True: 9.19k, False: 509]
  ------------------
11062|       |          // Set state to path state.
11063|  9.19k|          state = state::PATH;
11064|       |
11065|       |          // Optimization: Avoiding going into PATH state improves the
11066|       |          // performance of urls ending with /.
11067|  9.19k|          if (input_position == input_size) {
  ------------------
  |  Branch (11067:15): [True: 4.43k, False: 4.76k]
  ------------------
11068|  4.43k|            if constexpr (store_values) {
11069|  4.43k|              url.update_base_pathname("/");
11070|  4.43k|              if (fragment.has_value()) {
  ------------------
  |  Branch (11070:19): [True: 91, False: 4.33k]
  ------------------
11071|     91|                url.update_unencoded_base_hash(*fragment);
11072|     91|              }
11073|  4.43k|            }
11074|  4.43k|            return url;
11075|  4.43k|          }
11076|       |          // If c is neither U+002F (/) nor U+005C (\), then decrease pointer
11077|       |          // by 1. We know that (input_position == input_size) is impossible
11078|       |          // here, because of the previous if-check.
11079|  4.76k|          if ((url_data[input_position] != '/') &&
  ------------------
  |  Branch (11079:15): [True: 214, False: 4.55k]
  ------------------
11080|    214|              (url_data[input_position] != '\\')) {
  ------------------
  |  Branch (11080:15): [True: 188, False: 26]
  ------------------
11081|    188|            break;
11082|    188|          }
11083|  4.76k|        }
11084|       |        // Otherwise, if state override is not given and c is U+003F (?),
11085|       |        // set url's query to the empty string and state to query state.
11086|    509|        else if ((input_position != input_size) &&
  ------------------
  |  Branch (11086:18): [True: 152, False: 357]
  ------------------
11087|    152|                 (url_data[input_position] == '?')) {
  ------------------
  |  Branch (11087:18): [True: 51, False: 101]
  ------------------
11088|     51|          state = state::QUERY;
11089|     51|        }
11090|       |        // Otherwise, if c is not the EOF code point:
11091|    458|        else if (input_position != input_size) {
  ------------------
  |  Branch (11091:18): [True: 101, False: 357]
  ------------------
11092|       |          // Set state to path state.
11093|    101|          state = state::PATH;
11094|       |
11095|       |          // If c is not U+002F (/), then decrease pointer by 1.
11096|    101|          if (url_data[input_position] != '/') {
  ------------------
  |  Branch (11096:15): [True: 0, False: 101]
  ------------------
11097|      0|            break;
11098|      0|          }
11099|    101|        }
11100|       |
11101|  5.08k|        input_position++;
11102|  5.08k|        break;
11103|  9.70k|      }
11104|  7.36k|      case state::PATH: {
  ------------------
  |  Branch (11104:7): [True: 7.36k, False: 123k]
  ------------------
11105|  7.36k|        ada_log("PATH ", helpers::substring(url_data, input_position));
11106|       |        // Path, query, and fragment are structurally always valid: the
11107|       |        // parser would just percent-encode whatever is there. When we are
11108|       |        // not storing values (can_parse), we can return immediately since
11109|       |        // no subsequent state can invalidate the URL.
11110|       |        if constexpr (!store_values) {
11111|       |          return url;
11112|       |        }
11113|  7.36k|        std::string_view view = url_data.substr(input_position);
11114|       |
11115|       |        // Most time, we do not need percent encoding.
11116|       |        // Furthermore, we can immediately locate the '?'.
11117|  7.36k|        size_t locofquestionmark = view.find('?');
11118|  7.36k|        if (locofquestionmark != std::string_view::npos) {
  ------------------
  |  Branch (11118:13): [True: 453, False: 6.90k]
  ------------------
11119|    453|          state = state::QUERY;
11120|    453|          view.remove_suffix(view.size() - locofquestionmark);
11121|    453|          input_position += locofquestionmark + 1;
11122|  6.90k|        } else {
11123|  6.90k|          input_position = input_size + 1;
11124|  6.90k|        }
11125|  7.36k|        if constexpr (store_values) {
11126|       |          if constexpr (result_type_is_ada_url) {
11127|       |            helpers::parse_prepared_path(view, url.type, url.path);
11128|  7.36k|          } else {
11129|  7.36k|            url.consume_prepared_path(view);
11130|  7.36k|            ADA_ASSERT_TRUE(url.validate());
11131|  7.36k|          }
11132|  7.36k|        }
11133|  7.36k|        break;
11134|  9.70k|      }
11135|  1.91k|      case state::FILE_SLASH: {
  ------------------
  |  Branch (11135:7): [True: 1.91k, False: 128k]
  ------------------
11136|  1.91k|        ada_log("FILE_SLASH ", helpers::substring(url_data, input_position));
11137|       |
11138|       |        // If c is U+002F (/) or U+005C (\), then:
11139|  1.91k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (11139:13): [True: 1.82k, False: 85]
  ------------------
11140|  1.82k|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (11140:14): [True: 1.73k, False: 88]
  ------------------
11141|  1.74k|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (11141:14): [True: 6, False: 82]
  ------------------
11142|  1.74k|          ada_log("FILE_SLASH c is U+002F or U+005C");
11143|       |          // Set state to file host state.
11144|  1.74k|          state = state::FILE_HOST;
11145|  1.74k|          input_position++;
11146|  1.74k|        } else {
11147|    167|          ada_log("FILE_SLASH otherwise");
11148|       |          // If base is non-null and base's scheme is "file", then:
11149|       |          // Note: it is unsafe to do base_url->scheme unless you know that
11150|       |          // base_url_has_value() is true.
11151|    167|          if (base_url != nullptr && base_url->type == scheme::type::FILE) {
  ------------------
  |  Branch (11151:15): [True: 128, False: 39]
  |  Branch (11151:38): [True: 122, False: 6]
  ------------------
11152|       |            // Set url's host to base's host.
11153|       |            if constexpr (result_type_is_ada_url) {
11154|       |              url.host = base_url->host;
11155|    122|            } else {
11156|    122|              url.update_host_to_base_host(base_url->get_host());
11157|    122|            }
11158|       |            // If the code point substring from pointer to the end of input does
11159|       |            // not start with a Windows drive letter and base's path[0] is a
11160|       |            // normalized Windows drive letter, then append base's path[0] to
11161|       |            // url's path.
11162|    122|            if (!base_url->get_pathname().empty()) {
  ------------------
  |  Branch (11162:17): [True: 122, False: 0]
  ------------------
11163|    122|              if (!checkers::is_windows_drive_letter(
  ------------------
  |  Branch (11163:19): [True: 117, False: 5]
  ------------------
11164|    122|                      url_data.substr(input_position))) {
11165|    117|                std::string_view first_base_url_path =
11166|    117|                    base_url->get_pathname().substr(1);
11167|    117|                size_t loc = first_base_url_path.find('/');
11168|    117|                if (loc != std::string_view::npos) {
  ------------------
  |  Branch (11168:21): [True: 17, False: 100]
  ------------------
11169|     17|                  helpers::resize(first_base_url_path, loc);
11170|     17|                }
11171|    117|                if (checkers::is_normalized_windows_drive_letter(
  ------------------
  |  Branch (11171:21): [True: 2, False: 115]
  ------------------
11172|    117|                        first_base_url_path)) {
11173|       |                  if constexpr (result_type_is_ada_url) {
11174|       |                    url.path += '/';
11175|       |                    url.path += first_base_url_path;
11176|      2|                  } else {
11177|      2|                    url.append_base_pathname(
11178|      2|                        helpers::concat("/", first_base_url_path));
11179|      2|                  }
11180|      2|                }
11181|    117|              }
11182|    122|            }
11183|    122|          }
11184|       |
11185|       |          // Set state to path state, and decrease pointer by 1.
11186|    167|          state = state::PATH;
11187|    167|        }
11188|       |
11189|  1.91k|        break;
11190|  9.70k|      }
11191|  1.74k|      case state::FILE_HOST: {
  ------------------
  |  Branch (11191:7): [True: 1.74k, False: 129k]
  ------------------
11192|  1.74k|        ada_log("FILE_HOST ", helpers::substring(url_data, input_position));
11193|  1.74k|        std::string_view view = url_data.substr(input_position);
11194|       |
11195|  1.74k|        size_t location = view.find_first_of("/\\?");
11196|  1.74k|        std::string_view file_host_buffer = view.substr(
11197|  1.74k|            0, (location != std::string_view::npos) ? location : view.size());
  ------------------
  |  Branch (11197:16): [True: 828, False: 917]
  ------------------
11198|       |
11199|  1.74k|        if (checkers::is_windows_drive_letter(file_host_buffer)) {
  ------------------
  |  Branch (11199:13): [True: 12, False: 1.73k]
  ------------------
11200|     12|          state = state::PATH;
11201|  1.73k|        } else if (file_host_buffer.empty()) {
  ------------------
  |  Branch (11201:20): [True: 330, False: 1.40k]
  ------------------
11202|       |          // Set url's host to the empty string.
11203|       |          if constexpr (result_type_is_ada_url) {
11204|       |            url.host = "";
11205|    330|          } else {
11206|    330|            url.update_base_hostname("");
11207|    330|          }
11208|       |          // Set state to path start state.
11209|    330|          state = state::PATH_START;
11210|  1.40k|        } else {
11211|  1.40k|          size_t consumed_bytes = file_host_buffer.size();
11212|  1.40k|          input_position += consumed_bytes;
11213|       |          // Let host be the result of host parsing buffer with url is not
11214|       |          // special.
11215|  1.40k|          if (!url.parse_host(file_host_buffer)) {
  ------------------
  |  Branch (11215:15): [True: 160, False: 1.24k]
  ------------------
11216|    160|            return url;
11217|    160|          }
11218|       |
11219|       |          if constexpr (result_type_is_ada_url) {
11220|       |            // If host is "localhost", then set host to the empty string.
11221|       |            if (url.host.has_value() && url.host.value() == "localhost") {
11222|       |              url.host = "";
11223|       |            }
11224|  1.24k|          } else {
11225|  1.24k|            if (url.get_hostname() == "localhost") {
  ------------------
  |  Branch (11225:17): [True: 6, False: 1.23k]
  ------------------
11226|      6|              url.update_base_hostname("");
11227|      6|            }
11228|  1.24k|          }
11229|       |
11230|       |          // Set buffer to the empty string and state to path start state.
11231|  1.24k|          state = state::PATH_START;
11232|  1.24k|        }
11233|       |
11234|  1.58k|        break;
11235|  1.74k|      }
11236|  2.71k|      case state::FILE: {
  ------------------
  |  Branch (11236:7): [True: 2.71k, False: 128k]
  ------------------
11237|  2.71k|        ada_log("FILE ", helpers::substring(url_data, input_position));
11238|  2.71k|        std::string_view file_view = url_data.substr(input_position);
11239|       |
11240|  2.71k|        url.set_protocol_as_file();
11241|       |        if constexpr (result_type_is_ada_url) {
11242|       |          // Set url's host to the empty string.
11243|       |          url.host = "";
11244|  2.71k|        } else {
11245|  2.71k|          url.update_base_hostname("");
11246|  2.71k|        }
11247|       |        // If c is U+002F (/) or U+005C (\), then:
11248|  2.71k|        if (input_position != input_size &&
  ------------------
  |  Branch (11248:13): [True: 2.55k, False: 154]
  ------------------
11249|  2.55k|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (11249:14): [True: 1.90k, False: 653]
  ------------------
11250|  1.91k|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (11250:14): [True: 6, False: 647]
  ------------------
11251|  1.91k|          ada_log("FILE c is U+002F or U+005C");
11252|       |          // Set state to file slash state.
11253|  1.91k|          state = state::FILE_SLASH;
11254|  1.91k|        }
11255|       |        // Otherwise, if base is non-null and base's scheme is "file":
11256|    801|        else if (base_url != nullptr && base_url->type == scheme::type::FILE) {
  ------------------
  |  Branch (11256:18): [True: 289, False: 512]
  |  Branch (11256:41): [True: 212, False: 77]
  ------------------
11257|       |          // Set url's host to base's host, url's path to a clone of base's
11258|       |          // path, and url's query to base's query.
11259|    212|          ada_log("FILE base non-null");
11260|       |          if constexpr (result_type_is_ada_url) {
11261|       |            url.host = base_url->host;
11262|       |            url.path = base_url->path;
11263|       |            url.query = base_url->query;
11264|    212|          } else {
11265|    212|            url.update_host_to_base_host(base_url->get_hostname());
11266|    212|            url.update_base_pathname(base_url->get_pathname());
11267|    212|            if (base_url->has_search()) {
  ------------------
  |  Branch (11267:17): [True: 61, False: 151]
  ------------------
11268|       |              // get_search() returns "" for an empty query string (URL ends
11269|       |              // with '?'). update_base_search("") would incorrectly clear the
11270|       |              // query, so pass "?" to preserve the empty query distinction.
11271|     61|              auto s = base_url->get_search();
11272|     61|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (11272:38): [True: 26, False: 35]
  ------------------
11273|     61|            }
11274|    212|          }
11275|    212|          url.has_opaque_path = base_url->has_opaque_path;
11276|       |
11277|       |          // If c is U+003F (?), then set url's query to the empty string and
11278|       |          // state to query state.
11279|    212|          if (input_position != input_size && url_data[input_position] == '?') {
  ------------------
  |  Branch (11279:15): [True: 152, False: 60]
  |  Branch (11279:47): [True: 8, False: 144]
  ------------------
11280|      8|            state = state::QUERY;
11281|      8|          }
11282|       |          // Otherwise, if c is not the EOF code point:
11283|    204|          else if (input_position != input_size) {
  ------------------
  |  Branch (11283:20): [True: 144, False: 60]
  ------------------
11284|       |            // Set url's query to null.
11285|    144|            url.clear_search();
11286|       |            // If the code point substring from pointer to the end of input does
11287|       |            // not start with a Windows drive letter, then shorten url's path.
11288|    144|            if (!checkers::is_windows_drive_letter(file_view)) {
  ------------------
  |  Branch (11288:17): [True: 124, False: 20]
  ------------------
11289|       |              if constexpr (result_type_is_ada_url) {
11290|       |                helpers::shorten_path(url.path, url.type);
11291|    124|              } else {
11292|    124|                std::string_view path = url.get_pathname();
11293|    124|                if (helpers::shorten_path(path, url.type)) {
  ------------------
  |  Branch (11293:21): [True: 120, False: 4]
  ------------------
11294|    120|                  url.update_base_pathname(std::move(std::string(path)));
11295|    120|                }
11296|    124|              }
11297|    124|            }
11298|       |            // Otherwise:
11299|     20|            else {
11300|       |              // Set url's path to an empty list.
11301|     20|              url.clear_pathname();
11302|     20|              url.has_opaque_path = true;
11303|     20|            }
11304|       |
11305|       |            // Set state to path state and decrease pointer by 1.
11306|    144|            state = state::PATH;
11307|    144|            break;
11308|    144|          }
11309|    212|        }
11310|       |        // Otherwise, set state to path state, and decrease pointer by 1.
11311|    589|        else {
11312|    589|          ada_log("FILE go to path");
11313|    589|          state = state::PATH;
11314|    589|          break;
11315|    589|        }
11316|       |
11317|  1.98k|        input_position++;
11318|  1.98k|        break;
11319|  2.71k|      }
11320|      0|      default:
  ------------------
  |  Branch (11320:7): [True: 0, False: 130k]
  ------------------
11321|      0|        unreachable();
11322|   130k|    }
11323|   130k|  }
11324|  10.2k|  if constexpr (store_values) {
11325|  10.2k|    if (fragment.has_value()) {
  ------------------
  |  Branch (11325:9): [True: 349, False: 9.94k]
  ------------------
11326|    349|      url.update_unencoded_base_hash(*fragment);
11327|    349|    }
11328|  10.2k|  }
11329|       |  // Check the resulting (normalized) URL size against the maximum input length.
11330|       |  // Normalization (percent-encoding, IDNA, etc.) can expand the URL beyond the
11331|       |  // original input size.
11332|  10.2k|  if constexpr (store_values) {
11333|  10.2k|    if (url.is_valid) {
  ------------------
  |  Branch (11333:9): [True: 9.78k, False: 508]
  ------------------
11334|  9.78k|      if constexpr (result_type_is_ada_url_aggregator) {
11335|  9.78k|        if (url.buffer.size() > max_input_length) {
  ------------------
  |  Branch (11335:13): [True: 0, False: 9.78k]
  ------------------
11336|      0|          url.is_valid = false;
11337|      0|        }
11338|       |      } else {
11339|       |        if (url.get_href_size() > max_input_length) {
11340|       |          url.is_valid = false;
11341|       |        }
11342|       |      }
11343|  9.78k|    }
11344|  10.2k|  }
11345|  10.2k|  return url;
11346|  34.6k|}
_ZN3ada6parser14parse_url_implINS_14url_aggregatorELb0EEET_NSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEPKS3_:
10361|  23.4k|                           const result_type* base_url) {
10362|       |  // We can specialize the implementation per type.
10363|       |  // Important: result_type_is_ada_url is evaluated at *compile time*. This
10364|       |  // means that doing if constexpr(result_type_is_ada_url) { something } else {
10365|       |  // something else } is free (at runtime). This means that ada::url_aggregator
10366|       |  // and ada::url **do not have to support the exact same API**.
10367|  23.4k|  constexpr bool result_type_is_ada_url = std::is_same_v<url, result_type>;
10368|  23.4k|  constexpr bool result_type_is_ada_url_aggregator =
10369|  23.4k|      std::is_same_v<url_aggregator, result_type>;
10370|  23.4k|  static_assert(result_type_is_ada_url ||
10371|  23.4k|                result_type_is_ada_url_aggregator);  // We don't support
10372|       |                                                     // anything else for now.
10373|       |
10374|  23.4k|  ada_log("ada::parser::parse_url('", user_input, "' [", user_input.size(),
10375|  23.4k|          " bytes],", (base_url != nullptr ? base_url->to_string() : "null"),
10376|  23.4k|          ")");
10377|       |
10378|  23.4k|  state state = state::SCHEME_START;
10379|  23.4k|  result_type url{};
10380|       |
10381|  23.4k|  const uint32_t max_input_length = ada::get_max_input_length();
10382|       |
10383|       |  // We refuse to parse URL strings that exceed the maximum input length.
10384|       |  // By default, this is 4GB but can be configured via
10385|       |  // ada::set_max_input_length().
10386|  23.4k|  if (user_input.size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (10386:7): [True: 0, False: 23.4k]
  ------------------
10387|      0|    url.is_valid = false;
10388|      0|  }
10389|       |  // Going forward, user_input.size() is in [0,
10390|       |  // std::numeric_limits<uint32_t>::max). If we are provided with an invalid
10391|       |  // base, or the optional_url was invalid, we must return.
10392|  23.4k|  if (base_url != nullptr) {
  ------------------
  |  Branch (10392:7): [True: 3.04k, False: 20.3k]
  ------------------
10393|  3.04k|    url.is_valid &= base_url->is_valid;
10394|  3.04k|  }
10395|  23.4k|  if (!url.is_valid) {
  ------------------
  |  Branch (10395:7): [True: 0, False: 23.4k]
  ------------------
10396|      0|    return url;
10397|      0|  }
10398|       |
10399|       |  // Simple absolute http(s) fast path (before tabs/newline scan).
10400|       |  // Skip digit-led hosts (IPv4) with a cheap peek.
10401|       |  if constexpr (store_values) {
10402|       |    if (base_url == nullptr) {
10403|       |      const auto* p = reinterpret_cast<const uint8_t*>(user_input.data());
10404|       |      const size_t n = user_input.size();
10405|       |      const bool digit_led_host = (n >= 8 && p[4] == ':' && p[5] == '/' &&
10406|       |                                   p[6] == '/' && p[7] >= '0' && p[7] <= '9') ||
10407|       |                                  (n >= 9 && p[5] == ':' && p[6] == '/' &&
10408|       |                                   p[7] == '/' && p[8] >= '0' && p[8] <= '9');
10409|       |      if (!digit_led_host && try_parse_simple_absolute(user_input, url)) {
10410|       |        if constexpr (result_type_is_ada_url_aggregator) {
10411|       |          if (url.buffer.size() > max_input_length) [[unlikely]] {
10412|       |            url.is_valid = false;
10413|       |          }
10414|       |        } else {
10415|       |          if (url.get_href_size() > max_input_length) [[unlikely]] {
10416|       |            url.is_valid = false;
10417|       |          }
10418|       |        }
10419|       |        return url;
10420|       |      }
10421|       |    }
10422|       |  }
10423|       |
10424|  23.4k|  std::string tmp_buffer;
10425|  23.4k|  std::string_view url_data;
10426|  23.4k|  if (unicode::has_tabs_or_newline(user_input)) [[unlikely]] {
  ------------------
  |  Branch (10426:7): [True: 250, False: 23.1k]
  ------------------
10427|    250|    tmp_buffer = user_input;
10428|       |    // Optimization opportunity: Instead of copying and then pruning, we could
10429|       |    // just directly build the string from user_input.
10430|    250|    helpers::remove_ascii_tab_or_newline(tmp_buffer);
10431|    250|    url_data = tmp_buffer;
10432|  23.1k|  } else [[likely]] {
10433|  23.1k|    url_data = user_input;
10434|  23.1k|  }
10435|       |
10436|       |  // Leading and trailing control characters are uncommon and easy to deal with
10437|       |  // (no performance concern).
10438|  23.4k|  helpers::trim_c0_whitespace(url_data);
10439|       |
10440|       |  if constexpr (result_type_is_ada_url_aggregator && store_values) {
10441|       |    // Most of the time, we just need user_input.size().
10442|       |    // In some instances, we may need a bit more.
10443|       |    ///////////////////////////
10444|       |    // This is *very* important. This line should *not* be removed
10445|       |    // hastily. There are principled reasons why reserve is important
10446|       |    // for performance. If you have a benchmark with small inputs,
10447|       |    // it may not matter, but in other instances, it could.
10448|       |    ////
10449|       |    // This rounds up to the next power of two.
10450|       |    // We know that user_input.size() is in [0,
10451|       |    // std::numeric_limits<uint32_t>::max).
10452|       |    uint32_t reserve_capacity =
10453|       |        (0xFFFFFFFF >>
10454|       |         helpers::leading_zeroes(uint32_t(1 | user_input.size()))) +
10455|       |        1;
10456|       |    url.reserve(reserve_capacity);
10457|       |  }
10458|       |
10459|       |  // Optimization opportunity. Most websites do not have fragment.
10460|  23.4k|  std::optional<std::string_view> fragment = helpers::prune_hash(url_data);
10461|       |  // We add it last so that an implementation like ada::url_aggregator
10462|       |  // can append it last to its internal buffer, thus improving performance.
10463|       |
10464|       |  // Here url_data no longer has its fragment.
10465|       |  // We are going to access the data from url_data (it is immutable).
10466|       |  // At any given time, we are pointing at byte 'input_position' in url_data.
10467|       |  // The input_position variable should range from 0 to input_size.
10468|       |  // It is illegal to access url_data at input_size.
10469|  23.4k|  size_t input_position = 0;
10470|  23.4k|  const size_t input_size = url_data.size();
10471|       |  // Keep running the following state machine by switching on state.
10472|       |  // If after a run pointer points to the EOF code point, go to the next step.
10473|       |  // Otherwise, increase pointer by 1 and continue with the state machine.
10474|       |  // We never decrement input_position.
10475|   100k|  while (input_position <= input_size) {
  ------------------
  |  Branch (10475:10): [True: 100k, False: 192]
  ------------------
10476|   100k|    ada_log("In parsing at ", input_position, " out of ", input_size,
10477|   100k|            " in state ", ada::to_string(state));
10478|   100k|    switch (state) {
10479|  23.4k|      case state::SCHEME_START: {
  ------------------
  |  Branch (10479:7): [True: 23.4k, False: 76.9k]
  ------------------
10480|  23.4k|        ada_log("SCHEME_START ", helpers::substring(url_data, input_position));
10481|       |        // If c is an ASCII alpha, append c, lowercased, to buffer, and set
10482|       |        // state to scheme state.
10483|  23.4k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (10483:13): [True: 17.4k, False: 5.95k]
  ------------------
10484|  17.4k|            checkers::is_alpha(url_data[input_position])) {
  ------------------
  |  Branch (10484:13): [True: 16.9k, False: 473]
  ------------------
10485|  16.9k|          state = state::SCHEME;
10486|  16.9k|          input_position++;
10487|  16.9k|        } else {
10488|       |          // Otherwise, if state override is not given, set state to no scheme
10489|       |          // state and decrease pointer by 1.
10490|  6.43k|          state = state::NO_SCHEME;
10491|  6.43k|        }
10492|  23.4k|        break;
10493|      0|      }
10494|  16.9k|      case state::SCHEME: {
  ------------------
  |  Branch (10494:7): [True: 16.9k, False: 83.3k]
  ------------------
10495|  16.9k|        ada_log("SCHEME ", helpers::substring(url_data, input_position));
10496|       |        // If c is an ASCII alphanumeric, U+002B (+), U+002D (-), or U+002E (.),
10497|       |        // append c, lowercased, to buffer.
10498|  43.7k|        while ((input_position != input_size) &&
  ------------------
  |  Branch (10498:16): [True: 43.4k, False: 300]
  ------------------
10499|  43.4k|               (unicode::is_alnum_plus(url_data[input_position]))) {
  ------------------
  |  Branch (10499:16): [True: 26.7k, False: 16.6k]
  ------------------
10500|  26.7k|          input_position++;
10501|  26.7k|        }
10502|       |        // Otherwise, if c is U+003A (:), then:
10503|  16.9k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (10503:13): [True: 16.6k, False: 300]
  ------------------
10504|  16.6k|            (url_data[input_position] == ':')) {
  ------------------
  |  Branch (10504:13): [True: 16.5k, False: 120]
  ------------------
10505|  16.5k|          ada_log("SCHEME the scheme should be ",
10506|  16.5k|                  url_data.substr(0, input_position));
10507|       |          if constexpr (result_type_is_ada_url) {
10508|       |            if (!url.parse_scheme(url_data.substr(0, input_position))) {
10509|       |              return url;
10510|       |            }
10511|  16.5k|          } else {
10512|       |            // we pass the colon along instead of painfully adding it back.
10513|  16.5k|            if (!url.parse_scheme_with_colon(
  ------------------
  |  Branch (10513:17): [True: 0, False: 16.5k]
  ------------------
10514|  16.5k|                    url_data.substr(0, input_position + 1))) {
10515|      0|              return url;
10516|      0|            }
10517|  16.5k|          }
10518|  16.5k|          ada_log("SCHEME the scheme is ", url.get_protocol());
10519|       |
10520|       |          // If url's scheme is "file", then:
10521|       |          // NOLINTNEXTLINE(bugprone-branch-clone)
10522|  16.5k|          if (url.type == scheme::type::FILE) {
  ------------------
  |  Branch (10522:15): [True: 2.40k, False: 14.1k]
  ------------------
10523|       |            // Set state to file state.
10524|  2.40k|            state = state::FILE;
10525|  2.40k|          }
10526|       |          // Otherwise, if url is special, base is non-null, and base's scheme
10527|       |          // is url's scheme: Note: Doing base_url->scheme is unsafe if base_url
10528|       |          // != nullptr is false.
10529|  14.1k|          else if (url.is_special() && base_url != nullptr &&
  ------------------
  |  Branch (10529:20): [True: 9.72k, False: 4.43k]
  |  Branch (10529:40): [True: 1.49k, False: 8.23k]
  ------------------
10530|  1.49k|                   base_url->type == url.type) {
  ------------------
  |  Branch (10530:20): [True: 144, False: 1.34k]
  ------------------
10531|       |            // Set state to special relative or authority state.
10532|    144|            state = state::SPECIAL_RELATIVE_OR_AUTHORITY;
10533|    144|          }
10534|       |          // Otherwise, if url is special, set state to special authority
10535|       |          // slashes state.
10536|  14.0k|          else if (url.is_special()) {
  ------------------
  |  Branch (10536:20): [True: 9.58k, False: 4.43k]
  ------------------
10537|  9.58k|            state = state::SPECIAL_AUTHORITY_SLASHES;
10538|  9.58k|          }
10539|       |          // Otherwise, if remaining starts with an U+002F (/), set state to
10540|       |          // path or authority state and increase pointer by 1.
10541|  4.43k|          else if (input_position + 1 < input_size &&
  ------------------
  |  Branch (10541:20): [True: 2.68k, False: 1.75k]
  ------------------
10542|  2.68k|                   url_data[input_position + 1] == '/') {
  ------------------
  |  Branch (10542:20): [True: 1.83k, False: 853]
  ------------------
10543|  1.83k|            state = state::PATH_OR_AUTHORITY;
10544|  1.83k|            input_position++;
10545|  1.83k|          }
10546|       |          // Otherwise, set url's path to the empty string and set state to
10547|       |          // opaque path state.
10548|  2.60k|          else {
10549|  2.60k|            state = state::OPAQUE_PATH;
10550|  2.60k|          }
10551|  16.5k|        }
10552|       |        // Otherwise, if state override is not given, set buffer to the empty
10553|       |        // string, state to no scheme state, and start over (from the first code
10554|       |        // point in input).
10555|    420|        else {
10556|    420|          state = state::NO_SCHEME;
10557|    420|          input_position = 0;
10558|    420|          break;
10559|    420|        }
10560|  16.5k|        input_position++;
10561|  16.5k|        break;
10562|  16.9k|      }
10563|  6.85k|      case state::NO_SCHEME: {
  ------------------
  |  Branch (10563:7): [True: 6.85k, False: 93.4k]
  ------------------
10564|  6.85k|        ada_log("NO_SCHEME ", helpers::substring(url_data, input_position));
10565|       |        // If base is null, or base has an opaque path and c is not U+0023 (#),
10566|       |        // validation error, return failure.
10567|  6.85k|        if (base_url == nullptr ||
  ------------------
  |  Branch (10567:13): [True: 5.93k, False: 919]
  ------------------
10568|  5.97k|            (base_url->has_opaque_path && !fragment.has_value())) {
  ------------------
  |  Branch (10568:14): [True: 212, False: 707]
  |  Branch (10568:43): [True: 45, False: 167]
  ------------------
10569|  5.97k|          ada_log("NO_SCHEME validation error");
10570|  5.97k|          url.is_valid = false;
10571|  5.97k|          return url;
10572|  5.97k|        }
10573|       |        // Otherwise, if base has an opaque path and c is U+0023 (#),
10574|       |        // set url's scheme to base's scheme, url's path to base's path, url's
10575|       |        // query to base's query, and set state to fragment state.
10576|    874|        else if (base_url->has_opaque_path && fragment.has_value() &&
  ------------------
  |  Branch (10576:18): [True: 167, False: 707]
  |  Branch (10576:47): [True: 167, False: 0]
  ------------------
10577|    167|                 input_position == input_size) {
  ------------------
  |  Branch (10577:18): [True: 86, False: 81]
  ------------------
10578|     86|          ada_log("NO_SCHEME opaque base with fragment");
10579|     86|          url.copy_scheme(*base_url);
10580|     86|          url.has_opaque_path = base_url->has_opaque_path;
10581|       |
10582|       |          if constexpr (result_type_is_ada_url) {
10583|       |            url.path = base_url->path;
10584|       |            url.query = base_url->query;
10585|     86|          } else {
10586|     86|            url.update_base_pathname(base_url->get_pathname());
10587|     86|            if (base_url->has_search()) {
  ------------------
  |  Branch (10587:17): [True: 0, False: 86]
  ------------------
10588|       |              // get_search() returns "" for an empty query string (URL ends
10589|       |              // with '?'). update_base_search("") would incorrectly clear the
10590|       |              // query, so pass "?" to preserve the empty query distinction.
10591|      0|              auto s = base_url->get_search();
10592|      0|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (10592:38): [True: 0, False: 0]
  ------------------
10593|      0|            }
10594|     86|          }
10595|     86|          url.update_unencoded_base_hash(*fragment);
10596|     86|          return url;
10597|     86|        }
10598|       |        // Otherwise, if base's scheme is not "file", set state to relative
10599|       |        // state and decrease pointer by 1.
10600|       |        // NOLINTNEXTLINE(bugprone-branch-clone)
10601|    788|        else if (base_url->type != scheme::type::FILE) {
  ------------------
  |  Branch (10601:18): [True: 480, False: 308]
  ------------------
10602|    480|          ada_log("NO_SCHEME non-file relative path");
10603|    480|          state = state::RELATIVE_SCHEME;
10604|    480|        }
10605|       |        // Otherwise, set state to file state and decrease pointer by 1.
10606|    308|        else {
10607|    308|          ada_log("NO_SCHEME file base type");
10608|    308|          state = state::FILE;
10609|    308|        }
10610|    788|        break;
10611|  6.85k|      }
10612|  10.2k|      case state::AUTHORITY: {
  ------------------
  |  Branch (10612:7): [True: 10.2k, False: 90.0k]
  ------------------
10613|  10.2k|        ada_log("AUTHORITY ", helpers::substring(url_data, input_position));
10614|       |        // most URLs have no @. Having no @ tells us that we don't have to worry
10615|       |        // about AUTHORITY. Of course, we could have @ and still not have to
10616|       |        // worry about AUTHORITY.
10617|       |        // TODO: Instead of just collecting a bool, collect the location of the
10618|       |        // '@' and do something useful with it.
10619|       |        // TODO: We could do various processing early on, using a single pass
10620|       |        // over the string to collect information about it, e.g., telling us
10621|       |        // whether there is a @ and if so, where (or how many).
10622|       |
10623|       |        // Check if url data contains an @.
10624|  10.2k|        if (url_data.find('@', input_position) == std::string_view::npos) {
  ------------------
  |  Branch (10624:13): [True: 9.31k, False: 980]
  ------------------
10625|  9.31k|          state = state::HOST;
10626|  9.31k|          break;
10627|  9.31k|        }
10628|    980|        bool at_sign_seen{false};
10629|    980|        bool password_token_seen{false};
10630|       |        /**
10631|       |         * We expect something of the sort...
10632|       |         * https://user:pass@example.com:1234/foo/bar?baz#quux
10633|       |         * --------^
10634|       |         */
10635|  7.21k|        do {
10636|  7.21k|          std::string_view view = url_data.substr(input_position);
10637|       |          // The delimiters are @, /, ? \\.
10638|  7.21k|          size_t location =
10639|  7.21k|              url.is_special() ? helpers::find_authority_delimiter_special(view)
  ------------------
  |  Branch (10639:15): [True: 6.45k, False: 758]
  ------------------
10640|  7.21k|                               : helpers::find_authority_delimiter(view);
10641|  7.21k|          std::string_view authority_view = view.substr(0, location);
10642|  7.21k|          size_t end_of_authority = input_position + authority_view.size();
10643|       |          // If c is U+0040 (@), then:
10644|  7.21k|          if ((end_of_authority != input_size) &&
  ------------------
  |  Branch (10644:15): [True: 6.57k, False: 643]
  ------------------
10645|  6.57k|              (url_data[end_of_authority] == '@')) {
  ------------------
  |  Branch (10645:15): [True: 6.23k, False: 337]
  ------------------
10646|       |            // If atSignSeen is true, then prepend "%40" to buffer.
10647|  6.23k|            if (at_sign_seen) {
  ------------------
  |  Branch (10647:17): [True: 5.32k, False: 909]
  ------------------
10648|  5.32k|              if (password_token_seen) {
  ------------------
  |  Branch (10648:19): [True: 2.22k, False: 3.09k]
  ------------------
10649|       |                if constexpr (result_type_is_ada_url) {
10650|       |                  url.password += "%40";
10651|  2.22k|                } else {
10652|  2.22k|                  url.append_base_password("%40");
10653|  2.22k|                }
10654|  3.09k|              } else {
10655|       |                if constexpr (result_type_is_ada_url) {
10656|       |                  url.username += "%40";
10657|  3.09k|                } else {
10658|  3.09k|                  url.append_base_username("%40");
10659|  3.09k|                }
10660|  3.09k|              }
10661|  5.32k|            }
10662|       |
10663|  6.23k|            at_sign_seen = true;
10664|       |
10665|  6.23k|            if (!password_token_seen) {
  ------------------
  |  Branch (10665:17): [True: 4.00k, False: 2.22k]
  ------------------
10666|  4.00k|              size_t password_token_location = authority_view.find(':');
10667|  4.00k|              password_token_seen =
10668|  4.00k|                  password_token_location != std::string_view::npos;
10669|       |
10670|       |              if constexpr (store_values) {
10671|       |                if (!password_token_seen) {
10672|       |                  if constexpr (result_type_is_ada_url) {
10673|       |                    url.username += unicode::percent_encode(
10674|       |                        authority_view,
10675|       |                        character_sets::USERINFO_PERCENT_ENCODE);
10676|       |                  } else {
10677|       |                    url.append_base_username(unicode::percent_encode(
10678|       |                        authority_view,
10679|       |                        character_sets::USERINFO_PERCENT_ENCODE));
10680|       |                  }
10681|       |                } else {
10682|       |                  if constexpr (result_type_is_ada_url) {
10683|       |                    url.username += unicode::percent_encode(
10684|       |                        authority_view.substr(0, password_token_location),
10685|       |                        character_sets::USERINFO_PERCENT_ENCODE);
10686|       |                    url.password += unicode::percent_encode(
10687|       |                        authority_view.substr(password_token_location + 1),
10688|       |                        character_sets::USERINFO_PERCENT_ENCODE);
10689|       |                  } else {
10690|       |                    url.append_base_username(unicode::percent_encode(
10691|       |                        authority_view.substr(0, password_token_location),
10692|       |                        character_sets::USERINFO_PERCENT_ENCODE));
10693|       |                    url.append_base_password(unicode::percent_encode(
10694|       |                        authority_view.substr(password_token_location + 1),
10695|       |                        character_sets::USERINFO_PERCENT_ENCODE));
10696|       |                  }
10697|       |                }
10698|       |              }
10699|  4.00k|            } else if constexpr (store_values) {
10700|  2.22k|              if constexpr (result_type_is_ada_url) {
10701|  2.22k|                url.password += unicode::percent_encode(
10702|  2.22k|                    authority_view, character_sets::USERINFO_PERCENT_ENCODE);
10703|  2.22k|              } else {
10704|  2.22k|                url.append_base_password(unicode::percent_encode(
10705|  2.22k|                    authority_view, character_sets::USERINFO_PERCENT_ENCODE));
10706|  2.22k|              }
10707|  2.22k|            }
10708|  6.23k|          }
10709|       |          // Otherwise, if one of the following is true:
10710|       |          // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
10711|       |          // - url is special and c is U+005C (\)
10712|    980|          else if (end_of_authority == input_size ||
  ------------------
  |  Branch (10712:20): [True: 643, False: 337]
  ------------------
10713|    337|                   url_data[end_of_authority] == '/' ||
  ------------------
  |  Branch (10713:20): [True: 299, False: 38]
  ------------------
10714|     38|                   url_data[end_of_authority] == '?' ||
  ------------------
  |  Branch (10714:20): [True: 30, False: 8]
  ------------------
10715|    980|                   (url.is_special() && url_data[end_of_authority] == '\\')) {
  ------------------
  |  Branch (10715:21): [True: 8, False: 0]
  |  Branch (10715:41): [True: 8, False: 0]
  ------------------
10716|       |            // If atSignSeen is true and authority_view is the empty string,
10717|       |            // validation error, return failure.
10718|    980|            if (at_sign_seen && authority_view.empty()) {
  ------------------
  |  Branch (10718:17): [True: 909, False: 71]
  |  Branch (10718:33): [True: 283, False: 626]
  ------------------
10719|    283|              url.is_valid = false;
10720|    283|              return url;
10721|    283|            }
10722|    697|            state = state::HOST;
10723|    697|            break;
10724|    980|          }
10725|  6.23k|          if (end_of_authority == input_size) {
  ------------------
  |  Branch (10725:15): [True: 0, False: 6.23k]
  ------------------
10726|       |            if constexpr (store_values) {
10727|       |              if (fragment.has_value()) {
10728|       |                url.update_unencoded_base_hash(*fragment);
10729|       |              }
10730|       |            }
10731|      0|            return url;
10732|      0|          }
10733|  6.23k|          input_position = end_of_authority + 1;
10734|  6.23k|        } while (true);
  ------------------
  |  Branch (10734:18): [True: 6.23k, Folded]
  ------------------
10735|       |
10736|    697|        break;
10737|    980|      }
10738|    697|      case state::SPECIAL_RELATIVE_OR_AUTHORITY: {
  ------------------
  |  Branch (10738:7): [True: 144, False: 100k]
  ------------------
10739|    144|        ada_log("SPECIAL_RELATIVE_OR_AUTHORITY ",
10740|    144|                helpers::substring(url_data, input_position));
10741|       |
10742|       |        // If c is U+002F (/) and remaining starts with U+002F (/),
10743|       |        // then set state to special authority ignore slashes state and increase
10744|       |        // pointer by 1.
10745|    144|        if (url_data.substr(input_position, 2) == "//") {
  ------------------
  |  Branch (10745:13): [True: 53, False: 91]
  ------------------
10746|     53|          state = state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
10747|     53|          input_position += 2;
10748|     91|        } else {
10749|       |          // Otherwise, validation error, set state to relative state and
10750|       |          // decrease pointer by 1.
10751|     91|          state = state::RELATIVE_SCHEME;
10752|     91|        }
10753|       |
10754|    144|        break;
10755|    980|      }
10756|  1.83k|      case state::PATH_OR_AUTHORITY: {
  ------------------
  |  Branch (10756:7): [True: 1.83k, False: 98.5k]
  ------------------
10757|  1.83k|        ada_log("PATH_OR_AUTHORITY ",
10758|  1.83k|                helpers::substring(url_data, input_position));
10759|       |
10760|       |        // If c is U+002F (/), then set state to authority state.
10761|  1.83k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (10761:13): [True: 1.72k, False: 105]
  ------------------
10762|  1.72k|            (url_data[input_position] == '/')) {
  ------------------
  |  Branch (10762:13): [True: 652, False: 1.07k]
  ------------------
10763|    652|          state = state::AUTHORITY;
10764|    652|          input_position++;
10765|  1.18k|        } else {
10766|       |          // Otherwise, set state to path state, and decrease pointer by 1.
10767|  1.18k|          state = state::PATH;
10768|  1.18k|        }
10769|       |
10770|  1.83k|        break;
10771|    980|      }
10772|    571|      case state::RELATIVE_SCHEME: {
  ------------------
  |  Branch (10772:7): [True: 571, False: 99.7k]
  ------------------
10773|    571|        ada_log("RELATIVE_SCHEME ",
10774|    571|                helpers::substring(url_data, input_position));
10775|       |
10776|       |        // Set url's scheme to base's scheme.
10777|    571|        url.copy_scheme(*base_url);
10778|       |
10779|       |        // If c is U+002F (/), then set state to relative slash state.
10780|    571|        if ((input_position != input_size) &&
  ------------------
  |  Branch (10780:13): [True: 439, False: 132]
  ------------------
10781|       |            // NOLINTNEXTLINE(bugprone-branch-clone)
10782|    439|            (url_data[input_position] == '/')) {
  ------------------
  |  Branch (10782:13): [True: 68, False: 371]
  ------------------
10783|     68|          ada_log(
10784|     68|              "RELATIVE_SCHEME if c is U+002F (/), then set state to relative "
10785|     68|              "slash state");
10786|     68|          state = state::RELATIVE_SLASH;
10787|    503|        } else if (url.is_special() && (input_position != input_size) &&
  ------------------
  |  Branch (10787:20): [True: 315, False: 188]
  |  Branch (10787:40): [True: 223, False: 92]
  ------------------
10788|    223|                   (url_data[input_position] == '\\')) {
  ------------------
  |  Branch (10788:20): [True: 4, False: 219]
  ------------------
10789|       |          // Otherwise, if url is special and c is U+005C (\), validation error,
10790|       |          // set state to relative slash state.
10791|      4|          ada_log(
10792|      4|              "RELATIVE_SCHEME  if url is special and c is U+005C, validation "
10793|      4|              "error, set state to relative slash state");
10794|      4|          state = state::RELATIVE_SLASH;
10795|    499|        } else {
10796|    499|          ada_log("RELATIVE_SCHEME otherwise");
10797|       |          // Set url's username to base's username, url's password to base's
10798|       |          // password, url's host to base's host, url's port to base's port,
10799|       |          // url's path to a clone of base's path, and url's query to base's
10800|       |          // query.
10801|       |          if constexpr (result_type_is_ada_url) {
10802|       |            url.username = base_url->username;
10803|       |            url.password = base_url->password;
10804|       |            url.host = base_url->host;
10805|       |            url.port = base_url->port;
10806|       |            // cloning the base path includes cloning the has_opaque_path flag
10807|       |            url.has_opaque_path = base_url->has_opaque_path;
10808|       |            url.path = base_url->path;
10809|       |            url.query = base_url->query;
10810|    499|          } else {
10811|    499|            url.update_base_authority(base_url->get_href(),
10812|    499|                                      base_url->get_components());
10813|    499|            url.update_host_to_base_host(base_url->get_hostname());
10814|    499|            url.update_base_port(base_url->retrieve_base_port());
10815|       |            // cloning the base path includes cloning the has_opaque_path flag
10816|    499|            url.has_opaque_path = base_url->has_opaque_path;
10817|    499|            url.update_base_pathname(base_url->get_pathname());
10818|    499|            if (base_url->has_search()) {
  ------------------
  |  Branch (10818:17): [True: 0, False: 499]
  ------------------
10819|       |              // get_search() returns "" for an empty query string (URL ends
10820|       |              // with '?'). update_base_search("") would incorrectly clear the
10821|       |              // query, so pass "?" to preserve the empty query distinction.
10822|      0|              auto s = base_url->get_search();
10823|      0|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (10823:38): [True: 0, False: 0]
  ------------------
10824|      0|            }
10825|    499|          }
10826|       |
10827|    499|          url.has_opaque_path = base_url->has_opaque_path;
10828|       |
10829|       |          // If c is U+003F (?), then set url's query to the empty string, and
10830|       |          // state to query state.
10831|    499|          if ((input_position != input_size) &&
  ------------------
  |  Branch (10831:15): [True: 367, False: 132]
  ------------------
10832|    367|              (url_data[input_position] == '?')) {
  ------------------
  |  Branch (10832:15): [True: 27, False: 340]
  ------------------
10833|     27|            state = state::QUERY;
10834|     27|          }
10835|       |          // Otherwise, if c is not the EOF code point:
10836|    472|          else if (input_position != input_size) {
  ------------------
  |  Branch (10836:20): [True: 340, False: 132]
  ------------------
10837|       |            // Set url's query to null.
10838|    340|            url.clear_search();
10839|       |            if constexpr (result_type_is_ada_url) {
10840|       |              // Shorten url's path.
10841|       |              helpers::shorten_path(url.path, url.type);
10842|    340|            } else {
10843|    340|              std::string_view path = url.get_pathname();
10844|    340|              if (helpers::shorten_path(path, url.type)) {
  ------------------
  |  Branch (10844:19): [True: 0, False: 340]
  ------------------
10845|      0|                url.update_base_pathname(std::move(std::string(path)));
10846|      0|              }
10847|    340|            }
10848|       |            // Set state to path state and decrease pointer by 1.
10849|    340|            state = state::PATH;
10850|    340|            break;
10851|    340|          }
10852|    499|        }
10853|    231|        input_position++;
10854|    231|        break;
10855|    571|      }
10856|     72|      case state::RELATIVE_SLASH: {
  ------------------
  |  Branch (10856:7): [True: 72, False: 100k]
  ------------------
10857|     72|        ada_log("RELATIVE_SLASH ",
10858|     72|                helpers::substring(url_data, input_position));
10859|       |
10860|       |        // If url is special and c is U+002F (/) or U+005C (\), then:
10861|       |        // NOLINTNEXTLINE(bugprone-branch-clone)
10862|     72|        if (url.is_special() && (input_position != input_size) &&
  ------------------
  |  Branch (10862:13): [True: 50, False: 22]
  |  Branch (10862:33): [True: 35, False: 15]
  ------------------
10863|     35|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (10863:14): [True: 4, False: 31]
  ------------------
10864|     31|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (10864:14): [True: 1, False: 30]
  ------------------
10865|       |          // Set state to special authority ignore slashes state.
10866|      5|          state = state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
10867|      5|        }
10868|       |        // Otherwise, if c is U+002F (/), then set state to authority state.
10869|     67|        else if ((input_position != input_size) &&
  ------------------
  |  Branch (10869:18): [True: 45, False: 22]
  ------------------
10870|     45|                 (url_data[input_position] == '/')) {
  ------------------
  |  Branch (10870:18): [True: 6, False: 39]
  ------------------
10871|      6|          state = state::AUTHORITY;
10872|      6|        }
10873|       |        // Otherwise, set
10874|       |        // - url's username to base's username,
10875|       |        // - url's password to base's password,
10876|       |        // - url's host to base's host,
10877|       |        // - url's port to base's port,
10878|       |        // - state to path state, and then, decrease pointer by 1.
10879|     61|        else {
10880|       |          if constexpr (result_type_is_ada_url) {
10881|       |            url.username = base_url->username;
10882|       |            url.password = base_url->password;
10883|       |            url.host = base_url->host;
10884|       |            url.port = base_url->port;
10885|     61|          } else {
10886|     61|            url.update_base_authority(base_url->get_href(),
10887|     61|                                      base_url->get_components());
10888|     61|            url.update_host_to_base_host(base_url->get_hostname());
10889|     61|            url.update_base_port(base_url->retrieve_base_port());
10890|     61|          }
10891|     61|          state = state::PATH;
10892|     61|          break;
10893|     61|        }
10894|       |
10895|     11|        input_position++;
10896|     11|        break;
10897|     72|      }
10898|  9.58k|      case state::SPECIAL_AUTHORITY_SLASHES: {
  ------------------
  |  Branch (10898:7): [True: 9.58k, False: 90.7k]
  ------------------
10899|  9.58k|        ada_log("SPECIAL_AUTHORITY_SLASHES ",
10900|  9.58k|                helpers::substring(url_data, input_position));
10901|       |
10902|       |        // If c is U+002F (/) and remaining starts with U+002F (/),
10903|       |        // then set state to special authority ignore slashes state and increase
10904|       |        // pointer by 1.
10905|  9.58k|        if (url_data.substr(input_position, 2) == "//") {
  ------------------
  |  Branch (10905:13): [True: 2.42k, False: 7.16k]
  ------------------
10906|  2.42k|          input_position += 2;
10907|  2.42k|        }
10908|       |
10909|  9.58k|        [[fallthrough]];
10910|  9.58k|      }
10911|  9.64k|      case state::SPECIAL_AUTHORITY_IGNORE_SLASHES: {
  ------------------
  |  Branch (10911:7): [True: 58, False: 100k]
  ------------------
10912|  9.64k|        ada_log("SPECIAL_AUTHORITY_IGNORE_SLASHES ",
10913|  9.64k|                helpers::substring(url_data, input_position));
10914|       |
10915|       |        // If c is neither U+002F (/) nor U+005C (\), then set state to
10916|       |        // authority state and decrease pointer by 1.
10917|  10.4k|        while ((input_position != input_size) &&
  ------------------
  |  Branch (10917:16): [True: 10.3k, False: 48]
  ------------------
10918|  10.3k|               ((url_data[input_position] == '/') ||
  ------------------
  |  Branch (10918:17): [True: 371, False: 10.0k]
  ------------------
10919|  10.0k|                (url_data[input_position] == '\\'))) {
  ------------------
  |  Branch (10919:17): [True: 416, False: 9.59k]
  ------------------
10920|    787|          input_position++;
10921|    787|        }
10922|  9.64k|        state = state::AUTHORITY;
10923|       |
10924|  9.64k|        break;
10925|  9.58k|      }
10926|     35|      case state::QUERY: {
  ------------------
  |  Branch (10926:7): [True: 35, False: 100k]
  ------------------
10927|     35|        ada_log("QUERY ", helpers::substring(url_data, input_position));
10928|       |        if constexpr (store_values) {
10929|       |          // Let queryPercentEncodeSet be the special-query percent-encode set
10930|       |          // if url is special; otherwise the query percent-encode set.
10931|       |          const uint8_t* query_percent_encode_set =
10932|       |              url.is_special() ? character_sets::SPECIAL_QUERY_PERCENT_ENCODE
10933|       |                               : character_sets::QUERY_PERCENT_ENCODE;
10934|       |
10935|       |          // Percent-encode after encoding, with encoding, buffer, and
10936|       |          // queryPercentEncodeSet, and append the result to url's query.
10937|       |          url.update_base_search(url_data.substr(input_position),
10938|       |                                 query_percent_encode_set);
10939|       |          ada_log("QUERY update_base_search completed ");
10940|       |          if (fragment.has_value()) {
10941|       |            url.update_unencoded_base_hash(*fragment);
10942|       |          }
10943|       |        }
10944|     35|        return url;
10945|  9.58k|      }
10946|  10.0k|      case state::HOST: {
  ------------------
  |  Branch (10946:7): [True: 10.0k, False: 90.3k]
  ------------------
10947|  10.0k|        ada_log("HOST ", helpers::substring(url_data, input_position));
10948|       |
10949|  10.0k|        std::string_view host_view = url_data.substr(input_position);
10950|  10.0k|        auto [location, found_colon] =
10951|  10.0k|            helpers::get_host_delimiter_location(url.is_special(), host_view);
10952|  10.0k|        input_position = (location != std::string_view::npos)
  ------------------
  |  Branch (10952:26): [True: 10.0k, False: 0]
  ------------------
10953|  10.0k|                             ? input_position + location
10954|  10.0k|                             : input_size;
10955|       |        // Otherwise, if c is U+003A (:) and insideBrackets is false, then:
10956|       |        // Note: the 'found_colon' value is true if and only if a colon was
10957|       |        // encountered while not inside brackets.
10958|  10.0k|        if (found_colon) {
  ------------------
  |  Branch (10958:13): [True: 1.37k, False: 8.64k]
  ------------------
10959|       |          // If buffer is the empty string, validation error, return failure.
10960|       |          // Let host be the result of host parsing buffer with url is not
10961|       |          // special.
10962|  1.37k|          ada_log("HOST parsing ", host_view);
10963|  1.37k|          if (!url.parse_host(host_view)) {
  ------------------
  |  Branch (10963:15): [True: 143, False: 1.22k]
  ------------------
10964|    143|            return url;
10965|    143|          }
10966|  1.22k|          ada_log("HOST parsing results in ", url.get_hostname());
10967|       |          // Set url's host to host, buffer to the empty string, and state to
10968|       |          // port state.
10969|  1.22k|          state = state::PORT;
10970|  1.22k|          input_position++;
10971|  1.22k|        }
10972|       |        // Otherwise, if one of the following is true:
10973|       |        // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
10974|       |        // - url is special and c is U+005C (\)
10975|       |        // The get_host_delimiter_location function either brings us to
10976|       |        // the colon outside of the bracket, or to one of those characters.
10977|  8.64k|        else {
10978|       |          // If url is special and host_view is the empty string, validation
10979|       |          // error, return failure.
10980|  8.64k|          if (host_view.empty() && url.is_special()) {
  ------------------
  |  Branch (10980:15): [True: 117, False: 8.52k]
  |  Branch (10980:36): [True: 50, False: 67]
  ------------------
10981|     50|            url.is_valid = false;
10982|     50|            return url;
10983|     50|          }
10984|  8.59k|          ada_log("HOST parsing ", host_view, " href=", url.get_href());
10985|       |          // Let host be the result of host parsing host_view with url is not
10986|       |          // special.
10987|  8.59k|          if (host_view.empty()) {
  ------------------
  |  Branch (10987:15): [True: 67, False: 8.52k]
  ------------------
10988|     67|            url.update_base_hostname("");
10989|  8.52k|          } else if (!url.parse_host(host_view)) {
  ------------------
  |  Branch (10989:22): [True: 2.39k, False: 6.13k]
  ------------------
10990|  2.39k|            return url;
10991|  2.39k|          }
10992|  6.19k|          ada_log("HOST parsing results in ", url.get_hostname(),
10993|  6.19k|                  " href=", url.get_href());
10994|       |
10995|       |          // Set url's host to host, and state to path start state.
10996|  6.19k|          state = state::PATH_START;
10997|  6.19k|        }
10998|       |
10999|  7.42k|        break;
11000|  10.0k|      }
11001|  7.42k|      case state::OPAQUE_PATH: {
  ------------------
  |  Branch (11001:7): [True: 2.60k, False: 97.7k]
  ------------------
11002|  2.60k|        ada_log("OPAQUE_PATH ", helpers::substring(url_data, input_position));
11003|       |        // Opaque path, query, and fragment are structurally always valid:
11004|       |        // the parser would just percent-encode whatever is there. When we
11005|       |        // are not storing values (can_parse), we can return immediately.
11006|       |        // We must set has_opaque_path = true before returning so that when
11007|       |        // this URL is used as an internal base inside can_parse, NO_SCHEME
11008|       |        // correctly rejects relative inputs against an opaque-path base
11009|       |        // (e.g. can_parse("", &"W:") must return false).
11010|  2.60k|        if constexpr (!store_values) {
11011|  2.60k|          url.has_opaque_path = true;
11012|  2.60k|          return url;
11013|  2.60k|        }
11014|      0|        std::string_view view = url_data.substr(input_position);
11015|       |        // If c is U+003F (?), then set url's query to the empty string and
11016|       |        // state to query state.
11017|  2.60k|        size_t location = view.find('?');
11018|  2.60k|        if (location != std::string_view::npos) {
  ------------------
  |  Branch (11018:13): [True: 0, False: 2.60k]
  ------------------
11019|      0|          view.remove_suffix(view.size() - location);
11020|      0|          state = state::QUERY;
11021|      0|          input_position += location + 1;
11022|  2.60k|        } else {
11023|  2.60k|          input_position = input_size + 1;
11024|  2.60k|        }
11025|  2.60k|        url.has_opaque_path = true;
11026|       |
11027|       |        // This is a really unlikely scenario in real world. We should not seek
11028|       |        // to optimize it.
11029|  2.60k|        if (view.ends_with(' ')) {
  ------------------
  |  Branch (11029:13): [True: 0, False: 2.60k]
  ------------------
11030|      0|          std::string modified_view =
11031|      0|              std::string(view.substr(0, view.size() - 1)) + "%20";
11032|      0|          url.update_base_pathname(unicode::percent_encode(
11033|      0|              modified_view, character_sets::C0_CONTROL_PERCENT_ENCODE));
11034|  2.60k|        } else {
11035|  2.60k|          url.update_base_pathname(unicode::percent_encode(
11036|  2.60k|              view, character_sets::C0_CONTROL_PERCENT_ENCODE));
11037|  2.60k|        }
11038|  2.60k|        break;
11039|  10.0k|      }
11040|  1.22k|      case state::PORT: {
  ------------------
  |  Branch (11040:7): [True: 1.22k, False: 99.1k]
  ------------------
11041|  1.22k|        ada_log("PORT ", helpers::substring(url_data, input_position));
11042|  1.22k|        std::string_view port_view = url_data.substr(input_position);
11043|  1.22k|        input_position += url.parse_port(port_view, true);
11044|  1.22k|        if (!url.is_valid) {
  ------------------
  |  Branch (11044:13): [True: 85, False: 1.14k]
  ------------------
11045|     85|          return url;
11046|     85|        }
11047|  1.14k|        state = state::PATH_START;
11048|  1.14k|        [[fallthrough]];
11049|  1.14k|      }
11050|  8.91k|      case state::PATH_START: {
  ------------------
  |  Branch (11050:7): [True: 7.77k, False: 92.5k]
  ------------------
11051|  8.91k|        ada_log("PATH_START ", helpers::substring(url_data, input_position));
11052|       |        // Path, query, and fragment are structurally always valid: the
11053|       |        // parser would just percent-encode whatever is there. When we are
11054|       |        // not storing values (can_parse), we can return immediately since
11055|       |        // no subsequent state can invalidate the URL.
11056|  8.91k|        if constexpr (!store_values) {
11057|  8.91k|          return url;
11058|  8.91k|        }
11059|       |
11060|       |        // If url is special, then:
11061|  8.91k|        if (url.is_special()) {
  ------------------
  |  Branch (11061:13): [True: 0, False: 8.91k]
  ------------------
11062|       |          // Set state to path state.
11063|      0|          state = state::PATH;
11064|       |
11065|       |          // Optimization: Avoiding going into PATH state improves the
11066|       |          // performance of urls ending with /.
11067|      0|          if (input_position == input_size) {
  ------------------
  |  Branch (11067:15): [True: 0, False: 0]
  ------------------
11068|       |            if constexpr (store_values) {
11069|       |              url.update_base_pathname("/");
11070|       |              if (fragment.has_value()) {
11071|       |                url.update_unencoded_base_hash(*fragment);
11072|       |              }
11073|       |            }
11074|      0|            return url;
11075|      0|          }
11076|       |          // If c is neither U+002F (/) nor U+005C (\), then decrease pointer
11077|       |          // by 1. We know that (input_position == input_size) is impossible
11078|       |          // here, because of the previous if-check.
11079|      0|          if ((url_data[input_position] != '/') &&
  ------------------
  |  Branch (11079:15): [True: 0, False: 0]
  ------------------
11080|      0|              (url_data[input_position] != '\\')) {
  ------------------
  |  Branch (11080:15): [True: 0, False: 0]
  ------------------
11081|      0|            break;
11082|      0|          }
11083|      0|        }
11084|       |        // Otherwise, if state override is not given and c is U+003F (?),
11085|       |        // set url's query to the empty string and state to query state.
11086|  8.91k|        else if ((input_position != input_size) &&
  ------------------
  |  Branch (11086:18): [True: 0, False: 8.91k]
  ------------------
11087|      0|                 (url_data[input_position] == '?')) {
  ------------------
  |  Branch (11087:18): [True: 0, False: 0]
  ------------------
11088|      0|          state = state::QUERY;
11089|      0|        }
11090|       |        // Otherwise, if c is not the EOF code point:
11091|  8.91k|        else if (input_position != input_size) {
  ------------------
  |  Branch (11091:18): [True: 0, False: 8.91k]
  ------------------
11092|       |          // Set state to path state.
11093|      0|          state = state::PATH;
11094|       |
11095|       |          // If c is not U+002F (/), then decrease pointer by 1.
11096|      0|          if (url_data[input_position] != '/') {
  ------------------
  |  Branch (11096:15): [True: 0, False: 0]
  ------------------
11097|      0|            break;
11098|      0|          }
11099|      0|        }
11100|       |
11101|  8.91k|        input_position++;
11102|  8.91k|        break;
11103|  8.91k|      }
11104|  2.49k|      case state::PATH: {
  ------------------
  |  Branch (11104:7): [True: 2.49k, False: 97.8k]
  ------------------
11105|  2.49k|        ada_log("PATH ", helpers::substring(url_data, input_position));
11106|       |        // Path, query, and fragment are structurally always valid: the
11107|       |        // parser would just percent-encode whatever is there. When we are
11108|       |        // not storing values (can_parse), we can return immediately since
11109|       |        // no subsequent state can invalidate the URL.
11110|  2.49k|        if constexpr (!store_values) {
11111|  2.49k|          return url;
11112|  2.49k|        }
11113|      0|        std::string_view view = url_data.substr(input_position);
11114|       |
11115|       |        // Most time, we do not need percent encoding.
11116|       |        // Furthermore, we can immediately locate the '?'.
11117|  2.49k|        size_t locofquestionmark = view.find('?');
11118|  2.49k|        if (locofquestionmark != std::string_view::npos) {
  ------------------
  |  Branch (11118:13): [True: 0, False: 2.49k]
  ------------------
11119|      0|          state = state::QUERY;
11120|      0|          view.remove_suffix(view.size() - locofquestionmark);
11121|      0|          input_position += locofquestionmark + 1;
11122|  2.49k|        } else {
11123|  2.49k|          input_position = input_size + 1;
11124|  2.49k|        }
11125|       |        if constexpr (store_values) {
11126|       |          if constexpr (result_type_is_ada_url) {
11127|       |            helpers::parse_prepared_path(view, url.type, url.path);
11128|       |          } else {
11129|       |            url.consume_prepared_path(view);
11130|       |            ADA_ASSERT_TRUE(url.validate());
11131|       |          }
11132|       |        }
11133|  2.49k|        break;
11134|  8.91k|      }
11135|  1.91k|      case state::FILE_SLASH: {
  ------------------
  |  Branch (11135:7): [True: 1.91k, False: 98.4k]
  ------------------
11136|  1.91k|        ada_log("FILE_SLASH ", helpers::substring(url_data, input_position));
11137|       |
11138|       |        // If c is U+002F (/) or U+005C (\), then:
11139|  1.91k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (11139:13): [True: 1.82k, False: 85]
  ------------------
11140|  1.82k|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (11140:14): [True: 1.73k, False: 88]
  ------------------
11141|  1.74k|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (11141:14): [True: 6, False: 82]
  ------------------
11142|  1.74k|          ada_log("FILE_SLASH c is U+002F or U+005C");
11143|       |          // Set state to file host state.
11144|  1.74k|          state = state::FILE_HOST;
11145|  1.74k|          input_position++;
11146|  1.74k|        } else {
11147|    167|          ada_log("FILE_SLASH otherwise");
11148|       |          // If base is non-null and base's scheme is "file", then:
11149|       |          // Note: it is unsafe to do base_url->scheme unless you know that
11150|       |          // base_url_has_value() is true.
11151|    167|          if (base_url != nullptr && base_url->type == scheme::type::FILE) {
  ------------------
  |  Branch (11151:15): [True: 128, False: 39]
  |  Branch (11151:38): [True: 122, False: 6]
  ------------------
11152|       |            // Set url's host to base's host.
11153|       |            if constexpr (result_type_is_ada_url) {
11154|       |              url.host = base_url->host;
11155|    122|            } else {
11156|    122|              url.update_host_to_base_host(base_url->get_host());
11157|    122|            }
11158|       |            // If the code point substring from pointer to the end of input does
11159|       |            // not start with a Windows drive letter and base's path[0] is a
11160|       |            // normalized Windows drive letter, then append base's path[0] to
11161|       |            // url's path.
11162|    122|            if (!base_url->get_pathname().empty()) {
  ------------------
  |  Branch (11162:17): [True: 0, False: 122]
  ------------------
11163|      0|              if (!checkers::is_windows_drive_letter(
  ------------------
  |  Branch (11163:19): [True: 0, False: 0]
  ------------------
11164|      0|                      url_data.substr(input_position))) {
11165|      0|                std::string_view first_base_url_path =
11166|      0|                    base_url->get_pathname().substr(1);
11167|      0|                size_t loc = first_base_url_path.find('/');
11168|      0|                if (loc != std::string_view::npos) {
  ------------------
  |  Branch (11168:21): [True: 0, False: 0]
  ------------------
11169|      0|                  helpers::resize(first_base_url_path, loc);
11170|      0|                }
11171|      0|                if (checkers::is_normalized_windows_drive_letter(
  ------------------
  |  Branch (11171:21): [True: 0, False: 0]
  ------------------
11172|      0|                        first_base_url_path)) {
11173|       |                  if constexpr (result_type_is_ada_url) {
11174|       |                    url.path += '/';
11175|       |                    url.path += first_base_url_path;
11176|      0|                  } else {
11177|      0|                    url.append_base_pathname(
11178|      0|                        helpers::concat("/", first_base_url_path));
11179|      0|                  }
11180|      0|                }
11181|      0|              }
11182|      0|            }
11183|    122|          }
11184|       |
11185|       |          // Set state to path state, and decrease pointer by 1.
11186|    167|          state = state::PATH;
11187|    167|        }
11188|       |
11189|  1.91k|        break;
11190|  8.91k|      }
11191|  1.74k|      case state::FILE_HOST: {
  ------------------
  |  Branch (11191:7): [True: 1.74k, False: 98.5k]
  ------------------
11192|  1.74k|        ada_log("FILE_HOST ", helpers::substring(url_data, input_position));
11193|  1.74k|        std::string_view view = url_data.substr(input_position);
11194|       |
11195|  1.74k|        size_t location = view.find_first_of("/\\?");
11196|  1.74k|        std::string_view file_host_buffer = view.substr(
11197|  1.74k|            0, (location != std::string_view::npos) ? location : view.size());
  ------------------
  |  Branch (11197:16): [True: 828, False: 917]
  ------------------
11198|       |
11199|  1.74k|        if (checkers::is_windows_drive_letter(file_host_buffer)) {
  ------------------
  |  Branch (11199:13): [True: 12, False: 1.73k]
  ------------------
11200|     12|          state = state::PATH;
11201|  1.73k|        } else if (file_host_buffer.empty()) {
  ------------------
  |  Branch (11201:20): [True: 330, False: 1.40k]
  ------------------
11202|       |          // Set url's host to the empty string.
11203|       |          if constexpr (result_type_is_ada_url) {
11204|       |            url.host = "";
11205|    330|          } else {
11206|    330|            url.update_base_hostname("");
11207|    330|          }
11208|       |          // Set state to path start state.
11209|    330|          state = state::PATH_START;
11210|  1.40k|        } else {
11211|  1.40k|          size_t consumed_bytes = file_host_buffer.size();
11212|  1.40k|          input_position += consumed_bytes;
11213|       |          // Let host be the result of host parsing buffer with url is not
11214|       |          // special.
11215|  1.40k|          if (!url.parse_host(file_host_buffer)) {
  ------------------
  |  Branch (11215:15): [True: 160, False: 1.24k]
  ------------------
11216|    160|            return url;
11217|    160|          }
11218|       |
11219|       |          if constexpr (result_type_is_ada_url) {
11220|       |            // If host is "localhost", then set host to the empty string.
11221|       |            if (url.host.has_value() && url.host.value() == "localhost") {
11222|       |              url.host = "";
11223|       |            }
11224|  1.24k|          } else {
11225|  1.24k|            if (url.get_hostname() == "localhost") {
  ------------------
  |  Branch (11225:17): [True: 6, False: 1.23k]
  ------------------
11226|      6|              url.update_base_hostname("");
11227|      6|            }
11228|  1.24k|          }
11229|       |
11230|       |          // Set buffer to the empty string and state to path start state.
11231|  1.24k|          state = state::PATH_START;
11232|  1.24k|        }
11233|       |
11234|  1.58k|        break;
11235|  1.74k|      }
11236|  2.71k|      case state::FILE: {
  ------------------
  |  Branch (11236:7): [True: 2.71k, False: 97.6k]
  ------------------
11237|  2.71k|        ada_log("FILE ", helpers::substring(url_data, input_position));
11238|  2.71k|        std::string_view file_view = url_data.substr(input_position);
11239|       |
11240|  2.71k|        url.set_protocol_as_file();
11241|       |        if constexpr (result_type_is_ada_url) {
11242|       |          // Set url's host to the empty string.
11243|       |          url.host = "";
11244|  2.71k|        } else {
11245|  2.71k|          url.update_base_hostname("");
11246|  2.71k|        }
11247|       |        // If c is U+002F (/) or U+005C (\), then:
11248|  2.71k|        if (input_position != input_size &&
  ------------------
  |  Branch (11248:13): [True: 2.55k, False: 154]
  ------------------
11249|  2.55k|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (11249:14): [True: 1.90k, False: 653]
  ------------------
11250|  1.91k|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (11250:14): [True: 6, False: 647]
  ------------------
11251|  1.91k|          ada_log("FILE c is U+002F or U+005C");
11252|       |          // Set state to file slash state.
11253|  1.91k|          state = state::FILE_SLASH;
11254|  1.91k|        }
11255|       |        // Otherwise, if base is non-null and base's scheme is "file":
11256|    801|        else if (base_url != nullptr && base_url->type == scheme::type::FILE) {
  ------------------
  |  Branch (11256:18): [True: 289, False: 512]
  |  Branch (11256:41): [True: 212, False: 77]
  ------------------
11257|       |          // Set url's host to base's host, url's path to a clone of base's
11258|       |          // path, and url's query to base's query.
11259|    212|          ada_log("FILE base non-null");
11260|       |          if constexpr (result_type_is_ada_url) {
11261|       |            url.host = base_url->host;
11262|       |            url.path = base_url->path;
11263|       |            url.query = base_url->query;
11264|    212|          } else {
11265|    212|            url.update_host_to_base_host(base_url->get_hostname());
11266|    212|            url.update_base_pathname(base_url->get_pathname());
11267|    212|            if (base_url->has_search()) {
  ------------------
  |  Branch (11267:17): [True: 0, False: 212]
  ------------------
11268|       |              // get_search() returns "" for an empty query string (URL ends
11269|       |              // with '?'). update_base_search("") would incorrectly clear the
11270|       |              // query, so pass "?" to preserve the empty query distinction.
11271|      0|              auto s = base_url->get_search();
11272|      0|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (11272:38): [True: 0, False: 0]
  ------------------
11273|      0|            }
11274|    212|          }
11275|    212|          url.has_opaque_path = base_url->has_opaque_path;
11276|       |
11277|       |          // If c is U+003F (?), then set url's query to the empty string and
11278|       |          // state to query state.
11279|    212|          if (input_position != input_size && url_data[input_position] == '?') {
  ------------------
  |  Branch (11279:15): [True: 152, False: 60]
  |  Branch (11279:47): [True: 8, False: 144]
  ------------------
11280|      8|            state = state::QUERY;
11281|      8|          }
11282|       |          // Otherwise, if c is not the EOF code point:
11283|    204|          else if (input_position != input_size) {
  ------------------
  |  Branch (11283:20): [True: 144, False: 60]
  ------------------
11284|       |            // Set url's query to null.
11285|    144|            url.clear_search();
11286|       |            // If the code point substring from pointer to the end of input does
11287|       |            // not start with a Windows drive letter, then shorten url's path.
11288|    144|            if (!checkers::is_windows_drive_letter(file_view)) {
  ------------------
  |  Branch (11288:17): [True: 124, False: 20]
  ------------------
11289|       |              if constexpr (result_type_is_ada_url) {
11290|       |                helpers::shorten_path(url.path, url.type);
11291|    124|              } else {
11292|    124|                std::string_view path = url.get_pathname();
11293|    124|                if (helpers::shorten_path(path, url.type)) {
  ------------------
  |  Branch (11293:21): [True: 0, False: 124]
  ------------------
11294|      0|                  url.update_base_pathname(std::move(std::string(path)));
11295|      0|                }
11296|    124|              }
11297|    124|            }
11298|       |            // Otherwise:
11299|     20|            else {
11300|       |              // Set url's path to an empty list.
11301|     20|              url.clear_pathname();
11302|     20|              url.has_opaque_path = true;
11303|     20|            }
11304|       |
11305|       |            // Set state to path state and decrease pointer by 1.
11306|    144|            state = state::PATH;
11307|    144|            break;
11308|    144|          }
11309|    212|        }
11310|       |        // Otherwise, set state to path state, and decrease pointer by 1.
11311|    589|        else {
11312|    589|          ada_log("FILE go to path");
11313|    589|          state = state::PATH;
11314|    589|          break;
11315|    589|        }
11316|       |
11317|  1.98k|        input_position++;
11318|  1.98k|        break;
11319|  2.71k|      }
11320|      0|      default:
  ------------------
  |  Branch (11320:7): [True: 0, False: 100k]
  ------------------
11321|      0|        unreachable();
11322|   100k|    }
11323|   100k|  }
11324|       |  if constexpr (store_values) {
11325|       |    if (fragment.has_value()) {
11326|       |      url.update_unencoded_base_hash(*fragment);
11327|       |    }
11328|       |  }
11329|       |  // Check the resulting (normalized) URL size against the maximum input length.
11330|       |  // Normalization (percent-encoding, IDNA, etc.) can expand the URL beyond the
11331|       |  // original input size.
11332|       |  if constexpr (store_values) {
11333|       |    if (url.is_valid) {
11334|       |      if constexpr (result_type_is_ada_url_aggregator) {
11335|       |        if (url.buffer.size() > max_input_length) {
11336|       |          url.is_valid = false;
11337|       |        }
11338|       |      } else {
11339|       |        if (url.get_href_size() > max_input_length) {
11340|       |          url.is_valid = false;
11341|       |        }
11342|       |      }
11343|       |    }
11344|       |  }
11345|    192|  return url;
11346|  23.4k|}
_ZNK3ada14url_aggregator8get_hostEv:
12224|    244|    ada_lifetime_bound {
12225|    244|  ada_log("url_aggregator::get_host");
12226|       |  // Technically, we should check if there is a hostname, but
12227|       |  // the code below works even if there isn't.
12228|       |  // if(!has_hostname()) { return ""; }
12229|    244|  size_t start = components.host_start;
12230|    244|  if (components.host_end > components.host_start &&
  ------------------
  |  Branch (12230:7): [True: 60, False: 184]
  ------------------
12231|     60|      buffer[components.host_start] == '@') {
  ------------------
  |  Branch (12231:7): [True: 0, False: 60]
  ------------------
12232|      0|    start++;
12233|      0|  }
12234|       |  // if we have an empty host, then the space between components.host_end and
12235|       |  // components.pathname_start may be occupied by /.
12236|    244|  if (start == components.host_end) {
  ------------------
  |  Branch (12236:7): [True: 184, False: 60]
  ------------------
12237|    184|    return {};
12238|    184|  }
12239|     60|  return helpers::substring(buffer, start, components.pathname_start);
12240|    244|}
_ZNK3ada14url_aggregator12get_hostnameEv:
12243|  26.8k|    ada_lifetime_bound {
12244|  26.8k|  ada_log("url_aggregator::get_hostname");
12245|       |  // Technically, we should check if there is a hostname, but
12246|       |  // the code below works even if there isn't.
12247|       |  // if(!has_hostname()) { return ""; }
12248|  26.8k|  size_t start = components.host_start;
12249|       |  // So host_start is not where the host begins.
12250|  26.8k|  if (components.host_end > components.host_start &&
  ------------------
  |  Branch (12250:7): [True: 12.8k, False: 14.0k]
  ------------------
12251|  12.8k|      buffer[components.host_start] == '@') {
  ------------------
  |  Branch (12251:7): [True: 887, False: 11.9k]
  ------------------
12252|    887|    start++;
12253|    887|  }
12254|  26.8k|  return helpers::substring(buffer, start, components.host_end);
12255|  26.8k|}
_ZNK3ada14url_aggregator10get_searchEv:
12258|    187|    ada_lifetime_bound {
12259|    187|  ada_log("url_aggregator::get_search");
12260|       |  // If this's URL's query is either null or the empty string, then return the
12261|       |  // empty string. Return U+003F (?), followed by this's URL's query.
12262|    187|  if (components.search_start == url_components::omitted) {
  ------------------
  |  Branch (12262:7): [True: 0, False: 187]
  ------------------
12263|      0|    return "";
12264|      0|  }
12265|    187|  auto ending_index = uint32_t(buffer.size());
12266|    187|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (12266:7): [True: 49, False: 138]
  ------------------
12267|     49|    ending_index = components.hash_start;
12268|     49|  }
12269|    187|  if (ending_index - components.search_start <= 1) {
  ------------------
  |  Branch (12269:7): [True: 79, False: 108]
  ------------------
12270|     79|    return "";
12271|     79|  }
12272|    108|  return helpers::substring(buffer, components.search_start, ending_index);
12273|    187|}
_ZNK3ada14url_aggregator12get_protocolEv:
12276|  1.31k|    ada_lifetime_bound {
12277|  1.31k|  ada_log("url_aggregator::get_protocol");
12278|  1.31k|  return helpers::substring(buffer, 0, components.protocol_end);
12279|  1.31k|}
_ZN3ada14url_aggregator10parse_ipv4ENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEb:
12388|  2.57k|bool url_aggregator::parse_ipv4(std::string_view input, bool in_place) {
12389|  2.57k|  ada_log("parse_ipv4 ", input, " [", input.size(),
12390|  2.57k|          " bytes], overlaps with buffer: ",
12391|  2.57k|          helpers::overlaps(input, buffer) ? "yes" : "no");
12392|  2.57k|  ADA_ASSERT_TRUE(validate());
12393|  2.57k|  if (input.empty()) {
  ------------------
  |  Branch (12393:7): [True: 0, False: 2.57k]
  ------------------
12394|      0|    return is_valid = false;
12395|      0|  }
12396|  2.57k|  const bool trailing_dot = (input.back() == '.');
12397|  2.57k|  if (trailing_dot) {
  ------------------
  |  Branch (12397:7): [True: 64, False: 2.50k]
  ------------------
12398|     64|    input.remove_suffix(1);
12399|     64|    if (input.empty()) {
  ------------------
  |  Branch (12399:9): [True: 0, False: 64]
  ------------------
12400|      0|      return is_valid = false;
12401|      0|    }
12402|     64|  }
12403|       |
12404|  2.57k|  const uint64_t fast = checkers::try_parse_ipv4_fast(input);
12405|  2.57k|  if (fast < checkers::ipv4_fast_fail) [[likely]] {
  ------------------
  |  Branch (12405:7): [True: 18, False: 2.55k]
  ------------------
12406|       |    // Pure decimal: keep the buffer when it already holds the address.
12407|       |    // Otherwise write the (trailing-dot-stripped) input.
12408|     18|    if (!(in_place && !trailing_dot)) {
  ------------------
  |  Branch (12408:11): [True: 0, False: 18]
  |  Branch (12408:23): [True: 0, False: 0]
  ------------------
12409|     18|      update_base_hostname(input);
12410|     18|    }
12411|     18|    host_type = IPV4;
12412|     18|    ADA_ASSERT_TRUE(validate());
12413|     18|    return true;
12414|     18|  }
12415|       |
12416|  2.55k|  const char* p = input.data();
12417|  2.55k|  const char* end = p + input.size();
12418|  2.55k|  uint64_t ipv4 = 0;
12419|  2.55k|  int digit_count = 0;
12420|  2.55k|  int pure_decimal_count = 0;
12421|       |
12422|  3.45k|  for (; digit_count < 4 && p < end; ++digit_count) {
  ------------------
  |  Branch (12422:10): [True: 3.43k, False: 26]
  |  Branch (12422:29): [True: 3.43k, False: 0]
  ------------------
12423|  3.43k|    uint64_t segment = 0;
12424|  3.43k|    bool pure = false;
12425|  3.43k|    if (!detail::parse_ipv4_number(p, end, segment, pure)) {
  ------------------
  |  Branch (12425:9): [True: 358, False: 3.07k]
  ------------------
12426|    358|      return is_valid = false;
12427|    358|    }
12428|  3.07k|    if (pure) {
  ------------------
  |  Branch (12428:9): [True: 2.20k, False: 868]
  ------------------
12429|  2.20k|      ++pure_decimal_count;
12430|  2.20k|    }
12431|  3.07k|    if (p >= end) {
  ------------------
  |  Branch (12431:9): [True: 2.11k, False: 962]
  ------------------
12432|  2.11k|      const unsigned shift = static_cast<unsigned>(32 - digit_count * 8);
12433|  2.11k|      if (segment >= (uint64_t{1} << shift)) {
  ------------------
  |  Branch (12433:11): [True: 52, False: 2.05k]
  ------------------
12434|     52|        return is_valid = false;
12435|     52|      }
12436|  2.05k|      ipv4 = (ipv4 << shift) | segment;
12437|  2.05k|      goto ipv4_done;
12438|  2.11k|    }
12439|    962|    if (segment > 255 || *p != '.') {
  ------------------
  |  Branch (12439:9): [True: 60, False: 902]
  |  Branch (12439:26): [True: 0, False: 902]
  ------------------
12440|     60|      return is_valid = false;
12441|     60|    }
12442|    902|    ipv4 = (ipv4 << 8) | segment;
12443|    902|    ++p;
12444|    902|  }
12445|     26|  if (digit_count != 4 || p != end) {
  ------------------
  |  Branch (12445:7): [True: 0, False: 26]
  |  Branch (12445:27): [True: 26, False: 0]
  ------------------
12446|     26|    return is_valid = false;
12447|     26|  }
12448|  2.05k|ipv4_done:
12449|  2.05k|  ada_log("url_aggregator::parse_ipv4 completed ", get_href(),
12450|  2.05k|          " host: ", get_host());
12451|  2.05k|  if (in_place && pure_decimal_count == 4 && !trailing_dot) {
  ------------------
  |  Branch (12451:7): [True: 1.72k, False: 338]
  |  Branch (12451:19): [True: 0, False: 1.72k]
  |  Branch (12451:46): [True: 0, False: 0]
  ------------------
12452|      0|    ada_log(
12453|      0|        "url_aggregator::parse_ipv4 completed and was already correct in the "
12454|      0|        "buffer");
12455|  2.05k|  } else {
12456|  2.05k|    update_base_hostname(ada::serializers::ipv4(ipv4));
12457|  2.05k|  }
12458|  2.05k|  host_type = IPV4;
12459|  2.05k|  ADA_ASSERT_TRUE(validate());
12460|  2.05k|  return true;
12461|     26|}
_ZN3ada14url_aggregator10parse_ipv6ENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
12463|  1.14k|bool url_aggregator::parse_ipv6(std::string_view input) {
12464|  1.14k|  ada_log("parse_ipv6 ", input, " [", input.size(), " bytes]");
12465|  1.14k|  ADA_ASSERT_TRUE(validate());
12466|  1.14k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
12467|  1.14k|  if (input.empty() || input.size() > 45) [[unlikely]] {
  ------------------
  |  Branch (12467:7): [True: 32, False: 1.11k]
  |  Branch (12467:24): [True: 34, False: 1.08k]
  ------------------
12468|     66|    return is_valid = false;
12469|     66|  }
12470|       |#if defined(ADA_AVX512)
12471|       |  if (!detail::ipv6_structure_plausible(input.data(), input.size()))
12472|       |      [[unlikely]] {
12473|       |    return is_valid = false;
12474|       |  }
12475|       |#endif
12476|       |
12477|  1.08k|  std::array<uint16_t, 8> address{};
12478|  1.08k|  const char* pointer = input.data();
12479|  1.08k|  const char* const end = pointer + input.size();
12480|  1.08k|  int piece_index = 0;
12481|  1.08k|  int compress = -1;
12482|       |
12483|  1.08k|  if (*pointer == ':') {
  ------------------
  |  Branch (12483:7): [True: 406, False: 674]
  ------------------
12484|    406|    if (input.size() == 1 || pointer[1] != ':') [[unlikely]] {
  ------------------
  |  Branch (12484:9): [True: 6, False: 400]
  |  Branch (12484:30): [True: 18, False: 382]
  ------------------
12485|     24|      return is_valid = false;
12486|     24|    }
12487|    382|    pointer += 2;
12488|    382|    compress = ++piece_index;
12489|    382|  }
12490|       |
12491|  2.97k|  while (pointer != end) {
  ------------------
  |  Branch (12491:10): [True: 2.26k, False: 712]
  ------------------
12492|  2.26k|    if (piece_index == 8) [[unlikely]] {
  ------------------
  |  Branch (12492:9): [True: 6, False: 2.26k]
  ------------------
12493|      6|      return is_valid = false;
12494|      6|    }
12495|  2.26k|    if (*pointer == ':') {
  ------------------
  |  Branch (12495:9): [True: 300, False: 1.96k]
  ------------------
12496|    300|      if (compress != -1) [[unlikely]] {
  ------------------
  |  Branch (12496:11): [True: 6, False: 294]
  ------------------
12497|      6|        return is_valid = false;
12498|      6|      }
12499|    294|      ++pointer;
12500|    294|      compress = ++piece_index;
12501|    294|      continue;
12502|    300|    }
12503|       |
12504|  1.96k|    uint16_t value = 0;
12505|  1.96k|    const int length = detail::parse_hex_piece(pointer, end, value);
12506|       |
12507|  1.96k|    if (pointer != end && *pointer == '.') {
  ------------------
  |  Branch (12507:9): [True: 1.58k, False: 376]
  |  Branch (12507:27): [True: 202, False: 1.38k]
  ------------------
12508|    202|      if (length == 0) [[unlikely]] {
  ------------------
  |  Branch (12508:11): [True: 8, False: 194]
  ------------------
12509|      8|        return is_valid = false;
12510|      8|      }
12511|    194|      pointer -= length;
12512|    194|      if (piece_index > 6) [[unlikely]] {
  ------------------
  |  Branch (12512:11): [True: 6, False: 188]
  ------------------
12513|      6|        return is_valid = false;
12514|      6|      }
12515|       |
12516|    188|      int numbers_seen = 0;
12517|    544|      while (pointer != end) {
  ------------------
  |  Branch (12517:14): [True: 490, False: 54]
  ------------------
12518|    490|        int ipv4_piece = -1;
12519|    490|        if (numbers_seen > 0) {
  ------------------
  |  Branch (12519:13): [True: 302, False: 188]
  ------------------
12520|    302|          if (*pointer == '.' && numbers_seen < 4) {
  ------------------
  |  Branch (12520:15): [True: 260, False: 42]
  |  Branch (12520:34): [True: 250, False: 10]
  ------------------
12521|    250|            ++pointer;
12522|    250|          } else {
12523|     52|            return is_valid = false;
12524|     52|          }
12525|    302|        }
12526|    438|        if (pointer == end || *pointer < '0' || *pointer > '9') [[unlikely]] {
  ------------------
  |  Branch (12526:13): [True: 40, False: 398]
  |  Branch (12526:31): [True: 12, False: 386]
  |  Branch (12526:49): [True: 12, False: 374]
  ------------------
12527|     64|          return is_valid = false;
12528|     64|        }
12529|    374|        ipv4_piece = *pointer - '0';
12530|    374|        ++pointer;
12531|    374|        if (pointer != end && *pointer >= '0' && *pointer <= '9') {
  ------------------
  |  Branch (12531:13): [True: 338, False: 36]
  |  Branch (12531:31): [True: 138, False: 200]
  |  Branch (12531:50): [True: 132, False: 6]
  ------------------
12532|    132|          if (ipv4_piece == 0) [[unlikely]] {
  ------------------
  |  Branch (12532:15): [True: 6, False: 126]
  ------------------
12533|      6|            return is_valid = false;
12534|      6|          }
12535|    126|          ipv4_piece = ipv4_piece * 10 + (*pointer - '0');
12536|    126|          ++pointer;
12537|    126|          if (pointer != end && *pointer >= '0' && *pointer <= '9') {
  ------------------
  |  Branch (12537:15): [True: 120, False: 6]
  |  Branch (12537:33): [True: 62, False: 58]
  |  Branch (12537:52): [True: 56, False: 6]
  ------------------
12538|     56|            ipv4_piece = ipv4_piece * 10 + (*pointer - '0');
12539|     56|            ++pointer;
12540|     56|            if (ipv4_piece > 255) [[unlikely]] {
  ------------------
  |  Branch (12540:17): [True: 12, False: 44]
  ------------------
12541|     12|              return is_valid = false;
12542|     12|            }
12543|     56|          }
12544|    126|        }
12545|    356|        address[static_cast<size_t>(piece_index)] = static_cast<uint16_t>(
12546|    356|            address[static_cast<size_t>(piece_index)] * 0x100 +
12547|    356|            static_cast<uint16_t>(ipv4_piece));
12548|    356|        ++numbers_seen;
12549|    356|        if (numbers_seen == 2 || numbers_seen == 4) {
  ------------------
  |  Branch (12549:13): [True: 108, False: 248]
  |  Branch (12549:34): [True: 34, False: 214]
  ------------------
12550|    142|          ++piece_index;
12551|    142|        }
12552|    356|      }
12553|     54|      if (numbers_seen != 4) [[unlikely]] {
  ------------------
  |  Branch (12553:11): [True: 32, False: 22]
  ------------------
12554|     32|        return is_valid = false;
12555|     32|      }
12556|     22|      break;
12557|     54|    }
12558|       |
12559|  1.75k|    if (length == 0) [[unlikely]] {
  ------------------
  |  Branch (12559:9): [True: 100, False: 1.65k]
  ------------------
12560|    100|      return is_valid = false;
12561|    100|    }
12562|       |
12563|  1.65k|    if (pointer != end && *pointer == ':') {
  ------------------
  |  Branch (12563:9): [True: 1.28k, False: 376]
  |  Branch (12563:27): [True: 1.26k, False: 22]
  ------------------
12564|  1.26k|      ++pointer;
12565|  1.26k|      if (pointer == end) [[unlikely]] {
  ------------------
  |  Branch (12565:11): [True: 8, False: 1.25k]
  ------------------
12566|      8|        return is_valid = false;
12567|      8|      }
12568|  1.26k|    } else if (pointer != end) [[unlikely]] {
  ------------------
  |  Branch (12568:16): [True: 22, False: 376]
  ------------------
12569|     22|      return is_valid = false;
12570|     22|    }
12571|       |
12572|  1.62k|    address[static_cast<size_t>(piece_index)] = value;
12573|  1.62k|    ++piece_index;
12574|  1.62k|  }
12575|       |
12576|    734|  if (compress != -1) {
  ------------------
  |  Branch (12576:7): [True: 656, False: 78]
  ------------------
12577|    656|    const int right = piece_index - compress;
12578|    656|    if (right > 0) {
  ------------------
  |  Branch (12578:9): [True: 320, False: 336]
  ------------------
12579|    320|      const size_t dest = static_cast<size_t>(8 - right);
12580|    320|      const size_t src = static_cast<size_t>(compress);
12581|    320|      if (dest != src) {
  ------------------
  |  Branch (12581:11): [True: 292, False: 28]
  ------------------
12582|    860|        for (size_t i = static_cast<size_t>(right); i-- > 0;) {
  ------------------
  |  Branch (12582:53): [True: 568, False: 292]
  ------------------
12583|    568|          address[dest + i] = address[src + i];
12584|    568|          address[src + i] = 0;
12585|    568|        }
12586|    292|      }
12587|    320|    }
12588|    656|  } else if (piece_index != 8) [[unlikely]] {
  ------------------
  |  Branch (12588:14): [True: 42, False: 36]
  ------------------
12589|     42|    return is_valid = false;
12590|     42|  }
12591|       |
12592|       |  // Serialize once; skip rewrite when hostname is already canonical.
12593|    692|  const std::string serialized = ada::serializers::ipv6(address);
12594|    692|  const std::string_view current = get_hostname();
12595|    692|  if (current.size() == serialized.size() &&
  ------------------
  |  Branch (12595:7): [True: 0, False: 692]
  ------------------
12596|      0|      std::memcmp(current.data(), serialized.data(), serialized.size()) == 0) {
  ------------------
  |  Branch (12596:7): [True: 0, False: 0]
  ------------------
12597|      0|    ada_log("parse_ipv6 in-place canonical match");
12598|    692|  } else {
12599|    692|    update_base_hostname(serialized);
12600|    692|  }
12601|    692|  ada_log("parse_ipv6 ", get_hostname());
12602|    692|  ADA_ASSERT_TRUE(validate());
12603|    692|  host_type = IPV6;
12604|    692|  return true;
12605|    734|}
_ZN3ada14url_aggregator17parse_opaque_hostENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
12607|    822|bool url_aggregator::parse_opaque_host(std::string_view input) {
12608|    822|  ada_log("parse_opaque_host ", input, " [", input.size(), " bytes]");
12609|    822|  ADA_ASSERT_TRUE(validate());
12610|    822|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
12611|    822|  if (std::ranges::any_of(input, ada::unicode::is_forbidden_host_code_point)) {
  ------------------
  |  Branch (12611:7): [True: 18, False: 804]
  ------------------
12612|     18|    return is_valid = false;
12613|     18|  }
12614|       |
12615|       |  // Return the result of running UTF-8 percent-encode on input using the C0
12616|       |  // control percent-encode set.
12617|    804|  size_t idx = ada::unicode::percent_encode_index(
12618|    804|      input, character_sets::C0_CONTROL_PERCENT_ENCODE);
12619|    804|  if (idx == input.size()) {
  ------------------
  |  Branch (12619:7): [True: 492, False: 312]
  ------------------
12620|    492|    update_base_hostname(input);
12621|    492|  } else {
12622|       |    // We only create a temporary string if we need to.
12623|    312|    update_base_hostname(ada::unicode::percent_encode(
12624|    312|        input, character_sets::C0_CONTROL_PERCENT_ENCODE, idx));
12625|    312|  }
12626|    804|  ADA_ASSERT_TRUE(validate());
12627|    804|  return true;
12628|    822|}
_ZN3ada14url_aggregator15delete_dash_dotEv:
12787|      6|void url_aggregator::delete_dash_dot() {
12788|      6|  ada_log("url_aggregator::delete_dash_dot");
12789|      6|  ADA_ASSERT_TRUE(validate());
12790|      6|  ADA_ASSERT_TRUE(has_dash_dot());
12791|      6|  buffer.erase(components.host_end, 2);
12792|      6|  components.pathname_start -= 2;
12793|      6|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (12793:7): [True: 0, False: 6]
  ------------------
12794|      0|    components.search_start -= 2;
12795|      0|  }
12796|      6|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (12796:7): [True: 0, False: 6]
  ------------------
12797|      0|    components.hash_start -= 2;
12798|      0|  }
12799|      6|  ADA_ASSERT_TRUE(validate());
12800|      6|  ADA_ASSERT_TRUE(!has_dash_dot());
12801|      6|}
can_parse.cc:_ZZN3ada4idna22utf32_length_from_utf8EPKcmENK3$_0clEa:
  284|   435k|  return std::count_if(p, std::next(p, len), [](int8_t c) {
  285|       |    // -65 is 0b10111111, anything larger in two-complement's
  286|       |    // should start a new code point.
  287|   435k|    return c > -65;
  288|   435k|  });
_ZN3ada4idna7deflate22make_fixed_litlen_huffEv:
  490|      2|inline Huff make_fixed_litlen_huff() {
  491|      2|  Huff h;
  492|      2|  uint8_t lens[288];
  493|       |  // Fixed Huffman: 0-143:8, 144-255:9, 256-279:7, 280-287:8
  494|    290|  for (int i = 0; i <= 143; i++) lens[i] = 8;
  ------------------
  |  Branch (494:19): [True: 288, False: 2]
  ------------------
  495|    226|  for (int i = 144; i <= 255; i++) lens[i] = 9;
  ------------------
  |  Branch (495:21): [True: 224, False: 2]
  ------------------
  496|     50|  for (int i = 256; i <= 279; i++) lens[i] = 7;
  ------------------
  |  Branch (496:21): [True: 48, False: 2]
  ------------------
  497|     18|  for (int i = 280; i <= 287; i++) lens[i] = 8;
  ------------------
  |  Branch (497:21): [True: 16, False: 2]
  ------------------
  498|      2|  h.build(lens, 288);
  499|      2|  return h;
  500|      2|}
_ZN3ada4idna7deflate4Huff5buildEPKhi:
  439|     16|  bool build(const uint8_t* lens, int n) {
  440|     16|    std::memset(counts, 0, sizeof(counts));
  441|     16|    std::memset(first_code, 0, sizeof(first_code));
  442|     16|    std::memset(base_idx, 0, sizeof(base_idx));
  443|     16|    nsymbols = n;
  444|     16|    max_bits = 0;
  445|  1.98k|    for (int i = 0; i < n; i++) {
  ------------------
  |  Branch (445:21): [True: 1.96k, False: 16]
  ------------------
  446|  1.96k|      lengths[i] = lens[i];
  447|  1.96k|      if (lens[i]) {
  ------------------
  |  Branch (447:11): [True: 1.91k, False: 49]
  ------------------
  448|  1.91k|        counts[lens[i]]++;
  449|  1.91k|        if (lens[i] > max_bits) max_bits = lens[i];
  ------------------
  |  Branch (449:13): [True: 46, False: 1.87k]
  ------------------
  450|  1.91k|      }
  451|  1.96k|    }
  452|       |    // Canonical first code for each bit length (RFC 1951).
  453|     16|    int code = 0;
  454|    256|    for (int bits = 1; bits <= MAXBITS; bits++) {
  ------------------
  |  Branch (454:24): [True: 240, False: 16]
  ------------------
  455|    240|      code = (code + counts[bits - 1]) << 1;
  456|    240|      first_code[bits] = code;
  457|    240|    }
  458|     16|    int idx = 0;
  459|    158|    for (int bits = 1; bits <= max_bits; bits++) {
  ------------------
  |  Branch (459:24): [True: 142, False: 16]
  ------------------
  460|    142|      base_idx[bits] = idx;
  461|       |      // assign symbols in symbol order for codes of this length
  462|  21.6k|      for (int sym = 0; sym < n; sym++) {
  ------------------
  |  Branch (462:25): [True: 21.5k, False: 142]
  ------------------
  463|  21.5k|        if (lengths[sym] == bits) {
  ------------------
  |  Branch (463:13): [True: 1.91k, False: 19.6k]
  ------------------
  464|  1.91k|          symbols[idx++] = static_cast<int16_t>(sym);
  465|  1.91k|        }
  466|  21.5k|      }
  467|    142|    }
  468|     16|    return true;
  469|     16|  }
_ZN3ada4idna7deflate20make_fixed_dist_huffEv:
  502|      2|inline Huff make_fixed_dist_huff() {
  503|      2|  Huff h;
  504|      2|  uint8_t lens[32];
  505|     66|  for (int i = 0; i < 32; i++) lens[i] = 5;
  ------------------
  |  Branch (505:19): [True: 64, False: 2]
  ------------------
  506|      2|  h.build(lens, 32);
  507|      2|  return h;
  508|      2|}
can_parse.cc:_ZZN3ada4idna9ascii_mapEPcmENK3$_0clEh:
 5134|  21.4k|  auto broadcast = [](uint8_t v) -> uint64_t {
 5135|  21.4k|    return 0x101010101010101ull * v;
 5136|  21.4k|  };
_ZN3ada4idna13ensure_tablesEv:
 4885|  57.8k|[[nodiscard]] inline bool ensure_tables() noexcept {
 4886|  57.8k|  uint8_t state = tables_init_state.load(std::memory_order_acquire);
 4887|  57.8k|  if (state == kTablesReady) {
  ------------------
  |  Branch (4887:7): [True: 57.8k, False: 1]
  ------------------
 4888|  57.8k|    return true;
 4889|  57.8k|  }
 4890|      1|  if (state == kTablesFailed) {
  ------------------
  |  Branch (4890:7): [True: 0, False: 1]
  ------------------
 4891|      0|    return false;
 4892|      0|  }
 4893|       |
 4894|      1|  uint8_t expected = kTablesUninit;
 4895|      1|  if (tables_init_state.compare_exchange_strong(expected, kTablesInProgress,
  ------------------
  |  Branch (4895:7): [True: 1, False: 0]
  ------------------
 4896|      1|                                                std::memory_order_acq_rel,
 4897|      1|                                                std::memory_order_acquire)) {
 4898|      1|    uint8_t* buffer = new (std::nothrow) uint8_t[table_blob::uncompressed_size];
 4899|      1|    if (buffer == nullptr) {
  ------------------
  |  Branch (4899:9): [True: 0, False: 1]
  ------------------
 4900|      0|      tables_init_state.store(kTablesFailed, std::memory_order_release);
 4901|      0|      return false;
 4902|      0|    }
 4903|       |
 4904|      1|    const size_t n = deflate::inflate_raw(table_blob::compressed,
 4905|      1|                                          table_blob::compressed_size, buffer,
 4906|      1|                                          table_blob::uncompressed_size);
 4907|      1|    if (n != table_blob::uncompressed_size ||
  ------------------
  |  Branch (4907:9): [True: 0, False: 1]
  ------------------
 4908|      1|        crc32_ieee(buffer, n) != table_blob::uncompressed_crc32) {
  ------------------
  |  Branch (4908:9): [True: 0, False: 1]
  ------------------
 4909|      0|      delete[] buffer;
 4910|      0|      tables_init_state.store(kTablesFailed, std::memory_order_release);
 4911|      0|      return false;
 4912|      0|    }
 4913|       |
 4914|       |    // LE payload verified; convert multi-byte fields for big-endian hosts.
 4915|      1|    detail::convert_table_blob_to_host_endian(buffer);
 4916|       |
 4917|      1|    auto at = [&](size_t off) noexcept -> const uint8_t* {
 4918|      1|      return buffer + off;
 4919|      1|    };
 4920|       |
 4921|       |    // Publish all non-atomic pointers before READY. Waiters synchronize via
 4922|       |    // acquire on tables_init_state and then observe these writes.
 4923|      1|    idna_stage1 =
 4924|      1|        reinterpret_cast<const uint16_t*>(at(table_blob::off_idna_stage1));
 4925|      1|    idna_stage2 =
 4926|      1|        reinterpret_cast<const uint16_t*>(at(table_blob::off_idna_stage2));
 4927|      1|    idna_bool_blocks =
 4928|      1|        reinterpret_cast<const uint64_t*>(at(table_blob::off_idna_bool_blocks));
 4929|      1|    idna_utf8_mappings = at(table_blob::off_idna_utf8_mappings);
 4930|       |
 4931|      1|    decomposition_index = at(table_blob::off_decomposition_index);
 4932|      1|    decomposition_block_flat = reinterpret_cast<const uint16_t*>(
 4933|      1|        at(table_blob::off_decomposition_block));
 4934|      1|    decomposition_data = reinterpret_cast<const char32_t*>(
 4935|      1|        at(table_blob::off_decomposition_data));
 4936|      1|    ccc_index = at(table_blob::off_ccc_index);
 4937|      1|    ccc_block_flat = at(table_blob::off_ccc_block);
 4938|      1|    composition_index = at(table_blob::off_composition_index);
 4939|      1|    composition_block_flat = reinterpret_cast<const uint16_t*>(
 4940|      1|        at(table_blob::off_composition_block));
 4941|      1|    composition_data =
 4942|      1|        reinterpret_cast<const char32_t*>(at(table_blob::off_composition_data));
 4943|       |
 4944|      1|    id_continue =
 4945|      1|        reinterpret_cast<range_pair_ptr>(at(table_blob::off_id_continue_flat));
 4946|      1|    id_start =
 4947|      1|        reinterpret_cast<range_pair_ptr>(at(table_blob::off_id_start_flat));
 4948|       |
 4949|      1|    dir_start =
 4950|      1|        reinterpret_cast<const uint32_t*>(at(table_blob::off_dir_start));
 4951|      1|    dir_final =
 4952|      1|        reinterpret_cast<const uint32_t*>(at(table_blob::off_dir_final));
 4953|      1|    dir_value = at(table_blob::off_dir_value);
 4954|      1|    combining_ranges =
 4955|      1|        reinterpret_cast<range_pair_ptr>(at(table_blob::off_combining_flat));
 4956|       |
 4957|      1|    tables_buffer = buffer;
 4958|      1|    tables_init_state.store(kTablesReady, std::memory_order_release);
 4959|      1|    return true;
 4960|      1|  }
 4961|       |
 4962|       |  // Another thread owns init (or finished between our loads).
 4963|      0|  for (uint64_t spins = 0; spins < kTablesSpinLimit; ++spins) {
  ------------------
  |  Branch (4963:28): [True: 0, False: 0]
  ------------------
 4964|      0|    state = tables_init_state.load(std::memory_order_acquire);
 4965|      0|    if (state == kTablesReady) {
  ------------------
  |  Branch (4965:9): [True: 0, False: 0]
  ------------------
 4966|      0|      return true;
 4967|      0|    }
 4968|      0|    if (state == kTablesFailed) {
  ------------------
  |  Branch (4968:9): [True: 0, False: 0]
  ------------------
 4969|      0|      return false;
 4970|      0|    }
 4971|      0|#if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || \
 4972|      0|    defined(_M_IX86)
 4973|      0|#if defined(__GNUC__) || defined(__clang__)
 4974|      0|    __builtin_ia32_pause();
 4975|      0|#endif
 4976|       |#elif defined(__aarch64__) || defined(_M_ARM64)
 4977|       |#if defined(__GNUC__) || defined(__clang__)
 4978|       |    asm volatile("yield" ::: "memory");
 4979|       |#endif
 4980|       |#endif
 4981|      0|  }
 4982|       |  // Timed out waiting for a peer - treat as failure rather than hang.
 4983|      0|  return false;
 4984|      0|}
_ZN3ada4idna7deflate11inflate_rawEPKhmPhm:
  535|      1|                          size_t dst_cap) {
  536|      1|  BitReader br(src, src_len);
  537|      1|  size_t out = 0;
  538|      4|  for (;;) {
  539|      4|    uint32_t bfinal = br.get(1);
  540|      4|    uint32_t btype = br.get(2);
  541|      4|    if (bfinal == UINT32_MAX || btype == UINT32_MAX) return 0;
  ------------------
  |  Branch (541:9): [True: 0, False: 4]
  |  Branch (541:33): [True: 0, False: 4]
  ------------------
  542|      4|    if (btype == 0) {
  ------------------
  |  Branch (542:9): [True: 0, False: 4]
  ------------------
  543|       |      // stored
  544|      0|      br.align_byte();
  545|      0|      if (!br.ensure(16)) return 0;
  ------------------
  |  Branch (545:11): [True: 0, False: 0]
  ------------------
  546|       |      // read 16+16 from bit buffer awkwardly - use byte path
  547|       |      // Align: bits is multiple of 8
  548|       |      // Get len from remaining bits then bytes
  549|      0|      uint32_t len = br.get(16);
  550|      0|      uint32_t nlen = br.get(16);
  551|      0|      if (len == UINT32_MAX || nlen == UINT32_MAX) return 0;
  ------------------
  |  Branch (551:11): [True: 0, False: 0]
  |  Branch (551:32): [True: 0, False: 0]
  ------------------
  552|      0|      if ((len ^ 0xFFFF) != nlen) return 0;
  ------------------
  |  Branch (552:11): [True: 0, False: 0]
  ------------------
  553|       |      // After get, may have bits in acc from previous - for stored, should be
  554|       |      // byte aligned Copy len bytes from p
  555|      0|      if (br.bits != 0) {
  ------------------
  |  Branch (555:11): [True: 0, False: 0]
  ------------------
  556|       |        // leftover bits should be 0 if aligned
  557|      0|      }
  558|      0|      if (size_t(br.end - br.p) < len) return 0;
  ------------------
  |  Branch (558:11): [True: 0, False: 0]
  ------------------
  559|      0|      if (out + len > dst_cap) return 0;
  ------------------
  |  Branch (559:11): [True: 0, False: 0]
  ------------------
  560|      0|      std::memcpy(dst + out, br.p, len);
  561|      0|      br.p += len;
  562|      0|      out += len;
  563|      4|    } else if (btype == 1 || btype == 2) {
  ------------------
  |  Branch (563:16): [True: 0, False: 4]
  |  Branch (563:30): [True: 4, False: 0]
  ------------------
  564|      4|      Huff lit, dist;
  565|      4|      if (btype == 1) {
  ------------------
  |  Branch (565:11): [True: 0, False: 4]
  ------------------
  566|       |        // use fixed via functions
  567|      4|      } else {
  568|       |        // dynamic
  569|      4|        uint32_t hlit = br.get(5);
  570|      4|        if (hlit == UINT32_MAX) return 0;
  ------------------
  |  Branch (570:13): [True: 0, False: 4]
  ------------------
  571|      4|        hlit += 257;
  572|      4|        uint32_t hdist = br.get(5);
  573|      4|        if (hdist == UINT32_MAX) return 0;
  ------------------
  |  Branch (573:13): [True: 0, False: 4]
  ------------------
  574|      4|        hdist += 1;
  575|      4|        uint32_t hclen = br.get(4);
  576|      4|        if (hclen == UINT32_MAX) return 0;
  ------------------
  |  Branch (576:13): [True: 0, False: 4]
  ------------------
  577|      4|        hclen += 4;
  578|      4|        static const int order[19] = {16, 17, 18, 0, 8,  7, 9,  6, 10, 5,
  579|      4|                                      11, 4,  12, 3, 13, 2, 14, 1, 15};
  580|      4|        uint8_t clen[19]{};
  581|     69|        for (uint32_t i = 0; i < hclen; i++) {
  ------------------
  |  Branch (581:30): [True: 65, False: 4]
  ------------------
  582|     65|          uint32_t v = br.get(3);
  583|     65|          if (v == UINT32_MAX) return 0;
  ------------------
  |  Branch (583:15): [True: 0, False: 65]
  ------------------
  584|     65|          clen[order[i]] = uint8_t(v);
  585|     65|        }
  586|      4|        Huff cl;
  587|      4|        if (!cl.build(clen, 19)) return 0;
  ------------------
  |  Branch (587:13): [True: 0, False: 4]
  ------------------
  588|      4|        uint8_t lens[288 + 32]{};
  589|      4|        uint32_t n = hlit + hdist;
  590|  1.09k|        for (uint32_t i = 0; i < n;) {
  ------------------
  |  Branch (590:30): [True: 1.08k, False: 4]
  ------------------
  591|  1.08k|          int sym = cl.decode(br);
  592|  1.08k|          if (sym < 0) return 0;
  ------------------
  |  Branch (592:15): [True: 0, False: 1.08k]
  ------------------
  593|  1.08k|          if (sym < 16) {
  ------------------
  |  Branch (593:15): [True: 1.03k, False: 49]
  ------------------
  594|  1.03k|            lens[i++] = uint8_t(sym);
  595|  1.03k|          } else if (sym == 16) {
  ------------------
  |  Branch (595:22): [True: 49, False: 0]
  ------------------
  596|     49|            uint32_t rep = br.get(2);
  597|     49|            if (rep == UINT32_MAX) return 0;
  ------------------
  |  Branch (597:17): [True: 0, False: 49]
  ------------------
  598|     49|            rep += 3;
  599|     49|            if (i == 0) return 0;
  ------------------
  |  Branch (599:17): [True: 0, False: 49]
  ------------------
  600|     49|            uint8_t v = lens[i - 1];
  601|    263|            while (rep--) lens[i++] = v;
  ------------------
  |  Branch (601:20): [True: 214, False: 49]
  ------------------
  602|     49|          } else if (sym == 17) {
  ------------------
  |  Branch (602:22): [True: 0, False: 0]
  ------------------
  603|      0|            uint32_t rep = br.get(3);
  604|      0|            if (rep == UINT32_MAX) return 0;
  ------------------
  |  Branch (604:17): [True: 0, False: 0]
  ------------------
  605|      0|            rep += 3;
  606|      0|            while (rep--) lens[i++] = 0;
  ------------------
  |  Branch (606:20): [True: 0, False: 0]
  ------------------
  607|      0|          } else if (sym == 18) {
  ------------------
  |  Branch (607:22): [True: 0, False: 0]
  ------------------
  608|      0|            uint32_t rep = br.get(7);
  609|      0|            if (rep == UINT32_MAX) return 0;
  ------------------
  |  Branch (609:17): [True: 0, False: 0]
  ------------------
  610|      0|            rep += 11;
  611|      0|            while (rep--) lens[i++] = 0;
  ------------------
  |  Branch (611:20): [True: 0, False: 0]
  ------------------
  612|      0|          } else
  613|      0|            return 0;
  614|  1.08k|        }
  615|      4|        if (!lit.build(lens, int(hlit))) return 0;
  ------------------
  |  Branch (615:13): [True: 0, False: 4]
  ------------------
  616|      4|        if (!dist.build(lens + hlit, int(hdist))) return 0;
  ------------------
  |  Branch (616:13): [True: 0, False: 4]
  ------------------
  617|      4|      }
  618|  52.2k|      for (;;) {
  619|  52.2k|        int sym;
  620|  52.2k|        if (btype == 1)
  ------------------
  |  Branch (620:13): [True: 0, False: 52.2k]
  ------------------
  621|      0|          sym = fixed_litlen(br);
  622|  52.2k|        else
  623|  52.2k|          sym = lit.decode(br);
  624|  52.2k|        if (sym < 0) return 0;
  ------------------
  |  Branch (624:13): [True: 0, False: 52.2k]
  ------------------
  625|  52.2k|        if (sym < 256) {
  ------------------
  |  Branch (625:13): [True: 37.2k, False: 14.9k]
  ------------------
  626|  37.2k|          if (out >= dst_cap) return 0;
  ------------------
  |  Branch (626:15): [True: 0, False: 37.2k]
  ------------------
  627|  37.2k|          dst[out++] = uint8_t(sym);
  628|  37.2k|        } else if (sym == 256) {
  ------------------
  |  Branch (628:20): [True: 4, False: 14.9k]
  ------------------
  629|      4|          break;
  630|  14.9k|        } else {
  631|  14.9k|          int len_code = sym - 257;
  632|  14.9k|          if (len_code < 0 || len_code > 28) return 0;
  ------------------
  |  Branch (632:15): [True: 0, False: 14.9k]
  |  Branch (632:31): [True: 0, False: 14.9k]
  ------------------
  633|  14.9k|          uint32_t extra = br.get(len_extra[len_code]);
  634|  14.9k|          if (len_extra[len_code] && extra == UINT32_MAX) return 0;
  ------------------
  |  Branch (634:15): [True: 2.03k, False: 12.9k]
  |  Branch (634:38): [True: 0, False: 2.03k]
  ------------------
  635|  14.9k|          uint32_t length =
  636|  14.9k|              len_base[len_code] + (len_extra[len_code] ? extra : 0);
  ------------------
  |  Branch (636:37): [True: 2.03k, False: 12.9k]
  ------------------
  637|  14.9k|          int dsym;
  638|  14.9k|          if (btype == 1)
  ------------------
  |  Branch (638:15): [True: 0, False: 14.9k]
  ------------------
  639|      0|            dsym = fixed_dist(br);
  640|  14.9k|          else
  641|  14.9k|            dsym = dist.decode(br);
  642|  14.9k|          if (dsym < 0 || dsym > 29) return 0;
  ------------------
  |  Branch (642:15): [True: 0, False: 14.9k]
  |  Branch (642:27): [True: 0, False: 14.9k]
  ------------------
  643|  14.9k|          uint32_t dextra = br.get(dist_extra[dsym]);
  644|  14.9k|          if (dist_extra[dsym] && dextra == UINT32_MAX) return 0;
  ------------------
  |  Branch (644:15): [True: 9.97k, False: 5.01k]
  |  Branch (644:35): [True: 0, False: 9.97k]
  ------------------
  645|  14.9k|          uint32_t distance = dist_base[dsym] + (dist_extra[dsym] ? dextra : 0);
  ------------------
  |  Branch (645:50): [True: 9.97k, False: 5.01k]
  ------------------
  646|  14.9k|          if (distance > out || out + length > dst_cap) return 0;
  ------------------
  |  Branch (646:15): [True: 0, False: 14.9k]
  |  Branch (646:33): [True: 0, False: 14.9k]
  ------------------
  647|   202k|          for (uint32_t k = 0; k < length; k++) {
  ------------------
  |  Branch (647:32): [True: 187k, False: 14.9k]
  ------------------
  648|   187k|            dst[out] = dst[out - distance];
  649|   187k|            out++;
  650|   187k|          }
  651|  14.9k|        }
  652|  52.2k|      }
  653|      4|    } else {
  654|      0|      return 0;  // reserved
  655|      0|    }
  656|      4|    if (bfinal) break;
  ------------------
  |  Branch (656:9): [True: 1, False: 3]
  ------------------
  657|      4|  }
  658|      1|  return out;
  659|      1|}
_ZN3ada4idna7deflate9BitReaderC2EPKhm:
  402|      1|      : p(data), end(data + len) {}
_ZN3ada4idna7deflate9BitReader3getEi:
  412|   457k|  uint32_t get(int n) {
  413|   457k|    if (!ensure(n)) return UINT32_MAX;
  ------------------
  |  Branch (413:9): [True: 0, False: 457k]
  ------------------
  414|   457k|    uint32_t v = acc & ((1u << n) - 1);
  415|   457k|    acc >>= n;
  416|   457k|    bits -= n;
  417|   457k|    return v;
  418|   457k|  }
_ZN3ada4idna7deflate9BitReader6ensureEi:
  404|   457k|  bool ensure(int n) {
  405|   520k|    while (bits < n) {
  ------------------
  |  Branch (405:12): [True: 62.3k, False: 457k]
  ------------------
  406|  62.3k|      if (p >= end) return false;
  ------------------
  |  Branch (406:11): [True: 0, False: 62.3k]
  ------------------
  407|  62.3k|      acc |= uint32_t(*p++) << bits;
  408|  62.3k|      bits += 8;
  409|  62.3k|    }
  410|   457k|    return true;
  411|   457k|  }
_ZNK3ada4idna7deflate4Huff6decodeERNS1_9BitReaderE:
  471|  68.3k|  int decode(BitReader& br) const {
  472|  68.3k|    if (max_bits == 0) return -1;
  ------------------
  |  Branch (472:9): [True: 0, False: 68.3k]
  ------------------
  473|  68.3k|    int code = 0;
  474|   427k|    for (int len = 1; len <= max_bits; len++) {
  ------------------
  |  Branch (474:23): [True: 427k, False: 0]
  ------------------
  475|   427k|      uint32_t b = br.get(1);
  476|   427k|      if (b == UINT32_MAX) return -1;
  ------------------
  |  Branch (476:11): [True: 0, False: 427k]
  ------------------
  477|   427k|      code = (code << 1) | int(b);
  478|   427k|      int first = first_code[len];
  479|   427k|      int cnt = counts[len];
  480|   427k|      if (cnt && code - first < cnt) {
  ------------------
  |  Branch (480:11): [True: 263k, False: 164k]
  |  Branch (480:18): [True: 68.3k, False: 195k]
  ------------------
  481|  68.3k|        return symbols[base_idx[len] + (code - first)];
  482|  68.3k|      }
  483|   427k|    }
  484|      0|    return -1;
  485|  68.3k|  }
_ZN3ada4idna10crc32_ieeeEPKhm:
 4868|      1|                                         size_t len) noexcept {
 4869|      1|  uint32_t c = 0xFFFFFFFFu;
 4870|   224k|  for (size_t i = 0; i < len; ++i) {
  ------------------
  |  Branch (4870:22): [True: 224k, False: 1]
  ------------------
 4871|   224k|    c ^= data[i];
 4872|  2.02M|    for (int k = 0; k < 8; ++k) {
  ------------------
  |  Branch (4872:21): [True: 1.79M, False: 224k]
  ------------------
 4873|  1.79M|      const uint32_t mask = 0u - (c & 1u);
 4874|  1.79M|      c = (c >> 1) ^ (0xEDB88320u & mask);
 4875|  1.79M|    }
 4876|   224k|  }
 4877|      1|  return ~c;
 4878|      1|}
_ZN3ada4idna6detail33convert_table_blob_to_host_endianEPh:
 4691|      1|inline void convert_table_blob_to_host_endian(uint8_t* buffer) noexcept {
 4692|      1|  if constexpr (std::endian::native == std::endian::little) {
 4693|      1|    (void)buffer;
 4694|      1|    return;
 4695|      1|  }
 4696|      0|  auto u16 = [&](size_t off, size_t count) {
 4697|      1|    bswap_inplace(reinterpret_cast<uint16_t*>(buffer + off), count);
 4698|      1|  };
 4699|      1|  auto u32 = [&](size_t off, size_t count) {
 4700|      1|    bswap_inplace(reinterpret_cast<uint32_t*>(buffer + off), count);
 4701|      1|  };
 4702|      1|  auto u64 = [&](size_t off, size_t count) {
 4703|      1|    bswap_inplace(reinterpret_cast<uint64_t*>(buffer + off), count);
 4704|      1|  };
 4705|       |
 4706|      1|  u16(table_blob::off_idna_stage1, table_blob::count_idna_stage1);
 4707|      1|  u16(table_blob::off_idna_stage2, table_blob::count_idna_stage2);
 4708|      1|  u64(table_blob::off_idna_bool_blocks, table_blob::count_idna_bool_blocks);
 4709|      1|  u16(table_blob::off_decomposition_block,
 4710|      1|      table_blob::count_decomposition_block);
 4711|      1|  u32(table_blob::off_decomposition_data, table_blob::count_decomposition_data);
 4712|      1|  u16(table_blob::off_composition_block, table_blob::count_composition_block);
 4713|      1|  u32(table_blob::off_composition_data, table_blob::count_composition_data);
 4714|      1|  u32(table_blob::off_id_continue_flat, table_blob::count_id_continue_flat);
 4715|      1|  u32(table_blob::off_id_start_flat, table_blob::count_id_start_flat);
 4716|      1|  u32(table_blob::off_dir_start, table_blob::count_dir_start);
 4717|      1|  u32(table_blob::off_dir_final, table_blob::count_dir_final);
 4718|      1|  u32(table_blob::off_combining_flat, table_blob::count_combining_flat);
 4719|      1|}
_ZZN3ada4idna13ensure_tablesEvENKUlmE_clEm:
 4917|     18|    auto at = [&](size_t off) noexcept -> const uint8_t* {
 4918|     18|      return buffer + off;
 4919|     18|    };
can_parse.cc:_ZN3ada4idnaL11idna_lookupEj:
 5072|   721k|static uint16_t idna_lookup(uint32_t cp) noexcept {
 5073|   721k|  if (cp < IDNA_LOW_RANGE_END) {
  ------------------
  |  Branch (5073:7): [True: 719k, False: 2.51k]
  ------------------
 5074|   719k|    uint16_t ref = idna_stage1[cp >> IDNA_BLOCK_BITS];
 5075|   719k|    if (ref & IDNA_BOOL_FLAG) {
  ------------------
  |  Branch (5075:9): [True: 316k, False: 402k]
  ------------------
 5076|   316k|      uint32_t bit_idx =
 5077|   316k|          static_cast<uint32_t>(ref & ~IDNA_BOOL_FLAG) * IDNA_BLOCK_SIZE +
 5078|   316k|          (cp & IDNA_BLOCK_MASK);
 5079|   316k|      bool is_valid = (idna_bool_blocks[bit_idx >> 6] >> (bit_idx & 63u)) & 1u;
 5080|   316k|      return is_valid ? IDNA_VALID : IDNA_DISALLOWED;
  ------------------
  |  Branch (5080:14): [True: 316k, False: 45]
  ------------------
 5081|   316k|    }
 5082|   402k|    return idna_stage2[ref + (cp & IDNA_BLOCK_MASK)];
 5083|   719k|  }
 5084|       |
 5085|  2.51k|  if (cp >= IDNA_HIGH_IGNORED_START && cp < IDNA_HIGH_IGNORED_END) {
  ------------------
  |  Branch (5085:7): [True: 2.40k, False: 111]
  |  Branch (5085:40): [True: 1.98k, False: 423]
  ------------------
 5086|  1.98k|    return IDNA_IGNORED;
 5087|  1.98k|  }
 5088|       |
 5089|    534|  return IDNA_DISALLOWED;
 5090|  2.51k|}
can_parse.cc:_ZN3ada4idnaL21utf8_count_codepointsEPKh:
 5115|   114k|static size_t utf8_count_codepoints(const uint8_t* ptr) noexcept {
 5116|   114k|  size_t n = 0;
 5117|   582k|  while (*ptr != 0) {
  ------------------
  |  Branch (5117:10): [True: 468k, False: 114k]
  ------------------
 5118|   468k|    ++n;
 5119|   468k|    if (*ptr < 0x80u) {
  ------------------
  |  Branch (5119:9): [True: 120k, False: 347k]
  ------------------
 5120|   120k|      ++ptr;
 5121|   347k|    } else if (*ptr < 0xE0u) {
  ------------------
  |  Branch (5121:16): [True: 225k, False: 122k]
  ------------------
 5122|   225k|      ptr += 2;
 5123|   225k|    } else if (*ptr < 0xF0u) {
  ------------------
  |  Branch (5123:16): [True: 119k, False: 2.52k]
  ------------------
 5124|   119k|      ptr += 3;
 5125|   119k|    } else {
 5126|  2.52k|      ptr += 4;
 5127|  2.52k|    }
 5128|   468k|  }
 5129|   114k|  return n;
 5130|   114k|}
can_parse.cc:_ZN3ada4idnaL9utf8_nextERPKh:
 5093|   463k|static char32_t utf8_next(const uint8_t*& ptr) noexcept {
 5094|   463k|  uint8_t b0 = *ptr++;
 5095|   463k|  if (b0 < 0x80u) return static_cast<char32_t>(b0);
  ------------------
  |  Branch (5095:7): [True: 120k, False: 343k]
  ------------------
 5096|   343k|  if (b0 < 0xE0u) {
  ------------------
  |  Branch (5096:7): [True: 221k, False: 121k]
  ------------------
 5097|   221k|    uint32_t cp = (b0 & 0x1Fu) << 6;
 5098|   221k|    cp |= (*ptr++ & 0x3Fu);
 5099|   221k|    return static_cast<char32_t>(cp);
 5100|   221k|  }
 5101|   121k|  if (b0 < 0xF0u) {
  ------------------
  |  Branch (5101:7): [True: 119k, False: 2.25k]
  ------------------
 5102|   119k|    uint32_t cp = (b0 & 0x0Fu) << 12;
 5103|   119k|    cp |= ((*ptr++ & 0x3Fu) << 6);
 5104|   119k|    cp |= (*ptr++ & 0x3Fu);
 5105|   119k|    return static_cast<char32_t>(cp);
 5106|   119k|  }
 5107|  2.25k|  uint32_t cp = (b0 & 0x07u) << 18;
 5108|  2.25k|  cp |= ((*ptr++ & 0x3Fu) << 12);
 5109|  2.25k|  cp |= ((*ptr++ & 0x3Fu) << 6);
 5110|  2.25k|  cp |= (*ptr++ & 0x3Fu);
 5111|  2.25k|  return static_cast<char32_t>(cp);
 5112|   121k|}
_ZN3ada4idna23decomposition_block_rowEh:
 4989|   671k|inline const uint16_t* decomposition_block_row(uint8_t bi) noexcept {
 4990|   671k|  if (bi >= kDecompBlockRows) {
  ------------------
  |  Branch (4990:7): [True: 0, False: 671k]
  ------------------
 4991|      0|    bi = 0;
 4992|      0|  }
 4993|   671k|  return decomposition_block_flat + static_cast<size_t>(bi) * kDecompBlockCols;
 4994|   671k|}
_ZN3ada4idna13ccc_block_rowEh:
 4996|  1.18M|inline const uint8_t* ccc_block_row(uint8_t bi) noexcept {
 4997|  1.18M|  if (bi >= kCccBlockRows) {
  ------------------
  |  Branch (4997:7): [True: 0, False: 1.18M]
  ------------------
 4998|      0|    bi = 0;
 4999|      0|  }
 5000|  1.18M|  return ccc_block_flat + static_cast<size_t>(bi) * kCccBlockCols;
 5001|  1.18M|}
_ZN3ada4idna16tables_are_readyEv:
 4880|  13.3k|[[nodiscard]] inline bool tables_are_ready() noexcept {
 4881|  13.3k|  return tables_init_state.load(std::memory_order_acquire) == kTablesReady;
 4882|  13.3k|}
can_parse.cc:_ZN3ada4idnaL23canonical_decomp_lengthEDi:
 5272|   580k|static size_t canonical_decomp_length(char32_t current_character) noexcept {
 5273|   580k|  if (current_character >= hangul_sbase &&
  ------------------
  |  Branch (5273:7): [True: 32.1k, False: 548k]
  ------------------
 5274|  32.1k|      current_character < hangul_sbase + hangul_scount) {
  ------------------
  |  Branch (5274:7): [True: 19.6k, False: 12.5k]
  ------------------
 5275|       |    // Hangul precomposed syllables are NFC.
 5276|  19.6k|    return 0;
 5277|  19.6k|  }
 5278|   560k|  if (current_character >= 0x110000) {
  ------------------
  |  Branch (5278:7): [True: 0, False: 560k]
  ------------------
 5279|      0|    return 0;
 5280|      0|  }
 5281|   560k|  const uint8_t di = decomposition_index[current_character >> 8];
 5282|   560k|  const uint16_t* const decomposition =
 5283|   560k|      decomposition_block_row(di) + (current_character % 256);
 5284|   560k|  size_t decomposition_length =
 5285|   560k|      (decomposition[1] >> 2) - (decomposition[0] >> 2);
 5286|   560k|  if ((decomposition_length > 0) && (decomposition[0] & 1)) {
  ------------------
  |  Branch (5286:7): [True: 10.9k, False: 549k]
  |  Branch (5286:37): [True: 0, False: 10.9k]
  ------------------
 5287|      0|    decomposition_length = 0;  // compatibility-only: ignored for NFC
 5288|      0|  }
 5289|   560k|  return decomposition_length;
 5290|   560k|}
can_parse.cc:_ZN3ada4idnaL13would_composeENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 5404|  12.3k|static bool would_compose(std::u32string_view input) noexcept {
 5405|   488k|  for (size_t input_count = 0; input_count < input.size();) {
  ------------------
  |  Branch (5405:32): [True: 478k, False: 9.57k]
  ------------------
 5406|   478k|    const char32_t current = input[input_count];
 5407|   478k|    if (current >= hangul_lbase && current < hangul_lbase + hangul_lcount) {
  ------------------
  |  Branch (5407:9): [True: 155k, False: 323k]
  |  Branch (5407:36): [True: 7.61k, False: 148k]
  ------------------
 5408|  7.61k|      if (input_count + 1 < input.size() &&
  ------------------
  |  Branch (5408:11): [True: 7.50k, False: 111]
  ------------------
 5409|  7.50k|          input[input_count + 1] >= hangul_vbase &&
  ------------------
  |  Branch (5409:11): [True: 2.21k, False: 5.28k]
  ------------------
 5410|  2.21k|          input[input_count + 1] < hangul_vbase + hangul_vcount) {
  ------------------
  |  Branch (5410:11): [True: 402, False: 1.81k]
  ------------------
 5411|    402|        return true;
 5412|    402|      }
 5413|  7.21k|      ++input_count;
 5414|  7.21k|      continue;
 5415|  7.61k|    }
 5416|   471k|    if (current >= hangul_sbase && current < hangul_sbase + hangul_scount) {
  ------------------
  |  Branch (5416:9): [True: 15.9k, False: 455k]
  |  Branch (5416:36): [True: 11.1k, False: 4.75k]
  ------------------
 5417|  11.1k|      if ((current - hangul_sbase) % hangul_tcount &&
  ------------------
  |  Branch (5417:11): [True: 8.91k, False: 2.25k]
  ------------------
 5418|  8.91k|          input_count + 1 < input.size() &&
  ------------------
  |  Branch (5418:11): [True: 8.62k, False: 285]
  ------------------
 5419|  8.62k|          input[input_count + 1] > hangul_tbase &&
  ------------------
  |  Branch (5419:11): [True: 7.79k, False: 831]
  ------------------
 5420|  7.79k|          input[input_count + 1] < hangul_tbase + hangul_tcount) {
  ------------------
  |  Branch (5420:11): [True: 420, False: 7.37k]
  ------------------
 5421|    420|        return true;
 5422|    420|      }
 5423|  10.7k|      ++input_count;
 5424|  10.7k|      continue;
 5425|  11.1k|    }
 5426|   459k|    if (current < 0x110000) {
  ------------------
  |  Branch (5426:9): [True: 459k, False: 0]
  ------------------
 5427|   459k|      const uint16_t* composition =
 5428|   459k|          composition_block_row(composition_index[current >> 8]) +
 5429|   459k|          (current % 256);
 5430|   459k|      int32_t previous_ccc = -1;
 5431|   459k|      size_t j = input_count;
 5432|   466k|      for (; j + 1 < input.size(); ++j) {
  ------------------
  |  Branch (5432:14): [True: 457k, False: 8.97k]
  ------------------
 5433|   457k|        uint8_t ccc = get_ccc(input[j + 1]);
 5434|   457k|        if (composition[1] != composition[0] && previous_ccc < ccc) {
  ------------------
  |  Branch (5434:13): [True: 106k, False: 351k]
  |  Branch (5434:49): [True: 102k, False: 3.55k]
  ------------------
 5435|   102k|          int left = composition[0];
 5436|   102k|          int right = composition[1];
 5437|   102k|          if (left < 0 || right < left ||
  ------------------
  |  Branch (5437:15): [True: 0, False: 102k]
  |  Branch (5437:27): [True: 0, False: 102k]
  ------------------
 5438|   102k|              static_cast<size_t>(right) > composition_data_size) {
  ------------------
  |  Branch (5438:15): [True: 0, False: 102k]
  ------------------
 5439|      0|            break;
 5440|      0|          }
 5441|   279k|          while (left + 2 < right) {
  ------------------
  |  Branch (5441:18): [True: 177k, False: 102k]
  ------------------
 5442|   177k|            int middle = left + (((right - left) >> 1) & ~1);
 5443|   177k|            if (composition_data[static_cast<size_t>(middle)] <= input[j + 1]) {
  ------------------
  |  Branch (5443:17): [True: 10.9k, False: 166k]
  ------------------
 5444|  10.9k|              left = middle;
 5445|  10.9k|            }
 5446|   177k|            if (composition_data[static_cast<size_t>(middle)] >= input[j + 1]) {
  ------------------
  |  Branch (5446:17): [True: 167k, False: 9.60k]
  ------------------
 5447|   167k|              right = middle;
 5448|   167k|            }
 5449|   177k|          }
 5450|   102k|          if (static_cast<size_t>(left + 1) < composition_data_size &&
  ------------------
  |  Branch (5450:15): [True: 102k, False: 0]
  ------------------
 5451|   102k|              composition_data[static_cast<size_t>(left)] == input[j + 1]) {
  ------------------
  |  Branch (5451:15): [True: 1.92k, False: 100k]
  ------------------
 5452|  1.92k|            return true;
 5453|  1.92k|          }
 5454|   102k|        }
 5455|   455k|        if (ccc == 0) {
  ------------------
  |  Branch (5455:13): [True: 449k, False: 6.79k]
  ------------------
 5456|   449k|          break;
 5457|   449k|        }
 5458|  6.79k|        previous_ccc = ccc;
 5459|  6.79k|      }
 5460|   458k|      input_count = j + 1;
 5461|   458k|      continue;
 5462|   459k|    }
 5463|      0|    ++input_count;
 5464|      0|  }
 5465|  9.57k|  return false;
 5466|  12.3k|}
_ZN3ada4idna21composition_block_rowEh:
 5003|   514k|inline const uint16_t* composition_block_row(uint8_t bi) noexcept {
 5004|   514k|  if (bi >= kCompBlockRows) {
  ------------------
  |  Branch (5004:7): [True: 0, False: 514k]
  ------------------
 5005|      0|    bi = 0;
 5006|      0|  }
 5007|   514k|  return composition_block_flat + static_cast<size_t>(bi) * kCompBlockCols;
 5008|   514k|}
can_parse.cc:_ZN3ada4idnaL19char_to_digit_valueEc:
 5632|  96.6k|static constexpr int32_t char_to_digit_value(char value) {
 5633|  96.6k|  if (value >= 'a' && value <= 'z') return value - 'a';
  ------------------
  |  Branch (5633:7): [True: 86.3k, False: 10.3k]
  |  Branch (5633:23): [True: 86.3k, False: 15]
  ------------------
 5634|  10.3k|  if (value >= '0' && value <= '9') return value - '0' + 26;
  ------------------
  |  Branch (5634:7): [True: 10.3k, False: 42]
  |  Branch (5634:23): [True: 10.2k, False: 33]
  ------------------
 5635|     75|  return -1;
 5636|  10.3k|}
can_parse.cc:_ZN3ada4idnaL5adaptEiib:
 5642|   296k|static constexpr int32_t adapt(int32_t d, int32_t n, bool firsttime) {
 5643|   296k|  if (firsttime) {
  ------------------
  |  Branch (5643:7): [True: 41.1k, False: 255k]
  ------------------
 5644|  41.1k|    d = d / damp;
 5645|   255k|  } else {
 5646|   255k|    d = d / 2;
 5647|   255k|  }
 5648|   296k|  d += d / n;
 5649|   296k|  int32_t k = 0;
 5650|   390k|  while (d > ((base - tmin) * tmax) / 2) {
  ------------------
  |  Branch (5650:10): [True: 93.9k, False: 296k]
  ------------------
 5651|  93.9k|    d /= base - tmin;
 5652|  93.9k|    k += base;
 5653|  93.9k|  }
 5654|   296k|  return k + (((base - tmin + 1) * d) / (d + skew));
 5655|   296k|}
can_parse.cc:_ZN3ada4idnaL13digit_to_charEi:
 5638|   510k|static constexpr char digit_to_char(int32_t digit) {
 5639|   510k|  return digit < 26 ? char(digit + 97) : char(digit + 22);
  ------------------
  |  Branch (5639:10): [True: 368k, False: 142k]
  ------------------
 5640|   510k|}
can_parse.cc:_ZZN3ada4idna14is_label_validENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEEENK3$_0clIA2_jEEDaRKT_:
 5977|   340k|      comb_span, label.front(), {}, [](const auto& range) { return range[1]; });
can_parse.cc:_ZZN3ada4idna14is_label_validENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEEENK3$_1clEj:
 6062|  5.43k|      auto is_l_or_d = [](uint32_t code) {
 6063|  5.43k|        return std::ranges::binary_search(L, code) ||
  ------------------
  |  Branch (6063:16): [True: 111, False: 5.32k]
  ------------------
 6064|  5.32k|               std::ranges::binary_search(D, code);
  ------------------
  |  Branch (6064:16): [True: 1.47k, False: 3.84k]
  ------------------
 6065|  5.43k|      };
can_parse.cc:_ZZN3ada4idna14is_label_validENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEEENK3$_2clEj:
 6066|  5.98k|      auto is_r_or_d = [](uint32_t code) {
 6067|  5.98k|        return std::ranges::binary_search(R, code) ||
  ------------------
  |  Branch (6067:16): [True: 711, False: 5.27k]
  ------------------
 6068|  5.27k|               std::ranges::binary_search(D, code);
  ------------------
  |  Branch (6068:16): [True: 630, False: 4.64k]
  ------------------
 6069|  5.98k|      };
can_parse.cc:_ZN3ada4idnaL20find_last_not_of_nsmENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 5924|  38.7k|    const std::u32string_view label) noexcept {
 5925|  42.4k|  for (int i = static_cast<int>(label.size() - 1); i >= 0; i--)
  ------------------
  |  Branch (5925:52): [True: 42.4k, False: 0]
  ------------------
 5926|  42.4k|    if (find_direction(label[i]) != direction::NSM) return i;
  ------------------
  |  Branch (5926:9): [True: 38.7k, False: 3.71k]
  ------------------
 5927|       |
 5928|      0|  return std::u32string_view::npos;
 5929|  38.7k|}
can_parse.cc:_ZN3ada4idnaL12is_rtl_labelENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 5933|  38.7k|inline static bool is_rtl_label(const std::u32string_view label) noexcept {
 5934|  38.7k|  const size_t mask =
 5935|  38.7k|      (1u << direction::R) | (1u << direction::AL) | (1u << direction::AN);
 5936|       |
 5937|  38.7k|  size_t directions = 0;
 5938|   281k|  for (size_t i = 0; i < label.size(); i++) {
  ------------------
  |  Branch (5938:22): [True: 242k, False: 38.7k]
  ------------------
 5939|   242k|    directions |= 1u << find_direction(label[i]);
 5940|   242k|  }
 5941|  38.7k|  return (directions & mask) != 0;
 5942|  38.7k|}
can_parse.cc:_ZN3ada4idnaL14find_directionEj:
 5905|   321k|inline static direction find_direction(uint32_t code_point) noexcept {
 5906|       |  // Binary search on dir_final (sorted upper bounds).
 5907|   321k|  size_t lo = 0, hi = dir_table_count;
 5908|  3.61M|  while (lo < hi) {
  ------------------
  |  Branch (5908:10): [True: 3.29M, False: 321k]
  ------------------
 5909|  3.29M|    size_t mid = lo + (hi - lo) / 2;
 5910|  3.29M|    if (dir_final[mid] < code_point) {
  ------------------
  |  Branch (5910:9): [True: 1.40M, False: 1.88M]
  ------------------
 5911|  1.40M|      lo = mid + 1;
 5912|  1.88M|    } else {
 5913|  1.88M|      hi = mid;
 5914|  1.88M|    }
 5915|  3.29M|  }
 5916|   321k|  if (lo == dir_table_count) {
  ------------------
  |  Branch (5916:7): [True: 0, False: 321k]
  ------------------
 5917|      0|    return direction::NONE;
 5918|      0|  }
 5919|   321k|  return code_point >= dir_start[lo] ? static_cast<direction>(dir_value[lo])
  ------------------
  |  Branch (5919:10): [True: 317k, False: 3.81k]
  ------------------
 5920|   321k|                                     : direction::NONE;
 5921|   321k|}
_ZN3ada4idna8is_asciiENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 6290|  18.5k|bool constexpr is_ascii(std::string_view view) {
 6291|   471k|  for (uint8_t c : view) {
  ------------------
  |  Branch (6291:18): [True: 471k, False: 7.14k]
  ------------------
 6292|   471k|    if (c >= 0x80) {
  ------------------
  |  Branch (6292:9): [True: 11.4k, False: 460k]
  ------------------
 6293|  11.4k|      return false;
 6294|  11.4k|    }
 6295|   471k|  }
 6296|  7.14k|  return true;
 6297|  18.5k|}
can_parse.cc:_ZN3ada4idnaL19from_ascii_to_asciiENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEERNS1_12basic_stringIcS4_NS1_9allocatorIcEEEE:
 6327|  7.14k|static void from_ascii_to_ascii(std::string_view ut8_string, std::string& out) {
 6328|  7.14k|  out.assign(ut8_string);
 6329|  7.14k|  ascii_map(out.data(), out.size());
 6330|  7.14k|}
_ZN3ada4idna8is_asciiENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 6281|  61.0k|bool constexpr is_ascii(std::u32string_view view) {
 6282|   248k|  for (uint32_t c : view) {
  ------------------
  |  Branch (6282:19): [True: 248k, False: 6.97k]
  ------------------
 6283|   248k|    if (c >= 0x80) {
  ------------------
  |  Branch (6283:9): [True: 54.1k, False: 194k]
  ------------------
 6284|  54.1k|      return false;
 6285|  54.1k|    }
 6286|   248k|  }
 6287|  6.97k|  return true;
 6288|  61.0k|}
can_parse.cc:_ZN3ada4idnaL13is_ace_prefixENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 6343|  47.9k|static bool is_ace_prefix(std::u32string_view label) noexcept {
 6344|  47.9k|  return label.size() >= 4 && label[0] == U'x' && label[1] == U'n' &&
  ------------------
  |  Branch (6344:10): [True: 33.7k, False: 14.1k]
  |  Branch (6344:31): [True: 5.85k, False: 27.9k]
  |  Branch (6344:51): [True: 5.34k, False: 504]
  ------------------
 6345|  5.34k|         label[2] == U'-' && label[3] == U'-';
  ------------------
  |  Branch (6345:10): [True: 5.03k, False: 318]
  |  Branch (6345:30): [True: 4.46k, False: 570]
  ------------------
 6346|  47.9k|}
can_parse.cc:_ZN3ada4idnaL18append_ascii_labelERNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_17basic_string_viewIDiNS3_IDiEEEE:
 6333|  9.17k|static void append_ascii_label(std::string& out, std::u32string_view label) {
 6334|  9.17k|  const size_t old = out.size();
 6335|  9.17k|  out.resize(old + label.size());
 6336|  9.17k|  char* dest = out.data() + old;
 6337|   151k|  for (char32_t c : label) {
  ------------------
  |  Branch (6337:19): [True: 151k, False: 9.17k]
  ------------------
 6338|   151k|    *dest++ = static_cast<char>(c);
 6339|   151k|  }
 6340|  9.17k|}
_ZN3ada7unicode18is_ascii_hex_digitEc:
 7071|  9.18k|ada_really_inline constexpr bool is_ascii_hex_digit(const char c) noexcept {
 7072|  9.18k|  return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') ||
  ------------------
  |  Branch (7072:11): [True: 5.54k, False: 3.64k]
  |  Branch (7072:23): [True: 2.22k, False: 3.31k]
  |  Branch (7072:37): [True: 3.30k, False: 3.65k]
  |  Branch (7072:49): [True: 1.69k, False: 1.61k]
  ------------------
 7073|  5.26k|         (c >= 'a' && c <= 'f');
  ------------------
  |  Branch (7073:11): [True: 1.54k, False: 3.72k]
  |  Branch (7073:23): [True: 1.39k, False: 153]
  ------------------
 7074|  9.18k|}
_ZN3ada7unicode21convert_hex_to_binaryEc:
 7161|  3.74k|unsigned constexpr convert_hex_to_binary(const char c) noexcept {
 7162|  3.74k|  return hex_to_binary_table[c - '0'];
 7163|  3.74k|}
can_parse.cc:_ZZN3ada7unicode14percent_encodeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKhENK3$_0clEc:
 7282|  78.8k|  auto pointer = std::ranges::find_if(input, [character_set](const char c) {
 7283|  78.8k|    return character_sets::bit_at(character_set, c);
 7284|  78.8k|  });
_ZN3ada7unicode36contains_forbidden_domain_code_pointEPKcm:
 6998|  24.0k|    const char* input, size_t length) noexcept {
 6999|  24.0k|  size_t i = 0;
 7000|  24.0k|  uint8_t accumulator{};
 7001|   380k|  for (; i + 4 <= length; i += 4) {
  ------------------
  |  Branch (7001:10): [True: 356k, False: 24.0k]
  ------------------
 7002|   356k|    accumulator |= is_forbidden_domain_code_point_table[uint8_t(input[i])];
 7003|   356k|    accumulator |= is_forbidden_domain_code_point_table[uint8_t(input[i + 1])];
 7004|   356k|    accumulator |= is_forbidden_domain_code_point_table[uint8_t(input[i + 2])];
 7005|   356k|    accumulator |= is_forbidden_domain_code_point_table[uint8_t(input[i + 3])];
 7006|   356k|  }
 7007|  59.8k|  for (; i < length; i++) {
  ------------------
  |  Branch (7007:10): [True: 35.7k, False: 24.0k]
  ------------------
 7008|  35.7k|    accumulator |= is_forbidden_domain_code_point_table[uint8_t(input[i])];
 7009|  35.7k|  }
 7010|  24.0k|  return accumulator;
 7011|  24.0k|}
can_parse.cc:_ZN3ada11serializers12_GLOBAL__N_113write_hex_u16EPct:
 7413|  2.28k|ada_really_inline char* write_hex_u16(char* p, uint16_t v) noexcept {
 7414|  2.28k|  static constexpr char kHex[] = "0123456789abcdef";
 7415|  2.28k|  if (v >= 0x1000) {
  ------------------
  |  Branch (7415:7): [True: 228, False: 2.05k]
  ------------------
 7416|    228|    *p++ = kHex[(v >> 12) & 0xf];
 7417|    228|    *p++ = kHex[(v >> 8) & 0xf];
 7418|    228|    *p++ = kHex[(v >> 4) & 0xf];
 7419|    228|    *p++ = kHex[v & 0xf];
 7420|  2.05k|  } else if (v >= 0x100) {
  ------------------
  |  Branch (7420:14): [True: 282, False: 1.77k]
  ------------------
 7421|    282|    *p++ = kHex[(v >> 8) & 0xf];
 7422|    282|    *p++ = kHex[(v >> 4) & 0xf];
 7423|    282|    *p++ = kHex[v & 0xf];
 7424|  1.77k|  } else if (v >= 0x10) {
  ------------------
  |  Branch (7424:14): [True: 240, False: 1.53k]
  ------------------
 7425|    240|    *p++ = kHex[(v >> 4) & 0xf];
 7426|    240|    *p++ = kHex[v & 0xf];
 7427|  1.53k|  } else {
 7428|  1.53k|    *p++ = kHex[v & 0xf];
 7429|  1.53k|  }
 7430|  2.28k|  return p;
 7431|  2.28k|}
can_parse.cc:_ZN3ada11serializers12_GLOBAL__N_18write_u8EPch:
 7399|  12.3k|ada_really_inline char* write_u8(char* p, uint8_t v) noexcept {
 7400|  12.3k|  if (v < 10) {
  ------------------
  |  Branch (7400:7): [True: 9.95k, False: 2.39k]
  ------------------
 7401|  9.95k|    *p++ = static_cast<char>('0' + v);
 7402|  9.95k|  } else if (v < 100) {
  ------------------
  |  Branch (7402:14): [True: 1.08k, False: 1.30k]
  ------------------
 7403|  1.08k|    std::memcpy(p, &digit_pairs[static_cast<size_t>(v) * 2], 2);
 7404|  1.08k|    p += 2;
 7405|  1.30k|  } else {
 7406|  1.30k|    *p++ = static_cast<char>('0' + v / 100);
 7407|  1.30k|    std::memcpy(p, &digit_pairs[static_cast<size_t>(v % 100) * 2], 2);
 7408|  1.30k|    p += 2;
 7409|  1.30k|  }
 7410|  12.3k|  return p;
 7411|  12.3k|}
_ZN3ada7unicode19has_tabs_or_newlineENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 6847|  91.6k|    std::string_view user_input) noexcept {
 6848|       |  // first check for short strings in which case we do it naively.
 6849|  91.6k|  if (user_input.size() < 16) {  // slow path
  ------------------
  |  Branch (6849:7): [True: 71.9k, False: 19.7k]
  ------------------
 6850|  71.9k|    return std::ranges::any_of(user_input, is_tabs_or_newline);
 6851|  71.9k|  }
 6852|       |  // fast path for long strings (expected to be common)
 6853|  19.7k|  size_t i = 0;
 6854|  19.7k|  const __m128i mask1 = _mm_set1_epi8('\r');
 6855|  19.7k|  const __m128i mask2 = _mm_set1_epi8('\n');
 6856|  19.7k|  const __m128i mask3 = _mm_set1_epi8('\t');
 6857|       |  // If we supported SSSE3, we could use the algorithm that we use for NEON.
 6858|  19.7k|  __m128i running{0};
 6859|   110k|  for (; i + 15 < user_input.size(); i += 16) {
  ------------------
  |  Branch (6859:10): [True: 91.2k, False: 19.7k]
  ------------------
 6860|  91.2k|    __m128i word = _mm_loadu_si128((const __m128i*)(user_input.data() + i));
 6861|  91.2k|    running = _mm_or_si128(
 6862|  91.2k|        _mm_or_si128(running, _mm_or_si128(_mm_cmpeq_epi8(word, mask1),
 6863|  91.2k|                                           _mm_cmpeq_epi8(word, mask2))),
 6864|  91.2k|        _mm_cmpeq_epi8(word, mask3));
 6865|  91.2k|  }
 6866|  19.7k|  if (i < user_input.size()) {
  ------------------
  |  Branch (6866:7): [True: 17.4k, False: 2.33k]
  ------------------
 6867|  17.4k|    __m128i word = _mm_loadu_si128(
 6868|  17.4k|        (const __m128i*)(user_input.data() + user_input.length() - 16));
 6869|  17.4k|    running = _mm_or_si128(
 6870|  17.4k|        _mm_or_si128(running, _mm_or_si128(_mm_cmpeq_epi8(word, mask1),
 6871|  17.4k|                                           _mm_cmpeq_epi8(word, mask2))),
 6872|  17.4k|        _mm_cmpeq_epi8(word, mask3));
 6873|  17.4k|  }
 6874|  19.7k|  return _mm_movemask_epi8(running) != 0;
 6875|  91.6k|}
_ZN3ada7unicode18is_tabs_or_newlineEc:
 6742|   264k|constexpr bool is_tabs_or_newline(char c) noexcept {
 6743|   264k|  return c == '\r' || c == '\n' || c == '\t';
  ------------------
  |  Branch (6743:10): [True: 114, False: 264k]
  |  Branch (6743:23): [True: 131, False: 264k]
  |  Branch (6743:36): [True: 118, False: 264k]
  ------------------
 6744|   264k|}
can_parse.cc:_ZN3ada12_GLOBAL__N_127try_can_parse_absolute_fastENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 7550|  22.7k|    std::string_view input) noexcept {
 7551|  22.7k|  const uint8_t* b = reinterpret_cast<const uint8_t*>(input.data());
 7552|  22.7k|  size_t len = input.size();
 7553|       |
 7554|       |  // -- Inline C0 whitespace trim (no allocation) --------------------------
 7555|       |  // Note: \t (0x09), \n (0x0a), \r (0x0d) are all <= 0x20, so any
 7556|       |  // leading/trailing tabs or newlines are correctly stripped here, matching
 7557|       |  // the WHATWG spec's "remove leading/trailing C0 control and space" step.
 7558|  23.9k|  while (len > 0 && b[0] <= 0x20) {
  ------------------
  |  Branch (7558:10): [True: 14.7k, False: 9.14k]
  |  Branch (7558:21): [True: 1.14k, False: 13.6k]
  ------------------
 7559|  1.14k|    b++;
 7560|  1.14k|    len--;
 7561|  1.14k|  }
 7562|  23.7k|  while (len > 0 && b[len - 1] <= 0x20) {
  ------------------
  |  Branch (7562:10): [True: 14.5k, False: 9.14k]
  |  Branch (7562:21): [True: 967, False: 13.6k]
  ------------------
 7563|    967|    len--;
 7564|    967|  }
 7565|  22.7k|  if (len == 0) return false;
  ------------------
  |  Branch (7565:7): [True: 9.14k, False: 13.6k]
  ------------------
 7566|       |
 7567|       |  // -- Scheme detection -----------------------------------------------------
 7568|       |  // Fast path for HTTP and HTTPS (covers ~90%+ of real-world URLs).
 7569|       |  // Avoids the general scheme loop, buffer copy, and perfect hash lookup.
 7570|       |  // We know HTTP and HTTPS are special non-file schemes, so no further
 7571|       |  // scheme_type checks are needed on the fast path -- only `pos` matters.
 7572|  13.6k|  size_t pos;
 7573|       |
 7574|  13.6k|  if (len >= 7 && (b[0] | 0x20) == 'h' && (b[1] | 0x20) == 't' &&
  ------------------
  |  Branch (7574:7): [True: 11.1k, False: 2.42k]
  |  Branch (7574:19): [True: 974, False: 10.2k]
  |  Branch (7574:43): [True: 932, False: 42]
  ------------------
 7575|    932|      (b[2] | 0x20) == 't' && (b[3] | 0x20) == 'p') {
  ------------------
  |  Branch (7575:7): [True: 911, False: 21]
  |  Branch (7575:31): [True: 883, False: 28]
  ------------------
 7576|    883|    if (b[4] == ':' && b[5] == '/' && b[6] == '/') {
  ------------------
  |  Branch (7576:9): [True: 665, False: 218]
  |  Branch (7576:24): [True: 521, False: 144]
  |  Branch (7576:39): [True: 504, False: 17]
  ------------------
 7577|    504|      pos = 7;
 7578|    504|      goto skip_extra_slashes;
 7579|    504|    }
 7580|    379|    if (len >= 8 && (b[4] | 0x20) == 's' && b[5] == ':' && b[6] == '/' &&
  ------------------
  |  Branch (7580:9): [True: 341, False: 38]
  |  Branch (7580:21): [True: 182, False: 159]
  |  Branch (7580:45): [True: 167, False: 15]
  |  Branch (7580:60): [True: 134, False: 33]
  ------------------
 7581|    134|        b[7] == '/') {
  ------------------
  |  Branch (7581:9): [True: 121, False: 13]
  ------------------
 7582|    121|      pos = 8;
 7583|    121|      goto skip_extra_slashes;
 7584|    121|    }
 7585|       |    // Fall through: could be "httpe://", tabs in scheme, etc.
 7586|    379|  }
 7587|       |
 7588|  12.9k|  {
 7589|       |    // General scheme detection for ws, wss, ftp, and edge cases.
 7590|  12.9k|    if (!checkers::is_alpha(static_cast<char>(b[0]))) return false;
  ------------------
  |  Branch (7590:9): [True: 569, False: 12.4k]
  ------------------
 7591|       |
 7592|       |    // Scan for ':' within the first 7 bytes. All special schemes are <= 5
 7593|       |    // chars ("https"), so any URL whose first ':' is beyond byte 6 is either
 7594|       |    // non-special or relative -- both require the full parser.
 7595|  12.4k|    size_t colon_pos = 0;
 7596|  27.5k|    for (size_t i = 1;; ++i) {
 7597|  27.5k|      if (i >= 7 || i >= len) return std::nullopt;
  ------------------
  |  Branch (7597:11): [True: 80, False: 27.4k]
  |  Branch (7597:21): [True: 171, False: 27.3k]
  ------------------
 7598|  27.3k|      const char c = static_cast<char>(b[i]);
 7599|  27.3k|      if (c == ':') {
  ------------------
  |  Branch (7599:11): [True: 11.9k, False: 15.3k]
  ------------------
 7600|  11.9k|        colon_pos = i;
 7601|  11.9k|        break;
 7602|  11.9k|      }
 7603|       |      // Tabs/newlines in the scheme require the full parser to strip them.
 7604|  15.3k|      if (c == '\t' || c == '\n' || c == '\r') return std::nullopt;
  ------------------
  |  Branch (7604:11): [True: 10, False: 15.3k]
  |  Branch (7604:24): [True: 13, False: 15.2k]
  |  Branch (7604:37): [True: 7, False: 15.2k]
  ------------------
 7605|  15.2k|      if (!unicode::is_alnum_plus(c)) return false;
  ------------------
  |  Branch (7605:11): [True: 148, False: 15.1k]
  ------------------
 7606|  15.2k|    }
 7607|       |
 7608|       |    // Lowercase scheme bytes inline and classify via the existing perfect
 7609|       |    // hash.
 7610|  11.9k|    char scheme_buf[6];
 7611|  11.9k|    scheme_buf[0] = static_cast<char>(b[0] | 0x20);
 7612|  26.4k|    for (size_t i = 1; i < colon_pos; ++i)
  ------------------
  |  Branch (7612:24): [True: 14.4k, False: 11.9k]
  ------------------
 7613|  14.4k|      scheme_buf[i] = static_cast<char>(b[i] | 0x20);
 7614|       |
 7615|  11.9k|    const ada::scheme::type scheme_type =
 7616|  11.9k|        ada::scheme::get_scheme_type({scheme_buf, colon_pos});
 7617|       |
 7618|       |    // Only handle special, non-file schemes.
 7619|  11.9k|    if (scheme_type == ada::scheme::NOT_SPECIAL) return std::nullopt;
  ------------------
  |  Branch (7619:9): [True: 2.11k, False: 9.87k]
  ------------------
 7620|  9.87k|    if (scheme_type == ada::scheme::FILE) return std::nullopt;
  ------------------
  |  Branch (7620:9): [True: 1.65k, False: 8.21k]
  ------------------
 7621|       |
 7622|       |    // Per WHATWG, special URLs don't require "//": "http:example.com" is valid
 7623|       |    // (SPECIAL_AUTHORITY_IGNORE_SLASHES just skips leading slashes and
 7624|       |    // proceeds to AUTHORITY).  Defer to the inline fallback for any input
 7625|       |    // without "://".
 7626|  8.21k|    pos = colon_pos + 1;
 7627|  8.21k|    if (pos + 2 > len || b[pos] != '/' || b[pos + 1] != '/') {
  ------------------
  |  Branch (7627:9): [True: 127, False: 8.09k]
  |  Branch (7627:26): [True: 4.95k, False: 3.13k]
  |  Branch (7627:43): [True: 60, False: 3.07k]
  ------------------
 7628|  5.14k|      return std::nullopt;
 7629|  5.14k|    }
 7630|  3.07k|    pos += 2;
 7631|  3.07k|  }
 7632|       |
 7633|  3.69k|skip_extra_slashes:
 7634|       |  // SPECIAL_AUTHORITY_IGNORE_SLASHES: the full parser skips any additional
 7635|       |  // leading '/' or '\' after the initial "//".  Mirror that here so we don't
 7636|       |  // mis-identify the host as empty when there are extra slashes.
 7637|  4.24k|  while (pos < len && (b[pos] == '/' || b[pos] == '\\')) {
  ------------------
  |  Branch (7637:10): [True: 4.22k, False: 23]
  |  Branch (7637:24): [True: 365, False: 3.85k]
  |  Branch (7637:41): [True: 181, False: 3.67k]
  ------------------
 7638|    546|    ++pos;
 7639|    546|  }
 7640|       |
 7641|       |  // Early IPv6 bail-out: if the authority starts with '[', it's an IPv6
 7642|       |  // literal which requires the full parser.  Checking here avoids scanning
 7643|       |  // the entire bracketed address only to bail out afterward.
 7644|  3.69k|  if (pos < len && b[pos] == '[') return std::nullopt;
  ------------------
  |  Branch (7644:7): [True: 3.67k, False: 23]
  |  Branch (7644:20): [True: 107, False: 3.56k]
  ------------------
 7645|       |
 7646|       |  // -- Merged authority + host scan ------------------------------------------
 7647|       |  // A single forward pass over the authority bytes that simultaneously:
 7648|       |  //   - finds the authority end and port colon
 7649|       |  //   - validates host characters (forbidden domain code points)
 7650|       |  //   - tracks IPv4 indicators (all-decimal-dots, last non-dot char)
 7651|       |  //   - detects xn-- prefixes (IDNA punycode)
 7652|       |  //   - detects tabs/newlines (which require the full parser to strip)
 7653|       |  // This replaces 4 separate scans over the host bytes.
 7654|  3.59k|  const size_t auth_start = pos;
 7655|  3.59k|  size_t auth_end = pos;
 7656|  3.59k|  size_t port_colon = SIZE_MAX;
 7657|  3.59k|  bool all_dec_dots = true;
 7658|  3.59k|  uint8_t last_non_dot = 0;
 7659|       |
 7660|  27.0k|  for (; auth_end < len; ++auth_end) {
  ------------------
  |  Branch (7660:10): [True: 26.8k, False: 209]
  ------------------
 7661|  26.8k|    const uint8_t c = b[auth_end];
 7662|       |
 7663|       |    // Non-ASCII -> needs IDNA processing -> full parser.
 7664|  26.8k|    if (c >= 0x80) return std::nullopt;
  ------------------
  |  Branch (7664:9): [True: 14, False: 26.8k]
  ------------------
 7665|       |
 7666|       |    // Authority delimiters.
 7667|  26.8k|    if (c == '/' || c == '?' || c == '#' || c == '\\') break;
  ------------------
  |  Branch (7667:9): [True: 2.00k, False: 24.8k]
  |  Branch (7667:21): [True: 39, False: 24.8k]
  |  Branch (7667:33): [True: 28, False: 24.7k]
  |  Branch (7667:45): [True: 2, False: 24.7k]
  ------------------
 7668|       |
 7669|       |    // Port separator.
 7670|  24.7k|    if (c == ':') {
  ------------------
  |  Branch (7670:9): [True: 592, False: 24.1k]
  ------------------
 7671|    592|      if (port_colon == SIZE_MAX) port_colon = auth_end;
  ------------------
  |  Branch (7671:11): [True: 394, False: 198]
  ------------------
 7672|    592|      continue;
 7673|    592|    }
 7674|       |
 7675|       |    // Credentials or percent-encoding -> full parser.
 7676|  24.1k|    if (c == '@' || c == '%') return std::nullopt;
  ------------------
  |  Branch (7676:9): [True: 48, False: 24.1k]
  |  Branch (7676:21): [True: 162, False: 23.9k]
  ------------------
 7677|       |
 7678|       |    // Tabs/newlines anywhere in the authority require the full parser to
 7679|       |    // strip them before validation.  Without this, a tab in the port (e.g.
 7680|       |    // "http://host:8\t0/") would be mis-rejected by port validation.
 7681|  23.9k|    if (c == '\t' || c == '\n' || c == '\r') return std::nullopt;
  ------------------
  |  Branch (7681:9): [True: 1, False: 23.9k]
  |  Branch (7681:22): [True: 1, False: 23.9k]
  |  Branch (7681:35): [True: 3, False: 23.9k]
  ------------------
 7682|       |
 7683|       |    // Skip remaining host-specific checks for port bytes.  Port digits are
 7684|       |    // validated separately below, and no forbidden-domain-code-point check
 7685|       |    // is needed on port characters.
 7686|  23.9k|    if (port_colon != SIZE_MAX) continue;
  ------------------
  |  Branch (7686:9): [True: 1.06k, False: 22.8k]
  ------------------
 7687|       |
 7688|       |    // -- Host byte validation (inlined) ------------------------------------
 7689|       |    // Forbidden domain code points that are not already caught above:
 7690|       |    //   C0 controls and space (0x00-0x20), DEL (0x7F), <, >, [, ], ^, |.
 7691|       |    // At this stage, the input may still be userinfo or be normalized later
 7692|       |    // (e.g., percent-encoded), so we do not reject here and defer to the
 7693|       |    // parser. Characters already caught: >= 0x80 (non-ASCII), '/' '?' '#' '\\'
 7694|       |    // (delimiters), ':' (port), '@' '%' (bail), '\t' '\n' '\r' (bail).
 7695|  22.8k|    if (c <= 0x20 || c == 0x7F || c == '<' || c == '>' || c == '[' ||
  ------------------
  |  Branch (7695:9): [True: 11, False: 22.8k]
  |  Branch (7695:22): [True: 1, False: 22.8k]
  |  Branch (7695:35): [True: 1, False: 22.8k]
  |  Branch (7695:47): [True: 1, False: 22.8k]
  |  Branch (7695:59): [True: 1, False: 22.8k]
  ------------------
 7696|  22.8k|        c == ']' || c == '^' || c == '|') {
  ------------------
  |  Branch (7696:9): [True: 1, False: 22.8k]
  |  Branch (7696:21): [True: 1, False: 22.8k]
  |  Branch (7696:33): [True: 1, False: 22.8k]
  ------------------
 7697|     18|      return std::nullopt;
 7698|     18|    }
 7699|       |
 7700|       |    // Track whether host is all decimal digits and dots (potential IPv4).
 7701|  22.8k|    if (c != '.' && (c < '0' || c > '9')) all_dec_dots = false;
  ------------------
  |  Branch (7701:9): [True: 20.0k, False: 2.80k]
  |  Branch (7701:22): [True: 1.54k, False: 18.5k]
  |  Branch (7701:33): [True: 11.7k, False: 6.74k]
  ------------------
 7702|       |
 7703|       |    // Track last non-dot character for the IPv4 hex/octal heuristic.
 7704|  22.8k|    if (c != '.') last_non_dot = c;
  ------------------
  |  Branch (7704:9): [True: 20.0k, False: 2.80k]
  ------------------
 7705|       |
 7706|       |    // Detect xn-- prefix inline (IDNA punycode -> needs full parser).
 7707|       |    // Checking at every position mirrors the original behavior: any
 7708|       |    // occurrence of "xn--" in the host (not just at label boundaries)
 7709|       |    // triggers a bail-out to the full IDNA validator.
 7710|  22.8k|    if ((c | 0x20) == 'x' && auth_end + 4 <= len &&
  ------------------
  |  Branch (7710:9): [True: 2.79k, False: 20.0k]
  |  Branch (7710:30): [True: 2.58k, False: 203]
  ------------------
 7711|  2.58k|        (b[auth_end + 1] | 0x20) == 'n' && b[auth_end + 2] == '-' &&
  ------------------
  |  Branch (7711:9): [True: 1.73k, False: 854]
  |  Branch (7711:44): [True: 1.44k, False: 288]
  ------------------
 7712|  1.44k|        b[auth_end + 3] == '-') {
  ------------------
  |  Branch (7712:9): [True: 1.06k, False: 385]
  ------------------
 7713|  1.06k|      return std::nullopt;
 7714|  1.06k|    }
 7715|  22.8k|  }
 7716|       |
 7717|  2.28k|  const size_t host_end = (port_colon != SIZE_MAX) ? port_colon : auth_end;
  ------------------
  |  Branch (7717:27): [True: 351, False: 1.93k]
  ------------------
 7718|       |
 7719|       |  // Empty host is invalid for special URLs.
 7720|  2.28k|  if (auth_start == host_end) return false;
  ------------------
  |  Branch (7720:7): [True: 36, False: 2.24k]
  ------------------
 7721|       |
 7722|       |  // -- IPv4 handling ---------------------------------------------------------
 7723|  2.24k|  const char* host_ptr = reinterpret_cast<const char*>(b + auth_start);
 7724|  2.24k|  const size_t host_len = host_end - auth_start;
 7725|       |
 7726|  2.24k|  if (all_dec_dots) {
  ------------------
  |  Branch (7726:7): [True: 725, False: 1.52k]
  ------------------
 7727|       |    // Host is all decimal digits and dots -> try the fast IPv4 parser.
 7728|    725|    if (checkers::try_parse_ipv4_fast({host_ptr, host_len}) !=
  ------------------
  |  Branch (7728:9): [True: 503, False: 222]
  ------------------
 7729|    725|        checkers::ipv4_fast_fail) {
 7730|       |      // Valid decimal IPv4 host.  Do NOT return true yet: the port still
 7731|       |      // needs to be validated below before we can declare the URL valid.
 7732|    503|      goto validate_port;
 7733|    503|    }
 7734|       |    // Fast IPv4 parsing failed (e.g. host is ".", "..", "1.2.3.500").
 7735|       |    // Such hosts may still be valid domain names; defer to the full parser.
 7736|    222|    return std::nullopt;
 7737|    725|  }
 7738|       |
 7739|       |  // Last-significant-character heuristic for non-decimal IPv4 (hex/octal):
 7740|       |  // if the last non-dot char is a digit, 'a'-'f', or 'x' the host might be
 7741|       |  // an IPv4 address that the fast path can't validate -- fall through.
 7742|       |  // last_non_dot was tracked during the authority scan above.
 7743|  1.52k|  {
 7744|  1.52k|    const uint8_t lc = last_non_dot | 0x20;
 7745|  1.52k|    if ((last_non_dot >= '0' && last_non_dot <= '9') ||
  ------------------
  |  Branch (7745:10): [True: 1.23k, False: 284]
  |  Branch (7745:33): [True: 185, False: 1.05k]
  ------------------
 7746|  1.33k|        (lc >= 'a' && lc <= 'f') || lc == 'x') {
  ------------------
  |  Branch (7746:10): [True: 1.01k, False: 324]
  |  Branch (7746:23): [True: 298, False: 716]
  |  Branch (7746:37): [True: 227, False: 813]
  ------------------
 7747|    710|      return std::nullopt;
 7748|    710|    }
 7749|  1.52k|  }
 7750|       |
 7751|       |  // -- Port validation -------------------------------------------------------
 7752|  1.31k|validate_port:
 7753|  1.31k|  if (port_colon != SIZE_MAX) {
  ------------------
  |  Branch (7753:7): [True: 179, False: 1.13k]
  ------------------
 7754|    179|    const uint8_t* pp = b + port_colon + 1;
 7755|    179|    size_t pl = auth_end - port_colon - 1;
 7756|    179|    if (pl > 0) {
  ------------------
  |  Branch (7756:9): [True: 176, False: 3]
  ------------------
 7757|       |      // Strip leading zeros: "0000001" == 1, "0000000000000" == 0, both valid.
 7758|       |      // Only the significant digits count toward the 5-digit maximum.
 7759|    444|      while (pl > 0 && *pp == '0') {
  ------------------
  |  Branch (7759:14): [True: 407, False: 37]
  |  Branch (7759:24): [True: 268, False: 139]
  ------------------
 7760|    268|        ++pp;
 7761|    268|        --pl;
 7762|    268|      }
 7763|    176|      if (pl > 5) return false;  // significant digits > 99999
  ------------------
  |  Branch (7763:11): [True: 3, False: 173]
  ------------------
 7764|    173|      uint32_t pv = 0;
 7765|    525|      for (size_t i = 0; i < pl; ++i) {
  ------------------
  |  Branch (7765:26): [True: 363, False: 162]
  ------------------
 7766|    363|        if (pp[i] < '0' || pp[i] > '9') return false;
  ------------------
  |  Branch (7766:13): [True: 4, False: 359]
  |  Branch (7766:28): [True: 7, False: 352]
  ------------------
 7767|    352|        pv = pv * 10 + (pp[i] - '0');
 7768|    352|      }
 7769|    162|      if (pv > 65535) return false;
  ------------------
  |  Branch (7769:11): [True: 1, False: 161]
  ------------------
 7770|    162|    }
 7771|    179|  }
 7772|       |
 7773|       |  // Path, query, and fragment are structurally always valid for can_parse --
 7774|       |  // the parser would encode whatever is there.
 7775|  1.30k|  return true;
 7776|  1.31k|}
_ZN3ada7helpers27remove_ascii_tab_or_newlineERNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 8054|    856|ada_really_inline void remove_ascii_tab_or_newline(std::string& input) {
 8055|       |  // if this ever becomes a performance issue, we could use an approach similar
 8056|       |  // to has_tabs_or_newline
 8057|    856|  std::erase_if(input, ada::unicode::is_ascii_tab_or_newline);
 8058|    856|}
_ZN3ada7unicode23is_ascii_tab_or_newlineEc:
 7092|  50.0k|    const char c) noexcept {
 7093|  50.0k|  return c == '\t' || c == '\n' || c == '\r';
  ------------------
  |  Branch (7093:10): [True: 2.02k, False: 48.0k]
  |  Branch (7093:23): [True: 1.92k, False: 46.1k]
  |  Branch (7093:36): [True: 595, False: 45.5k]
  ------------------
 7094|  50.0k|}
_ZN3ada7unicode22is_c0_control_or_spaceEc:
 7087|   116k|ada_really_inline constexpr bool is_c0_control_or_space(const char c) noexcept {
 7088|   116k|  return (unsigned char)c <= ' ';
 7089|   116k|}
_ZN3ada7helpers19parse_prepared_pathENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEENS_6scheme4typeERNS1_12basic_stringIcS4_NS1_9allocatorIcEEEE:
 8736|  7.36k|                                           std::string& path) {
 8737|  7.36k|  ada_log("parse_prepared_path ", input);
 8738|  7.36k|  uint8_t accumulator = checkers::path_signature(input);
 8739|       |  // Let us first detect a trivial case.
 8740|       |  // If it is special, we check that we have no dot, no %,  no \ and no
 8741|       |  // character needing percent encoding. Otherwise, we check that we have no %,
 8742|       |  // no dot, and no character needing percent encoding.
 8743|  7.36k|  constexpr uint8_t need_encoding = 1;
 8744|  7.36k|  constexpr uint8_t backslash_char = 2;
 8745|  7.36k|  constexpr uint8_t dot_char = 4;
 8746|  7.36k|  constexpr uint8_t percent_char = 8;
 8747|  7.36k|  bool special = type != ada::scheme::NOT_SPECIAL;
 8748|  7.36k|  bool may_need_slow_file_handling = (type == ada::scheme::type::FILE &&
  ------------------
  |  Branch (8748:39): [True: 1.73k, False: 5.63k]
  ------------------
 8749|  1.73k|                                      checkers::is_windows_drive_letter(input));
  ------------------
  |  Branch (8749:39): [True: 134, False: 1.59k]
  ------------------
 8750|  7.36k|  bool trivial_path =
 8751|  7.36k|      (special ? (accumulator == 0)
  ------------------
  |  Branch (8751:7): [True: 4.51k, False: 2.84k]
  |  Branch (8751:8): [True: 5.93k, False: 1.42k]
  ------------------
 8752|  7.36k|               : ((accumulator & (need_encoding | dot_char | percent_char)) ==
 8753|  1.42k|                  0)) &&
 8754|  4.51k|      (!may_need_slow_file_handling);
  ------------------
  |  Branch (8754:7): [True: 4.42k, False: 96]
  ------------------
 8755|  7.36k|  if (accumulator == dot_char && !may_need_slow_file_handling) {
  ------------------
  |  Branch (8755:7): [True: 975, False: 6.38k]
  |  Branch (8755:34): [True: 952, False: 23]
  ------------------
 8756|       |    // '4' means that we have at least one dot, but nothing that requires
 8757|       |    // percent encoding or decoding. The only part that is not trivial is
 8758|       |    // that we may have single dots and double dots path segments.
 8759|       |    // If we have such segments, then we either have a path that begins
 8760|       |    // with '.' (easy to check), or we have the sequence './'.
 8761|       |    // Note: input cannot be empty, it must at least contain one character ('.')
 8762|       |    // Note: we know that '\' is not present.
 8763|    952|    if (input[0] != '.') {
  ------------------
  |  Branch (8763:9): [True: 436, False: 516]
  ------------------
 8764|    436|      size_t slashdot = 0;
 8765|    436|      bool dot_is_file = true;
 8766|  1.90k|      for (;;) {
 8767|  1.90k|        slashdot = input.find("/.", slashdot);
 8768|  1.90k|        if (slashdot == std::string_view::npos) {  // common case
  ------------------
  |  Branch (8768:13): [True: 436, False: 1.47k]
  ------------------
 8769|    436|          break;
 8770|  1.47k|        } else {  // uncommon
 8771|       |          // only three cases matter: /./, /.. or a final /
 8772|  1.47k|          slashdot += 2;
 8773|  1.47k|          dot_is_file &= !(slashdot == input.size() || input[slashdot] == '.' ||
  ------------------
  |  Branch (8773:28): [True: 60, False: 1.41k]
  |  Branch (8773:56): [True: 1.05k, False: 361]
  ------------------
 8774|    361|                           input[slashdot] == '/');
  ------------------
  |  Branch (8774:28): [True: 232, False: 129]
  ------------------
 8775|  1.47k|        }
 8776|  1.90k|      }
 8777|    436|      trivial_path = dot_is_file;
 8778|    436|    }
 8779|    952|  }
 8780|  7.36k|  if (trivial_path) {
  ------------------
  |  Branch (8780:7): [True: 4.55k, False: 2.80k]
  ------------------
 8781|  4.55k|    ada_log("parse_path trivial");
 8782|  4.55k|    path += '/';
 8783|  4.55k|    path += input;
 8784|  4.55k|    return;
 8785|  4.55k|  }
 8786|       |  // We are going to need to look a bit at the path, but let us see if we can
 8787|       |  // ignore percent encoding *and* backslashes *and* percent characters.
 8788|       |  // Except for the trivial case, this is likely to capture 99% of paths out
 8789|       |  // there.
 8790|  2.80k|  bool fast_path =
 8791|  2.80k|      (special &&
  ------------------
  |  Branch (8791:8): [True: 1.79k, False: 1.01k]
  ------------------
 8792|  1.79k|       (accumulator & (need_encoding | backslash_char | percent_char)) == 0) &&
  ------------------
  |  Branch (8792:8): [True: 766, False: 1.02k]
  ------------------
 8793|    766|      (type != ada::scheme::type::FILE);
  ------------------
  |  Branch (8793:7): [True: 585, False: 181]
  ------------------
 8794|  2.80k|  if (fast_path) {
  ------------------
  |  Branch (8794:7): [True: 585, False: 2.21k]
  ------------------
 8795|    585|    ada_log("parse_prepared_path fast");
 8796|       |    // Here we don't need to worry about \ or percent encoding.
 8797|       |    // We also do not have a file protocol. We might have dots, however,
 8798|       |    // but dots must as appear as '.', and they cannot be encoded because
 8799|       |    // the symbol '%' is not present.
 8800|    585|    size_t previous_location = 0;  // We start at 0.
 8801|  7.02k|    do {
 8802|  7.02k|      size_t new_location = input.find('/', previous_location);
 8803|       |      // std::string_view path_view = input;
 8804|       |      //  We process the last segment separately:
 8805|  7.02k|      if (new_location == std::string_view::npos) {
  ------------------
  |  Branch (8805:11): [True: 585, False: 6.44k]
  ------------------
 8806|    585|        std::string_view path_view = input.substr(previous_location);
 8807|    585|        if (path_view == "..") {  // The path ends with ..
  ------------------
  |  Branch (8807:13): [True: 60, False: 525]
  ------------------
 8808|       |          // e.g., if you receive ".." with an empty path, you go to "/".
 8809|     60|          if (path.empty()) {
  ------------------
  |  Branch (8809:15): [True: 18, False: 42]
  ------------------
 8810|     18|            path = '/';
 8811|     18|            return;
 8812|     18|          }
 8813|       |          // Fast case where we have nothing to do:
 8814|     42|          if (path.back() == '/') {
  ------------------
  |  Branch (8814:15): [True: 17, False: 25]
  ------------------
 8815|     17|            return;
 8816|     17|          }
 8817|       |          // If you have the path "/joe/myfriend",
 8818|       |          // then you delete 'myfriend'.
 8819|     25|          path.resize(path.rfind('/') + 1);
 8820|     25|          return;
 8821|     42|        }
 8822|    525|        path += '/';
 8823|    525|        if (path_view != ".") {
  ------------------
  |  Branch (8823:13): [True: 463, False: 62]
  ------------------
 8824|    463|          path.append(path_view);
 8825|    463|        }
 8826|    525|        return;
 8827|  6.44k|      } else {
 8828|       |        // This is a non-final segment.
 8829|  6.44k|        std::string_view path_view =
 8830|  6.44k|            input.substr(previous_location, new_location - previous_location);
 8831|  6.44k|        previous_location = new_location + 1;
 8832|  6.44k|        if (path_view == "..") {
  ------------------
  |  Branch (8832:13): [True: 994, False: 5.44k]
  ------------------
 8833|    994|          size_t last_delimiter = path.rfind('/');
 8834|    994|          if (last_delimiter != std::string::npos) {
  ------------------
  |  Branch (8834:15): [True: 548, False: 446]
  ------------------
 8835|    548|            path.erase(last_delimiter);
 8836|    548|          }
 8837|  5.44k|        } else if (path_view != ".") {
  ------------------
  |  Branch (8837:20): [True: 5.13k, False: 312]
  ------------------
 8838|  5.13k|          path += '/';
 8839|  5.13k|          path.append(path_view);
 8840|  5.13k|        }
 8841|  6.44k|      }
 8842|  7.02k|    } while (true);
  ------------------
  |  Branch (8842:14): [True: 6.44k, Folded]
  ------------------
 8843|  2.21k|  } else {
 8844|  2.21k|    ada_log("parse_path slow");
 8845|       |    // we have reached the general case
 8846|  2.21k|    bool needs_percent_encoding = (accumulator & 1);
 8847|  2.21k|    std::string path_buffer_tmp;
 8848|  12.8k|    do {
 8849|  12.8k|      size_t location = (special && (accumulator & 2))
  ------------------
  |  Branch (8849:26): [True: 7.65k, False: 5.23k]
  |  Branch (8849:37): [True: 393, False: 7.26k]
  ------------------
 8850|  12.8k|                            ? input.find_first_of("/\\")
 8851|  12.8k|                            : input.find('/');
 8852|  12.8k|      std::string_view path_view = input;
 8853|  12.8k|      if (location != std::string_view::npos) {
  ------------------
  |  Branch (8853:11): [True: 10.6k, False: 2.21k]
  ------------------
 8854|  10.6k|        path_view.remove_suffix(path_view.size() - location);
 8855|  10.6k|        input.remove_prefix(location + 1);
 8856|  10.6k|      }
 8857|       |      // path_buffer is either path_view or it might point at a percent encoded
 8858|       |      // temporary file.
 8859|  12.8k|      std::string_view path_buffer =
 8860|  12.8k|          (needs_percent_encoding &&
  ------------------
  |  Branch (8860:12): [True: 7.57k, False: 5.30k]
  ------------------
 8861|  7.57k|           ada::unicode::percent_encode<false>(
  ------------------
  |  Branch (8861:12): [True: 2.98k, False: 4.59k]
  ------------------
 8862|  7.57k|               path_view, character_sets::PATH_PERCENT_ENCODE, path_buffer_tmp))
 8863|  12.8k|              ? path_buffer_tmp
 8864|  12.8k|              : path_view;
 8865|  12.8k|      if (unicode::is_double_dot_path_segment(path_buffer)) {
  ------------------
  |  Branch (8865:11): [True: 2.67k, False: 10.2k]
  ------------------
 8866|  2.67k|        helpers::shorten_path(path, type);
 8867|  2.67k|        if (location == std::string_view::npos) {
  ------------------
  |  Branch (8867:13): [True: 198, False: 2.47k]
  ------------------
 8868|    198|          path += '/';
 8869|    198|        }
 8870|  10.2k|      } else if (unicode::is_single_dot_path_segment(path_buffer) &&
  ------------------
  |  Branch (8870:18): [True: 634, False: 9.57k]
  ------------------
 8871|    634|                 (location == std::string_view::npos)) {
  ------------------
  |  Branch (8871:18): [True: 95, False: 539]
  ------------------
 8872|     95|        path += '/';
 8873|     95|      }
 8874|       |      // Otherwise, if path_buffer is not a single-dot path segment, then:
 8875|  10.1k|      else if (!unicode::is_single_dot_path_segment(path_buffer)) {
  ------------------
  |  Branch (8875:16): [True: 9.57k, False: 539]
  ------------------
 8876|       |        // If url's scheme is "file", url's path is empty, and path_buffer is a
 8877|       |        // Windows drive letter, then replace the second code point in
 8878|       |        // path_buffer with U+003A (:).
 8879|  9.57k|        if (type == ada::scheme::type::FILE && path.empty() &&
  ------------------
  |  Branch (8879:13): [True: 2.62k, False: 6.95k]
  |  Branch (8879:48): [True: 1.23k, False: 1.39k]
  ------------------
 8880|  1.23k|            checkers::is_windows_drive_letter(path_buffer)) {
  ------------------
  |  Branch (8880:13): [True: 159, False: 1.07k]
  ------------------
 8881|    159|          path += '/';
 8882|    159|          path += path_buffer[0];
 8883|    159|          path += ':';
 8884|    159|          path_buffer.remove_prefix(2);
 8885|    159|          path.append(path_buffer);
 8886|  9.41k|        } else {
 8887|       |          // Append path_buffer to url's path.
 8888|  9.41k|          path += '/';
 8889|  9.41k|          path.append(path_buffer);
 8890|  9.41k|        }
 8891|  9.57k|      }
 8892|  12.8k|      if (location == std::string_view::npos) {
  ------------------
  |  Branch (8892:11): [True: 2.21k, False: 10.6k]
  ------------------
 8893|  2.21k|        return;
 8894|  2.21k|      }
 8895|  12.8k|    } while (true);
  ------------------
  |  Branch (8895:14): [True: 10.6k, Folded]
  ------------------
 8896|  2.21k|  }
 8897|  2.80k|}
_ZN3ada8checkers14path_signatureENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
   87|  14.7k|    std::string_view input) noexcept {
   88|       |  // The path percent-encode set is the query percent-encode set and U+003F (?),
   89|       |  // U+0060 (`), U+007B ({), and U+007D (}). The query percent-encode set is the
   90|       |  // C0 control percent-encode set and U+0020 SPACE, U+0022 ("), U+0023 (#),
   91|       |  // U+003C (<), and U+003E (>). The C0 control percent-encode set are the C0
   92|       |  // controls and all code points greater than U+007E (~).
   93|  14.7k|  size_t i = 0;
   94|  14.7k|  uint8_t accumulator{};
   95|  41.8k|  for (; i + 7 < input.size(); i += 8) {
  ------------------
  |  Branch (95:10): [True: 27.1k, False: 14.7k]
  ------------------
   96|  27.1k|    accumulator |= uint8_t(path_signature_table[uint8_t(input[i])] |
   97|  27.1k|                           path_signature_table[uint8_t(input[i + 1])] |
   98|  27.1k|                           path_signature_table[uint8_t(input[i + 2])] |
   99|  27.1k|                           path_signature_table[uint8_t(input[i + 3])] |
  100|  27.1k|                           path_signature_table[uint8_t(input[i + 4])] |
  101|  27.1k|                           path_signature_table[uint8_t(input[i + 5])] |
  102|  27.1k|                           path_signature_table[uint8_t(input[i + 6])] |
  103|  27.1k|                           path_signature_table[uint8_t(input[i + 7])]);
  104|  27.1k|  }
  105|  35.3k|  for (; i < input.size(); i++) {
  ------------------
  |  Branch (105:10): [True: 20.6k, False: 14.7k]
  ------------------
  106|  20.6k|    accumulator |= uint8_t(path_signature_table[uint8_t(input[i])]);
  107|  20.6k|  }
  108|  14.7k|  return accumulator;
  109|  14.7k|}
_ZN3ada7unicode14percent_encodeILb0EEEbNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEPKhRNS2_12basic_stringIcS5_NS2_9allocatorIcEEEE:
 7308|  15.1k|                    std::string& out) {
 7309|  15.1k|  ada_log("percent_encode ", input, " to output string while ",
 7310|  15.1k|          append ? "appending" : "overwriting");
 7311|  15.1k|  auto pointer = std::ranges::find_if(input, [character_set](const char c) {
 7312|  15.1k|    return character_sets::bit_at(character_set, c);
 7313|  15.1k|  });
 7314|  15.1k|  ada_log("percent_encode done checking, moved to ",
 7315|  15.1k|          std::distance(input.begin(), pointer));
 7316|       |
 7317|       |  // Optimization: Don't iterate if percent encode is not required
 7318|  15.1k|  if (pointer == input.end()) {
  ------------------
  |  Branch (7318:7): [True: 9.18k, False: 5.97k]
  ------------------
 7319|  9.18k|    ada_log("percent_encode encoding not needed.");
 7320|  9.18k|    return false;
 7321|  9.18k|  }
 7322|  5.97k|  if constexpr (!append) {
 7323|  5.97k|    out.clear();
 7324|  5.97k|  }
 7325|  5.97k|  ada_log("percent_encode appending ", std::distance(input.begin(), pointer),
 7326|  5.97k|          " bytes");
 7327|       |  // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
 7328|  5.97k|  out.append(input.data(), std::distance(input.begin(), pointer));
 7329|  5.97k|  ada_log("percent_encode processing ", std::distance(pointer, input.end()),
 7330|  5.97k|          " bytes");
 7331|  84.1k|  for (; pointer != input.end(); pointer++) {
  ------------------
  |  Branch (7331:10): [True: 78.2k, False: 5.97k]
  ------------------
 7332|  78.2k|    if (character_sets::bit_at(character_set, *pointer)) {
  ------------------
  |  Branch (7332:9): [True: 74.3k, False: 3.91k]
  ------------------
 7333|  74.3k|      out.append(character_sets::hex + uint8_t(*pointer) * 4, 3);
 7334|  74.3k|    } else {
 7335|  3.91k|      out += *pointer;
 7336|  3.91k|    }
 7337|  78.2k|  }
 7338|  5.97k|  return true;
 7339|  15.1k|}
_ZZN3ada7unicode14percent_encodeILb0EEEbNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEPKhRNS2_12basic_stringIcS5_NS2_9allocatorIcEEEEENKUlcE_clEc:
 7311|  19.2k|  auto pointer = std::ranges::find_if(input, [character_set](const char c) {
 7312|  19.2k|    return character_sets::bit_at(character_set, c);
 7313|  19.2k|  });
_ZN3ada7unicode26is_double_dot_path_segmentENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 7100|  25.8k|    std::string_view input) noexcept {
 7101|       |  // This will catch most cases:
 7102|       |  // The length must be 2,4 or 6.
 7103|       |  // We divide by two and require
 7104|       |  // that the result be between 1 and 3 inclusively.
 7105|  25.8k|  uint64_t half_length = uint64_t(input.size()) / 2;
 7106|  25.8k|  if (half_length - 1 > 2) {
  ------------------
  |  Branch (7106:7): [True: 11.9k, False: 13.8k]
  ------------------
 7107|  11.9k|    return false;
 7108|  11.9k|  }
 7109|       |  // We have a string of length 2, 4 or 6.
 7110|       |  // We now check the first character:
 7111|  13.8k|  if ((input[0] != '.') && (input[0] != '%')) {
  ------------------
  |  Branch (7111:7): [True: 6.84k, False: 7.00k]
  |  Branch (7111:28): [True: 2.06k, False: 4.77k]
  ------------------
 7112|  2.06k|    return false;
 7113|  2.06k|  }
 7114|       |  // We are unlikely the get beyond this point.
 7115|  11.7k|  int hash_value = (input.size() + (unsigned)(input[0])) & 3;
 7116|  11.7k|  const std::string_view target = table_is_double_dot_path_segment[hash_value];
 7117|  11.7k|  if (target.size() != input.size()) {
  ------------------
  |  Branch (7117:7): [True: 4.05k, False: 7.72k]
  ------------------
 7118|  4.05k|    return false;
 7119|  4.05k|  }
 7120|       |  // We almost never get here.
 7121|       |  // Optimizing the rest is relatively unimportant.
 7122|  7.72k|  auto prefix_equal_unsafe = [](std::string_view a, std::string_view b) {
 7123|  7.72k|    uint16_t A, B;
 7124|  7.72k|    memcpy(&A, a.data(), sizeof(A));
 7125|  7.72k|    memcpy(&B, b.data(), sizeof(B));
 7126|  7.72k|    return A == B;
 7127|  7.72k|  };
 7128|  7.72k|  if (!prefix_equal_unsafe(input, target)) {
  ------------------
  |  Branch (7128:7): [True: 956, False: 6.77k]
  ------------------
 7129|    956|    return false;
 7130|    956|  }
 7131|  8.95k|  for (size_t i = 2; i < input.size(); i++) {
  ------------------
  |  Branch (7131:22): [True: 3.60k, False: 5.35k]
  ------------------
 7132|  3.60k|    char c = input[i];
 7133|  3.60k|    if ((uint8_t((c | 0x20) - 0x61) <= 25 ? (c | 0x20) : c) != target[i]) {
  ------------------
  |  Branch (7133:9): [True: 1.42k, False: 2.18k]
  |  Branch (7133:10): [True: 924, False: 2.67k]
  ------------------
 7134|  1.42k|      return false;
 7135|  1.42k|    }
 7136|  3.60k|  }
 7137|  5.35k|  return true;
 7138|       |  // The above code might be a bit better than the code below. Compilers
 7139|       |  // are not stupid and may use the fact that these strings have length 2,4 and
 7140|       |  // 6 and other tricks.
 7141|       |  // return input == ".." ||
 7142|       |  //  input == ".%2e" || input == ".%2E" ||
 7143|       |  //  input == "%2e." || input == "%2E." ||
 7144|       |  //  input == "%2e%2e" || input == "%2E%2E" || input == "%2E%2e" || input ==
 7145|       |  //  "%2e%2E";
 7146|  6.77k|}
_ZZN3ada7unicode26is_double_dot_path_segmentENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEENKUlS5_S5_E_clES5_S5_:
 7122|  7.72k|  auto prefix_equal_unsafe = [](std::string_view a, std::string_view b) {
 7123|  7.72k|    uint16_t A, B;
 7124|  7.72k|    memcpy(&A, a.data(), sizeof(A));
 7125|  7.72k|    memcpy(&B, b.data(), sizeof(B));
 7126|  7.72k|    return A == B;
 7127|  7.72k|  };
_ZN3ada7unicode26is_single_dot_path_segmentENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 7149|  40.7k|    std::string_view input) noexcept {
 7150|  40.7k|  return input == "." || input == "%2e" || input == "%2E";
  ------------------
  |  Branch (7150:10): [True: 1.55k, False: 39.2k]
  |  Branch (7150:26): [True: 796, False: 38.4k]
  |  Branch (7150:44): [True: 0, False: 38.4k]
  ------------------
 7151|  40.7k|}
_ZN3ada7unicode28is_forbidden_host_code_pointEc:
 6970|  34.4k|    const char c) noexcept {
 6971|  34.4k|  return is_forbidden_host_code_point_table[uint8_t(c)];
 6972|  34.4k|}
_ZN3ada6detail17parse_ipv4_numberERPKcS2_RmRb:
 9014|  5.14k|                              bool& is_pure_decimal) noexcept {
 9015|  5.14k|  is_pure_decimal = false;
 9016|  5.14k|  if (p >= end) [[unlikely]] {
  ------------------
  |  Branch (9016:7): [True: 0, False: 5.14k]
  ------------------
 9017|      0|    return false;
 9018|      0|  }
 9019|  5.14k|  if (end - p >= 2 && p[0] == '0' && ((p[1] | 0x20) == 'x')) {
  ------------------
  |  Branch (9019:7): [True: 3.69k, False: 1.44k]
  |  Branch (9019:23): [True: 1.74k, False: 1.95k]
  |  Branch (9019:38): [True: 858, False: 888]
  ------------------
 9020|    858|    p += 2;
 9021|    858|    if (p == end || *p == '.') {
  ------------------
  |  Branch (9021:9): [True: 171, False: 687]
  |  Branch (9021:21): [True: 36, False: 651]
  ------------------
 9022|    207|      value = 0;
 9023|    207|      return true;
 9024|    207|    }
 9025|    651|    uint64_t v = 0;
 9026|    651|    int digits = 0;
 9027|  2.42k|    while (p < end && *p != '.') {
  ------------------
  |  Branch (9027:12): [True: 1.94k, False: 480]
  |  Branch (9027:23): [True: 1.83k, False: 114]
  ------------------
 9028|  1.83k|      const uint8_t nib = hex_nibble[static_cast<unsigned char>(*p)];
 9029|  1.83k|      if (nib == 0xff) [[unlikely]] {
  ------------------
  |  Branch (9029:11): [True: 24, False: 1.80k]
  ------------------
 9030|     24|        return false;
 9031|     24|      }
 9032|  1.80k|      if (v > (0xFFFFFFFFULL >> 4)) [[unlikely]] {
  ------------------
  |  Branch (9032:11): [True: 33, False: 1.77k]
  ------------------
 9033|     33|        return false;
 9034|     33|      }
 9035|  1.77k|      v = (v << 4) | nib;
 9036|  1.77k|      ++p;
 9037|  1.77k|      ++digits;
 9038|  1.77k|    }
 9039|    594|    if (digits == 0) [[unlikely]] {
  ------------------
  |  Branch (9039:9): [True: 0, False: 594]
  ------------------
 9040|      0|      return false;
 9041|      0|    }
 9042|    594|    value = v;
 9043|    594|    return true;
 9044|    594|  }
 9045|  4.28k|  if (end - p >= 2 && p[0] == '0' && p[1] >= '0' && p[1] <= '9') {
  ------------------
  |  Branch (9045:7): [True: 2.83k, False: 1.44k]
  |  Branch (9045:23): [True: 888, False: 1.95k]
  |  Branch (9045:38): [True: 582, False: 306]
  |  Branch (9045:53): [True: 570, False: 12]
  ------------------
 9046|    570|    ++p;
 9047|    570|    uint64_t v = 0;
 9048|  5.79k|    while (p < end && *p != '.') {
  ------------------
  |  Branch (9048:12): [True: 5.43k, False: 360]
  |  Branch (9048:23): [True: 5.29k, False: 141]
  ------------------
 9049|  5.29k|      const char c = *p;
 9050|  5.29k|      if (c < '0' || c > '7') [[unlikely]] {
  ------------------
  |  Branch (9050:11): [True: 18, False: 5.28k]
  |  Branch (9050:22): [True: 33, False: 5.24k]
  ------------------
 9051|     51|        return false;
 9052|     51|      }
 9053|  5.24k|      if (v > (0xFFFFFFFFULL >> 3)) [[unlikely]] {
  ------------------
  |  Branch (9053:11): [True: 18, False: 5.22k]
  ------------------
 9054|     18|        return false;
 9055|     18|      }
 9056|  5.22k|      v = (v << 3) | static_cast<uint64_t>(c - '0');
 9057|  5.22k|      ++p;
 9058|  5.22k|    }
 9059|    501|    value = v;
 9060|    501|    return true;
 9061|    570|  }
 9062|  3.71k|  if (*p < '0' || *p > '9') [[unlikely]] {
  ------------------
  |  Branch (9062:7): [True: 117, False: 3.60k]
  |  Branch (9062:19): [True: 189, False: 3.41k]
  ------------------
 9063|    306|    return false;
 9064|    306|  }
 9065|  3.41k|  is_pure_decimal = true;
 9066|  3.41k|  uint64_t v = static_cast<uint64_t>(*p - '0');
 9067|  3.41k|  ++p;
 9068|  7.20k|  while (p < end && *p != '.') {
  ------------------
  |  Branch (9068:10): [True: 5.05k, False: 2.15k]
  |  Branch (9068:21): [True: 3.90k, False: 1.15k]
  ------------------
 9069|  3.90k|    const char c = *p;
 9070|  3.90k|    if (c < '0' || c > '9') [[unlikely]] {
  ------------------
  |  Branch (9070:9): [True: 24, False: 3.87k]
  |  Branch (9070:20): [True: 45, False: 3.83k]
  ------------------
 9071|     69|      return false;
 9072|     69|    }
 9073|  3.83k|    if (v > 429496729ULL) [[unlikely]] {
  ------------------
  |  Branch (9073:9): [True: 24, False: 3.81k]
  ------------------
 9074|     24|      return false;
 9075|     24|    }
 9076|  3.81k|    v = v * 10u + static_cast<uint64_t>(c - '0');
 9077|  3.81k|    if (v > 0xFFFFFFFFULL) [[unlikely]] {
  ------------------
  |  Branch (9077:9): [True: 12, False: 3.79k]
  ------------------
 9078|     12|      return false;
 9079|     12|    }
 9080|  3.79k|    ++p;
 9081|  3.79k|  }
 9082|  3.30k|  value = v;
 9083|  3.30k|  return true;
 9084|  3.41k|}
_ZN3ada6detail15parse_hex_pieceERPKcS2_Rt:
 9088|  2.94k|                           uint16_t& value) noexcept {
 9089|  2.94k|  if (pointer == end) {
  ------------------
  |  Branch (9089:7): [True: 0, False: 2.94k]
  ------------------
 9090|      0|    return 0;
 9091|      0|  }
 9092|  2.94k|  const uint8_t n0 = hex_nibble[static_cast<unsigned char>(*pointer)];
 9093|  2.94k|  if (n0 == 0xff) {
  ------------------
  |  Branch (9093:7): [True: 162, False: 2.77k]
  ------------------
 9094|    162|    return 0;
 9095|    162|  }
 9096|  2.77k|  uint32_t v = n0;
 9097|  2.77k|  ++pointer;
 9098|  2.77k|  int length = 1;
 9099|  2.77k|  if (pointer != end) {
  ------------------
  |  Branch (9099:7): [True: 2.48k, False: 294]
  ------------------
 9100|  2.48k|    const uint8_t n1 = hex_nibble[static_cast<unsigned char>(*pointer)];
 9101|  2.48k|    if (n1 != 0xff) {
  ------------------
  |  Branch (9101:9): [True: 897, False: 1.58k]
  ------------------
 9102|    897|      v = (v << 4) | n1;
 9103|    897|      ++pointer;
 9104|    897|      ++length;
 9105|    897|      if (pointer != end) {
  ------------------
  |  Branch (9105:11): [True: 816, False: 81]
  ------------------
 9106|    816|        const uint8_t n2 = hex_nibble[static_cast<unsigned char>(*pointer)];
 9107|    816|        if (n2 != 0xff) {
  ------------------
  |  Branch (9107:13): [True: 588, False: 228]
  ------------------
 9108|    588|          v = (v << 4) | n2;
 9109|    588|          ++pointer;
 9110|    588|          ++length;
 9111|    588|          if (pointer != end) {
  ------------------
  |  Branch (9111:15): [True: 501, False: 87]
  ------------------
 9112|    501|            const uint8_t n3 = hex_nibble[static_cast<unsigned char>(*pointer)];
 9113|    501|            if (n3 != 0xff) {
  ------------------
  |  Branch (9113:17): [True: 252, False: 249]
  ------------------
 9114|    252|              v = (v << 4) | n3;
 9115|    252|              ++pointer;
 9116|    252|              ++length;
 9117|    252|            }
 9118|    501|          }
 9119|    588|        }
 9120|    816|      }
 9121|    897|    }
 9122|  2.48k|  }
 9123|  2.77k|  value = static_cast<uint16_t>(v);
 9124|  2.77k|  return length;
 9125|  2.94k|}
_ZN3ada7unicode13is_alnum_plusEc:
 7064|   148k|ada_really_inline constexpr bool is_alnum_plus(const char c) noexcept {
 7065|   148k|  return is_alnum_plus_table[uint8_t(c)];
 7066|       |  // A table is almost surely much faster than the
 7067|       |  // following under most compilers: return
 7068|       |  // return (std::isalnum(c) || c == '+' || c == '-' || c == '.');
 7069|   148k|}
_ZN3ada7helpers10prune_hashERNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 7994|  91.6k|    std::string_view& input) noexcept {
 7995|       |  // compiles down to 20--30 instructions including a class to memchr (C
 7996|       |  // function). this function should be quite fast.
 7997|  91.6k|  size_t location_of_first = input.find('#');
 7998|  91.6k|  if (location_of_first == std::string_view::npos) {
  ------------------
  |  Branch (7998:7): [True: 89.2k, False: 2.42k]
  ------------------
 7999|  89.2k|    return std::nullopt;
 8000|  89.2k|  }
 8001|  2.42k|  std::string_view hash = input;
 8002|  2.42k|  hash.remove_prefix(location_of_first + 1);
 8003|  2.42k|  input.remove_suffix(input.size() - location_of_first);
 8004|  2.42k|  return hash;
 8005|  91.6k|}
_ZN3ada7helpers32find_authority_delimiter_specialENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8932|  19.3k|find_authority_delimiter_special(std::string_view view) noexcept {
 8933|       |  // performance note: we might be able to gain further performance
 8934|       |  // with SIMD intrinsics.
 8935|   147k|  for (auto pos = view.begin(); pos != view.end(); ++pos) {
  ------------------
  |  Branch (8935:33): [True: 145k, False: 1.69k]
  ------------------
 8936|   145k|    if (authority_delimiter_special[(uint8_t)*pos]) {
  ------------------
  |  Branch (8936:9): [True: 17.6k, False: 127k]
  ------------------
 8937|  17.6k|      return pos - view.begin();
 8938|  17.6k|    }
 8939|   145k|  }
 8940|  1.69k|  return size_t(view.size());
 8941|  19.3k|}
_ZN3ada7helpers24find_authority_delimiterENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8953|  2.27k|find_authority_delimiter(std::string_view view) noexcept {
 8954|       |  // performance note: we might be able to gain further performance
 8955|       |  // with SIMD instrinsics.
 8956|  12.6k|  for (auto pos = view.begin(); pos != view.end(); ++pos) {
  ------------------
  |  Branch (8956:33): [True: 12.4k, False: 231]
  ------------------
 8957|  12.4k|    if (authority_delimiter[(uint8_t)*pos]) {
  ------------------
  |  Branch (8957:9): [True: 2.04k, False: 10.3k]
  ------------------
 8958|  2.04k|      return pos - view.begin();
 8959|  2.04k|    }
 8960|  12.4k|  }
 8961|    231|  return size_t(view.size());
 8962|  2.27k|}
_ZN3ada7helpers12shorten_pathERNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS_6scheme4typeE:
 8007|  5.81k|ada_really_inline bool shorten_path(std::string& path, ada::scheme::type type) {
 8008|       |  // Let path be url's path.
 8009|       |  // If url's scheme is "file", path's size is 1, and path[0] is a normalized
 8010|       |  // Windows drive letter, then return.
 8011|  5.81k|  if (type == ada::scheme::type::FILE &&
  ------------------
  |  Branch (8011:7): [True: 3.65k, False: 2.16k]
  ------------------
 8012|  3.65k|      path.find('/', 1) == std::string_view::npos && !path.empty()) {
  ------------------
  |  Branch (8012:7): [True: 2.62k, False: 1.03k]
  |  Branch (8012:54): [True: 1.80k, False: 812]
  ------------------
 8013|  1.80k|    if (checkers::is_normalized_windows_drive_letter(
  ------------------
  |  Branch (8013:9): [True: 648, False: 1.16k]
  ------------------
 8014|  1.80k|            helpers::substring(path, 1))) {
 8015|    648|      return false;
 8016|    648|    }
 8017|  1.80k|  }
 8018|       |
 8019|       |  // Remove path's last item, if any.
 8020|  5.16k|  size_t last_delimiter = path.rfind('/');
 8021|  5.16k|  if (last_delimiter != std::string::npos) {
  ------------------
  |  Branch (8021:7): [True: 3.13k, False: 2.03k]
  ------------------
 8022|  3.13k|    path.erase(last_delimiter);
 8023|  3.13k|    return true;
 8024|  3.13k|  }
 8025|       |
 8026|  2.03k|  return false;
 8027|  5.16k|}
_ZN3ada7helpers27get_host_delimiter_locationEbRNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8645|  31.7k|    const bool is_special, std::string_view& view) noexcept {
 8646|       |  /**
 8647|       |   * The spec at https://url.spec.whatwg.org/#hostname-state expects us to
 8648|       |   * compute a variable called insideBrackets but this variable is only used
 8649|       |   * once, to check whether a ':' character was found outside brackets. Exact
 8650|       |   * text: "Otherwise, if c is U+003A (:) and insideBrackets is false, then:".
 8651|       |   * It is conceptually simpler and arguably more efficient to just return a
 8652|       |   * Boolean indicating whether ':' was found outside brackets.
 8653|       |   */
 8654|  31.7k|  const size_t view_size = view.size();
 8655|  31.7k|  size_t location = 0;
 8656|  31.7k|  bool found_colon = false;
 8657|       |  /**
 8658|       |   * Performance analysis:
 8659|       |   *
 8660|       |   * We are basically seeking the end of the hostname which can be indicated
 8661|       |   * by the end of the view, or by one of the characters ':', '/', '?', '\\'
 8662|       |   * (where '\\' is only applicable for special URLs). However, these must
 8663|       |   * appear outside a bracket range. E.g., if you have [something?]fd: then the
 8664|       |   * '?' does not count.
 8665|       |   *
 8666|       |   * So we can skip ahead to the next delimiter, as long as we include '[' in
 8667|       |   * the set of delimiters, and that we handle it first.
 8668|       |   *
 8669|       |   * So the trick is to have a fast function that locates the next delimiter.
 8670|       |   * Unless we find '[', then it only needs to be called once! Ideally, such a
 8671|       |   * function would be provided by the C++ standard library, but it seems that
 8672|       |   * find_first_of is not very fast, so we are forced to roll our own.
 8673|       |   *
 8674|       |   * We do not break into two loops for speed, but for clarity.
 8675|       |   */
 8676|  31.7k|  if (is_special) {
  ------------------
  |  Branch (8676:7): [True: 29.8k, False: 1.89k]
  ------------------
 8677|       |    // We move to the next delimiter.
 8678|  29.8k|    location = find_next_host_delimiter_special(view, location);
 8679|       |    // Unless we find '[' then we are going only going to have to call
 8680|       |    // find_next_host_delimiter_special once.
 8681|  33.2k|    for (; location < view_size;
  ------------------
  |  Branch (8681:12): [True: 17.9k, False: 15.2k]
  ------------------
 8682|  29.8k|         location = find_next_host_delimiter_special(view, location)) {
 8683|  17.9k|      if (view[location] == '[') {
  ------------------
  |  Branch (8683:11): [True: 3.69k, False: 14.2k]
  ------------------
 8684|  3.69k|        location = view.find(']', location);
 8685|  3.69k|        if (location == std::string_view::npos) {
  ------------------
  |  Branch (8685:13): [True: 309, False: 3.38k]
  ------------------
 8686|       |          // performance: view.find might get translated to a memchr, which
 8687|       |          // has no notion of std::string_view::npos, so the code does not
 8688|       |          // reflect the assembly.
 8689|    309|          location = view_size;
 8690|    309|          break;
 8691|    309|        }
 8692|  14.2k|      } else {
 8693|  14.2k|        found_colon = view[location] == ':';
 8694|  14.2k|        break;
 8695|  14.2k|      }
 8696|  17.9k|    }
 8697|  29.8k|  } else {
 8698|       |    // We move to the next delimiter.
 8699|  1.89k|    location = find_next_host_delimiter(view, location);
 8700|       |    // Unless we find '[' then we are going only going to have to call
 8701|       |    // find_next_host_delimiter_special once.
 8702|  3.50k|    for (; location < view_size;
  ------------------
  |  Branch (8702:12): [True: 2.42k, False: 1.08k]
  ------------------
 8703|  2.42k|         location = find_next_host_delimiter(view, location)) {
 8704|  2.42k|      if (view[location] == '[') {
  ------------------
  |  Branch (8704:11): [True: 1.68k, False: 747]
  ------------------
 8705|  1.68k|        location = view.find(']', location);
 8706|  1.68k|        if (location == std::string_view::npos) {
  ------------------
  |  Branch (8706:13): [True: 69, False: 1.61k]
  ------------------
 8707|       |          // performance: view.find might get translated to a memchr, which
 8708|       |          // has no notion of std::string_view::npos, so the code does not
 8709|       |          // reflect the assembly.
 8710|     69|          location = view_size;
 8711|     69|          break;
 8712|     69|        }
 8713|  1.68k|      } else {
 8714|    747|        found_colon = view[location] == ':';
 8715|    747|        break;
 8716|    747|      }
 8717|  2.42k|    }
 8718|  1.89k|  }
 8719|       |  // performance: remove_suffix may translate into a single instruction.
 8720|  31.7k|  view.remove_suffix(view_size - location);
 8721|  31.7k|  return {location, found_colon};
 8722|  31.7k|}
_ZN3ada7helpers32find_next_host_delimiter_specialENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEm:
 8222|  33.2k|    std::string_view view, size_t location) noexcept {
 8223|       |  // first check for short strings in which case we do it naively.
 8224|  33.2k|  if (view.size() - location < 16) {  // slow path
  ------------------
  |  Branch (8224:7): [True: 22.6k, False: 10.6k]
  ------------------
 8225|   122k|    for (size_t i = location; i < view.size(); i++) {
  ------------------
  |  Branch (8225:31): [True: 111k, False: 11.2k]
  ------------------
 8226|   111k|      if (view[i] == ':' || view[i] == '/' || view[i] == '\\' ||
  ------------------
  |  Branch (8226:11): [True: 3.29k, False: 107k]
  |  Branch (8226:29): [True: 5.93k, False: 101k]
  |  Branch (8226:47): [True: 33, False: 101k]
  ------------------
 8227|   101k|          view[i] == '?' || view[i] == '[') {
  ------------------
  |  Branch (8227:11): [True: 380, False: 101k]
  |  Branch (8227:29): [True: 1.72k, False: 99.7k]
  ------------------
 8228|  11.3k|        return i;
 8229|  11.3k|      }
 8230|   111k|    }
 8231|  11.2k|    return size_t(view.size());
 8232|  22.6k|  }
 8233|       |  // fast path for long strings (expected to be common)
 8234|  10.6k|  size_t i = location;
 8235|  10.6k|  const __m128i mask1 = _mm_set1_epi8(':');
 8236|  10.6k|  const __m128i mask2 = _mm_set1_epi8('/');
 8237|  10.6k|  const __m128i mask3 = _mm_set1_epi8('\\');
 8238|  10.6k|  const __m128i mask4 = _mm_set1_epi8('?');
 8239|  10.6k|  const __m128i mask5 = _mm_set1_epi8('[');
 8240|       |
 8241|  46.5k|  for (; i + 15 < view.size(); i += 16) {
  ------------------
  |  Branch (8241:10): [True: 40.0k, False: 6.51k]
  ------------------
 8242|  40.0k|    __m128i word = _mm_loadu_si128((const __m128i*)(view.data() + i));
 8243|  40.0k|    __m128i m1 = _mm_cmpeq_epi8(word, mask1);
 8244|  40.0k|    __m128i m2 = _mm_cmpeq_epi8(word, mask2);
 8245|  40.0k|    __m128i m3 = _mm_cmpeq_epi8(word, mask3);
 8246|  40.0k|    __m128i m4 = _mm_cmpeq_epi8(word, mask4);
 8247|  40.0k|    __m128i m5 = _mm_cmpeq_epi8(word, mask5);
 8248|  40.0k|    __m128i m = _mm_or_si128(
 8249|  40.0k|        _mm_or_si128(_mm_or_si128(m1, m2), _mm_or_si128(m3, m4)), m5);
 8250|  40.0k|    int mask = _mm_movemask_epi8(m);
 8251|  40.0k|    if (mask != 0) {
  ------------------
  |  Branch (8251:9): [True: 4.08k, False: 35.9k]
  ------------------
 8252|  4.08k|      return i + trailing_zeroes(mask);
 8253|  4.08k|    }
 8254|  40.0k|  }
 8255|  6.51k|  if (i < view.size()) {
  ------------------
  |  Branch (8255:7): [True: 6.06k, False: 457]
  ------------------
 8256|  6.06k|    __m128i word =
 8257|  6.06k|        _mm_loadu_si128((const __m128i*)(view.data() + view.length() - 16));
 8258|  6.06k|    __m128i m1 = _mm_cmpeq_epi8(word, mask1);
 8259|  6.06k|    __m128i m2 = _mm_cmpeq_epi8(word, mask2);
 8260|  6.06k|    __m128i m3 = _mm_cmpeq_epi8(word, mask3);
 8261|  6.06k|    __m128i m4 = _mm_cmpeq_epi8(word, mask4);
 8262|  6.06k|    __m128i m5 = _mm_cmpeq_epi8(word, mask5);
 8263|  6.06k|    __m128i m = _mm_or_si128(
 8264|  6.06k|        _mm_or_si128(_mm_or_si128(m1, m2), _mm_or_si128(m3, m4)), m5);
 8265|  6.06k|    int mask = _mm_movemask_epi8(m);
 8266|  6.06k|    if (mask != 0) {
  ------------------
  |  Branch (8266:9): [True: 2.48k, False: 3.57k]
  ------------------
 8267|  2.48k|      return view.length() - 16 + trailing_zeroes(mask);
 8268|  2.48k|    }
 8269|  6.06k|  }
 8270|  4.03k|  return size_t(view.length());
 8271|  6.51k|}
_ZN3ada7helpers15trailing_zeroesEj:
 8075|  8.00k|ada_really_inline int trailing_zeroes(uint32_t input_num) noexcept {
 8076|       |#ifdef ADA_REGULAR_VISUAL_STUDIO
 8077|       |  unsigned long ret;
 8078|       |  // Search the mask data from least significant bit (LSB)
 8079|       |  // to the most significant bit (MSB) for a set bit (1).
 8080|       |  _BitScanForward(&ret, input_num);
 8081|       |  return (int)ret;
 8082|       |#else   // ADA_REGULAR_VISUAL_STUDIO
 8083|  8.00k|  return __builtin_ctzl(input_num);
 8084|  8.00k|#endif  // ADA_REGULAR_VISUAL_STUDIO
 8085|  8.00k|}
_ZN3ada7helpers24find_next_host_delimiterENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEm:
 8511|  3.50k|                                                  size_t location) noexcept {
 8512|       |  // first check for short strings in which case we do it naively.
 8513|  3.50k|  if (view.size() - location < 16) {  // slow path
  ------------------
  |  Branch (8513:7): [True: 1.71k, False: 1.79k]
  ------------------
 8514|  4.79k|    for (size_t i = location; i < view.size(); i++) {
  ------------------
  |  Branch (8514:31): [True: 4.06k, False: 726]
  ------------------
 8515|  4.06k|      if (view[i] == ':' || view[i] == '/' || view[i] == '?' ||
  ------------------
  |  Branch (8515:11): [True: 252, False: 3.81k]
  |  Branch (8515:29): [True: 135, False: 3.67k]
  |  Branch (8515:47): [True: 108, False: 3.57k]
  ------------------
 8516|  3.57k|          view[i] == '[') {
  ------------------
  |  Branch (8516:11): [True: 495, False: 3.07k]
  ------------------
 8517|    990|        return i;
 8518|    990|      }
 8519|  4.06k|    }
 8520|    726|    return size_t(view.size());
 8521|  1.71k|  }
 8522|       |  // fast path for long strings (expected to be common)
 8523|  1.79k|  size_t i = location;
 8524|  1.79k|  const __m128i mask1 = _mm_set1_epi8(':');
 8525|  1.79k|  const __m128i mask2 = _mm_set1_epi8('/');
 8526|  1.79k|  const __m128i mask4 = _mm_set1_epi8('?');
 8527|  1.79k|  const __m128i mask5 = _mm_set1_epi8('[');
 8528|       |
 8529|  3.93k|  for (; i + 15 < view.size(); i += 16) {
  ------------------
  |  Branch (8529:10): [True: 3.47k, False: 465]
  ------------------
 8530|  3.47k|    __m128i word = _mm_loadu_si128((const __m128i*)(view.data() + i));
 8531|  3.47k|    __m128i m1 = _mm_cmpeq_epi8(word, mask1);
 8532|  3.47k|    __m128i m2 = _mm_cmpeq_epi8(word, mask2);
 8533|  3.47k|    __m128i m4 = _mm_cmpeq_epi8(word, mask4);
 8534|  3.47k|    __m128i m5 = _mm_cmpeq_epi8(word, mask5);
 8535|  3.47k|    __m128i m = _mm_or_si128(_mm_or_si128(m1, m2), _mm_or_si128(m4, m5));
 8536|  3.47k|    int mask = _mm_movemask_epi8(m);
 8537|  3.47k|    if (mask != 0) {
  ------------------
  |  Branch (8537:9): [True: 1.32k, False: 2.14k]
  ------------------
 8538|  1.32k|      return i + trailing_zeroes(mask);
 8539|  1.32k|    }
 8540|  3.47k|  }
 8541|    465|  if (i < view.size()) {
  ------------------
  |  Branch (8541:7): [True: 333, False: 132]
  ------------------
 8542|    333|    __m128i word =
 8543|    333|        _mm_loadu_si128((const __m128i*)(view.data() + view.length() - 16));
 8544|    333|    __m128i m1 = _mm_cmpeq_epi8(word, mask1);
 8545|    333|    __m128i m2 = _mm_cmpeq_epi8(word, mask2);
 8546|    333|    __m128i m4 = _mm_cmpeq_epi8(word, mask4);
 8547|    333|    __m128i m5 = _mm_cmpeq_epi8(word, mask5);
 8548|    333|    __m128i m = _mm_or_si128(_mm_or_si128(m1, m2), _mm_or_si128(m4, m5));
 8549|    333|    int mask = _mm_movemask_epi8(m);
 8550|    333|    if (mask != 0) {
  ------------------
  |  Branch (8550:9): [True: 111, False: 222]
  ------------------
 8551|    111|      return view.length() - 16 + trailing_zeroes(mask);
 8552|    111|    }
 8553|    333|  }
 8554|    354|  return size_t(view.length());
 8555|    465|}
_ZN3ada3url10parse_hostENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9490|  12.1k|ada_really_inline bool url::parse_host(std::string_view input) {
 9491|  12.1k|  ada_log("parse_host ", input, " [", input.size(), " bytes]");
 9492|  12.1k|  if (input.empty()) {
  ------------------
  |  Branch (9492:7): [True: 17, False: 12.1k]
  ------------------
 9493|     17|    return is_valid = false;
 9494|     17|  }  // technically unnecessary.
 9495|       |  // If input starts with U+005B ([), then:
 9496|  12.1k|  if (input[0] == '[') {
  ------------------
  |  Branch (9496:7): [True: 743, False: 11.3k]
  ------------------
 9497|       |    // If input does not end with U+005D (]), validation error, return failure.
 9498|    743|    if (input.back() != ']') {
  ------------------
  |  Branch (9498:9): [True: 170, False: 573]
  ------------------
 9499|    170|      return is_valid = false;
 9500|    170|    }
 9501|    573|    ada_log("parse_host ipv6");
 9502|       |
 9503|       |    // Return the result of IPv6 parsing input with its leading U+005B ([) and
 9504|       |    // trailing U+005D (]) removed.
 9505|    573|    input.remove_prefix(1);
 9506|    573|    input.remove_suffix(1);
 9507|    573|    return parse_ipv6(input);
 9508|    743|  }
 9509|       |
 9510|       |  // If isNotSpecial is true, then return the result of opaque-host parsing
 9511|       |  // input.
 9512|  11.3k|  if (!is_special()) {
  ------------------
  |  Branch (9512:7): [True: 411, False: 10.9k]
  ------------------
 9513|    411|    return parse_opaque_host(input);
 9514|    411|  }
 9515|       |
 9516|       |  // Fast path: try to parse as pure decimal IPv4(a.b.c.d) first.
 9517|  10.9k|  const uint64_t fast_result = checkers::try_parse_ipv4_fast(input);
 9518|  10.9k|  if (fast_result < checkers::ipv4_fast_fail) {
  ------------------
  |  Branch (9518:7): [True: 744, False: 10.2k]
  ------------------
 9519|       |    // Fast path succeeded - input is pure decimal IPv4
 9520|    744|    if (!input.empty() && input.back() == '.') {
  ------------------
  |  Branch (9520:9): [True: 744, False: 0]
  |  Branch (9520:27): [True: 23, False: 721]
  ------------------
 9521|     23|      host = input.substr(0, input.size() - 1);
 9522|    721|    } else {
 9523|    721|      host = input;
 9524|    721|    }
 9525|    744|    host_type = IPV4;
 9526|    744|    is_valid = true;
 9527|    744|    ada_log("parse_host fast path decimal ipv4");
 9528|    744|    return true;
 9529|    744|  }
 9530|       |  // Let domain be the result of running UTF-8 decode without BOM on the
 9531|       |  // percent-decoding of input. Let asciiDomain be the result of running domain
 9532|       |  // to ASCII with domain and false. The most common case is an ASCII input, in
 9533|       |  // which case we do not need to call the expensive 'to_ascii' if a few
 9534|       |  // conditions are met: no '%' and no 'xn-' subsequence.
 9535|  10.2k|  std::string buffer = std::string(input);
 9536|       |  // This next function checks that the result is ascii, but we are going to
 9537|       |  // to check anyhow with is_forbidden.
 9538|       |  // bool is_ascii =
 9539|  10.2k|  unicode::to_lower_ascii(buffer.data(), buffer.size());
 9540|  10.2k|  bool is_forbidden = unicode::contains_forbidden_domain_code_point(
 9541|  10.2k|      buffer.data(), buffer.size());
 9542|  10.2k|  static constexpr std::string_view xn_dash{"xn-", 3};
 9543|  10.2k|  if (is_forbidden == 0 && buffer.find(xn_dash) == std::string_view::npos) {
  ------------------
  |  Branch (9543:7): [True: 6.14k, False: 4.06k]
  |  Branch (9543:28): [True: 4.48k, False: 1.65k]
  ------------------
 9544|       |    // fast path
 9545|  4.48k|    host = std::move(buffer);
 9546|       |
 9547|       |    // Check for other IPv4 formats (hex, octal, etc.)
 9548|  4.48k|    if (checkers::is_ipv4(host.value())) {
  ------------------
  |  Branch (9548:9): [True: 1.14k, False: 3.34k]
  ------------------
 9549|  1.14k|      ada_log("parse_host fast path ipv4");
 9550|  1.14k|      return parse_ipv4(host.value());
 9551|  1.14k|    }
 9552|  3.34k|    ada_log("parse_host fast path ", *host);
 9553|  3.34k|    is_valid = true;
 9554|  3.34k|    return true;
 9555|  4.48k|  }
 9556|  5.71k|  ada_log("parse_host calling to_ascii");
 9557|  5.71k|  is_valid = ada::unicode::to_ascii(host, input, input.find('%'));
 9558|  5.71k|  if (!is_valid || !host.has_value()) {
  ------------------
  |  Branch (9558:7): [True: 2.04k, False: 3.67k]
  |  Branch (9558:20): [True: 0, False: 3.67k]
  ------------------
 9559|  2.04k|    ada_log("parse_host to_ascii returns false");
 9560|  2.04k|    return is_valid = false;
 9561|  2.04k|  }
 9562|  3.67k|  ada_log("parse_host to_ascii succeeded ", *host, " [", host->size(),
 9563|  3.67k|          " bytes]");
 9564|       |
 9565|  3.67k|  if (std::any_of(host->begin(), host->end(),
  ------------------
  |  Branch (9565:7): [True: 0, False: 3.67k]
  ------------------
 9566|  3.67k|                  ada::unicode::is_forbidden_domain_code_point)) {
 9567|      0|    host = std::nullopt;
 9568|      0|    return is_valid = false;
 9569|      0|  }
 9570|       |
 9571|       |  // If asciiDomain ends in a number, then return the result of IPv4 parsing
 9572|       |  // asciiDomain.
 9573|  3.67k|  if (checkers::is_ipv4(*host)) {
  ------------------
  |  Branch (9573:7): [True: 143, False: 3.53k]
  ------------------
 9574|    143|    ada_log("parse_host got ipv4 ", *host);
 9575|    143|    return parse_ipv4(*host);
 9576|    143|  }
 9577|       |
 9578|  3.53k|  return true;
 9579|  3.67k|}
_ZN3ada7unicode30is_forbidden_domain_code_pointEc:
 6993|   982k|    const char c) noexcept {
 6994|   982k|  return is_forbidden_domain_code_point_table[uint8_t(c)];
 6995|   982k|}
_ZN3ada7helpers6resizeERNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEm:
 8068|     34|ada_really_inline void resize(std::string_view& input, size_t pos) noexcept {
 8069|     34|  ADA_ASSERT_TRUE(pos <= input.size());
 8070|     34|  input.remove_suffix(input.size() - pos);
 8071|     34|}
_ZN3ada7unicode14percent_encodeILb1EEEbNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEPKhRNS2_12basic_stringIcS5_NS2_9allocatorIcEEEE:
 7308|  1.56k|                    std::string& out) {
 7309|  1.56k|  ada_log("percent_encode ", input, " to output string while ",
 7310|  1.56k|          append ? "appending" : "overwriting");
 7311|  1.56k|  auto pointer = std::ranges::find_if(input, [character_set](const char c) {
 7312|  1.56k|    return character_sets::bit_at(character_set, c);
 7313|  1.56k|  });
 7314|  1.56k|  ada_log("percent_encode done checking, moved to ",
 7315|  1.56k|          std::distance(input.begin(), pointer));
 7316|       |
 7317|       |  // Optimization: Don't iterate if percent encode is not required
 7318|  1.56k|  if (pointer == input.end()) {
  ------------------
  |  Branch (7318:7): [True: 1.13k, False: 429]
  ------------------
 7319|  1.13k|    ada_log("percent_encode encoding not needed.");
 7320|  1.13k|    return false;
 7321|  1.13k|  }
 7322|       |  if constexpr (!append) {
 7323|       |    out.clear();
 7324|       |  }
 7325|    429|  ada_log("percent_encode appending ", std::distance(input.begin(), pointer),
 7326|    429|          " bytes");
 7327|       |  // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
 7328|    429|  out.append(input.data(), std::distance(input.begin(), pointer));
 7329|    429|  ada_log("percent_encode processing ", std::distance(pointer, input.end()),
 7330|    429|          " bytes");
 7331|  12.6k|  for (; pointer != input.end(); pointer++) {
  ------------------
  |  Branch (7331:10): [True: 12.2k, False: 429]
  ------------------
 7332|  12.2k|    if (character_sets::bit_at(character_set, *pointer)) {
  ------------------
  |  Branch (7332:9): [True: 11.0k, False: 1.15k]
  ------------------
 7333|  11.0k|      out.append(character_sets::hex + uint8_t(*pointer) * 4, 3);
 7334|  11.0k|    } else {
 7335|  1.15k|      out += *pointer;
 7336|  1.15k|    }
 7337|  12.2k|  }
 7338|    429|  return true;
 7339|  1.56k|}
_ZZN3ada7unicode14percent_encodeILb1EEEbNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEPKhRNS2_12basic_stringIcS5_NS2_9allocatorIcEEEEENKUlcE_clEc:
 7311|  10.7k|  auto pointer = std::ranges::find_if(input, [character_set](const char c) {
 7312|  10.7k|    return character_sets::bit_at(character_set, c);
 7313|  10.7k|  });
_ZN3ada7helpers12shorten_pathERNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEENS_6scheme4typeE:
 8030|    928|                                    ada::scheme::type type) {
 8031|       |  // Let path be url's path.
 8032|       |  // If url's scheme is "file", path's size is 1, and path[0] is a normalized
 8033|       |  // Windows drive letter, then return.
 8034|    928|  if (type == ada::scheme::type::FILE &&
  ------------------
  |  Branch (8034:7): [True: 248, False: 680]
  ------------------
 8035|    248|      path.find('/', 1) == std::string_view::npos && !path.empty()) {
  ------------------
  |  Branch (8035:7): [True: 210, False: 38]
  |  Branch (8035:54): [True: 86, False: 124]
  ------------------
 8036|     86|    if (checkers::is_normalized_windows_drive_letter(
  ------------------
  |  Branch (8036:9): [True: 4, False: 82]
  ------------------
 8037|     86|            helpers::substring(path, 1))) {
 8038|      4|      return false;
 8039|      4|    }
 8040|     86|  }
 8041|       |
 8042|       |  // Remove path's last item, if any.
 8043|    924|  if (!path.empty()) {
  ------------------
  |  Branch (8043:7): [True: 443, False: 481]
  ------------------
 8044|    443|    size_t slash_loc = path.rfind('/');
 8045|    443|    if (slash_loc != std::string_view::npos) {
  ------------------
  |  Branch (8045:9): [True: 399, False: 44]
  ------------------
 8046|    399|      path.remove_suffix(path.size() - slash_loc);
 8047|    399|      return true;
 8048|    399|    }
 8049|    443|  }
 8050|       |
 8051|    525|  return false;
 8052|    924|}
_ZN3ada14url_aggregator11copy_schemeERKS0_:
11552|  1.31k|inline void url_aggregator::copy_scheme(const url_aggregator& u) {
11553|  1.31k|  ada_log("url_aggregator::copy_scheme ", u.buffer);
11554|  1.31k|  ADA_ASSERT_TRUE(validate());
11555|       |  // next line could overflow but unsigned arithmetic has well-defined
11556|       |  // overflows.
11557|  1.31k|  uint32_t new_difference = u.components.protocol_end - components.protocol_end;
11558|       |
11559|  1.31k|  type = u.type;
11560|  1.31k|  buffer.erase(0, components.protocol_end);
11561|  1.31k|  buffer.insert(0, u.get_protocol());
11562|  1.31k|  components.protocol_end = u.components.protocol_end;
11563|       |
11564|       |  // No need to update the components
11565|  1.31k|  if (new_difference == 0) {
  ------------------
  |  Branch (11565:7): [True: 182, False: 1.13k]
  ------------------
11566|    182|    return;
11567|    182|  }
11568|       |
11569|  1.13k|  apply_shifted_non_scheme_offsets(components, new_difference);
11570|  1.13k|  ADA_ASSERT_TRUE(validate());
11571|  1.13k|}
can_parse.cc:_ZN12_GLOBAL__N_132apply_shifted_non_scheme_offsetsERN3ada14url_componentsEj:
11430|  35.1k|    ada::url_components& components, uint32_t new_difference) {
11431|  35.1k|  components.username_end += new_difference;
11432|  35.1k|  components.host_start += new_difference;
11433|  35.1k|  components.host_end += new_difference;
11434|  35.1k|  components.pathname_start += new_difference;
11435|  35.1k|  if (components.search_start != ada::url_components::omitted) {
  ------------------
  |  Branch (11435:7): [True: 0, False: 35.1k]
  ------------------
11436|      0|    components.search_start += new_difference;
11437|      0|  }
11438|  35.1k|  if (components.hash_start != ada::url_components::omitted) {
  ------------------
  |  Branch (11438:7): [True: 0, False: 35.1k]
  ------------------
11439|      0|    components.hash_start += new_difference;
11440|      0|  }
11441|  35.1k|}
_ZN3ada14url_aggregator10parse_hostENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
11890|  23.4k|ada_really_inline bool url_aggregator::parse_host(std::string_view input) {
11891|  23.4k|  ada_log("url_aggregator:parse_host \"", input, "\" [", input.size(),
11892|  23.4k|          " bytes]");
11893|  23.4k|  ADA_ASSERT_TRUE(validate());
11894|  23.4k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
11895|  23.4k|  if (input.empty()) {
  ------------------
  |  Branch (11895:7): [True: 24, False: 23.3k]
  ------------------
11896|     24|    return is_valid = false;
11897|     24|  }  // technically unnecessary.
11898|       |  // If input starts with U+005B ([), then:
11899|  23.3k|  if (input[0] == '[') {
  ------------------
  |  Branch (11899:7): [True: 1.48k, False: 21.9k]
  ------------------
11900|       |    // If input does not end with U+005D (]), validation error, return failure.
11901|  1.48k|    if (input.back() != ']') {
  ------------------
  |  Branch (11901:9): [True: 340, False: 1.14k]
  ------------------
11902|    340|      return is_valid = false;
11903|    340|    }
11904|  1.14k|    ada_log("parse_host ipv6");
11905|       |
11906|       |    // Return the result of IPv6 parsing input with its leading U+005B ([) and
11907|       |    // trailing U+005D (]) removed.
11908|  1.14k|    input.remove_prefix(1);
11909|  1.14k|    input.remove_suffix(1);
11910|  1.14k|    return parse_ipv6(input);
11911|  1.48k|  }
11912|       |
11913|       |  // If isNotSpecial is true, then return the result of opaque-host parsing
11914|       |  // input.
11915|  21.9k|  if (!is_special()) {
  ------------------
  |  Branch (11915:7): [True: 822, False: 21.0k]
  ------------------
11916|    822|    return parse_opaque_host(input);
11917|    822|  }
11918|       |  // Let domain be the result of running UTF-8 decode without BOM on the
11919|       |  // percent-decoding of input. Let asciiDomain be the result of running domain
11920|       |  // to ASCII with domain and false. The most common case is an ASCII input, in
11921|       |  // which case we do not need to call the expensive 'to_ascii' if a few
11922|       |  // conditions are met: no '%' and no 'xn-' subsequence.
11923|       |
11924|       |  // Often, the input does not contain any forbidden code points, and no upper
11925|       |  // case ASCII letter, then we can just copy it to the buffer. We want to
11926|       |  // optimize for such a common case.
11927|       |
11928|       |  // Fast path: try to parse as pure decimal IPv4(a.b.c.d) first.
11929|  21.0k|  const uint64_t fast_result = checkers::try_parse_ipv4_fast(input);
11930|  21.0k|  if (fast_result < checkers::ipv4_fast_fail) {
  ------------------
  |  Branch (11930:7): [True: 985, False: 20.1k]
  ------------------
11931|       |    // Fast path succeeded - input is pure decimal IPv4
11932|    985|    if (!input.empty() && input.back() == '.') {
  ------------------
  |  Branch (11932:9): [True: 985, False: 0]
  |  Branch (11932:27): [True: 45, False: 940]
  ------------------
11933|     45|      update_base_hostname(input.substr(0, input.size() - 1));
11934|    940|    } else {
11935|    940|      update_base_hostname(input);
11936|    940|    }
11937|    985|    host_type = IPV4;
11938|    985|    is_valid = true;
11939|    985|    ada_log("parse_host fast path decimal ipv4");
11940|    985|    ADA_ASSERT_TRUE(validate());
11941|    985|    return true;
11942|    985|  }
11943|  20.1k|  uint8_t is_forbidden_or_upper =
11944|  20.1k|      unicode::contains_forbidden_domain_code_point_or_upper(input.data(),
11945|  20.1k|                                                             input.size());
11946|       |  // Minor optimization opportunity:
11947|       |  // contains_forbidden_domain_code_point_or_upper could be extend to check for
11948|       |  // the presence of characters that cannot appear in the ipv4 address and we
11949|       |  // could also check whether x and n and - are present, and so we could skip
11950|       |  // some of the checks below. However, the gains are likely to be small, and
11951|       |  // the code would be more complex.
11952|  20.1k|  static constexpr std::string_view xn_dash{"xn-", 3};
11953|  20.1k|  if (is_forbidden_or_upper == 0 &&
  ------------------
  |  Branch (11953:7): [True: 10.3k, False: 9.75k]
  ------------------
11954|  10.3k|      input.find(xn_dash) == std::string_view::npos) {
  ------------------
  |  Branch (11954:7): [True: 7.26k, False: 3.08k]
  ------------------
11955|       |    // fast path
11956|  7.26k|    update_base_hostname(input);
11957|       |
11958|       |    // Check for other IPv4 formats (hex, octal, etc.)
11959|  7.26k|    if (checkers::is_ipv4(get_hostname())) {
  ------------------
  |  Branch (11959:9): [True: 2.03k, False: 5.22k]
  ------------------
11960|  2.03k|      ada_log("parse_host fast path ipv4");
11961|  2.03k|      return parse_ipv4(get_hostname(), true);
11962|  2.03k|    }
11963|  5.22k|    ada_log("parse_host fast path ", get_hostname());
11964|  5.22k|    is_valid = true;
11965|  5.22k|    return true;
11966|  7.26k|  }
11967|       |  // We have encountered at least one forbidden code point or the input contains
11968|       |  // 'xn-' (case insensitive), so we need to call 'to_ascii' to perform the full
11969|       |  // conversion.
11970|       |
11971|  12.8k|  ada_log("parse_host calling to_ascii");
11972|  12.8k|  std::optional<std::string> host = std::string(get_hostname());
11973|  12.8k|  is_valid = ada::unicode::to_ascii(host, input, input.find('%'));
11974|  12.8k|  if (!is_valid) {
  ------------------
  |  Branch (11974:7): [True: 4.08k, False: 8.76k]
  ------------------
11975|  4.08k|    ada_log("parse_host to_ascii returns false");
11976|  4.08k|    return is_valid = false;
11977|  4.08k|  }
11978|  8.76k|  ada_log("parse_host to_ascii succeeded ", *host, " [", host->size(),
11979|  8.76k|          " bytes]");
11980|       |
11981|  8.76k|  if (std::ranges::any_of(host.value(),
  ------------------
  |  Branch (11981:7): [True: 0, False: 8.76k]
  ------------------
11982|  8.76k|                          ada::unicode::is_forbidden_domain_code_point)) {
11983|      0|    return is_valid = false;
11984|      0|  }
11985|       |
11986|       |  // If asciiDomain ends in a number, then return the result of IPv4 parsing
11987|       |  // asciiDomain.
11988|  8.76k|  if (checkers::is_ipv4(host.value())) {
  ------------------
  |  Branch (11988:7): [True: 534, False: 8.22k]
  ------------------
11989|    534|    ada_log("parse_host got ipv4 ", *host);
11990|    534|    return parse_ipv4(host.value(), false);
11991|    534|  }
11992|       |
11993|  8.22k|  update_base_hostname(host.value());
11994|  8.22k|  ADA_ASSERT_TRUE(validate());
11995|  8.22k|  return true;
11996|  8.76k|}
_ZN3ada7unicode45contains_forbidden_domain_code_point_or_upperEPKcm:
 7034|  20.1k|                                              size_t length) noexcept {
 7035|  20.1k|  size_t i = 0;
 7036|  20.1k|  uint8_t accumulator{};
 7037|   158k|  for (; i + 4 <= length; i += 4) {
  ------------------
  |  Branch (7037:10): [True: 138k, False: 20.1k]
  ------------------
 7038|   138k|    accumulator |=
 7039|   138k|        is_forbidden_domain_code_point_table_or_upper[uint8_t(input[i])];
 7040|   138k|    accumulator |=
 7041|   138k|        is_forbidden_domain_code_point_table_or_upper[uint8_t(input[i + 1])];
 7042|   138k|    accumulator |=
 7043|   138k|        is_forbidden_domain_code_point_table_or_upper[uint8_t(input[i + 2])];
 7044|   138k|    accumulator |=
 7045|   138k|        is_forbidden_domain_code_point_table_or_upper[uint8_t(input[i + 3])];
 7046|   138k|  }
 7047|  50.0k|  for (; i < length; i++) {
  ------------------
  |  Branch (7047:10): [True: 29.9k, False: 20.1k]
  ------------------
 7048|  29.9k|    accumulator |=
 7049|  29.9k|        is_forbidden_domain_code_point_table_or_upper[uint8_t(input[i])];
 7050|  29.9k|  }
 7051|  20.1k|  return accumulator;
 7052|  20.1k|}
_ZN3ada7helpers9substringENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEm:
 8061|  1.89k|                                                       size_t pos) {
 8062|  1.89k|  ADA_ASSERT_TRUE(pos <= input.size());
 8063|       |  // The following is safer but unneeded if we have the above line:
 8064|       |  // return pos > input.size() ? std::string_view() : input.substr(pos);
 8065|  1.89k|  return input.substr(pos);
 8066|  1.89k|}
_ZN3ada14url_aggregator21consume_prepared_pathENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
12803|  7.36k|inline void url_aggregator::consume_prepared_path(std::string_view input) {
12804|  7.36k|  ada_log("url_aggregator::consume_prepared_path ", input);
12805|       |  /***
12806|       |   * This is largely duplicated code from helpers::parse_prepared_path, which is
12807|       |   * unfortunate. This particular function is nearly identical, except that it
12808|       |   * is a method on url_aggregator. The idea is that the trivial path (which is
12809|       |   * very common) merely appends to the buffer. This is the same trivial path as
12810|       |   * with helpers::parse_prepared_path, except that we have the additional check
12811|       |   * for is_at_path(). Otherwise, we grab a copy of the current path and we
12812|       |   * modify it, and then insert it back into the buffer.
12813|       |   */
12814|  7.36k|  uint8_t accumulator = checkers::path_signature(input);
12815|       |  // Let us first detect a trivial case.
12816|       |  // If it is special, we check that we have no dot, no %,  no \ and no
12817|       |  // character needing percent encoding. Otherwise, we check that we have no %,
12818|       |  // no dot, and no character needing percent encoding.
12819|  7.36k|  constexpr uint8_t need_encoding = 1;
12820|  7.36k|  constexpr uint8_t backslash_char = 2;
12821|  7.36k|  constexpr uint8_t dot_char = 4;
12822|  7.36k|  constexpr uint8_t percent_char = 8;
12823|  7.36k|  bool special = type != ada::scheme::NOT_SPECIAL;
12824|  7.36k|  bool may_need_slow_file_handling = (type == ada::scheme::type::FILE &&
  ------------------
  |  Branch (12824:39): [True: 1.73k, False: 5.63k]
  ------------------
12825|  1.73k|                                      checkers::is_windows_drive_letter(input));
  ------------------
  |  Branch (12825:39): [True: 134, False: 1.59k]
  ------------------
12826|  7.36k|  bool trivial_path =
12827|  7.36k|      (special ? (accumulator == 0)
  ------------------
  |  Branch (12827:7): [True: 4.51k, False: 2.84k]
  |  Branch (12827:8): [True: 5.93k, False: 1.42k]
  ------------------
12828|  7.36k|               : ((accumulator & (need_encoding | dot_char | percent_char)) ==
12829|  1.42k|                  0)) &&
12830|  4.51k|      (!may_need_slow_file_handling);
  ------------------
  |  Branch (12830:7): [True: 4.42k, False: 96]
  ------------------
12831|  7.36k|  if (accumulator == dot_char && !may_need_slow_file_handling) {
  ------------------
  |  Branch (12831:7): [True: 975, False: 6.38k]
  |  Branch (12831:34): [True: 952, False: 23]
  ------------------
12832|       |    // '4' means that we have at least one dot, but nothing that requires
12833|       |    // percent encoding or decoding. The only part that is not trivial is
12834|       |    // that we may have single dots and double dots path segments.
12835|       |    // If we have such segments, then we either have a path that begins
12836|       |    // with '.' (easy to check), or we have the sequence './'.
12837|       |    // Note: input cannot be empty, it must at least contain one character ('.')
12838|       |    // Note: we know that '\' is not present.
12839|    952|    if (input[0] != '.') {
  ------------------
  |  Branch (12839:9): [True: 436, False: 516]
  ------------------
12840|    436|      size_t slashdot = 0;
12841|    436|      bool dot_is_file = true;
12842|  1.90k|      for (;;) {
12843|  1.90k|        slashdot = input.find("/.", slashdot);
12844|  1.90k|        if (slashdot == std::string_view::npos) {  // common case
  ------------------
  |  Branch (12844:13): [True: 436, False: 1.47k]
  ------------------
12845|    436|          break;
12846|  1.47k|        } else {  // uncommon
12847|       |          // only three cases matter: /./, /.. or a final /
12848|  1.47k|          slashdot += 2;
12849|  1.47k|          dot_is_file &= !(slashdot == input.size() || input[slashdot] == '.' ||
  ------------------
  |  Branch (12849:28): [True: 60, False: 1.41k]
  |  Branch (12849:56): [True: 1.05k, False: 361]
  ------------------
12850|    361|                           input[slashdot] == '/');
  ------------------
  |  Branch (12850:28): [True: 232, False: 129]
  ------------------
12851|  1.47k|        }
12852|  1.90k|      }
12853|    436|      trivial_path = dot_is_file;
12854|    436|    }
12855|    952|  }
12856|  7.36k|  if (trivial_path && is_at_path()) {
  ------------------
  |  Branch (12856:7): [True: 4.55k, False: 2.80k]
  |  Branch (12856:23): [True: 4.44k, False: 114]
  ------------------
12857|  4.44k|    ada_log("parse_path trivial");
12858|  4.44k|    buffer += '/';
12859|  4.44k|    buffer += input;
12860|  4.44k|    return;
12861|  4.44k|  }
12862|  2.91k|  std::string path = std::string(get_pathname());
12863|       |  // We are going to need to look a bit at the path, but let us see if we can
12864|       |  // ignore percent encoding *and* backslashes *and* percent characters.
12865|       |  // Except for the trivial case, this is likely to capture 99% of paths out
12866|       |  // there.
12867|  2.91k|  bool fast_path =
12868|  2.91k|      (special &&
  ------------------
  |  Branch (12868:8): [True: 1.87k, False: 1.04k]
  ------------------
12869|  1.87k|       (accumulator & (need_encoding | backslash_char | percent_char)) == 0) &&
  ------------------
  |  Branch (12869:8): [True: 848, False: 1.02k]
  ------------------
12870|    848|      (type != ada::scheme::type::FILE);
  ------------------
  |  Branch (12870:7): [True: 646, False: 202]
  ------------------
12871|  2.91k|  if (fast_path) {
  ------------------
  |  Branch (12871:7): [True: 646, False: 2.27k]
  ------------------
12872|    646|    ada_log("parse_prepared_path fast");
12873|       |    // Here we don't need to worry about \ or percent encoding.
12874|       |    // We also do not have a file protocol. We might have dots, however,
12875|       |    // but dots must as appear as '.', and they cannot be encoded because
12876|       |    // the symbol '%' is not present.
12877|    646|    size_t previous_location = 0;  // We start at 0.
12878|  7.16k|    do {
12879|  7.16k|      size_t new_location = input.find('/', previous_location);
12880|       |      // std::string_view path_view = input;
12881|       |      //  We process the last segment separately:
12882|  7.16k|      if (new_location == std::string_view::npos) {
  ------------------
  |  Branch (12882:11): [True: 646, False: 6.52k]
  ------------------
12883|    646|        std::string_view path_view = input.substr(previous_location);
12884|    646|        if (path_view == "..") {  // The path ends with ..
  ------------------
  |  Branch (12884:13): [True: 60, False: 586]
  ------------------
12885|       |          // e.g., if you receive ".." with an empty path, you go to "/".
12886|     60|          if (path.empty()) {
  ------------------
  |  Branch (12886:15): [True: 18, False: 42]
  ------------------
12887|     18|            path = '/';
12888|     18|            update_base_pathname(path);
12889|     18|            return;
12890|     18|          }
12891|       |          // Fast case where we have nothing to do:
12892|     42|          if (path.back() == '/') {
  ------------------
  |  Branch (12892:15): [True: 17, False: 25]
  ------------------
12893|     17|            update_base_pathname(path);
12894|     17|            return;
12895|     17|          }
12896|       |          // If you have the path "/joe/myfriend",
12897|       |          // then you delete 'myfriend'.
12898|     25|          path.resize(path.rfind('/') + 1);
12899|     25|          update_base_pathname(path);
12900|     25|          return;
12901|     42|        }
12902|    586|        path += '/';
12903|    586|        if (path_view != ".") {
  ------------------
  |  Branch (12903:13): [True: 524, False: 62]
  ------------------
12904|    524|          path.append(path_view);
12905|    524|        }
12906|    586|        update_base_pathname(path);
12907|    586|        return;
12908|  6.52k|      } else {
12909|       |        // This is a non-final segment.
12910|  6.52k|        std::string_view path_view =
12911|  6.52k|            input.substr(previous_location, new_location - previous_location);
12912|  6.52k|        previous_location = new_location + 1;
12913|  6.52k|        if (path_view == "..") {
  ------------------
  |  Branch (12913:13): [True: 994, False: 5.52k]
  ------------------
12914|    994|          size_t last_delimiter = path.rfind('/');
12915|    994|          if (last_delimiter != std::string::npos) {
  ------------------
  |  Branch (12915:15): [True: 548, False: 446]
  ------------------
12916|    548|            path.erase(last_delimiter);
12917|    548|          }
12918|  5.52k|        } else if (path_view != ".") {
  ------------------
  |  Branch (12918:20): [True: 5.21k, False: 312]
  ------------------
12919|  5.21k|          path += '/';
12920|  5.21k|          path.append(path_view);
12921|  5.21k|        }
12922|  6.52k|      }
12923|  7.16k|    } while (true);
  ------------------
  |  Branch (12923:14): [True: 6.52k, Folded]
  ------------------
12924|  2.27k|  } else {
12925|  2.27k|    ada_log("parse_path slow");
12926|       |    // we have reached the general case
12927|  2.27k|    bool needs_percent_encoding = (accumulator & 1);
12928|  2.27k|    std::string path_buffer_tmp;
12929|  12.9k|    do {
12930|  12.9k|      size_t location = (special && (accumulator & 2))
  ------------------
  |  Branch (12930:26): [True: 7.67k, False: 5.26k]
  |  Branch (12930:37): [True: 393, False: 7.28k]
  ------------------
12931|  12.9k|                            ? input.find_first_of("/\\")
12932|  12.9k|                            : input.find('/');
12933|  12.9k|      std::string_view path_view = input;
12934|  12.9k|      if (location != std::string_view::npos) {
  ------------------
  |  Branch (12934:11): [True: 10.6k, False: 2.27k]
  ------------------
12935|  10.6k|        path_view.remove_suffix(path_view.size() - location);
12936|  10.6k|        input.remove_prefix(location + 1);
12937|  10.6k|      }
12938|       |      // path_buffer is either path_view or it might point at a percent encoded
12939|       |      // temporary string.
12940|  12.9k|      std::string_view path_buffer =
12941|  12.9k|          (needs_percent_encoding &&
  ------------------
  |  Branch (12941:12): [True: 7.57k, False: 5.36k]
  ------------------
12942|  7.57k|           ada::unicode::percent_encode<false>(
  ------------------
  |  Branch (12942:12): [True: 2.98k, False: 4.59k]
  ------------------
12943|  7.57k|               path_view, character_sets::PATH_PERCENT_ENCODE, path_buffer_tmp))
12944|  12.9k|              ? path_buffer_tmp
12945|  12.9k|              : path_view;
12946|  12.9k|      if (unicode::is_double_dot_path_segment(path_buffer)) {
  ------------------
  |  Branch (12946:11): [True: 2.67k, False: 10.2k]
  ------------------
12947|  2.67k|        helpers::shorten_path(path, type);
12948|  2.67k|        if (location == std::string_view::npos) {
  ------------------
  |  Branch (12948:13): [True: 198, False: 2.47k]
  ------------------
12949|    198|          path += '/';
12950|    198|        }
12951|  10.2k|      } else if (unicode::is_single_dot_path_segment(path_buffer) &&
  ------------------
  |  Branch (12951:18): [True: 634, False: 9.63k]
  ------------------
12952|    634|                 (location == std::string_view::npos)) {
  ------------------
  |  Branch (12952:18): [True: 95, False: 539]
  ------------------
12953|     95|        path += '/';
12954|     95|      }
12955|       |      // Otherwise, if path_buffer is not a single-dot path segment, then:
12956|  10.1k|      else if (!unicode::is_single_dot_path_segment(path_buffer)) {
  ------------------
  |  Branch (12956:16): [True: 9.63k, False: 539]
  ------------------
12957|       |        // If url's scheme is "file", url's path is empty, and path_buffer is a
12958|       |        // Windows drive letter, then replace the second code point in
12959|       |        // path_buffer with U+003A (:).
12960|  9.63k|        if (type == ada::scheme::type::FILE && path.empty() &&
  ------------------
  |  Branch (12960:13): [True: 2.64k, False: 6.98k]
  |  Branch (12960:48): [True: 1.23k, False: 1.41k]
  ------------------
12961|  1.23k|            checkers::is_windows_drive_letter(path_buffer)) {
  ------------------
  |  Branch (12961:13): [True: 159, False: 1.07k]
  ------------------
12962|    159|          path += '/';
12963|    159|          path += path_buffer[0];
12964|    159|          path += ':';
12965|    159|          path_buffer.remove_prefix(2);
12966|    159|          path.append(path_buffer);
12967|  9.47k|        } else {
12968|       |          // Append path_buffer to url's path.
12969|  9.47k|          path += '/';
12970|  9.47k|          path.append(path_buffer);
12971|  9.47k|        }
12972|  9.63k|      }
12973|  12.9k|      if (location == std::string_view::npos) {
  ------------------
  |  Branch (12973:11): [True: 2.27k, False: 10.6k]
  ------------------
12974|  2.27k|        update_base_pathname(path);
12975|  2.27k|        return;
12976|  2.27k|      }
12977|  12.9k|    } while (true);
  ------------------
  |  Branch (12977:14): [True: 10.6k, Folded]
  ------------------
12978|  2.27k|  }
12979|  2.91k|}
_ZN3ada7unicode14to_lower_asciiEPcm:
 6750|  39.1k|constexpr bool to_lower_ascii(char* input, size_t length) noexcept {
 6751|  39.1k|  uint64_t broadcast_80 = broadcast(0x80);
 6752|  39.1k|  uint64_t broadcast_Ap = broadcast(128 - 'A');
 6753|  39.1k|  uint64_t broadcast_Zp = broadcast(128 - 'Z' - 1);
 6754|  39.1k|  uint64_t non_ascii = 0;
 6755|  39.1k|  size_t i = 0;
 6756|       |
 6757|  74.4k|  for (; i + 7 < length; i += 8) {
  ------------------
  |  Branch (6757:10): [True: 35.3k, False: 39.1k]
  ------------------
 6758|  35.3k|    uint64_t word{};
 6759|  35.3k|    memcpy(&word, input + i, sizeof(word));
 6760|  35.3k|    non_ascii |= (word & broadcast_80);
 6761|  35.3k|    word ^=
 6762|  35.3k|        (((word + broadcast_Ap) ^ (word + broadcast_Zp)) & broadcast_80) >> 2;
 6763|  35.3k|    memcpy(input + i, &word, sizeof(word));
 6764|  35.3k|  }
 6765|  39.1k|  if (i < length) {
  ------------------
  |  Branch (6765:7): [True: 38.1k, False: 953]
  ------------------
 6766|  38.1k|    uint64_t word{};
 6767|  38.1k|    memcpy(&word, input + i, length - i);
 6768|  38.1k|    non_ascii |= (word & broadcast_80);
 6769|  38.1k|    word ^=
 6770|  38.1k|        (((word + broadcast_Ap) ^ (word + broadcast_Zp)) & broadcast_80) >> 2;
 6771|  38.1k|    memcpy(input + i, &word, length - i);
 6772|  38.1k|  }
 6773|  39.1k|  return non_ascii == 0;
 6774|  39.1k|}
_ZN3ada7unicode9broadcastEh:
 6746|   117k|constexpr uint64_t broadcast(uint8_t v) noexcept {
 6747|   117k|  return 0x101010101010101ull * v;
 6748|   117k|}
_ZN3ada8checkers7is_ipv4ENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
   12|  25.4k|ada_really_inline constexpr bool is_ipv4(std::string_view view) noexcept {
   13|       |  // The string is not empty and does not contain upper case ASCII characters.
   14|       |  //
   15|       |  // Optimization. To be considered as a possible ipv4, the string must end
   16|       |  // with 'x' or a lowercase hex character.
   17|       |  // Most of the time, this will be false so this simple check will save a lot
   18|       |  // of effort.
   19|       |  // If the address ends with a dot, we need to prune it (special case).
   20|  25.4k|  if (view.ends_with('.')) {
  ------------------
  |  Branch (20:7): [True: 2.48k, False: 22.9k]
  ------------------
   21|  2.48k|    view.remove_suffix(1);
   22|  2.48k|    if (view.empty()) {
  ------------------
  |  Branch (22:9): [True: 1.23k, False: 1.24k]
  ------------------
   23|  1.23k|      return false;
   24|  1.23k|    }
   25|  2.48k|  }
   26|  24.2k|  char last_char = view.back();
   27|  24.2k|  bool possible_ipv4 = (last_char >= '0' && last_char <= '9') ||
  ------------------
  |  Branch (27:25): [True: 21.7k, False: 2.49k]
  |  Branch (27:45): [True: 5.15k, False: 16.5k]
  ------------------
   28|  19.0k|                       (last_char >= 'a' && last_char <= 'f') ||
  ------------------
  |  Branch (28:25): [True: 16.2k, False: 2.77k]
  |  Branch (28:45): [True: 7.23k, False: 9.03k]
  ------------------
   29|  11.8k|                       last_char == 'x';
  ------------------
  |  Branch (29:24): [True: 2.00k, False: 9.80k]
  ------------------
   30|  24.2k|  if (!possible_ipv4) {
  ------------------
  |  Branch (30:7): [True: 9.80k, False: 14.3k]
  ------------------
   31|  9.80k|    return false;
   32|  9.80k|  }
   33|       |  // From the last character, find the last dot.
   34|  14.3k|  size_t last_dot = view.rfind('.');
   35|  14.3k|  if (last_dot != std::string_view::npos) {
  ------------------
  |  Branch (35:7): [True: 3.83k, False: 10.5k]
  ------------------
   36|       |    // We have at least one dot.
   37|  3.83k|    view.remove_prefix(last_dot + 1);
   38|  3.83k|  }
   39|       |  /** Optimization opportunity: we have basically identified the last number of
   40|       |     the ipv4 if we return true here. We might as well parse it and have at
   41|       |     least one number parsed when we get to parse_ipv4. */
   42|  14.3k|  if (std::ranges::all_of(view, ada::checkers::is_digit)) {
  ------------------
  |  Branch (42:7): [True: 3.13k, False: 11.2k]
  ------------------
   43|  3.13k|    return true;
   44|  3.13k|  }
   45|       |  // It could be hex (0x), but not if there is a single character.
   46|  11.2k|  if (view.size() == 1) {
  ------------------
  |  Branch (46:7): [True: 2.12k, False: 9.13k]
  ------------------
   47|  2.12k|    return false;
   48|  2.12k|  }
   49|       |  // It must start with 0x.
   50|  9.13k|  if (!view.starts_with("0x")) {
  ------------------
  |  Branch (50:7): [True: 6.84k, False: 2.28k]
  ------------------
   51|  6.84k|    return false;
   52|  6.84k|  }
   53|       |  // We must allow "0x".
   54|  2.28k|  if (view.size() == 2) {
  ------------------
  |  Branch (54:7): [True: 204, False: 2.08k]
  ------------------
   55|    204|    return true;
   56|    204|  }
   57|       |  // We have 0x followed by some characters, we need to check that they are
   58|       |  // hexadecimals.
   59|  2.08k|  view.remove_prefix(2);
   60|  2.08k|  return std::ranges::all_of(view, ada::unicode::is_lowercase_hex);
   61|  2.28k|}
_ZN3ada7unicode16is_lowercase_hexEc:
 7153|  15.4k|ada_really_inline constexpr bool is_lowercase_hex(const char c) noexcept {
 7154|  15.4k|  return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f');
  ------------------
  |  Branch (7154:11): [True: 15.0k, False: 408]
  |  Branch (7154:23): [True: 6.32k, False: 8.69k]
  |  Branch (7154:37): [True: 8.61k, False: 488]
  |  Branch (7154:49): [True: 7.55k, False: 1.05k]
  ------------------
 7155|  15.4k|}
_ZN3ada6parser25try_parse_simple_absoluteINS_3urlEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_:
10106|  31.0k|                                                result_type& out) {
10107|  31.0k|  constexpr bool is_ada_url = std::is_same_v<result_type, ada::url>;
10108|  31.0k|  constexpr bool is_aggregator =
10109|  31.0k|      std::is_same_v<result_type, ada::url_aggregator>;
10110|  31.0k|  static_assert(is_ada_url || is_aggregator);
10111|       |
10112|  31.0k|  const size_t len = input.size();
10113|  31.0k|  if (len < 8) [[unlikely]] {
  ------------------
  |  Branch (10113:7): [True: 20.1k, False: 10.8k]
  ------------------
10114|  20.1k|    return false;
10115|  20.1k|  }
10116|  10.8k|  const auto* b = reinterpret_cast<const uint8_t*>(input.data());
10117|       |
10118|  10.8k|  size_t pos;
10119|  10.8k|  ada::scheme::type scheme_type;
10120|  10.8k|  uint32_t protocol_end;
10121|  10.8k|  if (b[0] == 'h' && b[1] == 't' && b[2] == 't' && b[3] == 'p') {
  ------------------
  |  Branch (10121:7): [True: 930, False: 9.96k]
  |  Branch (10121:22): [True: 893, False: 37]
  |  Branch (10121:37): [True: 877, False: 16]
  |  Branch (10121:52): [True: 856, False: 21]
  ------------------
10122|    856|    if (b[4] == ':' && b[5] == '/' && b[6] == '/') {
  ------------------
  |  Branch (10122:9): [True: 653, False: 203]
  |  Branch (10122:24): [True: 558, False: 95]
  |  Branch (10122:39): [True: 544, False: 14]
  ------------------
10123|    544|      pos = 7;
10124|    544|      scheme_type = ada::scheme::type::HTTP;
10125|    544|      protocol_end = 5;
10126|    544|    } else if (len >= 8 && b[4] == 's' && b[5] == ':' && b[6] == '/' &&
  ------------------
  |  Branch (10126:16): [True: 312, False: 0]
  |  Branch (10126:28): [True: 183, False: 129]
  |  Branch (10126:43): [True: 171, False: 12]
  |  Branch (10126:58): [True: 137, False: 34]
  ------------------
10127|    137|               b[7] == '/') {
  ------------------
  |  Branch (10127:16): [True: 121, False: 16]
  ------------------
10128|    121|      pos = 8;
10129|    121|      scheme_type = ada::scheme::type::HTTPS;
10130|    121|      protocol_end = 6;
10131|    191|    } else {
10132|    191|      return false;
10133|    191|    }
10134|  10.0k|  } else {
10135|  10.0k|    return false;
10136|  10.0k|  }
10137|    665|  if (pos < len && (b[pos] == '/' || b[pos] == '\\')) [[unlikely]] {
  ------------------
  |  Branch (10137:7): [True: 662, False: 3]
  |  Branch (10137:21): [True: 3, False: 659]
  |  Branch (10137:38): [True: 3, False: 656]
  ------------------
10138|      6|    return false;
10139|      6|  }
10140|       |
10141|       |  // Digit-led hosts are IPv4/numeric; skip before scanning.
10142|    659|  if (pos < len && b[pos] >= '0' && b[pos] <= '9') {
  ------------------
  |  Branch (10142:7): [True: 656, False: 3]
  |  Branch (10142:20): [True: 410, False: 246]
  |  Branch (10142:37): [True: 0, False: 410]
  ------------------
10143|      0|    return false;
10144|      0|  }
10145|       |
10146|    659|  const size_t host_start = pos;
10147|    659|  bool has_upper = false;
10148|    659|  size_t i = pos;
10149|  8.67k|  for (; i < len; ++i) {
  ------------------
  |  Branch (10149:10): [True: 8.58k, False: 92]
  ------------------
10150|  8.58k|    const uint8_t c = b[i];
10151|  8.58k|    const uint8_t cls = k_host_class[c];
10152|  8.58k|    if (cls == 1) {
  ------------------
  |  Branch (10152:9): [True: 543, False: 8.03k]
  ------------------
10153|    543|      break;
10154|    543|    }
10155|  8.03k|    if (cls == 2) [[unlikely]] {
  ------------------
  |  Branch (10155:9): [True: 24, False: 8.01k]
  ------------------
10156|     24|      return false;
10157|     24|    }
10158|  8.01k|    if (c >= 'A' && c <= 'Z') {
  ------------------
  |  Branch (10158:9): [True: 5.29k, False: 2.72k]
  |  Branch (10158:21): [True: 693, False: 4.60k]
  ------------------
10159|    693|      has_upper = true;
10160|    693|    }
10161|  8.01k|  }
10162|    635|  const size_t host_end = i;
10163|    635|  if (host_start == host_end) [[unlikely]] {
  ------------------
  |  Branch (10163:7): [True: 4, False: 631]
  ------------------
10164|      4|    return false;
10165|      4|  }
10166|    631|  const size_t host_len = host_end - host_start;
10167|    631|  if (host_len > 253) [[unlikely]] {
  ------------------
  |  Branch (10167:7): [True: 5, False: 626]
  ------------------
10168|      5|    return false;
10169|      5|  }
10170|    626|  {
10171|    626|    std::string_view hv(input.data() + host_start, host_len);
10172|    626|    char host_buf[256];
10173|    626|    if (has_upper) [[unlikely]] {
  ------------------
  |  Branch (10173:9): [True: 97, False: 529]
  ------------------
10174|     97|      std::memcpy(host_buf, input.data() + host_start, host_len);
10175|     97|      unicode::to_lower_ascii(host_buf, host_len);
10176|     97|      hv = std::string_view(host_buf, host_len);
10177|     97|    }
10178|    626|    if (checkers::is_ipv4(hv)) [[unlikely]] {
  ------------------
  |  Branch (10178:9): [True: 11, False: 615]
  ------------------
10179|     11|      return false;
10180|     11|    }
10181|    615|    static constexpr std::string_view xn{"xn-", 3};
10182|    615|    if (hv.find(xn) != std::string_view::npos) [[unlikely]] {
  ------------------
  |  Branch (10182:9): [True: 33, False: 582]
  ------------------
10183|     33|      return false;
10184|     33|    }
10185|    615|  }
10186|       |
10187|    582|  size_t path_start = host_end;
10188|    582|  size_t path_end = host_end;
10189|    582|  size_t query_start = std::string_view::npos;
10190|    582|  size_t hash_start = std::string_view::npos;
10191|    582|  bool has_path = false;
10192|    582|  bool path_has_dot = false;
10193|       |
10194|    582|  if (i < len && b[i] == '/') {
  ------------------
  |  Branch (10194:7): [True: 509, False: 73]
  |  Branch (10194:18): [True: 433, False: 76]
  ------------------
10195|    433|    has_path = true;
10196|    433|    path_start = i;
10197|    433|    ++i;
10198|  3.06k|    for (; i < len; ++i) {
  ------------------
  |  Branch (10198:12): [True: 2.82k, False: 245]
  ------------------
10199|  2.82k|      const uint8_t c = b[i];
10200|  2.82k|      const uint8_t cls = k_rest[c];
10201|  2.82k|      if (cls == 0) {
  ------------------
  |  Branch (10201:11): [True: 2.63k, False: 188]
  ------------------
10202|  2.63k|        path_has_dot |= (c == '.');
10203|  2.63k|        continue;
10204|  2.63k|      }
10205|    188|      if (cls == 1) {
  ------------------
  |  Branch (10205:11): [True: 173, False: 15]
  ------------------
10206|    173|        path_end = i;
10207|    173|        if (c == '?') {
  ------------------
  |  Branch (10207:13): [True: 111, False: 62]
  ------------------
10208|    111|          query_start = i;
10209|    111|          ++i;
10210|    111|          goto scan_query;
10211|    111|        }
10212|     62|        hash_start = i;
10213|     62|        ++i;
10214|     62|        goto scan_hash;
10215|    173|      }
10216|     15|      return false;
10217|    188|    }
10218|    245|    path_end = i;
10219|    245|  } else if (i < len && b[i] == '?') {
  ------------------
  |  Branch (10219:14): [True: 76, False: 73]
  |  Branch (10219:25): [True: 46, False: 30]
  ------------------
10220|     46|    query_start = i;
10221|     46|    ++i;
10222|     46|    goto scan_query;
10223|    103|  } else if (i < len && b[i] == '#') {
  ------------------
  |  Branch (10223:14): [True: 30, False: 73]
  |  Branch (10223:25): [True: 30, False: 0]
  ------------------
10224|     30|    hash_start = i;
10225|     30|    ++i;
10226|     30|    goto scan_hash;
10227|     30|  }
10228|    318|  goto after_rest;
10229|       |
10230|    318|scan_query:
10231|  7.12k|  for (; i < len; ++i) {
  ------------------
  |  Branch (10231:10): [True: 7.01k, False: 106]
  ------------------
10232|  7.01k|    const uint8_t c = b[i];
10233|  7.01k|    if (c == '#') {
  ------------------
  |  Branch (10233:9): [True: 30, False: 6.98k]
  ------------------
10234|     30|      hash_start = i;
10235|     30|      ++i;
10236|     30|      goto scan_hash;
10237|     30|    }
10238|  6.98k|    if (c == '?' || c == '%') {
  ------------------
  |  Branch (10238:9): [True: 241, False: 6.74k]
  |  Branch (10238:21): [True: 2.06k, False: 4.68k]
  ------------------
10239|  2.30k|      continue;
10240|  2.30k|    }
10241|  4.68k|    if (k_rest[c] == 2) [[unlikely]] {
  ------------------
  |  Branch (10241:9): [True: 21, False: 4.66k]
  ------------------
10242|     21|      return false;
10243|     21|    }
10244|  4.68k|  }
10245|    106|  goto after_rest;
10246|       |
10247|    122|scan_hash:
10248|  2.73k|  for (; i < len; ++i) {
  ------------------
  |  Branch (10248:10): [True: 2.62k, False: 110]
  ------------------
10249|  2.62k|    const uint8_t c = b[i];
10250|  2.62k|    if (c == '?' || c == '#' || c == '%') {
  ------------------
  |  Branch (10250:9): [True: 218, False: 2.40k]
  |  Branch (10250:21): [True: 222, False: 2.18k]
  |  Branch (10250:33): [True: 660, False: 1.52k]
  ------------------
10251|  1.10k|      continue;
10252|  1.10k|    }
10253|  1.52k|    if (k_rest[c] == 2) [[unlikely]] {
  ------------------
  |  Branch (10253:9): [True: 12, False: 1.51k]
  ------------------
10254|     12|      return false;
10255|     12|    }
10256|  1.52k|  }
10257|       |
10258|    534|after_rest:
10259|    534|  if (path_has_dot) [[unlikely]] {
  ------------------
  |  Branch (10259:7): [True: 110, False: 424]
  ------------------
10260|    110|    const std::string_view path_body(input.data() + path_start,
10261|    110|                                     path_end - path_start);
10262|    110|    if (path_body.size() >= 2 && path_body[1] == '.') {
  ------------------
  |  Branch (10262:9): [True: 110, False: 0]
  |  Branch (10262:34): [True: 33, False: 77]
  ------------------
10263|     33|      if (path_body.size() == 2 || path_body[2] == '/' ||
  ------------------
  |  Branch (10263:11): [True: 4, False: 29]
  |  Branch (10263:36): [True: 3, False: 26]
  ------------------
10264|     26|          (path_body.size() >= 3 && path_body[2] == '.' &&
  ------------------
  |  Branch (10264:12): [True: 26, False: 0]
  |  Branch (10264:37): [True: 16, False: 10]
  ------------------
10265|     16|           (path_body.size() == 3 || path_body[3] == '/'))) {
  ------------------
  |  Branch (10265:13): [True: 3, False: 13]
  |  Branch (10265:38): [True: 3, False: 10]
  ------------------
10266|     13|        return false;
10267|     13|      }
10268|     33|    }
10269|     97|    static constexpr std::string_view slash_dot{"/.", 2};
10270|     97|    size_t p = 1;
10271|    622|    while ((p = path_body.find(slash_dot, p)) != std::string_view::npos) {
  ------------------
  |  Branch (10271:12): [True: 538, False: 84]
  ------------------
10272|    538|      const size_t after = p + 2;
10273|    538|      if (after == path_body.size() || path_body[after] == '/' ||
  ------------------
  |  Branch (10273:11): [True: 4, False: 534]
  |  Branch (10273:40): [True: 3, False: 531]
  ------------------
10274|    531|          (after + 1 <= path_body.size() && path_body[after] == '.' &&
  ------------------
  |  Branch (10274:12): [True: 531, False: 0]
  |  Branch (10274:45): [True: 123, False: 408]
  ------------------
10275|    123|           (after + 1 == path_body.size() || path_body[after + 1] == '/'))) {
  ------------------
  |  Branch (10275:13): [True: 3, False: 120]
  |  Branch (10275:46): [True: 3, False: 117]
  ------------------
10276|     13|        return false;
10277|     13|      }
10278|    525|      p = after;
10279|    525|    }
10280|     97|  }
10281|       |
10282|    508|  const bool need_slash = !has_path;
10283|    508|  out.type = scheme_type;
10284|    508|  out.is_valid = true;
10285|    508|  out.has_opaque_path = false;
10286|    508|  out.host_type = DEFAULT;
10287|       |
10288|       |  if constexpr (is_aggregator) {
10289|       |    if (!need_slash) {
10290|       |      out.buffer.resize(len);
10291|       |      // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
10292|       |      std::memcpy(out.buffer.data(), input.data(), len);
10293|       |      if (has_upper) {
10294|       |        unicode::to_lower_ascii(out.buffer.data() + host_start,
10295|       |                                host_end - host_start);
10296|       |      }
10297|       |      out.components.protocol_end = protocol_end;
10298|       |      out.components.username_end = protocol_end + 2;
10299|       |      out.components.host_start = protocol_end + 2;
10300|       |      out.components.host_end = static_cast<uint32_t>(host_end);
10301|       |      out.components.port = url_components::omitted;
10302|       |      out.components.pathname_start = static_cast<uint32_t>(path_start);
10303|       |      out.components.search_start = (query_start != std::string_view::npos)
10304|       |                                        ? static_cast<uint32_t>(query_start)
10305|       |                                        : url_components::omitted;
10306|       |      out.components.hash_start = (hash_start != std::string_view::npos)
10307|       |                                      ? static_cast<uint32_t>(hash_start)
10308|       |                                      : url_components::omitted;
10309|       |    } else {
10310|       |      out.buffer.resize(len + 1);
10311|       |      // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
10312|       |      std::memcpy(out.buffer.data(), input.data(), host_end);
10313|       |      out.buffer[host_end] = '/';
10314|       |      if (host_end < len) {
10315|       |        std::memcpy(out.buffer.data() + host_end + 1, input.data() + host_end,
10316|       |                    len - host_end);
10317|       |      }
10318|       |      if (has_upper) {
10319|       |        unicode::to_lower_ascii(out.buffer.data() + host_start,
10320|       |                                host_end - host_start);
10321|       |      }
10322|       |      out.components.protocol_end = protocol_end;
10323|       |      out.components.username_end = protocol_end + 2;
10324|       |      out.components.host_start = protocol_end + 2;
10325|       |      out.components.host_end = static_cast<uint32_t>(host_end);
10326|       |      out.components.port = url_components::omitted;
10327|       |      out.components.pathname_start = static_cast<uint32_t>(host_end);
10328|       |      out.components.search_start = (query_start != std::string_view::npos)
10329|       |                                        ? static_cast<uint32_t>(query_start + 1)
10330|       |                                        : url_components::omitted;
10331|       |      out.components.hash_start = (hash_start != std::string_view::npos)
10332|       |                                      ? static_cast<uint32_t>(hash_start + 1)
10333|       |                                      : url_components::omitted;
10334|       |    }
10335|    508|  } else {
10336|    508|    std::string host_str(input.substr(host_start, host_end - host_start));
10337|    508|    if (has_upper) {
  ------------------
  |  Branch (10337:9): [True: 82, False: 426]
  ------------------
10338|     82|      unicode::to_lower_ascii(host_str.data(), host_str.size());
10339|     82|    }
10340|    508|    out.host = std::move(host_str);
10341|    508|    if (need_slash) {
  ------------------
  |  Branch (10341:9): [True: 129, False: 379]
  ------------------
10342|    129|      out.path = "/";
10343|    379|    } else {
10344|    379|      out.path.assign(input.data() + path_start, path_end - path_start);
10345|    379|    }
10346|    508|    if (query_start != std::string_view::npos) {
  ------------------
  |  Branch (10346:9): [True: 136, False: 372]
  ------------------
10347|    136|      const size_t q_end =
10348|    136|          (hash_start != std::string_view::npos) ? hash_start : len;
  ------------------
  |  Branch (10348:11): [True: 30, False: 106]
  ------------------
10349|    136|      out.query.emplace(input.data() + query_start + 1,
10350|    136|                        q_end - query_start - 1);
10351|    136|    }
10352|    508|    if (hash_start != std::string_view::npos) {
  ------------------
  |  Branch (10352:9): [True: 110, False: 398]
  ------------------
10353|    110|      out.hash.emplace(input.data() + hash_start + 1, len - hash_start - 1);
10354|    110|    }
10355|    508|  }
10356|    508|  return true;
10357|    534|}
_ZN3ada3url12parse_schemeILb0EEEbNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEE:
 9392|  17.4k|ada_really_inline bool url::parse_scheme(const std::string_view input) {
 9393|  17.4k|  auto parsed_type = ada::scheme::get_scheme_type(input);
 9394|  17.4k|  bool is_input_special = (parsed_type != ada::scheme::NOT_SPECIAL);
 9395|       |  /**
 9396|       |   * In the common case, we will immediately recognize a special scheme (e.g.,
 9397|       |   *http, https), in which case, we can go really fast.
 9398|       |   **/
 9399|  17.4k|  if (is_input_special) {  // fast path!!!
  ------------------
  |  Branch (9399:7): [True: 7.87k, False: 9.53k]
  ------------------
 9400|       |    if constexpr (has_state_override) {
 9401|       |      // If url's scheme is not a special scheme and buffer is a special scheme,
 9402|       |      // then return.
 9403|       |      if (is_special() != is_input_special) {
 9404|       |        return false;
 9405|       |      }
 9406|       |
 9407|       |      // If url includes credentials or has a non-null port, and buffer is
 9408|       |      // "file", then return.
 9409|       |      if ((has_credentials() || port.has_value()) &&
 9410|       |          parsed_type == ada::scheme::type::FILE) {
 9411|       |        return false;
 9412|       |      }
 9413|       |
 9414|       |      // If url's scheme is "file" and its host is an empty host, then return.
 9415|       |      // An empty host is the empty string.
 9416|       |      if (type == ada::scheme::type::FILE && host.has_value() &&
 9417|       |          host->empty()) {
 9418|       |        return false;
 9419|       |      }
 9420|       |    }
 9421|       |
 9422|  7.87k|    type = parsed_type;
 9423|       |
 9424|       |    if constexpr (has_state_override) {
 9425|       |      // This is uncommon.
 9426|       |      uint16_t urls_scheme_port = get_special_port();
 9427|       |
 9428|       |      if (urls_scheme_port) {
 9429|       |        // If url's port is url's scheme's default port, then set url's port to
 9430|       |        // null.
 9431|       |        if (port.has_value() && *port == urls_scheme_port) {
 9432|       |          port = std::nullopt;
 9433|       |        }
 9434|       |      }
 9435|       |    }
 9436|  9.53k|  } else {  // slow path
 9437|  9.53k|    std::string _buffer(input);
 9438|       |    // Next function is only valid if the input is ASCII and returns false
 9439|       |    // otherwise, but it seems that we always have ascii content so we do not
 9440|       |    // need to check the return value.
 9441|       |    // bool is_ascii =
 9442|  9.53k|    unicode::to_lower_ascii(_buffer.data(), _buffer.size());
 9443|       |
 9444|       |    if constexpr (has_state_override) {
 9445|       |      // The state-override validation errors below ("return" in the WHATWG URL
 9446|       |      // parser) leave the URL unchanged. The setter contract is
 9447|       |      // "true on success, false if the scheme is invalid" -- the fast path
 9448|       |      // above already returns false here, so the slow path must agree.
 9449|       |
 9450|       |      // If url's scheme is a special scheme and buffer is not a special scheme,
 9451|       |      // then return. If url's scheme is not a special scheme and buffer is a
 9452|       |      // special scheme, then return.
 9453|       |      if (is_special() != ada::scheme::is_special(_buffer)) {
 9454|       |        return false;
 9455|       |      }
 9456|       |
 9457|       |      // If url includes credentials or has a non-null port, and buffer is
 9458|       |      // "file", then return.
 9459|       |      if ((has_credentials() || port.has_value()) && _buffer == "file") {
 9460|       |        return false;
 9461|       |      }
 9462|       |
 9463|       |      // If url's scheme is "file" and its host is an empty host, then return.
 9464|       |      // An empty host is the empty string.
 9465|       |      if (type == ada::scheme::type::FILE && host.has_value() &&
 9466|       |          host->empty()) {
 9467|       |        return false;
 9468|       |      }
 9469|       |    }
 9470|       |
 9471|  9.53k|    set_scheme(std::move(_buffer));
 9472|       |
 9473|       |    if constexpr (has_state_override) {
 9474|       |      // This is uncommon.
 9475|       |      uint16_t urls_scheme_port = get_special_port();
 9476|       |
 9477|       |      if (urls_scheme_port) {
 9478|       |        // If url's port is url's scheme's default port, then set url's port to
 9479|       |        // null.
 9480|       |        if (port.has_value() && *port == urls_scheme_port) {
 9481|       |          port = std::nullopt;
 9482|       |        }
 9483|       |      }
 9484|       |    }
 9485|  9.53k|  }
 9486|       |
 9487|  17.4k|  return true;
 9488|  17.4k|}
_ZN3ada6parser25try_parse_simple_absoluteINS_14url_aggregatorEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_:
10106|  31.0k|                                                result_type& out) {
10107|  31.0k|  constexpr bool is_ada_url = std::is_same_v<result_type, ada::url>;
10108|  31.0k|  constexpr bool is_aggregator =
10109|  31.0k|      std::is_same_v<result_type, ada::url_aggregator>;
10110|  31.0k|  static_assert(is_ada_url || is_aggregator);
10111|       |
10112|  31.0k|  const size_t len = input.size();
10113|  31.0k|  if (len < 8) [[unlikely]] {
  ------------------
  |  Branch (10113:7): [True: 20.1k, False: 10.8k]
  ------------------
10114|  20.1k|    return false;
10115|  20.1k|  }
10116|  10.8k|  const auto* b = reinterpret_cast<const uint8_t*>(input.data());
10117|       |
10118|  10.8k|  size_t pos;
10119|  10.8k|  ada::scheme::type scheme_type;
10120|  10.8k|  uint32_t protocol_end;
10121|  10.8k|  if (b[0] == 'h' && b[1] == 't' && b[2] == 't' && b[3] == 'p') {
  ------------------
  |  Branch (10121:7): [True: 930, False: 9.96k]
  |  Branch (10121:22): [True: 893, False: 37]
  |  Branch (10121:37): [True: 877, False: 16]
  |  Branch (10121:52): [True: 856, False: 21]
  ------------------
10122|    856|    if (b[4] == ':' && b[5] == '/' && b[6] == '/') {
  ------------------
  |  Branch (10122:9): [True: 653, False: 203]
  |  Branch (10122:24): [True: 558, False: 95]
  |  Branch (10122:39): [True: 544, False: 14]
  ------------------
10123|    544|      pos = 7;
10124|    544|      scheme_type = ada::scheme::type::HTTP;
10125|    544|      protocol_end = 5;
10126|    544|    } else if (len >= 8 && b[4] == 's' && b[5] == ':' && b[6] == '/' &&
  ------------------
  |  Branch (10126:16): [True: 312, False: 0]
  |  Branch (10126:28): [True: 183, False: 129]
  |  Branch (10126:43): [True: 171, False: 12]
  |  Branch (10126:58): [True: 137, False: 34]
  ------------------
10127|    137|               b[7] == '/') {
  ------------------
  |  Branch (10127:16): [True: 121, False: 16]
  ------------------
10128|    121|      pos = 8;
10129|    121|      scheme_type = ada::scheme::type::HTTPS;
10130|    121|      protocol_end = 6;
10131|    191|    } else {
10132|    191|      return false;
10133|    191|    }
10134|  10.0k|  } else {
10135|  10.0k|    return false;
10136|  10.0k|  }
10137|    665|  if (pos < len && (b[pos] == '/' || b[pos] == '\\')) [[unlikely]] {
  ------------------
  |  Branch (10137:7): [True: 662, False: 3]
  |  Branch (10137:21): [True: 3, False: 659]
  |  Branch (10137:38): [True: 3, False: 656]
  ------------------
10138|      6|    return false;
10139|      6|  }
10140|       |
10141|       |  // Digit-led hosts are IPv4/numeric; skip before scanning.
10142|    659|  if (pos < len && b[pos] >= '0' && b[pos] <= '9') {
  ------------------
  |  Branch (10142:7): [True: 656, False: 3]
  |  Branch (10142:20): [True: 410, False: 246]
  |  Branch (10142:37): [True: 0, False: 410]
  ------------------
10143|      0|    return false;
10144|      0|  }
10145|       |
10146|    659|  const size_t host_start = pos;
10147|    659|  bool has_upper = false;
10148|    659|  size_t i = pos;
10149|  8.67k|  for (; i < len; ++i) {
  ------------------
  |  Branch (10149:10): [True: 8.58k, False: 92]
  ------------------
10150|  8.58k|    const uint8_t c = b[i];
10151|  8.58k|    const uint8_t cls = k_host_class[c];
10152|  8.58k|    if (cls == 1) {
  ------------------
  |  Branch (10152:9): [True: 543, False: 8.03k]
  ------------------
10153|    543|      break;
10154|    543|    }
10155|  8.03k|    if (cls == 2) [[unlikely]] {
  ------------------
  |  Branch (10155:9): [True: 24, False: 8.01k]
  ------------------
10156|     24|      return false;
10157|     24|    }
10158|  8.01k|    if (c >= 'A' && c <= 'Z') {
  ------------------
  |  Branch (10158:9): [True: 5.29k, False: 2.72k]
  |  Branch (10158:21): [True: 693, False: 4.60k]
  ------------------
10159|    693|      has_upper = true;
10160|    693|    }
10161|  8.01k|  }
10162|    635|  const size_t host_end = i;
10163|    635|  if (host_start == host_end) [[unlikely]] {
  ------------------
  |  Branch (10163:7): [True: 4, False: 631]
  ------------------
10164|      4|    return false;
10165|      4|  }
10166|    631|  const size_t host_len = host_end - host_start;
10167|    631|  if (host_len > 253) [[unlikely]] {
  ------------------
  |  Branch (10167:7): [True: 5, False: 626]
  ------------------
10168|      5|    return false;
10169|      5|  }
10170|    626|  {
10171|    626|    std::string_view hv(input.data() + host_start, host_len);
10172|    626|    char host_buf[256];
10173|    626|    if (has_upper) [[unlikely]] {
  ------------------
  |  Branch (10173:9): [True: 97, False: 529]
  ------------------
10174|     97|      std::memcpy(host_buf, input.data() + host_start, host_len);
10175|     97|      unicode::to_lower_ascii(host_buf, host_len);
10176|     97|      hv = std::string_view(host_buf, host_len);
10177|     97|    }
10178|    626|    if (checkers::is_ipv4(hv)) [[unlikely]] {
  ------------------
  |  Branch (10178:9): [True: 11, False: 615]
  ------------------
10179|     11|      return false;
10180|     11|    }
10181|    615|    static constexpr std::string_view xn{"xn-", 3};
10182|    615|    if (hv.find(xn) != std::string_view::npos) [[unlikely]] {
  ------------------
  |  Branch (10182:9): [True: 33, False: 582]
  ------------------
10183|     33|      return false;
10184|     33|    }
10185|    615|  }
10186|       |
10187|    582|  size_t path_start = host_end;
10188|    582|  size_t path_end = host_end;
10189|    582|  size_t query_start = std::string_view::npos;
10190|    582|  size_t hash_start = std::string_view::npos;
10191|    582|  bool has_path = false;
10192|    582|  bool path_has_dot = false;
10193|       |
10194|    582|  if (i < len && b[i] == '/') {
  ------------------
  |  Branch (10194:7): [True: 509, False: 73]
  |  Branch (10194:18): [True: 433, False: 76]
  ------------------
10195|    433|    has_path = true;
10196|    433|    path_start = i;
10197|    433|    ++i;
10198|  3.06k|    for (; i < len; ++i) {
  ------------------
  |  Branch (10198:12): [True: 2.82k, False: 245]
  ------------------
10199|  2.82k|      const uint8_t c = b[i];
10200|  2.82k|      const uint8_t cls = k_rest[c];
10201|  2.82k|      if (cls == 0) {
  ------------------
  |  Branch (10201:11): [True: 2.63k, False: 188]
  ------------------
10202|  2.63k|        path_has_dot |= (c == '.');
10203|  2.63k|        continue;
10204|  2.63k|      }
10205|    188|      if (cls == 1) {
  ------------------
  |  Branch (10205:11): [True: 173, False: 15]
  ------------------
10206|    173|        path_end = i;
10207|    173|        if (c == '?') {
  ------------------
  |  Branch (10207:13): [True: 111, False: 62]
  ------------------
10208|    111|          query_start = i;
10209|    111|          ++i;
10210|    111|          goto scan_query;
10211|    111|        }
10212|     62|        hash_start = i;
10213|     62|        ++i;
10214|     62|        goto scan_hash;
10215|    173|      }
10216|     15|      return false;
10217|    188|    }
10218|    245|    path_end = i;
10219|    245|  } else if (i < len && b[i] == '?') {
  ------------------
  |  Branch (10219:14): [True: 76, False: 73]
  |  Branch (10219:25): [True: 46, False: 30]
  ------------------
10220|     46|    query_start = i;
10221|     46|    ++i;
10222|     46|    goto scan_query;
10223|    103|  } else if (i < len && b[i] == '#') {
  ------------------
  |  Branch (10223:14): [True: 30, False: 73]
  |  Branch (10223:25): [True: 30, False: 0]
  ------------------
10224|     30|    hash_start = i;
10225|     30|    ++i;
10226|     30|    goto scan_hash;
10227|     30|  }
10228|    318|  goto after_rest;
10229|       |
10230|    318|scan_query:
10231|  7.12k|  for (; i < len; ++i) {
  ------------------
  |  Branch (10231:10): [True: 7.01k, False: 106]
  ------------------
10232|  7.01k|    const uint8_t c = b[i];
10233|  7.01k|    if (c == '#') {
  ------------------
  |  Branch (10233:9): [True: 30, False: 6.98k]
  ------------------
10234|     30|      hash_start = i;
10235|     30|      ++i;
10236|     30|      goto scan_hash;
10237|     30|    }
10238|  6.98k|    if (c == '?' || c == '%') {
  ------------------
  |  Branch (10238:9): [True: 241, False: 6.74k]
  |  Branch (10238:21): [True: 2.06k, False: 4.68k]
  ------------------
10239|  2.30k|      continue;
10240|  2.30k|    }
10241|  4.68k|    if (k_rest[c] == 2) [[unlikely]] {
  ------------------
  |  Branch (10241:9): [True: 21, False: 4.66k]
  ------------------
10242|     21|      return false;
10243|     21|    }
10244|  4.68k|  }
10245|    106|  goto after_rest;
10246|       |
10247|    122|scan_hash:
10248|  2.73k|  for (; i < len; ++i) {
  ------------------
  |  Branch (10248:10): [True: 2.62k, False: 110]
  ------------------
10249|  2.62k|    const uint8_t c = b[i];
10250|  2.62k|    if (c == '?' || c == '#' || c == '%') {
  ------------------
  |  Branch (10250:9): [True: 218, False: 2.40k]
  |  Branch (10250:21): [True: 222, False: 2.18k]
  |  Branch (10250:33): [True: 660, False: 1.52k]
  ------------------
10251|  1.10k|      continue;
10252|  1.10k|    }
10253|  1.52k|    if (k_rest[c] == 2) [[unlikely]] {
  ------------------
  |  Branch (10253:9): [True: 12, False: 1.51k]
  ------------------
10254|     12|      return false;
10255|     12|    }
10256|  1.52k|  }
10257|       |
10258|    534|after_rest:
10259|    534|  if (path_has_dot) [[unlikely]] {
  ------------------
  |  Branch (10259:7): [True: 110, False: 424]
  ------------------
10260|    110|    const std::string_view path_body(input.data() + path_start,
10261|    110|                                     path_end - path_start);
10262|    110|    if (path_body.size() >= 2 && path_body[1] == '.') {
  ------------------
  |  Branch (10262:9): [True: 110, False: 0]
  |  Branch (10262:34): [True: 33, False: 77]
  ------------------
10263|     33|      if (path_body.size() == 2 || path_body[2] == '/' ||
  ------------------
  |  Branch (10263:11): [True: 4, False: 29]
  |  Branch (10263:36): [True: 3, False: 26]
  ------------------
10264|     26|          (path_body.size() >= 3 && path_body[2] == '.' &&
  ------------------
  |  Branch (10264:12): [True: 26, False: 0]
  |  Branch (10264:37): [True: 16, False: 10]
  ------------------
10265|     16|           (path_body.size() == 3 || path_body[3] == '/'))) {
  ------------------
  |  Branch (10265:13): [True: 3, False: 13]
  |  Branch (10265:38): [True: 3, False: 10]
  ------------------
10266|     13|        return false;
10267|     13|      }
10268|     33|    }
10269|     97|    static constexpr std::string_view slash_dot{"/.", 2};
10270|     97|    size_t p = 1;
10271|    622|    while ((p = path_body.find(slash_dot, p)) != std::string_view::npos) {
  ------------------
  |  Branch (10271:12): [True: 538, False: 84]
  ------------------
10272|    538|      const size_t after = p + 2;
10273|    538|      if (after == path_body.size() || path_body[after] == '/' ||
  ------------------
  |  Branch (10273:11): [True: 4, False: 534]
  |  Branch (10273:40): [True: 3, False: 531]
  ------------------
10274|    531|          (after + 1 <= path_body.size() && path_body[after] == '.' &&
  ------------------
  |  Branch (10274:12): [True: 531, False: 0]
  |  Branch (10274:45): [True: 123, False: 408]
  ------------------
10275|    123|           (after + 1 == path_body.size() || path_body[after + 1] == '/'))) {
  ------------------
  |  Branch (10275:13): [True: 3, False: 120]
  |  Branch (10275:46): [True: 3, False: 117]
  ------------------
10276|     13|        return false;
10277|     13|      }
10278|    525|      p = after;
10279|    525|    }
10280|     97|  }
10281|       |
10282|    508|  const bool need_slash = !has_path;
10283|    508|  out.type = scheme_type;
10284|    508|  out.is_valid = true;
10285|    508|  out.has_opaque_path = false;
10286|    508|  out.host_type = DEFAULT;
10287|       |
10288|    508|  if constexpr (is_aggregator) {
10289|    508|    if (!need_slash) {
  ------------------
  |  Branch (10289:9): [True: 379, False: 129]
  ------------------
10290|    379|      out.buffer.resize(len);
10291|       |      // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
10292|    379|      std::memcpy(out.buffer.data(), input.data(), len);
10293|    379|      if (has_upper) {
  ------------------
  |  Branch (10293:11): [True: 13, False: 366]
  ------------------
10294|     13|        unicode::to_lower_ascii(out.buffer.data() + host_start,
10295|     13|                                host_end - host_start);
10296|     13|      }
10297|    379|      out.components.protocol_end = protocol_end;
10298|    379|      out.components.username_end = protocol_end + 2;
10299|    379|      out.components.host_start = protocol_end + 2;
10300|    379|      out.components.host_end = static_cast<uint32_t>(host_end);
10301|    379|      out.components.port = url_components::omitted;
10302|    379|      out.components.pathname_start = static_cast<uint32_t>(path_start);
10303|    379|      out.components.search_start = (query_start != std::string_view::npos)
  ------------------
  |  Branch (10303:37): [True: 103, False: 276]
  ------------------
10304|    379|                                        ? static_cast<uint32_t>(query_start)
10305|    379|                                        : url_components::omitted;
10306|    379|      out.components.hash_start = (hash_start != std::string_view::npos)
  ------------------
  |  Branch (10306:35): [True: 79, False: 300]
  ------------------
10307|    379|                                      ? static_cast<uint32_t>(hash_start)
10308|    379|                                      : url_components::omitted;
10309|    379|    } else {
10310|    129|      out.buffer.resize(len + 1);
10311|       |      // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
10312|    129|      std::memcpy(out.buffer.data(), input.data(), host_end);
10313|    129|      out.buffer[host_end] = '/';
10314|    129|      if (host_end < len) {
  ------------------
  |  Branch (10314:11): [True: 56, False: 73]
  ------------------
10315|     56|        std::memcpy(out.buffer.data() + host_end + 1, input.data() + host_end,
10316|     56|                    len - host_end);
10317|     56|      }
10318|    129|      if (has_upper) {
  ------------------
  |  Branch (10318:11): [True: 69, False: 60]
  ------------------
10319|     69|        unicode::to_lower_ascii(out.buffer.data() + host_start,
10320|     69|                                host_end - host_start);
10321|     69|      }
10322|    129|      out.components.protocol_end = protocol_end;
10323|    129|      out.components.username_end = protocol_end + 2;
10324|    129|      out.components.host_start = protocol_end + 2;
10325|    129|      out.components.host_end = static_cast<uint32_t>(host_end);
10326|    129|      out.components.port = url_components::omitted;
10327|    129|      out.components.pathname_start = static_cast<uint32_t>(host_end);
10328|    129|      out.components.search_start = (query_start != std::string_view::npos)
  ------------------
  |  Branch (10328:37): [True: 33, False: 96]
  ------------------
10329|    129|                                        ? static_cast<uint32_t>(query_start + 1)
10330|    129|                                        : url_components::omitted;
10331|    129|      out.components.hash_start = (hash_start != std::string_view::npos)
  ------------------
  |  Branch (10331:35): [True: 31, False: 98]
  ------------------
10332|    129|                                      ? static_cast<uint32_t>(hash_start + 1)
10333|    129|                                      : url_components::omitted;
10334|    129|    }
10335|       |  } else {
10336|       |    std::string host_str(input.substr(host_start, host_end - host_start));
10337|       |    if (has_upper) {
10338|       |      unicode::to_lower_ascii(host_str.data(), host_str.size());
10339|       |    }
10340|       |    out.host = std::move(host_str);
10341|       |    if (need_slash) {
10342|       |      out.path = "/";
10343|       |    } else {
10344|       |      out.path.assign(input.data() + path_start, path_end - path_start);
10345|       |    }
10346|       |    if (query_start != std::string_view::npos) {
10347|       |      const size_t q_end =
10348|       |          (hash_start != std::string_view::npos) ? hash_start : len;
10349|       |      out.query.emplace(input.data() + query_start + 1,
10350|       |                        q_end - query_start - 1);
10351|       |    }
10352|       |    if (hash_start != std::string_view::npos) {
10353|       |      out.hash.emplace(input.data() + hash_start + 1, len - hash_start - 1);
10354|       |    }
10355|       |  }
10356|    508|  return true;
10357|    534|}
_ZN3ada14url_aggregator23parse_scheme_with_colonILb0EEEbNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEE:
11448|  33.9k|    const std::string_view input_with_colon) {
11449|  33.9k|  ada_log("url_aggregator::parse_scheme_with_colon ", input_with_colon);
11450|  33.9k|  ADA_ASSERT_TRUE(validate());
11451|  33.9k|  ADA_ASSERT_TRUE(!helpers::overlaps(input_with_colon, buffer));
11452|  33.9k|  std::string_view input{input_with_colon};
11453|  33.9k|  input.remove_suffix(1);
11454|  33.9k|  auto parsed_type = ada::scheme::get_scheme_type(input);
11455|  33.9k|  const bool is_input_special = (parsed_type != ada::scheme::NOT_SPECIAL);
11456|       |  /**
11457|       |   * In the common case, we will immediately recognize a special scheme (e.g.,
11458|       |   *http, https), in which case, we can go really fast.
11459|       |   **/
11460|  33.9k|  if (is_input_special) {  // fast path!!!
  ------------------
  |  Branch (11460:7): [True: 14.9k, False: 19.0k]
  ------------------
11461|       |    if constexpr (has_state_override) {
11462|       |      // If url's scheme is not a special scheme and buffer is a special scheme,
11463|       |      // then return.
11464|       |      if (is_special() != is_input_special) {
11465|       |        return false;
11466|       |      }
11467|       |
11468|       |      // If url includes credentials or has a non-null port, and buffer is
11469|       |      // "file", then return.
11470|       |      if ((has_credentials() || components.port != url_components::omitted) &&
11471|       |          parsed_type == ada::scheme::type::FILE) {
11472|       |        return false;
11473|       |      }
11474|       |
11475|       |      // If url's scheme is "file" and its host is an empty host, then return.
11476|       |      // An empty host is the empty string.
11477|       |      if (type == ada::scheme::type::FILE &&
11478|       |          components.host_start == components.host_end) {
11479|       |        return false;
11480|       |      }
11481|       |    }
11482|       |
11483|  14.9k|    type = parsed_type;
11484|  14.9k|    set_scheme_from_view_with_colon(input_with_colon);
11485|       |
11486|       |    if constexpr (has_state_override) {
11487|       |      // This is uncommon.
11488|       |      uint16_t urls_scheme_port = get_special_port();
11489|       |
11490|       |      if (urls_scheme_port) {
11491|       |        // If url's port is url's scheme's default port, then set url's port to
11492|       |        // null.
11493|       |        if (components.port == urls_scheme_port) {
11494|       |          clear_port();
11495|       |        }
11496|       |      }
11497|       |    }
11498|  19.0k|  } else {  // slow path
11499|  19.0k|    std::string _buffer(input);
11500|       |    // Next function is only valid if the input is ASCII and returns false
11501|       |    // otherwise, but it seems that we always have ascii content so we do not
11502|       |    // need to check the return value.
11503|  19.0k|    unicode::to_lower_ascii(_buffer.data(), _buffer.size());
11504|       |
11505|       |    if constexpr (has_state_override) {
11506|       |      // The state-override validation errors below ("return" in the WHATWG URL
11507|       |      // parser) leave the URL unchanged. The setter contract is
11508|       |      // "true on success, false if the scheme is invalid" -- the fast path
11509|       |      // above already returns false here, so the slow path must agree.
11510|       |
11511|       |      // If url's scheme is a special scheme and buffer is not a special scheme,
11512|       |      // then return. If url's scheme is not a special scheme and buffer is a
11513|       |      // special scheme, then return.
11514|       |      if (is_special() != ada::scheme::is_special(_buffer)) {
11515|       |        return false;
11516|       |      }
11517|       |
11518|       |      // If url includes credentials or has a non-null port, and buffer is
11519|       |      // "file", then return.
11520|       |      if ((has_credentials() || components.port != url_components::omitted) &&
11521|       |          _buffer == "file") {
11522|       |        return false;
11523|       |      }
11524|       |
11525|       |      // If url's scheme is "file" and its host is an empty host, then return.
11526|       |      // An empty host is the empty string.
11527|       |      if (type == ada::scheme::type::FILE &&
11528|       |          components.host_start == components.host_end) {
11529|       |        return false;
11530|       |      }
11531|       |    }
11532|       |
11533|  19.0k|    set_scheme(_buffer);
11534|       |
11535|       |    if constexpr (has_state_override) {
11536|       |      // This is uncommon.
11537|       |      uint16_t urls_scheme_port = get_special_port();
11538|       |
11539|       |      if (urls_scheme_port) {
11540|       |        // If url's port is url's scheme's default port, then set url's port to
11541|       |        // null.
11542|       |        if (components.port == urls_scheme_port) {
11543|       |          clear_port();
11544|       |        }
11545|       |      }
11546|       |    }
11547|  19.0k|  }
11548|  33.9k|  ADA_ASSERT_TRUE(validate());
11549|  33.9k|  return true;
11550|  33.9k|}
_ZN3ada14url_aggregator31set_scheme_from_view_with_colonENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
11574|  14.9k|    std::string_view new_scheme_with_colon) {
11575|  14.9k|  ada_log("url_aggregator::set_scheme_from_view_with_colon ",
11576|  14.9k|          new_scheme_with_colon);
11577|  14.9k|  ADA_ASSERT_TRUE(validate());
11578|  14.9k|  ADA_ASSERT_TRUE(!new_scheme_with_colon.empty() &&
11579|  14.9k|                  new_scheme_with_colon.back() == ':');
11580|       |  // next line could overflow but unsigned arithmetic has well-defined
11581|       |  // overflows.
11582|  14.9k|  uint32_t new_difference =
11583|  14.9k|      uint32_t(new_scheme_with_colon.size()) - components.protocol_end;
11584|       |
11585|  14.9k|  if (buffer.empty()) {
  ------------------
  |  Branch (11585:7): [True: 14.9k, False: 0]
  ------------------
11586|  14.9k|    buffer.append(new_scheme_with_colon);
11587|  14.9k|  } else {
11588|      0|    buffer.erase(0, components.protocol_end);
11589|      0|    buffer.insert(0, new_scheme_with_colon);
11590|      0|  }
11591|  14.9k|  components.protocol_end += new_difference;
11592|       |
11593|  14.9k|  apply_shifted_non_scheme_offsets(components, new_difference);
11594|  14.9k|  ADA_ASSERT_TRUE(validate());
11595|  14.9k|}
_ZN3ada14url_aggregator10set_schemeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
11597|  19.0k|inline void url_aggregator::set_scheme(std::string_view new_scheme) {
11598|  19.0k|  ada_log("url_aggregator::set_scheme ", new_scheme);
11599|  19.0k|  ADA_ASSERT_TRUE(validate());
11600|  19.0k|  ADA_ASSERT_TRUE(new_scheme.empty() || new_scheme.back() != ':');
11601|       |  // next line could overflow but unsigned arithmetic has well-defined
11602|       |  // overflows.
11603|  19.0k|  uint32_t new_difference =
11604|  19.0k|      uint32_t(new_scheme.size()) - components.protocol_end + 1;
11605|       |
11606|  19.0k|  type = ada::scheme::get_scheme_type(new_scheme);
11607|  19.0k|  if (buffer.empty()) {
  ------------------
  |  Branch (11607:7): [True: 19.0k, False: 0]
  ------------------
11608|  19.0k|    buffer.append(helpers::concat(new_scheme, ":"));
11609|  19.0k|  } else {
11610|      0|    buffer.erase(0, components.protocol_end);
11611|      0|    buffer.insert(0, helpers::concat(new_scheme, ":"));
11612|      0|  }
11613|  19.0k|  components.protocol_end = uint32_t(new_scheme.size() + 1);
11614|       |
11615|  19.0k|  apply_shifted_non_scheme_offsets(components, new_difference);
11616|  19.0k|  ADA_ASSERT_TRUE(validate());
11617|  19.0k|}

_ZN3ada37url_pattern_compile_component_optionsC2ENSt3__18optionalIcEES3_:
 5678|      6|      : delimiter(new_delimiter), prefix(new_prefix) {}
_ZN3ada14character_sets6bit_atEPKhh:
 1074|   276k|ada_really_inline constexpr bool bit_at(const uint8_t a[], const uint8_t i) {
 1075|   276k|  return !!(a[i >> 3] & (1 << (i & 7)));
 1076|   276k|}
_ZN2tl10unexpectedIN3ada6errorsEEC2EOS2_:
 2145|  76.0k|  constexpr explicit unexpected(E&& e) : m_val(std::move(e)) {}
_ZN2tl8expectedIN3ada3urlENS1_6errorsEEC2IS3_TnPNSt3__19enable_ifIXsr3std16is_constructibleIS3_OT_EE5valueEvE4typeELPv0ETnPNS7_IXsr3std14is_convertibleIS9_S3_EE5valueEvE4typeELSD_0EEEONS_10unexpectedIS8_EE:
 3631|  19.0k|      : impl_base(unexpect, std::move(e.value())),
 3632|  19.0k|        ctor_base(detail::default_constructor_tag{}) {}
_ZNR2tl10unexpectedIN3ada6errorsEE5valueEv:
 2159|  38.0k|  TL_EXPECTED_11_CONSTEXPR E& value() & { return m_val; }
_ZN2tl6detail21expected_storage_baseIN3ada3urlENS2_6errorsELb0ELb1EEC2IJS4_ETnPNSt3__19enable_ifIXsr3std16is_constructibleIS4_DpOT_EE5valueEvE4typeELPv0EEENS_10unexpect_tESB_:
 2617|  19.0k|      : m_unexpect(std::forward<Args>(args)...), m_has_val(false) {}
_ZN2tl6detail26expected_default_ctor_baseIN3ada3urlENS2_6errorsELb1EEC2ENS0_23default_constructor_tagE:
 3235|  34.6k|  constexpr explicit expected_default_ctor_base(default_constructor_tag) {}
_ZN2tl8expectedIN3ada3urlENS1_6errorsEEC2IS2_TnPNSt3__19enable_ifIXsr3std14is_convertibleIOT_S2_EE5valueEvE4typeELPv0ETnPNS7_IXaaaaaasr3std16is_constructibleIS2_S9_EE5valuentsr3std7is_sameINS6_5decayIS8_E4typeENS_10in_place_tEEE5valuentsr3std7is_sameIS4_SG_EE5valuentsr3std7is_sameINS_10unexpectedIS3_EESG_EE5valueEvE4typeELSD_0EEES9_:
 3717|  15.6k|      : expected(in_place, std::forward<U>(v)) {}
_ZN2tl8expectedIN3ada3urlENS1_6errorsEEC2IJS2_ETnPNSt3__19enable_ifIXsr3std16is_constructibleIS2_DpOT_EE5valueEvE4typeELPv0EEENS_10in_place_tESA_:
 3590|  15.6k|      : impl_base(in_place, std::forward<Args>(args)...),
 3591|  15.6k|        ctor_base(detail::default_constructor_tag{}) {}
_ZN2tl6detail21expected_storage_baseIN3ada3urlENS2_6errorsELb0ELb1EEC2IJS3_ETnPNSt3__19enable_ifIXsr3std16is_constructibleIS3_DpOT_EE5valueEvE4typeELPv0EEENS_10in_place_tESB_:
 2605|  15.6k|      : m_val(std::forward<Args>(args)...), m_has_val(true) {}
_ZN3ada3urlC2EOS0_:
 4986|  15.6k|  url(url&& u) noexcept = default;
_ZN3ada8url_baseD2Ev:
 1649|   144k|  virtual ~url_base() = default;
_ZN3ada3urlD2Ev:
 4989|  50.2k|  ~url() override = default;
_ZN2tl8expectedIN3ada14url_aggregatorENS1_6errorsEEC2IS3_TnPNSt3__19enable_ifIXsr3std16is_constructibleIS3_OT_EE5valueEvE4typeELPv0ETnPNS7_IXsr3std14is_convertibleIS9_S3_EE5valueEvE4typeELSD_0EEEONS_10unexpectedIS8_EE:
 3631|  19.0k|      : impl_base(unexpect, std::move(e.value())),
 3632|  19.0k|        ctor_base(detail::default_constructor_tag{}) {}
_ZN2tl6detail21expected_storage_baseIN3ada14url_aggregatorENS2_6errorsELb0ELb1EEC2IJS4_ETnPNSt3__19enable_ifIXsr3std16is_constructibleIS4_DpOT_EE5valueEvE4typeELPv0EEENS_10unexpect_tESB_:
 2617|  19.0k|      : m_unexpect(std::forward<Args>(args)...), m_has_val(false) {}
_ZN2tl6detail26expected_default_ctor_baseIN3ada14url_aggregatorENS2_6errorsELb1EEC2ENS0_23default_constructor_tagE:
 3235|  34.6k|  constexpr explicit expected_default_ctor_base(default_constructor_tag) {}
_ZN2tl8expectedIN3ada14url_aggregatorENS1_6errorsEEC2IS2_TnPNSt3__19enable_ifIXsr3std14is_convertibleIOT_S2_EE5valueEvE4typeELPv0ETnPNS7_IXaaaaaasr3std16is_constructibleIS2_S9_EE5valuentsr3std7is_sameINS6_5decayIS8_E4typeENS_10in_place_tEEE5valuentsr3std7is_sameIS4_SG_EE5valuentsr3std7is_sameINS_10unexpectedIS3_EESG_EE5valueEvE4typeELSD_0EEES9_:
 3717|  15.6k|      : expected(in_place, std::forward<U>(v)) {}
_ZN2tl8expectedIN3ada14url_aggregatorENS1_6errorsEEC2IJS2_ETnPNSt3__19enable_ifIXsr3std16is_constructibleIS2_DpOT_EE5valueEvE4typeELPv0EEENS_10in_place_tESA_:
 3590|  15.6k|      : impl_base(in_place, std::forward<Args>(args)...),
 3591|  15.6k|        ctor_base(detail::default_constructor_tag{}) {}
_ZN2tl6detail21expected_storage_baseIN3ada14url_aggregatorENS2_6errorsELb0ELb1EEC2IJS3_ETnPNSt3__19enable_ifIXsr3std16is_constructibleIS3_DpOT_EE5valueEvE4typeELPv0EEENS_10in_place_tESB_:
 2605|  15.6k|      : m_val(std::forward<Args>(args)...), m_has_val(true) {}
_ZN3ada14url_aggregatorC2EOS0_:
 7691|  15.6k|  url_aggregator(url_aggregator&& u) noexcept = default;
_ZN3ada14url_aggregatorD2Ev:
 7694|  94.0k|  ~url_aggregator() override = default;
_ZN3ada6scheme15get_scheme_typeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 6709|  91.9k|constexpr ada::scheme::type get_scheme_type(std::string_view scheme) noexcept {
 6710|  91.9k|  if (scheme.empty()) {
  ------------------
  |  Branch (6710:7): [True: 0, False: 91.9k]
  ------------------
 6711|      0|    return ada::scheme::NOT_SPECIAL;
 6712|      0|  }
 6713|  91.9k|  int hash_value = (2 * scheme.size() + (unsigned)(scheme[0])) & 7;
 6714|  91.9k|  const std::string_view target = details::is_special_list[hash_value];
 6715|  91.9k|  if (scheme.size() == target.size() &&
  ------------------
  |  Branch (6715:7): [True: 73.0k, False: 18.8k]
  ------------------
 6716|  73.0k|      details::branchless_load5(scheme.data(), scheme.size()) ==
  ------------------
  |  Branch (6716:7): [True: 47.9k, False: 25.0k]
  ------------------
 6717|  73.0k|          details::scheme_keys[hash_value]) {
 6718|  47.9k|    return ada::scheme::type(hash_value);
 6719|  47.9k|  } else {
 6720|  43.9k|    return ada::scheme::NOT_SPECIAL;
 6721|  43.9k|  }
 6722|  91.9k|}
_ZN3ada6scheme7details16branchless_load5EPKcm:
 6650|  73.0k|inline uint64_t branchless_load5(const char* p, size_t n) {
 6651|  73.0k|  uint64_t input = (uint8_t)p[0];
 6652|  73.0k|  input |= ((uint64_t)(uint8_t)p[n > 1] << 8) & (0 - (uint64_t)(n > 1));
 6653|  73.0k|  input |= ((uint64_t)(uint8_t)p[(n > 2) * 2] << 16) & (0 - (uint64_t)(n > 2));
 6654|  73.0k|  input |= ((uint64_t)(uint8_t)p[(n > 3) * 3] << 24) & (0 - (uint64_t)(n > 3));
 6655|  73.0k|  input |= ((uint64_t)(uint8_t)p[(n > 4) * 4] << 32) & (0 - (uint64_t)(n > 4));
 6656|  73.0k|  return input;
 6657|  73.0k|}
_ZN3ada14url_aggregatorC2Ev:
 7689|  78.4k|  url_aggregator() = default;
_ZN3ada14url_componentsC2Ev:
 4895|  78.4k|  url_components() = default;
_ZN3ada14url_aggregatoraSEOS0_:
 7692|  8.82k|  url_aggregator& operator=(url_aggregator&& u) noexcept = default;
_ZN3ada8checkers19try_parse_ipv4_fastENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 1402|  36.6k|try_parse_ipv4_fast(std::string_view input) noexcept {
 1403|  36.6k|  const size_t len = input.size();
 1404|       |  // Shortest pure decimal: "0.0.0.0" (7). Longest + trailing dot: 16.
 1405|  36.6k|  if (len < 7 || len > 16) [[unlikely]] {
  ------------------
  |  Branch (1405:7): [True: 17.8k, False: 18.7k]
  |  Branch (1405:18): [True: 7.87k, False: 10.8k]
  ------------------
 1406|  25.7k|    return ipv4_fast_fail;
 1407|  25.7k|  }
 1408|  10.8k|  const char* data = input.data();
 1409|       |
 1410|       |#if defined(ADA_AVX512)
 1411|       |  return detail::try_parse_ipv4_avx512(data, len);
 1412|       |#else
 1413|  10.8k|  return detail::parse_ipv4_decimal_scalar(data, data + len);
 1414|  36.6k|#endif
 1415|  36.6k|}
_ZN3ada8checkers6detail25parse_ipv4_decimal_scalarEPKcS3_:
 1277|  10.8k|parse_ipv4_decimal_scalar(const char* p, const char* pend) noexcept {
 1278|  10.8k|  uint32_t ipv4 = 0;
 1279|  24.0k|  for (int i = 0; i < 4; ++i) {
  ------------------
  |  Branch (1279:19): [True: 21.1k, False: 2.89k]
  ------------------
 1280|  21.1k|    if (p == pend) [[unlikely]] {
  ------------------
  |  Branch (1280:9): [True: 6, False: 21.1k]
  ------------------
 1281|      6|      return ipv4_fast_fail;
 1282|      6|    }
 1283|  21.1k|    uint32_t val;
 1284|  21.1k|    char c = *p;
 1285|  21.1k|    if (c >= '0' && c <= '9') [[likely]] {
  ------------------
  |  Branch (1285:9): [True: 19.3k, False: 1.77k]
  |  Branch (1285:21): [True: 15.9k, False: 3.36k]
  ------------------
 1286|  15.9k|      val = static_cast<uint32_t>(c - '0');
 1287|  15.9k|      ++p;
 1288|  15.9k|    } else {
 1289|  5.13k|      return ipv4_fast_fail;
 1290|  5.13k|    }
 1291|  15.9k|    if (p < pend) {
  ------------------
  |  Branch (1291:9): [True: 14.6k, False: 1.31k]
  ------------------
 1292|  14.6k|      c = *p;
 1293|  14.6k|      if (c >= '0' && c <= '9') {
  ------------------
  |  Branch (1293:11): [True: 6.45k, False: 8.23k]
  |  Branch (1293:23): [True: 5.51k, False: 932]
  ------------------
 1294|  5.51k|        if (val == 0) [[unlikely]] {
  ------------------
  |  Branch (1294:13): [True: 587, False: 4.93k]
  ------------------
 1295|    587|          return ipv4_fast_fail;
 1296|    587|        }
 1297|  4.93k|        val = val * 10u + static_cast<uint32_t>(c - '0');
 1298|  4.93k|        ++p;
 1299|  4.93k|        if (p < pend) {
  ------------------
  |  Branch (1299:13): [True: 4.35k, False: 574]
  ------------------
 1300|  4.35k|          c = *p;
 1301|  4.35k|          if (c >= '0' && c <= '9') {
  ------------------
  |  Branch (1301:15): [True: 2.90k, False: 1.45k]
  |  Branch (1301:27): [True: 2.73k, False: 170]
  ------------------
 1302|  2.73k|            val = val * 10u + static_cast<uint32_t>(c - '0');
 1303|  2.73k|            ++p;
 1304|  2.73k|            if (val > 255u) [[unlikely]] {
  ------------------
  |  Branch (1304:17): [True: 714, False: 2.02k]
  ------------------
 1305|    714|              return ipv4_fast_fail;
 1306|    714|            }
 1307|  2.73k|          }
 1308|  4.35k|        }
 1309|  4.93k|      }
 1310|  14.6k|    }
 1311|  14.6k|    ipv4 = (ipv4 << 8) | val;
 1312|  14.6k|    if (i < 3) {
  ------------------
  |  Branch (1312:9): [True: 11.8k, False: 2.89k]
  ------------------
 1313|  11.8k|      if (p == pend || *p != '.') [[unlikely]] {
  ------------------
  |  Branch (1313:11): [True: 346, False: 11.4k]
  |  Branch (1313:24): [True: 1.20k, False: 10.2k]
  ------------------
 1314|  1.55k|        return ipv4_fast_fail;
 1315|  1.55k|      }
 1316|  10.2k|      ++p;
 1317|  10.2k|    }
 1318|  14.6k|  }
 1319|  2.89k|  if (p != pend) {
  ------------------
  |  Branch (1319:7): [True: 700, False: 2.19k]
  ------------------
 1320|    700|    if (p == pend - 1 && *p == '.') {
  ------------------
  |  Branch (1320:9): [True: 372, False: 328]
  |  Branch (1320:26): [True: 69, False: 303]
  ------------------
 1321|     69|      return ipv4;
 1322|     69|    }
 1323|    631|    return ipv4_fast_fail;
 1324|    700|  }
 1325|  2.19k|  return ipv4;
 1326|  2.89k|}
_ZNK3ada3url15has_credentialsEv:
 7227|  10.3k|[[nodiscard]] ada_really_inline bool url::has_credentials() const noexcept {
 7228|  10.3k|  return !username.empty() || !password.empty();
  ------------------
  |  Branch (7228:10): [True: 1.23k, False: 9.09k]
  |  Branch (7228:31): [True: 199, False: 8.89k]
  ------------------
 7229|  10.3k|}
_ZNK3ada8url_base10is_specialEv:
 7192|   238k|    const noexcept {
 7193|   238k|  return type != ada::scheme::NOT_SPECIAL;
 7194|   238k|}
_ZNK2tl8expectedIN3ada3urlENS1_6errorsEEcvbEv:
 4030|  19.3k|  constexpr explicit operator bool() const noexcept { return this->m_has_val; }
_ZN2tl8expectedIN3ada3urlENS1_6errorsEEptEv:
 3999|  12.5k|  TL_EXPECTED_11_CONSTEXPR T* operator->() {
 4000|  12.5k|    TL_ASSERT(has_value());
  ------------------
  |  | 2052|  12.5k|#define TL_ASSERT(x) assert(x)
  ------------------
  |  Branch (4000:5): [True: 12.5k, False: 0]
  ------------------
 4001|  12.5k|    return valptr();
 4002|  12.5k|  }
_ZN2tl8expectedIN3ada3urlENS1_6errorsEE6valptrEv:
 3295|  12.5k|  T* valptr() { return std::addressof(this->m_val); }
_ZN2tl6detail21expected_storage_baseIN3ada3urlENS2_6errorsELb0ELb1EED2Ev:
 2627|  34.6k|  ~expected_storage_base() {
 2628|  34.6k|    if (m_has_val) {
  ------------------
  |  Branch (2628:9): [True: 15.6k, False: 19.0k]
  ------------------
 2629|  15.6k|      m_val.~T();
 2630|  15.6k|    }
 2631|  34.6k|  }
_ZNK3ada3url13get_href_sizeEv:
 7482|  14.3k|[[nodiscard]] inline size_t url::get_href_size() const noexcept {
 7483|  14.3k|  size_t size = 0;
 7484|  14.3k|  if (is_special()) {
  ------------------
  |  Branch (7484:7): [True: 7.56k, False: 6.75k]
  ------------------
 7485|  7.56k|    size += ada::scheme::details::is_special_list[type].size() + 1;
 7486|  7.56k|  } else {
 7487|  6.75k|    size += non_special_scheme.size() + 1;
 7488|  6.75k|  }
 7489|  14.3k|  if (host.has_value()) {
  ------------------
  |  Branch (7489:7): [True: 8.50k, False: 5.81k]
  ------------------
 7490|  8.50k|    size += host->size();
 7491|  8.50k|    size += 2;
 7492|  8.50k|    if (has_credentials()) {
  ------------------
  |  Branch (7492:9): [True: 877, False: 7.63k]
  ------------------
 7493|    877|      size += username.size();
 7494|    877|      if (!password.empty()) {
  ------------------
  |  Branch (7494:11): [True: 322, False: 555]
  ------------------
 7495|    322|        size += 1 + password.size();
 7496|    322|      }
 7497|    877|      size += 1;
 7498|    877|    }
 7499|  8.50k|    if (port.has_value()) {
  ------------------
  |  Branch (7499:9): [True: 1.42k, False: 7.08k]
  ------------------
 7500|  1.42k|      size += 1;
 7501|  1.42k|      uint16_t p = *port;
 7502|  1.42k|      size += (p >= 10000)  ? 5
  ------------------
  |  Branch (7502:15): [True: 97, False: 1.32k]
  ------------------
 7503|  1.42k|              : (p >= 1000) ? 4
  ------------------
  |  Branch (7503:17): [True: 106, False: 1.22k]
  ------------------
 7504|  1.32k|              : (p >= 100)  ? 3
  ------------------
  |  Branch (7504:17): [True: 95, False: 1.12k]
  ------------------
 7505|  1.22k|              : (p >= 10)   ? 2
  ------------------
  |  Branch (7505:17): [True: 59, False: 1.06k]
  ------------------
 7506|  1.12k|                            : 1;
 7507|  1.42k|    }
 7508|  8.50k|  } else if (!has_opaque_path && path.starts_with("//")) {
  ------------------
  |  Branch (7508:14): [True: 2.34k, False: 3.46k]
  |  Branch (7508:34): [True: 85, False: 2.25k]
  ------------------
 7509|     85|    size += 2;
 7510|     85|  }
 7511|  14.3k|  size += path.size();
 7512|  14.3k|  if (query.has_value()) {
  ------------------
  |  Branch (7512:7): [True: 621, False: 13.6k]
  ------------------
 7513|    621|    size += 1 + query->size();
 7514|    621|  }
 7515|  14.3k|  if (hash.has_value()) {
  ------------------
  |  Branch (7515:7): [True: 853, False: 13.4k]
  ------------------
 7516|    853|    size += 1 + hash->size();
 7517|    853|  }
 7518|  14.3k|  return size;
 7519|  14.3k|}
_ZN3ada8checkers8is_alphaEc:
 1257|  77.1k|constexpr bool is_alpha(char x) noexcept {
 1258|  77.1k|  return (to_lower(x) >= 'a') && (to_lower(x) <= 'z');
  ------------------
  |  Branch (1258:10): [True: 69.6k, False: 7.48k]
  |  Branch (1258:34): [True: 69.4k, False: 259]
  ------------------
 1259|  77.1k|}
_ZN3ada8checkers8to_lowerEc:
 1255|   146k|constexpr char to_lower(char x) noexcept { return (x | 0x20); }
_ZNR2tl8expectedIN3ada3urlENS1_6errorsEEdeIS2_TnPNSt3__19enable_ifIXntsr3std7is_voidIT_EE5valueEvE4typeELPv0EEERS8_v:
 4012|  3.04k|  TL_EXPECTED_11_CONSTEXPR U& operator*() & {
 4013|  3.04k|    TL_ASSERT(has_value());
  ------------------
  |  | 2052|  3.04k|#define TL_ASSERT(x) assert(x)
  ------------------
  |  Branch (4013:5): [True: 3.04k, False: 0]
  ------------------
 4014|  3.04k|    return val();
 4015|  3.04k|  }
_ZN2tl8expectedIN3ada3urlENS1_6errorsEE3valIS2_TnPNSt3__19enable_ifIXntsr3std7is_voidIT_EE5valueEvE4typeELPv0EEERS8_v:
 3304|  3.04k|  TL_EXPECTED_11_CONSTEXPR U& val() {
 3305|  3.04k|    return this->m_val;
 3306|  3.04k|  }
_ZNK2tl8expectedIN3ada3urlENS1_6errorsEE9has_valueEv:
 4029|  53.9k|  constexpr bool has_value() const noexcept { return this->m_has_val; }
_ZN3ada3urlC2Ev:
 4984|  34.6k|  url() = default;
_ZN3ada3url11copy_schemeERKS0_:
 7390|    657|constexpr void url::copy_scheme(const ada::url& u) {
 7391|    657|  non_special_scheme = u.non_special_scheme;
 7392|    657|  type = u.type;
 7393|    657|}
_ZN3ada3url26update_unencoded_base_hashENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 7332|    658|inline void url::update_unencoded_base_hash(std::string_view input) {
 7333|       |  // We do the percent encoding
 7334|    658|  hash = unicode::percent_encode(input,
 7335|    658|                                 ada::character_sets::FRAGMENT_PERCENT_ENCODE);
 7336|    658|}
_ZN3ada3url12clear_searchEv:
 7365|    484|constexpr void url::clear_search() { query = std::nullopt; }
_ZN3ada3url18update_base_searchENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKh:
 7339|    819|                                    const uint8_t query_percent_encode_set[]) {
 7340|    819|  query = ada::unicode::percent_encode(input, query_percent_encode_set);
 7341|    819|}
_ZN3ada3url20update_base_hostnameENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 7330|     67|inline void url::update_base_hostname(std::string_view input) { host = input; }
_ZN3ada3url20update_base_pathnameENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 7347|  7.03k|inline void url::update_base_pathname(const std::string_view input) {
 7348|  7.03k|  path = input;
 7349|  7.03k|}
_ZN3ada3url10parse_portENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEb:
 7522|  1.40k|                                         bool check_trailing_content) noexcept {
 7523|  1.40k|  ada_log("parse_port('", view, "') ", view.size());
 7524|  1.40k|  if (!view.empty() && view[0] == '-') {
  ------------------
  |  Branch (7524:7): [True: 1.09k, False: 316]
  |  Branch (7524:24): [True: 3, False: 1.08k]
  ------------------
 7525|      3|    ada_log("parse_port: view[0] == '0' && view.size() > 1");
 7526|      3|    is_valid = false;
 7527|      3|    return 0;
 7528|      3|  }
 7529|  1.40k|  uint16_t parsed_port{};
 7530|  1.40k|  auto r = std::from_chars(view.data(), view.data() + view.size(), parsed_port);
 7531|  1.40k|  if (r.ec == std::errc::result_out_of_range) {
  ------------------
  |  Branch (7531:7): [True: 26, False: 1.37k]
  ------------------
 7532|     26|    ada_log("parse_port: r.ec == std::errc::result_out_of_range");
 7533|     26|    is_valid = false;
 7534|     26|    return 0;
 7535|     26|  }
 7536|  1.37k|  ada_log("parse_port: ", parsed_port);
 7537|  1.37k|  const auto consumed = size_t(r.ptr - view.data());
 7538|  1.37k|  ada_log("parse_port: consumed ", consumed);
 7539|  1.37k|  if (check_trailing_content) {
  ------------------
  |  Branch (7539:7): [True: 1.37k, False: 0]
  ------------------
 7540|  1.37k|    is_valid &=
 7541|  1.37k|        (consumed == view.size() || view[consumed] == '/' ||
  ------------------
  |  Branch (7541:10): [True: 856, False: 521]
  |  Branch (7541:37): [True: 427, False: 94]
  ------------------
 7542|     94|         view[consumed] == '?' || (is_special() && view[consumed] == '\\'));
  ------------------
  |  Branch (7542:10): [True: 20, False: 74]
  |  Branch (7542:36): [True: 68, False: 6]
  |  Branch (7542:52): [True: 3, False: 65]
  ------------------
 7543|  1.37k|  }
 7544|  1.37k|  ada_log("parse_port: is_valid = ", is_valid);
 7545|  1.37k|  if (is_valid) {
  ------------------
  |  Branch (7545:7): [True: 1.30k, False: 71]
  ------------------
 7546|       |    // scheme_default_port can return 0, and we should allow 0 as a base port.
 7547|  1.30k|    auto default_port = scheme_default_port();
 7548|  1.30k|    bool is_port_valid = (default_port == 0 && parsed_port == 0) ||
  ------------------
  |  Branch (7548:27): [True: 75, False: 1.23k]
  |  Branch (7548:48): [True: 23, False: 52]
  ------------------
 7549|  1.28k|                         (default_port != parsed_port);
  ------------------
  |  Branch (7549:26): [True: 1.27k, False: 6]
  ------------------
 7550|  1.30k|    port = (r.ec == std::errc() && is_port_valid) ? std::optional(parsed_port)
  ------------------
  |  Branch (7550:13): [True: 967, False: 339]
  |  Branch (7550:36): [True: 961, False: 6]
  ------------------
 7551|  1.30k|                                                  : std::nullopt;
 7552|  1.30k|  }
 7553|  1.37k|  return consumed;
 7554|  1.40k|}
_ZNK3ada8url_base19scheme_default_portEv:
 7201|  3.75k|url_base::scheme_default_port() const noexcept {
 7202|  3.75k|  return scheme::get_special_port(type);
 7203|  3.75k|}
_ZN3ada6scheme16get_special_portENS0_4typeE:
 6706|  3.75k|constexpr uint16_t get_special_port(ada::scheme::type type) noexcept {
 6707|  3.75k|  return details::special_ports[int(type)];
 6708|  3.75k|}
_ZNK3ada3url12get_pathnameEv:
 7253|    239|[[nodiscard]] constexpr std::string_view url::get_pathname() const noexcept {
 7254|    239|  return path;
 7255|    239|}
_ZN3ada8checkers23is_windows_drive_letterENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 1261|  11.8k|constexpr bool is_windows_drive_letter(std::string_view input) noexcept {
 1262|  11.8k|  return input.size() >= 2 &&
  ------------------
  |  Branch (1262:10): [True: 7.94k, False: 3.89k]
  ------------------
 1263|  7.94k|         (is_alpha(input[0]) && ((input[1] == ':') || (input[1] == '|'))) &&
  ------------------
  |  Branch (1263:11): [True: 3.29k, False: 4.64k]
  |  Branch (1263:34): [True: 951, False: 2.34k]
  |  Branch (1263:55): [True: 572, False: 1.77k]
  ------------------
 1264|  1.52k|         ((input.size() == 2) || (input[2] == '/' || input[2] == '\\' ||
  ------------------
  |  Branch (1264:11): [True: 532, False: 991]
  |  Branch (1264:35): [True: 127, False: 864]
  |  Branch (1264:54): [True: 28, False: 836]
  ------------------
 1265|    836|                                  input[2] == '?' || input[2] == '#'));
  ------------------
  |  Branch (1265:35): [True: 5, False: 831]
  |  Branch (1265:54): [True: 0, False: 831]
  ------------------
 1266|  11.8k|}
_ZN3ada8checkers34is_normalized_windows_drive_letterENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 1269|  2.12k|    std::string_view input) noexcept {
 1270|  2.12k|  return input.size() == 2 && (is_alpha(input[0]) && (input[1] == ':'));
  ------------------
  |  Branch (1270:10): [True: 918, False: 1.21k]
  |  Branch (1270:32): [True: 764, False: 154]
  |  Branch (1270:54): [True: 656, False: 108]
  ------------------
 1271|  2.12k|}
_ZN3ada3url20set_protocol_as_fileEv:
 7375|  2.71k|constexpr void url::set_protocol_as_file() { type = ada::scheme::type::FILE; }
_ZN3ada3url14clear_pathnameEv:
 7363|     20|constexpr void url::clear_pathname() { path.clear(); }
_ZN3ada7helpers14leading_zeroesEj:
 1934|  34.1k|inline int leading_zeroes(uint32_t input_num) noexcept {
 1935|       |#if ADA_REGULAR_VISUAL_STUDIO
 1936|       |  unsigned long leading_zero(0);
 1937|       |  unsigned long in(input_num);
 1938|       |  return _BitScanReverse(&leading_zero, in) ? int(31 - leading_zero) : 32;
 1939|       |#else
 1940|  34.1k|  return __builtin_clz(input_num);
 1941|  34.1k|#endif  // ADA_REGULAR_VISUAL_STUDIO
 1942|  34.1k|}
_ZN3ada14url_aggregator7reserveEj:
 8901|  34.1k|constexpr void ada::url_aggregator::reserve(uint32_t capacity) {
 8902|  34.1k|  buffer.reserve(capacity);
 8903|  34.1k|}
_ZN3ada14url_aggregator20update_base_pathnameENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8391|  11.9k|inline void url_aggregator::update_base_pathname(const std::string_view input) {
 8392|  11.9k|  ada_log("url_aggregator::update_base_pathname '", input, "' [", input.size(),
 8393|  11.9k|          " bytes] \n", to_diagram());
 8394|  11.9k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 8395|  11.9k|  ADA_ASSERT_TRUE(validate());
 8396|       |
 8397|  11.9k|  const bool begins_with_dashdash = input.starts_with("//");
 8398|  11.9k|  if (!begins_with_dashdash && has_dash_dot()) {
  ------------------
  |  Branch (8398:7): [True: 11.6k, False: 296]
  |  Branch (8398:32): [True: 6, False: 11.6k]
  ------------------
 8399|       |    // We must delete the ./
 8400|      6|    delete_dash_dot();
 8401|      6|  }
 8402|       |
 8403|  11.9k|  if (begins_with_dashdash && !has_opaque_path && !has_authority() &&
  ------------------
  |  Branch (8403:7): [True: 296, False: 11.6k]
  |  Branch (8403:31): [True: 295, False: 1]
  |  Branch (8403:51): [True: 64, False: 231]
  ------------------
 8404|     64|      !has_dash_dot()) {
  ------------------
  |  Branch (8404:7): [True: 56, False: 8]
  ------------------
 8405|       |    // If url's host is null, url does not have an opaque path, url's path's
 8406|       |    // size is greater than 1, then append U+002F (/) followed by U+002E (.) to
 8407|       |    // output.
 8408|     56|    buffer.insert(components.pathname_start, "/.");
 8409|     56|    components.pathname_start += 2;
 8410|     56|    if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8410:9): [True: 0, False: 56]
  ------------------
 8411|      0|      components.search_start += 2;
 8412|      0|    }
 8413|     56|    if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8413:9): [True: 0, False: 56]
  ------------------
 8414|      0|      components.hash_start += 2;
 8415|      0|    }
 8416|     56|  }
 8417|       |
 8418|  11.9k|  uint32_t difference = replace_and_resize(
 8419|  11.9k|      components.pathname_start,
 8420|  11.9k|      components.pathname_start + get_pathname_length(), input);
 8421|  11.9k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8421:7): [True: 0, False: 11.9k]
  ------------------
 8422|      0|    components.search_start += difference;
 8423|      0|  }
 8424|  11.9k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8424:7): [True: 0, False: 11.9k]
  ------------------
 8425|      0|    components.hash_start += difference;
 8426|      0|  }
 8427|  11.9k|  ADA_ASSERT_TRUE(validate());
 8428|  11.9k|}
_ZN3ada14url_aggregator18replace_and_resizeEjjNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8234|  39.6k|    uint32_t start, uint32_t end, std::string_view input) {
 8235|  39.6k|  uint32_t current_length = end - start;
 8236|  39.6k|  uint32_t input_size = uint32_t(input.size());
 8237|  39.6k|  uint32_t new_difference = input_size - current_length;
 8238|       |
 8239|  39.6k|  if (current_length == 0) {
  ------------------
  |  Branch (8239:7): [True: 36.4k, False: 3.14k]
  ------------------
 8240|  36.4k|    buffer.insert(start, input);
 8241|  36.4k|  } else if (input_size == current_length) {
  ------------------
  |  Branch (8241:14): [True: 422, False: 2.72k]
  ------------------
 8242|    422|    buffer.replace(start, input_size, input);
 8243|  2.72k|  } else if (input_size < current_length) {
  ------------------
  |  Branch (8243:14): [True: 559, False: 2.16k]
  ------------------
 8244|    559|    buffer.erase(start, current_length - input_size);
 8245|    559|    buffer.replace(start, input_size, input);
 8246|  2.16k|  } else {
 8247|  2.16k|    buffer.replace(start, current_length, input.substr(0, current_length));
 8248|  2.16k|    buffer.insert(start + current_length, input.substr(current_length));
 8249|  2.16k|  }
 8250|       |
 8251|  39.6k|  return new_difference;
 8252|  39.6k|}
_ZNK3ada14url_aggregator19get_pathname_lengthEv:
 8283|  11.9k|url_aggregator::get_pathname_length() const noexcept {
 8284|  11.9k|  ada_log("url_aggregator::get_pathname_length");
 8285|  11.9k|  uint32_t ending_index = uint32_t(buffer.size());
 8286|  11.9k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8286:7): [True: 0, False: 11.9k]
  ------------------
 8287|      0|    ending_index = components.search_start;
 8288|  11.9k|  } else if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8288:14): [True: 0, False: 11.9k]
  ------------------
 8289|      0|    ending_index = components.hash_start;
 8290|      0|  }
 8291|  11.9k|  return ending_index - components.pathname_start;
 8292|  11.9k|}
_ZNK3ada14url_aggregator12get_pathnameEv:
 9228|  5.80k|    ada_lifetime_bound {
 9229|  5.80k|  ada_log("url_aggregator::get_pathname pathname_start = ",
 9230|  5.80k|          components.pathname_start, " buffer.size() = ", buffer.size(),
 9231|  5.80k|          " components.search_start = ", components.search_start,
 9232|  5.80k|          " components.hash_start = ", components.hash_start);
 9233|  5.80k|  auto ending_index = uint32_t(buffer.size());
 9234|  5.80k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9234:7): [True: 229, False: 5.57k]
  ------------------
 9235|    229|    ending_index = components.search_start;
 9236|  5.57k|  } else if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9236:14): [True: 72, False: 5.50k]
  ------------------
 9237|     72|    ending_index = components.hash_start;
 9238|     72|  }
 9239|  5.80k|  return helpers::substring(buffer, components.pathname_start, ending_index);
 9240|  5.80k|}
_ZN3ada14url_aggregator18update_base_searchENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8299|    187|inline void url_aggregator::update_base_search(std::string_view input) {
 8300|    187|  ada_log("url_aggregator::update_base_search ", input);
 8301|    187|  ADA_ASSERT_TRUE(validate());
 8302|    187|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 8303|    187|  if (input.empty()) {
  ------------------
  |  Branch (8303:7): [True: 0, False: 187]
  ------------------
 8304|      0|    clear_search();
 8305|      0|    return;
 8306|      0|  }
 8307|       |
 8308|    187|  if (input[0] == '?') {
  ------------------
  |  Branch (8308:7): [True: 187, False: 0]
  ------------------
 8309|    187|    input.remove_prefix(1);
 8310|    187|  }
 8311|       |
 8312|    187|  if (components.hash_start == url_components::omitted) {
  ------------------
  |  Branch (8312:7): [True: 187, False: 0]
  ------------------
 8313|    187|    if (components.search_start == url_components::omitted) {
  ------------------
  |  Branch (8313:9): [True: 187, False: 0]
  ------------------
 8314|    187|      components.search_start = uint32_t(buffer.size());
 8315|    187|      buffer += "?";
 8316|    187|    } else {
 8317|      0|      buffer.resize(components.search_start + 1);
 8318|      0|    }
 8319|       |
 8320|    187|    buffer.append(input);
 8321|    187|  } else {
 8322|      0|    if (components.search_start == url_components::omitted) {
  ------------------
  |  Branch (8322:9): [True: 0, False: 0]
  ------------------
 8323|      0|      components.search_start = components.hash_start;
 8324|      0|    } else {
 8325|      0|      buffer.erase(components.search_start,
 8326|      0|                   components.hash_start - components.search_start);
 8327|      0|      components.hash_start = components.search_start;
 8328|      0|    }
 8329|       |
 8330|      0|    buffer.insert(components.search_start, "?");
 8331|      0|    buffer.insert(components.search_start + 1, input);
 8332|      0|    components.hash_start += uint32_t(input.size() + 1);  // Do not forget `?`
 8333|      0|  }
 8334|       |
 8335|    187|  ADA_ASSERT_TRUE(validate());
 8336|    187|}
_ZN3ada14url_aggregator26update_unencoded_base_hashENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8210|    744|inline void url_aggregator::update_unencoded_base_hash(std::string_view input) {
 8211|    744|  ada_log("url_aggregator::update_unencoded_base_hash ", input, " [",
 8212|    744|          input.size(), " bytes], buffer is '", buffer, "' [", buffer.size(),
 8213|    744|          " bytes] components.hash_start = ", components.hash_start);
 8214|    744|  ADA_ASSERT_TRUE(validate());
 8215|    744|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 8216|    744|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8216:7): [True: 0, False: 744]
  ------------------
 8217|      0|    buffer.resize(components.hash_start);
 8218|      0|  }
 8219|    744|  components.hash_start = uint32_t(buffer.size());
 8220|    744|  buffer += "#";
 8221|    744|  bool encoding_required = unicode::percent_encode<true>(
 8222|    744|      input, ada::character_sets::FRAGMENT_PERCENT_ENCODE, buffer);
 8223|       |  // When encoding_required is false, then buffer is left unchanged, and percent
 8224|       |  // encoding was not deemed required.
 8225|    744|  if (!encoding_required) {
  ------------------
  |  Branch (8225:7): [True: 560, False: 184]
  ------------------
 8226|    560|    buffer.append(input);
 8227|    560|  }
 8228|    744|  ada_log("url_aggregator::update_unencoded_base_hash final buffer is '",
 8229|    744|          buffer, "' [", buffer.size(), " bytes]");
 8230|    744|  ADA_ASSERT_TRUE(validate());
 8231|    744|}
_ZN3ada14url_aggregator20append_base_passwordENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8619|  7.06k|inline void url_aggregator::append_base_password(const std::string_view input) {
 8620|  7.06k|  ada_log("url_aggregator::append_base_password ", input, " ", to_string(),
 8621|  7.06k|          "\n", to_diagram());
 8622|  7.06k|  ADA_ASSERT_TRUE(validate());
 8623|  7.06k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 8624|       |#if ADA_DEVELOPMENT_CHECKS
 8625|       |  // computing the expected password.
 8626|       |  std::string password_expected = std::string(get_password());
 8627|       |  password_expected.append(input);
 8628|       |#endif  // ADA_DEVELOPMENT_CHECKS
 8629|  7.06k|  add_authority_slashes_if_needed();
 8630|       |
 8631|       |  // If input is empty, do nothing.
 8632|  7.06k|  if (input.empty()) {
  ------------------
  |  Branch (8632:7): [True: 1.87k, False: 5.18k]
  ------------------
 8633|  1.87k|    return;
 8634|  1.87k|  }
 8635|       |
 8636|  5.18k|  uint32_t difference = uint32_t(input.size());
 8637|  5.18k|  if (has_password()) {
  ------------------
  |  Branch (8637:7): [True: 4.64k, False: 538]
  ------------------
 8638|  4.64k|    buffer.insert(components.host_start, input);
 8639|  4.64k|  } else {
 8640|    538|    difference++;  // Increment for ":"
 8641|    538|    buffer.insert(components.username_end, ":");
 8642|    538|    buffer.insert(components.username_end + 1, input);
 8643|    538|  }
 8644|  5.18k|  components.host_start += difference;
 8645|       |
 8646|       |  // The following line is required to add "@" to hostname. When updating
 8647|       |  // password if hostname does not start with "@", it is "append_base_password"s
 8648|       |  // responsibility to set it.
 8649|  5.18k|  if (buffer[components.host_start] != '@') {
  ------------------
  |  Branch (8649:7): [True: 356, False: 4.83k]
  ------------------
 8650|    356|    buffer.insert(components.host_start, "@");
 8651|    356|    difference++;
 8652|    356|  }
 8653|       |
 8654|  5.18k|  components.host_end += difference;
 8655|  5.18k|  components.pathname_start += difference;
 8656|  5.18k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8656:7): [True: 0, False: 5.18k]
  ------------------
 8657|      0|    components.search_start += difference;
 8658|      0|  }
 8659|  5.18k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8659:7): [True: 0, False: 5.18k]
  ------------------
 8660|      0|    components.hash_start += difference;
 8661|      0|  }
 8662|       |#if ADA_DEVELOPMENT_CHECKS
 8663|       |  std::string password_after(get_password());
 8664|       |  ADA_ASSERT_EQUAL(
 8665|       |      password_expected, password_after,
 8666|       |      "append_base_password problem after inserting " + std::string(input));
 8667|       |#endif  // ADA_DEVELOPMENT_CHECKS
 8668|  5.18k|  ADA_ASSERT_TRUE(validate());
 8669|  5.18k|}
_ZN3ada14url_aggregator31add_authority_slashes_if_neededEv:
 8875|  44.9k|inline void ada::url_aggregator::add_authority_slashes_if_needed() {
 8876|  44.9k|  ada_log("url_aggregator::add_authority_slashes_if_needed");
 8877|  44.9k|  ADA_ASSERT_TRUE(validate());
 8878|       |  // Protocol setter will insert `http:` to the URL. It is up to hostname setter
 8879|       |  // to insert
 8880|       |  // `//` initially to the buffer, since it depends on the hostname existence.
 8881|  44.9k|  if (has_authority()) {
  ------------------
  |  Branch (8881:7): [True: 22.9k, False: 21.9k]
  ------------------
 8882|  22.9k|    return;
 8883|  22.9k|  }
 8884|       |  // Performance: the common case is components.protocol_end == buffer.size()
 8885|       |  // Optimization opportunity: in many cases, the "//" is part of the input and
 8886|       |  // the insert could be fused with another insert.
 8887|  21.9k|  buffer.insert(components.protocol_end, "//");
 8888|  21.9k|  components.username_end += 2;
 8889|  21.9k|  components.host_start += 2;
 8890|  21.9k|  components.host_end += 2;
 8891|  21.9k|  components.pathname_start += 2;
 8892|  21.9k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8892:7): [True: 0, False: 21.9k]
  ------------------
 8893|      0|    components.search_start += 2;
 8894|      0|  }
 8895|  21.9k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8895:7): [True: 0, False: 21.9k]
  ------------------
 8896|      0|    components.hash_start += 2;
 8897|      0|  }
 8898|  21.9k|  ADA_ASSERT_TRUE(validate());
 8899|  21.9k|}
_ZN3ada14url_aggregator20append_base_usernameENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8501|  10.2k|inline void url_aggregator::append_base_username(const std::string_view input) {
 8502|  10.2k|  ada_log("url_aggregator::append_base_username ", input);
 8503|  10.2k|  ADA_ASSERT_TRUE(validate());
 8504|  10.2k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 8505|       |#if ADA_DEVELOPMENT_CHECKS
 8506|       |  // computing the expected password.
 8507|       |  std::string username_expected(get_username());
 8508|       |  username_expected.append(input);
 8509|       |#endif  // ADA_DEVELOPMENT_CHECKS
 8510|  10.2k|  add_authority_slashes_if_needed();
 8511|       |
 8512|       |  // If input is empty, do nothing.
 8513|  10.2k|  if (input.empty()) {
  ------------------
  |  Branch (8513:7): [True: 2.91k, False: 7.28k]
  ------------------
 8514|  2.91k|    return;
 8515|  2.91k|  }
 8516|       |
 8517|  7.28k|  uint32_t difference = uint32_t(input.size());
 8518|  7.28k|  buffer.insert(components.username_end, input);
 8519|  7.28k|  components.username_end += difference;
 8520|  7.28k|  components.host_start += difference;
 8521|       |
 8522|  7.28k|  if (buffer[components.host_start] != '@' &&
  ------------------
  |  Branch (8522:7): [True: 959, False: 6.32k]
  ------------------
 8523|    959|      components.host_start != components.host_end) {
  ------------------
  |  Branch (8523:7): [True: 959, False: 0]
  ------------------
 8524|    959|    buffer.insert(components.host_start, "@");
 8525|    959|    difference++;
 8526|    959|  }
 8527|       |
 8528|  7.28k|  components.host_end += difference;
 8529|  7.28k|  components.pathname_start += difference;
 8530|  7.28k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8530:7): [True: 0, False: 7.28k]
  ------------------
 8531|      0|    components.search_start += difference;
 8532|      0|  }
 8533|  7.28k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8533:7): [True: 0, False: 7.28k]
  ------------------
 8534|      0|    components.hash_start += difference;
 8535|      0|  }
 8536|       |#if ADA_DEVELOPMENT_CHECKS
 8537|       |  std::string username_after(get_username());
 8538|       |  ADA_ASSERT_EQUAL(
 8539|       |      username_expected, username_after,
 8540|       |      "append_base_username problem after inserting " + std::string(input));
 8541|       |#endif  // ADA_DEVELOPMENT_CHECKS
 8542|  7.28k|  ADA_ASSERT_TRUE(validate());
 8543|  7.28k|}
_ZN3ada14url_aggregator21update_base_authorityENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEERKNS_14url_componentsE:
 8152|  1.12k|    std::string_view base_buffer, const ada::url_components& base) {
 8153|  1.12k|  std::string_view input = base_buffer.substr(
 8154|  1.12k|      base.protocol_end, base.host_start - base.protocol_end);
 8155|  1.12k|  ada_log("url_aggregator::update_base_authority ", input);
 8156|       |
 8157|  1.12k|  bool input_starts_with_dash = input.starts_with("//");
 8158|  1.12k|  uint32_t diff = components.host_start - components.protocol_end;
 8159|       |
 8160|  1.12k|  buffer.erase(components.protocol_end,
 8161|  1.12k|               components.host_start - components.protocol_end);
 8162|  1.12k|  components.username_end = components.protocol_end;
 8163|       |
 8164|  1.12k|  if (input_starts_with_dash) {
  ------------------
  |  Branch (8164:7): [True: 756, False: 364]
  ------------------
 8165|    756|    input.remove_prefix(2);
 8166|    756|    diff += 2;  // add "//"
 8167|    756|    buffer.insert(components.protocol_end, "//");
 8168|    756|    components.username_end += 2;
 8169|    756|  }
 8170|       |
 8171|  1.12k|  size_t password_delimiter = input.find(':');
 8172|       |
 8173|       |  // Check if input contains both username and password by checking the
 8174|       |  // delimiter: ":" A typical input that contains authority would be "user:pass"
 8175|  1.12k|  if (password_delimiter != std::string_view::npos) {
  ------------------
  |  Branch (8175:7): [True: 43, False: 1.07k]
  ------------------
 8176|       |    // Insert both username and password
 8177|     43|    std::string_view username = input.substr(0, password_delimiter);
 8178|     43|    std::string_view password = input.substr(password_delimiter + 1);
 8179|       |
 8180|     43|    buffer.insert(components.protocol_end + diff, username);
 8181|     43|    diff += uint32_t(username.size());
 8182|     43|    buffer.insert(components.protocol_end + diff, ":");
 8183|     43|    components.username_end = components.protocol_end + diff;
 8184|     43|    buffer.insert(components.protocol_end + diff + 1, password);
 8185|     43|    diff += uint32_t(password.size()) + 1;
 8186|  1.07k|  } else if (!input.empty()) {
  ------------------
  |  Branch (8186:14): [True: 40, False: 1.03k]
  ------------------
 8187|       |    // Insert only username
 8188|     40|    buffer.insert(components.protocol_end + diff, input);
 8189|     40|    components.username_end =
 8190|     40|        components.protocol_end + diff + uint32_t(input.size());
 8191|     40|    diff += uint32_t(input.size());
 8192|     40|  }
 8193|       |
 8194|  1.12k|  components.host_start += diff;
 8195|       |
 8196|  1.12k|  if (buffer.size() > base.host_start && buffer[base.host_start] != '@') {
  ------------------
  |  Branch (8196:7): [True: 0, False: 1.12k]
  |  Branch (8196:42): [True: 0, False: 0]
  ------------------
 8197|      0|    buffer.insert(components.host_start, "@");
 8198|      0|    diff++;
 8199|      0|  }
 8200|  1.12k|  components.host_end += diff;
 8201|  1.12k|  components.pathname_start += diff;
 8202|  1.12k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8202:7): [True: 0, False: 1.12k]
  ------------------
 8203|      0|    components.search_start += diff;
 8204|      0|  }
 8205|  1.12k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8205:7): [True: 0, False: 1.12k]
  ------------------
 8206|      0|    components.hash_start += diff;
 8207|      0|  }
 8208|  1.12k|}
_ZNK3ada14url_aggregator8get_hrefEv:
 8979|  18.8k|    const noexcept ada_lifetime_bound {
 8980|  18.8k|  ada_log("url_aggregator::get_href");
 8981|  18.8k|  return buffer;
 8982|  18.8k|}
_ZNK3ada14url_aggregator14get_componentsEv:
 8861|  1.12k|url_aggregator::get_components() const noexcept {
 8862|  1.12k|  return components;
 8863|  1.12k|}
_ZN3ada14url_aggregator24update_host_to_base_hostENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9247|  1.78k|void url_aggregator::update_host_to_base_host(const std::string_view input) {
 9248|  1.78k|  ada_log("url_aggregator::update_host_to_base_host ", input);
 9249|  1.78k|  ADA_ASSERT_TRUE(validate());
 9250|  1.78k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 9251|  1.78k|  if (type != ada::scheme::type::FILE) {
  ------------------
  |  Branch (9251:7): [True: 1.12k, False: 668]
  ------------------
 9252|       |    // Let host be the result of host parsing host_view with url is not special.
 9253|  1.12k|    if (input.empty() && !is_special()) {
  ------------------
  |  Branch (9253:9): [True: 376, False: 744]
  |  Branch (9253:26): [True: 376, False: 0]
  ------------------
 9254|    376|      if (has_hostname()) {
  ------------------
  |  Branch (9254:11): [True: 12, False: 364]
  ------------------
 9255|     12|        clear_hostname();
 9256|    364|      } else if (has_dash_dot()) {
  ------------------
  |  Branch (9256:18): [True: 0, False: 364]
  ------------------
 9257|      0|        add_authority_slashes_if_needed();
 9258|      0|        delete_dash_dot();
 9259|      0|      }
 9260|    376|      return;
 9261|    376|    }
 9262|  1.12k|  }
 9263|  1.41k|  update_base_hostname(input);
 9264|  1.41k|  ADA_ASSERT_TRUE(validate());
 9265|  1.41k|  return;
 9266|  1.78k|}
_ZN3ada14url_aggregator14clear_hostnameEv:
 8802|     12|constexpr void url_aggregator::clear_hostname() {
 8803|     12|  ada_log("url_aggregator::clear_hostname");
 8804|     12|  ADA_ASSERT_TRUE(validate());
 8805|     12|  if (!has_authority()) {
  ------------------
  |  Branch (8805:7): [True: 0, False: 12]
  ------------------
 8806|      0|    return;
 8807|      0|  }
 8808|     12|  ADA_ASSERT_TRUE(has_authority());
 8809|       |
 8810|     12|  uint32_t hostname_length = components.host_end - components.host_start;
 8811|     12|  uint32_t start = components.host_start;
 8812|       |
 8813|       |  // If hostname starts with "@", we should not remove that character.
 8814|     12|  if (hostname_length > 0 && buffer[start] == '@') {
  ------------------
  |  Branch (8814:7): [True: 0, False: 12]
  |  Branch (8814:30): [True: 0, False: 0]
  ------------------
 8815|      0|    start++;
 8816|      0|    hostname_length--;
 8817|      0|  }
 8818|     12|  buffer.erase(start, hostname_length);
 8819|     12|  components.host_end = start;
 8820|     12|  components.pathname_start -= hostname_length;
 8821|     12|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8821:7): [True: 0, False: 12]
  ------------------
 8822|      0|    components.search_start -= hostname_length;
 8823|      0|  }
 8824|     12|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8824:7): [True: 0, False: 12]
  ------------------
 8825|      0|    components.hash_start -= hostname_length;
 8826|      0|  }
 8827|       |#if ADA_DEVELOPMENT_CHECKS
 8828|       |  ADA_ASSERT_EQUAL(get_hostname(), "",
 8829|       |                   "hostname should have been cleared on buffer=" + buffer +
 8830|       |                       " with " + components.to_string() + "\n" + to_diagram());
 8831|       |#endif
 8832|     12|  ADA_ASSERT_TRUE(has_authority());
 8833|     12|  ADA_ASSERT_EQUAL(has_empty_hostname(), true,
 8834|     12|                   "hostname should have been cleared on buffer=" + buffer +
 8835|     12|                       " with " + components.to_string() + "\n" + to_diagram());
 8836|     12|  ADA_ASSERT_TRUE(validate());
 8837|     12|}
_ZN3ada14url_aggregator16update_base_portEj:
 8671|  2.88k|inline void url_aggregator::update_base_port(uint32_t input) {
 8672|  2.88k|  ada_log("url_aggregator::update_base_port");
 8673|  2.88k|  ADA_ASSERT_TRUE(validate());
 8674|  2.88k|  if (input == url_components::omitted) {
  ------------------
  |  Branch (8674:7): [True: 1.08k, False: 1.79k]
  ------------------
 8675|  1.08k|    clear_port();
 8676|  1.08k|    return;
 8677|  1.08k|  }
 8678|       |  // calling std::to_string(input.value()) is unfortunate given that the port
 8679|       |  // value is probably already available as a string.
 8680|  1.79k|  std::string value = helpers::concat(":", std::to_string(input));
 8681|  1.79k|  uint32_t difference = uint32_t(value.size());
 8682|       |
 8683|  1.79k|  if (components.port != url_components::omitted) {
  ------------------
  |  Branch (8683:7): [True: 0, False: 1.79k]
  ------------------
 8684|      0|    difference -= components.pathname_start - components.host_end;
 8685|      0|    buffer.erase(components.host_end,
 8686|      0|                 components.pathname_start - components.host_end);
 8687|      0|  }
 8688|       |
 8689|  1.79k|  buffer.insert(components.host_end, value);
 8690|  1.79k|  components.pathname_start += difference;
 8691|  1.79k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8691:7): [True: 0, False: 1.79k]
  ------------------
 8692|      0|    components.search_start += difference;
 8693|      0|  }
 8694|  1.79k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8694:7): [True: 0, False: 1.79k]
  ------------------
 8695|      0|    components.hash_start += difference;
 8696|      0|  }
 8697|  1.79k|  components.port = input;
 8698|  1.79k|  ADA_ASSERT_TRUE(validate());
 8699|  1.79k|}
_ZN3ada7helpers6concatIJPKcNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEEEESA_DpT_:
 1924|  1.79k|std::string concat(Args... args) {
 1925|  1.79k|  std::string answer;
 1926|  1.79k|  inner_concat(answer, args...);
 1927|  1.79k|  return answer;
 1928|  1.79k|}
_ZN3ada7helpers12inner_concatIPKcJNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEEEEvRSA_T_DpT0_:
 1913|  1.79k|inline void inner_concat(std::string& buffer, T t, Args... args) {
 1914|  1.79k|  buffer.append(t);
 1915|  1.79k|  return inner_concat(buffer, args...);
 1916|  1.79k|}
_ZN3ada7helpers12inner_concatINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEJEEEvRS8_T_:
 1905|  1.79k|inline void inner_concat(std::string& buffer, T t) {
 1906|  1.79k|  buffer.append(t);
 1907|  1.79k|}
_ZNK3ada14url_aggregator18retrieve_base_portEv:
 8720|  1.12k|[[nodiscard]] inline uint32_t url_aggregator::retrieve_base_port() const {
 8721|  1.12k|  ada_log("url_aggregator::retrieve_base_port");
 8722|  1.12k|  return components.port;
 8723|  1.12k|}
_ZN3ada14url_aggregator12clear_searchEv:
 8725|    968|inline void url_aggregator::clear_search() {
 8726|    968|  ada_log("url_aggregator::clear_search");
 8727|    968|  ADA_ASSERT_TRUE(validate());
 8728|    968|  if (components.search_start == url_components::omitted) {
  ------------------
  |  Branch (8728:7): [True: 907, False: 61]
  ------------------
 8729|    907|    return;
 8730|    907|  }
 8731|       |
 8732|     61|  if (components.hash_start == url_components::omitted) {
  ------------------
  |  Branch (8732:7): [True: 61, False: 0]
  ------------------
 8733|     61|    buffer.resize(components.search_start);
 8734|     61|  } else {
 8735|      0|    buffer.erase(components.search_start,
 8736|      0|                 components.hash_start - components.search_start);
 8737|      0|    components.hash_start = components.search_start;
 8738|      0|  }
 8739|       |
 8740|     61|  components.search_start = url_components::omitted;
 8741|       |
 8742|       |#if ADA_DEVELOPMENT_CHECKS
 8743|       |  ADA_ASSERT_EQUAL(get_search(), "",
 8744|       |                   "search should have been cleared on buffer=" + buffer +
 8745|       |                       " with " + components.to_string() + "\n" + to_diagram());
 8746|       |#endif
 8747|     61|  ADA_ASSERT_TRUE(validate());
 8748|     61|}
_ZN3ada14url_aggregator18update_base_searchENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKh:
 8339|    819|    std::string_view input, const uint8_t query_percent_encode_set[]) {
 8340|    819|  ada_log("url_aggregator::update_base_search ", input,
 8341|    819|          " with encoding parameter ", to_string(), "\n", to_diagram());
 8342|    819|  ADA_ASSERT_TRUE(validate());
 8343|    819|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 8344|       |
 8345|    819|  if (components.hash_start == url_components::omitted) {
  ------------------
  |  Branch (8345:7): [True: 819, False: 0]
  ------------------
 8346|    819|    if (components.search_start == url_components::omitted) {
  ------------------
  |  Branch (8346:9): [True: 796, False: 23]
  ------------------
 8347|    796|      components.search_start = uint32_t(buffer.size());
 8348|    796|      buffer += "?";
 8349|    796|    } else {
 8350|     23|      buffer.resize(components.search_start + 1);
 8351|     23|    }
 8352|       |
 8353|    819|    bool encoding_required =
 8354|    819|        unicode::percent_encode<true>(input, query_percent_encode_set, buffer);
 8355|       |    // When encoding_required is false, then buffer is left unchanged, and
 8356|       |    // percent encoding was not deemed required.
 8357|    819|    if (!encoding_required) {
  ------------------
  |  Branch (8357:9): [True: 574, False: 245]
  ------------------
 8358|    574|      buffer.append(input);
 8359|    574|    }
 8360|    819|  } else {
 8361|      0|    if (components.search_start == url_components::omitted) {
  ------------------
  |  Branch (8361:9): [True: 0, False: 0]
  ------------------
 8362|      0|      components.search_start = components.hash_start;
 8363|      0|    } else {
 8364|      0|      buffer.erase(components.search_start,
 8365|      0|                   components.hash_start - components.search_start);
 8366|      0|      components.hash_start = components.search_start;
 8367|      0|    }
 8368|       |
 8369|      0|    buffer.insert(components.search_start, "?");
 8370|      0|    size_t idx =
 8371|      0|        ada::unicode::percent_encode_index(input, query_percent_encode_set);
 8372|      0|    if (idx == input.size()) {
  ------------------
  |  Branch (8372:9): [True: 0, False: 0]
  ------------------
 8373|      0|      buffer.insert(components.search_start + 1, input);
 8374|      0|      components.hash_start += uint32_t(input.size() + 1);  // Do not forget `?`
 8375|      0|    } else {
 8376|      0|      buffer.insert(components.search_start + 1, input, 0, idx);
 8377|      0|      input.remove_prefix(idx);
 8378|       |      // We only create a temporary string if we need percent encoding and
 8379|       |      // we attempt to create as small a temporary string as we can.
 8380|      0|      std::string encoded =
 8381|      0|          ada::unicode::percent_encode(input, query_percent_encode_set);
 8382|      0|      buffer.insert(components.search_start + idx + 1, encoded);
 8383|      0|      components.hash_start +=
 8384|      0|          uint32_t(encoded.size() + idx + 1);  // Do not forget `?`
 8385|      0|    }
 8386|      0|  }
 8387|       |
 8388|    819|  ADA_ASSERT_TRUE(validate());
 8389|    819|}
_ZN3ada14url_aggregator20update_base_hostnameENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8254|  27.6k|inline void url_aggregator::update_base_hostname(const std::string_view input) {
 8255|  27.6k|  ada_log("url_aggregator::update_base_hostname ", input, " [", input.size(),
 8256|  27.6k|          " bytes], buffer is '", buffer, "' [", buffer.size(), " bytes]");
 8257|  27.6k|  ADA_ASSERT_TRUE(validate());
 8258|  27.6k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 8259|       |
 8260|       |  // This next line is required for when parsing a URL like `foo://`
 8261|  27.6k|  add_authority_slashes_if_needed();
 8262|       |
 8263|  27.6k|  bool has_credentials = components.protocol_end + 2 < components.host_start;
 8264|  27.6k|  uint32_t new_difference =
 8265|  27.6k|      replace_and_resize(components.host_start, components.host_end, input);
 8266|       |
 8267|  27.6k|  if (has_credentials) {
  ------------------
  |  Branch (8267:7): [True: 1.03k, False: 26.6k]
  ------------------
 8268|  1.03k|    buffer.insert(components.host_start, "@");
 8269|  1.03k|    new_difference++;
 8270|  1.03k|  }
 8271|  27.6k|  components.host_end += new_difference;
 8272|  27.6k|  components.pathname_start += new_difference;
 8273|  27.6k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8273:7): [True: 0, False: 27.6k]
  ------------------
 8274|      0|    components.search_start += new_difference;
 8275|      0|  }
 8276|  27.6k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8276:7): [True: 0, False: 27.6k]
  ------------------
 8277|      0|    components.hash_start += new_difference;
 8278|      0|  }
 8279|  27.6k|  ADA_ASSERT_TRUE(validate());
 8280|  27.6k|}
_ZN3ada14url_aggregator10parse_portENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEb:
 8989|  2.63k|url_aggregator::parse_port(std::string_view view, bool check_trailing_content) {
 8990|  2.63k|  ada_log("url_aggregator::parse_port('", view, "') ", view.size());
 8991|  2.63k|  if (!view.empty() && view[0] == '-') {
  ------------------
  |  Branch (8991:7): [True: 2.00k, False: 629]
  |  Branch (8991:24): [True: 6, False: 1.99k]
  ------------------
 8992|      6|    ada_log("parse_port: view[0] == '0' && view.size() > 1");
 8993|      6|    is_valid = false;
 8994|      6|    return 0;
 8995|      6|  }
 8996|  2.62k|  uint16_t parsed_port{};
 8997|  2.62k|  auto r = std::from_chars(view.data(), view.data() + view.size(), parsed_port);
 8998|  2.62k|  if (r.ec == std::errc::result_out_of_range) {
  ------------------
  |  Branch (8998:7): [True: 48, False: 2.57k]
  ------------------
 8999|     48|    ada_log("parse_port: r.ec == std::errc::result_out_of_range");
 9000|     48|    is_valid = false;
 9001|     48|    return 0;
 9002|     48|  }
 9003|  2.57k|  ada_log("parse_port: ", parsed_port);
 9004|  2.57k|  const size_t consumed = size_t(r.ptr - view.data());
 9005|  2.57k|  ada_log("parse_port: consumed ", consumed);
 9006|  2.57k|  if (check_trailing_content) {
  ------------------
  |  Branch (9006:7): [True: 2.57k, False: 0]
  ------------------
 9007|  2.57k|    is_valid &=
 9008|  2.57k|        (consumed == view.size() || view[consumed] == '/' ||
  ------------------
  |  Branch (9008:10): [True: 1.69k, False: 882]
  |  Branch (9008:37): [True: 705, False: 177]
  ------------------
 9009|    177|         view[consumed] == '?' || (is_special() && view[consumed] == '\\'));
  ------------------
  |  Branch (9009:10): [True: 40, False: 137]
  |  Branch (9009:36): [True: 125, False: 12]
  |  Branch (9009:52): [True: 6, False: 119]
  ------------------
 9010|  2.57k|  }
 9011|  2.57k|  ada_log("parse_port: is_valid = ", is_valid);
 9012|  2.57k|  if (is_valid) {
  ------------------
  |  Branch (9012:7): [True: 2.44k, False: 131]
  ------------------
 9013|  2.44k|    ada_log("parse_port", r.ec == std::errc());
 9014|       |    // scheme_default_port can return 0, and we should allow 0 as a base port.
 9015|  2.44k|    auto default_port = scheme_default_port();
 9016|  2.44k|    bool is_port_valid = (default_port == 0 && parsed_port == 0) ||
  ------------------
  |  Branch (9016:27): [True: 150, False: 2.29k]
  |  Branch (9016:48): [True: 46, False: 104]
  ------------------
 9017|  2.40k|                         (default_port != parsed_port);
  ------------------
  |  Branch (9017:26): [True: 2.39k, False: 12]
  ------------------
 9018|  2.44k|    if (r.ec == std::errc() && is_port_valid) {
  ------------------
  |  Branch (9018:9): [True: 1.77k, False: 675]
  |  Branch (9018:32): [True: 1.76k, False: 12]
  ------------------
 9019|  1.76k|      update_base_port(parsed_port);
 9020|  1.76k|    } else {
 9021|    687|      clear_port();
 9022|    687|    }
 9023|  2.44k|  }
 9024|  2.57k|  return consumed;
 9025|  2.62k|}
_ZN3ada14url_aggregator20append_base_pathnameENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8430|      2|inline void url_aggregator::append_base_pathname(const std::string_view input) {
 8431|      2|  ada_log("url_aggregator::append_base_pathname ", input, " ", to_string(),
 8432|      2|          "\n", to_diagram());
 8433|      2|  ADA_ASSERT_TRUE(validate());
 8434|      2|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 8435|       |#if ADA_DEVELOPMENT_CHECKS
 8436|       |  // computing the expected password.
 8437|       |  std::string path_expected(get_pathname());
 8438|       |  path_expected.append(input);
 8439|       |#endif  // ADA_DEVELOPMENT_CHECKS
 8440|      2|  uint32_t ending_index = uint32_t(buffer.size());
 8441|      2|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8441:7): [True: 0, False: 2]
  ------------------
 8442|      0|    ending_index = components.search_start;
 8443|      2|  } else if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8443:14): [True: 0, False: 2]
  ------------------
 8444|      0|    ending_index = components.hash_start;
 8445|      0|  }
 8446|      2|  buffer.insert(ending_index, input);
 8447|       |
 8448|      2|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8448:7): [True: 0, False: 2]
  ------------------
 8449|      0|    components.search_start += uint32_t(input.size());
 8450|      0|  }
 8451|      2|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8451:7): [True: 0, False: 2]
  ------------------
 8452|      0|    components.hash_start += uint32_t(input.size());
 8453|      0|  }
 8454|       |#if ADA_DEVELOPMENT_CHECKS
 8455|       |  std::string path_after = std::string(get_pathname());
 8456|       |  ADA_ASSERT_EQUAL(
 8457|       |      path_expected, path_after,
 8458|       |      "append_base_pathname problem after inserting " + std::string(input));
 8459|       |#endif  // ADA_DEVELOPMENT_CHECKS
 8460|      2|  ADA_ASSERT_TRUE(validate());
 8461|      2|}
_ZN3ada14url_aggregator20set_protocol_as_fileEv:
 9027|  5.42k|constexpr void url_aggregator::set_protocol_as_file() {
 9028|  5.42k|  ada_log("url_aggregator::set_protocol_as_file ");
 9029|  5.42k|  ADA_ASSERT_TRUE(validate());
 9030|  5.42k|  type = ada::scheme::type::FILE;
 9031|       |  // next line could overflow but unsigned arithmetic has well-defined
 9032|       |  // overflows.
 9033|  5.42k|  uint32_t new_difference = 5 - components.protocol_end;
 9034|       |
 9035|  5.42k|  if (buffer.empty()) {
  ------------------
  |  Branch (9035:7): [True: 616, False: 4.81k]
  ------------------
 9036|    616|    buffer.append("file:");
 9037|  4.81k|  } else {
 9038|  4.81k|    buffer.erase(0, components.protocol_end);
 9039|  4.81k|    buffer.insert(0, "file:");
 9040|  4.81k|  }
 9041|  5.42k|  components.protocol_end = 5;
 9042|       |
 9043|       |  // Update the rest of the components.
 9044|  5.42k|  components.username_end += new_difference;
 9045|  5.42k|  components.host_start += new_difference;
 9046|  5.42k|  components.host_end += new_difference;
 9047|  5.42k|  components.pathname_start += new_difference;
 9048|  5.42k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9048:7): [True: 0, False: 5.42k]
  ------------------
 9049|      0|    components.search_start += new_difference;
 9050|      0|  }
 9051|  5.42k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9051:7): [True: 0, False: 5.42k]
  ------------------
 9052|      0|    components.hash_start += new_difference;
 9053|      0|  }
 9054|  5.42k|  ADA_ASSERT_TRUE(validate());
 9055|  5.42k|}
_ZN3ada14url_aggregator14clear_pathnameEv:
 8767|     40|constexpr void url_aggregator::clear_pathname() {
 8768|     40|  ada_log("url_aggregator::clear_pathname");
 8769|     40|  ADA_ASSERT_TRUE(validate());
 8770|     40|  uint32_t ending_index = uint32_t(buffer.size());
 8771|     40|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8771:7): [True: 0, False: 40]
  ------------------
 8772|      0|    ending_index = components.search_start;
 8773|     40|  } else if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8773:14): [True: 0, False: 40]
  ------------------
 8774|      0|    ending_index = components.hash_start;
 8775|      0|  }
 8776|     40|  uint32_t pathname_length = ending_index - components.pathname_start;
 8777|     40|  buffer.erase(components.pathname_start, pathname_length);
 8778|     40|  uint32_t difference = pathname_length;
 8779|     40|  if (components.pathname_start == components.host_end + 2 &&
  ------------------
  |  Branch (8779:7): [True: 0, False: 40]
  ------------------
 8780|      0|      buffer[components.host_end] == '/' &&
  ------------------
  |  Branch (8780:7): [True: 0, False: 0]
  ------------------
 8781|      0|      buffer[components.host_end + 1] == '.') {
  ------------------
  |  Branch (8781:7): [True: 0, False: 0]
  ------------------
 8782|      0|    components.pathname_start -= 2;
 8783|      0|    buffer.erase(components.host_end, 2);
 8784|      0|    difference += 2;
 8785|      0|  }
 8786|     40|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8786:7): [True: 0, False: 40]
  ------------------
 8787|      0|    components.search_start -= difference;
 8788|      0|  }
 8789|     40|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8789:7): [True: 0, False: 40]
  ------------------
 8790|      0|    components.hash_start -= difference;
 8791|      0|  }
 8792|     40|  ada_log("url_aggregator::clear_pathname completed, running checks...");
 8793|       |#if ADA_DEVELOPMENT_CHECKS
 8794|       |  ADA_ASSERT_EQUAL(get_pathname(), "",
 8795|       |                   "pathname should have been cleared on buffer=" + buffer +
 8796|       |                       " with " + components.to_string() + "\n" + to_diagram());
 8797|       |#endif
 8798|     40|  ADA_ASSERT_TRUE(validate());
 8799|     40|  ada_log("url_aggregator::clear_pathname completed, running checks... ok");
 8800|     40|}
_ZN3ada7unicode20percent_encode_indexENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKh:
 8112|    804|                                              const uint8_t character_set[]) {
 8113|    804|  const char* data = input.data();
 8114|    804|  const size_t size = input.size();
 8115|       |
 8116|       |  // Process 8 bytes at a time using unrolled loop
 8117|    804|  size_t i = 0;
 8118|  2.58k|  for (; i + 8 <= size; i += 8) {
  ------------------
  |  Branch (8118:10): [True: 1.94k, False: 638]
  ------------------
 8119|  1.94k|    unsigned char chunk[8];
 8120|  1.94k|    std::memcpy(&chunk, data + i,
 8121|  1.94k|                8);  // entices compiler to unconditionally process 8 characters
 8122|       |
 8123|       |    // Check 8 characters at once
 8124|  16.3k|    for (size_t j = 0; j < 8; j++) {
  ------------------
  |  Branch (8124:24): [True: 14.5k, False: 1.78k]
  ------------------
 8125|  14.5k|      if (character_sets::bit_at(character_set, chunk[j])) {
  ------------------
  |  Branch (8125:11): [True: 166, False: 14.3k]
  ------------------
 8126|    166|        return i + j;
 8127|    166|      }
 8128|  14.5k|    }
 8129|  1.94k|  }
 8130|       |
 8131|       |  // Handle remaining bytes
 8132|  1.65k|  for (; i < size; i++) {
  ------------------
  |  Branch (8132:10): [True: 1.15k, False: 492]
  ------------------
 8133|  1.15k|    if (character_sets::bit_at(character_set, data[i])) {
  ------------------
  |  Branch (8133:9): [True: 146, False: 1.01k]
  ------------------
 8134|    146|      return i;
 8135|    146|    }
 8136|  1.15k|  }
 8137|       |
 8138|    492|  return size;
 8139|    638|}
_ZN3ada14url_aggregator10clear_portEv:
 8701|  1.77k|inline void url_aggregator::clear_port() {
 8702|  1.77k|  ada_log("url_aggregator::clear_port");
 8703|  1.77k|  ADA_ASSERT_TRUE(validate());
 8704|  1.77k|  if (components.port == url_components::omitted) {
  ------------------
  |  Branch (8704:7): [True: 1.77k, False: 0]
  ------------------
 8705|  1.77k|    return;
 8706|  1.77k|  }
 8707|      0|  uint32_t length = components.pathname_start - components.host_end;
 8708|      0|  buffer.erase(components.host_end, length);
 8709|      0|  components.pathname_start -= length;
 8710|      0|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8710:7): [True: 0, False: 0]
  ------------------
 8711|      0|    components.search_start -= length;
 8712|      0|  }
 8713|      0|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8713:7): [True: 0, False: 0]
  ------------------
 8714|      0|    components.hash_start -= length;
 8715|      0|  }
 8716|      0|  components.port = url_components::omitted;
 8717|      0|  ADA_ASSERT_TRUE(validate());
 8718|      0|}
_ZNK3ada14url_aggregator13has_authorityEv:
 8866|  45.6k|    const noexcept {
 8867|  45.6k|  ada_log("url_aggregator::has_authority");
 8868|       |  // Performance: instead of doing this potentially expensive check, we could
 8869|       |  // have a boolean in the struct.
 8870|  45.6k|  return components.protocol_end + 2 <= components.host_start &&
  ------------------
  |  Branch (8870:10): [True: 23.2k, False: 22.3k]
  ------------------
 8871|  23.2k|         buffer[components.protocol_end] == '/' &&
  ------------------
  |  Branch (8871:10): [True: 23.2k, False: 0]
  ------------------
 8872|  23.2k|         buffer[components.protocol_end + 1] == '/';
  ------------------
  |  Branch (8872:10): [True: 23.2k, False: 0]
  ------------------
 8873|  45.6k|}
_ZNK3ada14url_aggregator12has_dash_dotEv:
 8946|  12.0k|[[nodiscard]] constexpr bool url_aggregator::has_dash_dot() const noexcept {
 8947|       |  // If url's host is null, url does not have an opaque path, url's path's size
 8948|       |  // is greater than 1, and url's path[0] is the empty string, then append
 8949|       |  // U+002F (/) followed by U+002E (.) to output.
 8950|  12.0k|  ada_log("url_aggregator::has_dash_dot");
 8951|       |#if ADA_DEVELOPMENT_CHECKS
 8952|       |  // If pathname_start and host_end are exactly two characters apart, then we
 8953|       |  // either have a one-digit port such as http://test.com:5?param=1 or else we
 8954|       |  // have a /.: sequence such as "non-spec:/.//". We test that this is the case.
 8955|       |  if (components.pathname_start == components.host_end + 2) {
 8956|       |    ADA_ASSERT_TRUE((buffer[components.host_end] == '/' &&
 8957|       |                     buffer[components.host_end + 1] == '.') ||
 8958|       |                    (buffer[components.host_end] == ':' &&
 8959|       |                     checkers::is_digit(buffer[components.host_end + 1])));
 8960|       |  }
 8961|       |  if (components.pathname_start == components.host_end + 2 &&
 8962|       |      buffer[components.host_end] == '/' &&
 8963|       |      buffer[components.host_end + 1] == '.') {
 8964|       |    ADA_ASSERT_TRUE(components.pathname_start + 1 < buffer.size());
 8965|       |    ADA_ASSERT_TRUE(buffer[components.pathname_start] == '/');
 8966|       |    ADA_ASSERT_TRUE(buffer[components.pathname_start + 1] == '/');
 8967|       |  }
 8968|       |#endif
 8969|       |  // Performance: it should be uncommon for components.pathname_start ==
 8970|       |  // components.host_end + 2 to be true. So we put this check first in the
 8971|       |  // sequence. Most times, we do not have an opaque path. Checking for '/.' is
 8972|       |  // more expensive, but should be uncommon.
 8973|  12.0k|  return components.pathname_start == components.host_end + 2 &&
  ------------------
  |  Branch (8973:10): [True: 431, False: 11.6k]
  ------------------
 8974|    431|         !has_opaque_path && buffer[components.host_end] == '/' &&
  ------------------
  |  Branch (8974:10): [True: 431, False: 0]
  |  Branch (8974:30): [True: 14, False: 417]
  ------------------
 8975|     14|         buffer[components.host_end + 1] == '.';
  ------------------
  |  Branch (8975:10): [True: 14, False: 0]
  ------------------
 8976|  12.0k|}
_ZNK2tl8expectedIN3ada14url_aggregatorENS1_6errorsEEcvbEv:
 4030|  30.9k|  constexpr explicit operator bool() const noexcept { return this->m_has_val; }
_ZN2tl8expectedIN3ada14url_aggregatorENS1_6errorsEEptEv:
 3999|  17.6k|  TL_EXPECTED_11_CONSTEXPR T* operator->() {
 4000|  17.6k|    TL_ASSERT(has_value());
  ------------------
  |  | 2052|  17.6k|#define TL_ASSERT(x) assert(x)
  ------------------
  |  Branch (4000:5): [True: 17.6k, False: 0]
  ------------------
 4001|  17.6k|    return valptr();
 4002|  17.6k|  }
_ZN2tl8expectedIN3ada14url_aggregatorENS1_6errorsEE6valptrEv:
 3295|  17.6k|  T* valptr() { return std::addressof(this->m_val); }
_ZNR2tl8expectedIN3ada14url_aggregatorENS1_6errorsEEdeIS2_TnPNSt3__19enable_ifIXntsr3std7is_voidIT_EE5valueEvE4typeELPv0EEERS8_v:
 4012|  3.04k|  TL_EXPECTED_11_CONSTEXPR U& operator*() & {
 4013|  3.04k|    TL_ASSERT(has_value());
  ------------------
  |  | 2052|  3.04k|#define TL_ASSERT(x) assert(x)
  ------------------
  |  Branch (4013:5): [True: 3.04k, False: 0]
  ------------------
 4014|  3.04k|    return val();
 4015|  3.04k|  }
_ZN2tl8expectedIN3ada14url_aggregatorENS1_6errorsEE3valIS2_TnPNSt3__19enable_ifIXntsr3std7is_voidIT_EE5valueEvE4typeELPv0EEERS8_v:
 3304|  3.04k|  TL_EXPECTED_11_CONSTEXPR U& val() {
 3305|  3.04k|    return this->m_val;
 3306|  3.04k|  }
_ZNK2tl8expectedIN3ada14url_aggregatorENS1_6errorsEE9has_valueEv:
 4029|  62.1k|  constexpr bool has_value() const noexcept { return this->m_has_val; }
_ZN2tl6detail21expected_storage_baseIN3ada14url_aggregatorENS2_6errorsELb0ELb1EED2Ev:
 2627|  34.6k|  ~expected_storage_base() {
 2628|  34.6k|    if (m_has_val) {
  ------------------
  |  Branch (2628:9): [True: 15.6k, False: 19.0k]
  ------------------
 2629|  15.6k|      m_val.~T();
 2630|  15.6k|    }
 2631|  34.6k|  }
_ZN3ada7helpers9substringENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEmm:
 1846|  34.1k|                                                       size_t pos2) {
 1847|       |#if ADA_DEVELOPMENT_CHECKS
 1848|       |  if (pos2 < pos1) {
 1849|       |    std::cerr << "Negative-length substring: [" << pos1 << " to " << pos2 << ")"
 1850|       |              << std::endl;
 1851|       |    abort();
 1852|       |  }
 1853|       |#endif
 1854|  34.1k|  return input.substr(pos1, pos2 - pos1);
 1855|  34.1k|}
_ZNK3ada14url_aggregator10is_at_pathEv:
 8295|  4.55k|    const noexcept {
 8296|  4.55k|  return buffer.size() == components.pathname_start;
 8297|  4.55k|}
_ZN3ada8checkers8is_digitEc:
 1253|  32.3k|constexpr bool is_digit(char x) noexcept { return (x >= '0') & (x <= '9'); }
_ZNK3ada14url_aggregator12has_hostnameEv:
 8935|    376|constexpr bool url_aggregator::has_hostname() const noexcept {
 8936|    376|  return has_authority();
 8937|    376|}
_ZNK3ada14url_aggregator12has_passwordEv:
 8915|  5.18k|constexpr bool url_aggregator::has_password() const noexcept {
 8916|  5.18k|  ada_log("url_aggregator::has_password");
 8917|       |  // This function does not care about the length of the password
 8918|  5.18k|  return components.host_start > components.username_end &&
  ------------------
  |  Branch (8918:10): [True: 4.64k, False: 538]
  ------------------
 8919|  4.64k|         buffer[components.username_end] == ':';
  ------------------
  |  Branch (8919:10): [True: 4.64k, False: 0]
  ------------------
 8920|  5.18k|}
_ZNK3ada3url8get_hrefEv:
 7395|  12.5k|[[nodiscard]] ada_really_inline std::string url::get_href() const {
 7396|  12.5k|  if (is_special() && host.has_value() && username.empty() &&
  ------------------
  |  Branch (7396:7): [True: 9.89k, False: 2.68k]
  |  Branch (7396:23): [True: 9.89k, False: 0]
  |  Branch (7396:43): [True: 9.46k, False: 426]
  ------------------
 7397|  9.46k|      password.empty() && !port.has_value()) [[likely]] {
  ------------------
  |  Branch (7397:7): [True: 9.39k, False: 70]
  |  Branch (7397:27): [True: 8.54k, False: 851]
  ------------------
 7398|  8.54k|    const std::string_view scheme = ada::scheme::details::is_special_list[type];
 7399|  8.54k|    const size_t host_size = host->size();
 7400|  8.54k|    const size_t path_size = path.size();
 7401|  8.54k|    const size_t query_size = query.has_value() ? query->size() : 0;
  ------------------
  |  Branch (7401:31): [True: 391, False: 8.15k]
  ------------------
 7402|  8.54k|    const size_t hash_size = hash.has_value() ? hash->size() : 0;
  ------------------
  |  Branch (7402:30): [True: 243, False: 8.30k]
  ------------------
 7403|  8.54k|    const size_t total = scheme.size() + 3 + host_size + path_size +
 7404|  8.54k|                         (query.has_value() ? query_size + 1 : 0) +
  ------------------
  |  Branch (7404:27): [True: 391, False: 8.15k]
  ------------------
 7405|  8.54k|                         (hash.has_value() ? hash_size + 1 : 0);
  ------------------
  |  Branch (7405:27): [True: 243, False: 8.30k]
  ------------------
 7406|  8.54k|    std::string output(total, '\0');
 7407|  8.54k|    char* p = output.data();
 7408|  8.54k|    std::memcpy(p, scheme.data(), scheme.size());
 7409|  8.54k|    p += scheme.size();
 7410|  8.54k|    p[0] = ':';
 7411|  8.54k|    p[1] = '/';
 7412|  8.54k|    p[2] = '/';
 7413|  8.54k|    p += 3;
 7414|       |    // NOLINTNEXTLINE(bugprone-not-null-terminated-result)
 7415|  8.54k|    std::memcpy(p, host->data(), host_size);
 7416|  8.54k|    p += host_size;
 7417|  8.54k|    std::memcpy(p, path.data(), path_size);
 7418|  8.54k|    p += path_size;
 7419|  8.54k|    if (query.has_value()) {
  ------------------
  |  Branch (7419:9): [True: 391, False: 8.15k]
  ------------------
 7420|    391|      *p++ = '?';
 7421|       |      // NOLINTNEXTLINE(bugprone-not-null-terminated-result)
 7422|    391|      std::memcpy(p, query->data(), query_size);
 7423|    391|      p += query_size;
 7424|    391|    }
 7425|  8.54k|    if (hash.has_value()) {
  ------------------
  |  Branch (7425:9): [True: 243, False: 8.30k]
  ------------------
 7426|    243|      *p++ = '#';
 7427|       |      // NOLINTNEXTLINE(bugprone-not-null-terminated-result)
 7428|    243|      std::memcpy(p, hash->data(), hash_size);
 7429|    243|    }
 7430|  8.54k|    return output;
 7431|  8.54k|  }
 7432|       |
 7433|  4.02k|  std::string output;
 7434|  4.02k|  output.reserve(get_href_size());
 7435|       |
 7436|  4.02k|  if (is_special()) {
  ------------------
  |  Branch (7436:7): [True: 1.34k, False: 2.68k]
  ------------------
 7437|  1.34k|    output.append(ada::scheme::details::is_special_list[type]);
 7438|  1.34k|    output += ':';
 7439|  2.68k|  } else {
 7440|  2.68k|    output.append(non_special_scheme);
 7441|  2.68k|    output += ':';
 7442|  2.68k|  }
 7443|       |
 7444|  4.02k|  if (host.has_value()) {
  ------------------
  |  Branch (7444:7): [True: 1.82k, False: 2.20k]
  ------------------
 7445|  1.82k|    output += '/';
 7446|  1.82k|    output += '/';
 7447|  1.82k|    if (has_credentials()) {
  ------------------
  |  Branch (7447:9): [True: 557, False: 1.26k]
  ------------------
 7448|    557|      output.append(username);
 7449|    557|      if (!password.empty()) {
  ------------------
  |  Branch (7449:11): [True: 205, False: 352]
  ------------------
 7450|    205|        output += ':';
 7451|    205|        output.append(password);
 7452|    205|      }
 7453|    557|      output += '@';
 7454|    557|    }
 7455|  1.82k|    output.append(*host);
 7456|  1.82k|    if (port.has_value()) {
  ------------------
  |  Branch (7456:9): [True: 950, False: 871]
  ------------------
 7457|    950|      output += ':';
 7458|    950|      char port_buf[5];
 7459|    950|      auto [ptr, ec] = std::to_chars(port_buf, port_buf + 5, *port);
 7460|    950|      (void)ec;
 7461|    950|      output.append(port_buf, static_cast<size_t>(ptr - port_buf));
 7462|    950|    }
 7463|  2.20k|  } else if (!has_opaque_path && path.starts_with("//")) {
  ------------------
  |  Branch (7463:14): [True: 1.13k, False: 1.06k]
  |  Branch (7463:34): [True: 38, False: 1.10k]
  ------------------
 7464|       |    // If url's host is null, url does not have an opaque path, url's path's
 7465|       |    // size is greater than 1, and url's path[0] is the empty string, then
 7466|       |    // append U+002F (/) followed by U+002E (.) to output.
 7467|     38|    output += '/';
 7468|     38|    output += '.';
 7469|     38|  }
 7470|  4.02k|  output.append(path);
 7471|  4.02k|  if (query.has_value()) {
  ------------------
  |  Branch (7471:7): [True: 423, False: 3.60k]
  ------------------
 7472|    423|    output += '?';
 7473|    423|    output.append(*query);
 7474|    423|  }
 7475|  4.02k|  if (hash.has_value()) {
  ------------------
  |  Branch (7475:7): [True: 394, False: 3.63k]
  ------------------
 7476|    394|    output += '#';
 7477|    394|    output.append(*hash);
 7478|    394|  }
 7479|  4.02k|  return output;
 7480|  12.5k|}
_ZNK3ada14url_aggregator10has_searchEv:
 8844|  1.59k|[[nodiscard]] constexpr bool url_aggregator::has_search() const noexcept {
 8845|  1.59k|  ada_log("url_aggregator::has_search");
 8846|  1.59k|  return components.search_start != url_components::omitted;
 8847|  1.59k|}
_ZN3ada7helpers6concatIJNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEPKcEEENS2_12basic_stringIcS5_NS2_9allocatorIcEEEEDpT_:
 1924|  19.0k|std::string concat(Args... args) {
 1925|  19.0k|  std::string answer;
 1926|  19.0k|  inner_concat(answer, args...);
 1927|  19.0k|  return answer;
 1928|  19.0k|}
_ZN3ada7helpers12inner_concatINSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEJPKcEEEvRNS2_12basic_stringIcS5_NS2_9allocatorIcEEEET_DpT0_:
 1913|  19.0k|inline void inner_concat(std::string& buffer, T t, Args... args) {
 1914|  19.0k|  buffer.append(t);
 1915|  19.0k|  return inner_concat(buffer, args...);
 1916|  19.0k|}
_ZN3ada7helpers12inner_concatIPKcJEEEvRNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEET_:
 1905|  19.0k|inline void inner_concat(std::string& buffer, T t) {
 1906|  19.0k|  buffer.append(t);
 1907|  19.0k|}
_ZN3ada3url10set_schemeEONSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 7377|  9.53k|inline void url::set_scheme(std::string&& new_scheme) noexcept {
 7378|  9.53k|  type = ada::scheme::get_scheme_type(new_scheme);
 7379|       |  // We only move the 'scheme' if it is non-special.
 7380|  9.53k|  if (!is_special()) {
  ------------------
  |  Branch (7380:7): [True: 4.43k, False: 5.09k]
  ------------------
 7381|  4.43k|    non_special_scheme = std::move(new_scheme);
 7382|  4.43k|  }
 7383|  9.53k|}
_ZN3ada7helpers6concatIJPKcNSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEEEENS4_12basic_stringIcS7_NS4_9allocatorIcEEEEDpT_:
 1924|      2|std::string concat(Args... args) {
 1925|      2|  std::string answer;
 1926|      2|  inner_concat(answer, args...);
 1927|      2|  return answer;
 1928|      2|}
_ZN3ada7helpers12inner_concatIPKcJNSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEEEEvRNS4_12basic_stringIcS7_NS4_9allocatorIcEEEET_DpT0_:
 1913|      2|inline void inner_concat(std::string& buffer, T t, Args... args) {
 1914|      2|  buffer.append(t);
 1915|      2|  return inner_concat(buffer, args...);
 1916|      2|}
_ZN3ada7helpers12inner_concatINSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEJEEEvRNS2_12basic_stringIcS5_NS2_9allocatorIcEEEET_:
 1905|      2|inline void inner_concat(std::string& buffer, T t) {
 1906|      2|  buffer.append(t);
 1907|      2|}

LLVMFuzzerTestOneInput:
   10|  8.82k|extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
   11|  8.82k|  FuzzedDataProvider fdp(data, size);
   12|  8.82k|  std::string source = fdp.ConsumeRandomLengthString(256);
   13|  8.82k|  std::string base_source = fdp.ConsumeRandomLengthString(256);
   14|       |
   15|  8.82k|  bool can_parse_result = ada::can_parse(source);
   16|  8.82k|  auto parsed_agg = ada::parse<ada::url_aggregator>(source);
   17|  8.82k|  auto parsed_url = ada::parse<ada::url>(source);
   18|       |
   19|  8.82k|  if (can_parse_result != parsed_agg.has_value()) {
  ------------------
  |  Branch (19:7): [True: 0, False: 8.82k]
  ------------------
   20|      0|    printf("can_parse vs parse<url_aggregator> inconsistency for: %s\n",
   21|      0|           source.c_str());
   22|      0|    abort();
   23|      0|  }
   24|  8.82k|  if (can_parse_result != parsed_url.has_value()) {
  ------------------
  |  Branch (24:7): [True: 0, False: 8.82k]
  ------------------
   25|      0|    printf("can_parse vs parse<url> inconsistency for: %s\n", source.c_str());
   26|      0|    abort();
   27|      0|  }
   28|  8.82k|  if (parsed_url.has_value() != parsed_agg.has_value()) {
  ------------------
  |  Branch (28:7): [True: 0, False: 8.82k]
  ------------------
   29|      0|    printf("parse<url> vs parse<url_aggregator> disagreement for: %s\n",
   30|      0|           source.c_str());
   31|      0|    abort();
   32|      0|  }
   33|  8.82k|  if (parsed_url && parsed_agg &&
  ------------------
  |  Branch (33:7): [True: 5.10k, False: 3.72k]
  |  Branch (33:7): [True: 0, False: 8.82k]
  |  Branch (33:21): [True: 5.10k, False: 0]
  ------------------
   34|  5.10k|      parsed_url->get_href() != std::string(parsed_agg->get_href())) {
  ------------------
  |  Branch (34:7): [True: 0, False: 5.10k]
  ------------------
   35|      0|    printf("parse href disagreement for: %s\n", source.c_str());
   36|      0|    abort();
   37|      0|  }
   38|       |
   39|  8.82k|  auto base_source_view =
   40|  8.82k|      std::string_view(base_source.data(), base_source.length());
   41|  8.82k|  bool can_parse_with_base = ada::can_parse(source, &base_source_view);
   42|       |
   43|  8.82k|  auto base_agg = ada::parse<ada::url_aggregator>(base_source);
   44|  8.82k|  auto base_url = ada::parse<ada::url>(base_source);
   45|  8.82k|  if (base_agg.has_value() != base_url.has_value()) {
  ------------------
  |  Branch (45:7): [True: 0, False: 8.82k]
  ------------------
   46|      0|    printf("base parse type disagreement for: %s\n", base_source.c_str());
   47|      0|    abort();
   48|      0|  }
   49|       |
   50|  8.82k|  if (base_agg && base_url) {
  ------------------
  |  Branch (50:7): [True: 3.04k, False: 5.77k]
  |  Branch (50:19): [True: 3.04k, False: 0]
  ------------------
   51|  3.04k|    auto ra = ada::parse<ada::url_aggregator>(source, &*base_agg);
   52|  3.04k|    auto ru = ada::parse<ada::url>(source, &*base_url);
   53|  3.04k|    if (can_parse_with_base != ra.has_value()) {
  ------------------
  |  Branch (53:9): [True: 0, False: 3.04k]
  ------------------
   54|      0|      printf(
   55|      0|          "can_parse_with_base vs parse inconsistency for source=%s base=%s\n",
   56|      0|          source.c_str(), base_source.c_str());
   57|      0|      abort();
   58|      0|    }
   59|  3.04k|    if (ra.has_value() != ru.has_value()) {
  ------------------
  |  Branch (59:9): [True: 0, False: 3.04k]
  ------------------
   60|      0|      printf("relative parse type disagreement source=%s base=%s\n",
   61|      0|             source.c_str(), base_source.c_str());
   62|      0|      abort();
   63|      0|    }
   64|  3.04k|    if (ra && ru && ru->get_href() != std::string(ra->get_href())) {
  ------------------
  |  Branch (64:9): [True: 2.36k, False: 684]
  |  Branch (64:9): [True: 0, False: 3.04k]
  |  Branch (64:15): [True: 2.36k, False: 0]
  |  Branch (64:21): [True: 0, False: 2.36k]
  ------------------
   65|      0|      printf("relative parse href disagreement source=%s base=%s\n",
   66|      0|             source.c_str(), base_source.c_str());
   67|      0|      abort();
   68|      0|    }
   69|  5.77k|  } else if (can_parse_with_base) {
  ------------------
  |  Branch (69:14): [True: 0, False: 5.77k]
  ------------------
   70|      0|    printf("can_parse_with_base true with invalid base=%s\n",
   71|      0|           base_source.c_str());
   72|      0|    abort();
   73|      0|  }
   74|       |
   75|  8.82k|  {
   76|  8.82k|    bool empty_cp = ada::can_parse("");
   77|  8.82k|    auto empty_agg = ada::parse<ada::url_aggregator>("");
   78|  8.82k|    auto empty_url = ada::parse<ada::url>("");
   79|  8.82k|    if (empty_cp != empty_agg.has_value() ||
  ------------------
  |  Branch (79:9): [True: 0, False: 8.82k]
  ------------------
   80|  8.82k|        empty_cp != empty_url.has_value()) {
  ------------------
  |  Branch (80:9): [True: 0, False: 8.82k]
  ------------------
   81|      0|      printf("Empty string can_parse/parse disagreement\n");
   82|      0|      abort();
   83|      0|    }
   84|  8.82k|  }
   85|       |
   86|  8.82k|  if (parsed_agg) {
  ------------------
  |  Branch (86:7): [True: 5.10k, False: 3.72k]
  ------------------
   87|  5.10k|    std::string href = std::string(parsed_agg->get_href());
   88|  5.10k|    if (!ada::can_parse(href)) {
  ------------------
  |  Branch (88:9): [True: 0, False: 5.10k]
  ------------------
   89|      0|      printf("can_parse rejected normalised href: '%s'\n", href.c_str());
   90|      0|      abort();
   91|      0|    }
   92|  5.10k|    auto reparsed = ada::parse<ada::url_aggregator>(href);
   93|  5.10k|    if (!reparsed || std::string(reparsed->get_href()) != href) {
  ------------------
  |  Branch (93:9): [True: 0, False: 5.10k]
  |  Branch (93:9): [True: 0, False: 5.10k]
  |  Branch (93:22): [True: 0, False: 5.10k]
  ------------------
   94|      0|      printf("href re-parse failure for: '%s'\n", href.c_str());
   95|      0|      abort();
   96|      0|    }
   97|  5.10k|    auto reparsed_url = ada::parse<ada::url>(href);
   98|  5.10k|    if (!reparsed_url || reparsed_url->get_href() != href) {
  ------------------
  |  Branch (98:9): [True: 0, False: 5.10k]
  |  Branch (98:9): [True: 0, False: 5.10k]
  |  Branch (98:26): [True: 0, False: 5.10k]
  ------------------
   99|      0|      printf("parse<url> re-parse disagreement on href: '%s'\n", href.c_str());
  100|      0|      abort();
  101|      0|    }
  102|  5.10k|  }
  103|       |
  104|  8.82k|  return 0;
  105|  8.82k|}

