_ZN3ada4idna13utf8_to_utf32EPKcmPDi:
  162|  12.5k|size_t utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_output) {
  163|  12.5k|  const uint8_t* data = reinterpret_cast<const uint8_t*>(buf);
  164|  12.5k|  size_t pos = 0;
  165|  12.5k|  const char32_t* start{utf32_output};
  166|   178k|  while (pos < len) {
  ------------------
  |  Branch (166:10): [True: 166k, False: 11.5k]
  ------------------
  167|       |    // try to convert the next block of 16 ASCII bytes
  168|   166k|    if (pos + 16 <= len) {  // if it is safe to read 16 more
  ------------------
  |  Branch (168:9): [True: 98.0k, False: 68.4k]
  ------------------
  169|       |                            // bytes, check that they are ascii
  170|  98.0k|      uint64_t v1;
  171|  98.0k|      std::memcpy(&v1, data + pos, sizeof(uint64_t));
  172|  98.0k|      uint64_t v2;
  173|  98.0k|      std::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  174|  98.0k|      uint64_t v{v1 | v2};
  175|  98.0k|      if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (175:11): [True: 6.08k, False: 92.0k]
  ------------------
  176|  6.08k|        size_t final_pos = pos + 16;
  177|   103k|        while (pos < final_pos) {
  ------------------
  |  Branch (177:16): [True: 97.3k, False: 6.08k]
  ------------------
  178|  97.3k|          *utf32_output++ = char32_t(buf[pos]);
  179|  97.3k|          pos++;
  180|  97.3k|        }
  181|  6.08k|        continue;
  182|  6.08k|      }
  183|  98.0k|    }
  184|   160k|    uint8_t leading_byte = data[pos];  // leading byte
  185|   160k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (185:9): [True: 92.9k, False: 67.5k]
  ------------------
  186|       |      // converting one ASCII byte !!!
  187|  92.9k|      *utf32_output++ = char32_t(leading_byte);
  188|  92.9k|      pos++;
  189|  92.9k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (189:16): [True: 20.2k, False: 47.3k]
  ------------------
  190|       |      // We have a two-byte UTF-8
  191|  20.2k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (191:11): [True: 138, False: 20.0k]
  ------------------
  192|    138|        return 0;
  193|    138|      }  // minimal bound checking
  194|  20.0k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (194:11): [True: 156, False: 19.9k]
  ------------------
  195|    156|        return 0;
  196|    156|      }
  197|       |      // range check
  198|  19.9k|      uint32_t code_point =
  199|  19.9k|          (leading_byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111);
  200|  19.9k|      if (code_point < 0x80 || 0x7ff < code_point) {
  ------------------
  |  Branch (200:11): [True: 18, False: 19.9k]
  |  Branch (200:32): [True: 0, False: 19.9k]
  ------------------
  201|     18|        return 0;
  202|     18|      }
  203|  19.9k|      *utf32_output++ = char32_t(code_point);
  204|  19.9k|      pos += 2;
  205|  47.3k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (205:16): [True: 45.3k, False: 1.99k]
  ------------------
  206|       |      // We have a three-byte UTF-8
  207|  45.3k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (207:11): [True: 51, False: 45.2k]
  ------------------
  208|     51|        return 0;
  209|     51|      }  // minimal bound checking
  210|       |
  211|  45.2k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (211:11): [True: 54, False: 45.2k]
  ------------------
  212|     54|        return 0;
  213|     54|      }
  214|  45.2k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (214:11): [True: 24, False: 45.1k]
  ------------------
  215|     24|        return 0;
  216|     24|      }
  217|       |      // range check
  218|  45.1k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
  219|  45.1k|                            (data[pos + 1] & 0b00111111) << 6 |
  220|  45.1k|                            (data[pos + 2] & 0b00111111);
  221|  45.1k|      if (code_point < 0x800 || 0xffff < code_point ||
  ------------------
  |  Branch (221:11): [True: 21, False: 45.1k]
  |  Branch (221:33): [True: 0, False: 45.1k]
  ------------------
  222|  45.1k|          (0xd7ff < code_point && code_point < 0xe000)) {
  ------------------
  |  Branch (222:12): [True: 3.01k, False: 42.1k]
  |  Branch (222:35): [True: 9, False: 3.00k]
  ------------------
  223|     30|        return 0;
  224|     30|      }
  225|  45.1k|      *utf32_output++ = char32_t(code_point);
  226|  45.1k|      pos += 3;
  227|  45.1k|    } else if ((leading_byte & 0b11111000) == 0b11110000) {  // 0b11110000
  ------------------
  |  Branch (227:16): [True: 1.64k, False: 354]
  ------------------
  228|       |      // we have a 4-byte UTF-8 word.
  229|  1.64k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (229:11): [True: 27, False: 1.61k]
  ------------------
  230|     27|        return 0;
  231|     27|      }  // minimal bound checking
  232|  1.61k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (232:11): [True: 30, False: 1.58k]
  ------------------
  233|     30|        return 0;
  234|     30|      }
  235|  1.58k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (235:11): [True: 15, False: 1.57k]
  ------------------
  236|     15|        return 0;
  237|     15|      }
  238|  1.57k|      if ((data[pos + 3] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (238:11): [True: 15, False: 1.55k]
  ------------------
  239|     15|        return 0;
  240|     15|      }
  241|       |
  242|       |      // range check
  243|  1.55k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  244|  1.55k|                            (data[pos + 1] & 0b00111111) << 12 |
  245|  1.55k|                            (data[pos + 2] & 0b00111111) << 6 |
  246|  1.55k|                            (data[pos + 3] & 0b00111111);
  247|  1.55k|      if (code_point <= 0xffff || 0x10ffff < code_point) {
  ------------------
  |  Branch (247:11): [True: 21, False: 1.53k]
  |  Branch (247:35): [True: 12, False: 1.52k]
  ------------------
  248|     33|        return 0;
  249|     33|      }
  250|  1.52k|      *utf32_output++ = char32_t(code_point);
  251|  1.52k|      pos += 4;
  252|  1.52k|    } else {
  253|    354|      return 0;
  254|    354|    }
  255|   160k|  }
  256|  11.5k|  return utf32_output - start;
  257|  12.5k|}
_ZN3ada4idna22utf32_length_from_utf8EPKcm:
  272|  12.6k|size_t utf32_length_from_utf8(const char* buf, size_t len) {
  273|  12.6k|  const int8_t* p = reinterpret_cast<const int8_t*>(buf);
  274|  12.6k|  return std::count_if(p, std::next(p, len), [](int8_t c) {
  275|       |    // -65 is 0b10111111, anything larger in two-complement's
  276|       |    // should start a new code point.
  277|  12.6k|    return c > -65;
  278|  12.6k|  });
  279|  12.6k|}
_ZN3ada4idna9ascii_mapEPcm:
 5259|  6.04k|void ascii_map(char* input, size_t length) {
 5260|  6.04k|  auto broadcast = [](uint8_t v) -> uint64_t {
 5261|  6.04k|    return 0x101010101010101ull * v;
 5262|  6.04k|  };
 5263|  6.04k|  uint64_t broadcast_80 = broadcast(0x80);
 5264|  6.04k|  uint64_t broadcast_Ap = broadcast(128 - 'A');
 5265|  6.04k|  uint64_t broadcast_Zp = broadcast(128 - 'Z' - 1);
 5266|  6.04k|  size_t i = 0;
 5267|       |
 5268|  49.4k|  for (; i + 7 < length; i += 8) {
  ------------------
  |  Branch (5268:10): [True: 43.4k, False: 6.04k]
  ------------------
 5269|  43.4k|    uint64_t word{};
 5270|  43.4k|    std::memcpy(&word, input + i, sizeof(word));
 5271|  43.4k|    word ^=
 5272|  43.4k|        (((word + broadcast_Ap) ^ (word + broadcast_Zp)) & broadcast_80) >> 2;
 5273|  43.4k|    std::memcpy(input + i, &word, sizeof(word));
 5274|  43.4k|  }
 5275|  6.04k|  if (i < length) {
  ------------------
  |  Branch (5275:7): [True: 5.23k, False: 806]
  ------------------
 5276|  5.23k|    uint64_t word{};
 5277|  5.23k|    std::memcpy(&word, input + i, length - i);
 5278|  5.23k|    word ^=
 5279|  5.23k|        (((word + broadcast_Ap) ^ (word + broadcast_Zp)) & broadcast_80) >> 2;
 5280|  5.23k|    std::memcpy(input + i, &word, length - i);
 5281|  5.23k|  }
 5282|  6.04k|}
_ZN3ada4idna3mapENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEERNS1_12basic_stringIDiS4_NS1_9allocatorIDiEEEE:
 5286|  15.5k|bool map(std::u32string_view input, std::u32string& out) {
 5287|       |  //  [Map](https://www.unicode.org/reports/tr46/#ProcessingStepMap).
 5288|  15.5k|  out.clear();
 5289|  15.5k|  if (!ensure_tables()) {
  ------------------
  |  Branch (5289:7): [True: 0, False: 15.5k]
  ------------------
 5290|      0|    return false;
 5291|      0|  }
 5292|       |
 5293|       |  // Pass 1: validate and compute exact output length.
 5294|  15.5k|  size_t out_size = 0;
 5295|   301k|  for (char32_t x : input) {
  ------------------
  |  Branch (5295:19): [True: 301k, False: 14.7k]
  ------------------
 5296|   301k|    uint16_t status = idna_lookup(static_cast<uint32_t>(x));
 5297|   301k|    if (status == IDNA_DISALLOWED) {
  ------------------
  |  Branch (5297:9): [True: 705, False: 300k]
  ------------------
 5298|    705|      return false;
 5299|    705|    }
 5300|   300k|    if (status == IDNA_VALID) {
  ------------------
  |  Branch (5300:9): [True: 195k, False: 104k]
  ------------------
 5301|   195k|      ++out_size;
 5302|   195k|      continue;
 5303|   195k|    }
 5304|   104k|    if (static_cast<size_t>(status) >= idna_utf8_mappings_size) {
  ------------------
  |  Branch (5304:9): [True: 0, False: 104k]
  ------------------
 5305|      0|      return false;
 5306|      0|    }
 5307|   104k|    out_size += utf8_count_codepoints(idna_utf8_mappings + status);
 5308|   104k|  }
 5309|       |
 5310|       |  // Pass 2: write into a single allocation.
 5311|  14.7k|  out.resize(out_size);
 5312|  14.7k|  size_t w = 0;
 5313|   299k|  for (char32_t x : input) {
  ------------------
  |  Branch (5313:19): [True: 299k, False: 14.7k]
  ------------------
 5314|   299k|    uint16_t status = idna_lookup(static_cast<uint32_t>(x));
 5315|   299k|    if (status == IDNA_VALID) {
  ------------------
  |  Branch (5315:9): [True: 195k, False: 104k]
  ------------------
 5316|   195k|      out[w++] = x;
 5317|   195k|      continue;
 5318|   195k|    }
 5319|       |    // IGNORED or mapped (status already validated in pass 1).
 5320|   104k|    const uint8_t* ptr = idna_utf8_mappings + status;
 5321|   462k|    while (*ptr != 0) {
  ------------------
  |  Branch (5321:12): [True: 358k, False: 104k]
  ------------------
 5322|   358k|      out[w++] = utf8_next(ptr);
 5323|   358k|    }
 5324|   104k|  }
 5325|  14.7k|  return true;
 5326|  15.5k|}
_ZN3ada4idna28compute_decomposition_lengthENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 5420|  2.26k|    const std::u32string_view input) noexcept {
 5421|  2.26k|  bool decomposition_needed{false};
 5422|  2.26k|  size_t additional_elements{0};
 5423|  71.6k|  for (char32_t current_character : input) {
  ------------------
  |  Branch (5423:35): [True: 71.6k, False: 2.26k]
  ------------------
 5424|  71.6k|    size_t decomposition_length{0};
 5425|       |
 5426|  71.6k|    if (current_character >= hangul_sbase &&
  ------------------
  |  Branch (5426:9): [True: 11.4k, False: 60.1k]
  ------------------
 5427|  11.4k|        current_character < hangul_sbase + hangul_scount) {
  ------------------
  |  Branch (5427:9): [True: 5.03k, False: 6.41k]
  ------------------
 5428|       |      // Full NFD-style Hangul decomp for the decompose() step.
 5429|  5.03k|      decomposition_length = 2;
 5430|  5.03k|      if ((current_character - hangul_sbase) % hangul_tcount) {
  ------------------
  |  Branch (5430:11): [True: 2.09k, False: 2.94k]
  ------------------
 5431|  2.09k|        decomposition_length = 3;
 5432|  2.09k|      }
 5433|  66.5k|    } else if (current_character < 0x110000) {
  ------------------
  |  Branch (5433:16): [True: 66.5k, False: 0]
  ------------------
 5434|  66.5k|      const uint8_t di = decomposition_index[current_character >> 8];
 5435|  66.5k|      const uint16_t* const decomposition =
 5436|  66.5k|          decomposition_block_row(di) + (current_character % 256);
 5437|  66.5k|      decomposition_length = (decomposition[1] >> 2) - (decomposition[0] >> 2);
 5438|  66.5k|      if ((decomposition_length > 0) && (decomposition[0] & 1)) {
  ------------------
  |  Branch (5438:11): [True: 5.68k, False: 60.9k]
  |  Branch (5438:41): [True: 0, False: 5.68k]
  ------------------
 5439|      0|        decomposition_length = 0;
 5440|      0|      }
 5441|  66.5k|    }
 5442|  71.6k|    if (decomposition_length != 0) {
  ------------------
  |  Branch (5442:9): [True: 10.7k, False: 60.9k]
  ------------------
 5443|  10.7k|      decomposition_needed = true;
 5444|  10.7k|      additional_elements += decomposition_length - 1;
 5445|  10.7k|    }
 5446|  71.6k|  }
 5447|  2.26k|  return {decomposition_needed, additional_elements};
 5448|  2.26k|}
_ZN3ada4idna9decomposeERNSt3__112basic_stringIDiNS1_11char_traitsIDiEENS1_9allocatorIDiEEEEm:
 5450|  1.01k|void decompose(std::u32string& input, size_t additional_elements) {
 5451|  1.01k|  input.resize(input.size() + additional_elements);
 5452|  1.01k|  for (size_t descending_idx = input.size(),
 5453|  1.01k|              input_count = descending_idx - additional_elements;
 5454|  37.7k|       input_count--;) {
  ------------------
  |  Branch (5454:8): [True: 36.7k, False: 1.01k]
  ------------------
 5455|  36.7k|    if (input[input_count] >= hangul_sbase &&
  ------------------
  |  Branch (5455:9): [True: 9.84k, False: 26.8k]
  ------------------
 5456|  9.84k|        input[input_count] < hangul_sbase + hangul_scount) {
  ------------------
  |  Branch (5456:9): [True: 5.03k, False: 4.81k]
  ------------------
 5457|       |      // Hangul decomposition.
 5458|  5.03k|      char32_t s_index = input[input_count] - hangul_sbase;
 5459|  5.03k|      if (s_index % hangul_tcount != 0) {
  ------------------
  |  Branch (5459:11): [True: 2.09k, False: 2.94k]
  ------------------
 5460|  2.09k|        input[--descending_idx] = hangul_tbase + s_index % hangul_tcount;
 5461|  2.09k|      }
 5462|  5.03k|      input[--descending_idx] =
 5463|  5.03k|          hangul_vbase + (s_index % hangul_ncount) / hangul_tcount;
 5464|  5.03k|      input[--descending_idx] = hangul_lbase + s_index / hangul_ncount;
 5465|  31.7k|    } else if (input[input_count] < 0x110000) {
  ------------------
  |  Branch (5465:16): [True: 31.7k, False: 0]
  ------------------
 5466|  31.7k|      const uint16_t* decomposition =
 5467|  31.7k|          decomposition_block_row(
 5468|  31.7k|              decomposition_index[input[input_count] >> 8]) +
 5469|  31.7k|          (input[input_count] % 256);
 5470|  31.7k|      uint16_t decomposition_length =
 5471|  31.7k|          (decomposition[1] >> 2) - (decomposition[0] >> 2);
 5472|  31.7k|      if (decomposition_length > 0 && (decomposition[0] & 1)) {
  ------------------
  |  Branch (5472:11): [True: 5.68k, False: 26.0k]
  |  Branch (5472:39): [True: 0, False: 5.68k]
  ------------------
 5473|      0|        decomposition_length = 0;
 5474|      0|      }
 5475|  31.7k|      if (decomposition_length > 0) {
  ------------------
  |  Branch (5475:11): [True: 5.68k, False: 26.0k]
  ------------------
 5476|  5.68k|        const size_t base = static_cast<size_t>(decomposition[0] >> 2);
 5477|  5.68k|        if (base + decomposition_length > decomposition_data_size) {
  ------------------
  |  Branch (5477:13): [True: 0, False: 5.68k]
  ------------------
 5478|      0|          input[--descending_idx] = input[input_count];
 5479|  5.68k|        } else {
 5480|  19.5k|          while (decomposition_length-- > 0) {
  ------------------
  |  Branch (5480:18): [True: 13.8k, False: 5.68k]
  ------------------
 5481|  13.8k|            input[--descending_idx] =
 5482|  13.8k|                decomposition_data[base + decomposition_length];
 5483|  13.8k|          }
 5484|  5.68k|        }
 5485|  26.0k|      } else {
 5486|  26.0k|        input[--descending_idx] = input[input_count];
 5487|  26.0k|      }
 5488|  31.7k|    } else {
 5489|      0|      input[--descending_idx] = input[input_count];
 5490|      0|    }
 5491|  36.7k|  }
 5492|  1.01k|}
_ZN3ada4idna7get_cccEDi:
 5494|   796k|uint8_t get_ccc(char32_t c) noexcept {
 5495|   796k|  if (c >= 0x110000) {
  ------------------
  |  Branch (5495:7): [True: 0, False: 796k]
  ------------------
 5496|      0|    return 0;
 5497|      0|  }
 5498|   796k|  return ccc_block_row(ccc_index[c >> 8])[c % 256];
 5499|   796k|}
_ZN3ada4idna10sort_marksERNSt3__112basic_stringIDiNS1_11char_traitsIDiEENS1_9allocatorIDiEEEE:
 5501|  2.26k|void sort_marks(std::u32string& input) {
 5502|  86.9k|  for (size_t idx = 1; idx < input.size(); idx++) {
  ------------------
  |  Branch (5502:24): [True: 84.6k, False: 2.26k]
  ------------------
 5503|  84.6k|    uint8_t ccc = get_ccc(input[idx]);
 5504|  84.6k|    if (ccc == 0) {
  ------------------
  |  Branch (5504:9): [True: 69.9k, False: 14.7k]
  ------------------
 5505|  69.9k|      continue;
 5506|  69.9k|    }
 5507|  14.7k|    auto current_character = input[idx];
 5508|  14.7k|    size_t back_idx = idx;
 5509|  21.0k|    while (back_idx != 0 && get_ccc(input[back_idx - 1]) > ccc) {
  ------------------
  |  Branch (5509:12): [True: 20.7k, False: 312]
  |  Branch (5509:29): [True: 6.38k, False: 14.3k]
  ------------------
 5510|  6.38k|      input[back_idx] = input[back_idx - 1];
 5511|  6.38k|      back_idx--;
 5512|  6.38k|    }
 5513|  14.7k|    input[back_idx] = current_character;
 5514|  14.7k|  }
 5515|  2.26k|}
_ZN3ada4idna13decompose_nfcERNSt3__112basic_stringIDiNS1_11char_traitsIDiEENS1_9allocatorIDiEEEE:
 5517|  2.26k|void decompose_nfc(std::u32string& input) {
 5518|       |  /**
 5519|       |   * Decompose the domain_name string to Unicode Normalization Form C.
 5520|       |   * @see https://www.unicode.org/reports/tr46/#ProcessingStepDecompose
 5521|       |   */
 5522|  2.26k|  auto [decomposition_needed, additional_elements] =
 5523|  2.26k|      compute_decomposition_length(input);
 5524|  2.26k|  if (decomposition_needed) {
  ------------------
  |  Branch (5524:7): [True: 1.01k, False: 1.24k]
  ------------------
 5525|  1.01k|    decompose(input, additional_elements);
 5526|  1.01k|  }
 5527|  2.26k|  sort_marks(input);
 5528|  2.26k|}
_ZN3ada4idna14is_already_nfcENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 5688|  13.7k|bool is_already_nfc(std::u32string_view input) noexcept {
 5689|  13.7k|  if (input.empty()) {
  ------------------
  |  Branch (5689:7): [True: 0, False: 13.7k]
  ------------------
 5690|      0|    return true;
 5691|      0|  }
 5692|  13.7k|  if (!tables_are_ready() && !ensure_tables()) {
  ------------------
  |  Branch (5692:7): [True: 0, False: 13.7k]
  |  Branch (5692:30): [True: 0, False: 0]
  ------------------
 5693|      0|    return false;
 5694|      0|  }
 5695|  13.7k|  uint8_t last_ccc = 0;
 5696|  13.7k|  bool maybe = false;
 5697|   404k|  for (char32_t c : input) {
  ------------------
  |  Branch (5697:19): [True: 404k, False: 12.6k]
  ------------------
 5698|   404k|    if (c < nfc_qc_first_non_starter) {
  ------------------
  |  Branch (5698:9): [True: 147k, False: 257k]
  ------------------
 5699|   147k|      last_ccc = 0;
 5700|   147k|      continue;
 5701|   147k|    }
 5702|   257k|    const uint8_t ccc = get_ccc(c);
 5703|   257k|    if (ccc != 0 && last_ccc > ccc) {
  ------------------
  |  Branch (5703:9): [True: 19.8k, False: 237k]
  |  Branch (5703:21): [True: 1.02k, False: 18.8k]
  ------------------
 5704|  1.02k|      return false;
 5705|  1.02k|    }
 5706|   256k|    const nfc_quick_check check = get_nfc_quick_check(c);
 5707|   256k|    if (check == nfc_quick_check::no) {
  ------------------
  |  Branch (5707:9): [True: 0, False: 256k]
  ------------------
 5708|      0|      return false;
 5709|      0|    }
 5710|   256k|    maybe = maybe || check == nfc_quick_check::maybe;
  ------------------
  |  Branch (5710:13): [True: 38.3k, False: 218k]
  |  Branch (5710:22): [True: 4.45k, False: 213k]
  ------------------
 5711|   256k|    last_ccc = ccc;
 5712|   256k|  }
 5713|  12.6k|  return !maybe || maybe_is_nfc(input);
  ------------------
  |  Branch (5713:10): [True: 8.48k, False: 4.20k]
  |  Branch (5713:20): [True: 708, False: 3.49k]
  ------------------
 5714|  13.7k|}
_ZN3ada4idna7composeERNSt3__112basic_stringIDiNS1_11char_traitsIDiEENS1_9allocatorIDiEEEE:
 5716|  2.26k|void compose(std::u32string& input) {
 5717|       |  /**
 5718|       |   * Compose the domain_name string to Unicode Normalization Form C.
 5719|       |   * @see https://www.unicode.org/reports/tr46/#ProcessingStepCompose
 5720|       |   */
 5721|  2.26k|  size_t input_count{0};
 5722|  2.26k|  size_t composition_count{0};
 5723|  63.8k|  for (; input_count < input.size(); input_count++, composition_count++) {
  ------------------
  |  Branch (5723:10): [True: 61.6k, False: 2.26k]
  ------------------
 5724|  61.6k|    input[composition_count] = input[input_count];
 5725|  61.6k|    if (input[input_count] >= hangul_lbase &&
  ------------------
  |  Branch (5725:9): [True: 19.0k, False: 42.5k]
  ------------------
 5726|  19.0k|        input[input_count] < hangul_lbase + hangul_lcount) {
  ------------------
  |  Branch (5726:9): [True: 8.34k, False: 10.7k]
  ------------------
 5727|  8.34k|      if (input_count + 1 < input.size() &&
  ------------------
  |  Branch (5727:11): [True: 8.29k, False: 48]
  ------------------
 5728|  8.29k|          input[input_count + 1] >= hangul_vbase &&
  ------------------
  |  Branch (5728:11): [True: 5.73k, False: 2.55k]
  ------------------
 5729|  5.73k|          input[input_count + 1] < hangul_vbase + hangul_vcount) {
  ------------------
  |  Branch (5729:11): [True: 5.16k, False: 576]
  ------------------
 5730|  5.16k|        input[composition_count] =
 5731|  5.16k|            hangul_sbase +
 5732|  5.16k|            ((input[input_count] - hangul_lbase) * hangul_vcount +
 5733|  5.16k|             input[input_count + 1] - hangul_vbase) *
 5734|  5.16k|                hangul_tcount;
 5735|  5.16k|        input_count++;
 5736|  5.16k|        if (input_count + 1 < input.size() &&
  ------------------
  |  Branch (5736:13): [True: 5.07k, False: 90]
  ------------------
 5737|  5.07k|            input[input_count + 1] > hangul_tbase &&
  ------------------
  |  Branch (5737:13): [True: 2.75k, False: 2.31k]
  ------------------
 5738|  2.75k|            input[input_count + 1] < hangul_tbase + hangul_tcount) {
  ------------------
  |  Branch (5738:13): [True: 2.18k, False: 573]
  ------------------
 5739|  2.18k|          input[composition_count] += input[++input_count] - hangul_tbase;
 5740|  2.18k|        }
 5741|  5.16k|      }
 5742|  53.2k|    } else if (input[input_count] >= hangul_sbase &&
  ------------------
  |  Branch (5742:16): [True: 5.39k, False: 47.8k]
  ------------------
 5743|  5.39k|               input[input_count] < hangul_sbase + hangul_scount) {
  ------------------
  |  Branch (5743:16): [True: 0, False: 5.39k]
  ------------------
 5744|      0|      if ((input[input_count] - hangul_sbase) % hangul_tcount == 0 &&
  ------------------
  |  Branch (5744:11): [True: 0, False: 0]
  ------------------
 5745|      0|          input_count + 1 < input.size() &&
  ------------------
  |  Branch (5745:11): [True: 0, False: 0]
  ------------------
 5746|      0|          input[input_count + 1] > hangul_tbase &&
  ------------------
  |  Branch (5746:11): [True: 0, False: 0]
  ------------------
 5747|      0|          input[input_count + 1] < hangul_tbase + hangul_tcount) {
  ------------------
  |  Branch (5747:11): [True: 0, False: 0]
  ------------------
 5748|      0|        input[composition_count] += input[++input_count] - hangul_tbase;
 5749|      0|      }
 5750|  53.2k|    } else if (input[input_count] < 0x110000) {
  ------------------
  |  Branch (5750:16): [True: 53.2k, False: 0]
  ------------------
 5751|  53.2k|      const uint16_t* composition =
 5752|  53.2k|          composition_block_row(composition_index[input[input_count] >> 8]) +
 5753|  53.2k|          (input[input_count] % 256);
 5754|  53.2k|      size_t initial_composition_count = composition_count;
 5755|  71.2k|      for (int32_t previous_ccc = -1; input_count + 1 < input.size();
  ------------------
  |  Branch (5755:39): [True: 69.2k, False: 2.02k]
  ------------------
 5756|  69.2k|           input_count++) {
 5757|  69.2k|        uint8_t ccc = get_ccc(input[input_count + 1]);
 5758|       |
 5759|  69.2k|        if (composition[1] != composition[0] && previous_ccc < ccc) {
  ------------------
  |  Branch (5759:13): [True: 26.2k, False: 42.9k]
  |  Branch (5759:49): [True: 23.3k, False: 2.95k]
  ------------------
 5760|  23.3k|          int left = composition[0];
 5761|  23.3k|          int right = composition[1];
 5762|  23.3k|          if (left < 0 || right < left ||
  ------------------
  |  Branch (5762:15): [True: 0, False: 23.3k]
  |  Branch (5762:27): [True: 0, False: 23.3k]
  ------------------
 5763|  23.3k|              static_cast<size_t>(right) > composition_data_size) {
  ------------------
  |  Branch (5763:15): [True: 0, False: 23.3k]
  ------------------
 5764|      0|            break;
 5765|      0|          }
 5766|  53.9k|          while (left + 2 < right) {
  ------------------
  |  Branch (5766:18): [True: 30.6k, False: 23.3k]
  ------------------
 5767|  30.6k|            int middle = left + (((right - left) >> 1) & ~1);
 5768|  30.6k|            if (composition_data[static_cast<size_t>(middle)] <=
  ------------------
  |  Branch (5768:17): [True: 13.5k, False: 17.0k]
  ------------------
 5769|  30.6k|                input[input_count + 1]) {
 5770|  13.5k|              left = middle;
 5771|  13.5k|            }
 5772|  30.6k|            if (composition_data[static_cast<size_t>(middle)] >=
  ------------------
  |  Branch (5772:17): [True: 22.7k, False: 7.82k]
  ------------------
 5773|  30.6k|                input[input_count + 1]) {
 5774|  22.7k|              right = middle;
 5775|  22.7k|            }
 5776|  30.6k|          }
 5777|  23.3k|          if (static_cast<size_t>(left + 1) < composition_data_size &&
  ------------------
  |  Branch (5777:15): [True: 23.3k, False: 0]
  ------------------
 5778|  23.3k|              composition_data[static_cast<size_t>(left)] ==
  ------------------
  |  Branch (5778:15): [True: 9.57k, False: 13.7k]
  ------------------
 5779|  23.3k|                  input[input_count + 1]) {
 5780|  9.57k|            char32_t composed = composition_data[static_cast<size_t>(left + 1)];
 5781|  9.57k|            input[initial_composition_count] = composed;
 5782|  9.57k|            composition =
 5783|  9.57k|                composition_block_row(composition_index[composed >> 8]) +
 5784|  9.57k|                (composed % 256);
 5785|  9.57k|            continue;
 5786|  9.57k|          }
 5787|  23.3k|        }
 5788|       |
 5789|  59.6k|        if (ccc == 0) {
  ------------------
  |  Branch (5789:13): [True: 51.2k, False: 8.40k]
  ------------------
 5790|  51.2k|          break;
 5791|  51.2k|        }
 5792|  8.40k|        previous_ccc = ccc;
 5793|  8.40k|        input[++composition_count] = input[input_count + 1];
 5794|  8.40k|      }
 5795|  53.2k|    }
 5796|  61.6k|  }
 5797|       |
 5798|  2.26k|  if (composition_count < input_count) {
  ------------------
  |  Branch (5798:7): [True: 1.94k, False: 318]
  ------------------
 5799|  1.94k|    input.resize(composition_count);
 5800|  1.94k|  }
 5801|  2.26k|}
_ZN3ada4idna9normalizeERNSt3__112basic_stringIDiNS1_11char_traitsIDiEENS1_9allocatorIDiEEEE:
 5803|  2.26k|bool normalize(std::u32string& input) {
 5804|       |  /**
 5805|       |   * Normalize the characters according to IDNA (Unicode Normalization Form C).
 5806|       |   * @see https://www.unicode.org/reports/tr46/#ProcessingStepNormalize
 5807|       |   */
 5808|  2.26k|  if (!ensure_tables() || decomposition_index == nullptr ||
  ------------------
  |  Branch (5808:7): [True: 0, False: 2.26k]
  |  Branch (5808:27): [True: 0, False: 2.26k]
  ------------------
 5809|  2.26k|      composition_index == nullptr) {
  ------------------
  |  Branch (5809:7): [True: 0, False: 2.26k]
  ------------------
 5810|      0|    return false;
 5811|      0|  }
 5812|  2.26k|  if (is_already_nfc(input)) {
  ------------------
  |  Branch (5812:7): [True: 0, False: 2.26k]
  ------------------
 5813|      0|    return true;
 5814|      0|  }
 5815|  2.26k|  decompose_nfc(input);
 5816|  2.26k|  compose(input);
 5817|  2.26k|  return true;
 5818|  2.26k|}
_ZN3ada4idna17punycode_to_utf32ENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEERNS1_12basic_stringIDiNS3_IDiEENS1_9allocatorIDiEEEE:
 5878|  4.53k|bool punycode_to_utf32(std::string_view input, std::u32string &out) {
 5879|  4.53k|  int32_t written_out{0};
 5880|  4.53k|  out.reserve(out.size() + input.size());
 5881|  4.53k|  uint32_t n = initial_n;
 5882|  4.53k|  int32_t i = 0;
 5883|  4.53k|  int32_t bias = initial_bias;
 5884|       |  // grab ascii content
 5885|       |  // RFC 3492 section 6.2: copy the code points before the last delimiter,
 5886|       |  // then consume the delimiter only "if more than zero code points were
 5887|       |  // consumed". With a leading delimiter, b == 0, decoding starts at the
 5888|       |  // delimiter itself, which is not a digit, and fails. This matches the
 5889|       |  // reference implementation in appendix C (`in = b > 0 ? b + 1 : 0`).
 5890|  4.53k|  size_t end_of_ascii = input.find_last_of('-');
 5891|  4.53k|  if (end_of_ascii != std::string_view::npos && end_of_ascii > 0) {
  ------------------
  |  Branch (5891:7): [True: 951, False: 3.58k]
  |  Branch (5891:49): [True: 933, False: 18]
  ------------------
 5892|  10.1k|    for (uint8_t c : input.substr(0, end_of_ascii)) {
  ------------------
  |  Branch (5892:20): [True: 10.1k, False: 933]
  ------------------
 5893|  10.1k|      if (c >= 0x80) {
  ------------------
  |  Branch (5893:11): [True: 0, False: 10.1k]
  ------------------
 5894|      0|        return false;
 5895|      0|      }
 5896|  10.1k|      out.push_back(c);
 5897|  10.1k|      written_out++;
 5898|  10.1k|    }
 5899|    933|    input.remove_prefix(end_of_ascii + 1);
 5900|    933|  }
 5901|  57.2k|  while (!input.empty()) {
  ------------------
  |  Branch (5901:10): [True: 53.0k, False: 4.16k]
  ------------------
 5902|  53.0k|    int32_t oldi = i;
 5903|  53.0k|    int32_t w = 1;
 5904|  71.7k|    for (int32_t k = base;; k += base) {
 5905|  71.7k|      if (input.empty()) {
  ------------------
  |  Branch (5905:11): [True: 168, False: 71.5k]
  ------------------
 5906|    168|        return false;
 5907|    168|      }
 5908|  71.5k|      uint8_t code_point = input.front();
 5909|  71.5k|      input.remove_prefix(1);
 5910|  71.5k|      int32_t digit = char_to_digit_value(code_point);
 5911|  71.5k|      if (digit < 0) {
  ------------------
  |  Branch (5911:11): [True: 99, False: 71.4k]
  ------------------
 5912|     99|        return false;
 5913|     99|      }
 5914|  71.4k|      if (digit > (0x7fffffff - i) / w) {
  ------------------
  |  Branch (5914:11): [True: 18, False: 71.4k]
  ------------------
 5915|     18|        return false;
 5916|     18|      }
 5917|  71.4k|      i = i + digit * w;
 5918|  71.4k|      int32_t t = k <= bias ? tmin : k >= bias + tmax ? tmax : k - bias;
  ------------------
  |  Branch (5918:19): [True: 13.1k, False: 58.2k]
  |  Branch (5918:38): [True: 54.6k, False: 3.59k]
  ------------------
 5919|  71.4k|      if (digit < t) {
  ------------------
  |  Branch (5919:11): [True: 52.8k, False: 18.6k]
  ------------------
 5920|  52.8k|        break;
 5921|  52.8k|      }
 5922|  18.6k|      if (w > 0x7fffffff / (base - t)) {
  ------------------
  |  Branch (5922:11): [True: 0, False: 18.6k]
  ------------------
 5923|      0|        return false;
 5924|      0|      }
 5925|  18.6k|      w = w * (base - t);
 5926|  18.6k|    }
 5927|  52.8k|    bias = adapt(i - oldi, written_out + 1, oldi == 0);
 5928|  52.8k|    if (i / (written_out + 1) > int32_t(0x7fffffff - n)) {
  ------------------
  |  Branch (5928:9): [True: 81, False: 52.7k]
  ------------------
 5929|     81|      return false;
 5930|     81|    }
 5931|  52.7k|    n = n + i / (written_out + 1);
 5932|  52.7k|    i = i % (written_out + 1);
 5933|  52.7k|    if (n < 0x80) {
  ------------------
  |  Branch (5933:9): [True: 0, False: 52.7k]
  ------------------
 5934|      0|      return false;
 5935|      0|    }
 5936|  52.7k|    out.insert(out.begin() + i, n);
 5937|  52.7k|    written_out++;
 5938|  52.7k|    ++i;
 5939|  52.7k|  }
 5940|       |  // See https://github.com/whatwg/url/issues/803
 5941|       |  // Reject labels whose decoded form begins with "xn--" (double-encoded ACE).
 5942|  4.16k|  if (out.size() >= 4 && out[0] == U'x' && out[1] == U'n' && out[2] == U'-' &&
  ------------------
  |  Branch (5942:7): [True: 2.10k, False: 2.06k]
  |  Branch (5942:26): [True: 480, False: 1.62k]
  |  Branch (5942:44): [True: 300, False: 180]
  |  Branch (5942:62): [True: 153, False: 147]
  ------------------
 5943|    153|      out[3] == U'-') {
  ------------------
  |  Branch (5943:7): [True: 9, False: 144]
  ------------------
 5944|      9|    return false;
 5945|      9|  }
 5946|  4.15k|  return true;
 5947|  4.16k|}
_ZN3ada4idna17utf32_to_punycodeENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEERNS1_12basic_stringIcNS3_IcEENS1_9allocatorIcEEEE:
 6027|  36.1k|bool utf32_to_punycode(std::u32string_view input, std::string &out) {
 6028|  36.1k|  out.reserve(input.size() + out.size());
 6029|  36.1k|  uint32_t n = initial_n;
 6030|  36.1k|  int32_t d = 0;
 6031|  36.1k|  int32_t bias = initial_bias;
 6032|  36.1k|  size_t h = 0;
 6033|       |  // first push the ascii content
 6034|   161k|  for (uint32_t c : input) {
  ------------------
  |  Branch (6034:19): [True: 161k, False: 36.1k]
  ------------------
 6035|   161k|    if (c < 0x80) {
  ------------------
  |  Branch (6035:9): [True: 22.0k, False: 139k]
  ------------------
 6036|  22.0k|      ++h;
 6037|  22.0k|      out.push_back(char(c));
 6038|  22.0k|    }
 6039|   161k|    if (c > 0x10ffff || (c >= 0xd800 && c < 0xe000)) {
  ------------------
  |  Branch (6039:9): [True: 0, False: 161k]
  |  Branch (6039:26): [True: 2.09k, False: 159k]
  |  Branch (6039:41): [True: 0, False: 2.09k]
  ------------------
 6040|      0|      return false;
 6041|      0|    }
 6042|   161k|  }
 6043|  36.1k|  size_t b = h;
 6044|  36.1k|  if (b > 0) {
  ------------------
  |  Branch (6044:7): [True: 6.08k, False: 30.0k]
  ------------------
 6045|  6.08k|    out.push_back('-');
 6046|  6.08k|  }
 6047|   156k|  while (h < input.size()) {
  ------------------
  |  Branch (6047:10): [True: 120k, False: 36.1k]
  ------------------
 6048|   120k|    uint32_t m = 0x10FFFF;
 6049|   668k|    for (auto code_point : input) {
  ------------------
  |  Branch (6049:26): [True: 668k, False: 120k]
  ------------------
 6050|   668k|      if (code_point >= n && code_point < m) m = code_point;
  ------------------
  |  Branch (6050:11): [True: 386k, False: 282k]
  |  Branch (6050:30): [True: 210k, False: 175k]
  ------------------
 6051|   668k|    }
 6052|       |
 6053|   120k|    if ((m - n) > (0x7fffffff - d) / (h + 1)) {
  ------------------
  |  Branch (6053:9): [True: 0, False: 120k]
  ------------------
 6054|      0|      return false;
 6055|      0|    }
 6056|   120k|    d = d + int32_t((m - n) * (h + 1));
 6057|   120k|    n = m;
 6058|   668k|    for (auto c : input) {
  ------------------
  |  Branch (6058:17): [True: 668k, False: 120k]
  ------------------
 6059|   668k|      if (c < n) {
  ------------------
  |  Branch (6059:11): [True: 282k, False: 386k]
  ------------------
 6060|   282k|        if (d == 0x7fffffff) {
  ------------------
  |  Branch (6060:13): [True: 0, False: 282k]
  ------------------
 6061|      0|          return false;
 6062|      0|        }
 6063|   282k|        ++d;
 6064|   282k|      }
 6065|   668k|      if (c == n) {
  ------------------
  |  Branch (6065:11): [True: 139k, False: 529k]
  ------------------
 6066|   139k|        int32_t q = d;
 6067|   416k|        for (int32_t k = base;; k += base) {
 6068|   416k|          int32_t t = k <= bias ? tmin : k >= bias + tmax ? tmax : k - bias;
  ------------------
  |  Branch (6068:23): [True: 129k, False: 287k]
  |  Branch (6068:42): [True: 206k, False: 80.7k]
  ------------------
 6069|       |
 6070|   416k|          if (q < t) {
  ------------------
  |  Branch (6070:15): [True: 139k, False: 276k]
  ------------------
 6071|   139k|            break;
 6072|   139k|          }
 6073|   276k|          out.push_back(digit_to_char(t + ((q - t) % (base - t))));
 6074|   276k|          q = (q - t) / (base - t);
 6075|   276k|        }
 6076|   139k|        out.push_back(digit_to_char(q));
 6077|   139k|        bias = adapt(d, int32_t(h + 1), h == b);
 6078|   139k|        d = 0;
 6079|   139k|        ++h;
 6080|   139k|      }
 6081|   668k|    }
 6082|   120k|    ++d;
 6083|   120k|    ++n;
 6084|   120k|  }
 6085|  36.1k|  return true;
 6086|  36.1k|}
_ZN3ada4idna8to_asciiENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEERNS1_12basic_stringIcS4_NS1_9allocatorIcEEEE:
 6548|  18.6k|[[nodiscard]] bool to_ascii(std::string_view ut8_string, std::string& out) {
 6549|  18.6k|  out.clear();
 6550|       |  // The ASCII path is a single same-size copy, so it needs no length bound.
 6551|       |  // Checking first would reject the (longer) ASCII output of a non-ASCII input
 6552|       |  // that was accepted, breaking to_ascii(to_ascii(x)) == to_ascii(x).
 6553|  18.6k|  if (is_ascii(ut8_string)) {
  ------------------
  |  Branch (6553:7): [True: 6.04k, False: 12.6k]
  ------------------
 6554|  6.04k|    from_ascii_to_ascii(ut8_string, out);
 6555|  6.04k|    return true;
 6556|  6.04k|  }
 6557|  12.6k|  if (ut8_string.size() > max_domain_input_bytes) {
  ------------------
  |  Branch (6557:7): [True: 0, False: 12.6k]
  ------------------
 6558|      0|    return false;
 6559|      0|  }
 6560|       |
 6561|       |#ifdef ADA_USE_SIMDUTF
 6562|       |  size_t utf32_length =
 6563|       |      simdutf::utf32_length_from_utf8(ut8_string.data(), ut8_string.size());
 6564|       |  if (utf32_length == 0 && !ut8_string.empty()) {
 6565|       |    return false;
 6566|       |  }
 6567|       |  std::u32string working(utf32_length, U'\0');
 6568|       |  size_t actual_utf32_length = simdutf::convert_utf8_to_utf32(
 6569|       |      ut8_string.data(), ut8_string.size(), working.data());
 6570|       |#else
 6571|  12.6k|  size_t utf32_length =
 6572|  12.6k|      ada::idna::utf32_length_from_utf8(ut8_string.data(), ut8_string.size());
 6573|  12.6k|  if (utf32_length == 0 && !ut8_string.empty()) {
  ------------------
  |  Branch (6573:7): [True: 147, False: 12.5k]
  |  Branch (6573:28): [True: 147, False: 0]
  ------------------
 6574|    147|    return false;
 6575|    147|  }
 6576|  12.5k|  std::u32string working(utf32_length, U'\0');
 6577|  12.5k|  size_t actual_utf32_length = ada::idna::utf8_to_utf32(
 6578|  12.5k|      ut8_string.data(), ut8_string.size(), working.data());
 6579|  12.5k|#endif
 6580|  12.5k|  if (actual_utf32_length == 0 || actual_utf32_length != utf32_length) {
  ------------------
  |  Branch (6580:7): [True: 945, False: 11.5k]
  |  Branch (6580:35): [True: 0, False: 11.5k]
  ------------------
 6581|    945|    return false;
 6582|    945|  }
 6583|  11.5k|  working.resize(actual_utf32_length);
 6584|       |
 6585|       |  // Map into a second buffer with exact sizing (no growth reallocs).
 6586|  11.5k|  std::u32string mapped;
 6587|  11.5k|  if (!ada::idna::map(working, mapped)) {
  ------------------
  |  Branch (6587:7): [True: 129, False: 11.4k]
  ------------------
 6588|    129|    return false;
 6589|    129|  }
 6590|       |  // Drop UTF-32 input; reuse `working` as scratch for ACE validation below.
 6591|  11.4k|  working.clear();
 6592|       |
 6593|       |  // Skip NFC when already normalized (ASCII is a fast subset of this check).
 6594|  11.4k|  if (!is_ascii(mapped) && !is_already_nfc(mapped)) {
  ------------------
  |  Branch (6594:7): [True: 8.38k, False: 3.04k]
  |  Branch (6594:28): [True: 1.81k, False: 6.57k]
  ------------------
 6595|  1.81k|    if (!normalize(mapped)) {
  ------------------
  |  Branch (6595:9): [True: 0, False: 1.81k]
  ------------------
 6596|      0|      return false;
 6597|      0|    }
 6598|  1.81k|  }
 6599|       |
 6600|       |  // Estimate ASCII output size (punycode may expand non-ASCII labels).
 6601|  11.4k|  out.reserve(mapped.size() + 8);
 6602|       |
 6603|       |  // CheckBidi applies to every label once any label is RTL (RFC 5893), which a
 6604|       |  // later label can decide. Any failure rejects the whole domain, so it is
 6605|       |  // enough to know at the end whether some label is RTL and whether every
 6606|       |  // label satisfies the Bidi rule.
 6607|  11.4k|  bool bidi_domain = false;
 6608|  11.4k|  bool bidi_rule_holds = true;
 6609|  11.4k|  auto accept = [&](const label_check& check) {
 6610|  11.4k|    bidi_domain = bidi_domain || check.rtl;
 6611|  11.4k|    bidi_rule_holds = bidi_rule_holds && check.bidi;
 6612|  11.4k|    return check.valid && (bidi_rule_holds || !bidi_domain);
 6613|  11.4k|  };
 6614|       |
 6615|       |  // Walk labels with a single pointer scan (no repeated string::find).
 6616|  11.4k|  const char32_t* p = mapped.data();
 6617|  11.4k|  const char32_t* const end = p + mapped.size();
 6618|  11.4k|  std::u32string post_map;
 6619|       |
 6620|  63.4k|  while (p < end) {
  ------------------
  |  Branch (6620:10): [True: 55.1k, False: 8.23k]
  ------------------
 6621|  55.1k|    const char32_t* label_begin = p;
 6622|   411k|    while (p < end && *p != U'.') {
  ------------------
  |  Branch (6622:12): [True: 401k, False: 10.8k]
  |  Branch (6622:23): [True: 356k, False: 44.3k]
  ------------------
 6623|   356k|      ++p;
 6624|   356k|    }
 6625|  55.1k|    const size_t label_size = static_cast<size_t>(p - label_begin);
 6626|  55.1k|    std::u32string_view label_view(label_begin, label_size);
 6627|  55.1k|    const bool is_last_label = (p == end);
 6628|  55.1k|    if (p < end) {
  ------------------
  |  Branch (6628:9): [True: 44.3k, False: 10.8k]
  ------------------
 6629|  44.3k|      ++p;  // skip dot
 6630|  44.3k|    }
 6631|       |
 6632|  55.1k|    if (label_size == 0) {
  ------------------
  |  Branch (6632:9): [True: 3.36k, False: 51.8k]
  ------------------
 6633|       |      // empty label
 6634|  51.8k|    } else if (is_ace_prefix(label_view)) {
  ------------------
  |  Branch (6634:16): [True: 4.58k, False: 47.2k]
  ------------------
 6635|   105k|      for (char32_t c : label_view) {
  ------------------
  |  Branch (6635:23): [True: 105k, False: 4.53k]
  ------------------
 6636|   105k|        if (c >= 0x80) {
  ------------------
  |  Branch (6636:13): [True: 51, False: 105k]
  ------------------
 6637|     51|          out.clear();
 6638|     51|          return false;
 6639|     51|        }
 6640|   105k|      }
 6641|  4.53k|      append_ascii_label(out, label_view);
 6642|  4.53k|      std::string_view puny_segment_ascii(
 6643|  4.53k|          out.data() + (out.size() - label_size) + 4, label_size - 4);
 6644|  4.53k|      working.clear();
 6645|  4.53k|      if (!ada::idna::punycode_to_utf32(puny_segment_ascii, working)) {
  ------------------
  |  Branch (6645:11): [True: 375, False: 4.15k]
  ------------------
 6646|    375|        out.clear();
 6647|    375|        return false;
 6648|    375|      }
 6649|  4.15k|      if (is_ascii(working)) {
  ------------------
  |  Branch (6649:11): [True: 213, False: 3.94k]
  ------------------
 6650|    213|        out.clear();
 6651|    213|        return false;
 6652|    213|      }
 6653|  3.94k|      if (!ada::idna::map(working, post_map) || working != post_map) {
  ------------------
  |  Branch (6653:11): [True: 576, False: 3.36k]
  |  Branch (6653:49): [True: 300, False: 3.06k]
  ------------------
 6654|    876|        out.clear();
 6655|    876|        return false;
 6656|    876|      }
 6657|       |      // Mapping must be stable; NFC must not change the mapped form either.
 6658|  3.06k|      if (!is_ascii(post_map) && !is_already_nfc(post_map)) {
  ------------------
  |  Branch (6658:11): [True: 3.06k, False: 0]
  |  Branch (6658:34): [True: 450, False: 2.61k]
  ------------------
 6659|    450|        if (!normalize(post_map) || post_map != working) {
  ------------------
  |  Branch (6659:13): [True: 0, False: 450]
  |  Branch (6659:37): [True: 372, False: 78]
  ------------------
 6660|    372|          out.clear();
 6661|    372|          return false;
 6662|    372|        }
 6663|    450|      }
 6664|  2.69k|      if (post_map.empty() || !accept(check_label(post_map))) {
  ------------------
  |  Branch (6664:11): [True: 0, False: 2.69k]
  |  Branch (6664:11): [True: 90, False: 2.60k]
  |  Branch (6664:31): [True: 90, False: 2.60k]
  ------------------
 6665|     90|        out.clear();
 6666|     90|        return false;
 6667|     90|      }
 6668|  47.2k|    } else if (is_ascii(label_view)) {
  ------------------
  |  Branch (6668:16): [True: 9.90k, False: 37.3k]
  ------------------
 6669|       |      // All-ASCII domains never reach here (they return above). An ASCII label
 6670|       |      // in a Bidi domain must still satisfy RFC 5893 rules 1, 5, and 6.
 6671|  9.90k|      if (!accept(check_label(label_view))) {
  ------------------
  |  Branch (6671:11): [True: 39, False: 9.86k]
  ------------------
 6672|     39|        out.clear();
 6673|     39|        return false;
 6674|     39|      }
 6675|  9.86k|      append_ascii_label(out, label_view);
 6676|  37.3k|    } else {
 6677|  37.3k|      if (!accept(check_label(label_view))) {
  ------------------
  |  Branch (6677:11): [True: 1.17k, False: 36.1k]
  ------------------
 6678|  1.17k|        out.clear();
 6679|  1.17k|        return false;
 6680|  1.17k|      }
 6681|  36.1k|      out.append("xn--");
 6682|  36.1k|      if (!ada::idna::utf32_to_punycode(label_view, out)) {
  ------------------
  |  Branch (6682:11): [True: 0, False: 36.1k]
  ------------------
 6683|      0|        out.clear();
 6684|      0|        return false;
 6685|      0|      }
 6686|  36.1k|    }
 6687|  51.9k|    if (!is_last_label) {
  ------------------
  |  Branch (6687:9): [True: 44.1k, False: 7.79k]
  ------------------
 6688|  44.1k|      out.push_back('.');
 6689|  44.1k|    }
 6690|  51.9k|  }
 6691|  8.23k|  return true;
 6692|  11.4k|}
_ZN3ada4idna8to_asciiENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 6694|  18.6k|std::string to_ascii(std::string_view ut8_string) {
 6695|  18.6k|  std::string out;
 6696|  18.6k|  if (!to_ascii(ut8_string, out)) {
  ------------------
  |  Branch (6696:7): [True: 4.41k, False: 14.2k]
  ------------------
 6697|  4.41k|    return {};
 6698|  4.41k|  }
 6699|  14.2k|  return out;
 6700|  18.6k|}
_ZN3ada7unicode14percent_encodeILb1EEEbNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEPKhRNS2_12basic_stringIcS5_NS2_9allocatorIcEEEE:
 7679|  30.0k|                    std::string& out) {
 7680|  30.0k|  ada_log("percent_encode ", input, " to output string while ",
 7681|  30.0k|          append ? "appending" : "overwriting");
 7682|  30.0k|  auto pointer = std::ranges::find_if(input, [character_set](const char c) {
 7683|  30.0k|    return character_sets::bit_at(character_set, c);
 7684|  30.0k|  });
 7685|  30.0k|  ada_log("percent_encode done checking, moved to ",
 7686|  30.0k|          std::distance(input.begin(), pointer));
 7687|       |
 7688|       |  // Optimization: Don't iterate if percent encode is not required
 7689|  30.0k|  if (pointer == input.end()) {
  ------------------
  |  Branch (7689:7): [True: 18.8k, False: 11.1k]
  ------------------
 7690|  18.8k|    ada_log("percent_encode encoding not needed.");
 7691|  18.8k|    return false;
 7692|  18.8k|  }
 7693|       |  if constexpr (!append) {
 7694|       |    out.clear();
 7695|       |  }
 7696|  11.1k|  ada_log("percent_encode appending ", std::distance(input.begin(), pointer),
 7697|  11.1k|          " bytes");
 7698|       |  // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
 7699|  11.1k|  out.append(input.data(), std::distance(input.begin(), pointer));
 7700|  11.1k|  ada_log("percent_encode processing ", std::distance(pointer, input.end()),
 7701|  11.1k|          " bytes");
 7702|   135k|  for (; pointer != input.end(); pointer++) {
  ------------------
  |  Branch (7702:10): [True: 124k, False: 11.1k]
  ------------------
 7703|   124k|    if (character_sets::bit_at(character_set, *pointer)) {
  ------------------
  |  Branch (7703:9): [True: 112k, False: 12.6k]
  ------------------
 7704|   112k|      out.append(character_sets::hex + uint8_t(*pointer) * 4, 3);
 7705|   112k|    } else {
 7706|  12.6k|      out += *pointer;
 7707|  12.6k|    }
 7708|   124k|  }
 7709|  11.1k|  return true;
 7710|  30.0k|}
_ZN3ada7unicode14percent_decodeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEm:
 7510|  4.21k|std::string percent_decode(const std::string_view input, size_t first_percent) {
 7511|       |  // next line is for safety only, we expect users to avoid calling
 7512|       |  // percent_decode when first_percent is outside the range.
 7513|  4.21k|  if (first_percent == std::string_view::npos) {
  ------------------
  |  Branch (7513:7): [True: 0, False: 4.21k]
  ------------------
 7514|      0|    return std::string(input);
 7515|      0|  }
 7516|       |
 7517|       |  // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
 7518|  4.21k|  const char* const src = input.data();
 7519|  4.21k|  const char* const end = src + input.size();
 7520|       |
 7521|       |  // Decoding never grows the string, so a single pre-sized buffer written via
 7522|       |  // bulk memcpy of the plain runs (then shrunk to the final length) avoids the
 7523|       |  // byte-at-a-time appends of the naive version.
 7524|  4.21k|  std::string out(input.size(), '\0');
 7525|  4.21k|  char* d = out.data();
 7526|  4.21k|  char* const d0 = d;
 7527|       |
 7528|  4.21k|  std::memcpy(d, src, first_percent);
 7529|  4.21k|  d += first_percent;
 7530|       |
 7531|  4.21k|  const char* p = src + first_percent;
 7532|  21.8k|  while (p < end) {
  ------------------
  |  Branch (7532:10): [True: 17.6k, False: 4.21k]
  ------------------
 7533|  17.6k|    if (*p == '%') {
  ------------------
  |  Branch (7533:9): [True: 10.9k, False: 6.68k]
  ------------------
 7534|       |      // Decode runs of valid %XX tightly (common for nested/encoded URLs).
 7535|  17.7k|      while (p + 2 < end && *p == '%') {
  ------------------
  |  Branch (7535:14): [True: 15.1k, False: 2.66k]
  |  Branch (7535:29): [True: 13.0k, False: 2.03k]
  ------------------
 7536|  13.0k|        if (!is_ascii_hex_digit(p[1]) || !is_ascii_hex_digit(p[2])) {
  ------------------
  |  Branch (7536:13): [True: 3.70k, False: 9.39k]
  |  Branch (7536:42): [True: 2.56k, False: 6.82k]
  ------------------
 7537|  6.27k|          break;
 7538|  6.27k|        }
 7539|  6.82k|        *d++ = static_cast<char>(convert_hex_to_binary(p[1]) * 16 +
 7540|  6.82k|                                 convert_hex_to_binary(p[2]));
 7541|  6.82k|        p += 3;
 7542|  6.82k|      }
 7543|  10.9k|      if (p < end && *p == '%') {
  ------------------
  |  Branch (7543:11): [True: 9.80k, False: 1.17k]
  |  Branch (7543:22): [True: 7.02k, False: 2.78k]
  ------------------
 7544|       |        // Not a valid escape (too few chars left or bad hex): copy '%'
 7545|       |        // literally and keep scanning after it.
 7546|  7.02k|        *d++ = *p++;
 7547|  7.02k|      }
 7548|  10.9k|    } else {
 7549|  6.68k|      const char* q = static_cast<const char*>(
 7550|  6.68k|          std::memchr(p, '%', static_cast<size_t>(end - p)));
 7551|  6.68k|      const char* run_end = q ? q : end;
  ------------------
  |  Branch (7551:29): [True: 4.14k, False: 2.53k]
  ------------------
 7552|  6.68k|      const size_t n = static_cast<size_t>(run_end - p);
 7553|  6.68k|      std::memcpy(d, p, n);
 7554|  6.68k|      d += n;
 7555|  6.68k|      p = run_end;
 7556|  6.68k|    }
 7557|  17.6k|  }
 7558|       |
 7559|  4.21k|  out.resize(static_cast<size_t>(d - d0));
 7560|  4.21k|  return out;
 7561|  4.21k|}
_ZN3ada7unicode14percent_encodeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKh:
 7649|  24.4k|                           const uint8_t character_set[]) {
 7650|  24.4k|  auto pointer = std::ranges::find_if(input, [character_set](const char c) {
 7651|  24.4k|    return character_sets::bit_at(character_set, c);
 7652|  24.4k|  });
 7653|       |  // Optimization: Don't iterate if percent encode is not required
 7654|  24.4k|  if (pointer == input.end()) {
  ------------------
  |  Branch (7654:7): [True: 20.0k, False: 4.32k]
  ------------------
 7655|  20.0k|    return std::string(input);
 7656|  20.0k|  }
 7657|       |
 7658|  4.32k|  std::string result;
 7659|  4.32k|  result.reserve(input.length());  // in the worst case, percent encoding might
 7660|       |                                   // produce 3 characters.
 7661|  4.32k|  result.append(input.substr(0, std::distance(input.begin(), pointer)));
 7662|  4.32k|  if (static_cast<size_t>(input.end() - pointer) >= 48) {
  ------------------
  |  Branch (7662:7): [True: 666, False: 3.65k]
  ------------------
 7663|    666|    percent_encode_suffix(&*pointer, input.data() + input.size(), character_set,
 7664|    666|                          result);
 7665|  3.65k|  } else {
 7666|  30.4k|    for (; pointer != input.end(); pointer++) {
  ------------------
  |  Branch (7666:12): [True: 26.8k, False: 3.65k]
  ------------------
 7667|  26.8k|      if (character_sets::bit_at(character_set, *pointer)) {
  ------------------
  |  Branch (7667:11): [True: 22.6k, False: 4.22k]
  ------------------
 7668|  22.6k|        result.append(character_sets::hex + uint8_t(*pointer) * 4, 3);
 7669|  22.6k|      } else {
 7670|  4.22k|        result += *pointer;
 7671|  4.22k|      }
 7672|  26.8k|    }
 7673|  3.65k|  }
 7674|  4.32k|  return result;
 7675|  24.4k|}
_ZN3ada7unicode8to_asciiERNSt3__18optionalINS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEENS1_17basic_string_viewIcS5_EEm:
 7720|  18.6k|              size_t first_percent) {
 7721|  18.6k|  std::string percent_decoded_buffer;
 7722|  18.6k|  std::string_view input = plain;
 7723|  18.6k|  if (first_percent != std::string_view::npos) {
  ------------------
  |  Branch (7723:7): [True: 1.12k, False: 17.5k]
  ------------------
 7724|  1.12k|    percent_decoded_buffer = unicode::percent_decode(plain, first_percent);
 7725|  1.12k|    input = percent_decoded_buffer;
 7726|  1.12k|  }
 7727|       |  // input is a non-empty UTF-8 string, must be percent decoded
 7728|  18.6k|  std::string idna_ascii = ada::idna::to_ascii(input);
 7729|  18.6k|  if (idna_ascii.empty() || contains_forbidden_domain_code_point(
  ------------------
  |  Branch (7729:7): [True: 4.47k, False: 14.2k]
  |  Branch (7729:29): [True: 1.23k, False: 12.9k]
  ------------------
 7730|  14.2k|                                idna_ascii.data(), idna_ascii.size())) {
 7731|  5.71k|    return false;
 7732|  5.71k|  }
 7733|  12.9k|  out = std::move(idna_ascii);
 7734|  12.9k|  return true;
 7735|  18.6k|}
_ZN3ada7unicode14percent_encodeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKhm:
 7738|    542|                           const uint8_t character_set[], size_t index) {
 7739|    542|  std::string out;
 7740|       |  // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
 7741|    542|  out.append(input.data(), index);
 7742|    542|  auto pointer = input.begin() + index;
 7743|    542|  if (static_cast<size_t>(input.end() - pointer) >= 48) {
  ------------------
  |  Branch (7743:7): [True: 184, False: 358]
  ------------------
 7744|    184|    percent_encode_suffix(&*pointer, input.data() + input.size(), character_set,
 7745|    184|                          out);
 7746|    358|  } else {
 7747|  3.20k|    for (; pointer != input.end(); pointer++) {
  ------------------
  |  Branch (7747:12): [True: 2.85k, False: 358]
  ------------------
 7748|  2.85k|      if (character_sets::bit_at(character_set, *pointer)) {
  ------------------
  |  Branch (7748:11): [True: 2.39k, False: 452]
  ------------------
 7749|  2.39k|        out.append(character_sets::hex + uint8_t(*pointer) * 4, 3);
 7750|  2.39k|      } else {
 7751|    452|        out += *pointer;
 7752|    452|      }
 7753|  2.85k|    }
 7754|    358|  }
 7755|    542|  return out;
 7756|    542|}
_ZN3ada7unicode21percent_encode_suffixEPKcS2_PKhRNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE:
 8054|    850|                           const uint8_t character_set[], std::string& out) {
 8055|    850|#if ADA_UNICODE_SSSE3 || ADA_NEON || ADA_RVV
 8056|    850|#ifdef ADA_UNICODE_NEED_SSSE3_TARGET
 8057|    850|  static const bool ssse3_supported = __builtin_cpu_supports("ssse3") != 0;
 8058|    850|  const bool use_wide = ssse3_supported;
 8059|       |#else
 8060|       |  const bool use_wide = true;
 8061|       |#endif
 8062|    850|  if (use_wide && static_cast<size_t>(end - p) >= kPercentEncodeSimdMin) {
  ------------------
  |  Branch (8062:7): [True: 850, False: 0]
  |  Branch (8062:19): [True: 850, False: 0]
  ------------------
 8063|    850|    percent_encode_to_wide(p, end, character_set, out);
 8064|    850|    return;
 8065|    850|  }
 8066|      0|#endif
 8067|      0|  percent_encode_to_scalar(p, end, character_set, out);
 8068|      0|}
_ZN3ada11serializers36find_longest_sequence_of_ipv6_piecesERKNSt3__15arrayItLm8EEERmS6_:
 8133|  1.02k|    size_t& compress_length) noexcept {
 8134|  1.02k|  compress = 0;
 8135|  1.02k|  compress_length = 0;
 8136|  1.02k|  size_t i = 0;
 8137|  4.37k|  while (i < 8) {
  ------------------
  |  Branch (8137:10): [True: 3.34k, False: 1.02k]
  ------------------
 8138|  3.34k|    if (address[i] != 0) {
  ------------------
  |  Branch (8138:9): [True: 2.09k, False: 1.25k]
  ------------------
 8139|  2.09k|      ++i;
 8140|  2.09k|      continue;
 8141|  2.09k|    }
 8142|  1.25k|    size_t next = i + 1;
 8143|  6.11k|    while (next < 8 && address[next] == 0) {
  ------------------
  |  Branch (8143:12): [True: 5.54k, False: 573]
  |  Branch (8143:24): [True: 4.86k, False: 684]
  ------------------
 8144|  4.86k|      ++next;
 8145|  4.86k|    }
 8146|  1.25k|    const size_t count = next - i;
 8147|  1.25k|    if (count > compress_length) {
  ------------------
  |  Branch (8147:9): [True: 1.07k, False: 180]
  ------------------
 8148|  1.07k|      compress_length = count;
 8149|  1.07k|      compress = i;
 8150|  1.07k|    }
 8151|  1.25k|    i = next;
 8152|  1.25k|  }
 8153|  1.02k|}
_ZN3ada11serializers4ipv6ERKNSt3__15arrayItLm8EEE:
 8155|  1.02k|std::string ipv6(const std::array<uint16_t, 8>& address) {
 8156|  1.02k|  size_t compress = 0;
 8157|  1.02k|  size_t compress_length = 0;
 8158|  1.02k|  find_longest_sequence_of_ipv6_pieces(address, compress, compress_length);
 8159|       |
 8160|       |  // Skip compression when the longest zero run is a single piece.
 8161|  1.02k|  if (compress_length <= 1) {
  ------------------
  |  Branch (8161:7): [True: 120, False: 906]
  ------------------
 8162|    120|    compress = compress_length = 8;
 8163|    120|  }
 8164|       |
 8165|       |  // Max: '[' + 8*4 hex + 7 ':' + ']' = 41
 8166|  1.02k|  char output[4 * 8 + 7 + 2];
 8167|  1.02k|  char* point = output;
 8168|  1.02k|  *point++ = '[';
 8169|  1.02k|  size_t piece_index = 0;
 8170|  2.97k|  while (true) {
  ------------------
  |  Branch (8170:10): [True: 2.97k, Folded]
  ------------------
 8171|  2.97k|    if (piece_index == compress) {
  ------------------
  |  Branch (8171:9): [True: 906, False: 2.07k]
  ------------------
 8172|    906|      *point++ = ':';
 8173|       |      // If we skip a value initially, we need to write '::'.
 8174|    906|      if (piece_index == 0) {
  ------------------
  |  Branch (8174:11): [True: 570, False: 336]
  ------------------
 8175|    570|        *point++ = ':';
 8176|    570|      }
 8177|    906|      piece_index += compress_length;
 8178|    906|      if (piece_index == 8) {
  ------------------
  |  Branch (8178:11): [True: 507, False: 399]
  ------------------
 8179|    507|        break;
 8180|    507|      }
 8181|    906|    }
 8182|  2.46k|    point = write_hex_u16(point, address[piece_index]);
 8183|  2.46k|    ++piece_index;
 8184|  2.46k|    if (piece_index == 8) {
  ------------------
  |  Branch (8184:9): [True: 519, False: 1.95k]
  ------------------
 8185|    519|      break;
 8186|    519|    }
 8187|  1.95k|    *point++ = ':';
 8188|  1.95k|  }
 8189|  1.02k|  *point++ = ']';
 8190|  1.02k|  return std::string(output, static_cast<size_t>(point - output));
 8191|  1.02k|}
_ZN3ada11serializers4ipv4Em:
 8193|  4.53k|std::string ipv4(const uint64_t address) {
 8194|  4.53k|  std::string output(15, '\0');
 8195|  4.53k|  char* point = output.data();
 8196|  4.53k|  point = write_u8(point, static_cast<uint8_t>(address >> 24));
 8197|  4.53k|  *point++ = '.';
 8198|  4.53k|  point = write_u8(point, static_cast<uint8_t>(address >> 16));
 8199|  4.53k|  *point++ = '.';
 8200|  4.53k|  point = write_u8(point, static_cast<uint8_t>(address >> 8));
 8201|  4.53k|  *point++ = '.';
 8202|  4.53k|  point = write_u8(point, static_cast<uint8_t>(address));
 8203|  4.53k|  output.resize(static_cast<size_t>(point - output.data()));
 8204|  4.53k|  return output;
 8205|  4.53k|}
_ZN3ada5parseINS_3urlEEEN2tl8expectedIT_NS_6errorsEEENSt3__117basic_string_viewIcNS7_11char_traitsIcEEEEPKS4_:
 8609|  50.6k|    std::string_view input, const result_type* base_url) {
 8610|  50.6k|  result_type u = ada::parser::parse_url_impl<result_type>(input, base_url);
 8611|  50.6k|  if (!u.is_valid) {
  ------------------
  |  Branch (8611:7): [True: 25.9k, False: 24.7k]
  ------------------
 8612|  25.9k|    return tl::unexpected(errors::type_error);
 8613|  25.9k|  }
 8614|  24.7k|  return u;
 8615|  50.6k|}
_ZN3ada5parseINS_14url_aggregatorEEEN2tl8expectedIT_NS_6errorsEEENSt3__117basic_string_viewIcNS7_11char_traitsIcEEEEPKS4_:
 8609|  50.6k|    std::string_view input, const result_type* base_url) {
 8610|  50.6k|  result_type u = ada::parser::parse_url_impl<result_type>(input, base_url);
 8611|  50.6k|  if (!u.is_valid) {
  ------------------
  |  Branch (8611:7): [True: 25.9k, False: 24.7k]
  ------------------
 8612|  25.9k|    return tl::unexpected(errors::type_error);
 8613|  25.9k|  }
 8614|  24.7k|  return u;
 8615|  50.6k|}
_ZN3ada20get_max_input_lengthEv:
 8230|   164k|uint32_t get_max_input_length() {
 8231|   164k|  return max_input_length_.load(std::memory_order_relaxed);
 8232|   164k|}
_ZN3ada9can_parseENSt3__117basic_string_viewIcNS0_11char_traitsIcEEEEPKS4_:
 8657|  46.2k|bool can_parse(std::string_view input, const std::string_view* base_input) {
 8658|       |  // Must match parse().has_value(), including post-normalization max length.
 8659|       |  // Percent-encoding expands a byte by at most 3x, but IDNA expands more: a
 8660|       |  // 3-byte UTF-8 label such as U+337F becomes the 17-byte "xn--6oqv20b1zgzxr",
 8661|       |  // so a dotted host sustains 4.5x. When the input (plus base, if any) fits in
 8662|       |  // max_length/5, the normalized href cannot exceed max_length, so
 8663|       |  // validation-only parsing (store_values=false) is safe.
 8664|       |
 8665|       |  // Hot path first: absolute special URLs, no base. Avoid loading max_length
 8666|       |  // until we need it (common absolute-fast true/false cases).
 8667|  46.2k|  if (base_input == nullptr) {
  ------------------
  |  Branch (8667:7): [True: 33.6k, False: 12.6k]
  ------------------
 8668|  33.6k|    auto r = try_can_parse_clean_http(input);
 8669|  33.6k|    if (!r.has_value()) {
  ------------------
  |  Branch (8669:9): [True: 33.4k, False: 185]
  ------------------
 8670|  33.4k|      r = try_can_parse_absolute_fast(input);
 8671|  33.4k|    }
 8672|  33.6k|    if (r.has_value()) {
  ------------------
  |  Branch (8672:9): [True: 19.6k, False: 13.9k]
  ------------------
 8673|  19.6k|      if (!*r) {
  ------------------
  |  Branch (8673:11): [True: 14.2k, False: 5.38k]
  ------------------
 8674|  14.2k|        return false;
 8675|  14.2k|      }
 8676|       |      // size <= max/5 => normalized href cannot exceed max (4.5x expansion).
 8677|       |      // Check this first: default max is ~4GB so almost all URLs return true.
 8678|  5.38k|      const uint32_t max_length = ada::get_max_input_length();
 8679|  5.38k|      if (input.size() <= static_cast<size_t>(max_length) / 5) {
  ------------------
  |  Branch (8679:11): [True: 5.38k, False: 0]
  ------------------
 8680|  5.38k|        return true;
 8681|  5.38k|      }
 8682|      0|      if (input.size() > max_length) {
  ------------------
  |  Branch (8682:11): [True: 0, False: 0]
  ------------------
 8683|      0|        return false;
 8684|      0|      }
 8685|      0|      return ada::parser::parse_url_impl<ada::url_aggregator, true>(input,
 8686|      0|                                                                    nullptr)
 8687|      0|          .is_valid;
 8688|      0|    }
 8689|  33.6k|  }
 8690|       |
 8691|  26.5k|  const uint32_t max_length = ada::get_max_input_length();
 8692|  26.5k|  if (input.size() > max_length) {
  ------------------
  |  Branch (8692:7): [True: 0, False: 26.5k]
  ------------------
 8693|      0|    return false;
 8694|      0|  }
 8695|  26.5k|  if (base_input != nullptr && base_input->size() > max_length) {
  ------------------
  |  Branch (8695:7): [True: 12.6k, False: 13.9k]
  |  Branch (8695:32): [True: 0, False: 12.6k]
  ------------------
 8696|      0|    return false;
 8697|      0|  }
 8698|       |
 8699|       |  // Relative resolution combines base + input; bound the sum so 4.5x expansion
 8700|       |  // of either side cannot push the final href past max_length.
 8701|  26.5k|  const size_t combined =
 8702|  26.5k|      input.size() + (base_input == nullptr ? 0 : base_input->size());
  ------------------
  |  Branch (8702:23): [True: 13.9k, False: 12.6k]
  ------------------
 8703|  26.5k|  const bool size_safe = combined <= static_cast<size_t>(max_length) / 5;
 8704|       |
 8705|  26.5k|  if (size_safe) {
  ------------------
  |  Branch (8705:7): [True: 26.5k, False: 0]
  ------------------
 8706|       |    // Validation-only: no buffer build, host still fully checked.
 8707|  26.5k|    ada::url_aggregator base_agg;
 8708|  26.5k|    ada::url_aggregator* base_ptr = nullptr;
 8709|  26.5k|    if (base_input != nullptr) {
  ------------------
  |  Branch (8709:9): [True: 12.6k, False: 13.9k]
  ------------------
 8710|  12.6k|      base_agg = ada::parser::parse_url_impl<ada::url_aggregator, false>(
 8711|  12.6k|          *base_input, nullptr);
 8712|  12.6k|      if (!base_agg.is_valid) {
  ------------------
  |  Branch (8712:11): [True: 8.17k, False: 4.45k]
  ------------------
 8713|  8.17k|        return false;
 8714|  8.17k|      }
 8715|  4.45k|      base_ptr = &base_agg;
 8716|  4.45k|    }
 8717|  18.4k|    return ada::parser::parse_url_impl<ada::url_aggregator, false>(input,
 8718|  18.4k|                                                                   base_ptr)
 8719|  18.4k|        .is_valid;
 8720|  26.5k|  }
 8721|       |
 8722|       |  // Near the limit: full parse so post-normalization length matches parse().
 8723|      0|  if (base_input == nullptr) {
  ------------------
  |  Branch (8723:7): [True: 0, False: 0]
  ------------------
 8724|      0|    return ada::parser::parse_url_impl<ada::url_aggregator, true>(input,
 8725|      0|                                                                  nullptr)
 8726|      0|        .is_valid;
 8727|      0|  }
 8728|      0|  ada::url_aggregator base_agg =
 8729|      0|      ada::parser::parse_url_impl<ada::url_aggregator, true>(*base_input,
 8730|      0|                                                             nullptr);
 8731|      0|  if (!base_agg.is_valid) {
  ------------------
  |  Branch (8731:7): [True: 0, False: 0]
  ------------------
 8732|      0|    return false;
 8733|      0|  }
 8734|      0|  return ada::parser::parse_url_impl<ada::url_aggregator, true>(input,
 8735|      0|                                                                &base_agg)
 8736|      0|      .is_valid;
 8737|      0|}
_ZN3ada7helpers18trim_c0_whitespaceERNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9597|   121k|void trim_c0_whitespace(std::string_view& input) noexcept {
 9598|   128k|  while (!input.empty() &&
  ------------------
  |  Branch (9598:10): [True: 77.4k, False: 50.5k]
  ------------------
 9599|  77.4k|         ada::unicode::is_c0_control_or_space(input.front())) {
  ------------------
  |  Branch (9599:10): [True: 6.69k, False: 70.7k]
  ------------------
 9600|  6.69k|    input.remove_prefix(1);
 9601|  6.69k|  }
 9602|   126k|  while (!input.empty() && ada::unicode::is_c0_control_or_space(input.back())) {
  ------------------
  |  Branch (9602:10): [True: 75.9k, False: 50.5k]
  |  Branch (9602:28): [True: 5.20k, False: 70.7k]
  ------------------
 9603|  5.20k|    input.remove_suffix(1);
 9604|  5.20k|  }
 9605|   121k|}
_ZN3ada7helpers8overlapsENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEERKNS1_12basic_stringIcS4_NS1_9allocatorIcEEEE:
 9769|     44|bool overlaps(std::string_view input1, const std::string& input2) noexcept {
 9770|     44|  ada_log("helpers::overlaps check if string_view '", input1, "' [",
 9771|     44|          input1.size(), " bytes] is part of string '", input2, "' [",
 9772|     44|          input2.size(), " bytes]");
 9773|     44|  return !input1.empty() && !input2.empty() && input1.data() >= input2.data() &&
  ------------------
  |  Branch (9773:10): [True: 44, False: 0]
  |  Branch (9773:29): [True: 44, False: 0]
  |  Branch (9773:48): [True: 17, False: 27]
  ------------------
 9774|     17|         input1.data() < input2.data() + input2.size();
  ------------------
  |  Branch (9774:10): [True: 0, False: 17]
  ------------------
 9775|     44|}
_ZN3ada3url17parse_opaque_hostENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
10154|    641|bool url::parse_opaque_host(std::string_view input) {
10155|    641|  ada_log("parse_opaque_host ", input, " [", input.size(), " bytes]");
10156|    641|  if (std::ranges::any_of(input, ada::unicode::is_forbidden_host_code_point)) {
  ------------------
  |  Branch (10156:7): [True: 14, False: 627]
  ------------------
10157|     14|    return is_valid = false;
10158|     14|  }
10159|       |
10160|       |  // Return the result of running UTF-8 percent-encode on input using the C0
10161|       |  // control percent-encode set.
10162|    627|  host = ada::unicode::percent_encode(
10163|    627|      input, ada::character_sets::C0_CONTROL_PERCENT_ENCODE);
10164|    627|  return true;
10165|    641|}
_ZN3ada3url10parse_ipv4ENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
10167|  1.96k|bool url::parse_ipv4(std::string_view input) {
10168|  1.96k|  ada_log("parse_ipv4 ", input, " [", input.size(), " bytes]");
10169|  1.96k|  if (input.empty()) {
  ------------------
  |  Branch (10169:7): [True: 0, False: 1.96k]
  ------------------
10170|      0|    return is_valid = false;
10171|      0|  }
10172|  1.96k|  std::string_view original_input = input;
10173|  1.96k|  if (original_input.back() == '.') {
  ------------------
  |  Branch (10173:7): [True: 67, False: 1.89k]
  ------------------
10174|     67|    original_input.remove_suffix(1);
10175|     67|  }
10176|  1.96k|  if (input.back() == '.') {
  ------------------
  |  Branch (10176:7): [True: 67, False: 1.89k]
  ------------------
10177|     67|    input.remove_suffix(1);
10178|     67|    if (input.empty()) {
  ------------------
  |  Branch (10178:9): [True: 0, False: 67]
  ------------------
10179|      0|      return is_valid = false;
10180|      0|    }
10181|     67|  }
10182|       |
10183|  1.96k|  const uint64_t fast = checkers::try_parse_ipv4_fast(input);
10184|  1.96k|  if (fast < checkers::ipv4_fast_fail) [[likely]] {
  ------------------
  |  Branch (10184:7): [True: 22, False: 1.93k]
  ------------------
10185|     22|    host = original_input;
10186|     22|    host_type = IPV4;
10187|     22|    return true;
10188|     22|  }
10189|       |
10190|  1.93k|  const char* p = input.data();
10191|  1.93k|  const char* end = p + input.size();
10192|  1.93k|  uint64_t ipv4 = 0;
10193|  1.93k|  int digit_count = 0;
10194|  1.93k|  int pure_decimal_count = 0;
10195|       |
10196|  2.42k|  for (; digit_count < 4 && p < end; ++digit_count) {
  ------------------
  |  Branch (10196:10): [True: 2.41k, False: 11]
  |  Branch (10196:29): [True: 2.41k, False: 0]
  ------------------
10197|  2.41k|    uint64_t segment = 0;
10198|  2.41k|    bool pure = false;
10199|  2.41k|    if (!detail::parse_ipv4_number(p, end, segment, pure)) {
  ------------------
  |  Branch (10199:9): [True: 360, False: 2.05k]
  ------------------
10200|    360|      return is_valid = false;
10201|    360|    }
10202|  2.05k|    if (pure) {
  ------------------
  |  Branch (10202:9): [True: 1.50k, False: 550]
  ------------------
10203|  1.50k|      ++pure_decimal_count;
10204|  1.50k|    }
10205|  2.05k|    if (p >= end) {
  ------------------
  |  Branch (10205:9): [True: 1.53k, False: 515]
  ------------------
10206|  1.53k|      const unsigned shift = static_cast<unsigned>(32 - digit_count * 8);
10207|  1.53k|      if (segment >= (uint64_t{1} << shift)) {
  ------------------
  |  Branch (10207:11): [True: 26, False: 1.51k]
  ------------------
10208|     26|        return is_valid = false;
10209|     26|      }
10210|  1.51k|      ipv4 = (ipv4 << shift) | segment;
10211|  1.51k|      host = (pure_decimal_count == 4) ? std::string(original_input)
  ------------------
  |  Branch (10211:14): [True: 0, False: 1.51k]
  ------------------
10212|  1.51k|                                       : ada::serializers::ipv4(ipv4);
10213|  1.51k|      host_type = IPV4;
10214|  1.51k|      return true;
10215|  1.53k|    }
10216|    515|    if (segment > 255 || *p != '.') {
  ------------------
  |  Branch (10216:9): [True: 29, False: 486]
  |  Branch (10216:26): [True: 0, False: 486]
  ------------------
10217|     29|      return is_valid = false;
10218|     29|    }
10219|    486|    ipv4 = (ipv4 << 8) | segment;
10220|    486|    ++p;
10221|    486|  }
10222|     11|  if (digit_count != 4 || p != end) {
  ------------------
  |  Branch (10222:7): [True: 0, False: 11]
  |  Branch (10222:27): [True: 11, False: 0]
  ------------------
10223|     11|    return is_valid = false;
10224|     11|  }
10225|      0|  host = (pure_decimal_count == 4) ? std::string(original_input)
  ------------------
  |  Branch (10225:10): [True: 0, False: 0]
  ------------------
10226|      0|                                   : ada::serializers::ipv4(ipv4);
10227|      0|  host_type = IPV4;
10228|      0|  return true;
10229|     11|}
_ZN3ada3url10parse_ipv6ENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
10231|    554|bool url::parse_ipv6(std::string_view input) {
10232|    554|  ada_log("parse_ipv6 ", input, " [", input.size(), " bytes]");
10233|    554|  if (input.empty() || input.size() > 45) [[unlikely]] {
  ------------------
  |  Branch (10233:7): [True: 15, False: 539]
  |  Branch (10233:24): [True: 15, False: 524]
  ------------------
10234|     30|    return is_valid = false;
10235|     30|  }
10236|    524|  std::array<uint16_t, 8> address{};
10237|       |#if defined(ADA_AVX512_IPV6)
10238|       |  if (bool simd_valid; detail::try_parse_ipv6_avx512(input.data(), input.size(),
10239|       |                                                     address, simd_valid)) {
10240|       |    if (!simd_valid) [[unlikely]] {
10241|       |      return is_valid = false;
10242|       |    }
10243|       |    host = ada::serializers::ipv6(address);
10244|       |    host_type = IPV6;
10245|       |    return true;
10246|       |  }
10247|       |  address = {};
10248|       |#endif
10249|    524|  const char* pointer = input.data();
10250|    524|  const char* const end = pointer + input.size();
10251|    524|  int piece_index = 0;
10252|    524|  int compress = -1;
10253|       |
10254|    524|  if (*pointer == ':') {
  ------------------
  |  Branch (10254:7): [True: 201, False: 323]
  ------------------
10255|    201|    if (input.size() == 1 || pointer[1] != ':') [[unlikely]] {
  ------------------
  |  Branch (10255:9): [True: 3, False: 198]
  |  Branch (10255:30): [True: 9, False: 189]
  ------------------
10256|     12|      return is_valid = false;
10257|     12|    }
10258|    189|    pointer += 2;
10259|    189|    compress = ++piece_index;
10260|    189|  }
10261|       |
10262|  1.51k|  while (pointer != end) {
  ------------------
  |  Branch (10262:10): [True: 1.16k, False: 353]
  ------------------
10263|  1.16k|    if (piece_index == 8) [[unlikely]] {
  ------------------
  |  Branch (10263:9): [True: 3, False: 1.16k]
  ------------------
10264|      3|      return is_valid = false;
10265|      3|    }
10266|  1.16k|    if (*pointer == ':') {
  ------------------
  |  Branch (10266:9): [True: 146, False: 1.01k]
  ------------------
10267|    146|      if (compress != -1) [[unlikely]] {
  ------------------
  |  Branch (10267:11): [True: 3, False: 143]
  ------------------
10268|      3|        return is_valid = false;
10269|      3|      }
10270|    143|      ++pointer;
10271|    143|      compress = ++piece_index;
10272|    143|      continue;
10273|    146|    }
10274|       |
10275|  1.01k|    uint16_t value = 0;
10276|  1.01k|    const int length = detail::parse_hex_piece(pointer, end, value);
10277|       |
10278|  1.01k|    if (pointer != end && *pointer == '.') {
  ------------------
  |  Branch (10278:9): [True: 828, False: 186]
  |  Branch (10278:27): [True: 97, False: 731]
  ------------------
10279|     97|      if (length == 0) [[unlikely]] {
  ------------------
  |  Branch (10279:11): [True: 3, False: 94]
  ------------------
10280|      3|        return is_valid = false;
10281|      3|      }
10282|     94|      pointer -= length;
10283|     94|      if (piece_index > 6) [[unlikely]] {
  ------------------
  |  Branch (10283:11): [True: 3, False: 91]
  ------------------
10284|      3|        return is_valid = false;
10285|      3|      }
10286|       |
10287|     91|      int numbers_seen = 0;
10288|    259|      while (pointer != end) {
  ------------------
  |  Branch (10288:14): [True: 228, False: 31]
  ------------------
10289|    228|        int ipv4_piece = -1;
10290|    228|        if (numbers_seen > 0) {
  ------------------
  |  Branch (10290:13): [True: 137, False: 91]
  ------------------
10291|    137|          if (*pointer == '.' && numbers_seen < 4) {
  ------------------
  |  Branch (10291:15): [True: 123, False: 14]
  |  Branch (10291:34): [True: 118, False: 5]
  ------------------
10292|    118|            ++pointer;
10293|    118|          } else {
10294|     19|            return is_valid = false;
10295|     19|          }
10296|    137|        }
10297|    209|        if (pointer == end || *pointer < '0' || *pointer > '9') [[unlikely]] {
  ------------------
  |  Branch (10297:13): [True: 22, False: 187]
  |  Branch (10297:31): [True: 3, False: 184]
  |  Branch (10297:49): [True: 7, False: 177]
  ------------------
10298|     32|          return is_valid = false;
10299|     32|        }
10300|    177|        ipv4_piece = *pointer - '0';
10301|    177|        ++pointer;
10302|    177|        if (pointer != end && *pointer >= '0' && *pointer <= '9') {
  ------------------
  |  Branch (10302:13): [True: 159, False: 18]
  |  Branch (10302:31): [True: 65, False: 94]
  |  Branch (10302:50): [True: 61, False: 4]
  ------------------
10303|     61|          if (ipv4_piece == 0) [[unlikely]] {
  ------------------
  |  Branch (10303:15): [True: 3, False: 58]
  ------------------
10304|      3|            return is_valid = false;
10305|      3|          }
10306|     58|          ipv4_piece = ipv4_piece * 10 + (*pointer - '0');
10307|     58|          ++pointer;
10308|     58|          if (pointer != end && *pointer >= '0' && *pointer <= '9') {
  ------------------
  |  Branch (10308:15): [True: 52, False: 6]
  |  Branch (10308:33): [True: 33, False: 19]
  |  Branch (10308:52): [True: 30, False: 3]
  ------------------
10309|     30|            ipv4_piece = ipv4_piece * 10 + (*pointer - '0');
10310|     30|            ++pointer;
10311|     30|            if (ipv4_piece > 255) [[unlikely]] {
  ------------------
  |  Branch (10311:17): [True: 6, False: 24]
  ------------------
10312|      6|              return is_valid = false;
10313|      6|            }
10314|     30|          }
10315|     58|        }
10316|    168|        address[static_cast<size_t>(piece_index)] = static_cast<uint16_t>(
10317|    168|            address[static_cast<size_t>(piece_index)] * 0x100 +
10318|    168|            static_cast<uint16_t>(ipv4_piece));
10319|    168|        ++numbers_seen;
10320|    168|        if (numbers_seen == 2 || numbers_seen == 4) {
  ------------------
  |  Branch (10320:13): [True: 50, False: 118]
  |  Branch (10320:34): [True: 17, False: 101]
  ------------------
10321|     67|          ++piece_index;
10322|     67|        }
10323|    168|      }
10324|     31|      if (numbers_seen != 4) [[unlikely]] {
  ------------------
  |  Branch (10324:11): [True: 19, False: 12]
  ------------------
10325|     19|        return is_valid = false;
10326|     19|      }
10327|     12|      break;
10328|     31|    }
10329|       |
10330|    917|    if (length == 0) [[unlikely]] {
  ------------------
  |  Branch (10330:9): [True: 44, False: 873]
  ------------------
10331|     44|      return is_valid = false;
10332|     44|    }
10333|       |
10334|    873|    if (pointer != end && *pointer == ':') {
  ------------------
  |  Branch (10334:9): [True: 687, False: 186]
  |  Branch (10334:27): [True: 678, False: 9]
  ------------------
10335|    678|      ++pointer;
10336|    678|      if (pointer == end) [[unlikely]] {
  ------------------
  |  Branch (10336:11): [True: 3, False: 675]
  ------------------
10337|      3|        return is_valid = false;
10338|      3|      }
10339|    678|    } else if (pointer != end) [[unlikely]] {
  ------------------
  |  Branch (10339:16): [True: 9, False: 186]
  ------------------
10340|      9|      return is_valid = false;
10341|      9|    }
10342|       |
10343|    861|    address[static_cast<size_t>(piece_index)] = value;
10344|    861|    ++piece_index;
10345|    861|  }
10346|       |
10347|    365|  if (compress != -1) {
  ------------------
  |  Branch (10347:7): [True: 323, False: 42]
  ------------------
10348|    323|    const int right = piece_index - compress;
10349|    323|    if (right > 0) {
  ------------------
  |  Branch (10349:9): [True: 156, False: 167]
  ------------------
10350|    156|      const size_t dest = static_cast<size_t>(8 - right);
10351|    156|      const size_t src = static_cast<size_t>(compress);
10352|    156|      if (dest != src) {
  ------------------
  |  Branch (10352:11): [True: 135, False: 21]
  ------------------
10353|    392|        for (size_t i = static_cast<size_t>(right); i-- > 0;) {
  ------------------
  |  Branch (10353:53): [True: 257, False: 135]
  ------------------
10354|    257|          address[dest + i] = address[src + i];
10355|    257|          address[src + i] = 0;
10356|    257|        }
10357|    135|      }
10358|    156|    }
10359|    323|  } else if (piece_index != 8) [[unlikely]] {
  ------------------
  |  Branch (10359:14): [True: 23, False: 19]
  ------------------
10360|     23|    return is_valid = false;
10361|     23|  }
10362|       |
10363|    342|  host = ada::serializers::ipv6(address);
10364|    342|  ada_log("parse_ipv6 ", *host);
10365|    342|  host_type = IPV6;
10366|    342|  return true;
10367|    365|}
_ZN3ada6parser25try_parse_simple_absoluteINS_3urlEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_:
12329|  45.5k|                                                result_type& out) {
12330|  45.5k|  constexpr bool is_ada_url = std::is_same_v<result_type, ada::url>;
12331|  45.5k|  constexpr bool is_aggregator =
12332|  45.5k|      std::is_same_v<result_type, ada::url_aggregator>;
12333|  45.5k|  static_assert(is_ada_url || is_aggregator);
12334|       |
12335|  45.5k|  const size_t len = input.size();
12336|       |  // Shortest accepted form is "ws://x" (6).
12337|  45.5k|  if (len < 6) [[unlikely]] {
  ------------------
  |  Branch (12337:7): [True: 25.3k, False: 20.1k]
  ------------------
12338|  25.3k|    return false;
12339|  25.3k|  }
12340|  20.1k|  const auto* b = reinterpret_cast<const uint8_t*>(input.data());
12341|       |
12342|  20.1k|  size_t pos = 0;
12343|  20.1k|  ada::scheme::type scheme_type = ada::scheme::type::NOT_SPECIAL;
12344|  20.1k|  uint32_t protocol_end = 0;
12345|  20.1k|#if (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \
12346|  20.1k|    defined(_M_X64) || defined(_M_IX86) || defined(_M_AMD64)
12347|       |  // One 8-byte load + integer compare is a single cmp/jcc on x86-64.
12348|       |  // Masked compares cover the shorter special schemes without extra loads.
12349|  20.1k|  if (len >= 8) {
  ------------------
  |  Branch (12349:7): [True: 17.4k, False: 2.70k]
  ------------------
12350|  17.4k|    uint64_t first8 = 0;
12351|  17.4k|    std::memcpy(&first8, b, 8);
12352|  17.4k|    if (first8 == 0x2f2f3a7370747468ull) {  // "https://"
  ------------------
  |  Branch (12352:9): [True: 8, False: 17.4k]
  ------------------
12353|      8|      pos = 8;
12354|      8|      scheme_type = ada::scheme::type::HTTPS;
12355|      8|      protocol_end = 6;
12356|  17.4k|    } else if ((first8 & 0x00ffffffffffffffull) ==
  ------------------
  |  Branch (12356:16): [True: 371, False: 17.0k]
  ------------------
12357|  17.4k|               0x002f2f3a70747468ull) {  // "http://"
12358|    371|      pos = 7;
12359|    371|      scheme_type = ada::scheme::type::HTTP;
12360|    371|      protocol_end = 5;
12361|  17.0k|    } else if ((first8 & 0x0000ffffffffffffull) ==
  ------------------
  |  Branch (12361:16): [True: 59, False: 17.0k]
  ------------------
12362|  17.0k|               0x00002f2f3a737377ull) {  // "wss://"
12363|     59|      pos = 6;
12364|     59|      scheme_type = ada::scheme::type::WSS;
12365|     59|      protocol_end = 4;
12366|  17.0k|    } else if ((first8 & 0x0000ffffffffffffull) ==
  ------------------
  |  Branch (12366:16): [True: 18, False: 17.0k]
  ------------------
12367|  17.0k|               0x00002f2f3a707466ull) {  // "ftp://"
12368|     18|      pos = 6;
12369|     18|      scheme_type = ada::scheme::type::FTP;
12370|     18|      protocol_end = 4;
12371|  17.0k|    } else if ((first8 & 0x000000ffffffffffull) ==
  ------------------
  |  Branch (12371:16): [True: 7.47k, False: 9.54k]
  ------------------
12372|  17.0k|               0x0000002f2f3a7377ull) {  // "ws://"
12373|  7.47k|      pos = 5;
12374|  7.47k|      scheme_type = ada::scheme::type::WS;
12375|  7.47k|      protocol_end = 3;
12376|  9.54k|    } else {
12377|  9.54k|      return false;
12378|  9.54k|    }
12379|  17.4k|  } else if (b[0] == 'w' && b[1] == 's') {
  ------------------
  |  Branch (12379:14): [True: 1.57k, False: 1.13k]
  |  Branch (12379:29): [True: 1.32k, False: 249]
  ------------------
12380|  1.32k|    if (b[2] == ':' && b[3] == '/' && b[4] == '/') {
  ------------------
  |  Branch (12380:9): [True: 1.21k, False: 113]
  |  Branch (12380:24): [True: 549, False: 662]
  |  Branch (12380:39): [True: 539, False: 10]
  ------------------
12381|    539|      pos = 5;
12382|    539|      scheme_type = ada::scheme::type::WS;
12383|    539|      protocol_end = 3;
12384|    785|    } else if (b[2] == 's' && b[3] == ':' && b[4] == '/' && b[5] == '/') {
  ------------------
  |  Branch (12384:16): [True: 87, False: 698]
  |  Branch (12384:31): [True: 73, False: 14]
  |  Branch (12384:46): [True: 11, False: 62]
  |  Branch (12384:61): [True: 5, False: 6]
  ------------------
12385|      5|      pos = 6;
12386|      5|      scheme_type = ada::scheme::type::WSS;
12387|      5|      protocol_end = 4;
12388|    780|    } else {
12389|    780|      return false;
12390|    780|    }
12391|  1.38k|  } else if (b[0] == 'f' && b[1] == 't' && b[2] == 'p' && b[3] == ':' &&
  ------------------
  |  Branch (12391:14): [True: 134, False: 1.24k]
  |  Branch (12391:29): [True: 50, False: 84]
  |  Branch (12391:44): [True: 36, False: 14]
  |  Branch (12391:59): [True: 25, False: 11]
  ------------------
12392|     25|             b[4] == '/' && b[5] == '/') {
  ------------------
  |  Branch (12392:14): [True: 12, False: 13]
  |  Branch (12392:29): [True: 3, False: 9]
  ------------------
12393|      3|    pos = 6;
12394|      3|    scheme_type = ada::scheme::type::FTP;
12395|      3|    protocol_end = 4;
12396|  1.37k|  } else if (len >= 7 && b[0] == 'h' && b[1] == 't' && b[2] == 't' &&
  ------------------
  |  Branch (12396:14): [True: 736, False: 642]
  |  Branch (12396:26): [True: 102, False: 634]
  |  Branch (12396:41): [True: 80, False: 22]
  |  Branch (12396:56): [True: 62, False: 18]
  ------------------
12397|     62|             b[3] == 'p' && b[4] == ':' && b[5] == '/' && b[6] == '/') {
  ------------------
  |  Branch (12397:14): [True: 46, False: 16]
  |  Branch (12397:29): [True: 31, False: 15]
  |  Branch (12397:44): [True: 13, False: 18]
  |  Branch (12397:59): [True: 3, False: 10]
  ------------------
12398|      3|    pos = 7;
12399|      3|    scheme_type = ada::scheme::type::HTTP;
12400|      3|    protocol_end = 5;
12401|  1.37k|  } else {
12402|  1.37k|    return false;
12403|  1.37k|  }
12404|       |#else
12405|       |  // Big-endian / uncommon arches: byte-wise special-scheme match.
12406|       |  if (len >= 8 && b[0] == 'h' && b[1] == 't' && b[2] == 't' && b[3] == 'p' &&
12407|       |      b[4] == 's' && b[5] == ':' && b[6] == '/' && b[7] == '/') {
12408|       |    pos = 8;
12409|       |    scheme_type = ada::scheme::type::HTTPS;
12410|       |    protocol_end = 6;
12411|       |  } else if (len >= 7 && b[0] == 'h' && b[1] == 't' && b[2] == 't' &&
12412|       |             b[3] == 'p' && b[4] == ':' && b[5] == '/' && b[6] == '/') {
12413|       |    pos = 7;
12414|       |    scheme_type = ada::scheme::type::HTTP;
12415|       |    protocol_end = 5;
12416|       |  } else if (b[0] == 'w' && b[1] == 's') {
12417|       |    if (b[2] == ':' && b[3] == '/' && b[4] == '/') {
12418|       |      pos = 5;
12419|       |      scheme_type = ada::scheme::type::WS;
12420|       |      protocol_end = 3;
12421|       |    } else if (len >= 6 && b[2] == 's' && b[3] == ':' && b[4] == '/' &&
12422|       |               b[5] == '/') {
12423|       |      pos = 6;
12424|       |      scheme_type = ada::scheme::type::WSS;
12425|       |      protocol_end = 4;
12426|       |    } else {
12427|       |      return false;
12428|       |    }
12429|       |  } else if (b[0] == 'f' && b[1] == 't' && b[2] == 'p' && b[3] == ':' &&
12430|       |             b[4] == '/' && b[5] == '/') {
12431|       |    pos = 6;
12432|       |    scheme_type = ada::scheme::type::FTP;
12433|       |    protocol_end = 4;
12434|       |  } else {
12435|       |    return false;
12436|       |  }
12437|       |#endif
12438|  8.47k|  if (pos < len && (b[pos] == '/' || b[pos] == '\\')) [[unlikely]] {
  ------------------
  |  Branch (12438:7): [True: 8.46k, False: 10]
  |  Branch (12438:21): [True: 12, False: 8.45k]
  |  Branch (12438:38): [True: 8, False: 8.44k]
  ------------------
12439|     20|    return false;
12440|     20|  }
12441|       |
12442|       |  // Digit-led hosts are IPv4/numeric; '[' is IPv6. Skip before scanning.
12443|  8.45k|  if (pos < len && ((b[pos] >= '0' && b[pos] <= '9') || b[pos] == '[')) {
  ------------------
  |  Branch (12443:7): [True: 8.44k, False: 10]
  |  Branch (12443:22): [True: 6.49k, False: 1.95k]
  |  Branch (12443:39): [True: 1.13k, False: 5.36k]
  |  Branch (12443:57): [True: 112, False: 7.20k]
  ------------------
12444|  1.24k|    return false;
12445|  1.24k|  }
12446|       |
12447|  7.21k|  const size_t host_start = pos;
12448|  7.21k|  bool has_upper = false;
12449|  7.21k|  bool has_x = false;
12450|  7.21k|  size_t host_end = pos;
12451|  7.21k|  if (!scan_plain_host(b, pos, len, host_end, has_upper, has_x)) {
  ------------------
  |  Branch (12451:7): [True: 282, False: 6.93k]
  ------------------
12452|    282|    return false;
12453|    282|  }
12454|  6.93k|  if (host_start == host_end) [[unlikely]] {
  ------------------
  |  Branch (12454:7): [True: 61, False: 6.87k]
  ------------------
12455|     61|    return false;
12456|     61|  }
12457|  6.87k|  const size_t host_len = host_end - host_start;
12458|  6.87k|  if (host_len > 253) [[unlikely]] {
  ------------------
  |  Branch (12458:7): [True: 88, False: 6.78k]
  ------------------
12459|     88|    return false;
12460|     88|  }
12461|  6.78k|  {
12462|  6.78k|    std::string_view hv(input.data() + host_start, host_len);
12463|  6.78k|    char host_buf[256];
12464|  6.78k|    if (has_upper) [[unlikely]] {
  ------------------
  |  Branch (12464:9): [True: 602, False: 6.18k]
  ------------------
12465|    602|      std::memcpy(host_buf, input.data() + host_start, host_len);
12466|    602|      unicode::to_lower_ascii(host_buf, host_len);
12467|    602|      hv = std::string_view(host_buf, host_len);
12468|    602|    }
12469|  6.78k|    if (ada::checkers::last_label_may_be_a_number(hv)) [[unlikely]] {
  ------------------
  |  Branch (12469:9): [True: 95, False: 6.68k]
  ------------------
12470|     95|      return false;
12471|     95|    }
12472|       |    // Punycode is "xn--...". The host scan already notes a lowercase 'x';
12473|       |    // uppercase 'X' is covered by has_upper after the in-place lower.
12474|  6.68k|    static constexpr std::string_view xn{"xn-", 3};
12475|  6.68k|    if ((has_x || has_upper) && hv.find(xn) != std::string_view::npos)
  ------------------
  |  Branch (12475:10): [True: 1.85k, False: 4.83k]
  |  Branch (12475:19): [True: 550, False: 4.28k]
  |  Branch (12475:33): [True: 1.23k, False: 1.17k]
  ------------------
12476|  1.23k|        [[unlikely]] {
12477|  1.23k|      return false;
12478|  1.23k|    }
12479|  6.68k|  }
12480|       |
12481|  5.45k|  if (host_end < len && b[host_end] == ':') [[unlikely]] {
  ------------------
  |  Branch (12481:7): [True: 5.28k, False: 173]
  |  Branch (12481:25): [True: 1.96k, False: 3.32k]
  ------------------
12482|  1.96k|    return finish_simple_absolute_with_port(input, out, scheme_type,
12483|  1.96k|                                            protocol_end, host_start, host_end,
12484|  1.96k|                                            host_len, has_upper);
12485|  1.96k|  }
12486|       |
12487|  3.49k|  size_t i = host_end;
12488|  3.49k|  size_t path_start = host_end;
12489|  3.49k|  size_t path_end = host_end;
12490|  3.49k|  size_t query_start = std::string_view::npos;
12491|  3.49k|  size_t hash_start = std::string_view::npos;
12492|  3.49k|  bool has_path = false;
12493|  3.49k|  bool maybe_dot_segment = false;
12494|  3.49k|  bool rest_simple = true;
12495|       |
12496|  3.49k|  if (i < len && b[i] == '/') {
  ------------------
  |  Branch (12496:7): [True: 3.32k, False: 173]
  |  Branch (12496:18): [True: 3.17k, False: 143]
  ------------------
12497|  3.17k|    has_path = true;
12498|  3.17k|    path_start = i;
12499|  3.17k|    ++i;
12500|  3.17k|    scan_path_run(b, i, len, maybe_dot_segment);
12501|  3.17k|    if (i < len) {
  ------------------
  |  Branch (12501:9): [True: 1.42k, False: 1.74k]
  ------------------
12502|  1.42k|      const uint8_t cls = k_path[b[i]];
12503|  1.42k|      if (cls == 1) {
  ------------------
  |  Branch (12503:11): [True: 427, False: 1.00k]
  ------------------
12504|    427|        path_end = i;
12505|    427|        if (b[i] == '?') {
  ------------------
  |  Branch (12505:13): [True: 268, False: 159]
  ------------------
12506|    268|          query_start = i;
12507|    268|          ++i;
12508|    268|          goto scan_query;
12509|    268|        }
12510|    159|        hash_start = i;
12511|    159|        ++i;
12512|    159|        goto scan_hash;
12513|    427|      }
12514|  1.00k|      rest_simple = false;
12515|  1.00k|      hash_start = input.find('#', i);
12516|  1.00k|      query_start = input.substr(0, hash_start).find('?', i);
12517|  1.00k|      if (query_start != std::string_view::npos) {
  ------------------
  |  Branch (12517:11): [True: 50, False: 952]
  ------------------
12518|     50|        path_end = query_start;
12519|    952|      } else {
12520|    952|        path_end = hash_start != std::string_view::npos ? hash_start : len;
  ------------------
  |  Branch (12520:20): [True: 32, False: 920]
  ------------------
12521|    952|      }
12522|  1.00k|      goto after_rest;
12523|  1.42k|    }
12524|  1.74k|    path_end = i;
12525|  1.74k|  } else if (i < len && b[i] == '?') {
  ------------------
  |  Branch (12525:14): [True: 143, False: 173]
  |  Branch (12525:25): [True: 73, False: 70]
  ------------------
12526|     73|    query_start = i;
12527|     73|    ++i;
12528|     73|    goto scan_query;
12529|    243|  } else if (i < len && b[i] == '#') {
  ------------------
  |  Branch (12529:14): [True: 70, False: 173]
  |  Branch (12529:25): [True: 70, False: 0]
  ------------------
12530|     70|    hash_start = i;
12531|     70|    ++i;
12532|     70|    goto scan_hash;
12533|     70|  }
12534|  1.92k|  goto after_rest;
12535|       |
12536|  1.92k|scan_query:
12537|    341|  scan_query_run(b, i, len);
12538|    341|  if (i < len) {
  ------------------
  |  Branch (12538:7): [True: 175, False: 166]
  ------------------
12539|    175|    if (b[i] == '#') {
  ------------------
  |  Branch (12539:9): [True: 119, False: 56]
  ------------------
12540|    119|      hash_start = i;
12541|    119|      ++i;
12542|    119|      goto scan_hash;
12543|    119|    }
12544|     56|    rest_simple = false;
12545|     56|    goto scan_query_boundary;
12546|    175|  }
12547|    166|  goto after_rest;
12548|       |
12549|    166|scan_query_boundary:
12550|     56|  hash_start = input.find('#', i);
12551|     56|  goto after_rest;
12552|       |
12553|    348|scan_hash:
12554|    348|  scan_hash_run(b, i, len);
12555|    348|  if (i < len) {
  ------------------
  |  Branch (12555:7): [True: 58, False: 290]
  ------------------
12556|     58|    rest_simple = false;
12557|     58|  }
12558|       |
12559|  3.49k|after_rest:
12560|  3.49k|  if (rest_simple && maybe_dot_segment) {
  ------------------
  |  Branch (12560:7): [True: 2.37k, False: 1.11k]
  |  Branch (12560:22): [True: 429, False: 1.94k]
  ------------------
12561|    429|    const std::string_view path_body(input.data() + path_start,
12562|    429|                                     path_end - path_start);
12563|    429|    if (path_has_dot_segment(path_body)) {
  ------------------
  |  Branch (12563:9): [True: 178, False: 251]
  ------------------
12564|    178|      rest_simple = false;
12565|    178|    }
12566|    429|  }
12567|       |
12568|       |  // The slow path removes ASCII tab/newline anywhere in the input and trims a
12569|       |  // trailing C0 control or space; this fast path does neither. A query or
12570|       |  // fragment reaching the helpers below would keep those bytes percent-encoded
12571|       |  // ("?a\nb" -> "?a%0Ab", "#f " -> "#f%20") instead of stripped, so hand such
12572|       |  // inputs back to the slow path.
12573|  3.49k|  if (!rest_simple && (unicode::is_c0_control_or_space(input.back()) ||
  ------------------
  |  Branch (12573:7): [True: 1.29k, False: 2.19k]
  |  Branch (12573:24): [True: 35, False: 1.25k]
  ------------------
12574|  1.25k|                       unicode::has_tabs_or_newline(input))) {
  ------------------
  |  Branch (12574:24): [True: 25, False: 1.23k]
  ------------------
12575|     60|    return false;
12576|     60|  }
12577|       |
12578|  3.43k|  out.type = scheme_type;
12579|  3.43k|  out.is_valid = true;
12580|  3.43k|  out.has_opaque_path = false;
12581|  3.43k|  out.host_type = DEFAULT;
12582|       |
12583|  3.43k|  if (!rest_simple) {
  ------------------
  |  Branch (12583:7): [True: 1.23k, False: 2.19k]
  ------------------
12584|       |    // Host is a plain domain. Finish path/query/hash with
12585|       |    // the regular helpers
12586|       |    // so percent-encoding and dot segments do not re-parse the authority.
12587|  1.23k|    const std::string_view path_view =
12588|  1.23k|        has_path
  ------------------
  |  Branch (12588:9): [True: 1.17k, False: 56]
  ------------------
12589|  1.23k|            ? std::string_view(input.data() + path_start, path_end - path_start)
12590|  1.23k|            : std::string_view{};
12591|  1.23k|    auto apply_query_and_hash = [&]() {
12592|  1.23k|      if (query_start != std::string_view::npos) {
12593|  1.23k|        const size_t q_end =
12594|  1.23k|            (hash_start != std::string_view::npos) ? hash_start : len;
12595|  1.23k|        out.update_base_search(std::string_view(input.data() + query_start + 1,
12596|  1.23k|                                                q_end - query_start - 1),
12597|  1.23k|                               character_sets::SPECIAL_QUERY_PERCENT_ENCODE);
12598|  1.23k|      }
12599|  1.23k|      if (hash_start != std::string_view::npos) {
12600|  1.23k|        out.update_unencoded_base_hash(std::string_view(
12601|  1.23k|            input.data() + hash_start + 1, len - hash_start - 1));
12602|  1.23k|      }
12603|  1.23k|    };
12604|       |    if constexpr (is_aggregator) {
12605|       |      out.buffer.assign(input.substr(0, host_end));
12606|       |      if (has_upper) {
12607|       |        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12608|       |      }
12609|       |      out.components.protocol_end = protocol_end;
12610|       |      out.components.username_end = protocol_end + 2;
12611|       |      out.components.host_start = protocol_end + 2;
12612|       |      out.components.host_end = static_cast<uint32_t>(host_end);
12613|       |      out.components.port = url_components::omitted;
12614|       |      out.components.pathname_start = static_cast<uint32_t>(host_end);
12615|       |      out.components.search_start = url_components::omitted;
12616|       |      out.components.hash_start = url_components::omitted;
12617|       |      out.parse_path(path_view);
12618|       |      apply_query_and_hash();
12619|  1.23k|    } else {
12620|  1.23k|      std::string host_str(input.substr(host_start, host_len));
12621|  1.23k|      if (has_upper) {
  ------------------
  |  Branch (12621:11): [True: 160, False: 1.07k]
  ------------------
12622|    160|        unicode::to_lower_ascii(host_str.data(), host_str.size());
12623|    160|      }
12624|  1.23k|      out.host = std::move(host_str);
12625|  1.23k|      out.parse_path(path_view);
12626|  1.23k|      apply_query_and_hash();
12627|  1.23k|    }
12628|  1.23k|    return true;
12629|  1.23k|  }
12630|       |
12631|  2.19k|  const bool need_slash = !has_path;
12632|       |  if constexpr (is_aggregator) {
12633|       |    if (!need_slash) {
12634|       |      // assign copies once. resize()+memcpy would value-init then overwrite.
12635|       |      out.buffer.assign(input);
12636|       |      if (has_upper) {
12637|       |        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12638|       |      }
12639|       |      out.components.protocol_end = protocol_end;
12640|       |      out.components.username_end = protocol_end + 2;
12641|       |      out.components.host_start = protocol_end + 2;
12642|       |      out.components.host_end = static_cast<uint32_t>(host_end);
12643|       |      out.components.port = url_components::omitted;
12644|       |      out.components.pathname_start = static_cast<uint32_t>(path_start);
12645|       |      out.components.search_start = (query_start != std::string_view::npos)
12646|       |                                        ? static_cast<uint32_t>(query_start)
12647|       |                                        : url_components::omitted;
12648|       |      out.components.hash_start = (hash_start != std::string_view::npos)
12649|       |                                      ? static_cast<uint32_t>(hash_start)
12650|       |                                      : url_components::omitted;
12651|       |    } else {
12652|       |      out.buffer.clear();
12653|       |      out.buffer.reserve(len + 1);
12654|       |      out.buffer.append(input.substr(0, host_end));
12655|       |      out.buffer.push_back('/');
12656|       |      if (host_end < len) {
12657|       |        out.buffer.append(input.substr(host_end));
12658|       |      }
12659|       |      if (has_upper) {
12660|       |        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12661|       |      }
12662|       |      out.components.protocol_end = protocol_end;
12663|       |      out.components.username_end = protocol_end + 2;
12664|       |      out.components.host_start = protocol_end + 2;
12665|       |      out.components.host_end = static_cast<uint32_t>(host_end);
12666|       |      out.components.port = url_components::omitted;
12667|       |      out.components.pathname_start = static_cast<uint32_t>(host_end);
12668|       |      out.components.search_start = (query_start != std::string_view::npos)
12669|       |                                        ? static_cast<uint32_t>(query_start + 1)
12670|       |                                        : url_components::omitted;
12671|       |      out.components.hash_start = (hash_start != std::string_view::npos)
12672|       |                                      ? static_cast<uint32_t>(hash_start + 1)
12673|       |                                      : url_components::omitted;
12674|       |    }
12675|  2.19k|  } else {
12676|  2.19k|    std::string host_str(input.substr(host_start, host_len));
12677|  2.19k|    if (has_upper) {
  ------------------
  |  Branch (12677:9): [True: 139, False: 2.06k]
  ------------------
12678|    139|      unicode::to_lower_ascii(host_str.data(), host_str.size());
12679|    139|    }
12680|  2.19k|    out.host = std::move(host_str);
12681|  2.19k|    if (need_slash) {
  ------------------
  |  Branch (12681:9): [True: 237, False: 1.96k]
  ------------------
12682|    237|      out.path = "/";
12683|  1.96k|    } else {
12684|  1.96k|      out.path.assign(input.data() + path_start, path_end - path_start);
12685|  1.96k|    }
12686|  2.19k|    if (query_start != std::string_view::npos) {
  ------------------
  |  Branch (12686:9): [True: 282, False: 1.91k]
  ------------------
12687|    282|      const size_t q_end =
12688|    282|          (hash_start != std::string_view::npos) ? hash_start : len;
  ------------------
  |  Branch (12688:11): [True: 117, False: 165]
  ------------------
12689|    282|      out.query.emplace(input.data() + query_start + 1,
12690|    282|                        q_end - query_start - 1);
12691|    282|    }
12692|  2.19k|    if (hash_start != std::string_view::npos) {
  ------------------
  |  Branch (12692:9): [True: 290, False: 1.90k]
  ------------------
12693|    290|      out.hash.emplace(input.data() + hash_start + 1, len - hash_start - 1);
12694|    290|    }
12695|  2.19k|  }
12696|  2.19k|  return true;
12697|  3.43k|}
_ZN3ada6parser25try_parse_simple_absoluteINS_14url_aggregatorEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_:
12329|  45.5k|                                                result_type& out) {
12330|  45.5k|  constexpr bool is_ada_url = std::is_same_v<result_type, ada::url>;
12331|  45.5k|  constexpr bool is_aggregator =
12332|  45.5k|      std::is_same_v<result_type, ada::url_aggregator>;
12333|  45.5k|  static_assert(is_ada_url || is_aggregator);
12334|       |
12335|  45.5k|  const size_t len = input.size();
12336|       |  // Shortest accepted form is "ws://x" (6).
12337|  45.5k|  if (len < 6) [[unlikely]] {
  ------------------
  |  Branch (12337:7): [True: 25.3k, False: 20.1k]
  ------------------
12338|  25.3k|    return false;
12339|  25.3k|  }
12340|  20.1k|  const auto* b = reinterpret_cast<const uint8_t*>(input.data());
12341|       |
12342|  20.1k|  size_t pos = 0;
12343|  20.1k|  ada::scheme::type scheme_type = ada::scheme::type::NOT_SPECIAL;
12344|  20.1k|  uint32_t protocol_end = 0;
12345|  20.1k|#if (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \
12346|  20.1k|    defined(_M_X64) || defined(_M_IX86) || defined(_M_AMD64)
12347|       |  // One 8-byte load + integer compare is a single cmp/jcc on x86-64.
12348|       |  // Masked compares cover the shorter special schemes without extra loads.
12349|  20.1k|  if (len >= 8) {
  ------------------
  |  Branch (12349:7): [True: 17.4k, False: 2.70k]
  ------------------
12350|  17.4k|    uint64_t first8 = 0;
12351|  17.4k|    std::memcpy(&first8, b, 8);
12352|  17.4k|    if (first8 == 0x2f2f3a7370747468ull) {  // "https://"
  ------------------
  |  Branch (12352:9): [True: 8, False: 17.4k]
  ------------------
12353|      8|      pos = 8;
12354|      8|      scheme_type = ada::scheme::type::HTTPS;
12355|      8|      protocol_end = 6;
12356|  17.4k|    } else if ((first8 & 0x00ffffffffffffffull) ==
  ------------------
  |  Branch (12356:16): [True: 371, False: 17.0k]
  ------------------
12357|  17.4k|               0x002f2f3a70747468ull) {  // "http://"
12358|    371|      pos = 7;
12359|    371|      scheme_type = ada::scheme::type::HTTP;
12360|    371|      protocol_end = 5;
12361|  17.0k|    } else if ((first8 & 0x0000ffffffffffffull) ==
  ------------------
  |  Branch (12361:16): [True: 59, False: 17.0k]
  ------------------
12362|  17.0k|               0x00002f2f3a737377ull) {  // "wss://"
12363|     59|      pos = 6;
12364|     59|      scheme_type = ada::scheme::type::WSS;
12365|     59|      protocol_end = 4;
12366|  17.0k|    } else if ((first8 & 0x0000ffffffffffffull) ==
  ------------------
  |  Branch (12366:16): [True: 18, False: 17.0k]
  ------------------
12367|  17.0k|               0x00002f2f3a707466ull) {  // "ftp://"
12368|     18|      pos = 6;
12369|     18|      scheme_type = ada::scheme::type::FTP;
12370|     18|      protocol_end = 4;
12371|  17.0k|    } else if ((first8 & 0x000000ffffffffffull) ==
  ------------------
  |  Branch (12371:16): [True: 7.47k, False: 9.54k]
  ------------------
12372|  17.0k|               0x0000002f2f3a7377ull) {  // "ws://"
12373|  7.47k|      pos = 5;
12374|  7.47k|      scheme_type = ada::scheme::type::WS;
12375|  7.47k|      protocol_end = 3;
12376|  9.54k|    } else {
12377|  9.54k|      return false;
12378|  9.54k|    }
12379|  17.4k|  } else if (b[0] == 'w' && b[1] == 's') {
  ------------------
  |  Branch (12379:14): [True: 1.57k, False: 1.13k]
  |  Branch (12379:29): [True: 1.32k, False: 249]
  ------------------
12380|  1.32k|    if (b[2] == ':' && b[3] == '/' && b[4] == '/') {
  ------------------
  |  Branch (12380:9): [True: 1.21k, False: 113]
  |  Branch (12380:24): [True: 549, False: 662]
  |  Branch (12380:39): [True: 539, False: 10]
  ------------------
12381|    539|      pos = 5;
12382|    539|      scheme_type = ada::scheme::type::WS;
12383|    539|      protocol_end = 3;
12384|    785|    } else if (b[2] == 's' && b[3] == ':' && b[4] == '/' && b[5] == '/') {
  ------------------
  |  Branch (12384:16): [True: 87, False: 698]
  |  Branch (12384:31): [True: 73, False: 14]
  |  Branch (12384:46): [True: 11, False: 62]
  |  Branch (12384:61): [True: 5, False: 6]
  ------------------
12385|      5|      pos = 6;
12386|      5|      scheme_type = ada::scheme::type::WSS;
12387|      5|      protocol_end = 4;
12388|    780|    } else {
12389|    780|      return false;
12390|    780|    }
12391|  1.38k|  } else if (b[0] == 'f' && b[1] == 't' && b[2] == 'p' && b[3] == ':' &&
  ------------------
  |  Branch (12391:14): [True: 134, False: 1.24k]
  |  Branch (12391:29): [True: 50, False: 84]
  |  Branch (12391:44): [True: 36, False: 14]
  |  Branch (12391:59): [True: 25, False: 11]
  ------------------
12392|     25|             b[4] == '/' && b[5] == '/') {
  ------------------
  |  Branch (12392:14): [True: 12, False: 13]
  |  Branch (12392:29): [True: 3, False: 9]
  ------------------
12393|      3|    pos = 6;
12394|      3|    scheme_type = ada::scheme::type::FTP;
12395|      3|    protocol_end = 4;
12396|  1.37k|  } else if (len >= 7 && b[0] == 'h' && b[1] == 't' && b[2] == 't' &&
  ------------------
  |  Branch (12396:14): [True: 736, False: 642]
  |  Branch (12396:26): [True: 102, False: 634]
  |  Branch (12396:41): [True: 80, False: 22]
  |  Branch (12396:56): [True: 62, False: 18]
  ------------------
12397|     62|             b[3] == 'p' && b[4] == ':' && b[5] == '/' && b[6] == '/') {
  ------------------
  |  Branch (12397:14): [True: 46, False: 16]
  |  Branch (12397:29): [True: 31, False: 15]
  |  Branch (12397:44): [True: 13, False: 18]
  |  Branch (12397:59): [True: 3, False: 10]
  ------------------
12398|      3|    pos = 7;
12399|      3|    scheme_type = ada::scheme::type::HTTP;
12400|      3|    protocol_end = 5;
12401|  1.37k|  } else {
12402|  1.37k|    return false;
12403|  1.37k|  }
12404|       |#else
12405|       |  // Big-endian / uncommon arches: byte-wise special-scheme match.
12406|       |  if (len >= 8 && b[0] == 'h' && b[1] == 't' && b[2] == 't' && b[3] == 'p' &&
12407|       |      b[4] == 's' && b[5] == ':' && b[6] == '/' && b[7] == '/') {
12408|       |    pos = 8;
12409|       |    scheme_type = ada::scheme::type::HTTPS;
12410|       |    protocol_end = 6;
12411|       |  } else if (len >= 7 && b[0] == 'h' && b[1] == 't' && b[2] == 't' &&
12412|       |             b[3] == 'p' && b[4] == ':' && b[5] == '/' && b[6] == '/') {
12413|       |    pos = 7;
12414|       |    scheme_type = ada::scheme::type::HTTP;
12415|       |    protocol_end = 5;
12416|       |  } else if (b[0] == 'w' && b[1] == 's') {
12417|       |    if (b[2] == ':' && b[3] == '/' && b[4] == '/') {
12418|       |      pos = 5;
12419|       |      scheme_type = ada::scheme::type::WS;
12420|       |      protocol_end = 3;
12421|       |    } else if (len >= 6 && b[2] == 's' && b[3] == ':' && b[4] == '/' &&
12422|       |               b[5] == '/') {
12423|       |      pos = 6;
12424|       |      scheme_type = ada::scheme::type::WSS;
12425|       |      protocol_end = 4;
12426|       |    } else {
12427|       |      return false;
12428|       |    }
12429|       |  } else if (b[0] == 'f' && b[1] == 't' && b[2] == 'p' && b[3] == ':' &&
12430|       |             b[4] == '/' && b[5] == '/') {
12431|       |    pos = 6;
12432|       |    scheme_type = ada::scheme::type::FTP;
12433|       |    protocol_end = 4;
12434|       |  } else {
12435|       |    return false;
12436|       |  }
12437|       |#endif
12438|  8.47k|  if (pos < len && (b[pos] == '/' || b[pos] == '\\')) [[unlikely]] {
  ------------------
  |  Branch (12438:7): [True: 8.46k, False: 10]
  |  Branch (12438:21): [True: 12, False: 8.45k]
  |  Branch (12438:38): [True: 8, False: 8.44k]
  ------------------
12439|     20|    return false;
12440|     20|  }
12441|       |
12442|       |  // Digit-led hosts are IPv4/numeric; '[' is IPv6. Skip before scanning.
12443|  8.45k|  if (pos < len && ((b[pos] >= '0' && b[pos] <= '9') || b[pos] == '[')) {
  ------------------
  |  Branch (12443:7): [True: 8.44k, False: 10]
  |  Branch (12443:22): [True: 6.49k, False: 1.95k]
  |  Branch (12443:39): [True: 1.13k, False: 5.36k]
  |  Branch (12443:57): [True: 112, False: 7.20k]
  ------------------
12444|  1.24k|    return false;
12445|  1.24k|  }
12446|       |
12447|  7.21k|  const size_t host_start = pos;
12448|  7.21k|  bool has_upper = false;
12449|  7.21k|  bool has_x = false;
12450|  7.21k|  size_t host_end = pos;
12451|  7.21k|  if (!scan_plain_host(b, pos, len, host_end, has_upper, has_x)) {
  ------------------
  |  Branch (12451:7): [True: 282, False: 6.93k]
  ------------------
12452|    282|    return false;
12453|    282|  }
12454|  6.93k|  if (host_start == host_end) [[unlikely]] {
  ------------------
  |  Branch (12454:7): [True: 61, False: 6.87k]
  ------------------
12455|     61|    return false;
12456|     61|  }
12457|  6.87k|  const size_t host_len = host_end - host_start;
12458|  6.87k|  if (host_len > 253) [[unlikely]] {
  ------------------
  |  Branch (12458:7): [True: 88, False: 6.78k]
  ------------------
12459|     88|    return false;
12460|     88|  }
12461|  6.78k|  {
12462|  6.78k|    std::string_view hv(input.data() + host_start, host_len);
12463|  6.78k|    char host_buf[256];
12464|  6.78k|    if (has_upper) [[unlikely]] {
  ------------------
  |  Branch (12464:9): [True: 602, False: 6.18k]
  ------------------
12465|    602|      std::memcpy(host_buf, input.data() + host_start, host_len);
12466|    602|      unicode::to_lower_ascii(host_buf, host_len);
12467|    602|      hv = std::string_view(host_buf, host_len);
12468|    602|    }
12469|  6.78k|    if (ada::checkers::last_label_may_be_a_number(hv)) [[unlikely]] {
  ------------------
  |  Branch (12469:9): [True: 95, False: 6.68k]
  ------------------
12470|     95|      return false;
12471|     95|    }
12472|       |    // Punycode is "xn--...". The host scan already notes a lowercase 'x';
12473|       |    // uppercase 'X' is covered by has_upper after the in-place lower.
12474|  6.68k|    static constexpr std::string_view xn{"xn-", 3};
12475|  6.68k|    if ((has_x || has_upper) && hv.find(xn) != std::string_view::npos)
  ------------------
  |  Branch (12475:10): [True: 1.85k, False: 4.83k]
  |  Branch (12475:19): [True: 550, False: 4.28k]
  |  Branch (12475:33): [True: 1.23k, False: 1.17k]
  ------------------
12476|  1.23k|        [[unlikely]] {
12477|  1.23k|      return false;
12478|  1.23k|    }
12479|  6.68k|  }
12480|       |
12481|  5.45k|  if (host_end < len && b[host_end] == ':') [[unlikely]] {
  ------------------
  |  Branch (12481:7): [True: 5.28k, False: 173]
  |  Branch (12481:25): [True: 1.96k, False: 3.32k]
  ------------------
12482|  1.96k|    return finish_simple_absolute_with_port(input, out, scheme_type,
12483|  1.96k|                                            protocol_end, host_start, host_end,
12484|  1.96k|                                            host_len, has_upper);
12485|  1.96k|  }
12486|       |
12487|  3.49k|  size_t i = host_end;
12488|  3.49k|  size_t path_start = host_end;
12489|  3.49k|  size_t path_end = host_end;
12490|  3.49k|  size_t query_start = std::string_view::npos;
12491|  3.49k|  size_t hash_start = std::string_view::npos;
12492|  3.49k|  bool has_path = false;
12493|  3.49k|  bool maybe_dot_segment = false;
12494|  3.49k|  bool rest_simple = true;
12495|       |
12496|  3.49k|  if (i < len && b[i] == '/') {
  ------------------
  |  Branch (12496:7): [True: 3.32k, False: 173]
  |  Branch (12496:18): [True: 3.17k, False: 143]
  ------------------
12497|  3.17k|    has_path = true;
12498|  3.17k|    path_start = i;
12499|  3.17k|    ++i;
12500|  3.17k|    scan_path_run(b, i, len, maybe_dot_segment);
12501|  3.17k|    if (i < len) {
  ------------------
  |  Branch (12501:9): [True: 1.42k, False: 1.74k]
  ------------------
12502|  1.42k|      const uint8_t cls = k_path[b[i]];
12503|  1.42k|      if (cls == 1) {
  ------------------
  |  Branch (12503:11): [True: 427, False: 1.00k]
  ------------------
12504|    427|        path_end = i;
12505|    427|        if (b[i] == '?') {
  ------------------
  |  Branch (12505:13): [True: 268, False: 159]
  ------------------
12506|    268|          query_start = i;
12507|    268|          ++i;
12508|    268|          goto scan_query;
12509|    268|        }
12510|    159|        hash_start = i;
12511|    159|        ++i;
12512|    159|        goto scan_hash;
12513|    427|      }
12514|  1.00k|      rest_simple = false;
12515|  1.00k|      hash_start = input.find('#', i);
12516|  1.00k|      query_start = input.substr(0, hash_start).find('?', i);
12517|  1.00k|      if (query_start != std::string_view::npos) {
  ------------------
  |  Branch (12517:11): [True: 50, False: 952]
  ------------------
12518|     50|        path_end = query_start;
12519|    952|      } else {
12520|    952|        path_end = hash_start != std::string_view::npos ? hash_start : len;
  ------------------
  |  Branch (12520:20): [True: 32, False: 920]
  ------------------
12521|    952|      }
12522|  1.00k|      goto after_rest;
12523|  1.42k|    }
12524|  1.74k|    path_end = i;
12525|  1.74k|  } else if (i < len && b[i] == '?') {
  ------------------
  |  Branch (12525:14): [True: 143, False: 173]
  |  Branch (12525:25): [True: 73, False: 70]
  ------------------
12526|     73|    query_start = i;
12527|     73|    ++i;
12528|     73|    goto scan_query;
12529|    243|  } else if (i < len && b[i] == '#') {
  ------------------
  |  Branch (12529:14): [True: 70, False: 173]
  |  Branch (12529:25): [True: 70, False: 0]
  ------------------
12530|     70|    hash_start = i;
12531|     70|    ++i;
12532|     70|    goto scan_hash;
12533|     70|  }
12534|  1.92k|  goto after_rest;
12535|       |
12536|  1.92k|scan_query:
12537|    341|  scan_query_run(b, i, len);
12538|    341|  if (i < len) {
  ------------------
  |  Branch (12538:7): [True: 175, False: 166]
  ------------------
12539|    175|    if (b[i] == '#') {
  ------------------
  |  Branch (12539:9): [True: 119, False: 56]
  ------------------
12540|    119|      hash_start = i;
12541|    119|      ++i;
12542|    119|      goto scan_hash;
12543|    119|    }
12544|     56|    rest_simple = false;
12545|     56|    goto scan_query_boundary;
12546|    175|  }
12547|    166|  goto after_rest;
12548|       |
12549|    166|scan_query_boundary:
12550|     56|  hash_start = input.find('#', i);
12551|     56|  goto after_rest;
12552|       |
12553|    348|scan_hash:
12554|    348|  scan_hash_run(b, i, len);
12555|    348|  if (i < len) {
  ------------------
  |  Branch (12555:7): [True: 58, False: 290]
  ------------------
12556|     58|    rest_simple = false;
12557|     58|  }
12558|       |
12559|  3.49k|after_rest:
12560|  3.49k|  if (rest_simple && maybe_dot_segment) {
  ------------------
  |  Branch (12560:7): [True: 2.37k, False: 1.11k]
  |  Branch (12560:22): [True: 429, False: 1.94k]
  ------------------
12561|    429|    const std::string_view path_body(input.data() + path_start,
12562|    429|                                     path_end - path_start);
12563|    429|    if (path_has_dot_segment(path_body)) {
  ------------------
  |  Branch (12563:9): [True: 178, False: 251]
  ------------------
12564|    178|      rest_simple = false;
12565|    178|    }
12566|    429|  }
12567|       |
12568|       |  // The slow path removes ASCII tab/newline anywhere in the input and trims a
12569|       |  // trailing C0 control or space; this fast path does neither. A query or
12570|       |  // fragment reaching the helpers below would keep those bytes percent-encoded
12571|       |  // ("?a\nb" -> "?a%0Ab", "#f " -> "#f%20") instead of stripped, so hand such
12572|       |  // inputs back to the slow path.
12573|  3.49k|  if (!rest_simple && (unicode::is_c0_control_or_space(input.back()) ||
  ------------------
  |  Branch (12573:7): [True: 1.29k, False: 2.19k]
  |  Branch (12573:24): [True: 35, False: 1.25k]
  ------------------
12574|  1.25k|                       unicode::has_tabs_or_newline(input))) {
  ------------------
  |  Branch (12574:24): [True: 25, False: 1.23k]
  ------------------
12575|     60|    return false;
12576|     60|  }
12577|       |
12578|  3.43k|  out.type = scheme_type;
12579|  3.43k|  out.is_valid = true;
12580|  3.43k|  out.has_opaque_path = false;
12581|  3.43k|  out.host_type = DEFAULT;
12582|       |
12583|  3.43k|  if (!rest_simple) {
  ------------------
  |  Branch (12583:7): [True: 1.23k, False: 2.19k]
  ------------------
12584|       |    // Host is a plain domain. Finish path/query/hash with
12585|       |    // the regular helpers
12586|       |    // so percent-encoding and dot segments do not re-parse the authority.
12587|  1.23k|    const std::string_view path_view =
12588|  1.23k|        has_path
  ------------------
  |  Branch (12588:9): [True: 1.17k, False: 56]
  ------------------
12589|  1.23k|            ? std::string_view(input.data() + path_start, path_end - path_start)
12590|  1.23k|            : std::string_view{};
12591|  1.23k|    auto apply_query_and_hash = [&]() {
12592|  1.23k|      if (query_start != std::string_view::npos) {
12593|  1.23k|        const size_t q_end =
12594|  1.23k|            (hash_start != std::string_view::npos) ? hash_start : len;
12595|  1.23k|        out.update_base_search(std::string_view(input.data() + query_start + 1,
12596|  1.23k|                                                q_end - query_start - 1),
12597|  1.23k|                               character_sets::SPECIAL_QUERY_PERCENT_ENCODE);
12598|  1.23k|      }
12599|  1.23k|      if (hash_start != std::string_view::npos) {
12600|  1.23k|        out.update_unencoded_base_hash(std::string_view(
12601|  1.23k|            input.data() + hash_start + 1, len - hash_start - 1));
12602|  1.23k|      }
12603|  1.23k|    };
12604|  1.23k|    if constexpr (is_aggregator) {
12605|  1.23k|      out.buffer.assign(input.substr(0, host_end));
12606|  1.23k|      if (has_upper) {
  ------------------
  |  Branch (12606:11): [True: 160, False: 1.07k]
  ------------------
12607|    160|        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12608|    160|      }
12609|  1.23k|      out.components.protocol_end = protocol_end;
12610|  1.23k|      out.components.username_end = protocol_end + 2;
12611|  1.23k|      out.components.host_start = protocol_end + 2;
12612|  1.23k|      out.components.host_end = static_cast<uint32_t>(host_end);
12613|  1.23k|      out.components.port = url_components::omitted;
12614|  1.23k|      out.components.pathname_start = static_cast<uint32_t>(host_end);
12615|  1.23k|      out.components.search_start = url_components::omitted;
12616|  1.23k|      out.components.hash_start = url_components::omitted;
12617|  1.23k|      out.parse_path(path_view);
12618|  1.23k|      apply_query_and_hash();
12619|       |    } else {
12620|       |      std::string host_str(input.substr(host_start, host_len));
12621|       |      if (has_upper) {
12622|       |        unicode::to_lower_ascii(host_str.data(), host_str.size());
12623|       |      }
12624|       |      out.host = std::move(host_str);
12625|       |      out.parse_path(path_view);
12626|       |      apply_query_and_hash();
12627|       |    }
12628|  1.23k|    return true;
12629|  1.23k|  }
12630|       |
12631|  2.19k|  const bool need_slash = !has_path;
12632|  2.19k|  if constexpr (is_aggregator) {
12633|  2.19k|    if (!need_slash) {
  ------------------
  |  Branch (12633:9): [True: 1.96k, False: 237]
  ------------------
12634|       |      // assign copies once. resize()+memcpy would value-init then overwrite.
12635|  1.96k|      out.buffer.assign(input);
12636|  1.96k|      if (has_upper) {
  ------------------
  |  Branch (12636:11): [True: 32, False: 1.93k]
  ------------------
12637|     32|        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12638|     32|      }
12639|  1.96k|      out.components.protocol_end = protocol_end;
12640|  1.96k|      out.components.username_end = protocol_end + 2;
12641|  1.96k|      out.components.host_start = protocol_end + 2;
12642|  1.96k|      out.components.host_end = static_cast<uint32_t>(host_end);
12643|  1.96k|      out.components.port = url_components::omitted;
12644|  1.96k|      out.components.pathname_start = static_cast<uint32_t>(path_start);
12645|  1.96k|      out.components.search_start = (query_start != std::string_view::npos)
  ------------------
  |  Branch (12645:37): [True: 241, False: 1.72k]
  ------------------
12646|  1.96k|                                        ? static_cast<uint32_t>(query_start)
12647|  1.96k|                                        : url_components::omitted;
12648|  1.96k|      out.components.hash_start = (hash_start != std::string_view::npos)
  ------------------
  |  Branch (12648:35): [True: 254, False: 1.70k]
  ------------------
12649|  1.96k|                                      ? static_cast<uint32_t>(hash_start)
12650|  1.96k|                                      : url_components::omitted;
12651|  1.96k|    } else {
12652|    237|      out.buffer.clear();
12653|    237|      out.buffer.reserve(len + 1);
12654|    237|      out.buffer.append(input.substr(0, host_end));
12655|    237|      out.buffer.push_back('/');
12656|    237|      if (host_end < len) {
  ------------------
  |  Branch (12656:11): [True: 64, False: 173]
  ------------------
12657|     64|        out.buffer.append(input.substr(host_end));
12658|     64|      }
12659|    237|      if (has_upper) {
  ------------------
  |  Branch (12659:11): [True: 107, False: 130]
  ------------------
12660|    107|        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12661|    107|      }
12662|    237|      out.components.protocol_end = protocol_end;
12663|    237|      out.components.username_end = protocol_end + 2;
12664|    237|      out.components.host_start = protocol_end + 2;
12665|    237|      out.components.host_end = static_cast<uint32_t>(host_end);
12666|    237|      out.components.port = url_components::omitted;
12667|    237|      out.components.pathname_start = static_cast<uint32_t>(host_end);
12668|    237|      out.components.search_start = (query_start != std::string_view::npos)
  ------------------
  |  Branch (12668:37): [True: 41, False: 196]
  ------------------
12669|    237|                                        ? static_cast<uint32_t>(query_start + 1)
12670|    237|                                        : url_components::omitted;
12671|    237|      out.components.hash_start = (hash_start != std::string_view::npos)
  ------------------
  |  Branch (12671:35): [True: 36, False: 201]
  ------------------
12672|    237|                                      ? static_cast<uint32_t>(hash_start + 1)
12673|    237|                                      : url_components::omitted;
12674|    237|    }
12675|       |  } else {
12676|       |    std::string host_str(input.substr(host_start, host_len));
12677|       |    if (has_upper) {
12678|       |      unicode::to_lower_ascii(host_str.data(), host_str.size());
12679|       |    }
12680|       |    out.host = std::move(host_str);
12681|       |    if (need_slash) {
12682|       |      out.path = "/";
12683|       |    } else {
12684|       |      out.path.assign(input.data() + path_start, path_end - path_start);
12685|       |    }
12686|       |    if (query_start != std::string_view::npos) {
12687|       |      const size_t q_end =
12688|       |          (hash_start != std::string_view::npos) ? hash_start : len;
12689|       |      out.query.emplace(input.data() + query_start + 1,
12690|       |                        q_end - query_start - 1);
12691|       |    }
12692|       |    if (hash_start != std::string_view::npos) {
12693|       |      out.hash.emplace(input.data() + hash_start + 1, len - hash_start - 1);
12694|       |    }
12695|       |  }
12696|  2.19k|  return true;
12697|  3.43k|}
_ZN3ada6parser32finish_simple_absolute_with_portINS_3urlEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_NS_6scheme4typeEjmmmb:
12057|  1.96k|    bool has_upper) {
12058|  1.96k|  constexpr bool is_ada_url = std::is_same_v<result_type, ada::url>;
12059|  1.96k|  constexpr bool is_aggregator =
12060|  1.96k|      std::is_same_v<result_type, ada::url_aggregator>;
12061|  1.96k|  static_assert(is_ada_url || is_aggregator);
12062|       |
12063|  1.96k|  const size_t len = input.size();
12064|  1.96k|  const auto* b = reinterpret_cast<const uint8_t*>(input.data());
12065|  1.96k|  size_t p = host_end + 1;
12066|  1.96k|  uint32_t port_value = 0;
12067|  1.96k|  bool any_digit = false;
12068|  4.22k|  while (p < len && b[p] >= '0' && b[p] <= '9') {
  ------------------
  |  Branch (12068:10): [True: 4.15k, False: 72]
  |  Branch (12068:21): [True: 2.37k, False: 1.77k]
  |  Branch (12068:36): [True: 2.27k, False: 105]
  ------------------
12069|  2.27k|    any_digit = true;
12070|  2.27k|    port_value = port_value * 10 + static_cast<uint32_t>(b[p] - '0');
12071|  2.27k|    if (port_value > 65535) [[unlikely]] {
  ------------------
  |  Branch (12071:9): [True: 11, False: 2.26k]
  ------------------
12072|     11|      return false;
12073|     11|    }
12074|  2.26k|    ++p;
12075|  2.26k|  }
12076|  1.95k|  if (p < len && b[p] != '/' && b[p] != '?' && b[p] != '#') [[unlikely]] {
  ------------------
  |  Branch (12076:7): [True: 1.88k, False: 72]
  |  Branch (12076:18): [True: 198, False: 1.68k]
  |  Branch (12076:33): [True: 129, False: 69]
  |  Branch (12076:48): [True: 53, False: 76]
  ------------------
12077|     53|    return false;
12078|     53|  }
12079|  1.90k|  uint32_t parsed_port = url_components::omitted;
12080|  1.90k|  const uint16_t default_port = ada::scheme::get_special_port(scheme_type);
12081|  1.90k|  if (any_digit && port_value != default_port) {
  ------------------
  |  Branch (12081:7): [True: 1.25k, False: 647]
  |  Branch (12081:20): [True: 1.24k, False: 4]
  ------------------
12082|  1.24k|    parsed_port = port_value;
12083|  1.24k|  }
12084|  1.90k|  const size_t authority_end = p;
12085|       |
12086|  1.90k|  size_t i = authority_end;
12087|  1.90k|  size_t path_start = host_end;
12088|  1.90k|  size_t path_end = host_end;
12089|  1.90k|  size_t query_start = std::string_view::npos;
12090|  1.90k|  size_t hash_start = std::string_view::npos;
12091|  1.90k|  bool has_path = false;
12092|  1.90k|  bool maybe_dot_segment = false;
12093|  1.90k|  bool rest_simple = true;
12094|       |
12095|  1.90k|  if (i < len && b[i] == '/') {
  ------------------
  |  Branch (12095:7): [True: 1.82k, False: 72]
  |  Branch (12095:18): [True: 1.68k, False: 145]
  ------------------
12096|  1.68k|    has_path = true;
12097|  1.68k|    path_start = i;
12098|  1.68k|    ++i;
12099|  1.68k|    scan_path_run(b, i, len, maybe_dot_segment);
12100|  1.68k|    if (i < len) {
  ------------------
  |  Branch (12100:9): [True: 1.07k, False: 608]
  ------------------
12101|  1.07k|      const uint8_t cls = k_path[b[i]];
12102|  1.07k|      if (cls == 1) {
  ------------------
  |  Branch (12102:11): [True: 237, False: 838]
  ------------------
12103|    237|        path_end = i;
12104|    237|        if (b[i] == '?') {
  ------------------
  |  Branch (12104:13): [True: 159, False: 78]
  ------------------
12105|    159|          query_start = i;
12106|    159|          ++i;
12107|    159|          goto scan_query;
12108|    159|        }
12109|     78|        hash_start = i;
12110|     78|        ++i;
12111|     78|        goto scan_hash;
12112|    237|      }
12113|    838|      rest_simple = false;
12114|  28.0k|      for (; i < len; ++i) {
  ------------------
  |  Branch (12114:14): [True: 27.2k, False: 767]
  ------------------
12115|  27.2k|        if (b[i] == '?') {
  ------------------
  |  Branch (12115:13): [True: 46, False: 27.1k]
  ------------------
12116|     46|          path_end = i;
12117|     46|          query_start = i;
12118|     46|          ++i;
12119|     46|          goto scan_query_boundary;
12120|     46|        }
12121|  27.1k|        if (b[i] == '#') {
  ------------------
  |  Branch (12121:13): [True: 25, False: 27.1k]
  ------------------
12122|     25|          path_end = i;
12123|     25|          hash_start = i;
12124|     25|          ++i;
12125|     25|          goto after_rest;
12126|     25|        }
12127|  27.1k|      }
12128|    767|      path_end = i;
12129|    767|      goto after_rest;
12130|    838|    }
12131|    608|    path_end = i;
12132|    608|  } else if (i < len && b[i] == '?') {
  ------------------
  |  Branch (12132:14): [True: 145, False: 72]
  |  Branch (12132:25): [True: 69, False: 76]
  ------------------
12133|     69|    query_start = i;
12134|     69|    ++i;
12135|     69|    goto scan_query;
12136|    148|  } else if (i < len && b[i] == '#') {
  ------------------
  |  Branch (12136:14): [True: 76, False: 72]
  |  Branch (12136:25): [True: 76, False: 0]
  ------------------
12137|     76|    hash_start = i;
12138|     76|    ++i;
12139|     76|    goto scan_hash;
12140|     76|  }
12141|    680|  goto after_rest;
12142|       |
12143|    680|scan_query:
12144|    228|  scan_query_run(b, i, len);
12145|    228|  if (i < len) {
  ------------------
  |  Branch (12145:7): [True: 118, False: 110]
  ------------------
12146|    118|    if (b[i] == '#') {
  ------------------
  |  Branch (12146:9): [True: 76, False: 42]
  ------------------
12147|     76|      hash_start = i;
12148|     76|      ++i;
12149|     76|      goto scan_hash;
12150|     76|    }
12151|     42|    rest_simple = false;
12152|     42|    goto scan_query_boundary;
12153|    118|  }
12154|    110|  goto after_rest;
12155|       |
12156|    110|scan_query_boundary:
12157|    919|  for (; i < len; ++i) {
  ------------------
  |  Branch (12157:10): [True: 850, False: 69]
  ------------------
12158|    850|    if (b[i] == '#') {
  ------------------
  |  Branch (12158:9): [True: 19, False: 831]
  ------------------
12159|     19|      hash_start = i;
12160|     19|      ++i;
12161|     19|      goto after_rest;
12162|     19|    }
12163|    850|  }
12164|     69|  goto after_rest;
12165|       |
12166|    230|scan_hash:
12167|    230|  scan_hash_run(b, i, len);
12168|    230|  if (i < len) {
  ------------------
  |  Branch (12168:7): [True: 58, False: 172]
  ------------------
12169|     58|    rest_simple = false;
12170|     58|  }
12171|       |
12172|  1.90k|after_rest:
12173|  1.90k|  if (rest_simple && maybe_dot_segment) {
  ------------------
  |  Branch (12173:7): [True: 962, False: 938]
  |  Branch (12173:22): [True: 344, False: 618]
  ------------------
12174|    344|    const std::string_view path_body(input.data() + path_start,
12175|    344|                                     path_end - path_start);
12176|    344|    if (path_has_dot_segment(path_body)) {
  ------------------
  |  Branch (12176:9): [True: 228, False: 116]
  ------------------
12177|    228|      rest_simple = false;
12178|    228|    }
12179|    344|  }
12180|       |
12181|       |  // The slow path removes ASCII tab/newline anywhere in the input and trims a
12182|       |  // trailing C0 control or space; this fast path does neither. A query or
12183|       |  // fragment reaching the helpers below would keep those bytes percent-encoded
12184|       |  // ("?a\nb" -> "?a%0Ab", "#f " -> "#f%20") instead of stripped, so hand such
12185|       |  // inputs back to the slow path.
12186|  1.90k|  if (!rest_simple && (unicode::is_c0_control_or_space(input.back()) ||
  ------------------
  |  Branch (12186:7): [True: 1.16k, False: 734]
  |  Branch (12186:24): [True: 41, False: 1.12k]
  ------------------
12187|  1.12k|                       unicode::has_tabs_or_newline(input))) {
  ------------------
  |  Branch (12187:24): [True: 29, False: 1.09k]
  ------------------
12188|     70|    return false;
12189|     70|  }
12190|       |
12191|  1.83k|  out.type = scheme_type;
12192|  1.83k|  out.is_valid = true;
12193|  1.83k|  out.has_opaque_path = false;
12194|  1.83k|  out.host_type = DEFAULT;
12195|       |
12196|  1.83k|  const uint32_t port_bytes = (parsed_port != url_components::omitted)
  ------------------
  |  Branch (12196:31): [True: 1.23k, False: 595]
  ------------------
12197|  1.83k|                                  ? (1 + port_decimal_digit_count(parsed_port))
12198|  1.83k|                                  : 0;
12199|       |
12200|  1.83k|  if (!rest_simple) {
  ------------------
  |  Branch (12200:7): [True: 1.09k, False: 734]
  ------------------
12201|  1.09k|    const std::string_view path_view =
12202|  1.09k|        has_path
  ------------------
  |  Branch (12202:9): [True: 1.05k, False: 46]
  ------------------
12203|  1.09k|            ? std::string_view(input.data() + path_start, path_end - path_start)
12204|  1.09k|            : std::string_view{};
12205|  1.09k|    auto apply_query_and_hash = [&]() {
12206|  1.09k|      if (query_start != std::string_view::npos) {
12207|  1.09k|        const size_t q_end =
12208|  1.09k|            (hash_start != std::string_view::npos) ? hash_start : len;
12209|  1.09k|        out.update_base_search(std::string_view(input.data() + query_start + 1,
12210|  1.09k|                                                q_end - query_start - 1),
12211|  1.09k|                               character_sets::SPECIAL_QUERY_PERCENT_ENCODE);
12212|  1.09k|      }
12213|  1.09k|      if (hash_start != std::string_view::npos) {
12214|  1.09k|        out.update_unencoded_base_hash(std::string_view(
12215|  1.09k|            input.data() + hash_start + 1, len - hash_start - 1));
12216|  1.09k|      }
12217|  1.09k|    };
12218|       |    if constexpr (is_aggregator) {
12219|       |      out.buffer.assign(input.substr(0, host_end));
12220|       |      if (parsed_port != url_components::omitted) {
12221|       |        append_canonical_port(out.buffer, parsed_port);
12222|       |      }
12223|       |      if (has_upper) {
12224|       |        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12225|       |      }
12226|       |      out.components.protocol_end = protocol_end;
12227|       |      out.components.username_end = protocol_end + 2;
12228|       |      out.components.host_start = protocol_end + 2;
12229|       |      out.components.host_end = static_cast<uint32_t>(host_end);
12230|       |      out.components.port = parsed_port;
12231|       |      out.components.pathname_start = static_cast<uint32_t>(out.buffer.size());
12232|       |      out.components.search_start = url_components::omitted;
12233|       |      out.components.hash_start = url_components::omitted;
12234|       |      out.parse_path(path_view);
12235|       |      apply_query_and_hash();
12236|  1.09k|    } else {
12237|  1.09k|      std::string host_str(input.substr(host_start, host_len));
12238|  1.09k|      if (has_upper) {
  ------------------
  |  Branch (12238:11): [True: 149, False: 947]
  ------------------
12239|    149|        unicode::to_lower_ascii(host_str.data(), host_str.size());
12240|    149|      }
12241|  1.09k|      out.host = std::move(host_str);
12242|  1.09k|      if (parsed_port != url_components::omitted) {
  ------------------
  |  Branch (12242:11): [True: 597, False: 499]
  ------------------
12243|    597|        out.port = static_cast<uint16_t>(parsed_port);
12244|    597|      }
12245|  1.09k|      out.parse_path(path_view);
12246|  1.09k|      apply_query_and_hash();
12247|  1.09k|    }
12248|  1.09k|    return true;
12249|  1.09k|  }
12250|       |
12251|    734|  const bool insert_slash = !has_path;
12252|       |  if constexpr (is_aggregator) {
12253|       |    const size_t out_len =
12254|       |        host_end + port_bytes + (insert_slash ? 1 : 0) + (len - authority_end);
12255|       |    const bool omit_port_bytes = parsed_port == url_components::omitted;
12256|       |    if (out_len == len && !insert_slash && !omit_port_bytes) {
12257|       |      out.buffer.assign(input);
12258|       |    } else {
12259|       |      out.buffer.clear();
12260|       |      out.buffer.reserve(out_len);
12261|       |      out.buffer.append(input.substr(0, host_end));
12262|       |      if (parsed_port != url_components::omitted) {
12263|       |        append_canonical_port(out.buffer, parsed_port);
12264|       |      }
12265|       |      if (insert_slash) {
12266|       |        out.buffer.push_back('/');
12267|       |      }
12268|       |      if (authority_end < len) {
12269|       |        out.buffer.append(input.substr(authority_end));
12270|       |      }
12271|       |    }
12272|       |    if (has_upper) {
12273|       |      unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12274|       |    }
12275|       |    const uint32_t pathname_start =
12276|       |        static_cast<uint32_t>(host_end) + port_bytes;
12277|       |    const int32_t tail_delta = static_cast<int32_t>(pathname_start) +
12278|       |                               (insert_slash ? 1 : 0) -
12279|       |                               static_cast<int32_t>(authority_end);
12280|       |    out.components.protocol_end = protocol_end;
12281|       |    out.components.username_end = protocol_end + 2;
12282|       |    out.components.host_start = protocol_end + 2;
12283|       |    out.components.host_end = static_cast<uint32_t>(host_end);
12284|       |    out.components.port = parsed_port;
12285|       |    out.components.pathname_start = pathname_start;
12286|       |    out.components.search_start =
12287|       |        (query_start != std::string_view::npos)
12288|       |            ? static_cast<uint32_t>(static_cast<int32_t>(query_start) +
12289|       |                                    tail_delta)
12290|       |            : url_components::omitted;
12291|       |    out.components.hash_start =
12292|       |        (hash_start != std::string_view::npos)
12293|       |            ? static_cast<uint32_t>(static_cast<int32_t>(hash_start) +
12294|       |                                    tail_delta)
12295|       |            : url_components::omitted;
12296|    734|  } else {
12297|    734|    std::string host_str(input.substr(host_start, host_len));
12298|    734|    if (has_upper) {
  ------------------
  |  Branch (12298:9): [True: 94, False: 640]
  ------------------
12299|     94|      unicode::to_lower_ascii(host_str.data(), host_str.size());
12300|     94|    }
12301|    734|    out.host = std::move(host_str);
12302|    734|    if (parsed_port != url_components::omitted) {
  ------------------
  |  Branch (12302:9): [True: 638, False: 96]
  ------------------
12303|    638|      out.port = static_cast<uint16_t>(parsed_port);
12304|    638|    }
12305|    734|    if (insert_slash) {
  ------------------
  |  Branch (12305:9): [True: 143, False: 591]
  ------------------
12306|    143|      out.path = "/";
12307|    591|    } else {
12308|    591|      out.path.assign(input.data() + path_start, path_end - path_start);
12309|    591|    }
12310|    734|    if (query_start != std::string_view::npos) {
  ------------------
  |  Branch (12310:9): [True: 182, False: 552]
  ------------------
12311|    182|      const size_t q_end =
12312|    182|          (hash_start != std::string_view::npos) ? hash_start : len;
  ------------------
  |  Branch (12312:11): [True: 72, False: 110]
  ------------------
12313|    182|      out.query.emplace(input.data() + query_start + 1,
12314|    182|                        q_end - query_start - 1);
12315|    182|    }
12316|    734|    if (hash_start != std::string_view::npos) {
  ------------------
  |  Branch (12316:9): [True: 172, False: 562]
  ------------------
12317|    172|      out.hash.emplace(input.data() + hash_start + 1, len - hash_start - 1);
12318|    172|    }
12319|    734|  }
12320|    734|  return true;
12321|  1.83k|}
_ZN3ada6parser32finish_simple_absolute_with_portINS_14url_aggregatorEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_NS_6scheme4typeEjmmmb:
12057|  1.96k|    bool has_upper) {
12058|  1.96k|  constexpr bool is_ada_url = std::is_same_v<result_type, ada::url>;
12059|  1.96k|  constexpr bool is_aggregator =
12060|  1.96k|      std::is_same_v<result_type, ada::url_aggregator>;
12061|  1.96k|  static_assert(is_ada_url || is_aggregator);
12062|       |
12063|  1.96k|  const size_t len = input.size();
12064|  1.96k|  const auto* b = reinterpret_cast<const uint8_t*>(input.data());
12065|  1.96k|  size_t p = host_end + 1;
12066|  1.96k|  uint32_t port_value = 0;
12067|  1.96k|  bool any_digit = false;
12068|  4.22k|  while (p < len && b[p] >= '0' && b[p] <= '9') {
  ------------------
  |  Branch (12068:10): [True: 4.15k, False: 72]
  |  Branch (12068:21): [True: 2.37k, False: 1.77k]
  |  Branch (12068:36): [True: 2.27k, False: 105]
  ------------------
12069|  2.27k|    any_digit = true;
12070|  2.27k|    port_value = port_value * 10 + static_cast<uint32_t>(b[p] - '0');
12071|  2.27k|    if (port_value > 65535) [[unlikely]] {
  ------------------
  |  Branch (12071:9): [True: 11, False: 2.26k]
  ------------------
12072|     11|      return false;
12073|     11|    }
12074|  2.26k|    ++p;
12075|  2.26k|  }
12076|  1.95k|  if (p < len && b[p] != '/' && b[p] != '?' && b[p] != '#') [[unlikely]] {
  ------------------
  |  Branch (12076:7): [True: 1.88k, False: 72]
  |  Branch (12076:18): [True: 198, False: 1.68k]
  |  Branch (12076:33): [True: 129, False: 69]
  |  Branch (12076:48): [True: 53, False: 76]
  ------------------
12077|     53|    return false;
12078|     53|  }
12079|  1.90k|  uint32_t parsed_port = url_components::omitted;
12080|  1.90k|  const uint16_t default_port = ada::scheme::get_special_port(scheme_type);
12081|  1.90k|  if (any_digit && port_value != default_port) {
  ------------------
  |  Branch (12081:7): [True: 1.25k, False: 647]
  |  Branch (12081:20): [True: 1.24k, False: 4]
  ------------------
12082|  1.24k|    parsed_port = port_value;
12083|  1.24k|  }
12084|  1.90k|  const size_t authority_end = p;
12085|       |
12086|  1.90k|  size_t i = authority_end;
12087|  1.90k|  size_t path_start = host_end;
12088|  1.90k|  size_t path_end = host_end;
12089|  1.90k|  size_t query_start = std::string_view::npos;
12090|  1.90k|  size_t hash_start = std::string_view::npos;
12091|  1.90k|  bool has_path = false;
12092|  1.90k|  bool maybe_dot_segment = false;
12093|  1.90k|  bool rest_simple = true;
12094|       |
12095|  1.90k|  if (i < len && b[i] == '/') {
  ------------------
  |  Branch (12095:7): [True: 1.82k, False: 72]
  |  Branch (12095:18): [True: 1.68k, False: 145]
  ------------------
12096|  1.68k|    has_path = true;
12097|  1.68k|    path_start = i;
12098|  1.68k|    ++i;
12099|  1.68k|    scan_path_run(b, i, len, maybe_dot_segment);
12100|  1.68k|    if (i < len) {
  ------------------
  |  Branch (12100:9): [True: 1.07k, False: 608]
  ------------------
12101|  1.07k|      const uint8_t cls = k_path[b[i]];
12102|  1.07k|      if (cls == 1) {
  ------------------
  |  Branch (12102:11): [True: 237, False: 838]
  ------------------
12103|    237|        path_end = i;
12104|    237|        if (b[i] == '?') {
  ------------------
  |  Branch (12104:13): [True: 159, False: 78]
  ------------------
12105|    159|          query_start = i;
12106|    159|          ++i;
12107|    159|          goto scan_query;
12108|    159|        }
12109|     78|        hash_start = i;
12110|     78|        ++i;
12111|     78|        goto scan_hash;
12112|    237|      }
12113|    838|      rest_simple = false;
12114|  28.0k|      for (; i < len; ++i) {
  ------------------
  |  Branch (12114:14): [True: 27.2k, False: 767]
  ------------------
12115|  27.2k|        if (b[i] == '?') {
  ------------------
  |  Branch (12115:13): [True: 46, False: 27.1k]
  ------------------
12116|     46|          path_end = i;
12117|     46|          query_start = i;
12118|     46|          ++i;
12119|     46|          goto scan_query_boundary;
12120|     46|        }
12121|  27.1k|        if (b[i] == '#') {
  ------------------
  |  Branch (12121:13): [True: 25, False: 27.1k]
  ------------------
12122|     25|          path_end = i;
12123|     25|          hash_start = i;
12124|     25|          ++i;
12125|     25|          goto after_rest;
12126|     25|        }
12127|  27.1k|      }
12128|    767|      path_end = i;
12129|    767|      goto after_rest;
12130|    838|    }
12131|    608|    path_end = i;
12132|    608|  } else if (i < len && b[i] == '?') {
  ------------------
  |  Branch (12132:14): [True: 145, False: 72]
  |  Branch (12132:25): [True: 69, False: 76]
  ------------------
12133|     69|    query_start = i;
12134|     69|    ++i;
12135|     69|    goto scan_query;
12136|    148|  } else if (i < len && b[i] == '#') {
  ------------------
  |  Branch (12136:14): [True: 76, False: 72]
  |  Branch (12136:25): [True: 76, False: 0]
  ------------------
12137|     76|    hash_start = i;
12138|     76|    ++i;
12139|     76|    goto scan_hash;
12140|     76|  }
12141|    680|  goto after_rest;
12142|       |
12143|    680|scan_query:
12144|    228|  scan_query_run(b, i, len);
12145|    228|  if (i < len) {
  ------------------
  |  Branch (12145:7): [True: 118, False: 110]
  ------------------
12146|    118|    if (b[i] == '#') {
  ------------------
  |  Branch (12146:9): [True: 76, False: 42]
  ------------------
12147|     76|      hash_start = i;
12148|     76|      ++i;
12149|     76|      goto scan_hash;
12150|     76|    }
12151|     42|    rest_simple = false;
12152|     42|    goto scan_query_boundary;
12153|    118|  }
12154|    110|  goto after_rest;
12155|       |
12156|    110|scan_query_boundary:
12157|    919|  for (; i < len; ++i) {
  ------------------
  |  Branch (12157:10): [True: 850, False: 69]
  ------------------
12158|    850|    if (b[i] == '#') {
  ------------------
  |  Branch (12158:9): [True: 19, False: 831]
  ------------------
12159|     19|      hash_start = i;
12160|     19|      ++i;
12161|     19|      goto after_rest;
12162|     19|    }
12163|    850|  }
12164|     69|  goto after_rest;
12165|       |
12166|    230|scan_hash:
12167|    230|  scan_hash_run(b, i, len);
12168|    230|  if (i < len) {
  ------------------
  |  Branch (12168:7): [True: 58, False: 172]
  ------------------
12169|     58|    rest_simple = false;
12170|     58|  }
12171|       |
12172|  1.90k|after_rest:
12173|  1.90k|  if (rest_simple && maybe_dot_segment) {
  ------------------
  |  Branch (12173:7): [True: 962, False: 938]
  |  Branch (12173:22): [True: 344, False: 618]
  ------------------
12174|    344|    const std::string_view path_body(input.data() + path_start,
12175|    344|                                     path_end - path_start);
12176|    344|    if (path_has_dot_segment(path_body)) {
  ------------------
  |  Branch (12176:9): [True: 228, False: 116]
  ------------------
12177|    228|      rest_simple = false;
12178|    228|    }
12179|    344|  }
12180|       |
12181|       |  // The slow path removes ASCII tab/newline anywhere in the input and trims a
12182|       |  // trailing C0 control or space; this fast path does neither. A query or
12183|       |  // fragment reaching the helpers below would keep those bytes percent-encoded
12184|       |  // ("?a\nb" -> "?a%0Ab", "#f " -> "#f%20") instead of stripped, so hand such
12185|       |  // inputs back to the slow path.
12186|  1.90k|  if (!rest_simple && (unicode::is_c0_control_or_space(input.back()) ||
  ------------------
  |  Branch (12186:7): [True: 1.16k, False: 734]
  |  Branch (12186:24): [True: 41, False: 1.12k]
  ------------------
12187|  1.12k|                       unicode::has_tabs_or_newline(input))) {
  ------------------
  |  Branch (12187:24): [True: 29, False: 1.09k]
  ------------------
12188|     70|    return false;
12189|     70|  }
12190|       |
12191|  1.83k|  out.type = scheme_type;
12192|  1.83k|  out.is_valid = true;
12193|  1.83k|  out.has_opaque_path = false;
12194|  1.83k|  out.host_type = DEFAULT;
12195|       |
12196|  1.83k|  const uint32_t port_bytes = (parsed_port != url_components::omitted)
  ------------------
  |  Branch (12196:31): [True: 1.23k, False: 595]
  ------------------
12197|  1.83k|                                  ? (1 + port_decimal_digit_count(parsed_port))
12198|  1.83k|                                  : 0;
12199|       |
12200|  1.83k|  if (!rest_simple) {
  ------------------
  |  Branch (12200:7): [True: 1.09k, False: 734]
  ------------------
12201|  1.09k|    const std::string_view path_view =
12202|  1.09k|        has_path
  ------------------
  |  Branch (12202:9): [True: 1.05k, False: 46]
  ------------------
12203|  1.09k|            ? std::string_view(input.data() + path_start, path_end - path_start)
12204|  1.09k|            : std::string_view{};
12205|  1.09k|    auto apply_query_and_hash = [&]() {
12206|  1.09k|      if (query_start != std::string_view::npos) {
12207|  1.09k|        const size_t q_end =
12208|  1.09k|            (hash_start != std::string_view::npos) ? hash_start : len;
12209|  1.09k|        out.update_base_search(std::string_view(input.data() + query_start + 1,
12210|  1.09k|                                                q_end - query_start - 1),
12211|  1.09k|                               character_sets::SPECIAL_QUERY_PERCENT_ENCODE);
12212|  1.09k|      }
12213|  1.09k|      if (hash_start != std::string_view::npos) {
12214|  1.09k|        out.update_unencoded_base_hash(std::string_view(
12215|  1.09k|            input.data() + hash_start + 1, len - hash_start - 1));
12216|  1.09k|      }
12217|  1.09k|    };
12218|  1.09k|    if constexpr (is_aggregator) {
12219|  1.09k|      out.buffer.assign(input.substr(0, host_end));
12220|  1.09k|      if (parsed_port != url_components::omitted) {
  ------------------
  |  Branch (12220:11): [True: 597, False: 499]
  ------------------
12221|    597|        append_canonical_port(out.buffer, parsed_port);
12222|    597|      }
12223|  1.09k|      if (has_upper) {
  ------------------
  |  Branch (12223:11): [True: 149, False: 947]
  ------------------
12224|    149|        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12225|    149|      }
12226|  1.09k|      out.components.protocol_end = protocol_end;
12227|  1.09k|      out.components.username_end = protocol_end + 2;
12228|  1.09k|      out.components.host_start = protocol_end + 2;
12229|  1.09k|      out.components.host_end = static_cast<uint32_t>(host_end);
12230|  1.09k|      out.components.port = parsed_port;
12231|  1.09k|      out.components.pathname_start = static_cast<uint32_t>(out.buffer.size());
12232|  1.09k|      out.components.search_start = url_components::omitted;
12233|  1.09k|      out.components.hash_start = url_components::omitted;
12234|  1.09k|      out.parse_path(path_view);
12235|  1.09k|      apply_query_and_hash();
12236|       |    } else {
12237|       |      std::string host_str(input.substr(host_start, host_len));
12238|       |      if (has_upper) {
12239|       |        unicode::to_lower_ascii(host_str.data(), host_str.size());
12240|       |      }
12241|       |      out.host = std::move(host_str);
12242|       |      if (parsed_port != url_components::omitted) {
12243|       |        out.port = static_cast<uint16_t>(parsed_port);
12244|       |      }
12245|       |      out.parse_path(path_view);
12246|       |      apply_query_and_hash();
12247|       |    }
12248|  1.09k|    return true;
12249|  1.09k|  }
12250|       |
12251|    734|  const bool insert_slash = !has_path;
12252|    734|  if constexpr (is_aggregator) {
12253|    734|    const size_t out_len =
12254|    734|        host_end + port_bytes + (insert_slash ? 1 : 0) + (len - authority_end);
  ------------------
  |  Branch (12254:34): [True: 143, False: 591]
  ------------------
12255|    734|    const bool omit_port_bytes = parsed_port == url_components::omitted;
12256|    734|    if (out_len == len && !insert_slash && !omit_port_bytes) {
  ------------------
  |  Branch (12256:9): [True: 605, False: 129]
  |  Branch (12256:27): [True: 550, False: 55]
  |  Branch (12256:44): [True: 550, False: 0]
  ------------------
12257|    550|      out.buffer.assign(input);
12258|    550|    } else {
12259|    184|      out.buffer.clear();
12260|    184|      out.buffer.reserve(out_len);
12261|    184|      out.buffer.append(input.substr(0, host_end));
12262|    184|      if (parsed_port != url_components::omitted) {
  ------------------
  |  Branch (12262:11): [True: 88, False: 96]
  ------------------
12263|     88|        append_canonical_port(out.buffer, parsed_port);
12264|     88|      }
12265|    184|      if (insert_slash) {
  ------------------
  |  Branch (12265:11): [True: 143, False: 41]
  ------------------
12266|    143|        out.buffer.push_back('/');
12267|    143|      }
12268|    184|      if (authority_end < len) {
  ------------------
  |  Branch (12268:11): [True: 112, False: 72]
  ------------------
12269|    112|        out.buffer.append(input.substr(authority_end));
12270|    112|      }
12271|    184|    }
12272|    734|    if (has_upper) {
  ------------------
  |  Branch (12272:9): [True: 94, False: 640]
  ------------------
12273|     94|      unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12274|     94|    }
12275|    734|    const uint32_t pathname_start =
12276|    734|        static_cast<uint32_t>(host_end) + port_bytes;
12277|    734|    const int32_t tail_delta = static_cast<int32_t>(pathname_start) +
12278|    734|                               (insert_slash ? 1 : 0) -
  ------------------
  |  Branch (12278:33): [True: 143, False: 591]
  ------------------
12279|    734|                               static_cast<int32_t>(authority_end);
12280|    734|    out.components.protocol_end = protocol_end;
12281|    734|    out.components.username_end = protocol_end + 2;
12282|    734|    out.components.host_start = protocol_end + 2;
12283|    734|    out.components.host_end = static_cast<uint32_t>(host_end);
12284|    734|    out.components.port = parsed_port;
12285|    734|    out.components.pathname_start = pathname_start;
12286|    734|    out.components.search_start =
12287|    734|        (query_start != std::string_view::npos)
  ------------------
  |  Branch (12287:9): [True: 182, False: 552]
  ------------------
12288|    734|            ? static_cast<uint32_t>(static_cast<int32_t>(query_start) +
12289|    182|                                    tail_delta)
12290|    734|            : url_components::omitted;
12291|    734|    out.components.hash_start =
12292|    734|        (hash_start != std::string_view::npos)
  ------------------
  |  Branch (12292:9): [True: 172, False: 562]
  ------------------
12293|    734|            ? static_cast<uint32_t>(static_cast<int32_t>(hash_start) +
12294|    172|                                    tail_delta)
12295|    734|            : url_components::omitted;
12296|       |  } else {
12297|       |    std::string host_str(input.substr(host_start, host_len));
12298|       |    if (has_upper) {
12299|       |      unicode::to_lower_ascii(host_str.data(), host_str.size());
12300|       |    }
12301|       |    out.host = std::move(host_str);
12302|       |    if (parsed_port != url_components::omitted) {
12303|       |      out.port = static_cast<uint16_t>(parsed_port);
12304|       |    }
12305|       |    if (insert_slash) {
12306|       |      out.path = "/";
12307|       |    } else {
12308|       |      out.path.assign(input.data() + path_start, path_end - path_start);
12309|       |    }
12310|       |    if (query_start != std::string_view::npos) {
12311|       |      const size_t q_end =
12312|       |          (hash_start != std::string_view::npos) ? hash_start : len;
12313|       |      out.query.emplace(input.data() + query_start + 1,
12314|       |                        q_end - query_start - 1);
12315|       |    }
12316|       |    if (hash_start != std::string_view::npos) {
12317|       |      out.hash.emplace(input.data() + hash_start + 1, len - hash_start - 1);
12318|       |    }
12319|       |  }
12320|    734|  return true;
12321|  1.83k|}
_ZN3ada6parser25try_parse_simple_relativeINS_3urlEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERKT_RS8_:
12705|  4.45k|                                                result_type& out) {
12706|  4.45k|  constexpr bool is_ada_url = std::is_same_v<result_type, ada::url>;
12707|  4.45k|  constexpr bool is_aggregator =
12708|  4.45k|      std::is_same_v<result_type, ada::url_aggregator>;
12709|  4.45k|  static_assert(is_ada_url || is_aggregator);
12710|       |
12711|  4.45k|  if (!base.is_special() || base.type == ada::scheme::type::FILE ||
  ------------------
  |  Branch (12711:7): [True: 2.26k, False: 2.19k]
  |  Branch (12711:29): [True: 407, False: 1.78k]
  ------------------
12712|  2.76k|      base.has_opaque_path || input.empty()) {
  ------------------
  |  Branch (12712:7): [True: 0, False: 1.78k]
  |  Branch (12712:31): [True: 94, False: 1.69k]
  ------------------
12713|  2.76k|    return false;
12714|  2.76k|  }
12715|  1.69k|  const auto* b = reinterpret_cast<const uint8_t*>(input.data());
12716|  1.69k|  const size_t len = input.size();
12717|  1.69k|  const uint8_t first = b[0];
12718|  1.69k|  const bool path_relative = first != '/' && first != '?' && first != '#';
  ------------------
  |  Branch (12718:30): [True: 1.63k, False: 52]
  |  Branch (12718:46): [True: 1.54k, False: 91]
  |  Branch (12718:62): [True: 1.47k, False: 72]
  ------------------
12719|  1.69k|  if (first == '/' && len > 1 && (b[1] == '/' || b[1] == '\\')) {
  ------------------
  |  Branch (12719:7): [True: 52, False: 1.63k]
  |  Branch (12719:23): [True: 39, False: 13]
  |  Branch (12719:35): [True: 3, False: 36]
  |  Branch (12719:50): [True: 1, False: 35]
  ------------------
12720|      4|    return false;
12721|      4|  }
12722|       |  // A ':' before the first / ? # is a scheme, not a path segment.
12723|  1.68k|  if (path_relative) {
  ------------------
  |  Branch (12723:7): [True: 1.47k, False: 211]
  ------------------
12724|  1.47k|    const size_t delim = input.find_first_of("/?#:");
12725|  1.47k|    if (delim != std::string_view::npos && input[delim] == ':') {
  ------------------
  |  Branch (12725:9): [True: 1.28k, False: 187]
  |  Branch (12725:44): [True: 968, False: 321]
  ------------------
12726|    968|      return false;
12727|    968|    }
12728|  1.47k|  }
12729|       |
12730|    719|  size_t i = 0;
12731|    719|  size_t path_start = 0;
12732|    719|  size_t path_end = 0;
12733|    719|  size_t query_start = std::string_view::npos;
12734|    719|  size_t hash_start = std::string_view::npos;
12735|    719|  bool has_path = false;
12736|    719|  bool maybe_dot_segment = false;
12737|       |
12738|    719|  if (first == '/' || path_relative) {
  ------------------
  |  Branch (12738:7): [True: 48, False: 671]
  |  Branch (12738:23): [True: 508, False: 163]
  ------------------
12739|    556|    has_path = true;
12740|    556|    path_start = 0;
12741|    556|    if (first == '/') {
  ------------------
  |  Branch (12741:9): [True: 48, False: 508]
  ------------------
12742|     48|      i = 1;
12743|     48|    }
12744|    556|    scan_path_run(b, i, len, maybe_dot_segment);
12745|    556|    if (i < len) {
  ------------------
  |  Branch (12745:9): [True: 313, False: 243]
  ------------------
12746|    313|      const uint8_t cls = k_path[b[i]];
12747|    313|      if (cls == 2) {
  ------------------
  |  Branch (12747:11): [True: 131, False: 182]
  ------------------
12748|    131|        return false;
12749|    131|      }
12750|    313|    }
12751|    425|    path_end = i;
12752|    425|    if (i < len && b[i] == '?') {
  ------------------
  |  Branch (12752:9): [True: 182, False: 243]
  |  Branch (12752:20): [True: 119, False: 63]
  ------------------
12753|    119|      query_start = i;
12754|    119|      ++i;
12755|    119|      scan_query_run(b, i, len);
12756|    119|      if (i < len) {
  ------------------
  |  Branch (12756:11): [True: 91, False: 28]
  ------------------
12757|     91|        if (b[i] != '#') {
  ------------------
  |  Branch (12757:13): [True: 28, False: 63]
  ------------------
12758|     28|          return false;
12759|     28|        }
12760|     63|        hash_start = i;
12761|     63|        ++i;
12762|     63|        scan_hash_run(b, i, len);
12763|     63|        if (i < len) {
  ------------------
  |  Branch (12763:13): [True: 49, False: 14]
  ------------------
12764|     49|          return false;
12765|     49|        }
12766|     63|      }
12767|    306|    } else if (i < len && b[i] == '#') {
  ------------------
  |  Branch (12767:16): [True: 63, False: 243]
  |  Branch (12767:27): [True: 63, False: 0]
  ------------------
12768|     63|      hash_start = i;
12769|     63|      ++i;
12770|     63|      scan_hash_run(b, i, len);
12771|     63|      if (i < len) {
  ------------------
  |  Branch (12771:11): [True: 42, False: 21]
  ------------------
12772|     42|        return false;
12773|     42|      }
12774|    243|    } else if (i < len) {
  ------------------
  |  Branch (12774:16): [True: 0, False: 243]
  ------------------
12775|      0|      return false;
12776|      0|    }
12777|    425|  } else if (first == '?') {
  ------------------
  |  Branch (12777:14): [True: 91, False: 72]
  ------------------
12778|     91|    query_start = 0;
12779|     91|    i = 1;
12780|     91|    scan_query_run(b, i, len);
12781|     91|    if (i < len) {
  ------------------
  |  Branch (12781:9): [True: 74, False: 17]
  ------------------
12782|     74|      if (b[i] != '#') {
  ------------------
  |  Branch (12782:11): [True: 20, False: 54]
  ------------------
12783|     20|        return false;
12784|     20|      }
12785|     54|      hash_start = i;
12786|     54|      ++i;
12787|     54|      scan_hash_run(b, i, len);
12788|     54|      if (i < len) {
  ------------------
  |  Branch (12788:11): [True: 39, False: 15]
  ------------------
12789|     39|        return false;
12790|     39|      }
12791|     54|    }
12792|     91|  } else {
12793|     72|    hash_start = 0;
12794|     72|    i = 1;
12795|     72|    scan_hash_run(b, i, len);
12796|     72|    if (i < len) {
  ------------------
  |  Branch (12796:9): [True: 39, False: 33]
  ------------------
12797|     39|      return false;
12798|     39|    }
12799|     72|  }
12800|       |
12801|    371|  if (has_path && maybe_dot_segment) {
  ------------------
  |  Branch (12801:7): [True: 306, False: 65]
  |  Branch (12801:19): [True: 129, False: 177]
  ------------------
12802|    129|    const std::string_view path_body(input.data() + path_start,
12803|    129|                                     path_end - path_start);
12804|    129|    if (path_has_dot_segment(path_body)) {
  ------------------
  |  Branch (12804:9): [True: 112, False: 17]
  ------------------
12805|    112|      return false;
12806|    112|    }
12807|    129|  }
12808|       |
12809|    259|  out = base;
12810|    259|  out.is_valid = true;
12811|    259|  out.has_opaque_path = false;
12812|       |
12813|    259|  const size_t q_end =
12814|    259|      (hash_start != std::string_view::npos) ? hash_start : len;
  ------------------
  |  Branch (12814:7): [True: 81, False: 178]
  ------------------
12815|    259|  const bool has_query = query_start != std::string_view::npos;
12816|    259|  const bool has_hash = hash_start != std::string_view::npos;
12817|    259|  const std::string_view query =
12818|    259|      has_query ? std::string_view(input.data() + query_start + 1,
  ------------------
  |  Branch (12818:7): [True: 69, False: 190]
  ------------------
12819|     69|                                   q_end - query_start - 1)
12820|    259|                : std::string_view{};
12821|    259|  const std::string_view hash =
12822|    259|      has_hash ? std::string_view(input.data() + hash_start + 1,
  ------------------
  |  Branch (12822:7): [True: 81, False: 178]
  ------------------
12823|     81|                                  len - hash_start - 1)
12824|    259|               : std::string_view{};
12825|       |
12826|       |  if constexpr (is_aggregator) {
12827|       |    if (first == '/' || first == '?' || path_relative) {
12828|       |      out.clear_hash();
12829|       |      out.clear_search();
12830|       |    }
12831|       |    if (first == '/') {
12832|       |      out.update_base_pathname(input.substr(path_start, path_end - path_start));
12833|       |    } else if (path_relative) {
12834|       |      const std::string_view base_path = out.get_pathname();
12835|       |      const size_t slash = base_path.rfind('/');
12836|       |      const std::string_view prefix = (slash == std::string_view::npos)
12837|       |                                          ? std::string_view("/")
12838|       |                                          : base_path.substr(0, slash + 1);
12839|       |      const std::string_view rel(input.data() + path_start,
12840|       |                                 path_end - path_start);
12841|       |      std::string new_path;
12842|       |      new_path.reserve(prefix.size() + rel.size());
12843|       |      new_path.assign(prefix);
12844|       |      new_path.append(rel);
12845|       |      out.update_base_pathname(new_path);
12846|       |    }
12847|       |    if (has_query) {
12848|       |      // Do not use update_base_search: it strips a leading '?' and would
12849|       |      // collapse '??a=b' into '?a=b'.
12850|       |      out.components.search_start = static_cast<uint32_t>(out.buffer.size());
12851|       |      out.buffer += '?';
12852|       |      out.buffer.append(query);
12853|       |    }
12854|       |    if (has_hash) {
12855|       |      out.update_unencoded_base_hash(hash);
12856|       |    }
12857|    259|  } else {
12858|    259|    if (first == '/' || first == '?' || path_relative) {
  ------------------
  |  Branch (12858:9): [True: 29, False: 230]
  |  Branch (12858:25): [True: 32, False: 198]
  |  Branch (12858:41): [True: 165, False: 33]
  ------------------
12859|    226|      out.hash.reset();
12860|    226|    }
12861|    259|    if (first == '/') {
  ------------------
  |  Branch (12861:9): [True: 29, False: 230]
  ------------------
12862|     29|      out.query.reset();
12863|     29|      out.path.assign(input.substr(path_start, path_end - path_start));
12864|    230|    } else if (path_relative) {
  ------------------
  |  Branch (12864:16): [True: 165, False: 65]
  ------------------
12865|    165|      out.query.reset();
12866|    165|      const size_t slash = out.path.rfind('/');
12867|    165|      if (slash == std::string::npos) {
  ------------------
  |  Branch (12867:11): [True: 0, False: 165]
  ------------------
12868|      0|        out.path = '/';
12869|    165|      } else {
12870|    165|        out.path.resize(slash + 1);
12871|    165|      }
12872|    165|      out.path.append(input.substr(path_start, path_end - path_start));
12873|    165|    }
12874|    259|    if (has_query) {
  ------------------
  |  Branch (12874:9): [True: 69, False: 190]
  ------------------
12875|     69|      out.query.emplace(query);
12876|     69|    }
12877|    259|    if (has_hash) {
  ------------------
  |  Branch (12877:9): [True: 81, False: 178]
  ------------------
12878|     81|      out.hash.emplace(hash);
12879|     81|    }
12880|    259|  }
12881|    259|  return true;
12882|    371|}
_ZN3ada6parser25try_parse_simple_relativeINS_14url_aggregatorEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERKT_RS8_:
12705|  4.45k|                                                result_type& out) {
12706|  4.45k|  constexpr bool is_ada_url = std::is_same_v<result_type, ada::url>;
12707|  4.45k|  constexpr bool is_aggregator =
12708|  4.45k|      std::is_same_v<result_type, ada::url_aggregator>;
12709|  4.45k|  static_assert(is_ada_url || is_aggregator);
12710|       |
12711|  4.45k|  if (!base.is_special() || base.type == ada::scheme::type::FILE ||
  ------------------
  |  Branch (12711:7): [True: 2.26k, False: 2.19k]
  |  Branch (12711:29): [True: 407, False: 1.78k]
  ------------------
12712|  2.76k|      base.has_opaque_path || input.empty()) {
  ------------------
  |  Branch (12712:7): [True: 0, False: 1.78k]
  |  Branch (12712:31): [True: 94, False: 1.69k]
  ------------------
12713|  2.76k|    return false;
12714|  2.76k|  }
12715|  1.69k|  const auto* b = reinterpret_cast<const uint8_t*>(input.data());
12716|  1.69k|  const size_t len = input.size();
12717|  1.69k|  const uint8_t first = b[0];
12718|  1.69k|  const bool path_relative = first != '/' && first != '?' && first != '#';
  ------------------
  |  Branch (12718:30): [True: 1.63k, False: 52]
  |  Branch (12718:46): [True: 1.54k, False: 91]
  |  Branch (12718:62): [True: 1.47k, False: 72]
  ------------------
12719|  1.69k|  if (first == '/' && len > 1 && (b[1] == '/' || b[1] == '\\')) {
  ------------------
  |  Branch (12719:7): [True: 52, False: 1.63k]
  |  Branch (12719:23): [True: 39, False: 13]
  |  Branch (12719:35): [True: 3, False: 36]
  |  Branch (12719:50): [True: 1, False: 35]
  ------------------
12720|      4|    return false;
12721|      4|  }
12722|       |  // A ':' before the first / ? # is a scheme, not a path segment.
12723|  1.68k|  if (path_relative) {
  ------------------
  |  Branch (12723:7): [True: 1.47k, False: 211]
  ------------------
12724|  1.47k|    const size_t delim = input.find_first_of("/?#:");
12725|  1.47k|    if (delim != std::string_view::npos && input[delim] == ':') {
  ------------------
  |  Branch (12725:9): [True: 1.28k, False: 187]
  |  Branch (12725:44): [True: 968, False: 321]
  ------------------
12726|    968|      return false;
12727|    968|    }
12728|  1.47k|  }
12729|       |
12730|    719|  size_t i = 0;
12731|    719|  size_t path_start = 0;
12732|    719|  size_t path_end = 0;
12733|    719|  size_t query_start = std::string_view::npos;
12734|    719|  size_t hash_start = std::string_view::npos;
12735|    719|  bool has_path = false;
12736|    719|  bool maybe_dot_segment = false;
12737|       |
12738|    719|  if (first == '/' || path_relative) {
  ------------------
  |  Branch (12738:7): [True: 48, False: 671]
  |  Branch (12738:23): [True: 508, False: 163]
  ------------------
12739|    556|    has_path = true;
12740|    556|    path_start = 0;
12741|    556|    if (first == '/') {
  ------------------
  |  Branch (12741:9): [True: 48, False: 508]
  ------------------
12742|     48|      i = 1;
12743|     48|    }
12744|    556|    scan_path_run(b, i, len, maybe_dot_segment);
12745|    556|    if (i < len) {
  ------------------
  |  Branch (12745:9): [True: 313, False: 243]
  ------------------
12746|    313|      const uint8_t cls = k_path[b[i]];
12747|    313|      if (cls == 2) {
  ------------------
  |  Branch (12747:11): [True: 131, False: 182]
  ------------------
12748|    131|        return false;
12749|    131|      }
12750|    313|    }
12751|    425|    path_end = i;
12752|    425|    if (i < len && b[i] == '?') {
  ------------------
  |  Branch (12752:9): [True: 182, False: 243]
  |  Branch (12752:20): [True: 119, False: 63]
  ------------------
12753|    119|      query_start = i;
12754|    119|      ++i;
12755|    119|      scan_query_run(b, i, len);
12756|    119|      if (i < len) {
  ------------------
  |  Branch (12756:11): [True: 91, False: 28]
  ------------------
12757|     91|        if (b[i] != '#') {
  ------------------
  |  Branch (12757:13): [True: 28, False: 63]
  ------------------
12758|     28|          return false;
12759|     28|        }
12760|     63|        hash_start = i;
12761|     63|        ++i;
12762|     63|        scan_hash_run(b, i, len);
12763|     63|        if (i < len) {
  ------------------
  |  Branch (12763:13): [True: 49, False: 14]
  ------------------
12764|     49|          return false;
12765|     49|        }
12766|     63|      }
12767|    306|    } else if (i < len && b[i] == '#') {
  ------------------
  |  Branch (12767:16): [True: 63, False: 243]
  |  Branch (12767:27): [True: 63, False: 0]
  ------------------
12768|     63|      hash_start = i;
12769|     63|      ++i;
12770|     63|      scan_hash_run(b, i, len);
12771|     63|      if (i < len) {
  ------------------
  |  Branch (12771:11): [True: 42, False: 21]
  ------------------
12772|     42|        return false;
12773|     42|      }
12774|    243|    } else if (i < len) {
  ------------------
  |  Branch (12774:16): [True: 0, False: 243]
  ------------------
12775|      0|      return false;
12776|      0|    }
12777|    425|  } else if (first == '?') {
  ------------------
  |  Branch (12777:14): [True: 91, False: 72]
  ------------------
12778|     91|    query_start = 0;
12779|     91|    i = 1;
12780|     91|    scan_query_run(b, i, len);
12781|     91|    if (i < len) {
  ------------------
  |  Branch (12781:9): [True: 74, False: 17]
  ------------------
12782|     74|      if (b[i] != '#') {
  ------------------
  |  Branch (12782:11): [True: 20, False: 54]
  ------------------
12783|     20|        return false;
12784|     20|      }
12785|     54|      hash_start = i;
12786|     54|      ++i;
12787|     54|      scan_hash_run(b, i, len);
12788|     54|      if (i < len) {
  ------------------
  |  Branch (12788:11): [True: 39, False: 15]
  ------------------
12789|     39|        return false;
12790|     39|      }
12791|     54|    }
12792|     91|  } else {
12793|     72|    hash_start = 0;
12794|     72|    i = 1;
12795|     72|    scan_hash_run(b, i, len);
12796|     72|    if (i < len) {
  ------------------
  |  Branch (12796:9): [True: 39, False: 33]
  ------------------
12797|     39|      return false;
12798|     39|    }
12799|     72|  }
12800|       |
12801|    371|  if (has_path && maybe_dot_segment) {
  ------------------
  |  Branch (12801:7): [True: 306, False: 65]
  |  Branch (12801:19): [True: 129, False: 177]
  ------------------
12802|    129|    const std::string_view path_body(input.data() + path_start,
12803|    129|                                     path_end - path_start);
12804|    129|    if (path_has_dot_segment(path_body)) {
  ------------------
  |  Branch (12804:9): [True: 112, False: 17]
  ------------------
12805|    112|      return false;
12806|    112|    }
12807|    129|  }
12808|       |
12809|    259|  out = base;
12810|    259|  out.is_valid = true;
12811|    259|  out.has_opaque_path = false;
12812|       |
12813|    259|  const size_t q_end =
12814|    259|      (hash_start != std::string_view::npos) ? hash_start : len;
  ------------------
  |  Branch (12814:7): [True: 81, False: 178]
  ------------------
12815|    259|  const bool has_query = query_start != std::string_view::npos;
12816|    259|  const bool has_hash = hash_start != std::string_view::npos;
12817|    259|  const std::string_view query =
12818|    259|      has_query ? std::string_view(input.data() + query_start + 1,
  ------------------
  |  Branch (12818:7): [True: 69, False: 190]
  ------------------
12819|     69|                                   q_end - query_start - 1)
12820|    259|                : std::string_view{};
12821|    259|  const std::string_view hash =
12822|    259|      has_hash ? std::string_view(input.data() + hash_start + 1,
  ------------------
  |  Branch (12822:7): [True: 81, False: 178]
  ------------------
12823|     81|                                  len - hash_start - 1)
12824|    259|               : std::string_view{};
12825|       |
12826|    259|  if constexpr (is_aggregator) {
12827|    259|    if (first == '/' || first == '?' || path_relative) {
  ------------------
  |  Branch (12827:9): [True: 29, False: 230]
  |  Branch (12827:25): [True: 32, False: 198]
  |  Branch (12827:41): [True: 165, False: 33]
  ------------------
12828|    226|      out.clear_hash();
12829|    226|      out.clear_search();
12830|    226|    }
12831|    259|    if (first == '/') {
  ------------------
  |  Branch (12831:9): [True: 29, False: 230]
  ------------------
12832|     29|      out.update_base_pathname(input.substr(path_start, path_end - path_start));
12833|    230|    } else if (path_relative) {
  ------------------
  |  Branch (12833:16): [True: 165, False: 65]
  ------------------
12834|    165|      const std::string_view base_path = out.get_pathname();
12835|    165|      const size_t slash = base_path.rfind('/');
12836|    165|      const std::string_view prefix = (slash == std::string_view::npos)
  ------------------
  |  Branch (12836:39): [True: 0, False: 165]
  ------------------
12837|    165|                                          ? std::string_view("/")
12838|    165|                                          : base_path.substr(0, slash + 1);
12839|    165|      const std::string_view rel(input.data() + path_start,
12840|    165|                                 path_end - path_start);
12841|    165|      std::string new_path;
12842|    165|      new_path.reserve(prefix.size() + rel.size());
12843|    165|      new_path.assign(prefix);
12844|    165|      new_path.append(rel);
12845|    165|      out.update_base_pathname(new_path);
12846|    165|    }
12847|    259|    if (has_query) {
  ------------------
  |  Branch (12847:9): [True: 69, False: 190]
  ------------------
12848|       |      // Do not use update_base_search: it strips a leading '?' and would
12849|       |      // collapse '??a=b' into '?a=b'.
12850|     69|      out.components.search_start = static_cast<uint32_t>(out.buffer.size());
12851|     69|      out.buffer += '?';
12852|     69|      out.buffer.append(query);
12853|     69|    }
12854|    259|    if (has_hash) {
  ------------------
  |  Branch (12854:9): [True: 81, False: 178]
  ------------------
12855|     81|      out.update_unencoded_base_hash(hash);
12856|     81|    }
12857|       |  } else {
12858|       |    if (first == '/' || first == '?' || path_relative) {
12859|       |      out.hash.reset();
12860|       |    }
12861|       |    if (first == '/') {
12862|       |      out.query.reset();
12863|       |      out.path.assign(input.substr(path_start, path_end - path_start));
12864|       |    } else if (path_relative) {
12865|       |      out.query.reset();
12866|       |      const size_t slash = out.path.rfind('/');
12867|       |      if (slash == std::string::npos) {
12868|       |        out.path = '/';
12869|       |      } else {
12870|       |        out.path.resize(slash + 1);
12871|       |      }
12872|       |      out.path.append(input.substr(path_start, path_end - path_start));
12873|       |    }
12874|       |    if (has_query) {
12875|       |      out.query.emplace(query);
12876|       |    }
12877|       |    if (has_hash) {
12878|       |      out.hash.emplace(hash);
12879|       |    }
12880|       |  }
12881|    259|  return true;
12882|    371|}
_ZN3ada6parser14parse_url_implINS_3urlELb1EEET_NSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEPKS3_:
12886|  50.6k|                           const result_type* base_url) {
12887|       |  // We can specialize the implementation per type.
12888|       |  // Important: result_type_is_ada_url is evaluated at *compile time*. This
12889|       |  // means that doing if constexpr(result_type_is_ada_url) { something } else {
12890|       |  // something else } is free (at runtime). This means that ada::url_aggregator
12891|       |  // and ada::url **do not have to support the exact same API**.
12892|  50.6k|  constexpr bool result_type_is_ada_url = std::is_same_v<url, result_type>;
12893|  50.6k|  constexpr bool result_type_is_ada_url_aggregator =
12894|  50.6k|      std::is_same_v<url_aggregator, result_type>;
12895|  50.6k|  static_assert(result_type_is_ada_url ||
12896|  50.6k|                result_type_is_ada_url_aggregator);  // We don't support
12897|       |                                                     // anything else for now.
12898|       |
12899|  50.6k|  ada_log("ada::parser::parse_url('", user_input, "' [", user_input.size(),
12900|  50.6k|          " bytes],", (base_url != nullptr ? base_url->to_string() : "null"),
12901|  50.6k|          ")");
12902|       |
12903|  50.6k|  result_type url{};
12904|       |
12905|  50.6k|  const uint32_t max_input_length = ada::get_max_input_length();
12906|       |
12907|       |  // Normalization (percent-encoding, IDNA) can push the serialized URL past
12908|       |  // max_input_length even when the input fit under it. The check at the end of
12909|       |  // the state machine covers URLs that run to completion, but several states
12910|       |  // return early after appending a query or fragment, so run the same check on
12911|       |  // those exits too. Without this, a query- or fragment-terminated URL such as
12912|       |  // file://x/?<...> or https://user@x/?<...> is accepted while the equivalent
12913|       |  // https://x/?<...> that takes the absolute fast path is rejected.
12914|  50.6k|  const auto enforce_max_input_length = [&]() {
12915|  50.6k|    if constexpr (store_values) {
12916|  50.6k|      if (url.is_valid) {
12917|  50.6k|        if constexpr (result_type_is_ada_url_aggregator) {
12918|  50.6k|          if (url.buffer.size() > max_input_length) [[unlikely]] {
12919|  50.6k|            url.is_valid = false;
12920|  50.6k|          }
12921|  50.6k|        } else {
12922|  50.6k|          if (url.get_href_size() > max_input_length) [[unlikely]] {
12923|  50.6k|            url.is_valid = false;
12924|  50.6k|          }
12925|  50.6k|        }
12926|  50.6k|      }
12927|  50.6k|    }
12928|  50.6k|  };
12929|       |
12930|       |  // We refuse to parse URL strings that exceed the maximum input length.
12931|       |  // By default, this is 4GB but can be configured via
12932|       |  // ada::set_max_input_length().
12933|  50.6k|  if (user_input.size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (12933:7): [True: 0, False: 50.6k]
  ------------------
12934|      0|    url.is_valid = false;
12935|      0|  }
12936|       |  // Going forward, user_input.size() is in [0,
12937|       |  // std::numeric_limits<uint32_t>::max). If we are provided with an invalid
12938|       |  // base, or the optional_url was invalid, we must return.
12939|  50.6k|  if (base_url != nullptr) {
  ------------------
  |  Branch (12939:7): [True: 4.45k, False: 46.2k]
  ------------------
12940|  4.45k|    url.is_valid &= base_url->is_valid;
12941|  4.45k|  }
12942|  50.6k|  if (!url.is_valid) {
  ------------------
  |  Branch (12942:7): [True: 0, False: 50.6k]
  ------------------
12943|      0|    return url;
12944|      0|  }
12945|       |
12946|       |  // Simple absolute / relative fast paths (before tabs/newline scan).
12947|  50.6k|  if constexpr (store_values) {
12948|  50.6k|    bool hit_fast_path = false;
12949|  50.6k|    if (base_url == nullptr) {
  ------------------
  |  Branch (12949:9): [True: 46.2k, False: 4.45k]
  ------------------
12950|       |      // IPv4/IPv6 and userinfo miss the fast path. Skip the never_inline
12951|       |      // call so those URLs (including SetHref) do not pay for a miss.
12952|  46.2k|      const auto* p = reinterpret_cast<const uint8_t*>(user_input.data());
12953|  46.2k|      const size_t n = user_input.size();
12954|  46.2k|      size_t host_start = 0;
12955|  46.2k|      if (n >= 8 && p[4] == ':' && p[5] == '/' && p[6] == '/') {
  ------------------
  |  Branch (12955:11): [True: 18.1k, False: 28.0k]
  |  Branch (12955:21): [True: 3.26k, False: 14.8k]
  |  Branch (12955:36): [True: 2.35k, False: 902]
  |  Branch (12955:51): [True: 2.32k, False: 34]
  ------------------
12956|  2.32k|        host_start = 7;
12957|  43.9k|      } else if (n >= 9 && p[5] == ':' && p[6] == '/' && p[7] == '/') {
  ------------------
  |  Branch (12957:18): [True: 14.4k, False: 29.4k]
  |  Branch (12957:28): [True: 278, False: 14.2k]
  |  Branch (12957:43): [True: 49, False: 229]
  |  Branch (12957:58): [True: 26, False: 23]
  ------------------
12958|     26|        host_start = 8;
12959|     26|      }
12960|  46.2k|      const uint8_t host_first = host_start != 0 ? p[host_start] : 0;
  ------------------
  |  Branch (12960:34): [True: 2.35k, False: 43.8k]
  ------------------
12961|  46.2k|      const bool skip_ip =
12962|  46.2k|          host_first == '[' || (host_first >= '0' && host_first <= '9');
  ------------------
  |  Branch (12962:11): [True: 22, False: 46.2k]
  |  Branch (12962:33): [True: 1.70k, False: 44.5k]
  |  Branch (12962:54): [True: 630, False: 1.07k]
  ------------------
12963|       |      // Only scan for userinfo when the host is not an IP literal, so
12964|       |      // IPv4/IPv6 inputs skip the SIMD '@' check entirely.
12965|  46.2k|      hit_fast_path =
12966|  46.2k|          !skip_ip &&
  ------------------
  |  Branch (12966:11): [True: 45.5k, False: 652]
  ------------------
12967|  45.5k|          !(host_start != 0 && authority_has_at(p, host_start, n)) &&
  ------------------
  |  Branch (12967:13): [True: 1.69k, False: 43.8k]
  |  Branch (12967:32): [True: 13, False: 1.68k]
  ------------------
12968|  45.5k|          try_parse_simple_absolute(user_input, url);
  ------------------
  |  Branch (12968:11): [True: 5.26k, False: 40.3k]
  ------------------
12969|  46.2k|    } else {
12970|  4.45k|      hit_fast_path = try_parse_simple_relative(user_input, *base_url, url);
12971|  4.45k|    }
12972|  50.6k|    if (hit_fast_path) {
  ------------------
  |  Branch (12972:9): [True: 5.52k, False: 45.1k]
  ------------------
12973|       |      if constexpr (result_type_is_ada_url_aggregator) {
12974|       |        if (url.buffer.size() > max_input_length) [[unlikely]] {
12975|       |          url.is_valid = false;
12976|       |        }
12977|  5.52k|      } else {
12978|       |        // For a small absolute input, even worst-case normalization cannot
12979|       |        // exceed the limit: percent encoding expands at most 3x and IDNA at
12980|       |        // most 4.5x. Avoid traversing every stored component on the common
12981|       |        // default-limit path.
12982|  5.52k|        if ((base_url != nullptr ||
  ------------------
  |  Branch (12982:14): [True: 259, False: 5.26k]
  ------------------
12983|  5.26k|             user_input.size() > static_cast<size_t>(max_input_length) / 5) &&
  ------------------
  |  Branch (12983:14): [True: 0, False: 5.26k]
  ------------------
12984|    259|            url.get_href_size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (12984:13): [True: 0, False: 259]
  ------------------
12985|      0|          url.is_valid = false;
12986|      0|        }
12987|  5.52k|      }
12988|  5.52k|      return url;
12989|  5.52k|    }
12990|  50.6k|  }
12991|       |
12992|  45.1k|  state state = state::SCHEME_START;
12993|       |
12994|  50.6k|  std::string tmp_buffer;
12995|  50.6k|  std::string_view url_data;
12996|  50.6k|  if (unicode::has_tabs_or_newline(user_input)) [[unlikely]] {
  ------------------
  |  Branch (12996:7): [True: 495, False: 50.1k]
  ------------------
12997|    495|    tmp_buffer = user_input;
12998|       |    // Optimization opportunity: Instead of copying and then pruning, we could
12999|       |    // just directly build the string from user_input.
13000|    495|    helpers::remove_ascii_tab_or_newline(tmp_buffer);
13001|    495|    url_data = tmp_buffer;
13002|  50.1k|  } else [[likely]] {
13003|  50.1k|    url_data = user_input;
13004|  50.1k|  }
13005|       |
13006|       |  // Leading and trailing control characters are uncommon and easy to deal with
13007|       |  // (no performance concern).
13008|  50.6k|  helpers::trim_c0_whitespace(url_data);
13009|       |
13010|       |  if constexpr (result_type_is_ada_url_aggregator && store_values) {
13011|       |    // Most of the time, we just need user_input.size().
13012|       |    // In some instances, we may need a bit more.
13013|       |    ///////////////////////////
13014|       |    // This is *very* important. This line should *not* be removed
13015|       |    // hastily. There are principled reasons why reserve is important
13016|       |    // for performance. If you have a benchmark with small inputs,
13017|       |    // it may not matter, but in other instances, it could.
13018|       |    ////
13019|       |    // This rounds up to the next power of two.
13020|       |    // We know that user_input.size() is in [0,
13021|       |    // std::numeric_limits<uint32_t>::max).
13022|       |    uint32_t reserve_capacity =
13023|       |        (0xFFFFFFFF >>
13024|       |         helpers::leading_zeroes(uint32_t(1 | user_input.size()))) +
13025|       |        1;
13026|       |    url.reserve(reserve_capacity);
13027|       |  }
13028|       |
13029|       |  // Optimization opportunity. Most websites do not have fragment.
13030|  50.6k|  std::optional<std::string_view> fragment = helpers::prune_hash(url_data);
13031|       |  // We add it last so that an implementation like ada::url_aggregator
13032|       |  // can append it last to its internal buffer, thus improving performance.
13033|       |
13034|       |  // Here url_data no longer has its fragment.
13035|       |  // We are going to access the data from url_data (it is immutable).
13036|       |  // At any given time, we are pointing at byte 'input_position' in url_data.
13037|       |  // The input_position variable should range from 0 to input_size.
13038|       |  // It is illegal to access url_data at input_size.
13039|  50.6k|  size_t input_position = 0;
13040|  50.6k|  const size_t input_size = url_data.size();
13041|       |  // Keep running the following state machine by switching on state.
13042|       |  // If after a run pointer points to the EOF code point, go to the next step.
13043|       |  // Otherwise, increase pointer by 1 and continue with the state machine.
13044|       |  // We never decrement input_position.
13045|   186k|  while (input_position <= input_size) {
  ------------------
  |  Branch (13045:10): [True: 169k, False: 17.0k]
  ------------------
13046|   169k|    ada_log("In parsing at ", input_position, " out of ", input_size,
13047|   169k|            " in state ", ada::to_string(state));
13048|   169k|    switch (state) {
13049|  45.1k|      case state::SCHEME_START: {
  ------------------
  |  Branch (13049:7): [True: 45.1k, False: 124k]
  ------------------
13050|  45.1k|        ada_log("SCHEME_START ", helpers::substring(url_data, input_position));
13051|       |        // If c is an ASCII alpha, append c, lowercased, to buffer, and set
13052|       |        // state to scheme state.
13053|  45.1k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13053:13): [True: 23.7k, False: 21.4k]
  ------------------
13054|  23.7k|            checkers::is_alpha(url_data[input_position])) {
  ------------------
  |  Branch (13054:13): [True: 22.2k, False: 1.52k]
  ------------------
13055|  22.2k|          state = state::SCHEME;
13056|  22.2k|          input_position++;
13057|  22.9k|        } else {
13058|       |          // Otherwise, if state override is not given, set state to no scheme
13059|       |          // state and decrease pointer by 1.
13060|  22.9k|          state = state::NO_SCHEME;
13061|  22.9k|        }
13062|  45.1k|        break;
13063|      0|      }
13064|  22.2k|      case state::SCHEME: {
  ------------------
  |  Branch (13064:7): [True: 22.2k, False: 147k]
  ------------------
13065|  22.2k|        ada_log("SCHEME ", helpers::substring(url_data, input_position));
13066|       |        // If c is an ASCII alphanumeric, U+002B (+), U+002D (-), or U+002E (.),
13067|       |        // append c, lowercased, to buffer.
13068|  54.5k|        while ((input_position != input_size) &&
  ------------------
  |  Branch (13068:16): [True: 54.1k, False: 323]
  ------------------
13069|  54.1k|               (unicode::is_alnum_plus(url_data[input_position]))) {
  ------------------
  |  Branch (13069:16): [True: 32.2k, False: 21.9k]
  ------------------
13070|  32.2k|          input_position++;
13071|  32.2k|        }
13072|       |        // Otherwise, if c is U+003A (:), then:
13073|  22.2k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13073:13): [True: 21.9k, False: 323]
  ------------------
13074|  21.9k|            (url_data[input_position] == ':')) {
  ------------------
  |  Branch (13074:13): [True: 21.4k, False: 467]
  ------------------
13075|  21.4k|          ada_log("SCHEME the scheme should be ",
13076|  21.4k|                  url_data.substr(0, input_position));
13077|  21.4k|          if constexpr (result_type_is_ada_url) {
13078|  21.4k|            if (!url.parse_scheme(url_data.substr(0, input_position))) {
  ------------------
  |  Branch (13078:17): [True: 0, False: 21.4k]
  ------------------
13079|      0|              return url;
13080|      0|            }
13081|       |          } else {
13082|       |            // we pass the colon along instead of painfully adding it back.
13083|       |            if (!url.parse_scheme_with_colon(
13084|       |                    url_data.substr(0, input_position + 1))) {
13085|       |              return url;
13086|       |            }
13087|       |          }
13088|  21.4k|          ada_log("SCHEME the scheme is ", url.get_protocol());
13089|       |
13090|       |          // If url's scheme is "file", then:
13091|       |          // NOLINTNEXTLINE(bugprone-branch-clone)
13092|  21.4k|          if (url.type == scheme::type::FILE) {
  ------------------
  |  Branch (13092:15): [True: 2.68k, False: 18.7k]
  ------------------
13093|       |            // Set state to file state.
13094|  2.68k|            state = state::FILE;
13095|  2.68k|          }
13096|       |          // Otherwise, if url is special, base is non-null, and base's scheme
13097|       |          // is url's scheme: Note: Doing base_url->scheme is unsafe if base_url
13098|       |          // != nullptr is false.
13099|  18.7k|          else if (url.is_special() && base_url != nullptr &&
  ------------------
  |  Branch (13099:20): [True: 13.2k, False: 5.46k]
  |  Branch (13099:40): [True: 2.22k, False: 11.0k]
  ------------------
13100|  2.22k|                   base_url->type == url.type) {
  ------------------
  |  Branch (13100:20): [True: 448, False: 1.77k]
  ------------------
13101|       |            // Set state to special relative or authority state.
13102|    448|            state = state::SPECIAL_RELATIVE_OR_AUTHORITY;
13103|    448|          }
13104|       |          // Otherwise, if url is special, set state to special authority
13105|       |          // slashes state.
13106|  18.3k|          else if (url.is_special()) {
  ------------------
  |  Branch (13106:20): [True: 12.8k, False: 5.46k]
  ------------------
13107|  12.8k|            state = state::SPECIAL_AUTHORITY_SLASHES;
13108|  12.8k|          }
13109|       |          // Otherwise, if remaining starts with an U+002F (/), set state to
13110|       |          // path or authority state and increase pointer by 1.
13111|  5.46k|          else if (input_position + 1 < input_size &&
  ------------------
  |  Branch (13111:20): [True: 3.20k, False: 2.26k]
  ------------------
13112|  3.20k|                   url_data[input_position + 1] == '/') {
  ------------------
  |  Branch (13112:20): [True: 2.24k, False: 961]
  ------------------
13113|  2.24k|            state = state::PATH_OR_AUTHORITY;
13114|  2.24k|            input_position++;
13115|  2.24k|          }
13116|       |          // Otherwise, set url's path to the empty string and set state to
13117|       |          // opaque path state.
13118|  3.22k|          else {
13119|  3.22k|            state = state::OPAQUE_PATH;
13120|  3.22k|          }
13121|  21.4k|        }
13122|       |        // Otherwise, if state override is not given, set buffer to the empty
13123|       |        // string, state to no scheme state, and start over (from the first code
13124|       |        // point in input).
13125|    790|        else {
13126|    790|          state = state::NO_SCHEME;
13127|    790|          input_position = 0;
13128|    790|          break;
13129|    790|        }
13130|  21.4k|        input_position++;
13131|  21.4k|        break;
13132|  22.2k|      }
13133|  23.7k|      case state::NO_SCHEME: {
  ------------------
  |  Branch (13133:7): [True: 23.7k, False: 145k]
  ------------------
13134|  23.7k|        ada_log("NO_SCHEME ", helpers::substring(url_data, input_position));
13135|       |        // The fragment was pruned from url_data before the state machine ran,
13136|       |        // so 'c is U+0023 (#)' holds exactly when a fragment was found and
13137|       |        // nothing else remains in front of it.
13138|  23.7k|        const bool c_is_hash =
13139|  23.7k|            fragment.has_value() && input_position == input_size;
  ------------------
  |  Branch (13139:13): [True: 585, False: 23.1k]
  |  Branch (13139:37): [True: 228, False: 357]
  ------------------
13140|       |        // If base is null, or base has an opaque path and c is not U+0023 (#),
13141|       |        // validation error, return failure.
13142|  23.7k|        if (base_url == nullptr || (base_url->has_opaque_path && !c_is_hash)) {
  ------------------
  |  Branch (13142:13): [True: 22.5k, False: 1.14k]
  |  Branch (13142:37): [True: 101, False: 1.04k]
  |  Branch (13142:66): [True: 46, False: 55]
  ------------------
13143|  22.6k|          ada_log("NO_SCHEME validation error");
13144|  22.6k|          url.is_valid = false;
13145|  22.6k|          return url;
13146|  22.6k|        }
13147|       |        // Otherwise, if base has an opaque path and c is U+0023 (#),
13148|       |        // set url's scheme to base's scheme, url's path to base's path, url's
13149|       |        // query to base's query, and set state to fragment state.
13150|  1.09k|        else if (base_url->has_opaque_path && c_is_hash) {
  ------------------
  |  Branch (13150:18): [True: 55, False: 1.04k]
  |  Branch (13150:47): [True: 55, False: 0]
  ------------------
13151|     55|          ada_log("NO_SCHEME opaque base with fragment");
13152|     55|          url.copy_scheme(*base_url);
13153|     55|          url.has_opaque_path = base_url->has_opaque_path;
13154|       |
13155|     55|          if constexpr (result_type_is_ada_url) {
13156|     55|            url.path = base_url->path;
13157|     55|            url.query = base_url->query;
13158|       |          } else {
13159|       |            url.update_base_pathname(base_url->get_pathname());
13160|       |            if (base_url->has_search()) {
13161|       |              // get_search() returns "" for an empty query string (URL ends
13162|       |              // with '?'). update_base_search("") would incorrectly clear the
13163|       |              // query, so pass "?" to preserve the empty query distinction.
13164|       |              auto s = base_url->get_search();
13165|       |              url.update_base_search(s.empty() ? std::string_view("?") : s);
13166|       |            }
13167|       |          }
13168|     55|          url.update_unencoded_base_hash(*fragment);
13169|     55|          enforce_max_input_length();
13170|     55|          return url;
13171|     55|        }
13172|       |        // Otherwise, if base's scheme is not "file", set state to relative
13173|       |        // state and decrease pointer by 1.
13174|       |        // NOLINTNEXTLINE(bugprone-branch-clone)
13175|  1.04k|        else if (base_url->type != scheme::type::FILE) {
  ------------------
  |  Branch (13175:18): [True: 777, False: 264]
  ------------------
13176|    777|          ada_log("NO_SCHEME non-file relative path");
13177|    777|          state = state::RELATIVE_SCHEME;
13178|    777|        }
13179|       |        // Otherwise, set state to file state and decrease pointer by 1.
13180|    264|        else {
13181|    264|          ada_log("NO_SCHEME file base type");
13182|    264|          state = state::FILE;
13183|    264|        }
13184|  1.04k|        break;
13185|  23.7k|      }
13186|  14.1k|      case state::AUTHORITY: {
  ------------------
  |  Branch (13186:7): [True: 14.1k, False: 155k]
  ------------------
13187|  14.1k|        ada_log("AUTHORITY ", helpers::substring(url_data, input_position));
13188|       |        // most URLs have no @. Having no @ tells us that we don't have to worry
13189|       |        // about AUTHORITY. Of course, we could have @ and still not have to
13190|       |        // worry about AUTHORITY.
13191|       |        // TODO: Instead of just collecting a bool, collect the location of the
13192|       |        // '@' and do something useful with it.
13193|       |        // TODO: We could do various processing early on, using a single pass
13194|       |        // over the string to collect information about it, e.g., telling us
13195|       |        // whether there is a @ and if so, where (or how many).
13196|       |
13197|       |        // Check if url data contains an @.
13198|  14.1k|        if (url_data.find('@', input_position) == std::string_view::npos) {
  ------------------
  |  Branch (13198:13): [True: 12.8k, False: 1.25k]
  ------------------
13199|  12.8k|          state = state::HOST;
13200|  12.8k|          break;
13201|  12.8k|        }
13202|  1.25k|        bool at_sign_seen{false};
13203|  1.25k|        bool password_token_seen{false};
13204|       |        /**
13205|       |         * We expect something of the sort...
13206|       |         * https://user:pass@example.com:1234/foo/bar?baz#quux
13207|       |         * --------^
13208|       |         */
13209|  8.18k|        do {
13210|  8.18k|          std::string_view view = url_data.substr(input_position);
13211|       |          // The delimiters are @, /, ? \\.
13212|  8.18k|          size_t location =
13213|  8.18k|              url.is_special() ? helpers::find_authority_delimiter_special(view)
  ------------------
  |  Branch (13213:15): [True: 7.23k, False: 955]
  ------------------
13214|  8.18k|                               : helpers::find_authority_delimiter(view);
13215|  8.18k|          std::string_view authority_view = view.substr(0, location);
13216|  8.18k|          size_t end_of_authority = input_position + authority_view.size();
13217|       |          // If c is U+0040 (@), then:
13218|  8.18k|          if ((end_of_authority != input_size) &&
  ------------------
  |  Branch (13218:15): [True: 7.37k, False: 812]
  ------------------
13219|  7.37k|              (url_data[end_of_authority] == '@')) {
  ------------------
  |  Branch (13219:15): [True: 6.92k, False: 447]
  ------------------
13220|       |            // If atSignSeen is true, then prepend "%40" to buffer.
13221|  6.92k|            if (at_sign_seen) {
  ------------------
  |  Branch (13221:17): [True: 5.81k, False: 1.10k]
  ------------------
13222|  5.81k|              if (password_token_seen) {
  ------------------
  |  Branch (13222:19): [True: 2.47k, False: 3.34k]
  ------------------
13223|  2.47k|                if constexpr (result_type_is_ada_url) {
13224|  2.47k|                  url.password += "%40";
13225|       |                } else {
13226|       |                  url.append_base_password("%40");
13227|       |                }
13228|  3.34k|              } else {
13229|  3.34k|                if constexpr (result_type_is_ada_url) {
13230|  3.34k|                  url.username += "%40";
13231|       |                } else {
13232|       |                  url.append_base_username("%40");
13233|       |                }
13234|  3.34k|              }
13235|  5.81k|            }
13236|       |
13237|  6.92k|            at_sign_seen = true;
13238|       |
13239|  6.92k|            if (!password_token_seen) {
  ------------------
  |  Branch (13239:17): [True: 4.45k, False: 2.47k]
  ------------------
13240|  4.45k|              size_t password_token_location = authority_view.find(':');
13241|  4.45k|              password_token_seen =
13242|  4.45k|                  password_token_location != std::string_view::npos;
13243|       |
13244|  4.45k|              if constexpr (store_values) {
13245|  4.45k|                if (!password_token_seen) {
  ------------------
  |  Branch (13245:21): [True: 4.03k, False: 426]
  ------------------
13246|  4.03k|                  if constexpr (result_type_is_ada_url) {
13247|  4.03k|                    url.username += unicode::percent_encode(
13248|  4.03k|                        authority_view,
13249|  4.03k|                        character_sets::USERINFO_PERCENT_ENCODE);
13250|       |                  } else {
13251|       |                    url.append_base_username(unicode::percent_encode(
13252|       |                        authority_view,
13253|       |                        character_sets::USERINFO_PERCENT_ENCODE));
13254|       |                  }
13255|  4.03k|                } else {
13256|    426|                  if constexpr (result_type_is_ada_url) {
13257|    426|                    url.username += unicode::percent_encode(
13258|    426|                        authority_view.substr(0, password_token_location),
13259|    426|                        character_sets::USERINFO_PERCENT_ENCODE);
13260|    426|                    url.password += unicode::percent_encode(
13261|    426|                        authority_view.substr(password_token_location + 1),
13262|    426|                        character_sets::USERINFO_PERCENT_ENCODE);
13263|       |                  } else {
13264|       |                    url.append_base_username(unicode::percent_encode(
13265|       |                        authority_view.substr(0, password_token_location),
13266|       |                        character_sets::USERINFO_PERCENT_ENCODE));
13267|       |                    url.append_base_password(unicode::percent_encode(
13268|       |                        authority_view.substr(password_token_location + 1),
13269|       |                        character_sets::USERINFO_PERCENT_ENCODE));
13270|       |                  }
13271|    426|                }
13272|  4.45k|              }
13273|  4.45k|            } else if constexpr (store_values) {
13274|  2.47k|              if constexpr (result_type_is_ada_url) {
13275|  2.47k|                url.password += unicode::percent_encode(
13276|  2.47k|                    authority_view, character_sets::USERINFO_PERCENT_ENCODE);
13277|       |              } else {
13278|       |                url.append_base_password(unicode::percent_encode(
13279|       |                    authority_view, character_sets::USERINFO_PERCENT_ENCODE));
13280|       |              }
13281|  2.47k|            }
13282|  6.92k|          }
13283|       |          // Otherwise, if one of the following is true:
13284|       |          // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
13285|       |          // - url is special and c is U+005C (\)
13286|  1.25k|          else if (end_of_authority == input_size ||
  ------------------
  |  Branch (13286:20): [True: 812, False: 447]
  ------------------
13287|    447|                   url_data[end_of_authority] == '/' ||
  ------------------
  |  Branch (13287:20): [True: 408, False: 39]
  ------------------
13288|     39|                   url_data[end_of_authority] == '?' ||
  ------------------
  |  Branch (13288:20): [True: 33, False: 6]
  ------------------
13289|  1.25k|                   (url.is_special() && url_data[end_of_authority] == '\\')) {
  ------------------
  |  Branch (13289:21): [True: 6, False: 0]
  |  Branch (13289:41): [True: 6, False: 0]
  ------------------
13290|       |            // If atSignSeen is true and authority_view is the empty string,
13291|       |            // validation error, return failure.
13292|  1.25k|            if (at_sign_seen && authority_view.empty()) {
  ------------------
  |  Branch (13292:17): [True: 1.10k, False: 150]
  |  Branch (13292:33): [True: 350, False: 759]
  ------------------
13293|    350|              url.is_valid = false;
13294|    350|              return url;
13295|    350|            }
13296|    909|            state = state::HOST;
13297|    909|            break;
13298|  1.25k|          }
13299|  6.92k|          if (end_of_authority == input_size) {
  ------------------
  |  Branch (13299:15): [True: 0, False: 6.92k]
  ------------------
13300|      0|            if constexpr (store_values) {
13301|      0|              if (fragment.has_value()) {
  ------------------
  |  Branch (13301:19): [True: 0, False: 0]
  ------------------
13302|      0|                url.update_unencoded_base_hash(*fragment);
13303|      0|              }
13304|      0|            }
13305|      0|            enforce_max_input_length();
13306|      0|            return url;
13307|      0|          }
13308|  6.92k|          input_position = end_of_authority + 1;
13309|  6.92k|        } while (true);
  ------------------
  |  Branch (13309:18): [True: 6.92k, Folded]
  ------------------
13310|       |
13311|    909|        break;
13312|  1.25k|      }
13313|    909|      case state::SPECIAL_RELATIVE_OR_AUTHORITY: {
  ------------------
  |  Branch (13313:7): [True: 448, False: 168k]
  ------------------
13314|    448|        ada_log("SPECIAL_RELATIVE_OR_AUTHORITY ",
13315|    448|                helpers::substring(url_data, input_position));
13316|       |
13317|       |        // If c is U+002F (/) and remaining starts with U+002F (/),
13318|       |        // then set state to special authority ignore slashes state and increase
13319|       |        // pointer by 1.
13320|    448|        if (url_data.substr(input_position, 2) == "//") {
  ------------------
  |  Branch (13320:13): [True: 360, False: 88]
  ------------------
13321|    360|          state = state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
13322|    360|          input_position += 2;
13323|    360|        } else {
13324|       |          // Otherwise, validation error, set state to relative state and
13325|       |          // decrease pointer by 1.
13326|     88|          state = state::RELATIVE_SCHEME;
13327|     88|        }
13328|       |
13329|    448|        break;
13330|  1.25k|      }
13331|  2.24k|      case state::PATH_OR_AUTHORITY: {
  ------------------
  |  Branch (13331:7): [True: 2.24k, False: 167k]
  ------------------
13332|  2.24k|        ada_log("PATH_OR_AUTHORITY ",
13333|  2.24k|                helpers::substring(url_data, input_position));
13334|       |
13335|       |        // If c is U+002F (/), then set state to authority state.
13336|  2.24k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13336:13): [True: 2.10k, False: 133]
  ------------------
13337|  2.10k|            (url_data[input_position] == '/')) {
  ------------------
  |  Branch (13337:13): [True: 914, False: 1.19k]
  ------------------
13338|    914|          state = state::AUTHORITY;
13339|    914|          input_position++;
13340|  1.32k|        } else {
13341|       |          // Otherwise, set state to path state, and decrease pointer by 1.
13342|  1.32k|          state = state::PATH;
13343|  1.32k|        }
13344|       |
13345|  2.24k|        break;
13346|  1.25k|      }
13347|    865|      case state::RELATIVE_SCHEME: {
  ------------------
  |  Branch (13347:7): [True: 865, False: 168k]
  ------------------
13348|    865|        ada_log("RELATIVE_SCHEME ",
13349|    865|                helpers::substring(url_data, input_position));
13350|       |
13351|       |        // Set url's scheme to base's scheme.
13352|    865|        url.copy_scheme(*base_url);
13353|       |
13354|       |        // If c is U+002F (/), then set state to relative slash state.
13355|    865|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13355:13): [True: 689, False: 176]
  ------------------
13356|       |            // NOLINTNEXTLINE(bugprone-branch-clone)
13357|    689|            (url_data[input_position] == '/')) {
  ------------------
  |  Branch (13357:13): [True: 67, False: 622]
  ------------------
13358|     67|          ada_log(
13359|     67|              "RELATIVE_SCHEME if c is U+002F (/), then set state to relative "
13360|     67|              "slash state");
13361|     67|          state = state::RELATIVE_SLASH;
13362|    798|        } else if (url.is_special() && (input_position != input_size) &&
  ------------------
  |  Branch (13362:20): [True: 647, False: 151]
  |  Branch (13362:40): [True: 508, False: 139]
  ------------------
13363|    508|                   (url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13363:20): [True: 2, False: 506]
  ------------------
13364|       |          // Otherwise, if url is special and c is U+005C (\), validation error,
13365|       |          // set state to relative slash state.
13366|      2|          ada_log(
13367|      2|              "RELATIVE_SCHEME  if url is special and c is U+005C, validation "
13368|      2|              "error, set state to relative slash state");
13369|      2|          state = state::RELATIVE_SLASH;
13370|    796|        } else {
13371|    796|          ada_log("RELATIVE_SCHEME otherwise");
13372|       |          // Set url's username to base's username, url's password to base's
13373|       |          // password, url's host to base's host, url's port to base's port,
13374|       |          // url's path to a clone of base's path, and url's query to base's
13375|       |          // query.
13376|    796|          if constexpr (result_type_is_ada_url) {
13377|    796|            url.username = base_url->username;
13378|    796|            url.password = base_url->password;
13379|    796|            url.host = base_url->host;
13380|    796|            url.port = base_url->port;
13381|       |            // cloning the base path includes cloning the has_opaque_path flag
13382|    796|            url.has_opaque_path = base_url->has_opaque_path;
13383|    796|            url.path = base_url->path;
13384|    796|            url.query = base_url->query;
13385|       |          } else {
13386|       |            url.update_base_authority(base_url->get_href(),
13387|       |                                      base_url->get_components());
13388|       |            url.update_host_to_base_host(base_url->get_hostname());
13389|       |            url.update_base_port(base_url->retrieve_base_port());
13390|       |            // cloning the base path includes cloning the has_opaque_path flag
13391|       |            url.has_opaque_path = base_url->has_opaque_path;
13392|       |            url.update_base_pathname(base_url->get_pathname());
13393|       |            if (base_url->has_search()) {
13394|       |              // get_search() returns "" for an empty query string (URL ends
13395|       |              // with '?'). update_base_search("") would incorrectly clear the
13396|       |              // query, so pass "?" to preserve the empty query distinction.
13397|       |              auto s = base_url->get_search();
13398|       |              url.update_base_search(s.empty() ? std::string_view("?") : s);
13399|       |            }
13400|       |          }
13401|       |
13402|    796|          url.has_opaque_path = base_url->has_opaque_path;
13403|       |
13404|       |          // If c is U+003F (?), then set url's query to the empty string, and
13405|       |          // state to query state.
13406|    796|          if ((input_position != input_size) &&
  ------------------
  |  Branch (13406:15): [True: 620, False: 176]
  ------------------
13407|    620|              (url_data[input_position] == '?')) {
  ------------------
  |  Branch (13407:15): [True: 73, False: 547]
  ------------------
13408|     73|            state = state::QUERY;
13409|     73|          }
13410|       |          // Otherwise, if c is not the EOF code point:
13411|    723|          else if (input_position != input_size) {
  ------------------
  |  Branch (13411:20): [True: 547, False: 176]
  ------------------
13412|       |            // Set url's query to null.
13413|    547|            url.clear_search();
13414|    547|            if constexpr (result_type_is_ada_url) {
13415|       |              // Shorten url's path.
13416|    547|              helpers::shorten_path(url.path, url.type);
13417|       |            } else {
13418|       |              std::string_view path = url.get_pathname();
13419|       |              if (helpers::shorten_path(path, url.type)) {
13420|       |                url.update_base_pathname(std::move(std::string(path)));
13421|       |              }
13422|       |            }
13423|       |            // Set state to path state and decrease pointer by 1.
13424|    547|            state = state::PATH;
13425|    547|            break;
13426|    547|          }
13427|    796|        }
13428|    318|        input_position++;
13429|    318|        break;
13430|    865|      }
13431|     69|      case state::RELATIVE_SLASH: {
  ------------------
  |  Branch (13431:7): [True: 69, False: 169k]
  ------------------
13432|     69|        ada_log("RELATIVE_SLASH ",
13433|     69|                helpers::substring(url_data, input_position));
13434|       |
13435|       |        // If url is special and c is U+002F (/) or U+005C (\), then:
13436|       |        // NOLINTNEXTLINE(bugprone-branch-clone)
13437|     69|        if (url.is_special() && (input_position != input_size) &&
  ------------------
  |  Branch (13437:13): [True: 48, False: 21]
  |  Branch (13437:33): [True: 33, False: 15]
  ------------------
13438|     33|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13438:14): [True: 3, False: 30]
  ------------------
13439|     30|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13439:14): [True: 2, False: 28]
  ------------------
13440|       |          // Set state to special authority ignore slashes state.
13441|      5|          state = state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
13442|      5|        }
13443|       |        // Otherwise, if c is U+002F (/), then set state to authority state.
13444|     64|        else if ((input_position != input_size) &&
  ------------------
  |  Branch (13444:18): [True: 43, False: 21]
  ------------------
13445|     43|                 (url_data[input_position] == '/')) {
  ------------------
  |  Branch (13445:18): [True: 5, False: 38]
  ------------------
13446|      5|          state = state::AUTHORITY;
13447|      5|        }
13448|       |        // Otherwise, set
13449|       |        // - url's username to base's username,
13450|       |        // - url's password to base's password,
13451|       |        // - url's host to base's host,
13452|       |        // - url's port to base's port,
13453|       |        // - state to path state, and then, decrease pointer by 1.
13454|     59|        else {
13455|     59|          if constexpr (result_type_is_ada_url) {
13456|     59|            url.username = base_url->username;
13457|     59|            url.password = base_url->password;
13458|     59|            url.host = base_url->host;
13459|     59|            url.port = base_url->port;
13460|       |          } else {
13461|       |            url.update_base_authority(base_url->get_href(),
13462|       |                                      base_url->get_components());
13463|       |            url.update_host_to_base_host(base_url->get_hostname());
13464|       |            url.update_base_port(base_url->retrieve_base_port());
13465|       |          }
13466|     59|          state = state::PATH;
13467|     59|          break;
13468|     59|        }
13469|       |
13470|     10|        input_position++;
13471|     10|        break;
13472|     69|      }
13473|  12.8k|      case state::SPECIAL_AUTHORITY_SLASHES: {
  ------------------
  |  Branch (13473:7): [True: 12.8k, False: 156k]
  ------------------
13474|  12.8k|        ada_log("SPECIAL_AUTHORITY_SLASHES ",
13475|  12.8k|                helpers::substring(url_data, input_position));
13476|       |
13477|       |        // If c is U+002F (/) and remaining starts with U+002F (/),
13478|       |        // then set state to special authority ignore slashes state and increase
13479|       |        // pointer by 1.
13480|  12.8k|        if (url_data.substr(input_position, 2) == "//") {
  ------------------
  |  Branch (13480:13): [True: 3.31k, False: 9.52k]
  ------------------
13481|  3.31k|          input_position += 2;
13482|  3.31k|        }
13483|       |
13484|  12.8k|        [[fallthrough]];
13485|  12.8k|      }
13486|  13.2k|      case state::SPECIAL_AUTHORITY_IGNORE_SLASHES: {
  ------------------
  |  Branch (13486:7): [True: 365, False: 168k]
  ------------------
13487|  13.2k|        ada_log("SPECIAL_AUTHORITY_IGNORE_SLASHES ",
13488|  13.2k|                helpers::substring(url_data, input_position));
13489|       |
13490|       |        // If c is neither U+002F (/) nor U+005C (\), then set state to
13491|       |        // authority state and decrease pointer by 1.
13492|  14.1k|        while ((input_position != input_size) &&
  ------------------
  |  Branch (13492:16): [True: 14.0k, False: 95]
  ------------------
13493|  14.0k|               ((url_data[input_position] == '/') ||
  ------------------
  |  Branch (13493:17): [True: 560, False: 13.5k]
  ------------------
13494|  13.5k|                (url_data[input_position] == '\\'))) {
  ------------------
  |  Branch (13494:17): [True: 409, False: 13.1k]
  ------------------
13495|    969|          input_position++;
13496|    969|        }
13497|  13.2k|        state = state::AUTHORITY;
13498|       |
13499|  13.2k|        break;
13500|  12.8k|      }
13501|  1.24k|      case state::QUERY: {
  ------------------
  |  Branch (13501:7): [True: 1.24k, False: 168k]
  ------------------
13502|  1.24k|        ada_log("QUERY ", helpers::substring(url_data, input_position));
13503|  1.24k|        if constexpr (store_values) {
13504|       |          // Let queryPercentEncodeSet be the special-query percent-encode set
13505|       |          // if url is special; otherwise the query percent-encode set.
13506|  1.24k|          const uint8_t* query_percent_encode_set =
13507|  1.24k|              url.is_special() ? character_sets::SPECIAL_QUERY_PERCENT_ENCODE
  ------------------
  |  Branch (13507:15): [True: 849, False: 400]
  ------------------
13508|  1.24k|                               : character_sets::QUERY_PERCENT_ENCODE;
13509|       |
13510|       |          // Percent-encode after encoding, with encoding, buffer, and
13511|       |          // queryPercentEncodeSet, and append the result to url's query.
13512|  1.24k|          url.update_base_search(url_data.substr(input_position),
13513|  1.24k|                                 query_percent_encode_set);
13514|  1.24k|          ada_log("QUERY update_base_search completed ");
13515|  1.24k|          if (fragment.has_value()) {
  ------------------
  |  Branch (13515:15): [True: 350, False: 899]
  ------------------
13516|    350|            url.update_unencoded_base_hash(*fragment);
13517|    350|          }
13518|  1.24k|        }
13519|  1.24k|        enforce_max_input_length();
13520|  1.24k|        return url;
13521|  12.8k|      }
13522|  13.7k|      case state::HOST: {
  ------------------
  |  Branch (13522:7): [True: 13.7k, False: 155k]
  ------------------
13523|  13.7k|        ada_log("HOST ", helpers::substring(url_data, input_position));
13524|       |
13525|  13.7k|        std::string_view host_view = url_data.substr(input_position);
13526|  13.7k|        auto [location, found_colon] =
13527|  13.7k|            helpers::get_host_delimiter_location(url.is_special(), host_view);
13528|  13.7k|        input_position = (location != std::string_view::npos)
  ------------------
  |  Branch (13528:26): [True: 13.7k, False: 0]
  ------------------
13529|  13.7k|                             ? input_position + location
13530|  13.7k|                             : input_size;
13531|       |        // Otherwise, if c is U+003A (:) and insideBrackets is false, then:
13532|       |        // Note: the 'found_colon' value is true if and only if a colon was
13533|       |        // encountered while not inside brackets.
13534|  13.7k|        if (found_colon) {
  ------------------
  |  Branch (13534:13): [True: 2.59k, False: 11.1k]
  ------------------
13535|       |          // If buffer is the empty string, validation error, return failure.
13536|       |          // Let host be the result of host parsing buffer with url is not
13537|       |          // special.
13538|  2.59k|          ada_log("HOST parsing ", host_view);
13539|  2.59k|          if (!url.parse_host(host_view)) {
  ------------------
  |  Branch (13539:15): [True: 254, False: 2.34k]
  ------------------
13540|    254|            return url;
13541|    254|          }
13542|  2.34k|          ada_log("HOST parsing results in ", url.get_hostname());
13543|       |          // Set url's host to host, buffer to the empty string, and state to
13544|       |          // port state.
13545|  2.34k|          state = state::PORT;
13546|  2.34k|          input_position++;
13547|  2.34k|        }
13548|       |        // Otherwise, if one of the following is true:
13549|       |        // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
13550|       |        // - url is special and c is U+005C (\)
13551|       |        // The get_host_delimiter_location function either brings us to
13552|       |        // the colon outside of the bracket, or to one of those characters.
13553|  11.1k|        else {
13554|       |          // If url is special and host_view is the empty string, validation
13555|       |          // error, return failure.
13556|  11.1k|          if (host_view.empty() && url.is_special()) {
  ------------------
  |  Branch (13556:15): [True: 228, False: 10.9k]
  |  Branch (13556:36): [True: 102, False: 126]
  ------------------
13557|    102|            url.is_valid = false;
13558|    102|            return url;
13559|    102|          }
13560|  11.0k|          ada_log("HOST parsing ", host_view, " href=", url.get_href());
13561|       |          // Let host be the result of host parsing host_view with url is not
13562|       |          // special.
13563|  11.0k|          if (host_view.empty()) {
  ------------------
  |  Branch (13563:15): [True: 126, False: 10.9k]
  ------------------
13564|    126|            url.update_base_hostname("");
13565|  10.9k|          } else if (!url.parse_host(host_view)) {
  ------------------
  |  Branch (13565:22): [True: 2.29k, False: 8.65k]
  ------------------
13566|  2.29k|            return url;
13567|  2.29k|          }
13568|  8.78k|          ada_log("HOST parsing results in ", url.get_hostname(),
13569|  8.78k|                  " href=", url.get_href());
13570|       |
13571|       |          // Set url's host to host, and state to path start state.
13572|  8.78k|          state = state::PATH_START;
13573|  8.78k|        }
13574|       |
13575|  11.1k|        break;
13576|  13.7k|      }
13577|  11.1k|      case state::OPAQUE_PATH: {
  ------------------
  |  Branch (13577:7): [True: 3.22k, False: 166k]
  ------------------
13578|  3.22k|        ada_log("OPAQUE_PATH ", helpers::substring(url_data, input_position));
13579|       |        // Opaque path, query, and fragment are structurally always valid:
13580|       |        // the parser would just percent-encode whatever is there. When we
13581|       |        // are not storing values (can_parse), we can return immediately.
13582|       |        // We must set has_opaque_path = true before returning so that when
13583|       |        // this URL is used as an internal base inside can_parse, NO_SCHEME
13584|       |        // correctly rejects relative inputs against an opaque-path base
13585|       |        // (e.g. can_parse("", &"W:") must return false).
13586|       |        if constexpr (!store_values) {
13587|       |          url.has_opaque_path = true;
13588|       |          return url;
13589|       |        }
13590|  3.22k|        std::string_view view = url_data.substr(input_position);
13591|       |        // If c is U+003F (?), then set url's query to the empty string and
13592|       |        // state to query state.
13593|  3.22k|        size_t location = view.find('?');
13594|  3.22k|        if (location != std::string_view::npos) {
  ------------------
  |  Branch (13594:13): [True: 253, False: 2.97k]
  ------------------
13595|    253|          view.remove_suffix(view.size() - location);
13596|    253|          state = state::QUERY;
13597|    253|          input_position += location + 1;
13598|  2.97k|        } else {
13599|  2.97k|          input_position = input_size + 1;
13600|  2.97k|        }
13601|  3.22k|        url.has_opaque_path = true;
13602|       |
13603|       |        // This is a really unlikely scenario in real world. We should not seek
13604|       |        // to optimize it.
13605|  3.22k|        if (view.ends_with(' ')) {
  ------------------
  |  Branch (13605:13): [True: 116, False: 3.11k]
  ------------------
13606|    116|          std::string modified_view =
13607|    116|              std::string(view.substr(0, view.size() - 1)) + "%20";
13608|    116|          url.update_base_pathname(unicode::percent_encode(
13609|    116|              modified_view, character_sets::C0_CONTROL_PERCENT_ENCODE));
13610|  3.11k|        } else {
13611|  3.11k|          url.update_base_pathname(unicode::percent_encode(
13612|  3.11k|              view, character_sets::C0_CONTROL_PERCENT_ENCODE));
13613|  3.11k|        }
13614|  3.22k|        break;
13615|  13.7k|      }
13616|  2.34k|      case state::PORT: {
  ------------------
  |  Branch (13616:7): [True: 2.34k, False: 166k]
  ------------------
13617|  2.34k|        ada_log("PORT ", helpers::substring(url_data, input_position));
13618|  2.34k|        std::string_view port_view = url_data.substr(input_position);
13619|  2.34k|        input_position += url.parse_port(port_view, true);
13620|  2.34k|        if (!url.is_valid) {
  ------------------
  |  Branch (13620:13): [True: 132, False: 2.21k]
  ------------------
13621|    132|          return url;
13622|    132|        }
13623|  2.21k|        state = state::PATH_START;
13624|  2.21k|        [[fallthrough]];
13625|  2.21k|      }
13626|  12.9k|      case state::PATH_START: {
  ------------------
  |  Branch (13626:7): [True: 10.7k, False: 158k]
  ------------------
13627|  12.9k|        ada_log("PATH_START ", helpers::substring(url_data, input_position));
13628|       |        // Path, query, and fragment are structurally always valid: the
13629|       |        // parser would just percent-encode whatever is there. When we are
13630|       |        // not storing values (can_parse), we can return immediately since
13631|       |        // no subsequent state can invalidate the URL.
13632|       |        if constexpr (!store_values) {
13633|       |          return url;
13634|       |        }
13635|       |
13636|       |        // If url is special, then:
13637|  12.9k|        if (url.is_special()) {
  ------------------
  |  Branch (13637:13): [True: 12.1k, False: 781]
  ------------------
13638|       |          // Set state to path state.
13639|  12.1k|          state = state::PATH;
13640|       |
13641|       |          // Optimization: Avoiding going into PATH state improves the
13642|       |          // performance of urls ending with /.
13643|  12.1k|          if (input_position == input_size) {
  ------------------
  |  Branch (13643:15): [True: 6.43k, False: 5.72k]
  ------------------
13644|  6.43k|            if constexpr (store_values) {
13645|  6.43k|              url.update_base_pathname("/");
13646|  6.43k|              if (fragment.has_value()) {
  ------------------
  |  Branch (13646:19): [True: 173, False: 6.26k]
  ------------------
13647|    173|                url.update_unencoded_base_hash(*fragment);
13648|    173|              }
13649|  6.43k|            }
13650|  6.43k|            enforce_max_input_length();
13651|  6.43k|            return url;
13652|  6.43k|          }
13653|       |          // If c is neither U+002F (/) nor U+005C (\), then decrease pointer
13654|       |          // by 1. We know that (input_position == input_size) is impossible
13655|       |          // here, because of the previous if-check.
13656|  5.72k|          if ((url_data[input_position] != '/') &&
  ------------------
  |  Branch (13656:15): [True: 443, False: 5.27k]
  ------------------
13657|    443|              (url_data[input_position] != '\\')) {
  ------------------
  |  Branch (13657:15): [True: 430, False: 13]
  ------------------
13658|    430|            break;
13659|    430|          }
13660|  5.72k|        }
13661|       |        // Otherwise, if state override is not given and c is U+003F (?),
13662|       |        // set url's query to the empty string and state to query state.
13663|    781|        else if ((input_position != input_size) &&
  ------------------
  |  Branch (13663:18): [True: 170, False: 611]
  ------------------
13664|    170|                 (url_data[input_position] == '?')) {
  ------------------
  |  Branch (13664:18): [True: 61, False: 109]
  ------------------
13665|     61|          state = state::QUERY;
13666|     61|        }
13667|       |        // Otherwise, if c is not the EOF code point:
13668|    720|        else if (input_position != input_size) {
  ------------------
  |  Branch (13668:18): [True: 109, False: 611]
  ------------------
13669|       |          // Set state to path state.
13670|    109|          state = state::PATH;
13671|       |
13672|       |          // If c is not U+002F (/), then decrease pointer by 1.
13673|    109|          if (url_data[input_position] != '/') {
  ------------------
  |  Branch (13673:15): [True: 0, False: 109]
  ------------------
13674|      0|            break;
13675|      0|          }
13676|    109|        }
13677|       |
13678|  6.07k|        input_position++;
13679|  6.07k|        break;
13680|  12.9k|      }
13681|  8.50k|      case state::PATH: {
  ------------------
  |  Branch (13681:7): [True: 8.50k, False: 160k]
  ------------------
13682|  8.50k|        ada_log("PATH ", helpers::substring(url_data, input_position));
13683|       |        // Path, query, and fragment are structurally always valid: the
13684|       |        // parser would just percent-encode whatever is there. When we are
13685|       |        // not storing values (can_parse), we can return immediately since
13686|       |        // no subsequent state can invalidate the URL.
13687|       |        if constexpr (!store_values) {
13688|       |          return url;
13689|       |        }
13690|  8.50k|        std::string_view view = url_data.substr(input_position);
13691|       |
13692|       |        // Most time, we do not need percent encoding.
13693|       |        // Furthermore, we can immediately locate the '?'.
13694|  8.50k|        size_t locofquestionmark = view.find('?');
13695|  8.50k|        if (locofquestionmark != std::string_view::npos) {
  ------------------
  |  Branch (13695:13): [True: 853, False: 7.65k]
  ------------------
13696|    853|          state = state::QUERY;
13697|    853|          view.remove_suffix(view.size() - locofquestionmark);
13698|    853|          input_position += locofquestionmark + 1;
13699|  7.65k|        } else {
13700|  7.65k|          input_position = input_size + 1;
13701|  7.65k|        }
13702|  8.50k|        if constexpr (store_values) {
13703|  8.50k|          if constexpr (result_type_is_ada_url) {
13704|  8.50k|            helpers::parse_prepared_path(view, url.type, url.path);
13705|       |          } else {
13706|       |            url.consume_prepared_path(view);
13707|       |            ADA_ASSERT_TRUE(url.validate());
13708|       |          }
13709|  8.50k|        }
13710|  8.50k|        break;
13711|  12.9k|      }
13712|  2.25k|      case state::FILE_SLASH: {
  ------------------
  |  Branch (13712:7): [True: 2.25k, False: 167k]
  ------------------
13713|  2.25k|        ada_log("FILE_SLASH ", helpers::substring(url_data, input_position));
13714|       |
13715|       |        // If c is U+002F (/) or U+005C (\), then:
13716|  2.25k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13716:13): [True: 2.18k, False: 70]
  ------------------
13717|  2.18k|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13717:14): [True: 2.13k, False: 48]
  ------------------
13718|  2.14k|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13718:14): [True: 6, False: 42]
  ------------------
13719|  2.14k|          ada_log("FILE_SLASH c is U+002F or U+005C");
13720|       |          // Set state to file host state.
13721|  2.14k|          state = state::FILE_HOST;
13722|  2.14k|          input_position++;
13723|  2.14k|        } else {
13724|    112|          ada_log("FILE_SLASH otherwise");
13725|       |          // If base is non-null and base's scheme is "file", then:
13726|       |          // Note: it is unsafe to do base_url->scheme unless you know that
13727|       |          // base_url_has_value() is true.
13728|    112|          if (base_url != nullptr && base_url->type == scheme::type::FILE) {
  ------------------
  |  Branch (13728:15): [True: 87, False: 25]
  |  Branch (13728:38): [True: 84, False: 3]
  ------------------
13729|       |            // Set url's host to base's host.
13730|     84|            if constexpr (result_type_is_ada_url) {
13731|     84|              url.host = base_url->host;
13732|       |            } else {
13733|       |              url.update_host_to_base_host(base_url->get_host());
13734|       |            }
13735|       |            // If the code point substring from pointer to the end of input does
13736|       |            // not start with a Windows drive letter and base's path[0] is a
13737|       |            // normalized Windows drive letter, then append base's path[0] to
13738|       |            // url's path.
13739|     84|            if (!base_url->get_pathname().empty()) {
  ------------------
  |  Branch (13739:17): [True: 84, False: 0]
  ------------------
13740|     84|              if (!checkers::is_windows_drive_letter(
  ------------------
  |  Branch (13740:19): [True: 79, False: 5]
  ------------------
13741|     84|                      url_data.substr(input_position))) {
13742|     79|                std::string_view first_base_url_path =
13743|     79|                    base_url->get_pathname().substr(1);
13744|     79|                size_t loc = first_base_url_path.find('/');
13745|     79|                if (loc != std::string_view::npos) {
  ------------------
  |  Branch (13745:21): [True: 12, False: 67]
  ------------------
13746|     12|                  helpers::resize(first_base_url_path, loc);
13747|     12|                }
13748|     79|                if (checkers::is_normalized_windows_drive_letter(
  ------------------
  |  Branch (13748:21): [True: 3, False: 76]
  ------------------
13749|     79|                        first_base_url_path)) {
13750|      3|                  if constexpr (result_type_is_ada_url) {
13751|      3|                    url.path += '/';
13752|      3|                    url.path += first_base_url_path;
13753|       |                  } else {
13754|       |                    url.append_base_pathname(
13755|       |                        helpers::concat("/", first_base_url_path));
13756|       |                  }
13757|      3|                }
13758|     79|              }
13759|     84|            }
13760|     84|          }
13761|       |
13762|       |          // Set state to path state, and decrease pointer by 1.
13763|    112|          state = state::PATH;
13764|    112|        }
13765|       |
13766|  2.25k|        break;
13767|  12.9k|      }
13768|  2.14k|      case state::FILE_HOST: {
  ------------------
  |  Branch (13768:7): [True: 2.14k, False: 167k]
  ------------------
13769|  2.14k|        ada_log("FILE_HOST ", helpers::substring(url_data, input_position));
13770|  2.14k|        std::string_view view = url_data.substr(input_position);
13771|       |
13772|  2.14k|        size_t location = view.find_first_of("/\\?");
13773|  2.14k|        std::string_view file_host_buffer = view.substr(
13774|  2.14k|            0, (location != std::string_view::npos) ? location : view.size());
  ------------------
  |  Branch (13774:16): [True: 924, False: 1.22k]
  ------------------
13775|       |
13776|  2.14k|        if (checkers::is_windows_drive_letter(file_host_buffer)) {
  ------------------
  |  Branch (13776:13): [True: 12, False: 2.13k]
  ------------------
13777|     12|          state = state::PATH;
13778|  2.13k|        } else if (file_host_buffer.empty()) {
  ------------------
  |  Branch (13778:20): [True: 274, False: 1.85k]
  ------------------
13779|       |          // Set url's host to the empty string.
13780|    274|          if constexpr (result_type_is_ada_url) {
13781|    274|            url.host = "";
13782|       |          } else {
13783|       |            url.update_base_hostname("");
13784|       |          }
13785|       |          // Set state to path start state.
13786|    274|          state = state::PATH_START;
13787|  1.85k|        } else {
13788|  1.85k|          size_t consumed_bytes = file_host_buffer.size();
13789|  1.85k|          input_position += consumed_bytes;
13790|       |          // Let host be the result of host parsing buffer with url is not
13791|       |          // special.
13792|  1.85k|          if (!url.parse_host(file_host_buffer)) {
  ------------------
  |  Branch (13792:15): [True: 191, False: 1.66k]
  ------------------
13793|    191|            return url;
13794|    191|          }
13795|       |
13796|  1.66k|          if constexpr (result_type_is_ada_url) {
13797|       |            // If host is "localhost", then set host to the empty string.
13798|  1.66k|            if (url.host.has_value() && url.host.value() == "localhost") {
  ------------------
  |  Branch (13798:17): [True: 1.66k, False: 0]
  |  Branch (13798:41): [True: 12, False: 1.65k]
  ------------------
13799|     12|              url.host = "";
13800|     12|            }
13801|       |          } else {
13802|       |            if (url.get_hostname() == "localhost") {
13803|       |              url.update_base_hostname("");
13804|       |            }
13805|       |          }
13806|       |
13807|       |          // Set buffer to the empty string and state to path start state.
13808|  1.66k|          state = state::PATH_START;
13809|  1.66k|        }
13810|       |
13811|  1.95k|        break;
13812|  2.14k|      }
13813|  2.95k|      case state::FILE: {
  ------------------
  |  Branch (13813:7): [True: 2.95k, False: 166k]
  ------------------
13814|  2.95k|        ada_log("FILE ", helpers::substring(url_data, input_position));
13815|  2.95k|        std::string_view file_view = url_data.substr(input_position);
13816|       |
13817|  2.95k|        url.set_protocol_as_file();
13818|  2.95k|        if constexpr (result_type_is_ada_url) {
13819|       |          // Set url's host to the empty string.
13820|  2.95k|          url.host = "";
13821|       |        } else {
13822|       |          url.update_base_hostname("");
13823|       |        }
13824|       |        // If c is U+002F (/) or U+005C (\), then:
13825|  2.95k|        if (input_position != input_size &&
  ------------------
  |  Branch (13825:13): [True: 2.81k, False: 137]
  ------------------
13826|  2.81k|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13826:14): [True: 2.25k, False: 562]
  ------------------
13827|  2.25k|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13827:14): [True: 6, False: 556]
  ------------------
13828|  2.25k|          ada_log("FILE c is U+002F or U+005C");
13829|       |          // Set state to file slash state.
13830|  2.25k|          state = state::FILE_SLASH;
13831|  2.25k|        }
13832|       |        // Otherwise, if base is non-null and base's scheme is "file":
13833|    693|        else if (base_url != nullptr && base_url->type == scheme::type::FILE) {
  ------------------
  |  Branch (13833:18): [True: 267, False: 426]
  |  Branch (13833:41): [True: 199, False: 68]
  ------------------
13834|       |          // Set url's host to base's host, url's path to a clone of base's
13835|       |          // path, and url's query to base's query.
13836|    199|          ada_log("FILE base non-null");
13837|    199|          if constexpr (result_type_is_ada_url) {
13838|    199|            url.host = base_url->host;
13839|    199|            url.path = base_url->path;
13840|    199|            url.query = base_url->query;
13841|       |          } else {
13842|       |            url.update_host_to_base_host(base_url->get_hostname());
13843|       |            url.update_base_pathname(base_url->get_pathname());
13844|       |            if (base_url->has_search()) {
13845|       |              // get_search() returns "" for an empty query string (URL ends
13846|       |              // with '?'). update_base_search("") would incorrectly clear the
13847|       |              // query, so pass "?" to preserve the empty query distinction.
13848|       |              auto s = base_url->get_search();
13849|       |              url.update_base_search(s.empty() ? std::string_view("?") : s);
13850|       |            }
13851|       |          }
13852|    199|          url.has_opaque_path = base_url->has_opaque_path;
13853|       |
13854|       |          // If c is U+003F (?), then set url's query to the empty string and
13855|       |          // state to query state.
13856|    199|          if (input_position != input_size && url_data[input_position] == '?') {
  ------------------
  |  Branch (13856:15): [True: 136, False: 63]
  |  Branch (13856:47): [True: 9, False: 127]
  ------------------
13857|      9|            state = state::QUERY;
13858|      9|          }
13859|       |          // Otherwise, if c is not the EOF code point:
13860|    190|          else if (input_position != input_size) {
  ------------------
  |  Branch (13860:20): [True: 127, False: 63]
  ------------------
13861|       |            // Set url's query to null.
13862|    127|            url.clear_search();
13863|       |            // If the code point substring from pointer to the end of input does
13864|       |            // not start with a Windows drive letter, then shorten url's path.
13865|    127|            if (!checkers::is_windows_drive_letter(file_view)) {
  ------------------
  |  Branch (13865:17): [True: 107, False: 20]
  ------------------
13866|    107|              if constexpr (result_type_is_ada_url) {
13867|    107|                helpers::shorten_path(url.path, url.type);
13868|       |              } else {
13869|       |                std::string_view path = url.get_pathname();
13870|       |                if (helpers::shorten_path(path, url.type)) {
13871|       |                  url.update_base_pathname(std::move(std::string(path)));
13872|       |                }
13873|       |              }
13874|    107|            }
13875|       |            // Otherwise:
13876|     20|            else {
13877|       |              // Set url's path to an empty list.
13878|     20|              url.clear_pathname();
13879|     20|            }
13880|       |
13881|       |            // Set state to path state and decrease pointer by 1.
13882|    127|            state = state::PATH;
13883|    127|            break;
13884|    127|          }
13885|    199|        }
13886|       |        // Otherwise, set state to path state, and decrease pointer by 1.
13887|    494|        else {
13888|    494|          ada_log("FILE go to path");
13889|    494|          state = state::PATH;
13890|    494|          break;
13891|    494|        }
13892|       |
13893|  2.32k|        input_position++;
13894|  2.32k|        break;
13895|  2.95k|      }
13896|      0|      default:
  ------------------
  |  Branch (13896:7): [True: 0, False: 169k]
  ------------------
13897|      0|        unreachable();
13898|   169k|    }
13899|   169k|  }
13900|  17.0k|  if constexpr (store_values) {
13901|  17.0k|    if (fragment.has_value()) {
  ------------------
  |  Branch (13901:9): [True: 446, False: 16.5k]
  ------------------
13902|    446|      url.update_unencoded_base_hash(*fragment);
13903|    446|    }
13904|  17.0k|  }
13905|  17.0k|  enforce_max_input_length();
13906|  17.0k|  return url;
13907|  50.6k|}
_ZN3ada6parser14parse_url_implINS_14url_aggregatorELb1EEET_NSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEPKS3_:
12886|  50.6k|                           const result_type* base_url) {
12887|       |  // We can specialize the implementation per type.
12888|       |  // Important: result_type_is_ada_url is evaluated at *compile time*. This
12889|       |  // means that doing if constexpr(result_type_is_ada_url) { something } else {
12890|       |  // something else } is free (at runtime). This means that ada::url_aggregator
12891|       |  // and ada::url **do not have to support the exact same API**.
12892|  50.6k|  constexpr bool result_type_is_ada_url = std::is_same_v<url, result_type>;
12893|  50.6k|  constexpr bool result_type_is_ada_url_aggregator =
12894|  50.6k|      std::is_same_v<url_aggregator, result_type>;
12895|  50.6k|  static_assert(result_type_is_ada_url ||
12896|  50.6k|                result_type_is_ada_url_aggregator);  // We don't support
12897|       |                                                     // anything else for now.
12898|       |
12899|  50.6k|  ada_log("ada::parser::parse_url('", user_input, "' [", user_input.size(),
12900|  50.6k|          " bytes],", (base_url != nullptr ? base_url->to_string() : "null"),
12901|  50.6k|          ")");
12902|       |
12903|  50.6k|  result_type url{};
12904|       |
12905|  50.6k|  const uint32_t max_input_length = ada::get_max_input_length();
12906|       |
12907|       |  // Normalization (percent-encoding, IDNA) can push the serialized URL past
12908|       |  // max_input_length even when the input fit under it. The check at the end of
12909|       |  // the state machine covers URLs that run to completion, but several states
12910|       |  // return early after appending a query or fragment, so run the same check on
12911|       |  // those exits too. Without this, a query- or fragment-terminated URL such as
12912|       |  // file://x/?<...> or https://user@x/?<...> is accepted while the equivalent
12913|       |  // https://x/?<...> that takes the absolute fast path is rejected.
12914|  50.6k|  const auto enforce_max_input_length = [&]() {
12915|  50.6k|    if constexpr (store_values) {
12916|  50.6k|      if (url.is_valid) {
12917|  50.6k|        if constexpr (result_type_is_ada_url_aggregator) {
12918|  50.6k|          if (url.buffer.size() > max_input_length) [[unlikely]] {
12919|  50.6k|            url.is_valid = false;
12920|  50.6k|          }
12921|  50.6k|        } else {
12922|  50.6k|          if (url.get_href_size() > max_input_length) [[unlikely]] {
12923|  50.6k|            url.is_valid = false;
12924|  50.6k|          }
12925|  50.6k|        }
12926|  50.6k|      }
12927|  50.6k|    }
12928|  50.6k|  };
12929|       |
12930|       |  // We refuse to parse URL strings that exceed the maximum input length.
12931|       |  // By default, this is 4GB but can be configured via
12932|       |  // ada::set_max_input_length().
12933|  50.6k|  if (user_input.size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (12933:7): [True: 0, False: 50.6k]
  ------------------
12934|      0|    url.is_valid = false;
12935|      0|  }
12936|       |  // Going forward, user_input.size() is in [0,
12937|       |  // std::numeric_limits<uint32_t>::max). If we are provided with an invalid
12938|       |  // base, or the optional_url was invalid, we must return.
12939|  50.6k|  if (base_url != nullptr) {
  ------------------
  |  Branch (12939:7): [True: 4.45k, False: 46.2k]
  ------------------
12940|  4.45k|    url.is_valid &= base_url->is_valid;
12941|  4.45k|  }
12942|  50.6k|  if (!url.is_valid) {
  ------------------
  |  Branch (12942:7): [True: 0, False: 50.6k]
  ------------------
12943|      0|    return url;
12944|      0|  }
12945|       |
12946|       |  // Simple absolute / relative fast paths (before tabs/newline scan).
12947|  50.6k|  if constexpr (store_values) {
12948|  50.6k|    bool hit_fast_path = false;
12949|  50.6k|    if (base_url == nullptr) {
  ------------------
  |  Branch (12949:9): [True: 46.2k, False: 4.45k]
  ------------------
12950|       |      // IPv4/IPv6 and userinfo miss the fast path. Skip the never_inline
12951|       |      // call so those URLs (including SetHref) do not pay for a miss.
12952|  46.2k|      const auto* p = reinterpret_cast<const uint8_t*>(user_input.data());
12953|  46.2k|      const size_t n = user_input.size();
12954|  46.2k|      size_t host_start = 0;
12955|  46.2k|      if (n >= 8 && p[4] == ':' && p[5] == '/' && p[6] == '/') {
  ------------------
  |  Branch (12955:11): [True: 18.1k, False: 28.0k]
  |  Branch (12955:21): [True: 3.26k, False: 14.8k]
  |  Branch (12955:36): [True: 2.35k, False: 902]
  |  Branch (12955:51): [True: 2.32k, False: 34]
  ------------------
12956|  2.32k|        host_start = 7;
12957|  43.9k|      } else if (n >= 9 && p[5] == ':' && p[6] == '/' && p[7] == '/') {
  ------------------
  |  Branch (12957:18): [True: 14.4k, False: 29.4k]
  |  Branch (12957:28): [True: 278, False: 14.2k]
  |  Branch (12957:43): [True: 49, False: 229]
  |  Branch (12957:58): [True: 26, False: 23]
  ------------------
12958|     26|        host_start = 8;
12959|     26|      }
12960|  46.2k|      const uint8_t host_first = host_start != 0 ? p[host_start] : 0;
  ------------------
  |  Branch (12960:34): [True: 2.35k, False: 43.8k]
  ------------------
12961|  46.2k|      const bool skip_ip =
12962|  46.2k|          host_first == '[' || (host_first >= '0' && host_first <= '9');
  ------------------
  |  Branch (12962:11): [True: 22, False: 46.2k]
  |  Branch (12962:33): [True: 1.70k, False: 44.5k]
  |  Branch (12962:54): [True: 630, False: 1.07k]
  ------------------
12963|       |      // Only scan for userinfo when the host is not an IP literal, so
12964|       |      // IPv4/IPv6 inputs skip the SIMD '@' check entirely.
12965|  46.2k|      hit_fast_path =
12966|  46.2k|          !skip_ip &&
  ------------------
  |  Branch (12966:11): [True: 45.5k, False: 652]
  ------------------
12967|  45.5k|          !(host_start != 0 && authority_has_at(p, host_start, n)) &&
  ------------------
  |  Branch (12967:13): [True: 1.69k, False: 43.8k]
  |  Branch (12967:32): [True: 13, False: 1.68k]
  ------------------
12968|  45.5k|          try_parse_simple_absolute(user_input, url);
  ------------------
  |  Branch (12968:11): [True: 5.26k, False: 40.3k]
  ------------------
12969|  46.2k|    } else {
12970|  4.45k|      hit_fast_path = try_parse_simple_relative(user_input, *base_url, url);
12971|  4.45k|    }
12972|  50.6k|    if (hit_fast_path) {
  ------------------
  |  Branch (12972:9): [True: 5.52k, False: 45.1k]
  ------------------
12973|  5.52k|      if constexpr (result_type_is_ada_url_aggregator) {
12974|  5.52k|        if (url.buffer.size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (12974:13): [True: 0, False: 5.52k]
  ------------------
12975|      0|          url.is_valid = false;
12976|      0|        }
12977|       |      } else {
12978|       |        // For a small absolute input, even worst-case normalization cannot
12979|       |        // exceed the limit: percent encoding expands at most 3x and IDNA at
12980|       |        // most 4.5x. Avoid traversing every stored component on the common
12981|       |        // default-limit path.
12982|       |        if ((base_url != nullptr ||
12983|       |             user_input.size() > static_cast<size_t>(max_input_length) / 5) &&
12984|       |            url.get_href_size() > max_input_length) [[unlikely]] {
12985|       |          url.is_valid = false;
12986|       |        }
12987|       |      }
12988|  5.52k|      return url;
12989|  5.52k|    }
12990|  50.6k|  }
12991|       |
12992|  45.1k|  state state = state::SCHEME_START;
12993|       |
12994|  50.6k|  std::string tmp_buffer;
12995|  50.6k|  std::string_view url_data;
12996|  50.6k|  if (unicode::has_tabs_or_newline(user_input)) [[unlikely]] {
  ------------------
  |  Branch (12996:7): [True: 495, False: 50.1k]
  ------------------
12997|    495|    tmp_buffer = user_input;
12998|       |    // Optimization opportunity: Instead of copying and then pruning, we could
12999|       |    // just directly build the string from user_input.
13000|    495|    helpers::remove_ascii_tab_or_newline(tmp_buffer);
13001|    495|    url_data = tmp_buffer;
13002|  50.1k|  } else [[likely]] {
13003|  50.1k|    url_data = user_input;
13004|  50.1k|  }
13005|       |
13006|       |  // Leading and trailing control characters are uncommon and easy to deal with
13007|       |  // (no performance concern).
13008|  50.6k|  helpers::trim_c0_whitespace(url_data);
13009|       |
13010|  50.6k|  if constexpr (result_type_is_ada_url_aggregator && store_values) {
13011|       |    // Most of the time, we just need user_input.size().
13012|       |    // In some instances, we may need a bit more.
13013|       |    ///////////////////////////
13014|       |    // This is *very* important. This line should *not* be removed
13015|       |    // hastily. There are principled reasons why reserve is important
13016|       |    // for performance. If you have a benchmark with small inputs,
13017|       |    // it may not matter, but in other instances, it could.
13018|       |    ////
13019|       |    // This rounds up to the next power of two.
13020|       |    // We know that user_input.size() is in [0,
13021|       |    // std::numeric_limits<uint32_t>::max).
13022|  50.6k|    uint32_t reserve_capacity =
13023|  50.6k|        (0xFFFFFFFF >>
13024|  50.6k|         helpers::leading_zeroes(uint32_t(1 | user_input.size()))) +
13025|  50.6k|        1;
13026|  50.6k|    url.reserve(reserve_capacity);
13027|  50.6k|  }
13028|       |
13029|       |  // Optimization opportunity. Most websites do not have fragment.
13030|  50.6k|  std::optional<std::string_view> fragment = helpers::prune_hash(url_data);
13031|       |  // We add it last so that an implementation like ada::url_aggregator
13032|       |  // can append it last to its internal buffer, thus improving performance.
13033|       |
13034|       |  // Here url_data no longer has its fragment.
13035|       |  // We are going to access the data from url_data (it is immutable).
13036|       |  // At any given time, we are pointing at byte 'input_position' in url_data.
13037|       |  // The input_position variable should range from 0 to input_size.
13038|       |  // It is illegal to access url_data at input_size.
13039|  50.6k|  size_t input_position = 0;
13040|  50.6k|  const size_t input_size = url_data.size();
13041|       |  // Keep running the following state machine by switching on state.
13042|       |  // If after a run pointer points to the EOF code point, go to the next step.
13043|       |  // Otherwise, increase pointer by 1 and continue with the state machine.
13044|       |  // We never decrement input_position.
13045|   186k|  while (input_position <= input_size) {
  ------------------
  |  Branch (13045:10): [True: 169k, False: 17.0k]
  ------------------
13046|   169k|    ada_log("In parsing at ", input_position, " out of ", input_size,
13047|   169k|            " in state ", ada::to_string(state));
13048|   169k|    switch (state) {
13049|  45.1k|      case state::SCHEME_START: {
  ------------------
  |  Branch (13049:7): [True: 45.1k, False: 124k]
  ------------------
13050|  45.1k|        ada_log("SCHEME_START ", helpers::substring(url_data, input_position));
13051|       |        // If c is an ASCII alpha, append c, lowercased, to buffer, and set
13052|       |        // state to scheme state.
13053|  45.1k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13053:13): [True: 23.7k, False: 21.4k]
  ------------------
13054|  23.7k|            checkers::is_alpha(url_data[input_position])) {
  ------------------
  |  Branch (13054:13): [True: 22.2k, False: 1.52k]
  ------------------
13055|  22.2k|          state = state::SCHEME;
13056|  22.2k|          input_position++;
13057|  22.9k|        } else {
13058|       |          // Otherwise, if state override is not given, set state to no scheme
13059|       |          // state and decrease pointer by 1.
13060|  22.9k|          state = state::NO_SCHEME;
13061|  22.9k|        }
13062|  45.1k|        break;
13063|      0|      }
13064|  22.2k|      case state::SCHEME: {
  ------------------
  |  Branch (13064:7): [True: 22.2k, False: 147k]
  ------------------
13065|  22.2k|        ada_log("SCHEME ", helpers::substring(url_data, input_position));
13066|       |        // If c is an ASCII alphanumeric, U+002B (+), U+002D (-), or U+002E (.),
13067|       |        // append c, lowercased, to buffer.
13068|  54.5k|        while ((input_position != input_size) &&
  ------------------
  |  Branch (13068:16): [True: 54.1k, False: 323]
  ------------------
13069|  54.1k|               (unicode::is_alnum_plus(url_data[input_position]))) {
  ------------------
  |  Branch (13069:16): [True: 32.2k, False: 21.9k]
  ------------------
13070|  32.2k|          input_position++;
13071|  32.2k|        }
13072|       |        // Otherwise, if c is U+003A (:), then:
13073|  22.2k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13073:13): [True: 21.9k, False: 323]
  ------------------
13074|  21.9k|            (url_data[input_position] == ':')) {
  ------------------
  |  Branch (13074:13): [True: 21.4k, False: 467]
  ------------------
13075|  21.4k|          ada_log("SCHEME the scheme should be ",
13076|  21.4k|                  url_data.substr(0, input_position));
13077|       |          if constexpr (result_type_is_ada_url) {
13078|       |            if (!url.parse_scheme(url_data.substr(0, input_position))) {
13079|       |              return url;
13080|       |            }
13081|  21.4k|          } else {
13082|       |            // we pass the colon along instead of painfully adding it back.
13083|  21.4k|            if (!url.parse_scheme_with_colon(
  ------------------
  |  Branch (13083:17): [True: 0, False: 21.4k]
  ------------------
13084|  21.4k|                    url_data.substr(0, input_position + 1))) {
13085|      0|              return url;
13086|      0|            }
13087|  21.4k|          }
13088|  21.4k|          ada_log("SCHEME the scheme is ", url.get_protocol());
13089|       |
13090|       |          // If url's scheme is "file", then:
13091|       |          // NOLINTNEXTLINE(bugprone-branch-clone)
13092|  21.4k|          if (url.type == scheme::type::FILE) {
  ------------------
  |  Branch (13092:15): [True: 2.68k, False: 18.7k]
  ------------------
13093|       |            // Set state to file state.
13094|  2.68k|            state = state::FILE;
13095|  2.68k|          }
13096|       |          // Otherwise, if url is special, base is non-null, and base's scheme
13097|       |          // is url's scheme: Note: Doing base_url->scheme is unsafe if base_url
13098|       |          // != nullptr is false.
13099|  18.7k|          else if (url.is_special() && base_url != nullptr &&
  ------------------
  |  Branch (13099:20): [True: 13.2k, False: 5.46k]
  |  Branch (13099:40): [True: 2.22k, False: 11.0k]
  ------------------
13100|  2.22k|                   base_url->type == url.type) {
  ------------------
  |  Branch (13100:20): [True: 448, False: 1.77k]
  ------------------
13101|       |            // Set state to special relative or authority state.
13102|    448|            state = state::SPECIAL_RELATIVE_OR_AUTHORITY;
13103|    448|          }
13104|       |          // Otherwise, if url is special, set state to special authority
13105|       |          // slashes state.
13106|  18.3k|          else if (url.is_special()) {
  ------------------
  |  Branch (13106:20): [True: 12.8k, False: 5.46k]
  ------------------
13107|  12.8k|            state = state::SPECIAL_AUTHORITY_SLASHES;
13108|  12.8k|          }
13109|       |          // Otherwise, if remaining starts with an U+002F (/), set state to
13110|       |          // path or authority state and increase pointer by 1.
13111|  5.46k|          else if (input_position + 1 < input_size &&
  ------------------
  |  Branch (13111:20): [True: 3.20k, False: 2.26k]
  ------------------
13112|  3.20k|                   url_data[input_position + 1] == '/') {
  ------------------
  |  Branch (13112:20): [True: 2.24k, False: 961]
  ------------------
13113|  2.24k|            state = state::PATH_OR_AUTHORITY;
13114|  2.24k|            input_position++;
13115|  2.24k|          }
13116|       |          // Otherwise, set url's path to the empty string and set state to
13117|       |          // opaque path state.
13118|  3.22k|          else {
13119|  3.22k|            state = state::OPAQUE_PATH;
13120|  3.22k|          }
13121|  21.4k|        }
13122|       |        // Otherwise, if state override is not given, set buffer to the empty
13123|       |        // string, state to no scheme state, and start over (from the first code
13124|       |        // point in input).
13125|    790|        else {
13126|    790|          state = state::NO_SCHEME;
13127|    790|          input_position = 0;
13128|    790|          break;
13129|    790|        }
13130|  21.4k|        input_position++;
13131|  21.4k|        break;
13132|  22.2k|      }
13133|  23.7k|      case state::NO_SCHEME: {
  ------------------
  |  Branch (13133:7): [True: 23.7k, False: 145k]
  ------------------
13134|  23.7k|        ada_log("NO_SCHEME ", helpers::substring(url_data, input_position));
13135|       |        // The fragment was pruned from url_data before the state machine ran,
13136|       |        // so 'c is U+0023 (#)' holds exactly when a fragment was found and
13137|       |        // nothing else remains in front of it.
13138|  23.7k|        const bool c_is_hash =
13139|  23.7k|            fragment.has_value() && input_position == input_size;
  ------------------
  |  Branch (13139:13): [True: 585, False: 23.1k]
  |  Branch (13139:37): [True: 228, False: 357]
  ------------------
13140|       |        // If base is null, or base has an opaque path and c is not U+0023 (#),
13141|       |        // validation error, return failure.
13142|  23.7k|        if (base_url == nullptr || (base_url->has_opaque_path && !c_is_hash)) {
  ------------------
  |  Branch (13142:13): [True: 22.5k, False: 1.14k]
  |  Branch (13142:37): [True: 101, False: 1.04k]
  |  Branch (13142:66): [True: 46, False: 55]
  ------------------
13143|  22.6k|          ada_log("NO_SCHEME validation error");
13144|  22.6k|          url.is_valid = false;
13145|  22.6k|          return url;
13146|  22.6k|        }
13147|       |        // Otherwise, if base has an opaque path and c is U+0023 (#),
13148|       |        // set url's scheme to base's scheme, url's path to base's path, url's
13149|       |        // query to base's query, and set state to fragment state.
13150|  1.09k|        else if (base_url->has_opaque_path && c_is_hash) {
  ------------------
  |  Branch (13150:18): [True: 55, False: 1.04k]
  |  Branch (13150:47): [True: 55, False: 0]
  ------------------
13151|     55|          ada_log("NO_SCHEME opaque base with fragment");
13152|     55|          url.copy_scheme(*base_url);
13153|     55|          url.has_opaque_path = base_url->has_opaque_path;
13154|       |
13155|       |          if constexpr (result_type_is_ada_url) {
13156|       |            url.path = base_url->path;
13157|       |            url.query = base_url->query;
13158|     55|          } else {
13159|     55|            url.update_base_pathname(base_url->get_pathname());
13160|     55|            if (base_url->has_search()) {
  ------------------
  |  Branch (13160:17): [True: 24, False: 31]
  ------------------
13161|       |              // get_search() returns "" for an empty query string (URL ends
13162|       |              // with '?'). update_base_search("") would incorrectly clear the
13163|       |              // query, so pass "?" to preserve the empty query distinction.
13164|     24|              auto s = base_url->get_search();
13165|     24|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (13165:38): [True: 12, False: 12]
  ------------------
13166|     24|            }
13167|     55|          }
13168|     55|          url.update_unencoded_base_hash(*fragment);
13169|     55|          enforce_max_input_length();
13170|     55|          return url;
13171|     55|        }
13172|       |        // Otherwise, if base's scheme is not "file", set state to relative
13173|       |        // state and decrease pointer by 1.
13174|       |        // NOLINTNEXTLINE(bugprone-branch-clone)
13175|  1.04k|        else if (base_url->type != scheme::type::FILE) {
  ------------------
  |  Branch (13175:18): [True: 777, False: 264]
  ------------------
13176|    777|          ada_log("NO_SCHEME non-file relative path");
13177|    777|          state = state::RELATIVE_SCHEME;
13178|    777|        }
13179|       |        // Otherwise, set state to file state and decrease pointer by 1.
13180|    264|        else {
13181|    264|          ada_log("NO_SCHEME file base type");
13182|    264|          state = state::FILE;
13183|    264|        }
13184|  1.04k|        break;
13185|  23.7k|      }
13186|  14.1k|      case state::AUTHORITY: {
  ------------------
  |  Branch (13186:7): [True: 14.1k, False: 155k]
  ------------------
13187|  14.1k|        ada_log("AUTHORITY ", helpers::substring(url_data, input_position));
13188|       |        // most URLs have no @. Having no @ tells us that we don't have to worry
13189|       |        // about AUTHORITY. Of course, we could have @ and still not have to
13190|       |        // worry about AUTHORITY.
13191|       |        // TODO: Instead of just collecting a bool, collect the location of the
13192|       |        // '@' and do something useful with it.
13193|       |        // TODO: We could do various processing early on, using a single pass
13194|       |        // over the string to collect information about it, e.g., telling us
13195|       |        // whether there is a @ and if so, where (or how many).
13196|       |
13197|       |        // Check if url data contains an @.
13198|  14.1k|        if (url_data.find('@', input_position) == std::string_view::npos) {
  ------------------
  |  Branch (13198:13): [True: 12.8k, False: 1.25k]
  ------------------
13199|  12.8k|          state = state::HOST;
13200|  12.8k|          break;
13201|  12.8k|        }
13202|  1.25k|        bool at_sign_seen{false};
13203|  1.25k|        bool password_token_seen{false};
13204|       |        /**
13205|       |         * We expect something of the sort...
13206|       |         * https://user:pass@example.com:1234/foo/bar?baz#quux
13207|       |         * --------^
13208|       |         */
13209|  8.18k|        do {
13210|  8.18k|          std::string_view view = url_data.substr(input_position);
13211|       |          // The delimiters are @, /, ? \\.
13212|  8.18k|          size_t location =
13213|  8.18k|              url.is_special() ? helpers::find_authority_delimiter_special(view)
  ------------------
  |  Branch (13213:15): [True: 7.23k, False: 955]
  ------------------
13214|  8.18k|                               : helpers::find_authority_delimiter(view);
13215|  8.18k|          std::string_view authority_view = view.substr(0, location);
13216|  8.18k|          size_t end_of_authority = input_position + authority_view.size();
13217|       |          // If c is U+0040 (@), then:
13218|  8.18k|          if ((end_of_authority != input_size) &&
  ------------------
  |  Branch (13218:15): [True: 7.37k, False: 812]
  ------------------
13219|  7.37k|              (url_data[end_of_authority] == '@')) {
  ------------------
  |  Branch (13219:15): [True: 6.92k, False: 447]
  ------------------
13220|       |            // If atSignSeen is true, then prepend "%40" to buffer.
13221|  6.92k|            if (at_sign_seen) {
  ------------------
  |  Branch (13221:17): [True: 5.81k, False: 1.10k]
  ------------------
13222|  5.81k|              if (password_token_seen) {
  ------------------
  |  Branch (13222:19): [True: 2.47k, False: 3.34k]
  ------------------
13223|       |                if constexpr (result_type_is_ada_url) {
13224|       |                  url.password += "%40";
13225|  2.47k|                } else {
13226|  2.47k|                  url.append_base_password("%40");
13227|  2.47k|                }
13228|  3.34k|              } else {
13229|       |                if constexpr (result_type_is_ada_url) {
13230|       |                  url.username += "%40";
13231|  3.34k|                } else {
13232|  3.34k|                  url.append_base_username("%40");
13233|  3.34k|                }
13234|  3.34k|              }
13235|  5.81k|            }
13236|       |
13237|  6.92k|            at_sign_seen = true;
13238|       |
13239|  6.92k|            if (!password_token_seen) {
  ------------------
  |  Branch (13239:17): [True: 4.45k, False: 2.47k]
  ------------------
13240|  4.45k|              size_t password_token_location = authority_view.find(':');
13241|  4.45k|              password_token_seen =
13242|  4.45k|                  password_token_location != std::string_view::npos;
13243|       |
13244|  4.45k|              if constexpr (store_values) {
13245|  4.45k|                if (!password_token_seen) {
  ------------------
  |  Branch (13245:21): [True: 4.03k, False: 426]
  ------------------
13246|       |                  if constexpr (result_type_is_ada_url) {
13247|       |                    url.username += unicode::percent_encode(
13248|       |                        authority_view,
13249|       |                        character_sets::USERINFO_PERCENT_ENCODE);
13250|  4.03k|                  } else {
13251|  4.03k|                    url.append_base_username(unicode::percent_encode(
13252|  4.03k|                        authority_view,
13253|  4.03k|                        character_sets::USERINFO_PERCENT_ENCODE));
13254|  4.03k|                  }
13255|  4.03k|                } else {
13256|       |                  if constexpr (result_type_is_ada_url) {
13257|       |                    url.username += unicode::percent_encode(
13258|       |                        authority_view.substr(0, password_token_location),
13259|       |                        character_sets::USERINFO_PERCENT_ENCODE);
13260|       |                    url.password += unicode::percent_encode(
13261|       |                        authority_view.substr(password_token_location + 1),
13262|       |                        character_sets::USERINFO_PERCENT_ENCODE);
13263|    426|                  } else {
13264|    426|                    url.append_base_username(unicode::percent_encode(
13265|    426|                        authority_view.substr(0, password_token_location),
13266|    426|                        character_sets::USERINFO_PERCENT_ENCODE));
13267|    426|                    url.append_base_password(unicode::percent_encode(
13268|    426|                        authority_view.substr(password_token_location + 1),
13269|    426|                        character_sets::USERINFO_PERCENT_ENCODE));
13270|    426|                  }
13271|    426|                }
13272|  4.45k|              }
13273|  4.45k|            } else if constexpr (store_values) {
13274|       |              if constexpr (result_type_is_ada_url) {
13275|       |                url.password += unicode::percent_encode(
13276|       |                    authority_view, character_sets::USERINFO_PERCENT_ENCODE);
13277|  2.47k|              } else {
13278|  2.47k|                url.append_base_password(unicode::percent_encode(
13279|  2.47k|                    authority_view, character_sets::USERINFO_PERCENT_ENCODE));
13280|  2.47k|              }
13281|  2.47k|            }
13282|  6.92k|          }
13283|       |          // Otherwise, if one of the following is true:
13284|       |          // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
13285|       |          // - url is special and c is U+005C (\)
13286|  1.25k|          else if (end_of_authority == input_size ||
  ------------------
  |  Branch (13286:20): [True: 812, False: 447]
  ------------------
13287|    447|                   url_data[end_of_authority] == '/' ||
  ------------------
  |  Branch (13287:20): [True: 408, False: 39]
  ------------------
13288|     39|                   url_data[end_of_authority] == '?' ||
  ------------------
  |  Branch (13288:20): [True: 33, False: 6]
  ------------------
13289|  1.25k|                   (url.is_special() && url_data[end_of_authority] == '\\')) {
  ------------------
  |  Branch (13289:21): [True: 6, False: 0]
  |  Branch (13289:41): [True: 6, False: 0]
  ------------------
13290|       |            // If atSignSeen is true and authority_view is the empty string,
13291|       |            // validation error, return failure.
13292|  1.25k|            if (at_sign_seen && authority_view.empty()) {
  ------------------
  |  Branch (13292:17): [True: 1.10k, False: 150]
  |  Branch (13292:33): [True: 350, False: 759]
  ------------------
13293|    350|              url.is_valid = false;
13294|    350|              return url;
13295|    350|            }
13296|    909|            state = state::HOST;
13297|    909|            break;
13298|  1.25k|          }
13299|  6.92k|          if (end_of_authority == input_size) {
  ------------------
  |  Branch (13299:15): [True: 0, False: 6.92k]
  ------------------
13300|      0|            if constexpr (store_values) {
13301|      0|              if (fragment.has_value()) {
  ------------------
  |  Branch (13301:19): [True: 0, False: 0]
  ------------------
13302|      0|                url.update_unencoded_base_hash(*fragment);
13303|      0|              }
13304|      0|            }
13305|      0|            enforce_max_input_length();
13306|      0|            return url;
13307|      0|          }
13308|  6.92k|          input_position = end_of_authority + 1;
13309|  6.92k|        } while (true);
  ------------------
  |  Branch (13309:18): [True: 6.92k, Folded]
  ------------------
13310|       |
13311|    909|        break;
13312|  1.25k|      }
13313|    909|      case state::SPECIAL_RELATIVE_OR_AUTHORITY: {
  ------------------
  |  Branch (13313:7): [True: 448, False: 168k]
  ------------------
13314|    448|        ada_log("SPECIAL_RELATIVE_OR_AUTHORITY ",
13315|    448|                helpers::substring(url_data, input_position));
13316|       |
13317|       |        // If c is U+002F (/) and remaining starts with U+002F (/),
13318|       |        // then set state to special authority ignore slashes state and increase
13319|       |        // pointer by 1.
13320|    448|        if (url_data.substr(input_position, 2) == "//") {
  ------------------
  |  Branch (13320:13): [True: 360, False: 88]
  ------------------
13321|    360|          state = state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
13322|    360|          input_position += 2;
13323|    360|        } else {
13324|       |          // Otherwise, validation error, set state to relative state and
13325|       |          // decrease pointer by 1.
13326|     88|          state = state::RELATIVE_SCHEME;
13327|     88|        }
13328|       |
13329|    448|        break;
13330|  1.25k|      }
13331|  2.24k|      case state::PATH_OR_AUTHORITY: {
  ------------------
  |  Branch (13331:7): [True: 2.24k, False: 167k]
  ------------------
13332|  2.24k|        ada_log("PATH_OR_AUTHORITY ",
13333|  2.24k|                helpers::substring(url_data, input_position));
13334|       |
13335|       |        // If c is U+002F (/), then set state to authority state.
13336|  2.24k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13336:13): [True: 2.10k, False: 133]
  ------------------
13337|  2.10k|            (url_data[input_position] == '/')) {
  ------------------
  |  Branch (13337:13): [True: 914, False: 1.19k]
  ------------------
13338|    914|          state = state::AUTHORITY;
13339|    914|          input_position++;
13340|  1.32k|        } else {
13341|       |          // Otherwise, set state to path state, and decrease pointer by 1.
13342|  1.32k|          state = state::PATH;
13343|  1.32k|        }
13344|       |
13345|  2.24k|        break;
13346|  1.25k|      }
13347|    865|      case state::RELATIVE_SCHEME: {
  ------------------
  |  Branch (13347:7): [True: 865, False: 168k]
  ------------------
13348|    865|        ada_log("RELATIVE_SCHEME ",
13349|    865|                helpers::substring(url_data, input_position));
13350|       |
13351|       |        // Set url's scheme to base's scheme.
13352|    865|        url.copy_scheme(*base_url);
13353|       |
13354|       |        // If c is U+002F (/), then set state to relative slash state.
13355|    865|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13355:13): [True: 689, False: 176]
  ------------------
13356|       |            // NOLINTNEXTLINE(bugprone-branch-clone)
13357|    689|            (url_data[input_position] == '/')) {
  ------------------
  |  Branch (13357:13): [True: 67, False: 622]
  ------------------
13358|     67|          ada_log(
13359|     67|              "RELATIVE_SCHEME if c is U+002F (/), then set state to relative "
13360|     67|              "slash state");
13361|     67|          state = state::RELATIVE_SLASH;
13362|    798|        } else if (url.is_special() && (input_position != input_size) &&
  ------------------
  |  Branch (13362:20): [True: 647, False: 151]
  |  Branch (13362:40): [True: 508, False: 139]
  ------------------
13363|    508|                   (url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13363:20): [True: 2, False: 506]
  ------------------
13364|       |          // Otherwise, if url is special and c is U+005C (\), validation error,
13365|       |          // set state to relative slash state.
13366|      2|          ada_log(
13367|      2|              "RELATIVE_SCHEME  if url is special and c is U+005C, validation "
13368|      2|              "error, set state to relative slash state");
13369|      2|          state = state::RELATIVE_SLASH;
13370|    796|        } else {
13371|    796|          ada_log("RELATIVE_SCHEME otherwise");
13372|       |          // Set url's username to base's username, url's password to base's
13373|       |          // password, url's host to base's host, url's port to base's port,
13374|       |          // url's path to a clone of base's path, and url's query to base's
13375|       |          // query.
13376|       |          if constexpr (result_type_is_ada_url) {
13377|       |            url.username = base_url->username;
13378|       |            url.password = base_url->password;
13379|       |            url.host = base_url->host;
13380|       |            url.port = base_url->port;
13381|       |            // cloning the base path includes cloning the has_opaque_path flag
13382|       |            url.has_opaque_path = base_url->has_opaque_path;
13383|       |            url.path = base_url->path;
13384|       |            url.query = base_url->query;
13385|    796|          } else {
13386|    796|            url.update_base_authority(base_url->get_href(),
13387|    796|                                      base_url->get_components());
13388|    796|            url.update_host_to_base_host(base_url->get_hostname());
13389|    796|            url.update_base_port(base_url->retrieve_base_port());
13390|       |            // cloning the base path includes cloning the has_opaque_path flag
13391|    796|            url.has_opaque_path = base_url->has_opaque_path;
13392|    796|            url.update_base_pathname(base_url->get_pathname());
13393|    796|            if (base_url->has_search()) {
  ------------------
  |  Branch (13393:17): [True: 82, False: 714]
  ------------------
13394|       |              // get_search() returns "" for an empty query string (URL ends
13395|       |              // with '?'). update_base_search("") would incorrectly clear the
13396|       |              // query, so pass "?" to preserve the empty query distinction.
13397|     82|              auto s = base_url->get_search();
13398|     82|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (13398:38): [True: 39, False: 43]
  ------------------
13399|     82|            }
13400|    796|          }
13401|       |
13402|    796|          url.has_opaque_path = base_url->has_opaque_path;
13403|       |
13404|       |          // If c is U+003F (?), then set url's query to the empty string, and
13405|       |          // state to query state.
13406|    796|          if ((input_position != input_size) &&
  ------------------
  |  Branch (13406:15): [True: 620, False: 176]
  ------------------
13407|    620|              (url_data[input_position] == '?')) {
  ------------------
  |  Branch (13407:15): [True: 73, False: 547]
  ------------------
13408|     73|            state = state::QUERY;
13409|     73|          }
13410|       |          // Otherwise, if c is not the EOF code point:
13411|    723|          else if (input_position != input_size) {
  ------------------
  |  Branch (13411:20): [True: 547, False: 176]
  ------------------
13412|       |            // Set url's query to null.
13413|    547|            url.clear_search();
13414|       |            if constexpr (result_type_is_ada_url) {
13415|       |              // Shorten url's path.
13416|       |              helpers::shorten_path(url.path, url.type);
13417|    547|            } else {
13418|    547|              std::string_view path = url.get_pathname();
13419|    547|              if (helpers::shorten_path(path, url.type)) {
  ------------------
  |  Branch (13419:19): [True: 542, False: 5]
  ------------------
13420|    542|                url.update_base_pathname(std::move(std::string(path)));
13421|    542|              }
13422|    547|            }
13423|       |            // Set state to path state and decrease pointer by 1.
13424|    547|            state = state::PATH;
13425|    547|            break;
13426|    547|          }
13427|    796|        }
13428|    318|        input_position++;
13429|    318|        break;
13430|    865|      }
13431|     69|      case state::RELATIVE_SLASH: {
  ------------------
  |  Branch (13431:7): [True: 69, False: 169k]
  ------------------
13432|     69|        ada_log("RELATIVE_SLASH ",
13433|     69|                helpers::substring(url_data, input_position));
13434|       |
13435|       |        // If url is special and c is U+002F (/) or U+005C (\), then:
13436|       |        // NOLINTNEXTLINE(bugprone-branch-clone)
13437|     69|        if (url.is_special() && (input_position != input_size) &&
  ------------------
  |  Branch (13437:13): [True: 48, False: 21]
  |  Branch (13437:33): [True: 33, False: 15]
  ------------------
13438|     33|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13438:14): [True: 3, False: 30]
  ------------------
13439|     30|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13439:14): [True: 2, False: 28]
  ------------------
13440|       |          // Set state to special authority ignore slashes state.
13441|      5|          state = state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
13442|      5|        }
13443|       |        // Otherwise, if c is U+002F (/), then set state to authority state.
13444|     64|        else if ((input_position != input_size) &&
  ------------------
  |  Branch (13444:18): [True: 43, False: 21]
  ------------------
13445|     43|                 (url_data[input_position] == '/')) {
  ------------------
  |  Branch (13445:18): [True: 5, False: 38]
  ------------------
13446|      5|          state = state::AUTHORITY;
13447|      5|        }
13448|       |        // Otherwise, set
13449|       |        // - url's username to base's username,
13450|       |        // - url's password to base's password,
13451|       |        // - url's host to base's host,
13452|       |        // - url's port to base's port,
13453|       |        // - state to path state, and then, decrease pointer by 1.
13454|     59|        else {
13455|       |          if constexpr (result_type_is_ada_url) {
13456|       |            url.username = base_url->username;
13457|       |            url.password = base_url->password;
13458|       |            url.host = base_url->host;
13459|       |            url.port = base_url->port;
13460|     59|          } else {
13461|     59|            url.update_base_authority(base_url->get_href(),
13462|     59|                                      base_url->get_components());
13463|     59|            url.update_host_to_base_host(base_url->get_hostname());
13464|     59|            url.update_base_port(base_url->retrieve_base_port());
13465|     59|          }
13466|     59|          state = state::PATH;
13467|     59|          break;
13468|     59|        }
13469|       |
13470|     10|        input_position++;
13471|     10|        break;
13472|     69|      }
13473|  12.8k|      case state::SPECIAL_AUTHORITY_SLASHES: {
  ------------------
  |  Branch (13473:7): [True: 12.8k, False: 156k]
  ------------------
13474|  12.8k|        ada_log("SPECIAL_AUTHORITY_SLASHES ",
13475|  12.8k|                helpers::substring(url_data, input_position));
13476|       |
13477|       |        // If c is U+002F (/) and remaining starts with U+002F (/),
13478|       |        // then set state to special authority ignore slashes state and increase
13479|       |        // pointer by 1.
13480|  12.8k|        if (url_data.substr(input_position, 2) == "//") {
  ------------------
  |  Branch (13480:13): [True: 3.31k, False: 9.52k]
  ------------------
13481|  3.31k|          input_position += 2;
13482|  3.31k|        }
13483|       |
13484|  12.8k|        [[fallthrough]];
13485|  12.8k|      }
13486|  13.2k|      case state::SPECIAL_AUTHORITY_IGNORE_SLASHES: {
  ------------------
  |  Branch (13486:7): [True: 365, False: 168k]
  ------------------
13487|  13.2k|        ada_log("SPECIAL_AUTHORITY_IGNORE_SLASHES ",
13488|  13.2k|                helpers::substring(url_data, input_position));
13489|       |
13490|       |        // If c is neither U+002F (/) nor U+005C (\), then set state to
13491|       |        // authority state and decrease pointer by 1.
13492|  14.1k|        while ((input_position != input_size) &&
  ------------------
  |  Branch (13492:16): [True: 14.0k, False: 95]
  ------------------
13493|  14.0k|               ((url_data[input_position] == '/') ||
  ------------------
  |  Branch (13493:17): [True: 560, False: 13.5k]
  ------------------
13494|  13.5k|                (url_data[input_position] == '\\'))) {
  ------------------
  |  Branch (13494:17): [True: 409, False: 13.1k]
  ------------------
13495|    969|          input_position++;
13496|    969|        }
13497|  13.2k|        state = state::AUTHORITY;
13498|       |
13499|  13.2k|        break;
13500|  12.8k|      }
13501|  1.24k|      case state::QUERY: {
  ------------------
  |  Branch (13501:7): [True: 1.24k, False: 168k]
  ------------------
13502|  1.24k|        ada_log("QUERY ", helpers::substring(url_data, input_position));
13503|  1.24k|        if constexpr (store_values) {
13504|       |          // Let queryPercentEncodeSet be the special-query percent-encode set
13505|       |          // if url is special; otherwise the query percent-encode set.
13506|  1.24k|          const uint8_t* query_percent_encode_set =
13507|  1.24k|              url.is_special() ? character_sets::SPECIAL_QUERY_PERCENT_ENCODE
  ------------------
  |  Branch (13507:15): [True: 849, False: 400]
  ------------------
13508|  1.24k|                               : character_sets::QUERY_PERCENT_ENCODE;
13509|       |
13510|       |          // Percent-encode after encoding, with encoding, buffer, and
13511|       |          // queryPercentEncodeSet, and append the result to url's query.
13512|  1.24k|          url.update_base_search(url_data.substr(input_position),
13513|  1.24k|                                 query_percent_encode_set);
13514|  1.24k|          ada_log("QUERY update_base_search completed ");
13515|  1.24k|          if (fragment.has_value()) {
  ------------------
  |  Branch (13515:15): [True: 350, False: 899]
  ------------------
13516|    350|            url.update_unencoded_base_hash(*fragment);
13517|    350|          }
13518|  1.24k|        }
13519|  1.24k|        enforce_max_input_length();
13520|  1.24k|        return url;
13521|  12.8k|      }
13522|  13.7k|      case state::HOST: {
  ------------------
  |  Branch (13522:7): [True: 13.7k, False: 155k]
  ------------------
13523|  13.7k|        ada_log("HOST ", helpers::substring(url_data, input_position));
13524|       |
13525|  13.7k|        std::string_view host_view = url_data.substr(input_position);
13526|  13.7k|        auto [location, found_colon] =
13527|  13.7k|            helpers::get_host_delimiter_location(url.is_special(), host_view);
13528|  13.7k|        input_position = (location != std::string_view::npos)
  ------------------
  |  Branch (13528:26): [True: 13.7k, False: 0]
  ------------------
13529|  13.7k|                             ? input_position + location
13530|  13.7k|                             : input_size;
13531|       |        // Otherwise, if c is U+003A (:) and insideBrackets is false, then:
13532|       |        // Note: the 'found_colon' value is true if and only if a colon was
13533|       |        // encountered while not inside brackets.
13534|  13.7k|        if (found_colon) {
  ------------------
  |  Branch (13534:13): [True: 2.59k, False: 11.1k]
  ------------------
13535|       |          // If buffer is the empty string, validation error, return failure.
13536|       |          // Let host be the result of host parsing buffer with url is not
13537|       |          // special.
13538|  2.59k|          ada_log("HOST parsing ", host_view);
13539|  2.59k|          if (!url.parse_host(host_view)) {
  ------------------
  |  Branch (13539:15): [True: 254, False: 2.34k]
  ------------------
13540|    254|            return url;
13541|    254|          }
13542|  2.34k|          ada_log("HOST parsing results in ", url.get_hostname());
13543|       |          // Set url's host to host, buffer to the empty string, and state to
13544|       |          // port state.
13545|  2.34k|          state = state::PORT;
13546|  2.34k|          input_position++;
13547|  2.34k|        }
13548|       |        // Otherwise, if one of the following is true:
13549|       |        // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
13550|       |        // - url is special and c is U+005C (\)
13551|       |        // The get_host_delimiter_location function either brings us to
13552|       |        // the colon outside of the bracket, or to one of those characters.
13553|  11.1k|        else {
13554|       |          // If url is special and host_view is the empty string, validation
13555|       |          // error, return failure.
13556|  11.1k|          if (host_view.empty() && url.is_special()) {
  ------------------
  |  Branch (13556:15): [True: 228, False: 10.9k]
  |  Branch (13556:36): [True: 102, False: 126]
  ------------------
13557|    102|            url.is_valid = false;
13558|    102|            return url;
13559|    102|          }
13560|  11.0k|          ada_log("HOST parsing ", host_view, " href=", url.get_href());
13561|       |          // Let host be the result of host parsing host_view with url is not
13562|       |          // special.
13563|  11.0k|          if (host_view.empty()) {
  ------------------
  |  Branch (13563:15): [True: 126, False: 10.9k]
  ------------------
13564|    126|            url.update_base_hostname("");
13565|  10.9k|          } else if (!url.parse_host(host_view)) {
  ------------------
  |  Branch (13565:22): [True: 2.29k, False: 8.65k]
  ------------------
13566|  2.29k|            return url;
13567|  2.29k|          }
13568|  8.78k|          ada_log("HOST parsing results in ", url.get_hostname(),
13569|  8.78k|                  " href=", url.get_href());
13570|       |
13571|       |          // Set url's host to host, and state to path start state.
13572|  8.78k|          state = state::PATH_START;
13573|  8.78k|        }
13574|       |
13575|  11.1k|        break;
13576|  13.7k|      }
13577|  11.1k|      case state::OPAQUE_PATH: {
  ------------------
  |  Branch (13577:7): [True: 3.22k, False: 166k]
  ------------------
13578|  3.22k|        ada_log("OPAQUE_PATH ", helpers::substring(url_data, input_position));
13579|       |        // Opaque path, query, and fragment are structurally always valid:
13580|       |        // the parser would just percent-encode whatever is there. When we
13581|       |        // are not storing values (can_parse), we can return immediately.
13582|       |        // We must set has_opaque_path = true before returning so that when
13583|       |        // this URL is used as an internal base inside can_parse, NO_SCHEME
13584|       |        // correctly rejects relative inputs against an opaque-path base
13585|       |        // (e.g. can_parse("", &"W:") must return false).
13586|       |        if constexpr (!store_values) {
13587|       |          url.has_opaque_path = true;
13588|       |          return url;
13589|       |        }
13590|  3.22k|        std::string_view view = url_data.substr(input_position);
13591|       |        // If c is U+003F (?), then set url's query to the empty string and
13592|       |        // state to query state.
13593|  3.22k|        size_t location = view.find('?');
13594|  3.22k|        if (location != std::string_view::npos) {
  ------------------
  |  Branch (13594:13): [True: 253, False: 2.97k]
  ------------------
13595|    253|          view.remove_suffix(view.size() - location);
13596|    253|          state = state::QUERY;
13597|    253|          input_position += location + 1;
13598|  2.97k|        } else {
13599|  2.97k|          input_position = input_size + 1;
13600|  2.97k|        }
13601|  3.22k|        url.has_opaque_path = true;
13602|       |
13603|       |        // This is a really unlikely scenario in real world. We should not seek
13604|       |        // to optimize it.
13605|  3.22k|        if (view.ends_with(' ')) {
  ------------------
  |  Branch (13605:13): [True: 116, False: 3.11k]
  ------------------
13606|    116|          std::string modified_view =
13607|    116|              std::string(view.substr(0, view.size() - 1)) + "%20";
13608|    116|          url.update_base_pathname(unicode::percent_encode(
13609|    116|              modified_view, character_sets::C0_CONTROL_PERCENT_ENCODE));
13610|  3.11k|        } else {
13611|  3.11k|          url.update_base_pathname(unicode::percent_encode(
13612|  3.11k|              view, character_sets::C0_CONTROL_PERCENT_ENCODE));
13613|  3.11k|        }
13614|  3.22k|        break;
13615|  13.7k|      }
13616|  2.34k|      case state::PORT: {
  ------------------
  |  Branch (13616:7): [True: 2.34k, False: 166k]
  ------------------
13617|  2.34k|        ada_log("PORT ", helpers::substring(url_data, input_position));
13618|  2.34k|        std::string_view port_view = url_data.substr(input_position);
13619|  2.34k|        input_position += url.parse_port(port_view, true);
13620|  2.34k|        if (!url.is_valid) {
  ------------------
  |  Branch (13620:13): [True: 132, False: 2.21k]
  ------------------
13621|    132|          return url;
13622|    132|        }
13623|  2.21k|        state = state::PATH_START;
13624|  2.21k|        [[fallthrough]];
13625|  2.21k|      }
13626|  12.9k|      case state::PATH_START: {
  ------------------
  |  Branch (13626:7): [True: 10.7k, False: 158k]
  ------------------
13627|  12.9k|        ada_log("PATH_START ", helpers::substring(url_data, input_position));
13628|       |        // Path, query, and fragment are structurally always valid: the
13629|       |        // parser would just percent-encode whatever is there. When we are
13630|       |        // not storing values (can_parse), we can return immediately since
13631|       |        // no subsequent state can invalidate the URL.
13632|       |        if constexpr (!store_values) {
13633|       |          return url;
13634|       |        }
13635|       |
13636|       |        // If url is special, then:
13637|  12.9k|        if (url.is_special()) {
  ------------------
  |  Branch (13637:13): [True: 12.1k, False: 781]
  ------------------
13638|       |          // Set state to path state.
13639|  12.1k|          state = state::PATH;
13640|       |
13641|       |          // Optimization: Avoiding going into PATH state improves the
13642|       |          // performance of urls ending with /.
13643|  12.1k|          if (input_position == input_size) {
  ------------------
  |  Branch (13643:15): [True: 6.43k, False: 5.72k]
  ------------------
13644|  6.43k|            if constexpr (store_values) {
13645|  6.43k|              url.update_base_pathname("/");
13646|  6.43k|              if (fragment.has_value()) {
  ------------------
  |  Branch (13646:19): [True: 173, False: 6.26k]
  ------------------
13647|    173|                url.update_unencoded_base_hash(*fragment);
13648|    173|              }
13649|  6.43k|            }
13650|  6.43k|            enforce_max_input_length();
13651|  6.43k|            return url;
13652|  6.43k|          }
13653|       |          // If c is neither U+002F (/) nor U+005C (\), then decrease pointer
13654|       |          // by 1. We know that (input_position == input_size) is impossible
13655|       |          // here, because of the previous if-check.
13656|  5.72k|          if ((url_data[input_position] != '/') &&
  ------------------
  |  Branch (13656:15): [True: 443, False: 5.27k]
  ------------------
13657|    443|              (url_data[input_position] != '\\')) {
  ------------------
  |  Branch (13657:15): [True: 430, False: 13]
  ------------------
13658|    430|            break;
13659|    430|          }
13660|  5.72k|        }
13661|       |        // Otherwise, if state override is not given and c is U+003F (?),
13662|       |        // set url's query to the empty string and state to query state.
13663|    781|        else if ((input_position != input_size) &&
  ------------------
  |  Branch (13663:18): [True: 170, False: 611]
  ------------------
13664|    170|                 (url_data[input_position] == '?')) {
  ------------------
  |  Branch (13664:18): [True: 61, False: 109]
  ------------------
13665|     61|          state = state::QUERY;
13666|     61|        }
13667|       |        // Otherwise, if c is not the EOF code point:
13668|    720|        else if (input_position != input_size) {
  ------------------
  |  Branch (13668:18): [True: 109, False: 611]
  ------------------
13669|       |          // Set state to path state.
13670|    109|          state = state::PATH;
13671|       |
13672|       |          // If c is not U+002F (/), then decrease pointer by 1.
13673|    109|          if (url_data[input_position] != '/') {
  ------------------
  |  Branch (13673:15): [True: 0, False: 109]
  ------------------
13674|      0|            break;
13675|      0|          }
13676|    109|        }
13677|       |
13678|  6.07k|        input_position++;
13679|  6.07k|        break;
13680|  12.9k|      }
13681|  8.50k|      case state::PATH: {
  ------------------
  |  Branch (13681:7): [True: 8.50k, False: 160k]
  ------------------
13682|  8.50k|        ada_log("PATH ", helpers::substring(url_data, input_position));
13683|       |        // Path, query, and fragment are structurally always valid: the
13684|       |        // parser would just percent-encode whatever is there. When we are
13685|       |        // not storing values (can_parse), we can return immediately since
13686|       |        // no subsequent state can invalidate the URL.
13687|       |        if constexpr (!store_values) {
13688|       |          return url;
13689|       |        }
13690|  8.50k|        std::string_view view = url_data.substr(input_position);
13691|       |
13692|       |        // Most time, we do not need percent encoding.
13693|       |        // Furthermore, we can immediately locate the '?'.
13694|  8.50k|        size_t locofquestionmark = view.find('?');
13695|  8.50k|        if (locofquestionmark != std::string_view::npos) {
  ------------------
  |  Branch (13695:13): [True: 853, False: 7.65k]
  ------------------
13696|    853|          state = state::QUERY;
13697|    853|          view.remove_suffix(view.size() - locofquestionmark);
13698|    853|          input_position += locofquestionmark + 1;
13699|  7.65k|        } else {
13700|  7.65k|          input_position = input_size + 1;
13701|  7.65k|        }
13702|  8.50k|        if constexpr (store_values) {
13703|       |          if constexpr (result_type_is_ada_url) {
13704|       |            helpers::parse_prepared_path(view, url.type, url.path);
13705|  8.50k|          } else {
13706|  8.50k|            url.consume_prepared_path(view);
13707|  8.50k|            ADA_ASSERT_TRUE(url.validate());
13708|  8.50k|          }
13709|  8.50k|        }
13710|  8.50k|        break;
13711|  12.9k|      }
13712|  2.25k|      case state::FILE_SLASH: {
  ------------------
  |  Branch (13712:7): [True: 2.25k, False: 167k]
  ------------------
13713|  2.25k|        ada_log("FILE_SLASH ", helpers::substring(url_data, input_position));
13714|       |
13715|       |        // If c is U+002F (/) or U+005C (\), then:
13716|  2.25k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13716:13): [True: 2.18k, False: 70]
  ------------------
13717|  2.18k|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13717:14): [True: 2.13k, False: 48]
  ------------------
13718|  2.14k|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13718:14): [True: 6, False: 42]
  ------------------
13719|  2.14k|          ada_log("FILE_SLASH c is U+002F or U+005C");
13720|       |          // Set state to file host state.
13721|  2.14k|          state = state::FILE_HOST;
13722|  2.14k|          input_position++;
13723|  2.14k|        } else {
13724|    112|          ada_log("FILE_SLASH otherwise");
13725|       |          // If base is non-null and base's scheme is "file", then:
13726|       |          // Note: it is unsafe to do base_url->scheme unless you know that
13727|       |          // base_url_has_value() is true.
13728|    112|          if (base_url != nullptr && base_url->type == scheme::type::FILE) {
  ------------------
  |  Branch (13728:15): [True: 87, False: 25]
  |  Branch (13728:38): [True: 84, False: 3]
  ------------------
13729|       |            // Set url's host to base's host.
13730|       |            if constexpr (result_type_is_ada_url) {
13731|       |              url.host = base_url->host;
13732|     84|            } else {
13733|     84|              url.update_host_to_base_host(base_url->get_host());
13734|     84|            }
13735|       |            // If the code point substring from pointer to the end of input does
13736|       |            // not start with a Windows drive letter and base's path[0] is a
13737|       |            // normalized Windows drive letter, then append base's path[0] to
13738|       |            // url's path.
13739|     84|            if (!base_url->get_pathname().empty()) {
  ------------------
  |  Branch (13739:17): [True: 84, False: 0]
  ------------------
13740|     84|              if (!checkers::is_windows_drive_letter(
  ------------------
  |  Branch (13740:19): [True: 79, False: 5]
  ------------------
13741|     84|                      url_data.substr(input_position))) {
13742|     79|                std::string_view first_base_url_path =
13743|     79|                    base_url->get_pathname().substr(1);
13744|     79|                size_t loc = first_base_url_path.find('/');
13745|     79|                if (loc != std::string_view::npos) {
  ------------------
  |  Branch (13745:21): [True: 12, False: 67]
  ------------------
13746|     12|                  helpers::resize(first_base_url_path, loc);
13747|     12|                }
13748|     79|                if (checkers::is_normalized_windows_drive_letter(
  ------------------
  |  Branch (13748:21): [True: 3, False: 76]
  ------------------
13749|     79|                        first_base_url_path)) {
13750|       |                  if constexpr (result_type_is_ada_url) {
13751|       |                    url.path += '/';
13752|       |                    url.path += first_base_url_path;
13753|      3|                  } else {
13754|      3|                    url.append_base_pathname(
13755|      3|                        helpers::concat("/", first_base_url_path));
13756|      3|                  }
13757|      3|                }
13758|     79|              }
13759|     84|            }
13760|     84|          }
13761|       |
13762|       |          // Set state to path state, and decrease pointer by 1.
13763|    112|          state = state::PATH;
13764|    112|        }
13765|       |
13766|  2.25k|        break;
13767|  12.9k|      }
13768|  2.14k|      case state::FILE_HOST: {
  ------------------
  |  Branch (13768:7): [True: 2.14k, False: 167k]
  ------------------
13769|  2.14k|        ada_log("FILE_HOST ", helpers::substring(url_data, input_position));
13770|  2.14k|        std::string_view view = url_data.substr(input_position);
13771|       |
13772|  2.14k|        size_t location = view.find_first_of("/\\?");
13773|  2.14k|        std::string_view file_host_buffer = view.substr(
13774|  2.14k|            0, (location != std::string_view::npos) ? location : view.size());
  ------------------
  |  Branch (13774:16): [True: 924, False: 1.22k]
  ------------------
13775|       |
13776|  2.14k|        if (checkers::is_windows_drive_letter(file_host_buffer)) {
  ------------------
  |  Branch (13776:13): [True: 12, False: 2.13k]
  ------------------
13777|     12|          state = state::PATH;
13778|  2.13k|        } else if (file_host_buffer.empty()) {
  ------------------
  |  Branch (13778:20): [True: 274, False: 1.85k]
  ------------------
13779|       |          // Set url's host to the empty string.
13780|       |          if constexpr (result_type_is_ada_url) {
13781|       |            url.host = "";
13782|    274|          } else {
13783|    274|            url.update_base_hostname("");
13784|    274|          }
13785|       |          // Set state to path start state.
13786|    274|          state = state::PATH_START;
13787|  1.85k|        } else {
13788|  1.85k|          size_t consumed_bytes = file_host_buffer.size();
13789|  1.85k|          input_position += consumed_bytes;
13790|       |          // Let host be the result of host parsing buffer with url is not
13791|       |          // special.
13792|  1.85k|          if (!url.parse_host(file_host_buffer)) {
  ------------------
  |  Branch (13792:15): [True: 191, False: 1.66k]
  ------------------
13793|    191|            return url;
13794|    191|          }
13795|       |
13796|       |          if constexpr (result_type_is_ada_url) {
13797|       |            // If host is "localhost", then set host to the empty string.
13798|       |            if (url.host.has_value() && url.host.value() == "localhost") {
13799|       |              url.host = "";
13800|       |            }
13801|  1.66k|          } else {
13802|  1.66k|            if (url.get_hostname() == "localhost") {
  ------------------
  |  Branch (13802:17): [True: 12, False: 1.65k]
  ------------------
13803|     12|              url.update_base_hostname("");
13804|     12|            }
13805|  1.66k|          }
13806|       |
13807|       |          // Set buffer to the empty string and state to path start state.
13808|  1.66k|          state = state::PATH_START;
13809|  1.66k|        }
13810|       |
13811|  1.95k|        break;
13812|  2.14k|      }
13813|  2.95k|      case state::FILE: {
  ------------------
  |  Branch (13813:7): [True: 2.95k, False: 166k]
  ------------------
13814|  2.95k|        ada_log("FILE ", helpers::substring(url_data, input_position));
13815|  2.95k|        std::string_view file_view = url_data.substr(input_position);
13816|       |
13817|  2.95k|        url.set_protocol_as_file();
13818|       |        if constexpr (result_type_is_ada_url) {
13819|       |          // Set url's host to the empty string.
13820|       |          url.host = "";
13821|  2.95k|        } else {
13822|  2.95k|          url.update_base_hostname("");
13823|  2.95k|        }
13824|       |        // If c is U+002F (/) or U+005C (\), then:
13825|  2.95k|        if (input_position != input_size &&
  ------------------
  |  Branch (13825:13): [True: 2.81k, False: 137]
  ------------------
13826|  2.81k|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13826:14): [True: 2.25k, False: 562]
  ------------------
13827|  2.25k|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13827:14): [True: 6, False: 556]
  ------------------
13828|  2.25k|          ada_log("FILE c is U+002F or U+005C");
13829|       |          // Set state to file slash state.
13830|  2.25k|          state = state::FILE_SLASH;
13831|  2.25k|        }
13832|       |        // Otherwise, if base is non-null and base's scheme is "file":
13833|    693|        else if (base_url != nullptr && base_url->type == scheme::type::FILE) {
  ------------------
  |  Branch (13833:18): [True: 267, False: 426]
  |  Branch (13833:41): [True: 199, False: 68]
  ------------------
13834|       |          // Set url's host to base's host, url's path to a clone of base's
13835|       |          // path, and url's query to base's query.
13836|    199|          ada_log("FILE base non-null");
13837|       |          if constexpr (result_type_is_ada_url) {
13838|       |            url.host = base_url->host;
13839|       |            url.path = base_url->path;
13840|       |            url.query = base_url->query;
13841|    199|          } else {
13842|    199|            url.update_host_to_base_host(base_url->get_hostname());
13843|    199|            url.update_base_pathname(base_url->get_pathname());
13844|    199|            if (base_url->has_search()) {
  ------------------
  |  Branch (13844:17): [True: 62, False: 137]
  ------------------
13845|       |              // get_search() returns "" for an empty query string (URL ends
13846|       |              // with '?'). update_base_search("") would incorrectly clear the
13847|       |              // query, so pass "?" to preserve the empty query distinction.
13848|     62|              auto s = base_url->get_search();
13849|     62|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (13849:38): [True: 21, False: 41]
  ------------------
13850|     62|            }
13851|    199|          }
13852|    199|          url.has_opaque_path = base_url->has_opaque_path;
13853|       |
13854|       |          // If c is U+003F (?), then set url's query to the empty string and
13855|       |          // state to query state.
13856|    199|          if (input_position != input_size && url_data[input_position] == '?') {
  ------------------
  |  Branch (13856:15): [True: 136, False: 63]
  |  Branch (13856:47): [True: 9, False: 127]
  ------------------
13857|      9|            state = state::QUERY;
13858|      9|          }
13859|       |          // Otherwise, if c is not the EOF code point:
13860|    190|          else if (input_position != input_size) {
  ------------------
  |  Branch (13860:20): [True: 127, False: 63]
  ------------------
13861|       |            // Set url's query to null.
13862|    127|            url.clear_search();
13863|       |            // If the code point substring from pointer to the end of input does
13864|       |            // not start with a Windows drive letter, then shorten url's path.
13865|    127|            if (!checkers::is_windows_drive_letter(file_view)) {
  ------------------
  |  Branch (13865:17): [True: 107, False: 20]
  ------------------
13866|       |              if constexpr (result_type_is_ada_url) {
13867|       |                helpers::shorten_path(url.path, url.type);
13868|    107|              } else {
13869|    107|                std::string_view path = url.get_pathname();
13870|    107|                if (helpers::shorten_path(path, url.type)) {
  ------------------
  |  Branch (13870:21): [True: 104, False: 3]
  ------------------
13871|    104|                  url.update_base_pathname(std::move(std::string(path)));
13872|    104|                }
13873|    107|              }
13874|    107|            }
13875|       |            // Otherwise:
13876|     20|            else {
13877|       |              // Set url's path to an empty list.
13878|     20|              url.clear_pathname();
13879|     20|            }
13880|       |
13881|       |            // Set state to path state and decrease pointer by 1.
13882|    127|            state = state::PATH;
13883|    127|            break;
13884|    127|          }
13885|    199|        }
13886|       |        // Otherwise, set state to path state, and decrease pointer by 1.
13887|    494|        else {
13888|    494|          ada_log("FILE go to path");
13889|    494|          state = state::PATH;
13890|    494|          break;
13891|    494|        }
13892|       |
13893|  2.32k|        input_position++;
13894|  2.32k|        break;
13895|  2.95k|      }
13896|      0|      default:
  ------------------
  |  Branch (13896:7): [True: 0, False: 169k]
  ------------------
13897|      0|        unreachable();
13898|   169k|    }
13899|   169k|  }
13900|  17.0k|  if constexpr (store_values) {
13901|  17.0k|    if (fragment.has_value()) {
  ------------------
  |  Branch (13901:9): [True: 446, False: 16.5k]
  ------------------
13902|    446|      url.update_unencoded_base_hash(*fragment);
13903|    446|    }
13904|  17.0k|  }
13905|  17.0k|  enforce_max_input_length();
13906|  17.0k|  return url;
13907|  50.6k|}
_ZN3ada6parser14parse_url_implINS_14url_aggregatorELb0EEET_NSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEPKS3_:
12886|  31.0k|                           const result_type* base_url) {
12887|       |  // We can specialize the implementation per type.
12888|       |  // Important: result_type_is_ada_url is evaluated at *compile time*. This
12889|       |  // means that doing if constexpr(result_type_is_ada_url) { something } else {
12890|       |  // something else } is free (at runtime). This means that ada::url_aggregator
12891|       |  // and ada::url **do not have to support the exact same API**.
12892|  31.0k|  constexpr bool result_type_is_ada_url = std::is_same_v<url, result_type>;
12893|  31.0k|  constexpr bool result_type_is_ada_url_aggregator =
12894|  31.0k|      std::is_same_v<url_aggregator, result_type>;
12895|  31.0k|  static_assert(result_type_is_ada_url ||
12896|  31.0k|                result_type_is_ada_url_aggregator);  // We don't support
12897|       |                                                     // anything else for now.
12898|       |
12899|  31.0k|  ada_log("ada::parser::parse_url('", user_input, "' [", user_input.size(),
12900|  31.0k|          " bytes],", (base_url != nullptr ? base_url->to_string() : "null"),
12901|  31.0k|          ")");
12902|       |
12903|  31.0k|  result_type url{};
12904|       |
12905|  31.0k|  const uint32_t max_input_length = ada::get_max_input_length();
12906|       |
12907|       |  // Normalization (percent-encoding, IDNA) can push the serialized URL past
12908|       |  // max_input_length even when the input fit under it. The check at the end of
12909|       |  // the state machine covers URLs that run to completion, but several states
12910|       |  // return early after appending a query or fragment, so run the same check on
12911|       |  // those exits too. Without this, a query- or fragment-terminated URL such as
12912|       |  // file://x/?<...> or https://user@x/?<...> is accepted while the equivalent
12913|       |  // https://x/?<...> that takes the absolute fast path is rejected.
12914|  31.0k|  const auto enforce_max_input_length = [&]() {
12915|  31.0k|    if constexpr (store_values) {
12916|  31.0k|      if (url.is_valid) {
12917|  31.0k|        if constexpr (result_type_is_ada_url_aggregator) {
12918|  31.0k|          if (url.buffer.size() > max_input_length) [[unlikely]] {
12919|  31.0k|            url.is_valid = false;
12920|  31.0k|          }
12921|  31.0k|        } else {
12922|  31.0k|          if (url.get_href_size() > max_input_length) [[unlikely]] {
12923|  31.0k|            url.is_valid = false;
12924|  31.0k|          }
12925|  31.0k|        }
12926|  31.0k|      }
12927|  31.0k|    }
12928|  31.0k|  };
12929|       |
12930|       |  // We refuse to parse URL strings that exceed the maximum input length.
12931|       |  // By default, this is 4GB but can be configured via
12932|       |  // ada::set_max_input_length().
12933|  31.0k|  if (user_input.size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (12933:7): [True: 0, False: 31.0k]
  ------------------
12934|      0|    url.is_valid = false;
12935|      0|  }
12936|       |  // Going forward, user_input.size() is in [0,
12937|       |  // std::numeric_limits<uint32_t>::max). If we are provided with an invalid
12938|       |  // base, or the optional_url was invalid, we must return.
12939|  31.0k|  if (base_url != nullptr) {
  ------------------
  |  Branch (12939:7): [True: 4.45k, False: 26.5k]
  ------------------
12940|  4.45k|    url.is_valid &= base_url->is_valid;
12941|  4.45k|  }
12942|  31.0k|  if (!url.is_valid) {
  ------------------
  |  Branch (12942:7): [True: 0, False: 31.0k]
  ------------------
12943|      0|    return url;
12944|      0|  }
12945|       |
12946|       |  // Simple absolute / relative fast paths (before tabs/newline scan).
12947|       |  if constexpr (store_values) {
12948|       |    bool hit_fast_path = false;
12949|       |    if (base_url == nullptr) {
12950|       |      // IPv4/IPv6 and userinfo miss the fast path. Skip the never_inline
12951|       |      // call so those URLs (including SetHref) do not pay for a miss.
12952|       |      const auto* p = reinterpret_cast<const uint8_t*>(user_input.data());
12953|       |      const size_t n = user_input.size();
12954|       |      size_t host_start = 0;
12955|       |      if (n >= 8 && p[4] == ':' && p[5] == '/' && p[6] == '/') {
12956|       |        host_start = 7;
12957|       |      } else if (n >= 9 && p[5] == ':' && p[6] == '/' && p[7] == '/') {
12958|       |        host_start = 8;
12959|       |      }
12960|       |      const uint8_t host_first = host_start != 0 ? p[host_start] : 0;
12961|       |      const bool skip_ip =
12962|       |          host_first == '[' || (host_first >= '0' && host_first <= '9');
12963|       |      // Only scan for userinfo when the host is not an IP literal, so
12964|       |      // IPv4/IPv6 inputs skip the SIMD '@' check entirely.
12965|       |      hit_fast_path =
12966|       |          !skip_ip &&
12967|       |          !(host_start != 0 && authority_has_at(p, host_start, n)) &&
12968|       |          try_parse_simple_absolute(user_input, url);
12969|       |    } else {
12970|       |      hit_fast_path = try_parse_simple_relative(user_input, *base_url, url);
12971|       |    }
12972|       |    if (hit_fast_path) {
12973|       |      if constexpr (result_type_is_ada_url_aggregator) {
12974|       |        if (url.buffer.size() > max_input_length) [[unlikely]] {
12975|       |          url.is_valid = false;
12976|       |        }
12977|       |      } else {
12978|       |        // For a small absolute input, even worst-case normalization cannot
12979|       |        // exceed the limit: percent encoding expands at most 3x and IDNA at
12980|       |        // most 4.5x. Avoid traversing every stored component on the common
12981|       |        // default-limit path.
12982|       |        if ((base_url != nullptr ||
12983|       |             user_input.size() > static_cast<size_t>(max_input_length) / 5) &&
12984|       |            url.get_href_size() > max_input_length) [[unlikely]] {
12985|       |          url.is_valid = false;
12986|       |        }
12987|       |      }
12988|       |      return url;
12989|       |    }
12990|       |  }
12991|       |
12992|  31.0k|  state state = state::SCHEME_START;
12993|       |
12994|  31.0k|  std::string tmp_buffer;
12995|  31.0k|  std::string_view url_data;
12996|  31.0k|  if (unicode::has_tabs_or_newline(user_input)) [[unlikely]] {
  ------------------
  |  Branch (12996:7): [True: 379, False: 30.6k]
  ------------------
12997|    379|    tmp_buffer = user_input;
12998|       |    // Optimization opportunity: Instead of copying and then pruning, we could
12999|       |    // just directly build the string from user_input.
13000|    379|    helpers::remove_ascii_tab_or_newline(tmp_buffer);
13001|    379|    url_data = tmp_buffer;
13002|  30.6k|  } else [[likely]] {
13003|  30.6k|    url_data = user_input;
13004|  30.6k|  }
13005|       |
13006|       |  // Leading and trailing control characters are uncommon and easy to deal with
13007|       |  // (no performance concern).
13008|  31.0k|  helpers::trim_c0_whitespace(url_data);
13009|       |
13010|       |  if constexpr (result_type_is_ada_url_aggregator && store_values) {
13011|       |    // Most of the time, we just need user_input.size().
13012|       |    // In some instances, we may need a bit more.
13013|       |    ///////////////////////////
13014|       |    // This is *very* important. This line should *not* be removed
13015|       |    // hastily. There are principled reasons why reserve is important
13016|       |    // for performance. If you have a benchmark with small inputs,
13017|       |    // it may not matter, but in other instances, it could.
13018|       |    ////
13019|       |    // This rounds up to the next power of two.
13020|       |    // We know that user_input.size() is in [0,
13021|       |    // std::numeric_limits<uint32_t>::max).
13022|       |    uint32_t reserve_capacity =
13023|       |        (0xFFFFFFFF >>
13024|       |         helpers::leading_zeroes(uint32_t(1 | user_input.size()))) +
13025|       |        1;
13026|       |    url.reserve(reserve_capacity);
13027|       |  }
13028|       |
13029|       |  // Optimization opportunity. Most websites do not have fragment.
13030|  31.0k|  std::optional<std::string_view> fragment = helpers::prune_hash(url_data);
13031|       |  // We add it last so that an implementation like ada::url_aggregator
13032|       |  // can append it last to its internal buffer, thus improving performance.
13033|       |
13034|       |  // Here url_data no longer has its fragment.
13035|       |  // We are going to access the data from url_data (it is immutable).
13036|       |  // At any given time, we are pointing at byte 'input_position' in url_data.
13037|       |  // The input_position variable should range from 0 to input_size.
13038|       |  // It is illegal to access url_data at input_size.
13039|  31.0k|  size_t input_position = 0;
13040|  31.0k|  const size_t input_size = url_data.size();
13041|       |  // Keep running the following state machine by switching on state.
13042|       |  // If after a run pointer points to the EOF code point, go to the next step.
13043|       |  // Otherwise, increase pointer by 1 and continue with the state machine.
13044|       |  // We never decrement input_position.
13045|   133k|  while (input_position <= input_size) {
  ------------------
  |  Branch (13045:10): [True: 133k, False: 272]
  ------------------
13046|   133k|    ada_log("In parsing at ", input_position, " out of ", input_size,
13047|   133k|            " in state ", ada::to_string(state));
13048|   133k|    switch (state) {
13049|  31.0k|      case state::SCHEME_START: {
  ------------------
  |  Branch (13049:7): [True: 31.0k, False: 102k]
  ------------------
13050|  31.0k|        ada_log("SCHEME_START ", helpers::substring(url_data, input_position));
13051|       |        // If c is an ASCII alpha, append c, lowercased, to buffer, and set
13052|       |        // state to scheme state.
13053|  31.0k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13053:13): [True: 22.6k, False: 8.36k]
  ------------------
13054|  22.6k|            checkers::is_alpha(url_data[input_position])) {
  ------------------
  |  Branch (13054:13): [True: 21.8k, False: 789]
  ------------------
13055|  21.8k|          state = state::SCHEME;
13056|  21.8k|          input_position++;
13057|  21.8k|        } else {
13058|       |          // Otherwise, if state override is not given, set state to no scheme
13059|       |          // state and decrease pointer by 1.
13060|  9.15k|          state = state::NO_SCHEME;
13061|  9.15k|        }
13062|  31.0k|        break;
13063|      0|      }
13064|  21.8k|      case state::SCHEME: {
  ------------------
  |  Branch (13064:7): [True: 21.8k, False: 111k]
  ------------------
13065|  21.8k|        ada_log("SCHEME ", helpers::substring(url_data, input_position));
13066|       |        // If c is an ASCII alphanumeric, U+002B (+), U+002D (-), or U+002E (.),
13067|       |        // append c, lowercased, to buffer.
13068|  54.9k|        while ((input_position != input_size) &&
  ------------------
  |  Branch (13068:16): [True: 54.5k, False: 351]
  ------------------
13069|  54.5k|               (unicode::is_alnum_plus(url_data[input_position]))) {
  ------------------
  |  Branch (13069:16): [True: 33.0k, False: 21.5k]
  ------------------
13070|  33.0k|          input_position++;
13071|  33.0k|        }
13072|       |        // Otherwise, if c is U+003A (:), then:
13073|  21.8k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13073:13): [True: 21.5k, False: 351]
  ------------------
13074|  21.5k|            (url_data[input_position] == ':')) {
  ------------------
  |  Branch (13074:13): [True: 21.2k, False: 272]
  ------------------
13075|  21.2k|          ada_log("SCHEME the scheme should be ",
13076|  21.2k|                  url_data.substr(0, input_position));
13077|       |          if constexpr (result_type_is_ada_url) {
13078|       |            if (!url.parse_scheme(url_data.substr(0, input_position))) {
13079|       |              return url;
13080|       |            }
13081|  21.2k|          } else {
13082|       |            // we pass the colon along instead of painfully adding it back.
13083|  21.2k|            if (!url.parse_scheme_with_colon(
  ------------------
  |  Branch (13083:17): [True: 0, False: 21.2k]
  ------------------
13084|  21.2k|                    url_data.substr(0, input_position + 1))) {
13085|      0|              return url;
13086|      0|            }
13087|  21.2k|          }
13088|  21.2k|          ada_log("SCHEME the scheme is ", url.get_protocol());
13089|       |
13090|       |          // If url's scheme is "file", then:
13091|       |          // NOLINTNEXTLINE(bugprone-branch-clone)
13092|  21.2k|          if (url.type == scheme::type::FILE) {
  ------------------
  |  Branch (13092:15): [True: 2.68k, False: 18.5k]
  ------------------
13093|       |            // Set state to file state.
13094|  2.68k|            state = state::FILE;
13095|  2.68k|          }
13096|       |          // Otherwise, if url is special, base is non-null, and base's scheme
13097|       |          // is url's scheme: Note: Doing base_url->scheme is unsafe if base_url
13098|       |          // != nullptr is false.
13099|  18.5k|          else if (url.is_special() && base_url != nullptr &&
  ------------------
  |  Branch (13099:20): [True: 13.1k, False: 5.46k]
  |  Branch (13099:40): [True: 2.22k, False: 10.8k]
  ------------------
13100|  2.22k|                   base_url->type == url.type) {
  ------------------
  |  Branch (13100:20): [True: 448, False: 1.77k]
  ------------------
13101|       |            // Set state to special relative or authority state.
13102|    448|            state = state::SPECIAL_RELATIVE_OR_AUTHORITY;
13103|    448|          }
13104|       |          // Otherwise, if url is special, set state to special authority
13105|       |          // slashes state.
13106|  18.1k|          else if (url.is_special()) {
  ------------------
  |  Branch (13106:20): [True: 12.6k, False: 5.46k]
  ------------------
13107|  12.6k|            state = state::SPECIAL_AUTHORITY_SLASHES;
13108|  12.6k|          }
13109|       |          // Otherwise, if remaining starts with an U+002F (/), set state to
13110|       |          // path or authority state and increase pointer by 1.
13111|  5.46k|          else if (input_position + 1 < input_size &&
  ------------------
  |  Branch (13111:20): [True: 3.20k, False: 2.26k]
  ------------------
13112|  3.20k|                   url_data[input_position + 1] == '/') {
  ------------------
  |  Branch (13112:20): [True: 2.24k, False: 961]
  ------------------
13113|  2.24k|            state = state::PATH_OR_AUTHORITY;
13114|  2.24k|            input_position++;
13115|  2.24k|          }
13116|       |          // Otherwise, set url's path to the empty string and set state to
13117|       |          // opaque path state.
13118|  3.22k|          else {
13119|  3.22k|            state = state::OPAQUE_PATH;
13120|  3.22k|          }
13121|  21.2k|        }
13122|       |        // Otherwise, if state override is not given, set buffer to the empty
13123|       |        // string, state to no scheme state, and start over (from the first code
13124|       |        // point in input).
13125|    623|        else {
13126|    623|          state = state::NO_SCHEME;
13127|    623|          input_position = 0;
13128|    623|          break;
13129|    623|        }
13130|  21.2k|        input_position++;
13131|  21.2k|        break;
13132|  21.8k|      }
13133|  9.77k|      case state::NO_SCHEME: {
  ------------------
  |  Branch (13133:7): [True: 9.77k, False: 123k]
  ------------------
13134|  9.77k|        ada_log("NO_SCHEME ", helpers::substring(url_data, input_position));
13135|       |        // The fragment was pruned from url_data before the state machine ran,
13136|       |        // so 'c is U+0023 (#)' holds exactly when a fragment was found and
13137|       |        // nothing else remains in front of it.
13138|  9.77k|        const bool c_is_hash =
13139|  9.77k|            fragment.has_value() && input_position == input_size;
  ------------------
  |  Branch (13139:13): [True: 338, False: 9.44k]
  |  Branch (13139:37): [True: 131, False: 207]
  ------------------
13140|       |        // If base is null, or base has an opaque path and c is not U+0023 (#),
13141|       |        // validation error, return failure.
13142|  9.77k|        if (base_url == nullptr || (base_url->has_opaque_path && !c_is_hash)) {
  ------------------
  |  Branch (13142:13): [True: 8.37k, False: 1.40k]
  |  Branch (13142:37): [True: 101, False: 1.30k]
  |  Branch (13142:66): [True: 46, False: 55]
  ------------------
13143|  8.42k|          ada_log("NO_SCHEME validation error");
13144|  8.42k|          url.is_valid = false;
13145|  8.42k|          return url;
13146|  8.42k|        }
13147|       |        // Otherwise, if base has an opaque path and c is U+0023 (#),
13148|       |        // set url's scheme to base's scheme, url's path to base's path, url's
13149|       |        // query to base's query, and set state to fragment state.
13150|  1.35k|        else if (base_url->has_opaque_path && c_is_hash) {
  ------------------
  |  Branch (13150:18): [True: 55, False: 1.30k]
  |  Branch (13150:47): [True: 55, False: 0]
  ------------------
13151|     55|          ada_log("NO_SCHEME opaque base with fragment");
13152|     55|          url.copy_scheme(*base_url);
13153|     55|          url.has_opaque_path = base_url->has_opaque_path;
13154|       |
13155|       |          if constexpr (result_type_is_ada_url) {
13156|       |            url.path = base_url->path;
13157|       |            url.query = base_url->query;
13158|     55|          } else {
13159|     55|            url.update_base_pathname(base_url->get_pathname());
13160|     55|            if (base_url->has_search()) {
  ------------------
  |  Branch (13160:17): [True: 0, False: 55]
  ------------------
13161|       |              // get_search() returns "" for an empty query string (URL ends
13162|       |              // with '?'). update_base_search("") would incorrectly clear the
13163|       |              // query, so pass "?" to preserve the empty query distinction.
13164|      0|              auto s = base_url->get_search();
13165|      0|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (13165:38): [True: 0, False: 0]
  ------------------
13166|      0|            }
13167|     55|          }
13168|     55|          url.update_unencoded_base_hash(*fragment);
13169|     55|          enforce_max_input_length();
13170|     55|          return url;
13171|     55|        }
13172|       |        // Otherwise, if base's scheme is not "file", set state to relative
13173|       |        // state and decrease pointer by 1.
13174|       |        // NOLINTNEXTLINE(bugprone-branch-clone)
13175|  1.30k|        else if (base_url->type != scheme::type::FILE) {
  ------------------
  |  Branch (13175:18): [True: 1.03k, False: 264]
  ------------------
13176|  1.03k|          ada_log("NO_SCHEME non-file relative path");
13177|  1.03k|          state = state::RELATIVE_SCHEME;
13178|  1.03k|        }
13179|       |        // Otherwise, set state to file state and decrease pointer by 1.
13180|    264|        else {
13181|    264|          ada_log("NO_SCHEME file base type");
13182|    264|          state = state::FILE;
13183|    264|        }
13184|  1.30k|        break;
13185|  9.77k|      }
13186|  13.9k|      case state::AUTHORITY: {
  ------------------
  |  Branch (13186:7): [True: 13.9k, False: 119k]
  ------------------
13187|  13.9k|        ada_log("AUTHORITY ", helpers::substring(url_data, input_position));
13188|       |        // most URLs have no @. Having no @ tells us that we don't have to worry
13189|       |        // about AUTHORITY. Of course, we could have @ and still not have to
13190|       |        // worry about AUTHORITY.
13191|       |        // TODO: Instead of just collecting a bool, collect the location of the
13192|       |        // '@' and do something useful with it.
13193|       |        // TODO: We could do various processing early on, using a single pass
13194|       |        // over the string to collect information about it, e.g., telling us
13195|       |        // whether there is a @ and if so, where (or how many).
13196|       |
13197|       |        // Check if url data contains an @.
13198|  13.9k|        if (url_data.find('@', input_position) == std::string_view::npos) {
  ------------------
  |  Branch (13198:13): [True: 12.6k, False: 1.28k]
  ------------------
13199|  12.6k|          state = state::HOST;
13200|  12.6k|          break;
13201|  12.6k|        }
13202|  1.28k|        bool at_sign_seen{false};
13203|  1.28k|        bool password_token_seen{false};
13204|       |        /**
13205|       |         * We expect something of the sort...
13206|       |         * https://user:pass@example.com:1234/foo/bar?baz#quux
13207|       |         * --------^
13208|       |         */
13209|  8.21k|        do {
13210|  8.21k|          std::string_view view = url_data.substr(input_position);
13211|       |          // The delimiters are @, /, ? \\.
13212|  8.21k|          size_t location =
13213|  8.21k|              url.is_special() ? helpers::find_authority_delimiter_special(view)
  ------------------
  |  Branch (13213:15): [True: 7.25k, False: 955]
  ------------------
13214|  8.21k|                               : helpers::find_authority_delimiter(view);
13215|  8.21k|          std::string_view authority_view = view.substr(0, location);
13216|  8.21k|          size_t end_of_authority = input_position + authority_view.size();
13217|       |          // If c is U+0040 (@), then:
13218|  8.21k|          if ((end_of_authority != input_size) &&
  ------------------
  |  Branch (13218:15): [True: 7.39k, False: 812]
  ------------------
13219|  7.39k|              (url_data[end_of_authority] == '@')) {
  ------------------
  |  Branch (13219:15): [True: 6.92k, False: 470]
  ------------------
13220|       |            // If atSignSeen is true, then prepend "%40" to buffer.
13221|  6.92k|            if (at_sign_seen) {
  ------------------
  |  Branch (13221:17): [True: 5.81k, False: 1.10k]
  ------------------
13222|  5.81k|              if (password_token_seen) {
  ------------------
  |  Branch (13222:19): [True: 2.47k, False: 3.34k]
  ------------------
13223|       |                if constexpr (result_type_is_ada_url) {
13224|       |                  url.password += "%40";
13225|  2.47k|                } else {
13226|  2.47k|                  url.append_base_password("%40");
13227|  2.47k|                }
13228|  3.34k|              } else {
13229|       |                if constexpr (result_type_is_ada_url) {
13230|       |                  url.username += "%40";
13231|  3.34k|                } else {
13232|  3.34k|                  url.append_base_username("%40");
13233|  3.34k|                }
13234|  3.34k|              }
13235|  5.81k|            }
13236|       |
13237|  6.92k|            at_sign_seen = true;
13238|       |
13239|  6.92k|            if (!password_token_seen) {
  ------------------
  |  Branch (13239:17): [True: 4.45k, False: 2.47k]
  ------------------
13240|  4.45k|              size_t password_token_location = authority_view.find(':');
13241|  4.45k|              password_token_seen =
13242|  4.45k|                  password_token_location != std::string_view::npos;
13243|       |
13244|       |              if constexpr (store_values) {
13245|       |                if (!password_token_seen) {
13246|       |                  if constexpr (result_type_is_ada_url) {
13247|       |                    url.username += unicode::percent_encode(
13248|       |                        authority_view,
13249|       |                        character_sets::USERINFO_PERCENT_ENCODE);
13250|       |                  } else {
13251|       |                    url.append_base_username(unicode::percent_encode(
13252|       |                        authority_view,
13253|       |                        character_sets::USERINFO_PERCENT_ENCODE));
13254|       |                  }
13255|       |                } else {
13256|       |                  if constexpr (result_type_is_ada_url) {
13257|       |                    url.username += unicode::percent_encode(
13258|       |                        authority_view.substr(0, password_token_location),
13259|       |                        character_sets::USERINFO_PERCENT_ENCODE);
13260|       |                    url.password += unicode::percent_encode(
13261|       |                        authority_view.substr(password_token_location + 1),
13262|       |                        character_sets::USERINFO_PERCENT_ENCODE);
13263|       |                  } else {
13264|       |                    url.append_base_username(unicode::percent_encode(
13265|       |                        authority_view.substr(0, password_token_location),
13266|       |                        character_sets::USERINFO_PERCENT_ENCODE));
13267|       |                    url.append_base_password(unicode::percent_encode(
13268|       |                        authority_view.substr(password_token_location + 1),
13269|       |                        character_sets::USERINFO_PERCENT_ENCODE));
13270|       |                  }
13271|       |                }
13272|       |              }
13273|  4.45k|            } else if constexpr (store_values) {
13274|  2.47k|              if constexpr (result_type_is_ada_url) {
13275|  2.47k|                url.password += unicode::percent_encode(
13276|  2.47k|                    authority_view, character_sets::USERINFO_PERCENT_ENCODE);
13277|  2.47k|              } else {
13278|  2.47k|                url.append_base_password(unicode::percent_encode(
13279|  2.47k|                    authority_view, character_sets::USERINFO_PERCENT_ENCODE));
13280|  2.47k|              }
13281|  2.47k|            }
13282|  6.92k|          }
13283|       |          // Otherwise, if one of the following is true:
13284|       |          // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
13285|       |          // - url is special and c is U+005C (\)
13286|  1.28k|          else if (end_of_authority == input_size ||
  ------------------
  |  Branch (13286:20): [True: 812, False: 470]
  ------------------
13287|    470|                   url_data[end_of_authority] == '/' ||
  ------------------
  |  Branch (13287:20): [True: 428, False: 42]
  ------------------
13288|     42|                   url_data[end_of_authority] == '?' ||
  ------------------
  |  Branch (13288:20): [True: 36, False: 6]
  ------------------
13289|  1.28k|                   (url.is_special() && url_data[end_of_authority] == '\\')) {
  ------------------
  |  Branch (13289:21): [True: 6, False: 0]
  |  Branch (13289:41): [True: 6, False: 0]
  ------------------
13290|       |            // If atSignSeen is true and authority_view is the empty string,
13291|       |            // validation error, return failure.
13292|  1.28k|            if (at_sign_seen && authority_view.empty()) {
  ------------------
  |  Branch (13292:17): [True: 1.10k, False: 173]
  |  Branch (13292:33): [True: 350, False: 759]
  ------------------
13293|    350|              url.is_valid = false;
13294|    350|              return url;
13295|    350|            }
13296|    932|            state = state::HOST;
13297|    932|            break;
13298|  1.28k|          }
13299|  6.92k|          if (end_of_authority == input_size) {
  ------------------
  |  Branch (13299:15): [True: 0, False: 6.92k]
  ------------------
13300|       |            if constexpr (store_values) {
13301|       |              if (fragment.has_value()) {
13302|       |                url.update_unencoded_base_hash(*fragment);
13303|       |              }
13304|       |            }
13305|      0|            enforce_max_input_length();
13306|      0|            return url;
13307|      0|          }
13308|  6.92k|          input_position = end_of_authority + 1;
13309|  6.92k|        } while (true);
  ------------------
  |  Branch (13309:18): [True: 6.92k, Folded]
  ------------------
13310|       |
13311|    932|        break;
13312|  1.28k|      }
13313|    932|      case state::SPECIAL_RELATIVE_OR_AUTHORITY: {
  ------------------
  |  Branch (13313:7): [True: 448, False: 133k]
  ------------------
13314|    448|        ada_log("SPECIAL_RELATIVE_OR_AUTHORITY ",
13315|    448|                helpers::substring(url_data, input_position));
13316|       |
13317|       |        // If c is U+002F (/) and remaining starts with U+002F (/),
13318|       |        // then set state to special authority ignore slashes state and increase
13319|       |        // pointer by 1.
13320|    448|        if (url_data.substr(input_position, 2) == "//") {
  ------------------
  |  Branch (13320:13): [True: 360, False: 88]
  ------------------
13321|    360|          state = state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
13322|    360|          input_position += 2;
13323|    360|        } else {
13324|       |          // Otherwise, validation error, set state to relative state and
13325|       |          // decrease pointer by 1.
13326|     88|          state = state::RELATIVE_SCHEME;
13327|     88|        }
13328|       |
13329|    448|        break;
13330|  1.28k|      }
13331|  2.24k|      case state::PATH_OR_AUTHORITY: {
  ------------------
  |  Branch (13331:7): [True: 2.24k, False: 131k]
  ------------------
13332|  2.24k|        ada_log("PATH_OR_AUTHORITY ",
13333|  2.24k|                helpers::substring(url_data, input_position));
13334|       |
13335|       |        // If c is U+002F (/), then set state to authority state.
13336|  2.24k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13336:13): [True: 2.10k, False: 133]
  ------------------
13337|  2.10k|            (url_data[input_position] == '/')) {
  ------------------
  |  Branch (13337:13): [True: 914, False: 1.19k]
  ------------------
13338|    914|          state = state::AUTHORITY;
13339|    914|          input_position++;
13340|  1.32k|        } else {
13341|       |          // Otherwise, set state to path state, and decrease pointer by 1.
13342|  1.32k|          state = state::PATH;
13343|  1.32k|        }
13344|       |
13345|  2.24k|        break;
13346|  1.28k|      }
13347|  1.12k|      case state::RELATIVE_SCHEME: {
  ------------------
  |  Branch (13347:7): [True: 1.12k, False: 132k]
  ------------------
13348|  1.12k|        ada_log("RELATIVE_SCHEME ",
13349|  1.12k|                helpers::substring(url_data, input_position));
13350|       |
13351|       |        // Set url's scheme to base's scheme.
13352|  1.12k|        url.copy_scheme(*base_url);
13353|       |
13354|       |        // If c is U+002F (/), then set state to relative slash state.
13355|  1.12k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13355:13): [True: 915, False: 209]
  ------------------
13356|       |            // NOLINTNEXTLINE(bugprone-branch-clone)
13357|    915|            (url_data[input_position] == '/')) {
  ------------------
  |  Branch (13357:13): [True: 96, False: 819]
  ------------------
13358|     96|          ada_log(
13359|     96|              "RELATIVE_SCHEME if c is U+002F (/), then set state to relative "
13360|     96|              "slash state");
13361|     96|          state = state::RELATIVE_SLASH;
13362|  1.02k|        } else if (url.is_special() && (input_position != input_size) &&
  ------------------
  |  Branch (13362:20): [True: 877, False: 151]
  |  Branch (13362:40): [True: 705, False: 172]
  ------------------
13363|    705|                   (url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13363:20): [True: 2, False: 703]
  ------------------
13364|       |          // Otherwise, if url is special and c is U+005C (\), validation error,
13365|       |          // set state to relative slash state.
13366|      2|          ada_log(
13367|      2|              "RELATIVE_SCHEME  if url is special and c is U+005C, validation "
13368|      2|              "error, set state to relative slash state");
13369|      2|          state = state::RELATIVE_SLASH;
13370|  1.02k|        } else {
13371|  1.02k|          ada_log("RELATIVE_SCHEME otherwise");
13372|       |          // Set url's username to base's username, url's password to base's
13373|       |          // password, url's host to base's host, url's port to base's port,
13374|       |          // url's path to a clone of base's path, and url's query to base's
13375|       |          // query.
13376|       |          if constexpr (result_type_is_ada_url) {
13377|       |            url.username = base_url->username;
13378|       |            url.password = base_url->password;
13379|       |            url.host = base_url->host;
13380|       |            url.port = base_url->port;
13381|       |            // cloning the base path includes cloning the has_opaque_path flag
13382|       |            url.has_opaque_path = base_url->has_opaque_path;
13383|       |            url.path = base_url->path;
13384|       |            url.query = base_url->query;
13385|  1.02k|          } else {
13386|  1.02k|            url.update_base_authority(base_url->get_href(),
13387|  1.02k|                                      base_url->get_components());
13388|  1.02k|            url.update_host_to_base_host(base_url->get_hostname());
13389|  1.02k|            url.update_base_port(base_url->retrieve_base_port());
13390|       |            // cloning the base path includes cloning the has_opaque_path flag
13391|  1.02k|            url.has_opaque_path = base_url->has_opaque_path;
13392|  1.02k|            url.update_base_pathname(base_url->get_pathname());
13393|  1.02k|            if (base_url->has_search()) {
  ------------------
  |  Branch (13393:17): [True: 0, False: 1.02k]
  ------------------
13394|       |              // get_search() returns "" for an empty query string (URL ends
13395|       |              // with '?'). update_base_search("") would incorrectly clear the
13396|       |              // query, so pass "?" to preserve the empty query distinction.
13397|      0|              auto s = base_url->get_search();
13398|      0|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (13398:38): [True: 0, False: 0]
  ------------------
13399|      0|            }
13400|  1.02k|          }
13401|       |
13402|  1.02k|          url.has_opaque_path = base_url->has_opaque_path;
13403|       |
13404|       |          // If c is U+003F (?), then set url's query to the empty string, and
13405|       |          // state to query state.
13406|  1.02k|          if ((input_position != input_size) &&
  ------------------
  |  Branch (13406:15): [True: 817, False: 209]
  ------------------
13407|    817|              (url_data[input_position] == '?')) {
  ------------------
  |  Branch (13407:15): [True: 105, False: 712]
  ------------------
13408|    105|            state = state::QUERY;
13409|    105|          }
13410|       |          // Otherwise, if c is not the EOF code point:
13411|    921|          else if (input_position != input_size) {
  ------------------
  |  Branch (13411:20): [True: 712, False: 209]
  ------------------
13412|       |            // Set url's query to null.
13413|    712|            url.clear_search();
13414|       |            if constexpr (result_type_is_ada_url) {
13415|       |              // Shorten url's path.
13416|       |              helpers::shorten_path(url.path, url.type);
13417|    712|            } else {
13418|    712|              std::string_view path = url.get_pathname();
13419|    712|              if (helpers::shorten_path(path, url.type)) {
  ------------------
  |  Branch (13419:19): [True: 0, False: 712]
  ------------------
13420|      0|                url.update_base_pathname(std::move(std::string(path)));
13421|      0|              }
13422|    712|            }
13423|       |            // Set state to path state and decrease pointer by 1.
13424|    712|            state = state::PATH;
13425|    712|            break;
13426|    712|          }
13427|  1.02k|        }
13428|    412|        input_position++;
13429|    412|        break;
13430|  1.12k|      }
13431|     98|      case state::RELATIVE_SLASH: {
  ------------------
  |  Branch (13431:7): [True: 98, False: 133k]
  ------------------
13432|     98|        ada_log("RELATIVE_SLASH ",
13433|     98|                helpers::substring(url_data, input_position));
13434|       |
13435|       |        // If url is special and c is U+002F (/) or U+005C (\), then:
13436|       |        // NOLINTNEXTLINE(bugprone-branch-clone)
13437|     98|        if (url.is_special() && (input_position != input_size) &&
  ------------------
  |  Branch (13437:13): [True: 77, False: 21]
  |  Branch (13437:33): [True: 46, False: 31]
  ------------------
13438|     46|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13438:14): [True: 3, False: 43]
  ------------------
13439|     43|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13439:14): [True: 2, False: 41]
  ------------------
13440|       |          // Set state to special authority ignore slashes state.
13441|      5|          state = state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
13442|      5|        }
13443|       |        // Otherwise, if c is U+002F (/), then set state to authority state.
13444|     93|        else if ((input_position != input_size) &&
  ------------------
  |  Branch (13444:18): [True: 56, False: 37]
  ------------------
13445|     56|                 (url_data[input_position] == '/')) {
  ------------------
  |  Branch (13445:18): [True: 5, False: 51]
  ------------------
13446|      5|          state = state::AUTHORITY;
13447|      5|        }
13448|       |        // Otherwise, set
13449|       |        // - url's username to base's username,
13450|       |        // - url's password to base's password,
13451|       |        // - url's host to base's host,
13452|       |        // - url's port to base's port,
13453|       |        // - state to path state, and then, decrease pointer by 1.
13454|     88|        else {
13455|       |          if constexpr (result_type_is_ada_url) {
13456|       |            url.username = base_url->username;
13457|       |            url.password = base_url->password;
13458|       |            url.host = base_url->host;
13459|       |            url.port = base_url->port;
13460|     88|          } else {
13461|     88|            url.update_base_authority(base_url->get_href(),
13462|     88|                                      base_url->get_components());
13463|     88|            url.update_host_to_base_host(base_url->get_hostname());
13464|     88|            url.update_base_port(base_url->retrieve_base_port());
13465|     88|          }
13466|     88|          state = state::PATH;
13467|     88|          break;
13468|     88|        }
13469|       |
13470|     10|        input_position++;
13471|     10|        break;
13472|     98|      }
13473|  12.6k|      case state::SPECIAL_AUTHORITY_SLASHES: {
  ------------------
  |  Branch (13473:7): [True: 12.6k, False: 120k]
  ------------------
13474|  12.6k|        ada_log("SPECIAL_AUTHORITY_SLASHES ",
13475|  12.6k|                helpers::substring(url_data, input_position));
13476|       |
13477|       |        // If c is U+002F (/) and remaining starts with U+002F (/),
13478|       |        // then set state to special authority ignore slashes state and increase
13479|       |        // pointer by 1.
13480|  12.6k|        if (url_data.substr(input_position, 2) == "//") {
  ------------------
  |  Branch (13480:13): [True: 3.13k, False: 9.52k]
  ------------------
13481|  3.13k|          input_position += 2;
13482|  3.13k|        }
13483|       |
13484|  12.6k|        [[fallthrough]];
13485|  12.6k|      }
13486|  13.0k|      case state::SPECIAL_AUTHORITY_IGNORE_SLASHES: {
  ------------------
  |  Branch (13486:7): [True: 365, False: 133k]
  ------------------
13487|  13.0k|        ada_log("SPECIAL_AUTHORITY_IGNORE_SLASHES ",
13488|  13.0k|                helpers::substring(url_data, input_position));
13489|       |
13490|       |        // If c is neither U+002F (/) nor U+005C (\), then set state to
13491|       |        // authority state and decrease pointer by 1.
13492|  13.6k|        while ((input_position != input_size) &&
  ------------------
  |  Branch (13492:16): [True: 13.5k, False: 63]
  ------------------
13493|  13.5k|               ((url_data[input_position] == '/') ||
  ------------------
  |  Branch (13493:17): [True: 352, False: 13.2k]
  ------------------
13494|  13.2k|                (url_data[input_position] == '\\'))) {
  ------------------
  |  Branch (13494:17): [True: 271, False: 12.9k]
  ------------------
13495|    623|          input_position++;
13496|    623|        }
13497|  13.0k|        state = state::AUTHORITY;
13498|       |
13499|  13.0k|        break;
13500|  12.6k|      }
13501|    114|      case state::QUERY: {
  ------------------
  |  Branch (13501:7): [True: 114, False: 133k]
  ------------------
13502|    114|        ada_log("QUERY ", helpers::substring(url_data, input_position));
13503|       |        if constexpr (store_values) {
13504|       |          // Let queryPercentEncodeSet be the special-query percent-encode set
13505|       |          // if url is special; otherwise the query percent-encode set.
13506|       |          const uint8_t* query_percent_encode_set =
13507|       |              url.is_special() ? character_sets::SPECIAL_QUERY_PERCENT_ENCODE
13508|       |                               : character_sets::QUERY_PERCENT_ENCODE;
13509|       |
13510|       |          // Percent-encode after encoding, with encoding, buffer, and
13511|       |          // queryPercentEncodeSet, and append the result to url's query.
13512|       |          url.update_base_search(url_data.substr(input_position),
13513|       |                                 query_percent_encode_set);
13514|       |          ada_log("QUERY update_base_search completed ");
13515|       |          if (fragment.has_value()) {
13516|       |            url.update_unencoded_base_hash(*fragment);
13517|       |          }
13518|       |        }
13519|    114|        enforce_max_input_length();
13520|    114|        return url;
13521|  12.6k|      }
13522|  13.5k|      case state::HOST: {
  ------------------
  |  Branch (13522:7): [True: 13.5k, False: 120k]
  ------------------
13523|  13.5k|        ada_log("HOST ", helpers::substring(url_data, input_position));
13524|       |
13525|  13.5k|        std::string_view host_view = url_data.substr(input_position);
13526|  13.5k|        auto [location, found_colon] =
13527|  13.5k|            helpers::get_host_delimiter_location(url.is_special(), host_view);
13528|  13.5k|        input_position = (location != std::string_view::npos)
  ------------------
  |  Branch (13528:26): [True: 13.5k, False: 0]
  ------------------
13529|  13.5k|                             ? input_position + location
13530|  13.5k|                             : input_size;
13531|       |        // Otherwise, if c is U+003A (:) and insideBrackets is false, then:
13532|       |        // Note: the 'found_colon' value is true if and only if a colon was
13533|       |        // encountered while not inside brackets.
13534|  13.5k|        if (found_colon) {
  ------------------
  |  Branch (13534:13): [True: 2.73k, False: 10.8k]
  ------------------
13535|       |          // If buffer is the empty string, validation error, return failure.
13536|       |          // Let host be the result of host parsing buffer with url is not
13537|       |          // special.
13538|  2.73k|          ada_log("HOST parsing ", host_view);
13539|  2.73k|          if (!url.parse_host(host_view)) {
  ------------------
  |  Branch (13539:15): [True: 245, False: 2.49k]
  ------------------
13540|    245|            return url;
13541|    245|          }
13542|  2.49k|          ada_log("HOST parsing results in ", url.get_hostname());
13543|       |          // Set url's host to host, buffer to the empty string, and state to
13544|       |          // port state.
13545|  2.49k|          state = state::PORT;
13546|  2.49k|          input_position++;
13547|  2.49k|        }
13548|       |        // Otherwise, if one of the following is true:
13549|       |        // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
13550|       |        // - url is special and c is U+005C (\)
13551|       |        // The get_host_delimiter_location function either brings us to
13552|       |        // the colon outside of the bracket, or to one of those characters.
13553|  10.8k|        else {
13554|       |          // If url is special and host_view is the empty string, validation
13555|       |          // error, return failure.
13556|  10.8k|          if (host_view.empty() && url.is_special()) {
  ------------------
  |  Branch (13556:15): [True: 194, False: 10.6k]
  |  Branch (13556:36): [True: 68, False: 126]
  ------------------
13557|     68|            url.is_valid = false;
13558|     68|            return url;
13559|     68|          }
13560|  10.7k|          ada_log("HOST parsing ", host_view, " href=", url.get_href());
13561|       |          // Let host be the result of host parsing host_view with url is not
13562|       |          // special.
13563|  10.7k|          if (host_view.empty()) {
  ------------------
  |  Branch (13563:15): [True: 126, False: 10.6k]
  ------------------
13564|    126|            url.update_base_hostname("");
13565|  10.6k|          } else if (!url.parse_host(host_view)) {
  ------------------
  |  Branch (13565:22): [True: 2.29k, False: 8.36k]
  ------------------
13566|  2.29k|            return url;
13567|  2.29k|          }
13568|  8.48k|          ada_log("HOST parsing results in ", url.get_hostname(),
13569|  8.48k|                  " href=", url.get_href());
13570|       |
13571|       |          // Set url's host to host, and state to path start state.
13572|  8.48k|          state = state::PATH_START;
13573|  8.48k|        }
13574|       |
13575|  10.9k|        break;
13576|  13.5k|      }
13577|  10.9k|      case state::OPAQUE_PATH: {
  ------------------
  |  Branch (13577:7): [True: 3.22k, False: 130k]
  ------------------
13578|  3.22k|        ada_log("OPAQUE_PATH ", helpers::substring(url_data, input_position));
13579|       |        // Opaque path, query, and fragment are structurally always valid:
13580|       |        // the parser would just percent-encode whatever is there. When we
13581|       |        // are not storing values (can_parse), we can return immediately.
13582|       |        // We must set has_opaque_path = true before returning so that when
13583|       |        // this URL is used as an internal base inside can_parse, NO_SCHEME
13584|       |        // correctly rejects relative inputs against an opaque-path base
13585|       |        // (e.g. can_parse("", &"W:") must return false).
13586|  3.22k|        if constexpr (!store_values) {
13587|  3.22k|          url.has_opaque_path = true;
13588|  3.22k|          return url;
13589|  3.22k|        }
13590|      0|        std::string_view view = url_data.substr(input_position);
13591|       |        // If c is U+003F (?), then set url's query to the empty string and
13592|       |        // state to query state.
13593|  3.22k|        size_t location = view.find('?');
13594|  3.22k|        if (location != std::string_view::npos) {
  ------------------
  |  Branch (13594:13): [True: 0, False: 3.22k]
  ------------------
13595|      0|          view.remove_suffix(view.size() - location);
13596|      0|          state = state::QUERY;
13597|      0|          input_position += location + 1;
13598|  3.22k|        } else {
13599|  3.22k|          input_position = input_size + 1;
13600|  3.22k|        }
13601|  3.22k|        url.has_opaque_path = true;
13602|       |
13603|       |        // This is a really unlikely scenario in real world. We should not seek
13604|       |        // to optimize it.
13605|  3.22k|        if (view.ends_with(' ')) {
  ------------------
  |  Branch (13605:13): [True: 0, False: 3.22k]
  ------------------
13606|      0|          std::string modified_view =
13607|      0|              std::string(view.substr(0, view.size() - 1)) + "%20";
13608|      0|          url.update_base_pathname(unicode::percent_encode(
13609|      0|              modified_view, character_sets::C0_CONTROL_PERCENT_ENCODE));
13610|  3.22k|        } else {
13611|  3.22k|          url.update_base_pathname(unicode::percent_encode(
13612|  3.22k|              view, character_sets::C0_CONTROL_PERCENT_ENCODE));
13613|  3.22k|        }
13614|  3.22k|        break;
13615|  13.5k|      }
13616|  2.49k|      case state::PORT: {
  ------------------
  |  Branch (13616:7): [True: 2.49k, False: 131k]
  ------------------
13617|  2.49k|        ada_log("PORT ", helpers::substring(url_data, input_position));
13618|  2.49k|        std::string_view port_view = url_data.substr(input_position);
13619|  2.49k|        input_position += url.parse_port(port_view, true);
13620|  2.49k|        if (!url.is_valid) {
  ------------------
  |  Branch (13620:13): [True: 106, False: 2.38k]
  ------------------
13621|    106|          return url;
13622|    106|        }
13623|  2.38k|        state = state::PATH_START;
13624|  2.38k|        [[fallthrough]];
13625|  2.38k|      }
13626|  12.8k|      case state::PATH_START: {
  ------------------
  |  Branch (13626:7): [True: 10.4k, False: 123k]
  ------------------
13627|  12.8k|        ada_log("PATH_START ", helpers::substring(url_data, input_position));
13628|       |        // Path, query, and fragment are structurally always valid: the
13629|       |        // parser would just percent-encode whatever is there. When we are
13630|       |        // not storing values (can_parse), we can return immediately since
13631|       |        // no subsequent state can invalidate the URL.
13632|  12.8k|        if constexpr (!store_values) {
13633|  12.8k|          return url;
13634|  12.8k|        }
13635|       |
13636|       |        // If url is special, then:
13637|  12.8k|        if (url.is_special()) {
  ------------------
  |  Branch (13637:13): [True: 0, False: 12.8k]
  ------------------
13638|       |          // Set state to path state.
13639|      0|          state = state::PATH;
13640|       |
13641|       |          // Optimization: Avoiding going into PATH state improves the
13642|       |          // performance of urls ending with /.
13643|      0|          if (input_position == input_size) {
  ------------------
  |  Branch (13643:15): [True: 0, False: 0]
  ------------------
13644|       |            if constexpr (store_values) {
13645|       |              url.update_base_pathname("/");
13646|       |              if (fragment.has_value()) {
13647|       |                url.update_unencoded_base_hash(*fragment);
13648|       |              }
13649|       |            }
13650|      0|            enforce_max_input_length();
13651|      0|            return url;
13652|      0|          }
13653|       |          // If c is neither U+002F (/) nor U+005C (\), then decrease pointer
13654|       |          // by 1. We know that (input_position == input_size) is impossible
13655|       |          // here, because of the previous if-check.
13656|      0|          if ((url_data[input_position] != '/') &&
  ------------------
  |  Branch (13656:15): [True: 0, False: 0]
  ------------------
13657|      0|              (url_data[input_position] != '\\')) {
  ------------------
  |  Branch (13657:15): [True: 0, False: 0]
  ------------------
13658|      0|            break;
13659|      0|          }
13660|      0|        }
13661|       |        // Otherwise, if state override is not given and c is U+003F (?),
13662|       |        // set url's query to the empty string and state to query state.
13663|  12.8k|        else if ((input_position != input_size) &&
  ------------------
  |  Branch (13663:18): [True: 0, False: 12.8k]
  ------------------
13664|      0|                 (url_data[input_position] == '?')) {
  ------------------
  |  Branch (13664:18): [True: 0, False: 0]
  ------------------
13665|      0|          state = state::QUERY;
13666|      0|        }
13667|       |        // Otherwise, if c is not the EOF code point:
13668|  12.8k|        else if (input_position != input_size) {
  ------------------
  |  Branch (13668:18): [True: 0, False: 12.8k]
  ------------------
13669|       |          // Set state to path state.
13670|      0|          state = state::PATH;
13671|       |
13672|       |          // If c is not U+002F (/), then decrease pointer by 1.
13673|      0|          if (url_data[input_position] != '/') {
  ------------------
  |  Branch (13673:15): [True: 0, False: 0]
  ------------------
13674|      0|            break;
13675|      0|          }
13676|      0|        }
13677|       |
13678|  12.8k|        input_position++;
13679|  12.8k|        break;
13680|  12.8k|      }
13681|  2.87k|      case state::PATH: {
  ------------------
  |  Branch (13681:7): [True: 2.87k, False: 130k]
  ------------------
13682|  2.87k|        ada_log("PATH ", helpers::substring(url_data, input_position));
13683|       |        // Path, query, and fragment are structurally always valid: the
13684|       |        // parser would just percent-encode whatever is there. When we are
13685|       |        // not storing values (can_parse), we can return immediately since
13686|       |        // no subsequent state can invalidate the URL.
13687|  2.87k|        if constexpr (!store_values) {
13688|  2.87k|          return url;
13689|  2.87k|        }
13690|      0|        std::string_view view = url_data.substr(input_position);
13691|       |
13692|       |        // Most time, we do not need percent encoding.
13693|       |        // Furthermore, we can immediately locate the '?'.
13694|  2.87k|        size_t locofquestionmark = view.find('?');
13695|  2.87k|        if (locofquestionmark != std::string_view::npos) {
  ------------------
  |  Branch (13695:13): [True: 0, False: 2.87k]
  ------------------
13696|      0|          state = state::QUERY;
13697|      0|          view.remove_suffix(view.size() - locofquestionmark);
13698|      0|          input_position += locofquestionmark + 1;
13699|  2.87k|        } else {
13700|  2.87k|          input_position = input_size + 1;
13701|  2.87k|        }
13702|       |        if constexpr (store_values) {
13703|       |          if constexpr (result_type_is_ada_url) {
13704|       |            helpers::parse_prepared_path(view, url.type, url.path);
13705|       |          } else {
13706|       |            url.consume_prepared_path(view);
13707|       |            ADA_ASSERT_TRUE(url.validate());
13708|       |          }
13709|       |        }
13710|  2.87k|        break;
13711|  12.8k|      }
13712|  2.25k|      case state::FILE_SLASH: {
  ------------------
  |  Branch (13712:7): [True: 2.25k, False: 131k]
  ------------------
13713|  2.25k|        ada_log("FILE_SLASH ", helpers::substring(url_data, input_position));
13714|       |
13715|       |        // If c is U+002F (/) or U+005C (\), then:
13716|  2.25k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13716:13): [True: 2.18k, False: 70]
  ------------------
13717|  2.18k|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13717:14): [True: 2.13k, False: 48]
  ------------------
13718|  2.14k|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13718:14): [True: 6, False: 42]
  ------------------
13719|  2.14k|          ada_log("FILE_SLASH c is U+002F or U+005C");
13720|       |          // Set state to file host state.
13721|  2.14k|          state = state::FILE_HOST;
13722|  2.14k|          input_position++;
13723|  2.14k|        } else {
13724|    112|          ada_log("FILE_SLASH otherwise");
13725|       |          // If base is non-null and base's scheme is "file", then:
13726|       |          // Note: it is unsafe to do base_url->scheme unless you know that
13727|       |          // base_url_has_value() is true.
13728|    112|          if (base_url != nullptr && base_url->type == scheme::type::FILE) {
  ------------------
  |  Branch (13728:15): [True: 87, False: 25]
  |  Branch (13728:38): [True: 84, False: 3]
  ------------------
13729|       |            // Set url's host to base's host.
13730|       |            if constexpr (result_type_is_ada_url) {
13731|       |              url.host = base_url->host;
13732|     84|            } else {
13733|     84|              url.update_host_to_base_host(base_url->get_host());
13734|     84|            }
13735|       |            // If the code point substring from pointer to the end of input does
13736|       |            // not start with a Windows drive letter and base's path[0] is a
13737|       |            // normalized Windows drive letter, then append base's path[0] to
13738|       |            // url's path.
13739|     84|            if (!base_url->get_pathname().empty()) {
  ------------------
  |  Branch (13739:17): [True: 0, False: 84]
  ------------------
13740|      0|              if (!checkers::is_windows_drive_letter(
  ------------------
  |  Branch (13740:19): [True: 0, False: 0]
  ------------------
13741|      0|                      url_data.substr(input_position))) {
13742|      0|                std::string_view first_base_url_path =
13743|      0|                    base_url->get_pathname().substr(1);
13744|      0|                size_t loc = first_base_url_path.find('/');
13745|      0|                if (loc != std::string_view::npos) {
  ------------------
  |  Branch (13745:21): [True: 0, False: 0]
  ------------------
13746|      0|                  helpers::resize(first_base_url_path, loc);
13747|      0|                }
13748|      0|                if (checkers::is_normalized_windows_drive_letter(
  ------------------
  |  Branch (13748:21): [True: 0, False: 0]
  ------------------
13749|      0|                        first_base_url_path)) {
13750|       |                  if constexpr (result_type_is_ada_url) {
13751|       |                    url.path += '/';
13752|       |                    url.path += first_base_url_path;
13753|      0|                  } else {
13754|      0|                    url.append_base_pathname(
13755|      0|                        helpers::concat("/", first_base_url_path));
13756|      0|                  }
13757|      0|                }
13758|      0|              }
13759|      0|            }
13760|     84|          }
13761|       |
13762|       |          // Set state to path state, and decrease pointer by 1.
13763|    112|          state = state::PATH;
13764|    112|        }
13765|       |
13766|  2.25k|        break;
13767|  12.8k|      }
13768|  2.14k|      case state::FILE_HOST: {
  ------------------
  |  Branch (13768:7): [True: 2.14k, False: 131k]
  ------------------
13769|  2.14k|        ada_log("FILE_HOST ", helpers::substring(url_data, input_position));
13770|  2.14k|        std::string_view view = url_data.substr(input_position);
13771|       |
13772|  2.14k|        size_t location = view.find_first_of("/\\?");
13773|  2.14k|        std::string_view file_host_buffer = view.substr(
13774|  2.14k|            0, (location != std::string_view::npos) ? location : view.size());
  ------------------
  |  Branch (13774:16): [True: 924, False: 1.22k]
  ------------------
13775|       |
13776|  2.14k|        if (checkers::is_windows_drive_letter(file_host_buffer)) {
  ------------------
  |  Branch (13776:13): [True: 12, False: 2.13k]
  ------------------
13777|     12|          state = state::PATH;
13778|  2.13k|        } else if (file_host_buffer.empty()) {
  ------------------
  |  Branch (13778:20): [True: 274, False: 1.85k]
  ------------------
13779|       |          // Set url's host to the empty string.
13780|       |          if constexpr (result_type_is_ada_url) {
13781|       |            url.host = "";
13782|    274|          } else {
13783|    274|            url.update_base_hostname("");
13784|    274|          }
13785|       |          // Set state to path start state.
13786|    274|          state = state::PATH_START;
13787|  1.85k|        } else {
13788|  1.85k|          size_t consumed_bytes = file_host_buffer.size();
13789|  1.85k|          input_position += consumed_bytes;
13790|       |          // Let host be the result of host parsing buffer with url is not
13791|       |          // special.
13792|  1.85k|          if (!url.parse_host(file_host_buffer)) {
  ------------------
  |  Branch (13792:15): [True: 191, False: 1.66k]
  ------------------
13793|    191|            return url;
13794|    191|          }
13795|       |
13796|       |          if constexpr (result_type_is_ada_url) {
13797|       |            // If host is "localhost", then set host to the empty string.
13798|       |            if (url.host.has_value() && url.host.value() == "localhost") {
13799|       |              url.host = "";
13800|       |            }
13801|  1.66k|          } else {
13802|  1.66k|            if (url.get_hostname() == "localhost") {
  ------------------
  |  Branch (13802:17): [True: 12, False: 1.65k]
  ------------------
13803|     12|              url.update_base_hostname("");
13804|     12|            }
13805|  1.66k|          }
13806|       |
13807|       |          // Set buffer to the empty string and state to path start state.
13808|  1.66k|          state = state::PATH_START;
13809|  1.66k|        }
13810|       |
13811|  1.95k|        break;
13812|  2.14k|      }
13813|  2.95k|      case state::FILE: {
  ------------------
  |  Branch (13813:7): [True: 2.95k, False: 130k]
  ------------------
13814|  2.95k|        ada_log("FILE ", helpers::substring(url_data, input_position));
13815|  2.95k|        std::string_view file_view = url_data.substr(input_position);
13816|       |
13817|  2.95k|        url.set_protocol_as_file();
13818|       |        if constexpr (result_type_is_ada_url) {
13819|       |          // Set url's host to the empty string.
13820|       |          url.host = "";
13821|  2.95k|        } else {
13822|  2.95k|          url.update_base_hostname("");
13823|  2.95k|        }
13824|       |        // If c is U+002F (/) or U+005C (\), then:
13825|  2.95k|        if (input_position != input_size &&
  ------------------
  |  Branch (13825:13): [True: 2.81k, False: 137]
  ------------------
13826|  2.81k|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13826:14): [True: 2.25k, False: 562]
  ------------------
13827|  2.25k|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13827:14): [True: 6, False: 556]
  ------------------
13828|  2.25k|          ada_log("FILE c is U+002F or U+005C");
13829|       |          // Set state to file slash state.
13830|  2.25k|          state = state::FILE_SLASH;
13831|  2.25k|        }
13832|       |        // Otherwise, if base is non-null and base's scheme is "file":
13833|    693|        else if (base_url != nullptr && base_url->type == scheme::type::FILE) {
  ------------------
  |  Branch (13833:18): [True: 267, False: 426]
  |  Branch (13833:41): [True: 199, False: 68]
  ------------------
13834|       |          // Set url's host to base's host, url's path to a clone of base's
13835|       |          // path, and url's query to base's query.
13836|    199|          ada_log("FILE base non-null");
13837|       |          if constexpr (result_type_is_ada_url) {
13838|       |            url.host = base_url->host;
13839|       |            url.path = base_url->path;
13840|       |            url.query = base_url->query;
13841|    199|          } else {
13842|    199|            url.update_host_to_base_host(base_url->get_hostname());
13843|    199|            url.update_base_pathname(base_url->get_pathname());
13844|    199|            if (base_url->has_search()) {
  ------------------
  |  Branch (13844:17): [True: 0, False: 199]
  ------------------
13845|       |              // get_search() returns "" for an empty query string (URL ends
13846|       |              // with '?'). update_base_search("") would incorrectly clear the
13847|       |              // query, so pass "?" to preserve the empty query distinction.
13848|      0|              auto s = base_url->get_search();
13849|      0|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (13849:38): [True: 0, False: 0]
  ------------------
13850|      0|            }
13851|    199|          }
13852|    199|          url.has_opaque_path = base_url->has_opaque_path;
13853|       |
13854|       |          // If c is U+003F (?), then set url's query to the empty string and
13855|       |          // state to query state.
13856|    199|          if (input_position != input_size && url_data[input_position] == '?') {
  ------------------
  |  Branch (13856:15): [True: 136, False: 63]
  |  Branch (13856:47): [True: 9, False: 127]
  ------------------
13857|      9|            state = state::QUERY;
13858|      9|          }
13859|       |          // Otherwise, if c is not the EOF code point:
13860|    190|          else if (input_position != input_size) {
  ------------------
  |  Branch (13860:20): [True: 127, False: 63]
  ------------------
13861|       |            // Set url's query to null.
13862|    127|            url.clear_search();
13863|       |            // If the code point substring from pointer to the end of input does
13864|       |            // not start with a Windows drive letter, then shorten url's path.
13865|    127|            if (!checkers::is_windows_drive_letter(file_view)) {
  ------------------
  |  Branch (13865:17): [True: 107, False: 20]
  ------------------
13866|       |              if constexpr (result_type_is_ada_url) {
13867|       |                helpers::shorten_path(url.path, url.type);
13868|    107|              } else {
13869|    107|                std::string_view path = url.get_pathname();
13870|    107|                if (helpers::shorten_path(path, url.type)) {
  ------------------
  |  Branch (13870:21): [True: 0, False: 107]
  ------------------
13871|      0|                  url.update_base_pathname(std::move(std::string(path)));
13872|      0|                }
13873|    107|              }
13874|    107|            }
13875|       |            // Otherwise:
13876|     20|            else {
13877|       |              // Set url's path to an empty list.
13878|     20|              url.clear_pathname();
13879|     20|            }
13880|       |
13881|       |            // Set state to path state and decrease pointer by 1.
13882|    127|            state = state::PATH;
13883|    127|            break;
13884|    127|          }
13885|    199|        }
13886|       |        // Otherwise, set state to path state, and decrease pointer by 1.
13887|    494|        else {
13888|    494|          ada_log("FILE go to path");
13889|    494|          state = state::PATH;
13890|    494|          break;
13891|    494|        }
13892|       |
13893|  2.32k|        input_position++;
13894|  2.32k|        break;
13895|  2.95k|      }
13896|      0|      default:
  ------------------
  |  Branch (13896:7): [True: 0, False: 133k]
  ------------------
13897|      0|        unreachable();
13898|   133k|    }
13899|   133k|  }
13900|       |  if constexpr (store_values) {
13901|       |    if (fragment.has_value()) {
13902|       |      url.update_unencoded_base_hash(*fragment);
13903|       |    }
13904|       |  }
13905|    272|  enforce_max_input_length();
13906|    272|  return url;
13907|  31.0k|}
_ZNK3ada14url_aggregator8get_hostEv:
14950|    168|    ada_lifetime_bound {
14951|    168|  ada_log("url_aggregator::get_host");
14952|       |  // Technically, we should check if there is a hostname, but
14953|       |  // the code below works even if there isn't.
14954|       |  // if(!has_hostname()) { return ""; }
14955|    168|  size_t start = components.host_start;
14956|    168|  if (components.host_end > components.host_start &&
  ------------------
  |  Branch (14956:7): [True: 38, False: 130]
  ------------------
14957|     38|      buffer[components.host_start] == '@') {
  ------------------
  |  Branch (14957:7): [True: 0, False: 38]
  ------------------
14958|      0|    start++;
14959|      0|  }
14960|       |  // if we have an empty host, then the space between components.host_end and
14961|       |  // components.pathname_start may be occupied by /.
14962|    168|  if (start == components.host_end) {
  ------------------
  |  Branch (14962:7): [True: 130, False: 38]
  ------------------
14963|    130|    return {};
14964|    130|  }
14965|     38|  return helpers::substring(buffer, start, components.pathname_start);
14966|    168|}
_ZNK3ada14url_aggregator12get_hostnameEv:
14969|  18.8k|    ada_lifetime_bound {
14970|  18.8k|  ada_log("url_aggregator::get_hostname");
14971|       |  // Technically, we should check if there is a hostname, but
14972|       |  // the code below works even if there isn't.
14973|       |  // if(!has_hostname()) { return ""; }
14974|  18.8k|  size_t start = components.host_start;
14975|       |  // So host_start is not where the host begins.
14976|  18.8k|  if (components.host_end > components.host_start &&
  ------------------
  |  Branch (14976:7): [True: 5.21k, False: 13.5k]
  ------------------
14977|  5.21k|      buffer[components.host_start] == '@') {
  ------------------
  |  Branch (14977:7): [True: 202, False: 5.01k]
  ------------------
14978|    202|    start++;
14979|    202|  }
14980|  18.8k|  return helpers::substring(buffer, start, components.host_end);
14981|  18.8k|}
_ZNK3ada14url_aggregator10get_searchEv:
14984|    168|    ada_lifetime_bound {
14985|    168|  ada_log("url_aggregator::get_search");
14986|       |  // If this's URL's query is either null or the empty string, then return the
14987|       |  // empty string. Return U+003F (?), followed by this's URL's query.
14988|    168|  if (components.search_start == url_components::omitted) {
  ------------------
  |  Branch (14988:7): [True: 0, False: 168]
  ------------------
14989|      0|    return "";
14990|      0|  }
14991|    168|  auto ending_index = uint32_t(buffer.size());
14992|    168|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (14992:7): [True: 35, False: 133]
  ------------------
14993|     35|    ending_index = components.hash_start;
14994|     35|  }
14995|    168|  if (ending_index - components.search_start <= 1) {
  ------------------
  |  Branch (14995:7): [True: 72, False: 96]
  ------------------
14996|     72|    return "";
14997|     72|  }
14998|     96|  return helpers::substring(buffer, components.search_start, ending_index);
14999|    168|}
_ZNK3ada14url_aggregator12get_protocolEv:
15002|  2.09k|    ada_lifetime_bound {
15003|  2.09k|  ada_log("url_aggregator::get_protocol");
15004|  2.09k|  return helpers::substring(buffer, 0, components.protocol_end);
15005|  2.09k|}
_ZN3ada14url_aggregator10parse_ipv4ENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEb:
15114|  3.92k|bool url_aggregator::parse_ipv4(std::string_view input, bool in_place) {
15115|  3.92k|  ada_log("parse_ipv4 ", input, " [", input.size(),
15116|  3.92k|          " bytes], overlaps with buffer: ",
15117|  3.92k|          helpers::overlaps(input, buffer) ? "yes" : "no");
15118|  3.92k|  ADA_ASSERT_TRUE(validate());
15119|  3.92k|  if (input.empty()) {
  ------------------
  |  Branch (15119:7): [True: 0, False: 3.92k]
  ------------------
15120|      0|    return is_valid = false;
15121|      0|  }
15122|  3.92k|  const bool trailing_dot = (input.back() == '.');
15123|  3.92k|  if (trailing_dot) {
  ------------------
  |  Branch (15123:7): [True: 134, False: 3.78k]
  ------------------
15124|    134|    input.remove_suffix(1);
15125|    134|    if (input.empty()) {
  ------------------
  |  Branch (15125:9): [True: 0, False: 134]
  ------------------
15126|      0|      return is_valid = false;
15127|      0|    }
15128|    134|  }
15129|       |
15130|  3.92k|  const uint64_t fast = checkers::try_parse_ipv4_fast(input);
15131|  3.92k|  if (fast < checkers::ipv4_fast_fail) [[likely]] {
  ------------------
  |  Branch (15131:7): [True: 44, False: 3.87k]
  ------------------
15132|       |    // Pure decimal: keep the buffer when it already holds the address.
15133|       |    // Otherwise write the (trailing-dot-stripped) input.
15134|     44|    if (!(in_place && !trailing_dot)) {
  ------------------
  |  Branch (15134:11): [True: 0, False: 44]
  |  Branch (15134:23): [True: 0, False: 0]
  ------------------
15135|     44|      if (helpers::overlaps(input, buffer)) {
  ------------------
  |  Branch (15135:11): [True: 0, False: 44]
  ------------------
15136|      0|        update_base_hostname(std::string(input));
15137|     44|      } else {
15138|     44|        update_base_hostname(input);
15139|     44|      }
15140|     44|    }
15141|     44|    host_type = IPV4;
15142|     44|    ADA_ASSERT_TRUE(validate());
15143|     44|    return true;
15144|     44|  }
15145|       |
15146|  3.87k|  const char* p = input.data();
15147|  3.87k|  const char* end = p + input.size();
15148|  3.87k|  uint64_t ipv4 = 0;
15149|  3.87k|  int digit_count = 0;
15150|  3.87k|  int pure_decimal_count = 0;
15151|       |
15152|  4.85k|  for (; digit_count < 4 && p < end; ++digit_count) {
  ------------------
  |  Branch (15152:10): [True: 4.82k, False: 22]
  |  Branch (15152:29): [True: 4.82k, False: 0]
  ------------------
15153|  4.82k|    uint64_t segment = 0;
15154|  4.82k|    bool pure = false;
15155|  4.82k|    if (!detail::parse_ipv4_number(p, end, segment, pure)) {
  ------------------
  |  Branch (15155:9): [True: 720, False: 4.10k]
  ------------------
15156|    720|      return is_valid = false;
15157|    720|    }
15158|  4.10k|    if (pure) {
  ------------------
  |  Branch (15158:9): [True: 3.00k, False: 1.10k]
  ------------------
15159|  3.00k|      ++pure_decimal_count;
15160|  3.00k|    }
15161|  4.10k|    if (p >= end) {
  ------------------
  |  Branch (15161:9): [True: 3.07k, False: 1.03k]
  ------------------
15162|  3.07k|      const unsigned shift = static_cast<unsigned>(32 - digit_count * 8);
15163|  3.07k|      if (segment >= (uint64_t{1} << shift)) {
  ------------------
  |  Branch (15163:11): [True: 52, False: 3.02k]
  ------------------
15164|     52|        return is_valid = false;
15165|     52|      }
15166|  3.02k|      ipv4 = (ipv4 << shift) | segment;
15167|  3.02k|      goto ipv4_done;
15168|  3.07k|    }
15169|  1.03k|    if (segment > 255 || *p != '.') {
  ------------------
  |  Branch (15169:9): [True: 58, False: 972]
  |  Branch (15169:26): [True: 0, False: 972]
  ------------------
15170|     58|      return is_valid = false;
15171|     58|    }
15172|    972|    ipv4 = (ipv4 << 8) | segment;
15173|    972|    ++p;
15174|    972|  }
15175|     22|  if (digit_count != 4 || p != end) {
  ------------------
  |  Branch (15175:7): [True: 0, False: 22]
  |  Branch (15175:27): [True: 22, False: 0]
  ------------------
15176|     22|    return is_valid = false;
15177|     22|  }
15178|  3.02k|ipv4_done:
15179|  3.02k|  ada_log("url_aggregator::parse_ipv4 completed ", get_href(),
15180|  3.02k|          " host: ", get_host());
15181|  3.02k|  if (in_place && pure_decimal_count == 4 && !trailing_dot) {
  ------------------
  |  Branch (15181:7): [True: 0, False: 3.02k]
  |  Branch (15181:19): [True: 0, False: 0]
  |  Branch (15181:46): [True: 0, False: 0]
  ------------------
15182|      0|    ada_log(
15183|      0|        "url_aggregator::parse_ipv4 completed and was already correct in the "
15184|      0|        "buffer");
15185|  3.02k|  } else {
15186|  3.02k|    update_base_hostname(ada::serializers::ipv4(ipv4));
15187|  3.02k|  }
15188|  3.02k|  host_type = IPV4;
15189|  3.02k|  ADA_ASSERT_TRUE(validate());
15190|  3.02k|  return true;
15191|     22|}
_ZN3ada14url_aggregator10parse_ipv6ENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
15193|  1.10k|bool url_aggregator::parse_ipv6(std::string_view input) {
15194|  1.10k|  ada_log("parse_ipv6 ", input, " [", input.size(), " bytes]");
15195|  1.10k|  ADA_ASSERT_TRUE(validate());
15196|  1.10k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
15197|  1.10k|  if (input.empty() || input.size() > 45) [[unlikely]] {
  ------------------
  |  Branch (15197:7): [True: 30, False: 1.07k]
  |  Branch (15197:24): [True: 30, False: 1.04k]
  ------------------
15198|     60|    return is_valid = false;
15199|     60|  }
15200|  1.04k|  std::array<uint16_t, 8> address{};
15201|       |#if defined(ADA_AVX512_IPV6)
15202|       |  if (bool simd_valid; detail::try_parse_ipv6_avx512(input.data(), input.size(),
15203|       |                                                     address, simd_valid)) {
15204|       |    if (!simd_valid) [[unlikely]] {
15205|       |      return is_valid = false;
15206|       |    }
15207|       |    const std::string serialized = ada::serializers::ipv6(address);
15208|       |    if (get_hostname() != serialized) {
15209|       |      update_base_hostname(serialized);
15210|       |    }
15211|       |    host_type = IPV6;
15212|       |    return true;
15213|       |  }
15214|       |  address = {};
15215|       |#endif
15216|  1.04k|  const char* pointer = input.data();
15217|  1.04k|  const char* const end = pointer + input.size();
15218|  1.04k|  int piece_index = 0;
15219|  1.04k|  int compress = -1;
15220|       |
15221|  1.04k|  if (*pointer == ':') {
  ------------------
  |  Branch (15221:7): [True: 402, False: 646]
  ------------------
15222|    402|    if (input.size() == 1 || pointer[1] != ':') [[unlikely]] {
  ------------------
  |  Branch (15222:9): [True: 6, False: 396]
  |  Branch (15222:30): [True: 18, False: 378]
  ------------------
15223|     24|      return is_valid = false;
15224|     24|    }
15225|    378|    pointer += 2;
15226|    378|    compress = ++piece_index;
15227|    378|  }
15228|       |
15229|  3.03k|  while (pointer != end) {
  ------------------
  |  Branch (15229:10): [True: 2.32k, False: 706]
  ------------------
15230|  2.32k|    if (piece_index == 8) [[unlikely]] {
  ------------------
  |  Branch (15230:9): [True: 6, False: 2.32k]
  ------------------
15231|      6|      return is_valid = false;
15232|      6|    }
15233|  2.32k|    if (*pointer == ':') {
  ------------------
  |  Branch (15233:9): [True: 292, False: 2.02k]
  ------------------
15234|    292|      if (compress != -1) [[unlikely]] {
  ------------------
  |  Branch (15234:11): [True: 6, False: 286]
  ------------------
15235|      6|        return is_valid = false;
15236|      6|      }
15237|    286|      ++pointer;
15238|    286|      compress = ++piece_index;
15239|    286|      continue;
15240|    292|    }
15241|       |
15242|  2.02k|    uint16_t value = 0;
15243|  2.02k|    const int length = detail::parse_hex_piece(pointer, end, value);
15244|       |
15245|  2.02k|    if (pointer != end && *pointer == '.') {
  ------------------
  |  Branch (15245:9): [True: 1.65k, False: 372]
  |  Branch (15245:27): [True: 194, False: 1.46k]
  ------------------
15246|    194|      if (length == 0) [[unlikely]] {
  ------------------
  |  Branch (15246:11): [True: 6, False: 188]
  ------------------
15247|      6|        return is_valid = false;
15248|      6|      }
15249|    188|      pointer -= length;
15250|    188|      if (piece_index > 6) [[unlikely]] {
  ------------------
  |  Branch (15250:11): [True: 6, False: 182]
  ------------------
15251|      6|        return is_valid = false;
15252|      6|      }
15253|       |
15254|    182|      int numbers_seen = 0;
15255|    518|      while (pointer != end) {
  ------------------
  |  Branch (15255:14): [True: 456, False: 62]
  ------------------
15256|    456|        int ipv4_piece = -1;
15257|    456|        if (numbers_seen > 0) {
  ------------------
  |  Branch (15257:13): [True: 274, False: 182]
  ------------------
15258|    274|          if (*pointer == '.' && numbers_seen < 4) {
  ------------------
  |  Branch (15258:15): [True: 246, False: 28]
  |  Branch (15258:34): [True: 236, False: 10]
  ------------------
15259|    236|            ++pointer;
15260|    236|          } else {
15261|     38|            return is_valid = false;
15262|     38|          }
15263|    274|        }
15264|    418|        if (pointer == end || *pointer < '0' || *pointer > '9') [[unlikely]] {
  ------------------
  |  Branch (15264:13): [True: 44, False: 374]
  |  Branch (15264:31): [True: 6, False: 368]
  |  Branch (15264:49): [True: 14, False: 354]
  ------------------
15265|     64|          return is_valid = false;
15266|     64|        }
15267|    354|        ipv4_piece = *pointer - '0';
15268|    354|        ++pointer;
15269|    354|        if (pointer != end && *pointer >= '0' && *pointer <= '9') {
  ------------------
  |  Branch (15269:13): [True: 318, False: 36]
  |  Branch (15269:31): [True: 130, False: 188]
  |  Branch (15269:50): [True: 122, False: 8]
  ------------------
15270|    122|          if (ipv4_piece == 0) [[unlikely]] {
  ------------------
  |  Branch (15270:15): [True: 6, False: 116]
  ------------------
15271|      6|            return is_valid = false;
15272|      6|          }
15273|    116|          ipv4_piece = ipv4_piece * 10 + (*pointer - '0');
15274|    116|          ++pointer;
15275|    116|          if (pointer != end && *pointer >= '0' && *pointer <= '9') {
  ------------------
  |  Branch (15275:15): [True: 104, False: 12]
  |  Branch (15275:33): [True: 66, False: 38]
  |  Branch (15275:52): [True: 60, False: 6]
  ------------------
15276|     60|            ipv4_piece = ipv4_piece * 10 + (*pointer - '0');
15277|     60|            ++pointer;
15278|     60|            if (ipv4_piece > 255) [[unlikely]] {
  ------------------
  |  Branch (15278:17): [True: 12, False: 48]
  ------------------
15279|     12|              return is_valid = false;
15280|     12|            }
15281|     60|          }
15282|    116|        }
15283|    336|        address[static_cast<size_t>(piece_index)] = static_cast<uint16_t>(
15284|    336|            address[static_cast<size_t>(piece_index)] * 0x100 +
15285|    336|            static_cast<uint16_t>(ipv4_piece));
15286|    336|        ++numbers_seen;
15287|    336|        if (numbers_seen == 2 || numbers_seen == 4) {
  ------------------
  |  Branch (15287:13): [True: 100, False: 236]
  |  Branch (15287:34): [True: 34, False: 202]
  ------------------
15288|    134|          ++piece_index;
15289|    134|        }
15290|    336|      }
15291|     62|      if (numbers_seen != 4) [[unlikely]] {
  ------------------
  |  Branch (15291:11): [True: 38, False: 24]
  ------------------
15292|     38|        return is_valid = false;
15293|     38|      }
15294|     24|      break;
15295|     62|    }
15296|       |
15297|  1.83k|    if (length == 0) [[unlikely]] {
  ------------------
  |  Branch (15297:9): [True: 88, False: 1.74k]
  ------------------
15298|     88|      return is_valid = false;
15299|     88|    }
15300|       |
15301|  1.74k|    if (pointer != end && *pointer == ':') {
  ------------------
  |  Branch (15301:9): [True: 1.37k, False: 372]
  |  Branch (15301:27): [True: 1.35k, False: 18]
  ------------------
15302|  1.35k|      ++pointer;
15303|  1.35k|      if (pointer == end) [[unlikely]] {
  ------------------
  |  Branch (15303:11): [True: 6, False: 1.35k]
  ------------------
15304|      6|        return is_valid = false;
15305|      6|      }
15306|  1.35k|    } else if (pointer != end) [[unlikely]] {
  ------------------
  |  Branch (15306:16): [True: 18, False: 372]
  ------------------
15307|     18|      return is_valid = false;
15308|     18|    }
15309|       |
15310|  1.72k|    address[static_cast<size_t>(piece_index)] = value;
15311|  1.72k|    ++piece_index;
15312|  1.72k|  }
15313|       |
15314|    730|  if (compress != -1) {
  ------------------
  |  Branch (15314:7): [True: 646, False: 84]
  ------------------
15315|    646|    const int right = piece_index - compress;
15316|    646|    if (right > 0) {
  ------------------
  |  Branch (15316:9): [True: 312, False: 334]
  ------------------
15317|    312|      const size_t dest = static_cast<size_t>(8 - right);
15318|    312|      const size_t src = static_cast<size_t>(compress);
15319|    312|      if (dest != src) {
  ------------------
  |  Branch (15319:11): [True: 270, False: 42]
  ------------------
15320|    784|        for (size_t i = static_cast<size_t>(right); i-- > 0;) {
  ------------------
  |  Branch (15320:53): [True: 514, False: 270]
  ------------------
15321|    514|          address[dest + i] = address[src + i];
15322|    514|          address[src + i] = 0;
15323|    514|        }
15324|    270|      }
15325|    312|    }
15326|    646|  } else if (piece_index != 8) [[unlikely]] {
  ------------------
  |  Branch (15326:14): [True: 46, False: 38]
  ------------------
15327|     46|    return is_valid = false;
15328|     46|  }
15329|       |
15330|       |  // Serialize once; skip rewrite when hostname is already canonical.
15331|    684|  const std::string serialized = ada::serializers::ipv6(address);
15332|    684|  const std::string_view current = get_hostname();
15333|    684|  if (current.size() == serialized.size() &&
  ------------------
  |  Branch (15333:7): [True: 0, False: 684]
  ------------------
15334|      0|      std::memcmp(current.data(), serialized.data(), serialized.size()) == 0) {
  ------------------
  |  Branch (15334:7): [True: 0, False: 0]
  ------------------
15335|      0|    ada_log("parse_ipv6 in-place canonical match");
15336|    684|  } else {
15337|    684|    update_base_hostname(serialized);
15338|    684|  }
15339|    684|  ada_log("parse_ipv6 ", get_hostname());
15340|    684|  ADA_ASSERT_TRUE(validate());
15341|    684|  host_type = IPV6;
15342|    684|  return true;
15343|    730|}
_ZN3ada14url_aggregator17parse_opaque_hostENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
15345|  1.28k|bool url_aggregator::parse_opaque_host(std::string_view input) {
15346|  1.28k|  ada_log("parse_opaque_host ", input, " [", input.size(), " bytes]");
15347|  1.28k|  ADA_ASSERT_TRUE(validate());
15348|  1.28k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
15349|  1.28k|  if (std::ranges::any_of(input, ada::unicode::is_forbidden_host_code_point)) {
  ------------------
  |  Branch (15349:7): [True: 28, False: 1.25k]
  ------------------
15350|     28|    return is_valid = false;
15351|     28|  }
15352|       |
15353|       |  // Return the result of running UTF-8 percent-encode on input using the C0
15354|       |  // control percent-encode set.
15355|  1.25k|  size_t idx = ada::unicode::percent_encode_index(
15356|  1.25k|      input, character_sets::C0_CONTROL_PERCENT_ENCODE);
15357|  1.25k|  if (idx == input.size()) {
  ------------------
  |  Branch (15357:7): [True: 712, False: 542]
  ------------------
15358|    712|    update_base_hostname(input);
15359|    712|  } else {
15360|       |    // We only create a temporary string if we need to.
15361|    542|    update_base_hostname(ada::unicode::percent_encode(
15362|    542|        input, character_sets::C0_CONTROL_PERCENT_ENCODE, idx));
15363|    542|  }
15364|  1.25k|  ADA_ASSERT_TRUE(validate());
15365|  1.25k|  return true;
15366|  1.28k|}
_ZN3ada14url_aggregator15delete_dash_dotEv:
15525|      6|void url_aggregator::delete_dash_dot() {
15526|      6|  ada_log("url_aggregator::delete_dash_dot");
15527|      6|  ADA_ASSERT_TRUE(validate());
15528|      6|  ADA_ASSERT_TRUE(has_dash_dot());
15529|      6|  buffer.erase(components.host_end, 2);
15530|      6|  components.pathname_start -= 2;
15531|      6|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (15531:7): [True: 0, False: 6]
  ------------------
15532|      0|    components.search_start -= 2;
15533|      0|  }
15534|      6|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (15534:7): [True: 0, False: 6]
  ------------------
15535|      0|    components.hash_start -= 2;
15536|      0|  }
15537|      6|  ADA_ASSERT_TRUE(validate());
15538|      6|  ADA_ASSERT_TRUE(!has_dash_dot());
15539|      6|}
can_parse.cc:_ZZN3ada4idna22utf32_length_from_utf8EPKcmENK3$_0clEa:
  274|   387k|  return std::count_if(p, std::next(p, len), [](int8_t c) {
  275|       |    // -65 is 0b10111111, anything larger in two-complement's
  276|       |    // should start a new code point.
  277|   387k|    return c > -65;
  278|   387k|  });
_ZN3ada4idna7deflate22make_fixed_litlen_huffEv:
  481|      2|inline Huff make_fixed_litlen_huff() {
  482|      2|  Huff h;
  483|      2|  uint8_t lens[288];
  484|       |  // Fixed Huffman: 0-143:8, 144-255:9, 256-279:7, 280-287:8
  485|    290|  for (int i = 0; i <= 143; i++) lens[i] = 8;
  ------------------
  |  Branch (485:19): [True: 288, False: 2]
  ------------------
  486|    226|  for (int i = 144; i <= 255; i++) lens[i] = 9;
  ------------------
  |  Branch (486:21): [True: 224, False: 2]
  ------------------
  487|     50|  for (int i = 256; i <= 279; i++) lens[i] = 7;
  ------------------
  |  Branch (487:21): [True: 48, False: 2]
  ------------------
  488|     18|  for (int i = 280; i <= 287; i++) lens[i] = 8;
  ------------------
  |  Branch (488:21): [True: 16, False: 2]
  ------------------
  489|      2|  h.build(lens, 288);
  490|      2|  return h;
  491|      2|}
_ZN3ada4idna7deflate4Huff5buildEPKhi:
  430|     16|  bool build(const uint8_t* lens, int n) {
  431|     16|    std::memset(counts, 0, sizeof(counts));
  432|     16|    std::memset(first_code, 0, sizeof(first_code));
  433|     16|    std::memset(base_idx, 0, sizeof(base_idx));
  434|     16|    nsymbols = n;
  435|     16|    max_bits = 0;
  436|  1.99k|    for (int i = 0; i < n; i++) {
  ------------------
  |  Branch (436:21): [True: 1.97k, False: 16]
  ------------------
  437|  1.97k|      lengths[i] = lens[i];
  438|  1.97k|      if (lens[i]) {
  ------------------
  |  Branch (438:11): [True: 1.93k, False: 41]
  ------------------
  439|  1.93k|        counts[lens[i]]++;
  440|  1.93k|        if (lens[i] > max_bits) max_bits = lens[i];
  ------------------
  |  Branch (440:13): [True: 48, False: 1.88k]
  ------------------
  441|  1.93k|      }
  442|  1.97k|    }
  443|       |    // Canonical first code for each bit length (RFC 1951).
  444|     16|    int code = 0;
  445|    256|    for (int bits = 1; bits <= MAXBITS; bits++) {
  ------------------
  |  Branch (445:24): [True: 240, False: 16]
  ------------------
  446|    240|      code = (code + counts[bits - 1]) << 1;
  447|    240|      first_code[bits] = code;
  448|    240|    }
  449|     16|    int idx = 0;
  450|    157|    for (int bits = 1; bits <= max_bits; bits++) {
  ------------------
  |  Branch (450:24): [True: 141, False: 16]
  ------------------
  451|    141|      base_idx[bits] = idx;
  452|       |      // assign symbols in symbol order for codes of this length
  453|  21.7k|      for (int sym = 0; sym < n; sym++) {
  ------------------
  |  Branch (453:25): [True: 21.6k, False: 141]
  ------------------
  454|  21.6k|        if (lengths[sym] == bits) {
  ------------------
  |  Branch (454:13): [True: 1.93k, False: 19.6k]
  ------------------
  455|  1.93k|          symbols[idx++] = static_cast<int16_t>(sym);
  456|  1.93k|        }
  457|  21.6k|      }
  458|    141|    }
  459|     16|    return true;
  460|     16|  }
_ZN3ada4idna7deflate20make_fixed_dist_huffEv:
  493|      2|inline Huff make_fixed_dist_huff() {
  494|      2|  Huff h;
  495|      2|  uint8_t lens[32];
  496|     66|  for (int i = 0; i < 32; i++) lens[i] = 5;
  ------------------
  |  Branch (496:19): [True: 64, False: 2]
  ------------------
  497|      2|  h.build(lens, 32);
  498|      2|  return h;
  499|      2|}
can_parse.cc:_ZZN3ada4idna9ascii_mapEPcmENK3$_0clEh:
 5260|  18.1k|  auto broadcast = [](uint8_t v) -> uint64_t {
 5261|  18.1k|    return 0x101010101010101ull * v;
 5262|  18.1k|  };
_ZN3ada4idna13ensure_tablesEv:
 4983|  67.6k|[[nodiscard]] inline bool ensure_tables() noexcept {
 4984|  67.6k|  uint8_t state = tables_init_state.load(std::memory_order_acquire);
 4985|  67.6k|  if (state == kTablesReady) {
  ------------------
  |  Branch (4985:7): [True: 67.6k, False: 1]
  ------------------
 4986|  67.6k|    return true;
 4987|  67.6k|  }
 4988|      1|  if (state == kTablesFailed) {
  ------------------
  |  Branch (4988:7): [True: 0, False: 1]
  ------------------
 4989|      0|    return false;
 4990|      0|  }
 4991|       |
 4992|      1|  uint8_t expected = kTablesUninit;
 4993|      1|  if (tables_init_state.compare_exchange_strong(expected, kTablesInProgress,
  ------------------
  |  Branch (4993:7): [True: 1, False: 0]
  ------------------
 4994|      1|                                                std::memory_order_acq_rel,
 4995|      1|                                                std::memory_order_acquire)) {
 4996|      1|    uint8_t* buffer = new (std::nothrow) uint8_t[table_blob::uncompressed_size];
 4997|      1|    if (buffer == nullptr) {
  ------------------
  |  Branch (4997:9): [True: 0, False: 1]
  ------------------
 4998|       |      // Leave the state uninitialized so a later call can retry. A corrupt
 4999|       |      // blob (below) is permanent; running out of memory may not be.
 5000|       |      // LCOV_EXCL_START
 5001|      0|      tables_init_state.store(kTablesUninit, std::memory_order_release);
 5002|      0|      return false;
 5003|       |      // LCOV_EXCL_STOP
 5004|      0|    }
 5005|       |
 5006|      1|    const size_t n = deflate::inflate_raw(table_blob::compressed,
 5007|      1|                                          table_blob::compressed_size, buffer,
 5008|      1|                                          table_blob::uncompressed_size);
 5009|      1|    if (n != table_blob::uncompressed_size ||
  ------------------
  |  Branch (5009:9): [True: 0, False: 1]
  ------------------
 5010|      1|        crc32_ieee(buffer, n) != table_blob::uncompressed_crc32) {
  ------------------
  |  Branch (5010:9): [True: 0, False: 1]
  ------------------
 5011|      0|      delete[] buffer;
 5012|      0|      tables_init_state.store(kTablesFailed, std::memory_order_release);
 5013|      0|      return false;
 5014|      0|    }
 5015|       |
 5016|       |    // LE payload verified; convert multi-byte fields for big-endian hosts.
 5017|      1|    detail::convert_table_blob_to_host_endian(buffer);
 5018|       |
 5019|      1|    auto at = [&](size_t off) noexcept -> const uint8_t* {
 5020|      1|      return buffer + off;
 5021|      1|    };
 5022|       |
 5023|       |    // Publish all non-atomic pointers before READY. Waiters synchronize via
 5024|       |    // acquire on tables_init_state and then observe these writes.
 5025|      1|    idna_stage1 =
 5026|      1|        reinterpret_cast<const uint16_t*>(at(table_blob::off_idna_stage1));
 5027|      1|    idna_stage2 =
 5028|      1|        reinterpret_cast<const uint16_t*>(at(table_blob::off_idna_stage2));
 5029|      1|    idna_bool_blocks =
 5030|      1|        reinterpret_cast<const uint64_t*>(at(table_blob::off_idna_bool_blocks));
 5031|      1|    idna_utf8_mappings = at(table_blob::off_idna_utf8_mappings);
 5032|       |
 5033|      1|    decomposition_index = at(table_blob::off_decomposition_index);
 5034|      1|    decomposition_block_flat = reinterpret_cast<const uint16_t*>(
 5035|      1|        at(table_blob::off_decomposition_block));
 5036|      1|    decomposition_data = reinterpret_cast<const char32_t*>(
 5037|      1|        at(table_blob::off_decomposition_data));
 5038|      1|    ccc_index = at(table_blob::off_ccc_index);
 5039|      1|    ccc_block_flat = at(table_blob::off_ccc_block);
 5040|      1|    composition_index = at(table_blob::off_composition_index);
 5041|      1|    composition_block_flat = reinterpret_cast<const uint16_t*>(
 5042|      1|        at(table_blob::off_composition_block));
 5043|      1|    composition_data =
 5044|      1|        reinterpret_cast<const char32_t*>(at(table_blob::off_composition_data));
 5045|      1|    nfc_qc_index = at(table_blob::off_nfc_qc_index);
 5046|      1|    nfc_qc_block_flat = at(table_blob::off_nfc_qc_block);
 5047|       |
 5048|      1|    id_continue =
 5049|      1|        reinterpret_cast<range_pair_ptr>(at(table_blob::off_id_continue_flat));
 5050|      1|    id_start =
 5051|      1|        reinterpret_cast<range_pair_ptr>(at(table_blob::off_id_start_flat));
 5052|       |
 5053|      1|    dir_index = at(table_blob::off_dir_index);
 5054|      1|    dir_block_flat = at(table_blob::off_dir_block);
 5055|      1|    combining_ranges =
 5056|      1|        reinterpret_cast<range_pair_ptr>(at(table_blob::off_combining_flat));
 5057|      1|    joining_start =
 5058|      1|        reinterpret_cast<const uint32_t*>(at(table_blob::off_joining_start));
 5059|      1|    joining_final =
 5060|      1|        reinterpret_cast<const uint32_t*>(at(table_blob::off_joining_final));
 5061|      1|    joining_value = at(table_blob::off_joining_value);
 5062|       |
 5063|      1|    tables_buffer = buffer;
 5064|      1|    tables_init_state.store(kTablesReady, std::memory_order_release);
 5065|      1|    return true;
 5066|      1|  }
 5067|       |
 5068|       |  // Another thread owns init (or finished between our loads).
 5069|      0|  for (uint64_t spins = 0; spins < kTablesSpinLimit; ++spins) {
  ------------------
  |  Branch (5069:28): [True: 0, False: 0]
  ------------------
 5070|      0|    state = tables_init_state.load(std::memory_order_acquire);
 5071|      0|    if (state == kTablesReady) {
  ------------------
  |  Branch (5071:9): [True: 0, False: 0]
  ------------------
 5072|      0|      return true;
 5073|      0|    }
 5074|       |    // Failed is permanent. Uninit means the peer gave up after a failed
 5075|       |    // allocation: do not spin, the next call can take the init slot. One
 5076|       |    // comparison, same shape as the old Failed check, so this wait loop does
 5077|       |    // not grow the unity translation unit.
 5078|       |    // LCOV_EXCL_START
 5079|      0|    if (state != kTablesInProgress) {
  ------------------
  |  Branch (5079:9): [True: 0, False: 0]
  ------------------
 5080|      0|      return false;
 5081|      0|    }
 5082|       |    // LCOV_EXCL_STOP
 5083|      0|#if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || \
 5084|      0|    defined(_M_IX86)
 5085|      0|#if defined(__GNUC__) || defined(__clang__)
 5086|      0|    __builtin_ia32_pause();
 5087|      0|#endif
 5088|       |#elif defined(__aarch64__) || defined(_M_ARM64)
 5089|       |#if defined(__GNUC__) || defined(__clang__)
 5090|       |    asm volatile("yield" ::: "memory");
 5091|       |#endif
 5092|       |#endif
 5093|      0|  }
 5094|       |  // Timed out waiting for a peer - treat as failure rather than hang.
 5095|      0|  return false;
 5096|      0|}
_ZN3ada4idna7deflate11inflate_rawEPKhmPhm:
  526|      1|                          size_t dst_cap) {
  527|      1|  BitReader br(src, src_len);
  528|      1|  size_t out = 0;
  529|      4|  for (;;) {
  530|      4|    uint32_t bfinal = br.get(1);
  531|      4|    uint32_t btype = br.get(2);
  532|      4|    if (bfinal == UINT32_MAX || btype == UINT32_MAX) return 0;
  ------------------
  |  Branch (532:9): [True: 0, False: 4]
  |  Branch (532:33): [True: 0, False: 4]
  ------------------
  533|      4|    if (btype == 0) {
  ------------------
  |  Branch (533:9): [True: 0, False: 4]
  ------------------
  534|       |      // stored
  535|      0|      br.align_byte();
  536|      0|      if (!br.ensure(16)) return 0;
  ------------------
  |  Branch (536:11): [True: 0, False: 0]
  ------------------
  537|       |      // read 16+16 from bit buffer awkwardly - use byte path
  538|       |      // Align: bits is multiple of 8
  539|       |      // Get len from remaining bits then bytes
  540|      0|      uint32_t len = br.get(16);
  541|      0|      uint32_t nlen = br.get(16);
  542|      0|      if (len == UINT32_MAX || nlen == UINT32_MAX) return 0;
  ------------------
  |  Branch (542:11): [True: 0, False: 0]
  |  Branch (542:32): [True: 0, False: 0]
  ------------------
  543|      0|      if ((len ^ 0xFFFF) != nlen) return 0;
  ------------------
  |  Branch (543:11): [True: 0, False: 0]
  ------------------
  544|       |      // After get, may have bits in acc from previous - for stored, should be
  545|       |      // byte aligned Copy len bytes from p
  546|      0|      if (br.bits != 0) {
  ------------------
  |  Branch (546:11): [True: 0, False: 0]
  ------------------
  547|       |        // leftover bits should be 0 if aligned
  548|      0|      }
  549|      0|      if (size_t(br.end - br.p) < len) return 0;
  ------------------
  |  Branch (549:11): [True: 0, False: 0]
  ------------------
  550|      0|      if (out + len > dst_cap) return 0;
  ------------------
  |  Branch (550:11): [True: 0, False: 0]
  ------------------
  551|      0|      std::memcpy(dst + out, br.p, len);
  552|      0|      br.p += len;
  553|      0|      out += len;
  554|      4|    } else if (btype == 1 || btype == 2) {
  ------------------
  |  Branch (554:16): [True: 0, False: 4]
  |  Branch (554:30): [True: 4, False: 0]
  ------------------
  555|      4|      Huff lit, dist;
  556|      4|      if (btype == 1) {
  ------------------
  |  Branch (556:11): [True: 0, False: 4]
  ------------------
  557|       |        // use fixed via functions
  558|      4|      } else {
  559|       |        // dynamic
  560|      4|        uint32_t hlit = br.get(5);
  561|      4|        if (hlit == UINT32_MAX) return 0;
  ------------------
  |  Branch (561:13): [True: 0, False: 4]
  ------------------
  562|      4|        hlit += 257;
  563|      4|        uint32_t hdist = br.get(5);
  564|      4|        if (hdist == UINT32_MAX) return 0;
  ------------------
  |  Branch (564:13): [True: 0, False: 4]
  ------------------
  565|      4|        hdist += 1;
  566|      4|        uint32_t hclen = br.get(4);
  567|      4|        if (hclen == UINT32_MAX) return 0;
  ------------------
  |  Branch (567:13): [True: 0, False: 4]
  ------------------
  568|      4|        hclen += 4;
  569|      4|        static const int order[19] = {16, 17, 18, 0, 8,  7, 9,  6, 10, 5,
  570|      4|                                      11, 4,  12, 3, 13, 2, 14, 1, 15};
  571|      4|        uint8_t clen[19]{};
  572|     69|        for (uint32_t i = 0; i < hclen; i++) {
  ------------------
  |  Branch (572:30): [True: 65, False: 4]
  ------------------
  573|     65|          uint32_t v = br.get(3);
  574|     65|          if (v == UINT32_MAX) return 0;
  ------------------
  |  Branch (574:15): [True: 0, False: 65]
  ------------------
  575|     65|          clen[order[i]] = uint8_t(v);
  576|     65|        }
  577|      4|        Huff cl;
  578|      4|        if (!cl.build(clen, 19)) return 0;
  ------------------
  |  Branch (578:13): [True: 0, False: 4]
  ------------------
  579|      4|        uint8_t lens[288 + 32]{};
  580|      4|        uint32_t n = hlit + hdist;
  581|  1.06k|        for (uint32_t i = 0; i < n;) {
  ------------------
  |  Branch (581:30): [True: 1.06k, False: 4]
  ------------------
  582|  1.06k|          int sym = cl.decode(br);
  583|  1.06k|          if (sym < 0) return 0;
  ------------------
  |  Branch (583:15): [True: 0, False: 1.06k]
  ------------------
  584|  1.06k|          if (sym < 16) {
  ------------------
  |  Branch (584:15): [True: 1.00k, False: 60]
  ------------------
  585|  1.00k|            lens[i++] = uint8_t(sym);
  586|  1.00k|          } else if (sym == 16) {
  ------------------
  |  Branch (586:22): [True: 60, False: 0]
  ------------------
  587|     60|            uint32_t rep = br.get(2);
  588|     60|            if (rep == UINT32_MAX) return 0;
  ------------------
  |  Branch (588:17): [True: 0, False: 60]
  ------------------
  589|     60|            rep += 3;
  590|     60|            if (i == 0) return 0;
  ------------------
  |  Branch (590:17): [True: 0, False: 60]
  ------------------
  591|     60|            uint8_t v = lens[i - 1];
  592|    318|            while (rep--) lens[i++] = v;
  ------------------
  |  Branch (592:20): [True: 258, False: 60]
  ------------------
  593|     60|          } else if (sym == 17) {
  ------------------
  |  Branch (593:22): [True: 0, False: 0]
  ------------------
  594|      0|            uint32_t rep = br.get(3);
  595|      0|            if (rep == UINT32_MAX) return 0;
  ------------------
  |  Branch (595:17): [True: 0, False: 0]
  ------------------
  596|      0|            rep += 3;
  597|      0|            while (rep--) lens[i++] = 0;
  ------------------
  |  Branch (597:20): [True: 0, False: 0]
  ------------------
  598|      0|          } else if (sym == 18) {
  ------------------
  |  Branch (598:22): [True: 0, False: 0]
  ------------------
  599|      0|            uint32_t rep = br.get(7);
  600|      0|            if (rep == UINT32_MAX) return 0;
  ------------------
  |  Branch (600:17): [True: 0, False: 0]
  ------------------
  601|      0|            rep += 11;
  602|      0|            while (rep--) lens[i++] = 0;
  ------------------
  |  Branch (602:20): [True: 0, False: 0]
  ------------------
  603|      0|          } else
  604|      0|            return 0;
  605|  1.06k|        }
  606|      4|        if (!lit.build(lens, int(hlit))) return 0;
  ------------------
  |  Branch (606:13): [True: 0, False: 4]
  ------------------
  607|      4|        if (!dist.build(lens + hlit, int(hdist))) return 0;
  ------------------
  |  Branch (607:13): [True: 0, False: 4]
  ------------------
  608|      4|      }
  609|  53.6k|      for (;;) {
  610|  53.6k|        int sym;
  611|  53.6k|        if (btype == 1)
  ------------------
  |  Branch (611:13): [True: 0, False: 53.6k]
  ------------------
  612|      0|          sym = fixed_litlen(br);
  613|  53.6k|        else
  614|  53.6k|          sym = lit.decode(br);
  615|  53.6k|        if (sym < 0) return 0;
  ------------------
  |  Branch (615:13): [True: 0, False: 53.6k]
  ------------------
  616|  53.6k|        if (sym < 256) {
  ------------------
  |  Branch (616:13): [True: 38.1k, False: 15.5k]
  ------------------
  617|  38.1k|          if (out >= dst_cap) return 0;
  ------------------
  |  Branch (617:15): [True: 0, False: 38.1k]
  ------------------
  618|  38.1k|          dst[out++] = uint8_t(sym);
  619|  38.1k|        } else if (sym == 256) {
  ------------------
  |  Branch (619:20): [True: 4, False: 15.5k]
  ------------------
  620|      4|          break;
  621|  15.5k|        } else {
  622|  15.5k|          int len_code = sym - 257;
  623|  15.5k|          if (len_code < 0 || len_code > 28) return 0;
  ------------------
  |  Branch (623:15): [True: 0, False: 15.5k]
  |  Branch (623:31): [True: 0, False: 15.5k]
  ------------------
  624|  15.5k|          uint32_t extra = br.get(len_extra[len_code]);
  625|  15.5k|          if (len_extra[len_code] && extra == UINT32_MAX) return 0;
  ------------------
  |  Branch (625:15): [True: 2.60k, False: 12.9k]
  |  Branch (625:38): [True: 0, False: 2.60k]
  ------------------
  626|  15.5k|          uint32_t length =
  627|  15.5k|              len_base[len_code] + (len_extra[len_code] ? extra : 0);
  ------------------
  |  Branch (627:37): [True: 2.60k, False: 12.9k]
  ------------------
  628|  15.5k|          int dsym;
  629|  15.5k|          if (btype == 1)
  ------------------
  |  Branch (629:15): [True: 0, False: 15.5k]
  ------------------
  630|      0|            dsym = fixed_dist(br);
  631|  15.5k|          else
  632|  15.5k|            dsym = dist.decode(br);
  633|  15.5k|          if (dsym < 0 || dsym > 29) return 0;
  ------------------
  |  Branch (633:15): [True: 0, False: 15.5k]
  |  Branch (633:27): [True: 0, False: 15.5k]
  ------------------
  634|  15.5k|          uint32_t dextra = br.get(dist_extra[dsym]);
  635|  15.5k|          if (dist_extra[dsym] && dextra == UINT32_MAX) return 0;
  ------------------
  |  Branch (635:15): [True: 9.94k, False: 5.58k]
  |  Branch (635:35): [True: 0, False: 9.94k]
  ------------------
  636|  15.5k|          uint32_t distance = dist_base[dsym] + (dist_extra[dsym] ? dextra : 0);
  ------------------
  |  Branch (636:50): [True: 9.94k, False: 5.58k]
  ------------------
  637|  15.5k|          if (distance > out || out + length > dst_cap) return 0;
  ------------------
  |  Branch (637:15): [True: 0, False: 15.5k]
  |  Branch (637:33): [True: 0, False: 15.5k]
  ------------------
  638|   236k|          for (uint32_t k = 0; k < length; k++) {
  ------------------
  |  Branch (638:32): [True: 220k, False: 15.5k]
  ------------------
  639|   220k|            dst[out] = dst[out - distance];
  640|   220k|            out++;
  641|   220k|          }
  642|  15.5k|        }
  643|  53.6k|      }
  644|      4|    } else {
  645|      0|      return 0;  // reserved
  646|      0|    }
  647|      4|    if (bfinal) break;
  ------------------
  |  Branch (647:9): [True: 1, False: 3]
  ------------------
  648|      4|  }
  649|      1|  return out;
  650|      1|}
_ZN3ada4idna7deflate9BitReaderC2EPKhm:
  393|      1|      : p(data), end(data + len) {}
_ZN3ada4idna7deflate9BitReader3getEi:
  403|   471k|  uint32_t get(int n) {
  404|   471k|    if (!ensure(n)) return UINT32_MAX;
  ------------------
  |  Branch (404:9): [True: 0, False: 471k]
  ------------------
  405|   471k|    uint32_t v = acc & ((1u << n) - 1);
  406|   471k|    acc >>= n;
  407|   471k|    bits -= n;
  408|   471k|    return v;
  409|   471k|  }
_ZN3ada4idna7deflate9BitReader6ensureEi:
  395|   471k|  bool ensure(int n) {
  396|   534k|    while (bits < n) {
  ------------------
  |  Branch (396:12): [True: 63.5k, False: 471k]
  ------------------
  397|  63.5k|      if (p >= end) return false;
  ------------------
  |  Branch (397:11): [True: 0, False: 63.5k]
  ------------------
  398|  63.5k|      acc |= uint32_t(*p++) << bits;
  399|  63.5k|      bits += 8;
  400|  63.5k|    }
  401|   471k|    return true;
  402|   471k|  }
_ZNK3ada4idna7deflate4Huff6decodeERNS1_9BitReaderE:
  462|  70.2k|  int decode(BitReader& br) const {
  463|  70.2k|    if (max_bits == 0) return -1;
  ------------------
  |  Branch (463:9): [True: 0, False: 70.2k]
  ------------------
  464|  70.2k|    int code = 0;
  465|   439k|    for (int len = 1; len <= max_bits; len++) {
  ------------------
  |  Branch (465:23): [True: 439k, False: 0]
  ------------------
  466|   439k|      uint32_t b = br.get(1);
  467|   439k|      if (b == UINT32_MAX) return -1;
  ------------------
  |  Branch (467:11): [True: 0, False: 439k]
  ------------------
  468|   439k|      code = (code << 1) | int(b);
  469|   439k|      int first = first_code[len];
  470|   439k|      int cnt = counts[len];
  471|   439k|      if (cnt && code - first < cnt) {
  ------------------
  |  Branch (471:11): [True: 271k, False: 168k]
  |  Branch (471:18): [True: 70.2k, False: 201k]
  ------------------
  472|  70.2k|        return symbols[base_idx[len] + (code - first)];
  473|  70.2k|      }
  474|   439k|    }
  475|      0|    return -1;
  476|  70.2k|  }
_ZN3ada4idna10crc32_ieeeEPKhm:
 4966|      1|                                         size_t len) noexcept {
 4967|      1|  uint32_t c = 0xFFFFFFFFu;
 4968|   258k|  for (size_t i = 0; i < len; ++i) {
  ------------------
  |  Branch (4968:22): [True: 258k, False: 1]
  ------------------
 4969|   258k|    c ^= data[i];
 4970|  2.32M|    for (int k = 0; k < 8; ++k) {
  ------------------
  |  Branch (4970:21): [True: 2.06M, False: 258k]
  ------------------
 4971|  2.06M|      const uint32_t mask = 0u - (c & 1u);
 4972|  2.06M|      c = (c >> 1) ^ (0xEDB88320u & mask);
 4973|  2.06M|    }
 4974|   258k|  }
 4975|      1|  return ~c;
 4976|      1|}
_ZN3ada4idna6detail33convert_table_blob_to_host_endianEPh:
 4766|      1|inline void convert_table_blob_to_host_endian(uint8_t* buffer) noexcept {
 4767|      1|  if constexpr (std::endian::native == std::endian::little) {
 4768|      1|    (void)buffer;
 4769|      1|    return;
 4770|      1|  }
 4771|      0|  auto u16 = [&](size_t off, size_t count) {
 4772|      1|    bswap_inplace(reinterpret_cast<uint16_t*>(buffer + off), count);
 4773|      1|  };
 4774|      1|  auto u32 = [&](size_t off, size_t count) {
 4775|      1|    bswap_inplace(reinterpret_cast<uint32_t*>(buffer + off), count);
 4776|      1|  };
 4777|      1|  auto u64 = [&](size_t off, size_t count) {
 4778|      1|    bswap_inplace(reinterpret_cast<uint64_t*>(buffer + off), count);
 4779|      1|  };
 4780|       |
 4781|      1|  u16(table_blob::off_idna_stage1, table_blob::count_idna_stage1);
 4782|      1|  u16(table_blob::off_idna_stage2, table_blob::count_idna_stage2);
 4783|      1|  u64(table_blob::off_idna_bool_blocks, table_blob::count_idna_bool_blocks);
 4784|      1|  u16(table_blob::off_decomposition_block,
 4785|      1|      table_blob::count_decomposition_block);
 4786|      1|  u32(table_blob::off_decomposition_data, table_blob::count_decomposition_data);
 4787|      1|  u16(table_blob::off_composition_block, table_blob::count_composition_block);
 4788|      1|  u32(table_blob::off_composition_data, table_blob::count_composition_data);
 4789|      1|  u32(table_blob::off_id_continue_flat, table_blob::count_id_continue_flat);
 4790|      1|  u32(table_blob::off_id_start_flat, table_blob::count_id_start_flat);
 4791|      1|  u32(table_blob::off_combining_flat, table_blob::count_combining_flat);
 4792|      1|  u32(table_blob::off_joining_start, table_blob::count_joining_start);
 4793|      1|  u32(table_blob::off_joining_final, table_blob::count_joining_final);
 4794|      1|}
_ZZN3ada4idna13ensure_tablesEvENKUlmE_clEm:
 5019|     22|    auto at = [&](size_t off) noexcept -> const uint8_t* {
 5020|     22|      return buffer + off;
 5021|     22|    };
can_parse.cc:_ZN3ada4idnaL11idna_lookupEj:
 5198|   600k|static uint16_t idna_lookup(uint32_t cp) noexcept {
 5199|   600k|  if (cp < IDNA_LOW_RANGE_END) {
  ------------------
  |  Branch (5199:7): [True: 598k, False: 2.56k]
  ------------------
 5200|   598k|    uint16_t ref = idna_stage1[cp >> IDNA_BLOCK_BITS];
 5201|   598k|    if (ref & IDNA_BOOL_FLAG) {
  ------------------
  |  Branch (5201:9): [True: 254k, False: 343k]
  ------------------
 5202|   254k|      uint32_t bit_idx =
 5203|   254k|          static_cast<uint32_t>(ref & ~IDNA_BOOL_FLAG) * IDNA_BLOCK_SIZE +
 5204|   254k|          (cp & IDNA_BLOCK_MASK);
 5205|   254k|      bool is_valid = (idna_bool_blocks[bit_idx >> 6] >> (bit_idx & 63u)) & 1u;
 5206|   254k|      return is_valid ? IDNA_VALID : IDNA_DISALLOWED;
  ------------------
  |  Branch (5206:14): [True: 254k, False: 48]
  ------------------
 5207|   254k|    }
 5208|   343k|    return idna_stage2[ref + (cp & IDNA_BLOCK_MASK)];
 5209|   598k|  }
 5210|       |
 5211|  2.56k|  if (cp >= IDNA_HIGH_IGNORED_START && cp < IDNA_HIGH_IGNORED_END) {
  ------------------
  |  Branch (5211:7): [True: 2.48k, False: 78]
  |  Branch (5211:40): [True: 2.05k, False: 435]
  ------------------
 5212|  2.05k|    return IDNA_IGNORED;
 5213|  2.05k|  }
 5214|       |
 5215|    513|  return IDNA_DISALLOWED;
 5216|  2.56k|}
can_parse.cc:_ZN3ada4idnaL21utf8_count_codepointsEPKh:
 5241|   104k|static size_t utf8_count_codepoints(const uint8_t* ptr) noexcept {
 5242|   104k|  size_t n = 0;
 5243|   464k|  while (*ptr != 0) {
  ------------------
  |  Branch (5243:10): [True: 359k, False: 104k]
  ------------------
 5244|   359k|    ++n;
 5245|   359k|    if (*ptr < 0x80u) {
  ------------------
  |  Branch (5245:9): [True: 103k, False: 256k]
  ------------------
 5246|   103k|      ++ptr;
 5247|   256k|    } else if (*ptr < 0xE0u) {
  ------------------
  |  Branch (5247:16): [True: 130k, False: 126k]
  ------------------
 5248|   130k|      ptr += 2;
 5249|   130k|    } else if (*ptr < 0xF0u) {
  ------------------
  |  Branch (5249:16): [True: 123k, False: 2.18k]
  ------------------
 5250|   123k|      ptr += 3;
 5251|   123k|    } else {
 5252|  2.18k|      ptr += 4;
 5253|  2.18k|    }
 5254|   359k|  }
 5255|   104k|  return n;
 5256|   104k|}
can_parse.cc:_ZN3ada4idnaL9utf8_nextERPKh:
 5219|   358k|static char32_t utf8_next(const uint8_t*& ptr) noexcept {
 5220|   358k|  uint8_t b0 = *ptr++;
 5221|   358k|  if (b0 < 0x80u) return static_cast<char32_t>(b0);
  ------------------
  |  Branch (5221:7): [True: 103k, False: 254k]
  ------------------
 5222|   254k|  if (b0 < 0xE0u) {
  ------------------
  |  Branch (5222:7): [True: 130k, False: 124k]
  ------------------
 5223|   130k|    uint32_t cp = (b0 & 0x1Fu) << 6;
 5224|   130k|    cp |= (*ptr++ & 0x3Fu);
 5225|   130k|    return static_cast<char32_t>(cp);
 5226|   130k|  }
 5227|   124k|  if (b0 < 0xF0u) {
  ------------------
  |  Branch (5227:7): [True: 122k, False: 2.18k]
  ------------------
 5228|   122k|    uint32_t cp = (b0 & 0x0Fu) << 12;
 5229|   122k|    cp |= ((*ptr++ & 0x3Fu) << 6);
 5230|   122k|    cp |= (*ptr++ & 0x3Fu);
 5231|   122k|    return static_cast<char32_t>(cp);
 5232|   122k|  }
 5233|  2.18k|  uint32_t cp = (b0 & 0x07u) << 18;
 5234|  2.18k|  cp |= ((*ptr++ & 0x3Fu) << 12);
 5235|  2.18k|  cp |= ((*ptr++ & 0x3Fu) << 6);
 5236|  2.18k|  cp |= (*ptr++ & 0x3Fu);
 5237|  2.18k|  return static_cast<char32_t>(cp);
 5238|   124k|}
_ZN3ada4idna23decomposition_block_rowEh:
 5101|   377k|inline const uint16_t* decomposition_block_row(uint8_t bi) noexcept {
 5102|   377k|  if (bi >= kDecompBlockRows) {
  ------------------
  |  Branch (5102:7): [True: 0, False: 377k]
  ------------------
 5103|      0|    bi = 0;
 5104|      0|  }
 5105|   377k|  return decomposition_block_flat + static_cast<size_t>(bi) * kDecompBlockCols;
 5106|   377k|}
_ZN3ada4idna13ccc_block_rowEh:
 5108|   796k|inline const uint8_t* ccc_block_row(uint8_t bi) noexcept {
 5109|   796k|  if (bi >= kCccBlockRows) {
  ------------------
  |  Branch (5109:7): [True: 0, False: 796k]
  ------------------
 5110|      0|    bi = 0;
 5111|      0|  }
 5112|   796k|  return ccc_block_flat + static_cast<size_t>(bi) * kCccBlockCols;
 5113|   796k|}
_ZN3ada4idna16tables_are_readyEv:
 4978|  13.7k|[[nodiscard]] inline bool tables_are_ready() noexcept {
 4979|  13.7k|  return tables_init_state.load(std::memory_order_acquire) == kTablesReady;
 4980|  13.7k|}
can_parse.cc:_ZN3ada4idnaL19get_nfc_quick_checkEDi:
 5645|   256k|static nfc_quick_check get_nfc_quick_check(char32_t c) noexcept {
 5646|   256k|  if (c >= 0x110000) {
  ------------------
  |  Branch (5646:7): [True: 0, False: 256k]
  ------------------
 5647|      0|    return nfc_quick_check::yes;
 5648|      0|  }
 5649|   256k|  return static_cast<nfc_quick_check>(
 5650|   256k|      nfc_qc_block_row(nfc_qc_index[c >> 8])[c % 256]);
 5651|   256k|}
_ZN3ada4idna16nfc_qc_block_rowEh:
 5122|   256k|inline const uint8_t* nfc_qc_block_row(uint8_t bi) noexcept {
 5123|   256k|  if (bi >= kNfcQcBlockRows) {
  ------------------
  |  Branch (5123:7): [True: 0, False: 256k]
  ------------------
 5124|      0|    bi = 0;
 5125|      0|  }
 5126|   256k|  return nfc_qc_block_flat + static_cast<size_t>(bi) * kNfcQcBlockCols;
 5127|   256k|}
can_parse.cc:_ZN3ada4idnaL12maybe_is_nfcENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 5656|  4.20k|static bool maybe_is_nfc(std::u32string_view input) noexcept {
 5657|       |  // 1) A character whose decomposition starts with a code point that composes
 5658|       |  //    with the previous character (e.g. U+1611E U+16121).
 5659|  4.20k|  char32_t previous = 0x110000;  // none
 5660|   136k|  for (char32_t c : input) {
  ------------------
  |  Branch (5660:19): [True: 136k, False: 4.12k]
  ------------------
 5661|   136k|    if (decomposition_composes_with_previous(previous, c)) {
  ------------------
  |  Branch (5661:9): [True: 78, False: 136k]
  ------------------
 5662|     78|      return false;
 5663|     78|    }
 5664|   136k|    previous = c;
 5665|   136k|  }
 5666|       |  // 2) Combining marks already in canonical order. prev_ccc carries the
 5667|       |  //    trailing class of the previous character's canonical decomposition so a
 5668|       |  //    composite starter followed by a lower-class mark is caught.
 5669|  4.12k|  uint8_t prev_ccc = 0;
 5670|   132k|  for (char32_t c : input) {
  ------------------
  |  Branch (5670:19): [True: 132k, False: 3.69k]
  ------------------
 5671|   132k|    uint8_t ccc = get_ccc(c);
 5672|   132k|    if (ccc != 0 && prev_ccc > ccc) {
  ------------------
  |  Branch (5672:9): [True: 12.7k, False: 119k]
  |  Branch (5672:21): [True: 432, False: 12.3k]
  ------------------
 5673|    432|      return false;
 5674|    432|    }
 5675|   132k|    prev_ccc = trailing_ccc(c);
 5676|   132k|  }
 5677|       |  // 3) No pairwise composition would apply (including Hangul L+V / LV+T).
 5678|  3.69k|  return !would_compose(input);
 5679|  4.12k|}
can_parse.cc:_ZN3ada4idnaL36decomposition_composes_with_previousEDiDi:
 5620|   136k|                                                 char32_t c) noexcept {
 5621|   136k|  const size_t length = canonical_decomp_length(c);
 5622|   136k|  if (length < 2 || previous >= 0x110000) {
  ------------------
  |  Branch (5622:7): [True: 126k, False: 10.2k]
  |  Branch (5622:21): [True: 627, False: 9.62k]
  ------------------
 5623|   126k|    return false;
 5624|   126k|  }
 5625|  9.62k|  const uint16_t* const decomposition =
 5626|  9.62k|      decomposition_block_row(decomposition_index[c >> 8]) + (c % 256);
 5627|  9.62k|  const size_t base = decomposition[0] >> 2;
 5628|  9.62k|  if (base + length > decomposition_data_size) {
  ------------------
  |  Branch (5628:7): [True: 0, False: 9.62k]
  ------------------
 5629|      0|    return false;
 5630|      0|  }
 5631|  9.62k|  return has_composition(
 5632|  9.62k|      composition_block_row(composition_index[previous >> 8]) +
 5633|  9.62k|          (previous % 256),
 5634|  9.62k|      decomposition_data[base]);
 5635|  9.62k|}
can_parse.cc:_ZN3ada4idnaL23canonical_decomp_lengthEDi:
 5399|   268k|static size_t canonical_decomp_length(char32_t current_character) noexcept {
 5400|   268k|  if (current_character >= hangul_sbase &&
  ------------------
  |  Branch (5400:7): [True: 33.0k, False: 235k]
  ------------------
 5401|  33.0k|      current_character < hangul_sbase + hangul_scount) {
  ------------------
  |  Branch (5401:7): [True: 8.65k, False: 24.3k]
  ------------------
 5402|       |    // Hangul precomposed syllables are NFC.
 5403|  8.65k|    return 0;
 5404|  8.65k|  }
 5405|   260k|  if (current_character >= 0x110000) {
  ------------------
  |  Branch (5405:7): [True: 0, False: 260k]
  ------------------
 5406|      0|    return 0;
 5407|      0|  }
 5408|   260k|  const uint8_t di = decomposition_index[current_character >> 8];
 5409|   260k|  const uint16_t* const decomposition =
 5410|   260k|      decomposition_block_row(di) + (current_character % 256);
 5411|   260k|  size_t decomposition_length =
 5412|   260k|      (decomposition[1] >> 2) - (decomposition[0] >> 2);
 5413|   260k|  if ((decomposition_length > 0) && (decomposition[0] & 1)) {
  ------------------
  |  Branch (5413:7): [True: 19.5k, False: 240k]
  |  Branch (5413:37): [True: 0, False: 19.5k]
  ------------------
 5414|      0|    decomposition_length = 0;  // compatibility-only: ignored for NFC
 5415|      0|  }
 5416|   260k|  return decomposition_length;
 5417|   260k|}
can_parse.cc:_ZN3ada4idnaL15has_compositionEPKtDi:
 5532|  34.2k|                            char32_t second) noexcept {
 5533|  34.2k|  int left = composition[0];
 5534|  34.2k|  int right = composition[1];
 5535|  34.2k|  if (left < 0 || right <= left ||
  ------------------
  |  Branch (5535:7): [True: 0, False: 34.2k]
  |  Branch (5535:19): [True: 6.42k, False: 27.8k]
  ------------------
 5536|  27.8k|      static_cast<size_t>(right) > composition_data_size) {
  ------------------
  |  Branch (5536:7): [True: 0, False: 27.8k]
  ------------------
 5537|  6.42k|    return false;
 5538|  6.42k|  }
 5539|  60.1k|  while (left + 2 < right) {
  ------------------
  |  Branch (5539:10): [True: 32.3k, False: 27.8k]
  ------------------
 5540|  32.3k|    int middle = left + (((right - left) >> 1) & ~1);
 5541|  32.3k|    if (composition_data[static_cast<size_t>(middle)] <= second) {
  ------------------
  |  Branch (5541:9): [True: 8.78k, False: 23.5k]
  ------------------
 5542|  8.78k|      left = middle;
 5543|  8.78k|    }
 5544|  32.3k|    if (composition_data[static_cast<size_t>(middle)] >= second) {
  ------------------
  |  Branch (5544:9): [True: 25.5k, False: 6.83k]
  ------------------
 5545|  25.5k|      right = middle;
 5546|  25.5k|    }
 5547|  32.3k|  }
 5548|  27.8k|  return static_cast<size_t>(left + 1) < composition_data_size &&
  ------------------
  |  Branch (5548:10): [True: 27.8k, False: 0]
  ------------------
 5549|  27.8k|         composition_data[static_cast<size_t>(left)] == second;
  ------------------
  |  Branch (5549:10): [True: 2.62k, False: 25.2k]
  ------------------
 5550|  34.2k|}
can_parse.cc:_ZN3ada4idnaL12trailing_cccEDi:
 5605|   132k|static uint8_t trailing_ccc(char32_t c) noexcept {
 5606|   132k|  const size_t length = canonical_decomp_length(c);
 5607|   132k|  if (length == 0) {
  ------------------
  |  Branch (5607:7): [True: 123k, False: 9.26k]
  ------------------
 5608|   123k|    return get_ccc(c);
 5609|   123k|  }
 5610|  9.26k|  const uint16_t* const decomposition =
 5611|  9.26k|      decomposition_block_row(decomposition_index[c >> 8]) + (c % 256);
 5612|  9.26k|  const size_t base = decomposition[0] >> 2;
 5613|  9.26k|  return get_ccc(decomposition_data[base + length - 1]);
 5614|   132k|}
can_parse.cc:_ZN3ada4idnaL13would_composeENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 5553|  3.69k|static bool would_compose(std::u32string_view input) noexcept {
 5554|   102k|  for (size_t input_count = 0; input_count < input.size();) {
  ------------------
  |  Branch (5554:32): [True: 101k, False: 708]
  ------------------
 5555|   101k|    const char32_t current = input[input_count];
 5556|   101k|    if (current >= hangul_lbase && current < hangul_lbase + hangul_lcount) {
  ------------------
  |  Branch (5556:9): [True: 24.4k, False: 77.2k]
  |  Branch (5556:36): [True: 5.48k, False: 18.9k]
  ------------------
 5557|  5.48k|      if (input_count + 1 < input.size() &&
  ------------------
  |  Branch (5557:11): [True: 5.44k, False: 36]
  ------------------
 5558|  5.44k|          input[input_count + 1] >= hangul_vbase &&
  ------------------
  |  Branch (5558:11): [True: 1.25k, False: 4.18k]
  ------------------
 5559|  1.25k|          input[input_count + 1] < hangul_vbase + hangul_vcount) {
  ------------------
  |  Branch (5559:11): [True: 258, False: 999]
  ------------------
 5560|    258|        return true;
 5561|    258|      }
 5562|  5.22k|      ++input_count;
 5563|  5.22k|      continue;
 5564|  5.48k|    }
 5565|  96.1k|    if (current >= hangul_sbase && current < hangul_sbase + hangul_scount) {
  ------------------
  |  Branch (5565:9): [True: 12.1k, False: 84.0k]
  |  Branch (5565:36): [True: 3.82k, False: 8.34k]
  ------------------
 5566|  3.82k|      if ((current - hangul_sbase) % hangul_tcount == 0 &&
  ------------------
  |  Branch (5566:11): [True: 1.89k, False: 1.93k]
  ------------------
 5567|  1.89k|          input_count + 1 < input.size() &&
  ------------------
  |  Branch (5567:11): [True: 1.86k, False: 27]
  ------------------
 5568|  1.86k|          input[input_count + 1] > hangul_tbase &&
  ------------------
  |  Branch (5568:11): [True: 1.57k, False: 291]
  ------------------
 5569|  1.57k|          input[input_count + 1] < hangul_tbase + hangul_tcount) {
  ------------------
  |  Branch (5569:11): [True: 180, False: 1.39k]
  ------------------
 5570|    180|        return true;
 5571|    180|      }
 5572|  3.64k|      ++input_count;
 5573|  3.64k|      continue;
 5574|  3.82k|    }
 5575|  92.3k|    if (current < 0x110000) {
  ------------------
  |  Branch (5575:9): [True: 92.3k, False: 0]
  ------------------
 5576|  92.3k|      const uint16_t* composition =
 5577|  92.3k|          composition_block_row(composition_index[current >> 8]) +
 5578|  92.3k|          (current % 256);
 5579|  92.3k|      int32_t previous_ccc = -1;
 5580|  92.3k|      size_t j = input_count;
 5581|  98.2k|      for (; j + 1 < input.size(); ++j) {
  ------------------
  |  Branch (5581:14): [True: 97.6k, False: 633]
  ------------------
 5582|  97.6k|        uint8_t ccc = get_ccc(input[j + 1]);
 5583|  97.6k|        if (composition[1] != composition[0] && previous_ccc < ccc &&
  ------------------
  |  Branch (5583:13): [True: 27.6k, False: 70.0k]
  |  Branch (5583:49): [True: 24.6k, False: 2.99k]
  ------------------
 5584|  24.6k|            has_composition(composition, input[j + 1])) {
  ------------------
  |  Branch (5584:13): [True: 2.55k, False: 22.0k]
  ------------------
 5585|  2.55k|          return true;
 5586|  2.55k|        }
 5587|  95.0k|        if (ccc == 0) {
  ------------------
  |  Branch (5587:13): [True: 89.1k, False: 5.91k]
  ------------------
 5588|  89.1k|          break;
 5589|  89.1k|        }
 5590|  5.91k|        previous_ccc = ccc;
 5591|  5.91k|      }
 5592|  89.8k|      input_count = j + 1;
 5593|  89.8k|      continue;
 5594|  92.3k|    }
 5595|      0|    ++input_count;
 5596|      0|  }
 5597|    708|  return false;
 5598|  3.69k|}
_ZN3ada4idna21composition_block_rowEh:
 5115|   164k|inline const uint16_t* composition_block_row(uint8_t bi) noexcept {
 5116|   164k|  if (bi >= kCompBlockRows) {
  ------------------
  |  Branch (5116:7): [True: 0, False: 164k]
  ------------------
 5117|      0|    bi = 0;
 5118|      0|  }
 5119|   164k|  return composition_block_flat + static_cast<size_t>(bi) * kCompBlockCols;
 5120|   164k|}
can_parse.cc:_ZN3ada4idnaL19char_to_digit_valueEc:
 5853|  71.5k|static constexpr int32_t char_to_digit_value(char value) {
 5854|  71.5k|  if (value >= 'a' && value <= 'z') return value - 'a';
  ------------------
  |  Branch (5854:7): [True: 64.1k, False: 7.40k]
  |  Branch (5854:23): [True: 64.1k, False: 15]
  ------------------
 5855|  7.42k|  if (value >= '0' && value <= '9') return value - '0' + 26;
  ------------------
  |  Branch (5855:7): [True: 7.35k, False: 69]
  |  Branch (5855:23): [True: 7.32k, False: 30]
  ------------------
 5856|     99|  return -1;
 5857|  7.42k|}
can_parse.cc:_ZN3ada4idnaL5adaptEiib:
 5863|   192k|static constexpr int32_t adapt(int32_t d, int32_t n, bool firsttime) {
 5864|   192k|  if (firsttime) {
  ------------------
  |  Branch (5864:7): [True: 40.3k, False: 152k]
  ------------------
 5865|  40.3k|    d = d / damp;
 5866|   152k|  } else {
 5867|   152k|    d = d / 2;
 5868|   152k|  }
 5869|   192k|  d += d / n;
 5870|   192k|  int32_t k = 0;
 5871|   282k|  while (d > ((base - tmin) * tmax) / 2) {
  ------------------
  |  Branch (5871:10): [True: 89.8k, False: 192k]
  ------------------
 5872|  89.8k|    d /= base - tmin;
 5873|  89.8k|    k += base;
 5874|  89.8k|  }
 5875|   192k|  return k + (((base - tmin + 1) * d) / (d + skew));
 5876|   192k|}
can_parse.cc:_ZN3ada4idnaL13digit_to_charEi:
 5859|   416k|static constexpr char digit_to_char(int32_t digit) {
 5860|   416k|  return digit < 26 ? char(digit + 97) : char(digit + 22);
  ------------------
  |  Branch (5860:10): [True: 282k, False: 133k]
  ------------------
 5861|   416k|}
can_parse.cc:_ZN3ada4idnaL11check_labelENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 6260|  49.9k|static label_check check_label(const std::u32string_view label) {
 6261|  49.9k|  if (label.empty()) {
  ------------------
  |  Branch (6261:7): [True: 0, False: 49.9k]
  ------------------
 6262|      0|    return {true, false, true};
 6263|      0|  }
 6264|  49.9k|  if (!ensure_tables() || combining_ranges == nullptr || dir_index == nullptr ||
  ------------------
  |  Branch (6264:7): [True: 0, False: 49.9k]
  |  Branch (6264:27): [True: 0, False: 49.9k]
  |  Branch (6264:58): [True: 0, False: 49.9k]
  ------------------
 6265|  49.9k|      dir_block_flat == nullptr || joining_start == nullptr ||
  ------------------
  |  Branch (6265:7): [True: 0, False: 49.9k]
  |  Branch (6265:36): [True: 0, False: 49.9k]
  ------------------
 6266|  49.9k|      joining_final == nullptr || joining_value == nullptr) {
  ------------------
  |  Branch (6266:7): [True: 0, False: 49.9k]
  |  Branch (6266:35): [True: 0, False: 49.9k]
  ------------------
 6267|      0|    return {};
 6268|      0|  }
 6269|       |
 6270|       |  // An invalid RTL label still makes the domain a Bidi domain name, so `rtl`
 6271|       |  // is reported even when another criterion fails.
 6272|  49.9k|  uint32_t directions = 0;
 6273|  49.9k|  direction last = direction::NSM;  // last direction that is not NSM
 6274|   273k|  for (char32_t c : label) {
  ------------------
  |  Branch (6274:19): [True: 273k, False: 49.9k]
  ------------------
 6275|   273k|    const direction d = find_direction(c);
 6276|   273k|    directions |= 1u << d;
 6277|   273k|    if (d != direction::NSM) {
  ------------------
  |  Branch (6277:9): [True: 259k, False: 14.2k]
  ------------------
 6278|   259k|      last = d;
 6279|   259k|    }
 6280|   273k|  }
 6281|  49.9k|  const bool rtl = (directions & rtl_directions) != 0;
 6282|       |
 6283|       |  ///////////////
 6284|       |  // We have a normalization step which ensures that we are in NFC.
 6285|       |  // If we receive punycode, we normalize and check that the normalized
 6286|       |  // version matches the original.
 6287|       |  // --------------------------------------
 6288|       |  // The label must be in Unicode Normalization Form NFC.
 6289|       |
 6290|       |  // Current URL standard indicatest that CheckHyphens is set to false.
 6291|       |  // ---------------------------------------
 6292|       |  // If CheckHyphens, the label must not contain a U+002D HYPHEN-MINUS character
 6293|       |  // in both the third and fourth positions. If CheckHyphens, the label must
 6294|       |  // neither begin nor end with a U+002D HYPHEN-MINUS character.
 6295|       |
 6296|       |  // This is not necessary because we segment the
 6297|       |  // labels by '.'.
 6298|       |  // ---------------------------------------
 6299|       |  // The label must not contain a U+002E ( . ) FULL STOP.
 6300|       |  // if (label.find('.') != std::string_view::npos) return false;
 6301|       |
 6302|       |  // The label must not begin with a combining mark.
 6303|       |  // Range membership via lower_bound on range end.
 6304|  49.9k|  const std::span<const uint32_t[2]> comb_span{combining_ranges,
 6305|  49.9k|                                               combining_range_count};
 6306|  49.9k|  const auto comb_it = std::ranges::lower_bound(
 6307|  49.9k|      comb_span, label.front(), {}, [](const auto& range) { return range[1]; });
 6308|  49.9k|  if (comb_it != comb_span.end() && label.front() >= (*comb_it)[0]) {
  ------------------
  |  Branch (6308:7): [True: 49.9k, False: 0]
  |  Branch (6308:7): [True: 342, False: 49.5k]
  |  Branch (6308:37): [True: 342, False: 49.5k]
  ------------------
 6309|    342|    return {false, rtl, false};
 6310|    342|  }
 6311|       |  // We verify this next step as part of the mapping:
 6312|       |  // ---------------------------------------------
 6313|       |  // Each code point in the label must only have certain status values
 6314|       |  // according to Section 5, IDNA Mapping Table:
 6315|       |  // - For Transitional Processing, each value must be valid.
 6316|       |  // - For Nontransitional Processing, each value must be either valid or
 6317|       |  // deviation.
 6318|       |
 6319|       |  // If CheckJoiners, the label must satisfy the ContextJ rules from Appendix
 6320|       |  // A, in The Unicode Code Points and Internationalized Domain Names for
 6321|       |  // Applications (IDNA) [IDNA2008].
 6322|  49.5k|  if (!is_contextj_valid(label)) {
  ------------------
  |  Branch (6322:7): [True: 483, False: 49.0k]
  ------------------
 6323|    483|    return {false, rtl, false};
 6324|    483|  }
 6325|       |
 6326|       |  // If CheckBidi, and if the domain name is a  Bidi domain name, then the label
 6327|       |  // must satisfy all six of the numbered conditions in [IDNA2008] RFC 5893,
 6328|       |  // Section 2.
 6329|       |
 6330|       |  // The following rule, consisting of six conditions, applies to labels
 6331|       |  // in Bidi domain names.  The requirements that this rule satisfies are
 6332|       |  // described in Section 3.  All of the conditions must be satisfied for
 6333|       |  // the rule to be satisfied.
 6334|       |  //
 6335|       |  //  1.  The first character must be a character with Bidi property L, R,
 6336|       |  //     or AL.  If it has the R or AL property, it is an RTL label; if it
 6337|       |  //     has the L property, it is an LTR label.
 6338|       |  //
 6339|       |  //  2.  In an RTL label, only characters with the Bidi properties R, AL,
 6340|       |  //      AN, EN, ES, CS, ET, ON, BN, or NSM are allowed.
 6341|       |  //
 6342|       |  //   3.  In an RTL label, the end of the label must be a character with
 6343|       |  //       Bidi property R, AL, EN, or AN, followed by zero or more
 6344|       |  //       characters with Bidi property NSM.
 6345|       |  //
 6346|       |  //   4.  In an RTL label, if an EN is present, no AN may be present, and
 6347|       |  //       vice versa.
 6348|       |  //
 6349|       |  //  5.  In an LTR label, only characters with the Bidi properties L, EN,
 6350|       |  //       ES, CS, ET, ON, BN, or NSM are allowed.
 6351|       |  //
 6352|       |  //   6.  In an LTR label, the end of the label must be a character with
 6353|       |  //       Bidi property L or EN, followed by zero or more characters with
 6354|       |  //       Bidi property NSM.
 6355|       |  //
 6356|       |  // Every character after the last non-NSM character is NSM, which both the
 6357|       |  // LTR and the RTL rules allow, so conditions 2, 4 and 5 only depend on the
 6358|       |  // set of directions in the whole label.
 6359|  49.0k|  if (last == direction::NSM) {
  ------------------
  |  Branch (6359:7): [True: 0, False: 49.0k]
  ------------------
 6360|      0|    return {false, rtl, false};
 6361|      0|  }
 6362|       |
 6363|  49.0k|  label_check result{true, rtl, false};
 6364|  49.0k|  const direction first = find_direction(label[0]);
 6365|  49.0k|  if (first == direction::L) {
  ------------------
  |  Branch (6365:7): [True: 39.3k, False: 9.72k]
  ------------------
 6366|  39.3k|    constexpr uint32_t ltr_allowed =
 6367|  39.3k|        (1u << direction::L) | (1u << direction::EN) | (1u << direction::ES) |
 6368|  39.3k|        (1u << direction::CS) | (1u << direction::ET) | (1u << direction::ON) |
 6369|  39.3k|        (1u << direction::BN) | (1u << direction::NSM);
 6370|  39.3k|    result.bidi = (directions & ~ltr_allowed) == 0 &&
  ------------------
  |  Branch (6370:19): [True: 39.1k, False: 243]
  ------------------
 6371|  39.1k|                  (last == direction::L || last == direction::EN);
  ------------------
  |  Branch (6371:20): [True: 37.0k, False: 2.06k]
  |  Branch (6371:44): [True: 1.06k, False: 999]
  ------------------
 6372|  39.3k|  } else if (first == direction::R || first == direction::AL) {
  ------------------
  |  Branch (6372:14): [True: 1.37k, False: 8.35k]
  |  Branch (6372:39): [True: 2.08k, False: 6.27k]
  ------------------
 6373|  3.45k|    constexpr uint32_t rtl_allowed =
 6374|  3.45k|        rtl_directions | (1u << direction::EN) | (1u << direction::ES) |
 6375|  3.45k|        (1u << direction::CS) | (1u << direction::ET) | (1u << direction::ON) |
 6376|  3.45k|        (1u << direction::BN) | (1u << direction::NSM);
 6377|  3.45k|    constexpr uint32_t en_and_an =
 6378|  3.45k|        (1u << direction::EN) | (1u << direction::AN);
 6379|  3.45k|    result.bidi = (directions & ~rtl_allowed) == 0 &&
  ------------------
  |  Branch (6379:19): [True: 3.25k, False: 198]
  ------------------
 6380|  3.25k|                  (directions & en_and_an) != en_and_an &&
  ------------------
  |  Branch (6380:19): [True: 3.24k, False: 9]
  ------------------
 6381|  3.24k|                  (last == direction::R || last == direction::AL ||
  ------------------
  |  Branch (6381:20): [True: 687, False: 2.56k]
  |  Branch (6381:44): [True: 1.32k, False: 1.23k]
  ------------------
 6382|  1.23k|                   last == direction::AN || last == direction::EN);
  ------------------
  |  Branch (6382:20): [True: 465, False: 771]
  |  Branch (6382:45): [True: 741, False: 30]
  ------------------
 6383|  3.45k|  }
 6384|  49.0k|  return result;
 6385|  49.0k|}
can_parse.cc:_ZN3ada4idnaL14find_directionEj:
 6165|   322k|inline static direction find_direction(uint32_t code_point) noexcept {
 6166|   322k|  if (code_point >= 0x110000) {
  ------------------
  |  Branch (6166:7): [True: 0, False: 322k]
  ------------------
 6167|      0|    return direction::NONE;
 6168|      0|  }
 6169|   322k|  return static_cast<direction>(
 6170|   322k|      dir_block_row(dir_index[code_point >> 8])[code_point & 0xFF]);
 6171|   322k|}
_ZN3ada4idna13dir_block_rowEh:
 5129|   322k|inline const uint8_t* dir_block_row(uint8_t bi) noexcept {
 5130|   322k|  if (bi >= kDirBlockRows) {
  ------------------
  |  Branch (5130:7): [True: 0, False: 322k]
  ------------------
 5131|      0|    bi = 0;
 5132|      0|  }
 5133|   322k|  return dir_block_flat + static_cast<size_t>(bi) * kDirBlockCols;
 5134|   322k|}
can_parse.cc:_ZZN3ada4idnaL11check_labelENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEEENK3$_0clIA2_jEEDaRKT_:
 6307|   417k|      comb_span, label.front(), {}, [](const auto& range) { return range[1]; });
can_parse.cc:_ZN3ada4idnaL17is_contextj_validENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 6182|  49.5k|inline static bool is_contextj_valid(std::u32string_view label) noexcept {
 6183|  49.5k|  constexpr uint8_t virama_ccc = 9;
 6184|   314k|  for (size_t i = 0; i < label.size(); i++) {
  ------------------
  |  Branch (6184:22): [True: 265k, False: 49.0k]
  ------------------
 6185|   265k|    if (label[i] != 0x200C && label[i] != 0x200D) {
  ------------------
  |  Branch (6185:9): [True: 264k, False: 1.46k]
  |  Branch (6185:31): [True: 263k, False: 363]
  ------------------
 6186|   263k|      continue;
 6187|   263k|    }
 6188|       |    // If Canonical_Combining_Class(Before(cp)) .eq. Virama Then True;
 6189|  1.82k|    if (i > 0 && get_ccc(label[i - 1]) == virama_ccc) {
  ------------------
  |  Branch (6189:9): [True: 1.80k, False: 18]
  |  Branch (6189:18): [True: 381, False: 1.42k]
  ------------------
 6190|    381|      continue;
 6191|    381|    }
 6192|  1.44k|    if (label[i] == 0x200D) {
  ------------------
  |  Branch (6192:9): [True: 39, False: 1.40k]
  ------------------
 6193|     39|      return false;
 6194|     39|    }
 6195|       |    // If RegExpMatch((Joining_Type:{L,D})(Joining_Type:T)*\u200C
 6196|       |    //    (Joining_Type:T)*(Joining_Type:{R,D})) Then True;
 6197|  1.40k|    joining_type before = joining_type::U;
 6198|  2.99k|    for (size_t j = i; j > 0;) {
  ------------------
  |  Branch (6198:24): [True: 2.97k, False: 18]
  ------------------
 6199|  2.97k|      before = find_joining_type(label[--j]);
 6200|  2.97k|      if (before != joining_type::T) {
  ------------------
  |  Branch (6200:11): [True: 1.38k, False: 1.59k]
  ------------------
 6201|  1.38k|        break;
 6202|  1.38k|      }
 6203|  2.97k|    }
 6204|  1.40k|    if (before != joining_type::L && before != joining_type::D) {
  ------------------
  |  Branch (6204:9): [True: 1.19k, False: 207]
  |  Branch (6204:38): [True: 180, False: 1.01k]
  ------------------
 6205|    180|      return false;
 6206|    180|    }
 6207|  1.22k|    joining_type after = joining_type::U;
 6208|  2.21k|    for (size_t j = i + 1; j < label.size(); j++) {
  ------------------
  |  Branch (6208:28): [True: 2.08k, False: 126]
  ------------------
 6209|  2.08k|      after = find_joining_type(label[j]);
 6210|  2.08k|      if (after != joining_type::T) {
  ------------------
  |  Branch (6210:11): [True: 1.09k, False: 990]
  ------------------
 6211|  1.09k|        break;
 6212|  1.09k|      }
 6213|  2.08k|    }
 6214|  1.22k|    if (after != joining_type::R && after != joining_type::D) {
  ------------------
  |  Branch (6214:9): [True: 1.00k, False: 216]
  |  Branch (6214:37): [True: 264, False: 744]
  ------------------
 6215|    264|      return false;
 6216|    264|    }
 6217|  1.22k|  }
 6218|  49.0k|  return true;
 6219|  49.5k|}
can_parse.cc:_ZN3ada4idnaL17find_joining_typeEj:
 6174|  5.06k|inline static joining_type find_joining_type(uint32_t code_point) noexcept {
 6175|  5.06k|  size_t i =
 6176|  5.06k|      find_range(joining_start, joining_final, joining_table_count, code_point);
 6177|  5.06k|  return i == joining_table_count ? joining_type::U
  ------------------
  |  Branch (6177:10): [True: 285, False: 4.78k]
  ------------------
 6178|  5.06k|                                  : static_cast<joining_type>(joining_value[i]);
 6179|  5.06k|}
can_parse.cc:_ZN3ada4idnaL10find_rangeEPKjS2_mj:
 6151|  5.06k|                                size_t count, uint32_t code_point) noexcept {
 6152|  5.06k|  size_t lo = 0, hi = count;
 6153|  52.9k|  while (lo < hi) {
  ------------------
  |  Branch (6153:10): [True: 47.9k, False: 5.06k]
  ------------------
 6154|  47.9k|    size_t mid = lo + (hi - lo) / 2;
 6155|  47.9k|    if (last[mid] < code_point) {
  ------------------
  |  Branch (6155:9): [True: 12.2k, False: 35.6k]
  ------------------
 6156|  12.2k|      lo = mid + 1;
 6157|  35.6k|    } else {
 6158|  35.6k|      hi = mid;
 6159|  35.6k|    }
 6160|  47.9k|  }
 6161|  5.06k|  return lo < count && code_point >= start[lo] ? lo : count;
  ------------------
  |  Branch (6161:10): [True: 5.06k, False: 0]
  |  Branch (6161:24): [True: 4.78k, False: 285]
  ------------------
 6162|  5.06k|}
_ZN3ada4idna8is_asciiENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 6490|  18.6k|bool constexpr is_ascii(std::string_view view) {
 6491|   448k|  for (uint8_t c : view) {
  ------------------
  |  Branch (6491:18): [True: 448k, False: 6.04k]
  ------------------
 6492|   448k|    if (c >= 0x80) {
  ------------------
  |  Branch (6492:9): [True: 12.6k, False: 435k]
  ------------------
 6493|  12.6k|      return false;
 6494|  12.6k|    }
 6495|   448k|  }
 6496|  6.04k|  return true;
 6497|  18.6k|}
can_parse.cc:_ZN3ada4idnaL19from_ascii_to_asciiENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEERNS1_12basic_stringIcS4_NS1_9allocatorIcEEEE:
 6527|  6.04k|static void from_ascii_to_ascii(std::string_view ut8_string, std::string& out) {
 6528|  6.04k|  out.assign(ut8_string);
 6529|  6.04k|  ascii_map(out.data(), out.size());
 6530|  6.04k|}
_ZN3ada4idna8is_asciiENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 6481|  65.8k|bool constexpr is_ascii(std::u32string_view view) {
 6482|   236k|  for (uint32_t c : view) {
  ------------------
  |  Branch (6482:19): [True: 236k, False: 13.1k]
  ------------------
 6483|   236k|    if (c >= 0x80) {
  ------------------
  |  Branch (6483:9): [True: 52.7k, False: 183k]
  ------------------
 6484|  52.7k|      return false;
 6485|  52.7k|    }
 6486|   236k|  }
 6487|  13.1k|  return true;
 6488|  65.8k|}
can_parse.cc:_ZN3ada4idnaL13is_ace_prefixENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 6543|  51.8k|static bool is_ace_prefix(std::u32string_view label) noexcept {
 6544|  51.8k|  return label.size() >= 4 && label[0] == U'x' && label[1] == U'n' &&
  ------------------
  |  Branch (6544:10): [True: 34.5k, False: 17.2k]
  |  Branch (6544:31): [True: 6.45k, False: 28.1k]
  |  Branch (6544:51): [True: 5.65k, False: 807]
  ------------------
 6545|  5.65k|         label[2] == U'-' && label[3] == U'-';
  ------------------
  |  Branch (6545:10): [True: 5.11k, False: 537]
  |  Branch (6545:30): [True: 4.58k, False: 531]
  ------------------
 6546|  51.8k|}
can_parse.cc:_ZN3ada4idnaL18append_ascii_labelERNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_17basic_string_viewIDiNS3_IDiEEEE:
 6533|  14.3k|static void append_ascii_label(std::string& out, std::u32string_view label) {
 6534|  14.3k|  const size_t old = out.size();
 6535|  14.3k|  out.resize(old + label.size());
 6536|  14.3k|  char* dest = out.data() + old;
 6537|   146k|  for (char32_t c : label) {
  ------------------
  |  Branch (6537:19): [True: 146k, False: 14.3k]
  ------------------
 6538|   146k|    *dest++ = static_cast<char>(c);
 6539|   146k|  }
 6540|  14.3k|}
can_parse.cc:_ZZN3ada4idna8to_asciiENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEERNS1_12basic_stringIcS4_NS1_9allocatorIcEEEEENK3$_0clERKNS0_11label_checkE:
 6609|  49.9k|  auto accept = [&](const label_check& check) {
 6610|  49.9k|    bidi_domain = bidi_domain || check.rtl;
  ------------------
  |  Branch (6610:19): [True: 3.33k, False: 46.5k]
  |  Branch (6610:34): [True: 1.33k, False: 45.2k]
  ------------------
 6611|  49.9k|    bidi_rule_holds = bidi_rule_holds && check.bidi;
  ------------------
  |  Branch (6611:23): [True: 31.3k, False: 18.6k]
  |  Branch (6611:42): [True: 26.6k, False: 4.71k]
  ------------------
 6612|  49.9k|    return check.valid && (bidi_rule_holds || !bidi_domain);
  ------------------
  |  Branch (6612:12): [True: 49.0k, False: 825]
  |  Branch (6612:28): [True: 26.6k, False: 22.4k]
  |  Branch (6612:47): [True: 22.0k, False: 483]
  ------------------
 6613|  49.9k|  };
_ZZN3ada7unicode14percent_encodeILb1EEEbNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEPKhRNS2_12basic_stringIcS5_NS2_9allocatorIcEEEEENKUlcE_clEc:
 7682|  75.8k|  auto pointer = std::ranges::find_if(input, [character_set](const char c) {
 7683|  75.8k|    return character_sets::bit_at(character_set, c);
 7684|  75.8k|  });
_ZN3ada7unicode18is_ascii_hex_digitEc:
 7416|  22.4k|ada_really_inline constexpr bool is_ascii_hex_digit(const char c) noexcept {
 7417|  22.4k|  return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') ||
  ------------------
  |  Branch (7417:11): [True: 16.7k, False: 5.71k]
  |  Branch (7417:23): [True: 10.4k, False: 6.32k]
  |  Branch (7417:37): [True: 6.32k, False: 5.72k]
  |  Branch (7417:49): [True: 3.27k, False: 3.04k]
  ------------------
 7418|  8.76k|         (c >= 'a' && c <= 'f');
  ------------------
  |  Branch (7418:11): [True: 2.76k, False: 6.00k]
  |  Branch (7418:23): [True: 2.49k, False: 264]
  ------------------
 7419|  22.4k|}
_ZN3ada7unicode21convert_hex_to_binaryEc:
 7506|  13.6k|unsigned constexpr convert_hex_to_binary(const char c) noexcept {
 7507|  13.6k|  return hex_to_binary_table[c - '0'];
 7508|  13.6k|}
can_parse.cc:_ZZN3ada7unicode14percent_encodeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKhENK3$_0clEc:
 7650|   107k|  auto pointer = std::ranges::find_if(input, [character_set](const char c) {
 7651|   107k|    return character_sets::bit_at(character_set, c);
 7652|   107k|  });
_ZN3ada7unicode36contains_forbidden_domain_code_pointEPKcm:
 7343|  14.2k|    const char* input, size_t length) noexcept {
 7344|  14.2k|  size_t i = 0;
 7345|  14.2k|  uint8_t accumulator{};
 7346|   273k|  for (; i + 4 <= length; i += 4) {
  ------------------
  |  Branch (7346:10): [True: 259k, False: 14.2k]
  ------------------
 7347|   259k|    accumulator |= is_forbidden_domain_code_point_table[uint8_t(input[i])];
 7348|   259k|    accumulator |= is_forbidden_domain_code_point_table[uint8_t(input[i + 1])];
 7349|   259k|    accumulator |= is_forbidden_domain_code_point_table[uint8_t(input[i + 2])];
 7350|   259k|    accumulator |= is_forbidden_domain_code_point_table[uint8_t(input[i + 3])];
 7351|   259k|  }
 7352|  36.8k|  for (; i < length; i++) {
  ------------------
  |  Branch (7352:10): [True: 22.6k, False: 14.2k]
  ------------------
 7353|  22.6k|    accumulator |= is_forbidden_domain_code_point_table[uint8_t(input[i])];
 7354|  22.6k|  }
 7355|  14.2k|  return accumulator;
 7356|  14.2k|}
can_parse.cc:_ZN3ada7unicode12_GLOBAL__N_122percent_encode_to_wideEPKcS3_PKhRNSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEE:
 8036|    850|                            const uint8_t character_set[], std::string& out) {
 8037|       |  // Worst case every byte becomes %XX. Avoids realloc while walking windows.
 8038|    850|  out.reserve(out.size() + static_cast<size_t>(end - p) * 3);
 8039|    850|#if ADA_UNICODE_SSSE3
 8040|    850|  const ssse3_percent_tables tables = load_ssse3_percent_tables(character_set);
 8041|    850|  percent_encode_to_ssse3(p, end, character_set, tables, out);
 8042|       |#elif ADA_NEON
 8043|       |  percent_encode_to_neon(p, end, character_set,
 8044|       |                         load_neon_percent_table(character_set), out);
 8045|       |#elif ADA_RVV
 8046|       |  percent_encode_to_rvv(p, end, character_set, out);
 8047|       |#endif
 8048|    850|}
can_parse.cc:_ZN3ada7unicode12_GLOBAL__N_125load_ssse3_percent_tablesEPKh:
 7863|    850|load_ssse3_percent_tables(const uint8_t character_set[]) noexcept {
 7864|    850|  ssse3_percent_tables t{};
 7865|    850|  t.cs_lo = _mm_loadu_si128(reinterpret_cast<const __m128i*>(character_set));
 7866|    850|  t.cs_hi =
 7867|    850|      _mm_loadu_si128(reinterpret_cast<const __m128i*>(character_set + 16));
 7868|       |  // 1 << (0..7), duplicated so pshufb(index & 7) works for every lane.
 7869|    850|  t.pow2 =
 7870|    850|      _mm_setr_epi8(1, 2, 4, 8, 16, 32, 64, -128, 1, 2, 4, 8, 16, 32, 64, -128);
 7871|    850|  t.mask_0f = _mm_set1_epi8(0x0F);
 7872|    850|  t.mask_07 = _mm_set1_epi8(0x07);
 7873|    850|  t.zero = _mm_setzero_si128();
 7874|    850|  return t;
 7875|    850|}
can_parse.cc:_ZN3ada7unicode12_GLOBAL__N_123percent_encode_to_ssse3EPKcS3_PKhRKNS1_20ssse3_percent_tablesERNSt3__112basic_stringIcNS9_11char_traitsIcEENS9_9allocatorIcEEEE:
 7894|    850|    const ssse3_percent_tables& tables, std::string& out) {
 7895|       |  // Pair 16-byte windows so a fully clean 32-byte run is one append.
 7896|  2.83k|  while (p + 32 <= end) {
  ------------------
  |  Branch (7896:10): [True: 1.98k, False: 850]
  ------------------
 7897|  1.98k|    const __m128i word0 = _mm_loadu_si128(reinterpret_cast<const __m128i*>(p));
 7898|  1.98k|    const __m128i word1 =
 7899|  1.98k|        _mm_loadu_si128(reinterpret_cast<const __m128i*>(p + 16));
 7900|  1.98k|    const int mask0 = ssse3_percent_mask(word0, tables);
 7901|  1.98k|    const int mask1 = ssse3_percent_mask(word1, tables);
 7902|  1.98k|    if ((mask0 | mask1) == 0) {
  ------------------
  |  Branch (7902:9): [True: 114, False: 1.86k]
  ------------------
 7903|    114|      out.append(p, 32);
 7904|  1.86k|    } else {
 7905|  1.86k|      if (mask0 == 0) {
  ------------------
  |  Branch (7905:11): [True: 125, False: 1.74k]
  ------------------
 7906|    125|        out.append(p, 16);
 7907|  1.74k|      } else {
 7908|  1.74k|        encode_mask_window(p, static_cast<uint32_t>(mask0), 16, out);
 7909|  1.74k|      }
 7910|  1.86k|      if (mask1 == 0) {
  ------------------
  |  Branch (7910:11): [True: 192, False: 1.67k]
  ------------------
 7911|    192|        out.append(p + 16, 16);
 7912|  1.67k|      } else {
 7913|  1.67k|        encode_mask_window(p + 16, static_cast<uint32_t>(mask1), 16, out);
 7914|  1.67k|      }
 7915|  1.86k|    }
 7916|  1.98k|    p += 32;
 7917|  1.98k|  }
 7918|    850|  if (p + 16 <= end) {
  ------------------
  |  Branch (7918:7): [True: 572, False: 278]
  ------------------
 7919|    572|    const __m128i word = _mm_loadu_si128(reinterpret_cast<const __m128i*>(p));
 7920|    572|    const int mask = ssse3_percent_mask(word, tables);
 7921|    572|    if (mask == 0) {
  ------------------
  |  Branch (7921:9): [True: 62, False: 510]
  ------------------
 7922|     62|      out.append(p, 16);
 7923|    510|    } else {
 7924|    510|      encode_mask_window(p, static_cast<uint32_t>(mask), 16, out);
 7925|    510|    }
 7926|    572|    p += 16;
 7927|    572|  }
 7928|    850|  percent_encode_to_scalar(p, end, character_set, out);
 7929|    850|}
can_parse.cc:_ZN3ada7unicode12_GLOBAL__N_118ssse3_percent_maskEDv2_xRKNS1_20ssse3_percent_tablesE:
 7878|  4.53k|    __m128i word, const ssse3_percent_tables& tables) noexcept {
 7879|  4.53k|  const __m128i idx = _mm_and_si128(_mm_srli_epi16(word, 3), tables.mask_0f);
 7880|  4.53k|  const __m128i lo = _mm_shuffle_epi8(tables.cs_lo, idx);
 7881|  4.53k|  const __m128i hi = _mm_shuffle_epi8(tables.cs_hi, idx);
 7882|       |  // Bytes 0x80-0xFF are signed-negative; select the high half of the bitmap.
 7883|  4.53k|  const __m128i high_byte = _mm_cmpgt_epi8(tables.zero, word);
 7884|  4.53k|  const __m128i cs_byte = _mm_or_si128(_mm_and_si128(hi, high_byte),
 7885|  4.53k|                                       _mm_andnot_si128(high_byte, lo));
 7886|  4.53k|  const __m128i bits =
 7887|  4.53k|      _mm_shuffle_epi8(tables.pow2, _mm_and_si128(word, tables.mask_07));
 7888|  4.53k|  const __m128i hits = _mm_and_si128(cs_byte, bits);
 7889|  4.53k|  return _mm_movemask_epi8(_mm_cmpeq_epi8(hits, tables.zero)) ^ 0xFFFF;
 7890|  4.53k|}
can_parse.cc:_ZN3ada7unicode12_GLOBAL__N_118encode_mask_windowEPKcjmRNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEE:
 7818|  3.93k|                                          size_t width, std::string& out) {
 7819|  3.93k|  uint64_t bits = mask;
 7820|  3.93k|  size_t off = 0;
 7821|  51.2k|  while (bits != 0) {
  ------------------
  |  Branch (7821:10): [True: 47.3k, False: 3.93k]
  ------------------
 7822|  47.3k|    const int zero_run = trailing_zeroes32(static_cast<uint32_t>(bits));
 7823|  47.3k|    if (zero_run != 0) {
  ------------------
  |  Branch (7823:9): [True: 3.06k, False: 44.2k]
  ------------------
 7824|  3.06k|      out.append(p + off, static_cast<size_t>(zero_run));
 7825|  3.06k|    }
 7826|  47.3k|    off += static_cast<size_t>(zero_run);
 7827|  47.3k|    out.append(character_sets::hex + uint8_t(p[off]) * 4, 3);
 7828|  47.3k|    ++off;
 7829|  47.3k|    bits >>= static_cast<unsigned>(zero_run + 1);
 7830|  47.3k|  }
 7831|  3.93k|  if (off < width) {
  ------------------
  |  Branch (7831:7): [True: 1.05k, False: 2.87k]
  ------------------
 7832|  1.05k|    out.append(p + off, width - off);
 7833|  1.05k|  }
 7834|  3.93k|}
can_parse.cc:_ZN3ada7unicode12_GLOBAL__N_117trailing_zeroes32Ej:
 7806|  47.3k|ada_really_inline int trailing_zeroes32(uint32_t input_num) noexcept {
 7807|       |#ifdef ADA_REGULAR_VISUAL_STUDIO
 7808|       |  unsigned long ret;
 7809|       |  _BitScanForward(&ret, input_num);
 7810|       |  return static_cast<int>(ret);
 7811|       |#else
 7812|  47.3k|  return __builtin_ctz(input_num);
 7813|  47.3k|#endif
 7814|  47.3k|}
can_parse.cc:_ZN3ada7unicode12_GLOBAL__N_124percent_encode_to_scalarEPKcS3_PKhRNSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEE:
 7839|    850|                                                std::string& out) {
 7840|  3.45k|  for (; p != end; ++p) {
  ------------------
  |  Branch (7840:10): [True: 2.60k, False: 850]
  ------------------
 7841|  2.60k|    if (character_sets::bit_at(character_set, *p)) {
  ------------------
  |  Branch (7841:9): [True: 2.01k, False: 593]
  ------------------
 7842|  2.01k|      out.append(character_sets::hex + uint8_t(*p) * 4, 3);
 7843|  2.01k|    } else {
 7844|    593|      out += *p;
 7845|    593|    }
 7846|  2.60k|  }
 7847|    850|}
can_parse.cc:_ZN3ada11serializers12_GLOBAL__N_113write_hex_u16EPct:
 8109|  2.46k|ada_really_inline char* write_hex_u16(char* p, uint16_t v) noexcept {
 8110|  2.46k|  static constexpr char kHex[] = "0123456789abcdef";
 8111|  2.46k|  if (v >= 0x1000) {
  ------------------
  |  Branch (8111:7): [True: 243, False: 2.22k]
  ------------------
 8112|    243|    *p++ = kHex[(v >> 12) & 0xf];
 8113|    243|    *p++ = kHex[(v >> 8) & 0xf];
 8114|    243|    *p++ = kHex[(v >> 4) & 0xf];
 8115|    243|    *p++ = kHex[v & 0xf];
 8116|  2.22k|  } else if (v >= 0x100) {
  ------------------
  |  Branch (8116:14): [True: 318, False: 1.90k]
  ------------------
 8117|    318|    *p++ = kHex[(v >> 8) & 0xf];
 8118|    318|    *p++ = kHex[(v >> 4) & 0xf];
 8119|    318|    *p++ = kHex[v & 0xf];
 8120|  1.90k|  } else if (v >= 0x10) {
  ------------------
  |  Branch (8120:14): [True: 342, False: 1.56k]
  ------------------
 8121|    342|    *p++ = kHex[(v >> 4) & 0xf];
 8122|    342|    *p++ = kHex[v & 0xf];
 8123|  1.56k|  } else {
 8124|  1.56k|    *p++ = kHex[v & 0xf];
 8125|  1.56k|  }
 8126|  2.46k|  return p;
 8127|  2.46k|}
can_parse.cc:_ZN3ada11serializers12_GLOBAL__N_18write_u8EPch:
 8095|  18.1k|ada_really_inline char* write_u8(char* p, uint8_t v) noexcept {
 8096|  18.1k|  if (v < 10) {
  ------------------
  |  Branch (8096:7): [True: 14.6k, False: 3.51k]
  ------------------
 8097|  14.6k|    *p++ = static_cast<char>('0' + v);
 8098|  14.6k|  } else if (v < 100) {
  ------------------
  |  Branch (8098:14): [True: 1.39k, False: 2.11k]
  ------------------
 8099|  1.39k|    std::memcpy(p, &digit_pairs[static_cast<size_t>(v) * 2], 2);
 8100|  1.39k|    p += 2;
 8101|  2.11k|  } else {
 8102|  2.11k|    *p++ = static_cast<char>('0' + v / 100);
 8103|  2.11k|    std::memcpy(p, &digit_pairs[static_cast<size_t>(v % 100) * 2], 2);
 8104|  2.11k|    p += 2;
 8105|  2.11k|  }
 8106|  18.1k|  return p;
 8107|  18.1k|}
_ZN3ada7unicode19has_tabs_or_newlineENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 7192|   132k|    std::string_view user_input) noexcept {
 7193|       |  // first check for short strings in which case we do it naively.
 7194|   132k|  if (user_input.size() < 16) {  // slow path
  ------------------
  |  Branch (7194:7): [True: 97.9k, False: 34.2k]
  ------------------
 7195|  97.9k|    return std::ranges::any_of(user_input, is_tabs_or_newline);
 7196|  97.9k|  }
 7197|       |  // fast path for long strings (expected to be common)
 7198|  34.2k|  size_t i = 0;
 7199|  34.2k|  const __m128i mask1 = _mm_set1_epi8('\r');
 7200|  34.2k|  const __m128i mask2 = _mm_set1_epi8('\n');
 7201|  34.2k|  const __m128i mask3 = _mm_set1_epi8('\t');
 7202|       |  // If we supported SSSE3, we could use the algorithm that we use for NEON.
 7203|  34.2k|  __m128i running{0};
 7204|   170k|  for (; i + 15 < user_input.size(); i += 16) {
  ------------------
  |  Branch (7204:10): [True: 136k, False: 34.2k]
  ------------------
 7205|   136k|    __m128i word = _mm_loadu_si128((const __m128i*)(user_input.data() + i));
 7206|   136k|    running = _mm_or_si128(
 7207|   136k|        _mm_or_si128(running, _mm_or_si128(_mm_cmpeq_epi8(word, mask1),
 7208|   136k|                                           _mm_cmpeq_epi8(word, mask2))),
 7209|   136k|        _mm_cmpeq_epi8(word, mask3));
 7210|   136k|  }
 7211|  34.2k|  if (i < user_input.size()) {
  ------------------
  |  Branch (7211:7): [True: 30.1k, False: 4.09k]
  ------------------
 7212|  30.1k|    __m128i word = _mm_loadu_si128(
 7213|  30.1k|        (const __m128i*)(user_input.data() + user_input.length() - 16));
 7214|  30.1k|    running = _mm_or_si128(
 7215|  30.1k|        _mm_or_si128(running, _mm_or_si128(_mm_cmpeq_epi8(word, mask1),
 7216|  30.1k|                                           _mm_cmpeq_epi8(word, mask2))),
 7217|  30.1k|        _mm_cmpeq_epi8(word, mask3));
 7218|  30.1k|  }
 7219|  34.2k|  return _mm_movemask_epi8(running) != 0;
 7220|   132k|}
_ZN3ada7unicode18is_tabs_or_newlineEc:
 7078|   345k|constexpr bool is_tabs_or_newline(char c) noexcept {
 7079|   345k|  return c == '\r' || c == '\n' || c == '\t';
  ------------------
  |  Branch (7079:10): [True: 398, False: 344k]
  |  Branch (7079:23): [True: 396, False: 344k]
  |  Branch (7079:36): [True: 390, False: 343k]
  ------------------
 7080|   345k|}
can_parse.cc:_ZN3ada12_GLOBAL__N_124try_can_parse_clean_httpENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8288|  33.6k|std::optional<bool> try_can_parse_clean_http(std::string_view input) noexcept {
 8289|  33.6k|  const auto* bytes = reinterpret_cast<const uint8_t*>(input.data());
 8290|  33.6k|  const size_t length = input.size();
 8291|  33.6k|  if (length < 7) {
  ------------------
  |  Branch (8291:7): [True: 15.6k, False: 17.9k]
  ------------------
 8292|  15.6k|    return std::nullopt;
 8293|  15.6k|  }
 8294|       |
 8295|  17.9k|  size_t authority_start;
 8296|  17.9k|  if constexpr (k_can_parse_little_endian) {
 8297|  17.9k|    if (length >= 8) {
  ------------------
  |  Branch (8297:9): [True: 16.5k, False: 1.41k]
  ------------------
 8298|  16.5k|      uint64_t first8 = 0;
 8299|  16.5k|      std::memcpy(&first8, bytes, 8);
 8300|  16.5k|      if (first8 == 0x2f2f3a7370747468ull) {  // "https://"
  ------------------
  |  Branch (8300:11): [True: 9, False: 16.5k]
  ------------------
 8301|      9|        authority_start = 8;
 8302|  16.5k|      } else if ((first8 & 0x00ffffffffffffffull) ==
  ------------------
  |  Branch (8302:18): [True: 357, False: 16.1k]
  ------------------
 8303|  16.5k|                 0x002f2f3a70747468ull) {  // "http://"
 8304|    357|        authority_start = 7;
 8305|  16.1k|      } else {
 8306|  16.1k|        return std::nullopt;
 8307|  16.1k|      }
 8308|  16.5k|    } else if (bytes[0] == 'h' && bytes[1] == 't' && bytes[2] == 't' &&
  ------------------
  |  Branch (8308:16): [True: 92, False: 1.32k]
  |  Branch (8308:35): [True: 71, False: 21]
  |  Branch (8308:54): [True: 54, False: 17]
  ------------------
 8309|     54|               bytes[3] == 'p' && bytes[4] == ':' && bytes[5] == '/' &&
  ------------------
  |  Branch (8309:16): [True: 39, False: 15]
  |  Branch (8309:35): [True: 25, False: 14]
  |  Branch (8309:54): [True: 10, False: 15]
  ------------------
 8310|     10|               bytes[6] == '/') {
  ------------------
  |  Branch (8310:16): [True: 2, False: 8]
  ------------------
 8311|      2|      authority_start = 7;
 8312|  1.41k|    } else {
 8313|  1.41k|      return std::nullopt;
 8314|  1.41k|    }
 8315|       |  } else {
 8316|       |    uint32_t first4{};
 8317|       |    std::memcpy(&first4, bytes, 4);
 8318|       |    if (first4 != 0x68747470u) {  // "http"
 8319|       |      return std::nullopt;
 8320|       |    }
 8321|       |    if (length >= 8 && bytes[4] == 's' && bytes[5] == ':' && bytes[6] == '/' &&
 8322|       |        bytes[7] == '/') {
 8323|       |      authority_start = 8;
 8324|       |    } else if (bytes[4] == ':' && bytes[5] == '/' && bytes[6] == '/') {
 8325|       |      authority_start = 7;
 8326|       |    } else {
 8327|       |      return std::nullopt;
 8328|       |    }
 8329|       |  }
 8330|       |
 8331|  17.9k|  if (authority_start >= length) {
  ------------------
  |  Branch (8331:7): [True: 2, False: 17.9k]
  ------------------
 8332|      2|    return false;
 8333|      2|  }
 8334|       |
 8335|  17.9k|  size_t cursor = authority_start;
 8336|  19.1k|  while (cursor + 8 <= length && eight_clean_http_host_bytes(bytes + cursor)) {
  ------------------
  |  Branch (8336:10): [True: 1.34k, False: 17.7k]
  |  Branch (8336:34): [True: 1.16k, False: 180]
  ------------------
 8337|  1.16k|    cursor += 8;
 8338|  1.16k|  }
 8339|  18.6k|  while (cursor < length) {
  ------------------
  |  Branch (8339:10): [True: 984, False: 17.6k]
  ------------------
 8340|    984|    const uint8_t c = bytes[cursor];
 8341|    984|    if (c == '/' || c == '?' || c == '#') {
  ------------------
  |  Branch (8341:9): [True: 222, False: 762]
  |  Branch (8341:21): [True: 2, False: 760]
  |  Branch (8341:33): [True: 2, False: 758]
  ------------------
 8342|    226|      break;
 8343|    226|    }
 8344|    758|    if (!clean_http_host_byte[c]) {
  ------------------
  |  Branch (8344:9): [True: 106, False: 652]
  ------------------
 8345|    106|      return std::nullopt;
 8346|    106|    }
 8347|    652|    ++cursor;
 8348|    652|  }
 8349|       |
 8350|  17.8k|  const size_t host_length = cursor - authority_start;
 8351|  17.8k|  if (host_length == 0) {
  ------------------
  |  Branch (8351:7): [True: 4, False: 17.8k]
  ------------------
 8352|       |    // Extra special-scheme slashes are normalization, not an empty host.
 8353|      4|    if (bytes[authority_start] == '/' || bytes[authority_start] == '\\') {
  ------------------
  |  Branch (8353:9): [True: 1, False: 3]
  |  Branch (8353:42): [True: 0, False: 3]
  ------------------
 8354|      1|      return std::nullopt;
 8355|      1|    }
 8356|      3|    return false;
 8357|      4|  }
 8358|  17.8k|  if (host_length > 253 || bytes[cursor - 1] == '.') {
  ------------------
  |  Branch (8358:7): [True: 17.5k, False: 247]
  |  Branch (8358:28): [True: 19, False: 228]
  ------------------
 8359|     28|    return std::nullopt;
 8360|     28|  }
 8361|       |
 8362|  17.8k|  const std::string_view host(input.data() + authority_start, host_length);
 8363|  17.8k|  if (checkers::last_label_may_be_a_number(host)) {
  ------------------
  |  Branch (8363:7): [True: 21, False: 17.7k]
  ------------------
 8364|     21|    return std::nullopt;
 8365|     21|  }
 8366|  17.7k|  if (host.find('x') != std::string_view::npos &&
  ------------------
  |  Branch (8366:7): [True: 98, False: 17.6k]
  ------------------
 8367|     98|      host.find("xn-") != std::string_view::npos) {
  ------------------
  |  Branch (8367:7): [True: 27, False: 71]
  ------------------
 8368|     27|    return std::nullopt;
 8369|     27|  }
 8370|       |
 8371|       |  // Once a special URL has a valid host, path/query/fragment bytes cannot make
 8372|       |  // it structurally invalid: the full parser percent-encodes them as needed.
 8373|  17.7k|  return true;
 8374|  17.7k|}
can_parse.cc:_ZN3ada12_GLOBAL__N_127eight_clean_http_host_bytesEPKh:
 8264|  1.34k|    const uint8_t* input) noexcept {
 8265|  1.34k|  uint64_t w = 0;
 8266|  1.34k|  std::memcpy(&w, input, 8);
 8267|  1.34k|  constexpr uint64_t k_high = 0x8080808080808080ull;
 8268|  1.34k|  if ((w & k_high) != 0) {
  ------------------
  |  Branch (8268:7): [True: 9, False: 1.33k]
  ------------------
 8269|      9|    return false;
 8270|      9|  }
 8271|  1.33k|  const uint64_t ok = swar_in_range(w, 'a', 'z') | swar_in_range(w, '0', '9') |
 8272|  1.33k|                      swar_in_range(w, '-', '-') | swar_in_range(w, '.', '.') |
 8273|  1.33k|                      swar_in_range(w, '_', '_') | swar_in_range(w, '~', '~');
 8274|  1.33k|  return ok == k_high;
 8275|  1.34k|}
can_parse.cc:_ZN3ada12_GLOBAL__N_113swar_in_rangeEmhh:
 8255|  8.01k|                                         uint8_t hi) noexcept {
 8256|  8.01k|  constexpr uint64_t k_ones = 0x0101010101010101ull;
 8257|  8.01k|  constexpr uint64_t k_high = 0x8080808080808080ull;
 8258|  8.01k|  const uint64_t ge_lo = (w | k_high) - (k_ones * lo);
 8259|  8.01k|  const uint64_t le_hi = ((k_ones * hi) | k_high) - w;
 8260|  8.01k|  return ge_lo & le_hi & k_high;
 8261|  8.01k|}
can_parse.cc:_ZN3ada12_GLOBAL__N_127try_can_parse_absolute_fastENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8389|  33.4k|    std::string_view input) noexcept {
 8390|  33.4k|  const uint8_t* b = reinterpret_cast<const uint8_t*>(input.data());
 8391|  33.4k|  size_t len = input.size();
 8392|       |
 8393|       |  // -- Inline C0 whitespace trim (no allocation) --------------------------
 8394|       |  // Note: \t (0x09), \n (0x0a), \r (0x0d) are all <= 0x20, so any
 8395|       |  // leading/trailing tabs or newlines are correctly stripped here, matching
 8396|       |  // the WHATWG spec's "remove leading/trailing C0 control and space" step.
 8397|  34.9k|  while (len > 0 && b[0] <= 0x20) {
  ------------------
  |  Branch (8397:10): [True: 22.0k, False: 12.9k]
  |  Branch (8397:21): [True: 1.58k, False: 20.4k]
  ------------------
 8398|  1.58k|    b++;
 8399|  1.58k|    len--;
 8400|  1.58k|  }
 8401|  34.8k|  while (len > 0 && b[len - 1] <= 0x20) {
  ------------------
  |  Branch (8401:10): [True: 21.9k, False: 12.9k]
  |  Branch (8401:21): [True: 1.47k, False: 20.4k]
  ------------------
 8402|  1.47k|    len--;
 8403|  1.47k|  }
 8404|  33.4k|  if (len == 0) return false;
  ------------------
  |  Branch (8404:7): [True: 12.9k, False: 20.4k]
  ------------------
 8405|       |
 8406|       |  // -- Scheme detection -----------------------------------------------------
 8407|       |  // Fast path for HTTP and HTTPS (covers ~90%+ of real-world URLs).
 8408|       |  // Avoids the general scheme loop, buffer copy, and perfect hash lookup.
 8409|       |  // We know HTTP and HTTPS are special non-file schemes, so no further
 8410|       |  // scheme_type checks are needed on the fast path -- only `pos` matters.
 8411|  20.4k|  size_t pos;
 8412|       |
 8413|  20.4k|  if (len >= 7 && (b[0] | 0x20) == 'h' && (b[1] | 0x20) == 't' &&
  ------------------
  |  Branch (8413:7): [True: 17.7k, False: 2.76k]
  |  Branch (8413:19): [True: 522, False: 17.1k]
  |  Branch (8413:43): [True: 398, False: 124]
  ------------------
 8414|    398|      (b[2] | 0x20) == 't' && (b[3] | 0x20) == 'p') {
  ------------------
  |  Branch (8414:7): [True: 355, False: 43]
  |  Branch (8414:31): [True: 328, False: 27]
  ------------------
 8415|    328|    if (b[4] == ':' && b[5] == '/' && b[6] == '/') {
  ------------------
  |  Branch (8415:9): [True: 281, False: 47]
  |  Branch (8415:24): [True: 184, False: 97]
  |  Branch (8415:39): [True: 175, False: 9]
  ------------------
 8416|    175|      pos = 7;
 8417|    175|      goto skip_extra_slashes;
 8418|    175|    }
 8419|    153|    if (len >= 8 && (b[4] | 0x20) == 's' && b[5] == ':' && b[6] == '/' &&
  ------------------
  |  Branch (8419:9): [True: 117, False: 36]
  |  Branch (8419:21): [True: 20, False: 97]
  |  Branch (8419:45): [True: 12, False: 8]
  |  Branch (8419:60): [True: 9, False: 3]
  ------------------
 8420|      9|        b[7] == '/') {
  ------------------
  |  Branch (8420:9): [True: 8, False: 1]
  ------------------
 8421|      8|      pos = 8;
 8422|      8|      goto skip_extra_slashes;
 8423|      8|    }
 8424|       |    // Fall through: could be "httpe://", tabs in scheme, etc.
 8425|    153|  }
 8426|       |
 8427|  20.2k|  {
 8428|       |    // General scheme detection for ws, wss, ftp, and edge cases.
 8429|  20.2k|    if (!checkers::is_alpha(static_cast<char>(b[0]))) return false;
  ------------------
  |  Branch (8429:9): [True: 990, False: 19.2k]
  ------------------
 8430|       |
 8431|       |    // Scan for ':' within the first 7 bytes. All special schemes are <= 5
 8432|       |    // chars ("https"), so any URL whose first ':' is beyond byte 6 is either
 8433|       |    // non-special or relative -- both require the full parser.
 8434|  19.2k|    size_t colon_pos = 0;
 8435|  41.7k|    for (size_t i = 1;; ++i) {
 8436|  41.7k|      if (i >= 7 || i >= len) return std::nullopt;
  ------------------
  |  Branch (8436:11): [True: 117, False: 41.6k]
  |  Branch (8436:21): [True: 187, False: 41.4k]
  ------------------
 8437|  41.4k|      const char c = static_cast<char>(b[i]);
 8438|  41.4k|      if (c == ':') {
  ------------------
  |  Branch (8438:11): [True: 18.7k, False: 22.7k]
  ------------------
 8439|  18.7k|        colon_pos = i;
 8440|  18.7k|        break;
 8441|  18.7k|      }
 8442|       |      // Tabs/newlines in the scheme require the full parser to strip them.
 8443|  22.7k|      if (c == '\t' || c == '\n' || c == '\r') return std::nullopt;
  ------------------
  |  Branch (8443:11): [True: 7, False: 22.7k]
  |  Branch (8443:24): [True: 8, False: 22.7k]
  |  Branch (8443:37): [True: 9, False: 22.7k]
  ------------------
 8444|  22.7k|      if (!unicode::is_alnum_plus(c)) return false;
  ------------------
  |  Branch (8444:11): [True: 267, False: 22.4k]
  ------------------
 8445|  22.7k|    }
 8446|       |
 8447|       |    // Lowercase scheme bytes inline and classify via the existing perfect
 8448|       |    // hash.
 8449|  18.7k|    char scheme_buf[6];
 8450|  18.7k|    scheme_buf[0] = static_cast<char>(b[0] | 0x20);
 8451|  40.2k|    for (size_t i = 1; i < colon_pos; ++i)
  ------------------
  |  Branch (8451:24): [True: 21.5k, False: 18.7k]
  ------------------
 8452|  21.5k|      scheme_buf[i] = static_cast<char>(b[i] | 0x20);
 8453|       |
 8454|  18.7k|    const ada::scheme::type scheme_type =
 8455|  18.7k|        ada::scheme::get_scheme_type({scheme_buf, colon_pos});
 8456|       |
 8457|       |    // Only handle special, non-file schemes.
 8458|  18.7k|    if (scheme_type == ada::scheme::NOT_SPECIAL) return std::nullopt;
  ------------------
  |  Branch (8458:9): [True: 2.68k, False: 16.0k]
  ------------------
 8459|  16.0k|    if (scheme_type == ada::scheme::FILE) return std::nullopt;
  ------------------
  |  Branch (8459:9): [True: 1.88k, False: 14.1k]
  ------------------
 8460|       |
 8461|       |    // Per WHATWG, special URLs don't require "//": "http:example.com" is valid
 8462|       |    // (SPECIAL_AUTHORITY_IGNORE_SLASHES just skips leading slashes and
 8463|       |    // proceeds to AUTHORITY).  Defer to the inline fallback for any input
 8464|       |    // without "://".
 8465|  14.1k|    pos = colon_pos + 1;
 8466|  14.1k|    if (pos + 2 > len || b[pos] != '/' || b[pos + 1] != '/') {
  ------------------
  |  Branch (8466:9): [True: 149, False: 13.9k]
  |  Branch (8466:26): [True: 6.17k, False: 7.81k]
  |  Branch (8466:43): [True: 69, False: 7.74k]
  ------------------
 8467|  6.38k|      return std::nullopt;
 8468|  6.38k|    }
 8469|  7.74k|    pos += 2;
 8470|  7.74k|  }
 8471|       |
 8472|  7.92k|skip_extra_slashes:
 8473|       |  // SPECIAL_AUTHORITY_IGNORE_SLASHES: the full parser skips any additional
 8474|       |  // leading '/' or '\' after the initial "//".  Mirror that here so we don't
 8475|       |  // mis-identify the host as empty when there are extra slashes.
 8476|  8.38k|  while (pos < len && (b[pos] == '/' || b[pos] == '\\')) {
  ------------------
  |  Branch (8476:10): [True: 8.36k, False: 27]
  |  Branch (8476:24): [True: 278, False: 8.08k]
  |  Branch (8476:41): [True: 182, False: 7.90k]
  ------------------
 8477|    460|    ++pos;
 8478|    460|  }
 8479|       |
 8480|       |  // Early IPv6 bail-out: if the authority starts with '[', it's an IPv6
 8481|       |  // literal which requires the full parser.  Checking here avoids scanning
 8482|       |  // the entire bracketed address only to bail out afterward.
 8483|  7.92k|  if (pos < len && b[pos] == '[') return std::nullopt;
  ------------------
  |  Branch (8483:7): [True: 7.90k, False: 27]
  |  Branch (8483:20): [True: 111, False: 7.79k]
  ------------------
 8484|       |
 8485|       |  // -- Merged authority + host scan ------------------------------------------
 8486|       |  // A single forward pass over the authority bytes that simultaneously:
 8487|       |  //   - finds the authority end and port colon
 8488|       |  //   - validates host characters (forbidden domain code points)
 8489|       |  //   - tracks IPv4 indicators (all-decimal-dots, last non-dot char)
 8490|       |  //   - detects xn-- prefixes (IDNA punycode)
 8491|       |  //   - detects tabs/newlines (which require the full parser to strip)
 8492|       |  // This replaces 4 separate scans over the host bytes.
 8493|  7.81k|  const size_t auth_start = pos;
 8494|  7.81k|  size_t auth_end = pos;
 8495|  7.81k|  size_t port_colon = SIZE_MAX;
 8496|  7.81k|  bool all_dec_dots = true;
 8497|       |
 8498|  53.0k|  for (; auth_end < len; ++auth_end) {
  ------------------
  |  Branch (8498:10): [True: 52.7k, False: 309]
  ------------------
 8499|  52.7k|    const uint8_t c = b[auth_end];
 8500|       |
 8501|       |    // Non-ASCII -> needs IDNA processing -> full parser.
 8502|  52.7k|    if (c >= 0x80) return std::nullopt;
  ------------------
  |  Branch (8502:9): [True: 33, False: 52.7k]
  ------------------
 8503|       |
 8504|       |    // Authority delimiters.
 8505|  52.7k|    if (c == '/' || c == '?' || c == '#' || c == '\\') break;
  ------------------
  |  Branch (8505:9): [True: 5.65k, False: 47.0k]
  |  Branch (8505:21): [True: 102, False: 46.9k]
  |  Branch (8505:33): [True: 115, False: 46.8k]
  |  Branch (8505:45): [True: 2, False: 46.8k]
  ------------------
 8506|       |
 8507|       |    // Port separator.
 8508|  46.8k|    if (c == ':') {
  ------------------
  |  Branch (8508:9): [True: 2.20k, False: 44.6k]
  ------------------
 8509|  2.20k|      if (port_colon == SIZE_MAX) port_colon = auth_end;
  ------------------
  |  Branch (8509:11): [True: 2.00k, False: 204]
  ------------------
 8510|  2.20k|      continue;
 8511|  2.20k|    }
 8512|       |
 8513|       |    // Credentials or percent-encoding -> full parser.
 8514|  44.6k|    if (c == '@' || c == '%') return std::nullopt;
  ------------------
  |  Branch (8514:9): [True: 128, False: 44.5k]
  |  Branch (8514:21): [True: 173, False: 44.3k]
  ------------------
 8515|       |
 8516|       |    // Tabs/newlines anywhere in the authority require the full parser to
 8517|       |    // strip them before validation.  Without this, a tab in the port (e.g.
 8518|       |    // "http://host:8\t0/") would be mis-rejected by port validation.
 8519|  44.3k|    if (c == '\t' || c == '\n' || c == '\r') return std::nullopt;
  ------------------
  |  Branch (8519:9): [True: 1, False: 44.3k]
  |  Branch (8519:22): [True: 1, False: 44.3k]
  |  Branch (8519:35): [True: 1, False: 44.3k]
  ------------------
 8520|       |
 8521|       |    // Skip remaining host-specific checks for port bytes.  Port digits are
 8522|       |    // validated separately below, and no forbidden-domain-code-point check
 8523|       |    // is needed on port characters.
 8524|  44.3k|    if (port_colon != SIZE_MAX) continue;
  ------------------
  |  Branch (8524:9): [True: 2.72k, False: 41.6k]
  ------------------
 8525|       |
 8526|       |    // -- Host byte validation (inlined) ------------------------------------
 8527|       |    // Forbidden domain code points that are not already caught above:
 8528|       |    //   C0 controls and space (0x00-0x20), DEL (0x7F), <, >, [, ], ^, |.
 8529|       |    // At this stage, the input may still be userinfo or be normalized later
 8530|       |    // (e.g., percent-encoded), so we do not reject here and defer to the
 8531|       |    // parser. Characters already caught: >= 0x80 (non-ASCII), '/' '?' '#' '\\'
 8532|       |    // (delimiters), ':' (port), '@' '%' (bail), '\t' '\n' '\r' (bail).
 8533|  41.6k|    if (c <= 0x20 || c == 0x7F || c == '<' || c == '>' || c == '[' ||
  ------------------
  |  Branch (8533:9): [True: 7, False: 41.6k]
  |  Branch (8533:22): [True: 1, False: 41.6k]
  |  Branch (8533:35): [True: 1, False: 41.6k]
  |  Branch (8533:47): [True: 1, False: 41.6k]
  |  Branch (8533:59): [True: 3, False: 41.6k]
  ------------------
 8534|  41.6k|        c == ']' || c == '^' || c == '|') {
  ------------------
  |  Branch (8534:9): [True: 1, False: 41.6k]
  |  Branch (8534:21): [True: 1, False: 41.5k]
  |  Branch (8534:33): [True: 1, False: 41.5k]
  ------------------
 8535|     16|      return std::nullopt;
 8536|     16|    }
 8537|       |
 8538|       |    // Track whether host is all decimal digits and dots (potential IPv4).
 8539|  41.5k|    if (c != '.' && (c < '0' || c > '9')) all_dec_dots = false;
  ------------------
  |  Branch (8539:9): [True: 36.8k, False: 4.78k]
  |  Branch (8539:22): [True: 2.78k, False: 34.0k]
  |  Branch (8539:33): [True: 25.1k, False: 8.89k]
  ------------------
 8540|       |
 8541|       |    // Detect xn-- prefix inline (IDNA punycode -> needs full parser).
 8542|       |    // Checking at every position mirrors the original behavior: any
 8543|       |    // occurrence of "xn--" in the host (not just at label boundaries)
 8544|       |    // triggers a bail-out to the full IDNA validator.
 8545|  41.5k|    if ((c | 0x20) == 'x' && auth_end + 4 <= len &&
  ------------------
  |  Branch (8545:9): [True: 7.06k, False: 34.5k]
  |  Branch (8545:30): [True: 6.60k, False: 461]
  ------------------
 8546|  6.60k|        (b[auth_end + 1] | 0x20) == 'n' && b[auth_end + 2] == '-' &&
  ------------------
  |  Branch (8546:9): [True: 1.85k, False: 4.74k]
  |  Branch (8546:44): [True: 1.59k, False: 260]
  ------------------
 8547|  1.59k|        b[auth_end + 3] == '-') {
  ------------------
  |  Branch (8547:9): [True: 1.28k, False: 316]
  ------------------
 8548|  1.28k|      return std::nullopt;
 8549|  1.28k|    }
 8550|  41.5k|  }
 8551|       |
 8552|  6.18k|  const size_t host_end = (port_colon != SIZE_MAX) ? port_colon : auth_end;
  ------------------
  |  Branch (8552:27): [True: 1.92k, False: 4.25k]
  ------------------
 8553|       |
 8554|       |  // Empty host is invalid for special URLs.
 8555|  6.18k|  if (auth_start == host_end) return false;
  ------------------
  |  Branch (8555:7): [True: 38, False: 6.14k]
  ------------------
 8556|       |
 8557|       |  // -- IPv4 handling ---------------------------------------------------------
 8558|  6.14k|  const char* host_ptr = reinterpret_cast<const char*>(b + auth_start);
 8559|  6.14k|  const size_t host_len = host_end - auth_start;
 8560|       |
 8561|  6.14k|  if (all_dec_dots) {
  ------------------
  |  Branch (8561:7): [True: 1.38k, False: 4.76k]
  ------------------
 8562|       |    // Host is all decimal digits and dots -> try the fast IPv4 parser.
 8563|  1.38k|    if (checkers::try_parse_ipv4_fast({host_ptr, host_len}) !=
  ------------------
  |  Branch (8563:9): [True: 736, False: 648]
  ------------------
 8564|  1.38k|        checkers::ipv4_fast_fail) {
 8565|       |      // Valid decimal IPv4 host.  Do NOT return true yet: the port still
 8566|       |      // needs to be validated below before we can declare the URL valid.
 8567|    736|      goto validate_port;
 8568|    736|    }
 8569|       |    // Fast IPv4 parsing failed (e.g. host is ".", "..", "1.2.3.500").
 8570|       |    // Such hosts may still be valid domain names; defer to the full parser.
 8571|    648|    return std::nullopt;
 8572|  1.38k|  }
 8573|       |
 8574|  4.76k|  if (checkers::last_label_may_be_a_number({host_ptr, host_len})) {
  ------------------
  |  Branch (8574:7): [True: 270, False: 4.49k]
  ------------------
 8575|    270|    return std::nullopt;
 8576|    270|  }
 8577|       |
 8578|       |  // -- Port validation -------------------------------------------------------
 8579|  5.22k|validate_port:
 8580|  5.22k|  if (port_colon != SIZE_MAX) {
  ------------------
  |  Branch (8580:7): [True: 1.68k, False: 3.54k]
  ------------------
 8581|  1.68k|    const uint8_t* pp = b + port_colon + 1;
 8582|  1.68k|    size_t pl = auth_end - port_colon - 1;
 8583|  1.68k|    if (pl > 0) {
  ------------------
  |  Branch (8583:9): [True: 1.23k, False: 443]
  ------------------
 8584|       |      // Strip leading zeros: "0000001" == 1, "0000000000000" == 0, both valid.
 8585|       |      // Only the significant digits count toward the 5-digit maximum.
 8586|  1.72k|      while (pl > 0 && *pp == '0') {
  ------------------
  |  Branch (8586:14): [True: 1.41k, False: 306]
  |  Branch (8586:24): [True: 488, False: 931]
  ------------------
 8587|    488|        ++pp;
 8588|    488|        --pl;
 8589|    488|      }
 8590|  1.23k|      if (pl > 5) return false;  // significant digits > 99999
  ------------------
  |  Branch (8590:11): [True: 4, False: 1.23k]
  ------------------
 8591|  1.23k|      uint32_t pv = 0;
 8592|  2.60k|      for (size_t i = 0; i < pl; ++i) {
  ------------------
  |  Branch (8592:26): [True: 1.38k, False: 1.21k]
  ------------------
 8593|  1.38k|        if (pp[i] < '0' || pp[i] > '9') return false;
  ------------------
  |  Branch (8593:13): [True: 4, False: 1.38k]
  |  Branch (8593:28): [True: 15, False: 1.36k]
  ------------------
 8594|  1.36k|        pv = pv * 10 + (pp[i] - '0');
 8595|  1.36k|      }
 8596|  1.21k|      if (pv > 65535) return false;
  ------------------
  |  Branch (8596:11): [True: 3, False: 1.21k]
  ------------------
 8597|  1.21k|    }
 8598|  1.68k|  }
 8599|       |
 8600|       |  // Path, query, and fragment are structurally always valid for can_parse --
 8601|       |  // the parser would encode whatever is there.
 8602|  5.20k|  return true;
 8603|  5.22k|}
_ZN3ada7helpers27remove_ascii_tab_or_newlineERNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 8904|  1.36k|ada_really_inline void remove_ascii_tab_or_newline(std::string& input) {
 8905|       |  // Fast path: inputs with no tab/newline (the common case) avoid the
 8906|       |  // per-character erase_if scan. has_tabs_or_newline uses SIMD for inputs
 8907|       |  // >= 16 bytes, making this check much cheaper than erase_if's scalar
 8908|       |  // predicate walk when there is nothing to remove.
 8909|  1.36k|  if (!ada::unicode::has_tabs_or_newline(input)) {
  ------------------
  |  Branch (8909:7): [True: 0, False: 1.36k]
  ------------------
 8910|      0|    return;
 8911|      0|  }
 8912|  1.36k|  std::erase_if(input, ada::unicode::is_ascii_tab_or_newline);
 8913|  1.36k|}
_ZN3ada7unicode23is_ascii_tab_or_newlineEc:
 7437|  60.2k|    const char c) noexcept {
 7438|  60.2k|  return c == '\t' || c == '\n' || c == '\r';
  ------------------
  |  Branch (7438:10): [True: 1.14k, False: 59.1k]
  |  Branch (7438:23): [True: 1.61k, False: 57.5k]
  |  Branch (7438:36): [True: 1.12k, False: 56.3k]
  ------------------
 7439|  60.2k|}
_ZN3ada7unicode22is_c0_control_or_spaceEc:
 7432|   158k|ada_really_inline constexpr bool is_c0_control_or_space(const char c) noexcept {
 7433|   158k|  return (unsigned char)c <= ' ';
 7434|   158k|}
_ZN3ada7helpers19parse_prepared_pathENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEENS_6scheme4typeERNS1_12basic_stringIcS4_NS1_9allocatorIcEEEE:
 9609|  10.7k|                                           std::string& path) {
 9610|  10.7k|  ada_log("parse_prepared_path ", input);
 9611|  10.7k|  uint8_t accumulator = checkers::path_signature(input);
 9612|       |  // Let us first detect a trivial case.
 9613|       |  // If it is special, we check that we have no dot, no %,  no \ and no
 9614|       |  // character needing percent encoding. Otherwise, we check that we have no %,
 9615|       |  // no dot, and no character needing percent encoding.
 9616|  10.7k|  constexpr uint8_t need_encoding = 1;
 9617|  10.7k|  constexpr uint8_t backslash_char = 2;
 9618|  10.7k|  constexpr uint8_t dot_char = 4;
 9619|  10.7k|  constexpr uint8_t percent_char = 8;
 9620|  10.7k|  bool special = type != ada::scheme::NOT_SPECIAL;
 9621|  10.7k|  bool may_need_slow_file_handling = (type == ada::scheme::type::FILE &&
  ------------------
  |  Branch (9621:39): [True: 1.66k, False: 9.07k]
  ------------------
 9622|  1.66k|                                      checkers::is_windows_drive_letter(input));
  ------------------
  |  Branch (9622:39): [True: 124, False: 1.53k]
  ------------------
 9623|  10.7k|  bool trivial_path =
 9624|  10.7k|      (special ? (accumulator == 0)
  ------------------
  |  Branch (9624:7): [True: 4.87k, False: 5.85k]
  |  Branch (9624:8): [True: 9.18k, False: 1.55k]
  ------------------
 9625|  10.7k|               : ((accumulator & (need_encoding | dot_char | percent_char)) ==
 9626|  1.55k|                  0)) &&
 9627|  4.87k|      (!may_need_slow_file_handling);
  ------------------
  |  Branch (9627:7): [True: 4.78k, False: 89]
  ------------------
 9628|  10.7k|  if (accumulator == dot_char && !may_need_slow_file_handling) {
  ------------------
  |  Branch (9628:7): [True: 1.63k, False: 9.10k]
  |  Branch (9628:34): [True: 1.60k, False: 23]
  ------------------
 9629|       |    // '4' means that we have at least one dot, but nothing that requires
 9630|       |    // percent encoding or decoding. The only part that is not trivial is
 9631|       |    // that we may have single dots and double dots path segments.
 9632|       |    // If we have such segments, then we either have a path that begins
 9633|       |    // with '.' (easy to check), or we have the sequence './'.
 9634|       |    // Note: input cannot be empty, it must at least contain one character ('.')
 9635|       |    // Note: we know that '\' is not present.
 9636|  1.60k|    if (input[0] != '.') {
  ------------------
  |  Branch (9636:9): [True: 863, False: 746]
  ------------------
 9637|    863|      size_t slashdot = 0;
 9638|    863|      bool dot_is_file = true;
 9639|  5.79k|      for (;;) {
 9640|  5.79k|        slashdot = input.find("/.", slashdot);
 9641|  5.79k|        if (slashdot == std::string_view::npos) {  // common case
  ------------------
  |  Branch (9641:13): [True: 863, False: 4.93k]
  ------------------
 9642|    863|          break;
 9643|  4.93k|        } else {  // uncommon
 9644|       |          // only three cases matter: /./, /.. or a final /
 9645|  4.93k|          slashdot += 2;
 9646|  4.93k|          dot_is_file &= !(slashdot == input.size() || input[slashdot] == '.' ||
  ------------------
  |  Branch (9646:28): [True: 175, False: 4.75k]
  |  Branch (9646:56): [True: 2.84k, False: 1.91k]
  ------------------
 9647|  1.91k|                           input[slashdot] == '/');
  ------------------
  |  Branch (9647:28): [True: 1.29k, False: 616]
  ------------------
 9648|  4.93k|        }
 9649|  5.79k|      }
 9650|    863|      trivial_path = dot_is_file;
 9651|    863|    }
 9652|  1.60k|  }
 9653|  10.7k|  if (trivial_path) {
  ------------------
  |  Branch (9653:7): [True: 5.00k, False: 5.73k]
  ------------------
 9654|  5.00k|    ada_log("parse_path trivial");
 9655|  5.00k|    path += '/';
 9656|  5.00k|    path += input;
 9657|  5.00k|    return;
 9658|  5.00k|  }
 9659|       |  // We are going to need to look a bit at the path, but let us see if we can
 9660|       |  // ignore percent encoding *and* backslashes *and* percent characters.
 9661|       |  // Except for the trivial case, this is likely to capture 99% of paths out
 9662|       |  // there.
 9663|  5.73k|  bool fast_path =
 9664|  5.73k|      (special &&
  ------------------
  |  Branch (9664:8): [True: 4.60k, False: 1.12k]
  ------------------
 9665|  4.60k|       (accumulator & (need_encoding | backslash_char | percent_char)) == 0) &&
  ------------------
  |  Branch (9665:8): [True: 1.34k, False: 3.26k]
  ------------------
 9666|  1.34k|      (type != ada::scheme::type::FILE);
  ------------------
  |  Branch (9666:7): [True: 1.16k, False: 176]
  ------------------
 9667|  5.73k|  if (fast_path) {
  ------------------
  |  Branch (9667:7): [True: 1.16k, False: 4.56k]
  ------------------
 9668|  1.16k|    ada_log("parse_prepared_path fast");
 9669|       |    // Here we don't need to worry about \ or percent encoding.
 9670|       |    // We also do not have a file protocol. We might have dots, however,
 9671|       |    // but dots must as appear as '.', and they cannot be encoded because
 9672|       |    // the symbol '%' is not present.
 9673|  1.16k|    size_t previous_location = 0;  // We start at 0.
 9674|  15.5k|    do {
 9675|  15.5k|      size_t new_location = input.find('/', previous_location);
 9676|       |      // std::string_view path_view = input;
 9677|       |      //  We process the last segment separately:
 9678|  15.5k|      if (new_location == std::string_view::npos) {
  ------------------
  |  Branch (9678:11): [True: 1.16k, False: 14.3k]
  ------------------
 9679|  1.16k|        std::string_view path_view = input.substr(previous_location);
 9680|  1.16k|        if (path_view == "..") {  // The path ends with ..
  ------------------
  |  Branch (9680:13): [True: 130, False: 1.03k]
  ------------------
 9681|       |          // e.g., if you receive ".." with an empty path, you go to "/".
 9682|    130|          if (path.empty()) {
  ------------------
  |  Branch (9682:15): [True: 50, False: 80]
  ------------------
 9683|     50|            path = '/';
 9684|     50|            return;
 9685|     50|          }
 9686|       |          // Fast case where we have nothing to do:
 9687|     80|          if (path.back() == '/') {
  ------------------
  |  Branch (9687:15): [True: 27, False: 53]
  ------------------
 9688|     27|            return;
 9689|     27|          }
 9690|       |          // If you have the path "/joe/myfriend",
 9691|       |          // then you delete 'myfriend'.
 9692|     53|          path.resize(path.rfind('/') + 1);
 9693|     53|          return;
 9694|     80|        }
 9695|  1.03k|        path += '/';
 9696|  1.03k|        if (path_view != ".") {
  ------------------
  |  Branch (9696:13): [True: 793, False: 244]
  ------------------
 9697|    793|          path.append(path_view);
 9698|    793|        }
 9699|  1.03k|        return;
 9700|  14.3k|      } else {
 9701|       |        // This is a non-final segment.
 9702|  14.3k|        std::string_view path_view =
 9703|  14.3k|            input.substr(previous_location, new_location - previous_location);
 9704|  14.3k|        previous_location = new_location + 1;
 9705|  14.3k|        if (path_view == "..") {
  ------------------
  |  Branch (9705:13): [True: 3.18k, False: 11.2k]
  ------------------
 9706|  3.18k|          size_t last_delimiter = path.rfind('/');
 9707|  3.18k|          if (last_delimiter != std::string::npos) {
  ------------------
  |  Branch (9707:15): [True: 1.23k, False: 1.94k]
  ------------------
 9708|  1.23k|            path.erase(last_delimiter);
 9709|  1.23k|          }
 9710|  11.2k|        } else if (path_view != ".") {
  ------------------
  |  Branch (9710:20): [True: 9.26k, False: 1.94k]
  ------------------
 9711|  9.26k|          path += '/';
 9712|  9.26k|          path.append(path_view);
 9713|  9.26k|        }
 9714|  14.3k|      }
 9715|  15.5k|    } while (true);
  ------------------
  |  Branch (9715:14): [True: 14.3k, Folded]
  ------------------
 9716|  4.56k|  } else {
 9717|  4.56k|    ada_log("parse_path slow");
 9718|       |    // we have reached the general case
 9719|  4.56k|    bool needs_percent_encoding = (accumulator & 1);
 9720|  32.1k|    do {
 9721|  32.1k|      size_t location = (special && (accumulator & 2))
  ------------------
  |  Branch (9721:26): [True: 24.7k, False: 7.39k]
  |  Branch (9721:37): [True: 1.91k, False: 22.8k]
  ------------------
 9722|  32.1k|                            ? input.find_first_of("/\\")
 9723|  32.1k|                            : input.find('/');
 9724|  32.1k|      std::string_view path_view = input;
 9725|  32.1k|      if (location != std::string_view::npos) {
  ------------------
  |  Branch (9725:11): [True: 27.5k, False: 4.56k]
  ------------------
 9726|  27.5k|        path_view.remove_suffix(path_view.size() - location);
 9727|  27.5k|        input.remove_prefix(location + 1);
 9728|  27.5k|      }
 9729|       |      // Path encoding preserves dots and percent signs, so normalize first.
 9730|  32.1k|      if (unicode::is_double_dot_path_segment(path_view)) {
  ------------------
  |  Branch (9730:11): [True: 4.45k, False: 27.7k]
  ------------------
 9731|  4.45k|        helpers::shorten_path(path, type);
 9732|  4.45k|        if (location == std::string_view::npos) {
  ------------------
  |  Branch (9732:13): [True: 255, False: 4.19k]
  ------------------
 9733|    255|          path += '/';
 9734|    255|        }
 9735|  27.7k|      } else if (unicode::is_single_dot_path_segment(path_view) &&
  ------------------
  |  Branch (9735:18): [True: 1.42k, False: 26.2k]
  ------------------
 9736|  1.42k|                 (location == std::string_view::npos)) {
  ------------------
  |  Branch (9736:18): [True: 122, False: 1.29k]
  ------------------
 9737|    122|        path += '/';
 9738|    122|      }
 9739|       |      // Otherwise, if path_view is not a single-dot path segment, then:
 9740|  27.5k|      else if (!unicode::is_single_dot_path_segment(path_view)) {
  ------------------
  |  Branch (9740:16): [True: 26.2k, False: 1.29k]
  ------------------
 9741|       |        // If url's scheme is "file", url's path is empty, and path_view is a
 9742|       |        // Windows drive letter, then replace the second code point in
 9743|       |        // path_view with U+003A (:).
 9744|  26.2k|        if (type == ada::scheme::type::FILE && path.empty() &&
  ------------------
  |  Branch (9744:13): [True: 2.04k, False: 24.2k]
  |  Branch (9744:48): [True: 879, False: 1.16k]
  ------------------
 9745|    879|            path_view.size() == 2 &&
  ------------------
  |  Branch (9745:13): [True: 346, False: 533]
  ------------------
 9746|    346|            checkers::is_windows_drive_letter(path_view)) {
  ------------------
  |  Branch (9746:13): [True: 139, False: 207]
  ------------------
 9747|    139|          path += '/';
 9748|    139|          path += path_view[0];
 9749|    139|          path += ':';
 9750|    139|          path_view.remove_prefix(2);
 9751|    139|          path.append(path_view);
 9752|  26.1k|        } else {
 9753|       |          // Append encoded bytes directly to the pathname.
 9754|  26.1k|          path += '/';
 9755|  26.1k|          if (!needs_percent_encoding ||
  ------------------
  |  Branch (9755:15): [True: 12.5k, False: 13.6k]
  ------------------
 9756|  13.6k|              !ada::unicode::percent_encode<true>(
  ------------------
  |  Branch (9756:15): [True: 8.57k, False: 5.06k]
  ------------------
 9757|  21.0k|                  path_view, character_sets::PATH_PERCENT_ENCODE, path)) {
 9758|  21.0k|            path.append(path_view);
 9759|  21.0k|          }
 9760|  26.1k|        }
 9761|  26.2k|      }
 9762|  32.1k|      if (location == std::string_view::npos) {
  ------------------
  |  Branch (9762:11): [True: 4.56k, False: 27.5k]
  ------------------
 9763|  4.56k|        return;
 9764|  4.56k|      }
 9765|  32.1k|    } while (true);
  ------------------
  |  Branch (9765:14): [True: 27.5k, Folded]
  ------------------
 9766|  4.56k|  }
 9767|  5.73k|}
_ZN3ada8checkers14path_signatureENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
   77|  21.4k|    std::string_view input) noexcept {
   78|       |  // The path percent-encode set is the query percent-encode set and U+003F (?),
   79|       |  // U+0060 (`), U+007B ({), and U+007D (}). The query percent-encode set is the
   80|       |  // C0 control percent-encode set and U+0020 SPACE, U+0022 ("), U+0023 (#),
   81|       |  // U+003C (<), and U+003E (>). The C0 control percent-encode set are the C0
   82|       |  // controls and all code points greater than U+007E (~).
   83|  21.4k|  size_t i = 0;
   84|  21.4k|  uint8_t accumulator{};
   85|  76.5k|  for (; i + 7 < input.size(); i += 8) {
  ------------------
  |  Branch (85:10): [True: 55.0k, False: 21.4k]
  ------------------
   86|  55.0k|    accumulator |= uint8_t(path_signature_table[uint8_t(input[i])] |
   87|  55.0k|                           path_signature_table[uint8_t(input[i + 1])] |
   88|  55.0k|                           path_signature_table[uint8_t(input[i + 2])] |
   89|  55.0k|                           path_signature_table[uint8_t(input[i + 3])] |
   90|  55.0k|                           path_signature_table[uint8_t(input[i + 4])] |
   91|  55.0k|                           path_signature_table[uint8_t(input[i + 5])] |
   92|  55.0k|                           path_signature_table[uint8_t(input[i + 6])] |
   93|  55.0k|                           path_signature_table[uint8_t(input[i + 7])]);
   94|  55.0k|  }
   95|  59.0k|  for (; i < input.size(); i++) {
  ------------------
  |  Branch (95:10): [True: 37.6k, False: 21.4k]
  ------------------
   96|  37.6k|    accumulator |= uint8_t(path_signature_table[uint8_t(input[i])]);
   97|  37.6k|  }
   98|  21.4k|  return accumulator;
   99|  21.4k|}
_ZN3ada7unicode26is_double_dot_path_segmentENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 7445|  64.3k|    std::string_view input) noexcept {
 7446|       |  // This will catch most cases:
 7447|       |  // The length must be 2,4 or 6.
 7448|       |  // We divide by two and require
 7449|       |  // that the result be between 1 and 3 inclusively.
 7450|  64.3k|  uint64_t half_length = uint64_t(input.size()) / 2;
 7451|  64.3k|  if (half_length - 1 > 2) {
  ------------------
  |  Branch (7451:7): [True: 36.5k, False: 27.7k]
  ------------------
 7452|  36.5k|    return false;
 7453|  36.5k|  }
 7454|       |  // We have a string of length 2, 4 or 6.
 7455|       |  // We now check the first character:
 7456|  27.7k|  if ((input[0] != '.') && (input[0] != '%')) {
  ------------------
  |  Branch (7456:7): [True: 13.9k, False: 13.8k]
  |  Branch (7456:28): [True: 6.58k, False: 7.31k]
  ------------------
 7457|  6.58k|    return false;
 7458|  6.58k|  }
 7459|       |  // We are unlikely the get beyond this point.
 7460|  21.1k|  int hash_value = (input.size() + (unsigned)(input[0])) & 3;
 7461|  21.1k|  const std::string_view target = table_is_double_dot_path_segment[hash_value];
 7462|  21.1k|  if (target.size() != input.size()) {
  ------------------
  |  Branch (7462:7): [True: 6.42k, False: 14.7k]
  ------------------
 7463|  6.42k|    return false;
 7464|  6.42k|  }
 7465|       |  // We almost never get here.
 7466|       |  // Optimizing the rest is relatively unimportant.
 7467|  14.7k|  auto prefix_equal_unsafe = [](std::string_view a, std::string_view b) {
 7468|  14.7k|    uint16_t A, B;
 7469|  14.7k|    memcpy(&A, a.data(), sizeof(A));
 7470|  14.7k|    memcpy(&B, b.data(), sizeof(B));
 7471|  14.7k|    return A == B;
 7472|  14.7k|  };
 7473|  14.7k|  if (!prefix_equal_unsafe(input, target)) {
  ------------------
  |  Branch (7473:7): [True: 2.97k, False: 11.7k]
  ------------------
 7474|  2.97k|    return false;
 7475|  2.97k|  }
 7476|  16.5k|  for (size_t i = 2; i < input.size(); i++) {
  ------------------
  |  Branch (7476:22): [True: 7.65k, False: 8.90k]
  ------------------
 7477|  7.65k|    char c = input[i];
 7478|  7.65k|    if ((uint8_t((c | 0x20) - 0x61) <= 25 ? (c | 0x20) : c) != target[i]) {
  ------------------
  |  Branch (7478:9): [True: 2.86k, False: 4.79k]
  |  Branch (7478:10): [True: 3.97k, False: 3.68k]
  ------------------
 7479|  2.86k|      return false;
 7480|  2.86k|    }
 7481|  7.65k|  }
 7482|  8.90k|  return true;
 7483|       |  // The above code might be a bit better than the code below. Compilers
 7484|       |  // are not stupid and may use the fact that these strings have length 2,4 and
 7485|       |  // 6 and other tricks.
 7486|       |  // return input == ".." ||
 7487|       |  //  input == ".%2e" || input == ".%2E" ||
 7488|       |  //  input == "%2e." || input == "%2E." ||
 7489|       |  //  input == "%2e%2e" || input == "%2E%2E" || input == "%2E%2e" || input ==
 7490|       |  //  "%2e%2E";
 7491|  11.7k|}
_ZZN3ada7unicode26is_double_dot_path_segmentENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEENKUlS5_S5_E_clES5_S5_:
 7467|  14.7k|  auto prefix_equal_unsafe = [](std::string_view a, std::string_view b) {
 7468|  14.7k|    uint16_t A, B;
 7469|  14.7k|    memcpy(&A, a.data(), sizeof(A));
 7470|  14.7k|    memcpy(&B, b.data(), sizeof(B));
 7471|  14.7k|    return A == B;
 7472|  14.7k|  };
_ZN3ada7unicode26is_single_dot_path_segmentENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 7494|   110k|    std::string_view input) noexcept {
 7495|   110k|  return input == "." || input == "%2e" || input == "%2E";
  ------------------
  |  Branch (7495:10): [True: 3.73k, False: 106k]
  |  Branch (7495:26): [True: 1.67k, False: 105k]
  |  Branch (7495:44): [True: 34, False: 105k]
  ------------------
 7496|   110k|}
_ZN3ada7unicode28is_forbidden_host_code_pointEc:
 7315|  69.2k|    const char c) noexcept {
 7316|  69.2k|  return is_forbidden_host_code_point_table[uint8_t(c)];
 7317|  69.2k|}
_ZN3ada6detail17parse_ipv4_numberERPKcS2_RmRb:
 9891|  7.24k|                              bool& is_pure_decimal) noexcept {
 9892|  7.24k|  is_pure_decimal = false;
 9893|  7.24k|  if (p >= end) [[unlikely]] {
  ------------------
  |  Branch (9893:7): [True: 0, False: 7.24k]
  ------------------
 9894|      0|    return false;
 9895|      0|  }
 9896|  7.24k|  if (end - p >= 2 && p[0] == '0' && ((p[1] | 0x20) == 'x')) {
  ------------------
  |  Branch (9896:7): [True: 4.85k, False: 2.39k]
  |  Branch (9896:23): [True: 2.39k, False: 2.46k]
  |  Branch (9896:38): [True: 1.54k, False: 846]
  ------------------
 9897|  1.54k|    p += 2;
 9898|  1.54k|    if (p == end || *p == '.') {
  ------------------
  |  Branch (9898:9): [True: 249, False: 1.29k]
  |  Branch (9898:21): [True: 45, False: 1.25k]
  ------------------
 9899|    294|      value = 0;
 9900|    294|      return true;
 9901|    294|    }
 9902|  1.25k|    uint64_t v = 0;
 9903|  1.25k|    int digits = 0;
 9904|  8.14k|    while (p < end && *p != '.') {
  ------------------
  |  Branch (9904:12): [True: 7.26k, False: 882]
  |  Branch (9904:23): [True: 7.16k, False: 99]
  ------------------
 9905|  7.16k|      const uint8_t nib = hex_nibble[static_cast<unsigned char>(*p)];
 9906|  7.16k|      if (nib == 0xff) [[unlikely]] {
  ------------------
  |  Branch (9906:11): [True: 15, False: 7.14k]
  ------------------
 9907|     15|        return false;
 9908|     15|      }
 9909|  7.14k|      if (v > (0xFFFFFFFFULL >> 4)) [[unlikely]] {
  ------------------
  |  Branch (9909:11): [True: 255, False: 6.89k]
  ------------------
 9910|    255|        return false;
 9911|    255|      }
 9912|  6.89k|      v = (v << 4) | nib;
 9913|  6.89k|      ++p;
 9914|  6.89k|      ++digits;
 9915|  6.89k|    }
 9916|    981|    if (digits == 0) [[unlikely]] {
  ------------------
  |  Branch (9916:9): [True: 0, False: 981]
  ------------------
 9917|      0|      return false;
 9918|      0|    }
 9919|    981|    value = v;
 9920|    981|    return true;
 9921|    981|  }
 9922|  5.69k|  if (end - p >= 2 && p[0] == '0' && p[1] >= '0' && p[1] <= '9') {
  ------------------
  |  Branch (9922:7): [True: 3.30k, False: 2.39k]
  |  Branch (9922:23): [True: 846, False: 2.46k]
  |  Branch (9922:38): [True: 486, False: 360]
  |  Branch (9922:53): [True: 474, False: 12]
  ------------------
 9923|    474|    ++p;
 9924|    474|    uint64_t v = 0;
 9925|  3.46k|    while (p < end && *p != '.') {
  ------------------
  |  Branch (9925:12): [True: 3.18k, False: 282]
  |  Branch (9925:23): [True: 3.09k, False: 93]
  ------------------
 9926|  3.09k|      const char c = *p;
 9927|  3.09k|      if (c < '0' || c > '7') [[unlikely]] {
  ------------------
  |  Branch (9927:11): [True: 18, False: 3.07k]
  |  Branch (9927:22): [True: 48, False: 3.02k]
  ------------------
 9928|     66|        return false;
 9929|     66|      }
 9930|  3.02k|      if (v > (0xFFFFFFFFULL >> 3)) [[unlikely]] {
  ------------------
  |  Branch (9930:11): [True: 33, False: 2.99k]
  ------------------
 9931|     33|        return false;
 9932|     33|      }
 9933|  2.99k|      v = (v << 3) | static_cast<uint64_t>(c - '0');
 9934|  2.99k|      ++p;
 9935|  2.99k|    }
 9936|    375|    value = v;
 9937|    375|    return true;
 9938|    474|  }
 9939|  5.22k|  if (*p < '0' || *p > '9') [[unlikely]] {
  ------------------
  |  Branch (9939:7): [True: 198, False: 5.02k]
  |  Branch (9939:19): [True: 330, False: 4.69k]
  ------------------
 9940|    528|    return false;
 9941|    528|  }
 9942|  4.69k|  is_pure_decimal = true;
 9943|  4.69k|  uint64_t v = static_cast<uint64_t>(*p - '0');
 9944|  4.69k|  ++p;
 9945|  9.18k|  while (p < end && *p != '.') {
  ------------------
  |  Branch (9945:10): [True: 5.98k, False: 3.20k]
  |  Branch (9945:21): [True: 4.67k, False: 1.30k]
  ------------------
 9946|  4.67k|    const char c = *p;
 9947|  4.67k|    if (c < '0' || c > '9') [[unlikely]] {
  ------------------
  |  Branch (9947:9): [True: 24, False: 4.65k]
  |  Branch (9947:20): [True: 78, False: 4.57k]
  ------------------
 9948|    102|      return false;
 9949|    102|    }
 9950|  4.57k|    if (v > 429496729ULL) [[unlikely]] {
  ------------------
  |  Branch (9950:9): [True: 69, False: 4.50k]
  ------------------
 9951|     69|      return false;
 9952|     69|    }
 9953|  4.50k|    v = v * 10u + static_cast<uint64_t>(c - '0');
 9954|  4.50k|    if (v > 0xFFFFFFFFULL) [[unlikely]] {
  ------------------
  |  Branch (9954:9): [True: 12, False: 4.49k]
  ------------------
 9955|     12|      return false;
 9956|     12|    }
 9957|  4.49k|    ++p;
 9958|  4.49k|  }
 9959|  4.51k|  value = v;
 9960|  4.51k|  return true;
 9961|  4.69k|}
_ZN3ada6detail15parse_hex_pieceERPKcS2_Rt:
 9965|  3.04k|                           uint16_t& value) noexcept {
 9966|  3.04k|  if (pointer == end) {
  ------------------
  |  Branch (9966:7): [True: 0, False: 3.04k]
  ------------------
 9967|      0|    return 0;
 9968|      0|  }
 9969|  3.04k|  const uint8_t n0 = hex_nibble[static_cast<unsigned char>(*pointer)];
 9970|  3.04k|  if (n0 == 0xff) {
  ------------------
  |  Branch (9970:7): [True: 141, False: 2.90k]
  ------------------
 9971|    141|    return 0;
 9972|    141|  }
 9973|  2.90k|  uint32_t v = n0;
 9974|  2.90k|  ++pointer;
 9975|  2.90k|  int length = 1;
 9976|  2.90k|  if (pointer != end) {
  ------------------
  |  Branch (9976:7): [True: 2.62k, False: 273]
  ------------------
 9977|  2.62k|    const uint8_t n1 = hex_nibble[static_cast<unsigned char>(*pointer)];
 9978|  2.62k|    if (n1 != 0xff) {
  ------------------
  |  Branch (9978:9): [True: 1.02k, False: 1.60k]
  ------------------
 9979|  1.02k|      v = (v << 4) | n1;
 9980|  1.02k|      ++pointer;
 9981|  1.02k|      ++length;
 9982|  1.02k|      if (pointer != end) {
  ------------------
  |  Branch (9982:11): [True: 945, False: 75]
  ------------------
 9983|    945|        const uint8_t n2 = hex_nibble[static_cast<unsigned char>(*pointer)];
 9984|    945|        if (n2 != 0xff) {
  ------------------
  |  Branch (9984:13): [True: 621, False: 324]
  ------------------
 9985|    621|          v = (v << 4) | n2;
 9986|    621|          ++pointer;
 9987|    621|          ++length;
 9988|    621|          if (pointer != end) {
  ------------------
  |  Branch (9988:15): [True: 510, False: 111]
  ------------------
 9989|    510|            const uint8_t n3 = hex_nibble[static_cast<unsigned char>(*pointer)];
 9990|    510|            if (n3 != 0xff) {
  ------------------
  |  Branch (9990:17): [True: 255, False: 255]
  ------------------
 9991|    255|              v = (v << 4) | n3;
 9992|    255|              ++pointer;
 9993|    255|              ++length;
 9994|    255|            }
 9995|    510|          }
 9996|    621|        }
 9997|    945|      }
 9998|  1.02k|    }
 9999|  2.62k|  }
10000|  2.90k|  value = static_cast<uint16_t>(v);
10001|  2.90k|  return length;
10002|  3.04k|}
_ZN3ada3url10parse_pathENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
10577|  2.33k|ada_really_inline void url::parse_path(std::string_view input) {
10578|  2.33k|  ada_log("parse_path ", input);
10579|  2.33k|  std::string tmp_buffer;
10580|  2.33k|  std::string_view internal_input;
10581|  2.33k|  if (unicode::has_tabs_or_newline(input)) {
  ------------------
  |  Branch (10581:7): [True: 0, False: 2.33k]
  ------------------
10582|      0|    tmp_buffer = input;
10583|       |    // Optimization opportunity: Instead of copying and then pruning, we could
10584|       |    // just directly build the string from user_input.
10585|      0|    helpers::remove_ascii_tab_or_newline(tmp_buffer);
10586|      0|    internal_input = tmp_buffer;
10587|  2.33k|  } else {
10588|  2.33k|    internal_input = input;
10589|  2.33k|  }
10590|       |
10591|       |  // If url is special, then:
10592|  2.33k|  if (is_special()) {
  ------------------
  |  Branch (10592:7): [True: 2.33k, False: 0]
  ------------------
10593|  2.33k|    if (internal_input.empty()) {
  ------------------
  |  Branch (10593:9): [True: 102, False: 2.22k]
  ------------------
10594|    102|      path = "/";
10595|  2.22k|    } else if ((internal_input[0] == '/') || (internal_input[0] == '\\')) {
  ------------------
  |  Branch (10595:16): [True: 2.22k, False: 0]
  |  Branch (10595:46): [True: 0, False: 0]
  ------------------
10596|  2.22k|      helpers::parse_prepared_path(internal_input.substr(1), type, path);
10597|  2.22k|    } else {
10598|      0|      helpers::parse_prepared_path(internal_input, type, path);
10599|      0|    }
10600|  2.33k|  } else if (!internal_input.empty()) {
  ------------------
  |  Branch (10600:14): [True: 0, False: 0]
  ------------------
10601|      0|    if (internal_input[0] == '/') {
  ------------------
  |  Branch (10601:9): [True: 0, False: 0]
  ------------------
10602|      0|      helpers::parse_prepared_path(internal_input.substr(1), type, path);
10603|      0|    } else {
10604|      0|      helpers::parse_prepared_path(internal_input, type, path);
10605|      0|    }
10606|      0|  } else {
10607|      0|    if (!host.has_value()) {
  ------------------
  |  Branch (10607:9): [True: 0, False: 0]
  ------------------
10608|      0|      path = "/";
10609|      0|    }
10610|      0|  }
10611|  2.33k|}
_ZN3ada7unicode13is_alnum_plusEc:
 7409|   185k|ada_really_inline constexpr bool is_alnum_plus(const char c) noexcept {
 7410|   185k|  return is_alnum_plus_table[uint8_t(c)];
 7411|       |  // A table is almost surely much faster than the
 7412|       |  // following under most compilers: return
 7413|       |  // return (std::isalnum(c) || c == '+' || c == '-' || c == '.');
 7414|   185k|}
_ZN3ada7unicode14to_lower_asciiEPcm:
 7086|  41.2k|constexpr bool to_lower_ascii(char* input, size_t length) noexcept {
 7087|  41.2k|  uint64_t broadcast_80 = broadcast(0x80);
 7088|  41.2k|  uint64_t broadcast_Ap = broadcast(128 - 'A');
 7089|  41.2k|  uint64_t broadcast_Zp = broadcast(128 - 'Z' - 1);
 7090|  41.2k|  uint64_t non_ascii = 0;
 7091|  41.2k|  size_t i = 0;
 7092|       |
 7093|  51.8k|  for (; i + 7 < length; i += 8) {
  ------------------
  |  Branch (7093:10): [True: 10.6k, False: 41.2k]
  ------------------
 7094|  10.6k|    uint64_t word{};
 7095|  10.6k|    memcpy(&word, input + i, sizeof(word));
 7096|  10.6k|    non_ascii |= (word & broadcast_80);
 7097|  10.6k|    word ^=
 7098|  10.6k|        (((word + broadcast_Ap) ^ (word + broadcast_Zp)) & broadcast_80) >> 2;
 7099|  10.6k|    memcpy(input + i, &word, sizeof(word));
 7100|  10.6k|  }
 7101|  41.2k|  if (i < length) {
  ------------------
  |  Branch (7101:7): [True: 40.3k, False: 930]
  ------------------
 7102|  40.3k|    uint64_t word{};
 7103|  40.3k|    memcpy(&word, input + i, length - i);
 7104|  40.3k|    non_ascii |= (word & broadcast_80);
 7105|  40.3k|    word ^=
 7106|  40.3k|        (((word + broadcast_Ap) ^ (word + broadcast_Zp)) & broadcast_80) >> 2;
 7107|  40.3k|    memcpy(input + i, &word, length - i);
 7108|  40.3k|  }
 7109|  41.2k|  return non_ascii == 0;
 7110|  41.2k|}
_ZN3ada7unicode9broadcastEh:
 7082|   123k|constexpr uint64_t broadcast(uint8_t v) noexcept {
 7083|   123k|  return 0x101010101010101ull * v;
 7084|   123k|}
_ZZN3ada6parser25try_parse_simple_absoluteINS_3urlEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_ENKUlvE_clEv:
12591|  1.23k|    auto apply_query_and_hash = [&]() {
12592|  1.23k|      if (query_start != std::string_view::npos) {
  ------------------
  |  Branch (12592:11): [True: 101, False: 1.13k]
  ------------------
12593|    101|        const size_t q_end =
12594|    101|            (hash_start != std::string_view::npos) ? hash_start : len;
  ------------------
  |  Branch (12594:13): [True: 24, False: 77]
  ------------------
12595|    101|        out.update_base_search(std::string_view(input.data() + query_start + 1,
12596|    101|                                                q_end - query_start - 1),
12597|    101|                               character_sets::SPECIAL_QUERY_PERCENT_ENCODE);
12598|    101|      }
12599|  1.23k|      if (hash_start != std::string_view::npos) {
  ------------------
  |  Branch (12599:11): [True: 94, False: 1.14k]
  ------------------
12600|     94|        out.update_unencoded_base_hash(std::string_view(
12601|     94|            input.data() + hash_start + 1, len - hash_start - 1));
12602|     94|      }
12603|  1.23k|    };
_ZZN3ada6parser25try_parse_simple_absoluteINS_14url_aggregatorEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_ENKUlvE_clEv:
12591|  1.23k|    auto apply_query_and_hash = [&]() {
12592|  1.23k|      if (query_start != std::string_view::npos) {
  ------------------
  |  Branch (12592:11): [True: 101, False: 1.13k]
  ------------------
12593|    101|        const size_t q_end =
12594|    101|            (hash_start != std::string_view::npos) ? hash_start : len;
  ------------------
  |  Branch (12594:13): [True: 24, False: 77]
  ------------------
12595|    101|        out.update_base_search(std::string_view(input.data() + query_start + 1,
12596|    101|                                                q_end - query_start - 1),
12597|    101|                               character_sets::SPECIAL_QUERY_PERCENT_ENCODE);
12598|    101|      }
12599|  1.23k|      if (hash_start != std::string_view::npos) {
  ------------------
  |  Branch (12599:11): [True: 94, False: 1.14k]
  ------------------
12600|     94|        out.update_unencoded_base_hash(std::string_view(
12601|     94|            input.data() + hash_start + 1, len - hash_start - 1));
12602|     94|      }
12603|  1.23k|    };
_ZZN3ada6parser32finish_simple_absolute_with_portINS_3urlEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_NS_6scheme4typeEjmmmbENKUlvE_clEv:
12205|  1.09k|    auto apply_query_and_hash = [&]() {
12206|  1.09k|      if (query_start != std::string_view::npos) {
  ------------------
  |  Branch (12206:11): [True: 78, False: 1.01k]
  ------------------
12207|     78|        const size_t q_end =
12208|     78|            (hash_start != std::string_view::npos) ? hash_start : len;
  ------------------
  |  Branch (12208:13): [True: 20, False: 58]
  ------------------
12209|     78|        out.update_base_search(std::string_view(input.data() + query_start + 1,
12210|     78|                                                q_end - query_start - 1),
12211|     78|                               character_sets::SPECIAL_QUERY_PERCENT_ENCODE);
12212|     78|      }
12213|  1.09k|      if (hash_start != std::string_view::npos) {
  ------------------
  |  Branch (12213:11): [True: 82, False: 1.01k]
  ------------------
12214|     82|        out.update_unencoded_base_hash(std::string_view(
12215|     82|            input.data() + hash_start + 1, len - hash_start - 1));
12216|     82|      }
12217|  1.09k|    };
_ZZN3ada6parser32finish_simple_absolute_with_portINS_14url_aggregatorEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_NS_6scheme4typeEjmmmbENKUlvE_clEv:
12205|  1.09k|    auto apply_query_and_hash = [&]() {
12206|  1.09k|      if (query_start != std::string_view::npos) {
  ------------------
  |  Branch (12206:11): [True: 78, False: 1.01k]
  ------------------
12207|     78|        const size_t q_end =
12208|     78|            (hash_start != std::string_view::npos) ? hash_start : len;
  ------------------
  |  Branch (12208:13): [True: 20, False: 58]
  ------------------
12209|     78|        out.update_base_search(std::string_view(input.data() + query_start + 1,
12210|     78|                                                q_end - query_start - 1),
12211|     78|                               character_sets::SPECIAL_QUERY_PERCENT_ENCODE);
12212|     78|      }
12213|  1.09k|      if (hash_start != std::string_view::npos) {
  ------------------
  |  Branch (12213:11): [True: 82, False: 1.01k]
  ------------------
12214|     82|        out.update_unencoded_base_hash(std::string_view(
12215|     82|            input.data() + hash_start + 1, len - hash_start - 1));
12216|     82|      }
12217|  1.09k|    };
_ZN3ada7helpers10prune_hashERNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8844|   121k|    std::string_view& input) noexcept {
 8845|       |  // compiles down to 20--30 instructions including a class to memchr (C
 8846|       |  // function). this function should be quite fast.
 8847|   121k|  size_t location_of_first = input.find('#');
 8848|   121k|  if (location_of_first == std::string_view::npos) {
  ------------------
  |  Branch (8848:7): [True: 117k, False: 3.98k]
  ------------------
 8849|   117k|    return std::nullopt;
 8850|   117k|  }
 8851|  3.98k|  std::string_view hash = input;
 8852|  3.98k|  hash.remove_prefix(location_of_first + 1);
 8853|  3.98k|  input.remove_suffix(input.size() - location_of_first);
 8854|  3.98k|  return hash;
 8855|   121k|}
_ZZN3ada6parser14parse_url_implINS_3urlELb1EEET_NSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEPKS3_ENKUlvE_clEv:
12914|  19.2k|  const auto enforce_max_input_length = [&]() {
12915|  19.2k|    if constexpr (store_values) {
12916|  19.2k|      if (url.is_valid) {
  ------------------
  |  Branch (12916:11): [True: 19.2k, False: 0]
  ------------------
12917|       |        if constexpr (result_type_is_ada_url_aggregator) {
12918|       |          if (url.buffer.size() > max_input_length) [[unlikely]] {
12919|       |            url.is_valid = false;
12920|       |          }
12921|  19.2k|        } else {
12922|  19.2k|          if (url.get_href_size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (12922:15): [True: 0, False: 19.2k]
  ------------------
12923|      0|            url.is_valid = false;
12924|      0|          }
12925|  19.2k|        }
12926|  19.2k|      }
12927|  19.2k|    }
12928|  19.2k|  };
_ZN3ada7helpers32find_authority_delimiter_specialENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9802|  21.7k|find_authority_delimiter_special(std::string_view view) noexcept {
 9803|       |  // performance note: we might be able to gain further performance
 9804|       |  // with SIMD intrinsics.
 9805|   149k|  for (auto pos = view.begin(); pos != view.end(); ++pos) {
  ------------------
  |  Branch (9805:33): [True: 147k, False: 2.08k]
  ------------------
 9806|   147k|    if (authority_delimiter_special[(uint8_t)*pos]) {
  ------------------
  |  Branch (9806:9): [True: 19.6k, False: 128k]
  ------------------
 9807|  19.6k|      return pos - view.begin();
 9808|  19.6k|    }
 9809|   147k|  }
 9810|  2.08k|  return size_t(view.size());
 9811|  21.7k|}
_ZN3ada7helpers24find_authority_delimiterENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9823|  2.86k|find_authority_delimiter(std::string_view view) noexcept {
 9824|       |  // performance note: we might be able to gain further performance
 9825|       |  // with SIMD instrinsics.
 9826|  33.7k|  for (auto pos = view.begin(); pos != view.end(); ++pos) {
  ------------------
  |  Branch (9826:33): [True: 33.3k, False: 348]
  ------------------
 9827|  33.3k|    if (authority_delimiter[(uint8_t)*pos]) {
  ------------------
  |  Branch (9827:9): [True: 2.51k, False: 30.8k]
  ------------------
 9828|  2.51k|      return pos - view.begin();
 9829|  2.51k|    }
 9830|  33.3k|  }
 9831|    348|  return size_t(view.size());
 9832|  2.86k|}
_ZN3ada7helpers12shorten_pathERNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS_6scheme4typeE:
 8857|  9.56k|ada_really_inline bool shorten_path(std::string& path, ada::scheme::type type) {
 8858|       |  // Let path be url's path.
 8859|       |  // If url's scheme is "file", path's size is 1, and path[0] is a normalized
 8860|       |  // Windows drive letter, then return.
 8861|  9.56k|  if (type == ada::scheme::type::FILE &&
  ------------------
  |  Branch (8861:7): [True: 2.96k, False: 6.59k]
  ------------------
 8862|  2.96k|      path.find('/', 1) == std::string_view::npos && !path.empty()) {
  ------------------
  |  Branch (8862:7): [True: 2.24k, False: 716]
  |  Branch (8862:54): [True: 1.48k, False: 764]
  ------------------
 8863|  1.48k|    if (checkers::is_normalized_windows_drive_letter(
  ------------------
  |  Branch (8863:9): [True: 739, False: 744]
  ------------------
 8864|  1.48k|            helpers::substring(path, 1))) {
 8865|    739|      return false;
 8866|    739|    }
 8867|  1.48k|  }
 8868|       |
 8869|       |  // Remove path's last item, if any.
 8870|  8.82k|  size_t last_delimiter = path.rfind('/');
 8871|  8.82k|  if (last_delimiter != std::string::npos) {
  ------------------
  |  Branch (8871:7): [True: 4.60k, False: 4.21k]
  ------------------
 8872|  4.60k|    path.erase(last_delimiter);
 8873|  4.60k|    return true;
 8874|  4.60k|  }
 8875|       |
 8876|  4.21k|  return false;
 8877|  8.82k|}
_ZN3ada7helpers27get_host_delimiter_locationEbRNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9518|  41.1k|    const bool is_special, std::string_view& view) noexcept {
 9519|       |  /**
 9520|       |   * The spec at https://url.spec.whatwg.org/#hostname-state expects us to
 9521|       |   * compute a variable called insideBrackets but this variable is only used
 9522|       |   * once, to check whether a ':' character was found outside brackets. Exact
 9523|       |   * text: "Otherwise, if c is U+003A (:) and insideBrackets is false, then:".
 9524|       |   * It is conceptually simpler and arguably more efficient to just return a
 9525|       |   * Boolean indicating whether ':' was found outside brackets.
 9526|       |   */
 9527|  41.1k|  const size_t view_size = view.size();
 9528|  41.1k|  size_t location = 0;
 9529|  41.1k|  bool found_colon = false;
 9530|       |  /**
 9531|       |   * Performance analysis:
 9532|       |   *
 9533|       |   * We are basically seeking the end of the hostname which can be indicated
 9534|       |   * by the end of the view, or by one of the characters ':', '/', '?', '\\'
 9535|       |   * (where '\\' is only applicable for special URLs). However, these must
 9536|       |   * appear outside a bracket range. E.g., if you have [something?]fd: then the
 9537|       |   * '?' does not count.
 9538|       |   *
 9539|       |   * So we can skip ahead to the next delimiter, as long as we include '[' in
 9540|       |   * the set of delimiters, and that we handle it first.
 9541|       |   *
 9542|       |   * So the trick is to have a fast function that locates the next delimiter.
 9543|       |   * Unless we find '[', then it only needs to be called once! Ideally, such a
 9544|       |   * function would be provided by the C++ standard library, but it seems that
 9545|       |   * find_first_of is not very fast, so we are forced to roll our own.
 9546|       |   *
 9547|       |   * We do not break into two loops for speed, but for clarity.
 9548|       |   */
 9549|  41.1k|  if (is_special) {
  ------------------
  |  Branch (9549:7): [True: 38.4k, False: 2.67k]
  ------------------
 9550|       |    // We move to the next delimiter.
 9551|  38.4k|    location = find_next_host_delimiter_special(view, location);
 9552|       |    // Unless we find '[' then we are going only going to have to call
 9553|       |    // find_next_host_delimiter_special once.
 9554|  41.9k|    for (; location < view_size;
  ------------------
  |  Branch (9554:12): [True: 23.0k, False: 18.9k]
  ------------------
 9555|  38.4k|         location = find_next_host_delimiter_special(view, location)) {
 9556|  23.0k|      if (view[location] == '[') {
  ------------------
  |  Branch (9556:11): [True: 3.69k, False: 19.3k]
  ------------------
 9557|  3.69k|        location = view.find(']', location);
 9558|  3.69k|        if (location == std::string_view::npos) {
  ------------------
  |  Branch (9558:13): [True: 192, False: 3.50k]
  ------------------
 9559|       |          // performance: view.find might get translated to a memchr, which
 9560|       |          // has no notion of std::string_view::npos, so the code does not
 9561|       |          // reflect the assembly.
 9562|    192|          location = view_size;
 9563|    192|          break;
 9564|    192|        }
 9565|  19.3k|      } else {
 9566|  19.3k|        found_colon = view[location] == ':';
 9567|  19.3k|        break;
 9568|  19.3k|      }
 9569|  23.0k|    }
 9570|  38.4k|  } else {
 9571|       |    // We move to the next delimiter.
 9572|  2.67k|    location = find_next_host_delimiter(view, location);
 9573|       |    // Unless we find '[' then we are going only going to have to call
 9574|       |    // find_next_host_delimiter_special once.
 9575|  4.38k|    for (; location < view_size;
  ------------------
  |  Branch (9575:12): [True: 2.54k, False: 1.84k]
  ------------------
 9576|  2.67k|         location = find_next_host_delimiter(view, location)) {
 9577|  2.54k|      if (view[location] == '[') {
  ------------------
  |  Branch (9577:11): [True: 1.76k, False: 777]
  ------------------
 9578|  1.76k|        location = view.find(']', location);
 9579|  1.76k|        if (location == std::string_view::npos) {
  ------------------
  |  Branch (9579:13): [True: 54, False: 1.71k]
  ------------------
 9580|       |          // performance: view.find might get translated to a memchr, which
 9581|       |          // has no notion of std::string_view::npos, so the code does not
 9582|       |          // reflect the assembly.
 9583|     54|          location = view_size;
 9584|     54|          break;
 9585|     54|        }
 9586|  1.76k|      } else {
 9587|    777|        found_colon = view[location] == ':';
 9588|    777|        break;
 9589|    777|      }
 9590|  2.54k|    }
 9591|  2.67k|  }
 9592|       |  // performance: remove_suffix may translate into a single instruction.
 9593|  41.1k|  view.remove_suffix(view_size - location);
 9594|  41.1k|  return {location, found_colon};
 9595|  41.1k|}
_ZN3ada7helpers32find_next_host_delimiter_specialENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEm:
 9108|  41.9k|    std::string_view view, size_t location) noexcept {
 9109|       |  // first check for short strings in which case we do it naively.
 9110|  41.9k|  if (view.size() - location < 16) {  // slow path
  ------------------
  |  Branch (9110:7): [True: 28.2k, False: 13.7k]
  ------------------
 9111|   150k|    for (size_t i = location; i < view.size(); i++) {
  ------------------
  |  Branch (9111:31): [True: 136k, False: 14.4k]
  ------------------
 9112|   136k|      if (view[i] == ':' || view[i] == '/' || view[i] == '\\' ||
  ------------------
  |  Branch (9112:11): [True: 5.31k, False: 131k]
  |  Branch (9112:29): [True: 6.01k, False: 125k]
  |  Branch (9112:47): [True: 32, False: 125k]
  ------------------
 9113|   125k|          view[i] == '?' || view[i] == '[') {
  ------------------
  |  Branch (9113:11): [True: 644, False: 124k]
  |  Branch (9113:29): [True: 1.70k, False: 122k]
  ------------------
 9114|  13.7k|        return i;
 9115|  13.7k|      }
 9116|   136k|    }
 9117|  14.4k|    return size_t(view.size());
 9118|  28.2k|  }
 9119|       |  // fast path for long strings (expected to be common)
 9120|  13.7k|  size_t i = location;
 9121|  13.7k|  const __m128i mask1 = _mm_set1_epi8(':');
 9122|  13.7k|  const __m128i mask2 = _mm_set1_epi8('/');
 9123|  13.7k|  const __m128i mask3 = _mm_set1_epi8('\\');
 9124|  13.7k|  const __m128i mask4 = _mm_set1_epi8('?');
 9125|  13.7k|  const __m128i mask5 = _mm_set1_epi8('[');
 9126|       |
 9127|  50.7k|  for (; i + 15 < view.size(); i += 16) {
  ------------------
  |  Branch (9127:10): [True: 43.2k, False: 7.46k]
  ------------------
 9128|  43.2k|    __m128i word = _mm_loadu_si128((const __m128i*)(view.data() + i));
 9129|  43.2k|    __m128i m1 = _mm_cmpeq_epi8(word, mask1);
 9130|  43.2k|    __m128i m2 = _mm_cmpeq_epi8(word, mask2);
 9131|  43.2k|    __m128i m3 = _mm_cmpeq_epi8(word, mask3);
 9132|  43.2k|    __m128i m4 = _mm_cmpeq_epi8(word, mask4);
 9133|  43.2k|    __m128i m5 = _mm_cmpeq_epi8(word, mask5);
 9134|  43.2k|    __m128i m = _mm_or_si128(
 9135|  43.2k|        _mm_or_si128(_mm_or_si128(m1, m2), _mm_or_si128(m3, m4)), m5);
 9136|  43.2k|    int mask = _mm_movemask_epi8(m);
 9137|  43.2k|    if (mask != 0) {
  ------------------
  |  Branch (9137:9): [True: 6.30k, False: 36.9k]
  ------------------
 9138|  6.30k|      return i + trailing_zeroes(mask);
 9139|  6.30k|    }
 9140|  43.2k|  }
 9141|  7.46k|  if (i < view.size()) {
  ------------------
  |  Branch (9141:7): [True: 6.82k, False: 638]
  ------------------
 9142|  6.82k|    __m128i word =
 9143|  6.82k|        _mm_loadu_si128((const __m128i*)(view.data() + view.length() - 16));
 9144|  6.82k|    __m128i m1 = _mm_cmpeq_epi8(word, mask1);
 9145|  6.82k|    __m128i m2 = _mm_cmpeq_epi8(word, mask2);
 9146|  6.82k|    __m128i m3 = _mm_cmpeq_epi8(word, mask3);
 9147|  6.82k|    __m128i m4 = _mm_cmpeq_epi8(word, mask4);
 9148|  6.82k|    __m128i m5 = _mm_cmpeq_epi8(word, mask5);
 9149|  6.82k|    __m128i m = _mm_or_si128(
 9150|  6.82k|        _mm_or_si128(_mm_or_si128(m1, m2), _mm_or_si128(m3, m4)), m5);
 9151|  6.82k|    int mask = _mm_movemask_epi8(m);
 9152|  6.82k|    if (mask != 0) {
  ------------------
  |  Branch (9152:9): [True: 3.01k, False: 3.81k]
  ------------------
 9153|  3.01k|      return view.length() - 16 + trailing_zeroes(mask);
 9154|  3.01k|    }
 9155|  6.82k|  }
 9156|  4.45k|  return size_t(view.length());
 9157|  7.46k|}
_ZN3ada7helpers15trailing_zeroesEj:
 8930|  10.9k|ada_really_inline int trailing_zeroes(uint32_t input_num) noexcept {
 8931|       |#ifdef ADA_REGULAR_VISUAL_STUDIO
 8932|       |  unsigned long ret;
 8933|       |  // Search the mask data from least significant bit (LSB)
 8934|       |  // to the most significant bit (MSB) for a set bit (1).
 8935|       |  _BitScanForward(&ret, input_num);
 8936|       |  return (int)ret;
 8937|       |#else   // ADA_REGULAR_VISUAL_STUDIO
 8938|  10.9k|  return __builtin_ctzl(input_num);
 8939|  10.9k|#endif  // ADA_REGULAR_VISUAL_STUDIO
 8940|  10.9k|}
_ZN3ada7helpers24find_next_host_delimiterENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEm:
 9384|  4.38k|                                                  size_t location) noexcept {
 9385|       |  // first check for short strings in which case we do it naively.
 9386|  4.38k|  if (view.size() - location < 16) {  // slow path
  ------------------
  |  Branch (9386:7): [True: 2.12k, False: 2.25k]
  ------------------
 9387|  5.98k|    for (size_t i = location; i < view.size(); i++) {
  ------------------
  |  Branch (9387:31): [True: 4.81k, False: 1.17k]
  ------------------
 9388|  4.81k|      if (view[i] == ':' || view[i] == '/' || view[i] == '?' ||
  ------------------
  |  Branch (9388:11): [True: 213, False: 4.60k]
  |  Branch (9388:29): [True: 150, False: 4.45k]
  |  Branch (9388:47): [True: 108, False: 4.34k]
  ------------------
 9389|  4.34k|          view[i] == '[') {
  ------------------
  |  Branch (9389:11): [True: 486, False: 3.86k]
  ------------------
 9390|    957|        return i;
 9391|    957|      }
 9392|  4.81k|    }
 9393|  1.17k|    return size_t(view.size());
 9394|  2.12k|  }
 9395|       |  // fast path for long strings (expected to be common)
 9396|  2.25k|  size_t i = location;
 9397|  2.25k|  const __m128i mask1 = _mm_set1_epi8(':');
 9398|  2.25k|  const __m128i mask2 = _mm_set1_epi8('/');
 9399|  2.25k|  const __m128i mask4 = _mm_set1_epi8('?');
 9400|  2.25k|  const __m128i mask5 = _mm_set1_epi8('[');
 9401|       |
 9402|  6.43k|  for (; i + 15 < view.size(); i += 16) {
  ------------------
  |  Branch (9402:10): [True: 5.64k, False: 789]
  ------------------
 9403|  5.64k|    __m128i word = _mm_loadu_si128((const __m128i*)(view.data() + i));
 9404|  5.64k|    __m128i m1 = _mm_cmpeq_epi8(word, mask1);
 9405|  5.64k|    __m128i m2 = _mm_cmpeq_epi8(word, mask2);
 9406|  5.64k|    __m128i m4 = _mm_cmpeq_epi8(word, mask4);
 9407|  5.64k|    __m128i m5 = _mm_cmpeq_epi8(word, mask5);
 9408|  5.64k|    __m128i m = _mm_or_si128(_mm_or_si128(m1, m2), _mm_or_si128(m4, m5));
 9409|  5.64k|    int mask = _mm_movemask_epi8(m);
 9410|  5.64k|    if (mask != 0) {
  ------------------
  |  Branch (9410:9): [True: 1.46k, False: 4.18k]
  ------------------
 9411|  1.46k|      return i + trailing_zeroes(mask);
 9412|  1.46k|    }
 9413|  5.64k|  }
 9414|    789|  if (i < view.size()) {
  ------------------
  |  Branch (9414:7): [True: 495, False: 294]
  ------------------
 9415|    495|    __m128i word =
 9416|    495|        _mm_loadu_si128((const __m128i*)(view.data() + view.length() - 16));
 9417|    495|    __m128i m1 = _mm_cmpeq_epi8(word, mask1);
 9418|    495|    __m128i m2 = _mm_cmpeq_epi8(word, mask2);
 9419|    495|    __m128i m4 = _mm_cmpeq_epi8(word, mask4);
 9420|    495|    __m128i m5 = _mm_cmpeq_epi8(word, mask5);
 9421|    495|    __m128i m = _mm_or_si128(_mm_or_si128(m1, m2), _mm_or_si128(m4, m5));
 9422|    495|    int mask = _mm_movemask_epi8(m);
 9423|    495|    if (mask != 0) {
  ------------------
  |  Branch (9423:9): [True: 117, False: 378]
  ------------------
 9424|    117|      return view.length() - 16 + trailing_zeroes(mask);
 9425|    117|    }
 9426|    495|  }
 9427|    672|  return size_t(view.length());
 9428|    789|}
_ZN3ada3url10parse_hostENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
10468|  15.4k|ada_really_inline bool url::parse_host(std::string_view input) {
10469|  15.4k|  ada_log("parse_host ", input, " [", input.size(), " bytes]");
10470|  15.4k|  if (input.empty()) {
  ------------------
  |  Branch (10470:7): [True: 25, False: 15.3k]
  ------------------
10471|     25|    return is_valid = false;
10472|     25|  }  // technically unnecessary.
10473|       |  // If input starts with U+005B ([), then:
10474|  15.3k|  if (input[0] == '[') {
  ------------------
  |  Branch (10474:7): [True: 713, False: 14.6k]
  ------------------
10475|       |    // If input does not end with U+005D (]), validation error, return failure.
10476|    713|    if (input.back() != ']') {
  ------------------
  |  Branch (10476:9): [True: 159, False: 554]
  ------------------
10477|    159|      return is_valid = false;
10478|    159|    }
10479|    554|    ada_log("parse_host ipv6");
10480|       |
10481|       |    // Return the result of IPv6 parsing input with its leading U+005B ([) and
10482|       |    // trailing U+005D (]) removed.
10483|    554|    input.remove_prefix(1);
10484|    554|    input.remove_suffix(1);
10485|    554|    return parse_ipv6(input);
10486|    713|  }
10487|       |
10488|       |  // If isNotSpecial is true, then return the result of opaque-host parsing
10489|       |  // input.
10490|  14.6k|  if (!is_special()) {
  ------------------
  |  Branch (10490:7): [True: 641, False: 14.0k]
  ------------------
10491|    641|    return parse_opaque_host(input);
10492|    641|  }
10493|       |
10494|       |  // Fast path: try to parse as pure decimal IPv4 first.
10495|  14.0k|  const uint64_t fast_result = checkers::try_parse_ipv4_fast(input);
10496|  14.0k|  if (fast_result < checkers::ipv4_fast_fail) {
  ------------------
  |  Branch (10496:7): [True: 1.01k, False: 13.0k]
  ------------------
10497|  1.01k|    if (!input.empty() && input.back() == '.') {
  ------------------
  |  Branch (10497:9): [True: 1.01k, False: 0]
  |  Branch (10497:27): [True: 22, False: 988]
  ------------------
10498|     22|      host = input.substr(0, input.size() - 1);
10499|    988|    } else {
10500|    988|      host = input;
10501|    988|    }
10502|  1.01k|    host_type = IPV4;
10503|  1.01k|    is_valid = true;
10504|  1.01k|    ada_log("parse_host fast path decimal ipv4");
10505|  1.01k|    return true;
10506|  1.01k|  }
10507|       |  // Let domain be the result of running UTF-8 decode without BOM on the
10508|       |  // percent-decoding of input. Let asciiDomain be the result of running domain
10509|       |  // to ASCII with domain and false. The most common case is an ASCII input, in
10510|       |  // which case we do not need to call the expensive 'to_ascii' if a few
10511|       |  // conditions are met: no '%' and no 'xn-' subsequence.
10512|  13.0k|  const uint8_t forbidden_or_upper =
10513|  13.0k|      unicode::contains_forbidden_domain_code_point_or_upper(input.data(),
10514|  13.0k|                                                             input.size());
10515|  13.0k|  static constexpr std::string_view xn_dash{"xn-", 3};
10516|  13.0k|  if ((forbidden_or_upper & 1) == 0) {
  ------------------
  |  Branch (10516:7): [True: 7.88k, False: 5.13k]
  ------------------
10517|  7.88k|    host = std::string(input);
10518|  7.88k|    if ((forbidden_or_upper & 2) != 0) {
  ------------------
  |  Branch (10518:9): [True: 1.46k, False: 6.42k]
  ------------------
10519|  1.46k|      unicode::to_lower_ascii(host->data(), host->size());
10520|  1.46k|    }
10521|  7.88k|    if (host->find('-') == std::string_view::npos ||
  ------------------
  |  Branch (10521:9): [True: 5.71k, False: 2.17k]
  ------------------
10522|  6.08k|        host->find(xn_dash) == std::string_view::npos) {
  ------------------
  |  Branch (10522:9): [True: 372, False: 1.80k]
  ------------------
10523|  6.08k|      if (checkers::is_ipv4(*host)) {
  ------------------
  |  Branch (10523:11): [True: 1.46k, False: 4.62k]
  ------------------
10524|  1.46k|        ada_log("parse_host fast path ipv4");
10525|  1.46k|        return parse_ipv4(*host);
10526|  1.46k|      }
10527|  4.62k|      ada_log("parse_host fast path ", *host);
10528|  4.62k|      is_valid = true;
10529|  4.62k|      return true;
10530|  6.08k|    }
10531|  7.88k|  } else if (const size_t first_percent = input.find('%');
10532|  5.13k|             first_percent != std::string_view::npos) {
  ------------------
  |  Branch (10532:14): [True: 1.02k, False: 4.10k]
  ------------------
10533|  1.02k|    std::string decoded = unicode::percent_decode(input, first_percent);
10534|  1.02k|    const uint8_t decoded_flags =
10535|  1.02k|        unicode::contains_forbidden_domain_code_point_or_upper(decoded.data(),
10536|  1.02k|                                                               decoded.size());
10537|  1.02k|    if ((decoded_flags & 1) == 0) {
  ------------------
  |  Branch (10537:9): [True: 712, False: 317]
  ------------------
10538|    712|      if ((decoded_flags & 2) != 0) {
  ------------------
  |  Branch (10538:11): [True: 320, False: 392]
  ------------------
10539|    320|        unicode::to_lower_ascii(decoded.data(), decoded.size());
10540|    320|      }
10541|    712|      if (decoded.find('-') == std::string_view::npos ||
  ------------------
  |  Branch (10541:11): [True: 612, False: 100]
  ------------------
10542|    654|          decoded.find(xn_dash) == std::string_view::npos) {
  ------------------
  |  Branch (10542:11): [True: 42, False: 58]
  ------------------
10543|    654|        host = std::move(decoded);
10544|    654|        if (checkers::is_ipv4(*host)) {
  ------------------
  |  Branch (10544:13): [True: 284, False: 370]
  ------------------
10545|    284|          return parse_ipv4(*host);
10546|    284|        }
10547|    370|        is_valid = true;
10548|    370|        return true;
10549|    654|      }
10550|    712|    }
10551|  1.02k|  }
10552|  6.27k|  ada_log("parse_host calling to_ascii");
10553|  6.27k|  is_valid = ada::unicode::to_ascii(host, input, input.find('%'));
10554|  6.27k|  if (!is_valid || !host.has_value()) {
  ------------------
  |  Branch (10554:7): [True: 1.90k, False: 4.37k]
  |  Branch (10554:20): [True: 0, False: 4.37k]
  ------------------
10555|  1.90k|    ada_log("parse_host to_ascii returns false");
10556|  1.90k|    return is_valid = false;
10557|  1.90k|  }
10558|  4.37k|  ada_log("parse_host to_ascii succeeded ", *host, " [", host->size(),
10559|  4.37k|          " bytes]");
10560|       |
10561|  4.37k|  if (std::any_of(host->begin(), host->end(),
  ------------------
  |  Branch (10561:7): [True: 0, False: 4.37k]
  ------------------
10562|  4.37k|                  ada::unicode::is_forbidden_domain_code_point)) {
10563|      0|    host = std::nullopt;
10564|      0|    return is_valid = false;
10565|      0|  }
10566|       |
10567|       |  // If asciiDomain ends in a number, then return the result of IPv4 parsing
10568|       |  // asciiDomain.
10569|  4.37k|  if (checkers::is_ipv4(*host)) {
  ------------------
  |  Branch (10569:7): [True: 216, False: 4.15k]
  ------------------
10570|    216|    ada_log("parse_host got ipv4 ", *host);
10571|    216|    return parse_ipv4(*host);
10572|    216|  }
10573|       |
10574|  4.15k|  return true;
10575|  4.37k|}
_ZN3ada7unicode45contains_forbidden_domain_code_point_or_upperEPKcm:
 7379|  42.7k|                                              size_t length) noexcept {
 7380|  42.7k|  size_t i = 0;
 7381|  42.7k|  uint8_t accumulator{};
 7382|   264k|  for (; i + 4 <= length; i += 4) {
  ------------------
  |  Branch (7382:10): [True: 221k, False: 42.7k]
  ------------------
 7383|   221k|    accumulator |=
 7384|   221k|        is_forbidden_domain_code_point_table_or_upper[uint8_t(input[i])];
 7385|   221k|    accumulator |=
 7386|   221k|        is_forbidden_domain_code_point_table_or_upper[uint8_t(input[i + 1])];
 7387|   221k|    accumulator |=
 7388|   221k|        is_forbidden_domain_code_point_table_or_upper[uint8_t(input[i + 2])];
 7389|   221k|    accumulator |=
 7390|   221k|        is_forbidden_domain_code_point_table_or_upper[uint8_t(input[i + 3])];
 7391|   221k|  }
 7392|   105k|  for (; i < length; i++) {
  ------------------
  |  Branch (7392:10): [True: 62.5k, False: 42.7k]
  ------------------
 7393|  62.5k|    accumulator |=
 7394|  62.5k|        is_forbidden_domain_code_point_table_or_upper[uint8_t(input[i])];
 7395|  62.5k|  }
 7396|  42.7k|  return accumulator;
 7397|  42.7k|}
_ZN3ada7unicode30is_forbidden_domain_code_pointEc:
 7338|   992k|    const char c) noexcept {
 7339|   992k|  return is_forbidden_domain_code_point_table[uint8_t(c)];
 7340|   992k|}
_ZN3ada7helpers6resizeERNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEm:
 8923|     24|ada_really_inline void resize(std::string_view& input, size_t pos) noexcept {
 8924|     24|  ADA_ASSERT_TRUE(pos <= input.size());
 8925|     24|  input.remove_suffix(input.size() - pos);
 8926|     24|}
_ZZN3ada6parser14parse_url_implINS_14url_aggregatorELb1EEET_NSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEPKS3_ENKUlvE_clEv:
12914|  19.2k|  const auto enforce_max_input_length = [&]() {
12915|  19.2k|    if constexpr (store_values) {
12916|  19.2k|      if (url.is_valid) {
  ------------------
  |  Branch (12916:11): [True: 19.2k, False: 0]
  ------------------
12917|  19.2k|        if constexpr (result_type_is_ada_url_aggregator) {
12918|  19.2k|          if (url.buffer.size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (12918:15): [True: 0, False: 19.2k]
  ------------------
12919|      0|            url.is_valid = false;
12920|      0|          }
12921|       |        } else {
12922|       |          if (url.get_href_size() > max_input_length) [[unlikely]] {
12923|       |            url.is_valid = false;
12924|       |          }
12925|       |        }
12926|  19.2k|      }
12927|  19.2k|    }
12928|  19.2k|  };
_ZN3ada7helpers12shorten_pathERNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEENS_6scheme4typeE:
 8880|  1.47k|                                    ada::scheme::type type) {
 8881|       |  // Let path be url's path.
 8882|       |  // If url's scheme is "file", path's size is 1, and path[0] is a normalized
 8883|       |  // Windows drive letter, then return.
 8884|  1.47k|  if (type == ada::scheme::type::FILE &&
  ------------------
  |  Branch (8884:7): [True: 214, False: 1.25k]
  ------------------
 8885|    214|      path.find('/', 1) == std::string_view::npos && !path.empty()) {
  ------------------
  |  Branch (8885:7): [True: 188, False: 26]
  |  Branch (8885:54): [True: 81, False: 107]
  ------------------
 8886|     81|    if (checkers::is_normalized_windows_drive_letter(
  ------------------
  |  Branch (8886:9): [True: 3, False: 78]
  ------------------
 8887|     81|            helpers::substring(path, 1))) {
 8888|      3|      return false;
 8889|      3|    }
 8890|     81|  }
 8891|       |
 8892|       |  // Remove path's last item, if any.
 8893|  1.47k|  if (!path.empty()) {
  ------------------
  |  Branch (8893:7): [True: 646, False: 824]
  ------------------
 8894|    646|    size_t slash_loc = path.rfind('/');
 8895|    646|    if (slash_loc != std::string_view::npos) {
  ------------------
  |  Branch (8895:9): [True: 646, False: 0]
  ------------------
 8896|    646|      path.remove_suffix(path.size() - slash_loc);
 8897|    646|      return true;
 8898|    646|    }
 8899|    646|  }
 8900|       |
 8901|    824|  return false;
 8902|  1.47k|}
_ZZN3ada6parser14parse_url_implINS_14url_aggregatorELb0EEET_NSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEPKS3_ENKUlvE_clEv:
12914|    441|  const auto enforce_max_input_length = [&]() {
12915|       |    if constexpr (store_values) {
12916|       |      if (url.is_valid) {
12917|       |        if constexpr (result_type_is_ada_url_aggregator) {
12918|       |          if (url.buffer.size() > max_input_length) [[unlikely]] {
12919|       |            url.is_valid = false;
12920|       |          }
12921|       |        } else {
12922|       |          if (url.get_href_size() > max_input_length) [[unlikely]] {
12923|       |            url.is_valid = false;
12924|       |          }
12925|       |        }
12926|       |      }
12927|       |    }
12928|    441|  };
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_124port_decimal_digit_countEj:
11252|  2.47k|ada_really_inline uint32_t port_decimal_digit_count(uint32_t port) noexcept {
11253|  2.47k|  uint32_t digits = 1;
11254|  3.31k|  while (port >= 10) {
  ------------------
  |  Branch (11254:10): [True: 842, False: 2.47k]
  ------------------
11255|    842|    port /= 10;
11256|    842|    ++digits;
11257|    842|  }
11258|  2.47k|  return digits;
11259|  2.47k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_121append_canonical_portERNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEj:
11262|    685|                                             uint32_t port) {
11263|    685|  buffer += ':';
11264|    685|  char port_buf[5];
11265|    685|  auto [ptr, ec] = std::to_chars(port_buf, port_buf + 5, port);
11266|    685|  (void)ec;
11267|    685|  buffer.append(port_buf, static_cast<size_t>(ptr - port_buf));
11268|    685|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_116authority_has_atEPKhmm:
11412|  3.39k|                                        size_t n) noexcept {
11413|  3.39k|  const size_t rem = n - host_start;
11414|       |#if ADA_NEON
11415|       |  if (rem >= 16) {
11416|       |    const uint8x16_t w = vld1q_u8(p + host_start);
11417|       |    const uint64_t at = neon_nibble_bits(vceqq_u8(w, vdupq_n_u8('@')));
11418|       |    if (at == 0) {
11419|       |      return false;
11420|       |    }
11421|       |    const uint64_t delim = neon_nibble_bits(vceqq_u8(w, vdupq_n_u8('/'))) |
11422|       |                           neon_nibble_bits(vceqq_u8(w, vdupq_n_u8('?'))) |
11423|       |                           neon_nibble_bits(vceqq_u8(w, vdupq_n_u8('#')));
11424|       |    return delim == 0 || std::countr_zero(at) < std::countr_zero(delim);
11425|       |  }
11426|       |#elif ADA_SSE2
11427|  3.39k|  if (rem >= 16) {
  ------------------
  |  Branch (11427:7): [True: 1.09k, False: 2.29k]
  ------------------
11428|  1.09k|    const __m128i w =
11429|  1.09k|        _mm_loadu_si128(reinterpret_cast<const __m128i*>(p + host_start));
11430|  1.09k|    const uint16_t at = static_cast<uint16_t>(
11431|  1.09k|        _mm_movemask_epi8(_mm_cmpeq_epi8(w, _mm_set1_epi8('@'))));
11432|  1.09k|    if (at == 0) {
  ------------------
  |  Branch (11432:9): [True: 1.02k, False: 78]
  ------------------
11433|  1.02k|      return false;
11434|  1.02k|    }
11435|     78|    const uint16_t delim = static_cast<uint16_t>(
11436|     78|        _mm_movemask_epi8(_mm_cmpeq_epi8(w, _mm_set1_epi8('/'))) |
11437|     78|        _mm_movemask_epi8(_mm_cmpeq_epi8(w, _mm_set1_epi8('?'))) |
11438|     78|        _mm_movemask_epi8(_mm_cmpeq_epi8(w, _mm_set1_epi8('#'))));
11439|     78|    return delim == 0 || std::countr_zero(at) < std::countr_zero(delim);
  ------------------
  |  Branch (11439:12): [True: 18, False: 60]
  |  Branch (11439:26): [True: 8, False: 52]
  ------------------
11440|  1.09k|  }
11441|       |#else
11442|       |  (void)p;
11443|       |  (void)rem;
11444|       |#endif
11445|  2.29k|  return false;
11446|  3.39k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_115scan_plain_hostEPKhmmRmRbS5_:
11467|  14.4k|                                     bool& has_x) noexcept {
11468|  14.4k|  has_upper = false;
11469|  14.4k|  has_x = false;
11470|  14.4k|  size_t i = start;
11471|  14.4k|#if ADA_PARSER_SSSE3
11472|  14.4k|  if (parser_use_ssse3() && (len - start >= 16)) {
  ------------------
  |  Branch (11472:7): [True: 14.4k, False: 0]
  |  Branch (11472:29): [True: 7.74k, False: 6.68k]
  ------------------
11473|  7.74k|    const __m128i lo_tbl = nibble_load(k_host_nibbles.low);
11474|  7.74k|    const __m128i hi_tbl = nibble_load(k_host_nibbles.high);
11475|  7.74k|    const __m128i x_splat = _mm_set1_epi8('x');
11476|  7.74k|    auto visit = [&](size_t at) noexcept -> bool {
11477|  7.74k|      const __m128i w =
11478|  7.74k|          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + at));
11479|  7.74k|      const int up = sse2_uppercase(w);
11480|  7.74k|      const int xs = _mm_movemask_epi8(_mm_cmpeq_epi8(w, x_splat));
11481|  7.74k|      const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);
11482|  7.74k|      if (mask == 0) {
11483|  7.74k|        if (up != 0) {
11484|  7.74k|          has_upper = true;
11485|  7.74k|        }
11486|  7.74k|        if (xs != 0) {
11487|  7.74k|          has_x = true;
11488|  7.74k|        }
11489|  7.74k|        return false;
11490|  7.74k|      }
11491|  7.74k|      const int hit = trailing_zeroes32(static_cast<uint32_t>(mask));
11492|  7.74k|      const int valid = (1 << hit) - 1;
11493|  7.74k|      if ((up & valid) != 0) {
11494|  7.74k|        has_upper = true;
11495|  7.74k|      }
11496|  7.74k|      if ((xs & valid) != 0) {
11497|  7.74k|        has_x = true;
11498|  7.74k|      }
11499|  7.74k|      end = at + static_cast<size_t>(hit);
11500|  7.74k|      return true;
11501|  7.74k|    };
11502|  12.9k|    for (; i + 32 <= len; i += 32) {
  ------------------
  |  Branch (11502:12): [True: 8.84k, False: 4.14k]
  ------------------
11503|  8.84k|      if (visit(i) || visit(i + 16)) {
  ------------------
  |  Branch (11503:11): [True: 3.38k, False: 5.45k]
  |  Branch (11503:23): [True: 218, False: 5.23k]
  ------------------
11504|  3.60k|        return k_host_class[b[end]] == 1;
11505|  3.60k|      }
11506|  8.84k|    }
11507|  5.46k|    for (; i + 16 <= len; i += 16) {
  ------------------
  |  Branch (11507:12): [True: 3.59k, False: 1.86k]
  ------------------
11508|  3.59k|      if (visit(i)) {
  ------------------
  |  Branch (11508:11): [True: 2.28k, False: 1.31k]
  ------------------
11509|  2.28k|        return k_host_class[b[end]] == 1;
11510|  2.28k|      }
11511|  3.59k|    }
11512|       |    // Overlapping tail only after a full 16-byte step so the window cannot
11513|       |    // start before `start` (a prior '/' would otherwise look like a host stop).
11514|  1.86k|    if (i > start && i < len) {
  ------------------
  |  Branch (11514:9): [True: 1.86k, False: 0]
  |  Branch (11514:22): [True: 1.79k, False: 72]
  ------------------
11515|  1.79k|      if (visit(len - 16) && end >= i) {
  ------------------
  |  Branch (11515:11): [True: 1.72k, False: 72]
  |  Branch (11515:30): [True: 1.72k, False: 0]
  ------------------
11516|  1.72k|        return k_host_class[b[end]] == 1;
11517|  1.72k|      }
11518|     72|      end = len;
11519|     72|      return true;
11520|  1.79k|    }
11521|  1.86k|  }
11522|       |#elif ADA_SSE2
11523|       |  const __m128i x_splat = _mm_set1_epi8('x');
11524|       |  for (; i + 32 <= len; i += 32) {
11525|       |    for (size_t off = 0; off < 32; off += 16) {
11526|       |      const __m128i w =
11527|       |          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i + off));
11528|       |      const int up = sse2_uppercase(w);
11529|       |      const int xs = _mm_movemask_epi8(_mm_cmpeq_epi8(w, x_splat));
11530|       |      const int mask = sse2_host_stop(w);
11531|       |      if (mask != 0) {
11532|       |        const int hit = trailing_zeroes32(static_cast<uint32_t>(mask));
11533|       |        const int valid = (1 << hit) - 1;
11534|       |        if ((up & valid) != 0) {
11535|       |          has_upper = true;
11536|       |        }
11537|       |        if ((xs & valid) != 0) {
11538|       |          has_x = true;
11539|       |        }
11540|       |        end = i + off + static_cast<size_t>(hit);
11541|       |        return k_host_class[b[end]] == 1;
11542|       |      }
11543|       |      if (up != 0) {
11544|       |        has_upper = true;
11545|       |      }
11546|       |      if (xs != 0) {
11547|       |        has_x = true;
11548|       |      }
11549|       |    }
11550|       |  }
11551|       |  for (; i + 16 <= len; i += 16) {
11552|       |    const __m128i w = _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));
11553|       |    const int up = sse2_uppercase(w);
11554|       |    const int xs = _mm_movemask_epi8(_mm_cmpeq_epi8(w, x_splat));
11555|       |    const int mask = sse2_host_stop(w);
11556|       |    if (mask != 0) {
11557|       |      const int hit = trailing_zeroes32(static_cast<uint32_t>(mask));
11558|       |      const int valid = (1 << hit) - 1;
11559|       |      if ((up & valid) != 0) {
11560|       |        has_upper = true;
11561|       |      }
11562|       |      if ((xs & valid) != 0) {
11563|       |        has_x = true;
11564|       |      }
11565|       |      end = i + static_cast<size_t>(hit);
11566|       |      return k_host_class[b[end]] == 1;
11567|       |    }
11568|       |    if (up != 0) {
11569|       |      has_upper = true;
11570|       |    }
11571|       |    if (xs != 0) {
11572|       |      has_x = true;
11573|       |    }
11574|       |  }
11575|       |#elif ADA_NEON
11576|       |  if (len - start >= 16) {
11577|       |    const uint8x16_t lo_tbl = vld1q_u8(k_host_nibbles.low);
11578|       |    const uint8x16_t hi_tbl = vld1q_u8(k_host_nibbles.high);
11579|       |    const uint8x16_t x_splat = vdupq_n_u8('x');
11580|       |    auto visit = [&](size_t at) noexcept -> bool {
11581|       |      const uint8x16_t w = vld1q_u8(b + at);
11582|       |      const uint64_t up = neon_uppercase(w);
11583|       |      const uint64_t xs = neon_nibble_bits(vceqq_u8(w, x_splat));
11584|       |      const uint64_t bits = neon_table_stop(w, lo_tbl, hi_tbl);
11585|       |      if (bits == 0) {
11586|       |        if (up != 0) {
11587|       |          has_upper = true;
11588|       |        }
11589|       |        if (xs != 0) {
11590|       |          has_x = true;
11591|       |        }
11592|       |        return false;
11593|       |      }
11594|       |      const size_t hit = static_cast<size_t>(trailing_zeroes64(bits)) >> 2;
11595|       |      const uint64_t valid = (hit == 0) ? 0 : (uint64_t{1} << (hit * 4)) - 1;
11596|       |      if ((up & valid) != 0) {
11597|       |        has_upper = true;
11598|       |      }
11599|       |      if ((xs & valid) != 0) {
11600|       |        has_x = true;
11601|       |      }
11602|       |      end = at + hit;
11603|       |      return true;
11604|       |    };
11605|       |    for (; i + 32 <= len; i += 32) {
11606|       |      if (visit(i) || visit(i + 16)) {
11607|       |        return k_host_class[b[end]] == 1;
11608|       |      }
11609|       |    }
11610|       |    for (; i + 16 <= len; i += 16) {
11611|       |      if (visit(i)) {
11612|       |        return k_host_class[b[end]] == 1;
11613|       |      }
11614|       |    }
11615|       |    if (i > start && i < len) {
11616|       |      if (visit(len - 16) && end >= i) {
11617|       |        return k_host_class[b[end]] == 1;
11618|       |      }
11619|       |      end = len;
11620|       |      return true;
11621|       |    }
11622|       |  }
11623|       |#endif
11624|  26.6k|  for (; i < len; ++i) {
  ------------------
  |  Branch (11624:10): [True: 26.3k, False: 328]
  ------------------
11625|  26.3k|    const uint8_t c = b[i];
11626|  26.3k|    const uint8_t cls = k_host_class[c];
11627|  26.3k|    if (cls == 1) {
  ------------------
  |  Branch (11627:9): [True: 6.21k, False: 20.1k]
  ------------------
11628|  6.21k|      end = i;
11629|  6.21k|      return true;
11630|  6.21k|    }
11631|  20.1k|    if (cls == 2) {
  ------------------
  |  Branch (11631:9): [True: 206, False: 19.9k]
  ------------------
11632|    206|      return false;
11633|    206|    }
11634|  19.9k|    if (c >= 'A' && c <= 'Z') {
  ------------------
  |  Branch (11634:9): [True: 12.1k, False: 7.79k]
  |  Branch (11634:21): [True: 724, False: 11.3k]
  ------------------
11635|    724|      has_upper = true;
11636|  19.1k|    } else if (c == 'x') {
  ------------------
  |  Branch (11636:16): [True: 2.89k, False: 16.2k]
  ------------------
11637|  2.89k|      has_x = true;
11638|  2.89k|    }
11639|  19.9k|  }
11640|    328|  end = len;
11641|    328|  return true;
11642|  6.75k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_116parser_use_ssse3Ev:
11452|  28.4k|ada_really_inline bool parser_use_ssse3() noexcept {
11453|  28.4k|#ifdef ADA_PARSER_NEED_SSSE3_TARGET
11454|  28.4k|  static const bool supported = __builtin_cpu_supports("ssse3") != 0;
11455|  28.4k|  return supported;
11456|       |#else
11457|       |  return true;
11458|       |#endif
11459|  28.4k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_111nibble_loadEPKh:
11291|  29.4k|ADA_PARSER_SIMD __m128i nibble_load(const uint8_t* t) noexcept {
11292|  29.4k|  return _mm_load_si128(reinterpret_cast<const __m128i*>(t));
11293|  29.4k|}
can_parse.cc:_ZZN3ada6parser12_GLOBAL__N_115scan_plain_hostEPKhmmRmRbS5_ENKUlmE_clEm:
11476|  19.6k|    auto visit = [&](size_t at) noexcept -> bool {
11477|  19.6k|      const __m128i w =
11478|  19.6k|          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + at));
11479|  19.6k|      const int up = sse2_uppercase(w);
11480|  19.6k|      const int xs = _mm_movemask_epi8(_mm_cmpeq_epi8(w, x_splat));
11481|  19.6k|      const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);
11482|  19.6k|      if (mask == 0) {
  ------------------
  |  Branch (11482:11): [True: 12.0k, False: 7.60k]
  ------------------
11483|  12.0k|        if (up != 0) {
  ------------------
  |  Branch (11483:13): [True: 870, False: 11.2k]
  ------------------
11484|    870|          has_upper = true;
11485|    870|        }
11486|  12.0k|        if (xs != 0) {
  ------------------
  |  Branch (11486:13): [True: 9.43k, False: 2.65k]
  ------------------
11487|  9.43k|          has_x = true;
11488|  9.43k|        }
11489|  12.0k|        return false;
11490|  12.0k|      }
11491|  7.60k|      const int hit = trailing_zeroes32(static_cast<uint32_t>(mask));
11492|  7.60k|      const int valid = (1 << hit) - 1;
11493|  7.60k|      if ((up & valid) != 0) {
  ------------------
  |  Branch (11493:11): [True: 828, False: 6.77k]
  ------------------
11494|    828|        has_upper = true;
11495|    828|      }
11496|  7.60k|      if ((xs & valid) != 0) {
  ------------------
  |  Branch (11496:11): [True: 1.52k, False: 6.08k]
  ------------------
11497|  1.52k|        has_x = true;
11498|  1.52k|      }
11499|  7.60k|      end = at + static_cast<size_t>(hit);
11500|  7.60k|      return true;
11501|  19.6k|    };
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_114sse2_uppercaseEDv2_x:
11378|  19.6k|ada_really_inline int sse2_uppercase(__m128i w) noexcept {
11379|  19.6k|  return _mm_movemask_epi8(_mm_and_si128(
11380|  19.6k|      _mm_cmpgt_epi8(w, _mm_set1_epi8(static_cast<char>('A' - 1))),
11381|  19.6k|      _mm_cmplt_epi8(w, _mm_set1_epi8(static_cast<char>('Z' + 1)))));
11382|  19.6k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_117ssse3_nibble_maskEDv2_xS2_S2_:
11298|  38.8k|                                          __m128i hi_tbl) noexcept {
11299|  38.8k|  const __m128i nibble = _mm_set1_epi8(0x0F);
11300|  38.8k|  const __m128i lo = _mm_and_si128(w, nibble);
11301|  38.8k|  const __m128i hi = _mm_and_si128(_mm_srli_epi16(w, 4), nibble);
11302|  38.8k|  const __m128i hit =
11303|  38.8k|      _mm_and_si128(_mm_shuffle_epi8(lo_tbl, lo), _mm_shuffle_epi8(hi_tbl, hi));
11304|  38.8k|  return _mm_movemask_epi8(_mm_cmpeq_epi8(hit, _mm_setzero_si128())) ^ 0xFFFF;
11305|  38.8k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_117trailing_zeroes32Ej:
11270|  12.3k|ada_really_inline int trailing_zeroes32(uint32_t input_num) noexcept {
11271|       |#ifdef ADA_REGULAR_VISUAL_STUDIO
11272|       |  unsigned long ret;
11273|       |  _BitScanForward(&ret, input_num);
11274|       |  return static_cast<int>(ret);
11275|       |#else
11276|  12.3k|  return __builtin_ctz(input_num);
11277|  12.3k|#endif
11278|  12.3k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_113scan_path_runEPKhRmmRb:
11702|  10.8k|                                   bool& maybe_dot_segment) noexcept {
11703|  10.8k|  const size_t run_start = i;
11704|  10.8k|#if ADA_PARSER_SSSE3
11705|  10.8k|  if (parser_use_ssse3() && (i + 16 <= len)) {
  ------------------
  |  Branch (11705:7): [True: 10.8k, False: 0]
  |  Branch (11705:29): [True: 5.10k, False: 5.72k]
  ------------------
11706|  5.10k|    const __m128i lo_tbl = nibble_load(k_path_nibbles.low);
11707|  5.10k|    const __m128i hi_tbl = nibble_load(k_path_nibbles.high);
11708|  8.32k|    for (; i + 32 <= len; i += 32) {
  ------------------
  |  Branch (11708:12): [True: 5.39k, False: 2.92k]
  ------------------
11709|  5.39k|      const __m128i w0 =
11710|  5.39k|          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));
11711|  5.39k|      const int m0 = ssse3_nibble_mask(w0, lo_tbl, hi_tbl);
11712|  5.39k|      if (m0 != 0) {
  ------------------
  |  Branch (11712:11): [True: 1.63k, False: 3.76k]
  ------------------
11713|  1.63k|        const int hit_bit = trailing_zeroes32(static_cast<uint32_t>(m0));
11714|  1.63k|        note_dots_in_window(b, i, run_start, w0, (1 << hit_bit) - 1,
11715|  1.63k|                            maybe_dot_segment);
11716|  1.63k|        i += static_cast<size_t>(hit_bit);
11717|  1.63k|        return;
11718|  1.63k|      }
11719|  3.76k|      note_dots_in_window(b, i, run_start, w0, 0xFFFF, maybe_dot_segment);
11720|  3.76k|      const __m128i w1 =
11721|  3.76k|          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i + 16));
11722|  3.76k|      const int m1 = ssse3_nibble_mask(w1, lo_tbl, hi_tbl);
11723|  3.76k|      if (m1 != 0) {
  ------------------
  |  Branch (11723:11): [True: 552, False: 3.21k]
  ------------------
11724|    552|        const int hit_bit = trailing_zeroes32(static_cast<uint32_t>(m1));
11725|    552|        note_dots_in_window(b, i + 16, run_start, w1, (1 << hit_bit) - 1,
11726|    552|                            maybe_dot_segment);
11727|    552|        i += 16 + static_cast<size_t>(hit_bit);
11728|    552|        return;
11729|    552|      }
11730|  3.21k|      note_dots_in_window(b, i + 16, run_start, w1, 0xFFFF, maybe_dot_segment);
11731|  3.21k|    }
11732|  4.22k|    for (; i + 16 <= len; i += 16) {
  ------------------
  |  Branch (11732:12): [True: 2.30k, False: 1.92k]
  ------------------
11733|  2.30k|      const __m128i w =
11734|  2.30k|          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));
11735|  2.30k|      const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);
11736|  2.30k|      if (mask != 0) {
  ------------------
  |  Branch (11736:11): [True: 1.00k, False: 1.30k]
  ------------------
11737|  1.00k|        const int hit_bit = trailing_zeroes32(static_cast<uint32_t>(mask));
11738|  1.00k|        note_dots_in_window(b, i, run_start, w, (1 << hit_bit) - 1,
11739|  1.00k|                            maybe_dot_segment);
11740|  1.00k|        i += static_cast<size_t>(hit_bit);
11741|  1.00k|        return;
11742|  1.00k|      }
11743|  1.30k|      note_dots_in_window(b, i, run_start, w, 0xFFFF, maybe_dot_segment);
11744|  1.30k|    }
11745|  1.92k|    if (i > run_start && i < len) {
  ------------------
  |  Branch (11745:9): [True: 1.92k, False: 0]
  |  Branch (11745:26): [True: 1.16k, False: 758]
  ------------------
11746|  1.16k|      const __m128i w =
11747|  1.16k|          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + len - 16));
11748|  1.16k|      const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);
11749|  1.16k|      if (mask != 0) {
  ------------------
  |  Branch (11749:11): [True: 440, False: 724]
  ------------------
11750|    440|        const size_t hit =
11751|    440|            len - 16 +
11752|    440|            static_cast<size_t>(trailing_zeroes32(static_cast<uint32_t>(mask)));
11753|    440|        if (hit >= i) {
  ------------------
  |  Branch (11753:13): [True: 440, False: 0]
  ------------------
11754|  2.38k|          for (size_t j = i; j < hit; ++j) {
  ------------------
  |  Branch (11754:30): [True: 1.94k, False: 440]
  ------------------
11755|  1.94k|            if (b[j] == '.') {
  ------------------
  |  Branch (11755:17): [True: 732, False: 1.21k]
  ------------------
11756|    732|              note_possible_dot_segment(b, j, run_start, maybe_dot_segment);
11757|    732|            }
11758|  1.94k|          }
11759|    440|          i = hit;
11760|    440|          return;
11761|    440|        }
11762|    440|      }
11763|  5.31k|      for (size_t j = i; j < len; ++j) {
  ------------------
  |  Branch (11763:26): [True: 4.58k, False: 724]
  ------------------
11764|  4.58k|        if (b[j] == '.') {
  ------------------
  |  Branch (11764:13): [True: 1.41k, False: 3.17k]
  ------------------
11765|  1.41k|          note_possible_dot_segment(b, j, run_start, maybe_dot_segment);
11766|  1.41k|        }
11767|  4.58k|      }
11768|    724|      i = len;
11769|    724|      return;
11770|  1.16k|    }
11771|  1.92k|  }
11772|       |#elif ADA_SSE2
11773|       |  for (; i + 16 <= len; i += 16) {
11774|       |    const __m128i w = _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));
11775|       |    const int mask = sse2_path_stop(w);
11776|       |    if (mask != 0) {
11777|       |      const int hit_bit = trailing_zeroes32(static_cast<uint32_t>(mask));
11778|       |      note_dots_in_window(b, i, run_start, w, (1 << hit_bit) - 1,
11779|       |                          maybe_dot_segment);
11780|       |      i += static_cast<size_t>(hit_bit);
11781|       |      return;
11782|       |    }
11783|       |    note_dots_in_window(b, i, run_start, w, 0xFFFF, maybe_dot_segment);
11784|       |  }
11785|       |#elif ADA_NEON
11786|       |  if (i + 16 <= len) {
11787|       |    const uint8x16_t lo_tbl = vld1q_u8(k_path_nibbles.low);
11788|       |    const uint8x16_t hi_tbl = vld1q_u8(k_path_nibbles.high);
11789|       |    for (; i + 32 <= len; i += 32) {
11790|       |      const uint8x16_t w0 = vld1q_u8(b + i);
11791|       |      const uint64_t bits0 = neon_table_stop(w0, lo_tbl, hi_tbl);
11792|       |      if (bits0 != 0) {
11793|       |        const size_t hit_off =
11794|       |            static_cast<size_t>(trailing_zeroes64(bits0)) >> 2;
11795|       |        const uint64_t valid =
11796|       |            (hit_off == 0) ? 0 : (uint64_t{1} << (hit_off * 4)) - 1;
11797|       |        note_dots_in_window_neon(b, i, run_start, w0, valid, maybe_dot_segment);
11798|       |        i += hit_off;
11799|       |        return;
11800|       |      }
11801|       |      note_dots_in_window_neon(b, i, run_start, w0, ~uint64_t{0},
11802|       |                               maybe_dot_segment);
11803|       |      const uint8x16_t w1 = vld1q_u8(b + i + 16);
11804|       |      const uint64_t bits1 = neon_table_stop(w1, lo_tbl, hi_tbl);
11805|       |      if (bits1 != 0) {
11806|       |        const size_t hit_off =
11807|       |            static_cast<size_t>(trailing_zeroes64(bits1)) >> 2;
11808|       |        const uint64_t valid =
11809|       |            (hit_off == 0) ? 0 : (uint64_t{1} << (hit_off * 4)) - 1;
11810|       |        note_dots_in_window_neon(b, i + 16, run_start, w1, valid,
11811|       |                                 maybe_dot_segment);
11812|       |        i += 16 + hit_off;
11813|       |        return;
11814|       |      }
11815|       |      note_dots_in_window_neon(b, i + 16, run_start, w1, ~uint64_t{0},
11816|       |                               maybe_dot_segment);
11817|       |    }
11818|       |    for (; i + 16 <= len; i += 16) {
11819|       |      const uint8x16_t w = vld1q_u8(b + i);
11820|       |      const uint64_t bits = neon_table_stop(w, lo_tbl, hi_tbl);
11821|       |      if (bits != 0) {
11822|       |        const size_t hit_off =
11823|       |            static_cast<size_t>(trailing_zeroes64(bits)) >> 2;
11824|       |        const uint64_t valid =
11825|       |            (hit_off == 0) ? 0 : (uint64_t{1} << (hit_off * 4)) - 1;
11826|       |        note_dots_in_window_neon(b, i, run_start, w, valid, maybe_dot_segment);
11827|       |        i += hit_off;
11828|       |        return;
11829|       |      }
11830|       |      note_dots_in_window_neon(b, i, run_start, w, ~uint64_t{0},
11831|       |                               maybe_dot_segment);
11832|       |    }
11833|       |    if (i > run_start && i < len) {
11834|       |      const uint8x16_t w = vld1q_u8(b + len - 16);
11835|       |      const uint64_t bits = neon_table_stop(w, lo_tbl, hi_tbl);
11836|       |      if (bits != 0) {
11837|       |        const size_t hit =
11838|       |            len - 16 + (static_cast<size_t>(trailing_zeroes64(bits)) >> 2);
11839|       |        if (hit >= i) {
11840|       |          for (size_t j = i; j < hit; ++j) {
11841|       |            if (b[j] == '.') {
11842|       |              note_possible_dot_segment(b, j, run_start, maybe_dot_segment);
11843|       |            }
11844|       |          }
11845|       |          i = hit;
11846|       |          return;
11847|       |        }
11848|       |      }
11849|       |      for (size_t j = i; j < len; ++j) {
11850|       |        if (b[j] == '.') {
11851|       |          note_possible_dot_segment(b, j, run_start, maybe_dot_segment);
11852|       |        }
11853|       |      }
11854|       |      i = len;
11855|       |      return;
11856|       |    }
11857|       |  }
11858|       |#endif
11859|  14.2k|  for (; i < len; ++i) {
  ------------------
  |  Branch (11859:10): [True: 9.76k, False: 4.47k]
  ------------------
11860|  9.76k|    const uint8_t c = b[i];
11861|  9.76k|    const uint8_t cls = k_path[c];
11862|  9.76k|    if (cls != 0) {
  ------------------
  |  Branch (11862:9): [True: 2.01k, False: 7.75k]
  ------------------
11863|  2.01k|      return;
11864|  2.01k|    }
11865|  7.75k|    if (c == '.') {
  ------------------
  |  Branch (11865:9): [True: 2.35k, False: 5.40k]
  ------------------
11866|  2.35k|      note_possible_dot_segment(b, i, run_start, maybe_dot_segment);
11867|  2.35k|    }
11868|  7.75k|  }
11869|  6.48k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_119note_dots_in_windowEPKhmmDv2_xiRb:
11659|  11.4k|                                           bool& maybe_dot_segment) noexcept {
11660|  11.4k|  if (maybe_dot_segment || valid_mask == 0) {
  ------------------
  |  Branch (11660:7): [True: 2.53k, False: 8.92k]
  |  Branch (11660:28): [True: 1.52k, False: 7.40k]
  ------------------
11661|  4.06k|    return;
11662|  4.06k|  }
11663|  7.40k|  const int dots =
11664|  7.40k|      _mm_movemask_epi8(_mm_cmpeq_epi8(w, _mm_set1_epi8('.'))) & valid_mask;
11665|  7.40k|  if (dots == 0) {
  ------------------
  |  Branch (11665:7): [True: 2.77k, False: 4.62k]
  ------------------
11666|  2.77k|    return;
11667|  2.77k|  }
11668|  4.62k|  const int slashes =
11669|  4.62k|      _mm_movemask_epi8(_mm_cmpeq_epi8(w, _mm_set1_epi8('/'))) & valid_mask;
11670|  4.62k|  if (((dots & 1) != 0 && (i == run_start || b[i - 1] == '/')) ||
  ------------------
  |  Branch (11670:8): [True: 1.92k, False: 2.70k]
  |  Branch (11670:28): [True: 662, False: 1.26k]
  |  Branch (11670:46): [True: 184, False: 1.08k]
  ------------------
11671|  3.78k|      (dots & (slashes << 1)) != 0) {
  ------------------
  |  Branch (11671:7): [True: 914, False: 2.86k]
  ------------------
11672|  1.76k|    maybe_dot_segment = true;
11673|  1.76k|  }
11674|  4.62k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_125note_possible_dot_segmentEPKhmmRb:
11646|  4.49k|    bool& maybe_dot_segment) noexcept {
11647|  4.49k|  if (pos == run_start || b[pos - 1] == '/') {
  ------------------
  |  Branch (11647:7): [True: 556, False: 3.93k]
  |  Branch (11647:27): [True: 1.64k, False: 2.29k]
  ------------------
11648|  2.19k|    maybe_dot_segment = true;
11649|  2.19k|  }
11650|  4.49k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_114scan_query_runEPKhRmm:
12012|  1.55k|                                    size_t len) noexcept {
12013|  1.55k|  ADA_SCAN_STOP_RUN(k_query_nibbles, k_query, sse2_query_stop);
  ------------------
  |  |11875|  1.55k|  do {                                                                       \
  |  |11876|  1.55k|    const size_t scan_start = i;                                             \
  |  |11877|  1.55k|    if (parser_use_ssse3() && (i + 16 <= len)) {                             \
  |  |  ------------------
  |  |  |  Branch (11877:9): [True: 1.55k, False: 0]
  |  |  |  Branch (11877:31): [True: 910, False: 648]
  |  |  ------------------
  |  |11878|    910|      const __m128i lo_tbl = nibble_load((nibbles).low);                     \
  |  |11879|    910|      const __m128i hi_tbl = nibble_load((nibbles).high);                    \
  |  |11880|  1.99k|      for (; i + 32 <= len; i += 32) {                                       \
  |  |  ------------------
  |  |  |  Branch (11880:14): [True: 1.40k, False: 592]
  |  |  ------------------
  |  |11881|  1.40k|        const __m128i w0 =                                                   \
  |  |11882|  1.40k|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));        \
  |  |11883|  1.40k|        const int m0 = ssse3_nibble_mask(w0, lo_tbl, hi_tbl);                \
  |  |11884|  1.40k|        if (m0 != 0) {                                                       \
  |  |  ------------------
  |  |  |  Branch (11884:13): [True: 204, False: 1.19k]
  |  |  ------------------
  |  |11885|    204|          i += static_cast<size_t>(                                          \
  |  |11886|    204|              trailing_zeroes32(static_cast<uint32_t>(m0)));                 \
  |  |11887|    204|          return;                                                            \
  |  |11888|    204|        }                                                                    \
  |  |11889|  1.40k|        const __m128i w1 =                                                   \
  |  |11890|  1.19k|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i + 16));   \
  |  |11891|  1.19k|        const int m1 = ssse3_nibble_mask(w1, lo_tbl, hi_tbl);                \
  |  |11892|  1.19k|        if (m1 != 0) {                                                       \
  |  |  ------------------
  |  |  |  Branch (11892:13): [True: 114, False: 1.08k]
  |  |  ------------------
  |  |11893|    114|          i += 16 + static_cast<size_t>(                                     \
  |  |11894|    114|                        trailing_zeroes32(static_cast<uint32_t>(m1)));       \
  |  |11895|    114|          return;                                                            \
  |  |11896|    114|        }                                                                    \
  |  |11897|  1.19k|      }                                                                      \
  |  |11898|    910|      for (; i + 16 <= len; i += 16) {                                       \
  |  |  ------------------
  |  |  |  Branch (11898:14): [True: 488, False: 396]
  |  |  ------------------
  |  |11899|    488|        const __m128i w =                                                    \
  |  |11900|    488|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));        \
  |  |11901|    488|        const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);               \
  |  |11902|    488|        if (mask != 0) {                                                     \
  |  |  ------------------
  |  |  |  Branch (11902:13): [True: 196, False: 292]
  |  |  ------------------
  |  |11903|    196|          i += static_cast<size_t>(                                          \
  |  |11904|    196|              trailing_zeroes32(static_cast<uint32_t>(mask)));               \
  |  |11905|    196|          return;                                                            \
  |  |11906|    196|        }                                                                    \
  |  |11907|    488|      }                                                                      \
  |  |11908|    592|      if (i > scan_start && i < len) {                                       \
  |  |  ------------------
  |  |  |  Branch (11908:11): [True: 396, False: 0]
  |  |  |  Branch (11908:29): [True: 306, False: 90]
  |  |  ------------------
  |  |11909|    306|        const __m128i w =                                                    \
  |  |11910|    306|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + len - 16)); \
  |  |11911|    306|        const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);               \
  |  |11912|    306|        if (mask != 0) {                                                     \
  |  |  ------------------
  |  |  |  Branch (11912:13): [True: 140, False: 166]
  |  |  ------------------
  |  |11913|    140|          const size_t hit = len - 16 +                                      \
  |  |11914|    140|                             static_cast<size_t>(trailing_zeroes32(          \
  |  |11915|    140|                                 static_cast<uint32_t>(mask)));              \
  |  |11916|    140|          if (hit >= i) {                                                    \
  |  |  ------------------
  |  |  |  Branch (11916:15): [True: 140, False: 0]
  |  |  ------------------
  |  |11917|    140|            i = hit;                                                         \
  |  |11918|    140|            return;                                                          \
  |  |11919|    140|          }                                                                  \
  |  |11920|    140|        }                                                                    \
  |  |11921|    306|        i = len;                                                             \
  |  |11922|    166|        return;                                                              \
  |  |11923|    306|      }                                                                      \
  |  |11924|    396|    }                                                                        \
  |  |11925|  2.21k|    for (; i < len; ++i) {                                                   \
  |  |  ------------------
  |  |  |  Branch (11925:12): [True: 1.73k, False: 476]
  |  |  ------------------
  |  |11926|  1.73k|      if ((cls)[b[i]] != 0) {                                                \
  |  |  ------------------
  |  |  |  Branch (11926:11): [True: 262, False: 1.47k]
  |  |  ------------------
  |  |11927|    262|        return;                                                              \
  |  |11928|    262|      }                                                                      \
  |  |11929|  1.73k|    }                                                                        \
  |  |11930|    738|  } while (0)
  |  |  ------------------
  |  |  |  Branch (11930:12): [Folded, False: 476]
  |  |  ------------------
  ------------------
12014|  1.55k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_113scan_hash_runEPKhRmm:
12017|  1.66k|                                   size_t len) noexcept {
12018|  1.66k|  ADA_SCAN_STOP_RUN(k_hash_nibbles, k_hash, sse2_hash_stop);
  ------------------
  |  |11875|  1.66k|  do {                                                                       \
  |  |11876|  1.66k|    const size_t scan_start = i;                                             \
  |  |11877|  1.66k|    if (parser_use_ssse3() && (i + 16 <= len)) {                             \
  |  |  ------------------
  |  |  |  Branch (11877:9): [True: 1.66k, False: 0]
  |  |  |  Branch (11877:31): [True: 970, False: 690]
  |  |  ------------------
  |  |11878|    970|      const __m128i lo_tbl = nibble_load((nibbles).low);                     \
  |  |11879|    970|      const __m128i hi_tbl = nibble_load((nibbles).high);                    \
  |  |11880|  1.85k|      for (; i + 32 <= len; i += 32) {                                       \
  |  |  ------------------
  |  |  |  Branch (11880:14): [True: 1.08k, False: 770]
  |  |  ------------------
  |  |11881|  1.08k|        const __m128i w0 =                                                   \
  |  |11882|  1.08k|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));        \
  |  |11883|  1.08k|        const int m0 = ssse3_nibble_mask(w0, lo_tbl, hi_tbl);                \
  |  |11884|  1.08k|        if (m0 != 0) {                                                       \
  |  |  ------------------
  |  |  |  Branch (11884:13): [True: 98, False: 988]
  |  |  ------------------
  |  |11885|     98|          i += static_cast<size_t>(                                          \
  |  |11886|     98|              trailing_zeroes32(static_cast<uint32_t>(m0)));                 \
  |  |11887|     98|          return;                                                            \
  |  |11888|     98|        }                                                                    \
  |  |11889|  1.08k|        const __m128i w1 =                                                   \
  |  |11890|    988|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i + 16));   \
  |  |11891|    988|        const int m1 = ssse3_nibble_mask(w1, lo_tbl, hi_tbl);                \
  |  |11892|    988|        if (m1 != 0) {                                                       \
  |  |  ------------------
  |  |  |  Branch (11892:13): [True: 102, False: 886]
  |  |  ------------------
  |  |11893|    102|          i += 16 + static_cast<size_t>(                                     \
  |  |11894|    102|                        trailing_zeroes32(static_cast<uint32_t>(m1)));       \
  |  |11895|    102|          return;                                                            \
  |  |11896|    102|        }                                                                    \
  |  |11897|    988|      }                                                                      \
  |  |11898|  1.21k|      for (; i + 16 <= len; i += 16) {                                       \
  |  |  ------------------
  |  |  |  Branch (11898:14): [True: 570, False: 642]
  |  |  ------------------
  |  |11899|    570|        const __m128i w =                                                    \
  |  |11900|    570|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));        \
  |  |11901|    570|        const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);               \
  |  |11902|    570|        if (mask != 0) {                                                     \
  |  |  ------------------
  |  |  |  Branch (11902:13): [True: 128, False: 442]
  |  |  ------------------
  |  |11903|    128|          i += static_cast<size_t>(                                          \
  |  |11904|    128|              trailing_zeroes32(static_cast<uint32_t>(mask)));               \
  |  |11905|    128|          return;                                                            \
  |  |11906|    128|        }                                                                    \
  |  |11907|    570|      }                                                                      \
  |  |11908|    770|      if (i > scan_start && i < len) {                                       \
  |  |  ------------------
  |  |  |  Branch (11908:11): [True: 642, False: 0]
  |  |  |  Branch (11908:29): [True: 494, False: 148]
  |  |  ------------------
  |  |11909|    494|        const __m128i w =                                                    \
  |  |11910|    494|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + len - 16)); \
  |  |11911|    494|        const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);               \
  |  |11912|    494|        if (mask != 0) {                                                     \
  |  |  ------------------
  |  |  |  Branch (11912:13): [True: 128, False: 366]
  |  |  ------------------
  |  |11913|    128|          const size_t hit = len - 16 +                                      \
  |  |11914|    128|                             static_cast<size_t>(trailing_zeroes32(          \
  |  |11915|    128|                                 static_cast<uint32_t>(mask)));              \
  |  |11916|    128|          if (hit >= i) {                                                    \
  |  |  ------------------
  |  |  |  Branch (11916:15): [True: 128, False: 0]
  |  |  ------------------
  |  |11917|    128|            i = hit;                                                         \
  |  |11918|    128|            return;                                                          \
  |  |11919|    128|          }                                                                  \
  |  |11920|    128|        }                                                                    \
  |  |11921|    494|        i = len;                                                             \
  |  |11922|    366|        return;                                                              \
  |  |11923|    494|      }                                                                      \
  |  |11924|    642|    }                                                                        \
  |  |11925|  3.29k|    for (; i < len; ++i) {                                                   \
  |  |  ------------------
  |  |  |  Branch (11925:12): [True: 2.57k, False: 724]
  |  |  ------------------
  |  |11926|  2.57k|      if ((cls)[b[i]] != 0) {                                                \
  |  |  ------------------
  |  |  |  Branch (11926:11): [True: 114, False: 2.45k]
  |  |  ------------------
  |  |11927|    114|        return;                                                              \
  |  |11928|    114|      }                                                                      \
  |  |11929|  2.57k|    }                                                                        \
  |  |11930|    838|  } while (0)
  |  |  ------------------
  |  |  |  Branch (11930:12): [Folded, False: 724]
  |  |  ------------------
  ------------------
12019|  1.66k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_120path_has_dot_segmentENSt3__117basic_string_viewIcNS2_11char_traitsIcEEEE:
12023|  1.80k|bool path_has_dot_segment(std::string_view path) noexcept {
12024|  1.80k|  if (path.empty()) {
  ------------------
  |  Branch (12024:7): [True: 0, False: 1.80k]
  ------------------
12025|      0|    return false;
12026|      0|  }
12027|       |  // "." / ".." at the start, with or without a leading '/'.
12028|  1.80k|  const size_t i = (path[0] == '/') ? 1 : 0;
  ------------------
  |  Branch (12028:20): [True: 1.55k, False: 252]
  ------------------
12029|  1.80k|  if (i < path.size() && path[i] == '.') {
  ------------------
  |  Branch (12029:7): [True: 1.80k, False: 0]
  |  Branch (12029:26): [True: 634, False: 1.17k]
  ------------------
12030|    634|    const size_t after = i + 1;
12031|    634|    if (after == path.size() || path[after] == '/' ||
  ------------------
  |  Branch (12031:9): [True: 70, False: 564]
  |  Branch (12031:33): [True: 124, False: 440]
  ------------------
12032|    440|        (after < path.size() && path[after] == '.' &&
  ------------------
  |  Branch (12032:10): [True: 440, False: 0]
  |  Branch (12032:33): [True: 236, False: 204]
  ------------------
12033|    328|         (after + 1 == path.size() || path[after + 1] == '/'))) {
  ------------------
  |  Branch (12033:11): [True: 38, False: 198]
  |  Branch (12033:39): [True: 96, False: 102]
  ------------------
12034|    328|      return true;
12035|    328|    }
12036|    634|  }
12037|  1.47k|  static constexpr std::string_view slash_dot{"/.", 2};
12038|  1.47k|  size_t p = i;
12039|  3.72k|  while ((p = path.find(slash_dot, p)) != std::string_view::npos) {
  ------------------
  |  Branch (12039:10): [True: 2.95k, False: 768]
  ------------------
12040|  2.95k|    const size_t after = p + 2;
12041|  2.95k|    if (after == path.size() || path[after] == '/' ||
  ------------------
  |  Branch (12041:9): [True: 174, False: 2.78k]
  |  Branch (12041:33): [True: 250, False: 2.53k]
  ------------------
12042|  2.53k|        (after < path.size() && path[after] == '.' &&
  ------------------
  |  Branch (12042:10): [True: 2.53k, False: 0]
  |  Branch (12042:33): [True: 764, False: 1.76k]
  ------------------
12043|    764|         (after + 1 == path.size() || path[after + 1] == '/'))) {
  ------------------
  |  Branch (12043:11): [True: 66, False: 698]
  |  Branch (12043:39): [True: 218, False: 480]
  ------------------
12044|    708|      return true;
12045|    708|    }
12046|  2.24k|    p = after;
12047|  2.24k|  }
12048|    768|  return false;
12049|  1.47k|}
_ZN3ada14url_aggregator11copy_schemeERKS0_:
14132|  2.09k|inline void url_aggregator::copy_scheme(const url_aggregator& u) {
14133|  2.09k|  ada_log("url_aggregator::copy_scheme ", u.buffer);
14134|  2.09k|  ADA_ASSERT_TRUE(validate());
14135|       |  // next line could overflow but unsigned arithmetic has well-defined
14136|       |  // overflows.
14137|  2.09k|  uint32_t new_difference = u.components.protocol_end - components.protocol_end;
14138|       |
14139|  2.09k|  type = u.type;
14140|  2.09k|  buffer.erase(0, components.protocol_end);
14141|  2.09k|  buffer.insert(0, u.get_protocol());
14142|  2.09k|  components.protocol_end = u.components.protocol_end;
14143|       |
14144|       |  // No need to update the components
14145|  2.09k|  if (new_difference == 0) {
  ------------------
  |  Branch (14145:7): [True: 176, False: 1.92k]
  ------------------
14146|    176|    return;
14147|    176|  }
14148|       |
14149|  1.92k|  apply_shifted_non_scheme_offsets(components, new_difference);
14150|  1.92k|  ADA_ASSERT_TRUE(validate());
14151|  1.92k|}
can_parse.cc:_ZN12_GLOBAL__N_132apply_shifted_non_scheme_offsetsERN3ada14url_componentsEj:
14010|  44.6k|    ada::url_components& components, uint32_t new_difference) {
14011|  44.6k|  components.username_end += new_difference;
14012|  44.6k|  components.host_start += new_difference;
14013|  44.6k|  components.host_end += new_difference;
14014|  44.6k|  components.pathname_start += new_difference;
14015|  44.6k|  if (components.search_start != ada::url_components::omitted) {
  ------------------
  |  Branch (14015:7): [True: 0, False: 44.6k]
  ------------------
14016|      0|    components.search_start += new_difference;
14017|      0|  }
14018|  44.6k|  if (components.hash_start != ada::url_components::omitted) {
  ------------------
  |  Branch (14018:7): [True: 0, False: 44.6k]
  ------------------
14019|      0|    components.hash_start += new_difference;
14020|      0|  }
14021|  44.6k|}
_ZN3ada14url_aggregator10parse_pathENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
14389|  2.33k|ada_really_inline void url_aggregator::parse_path(std::string_view input) {
14390|  2.33k|  ada_log("url_aggregator::parse_path ", input);
14391|  2.33k|  ADA_ASSERT_TRUE(validate());
14392|  2.33k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
14393|  2.33k|  std::string tmp_buffer;
14394|  2.33k|  std::string_view internal_input;
14395|  2.33k|  if (unicode::has_tabs_or_newline(input)) {
  ------------------
  |  Branch (14395:7): [True: 0, False: 2.33k]
  ------------------
14396|      0|    tmp_buffer = input;
14397|       |    // Optimization opportunity: Instead of copying and then pruning, we could
14398|       |    // just directly build the string from user_input.
14399|      0|    helpers::remove_ascii_tab_or_newline(tmp_buffer);
14400|      0|    internal_input = tmp_buffer;
14401|  2.33k|  } else {
14402|  2.33k|    internal_input = input;
14403|  2.33k|  }
14404|       |
14405|       |  // If url is special, then:
14406|  2.33k|  if (is_special()) {
  ------------------
  |  Branch (14406:7): [True: 2.33k, False: 0]
  ------------------
14407|  2.33k|    if (internal_input.empty()) {
  ------------------
  |  Branch (14407:9): [True: 102, False: 2.22k]
  ------------------
14408|    102|      update_base_pathname("/");
14409|  2.22k|    } else if ((internal_input[0] == '/') || (internal_input[0] == '\\')) {
  ------------------
  |  Branch (14409:16): [True: 2.22k, False: 0]
  |  Branch (14409:46): [True: 0, False: 0]
  ------------------
14410|  2.22k|      consume_prepared_path(internal_input.substr(1));
14411|  2.22k|    } else {
14412|      0|      consume_prepared_path(internal_input);
14413|      0|    }
14414|  2.33k|  } else if (!internal_input.empty()) {
  ------------------
  |  Branch (14414:14): [True: 0, False: 0]
  ------------------
14415|      0|    if (internal_input[0] == '/') {
  ------------------
  |  Branch (14415:9): [True: 0, False: 0]
  ------------------
14416|      0|      consume_prepared_path(internal_input.substr(1));
14417|      0|    } else {
14418|      0|      consume_prepared_path(internal_input);
14419|      0|    }
14420|      0|  } else {
14421|       |    // Non-special URLs with an empty host can have their paths erased
14422|       |    // Path-only URLs cannot have their paths erased
14423|      0|    if (components.host_start == components.host_end && !has_authority()) {
  ------------------
  |  Branch (14423:9): [True: 0, False: 0]
  |  Branch (14423:57): [True: 0, False: 0]
  ------------------
14424|      0|      update_base_pathname("/");
14425|      0|    }
14426|      0|  }
14427|  2.33k|  ADA_ASSERT_TRUE(validate());
14428|  2.33k|}
_ZN3ada14url_aggregator10parse_hostENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
14530|  30.6k|ada_really_inline bool url_aggregator::parse_host(std::string_view input) {
14531|  30.6k|  ada_log("url_aggregator:parse_host \"", input, "\" [", input.size(),
14532|  30.6k|          " bytes]");
14533|  30.6k|  ADA_ASSERT_TRUE(validate());
14534|  30.6k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
14535|  30.6k|  if (input.empty()) {
  ------------------
  |  Branch (14535:7): [True: 41, False: 30.6k]
  ------------------
14536|     41|    return is_valid = false;
14537|     41|  }  // technically unnecessary.
14538|       |  // If input starts with U+005B ([), then:
14539|  30.6k|  if (input[0] == '[') {
  ------------------
  |  Branch (14539:7): [True: 1.42k, False: 29.1k]
  ------------------
14540|       |    // If input does not end with U+005D (]), validation error, return failure.
14541|  1.42k|    if (input.back() != ']') {
  ------------------
  |  Branch (14541:9): [True: 318, False: 1.10k]
  ------------------
14542|    318|      return is_valid = false;
14543|    318|    }
14544|  1.10k|    ada_log("parse_host ipv6");
14545|       |
14546|       |    // Return the result of IPv6 parsing input with its leading U+005B ([) and
14547|       |    // trailing U+005D (]) removed.
14548|  1.10k|    input.remove_prefix(1);
14549|  1.10k|    input.remove_suffix(1);
14550|  1.10k|    return parse_ipv6(input);
14551|  1.42k|  }
14552|       |
14553|       |  // If isNotSpecial is true, then return the result of opaque-host parsing
14554|       |  // input.
14555|  29.1k|  if (!is_special()) {
  ------------------
  |  Branch (14555:7): [True: 1.28k, False: 27.9k]
  ------------------
14556|  1.28k|    return parse_opaque_host(input);
14557|  1.28k|  }
14558|       |  // Let domain be the result of running UTF-8 decode without BOM on the
14559|       |  // percent-decoding of input. Let asciiDomain be the result of running domain
14560|       |  // to ASCII with domain and false. The most common case is an ASCII input, in
14561|       |  // which case we do not need to call the expensive 'to_ascii' if a few
14562|       |  // conditions are met: no '%' and no 'xn-' subsequence.
14563|       |
14564|       |  // Often, the input does not contain any forbidden code points, and no upper
14565|       |  // case ASCII letter, then we can just copy it to the buffer. We want to
14566|       |  // optimize for such a common case.
14567|       |
14568|       |  // Fast path: try to parse as pure decimal IPv4 first.
14569|  27.9k|  const uint64_t fast_result = checkers::try_parse_ipv4_fast(input);
14570|  27.9k|  if (fast_result < checkers::ipv4_fast_fail) {
  ------------------
  |  Branch (14570:7): [True: 1.28k, False: 26.6k]
  ------------------
14571|  1.28k|    if (!input.empty() && input.back() == '.') {
  ------------------
  |  Branch (14571:9): [True: 1.28k, False: 0]
  |  Branch (14571:27): [True: 43, False: 1.24k]
  ------------------
14572|     43|      update_base_hostname(input.substr(0, input.size() - 1));
14573|  1.24k|    } else {
14574|  1.24k|      update_base_hostname(input);
14575|  1.24k|    }
14576|  1.28k|    host_type = IPV4;
14577|  1.28k|    is_valid = true;
14578|  1.28k|    ada_log("parse_host fast path decimal ipv4");
14579|  1.28k|    ADA_ASSERT_TRUE(validate());
14580|  1.28k|    return true;
14581|  1.28k|  }
14582|  26.6k|  uint8_t is_forbidden_or_upper =
14583|  26.6k|      unicode::contains_forbidden_domain_code_point_or_upper(input.data(),
14584|  26.6k|                                                             input.size());
14585|  26.6k|  static constexpr std::string_view xn_dash{"xn-", 3};
14586|  26.6k|  if ((is_forbidden_or_upper & 1) == 0) {
  ------------------
  |  Branch (14586:7): [True: 16.3k, False: 10.2k]
  ------------------
14587|  16.3k|    if ((is_forbidden_or_upper & 2) != 0) {
  ------------------
  |  Branch (14587:9): [True: 3.00k, False: 13.3k]
  ------------------
14588|  3.00k|      std::string lowered(input);
14589|  3.00k|      unicode::to_lower_ascii(lowered.data(), lowered.size());
14590|  3.00k|      if (lowered.find('-') == std::string_view::npos ||
  ------------------
  |  Branch (14590:11): [True: 2.61k, False: 395]
  ------------------
14591|  2.78k|          lowered.find(xn_dash) == std::string_view::npos) {
  ------------------
  |  Branch (14591:11): [True: 177, False: 218]
  ------------------
14592|       |        // Check IPv4 before mutating so failures leave the buffer untouched.
14593|       |        // This also avoids a double buffer rewrite for hex/octal IPv4.
14594|  2.78k|        if (checkers::is_ipv4(lowered)) {
  ------------------
  |  Branch (14594:13): [True: 498, False: 2.29k]
  ------------------
14595|    498|          ada_log("parse_host fast path ipv4");
14596|    498|          return parse_ipv4(lowered, false);
14597|    498|        }
14598|  2.29k|        update_base_hostname(lowered);
14599|  2.29k|        ada_log("parse_host fast path ", get_hostname());
14600|  2.29k|        is_valid = true;
14601|  2.29k|        return true;
14602|  2.78k|      }
14603|  13.3k|    } else if (input.find('-') == std::string_view::npos ||
  ------------------
  |  Branch (14603:16): [True: 9.57k, False: 3.78k]
  ------------------
14604|  10.1k|               input.find(xn_dash) == std::string_view::npos) {
  ------------------
  |  Branch (14604:16): [True: 538, False: 3.24k]
  ------------------
14605|       |      // Check IPv4 before mutating so failures leave the buffer untouched.
14606|  10.1k|      if (checkers::is_ipv4(input)) {
  ------------------
  |  Branch (14606:11): [True: 2.42k, False: 7.69k]
  ------------------
14607|  2.42k|        ada_log("parse_host fast path ipv4");
14608|  2.42k|        return parse_ipv4(input, false);
14609|  2.42k|      }
14610|  7.69k|      update_base_hostname(input);
14611|  7.69k|      ada_log("parse_host fast path ", get_hostname());
14612|  7.69k|      is_valid = true;
14613|  7.69k|      return true;
14614|  10.1k|    }
14615|  16.3k|  } else if (const size_t first_percent = input.find('%');
14616|  10.2k|             first_percent != std::string_view::npos) {
  ------------------
  |  Branch (14616:14): [True: 2.05k, False: 8.20k]
  ------------------
14617|  2.05k|    std::string decoded = unicode::percent_decode(input, first_percent);
14618|  2.05k|    const uint8_t decoded_flags =
14619|  2.05k|        unicode::contains_forbidden_domain_code_point_or_upper(decoded.data(),
14620|  2.05k|                                                               decoded.size());
14621|  2.05k|    if ((decoded_flags & 1) == 0) {
  ------------------
  |  Branch (14621:9): [True: 1.42k, False: 634]
  ------------------
14622|  1.42k|      if ((decoded_flags & 2) != 0) {
  ------------------
  |  Branch (14622:11): [True: 640, False: 784]
  ------------------
14623|    640|        unicode::to_lower_ascii(decoded.data(), decoded.size());
14624|    640|      }
14625|  1.42k|      if (decoded.find('-') == std::string_view::npos ||
  ------------------
  |  Branch (14625:11): [True: 1.22k, False: 200]
  ------------------
14626|  1.30k|          decoded.find(xn_dash) == std::string_view::npos) {
  ------------------
  |  Branch (14626:11): [True: 84, False: 116]
  ------------------
14627|       |        // Check IPv4 before mutating so failures leave the buffer untouched.
14628|  1.30k|        if (checkers::is_ipv4(decoded)) {
  ------------------
  |  Branch (14628:13): [True: 568, False: 740]
  ------------------
14629|    568|          return parse_ipv4(decoded, false);
14630|    568|        }
14631|    740|        update_base_hostname(decoded);
14632|    740|        is_valid = true;
14633|    740|        return true;
14634|  1.30k|      }
14635|  1.42k|    }
14636|  2.05k|  }
14637|       |  // We have encountered at least one forbidden code point or the input contains
14638|       |  // 'xn-' (case insensitive), so we need to call 'to_ascii' to perform the full
14639|       |  // conversion.
14640|       |
14641|  12.4k|  ada_log("parse_host calling to_ascii");
14642|  12.4k|  std::optional<std::string> host = std::string(get_hostname());
14643|  12.4k|  is_valid = ada::unicode::to_ascii(host, input, input.find('%'));
14644|  12.4k|  if (!is_valid) {
  ------------------
  |  Branch (14644:7): [True: 3.80k, False: 8.61k]
  ------------------
14645|  3.80k|    ada_log("parse_host to_ascii returns false");
14646|  3.80k|    return is_valid = false;
14647|  3.80k|  }
14648|  8.61k|  ada_log("parse_host to_ascii succeeded ", *host, " [", host->size(),
14649|  8.61k|          " bytes]");
14650|       |
14651|  8.61k|  if (std::ranges::any_of(host.value(),
  ------------------
  |  Branch (14651:7): [True: 0, False: 8.61k]
  ------------------
14652|  8.61k|                          ada::unicode::is_forbidden_domain_code_point)) {
14653|      0|    return is_valid = false;
14654|      0|  }
14655|       |
14656|       |  // If asciiDomain ends in a number, then return the result of IPv4 parsing
14657|       |  // asciiDomain.
14658|  8.61k|  if (checkers::is_ipv4(host.value())) {
  ------------------
  |  Branch (14658:7): [True: 432, False: 8.17k]
  ------------------
14659|    432|    ada_log("parse_host got ipv4 ", *host);
14660|    432|    return parse_ipv4(host.value(), false);
14661|    432|  }
14662|       |
14663|  8.17k|  update_base_hostname(host.value());
14664|  8.17k|  ADA_ASSERT_TRUE(validate());
14665|  8.17k|  return true;
14666|  8.61k|}
_ZN3ada7helpers9substringENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEm:
 8916|  1.56k|                                                       size_t pos) {
 8917|  1.56k|  ADA_ASSERT_TRUE(pos <= input.size());
 8918|       |  // The following is safer but unneeded if we have the above line:
 8919|       |  // return pos > input.size() ? std::string_view() : input.substr(pos);
 8920|  1.56k|  return input.substr(pos);
 8921|  1.56k|}
_ZN3ada14url_aggregator21consume_prepared_pathENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
15541|  10.7k|inline void url_aggregator::consume_prepared_path(std::string_view input) {
15542|  10.7k|  ada_log("url_aggregator::consume_prepared_path ", input);
15543|       |  /***
15544|       |   * This is largely duplicated code from helpers::parse_prepared_path, which is
15545|       |   * unfortunate. This particular function is nearly identical, except that it
15546|       |   * is a method on url_aggregator. The idea is that the trivial path (which is
15547|       |   * very common) merely appends to the buffer. This is the same trivial path as
15548|       |   * with helpers::parse_prepared_path, except that we have the additional check
15549|       |   * for is_at_path(). Otherwise, we grab a copy of the current path and we
15550|       |   * modify it, and then insert it back into the buffer.
15551|       |   */
15552|  10.7k|  uint8_t accumulator = checkers::path_signature(input);
15553|       |  // Let us first detect a trivial case.
15554|       |  // If it is special, we check that we have no dot, no %,  no \ and no
15555|       |  // character needing percent encoding. Otherwise, we check that we have no %,
15556|       |  // no dot, and no character needing percent encoding.
15557|  10.7k|  constexpr uint8_t need_encoding = 1;
15558|  10.7k|  constexpr uint8_t backslash_char = 2;
15559|  10.7k|  constexpr uint8_t dot_char = 4;
15560|  10.7k|  constexpr uint8_t percent_char = 8;
15561|  10.7k|  bool special = type != ada::scheme::NOT_SPECIAL;
15562|  10.7k|  bool may_need_slow_file_handling = (type == ada::scheme::type::FILE &&
  ------------------
  |  Branch (15562:39): [True: 1.66k, False: 9.07k]
  ------------------
15563|  1.66k|                                      checkers::is_windows_drive_letter(input));
  ------------------
  |  Branch (15563:39): [True: 124, False: 1.53k]
  ------------------
15564|  10.7k|  bool trivial_path =
15565|  10.7k|      (special ? (accumulator == 0)
  ------------------
  |  Branch (15565:7): [True: 4.87k, False: 5.85k]
  |  Branch (15565:8): [True: 9.18k, False: 1.55k]
  ------------------
15566|  10.7k|               : ((accumulator & (need_encoding | dot_char | percent_char)) ==
15567|  1.55k|                  0)) &&
15568|  4.87k|      (!may_need_slow_file_handling);
  ------------------
  |  Branch (15568:7): [True: 4.78k, False: 89]
  ------------------
15569|  10.7k|  if (accumulator == dot_char && !may_need_slow_file_handling) {
  ------------------
  |  Branch (15569:7): [True: 1.63k, False: 9.10k]
  |  Branch (15569:34): [True: 1.60k, False: 23]
  ------------------
15570|       |    // '4' means that we have at least one dot, but nothing that requires
15571|       |    // percent encoding or decoding. The only part that is not trivial is
15572|       |    // that we may have single dots and double dots path segments.
15573|       |    // If we have such segments, then we either have a path that begins
15574|       |    // with '.' (easy to check), or we have the sequence './'.
15575|       |    // Note: input cannot be empty, it must at least contain one character ('.')
15576|       |    // Note: we know that '\' is not present.
15577|  1.60k|    if (input[0] != '.') {
  ------------------
  |  Branch (15577:9): [True: 863, False: 746]
  ------------------
15578|    863|      size_t slashdot = 0;
15579|    863|      bool dot_is_file = true;
15580|  5.79k|      for (;;) {
15581|  5.79k|        slashdot = input.find("/.", slashdot);
15582|  5.79k|        if (slashdot == std::string_view::npos) {  // common case
  ------------------
  |  Branch (15582:13): [True: 863, False: 4.93k]
  ------------------
15583|    863|          break;
15584|  4.93k|        } else {  // uncommon
15585|       |          // only three cases matter: /./, /.. or a final /
15586|  4.93k|          slashdot += 2;
15587|  4.93k|          dot_is_file &= !(slashdot == input.size() || input[slashdot] == '.' ||
  ------------------
  |  Branch (15587:28): [True: 175, False: 4.75k]
  |  Branch (15587:56): [True: 2.84k, False: 1.91k]
  ------------------
15588|  1.91k|                           input[slashdot] == '/');
  ------------------
  |  Branch (15588:28): [True: 1.29k, False: 616]
  ------------------
15589|  4.93k|        }
15590|  5.79k|      }
15591|    863|      trivial_path = dot_is_file;
15592|    863|    }
15593|  1.60k|  }
15594|  10.7k|  if (trivial_path && is_at_path()) {
  ------------------
  |  Branch (15594:7): [True: 5.00k, False: 5.73k]
  |  Branch (15594:23): [True: 4.92k, False: 80]
  ------------------
15595|  4.92k|    ada_log("parse_path trivial");
15596|  4.92k|    buffer += '/';
15597|  4.92k|    buffer += input;
15598|  4.92k|    return;
15599|  4.92k|  }
15600|  5.81k|  std::string path = std::string(get_pathname());
15601|       |  // We are going to need to look a bit at the path, but let us see if we can
15602|       |  // ignore percent encoding *and* backslashes *and* percent characters.
15603|       |  // Except for the trivial case, this is likely to capture 99% of paths out
15604|       |  // there.
15605|  5.81k|  bool fast_path =
15606|  5.81k|      (special &&
  ------------------
  |  Branch (15606:8): [True: 4.66k, False: 1.14k]
  ------------------
15607|  4.66k|       (accumulator & (need_encoding | backslash_char | percent_char)) == 0) &&
  ------------------
  |  Branch (15607:8): [True: 1.40k, False: 3.26k]
  ------------------
15608|  1.40k|      (type != ada::scheme::type::FILE);
  ------------------
  |  Branch (15608:7): [True: 1.21k, False: 189]
  ------------------
15609|  5.81k|  if (fast_path) {
  ------------------
  |  Branch (15609:7): [True: 1.21k, False: 4.59k]
  ------------------
15610|  1.21k|    ada_log("parse_prepared_path fast");
15611|       |    // Here we don't need to worry about \ or percent encoding.
15612|       |    // We also do not have a file protocol. We might have dots, however,
15613|       |    // but dots must as appear as '.', and they cannot be encoded because
15614|       |    // the symbol '%' is not present.
15615|  1.21k|    size_t previous_location = 0;  // We start at 0.
15616|  15.6k|    do {
15617|  15.6k|      size_t new_location = input.find('/', previous_location);
15618|       |      // std::string_view path_view = input;
15619|       |      //  We process the last segment separately:
15620|  15.6k|      if (new_location == std::string_view::npos) {
  ------------------
  |  Branch (15620:11): [True: 1.21k, False: 14.4k]
  ------------------
15621|  1.21k|        std::string_view path_view = input.substr(previous_location);
15622|  1.21k|        if (path_view == "..") {  // The path ends with ..
  ------------------
  |  Branch (15622:13): [True: 130, False: 1.08k]
  ------------------
15623|       |          // e.g., if you receive ".." with an empty path, you go to "/".
15624|    130|          if (path.empty()) {
  ------------------
  |  Branch (15624:15): [True: 50, False: 80]
  ------------------
15625|     50|            path = '/';
15626|     50|            update_base_pathname(path);
15627|     50|            return;
15628|     50|          }
15629|       |          // Fast case where we have nothing to do:
15630|     80|          if (path.back() == '/') {
  ------------------
  |  Branch (15630:15): [True: 27, False: 53]
  ------------------
15631|     27|            update_base_pathname(path);
15632|     27|            return;
15633|     27|          }
15634|       |          // If you have the path "/joe/myfriend",
15635|       |          // then you delete 'myfriend'.
15636|     53|          path.resize(path.rfind('/') + 1);
15637|     53|          update_base_pathname(path);
15638|     53|          return;
15639|     80|        }
15640|  1.08k|        path += '/';
15641|  1.08k|        if (path_view != ".") {
  ------------------
  |  Branch (15641:13): [True: 840, False: 244]
  ------------------
15642|    840|          path.append(path_view);
15643|    840|        }
15644|  1.08k|        update_base_pathname(path);
15645|  1.08k|        return;
15646|  14.4k|      } else {
15647|       |        // This is a non-final segment.
15648|  14.4k|        std::string_view path_view =
15649|  14.4k|            input.substr(previous_location, new_location - previous_location);
15650|  14.4k|        previous_location = new_location + 1;
15651|  14.4k|        if (path_view == "..") {
  ------------------
  |  Branch (15651:13): [True: 3.18k, False: 11.2k]
  ------------------
15652|  3.18k|          size_t last_delimiter = path.rfind('/');
15653|  3.18k|          if (last_delimiter != std::string::npos) {
  ------------------
  |  Branch (15653:15): [True: 1.23k, False: 1.94k]
  ------------------
15654|  1.23k|            path.erase(last_delimiter);
15655|  1.23k|          }
15656|  11.2k|        } else if (path_view != ".") {
  ------------------
  |  Branch (15656:20): [True: 9.34k, False: 1.94k]
  ------------------
15657|  9.34k|          path += '/';
15658|  9.34k|          path.append(path_view);
15659|  9.34k|        }
15660|  14.4k|      }
15661|  15.6k|    } while (true);
  ------------------
  |  Branch (15661:14): [True: 14.4k, Folded]
  ------------------
15662|  4.59k|  } else {
15663|  4.59k|    ada_log("parse_path slow");
15664|       |    // we have reached the general case
15665|  4.59k|    bool needs_percent_encoding = (accumulator & 1);
15666|  32.1k|    do {
15667|  32.1k|      size_t location = (special && (accumulator & 2))
  ------------------
  |  Branch (15667:26): [True: 24.7k, False: 7.41k]
  |  Branch (15667:37): [True: 1.91k, False: 22.8k]
  ------------------
15668|  32.1k|                            ? input.find_first_of("/\\")
15669|  32.1k|                            : input.find('/');
15670|  32.1k|      std::string_view path_view = input;
15671|  32.1k|      if (location != std::string_view::npos) {
  ------------------
  |  Branch (15671:11): [True: 27.5k, False: 4.59k]
  ------------------
15672|  27.5k|        path_view.remove_suffix(path_view.size() - location);
15673|  27.5k|        input.remove_prefix(location + 1);
15674|  27.5k|      }
15675|       |      // Path encoding preserves dots and percent signs, so normalize first.
15676|  32.1k|      if (unicode::is_double_dot_path_segment(path_view)) {
  ------------------
  |  Branch (15676:11): [True: 4.45k, False: 27.7k]
  ------------------
15677|  4.45k|        helpers::shorten_path(path, type);
15678|  4.45k|        if (location == std::string_view::npos) {
  ------------------
  |  Branch (15678:13): [True: 255, False: 4.19k]
  ------------------
15679|    255|          path += '/';
15680|    255|        }
15681|  27.7k|      } else if (unicode::is_single_dot_path_segment(path_view) &&
  ------------------
  |  Branch (15681:18): [True: 1.42k, False: 26.3k]
  ------------------
15682|  1.42k|                 (location == std::string_view::npos)) {
  ------------------
  |  Branch (15682:18): [True: 122, False: 1.29k]
  ------------------
15683|    122|        path += '/';
15684|    122|      }
15685|       |      // Otherwise, if path_view is not a single-dot path segment, then:
15686|  27.6k|      else if (!unicode::is_single_dot_path_segment(path_view)) {
  ------------------
  |  Branch (15686:16): [True: 26.3k, False: 1.29k]
  ------------------
15687|       |        // If url's scheme is "file", url's path is empty, and path_view is a
15688|       |        // Windows drive letter, then replace the second code point in
15689|       |        // path_view with U+003A (:).
15690|  26.3k|        if (type == ada::scheme::type::FILE && path.empty() &&
  ------------------
  |  Branch (15690:13): [True: 2.06k, False: 24.2k]
  |  Branch (15690:48): [True: 879, False: 1.18k]
  ------------------
15691|    879|            path_view.size() == 2 &&
  ------------------
  |  Branch (15691:13): [True: 346, False: 533]
  ------------------
15692|    346|            checkers::is_windows_drive_letter(path_view)) {
  ------------------
  |  Branch (15692:13): [True: 139, False: 207]
  ------------------
15693|    139|          path += '/';
15694|    139|          path += path_view[0];
15695|    139|          path += ':';
15696|    139|          path_view.remove_prefix(2);
15697|    139|          path.append(path_view);
15698|  26.1k|        } else {
15699|       |          // Append encoded bytes directly to the pathname.
15700|  26.1k|          path += '/';
15701|  26.1k|          if (!needs_percent_encoding ||
  ------------------
  |  Branch (15701:15): [True: 12.5k, False: 13.6k]
  ------------------
15702|  13.6k|              !ada::unicode::percent_encode<true>(
  ------------------
  |  Branch (15702:15): [True: 8.57k, False: 5.06k]
  ------------------
15703|  21.1k|                  path_view, character_sets::PATH_PERCENT_ENCODE, path)) {
15704|  21.1k|            path.append(path_view);
15705|  21.1k|          }
15706|  26.1k|        }
15707|  26.3k|      }
15708|  32.1k|      if (location == std::string_view::npos) {
  ------------------
  |  Branch (15708:11): [True: 4.59k, False: 27.5k]
  ------------------
15709|  4.59k|        update_base_pathname(path);
15710|  4.59k|        return;
15711|  4.59k|      }
15712|  32.1k|    } while (true);
  ------------------
  |  Branch (15712:14): [True: 27.5k, Folded]
  ------------------
15713|  4.59k|  }
15714|  5.81k|}
_ZN3ada8checkers7is_ipv4ENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
   14|  33.9k|ada_really_inline constexpr bool is_ipv4(std::string_view view) noexcept {
   15|       |  // The string is not empty and does not contain upper case ASCII characters.
   16|  33.9k|  if (!last_label_may_be_a_number(view)) {
  ------------------
  |  Branch (16:7): [True: 24.5k, False: 9.42k]
  ------------------
   17|  24.5k|    return false;
   18|  24.5k|  }
   19|       |  // If the address ends with a dot, we need to prune it (special case).
   20|  9.42k|  if (view.ends_with('.')) {
  ------------------
  |  Branch (20:7): [True: 462, False: 8.96k]
  ------------------
   21|    462|    view.remove_suffix(1);
   22|    462|  }
   23|       |  // From the last character, find the last dot.
   24|  9.42k|  size_t last_dot = view.rfind('.');
   25|  9.42k|  if (last_dot != std::string_view::npos) {
  ------------------
  |  Branch (25:7): [True: 2.78k, False: 6.64k]
  ------------------
   26|       |    // We have at least one dot.
   27|  2.78k|    view.remove_prefix(last_dot + 1);
   28|  2.78k|  }
   29|       |  /** Optimization opportunity: we have basically identified the last number of
   30|       |     the ipv4 if we return true here. We might as well parse it and have at
   31|       |     least one number parsed when we get to parse_ipv4. */
   32|  9.42k|  if (std::ranges::all_of(view, ada::checkers::is_digit)) {
  ------------------
  |  Branch (32:7): [True: 4.48k, False: 4.94k]
  ------------------
   33|  4.48k|    return true;
   34|  4.48k|  }
   35|       |  // It could be hex (0x), but not if there is a single character.
   36|  4.94k|  if (view.size() == 1) {
  ------------------
  |  Branch (36:7): [True: 0, False: 4.94k]
  ------------------
   37|      0|    return false;
   38|      0|  }
   39|       |  // It must start with 0x.
   40|  4.94k|  if (!view.starts_with("0x")) {
  ------------------
  |  Branch (40:7): [True: 2.41k, False: 2.52k]
  ------------------
   41|  2.41k|    return false;
   42|  2.41k|  }
   43|       |  // We must allow "0x".
   44|  2.52k|  if (view.size() == 2) {
  ------------------
  |  Branch (44:7): [True: 249, False: 2.27k]
  ------------------
   45|    249|    return true;
   46|    249|  }
   47|       |  // We have 0x followed by some characters, we need to check that they are
   48|       |  // hexadecimals.
   49|  2.27k|  view.remove_prefix(2);
   50|  2.27k|  return std::ranges::all_of(view, ada::unicode::is_lowercase_hex);
   51|  2.52k|}
_ZN3ada7unicode16is_lowercase_hexEc:
 7498|  25.7k|ada_really_inline constexpr bool is_lowercase_hex(const char c) noexcept {
 7499|  25.7k|  return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f');
  ------------------
  |  Branch (7499:11): [True: 25.7k, False: 0]
  |  Branch (7499:23): [True: 12.2k, False: 13.5k]
  |  Branch (7499:37): [True: 13.5k, False: 0]
  |  Branch (7499:49): [True: 12.3k, False: 1.12k]
  ------------------
 7500|  25.7k|}
_ZN3ada3url12parse_schemeILb0EEEbNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEE:
10370|  21.4k|ada_really_inline bool url::parse_scheme(const std::string_view input) {
10371|  21.4k|  auto parsed_type = ada::scheme::get_scheme_type(input);
10372|  21.4k|  bool is_input_special = (parsed_type != ada::scheme::NOT_SPECIAL);
10373|       |  /**
10374|       |   * In the common case, we will immediately recognize a special scheme (e.g.,
10375|       |   *http, https), in which case, we can go really fast.
10376|       |   **/
10377|  21.4k|  if (is_input_special) {  // fast path!!!
  ------------------
  |  Branch (10377:7): [True: 10.2k, False: 11.1k]
  ------------------
10378|       |    if constexpr (has_state_override) {
10379|       |      // If url's scheme is not a special scheme and buffer is a special scheme,
10380|       |      // then return.
10381|       |      if (is_special() != is_input_special) {
10382|       |        return false;
10383|       |      }
10384|       |
10385|       |      // If url includes credentials or has a non-null port, and buffer is
10386|       |      // "file", then return.
10387|       |      if ((has_credentials() || port.has_value()) &&
10388|       |          parsed_type == ada::scheme::type::FILE) {
10389|       |        return false;
10390|       |      }
10391|       |
10392|       |      // If url's scheme is "file" and its host is an empty host, then return.
10393|       |      // An empty host is the empty string.
10394|       |      if (type == ada::scheme::type::FILE && host.has_value() &&
10395|       |          host->empty()) {
10396|       |        return false;
10397|       |      }
10398|       |    }
10399|       |
10400|  10.2k|    type = parsed_type;
10401|       |
10402|       |    if constexpr (has_state_override) {
10403|       |      // This is uncommon.
10404|       |      uint16_t urls_scheme_port = get_special_port();
10405|       |
10406|       |      if (urls_scheme_port) {
10407|       |        // If url's port is url's scheme's default port, then set url's port to
10408|       |        // null.
10409|       |        if (port.has_value() && *port == urls_scheme_port) {
10410|       |          port = std::nullopt;
10411|       |        }
10412|       |      }
10413|       |    }
10414|  11.1k|  } else {  // slow path
10415|  11.1k|    std::string _buffer(input);
10416|       |    // Next function is only valid if the input is ASCII and returns false
10417|       |    // otherwise, but it seems that we always have ascii content so we do not
10418|       |    // need to check the return value.
10419|       |    // bool is_ascii =
10420|  11.1k|    unicode::to_lower_ascii(_buffer.data(), _buffer.size());
10421|       |
10422|       |    if constexpr (has_state_override) {
10423|       |      // The state-override validation errors below ("return" in the WHATWG URL
10424|       |      // parser) leave the URL unchanged. The setter contract is
10425|       |      // "true on success, false if the scheme is invalid" -- the fast path
10426|       |      // above already returns false here, so the slow path must agree.
10427|       |
10428|       |      // If url's scheme is a special scheme and buffer is not a special scheme,
10429|       |      // then return. If url's scheme is not a special scheme and buffer is a
10430|       |      // special scheme, then return.
10431|       |      if (is_special() != ada::scheme::is_special(_buffer)) {
10432|       |        return false;
10433|       |      }
10434|       |
10435|       |      // If url includes credentials or has a non-null port, and buffer is
10436|       |      // "file", then return.
10437|       |      if ((has_credentials() || port.has_value()) && _buffer == "file") {
10438|       |        return false;
10439|       |      }
10440|       |
10441|       |      // If url's scheme is "file" and its host is an empty host, then return.
10442|       |      // An empty host is the empty string.
10443|       |      if (type == ada::scheme::type::FILE && host.has_value() &&
10444|       |          host->empty()) {
10445|       |        return false;
10446|       |      }
10447|       |    }
10448|       |
10449|  11.1k|    set_scheme(std::move(_buffer));
10450|       |
10451|       |    if constexpr (has_state_override) {
10452|       |      // This is uncommon.
10453|       |      uint16_t urls_scheme_port = get_special_port();
10454|       |
10455|       |      if (urls_scheme_port) {
10456|       |        // If url's port is url's scheme's default port, then set url's port to
10457|       |        // null.
10458|       |        if (port.has_value() && *port == urls_scheme_port) {
10459|       |          port = std::nullopt;
10460|       |        }
10461|       |      }
10462|       |    }
10463|  11.1k|  }
10464|       |
10465|  21.4k|  return true;
10466|  21.4k|}
_ZN3ada14url_aggregator23parse_scheme_with_colonILb0EEEbNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEE:
14028|  42.7k|    const std::string_view input_with_colon) {
14029|  42.7k|  ada_log("url_aggregator::parse_scheme_with_colon ", input_with_colon);
14030|  42.7k|  ADA_ASSERT_TRUE(validate());
14031|  42.7k|  ADA_ASSERT_TRUE(!helpers::overlaps(input_with_colon, buffer));
14032|  42.7k|  std::string_view input{input_with_colon};
14033|  42.7k|  input.remove_suffix(1);
14034|  42.7k|  auto parsed_type = ada::scheme::get_scheme_type(input);
14035|  42.7k|  const bool is_input_special = (parsed_type != ada::scheme::NOT_SPECIAL);
14036|       |  /**
14037|       |   * In the common case, we will immediately recognize a special scheme (e.g.,
14038|       |   *http, https), in which case, we can go really fast.
14039|       |   **/
14040|  42.7k|  if (is_input_special) {  // fast path!!!
  ------------------
  |  Branch (14040:7): [True: 20.3k, False: 22.3k]
  ------------------
14041|       |    if constexpr (has_state_override) {
14042|       |      // If url's scheme is not a special scheme and buffer is a special scheme,
14043|       |      // then return.
14044|       |      if (is_special() != is_input_special) {
14045|       |        return false;
14046|       |      }
14047|       |
14048|       |      // If url includes credentials or has a non-null port, and buffer is
14049|       |      // "file", then return.
14050|       |      if ((has_credentials() || components.port != url_components::omitted) &&
14051|       |          parsed_type == ada::scheme::type::FILE) {
14052|       |        return false;
14053|       |      }
14054|       |
14055|       |      // If url's scheme is "file" and its host is an empty host, then return.
14056|       |      // An empty host is the empty string.
14057|       |      if (type == ada::scheme::type::FILE &&
14058|       |          components.host_start == components.host_end) {
14059|       |        return false;
14060|       |      }
14061|       |    }
14062|       |
14063|  20.3k|    type = parsed_type;
14064|  20.3k|    set_scheme_from_view_with_colon(input_with_colon);
14065|       |
14066|       |    if constexpr (has_state_override) {
14067|       |      // This is uncommon.
14068|       |      uint16_t urls_scheme_port = get_special_port();
14069|       |
14070|       |      if (urls_scheme_port) {
14071|       |        // If url's port is url's scheme's default port, then set url's port to
14072|       |        // null.
14073|       |        if (components.port == urls_scheme_port) {
14074|       |          clear_port();
14075|       |        }
14076|       |      }
14077|       |    }
14078|  22.3k|  } else {  // slow path
14079|  22.3k|    std::string _buffer(input);
14080|       |    // Next function is only valid if the input is ASCII and returns false
14081|       |    // otherwise, but it seems that we always have ascii content so we do not
14082|       |    // need to check the return value.
14083|  22.3k|    unicode::to_lower_ascii(_buffer.data(), _buffer.size());
14084|       |
14085|       |    if constexpr (has_state_override) {
14086|       |      // The state-override validation errors below ("return" in the WHATWG URL
14087|       |      // parser) leave the URL unchanged. The setter contract is
14088|       |      // "true on success, false if the scheme is invalid" -- the fast path
14089|       |      // above already returns false here, so the slow path must agree.
14090|       |
14091|       |      // If url's scheme is a special scheme and buffer is not a special scheme,
14092|       |      // then return. If url's scheme is not a special scheme and buffer is a
14093|       |      // special scheme, then return.
14094|       |      if (is_special() != ada::scheme::is_special(_buffer)) {
14095|       |        return false;
14096|       |      }
14097|       |
14098|       |      // If url includes credentials or has a non-null port, and buffer is
14099|       |      // "file", then return.
14100|       |      if ((has_credentials() || components.port != url_components::omitted) &&
14101|       |          _buffer == "file") {
14102|       |        return false;
14103|       |      }
14104|       |
14105|       |      // If url's scheme is "file" and its host is an empty host, then return.
14106|       |      // An empty host is the empty string.
14107|       |      if (type == ada::scheme::type::FILE &&
14108|       |          components.host_start == components.host_end) {
14109|       |        return false;
14110|       |      }
14111|       |    }
14112|       |
14113|  22.3k|    set_scheme(_buffer);
14114|       |
14115|       |    if constexpr (has_state_override) {
14116|       |      // This is uncommon.
14117|       |      uint16_t urls_scheme_port = get_special_port();
14118|       |
14119|       |      if (urls_scheme_port) {
14120|       |        // If url's port is url's scheme's default port, then set url's port to
14121|       |        // null.
14122|       |        if (components.port == urls_scheme_port) {
14123|       |          clear_port();
14124|       |        }
14125|       |      }
14126|       |    }
14127|  22.3k|  }
14128|  42.7k|  ADA_ASSERT_TRUE(validate());
14129|  42.7k|  return true;
14130|  42.7k|}
_ZN3ada14url_aggregator31set_scheme_from_view_with_colonENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
14154|  20.3k|    std::string_view new_scheme_with_colon) {
14155|  20.3k|  ada_log("url_aggregator::set_scheme_from_view_with_colon ",
14156|  20.3k|          new_scheme_with_colon);
14157|  20.3k|  ADA_ASSERT_TRUE(validate());
14158|  20.3k|  ADA_ASSERT_TRUE(!new_scheme_with_colon.empty() &&
14159|  20.3k|                  new_scheme_with_colon.back() == ':');
14160|       |  // next line could overflow but unsigned arithmetic has well-defined
14161|       |  // overflows.
14162|  20.3k|  uint32_t new_difference =
14163|  20.3k|      uint32_t(new_scheme_with_colon.size()) - components.protocol_end;
14164|       |
14165|  20.3k|  if (buffer.empty()) {
  ------------------
  |  Branch (14165:7): [True: 20.3k, False: 0]
  ------------------
14166|  20.3k|    buffer.append(new_scheme_with_colon);
14167|  20.3k|  } else {
14168|      0|    buffer.erase(0, components.protocol_end);
14169|      0|    buffer.insert(0, new_scheme_with_colon);
14170|      0|  }
14171|  20.3k|  components.protocol_end += new_difference;
14172|       |
14173|  20.3k|  apply_shifted_non_scheme_offsets(components, new_difference);
14174|  20.3k|  ADA_ASSERT_TRUE(validate());
14175|  20.3k|}
_ZN3ada14url_aggregator10set_schemeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
14177|  22.3k|inline void url_aggregator::set_scheme(std::string_view new_scheme) {
14178|  22.3k|  ada_log("url_aggregator::set_scheme ", new_scheme);
14179|  22.3k|  ADA_ASSERT_TRUE(validate());
14180|  22.3k|  ADA_ASSERT_TRUE(new_scheme.empty() || new_scheme.back() != ':');
14181|       |  // next line could overflow but unsigned arithmetic has well-defined
14182|       |  // overflows.
14183|  22.3k|  uint32_t new_difference =
14184|  22.3k|      uint32_t(new_scheme.size()) - components.protocol_end + 1;
14185|       |
14186|  22.3k|  type = ada::scheme::get_scheme_type(new_scheme);
14187|  22.3k|  if (buffer.empty()) {
  ------------------
  |  Branch (14187:7): [True: 22.3k, False: 0]
  ------------------
14188|  22.3k|    buffer.append(helpers::concat(new_scheme, ":"));
14189|  22.3k|  } else {
14190|      0|    buffer.erase(0, components.protocol_end);
14191|      0|    buffer.insert(0, helpers::concat(new_scheme, ":"));
14192|      0|  }
14193|  22.3k|  components.protocol_end = uint32_t(new_scheme.size() + 1);
14194|       |
14195|  22.3k|  apply_shifted_non_scheme_offsets(components, new_difference);
14196|  22.3k|  ADA_ASSERT_TRUE(validate());
14197|  22.3k|}

_ZN3ada37url_pattern_compile_component_optionsC2ENSt3__18optionalIcEES3_:
 6341|      6|      : delimiter(new_delimiter), prefix(new_prefix) {}
_ZN3ada14character_sets6bit_atEPKhh:
 1086|   366k|ada_really_inline constexpr bool bit_at(const uint8_t a[], const uint8_t i) {
 1087|   366k|  return !!(a[i >> 3] & (1 << (i & 7)));
 1088|   366k|}
_ZN2tl10unexpectedIN3ada6errorsEEC2EOS2_:
 2688|   103k|  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:
 4174|  25.9k|      : impl_base(unexpect, std::move(e.value())),
 4175|  25.9k|        ctor_base(detail::default_constructor_tag{}) {}
_ZNR2tl10unexpectedIN3ada6errorsEE5valueEv:
 2702|  51.9k|  TL_EXPECTED_11_CONSTEXPR E& value() & { return m_val; }
_ZN2tl6detail21expected_storage_baseIN3ada3urlENS2_6errorsELb0ELb1EEC2IJS4_ETnPNSt3__19enable_ifIXsr3std16is_constructibleIS4_DpOT_EE5valueEvE4typeELPv0EEENS_10unexpect_tESB_:
 3160|  25.9k|      : m_unexpect(std::forward<Args>(args)...), m_has_val(false) {}
_ZN2tl6detail26expected_default_ctor_baseIN3ada3urlENS2_6errorsELb1EEC2ENS0_23default_constructor_tagE:
 3778|  50.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_:
 4260|  24.7k|      : expected(in_place, std::forward<U>(v)) {}
_ZN2tl8expectedIN3ada3urlENS1_6errorsEEC2IJS2_ETnPNSt3__19enable_ifIXsr3std16is_constructibleIS2_DpOT_EE5valueEvE4typeELPv0EEENS_10in_place_tESA_:
 4133|  24.7k|      : impl_base(in_place, std::forward<Args>(args)...),
 4134|  24.7k|        ctor_base(detail::default_constructor_tag{}) {}
_ZN2tl6detail21expected_storage_baseIN3ada3urlENS2_6errorsELb0ELb1EEC2IJS3_ETnPNSt3__19enable_ifIXsr3std16is_constructibleIS3_DpOT_EE5valueEvE4typeELPv0EEENS_10in_place_tESB_:
 3148|  24.7k|      : m_val(std::forward<Args>(args)...), m_has_val(true) {}
_ZN3ada3urlC2EOS0_:
 5580|  24.7k|  url(url&& u) noexcept = default;
_ZN3ada8url_baseD2Ev:
 2184|   208k|  virtual ~url_base() = default;
_ZN3ada3urlD2Ev:
 5583|  75.4k|  ~url() override = default;
_ZN2tl8expectedIN3ada14url_aggregatorENS1_6errorsEEC2IS3_TnPNSt3__19enable_ifIXsr3std16is_constructibleIS3_OT_EE5valueEvE4typeELPv0ETnPNS7_IXsr3std14is_convertibleIS9_S3_EE5valueEvE4typeELSD_0EEEONS_10unexpectedIS8_EE:
 4174|  25.9k|      : impl_base(unexpect, std::move(e.value())),
 4175|  25.9k|        ctor_base(detail::default_constructor_tag{}) {}
_ZN2tl6detail21expected_storage_baseIN3ada14url_aggregatorENS2_6errorsELb0ELb1EEC2IJS4_ETnPNSt3__19enable_ifIXsr3std16is_constructibleIS4_DpOT_EE5valueEvE4typeELPv0EEENS_10unexpect_tESB_:
 3160|  25.9k|      : m_unexpect(std::forward<Args>(args)...), m_has_val(false) {}
_ZN2tl6detail26expected_default_ctor_baseIN3ada14url_aggregatorENS2_6errorsELb1EEC2ENS0_23default_constructor_tagE:
 3778|  50.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_:
 4260|  24.7k|      : expected(in_place, std::forward<U>(v)) {}
_ZN2tl8expectedIN3ada14url_aggregatorENS1_6errorsEEC2IJS2_ETnPNSt3__19enable_ifIXsr3std16is_constructibleIS2_DpOT_EE5valueEvE4typeELPv0EEENS_10in_place_tESA_:
 4133|  24.7k|      : impl_base(in_place, std::forward<Args>(args)...),
 4134|  24.7k|        ctor_base(detail::default_constructor_tag{}) {}
_ZN2tl6detail21expected_storage_baseIN3ada14url_aggregatorENS2_6errorsELb0ELb1EEC2IJS3_ETnPNSt3__19enable_ifIXsr3std16is_constructibleIS3_DpOT_EE5valueEvE4typeELPv0EEENS_10in_place_tESB_:
 3148|  24.7k|      : m_val(std::forward<Args>(args)...), m_has_val(true) {}
_ZN3ada14url_aggregatorC2EOS0_:
 8424|  24.7k|  url_aggregator(url_aggregator&& u) noexcept = default;
_ZN3ada14url_aggregatorD2Ev:
 8427|   133k|  ~url_aggregator() override = default;
_ZN3ada6scheme15get_scheme_typeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 7425|   116k|constexpr ada::scheme::type get_scheme_type(std::string_view scheme) noexcept {
 7426|   116k|  if (scheme.empty()) {
  ------------------
  |  Branch (7426:7): [True: 0, False: 116k]
  ------------------
 7427|      0|    return ada::scheme::NOT_SPECIAL;
 7428|      0|  }
 7429|   116k|  int hash_value = (2 * scheme.size() + (unsigned)(scheme[0])) & 7;
 7430|   116k|  const std::string_view target = details::is_special_list[hash_value];
 7431|   116k|  if (scheme.size() == target.size() &&
  ------------------
  |  Branch (7431:7): [True: 93.8k, False: 22.5k]
  ------------------
 7432|  93.8k|      details::branchless_load5(scheme.data(), scheme.size()) ==
  ------------------
  |  Branch (7432:7): [True: 63.7k, False: 30.0k]
  ------------------
 7433|  93.8k|          details::scheme_keys[hash_value]) {
 7434|  63.7k|    return ada::scheme::type(hash_value);
 7435|  63.7k|  } else {
 7436|  52.6k|    return ada::scheme::NOT_SPECIAL;
 7437|  52.6k|  }
 7438|   116k|}
_ZN3ada6scheme7details16branchless_load5EPKcm:
 7366|  93.8k|inline uint64_t branchless_load5(const char* p, size_t n) {
 7367|  93.8k|  uint64_t input = (uint8_t)p[0];
 7368|  93.8k|  input |= ((uint64_t)(uint8_t)p[n > 1] << 8) & (0 - (uint64_t)(n > 1));
 7369|  93.8k|  input |= ((uint64_t)(uint8_t)p[(n > 2) * 2] << 16) & (0 - (uint64_t)(n > 2));
 7370|  93.8k|  input |= ((uint64_t)(uint8_t)p[(n > 3) * 3] << 24) & (0 - (uint64_t)(n > 3));
 7371|  93.8k|  input |= ((uint64_t)(uint8_t)p[(n > 4) * 4] << 32) & (0 - (uint64_t)(n > 4));
 7372|  93.8k|  return input;
 7373|  93.8k|}
_ZN3ada14url_aggregatorC2Ev:
 8422|   108k|  url_aggregator() = default;
_ZN3ada14url_componentsC2Ev:
 5489|   108k|  url_components() = default;
_ZN3ada14url_aggregatoraSEOS0_:
 8425|  12.6k|  url_aggregator& operator=(url_aggregator&& u) noexcept = default;
_ZN3ada8checkers19try_parse_ipv4_fastENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 1930|  49.2k|try_parse_ipv4_fast(std::string_view input) noexcept {
 1931|  49.2k|  const size_t len = input.size();
 1932|       |  // Shortest pure decimal: "0.0.0.0" (7). Longest + trailing dot: 16.
 1933|  49.2k|  if (len < 7 || len > 16) [[unlikely]] {
  ------------------
  |  Branch (1933:7): [True: 26.0k, False: 23.1k]
  |  Branch (1933:18): [True: 9.19k, False: 13.9k]
  ------------------
 1934|  35.2k|    return ipv4_fast_fail;
 1935|  35.2k|  }
 1936|  13.9k|  const char* data = input.data();
 1937|       |
 1938|       |#if defined(ADA_AVX512_IPV4)
 1939|       |  return detail::try_parse_ipv4_avx512(data, len);
 1940|       |#elif defined(ADA_HYBRID_IPV4)
 1941|       |  return detail::try_parse_ipv4_hybrid(data, len);
 1942|       |#else
 1943|  13.9k|  return detail::parse_ipv4_decimal_scalar(data, data + len);
 1944|  49.2k|#endif
 1945|  49.2k|}
_ZN3ada8checkers6detail25parse_ipv4_decimal_scalarEPKcS3_:
 1579|  13.9k|parse_ipv4_decimal_scalar(const char* p, const char* pend) noexcept {
 1580|  13.9k|  uint32_t ipv4 = 0;
 1581|  30.7k|  for (int i = 0; i < 4; ++i) {
  ------------------
  |  Branch (1581:19): [True: 27.0k, False: 3.68k]
  ------------------
 1582|  27.0k|    if (p == pend) [[unlikely]] {
  ------------------
  |  Branch (1582:9): [True: 31, False: 27.0k]
  ------------------
 1583|     31|      return ipv4_fast_fail;
 1584|     31|    }
 1585|  27.0k|    uint32_t val;
 1586|  27.0k|    char c = *p;
 1587|  27.0k|    if (c >= '0' && c <= '9') [[likely]] {
  ------------------
  |  Branch (1587:9): [True: 24.7k, False: 2.24k]
  |  Branch (1587:21): [True: 20.2k, False: 4.56k]
  ------------------
 1588|  20.2k|      val = static_cast<uint32_t>(c - '0');
 1589|  20.2k|      ++p;
 1590|  20.2k|    } else {
 1591|  6.81k|      return ipv4_fast_fail;
 1592|  6.81k|    }
 1593|  20.2k|    if (p < pend) {
  ------------------
  |  Branch (1593:9): [True: 18.3k, False: 1.88k]
  ------------------
 1594|  18.3k|      c = *p;
 1595|  18.3k|      if (c >= '0' && c <= '9') {
  ------------------
  |  Branch (1595:11): [True: 7.85k, False: 10.4k]
  |  Branch (1595:23): [True: 6.40k, False: 1.45k]
  ------------------
 1596|  6.40k|        if (val == 0) [[unlikely]] {
  ------------------
  |  Branch (1596:13): [True: 534, False: 5.86k]
  ------------------
 1597|    534|          return ipv4_fast_fail;
 1598|    534|        }
 1599|  5.86k|        val = val * 10u + static_cast<uint32_t>(c - '0');
 1600|  5.86k|        ++p;
 1601|  5.86k|        if (p < pend) {
  ------------------
  |  Branch (1601:13): [True: 5.20k, False: 664]
  ------------------
 1602|  5.20k|          c = *p;
 1603|  5.20k|          if (c >= '0' && c <= '9') {
  ------------------
  |  Branch (1603:15): [True: 3.59k, False: 1.61k]
  |  Branch (1603:27): [True: 3.42k, False: 168]
  ------------------
 1604|  3.42k|            val = val * 10u + static_cast<uint32_t>(c - '0');
 1605|  3.42k|            ++p;
 1606|  3.42k|            if (val > 255u) [[unlikely]] {
  ------------------
  |  Branch (1606:17): [True: 763, False: 2.66k]
  ------------------
 1607|    763|              return ipv4_fast_fail;
 1608|    763|            }
 1609|  3.42k|          }
 1610|  5.20k|        }
 1611|  5.86k|      }
 1612|  18.3k|    }
 1613|  18.9k|    ipv4 = (ipv4 << 8) | val;
 1614|  18.9k|    if (i < 3) {
  ------------------
  |  Branch (1614:9): [True: 15.2k, False: 3.68k]
  ------------------
 1615|  15.2k|      if (p == pend || *p != '.') [[unlikely]] {
  ------------------
  |  Branch (1615:11): [True: 387, False: 14.8k]
  |  Branch (1615:24): [True: 1.77k, False: 13.0k]
  ------------------
 1616|  2.16k|        return ipv4_fast_fail;
 1617|  2.16k|      }
 1618|  13.0k|      ++p;
 1619|  13.0k|    }
 1620|  18.9k|  }
 1621|  3.68k|  if (p != pend) {
  ------------------
  |  Branch (1621:7): [True: 650, False: 3.03k]
  ------------------
 1622|    650|    if (p == pend - 1 && *p == '.') {
  ------------------
  |  Branch (1622:9): [True: 388, False: 262]
  |  Branch (1622:26): [True: 66, False: 322]
  ------------------
 1623|     66|      return ipv4;
 1624|     66|    }
 1625|    584|    return ipv4_fast_fail;
 1626|    650|  }
 1627|  3.03k|  return ipv4;
 1628|  3.68k|}
_ZNK3ada3url15has_credentialsEv:
 7953|  22.4k|[[nodiscard]] ada_really_inline bool url::has_credentials() const noexcept {
 7954|  22.4k|  return !username.empty() || !password.empty();
  ------------------
  |  Branch (7954:10): [True: 1.92k, False: 20.5k]
  |  Branch (7954:31): [True: 253, False: 20.2k]
  ------------------
 7955|  22.4k|}
_ZNK3ada8url_base10is_specialEv:
 7913|   330k|    const noexcept {
 7914|   330k|  return type != ada::scheme::NOT_SPECIAL;
 7915|   330k|}
_ZNK2tl8expectedIN3ada3urlENS1_6errorsEEcvbEv:
 4573|  29.0k|  constexpr explicit operator bool() const noexcept { return this->m_has_val; }
_ZN2tl8expectedIN3ada3urlENS1_6errorsEEptEv:
 4542|  20.2k|  TL_EXPECTED_11_CONSTEXPR T* operator->() {
 4543|  20.2k|    TL_ASSERT(has_value());
  ------------------
  |  | 2595|  20.2k|#define TL_ASSERT(x) assert(x)
  ------------------
  |  Branch (4543:5): [True: 20.2k, False: 0]
  ------------------
 4544|  20.2k|    return valptr();
 4545|  20.2k|  }
_ZN2tl8expectedIN3ada3urlENS1_6errorsEE6valptrEv:
 3838|  20.2k|  T* valptr() { return std::addressof(this->m_val); }
_ZN2tl6detail21expected_storage_baseIN3ada3urlENS2_6errorsELb0ELb1EED2Ev:
 3170|  50.6k|  ~expected_storage_base() {
 3171|  50.6k|    if (m_has_val) {
  ------------------
  |  Branch (3171:9): [True: 24.7k, False: 25.9k]
  ------------------
 3172|  24.7k|      m_val.~T();
 3173|  24.7k|    }
 3174|  50.6k|  }
_ZNK3ada3url13get_href_sizeEv:
 8211|  25.8k|[[nodiscard]] inline size_t url::get_href_size() const noexcept {
 8212|  25.8k|  size_t size = 0;
 8213|  25.8k|  if (is_special()) {
  ------------------
  |  Branch (8213:7): [True: 17.0k, False: 8.84k]
  ------------------
 8214|  17.0k|    size += ada::scheme::details::is_special_list[type].size() + 1;
 8215|  17.0k|  } else {
 8216|  8.84k|    size += non_special_scheme.size() + 1;
 8217|  8.84k|  }
 8218|  25.8k|  if (host.has_value()) {
  ------------------
  |  Branch (8218:7): [True: 18.5k, False: 7.30k]
  ------------------
 8219|  18.5k|    size += host->size();
 8220|  18.5k|    size += 2;
 8221|  18.5k|    if (has_credentials()) {
  ------------------
  |  Branch (8221:9): [True: 1.47k, False: 17.0k]
  ------------------
 8222|  1.47k|      size += username.size();
 8223|  1.47k|      if (!password.empty()) {
  ------------------
  |  Branch (8223:11): [True: 484, False: 994]
  ------------------
 8224|    484|        size += 1 + password.size();
 8225|    484|      }
 8226|  1.47k|      size += 1;
 8227|  1.47k|    }
 8228|  18.5k|    if (port.has_value()) {
  ------------------
  |  Branch (8228:9): [True: 4.02k, False: 14.5k]
  ------------------
 8229|  4.02k|      size += 1;
 8230|  4.02k|      uint16_t p = *port;
 8231|  4.02k|      size += (p >= 10000)  ? 5
  ------------------
  |  Branch (8231:15): [True: 123, False: 3.90k]
  ------------------
 8232|  4.02k|              : (p >= 1000) ? 4
  ------------------
  |  Branch (8232:17): [True: 170, False: 3.73k]
  ------------------
 8233|  3.90k|              : (p >= 100)  ? 3
  ------------------
  |  Branch (8233:17): [True: 113, False: 3.62k]
  ------------------
 8234|  3.73k|              : (p >= 10)   ? 2
  ------------------
  |  Branch (8234:17): [True: 73, False: 3.54k]
  ------------------
 8235|  3.62k|                            : 1;
 8236|  4.02k|    }
 8237|  18.5k|  } else if (!has_opaque_path && path.starts_with("//")) {
  ------------------
  |  Branch (8237:14): [True: 2.76k, False: 4.54k]
  |  Branch (8237:34): [True: 72, False: 2.68k]
  ------------------
 8238|     72|    size += 2;
 8239|     72|  }
 8240|  25.8k|  size += path.size();
 8241|  25.8k|  if (query.has_value()) {
  ------------------
  |  Branch (8241:7): [True: 2.15k, False: 23.7k]
  ------------------
 8242|  2.15k|    size += 1 + query->size();
 8243|  2.15k|  }
 8244|  25.8k|  if (hash.has_value()) {
  ------------------
  |  Branch (8244:7): [True: 1.74k, False: 24.1k]
  ------------------
 8245|  1.74k|    size += 1 + hash->size();
 8246|  1.74k|  }
 8247|  25.8k|  return size;
 8248|  25.8k|}
_ZN3ada8checkers8is_alphaEc:
 1559|  98.8k|constexpr bool is_alpha(char x) noexcept {
 1560|  98.8k|  return (to_lower(x) >= 'a') && (to_lower(x) <= 'z');
  ------------------
  |  Branch (1560:10): [True: 89.3k, False: 9.51k]
  |  Branch (1560:34): [True: 89.0k, False: 261]
  ------------------
 1561|  98.8k|}
_ZN3ada8checkers8to_lowerEc:
 1557|   188k|constexpr char to_lower(char x) noexcept { return (x | 0x20); }
_ZNR2tl8expectedIN3ada3urlENS1_6errorsEEdeIS2_TnPNSt3__19enable_ifIXntsr3std7is_voidIT_EE5valueEvE4typeELPv0EEERS8_v:
 4555|  4.45k|  TL_EXPECTED_11_CONSTEXPR U& operator*() & {
 4556|  4.45k|    TL_ASSERT(has_value());
  ------------------
  |  | 2595|  4.45k|#define TL_ASSERT(x) assert(x)
  ------------------
  |  Branch (4556:5): [True: 4.45k, False: 0]
  ------------------
 4557|  4.45k|    return val();
 4558|  4.45k|  }
_ZN2tl8expectedIN3ada3urlENS1_6errorsEE3valIS2_TnPNSt3__19enable_ifIXntsr3std7is_voidIT_EE5valueEvE4typeELPv0EEERS8_v:
 3847|  4.45k|  TL_EXPECTED_11_CONSTEXPR U& val() {
 3848|  4.45k|    return this->m_val;
 3849|  4.45k|  }
_ZNK2tl8expectedIN3ada3urlENS1_6errorsEE9has_valueEv:
 4572|  79.7k|  constexpr bool has_value() const noexcept { return this->m_has_val; }
_ZN3ada8checkers26last_label_may_be_a_numberENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 1532|  52.4k|constexpr bool last_label_may_be_a_number(std::string_view view) noexcept {
 1533|  52.4k|  if (view.empty()) {
  ------------------
  |  Branch (1533:7): [True: 0, False: 52.4k]
  ------------------
 1534|      0|    return false;
 1535|      0|  }
 1536|  52.4k|  const char* start = view.data();
 1537|  52.4k|  const char* end = start + view.size();
 1538|  52.4k|  if (end[-1] == '.') {
  ------------------
  |  Branch (1538:7): [True: 4.97k, False: 47.5k]
  ------------------
 1539|  4.97k|    --end;
 1540|  4.97k|    if (end == start) {
  ------------------
  |  Branch (1540:9): [True: 3.36k, False: 1.60k]
  ------------------
 1541|  3.36k|      return false;
 1542|  3.36k|    }
 1543|  4.97k|  }
 1544|  49.1k|  if (!is_ipv4_number_char(end[-1])) {
  ------------------
  |  Branch (1544:7): [True: 24.1k, False: 24.9k]
  ------------------
 1545|  24.1k|    return false;
 1546|  24.1k|  }
 1547|  24.9k|  const char* label = end;
 1548|   163k|  while (label != start && is_ipv4_number_char(label[-1])) {
  ------------------
  |  Branch (1548:10): [True: 151k, False: 12.4k]
  |  Branch (1548:28): [True: 138k, False: 12.5k]
  ------------------
 1549|   138k|    --label;
 1550|   138k|  }
 1551|  24.9k|  if (label != start && label[-1] != '.') {
  ------------------
  |  Branch (1551:7): [True: 12.5k, False: 12.4k]
  |  Branch (1551:25): [True: 8.74k, False: 3.79k]
  ------------------
 1552|  8.74k|    return false;
 1553|  8.74k|  }
 1554|  16.2k|  return label != end && is_digit(*label);
  ------------------
  |  Branch (1554:10): [True: 16.2k, False: 0]
  |  Branch (1554:26): [True: 9.91k, False: 6.31k]
  ------------------
 1555|  24.9k|}
_ZN3ada8checkers19is_ipv4_number_charEc:
 1526|   200k|constexpr bool is_ipv4_number_char(char x) noexcept {
 1527|   200k|  const unsigned char c = static_cast<unsigned char>(x);
 1528|   200k|  return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') ||
  ------------------
  |  Branch (1528:11): [True: 187k, False: 12.9k]
  |  Branch (1528:23): [True: 65.3k, False: 121k]
  |  Branch (1528:37): [True: 119k, False: 15.5k]
  |  Branch (1528:49): [True: 65.9k, False: 53.3k]
  ------------------
 1529|  68.8k|         (c >= 'A' && c <= 'F') || c == 'x' || c == 'X';
  ------------------
  |  Branch (1529:11): [True: 55.1k, False: 13.7k]
  |  Branch (1529:23): [True: 681, False: 54.4k]
  |  Branch (1529:36): [True: 31.0k, False: 37.1k]
  |  Branch (1529:48): [True: 488, False: 36.6k]
  ------------------
 1530|   200k|}
_ZN3ada8checkers8is_digitEc:
 1524|  48.8k|constexpr bool is_digit(char x) noexcept { return (x >= '0') & (x <= '9'); }
_ZN3ada6scheme16get_special_portENS0_4typeE:
 7422|  10.6k|constexpr uint16_t get_special_port(ada::scheme::type type) noexcept {
 7423|  10.6k|  return details::special_ports[int(type)];
 7424|  10.6k|}
_ZN3ada3urlaSERKS0_:
 5582|    259|  url& operator=(const url& u) = default;
_ZN3ada14url_aggregatoraSERKS0_:
 8426|    259|  url_aggregator& operator=(const url_aggregator& u) = default;
_ZN3ada14url_aggregator10clear_hashEv:
 9512|    226|inline void url_aggregator::clear_hash() {
 9513|    226|  ada_log("url_aggregator::clear_hash");
 9514|    226|  ADA_ASSERT_TRUE(validate());
 9515|    226|  if (components.hash_start == url_components::omitted) {
  ------------------
  |  Branch (9515:7): [True: 210, False: 16]
  ------------------
 9516|    210|    return;
 9517|    210|  }
 9518|     16|  buffer.resize(components.hash_start);
 9519|     16|  components.hash_start = url_components::omitted;
 9520|       |
 9521|       |#if ADA_DEVELOPMENT_CHECKS
 9522|       |  ADA_ASSERT_EQUAL(get_hash(), "",
 9523|       |                   "hash should have been cleared on buffer=" + buffer +
 9524|       |                       " with " + components.to_string() + "\n" + to_diagram());
 9525|       |#endif
 9526|     16|  ADA_ASSERT_TRUE(validate());
 9527|     16|}
_ZN3ada14url_aggregator20update_base_pathnameENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9155|  18.7k|inline void url_aggregator::update_base_pathname(const std::string_view input) {
 9156|  18.7k|  ada_log("url_aggregator::update_base_pathname '", input, "' [", input.size(),
 9157|  18.7k|          " bytes] \n", to_diagram());
 9158|  18.7k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 9159|  18.7k|  ADA_ASSERT_TRUE(validate());
 9160|       |
 9161|  18.7k|  const bool begins_with_dashdash = input.starts_with("//");
 9162|  18.7k|  if (!begins_with_dashdash && has_dash_dot()) {
  ------------------
  |  Branch (9162:7): [True: 17.9k, False: 838]
  |  Branch (9162:32): [True: 6, False: 17.9k]
  ------------------
 9163|       |    // We must delete the ./
 9164|      6|    delete_dash_dot();
 9165|      6|  }
 9166|       |
 9167|  18.7k|  if (begins_with_dashdash && !has_opaque_path && !has_authority() &&
  ------------------
  |  Branch (9167:7): [True: 838, False: 17.9k]
  |  Branch (9167:31): [True: 838, False: 0]
  |  Branch (9167:51): [True: 54, False: 784]
  ------------------
 9168|     54|      !has_dash_dot()) {
  ------------------
  |  Branch (9168:7): [True: 48, False: 6]
  ------------------
 9169|       |    // If url's host is null, url does not have an opaque path, url's path's
 9170|       |    // size is greater than 1, then append U+002F (/) followed by U+002E (.) to
 9171|       |    // output.
 9172|     48|    buffer.insert(components.pathname_start, "/.");
 9173|     48|    components.pathname_start += 2;
 9174|     48|    if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9174:9): [True: 0, False: 48]
  ------------------
 9175|      0|      components.search_start += 2;
 9176|      0|    }
 9177|     48|    if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9177:9): [True: 0, False: 48]
  ------------------
 9178|      0|      components.hash_start += 2;
 9179|      0|    }
 9180|     48|  }
 9181|       |
 9182|  18.7k|  uint32_t difference = replace_and_resize(
 9183|  18.7k|      components.pathname_start,
 9184|  18.7k|      components.pathname_start + get_pathname_length(), input);
 9185|  18.7k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9185:7): [True: 0, False: 18.7k]
  ------------------
 9186|      0|    components.search_start += difference;
 9187|      0|  }
 9188|  18.7k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9188:7): [True: 0, False: 18.7k]
  ------------------
 9189|      0|    components.hash_start += difference;
 9190|      0|  }
 9191|  18.7k|  ADA_ASSERT_TRUE(validate());
 9192|  18.7k|}
_ZN3ada14url_aggregator18replace_and_resizeEjjNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8997|  52.8k|    uint32_t start, uint32_t end, std::string_view input) {
 8998|  52.8k|  uint32_t current_length = end - start;
 8999|  52.8k|  uint32_t input_size = uint32_t(input.size());
 9000|  52.8k|  uint32_t new_difference = input_size - current_length;
 9001|       |
 9002|  52.8k|  if (current_length == 0) {
  ------------------
  |  Branch (9002:7): [True: 50.8k, False: 2.02k]
  ------------------
 9003|  50.8k|    buffer.insert(start, input);
 9004|  50.8k|  } else if (input_size == current_length) {
  ------------------
  |  Branch (9004:14): [True: 423, False: 1.60k]
  ------------------
 9005|    423|    if (input_size != 0) {
  ------------------
  |  Branch (9005:9): [True: 423, False: 0]
  ------------------
 9006|    423|      std::memmove(buffer.data() + start, input.data(), input_size);
 9007|    423|    }
 9008|  1.60k|  } else if (input_size < current_length) {
  ------------------
  |  Branch (9008:14): [True: 739, False: 865]
  ------------------
 9009|    739|    buffer.erase(start, current_length - input_size);
 9010|    739|    buffer.replace(start, input_size, input);
 9011|    865|  } else {
 9012|    865|    buffer.replace(start, current_length, input.substr(0, current_length));
 9013|    865|    buffer.insert(start + current_length, input.substr(current_length));
 9014|    865|  }
 9015|       |
 9016|  52.8k|  return new_difference;
 9017|  52.8k|}
_ZNK3ada14url_aggregator19get_pathname_lengthEv:
 9048|  18.7k|url_aggregator::get_pathname_length() const noexcept {
 9049|  18.7k|  ada_log("url_aggregator::get_pathname_length");
 9050|  18.7k|  uint32_t ending_index = uint32_t(buffer.size());
 9051|  18.7k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9051:7): [True: 0, False: 18.7k]
  ------------------
 9052|      0|    ending_index = components.search_start;
 9053|  18.7k|  } else if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9053:14): [True: 0, False: 18.7k]
  ------------------
 9054|      0|    ending_index = components.hash_start;
 9055|      0|  }
 9056|  18.7k|  return ending_index - components.pathname_start;
 9057|  18.7k|}
_ZNK3ada14url_aggregator12get_pathnameEv:
 9990|  10.0k|    ada_lifetime_bound {
 9991|  10.0k|  ada_log("url_aggregator::get_pathname pathname_start = ",
 9992|  10.0k|          components.pathname_start, " buffer.size() = ", buffer.size(),
 9993|  10.0k|          " components.search_start = ", components.search_start,
 9994|  10.0k|          " components.hash_start = ", components.hash_start);
 9995|  10.0k|  auto ending_index = uint32_t(buffer.size());
 9996|  10.0k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9996:7): [True: 190, False: 9.83k]
  ------------------
 9997|    190|    ending_index = components.search_start;
 9998|  9.83k|  } else if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9998:14): [True: 67, False: 9.77k]
  ------------------
 9999|     67|    ending_index = components.hash_start;
10000|     67|  }
10001|  10.0k|  return helpers::substring(buffer, components.pathname_start, ending_index);
10002|  10.0k|}
_ZN3ada14url_aggregator26update_unencoded_base_hashENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8973|  1.33k|inline void url_aggregator::update_unencoded_base_hash(std::string_view input) {
 8974|  1.33k|  ada_log("url_aggregator::update_unencoded_base_hash ", input, " [",
 8975|  1.33k|          input.size(), " bytes], buffer is '", buffer, "' [", buffer.size(),
 8976|  1.33k|          " bytes] components.hash_start = ", components.hash_start);
 8977|  1.33k|  ADA_ASSERT_TRUE(validate());
 8978|  1.33k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 8979|  1.33k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8979:7): [True: 17, False: 1.31k]
  ------------------
 8980|     17|    buffer.resize(components.hash_start);
 8981|     17|  }
 8982|  1.33k|  components.hash_start = uint32_t(buffer.size());
 8983|  1.33k|  buffer += "#";
 8984|  1.33k|  bool encoding_required = unicode::percent_encode<true>(
 8985|  1.33k|      input, ada::character_sets::FRAGMENT_PERCENT_ENCODE, buffer);
 8986|       |  // When encoding_required is false, then buffer is left unchanged, and percent
 8987|       |  // encoding was not deemed required.
 8988|  1.33k|  if (!encoding_required) {
  ------------------
  |  Branch (8988:7): [True: 808, False: 528]
  ------------------
 8989|    808|    buffer.append(input);
 8990|    808|  }
 8991|  1.33k|  ada_log("url_aggregator::update_unencoded_base_hash final buffer is '",
 8992|  1.33k|          buffer, "' [", buffer.size(), " bytes]");
 8993|  1.33k|  ADA_ASSERT_TRUE(validate());
 8994|  1.33k|}
_ZN3ada3urlC2Ev:
 5578|  50.6k|  url() = default;
_ZN3ada3url11copy_schemeERKS0_:
 8119|    920|constexpr void url::copy_scheme(const ada::url& u) {
 8120|    920|  non_special_scheme = u.non_special_scheme;
 8121|    920|  type = u.type;
 8122|    920|}
_ZN3ada3url26update_unencoded_base_hashENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8061|  1.20k|inline void url::update_unencoded_base_hash(std::string_view input) {
 8062|       |  // We do the percent encoding
 8063|  1.20k|  hash = unicode::percent_encode(input,
 8064|  1.20k|                                 ada::character_sets::FRAGMENT_PERCENT_ENCODE);
 8065|  1.20k|}
_ZN3ada3url12clear_searchEv:
 8094|    674|constexpr void url::clear_search() { query = std::nullopt; }
_ZN3ada3url18update_base_searchENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKh:
 8068|  1.42k|                                    const uint8_t query_percent_encode_set[]) {
 8069|  1.42k|  query = ada::unicode::percent_encode(input, query_percent_encode_set);
 8070|  1.42k|}
_ZN3ada3url20update_base_hostnameENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8059|    126|inline void url::update_base_hostname(std::string_view input) { host = input; }
_ZN3ada3url20update_base_pathnameENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8076|  9.66k|inline void url::update_base_pathname(const std::string_view input) {
 8077|  9.66k|  path = input;
 8078|  9.66k|}
_ZN3ada3url10parse_portENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEb:
 8251|  2.34k|                                         bool check_trailing_content) noexcept {
 8252|  2.34k|  ada_log("parse_port('", view, "') ", view.size());
 8253|  2.34k|  if (!view.empty() && view[0] == '-') {
  ------------------
  |  Branch (8253:7): [True: 1.66k, False: 682]
  |  Branch (8253:24): [True: 4, False: 1.65k]
  ------------------
 8254|      4|    ada_log("parse_port: view[0] == '0' && view.size() > 1");
 8255|      4|    is_valid = false;
 8256|      4|    return 0;
 8257|      4|  }
 8258|  2.34k|  uint16_t parsed_port{};
 8259|  2.34k|  auto r = std::from_chars(view.data(), view.data() + view.size(), parsed_port);
 8260|  2.34k|  if (r.ec == std::errc::result_out_of_range) {
  ------------------
  |  Branch (8260:7): [True: 36, False: 2.30k]
  ------------------
 8261|     36|    ada_log("parse_port: r.ec == std::errc::result_out_of_range");
 8262|     36|    is_valid = false;
 8263|     36|    return 0;
 8264|     36|  }
 8265|  2.30k|  ada_log("parse_port: ", parsed_port);
 8266|  2.30k|  const auto consumed = size_t(r.ptr - view.data());
 8267|  2.30k|  ada_log("parse_port: consumed ", consumed);
 8268|  2.30k|  if (check_trailing_content) {
  ------------------
  |  Branch (8268:7): [True: 2.30k, False: 0]
  ------------------
 8269|  2.30k|    is_valid &=
 8270|  2.30k|        (consumed == view.size() || view[consumed] == '/' ||
  ------------------
  |  Branch (8270:10): [True: 1.32k, False: 983]
  |  Branch (8270:37): [True: 755, False: 228]
  ------------------
 8271|    228|         view[consumed] == '?' || (is_special() && view[consumed] == '\\'));
  ------------------
  |  Branch (8271:10): [True: 135, False: 93]
  |  Branch (8271:36): [True: 89, False: 4]
  |  Branch (8271:52): [True: 1, False: 88]
  ------------------
 8272|  2.30k|  }
 8273|  2.30k|  ada_log("parse_port: is_valid = ", is_valid);
 8274|  2.30k|  if (is_valid) {
  ------------------
  |  Branch (8274:7): [True: 2.21k, False: 92]
  ------------------
 8275|       |    // scheme_default_port can return 0, and we should allow 0 as a base port.
 8276|  2.21k|    auto default_port = scheme_default_port();
 8277|  2.21k|    bool is_port_valid = (default_port == 0 && parsed_port == 0) ||
  ------------------
  |  Branch (8277:27): [True: 70, False: 2.14k]
  |  Branch (8277:48): [True: 27, False: 43]
  ------------------
 8278|  2.18k|                         (default_port != parsed_port);
  ------------------
  |  Branch (8278:26): [True: 2.17k, False: 7]
  ------------------
 8279|  2.21k|    port = (r.ec == std::errc() && is_port_valid) ? std::optional(parsed_port)
  ------------------
  |  Branch (8279:13): [True: 1.40k, False: 804]
  |  Branch (8279:36): [True: 1.40k, False: 7]
  ------------------
 8280|  2.21k|                                                  : std::nullopt;
 8281|  2.21k|  }
 8282|  2.30k|  return consumed;
 8283|  2.34k|}
_ZNK3ada8url_base19scheme_default_portEv:
 7922|  6.81k|url_base::scheme_default_port() const noexcept {
 7923|  6.81k|  return scheme::get_special_port(type);
 7924|  6.81k|}
_ZNK3ada3url12get_pathnameEv:
 7979|    163|[[nodiscard]] constexpr std::string_view url::get_pathname() const noexcept {
 7980|    163|  return path;
 7981|    163|}
_ZN3ada8checkers23is_windows_drive_letterENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 1563|  10.9k|constexpr bool is_windows_drive_letter(std::string_view input) noexcept {
 1564|  10.9k|  return input.size() >= 2 &&
  ------------------
  |  Branch (1564:10): [True: 7.39k, False: 3.60k]
  ------------------
 1565|  7.39k|         (is_alpha(input[0]) && ((input[1] == ':') || (input[1] == '|'))) &&
  ------------------
  |  Branch (1565:11): [True: 2.60k, False: 4.79k]
  |  Branch (1565:34): [True: 531, False: 2.06k]
  |  Branch (1565:55): [True: 254, False: 1.81k]
  ------------------
 1566|    785|         ((input.size() == 2) || (input[2] == '/' || input[2] == '\\' ||
  ------------------
  |  Branch (1566:11): [True: 486, False: 299]
  |  Branch (1566:35): [True: 117, False: 182]
  |  Branch (1566:54): [True: 24, False: 158]
  ------------------
 1567|    158|                                  input[2] == '?' || input[2] == '#'));
  ------------------
  |  Branch (1567:35): [True: 5, False: 153]
  |  Branch (1567:54): [True: 0, False: 153]
  ------------------
 1568|  10.9k|}
_ZN3ada8checkers34is_normalized_windows_drive_letterENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 1571|  1.72k|    std::string_view input) noexcept {
 1572|  1.72k|  return input.size() == 2 && (is_alpha(input[0]) && (input[1] == ':'));
  ------------------
  |  Branch (1572:10): [True: 978, False: 744]
  |  Branch (1572:32): [True: 826, False: 152]
  |  Branch (1572:54): [True: 748, False: 78]
  ------------------
 1573|  1.72k|}
_ZN3ada3url20set_protocol_as_fileEv:
 8104|  2.95k|constexpr void url::set_protocol_as_file() { type = ada::scheme::type::FILE; }
_ZN3ada3url14clear_pathnameEv:
 8092|     20|constexpr void url::clear_pathname() { path.clear(); }
_ZN3ada7helpers14leading_zeroesEj:
 2473|  45.1k|inline int leading_zeroes(uint32_t input_num) noexcept {
 2474|       |#if ADA_REGULAR_VISUAL_STUDIO
 2475|       |  unsigned long leading_zero(0);
 2476|       |  unsigned long in(input_num);
 2477|       |  return _BitScanReverse(&leading_zero, in) ? int(31 - leading_zero) : 32;
 2478|       |#else
 2479|  45.1k|  return __builtin_clz(input_num);
 2480|  45.1k|#endif  // ADA_REGULAR_VISUAL_STUDIO
 2481|  45.1k|}
_ZN3ada14url_aggregator7reserveEj:
 9663|  45.1k|constexpr void ada::url_aggregator::reserve(uint32_t capacity) {
 9664|  45.1k|  buffer.reserve(capacity);
 9665|  45.1k|}
_ZN3ada14url_aggregator18update_base_searchENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9064|    168|inline void url_aggregator::update_base_search(std::string_view input) {
 9065|    168|  ada_log("url_aggregator::update_base_search ", input);
 9066|    168|  ADA_ASSERT_TRUE(validate());
 9067|    168|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 9068|    168|  if (input.empty()) {
  ------------------
  |  Branch (9068:7): [True: 0, False: 168]
  ------------------
 9069|      0|    clear_search();
 9070|      0|    return;
 9071|      0|  }
 9072|       |
 9073|    168|  if (input[0] == '?') {
  ------------------
  |  Branch (9073:7): [True: 168, False: 0]
  ------------------
 9074|    168|    input.remove_prefix(1);
 9075|    168|  }
 9076|       |
 9077|    168|  if (components.hash_start == url_components::omitted) {
  ------------------
  |  Branch (9077:7): [True: 168, False: 0]
  ------------------
 9078|    168|    if (components.search_start == url_components::omitted) {
  ------------------
  |  Branch (9078:9): [True: 168, False: 0]
  ------------------
 9079|    168|      components.search_start = uint32_t(buffer.size());
 9080|    168|      buffer += "?";
 9081|    168|    } else {
 9082|      0|      buffer.resize(components.search_start + 1);
 9083|      0|    }
 9084|       |
 9085|    168|    buffer.append(input);
 9086|    168|  } else if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9086:14): [True: 0, False: 0]
  ------------------
 9087|      0|    const uint32_t difference = replace_and_resize(
 9088|      0|        components.search_start + 1, components.hash_start, input);
 9089|      0|    components.hash_start += difference;
 9090|      0|  } else {
 9091|      0|    components.search_start = components.hash_start;
 9092|      0|    buffer.insert(components.search_start, input.size() + 1, '?');
 9093|      0|    if (!input.empty()) {
  ------------------
  |  Branch (9093:9): [True: 0, False: 0]
  ------------------
 9094|      0|      std::memmove(buffer.data() + components.search_start + 1, input.data(),
 9095|      0|                   input.size());
 9096|      0|    }
 9097|      0|    components.hash_start += uint32_t(input.size() + 1);  // Do not forget `?`
 9098|      0|  }
 9099|       |
 9100|    168|  ADA_ASSERT_TRUE(validate());
 9101|    168|}
_ZN3ada14url_aggregator20append_base_passwordENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9381|  7.83k|inline void url_aggregator::append_base_password(const std::string_view input) {
 9382|  7.83k|  ada_log("url_aggregator::append_base_password ", input, " ", to_string(),
 9383|  7.83k|          "\n", to_diagram());
 9384|  7.83k|  ADA_ASSERT_TRUE(validate());
 9385|  7.83k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 9386|       |#if ADA_DEVELOPMENT_CHECKS
 9387|       |  // computing the expected password.
 9388|       |  std::string password_expected = std::string(get_password());
 9389|       |  password_expected.append(input);
 9390|       |#endif  // ADA_DEVELOPMENT_CHECKS
 9391|  7.83k|  add_authority_slashes_if_needed();
 9392|       |
 9393|       |  // If input is empty, do nothing.
 9394|  7.83k|  if (input.empty()) {
  ------------------
  |  Branch (9394:7): [True: 2.13k, False: 5.70k]
  ------------------
 9395|  2.13k|    return;
 9396|  2.13k|  }
 9397|       |
 9398|  5.70k|  uint32_t difference = uint32_t(input.size());
 9399|  5.70k|  if (has_password()) {
  ------------------
  |  Branch (9399:7): [True: 5.09k, False: 616]
  ------------------
 9400|  5.09k|    buffer.insert(components.host_start, input);
 9401|  5.09k|  } else {
 9402|    616|    difference++;  // Increment for ":"
 9403|    616|    buffer.insert(components.username_end, ":");
 9404|    616|    buffer.insert(components.username_end + 1, input);
 9405|    616|  }
 9406|  5.70k|  components.host_start += difference;
 9407|       |
 9408|       |  // The following line is required to add "@" to hostname. When updating
 9409|       |  // password if hostname does not start with "@", it is "append_base_password"s
 9410|       |  // responsibility to set it.
 9411|  5.70k|  if (buffer[components.host_start] != '@') {
  ------------------
  |  Branch (9411:7): [True: 419, False: 5.28k]
  ------------------
 9412|    419|    buffer.insert(components.host_start, "@");
 9413|    419|    difference++;
 9414|    419|  }
 9415|       |
 9416|  5.70k|  components.host_end += difference;
 9417|  5.70k|  components.pathname_start += difference;
 9418|  5.70k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9418:7): [True: 0, False: 5.70k]
  ------------------
 9419|      0|    components.search_start += difference;
 9420|      0|  }
 9421|  5.70k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9421:7): [True: 0, False: 5.70k]
  ------------------
 9422|      0|    components.hash_start += difference;
 9423|      0|  }
 9424|       |#if ADA_DEVELOPMENT_CHECKS
 9425|       |  std::string password_after(get_password());
 9426|       |  ADA_ASSERT_EQUAL(
 9427|       |      password_expected, password_after,
 9428|       |      "append_base_password problem after inserting " + std::string(input));
 9429|       |#endif  // ADA_DEVELOPMENT_CHECKS
 9430|  5.70k|  ADA_ASSERT_TRUE(validate());
 9431|  5.70k|}
_ZN3ada14url_aggregator31add_authority_slashes_if_neededEv:
 9637|  53.1k|inline void ada::url_aggregator::add_authority_slashes_if_needed() {
 9638|  53.1k|  ada_log("url_aggregator::add_authority_slashes_if_needed");
 9639|  53.1k|  ADA_ASSERT_TRUE(validate());
 9640|       |  // Protocol setter will insert `http:` to the URL. It is up to hostname setter
 9641|       |  // to insert
 9642|       |  // `//` initially to the buffer, since it depends on the hostname existence.
 9643|  53.1k|  if (has_authority()) {
  ------------------
  |  Branch (9643:7): [True: 24.4k, False: 28.6k]
  ------------------
 9644|  24.4k|    return;
 9645|  24.4k|  }
 9646|       |  // Performance: the common case is components.protocol_end == buffer.size()
 9647|       |  // Optimization opportunity: in many cases, the "//" is part of the input and
 9648|       |  // the insert could be fused with another insert.
 9649|  28.6k|  buffer.insert(components.protocol_end, "//");
 9650|  28.6k|  components.username_end += 2;
 9651|  28.6k|  components.host_start += 2;
 9652|  28.6k|  components.host_end += 2;
 9653|  28.6k|  components.pathname_start += 2;
 9654|  28.6k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9654:7): [True: 0, False: 28.6k]
  ------------------
 9655|      0|    components.search_start += 2;
 9656|      0|  }
 9657|  28.6k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9657:7): [True: 0, False: 28.6k]
  ------------------
 9658|      0|    components.hash_start += 2;
 9659|      0|  }
 9660|  28.6k|  ADA_ASSERT_TRUE(validate());
 9661|  28.6k|}
_ZN3ada14url_aggregator20append_base_usernameENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9265|  11.1k|inline void url_aggregator::append_base_username(const std::string_view input) {
 9266|  11.1k|  ada_log("url_aggregator::append_base_username ", input);
 9267|  11.1k|  ADA_ASSERT_TRUE(validate());
 9268|  11.1k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 9269|       |#if ADA_DEVELOPMENT_CHECKS
 9270|       |  // computing the expected password.
 9271|       |  std::string username_expected(get_username());
 9272|       |  username_expected.append(input);
 9273|       |#endif  // ADA_DEVELOPMENT_CHECKS
 9274|  11.1k|  add_authority_slashes_if_needed();
 9275|       |
 9276|       |  // If input is empty, do nothing.
 9277|  11.1k|  if (input.empty()) {
  ------------------
  |  Branch (9277:7): [True: 3.14k, False: 8.01k]
  ------------------
 9278|  3.14k|    return;
 9279|  3.14k|  }
 9280|       |
 9281|  8.01k|  uint32_t difference = uint32_t(input.size());
 9282|  8.01k|  buffer.insert(components.username_end, input);
 9283|  8.01k|  components.username_end += difference;
 9284|  8.01k|  components.host_start += difference;
 9285|       |
 9286|  8.01k|  if (buffer[components.host_start] != '@' &&
  ------------------
  |  Branch (9286:7): [True: 1.16k, False: 6.84k]
  ------------------
 9287|  1.16k|      components.host_start != components.host_end) {
  ------------------
  |  Branch (9287:7): [True: 1.16k, False: 0]
  ------------------
 9288|  1.16k|    buffer.insert(components.host_start, "@");
 9289|  1.16k|    difference++;
 9290|  1.16k|  }
 9291|       |
 9292|  8.01k|  components.host_end += difference;
 9293|  8.01k|  components.pathname_start += difference;
 9294|  8.01k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9294:7): [True: 0, False: 8.01k]
  ------------------
 9295|      0|    components.search_start += difference;
 9296|      0|  }
 9297|  8.01k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9297:7): [True: 0, False: 8.01k]
  ------------------
 9298|      0|    components.hash_start += difference;
 9299|      0|  }
 9300|       |#if ADA_DEVELOPMENT_CHECKS
 9301|       |  std::string username_after(get_username());
 9302|       |  ADA_ASSERT_EQUAL(
 9303|       |      username_expected, username_after,
 9304|       |      "append_base_username problem after inserting " + std::string(input));
 9305|       |#endif  // ADA_DEVELOPMENT_CHECKS
 9306|  8.01k|  ADA_ASSERT_TRUE(validate());
 9307|  8.01k|}
_ZN3ada14url_aggregator21update_base_authorityENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEERKNS_14url_componentsE:
 8915|  1.96k|    std::string_view base_buffer, const ada::url_components& base) {
 8916|  1.96k|  std::string_view input = base_buffer.substr(
 8917|  1.96k|      base.protocol_end, base.host_start - base.protocol_end);
 8918|  1.96k|  ada_log("url_aggregator::update_base_authority ", input);
 8919|       |
 8920|  1.96k|  bool input_starts_with_dash = input.starts_with("//");
 8921|  1.96k|  uint32_t diff = components.host_start - components.protocol_end;
 8922|       |
 8923|  1.96k|  buffer.erase(components.protocol_end,
 8924|  1.96k|               components.host_start - components.protocol_end);
 8925|  1.96k|  components.username_end = components.protocol_end;
 8926|       |
 8927|  1.96k|  if (input_starts_with_dash) {
  ------------------
  |  Branch (8927:7): [True: 1.67k, False: 298]
  ------------------
 8928|  1.67k|    input.remove_prefix(2);
 8929|  1.67k|    diff += 2;  // add "//"
 8930|  1.67k|    buffer.insert(components.protocol_end, "//");
 8931|  1.67k|    components.username_end += 2;
 8932|  1.67k|  }
 8933|       |
 8934|  1.96k|  size_t password_delimiter = input.find(':');
 8935|       |
 8936|       |  // Check if input contains both username and password by checking the
 8937|       |  // delimiter: ":" A typical input that contains authority would be "user:pass"
 8938|  1.96k|  if (password_delimiter != std::string_view::npos) {
  ------------------
  |  Branch (8938:7): [True: 30, False: 1.93k]
  ------------------
 8939|       |    // Insert both username and password
 8940|     30|    std::string_view username = input.substr(0, password_delimiter);
 8941|     30|    std::string_view password = input.substr(password_delimiter + 1);
 8942|       |
 8943|     30|    buffer.insert(components.protocol_end + diff, username);
 8944|     30|    diff += uint32_t(username.size());
 8945|     30|    buffer.insert(components.protocol_end + diff, ":");
 8946|     30|    components.username_end = components.protocol_end + diff;
 8947|     30|    buffer.insert(components.protocol_end + diff + 1, password);
 8948|     30|    diff += uint32_t(password.size()) + 1;
 8949|  1.93k|  } else if (!input.empty()) {
  ------------------
  |  Branch (8949:14): [True: 31, False: 1.90k]
  ------------------
 8950|       |    // Insert only username
 8951|     31|    buffer.insert(components.protocol_end + diff, input);
 8952|     31|    components.username_end =
 8953|     31|        components.protocol_end + diff + uint32_t(input.size());
 8954|     31|    diff += uint32_t(input.size());
 8955|     31|  }
 8956|       |
 8957|  1.96k|  components.host_start += diff;
 8958|       |
 8959|  1.96k|  if (buffer.size() > base.host_start && buffer[base.host_start] != '@') {
  ------------------
  |  Branch (8959:7): [True: 0, False: 1.96k]
  |  Branch (8959:42): [True: 0, False: 0]
  ------------------
 8960|      0|    buffer.insert(components.host_start, "@");
 8961|      0|    diff++;
 8962|      0|  }
 8963|  1.96k|  components.host_end += diff;
 8964|  1.96k|  components.pathname_start += diff;
 8965|  1.96k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8965:7): [True: 0, False: 1.96k]
  ------------------
 8966|      0|    components.search_start += diff;
 8967|      0|  }
 8968|  1.96k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8968:7): [True: 0, False: 1.96k]
  ------------------
 8969|      0|    components.hash_start += diff;
 8970|      0|  }
 8971|  1.96k|}
_ZNK3ada14url_aggregator8get_hrefEv:
 9741|  30.5k|    const noexcept ada_lifetime_bound {
 9742|  30.5k|  ada_log("url_aggregator::get_href");
 9743|  30.5k|  return buffer;
 9744|  30.5k|}
_ZNK3ada14url_aggregator14get_componentsEv:
 9623|  1.96k|url_aggregator::get_components() const noexcept {
 9624|  1.96k|  return components;
 9625|  1.96k|}
_ZN3ada14url_aggregator24update_host_to_base_hostENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
10009|  2.53k|void url_aggregator::update_host_to_base_host(const std::string_view input) {
10010|  2.53k|  ada_log("url_aggregator::update_host_to_base_host ", input);
10011|  2.53k|  ADA_ASSERT_TRUE(validate());
10012|  2.53k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
10013|  2.53k|  if (type != ada::scheme::type::FILE) {
  ------------------
  |  Branch (10013:7): [True: 1.96k, False: 566]
  ------------------
10014|       |    // Let host be the result of host parsing host_view with url is not special.
10015|  1.96k|    if (input.empty() && !is_special()) {
  ------------------
  |  Branch (10015:9): [True: 316, False: 1.65k]
  |  Branch (10015:26): [True: 316, False: 0]
  ------------------
10016|    316|      if (has_hostname()) {
  ------------------
  |  Branch (10016:11): [True: 18, False: 298]
  ------------------
10017|     18|        clear_hostname();
10018|    298|      } else if (has_dash_dot()) {
  ------------------
  |  Branch (10018:18): [True: 0, False: 298]
  ------------------
10019|      0|        add_authority_slashes_if_needed();
10020|      0|        delete_dash_dot();
10021|      0|      }
10022|    316|      return;
10023|    316|    }
10024|  1.96k|  }
10025|  2.21k|  update_base_hostname(input);
10026|  2.21k|  ADA_ASSERT_TRUE(validate());
10027|  2.21k|  return;
10028|  2.53k|}
_ZN3ada14url_aggregator14clear_hostnameEv:
 9564|     18|constexpr void url_aggregator::clear_hostname() {
 9565|     18|  ada_log("url_aggregator::clear_hostname");
 9566|     18|  ADA_ASSERT_TRUE(validate());
 9567|     18|  if (!has_authority()) {
  ------------------
  |  Branch (9567:7): [True: 0, False: 18]
  ------------------
 9568|      0|    return;
 9569|      0|  }
 9570|     18|  ADA_ASSERT_TRUE(has_authority());
 9571|       |
 9572|     18|  uint32_t hostname_length = components.host_end - components.host_start;
 9573|     18|  uint32_t start = components.host_start;
 9574|       |
 9575|       |  // If hostname starts with "@", we should not remove that character.
 9576|     18|  if (hostname_length > 0 && buffer[start] == '@') {
  ------------------
  |  Branch (9576:7): [True: 0, False: 18]
  |  Branch (9576:30): [True: 0, False: 0]
  ------------------
 9577|      0|    start++;
 9578|      0|    hostname_length--;
 9579|      0|  }
 9580|     18|  buffer.erase(start, hostname_length);
 9581|     18|  components.host_end = start;
 9582|     18|  components.pathname_start -= hostname_length;
 9583|     18|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9583:7): [True: 0, False: 18]
  ------------------
 9584|      0|    components.search_start -= hostname_length;
 9585|      0|  }
 9586|     18|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9586:7): [True: 0, False: 18]
  ------------------
 9587|      0|    components.hash_start -= hostname_length;
 9588|      0|  }
 9589|       |#if ADA_DEVELOPMENT_CHECKS
 9590|       |  ADA_ASSERT_EQUAL(get_hostname(), "",
 9591|       |                   "hostname should have been cleared on buffer=" + buffer +
 9592|       |                       " with " + components.to_string() + "\n" + to_diagram());
 9593|       |#endif
 9594|     18|  ADA_ASSERT_TRUE(has_authority());
 9595|     18|  ADA_ASSERT_EQUAL(has_empty_hostname(), true,
 9596|     18|                   "hostname should have been cleared on buffer=" + buffer +
 9597|     18|                       " with " + components.to_string() + "\n" + to_diagram());
 9598|     18|  ADA_ASSERT_TRUE(validate());
 9599|     18|}
_ZN3ada14url_aggregator16update_base_portEj:
 9433|  4.79k|inline void url_aggregator::update_base_port(uint32_t input) {
 9434|  4.79k|  ada_log("url_aggregator::update_base_port");
 9435|  4.79k|  ADA_ASSERT_TRUE(validate());
 9436|  4.79k|  if (input == url_components::omitted) {
  ------------------
  |  Branch (9436:7): [True: 1.94k, False: 2.85k]
  ------------------
 9437|  1.94k|    clear_port();
 9438|  1.94k|    return;
 9439|  1.94k|  }
 9440|       |  // calling std::to_string(input.value()) is unfortunate given that the port
 9441|       |  // value is probably already available as a string.
 9442|  2.85k|  std::string value = helpers::concat(":", std::to_string(input));
 9443|  2.85k|  uint32_t difference = uint32_t(value.size());
 9444|       |
 9445|  2.85k|  if (components.port != url_components::omitted) {
  ------------------
  |  Branch (9445:7): [True: 0, False: 2.85k]
  ------------------
 9446|      0|    difference -= components.pathname_start - components.host_end;
 9447|      0|    buffer.erase(components.host_end,
 9448|      0|                 components.pathname_start - components.host_end);
 9449|      0|  }
 9450|       |
 9451|  2.85k|  buffer.insert(components.host_end, value);
 9452|  2.85k|  components.pathname_start += difference;
 9453|  2.85k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9453:7): [True: 0, False: 2.85k]
  ------------------
 9454|      0|    components.search_start += difference;
 9455|      0|  }
 9456|  2.85k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9456:7): [True: 0, False: 2.85k]
  ------------------
 9457|      0|    components.hash_start += difference;
 9458|      0|  }
 9459|  2.85k|  components.port = input;
 9460|  2.85k|  ADA_ASSERT_TRUE(validate());
 9461|  2.85k|}
_ZN3ada7helpers6concatIJPKcNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEEEESA_DpT_:
 2463|  2.85k|std::string concat(Args... args) {
 2464|  2.85k|  std::string answer;
 2465|  2.85k|  inner_concat(answer, args...);
 2466|  2.85k|  return answer;
 2467|  2.85k|}
_ZN3ada7helpers12inner_concatIPKcJNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEEEEvRSA_T_DpT0_:
 2452|  2.85k|inline void inner_concat(std::string& buffer, T t, Args... args) {
 2453|  2.85k|  buffer.append(t);
 2454|  2.85k|  return inner_concat(buffer, args...);
 2455|  2.85k|}
_ZN3ada7helpers12inner_concatINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEJEEEvRS8_T_:
 2444|  2.85k|inline void inner_concat(std::string& buffer, T t) {
 2445|  2.85k|  buffer.append(t);
 2446|  2.85k|}
_ZNK3ada14url_aggregator18retrieve_base_portEv:
 9482|  1.96k|[[nodiscard]] inline uint32_t url_aggregator::retrieve_base_port() const {
 9483|  1.96k|  ada_log("url_aggregator::retrieve_base_port");
 9484|  1.96k|  return components.port;
 9485|  1.96k|}
_ZN3ada14url_aggregator12clear_searchEv:
 9487|  1.73k|inline void url_aggregator::clear_search() {
 9488|  1.73k|  ada_log("url_aggregator::clear_search");
 9489|  1.73k|  ADA_ASSERT_TRUE(validate());
 9490|  1.73k|  if (components.search_start == url_components::omitted) {
  ------------------
  |  Branch (9490:7): [True: 1.66k, False: 73]
  ------------------
 9491|  1.66k|    return;
 9492|  1.66k|  }
 9493|       |
 9494|     73|  if (components.hash_start == url_components::omitted) {
  ------------------
  |  Branch (9494:7): [True: 73, False: 0]
  ------------------
 9495|     73|    buffer.resize(components.search_start);
 9496|     73|  } else {
 9497|      0|    buffer.erase(components.search_start,
 9498|      0|                 components.hash_start - components.search_start);
 9499|      0|    components.hash_start = components.search_start;
 9500|      0|  }
 9501|       |
 9502|     73|  components.search_start = url_components::omitted;
 9503|       |
 9504|       |#if ADA_DEVELOPMENT_CHECKS
 9505|       |  ADA_ASSERT_EQUAL(get_search(), "",
 9506|       |                   "search should have been cleared on buffer=" + buffer +
 9507|       |                       " with " + components.to_string() + "\n" + to_diagram());
 9508|       |#endif
 9509|     73|  ADA_ASSERT_TRUE(validate());
 9510|     73|}
_ZN3ada14url_aggregator18update_base_searchENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKh:
 9104|  1.42k|    std::string_view input, const uint8_t query_percent_encode_set[]) {
 9105|  1.42k|  ada_log("url_aggregator::update_base_search ", input,
 9106|  1.42k|          " with encoding parameter ", to_string(), "\n", to_diagram());
 9107|  1.42k|  ADA_ASSERT_TRUE(validate());
 9108|  1.42k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 9109|       |
 9110|  1.42k|  if (components.hash_start == url_components::omitted) {
  ------------------
  |  Branch (9110:7): [True: 1.42k, False: 0]
  ------------------
 9111|  1.42k|    if (components.search_start == url_components::omitted) {
  ------------------
  |  Branch (9111:9): [True: 1.40k, False: 21]
  ------------------
 9112|  1.40k|      components.search_start = uint32_t(buffer.size());
 9113|  1.40k|      buffer += "?";
 9114|  1.40k|    } else {
 9115|     21|      buffer.resize(components.search_start + 1);
 9116|     21|    }
 9117|       |
 9118|  1.42k|    bool encoding_required =
 9119|  1.42k|        unicode::percent_encode<true>(input, query_percent_encode_set, buffer);
 9120|       |    // When encoding_required is false, then buffer is left unchanged, and
 9121|       |    // percent encoding was not deemed required.
 9122|  1.42k|    if (!encoding_required) {
  ------------------
  |  Branch (9122:9): [True: 916, False: 512]
  ------------------
 9123|    916|      buffer.append(input);
 9124|    916|    }
 9125|  1.42k|  } else {
 9126|      0|    const size_t idx =
 9127|      0|        ada::unicode::percent_encode_index(input, query_percent_encode_set);
 9128|      0|    std::string encoded;
 9129|      0|    std::string_view replacement = input;
 9130|      0|    if (idx != input.size()) {
  ------------------
  |  Branch (9130:9): [True: 0, False: 0]
  ------------------
 9131|      0|      encoded =
 9132|      0|          ada::unicode::percent_encode(input, query_percent_encode_set, idx);
 9133|      0|      replacement = encoded;
 9134|      0|    }
 9135|       |
 9136|      0|    if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9136:9): [True: 0, False: 0]
  ------------------
 9137|      0|      const uint32_t difference = replace_and_resize(
 9138|      0|          components.search_start + 1, components.hash_start, replacement);
 9139|      0|      components.hash_start += difference;
 9140|      0|    } else {
 9141|      0|      components.search_start = components.hash_start;
 9142|      0|      buffer.insert(components.search_start, replacement.size() + 1, '?');
 9143|      0|      if (!replacement.empty()) {
  ------------------
  |  Branch (9143:11): [True: 0, False: 0]
  ------------------
 9144|      0|        std::memmove(buffer.data() + components.search_start + 1,
 9145|      0|                     replacement.data(), replacement.size());
 9146|      0|      }
 9147|      0|      components.hash_start +=
 9148|      0|          uint32_t(replacement.size() + 1);  // Do not forget `?`
 9149|      0|    }
 9150|      0|  }
 9151|       |
 9152|  1.42k|  ADA_ASSERT_TRUE(validate());
 9153|  1.42k|}
_ZN3ada14url_aggregator20update_base_hostnameENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9019|  34.1k|inline void url_aggregator::update_base_hostname(const std::string_view input) {
 9020|  34.1k|  ada_log("url_aggregator::update_base_hostname ", input, " [", input.size(),
 9021|  34.1k|          " bytes], buffer is '", buffer, "' [", buffer.size(), " bytes]");
 9022|  34.1k|  ADA_ASSERT_TRUE(validate());
 9023|  34.1k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 9024|       |
 9025|       |  // This next line is required for when parsing a URL like `foo://`
 9026|  34.1k|  add_authority_slashes_if_needed();
 9027|       |
 9028|  34.1k|  bool has_credentials = components.protocol_end + 2 < components.host_start;
 9029|  34.1k|  uint32_t new_difference =
 9030|  34.1k|      replace_and_resize(components.host_start, components.host_end, input);
 9031|       |
 9032|  34.1k|  if (has_credentials) {
  ------------------
  |  Branch (9032:7): [True: 988, False: 33.1k]
  ------------------
 9033|    988|    buffer.insert(components.host_start, "@");
 9034|    988|    new_difference++;
 9035|    988|  }
 9036|  34.1k|  components.host_end += new_difference;
 9037|  34.1k|  components.pathname_start += new_difference;
 9038|  34.1k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9038:7): [True: 0, False: 34.1k]
  ------------------
 9039|      0|    components.search_start += new_difference;
 9040|      0|  }
 9041|  34.1k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9041:7): [True: 0, False: 34.1k]
  ------------------
 9042|      0|    components.hash_start += new_difference;
 9043|      0|  }
 9044|  34.1k|  ADA_ASSERT_TRUE(validate());
 9045|  34.1k|}
_ZN3ada14url_aggregator10parse_portENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEb:
 9751|  4.83k|url_aggregator::parse_port(std::string_view view, bool check_trailing_content) {
 9752|  4.83k|  ada_log("url_aggregator::parse_port('", view, "') ", view.size());
 9753|  4.83k|  if (!view.empty() && view[0] == '-') {
  ------------------
  |  Branch (9753:7): [True: 3.46k, False: 1.37k]
  |  Branch (9753:24): [True: 8, False: 3.45k]
  ------------------
 9754|      8|    ada_log("parse_port: view[0] == '0' && view.size() > 1");
 9755|      8|    is_valid = false;
 9756|      8|    return 0;
 9757|      8|  }
 9758|  4.83k|  uint16_t parsed_port{};
 9759|  4.83k|  auto r = std::from_chars(view.data(), view.data() + view.size(), parsed_port);
 9760|  4.83k|  if (r.ec == std::errc::result_out_of_range) {
  ------------------
  |  Branch (9760:7): [True: 65, False: 4.76k]
  ------------------
 9761|     65|    ada_log("parse_port: r.ec == std::errc::result_out_of_range");
 9762|     65|    is_valid = false;
 9763|     65|    return 0;
 9764|     65|  }
 9765|  4.76k|  ada_log("parse_port: ", parsed_port);
 9766|  4.76k|  const size_t consumed = size_t(r.ptr - view.data());
 9767|  4.76k|  ada_log("parse_port: consumed ", consumed);
 9768|  4.76k|  if (check_trailing_content) {
  ------------------
  |  Branch (9768:7): [True: 4.76k, False: 0]
  ------------------
 9769|  4.76k|    is_valid &=
 9770|  4.76k|        (consumed == view.size() || view[consumed] == '/' ||
  ------------------
  |  Branch (9770:10): [True: 2.65k, False: 2.10k]
  |  Branch (9770:37): [True: 1.65k, False: 449]
  ------------------
 9771|    449|         view[consumed] == '?' || (is_special() && view[consumed] == '\\'));
  ------------------
  |  Branch (9771:10): [True: 282, False: 167]
  |  Branch (9771:36): [True: 159, False: 8]
  |  Branch (9771:52): [True: 2, False: 157]
  ------------------
 9772|  4.76k|  }
 9773|  4.76k|  ada_log("parse_port: is_valid = ", is_valid);
 9774|  4.76k|  if (is_valid) {
  ------------------
  |  Branch (9774:7): [True: 4.60k, False: 165]
  ------------------
 9775|  4.60k|    ada_log("parse_port", r.ec == std::errc());
 9776|       |    // scheme_default_port can return 0, and we should allow 0 as a base port.
 9777|  4.60k|    auto default_port = scheme_default_port();
 9778|  4.60k|    bool is_port_valid = (default_port == 0 && parsed_port == 0) ||
  ------------------
  |  Branch (9778:27): [True: 140, False: 4.46k]
  |  Branch (9778:48): [True: 54, False: 86]
  ------------------
 9779|  4.54k|                         (default_port != parsed_port);
  ------------------
  |  Branch (9779:26): [True: 4.53k, False: 16]
  ------------------
 9780|  4.60k|    if (r.ec == std::errc() && is_port_valid) {
  ------------------
  |  Branch (9780:9): [True: 2.84k, False: 1.75k]
  |  Branch (9780:32): [True: 2.82k, False: 16]
  ------------------
 9781|  2.82k|      update_base_port(parsed_port);
 9782|  2.82k|    } else {
 9783|  1.77k|      clear_port();
 9784|  1.77k|    }
 9785|  4.60k|  }
 9786|  4.76k|  return consumed;
 9787|  4.83k|}
_ZN3ada14url_aggregator20append_base_pathnameENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9194|      3|inline void url_aggregator::append_base_pathname(const std::string_view input) {
 9195|      3|  ada_log("url_aggregator::append_base_pathname ", input, " ", to_string(),
 9196|      3|          "\n", to_diagram());
 9197|      3|  ADA_ASSERT_TRUE(validate());
 9198|      3|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 9199|       |#if ADA_DEVELOPMENT_CHECKS
 9200|       |  // computing the expected password.
 9201|       |  std::string path_expected(get_pathname());
 9202|       |  path_expected.append(input);
 9203|       |#endif  // ADA_DEVELOPMENT_CHECKS
 9204|      3|  uint32_t ending_index = uint32_t(buffer.size());
 9205|      3|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9205:7): [True: 0, False: 3]
  ------------------
 9206|      0|    ending_index = components.search_start;
 9207|      3|  } else if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9207:14): [True: 0, False: 3]
  ------------------
 9208|      0|    ending_index = components.hash_start;
 9209|      0|  }
 9210|      3|  buffer.insert(ending_index, input);
 9211|       |
 9212|      3|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9212:7): [True: 0, False: 3]
  ------------------
 9213|      0|    components.search_start += uint32_t(input.size());
 9214|      0|  }
 9215|      3|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9215:7): [True: 0, False: 3]
  ------------------
 9216|      0|    components.hash_start += uint32_t(input.size());
 9217|      0|  }
 9218|       |#if ADA_DEVELOPMENT_CHECKS
 9219|       |  std::string path_after = std::string(get_pathname());
 9220|       |  ADA_ASSERT_EQUAL(
 9221|       |      path_expected, path_after,
 9222|       |      "append_base_pathname problem after inserting " + std::string(input));
 9223|       |#endif  // ADA_DEVELOPMENT_CHECKS
 9224|      3|  ADA_ASSERT_TRUE(validate());
 9225|      3|}
_ZN3ada14url_aggregator20set_protocol_as_fileEv:
 9789|  5.90k|constexpr void url_aggregator::set_protocol_as_file() {
 9790|  5.90k|  ada_log("url_aggregator::set_protocol_as_file ");
 9791|  5.90k|  ADA_ASSERT_TRUE(validate());
 9792|  5.90k|  type = ada::scheme::type::FILE;
 9793|       |  // next line could overflow but unsigned arithmetic has well-defined
 9794|       |  // overflows.
 9795|  5.90k|  uint32_t new_difference = 5 - components.protocol_end;
 9796|       |
 9797|  5.90k|  if (buffer.empty()) {
  ------------------
  |  Branch (9797:7): [True: 528, False: 5.37k]
  ------------------
 9798|    528|    buffer.append("file:");
 9799|  5.37k|  } else {
 9800|  5.37k|    buffer.erase(0, components.protocol_end);
 9801|  5.37k|    buffer.insert(0, "file:");
 9802|  5.37k|  }
 9803|  5.90k|  components.protocol_end = 5;
 9804|       |
 9805|       |  // Update the rest of the components.
 9806|  5.90k|  components.username_end += new_difference;
 9807|  5.90k|  components.host_start += new_difference;
 9808|  5.90k|  components.host_end += new_difference;
 9809|  5.90k|  components.pathname_start += new_difference;
 9810|  5.90k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9810:7): [True: 0, False: 5.90k]
  ------------------
 9811|      0|    components.search_start += new_difference;
 9812|      0|  }
 9813|  5.90k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9813:7): [True: 0, False: 5.90k]
  ------------------
 9814|      0|    components.hash_start += new_difference;
 9815|      0|  }
 9816|  5.90k|  ADA_ASSERT_TRUE(validate());
 9817|  5.90k|}
_ZN3ada14url_aggregator14clear_pathnameEv:
 9529|     40|constexpr void url_aggregator::clear_pathname() {
 9530|     40|  ada_log("url_aggregator::clear_pathname");
 9531|     40|  ADA_ASSERT_TRUE(validate());
 9532|     40|  uint32_t ending_index = uint32_t(buffer.size());
 9533|     40|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9533:7): [True: 0, False: 40]
  ------------------
 9534|      0|    ending_index = components.search_start;
 9535|     40|  } else if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9535:14): [True: 0, False: 40]
  ------------------
 9536|      0|    ending_index = components.hash_start;
 9537|      0|  }
 9538|     40|  uint32_t pathname_length = ending_index - components.pathname_start;
 9539|     40|  buffer.erase(components.pathname_start, pathname_length);
 9540|     40|  uint32_t difference = pathname_length;
 9541|     40|  if (components.pathname_start == components.host_end + 2 &&
  ------------------
  |  Branch (9541:7): [True: 0, False: 40]
  ------------------
 9542|      0|      buffer[components.host_end] == '/' &&
  ------------------
  |  Branch (9542:7): [True: 0, False: 0]
  ------------------
 9543|      0|      buffer[components.host_end + 1] == '.') {
  ------------------
  |  Branch (9543:7): [True: 0, False: 0]
  ------------------
 9544|      0|    components.pathname_start -= 2;
 9545|      0|    buffer.erase(components.host_end, 2);
 9546|      0|    difference += 2;
 9547|      0|  }
 9548|     40|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9548:7): [True: 0, False: 40]
  ------------------
 9549|      0|    components.search_start -= difference;
 9550|      0|  }
 9551|     40|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9551:7): [True: 0, False: 40]
  ------------------
 9552|      0|    components.hash_start -= difference;
 9553|      0|  }
 9554|     40|  ada_log("url_aggregator::clear_pathname completed, running checks...");
 9555|       |#if ADA_DEVELOPMENT_CHECKS
 9556|       |  ADA_ASSERT_EQUAL(get_pathname(), "",
 9557|       |                   "pathname should have been cleared on buffer=" + buffer +
 9558|       |                       " with " + components.to_string() + "\n" + to_diagram());
 9559|       |#endif
 9560|     40|  ADA_ASSERT_TRUE(validate());
 9561|     40|  ada_log("url_aggregator::clear_pathname completed, running checks... ok");
 9562|     40|}
_ZN3ada7unicode20percent_encode_indexENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKh:
 8871|  1.25k|                                              const uint8_t character_set[]) {
 8872|  1.25k|  const char* data = input.data();
 8873|  1.25k|  const size_t size = input.size();
 8874|       |
 8875|       |  // Process 8 bytes at a time using unrolled loop
 8876|  1.25k|  size_t i = 0;
 8877|  4.22k|  for (; i + 8 <= size; i += 8) {
  ------------------
  |  Branch (8877:10): [True: 3.28k, False: 940]
  ------------------
 8878|  3.28k|    unsigned char chunk[8];
 8879|  3.28k|    std::memcpy(&chunk, data + i,
 8880|  3.28k|                8);  // entices compiler to unconditionally process 8 characters
 8881|       |
 8882|       |    // Check 8 characters at once
 8883|  27.1k|    for (size_t j = 0; j < 8; j++) {
  ------------------
  |  Branch (8883:24): [True: 24.2k, False: 2.96k]
  ------------------
 8884|  24.2k|      if (character_sets::bit_at(character_set, chunk[j])) {
  ------------------
  |  Branch (8884:11): [True: 314, False: 23.8k]
  ------------------
 8885|    314|        return i + j;
 8886|    314|      }
 8887|  24.2k|    }
 8888|  3.28k|  }
 8889|       |
 8890|       |  // Handle remaining bytes
 8891|  2.55k|  for (; i < size; i++) {
  ------------------
  |  Branch (8891:10): [True: 1.84k, False: 712]
  ------------------
 8892|  1.84k|    if (character_sets::bit_at(character_set, data[i])) {
  ------------------
  |  Branch (8892:9): [True: 228, False: 1.61k]
  ------------------
 8893|    228|      return i;
 8894|    228|    }
 8895|  1.84k|  }
 8896|       |
 8897|    712|  return size;
 8898|    940|}
_ZN3ada14url_aggregator10clear_portEv:
 9463|  3.71k|inline void url_aggregator::clear_port() {
 9464|  3.71k|  ada_log("url_aggregator::clear_port");
 9465|  3.71k|  ADA_ASSERT_TRUE(validate());
 9466|  3.71k|  if (components.port == url_components::omitted) {
  ------------------
  |  Branch (9466:7): [True: 3.71k, False: 0]
  ------------------
 9467|  3.71k|    return;
 9468|  3.71k|  }
 9469|      0|  uint32_t length = components.pathname_start - components.host_end;
 9470|      0|  buffer.erase(components.host_end, length);
 9471|      0|  components.pathname_start -= length;
 9472|      0|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9472:7): [True: 0, False: 0]
  ------------------
 9473|      0|    components.search_start -= length;
 9474|      0|  }
 9475|      0|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9475:7): [True: 0, False: 0]
  ------------------
 9476|      0|    components.hash_start -= length;
 9477|      0|  }
 9478|      0|  components.port = url_components::omitted;
 9479|      0|  ADA_ASSERT_TRUE(validate());
 9480|      0|}
_ZNK3ada14url_aggregator13has_authorityEv:
 9628|  54.2k|    const noexcept {
 9629|  54.2k|  ada_log("url_aggregator::has_authority");
 9630|       |  // Performance: instead of doing this potentially expensive check, we could
 9631|       |  // have a boolean in the struct.
 9632|  54.2k|  return components.protocol_end + 2 <= components.host_start &&
  ------------------
  |  Branch (9632:10): [True: 25.2k, False: 29.0k]
  ------------------
 9633|  25.2k|         buffer[components.protocol_end] == '/' &&
  ------------------
  |  Branch (9633:10): [True: 25.2k, False: 0]
  ------------------
 9634|  25.2k|         buffer[components.protocol_end + 1] == '/';
  ------------------
  |  Branch (9634:10): [True: 25.2k, False: 0]
  ------------------
 9635|  54.2k|}
_ZNK3ada14url_aggregator12has_dash_dotEv:
 9708|  18.2k|[[nodiscard]] constexpr bool url_aggregator::has_dash_dot() const noexcept {
 9709|       |  // If url's host is null, url does not have an opaque path, url's path's size
 9710|       |  // is greater than 1, and url's path[0] is the empty string, then append
 9711|       |  // U+002F (/) followed by U+002E (.) to output.
 9712|  18.2k|  ada_log("url_aggregator::has_dash_dot");
 9713|       |#if ADA_DEVELOPMENT_CHECKS
 9714|       |  // If pathname_start and host_end are exactly two characters apart, then we
 9715|       |  // either have a one-digit port such as http://test.com:5?param=1 or else we
 9716|       |  // have a /.: sequence such as "non-spec:/.//". We test that this is the case.
 9717|       |  if (components.pathname_start == components.host_end + 2) {
 9718|       |    ADA_ASSERT_TRUE((buffer[components.host_end] == '/' &&
 9719|       |                     buffer[components.host_end + 1] == '.') ||
 9720|       |                    (buffer[components.host_end] == ':' &&
 9721|       |                     checkers::is_digit(buffer[components.host_end + 1])));
 9722|       |  }
 9723|       |  if (components.pathname_start == components.host_end + 2 &&
 9724|       |      buffer[components.host_end] == '/' &&
 9725|       |      buffer[components.host_end + 1] == '.') {
 9726|       |    ADA_ASSERT_TRUE(components.pathname_start + 1 < buffer.size());
 9727|       |    ADA_ASSERT_TRUE(buffer[components.pathname_start] == '/');
 9728|       |    ADA_ASSERT_TRUE(buffer[components.pathname_start + 1] == '/');
 9729|       |  }
 9730|       |#endif
 9731|       |  // Performance: it should be uncommon for components.pathname_start ==
 9732|       |  // components.host_end + 2 to be true. So we put this check first in the
 9733|       |  // sequence. Most times, we do not have an opaque path. Checking for '/.' is
 9734|       |  // more expensive, but should be uncommon.
 9735|  18.2k|  return components.pathname_start == components.host_end + 2 &&
  ------------------
  |  Branch (9735:10): [True: 1.26k, False: 16.9k]
  ------------------
 9736|  1.26k|         !has_opaque_path && buffer[components.host_end] == '/' &&
  ------------------
  |  Branch (9736:10): [True: 1.26k, False: 0]
  |  Branch (9736:30): [True: 12, False: 1.25k]
  ------------------
 9737|     12|         buffer[components.host_end + 1] == '.';
  ------------------
  |  Branch (9737:10): [True: 12, False: 0]
  ------------------
 9738|  18.2k|}
_ZNK2tl8expectedIN3ada14url_aggregatorENS1_6errorsEEcvbEv:
 4573|  46.3k|  constexpr explicit operator bool() const noexcept { return this->m_has_val; }
_ZN2tl8expectedIN3ada14url_aggregatorENS1_6errorsEEptEv:
 4542|  28.6k|  TL_EXPECTED_11_CONSTEXPR T* operator->() {
 4543|  28.6k|    TL_ASSERT(has_value());
  ------------------
  |  | 2595|  28.6k|#define TL_ASSERT(x) assert(x)
  ------------------
  |  Branch (4543:5): [True: 28.6k, False: 0]
  ------------------
 4544|  28.6k|    return valptr();
 4545|  28.6k|  }
_ZN2tl8expectedIN3ada14url_aggregatorENS1_6errorsEE6valptrEv:
 3838|  28.6k|  T* valptr() { return std::addressof(this->m_val); }
_ZNR2tl8expectedIN3ada14url_aggregatorENS1_6errorsEEdeIS2_TnPNSt3__19enable_ifIXntsr3std7is_voidIT_EE5valueEvE4typeELPv0EEERS8_v:
 4555|  4.45k|  TL_EXPECTED_11_CONSTEXPR U& operator*() & {
 4556|  4.45k|    TL_ASSERT(has_value());
  ------------------
  |  | 2595|  4.45k|#define TL_ASSERT(x) assert(x)
  ------------------
  |  Branch (4556:5): [True: 4.45k, False: 0]
  ------------------
 4557|  4.45k|    return val();
 4558|  4.45k|  }
_ZN2tl8expectedIN3ada14url_aggregatorENS1_6errorsEE3valIS2_TnPNSt3__19enable_ifIXntsr3std7is_voidIT_EE5valueEvE4typeELPv0EEERS8_v:
 3847|  4.45k|  TL_EXPECTED_11_CONSTEXPR U& val() {
 3848|  4.45k|    return this->m_val;
 3849|  4.45k|  }
_ZNK2tl8expectedIN3ada14url_aggregatorENS1_6errorsEE9has_valueEv:
 4572|  92.5k|  constexpr bool has_value() const noexcept { return this->m_has_val; }
_ZN2tl6detail21expected_storage_baseIN3ada14url_aggregatorENS2_6errorsELb0ELb1EED2Ev:
 3170|  50.6k|  ~expected_storage_base() {
 3171|  50.6k|    if (m_has_val) {
  ------------------
  |  Branch (3171:9): [True: 24.7k, False: 25.9k]
  ------------------
 3172|  24.7k|      m_val.~T();
 3173|  24.7k|    }
 3174|  50.6k|  }
_ZN3ada7helpers9substringENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEmm:
 2385|  31.0k|                                                       size_t pos2) {
 2386|       |#if ADA_DEVELOPMENT_CHECKS
 2387|       |  if (pos2 < pos1) {
 2388|       |    std::cerr << "Negative-length substring: [" << pos1 << " to " << pos2 << ")"
 2389|       |              << std::endl;
 2390|       |    abort();
 2391|       |  }
 2392|       |#endif
 2393|  31.0k|  return input.substr(pos1, pos2 - pos1);
 2394|  31.0k|}
_ZNK3ada14url_aggregator10is_at_pathEv:
 9060|  5.00k|    const noexcept {
 9061|  5.00k|  return buffer.size() == components.pathname_start;
 9062|  5.00k|}
_ZNK3ada14url_aggregator12has_hostnameEv:
 9697|    316|constexpr bool url_aggregator::has_hostname() const noexcept {
 9698|    316|  return has_authority();
 9699|    316|}
_ZNK3ada14url_aggregator12has_passwordEv:
 9677|  5.70k|constexpr bool url_aggregator::has_password() const noexcept {
 9678|  5.70k|  ada_log("url_aggregator::has_password");
 9679|       |  // This function does not care about the length of the password
 9680|  5.70k|  return components.host_start > components.username_end &&
  ------------------
  |  Branch (9680:10): [True: 5.09k, False: 616]
  ------------------
 9681|  5.09k|         buffer[components.username_end] == ':';
  ------------------
  |  Branch (9681:10): [True: 5.09k, False: 0]
  ------------------
 9682|  5.70k|}
_ZNK3ada3url8get_hrefEv:
 8124|  20.2k|[[nodiscard]] ada_really_inline std::string url::get_href() const {
 8125|  20.2k|  if (is_special() && host.has_value() && username.empty() &&
  ------------------
  |  Branch (8125:7): [True: 16.9k, False: 3.29k]
  |  Branch (8125:23): [True: 16.9k, False: 0]
  |  Branch (8125:43): [True: 16.4k, False: 543]
  ------------------
 8126|  16.4k|      password.empty() && !port.has_value()) [[likely]] {
  ------------------
  |  Branch (8126:7): [True: 16.3k, False: 69]
  |  Branch (8126:27): [True: 13.8k, False: 2.50k]
  ------------------
 8127|  13.8k|    const std::string_view scheme = ada::scheme::details::is_special_list[type];
 8128|  13.8k|    const size_t host_size = host->size();
 8129|  13.8k|    const size_t path_size = path.size();
 8130|  13.8k|    const size_t query_size = query.has_value() ? query->size() : 0;
  ------------------
  |  Branch (8130:31): [True: 1.03k, False: 12.8k]
  ------------------
 8131|  13.8k|    const size_t hash_size = hash.has_value() ? hash->size() : 0;
  ------------------
  |  Branch (8131:30): [True: 912, False: 12.9k]
  ------------------
 8132|  13.8k|    const size_t total = scheme.size() + 3 + host_size + path_size +
 8133|  13.8k|                         (query.has_value() ? query_size + 1 : 0) +
  ------------------
  |  Branch (8133:27): [True: 1.03k, False: 12.8k]
  ------------------
 8134|  13.8k|                         (hash.has_value() ? hash_size + 1 : 0);
  ------------------
  |  Branch (8134:27): [True: 912, False: 12.9k]
  ------------------
 8135|  13.8k|    std::string output(total, '\0');
 8136|  13.8k|    char* p = output.data();
 8137|  13.8k|    std::memcpy(p, scheme.data(), scheme.size());
 8138|  13.8k|    p += scheme.size();
 8139|  13.8k|    p[0] = ':';
 8140|  13.8k|    p[1] = '/';
 8141|  13.8k|    p[2] = '/';
 8142|  13.8k|    p += 3;
 8143|       |    // NOLINTNEXTLINE(bugprone-not-null-terminated-result)
 8144|  13.8k|    std::memcpy(p, host->data(), host_size);
 8145|  13.8k|    p += host_size;
 8146|  13.8k|    std::memcpy(p, path.data(), path_size);
 8147|  13.8k|    p += path_size;
 8148|  13.8k|    if (query.has_value()) {
  ------------------
  |  Branch (8148:9): [True: 1.03k, False: 12.8k]
  ------------------
 8149|  1.03k|      *p++ = '?';
 8150|       |      // NOLINTNEXTLINE(bugprone-not-null-terminated-result)
 8151|  1.03k|      std::memcpy(p, query->data(), query_size);
 8152|  1.03k|      p += query_size;
 8153|  1.03k|    }
 8154|  13.8k|    if (hash.has_value()) {
  ------------------
  |  Branch (8154:9): [True: 912, False: 12.9k]
  ------------------
 8155|    912|      *p++ = '#';
 8156|       |      // NOLINTNEXTLINE(bugprone-not-null-terminated-result)
 8157|    912|      std::memcpy(p, hash->data(), hash_size);
 8158|    912|    }
 8159|  13.8k|    return output;
 8160|  13.8k|  }
 8161|       |
 8162|  6.40k|  std::string output;
 8163|  6.40k|  output.reserve(get_href_size());
 8164|       |
 8165|  6.40k|  if (is_special()) {
  ------------------
  |  Branch (8165:7): [True: 3.11k, False: 3.29k]
  ------------------
 8166|  3.11k|    output.append(ada::scheme::details::is_special_list[type]);
 8167|  3.11k|    output += ':';
 8168|  3.29k|  } else {
 8169|  3.29k|    output.append(non_special_scheme);
 8170|  3.29k|    output += ':';
 8171|  3.29k|  }
 8172|       |
 8173|  6.40k|  if (host.has_value()) {
  ------------------
  |  Branch (8173:7): [True: 3.85k, False: 2.54k]
  ------------------
 8174|  3.85k|    output += '/';
 8175|  3.85k|    output += '/';
 8176|  3.85k|    if (has_credentials()) {
  ------------------
  |  Branch (8176:9): [True: 701, False: 3.15k]
  ------------------
 8177|    701|      output.append(username);
 8178|    701|      if (!password.empty()) {
  ------------------
  |  Branch (8178:11): [True: 224, False: 477]
  ------------------
 8179|    224|        output += ':';
 8180|    224|        output.append(password);
 8181|    224|      }
 8182|    701|      output += '@';
 8183|    701|    }
 8184|  3.85k|    output.append(*host);
 8185|  3.85k|    if (port.has_value()) {
  ------------------
  |  Branch (8185:9): [True: 2.61k, False: 1.24k]
  ------------------
 8186|  2.61k|      output += ':';
 8187|  2.61k|      char port_buf[5];
 8188|  2.61k|      auto [ptr, ec] = std::to_chars(port_buf, port_buf + 5, *port);
 8189|  2.61k|      (void)ec;
 8190|  2.61k|      output.append(port_buf, static_cast<size_t>(ptr - port_buf));
 8191|  2.61k|    }
 8192|  3.85k|  } else if (!has_opaque_path && path.starts_with("//")) {
  ------------------
  |  Branch (8192:14): [True: 1.28k, False: 1.26k]
  |  Branch (8192:34): [True: 30, False: 1.25k]
  ------------------
 8193|       |    // If url's host is null, url does not have an opaque path, url's path's
 8194|       |    // size is greater than 1, and url's path[0] is the empty string, then
 8195|       |    // append U+002F (/) followed by U+002E (.) to output.
 8196|     30|    output += '/';
 8197|     30|    output += '.';
 8198|     30|  }
 8199|  6.40k|  output.append(path);
 8200|  6.40k|  if (query.has_value()) {
  ------------------
  |  Branch (8200:7): [True: 737, False: 5.66k]
  ------------------
 8201|    737|    output += '?';
 8202|    737|    output.append(*query);
 8203|    737|  }
 8204|  6.40k|  if (hash.has_value()) {
  ------------------
  |  Branch (8204:7): [True: 642, False: 5.76k]
  ------------------
 8205|    642|    output += '#';
 8206|    642|    output.append(*hash);
 8207|    642|  }
 8208|  6.40k|  return output;
 8209|  20.2k|}
_ZNK3ada14url_aggregator10has_searchEv:
 9606|  2.33k|[[nodiscard]] constexpr bool url_aggregator::has_search() const noexcept {
 9607|  2.33k|  ada_log("url_aggregator::has_search");
 9608|  2.33k|  return components.search_start != url_components::omitted;
 9609|  2.33k|}
_ZN3ada7helpers6concatIJNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEPKcEEENS2_12basic_stringIcS5_NS2_9allocatorIcEEEEDpT_:
 2463|  22.3k|std::string concat(Args... args) {
 2464|  22.3k|  std::string answer;
 2465|  22.3k|  inner_concat(answer, args...);
 2466|  22.3k|  return answer;
 2467|  22.3k|}
_ZN3ada7helpers12inner_concatINSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEJPKcEEEvRNS2_12basic_stringIcS5_NS2_9allocatorIcEEEET_DpT0_:
 2452|  22.3k|inline void inner_concat(std::string& buffer, T t, Args... args) {
 2453|  22.3k|  buffer.append(t);
 2454|  22.3k|  return inner_concat(buffer, args...);
 2455|  22.3k|}
_ZN3ada7helpers12inner_concatIPKcJEEEvRNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEET_:
 2444|  22.3k|inline void inner_concat(std::string& buffer, T t) {
 2445|  22.3k|  buffer.append(t);
 2446|  22.3k|}
_ZN3ada3url10set_schemeEONSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 8106|  11.1k|inline void url::set_scheme(std::string&& new_scheme) noexcept {
 8107|  11.1k|  type = ada::scheme::get_scheme_type(new_scheme);
 8108|       |  // We only move the 'scheme' if it is non-special.
 8109|  11.1k|  if (!is_special()) {
  ------------------
  |  Branch (8109:7): [True: 5.46k, False: 5.72k]
  ------------------
 8110|  5.46k|    non_special_scheme = std::move(new_scheme);
 8111|  5.46k|  }
 8112|  11.1k|}
_ZN3ada7helpers6concatIJPKcNSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEEEENS4_12basic_stringIcS7_NS4_9allocatorIcEEEEDpT_:
 2463|      3|std::string concat(Args... args) {
 2464|      3|  std::string answer;
 2465|      3|  inner_concat(answer, args...);
 2466|      3|  return answer;
 2467|      3|}
_ZN3ada7helpers12inner_concatIPKcJNSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEEEEvRNS4_12basic_stringIcS7_NS4_9allocatorIcEEEET_DpT0_:
 2452|      3|inline void inner_concat(std::string& buffer, T t, Args... args) {
 2453|      3|  buffer.append(t);
 2454|      3|  return inner_concat(buffer, args...);
 2455|      3|}
_ZN3ada7helpers12inner_concatINSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEJEEEvRNS2_12basic_stringIcS5_NS2_9allocatorIcEEEET_:
 2444|      3|inline void inner_concat(std::string& buffer, T t) {
 2445|      3|  buffer.append(t);
 2446|      3|}

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

