_ZN3ada4idna13utf8_to_utf32EPKcmPDi:
  160|  13.5k|size_t utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_output) {
  161|  13.5k|  const uint8_t* data = reinterpret_cast<const uint8_t*>(buf);
  162|  13.5k|  size_t pos = 0;
  163|  13.5k|  const char32_t* start{utf32_output};
  164|   198k|  while (pos < len) {
  ------------------
  |  Branch (164:10): [True: 185k, False: 12.5k]
  ------------------
  165|       |    // try to convert the next block of 16 ASCII bytes
  166|   185k|    if (pos + 16 <= len) {  // if it is safe to read 16 more
  ------------------
  |  Branch (166:9): [True: 112k, False: 72.7k]
  ------------------
  167|       |                            // bytes, check that they are ascii
  168|   112k|      uint64_t v1;
  169|   112k|      std::memcpy(&v1, data + pos, sizeof(uint64_t));
  170|   112k|      uint64_t v2;
  171|   112k|      std::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  172|   112k|      uint64_t v{v1 | v2};
  173|   112k|      if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (173:11): [True: 8.05k, False: 104k]
  ------------------
  174|  8.05k|        size_t final_pos = pos + 16;
  175|   136k|        while (pos < final_pos) {
  ------------------
  |  Branch (175:16): [True: 128k, False: 8.05k]
  ------------------
  176|   128k|          *utf32_output++ = char32_t(buf[pos]);
  177|   128k|          pos++;
  178|   128k|        }
  179|  8.05k|        continue;
  180|  8.05k|      }
  181|   112k|    }
  182|   177k|    uint8_t leading_byte = data[pos];  // leading byte
  183|   177k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (183:9): [True: 99.9k, False: 77.6k]
  ------------------
  184|       |      // converting one ASCII byte !!!
  185|  99.9k|      *utf32_output++ = char32_t(leading_byte);
  186|  99.9k|      pos++;
  187|  99.9k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (187:16): [True: 19.7k, False: 57.8k]
  ------------------
  188|       |      // We have a two-byte UTF-8
  189|  19.7k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (189:11): [True: 150, False: 19.5k]
  ------------------
  190|    150|        return 0;
  191|    150|      }  // minimal bound checking
  192|  19.5k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (192:11): [True: 150, False: 19.4k]
  ------------------
  193|    150|        return 0;
  194|    150|      }
  195|       |      // range check
  196|  19.4k|      uint32_t code_point =
  197|  19.4k|          (leading_byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111);
  198|  19.4k|      if (code_point < 0x80 || 0x7ff < code_point) {
  ------------------
  |  Branch (198:11): [True: 18, False: 19.4k]
  |  Branch (198:32): [True: 0, False: 19.4k]
  ------------------
  199|     18|        return 0;
  200|     18|      }
  201|  19.4k|      *utf32_output++ = char32_t(code_point);
  202|  19.4k|      pos += 2;
  203|  57.8k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (203:16): [True: 55.4k, False: 2.39k]
  ------------------
  204|       |      // We have a three-byte UTF-8
  205|  55.4k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (205:11): [True: 33, False: 55.4k]
  ------------------
  206|     33|        return 0;
  207|     33|      }  // minimal bound checking
  208|       |
  209|  55.4k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (209:11): [True: 57, False: 55.4k]
  ------------------
  210|     57|        return 0;
  211|     57|      }
  212|  55.4k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (212:11): [True: 18, False: 55.3k]
  ------------------
  213|     18|        return 0;
  214|     18|      }
  215|       |      // range check
  216|  55.3k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
  217|  55.3k|                            (data[pos + 1] & 0b00111111) << 6 |
  218|  55.3k|                            (data[pos + 2] & 0b00111111);
  219|  55.3k|      if (code_point < 0x800 || 0xffff < code_point ||
  ------------------
  |  Branch (219:11): [True: 18, False: 55.3k]
  |  Branch (219:33): [True: 0, False: 55.3k]
  ------------------
  220|  55.3k|          (0xd7ff < code_point && code_point < 0xe000)) {
  ------------------
  |  Branch (220:12): [True: 8.86k, False: 46.5k]
  |  Branch (220:35): [True: 9, False: 8.85k]
  ------------------
  221|     27|        return 0;
  222|     27|      }
  223|  55.3k|      *utf32_output++ = char32_t(code_point);
  224|  55.3k|      pos += 3;
  225|  55.3k|    } else if ((leading_byte & 0b11111000) == 0b11110000) {  // 0b11110000
  ------------------
  |  Branch (225:16): [True: 2.01k, False: 375]
  ------------------
  226|       |      // we have a 4-byte UTF-8 word.
  227|  2.01k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (227:11): [True: 57, False: 1.96k]
  ------------------
  228|     57|        return 0;
  229|     57|      }  // minimal bound checking
  230|  1.96k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (230:11): [True: 24, False: 1.93k]
  ------------------
  231|     24|        return 0;
  232|     24|      }
  233|  1.93k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (233:11): [True: 9, False: 1.92k]
  ------------------
  234|      9|        return 0;
  235|      9|      }
  236|  1.92k|      if ((data[pos + 3] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (236:11): [True: 21, False: 1.90k]
  ------------------
  237|     21|        return 0;
  238|     21|      }
  239|       |
  240|       |      // range check
  241|  1.90k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  242|  1.90k|                            (data[pos + 1] & 0b00111111) << 12 |
  243|  1.90k|                            (data[pos + 2] & 0b00111111) << 6 |
  244|  1.90k|                            (data[pos + 3] & 0b00111111);
  245|  1.90k|      if (code_point <= 0xffff || 0x10ffff < code_point) {
  ------------------
  |  Branch (245:11): [True: 21, False: 1.88k]
  |  Branch (245:35): [True: 15, False: 1.87k]
  ------------------
  246|     36|        return 0;
  247|     36|      }
  248|  1.87k|      *utf32_output++ = char32_t(code_point);
  249|  1.87k|      pos += 4;
  250|  1.87k|    } else {
  251|    375|      return 0;
  252|    375|    }
  253|   177k|  }
  254|  12.5k|  return utf32_output - start;
  255|  13.5k|}
_ZN3ada4idna22utf32_length_from_utf8EPKcm:
  270|  13.6k|size_t utf32_length_from_utf8(const char* buf, size_t len) {
  271|  13.6k|  const int8_t* p = reinterpret_cast<const int8_t*>(buf);
  272|  13.6k|  return std::count_if(p, std::next(p, len), [](int8_t c) {
  273|       |    // -65 is 0b10111111, anything larger in two-complement's
  274|       |    // should start a new code point.
  275|  13.6k|    return c > -65;
  276|  13.6k|  });
  277|  13.6k|}
_ZN3ada4idna7deflate9BitReader3getEi:
  405|   457k|  uint32_t get(int n) {
  406|   457k|    if (!ensure(n)) return UINT32_MAX;
  ------------------
  |  Branch (406:9): [True: 0, False: 457k]
  ------------------
  407|   457k|    uint32_t v = acc & ((1u << n) - 1);
  408|   457k|    acc >>= n;
  409|   457k|    bits -= n;
  410|   457k|    return v;
  411|   457k|  }
_ZN3ada4idna9ascii_mapEPcm:
 5126|  6.19k|void ascii_map(char* input, size_t length) {
 5127|  6.19k|  auto broadcast = [](uint8_t v) -> uint64_t {
 5128|  6.19k|    return 0x101010101010101ull * v;
 5129|  6.19k|  };
 5130|  6.19k|  uint64_t broadcast_80 = broadcast(0x80);
 5131|  6.19k|  uint64_t broadcast_Ap = broadcast(128 - 'A');
 5132|  6.19k|  uint64_t broadcast_Zp = broadcast(128 - 'Z' - 1);
 5133|  6.19k|  size_t i = 0;
 5134|       |
 5135|  55.0k|  for (; i + 7 < length; i += 8) {
  ------------------
  |  Branch (5135:10): [True: 48.8k, False: 6.19k]
  ------------------
 5136|  48.8k|    uint64_t word{};
 5137|  48.8k|    std::memcpy(&word, input + i, sizeof(word));
 5138|  48.8k|    word ^=
 5139|  48.8k|        (((word + broadcast_Ap) ^ (word + broadcast_Zp)) & broadcast_80) >> 2;
 5140|  48.8k|    std::memcpy(input + i, &word, sizeof(word));
 5141|  48.8k|  }
 5142|  6.19k|  if (i < length) {
  ------------------
  |  Branch (5142:7): [True: 5.27k, False: 923]
  ------------------
 5143|  5.27k|    uint64_t word{};
 5144|  5.27k|    std::memcpy(&word, input + i, length - i);
 5145|  5.27k|    word ^=
 5146|  5.27k|        (((word + broadcast_Ap) ^ (word + broadcast_Zp)) & broadcast_80) >> 2;
 5147|  5.27k|    std::memcpy(input + i, &word, length - i);
 5148|  5.27k|  }
 5149|  6.19k|}
_ZN3ada4idna3mapENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEERNS1_12basic_stringIDiS4_NS1_9allocatorIDiEEEE:
 5153|  20.2k|bool map(std::u32string_view input, std::u32string& out) {
 5154|       |  //  [Map](https://www.unicode.org/reports/tr46/#ProcessingStepMap).
 5155|  20.2k|  out.clear();
 5156|  20.2k|  if (!ensure_tables()) {
  ------------------
  |  Branch (5156:7): [True: 0, False: 20.2k]
  ------------------
 5157|      0|    return false;
 5158|      0|  }
 5159|       |
 5160|       |  // Pass 1: validate and compute exact output length.
 5161|  20.2k|  size_t out_size = 0;
 5162|   364k|  for (char32_t x : input) {
  ------------------
  |  Branch (5162:19): [True: 364k, False: 19.6k]
  ------------------
 5163|   364k|    uint16_t status = idna_lookup(static_cast<uint32_t>(x));
 5164|   364k|    if (status == IDNA_DISALLOWED) {
  ------------------
  |  Branch (5164:9): [True: 642, False: 364k]
  ------------------
 5165|    642|      return false;
 5166|    642|    }
 5167|   364k|    if (status == IDNA_VALID) {
  ------------------
  |  Branch (5167:9): [True: 255k, False: 108k]
  ------------------
 5168|   255k|      ++out_size;
 5169|   255k|      continue;
 5170|   255k|    }
 5171|   108k|    if (static_cast<size_t>(status) >= idna_utf8_mappings_size) {
  ------------------
  |  Branch (5171:9): [True: 0, False: 108k]
  ------------------
 5172|      0|      return false;
 5173|      0|    }
 5174|   108k|    out_size += utf8_count_codepoints(idna_utf8_mappings + status);
 5175|   108k|  }
 5176|       |
 5177|       |  // Pass 2: write into a single allocation.
 5178|  19.6k|  out.resize(out_size);
 5179|  19.6k|  size_t w = 0;
 5180|   363k|  for (char32_t x : input) {
  ------------------
  |  Branch (5180:19): [True: 363k, False: 19.6k]
  ------------------
 5181|   363k|    uint16_t status = idna_lookup(static_cast<uint32_t>(x));
 5182|   363k|    if (status == IDNA_VALID) {
  ------------------
  |  Branch (5182:9): [True: 255k, False: 108k]
  ------------------
 5183|   255k|      out[w++] = x;
 5184|   255k|      continue;
 5185|   255k|    }
 5186|       |    // IGNORED or mapped (status already validated in pass 1).
 5187|   108k|    const uint8_t* ptr = idna_utf8_mappings + status;
 5188|   617k|    while (*ptr != 0) {
  ------------------
  |  Branch (5188:12): [True: 508k, False: 108k]
  ------------------
 5189|   508k|      out[w++] = utf8_next(ptr);
 5190|   508k|    }
 5191|   108k|  }
 5192|  19.6k|  return true;
 5193|  20.2k|}
_ZN3ada4idna28compute_decomposition_lengthENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 5286|  5.86k|    const std::u32string_view input) noexcept {
 5287|  5.86k|  bool decomposition_needed{false};
 5288|  5.86k|  size_t additional_elements{0};
 5289|  76.2k|  for (char32_t current_character : input) {
  ------------------
  |  Branch (5289:35): [True: 76.2k, False: 5.86k]
  ------------------
 5290|  76.2k|    size_t decomposition_length{0};
 5291|       |
 5292|  76.2k|    if (current_character >= hangul_sbase &&
  ------------------
  |  Branch (5292:9): [True: 9.52k, False: 66.7k]
  ------------------
 5293|  9.52k|        current_character < hangul_sbase + hangul_scount) {
  ------------------
  |  Branch (5293:9): [True: 5.90k, False: 3.62k]
  ------------------
 5294|       |      // Full NFD-style Hangul decomp for the decompose() step.
 5295|  5.90k|      decomposition_length = 2;
 5296|  5.90k|      if ((current_character - hangul_sbase) % hangul_tcount) {
  ------------------
  |  Branch (5296:11): [True: 3.55k, False: 2.34k]
  ------------------
 5297|  3.55k|        decomposition_length = 3;
 5298|  3.55k|      }
 5299|  70.3k|    } else if (current_character < 0x110000) {
  ------------------
  |  Branch (5299:16): [True: 70.3k, False: 0]
  ------------------
 5300|  70.3k|      const uint8_t di = decomposition_index[current_character >> 8];
 5301|  70.3k|      const uint16_t* const decomposition =
 5302|  70.3k|          decomposition_block_row(di) + (current_character % 256);
 5303|  70.3k|      decomposition_length = (decomposition[1] >> 2) - (decomposition[0] >> 2);
 5304|  70.3k|      if ((decomposition_length > 0) && (decomposition[0] & 1)) {
  ------------------
  |  Branch (5304:11): [True: 7.75k, False: 62.5k]
  |  Branch (5304:41): [True: 0, False: 7.75k]
  ------------------
 5305|      0|        decomposition_length = 0;
 5306|      0|      }
 5307|  70.3k|    }
 5308|  76.2k|    if (decomposition_length != 0) {
  ------------------
  |  Branch (5308:9): [True: 13.6k, False: 62.5k]
  ------------------
 5309|  13.6k|      decomposition_needed = true;
 5310|  13.6k|      additional_elements += decomposition_length - 1;
 5311|  13.6k|    }
 5312|  76.2k|  }
 5313|  5.86k|  return {decomposition_needed, additional_elements};
 5314|  5.86k|}
_ZN3ada4idna9decomposeERNSt3__112basic_stringIDiNS1_11char_traitsIDiEENS1_9allocatorIDiEEEEm:
 5316|  4.54k|void decompose(std::u32string& input, size_t additional_elements) {
 5317|  4.54k|  input.resize(input.size() + additional_elements);
 5318|  4.54k|  for (size_t descending_idx = input.size(),
 5319|  4.54k|              input_count = descending_idx - additional_elements;
 5320|  54.7k|       input_count--;) {
  ------------------
  |  Branch (5320:8): [True: 50.2k, False: 4.54k]
  ------------------
 5321|  50.2k|    if (input[input_count] >= hangul_sbase &&
  ------------------
  |  Branch (5321:9): [True: 7.71k, False: 42.5k]
  ------------------
 5322|  7.71k|        input[input_count] < hangul_sbase + hangul_scount) {
  ------------------
  |  Branch (5322:9): [True: 5.90k, False: 1.80k]
  ------------------
 5323|       |      // Hangul decomposition.
 5324|  5.90k|      char32_t s_index = input[input_count] - hangul_sbase;
 5325|  5.90k|      if (s_index % hangul_tcount != 0) {
  ------------------
  |  Branch (5325:11): [True: 3.55k, False: 2.34k]
  ------------------
 5326|  3.55k|        input[--descending_idx] = hangul_tbase + s_index % hangul_tcount;
 5327|  3.55k|      }
 5328|  5.90k|      input[--descending_idx] =
 5329|  5.90k|          hangul_vbase + (s_index % hangul_ncount) / hangul_tcount;
 5330|  5.90k|      input[--descending_idx] = hangul_lbase + s_index / hangul_ncount;
 5331|  44.3k|    } else if (input[input_count] < 0x110000) {
  ------------------
  |  Branch (5331:16): [True: 44.3k, False: 0]
  ------------------
 5332|  44.3k|      const uint16_t* decomposition =
 5333|  44.3k|          decomposition_block_row(
 5334|  44.3k|              decomposition_index[input[input_count] >> 8]) +
 5335|  44.3k|          (input[input_count] % 256);
 5336|  44.3k|      uint16_t decomposition_length =
 5337|  44.3k|          (decomposition[1] >> 2) - (decomposition[0] >> 2);
 5338|  44.3k|      if (decomposition_length > 0 && (decomposition[0] & 1)) {
  ------------------
  |  Branch (5338:11): [True: 7.75k, False: 36.5k]
  |  Branch (5338:39): [True: 0, False: 7.75k]
  ------------------
 5339|      0|        decomposition_length = 0;
 5340|      0|      }
 5341|  44.3k|      if (decomposition_length > 0) {
  ------------------
  |  Branch (5341:11): [True: 7.75k, False: 36.5k]
  ------------------
 5342|  7.75k|        const size_t base = static_cast<size_t>(decomposition[0] >> 2);
 5343|  7.75k|        if (base + decomposition_length > decomposition_data_size) {
  ------------------
  |  Branch (5343:13): [True: 0, False: 7.75k]
  ------------------
 5344|      0|          input[--descending_idx] = input[input_count];
 5345|  7.75k|        } else {
 5346|  24.8k|          while (decomposition_length-- > 0) {
  ------------------
  |  Branch (5346:18): [True: 17.1k, False: 7.75k]
  ------------------
 5347|  17.1k|            input[--descending_idx] =
 5348|  17.1k|                decomposition_data[base + decomposition_length];
 5349|  17.1k|          }
 5350|  7.75k|        }
 5351|  36.5k|      } else {
 5352|  36.5k|        input[--descending_idx] = input[input_count];
 5353|  36.5k|      }
 5354|  44.3k|    } else {
 5355|      0|      input[--descending_idx] = input[input_count];
 5356|      0|    }
 5357|  50.2k|  }
 5358|  4.54k|}
_ZN3ada4idna7get_cccEDi:
 5360|  1.80M|uint8_t get_ccc(char32_t c) noexcept {
 5361|  1.80M|  if (c >= 0x110000) {
  ------------------
  |  Branch (5361:7): [True: 0, False: 1.80M]
  ------------------
 5362|      0|    return 0;
 5363|      0|  }
 5364|  1.80M|  return ccc_block_row(ccc_index[c >> 8])[c % 256];
 5365|  1.80M|}
_ZN3ada4idna10sort_marksERNSt3__112basic_stringIDiNS1_11char_traitsIDiEENS1_9allocatorIDiEEEE:
 5367|  5.86k|void sort_marks(std::u32string& input) {
 5368|  95.0k|  for (size_t idx = 1; idx < input.size(); idx++) {
  ------------------
  |  Branch (5368:24): [True: 89.2k, False: 5.86k]
  ------------------
 5369|  89.2k|    uint8_t ccc = get_ccc(input[idx]);
 5370|  89.2k|    if (ccc == 0) {
  ------------------
  |  Branch (5370:9): [True: 67.3k, False: 21.8k]
  ------------------
 5371|  67.3k|      continue;
 5372|  67.3k|    }
 5373|  21.8k|    auto current_character = input[idx];
 5374|  21.8k|    size_t back_idx = idx;
 5375|  31.6k|    while (back_idx != 0 && get_ccc(input[back_idx - 1]) > ccc) {
  ------------------
  |  Branch (5375:12): [True: 31.1k, False: 426]
  |  Branch (5375:29): [True: 9.75k, False: 21.4k]
  ------------------
 5376|  9.75k|      input[back_idx] = input[back_idx - 1];
 5377|  9.75k|      back_idx--;
 5378|  9.75k|    }
 5379|  21.8k|    input[back_idx] = current_character;
 5380|  21.8k|  }
 5381|  5.86k|}
_ZN3ada4idna13decompose_nfcERNSt3__112basic_stringIDiNS1_11char_traitsIDiEENS1_9allocatorIDiEEEE:
 5383|  5.86k|void decompose_nfc(std::u32string& input) {
 5384|       |  /**
 5385|       |   * Decompose the domain_name string to Unicode Normalization Form C.
 5386|       |   * @see https://www.unicode.org/reports/tr46/#ProcessingStepDecompose
 5387|       |   */
 5388|  5.86k|  auto [decomposition_needed, additional_elements] =
 5389|  5.86k|      compute_decomposition_length(input);
 5390|  5.86k|  if (decomposition_needed) {
  ------------------
  |  Branch (5390:7): [True: 4.54k, False: 1.32k]
  ------------------
 5391|  4.54k|    decompose(input, additional_elements);
 5392|  4.54k|  }
 5393|  5.86k|  sort_marks(input);
 5394|  5.86k|}
_ZN3ada4idna14is_already_nfcENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 5477|  22.2k|bool is_already_nfc(std::u32string_view input) noexcept {
 5478|  22.2k|  if (input.empty()) {
  ------------------
  |  Branch (5478:7): [True: 0, False: 22.2k]
  ------------------
 5479|      0|    return true;
 5480|      0|  }
 5481|  22.2k|  if (!tables_are_ready() && !ensure_tables()) {
  ------------------
  |  Branch (5481:7): [True: 0, False: 22.2k]
  |  Branch (5481:30): [True: 0, False: 0]
  ------------------
 5482|      0|    return false;
 5483|      0|  }
 5484|       |  // 1) Singleton decompositions are never NFC (e.g. U+212B ANGSTROM SIGN).
 5485|       |  //    Multi-code-point decomps are primary composites that are NFC as-is.
 5486|   585k|  for (char32_t c : input) {
  ------------------
  |  Branch (5486:19): [True: 585k, False: 22.2k]
  ------------------
 5487|   585k|    if (canonical_decomp_length(c) == 1) {
  ------------------
  |  Branch (5487:9): [True: 0, False: 585k]
  ------------------
 5488|      0|      return false;
 5489|      0|    }
 5490|   585k|  }
 5491|       |  // 2) Combining marks already in canonical order. prev_ccc carries the
 5492|       |  //    trailing class of the previous character's canonical decomposition so a
 5493|       |  //    composite starter followed by a lower-class mark is caught.
 5494|  22.2k|  uint8_t prev_ccc = 0;
 5495|   571k|  for (char32_t c : input) {
  ------------------
  |  Branch (5495:19): [True: 571k, False: 13.9k]
  ------------------
 5496|   571k|    uint8_t ccc = get_ccc(c);
 5497|   571k|    if (ccc != 0 && prev_ccc > ccc) {
  ------------------
  |  Branch (5497:9): [True: 28.6k, False: 542k]
  |  Branch (5497:21): [True: 8.25k, False: 20.4k]
  ------------------
 5498|  8.25k|      return false;
 5499|  8.25k|    }
 5500|   563k|    prev_ccc = trailing_ccc(c);
 5501|   563k|  }
 5502|       |  // 3) No pairwise composition would apply (including Hangul L+V / LV+T).
 5503|  13.9k|  return !would_compose(input);
 5504|  22.2k|}
_ZN3ada4idna7composeERNSt3__112basic_stringIDiNS1_11char_traitsIDiEENS1_9allocatorIDiEEEE:
 5506|  5.86k|void compose(std::u32string& input) {
 5507|       |  /**
 5508|       |   * Compose the domain_name string to Unicode Normalization Form C.
 5509|       |   * @see https://www.unicode.org/reports/tr46/#ProcessingStepCompose
 5510|       |   */
 5511|  5.86k|  size_t input_count{0};
 5512|  5.86k|  size_t composition_count{0};
 5513|  69.1k|  for (; input_count < input.size(); input_count++, composition_count++) {
  ------------------
  |  Branch (5513:10): [True: 63.2k, False: 5.86k]
  ------------------
 5514|  63.2k|    input[composition_count] = input[input_count];
 5515|  63.2k|    if (input[input_count] >= hangul_lbase &&
  ------------------
  |  Branch (5515:9): [True: 17.8k, False: 45.4k]
  ------------------
 5516|  17.8k|        input[input_count] < hangul_lbase + hangul_lcount) {
  ------------------
  |  Branch (5516:9): [True: 8.85k, False: 8.99k]
  ------------------
 5517|  8.85k|      if (input_count + 1 < input.size() &&
  ------------------
  |  Branch (5517:11): [True: 8.81k, False: 39]
  ------------------
 5518|  8.81k|          input[input_count + 1] >= hangul_vbase &&
  ------------------
  |  Branch (5518:11): [True: 6.60k, False: 2.21k]
  ------------------
 5519|  6.60k|          input[input_count + 1] < hangul_vbase + hangul_vcount) {
  ------------------
  |  Branch (5519:11): [True: 6.04k, False: 558]
  ------------------
 5520|  6.04k|        input[composition_count] =
 5521|  6.04k|            hangul_sbase +
 5522|  6.04k|            ((input[input_count] - hangul_lbase) * hangul_vcount +
 5523|  6.04k|             input[input_count + 1] - hangul_vbase) *
 5524|  6.04k|                hangul_tcount;
 5525|  6.04k|        input_count++;
 5526|  6.04k|        if (input_count + 1 < input.size() &&
  ------------------
  |  Branch (5526:13): [True: 5.89k, False: 150]
  ------------------
 5527|  5.89k|            input[input_count + 1] > hangul_tbase &&
  ------------------
  |  Branch (5527:13): [True: 4.05k, False: 1.83k]
  ------------------
 5528|  4.05k|            input[input_count + 1] < hangul_tbase + hangul_tcount) {
  ------------------
  |  Branch (5528:13): [True: 3.55k, False: 501]
  ------------------
 5529|  3.55k|          input[composition_count] += input[++input_count] - hangul_tbase;
 5530|  3.55k|        }
 5531|  6.04k|      }
 5532|  54.3k|    } else if (input[input_count] >= hangul_sbase &&
  ------------------
  |  Branch (5532:16): [True: 2.63k, False: 51.7k]
  ------------------
 5533|  2.63k|               input[input_count] < hangul_sbase + hangul_scount) {
  ------------------
  |  Branch (5533:16): [True: 0, False: 2.63k]
  ------------------
 5534|      0|      if ((input[input_count] - hangul_sbase) % hangul_tcount &&
  ------------------
  |  Branch (5534:11): [True: 0, False: 0]
  ------------------
 5535|      0|          input_count + 1 < input.size() &&
  ------------------
  |  Branch (5535:11): [True: 0, False: 0]
  ------------------
 5536|      0|          input[input_count + 1] > hangul_tbase &&
  ------------------
  |  Branch (5536:11): [True: 0, False: 0]
  ------------------
 5537|      0|          input[input_count + 1] < hangul_tbase + hangul_tcount) {
  ------------------
  |  Branch (5537:11): [True: 0, False: 0]
  ------------------
 5538|      0|        input[composition_count] += input[++input_count] - hangul_tbase;
 5539|      0|      }
 5540|  54.3k|    } else if (input[input_count] < 0x110000) {
  ------------------
  |  Branch (5540:16): [True: 54.3k, False: 0]
  ------------------
 5541|  54.3k|      const uint16_t* composition =
 5542|  54.3k|          composition_block_row(composition_index[input[input_count] >> 8]) +
 5543|  54.3k|          (input[input_count] % 256);
 5544|  54.3k|      size_t initial_composition_count = composition_count;
 5545|  76.6k|      for (int32_t previous_ccc = -1; input_count + 1 < input.size();
  ------------------
  |  Branch (5545:39): [True: 70.9k, False: 5.63k]
  ------------------
 5546|  70.9k|           input_count++) {
 5547|  70.9k|        uint8_t ccc = get_ccc(input[input_count + 1]);
 5548|       |
 5549|  70.9k|        if (composition[1] != composition[0] && previous_ccc < ccc) {
  ------------------
  |  Branch (5549:13): [True: 30.0k, False: 40.9k]
  |  Branch (5549:49): [True: 26.5k, False: 3.54k]
  ------------------
 5550|  26.5k|          int left = composition[0];
 5551|  26.5k|          int right = composition[1];
 5552|  26.5k|          if (left < 0 || right < left ||
  ------------------
  |  Branch (5552:15): [True: 0, False: 26.5k]
  |  Branch (5552:27): [True: 0, False: 26.5k]
  ------------------
 5553|  26.5k|              static_cast<size_t>(right) > composition_data_size) {
  ------------------
  |  Branch (5553:15): [True: 0, False: 26.5k]
  ------------------
 5554|      0|            break;
 5555|      0|          }
 5556|  68.3k|          while (left + 2 < right) {
  ------------------
  |  Branch (5556:18): [True: 41.8k, False: 26.5k]
  ------------------
 5557|  41.8k|            int middle = left + (((right - left) >> 1) & ~1);
 5558|  41.8k|            if (composition_data[static_cast<size_t>(middle)] <=
  ------------------
  |  Branch (5558:17): [True: 22.5k, False: 19.3k]
  ------------------
 5559|  41.8k|                input[input_count + 1]) {
 5560|  22.5k|              left = middle;
 5561|  22.5k|            }
 5562|  41.8k|            if (composition_data[static_cast<size_t>(middle)] >=
  ------------------
  |  Branch (5562:17): [True: 27.8k, False: 13.9k]
  ------------------
 5563|  41.8k|                input[input_count + 1]) {
 5564|  27.8k|              right = middle;
 5565|  27.8k|            }
 5566|  41.8k|          }
 5567|  26.5k|          if (static_cast<size_t>(left + 1) < composition_data_size &&
  ------------------
  |  Branch (5567:15): [True: 26.5k, False: 0]
  ------------------
 5568|  26.5k|              composition_data[static_cast<size_t>(left)] ==
  ------------------
  |  Branch (5568:15): [True: 10.7k, False: 15.7k]
  ------------------
 5569|  26.5k|                  input[input_count + 1]) {
 5570|  10.7k|            char32_t composed = composition_data[static_cast<size_t>(left + 1)];
 5571|  10.7k|            input[initial_composition_count] = composed;
 5572|  10.7k|            composition =
 5573|  10.7k|                composition_block_row(composition_index[composed >> 8]) +
 5574|  10.7k|                (composed % 256);
 5575|  10.7k|            continue;
 5576|  10.7k|          }
 5577|  26.5k|        }
 5578|       |
 5579|  60.2k|        if (ccc == 0) {
  ------------------
  |  Branch (5579:13): [True: 48.7k, False: 11.4k]
  ------------------
 5580|  48.7k|          break;
 5581|  48.7k|        }
 5582|  11.4k|        previous_ccc = ccc;
 5583|  11.4k|        input[++composition_count] = input[input_count + 1];
 5584|  11.4k|      }
 5585|  54.3k|    }
 5586|  63.2k|  }
 5587|       |
 5588|  5.86k|  if (composition_count < input_count) {
  ------------------
  |  Branch (5588:7): [True: 5.49k, False: 378]
  ------------------
 5589|  5.49k|    input.resize(composition_count);
 5590|  5.49k|  }
 5591|  5.86k|}
_ZN3ada4idna9normalizeERNSt3__112basic_stringIDiNS1_11char_traitsIDiEENS1_9allocatorIDiEEEE:
 5593|  5.86k|bool normalize(std::u32string& input) {
 5594|       |  /**
 5595|       |   * Normalize the characters according to IDNA (Unicode Normalization Form C).
 5596|       |   * @see https://www.unicode.org/reports/tr46/#ProcessingStepNormalize
 5597|       |   */
 5598|  5.86k|  if (!ensure_tables() || decomposition_index == nullptr ||
  ------------------
  |  Branch (5598:7): [True: 0, False: 5.86k]
  |  Branch (5598:27): [True: 0, False: 5.86k]
  ------------------
 5599|  5.86k|      composition_index == nullptr) {
  ------------------
  |  Branch (5599:7): [True: 0, False: 5.86k]
  ------------------
 5600|      0|    return false;
 5601|      0|  }
 5602|  5.86k|  if (is_already_nfc(input)) {
  ------------------
  |  Branch (5602:7): [True: 0, False: 5.86k]
  ------------------
 5603|      0|    return true;
 5604|      0|  }
 5605|  5.86k|  decompose_nfc(input);
 5606|  5.86k|  compose(input);
 5607|  5.86k|  return true;
 5608|  5.86k|}
_ZN3ada4idna17punycode_to_utf32ENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEERNS1_12basic_stringIDiNS3_IDiEENS1_9allocatorIDiEEEE:
 5668|  8.34k|bool punycode_to_utf32(std::string_view input, std::u32string &out) {
 5669|  8.34k|  int32_t written_out{0};
 5670|  8.34k|  out.reserve(out.size() + input.size());
 5671|  8.34k|  uint32_t n = initial_n;
 5672|  8.34k|  int32_t i = 0;
 5673|  8.34k|  int32_t bias = initial_bias;
 5674|       |  // grab ascii content
 5675|  8.34k|  size_t end_of_ascii = input.find_last_of('-');
 5676|  8.34k|  if (end_of_ascii != std::string_view::npos) {
  ------------------
  |  Branch (5676:7): [True: 1.62k, False: 6.72k]
  ------------------
 5677|  10.3k|    for (uint8_t c : input.substr(0, end_of_ascii)) {
  ------------------
  |  Branch (5677:20): [True: 10.3k, False: 1.62k]
  ------------------
 5678|  10.3k|      if (c >= 0x80) {
  ------------------
  |  Branch (5678:11): [True: 0, False: 10.3k]
  ------------------
 5679|      0|        return false;
 5680|      0|      }
 5681|  10.3k|      out.push_back(c);
 5682|  10.3k|      written_out++;
 5683|  10.3k|    }
 5684|  1.62k|    input.remove_prefix(end_of_ascii + 1);
 5685|  1.62k|  }
 5686|  78.3k|  while (!input.empty()) {
  ------------------
  |  Branch (5686:10): [True: 70.3k, False: 7.98k]
  ------------------
 5687|  70.3k|    int32_t oldi = i;
 5688|  70.3k|    int32_t w = 1;
 5689|  99.2k|    for (int32_t k = base;; k += base) {
 5690|  99.2k|      if (input.empty()) {
  ------------------
  |  Branch (5690:11): [True: 198, False: 99.0k]
  ------------------
 5691|    198|        return false;
 5692|    198|      }
 5693|  99.0k|      uint8_t code_point = input.front();
 5694|  99.0k|      input.remove_prefix(1);
 5695|  99.0k|      int32_t digit = char_to_digit_value(code_point);
 5696|  99.0k|      if (digit < 0) {
  ------------------
  |  Branch (5696:11): [True: 69, False: 99.0k]
  ------------------
 5697|     69|        return false;
 5698|     69|      }
 5699|  99.0k|      if (digit > (0x7fffffff - i) / w) {
  ------------------
  |  Branch (5699:11): [True: 15, False: 98.9k]
  ------------------
 5700|     15|        return false;
 5701|     15|      }
 5702|  98.9k|      i = i + digit * w;
 5703|  98.9k|      int32_t t = k <= bias ? tmin : k >= bias + tmax ? tmax : k - bias;
  ------------------
  |  Branch (5703:19): [True: 21.0k, False: 77.9k]
  |  Branch (5703:38): [True: 73.0k, False: 4.89k]
  ------------------
 5704|  98.9k|      if (digit < t) {
  ------------------
  |  Branch (5704:11): [True: 70.1k, False: 28.8k]
  ------------------
 5705|  70.1k|        break;
 5706|  70.1k|      }
 5707|  28.8k|      if (w > 0x7fffffff / (base - t)) {
  ------------------
  |  Branch (5707:11): [True: 0, False: 28.8k]
  ------------------
 5708|      0|        return false;
 5709|      0|      }
 5710|  28.8k|      w = w * (base - t);
 5711|  28.8k|    }
 5712|  70.1k|    bias = adapt(i - oldi, written_out + 1, oldi == 0);
 5713|  70.1k|    if (i / (written_out + 1) > int32_t(0x7fffffff - n)) {
  ------------------
  |  Branch (5713:9): [True: 78, False: 70.0k]
  ------------------
 5714|     78|      return false;
 5715|     78|    }
 5716|  70.0k|    n = n + i / (written_out + 1);
 5717|  70.0k|    i = i % (written_out + 1);
 5718|  70.0k|    if (n < 0x80) {
  ------------------
  |  Branch (5718:9): [True: 0, False: 70.0k]
  ------------------
 5719|      0|      return false;
 5720|      0|    }
 5721|  70.0k|    out.insert(out.begin() + i, n);
 5722|  70.0k|    written_out++;
 5723|  70.0k|    ++i;
 5724|  70.0k|  }
 5725|       |  // See https://github.com/whatwg/url/issues/803
 5726|       |  // Reject labels whose decoded form begins with "xn--" (double-encoded ACE).
 5727|  7.98k|  if (out.size() >= 4 && out[0] == U'x' && out[1] == U'n' && out[2] == U'-' &&
  ------------------
  |  Branch (5727:7): [True: 2.54k, False: 5.44k]
  |  Branch (5727:26): [True: 573, False: 1.97k]
  |  Branch (5727:44): [True: 363, False: 210]
  |  Branch (5727:62): [True: 165, False: 198]
  ------------------
 5728|    165|      out[3] == U'-') {
  ------------------
  |  Branch (5728:7): [True: 9, False: 156]
  ------------------
 5729|      9|    return false;
 5730|      9|  }
 5731|  7.98k|  return true;
 5732|  7.98k|}
_ZN3ada4idna17utf32_to_punycodeENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEERNS1_12basic_stringIcNS3_IcEENS1_9allocatorIcEEEE:
 5812|  38.3k|bool utf32_to_punycode(std::u32string_view input, std::string &out) {
 5813|  38.3k|  out.reserve(input.size() + out.size());
 5814|  38.3k|  uint32_t n = initial_n;
 5815|  38.3k|  int32_t d = 0;
 5816|  38.3k|  int32_t bias = initial_bias;
 5817|  38.3k|  size_t h = 0;
 5818|       |  // first push the ascii content
 5819|   238k|  for (uint32_t c : input) {
  ------------------
  |  Branch (5819:19): [True: 238k, False: 38.3k]
  ------------------
 5820|   238k|    if (c < 0x80) {
  ------------------
  |  Branch (5820:9): [True: 31.6k, False: 207k]
  ------------------
 5821|  31.6k|      ++h;
 5822|  31.6k|      out.push_back(char(c));
 5823|  31.6k|    }
 5824|   238k|    if (c > 0x10ffff || (c >= 0xd800 && c < 0xe000)) {
  ------------------
  |  Branch (5824:9): [True: 0, False: 238k]
  |  Branch (5824:26): [True: 2.31k, False: 236k]
  |  Branch (5824:41): [True: 0, False: 2.31k]
  ------------------
 5825|      0|      return false;
 5826|      0|    }
 5827|   238k|  }
 5828|  38.3k|  size_t b = h;
 5829|  38.3k|  if (b > 0) {
  ------------------
  |  Branch (5829:7): [True: 5.92k, False: 32.4k]
  ------------------
 5830|  5.92k|    out.push_back('-');
 5831|  5.92k|  }
 5832|   167k|  while (h < input.size()) {
  ------------------
  |  Branch (5832:10): [True: 129k, False: 38.3k]
  ------------------
 5833|   129k|    uint32_t m = 0x10FFFF;
 5834|  1.66M|    for (auto code_point : input) {
  ------------------
  |  Branch (5834:26): [True: 1.66M, False: 129k]
  ------------------
 5835|  1.66M|      if (code_point >= n && code_point < m) m = code_point;
  ------------------
  |  Branch (5835:11): [True: 774k, False: 891k]
  |  Branch (5835:30): [True: 221k, False: 552k]
  ------------------
 5836|  1.66M|    }
 5837|       |
 5838|   129k|    if ((m - n) > (0x7fffffff - d) / (h + 1)) {
  ------------------
  |  Branch (5838:9): [True: 0, False: 129k]
  ------------------
 5839|      0|      return false;
 5840|      0|    }
 5841|   129k|    d = d + int32_t((m - n) * (h + 1));
 5842|   129k|    n = m;
 5843|  1.66M|    for (auto c : input) {
  ------------------
  |  Branch (5843:17): [True: 1.66M, False: 129k]
  ------------------
 5844|  1.66M|      if (c < n) {
  ------------------
  |  Branch (5844:11): [True: 891k, False: 774k]
  ------------------
 5845|   891k|        if (d == 0x7fffffff) {
  ------------------
  |  Branch (5845:13): [True: 0, False: 891k]
  ------------------
 5846|      0|          return false;
 5847|      0|        }
 5848|   891k|        ++d;
 5849|   891k|      }
 5850|  1.66M|      if (c == n) {
  ------------------
  |  Branch (5850:11): [True: 207k, False: 1.45M]
  ------------------
 5851|   207k|        int32_t q = d;
 5852|   503k|        for (int32_t k = base;; k += base) {
 5853|   503k|          int32_t t = k <= bias ? tmin : k >= bias + tmax ? tmax : k - bias;
  ------------------
  |  Branch (5853:23): [True: 134k, False: 368k]
  |  Branch (5853:42): [True: 283k, False: 85.2k]
  ------------------
 5854|       |
 5855|   503k|          if (q < t) {
  ------------------
  |  Branch (5855:15): [True: 207k, False: 296k]
  ------------------
 5856|   207k|            break;
 5857|   207k|          }
 5858|   296k|          out.push_back(digit_to_char(t + ((q - t) % (base - t))));
 5859|   296k|          q = (q - t) / (base - t);
 5860|   296k|        }
 5861|   207k|        out.push_back(digit_to_char(q));
 5862|   207k|        bias = adapt(d, int32_t(h + 1), h == b);
 5863|   207k|        d = 0;
 5864|   207k|        ++h;
 5865|   207k|      }
 5866|  1.66M|    }
 5867|   129k|    ++d;
 5868|   129k|    ++n;
 5869|   129k|  }
 5870|  38.3k|  return true;
 5871|  38.3k|}
_ZN3ada4idna14is_label_validENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 5955|  46.8k|bool is_label_valid(const std::u32string_view label) {
 5956|  46.8k|  if (label.empty()) {
  ------------------
  |  Branch (5956:7): [True: 0, False: 46.8k]
  ------------------
 5957|      0|    return true;
 5958|      0|  }
 5959|  46.8k|  if (!ensure_tables() || combining_ranges == nullptr || dir_start == nullptr ||
  ------------------
  |  Branch (5959:7): [True: 0, False: 46.8k]
  |  Branch (5959:27): [True: 0, False: 46.8k]
  |  Branch (5959:58): [True: 0, False: 46.8k]
  ------------------
 5960|  46.8k|      dir_final == nullptr || dir_value == nullptr) {
  ------------------
  |  Branch (5960:7): [True: 0, False: 46.8k]
  |  Branch (5960:31): [True: 0, False: 46.8k]
  ------------------
 5961|      0|    return false;
 5962|      0|  }
 5963|       |
 5964|       |  ///////////////
 5965|       |  // We have a normalization step which ensures that we are in NFC.
 5966|       |  // If we receive punycode, we normalize and check that the normalized
 5967|       |  // version matches the original.
 5968|       |  // --------------------------------------
 5969|       |  // The label must be in Unicode Normalization Form NFC.
 5970|       |
 5971|       |  // Current URL standard indicatest that CheckHyphens is set to false.
 5972|       |  // ---------------------------------------
 5973|       |  // If CheckHyphens, the label must not contain a U+002D HYPHEN-MINUS character
 5974|       |  // in both the third and fourth positions. If CheckHyphens, the label must
 5975|       |  // neither begin nor end with a U+002D HYPHEN-MINUS character.
 5976|       |
 5977|       |  // This is not necessary because we segment the
 5978|       |  // labels by '.'.
 5979|       |  // ---------------------------------------
 5980|       |  // The label must not contain a U+002E ( . ) FULL STOP.
 5981|       |  // if (label.find('.') != std::string_view::npos) return false;
 5982|       |
 5983|       |  // The label must not begin with a combining mark.
 5984|       |  // Range membership via lower_bound on range end.
 5985|  46.8k|  const std::span<const uint32_t[2]> comb_span{combining_ranges,
 5986|  46.8k|                                               combining_range_count};
 5987|  46.8k|  const auto comb_it = std::ranges::lower_bound(
 5988|  46.8k|      comb_span, label.front(), {}, [](const auto& range) { return range[1]; });
 5989|  46.8k|  if (comb_it != comb_span.end() && label.front() >= (*comb_it)[0]) {
  ------------------
  |  Branch (5989:7): [True: 46.8k, False: 0]
  |  Branch (5989:7): [True: 204, False: 46.6k]
  |  Branch (5989:37): [True: 204, False: 46.6k]
  ------------------
 5990|    204|    return false;
 5991|    204|  }
 5992|       |  // We verify this next step as part of the mapping:
 5993|       |  // ---------------------------------------------
 5994|       |  // Each code point in the label must only have certain status values
 5995|       |  // according to Section 5, IDNA Mapping Table:
 5996|       |  // - For Transitional Processing, each value must be valid.
 5997|       |  // - For Nontransitional Processing, each value must be either valid or
 5998|       |  // deviation.
 5999|       |
 6000|       |  // If CheckJoiners, the label must satisfy the ContextJ rules from Appendix
 6001|       |  // A, in The Unicode Code Points and Internationalized Domain Names for
 6002|       |  // Applications (IDNA) [IDNA2008].
 6003|  46.6k|  constexpr static uint32_t virama[] = {
 6004|  46.6k|      0x094D,  0x09CD,  0x0A4D,  0x0ACD,  0x0B4D,  0x0BCD,  0x0C4D,  0x0CCD,
 6005|  46.6k|      0x0D3B,  0x0D3C,  0x0D4D,  0x0DCA,  0x0E3A,  0x0EBA,  0x0F84,  0x1039,
 6006|  46.6k|      0x103A,  0x1714,  0x1734,  0x17D2,  0x1A60,  0x1B44,  0x1BAA,  0x1BAB,
 6007|  46.6k|      0x1BF2,  0x1BF3,  0x2D7F,  0xA806,  0xA82C,  0xA8C4,  0xA953,  0xA9C0,
 6008|  46.6k|      0xAAF6,  0xABED,  0x10A3F, 0x11046, 0x1107F, 0x110B9, 0x11133, 0x11134,
 6009|  46.6k|      0x111C0, 0x11235, 0x112EA, 0x1134D, 0x11442, 0x114C2, 0x115BF, 0x1163F,
 6010|  46.6k|      0x116B6, 0x1172B, 0x11839, 0x1193D, 0x1193E, 0x119E0, 0x11A34, 0x11A47,
 6011|  46.6k|      0x11A99, 0x11C3F, 0x11D44, 0x11D45, 0x11D97};
 6012|  46.6k|  constexpr static uint32_t R[] = {
 6013|  46.6k|      0x622, 0x623, 0x624, 0x625, 0x627, 0x629, 0x62f, 0x630, 0x631,
 6014|  46.6k|      0x632, 0x648, 0x671, 0x672, 0x673, 0x675, 0x676, 0x677, 0x688,
 6015|  46.6k|      0x689, 0x68a, 0x68b, 0x68c, 0x68d, 0x68e, 0x68f, 0x690, 0x691,
 6016|  46.6k|      0x692, 0x693, 0x694, 0x695, 0x696, 0x697, 0x698, 0x699, 0x6c0,
 6017|  46.6k|      0x6c3, 0x6c4, 0x6c5, 0x6c6, 0x6c7, 0x6c8, 0x6c9, 0x6ca, 0x6cb,
 6018|  46.6k|      0x6cd, 0x6cf, 0x6d2, 0x6d3, 0x6d5, 0x6ee, 0x6ef, 0x710, 0x715,
 6019|  46.6k|      0x716, 0x717, 0x718, 0x719, 0x71e, 0x728, 0x72a, 0x72c, 0x72f,
 6020|  46.6k|      0x74d, 0x759, 0x75a, 0x75b, 0x854, 0x8aa, 0x8ab, 0x8ac};
 6021|  46.6k|  constexpr static uint32_t L[] = {0xa872};
 6022|  46.6k|  constexpr static uint32_t D[] = {
 6023|  46.6k|      0x620,  0x626,  0x628,  0x62a,  0x62b,  0x62c,  0x62d,  0x62e,  0x633,
 6024|  46.6k|      0x634,  0x635,  0x636,  0x637,  0x638,  0x639,  0x63a,  0x63b,  0x63c,
 6025|  46.6k|      0x63d,  0x63e,  0x63f,  0x641,  0x642,  0x643,  0x644,  0x645,  0x646,
 6026|  46.6k|      0x647,  0x649,  0x64a,  0x66e,  0x66f,  0x678,  0x679,  0x67a,  0x67b,
 6027|  46.6k|      0x67c,  0x67d,  0x67e,  0x67f,  0x680,  0x681,  0x682,  0x683,  0x684,
 6028|  46.6k|      0x685,  0x686,  0x687,  0x69a,  0x69b,  0x69c,  0x69d,  0x69e,  0x69f,
 6029|  46.6k|      0x6a0,  0x6a1,  0x6a2,  0x6a3,  0x6a4,  0x6a5,  0x6a6,  0x6a7,  0x6a8,
 6030|  46.6k|      0x6a9,  0x6aa,  0x6ab,  0x6ac,  0x6ad,  0x6ae,  0x6af,  0x6b0,  0x6b1,
 6031|  46.6k|      0x6b2,  0x6b3,  0x6b4,  0x6b5,  0x6b6,  0x6b7,  0x6b8,  0x6b9,  0x6ba,
 6032|  46.6k|      0x6bb,  0x6bc,  0x6bd,  0x6be,  0x6bf,  0x6c1,  0x6c2,  0x6cc,  0x6ce,
 6033|  46.6k|      0x6d0,  0x6d1,  0x6fa,  0x6fb,  0x6fc,  0x6ff,  0x712,  0x713,  0x714,
 6034|  46.6k|      0x71a,  0x71b,  0x71c,  0x71d,  0x71f,  0x720,  0x721,  0x722,  0x723,
 6035|  46.6k|      0x724,  0x725,  0x726,  0x727,  0x729,  0x72b,  0x72d,  0x72e,  0x74e,
 6036|  46.6k|      0x74f,  0x750,  0x751,  0x752,  0x753,  0x754,  0x755,  0x756,  0x757,
 6037|  46.6k|      0x758,  0x75c,  0x75d,  0x75e,  0x75f,  0x760,  0x761,  0x762,  0x763,
 6038|  46.6k|      0x764,  0x765,  0x766,  0x850,  0x851,  0x852,  0x853,  0x855,  0x8a0,
 6039|  46.6k|      0x8a2,  0x8a3,  0x8a4,  0x8a5,  0x8a6,  0x8a7,  0x8a8,  0x8a9,  0x1807,
 6040|  46.6k|      0x1820, 0x1821, 0x1822, 0x1823, 0x1824, 0x1825, 0x1826, 0x1827, 0x1828,
 6041|  46.6k|      0x1829, 0x182a, 0x182b, 0x182c, 0x182d, 0x182e, 0x182f, 0x1830, 0x1831,
 6042|  46.6k|      0x1832, 0x1833, 0x1834, 0x1835, 0x1836, 0x1837, 0x1838, 0x1839, 0x183a,
 6043|  46.6k|      0x183b, 0x183c, 0x183d, 0x183e, 0x183f, 0x1840, 0x1841, 0x1842, 0x1843,
 6044|  46.6k|      0x1844, 0x1845, 0x1846, 0x1847, 0x1848, 0x1849, 0x184a, 0x184b, 0x184c,
 6045|  46.6k|      0x184d, 0x184e, 0x184f, 0x1850, 0x1851, 0x1852, 0x1853, 0x1854, 0x1855,
 6046|  46.6k|      0x1856, 0x1857, 0x1858, 0x1859, 0x185a, 0x185b, 0x185c, 0x185d, 0x185e,
 6047|  46.6k|      0x185f, 0x1860, 0x1861, 0x1862, 0x1863, 0x1864, 0x1865, 0x1866, 0x1867,
 6048|  46.6k|      0x1868, 0x1869, 0x186a, 0x186b, 0x186c, 0x186d, 0x186e, 0x186f, 0x1870,
 6049|  46.6k|      0x1871, 0x1872, 0x1873, 0x1874, 0x1875, 0x1876, 0x1877, 0x1887, 0x1888,
 6050|  46.6k|      0x1889, 0x188a, 0x188b, 0x188c, 0x188d, 0x188e, 0x188f, 0x1890, 0x1891,
 6051|  46.6k|      0x1892, 0x1893, 0x1894, 0x1895, 0x1896, 0x1897, 0x1898, 0x1899, 0x189a,
 6052|  46.6k|      0x189b, 0x189c, 0x189d, 0x189e, 0x189f, 0x18a0, 0x18a1, 0x18a2, 0x18a3,
 6053|  46.6k|      0x18a4, 0x18a5, 0x18a6, 0x18a7, 0x18a8, 0x18aa, 0xa840, 0xa841, 0xa842,
 6054|  46.6k|      0xa843, 0xa844, 0xa845, 0xa846, 0xa847, 0xa848, 0xa849, 0xa84a, 0xa84b,
 6055|  46.6k|      0xa84c, 0xa84d, 0xa84e, 0xa84f, 0xa850, 0xa851, 0xa852, 0xa853, 0xa854,
 6056|  46.6k|      0xa855, 0xa856, 0xa857, 0xa858, 0xa859, 0xa85a, 0xa85b, 0xa85c, 0xa85d,
 6057|  46.6k|      0xa85e, 0xa85f, 0xa860, 0xa861, 0xa862, 0xa863, 0xa864, 0xa865, 0xa866,
 6058|  46.6k|      0xa867, 0xa868, 0xa869, 0xa86a, 0xa86b, 0xa86c, 0xa86d, 0xa86e, 0xa86f,
 6059|  46.6k|      0xa870, 0xa871};
 6060|       |
 6061|   315k|  for (size_t i = 0; i < label.size(); i++) {
  ------------------
  |  Branch (6061:22): [True: 272k, False: 43.4k]
  ------------------
 6062|   272k|    uint32_t c = label[i];
 6063|   272k|    if (c == 0x200c) {
  ------------------
  |  Branch (6063:9): [True: 2.30k, False: 269k]
  ------------------
 6064|  2.30k|      if (i > 0) {
  ------------------
  |  Branch (6064:11): [True: 2.29k, False: 9]
  ------------------
 6065|  2.29k|        if (std::ranges::binary_search(virama, label[i - 1])) {
  ------------------
  |  Branch (6065:13): [True: 213, False: 2.07k]
  ------------------
 6066|    213|          return true;
 6067|    213|        }
 6068|  2.29k|      }
 6069|  2.08k|      if ((i == 0) || (i + 1 >= label.size())) {
  ------------------
  |  Branch (6069:11): [True: 9, False: 2.07k]
  |  Branch (6069:23): [True: 189, False: 1.89k]
  ------------------
 6070|    198|        return false;
 6071|    198|      }
 6072|       |      // we go backward looking for L or D
 6073|  1.89k|      auto is_l_or_d = [](uint32_t code) {
 6074|  1.89k|        return std::ranges::binary_search(L, code) ||
 6075|  1.89k|               std::ranges::binary_search(D, code);
 6076|  1.89k|      };
 6077|  1.89k|      auto is_r_or_d = [](uint32_t code) {
 6078|  1.89k|        return std::ranges::binary_search(R, code) ||
 6079|  1.89k|               std::ranges::binary_search(D, code);
 6080|  1.89k|      };
 6081|  1.89k|      std::u32string_view before = label.substr(0, i);
 6082|  1.89k|      std::u32string_view after = label.substr(i + 1);
 6083|  1.89k|      return (std::find_if(before.begin(), before.end(), is_l_or_d) !=
  ------------------
  |  Branch (6083:14): [True: 1.74k, False: 150]
  ------------------
 6084|  1.89k|              before.end()) &&
 6085|  1.74k|             (std::find_if(after.begin(), after.end(), is_r_or_d) !=
  ------------------
  |  Branch (6085:14): [True: 1.43k, False: 303]
  ------------------
 6086|  1.74k|              after.end());
 6087|   269k|    } else if (c == 0x200d) {
  ------------------
  |  Branch (6087:16): [True: 918, False: 268k]
  ------------------
 6088|    918|      if (i > 0) {
  ------------------
  |  Branch (6088:11): [True: 891, False: 27]
  ------------------
 6089|    891|        if (std::ranges::binary_search(virama, label[i - 1])) {
  ------------------
  |  Branch (6089:13): [True: 756, False: 135]
  ------------------
 6090|    756|          return true;
 6091|    756|        }
 6092|    891|      }
 6093|    162|      return false;
 6094|    918|    }
 6095|   272k|  }
 6096|       |
 6097|       |  // If CheckBidi, and if the domain name is a  Bidi domain name, then the label
 6098|       |  // must satisfy all six of the numbered conditions in [IDNA2008] RFC 5893,
 6099|       |  // Section 2.
 6100|       |
 6101|       |  // The following rule, consisting of six conditions, applies to labels
 6102|       |  // in Bidi domain names.  The requirements that this rule satisfies are
 6103|       |  // described in Section 3.  All of the conditions must be satisfied for
 6104|       |  // the rule to be satisfied.
 6105|       |  //
 6106|       |  //  1.  The first character must be a character with Bidi property L, R,
 6107|       |  //     or AL.  If it has the R or AL property, it is an RTL label; if it
 6108|       |  //     has the L property, it is an LTR label.
 6109|       |  //
 6110|       |  //  2.  In an RTL label, only characters with the Bidi properties R, AL,
 6111|       |  //      AN, EN, ES, CS, ET, ON, BN, or NSM are allowed.
 6112|       |  //
 6113|       |  //   3.  In an RTL label, the end of the label must be a character with
 6114|       |  //       Bidi property R, AL, EN, or AN, followed by zero or more
 6115|       |  //       characters with Bidi property NSM.
 6116|       |  //
 6117|       |  //   4.  In an RTL label, if an EN is present, no AN may be present, and
 6118|       |  //       vice versa.
 6119|       |  //
 6120|       |  //  5.  In an LTR label, only characters with the Bidi properties L, EN,
 6121|       |  //       ES, CS, ET, ON, BN, or NSM are allowed.
 6122|       |  //
 6123|       |  //   6.  In an LTR label, the end of the label must be a character with
 6124|       |  //       Bidi property L or EN, followed by zero or more characters with
 6125|       |  //       Bidi property NSM.
 6126|       |
 6127|  43.4k|  size_t last_non_nsm_char = find_last_not_of_nsm(label);
 6128|  43.4k|  if (last_non_nsm_char == std::u32string_view::npos) {
  ------------------
  |  Branch (6128:7): [True: 0, False: 43.4k]
  ------------------
 6129|      0|    return false;
 6130|      0|  }
 6131|       |
 6132|       |  // A "Bidi domain name" is a domain name that contains at least one RTL label.
 6133|       |  // The following rule, consisting of six conditions, applies to labels in Bidi
 6134|       |  // domain names.
 6135|  43.4k|  if (is_rtl_label(label)) {
  ------------------
  |  Branch (6135:7): [True: 6.55k, False: 36.9k]
  ------------------
 6136|       |    // The first character must be a character with Bidi property L, R,
 6137|       |    // or AL. If it has the R or AL property, it is an RTL label; if it
 6138|       |    // has the L property, it is an LTR label.
 6139|       |
 6140|  6.55k|    if (find_direction(label[0]) == direction::L) {
  ------------------
  |  Branch (6140:9): [True: 498, False: 6.05k]
  ------------------
 6141|       |      // Eval as LTR
 6142|       |
 6143|       |      // In an LTR label, only characters with the Bidi properties L, EN,
 6144|       |      // ES, CS, ET, ON, BN, or NSM are allowed.
 6145|  10.9k|      for (size_t i = 0; i <= last_non_nsm_char; i++) {
  ------------------
  |  Branch (6145:26): [True: 10.9k, False: 0]
  ------------------
 6146|  10.9k|        const direction d = find_direction(label[i]);
 6147|  10.9k|        if (!(d == direction::L || d == direction::EN || d == direction::ES ||
  ------------------
  |  Branch (6147:15): [True: 2.55k, False: 8.40k]
  |  Branch (6147:36): [True: 1.27k, False: 7.12k]
  |  Branch (6147:58): [True: 981, False: 6.14k]
  ------------------
 6148|  6.14k|              d == direction::CS || d == direction::ET || d == direction::ON ||
  ------------------
  |  Branch (6148:15): [True: 1.13k, False: 5.01k]
  |  Branch (6148:37): [True: 1.00k, False: 4.01k]
  |  Branch (6148:59): [True: 1.08k, False: 2.93k]
  ------------------
 6149|  2.93k|              d == direction::BN || d == direction::NSM)) {
  ------------------
  |  Branch (6149:15): [True: 1.20k, False: 1.72k]
  |  Branch (6149:37): [True: 1.23k, False: 498]
  ------------------
 6150|    498|          return false;
 6151|    498|        }
 6152|  10.9k|      }
 6153|       |
 6154|      0|      const direction last_dir = find_direction(label[last_non_nsm_char]);
 6155|      0|      if (!(last_dir == direction::L || last_dir == direction::EN)) {
  ------------------
  |  Branch (6155:13): [True: 0, False: 0]
  |  Branch (6155:41): [True: 0, False: 0]
  ------------------
 6156|      0|        return false;
 6157|      0|      }
 6158|       |
 6159|      0|      return true;
 6160|       |
 6161|  6.05k|    } else {
 6162|       |      // Eval as RTL
 6163|       |
 6164|       |      // The first character must be R or AL; a leading AN (or any other
 6165|       |      // direction) does not start a valid RTL label.
 6166|  6.05k|      const direction first_dir = find_direction(label[0]);
 6167|  6.05k|      if (first_dir != direction::R && first_dir != direction::AL) {
  ------------------
  |  Branch (6167:11): [True: 4.52k, False: 1.53k]
  |  Branch (6167:40): [True: 99, False: 4.42k]
  ------------------
 6168|     99|        return false;
 6169|     99|      }
 6170|       |
 6171|  5.95k|      bool has_an = false;
 6172|  5.95k|      bool has_en = false;
 6173|  27.0k|      for (size_t i = 0; i <= last_non_nsm_char; i++) {
  ------------------
  |  Branch (6173:26): [True: 21.5k, False: 5.44k]
  ------------------
 6174|  21.5k|        const direction d = find_direction(label[i]);
 6175|       |
 6176|       |        // In an RTL label, if an EN is present, no AN may be present, and vice
 6177|       |        // versa.
 6178|  21.5k|        if ((d == direction::EN && ((has_en = true) && has_an)) ||
  ------------------
  |  Branch (6178:14): [True: 2.36k, False: 19.2k]
  |  Branch (6178:37): [True: 2.36k, False: 0]
  |  Branch (6178:56): [True: 18, False: 2.34k]
  ------------------
 6179|  21.5k|            (d == direction::AN && ((has_an = true) && has_en))) {
  ------------------
  |  Branch (6179:14): [True: 1.46k, False: 20.1k]
  |  Branch (6179:37): [True: 1.46k, False: 0]
  |  Branch (6179:56): [True: 9, False: 1.45k]
  ------------------
 6180|     27|          return false;
 6181|     27|        }
 6182|       |
 6183|  21.5k|        if (!(d == direction::R || d == direction::AL || d == direction::AN ||
  ------------------
  |  Branch (6183:15): [True: 2.50k, False: 19.0k]
  |  Branch (6183:36): [True: 6.96k, False: 12.0k]
  |  Branch (6183:58): [True: 1.45k, False: 10.6k]
  ------------------
 6184|  10.6k|              d == direction::EN || d == direction::ES || d == direction::CS ||
  ------------------
  |  Branch (6184:15): [True: 2.34k, False: 8.28k]
  |  Branch (6184:37): [True: 1.06k, False: 7.22k]
  |  Branch (6184:59): [True: 1.46k, False: 5.76k]
  ------------------
 6185|  5.76k|              d == direction::ET || d == direction::ON || d == direction::BN ||
  ------------------
  |  Branch (6185:15): [True: 1.14k, False: 4.61k]
  |  Branch (6185:37): [True: 1.33k, False: 3.28k]
  |  Branch (6185:59): [True: 1.90k, False: 1.37k]
  ------------------
 6186|  1.37k|              d == direction::NSM)) {
  ------------------
  |  Branch (6186:15): [True: 1.13k, False: 237]
  ------------------
 6187|    237|          return false;
 6188|    237|        }
 6189|       |
 6190|  21.3k|        if (i == last_non_nsm_char &&
  ------------------
  |  Branch (6190:13): [True: 5.69k, False: 15.6k]
  ------------------
 6191|  5.69k|            !(d == direction::R || d == direction::AL || d == direction::AN ||
  ------------------
  |  Branch (6191:15): [True: 969, False: 4.72k]
  |  Branch (6191:36): [True: 3.43k, False: 1.28k]
  |  Branch (6191:58): [True: 498, False: 789]
  ------------------
 6192|    789|              d == direction::EN)) {
  ------------------
  |  Branch (6192:15): [True: 546, False: 243]
  ------------------
 6193|    243|          return false;
 6194|    243|        }
 6195|  21.3k|      }
 6196|       |
 6197|  5.44k|      return true;
 6198|  5.95k|    }
 6199|  6.55k|  }
 6200|       |
 6201|  36.9k|  return true;
 6202|  43.4k|}
_ZN3ada4idna8to_asciiENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEERNS1_12basic_stringIcS4_NS1_9allocatorIcEEEE:
 6359|  19.8k|[[nodiscard]] bool to_ascii(std::string_view ut8_string, std::string& out) {
 6360|  19.8k|  out.clear();
 6361|  19.8k|  if (ut8_string.size() > max_domain_input_bytes) {
  ------------------
  |  Branch (6361:7): [True: 0, False: 19.8k]
  ------------------
 6362|      0|    return false;
 6363|      0|  }
 6364|  19.8k|  if (is_ascii(ut8_string)) {
  ------------------
  |  Branch (6364:7): [True: 6.19k, False: 13.6k]
  ------------------
 6365|  6.19k|    from_ascii_to_ascii(ut8_string, out);
 6366|  6.19k|    return true;
 6367|  6.19k|  }
 6368|       |
 6369|       |#ifdef ADA_USE_SIMDUTF
 6370|       |  size_t utf32_length =
 6371|       |      simdutf::utf32_length_from_utf8(ut8_string.data(), ut8_string.size());
 6372|       |  if (utf32_length == 0 && !ut8_string.empty()) {
 6373|       |    return false;
 6374|       |  }
 6375|       |  std::u32string working(utf32_length, U'\0');
 6376|       |  size_t actual_utf32_length = simdutf::convert_utf8_to_utf32(
 6377|       |      ut8_string.data(), ut8_string.size(), working.data());
 6378|       |#else
 6379|  13.6k|  size_t utf32_length =
 6380|  13.6k|      ada::idna::utf32_length_from_utf8(ut8_string.data(), ut8_string.size());
 6381|  13.6k|  if (utf32_length == 0 && !ut8_string.empty()) {
  ------------------
  |  Branch (6381:7): [True: 129, False: 13.5k]
  |  Branch (6381:28): [True: 129, False: 0]
  ------------------
 6382|    129|    return false;
 6383|    129|  }
 6384|  13.5k|  std::u32string working(utf32_length, U'\0');
 6385|  13.5k|  size_t actual_utf32_length = ada::idna::utf8_to_utf32(
 6386|  13.5k|      ut8_string.data(), ut8_string.size(), working.data());
 6387|  13.5k|#endif
 6388|  13.5k|  if (actual_utf32_length == 0 || actual_utf32_length != utf32_length) {
  ------------------
  |  Branch (6388:7): [True: 975, False: 12.5k]
  |  Branch (6388:35): [True: 0, False: 12.5k]
  ------------------
 6389|    975|    return false;
 6390|    975|  }
 6391|  12.5k|  working.resize(actual_utf32_length);
 6392|       |
 6393|       |  // Map into a second buffer with exact sizing (no growth reallocs).
 6394|  12.5k|  std::u32string mapped;
 6395|  12.5k|  if (!ada::idna::map(working, mapped)) {
  ------------------
  |  Branch (6395:7): [True: 108, False: 12.4k]
  ------------------
 6396|    108|    return false;
 6397|    108|  }
 6398|       |  // Drop UTF-32 input; reuse `working` as scratch for ACE validation below.
 6399|  12.4k|  working.clear();
 6400|       |
 6401|       |  // Skip NFC when already normalized (ASCII is a fast subset of this check).
 6402|  12.4k|  if (!is_ascii(mapped) && !is_already_nfc(mapped)) {
  ------------------
  |  Branch (6402:7): [True: 9.47k, False: 2.98k]
  |  Branch (6402:28): [True: 1.73k, False: 7.74k]
  ------------------
 6403|  1.73k|    if (!normalize(mapped)) {
  ------------------
  |  Branch (6403:9): [True: 0, False: 1.73k]
  ------------------
 6404|      0|      return false;
 6405|      0|    }
 6406|  1.73k|  }
 6407|       |
 6408|       |  // Estimate ASCII output size (punycode may expand non-ASCII labels).
 6409|  12.4k|  out.reserve(mapped.size() + 8);
 6410|       |
 6411|       |  // Walk labels with a single pointer scan (no repeated string::find).
 6412|  12.4k|  const char32_t* p = mapped.data();
 6413|  12.4k|  const char32_t* const end = p + mapped.size();
 6414|  12.4k|  std::u32string post_map;
 6415|       |
 6416|  67.8k|  while (p < end) {
  ------------------
  |  Branch (6416:10): [True: 59.4k, False: 8.42k]
  ------------------
 6417|  59.4k|    const char32_t* label_begin = p;
 6418|   562k|    while (p < end && *p != U'.') {
  ------------------
  |  Branch (6418:12): [True: 550k, False: 11.8k]
  |  Branch (6418:23): [True: 503k, False: 47.6k]
  ------------------
 6419|   503k|      ++p;
 6420|   503k|    }
 6421|  59.4k|    const size_t label_size = static_cast<size_t>(p - label_begin);
 6422|  59.4k|    std::u32string_view label_view(label_begin, label_size);
 6423|  59.4k|    const bool is_last_label = (p == end);
 6424|  59.4k|    if (p < end) {
  ------------------
  |  Branch (6424:9): [True: 47.6k, False: 11.8k]
  ------------------
 6425|  47.6k|      ++p;  // skip dot
 6426|  47.6k|    }
 6427|       |
 6428|  59.4k|    if (label_size == 0) {
  ------------------
  |  Branch (6428:9): [True: 4.43k, False: 55.0k]
  ------------------
 6429|       |      // empty label
 6430|  55.0k|    } else if (is_ace_prefix(label_view)) {
  ------------------
  |  Branch (6430:16): [True: 8.39k, False: 46.6k]
  ------------------
 6431|   145k|      for (char32_t c : label_view) {
  ------------------
  |  Branch (6431:23): [True: 145k, False: 8.34k]
  ------------------
 6432|   145k|        if (c >= 0x80) {
  ------------------
  |  Branch (6432:13): [True: 48, False: 145k]
  ------------------
 6433|     48|          out.clear();
 6434|     48|          return false;
 6435|     48|        }
 6436|   145k|      }
 6437|  8.34k|      append_ascii_label(out, label_view);
 6438|  8.34k|      std::string_view puny_segment_ascii(
 6439|  8.34k|          out.data() + (out.size() - label_size) + 4, label_size - 4);
 6440|  8.34k|      working.clear();
 6441|  8.34k|      if (!ada::idna::punycode_to_utf32(puny_segment_ascii, working)) {
  ------------------
  |  Branch (6441:11): [True: 369, False: 7.98k]
  ------------------
 6442|    369|        out.clear();
 6443|    369|        return false;
 6444|    369|      }
 6445|  7.98k|      if (is_ascii(working)) {
  ------------------
  |  Branch (6445:11): [True: 288, False: 7.69k]
  ------------------
 6446|    288|        out.clear();
 6447|    288|        return false;
 6448|    288|      }
 6449|  7.69k|      if (!ada::idna::map(working, post_map) || working != post_map) {
  ------------------
  |  Branch (6449:11): [True: 534, False: 7.15k]
  |  Branch (6449:49): [True: 270, False: 6.88k]
  ------------------
 6450|    804|        out.clear();
 6451|    804|        return false;
 6452|    804|      }
 6453|       |      // Mapping must be stable; NFC must not change the mapped form either.
 6454|  6.88k|      if (!is_ascii(post_map) && !is_already_nfc(post_map)) {
  ------------------
  |  Branch (6454:11): [True: 6.88k, False: 0]
  |  Branch (6454:34): [True: 4.13k, False: 2.75k]
  ------------------
 6455|  4.13k|        if (!normalize(post_map) || post_map != working) {
  ------------------
  |  Branch (6455:13): [True: 0, False: 4.13k]
  |  Branch (6455:37): [True: 408, False: 3.72k]
  ------------------
 6456|    408|          out.clear();
 6457|    408|          return false;
 6458|    408|        }
 6459|  4.13k|      }
 6460|  6.48k|      if (post_map.empty() || !is_label_valid(post_map)) {
  ------------------
  |  Branch (6460:11): [True: 0, False: 6.48k]
  |  Branch (6460:31): [True: 51, False: 6.42k]
  ------------------
 6461|     51|        out.clear();
 6462|     51|        return false;
 6463|     51|      }
 6464|  46.6k|    } else if (is_ascii(label_view)) {
  ------------------
  |  Branch (6464:16): [True: 6.21k, False: 40.4k]
  ------------------
 6465|  6.21k|      append_ascii_label(out, label_view);
 6466|  40.4k|    } else {
 6467|  40.4k|      if (!is_label_valid(label_view)) {
  ------------------
  |  Branch (6467:11): [True: 2.07k, False: 38.3k]
  ------------------
 6468|  2.07k|        out.clear();
 6469|  2.07k|        return false;
 6470|  2.07k|      }
 6471|  38.3k|      out.append("xn--");
 6472|  38.3k|      if (!ada::idna::utf32_to_punycode(label_view, out)) {
  ------------------
  |  Branch (6472:11): [True: 0, False: 38.3k]
  ------------------
 6473|      0|        out.clear();
 6474|      0|        return false;
 6475|      0|      }
 6476|  38.3k|    }
 6477|  55.4k|    if (!is_last_label) {
  ------------------
  |  Branch (6477:9): [True: 47.4k, False: 7.92k]
  ------------------
 6478|  47.4k|      out.push_back('.');
 6479|  47.4k|    }
 6480|  55.4k|  }
 6481|  8.42k|  return true;
 6482|  12.4k|}
_ZN3ada4idna8to_asciiENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 6484|  19.8k|std::string to_ascii(std::string_view ut8_string) {
 6485|  19.8k|  std::string out;
 6486|  19.8k|  if (!to_ascii(ut8_string, out)) {
  ------------------
  |  Branch (6486:7): [True: 5.25k, False: 14.6k]
  ------------------
 6487|  5.25k|    return {};
 6488|  5.25k|  }
 6489|  14.6k|  return out;
 6490|  19.8k|}
_ZN3ada7unicode14percent_encodeILb1EEEbNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEPKhRNS2_12basic_stringIcS5_NS2_9allocatorIcEEEE:
 7349|  2.16k|                    std::string& out) {
 7350|  2.16k|  ada_log("percent_encode ", input, " to output string while ",
 7351|  2.16k|          append ? "appending" : "overwriting");
 7352|  2.16k|  auto pointer = std::ranges::find_if(input, [character_set](const char c) {
 7353|  2.16k|    return character_sets::bit_at(character_set, c);
 7354|  2.16k|  });
 7355|  2.16k|  ada_log("percent_encode done checking, moved to ",
 7356|  2.16k|          std::distance(input.begin(), pointer));
 7357|       |
 7358|       |  // Optimization: Don't iterate if percent encode is not required
 7359|  2.16k|  if (pointer == input.end()) {
  ------------------
  |  Branch (7359:7): [True: 1.44k, False: 724]
  ------------------
 7360|  1.44k|    ada_log("percent_encode encoding not needed.");
 7361|  1.44k|    return false;
 7362|  1.44k|  }
 7363|       |  if constexpr (!append) {
 7364|       |    out.clear();
 7365|       |  }
 7366|    724|  ada_log("percent_encode appending ", std::distance(input.begin(), pointer),
 7367|    724|          " bytes");
 7368|       |  // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
 7369|    724|  out.append(input.data(), std::distance(input.begin(), pointer));
 7370|    724|  ada_log("percent_encode processing ", std::distance(pointer, input.end()),
 7371|    724|          " bytes");
 7372|  17.2k|  for (; pointer != input.end(); pointer++) {
  ------------------
  |  Branch (7372:10): [True: 16.5k, False: 724]
  ------------------
 7373|  16.5k|    if (character_sets::bit_at(character_set, *pointer)) {
  ------------------
  |  Branch (7373:9): [True: 14.6k, False: 1.90k]
  ------------------
 7374|  14.6k|      out.append(character_sets::hex + uint8_t(*pointer) * 4, 3);
 7375|  14.6k|    } else {
 7376|  1.90k|      out += *pointer;
 7377|  1.90k|    }
 7378|  16.5k|  }
 7379|    724|  return true;
 7380|  2.16k|}
_ZN3ada7unicode14percent_encodeILb0EEEbNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEPKhRNS2_12basic_stringIcS5_NS2_9allocatorIcEEEE:
 7349|  28.5k|                    std::string& out) {
 7350|  28.5k|  ada_log("percent_encode ", input, " to output string while ",
 7351|  28.5k|          append ? "appending" : "overwriting");
 7352|  28.5k|  auto pointer = std::ranges::find_if(input, [character_set](const char c) {
 7353|  28.5k|    return character_sets::bit_at(character_set, c);
 7354|  28.5k|  });
 7355|  28.5k|  ada_log("percent_encode done checking, moved to ",
 7356|  28.5k|          std::distance(input.begin(), pointer));
 7357|       |
 7358|       |  // Optimization: Don't iterate if percent encode is not required
 7359|  28.5k|  if (pointer == input.end()) {
  ------------------
  |  Branch (7359:7): [True: 17.3k, False: 11.2k]
  ------------------
 7360|  17.3k|    ada_log("percent_encode encoding not needed.");
 7361|  17.3k|    return false;
 7362|  17.3k|  }
 7363|  11.2k|  if constexpr (!append) {
 7364|  11.2k|    out.clear();
 7365|  11.2k|  }
 7366|  11.2k|  ada_log("percent_encode appending ", std::distance(input.begin(), pointer),
 7367|  11.2k|          " bytes");
 7368|       |  // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
 7369|  11.2k|  out.append(input.data(), std::distance(input.begin(), pointer));
 7370|  11.2k|  ada_log("percent_encode processing ", std::distance(pointer, input.end()),
 7371|  11.2k|          " bytes");
 7372|   118k|  for (; pointer != input.end(); pointer++) {
  ------------------
  |  Branch (7372:10): [True: 107k, False: 11.2k]
  ------------------
 7373|   107k|    if (character_sets::bit_at(character_set, *pointer)) {
  ------------------
  |  Branch (7373:9): [True: 103k, False: 4.43k]
  ------------------
 7374|   103k|      out.append(character_sets::hex + uint8_t(*pointer) * 4, 3);
 7375|   103k|    } else {
 7376|  4.43k|      out += *pointer;
 7377|  4.43k|    }
 7378|   107k|  }
 7379|  11.2k|  return true;
 7380|  28.5k|}
_ZN3ada7unicode14percent_decodeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEm:
 7180|  4.20k|std::string percent_decode(const std::string_view input, size_t first_percent) {
 7181|       |  // next line is for safety only, we expect users to avoid calling
 7182|       |  // percent_decode when first_percent is outside the range.
 7183|  4.20k|  if (first_percent == std::string_view::npos) {
  ------------------
  |  Branch (7183:7): [True: 0, False: 4.20k]
  ------------------
 7184|      0|    return std::string(input);
 7185|      0|  }
 7186|       |
 7187|       |  // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
 7188|  4.20k|  const char* const src = input.data();
 7189|  4.20k|  const char* const end = src + input.size();
 7190|       |
 7191|       |  // Decoding never grows the string, so a single pre-sized buffer written via
 7192|       |  // bulk memcpy of the plain runs (then shrunk to the final length) avoids the
 7193|       |  // byte-at-a-time appends of the naive version.
 7194|  4.20k|  std::string out(input.size(), '\0');
 7195|  4.20k|  char* d = out.data();
 7196|  4.20k|  char* const d0 = d;
 7197|       |
 7198|  4.20k|  std::memcpy(d, src, first_percent);
 7199|  4.20k|  d += first_percent;
 7200|       |
 7201|  4.20k|  const char* p = src + first_percent;
 7202|  20.7k|  while (p < end) {
  ------------------
  |  Branch (7202:10): [True: 16.5k, False: 4.20k]
  ------------------
 7203|  16.5k|    if (*p == '%') {
  ------------------
  |  Branch (7203:9): [True: 10.9k, False: 5.60k]
  ------------------
 7204|       |      // Decode runs of valid %XX tightly (common for nested/encoded URLs).
 7205|  16.3k|      while (p + 2 < end && *p == '%') {
  ------------------
  |  Branch (7205:14): [True: 13.5k, False: 2.74k]
  |  Branch (7205:29): [True: 12.0k, False: 1.55k]
  ------------------
 7206|  12.0k|        if (!is_ascii_hex_digit(p[1]) || !is_ascii_hex_digit(p[2])) {
  ------------------
  |  Branch (7206:13): [True: 4.26k, False: 7.78k]
  |  Branch (7206:42): [True: 2.42k, False: 5.35k]
  ------------------
 7207|  6.68k|          break;
 7208|  6.68k|        }
 7209|  5.35k|        *d++ = static_cast<char>(convert_hex_to_binary(p[1]) * 16 +
 7210|  5.35k|                                 convert_hex_to_binary(p[2]));
 7211|  5.35k|        p += 3;
 7212|  5.35k|      }
 7213|  10.9k|      if (p < end && *p == '%') {
  ------------------
  |  Branch (7213:11): [True: 9.98k, False: 999]
  |  Branch (7213:22): [True: 7.73k, False: 2.24k]
  ------------------
 7214|       |        // Not a valid escape (too few chars left or bad hex): copy '%'
 7215|       |        // literally and keep scanning after it.
 7216|  7.73k|        *d++ = *p++;
 7217|  7.73k|      }
 7218|  10.9k|    } else {
 7219|  5.60k|      const char* q = static_cast<const char*>(
 7220|  5.60k|          std::memchr(p, '%', static_cast<size_t>(end - p)));
 7221|  5.60k|      const char* run_end = q ? q : end;
  ------------------
  |  Branch (7221:29): [True: 3.06k, False: 2.53k]
  ------------------
 7222|  5.60k|      const size_t n = static_cast<size_t>(run_end - p);
 7223|  5.60k|      std::memcpy(d, p, n);
 7224|  5.60k|      d += n;
 7225|  5.60k|      p = run_end;
 7226|  5.60k|    }
 7227|  16.5k|  }
 7228|       |
 7229|  4.20k|  out.resize(static_cast<size_t>(d - d0));
 7230|  4.20k|  return out;
 7231|  4.20k|}
_ZN3ada7unicode14percent_encodeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKh:
 7319|  25.3k|                           const uint8_t character_set[]) {
 7320|  25.3k|  auto pointer = std::ranges::find_if(input, [character_set](const char c) {
 7321|  25.3k|    return character_sets::bit_at(character_set, c);
 7322|  25.3k|  });
 7323|       |  // Optimization: Don't iterate if percent encode is not required
 7324|  25.3k|  if (pointer == input.end()) {
  ------------------
  |  Branch (7324:7): [True: 21.4k, False: 3.87k]
  ------------------
 7325|  21.4k|    return std::string(input);
 7326|  21.4k|  }
 7327|       |
 7328|  3.87k|  std::string result;
 7329|  3.87k|  result.reserve(input.length());  // in the worst case, percent encoding might
 7330|       |                                   // produce 3 characters.
 7331|  3.87k|  result.append(input.substr(0, std::distance(input.begin(), pointer)));
 7332|  3.87k|  if (static_cast<size_t>(input.end() - pointer) >= 48) {
  ------------------
  |  Branch (7332:7): [True: 584, False: 3.28k]
  ------------------
 7333|    584|    percent_encode_suffix(&*pointer, input.data() + input.size(), character_set,
 7334|    584|                          result);
 7335|  3.28k|  } else {
 7336|  24.9k|    for (; pointer != input.end(); pointer++) {
  ------------------
  |  Branch (7336:12): [True: 21.6k, False: 3.28k]
  ------------------
 7337|  21.6k|      if (character_sets::bit_at(character_set, *pointer)) {
  ------------------
  |  Branch (7337:11): [True: 18.9k, False: 2.66k]
  ------------------
 7338|  18.9k|        result.append(character_sets::hex + uint8_t(*pointer) * 4, 3);
 7339|  18.9k|      } else {
 7340|  2.66k|        result += *pointer;
 7341|  2.66k|      }
 7342|  21.6k|    }
 7343|  3.28k|  }
 7344|  3.87k|  return result;
 7345|  25.3k|}
_ZN3ada7unicode8to_asciiERNSt3__18optionalINS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEENS1_17basic_string_viewIcS5_EEm:
 7390|  19.8k|              size_t first_percent) {
 7391|  19.8k|  std::string percent_decoded_buffer;
 7392|  19.8k|  std::string_view input = plain;
 7393|  19.8k|  if (first_percent != std::string_view::npos) {
  ------------------
  |  Branch (7393:7): [True: 1.17k, False: 18.6k]
  ------------------
 7394|  1.17k|    percent_decoded_buffer = unicode::percent_decode(plain, first_percent);
 7395|  1.17k|    input = percent_decoded_buffer;
 7396|  1.17k|  }
 7397|       |  // input is a non-empty UTF-8 string, must be percent decoded
 7398|  19.8k|  std::string idna_ascii = ada::idna::to_ascii(input);
 7399|  19.8k|  if (idna_ascii.empty() || contains_forbidden_domain_code_point(
  ------------------
  |  Branch (7399:7): [True: 5.29k, False: 14.5k]
  |  Branch (7399:29): [True: 1.26k, False: 13.3k]
  ------------------
 7400|  14.5k|                                idna_ascii.data(), idna_ascii.size())) {
 7401|  6.56k|    return false;
 7402|  6.56k|  }
 7403|  13.3k|  out = std::move(idna_ascii);
 7404|  13.3k|  return true;
 7405|  19.8k|}
_ZN3ada7unicode14percent_encodeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKhm:
 7408|    454|                           const uint8_t character_set[], size_t index) {
 7409|    454|  std::string out;
 7410|       |  // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
 7411|    454|  out.append(input.data(), index);
 7412|    454|  auto pointer = input.begin() + index;
 7413|    454|  if (static_cast<size_t>(input.end() - pointer) >= 48) {
  ------------------
  |  Branch (7413:7): [True: 134, False: 320]
  ------------------
 7414|    134|    percent_encode_suffix(&*pointer, input.data() + input.size(), character_set,
 7415|    134|                          out);
 7416|    320|  } else {
 7417|  2.88k|    for (; pointer != input.end(); pointer++) {
  ------------------
  |  Branch (7417:12): [True: 2.56k, False: 320]
  ------------------
 7418|  2.56k|      if (character_sets::bit_at(character_set, *pointer)) {
  ------------------
  |  Branch (7418:11): [True: 2.16k, False: 400]
  ------------------
 7419|  2.16k|        out.append(character_sets::hex + uint8_t(*pointer) * 4, 3);
 7420|  2.16k|      } else {
 7421|    400|        out += *pointer;
 7422|    400|      }
 7423|  2.56k|    }
 7424|    320|  }
 7425|    454|  return out;
 7426|    454|}
_ZN3ada7unicode21percent_encode_suffixEPKcS2_PKhRNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE:
 7720|    718|                           const uint8_t character_set[], std::string& out) {
 7721|    718|#if ADA_UNICODE_SSSE3 || ADA_NEON || ADA_RVV
 7722|    718|  if (static_cast<size_t>(end - p) >= kPercentEncodeSimdMin) {
  ------------------
  |  Branch (7722:7): [True: 718, False: 0]
  ------------------
 7723|    718|    percent_encode_to_wide(p, end, character_set, out);
 7724|    718|    return;
 7725|    718|  }
 7726|      0|#endif
 7727|      0|  percent_encode_to_scalar(p, end, character_set, out);
 7728|      0|}
_ZN3ada11serializers36find_longest_sequence_of_ipv6_piecesERKNSt3__15arrayItLm8EEERmS6_:
 7793|    990|    size_t& compress_length) noexcept {
 7794|    990|  compress = 0;
 7795|    990|  compress_length = 0;
 7796|    990|  size_t i = 0;
 7797|  3.92k|  while (i < 8) {
  ------------------
  |  Branch (7797:10): [True: 2.93k, False: 990]
  ------------------
 7798|  2.93k|    if (address[i] != 0) {
  ------------------
  |  Branch (7798:9): [True: 1.81k, False: 1.11k]
  ------------------
 7799|  1.81k|      ++i;
 7800|  1.81k|      continue;
 7801|  1.81k|    }
 7802|  1.11k|    size_t next = i + 1;
 7803|  6.10k|    while (next < 8 && address[next] == 0) {
  ------------------
  |  Branch (7803:12): [True: 5.52k, False: 582]
  |  Branch (7803:24): [True: 4.98k, False: 531]
  ------------------
 7804|  4.98k|      ++next;
 7805|  4.98k|    }
 7806|  1.11k|    const size_t count = next - i;
 7807|  1.11k|    if (count > compress_length) {
  ------------------
  |  Branch (7807:9): [True: 999, False: 114]
  ------------------
 7808|    999|      compress_length = count;
 7809|    999|      compress = i;
 7810|    999|    }
 7811|  1.11k|    i = next;
 7812|  1.11k|  }
 7813|    990|}
_ZN3ada11serializers4ipv6ERKNSt3__15arrayItLm8EEE:
 7815|    990|std::string ipv6(const std::array<uint16_t, 8>& address) {
 7816|    990|  size_t compress = 0;
 7817|    990|  size_t compress_length = 0;
 7818|    990|  find_longest_sequence_of_ipv6_pieces(address, compress, compress_length);
 7819|       |
 7820|       |  // Skip compression when the longest zero run is a single piece.
 7821|    990|  if (compress_length <= 1) {
  ------------------
  |  Branch (7821:7): [True: 63, False: 927]
  ------------------
 7822|     63|    compress = compress_length = 8;
 7823|     63|  }
 7824|       |
 7825|       |  // Max: '[' + 8*4 hex + 7 ':' + ']' = 41
 7826|    990|  std::string output(4 * 8 + 7 + 2, '\0');
 7827|    990|  char* point = output.data();
 7828|    990|  *point++ = '[';
 7829|    990|  size_t piece_index = 0;
 7830|  2.54k|  while (true) {
  ------------------
  |  Branch (7830:10): [True: 2.54k, Folded]
  ------------------
 7831|  2.54k|    if (piece_index == compress) {
  ------------------
  |  Branch (7831:9): [True: 927, False: 1.61k]
  ------------------
 7832|    927|      *point++ = ':';
 7833|       |      // If we skip a value initially, we need to write '::'.
 7834|    927|      if (piece_index == 0) {
  ------------------
  |  Branch (7834:11): [True: 552, False: 375]
  ------------------
 7835|    552|        *point++ = ':';
 7836|    552|      }
 7837|    927|      piece_index += compress_length;
 7838|    927|      if (piece_index == 8) {
  ------------------
  |  Branch (7838:11): [True: 519, False: 408]
  ------------------
 7839|    519|        break;
 7840|    519|      }
 7841|    927|    }
 7842|  2.02k|    point = write_hex_u16(point, address[piece_index]);
 7843|  2.02k|    ++piece_index;
 7844|  2.02k|    if (piece_index == 8) {
  ------------------
  |  Branch (7844:9): [True: 471, False: 1.55k]
  ------------------
 7845|    471|      break;
 7846|    471|    }
 7847|  1.55k|    *point++ = ':';
 7848|  1.55k|  }
 7849|    990|  *point++ = ']';
 7850|    990|  output.resize(static_cast<size_t>(point - output.data()));
 7851|    990|  return output;
 7852|    990|}
_ZN3ada11serializers4ipv4Em:
 7854|  4.32k|std::string ipv4(const uint64_t address) {
 7855|  4.32k|  std::string output(15, '\0');
 7856|  4.32k|  char* point = output.data();
 7857|  4.32k|  point = write_u8(point, static_cast<uint8_t>(address >> 24));
 7858|  4.32k|  *point++ = '.';
 7859|  4.32k|  point = write_u8(point, static_cast<uint8_t>(address >> 16));
 7860|  4.32k|  *point++ = '.';
 7861|  4.32k|  point = write_u8(point, static_cast<uint8_t>(address >> 8));
 7862|  4.32k|  *point++ = '.';
 7863|  4.32k|  point = write_u8(point, static_cast<uint8_t>(address));
 7864|  4.32k|  output.resize(static_cast<size_t>(point - output.data()));
 7865|  4.32k|  return output;
 7866|  4.32k|}
_ZN3ada5parseINS_3urlEEEN2tl8expectedIT_NS_6errorsEEENSt3__117basic_string_viewIcNS7_11char_traitsIcEEEEPKS4_:
 8268|  47.3k|    std::string_view input, const result_type* base_url) {
 8269|  47.3k|  result_type u = ada::parser::parse_url_impl<result_type>(input, base_url);
 8270|  47.3k|  if (!u.is_valid) {
  ------------------
  |  Branch (8270:7): [True: 24.6k, False: 22.7k]
  ------------------
 8271|  24.6k|    return tl::unexpected(errors::type_error);
 8272|  24.6k|  }
 8273|  22.7k|  return u;
 8274|  47.3k|}
_ZN3ada5parseINS_14url_aggregatorEEEN2tl8expectedIT_NS_6errorsEEENSt3__117basic_string_viewIcNS7_11char_traitsIcEEEEPKS4_:
 8268|  47.3k|    std::string_view input, const result_type* base_url) {
 8269|  47.3k|  result_type u = ada::parser::parse_url_impl<result_type>(input, base_url);
 8270|  47.3k|  if (!u.is_valid) {
  ------------------
  |  Branch (8270:7): [True: 24.6k, False: 22.7k]
  ------------------
 8271|  24.6k|    return tl::unexpected(errors::type_error);
 8272|  24.6k|  }
 8273|  22.7k|  return u;
 8274|  47.3k|}
_ZN3ada20get_max_input_lengthEv:
 7889|   154k|uint32_t get_max_input_length() {
 7890|   154k|  return max_input_length_.load(std::memory_order_relaxed);
 7891|   154k|}
_ZN3ada9can_parseENSt3__117basic_string_viewIcNS0_11char_traitsIcEEEEPKS4_:
 8316|  43.3k|bool can_parse(std::string_view input, const std::string_view* base_input) {
 8317|       |  // Must match parse().has_value(), including post-normalization max length.
 8318|       |  // Percent-encoding expands a byte by at most 3x, but IDNA expands more: a
 8319|       |  // 3-byte UTF-8 label such as U+337F becomes the 17-byte "xn--6oqv20b1zgzxr",
 8320|       |  // so a dotted host sustains 4.5x. When the input (plus base, if any) fits in
 8321|       |  // max_length/5, the normalized href cannot exceed max_length, so
 8322|       |  // validation-only parsing (store_values=false) is safe.
 8323|       |
 8324|       |  // Hot path first: absolute special URLs, no base. Avoid loading max_length
 8325|       |  // until we need it (common absolute-fast true/false cases).
 8326|  43.3k|  if (base_input == nullptr) {
  ------------------
  |  Branch (8326:7): [True: 31.5k, False: 11.8k]
  ------------------
 8327|  31.5k|    auto r = try_can_parse_clean_http(input);
 8328|  31.5k|    if (!r.has_value()) {
  ------------------
  |  Branch (8328:9): [True: 31.3k, False: 240]
  ------------------
 8329|  31.3k|      r = try_can_parse_absolute_fast(input);
 8330|  31.3k|    }
 8331|  31.5k|    if (r.has_value()) {
  ------------------
  |  Branch (8331:9): [True: 17.5k, False: 13.9k]
  ------------------
 8332|  17.5k|      if (!*r) {
  ------------------
  |  Branch (8332:11): [True: 13.0k, False: 4.50k]
  ------------------
 8333|  13.0k|        return false;
 8334|  13.0k|      }
 8335|       |      // size <= max/5 => normalized href cannot exceed max (4.5x expansion).
 8336|       |      // Check this first: default max is ~4GB so almost all URLs return true.
 8337|  4.50k|      const uint32_t max_length = ada::get_max_input_length();
 8338|  4.50k|      if (input.size() <= static_cast<size_t>(max_length) / 5) {
  ------------------
  |  Branch (8338:11): [True: 4.50k, False: 0]
  ------------------
 8339|  4.50k|        return true;
 8340|  4.50k|      }
 8341|      0|      if (input.size() > max_length) {
  ------------------
  |  Branch (8341:11): [True: 0, False: 0]
  ------------------
 8342|      0|        return false;
 8343|      0|      }
 8344|      0|      return ada::parser::parse_url_impl<ada::url_aggregator, true>(input,
 8345|      0|                                                                    nullptr)
 8346|      0|          .is_valid;
 8347|      0|    }
 8348|  31.5k|  }
 8349|       |
 8350|  25.8k|  const uint32_t max_length = ada::get_max_input_length();
 8351|  25.8k|  if (input.size() > max_length) {
  ------------------
  |  Branch (8351:7): [True: 0, False: 25.8k]
  ------------------
 8352|      0|    return false;
 8353|      0|  }
 8354|  25.8k|  if (base_input != nullptr && base_input->size() > max_length) {
  ------------------
  |  Branch (8354:7): [True: 11.8k, False: 13.9k]
  |  Branch (8354:32): [True: 0, False: 11.8k]
  ------------------
 8355|      0|    return false;
 8356|      0|  }
 8357|       |
 8358|       |  // Relative resolution combines base + input; bound the sum so 4.5x expansion
 8359|       |  // of either side cannot push the final href past max_length.
 8360|  25.8k|  const size_t combined =
 8361|  25.8k|      input.size() + (base_input == nullptr ? 0 : base_input->size());
  ------------------
  |  Branch (8361:23): [True: 13.9k, False: 11.8k]
  ------------------
 8362|  25.8k|  const bool size_safe = combined <= static_cast<size_t>(max_length) / 5;
 8363|       |
 8364|  25.8k|  if (size_safe) {
  ------------------
  |  Branch (8364:7): [True: 25.8k, False: 0]
  ------------------
 8365|       |    // Validation-only: no buffer build, host still fully checked.
 8366|  25.8k|    ada::url_aggregator base_agg;
 8367|  25.8k|    ada::url_aggregator* base_ptr = nullptr;
 8368|  25.8k|    if (base_input != nullptr) {
  ------------------
  |  Branch (8368:9): [True: 11.8k, False: 13.9k]
  ------------------
 8369|  11.8k|      base_agg = ada::parser::parse_url_impl<ada::url_aggregator, false>(
 8370|  11.8k|          *base_input, nullptr);
 8371|  11.8k|      if (!base_agg.is_valid) {
  ------------------
  |  Branch (8371:11): [True: 7.87k, False: 3.97k]
  ------------------
 8372|  7.87k|        return false;
 8373|  7.87k|      }
 8374|  3.97k|      base_ptr = &base_agg;
 8375|  3.97k|    }
 8376|  17.9k|    return ada::parser::parse_url_impl<ada::url_aggregator, false>(input,
 8377|  17.9k|                                                                   base_ptr)
 8378|  17.9k|        .is_valid;
 8379|  25.8k|  }
 8380|       |
 8381|       |  // Near the limit: full parse so post-normalization length matches parse().
 8382|      0|  if (base_input == nullptr) {
  ------------------
  |  Branch (8382:7): [True: 0, False: 0]
  ------------------
 8383|      0|    return ada::parser::parse_url_impl<ada::url_aggregator, true>(input,
 8384|      0|                                                                  nullptr)
 8385|      0|        .is_valid;
 8386|      0|  }
 8387|      0|  ada::url_aggregator base_agg =
 8388|      0|      ada::parser::parse_url_impl<ada::url_aggregator, true>(*base_input,
 8389|      0|                                                             nullptr);
 8390|      0|  if (!base_agg.is_valid) {
  ------------------
  |  Branch (8390:7): [True: 0, False: 0]
  ------------------
 8391|      0|    return false;
 8392|      0|  }
 8393|      0|  return ada::parser::parse_url_impl<ada::url_aggregator, true>(input,
 8394|      0|                                                                &base_agg)
 8395|      0|      .is_valid;
 8396|      0|}
_ZN3ada7helpers18trim_c0_whitespaceERNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9243|   115k|void trim_c0_whitespace(std::string_view& input) noexcept {
 9244|   118k|  while (!input.empty() &&
  ------------------
  |  Branch (9244:10): [True: 70.1k, False: 48.2k]
  ------------------
 9245|  70.1k|         ada::unicode::is_c0_control_or_space(input.front())) {
  ------------------
  |  Branch (9245:10): [True: 2.63k, False: 67.5k]
  ------------------
 9246|  2.63k|    input.remove_prefix(1);
 9247|  2.63k|  }
 9248|   118k|  while (!input.empty() && ada::unicode::is_c0_control_or_space(input.back())) {
  ------------------
  |  Branch (9248:10): [True: 70.5k, False: 48.2k]
  |  Branch (9248:28): [True: 3.02k, False: 67.5k]
  ------------------
 9249|  3.02k|    input.remove_suffix(1);
 9250|  3.02k|  }
 9251|   115k|}
_ZN3ada7helpers8overlapsENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEERKNS1_12basic_stringIcS4_NS1_9allocatorIcEEEE:
 9418|     46|bool overlaps(std::string_view input1, const std::string& input2) noexcept {
 9419|     46|  ada_log("helpers::overlaps check if string_view '", input1, "' [",
 9420|     46|          input1.size(), " bytes] is part of string '", input2, "' [",
 9421|     46|          input2.size(), " bytes]");
 9422|     46|  return !input1.empty() && !input2.empty() && input1.data() >= input2.data() &&
  ------------------
  |  Branch (9422:10): [True: 46, False: 0]
  |  Branch (9422:29): [True: 46, False: 0]
  |  Branch (9422:48): [True: 13, False: 33]
  ------------------
 9423|     13|         input1.data() < input2.data() + input2.size();
  ------------------
  |  Branch (9423:10): [True: 0, False: 13]
  ------------------
 9424|     46|}
_ZN3ada3url17parse_opaque_hostENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9799|    564|bool url::parse_opaque_host(std::string_view input) {
 9800|    564|  ada_log("parse_opaque_host ", input, " [", input.size(), " bytes]");
 9801|    564|  if (std::ranges::any_of(input, ada::unicode::is_forbidden_host_code_point)) {
  ------------------
  |  Branch (9801:7): [True: 9, False: 555]
  ------------------
 9802|      9|    return is_valid = false;
 9803|      9|  }
 9804|       |
 9805|       |  // Return the result of running UTF-8 percent-encode on input using the C0
 9806|       |  // control percent-encode set.
 9807|    555|  host = ada::unicode::percent_encode(
 9808|    555|      input, ada::character_sets::C0_CONTROL_PERCENT_ENCODE);
 9809|    555|  return true;
 9810|    564|}
_ZN3ada3url10parse_ipv4ENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9812|  1.87k|bool url::parse_ipv4(std::string_view input) {
 9813|  1.87k|  ada_log("parse_ipv4 ", input, " [", input.size(), " bytes]");
 9814|  1.87k|  if (input.empty()) {
  ------------------
  |  Branch (9814:7): [True: 0, False: 1.87k]
  ------------------
 9815|      0|    return is_valid = false;
 9816|      0|  }
 9817|  1.87k|  std::string_view original_input = input;
 9818|  1.87k|  if (original_input.back() == '.') {
  ------------------
  |  Branch (9818:7): [True: 80, False: 1.79k]
  ------------------
 9819|     80|    original_input.remove_suffix(1);
 9820|     80|  }
 9821|  1.87k|  if (input.back() == '.') {
  ------------------
  |  Branch (9821:7): [True: 80, False: 1.79k]
  ------------------
 9822|     80|    input.remove_suffix(1);
 9823|     80|    if (input.empty()) {
  ------------------
  |  Branch (9823:9): [True: 0, False: 80]
  ------------------
 9824|      0|      return is_valid = false;
 9825|      0|    }
 9826|     80|  }
 9827|       |
 9828|  1.87k|  const uint64_t fast = checkers::try_parse_ipv4_fast(input);
 9829|  1.87k|  if (fast < checkers::ipv4_fast_fail) [[likely]] {
  ------------------
  |  Branch (9829:7): [True: 26, False: 1.84k]
  ------------------
 9830|     26|    host = original_input;
 9831|     26|    host_type = IPV4;
 9832|     26|    return true;
 9833|     26|  }
 9834|       |
 9835|  1.84k|  const char* p = input.data();
 9836|  1.84k|  const char* end = p + input.size();
 9837|  1.84k|  uint64_t ipv4 = 0;
 9838|  1.84k|  int digit_count = 0;
 9839|  1.84k|  int pure_decimal_count = 0;
 9840|       |
 9841|  2.33k|  for (; digit_count < 4 && p < end; ++digit_count) {
  ------------------
  |  Branch (9841:10): [True: 2.32k, False: 10]
  |  Branch (9841:29): [True: 2.32k, False: 0]
  ------------------
 9842|  2.32k|    uint64_t segment = 0;
 9843|  2.32k|    bool pure = false;
 9844|  2.32k|    if (!detail::parse_ipv4_number(p, end, segment, pure)) {
  ------------------
  |  Branch (9844:9): [True: 336, False: 1.98k]
  ------------------
 9845|    336|      return is_valid = false;
 9846|    336|    }
 9847|  1.98k|    if (pure) {
  ------------------
  |  Branch (9847:9): [True: 1.40k, False: 584]
  ------------------
 9848|  1.40k|      ++pure_decimal_count;
 9849|  1.40k|    }
 9850|  1.98k|    if (p >= end) {
  ------------------
  |  Branch (9850:9): [True: 1.46k, False: 518]
  ------------------
 9851|  1.46k|      const unsigned shift = static_cast<unsigned>(32 - digit_count * 8);
 9852|  1.46k|      if (segment >= (uint64_t{1} << shift)) {
  ------------------
  |  Branch (9852:11): [True: 26, False: 1.44k]
  ------------------
 9853|     26|        return is_valid = false;
 9854|     26|      }
 9855|  1.44k|      ipv4 = (ipv4 << shift) | segment;
 9856|  1.44k|      host = (pure_decimal_count == 4) ? std::string(original_input)
  ------------------
  |  Branch (9856:14): [True: 0, False: 1.44k]
  ------------------
 9857|  1.44k|                                       : ada::serializers::ipv4(ipv4);
 9858|  1.44k|      host_type = IPV4;
 9859|  1.44k|      return true;
 9860|  1.46k|    }
 9861|    518|    if (segment > 255 || *p != '.') {
  ------------------
  |  Branch (9861:9): [True: 35, False: 483]
  |  Branch (9861:26): [True: 0, False: 483]
  ------------------
 9862|     35|      return is_valid = false;
 9863|     35|    }
 9864|    483|    ipv4 = (ipv4 << 8) | segment;
 9865|    483|    ++p;
 9866|    483|  }
 9867|     10|  if (digit_count != 4 || p != end) {
  ------------------
  |  Branch (9867:7): [True: 0, False: 10]
  |  Branch (9867:27): [True: 10, False: 0]
  ------------------
 9868|     10|    return is_valid = false;
 9869|     10|  }
 9870|      0|  host = (pure_decimal_count == 4) ? std::string(original_input)
  ------------------
  |  Branch (9870:10): [True: 0, False: 0]
  ------------------
 9871|      0|                                   : ada::serializers::ipv4(ipv4);
 9872|      0|  host_type = IPV4;
 9873|      0|  return true;
 9874|     10|}
_ZN3ada3url10parse_ipv6ENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9876|    537|bool url::parse_ipv6(std::string_view input) {
 9877|    537|  ada_log("parse_ipv6 ", input, " [", input.size(), " bytes]");
 9878|    537|  if (input.empty() || input.size() > 45) [[unlikely]] {
  ------------------
  |  Branch (9878:7): [True: 14, False: 523]
  |  Branch (9878:24): [True: 14, False: 509]
  ------------------
 9879|     28|    return is_valid = false;
 9880|     28|  }
 9881|    509|  std::array<uint16_t, 8> address{};
 9882|       |#if defined(ADA_AVX512_IPV6)
 9883|       |  if (bool simd_valid; detail::try_parse_ipv6_avx512(input.data(), input.size(),
 9884|       |                                                     address, simd_valid)) {
 9885|       |    if (!simd_valid) [[unlikely]] {
 9886|       |      return is_valid = false;
 9887|       |    }
 9888|       |    host = ada::serializers::ipv6(address);
 9889|       |    host_type = IPV6;
 9890|       |    return true;
 9891|       |  }
 9892|       |  address = {};
 9893|       |#endif
 9894|    509|  const char* pointer = input.data();
 9895|    509|  const char* const end = pointer + input.size();
 9896|    509|  int piece_index = 0;
 9897|    509|  int compress = -1;
 9898|       |
 9899|    509|  if (*pointer == ':') {
  ------------------
  |  Branch (9899:7): [True: 193, False: 316]
  ------------------
 9900|    193|    if (input.size() == 1 || pointer[1] != ':') [[unlikely]] {
  ------------------
  |  Branch (9900:9): [True: 3, False: 190]
  |  Branch (9900:30): [True: 5, False: 185]
  ------------------
 9901|      8|      return is_valid = false;
 9902|      8|    }
 9903|    185|    pointer += 2;
 9904|    185|    compress = ++piece_index;
 9905|    185|  }
 9906|       |
 9907|  1.37k|  while (pointer != end) {
  ------------------
  |  Branch (9907:10): [True: 1.03k, False: 339]
  ------------------
 9908|  1.03k|    if (piece_index == 8) [[unlikely]] {
  ------------------
  |  Branch (9908:9): [True: 3, False: 1.02k]
  ------------------
 9909|      3|      return is_valid = false;
 9910|      3|    }
 9911|  1.02k|    if (*pointer == ':') {
  ------------------
  |  Branch (9911:9): [True: 147, False: 882]
  ------------------
 9912|    147|      if (compress != -1) [[unlikely]] {
  ------------------
  |  Branch (9912:11): [True: 4, False: 143]
  ------------------
 9913|      4|        return is_valid = false;
 9914|      4|      }
 9915|    143|      ++pointer;
 9916|    143|      compress = ++piece_index;
 9917|    143|      continue;
 9918|    147|    }
 9919|       |
 9920|    882|    uint16_t value = 0;
 9921|    882|    const int length = detail::parse_hex_piece(pointer, end, value);
 9922|       |
 9923|    882|    if (pointer != end && *pointer == '.') {
  ------------------
  |  Branch (9923:9): [True: 713, False: 169]
  |  Branch (9923:27): [True: 96, False: 617]
  ------------------
 9924|     96|      if (length == 0) [[unlikely]] {
  ------------------
  |  Branch (9924:11): [True: 3, False: 93]
  ------------------
 9925|      3|        return is_valid = false;
 9926|      3|      }
 9927|     93|      pointer -= length;
 9928|     93|      if (piece_index > 6) [[unlikely]] {
  ------------------
  |  Branch (9928:11): [True: 3, False: 90]
  ------------------
 9929|      3|        return is_valid = false;
 9930|      3|      }
 9931|       |
 9932|     90|      int numbers_seen = 0;
 9933|    258|      while (pointer != end) {
  ------------------
  |  Branch (9933:14): [True: 228, False: 30]
  ------------------
 9934|    228|        int ipv4_piece = -1;
 9935|    228|        if (numbers_seen > 0) {
  ------------------
  |  Branch (9935:13): [True: 138, False: 90]
  ------------------
 9936|    138|          if (*pointer == '.' && numbers_seen < 4) {
  ------------------
  |  Branch (9936:15): [True: 121, False: 17]
  |  Branch (9936:34): [True: 118, False: 3]
  ------------------
 9937|    118|            ++pointer;
 9938|    118|          } else {
 9939|     20|            return is_valid = false;
 9940|     20|          }
 9941|    138|        }
 9942|    208|        if (pointer == end || *pointer < '0' || *pointer > '9') [[unlikely]] {
  ------------------
  |  Branch (9942:13): [True: 19, False: 189]
  |  Branch (9942:31): [True: 3, False: 186]
  |  Branch (9942:49): [True: 8, False: 178]
  ------------------
 9943|     30|          return is_valid = false;
 9944|     30|        }
 9945|    178|        ipv4_piece = *pointer - '0';
 9946|    178|        ++pointer;
 9947|    178|        if (pointer != end && *pointer >= '0' && *pointer <= '9') {
  ------------------
  |  Branch (9947:13): [True: 160, False: 18]
  |  Branch (9947:31): [True: 63, False: 97]
  |  Branch (9947:50): [True: 60, False: 3]
  ------------------
 9948|     60|          if (ipv4_piece == 0) [[unlikely]] {
  ------------------
  |  Branch (9948:15): [True: 3, False: 57]
  ------------------
 9949|      3|            return is_valid = false;
 9950|      3|          }
 9951|     57|          ipv4_piece = ipv4_piece * 10 + (*pointer - '0');
 9952|     57|          ++pointer;
 9953|     57|          if (pointer != end && *pointer >= '0' && *pointer <= '9') {
  ------------------
  |  Branch (9953:15): [True: 51, False: 6]
  |  Branch (9953:33): [True: 31, False: 20]
  |  Branch (9953:52): [True: 28, False: 3]
  ------------------
 9954|     28|            ipv4_piece = ipv4_piece * 10 + (*pointer - '0');
 9955|     28|            ++pointer;
 9956|     28|            if (ipv4_piece > 255) [[unlikely]] {
  ------------------
  |  Branch (9956:17): [True: 7, False: 21]
  ------------------
 9957|      7|              return is_valid = false;
 9958|      7|            }
 9959|     28|          }
 9960|     57|        }
 9961|    168|        address[static_cast<size_t>(piece_index)] = static_cast<uint16_t>(
 9962|    168|            address[static_cast<size_t>(piece_index)] * 0x100 +
 9963|    168|            static_cast<uint16_t>(ipv4_piece));
 9964|    168|        ++numbers_seen;
 9965|    168|        if (numbers_seen == 2 || numbers_seen == 4) {
  ------------------
  |  Branch (9965:13): [True: 52, False: 116]
  |  Branch (9965:34): [True: 17, False: 99]
  ------------------
 9966|     69|          ++piece_index;
 9967|     69|        }
 9968|    168|      }
 9969|     30|      if (numbers_seen != 4) [[unlikely]] {
  ------------------
  |  Branch (9969:11): [True: 18, False: 12]
  ------------------
 9970|     18|        return is_valid = false;
 9971|     18|      }
 9972|     12|      break;
 9973|     30|    }
 9974|       |
 9975|    786|    if (length == 0) [[unlikely]] {
  ------------------
  |  Branch (9975:9): [True: 51, False: 735]
  ------------------
 9976|     51|      return is_valid = false;
 9977|     51|    }
 9978|       |
 9979|    735|    if (pointer != end && *pointer == ':') {
  ------------------
  |  Branch (9979:9): [True: 566, False: 169]
  |  Branch (9979:27): [True: 561, False: 5]
  ------------------
 9980|    561|      ++pointer;
 9981|    561|      if (pointer == end) [[unlikely]] {
  ------------------
  |  Branch (9981:11): [True: 3, False: 558]
  ------------------
 9982|      3|        return is_valid = false;
 9983|      3|      }
 9984|    561|    } else if (pointer != end) [[unlikely]] {
  ------------------
  |  Branch (9984:16): [True: 5, False: 169]
  ------------------
 9985|      5|      return is_valid = false;
 9986|      5|    }
 9987|       |
 9988|    727|    address[static_cast<size_t>(piece_index)] = value;
 9989|    727|    ++piece_index;
 9990|    727|  }
 9991|       |
 9992|    351|  if (compress != -1) {
  ------------------
  |  Branch (9992:7): [True: 317, False: 34]
  ------------------
 9993|    317|    const int right = piece_index - compress;
 9994|    317|    if (right > 0) {
  ------------------
  |  Branch (9994:9): [True: 147, False: 170]
  ------------------
 9995|    147|      const size_t dest = static_cast<size_t>(8 - right);
 9996|    147|      const size_t src = static_cast<size_t>(compress);
 9997|    147|      if (dest != src) {
  ------------------
  |  Branch (9997:11): [True: 139, False: 8]
  ------------------
 9998|    384|        for (size_t i = static_cast<size_t>(right); i-- > 0;) {
  ------------------
  |  Branch (9998:53): [True: 245, False: 139]
  ------------------
 9999|    245|          address[dest + i] = address[src + i];
10000|    245|          address[src + i] = 0;
10001|    245|        }
10002|    139|      }
10003|    147|    }
10004|    317|  } else if (piece_index != 8) [[unlikely]] {
  ------------------
  |  Branch (10004:14): [True: 21, False: 13]
  ------------------
10005|     21|    return is_valid = false;
10006|     21|  }
10007|       |
10008|    330|  host = ada::serializers::ipv6(address);
10009|    330|  ada_log("parse_ipv6 ", *host);
10010|    330|  host_type = IPV6;
10011|    330|  return true;
10012|    351|}
_ZN3ada6parser25try_parse_simple_absoluteINS_3urlEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_:
11946|  42.8k|                                                result_type& out) {
11947|  42.8k|  constexpr bool is_ada_url = std::is_same_v<result_type, ada::url>;
11948|  42.8k|  constexpr bool is_aggregator =
11949|  42.8k|      std::is_same_v<result_type, ada::url_aggregator>;
11950|  42.8k|  static_assert(is_ada_url || is_aggregator);
11951|       |
11952|  42.8k|  const size_t len = input.size();
11953|       |  // Shortest accepted form is "ws://x" (6).
11954|  42.8k|  if (len < 6) [[unlikely]] {
  ------------------
  |  Branch (11954:7): [True: 24.0k, False: 18.7k]
  ------------------
11955|  24.0k|    return false;
11956|  24.0k|  }
11957|  18.7k|  const auto* b = reinterpret_cast<const uint8_t*>(input.data());
11958|       |
11959|  18.7k|  size_t pos = 0;
11960|  18.7k|  ada::scheme::type scheme_type = ada::scheme::type::NOT_SPECIAL;
11961|  18.7k|  uint32_t protocol_end = 0;
11962|  18.7k|#if (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \
11963|  18.7k|    defined(_M_X64) || defined(_M_IX86) || defined(_M_AMD64)
11964|       |  // One 8-byte load + integer compare is a single cmp/jcc on x86-64.
11965|       |  // Masked compares cover the shorter special schemes without extra loads.
11966|  18.7k|  if (len >= 8) {
  ------------------
  |  Branch (11966:7): [True: 16.0k, False: 2.74k]
  ------------------
11967|  16.0k|    uint64_t first8 = 0;
11968|  16.0k|    std::memcpy(&first8, b, 8);
11969|  16.0k|    if (first8 == 0x2f2f3a7370747468ull) {  // "https://"
  ------------------
  |  Branch (11969:9): [True: 24, False: 15.9k]
  ------------------
11970|     24|      pos = 8;
11971|     24|      scheme_type = ada::scheme::type::HTTPS;
11972|     24|      protocol_end = 6;
11973|  15.9k|    } else if ((first8 & 0x00ffffffffffffffull) ==
  ------------------
  |  Branch (11973:16): [True: 562, False: 15.4k]
  ------------------
11974|  15.9k|               0x002f2f3a70747468ull) {  // "http://"
11975|    562|      pos = 7;
11976|    562|      scheme_type = ada::scheme::type::HTTP;
11977|    562|      protocol_end = 5;
11978|  15.4k|    } else if ((first8 & 0x0000ffffffffffffull) ==
  ------------------
  |  Branch (11978:16): [True: 47, False: 15.3k]
  ------------------
11979|  15.4k|               0x00002f2f3a737377ull) {  // "wss://"
11980|     47|      pos = 6;
11981|     47|      scheme_type = ada::scheme::type::WSS;
11982|     47|      protocol_end = 4;
11983|  15.3k|    } else if ((first8 & 0x0000ffffffffffffull) ==
  ------------------
  |  Branch (11983:16): [True: 23, False: 15.3k]
  ------------------
11984|  15.3k|               0x00002f2f3a707466ull) {  // "ftp://"
11985|     23|      pos = 6;
11986|     23|      scheme_type = ada::scheme::type::FTP;
11987|     23|      protocol_end = 4;
11988|  15.3k|    } else if ((first8 & 0x000000ffffffffffull) ==
  ------------------
  |  Branch (11988:16): [True: 6.18k, False: 9.17k]
  ------------------
11989|  15.3k|               0x0000002f2f3a7377ull) {  // "ws://"
11990|  6.18k|      pos = 5;
11991|  6.18k|      scheme_type = ada::scheme::type::WS;
11992|  6.18k|      protocol_end = 3;
11993|  9.17k|    } else {
11994|  9.17k|      return false;
11995|  9.17k|    }
11996|  16.0k|  } else if (b[0] == 'w' && b[1] == 's') {
  ------------------
  |  Branch (11996:14): [True: 1.62k, False: 1.12k]
  |  Branch (11996:29): [True: 1.35k, False: 270]
  ------------------
11997|  1.35k|    if (b[2] == ':' && b[3] == '/' && b[4] == '/') {
  ------------------
  |  Branch (11997:9): [True: 1.23k, False: 116]
  |  Branch (11997:24): [True: 514, False: 721]
  |  Branch (11997:39): [True: 505, False: 9]
  ------------------
11998|    505|      pos = 5;
11999|    505|      scheme_type = ada::scheme::type::WS;
12000|    505|      protocol_end = 3;
12001|    846|    } else if (b[2] == 's' && b[3] == ':' && b[4] == '/' && b[5] == '/') {
  ------------------
  |  Branch (12001:16): [True: 83, False: 763]
  |  Branch (12001:31): [True: 75, False: 8]
  |  Branch (12001:46): [True: 16, False: 59]
  |  Branch (12001:61): [True: 5, False: 11]
  ------------------
12002|      5|      pos = 6;
12003|      5|      scheme_type = ada::scheme::type::WSS;
12004|      5|      protocol_end = 4;
12005|    841|    } else {
12006|    841|      return false;
12007|    841|    }
12008|  1.39k|  } else if (b[0] == 'f' && b[1] == 't' && b[2] == 'p' && b[3] == ':' &&
  ------------------
  |  Branch (12008:14): [True: 151, False: 1.24k]
  |  Branch (12008:29): [True: 50, False: 101]
  |  Branch (12008:44): [True: 37, False: 13]
  |  Branch (12008:59): [True: 22, False: 15]
  ------------------
12009|     22|             b[4] == '/' && b[5] == '/') {
  ------------------
  |  Branch (12009:14): [True: 14, False: 8]
  |  Branch (12009:29): [True: 4, False: 10]
  ------------------
12010|      4|    pos = 6;
12011|      4|    scheme_type = ada::scheme::type::FTP;
12012|      4|    protocol_end = 4;
12013|  1.38k|  } else if (len >= 7 && b[0] == 'h' && b[1] == 't' && b[2] == 't' &&
  ------------------
  |  Branch (12013:14): [True: 710, False: 677]
  |  Branch (12013:26): [True: 100, False: 610]
  |  Branch (12013:41): [True: 81, False: 19]
  |  Branch (12013:56): [True: 65, False: 16]
  ------------------
12014|     65|             b[3] == 'p' && b[4] == ':' && b[5] == '/' && b[6] == '/') {
  ------------------
  |  Branch (12014:14): [True: 51, False: 14]
  |  Branch (12014:29): [True: 36, False: 15]
  |  Branch (12014:44): [True: 14, False: 22]
  |  Branch (12014:59): [True: 3, False: 11]
  ------------------
12015|      3|    pos = 7;
12016|      3|    scheme_type = ada::scheme::type::HTTP;
12017|      3|    protocol_end = 5;
12018|  1.38k|  } else {
12019|  1.38k|    return false;
12020|  1.38k|  }
12021|       |#else
12022|       |  // Big-endian / uncommon arches: byte-wise special-scheme match.
12023|       |  if (len >= 8 && b[0] == 'h' && b[1] == 't' && b[2] == 't' && b[3] == 'p' &&
12024|       |      b[4] == 's' && b[5] == ':' && b[6] == '/' && b[7] == '/') {
12025|       |    pos = 8;
12026|       |    scheme_type = ada::scheme::type::HTTPS;
12027|       |    protocol_end = 6;
12028|       |  } else if (len >= 7 && b[0] == 'h' && b[1] == 't' && b[2] == 't' &&
12029|       |             b[3] == 'p' && b[4] == ':' && b[5] == '/' && b[6] == '/') {
12030|       |    pos = 7;
12031|       |    scheme_type = ada::scheme::type::HTTP;
12032|       |    protocol_end = 5;
12033|       |  } else if (b[0] == 'w' && b[1] == 's') {
12034|       |    if (b[2] == ':' && b[3] == '/' && b[4] == '/') {
12035|       |      pos = 5;
12036|       |      scheme_type = ada::scheme::type::WS;
12037|       |      protocol_end = 3;
12038|       |    } else if (len >= 6 && b[2] == 's' && b[3] == ':' && b[4] == '/' &&
12039|       |               b[5] == '/') {
12040|       |      pos = 6;
12041|       |      scheme_type = ada::scheme::type::WSS;
12042|       |      protocol_end = 4;
12043|       |    } else {
12044|       |      return false;
12045|       |    }
12046|       |  } else if (b[0] == 'f' && b[1] == 't' && b[2] == 'p' && b[3] == ':' &&
12047|       |             b[4] == '/' && b[5] == '/') {
12048|       |    pos = 6;
12049|       |    scheme_type = ada::scheme::type::FTP;
12050|       |    protocol_end = 4;
12051|       |  } else {
12052|       |    return false;
12053|       |  }
12054|       |#endif
12055|  7.36k|  if (pos < len && (b[pos] == '/' || b[pos] == '\\')) [[unlikely]] {
  ------------------
  |  Branch (12055:7): [True: 7.35k, False: 10]
  |  Branch (12055:21): [True: 10, False: 7.34k]
  |  Branch (12055:38): [True: 9, False: 7.33k]
  ------------------
12056|     19|    return false;
12057|     19|  }
12058|       |
12059|       |  // Digit-led hosts are IPv4/numeric; '[' is IPv6. Skip before scanning.
12060|  7.34k|  if (pos < len && ((b[pos] >= '0' && b[pos] <= '9') || b[pos] == '[')) {
  ------------------
  |  Branch (12060:7): [True: 7.33k, False: 10]
  |  Branch (12060:22): [True: 5.77k, False: 1.55k]
  |  Branch (12060:39): [True: 1.14k, False: 4.63k]
  |  Branch (12060:57): [True: 100, False: 6.08k]
  ------------------
12061|  1.24k|    return false;
12062|  1.24k|  }
12063|       |
12064|  6.09k|  const size_t host_start = pos;
12065|  6.09k|  bool has_upper = false;
12066|  6.09k|  bool has_x = false;
12067|  6.09k|  size_t host_end = pos;
12068|  6.09k|  if (!scan_plain_host(b, pos, len, host_end, has_upper, has_x)) {
  ------------------
  |  Branch (12068:7): [True: 251, False: 5.84k]
  ------------------
12069|    251|    return false;
12070|    251|  }
12071|  5.84k|  if (host_start == host_end) [[unlikely]] {
  ------------------
  |  Branch (12071:7): [True: 60, False: 5.78k]
  ------------------
12072|     60|    return false;
12073|     60|  }
12074|  5.78k|  const size_t host_len = host_end - host_start;
12075|  5.78k|  if (host_len > 253) [[unlikely]] {
  ------------------
  |  Branch (12075:7): [True: 99, False: 5.68k]
  ------------------
12076|     99|    return false;
12077|     99|  }
12078|  5.68k|  {
12079|  5.68k|    std::string_view hv(input.data() + host_start, host_len);
12080|  5.68k|    char host_buf[256];
12081|  5.68k|    if (has_upper) [[unlikely]] {
  ------------------
  |  Branch (12081:9): [True: 441, False: 5.24k]
  ------------------
12082|    441|      std::memcpy(host_buf, input.data() + host_start, host_len);
12083|    441|      unicode::to_lower_ascii(host_buf, host_len);
12084|    441|      hv = std::string_view(host_buf, host_len);
12085|    441|    }
12086|  5.68k|    if (ada::checkers::last_label_may_be_a_number(hv)) [[unlikely]] {
  ------------------
  |  Branch (12086:9): [True: 78, False: 5.60k]
  ------------------
12087|     78|      return false;
12088|     78|    }
12089|       |    // Punycode is "xn--...". The host scan already notes a lowercase 'x';
12090|       |    // uppercase 'X' is covered by has_upper after the in-place lower.
12091|  5.60k|    static constexpr std::string_view xn{"xn-", 3};
12092|  5.60k|    if ((has_x || has_upper) && hv.find(xn) != std::string_view::npos)
  ------------------
  |  Branch (12092:10): [True: 1.77k, False: 3.83k]
  |  Branch (12092:19): [True: 401, False: 3.43k]
  |  Branch (12092:33): [True: 1.24k, False: 933]
  ------------------
12093|  1.24k|        [[unlikely]] {
12094|  1.24k|      return false;
12095|  1.24k|    }
12096|  5.60k|  }
12097|       |
12098|  4.36k|  if (host_end < len && b[host_end] == ':') [[unlikely]] {
  ------------------
  |  Branch (12098:7): [True: 4.21k, False: 146]
  |  Branch (12098:25): [True: 1.21k, False: 3.00k]
  ------------------
12099|  1.21k|    return finish_simple_absolute_with_port(input, out, scheme_type,
12100|  1.21k|                                            protocol_end, host_start, host_end,
12101|  1.21k|                                            host_len, has_upper);
12102|  1.21k|  }
12103|       |
12104|  3.15k|  size_t i = host_end;
12105|  3.15k|  size_t path_start = host_end;
12106|  3.15k|  size_t path_end = host_end;
12107|  3.15k|  size_t query_start = std::string_view::npos;
12108|  3.15k|  size_t hash_start = std::string_view::npos;
12109|  3.15k|  bool has_path = false;
12110|  3.15k|  bool maybe_dot_segment = false;
12111|  3.15k|  bool rest_simple = true;
12112|       |
12113|  3.15k|  if (i < len && b[i] == '/') {
  ------------------
  |  Branch (12113:7): [True: 3.00k, False: 146]
  |  Branch (12113:18): [True: 2.89k, False: 111]
  ------------------
12114|  2.89k|    has_path = true;
12115|  2.89k|    path_start = i;
12116|  2.89k|    ++i;
12117|  2.89k|    scan_path_run(b, i, len, maybe_dot_segment);
12118|  2.89k|    if (i < len) {
  ------------------
  |  Branch (12118:9): [True: 1.16k, False: 1.72k]
  ------------------
12119|  1.16k|      const uint8_t cls = k_path[b[i]];
12120|  1.16k|      if (cls == 1) {
  ------------------
  |  Branch (12120:11): [True: 334, False: 835]
  ------------------
12121|    334|        path_end = i;
12122|    334|        if (b[i] == '?') {
  ------------------
  |  Branch (12122:13): [True: 217, False: 117]
  ------------------
12123|    217|          query_start = i;
12124|    217|          ++i;
12125|    217|          goto scan_query;
12126|    217|        }
12127|    117|        hash_start = i;
12128|    117|        ++i;
12129|    117|        goto scan_hash;
12130|    334|      }
12131|    835|      rest_simple = false;
12132|  34.2k|      for (; i < len; ++i) {
  ------------------
  |  Branch (12132:14): [True: 33.4k, False: 748]
  ------------------
12133|  33.4k|        if (b[i] == '?') {
  ------------------
  |  Branch (12133:13): [True: 68, False: 33.3k]
  ------------------
12134|     68|          path_end = i;
12135|     68|          query_start = i;
12136|     68|          ++i;
12137|     68|          goto scan_query_boundary;
12138|     68|        }
12139|  33.3k|        if (b[i] == '#') {
  ------------------
  |  Branch (12139:13): [True: 19, False: 33.3k]
  ------------------
12140|     19|          path_end = i;
12141|     19|          hash_start = i;
12142|     19|          ++i;
12143|     19|          goto after_rest;
12144|     19|        }
12145|  33.3k|      }
12146|    748|      path_end = i;
12147|    748|      goto after_rest;
12148|    835|    }
12149|  1.72k|    path_end = i;
12150|  1.72k|  } else if (i < len && b[i] == '?') {
  ------------------
  |  Branch (12150:14): [True: 111, False: 146]
  |  Branch (12150:25): [True: 58, False: 53]
  ------------------
12151|     58|    query_start = i;
12152|     58|    ++i;
12153|     58|    goto scan_query;
12154|    199|  } else if (i < len && b[i] == '#') {
  ------------------
  |  Branch (12154:14): [True: 53, False: 146]
  |  Branch (12154:25): [True: 53, False: 0]
  ------------------
12155|     53|    hash_start = i;
12156|     53|    ++i;
12157|     53|    goto scan_hash;
12158|     53|  }
12159|  1.87k|  goto after_rest;
12160|       |
12161|  1.87k|scan_query:
12162|    275|  scan_query_run(b, i, len);
12163|    275|  if (i < len) {
  ------------------
  |  Branch (12163:7): [True: 131, False: 144]
  ------------------
12164|    131|    if (b[i] == '#') {
  ------------------
  |  Branch (12164:9): [True: 96, False: 35]
  ------------------
12165|     96|      hash_start = i;
12166|     96|      ++i;
12167|     96|      goto scan_hash;
12168|     96|    }
12169|     35|    rest_simple = false;
12170|     35|    goto scan_query_boundary;
12171|    131|  }
12172|    144|  goto after_rest;
12173|       |
12174|    144|scan_query_boundary:
12175|  1.40k|  for (; i < len; ++i) {
  ------------------
  |  Branch (12175:10): [True: 1.32k, False: 81]
  ------------------
12176|  1.32k|    if (b[i] == '#') {
  ------------------
  |  Branch (12176:9): [True: 22, False: 1.30k]
  ------------------
12177|     22|      hash_start = i;
12178|     22|      ++i;
12179|     22|      goto after_rest;
12180|     22|    }
12181|  1.32k|  }
12182|     81|  goto after_rest;
12183|       |
12184|    266|scan_hash:
12185|    266|  scan_hash_run(b, i, len);
12186|    266|  if (i < len) {
  ------------------
  |  Branch (12186:7): [True: 50, False: 216]
  ------------------
12187|     50|    rest_simple = false;
12188|     50|  }
12189|       |
12190|  3.15k|after_rest:
12191|  3.15k|  if (rest_simple && maybe_dot_segment) {
  ------------------
  |  Branch (12191:7): [True: 2.23k, False: 920]
  |  Branch (12191:22): [True: 375, False: 1.85k]
  ------------------
12192|    375|    const std::string_view path_body(input.data() + path_start,
12193|    375|                                     path_end - path_start);
12194|    375|    if (path_has_dot_segment(path_body)) {
  ------------------
  |  Branch (12194:9): [True: 177, False: 198]
  ------------------
12195|    177|      rest_simple = false;
12196|    177|    }
12197|    375|  }
12198|       |
12199|       |  // The slow path removes ASCII tab/newline anywhere in the input and trims a
12200|       |  // trailing C0 control or space; this fast path does neither. A query or
12201|       |  // fragment reaching the helpers below would keep those bytes percent-encoded
12202|       |  // ("?a\nb" -> "?a%0Ab", "#f " -> "#f%20") instead of stripped, so hand such
12203|       |  // inputs back to the slow path.
12204|  3.15k|  if (!rest_simple && (unicode::is_c0_control_or_space(input.back()) ||
  ------------------
  |  Branch (12204:7): [True: 1.09k, False: 2.05k]
  |  Branch (12204:24): [True: 15, False: 1.08k]
  ------------------
12205|  1.08k|                       unicode::has_tabs_or_newline(input))) {
  ------------------
  |  Branch (12205:24): [True: 10, False: 1.07k]
  ------------------
12206|     25|    return false;
12207|     25|  }
12208|       |
12209|  3.12k|  out.type = scheme_type;
12210|  3.12k|  out.is_valid = true;
12211|  3.12k|  out.has_opaque_path = false;
12212|  3.12k|  out.host_type = DEFAULT;
12213|       |
12214|  3.12k|  if (!rest_simple) {
  ------------------
  |  Branch (12214:7): [True: 1.07k, False: 2.05k]
  ------------------
12215|       |    // Host is a plain domain. Finish path/query/hash with
12216|       |    // the regular helpers
12217|       |    // so percent-encoding and dot segments do not re-parse the authority.
12218|  1.07k|    const std::string_view path_view =
12219|  1.07k|        has_path
  ------------------
  |  Branch (12219:9): [True: 1.02k, False: 51]
  ------------------
12220|  1.07k|            ? std::string_view(input.data() + path_start, path_end - path_start)
12221|  1.07k|            : std::string_view{};
12222|  1.07k|    auto apply_query_and_hash = [&]() {
12223|  1.07k|      if (query_start != std::string_view::npos) {
12224|  1.07k|        const size_t q_end =
12225|  1.07k|            (hash_start != std::string_view::npos) ? hash_start : len;
12226|  1.07k|        out.update_base_search(std::string_view(input.data() + query_start + 1,
12227|  1.07k|                                                q_end - query_start - 1),
12228|  1.07k|                               character_sets::SPECIAL_QUERY_PERCENT_ENCODE);
12229|  1.07k|      }
12230|  1.07k|      if (hash_start != std::string_view::npos) {
12231|  1.07k|        out.update_unencoded_base_hash(std::string_view(
12232|  1.07k|            input.data() + hash_start + 1, len - hash_start - 1));
12233|  1.07k|      }
12234|  1.07k|    };
12235|       |    if constexpr (is_aggregator) {
12236|       |      out.buffer.assign(input.substr(0, host_end));
12237|       |      if (has_upper) {
12238|       |        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12239|       |      }
12240|       |      out.components.protocol_end = protocol_end;
12241|       |      out.components.username_end = protocol_end + 2;
12242|       |      out.components.host_start = protocol_end + 2;
12243|       |      out.components.host_end = static_cast<uint32_t>(host_end);
12244|       |      out.components.port = url_components::omitted;
12245|       |      out.components.pathname_start = static_cast<uint32_t>(host_end);
12246|       |      out.components.search_start = url_components::omitted;
12247|       |      out.components.hash_start = url_components::omitted;
12248|       |      out.parse_path(path_view);
12249|       |      apply_query_and_hash();
12250|  1.07k|    } else {
12251|  1.07k|      std::string host_str(input.substr(host_start, host_len));
12252|  1.07k|      if (has_upper) {
  ------------------
  |  Branch (12252:11): [True: 117, False: 955]
  ------------------
12253|    117|        unicode::to_lower_ascii(host_str.data(), host_str.size());
12254|    117|      }
12255|  1.07k|      out.host = std::move(host_str);
12256|  1.07k|      out.parse_path(path_view);
12257|  1.07k|      apply_query_and_hash();
12258|  1.07k|    }
12259|  1.07k|    return true;
12260|  1.07k|  }
12261|       |
12262|  2.05k|  const bool need_slash = !has_path;
12263|       |  if constexpr (is_aggregator) {
12264|       |    if (!need_slash) {
12265|       |      // assign copies once. resize()+memcpy would value-init then overwrite.
12266|       |      out.buffer.assign(input);
12267|       |      if (has_upper) {
12268|       |        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12269|       |      }
12270|       |      out.components.protocol_end = protocol_end;
12271|       |      out.components.username_end = protocol_end + 2;
12272|       |      out.components.host_start = protocol_end + 2;
12273|       |      out.components.host_end = static_cast<uint32_t>(host_end);
12274|       |      out.components.port = url_components::omitted;
12275|       |      out.components.pathname_start = static_cast<uint32_t>(path_start);
12276|       |      out.components.search_start = (query_start != std::string_view::npos)
12277|       |                                        ? static_cast<uint32_t>(query_start)
12278|       |                                        : url_components::omitted;
12279|       |      out.components.hash_start = (hash_start != std::string_view::npos)
12280|       |                                      ? static_cast<uint32_t>(hash_start)
12281|       |                                      : url_components::omitted;
12282|       |    } else {
12283|       |      out.buffer.clear();
12284|       |      out.buffer.reserve(len + 1);
12285|       |      out.buffer.append(input.substr(0, host_end));
12286|       |      out.buffer.push_back('/');
12287|       |      if (host_end < len) {
12288|       |        out.buffer.append(input.substr(host_end));
12289|       |      }
12290|       |      if (has_upper) {
12291|       |        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12292|       |      }
12293|       |      out.components.protocol_end = protocol_end;
12294|       |      out.components.username_end = protocol_end + 2;
12295|       |      out.components.host_start = protocol_end + 2;
12296|       |      out.components.host_end = static_cast<uint32_t>(host_end);
12297|       |      out.components.port = url_components::omitted;
12298|       |      out.components.pathname_start = static_cast<uint32_t>(host_end);
12299|       |      out.components.search_start = (query_start != std::string_view::npos)
12300|       |                                        ? static_cast<uint32_t>(query_start + 1)
12301|       |                                        : url_components::omitted;
12302|       |      out.components.hash_start = (hash_start != std::string_view::npos)
12303|       |                                      ? static_cast<uint32_t>(hash_start + 1)
12304|       |                                      : url_components::omitted;
12305|       |    }
12306|  2.05k|  } else {
12307|  2.05k|    std::string host_str(input.substr(host_start, host_len));
12308|  2.05k|    if (has_upper) {
  ------------------
  |  Branch (12308:9): [True: 90, False: 1.96k]
  ------------------
12309|     90|      unicode::to_lower_ascii(host_str.data(), host_str.size());
12310|     90|    }
12311|  2.05k|    out.host = std::move(host_str);
12312|  2.05k|    if (need_slash) {
  ------------------
  |  Branch (12312:9): [True: 190, False: 1.86k]
  ------------------
12313|    190|      out.path = "/";
12314|  1.86k|    } else {
12315|  1.86k|      out.path.assign(input.data() + path_start, path_end - path_start);
12316|  1.86k|    }
12317|  2.05k|    if (query_start != std::string_view::npos) {
  ------------------
  |  Branch (12317:9): [True: 237, False: 1.81k]
  ------------------
12318|    237|      const size_t q_end =
12319|    237|          (hash_start != std::string_view::npos) ? hash_start : len;
  ------------------
  |  Branch (12319:11): [True: 93, False: 144]
  ------------------
12320|    237|      out.query.emplace(input.data() + query_start + 1,
12321|    237|                        q_end - query_start - 1);
12322|    237|    }
12323|  2.05k|    if (hash_start != std::string_view::npos) {
  ------------------
  |  Branch (12323:9): [True: 216, False: 1.83k]
  ------------------
12324|    216|      out.hash.emplace(input.data() + hash_start + 1, len - hash_start - 1);
12325|    216|    }
12326|  2.05k|  }
12327|  2.05k|  return true;
12328|  3.12k|}
_ZN3ada6parser25try_parse_simple_absoluteINS_14url_aggregatorEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_:
11946|  42.8k|                                                result_type& out) {
11947|  42.8k|  constexpr bool is_ada_url = std::is_same_v<result_type, ada::url>;
11948|  42.8k|  constexpr bool is_aggregator =
11949|  42.8k|      std::is_same_v<result_type, ada::url_aggregator>;
11950|  42.8k|  static_assert(is_ada_url || is_aggregator);
11951|       |
11952|  42.8k|  const size_t len = input.size();
11953|       |  // Shortest accepted form is "ws://x" (6).
11954|  42.8k|  if (len < 6) [[unlikely]] {
  ------------------
  |  Branch (11954:7): [True: 24.0k, False: 18.7k]
  ------------------
11955|  24.0k|    return false;
11956|  24.0k|  }
11957|  18.7k|  const auto* b = reinterpret_cast<const uint8_t*>(input.data());
11958|       |
11959|  18.7k|  size_t pos = 0;
11960|  18.7k|  ada::scheme::type scheme_type = ada::scheme::type::NOT_SPECIAL;
11961|  18.7k|  uint32_t protocol_end = 0;
11962|  18.7k|#if (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \
11963|  18.7k|    defined(_M_X64) || defined(_M_IX86) || defined(_M_AMD64)
11964|       |  // One 8-byte load + integer compare is a single cmp/jcc on x86-64.
11965|       |  // Masked compares cover the shorter special schemes without extra loads.
11966|  18.7k|  if (len >= 8) {
  ------------------
  |  Branch (11966:7): [True: 16.0k, False: 2.74k]
  ------------------
11967|  16.0k|    uint64_t first8 = 0;
11968|  16.0k|    std::memcpy(&first8, b, 8);
11969|  16.0k|    if (first8 == 0x2f2f3a7370747468ull) {  // "https://"
  ------------------
  |  Branch (11969:9): [True: 24, False: 15.9k]
  ------------------
11970|     24|      pos = 8;
11971|     24|      scheme_type = ada::scheme::type::HTTPS;
11972|     24|      protocol_end = 6;
11973|  15.9k|    } else if ((first8 & 0x00ffffffffffffffull) ==
  ------------------
  |  Branch (11973:16): [True: 562, False: 15.4k]
  ------------------
11974|  15.9k|               0x002f2f3a70747468ull) {  // "http://"
11975|    562|      pos = 7;
11976|    562|      scheme_type = ada::scheme::type::HTTP;
11977|    562|      protocol_end = 5;
11978|  15.4k|    } else if ((first8 & 0x0000ffffffffffffull) ==
  ------------------
  |  Branch (11978:16): [True: 47, False: 15.3k]
  ------------------
11979|  15.4k|               0x00002f2f3a737377ull) {  // "wss://"
11980|     47|      pos = 6;
11981|     47|      scheme_type = ada::scheme::type::WSS;
11982|     47|      protocol_end = 4;
11983|  15.3k|    } else if ((first8 & 0x0000ffffffffffffull) ==
  ------------------
  |  Branch (11983:16): [True: 23, False: 15.3k]
  ------------------
11984|  15.3k|               0x00002f2f3a707466ull) {  // "ftp://"
11985|     23|      pos = 6;
11986|     23|      scheme_type = ada::scheme::type::FTP;
11987|     23|      protocol_end = 4;
11988|  15.3k|    } else if ((first8 & 0x000000ffffffffffull) ==
  ------------------
  |  Branch (11988:16): [True: 6.18k, False: 9.17k]
  ------------------
11989|  15.3k|               0x0000002f2f3a7377ull) {  // "ws://"
11990|  6.18k|      pos = 5;
11991|  6.18k|      scheme_type = ada::scheme::type::WS;
11992|  6.18k|      protocol_end = 3;
11993|  9.17k|    } else {
11994|  9.17k|      return false;
11995|  9.17k|    }
11996|  16.0k|  } else if (b[0] == 'w' && b[1] == 's') {
  ------------------
  |  Branch (11996:14): [True: 1.62k, False: 1.12k]
  |  Branch (11996:29): [True: 1.35k, False: 270]
  ------------------
11997|  1.35k|    if (b[2] == ':' && b[3] == '/' && b[4] == '/') {
  ------------------
  |  Branch (11997:9): [True: 1.23k, False: 116]
  |  Branch (11997:24): [True: 514, False: 721]
  |  Branch (11997:39): [True: 505, False: 9]
  ------------------
11998|    505|      pos = 5;
11999|    505|      scheme_type = ada::scheme::type::WS;
12000|    505|      protocol_end = 3;
12001|    846|    } else if (b[2] == 's' && b[3] == ':' && b[4] == '/' && b[5] == '/') {
  ------------------
  |  Branch (12001:16): [True: 83, False: 763]
  |  Branch (12001:31): [True: 75, False: 8]
  |  Branch (12001:46): [True: 16, False: 59]
  |  Branch (12001:61): [True: 5, False: 11]
  ------------------
12002|      5|      pos = 6;
12003|      5|      scheme_type = ada::scheme::type::WSS;
12004|      5|      protocol_end = 4;
12005|    841|    } else {
12006|    841|      return false;
12007|    841|    }
12008|  1.39k|  } else if (b[0] == 'f' && b[1] == 't' && b[2] == 'p' && b[3] == ':' &&
  ------------------
  |  Branch (12008:14): [True: 151, False: 1.24k]
  |  Branch (12008:29): [True: 50, False: 101]
  |  Branch (12008:44): [True: 37, False: 13]
  |  Branch (12008:59): [True: 22, False: 15]
  ------------------
12009|     22|             b[4] == '/' && b[5] == '/') {
  ------------------
  |  Branch (12009:14): [True: 14, False: 8]
  |  Branch (12009:29): [True: 4, False: 10]
  ------------------
12010|      4|    pos = 6;
12011|      4|    scheme_type = ada::scheme::type::FTP;
12012|      4|    protocol_end = 4;
12013|  1.38k|  } else if (len >= 7 && b[0] == 'h' && b[1] == 't' && b[2] == 't' &&
  ------------------
  |  Branch (12013:14): [True: 710, False: 677]
  |  Branch (12013:26): [True: 100, False: 610]
  |  Branch (12013:41): [True: 81, False: 19]
  |  Branch (12013:56): [True: 65, False: 16]
  ------------------
12014|     65|             b[3] == 'p' && b[4] == ':' && b[5] == '/' && b[6] == '/') {
  ------------------
  |  Branch (12014:14): [True: 51, False: 14]
  |  Branch (12014:29): [True: 36, False: 15]
  |  Branch (12014:44): [True: 14, False: 22]
  |  Branch (12014:59): [True: 3, False: 11]
  ------------------
12015|      3|    pos = 7;
12016|      3|    scheme_type = ada::scheme::type::HTTP;
12017|      3|    protocol_end = 5;
12018|  1.38k|  } else {
12019|  1.38k|    return false;
12020|  1.38k|  }
12021|       |#else
12022|       |  // Big-endian / uncommon arches: byte-wise special-scheme match.
12023|       |  if (len >= 8 && b[0] == 'h' && b[1] == 't' && b[2] == 't' && b[3] == 'p' &&
12024|       |      b[4] == 's' && b[5] == ':' && b[6] == '/' && b[7] == '/') {
12025|       |    pos = 8;
12026|       |    scheme_type = ada::scheme::type::HTTPS;
12027|       |    protocol_end = 6;
12028|       |  } else if (len >= 7 && b[0] == 'h' && b[1] == 't' && b[2] == 't' &&
12029|       |             b[3] == 'p' && b[4] == ':' && b[5] == '/' && b[6] == '/') {
12030|       |    pos = 7;
12031|       |    scheme_type = ada::scheme::type::HTTP;
12032|       |    protocol_end = 5;
12033|       |  } else if (b[0] == 'w' && b[1] == 's') {
12034|       |    if (b[2] == ':' && b[3] == '/' && b[4] == '/') {
12035|       |      pos = 5;
12036|       |      scheme_type = ada::scheme::type::WS;
12037|       |      protocol_end = 3;
12038|       |    } else if (len >= 6 && b[2] == 's' && b[3] == ':' && b[4] == '/' &&
12039|       |               b[5] == '/') {
12040|       |      pos = 6;
12041|       |      scheme_type = ada::scheme::type::WSS;
12042|       |      protocol_end = 4;
12043|       |    } else {
12044|       |      return false;
12045|       |    }
12046|       |  } else if (b[0] == 'f' && b[1] == 't' && b[2] == 'p' && b[3] == ':' &&
12047|       |             b[4] == '/' && b[5] == '/') {
12048|       |    pos = 6;
12049|       |    scheme_type = ada::scheme::type::FTP;
12050|       |    protocol_end = 4;
12051|       |  } else {
12052|       |    return false;
12053|       |  }
12054|       |#endif
12055|  7.36k|  if (pos < len && (b[pos] == '/' || b[pos] == '\\')) [[unlikely]] {
  ------------------
  |  Branch (12055:7): [True: 7.35k, False: 10]
  |  Branch (12055:21): [True: 10, False: 7.34k]
  |  Branch (12055:38): [True: 9, False: 7.33k]
  ------------------
12056|     19|    return false;
12057|     19|  }
12058|       |
12059|       |  // Digit-led hosts are IPv4/numeric; '[' is IPv6. Skip before scanning.
12060|  7.34k|  if (pos < len && ((b[pos] >= '0' && b[pos] <= '9') || b[pos] == '[')) {
  ------------------
  |  Branch (12060:7): [True: 7.33k, False: 10]
  |  Branch (12060:22): [True: 5.77k, False: 1.55k]
  |  Branch (12060:39): [True: 1.14k, False: 4.63k]
  |  Branch (12060:57): [True: 100, False: 6.08k]
  ------------------
12061|  1.24k|    return false;
12062|  1.24k|  }
12063|       |
12064|  6.09k|  const size_t host_start = pos;
12065|  6.09k|  bool has_upper = false;
12066|  6.09k|  bool has_x = false;
12067|  6.09k|  size_t host_end = pos;
12068|  6.09k|  if (!scan_plain_host(b, pos, len, host_end, has_upper, has_x)) {
  ------------------
  |  Branch (12068:7): [True: 251, False: 5.84k]
  ------------------
12069|    251|    return false;
12070|    251|  }
12071|  5.84k|  if (host_start == host_end) [[unlikely]] {
  ------------------
  |  Branch (12071:7): [True: 60, False: 5.78k]
  ------------------
12072|     60|    return false;
12073|     60|  }
12074|  5.78k|  const size_t host_len = host_end - host_start;
12075|  5.78k|  if (host_len > 253) [[unlikely]] {
  ------------------
  |  Branch (12075:7): [True: 99, False: 5.68k]
  ------------------
12076|     99|    return false;
12077|     99|  }
12078|  5.68k|  {
12079|  5.68k|    std::string_view hv(input.data() + host_start, host_len);
12080|  5.68k|    char host_buf[256];
12081|  5.68k|    if (has_upper) [[unlikely]] {
  ------------------
  |  Branch (12081:9): [True: 441, False: 5.24k]
  ------------------
12082|    441|      std::memcpy(host_buf, input.data() + host_start, host_len);
12083|    441|      unicode::to_lower_ascii(host_buf, host_len);
12084|    441|      hv = std::string_view(host_buf, host_len);
12085|    441|    }
12086|  5.68k|    if (ada::checkers::last_label_may_be_a_number(hv)) [[unlikely]] {
  ------------------
  |  Branch (12086:9): [True: 78, False: 5.60k]
  ------------------
12087|     78|      return false;
12088|     78|    }
12089|       |    // Punycode is "xn--...". The host scan already notes a lowercase 'x';
12090|       |    // uppercase 'X' is covered by has_upper after the in-place lower.
12091|  5.60k|    static constexpr std::string_view xn{"xn-", 3};
12092|  5.60k|    if ((has_x || has_upper) && hv.find(xn) != std::string_view::npos)
  ------------------
  |  Branch (12092:10): [True: 1.77k, False: 3.83k]
  |  Branch (12092:19): [True: 401, False: 3.43k]
  |  Branch (12092:33): [True: 1.24k, False: 933]
  ------------------
12093|  1.24k|        [[unlikely]] {
12094|  1.24k|      return false;
12095|  1.24k|    }
12096|  5.60k|  }
12097|       |
12098|  4.36k|  if (host_end < len && b[host_end] == ':') [[unlikely]] {
  ------------------
  |  Branch (12098:7): [True: 4.21k, False: 146]
  |  Branch (12098:25): [True: 1.21k, False: 3.00k]
  ------------------
12099|  1.21k|    return finish_simple_absolute_with_port(input, out, scheme_type,
12100|  1.21k|                                            protocol_end, host_start, host_end,
12101|  1.21k|                                            host_len, has_upper);
12102|  1.21k|  }
12103|       |
12104|  3.15k|  size_t i = host_end;
12105|  3.15k|  size_t path_start = host_end;
12106|  3.15k|  size_t path_end = host_end;
12107|  3.15k|  size_t query_start = std::string_view::npos;
12108|  3.15k|  size_t hash_start = std::string_view::npos;
12109|  3.15k|  bool has_path = false;
12110|  3.15k|  bool maybe_dot_segment = false;
12111|  3.15k|  bool rest_simple = true;
12112|       |
12113|  3.15k|  if (i < len && b[i] == '/') {
  ------------------
  |  Branch (12113:7): [True: 3.00k, False: 146]
  |  Branch (12113:18): [True: 2.89k, False: 111]
  ------------------
12114|  2.89k|    has_path = true;
12115|  2.89k|    path_start = i;
12116|  2.89k|    ++i;
12117|  2.89k|    scan_path_run(b, i, len, maybe_dot_segment);
12118|  2.89k|    if (i < len) {
  ------------------
  |  Branch (12118:9): [True: 1.16k, False: 1.72k]
  ------------------
12119|  1.16k|      const uint8_t cls = k_path[b[i]];
12120|  1.16k|      if (cls == 1) {
  ------------------
  |  Branch (12120:11): [True: 334, False: 835]
  ------------------
12121|    334|        path_end = i;
12122|    334|        if (b[i] == '?') {
  ------------------
  |  Branch (12122:13): [True: 217, False: 117]
  ------------------
12123|    217|          query_start = i;
12124|    217|          ++i;
12125|    217|          goto scan_query;
12126|    217|        }
12127|    117|        hash_start = i;
12128|    117|        ++i;
12129|    117|        goto scan_hash;
12130|    334|      }
12131|    835|      rest_simple = false;
12132|  34.2k|      for (; i < len; ++i) {
  ------------------
  |  Branch (12132:14): [True: 33.4k, False: 748]
  ------------------
12133|  33.4k|        if (b[i] == '?') {
  ------------------
  |  Branch (12133:13): [True: 68, False: 33.3k]
  ------------------
12134|     68|          path_end = i;
12135|     68|          query_start = i;
12136|     68|          ++i;
12137|     68|          goto scan_query_boundary;
12138|     68|        }
12139|  33.3k|        if (b[i] == '#') {
  ------------------
  |  Branch (12139:13): [True: 19, False: 33.3k]
  ------------------
12140|     19|          path_end = i;
12141|     19|          hash_start = i;
12142|     19|          ++i;
12143|     19|          goto after_rest;
12144|     19|        }
12145|  33.3k|      }
12146|    748|      path_end = i;
12147|    748|      goto after_rest;
12148|    835|    }
12149|  1.72k|    path_end = i;
12150|  1.72k|  } else if (i < len && b[i] == '?') {
  ------------------
  |  Branch (12150:14): [True: 111, False: 146]
  |  Branch (12150:25): [True: 58, False: 53]
  ------------------
12151|     58|    query_start = i;
12152|     58|    ++i;
12153|     58|    goto scan_query;
12154|    199|  } else if (i < len && b[i] == '#') {
  ------------------
  |  Branch (12154:14): [True: 53, False: 146]
  |  Branch (12154:25): [True: 53, False: 0]
  ------------------
12155|     53|    hash_start = i;
12156|     53|    ++i;
12157|     53|    goto scan_hash;
12158|     53|  }
12159|  1.87k|  goto after_rest;
12160|       |
12161|  1.87k|scan_query:
12162|    275|  scan_query_run(b, i, len);
12163|    275|  if (i < len) {
  ------------------
  |  Branch (12163:7): [True: 131, False: 144]
  ------------------
12164|    131|    if (b[i] == '#') {
  ------------------
  |  Branch (12164:9): [True: 96, False: 35]
  ------------------
12165|     96|      hash_start = i;
12166|     96|      ++i;
12167|     96|      goto scan_hash;
12168|     96|    }
12169|     35|    rest_simple = false;
12170|     35|    goto scan_query_boundary;
12171|    131|  }
12172|    144|  goto after_rest;
12173|       |
12174|    144|scan_query_boundary:
12175|  1.40k|  for (; i < len; ++i) {
  ------------------
  |  Branch (12175:10): [True: 1.32k, False: 81]
  ------------------
12176|  1.32k|    if (b[i] == '#') {
  ------------------
  |  Branch (12176:9): [True: 22, False: 1.30k]
  ------------------
12177|     22|      hash_start = i;
12178|     22|      ++i;
12179|     22|      goto after_rest;
12180|     22|    }
12181|  1.32k|  }
12182|     81|  goto after_rest;
12183|       |
12184|    266|scan_hash:
12185|    266|  scan_hash_run(b, i, len);
12186|    266|  if (i < len) {
  ------------------
  |  Branch (12186:7): [True: 50, False: 216]
  ------------------
12187|     50|    rest_simple = false;
12188|     50|  }
12189|       |
12190|  3.15k|after_rest:
12191|  3.15k|  if (rest_simple && maybe_dot_segment) {
  ------------------
  |  Branch (12191:7): [True: 2.23k, False: 920]
  |  Branch (12191:22): [True: 375, False: 1.85k]
  ------------------
12192|    375|    const std::string_view path_body(input.data() + path_start,
12193|    375|                                     path_end - path_start);
12194|    375|    if (path_has_dot_segment(path_body)) {
  ------------------
  |  Branch (12194:9): [True: 177, False: 198]
  ------------------
12195|    177|      rest_simple = false;
12196|    177|    }
12197|    375|  }
12198|       |
12199|       |  // The slow path removes ASCII tab/newline anywhere in the input and trims a
12200|       |  // trailing C0 control or space; this fast path does neither. A query or
12201|       |  // fragment reaching the helpers below would keep those bytes percent-encoded
12202|       |  // ("?a\nb" -> "?a%0Ab", "#f " -> "#f%20") instead of stripped, so hand such
12203|       |  // inputs back to the slow path.
12204|  3.15k|  if (!rest_simple && (unicode::is_c0_control_or_space(input.back()) ||
  ------------------
  |  Branch (12204:7): [True: 1.09k, False: 2.05k]
  |  Branch (12204:24): [True: 15, False: 1.08k]
  ------------------
12205|  1.08k|                       unicode::has_tabs_or_newline(input))) {
  ------------------
  |  Branch (12205:24): [True: 10, False: 1.07k]
  ------------------
12206|     25|    return false;
12207|     25|  }
12208|       |
12209|  3.12k|  out.type = scheme_type;
12210|  3.12k|  out.is_valid = true;
12211|  3.12k|  out.has_opaque_path = false;
12212|  3.12k|  out.host_type = DEFAULT;
12213|       |
12214|  3.12k|  if (!rest_simple) {
  ------------------
  |  Branch (12214:7): [True: 1.07k, False: 2.05k]
  ------------------
12215|       |    // Host is a plain domain. Finish path/query/hash with
12216|       |    // the regular helpers
12217|       |    // so percent-encoding and dot segments do not re-parse the authority.
12218|  1.07k|    const std::string_view path_view =
12219|  1.07k|        has_path
  ------------------
  |  Branch (12219:9): [True: 1.02k, False: 51]
  ------------------
12220|  1.07k|            ? std::string_view(input.data() + path_start, path_end - path_start)
12221|  1.07k|            : std::string_view{};
12222|  1.07k|    auto apply_query_and_hash = [&]() {
12223|  1.07k|      if (query_start != std::string_view::npos) {
12224|  1.07k|        const size_t q_end =
12225|  1.07k|            (hash_start != std::string_view::npos) ? hash_start : len;
12226|  1.07k|        out.update_base_search(std::string_view(input.data() + query_start + 1,
12227|  1.07k|                                                q_end - query_start - 1),
12228|  1.07k|                               character_sets::SPECIAL_QUERY_PERCENT_ENCODE);
12229|  1.07k|      }
12230|  1.07k|      if (hash_start != std::string_view::npos) {
12231|  1.07k|        out.update_unencoded_base_hash(std::string_view(
12232|  1.07k|            input.data() + hash_start + 1, len - hash_start - 1));
12233|  1.07k|      }
12234|  1.07k|    };
12235|  1.07k|    if constexpr (is_aggregator) {
12236|  1.07k|      out.buffer.assign(input.substr(0, host_end));
12237|  1.07k|      if (has_upper) {
  ------------------
  |  Branch (12237:11): [True: 117, False: 955]
  ------------------
12238|    117|        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12239|    117|      }
12240|  1.07k|      out.components.protocol_end = protocol_end;
12241|  1.07k|      out.components.username_end = protocol_end + 2;
12242|  1.07k|      out.components.host_start = protocol_end + 2;
12243|  1.07k|      out.components.host_end = static_cast<uint32_t>(host_end);
12244|  1.07k|      out.components.port = url_components::omitted;
12245|  1.07k|      out.components.pathname_start = static_cast<uint32_t>(host_end);
12246|  1.07k|      out.components.search_start = url_components::omitted;
12247|  1.07k|      out.components.hash_start = url_components::omitted;
12248|  1.07k|      out.parse_path(path_view);
12249|  1.07k|      apply_query_and_hash();
12250|       |    } else {
12251|       |      std::string host_str(input.substr(host_start, host_len));
12252|       |      if (has_upper) {
12253|       |        unicode::to_lower_ascii(host_str.data(), host_str.size());
12254|       |      }
12255|       |      out.host = std::move(host_str);
12256|       |      out.parse_path(path_view);
12257|       |      apply_query_and_hash();
12258|       |    }
12259|  1.07k|    return true;
12260|  1.07k|  }
12261|       |
12262|  2.05k|  const bool need_slash = !has_path;
12263|  2.05k|  if constexpr (is_aggregator) {
12264|  2.05k|    if (!need_slash) {
  ------------------
  |  Branch (12264:9): [True: 1.86k, False: 190]
  ------------------
12265|       |      // assign copies once. resize()+memcpy would value-init then overwrite.
12266|  1.86k|      out.buffer.assign(input);
12267|  1.86k|      if (has_upper) {
  ------------------
  |  Branch (12267:11): [True: 15, False: 1.84k]
  ------------------
12268|     15|        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12269|     15|      }
12270|  1.86k|      out.components.protocol_end = protocol_end;
12271|  1.86k|      out.components.username_end = protocol_end + 2;
12272|  1.86k|      out.components.host_start = protocol_end + 2;
12273|  1.86k|      out.components.host_end = static_cast<uint32_t>(host_end);
12274|  1.86k|      out.components.port = url_components::omitted;
12275|  1.86k|      out.components.pathname_start = static_cast<uint32_t>(path_start);
12276|  1.86k|      out.components.search_start = (query_start != std::string_view::npos)
  ------------------
  |  Branch (12276:37): [True: 207, False: 1.65k]
  ------------------
12277|  1.86k|                                        ? static_cast<uint32_t>(query_start)
12278|  1.86k|                                        : url_components::omitted;
12279|  1.86k|      out.components.hash_start = (hash_start != std::string_view::npos)
  ------------------
  |  Branch (12279:35): [True: 191, False: 1.67k]
  ------------------
12280|  1.86k|                                      ? static_cast<uint32_t>(hash_start)
12281|  1.86k|                                      : url_components::omitted;
12282|  1.86k|    } else {
12283|    190|      out.buffer.clear();
12284|    190|      out.buffer.reserve(len + 1);
12285|    190|      out.buffer.append(input.substr(0, host_end));
12286|    190|      out.buffer.push_back('/');
12287|    190|      if (host_end < len) {
  ------------------
  |  Branch (12287:11): [True: 44, False: 146]
  ------------------
12288|     44|        out.buffer.append(input.substr(host_end));
12289|     44|      }
12290|    190|      if (has_upper) {
  ------------------
  |  Branch (12290:11): [True: 75, False: 115]
  ------------------
12291|     75|        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12292|     75|      }
12293|    190|      out.components.protocol_end = protocol_end;
12294|    190|      out.components.username_end = protocol_end + 2;
12295|    190|      out.components.host_start = protocol_end + 2;
12296|    190|      out.components.host_end = static_cast<uint32_t>(host_end);
12297|    190|      out.components.port = url_components::omitted;
12298|    190|      out.components.pathname_start = static_cast<uint32_t>(host_end);
12299|    190|      out.components.search_start = (query_start != std::string_view::npos)
  ------------------
  |  Branch (12299:37): [True: 30, False: 160]
  ------------------
12300|    190|                                        ? static_cast<uint32_t>(query_start + 1)
12301|    190|                                        : url_components::omitted;
12302|    190|      out.components.hash_start = (hash_start != std::string_view::npos)
  ------------------
  |  Branch (12302:35): [True: 25, False: 165]
  ------------------
12303|    190|                                      ? static_cast<uint32_t>(hash_start + 1)
12304|    190|                                      : url_components::omitted;
12305|    190|    }
12306|       |  } else {
12307|       |    std::string host_str(input.substr(host_start, host_len));
12308|       |    if (has_upper) {
12309|       |      unicode::to_lower_ascii(host_str.data(), host_str.size());
12310|       |    }
12311|       |    out.host = std::move(host_str);
12312|       |    if (need_slash) {
12313|       |      out.path = "/";
12314|       |    } else {
12315|       |      out.path.assign(input.data() + path_start, path_end - path_start);
12316|       |    }
12317|       |    if (query_start != std::string_view::npos) {
12318|       |      const size_t q_end =
12319|       |          (hash_start != std::string_view::npos) ? hash_start : len;
12320|       |      out.query.emplace(input.data() + query_start + 1,
12321|       |                        q_end - query_start - 1);
12322|       |    }
12323|       |    if (hash_start != std::string_view::npos) {
12324|       |      out.hash.emplace(input.data() + hash_start + 1, len - hash_start - 1);
12325|       |    }
12326|       |  }
12327|  2.05k|  return true;
12328|  3.12k|}
_ZN3ada6parser32finish_simple_absolute_with_portINS_3urlEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_NS_6scheme4typeEjmmmb:
11674|  1.21k|    bool has_upper) {
11675|  1.21k|  constexpr bool is_ada_url = std::is_same_v<result_type, ada::url>;
11676|  1.21k|  constexpr bool is_aggregator =
11677|  1.21k|      std::is_same_v<result_type, ada::url_aggregator>;
11678|  1.21k|  static_assert(is_ada_url || is_aggregator);
11679|       |
11680|  1.21k|  const size_t len = input.size();
11681|  1.21k|  const auto* b = reinterpret_cast<const uint8_t*>(input.data());
11682|  1.21k|  size_t p = host_end + 1;
11683|  1.21k|  uint32_t port_value = 0;
11684|  1.21k|  bool any_digit = false;
11685|  2.56k|  while (p < len && b[p] >= '0' && b[p] <= '9') {
  ------------------
  |  Branch (11685:10): [True: 2.50k, False: 55]
  |  Branch (11685:21): [True: 1.42k, False: 1.08k]
  |  Branch (11685:36): [True: 1.35k, False: 62]
  ------------------
11686|  1.35k|    any_digit = true;
11687|  1.35k|    port_value = port_value * 10 + static_cast<uint32_t>(b[p] - '0');
11688|  1.35k|    if (port_value > 65535) [[unlikely]] {
  ------------------
  |  Branch (11688:9): [True: 12, False: 1.34k]
  ------------------
11689|     12|      return false;
11690|     12|    }
11691|  1.34k|    ++p;
11692|  1.34k|  }
11693|  1.20k|  if (p < len && b[p] != '/' && b[p] != '?' && b[p] != '#') [[unlikely]] {
  ------------------
  |  Branch (11693:7): [True: 1.14k, False: 55]
  |  Branch (11693:18): [True: 100, False: 1.04k]
  |  Branch (11693:33): [True: 61, False: 39]
  |  Branch (11693:48): [True: 41, False: 20]
  ------------------
11694|     41|    return false;
11695|     41|  }
11696|  1.16k|  uint32_t parsed_port = url_components::omitted;
11697|  1.16k|  const uint16_t default_port = ada::scheme::get_special_port(scheme_type);
11698|  1.16k|  if (any_digit && port_value != default_port) {
  ------------------
  |  Branch (11698:7): [True: 628, False: 534]
  |  Branch (11698:20): [True: 624, False: 4]
  ------------------
11699|    624|    parsed_port = port_value;
11700|    624|  }
11701|  1.16k|  const size_t authority_end = p;
11702|       |
11703|  1.16k|  size_t i = authority_end;
11704|  1.16k|  size_t path_start = host_end;
11705|  1.16k|  size_t path_end = host_end;
11706|  1.16k|  size_t query_start = std::string_view::npos;
11707|  1.16k|  size_t hash_start = std::string_view::npos;
11708|  1.16k|  bool has_path = false;
11709|  1.16k|  bool maybe_dot_segment = false;
11710|  1.16k|  bool rest_simple = true;
11711|       |
11712|  1.16k|  if (i < len && b[i] == '/') {
  ------------------
  |  Branch (11712:7): [True: 1.10k, False: 55]
  |  Branch (11712:18): [True: 1.04k, False: 59]
  ------------------
11713|  1.04k|    has_path = true;
11714|  1.04k|    path_start = i;
11715|  1.04k|    ++i;
11716|  1.04k|    scan_path_run(b, i, len, maybe_dot_segment);
11717|  1.04k|    if (i < len) {
  ------------------
  |  Branch (11717:9): [True: 665, False: 383]
  ------------------
11718|    665|      const uint8_t cls = k_path[b[i]];
11719|    665|      if (cls == 1) {
  ------------------
  |  Branch (11719:11): [True: 88, False: 577]
  ------------------
11720|     88|        path_end = i;
11721|     88|        if (b[i] == '?') {
  ------------------
  |  Branch (11721:13): [True: 55, False: 33]
  ------------------
11722|     55|          query_start = i;
11723|     55|          ++i;
11724|     55|          goto scan_query;
11725|     55|        }
11726|     33|        hash_start = i;
11727|     33|        ++i;
11728|     33|        goto scan_hash;
11729|     88|      }
11730|    577|      rest_simple = false;
11731|  23.3k|      for (; i < len; ++i) {
  ------------------
  |  Branch (11731:14): [True: 22.8k, False: 523]
  ------------------
11732|  22.8k|        if (b[i] == '?') {
  ------------------
  |  Branch (11732:13): [True: 45, False: 22.7k]
  ------------------
11733|     45|          path_end = i;
11734|     45|          query_start = i;
11735|     45|          ++i;
11736|     45|          goto scan_query_boundary;
11737|     45|        }
11738|  22.7k|        if (b[i] == '#') {
  ------------------
  |  Branch (11738:13): [True: 9, False: 22.7k]
  ------------------
11739|      9|          path_end = i;
11740|      9|          hash_start = i;
11741|      9|          ++i;
11742|      9|          goto after_rest;
11743|      9|        }
11744|  22.7k|      }
11745|    523|      path_end = i;
11746|    523|      goto after_rest;
11747|    577|    }
11748|    383|    path_end = i;
11749|    383|  } else if (i < len && b[i] == '?') {
  ------------------
  |  Branch (11749:14): [True: 59, False: 55]
  |  Branch (11749:25): [True: 39, False: 20]
  ------------------
11750|     39|    query_start = i;
11751|     39|    ++i;
11752|     39|    goto scan_query;
11753|     75|  } else if (i < len && b[i] == '#') {
  ------------------
  |  Branch (11753:14): [True: 20, False: 55]
  |  Branch (11753:25): [True: 20, False: 0]
  ------------------
11754|     20|    hash_start = i;
11755|     20|    ++i;
11756|     20|    goto scan_hash;
11757|     20|  }
11758|    438|  goto after_rest;
11759|       |
11760|    438|scan_query:
11761|     94|  scan_query_run(b, i, len);
11762|     94|  if (i < len) {
  ------------------
  |  Branch (11762:7): [True: 41, False: 53]
  ------------------
11763|     41|    if (b[i] == '#') {
  ------------------
  |  Branch (11763:9): [True: 20, False: 21]
  ------------------
11764|     20|      hash_start = i;
11765|     20|      ++i;
11766|     20|      goto scan_hash;
11767|     20|    }
11768|     21|    rest_simple = false;
11769|     21|    goto scan_query_boundary;
11770|     41|  }
11771|     53|  goto after_rest;
11772|       |
11773|     66|scan_query_boundary:
11774|    871|  for (; i < len; ++i) {
  ------------------
  |  Branch (11774:10): [True: 819, False: 52]
  ------------------
11775|    819|    if (b[i] == '#') {
  ------------------
  |  Branch (11775:9): [True: 14, False: 805]
  ------------------
11776|     14|      hash_start = i;
11777|     14|      ++i;
11778|     14|      goto after_rest;
11779|     14|    }
11780|    819|  }
11781|     52|  goto after_rest;
11782|       |
11783|     73|scan_hash:
11784|     73|  scan_hash_run(b, i, len);
11785|     73|  if (i < len) {
  ------------------
  |  Branch (11785:7): [True: 14, False: 59]
  ------------------
11786|     14|    rest_simple = false;
11787|     14|  }
11788|       |
11789|  1.16k|after_rest:
11790|  1.16k|  if (rest_simple && maybe_dot_segment) {
  ------------------
  |  Branch (11790:7): [True: 550, False: 612]
  |  Branch (11790:22): [True: 254, False: 296]
  ------------------
11791|    254|    const std::string_view path_body(input.data() + path_start,
11792|    254|                                     path_end - path_start);
11793|    254|    if (path_has_dot_segment(path_body)) {
  ------------------
  |  Branch (11793:9): [True: 243, False: 11]
  ------------------
11794|    243|      rest_simple = false;
11795|    243|    }
11796|    254|  }
11797|       |
11798|       |  // The slow path removes ASCII tab/newline anywhere in the input and trims a
11799|       |  // trailing C0 control or space; this fast path does neither. A query or
11800|       |  // fragment reaching the helpers below would keep those bytes percent-encoded
11801|       |  // ("?a\nb" -> "?a%0Ab", "#f " -> "#f%20") instead of stripped, so hand such
11802|       |  // inputs back to the slow path.
11803|  1.16k|  if (!rest_simple && (unicode::is_c0_control_or_space(input.back()) ||
  ------------------
  |  Branch (11803:7): [True: 855, False: 307]
  |  Branch (11803:24): [True: 9, False: 846]
  ------------------
11804|    846|                       unicode::has_tabs_or_newline(input))) {
  ------------------
  |  Branch (11804:24): [True: 14, False: 832]
  ------------------
11805|     23|    return false;
11806|     23|  }
11807|       |
11808|  1.13k|  out.type = scheme_type;
11809|  1.13k|  out.is_valid = true;
11810|  1.13k|  out.has_opaque_path = false;
11811|  1.13k|  out.host_type = DEFAULT;
11812|       |
11813|  1.13k|  const uint32_t port_bytes = (parsed_port != url_components::omitted)
  ------------------
  |  Branch (11813:31): [True: 623, False: 516]
  ------------------
11814|  1.13k|                                  ? (1 + port_decimal_digit_count(parsed_port))
11815|  1.13k|                                  : 0;
11816|       |
11817|  1.13k|  if (!rest_simple) {
  ------------------
  |  Branch (11817:7): [True: 832, False: 307]
  ------------------
11818|    832|    const std::string_view path_view =
11819|    832|        has_path
  ------------------
  |  Branch (11819:9): [True: 816, False: 16]
  ------------------
11820|    832|            ? std::string_view(input.data() + path_start, path_end - path_start)
11821|    832|            : std::string_view{};
11822|    832|    auto apply_query_and_hash = [&]() {
11823|    832|      if (query_start != std::string_view::npos) {
11824|    832|        const size_t q_end =
11825|    832|            (hash_start != std::string_view::npos) ? hash_start : len;
11826|    832|        out.update_base_search(std::string_view(input.data() + query_start + 1,
11827|    832|                                                q_end - query_start - 1),
11828|    832|                               character_sets::SPECIAL_QUERY_PERCENT_ENCODE);
11829|    832|      }
11830|    832|      if (hash_start != std::string_view::npos) {
11831|    832|        out.update_unencoded_base_hash(std::string_view(
11832|    832|            input.data() + hash_start + 1, len - hash_start - 1));
11833|    832|      }
11834|    832|    };
11835|       |    if constexpr (is_aggregator) {
11836|       |      out.buffer.assign(input.substr(0, host_end));
11837|       |      if (parsed_port != url_components::omitted) {
11838|       |        append_canonical_port(out.buffer, parsed_port);
11839|       |      }
11840|       |      if (has_upper) {
11841|       |        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
11842|       |      }
11843|       |      out.components.protocol_end = protocol_end;
11844|       |      out.components.username_end = protocol_end + 2;
11845|       |      out.components.host_start = protocol_end + 2;
11846|       |      out.components.host_end = static_cast<uint32_t>(host_end);
11847|       |      out.components.port = parsed_port;
11848|       |      out.components.pathname_start = static_cast<uint32_t>(out.buffer.size());
11849|       |      out.components.search_start = url_components::omitted;
11850|       |      out.components.hash_start = url_components::omitted;
11851|       |      out.parse_path(path_view);
11852|       |      apply_query_and_hash();
11853|    832|    } else {
11854|    832|      std::string host_str(input.substr(host_start, host_len));
11855|    832|      if (has_upper) {
  ------------------
  |  Branch (11855:11): [True: 119, False: 713]
  ------------------
11856|    119|        unicode::to_lower_ascii(host_str.data(), host_str.size());
11857|    119|      }
11858|    832|      out.host = std::move(host_str);
11859|    832|      if (parsed_port != url_components::omitted) {
  ------------------
  |  Branch (11859:11): [True: 371, False: 461]
  ------------------
11860|    371|        out.port = static_cast<uint16_t>(parsed_port);
11861|    371|      }
11862|    832|      out.parse_path(path_view);
11863|    832|      apply_query_and_hash();
11864|    832|    }
11865|    832|    return true;
11866|    832|  }
11867|       |
11868|    307|  const bool insert_slash = !has_path;
11869|       |  if constexpr (is_aggregator) {
11870|       |    const size_t out_len =
11871|       |        host_end + port_bytes + (insert_slash ? 1 : 0) + (len - authority_end);
11872|       |    const bool omit_port_bytes = parsed_port == url_components::omitted;
11873|       |    if (out_len == len && !insert_slash && !omit_port_bytes) {
11874|       |      out.buffer.assign(input);
11875|       |    } else {
11876|       |      out.buffer.clear();
11877|       |      out.buffer.reserve(out_len);
11878|       |      out.buffer.append(input.substr(0, host_end));
11879|       |      if (parsed_port != url_components::omitted) {
11880|       |        append_canonical_port(out.buffer, parsed_port);
11881|       |      }
11882|       |      if (insert_slash) {
11883|       |        out.buffer.push_back('/');
11884|       |      }
11885|       |      if (authority_end < len) {
11886|       |        out.buffer.append(input.substr(authority_end));
11887|       |      }
11888|       |    }
11889|       |    if (has_upper) {
11890|       |      unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
11891|       |    }
11892|       |    const uint32_t pathname_start =
11893|       |        static_cast<uint32_t>(host_end) + port_bytes;
11894|       |    const int32_t tail_delta = static_cast<int32_t>(pathname_start) +
11895|       |                               (insert_slash ? 1 : 0) -
11896|       |                               static_cast<int32_t>(authority_end);
11897|       |    out.components.protocol_end = protocol_end;
11898|       |    out.components.username_end = protocol_end + 2;
11899|       |    out.components.host_start = protocol_end + 2;
11900|       |    out.components.host_end = static_cast<uint32_t>(host_end);
11901|       |    out.components.port = parsed_port;
11902|       |    out.components.pathname_start = pathname_start;
11903|       |    out.components.search_start =
11904|       |        (query_start != std::string_view::npos)
11905|       |            ? static_cast<uint32_t>(static_cast<int32_t>(query_start) +
11906|       |                                    tail_delta)
11907|       |            : url_components::omitted;
11908|       |    out.components.hash_start =
11909|       |        (hash_start != std::string_view::npos)
11910|       |            ? static_cast<uint32_t>(static_cast<int32_t>(hash_start) +
11911|       |                                    tail_delta)
11912|       |            : url_components::omitted;
11913|    307|  } else {
11914|    307|    std::string host_str(input.substr(host_start, host_len));
11915|    307|    if (has_upper) {
  ------------------
  |  Branch (11915:9): [True: 66, False: 241]
  ------------------
11916|     66|      unicode::to_lower_ascii(host_str.data(), host_str.size());
11917|     66|    }
11918|    307|    out.host = std::move(host_str);
11919|    307|    if (parsed_port != url_components::omitted) {
  ------------------
  |  Branch (11919:9): [True: 252, False: 55]
  ------------------
11920|    252|      out.port = static_cast<uint16_t>(parsed_port);
11921|    252|    }
11922|    307|    if (insert_slash) {
  ------------------
  |  Branch (11922:9): [True: 96, False: 211]
  ------------------
11923|     96|      out.path = "/";
11924|    211|    } else {
11925|    211|      out.path.assign(input.data() + path_start, path_end - path_start);
11926|    211|    }
11927|    307|    if (query_start != std::string_view::npos) {
  ------------------
  |  Branch (11927:9): [True: 70, False: 237]
  ------------------
11928|     70|      const size_t q_end =
11929|     70|          (hash_start != std::string_view::npos) ? hash_start : len;
  ------------------
  |  Branch (11929:11): [True: 19, False: 51]
  ------------------
11930|     70|      out.query.emplace(input.data() + query_start + 1,
11931|     70|                        q_end - query_start - 1);
11932|     70|    }
11933|    307|    if (hash_start != std::string_view::npos) {
  ------------------
  |  Branch (11933:9): [True: 59, False: 248]
  ------------------
11934|     59|      out.hash.emplace(input.data() + hash_start + 1, len - hash_start - 1);
11935|     59|    }
11936|    307|  }
11937|    307|  return true;
11938|  1.13k|}
_ZN3ada6parser32finish_simple_absolute_with_portINS_14url_aggregatorEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_NS_6scheme4typeEjmmmb:
11674|  1.21k|    bool has_upper) {
11675|  1.21k|  constexpr bool is_ada_url = std::is_same_v<result_type, ada::url>;
11676|  1.21k|  constexpr bool is_aggregator =
11677|  1.21k|      std::is_same_v<result_type, ada::url_aggregator>;
11678|  1.21k|  static_assert(is_ada_url || is_aggregator);
11679|       |
11680|  1.21k|  const size_t len = input.size();
11681|  1.21k|  const auto* b = reinterpret_cast<const uint8_t*>(input.data());
11682|  1.21k|  size_t p = host_end + 1;
11683|  1.21k|  uint32_t port_value = 0;
11684|  1.21k|  bool any_digit = false;
11685|  2.56k|  while (p < len && b[p] >= '0' && b[p] <= '9') {
  ------------------
  |  Branch (11685:10): [True: 2.50k, False: 55]
  |  Branch (11685:21): [True: 1.42k, False: 1.08k]
  |  Branch (11685:36): [True: 1.35k, False: 62]
  ------------------
11686|  1.35k|    any_digit = true;
11687|  1.35k|    port_value = port_value * 10 + static_cast<uint32_t>(b[p] - '0');
11688|  1.35k|    if (port_value > 65535) [[unlikely]] {
  ------------------
  |  Branch (11688:9): [True: 12, False: 1.34k]
  ------------------
11689|     12|      return false;
11690|     12|    }
11691|  1.34k|    ++p;
11692|  1.34k|  }
11693|  1.20k|  if (p < len && b[p] != '/' && b[p] != '?' && b[p] != '#') [[unlikely]] {
  ------------------
  |  Branch (11693:7): [True: 1.14k, False: 55]
  |  Branch (11693:18): [True: 100, False: 1.04k]
  |  Branch (11693:33): [True: 61, False: 39]
  |  Branch (11693:48): [True: 41, False: 20]
  ------------------
11694|     41|    return false;
11695|     41|  }
11696|  1.16k|  uint32_t parsed_port = url_components::omitted;
11697|  1.16k|  const uint16_t default_port = ada::scheme::get_special_port(scheme_type);
11698|  1.16k|  if (any_digit && port_value != default_port) {
  ------------------
  |  Branch (11698:7): [True: 628, False: 534]
  |  Branch (11698:20): [True: 624, False: 4]
  ------------------
11699|    624|    parsed_port = port_value;
11700|    624|  }
11701|  1.16k|  const size_t authority_end = p;
11702|       |
11703|  1.16k|  size_t i = authority_end;
11704|  1.16k|  size_t path_start = host_end;
11705|  1.16k|  size_t path_end = host_end;
11706|  1.16k|  size_t query_start = std::string_view::npos;
11707|  1.16k|  size_t hash_start = std::string_view::npos;
11708|  1.16k|  bool has_path = false;
11709|  1.16k|  bool maybe_dot_segment = false;
11710|  1.16k|  bool rest_simple = true;
11711|       |
11712|  1.16k|  if (i < len && b[i] == '/') {
  ------------------
  |  Branch (11712:7): [True: 1.10k, False: 55]
  |  Branch (11712:18): [True: 1.04k, False: 59]
  ------------------
11713|  1.04k|    has_path = true;
11714|  1.04k|    path_start = i;
11715|  1.04k|    ++i;
11716|  1.04k|    scan_path_run(b, i, len, maybe_dot_segment);
11717|  1.04k|    if (i < len) {
  ------------------
  |  Branch (11717:9): [True: 665, False: 383]
  ------------------
11718|    665|      const uint8_t cls = k_path[b[i]];
11719|    665|      if (cls == 1) {
  ------------------
  |  Branch (11719:11): [True: 88, False: 577]
  ------------------
11720|     88|        path_end = i;
11721|     88|        if (b[i] == '?') {
  ------------------
  |  Branch (11721:13): [True: 55, False: 33]
  ------------------
11722|     55|          query_start = i;
11723|     55|          ++i;
11724|     55|          goto scan_query;
11725|     55|        }
11726|     33|        hash_start = i;
11727|     33|        ++i;
11728|     33|        goto scan_hash;
11729|     88|      }
11730|    577|      rest_simple = false;
11731|  23.3k|      for (; i < len; ++i) {
  ------------------
  |  Branch (11731:14): [True: 22.8k, False: 523]
  ------------------
11732|  22.8k|        if (b[i] == '?') {
  ------------------
  |  Branch (11732:13): [True: 45, False: 22.7k]
  ------------------
11733|     45|          path_end = i;
11734|     45|          query_start = i;
11735|     45|          ++i;
11736|     45|          goto scan_query_boundary;
11737|     45|        }
11738|  22.7k|        if (b[i] == '#') {
  ------------------
  |  Branch (11738:13): [True: 9, False: 22.7k]
  ------------------
11739|      9|          path_end = i;
11740|      9|          hash_start = i;
11741|      9|          ++i;
11742|      9|          goto after_rest;
11743|      9|        }
11744|  22.7k|      }
11745|    523|      path_end = i;
11746|    523|      goto after_rest;
11747|    577|    }
11748|    383|    path_end = i;
11749|    383|  } else if (i < len && b[i] == '?') {
  ------------------
  |  Branch (11749:14): [True: 59, False: 55]
  |  Branch (11749:25): [True: 39, False: 20]
  ------------------
11750|     39|    query_start = i;
11751|     39|    ++i;
11752|     39|    goto scan_query;
11753|     75|  } else if (i < len && b[i] == '#') {
  ------------------
  |  Branch (11753:14): [True: 20, False: 55]
  |  Branch (11753:25): [True: 20, False: 0]
  ------------------
11754|     20|    hash_start = i;
11755|     20|    ++i;
11756|     20|    goto scan_hash;
11757|     20|  }
11758|    438|  goto after_rest;
11759|       |
11760|    438|scan_query:
11761|     94|  scan_query_run(b, i, len);
11762|     94|  if (i < len) {
  ------------------
  |  Branch (11762:7): [True: 41, False: 53]
  ------------------
11763|     41|    if (b[i] == '#') {
  ------------------
  |  Branch (11763:9): [True: 20, False: 21]
  ------------------
11764|     20|      hash_start = i;
11765|     20|      ++i;
11766|     20|      goto scan_hash;
11767|     20|    }
11768|     21|    rest_simple = false;
11769|     21|    goto scan_query_boundary;
11770|     41|  }
11771|     53|  goto after_rest;
11772|       |
11773|     66|scan_query_boundary:
11774|    871|  for (; i < len; ++i) {
  ------------------
  |  Branch (11774:10): [True: 819, False: 52]
  ------------------
11775|    819|    if (b[i] == '#') {
  ------------------
  |  Branch (11775:9): [True: 14, False: 805]
  ------------------
11776|     14|      hash_start = i;
11777|     14|      ++i;
11778|     14|      goto after_rest;
11779|     14|    }
11780|    819|  }
11781|     52|  goto after_rest;
11782|       |
11783|     73|scan_hash:
11784|     73|  scan_hash_run(b, i, len);
11785|     73|  if (i < len) {
  ------------------
  |  Branch (11785:7): [True: 14, False: 59]
  ------------------
11786|     14|    rest_simple = false;
11787|     14|  }
11788|       |
11789|  1.16k|after_rest:
11790|  1.16k|  if (rest_simple && maybe_dot_segment) {
  ------------------
  |  Branch (11790:7): [True: 550, False: 612]
  |  Branch (11790:22): [True: 254, False: 296]
  ------------------
11791|    254|    const std::string_view path_body(input.data() + path_start,
11792|    254|                                     path_end - path_start);
11793|    254|    if (path_has_dot_segment(path_body)) {
  ------------------
  |  Branch (11793:9): [True: 243, False: 11]
  ------------------
11794|    243|      rest_simple = false;
11795|    243|    }
11796|    254|  }
11797|       |
11798|       |  // The slow path removes ASCII tab/newline anywhere in the input and trims a
11799|       |  // trailing C0 control or space; this fast path does neither. A query or
11800|       |  // fragment reaching the helpers below would keep those bytes percent-encoded
11801|       |  // ("?a\nb" -> "?a%0Ab", "#f " -> "#f%20") instead of stripped, so hand such
11802|       |  // inputs back to the slow path.
11803|  1.16k|  if (!rest_simple && (unicode::is_c0_control_or_space(input.back()) ||
  ------------------
  |  Branch (11803:7): [True: 855, False: 307]
  |  Branch (11803:24): [True: 9, False: 846]
  ------------------
11804|    846|                       unicode::has_tabs_or_newline(input))) {
  ------------------
  |  Branch (11804:24): [True: 14, False: 832]
  ------------------
11805|     23|    return false;
11806|     23|  }
11807|       |
11808|  1.13k|  out.type = scheme_type;
11809|  1.13k|  out.is_valid = true;
11810|  1.13k|  out.has_opaque_path = false;
11811|  1.13k|  out.host_type = DEFAULT;
11812|       |
11813|  1.13k|  const uint32_t port_bytes = (parsed_port != url_components::omitted)
  ------------------
  |  Branch (11813:31): [True: 623, False: 516]
  ------------------
11814|  1.13k|                                  ? (1 + port_decimal_digit_count(parsed_port))
11815|  1.13k|                                  : 0;
11816|       |
11817|  1.13k|  if (!rest_simple) {
  ------------------
  |  Branch (11817:7): [True: 832, False: 307]
  ------------------
11818|    832|    const std::string_view path_view =
11819|    832|        has_path
  ------------------
  |  Branch (11819:9): [True: 816, False: 16]
  ------------------
11820|    832|            ? std::string_view(input.data() + path_start, path_end - path_start)
11821|    832|            : std::string_view{};
11822|    832|    auto apply_query_and_hash = [&]() {
11823|    832|      if (query_start != std::string_view::npos) {
11824|    832|        const size_t q_end =
11825|    832|            (hash_start != std::string_view::npos) ? hash_start : len;
11826|    832|        out.update_base_search(std::string_view(input.data() + query_start + 1,
11827|    832|                                                q_end - query_start - 1),
11828|    832|                               character_sets::SPECIAL_QUERY_PERCENT_ENCODE);
11829|    832|      }
11830|    832|      if (hash_start != std::string_view::npos) {
11831|    832|        out.update_unencoded_base_hash(std::string_view(
11832|    832|            input.data() + hash_start + 1, len - hash_start - 1));
11833|    832|      }
11834|    832|    };
11835|    832|    if constexpr (is_aggregator) {
11836|    832|      out.buffer.assign(input.substr(0, host_end));
11837|    832|      if (parsed_port != url_components::omitted) {
  ------------------
  |  Branch (11837:11): [True: 371, False: 461]
  ------------------
11838|    371|        append_canonical_port(out.buffer, parsed_port);
11839|    371|      }
11840|    832|      if (has_upper) {
  ------------------
  |  Branch (11840:11): [True: 119, False: 713]
  ------------------
11841|    119|        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
11842|    119|      }
11843|    832|      out.components.protocol_end = protocol_end;
11844|    832|      out.components.username_end = protocol_end + 2;
11845|    832|      out.components.host_start = protocol_end + 2;
11846|    832|      out.components.host_end = static_cast<uint32_t>(host_end);
11847|    832|      out.components.port = parsed_port;
11848|    832|      out.components.pathname_start = static_cast<uint32_t>(out.buffer.size());
11849|    832|      out.components.search_start = url_components::omitted;
11850|    832|      out.components.hash_start = url_components::omitted;
11851|    832|      out.parse_path(path_view);
11852|    832|      apply_query_and_hash();
11853|       |    } else {
11854|       |      std::string host_str(input.substr(host_start, host_len));
11855|       |      if (has_upper) {
11856|       |        unicode::to_lower_ascii(host_str.data(), host_str.size());
11857|       |      }
11858|       |      out.host = std::move(host_str);
11859|       |      if (parsed_port != url_components::omitted) {
11860|       |        out.port = static_cast<uint16_t>(parsed_port);
11861|       |      }
11862|       |      out.parse_path(path_view);
11863|       |      apply_query_and_hash();
11864|       |    }
11865|    832|    return true;
11866|    832|  }
11867|       |
11868|    307|  const bool insert_slash = !has_path;
11869|    307|  if constexpr (is_aggregator) {
11870|    307|    const size_t out_len =
11871|    307|        host_end + port_bytes + (insert_slash ? 1 : 0) + (len - authority_end);
  ------------------
  |  Branch (11871:34): [True: 96, False: 211]
  ------------------
11872|    307|    const bool omit_port_bytes = parsed_port == url_components::omitted;
11873|    307|    if (out_len == len && !insert_slash && !omit_port_bytes) {
  ------------------
  |  Branch (11873:9): [True: 241, False: 66]
  |  Branch (11873:27): [True: 200, False: 41]
  |  Branch (11873:44): [True: 200, False: 0]
  ------------------
11874|    200|      out.buffer.assign(input);
11875|    200|    } else {
11876|    107|      out.buffer.clear();
11877|    107|      out.buffer.reserve(out_len);
11878|    107|      out.buffer.append(input.substr(0, host_end));
11879|    107|      if (parsed_port != url_components::omitted) {
  ------------------
  |  Branch (11879:11): [True: 52, False: 55]
  ------------------
11880|     52|        append_canonical_port(out.buffer, parsed_port);
11881|     52|      }
11882|    107|      if (insert_slash) {
  ------------------
  |  Branch (11882:11): [True: 96, False: 11]
  ------------------
11883|     96|        out.buffer.push_back('/');
11884|     96|      }
11885|    107|      if (authority_end < len) {
  ------------------
  |  Branch (11885:11): [True: 52, False: 55]
  ------------------
11886|     52|        out.buffer.append(input.substr(authority_end));
11887|     52|      }
11888|    107|    }
11889|    307|    if (has_upper) {
  ------------------
  |  Branch (11889:9): [True: 66, False: 241]
  ------------------
11890|     66|      unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
11891|     66|    }
11892|    307|    const uint32_t pathname_start =
11893|    307|        static_cast<uint32_t>(host_end) + port_bytes;
11894|    307|    const int32_t tail_delta = static_cast<int32_t>(pathname_start) +
11895|    307|                               (insert_slash ? 1 : 0) -
  ------------------
  |  Branch (11895:33): [True: 96, False: 211]
  ------------------
11896|    307|                               static_cast<int32_t>(authority_end);
11897|    307|    out.components.protocol_end = protocol_end;
11898|    307|    out.components.username_end = protocol_end + 2;
11899|    307|    out.components.host_start = protocol_end + 2;
11900|    307|    out.components.host_end = static_cast<uint32_t>(host_end);
11901|    307|    out.components.port = parsed_port;
11902|    307|    out.components.pathname_start = pathname_start;
11903|    307|    out.components.search_start =
11904|    307|        (query_start != std::string_view::npos)
  ------------------
  |  Branch (11904:9): [True: 70, False: 237]
  ------------------
11905|    307|            ? static_cast<uint32_t>(static_cast<int32_t>(query_start) +
11906|     70|                                    tail_delta)
11907|    307|            : url_components::omitted;
11908|    307|    out.components.hash_start =
11909|    307|        (hash_start != std::string_view::npos)
  ------------------
  |  Branch (11909:9): [True: 59, False: 248]
  ------------------
11910|    307|            ? static_cast<uint32_t>(static_cast<int32_t>(hash_start) +
11911|     59|                                    tail_delta)
11912|    307|            : url_components::omitted;
11913|       |  } else {
11914|       |    std::string host_str(input.substr(host_start, host_len));
11915|       |    if (has_upper) {
11916|       |      unicode::to_lower_ascii(host_str.data(), host_str.size());
11917|       |    }
11918|       |    out.host = std::move(host_str);
11919|       |    if (parsed_port != url_components::omitted) {
11920|       |      out.port = static_cast<uint16_t>(parsed_port);
11921|       |    }
11922|       |    if (insert_slash) {
11923|       |      out.path = "/";
11924|       |    } else {
11925|       |      out.path.assign(input.data() + path_start, path_end - path_start);
11926|       |    }
11927|       |    if (query_start != std::string_view::npos) {
11928|       |      const size_t q_end =
11929|       |          (hash_start != std::string_view::npos) ? hash_start : len;
11930|       |      out.query.emplace(input.data() + query_start + 1,
11931|       |                        q_end - query_start - 1);
11932|       |    }
11933|       |    if (hash_start != std::string_view::npos) {
11934|       |      out.hash.emplace(input.data() + hash_start + 1, len - hash_start - 1);
11935|       |    }
11936|       |  }
11937|    307|  return true;
11938|  1.13k|}
_ZN3ada6parser25try_parse_simple_relativeINS_3urlEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERKT_RS8_:
12336|  3.97k|                                                result_type& out) {
12337|  3.97k|  constexpr bool is_ada_url = std::is_same_v<result_type, ada::url>;
12338|  3.97k|  constexpr bool is_aggregator =
12339|  3.97k|      std::is_same_v<result_type, ada::url_aggregator>;
12340|  3.97k|  static_assert(is_ada_url || is_aggregator);
12341|       |
12342|  3.97k|  if (!base.is_special() || base.type == ada::scheme::type::FILE ||
  ------------------
  |  Branch (12342:7): [True: 2.35k, False: 1.61k]
  |  Branch (12342:29): [True: 406, False: 1.21k]
  ------------------
12343|  2.84k|      base.has_opaque_path || input.empty()) {
  ------------------
  |  Branch (12343:7): [True: 0, False: 1.21k]
  |  Branch (12343:31): [True: 83, False: 1.12k]
  ------------------
12344|  2.84k|    return false;
12345|  2.84k|  }
12346|  1.12k|  const auto* b = reinterpret_cast<const uint8_t*>(input.data());
12347|  1.12k|  const size_t len = input.size();
12348|  1.12k|  const uint8_t first = b[0];
12349|  1.12k|  const bool path_relative = first != '/' && first != '?' && first != '#';
  ------------------
  |  Branch (12349:30): [True: 1.08k, False: 40]
  |  Branch (12349:46): [True: 1.06k, False: 26]
  |  Branch (12349:62): [True: 1.02k, False: 43]
  ------------------
12350|  1.12k|  if (first == '/' && len > 1 && (b[1] == '/' || b[1] == '\\')) {
  ------------------
  |  Branch (12350:7): [True: 40, False: 1.08k]
  |  Branch (12350:23): [True: 27, False: 13]
  |  Branch (12350:35): [True: 3, False: 24]
  |  Branch (12350:50): [True: 1, False: 23]
  ------------------
12351|      4|    return false;
12352|      4|  }
12353|       |  // A ':' before the first / ? # is a scheme, not a path segment.
12354|  1.12k|  if (path_relative) {
  ------------------
  |  Branch (12354:7): [True: 1.02k, False: 105]
  ------------------
12355|  1.02k|    const size_t delim = input.find_first_of("/?#:");
12356|  1.02k|    if (delim != std::string_view::npos && input[delim] == ':') {
  ------------------
  |  Branch (12356:9): [True: 879, False: 141]
  |  Branch (12356:44): [True: 769, False: 110]
  ------------------
12357|    769|      return false;
12358|    769|    }
12359|  1.02k|  }
12360|       |
12361|    356|  size_t i = 0;
12362|    356|  size_t path_start = 0;
12363|    356|  size_t path_end = 0;
12364|    356|  size_t query_start = std::string_view::npos;
12365|    356|  size_t hash_start = std::string_view::npos;
12366|    356|  bool has_path = false;
12367|    356|  bool maybe_dot_segment = false;
12368|       |
12369|    356|  if (first == '/' || path_relative) {
  ------------------
  |  Branch (12369:7): [True: 36, False: 320]
  |  Branch (12369:23): [True: 251, False: 69]
  ------------------
12370|    287|    has_path = true;
12371|    287|    path_start = 0;
12372|    287|    if (first == '/') {
  ------------------
  |  Branch (12372:9): [True: 36, False: 251]
  ------------------
12373|     36|      i = 1;
12374|     36|    }
12375|    287|    scan_path_run(b, i, len, maybe_dot_segment);
12376|    287|    if (i < len) {
  ------------------
  |  Branch (12376:9): [True: 102, False: 185]
  ------------------
12377|    102|      const uint8_t cls = k_path[b[i]];
12378|    102|      if (cls == 2) {
  ------------------
  |  Branch (12378:11): [True: 76, False: 26]
  ------------------
12379|     76|        return false;
12380|     76|      }
12381|    102|    }
12382|    211|    path_end = i;
12383|    211|    if (i < len && b[i] == '?') {
  ------------------
  |  Branch (12383:9): [True: 26, False: 185]
  |  Branch (12383:20): [True: 18, False: 8]
  ------------------
12384|     18|      query_start = i;
12385|     18|      ++i;
12386|     18|      scan_query_run(b, i, len);
12387|     18|      if (i < len) {
  ------------------
  |  Branch (12387:11): [True: 11, False: 7]
  ------------------
12388|     11|        if (b[i] != '#') {
  ------------------
  |  Branch (12388:13): [True: 3, False: 8]
  ------------------
12389|      3|          return false;
12390|      3|        }
12391|      8|        hash_start = i;
12392|      8|        ++i;
12393|      8|        scan_hash_run(b, i, len);
12394|      8|        if (i < len) {
  ------------------
  |  Branch (12394:13): [True: 1, False: 7]
  ------------------
12395|      1|          return false;
12396|      1|        }
12397|      8|      }
12398|    193|    } else if (i < len && b[i] == '#') {
  ------------------
  |  Branch (12398:16): [True: 8, False: 185]
  |  Branch (12398:27): [True: 8, False: 0]
  ------------------
12399|      8|      hash_start = i;
12400|      8|      ++i;
12401|      8|      scan_hash_run(b, i, len);
12402|      8|      if (i < len) {
  ------------------
  |  Branch (12402:11): [True: 2, False: 6]
  ------------------
12403|      2|        return false;
12404|      2|      }
12405|    185|    } else if (i < len) {
  ------------------
  |  Branch (12405:16): [True: 0, False: 185]
  ------------------
12406|      0|      return false;
12407|      0|    }
12408|    211|  } else if (first == '?') {
  ------------------
  |  Branch (12408:14): [True: 26, False: 43]
  ------------------
12409|     26|    query_start = 0;
12410|     26|    i = 1;
12411|     26|    scan_query_run(b, i, len);
12412|     26|    if (i < len) {
  ------------------
  |  Branch (12412:9): [True: 15, False: 11]
  ------------------
12413|     15|      if (b[i] != '#') {
  ------------------
  |  Branch (12413:11): [True: 7, False: 8]
  ------------------
12414|      7|        return false;
12415|      7|      }
12416|      8|      hash_start = i;
12417|      8|      ++i;
12418|      8|      scan_hash_run(b, i, len);
12419|      8|      if (i < len) {
  ------------------
  |  Branch (12419:11): [True: 4, False: 4]
  ------------------
12420|      4|        return false;
12421|      4|      }
12422|      8|    }
12423|     43|  } else {
12424|     43|    hash_start = 0;
12425|     43|    i = 1;
12426|     43|    scan_hash_run(b, i, len);
12427|     43|    if (i < len) {
  ------------------
  |  Branch (12427:9): [True: 18, False: 25]
  ------------------
12428|     18|      return false;
12429|     18|    }
12430|     43|  }
12431|       |
12432|    245|  if (has_path && maybe_dot_segment) {
  ------------------
  |  Branch (12432:7): [True: 205, False: 40]
  |  Branch (12432:19): [True: 98, False: 107]
  ------------------
12433|     98|    const std::string_view path_body(input.data() + path_start,
12434|     98|                                     path_end - path_start);
12435|     98|    if (path_has_dot_segment(path_body)) {
  ------------------
  |  Branch (12435:9): [True: 93, False: 5]
  ------------------
12436|     93|      return false;
12437|     93|    }
12438|     98|  }
12439|       |
12440|    152|  out = base;
12441|    152|  out.is_valid = true;
12442|    152|  out.has_opaque_path = false;
12443|       |
12444|    152|  const size_t q_end =
12445|    152|      (hash_start != std::string_view::npos) ? hash_start : len;
  ------------------
  |  Branch (12445:7): [True: 42, False: 110]
  ------------------
12446|    152|  const bool has_query = query_start != std::string_view::npos;
12447|    152|  const bool has_hash = hash_start != std::string_view::npos;
12448|    152|  const std::string_view query =
12449|    152|      has_query ? std::string_view(input.data() + query_start + 1,
  ------------------
  |  Branch (12449:7): [True: 29, False: 123]
  ------------------
12450|     29|                                   q_end - query_start - 1)
12451|    152|                : std::string_view{};
12452|    152|  const std::string_view hash =
12453|    152|      has_hash ? std::string_view(input.data() + hash_start + 1,
  ------------------
  |  Branch (12453:7): [True: 42, False: 110]
  ------------------
12454|     42|                                  len - hash_start - 1)
12455|    152|               : std::string_view{};
12456|       |
12457|       |  if constexpr (is_aggregator) {
12458|       |    if (first == '/' || first == '?' || path_relative) {
12459|       |      out.clear_hash();
12460|       |      out.clear_search();
12461|       |    }
12462|       |    if (first == '/') {
12463|       |      out.update_base_pathname(input.substr(path_start, path_end - path_start));
12464|       |    } else if (path_relative) {
12465|       |      const std::string_view base_path = out.get_pathname();
12466|       |      const size_t slash = base_path.rfind('/');
12467|       |      const std::string_view prefix = (slash == std::string_view::npos)
12468|       |                                          ? std::string_view("/")
12469|       |                                          : base_path.substr(0, slash + 1);
12470|       |      const std::string_view rel(input.data() + path_start,
12471|       |                                 path_end - path_start);
12472|       |      std::string new_path;
12473|       |      new_path.reserve(prefix.size() + rel.size());
12474|       |      new_path.assign(prefix);
12475|       |      new_path.append(rel);
12476|       |      out.update_base_pathname(new_path);
12477|       |    }
12478|       |    if (has_query) {
12479|       |      // Do not use update_base_search: it strips a leading '?' and would
12480|       |      // collapse '??a=b' into '?a=b'.
12481|       |      out.components.search_start = static_cast<uint32_t>(out.buffer.size());
12482|       |      out.buffer += '?';
12483|       |      out.buffer.append(query);
12484|       |    }
12485|       |    if (has_hash) {
12486|       |      out.update_unencoded_base_hash(hash);
12487|       |    }
12488|    152|  } else {
12489|    152|    if (first == '/' || first == '?' || path_relative) {
  ------------------
  |  Branch (12489:9): [True: 25, False: 127]
  |  Branch (12489:25): [True: 15, False: 112]
  |  Branch (12489:41): [True: 87, False: 25]
  ------------------
12490|    127|      out.hash.reset();
12491|    127|    }
12492|    152|    if (first == '/') {
  ------------------
  |  Branch (12492:9): [True: 25, False: 127]
  ------------------
12493|     25|      out.query.reset();
12494|     25|      out.path.assign(input.substr(path_start, path_end - path_start));
12495|    127|    } else if (path_relative) {
  ------------------
  |  Branch (12495:16): [True: 87, False: 40]
  ------------------
12496|     87|      out.query.reset();
12497|     87|      const size_t slash = out.path.rfind('/');
12498|     87|      if (slash == std::string::npos) {
  ------------------
  |  Branch (12498:11): [True: 0, False: 87]
  ------------------
12499|      0|        out.path = '/';
12500|     87|      } else {
12501|     87|        out.path.resize(slash + 1);
12502|     87|      }
12503|     87|      out.path.append(input.substr(path_start, path_end - path_start));
12504|     87|    }
12505|    152|    if (has_query) {
  ------------------
  |  Branch (12505:9): [True: 29, False: 123]
  ------------------
12506|     29|      out.query.emplace(query);
12507|     29|    }
12508|    152|    if (has_hash) {
  ------------------
  |  Branch (12508:9): [True: 42, False: 110]
  ------------------
12509|     42|      out.hash.emplace(hash);
12510|     42|    }
12511|    152|  }
12512|    152|  return true;
12513|    245|}
_ZN3ada6parser25try_parse_simple_relativeINS_14url_aggregatorEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERKT_RS8_:
12336|  3.97k|                                                result_type& out) {
12337|  3.97k|  constexpr bool is_ada_url = std::is_same_v<result_type, ada::url>;
12338|  3.97k|  constexpr bool is_aggregator =
12339|  3.97k|      std::is_same_v<result_type, ada::url_aggregator>;
12340|  3.97k|  static_assert(is_ada_url || is_aggregator);
12341|       |
12342|  3.97k|  if (!base.is_special() || base.type == ada::scheme::type::FILE ||
  ------------------
  |  Branch (12342:7): [True: 2.35k, False: 1.61k]
  |  Branch (12342:29): [True: 406, False: 1.21k]
  ------------------
12343|  2.84k|      base.has_opaque_path || input.empty()) {
  ------------------
  |  Branch (12343:7): [True: 0, False: 1.21k]
  |  Branch (12343:31): [True: 83, False: 1.12k]
  ------------------
12344|  2.84k|    return false;
12345|  2.84k|  }
12346|  1.12k|  const auto* b = reinterpret_cast<const uint8_t*>(input.data());
12347|  1.12k|  const size_t len = input.size();
12348|  1.12k|  const uint8_t first = b[0];
12349|  1.12k|  const bool path_relative = first != '/' && first != '?' && first != '#';
  ------------------
  |  Branch (12349:30): [True: 1.08k, False: 40]
  |  Branch (12349:46): [True: 1.06k, False: 26]
  |  Branch (12349:62): [True: 1.02k, False: 43]
  ------------------
12350|  1.12k|  if (first == '/' && len > 1 && (b[1] == '/' || b[1] == '\\')) {
  ------------------
  |  Branch (12350:7): [True: 40, False: 1.08k]
  |  Branch (12350:23): [True: 27, False: 13]
  |  Branch (12350:35): [True: 3, False: 24]
  |  Branch (12350:50): [True: 1, False: 23]
  ------------------
12351|      4|    return false;
12352|      4|  }
12353|       |  // A ':' before the first / ? # is a scheme, not a path segment.
12354|  1.12k|  if (path_relative) {
  ------------------
  |  Branch (12354:7): [True: 1.02k, False: 105]
  ------------------
12355|  1.02k|    const size_t delim = input.find_first_of("/?#:");
12356|  1.02k|    if (delim != std::string_view::npos && input[delim] == ':') {
  ------------------
  |  Branch (12356:9): [True: 879, False: 141]
  |  Branch (12356:44): [True: 769, False: 110]
  ------------------
12357|    769|      return false;
12358|    769|    }
12359|  1.02k|  }
12360|       |
12361|    356|  size_t i = 0;
12362|    356|  size_t path_start = 0;
12363|    356|  size_t path_end = 0;
12364|    356|  size_t query_start = std::string_view::npos;
12365|    356|  size_t hash_start = std::string_view::npos;
12366|    356|  bool has_path = false;
12367|    356|  bool maybe_dot_segment = false;
12368|       |
12369|    356|  if (first == '/' || path_relative) {
  ------------------
  |  Branch (12369:7): [True: 36, False: 320]
  |  Branch (12369:23): [True: 251, False: 69]
  ------------------
12370|    287|    has_path = true;
12371|    287|    path_start = 0;
12372|    287|    if (first == '/') {
  ------------------
  |  Branch (12372:9): [True: 36, False: 251]
  ------------------
12373|     36|      i = 1;
12374|     36|    }
12375|    287|    scan_path_run(b, i, len, maybe_dot_segment);
12376|    287|    if (i < len) {
  ------------------
  |  Branch (12376:9): [True: 102, False: 185]
  ------------------
12377|    102|      const uint8_t cls = k_path[b[i]];
12378|    102|      if (cls == 2) {
  ------------------
  |  Branch (12378:11): [True: 76, False: 26]
  ------------------
12379|     76|        return false;
12380|     76|      }
12381|    102|    }
12382|    211|    path_end = i;
12383|    211|    if (i < len && b[i] == '?') {
  ------------------
  |  Branch (12383:9): [True: 26, False: 185]
  |  Branch (12383:20): [True: 18, False: 8]
  ------------------
12384|     18|      query_start = i;
12385|     18|      ++i;
12386|     18|      scan_query_run(b, i, len);
12387|     18|      if (i < len) {
  ------------------
  |  Branch (12387:11): [True: 11, False: 7]
  ------------------
12388|     11|        if (b[i] != '#') {
  ------------------
  |  Branch (12388:13): [True: 3, False: 8]
  ------------------
12389|      3|          return false;
12390|      3|        }
12391|      8|        hash_start = i;
12392|      8|        ++i;
12393|      8|        scan_hash_run(b, i, len);
12394|      8|        if (i < len) {
  ------------------
  |  Branch (12394:13): [True: 1, False: 7]
  ------------------
12395|      1|          return false;
12396|      1|        }
12397|      8|      }
12398|    193|    } else if (i < len && b[i] == '#') {
  ------------------
  |  Branch (12398:16): [True: 8, False: 185]
  |  Branch (12398:27): [True: 8, False: 0]
  ------------------
12399|      8|      hash_start = i;
12400|      8|      ++i;
12401|      8|      scan_hash_run(b, i, len);
12402|      8|      if (i < len) {
  ------------------
  |  Branch (12402:11): [True: 2, False: 6]
  ------------------
12403|      2|        return false;
12404|      2|      }
12405|    185|    } else if (i < len) {
  ------------------
  |  Branch (12405:16): [True: 0, False: 185]
  ------------------
12406|      0|      return false;
12407|      0|    }
12408|    211|  } else if (first == '?') {
  ------------------
  |  Branch (12408:14): [True: 26, False: 43]
  ------------------
12409|     26|    query_start = 0;
12410|     26|    i = 1;
12411|     26|    scan_query_run(b, i, len);
12412|     26|    if (i < len) {
  ------------------
  |  Branch (12412:9): [True: 15, False: 11]
  ------------------
12413|     15|      if (b[i] != '#') {
  ------------------
  |  Branch (12413:11): [True: 7, False: 8]
  ------------------
12414|      7|        return false;
12415|      7|      }
12416|      8|      hash_start = i;
12417|      8|      ++i;
12418|      8|      scan_hash_run(b, i, len);
12419|      8|      if (i < len) {
  ------------------
  |  Branch (12419:11): [True: 4, False: 4]
  ------------------
12420|      4|        return false;
12421|      4|      }
12422|      8|    }
12423|     43|  } else {
12424|     43|    hash_start = 0;
12425|     43|    i = 1;
12426|     43|    scan_hash_run(b, i, len);
12427|     43|    if (i < len) {
  ------------------
  |  Branch (12427:9): [True: 18, False: 25]
  ------------------
12428|     18|      return false;
12429|     18|    }
12430|     43|  }
12431|       |
12432|    245|  if (has_path && maybe_dot_segment) {
  ------------------
  |  Branch (12432:7): [True: 205, False: 40]
  |  Branch (12432:19): [True: 98, False: 107]
  ------------------
12433|     98|    const std::string_view path_body(input.data() + path_start,
12434|     98|                                     path_end - path_start);
12435|     98|    if (path_has_dot_segment(path_body)) {
  ------------------
  |  Branch (12435:9): [True: 93, False: 5]
  ------------------
12436|     93|      return false;
12437|     93|    }
12438|     98|  }
12439|       |
12440|    152|  out = base;
12441|    152|  out.is_valid = true;
12442|    152|  out.has_opaque_path = false;
12443|       |
12444|    152|  const size_t q_end =
12445|    152|      (hash_start != std::string_view::npos) ? hash_start : len;
  ------------------
  |  Branch (12445:7): [True: 42, False: 110]
  ------------------
12446|    152|  const bool has_query = query_start != std::string_view::npos;
12447|    152|  const bool has_hash = hash_start != std::string_view::npos;
12448|    152|  const std::string_view query =
12449|    152|      has_query ? std::string_view(input.data() + query_start + 1,
  ------------------
  |  Branch (12449:7): [True: 29, False: 123]
  ------------------
12450|     29|                                   q_end - query_start - 1)
12451|    152|                : std::string_view{};
12452|    152|  const std::string_view hash =
12453|    152|      has_hash ? std::string_view(input.data() + hash_start + 1,
  ------------------
  |  Branch (12453:7): [True: 42, False: 110]
  ------------------
12454|     42|                                  len - hash_start - 1)
12455|    152|               : std::string_view{};
12456|       |
12457|    152|  if constexpr (is_aggregator) {
12458|    152|    if (first == '/' || first == '?' || path_relative) {
  ------------------
  |  Branch (12458:9): [True: 25, False: 127]
  |  Branch (12458:25): [True: 15, False: 112]
  |  Branch (12458:41): [True: 87, False: 25]
  ------------------
12459|    127|      out.clear_hash();
12460|    127|      out.clear_search();
12461|    127|    }
12462|    152|    if (first == '/') {
  ------------------
  |  Branch (12462:9): [True: 25, False: 127]
  ------------------
12463|     25|      out.update_base_pathname(input.substr(path_start, path_end - path_start));
12464|    127|    } else if (path_relative) {
  ------------------
  |  Branch (12464:16): [True: 87, False: 40]
  ------------------
12465|     87|      const std::string_view base_path = out.get_pathname();
12466|     87|      const size_t slash = base_path.rfind('/');
12467|     87|      const std::string_view prefix = (slash == std::string_view::npos)
  ------------------
  |  Branch (12467:39): [True: 0, False: 87]
  ------------------
12468|     87|                                          ? std::string_view("/")
12469|     87|                                          : base_path.substr(0, slash + 1);
12470|     87|      const std::string_view rel(input.data() + path_start,
12471|     87|                                 path_end - path_start);
12472|     87|      std::string new_path;
12473|     87|      new_path.reserve(prefix.size() + rel.size());
12474|     87|      new_path.assign(prefix);
12475|     87|      new_path.append(rel);
12476|     87|      out.update_base_pathname(new_path);
12477|     87|    }
12478|    152|    if (has_query) {
  ------------------
  |  Branch (12478:9): [True: 29, False: 123]
  ------------------
12479|       |      // Do not use update_base_search: it strips a leading '?' and would
12480|       |      // collapse '??a=b' into '?a=b'.
12481|     29|      out.components.search_start = static_cast<uint32_t>(out.buffer.size());
12482|     29|      out.buffer += '?';
12483|     29|      out.buffer.append(query);
12484|     29|    }
12485|    152|    if (has_hash) {
  ------------------
  |  Branch (12485:9): [True: 42, False: 110]
  ------------------
12486|     42|      out.update_unencoded_base_hash(hash);
12487|     42|    }
12488|       |  } else {
12489|       |    if (first == '/' || first == '?' || path_relative) {
12490|       |      out.hash.reset();
12491|       |    }
12492|       |    if (first == '/') {
12493|       |      out.query.reset();
12494|       |      out.path.assign(input.substr(path_start, path_end - path_start));
12495|       |    } else if (path_relative) {
12496|       |      out.query.reset();
12497|       |      const size_t slash = out.path.rfind('/');
12498|       |      if (slash == std::string::npos) {
12499|       |        out.path = '/';
12500|       |      } else {
12501|       |        out.path.resize(slash + 1);
12502|       |      }
12503|       |      out.path.append(input.substr(path_start, path_end - path_start));
12504|       |    }
12505|       |    if (has_query) {
12506|       |      out.query.emplace(query);
12507|       |    }
12508|       |    if (has_hash) {
12509|       |      out.hash.emplace(hash);
12510|       |    }
12511|       |  }
12512|    152|  return true;
12513|    245|}
_ZN3ada6parser14parse_url_implINS_3urlELb1EEET_NSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEPKS3_:
12517|  47.3k|                           const result_type* base_url) {
12518|       |  // We can specialize the implementation per type.
12519|       |  // Important: result_type_is_ada_url is evaluated at *compile time*. This
12520|       |  // means that doing if constexpr(result_type_is_ada_url) { something } else {
12521|       |  // something else } is free (at runtime). This means that ada::url_aggregator
12522|       |  // and ada::url **do not have to support the exact same API**.
12523|  47.3k|  constexpr bool result_type_is_ada_url = std::is_same_v<url, result_type>;
12524|  47.3k|  constexpr bool result_type_is_ada_url_aggregator =
12525|  47.3k|      std::is_same_v<url_aggregator, result_type>;
12526|  47.3k|  static_assert(result_type_is_ada_url ||
12527|  47.3k|                result_type_is_ada_url_aggregator);  // We don't support
12528|       |                                                     // anything else for now.
12529|       |
12530|  47.3k|  ada_log("ada::parser::parse_url('", user_input, "' [", user_input.size(),
12531|  47.3k|          " bytes],", (base_url != nullptr ? base_url->to_string() : "null"),
12532|  47.3k|          ")");
12533|       |
12534|  47.3k|  result_type url{};
12535|       |
12536|  47.3k|  const uint32_t max_input_length = ada::get_max_input_length();
12537|       |
12538|       |  // Normalization (percent-encoding, IDNA) can push the serialized URL past
12539|       |  // max_input_length even when the input fit under it. The check at the end of
12540|       |  // the state machine covers URLs that run to completion, but several states
12541|       |  // return early after appending a query or fragment, so run the same check on
12542|       |  // those exits too. Without this, a query- or fragment-terminated URL such as
12543|       |  // file://x/?<...> or https://user@x/?<...> is accepted while the equivalent
12544|       |  // https://x/?<...> that takes the absolute fast path is rejected.
12545|  47.3k|  const auto enforce_max_input_length = [&]() {
12546|  47.3k|    if constexpr (store_values) {
12547|  47.3k|      if (url.is_valid) {
12548|  47.3k|        if constexpr (result_type_is_ada_url_aggregator) {
12549|  47.3k|          if (url.buffer.size() > max_input_length) [[unlikely]] {
12550|  47.3k|            url.is_valid = false;
12551|  47.3k|          }
12552|  47.3k|        } else {
12553|  47.3k|          if (url.get_href_size() > max_input_length) [[unlikely]] {
12554|  47.3k|            url.is_valid = false;
12555|  47.3k|          }
12556|  47.3k|        }
12557|  47.3k|      }
12558|  47.3k|    }
12559|  47.3k|  };
12560|       |
12561|       |  // We refuse to parse URL strings that exceed the maximum input length.
12562|       |  // By default, this is 4GB but can be configured via
12563|       |  // ada::set_max_input_length().
12564|  47.3k|  if (user_input.size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (12564:7): [True: 0, False: 47.3k]
  ------------------
12565|      0|    url.is_valid = false;
12566|      0|  }
12567|       |  // Going forward, user_input.size() is in [0,
12568|       |  // std::numeric_limits<uint32_t>::max). If we are provided with an invalid
12569|       |  // base, or the optional_url was invalid, we must return.
12570|  47.3k|  if (base_url != nullptr) {
  ------------------
  |  Branch (12570:7): [True: 3.97k, False: 43.3k]
  ------------------
12571|  3.97k|    url.is_valid &= base_url->is_valid;
12572|  3.97k|  }
12573|  47.3k|  if (!url.is_valid) {
  ------------------
  |  Branch (12573:7): [True: 0, False: 47.3k]
  ------------------
12574|      0|    return url;
12575|      0|  }
12576|       |
12577|       |  // Simple absolute / relative fast paths (before tabs/newline scan).
12578|  47.3k|  if constexpr (store_values) {
12579|  47.3k|    bool hit_fast_path = false;
12580|  47.3k|    if (base_url == nullptr) {
  ------------------
  |  Branch (12580:9): [True: 43.3k, False: 3.97k]
  ------------------
12581|       |      // IPv4/IPv6 and userinfo miss the fast path. Skip the never_inline
12582|       |      // call so those URLs (including SetHref) do not pay for a miss.
12583|  43.3k|      const auto* p = reinterpret_cast<const uint8_t*>(user_input.data());
12584|  43.3k|      const size_t n = user_input.size();
12585|  43.3k|      size_t host_start = 0;
12586|  43.3k|      if (n >= 8 && p[4] == ':' && p[5] == '/' && p[6] == '/') {
  ------------------
  |  Branch (12586:11): [True: 16.6k, False: 26.7k]
  |  Branch (12586:21): [True: 3.30k, False: 13.3k]
  |  Branch (12586:36): [True: 2.52k, False: 780]
  |  Branch (12586:51): [True: 2.49k, False: 26]
  ------------------
12587|  2.49k|        host_start = 7;
12588|  40.9k|      } else if (n >= 9 && p[5] == ':' && p[6] == '/' && p[7] == '/') {
  ------------------
  |  Branch (12588:18): [True: 12.8k, False: 28.0k]
  |  Branch (12588:28): [True: 283, False: 12.5k]
  |  Branch (12588:43): [True: 60, False: 223]
  |  Branch (12588:58): [True: 39, False: 21]
  ------------------
12589|     39|        host_start = 8;
12590|     39|      }
12591|  43.3k|      const uint8_t host_first = host_start != 0 ? p[host_start] : 0;
  ------------------
  |  Branch (12591:34): [True: 2.53k, False: 40.8k]
  ------------------
12592|  43.3k|      const bool skip_ip =
12593|  43.3k|          host_first == '[' || (host_first >= '0' && host_first <= '9');
  ------------------
  |  Branch (12593:11): [True: 34, False: 43.3k]
  |  Branch (12593:33): [True: 1.81k, False: 41.5k]
  |  Branch (12593:54): [True: 544, False: 1.27k]
  ------------------
12594|  43.3k|      const bool skip_userinfo =
12595|  43.3k|          host_start != 0 && authority_has_at(p, host_start, n);
  ------------------
  |  Branch (12595:11): [True: 2.53k, False: 40.8k]
  |  Branch (12595:30): [True: 19, False: 2.51k]
  ------------------
12596|  43.3k|      hit_fast_path = !skip_ip && !skip_userinfo &&
  ------------------
  |  Branch (12596:23): [True: 42.8k, False: 578]
  |  Branch (12596:35): [True: 42.8k, False: 16]
  ------------------
12597|  42.8k|                      try_parse_simple_absolute(user_input, url);
  ------------------
  |  Branch (12597:23): [True: 4.26k, False: 38.5k]
  ------------------
12598|  43.3k|    } else {
12599|  3.97k|      hit_fast_path = try_parse_simple_relative(user_input, *base_url, url);
12600|  3.97k|    }
12601|  47.3k|    if (hit_fast_path) {
  ------------------
  |  Branch (12601:9): [True: 4.41k, False: 42.9k]
  ------------------
12602|       |      if constexpr (result_type_is_ada_url_aggregator) {
12603|       |        if (url.buffer.size() > max_input_length) [[unlikely]] {
12604|       |          url.is_valid = false;
12605|       |        }
12606|  4.41k|      } else {
12607|       |        // For a small absolute input, even worst-case normalization cannot
12608|       |        // exceed the limit: percent encoding expands at most 3x and IDNA at
12609|       |        // most 4.5x. Avoid traversing every stored component on the common
12610|       |        // default-limit path.
12611|  4.41k|        if ((base_url != nullptr ||
  ------------------
  |  Branch (12611:14): [True: 152, False: 4.26k]
  ------------------
12612|  4.26k|             user_input.size() > static_cast<size_t>(max_input_length) / 5) &&
  ------------------
  |  Branch (12612:14): [True: 0, False: 4.26k]
  ------------------
12613|    152|            url.get_href_size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (12613:13): [True: 0, False: 152]
  ------------------
12614|      0|          url.is_valid = false;
12615|      0|        }
12616|  4.41k|      }
12617|  4.41k|      return url;
12618|  4.41k|    }
12619|  47.3k|  }
12620|       |
12621|  42.9k|  state state = state::SCHEME_START;
12622|       |
12623|  47.3k|  std::string tmp_buffer;
12624|  47.3k|  std::string_view url_data;
12625|  47.3k|  if (unicode::has_tabs_or_newline(user_input)) [[unlikely]] {
  ------------------
  |  Branch (12625:7): [True: 257, False: 47.1k]
  ------------------
12626|    257|    tmp_buffer = user_input;
12627|       |    // Optimization opportunity: Instead of copying and then pruning, we could
12628|       |    // just directly build the string from user_input.
12629|    257|    helpers::remove_ascii_tab_or_newline(tmp_buffer);
12630|    257|    url_data = tmp_buffer;
12631|  47.1k|  } else [[likely]] {
12632|  47.1k|    url_data = user_input;
12633|  47.1k|  }
12634|       |
12635|       |  // Leading and trailing control characters are uncommon and easy to deal with
12636|       |  // (no performance concern).
12637|  47.3k|  helpers::trim_c0_whitespace(url_data);
12638|       |
12639|       |  if constexpr (result_type_is_ada_url_aggregator && store_values) {
12640|       |    // Most of the time, we just need user_input.size().
12641|       |    // In some instances, we may need a bit more.
12642|       |    ///////////////////////////
12643|       |    // This is *very* important. This line should *not* be removed
12644|       |    // hastily. There are principled reasons why reserve is important
12645|       |    // for performance. If you have a benchmark with small inputs,
12646|       |    // it may not matter, but in other instances, it could.
12647|       |    ////
12648|       |    // This rounds up to the next power of two.
12649|       |    // We know that user_input.size() is in [0,
12650|       |    // std::numeric_limits<uint32_t>::max).
12651|       |    uint32_t reserve_capacity =
12652|       |        (0xFFFFFFFF >>
12653|       |         helpers::leading_zeroes(uint32_t(1 | user_input.size()))) +
12654|       |        1;
12655|       |    url.reserve(reserve_capacity);
12656|       |  }
12657|       |
12658|       |  // Optimization opportunity. Most websites do not have fragment.
12659|  47.3k|  std::optional<std::string_view> fragment = helpers::prune_hash(url_data);
12660|       |  // We add it last so that an implementation like ada::url_aggregator
12661|       |  // can append it last to its internal buffer, thus improving performance.
12662|       |
12663|       |  // Here url_data no longer has its fragment.
12664|       |  // We are going to access the data from url_data (it is immutable).
12665|       |  // At any given time, we are pointing at byte 'input_position' in url_data.
12666|       |  // The input_position variable should range from 0 to input_size.
12667|       |  // It is illegal to access url_data at input_size.
12668|  47.3k|  size_t input_position = 0;
12669|  47.3k|  const size_t input_size = url_data.size();
12670|       |  // Keep running the following state machine by switching on state.
12671|       |  // If after a run pointer points to the EOF code point, go to the next step.
12672|       |  // Otherwise, increase pointer by 1 and continue with the state machine.
12673|       |  // We never decrement input_position.
12674|   176k|  while (input_position <= input_size) {
  ------------------
  |  Branch (12674:10): [True: 161k, False: 15.6k]
  ------------------
12675|   161k|    ada_log("In parsing at ", input_position, " out of ", input_size,
12676|   161k|            " in state ", ada::to_string(state));
12677|   161k|    switch (state) {
12678|  42.9k|      case state::SCHEME_START: {
  ------------------
  |  Branch (12678:7): [True: 42.9k, False: 118k]
  ------------------
12679|  42.9k|        ada_log("SCHEME_START ", helpers::substring(url_data, input_position));
12680|       |        // If c is an ASCII alpha, append c, lowercased, to buffer, and set
12681|       |        // state to scheme state.
12682|  42.9k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (12682:13): [True: 22.6k, False: 20.3k]
  ------------------
12683|  22.6k|            checkers::is_alpha(url_data[input_position])) {
  ------------------
  |  Branch (12683:13): [True: 21.6k, False: 994]
  ------------------
12684|  21.6k|          state = state::SCHEME;
12685|  21.6k|          input_position++;
12686|  21.6k|        } else {
12687|       |          // Otherwise, if state override is not given, set state to no scheme
12688|       |          // state and decrease pointer by 1.
12689|  21.3k|          state = state::NO_SCHEME;
12690|  21.3k|        }
12691|  42.9k|        break;
12692|      0|      }
12693|  21.6k|      case state::SCHEME: {
  ------------------
  |  Branch (12693:7): [True: 21.6k, False: 139k]
  ------------------
12694|  21.6k|        ada_log("SCHEME ", helpers::substring(url_data, input_position));
12695|       |        // If c is an ASCII alphanumeric, U+002B (+), U+002D (-), or U+002E (.),
12696|       |        // append c, lowercased, to buffer.
12697|  51.4k|        while ((input_position != input_size) &&
  ------------------
  |  Branch (12697:16): [True: 51.1k, False: 279]
  ------------------
12698|  51.1k|               (unicode::is_alnum_plus(url_data[input_position]))) {
  ------------------
  |  Branch (12698:16): [True: 29.8k, False: 21.3k]
  ------------------
12699|  29.8k|          input_position++;
12700|  29.8k|        }
12701|       |        // Otherwise, if c is U+003A (:), then:
12702|  21.6k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (12702:13): [True: 21.3k, False: 279]
  ------------------
12703|  21.3k|            (url_data[input_position] == ':')) {
  ------------------
  |  Branch (12703:13): [True: 21.0k, False: 315]
  ------------------
12704|  21.0k|          ada_log("SCHEME the scheme should be ",
12705|  21.0k|                  url_data.substr(0, input_position));
12706|  21.0k|          if constexpr (result_type_is_ada_url) {
12707|  21.0k|            if (!url.parse_scheme(url_data.substr(0, input_position))) {
  ------------------
  |  Branch (12707:17): [True: 0, False: 21.0k]
  ------------------
12708|      0|              return url;
12709|      0|            }
12710|       |          } else {
12711|       |            // we pass the colon along instead of painfully adding it back.
12712|       |            if (!url.parse_scheme_with_colon(
12713|       |                    url_data.substr(0, input_position + 1))) {
12714|       |              return url;
12715|       |            }
12716|       |          }
12717|  21.0k|          ada_log("SCHEME the scheme is ", url.get_protocol());
12718|       |
12719|       |          // If url's scheme is "file", then:
12720|       |          // NOLINTNEXTLINE(bugprone-branch-clone)
12721|  21.0k|          if (url.type == scheme::type::FILE) {
  ------------------
  |  Branch (12721:15): [True: 2.71k, False: 18.3k]
  ------------------
12722|       |            // Set state to file state.
12723|  2.71k|            state = state::FILE;
12724|  2.71k|          }
12725|       |          // Otherwise, if url is special, base is non-null, and base's scheme
12726|       |          // is url's scheme: Note: Doing base_url->scheme is unsafe if base_url
12727|       |          // != nullptr is false.
12728|  18.3k|          else if (url.is_special() && base_url != nullptr &&
  ------------------
  |  Branch (12728:20): [True: 12.7k, False: 5.54k]
  |  Branch (12728:40): [True: 2.13k, False: 10.6k]
  ------------------
12729|  2.13k|                   base_url->type == url.type) {
  ------------------
  |  Branch (12729:20): [True: 270, False: 1.86k]
  ------------------
12730|       |            // Set state to special relative or authority state.
12731|    270|            state = state::SPECIAL_RELATIVE_OR_AUTHORITY;
12732|    270|          }
12733|       |          // Otherwise, if url is special, set state to special authority
12734|       |          // slashes state.
12735|  18.0k|          else if (url.is_special()) {
  ------------------
  |  Branch (12735:20): [True: 12.5k, False: 5.54k]
  ------------------
12736|  12.5k|            state = state::SPECIAL_AUTHORITY_SLASHES;
12737|  12.5k|          }
12738|       |          // Otherwise, if remaining starts with an U+002F (/), set state to
12739|       |          // path or authority state and increase pointer by 1.
12740|  5.54k|          else if (input_position + 1 < input_size &&
  ------------------
  |  Branch (12740:20): [True: 3.20k, False: 2.33k]
  ------------------
12741|  3.20k|                   url_data[input_position + 1] == '/') {
  ------------------
  |  Branch (12741:20): [True: 2.20k, False: 1.00k]
  ------------------
12742|  2.20k|            state = state::PATH_OR_AUTHORITY;
12743|  2.20k|            input_position++;
12744|  2.20k|          }
12745|       |          // Otherwise, set url's path to the empty string and set state to
12746|       |          // opaque path state.
12747|  3.33k|          else {
12748|  3.33k|            state = state::OPAQUE_PATH;
12749|  3.33k|          }
12750|  21.0k|        }
12751|       |        // Otherwise, if state override is not given, set buffer to the empty
12752|       |        // string, state to no scheme state, and start over (from the first code
12753|       |        // point in input).
12754|    594|        else {
12755|    594|          state = state::NO_SCHEME;
12756|    594|          input_position = 0;
12757|    594|          break;
12758|    594|        }
12759|  21.0k|        input_position++;
12760|  21.0k|        break;
12761|  21.6k|      }
12762|  21.9k|      case state::NO_SCHEME: {
  ------------------
  |  Branch (12762:7): [True: 21.9k, False: 139k]
  ------------------
12763|  21.9k|        ada_log("NO_SCHEME ", helpers::substring(url_data, input_position));
12764|       |        // The fragment was pruned from url_data before the state machine ran,
12765|       |        // so 'c is U+0023 (#)' holds exactly when a fragment was found and
12766|       |        // nothing else remains in front of it.
12767|  21.9k|        const bool c_is_hash =
12768|  21.9k|            fragment.has_value() && input_position == input_size;
  ------------------
  |  Branch (12768:13): [True: 257, False: 21.6k]
  |  Branch (12768:37): [True: 201, False: 56]
  ------------------
12769|       |        // If base is null, or base has an opaque path and c is not U+0023 (#),
12770|       |        // validation error, return failure.
12771|  21.9k|        if (base_url == nullptr || (base_url->has_opaque_path && !c_is_hash)) {
  ------------------
  |  Branch (12771:13): [True: 21.0k, False: 858]
  |  Branch (12771:37): [True: 117, False: 741]
  |  Branch (12771:66): [True: 50, False: 67]
  ------------------
12772|  21.0k|          ada_log("NO_SCHEME validation error");
12773|  21.0k|          url.is_valid = false;
12774|  21.0k|          return url;
12775|  21.0k|        }
12776|       |        // Otherwise, if base has an opaque path and c is U+0023 (#),
12777|       |        // set url's scheme to base's scheme, url's path to base's path, url's
12778|       |        // query to base's query, and set state to fragment state.
12779|    808|        else if (base_url->has_opaque_path && c_is_hash) {
  ------------------
  |  Branch (12779:18): [True: 67, False: 741]
  |  Branch (12779:47): [True: 67, False: 0]
  ------------------
12780|     67|          ada_log("NO_SCHEME opaque base with fragment");
12781|     67|          url.copy_scheme(*base_url);
12782|     67|          url.has_opaque_path = base_url->has_opaque_path;
12783|       |
12784|     67|          if constexpr (result_type_is_ada_url) {
12785|     67|            url.path = base_url->path;
12786|     67|            url.query = base_url->query;
12787|       |          } else {
12788|       |            url.update_base_pathname(base_url->get_pathname());
12789|       |            if (base_url->has_search()) {
12790|       |              // get_search() returns "" for an empty query string (URL ends
12791|       |              // with '?'). update_base_search("") would incorrectly clear the
12792|       |              // query, so pass "?" to preserve the empty query distinction.
12793|       |              auto s = base_url->get_search();
12794|       |              url.update_base_search(s.empty() ? std::string_view("?") : s);
12795|       |            }
12796|       |          }
12797|     67|          url.update_unencoded_base_hash(*fragment);
12798|     67|          enforce_max_input_length();
12799|     67|          return url;
12800|     67|        }
12801|       |        // Otherwise, if base's scheme is not "file", set state to relative
12802|       |        // state and decrease pointer by 1.
12803|       |        // NOLINTNEXTLINE(bugprone-branch-clone)
12804|    741|        else if (base_url->type != scheme::type::FILE) {
  ------------------
  |  Branch (12804:18): [True: 485, False: 256]
  ------------------
12805|    485|          ada_log("NO_SCHEME non-file relative path");
12806|    485|          state = state::RELATIVE_SCHEME;
12807|    485|        }
12808|       |        // Otherwise, set state to file state and decrease pointer by 1.
12809|    256|        else {
12810|    256|          ada_log("NO_SCHEME file base type");
12811|    256|          state = state::FILE;
12812|    256|        }
12813|    741|        break;
12814|  21.9k|      }
12815|  13.5k|      case state::AUTHORITY: {
  ------------------
  |  Branch (12815:7): [True: 13.5k, False: 147k]
  ------------------
12816|  13.5k|        ada_log("AUTHORITY ", helpers::substring(url_data, input_position));
12817|       |        // most URLs have no @. Having no @ tells us that we don't have to worry
12818|       |        // about AUTHORITY. Of course, we could have @ and still not have to
12819|       |        // worry about AUTHORITY.
12820|       |        // TODO: Instead of just collecting a bool, collect the location of the
12821|       |        // '@' and do something useful with it.
12822|       |        // TODO: We could do various processing early on, using a single pass
12823|       |        // over the string to collect information about it, e.g., telling us
12824|       |        // whether there is a @ and if so, where (or how many).
12825|       |
12826|       |        // Check if url data contains an @.
12827|  13.5k|        if (url_data.find('@', input_position) == std::string_view::npos) {
  ------------------
  |  Branch (12827:13): [True: 12.3k, False: 1.25k]
  ------------------
12828|  12.3k|          state = state::HOST;
12829|  12.3k|          break;
12830|  12.3k|        }
12831|  1.25k|        bool at_sign_seen{false};
12832|  1.25k|        bool password_token_seen{false};
12833|       |        /**
12834|       |         * We expect something of the sort...
12835|       |         * https://user:pass@example.com:1234/foo/bar?baz#quux
12836|       |         * --------^
12837|       |         */
12838|  8.84k|        do {
12839|  8.84k|          std::string_view view = url_data.substr(input_position);
12840|       |          // The delimiters are @, /, ? \\.
12841|  8.84k|          size_t location =
12842|  8.84k|              url.is_special() ? helpers::find_authority_delimiter_special(view)
  ------------------
  |  Branch (12842:15): [True: 8.31k, False: 531]
  ------------------
12843|  8.84k|                               : helpers::find_authority_delimiter(view);
12844|  8.84k|          std::string_view authority_view = view.substr(0, location);
12845|  8.84k|          size_t end_of_authority = input_position + authority_view.size();
12846|       |          // If c is U+0040 (@), then:
12847|  8.84k|          if ((end_of_authority != input_size) &&
  ------------------
  |  Branch (12847:15): [True: 8.04k, False: 798]
  ------------------
12848|  8.04k|              (url_data[end_of_authority] == '@')) {
  ------------------
  |  Branch (12848:15): [True: 7.59k, False: 455]
  ------------------
12849|       |            // If atSignSeen is true, then prepend "%40" to buffer.
12850|  7.59k|            if (at_sign_seen) {
  ------------------
  |  Branch (12850:17): [True: 6.46k, False: 1.12k]
  ------------------
12851|  6.46k|              if (password_token_seen) {
  ------------------
  |  Branch (12851:19): [True: 2.33k, False: 4.13k]
  ------------------
12852|  2.33k|                if constexpr (result_type_is_ada_url) {
12853|  2.33k|                  url.password += "%40";
12854|       |                } else {
12855|       |                  url.append_base_password("%40");
12856|       |                }
12857|  4.13k|              } else {
12858|  4.13k|                if constexpr (result_type_is_ada_url) {
12859|  4.13k|                  url.username += "%40";
12860|       |                } else {
12861|       |                  url.append_base_username("%40");
12862|       |                }
12863|  4.13k|              }
12864|  6.46k|            }
12865|       |
12866|  7.59k|            at_sign_seen = true;
12867|       |
12868|  7.59k|            if (!password_token_seen) {
  ------------------
  |  Branch (12868:17): [True: 5.25k, False: 2.33k]
  ------------------
12869|  5.25k|              size_t password_token_location = authority_view.find(':');
12870|  5.25k|              password_token_seen =
12871|  5.25k|                  password_token_location != std::string_view::npos;
12872|       |
12873|  5.25k|              if constexpr (store_values) {
12874|  5.25k|                if (!password_token_seen) {
  ------------------
  |  Branch (12874:21): [True: 4.81k, False: 441]
  ------------------
12875|  4.81k|                  if constexpr (result_type_is_ada_url) {
12876|  4.81k|                    url.username += unicode::percent_encode(
12877|  4.81k|                        authority_view,
12878|  4.81k|                        character_sets::USERINFO_PERCENT_ENCODE);
12879|       |                  } else {
12880|       |                    url.append_base_username(unicode::percent_encode(
12881|       |                        authority_view,
12882|       |                        character_sets::USERINFO_PERCENT_ENCODE));
12883|       |                  }
12884|  4.81k|                } else {
12885|    441|                  if constexpr (result_type_is_ada_url) {
12886|    441|                    url.username += unicode::percent_encode(
12887|    441|                        authority_view.substr(0, password_token_location),
12888|    441|                        character_sets::USERINFO_PERCENT_ENCODE);
12889|    441|                    url.password += unicode::percent_encode(
12890|    441|                        authority_view.substr(password_token_location + 1),
12891|    441|                        character_sets::USERINFO_PERCENT_ENCODE);
12892|       |                  } else {
12893|       |                    url.append_base_username(unicode::percent_encode(
12894|       |                        authority_view.substr(0, password_token_location),
12895|       |                        character_sets::USERINFO_PERCENT_ENCODE));
12896|       |                    url.append_base_password(unicode::percent_encode(
12897|       |                        authority_view.substr(password_token_location + 1),
12898|       |                        character_sets::USERINFO_PERCENT_ENCODE));
12899|       |                  }
12900|    441|                }
12901|  5.25k|              }
12902|  5.25k|            } else if constexpr (store_values) {
12903|  2.33k|              if constexpr (result_type_is_ada_url) {
12904|  2.33k|                url.password += unicode::percent_encode(
12905|  2.33k|                    authority_view, character_sets::USERINFO_PERCENT_ENCODE);
12906|       |              } else {
12907|       |                url.append_base_password(unicode::percent_encode(
12908|       |                    authority_view, character_sets::USERINFO_PERCENT_ENCODE));
12909|       |              }
12910|  2.33k|            }
12911|  7.59k|          }
12912|       |          // Otherwise, if one of the following is true:
12913|       |          // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
12914|       |          // - url is special and c is U+005C (\)
12915|  1.25k|          else if (end_of_authority == input_size ||
  ------------------
  |  Branch (12915:20): [True: 798, False: 455]
  ------------------
12916|    455|                   url_data[end_of_authority] == '/' ||
  ------------------
  |  Branch (12916:20): [True: 418, False: 37]
  ------------------
12917|     37|                   url_data[end_of_authority] == '?' ||
  ------------------
  |  Branch (12917:20): [True: 30, False: 7]
  ------------------
12918|  1.25k|                   (url.is_special() && url_data[end_of_authority] == '\\')) {
  ------------------
  |  Branch (12918:21): [True: 7, False: 0]
  |  Branch (12918:41): [True: 7, False: 0]
  ------------------
12919|       |            // If atSignSeen is true and authority_view is the empty string,
12920|       |            // validation error, return failure.
12921|  1.25k|            if (at_sign_seen && authority_view.empty()) {
  ------------------
  |  Branch (12921:17): [True: 1.12k, False: 131]
  |  Branch (12921:33): [True: 337, False: 785]
  ------------------
12922|    337|              url.is_valid = false;
12923|    337|              return url;
12924|    337|            }
12925|    916|            state = state::HOST;
12926|    916|            break;
12927|  1.25k|          }
12928|  7.59k|          if (end_of_authority == input_size) {
  ------------------
  |  Branch (12928:15): [True: 0, False: 7.59k]
  ------------------
12929|      0|            if constexpr (store_values) {
12930|      0|              if (fragment.has_value()) {
  ------------------
  |  Branch (12930:19): [True: 0, False: 0]
  ------------------
12931|      0|                url.update_unencoded_base_hash(*fragment);
12932|      0|              }
12933|      0|            }
12934|      0|            enforce_max_input_length();
12935|      0|            return url;
12936|      0|          }
12937|  7.59k|          input_position = end_of_authority + 1;
12938|  7.59k|        } while (true);
  ------------------
  |  Branch (12938:18): [True: 7.59k, Folded]
  ------------------
12939|       |
12940|    916|        break;
12941|  1.25k|      }
12942|    916|      case state::SPECIAL_RELATIVE_OR_AUTHORITY: {
  ------------------
  |  Branch (12942:7): [True: 270, False: 160k]
  ------------------
12943|    270|        ada_log("SPECIAL_RELATIVE_OR_AUTHORITY ",
12944|    270|                helpers::substring(url_data, input_position));
12945|       |
12946|       |        // If c is U+002F (/) and remaining starts with U+002F (/),
12947|       |        // then set state to special authority ignore slashes state and increase
12948|       |        // pointer by 1.
12949|    270|        if (url_data.substr(input_position, 2) == "//") {
  ------------------
  |  Branch (12949:13): [True: 192, False: 78]
  ------------------
12950|    192|          state = state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
12951|    192|          input_position += 2;
12952|    192|        } else {
12953|       |          // Otherwise, validation error, set state to relative state and
12954|       |          // decrease pointer by 1.
12955|     78|          state = state::RELATIVE_SCHEME;
12956|     78|        }
12957|       |
12958|    270|        break;
12959|  1.25k|      }
12960|  2.20k|      case state::PATH_OR_AUTHORITY: {
  ------------------
  |  Branch (12960:7): [True: 2.20k, False: 158k]
  ------------------
12961|  2.20k|        ada_log("PATH_OR_AUTHORITY ",
12962|  2.20k|                helpers::substring(url_data, input_position));
12963|       |
12964|       |        // If c is U+002F (/), then set state to authority state.
12965|  2.20k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (12965:13): [True: 2.08k, False: 115]
  ------------------
12966|  2.08k|            (url_data[input_position] == '/')) {
  ------------------
  |  Branch (12966:13): [True: 840, False: 1.24k]
  ------------------
12967|    840|          state = state::AUTHORITY;
12968|    840|          input_position++;
12969|  1.36k|        } else {
12970|       |          // Otherwise, set state to path state, and decrease pointer by 1.
12971|  1.36k|          state = state::PATH;
12972|  1.36k|        }
12973|       |
12974|  2.20k|        break;
12975|  1.25k|      }
12976|    563|      case state::RELATIVE_SCHEME: {
  ------------------
  |  Branch (12976:7): [True: 563, False: 160k]
  ------------------
12977|    563|        ada_log("RELATIVE_SCHEME ",
12978|    563|                helpers::substring(url_data, input_position));
12979|       |
12980|       |        // Set url's scheme to base's scheme.
12981|    563|        url.copy_scheme(*base_url);
12982|       |
12983|       |        // If c is U+002F (/), then set state to relative slash state.
12984|    563|        if ((input_position != input_size) &&
  ------------------
  |  Branch (12984:13): [True: 418, False: 145]
  ------------------
12985|       |            // NOLINTNEXTLINE(bugprone-branch-clone)
12986|    418|            (url_data[input_position] == '/')) {
  ------------------
  |  Branch (12986:13): [True: 40, False: 378]
  ------------------
12987|     40|          ada_log(
12988|     40|              "RELATIVE_SCHEME if c is U+002F (/), then set state to relative "
12989|     40|              "slash state");
12990|     40|          state = state::RELATIVE_SLASH;
12991|    523|        } else if (url.is_special() && (input_position != input_size) &&
  ------------------
  |  Branch (12991:20): [True: 378, False: 145]
  |  Branch (12991:40): [True: 275, False: 103]
  ------------------
12992|    275|                   (url_data[input_position] == '\\')) {
  ------------------
  |  Branch (12992:20): [True: 6, False: 269]
  ------------------
12993|       |          // Otherwise, if url is special and c is U+005C (\), validation error,
12994|       |          // set state to relative slash state.
12995|      6|          ada_log(
12996|      6|              "RELATIVE_SCHEME  if url is special and c is U+005C, validation "
12997|      6|              "error, set state to relative slash state");
12998|      6|          state = state::RELATIVE_SLASH;
12999|    517|        } else {
13000|    517|          ada_log("RELATIVE_SCHEME otherwise");
13001|       |          // Set url's username to base's username, url's password to base's
13002|       |          // password, url's host to base's host, url's port to base's port,
13003|       |          // url's path to a clone of base's path, and url's query to base's
13004|       |          // query.
13005|    517|          if constexpr (result_type_is_ada_url) {
13006|    517|            url.username = base_url->username;
13007|    517|            url.password = base_url->password;
13008|    517|            url.host = base_url->host;
13009|    517|            url.port = base_url->port;
13010|       |            // cloning the base path includes cloning the has_opaque_path flag
13011|    517|            url.has_opaque_path = base_url->has_opaque_path;
13012|    517|            url.path = base_url->path;
13013|    517|            url.query = base_url->query;
13014|       |          } else {
13015|       |            url.update_base_authority(base_url->get_href(),
13016|       |                                      base_url->get_components());
13017|       |            url.update_host_to_base_host(base_url->get_hostname());
13018|       |            url.update_base_port(base_url->retrieve_base_port());
13019|       |            // cloning the base path includes cloning the has_opaque_path flag
13020|       |            url.has_opaque_path = base_url->has_opaque_path;
13021|       |            url.update_base_pathname(base_url->get_pathname());
13022|       |            if (base_url->has_search()) {
13023|       |              // get_search() returns "" for an empty query string (URL ends
13024|       |              // with '?'). update_base_search("") would incorrectly clear the
13025|       |              // query, so pass "?" to preserve the empty query distinction.
13026|       |              auto s = base_url->get_search();
13027|       |              url.update_base_search(s.empty() ? std::string_view("?") : s);
13028|       |            }
13029|       |          }
13030|       |
13031|    517|          url.has_opaque_path = base_url->has_opaque_path;
13032|       |
13033|       |          // If c is U+003F (?), then set url's query to the empty string, and
13034|       |          // state to query state.
13035|    517|          if ((input_position != input_size) &&
  ------------------
  |  Branch (13035:15): [True: 372, False: 145]
  ------------------
13036|    372|              (url_data[input_position] == '?')) {
  ------------------
  |  Branch (13036:15): [True: 19, False: 353]
  ------------------
13037|     19|            state = state::QUERY;
13038|     19|          }
13039|       |          // Otherwise, if c is not the EOF code point:
13040|    498|          else if (input_position != input_size) {
  ------------------
  |  Branch (13040:20): [True: 353, False: 145]
  ------------------
13041|       |            // Set url's query to null.
13042|    353|            url.clear_search();
13043|    353|            if constexpr (result_type_is_ada_url) {
13044|       |              // Shorten url's path.
13045|    353|              helpers::shorten_path(url.path, url.type);
13046|       |            } else {
13047|       |              std::string_view path = url.get_pathname();
13048|       |              if (helpers::shorten_path(path, url.type)) {
13049|       |                url.update_base_pathname(std::move(std::string(path)));
13050|       |              }
13051|       |            }
13052|       |            // Set state to path state and decrease pointer by 1.
13053|    353|            state = state::PATH;
13054|    353|            break;
13055|    353|          }
13056|    517|        }
13057|    210|        input_position++;
13058|    210|        break;
13059|    563|      }
13060|     46|      case state::RELATIVE_SLASH: {
  ------------------
  |  Branch (13060:7): [True: 46, False: 161k]
  ------------------
13061|     46|        ada_log("RELATIVE_SLASH ",
13062|     46|                helpers::substring(url_data, input_position));
13063|       |
13064|       |        // If url is special and c is U+002F (/) or U+005C (\), then:
13065|       |        // NOLINTNEXTLINE(bugprone-branch-clone)
13066|     46|        if (url.is_special() && (input_position != input_size) &&
  ------------------
  |  Branch (13066:13): [True: 37, False: 9]
  |  Branch (13066:33): [True: 28, False: 9]
  ------------------
13067|     28|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13067:14): [True: 4, False: 24]
  ------------------
13068|     24|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13068:14): [True: 2, False: 22]
  ------------------
13069|       |          // Set state to special authority ignore slashes state.
13070|      6|          state = state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
13071|      6|        }
13072|       |        // Otherwise, if c is U+002F (/), then set state to authority state.
13073|     40|        else if ((input_position != input_size) &&
  ------------------
  |  Branch (13073:18): [True: 26, False: 14]
  ------------------
13074|     26|                 (url_data[input_position] == '/')) {
  ------------------
  |  Branch (13074:18): [True: 2, False: 24]
  ------------------
13075|      2|          state = state::AUTHORITY;
13076|      2|        }
13077|       |        // Otherwise, set
13078|       |        // - url's username to base's username,
13079|       |        // - url's password to base's password,
13080|       |        // - url's host to base's host,
13081|       |        // - url's port to base's port,
13082|       |        // - state to path state, and then, decrease pointer by 1.
13083|     38|        else {
13084|     38|          if constexpr (result_type_is_ada_url) {
13085|     38|            url.username = base_url->username;
13086|     38|            url.password = base_url->password;
13087|     38|            url.host = base_url->host;
13088|     38|            url.port = base_url->port;
13089|       |          } else {
13090|       |            url.update_base_authority(base_url->get_href(),
13091|       |                                      base_url->get_components());
13092|       |            url.update_host_to_base_host(base_url->get_hostname());
13093|       |            url.update_base_port(base_url->retrieve_base_port());
13094|       |          }
13095|     38|          state = state::PATH;
13096|     38|          break;
13097|     38|        }
13098|       |
13099|      8|        input_position++;
13100|      8|        break;
13101|     46|      }
13102|  12.5k|      case state::SPECIAL_AUTHORITY_SLASHES: {
  ------------------
  |  Branch (13102:7): [True: 12.5k, False: 148k]
  ------------------
13103|  12.5k|        ada_log("SPECIAL_AUTHORITY_SLASHES ",
13104|  12.5k|                helpers::substring(url_data, input_position));
13105|       |
13106|       |        // If c is U+002F (/) and remaining starts with U+002F (/),
13107|       |        // then set state to special authority ignore slashes state and increase
13108|       |        // pointer by 1.
13109|  12.5k|        if (url_data.substr(input_position, 2) == "//") {
  ------------------
  |  Branch (13109:13): [True: 3.21k, False: 9.30k]
  ------------------
13110|  3.21k|          input_position += 2;
13111|  3.21k|        }
13112|       |
13113|  12.5k|        [[fallthrough]];
13114|  12.5k|      }
13115|  12.7k|      case state::SPECIAL_AUTHORITY_IGNORE_SLASHES: {
  ------------------
  |  Branch (13115:7): [True: 198, False: 160k]
  ------------------
13116|  12.7k|        ada_log("SPECIAL_AUTHORITY_IGNORE_SLASHES ",
13117|  12.7k|                helpers::substring(url_data, input_position));
13118|       |
13119|       |        // If c is neither U+002F (/) nor U+005C (\), then set state to
13120|       |        // authority state and decrease pointer by 1.
13121|  13.7k|        while ((input_position != input_size) &&
  ------------------
  |  Branch (13121:16): [True: 13.6k, False: 86]
  ------------------
13122|  13.6k|               ((url_data[input_position] == '/') ||
  ------------------
  |  Branch (13122:17): [True: 627, False: 13.0k]
  ------------------
13123|  13.0k|                (url_data[input_position] == '\\'))) {
  ------------------
  |  Branch (13123:17): [True: 401, False: 12.6k]
  ------------------
13124|  1.02k|          input_position++;
13125|  1.02k|        }
13126|  12.7k|        state = state::AUTHORITY;
13127|       |
13128|  12.7k|        break;
13129|  12.5k|      }
13130|  1.00k|      case state::QUERY: {
  ------------------
  |  Branch (13130:7): [True: 1.00k, False: 160k]
  ------------------
13131|  1.00k|        ada_log("QUERY ", helpers::substring(url_data, input_position));
13132|  1.00k|        if constexpr (store_values) {
13133|       |          // Let queryPercentEncodeSet be the special-query percent-encode set
13134|       |          // if url is special; otherwise the query percent-encode set.
13135|  1.00k|          const uint8_t* query_percent_encode_set =
13136|  1.00k|              url.is_special() ? character_sets::SPECIAL_QUERY_PERCENT_ENCODE
  ------------------
  |  Branch (13136:15): [True: 584, False: 418]
  ------------------
13137|  1.00k|                               : character_sets::QUERY_PERCENT_ENCODE;
13138|       |
13139|       |          // Percent-encode after encoding, with encoding, buffer, and
13140|       |          // queryPercentEncodeSet, and append the result to url's query.
13141|  1.00k|          url.update_base_search(url_data.substr(input_position),
13142|  1.00k|                                 query_percent_encode_set);
13143|  1.00k|          ada_log("QUERY update_base_search completed ");
13144|  1.00k|          if (fragment.has_value()) {
  ------------------
  |  Branch (13144:15): [True: 216, False: 786]
  ------------------
13145|    216|            url.update_unencoded_base_hash(*fragment);
13146|    216|          }
13147|  1.00k|        }
13148|  1.00k|        enforce_max_input_length();
13149|  1.00k|        return url;
13150|  12.5k|      }
13151|  13.2k|      case state::HOST: {
  ------------------
  |  Branch (13151:7): [True: 13.2k, False: 147k]
  ------------------
13152|  13.2k|        ada_log("HOST ", helpers::substring(url_data, input_position));
13153|       |
13154|  13.2k|        std::string_view host_view = url_data.substr(input_position);
13155|  13.2k|        auto [location, found_colon] =
13156|  13.2k|            helpers::get_host_delimiter_location(url.is_special(), host_view);
13157|  13.2k|        input_position = (location != std::string_view::npos)
  ------------------
  |  Branch (13157:26): [True: 13.2k, False: 0]
  ------------------
13158|  13.2k|                             ? input_position + location
13159|  13.2k|                             : input_size;
13160|       |        // Otherwise, if c is U+003A (:) and insideBrackets is false, then:
13161|       |        // Note: the 'found_colon' value is true if and only if a colon was
13162|       |        // encountered while not inside brackets.
13163|  13.2k|        if (found_colon) {
  ------------------
  |  Branch (13163:13): [True: 2.17k, False: 11.0k]
  ------------------
13164|       |          // If buffer is the empty string, validation error, return failure.
13165|       |          // Let host be the result of host parsing buffer with url is not
13166|       |          // special.
13167|  2.17k|          ada_log("HOST parsing ", host_view);
13168|  2.17k|          if (!url.parse_host(host_view)) {
  ------------------
  |  Branch (13168:15): [True: 232, False: 1.94k]
  ------------------
13169|    232|            return url;
13170|    232|          }
13171|  1.94k|          ada_log("HOST parsing results in ", url.get_hostname());
13172|       |          // Set url's host to host, buffer to the empty string, and state to
13173|       |          // port state.
13174|  1.94k|          state = state::PORT;
13175|  1.94k|          input_position++;
13176|  1.94k|        }
13177|       |        // Otherwise, if one of the following is true:
13178|       |        // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
13179|       |        // - url is special and c is U+005C (\)
13180|       |        // The get_host_delimiter_location function either brings us to
13181|       |        // the colon outside of the bracket, or to one of those characters.
13182|  11.0k|        else {
13183|       |          // If url is special and host_view is the empty string, validation
13184|       |          // error, return failure.
13185|  11.0k|          if (host_view.empty() && url.is_special()) {
  ------------------
  |  Branch (13185:15): [True: 226, False: 10.8k]
  |  Branch (13185:36): [True: 90, False: 136]
  ------------------
13186|     90|            url.is_valid = false;
13187|     90|            return url;
13188|     90|          }
13189|  10.9k|          ada_log("HOST parsing ", host_view, " href=", url.get_href());
13190|       |          // Let host be the result of host parsing host_view with url is not
13191|       |          // special.
13192|  10.9k|          if (host_view.empty()) {
  ------------------
  |  Branch (13192:15): [True: 136, False: 10.8k]
  ------------------
13193|    136|            url.update_base_hostname("");
13194|  10.8k|          } else if (!url.parse_host(host_view)) {
  ------------------
  |  Branch (13194:22): [True: 2.54k, False: 8.26k]
  ------------------
13195|  2.54k|            return url;
13196|  2.54k|          }
13197|  8.40k|          ada_log("HOST parsing results in ", url.get_hostname(),
13198|  8.40k|                  " href=", url.get_href());
13199|       |
13200|       |          // Set url's host to host, and state to path start state.
13201|  8.40k|          state = state::PATH_START;
13202|  8.40k|        }
13203|       |
13204|  10.3k|        break;
13205|  13.2k|      }
13206|  10.3k|      case state::OPAQUE_PATH: {
  ------------------
  |  Branch (13206:7): [True: 3.33k, False: 157k]
  ------------------
13207|  3.33k|        ada_log("OPAQUE_PATH ", helpers::substring(url_data, input_position));
13208|       |        // Opaque path, query, and fragment are structurally always valid:
13209|       |        // the parser would just percent-encode whatever is there. When we
13210|       |        // are not storing values (can_parse), we can return immediately.
13211|       |        // We must set has_opaque_path = true before returning so that when
13212|       |        // this URL is used as an internal base inside can_parse, NO_SCHEME
13213|       |        // correctly rejects relative inputs against an opaque-path base
13214|       |        // (e.g. can_parse("", &"W:") must return false).
13215|       |        if constexpr (!store_values) {
13216|       |          url.has_opaque_path = true;
13217|       |          return url;
13218|       |        }
13219|  3.33k|        std::string_view view = url_data.substr(input_position);
13220|       |        // If c is U+003F (?), then set url's query to the empty string and
13221|       |        // state to query state.
13222|  3.33k|        size_t location = view.find('?');
13223|  3.33k|        if (location != std::string_view::npos) {
  ------------------
  |  Branch (13223:13): [True: 255, False: 3.08k]
  ------------------
13224|    255|          view.remove_suffix(view.size() - location);
13225|    255|          state = state::QUERY;
13226|    255|          input_position += location + 1;
13227|  3.08k|        } else {
13228|  3.08k|          input_position = input_size + 1;
13229|  3.08k|        }
13230|  3.33k|        url.has_opaque_path = true;
13231|       |
13232|       |        // This is a really unlikely scenario in real world. We should not seek
13233|       |        // to optimize it.
13234|  3.33k|        if (view.ends_with(' ')) {
  ------------------
  |  Branch (13234:13): [True: 99, False: 3.24k]
  ------------------
13235|     99|          std::string modified_view =
13236|     99|              std::string(view.substr(0, view.size() - 1)) + "%20";
13237|     99|          url.update_base_pathname(unicode::percent_encode(
13238|     99|              modified_view, character_sets::C0_CONTROL_PERCENT_ENCODE));
13239|  3.24k|        } else {
13240|  3.24k|          url.update_base_pathname(unicode::percent_encode(
13241|  3.24k|              view, character_sets::C0_CONTROL_PERCENT_ENCODE));
13242|  3.24k|        }
13243|  3.33k|        break;
13244|  13.2k|      }
13245|  1.94k|      case state::PORT: {
  ------------------
  |  Branch (13245:7): [True: 1.94k, False: 159k]
  ------------------
13246|  1.94k|        ada_log("PORT ", helpers::substring(url_data, input_position));
13247|  1.94k|        std::string_view port_view = url_data.substr(input_position);
13248|  1.94k|        input_position += url.parse_port(port_view, true);
13249|  1.94k|        if (!url.is_valid) {
  ------------------
  |  Branch (13249:13): [True: 109, False: 1.83k]
  ------------------
13250|    109|          return url;
13251|    109|        }
13252|  1.83k|        state = state::PATH_START;
13253|  1.83k|        [[fallthrough]];
13254|  1.83k|      }
13255|  12.1k|      case state::PATH_START: {
  ------------------
  |  Branch (13255:7): [True: 10.3k, False: 150k]
  ------------------
13256|  12.1k|        ada_log("PATH_START ", helpers::substring(url_data, input_position));
13257|       |        // Path, query, and fragment are structurally always valid: the
13258|       |        // parser would just percent-encode whatever is there. When we are
13259|       |        // not storing values (can_parse), we can return immediately since
13260|       |        // no subsequent state can invalidate the URL.
13261|       |        if constexpr (!store_values) {
13262|       |          return url;
13263|       |        }
13264|       |
13265|       |        // If url is special, then:
13266|  12.1k|        if (url.is_special()) {
  ------------------
  |  Branch (13266:13): [True: 11.4k, False: 720]
  ------------------
13267|       |          // Set state to path state.
13268|  11.4k|          state = state::PATH;
13269|       |
13270|       |          // Optimization: Avoiding going into PATH state improves the
13271|       |          // performance of urls ending with /.
13272|  11.4k|          if (input_position == input_size) {
  ------------------
  |  Branch (13272:15): [True: 6.04k, False: 5.39k]
  ------------------
13273|  6.04k|            if constexpr (store_values) {
13274|  6.04k|              url.update_base_pathname("/");
13275|  6.04k|              if (fragment.has_value()) {
  ------------------
  |  Branch (13275:19): [True: 119, False: 5.92k]
  ------------------
13276|    119|                url.update_unencoded_base_hash(*fragment);
13277|    119|              }
13278|  6.04k|            }
13279|  6.04k|            enforce_max_input_length();
13280|  6.04k|            return url;
13281|  6.04k|          }
13282|       |          // If c is neither U+002F (/) nor U+005C (\), then decrease pointer
13283|       |          // by 1. We know that (input_position == input_size) is impossible
13284|       |          // here, because of the previous if-check.
13285|  5.39k|          if ((url_data[input_position] != '/') &&
  ------------------
  |  Branch (13285:15): [True: 324, False: 5.07k]
  ------------------
13286|    324|              (url_data[input_position] != '\\')) {
  ------------------
  |  Branch (13286:15): [True: 309, False: 15]
  ------------------
13287|    309|            break;
13288|    309|          }
13289|  5.39k|        }
13290|       |        // Otherwise, if state override is not given and c is U+003F (?),
13291|       |        // set url's query to the empty string and state to query state.
13292|    720|        else if ((input_position != input_size) &&
  ------------------
  |  Branch (13292:18): [True: 185, False: 535]
  ------------------
13293|    185|                 (url_data[input_position] == '?')) {
  ------------------
  |  Branch (13293:18): [True: 63, False: 122]
  ------------------
13294|     63|          state = state::QUERY;
13295|     63|        }
13296|       |        // Otherwise, if c is not the EOF code point:
13297|    657|        else if (input_position != input_size) {
  ------------------
  |  Branch (13297:18): [True: 122, False: 535]
  ------------------
13298|       |          // Set state to path state.
13299|    122|          state = state::PATH;
13300|       |
13301|       |          // If c is not U+002F (/), then decrease pointer by 1.
13302|    122|          if (url_data[input_position] != '/') {
  ------------------
  |  Branch (13302:15): [True: 0, False: 122]
  ------------------
13303|      0|            break;
13304|      0|          }
13305|    122|        }
13306|       |
13307|  5.80k|        input_position++;
13308|  5.80k|        break;
13309|  12.1k|      }
13310|  8.04k|      case state::PATH: {
  ------------------
  |  Branch (13310:7): [True: 8.04k, False: 153k]
  ------------------
13311|  8.04k|        ada_log("PATH ", helpers::substring(url_data, input_position));
13312|       |        // Path, query, and fragment are structurally always valid: the
13313|       |        // parser would just percent-encode whatever is there. When we are
13314|       |        // not storing values (can_parse), we can return immediately since
13315|       |        // no subsequent state can invalidate the URL.
13316|       |        if constexpr (!store_values) {
13317|       |          return url;
13318|       |        }
13319|  8.04k|        std::string_view view = url_data.substr(input_position);
13320|       |
13321|       |        // Most time, we do not need percent encoding.
13322|       |        // Furthermore, we can immediately locate the '?'.
13323|  8.04k|        size_t locofquestionmark = view.find('?');
13324|  8.04k|        if (locofquestionmark != std::string_view::npos) {
  ------------------
  |  Branch (13324:13): [True: 662, False: 7.38k]
  ------------------
13325|    662|          state = state::QUERY;
13326|    662|          view.remove_suffix(view.size() - locofquestionmark);
13327|    662|          input_position += locofquestionmark + 1;
13328|  7.38k|        } else {
13329|  7.38k|          input_position = input_size + 1;
13330|  7.38k|        }
13331|  8.04k|        if constexpr (store_values) {
13332|  8.04k|          if constexpr (result_type_is_ada_url) {
13333|  8.04k|            helpers::parse_prepared_path(view, url.type, url.path);
13334|       |          } else {
13335|       |            url.consume_prepared_path(view);
13336|       |            ADA_ASSERT_TRUE(url.validate());
13337|       |          }
13338|  8.04k|        }
13339|  8.04k|        break;
13340|  12.1k|      }
13341|  2.25k|      case state::FILE_SLASH: {
  ------------------
  |  Branch (13341:7): [True: 2.25k, False: 158k]
  ------------------
13342|  2.25k|        ada_log("FILE_SLASH ", helpers::substring(url_data, input_position));
13343|       |
13344|       |        // If c is U+002F (/) or U+005C (\), then:
13345|  2.25k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13345:13): [True: 2.18k, False: 68]
  ------------------
13346|  2.18k|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13346:14): [True: 2.14k, False: 44]
  ------------------
13347|  2.15k|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13347:14): [True: 6, False: 38]
  ------------------
13348|  2.15k|          ada_log("FILE_SLASH c is U+002F or U+005C");
13349|       |          // Set state to file host state.
13350|  2.15k|          state = state::FILE_HOST;
13351|  2.15k|          input_position++;
13352|  2.15k|        } else {
13353|    106|          ada_log("FILE_SLASH otherwise");
13354|       |          // If base is non-null and base's scheme is "file", then:
13355|       |          // Note: it is unsafe to do base_url->scheme unless you know that
13356|       |          // base_url_has_value() is true.
13357|    106|          if (base_url != nullptr && base_url->type == scheme::type::FILE) {
  ------------------
  |  Branch (13357:15): [True: 84, False: 22]
  |  Branch (13357:38): [True: 82, False: 2]
  ------------------
13358|       |            // Set url's host to base's host.
13359|     82|            if constexpr (result_type_is_ada_url) {
13360|     82|              url.host = base_url->host;
13361|       |            } else {
13362|       |              url.update_host_to_base_host(base_url->get_host());
13363|       |            }
13364|       |            // If the code point substring from pointer to the end of input does
13365|       |            // not start with a Windows drive letter and base's path[0] is a
13366|       |            // normalized Windows drive letter, then append base's path[0] to
13367|       |            // url's path.
13368|     82|            if (!base_url->get_pathname().empty()) {
  ------------------
  |  Branch (13368:17): [True: 82, False: 0]
  ------------------
13369|     82|              if (!checkers::is_windows_drive_letter(
  ------------------
  |  Branch (13369:19): [True: 77, False: 5]
  ------------------
13370|     82|                      url_data.substr(input_position))) {
13371|     77|                std::string_view first_base_url_path =
13372|     77|                    base_url->get_pathname().substr(1);
13373|     77|                size_t loc = first_base_url_path.find('/');
13374|     77|                if (loc != std::string_view::npos) {
  ------------------
  |  Branch (13374:21): [True: 13, False: 64]
  ------------------
13375|     13|                  helpers::resize(first_base_url_path, loc);
13376|     13|                }
13377|     77|                if (checkers::is_normalized_windows_drive_letter(
  ------------------
  |  Branch (13377:21): [True: 3, False: 74]
  ------------------
13378|     77|                        first_base_url_path)) {
13379|      3|                  if constexpr (result_type_is_ada_url) {
13380|      3|                    url.path += '/';
13381|      3|                    url.path += first_base_url_path;
13382|       |                  } else {
13383|       |                    url.append_base_pathname(
13384|       |                        helpers::concat("/", first_base_url_path));
13385|       |                  }
13386|      3|                }
13387|     77|              }
13388|     82|            }
13389|     82|          }
13390|       |
13391|       |          // Set state to path state, and decrease pointer by 1.
13392|    106|          state = state::PATH;
13393|    106|        }
13394|       |
13395|  2.25k|        break;
13396|  12.1k|      }
13397|  2.15k|      case state::FILE_HOST: {
  ------------------
  |  Branch (13397:7): [True: 2.15k, False: 158k]
  ------------------
13398|  2.15k|        ada_log("FILE_HOST ", helpers::substring(url_data, input_position));
13399|  2.15k|        std::string_view view = url_data.substr(input_position);
13400|       |
13401|  2.15k|        size_t location = view.find_first_of("/\\?");
13402|  2.15k|        std::string_view file_host_buffer = view.substr(
13403|  2.15k|            0, (location != std::string_view::npos) ? location : view.size());
  ------------------
  |  Branch (13403:16): [True: 927, False: 1.22k]
  ------------------
13404|       |
13405|  2.15k|        if (checkers::is_windows_drive_letter(file_host_buffer)) {
  ------------------
  |  Branch (13405:13): [True: 12, False: 2.13k]
  ------------------
13406|     12|          state = state::PATH;
13407|  2.13k|        } else if (file_host_buffer.empty()) {
  ------------------
  |  Branch (13407:20): [True: 284, False: 1.85k]
  ------------------
13408|       |          // Set url's host to the empty string.
13409|    284|          if constexpr (result_type_is_ada_url) {
13410|    284|            url.host = "";
13411|       |          } else {
13412|       |            url.update_base_hostname("");
13413|       |          }
13414|       |          // Set state to path start state.
13415|    284|          state = state::PATH_START;
13416|  1.85k|        } else {
13417|  1.85k|          size_t consumed_bytes = file_host_buffer.size();
13418|  1.85k|          input_position += consumed_bytes;
13419|       |          // Let host be the result of host parsing buffer with url is not
13420|       |          // special.
13421|  1.85k|          if (!url.parse_host(file_host_buffer)) {
  ------------------
  |  Branch (13421:15): [True: 216, False: 1.63k]
  ------------------
13422|    216|            return url;
13423|    216|          }
13424|       |
13425|  1.63k|          if constexpr (result_type_is_ada_url) {
13426|       |            // If host is "localhost", then set host to the empty string.
13427|  1.63k|            if (url.host.has_value() && url.host.value() == "localhost") {
  ------------------
  |  Branch (13427:17): [True: 1.63k, False: 0]
  |  Branch (13427:41): [True: 9, False: 1.62k]
  ------------------
13428|      9|              url.host = "";
13429|      9|            }
13430|       |          } else {
13431|       |            if (url.get_hostname() == "localhost") {
13432|       |              url.update_base_hostname("");
13433|       |            }
13434|       |          }
13435|       |
13436|       |          // Set buffer to the empty string and state to path start state.
13437|  1.63k|          state = state::PATH_START;
13438|  1.63k|        }
13439|       |
13440|  1.93k|        break;
13441|  2.15k|      }
13442|  2.97k|      case state::FILE: {
  ------------------
  |  Branch (13442:7): [True: 2.97k, False: 158k]
  ------------------
13443|  2.97k|        ada_log("FILE ", helpers::substring(url_data, input_position));
13444|  2.97k|        std::string_view file_view = url_data.substr(input_position);
13445|       |
13446|  2.97k|        url.set_protocol_as_file();
13447|  2.97k|        if constexpr (result_type_is_ada_url) {
13448|       |          // Set url's host to the empty string.
13449|  2.97k|          url.host = "";
13450|       |        } else {
13451|       |          url.update_base_hostname("");
13452|       |        }
13453|       |        // If c is U+002F (/) or U+005C (\), then:
13454|  2.97k|        if (input_position != input_size &&
  ------------------
  |  Branch (13454:13): [True: 2.84k, False: 133]
  ------------------
13455|  2.84k|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13455:14): [True: 2.25k, False: 592]
  ------------------
13456|  2.25k|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13456:14): [True: 6, False: 586]
  ------------------
13457|  2.25k|          ada_log("FILE c is U+002F or U+005C");
13458|       |          // Set state to file slash state.
13459|  2.25k|          state = state::FILE_SLASH;
13460|  2.25k|        }
13461|       |        // Otherwise, if base is non-null and base's scheme is "file":
13462|    719|        else if (base_url != nullptr && base_url->type == scheme::type::FILE) {
  ------------------
  |  Branch (13462:18): [True: 272, False: 447]
  |  Branch (13462:41): [True: 199, False: 73]
  ------------------
13463|       |          // Set url's host to base's host, url's path to a clone of base's
13464|       |          // path, and url's query to base's query.
13465|    199|          ada_log("FILE base non-null");
13466|    199|          if constexpr (result_type_is_ada_url) {
13467|    199|            url.host = base_url->host;
13468|    199|            url.path = base_url->path;
13469|    199|            url.query = base_url->query;
13470|       |          } else {
13471|       |            url.update_host_to_base_host(base_url->get_hostname());
13472|       |            url.update_base_pathname(base_url->get_pathname());
13473|       |            if (base_url->has_search()) {
13474|       |              // get_search() returns "" for an empty query string (URL ends
13475|       |              // with '?'). update_base_search("") would incorrectly clear the
13476|       |              // query, so pass "?" to preserve the empty query distinction.
13477|       |              auto s = base_url->get_search();
13478|       |              url.update_base_search(s.empty() ? std::string_view("?") : s);
13479|       |            }
13480|       |          }
13481|    199|          url.has_opaque_path = base_url->has_opaque_path;
13482|       |
13483|       |          // If c is U+003F (?), then set url's query to the empty string and
13484|       |          // state to query state.
13485|    199|          if (input_position != input_size && url_data[input_position] == '?') {
  ------------------
  |  Branch (13485:15): [True: 138, False: 61]
  |  Branch (13485:47): [True: 3, False: 135]
  ------------------
13486|      3|            state = state::QUERY;
13487|      3|          }
13488|       |          // Otherwise, if c is not the EOF code point:
13489|    196|          else if (input_position != input_size) {
  ------------------
  |  Branch (13489:20): [True: 135, False: 61]
  ------------------
13490|       |            // Set url's query to null.
13491|    135|            url.clear_search();
13492|       |            // If the code point substring from pointer to the end of input does
13493|       |            // not start with a Windows drive letter, then shorten url's path.
13494|    135|            if (!checkers::is_windows_drive_letter(file_view)) {
  ------------------
  |  Branch (13494:17): [True: 113, False: 22]
  ------------------
13495|    113|              if constexpr (result_type_is_ada_url) {
13496|    113|                helpers::shorten_path(url.path, url.type);
13497|       |              } else {
13498|       |                std::string_view path = url.get_pathname();
13499|       |                if (helpers::shorten_path(path, url.type)) {
13500|       |                  url.update_base_pathname(std::move(std::string(path)));
13501|       |                }
13502|       |              }
13503|    113|            }
13504|       |            // Otherwise:
13505|     22|            else {
13506|       |              // Set url's path to an empty list.
13507|     22|              url.clear_pathname();
13508|     22|              url.has_opaque_path = true;
13509|     22|            }
13510|       |
13511|       |            // Set state to path state and decrease pointer by 1.
13512|    135|            state = state::PATH;
13513|    135|            break;
13514|    135|          }
13515|    199|        }
13516|       |        // Otherwise, set state to path state, and decrease pointer by 1.
13517|    520|        else {
13518|    520|          ada_log("FILE go to path");
13519|    520|          state = state::PATH;
13520|    520|          break;
13521|    520|        }
13522|       |
13523|  2.32k|        input_position++;
13524|  2.32k|        break;
13525|  2.97k|      }
13526|      0|      default:
  ------------------
  |  Branch (13526:7): [True: 0, False: 161k]
  ------------------
13527|      0|        unreachable();
13528|   161k|    }
13529|   161k|  }
13530|  15.6k|  if constexpr (store_values) {
13531|  15.6k|    if (fragment.has_value()) {
  ------------------
  |  Branch (13531:9): [True: 373, False: 15.2k]
  ------------------
13532|    373|      url.update_unencoded_base_hash(*fragment);
13533|    373|    }
13534|  15.6k|  }
13535|  15.6k|  enforce_max_input_length();
13536|  15.6k|  return url;
13537|  47.3k|}
_ZN3ada6parser14parse_url_implINS_14url_aggregatorELb1EEET_NSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEPKS3_:
12517|  47.3k|                           const result_type* base_url) {
12518|       |  // We can specialize the implementation per type.
12519|       |  // Important: result_type_is_ada_url is evaluated at *compile time*. This
12520|       |  // means that doing if constexpr(result_type_is_ada_url) { something } else {
12521|       |  // something else } is free (at runtime). This means that ada::url_aggregator
12522|       |  // and ada::url **do not have to support the exact same API**.
12523|  47.3k|  constexpr bool result_type_is_ada_url = std::is_same_v<url, result_type>;
12524|  47.3k|  constexpr bool result_type_is_ada_url_aggregator =
12525|  47.3k|      std::is_same_v<url_aggregator, result_type>;
12526|  47.3k|  static_assert(result_type_is_ada_url ||
12527|  47.3k|                result_type_is_ada_url_aggregator);  // We don't support
12528|       |                                                     // anything else for now.
12529|       |
12530|  47.3k|  ada_log("ada::parser::parse_url('", user_input, "' [", user_input.size(),
12531|  47.3k|          " bytes],", (base_url != nullptr ? base_url->to_string() : "null"),
12532|  47.3k|          ")");
12533|       |
12534|  47.3k|  result_type url{};
12535|       |
12536|  47.3k|  const uint32_t max_input_length = ada::get_max_input_length();
12537|       |
12538|       |  // Normalization (percent-encoding, IDNA) can push the serialized URL past
12539|       |  // max_input_length even when the input fit under it. The check at the end of
12540|       |  // the state machine covers URLs that run to completion, but several states
12541|       |  // return early after appending a query or fragment, so run the same check on
12542|       |  // those exits too. Without this, a query- or fragment-terminated URL such as
12543|       |  // file://x/?<...> or https://user@x/?<...> is accepted while the equivalent
12544|       |  // https://x/?<...> that takes the absolute fast path is rejected.
12545|  47.3k|  const auto enforce_max_input_length = [&]() {
12546|  47.3k|    if constexpr (store_values) {
12547|  47.3k|      if (url.is_valid) {
12548|  47.3k|        if constexpr (result_type_is_ada_url_aggregator) {
12549|  47.3k|          if (url.buffer.size() > max_input_length) [[unlikely]] {
12550|  47.3k|            url.is_valid = false;
12551|  47.3k|          }
12552|  47.3k|        } else {
12553|  47.3k|          if (url.get_href_size() > max_input_length) [[unlikely]] {
12554|  47.3k|            url.is_valid = false;
12555|  47.3k|          }
12556|  47.3k|        }
12557|  47.3k|      }
12558|  47.3k|    }
12559|  47.3k|  };
12560|       |
12561|       |  // We refuse to parse URL strings that exceed the maximum input length.
12562|       |  // By default, this is 4GB but can be configured via
12563|       |  // ada::set_max_input_length().
12564|  47.3k|  if (user_input.size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (12564:7): [True: 0, False: 47.3k]
  ------------------
12565|      0|    url.is_valid = false;
12566|      0|  }
12567|       |  // Going forward, user_input.size() is in [0,
12568|       |  // std::numeric_limits<uint32_t>::max). If we are provided with an invalid
12569|       |  // base, or the optional_url was invalid, we must return.
12570|  47.3k|  if (base_url != nullptr) {
  ------------------
  |  Branch (12570:7): [True: 3.97k, False: 43.3k]
  ------------------
12571|  3.97k|    url.is_valid &= base_url->is_valid;
12572|  3.97k|  }
12573|  47.3k|  if (!url.is_valid) {
  ------------------
  |  Branch (12573:7): [True: 0, False: 47.3k]
  ------------------
12574|      0|    return url;
12575|      0|  }
12576|       |
12577|       |  // Simple absolute / relative fast paths (before tabs/newline scan).
12578|  47.3k|  if constexpr (store_values) {
12579|  47.3k|    bool hit_fast_path = false;
12580|  47.3k|    if (base_url == nullptr) {
  ------------------
  |  Branch (12580:9): [True: 43.3k, False: 3.97k]
  ------------------
12581|       |      // IPv4/IPv6 and userinfo miss the fast path. Skip the never_inline
12582|       |      // call so those URLs (including SetHref) do not pay for a miss.
12583|  43.3k|      const auto* p = reinterpret_cast<const uint8_t*>(user_input.data());
12584|  43.3k|      const size_t n = user_input.size();
12585|  43.3k|      size_t host_start = 0;
12586|  43.3k|      if (n >= 8 && p[4] == ':' && p[5] == '/' && p[6] == '/') {
  ------------------
  |  Branch (12586:11): [True: 16.6k, False: 26.7k]
  |  Branch (12586:21): [True: 3.30k, False: 13.3k]
  |  Branch (12586:36): [True: 2.52k, False: 780]
  |  Branch (12586:51): [True: 2.49k, False: 26]
  ------------------
12587|  2.49k|        host_start = 7;
12588|  40.9k|      } else if (n >= 9 && p[5] == ':' && p[6] == '/' && p[7] == '/') {
  ------------------
  |  Branch (12588:18): [True: 12.8k, False: 28.0k]
  |  Branch (12588:28): [True: 283, False: 12.5k]
  |  Branch (12588:43): [True: 60, False: 223]
  |  Branch (12588:58): [True: 39, False: 21]
  ------------------
12589|     39|        host_start = 8;
12590|     39|      }
12591|  43.3k|      const uint8_t host_first = host_start != 0 ? p[host_start] : 0;
  ------------------
  |  Branch (12591:34): [True: 2.53k, False: 40.8k]
  ------------------
12592|  43.3k|      const bool skip_ip =
12593|  43.3k|          host_first == '[' || (host_first >= '0' && host_first <= '9');
  ------------------
  |  Branch (12593:11): [True: 34, False: 43.3k]
  |  Branch (12593:33): [True: 1.81k, False: 41.5k]
  |  Branch (12593:54): [True: 544, False: 1.27k]
  ------------------
12594|  43.3k|      const bool skip_userinfo =
12595|  43.3k|          host_start != 0 && authority_has_at(p, host_start, n);
  ------------------
  |  Branch (12595:11): [True: 2.53k, False: 40.8k]
  |  Branch (12595:30): [True: 19, False: 2.51k]
  ------------------
12596|  43.3k|      hit_fast_path = !skip_ip && !skip_userinfo &&
  ------------------
  |  Branch (12596:23): [True: 42.8k, False: 578]
  |  Branch (12596:35): [True: 42.8k, False: 16]
  ------------------
12597|  42.8k|                      try_parse_simple_absolute(user_input, url);
  ------------------
  |  Branch (12597:23): [True: 4.26k, False: 38.5k]
  ------------------
12598|  43.3k|    } else {
12599|  3.97k|      hit_fast_path = try_parse_simple_relative(user_input, *base_url, url);
12600|  3.97k|    }
12601|  47.3k|    if (hit_fast_path) {
  ------------------
  |  Branch (12601:9): [True: 4.41k, False: 42.9k]
  ------------------
12602|  4.41k|      if constexpr (result_type_is_ada_url_aggregator) {
12603|  4.41k|        if (url.buffer.size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (12603:13): [True: 0, False: 4.41k]
  ------------------
12604|      0|          url.is_valid = false;
12605|      0|        }
12606|       |      } else {
12607|       |        // For a small absolute input, even worst-case normalization cannot
12608|       |        // exceed the limit: percent encoding expands at most 3x and IDNA at
12609|       |        // most 4.5x. Avoid traversing every stored component on the common
12610|       |        // default-limit path.
12611|       |        if ((base_url != nullptr ||
12612|       |             user_input.size() > static_cast<size_t>(max_input_length) / 5) &&
12613|       |            url.get_href_size() > max_input_length) [[unlikely]] {
12614|       |          url.is_valid = false;
12615|       |        }
12616|       |      }
12617|  4.41k|      return url;
12618|  4.41k|    }
12619|  47.3k|  }
12620|       |
12621|  42.9k|  state state = state::SCHEME_START;
12622|       |
12623|  47.3k|  std::string tmp_buffer;
12624|  47.3k|  std::string_view url_data;
12625|  47.3k|  if (unicode::has_tabs_or_newline(user_input)) [[unlikely]] {
  ------------------
  |  Branch (12625:7): [True: 257, False: 47.1k]
  ------------------
12626|    257|    tmp_buffer = user_input;
12627|       |    // Optimization opportunity: Instead of copying and then pruning, we could
12628|       |    // just directly build the string from user_input.
12629|    257|    helpers::remove_ascii_tab_or_newline(tmp_buffer);
12630|    257|    url_data = tmp_buffer;
12631|  47.1k|  } else [[likely]] {
12632|  47.1k|    url_data = user_input;
12633|  47.1k|  }
12634|       |
12635|       |  // Leading and trailing control characters are uncommon and easy to deal with
12636|       |  // (no performance concern).
12637|  47.3k|  helpers::trim_c0_whitespace(url_data);
12638|       |
12639|  47.3k|  if constexpr (result_type_is_ada_url_aggregator && store_values) {
12640|       |    // Most of the time, we just need user_input.size().
12641|       |    // In some instances, we may need a bit more.
12642|       |    ///////////////////////////
12643|       |    // This is *very* important. This line should *not* be removed
12644|       |    // hastily. There are principled reasons why reserve is important
12645|       |    // for performance. If you have a benchmark with small inputs,
12646|       |    // it may not matter, but in other instances, it could.
12647|       |    ////
12648|       |    // This rounds up to the next power of two.
12649|       |    // We know that user_input.size() is in [0,
12650|       |    // std::numeric_limits<uint32_t>::max).
12651|  47.3k|    uint32_t reserve_capacity =
12652|  47.3k|        (0xFFFFFFFF >>
12653|  47.3k|         helpers::leading_zeroes(uint32_t(1 | user_input.size()))) +
12654|  47.3k|        1;
12655|  47.3k|    url.reserve(reserve_capacity);
12656|  47.3k|  }
12657|       |
12658|       |  // Optimization opportunity. Most websites do not have fragment.
12659|  47.3k|  std::optional<std::string_view> fragment = helpers::prune_hash(url_data);
12660|       |  // We add it last so that an implementation like ada::url_aggregator
12661|       |  // can append it last to its internal buffer, thus improving performance.
12662|       |
12663|       |  // Here url_data no longer has its fragment.
12664|       |  // We are going to access the data from url_data (it is immutable).
12665|       |  // At any given time, we are pointing at byte 'input_position' in url_data.
12666|       |  // The input_position variable should range from 0 to input_size.
12667|       |  // It is illegal to access url_data at input_size.
12668|  47.3k|  size_t input_position = 0;
12669|  47.3k|  const size_t input_size = url_data.size();
12670|       |  // Keep running the following state machine by switching on state.
12671|       |  // If after a run pointer points to the EOF code point, go to the next step.
12672|       |  // Otherwise, increase pointer by 1 and continue with the state machine.
12673|       |  // We never decrement input_position.
12674|   176k|  while (input_position <= input_size) {
  ------------------
  |  Branch (12674:10): [True: 161k, False: 15.6k]
  ------------------
12675|   161k|    ada_log("In parsing at ", input_position, " out of ", input_size,
12676|   161k|            " in state ", ada::to_string(state));
12677|   161k|    switch (state) {
12678|  42.9k|      case state::SCHEME_START: {
  ------------------
  |  Branch (12678:7): [True: 42.9k, False: 118k]
  ------------------
12679|  42.9k|        ada_log("SCHEME_START ", helpers::substring(url_data, input_position));
12680|       |        // If c is an ASCII alpha, append c, lowercased, to buffer, and set
12681|       |        // state to scheme state.
12682|  42.9k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (12682:13): [True: 22.6k, False: 20.3k]
  ------------------
12683|  22.6k|            checkers::is_alpha(url_data[input_position])) {
  ------------------
  |  Branch (12683:13): [True: 21.6k, False: 994]
  ------------------
12684|  21.6k|          state = state::SCHEME;
12685|  21.6k|          input_position++;
12686|  21.6k|        } else {
12687|       |          // Otherwise, if state override is not given, set state to no scheme
12688|       |          // state and decrease pointer by 1.
12689|  21.3k|          state = state::NO_SCHEME;
12690|  21.3k|        }
12691|  42.9k|        break;
12692|      0|      }
12693|  21.6k|      case state::SCHEME: {
  ------------------
  |  Branch (12693:7): [True: 21.6k, False: 139k]
  ------------------
12694|  21.6k|        ada_log("SCHEME ", helpers::substring(url_data, input_position));
12695|       |        // If c is an ASCII alphanumeric, U+002B (+), U+002D (-), or U+002E (.),
12696|       |        // append c, lowercased, to buffer.
12697|  51.4k|        while ((input_position != input_size) &&
  ------------------
  |  Branch (12697:16): [True: 51.1k, False: 279]
  ------------------
12698|  51.1k|               (unicode::is_alnum_plus(url_data[input_position]))) {
  ------------------
  |  Branch (12698:16): [True: 29.8k, False: 21.3k]
  ------------------
12699|  29.8k|          input_position++;
12700|  29.8k|        }
12701|       |        // Otherwise, if c is U+003A (:), then:
12702|  21.6k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (12702:13): [True: 21.3k, False: 279]
  ------------------
12703|  21.3k|            (url_data[input_position] == ':')) {
  ------------------
  |  Branch (12703:13): [True: 21.0k, False: 315]
  ------------------
12704|  21.0k|          ada_log("SCHEME the scheme should be ",
12705|  21.0k|                  url_data.substr(0, input_position));
12706|       |          if constexpr (result_type_is_ada_url) {
12707|       |            if (!url.parse_scheme(url_data.substr(0, input_position))) {
12708|       |              return url;
12709|       |            }
12710|  21.0k|          } else {
12711|       |            // we pass the colon along instead of painfully adding it back.
12712|  21.0k|            if (!url.parse_scheme_with_colon(
  ------------------
  |  Branch (12712:17): [True: 0, False: 21.0k]
  ------------------
12713|  21.0k|                    url_data.substr(0, input_position + 1))) {
12714|      0|              return url;
12715|      0|            }
12716|  21.0k|          }
12717|  21.0k|          ada_log("SCHEME the scheme is ", url.get_protocol());
12718|       |
12719|       |          // If url's scheme is "file", then:
12720|       |          // NOLINTNEXTLINE(bugprone-branch-clone)
12721|  21.0k|          if (url.type == scheme::type::FILE) {
  ------------------
  |  Branch (12721:15): [True: 2.71k, False: 18.3k]
  ------------------
12722|       |            // Set state to file state.
12723|  2.71k|            state = state::FILE;
12724|  2.71k|          }
12725|       |          // Otherwise, if url is special, base is non-null, and base's scheme
12726|       |          // is url's scheme: Note: Doing base_url->scheme is unsafe if base_url
12727|       |          // != nullptr is false.
12728|  18.3k|          else if (url.is_special() && base_url != nullptr &&
  ------------------
  |  Branch (12728:20): [True: 12.7k, False: 5.54k]
  |  Branch (12728:40): [True: 2.13k, False: 10.6k]
  ------------------
12729|  2.13k|                   base_url->type == url.type) {
  ------------------
  |  Branch (12729:20): [True: 270, False: 1.86k]
  ------------------
12730|       |            // Set state to special relative or authority state.
12731|    270|            state = state::SPECIAL_RELATIVE_OR_AUTHORITY;
12732|    270|          }
12733|       |          // Otherwise, if url is special, set state to special authority
12734|       |          // slashes state.
12735|  18.0k|          else if (url.is_special()) {
  ------------------
  |  Branch (12735:20): [True: 12.5k, False: 5.54k]
  ------------------
12736|  12.5k|            state = state::SPECIAL_AUTHORITY_SLASHES;
12737|  12.5k|          }
12738|       |          // Otherwise, if remaining starts with an U+002F (/), set state to
12739|       |          // path or authority state and increase pointer by 1.
12740|  5.54k|          else if (input_position + 1 < input_size &&
  ------------------
  |  Branch (12740:20): [True: 3.20k, False: 2.33k]
  ------------------
12741|  3.20k|                   url_data[input_position + 1] == '/') {
  ------------------
  |  Branch (12741:20): [True: 2.20k, False: 1.00k]
  ------------------
12742|  2.20k|            state = state::PATH_OR_AUTHORITY;
12743|  2.20k|            input_position++;
12744|  2.20k|          }
12745|       |          // Otherwise, set url's path to the empty string and set state to
12746|       |          // opaque path state.
12747|  3.33k|          else {
12748|  3.33k|            state = state::OPAQUE_PATH;
12749|  3.33k|          }
12750|  21.0k|        }
12751|       |        // Otherwise, if state override is not given, set buffer to the empty
12752|       |        // string, state to no scheme state, and start over (from the first code
12753|       |        // point in input).
12754|    594|        else {
12755|    594|          state = state::NO_SCHEME;
12756|    594|          input_position = 0;
12757|    594|          break;
12758|    594|        }
12759|  21.0k|        input_position++;
12760|  21.0k|        break;
12761|  21.6k|      }
12762|  21.9k|      case state::NO_SCHEME: {
  ------------------
  |  Branch (12762:7): [True: 21.9k, False: 139k]
  ------------------
12763|  21.9k|        ada_log("NO_SCHEME ", helpers::substring(url_data, input_position));
12764|       |        // The fragment was pruned from url_data before the state machine ran,
12765|       |        // so 'c is U+0023 (#)' holds exactly when a fragment was found and
12766|       |        // nothing else remains in front of it.
12767|  21.9k|        const bool c_is_hash =
12768|  21.9k|            fragment.has_value() && input_position == input_size;
  ------------------
  |  Branch (12768:13): [True: 257, False: 21.6k]
  |  Branch (12768:37): [True: 201, False: 56]
  ------------------
12769|       |        // If base is null, or base has an opaque path and c is not U+0023 (#),
12770|       |        // validation error, return failure.
12771|  21.9k|        if (base_url == nullptr || (base_url->has_opaque_path && !c_is_hash)) {
  ------------------
  |  Branch (12771:13): [True: 21.0k, False: 858]
  |  Branch (12771:37): [True: 117, False: 741]
  |  Branch (12771:66): [True: 50, False: 67]
  ------------------
12772|  21.0k|          ada_log("NO_SCHEME validation error");
12773|  21.0k|          url.is_valid = false;
12774|  21.0k|          return url;
12775|  21.0k|        }
12776|       |        // Otherwise, if base has an opaque path and c is U+0023 (#),
12777|       |        // set url's scheme to base's scheme, url's path to base's path, url's
12778|       |        // query to base's query, and set state to fragment state.
12779|    808|        else if (base_url->has_opaque_path && c_is_hash) {
  ------------------
  |  Branch (12779:18): [True: 67, False: 741]
  |  Branch (12779:47): [True: 67, False: 0]
  ------------------
12780|     67|          ada_log("NO_SCHEME opaque base with fragment");
12781|     67|          url.copy_scheme(*base_url);
12782|     67|          url.has_opaque_path = base_url->has_opaque_path;
12783|       |
12784|       |          if constexpr (result_type_is_ada_url) {
12785|       |            url.path = base_url->path;
12786|       |            url.query = base_url->query;
12787|     67|          } else {
12788|     67|            url.update_base_pathname(base_url->get_pathname());
12789|     67|            if (base_url->has_search()) {
  ------------------
  |  Branch (12789:17): [True: 35, False: 32]
  ------------------
12790|       |              // get_search() returns "" for an empty query string (URL ends
12791|       |              // with '?'). update_base_search("") would incorrectly clear the
12792|       |              // query, so pass "?" to preserve the empty query distinction.
12793|     35|              auto s = base_url->get_search();
12794|     35|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (12794:38): [True: 13, False: 22]
  ------------------
12795|     35|            }
12796|     67|          }
12797|     67|          url.update_unencoded_base_hash(*fragment);
12798|     67|          enforce_max_input_length();
12799|     67|          return url;
12800|     67|        }
12801|       |        // Otherwise, if base's scheme is not "file", set state to relative
12802|       |        // state and decrease pointer by 1.
12803|       |        // NOLINTNEXTLINE(bugprone-branch-clone)
12804|    741|        else if (base_url->type != scheme::type::FILE) {
  ------------------
  |  Branch (12804:18): [True: 485, False: 256]
  ------------------
12805|    485|          ada_log("NO_SCHEME non-file relative path");
12806|    485|          state = state::RELATIVE_SCHEME;
12807|    485|        }
12808|       |        // Otherwise, set state to file state and decrease pointer by 1.
12809|    256|        else {
12810|    256|          ada_log("NO_SCHEME file base type");
12811|    256|          state = state::FILE;
12812|    256|        }
12813|    741|        break;
12814|  21.9k|      }
12815|  13.5k|      case state::AUTHORITY: {
  ------------------
  |  Branch (12815:7): [True: 13.5k, False: 147k]
  ------------------
12816|  13.5k|        ada_log("AUTHORITY ", helpers::substring(url_data, input_position));
12817|       |        // most URLs have no @. Having no @ tells us that we don't have to worry
12818|       |        // about AUTHORITY. Of course, we could have @ and still not have to
12819|       |        // worry about AUTHORITY.
12820|       |        // TODO: Instead of just collecting a bool, collect the location of the
12821|       |        // '@' and do something useful with it.
12822|       |        // TODO: We could do various processing early on, using a single pass
12823|       |        // over the string to collect information about it, e.g., telling us
12824|       |        // whether there is a @ and if so, where (or how many).
12825|       |
12826|       |        // Check if url data contains an @.
12827|  13.5k|        if (url_data.find('@', input_position) == std::string_view::npos) {
  ------------------
  |  Branch (12827:13): [True: 12.3k, False: 1.25k]
  ------------------
12828|  12.3k|          state = state::HOST;
12829|  12.3k|          break;
12830|  12.3k|        }
12831|  1.25k|        bool at_sign_seen{false};
12832|  1.25k|        bool password_token_seen{false};
12833|       |        /**
12834|       |         * We expect something of the sort...
12835|       |         * https://user:pass@example.com:1234/foo/bar?baz#quux
12836|       |         * --------^
12837|       |         */
12838|  8.84k|        do {
12839|  8.84k|          std::string_view view = url_data.substr(input_position);
12840|       |          // The delimiters are @, /, ? \\.
12841|  8.84k|          size_t location =
12842|  8.84k|              url.is_special() ? helpers::find_authority_delimiter_special(view)
  ------------------
  |  Branch (12842:15): [True: 8.31k, False: 531]
  ------------------
12843|  8.84k|                               : helpers::find_authority_delimiter(view);
12844|  8.84k|          std::string_view authority_view = view.substr(0, location);
12845|  8.84k|          size_t end_of_authority = input_position + authority_view.size();
12846|       |          // If c is U+0040 (@), then:
12847|  8.84k|          if ((end_of_authority != input_size) &&
  ------------------
  |  Branch (12847:15): [True: 8.04k, False: 798]
  ------------------
12848|  8.04k|              (url_data[end_of_authority] == '@')) {
  ------------------
  |  Branch (12848:15): [True: 7.59k, False: 455]
  ------------------
12849|       |            // If atSignSeen is true, then prepend "%40" to buffer.
12850|  7.59k|            if (at_sign_seen) {
  ------------------
  |  Branch (12850:17): [True: 6.46k, False: 1.12k]
  ------------------
12851|  6.46k|              if (password_token_seen) {
  ------------------
  |  Branch (12851:19): [True: 2.33k, False: 4.13k]
  ------------------
12852|       |                if constexpr (result_type_is_ada_url) {
12853|       |                  url.password += "%40";
12854|  2.33k|                } else {
12855|  2.33k|                  url.append_base_password("%40");
12856|  2.33k|                }
12857|  4.13k|              } else {
12858|       |                if constexpr (result_type_is_ada_url) {
12859|       |                  url.username += "%40";
12860|  4.13k|                } else {
12861|  4.13k|                  url.append_base_username("%40");
12862|  4.13k|                }
12863|  4.13k|              }
12864|  6.46k|            }
12865|       |
12866|  7.59k|            at_sign_seen = true;
12867|       |
12868|  7.59k|            if (!password_token_seen) {
  ------------------
  |  Branch (12868:17): [True: 5.25k, False: 2.33k]
  ------------------
12869|  5.25k|              size_t password_token_location = authority_view.find(':');
12870|  5.25k|              password_token_seen =
12871|  5.25k|                  password_token_location != std::string_view::npos;
12872|       |
12873|  5.25k|              if constexpr (store_values) {
12874|  5.25k|                if (!password_token_seen) {
  ------------------
  |  Branch (12874:21): [True: 4.81k, False: 441]
  ------------------
12875|       |                  if constexpr (result_type_is_ada_url) {
12876|       |                    url.username += unicode::percent_encode(
12877|       |                        authority_view,
12878|       |                        character_sets::USERINFO_PERCENT_ENCODE);
12879|  4.81k|                  } else {
12880|  4.81k|                    url.append_base_username(unicode::percent_encode(
12881|  4.81k|                        authority_view,
12882|  4.81k|                        character_sets::USERINFO_PERCENT_ENCODE));
12883|  4.81k|                  }
12884|  4.81k|                } else {
12885|       |                  if constexpr (result_type_is_ada_url) {
12886|       |                    url.username += unicode::percent_encode(
12887|       |                        authority_view.substr(0, password_token_location),
12888|       |                        character_sets::USERINFO_PERCENT_ENCODE);
12889|       |                    url.password += unicode::percent_encode(
12890|       |                        authority_view.substr(password_token_location + 1),
12891|       |                        character_sets::USERINFO_PERCENT_ENCODE);
12892|    441|                  } else {
12893|    441|                    url.append_base_username(unicode::percent_encode(
12894|    441|                        authority_view.substr(0, password_token_location),
12895|    441|                        character_sets::USERINFO_PERCENT_ENCODE));
12896|    441|                    url.append_base_password(unicode::percent_encode(
12897|    441|                        authority_view.substr(password_token_location + 1),
12898|    441|                        character_sets::USERINFO_PERCENT_ENCODE));
12899|    441|                  }
12900|    441|                }
12901|  5.25k|              }
12902|  5.25k|            } else if constexpr (store_values) {
12903|       |              if constexpr (result_type_is_ada_url) {
12904|       |                url.password += unicode::percent_encode(
12905|       |                    authority_view, character_sets::USERINFO_PERCENT_ENCODE);
12906|  2.33k|              } else {
12907|  2.33k|                url.append_base_password(unicode::percent_encode(
12908|  2.33k|                    authority_view, character_sets::USERINFO_PERCENT_ENCODE));
12909|  2.33k|              }
12910|  2.33k|            }
12911|  7.59k|          }
12912|       |          // Otherwise, if one of the following is true:
12913|       |          // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
12914|       |          // - url is special and c is U+005C (\)
12915|  1.25k|          else if (end_of_authority == input_size ||
  ------------------
  |  Branch (12915:20): [True: 798, False: 455]
  ------------------
12916|    455|                   url_data[end_of_authority] == '/' ||
  ------------------
  |  Branch (12916:20): [True: 418, False: 37]
  ------------------
12917|     37|                   url_data[end_of_authority] == '?' ||
  ------------------
  |  Branch (12917:20): [True: 30, False: 7]
  ------------------
12918|  1.25k|                   (url.is_special() && url_data[end_of_authority] == '\\')) {
  ------------------
  |  Branch (12918:21): [True: 7, False: 0]
  |  Branch (12918:41): [True: 7, False: 0]
  ------------------
12919|       |            // If atSignSeen is true and authority_view is the empty string,
12920|       |            // validation error, return failure.
12921|  1.25k|            if (at_sign_seen && authority_view.empty()) {
  ------------------
  |  Branch (12921:17): [True: 1.12k, False: 131]
  |  Branch (12921:33): [True: 337, False: 785]
  ------------------
12922|    337|              url.is_valid = false;
12923|    337|              return url;
12924|    337|            }
12925|    916|            state = state::HOST;
12926|    916|            break;
12927|  1.25k|          }
12928|  7.59k|          if (end_of_authority == input_size) {
  ------------------
  |  Branch (12928:15): [True: 0, False: 7.59k]
  ------------------
12929|      0|            if constexpr (store_values) {
12930|      0|              if (fragment.has_value()) {
  ------------------
  |  Branch (12930:19): [True: 0, False: 0]
  ------------------
12931|      0|                url.update_unencoded_base_hash(*fragment);
12932|      0|              }
12933|      0|            }
12934|      0|            enforce_max_input_length();
12935|      0|            return url;
12936|      0|          }
12937|  7.59k|          input_position = end_of_authority + 1;
12938|  7.59k|        } while (true);
  ------------------
  |  Branch (12938:18): [True: 7.59k, Folded]
  ------------------
12939|       |
12940|    916|        break;
12941|  1.25k|      }
12942|    916|      case state::SPECIAL_RELATIVE_OR_AUTHORITY: {
  ------------------
  |  Branch (12942:7): [True: 270, False: 160k]
  ------------------
12943|    270|        ada_log("SPECIAL_RELATIVE_OR_AUTHORITY ",
12944|    270|                helpers::substring(url_data, input_position));
12945|       |
12946|       |        // If c is U+002F (/) and remaining starts with U+002F (/),
12947|       |        // then set state to special authority ignore slashes state and increase
12948|       |        // pointer by 1.
12949|    270|        if (url_data.substr(input_position, 2) == "//") {
  ------------------
  |  Branch (12949:13): [True: 192, False: 78]
  ------------------
12950|    192|          state = state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
12951|    192|          input_position += 2;
12952|    192|        } else {
12953|       |          // Otherwise, validation error, set state to relative state and
12954|       |          // decrease pointer by 1.
12955|     78|          state = state::RELATIVE_SCHEME;
12956|     78|        }
12957|       |
12958|    270|        break;
12959|  1.25k|      }
12960|  2.20k|      case state::PATH_OR_AUTHORITY: {
  ------------------
  |  Branch (12960:7): [True: 2.20k, False: 158k]
  ------------------
12961|  2.20k|        ada_log("PATH_OR_AUTHORITY ",
12962|  2.20k|                helpers::substring(url_data, input_position));
12963|       |
12964|       |        // If c is U+002F (/), then set state to authority state.
12965|  2.20k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (12965:13): [True: 2.08k, False: 115]
  ------------------
12966|  2.08k|            (url_data[input_position] == '/')) {
  ------------------
  |  Branch (12966:13): [True: 840, False: 1.24k]
  ------------------
12967|    840|          state = state::AUTHORITY;
12968|    840|          input_position++;
12969|  1.36k|        } else {
12970|       |          // Otherwise, set state to path state, and decrease pointer by 1.
12971|  1.36k|          state = state::PATH;
12972|  1.36k|        }
12973|       |
12974|  2.20k|        break;
12975|  1.25k|      }
12976|    563|      case state::RELATIVE_SCHEME: {
  ------------------
  |  Branch (12976:7): [True: 563, False: 160k]
  ------------------
12977|    563|        ada_log("RELATIVE_SCHEME ",
12978|    563|                helpers::substring(url_data, input_position));
12979|       |
12980|       |        // Set url's scheme to base's scheme.
12981|    563|        url.copy_scheme(*base_url);
12982|       |
12983|       |        // If c is U+002F (/), then set state to relative slash state.
12984|    563|        if ((input_position != input_size) &&
  ------------------
  |  Branch (12984:13): [True: 418, False: 145]
  ------------------
12985|       |            // NOLINTNEXTLINE(bugprone-branch-clone)
12986|    418|            (url_data[input_position] == '/')) {
  ------------------
  |  Branch (12986:13): [True: 40, False: 378]
  ------------------
12987|     40|          ada_log(
12988|     40|              "RELATIVE_SCHEME if c is U+002F (/), then set state to relative "
12989|     40|              "slash state");
12990|     40|          state = state::RELATIVE_SLASH;
12991|    523|        } else if (url.is_special() && (input_position != input_size) &&
  ------------------
  |  Branch (12991:20): [True: 378, False: 145]
  |  Branch (12991:40): [True: 275, False: 103]
  ------------------
12992|    275|                   (url_data[input_position] == '\\')) {
  ------------------
  |  Branch (12992:20): [True: 6, False: 269]
  ------------------
12993|       |          // Otherwise, if url is special and c is U+005C (\), validation error,
12994|       |          // set state to relative slash state.
12995|      6|          ada_log(
12996|      6|              "RELATIVE_SCHEME  if url is special and c is U+005C, validation "
12997|      6|              "error, set state to relative slash state");
12998|      6|          state = state::RELATIVE_SLASH;
12999|    517|        } else {
13000|    517|          ada_log("RELATIVE_SCHEME otherwise");
13001|       |          // Set url's username to base's username, url's password to base's
13002|       |          // password, url's host to base's host, url's port to base's port,
13003|       |          // url's path to a clone of base's path, and url's query to base's
13004|       |          // query.
13005|       |          if constexpr (result_type_is_ada_url) {
13006|       |            url.username = base_url->username;
13007|       |            url.password = base_url->password;
13008|       |            url.host = base_url->host;
13009|       |            url.port = base_url->port;
13010|       |            // cloning the base path includes cloning the has_opaque_path flag
13011|       |            url.has_opaque_path = base_url->has_opaque_path;
13012|       |            url.path = base_url->path;
13013|       |            url.query = base_url->query;
13014|    517|          } else {
13015|    517|            url.update_base_authority(base_url->get_href(),
13016|    517|                                      base_url->get_components());
13017|    517|            url.update_host_to_base_host(base_url->get_hostname());
13018|    517|            url.update_base_port(base_url->retrieve_base_port());
13019|       |            // cloning the base path includes cloning the has_opaque_path flag
13020|    517|            url.has_opaque_path = base_url->has_opaque_path;
13021|    517|            url.update_base_pathname(base_url->get_pathname());
13022|    517|            if (base_url->has_search()) {
  ------------------
  |  Branch (13022:17): [True: 75, False: 442]
  ------------------
13023|       |              // get_search() returns "" for an empty query string (URL ends
13024|       |              // with '?'). update_base_search("") would incorrectly clear the
13025|       |              // query, so pass "?" to preserve the empty query distinction.
13026|     75|              auto s = base_url->get_search();
13027|     75|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (13027:38): [True: 28, False: 47]
  ------------------
13028|     75|            }
13029|    517|          }
13030|       |
13031|    517|          url.has_opaque_path = base_url->has_opaque_path;
13032|       |
13033|       |          // If c is U+003F (?), then set url's query to the empty string, and
13034|       |          // state to query state.
13035|    517|          if ((input_position != input_size) &&
  ------------------
  |  Branch (13035:15): [True: 372, False: 145]
  ------------------
13036|    372|              (url_data[input_position] == '?')) {
  ------------------
  |  Branch (13036:15): [True: 19, False: 353]
  ------------------
13037|     19|            state = state::QUERY;
13038|     19|          }
13039|       |          // Otherwise, if c is not the EOF code point:
13040|    498|          else if (input_position != input_size) {
  ------------------
  |  Branch (13040:20): [True: 353, False: 145]
  ------------------
13041|       |            // Set url's query to null.
13042|    353|            url.clear_search();
13043|       |            if constexpr (result_type_is_ada_url) {
13044|       |              // Shorten url's path.
13045|       |              helpers::shorten_path(url.path, url.type);
13046|    353|            } else {
13047|    353|              std::string_view path = url.get_pathname();
13048|    353|              if (helpers::shorten_path(path, url.type)) {
  ------------------
  |  Branch (13048:19): [True: 349, False: 4]
  ------------------
13049|    349|                url.update_base_pathname(std::move(std::string(path)));
13050|    349|              }
13051|    353|            }
13052|       |            // Set state to path state and decrease pointer by 1.
13053|    353|            state = state::PATH;
13054|    353|            break;
13055|    353|          }
13056|    517|        }
13057|    210|        input_position++;
13058|    210|        break;
13059|    563|      }
13060|     46|      case state::RELATIVE_SLASH: {
  ------------------
  |  Branch (13060:7): [True: 46, False: 161k]
  ------------------
13061|     46|        ada_log("RELATIVE_SLASH ",
13062|     46|                helpers::substring(url_data, input_position));
13063|       |
13064|       |        // If url is special and c is U+002F (/) or U+005C (\), then:
13065|       |        // NOLINTNEXTLINE(bugprone-branch-clone)
13066|     46|        if (url.is_special() && (input_position != input_size) &&
  ------------------
  |  Branch (13066:13): [True: 37, False: 9]
  |  Branch (13066:33): [True: 28, False: 9]
  ------------------
13067|     28|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13067:14): [True: 4, False: 24]
  ------------------
13068|     24|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13068:14): [True: 2, False: 22]
  ------------------
13069|       |          // Set state to special authority ignore slashes state.
13070|      6|          state = state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
13071|      6|        }
13072|       |        // Otherwise, if c is U+002F (/), then set state to authority state.
13073|     40|        else if ((input_position != input_size) &&
  ------------------
  |  Branch (13073:18): [True: 26, False: 14]
  ------------------
13074|     26|                 (url_data[input_position] == '/')) {
  ------------------
  |  Branch (13074:18): [True: 2, False: 24]
  ------------------
13075|      2|          state = state::AUTHORITY;
13076|      2|        }
13077|       |        // Otherwise, set
13078|       |        // - url's username to base's username,
13079|       |        // - url's password to base's password,
13080|       |        // - url's host to base's host,
13081|       |        // - url's port to base's port,
13082|       |        // - state to path state, and then, decrease pointer by 1.
13083|     38|        else {
13084|       |          if constexpr (result_type_is_ada_url) {
13085|       |            url.username = base_url->username;
13086|       |            url.password = base_url->password;
13087|       |            url.host = base_url->host;
13088|       |            url.port = base_url->port;
13089|     38|          } else {
13090|     38|            url.update_base_authority(base_url->get_href(),
13091|     38|                                      base_url->get_components());
13092|     38|            url.update_host_to_base_host(base_url->get_hostname());
13093|     38|            url.update_base_port(base_url->retrieve_base_port());
13094|     38|          }
13095|     38|          state = state::PATH;
13096|     38|          break;
13097|     38|        }
13098|       |
13099|      8|        input_position++;
13100|      8|        break;
13101|     46|      }
13102|  12.5k|      case state::SPECIAL_AUTHORITY_SLASHES: {
  ------------------
  |  Branch (13102:7): [True: 12.5k, False: 148k]
  ------------------
13103|  12.5k|        ada_log("SPECIAL_AUTHORITY_SLASHES ",
13104|  12.5k|                helpers::substring(url_data, input_position));
13105|       |
13106|       |        // If c is U+002F (/) and remaining starts with U+002F (/),
13107|       |        // then set state to special authority ignore slashes state and increase
13108|       |        // pointer by 1.
13109|  12.5k|        if (url_data.substr(input_position, 2) == "//") {
  ------------------
  |  Branch (13109:13): [True: 3.21k, False: 9.30k]
  ------------------
13110|  3.21k|          input_position += 2;
13111|  3.21k|        }
13112|       |
13113|  12.5k|        [[fallthrough]];
13114|  12.5k|      }
13115|  12.7k|      case state::SPECIAL_AUTHORITY_IGNORE_SLASHES: {
  ------------------
  |  Branch (13115:7): [True: 198, False: 160k]
  ------------------
13116|  12.7k|        ada_log("SPECIAL_AUTHORITY_IGNORE_SLASHES ",
13117|  12.7k|                helpers::substring(url_data, input_position));
13118|       |
13119|       |        // If c is neither U+002F (/) nor U+005C (\), then set state to
13120|       |        // authority state and decrease pointer by 1.
13121|  13.7k|        while ((input_position != input_size) &&
  ------------------
  |  Branch (13121:16): [True: 13.6k, False: 86]
  ------------------
13122|  13.6k|               ((url_data[input_position] == '/') ||
  ------------------
  |  Branch (13122:17): [True: 627, False: 13.0k]
  ------------------
13123|  13.0k|                (url_data[input_position] == '\\'))) {
  ------------------
  |  Branch (13123:17): [True: 401, False: 12.6k]
  ------------------
13124|  1.02k|          input_position++;
13125|  1.02k|        }
13126|  12.7k|        state = state::AUTHORITY;
13127|       |
13128|  12.7k|        break;
13129|  12.5k|      }
13130|  1.00k|      case state::QUERY: {
  ------------------
  |  Branch (13130:7): [True: 1.00k, False: 160k]
  ------------------
13131|  1.00k|        ada_log("QUERY ", helpers::substring(url_data, input_position));
13132|  1.00k|        if constexpr (store_values) {
13133|       |          // Let queryPercentEncodeSet be the special-query percent-encode set
13134|       |          // if url is special; otherwise the query percent-encode set.
13135|  1.00k|          const uint8_t* query_percent_encode_set =
13136|  1.00k|              url.is_special() ? character_sets::SPECIAL_QUERY_PERCENT_ENCODE
  ------------------
  |  Branch (13136:15): [True: 584, False: 418]
  ------------------
13137|  1.00k|                               : character_sets::QUERY_PERCENT_ENCODE;
13138|       |
13139|       |          // Percent-encode after encoding, with encoding, buffer, and
13140|       |          // queryPercentEncodeSet, and append the result to url's query.
13141|  1.00k|          url.update_base_search(url_data.substr(input_position),
13142|  1.00k|                                 query_percent_encode_set);
13143|  1.00k|          ada_log("QUERY update_base_search completed ");
13144|  1.00k|          if (fragment.has_value()) {
  ------------------
  |  Branch (13144:15): [True: 216, False: 786]
  ------------------
13145|    216|            url.update_unencoded_base_hash(*fragment);
13146|    216|          }
13147|  1.00k|        }
13148|  1.00k|        enforce_max_input_length();
13149|  1.00k|        return url;
13150|  12.5k|      }
13151|  13.2k|      case state::HOST: {
  ------------------
  |  Branch (13151:7): [True: 13.2k, False: 147k]
  ------------------
13152|  13.2k|        ada_log("HOST ", helpers::substring(url_data, input_position));
13153|       |
13154|  13.2k|        std::string_view host_view = url_data.substr(input_position);
13155|  13.2k|        auto [location, found_colon] =
13156|  13.2k|            helpers::get_host_delimiter_location(url.is_special(), host_view);
13157|  13.2k|        input_position = (location != std::string_view::npos)
  ------------------
  |  Branch (13157:26): [True: 13.2k, False: 0]
  ------------------
13158|  13.2k|                             ? input_position + location
13159|  13.2k|                             : input_size;
13160|       |        // Otherwise, if c is U+003A (:) and insideBrackets is false, then:
13161|       |        // Note: the 'found_colon' value is true if and only if a colon was
13162|       |        // encountered while not inside brackets.
13163|  13.2k|        if (found_colon) {
  ------------------
  |  Branch (13163:13): [True: 2.17k, False: 11.0k]
  ------------------
13164|       |          // If buffer is the empty string, validation error, return failure.
13165|       |          // Let host be the result of host parsing buffer with url is not
13166|       |          // special.
13167|  2.17k|          ada_log("HOST parsing ", host_view);
13168|  2.17k|          if (!url.parse_host(host_view)) {
  ------------------
  |  Branch (13168:15): [True: 232, False: 1.94k]
  ------------------
13169|    232|            return url;
13170|    232|          }
13171|  1.94k|          ada_log("HOST parsing results in ", url.get_hostname());
13172|       |          // Set url's host to host, buffer to the empty string, and state to
13173|       |          // port state.
13174|  1.94k|          state = state::PORT;
13175|  1.94k|          input_position++;
13176|  1.94k|        }
13177|       |        // Otherwise, if one of the following is true:
13178|       |        // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
13179|       |        // - url is special and c is U+005C (\)
13180|       |        // The get_host_delimiter_location function either brings us to
13181|       |        // the colon outside of the bracket, or to one of those characters.
13182|  11.0k|        else {
13183|       |          // If url is special and host_view is the empty string, validation
13184|       |          // error, return failure.
13185|  11.0k|          if (host_view.empty() && url.is_special()) {
  ------------------
  |  Branch (13185:15): [True: 226, False: 10.8k]
  |  Branch (13185:36): [True: 90, False: 136]
  ------------------
13186|     90|            url.is_valid = false;
13187|     90|            return url;
13188|     90|          }
13189|  10.9k|          ada_log("HOST parsing ", host_view, " href=", url.get_href());
13190|       |          // Let host be the result of host parsing host_view with url is not
13191|       |          // special.
13192|  10.9k|          if (host_view.empty()) {
  ------------------
  |  Branch (13192:15): [True: 136, False: 10.8k]
  ------------------
13193|    136|            url.update_base_hostname("");
13194|  10.8k|          } else if (!url.parse_host(host_view)) {
  ------------------
  |  Branch (13194:22): [True: 2.54k, False: 8.26k]
  ------------------
13195|  2.54k|            return url;
13196|  2.54k|          }
13197|  8.40k|          ada_log("HOST parsing results in ", url.get_hostname(),
13198|  8.40k|                  " href=", url.get_href());
13199|       |
13200|       |          // Set url's host to host, and state to path start state.
13201|  8.40k|          state = state::PATH_START;
13202|  8.40k|        }
13203|       |
13204|  10.3k|        break;
13205|  13.2k|      }
13206|  10.3k|      case state::OPAQUE_PATH: {
  ------------------
  |  Branch (13206:7): [True: 3.33k, False: 157k]
  ------------------
13207|  3.33k|        ada_log("OPAQUE_PATH ", helpers::substring(url_data, input_position));
13208|       |        // Opaque path, query, and fragment are structurally always valid:
13209|       |        // the parser would just percent-encode whatever is there. When we
13210|       |        // are not storing values (can_parse), we can return immediately.
13211|       |        // We must set has_opaque_path = true before returning so that when
13212|       |        // this URL is used as an internal base inside can_parse, NO_SCHEME
13213|       |        // correctly rejects relative inputs against an opaque-path base
13214|       |        // (e.g. can_parse("", &"W:") must return false).
13215|       |        if constexpr (!store_values) {
13216|       |          url.has_opaque_path = true;
13217|       |          return url;
13218|       |        }
13219|  3.33k|        std::string_view view = url_data.substr(input_position);
13220|       |        // If c is U+003F (?), then set url's query to the empty string and
13221|       |        // state to query state.
13222|  3.33k|        size_t location = view.find('?');
13223|  3.33k|        if (location != std::string_view::npos) {
  ------------------
  |  Branch (13223:13): [True: 255, False: 3.08k]
  ------------------
13224|    255|          view.remove_suffix(view.size() - location);
13225|    255|          state = state::QUERY;
13226|    255|          input_position += location + 1;
13227|  3.08k|        } else {
13228|  3.08k|          input_position = input_size + 1;
13229|  3.08k|        }
13230|  3.33k|        url.has_opaque_path = true;
13231|       |
13232|       |        // This is a really unlikely scenario in real world. We should not seek
13233|       |        // to optimize it.
13234|  3.33k|        if (view.ends_with(' ')) {
  ------------------
  |  Branch (13234:13): [True: 99, False: 3.24k]
  ------------------
13235|     99|          std::string modified_view =
13236|     99|              std::string(view.substr(0, view.size() - 1)) + "%20";
13237|     99|          url.update_base_pathname(unicode::percent_encode(
13238|     99|              modified_view, character_sets::C0_CONTROL_PERCENT_ENCODE));
13239|  3.24k|        } else {
13240|  3.24k|          url.update_base_pathname(unicode::percent_encode(
13241|  3.24k|              view, character_sets::C0_CONTROL_PERCENT_ENCODE));
13242|  3.24k|        }
13243|  3.33k|        break;
13244|  13.2k|      }
13245|  1.94k|      case state::PORT: {
  ------------------
  |  Branch (13245:7): [True: 1.94k, False: 159k]
  ------------------
13246|  1.94k|        ada_log("PORT ", helpers::substring(url_data, input_position));
13247|  1.94k|        std::string_view port_view = url_data.substr(input_position);
13248|  1.94k|        input_position += url.parse_port(port_view, true);
13249|  1.94k|        if (!url.is_valid) {
  ------------------
  |  Branch (13249:13): [True: 109, False: 1.83k]
  ------------------
13250|    109|          return url;
13251|    109|        }
13252|  1.83k|        state = state::PATH_START;
13253|  1.83k|        [[fallthrough]];
13254|  1.83k|      }
13255|  12.1k|      case state::PATH_START: {
  ------------------
  |  Branch (13255:7): [True: 10.3k, False: 150k]
  ------------------
13256|  12.1k|        ada_log("PATH_START ", helpers::substring(url_data, input_position));
13257|       |        // Path, query, and fragment are structurally always valid: the
13258|       |        // parser would just percent-encode whatever is there. When we are
13259|       |        // not storing values (can_parse), we can return immediately since
13260|       |        // no subsequent state can invalidate the URL.
13261|       |        if constexpr (!store_values) {
13262|       |          return url;
13263|       |        }
13264|       |
13265|       |        // If url is special, then:
13266|  12.1k|        if (url.is_special()) {
  ------------------
  |  Branch (13266:13): [True: 11.4k, False: 720]
  ------------------
13267|       |          // Set state to path state.
13268|  11.4k|          state = state::PATH;
13269|       |
13270|       |          // Optimization: Avoiding going into PATH state improves the
13271|       |          // performance of urls ending with /.
13272|  11.4k|          if (input_position == input_size) {
  ------------------
  |  Branch (13272:15): [True: 6.04k, False: 5.39k]
  ------------------
13273|  6.04k|            if constexpr (store_values) {
13274|  6.04k|              url.update_base_pathname("/");
13275|  6.04k|              if (fragment.has_value()) {
  ------------------
  |  Branch (13275:19): [True: 119, False: 5.92k]
  ------------------
13276|    119|                url.update_unencoded_base_hash(*fragment);
13277|    119|              }
13278|  6.04k|            }
13279|  6.04k|            enforce_max_input_length();
13280|  6.04k|            return url;
13281|  6.04k|          }
13282|       |          // If c is neither U+002F (/) nor U+005C (\), then decrease pointer
13283|       |          // by 1. We know that (input_position == input_size) is impossible
13284|       |          // here, because of the previous if-check.
13285|  5.39k|          if ((url_data[input_position] != '/') &&
  ------------------
  |  Branch (13285:15): [True: 324, False: 5.07k]
  ------------------
13286|    324|              (url_data[input_position] != '\\')) {
  ------------------
  |  Branch (13286:15): [True: 309, False: 15]
  ------------------
13287|    309|            break;
13288|    309|          }
13289|  5.39k|        }
13290|       |        // Otherwise, if state override is not given and c is U+003F (?),
13291|       |        // set url's query to the empty string and state to query state.
13292|    720|        else if ((input_position != input_size) &&
  ------------------
  |  Branch (13292:18): [True: 185, False: 535]
  ------------------
13293|    185|                 (url_data[input_position] == '?')) {
  ------------------
  |  Branch (13293:18): [True: 63, False: 122]
  ------------------
13294|     63|          state = state::QUERY;
13295|     63|        }
13296|       |        // Otherwise, if c is not the EOF code point:
13297|    657|        else if (input_position != input_size) {
  ------------------
  |  Branch (13297:18): [True: 122, False: 535]
  ------------------
13298|       |          // Set state to path state.
13299|    122|          state = state::PATH;
13300|       |
13301|       |          // If c is not U+002F (/), then decrease pointer by 1.
13302|    122|          if (url_data[input_position] != '/') {
  ------------------
  |  Branch (13302:15): [True: 0, False: 122]
  ------------------
13303|      0|            break;
13304|      0|          }
13305|    122|        }
13306|       |
13307|  5.80k|        input_position++;
13308|  5.80k|        break;
13309|  12.1k|      }
13310|  8.04k|      case state::PATH: {
  ------------------
  |  Branch (13310:7): [True: 8.04k, False: 153k]
  ------------------
13311|  8.04k|        ada_log("PATH ", helpers::substring(url_data, input_position));
13312|       |        // Path, query, and fragment are structurally always valid: the
13313|       |        // parser would just percent-encode whatever is there. When we are
13314|       |        // not storing values (can_parse), we can return immediately since
13315|       |        // no subsequent state can invalidate the URL.
13316|       |        if constexpr (!store_values) {
13317|       |          return url;
13318|       |        }
13319|  8.04k|        std::string_view view = url_data.substr(input_position);
13320|       |
13321|       |        // Most time, we do not need percent encoding.
13322|       |        // Furthermore, we can immediately locate the '?'.
13323|  8.04k|        size_t locofquestionmark = view.find('?');
13324|  8.04k|        if (locofquestionmark != std::string_view::npos) {
  ------------------
  |  Branch (13324:13): [True: 662, False: 7.38k]
  ------------------
13325|    662|          state = state::QUERY;
13326|    662|          view.remove_suffix(view.size() - locofquestionmark);
13327|    662|          input_position += locofquestionmark + 1;
13328|  7.38k|        } else {
13329|  7.38k|          input_position = input_size + 1;
13330|  7.38k|        }
13331|  8.04k|        if constexpr (store_values) {
13332|       |          if constexpr (result_type_is_ada_url) {
13333|       |            helpers::parse_prepared_path(view, url.type, url.path);
13334|  8.04k|          } else {
13335|  8.04k|            url.consume_prepared_path(view);
13336|  8.04k|            ADA_ASSERT_TRUE(url.validate());
13337|  8.04k|          }
13338|  8.04k|        }
13339|  8.04k|        break;
13340|  12.1k|      }
13341|  2.25k|      case state::FILE_SLASH: {
  ------------------
  |  Branch (13341:7): [True: 2.25k, False: 158k]
  ------------------
13342|  2.25k|        ada_log("FILE_SLASH ", helpers::substring(url_data, input_position));
13343|       |
13344|       |        // If c is U+002F (/) or U+005C (\), then:
13345|  2.25k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13345:13): [True: 2.18k, False: 68]
  ------------------
13346|  2.18k|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13346:14): [True: 2.14k, False: 44]
  ------------------
13347|  2.15k|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13347:14): [True: 6, False: 38]
  ------------------
13348|  2.15k|          ada_log("FILE_SLASH c is U+002F or U+005C");
13349|       |          // Set state to file host state.
13350|  2.15k|          state = state::FILE_HOST;
13351|  2.15k|          input_position++;
13352|  2.15k|        } else {
13353|    106|          ada_log("FILE_SLASH otherwise");
13354|       |          // If base is non-null and base's scheme is "file", then:
13355|       |          // Note: it is unsafe to do base_url->scheme unless you know that
13356|       |          // base_url_has_value() is true.
13357|    106|          if (base_url != nullptr && base_url->type == scheme::type::FILE) {
  ------------------
  |  Branch (13357:15): [True: 84, False: 22]
  |  Branch (13357:38): [True: 82, False: 2]
  ------------------
13358|       |            // Set url's host to base's host.
13359|       |            if constexpr (result_type_is_ada_url) {
13360|       |              url.host = base_url->host;
13361|     82|            } else {
13362|     82|              url.update_host_to_base_host(base_url->get_host());
13363|     82|            }
13364|       |            // If the code point substring from pointer to the end of input does
13365|       |            // not start with a Windows drive letter and base's path[0] is a
13366|       |            // normalized Windows drive letter, then append base's path[0] to
13367|       |            // url's path.
13368|     82|            if (!base_url->get_pathname().empty()) {
  ------------------
  |  Branch (13368:17): [True: 82, False: 0]
  ------------------
13369|     82|              if (!checkers::is_windows_drive_letter(
  ------------------
  |  Branch (13369:19): [True: 77, False: 5]
  ------------------
13370|     82|                      url_data.substr(input_position))) {
13371|     77|                std::string_view first_base_url_path =
13372|     77|                    base_url->get_pathname().substr(1);
13373|     77|                size_t loc = first_base_url_path.find('/');
13374|     77|                if (loc != std::string_view::npos) {
  ------------------
  |  Branch (13374:21): [True: 13, False: 64]
  ------------------
13375|     13|                  helpers::resize(first_base_url_path, loc);
13376|     13|                }
13377|     77|                if (checkers::is_normalized_windows_drive_letter(
  ------------------
  |  Branch (13377:21): [True: 3, False: 74]
  ------------------
13378|     77|                        first_base_url_path)) {
13379|       |                  if constexpr (result_type_is_ada_url) {
13380|       |                    url.path += '/';
13381|       |                    url.path += first_base_url_path;
13382|      3|                  } else {
13383|      3|                    url.append_base_pathname(
13384|      3|                        helpers::concat("/", first_base_url_path));
13385|      3|                  }
13386|      3|                }
13387|     77|              }
13388|     82|            }
13389|     82|          }
13390|       |
13391|       |          // Set state to path state, and decrease pointer by 1.
13392|    106|          state = state::PATH;
13393|    106|        }
13394|       |
13395|  2.25k|        break;
13396|  12.1k|      }
13397|  2.15k|      case state::FILE_HOST: {
  ------------------
  |  Branch (13397:7): [True: 2.15k, False: 158k]
  ------------------
13398|  2.15k|        ada_log("FILE_HOST ", helpers::substring(url_data, input_position));
13399|  2.15k|        std::string_view view = url_data.substr(input_position);
13400|       |
13401|  2.15k|        size_t location = view.find_first_of("/\\?");
13402|  2.15k|        std::string_view file_host_buffer = view.substr(
13403|  2.15k|            0, (location != std::string_view::npos) ? location : view.size());
  ------------------
  |  Branch (13403:16): [True: 927, False: 1.22k]
  ------------------
13404|       |
13405|  2.15k|        if (checkers::is_windows_drive_letter(file_host_buffer)) {
  ------------------
  |  Branch (13405:13): [True: 12, False: 2.13k]
  ------------------
13406|     12|          state = state::PATH;
13407|  2.13k|        } else if (file_host_buffer.empty()) {
  ------------------
  |  Branch (13407:20): [True: 284, False: 1.85k]
  ------------------
13408|       |          // Set url's host to the empty string.
13409|       |          if constexpr (result_type_is_ada_url) {
13410|       |            url.host = "";
13411|    284|          } else {
13412|    284|            url.update_base_hostname("");
13413|    284|          }
13414|       |          // Set state to path start state.
13415|    284|          state = state::PATH_START;
13416|  1.85k|        } else {
13417|  1.85k|          size_t consumed_bytes = file_host_buffer.size();
13418|  1.85k|          input_position += consumed_bytes;
13419|       |          // Let host be the result of host parsing buffer with url is not
13420|       |          // special.
13421|  1.85k|          if (!url.parse_host(file_host_buffer)) {
  ------------------
  |  Branch (13421:15): [True: 216, False: 1.63k]
  ------------------
13422|    216|            return url;
13423|    216|          }
13424|       |
13425|       |          if constexpr (result_type_is_ada_url) {
13426|       |            // If host is "localhost", then set host to the empty string.
13427|       |            if (url.host.has_value() && url.host.value() == "localhost") {
13428|       |              url.host = "";
13429|       |            }
13430|  1.63k|          } else {
13431|  1.63k|            if (url.get_hostname() == "localhost") {
  ------------------
  |  Branch (13431:17): [True: 9, False: 1.62k]
  ------------------
13432|      9|              url.update_base_hostname("");
13433|      9|            }
13434|  1.63k|          }
13435|       |
13436|       |          // Set buffer to the empty string and state to path start state.
13437|  1.63k|          state = state::PATH_START;
13438|  1.63k|        }
13439|       |
13440|  1.93k|        break;
13441|  2.15k|      }
13442|  2.97k|      case state::FILE: {
  ------------------
  |  Branch (13442:7): [True: 2.97k, False: 158k]
  ------------------
13443|  2.97k|        ada_log("FILE ", helpers::substring(url_data, input_position));
13444|  2.97k|        std::string_view file_view = url_data.substr(input_position);
13445|       |
13446|  2.97k|        url.set_protocol_as_file();
13447|       |        if constexpr (result_type_is_ada_url) {
13448|       |          // Set url's host to the empty string.
13449|       |          url.host = "";
13450|  2.97k|        } else {
13451|  2.97k|          url.update_base_hostname("");
13452|  2.97k|        }
13453|       |        // If c is U+002F (/) or U+005C (\), then:
13454|  2.97k|        if (input_position != input_size &&
  ------------------
  |  Branch (13454:13): [True: 2.84k, False: 133]
  ------------------
13455|  2.84k|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13455:14): [True: 2.25k, False: 592]
  ------------------
13456|  2.25k|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13456:14): [True: 6, False: 586]
  ------------------
13457|  2.25k|          ada_log("FILE c is U+002F or U+005C");
13458|       |          // Set state to file slash state.
13459|  2.25k|          state = state::FILE_SLASH;
13460|  2.25k|        }
13461|       |        // Otherwise, if base is non-null and base's scheme is "file":
13462|    719|        else if (base_url != nullptr && base_url->type == scheme::type::FILE) {
  ------------------
  |  Branch (13462:18): [True: 272, False: 447]
  |  Branch (13462:41): [True: 199, False: 73]
  ------------------
13463|       |          // Set url's host to base's host, url's path to a clone of base's
13464|       |          // path, and url's query to base's query.
13465|    199|          ada_log("FILE base non-null");
13466|       |          if constexpr (result_type_is_ada_url) {
13467|       |            url.host = base_url->host;
13468|       |            url.path = base_url->path;
13469|       |            url.query = base_url->query;
13470|    199|          } else {
13471|    199|            url.update_host_to_base_host(base_url->get_hostname());
13472|    199|            url.update_base_pathname(base_url->get_pathname());
13473|    199|            if (base_url->has_search()) {
  ------------------
  |  Branch (13473:17): [True: 59, False: 140]
  ------------------
13474|       |              // get_search() returns "" for an empty query string (URL ends
13475|       |              // with '?'). update_base_search("") would incorrectly clear the
13476|       |              // query, so pass "?" to preserve the empty query distinction.
13477|     59|              auto s = base_url->get_search();
13478|     59|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (13478:38): [True: 25, False: 34]
  ------------------
13479|     59|            }
13480|    199|          }
13481|    199|          url.has_opaque_path = base_url->has_opaque_path;
13482|       |
13483|       |          // If c is U+003F (?), then set url's query to the empty string and
13484|       |          // state to query state.
13485|    199|          if (input_position != input_size && url_data[input_position] == '?') {
  ------------------
  |  Branch (13485:15): [True: 138, False: 61]
  |  Branch (13485:47): [True: 3, False: 135]
  ------------------
13486|      3|            state = state::QUERY;
13487|      3|          }
13488|       |          // Otherwise, if c is not the EOF code point:
13489|    196|          else if (input_position != input_size) {
  ------------------
  |  Branch (13489:20): [True: 135, False: 61]
  ------------------
13490|       |            // Set url's query to null.
13491|    135|            url.clear_search();
13492|       |            // If the code point substring from pointer to the end of input does
13493|       |            // not start with a Windows drive letter, then shorten url's path.
13494|    135|            if (!checkers::is_windows_drive_letter(file_view)) {
  ------------------
  |  Branch (13494:17): [True: 113, False: 22]
  ------------------
13495|       |              if constexpr (result_type_is_ada_url) {
13496|       |                helpers::shorten_path(url.path, url.type);
13497|    113|              } else {
13498|    113|                std::string_view path = url.get_pathname();
13499|    113|                if (helpers::shorten_path(path, url.type)) {
  ------------------
  |  Branch (13499:21): [True: 106, False: 7]
  ------------------
13500|    106|                  url.update_base_pathname(std::move(std::string(path)));
13501|    106|                }
13502|    113|              }
13503|    113|            }
13504|       |            // Otherwise:
13505|     22|            else {
13506|       |              // Set url's path to an empty list.
13507|     22|              url.clear_pathname();
13508|     22|              url.has_opaque_path = true;
13509|     22|            }
13510|       |
13511|       |            // Set state to path state and decrease pointer by 1.
13512|    135|            state = state::PATH;
13513|    135|            break;
13514|    135|          }
13515|    199|        }
13516|       |        // Otherwise, set state to path state, and decrease pointer by 1.
13517|    520|        else {
13518|    520|          ada_log("FILE go to path");
13519|    520|          state = state::PATH;
13520|    520|          break;
13521|    520|        }
13522|       |
13523|  2.32k|        input_position++;
13524|  2.32k|        break;
13525|  2.97k|      }
13526|      0|      default:
  ------------------
  |  Branch (13526:7): [True: 0, False: 161k]
  ------------------
13527|      0|        unreachable();
13528|   161k|    }
13529|   161k|  }
13530|  15.6k|  if constexpr (store_values) {
13531|  15.6k|    if (fragment.has_value()) {
  ------------------
  |  Branch (13531:9): [True: 373, False: 15.2k]
  ------------------
13532|    373|      url.update_unencoded_base_hash(*fragment);
13533|    373|    }
13534|  15.6k|  }
13535|  15.6k|  enforce_max_input_length();
13536|  15.6k|  return url;
13537|  47.3k|}
_ZN3ada6parser14parse_url_implINS_14url_aggregatorELb0EEET_NSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEPKS3_:
12517|  29.8k|                           const result_type* base_url) {
12518|       |  // We can specialize the implementation per type.
12519|       |  // Important: result_type_is_ada_url is evaluated at *compile time*. This
12520|       |  // means that doing if constexpr(result_type_is_ada_url) { something } else {
12521|       |  // something else } is free (at runtime). This means that ada::url_aggregator
12522|       |  // and ada::url **do not have to support the exact same API**.
12523|  29.8k|  constexpr bool result_type_is_ada_url = std::is_same_v<url, result_type>;
12524|  29.8k|  constexpr bool result_type_is_ada_url_aggregator =
12525|  29.8k|      std::is_same_v<url_aggregator, result_type>;
12526|  29.8k|  static_assert(result_type_is_ada_url ||
12527|  29.8k|                result_type_is_ada_url_aggregator);  // We don't support
12528|       |                                                     // anything else for now.
12529|       |
12530|  29.8k|  ada_log("ada::parser::parse_url('", user_input, "' [", user_input.size(),
12531|  29.8k|          " bytes],", (base_url != nullptr ? base_url->to_string() : "null"),
12532|  29.8k|          ")");
12533|       |
12534|  29.8k|  result_type url{};
12535|       |
12536|  29.8k|  const uint32_t max_input_length = ada::get_max_input_length();
12537|       |
12538|       |  // Normalization (percent-encoding, IDNA) can push the serialized URL past
12539|       |  // max_input_length even when the input fit under it. The check at the end of
12540|       |  // the state machine covers URLs that run to completion, but several states
12541|       |  // return early after appending a query or fragment, so run the same check on
12542|       |  // those exits too. Without this, a query- or fragment-terminated URL such as
12543|       |  // file://x/?<...> or https://user@x/?<...> is accepted while the equivalent
12544|       |  // https://x/?<...> that takes the absolute fast path is rejected.
12545|  29.8k|  const auto enforce_max_input_length = [&]() {
12546|  29.8k|    if constexpr (store_values) {
12547|  29.8k|      if (url.is_valid) {
12548|  29.8k|        if constexpr (result_type_is_ada_url_aggregator) {
12549|  29.8k|          if (url.buffer.size() > max_input_length) [[unlikely]] {
12550|  29.8k|            url.is_valid = false;
12551|  29.8k|          }
12552|  29.8k|        } else {
12553|  29.8k|          if (url.get_href_size() > max_input_length) [[unlikely]] {
12554|  29.8k|            url.is_valid = false;
12555|  29.8k|          }
12556|  29.8k|        }
12557|  29.8k|      }
12558|  29.8k|    }
12559|  29.8k|  };
12560|       |
12561|       |  // We refuse to parse URL strings that exceed the maximum input length.
12562|       |  // By default, this is 4GB but can be configured via
12563|       |  // ada::set_max_input_length().
12564|  29.8k|  if (user_input.size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (12564:7): [True: 0, False: 29.8k]
  ------------------
12565|      0|    url.is_valid = false;
12566|      0|  }
12567|       |  // Going forward, user_input.size() is in [0,
12568|       |  // std::numeric_limits<uint32_t>::max). If we are provided with an invalid
12569|       |  // base, or the optional_url was invalid, we must return.
12570|  29.8k|  if (base_url != nullptr) {
  ------------------
  |  Branch (12570:7): [True: 3.97k, False: 25.8k]
  ------------------
12571|  3.97k|    url.is_valid &= base_url->is_valid;
12572|  3.97k|  }
12573|  29.8k|  if (!url.is_valid) {
  ------------------
  |  Branch (12573:7): [True: 0, False: 29.8k]
  ------------------
12574|      0|    return url;
12575|      0|  }
12576|       |
12577|       |  // Simple absolute / relative fast paths (before tabs/newline scan).
12578|       |  if constexpr (store_values) {
12579|       |    bool hit_fast_path = false;
12580|       |    if (base_url == nullptr) {
12581|       |      // IPv4/IPv6 and userinfo miss the fast path. Skip the never_inline
12582|       |      // call so those URLs (including SetHref) do not pay for a miss.
12583|       |      const auto* p = reinterpret_cast<const uint8_t*>(user_input.data());
12584|       |      const size_t n = user_input.size();
12585|       |      size_t host_start = 0;
12586|       |      if (n >= 8 && p[4] == ':' && p[5] == '/' && p[6] == '/') {
12587|       |        host_start = 7;
12588|       |      } else if (n >= 9 && p[5] == ':' && p[6] == '/' && p[7] == '/') {
12589|       |        host_start = 8;
12590|       |      }
12591|       |      const uint8_t host_first = host_start != 0 ? p[host_start] : 0;
12592|       |      const bool skip_ip =
12593|       |          host_first == '[' || (host_first >= '0' && host_first <= '9');
12594|       |      const bool skip_userinfo =
12595|       |          host_start != 0 && authority_has_at(p, host_start, n);
12596|       |      hit_fast_path = !skip_ip && !skip_userinfo &&
12597|       |                      try_parse_simple_absolute(user_input, url);
12598|       |    } else {
12599|       |      hit_fast_path = try_parse_simple_relative(user_input, *base_url, url);
12600|       |    }
12601|       |    if (hit_fast_path) {
12602|       |      if constexpr (result_type_is_ada_url_aggregator) {
12603|       |        if (url.buffer.size() > max_input_length) [[unlikely]] {
12604|       |          url.is_valid = false;
12605|       |        }
12606|       |      } else {
12607|       |        // For a small absolute input, even worst-case normalization cannot
12608|       |        // exceed the limit: percent encoding expands at most 3x and IDNA at
12609|       |        // most 4.5x. Avoid traversing every stored component on the common
12610|       |        // default-limit path.
12611|       |        if ((base_url != nullptr ||
12612|       |             user_input.size() > static_cast<size_t>(max_input_length) / 5) &&
12613|       |            url.get_href_size() > max_input_length) [[unlikely]] {
12614|       |          url.is_valid = false;
12615|       |        }
12616|       |      }
12617|       |      return url;
12618|       |    }
12619|       |  }
12620|       |
12621|  29.8k|  state state = state::SCHEME_START;
12622|       |
12623|  29.8k|  std::string tmp_buffer;
12624|  29.8k|  std::string_view url_data;
12625|  29.8k|  if (unicode::has_tabs_or_newline(user_input)) [[unlikely]] {
  ------------------
  |  Branch (12625:7): [True: 182, False: 29.6k]
  ------------------
12626|    182|    tmp_buffer = user_input;
12627|       |    // Optimization opportunity: Instead of copying and then pruning, we could
12628|       |    // just directly build the string from user_input.
12629|    182|    helpers::remove_ascii_tab_or_newline(tmp_buffer);
12630|    182|    url_data = tmp_buffer;
12631|  29.6k|  } else [[likely]] {
12632|  29.6k|    url_data = user_input;
12633|  29.6k|  }
12634|       |
12635|       |  // Leading and trailing control characters are uncommon and easy to deal with
12636|       |  // (no performance concern).
12637|  29.8k|  helpers::trim_c0_whitespace(url_data);
12638|       |
12639|       |  if constexpr (result_type_is_ada_url_aggregator && store_values) {
12640|       |    // Most of the time, we just need user_input.size().
12641|       |    // In some instances, we may need a bit more.
12642|       |    ///////////////////////////
12643|       |    // This is *very* important. This line should *not* be removed
12644|       |    // hastily. There are principled reasons why reserve is important
12645|       |    // for performance. If you have a benchmark with small inputs,
12646|       |    // it may not matter, but in other instances, it could.
12647|       |    ////
12648|       |    // This rounds up to the next power of two.
12649|       |    // We know that user_input.size() is in [0,
12650|       |    // std::numeric_limits<uint32_t>::max).
12651|       |    uint32_t reserve_capacity =
12652|       |        (0xFFFFFFFF >>
12653|       |         helpers::leading_zeroes(uint32_t(1 | user_input.size()))) +
12654|       |        1;
12655|       |    url.reserve(reserve_capacity);
12656|       |  }
12657|       |
12658|       |  // Optimization opportunity. Most websites do not have fragment.
12659|  29.8k|  std::optional<std::string_view> fragment = helpers::prune_hash(url_data);
12660|       |  // We add it last so that an implementation like ada::url_aggregator
12661|       |  // can append it last to its internal buffer, thus improving performance.
12662|       |
12663|       |  // Here url_data no longer has its fragment.
12664|       |  // We are going to access the data from url_data (it is immutable).
12665|       |  // At any given time, we are pointing at byte 'input_position' in url_data.
12666|       |  // The input_position variable should range from 0 to input_size.
12667|       |  // It is illegal to access url_data at input_size.
12668|  29.8k|  size_t input_position = 0;
12669|  29.8k|  const size_t input_size = url_data.size();
12670|       |  // Keep running the following state machine by switching on state.
12671|       |  // If after a run pointer points to the EOF code point, go to the next step.
12672|       |  // Otherwise, increase pointer by 1 and continue with the state machine.
12673|       |  // We never decrement input_position.
12674|   127k|  while (input_position <= input_size) {
  ------------------
  |  Branch (12674:10): [True: 127k, False: 231]
  ------------------
12675|   127k|    ada_log("In parsing at ", input_position, " out of ", input_size,
12676|   127k|            " in state ", ada::to_string(state));
12677|   127k|    switch (state) {
12678|  29.8k|      case state::SCHEME_START: {
  ------------------
  |  Branch (12678:7): [True: 29.8k, False: 97.5k]
  ------------------
12679|  29.8k|        ada_log("SCHEME_START ", helpers::substring(url_data, input_position));
12680|       |        // If c is an ASCII alpha, append c, lowercased, to buffer, and set
12681|       |        // state to scheme state.
12682|  29.8k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (12682:13): [True: 21.7k, False: 8.08k]
  ------------------
12683|  21.7k|            checkers::is_alpha(url_data[input_position])) {
  ------------------
  |  Branch (12683:13): [True: 21.2k, False: 502]
  ------------------
12684|  21.2k|          state = state::SCHEME;
12685|  21.2k|          input_position++;
12686|  21.2k|        } else {
12687|       |          // Otherwise, if state override is not given, set state to no scheme
12688|       |          // state and decrease pointer by 1.
12689|  8.58k|          state = state::NO_SCHEME;
12690|  8.58k|        }
12691|  29.8k|        break;
12692|      0|      }
12693|  21.2k|      case state::SCHEME: {
  ------------------
  |  Branch (12693:7): [True: 21.2k, False: 106k]
  ------------------
12694|  21.2k|        ada_log("SCHEME ", helpers::substring(url_data, input_position));
12695|       |        // If c is an ASCII alphanumeric, U+002B (+), U+002D (-), or U+002E (.),
12696|       |        // append c, lowercased, to buffer.
12697|  50.9k|        while ((input_position != input_size) &&
  ------------------
  |  Branch (12697:16): [True: 50.6k, False: 309]
  ------------------
12698|  50.6k|               (unicode::is_alnum_plus(url_data[input_position]))) {
  ------------------
  |  Branch (12698:16): [True: 29.7k, False: 20.9k]
  ------------------
12699|  29.7k|          input_position++;
12700|  29.7k|        }
12701|       |        // Otherwise, if c is U+003A (:), then:
12702|  21.2k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (12702:13): [True: 20.9k, False: 309]
  ------------------
12703|  20.9k|            (url_data[input_position] == ':')) {
  ------------------
  |  Branch (12703:13): [True: 20.7k, False: 159]
  ------------------
12704|  20.7k|          ada_log("SCHEME the scheme should be ",
12705|  20.7k|                  url_data.substr(0, input_position));
12706|       |          if constexpr (result_type_is_ada_url) {
12707|       |            if (!url.parse_scheme(url_data.substr(0, input_position))) {
12708|       |              return url;
12709|       |            }
12710|  20.7k|          } else {
12711|       |            // we pass the colon along instead of painfully adding it back.
12712|  20.7k|            if (!url.parse_scheme_with_colon(
  ------------------
  |  Branch (12712:17): [True: 0, False: 20.7k]
  ------------------
12713|  20.7k|                    url_data.substr(0, input_position + 1))) {
12714|      0|              return url;
12715|      0|            }
12716|  20.7k|          }
12717|  20.7k|          ada_log("SCHEME the scheme is ", url.get_protocol());
12718|       |
12719|       |          // If url's scheme is "file", then:
12720|       |          // NOLINTNEXTLINE(bugprone-branch-clone)
12721|  20.7k|          if (url.type == scheme::type::FILE) {
  ------------------
  |  Branch (12721:15): [True: 2.71k, False: 18.0k]
  ------------------
12722|       |            // Set state to file state.
12723|  2.71k|            state = state::FILE;
12724|  2.71k|          }
12725|       |          // Otherwise, if url is special, base is non-null, and base's scheme
12726|       |          // is url's scheme: Note: Doing base_url->scheme is unsafe if base_url
12727|       |          // != nullptr is false.
12728|  18.0k|          else if (url.is_special() && base_url != nullptr &&
  ------------------
  |  Branch (12728:20): [True: 12.4k, False: 5.54k]
  |  Branch (12728:40): [True: 2.13k, False: 10.3k]
  ------------------
12729|  2.13k|                   base_url->type == url.type) {
  ------------------
  |  Branch (12729:20): [True: 270, False: 1.86k]
  ------------------
12730|       |            // Set state to special relative or authority state.
12731|    270|            state = state::SPECIAL_RELATIVE_OR_AUTHORITY;
12732|    270|          }
12733|       |          // Otherwise, if url is special, set state to special authority
12734|       |          // slashes state.
12735|  17.7k|          else if (url.is_special()) {
  ------------------
  |  Branch (12735:20): [True: 12.2k, False: 5.54k]
  ------------------
12736|  12.2k|            state = state::SPECIAL_AUTHORITY_SLASHES;
12737|  12.2k|          }
12738|       |          // Otherwise, if remaining starts with an U+002F (/), set state to
12739|       |          // path or authority state and increase pointer by 1.
12740|  5.54k|          else if (input_position + 1 < input_size &&
  ------------------
  |  Branch (12740:20): [True: 3.20k, False: 2.33k]
  ------------------
12741|  3.20k|                   url_data[input_position + 1] == '/') {
  ------------------
  |  Branch (12741:20): [True: 2.20k, False: 1.00k]
  ------------------
12742|  2.20k|            state = state::PATH_OR_AUTHORITY;
12743|  2.20k|            input_position++;
12744|  2.20k|          }
12745|       |          // Otherwise, set url's path to the empty string and set state to
12746|       |          // opaque path state.
12747|  3.33k|          else {
12748|  3.33k|            state = state::OPAQUE_PATH;
12749|  3.33k|          }
12750|  20.7k|        }
12751|       |        // Otherwise, if state override is not given, set buffer to the empty
12752|       |        // string, state to no scheme state, and start over (from the first code
12753|       |        // point in input).
12754|    468|        else {
12755|    468|          state = state::NO_SCHEME;
12756|    468|          input_position = 0;
12757|    468|          break;
12758|    468|        }
12759|  20.7k|        input_position++;
12760|  20.7k|        break;
12761|  21.2k|      }
12762|  9.05k|      case state::NO_SCHEME: {
  ------------------
  |  Branch (12762:7): [True: 9.05k, False: 118k]
  ------------------
12763|  9.05k|        ada_log("NO_SCHEME ", helpers::substring(url_data, input_position));
12764|       |        // The fragment was pruned from url_data before the state machine ran,
12765|       |        // so 'c is U+0023 (#)' holds exactly when a fragment was found and
12766|       |        // nothing else remains in front of it.
12767|  9.05k|        const bool c_is_hash =
12768|  9.05k|            fragment.has_value() && input_position == input_size;
  ------------------
  |  Branch (12768:13): [True: 155, False: 8.90k]
  |  Branch (12768:37): [True: 113, False: 42]
  ------------------
12769|       |        // If base is null, or base has an opaque path and c is not U+0023 (#),
12770|       |        // validation error, return failure.
12771|  9.05k|        if (base_url == nullptr || (base_url->has_opaque_path && !c_is_hash)) {
  ------------------
  |  Branch (12771:13): [True: 8.04k, False: 1.01k]
  |  Branch (12771:37): [True: 117, False: 893]
  |  Branch (12771:66): [True: 50, False: 67]
  ------------------
12772|  8.09k|          ada_log("NO_SCHEME validation error");
12773|  8.09k|          url.is_valid = false;
12774|  8.09k|          return url;
12775|  8.09k|        }
12776|       |        // Otherwise, if base has an opaque path and c is U+0023 (#),
12777|       |        // set url's scheme to base's scheme, url's path to base's path, url's
12778|       |        // query to base's query, and set state to fragment state.
12779|    960|        else if (base_url->has_opaque_path && c_is_hash) {
  ------------------
  |  Branch (12779:18): [True: 67, False: 893]
  |  Branch (12779:47): [True: 67, False: 0]
  ------------------
12780|     67|          ada_log("NO_SCHEME opaque base with fragment");
12781|     67|          url.copy_scheme(*base_url);
12782|     67|          url.has_opaque_path = base_url->has_opaque_path;
12783|       |
12784|       |          if constexpr (result_type_is_ada_url) {
12785|       |            url.path = base_url->path;
12786|       |            url.query = base_url->query;
12787|     67|          } else {
12788|     67|            url.update_base_pathname(base_url->get_pathname());
12789|     67|            if (base_url->has_search()) {
  ------------------
  |  Branch (12789:17): [True: 0, False: 67]
  ------------------
12790|       |              // get_search() returns "" for an empty query string (URL ends
12791|       |              // with '?'). update_base_search("") would incorrectly clear the
12792|       |              // query, so pass "?" to preserve the empty query distinction.
12793|      0|              auto s = base_url->get_search();
12794|      0|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (12794:38): [True: 0, False: 0]
  ------------------
12795|      0|            }
12796|     67|          }
12797|     67|          url.update_unencoded_base_hash(*fragment);
12798|     67|          enforce_max_input_length();
12799|     67|          return url;
12800|     67|        }
12801|       |        // Otherwise, if base's scheme is not "file", set state to relative
12802|       |        // state and decrease pointer by 1.
12803|       |        // NOLINTNEXTLINE(bugprone-branch-clone)
12804|    893|        else if (base_url->type != scheme::type::FILE) {
  ------------------
  |  Branch (12804:18): [True: 637, False: 256]
  ------------------
12805|    637|          ada_log("NO_SCHEME non-file relative path");
12806|    637|          state = state::RELATIVE_SCHEME;
12807|    637|        }
12808|       |        // Otherwise, set state to file state and decrease pointer by 1.
12809|    256|        else {
12810|    256|          ada_log("NO_SCHEME file base type");
12811|    256|          state = state::FILE;
12812|    256|        }
12813|    893|        break;
12814|  9.05k|      }
12815|  13.2k|      case state::AUTHORITY: {
  ------------------
  |  Branch (12815:7): [True: 13.2k, False: 114k]
  ------------------
12816|  13.2k|        ada_log("AUTHORITY ", helpers::substring(url_data, input_position));
12817|       |        // most URLs have no @. Having no @ tells us that we don't have to worry
12818|       |        // about AUTHORITY. Of course, we could have @ and still not have to
12819|       |        // worry about AUTHORITY.
12820|       |        // TODO: Instead of just collecting a bool, collect the location of the
12821|       |        // '@' and do something useful with it.
12822|       |        // TODO: We could do various processing early on, using a single pass
12823|       |        // over the string to collect information about it, e.g., telling us
12824|       |        // whether there is a @ and if so, where (or how many).
12825|       |
12826|       |        // Check if url data contains an @.
12827|  13.2k|        if (url_data.find('@', input_position) == std::string_view::npos) {
  ------------------
  |  Branch (12827:13): [True: 11.9k, False: 1.27k]
  ------------------
12828|  11.9k|          state = state::HOST;
12829|  11.9k|          break;
12830|  11.9k|        }
12831|  1.27k|        bool at_sign_seen{false};
12832|  1.27k|        bool password_token_seen{false};
12833|       |        /**
12834|       |         * We expect something of the sort...
12835|       |         * https://user:pass@example.com:1234/foo/bar?baz#quux
12836|       |         * --------^
12837|       |         */
12838|  8.86k|        do {
12839|  8.86k|          std::string_view view = url_data.substr(input_position);
12840|       |          // The delimiters are @, /, ? \\.
12841|  8.86k|          size_t location =
12842|  8.86k|              url.is_special() ? helpers::find_authority_delimiter_special(view)
  ------------------
  |  Branch (12842:15): [True: 8.33k, False: 531]
  ------------------
12843|  8.86k|                               : helpers::find_authority_delimiter(view);
12844|  8.86k|          std::string_view authority_view = view.substr(0, location);
12845|  8.86k|          size_t end_of_authority = input_position + authority_view.size();
12846|       |          // If c is U+0040 (@), then:
12847|  8.86k|          if ((end_of_authority != input_size) &&
  ------------------
  |  Branch (12847:15): [True: 8.06k, False: 798]
  ------------------
12848|  8.06k|              (url_data[end_of_authority] == '@')) {
  ------------------
  |  Branch (12848:15): [True: 7.59k, False: 473]
  ------------------
12849|       |            // If atSignSeen is true, then prepend "%40" to buffer.
12850|  7.59k|            if (at_sign_seen) {
  ------------------
  |  Branch (12850:17): [True: 6.46k, False: 1.12k]
  ------------------
12851|  6.46k|              if (password_token_seen) {
  ------------------
  |  Branch (12851:19): [True: 2.33k, False: 4.13k]
  ------------------
12852|       |                if constexpr (result_type_is_ada_url) {
12853|       |                  url.password += "%40";
12854|  2.33k|                } else {
12855|  2.33k|                  url.append_base_password("%40");
12856|  2.33k|                }
12857|  4.13k|              } else {
12858|       |                if constexpr (result_type_is_ada_url) {
12859|       |                  url.username += "%40";
12860|  4.13k|                } else {
12861|  4.13k|                  url.append_base_username("%40");
12862|  4.13k|                }
12863|  4.13k|              }
12864|  6.46k|            }
12865|       |
12866|  7.59k|            at_sign_seen = true;
12867|       |
12868|  7.59k|            if (!password_token_seen) {
  ------------------
  |  Branch (12868:17): [True: 5.25k, False: 2.33k]
  ------------------
12869|  5.25k|              size_t password_token_location = authority_view.find(':');
12870|  5.25k|              password_token_seen =
12871|  5.25k|                  password_token_location != std::string_view::npos;
12872|       |
12873|       |              if constexpr (store_values) {
12874|       |                if (!password_token_seen) {
12875|       |                  if constexpr (result_type_is_ada_url) {
12876|       |                    url.username += unicode::percent_encode(
12877|       |                        authority_view,
12878|       |                        character_sets::USERINFO_PERCENT_ENCODE);
12879|       |                  } else {
12880|       |                    url.append_base_username(unicode::percent_encode(
12881|       |                        authority_view,
12882|       |                        character_sets::USERINFO_PERCENT_ENCODE));
12883|       |                  }
12884|       |                } else {
12885|       |                  if constexpr (result_type_is_ada_url) {
12886|       |                    url.username += unicode::percent_encode(
12887|       |                        authority_view.substr(0, password_token_location),
12888|       |                        character_sets::USERINFO_PERCENT_ENCODE);
12889|       |                    url.password += unicode::percent_encode(
12890|       |                        authority_view.substr(password_token_location + 1),
12891|       |                        character_sets::USERINFO_PERCENT_ENCODE);
12892|       |                  } else {
12893|       |                    url.append_base_username(unicode::percent_encode(
12894|       |                        authority_view.substr(0, password_token_location),
12895|       |                        character_sets::USERINFO_PERCENT_ENCODE));
12896|       |                    url.append_base_password(unicode::percent_encode(
12897|       |                        authority_view.substr(password_token_location + 1),
12898|       |                        character_sets::USERINFO_PERCENT_ENCODE));
12899|       |                  }
12900|       |                }
12901|       |              }
12902|  5.25k|            } else if constexpr (store_values) {
12903|  2.33k|              if constexpr (result_type_is_ada_url) {
12904|  2.33k|                url.password += unicode::percent_encode(
12905|  2.33k|                    authority_view, character_sets::USERINFO_PERCENT_ENCODE);
12906|  2.33k|              } else {
12907|  2.33k|                url.append_base_password(unicode::percent_encode(
12908|  2.33k|                    authority_view, character_sets::USERINFO_PERCENT_ENCODE));
12909|  2.33k|              }
12910|  2.33k|            }
12911|  7.59k|          }
12912|       |          // Otherwise, if one of the following is true:
12913|       |          // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
12914|       |          // - url is special and c is U+005C (\)
12915|  1.27k|          else if (end_of_authority == input_size ||
  ------------------
  |  Branch (12915:20): [True: 798, False: 473]
  ------------------
12916|    473|                   url_data[end_of_authority] == '/' ||
  ------------------
  |  Branch (12916:20): [True: 435, False: 38]
  ------------------
12917|     38|                   url_data[end_of_authority] == '?' ||
  ------------------
  |  Branch (12917:20): [True: 31, False: 7]
  ------------------
12918|  1.27k|                   (url.is_special() && url_data[end_of_authority] == '\\')) {
  ------------------
  |  Branch (12918:21): [True: 7, False: 0]
  |  Branch (12918:41): [True: 7, False: 0]
  ------------------
12919|       |            // If atSignSeen is true and authority_view is the empty string,
12920|       |            // validation error, return failure.
12921|  1.27k|            if (at_sign_seen && authority_view.empty()) {
  ------------------
  |  Branch (12921:17): [True: 1.12k, False: 149]
  |  Branch (12921:33): [True: 337, False: 785]
  ------------------
12922|    337|              url.is_valid = false;
12923|    337|              return url;
12924|    337|            }
12925|    934|            state = state::HOST;
12926|    934|            break;
12927|  1.27k|          }
12928|  7.59k|          if (end_of_authority == input_size) {
  ------------------
  |  Branch (12928:15): [True: 0, False: 7.59k]
  ------------------
12929|       |            if constexpr (store_values) {
12930|       |              if (fragment.has_value()) {
12931|       |                url.update_unencoded_base_hash(*fragment);
12932|       |              }
12933|       |            }
12934|      0|            enforce_max_input_length();
12935|      0|            return url;
12936|      0|          }
12937|  7.59k|          input_position = end_of_authority + 1;
12938|  7.59k|        } while (true);
  ------------------
  |  Branch (12938:18): [True: 7.59k, Folded]
  ------------------
12939|       |
12940|    934|        break;
12941|  1.27k|      }
12942|    934|      case state::SPECIAL_RELATIVE_OR_AUTHORITY: {
  ------------------
  |  Branch (12942:7): [True: 270, False: 127k]
  ------------------
12943|    270|        ada_log("SPECIAL_RELATIVE_OR_AUTHORITY ",
12944|    270|                helpers::substring(url_data, input_position));
12945|       |
12946|       |        // If c is U+002F (/) and remaining starts with U+002F (/),
12947|       |        // then set state to special authority ignore slashes state and increase
12948|       |        // pointer by 1.
12949|    270|        if (url_data.substr(input_position, 2) == "//") {
  ------------------
  |  Branch (12949:13): [True: 192, False: 78]
  ------------------
12950|    192|          state = state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
12951|    192|          input_position += 2;
12952|    192|        } else {
12953|       |          // Otherwise, validation error, set state to relative state and
12954|       |          // decrease pointer by 1.
12955|     78|          state = state::RELATIVE_SCHEME;
12956|     78|        }
12957|       |
12958|    270|        break;
12959|  1.27k|      }
12960|  2.20k|      case state::PATH_OR_AUTHORITY: {
  ------------------
  |  Branch (12960:7): [True: 2.20k, False: 125k]
  ------------------
12961|  2.20k|        ada_log("PATH_OR_AUTHORITY ",
12962|  2.20k|                helpers::substring(url_data, input_position));
12963|       |
12964|       |        // If c is U+002F (/), then set state to authority state.
12965|  2.20k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (12965:13): [True: 2.08k, False: 115]
  ------------------
12966|  2.08k|            (url_data[input_position] == '/')) {
  ------------------
  |  Branch (12966:13): [True: 840, False: 1.24k]
  ------------------
12967|    840|          state = state::AUTHORITY;
12968|    840|          input_position++;
12969|  1.36k|        } else {
12970|       |          // Otherwise, set state to path state, and decrease pointer by 1.
12971|  1.36k|          state = state::PATH;
12972|  1.36k|        }
12973|       |
12974|  2.20k|        break;
12975|  1.27k|      }
12976|    715|      case state::RELATIVE_SCHEME: {
  ------------------
  |  Branch (12976:7): [True: 715, False: 126k]
  ------------------
12977|    715|        ada_log("RELATIVE_SCHEME ",
12978|    715|                helpers::substring(url_data, input_position));
12979|       |
12980|       |        // Set url's scheme to base's scheme.
12981|    715|        url.copy_scheme(*base_url);
12982|       |
12983|       |        // If c is U+002F (/), then set state to relative slash state.
12984|    715|        if ((input_position != input_size) &&
  ------------------
  |  Branch (12984:13): [True: 545, False: 170]
  ------------------
12985|       |            // NOLINTNEXTLINE(bugprone-branch-clone)
12986|    545|            (url_data[input_position] == '/')) {
  ------------------
  |  Branch (12986:13): [True: 65, False: 480]
  ------------------
12987|     65|          ada_log(
12988|     65|              "RELATIVE_SCHEME if c is U+002F (/), then set state to relative "
12989|     65|              "slash state");
12990|     65|          state = state::RELATIVE_SLASH;
12991|    650|        } else if (url.is_special() && (input_position != input_size) &&
  ------------------
  |  Branch (12991:20): [True: 505, False: 145]
  |  Branch (12991:40): [True: 377, False: 128]
  ------------------
12992|    377|                   (url_data[input_position] == '\\')) {
  ------------------
  |  Branch (12992:20): [True: 6, False: 371]
  ------------------
12993|       |          // Otherwise, if url is special and c is U+005C (\), validation error,
12994|       |          // set state to relative slash state.
12995|      6|          ada_log(
12996|      6|              "RELATIVE_SCHEME  if url is special and c is U+005C, validation "
12997|      6|              "error, set state to relative slash state");
12998|      6|          state = state::RELATIVE_SLASH;
12999|    644|        } else {
13000|    644|          ada_log("RELATIVE_SCHEME otherwise");
13001|       |          // Set url's username to base's username, url's password to base's
13002|       |          // password, url's host to base's host, url's port to base's port,
13003|       |          // url's path to a clone of base's path, and url's query to base's
13004|       |          // query.
13005|       |          if constexpr (result_type_is_ada_url) {
13006|       |            url.username = base_url->username;
13007|       |            url.password = base_url->password;
13008|       |            url.host = base_url->host;
13009|       |            url.port = base_url->port;
13010|       |            // cloning the base path includes cloning the has_opaque_path flag
13011|       |            url.has_opaque_path = base_url->has_opaque_path;
13012|       |            url.path = base_url->path;
13013|       |            url.query = base_url->query;
13014|    644|          } else {
13015|    644|            url.update_base_authority(base_url->get_href(),
13016|    644|                                      base_url->get_components());
13017|    644|            url.update_host_to_base_host(base_url->get_hostname());
13018|    644|            url.update_base_port(base_url->retrieve_base_port());
13019|       |            // cloning the base path includes cloning the has_opaque_path flag
13020|    644|            url.has_opaque_path = base_url->has_opaque_path;
13021|    644|            url.update_base_pathname(base_url->get_pathname());
13022|    644|            if (base_url->has_search()) {
  ------------------
  |  Branch (13022:17): [True: 0, False: 644]
  ------------------
13023|       |              // get_search() returns "" for an empty query string (URL ends
13024|       |              // with '?'). update_base_search("") would incorrectly clear the
13025|       |              // query, so pass "?" to preserve the empty query distinction.
13026|      0|              auto s = base_url->get_search();
13027|      0|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (13027:38): [True: 0, False: 0]
  ------------------
13028|      0|            }
13029|    644|          }
13030|       |
13031|    644|          url.has_opaque_path = base_url->has_opaque_path;
13032|       |
13033|       |          // If c is U+003F (?), then set url's query to the empty string, and
13034|       |          // state to query state.
13035|    644|          if ((input_position != input_size) &&
  ------------------
  |  Branch (13035:15): [True: 474, False: 170]
  ------------------
13036|    474|              (url_data[input_position] == '?')) {
  ------------------
  |  Branch (13036:15): [True: 34, False: 440]
  ------------------
13037|     34|            state = state::QUERY;
13038|     34|          }
13039|       |          // Otherwise, if c is not the EOF code point:
13040|    610|          else if (input_position != input_size) {
  ------------------
  |  Branch (13040:20): [True: 440, False: 170]
  ------------------
13041|       |            // Set url's query to null.
13042|    440|            url.clear_search();
13043|       |            if constexpr (result_type_is_ada_url) {
13044|       |              // Shorten url's path.
13045|       |              helpers::shorten_path(url.path, url.type);
13046|    440|            } else {
13047|    440|              std::string_view path = url.get_pathname();
13048|    440|              if (helpers::shorten_path(path, url.type)) {
  ------------------
  |  Branch (13048:19): [True: 0, False: 440]
  ------------------
13049|      0|                url.update_base_pathname(std::move(std::string(path)));
13050|      0|              }
13051|    440|            }
13052|       |            // Set state to path state and decrease pointer by 1.
13053|    440|            state = state::PATH;
13054|    440|            break;
13055|    440|          }
13056|    644|        }
13057|    275|        input_position++;
13058|    275|        break;
13059|    715|      }
13060|     71|      case state::RELATIVE_SLASH: {
  ------------------
  |  Branch (13060:7): [True: 71, False: 127k]
  ------------------
13061|     71|        ada_log("RELATIVE_SLASH ",
13062|     71|                helpers::substring(url_data, input_position));
13063|       |
13064|       |        // If url is special and c is U+002F (/) or U+005C (\), then:
13065|       |        // NOLINTNEXTLINE(bugprone-branch-clone)
13066|     71|        if (url.is_special() && (input_position != input_size) &&
  ------------------
  |  Branch (13066:13): [True: 62, False: 9]
  |  Branch (13066:33): [True: 38, False: 24]
  ------------------
13067|     38|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13067:14): [True: 4, False: 34]
  ------------------
13068|     34|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13068:14): [True: 2, False: 32]
  ------------------
13069|       |          // Set state to special authority ignore slashes state.
13070|      6|          state = state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
13071|      6|        }
13072|       |        // Otherwise, if c is U+002F (/), then set state to authority state.
13073|     65|        else if ((input_position != input_size) &&
  ------------------
  |  Branch (13073:18): [True: 36, False: 29]
  ------------------
13074|     36|                 (url_data[input_position] == '/')) {
  ------------------
  |  Branch (13074:18): [True: 2, False: 34]
  ------------------
13075|      2|          state = state::AUTHORITY;
13076|      2|        }
13077|       |        // Otherwise, set
13078|       |        // - url's username to base's username,
13079|       |        // - url's password to base's password,
13080|       |        // - url's host to base's host,
13081|       |        // - url's port to base's port,
13082|       |        // - state to path state, and then, decrease pointer by 1.
13083|     63|        else {
13084|       |          if constexpr (result_type_is_ada_url) {
13085|       |            url.username = base_url->username;
13086|       |            url.password = base_url->password;
13087|       |            url.host = base_url->host;
13088|       |            url.port = base_url->port;
13089|     63|          } else {
13090|     63|            url.update_base_authority(base_url->get_href(),
13091|     63|                                      base_url->get_components());
13092|     63|            url.update_host_to_base_host(base_url->get_hostname());
13093|     63|            url.update_base_port(base_url->retrieve_base_port());
13094|     63|          }
13095|     63|          state = state::PATH;
13096|     63|          break;
13097|     63|        }
13098|       |
13099|      8|        input_position++;
13100|      8|        break;
13101|     71|      }
13102|  12.2k|      case state::SPECIAL_AUTHORITY_SLASHES: {
  ------------------
  |  Branch (13102:7): [True: 12.2k, False: 115k]
  ------------------
13103|  12.2k|        ada_log("SPECIAL_AUTHORITY_SLASHES ",
13104|  12.2k|                helpers::substring(url_data, input_position));
13105|       |
13106|       |        // If c is U+002F (/) and remaining starts with U+002F (/),
13107|       |        // then set state to special authority ignore slashes state and increase
13108|       |        // pointer by 1.
13109|  12.2k|        if (url_data.substr(input_position, 2) == "//") {
  ------------------
  |  Branch (13109:13): [True: 2.91k, False: 9.30k]
  ------------------
13110|  2.91k|          input_position += 2;
13111|  2.91k|        }
13112|       |
13113|  12.2k|        [[fallthrough]];
13114|  12.2k|      }
13115|  12.4k|      case state::SPECIAL_AUTHORITY_IGNORE_SLASHES: {
  ------------------
  |  Branch (13115:7): [True: 198, False: 127k]
  ------------------
13116|  12.4k|        ada_log("SPECIAL_AUTHORITY_IGNORE_SLASHES ",
13117|  12.4k|                helpers::substring(url_data, input_position));
13118|       |
13119|       |        // If c is neither U+002F (/) nor U+005C (\), then set state to
13120|       |        // authority state and decrease pointer by 1.
13121|  12.9k|        while ((input_position != input_size) &&
  ------------------
  |  Branch (13121:16): [True: 12.9k, False: 57]
  ------------------
13122|  12.9k|               ((url_data[input_position] == '/') ||
  ------------------
  |  Branch (13122:17): [True: 366, False: 12.5k]
  ------------------
13123|  12.5k|                (url_data[input_position] == '\\'))) {
  ------------------
  |  Branch (13123:17): [True: 220, False: 12.3k]
  ------------------
13124|    586|          input_position++;
13125|    586|        }
13126|  12.4k|        state = state::AUTHORITY;
13127|       |
13128|  12.4k|        break;
13129|  12.2k|      }
13130|     37|      case state::QUERY: {
  ------------------
  |  Branch (13130:7): [True: 37, False: 127k]
  ------------------
13131|     37|        ada_log("QUERY ", helpers::substring(url_data, input_position));
13132|       |        if constexpr (store_values) {
13133|       |          // Let queryPercentEncodeSet be the special-query percent-encode set
13134|       |          // if url is special; otherwise the query percent-encode set.
13135|       |          const uint8_t* query_percent_encode_set =
13136|       |              url.is_special() ? character_sets::SPECIAL_QUERY_PERCENT_ENCODE
13137|       |                               : character_sets::QUERY_PERCENT_ENCODE;
13138|       |
13139|       |          // Percent-encode after encoding, with encoding, buffer, and
13140|       |          // queryPercentEncodeSet, and append the result to url's query.
13141|       |          url.update_base_search(url_data.substr(input_position),
13142|       |                                 query_percent_encode_set);
13143|       |          ada_log("QUERY update_base_search completed ");
13144|       |          if (fragment.has_value()) {
13145|       |            url.update_unencoded_base_hash(*fragment);
13146|       |          }
13147|       |        }
13148|     37|        enforce_max_input_length();
13149|     37|        return url;
13150|  12.2k|      }
13151|  12.9k|      case state::HOST: {
  ------------------
  |  Branch (13151:7): [True: 12.9k, False: 114k]
  ------------------
13152|  12.9k|        ada_log("HOST ", helpers::substring(url_data, input_position));
13153|       |
13154|  12.9k|        std::string_view host_view = url_data.substr(input_position);
13155|  12.9k|        auto [location, found_colon] =
13156|  12.9k|            helpers::get_host_delimiter_location(url.is_special(), host_view);
13157|  12.9k|        input_position = (location != std::string_view::npos)
  ------------------
  |  Branch (13157:26): [True: 12.9k, False: 0]
  ------------------
13158|  12.9k|                             ? input_position + location
13159|  12.9k|                             : input_size;
13160|       |        // Otherwise, if c is U+003A (:) and insideBrackets is false, then:
13161|       |        // Note: the 'found_colon' value is true if and only if a colon was
13162|       |        // encountered while not inside brackets.
13163|  12.9k|        if (found_colon) {
  ------------------
  |  Branch (13163:13): [True: 2.21k, False: 10.6k]
  ------------------
13164|       |          // If buffer is the empty string, validation error, return failure.
13165|       |          // Let host be the result of host parsing buffer with url is not
13166|       |          // special.
13167|  2.21k|          ada_log("HOST parsing ", host_view);
13168|  2.21k|          if (!url.parse_host(host_view)) {
  ------------------
  |  Branch (13168:15): [True: 223, False: 1.99k]
  ------------------
13169|    223|            return url;
13170|    223|          }
13171|  1.99k|          ada_log("HOST parsing results in ", url.get_hostname());
13172|       |          // Set url's host to host, buffer to the empty string, and state to
13173|       |          // port state.
13174|  1.99k|          state = state::PORT;
13175|  1.99k|          input_position++;
13176|  1.99k|        }
13177|       |        // Otherwise, if one of the following is true:
13178|       |        // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
13179|       |        // - url is special and c is U+005C (\)
13180|       |        // The get_host_delimiter_location function either brings us to
13181|       |        // the colon outside of the bracket, or to one of those characters.
13182|  10.6k|        else {
13183|       |          // If url is special and host_view is the empty string, validation
13184|       |          // error, return failure.
13185|  10.6k|          if (host_view.empty() && url.is_special()) {
  ------------------
  |  Branch (13185:15): [True: 195, False: 10.5k]
  |  Branch (13185:36): [True: 59, False: 136]
  ------------------
13186|     59|            url.is_valid = false;
13187|     59|            return url;
13188|     59|          }
13189|  10.6k|          ada_log("HOST parsing ", host_view, " href=", url.get_href());
13190|       |          // Let host be the result of host parsing host_view with url is not
13191|       |          // special.
13192|  10.6k|          if (host_view.empty()) {
  ------------------
  |  Branch (13192:15): [True: 136, False: 10.5k]
  ------------------
13193|    136|            url.update_base_hostname("");
13194|  10.5k|          } else if (!url.parse_host(host_view)) {
  ------------------
  |  Branch (13194:22): [True: 2.54k, False: 7.95k]
  ------------------
13195|  2.54k|            return url;
13196|  2.54k|          }
13197|  8.09k|          ada_log("HOST parsing results in ", url.get_hostname(),
13198|  8.09k|                  " href=", url.get_href());
13199|       |
13200|       |          // Set url's host to host, and state to path start state.
13201|  8.09k|          state = state::PATH_START;
13202|  8.09k|        }
13203|       |
13204|  10.0k|        break;
13205|  12.9k|      }
13206|  10.0k|      case state::OPAQUE_PATH: {
  ------------------
  |  Branch (13206:7): [True: 3.33k, False: 123k]
  ------------------
13207|  3.33k|        ada_log("OPAQUE_PATH ", helpers::substring(url_data, input_position));
13208|       |        // Opaque path, query, and fragment are structurally always valid:
13209|       |        // the parser would just percent-encode whatever is there. When we
13210|       |        // are not storing values (can_parse), we can return immediately.
13211|       |        // We must set has_opaque_path = true before returning so that when
13212|       |        // this URL is used as an internal base inside can_parse, NO_SCHEME
13213|       |        // correctly rejects relative inputs against an opaque-path base
13214|       |        // (e.g. can_parse("", &"W:") must return false).
13215|  3.33k|        if constexpr (!store_values) {
13216|  3.33k|          url.has_opaque_path = true;
13217|  3.33k|          return url;
13218|  3.33k|        }
13219|      0|        std::string_view view = url_data.substr(input_position);
13220|       |        // If c is U+003F (?), then set url's query to the empty string and
13221|       |        // state to query state.
13222|  3.33k|        size_t location = view.find('?');
13223|  3.33k|        if (location != std::string_view::npos) {
  ------------------
  |  Branch (13223:13): [True: 0, False: 3.33k]
  ------------------
13224|      0|          view.remove_suffix(view.size() - location);
13225|      0|          state = state::QUERY;
13226|      0|          input_position += location + 1;
13227|  3.33k|        } else {
13228|  3.33k|          input_position = input_size + 1;
13229|  3.33k|        }
13230|  3.33k|        url.has_opaque_path = true;
13231|       |
13232|       |        // This is a really unlikely scenario in real world. We should not seek
13233|       |        // to optimize it.
13234|  3.33k|        if (view.ends_with(' ')) {
  ------------------
  |  Branch (13234:13): [True: 0, False: 3.33k]
  ------------------
13235|      0|          std::string modified_view =
13236|      0|              std::string(view.substr(0, view.size() - 1)) + "%20";
13237|      0|          url.update_base_pathname(unicode::percent_encode(
13238|      0|              modified_view, character_sets::C0_CONTROL_PERCENT_ENCODE));
13239|  3.33k|        } else {
13240|  3.33k|          url.update_base_pathname(unicode::percent_encode(
13241|  3.33k|              view, character_sets::C0_CONTROL_PERCENT_ENCODE));
13242|  3.33k|        }
13243|  3.33k|        break;
13244|  12.9k|      }
13245|  1.99k|      case state::PORT: {
  ------------------
  |  Branch (13245:7): [True: 1.99k, False: 125k]
  ------------------
13246|  1.99k|        ada_log("PORT ", helpers::substring(url_data, input_position));
13247|  1.99k|        std::string_view port_view = url_data.substr(input_position);
13248|  1.99k|        input_position += url.parse_port(port_view, true);
13249|  1.99k|        if (!url.is_valid) {
  ------------------
  |  Branch (13249:13): [True: 89, False: 1.90k]
  ------------------
13250|     89|          return url;
13251|     89|        }
13252|  1.90k|        state = state::PATH_START;
13253|  1.90k|        [[fallthrough]];
13254|  1.90k|      }
13255|  11.9k|      case state::PATH_START: {
  ------------------
  |  Branch (13255:7): [True: 10.0k, False: 117k]
  ------------------
13256|  11.9k|        ada_log("PATH_START ", helpers::substring(url_data, input_position));
13257|       |        // Path, query, and fragment are structurally always valid: the
13258|       |        // parser would just percent-encode whatever is there. When we are
13259|       |        // not storing values (can_parse), we can return immediately since
13260|       |        // no subsequent state can invalidate the URL.
13261|  11.9k|        if constexpr (!store_values) {
13262|  11.9k|          return url;
13263|  11.9k|        }
13264|       |
13265|       |        // If url is special, then:
13266|  11.9k|        if (url.is_special()) {
  ------------------
  |  Branch (13266:13): [True: 0, False: 11.9k]
  ------------------
13267|       |          // Set state to path state.
13268|      0|          state = state::PATH;
13269|       |
13270|       |          // Optimization: Avoiding going into PATH state improves the
13271|       |          // performance of urls ending with /.
13272|      0|          if (input_position == input_size) {
  ------------------
  |  Branch (13272:15): [True: 0, False: 0]
  ------------------
13273|       |            if constexpr (store_values) {
13274|       |              url.update_base_pathname("/");
13275|       |              if (fragment.has_value()) {
13276|       |                url.update_unencoded_base_hash(*fragment);
13277|       |              }
13278|       |            }
13279|      0|            enforce_max_input_length();
13280|      0|            return url;
13281|      0|          }
13282|       |          // If c is neither U+002F (/) nor U+005C (\), then decrease pointer
13283|       |          // by 1. We know that (input_position == input_size) is impossible
13284|       |          // here, because of the previous if-check.
13285|      0|          if ((url_data[input_position] != '/') &&
  ------------------
  |  Branch (13285:15): [True: 0, False: 0]
  ------------------
13286|      0|              (url_data[input_position] != '\\')) {
  ------------------
  |  Branch (13286:15): [True: 0, False: 0]
  ------------------
13287|      0|            break;
13288|      0|          }
13289|      0|        }
13290|       |        // Otherwise, if state override is not given and c is U+003F (?),
13291|       |        // set url's query to the empty string and state to query state.
13292|  11.9k|        else if ((input_position != input_size) &&
  ------------------
  |  Branch (13292:18): [True: 0, False: 11.9k]
  ------------------
13293|      0|                 (url_data[input_position] == '?')) {
  ------------------
  |  Branch (13293:18): [True: 0, False: 0]
  ------------------
13294|      0|          state = state::QUERY;
13295|      0|        }
13296|       |        // Otherwise, if c is not the EOF code point:
13297|  11.9k|        else if (input_position != input_size) {
  ------------------
  |  Branch (13297:18): [True: 0, False: 11.9k]
  ------------------
13298|       |          // Set state to path state.
13299|      0|          state = state::PATH;
13300|       |
13301|       |          // If c is not U+002F (/), then decrease pointer by 1.
13302|      0|          if (url_data[input_position] != '/') {
  ------------------
  |  Branch (13302:15): [True: 0, False: 0]
  ------------------
13303|      0|            break;
13304|      0|          }
13305|      0|        }
13306|       |
13307|  11.9k|        input_position++;
13308|  11.9k|        break;
13309|  11.9k|      }
13310|  2.63k|      case state::PATH: {
  ------------------
  |  Branch (13310:7): [True: 2.63k, False: 124k]
  ------------------
13311|  2.63k|        ada_log("PATH ", helpers::substring(url_data, input_position));
13312|       |        // Path, query, and fragment are structurally always valid: the
13313|       |        // parser would just percent-encode whatever is there. When we are
13314|       |        // not storing values (can_parse), we can return immediately since
13315|       |        // no subsequent state can invalidate the URL.
13316|  2.63k|        if constexpr (!store_values) {
13317|  2.63k|          return url;
13318|  2.63k|        }
13319|      0|        std::string_view view = url_data.substr(input_position);
13320|       |
13321|       |        // Most time, we do not need percent encoding.
13322|       |        // Furthermore, we can immediately locate the '?'.
13323|  2.63k|        size_t locofquestionmark = view.find('?');
13324|  2.63k|        if (locofquestionmark != std::string_view::npos) {
  ------------------
  |  Branch (13324:13): [True: 0, False: 2.63k]
  ------------------
13325|      0|          state = state::QUERY;
13326|      0|          view.remove_suffix(view.size() - locofquestionmark);
13327|      0|          input_position += locofquestionmark + 1;
13328|  2.63k|        } else {
13329|  2.63k|          input_position = input_size + 1;
13330|  2.63k|        }
13331|       |        if constexpr (store_values) {
13332|       |          if constexpr (result_type_is_ada_url) {
13333|       |            helpers::parse_prepared_path(view, url.type, url.path);
13334|       |          } else {
13335|       |            url.consume_prepared_path(view);
13336|       |            ADA_ASSERT_TRUE(url.validate());
13337|       |          }
13338|       |        }
13339|  2.63k|        break;
13340|  11.9k|      }
13341|  2.25k|      case state::FILE_SLASH: {
  ------------------
  |  Branch (13341:7): [True: 2.25k, False: 125k]
  ------------------
13342|  2.25k|        ada_log("FILE_SLASH ", helpers::substring(url_data, input_position));
13343|       |
13344|       |        // If c is U+002F (/) or U+005C (\), then:
13345|  2.25k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13345:13): [True: 2.18k, False: 68]
  ------------------
13346|  2.18k|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13346:14): [True: 2.14k, False: 44]
  ------------------
13347|  2.15k|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13347:14): [True: 6, False: 38]
  ------------------
13348|  2.15k|          ada_log("FILE_SLASH c is U+002F or U+005C");
13349|       |          // Set state to file host state.
13350|  2.15k|          state = state::FILE_HOST;
13351|  2.15k|          input_position++;
13352|  2.15k|        } else {
13353|    106|          ada_log("FILE_SLASH otherwise");
13354|       |          // If base is non-null and base's scheme is "file", then:
13355|       |          // Note: it is unsafe to do base_url->scheme unless you know that
13356|       |          // base_url_has_value() is true.
13357|    106|          if (base_url != nullptr && base_url->type == scheme::type::FILE) {
  ------------------
  |  Branch (13357:15): [True: 84, False: 22]
  |  Branch (13357:38): [True: 82, False: 2]
  ------------------
13358|       |            // Set url's host to base's host.
13359|       |            if constexpr (result_type_is_ada_url) {
13360|       |              url.host = base_url->host;
13361|     82|            } else {
13362|     82|              url.update_host_to_base_host(base_url->get_host());
13363|     82|            }
13364|       |            // If the code point substring from pointer to the end of input does
13365|       |            // not start with a Windows drive letter and base's path[0] is a
13366|       |            // normalized Windows drive letter, then append base's path[0] to
13367|       |            // url's path.
13368|     82|            if (!base_url->get_pathname().empty()) {
  ------------------
  |  Branch (13368:17): [True: 0, False: 82]
  ------------------
13369|      0|              if (!checkers::is_windows_drive_letter(
  ------------------
  |  Branch (13369:19): [True: 0, False: 0]
  ------------------
13370|      0|                      url_data.substr(input_position))) {
13371|      0|                std::string_view first_base_url_path =
13372|      0|                    base_url->get_pathname().substr(1);
13373|      0|                size_t loc = first_base_url_path.find('/');
13374|      0|                if (loc != std::string_view::npos) {
  ------------------
  |  Branch (13374:21): [True: 0, False: 0]
  ------------------
13375|      0|                  helpers::resize(first_base_url_path, loc);
13376|      0|                }
13377|      0|                if (checkers::is_normalized_windows_drive_letter(
  ------------------
  |  Branch (13377:21): [True: 0, False: 0]
  ------------------
13378|      0|                        first_base_url_path)) {
13379|       |                  if constexpr (result_type_is_ada_url) {
13380|       |                    url.path += '/';
13381|       |                    url.path += first_base_url_path;
13382|      0|                  } else {
13383|      0|                    url.append_base_pathname(
13384|      0|                        helpers::concat("/", first_base_url_path));
13385|      0|                  }
13386|      0|                }
13387|      0|              }
13388|      0|            }
13389|     82|          }
13390|       |
13391|       |          // Set state to path state, and decrease pointer by 1.
13392|    106|          state = state::PATH;
13393|    106|        }
13394|       |
13395|  2.25k|        break;
13396|  11.9k|      }
13397|  2.15k|      case state::FILE_HOST: {
  ------------------
  |  Branch (13397:7): [True: 2.15k, False: 125k]
  ------------------
13398|  2.15k|        ada_log("FILE_HOST ", helpers::substring(url_data, input_position));
13399|  2.15k|        std::string_view view = url_data.substr(input_position);
13400|       |
13401|  2.15k|        size_t location = view.find_first_of("/\\?");
13402|  2.15k|        std::string_view file_host_buffer = view.substr(
13403|  2.15k|            0, (location != std::string_view::npos) ? location : view.size());
  ------------------
  |  Branch (13403:16): [True: 927, False: 1.22k]
  ------------------
13404|       |
13405|  2.15k|        if (checkers::is_windows_drive_letter(file_host_buffer)) {
  ------------------
  |  Branch (13405:13): [True: 12, False: 2.13k]
  ------------------
13406|     12|          state = state::PATH;
13407|  2.13k|        } else if (file_host_buffer.empty()) {
  ------------------
  |  Branch (13407:20): [True: 284, False: 1.85k]
  ------------------
13408|       |          // Set url's host to the empty string.
13409|       |          if constexpr (result_type_is_ada_url) {
13410|       |            url.host = "";
13411|    284|          } else {
13412|    284|            url.update_base_hostname("");
13413|    284|          }
13414|       |          // Set state to path start state.
13415|    284|          state = state::PATH_START;
13416|  1.85k|        } else {
13417|  1.85k|          size_t consumed_bytes = file_host_buffer.size();
13418|  1.85k|          input_position += consumed_bytes;
13419|       |          // Let host be the result of host parsing buffer with url is not
13420|       |          // special.
13421|  1.85k|          if (!url.parse_host(file_host_buffer)) {
  ------------------
  |  Branch (13421:15): [True: 216, False: 1.63k]
  ------------------
13422|    216|            return url;
13423|    216|          }
13424|       |
13425|       |          if constexpr (result_type_is_ada_url) {
13426|       |            // If host is "localhost", then set host to the empty string.
13427|       |            if (url.host.has_value() && url.host.value() == "localhost") {
13428|       |              url.host = "";
13429|       |            }
13430|  1.63k|          } else {
13431|  1.63k|            if (url.get_hostname() == "localhost") {
  ------------------
  |  Branch (13431:17): [True: 9, False: 1.62k]
  ------------------
13432|      9|              url.update_base_hostname("");
13433|      9|            }
13434|  1.63k|          }
13435|       |
13436|       |          // Set buffer to the empty string and state to path start state.
13437|  1.63k|          state = state::PATH_START;
13438|  1.63k|        }
13439|       |
13440|  1.93k|        break;
13441|  2.15k|      }
13442|  2.97k|      case state::FILE: {
  ------------------
  |  Branch (13442:7): [True: 2.97k, False: 124k]
  ------------------
13443|  2.97k|        ada_log("FILE ", helpers::substring(url_data, input_position));
13444|  2.97k|        std::string_view file_view = url_data.substr(input_position);
13445|       |
13446|  2.97k|        url.set_protocol_as_file();
13447|       |        if constexpr (result_type_is_ada_url) {
13448|       |          // Set url's host to the empty string.
13449|       |          url.host = "";
13450|  2.97k|        } else {
13451|  2.97k|          url.update_base_hostname("");
13452|  2.97k|        }
13453|       |        // If c is U+002F (/) or U+005C (\), then:
13454|  2.97k|        if (input_position != input_size &&
  ------------------
  |  Branch (13454:13): [True: 2.84k, False: 133]
  ------------------
13455|  2.84k|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13455:14): [True: 2.25k, False: 592]
  ------------------
13456|  2.25k|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13456:14): [True: 6, False: 586]
  ------------------
13457|  2.25k|          ada_log("FILE c is U+002F or U+005C");
13458|       |          // Set state to file slash state.
13459|  2.25k|          state = state::FILE_SLASH;
13460|  2.25k|        }
13461|       |        // Otherwise, if base is non-null and base's scheme is "file":
13462|    719|        else if (base_url != nullptr && base_url->type == scheme::type::FILE) {
  ------------------
  |  Branch (13462:18): [True: 272, False: 447]
  |  Branch (13462:41): [True: 199, False: 73]
  ------------------
13463|       |          // Set url's host to base's host, url's path to a clone of base's
13464|       |          // path, and url's query to base's query.
13465|    199|          ada_log("FILE base non-null");
13466|       |          if constexpr (result_type_is_ada_url) {
13467|       |            url.host = base_url->host;
13468|       |            url.path = base_url->path;
13469|       |            url.query = base_url->query;
13470|    199|          } else {
13471|    199|            url.update_host_to_base_host(base_url->get_hostname());
13472|    199|            url.update_base_pathname(base_url->get_pathname());
13473|    199|            if (base_url->has_search()) {
  ------------------
  |  Branch (13473:17): [True: 0, False: 199]
  ------------------
13474|       |              // get_search() returns "" for an empty query string (URL ends
13475|       |              // with '?'). update_base_search("") would incorrectly clear the
13476|       |              // query, so pass "?" to preserve the empty query distinction.
13477|      0|              auto s = base_url->get_search();
13478|      0|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (13478:38): [True: 0, False: 0]
  ------------------
13479|      0|            }
13480|    199|          }
13481|    199|          url.has_opaque_path = base_url->has_opaque_path;
13482|       |
13483|       |          // If c is U+003F (?), then set url's query to the empty string and
13484|       |          // state to query state.
13485|    199|          if (input_position != input_size && url_data[input_position] == '?') {
  ------------------
  |  Branch (13485:15): [True: 138, False: 61]
  |  Branch (13485:47): [True: 3, False: 135]
  ------------------
13486|      3|            state = state::QUERY;
13487|      3|          }
13488|       |          // Otherwise, if c is not the EOF code point:
13489|    196|          else if (input_position != input_size) {
  ------------------
  |  Branch (13489:20): [True: 135, False: 61]
  ------------------
13490|       |            // Set url's query to null.
13491|    135|            url.clear_search();
13492|       |            // If the code point substring from pointer to the end of input does
13493|       |            // not start with a Windows drive letter, then shorten url's path.
13494|    135|            if (!checkers::is_windows_drive_letter(file_view)) {
  ------------------
  |  Branch (13494:17): [True: 113, False: 22]
  ------------------
13495|       |              if constexpr (result_type_is_ada_url) {
13496|       |                helpers::shorten_path(url.path, url.type);
13497|    113|              } else {
13498|    113|                std::string_view path = url.get_pathname();
13499|    113|                if (helpers::shorten_path(path, url.type)) {
  ------------------
  |  Branch (13499:21): [True: 0, False: 113]
  ------------------
13500|      0|                  url.update_base_pathname(std::move(std::string(path)));
13501|      0|                }
13502|    113|              }
13503|    113|            }
13504|       |            // Otherwise:
13505|     22|            else {
13506|       |              // Set url's path to an empty list.
13507|     22|              url.clear_pathname();
13508|     22|              url.has_opaque_path = true;
13509|     22|            }
13510|       |
13511|       |            // Set state to path state and decrease pointer by 1.
13512|    135|            state = state::PATH;
13513|    135|            break;
13514|    135|          }
13515|    199|        }
13516|       |        // Otherwise, set state to path state, and decrease pointer by 1.
13517|    520|        else {
13518|    520|          ada_log("FILE go to path");
13519|    520|          state = state::PATH;
13520|    520|          break;
13521|    520|        }
13522|       |
13523|  2.32k|        input_position++;
13524|  2.32k|        break;
13525|  2.97k|      }
13526|      0|      default:
  ------------------
  |  Branch (13526:7): [True: 0, False: 127k]
  ------------------
13527|      0|        unreachable();
13528|   127k|    }
13529|   127k|  }
13530|       |  if constexpr (store_values) {
13531|       |    if (fragment.has_value()) {
13532|       |      url.update_unencoded_base_hash(*fragment);
13533|       |    }
13534|       |  }
13535|    231|  enforce_max_input_length();
13536|    231|  return url;
13537|  29.8k|}
_ZNK3ada14url_aggregator8get_hostEv:
14486|    164|    ada_lifetime_bound {
14487|    164|  ada_log("url_aggregator::get_host");
14488|       |  // Technically, we should check if there is a hostname, but
14489|       |  // the code below works even if there isn't.
14490|       |  // if(!has_hostname()) { return ""; }
14491|    164|  size_t start = components.host_start;
14492|    164|  if (components.host_end > components.host_start &&
  ------------------
  |  Branch (14492:7): [True: 42, False: 122]
  ------------------
14493|     42|      buffer[components.host_start] == '@') {
  ------------------
  |  Branch (14493:7): [True: 0, False: 42]
  ------------------
14494|      0|    start++;
14495|      0|  }
14496|       |  // if we have an empty host, then the space between components.host_end and
14497|       |  // components.pathname_start may be occupied by /.
14498|    164|  if (start == components.host_end) {
  ------------------
  |  Branch (14498:7): [True: 122, False: 42]
  ------------------
14499|    122|    return {};
14500|    122|  }
14501|     42|  return helpers::substring(buffer, start, components.pathname_start);
14502|    164|}
_ZNK3ada14url_aggregator12get_hostnameEv:
14505|  18.7k|    ada_lifetime_bound {
14506|  18.7k|  ada_log("url_aggregator::get_hostname");
14507|       |  // Technically, we should check if there is a hostname, but
14508|       |  // the code below works even if there isn't.
14509|       |  // if(!has_hostname()) { return ""; }
14510|  18.7k|  size_t start = components.host_start;
14511|       |  // So host_start is not where the host begins.
14512|  18.7k|  if (components.host_end > components.host_start &&
  ------------------
  |  Branch (14512:7): [True: 4.49k, False: 14.3k]
  ------------------
14513|  4.49k|      buffer[components.host_start] == '@') {
  ------------------
  |  Branch (14513:7): [True: 246, False: 4.24k]
  ------------------
14514|    246|    start++;
14515|    246|  }
14516|  18.7k|  return helpers::substring(buffer, start, components.host_end);
14517|  18.7k|}
_ZNK3ada14url_aggregator10get_searchEv:
14520|    169|    ada_lifetime_bound {
14521|    169|  ada_log("url_aggregator::get_search");
14522|       |  // If this's URL's query is either null or the empty string, then return the
14523|       |  // empty string. Return U+003F (?), followed by this's URL's query.
14524|    169|  if (components.search_start == url_components::omitted) {
  ------------------
  |  Branch (14524:7): [True: 0, False: 169]
  ------------------
14525|      0|    return "";
14526|      0|  }
14527|    169|  auto ending_index = uint32_t(buffer.size());
14528|    169|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (14528:7): [True: 45, False: 124]
  ------------------
14529|     45|    ending_index = components.hash_start;
14530|     45|  }
14531|    169|  if (ending_index - components.search_start <= 1) {
  ------------------
  |  Branch (14531:7): [True: 66, False: 103]
  ------------------
14532|     66|    return "";
14533|     66|  }
14534|    103|  return helpers::substring(buffer, components.search_start, ending_index);
14535|    169|}
_ZNK3ada14url_aggregator12get_protocolEv:
14538|  1.41k|    ada_lifetime_bound {
14539|  1.41k|  ada_log("url_aggregator::get_protocol");
14540|  1.41k|  return helpers::substring(buffer, 0, components.protocol_end);
14541|  1.41k|}
_ZN3ada14url_aggregator10parse_ipv4ENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEb:
14650|  3.74k|bool url_aggregator::parse_ipv4(std::string_view input, bool in_place) {
14651|  3.74k|  ada_log("parse_ipv4 ", input, " [", input.size(),
14652|  3.74k|          " bytes], overlaps with buffer: ",
14653|  3.74k|          helpers::overlaps(input, buffer) ? "yes" : "no");
14654|  3.74k|  ADA_ASSERT_TRUE(validate());
14655|  3.74k|  if (input.empty()) {
  ------------------
  |  Branch (14655:7): [True: 0, False: 3.74k]
  ------------------
14656|      0|    return is_valid = false;
14657|      0|  }
14658|  3.74k|  const bool trailing_dot = (input.back() == '.');
14659|  3.74k|  if (trailing_dot) {
  ------------------
  |  Branch (14659:7): [True: 160, False: 3.58k]
  ------------------
14660|    160|    input.remove_suffix(1);
14661|    160|    if (input.empty()) {
  ------------------
  |  Branch (14661:9): [True: 0, False: 160]
  ------------------
14662|      0|      return is_valid = false;
14663|      0|    }
14664|    160|  }
14665|       |
14666|  3.74k|  const uint64_t fast = checkers::try_parse_ipv4_fast(input);
14667|  3.74k|  if (fast < checkers::ipv4_fast_fail) [[likely]] {
  ------------------
  |  Branch (14667:7): [True: 52, False: 3.69k]
  ------------------
14668|       |    // Pure decimal: keep the buffer when it already holds the address.
14669|       |    // Otherwise write the (trailing-dot-stripped) input.
14670|     52|    if (!(in_place && !trailing_dot)) {
  ------------------
  |  Branch (14670:11): [True: 26, False: 26]
  |  Branch (14670:23): [True: 6, False: 20]
  ------------------
14671|     46|      if (helpers::overlaps(input, buffer)) {
  ------------------
  |  Branch (14671:11): [True: 0, False: 46]
  ------------------
14672|      0|        update_base_hostname(std::string(input));
14673|     46|      } else {
14674|     46|        update_base_hostname(input);
14675|     46|      }
14676|     46|    }
14677|     52|    host_type = IPV4;
14678|     52|    ADA_ASSERT_TRUE(validate());
14679|     52|    return true;
14680|     52|  }
14681|       |
14682|  3.69k|  const char* p = input.data();
14683|  3.69k|  const char* end = p + input.size();
14684|  3.69k|  uint64_t ipv4 = 0;
14685|  3.69k|  int digit_count = 0;
14686|  3.69k|  int pure_decimal_count = 0;
14687|       |
14688|  4.66k|  for (; digit_count < 4 && p < end; ++digit_count) {
  ------------------
  |  Branch (14688:10): [True: 4.64k, False: 20]
  |  Branch (14688:29): [True: 4.64k, False: 0]
  ------------------
14689|  4.64k|    uint64_t segment = 0;
14690|  4.64k|    bool pure = false;
14691|  4.64k|    if (!detail::parse_ipv4_number(p, end, segment, pure)) {
  ------------------
  |  Branch (14691:9): [True: 672, False: 3.96k]
  ------------------
14692|    672|      return is_valid = false;
14693|    672|    }
14694|  3.96k|    if (pure) {
  ------------------
  |  Branch (14694:9): [True: 2.80k, False: 1.16k]
  ------------------
14695|  2.80k|      ++pure_decimal_count;
14696|  2.80k|    }
14697|  3.96k|    if (p >= end) {
  ------------------
  |  Branch (14697:9): [True: 2.93k, False: 1.03k]
  ------------------
14698|  2.93k|      const unsigned shift = static_cast<unsigned>(32 - digit_count * 8);
14699|  2.93k|      if (segment >= (uint64_t{1} << shift)) {
  ------------------
  |  Branch (14699:11): [True: 52, False: 2.88k]
  ------------------
14700|     52|        return is_valid = false;
14701|     52|      }
14702|  2.88k|      ipv4 = (ipv4 << shift) | segment;
14703|  2.88k|      goto ipv4_done;
14704|  2.93k|    }
14705|  1.03k|    if (segment > 255 || *p != '.') {
  ------------------
  |  Branch (14705:9): [True: 70, False: 966]
  |  Branch (14705:26): [True: 0, False: 966]
  ------------------
14706|     70|      return is_valid = false;
14707|     70|    }
14708|    966|    ipv4 = (ipv4 << 8) | segment;
14709|    966|    ++p;
14710|    966|  }
14711|     20|  if (digit_count != 4 || p != end) {
  ------------------
  |  Branch (14711:7): [True: 0, False: 20]
  |  Branch (14711:27): [True: 20, False: 0]
  ------------------
14712|     20|    return is_valid = false;
14713|     20|  }
14714|  2.88k|ipv4_done:
14715|  2.88k|  ada_log("url_aggregator::parse_ipv4 completed ", get_href(),
14716|  2.88k|          " host: ", get_host());
14717|  2.88k|  if (in_place && pure_decimal_count == 4 && !trailing_dot) {
  ------------------
  |  Branch (14717:7): [True: 2.64k, False: 236]
  |  Branch (14717:19): [True: 0, False: 2.64k]
  |  Branch (14717:46): [True: 0, False: 0]
  ------------------
14718|      0|    ada_log(
14719|      0|        "url_aggregator::parse_ipv4 completed and was already correct in the "
14720|      0|        "buffer");
14721|  2.88k|  } else {
14722|  2.88k|    update_base_hostname(ada::serializers::ipv4(ipv4));
14723|  2.88k|  }
14724|  2.88k|  host_type = IPV4;
14725|  2.88k|  ADA_ASSERT_TRUE(validate());
14726|  2.88k|  return true;
14727|     20|}
_ZN3ada14url_aggregator10parse_ipv6ENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
14729|  1.07k|bool url_aggregator::parse_ipv6(std::string_view input) {
14730|  1.07k|  ada_log("parse_ipv6 ", input, " [", input.size(), " bytes]");
14731|  1.07k|  ADA_ASSERT_TRUE(validate());
14732|  1.07k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
14733|  1.07k|  if (input.empty() || input.size() > 45) [[unlikely]] {
  ------------------
  |  Branch (14733:7): [True: 28, False: 1.04k]
  |  Branch (14733:24): [True: 28, False: 1.01k]
  ------------------
14734|     56|    return is_valid = false;
14735|     56|  }
14736|  1.01k|  std::array<uint16_t, 8> address{};
14737|       |#if defined(ADA_AVX512_IPV6)
14738|       |  if (bool simd_valid; detail::try_parse_ipv6_avx512(input.data(), input.size(),
14739|       |                                                     address, simd_valid)) {
14740|       |    if (!simd_valid) [[unlikely]] {
14741|       |      return is_valid = false;
14742|       |    }
14743|       |    const std::string serialized = ada::serializers::ipv6(address);
14744|       |    if (get_hostname() != serialized) {
14745|       |      update_base_hostname(serialized);
14746|       |    }
14747|       |    host_type = IPV6;
14748|       |    return true;
14749|       |  }
14750|       |  address = {};
14751|       |#endif
14752|  1.01k|  const char* pointer = input.data();
14753|  1.01k|  const char* const end = pointer + input.size();
14754|  1.01k|  int piece_index = 0;
14755|  1.01k|  int compress = -1;
14756|       |
14757|  1.01k|  if (*pointer == ':') {
  ------------------
  |  Branch (14757:7): [True: 386, False: 632]
  ------------------
14758|    386|    if (input.size() == 1 || pointer[1] != ':') [[unlikely]] {
  ------------------
  |  Branch (14758:9): [True: 6, False: 380]
  |  Branch (14758:30): [True: 10, False: 370]
  ------------------
14759|     16|      return is_valid = false;
14760|     16|    }
14761|    370|    pointer += 2;
14762|    370|    compress = ++piece_index;
14763|    370|  }
14764|       |
14765|  2.74k|  while (pointer != end) {
  ------------------
  |  Branch (14765:10): [True: 2.06k, False: 678]
  ------------------
14766|  2.06k|    if (piece_index == 8) [[unlikely]] {
  ------------------
  |  Branch (14766:9): [True: 6, False: 2.05k]
  ------------------
14767|      6|      return is_valid = false;
14768|      6|    }
14769|  2.05k|    if (*pointer == ':') {
  ------------------
  |  Branch (14769:9): [True: 294, False: 1.76k]
  ------------------
14770|    294|      if (compress != -1) [[unlikely]] {
  ------------------
  |  Branch (14770:11): [True: 8, False: 286]
  ------------------
14771|      8|        return is_valid = false;
14772|      8|      }
14773|    286|      ++pointer;
14774|    286|      compress = ++piece_index;
14775|    286|      continue;
14776|    294|    }
14777|       |
14778|  1.76k|    uint16_t value = 0;
14779|  1.76k|    const int length = detail::parse_hex_piece(pointer, end, value);
14780|       |
14781|  1.76k|    if (pointer != end && *pointer == '.') {
  ------------------
  |  Branch (14781:9): [True: 1.42k, False: 338]
  |  Branch (14781:27): [True: 192, False: 1.23k]
  ------------------
14782|    192|      if (length == 0) [[unlikely]] {
  ------------------
  |  Branch (14782:11): [True: 6, False: 186]
  ------------------
14783|      6|        return is_valid = false;
14784|      6|      }
14785|    186|      pointer -= length;
14786|    186|      if (piece_index > 6) [[unlikely]] {
  ------------------
  |  Branch (14786:11): [True: 6, False: 180]
  ------------------
14787|      6|        return is_valid = false;
14788|      6|      }
14789|       |
14790|    180|      int numbers_seen = 0;
14791|    516|      while (pointer != end) {
  ------------------
  |  Branch (14791:14): [True: 456, False: 60]
  ------------------
14792|    456|        int ipv4_piece = -1;
14793|    456|        if (numbers_seen > 0) {
  ------------------
  |  Branch (14793:13): [True: 276, False: 180]
  ------------------
14794|    276|          if (*pointer == '.' && numbers_seen < 4) {
  ------------------
  |  Branch (14794:15): [True: 242, False: 34]
  |  Branch (14794:34): [True: 236, False: 6]
  ------------------
14795|    236|            ++pointer;
14796|    236|          } else {
14797|     40|            return is_valid = false;
14798|     40|          }
14799|    276|        }
14800|    416|        if (pointer == end || *pointer < '0' || *pointer > '9') [[unlikely]] {
  ------------------
  |  Branch (14800:13): [True: 38, False: 378]
  |  Branch (14800:31): [True: 6, False: 372]
  |  Branch (14800:49): [True: 16, False: 356]
  ------------------
14801|     60|          return is_valid = false;
14802|     60|        }
14803|    356|        ipv4_piece = *pointer - '0';
14804|    356|        ++pointer;
14805|    356|        if (pointer != end && *pointer >= '0' && *pointer <= '9') {
  ------------------
  |  Branch (14805:13): [True: 320, False: 36]
  |  Branch (14805:31): [True: 126, False: 194]
  |  Branch (14805:50): [True: 120, False: 6]
  ------------------
14806|    120|          if (ipv4_piece == 0) [[unlikely]] {
  ------------------
  |  Branch (14806:15): [True: 6, False: 114]
  ------------------
14807|      6|            return is_valid = false;
14808|      6|          }
14809|    114|          ipv4_piece = ipv4_piece * 10 + (*pointer - '0');
14810|    114|          ++pointer;
14811|    114|          if (pointer != end && *pointer >= '0' && *pointer <= '9') {
  ------------------
  |  Branch (14811:15): [True: 102, False: 12]
  |  Branch (14811:33): [True: 62, False: 40]
  |  Branch (14811:52): [True: 56, False: 6]
  ------------------
14812|     56|            ipv4_piece = ipv4_piece * 10 + (*pointer - '0');
14813|     56|            ++pointer;
14814|     56|            if (ipv4_piece > 255) [[unlikely]] {
  ------------------
  |  Branch (14814:17): [True: 14, False: 42]
  ------------------
14815|     14|              return is_valid = false;
14816|     14|            }
14817|     56|          }
14818|    114|        }
14819|    336|        address[static_cast<size_t>(piece_index)] = static_cast<uint16_t>(
14820|    336|            address[static_cast<size_t>(piece_index)] * 0x100 +
14821|    336|            static_cast<uint16_t>(ipv4_piece));
14822|    336|        ++numbers_seen;
14823|    336|        if (numbers_seen == 2 || numbers_seen == 4) {
  ------------------
  |  Branch (14823:13): [True: 104, False: 232]
  |  Branch (14823:34): [True: 34, False: 198]
  ------------------
14824|    138|          ++piece_index;
14825|    138|        }
14826|    336|      }
14827|     60|      if (numbers_seen != 4) [[unlikely]] {
  ------------------
  |  Branch (14827:11): [True: 36, False: 24]
  ------------------
14828|     36|        return is_valid = false;
14829|     36|      }
14830|     24|      break;
14831|     60|    }
14832|       |
14833|  1.57k|    if (length == 0) [[unlikely]] {
  ------------------
  |  Branch (14833:9): [True: 102, False: 1.47k]
  ------------------
14834|    102|      return is_valid = false;
14835|    102|    }
14836|       |
14837|  1.47k|    if (pointer != end && *pointer == ':') {
  ------------------
  |  Branch (14837:9): [True: 1.13k, False: 338]
  |  Branch (14837:27): [True: 1.12k, False: 10]
  ------------------
14838|  1.12k|      ++pointer;
14839|  1.12k|      if (pointer == end) [[unlikely]] {
  ------------------
  |  Branch (14839:11): [True: 6, False: 1.11k]
  ------------------
14840|      6|        return is_valid = false;
14841|      6|      }
14842|  1.12k|    } else if (pointer != end) [[unlikely]] {
  ------------------
  |  Branch (14842:16): [True: 10, False: 338]
  ------------------
14843|     10|      return is_valid = false;
14844|     10|    }
14845|       |
14846|  1.45k|    address[static_cast<size_t>(piece_index)] = value;
14847|  1.45k|    ++piece_index;
14848|  1.45k|  }
14849|       |
14850|    702|  if (compress != -1) {
  ------------------
  |  Branch (14850:7): [True: 634, False: 68]
  ------------------
14851|    634|    const int right = piece_index - compress;
14852|    634|    if (right > 0) {
  ------------------
  |  Branch (14852:9): [True: 294, False: 340]
  ------------------
14853|    294|      const size_t dest = static_cast<size_t>(8 - right);
14854|    294|      const size_t src = static_cast<size_t>(compress);
14855|    294|      if (dest != src) {
  ------------------
  |  Branch (14855:11): [True: 278, False: 16]
  ------------------
14856|    768|        for (size_t i = static_cast<size_t>(right); i-- > 0;) {
  ------------------
  |  Branch (14856:53): [True: 490, False: 278]
  ------------------
14857|    490|          address[dest + i] = address[src + i];
14858|    490|          address[src + i] = 0;
14859|    490|        }
14860|    278|      }
14861|    294|    }
14862|    634|  } else if (piece_index != 8) [[unlikely]] {
  ------------------
  |  Branch (14862:14): [True: 42, False: 26]
  ------------------
14863|     42|    return is_valid = false;
14864|     42|  }
14865|       |
14866|       |  // Serialize once; skip rewrite when hostname is already canonical.
14867|    660|  const std::string serialized = ada::serializers::ipv6(address);
14868|    660|  const std::string_view current = get_hostname();
14869|    660|  if (current.size() == serialized.size() &&
  ------------------
  |  Branch (14869:7): [True: 0, False: 660]
  ------------------
14870|      0|      std::memcmp(current.data(), serialized.data(), serialized.size()) == 0) {
  ------------------
  |  Branch (14870:7): [True: 0, False: 0]
  ------------------
14871|      0|    ada_log("parse_ipv6 in-place canonical match");
14872|    660|  } else {
14873|    660|    update_base_hostname(serialized);
14874|    660|  }
14875|    660|  ada_log("parse_ipv6 ", get_hostname());
14876|    660|  ADA_ASSERT_TRUE(validate());
14877|    660|  host_type = IPV6;
14878|    660|  return true;
14879|    702|}
_ZN3ada14url_aggregator17parse_opaque_hostENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
14881|  1.12k|bool url_aggregator::parse_opaque_host(std::string_view input) {
14882|  1.12k|  ada_log("parse_opaque_host ", input, " [", input.size(), " bytes]");
14883|  1.12k|  ADA_ASSERT_TRUE(validate());
14884|  1.12k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
14885|  1.12k|  if (std::ranges::any_of(input, ada::unicode::is_forbidden_host_code_point)) {
  ------------------
  |  Branch (14885:7): [True: 18, False: 1.11k]
  ------------------
14886|     18|    return is_valid = false;
14887|     18|  }
14888|       |
14889|       |  // Return the result of running UTF-8 percent-encode on input using the C0
14890|       |  // control percent-encode set.
14891|  1.11k|  size_t idx = ada::unicode::percent_encode_index(
14892|  1.11k|      input, character_sets::C0_CONTROL_PERCENT_ENCODE);
14893|  1.11k|  if (idx == input.size()) {
  ------------------
  |  Branch (14893:7): [True: 656, False: 454]
  ------------------
14894|    656|    update_base_hostname(input);
14895|    656|  } else {
14896|       |    // We only create a temporary string if we need to.
14897|    454|    update_base_hostname(ada::unicode::percent_encode(
14898|    454|        input, character_sets::C0_CONTROL_PERCENT_ENCODE, idx));
14899|    454|  }
14900|  1.11k|  ADA_ASSERT_TRUE(validate());
14901|  1.11k|  return true;
14902|  1.12k|}
_ZN3ada14url_aggregator15delete_dash_dotEv:
15061|      8|void url_aggregator::delete_dash_dot() {
15062|      8|  ada_log("url_aggregator::delete_dash_dot");
15063|      8|  ADA_ASSERT_TRUE(validate());
15064|      8|  ADA_ASSERT_TRUE(has_dash_dot());
15065|      8|  buffer.erase(components.host_end, 2);
15066|      8|  components.pathname_start -= 2;
15067|      8|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (15067:7): [True: 0, False: 8]
  ------------------
15068|      0|    components.search_start -= 2;
15069|      0|  }
15070|      8|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (15070:7): [True: 0, False: 8]
  ------------------
15071|      0|    components.hash_start -= 2;
15072|      0|  }
15073|      8|  ADA_ASSERT_TRUE(validate());
15074|      8|  ADA_ASSERT_TRUE(!has_dash_dot());
15075|      8|}
can_parse.cc:_ZZN3ada4idna22utf32_length_from_utf8EPKcmENK3$_0clEa:
  272|   457k|  return std::count_if(p, std::next(p, len), [](int8_t c) {
  273|       |    // -65 is 0b10111111, anything larger in two-complement's
  274|       |    // should start a new code point.
  275|   457k|    return c > -65;
  276|   457k|  });
_ZN3ada4idna7deflate22make_fixed_litlen_huffEv:
  483|      2|inline Huff make_fixed_litlen_huff() {
  484|      2|  Huff h;
  485|      2|  uint8_t lens[288];
  486|       |  // Fixed Huffman: 0-143:8, 144-255:9, 256-279:7, 280-287:8
  487|    290|  for (int i = 0; i <= 143; i++) lens[i] = 8;
  ------------------
  |  Branch (487:19): [True: 288, False: 2]
  ------------------
  488|    226|  for (int i = 144; i <= 255; i++) lens[i] = 9;
  ------------------
  |  Branch (488:21): [True: 224, False: 2]
  ------------------
  489|     50|  for (int i = 256; i <= 279; i++) lens[i] = 7;
  ------------------
  |  Branch (489:21): [True: 48, False: 2]
  ------------------
  490|     18|  for (int i = 280; i <= 287; i++) lens[i] = 8;
  ------------------
  |  Branch (490:21): [True: 16, False: 2]
  ------------------
  491|      2|  h.build(lens, 288);
  492|      2|  return h;
  493|      2|}
_ZN3ada4idna7deflate4Huff5buildEPKhi:
  432|     16|  bool build(const uint8_t* lens, int n) {
  433|     16|    std::memset(counts, 0, sizeof(counts));
  434|     16|    std::memset(first_code, 0, sizeof(first_code));
  435|     16|    std::memset(base_idx, 0, sizeof(base_idx));
  436|     16|    nsymbols = n;
  437|     16|    max_bits = 0;
  438|  1.98k|    for (int i = 0; i < n; i++) {
  ------------------
  |  Branch (438:21): [True: 1.96k, False: 16]
  ------------------
  439|  1.96k|      lengths[i] = lens[i];
  440|  1.96k|      if (lens[i]) {
  ------------------
  |  Branch (440:11): [True: 1.91k, False: 49]
  ------------------
  441|  1.91k|        counts[lens[i]]++;
  442|  1.91k|        if (lens[i] > max_bits) max_bits = lens[i];
  ------------------
  |  Branch (442:13): [True: 46, False: 1.87k]
  ------------------
  443|  1.91k|      }
  444|  1.96k|    }
  445|       |    // Canonical first code for each bit length (RFC 1951).
  446|     16|    int code = 0;
  447|    256|    for (int bits = 1; bits <= MAXBITS; bits++) {
  ------------------
  |  Branch (447:24): [True: 240, False: 16]
  ------------------
  448|    240|      code = (code + counts[bits - 1]) << 1;
  449|    240|      first_code[bits] = code;
  450|    240|    }
  451|     16|    int idx = 0;
  452|    158|    for (int bits = 1; bits <= max_bits; bits++) {
  ------------------
  |  Branch (452:24): [True: 142, False: 16]
  ------------------
  453|    142|      base_idx[bits] = idx;
  454|       |      // assign symbols in symbol order for codes of this length
  455|  21.6k|      for (int sym = 0; sym < n; sym++) {
  ------------------
  |  Branch (455:25): [True: 21.5k, False: 142]
  ------------------
  456|  21.5k|        if (lengths[sym] == bits) {
  ------------------
  |  Branch (456:13): [True: 1.91k, False: 19.6k]
  ------------------
  457|  1.91k|          symbols[idx++] = static_cast<int16_t>(sym);
  458|  1.91k|        }
  459|  21.5k|      }
  460|    142|    }
  461|     16|    return true;
  462|     16|  }
_ZN3ada4idna7deflate20make_fixed_dist_huffEv:
  495|      2|inline Huff make_fixed_dist_huff() {
  496|      2|  Huff h;
  497|      2|  uint8_t lens[32];
  498|     66|  for (int i = 0; i < 32; i++) lens[i] = 5;
  ------------------
  |  Branch (498:19): [True: 64, False: 2]
  ------------------
  499|      2|  h.build(lens, 32);
  500|      2|  return h;
  501|      2|}
_ZN3ada4idna7deflate9BitReader6ensureEi:
  392|   457k|  bool ensure(int n) {
  393|   520k|    while (bits < n) {
  ------------------
  |  Branch (393:12): [True: 62.3k, False: 457k]
  ------------------
  394|  62.3k|      if (p >= end) return false;
  ------------------
  |  Branch (394:11): [True: 0, False: 62.3k]
  ------------------
  395|  62.3k|      acc |= uint32_t(*p++) << bits;
  396|  62.3k|      bits += 8;
  397|  62.3k|    }
  398|   457k|    return true;
  399|   457k|  }
can_parse.cc:_ZZN3ada4idna9ascii_mapEPcmENK3$_0clEh:
 5127|  18.5k|  auto broadcast = [](uint8_t v) -> uint64_t {
 5128|  18.5k|    return 0x101010101010101ull * v;
 5129|  18.5k|  };
_ZN3ada4idna13ensure_tablesEv:
 4878|  73.0k|[[nodiscard]] inline bool ensure_tables() noexcept {
 4879|  73.0k|  uint8_t state = tables_init_state.load(std::memory_order_acquire);
 4880|  73.0k|  if (state == kTablesReady) {
  ------------------
  |  Branch (4880:7): [True: 73.0k, False: 1]
  ------------------
 4881|  73.0k|    return true;
 4882|  73.0k|  }
 4883|      1|  if (state == kTablesFailed) {
  ------------------
  |  Branch (4883:7): [True: 0, False: 1]
  ------------------
 4884|      0|    return false;
 4885|      0|  }
 4886|       |
 4887|      1|  uint8_t expected = kTablesUninit;
 4888|      1|  if (tables_init_state.compare_exchange_strong(expected, kTablesInProgress,
  ------------------
  |  Branch (4888:7): [True: 1, False: 0]
  ------------------
 4889|      1|                                                std::memory_order_acq_rel,
 4890|      1|                                                std::memory_order_acquire)) {
 4891|      1|    uint8_t* buffer = new (std::nothrow) uint8_t[table_blob::uncompressed_size];
 4892|      1|    if (buffer == nullptr) {
  ------------------
  |  Branch (4892:9): [True: 0, False: 1]
  ------------------
 4893|      0|      tables_init_state.store(kTablesFailed, std::memory_order_release);
 4894|      0|      return false;
 4895|      0|    }
 4896|       |
 4897|      1|    const size_t n = deflate::inflate_raw(table_blob::compressed,
 4898|      1|                                          table_blob::compressed_size, buffer,
 4899|      1|                                          table_blob::uncompressed_size);
 4900|      1|    if (n != table_blob::uncompressed_size ||
  ------------------
  |  Branch (4900:9): [True: 0, False: 1]
  ------------------
 4901|      1|        crc32_ieee(buffer, n) != table_blob::uncompressed_crc32) {
  ------------------
  |  Branch (4901:9): [True: 0, False: 1]
  ------------------
 4902|      0|      delete[] buffer;
 4903|      0|      tables_init_state.store(kTablesFailed, std::memory_order_release);
 4904|      0|      return false;
 4905|      0|    }
 4906|       |
 4907|       |    // LE payload verified; convert multi-byte fields for big-endian hosts.
 4908|      1|    detail::convert_table_blob_to_host_endian(buffer);
 4909|       |
 4910|      1|    auto at = [&](size_t off) noexcept -> const uint8_t* {
 4911|      1|      return buffer + off;
 4912|      1|    };
 4913|       |
 4914|       |    // Publish all non-atomic pointers before READY. Waiters synchronize via
 4915|       |    // acquire on tables_init_state and then observe these writes.
 4916|      1|    idna_stage1 =
 4917|      1|        reinterpret_cast<const uint16_t*>(at(table_blob::off_idna_stage1));
 4918|      1|    idna_stage2 =
 4919|      1|        reinterpret_cast<const uint16_t*>(at(table_blob::off_idna_stage2));
 4920|      1|    idna_bool_blocks =
 4921|      1|        reinterpret_cast<const uint64_t*>(at(table_blob::off_idna_bool_blocks));
 4922|      1|    idna_utf8_mappings = at(table_blob::off_idna_utf8_mappings);
 4923|       |
 4924|      1|    decomposition_index = at(table_blob::off_decomposition_index);
 4925|      1|    decomposition_block_flat = reinterpret_cast<const uint16_t*>(
 4926|      1|        at(table_blob::off_decomposition_block));
 4927|      1|    decomposition_data = reinterpret_cast<const char32_t*>(
 4928|      1|        at(table_blob::off_decomposition_data));
 4929|      1|    ccc_index = at(table_blob::off_ccc_index);
 4930|      1|    ccc_block_flat = at(table_blob::off_ccc_block);
 4931|      1|    composition_index = at(table_blob::off_composition_index);
 4932|      1|    composition_block_flat = reinterpret_cast<const uint16_t*>(
 4933|      1|        at(table_blob::off_composition_block));
 4934|      1|    composition_data =
 4935|      1|        reinterpret_cast<const char32_t*>(at(table_blob::off_composition_data));
 4936|       |
 4937|      1|    id_continue =
 4938|      1|        reinterpret_cast<range_pair_ptr>(at(table_blob::off_id_continue_flat));
 4939|      1|    id_start =
 4940|      1|        reinterpret_cast<range_pair_ptr>(at(table_blob::off_id_start_flat));
 4941|       |
 4942|      1|    dir_start =
 4943|      1|        reinterpret_cast<const uint32_t*>(at(table_blob::off_dir_start));
 4944|      1|    dir_final =
 4945|      1|        reinterpret_cast<const uint32_t*>(at(table_blob::off_dir_final));
 4946|      1|    dir_value = at(table_blob::off_dir_value);
 4947|      1|    combining_ranges =
 4948|      1|        reinterpret_cast<range_pair_ptr>(at(table_blob::off_combining_flat));
 4949|       |
 4950|      1|    tables_buffer = buffer;
 4951|      1|    tables_init_state.store(kTablesReady, std::memory_order_release);
 4952|      1|    return true;
 4953|      1|  }
 4954|       |
 4955|       |  // Another thread owns init (or finished between our loads).
 4956|      0|  for (uint64_t spins = 0; spins < kTablesSpinLimit; ++spins) {
  ------------------
  |  Branch (4956:28): [True: 0, False: 0]
  ------------------
 4957|      0|    state = tables_init_state.load(std::memory_order_acquire);
 4958|      0|    if (state == kTablesReady) {
  ------------------
  |  Branch (4958:9): [True: 0, False: 0]
  ------------------
 4959|      0|      return true;
 4960|      0|    }
 4961|      0|    if (state == kTablesFailed) {
  ------------------
  |  Branch (4961:9): [True: 0, False: 0]
  ------------------
 4962|      0|      return false;
 4963|      0|    }
 4964|      0|#if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || \
 4965|      0|    defined(_M_IX86)
 4966|      0|#if defined(__GNUC__) || defined(__clang__)
 4967|      0|    __builtin_ia32_pause();
 4968|      0|#endif
 4969|       |#elif defined(__aarch64__) || defined(_M_ARM64)
 4970|       |#if defined(__GNUC__) || defined(__clang__)
 4971|       |    asm volatile("yield" ::: "memory");
 4972|       |#endif
 4973|       |#endif
 4974|      0|  }
 4975|       |  // Timed out waiting for a peer - treat as failure rather than hang.
 4976|      0|  return false;
 4977|      0|}
_ZN3ada4idna7deflate11inflate_rawEPKhmPhm:
  528|      1|                          size_t dst_cap) {
  529|      1|  BitReader br(src, src_len);
  530|      1|  size_t out = 0;
  531|      4|  for (;;) {
  532|      4|    uint32_t bfinal = br.get(1);
  533|      4|    uint32_t btype = br.get(2);
  534|      4|    if (bfinal == UINT32_MAX || btype == UINT32_MAX) return 0;
  ------------------
  |  Branch (534:9): [True: 0, False: 4]
  |  Branch (534:33): [True: 0, False: 4]
  ------------------
  535|      4|    if (btype == 0) {
  ------------------
  |  Branch (535:9): [True: 0, False: 4]
  ------------------
  536|       |      // stored
  537|      0|      br.align_byte();
  538|      0|      if (!br.ensure(16)) return 0;
  ------------------
  |  Branch (538:11): [True: 0, False: 0]
  ------------------
  539|       |      // read 16+16 from bit buffer awkwardly - use byte path
  540|       |      // Align: bits is multiple of 8
  541|       |      // Get len from remaining bits then bytes
  542|      0|      uint32_t len = br.get(16);
  543|      0|      uint32_t nlen = br.get(16);
  544|      0|      if (len == UINT32_MAX || nlen == UINT32_MAX) return 0;
  ------------------
  |  Branch (544:11): [True: 0, False: 0]
  |  Branch (544:32): [True: 0, False: 0]
  ------------------
  545|      0|      if ((len ^ 0xFFFF) != nlen) return 0;
  ------------------
  |  Branch (545:11): [True: 0, False: 0]
  ------------------
  546|       |      // After get, may have bits in acc from previous - for stored, should be
  547|       |      // byte aligned Copy len bytes from p
  548|      0|      if (br.bits != 0) {
  ------------------
  |  Branch (548:11): [True: 0, False: 0]
  ------------------
  549|       |        // leftover bits should be 0 if aligned
  550|      0|      }
  551|      0|      if (size_t(br.end - br.p) < len) return 0;
  ------------------
  |  Branch (551:11): [True: 0, False: 0]
  ------------------
  552|      0|      if (out + len > dst_cap) return 0;
  ------------------
  |  Branch (552:11): [True: 0, False: 0]
  ------------------
  553|      0|      std::memcpy(dst + out, br.p, len);
  554|      0|      br.p += len;
  555|      0|      out += len;
  556|      4|    } else if (btype == 1 || btype == 2) {
  ------------------
  |  Branch (556:16): [True: 0, False: 4]
  |  Branch (556:30): [True: 4, False: 0]
  ------------------
  557|      4|      Huff lit, dist;
  558|      4|      if (btype == 1) {
  ------------------
  |  Branch (558:11): [True: 0, False: 4]
  ------------------
  559|       |        // use fixed via functions
  560|      4|      } else {
  561|       |        // dynamic
  562|      4|        uint32_t hlit = br.get(5);
  563|      4|        if (hlit == UINT32_MAX) return 0;
  ------------------
  |  Branch (563:13): [True: 0, False: 4]
  ------------------
  564|      4|        hlit += 257;
  565|      4|        uint32_t hdist = br.get(5);
  566|      4|        if (hdist == UINT32_MAX) return 0;
  ------------------
  |  Branch (566:13): [True: 0, False: 4]
  ------------------
  567|      4|        hdist += 1;
  568|      4|        uint32_t hclen = br.get(4);
  569|      4|        if (hclen == UINT32_MAX) return 0;
  ------------------
  |  Branch (569:13): [True: 0, False: 4]
  ------------------
  570|      4|        hclen += 4;
  571|      4|        static const int order[19] = {16, 17, 18, 0, 8,  7, 9,  6, 10, 5,
  572|      4|                                      11, 4,  12, 3, 13, 2, 14, 1, 15};
  573|      4|        uint8_t clen[19]{};
  574|     69|        for (uint32_t i = 0; i < hclen; i++) {
  ------------------
  |  Branch (574:30): [True: 65, False: 4]
  ------------------
  575|     65|          uint32_t v = br.get(3);
  576|     65|          if (v == UINT32_MAX) return 0;
  ------------------
  |  Branch (576:15): [True: 0, False: 65]
  ------------------
  577|     65|          clen[order[i]] = uint8_t(v);
  578|     65|        }
  579|      4|        Huff cl;
  580|      4|        if (!cl.build(clen, 19)) return 0;
  ------------------
  |  Branch (580:13): [True: 0, False: 4]
  ------------------
  581|      4|        uint8_t lens[288 + 32]{};
  582|      4|        uint32_t n = hlit + hdist;
  583|  1.09k|        for (uint32_t i = 0; i < n;) {
  ------------------
  |  Branch (583:30): [True: 1.08k, False: 4]
  ------------------
  584|  1.08k|          int sym = cl.decode(br);
  585|  1.08k|          if (sym < 0) return 0;
  ------------------
  |  Branch (585:15): [True: 0, False: 1.08k]
  ------------------
  586|  1.08k|          if (sym < 16) {
  ------------------
  |  Branch (586:15): [True: 1.03k, False: 49]
  ------------------
  587|  1.03k|            lens[i++] = uint8_t(sym);
  588|  1.03k|          } else if (sym == 16) {
  ------------------
  |  Branch (588:22): [True: 49, False: 0]
  ------------------
  589|     49|            uint32_t rep = br.get(2);
  590|     49|            if (rep == UINT32_MAX) return 0;
  ------------------
  |  Branch (590:17): [True: 0, False: 49]
  ------------------
  591|     49|            rep += 3;
  592|     49|            if (i == 0) return 0;
  ------------------
  |  Branch (592:17): [True: 0, False: 49]
  ------------------
  593|     49|            uint8_t v = lens[i - 1];
  594|    263|            while (rep--) lens[i++] = v;
  ------------------
  |  Branch (594:20): [True: 214, False: 49]
  ------------------
  595|     49|          } else if (sym == 17) {
  ------------------
  |  Branch (595:22): [True: 0, False: 0]
  ------------------
  596|      0|            uint32_t rep = br.get(3);
  597|      0|            if (rep == UINT32_MAX) return 0;
  ------------------
  |  Branch (597:17): [True: 0, False: 0]
  ------------------
  598|      0|            rep += 3;
  599|      0|            while (rep--) lens[i++] = 0;
  ------------------
  |  Branch (599:20): [True: 0, False: 0]
  ------------------
  600|      0|          } else if (sym == 18) {
  ------------------
  |  Branch (600:22): [True: 0, False: 0]
  ------------------
  601|      0|            uint32_t rep = br.get(7);
  602|      0|            if (rep == UINT32_MAX) return 0;
  ------------------
  |  Branch (602:17): [True: 0, False: 0]
  ------------------
  603|      0|            rep += 11;
  604|      0|            while (rep--) lens[i++] = 0;
  ------------------
  |  Branch (604:20): [True: 0, False: 0]
  ------------------
  605|      0|          } else
  606|      0|            return 0;
  607|  1.08k|        }
  608|      4|        if (!lit.build(lens, int(hlit))) return 0;
  ------------------
  |  Branch (608:13): [True: 0, False: 4]
  ------------------
  609|      4|        if (!dist.build(lens + hlit, int(hdist))) return 0;
  ------------------
  |  Branch (609:13): [True: 0, False: 4]
  ------------------
  610|      4|      }
  611|  52.2k|      for (;;) {
  612|  52.2k|        int sym;
  613|  52.2k|        if (btype == 1)
  ------------------
  |  Branch (613:13): [True: 0, False: 52.2k]
  ------------------
  614|      0|          sym = fixed_litlen(br);
  615|  52.2k|        else
  616|  52.2k|          sym = lit.decode(br);
  617|  52.2k|        if (sym < 0) return 0;
  ------------------
  |  Branch (617:13): [True: 0, False: 52.2k]
  ------------------
  618|  52.2k|        if (sym < 256) {
  ------------------
  |  Branch (618:13): [True: 37.2k, False: 14.9k]
  ------------------
  619|  37.2k|          if (out >= dst_cap) return 0;
  ------------------
  |  Branch (619:15): [True: 0, False: 37.2k]
  ------------------
  620|  37.2k|          dst[out++] = uint8_t(sym);
  621|  37.2k|        } else if (sym == 256) {
  ------------------
  |  Branch (621:20): [True: 4, False: 14.9k]
  ------------------
  622|      4|          break;
  623|  14.9k|        } else {
  624|  14.9k|          int len_code = sym - 257;
  625|  14.9k|          if (len_code < 0 || len_code > 28) return 0;
  ------------------
  |  Branch (625:15): [True: 0, False: 14.9k]
  |  Branch (625:31): [True: 0, False: 14.9k]
  ------------------
  626|  14.9k|          uint32_t extra = br.get(len_extra[len_code]);
  627|  14.9k|          if (len_extra[len_code] && extra == UINT32_MAX) return 0;
  ------------------
  |  Branch (627:15): [True: 2.03k, False: 12.9k]
  |  Branch (627:38): [True: 0, False: 2.03k]
  ------------------
  628|  14.9k|          uint32_t length =
  629|  14.9k|              len_base[len_code] + (len_extra[len_code] ? extra : 0);
  ------------------
  |  Branch (629:37): [True: 2.03k, False: 12.9k]
  ------------------
  630|  14.9k|          int dsym;
  631|  14.9k|          if (btype == 1)
  ------------------
  |  Branch (631:15): [True: 0, False: 14.9k]
  ------------------
  632|      0|            dsym = fixed_dist(br);
  633|  14.9k|          else
  634|  14.9k|            dsym = dist.decode(br);
  635|  14.9k|          if (dsym < 0 || dsym > 29) return 0;
  ------------------
  |  Branch (635:15): [True: 0, False: 14.9k]
  |  Branch (635:27): [True: 0, False: 14.9k]
  ------------------
  636|  14.9k|          uint32_t dextra = br.get(dist_extra[dsym]);
  637|  14.9k|          if (dist_extra[dsym] && dextra == UINT32_MAX) return 0;
  ------------------
  |  Branch (637:15): [True: 9.97k, False: 5.01k]
  |  Branch (637:35): [True: 0, False: 9.97k]
  ------------------
  638|  14.9k|          uint32_t distance = dist_base[dsym] + (dist_extra[dsym] ? dextra : 0);
  ------------------
  |  Branch (638:50): [True: 9.97k, False: 5.01k]
  ------------------
  639|  14.9k|          if (distance > out || out + length > dst_cap) return 0;
  ------------------
  |  Branch (639:15): [True: 0, False: 14.9k]
  |  Branch (639:33): [True: 0, False: 14.9k]
  ------------------
  640|   202k|          for (uint32_t k = 0; k < length; k++) {
  ------------------
  |  Branch (640:32): [True: 187k, False: 14.9k]
  ------------------
  641|   187k|            dst[out] = dst[out - distance];
  642|   187k|            out++;
  643|   187k|          }
  644|  14.9k|        }
  645|  52.2k|      }
  646|      4|    } else {
  647|      0|      return 0;  // reserved
  648|      0|    }
  649|      4|    if (bfinal) break;
  ------------------
  |  Branch (649:9): [True: 1, False: 3]
  ------------------
  650|      4|  }
  651|      1|  return out;
  652|      1|}
_ZN3ada4idna7deflate9BitReaderC2EPKhm:
  390|      1|      : p(data), end(data + len) {}
_ZNK3ada4idna7deflate4Huff6decodeERNS1_9BitReaderE:
  464|  68.3k|  int decode(BitReader& br) const {
  465|  68.3k|    if (max_bits == 0) return -1;
  ------------------
  |  Branch (465:9): [True: 0, False: 68.3k]
  ------------------
  466|  68.3k|    int code = 0;
  467|   427k|    for (int len = 1; len <= max_bits; len++) {
  ------------------
  |  Branch (467:23): [True: 427k, False: 0]
  ------------------
  468|   427k|      uint32_t b = br.get(1);
  469|   427k|      if (b == UINT32_MAX) return -1;
  ------------------
  |  Branch (469:11): [True: 0, False: 427k]
  ------------------
  470|   427k|      code = (code << 1) | int(b);
  471|   427k|      int first = first_code[len];
  472|   427k|      int cnt = counts[len];
  473|   427k|      if (cnt && code - first < cnt) {
  ------------------
  |  Branch (473:11): [True: 263k, False: 164k]
  |  Branch (473:18): [True: 68.3k, False: 195k]
  ------------------
  474|  68.3k|        return symbols[base_idx[len] + (code - first)];
  475|  68.3k|      }
  476|   427k|    }
  477|      0|    return -1;
  478|  68.3k|  }
_ZN3ada4idna10crc32_ieeeEPKhm:
 4861|      1|                                         size_t len) noexcept {
 4862|      1|  uint32_t c = 0xFFFFFFFFu;
 4863|   224k|  for (size_t i = 0; i < len; ++i) {
  ------------------
  |  Branch (4863:22): [True: 224k, False: 1]
  ------------------
 4864|   224k|    c ^= data[i];
 4865|  2.02M|    for (int k = 0; k < 8; ++k) {
  ------------------
  |  Branch (4865:21): [True: 1.79M, False: 224k]
  ------------------
 4866|  1.79M|      const uint32_t mask = 0u - (c & 1u);
 4867|  1.79M|      c = (c >> 1) ^ (0xEDB88320u & mask);
 4868|  1.79M|    }
 4869|   224k|  }
 4870|      1|  return ~c;
 4871|      1|}
_ZN3ada4idna6detail33convert_table_blob_to_host_endianEPh:
 4684|      1|inline void convert_table_blob_to_host_endian(uint8_t* buffer) noexcept {
 4685|      1|  if constexpr (std::endian::native == std::endian::little) {
 4686|      1|    (void)buffer;
 4687|      1|    return;
 4688|      1|  }
 4689|      0|  auto u16 = [&](size_t off, size_t count) {
 4690|      1|    bswap_inplace(reinterpret_cast<uint16_t*>(buffer + off), count);
 4691|      1|  };
 4692|      1|  auto u32 = [&](size_t off, size_t count) {
 4693|      1|    bswap_inplace(reinterpret_cast<uint32_t*>(buffer + off), count);
 4694|      1|  };
 4695|      1|  auto u64 = [&](size_t off, size_t count) {
 4696|      1|    bswap_inplace(reinterpret_cast<uint64_t*>(buffer + off), count);
 4697|      1|  };
 4698|       |
 4699|      1|  u16(table_blob::off_idna_stage1, table_blob::count_idna_stage1);
 4700|      1|  u16(table_blob::off_idna_stage2, table_blob::count_idna_stage2);
 4701|      1|  u64(table_blob::off_idna_bool_blocks, table_blob::count_idna_bool_blocks);
 4702|      1|  u16(table_blob::off_decomposition_block,
 4703|      1|      table_blob::count_decomposition_block);
 4704|      1|  u32(table_blob::off_decomposition_data, table_blob::count_decomposition_data);
 4705|      1|  u16(table_blob::off_composition_block, table_blob::count_composition_block);
 4706|      1|  u32(table_blob::off_composition_data, table_blob::count_composition_data);
 4707|      1|  u32(table_blob::off_id_continue_flat, table_blob::count_id_continue_flat);
 4708|      1|  u32(table_blob::off_id_start_flat, table_blob::count_id_start_flat);
 4709|      1|  u32(table_blob::off_dir_start, table_blob::count_dir_start);
 4710|      1|  u32(table_blob::off_dir_final, table_blob::count_dir_final);
 4711|      1|  u32(table_blob::off_combining_flat, table_blob::count_combining_flat);
 4712|      1|}
_ZZN3ada4idna13ensure_tablesEvENKUlmE_clEm:
 4910|     18|    auto at = [&](size_t off) noexcept -> const uint8_t* {
 4911|     18|      return buffer + off;
 4912|     18|    };
can_parse.cc:_ZN3ada4idnaL11idna_lookupEj:
 5065|   728k|static uint16_t idna_lookup(uint32_t cp) noexcept {
 5066|   728k|  if (cp < IDNA_LOW_RANGE_END) {
  ------------------
  |  Branch (5066:7): [True: 723k, False: 4.73k]
  ------------------
 5067|   723k|    uint16_t ref = idna_stage1[cp >> IDNA_BLOCK_BITS];
 5068|   723k|    if (ref & IDNA_BOOL_FLAG) {
  ------------------
  |  Branch (5068:9): [True: 321k, False: 401k]
  ------------------
 5069|   321k|      uint32_t bit_idx =
 5070|   321k|          static_cast<uint32_t>(ref & ~IDNA_BOOL_FLAG) * IDNA_BLOCK_SIZE +
 5071|   321k|          (cp & IDNA_BLOCK_MASK);
 5072|   321k|      bool is_valid = (idna_bool_blocks[bit_idx >> 6] >> (bit_idx & 63u)) & 1u;
 5073|   321k|      return is_valid ? IDNA_VALID : IDNA_DISALLOWED;
  ------------------
  |  Branch (5073:14): [True: 321k, False: 42]
  ------------------
 5074|   321k|    }
 5075|   401k|    return idna_stage2[ref + (cp & IDNA_BLOCK_MASK)];
 5076|   723k|  }
 5077|       |
 5078|  4.73k|  if (cp >= IDNA_HIGH_IGNORED_START && cp < IDNA_HIGH_IGNORED_END) {
  ------------------
  |  Branch (5078:7): [True: 4.69k, False: 45]
  |  Branch (5078:40): [True: 4.29k, False: 402]
  ------------------
 5079|  4.29k|    return IDNA_IGNORED;
 5080|  4.29k|  }
 5081|       |
 5082|    447|  return IDNA_DISALLOWED;
 5083|  4.73k|}
can_parse.cc:_ZN3ada4idnaL21utf8_count_codepointsEPKh:
 5108|   108k|static size_t utf8_count_codepoints(const uint8_t* ptr) noexcept {
 5109|   108k|  size_t n = 0;
 5110|   618k|  while (*ptr != 0) {
  ------------------
  |  Branch (5110:10): [True: 510k, False: 108k]
  ------------------
 5111|   510k|    ++n;
 5112|   510k|    if (*ptr < 0x80u) {
  ------------------
  |  Branch (5112:9): [True: 129k, False: 381k]
  ------------------
 5113|   129k|      ++ptr;
 5114|   381k|    } else if (*ptr < 0xE0u) {
  ------------------
  |  Branch (5114:16): [True: 252k, False: 128k]
  ------------------
 5115|   252k|      ptr += 2;
 5116|   252k|    } else if (*ptr < 0xF0u) {
  ------------------
  |  Branch (5116:16): [True: 125k, False: 3.11k]
  ------------------
 5117|   125k|      ptr += 3;
 5118|   125k|    } else {
 5119|  3.11k|      ptr += 4;
 5120|  3.11k|    }
 5121|   510k|  }
 5122|   108k|  return n;
 5123|   108k|}
can_parse.cc:_ZN3ada4idnaL9utf8_nextERPKh:
 5086|   508k|static char32_t utf8_next(const uint8_t*& ptr) noexcept {
 5087|   508k|  uint8_t b0 = *ptr++;
 5088|   508k|  if (b0 < 0x80u) return static_cast<char32_t>(b0);
  ------------------
  |  Branch (5088:7): [True: 129k, False: 379k]
  ------------------
 5089|   379k|  if (b0 < 0xE0u) {
  ------------------
  |  Branch (5089:7): [True: 252k, False: 126k]
  ------------------
 5090|   252k|    uint32_t cp = (b0 & 0x1Fu) << 6;
 5091|   252k|    cp |= (*ptr++ & 0x3Fu);
 5092|   252k|    return static_cast<char32_t>(cp);
 5093|   252k|  }
 5094|   126k|  if (b0 < 0xF0u) {
  ------------------
  |  Branch (5094:7): [True: 123k, False: 3.11k]
  ------------------
 5095|   123k|    uint32_t cp = (b0 & 0x0Fu) << 12;
 5096|   123k|    cp |= ((*ptr++ & 0x3Fu) << 6);
 5097|   123k|    cp |= (*ptr++ & 0x3Fu);
 5098|   123k|    return static_cast<char32_t>(cp);
 5099|   123k|  }
 5100|  3.11k|  uint32_t cp = (b0 & 0x07u) << 18;
 5101|  3.11k|  cp |= ((*ptr++ & 0x3Fu) << 12);
 5102|  3.11k|  cp |= ((*ptr++ & 0x3Fu) << 6);
 5103|  3.11k|  cp |= (*ptr++ & 0x3Fu);
 5104|  3.11k|  return static_cast<char32_t>(cp);
 5105|   126k|}
_ZN3ada4idna23decomposition_block_rowEh:
 4982|  1.25M|inline const uint16_t* decomposition_block_row(uint8_t bi) noexcept {
 4983|  1.25M|  if (bi >= kDecompBlockRows) {
  ------------------
  |  Branch (4983:7): [True: 0, False: 1.25M]
  ------------------
 4984|      0|    bi = 0;
 4985|      0|  }
 4986|  1.25M|  return decomposition_block_flat + static_cast<size_t>(bi) * kDecompBlockCols;
 4987|  1.25M|}
_ZN3ada4idna13ccc_block_rowEh:
 4989|  1.80M|inline const uint8_t* ccc_block_row(uint8_t bi) noexcept {
 4990|  1.80M|  if (bi >= kCccBlockRows) {
  ------------------
  |  Branch (4990:7): [True: 0, False: 1.80M]
  ------------------
 4991|      0|    bi = 0;
 4992|      0|  }
 4993|  1.80M|  return ccc_block_flat + static_cast<size_t>(bi) * kCccBlockCols;
 4994|  1.80M|}
_ZN3ada4idna16tables_are_readyEv:
 4873|  22.2k|[[nodiscard]] inline bool tables_are_ready() noexcept {
 4874|  22.2k|  return tables_init_state.load(std::memory_order_acquire) == kTablesReady;
 4875|  22.2k|}
can_parse.cc:_ZN3ada4idnaL23canonical_decomp_lengthEDi:
 5265|  1.14M|static size_t canonical_decomp_length(char32_t current_character) noexcept {
 5266|  1.14M|  if (current_character >= hangul_sbase &&
  ------------------
  |  Branch (5266:7): [True: 50.5k, False: 1.09M]
  ------------------
 5267|  50.5k|      current_character < hangul_sbase + hangul_scount) {
  ------------------
  |  Branch (5267:7): [True: 28.8k, False: 21.6k]
  ------------------
 5268|       |    // Hangul precomposed syllables are NFC.
 5269|  28.8k|    return 0;
 5270|  28.8k|  }
 5271|  1.11M|  if (current_character >= 0x110000) {
  ------------------
  |  Branch (5271:7): [True: 0, False: 1.11M]
  ------------------
 5272|      0|    return 0;
 5273|      0|  }
 5274|  1.11M|  const uint8_t di = decomposition_index[current_character >> 8];
 5275|  1.11M|  const uint16_t* const decomposition =
 5276|  1.11M|      decomposition_block_row(di) + (current_character % 256);
 5277|  1.11M|  size_t decomposition_length =
 5278|  1.11M|      (decomposition[1] >> 2) - (decomposition[0] >> 2);
 5279|  1.11M|  if ((decomposition_length > 0) && (decomposition[0] & 1)) {
  ------------------
  |  Branch (5279:7): [True: 35.0k, False: 1.08M]
  |  Branch (5279:37): [True: 0, False: 35.0k]
  ------------------
 5280|      0|    decomposition_length = 0;  // compatibility-only: ignored for NFC
 5281|      0|  }
 5282|  1.11M|  return decomposition_length;
 5283|  1.11M|}
can_parse.cc:_ZN3ada4idnaL12trailing_cccEDi:
 5466|   563k|static uint8_t trailing_ccc(char32_t c) noexcept {
 5467|   563k|  const size_t length = canonical_decomp_length(c);
 5468|   563k|  if (length == 0) {
  ------------------
  |  Branch (5468:7): [True: 547k, False: 15.6k]
  ------------------
 5469|   547k|    return get_ccc(c);
 5470|   547k|  }
 5471|  15.6k|  const uint16_t* const decomposition =
 5472|  15.6k|      decomposition_block_row(decomposition_index[c >> 8]) + (c % 256);
 5473|  15.6k|  const size_t base = decomposition[0] >> 2;
 5474|  15.6k|  return get_ccc(decomposition_data[base + length - 1]);
 5475|   563k|}
can_parse.cc:_ZN3ada4idnaL13would_composeENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 5397|  13.9k|static bool would_compose(std::u32string_view input) noexcept {
 5398|   507k|  for (size_t input_count = 0; input_count < input.size();) {
  ------------------
  |  Branch (5398:32): [True: 497k, False: 10.4k]
  ------------------
 5399|   497k|    const char32_t current = input[input_count];
 5400|   497k|    if (current >= hangul_lbase && current < hangul_lbase + hangul_lcount) {
  ------------------
  |  Branch (5400:9): [True: 151k, False: 345k]
  |  Branch (5400:36): [True: 5.52k, False: 146k]
  ------------------
 5401|  5.52k|      if (input_count + 1 < input.size() &&
  ------------------
  |  Branch (5401:11): [True: 5.29k, False: 231]
  ------------------
 5402|  5.29k|          input[input_count + 1] >= hangul_vbase &&
  ------------------
  |  Branch (5402:11): [True: 1.37k, False: 3.92k]
  ------------------
 5403|  1.37k|          input[input_count + 1] < hangul_vbase + hangul_vcount) {
  ------------------
  |  Branch (5403:11): [True: 282, False: 1.09k]
  ------------------
 5404|    282|        return true;
 5405|    282|      }
 5406|  5.24k|      ++input_count;
 5407|  5.24k|      continue;
 5408|  5.52k|    }
 5409|   491k|    if (current >= hangul_sbase && current < hangul_sbase + hangul_scount) {
  ------------------
  |  Branch (5409:9): [True: 12.8k, False: 478k]
  |  Branch (5409:36): [True: 7.03k, False: 5.82k]
  ------------------
 5410|  7.03k|      if ((current - hangul_sbase) % hangul_tcount &&
  ------------------
  |  Branch (5410:11): [True: 5.37k, False: 1.66k]
  ------------------
 5411|  5.37k|          input_count + 1 < input.size() &&
  ------------------
  |  Branch (5411:11): [True: 5.02k, False: 348]
  ------------------
 5412|  5.02k|          input[input_count + 1] > hangul_tbase &&
  ------------------
  |  Branch (5412:11): [True: 4.22k, False: 798]
  ------------------
 5413|  4.22k|          input[input_count + 1] < hangul_tbase + hangul_tcount) {
  ------------------
  |  Branch (5413:11): [True: 702, False: 3.52k]
  ------------------
 5414|    702|        return true;
 5415|    702|      }
 5416|  6.33k|      ++input_count;
 5417|  6.33k|      continue;
 5418|  7.03k|    }
 5419|   484k|    if (current < 0x110000) {
  ------------------
  |  Branch (5419:9): [True: 484k, False: 0]
  ------------------
 5420|   484k|      const uint16_t* composition =
 5421|   484k|          composition_block_row(composition_index[current >> 8]) +
 5422|   484k|          (current % 256);
 5423|   484k|      int32_t previous_ccc = -1;
 5424|   484k|      size_t j = input_count;
 5425|   492k|      for (; j + 1 < input.size(); ++j) {
  ------------------
  |  Branch (5425:14): [True: 482k, False: 9.88k]
  ------------------
 5426|   482k|        uint8_t ccc = get_ccc(input[j + 1]);
 5427|   482k|        if (composition[1] != composition[0] && previous_ccc < ccc) {
  ------------------
  |  Branch (5427:13): [True: 108k, False: 374k]
  |  Branch (5427:49): [True: 105k, False: 2.97k]
  ------------------
 5428|   105k|          int left = composition[0];
 5429|   105k|          int right = composition[1];
 5430|   105k|          if (left < 0 || right < left ||
  ------------------
  |  Branch (5430:15): [True: 0, False: 105k]
  |  Branch (5430:27): [True: 0, False: 105k]
  ------------------
 5431|   105k|              static_cast<size_t>(right) > composition_data_size) {
  ------------------
  |  Branch (5431:15): [True: 0, False: 105k]
  ------------------
 5432|      0|            break;
 5433|      0|          }
 5434|   278k|          while (left + 2 < right) {
  ------------------
  |  Branch (5434:18): [True: 173k, False: 105k]
  ------------------
 5435|   173k|            int middle = left + (((right - left) >> 1) & ~1);
 5436|   173k|            if (composition_data[static_cast<size_t>(middle)] <= input[j + 1]) {
  ------------------
  |  Branch (5436:17): [True: 12.5k, False: 160k]
  ------------------
 5437|  12.5k|              left = middle;
 5438|  12.5k|            }
 5439|   173k|            if (composition_data[static_cast<size_t>(middle)] >= input[j + 1]) {
  ------------------
  |  Branch (5439:17): [True: 162k, False: 10.7k]
  ------------------
 5440|   162k|              right = middle;
 5441|   162k|            }
 5442|   173k|          }
 5443|   105k|          if (static_cast<size_t>(left + 1) < composition_data_size &&
  ------------------
  |  Branch (5443:15): [True: 105k, False: 0]
  ------------------
 5444|   105k|              composition_data[static_cast<size_t>(left)] == input[j + 1]) {
  ------------------
  |  Branch (5444:15): [True: 2.49k, False: 103k]
  ------------------
 5445|  2.49k|            return true;
 5446|  2.49k|          }
 5447|   105k|        }
 5448|   480k|        if (ccc == 0) {
  ------------------
  |  Branch (5448:13): [True: 472k, False: 7.98k]
  ------------------
 5449|   472k|          break;
 5450|   472k|        }
 5451|  7.98k|        previous_ccc = ccc;
 5452|  7.98k|      }
 5453|   482k|      input_count = j + 1;
 5454|   482k|      continue;
 5455|   484k|    }
 5456|      0|    ++input_count;
 5457|      0|  }
 5458|  10.4k|  return false;
 5459|  13.9k|}
_ZN3ada4idna21composition_block_rowEh:
 4996|   549k|inline const uint16_t* composition_block_row(uint8_t bi) noexcept {
 4997|   549k|  if (bi >= kCompBlockRows) {
  ------------------
  |  Branch (4997:7): [True: 0, False: 549k]
  ------------------
 4998|      0|    bi = 0;
 4999|      0|  }
 5000|   549k|  return composition_block_flat + static_cast<size_t>(bi) * kCompBlockCols;
 5001|   549k|}
can_parse.cc:_ZN3ada4idnaL19char_to_digit_valueEc:
 5643|  99.0k|static constexpr int32_t char_to_digit_value(char value) {
 5644|  99.0k|  if (value >= 'a' && value <= 'z') return value - 'a';
  ------------------
  |  Branch (5644:7): [True: 85.2k, False: 13.8k]
  |  Branch (5644:23): [True: 85.2k, False: 15]
  ------------------
 5645|  13.8k|  if (value >= '0' && value <= '9') return value - '0' + 26;
  ------------------
  |  Branch (5645:7): [True: 13.8k, False: 51]
  |  Branch (5645:23): [True: 13.7k, False: 18]
  ------------------
 5646|     69|  return -1;
 5647|  13.8k|}
can_parse.cc:_ZN3ada4idnaL5adaptEiib:
 5653|   277k|static constexpr int32_t adapt(int32_t d, int32_t n, bool firsttime) {
 5654|   277k|  if (firsttime) {
  ------------------
  |  Branch (5654:7): [True: 46.2k, False: 230k]
  ------------------
 5655|  46.2k|    d = d / damp;
 5656|   230k|  } else {
 5657|   230k|    d = d / 2;
 5658|   230k|  }
 5659|   277k|  d += d / n;
 5660|   277k|  int32_t k = 0;
 5661|   374k|  while (d > ((base - tmin) * tmax) / 2) {
  ------------------
  |  Branch (5661:10): [True: 97.2k, False: 277k]
  ------------------
 5662|  97.2k|    d /= base - tmin;
 5663|  97.2k|    k += base;
 5664|  97.2k|  }
 5665|   277k|  return k + (((base - tmin + 1) * d) / (d + skew));
 5666|   277k|}
can_parse.cc:_ZN3ada4idnaL13digit_to_charEi:
 5649|   503k|static constexpr char digit_to_char(int32_t digit) {
 5650|   503k|  return digit < 26 ? char(digit + 97) : char(digit + 22);
  ------------------
  |  Branch (5650:10): [True: 358k, False: 144k]
  ------------------
 5651|   503k|}
can_parse.cc:_ZZN3ada4idna14is_label_validENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEEENK3$_0clIA2_jEEDaRKT_:
 5988|   385k|      comb_span, label.front(), {}, [](const auto& range) { return range[1]; });
can_parse.cc:_ZZN3ada4idna14is_label_validENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEEENK3$_1clEj:
 6073|  5.23k|      auto is_l_or_d = [](uint32_t code) {
 6074|  5.23k|        return std::ranges::binary_search(L, code) ||
  ------------------
  |  Branch (6074:16): [True: 285, False: 4.95k]
  ------------------
 6075|  4.95k|               std::ranges::binary_search(D, code);
  ------------------
  |  Branch (6075:16): [True: 1.45k, False: 3.49k]
  ------------------
 6076|  5.23k|      };
can_parse.cc:_ZZN3ada4idna14is_label_validENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEEENK3$_2clEj:
 6077|  7.04k|      auto is_r_or_d = [](uint32_t code) {
 6078|  7.04k|        return std::ranges::binary_search(R, code) ||
  ------------------
  |  Branch (6078:16): [True: 885, False: 6.16k]
  ------------------
 6079|  6.16k|               std::ranges::binary_search(D, code);
  ------------------
  |  Branch (6079:16): [True: 552, False: 5.61k]
  ------------------
 6080|  7.04k|      };
can_parse.cc:_ZN3ada4idnaL20find_last_not_of_nsmENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 5935|  43.4k|    const std::u32string_view label) noexcept {
 5936|  50.1k|  for (int i = static_cast<int>(label.size() - 1); i >= 0; i--)
  ------------------
  |  Branch (5936:52): [True: 50.1k, False: 0]
  ------------------
 5937|  50.1k|    if (find_direction(label[i]) != direction::NSM) return i;
  ------------------
  |  Branch (5937:9): [True: 43.4k, False: 6.67k]
  ------------------
 5938|       |
 5939|      0|  return std::u32string_view::npos;
 5940|  43.4k|}
can_parse.cc:_ZN3ada4idnaL12is_rtl_labelENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 5944|  43.4k|inline static bool is_rtl_label(const std::u32string_view label) noexcept {
 5945|  43.4k|  const size_t mask =
 5946|  43.4k|      (1u << direction::R) | (1u << direction::AL) | (1u << direction::AN);
 5947|       |
 5948|  43.4k|  size_t directions = 0;
 5949|   284k|  for (size_t i = 0; i < label.size(); i++) {
  ------------------
  |  Branch (5949:22): [True: 240k, False: 43.4k]
  ------------------
 5950|   240k|    directions |= 1u << find_direction(label[i]);
 5951|   240k|  }
 5952|  43.4k|  return (directions & mask) != 0;
 5953|  43.4k|}
can_parse.cc:_ZN3ada4idnaL14find_directionEj:
 5916|   336k|inline static direction find_direction(uint32_t code_point) noexcept {
 5917|       |  // Binary search on dir_final (sorted upper bounds).
 5918|   336k|  size_t lo = 0, hi = dir_table_count;
 5919|  3.80M|  while (lo < hi) {
  ------------------
  |  Branch (5919:10): [True: 3.46M, False: 336k]
  ------------------
 5920|  3.46M|    size_t mid = lo + (hi - lo) / 2;
 5921|  3.46M|    if (dir_final[mid] < code_point) {
  ------------------
  |  Branch (5921:9): [True: 1.45M, False: 2.00M]
  ------------------
 5922|  1.45M|      lo = mid + 1;
 5923|  2.00M|    } else {
 5924|  2.00M|      hi = mid;
 5925|  2.00M|    }
 5926|  3.46M|  }
 5927|   336k|  if (lo == dir_table_count) {
  ------------------
  |  Branch (5927:7): [True: 0, False: 336k]
  ------------------
 5928|      0|    return direction::NONE;
 5929|      0|  }
 5930|   336k|  return code_point >= dir_start[lo] ? static_cast<direction>(dir_value[lo])
  ------------------
  |  Branch (5930:10): [True: 332k, False: 4.05k]
  ------------------
 5931|   336k|                                     : direction::NONE;
 5932|   336k|}
_ZN3ada4idna8is_asciiENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 6301|  19.8k|bool constexpr is_ascii(std::string_view view) {
 6302|   510k|  for (uint8_t c : view) {
  ------------------
  |  Branch (6302:18): [True: 510k, False: 6.19k]
  ------------------
 6303|   510k|    if (c >= 0x80) {
  ------------------
  |  Branch (6303:9): [True: 13.6k, False: 496k]
  ------------------
 6304|  13.6k|      return false;
 6305|  13.6k|    }
 6306|   510k|  }
 6307|  6.19k|  return true;
 6308|  19.8k|}
can_parse.cc:_ZN3ada4idnaL19from_ascii_to_asciiENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEERNS1_12basic_stringIcS4_NS1_9allocatorIcEEEE:
 6338|  6.19k|static void from_ascii_to_ascii(std::string_view ut8_string, std::string& out) {
 6339|  6.19k|  out.assign(ut8_string);
 6340|  6.19k|  ascii_map(out.data(), out.size());
 6341|  6.19k|}
_ZN3ada4idna8is_asciiENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 6292|  73.9k|bool constexpr is_ascii(std::u32string_view view) {
 6293|   263k|  for (uint32_t c : view) {
  ------------------
  |  Branch (6293:19): [True: 263k, False: 9.49k]
  ------------------
 6294|   263k|    if (c >= 0x80) {
  ------------------
  |  Branch (6294:9): [True: 64.4k, False: 198k]
  ------------------
 6295|  64.4k|      return false;
 6296|  64.4k|    }
 6297|   263k|  }
 6298|  9.49k|  return true;
 6299|  73.9k|}
can_parse.cc:_ZN3ada4idnaL13is_ace_prefixENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 6354|  55.0k|static bool is_ace_prefix(std::u32string_view label) noexcept {
 6355|  55.0k|  return label.size() >= 4 && label[0] == U'x' && label[1] == U'n' &&
  ------------------
  |  Branch (6355:10): [True: 39.5k, False: 15.4k]
  |  Branch (6355:31): [True: 10.3k, False: 29.2k]
  |  Branch (6355:51): [True: 9.51k, False: 801]
  ------------------
 6356|  9.51k|         label[2] == U'-' && label[3] == U'-';
  ------------------
  |  Branch (6356:10): [True: 8.96k, False: 549]
  |  Branch (6356:30): [True: 8.39k, False: 567]
  ------------------
 6357|  55.0k|}
can_parse.cc:_ZN3ada4idnaL18append_ascii_labelERNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_17basic_string_viewIDiNS3_IDiEEEE:
 6344|  14.5k|static void append_ascii_label(std::string& out, std::u32string_view label) {
 6345|  14.5k|  const size_t old = out.size();
 6346|  14.5k|  out.resize(old + label.size());
 6347|  14.5k|  char* dest = out.data() + old;
 6348|   177k|  for (char32_t c : label) {
  ------------------
  |  Branch (6348:19): [True: 177k, False: 14.5k]
  ------------------
 6349|   177k|    *dest++ = static_cast<char>(c);
 6350|   177k|  }
 6351|  14.5k|}
_ZZN3ada7unicode14percent_encodeILb1EEEbNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEPKhRNS2_12basic_stringIcS5_NS2_9allocatorIcEEEEENKUlcE_clEc:
 7352|  13.5k|  auto pointer = std::ranges::find_if(input, [character_set](const char c) {
 7353|  13.5k|    return character_sets::bit_at(character_set, c);
 7354|  13.5k|  });
_ZZN3ada7unicode14percent_encodeILb0EEEbNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEPKhRNS2_12basic_stringIcS5_NS2_9allocatorIcEEEEENKUlcE_clEc:
 7352|  38.9k|  auto pointer = std::ranges::find_if(input, [character_set](const char c) {
 7353|  38.9k|    return character_sets::bit_at(character_set, c);
 7354|  38.9k|  });
_ZN3ada7unicode18is_ascii_hex_digitEc:
 7086|  19.8k|ada_really_inline constexpr bool is_ascii_hex_digit(const char c) noexcept {
 7087|  19.8k|  return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') ||
  ------------------
  |  Branch (7087:11): [True: 13.5k, False: 6.26k]
  |  Branch (7087:23): [True: 8.27k, False: 5.28k]
  |  Branch (7087:37): [True: 5.24k, False: 6.30k]
  |  Branch (7087:49): [True: 2.81k, False: 2.42k]
  ------------------
 7088|  8.73k|         (c >= 'a' && c <= 'f');
  ------------------
  |  Branch (7088:11): [True: 2.36k, False: 6.36k]
  |  Branch (7088:23): [True: 2.04k, False: 318]
  ------------------
 7089|  19.8k|}
_ZN3ada7unicode21convert_hex_to_binaryEc:
 7176|  10.7k|unsigned constexpr convert_hex_to_binary(const char c) noexcept {
 7177|  10.7k|  return hex_to_binary_table[c - '0'];
 7178|  10.7k|}
can_parse.cc:_ZZN3ada7unicode14percent_encodeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKhENK3$_0clEc:
 7320|   103k|  auto pointer = std::ranges::find_if(input, [character_set](const char c) {
 7321|   103k|    return character_sets::bit_at(character_set, c);
 7322|   103k|  });
_ZN3ada7unicode36contains_forbidden_domain_code_pointEPKcm:
 7013|  14.5k|    const char* input, size_t length) noexcept {
 7014|  14.5k|  size_t i = 0;
 7015|  14.5k|  uint8_t accumulator{};
 7016|   315k|  for (; i + 4 <= length; i += 4) {
  ------------------
  |  Branch (7016:10): [True: 301k, False: 14.5k]
  ------------------
 7017|   301k|    accumulator |= is_forbidden_domain_code_point_table[uint8_t(input[i])];
 7018|   301k|    accumulator |= is_forbidden_domain_code_point_table[uint8_t(input[i + 1])];
 7019|   301k|    accumulator |= is_forbidden_domain_code_point_table[uint8_t(input[i + 2])];
 7020|   301k|    accumulator |= is_forbidden_domain_code_point_table[uint8_t(input[i + 3])];
 7021|   301k|  }
 7022|  36.7k|  for (; i < length; i++) {
  ------------------
  |  Branch (7022:10): [True: 22.2k, False: 14.5k]
  ------------------
 7023|  22.2k|    accumulator |= is_forbidden_domain_code_point_table[uint8_t(input[i])];
 7024|  22.2k|  }
 7025|  14.5k|  return accumulator;
 7026|  14.5k|}
can_parse.cc:_ZN3ada7unicode12_GLOBAL__N_122percent_encode_to_wideEPKcS3_PKhRNSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEE:
 7702|    718|                            const uint8_t character_set[], std::string& out) {
 7703|       |  // Worst case every byte becomes %XX. Avoids realloc while walking windows.
 7704|    718|  out.reserve(out.size() + static_cast<size_t>(end - p) * 3);
 7705|    718|#if ADA_UNICODE_SSSE3
 7706|    718|  const ssse3_percent_tables tables = load_ssse3_percent_tables(character_set);
 7707|    718|  percent_encode_to_ssse3(p, end, character_set, tables, out);
 7708|       |#elif ADA_NEON
 7709|       |  percent_encode_to_neon(p, end, character_set,
 7710|       |                         load_neon_percent_table(character_set), out);
 7711|       |#elif ADA_RVV
 7712|       |  percent_encode_to_rvv(p, end, character_set, out);
 7713|       |#endif
 7714|    718|}
can_parse.cc:_ZN3ada7unicode12_GLOBAL__N_125load_ssse3_percent_tablesEPKh:
 7529|    718|load_ssse3_percent_tables(const uint8_t character_set[]) noexcept {
 7530|    718|  ssse3_percent_tables t{};
 7531|    718|  t.cs_lo = _mm_loadu_si128(reinterpret_cast<const __m128i*>(character_set));
 7532|    718|  t.cs_hi =
 7533|    718|      _mm_loadu_si128(reinterpret_cast<const __m128i*>(character_set + 16));
 7534|       |  // 1 << (0..7), duplicated so pshufb(index & 7) works for every lane.
 7535|    718|  t.pow2 =
 7536|    718|      _mm_setr_epi8(1, 2, 4, 8, 16, 32, 64, -128, 1, 2, 4, 8, 16, 32, 64, -128);
 7537|    718|  t.mask_0f = _mm_set1_epi8(0x0F);
 7538|    718|  t.mask_07 = _mm_set1_epi8(0x07);
 7539|    718|  t.zero = _mm_setzero_si128();
 7540|    718|  return t;
 7541|    718|}
can_parse.cc:_ZN3ada7unicode12_GLOBAL__N_123percent_encode_to_ssse3EPKcS3_PKhRKNS1_20ssse3_percent_tablesERNSt3__112basic_stringIcNS9_11char_traitsIcEENS9_9allocatorIcEEEE:
 7560|    718|    const ssse3_percent_tables& tables, std::string& out) {
 7561|       |  // Pair 16-byte windows so a fully clean 32-byte run is one append.
 7562|  2.43k|  while (p + 32 <= end) {
  ------------------
  |  Branch (7562:10): [True: 1.71k, False: 718]
  ------------------
 7563|  1.71k|    const __m128i word0 = _mm_loadu_si128(reinterpret_cast<const __m128i*>(p));
 7564|  1.71k|    const __m128i word1 =
 7565|  1.71k|        _mm_loadu_si128(reinterpret_cast<const __m128i*>(p + 16));
 7566|  1.71k|    const int mask0 = ssse3_percent_mask(word0, tables);
 7567|  1.71k|    const int mask1 = ssse3_percent_mask(word1, tables);
 7568|  1.71k|    if ((mask0 | mask1) == 0) {
  ------------------
  |  Branch (7568:9): [True: 99, False: 1.61k]
  ------------------
 7569|     99|      out.append(p, 32);
 7570|  1.61k|    } else {
 7571|  1.61k|      if (mask0 == 0) {
  ------------------
  |  Branch (7571:11): [True: 98, False: 1.52k]
  ------------------
 7572|     98|        out.append(p, 16);
 7573|  1.52k|      } else {
 7574|  1.52k|        encode_mask_window(p, static_cast<uint32_t>(mask0), 16, out);
 7575|  1.52k|      }
 7576|  1.61k|      if (mask1 == 0) {
  ------------------
  |  Branch (7576:11): [True: 163, False: 1.45k]
  ------------------
 7577|    163|        out.append(p + 16, 16);
 7578|  1.45k|      } else {
 7579|  1.45k|        encode_mask_window(p + 16, static_cast<uint32_t>(mask1), 16, out);
 7580|  1.45k|      }
 7581|  1.61k|    }
 7582|  1.71k|    p += 32;
 7583|  1.71k|  }
 7584|    718|  if (p + 16 <= end) {
  ------------------
  |  Branch (7584:7): [True: 437, False: 281]
  ------------------
 7585|    437|    const __m128i word = _mm_loadu_si128(reinterpret_cast<const __m128i*>(p));
 7586|    437|    const int mask = ssse3_percent_mask(word, tables);
 7587|    437|    if (mask == 0) {
  ------------------
  |  Branch (7587:9): [True: 66, False: 371]
  ------------------
 7588|     66|      out.append(p, 16);
 7589|    371|    } else {
 7590|    371|      encode_mask_window(p, static_cast<uint32_t>(mask), 16, out);
 7591|    371|    }
 7592|    437|    p += 16;
 7593|    437|  }
 7594|    718|  percent_encode_to_scalar(p, end, character_set, out);
 7595|    718|}
can_parse.cc:_ZN3ada7unicode12_GLOBAL__N_118ssse3_percent_maskEDv2_xRKNS1_20ssse3_percent_tablesE:
 7544|  3.87k|    __m128i word, const ssse3_percent_tables& tables) noexcept {
 7545|  3.87k|  const __m128i idx = _mm_and_si128(_mm_srli_epi16(word, 3), tables.mask_0f);
 7546|  3.87k|  const __m128i lo = _mm_shuffle_epi8(tables.cs_lo, idx);
 7547|  3.87k|  const __m128i hi = _mm_shuffle_epi8(tables.cs_hi, idx);
 7548|       |  // Bytes 0x80-0xFF are signed-negative; select the high half of the bitmap.
 7549|  3.87k|  const __m128i high_byte = _mm_cmpgt_epi8(tables.zero, word);
 7550|  3.87k|  const __m128i cs_byte = _mm_or_si128(_mm_and_si128(hi, high_byte),
 7551|  3.87k|                                       _mm_andnot_si128(high_byte, lo));
 7552|  3.87k|  const __m128i bits =
 7553|  3.87k|      _mm_shuffle_epi8(tables.pow2, _mm_and_si128(word, tables.mask_07));
 7554|  3.87k|  const __m128i hits = _mm_and_si128(cs_byte, bits);
 7555|  3.87k|  return _mm_movemask_epi8(_mm_cmpeq_epi8(hits, tables.zero)) ^ 0xFFFF;
 7556|  3.87k|}
can_parse.cc:_ZN3ada7unicode12_GLOBAL__N_118encode_mask_windowEPKcjmRNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEE:
 7484|  3.34k|                                          size_t width, std::string& out) {
 7485|  3.34k|  uint64_t bits = mask;
 7486|  3.34k|  size_t off = 0;
 7487|  45.0k|  while (bits != 0) {
  ------------------
  |  Branch (7487:10): [True: 41.7k, False: 3.34k]
  ------------------
 7488|  41.7k|    const int zero_run = trailing_zeroes32(static_cast<uint32_t>(bits));
 7489|  41.7k|    if (zero_run != 0) {
  ------------------
  |  Branch (7489:9): [True: 2.59k, False: 39.1k]
  ------------------
 7490|  2.59k|      out.append(p + off, static_cast<size_t>(zero_run));
 7491|  2.59k|    }
 7492|  41.7k|    off += static_cast<size_t>(zero_run);
 7493|  41.7k|    out.append(character_sets::hex + uint8_t(p[off]) * 4, 3);
 7494|  41.7k|    ++off;
 7495|  41.7k|    bits >>= static_cast<unsigned>(zero_run + 1);
 7496|  41.7k|  }
 7497|  3.34k|  if (off < width) {
  ------------------
  |  Branch (7497:7): [True: 848, False: 2.49k]
  ------------------
 7498|    848|    out.append(p + off, width - off);
 7499|    848|  }
 7500|  3.34k|}
can_parse.cc:_ZN3ada7unicode12_GLOBAL__N_117trailing_zeroes32Ej:
 7472|  41.7k|ada_really_inline int trailing_zeroes32(uint32_t input_num) noexcept {
 7473|       |#ifdef ADA_REGULAR_VISUAL_STUDIO
 7474|       |  unsigned long ret;
 7475|       |  _BitScanForward(&ret, input_num);
 7476|       |  return static_cast<int>(ret);
 7477|       |#else
 7478|  41.7k|  return __builtin_ctz(input_num);
 7479|  41.7k|#endif
 7480|  41.7k|}
can_parse.cc:_ZN3ada7unicode12_GLOBAL__N_124percent_encode_to_scalarEPKcS3_PKhRNSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEE:
 7505|    718|                                                std::string& out) {
 7506|  3.24k|  for (; p != end; ++p) {
  ------------------
  |  Branch (7506:10): [True: 2.52k, False: 718]
  ------------------
 7507|  2.52k|    if (character_sets::bit_at(character_set, *p)) {
  ------------------
  |  Branch (7507:9): [True: 1.97k, False: 546]
  ------------------
 7508|  1.97k|      out.append(character_sets::hex + uint8_t(*p) * 4, 3);
 7509|  1.97k|    } else {
 7510|    546|      out += *p;
 7511|    546|    }
 7512|  2.52k|  }
 7513|    718|}
can_parse.cc:_ZN3ada11serializers12_GLOBAL__N_113write_hex_u16EPct:
 7769|  2.02k|ada_really_inline char* write_hex_u16(char* p, uint16_t v) noexcept {
 7770|  2.02k|  static constexpr char kHex[] = "0123456789abcdef";
 7771|  2.02k|  if (v >= 0x1000) {
  ------------------
  |  Branch (7771:7): [True: 237, False: 1.78k]
  ------------------
 7772|    237|    *p++ = kHex[(v >> 12) & 0xf];
 7773|    237|    *p++ = kHex[(v >> 8) & 0xf];
 7774|    237|    *p++ = kHex[(v >> 4) & 0xf];
 7775|    237|    *p++ = kHex[v & 0xf];
 7776|  1.78k|  } else if (v >= 0x100) {
  ------------------
  |  Branch (7776:14): [True: 312, False: 1.47k]
  ------------------
 7777|    312|    *p++ = kHex[(v >> 8) & 0xf];
 7778|    312|    *p++ = kHex[(v >> 4) & 0xf];
 7779|    312|    *p++ = kHex[v & 0xf];
 7780|  1.47k|  } else if (v >= 0x10) {
  ------------------
  |  Branch (7780:14): [True: 243, False: 1.23k]
  ------------------
 7781|    243|    *p++ = kHex[(v >> 4) & 0xf];
 7782|    243|    *p++ = kHex[v & 0xf];
 7783|  1.23k|  } else {
 7784|  1.23k|    *p++ = kHex[v & 0xf];
 7785|  1.23k|  }
 7786|  2.02k|  return p;
 7787|  2.02k|}
can_parse.cc:_ZN3ada11serializers12_GLOBAL__N_18write_u8EPch:
 7755|  17.2k|ada_really_inline char* write_u8(char* p, uint8_t v) noexcept {
 7756|  17.2k|  if (v < 10) {
  ------------------
  |  Branch (7756:7): [True: 13.8k, False: 3.45k]
  ------------------
 7757|  13.8k|    *p++ = static_cast<char>('0' + v);
 7758|  13.8k|  } else if (v < 100) {
  ------------------
  |  Branch (7758:14): [True: 1.31k, False: 2.13k]
  ------------------
 7759|  1.31k|    std::memcpy(p, &digit_pairs[static_cast<size_t>(v) * 2], 2);
 7760|  1.31k|    p += 2;
 7761|  2.13k|  } else {
 7762|  2.13k|    *p++ = static_cast<char>('0' + v / 100);
 7763|  2.13k|    std::memcpy(p, &digit_pairs[static_cast<size_t>(v % 100) * 2], 2);
 7764|  2.13k|    p += 2;
 7765|  2.13k|  }
 7766|  17.2k|  return p;
 7767|  17.2k|}
_ZN3ada7unicode19has_tabs_or_newlineENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 6862|   123k|    std::string_view user_input) noexcept {
 6863|       |  // first check for short strings in which case we do it naively.
 6864|   123k|  if (user_input.size() < 16) {  // slow path
  ------------------
  |  Branch (6864:7): [True: 94.6k, False: 28.6k]
  ------------------
 6865|  94.6k|    return std::ranges::any_of(user_input, is_tabs_or_newline);
 6866|  94.6k|  }
 6867|       |  // fast path for long strings (expected to be common)
 6868|  28.6k|  size_t i = 0;
 6869|  28.6k|  const __m128i mask1 = _mm_set1_epi8('\r');
 6870|  28.6k|  const __m128i mask2 = _mm_set1_epi8('\n');
 6871|  28.6k|  const __m128i mask3 = _mm_set1_epi8('\t');
 6872|       |  // If we supported SSSE3, we could use the algorithm that we use for NEON.
 6873|  28.6k|  __m128i running{0};
 6874|   152k|  for (; i + 15 < user_input.size(); i += 16) {
  ------------------
  |  Branch (6874:10): [True: 123k, False: 28.6k]
  ------------------
 6875|   123k|    __m128i word = _mm_loadu_si128((const __m128i*)(user_input.data() + i));
 6876|   123k|    running = _mm_or_si128(
 6877|   123k|        _mm_or_si128(running, _mm_or_si128(_mm_cmpeq_epi8(word, mask1),
 6878|   123k|                                           _mm_cmpeq_epi8(word, mask2))),
 6879|   123k|        _mm_cmpeq_epi8(word, mask3));
 6880|   123k|  }
 6881|  28.6k|  if (i < user_input.size()) {
  ------------------
  |  Branch (6881:7): [True: 25.5k, False: 3.18k]
  ------------------
 6882|  25.5k|    __m128i word = _mm_loadu_si128(
 6883|  25.5k|        (const __m128i*)(user_input.data() + user_input.length() - 16));
 6884|  25.5k|    running = _mm_or_si128(
 6885|  25.5k|        _mm_or_si128(running, _mm_or_si128(_mm_cmpeq_epi8(word, mask1),
 6886|  25.5k|                                           _mm_cmpeq_epi8(word, mask2))),
 6887|  25.5k|        _mm_cmpeq_epi8(word, mask3));
 6888|  25.5k|  }
 6889|  28.6k|  return _mm_movemask_epi8(running) != 0;
 6890|   123k|}
_ZN3ada7unicode18is_tabs_or_newlineEc:
 6753|   345k|constexpr bool is_tabs_or_newline(char c) noexcept {
 6754|   345k|  return c == '\r' || c == '\n' || c == '\t';
  ------------------
  |  Branch (6754:10): [True: 127, False: 345k]
  |  Branch (6754:23): [True: 179, False: 344k]
  |  Branch (6754:36): [True: 114, False: 344k]
  ------------------
 6755|   345k|}
can_parse.cc:_ZN3ada12_GLOBAL__N_124try_can_parse_clean_httpENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 7947|  31.5k|std::optional<bool> try_can_parse_clean_http(std::string_view input) noexcept {
 7948|  31.5k|  const auto* bytes = reinterpret_cast<const uint8_t*>(input.data());
 7949|  31.5k|  const size_t length = input.size();
 7950|  31.5k|  if (length < 7) {
  ------------------
  |  Branch (7950:7): [True: 14.9k, False: 16.6k]
  ------------------
 7951|  14.9k|    return std::nullopt;
 7952|  14.9k|  }
 7953|       |
 7954|  16.6k|  size_t authority_start;
 7955|  16.6k|  if constexpr (k_can_parse_little_endian) {
 7956|  16.6k|    if (length >= 8) {
  ------------------
  |  Branch (7956:9): [True: 15.2k, False: 1.40k]
  ------------------
 7957|  15.2k|      uint64_t first8 = 0;
 7958|  15.2k|      std::memcpy(&first8, bytes, 8);
 7959|  15.2k|      if (first8 == 0x2f2f3a7370747468ull) {  // "https://"
  ------------------
  |  Branch (7959:11): [True: 21, False: 15.2k]
  ------------------
 7960|     21|        authority_start = 8;
 7961|  15.2k|      } else if ((first8 & 0x00ffffffffffffffull) ==
  ------------------
  |  Branch (7961:18): [True: 530, False: 14.6k]
  ------------------
 7962|  15.2k|                 0x002f2f3a70747468ull) {  // "http://"
 7963|    530|        authority_start = 7;
 7964|  14.6k|      } else {
 7965|  14.6k|        return std::nullopt;
 7966|  14.6k|      }
 7967|  15.2k|    } else if (bytes[0] == 'h' && bytes[1] == 't' && bytes[2] == 't' &&
  ------------------
  |  Branch (7967:16): [True: 88, False: 1.31k]
  |  Branch (7967:35): [True: 70, False: 18]
  |  Branch (7967:54): [True: 55, False: 15]
  ------------------
 7968|     55|               bytes[3] == 'p' && bytes[4] == ':' && bytes[5] == '/' &&
  ------------------
  |  Branch (7968:16): [True: 42, False: 13]
  |  Branch (7968:35): [True: 28, False: 14]
  |  Branch (7968:54): [True: 12, False: 16]
  ------------------
 7969|     12|               bytes[6] == '/') {
  ------------------
  |  Branch (7969:16): [True: 2, False: 10]
  ------------------
 7970|      2|      authority_start = 7;
 7971|  1.39k|    } else {
 7972|  1.39k|      return std::nullopt;
 7973|  1.39k|    }
 7974|       |  } else {
 7975|       |    uint32_t first4{};
 7976|       |    std::memcpy(&first4, bytes, 4);
 7977|       |    if (first4 != 0x68747470u) {  // "http"
 7978|       |      return std::nullopt;
 7979|       |    }
 7980|       |    if (length >= 8 && bytes[4] == 's' && bytes[5] == ':' && bytes[6] == '/' &&
 7981|       |        bytes[7] == '/') {
 7982|       |      authority_start = 8;
 7983|       |    } else if (bytes[4] == ':' && bytes[5] == '/' && bytes[6] == '/') {
 7984|       |      authority_start = 7;
 7985|       |    } else {
 7986|       |      return std::nullopt;
 7987|       |    }
 7988|       |  }
 7989|       |
 7990|  16.6k|  if (authority_start >= length) {
  ------------------
  |  Branch (7990:7): [True: 2, False: 16.6k]
  ------------------
 7991|      2|    return false;
 7992|      2|  }
 7993|       |
 7994|  16.6k|  size_t cursor = authority_start;
 7995|  18.0k|  while (cursor + 8 <= length && eight_clean_http_host_bytes(bytes + cursor)) {
  ------------------
  |  Branch (7995:10): [True: 1.68k, False: 16.3k]
  |  Branch (7995:34): [True: 1.36k, False: 322]
  ------------------
 7996|  1.36k|    cursor += 8;
 7997|  1.36k|  }
 7998|  17.4k|  while (cursor < length) {
  ------------------
  |  Branch (7998:10): [True: 1.33k, False: 16.1k]
  ------------------
 7999|  1.33k|    const uint8_t c = bytes[cursor];
 8000|  1.33k|    if (c == '/' || c == '?' || c == '#') {
  ------------------
  |  Branch (8000:9): [True: 312, False: 1.02k]
  |  Branch (8000:21): [True: 3, False: 1.02k]
  |  Branch (8000:33): [True: 2, False: 1.02k]
  ------------------
 8001|    317|      break;
 8002|    317|    }
 8003|  1.02k|    if (!clean_http_host_byte[c]) {
  ------------------
  |  Branch (8003:9): [True: 203, False: 818]
  ------------------
 8004|    203|      return std::nullopt;
 8005|    203|    }
 8006|    818|    ++cursor;
 8007|    818|  }
 8008|       |
 8009|  16.4k|  const size_t host_length = cursor - authority_start;
 8010|  16.4k|  if (host_length == 0) {
  ------------------
  |  Branch (8010:7): [True: 4, False: 16.4k]
  ------------------
 8011|       |    // Extra special-scheme slashes are normalization, not an empty host.
 8012|      4|    if (bytes[authority_start] == '/' || bytes[authority_start] == '\\') {
  ------------------
  |  Branch (8012:9): [True: 2, False: 2]
  |  Branch (8012:42): [True: 0, False: 2]
  ------------------
 8013|      2|      return std::nullopt;
 8014|      2|    }
 8015|      2|    return false;
 8016|      4|  }
 8017|  16.4k|  if (host_length > 253 || bytes[cursor - 1] == '.') {
  ------------------
  |  Branch (8017:7): [True: 16.1k, False: 331]
  |  Branch (8017:28): [True: 51, False: 280]
  ------------------
 8018|     64|    return std::nullopt;
 8019|     64|  }
 8020|       |
 8021|  16.3k|  const std::string_view host(input.data() + authority_start, host_length);
 8022|  16.3k|  if (checkers::last_label_may_be_a_number(host)) {
  ------------------
  |  Branch (8022:7): [True: 12, False: 16.3k]
  ------------------
 8023|     12|    return std::nullopt;
 8024|     12|  }
 8025|  16.3k|  if (host.find('x') != std::string_view::npos &&
  ------------------
  |  Branch (8025:7): [True: 110, False: 16.2k]
  ------------------
 8026|    110|      host.find("xn-") != std::string_view::npos) {
  ------------------
  |  Branch (8026:7): [True: 32, False: 78]
  ------------------
 8027|     32|    return std::nullopt;
 8028|     32|  }
 8029|       |
 8030|       |  // Once a special URL has a valid host, path/query/fragment bytes cannot make
 8031|       |  // it structurally invalid: the full parser percent-encodes them as needed.
 8032|  16.3k|  return true;
 8033|  16.3k|}
can_parse.cc:_ZN3ada12_GLOBAL__N_127eight_clean_http_host_bytesEPKh:
 7923|  1.68k|    const uint8_t* input) noexcept {
 7924|  1.68k|  uint64_t w = 0;
 7925|  1.68k|  std::memcpy(&w, input, 8);
 7926|  1.68k|  constexpr uint64_t k_high = 0x8080808080808080ull;
 7927|  1.68k|  if ((w & k_high) != 0) {
  ------------------
  |  Branch (7927:7): [True: 29, False: 1.66k]
  ------------------
 7928|     29|    return false;
 7929|     29|  }
 7930|  1.66k|  const uint64_t ok = swar_in_range(w, 'a', 'z') | swar_in_range(w, '0', '9') |
 7931|  1.66k|                      swar_in_range(w, '-', '-') | swar_in_range(w, '.', '.') |
 7932|  1.66k|                      swar_in_range(w, '_', '_') | swar_in_range(w, '~', '~');
 7933|  1.66k|  return ok == k_high;
 7934|  1.68k|}
can_parse.cc:_ZN3ada12_GLOBAL__N_113swar_in_rangeEmhh:
 7914|  9.96k|                                         uint8_t hi) noexcept {
 7915|  9.96k|  constexpr uint64_t k_ones = 0x0101010101010101ull;
 7916|  9.96k|  constexpr uint64_t k_high = 0x8080808080808080ull;
 7917|  9.96k|  const uint64_t ge_lo = (w | k_high) - (k_ones * lo);
 7918|  9.96k|  const uint64_t le_hi = ((k_ones * hi) | k_high) - w;
 7919|  9.96k|  return ge_lo & le_hi & k_high;
 7920|  9.96k|}
can_parse.cc:_ZN3ada12_GLOBAL__N_127try_can_parse_absolute_fastENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8048|  31.3k|    std::string_view input) noexcept {
 8049|  31.3k|  const uint8_t* b = reinterpret_cast<const uint8_t*>(input.data());
 8050|  31.3k|  size_t len = input.size();
 8051|       |
 8052|       |  // -- Inline C0 whitespace trim (no allocation) --------------------------
 8053|       |  // Note: \t (0x09), \n (0x0a), \r (0x0d) are all <= 0x20, so any
 8054|       |  // leading/trailing tabs or newlines are correctly stripped here, matching
 8055|       |  // the WHATWG spec's "remove leading/trailing C0 control and space" step.
 8056|  32.6k|  while (len > 0 && b[0] <= 0x20) {
  ------------------
  |  Branch (8056:10): [True: 20.4k, False: 12.1k]
  |  Branch (8056:21): [True: 1.30k, False: 19.1k]
  ------------------
 8057|  1.30k|    b++;
 8058|  1.30k|    len--;
 8059|  1.30k|  }
 8060|  32.1k|  while (len > 0 && b[len - 1] <= 0x20) {
  ------------------
  |  Branch (8060:10): [True: 20.0k, False: 12.1k]
  |  Branch (8060:21): [True: 857, False: 19.1k]
  ------------------
 8061|    857|    len--;
 8062|    857|  }
 8063|  31.3k|  if (len == 0) return false;
  ------------------
  |  Branch (8063:7): [True: 12.1k, False: 19.1k]
  ------------------
 8064|       |
 8065|       |  // -- Scheme detection -----------------------------------------------------
 8066|       |  // Fast path for HTTP and HTTPS (covers ~90%+ of real-world URLs).
 8067|       |  // Avoids the general scheme loop, buffer copy, and perfect hash lookup.
 8068|       |  // We know HTTP and HTTPS are special non-file schemes, so no further
 8069|       |  // scheme_type checks are needed on the fast path -- only `pos` matters.
 8070|  19.1k|  size_t pos;
 8071|       |
 8072|  19.1k|  if (len >= 7 && (b[0] | 0x20) == 'h' && (b[1] | 0x20) == 't' &&
  ------------------
  |  Branch (8072:7): [True: 16.3k, False: 2.82k]
  |  Branch (8072:19): [True: 678, False: 15.6k]
  |  Branch (8072:43): [True: 535, False: 143]
  ------------------
 8073|    535|      (b[2] | 0x20) == 't' && (b[3] | 0x20) == 'p') {
  ------------------
  |  Branch (8073:7): [True: 508, False: 27]
  |  Branch (8073:31): [True: 485, False: 23]
  ------------------
 8074|    485|    if (b[4] == ':' && b[5] == '/' && b[6] == '/') {
  ------------------
  |  Branch (8074:9): [True: 441, False: 44]
  |  Branch (8074:24): [True: 315, False: 126]
  |  Branch (8074:39): [True: 304, False: 11]
  ------------------
 8075|    304|      pos = 7;
 8076|    304|      goto skip_extra_slashes;
 8077|    304|    }
 8078|    181|    if (len >= 8 && (b[4] | 0x20) == 's' && b[5] == ':' && b[6] == '/' &&
  ------------------
  |  Branch (8078:9): [True: 144, False: 37]
  |  Branch (8078:21): [True: 19, False: 125]
  |  Branch (8078:45): [True: 16, False: 3]
  |  Branch (8078:60): [True: 11, False: 5]
  ------------------
 8079|     11|        b[7] == '/') {
  ------------------
  |  Branch (8079:9): [True: 10, False: 1]
  ------------------
 8080|     10|      pos = 8;
 8081|     10|      goto skip_extra_slashes;
 8082|     10|    }
 8083|       |    // Fall through: could be "httpe://", tabs in scheme, etc.
 8084|    181|  }
 8085|       |
 8086|  18.8k|  {
 8087|       |    // General scheme detection for ws, wss, ftp, and edge cases.
 8088|  18.8k|    if (!checkers::is_alpha(static_cast<char>(b[0]))) return false;
  ------------------
  |  Branch (8088:9): [True: 682, False: 18.1k]
  ------------------
 8089|       |
 8090|       |    // Scan for ':' within the first 7 bytes. All special schemes are <= 5
 8091|       |    // chars ("https"), so any URL whose first ':' is beyond byte 6 is either
 8092|       |    // non-special or relative -- both require the full parser.
 8093|  18.1k|    size_t colon_pos = 0;
 8094|  39.2k|    for (size_t i = 1;; ++i) {
 8095|  39.2k|      if (i >= 7 || i >= len) return std::nullopt;
  ------------------
  |  Branch (8095:11): [True: 91, False: 39.1k]
  |  Branch (8095:21): [True: 178, False: 39.0k]
  ------------------
 8096|  39.0k|      const char c = static_cast<char>(b[i]);
 8097|  39.0k|      if (c == ':') {
  ------------------
  |  Branch (8097:11): [True: 17.6k, False: 21.3k]
  ------------------
 8098|  17.6k|        colon_pos = i;
 8099|  17.6k|        break;
 8100|  17.6k|      }
 8101|       |      // Tabs/newlines in the scheme require the full parser to strip them.
 8102|  21.3k|      if (c == '\t' || c == '\n' || c == '\r') return std::nullopt;
  ------------------
  |  Branch (8102:11): [True: 11, False: 21.2k]
  |  Branch (8102:24): [True: 8, False: 21.2k]
  |  Branch (8102:37): [True: 7, False: 21.2k]
  ------------------
 8103|  21.2k|      if (!unicode::is_alnum_plus(c)) return false;
  ------------------
  |  Branch (8103:11): [True: 176, False: 21.1k]
  ------------------
 8104|  21.2k|    }
 8105|       |
 8106|       |    // Lowercase scheme bytes inline and classify via the existing perfect
 8107|       |    // hash.
 8108|  17.6k|    char scheme_buf[6];
 8109|  17.6k|    scheme_buf[0] = static_cast<char>(b[0] | 0x20);
 8110|  38.1k|    for (size_t i = 1; i < colon_pos; ++i)
  ------------------
  |  Branch (8110:24): [True: 20.4k, False: 17.6k]
  ------------------
 8111|  20.4k|      scheme_buf[i] = static_cast<char>(b[i] | 0x20);
 8112|       |
 8113|  17.6k|    const ada::scheme::type scheme_type =
 8114|  17.6k|        ada::scheme::get_scheme_type({scheme_buf, colon_pos});
 8115|       |
 8116|       |    // Only handle special, non-file schemes.
 8117|  17.6k|    if (scheme_type == ada::scheme::NOT_SPECIAL) return std::nullopt;
  ------------------
  |  Branch (8117:9): [True: 2.69k, False: 15.0k]
  ------------------
 8118|  15.0k|    if (scheme_type == ada::scheme::FILE) return std::nullopt;
  ------------------
  |  Branch (8118:9): [True: 1.90k, False: 13.1k]
  ------------------
 8119|       |
 8120|       |    // Per WHATWG, special URLs don't require "//": "http:example.com" is valid
 8121|       |    // (SPECIAL_AUTHORITY_IGNORE_SLASHES just skips leading slashes and
 8122|       |    // proceeds to AUTHORITY).  Defer to the inline fallback for any input
 8123|       |    // without "://".
 8124|  13.1k|    pos = colon_pos + 1;
 8125|  13.1k|    if (pos + 2 > len || b[pos] != '/' || b[pos + 1] != '/') {
  ------------------
  |  Branch (8125:9): [True: 152, False: 12.9k]
  |  Branch (8125:26): [True: 6.25k, False: 6.70k]
  |  Branch (8125:43): [True: 64, False: 6.63k]
  ------------------
 8126|  6.46k|      return std::nullopt;
 8127|  6.46k|    }
 8128|  6.63k|    pos += 2;
 8129|  6.63k|  }
 8130|       |
 8131|  6.95k|skip_extra_slashes:
 8132|       |  // SPECIAL_AUTHORITY_IGNORE_SLASHES: the full parser skips any additional
 8133|       |  // leading '/' or '\' after the initial "//".  Mirror that here so we don't
 8134|       |  // mis-identify the host as empty when there are extra slashes.
 8135|  7.45k|  while (pos < len && (b[pos] == '/' || b[pos] == '\\')) {
  ------------------
  |  Branch (8135:10): [True: 7.43k, False: 25]
  |  Branch (8135:24): [True: 325, False: 7.10k]
  |  Branch (8135:41): [True: 181, False: 6.92k]
  ------------------
 8136|    506|    ++pos;
 8137|    506|  }
 8138|       |
 8139|       |  // Early IPv6 bail-out: if the authority starts with '[', it's an IPv6
 8140|       |  // literal which requires the full parser.  Checking here avoids scanning
 8141|       |  // the entire bracketed address only to bail out afterward.
 8142|  6.95k|  if (pos < len && b[pos] == '[') return std::nullopt;
  ------------------
  |  Branch (8142:7): [True: 6.92k, False: 25]
  |  Branch (8142:20): [True: 99, False: 6.82k]
  ------------------
 8143|       |
 8144|       |  // -- Merged authority + host scan ------------------------------------------
 8145|       |  // A single forward pass over the authority bytes that simultaneously:
 8146|       |  //   - finds the authority end and port colon
 8147|       |  //   - validates host characters (forbidden domain code points)
 8148|       |  //   - tracks IPv4 indicators (all-decimal-dots, last non-dot char)
 8149|       |  //   - detects xn-- prefixes (IDNA punycode)
 8150|       |  //   - detects tabs/newlines (which require the full parser to strip)
 8151|       |  // This replaces 4 separate scans over the host bytes.
 8152|  6.85k|  const size_t auth_start = pos;
 8153|  6.85k|  size_t auth_end = pos;
 8154|  6.85k|  size_t port_colon = SIZE_MAX;
 8155|  6.85k|  bool all_dec_dots = true;
 8156|       |
 8157|  48.4k|  for (; auth_end < len; ++auth_end) {
  ------------------
  |  Branch (8157:10): [True: 48.1k, False: 262]
  ------------------
 8158|  48.1k|    const uint8_t c = b[auth_end];
 8159|       |
 8160|       |    // Non-ASCII -> needs IDNA processing -> full parser.
 8161|  48.1k|    if (c >= 0x80) return std::nullopt;
  ------------------
  |  Branch (8161:9): [True: 27, False: 48.1k]
  ------------------
 8162|       |
 8163|       |    // Authority delimiters.
 8164|  48.1k|    if (c == '/' || c == '?' || c == '#' || c == '\\') break;
  ------------------
  |  Branch (8164:9): [True: 4.79k, False: 43.3k]
  |  Branch (8164:21): [True: 75, False: 43.2k]
  |  Branch (8164:33): [True: 57, False: 43.2k]
  |  Branch (8164:45): [True: 3, False: 43.2k]
  ------------------
 8165|       |
 8166|       |    // Port separator.
 8167|  43.2k|    if (c == ':') {
  ------------------
  |  Branch (8167:9): [True: 1.56k, False: 41.6k]
  ------------------
 8168|  1.56k|      if (port_colon == SIZE_MAX) port_colon = auth_end;
  ------------------
  |  Branch (8168:11): [True: 1.36k, False: 200]
  ------------------
 8169|  1.56k|      continue;
 8170|  1.56k|    }
 8171|       |
 8172|       |    // Credentials or percent-encoding -> full parser.
 8173|  41.6k|    if (c == '@' || c == '%') return std::nullopt;
  ------------------
  |  Branch (8173:9): [True: 109, False: 41.5k]
  |  Branch (8173:21): [True: 197, False: 41.3k]
  ------------------
 8174|       |
 8175|       |    // Tabs/newlines anywhere in the authority require the full parser to
 8176|       |    // strip them before validation.  Without this, a tab in the port (e.g.
 8177|       |    // "http://host:8\t0/") would be mis-rejected by port validation.
 8178|  41.3k|    if (c == '\t' || c == '\n' || c == '\r') return std::nullopt;
  ------------------
  |  Branch (8178:9): [True: 1, False: 41.3k]
  |  Branch (8178:22): [True: 1, False: 41.3k]
  |  Branch (8178:35): [True: 1, False: 41.3k]
  ------------------
 8179|       |
 8180|       |    // Skip remaining host-specific checks for port bytes.  Port digits are
 8181|       |    // validated separately below, and no forbidden-domain-code-point check
 8182|       |    // is needed on port characters.
 8183|  41.3k|    if (port_colon != SIZE_MAX) continue;
  ------------------
  |  Branch (8183:9): [True: 1.97k, False: 39.3k]
  ------------------
 8184|       |
 8185|       |    // -- Host byte validation (inlined) ------------------------------------
 8186|       |    // Forbidden domain code points that are not already caught above:
 8187|       |    //   C0 controls and space (0x00-0x20), DEL (0x7F), <, >, [, ], ^, |.
 8188|       |    // At this stage, the input may still be userinfo or be normalized later
 8189|       |    // (e.g., percent-encoded), so we do not reject here and defer to the
 8190|       |    // parser. Characters already caught: >= 0x80 (non-ASCII), '/' '?' '#' '\\'
 8191|       |    // (delimiters), ':' (port), '@' '%' (bail), '\t' '\n' '\r' (bail).
 8192|  39.3k|    if (c <= 0x20 || c == 0x7F || c == '<' || c == '>' || c == '[' ||
  ------------------
  |  Branch (8192:9): [True: 8, False: 39.3k]
  |  Branch (8192:22): [True: 1, False: 39.3k]
  |  Branch (8192:35): [True: 1, False: 39.3k]
  |  Branch (8192:47): [True: 1, False: 39.3k]
  |  Branch (8192:59): [True: 5, False: 39.3k]
  ------------------
 8193|  39.3k|        c == ']' || c == '^' || c == '|') {
  ------------------
  |  Branch (8193:9): [True: 1, False: 39.3k]
  |  Branch (8193:21): [True: 1, False: 39.3k]
  |  Branch (8193:33): [True: 2, False: 39.3k]
  ------------------
 8194|     20|      return std::nullopt;
 8195|     20|    }
 8196|       |
 8197|       |    // Track whether host is all decimal digits and dots (potential IPv4).
 8198|  39.3k|    if (c != '.' && (c < '0' || c > '9')) all_dec_dots = false;
  ------------------
  |  Branch (8198:9): [True: 35.1k, False: 4.22k]
  |  Branch (8198:22): [True: 1.96k, False: 33.1k]
  |  Branch (8198:33): [True: 24.4k, False: 8.72k]
  ------------------
 8199|       |
 8200|       |    // Detect xn-- prefix inline (IDNA punycode -> needs full parser).
 8201|       |    // Checking at every position mirrors the original behavior: any
 8202|       |    // occurrence of "xn--" in the host (not just at label boundaries)
 8203|       |    // triggers a bail-out to the full IDNA validator.
 8204|  39.3k|    if ((c | 0x20) == 'x' && auth_end + 4 <= len &&
  ------------------
  |  Branch (8204:9): [True: 5.50k, False: 33.8k]
  |  Branch (8204:30): [True: 5.07k, False: 433]
  ------------------
 8205|  5.07k|        (b[auth_end + 1] | 0x20) == 'n' && b[auth_end + 2] == '-' &&
  ------------------
  |  Branch (8205:9): [True: 1.90k, False: 3.17k]
  |  Branch (8205:44): [True: 1.62k, False: 277]
  ------------------
 8206|  1.62k|        b[auth_end + 3] == '-') {
  ------------------
  |  Branch (8206:9): [True: 1.30k, False: 322]
  ------------------
 8207|  1.30k|      return std::nullopt;
 8208|  1.30k|    }
 8209|  39.3k|  }
 8210|       |
 8211|  5.19k|  const size_t host_end = (port_colon != SIZE_MAX) ? port_colon : auth_end;
  ------------------
  |  Branch (8211:27): [True: 1.27k, False: 3.91k]
  ------------------
 8212|       |
 8213|       |  // Empty host is invalid for special URLs.
 8214|  5.19k|  if (auth_start == host_end) return false;
  ------------------
  |  Branch (8214:7): [True: 36, False: 5.15k]
  ------------------
 8215|       |
 8216|       |  // -- IPv4 handling ---------------------------------------------------------
 8217|  5.15k|  const char* host_ptr = reinterpret_cast<const char*>(b + auth_start);
 8218|  5.15k|  const size_t host_len = host_end - auth_start;
 8219|       |
 8220|  5.15k|  if (all_dec_dots) {
  ------------------
  |  Branch (8220:7): [True: 1.32k, False: 3.83k]
  ------------------
 8221|       |    // Host is all decimal digits and dots -> try the fast IPv4 parser.
 8222|  1.32k|    if (checkers::try_parse_ipv4_fast({host_ptr, host_len}) !=
  ------------------
  |  Branch (8222:9): [True: 737, False: 587]
  ------------------
 8223|  1.32k|        checkers::ipv4_fast_fail) {
 8224|       |      // Valid decimal IPv4 host.  Do NOT return true yet: the port still
 8225|       |      // needs to be validated below before we can declare the URL valid.
 8226|    737|      goto validate_port;
 8227|    737|    }
 8228|       |    // Fast IPv4 parsing failed (e.g. host is ".", "..", "1.2.3.500").
 8229|       |    // Such hosts may still be valid domain names; defer to the full parser.
 8230|    587|    return std::nullopt;
 8231|  1.32k|  }
 8232|       |
 8233|  3.83k|  if (checkers::last_label_may_be_a_number({host_ptr, host_len})) {
  ------------------
  |  Branch (8233:7): [True: 280, False: 3.55k]
  ------------------
 8234|    280|    return std::nullopt;
 8235|    280|  }
 8236|       |
 8237|       |  // -- Port validation -------------------------------------------------------
 8238|  4.29k|validate_port:
 8239|  4.29k|  if (port_colon != SIZE_MAX) {
  ------------------
  |  Branch (8239:7): [True: 1.08k, False: 3.20k]
  ------------------
 8240|  1.08k|    const uint8_t* pp = b + port_colon + 1;
 8241|  1.08k|    size_t pl = auth_end - port_colon - 1;
 8242|  1.08k|    if (pl > 0) {
  ------------------
  |  Branch (8242:9): [True: 676, False: 411]
  ------------------
 8243|       |      // Strip leading zeros: "0000001" == 1, "0000000000000" == 0, both valid.
 8244|       |      // Only the significant digits count toward the 5-digit maximum.
 8245|    982|      while (pl > 0 && *pp == '0') {
  ------------------
  |  Branch (8245:14): [True: 855, False: 127]
  |  Branch (8245:24): [True: 306, False: 549]
  ------------------
 8246|    306|        ++pp;
 8247|    306|        --pl;
 8248|    306|      }
 8249|    676|      if (pl > 5) return false;  // significant digits > 99999
  ------------------
  |  Branch (8249:11): [True: 6, False: 670]
  ------------------
 8250|    670|      uint32_t pv = 0;
 8251|  1.52k|      for (size_t i = 0; i < pl; ++i) {
  ------------------
  |  Branch (8251:26): [True: 866, False: 658]
  ------------------
 8252|    866|        if (pp[i] < '0' || pp[i] > '9') return false;
  ------------------
  |  Branch (8252:13): [True: 0, False: 866]
  |  Branch (8252:28): [True: 12, False: 854]
  ------------------
 8253|    854|        pv = pv * 10 + (pp[i] - '0');
 8254|    854|      }
 8255|    658|      if (pv > 65535) return false;
  ------------------
  |  Branch (8255:11): [True: 2, False: 656]
  ------------------
 8256|    658|    }
 8257|  1.08k|  }
 8258|       |
 8259|       |  // Path, query, and fragment are structurally always valid for can_parse --
 8260|       |  // the parser would encode whatever is there.
 8261|  4.27k|  return true;
 8262|  4.29k|}
_ZN3ada7helpers27remove_ascii_tab_or_newlineERNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 8558|    696|ada_really_inline void remove_ascii_tab_or_newline(std::string& input) {
 8559|       |  // if this ever becomes a performance issue, we could use an approach similar
 8560|       |  // to has_tabs_or_newline
 8561|    696|  std::erase_if(input, ada::unicode::is_ascii_tab_or_newline);
 8562|    696|}
_ZN3ada7unicode23is_ascii_tab_or_newlineEc:
 7107|  24.2k|    const char c) noexcept {
 7108|  24.2k|  return c == '\t' || c == '\n' || c == '\r';
  ------------------
  |  Branch (7108:10): [True: 1.42k, False: 22.8k]
  |  Branch (7108:23): [True: 1.66k, False: 21.1k]
  |  Branch (7108:36): [True: 659, False: 20.4k]
  ------------------
 7109|  24.2k|}
_ZN3ada7unicode22is_c0_control_or_spaceEc:
 7102|   144k|ada_really_inline constexpr bool is_c0_control_or_space(const char c) noexcept {
 7103|   144k|  return (unsigned char)c <= ' ';
 7104|   144k|}
_ZN3ada7helpers19parse_prepared_pathENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEENS_6scheme4typeERNS1_12basic_stringIcS4_NS1_9allocatorIcEEEE:
 9255|  9.88k|                                           std::string& path) {
 9256|  9.88k|  ada_log("parse_prepared_path ", input);
 9257|  9.88k|  uint8_t accumulator = checkers::path_signature(input);
 9258|       |  // Let us first detect a trivial case.
 9259|       |  // If it is special, we check that we have no dot, no %,  no \ and no
 9260|       |  // character needing percent encoding. Otherwise, we check that we have no %,
 9261|       |  // no dot, and no character needing percent encoding.
 9262|  9.88k|  constexpr uint8_t need_encoding = 1;
 9263|  9.88k|  constexpr uint8_t backslash_char = 2;
 9264|  9.88k|  constexpr uint8_t dot_char = 4;
 9265|  9.88k|  constexpr uint8_t percent_char = 8;
 9266|  9.88k|  bool special = type != ada::scheme::NOT_SPECIAL;
 9267|  9.88k|  bool may_need_slow_file_handling = (type == ada::scheme::type::FILE &&
  ------------------
  |  Branch (9267:39): [True: 1.69k, False: 8.18k]
  ------------------
 9268|  1.69k|                                      checkers::is_windows_drive_letter(input));
  ------------------
  |  Branch (9268:39): [True: 142, False: 1.55k]
  ------------------
 9269|  9.88k|  bool trivial_path =
 9270|  9.88k|      (special ? (accumulator == 0)
  ------------------
  |  Branch (9270:7): [True: 4.72k, False: 5.15k]
  |  Branch (9270:8): [True: 8.29k, False: 1.58k]
  ------------------
 9271|  9.88k|               : ((accumulator & (need_encoding | dot_char | percent_char)) ==
 9272|  1.58k|                  0)) &&
 9273|  4.72k|      (!may_need_slow_file_handling);
  ------------------
  |  Branch (9273:7): [True: 4.62k, False: 101]
  ------------------
 9274|  9.88k|  if (accumulator == dot_char && !may_need_slow_file_handling) {
  ------------------
  |  Branch (9274:7): [True: 1.42k, False: 8.45k]
  |  Branch (9274:34): [True: 1.40k, False: 25]
  ------------------
 9275|       |    // '4' means that we have at least one dot, but nothing that requires
 9276|       |    // percent encoding or decoding. The only part that is not trivial is
 9277|       |    // that we may have single dots and double dots path segments.
 9278|       |    // If we have such segments, then we either have a path that begins
 9279|       |    // with '.' (easy to check), or we have the sequence './'.
 9280|       |    // Note: input cannot be empty, it must at least contain one character ('.')
 9281|       |    // Note: we know that '\' is not present.
 9282|  1.40k|    if (input[0] != '.') {
  ------------------
  |  Branch (9282:9): [True: 693, False: 709]
  ------------------
 9283|    693|      size_t slashdot = 0;
 9284|    693|      bool dot_is_file = true;
 9285|  4.18k|      for (;;) {
 9286|  4.18k|        slashdot = input.find("/.", slashdot);
 9287|  4.18k|        if (slashdot == std::string_view::npos) {  // common case
  ------------------
  |  Branch (9287:13): [True: 693, False: 3.48k]
  ------------------
 9288|    693|          break;
 9289|  3.48k|        } else {  // uncommon
 9290|       |          // only three cases matter: /./, /.. or a final /
 9291|  3.48k|          slashdot += 2;
 9292|  3.48k|          dot_is_file &= !(slashdot == input.size() || input[slashdot] == '.' ||
  ------------------
  |  Branch (9292:28): [True: 199, False: 3.28k]
  |  Branch (9292:56): [True: 2.22k, False: 1.06k]
  ------------------
 9293|  1.06k|                           input[slashdot] == '/');
  ------------------
  |  Branch (9293:28): [True: 774, False: 290]
  ------------------
 9294|  3.48k|        }
 9295|  4.18k|      }
 9296|    693|      trivial_path = dot_is_file;
 9297|    693|    }
 9298|  1.40k|  }
 9299|  9.88k|  if (trivial_path) {
  ------------------
  |  Branch (9299:7): [True: 4.75k, False: 5.12k]
  ------------------
 9300|  4.75k|    ada_log("parse_path trivial");
 9301|  4.75k|    path += '/';
 9302|  4.75k|    path += input;
 9303|  4.75k|    return;
 9304|  4.75k|  }
 9305|       |  // We are going to need to look a bit at the path, but let us see if we can
 9306|       |  // ignore percent encoding *and* backslashes *and* percent characters.
 9307|       |  // Except for the trivial case, this is likely to capture 99% of paths out
 9308|       |  // there.
 9309|  5.12k|  bool fast_path =
 9310|  5.12k|      (special &&
  ------------------
  |  Branch (9310:8): [True: 3.98k, False: 1.13k]
  ------------------
 9311|  3.98k|       (accumulator & (need_encoding | backslash_char | percent_char)) == 0) &&
  ------------------
  |  Branch (9311:8): [True: 1.23k, False: 2.75k]
  ------------------
 9312|  1.23k|      (type != ada::scheme::type::FILE);
  ------------------
  |  Branch (9312:7): [True: 1.03k, False: 200]
  ------------------
 9313|  5.12k|  if (fast_path) {
  ------------------
  |  Branch (9313:7): [True: 1.03k, False: 4.08k]
  ------------------
 9314|  1.03k|    ada_log("parse_prepared_path fast");
 9315|       |    // Here we don't need to worry about \ or percent encoding.
 9316|       |    // We also do not have a file protocol. We might have dots, however,
 9317|       |    // but dots must as appear as '.', and they cannot be encoded because
 9318|       |    // the symbol '%' is not present.
 9319|  1.03k|    size_t previous_location = 0;  // We start at 0.
 9320|  12.8k|    do {
 9321|  12.8k|      size_t new_location = input.find('/', previous_location);
 9322|       |      // std::string_view path_view = input;
 9323|       |      //  We process the last segment separately:
 9324|  12.8k|      if (new_location == std::string_view::npos) {
  ------------------
  |  Branch (9324:11): [True: 1.03k, False: 11.8k]
  ------------------
 9325|  1.03k|        std::string_view path_view = input.substr(previous_location);
 9326|  1.03k|        if (path_view == "..") {  // The path ends with ..
  ------------------
  |  Branch (9326:13): [True: 131, False: 902]
  ------------------
 9327|       |          // e.g., if you receive ".." with an empty path, you go to "/".
 9328|    131|          if (path.empty()) {
  ------------------
  |  Branch (9328:15): [True: 53, False: 78]
  ------------------
 9329|     53|            path = '/';
 9330|     53|            return;
 9331|     53|          }
 9332|       |          // Fast case where we have nothing to do:
 9333|     78|          if (path.back() == '/') {
  ------------------
  |  Branch (9333:15): [True: 21, False: 57]
  ------------------
 9334|     21|            return;
 9335|     21|          }
 9336|       |          // If you have the path "/joe/myfriend",
 9337|       |          // then you delete 'myfriend'.
 9338|     57|          path.resize(path.rfind('/') + 1);
 9339|     57|          return;
 9340|     78|        }
 9341|    902|        path += '/';
 9342|    902|        if (path_view != ".") {
  ------------------
  |  Branch (9342:13): [True: 658, False: 244]
  ------------------
 9343|    658|          path.append(path_view);
 9344|    658|        }
 9345|    902|        return;
 9346|  11.8k|      } else {
 9347|       |        // This is a non-final segment.
 9348|  11.8k|        std::string_view path_view =
 9349|  11.8k|            input.substr(previous_location, new_location - previous_location);
 9350|  11.8k|        previous_location = new_location + 1;
 9351|  11.8k|        if (path_view == "..") {
  ------------------
  |  Branch (9351:13): [True: 2.48k, False: 9.36k]
  ------------------
 9352|  2.48k|          size_t last_delimiter = path.rfind('/');
 9353|  2.48k|          if (last_delimiter != std::string::npos) {
  ------------------
  |  Branch (9353:15): [True: 1.00k, False: 1.48k]
  ------------------
 9354|  1.00k|            path.erase(last_delimiter);
 9355|  1.00k|          }
 9356|  9.36k|        } else if (path_view != ".") {
  ------------------
  |  Branch (9356:20): [True: 7.89k, False: 1.46k]
  ------------------
 9357|  7.89k|          path += '/';
 9358|  7.89k|          path.append(path_view);
 9359|  7.89k|        }
 9360|  11.8k|      }
 9361|  12.8k|    } while (true);
  ------------------
  |  Branch (9361:14): [True: 11.8k, Folded]
  ------------------
 9362|  4.08k|  } else {
 9363|  4.08k|    ada_log("parse_path slow");
 9364|       |    // we have reached the general case
 9365|  4.08k|    bool needs_percent_encoding = (accumulator & 1);
 9366|  4.08k|    std::string path_buffer_tmp;
 9367|  26.4k|    do {
 9368|  26.4k|      size_t location = (special && (accumulator & 2))
  ------------------
  |  Branch (9368:26): [True: 19.7k, False: 6.70k]
  |  Branch (9368:37): [True: 1.63k, False: 18.0k]
  ------------------
 9369|  26.4k|                            ? input.find_first_of("/\\")
 9370|  26.4k|                            : input.find('/');
 9371|  26.4k|      std::string_view path_view = input;
 9372|  26.4k|      if (location != std::string_view::npos) {
  ------------------
  |  Branch (9372:11): [True: 22.3k, False: 4.08k]
  ------------------
 9373|  22.3k|        path_view.remove_suffix(path_view.size() - location);
 9374|  22.3k|        input.remove_prefix(location + 1);
 9375|  22.3k|      }
 9376|       |      // path_buffer is either path_view or it might point at a percent encoded
 9377|       |      // temporary file.
 9378|  26.4k|      std::string_view path_buffer =
 9379|  26.4k|          (needs_percent_encoding &&
  ------------------
  |  Branch (9379:12): [True: 14.2k, False: 12.1k]
  ------------------
 9380|  14.2k|           ada::unicode::percent_encode<false>(
  ------------------
  |  Branch (9380:12): [True: 5.61k, False: 8.68k]
  ------------------
 9381|  14.2k|               path_view, character_sets::PATH_PERCENT_ENCODE, path_buffer_tmp))
 9382|  26.4k|              ? path_buffer_tmp
 9383|  26.4k|              : path_view;
 9384|  26.4k|      if (unicode::is_double_dot_path_segment(path_buffer)) {
  ------------------
  |  Branch (9384:11): [True: 4.03k, False: 22.3k]
  ------------------
 9385|  4.03k|        helpers::shorten_path(path, type);
 9386|  4.03k|        if (location == std::string_view::npos) {
  ------------------
  |  Branch (9386:13): [True: 263, False: 3.77k]
  ------------------
 9387|    263|          path += '/';
 9388|    263|        }
 9389|  22.3k|      } else if (unicode::is_single_dot_path_segment(path_buffer) &&
  ------------------
  |  Branch (9389:18): [True: 1.35k, False: 21.0k]
  ------------------
 9390|  1.35k|                 (location == std::string_view::npos)) {
  ------------------
  |  Branch (9390:18): [True: 122, False: 1.23k]
  ------------------
 9391|    122|        path += '/';
 9392|    122|      }
 9393|       |      // Otherwise, if path_buffer is not a single-dot path segment, then:
 9394|  22.2k|      else if (!unicode::is_single_dot_path_segment(path_buffer)) {
  ------------------
  |  Branch (9394:16): [True: 21.0k, False: 1.23k]
  ------------------
 9395|       |        // If url's scheme is "file", url's path is empty, and path_buffer is a
 9396|       |        // Windows drive letter, then replace the second code point in
 9397|       |        // path_buffer with U+003A (:).
 9398|  21.0k|        if (type == ada::scheme::type::FILE && path.empty() &&
  ------------------
  |  Branch (9398:13): [True: 2.23k, False: 18.7k]
  |  Branch (9398:48): [True: 1.08k, False: 1.15k]
  ------------------
 9399|  1.08k|            checkers::is_windows_drive_letter(path_buffer)) {
  ------------------
  |  Branch (9399:13): [True: 164, False: 916]
  ------------------
 9400|    164|          path += '/';
 9401|    164|          path += path_buffer[0];
 9402|    164|          path += ':';
 9403|    164|          path_buffer.remove_prefix(2);
 9404|    164|          path.append(path_buffer);
 9405|  20.8k|        } else {
 9406|       |          // Append path_buffer to url's path.
 9407|  20.8k|          path += '/';
 9408|  20.8k|          path.append(path_buffer);
 9409|  20.8k|        }
 9410|  21.0k|      }
 9411|  26.4k|      if (location == std::string_view::npos) {
  ------------------
  |  Branch (9411:11): [True: 4.08k, False: 22.3k]
  ------------------
 9412|  4.08k|        return;
 9413|  4.08k|      }
 9414|  26.4k|    } while (true);
  ------------------
  |  Branch (9414:14): [True: 22.3k, Folded]
  ------------------
 9415|  4.08k|  }
 9416|  5.12k|}
_ZN3ada8checkers14path_signatureENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
   75|  19.7k|    std::string_view input) noexcept {
   76|       |  // The path percent-encode set is the query percent-encode set and U+003F (?),
   77|       |  // U+0060 (`), U+007B ({), and U+007D (}). The query percent-encode set is the
   78|       |  // C0 control percent-encode set and U+0020 SPACE, U+0022 ("), U+0023 (#),
   79|       |  // U+003C (<), and U+003E (>). The C0 control percent-encode set are the C0
   80|       |  // controls and all code points greater than U+007E (~).
   81|  19.7k|  size_t i = 0;
   82|  19.7k|  uint8_t accumulator{};
   83|  67.0k|  for (; i + 7 < input.size(); i += 8) {
  ------------------
  |  Branch (83:10): [True: 47.2k, False: 19.7k]
  ------------------
   84|  47.2k|    accumulator |= uint8_t(path_signature_table[uint8_t(input[i])] |
   85|  47.2k|                           path_signature_table[uint8_t(input[i + 1])] |
   86|  47.2k|                           path_signature_table[uint8_t(input[i + 2])] |
   87|  47.2k|                           path_signature_table[uint8_t(input[i + 3])] |
   88|  47.2k|                           path_signature_table[uint8_t(input[i + 4])] |
   89|  47.2k|                           path_signature_table[uint8_t(input[i + 5])] |
   90|  47.2k|                           path_signature_table[uint8_t(input[i + 6])] |
   91|  47.2k|                           path_signature_table[uint8_t(input[i + 7])]);
   92|  47.2k|  }
   93|  54.4k|  for (; i < input.size(); i++) {
  ------------------
  |  Branch (93:10): [True: 34.6k, False: 19.7k]
  ------------------
   94|  34.6k|    accumulator |= uint8_t(path_signature_table[uint8_t(input[i])]);
   95|  34.6k|  }
   96|  19.7k|  return accumulator;
   97|  19.7k|}
_ZN3ada7unicode26is_double_dot_path_segmentENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 7115|  52.8k|    std::string_view input) noexcept {
 7116|       |  // This will catch most cases:
 7117|       |  // The length must be 2,4 or 6.
 7118|       |  // We divide by two and require
 7119|       |  // that the result be between 1 and 3 inclusively.
 7120|  52.8k|  uint64_t half_length = uint64_t(input.size()) / 2;
 7121|  52.8k|  if (half_length - 1 > 2) {
  ------------------
  |  Branch (7121:7): [True: 26.7k, False: 26.1k]
  ------------------
 7122|  26.7k|    return false;
 7123|  26.7k|  }
 7124|       |  // We have a string of length 2, 4 or 6.
 7125|       |  // We now check the first character:
 7126|  26.1k|  if ((input[0] != '.') && (input[0] != '%')) {
  ------------------
  |  Branch (7126:7): [True: 14.2k, False: 11.9k]
  |  Branch (7126:28): [True: 3.11k, False: 11.1k]
  ------------------
 7127|  3.11k|    return false;
 7128|  3.11k|  }
 7129|       |  // We are unlikely the get beyond this point.
 7130|  23.0k|  int hash_value = (input.size() + (unsigned)(input[0])) & 3;
 7131|  23.0k|  const std::string_view target = table_is_double_dot_path_segment[hash_value];
 7132|  23.0k|  if (target.size() != input.size()) {
  ------------------
  |  Branch (7132:7): [True: 9.26k, False: 13.7k]
  ------------------
 7133|  9.26k|    return false;
 7134|  9.26k|  }
 7135|       |  // We almost never get here.
 7136|       |  // Optimizing the rest is relatively unimportant.
 7137|  13.7k|  auto prefix_equal_unsafe = [](std::string_view a, std::string_view b) {
 7138|  13.7k|    uint16_t A, B;
 7139|  13.7k|    memcpy(&A, a.data(), sizeof(A));
 7140|  13.7k|    memcpy(&B, b.data(), sizeof(B));
 7141|  13.7k|    return A == B;
 7142|  13.7k|  };
 7143|  13.7k|  if (!prefix_equal_unsafe(input, target)) {
  ------------------
  |  Branch (7143:7): [True: 2.03k, False: 11.7k]
  ------------------
 7144|  2.03k|    return false;
 7145|  2.03k|  }
 7146|  17.4k|  for (size_t i = 2; i < input.size(); i++) {
  ------------------
  |  Branch (7146:22): [True: 9.33k, False: 8.07k]
  ------------------
 7147|  9.33k|    char c = input[i];
 7148|  9.33k|    if ((uint8_t((c | 0x20) - 0x61) <= 25 ? (c | 0x20) : c) != target[i]) {
  ------------------
  |  Branch (7148:9): [True: 3.63k, False: 5.69k]
  |  Branch (7148:10): [True: 2.46k, False: 6.86k]
  ------------------
 7149|  3.63k|      return false;
 7150|  3.63k|    }
 7151|  9.33k|  }
 7152|  8.07k|  return true;
 7153|       |  // The above code might be a bit better than the code below. Compilers
 7154|       |  // are not stupid and may use the fact that these strings have length 2,4 and
 7155|       |  // 6 and other tricks.
 7156|       |  // return input == ".." ||
 7157|       |  //  input == ".%2e" || input == ".%2E" ||
 7158|       |  //  input == "%2e." || input == "%2E." ||
 7159|       |  //  input == "%2e%2e" || input == "%2E%2E" || input == "%2E%2e" || input ==
 7160|       |  //  "%2e%2E";
 7161|  11.7k|}
_ZZN3ada7unicode26is_double_dot_path_segmentENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEENKUlS5_S5_E_clES5_S5_:
 7137|  13.7k|  auto prefix_equal_unsafe = [](std::string_view a, std::string_view b) {
 7138|  13.7k|    uint16_t A, B;
 7139|  13.7k|    memcpy(&A, a.data(), sizeof(A));
 7140|  13.7k|    memcpy(&B, b.data(), sizeof(B));
 7141|  13.7k|    return A == B;
 7142|  13.7k|  };
_ZN3ada7unicode26is_single_dot_path_segmentENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 7164|  89.3k|    std::string_view input) noexcept {
 7165|  89.3k|  return input == "." || input == "%2e" || input == "%2E";
  ------------------
  |  Branch (7165:10): [True: 3.74k, False: 85.6k]
  |  Branch (7165:26): [True: 1.43k, False: 84.2k]
  |  Branch (7165:44): [True: 4, False: 84.2k]
  ------------------
 7166|  89.3k|}
_ZN3ada7unicode28is_forbidden_host_code_pointEc:
 6985|  59.3k|    const char c) noexcept {
 6986|  59.3k|  return is_forbidden_host_code_point_table[uint8_t(c)];
 6987|  59.3k|}
_ZN3ada6detail17parse_ipv4_numberERPKcS2_RmRb:
 9539|  6.96k|                              bool& is_pure_decimal) noexcept {
 9540|  6.96k|  is_pure_decimal = false;
 9541|  6.96k|  if (p >= end) [[unlikely]] {
  ------------------
  |  Branch (9541:7): [True: 0, False: 6.96k]
  ------------------
 9542|      0|    return false;
 9543|      0|  }
 9544|  6.96k|  if (end - p >= 2 && p[0] == '0' && ((p[1] | 0x20) == 'x')) {
  ------------------
  |  Branch (9544:7): [True: 4.80k, False: 2.15k]
  |  Branch (9544:23): [True: 2.40k, False: 2.40k]
  |  Branch (9544:38): [True: 1.53k, False: 867]
  ------------------
 9545|  1.53k|    p += 2;
 9546|  1.53k|    if (p == end || *p == '.') {
  ------------------
  |  Branch (9546:9): [True: 258, False: 1.28k]
  |  Branch (9546:21): [True: 60, False: 1.22k]
  ------------------
 9547|    318|      value = 0;
 9548|    318|      return true;
 9549|    318|    }
 9550|  1.22k|    uint64_t v = 0;
 9551|  1.22k|    int digits = 0;
 9552|  7.90k|    while (p < end && *p != '.') {
  ------------------
  |  Branch (9552:12): [True: 7.05k, False: 843]
  |  Branch (9552:23): [True: 6.96k, False: 90]
  ------------------
 9553|  6.96k|      const uint8_t nib = hex_nibble[static_cast<unsigned char>(*p)];
 9554|  6.96k|      if (nib == 0xff) [[unlikely]] {
  ------------------
  |  Branch (9554:11): [True: 18, False: 6.95k]
  ------------------
 9555|     18|        return false;
 9556|     18|      }
 9557|  6.95k|      if (v > (0xFFFFFFFFULL >> 4)) [[unlikely]] {
  ------------------
  |  Branch (9557:11): [True: 270, False: 6.68k]
  ------------------
 9558|    270|        return false;
 9559|    270|      }
 9560|  6.68k|      v = (v << 4) | nib;
 9561|  6.68k|      ++p;
 9562|  6.68k|      ++digits;
 9563|  6.68k|    }
 9564|    933|    if (digits == 0) [[unlikely]] {
  ------------------
  |  Branch (9564:9): [True: 0, False: 933]
  ------------------
 9565|      0|      return false;
 9566|      0|    }
 9567|    933|    value = v;
 9568|    933|    return true;
 9569|    933|  }
 9570|  5.42k|  if (end - p >= 2 && p[0] == '0' && p[1] >= '0' && p[1] <= '9') {
  ------------------
  |  Branch (9570:7): [True: 3.26k, False: 2.15k]
  |  Branch (9570:23): [True: 867, False: 2.40k]
  |  Branch (9570:38): [True: 591, False: 276]
  |  Branch (9570:53): [True: 573, False: 18]
  ------------------
 9571|    573|    ++p;
 9572|    573|    uint64_t v = 0;
 9573|  5.29k|    while (p < end && *p != '.') {
  ------------------
  |  Branch (9573:12): [True: 4.91k, False: 381]
  |  Branch (9573:23): [True: 4.79k, False: 120]
  ------------------
 9574|  4.79k|      const char c = *p;
 9575|  4.79k|      if (c < '0' || c > '7') [[unlikely]] {
  ------------------
  |  Branch (9575:11): [True: 12, False: 4.78k]
  |  Branch (9575:22): [True: 36, False: 4.74k]
  ------------------
 9576|     48|        return false;
 9577|     48|      }
 9578|  4.74k|      if (v > (0xFFFFFFFFULL >> 3)) [[unlikely]] {
  ------------------
  |  Branch (9578:11): [True: 24, False: 4.72k]
  ------------------
 9579|     24|        return false;
 9580|     24|      }
 9581|  4.72k|      v = (v << 3) | static_cast<uint64_t>(c - '0');
 9582|  4.72k|      ++p;
 9583|  4.72k|    }
 9584|    501|    value = v;
 9585|    501|    return true;
 9586|    573|  }
 9587|  4.84k|  if (*p < '0' || *p > '9') [[unlikely]] {
  ------------------
  |  Branch (9587:7): [True: 168, False: 4.68k]
  |  Branch (9587:19): [True: 294, False: 4.38k]
  ------------------
 9588|    462|    return false;
 9589|    462|  }
 9590|  4.38k|  is_pure_decimal = true;
 9591|  4.38k|  uint64_t v = static_cast<uint64_t>(*p - '0');
 9592|  4.38k|  ++p;
 9593|  9.05k|  while (p < end && *p != '.') {
  ------------------
  |  Branch (9593:10): [True: 6.13k, False: 2.91k]
  |  Branch (9593:21): [True: 4.85k, False: 1.28k]
  ------------------
 9594|  4.85k|    const char c = *p;
 9595|  4.85k|    if (c < '0' || c > '9') [[unlikely]] {
  ------------------
  |  Branch (9595:9): [True: 15, False: 4.83k]
  |  Branch (9595:20): [True: 72, False: 4.76k]
  ------------------
 9596|     87|      return false;
 9597|     87|    }
 9598|  4.76k|    if (v > 429496729ULL) [[unlikely]] {
  ------------------
  |  Branch (9598:9): [True: 87, False: 4.68k]
  ------------------
 9599|     87|      return false;
 9600|     87|    }
 9601|  4.68k|    v = v * 10u + static_cast<uint64_t>(c - '0');
 9602|  4.68k|    if (v > 0xFFFFFFFFULL) [[unlikely]] {
  ------------------
  |  Branch (9602:9): [True: 12, False: 4.66k]
  ------------------
 9603|     12|      return false;
 9604|     12|    }
 9605|  4.66k|    ++p;
 9606|  4.66k|  }
 9607|  4.20k|  value = v;
 9608|  4.20k|  return true;
 9609|  4.38k|}
_ZN3ada6detail15parse_hex_pieceERPKcS2_Rt:
 9613|  2.64k|                           uint16_t& value) noexcept {
 9614|  2.64k|  if (pointer == end) {
  ------------------
  |  Branch (9614:7): [True: 0, False: 2.64k]
  ------------------
 9615|      0|    return 0;
 9616|      0|  }
 9617|  2.64k|  const uint8_t n0 = hex_nibble[static_cast<unsigned char>(*pointer)];
 9618|  2.64k|  if (n0 == 0xff) {
  ------------------
  |  Branch (9618:7): [True: 162, False: 2.48k]
  ------------------
 9619|    162|    return 0;
 9620|    162|  }
 9621|  2.48k|  uint32_t v = n0;
 9622|  2.48k|  ++pointer;
 9623|  2.48k|  int length = 1;
 9624|  2.48k|  if (pointer != end) {
  ------------------
  |  Branch (9624:7): [True: 2.24k, False: 240]
  ------------------
 9625|  2.24k|    const uint8_t n1 = hex_nibble[static_cast<unsigned char>(*pointer)];
 9626|  2.24k|    if (n1 != 0xff) {
  ------------------
  |  Branch (9626:9): [True: 906, False: 1.33k]
  ------------------
 9627|    906|      v = (v << 4) | n1;
 9628|    906|      ++pointer;
 9629|    906|      ++length;
 9630|    906|      if (pointer != end) {
  ------------------
  |  Branch (9630:11): [True: 852, False: 54]
  ------------------
 9631|    852|        const uint8_t n2 = hex_nibble[static_cast<unsigned char>(*pointer)];
 9632|    852|        if (n2 != 0xff) {
  ------------------
  |  Branch (9632:13): [True: 618, False: 234]
  ------------------
 9633|    618|          v = (v << 4) | n2;
 9634|    618|          ++pointer;
 9635|    618|          ++length;
 9636|    618|          if (pointer != end) {
  ------------------
  |  Branch (9636:15): [True: 501, False: 117]
  ------------------
 9637|    501|            const uint8_t n3 = hex_nibble[static_cast<unsigned char>(*pointer)];
 9638|    501|            if (n3 != 0xff) {
  ------------------
  |  Branch (9638:17): [True: 243, False: 258]
  ------------------
 9639|    243|              v = (v << 4) | n3;
 9640|    243|              ++pointer;
 9641|    243|              ++length;
 9642|    243|            }
 9643|    501|          }
 9644|    618|        }
 9645|    852|      }
 9646|    906|    }
 9647|  2.24k|  }
 9648|  2.48k|  value = static_cast<uint16_t>(v);
 9649|  2.48k|  return length;
 9650|  2.64k|}
_ZN3ada3url10parse_pathENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
10222|  1.90k|ada_really_inline void url::parse_path(std::string_view input) {
10223|  1.90k|  ada_log("parse_path ", input);
10224|  1.90k|  std::string tmp_buffer;
10225|  1.90k|  std::string_view internal_input;
10226|  1.90k|  if (unicode::has_tabs_or_newline(input)) {
  ------------------
  |  Branch (10226:7): [True: 0, False: 1.90k]
  ------------------
10227|      0|    tmp_buffer = input;
10228|       |    // Optimization opportunity: Instead of copying and then pruning, we could
10229|       |    // just directly build the string from user_input.
10230|      0|    helpers::remove_ascii_tab_or_newline(tmp_buffer);
10231|      0|    internal_input = tmp_buffer;
10232|  1.90k|  } else {
10233|  1.90k|    internal_input = input;
10234|  1.90k|  }
10235|       |
10236|       |  // If url is special, then:
10237|  1.90k|  if (is_special()) {
  ------------------
  |  Branch (10237:7): [True: 1.90k, False: 0]
  ------------------
10238|  1.90k|    if (internal_input.empty()) {
  ------------------
  |  Branch (10238:9): [True: 67, False: 1.83k]
  ------------------
10239|     67|      path = "/";
10240|  1.83k|    } else if ((internal_input[0] == '/') || (internal_input[0] == '\\')) {
  ------------------
  |  Branch (10240:16): [True: 1.83k, False: 0]
  |  Branch (10240:46): [True: 0, False: 0]
  ------------------
10241|  1.83k|      helpers::parse_prepared_path(internal_input.substr(1), type, path);
10242|  1.83k|    } else {
10243|      0|      helpers::parse_prepared_path(internal_input, type, path);
10244|      0|    }
10245|  1.90k|  } else if (!internal_input.empty()) {
  ------------------
  |  Branch (10245:14): [True: 0, False: 0]
  ------------------
10246|      0|    if (internal_input[0] == '/') {
  ------------------
  |  Branch (10246:9): [True: 0, False: 0]
  ------------------
10247|      0|      helpers::parse_prepared_path(internal_input.substr(1), type, path);
10248|      0|    } else {
10249|      0|      helpers::parse_prepared_path(internal_input, type, path);
10250|      0|    }
10251|      0|  } else {
10252|      0|    if (!host.has_value()) {
  ------------------
  |  Branch (10252:9): [True: 0, False: 0]
  ------------------
10253|      0|      path = "/";
10254|      0|    }
10255|      0|  }
10256|  1.90k|}
_ZN3ada7unicode13is_alnum_plusEc:
 7079|   174k|ada_really_inline constexpr bool is_alnum_plus(const char c) noexcept {
 7080|   174k|  return is_alnum_plus_table[uint8_t(c)];
 7081|       |  // A table is almost surely much faster than the
 7082|       |  // following under most compilers: return
 7083|       |  // return (std::isalnum(c) || c == '+' || c == '-' || c == '.');
 7084|   174k|}
_ZN3ada7unicode14to_lower_asciiEPcm:
 6761|  39.8k|constexpr bool to_lower_ascii(char* input, size_t length) noexcept {
 6762|  39.8k|  uint64_t broadcast_80 = broadcast(0x80);
 6763|  39.8k|  uint64_t broadcast_Ap = broadcast(128 - 'A');
 6764|  39.8k|  uint64_t broadcast_Zp = broadcast(128 - 'Z' - 1);
 6765|  39.8k|  uint64_t non_ascii = 0;
 6766|  39.8k|  size_t i = 0;
 6767|       |
 6768|  49.4k|  for (; i + 7 < length; i += 8) {
  ------------------
  |  Branch (6768:10): [True: 9.56k, False: 39.8k]
  ------------------
 6769|  9.56k|    uint64_t word{};
 6770|  9.56k|    memcpy(&word, input + i, sizeof(word));
 6771|  9.56k|    non_ascii |= (word & broadcast_80);
 6772|  9.56k|    word ^=
 6773|  9.56k|        (((word + broadcast_Ap) ^ (word + broadcast_Zp)) & broadcast_80) >> 2;
 6774|  9.56k|    memcpy(input + i, &word, sizeof(word));
 6775|  9.56k|  }
 6776|  39.8k|  if (i < length) {
  ------------------
  |  Branch (6776:7): [True: 38.9k, False: 842]
  ------------------
 6777|  38.9k|    uint64_t word{};
 6778|  38.9k|    memcpy(&word, input + i, length - i);
 6779|  38.9k|    non_ascii |= (word & broadcast_80);
 6780|  38.9k|    word ^=
 6781|  38.9k|        (((word + broadcast_Ap) ^ (word + broadcast_Zp)) & broadcast_80) >> 2;
 6782|  38.9k|    memcpy(input + i, &word, length - i);
 6783|  38.9k|  }
 6784|  39.8k|  return non_ascii == 0;
 6785|  39.8k|}
_ZN3ada7unicode9broadcastEh:
 6757|   119k|constexpr uint64_t broadcast(uint8_t v) noexcept {
 6758|   119k|  return 0x101010101010101ull * v;
 6759|   119k|}
_ZZN3ada6parser25try_parse_simple_absoluteINS_3urlEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_ENKUlvE_clEv:
12222|  1.07k|    auto apply_query_and_hash = [&]() {
12223|  1.07k|      if (query_start != std::string_view::npos) {
  ------------------
  |  Branch (12223:11): [True: 96, False: 976]
  ------------------
12224|     96|        const size_t q_end =
12225|     96|            (hash_start != std::string_view::npos) ? hash_start : len;
  ------------------
  |  Branch (12225:13): [True: 23, False: 73]
  ------------------
12226|     96|        out.update_base_search(std::string_view(input.data() + query_start + 1,
12227|     96|                                                q_end - query_start - 1),
12228|     96|                               character_sets::SPECIAL_QUERY_PERCENT_ENCODE);
12229|     96|      }
12230|  1.07k|      if (hash_start != std::string_view::npos) {
  ------------------
  |  Branch (12230:11): [True: 82, False: 990]
  ------------------
12231|     82|        out.update_unencoded_base_hash(std::string_view(
12232|     82|            input.data() + hash_start + 1, len - hash_start - 1));
12233|     82|      }
12234|  1.07k|    };
_ZZN3ada6parser25try_parse_simple_absoluteINS_14url_aggregatorEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_ENKUlvE_clEv:
12222|  1.07k|    auto apply_query_and_hash = [&]() {
12223|  1.07k|      if (query_start != std::string_view::npos) {
  ------------------
  |  Branch (12223:11): [True: 96, False: 976]
  ------------------
12224|     96|        const size_t q_end =
12225|     96|            (hash_start != std::string_view::npos) ? hash_start : len;
  ------------------
  |  Branch (12225:13): [True: 23, False: 73]
  ------------------
12226|     96|        out.update_base_search(std::string_view(input.data() + query_start + 1,
12227|     96|                                                q_end - query_start - 1),
12228|     96|                               character_sets::SPECIAL_QUERY_PERCENT_ENCODE);
12229|     96|      }
12230|  1.07k|      if (hash_start != std::string_view::npos) {
  ------------------
  |  Branch (12230:11): [True: 82, False: 990]
  ------------------
12231|     82|        out.update_unencoded_base_hash(std::string_view(
12232|     82|            input.data() + hash_start + 1, len - hash_start - 1));
12233|     82|      }
12234|  1.07k|    };
_ZZN3ada6parser32finish_simple_absolute_with_portINS_3urlEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_NS_6scheme4typeEjmmmbENKUlvE_clEv:
11822|    832|    auto apply_query_and_hash = [&]() {
11823|    832|      if (query_start != std::string_view::npos) {
  ------------------
  |  Branch (11823:11): [True: 67, False: 765]
  ------------------
11824|     67|        const size_t q_end =
11825|     67|            (hash_start != std::string_view::npos) ? hash_start : len;
  ------------------
  |  Branch (11825:13): [True: 15, False: 52]
  ------------------
11826|     67|        out.update_base_search(std::string_view(input.data() + query_start + 1,
11827|     67|                                                q_end - query_start - 1),
11828|     67|                               character_sets::SPECIAL_QUERY_PERCENT_ENCODE);
11829|     67|      }
11830|    832|      if (hash_start != std::string_view::npos) {
  ------------------
  |  Branch (11830:11): [True: 36, False: 796]
  ------------------
11831|     36|        out.update_unencoded_base_hash(std::string_view(
11832|     36|            input.data() + hash_start + 1, len - hash_start - 1));
11833|     36|      }
11834|    832|    };
_ZZN3ada6parser32finish_simple_absolute_with_portINS_14url_aggregatorEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_NS_6scheme4typeEjmmmbENKUlvE_clEv:
11822|    832|    auto apply_query_and_hash = [&]() {
11823|    832|      if (query_start != std::string_view::npos) {
  ------------------
  |  Branch (11823:11): [True: 67, False: 765]
  ------------------
11824|     67|        const size_t q_end =
11825|     67|            (hash_start != std::string_view::npos) ? hash_start : len;
  ------------------
  |  Branch (11825:13): [True: 15, False: 52]
  ------------------
11826|     67|        out.update_base_search(std::string_view(input.data() + query_start + 1,
11827|     67|                                                q_end - query_start - 1),
11828|     67|                               character_sets::SPECIAL_QUERY_PERCENT_ENCODE);
11829|     67|      }
11830|    832|      if (hash_start != std::string_view::npos) {
  ------------------
  |  Branch (11830:11): [True: 36, False: 796]
  ------------------
11831|     36|        out.update_unencoded_base_hash(std::string_view(
11832|     36|            input.data() + hash_start + 1, len - hash_start - 1));
11833|     36|      }
11834|    832|    };
_ZN3ada7helpers10prune_hashERNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8498|   115k|    std::string_view& input) noexcept {
 8499|       |  // compiles down to 20--30 instructions including a class to memchr (C
 8500|       |  // function). this function should be quite fast.
 8501|   115k|  size_t location_of_first = input.find('#');
 8502|   115k|  if (location_of_first == std::string_view::npos) {
  ------------------
  |  Branch (8502:7): [True: 112k, False: 2.77k]
  ------------------
 8503|   112k|    return std::nullopt;
 8504|   112k|  }
 8505|  2.77k|  std::string_view hash = input;
 8506|  2.77k|  hash.remove_prefix(location_of_first + 1);
 8507|  2.77k|  input.remove_suffix(input.size() - location_of_first);
 8508|  2.77k|  return hash;
 8509|   115k|}
_ZZN3ada6parser14parse_url_implINS_3urlELb1EEET_NSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEPKS3_ENKUlvE_clEv:
12545|  18.3k|  const auto enforce_max_input_length = [&]() {
12546|  18.3k|    if constexpr (store_values) {
12547|  18.3k|      if (url.is_valid) {
  ------------------
  |  Branch (12547:11): [True: 18.3k, False: 0]
  ------------------
12548|       |        if constexpr (result_type_is_ada_url_aggregator) {
12549|       |          if (url.buffer.size() > max_input_length) [[unlikely]] {
12550|       |            url.is_valid = false;
12551|       |          }
12552|  18.3k|        } else {
12553|  18.3k|          if (url.get_href_size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (12553:15): [True: 0, False: 18.3k]
  ------------------
12554|      0|            url.is_valid = false;
12555|      0|          }
12556|  18.3k|        }
12557|  18.3k|      }
12558|  18.3k|    }
12559|  18.3k|  };
_ZN3ada7helpers32find_authority_delimiter_specialENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9451|  24.9k|find_authority_delimiter_special(std::string_view view) noexcept {
 9452|       |  // performance note: we might be able to gain further performance
 9453|       |  // with SIMD intrinsics.
 9454|   160k|  for (auto pos = view.begin(); pos != view.end(); ++pos) {
  ------------------
  |  Branch (9454:33): [True: 157k, False: 2.15k]
  ------------------
 9455|   157k|    if (authority_delimiter_special[(uint8_t)*pos]) {
  ------------------
  |  Branch (9455:9): [True: 22.8k, False: 135k]
  ------------------
 9456|  22.8k|      return pos - view.begin();
 9457|  22.8k|    }
 9458|   157k|  }
 9459|  2.15k|  return size_t(view.size());
 9460|  24.9k|}
_ZN3ada7helpers24find_authority_delimiterENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9472|  1.59k|find_authority_delimiter(std::string_view view) noexcept {
 9473|       |  // performance note: we might be able to gain further performance
 9474|       |  // with SIMD instrinsics.
 9475|  16.6k|  for (auto pos = view.begin(); pos != view.end(); ++pos) {
  ------------------
  |  Branch (9475:33): [True: 16.4k, False: 240]
  ------------------
 9476|  16.4k|    if (authority_delimiter[(uint8_t)*pos]) {
  ------------------
  |  Branch (9476:9): [True: 1.35k, False: 15.0k]
  ------------------
 9477|  1.35k|      return pos - view.begin();
 9478|  1.35k|    }
 9479|  16.4k|  }
 9480|    240|  return size_t(view.size());
 9481|  1.59k|}
_ZN3ada7helpers12shorten_pathERNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS_6scheme4typeE:
 8511|  8.53k|ada_really_inline bool shorten_path(std::string& path, ada::scheme::type type) {
 8512|       |  // Let path be url's path.
 8513|       |  // If url's scheme is "file", path's size is 1, and path[0] is a normalized
 8514|       |  // Windows drive letter, then return.
 8515|  8.53k|  if (type == ada::scheme::type::FILE &&
  ------------------
  |  Branch (8515:7): [True: 3.34k, False: 5.18k]
  ------------------
 8516|  3.34k|      path.find('/', 1) == std::string_view::npos && !path.empty()) {
  ------------------
  |  Branch (8516:7): [True: 2.52k, False: 824]
  |  Branch (8516:54): [True: 1.77k, False: 750]
  ------------------
 8517|  1.77k|    if (checkers::is_normalized_windows_drive_letter(
  ------------------
  |  Branch (8517:9): [True: 751, False: 1.02k]
  ------------------
 8518|  1.77k|            helpers::substring(path, 1))) {
 8519|    751|      return false;
 8520|    751|    }
 8521|  1.77k|  }
 8522|       |
 8523|       |  // Remove path's last item, if any.
 8524|  7.78k|  size_t last_delimiter = path.rfind('/');
 8525|  7.78k|  if (last_delimiter != std::string::npos) {
  ------------------
  |  Branch (8525:7): [True: 3.98k, False: 3.79k]
  ------------------
 8526|  3.98k|    path.erase(last_delimiter);
 8527|  3.98k|    return true;
 8528|  3.98k|  }
 8529|       |
 8530|  3.79k|  return false;
 8531|  7.78k|}
_ZN3ada7helpers27get_host_delimiter_locationEbRNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9164|  39.3k|    const bool is_special, std::string_view& view) noexcept {
 9165|       |  /**
 9166|       |   * The spec at https://url.spec.whatwg.org/#hostname-state expects us to
 9167|       |   * compute a variable called insideBrackets but this variable is only used
 9168|       |   * once, to check whether a ':' character was found outside brackets. Exact
 9169|       |   * text: "Otherwise, if c is U+003A (:) and insideBrackets is false, then:".
 9170|       |   * It is conceptually simpler and arguably more efficient to just return a
 9171|       |   * Boolean indicating whether ':' was found outside brackets.
 9172|       |   */
 9173|  39.3k|  const size_t view_size = view.size();
 9174|  39.3k|  size_t location = 0;
 9175|  39.3k|  bool found_colon = false;
 9176|       |  /**
 9177|       |   * Performance analysis:
 9178|       |   *
 9179|       |   * We are basically seeking the end of the hostname which can be indicated
 9180|       |   * by the end of the view, or by one of the characters ':', '/', '?', '\\'
 9181|       |   * (where '\\' is only applicable for special URLs). However, these must
 9182|       |   * appear outside a bracket range. E.g., if you have [something?]fd: then the
 9183|       |   * '?' does not count.
 9184|       |   *
 9185|       |   * So we can skip ahead to the next delimiter, as long as we include '[' in
 9186|       |   * the set of delimiters, and that we handle it first.
 9187|       |   *
 9188|       |   * So the trick is to have a fast function that locates the next delimiter.
 9189|       |   * Unless we find '[', then it only needs to be called once! Ideally, such a
 9190|       |   * function would be provided by the C++ standard library, but it seems that
 9191|       |   * find_first_of is not very fast, so we are forced to roll our own.
 9192|       |   *
 9193|       |   * We do not break into two loops for speed, but for clarity.
 9194|       |   */
 9195|  39.3k|  if (is_special) {
  ------------------
  |  Branch (9195:7): [True: 36.8k, False: 2.48k]
  ------------------
 9196|       |    // We move to the next delimiter.
 9197|  36.8k|    location = find_next_host_delimiter_special(view, location);
 9198|       |    // Unless we find '[' then we are going only going to have to call
 9199|       |    // find_next_host_delimiter_special once.
 9200|  40.2k|    for (; location < view_size;
  ------------------
  |  Branch (9200:12): [True: 21.2k, False: 18.9k]
  ------------------
 9201|  36.8k|         location = find_next_host_delimiter_special(view, location)) {
 9202|  21.2k|      if (view[location] == '[') {
  ------------------
  |  Branch (9202:11): [True: 3.58k, False: 17.6k]
  ------------------
 9203|  3.58k|        location = view.find(']', location);
 9204|  3.58k|        if (location == std::string_view::npos) {
  ------------------
  |  Branch (9204:13): [True: 225, False: 3.35k]
  ------------------
 9205|       |          // performance: view.find might get translated to a memchr, which
 9206|       |          // has no notion of std::string_view::npos, so the code does not
 9207|       |          // reflect the assembly.
 9208|    225|          location = view_size;
 9209|    225|          break;
 9210|    225|        }
 9211|  17.6k|      } else {
 9212|  17.6k|        found_colon = view[location] == ':';
 9213|  17.6k|        break;
 9214|  17.6k|      }
 9215|  21.2k|    }
 9216|  36.8k|  } else {
 9217|       |    // We move to the next delimiter.
 9218|  2.48k|    location = find_next_host_delimiter(view, location);
 9219|       |    // Unless we find '[' then we are going only going to have to call
 9220|       |    // find_next_host_delimiter_special once.
 9221|  4.10k|    for (; location < view_size;
  ------------------
  |  Branch (9221:12): [True: 2.52k, False: 1.57k]
  ------------------
 9222|  2.52k|         location = find_next_host_delimiter(view, location)) {
 9223|  2.52k|      if (view[location] == '[') {
  ------------------
  |  Branch (9223:11): [True: 1.69k, False: 831]
  ------------------
 9224|  1.69k|        location = view.find(']', location);
 9225|  1.69k|        if (location == std::string_view::npos) {
  ------------------
  |  Branch (9225:13): [True: 75, False: 1.62k]
  ------------------
 9226|       |          // performance: view.find might get translated to a memchr, which
 9227|       |          // has no notion of std::string_view::npos, so the code does not
 9228|       |          // reflect the assembly.
 9229|     75|          location = view_size;
 9230|     75|          break;
 9231|     75|        }
 9232|  1.69k|      } else {
 9233|    831|        found_colon = view[location] == ':';
 9234|    831|        break;
 9235|    831|      }
 9236|  2.52k|    }
 9237|  2.48k|  }
 9238|       |  // performance: remove_suffix may translate into a single instruction.
 9239|  39.3k|  view.remove_suffix(view_size - location);
 9240|  39.3k|  return {location, found_colon};
 9241|  39.3k|}
_ZN3ada7helpers32find_next_host_delimiter_specialENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEm:
 8754|  40.2k|    std::string_view view, size_t location) noexcept {
 8755|       |  // first check for short strings in which case we do it naively.
 8756|  40.2k|  if (view.size() - location < 16) {  // slow path
  ------------------
  |  Branch (8756:7): [True: 27.2k, False: 12.9k]
  ------------------
 8757|   150k|    for (size_t i = location; i < view.size(); i++) {
  ------------------
  |  Branch (8757:31): [True: 136k, False: 13.7k]
  ------------------
 8758|   136k|      if (view[i] == ':' || view[i] == '/' || view[i] == '\\' ||
  ------------------
  |  Branch (8758:11): [True: 4.84k, False: 132k]
  |  Branch (8758:29): [True: 6.35k, False: 125k]
  |  Branch (8758:47): [True: 37, False: 125k]
  ------------------
 8759|   125k|          view[i] == '?' || view[i] == '[') {
  ------------------
  |  Branch (8759:11): [True: 583, False: 125k]
  |  Branch (8759:29): [True: 1.65k, False: 123k]
  ------------------
 8760|  13.4k|        return i;
 8761|  13.4k|      }
 8762|   136k|    }
 8763|  13.7k|    return size_t(view.size());
 8764|  27.2k|  }
 8765|       |  // fast path for long strings (expected to be common)
 8766|  12.9k|  size_t i = location;
 8767|  12.9k|  const __m128i mask1 = _mm_set1_epi8(':');
 8768|  12.9k|  const __m128i mask2 = _mm_set1_epi8('/');
 8769|  12.9k|  const __m128i mask3 = _mm_set1_epi8('\\');
 8770|  12.9k|  const __m128i mask4 = _mm_set1_epi8('?');
 8771|  12.9k|  const __m128i mask5 = _mm_set1_epi8('[');
 8772|       |
 8773|  54.7k|  for (; i + 15 < view.size(); i += 16) {
  ------------------
  |  Branch (8773:10): [True: 46.7k, False: 8.04k]
  ------------------
 8774|  46.7k|    __m128i word = _mm_loadu_si128((const __m128i*)(view.data() + i));
 8775|  46.7k|    __m128i m1 = _mm_cmpeq_epi8(word, mask1);
 8776|  46.7k|    __m128i m2 = _mm_cmpeq_epi8(word, mask2);
 8777|  46.7k|    __m128i m3 = _mm_cmpeq_epi8(word, mask3);
 8778|  46.7k|    __m128i m4 = _mm_cmpeq_epi8(word, mask4);
 8779|  46.7k|    __m128i m5 = _mm_cmpeq_epi8(word, mask5);
 8780|  46.7k|    __m128i m = _mm_or_si128(
 8781|  46.7k|        _mm_or_si128(_mm_or_si128(m1, m2), _mm_or_si128(m3, m4)), m5);
 8782|  46.7k|    int mask = _mm_movemask_epi8(m);
 8783|  46.7k|    if (mask != 0) {
  ------------------
  |  Branch (8783:9): [True: 4.93k, False: 41.8k]
  ------------------
 8784|  4.93k|      return i + trailing_zeroes(mask);
 8785|  4.93k|    }
 8786|  46.7k|  }
 8787|  8.04k|  if (i < view.size()) {
  ------------------
  |  Branch (8787:7): [True: 7.44k, False: 606]
  ------------------
 8788|  7.44k|    __m128i word =
 8789|  7.44k|        _mm_loadu_si128((const __m128i*)(view.data() + view.length() - 16));
 8790|  7.44k|    __m128i m1 = _mm_cmpeq_epi8(word, mask1);
 8791|  7.44k|    __m128i m2 = _mm_cmpeq_epi8(word, mask2);
 8792|  7.44k|    __m128i m3 = _mm_cmpeq_epi8(word, mask3);
 8793|  7.44k|    __m128i m4 = _mm_cmpeq_epi8(word, mask4);
 8794|  7.44k|    __m128i m5 = _mm_cmpeq_epi8(word, mask5);
 8795|  7.44k|    __m128i m = _mm_or_si128(
 8796|  7.44k|        _mm_or_si128(_mm_or_si128(m1, m2), _mm_or_si128(m3, m4)), m5);
 8797|  7.44k|    int mask = _mm_movemask_epi8(m);
 8798|  7.44k|    if (mask != 0) {
  ------------------
  |  Branch (8798:9): [True: 2.84k, False: 4.59k]
  ------------------
 8799|  2.84k|      return view.length() - 16 + trailing_zeroes(mask);
 8800|  2.84k|    }
 8801|  7.44k|  }
 8802|  5.20k|  return size_t(view.length());
 8803|  8.04k|}
_ZN3ada7helpers15trailing_zeroesEj:
 8579|  9.29k|ada_really_inline int trailing_zeroes(uint32_t input_num) noexcept {
 8580|       |#ifdef ADA_REGULAR_VISUAL_STUDIO
 8581|       |  unsigned long ret;
 8582|       |  // Search the mask data from least significant bit (LSB)
 8583|       |  // to the most significant bit (MSB) for a set bit (1).
 8584|       |  _BitScanForward(&ret, input_num);
 8585|       |  return (int)ret;
 8586|       |#else   // ADA_REGULAR_VISUAL_STUDIO
 8587|  9.29k|  return __builtin_ctzl(input_num);
 8588|  9.29k|#endif  // ADA_REGULAR_VISUAL_STUDIO
 8589|  9.29k|}
_ZN3ada7helpers24find_next_host_delimiterENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEm:
 9030|  4.10k|                                                  size_t location) noexcept {
 9031|       |  // first check for short strings in which case we do it naively.
 9032|  4.10k|  if (view.size() - location < 16) {  // slow path
  ------------------
  |  Branch (9032:7): [True: 2.02k, False: 2.07k]
  ------------------
 9033|  5.50k|    for (size_t i = location; i < view.size(); i++) {
  ------------------
  |  Branch (9033:31): [True: 4.49k, False: 1.01k]
  ------------------
 9034|  4.49k|      if (view[i] == ':' || view[i] == '/' || view[i] == '?' ||
  ------------------
  |  Branch (9034:11): [True: 228, False: 4.26k]
  |  Branch (9034:29): [True: 180, False: 4.08k]
  |  Branch (9034:47): [True: 114, False: 3.96k]
  ------------------
 9035|  3.96k|          view[i] == '[') {
  ------------------
  |  Branch (9035:11): [True: 489, False: 3.48k]
  ------------------
 9036|  1.01k|        return i;
 9037|  1.01k|      }
 9038|  4.49k|    }
 9039|  1.01k|    return size_t(view.size());
 9040|  2.02k|  }
 9041|       |  // fast path for long strings (expected to be common)
 9042|  2.07k|  size_t i = location;
 9043|  2.07k|  const __m128i mask1 = _mm_set1_epi8(':');
 9044|  2.07k|  const __m128i mask2 = _mm_set1_epi8('/');
 9045|  2.07k|  const __m128i mask4 = _mm_set1_epi8('?');
 9046|  2.07k|  const __m128i mask5 = _mm_set1_epi8('[');
 9047|       |
 9048|  5.76k|  for (; i + 15 < view.size(); i += 16) {
  ------------------
  |  Branch (9048:10): [True: 5.06k, False: 699]
  ------------------
 9049|  5.06k|    __m128i word = _mm_loadu_si128((const __m128i*)(view.data() + i));
 9050|  5.06k|    __m128i m1 = _mm_cmpeq_epi8(word, mask1);
 9051|  5.06k|    __m128i m2 = _mm_cmpeq_epi8(word, mask2);
 9052|  5.06k|    __m128i m4 = _mm_cmpeq_epi8(word, mask4);
 9053|  5.06k|    __m128i m5 = _mm_cmpeq_epi8(word, mask5);
 9054|  5.06k|    __m128i m = _mm_or_si128(_mm_or_si128(m1, m2), _mm_or_si128(m4, m5));
 9055|  5.06k|    int mask = _mm_movemask_epi8(m);
 9056|  5.06k|    if (mask != 0) {
  ------------------
  |  Branch (9056:9): [True: 1.38k, False: 3.68k]
  ------------------
 9057|  1.38k|      return i + trailing_zeroes(mask);
 9058|  1.38k|    }
 9059|  5.06k|  }
 9060|    699|  if (i < view.size()) {
  ------------------
  |  Branch (9060:7): [True: 456, False: 243]
  ------------------
 9061|    456|    __m128i word =
 9062|    456|        _mm_loadu_si128((const __m128i*)(view.data() + view.length() - 16));
 9063|    456|    __m128i m1 = _mm_cmpeq_epi8(word, mask1);
 9064|    456|    __m128i m2 = _mm_cmpeq_epi8(word, mask2);
 9065|    456|    __m128i m4 = _mm_cmpeq_epi8(word, mask4);
 9066|    456|    __m128i m5 = _mm_cmpeq_epi8(word, mask5);
 9067|    456|    __m128i m = _mm_or_si128(_mm_or_si128(m1, m2), _mm_or_si128(m4, m5));
 9068|    456|    int mask = _mm_movemask_epi8(m);
 9069|    456|    if (mask != 0) {
  ------------------
  |  Branch (9069:9): [True: 135, False: 321]
  ------------------
 9070|    135|      return view.length() - 16 + trailing_zeroes(mask);
 9071|    135|    }
 9072|    456|  }
 9073|    564|  return size_t(view.length());
 9074|    699|}
_ZN3ada3url10parse_hostENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
10113|  14.8k|ada_really_inline bool url::parse_host(std::string_view input) {
10114|  14.8k|  ada_log("parse_host ", input, " [", input.size(), " bytes]");
10115|  14.8k|  if (input.empty()) {
  ------------------
  |  Branch (10115:7): [True: 17, False: 14.8k]
  ------------------
10116|     17|    return is_valid = false;
10117|     17|  }  // technically unnecessary.
10118|       |  // If input starts with U+005B ([), then:
10119|  14.8k|  if (input[0] == '[') {
  ------------------
  |  Branch (10119:7): [True: 707, False: 14.1k]
  ------------------
10120|       |    // If input does not end with U+005D (]), validation error, return failure.
10121|    707|    if (input.back() != ']') {
  ------------------
  |  Branch (10121:9): [True: 170, False: 537]
  ------------------
10122|    170|      return is_valid = false;
10123|    170|    }
10124|    537|    ada_log("parse_host ipv6");
10125|       |
10126|       |    // Return the result of IPv6 parsing input with its leading U+005B ([) and
10127|       |    // trailing U+005D (]) removed.
10128|    537|    input.remove_prefix(1);
10129|    537|    input.remove_suffix(1);
10130|    537|    return parse_ipv6(input);
10131|    707|  }
10132|       |
10133|       |  // If isNotSpecial is true, then return the result of opaque-host parsing
10134|       |  // input.
10135|  14.1k|  if (!is_special()) {
  ------------------
  |  Branch (10135:7): [True: 564, False: 13.5k]
  ------------------
10136|    564|    return parse_opaque_host(input);
10137|    564|  }
10138|       |
10139|       |  // Fast path: try to parse as pure decimal IPv4 first.
10140|  13.5k|  const uint64_t fast_result = checkers::try_parse_ipv4_fast(input);
10141|  13.5k|  if (fast_result < checkers::ipv4_fast_fail) {
  ------------------
  |  Branch (10141:7): [True: 1.01k, False: 12.5k]
  ------------------
10142|  1.01k|    if (!input.empty() && input.back() == '.') {
  ------------------
  |  Branch (10142:9): [True: 1.01k, False: 0]
  |  Branch (10142:27): [True: 25, False: 994]
  ------------------
10143|     25|      host = input.substr(0, input.size() - 1);
10144|    994|    } else {
10145|    994|      host = input;
10146|    994|    }
10147|  1.01k|    host_type = IPV4;
10148|  1.01k|    is_valid = true;
10149|  1.01k|    ada_log("parse_host fast path decimal ipv4");
10150|  1.01k|    return true;
10151|  1.01k|  }
10152|       |  // Let domain be the result of running UTF-8 decode without BOM on the
10153|       |  // percent-decoding of input. Let asciiDomain be the result of running domain
10154|       |  // to ASCII with domain and false. The most common case is an ASCII input, in
10155|       |  // which case we do not need to call the expensive 'to_ascii' if a few
10156|       |  // conditions are met: no '%' and no 'xn-' subsequence.
10157|  12.5k|  const uint8_t forbidden_or_upper =
10158|  12.5k|      unicode::contains_forbidden_domain_code_point_or_upper(input.data(),
10159|  12.5k|                                                             input.size());
10160|  12.5k|  static constexpr std::string_view xn_dash{"xn-", 3};
10161|  12.5k|  if ((forbidden_or_upper & 1) == 0) {
  ------------------
  |  Branch (10161:7): [True: 7.12k, False: 5.41k]
  ------------------
10162|  7.12k|    host = std::string(input);
10163|  7.12k|    if ((forbidden_or_upper & 2) != 0) {
  ------------------
  |  Branch (10163:9): [True: 1.32k, False: 5.80k]
  ------------------
10164|  1.32k|      unicode::to_lower_ascii(host->data(), host->size());
10165|  1.32k|    }
10166|  7.12k|    if (host->find('-') == std::string_view::npos ||
  ------------------
  |  Branch (10166:9): [True: 4.94k, False: 2.18k]
  ------------------
10167|  5.25k|        host->find(xn_dash) == std::string_view::npos) {
  ------------------
  |  Branch (10167:9): [True: 315, False: 1.86k]
  ------------------
10168|  5.25k|      if (checkers::is_ipv4(*host)) {
  ------------------
  |  Branch (10168:11): [True: 1.38k, False: 3.86k]
  ------------------
10169|  1.38k|        ada_log("parse_host fast path ipv4");
10170|  1.38k|        return parse_ipv4(*host);
10171|  1.38k|      }
10172|  3.86k|      ada_log("parse_host fast path ", *host);
10173|  3.86k|      is_valid = true;
10174|  3.86k|      return true;
10175|  5.25k|    }
10176|  7.12k|  } else if (const size_t first_percent = input.find('%');
10177|  5.41k|             first_percent != std::string_view::npos) {
  ------------------
  |  Branch (10177:14): [True: 1.00k, False: 4.40k]
  ------------------
10178|  1.00k|    std::string decoded = unicode::percent_decode(input, first_percent);
10179|  1.00k|    const uint8_t decoded_flags =
10180|  1.00k|        unicode::contains_forbidden_domain_code_point_or_upper(decoded.data(),
10181|  1.00k|                                                               decoded.size());
10182|  1.00k|    if ((decoded_flags & 1) == 0) {
  ------------------
  |  Branch (10182:9): [True: 666, False: 343]
  ------------------
10183|    666|      if ((decoded_flags & 2) != 0) {
  ------------------
  |  Branch (10183:11): [True: 260, False: 406]
  ------------------
10184|    260|        unicode::to_lower_ascii(decoded.data(), decoded.size());
10185|    260|      }
10186|    666|      if (decoded.find('-') == std::string_view::npos ||
  ------------------
  |  Branch (10186:11): [True: 574, False: 92]
  ------------------
10187|    618|          decoded.find(xn_dash) == std::string_view::npos) {
  ------------------
  |  Branch (10187:11): [True: 44, False: 48]
  ------------------
10188|    618|        host = std::move(decoded);
10189|    618|        if (checkers::is_ipv4(*host)) {
  ------------------
  |  Branch (10189:13): [True: 280, False: 338]
  ------------------
10190|    280|          return parse_ipv4(*host);
10191|    280|        }
10192|    338|        is_valid = true;
10193|    338|        return true;
10194|    618|      }
10195|    666|    }
10196|  1.00k|  }
10197|  6.66k|  ada_log("parse_host calling to_ascii");
10198|  6.66k|  is_valid = ada::unicode::to_ascii(host, input, input.find('%'));
10199|  6.66k|  if (!is_valid || !host.has_value()) {
  ------------------
  |  Branch (10199:7): [True: 2.18k, False: 4.47k]
  |  Branch (10199:20): [True: 0, False: 4.47k]
  ------------------
10200|  2.18k|    ada_log("parse_host to_ascii returns false");
10201|  2.18k|    return is_valid = false;
10202|  2.18k|  }
10203|  4.47k|  ada_log("parse_host to_ascii succeeded ", *host, " [", host->size(),
10204|  4.47k|          " bytes]");
10205|       |
10206|  4.47k|  if (std::any_of(host->begin(), host->end(),
  ------------------
  |  Branch (10206:7): [True: 0, False: 4.47k]
  ------------------
10207|  4.47k|                  ada::unicode::is_forbidden_domain_code_point)) {
10208|      0|    host = std::nullopt;
10209|      0|    return is_valid = false;
10210|      0|  }
10211|       |
10212|       |  // If asciiDomain ends in a number, then return the result of IPv4 parsing
10213|       |  // asciiDomain.
10214|  4.47k|  if (checkers::is_ipv4(*host)) {
  ------------------
  |  Branch (10214:7): [True: 205, False: 4.27k]
  ------------------
10215|    205|    ada_log("parse_host got ipv4 ", *host);
10216|    205|    return parse_ipv4(*host);
10217|    205|  }
10218|       |
10219|  4.27k|  return true;
10220|  4.47k|}
_ZN3ada7unicode45contains_forbidden_domain_code_point_or_upperEPKcm:
 7049|  41.1k|                                              size_t length) noexcept {
 7050|  41.1k|  size_t i = 0;
 7051|  41.1k|  uint8_t accumulator{};
 7052|   286k|  for (; i + 4 <= length; i += 4) {
  ------------------
  |  Branch (7052:10): [True: 245k, False: 41.1k]
  ------------------
 7053|   245k|    accumulator |=
 7054|   245k|        is_forbidden_domain_code_point_table_or_upper[uint8_t(input[i])];
 7055|   245k|    accumulator |=
 7056|   245k|        is_forbidden_domain_code_point_table_or_upper[uint8_t(input[i + 1])];
 7057|   245k|    accumulator |=
 7058|   245k|        is_forbidden_domain_code_point_table_or_upper[uint8_t(input[i + 2])];
 7059|   245k|    accumulator |=
 7060|   245k|        is_forbidden_domain_code_point_table_or_upper[uint8_t(input[i + 3])];
 7061|   245k|  }
 7062|   101k|  for (; i < length; i++) {
  ------------------
  |  Branch (7062:10): [True: 60.8k, False: 41.1k]
  ------------------
 7063|  60.8k|    accumulator |=
 7064|  60.8k|        is_forbidden_domain_code_point_table_or_upper[uint8_t(input[i])];
 7065|  60.8k|  }
 7066|  41.1k|  return accumulator;
 7067|  41.1k|}
_ZN3ada7unicode30is_forbidden_domain_code_pointEc:
 7008|  1.08M|    const char c) noexcept {
 7009|  1.08M|  return is_forbidden_domain_code_point_table[uint8_t(c)];
 7010|  1.08M|}
_ZN3ada7helpers6resizeERNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEm:
 8572|     26|ada_really_inline void resize(std::string_view& input, size_t pos) noexcept {
 8573|     26|  ADA_ASSERT_TRUE(pos <= input.size());
 8574|     26|  input.remove_suffix(input.size() - pos);
 8575|     26|}
_ZZN3ada6parser14parse_url_implINS_14url_aggregatorELb1EEET_NSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEPKS3_ENKUlvE_clEv:
12545|  18.3k|  const auto enforce_max_input_length = [&]() {
12546|  18.3k|    if constexpr (store_values) {
12547|  18.3k|      if (url.is_valid) {
  ------------------
  |  Branch (12547:11): [True: 18.3k, False: 0]
  ------------------
12548|  18.3k|        if constexpr (result_type_is_ada_url_aggregator) {
12549|  18.3k|          if (url.buffer.size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (12549:15): [True: 0, False: 18.3k]
  ------------------
12550|      0|            url.is_valid = false;
12551|      0|          }
12552|       |        } else {
12553|       |          if (url.get_href_size() > max_input_length) [[unlikely]] {
12554|       |            url.is_valid = false;
12555|       |          }
12556|       |        }
12557|  18.3k|      }
12558|  18.3k|    }
12559|  18.3k|  };
_ZN3ada7helpers12shorten_pathERNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEENS_6scheme4typeE:
 8534|  1.01k|                                    ada::scheme::type type) {
 8535|       |  // Let path be url's path.
 8536|       |  // If url's scheme is "file", path's size is 1, and path[0] is a normalized
 8537|       |  // Windows drive letter, then return.
 8538|  1.01k|  if (type == ada::scheme::type::FILE &&
  ------------------
  |  Branch (8538:7): [True: 226, False: 793]
  ------------------
 8539|    226|      path.find('/', 1) == std::string_view::npos && !path.empty()) {
  ------------------
  |  Branch (8539:7): [True: 202, False: 24]
  |  Branch (8539:54): [True: 89, False: 113]
  ------------------
 8540|     89|    if (checkers::is_normalized_windows_drive_letter(
  ------------------
  |  Branch (8540:9): [True: 7, False: 82]
  ------------------
 8541|     89|            helpers::substring(path, 1))) {
 8542|      7|      return false;
 8543|      7|    }
 8544|     89|  }
 8545|       |
 8546|       |  // Remove path's last item, if any.
 8547|  1.01k|  if (!path.empty()) {
  ------------------
  |  Branch (8547:7): [True: 455, False: 557]
  ------------------
 8548|    455|    size_t slash_loc = path.rfind('/');
 8549|    455|    if (slash_loc != std::string_view::npos) {
  ------------------
  |  Branch (8549:9): [True: 455, False: 0]
  ------------------
 8550|    455|      path.remove_suffix(path.size() - slash_loc);
 8551|    455|      return true;
 8552|    455|    }
 8553|    455|  }
 8554|       |
 8555|    557|  return false;
 8556|  1.01k|}
_ZZN3ada6parser14parse_url_implINS_14url_aggregatorELb0EEET_NSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEPKS3_ENKUlvE_clEv:
12545|    335|  const auto enforce_max_input_length = [&]() {
12546|       |    if constexpr (store_values) {
12547|       |      if (url.is_valid) {
12548|       |        if constexpr (result_type_is_ada_url_aggregator) {
12549|       |          if (url.buffer.size() > max_input_length) [[unlikely]] {
12550|       |            url.is_valid = false;
12551|       |          }
12552|       |        } else {
12553|       |          if (url.get_href_size() > max_input_length) [[unlikely]] {
12554|       |            url.is_valid = false;
12555|       |          }
12556|       |        }
12557|       |      }
12558|       |    }
12559|    335|  };
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_124port_decimal_digit_countEj:
10875|  1.24k|ada_really_inline uint32_t port_decimal_digit_count(uint32_t port) noexcept {
10876|  1.24k|  uint32_t digits = 1;
10877|  1.85k|  while (port >= 10) {
  ------------------
  |  Branch (10877:10): [True: 612, False: 1.24k]
  ------------------
10878|    612|    port /= 10;
10879|    612|    ++digits;
10880|    612|  }
10881|  1.24k|  return digits;
10882|  1.24k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_121append_canonical_portERNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEj:
10885|    423|                                             uint32_t port) {
10886|    423|  buffer += ':';
10887|    423|  char port_buf[5];
10888|    423|  auto [ptr, ec] = std::to_chars(port_buf, port_buf + 5, port);
10889|    423|  (void)ec;
10890|    423|  buffer.append(port_buf, static_cast<size_t>(ptr - port_buf));
10891|    423|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_116authority_has_atEPKhmm:
11033|  5.06k|                                        size_t n) noexcept {
11034|  5.06k|  const size_t rem = n - host_start;
11035|  5.06k|  if (rem == 0) {
  ------------------
  |  Branch (11035:7): [True: 0, False: 5.06k]
  ------------------
11036|      0|    return false;
11037|      0|  }
11038|       |#if ADA_NEON
11039|       |  if (rem >= 16) {
11040|       |    const uint8x16_t w = vld1q_u8(p + host_start);
11041|       |    const uint64_t at = neon_nibble_bits(vceqq_u8(w, vdupq_n_u8('@')));
11042|       |    if (at == 0) {
11043|       |      return false;
11044|       |    }
11045|       |    const uint64_t delim = neon_nibble_bits(vceqq_u8(w, vdupq_n_u8('/'))) |
11046|       |                           neon_nibble_bits(vceqq_u8(w, vdupq_n_u8('?'))) |
11047|       |                           neon_nibble_bits(vceqq_u8(w, vdupq_n_u8('#')));
11048|       |    return delim == 0 || std::countr_zero(at) < std::countr_zero(delim);
11049|       |  }
11050|       |#elif ADA_SSE2
11051|  5.06k|  if (rem >= 16) {
  ------------------
  |  Branch (11051:7): [True: 1.66k, False: 3.40k]
  ------------------
11052|  1.66k|    const __m128i w =
11053|  1.66k|        _mm_loadu_si128(reinterpret_cast<const __m128i*>(p + host_start));
11054|  1.66k|    const uint16_t at = static_cast<uint16_t>(
11055|  1.66k|        _mm_movemask_epi8(_mm_cmpeq_epi8(w, _mm_set1_epi8('@'))));
11056|  1.66k|    if (at == 0) {
  ------------------
  |  Branch (11056:9): [True: 1.58k, False: 74]
  ------------------
11057|  1.58k|      return false;
11058|  1.58k|    }
11059|     74|    const uint16_t delim = static_cast<uint16_t>(
11060|     74|        _mm_movemask_epi8(_mm_cmpeq_epi8(w, _mm_set1_epi8('/'))) |
11061|     74|        _mm_movemask_epi8(_mm_cmpeq_epi8(w, _mm_set1_epi8('?'))) |
11062|     74|        _mm_movemask_epi8(_mm_cmpeq_epi8(w, _mm_set1_epi8('#'))));
11063|     74|    return delim == 0 || std::countr_zero(at) < std::countr_zero(delim);
  ------------------
  |  Branch (11063:12): [True: 16, False: 58]
  |  Branch (11063:26): [True: 2, False: 56]
  ------------------
11064|  1.66k|  }
11065|  3.40k|#endif
11066|  3.40k|  const size_t lim = host_start + rem;
11067|  17.5k|  for (size_t i = host_start; i < lim; ++i) {
  ------------------
  |  Branch (11067:31): [True: 15.9k, False: 1.56k]
  ------------------
11068|  15.9k|    const uint8_t c = p[i];
11069|  15.9k|    if (c == '@') {
  ------------------
  |  Branch (11069:9): [True: 20, False: 15.9k]
  ------------------
11070|     20|      return true;
11071|     20|    }
11072|  15.9k|    if (c == '/' || c == '?' || c == '#') {
  ------------------
  |  Branch (11072:9): [True: 1.76k, False: 14.2k]
  |  Branch (11072:21): [True: 36, False: 14.1k]
  |  Branch (11072:33): [True: 18, False: 14.1k]
  ------------------
11073|  1.81k|      return false;
11074|  1.81k|    }
11075|  15.9k|  }
11076|  1.56k|  return false;
11077|  3.40k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_115scan_plain_hostEPKhmmRmRbS5_:
11084|  12.1k|                                     bool& has_x) noexcept {
11085|  12.1k|  has_upper = false;
11086|  12.1k|  has_x = false;
11087|  12.1k|  size_t i = start;
11088|  12.1k|#if ADA_PARSER_SSSE3
11089|  12.1k|  if (len - start >= 16) {
  ------------------
  |  Branch (11089:7): [True: 5.33k, False: 6.86k]
  ------------------
11090|  5.33k|    const __m128i lo_tbl = nibble_load(k_host_nibbles.low);
11091|  5.33k|    const __m128i hi_tbl = nibble_load(k_host_nibbles.high);
11092|  5.33k|    const __m128i x_splat = _mm_set1_epi8('x');
11093|  5.33k|    auto visit = [&](size_t at) noexcept -> bool {
11094|  5.33k|      const __m128i w =
11095|  5.33k|          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + at));
11096|  5.33k|      const int up = sse2_uppercase(w);
11097|  5.33k|      const int xs = _mm_movemask_epi8(_mm_cmpeq_epi8(w, x_splat));
11098|  5.33k|      const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);
11099|  5.33k|      if (mask == 0) {
11100|  5.33k|        if (up != 0) {
11101|  5.33k|          has_upper = true;
11102|  5.33k|        }
11103|  5.33k|        if (xs != 0) {
11104|  5.33k|          has_x = true;
11105|  5.33k|        }
11106|  5.33k|        return false;
11107|  5.33k|      }
11108|  5.33k|      const int hit = trailing_zeroes32(static_cast<uint32_t>(mask));
11109|  5.33k|      const int valid = (1 << hit) - 1;
11110|  5.33k|      if ((up & valid) != 0) {
11111|  5.33k|        has_upper = true;
11112|  5.33k|      }
11113|  5.33k|      if ((xs & valid) != 0) {
11114|  5.33k|        has_x = true;
11115|  5.33k|      }
11116|  5.33k|      end = at + static_cast<size_t>(hit);
11117|  5.33k|      return true;
11118|  5.33k|    };
11119|  11.1k|    for (; i + 32 <= len; i += 32) {
  ------------------
  |  Branch (11119:12): [True: 7.99k, False: 3.12k]
  ------------------
11120|  7.99k|      if (visit(i) || visit(i + 16)) {
  ------------------
  |  Branch (11120:11): [True: 2.01k, False: 5.97k]
  |  Branch (11120:23): [True: 188, False: 5.79k]
  ------------------
11121|  2.20k|        return k_host_class[b[end]] == 1;
11122|  2.20k|      }
11123|  7.99k|    }
11124|  4.29k|    for (; i + 16 <= len; i += 16) {
  ------------------
  |  Branch (11124:12): [True: 2.56k, False: 1.72k]
  ------------------
11125|  2.56k|      if (visit(i)) {
  ------------------
  |  Branch (11125:11): [True: 1.39k, False: 1.16k]
  ------------------
11126|  1.39k|        return k_host_class[b[end]] == 1;
11127|  1.39k|      }
11128|  2.56k|    }
11129|       |    // Overlapping tail only after a full 16-byte step so the window cannot
11130|       |    // start before `start` (a prior '/' would otherwise look like a host stop).
11131|  1.72k|    if (i > start && i < len) {
  ------------------
  |  Branch (11131:9): [True: 1.72k, False: 0]
  |  Branch (11131:22): [True: 1.67k, False: 52]
  ------------------
11132|  1.67k|      if (visit(len - 16) && end >= i) {
  ------------------
  |  Branch (11132:11): [True: 1.62k, False: 52]
  |  Branch (11132:30): [True: 1.62k, False: 0]
  ------------------
11133|  1.62k|        return k_host_class[b[end]] == 1;
11134|  1.62k|      }
11135|     52|      end = len;
11136|     52|      return true;
11137|  1.67k|    }
11138|  1.72k|  }
11139|       |#elif ADA_SSE2
11140|       |  const __m128i x_splat = _mm_set1_epi8('x');
11141|       |  for (; i + 32 <= len; i += 32) {
11142|       |    for (size_t off = 0; off < 32; off += 16) {
11143|       |      const __m128i w =
11144|       |          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i + off));
11145|       |      const int up = sse2_uppercase(w);
11146|       |      const int xs = _mm_movemask_epi8(_mm_cmpeq_epi8(w, x_splat));
11147|       |      const int mask = sse2_host_stop(w);
11148|       |      if (mask != 0) {
11149|       |        const int hit = trailing_zeroes32(static_cast<uint32_t>(mask));
11150|       |        const int valid = (1 << hit) - 1;
11151|       |        if ((up & valid) != 0) {
11152|       |          has_upper = true;
11153|       |        }
11154|       |        if ((xs & valid) != 0) {
11155|       |          has_x = true;
11156|       |        }
11157|       |        end = i + off + static_cast<size_t>(hit);
11158|       |        return k_host_class[b[end]] == 1;
11159|       |      }
11160|       |      if (up != 0) {
11161|       |        has_upper = true;
11162|       |      }
11163|       |      if (xs != 0) {
11164|       |        has_x = true;
11165|       |      }
11166|       |    }
11167|       |  }
11168|       |  for (; i + 16 <= len; i += 16) {
11169|       |    const __m128i w = _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));
11170|       |    const int up = sse2_uppercase(w);
11171|       |    const int xs = _mm_movemask_epi8(_mm_cmpeq_epi8(w, x_splat));
11172|       |    const int mask = sse2_host_stop(w);
11173|       |    if (mask != 0) {
11174|       |      const int hit = trailing_zeroes32(static_cast<uint32_t>(mask));
11175|       |      const int valid = (1 << hit) - 1;
11176|       |      if ((up & valid) != 0) {
11177|       |        has_upper = true;
11178|       |      }
11179|       |      if ((xs & valid) != 0) {
11180|       |        has_x = true;
11181|       |      }
11182|       |      end = i + static_cast<size_t>(hit);
11183|       |      return k_host_class[b[end]] == 1;
11184|       |    }
11185|       |    if (up != 0) {
11186|       |      has_upper = true;
11187|       |    }
11188|       |    if (xs != 0) {
11189|       |      has_x = true;
11190|       |    }
11191|       |  }
11192|       |#elif ADA_NEON
11193|       |  if (len - start >= 16) {
11194|       |    const uint8x16_t lo_tbl = vld1q_u8(k_host_nibbles.low);
11195|       |    const uint8x16_t hi_tbl = vld1q_u8(k_host_nibbles.high);
11196|       |    const uint8x16_t x_splat = vdupq_n_u8('x');
11197|       |    auto visit = [&](size_t at) noexcept -> bool {
11198|       |      const uint8x16_t w = vld1q_u8(b + at);
11199|       |      const uint64_t up = neon_uppercase(w);
11200|       |      const uint64_t xs = neon_nibble_bits(vceqq_u8(w, x_splat));
11201|       |      const uint64_t bits = neon_table_stop(w, lo_tbl, hi_tbl);
11202|       |      if (bits == 0) {
11203|       |        if (up != 0) {
11204|       |          has_upper = true;
11205|       |        }
11206|       |        if (xs != 0) {
11207|       |          has_x = true;
11208|       |        }
11209|       |        return false;
11210|       |      }
11211|       |      const size_t hit = static_cast<size_t>(trailing_zeroes64(bits)) >> 2;
11212|       |      const uint64_t valid = (hit == 0) ? 0 : (uint64_t{1} << (hit * 4)) - 1;
11213|       |      if ((up & valid) != 0) {
11214|       |        has_upper = true;
11215|       |      }
11216|       |      if ((xs & valid) != 0) {
11217|       |        has_x = true;
11218|       |      }
11219|       |      end = at + hit;
11220|       |      return true;
11221|       |    };
11222|       |    for (; i + 32 <= len; i += 32) {
11223|       |      if (visit(i) || visit(i + 16)) {
11224|       |        return k_host_class[b[end]] == 1;
11225|       |      }
11226|       |    }
11227|       |    for (; i + 16 <= len; i += 16) {
11228|       |      if (visit(i)) {
11229|       |        return k_host_class[b[end]] == 1;
11230|       |      }
11231|       |    }
11232|       |    if (i > start && i < len) {
11233|       |      if (visit(len - 16) && end >= i) {
11234|       |        return k_host_class[b[end]] == 1;
11235|       |      }
11236|       |      end = len;
11237|       |      return true;
11238|       |    }
11239|       |  }
11240|       |#endif
11241|  27.4k|  for (; i < len; ++i) {
  ------------------
  |  Branch (11241:10): [True: 27.1k, False: 286]
  ------------------
11242|  27.1k|    const uint8_t c = b[i];
11243|  27.1k|    const uint8_t cls = k_host_class[c];
11244|  27.1k|    if (cls == 1) {
  ------------------
  |  Branch (11244:9): [True: 6.46k, False: 20.6k]
  ------------------
11245|  6.46k|      end = i;
11246|  6.46k|      return true;
11247|  6.46k|    }
11248|  20.6k|    if (cls == 2) {
  ------------------
  |  Branch (11248:9): [True: 164, False: 20.4k]
  ------------------
11249|    164|      return false;
11250|    164|    }
11251|  20.4k|    if (c >= 'A' && c <= 'Z') {
  ------------------
  |  Branch (11251:9): [True: 12.4k, False: 8.06k]
  |  Branch (11251:21): [True: 670, False: 11.7k]
  ------------------
11252|    670|      has_upper = true;
11253|  19.8k|    } else if (c == 'x') {
  ------------------
  |  Branch (11253:16): [True: 2.85k, False: 16.9k]
  ------------------
11254|  2.85k|      has_x = true;
11255|  2.85k|    }
11256|  20.4k|  }
11257|    286|  end = len;
11258|    286|  return true;
11259|  6.91k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_111nibble_loadEPKh:
10914|  17.2k|ADA_PARSER_SIMD __m128i nibble_load(const uint8_t* t) noexcept {
10915|  17.2k|  return _mm_load_si128(reinterpret_cast<const __m128i*>(t));
10916|  17.2k|}
can_parse.cc:_ZZN3ada6parser12_GLOBAL__N_115scan_plain_hostEPKhmmRmRbS5_ENK3$_0clEm:
11093|  18.2k|    auto visit = [&](size_t at) noexcept -> bool {
11094|  18.2k|      const __m128i w =
11095|  18.2k|          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + at));
11096|  18.2k|      const int up = sse2_uppercase(w);
11097|  18.2k|      const int xs = _mm_movemask_epi8(_mm_cmpeq_epi8(w, x_splat));
11098|  18.2k|      const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);
11099|  18.2k|      if (mask == 0) {
  ------------------
  |  Branch (11099:11): [True: 12.9k, False: 5.22k]
  ------------------
11100|  12.9k|        if (up != 0) {
  ------------------
  |  Branch (11100:13): [True: 812, False: 12.1k]
  ------------------
11101|    812|          has_upper = true;
11102|    812|        }
11103|  12.9k|        if (xs != 0) {
  ------------------
  |  Branch (11103:13): [True: 10.1k, False: 2.84k]
  ------------------
11104|  10.1k|          has_x = true;
11105|  10.1k|        }
11106|  12.9k|        return false;
11107|  12.9k|      }
11108|  5.22k|      const int hit = trailing_zeroes32(static_cast<uint32_t>(mask));
11109|  5.22k|      const int valid = (1 << hit) - 1;
11110|  5.22k|      if ((up & valid) != 0) {
  ------------------
  |  Branch (11110:11): [True: 480, False: 4.74k]
  ------------------
11111|    480|        has_upper = true;
11112|    480|      }
11113|  5.22k|      if ((xs & valid) != 0) {
  ------------------
  |  Branch (11113:11): [True: 1.18k, False: 4.04k]
  ------------------
11114|  1.18k|        has_x = true;
11115|  1.18k|      }
11116|  5.22k|      end = at + static_cast<size_t>(hit);
11117|  5.22k|      return true;
11118|  18.2k|    };
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_114sse2_uppercaseEDv2_x:
11001|  18.2k|ada_really_inline int sse2_uppercase(__m128i w) noexcept {
11002|  18.2k|  return _mm_movemask_epi8(_mm_and_si128(
11003|  18.2k|      _mm_cmpgt_epi8(w, _mm_set1_epi8(static_cast<char>('A' - 1))),
11004|  18.2k|      _mm_cmplt_epi8(w, _mm_set1_epi8(static_cast<char>('Z' + 1)))));
11005|  18.2k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_117ssse3_nibble_maskEDv2_xS2_S2_:
10921|  27.8k|                                      __m128i hi_tbl) noexcept {
10922|  27.8k|  const __m128i nibble = _mm_set1_epi8(0x0F);
10923|  27.8k|  const __m128i lo = _mm_and_si128(w, nibble);
10924|  27.8k|  const __m128i hi = _mm_and_si128(_mm_srli_epi16(w, 4), nibble);
10925|  27.8k|  const __m128i hit =
10926|  27.8k|      _mm_and_si128(_mm_shuffle_epi8(lo_tbl, lo), _mm_shuffle_epi8(hi_tbl, hi));
10927|  27.8k|  return _mm_movemask_epi8(_mm_cmpeq_epi8(hit, _mm_setzero_si128())) ^ 0xFFFF;
10928|  27.8k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_117trailing_zeroes32Ej:
10893|  7.40k|ada_really_inline int trailing_zeroes32(uint32_t input_num) noexcept {
10894|       |#ifdef ADA_REGULAR_VISUAL_STUDIO
10895|       |  unsigned long ret;
10896|       |  _BitScanForward(&ret, input_num);
10897|       |  return static_cast<int>(ret);
10898|       |#else
10899|  7.40k|  return __builtin_ctz(input_num);
10900|  7.40k|#endif
10901|  7.40k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_113scan_path_runEPKhRmmRb:
11319|  8.45k|                                   bool& maybe_dot_segment) noexcept {
11320|  8.45k|  const size_t run_start = i;
11321|  8.45k|#if ADA_PARSER_SSSE3
11322|  8.45k|  if (i + 16 <= len) {
  ------------------
  |  Branch (11322:7): [True: 2.64k, False: 5.81k]
  ------------------
11323|  2.64k|    const __m128i lo_tbl = nibble_load(k_path_nibbles.low);
11324|  2.64k|    const __m128i hi_tbl = nibble_load(k_path_nibbles.high);
11325|  4.33k|    for (; i + 32 <= len; i += 32) {
  ------------------
  |  Branch (11325:12): [True: 2.86k, False: 1.47k]
  ------------------
11326|  2.86k|      const __m128i w0 =
11327|  2.86k|          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));
11328|  2.86k|      const int m0 = ssse3_nibble_mask(w0, lo_tbl, hi_tbl);
11329|  2.86k|      if (m0 != 0) {
  ------------------
  |  Branch (11329:11): [True: 978, False: 1.88k]
  ------------------
11330|    978|        const int hit_bit = trailing_zeroes32(static_cast<uint32_t>(m0));
11331|    978|        note_dots_in_window(b, i, run_start, w0, (1 << hit_bit) - 1,
11332|    978|                            maybe_dot_segment);
11333|    978|        i += static_cast<size_t>(hit_bit);
11334|    978|        return;
11335|    978|      }
11336|  1.88k|      note_dots_in_window(b, i, run_start, w0, 0xFFFF, maybe_dot_segment);
11337|  1.88k|      const __m128i w1 =
11338|  1.88k|          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i + 16));
11339|  1.88k|      const int m1 = ssse3_nibble_mask(w1, lo_tbl, hi_tbl);
11340|  1.88k|      if (m1 != 0) {
  ------------------
  |  Branch (11340:11): [True: 190, False: 1.69k]
  ------------------
11341|    190|        const int hit_bit = trailing_zeroes32(static_cast<uint32_t>(m1));
11342|    190|        note_dots_in_window(b, i + 16, run_start, w1, (1 << hit_bit) - 1,
11343|    190|                            maybe_dot_segment);
11344|    190|        i += 16 + static_cast<size_t>(hit_bit);
11345|    190|        return;
11346|    190|      }
11347|  1.69k|      note_dots_in_window(b, i + 16, run_start, w1, 0xFFFF, maybe_dot_segment);
11348|  1.69k|    }
11349|  2.04k|    for (; i + 16 <= len; i += 16) {
  ------------------
  |  Branch (11349:12): [True: 1.11k, False: 930]
  ------------------
11350|  1.11k|      const __m128i w =
11351|  1.11k|          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));
11352|  1.11k|      const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);
11353|  1.11k|      if (mask != 0) {
  ------------------
  |  Branch (11353:11): [True: 542, False: 574]
  ------------------
11354|    542|        const int hit_bit = trailing_zeroes32(static_cast<uint32_t>(mask));
11355|    542|        note_dots_in_window(b, i, run_start, w, (1 << hit_bit) - 1,
11356|    542|                            maybe_dot_segment);
11357|    542|        i += static_cast<size_t>(hit_bit);
11358|    542|        return;
11359|    542|      }
11360|    574|      note_dots_in_window(b, i, run_start, w, 0xFFFF, maybe_dot_segment);
11361|    574|    }
11362|    930|    if (i > run_start && i < len) {
  ------------------
  |  Branch (11362:9): [True: 930, False: 0]
  |  Branch (11362:26): [True: 636, False: 294]
  ------------------
11363|    636|      const __m128i w =
11364|    636|          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + len - 16));
11365|    636|      const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);
11366|    636|      if (mask != 0) {
  ------------------
  |  Branch (11366:11): [True: 178, False: 458]
  ------------------
11367|    178|        const size_t hit =
11368|    178|            len - 16 +
11369|    178|            static_cast<size_t>(trailing_zeroes32(static_cast<uint32_t>(mask)));
11370|    178|        if (hit >= i) {
  ------------------
  |  Branch (11370:13): [True: 178, False: 0]
  ------------------
11371|    814|          for (size_t j = i; j < hit; ++j) {
  ------------------
  |  Branch (11371:30): [True: 636, False: 178]
  ------------------
11372|    636|            if (b[j] == '.') {
  ------------------
  |  Branch (11372:17): [True: 240, False: 396]
  ------------------
11373|    240|              note_possible_dot_segment(b, j, run_start, maybe_dot_segment);
11374|    240|            }
11375|    636|          }
11376|    178|          i = hit;
11377|    178|          return;
11378|    178|        }
11379|    178|      }
11380|  3.52k|      for (size_t j = i; j < len; ++j) {
  ------------------
  |  Branch (11380:26): [True: 3.07k, False: 458]
  ------------------
11381|  3.07k|        if (b[j] == '.') {
  ------------------
  |  Branch (11381:13): [True: 774, False: 2.29k]
  ------------------
11382|    774|          note_possible_dot_segment(b, j, run_start, maybe_dot_segment);
11383|    774|        }
11384|  3.07k|      }
11385|    458|      i = len;
11386|    458|      return;
11387|    636|    }
11388|    930|  }
11389|       |#elif ADA_SSE2
11390|       |  for (; i + 16 <= len; i += 16) {
11391|       |    const __m128i w = _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));
11392|       |    const int mask = sse2_path_stop(w);
11393|       |    if (mask != 0) {
11394|       |      const int hit_bit = trailing_zeroes32(static_cast<uint32_t>(mask));
11395|       |      note_dots_in_window(b, i, run_start, w, (1 << hit_bit) - 1,
11396|       |                          maybe_dot_segment);
11397|       |      i += static_cast<size_t>(hit_bit);
11398|       |      return;
11399|       |    }
11400|       |    note_dots_in_window(b, i, run_start, w, 0xFFFF, maybe_dot_segment);
11401|       |  }
11402|       |#elif ADA_NEON
11403|       |  if (i + 16 <= len) {
11404|       |    const uint8x16_t lo_tbl = vld1q_u8(k_path_nibbles.low);
11405|       |    const uint8x16_t hi_tbl = vld1q_u8(k_path_nibbles.high);
11406|       |    for (; i + 32 <= len; i += 32) {
11407|       |      const uint8x16_t w0 = vld1q_u8(b + i);
11408|       |      const uint64_t bits0 = neon_table_stop(w0, lo_tbl, hi_tbl);
11409|       |      if (bits0 != 0) {
11410|       |        const size_t hit_off =
11411|       |            static_cast<size_t>(trailing_zeroes64(bits0)) >> 2;
11412|       |        const uint64_t valid =
11413|       |            (hit_off == 0) ? 0 : (uint64_t{1} << (hit_off * 4)) - 1;
11414|       |        note_dots_in_window_neon(b, i, run_start, w0, valid, maybe_dot_segment);
11415|       |        i += hit_off;
11416|       |        return;
11417|       |      }
11418|       |      note_dots_in_window_neon(b, i, run_start, w0, ~uint64_t{0},
11419|       |                               maybe_dot_segment);
11420|       |      const uint8x16_t w1 = vld1q_u8(b + i + 16);
11421|       |      const uint64_t bits1 = neon_table_stop(w1, lo_tbl, hi_tbl);
11422|       |      if (bits1 != 0) {
11423|       |        const size_t hit_off =
11424|       |            static_cast<size_t>(trailing_zeroes64(bits1)) >> 2;
11425|       |        const uint64_t valid =
11426|       |            (hit_off == 0) ? 0 : (uint64_t{1} << (hit_off * 4)) - 1;
11427|       |        note_dots_in_window_neon(b, i + 16, run_start, w1, valid,
11428|       |                                 maybe_dot_segment);
11429|       |        i += 16 + hit_off;
11430|       |        return;
11431|       |      }
11432|       |      note_dots_in_window_neon(b, i + 16, run_start, w1, ~uint64_t{0},
11433|       |                               maybe_dot_segment);
11434|       |    }
11435|       |    for (; i + 16 <= len; i += 16) {
11436|       |      const uint8x16_t w = vld1q_u8(b + i);
11437|       |      const uint64_t bits = neon_table_stop(w, lo_tbl, hi_tbl);
11438|       |      if (bits != 0) {
11439|       |        const size_t hit_off =
11440|       |            static_cast<size_t>(trailing_zeroes64(bits)) >> 2;
11441|       |        const uint64_t valid =
11442|       |            (hit_off == 0) ? 0 : (uint64_t{1} << (hit_off * 4)) - 1;
11443|       |        note_dots_in_window_neon(b, i, run_start, w, valid, maybe_dot_segment);
11444|       |        i += hit_off;
11445|       |        return;
11446|       |      }
11447|       |      note_dots_in_window_neon(b, i, run_start, w, ~uint64_t{0},
11448|       |                               maybe_dot_segment);
11449|       |    }
11450|       |    if (i > run_start && i < len) {
11451|       |      const uint8x16_t w = vld1q_u8(b + len - 16);
11452|       |      const uint64_t bits = neon_table_stop(w, lo_tbl, hi_tbl);
11453|       |      if (bits != 0) {
11454|       |        const size_t hit =
11455|       |            len - 16 + (static_cast<size_t>(trailing_zeroes64(bits)) >> 2);
11456|       |        if (hit >= i) {
11457|       |          for (size_t j = i; j < hit; ++j) {
11458|       |            if (b[j] == '.') {
11459|       |              note_possible_dot_segment(b, j, run_start, maybe_dot_segment);
11460|       |            }
11461|       |          }
11462|       |          i = hit;
11463|       |          return;
11464|       |        }
11465|       |      }
11466|       |      for (size_t j = i; j < len; ++j) {
11467|       |        if (b[j] == '.') {
11468|       |          note_possible_dot_segment(b, j, run_start, maybe_dot_segment);
11469|       |        }
11470|       |      }
11471|       |      i = len;
11472|       |      return;
11473|       |    }
11474|       |  }
11475|       |#endif
11476|  13.5k|  for (; i < len; ++i) {
  ------------------
  |  Branch (11476:10): [True: 9.40k, False: 4.12k]
  ------------------
11477|  9.40k|    const uint8_t c = b[i];
11478|  9.40k|    const uint8_t cls = k_path[c];
11479|  9.40k|    if (cls != 0) {
  ------------------
  |  Branch (11479:9): [True: 1.98k, False: 7.41k]
  ------------------
11480|  1.98k|      return;
11481|  1.98k|    }
11482|  7.41k|    if (c == '.') {
  ------------------
  |  Branch (11482:9): [True: 2.05k, False: 5.36k]
  ------------------
11483|  2.05k|      note_possible_dot_segment(b, i, run_start, maybe_dot_segment);
11484|  2.05k|    }
11485|  7.41k|  }
11486|  6.11k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_119note_dots_in_windowEPKhmmDv2_xiRb:
11276|  5.86k|                                           bool& maybe_dot_segment) noexcept {
11277|  5.86k|  if (maybe_dot_segment || valid_mask == 0) {
  ------------------
  |  Branch (11277:7): [True: 1.57k, False: 4.29k]
  |  Branch (11277:28): [True: 1.09k, False: 3.20k]
  ------------------
11278|  2.66k|    return;
11279|  2.66k|  }
11280|  3.20k|  const int dots =
11281|  3.20k|      _mm_movemask_epi8(_mm_cmpeq_epi8(w, _mm_set1_epi8('.'))) & valid_mask;
11282|  3.20k|  if (dots == 0) {
  ------------------
  |  Branch (11282:7): [True: 1.59k, False: 1.60k]
  ------------------
11283|  1.59k|    return;
11284|  1.59k|  }
11285|  1.60k|  const int slashes =
11286|  1.60k|      _mm_movemask_epi8(_mm_cmpeq_epi8(w, _mm_set1_epi8('/'))) & valid_mask;
11287|  1.60k|  if (((dots & 1) != 0 && (i == run_start || b[i - 1] == '/')) ||
  ------------------
  |  Branch (11287:8): [True: 728, False: 880]
  |  Branch (11287:28): [True: 330, False: 398]
  |  Branch (11287:46): [True: 44, False: 354]
  ------------------
11288|  1.23k|      (dots & (slashes << 1)) != 0) {
  ------------------
  |  Branch (11288:7): [True: 380, False: 854]
  ------------------
11289|    754|    maybe_dot_segment = true;
11290|    754|  }
11291|  1.60k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_125note_possible_dot_segmentEPKhmmRb:
11263|  3.07k|    bool& maybe_dot_segment) noexcept {
11264|  3.07k|  if (pos == run_start || b[pos - 1] == '/') {
  ------------------
  |  Branch (11264:7): [True: 622, False: 2.45k]
  |  Branch (11264:27): [True: 1.25k, False: 1.19k]
  ------------------
11265|  1.88k|    maybe_dot_segment = true;
11266|  1.88k|  }
11267|  3.07k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_114scan_query_runEPKhRmm:
11629|    826|                                    size_t len) noexcept {
11630|    826|  ADA_SCAN_STOP_RUN(k_query_nibbles, k_query, sse2_query_stop);
  ------------------
  |  |11492|    826|  do {                                                                       \
  |  |11493|    826|    const size_t scan_start = i;                                             \
  |  |11494|    826|    if (i + 16 <= len) {                                                     \
  |  |  ------------------
  |  |  |  Branch (11494:9): [True: 340, False: 486]
  |  |  ------------------
  |  |11495|    340|      const __m128i lo_tbl = nibble_load((nibbles).low);                     \
  |  |11496|    340|      const __m128i hi_tbl = nibble_load((nibbles).high);                    \
  |  |11497|    906|      for (; i + 32 <= len; i += 32) {                                       \
  |  |  ------------------
  |  |  |  Branch (11497:14): [True: 658, False: 248]
  |  |  ------------------
  |  |11498|    658|        const __m128i w0 =                                                   \
  |  |11499|    658|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));        \
  |  |11500|    658|        const int m0 = ssse3_nibble_mask(w0, lo_tbl, hi_tbl);                \
  |  |11501|    658|        if (m0 != 0) {                                                       \
  |  |  ------------------
  |  |  |  Branch (11501:13): [True: 26, False: 632]
  |  |  ------------------
  |  |11502|     26|          i += static_cast<size_t>(                                          \
  |  |11503|     26|              trailing_zeroes32(static_cast<uint32_t>(m0)));                 \
  |  |11504|     26|          return;                                                            \
  |  |11505|     26|        }                                                                    \
  |  |11506|    658|        const __m128i w1 =                                                   \
  |  |11507|    632|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i + 16));   \
  |  |11508|    632|        const int m1 = ssse3_nibble_mask(w1, lo_tbl, hi_tbl);                \
  |  |11509|    632|        if (m1 != 0) {                                                       \
  |  |  ------------------
  |  |  |  Branch (11509:13): [True: 66, False: 566]
  |  |  ------------------
  |  |11510|     66|          i += 16 + static_cast<size_t>(                                     \
  |  |11511|     66|                        trailing_zeroes32(static_cast<uint32_t>(m1)));       \
  |  |11512|     66|          return;                                                            \
  |  |11513|     66|        }                                                                    \
  |  |11514|    632|      }                                                                      \
  |  |11515|    426|      for (; i + 16 <= len; i += 16) {                                       \
  |  |  ------------------
  |  |  |  Branch (11515:14): [True: 214, False: 212]
  |  |  ------------------
  |  |11516|    214|        const __m128i w =                                                    \
  |  |11517|    214|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));        \
  |  |11518|    214|        const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);               \
  |  |11519|    214|        if (mask != 0) {                                                     \
  |  |  ------------------
  |  |  |  Branch (11519:13): [True: 36, False: 178]
  |  |  ------------------
  |  |11520|     36|          i += static_cast<size_t>(                                          \
  |  |11521|     36|              trailing_zeroes32(static_cast<uint32_t>(mask)));               \
  |  |11522|     36|          return;                                                            \
  |  |11523|     36|        }                                                                    \
  |  |11524|    214|      }                                                                      \
  |  |11525|    248|      if (i > scan_start && i < len) {                                       \
  |  |  ------------------
  |  |  |  Branch (11525:11): [True: 212, False: 0]
  |  |  |  Branch (11525:29): [True: 188, False: 24]
  |  |  ------------------
  |  |11526|    188|        const __m128i w =                                                    \
  |  |11527|    188|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + len - 16)); \
  |  |11528|    188|        const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);               \
  |  |11529|    188|        if (mask != 0) {                                                     \
  |  |  ------------------
  |  |  |  Branch (11529:13): [True: 66, False: 122]
  |  |  ------------------
  |  |11530|     66|          const size_t hit = len - 16 +                                      \
  |  |11531|     66|                             static_cast<size_t>(trailing_zeroes32(          \
  |  |11532|     66|                                 static_cast<uint32_t>(mask)));              \
  |  |11533|     66|          if (hit >= i) {                                                    \
  |  |  ------------------
  |  |  |  Branch (11533:15): [True: 66, False: 0]
  |  |  ------------------
  |  |11534|     66|            i = hit;                                                         \
  |  |11535|     66|            return;                                                          \
  |  |11536|     66|          }                                                                  \
  |  |11537|     66|        }                                                                    \
  |  |11538|    188|        i = len;                                                             \
  |  |11539|    122|        return;                                                              \
  |  |11540|    188|      }                                                                      \
  |  |11541|    212|    }                                                                        \
  |  |11542|  1.43k|    for (; i < len; ++i) {                                                   \
  |  |  ------------------
  |  |  |  Branch (11542:12): [True: 1.12k, False: 308]
  |  |  ------------------
  |  |11543|  1.12k|      if ((cls)[b[i]] != 0) {                                                \
  |  |  ------------------
  |  |  |  Branch (11543:11): [True: 202, False: 922]
  |  |  ------------------
  |  |11544|    202|        return;                                                              \
  |  |11545|    202|      }                                                                      \
  |  |11546|  1.12k|    }                                                                        \
  |  |11547|    510|  } while (0)
  |  |  ------------------
  |  |  |  Branch (11547:12): [Folded, False: 308]
  |  |  ------------------
  ------------------
11631|    826|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_113scan_hash_runEPKhRmm:
11634|    812|                                   size_t len) noexcept {
11635|    812|  ADA_SCAN_STOP_RUN(k_hash_nibbles, k_hash, sse2_hash_stop);
  ------------------
  |  |11492|    812|  do {                                                                       \
  |  |11493|    812|    const size_t scan_start = i;                                             \
  |  |11494|    812|    if (i + 16 <= len) {                                                     \
  |  |  ------------------
  |  |  |  Branch (11494:9): [True: 312, False: 500]
  |  |  ------------------
  |  |11495|    312|      const __m128i lo_tbl = nibble_load((nibbles).low);                     \
  |  |11496|    312|      const __m128i hi_tbl = nibble_load((nibbles).high);                    \
  |  |11497|    780|      for (; i + 32 <= len; i += 32) {                                       \
  |  |  ------------------
  |  |  |  Branch (11497:14): [True: 532, False: 248]
  |  |  ------------------
  |  |11498|    532|        const __m128i w0 =                                                   \
  |  |11499|    532|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));        \
  |  |11500|    532|        const int m0 = ssse3_nibble_mask(w0, lo_tbl, hi_tbl);                \
  |  |11501|    532|        if (m0 != 0) {                                                       \
  |  |  ------------------
  |  |  |  Branch (11501:13): [True: 24, False: 508]
  |  |  ------------------
  |  |11502|     24|          i += static_cast<size_t>(                                          \
  |  |11503|     24|              trailing_zeroes32(static_cast<uint32_t>(m0)));                 \
  |  |11504|     24|          return;                                                            \
  |  |11505|     24|        }                                                                    \
  |  |11506|    532|        const __m128i w1 =                                                   \
  |  |11507|    508|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i + 16));   \
  |  |11508|    508|        const int m1 = ssse3_nibble_mask(w1, lo_tbl, hi_tbl);                \
  |  |11509|    508|        if (m1 != 0) {                                                       \
  |  |  ------------------
  |  |  |  Branch (11509:13): [True: 40, False: 468]
  |  |  ------------------
  |  |11510|     40|          i += 16 + static_cast<size_t>(                                     \
  |  |11511|     40|                        trailing_zeroes32(static_cast<uint32_t>(m1)));       \
  |  |11512|     40|          return;                                                            \
  |  |11513|     40|        }                                                                    \
  |  |11514|    508|      }                                                                      \
  |  |11515|    422|      for (; i + 16 <= len; i += 16) {                                       \
  |  |  ------------------
  |  |  |  Branch (11515:14): [True: 186, False: 236]
  |  |  ------------------
  |  |11516|    186|        const __m128i w =                                                    \
  |  |11517|    186|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));        \
  |  |11518|    186|        const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);               \
  |  |11519|    186|        if (mask != 0) {                                                     \
  |  |  ------------------
  |  |  |  Branch (11519:13): [True: 12, False: 174]
  |  |  ------------------
  |  |11520|     12|          i += static_cast<size_t>(                                          \
  |  |11521|     12|              trailing_zeroes32(static_cast<uint32_t>(mask)));               \
  |  |11522|     12|          return;                                                            \
  |  |11523|     12|        }                                                                    \
  |  |11524|    186|      }                                                                      \
  |  |11525|    248|      if (i > scan_start && i < len) {                                       \
  |  |  ------------------
  |  |  |  Branch (11525:11): [True: 236, False: 0]
  |  |  |  Branch (11525:29): [True: 206, False: 30]
  |  |  ------------------
  |  |11526|    206|        const __m128i w =                                                    \
  |  |11527|    206|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + len - 16)); \
  |  |11528|    206|        const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);               \
  |  |11529|    206|        if (mask != 0) {                                                     \
  |  |  ------------------
  |  |  |  Branch (11529:13): [True: 18, False: 188]
  |  |  ------------------
  |  |11530|     18|          const size_t hit = len - 16 +                                      \
  |  |11531|     18|                             static_cast<size_t>(trailing_zeroes32(          \
  |  |11532|     18|                                 static_cast<uint32_t>(mask)));              \
  |  |11533|     18|          if (hit >= i) {                                                    \
  |  |  ------------------
  |  |  |  Branch (11533:15): [True: 18, False: 0]
  |  |  ------------------
  |  |11534|     18|            i = hit;                                                         \
  |  |11535|     18|            return;                                                          \
  |  |11536|     18|          }                                                                  \
  |  |11537|     18|        }                                                                    \
  |  |11538|    206|        i = len;                                                             \
  |  |11539|    188|        return;                                                              \
  |  |11540|    206|      }                                                                      \
  |  |11541|    236|    }                                                                        \
  |  |11542|  1.40k|    for (; i < len; ++i) {                                                   \
  |  |  ------------------
  |  |  |  Branch (11542:12): [True: 956, False: 446]
  |  |  ------------------
  |  |11543|    956|      if ((cls)[b[i]] != 0) {                                                \
  |  |  ------------------
  |  |  |  Branch (11543:11): [True: 84, False: 872]
  |  |  ------------------
  |  |11544|     84|        return;                                                              \
  |  |11545|     84|      }                                                                      \
  |  |11546|    956|    }                                                                        \
  |  |11547|    530|  } while (0)
  |  |  ------------------
  |  |  |  Branch (11547:12): [Folded, False: 446]
  |  |  ------------------
  ------------------
11636|    812|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_120path_has_dot_segmentENSt3__117basic_string_viewIcNS2_11char_traitsIcEEEE:
11640|  1.45k|bool path_has_dot_segment(std::string_view path) noexcept {
11641|  1.45k|  if (path.empty()) {
  ------------------
  |  Branch (11641:7): [True: 0, False: 1.45k]
  ------------------
11642|      0|    return false;
11643|      0|  }
11644|       |  // "." / ".." at the start, with or without a leading '/'.
11645|  1.45k|  const size_t i = (path[0] == '/') ? 1 : 0;
  ------------------
  |  Branch (11645:20): [True: 1.26k, False: 188]
  ------------------
11646|  1.45k|  if (i < path.size() && path[i] == '.') {
  ------------------
  |  Branch (11646:7): [True: 1.45k, False: 0]
  |  Branch (11646:26): [True: 638, False: 816]
  ------------------
11647|    638|    const size_t after = i + 1;
11648|    638|    if (after == path.size() || path[after] == '/' ||
  ------------------
  |  Branch (11648:9): [True: 52, False: 586]
  |  Branch (11648:33): [True: 202, False: 384]
  ------------------
11649|    384|        (after < path.size() && path[after] == '.' &&
  ------------------
  |  Branch (11649:10): [True: 384, False: 0]
  |  Branch (11649:33): [True: 160, False: 224]
  ------------------
11650|    372|         (after + 1 == path.size() || path[after + 1] == '/'))) {
  ------------------
  |  Branch (11650:11): [True: 38, False: 122]
  |  Branch (11650:39): [True: 80, False: 42]
  ------------------
11651|    372|      return true;
11652|    372|    }
11653|    638|  }
11654|  1.08k|  static constexpr std::string_view slash_dot{"/.", 2};
11655|  1.08k|  size_t p = i;
11656|  2.23k|  while ((p = path.find(slash_dot, p)) != std::string_view::npos) {
  ------------------
  |  Branch (11656:10): [True: 1.80k, False: 428]
  ------------------
11657|  1.80k|    const size_t after = p + 2;
11658|  1.80k|    if (after == path.size() || path[after] == '/' ||
  ------------------
  |  Branch (11658:9): [True: 266, False: 1.54k]
  |  Branch (11658:33): [True: 140, False: 1.40k]
  ------------------
11659|  1.40k|        (after < path.size() && path[after] == '.' &&
  ------------------
  |  Branch (11659:10): [True: 1.40k, False: 0]
  |  Branch (11659:33): [True: 610, False: 792]
  ------------------
11660|    654|         (after + 1 == path.size() || path[after + 1] == '/'))) {
  ------------------
  |  Branch (11660:11): [True: 66, False: 544]
  |  Branch (11660:39): [True: 182, False: 362]
  ------------------
11661|    654|      return true;
11662|    654|    }
11663|  1.15k|    p = after;
11664|  1.15k|  }
11665|    428|  return false;
11666|  1.08k|}
_ZN3ada14url_aggregator11copy_schemeERKS0_:
13759|  1.41k|inline void url_aggregator::copy_scheme(const url_aggregator& u) {
13760|  1.41k|  ada_log("url_aggregator::copy_scheme ", u.buffer);
13761|  1.41k|  ADA_ASSERT_TRUE(validate());
13762|       |  // next line could overflow but unsigned arithmetic has well-defined
13763|       |  // overflows.
13764|  1.41k|  uint32_t new_difference = u.components.protocol_end - components.protocol_end;
13765|       |
13766|  1.41k|  type = u.type;
13767|  1.41k|  buffer.erase(0, components.protocol_end);
13768|  1.41k|  buffer.insert(0, u.get_protocol());
13769|  1.41k|  components.protocol_end = u.components.protocol_end;
13770|       |
13771|       |  // No need to update the components
13772|  1.41k|  if (new_difference == 0) {
  ------------------
  |  Branch (13772:7): [True: 156, False: 1.25k]
  ------------------
13773|    156|    return;
13774|    156|  }
13775|       |
13776|  1.25k|  apply_shifted_non_scheme_offsets(components, new_difference);
13777|  1.25k|  ADA_ASSERT_TRUE(validate());
13778|  1.25k|}
can_parse.cc:_ZN12_GLOBAL__N_132apply_shifted_non_scheme_offsetsERN3ada14url_componentsEj:
13637|  43.0k|    ada::url_components& components, uint32_t new_difference) {
13638|  43.0k|  components.username_end += new_difference;
13639|  43.0k|  components.host_start += new_difference;
13640|  43.0k|  components.host_end += new_difference;
13641|  43.0k|  components.pathname_start += new_difference;
13642|  43.0k|  if (components.search_start != ada::url_components::omitted) {
  ------------------
  |  Branch (13642:7): [True: 0, False: 43.0k]
  ------------------
13643|      0|    components.search_start += new_difference;
13644|      0|  }
13645|  43.0k|  if (components.hash_start != ada::url_components::omitted) {
  ------------------
  |  Branch (13645:7): [True: 0, False: 43.0k]
  ------------------
13646|      0|    components.hash_start += new_difference;
13647|      0|  }
13648|  43.0k|}
_ZN3ada14url_aggregator10parse_pathENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
14007|  1.90k|ada_really_inline void url_aggregator::parse_path(std::string_view input) {
14008|  1.90k|  ada_log("url_aggregator::parse_path ", input);
14009|  1.90k|  ADA_ASSERT_TRUE(validate());
14010|  1.90k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
14011|  1.90k|  std::string tmp_buffer;
14012|  1.90k|  std::string_view internal_input;
14013|  1.90k|  if (unicode::has_tabs_or_newline(input)) {
  ------------------
  |  Branch (14013:7): [True: 0, False: 1.90k]
  ------------------
14014|      0|    tmp_buffer = input;
14015|       |    // Optimization opportunity: Instead of copying and then pruning, we could
14016|       |    // just directly build the string from user_input.
14017|      0|    helpers::remove_ascii_tab_or_newline(tmp_buffer);
14018|      0|    internal_input = tmp_buffer;
14019|  1.90k|  } else {
14020|  1.90k|    internal_input = input;
14021|  1.90k|  }
14022|       |
14023|       |  // If url is special, then:
14024|  1.90k|  if (is_special()) {
  ------------------
  |  Branch (14024:7): [True: 1.90k, False: 0]
  ------------------
14025|  1.90k|    if (internal_input.empty()) {
  ------------------
  |  Branch (14025:9): [True: 67, False: 1.83k]
  ------------------
14026|     67|      update_base_pathname("/");
14027|  1.83k|    } else if ((internal_input[0] == '/') || (internal_input[0] == '\\')) {
  ------------------
  |  Branch (14027:16): [True: 1.83k, False: 0]
  |  Branch (14027:46): [True: 0, False: 0]
  ------------------
14028|  1.83k|      consume_prepared_path(internal_input.substr(1));
14029|  1.83k|    } else {
14030|      0|      consume_prepared_path(internal_input);
14031|      0|    }
14032|  1.90k|  } else if (!internal_input.empty()) {
  ------------------
  |  Branch (14032:14): [True: 0, False: 0]
  ------------------
14033|      0|    if (internal_input[0] == '/') {
  ------------------
  |  Branch (14033:9): [True: 0, False: 0]
  ------------------
14034|      0|      consume_prepared_path(internal_input.substr(1));
14035|      0|    } else {
14036|      0|      consume_prepared_path(internal_input);
14037|      0|    }
14038|      0|  } else {
14039|       |    // Non-special URLs with an empty host can have their paths erased
14040|       |    // Path-only URLs cannot have their paths erased
14041|      0|    if (components.host_start == components.host_end && !has_authority()) {
  ------------------
  |  Branch (14041:9): [True: 0, False: 0]
  |  Branch (14041:57): [True: 0, False: 0]
  ------------------
14042|      0|      update_base_pathname("/");
14043|      0|    }
14044|      0|  }
14045|  1.90k|  ADA_ASSERT_TRUE(validate());
14046|  1.90k|}
_ZN3ada14url_aggregator10parse_hostENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
14126|  29.4k|ada_really_inline bool url_aggregator::parse_host(std::string_view input) {
14127|  29.4k|  ada_log("url_aggregator:parse_host \"", input, "\" [", input.size(),
14128|  29.4k|          " bytes]");
14129|  29.4k|  ADA_ASSERT_TRUE(validate());
14130|  29.4k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
14131|  29.4k|  if (input.empty()) {
  ------------------
  |  Branch (14131:7): [True: 25, False: 29.3k]
  ------------------
14132|     25|    return is_valid = false;
14133|     25|  }  // technically unnecessary.
14134|       |  // If input starts with U+005B ([), then:
14135|  29.3k|  if (input[0] == '[') {
  ------------------
  |  Branch (14135:7): [True: 1.41k, False: 27.9k]
  ------------------
14136|       |    // If input does not end with U+005D (]), validation error, return failure.
14137|  1.41k|    if (input.back() != ']') {
  ------------------
  |  Branch (14137:9): [True: 340, False: 1.07k]
  ------------------
14138|    340|      return is_valid = false;
14139|    340|    }
14140|  1.07k|    ada_log("parse_host ipv6");
14141|       |
14142|       |    // Return the result of IPv6 parsing input with its leading U+005B ([) and
14143|       |    // trailing U+005D (]) removed.
14144|  1.07k|    input.remove_prefix(1);
14145|  1.07k|    input.remove_suffix(1);
14146|  1.07k|    return parse_ipv6(input);
14147|  1.41k|  }
14148|       |
14149|       |  // If isNotSpecial is true, then return the result of opaque-host parsing
14150|       |  // input.
14151|  27.9k|  if (!is_special()) {
  ------------------
  |  Branch (14151:7): [True: 1.12k, False: 26.8k]
  ------------------
14152|  1.12k|    return parse_opaque_host(input);
14153|  1.12k|  }
14154|       |  // Let domain be the result of running UTF-8 decode without BOM on the
14155|       |  // percent-decoding of input. Let asciiDomain be the result of running domain
14156|       |  // to ASCII with domain and false. The most common case is an ASCII input, in
14157|       |  // which case we do not need to call the expensive 'to_ascii' if a few
14158|       |  // conditions are met: no '%' and no 'xn-' subsequence.
14159|       |
14160|       |  // Often, the input does not contain any forbidden code points, and no upper
14161|       |  // case ASCII letter, then we can just copy it to the buffer. We want to
14162|       |  // optimize for such a common case.
14163|       |
14164|       |  // Fast path: try to parse as pure decimal IPv4 first.
14165|  26.8k|  const uint64_t fast_result = checkers::try_parse_ipv4_fast(input);
14166|  26.8k|  if (fast_result < checkers::ipv4_fast_fail) {
  ------------------
  |  Branch (14166:7): [True: 1.30k, False: 25.5k]
  ------------------
14167|  1.30k|    if (!input.empty() && input.back() == '.') {
  ------------------
  |  Branch (14167:9): [True: 1.30k, False: 0]
  |  Branch (14167:27): [True: 49, False: 1.25k]
  ------------------
14168|     49|      update_base_hostname(input.substr(0, input.size() - 1));
14169|  1.25k|    } else {
14170|  1.25k|      update_base_hostname(input);
14171|  1.25k|    }
14172|  1.30k|    host_type = IPV4;
14173|  1.30k|    is_valid = true;
14174|  1.30k|    ada_log("parse_host fast path decimal ipv4");
14175|  1.30k|    ADA_ASSERT_TRUE(validate());
14176|  1.30k|    return true;
14177|  1.30k|  }
14178|  25.5k|  uint8_t is_forbidden_or_upper =
14179|  25.5k|      unicode::contains_forbidden_domain_code_point_or_upper(input.data(),
14180|  25.5k|                                                             input.size());
14181|  25.5k|  static constexpr std::string_view xn_dash{"xn-", 3};
14182|  25.5k|  if ((is_forbidden_or_upper & 1) == 0) {
  ------------------
  |  Branch (14182:7): [True: 14.7k, False: 10.8k]
  ------------------
14183|  14.7k|    if ((is_forbidden_or_upper & 2) != 0) {
  ------------------
  |  Branch (14183:9): [True: 2.69k, False: 12.0k]
  ------------------
14184|  2.69k|      std::string lowered(input);
14185|  2.69k|      unicode::to_lower_ascii(lowered.data(), lowered.size());
14186|  2.69k|      if (lowered.find('-') == std::string_view::npos ||
  ------------------
  |  Branch (14186:11): [True: 2.33k, False: 361]
  ------------------
14187|  2.47k|          lowered.find(xn_dash) == std::string_view::npos) {
  ------------------
  |  Branch (14187:11): [True: 139, False: 222]
  ------------------
14188|  2.47k|        update_base_hostname(lowered);
14189|  2.47k|        if (checkers::is_ipv4(lowered)) {
  ------------------
  |  Branch (14189:13): [True: 460, False: 2.01k]
  ------------------
14190|    460|          ada_log("parse_host fast path ipv4");
14191|    460|          return parse_ipv4(lowered, true);
14192|    460|        }
14193|  2.01k|        ada_log("parse_host fast path ", get_hostname());
14194|  2.01k|        is_valid = true;
14195|  2.01k|        return true;
14196|  2.47k|      }
14197|  12.0k|    } else if (input.find('-') == std::string_view::npos ||
  ------------------
  |  Branch (14197:16): [True: 8.16k, False: 3.85k]
  ------------------
14198|  8.64k|               input.find(xn_dash) == std::string_view::npos) {
  ------------------
  |  Branch (14198:16): [True: 477, False: 3.38k]
  ------------------
14199|  8.64k|      update_base_hostname(input);
14200|  8.64k|      if (checkers::is_ipv4(input)) {
  ------------------
  |  Branch (14200:11): [True: 2.31k, False: 6.32k]
  ------------------
14201|  2.31k|        ada_log("parse_host fast path ipv4");
14202|  2.31k|        return parse_ipv4(input, true);
14203|  2.31k|      }
14204|  6.32k|      ada_log("parse_host fast path ", get_hostname());
14205|  6.32k|      is_valid = true;
14206|  6.32k|      return true;
14207|  8.64k|    }
14208|  14.7k|  } else if (const size_t first_percent = input.find('%');
14209|  10.8k|             first_percent != std::string_view::npos) {
  ------------------
  |  Branch (14209:14): [True: 2.01k, False: 8.81k]
  ------------------
14210|  2.01k|    std::string decoded = unicode::percent_decode(input, first_percent);
14211|  2.01k|    const uint8_t decoded_flags =
14212|  2.01k|        unicode::contains_forbidden_domain_code_point_or_upper(decoded.data(),
14213|  2.01k|                                                               decoded.size());
14214|  2.01k|    if ((decoded_flags & 1) == 0) {
  ------------------
  |  Branch (14214:9): [True: 1.33k, False: 686]
  ------------------
14215|  1.33k|      if ((decoded_flags & 2) != 0) {
  ------------------
  |  Branch (14215:11): [True: 520, False: 812]
  ------------------
14216|    520|        unicode::to_lower_ascii(decoded.data(), decoded.size());
14217|    520|      }
14218|  1.33k|      if (decoded.find('-') == std::string_view::npos ||
  ------------------
  |  Branch (14218:11): [True: 1.14k, False: 184]
  ------------------
14219|  1.23k|          decoded.find(xn_dash) == std::string_view::npos) {
  ------------------
  |  Branch (14219:11): [True: 88, False: 96]
  ------------------
14220|  1.23k|        update_base_hostname(decoded);
14221|  1.23k|        if (checkers::is_ipv4(decoded)) {
  ------------------
  |  Branch (14221:13): [True: 560, False: 676]
  ------------------
14222|    560|          return parse_ipv4(decoded, true);
14223|    560|        }
14224|    676|        is_valid = true;
14225|    676|        return true;
14226|  1.23k|      }
14227|  1.33k|    }
14228|  2.01k|  }
14229|       |  // We have encountered at least one forbidden code point or the input contains
14230|       |  // 'xn-' (case insensitive), so we need to call 'to_ascii' to perform the full
14231|       |  // conversion.
14232|       |
14233|  13.2k|  ada_log("parse_host calling to_ascii");
14234|  13.2k|  std::optional<std::string> host = std::string(get_hostname());
14235|  13.2k|  is_valid = ada::unicode::to_ascii(host, input, input.find('%'));
14236|  13.2k|  if (!is_valid) {
  ------------------
  |  Branch (14236:7): [True: 4.37k, False: 8.82k]
  ------------------
14237|  4.37k|    ada_log("parse_host to_ascii returns false");
14238|  4.37k|    return is_valid = false;
14239|  4.37k|  }
14240|  8.82k|  ada_log("parse_host to_ascii succeeded ", *host, " [", host->size(),
14241|  8.82k|          " bytes]");
14242|       |
14243|  8.82k|  if (std::ranges::any_of(host.value(),
  ------------------
  |  Branch (14243:7): [True: 0, False: 8.82k]
  ------------------
14244|  8.82k|                          ada::unicode::is_forbidden_domain_code_point)) {
14245|      0|    return is_valid = false;
14246|      0|  }
14247|       |
14248|       |  // If asciiDomain ends in a number, then return the result of IPv4 parsing
14249|       |  // asciiDomain.
14250|  8.82k|  if (checkers::is_ipv4(host.value())) {
  ------------------
  |  Branch (14250:7): [True: 410, False: 8.41k]
  ------------------
14251|    410|    ada_log("parse_host got ipv4 ", *host);
14252|    410|    return parse_ipv4(host.value(), false);
14253|    410|  }
14254|       |
14255|  8.41k|  update_base_hostname(host.value());
14256|  8.41k|  ADA_ASSERT_TRUE(validate());
14257|  8.41k|  return true;
14258|  8.82k|}
_ZN3ada7helpers9substringENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEm:
 8565|  1.86k|                                                       size_t pos) {
 8566|  1.86k|  ADA_ASSERT_TRUE(pos <= input.size());
 8567|       |  // The following is safer but unneeded if we have the above line:
 8568|       |  // return pos > input.size() ? std::string_view() : input.substr(pos);
 8569|  1.86k|  return input.substr(pos);
 8570|  1.86k|}
_ZN3ada14url_aggregator21consume_prepared_pathENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
15077|  9.88k|inline void url_aggregator::consume_prepared_path(std::string_view input) {
15078|  9.88k|  ada_log("url_aggregator::consume_prepared_path ", input);
15079|       |  /***
15080|       |   * This is largely duplicated code from helpers::parse_prepared_path, which is
15081|       |   * unfortunate. This particular function is nearly identical, except that it
15082|       |   * is a method on url_aggregator. The idea is that the trivial path (which is
15083|       |   * very common) merely appends to the buffer. This is the same trivial path as
15084|       |   * with helpers::parse_prepared_path, except that we have the additional check
15085|       |   * for is_at_path(). Otherwise, we grab a copy of the current path and we
15086|       |   * modify it, and then insert it back into the buffer.
15087|       |   */
15088|  9.88k|  uint8_t accumulator = checkers::path_signature(input);
15089|       |  // Let us first detect a trivial case.
15090|       |  // If it is special, we check that we have no dot, no %,  no \ and no
15091|       |  // character needing percent encoding. Otherwise, we check that we have no %,
15092|       |  // no dot, and no character needing percent encoding.
15093|  9.88k|  constexpr uint8_t need_encoding = 1;
15094|  9.88k|  constexpr uint8_t backslash_char = 2;
15095|  9.88k|  constexpr uint8_t dot_char = 4;
15096|  9.88k|  constexpr uint8_t percent_char = 8;
15097|  9.88k|  bool special = type != ada::scheme::NOT_SPECIAL;
15098|  9.88k|  bool may_need_slow_file_handling = (type == ada::scheme::type::FILE &&
  ------------------
  |  Branch (15098:39): [True: 1.69k, False: 8.18k]
  ------------------
15099|  1.69k|                                      checkers::is_windows_drive_letter(input));
  ------------------
  |  Branch (15099:39): [True: 142, False: 1.55k]
  ------------------
15100|  9.88k|  bool trivial_path =
15101|  9.88k|      (special ? (accumulator == 0)
  ------------------
  |  Branch (15101:7): [True: 4.72k, False: 5.15k]
  |  Branch (15101:8): [True: 8.29k, False: 1.58k]
  ------------------
15102|  9.88k|               : ((accumulator & (need_encoding | dot_char | percent_char)) ==
15103|  1.58k|                  0)) &&
15104|  4.72k|      (!may_need_slow_file_handling);
  ------------------
  |  Branch (15104:7): [True: 4.62k, False: 101]
  ------------------
15105|  9.88k|  if (accumulator == dot_char && !may_need_slow_file_handling) {
  ------------------
  |  Branch (15105:7): [True: 1.42k, False: 8.45k]
  |  Branch (15105:34): [True: 1.40k, False: 25]
  ------------------
15106|       |    // '4' means that we have at least one dot, but nothing that requires
15107|       |    // percent encoding or decoding. The only part that is not trivial is
15108|       |    // that we may have single dots and double dots path segments.
15109|       |    // If we have such segments, then we either have a path that begins
15110|       |    // with '.' (easy to check), or we have the sequence './'.
15111|       |    // Note: input cannot be empty, it must at least contain one character ('.')
15112|       |    // Note: we know that '\' is not present.
15113|  1.40k|    if (input[0] != '.') {
  ------------------
  |  Branch (15113:9): [True: 693, False: 709]
  ------------------
15114|    693|      size_t slashdot = 0;
15115|    693|      bool dot_is_file = true;
15116|  4.18k|      for (;;) {
15117|  4.18k|        slashdot = input.find("/.", slashdot);
15118|  4.18k|        if (slashdot == std::string_view::npos) {  // common case
  ------------------
  |  Branch (15118:13): [True: 693, False: 3.48k]
  ------------------
15119|    693|          break;
15120|  3.48k|        } else {  // uncommon
15121|       |          // only three cases matter: /./, /.. or a final /
15122|  3.48k|          slashdot += 2;
15123|  3.48k|          dot_is_file &= !(slashdot == input.size() || input[slashdot] == '.' ||
  ------------------
  |  Branch (15123:28): [True: 199, False: 3.28k]
  |  Branch (15123:56): [True: 2.22k, False: 1.06k]
  ------------------
15124|  1.06k|                           input[slashdot] == '/');
  ------------------
  |  Branch (15124:28): [True: 774, False: 290]
  ------------------
15125|  3.48k|        }
15126|  4.18k|      }
15127|    693|      trivial_path = dot_is_file;
15128|    693|    }
15129|  1.40k|  }
15130|  9.88k|  if (trivial_path && is_at_path()) {
  ------------------
  |  Branch (15130:7): [True: 4.75k, False: 5.12k]
  |  Branch (15130:23): [True: 4.67k, False: 86]
  ------------------
15131|  4.67k|    ada_log("parse_path trivial");
15132|  4.67k|    buffer += '/';
15133|  4.67k|    buffer += input;
15134|  4.67k|    return;
15135|  4.67k|  }
15136|  5.20k|  std::string path = std::string(get_pathname());
15137|       |  // We are going to need to look a bit at the path, but let us see if we can
15138|       |  // ignore percent encoding *and* backslashes *and* percent characters.
15139|       |  // Except for the trivial case, this is likely to capture 99% of paths out
15140|       |  // there.
15141|  5.20k|  bool fast_path =
15142|  5.20k|      (special &&
  ------------------
  |  Branch (15142:8): [True: 4.04k, False: 1.16k]
  ------------------
15143|  4.04k|       (accumulator & (need_encoding | backslash_char | percent_char)) == 0) &&
  ------------------
  |  Branch (15143:8): [True: 1.29k, False: 2.75k]
  ------------------
15144|  1.29k|      (type != ada::scheme::type::FILE);
  ------------------
  |  Branch (15144:7): [True: 1.07k, False: 217]
  ------------------
15145|  5.20k|  if (fast_path) {
  ------------------
  |  Branch (15145:7): [True: 1.07k, False: 4.13k]
  ------------------
15146|  1.07k|    ada_log("parse_prepared_path fast");
15147|       |    // Here we don't need to worry about \ or percent encoding.
15148|       |    // We also do not have a file protocol. We might have dots, however,
15149|       |    // but dots must as appear as '.', and they cannot be encoded because
15150|       |    // the symbol '%' is not present.
15151|  1.07k|    size_t previous_location = 0;  // We start at 0.
15152|  12.9k|    do {
15153|  12.9k|      size_t new_location = input.find('/', previous_location);
15154|       |      // std::string_view path_view = input;
15155|       |      //  We process the last segment separately:
15156|  12.9k|      if (new_location == std::string_view::npos) {
  ------------------
  |  Branch (15156:11): [True: 1.07k, False: 11.9k]
  ------------------
15157|  1.07k|        std::string_view path_view = input.substr(previous_location);
15158|  1.07k|        if (path_view == "..") {  // The path ends with ..
  ------------------
  |  Branch (15158:13): [True: 131, False: 947]
  ------------------
15159|       |          // e.g., if you receive ".." with an empty path, you go to "/".
15160|    131|          if (path.empty()) {
  ------------------
  |  Branch (15160:15): [True: 53, False: 78]
  ------------------
15161|     53|            path = '/';
15162|     53|            update_base_pathname(path);
15163|     53|            return;
15164|     53|          }
15165|       |          // Fast case where we have nothing to do:
15166|     78|          if (path.back() == '/') {
  ------------------
  |  Branch (15166:15): [True: 21, False: 57]
  ------------------
15167|     21|            update_base_pathname(path);
15168|     21|            return;
15169|     21|          }
15170|       |          // If you have the path "/joe/myfriend",
15171|       |          // then you delete 'myfriend'.
15172|     57|          path.resize(path.rfind('/') + 1);
15173|     57|          update_base_pathname(path);
15174|     57|          return;
15175|     78|        }
15176|    947|        path += '/';
15177|    947|        if (path_view != ".") {
  ------------------
  |  Branch (15177:13): [True: 703, False: 244]
  ------------------
15178|    703|          path.append(path_view);
15179|    703|        }
15180|    947|        update_base_pathname(path);
15181|    947|        return;
15182|  11.9k|      } else {
15183|       |        // This is a non-final segment.
15184|  11.9k|        std::string_view path_view =
15185|  11.9k|            input.substr(previous_location, new_location - previous_location);
15186|  11.9k|        previous_location = new_location + 1;
15187|  11.9k|        if (path_view == "..") {
  ------------------
  |  Branch (15187:13): [True: 2.48k, False: 9.43k]
  ------------------
15188|  2.48k|          size_t last_delimiter = path.rfind('/');
15189|  2.48k|          if (last_delimiter != std::string::npos) {
  ------------------
  |  Branch (15189:15): [True: 1.00k, False: 1.48k]
  ------------------
15190|  1.00k|            path.erase(last_delimiter);
15191|  1.00k|          }
15192|  9.43k|        } else if (path_view != ".") {
  ------------------
  |  Branch (15192:20): [True: 7.96k, False: 1.46k]
  ------------------
15193|  7.96k|          path += '/';
15194|  7.96k|          path.append(path_view);
15195|  7.96k|        }
15196|  11.9k|      }
15197|  12.9k|    } while (true);
  ------------------
  |  Branch (15197:14): [True: 11.9k, Folded]
  ------------------
15198|  4.13k|  } else {
15199|  4.13k|    ada_log("parse_path slow");
15200|       |    // we have reached the general case
15201|  4.13k|    bool needs_percent_encoding = (accumulator & 1);
15202|  4.13k|    std::string path_buffer_tmp;
15203|  26.4k|    do {
15204|  26.4k|      size_t location = (special && (accumulator & 2))
  ------------------
  |  Branch (15204:26): [True: 19.7k, False: 6.72k]
  |  Branch (15204:37): [True: 1.63k, False: 18.0k]
  ------------------
15205|  26.4k|                            ? input.find_first_of("/\\")
15206|  26.4k|                            : input.find('/');
15207|  26.4k|      std::string_view path_view = input;
15208|  26.4k|      if (location != std::string_view::npos) {
  ------------------
  |  Branch (15208:11): [True: 22.3k, False: 4.13k]
  ------------------
15209|  22.3k|        path_view.remove_suffix(path_view.size() - location);
15210|  22.3k|        input.remove_prefix(location + 1);
15211|  22.3k|      }
15212|       |      // path_buffer is either path_view or it might point at a percent encoded
15213|       |      // temporary string.
15214|  26.4k|      std::string_view path_buffer =
15215|  26.4k|          (needs_percent_encoding &&
  ------------------
  |  Branch (15215:12): [True: 14.2k, False: 12.1k]
  ------------------
15216|  14.2k|           ada::unicode::percent_encode<false>(
  ------------------
  |  Branch (15216:12): [True: 5.61k, False: 8.68k]
  ------------------
15217|  14.2k|               path_view, character_sets::PATH_PERCENT_ENCODE, path_buffer_tmp))
15218|  26.4k|              ? path_buffer_tmp
15219|  26.4k|              : path_view;
15220|  26.4k|      if (unicode::is_double_dot_path_segment(path_buffer)) {
  ------------------
  |  Branch (15220:11): [True: 4.03k, False: 22.4k]
  ------------------
15221|  4.03k|        helpers::shorten_path(path, type);
15222|  4.03k|        if (location == std::string_view::npos) {
  ------------------
  |  Branch (15222:13): [True: 263, False: 3.77k]
  ------------------
15223|    263|          path += '/';
15224|    263|        }
15225|  22.4k|      } else if (unicode::is_single_dot_path_segment(path_buffer) &&
  ------------------
  |  Branch (15225:18): [True: 1.35k, False: 21.0k]
  ------------------
15226|  1.35k|                 (location == std::string_view::npos)) {
  ------------------
  |  Branch (15226:18): [True: 122, False: 1.23k]
  ------------------
15227|    122|        path += '/';
15228|    122|      }
15229|       |      // Otherwise, if path_buffer is not a single-dot path segment, then:
15230|  22.3k|      else if (!unicode::is_single_dot_path_segment(path_buffer)) {
  ------------------
  |  Branch (15230:16): [True: 21.0k, False: 1.23k]
  ------------------
15231|       |        // If url's scheme is "file", url's path is empty, and path_buffer is a
15232|       |        // Windows drive letter, then replace the second code point in
15233|       |        // path_buffer with U+003A (:).
15234|  21.0k|        if (type == ada::scheme::type::FILE && path.empty() &&
  ------------------
  |  Branch (15234:13): [True: 2.25k, False: 18.8k]
  |  Branch (15234:48): [True: 1.08k, False: 1.17k]
  ------------------
15235|  1.08k|            checkers::is_windows_drive_letter(path_buffer)) {
  ------------------
  |  Branch (15235:13): [True: 164, False: 916]
  ------------------
15236|    164|          path += '/';
15237|    164|          path += path_buffer[0];
15238|    164|          path += ':';
15239|    164|          path_buffer.remove_prefix(2);
15240|    164|          path.append(path_buffer);
15241|  20.9k|        } else {
15242|       |          // Append path_buffer to url's path.
15243|  20.9k|          path += '/';
15244|  20.9k|          path.append(path_buffer);
15245|  20.9k|        }
15246|  21.0k|      }
15247|  26.4k|      if (location == std::string_view::npos) {
  ------------------
  |  Branch (15247:11): [True: 4.13k, False: 22.3k]
  ------------------
15248|  4.13k|        update_base_pathname(path);
15249|  4.13k|        return;
15250|  4.13k|      }
15251|  26.4k|    } while (true);
  ------------------
  |  Branch (15251:14): [True: 22.3k, Folded]
  ------------------
15252|  4.13k|  }
15253|  5.20k|}
_ZN3ada8checkers7is_ipv4ENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
   12|  31.5k|ada_really_inline constexpr bool is_ipv4(std::string_view view) noexcept {
   13|       |  // The string is not empty and does not contain upper case ASCII characters.
   14|  31.5k|  if (!last_label_may_be_a_number(view)) {
  ------------------
  |  Branch (14:7): [True: 22.6k, False: 8.91k]
  ------------------
   15|  22.6k|    return false;
   16|  22.6k|  }
   17|       |  // If the address ends with a dot, we need to prune it (special case).
   18|  8.91k|  if (view.ends_with('.')) {
  ------------------
  |  Branch (18:7): [True: 510, False: 8.40k]
  ------------------
   19|    510|    view.remove_suffix(1);
   20|    510|  }
   21|       |  // From the last character, find the last dot.
   22|  8.91k|  size_t last_dot = view.rfind('.');
   23|  8.91k|  if (last_dot != std::string_view::npos) {
  ------------------
  |  Branch (23:7): [True: 2.52k, False: 6.39k]
  ------------------
   24|       |    // We have at least one dot.
   25|  2.52k|    view.remove_prefix(last_dot + 1);
   26|  2.52k|  }
   27|       |  /** Optimization opportunity: we have basically identified the last number of
   28|       |     the ipv4 if we return true here. We might as well parse it and have at
   29|       |     least one number parsed when we get to parse_ipv4. */
   30|  8.91k|  if (std::ranges::all_of(view, ada::checkers::is_digit)) {
  ------------------
  |  Branch (30:7): [True: 4.23k, False: 4.68k]
  ------------------
   31|  4.23k|    return true;
   32|  4.23k|  }
   33|       |  // It could be hex (0x), but not if there is a single character.
   34|  4.68k|  if (view.size() == 1) {
  ------------------
  |  Branch (34:7): [True: 0, False: 4.68k]
  ------------------
   35|      0|    return false;
   36|      0|  }
   37|       |  // It must start with 0x.
   38|  4.68k|  if (!view.starts_with("0x")) {
  ------------------
  |  Branch (38:7): [True: 2.21k, False: 2.46k]
  ------------------
   39|  2.21k|    return false;
   40|  2.21k|  }
   41|       |  // We must allow "0x".
   42|  2.46k|  if (view.size() == 2) {
  ------------------
  |  Branch (42:7): [True: 258, False: 2.21k]
  ------------------
   43|    258|    return true;
   44|    258|  }
   45|       |  // We have 0x followed by some characters, we need to check that they are
   46|       |  // hexadecimals.
   47|  2.21k|  view.remove_prefix(2);
   48|  2.21k|  return std::ranges::all_of(view, ada::unicode::is_lowercase_hex);
   49|  2.46k|}
_ZN3ada7unicode16is_lowercase_hexEc:
 7168|  24.5k|ada_really_inline constexpr bool is_lowercase_hex(const char c) noexcept {
 7169|  24.5k|  return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f');
  ------------------
  |  Branch (7169:11): [True: 24.5k, False: 0]
  |  Branch (7169:23): [True: 12.2k, False: 12.2k]
  |  Branch (7169:37): [True: 12.2k, False: 0]
  |  Branch (7169:49): [True: 11.2k, False: 1.08k]
  ------------------
 7170|  24.5k|}
_ZN3ada3url12parse_schemeILb0EEEbNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEE:
10015|  21.0k|ada_really_inline bool url::parse_scheme(const std::string_view input) {
10016|  21.0k|  auto parsed_type = ada::scheme::get_scheme_type(input);
10017|  21.0k|  bool is_input_special = (parsed_type != ada::scheme::NOT_SPECIAL);
10018|       |  /**
10019|       |   * In the common case, we will immediately recognize a special scheme (e.g.,
10020|       |   *http, https), in which case, we can go really fast.
10021|       |   **/
10022|  21.0k|  if (is_input_special) {  // fast path!!!
  ------------------
  |  Branch (10022:7): [True: 9.91k, False: 11.1k]
  ------------------
10023|       |    if constexpr (has_state_override) {
10024|       |      // If url's scheme is not a special scheme and buffer is a special scheme,
10025|       |      // then return.
10026|       |      if (is_special() != is_input_special) {
10027|       |        return false;
10028|       |      }
10029|       |
10030|       |      // If url includes credentials or has a non-null port, and buffer is
10031|       |      // "file", then return.
10032|       |      if ((has_credentials() || port.has_value()) &&
10033|       |          parsed_type == ada::scheme::type::FILE) {
10034|       |        return false;
10035|       |      }
10036|       |
10037|       |      // If url's scheme is "file" and its host is an empty host, then return.
10038|       |      // An empty host is the empty string.
10039|       |      if (type == ada::scheme::type::FILE && host.has_value() &&
10040|       |          host->empty()) {
10041|       |        return false;
10042|       |      }
10043|       |    }
10044|       |
10045|  9.91k|    type = parsed_type;
10046|       |
10047|       |    if constexpr (has_state_override) {
10048|       |      // This is uncommon.
10049|       |      uint16_t urls_scheme_port = get_special_port();
10050|       |
10051|       |      if (urls_scheme_port) {
10052|       |        // If url's port is url's scheme's default port, then set url's port to
10053|       |        // null.
10054|       |        if (port.has_value() && *port == urls_scheme_port) {
10055|       |          port = std::nullopt;
10056|       |        }
10057|       |      }
10058|       |    }
10059|  11.1k|  } else {  // slow path
10060|  11.1k|    std::string _buffer(input);
10061|       |    // Next function is only valid if the input is ASCII and returns false
10062|       |    // otherwise, but it seems that we always have ascii content so we do not
10063|       |    // need to check the return value.
10064|       |    // bool is_ascii =
10065|  11.1k|    unicode::to_lower_ascii(_buffer.data(), _buffer.size());
10066|       |
10067|       |    if constexpr (has_state_override) {
10068|       |      // The state-override validation errors below ("return" in the WHATWG URL
10069|       |      // parser) leave the URL unchanged. The setter contract is
10070|       |      // "true on success, false if the scheme is invalid" -- the fast path
10071|       |      // above already returns false here, so the slow path must agree.
10072|       |
10073|       |      // If url's scheme is a special scheme and buffer is not a special scheme,
10074|       |      // then return. If url's scheme is not a special scheme and buffer is a
10075|       |      // special scheme, then return.
10076|       |      if (is_special() != ada::scheme::is_special(_buffer)) {
10077|       |        return false;
10078|       |      }
10079|       |
10080|       |      // If url includes credentials or has a non-null port, and buffer is
10081|       |      // "file", then return.
10082|       |      if ((has_credentials() || port.has_value()) && _buffer == "file") {
10083|       |        return false;
10084|       |      }
10085|       |
10086|       |      // If url's scheme is "file" and its host is an empty host, then return.
10087|       |      // An empty host is the empty string.
10088|       |      if (type == ada::scheme::type::FILE && host.has_value() &&
10089|       |          host->empty()) {
10090|       |        return false;
10091|       |      }
10092|       |    }
10093|       |
10094|  11.1k|    set_scheme(std::move(_buffer));
10095|       |
10096|       |    if constexpr (has_state_override) {
10097|       |      // This is uncommon.
10098|       |      uint16_t urls_scheme_port = get_special_port();
10099|       |
10100|       |      if (urls_scheme_port) {
10101|       |        // If url's port is url's scheme's default port, then set url's port to
10102|       |        // null.
10103|       |        if (port.has_value() && *port == urls_scheme_port) {
10104|       |          port = std::nullopt;
10105|       |        }
10106|       |      }
10107|       |    }
10108|  11.1k|  }
10109|       |
10110|  21.0k|  return true;
10111|  21.0k|}
_ZN3ada14url_aggregator23parse_scheme_with_colonILb0EEEbNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEE:
13655|  41.7k|    const std::string_view input_with_colon) {
13656|  41.7k|  ada_log("url_aggregator::parse_scheme_with_colon ", input_with_colon);
13657|  41.7k|  ADA_ASSERT_TRUE(validate());
13658|  41.7k|  ADA_ASSERT_TRUE(!helpers::overlaps(input_with_colon, buffer));
13659|  41.7k|  std::string_view input{input_with_colon};
13660|  41.7k|  input.remove_suffix(1);
13661|  41.7k|  auto parsed_type = ada::scheme::get_scheme_type(input);
13662|  41.7k|  const bool is_input_special = (parsed_type != ada::scheme::NOT_SPECIAL);
13663|       |  /**
13664|       |   * In the common case, we will immediately recognize a special scheme (e.g.,
13665|       |   *http, https), in which case, we can go really fast.
13666|       |   **/
13667|  41.7k|  if (is_input_special) {  // fast path!!!
  ------------------
  |  Branch (13667:7): [True: 19.5k, False: 22.2k]
  ------------------
13668|       |    if constexpr (has_state_override) {
13669|       |      // If url's scheme is not a special scheme and buffer is a special scheme,
13670|       |      // then return.
13671|       |      if (is_special() != is_input_special) {
13672|       |        return false;
13673|       |      }
13674|       |
13675|       |      // If url includes credentials or has a non-null port, and buffer is
13676|       |      // "file", then return.
13677|       |      if ((has_credentials() || components.port != url_components::omitted) &&
13678|       |          parsed_type == ada::scheme::type::FILE) {
13679|       |        return false;
13680|       |      }
13681|       |
13682|       |      // If url's scheme is "file" and its host is an empty host, then return.
13683|       |      // An empty host is the empty string.
13684|       |      if (type == ada::scheme::type::FILE &&
13685|       |          components.host_start == components.host_end) {
13686|       |        return false;
13687|       |      }
13688|       |    }
13689|       |
13690|  19.5k|    type = parsed_type;
13691|  19.5k|    set_scheme_from_view_with_colon(input_with_colon);
13692|       |
13693|       |    if constexpr (has_state_override) {
13694|       |      // This is uncommon.
13695|       |      uint16_t urls_scheme_port = get_special_port();
13696|       |
13697|       |      if (urls_scheme_port) {
13698|       |        // If url's port is url's scheme's default port, then set url's port to
13699|       |        // null.
13700|       |        if (components.port == urls_scheme_port) {
13701|       |          clear_port();
13702|       |        }
13703|       |      }
13704|       |    }
13705|  22.2k|  } else {  // slow path
13706|  22.2k|    std::string _buffer(input);
13707|       |    // Next function is only valid if the input is ASCII and returns false
13708|       |    // otherwise, but it seems that we always have ascii content so we do not
13709|       |    // need to check the return value.
13710|  22.2k|    unicode::to_lower_ascii(_buffer.data(), _buffer.size());
13711|       |
13712|       |    if constexpr (has_state_override) {
13713|       |      // The state-override validation errors below ("return" in the WHATWG URL
13714|       |      // parser) leave the URL unchanged. The setter contract is
13715|       |      // "true on success, false if the scheme is invalid" -- the fast path
13716|       |      // above already returns false here, so the slow path must agree.
13717|       |
13718|       |      // If url's scheme is a special scheme and buffer is not a special scheme,
13719|       |      // then return. If url's scheme is not a special scheme and buffer is a
13720|       |      // special scheme, then return.
13721|       |      if (is_special() != ada::scheme::is_special(_buffer)) {
13722|       |        return false;
13723|       |      }
13724|       |
13725|       |      // If url includes credentials or has a non-null port, and buffer is
13726|       |      // "file", then return.
13727|       |      if ((has_credentials() || components.port != url_components::omitted) &&
13728|       |          _buffer == "file") {
13729|       |        return false;
13730|       |      }
13731|       |
13732|       |      // If url's scheme is "file" and its host is an empty host, then return.
13733|       |      // An empty host is the empty string.
13734|       |      if (type == ada::scheme::type::FILE &&
13735|       |          components.host_start == components.host_end) {
13736|       |        return false;
13737|       |      }
13738|       |    }
13739|       |
13740|  22.2k|    set_scheme(_buffer);
13741|       |
13742|       |    if constexpr (has_state_override) {
13743|       |      // This is uncommon.
13744|       |      uint16_t urls_scheme_port = get_special_port();
13745|       |
13746|       |      if (urls_scheme_port) {
13747|       |        // If url's port is url's scheme's default port, then set url's port to
13748|       |        // null.
13749|       |        if (components.port == urls_scheme_port) {
13750|       |          clear_port();
13751|       |        }
13752|       |      }
13753|       |    }
13754|  22.2k|  }
13755|  41.7k|  ADA_ASSERT_TRUE(validate());
13756|  41.7k|  return true;
13757|  41.7k|}
_ZN3ada14url_aggregator31set_scheme_from_view_with_colonENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
13781|  19.5k|    std::string_view new_scheme_with_colon) {
13782|  19.5k|  ada_log("url_aggregator::set_scheme_from_view_with_colon ",
13783|  19.5k|          new_scheme_with_colon);
13784|  19.5k|  ADA_ASSERT_TRUE(validate());
13785|  19.5k|  ADA_ASSERT_TRUE(!new_scheme_with_colon.empty() &&
13786|  19.5k|                  new_scheme_with_colon.back() == ':');
13787|       |  // next line could overflow but unsigned arithmetic has well-defined
13788|       |  // overflows.
13789|  19.5k|  uint32_t new_difference =
13790|  19.5k|      uint32_t(new_scheme_with_colon.size()) - components.protocol_end;
13791|       |
13792|  19.5k|  if (buffer.empty()) {
  ------------------
  |  Branch (13792:7): [True: 19.5k, False: 0]
  ------------------
13793|  19.5k|    buffer.append(new_scheme_with_colon);
13794|  19.5k|  } else {
13795|      0|    buffer.erase(0, components.protocol_end);
13796|      0|    buffer.insert(0, new_scheme_with_colon);
13797|      0|  }
13798|  19.5k|  components.protocol_end += new_difference;
13799|       |
13800|  19.5k|  apply_shifted_non_scheme_offsets(components, new_difference);
13801|  19.5k|  ADA_ASSERT_TRUE(validate());
13802|  19.5k|}
_ZN3ada14url_aggregator10set_schemeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
13804|  22.2k|inline void url_aggregator::set_scheme(std::string_view new_scheme) {
13805|  22.2k|  ada_log("url_aggregator::set_scheme ", new_scheme);
13806|  22.2k|  ADA_ASSERT_TRUE(validate());
13807|  22.2k|  ADA_ASSERT_TRUE(new_scheme.empty() || new_scheme.back() != ':');
13808|       |  // next line could overflow but unsigned arithmetic has well-defined
13809|       |  // overflows.
13810|  22.2k|  uint32_t new_difference =
13811|  22.2k|      uint32_t(new_scheme.size()) - components.protocol_end + 1;
13812|       |
13813|  22.2k|  type = ada::scheme::get_scheme_type(new_scheme);
13814|  22.2k|  if (buffer.empty()) {
  ------------------
  |  Branch (13814:7): [True: 22.2k, False: 0]
  ------------------
13815|  22.2k|    buffer.append(helpers::concat(new_scheme, ":"));
13816|  22.2k|  } else {
13817|      0|    buffer.erase(0, components.protocol_end);
13818|      0|    buffer.insert(0, helpers::concat(new_scheme, ":"));
13819|      0|  }
13820|  22.2k|  components.protocol_end = uint32_t(new_scheme.size() + 1);
13821|       |
13822|  22.2k|  apply_shifted_non_scheme_offsets(components, new_difference);
13823|  22.2k|  ADA_ASSERT_TRUE(validate());
13824|  22.2k|}

_ZN3ada37url_pattern_compile_component_optionsC2ENSt3__18optionalIcEES3_:
 5755|      6|      : delimiter(new_delimiter), prefix(new_prefix) {}
_ZN3ada14character_sets6bit_atEPKhh:
 1074|   330k|ada_really_inline constexpr bool bit_at(const uint8_t a[], const uint8_t i) {
 1075|   330k|  return !!(a[i >> 3] & (1 << (i & 7)));
 1076|   330k|}
_ZN2tl10unexpectedIN3ada6errorsEEC2EOS2_:
 2189|  98.5k|  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:
 3675|  24.6k|      : impl_base(unexpect, std::move(e.value())),
 3676|  24.6k|        ctor_base(detail::default_constructor_tag{}) {}
_ZNR2tl10unexpectedIN3ada6errorsEE5valueEv:
 2203|  49.2k|  TL_EXPECTED_11_CONSTEXPR E& value() & { return m_val; }
_ZN2tl6detail21expected_storage_baseIN3ada3urlENS2_6errorsELb0ELb1EEC2IJS4_ETnPNSt3__19enable_ifIXsr3std16is_constructibleIS4_DpOT_EE5valueEvE4typeELPv0EEENS_10unexpect_tESB_:
 2661|  24.6k|      : m_unexpect(std::forward<Args>(args)...), m_has_val(false) {}
_ZN2tl6detail26expected_default_ctor_baseIN3ada3urlENS2_6errorsELb1EEC2ENS0_23default_constructor_tagE:
 3279|  47.3k|  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_:
 3761|  22.7k|      : expected(in_place, std::forward<U>(v)) {}
_ZN2tl8expectedIN3ada3urlENS1_6errorsEEC2IJS2_ETnPNSt3__19enable_ifIXsr3std16is_constructibleIS2_DpOT_EE5valueEvE4typeELPv0EEENS_10in_place_tESA_:
 3634|  22.7k|      : impl_base(in_place, std::forward<Args>(args)...),
 3635|  22.7k|        ctor_base(detail::default_constructor_tag{}) {}
_ZN2tl6detail21expected_storage_baseIN3ada3urlENS2_6errorsELb0ELb1EEC2IJS3_ETnPNSt3__19enable_ifIXsr3std16is_constructibleIS3_DpOT_EE5valueEvE4typeELPv0EEENS_10in_place_tESB_:
 2649|  22.7k|      : m_val(std::forward<Args>(args)...), m_has_val(true) {}
_ZN3ada3urlC2EOS0_:
 5043|  22.7k|  url(url&& u) noexcept = default;
_ZN3ada8url_baseD2Ev:
 1693|   195k|  virtual ~url_base() = default;
_ZN3ada3urlD2Ev:
 5046|  70.1k|  ~url() override = default;
_ZN2tl8expectedIN3ada14url_aggregatorENS1_6errorsEEC2IS3_TnPNSt3__19enable_ifIXsr3std16is_constructibleIS3_OT_EE5valueEvE4typeELPv0ETnPNS7_IXsr3std14is_convertibleIS9_S3_EE5valueEvE4typeELSD_0EEEONS_10unexpectedIS8_EE:
 3675|  24.6k|      : impl_base(unexpect, std::move(e.value())),
 3676|  24.6k|        ctor_base(detail::default_constructor_tag{}) {}
_ZN2tl6detail21expected_storage_baseIN3ada14url_aggregatorENS2_6errorsELb0ELb1EEC2IJS4_ETnPNSt3__19enable_ifIXsr3std16is_constructibleIS4_DpOT_EE5valueEvE4typeELPv0EEENS_10unexpect_tESB_:
 2661|  24.6k|      : m_unexpect(std::forward<Args>(args)...), m_has_val(false) {}
_ZN2tl6detail26expected_default_ctor_baseIN3ada14url_aggregatorENS2_6errorsELb1EEC2ENS0_23default_constructor_tagE:
 3279|  47.3k|  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_:
 3761|  22.7k|      : expected(in_place, std::forward<U>(v)) {}
_ZN2tl8expectedIN3ada14url_aggregatorENS1_6errorsEEC2IJS2_ETnPNSt3__19enable_ifIXsr3std16is_constructibleIS2_DpOT_EE5valueEvE4typeELPv0EEENS_10in_place_tESA_:
 3634|  22.7k|      : impl_base(in_place, std::forward<Args>(args)...),
 3635|  22.7k|        ctor_base(detail::default_constructor_tag{}) {}
_ZN2tl6detail21expected_storage_baseIN3ada14url_aggregatorENS2_6errorsELb0ELb1EEC2IJS3_ETnPNSt3__19enable_ifIXsr3std16is_constructibleIS3_DpOT_EE5valueEvE4typeELPv0EEENS_10in_place_tESB_:
 2649|  22.7k|      : m_val(std::forward<Args>(args)...), m_has_val(true) {}
_ZN3ada14url_aggregatorC2EOS0_:
 7771|  22.7k|  url_aggregator(url_aggregator&& u) noexcept = default;
_ZN3ada14url_aggregatorD2Ev:
 7774|   125k|  ~url_aggregator() override = default;
_ZN3ada6scheme15get_scheme_typeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 6789|   113k|constexpr ada::scheme::type get_scheme_type(std::string_view scheme) noexcept {
 6790|   113k|  if (scheme.empty()) {
  ------------------
  |  Branch (6790:7): [True: 0, False: 113k]
  ------------------
 6791|      0|    return ada::scheme::NOT_SPECIAL;
 6792|      0|  }
 6793|   113k|  int hash_value = (2 * scheme.size() + (unsigned)(scheme[0])) & 7;
 6794|   113k|  const std::string_view target = details::is_special_list[hash_value];
 6795|   113k|  if (scheme.size() == target.size() &&
  ------------------
  |  Branch (6795:7): [True: 91.0k, False: 22.8k]
  ------------------
 6796|  91.0k|      details::branchless_load5(scheme.data(), scheme.size()) ==
  ------------------
  |  Branch (6796:7): [True: 61.2k, False: 29.8k]
  ------------------
 6797|  91.0k|          details::scheme_keys[hash_value]) {
 6798|  61.2k|    return ada::scheme::type(hash_value);
 6799|  61.2k|  } else {
 6800|  52.6k|    return ada::scheme::NOT_SPECIAL;
 6801|  52.6k|  }
 6802|   113k|}
_ZN3ada6scheme7details16branchless_load5EPKcm:
 6730|  91.0k|inline uint64_t branchless_load5(const char* p, size_t n) {
 6731|  91.0k|  uint64_t input = (uint8_t)p[0];
 6732|  91.0k|  input |= ((uint64_t)(uint8_t)p[n > 1] << 8) & (0 - (uint64_t)(n > 1));
 6733|  91.0k|  input |= ((uint64_t)(uint8_t)p[(n > 2) * 2] << 16) & (0 - (uint64_t)(n > 2));
 6734|  91.0k|  input |= ((uint64_t)(uint8_t)p[(n > 3) * 3] << 24) & (0 - (uint64_t)(n > 3));
 6735|  91.0k|  input |= ((uint64_t)(uint8_t)p[(n > 4) * 4] << 32) & (0 - (uint64_t)(n > 4));
 6736|  91.0k|  return input;
 6737|  91.0k|}
_ZN3ada14url_aggregatorC2Ev:
 7769|   102k|  url_aggregator() = default;
_ZN3ada14url_componentsC2Ev:
 4952|   102k|  url_components() = default;
_ZN3ada14url_aggregatoraSEOS0_:
 7772|  11.8k|  url_aggregator& operator=(url_aggregator&& u) noexcept = default;
_ZN3ada8checkers19try_parse_ipv4_fastENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 1446|  47.3k|try_parse_ipv4_fast(std::string_view input) noexcept {
 1447|  47.3k|  const size_t len = input.size();
 1448|       |  // Shortest pure decimal: "0.0.0.0" (7). Longest + trailing dot: 16.
 1449|  47.3k|  if (len < 7 || len > 16) [[unlikely]] {
  ------------------
  |  Branch (1449:7): [True: 23.6k, False: 23.7k]
  |  Branch (1449:18): [True: 9.81k, False: 13.8k]
  ------------------
 1450|  33.4k|    return ipv4_fast_fail;
 1451|  33.4k|  }
 1452|  13.8k|  const char* data = input.data();
 1453|       |
 1454|       |#if defined(ADA_AVX512) && defined(__AVX512VBMI2__)
 1455|       |  return detail::try_parse_ipv4_avx512(data, len);
 1456|       |#else
 1457|  13.8k|  return detail::parse_ipv4_decimal_scalar(data, data + len);
 1458|  47.3k|#endif
 1459|  47.3k|}
_ZN3ada8checkers6detail25parse_ipv4_decimal_scalarEPKcS3_:
 1287|  13.8k|parse_ipv4_decimal_scalar(const char* p, const char* pend) noexcept {
 1288|  13.8k|  uint32_t ipv4 = 0;
 1289|  30.7k|  for (int i = 0; i < 4; ++i) {
  ------------------
  |  Branch (1289:19): [True: 26.9k, False: 3.76k]
  ------------------
 1290|  26.9k|    if (p == pend) [[unlikely]] {
  ------------------
  |  Branch (1290:9): [True: 13, False: 26.9k]
  ------------------
 1291|     13|      return ipv4_fast_fail;
 1292|     13|    }
 1293|  26.9k|    uint32_t val;
 1294|  26.9k|    char c = *p;
 1295|  26.9k|    if (c >= '0' && c <= '9') [[likely]] {
  ------------------
  |  Branch (1295:9): [True: 24.8k, False: 2.13k]
  |  Branch (1295:21): [True: 20.3k, False: 4.44k]
  ------------------
 1296|  20.3k|      val = static_cast<uint32_t>(c - '0');
 1297|  20.3k|      ++p;
 1298|  20.3k|    } else {
 1299|  6.57k|      return ipv4_fast_fail;
 1300|  6.57k|    }
 1301|  20.3k|    if (p < pend) {
  ------------------
  |  Branch (1301:9): [True: 18.4k, False: 1.93k]
  ------------------
 1302|  18.4k|      c = *p;
 1303|  18.4k|      if (c >= '0' && c <= '9') {
  ------------------
  |  Branch (1303:11): [True: 7.84k, False: 10.5k]
  |  Branch (1303:23): [True: 6.44k, False: 1.39k]
  ------------------
 1304|  6.44k|        if (val == 0) [[unlikely]] {
  ------------------
  |  Branch (1304:13): [True: 622, False: 5.82k]
  ------------------
 1305|    622|          return ipv4_fast_fail;
 1306|    622|        }
 1307|  5.82k|        val = val * 10u + static_cast<uint32_t>(c - '0');
 1308|  5.82k|        ++p;
 1309|  5.82k|        if (p < pend) {
  ------------------
  |  Branch (1309:13): [True: 5.18k, False: 640]
  ------------------
 1310|  5.18k|          c = *p;
 1311|  5.18k|          if (c >= '0' && c <= '9') {
  ------------------
  |  Branch (1311:15): [True: 3.69k, False: 1.48k]
  |  Branch (1311:27): [True: 3.53k, False: 159]
  ------------------
 1312|  3.53k|            val = val * 10u + static_cast<uint32_t>(c - '0');
 1313|  3.53k|            ++p;
 1314|  3.53k|            if (val > 255u) [[unlikely]] {
  ------------------
  |  Branch (1314:17): [True: 815, False: 2.72k]
  ------------------
 1315|    815|              return ipv4_fast_fail;
 1316|    815|            }
 1317|  3.53k|          }
 1318|  5.18k|        }
 1319|  5.82k|      }
 1320|  18.4k|    }
 1321|  18.9k|    ipv4 = (ipv4 << 8) | val;
 1322|  18.9k|    if (i < 3) {
  ------------------
  |  Branch (1322:9): [True: 15.1k, False: 3.76k]
  ------------------
 1323|  15.1k|      if (p == pend || *p != '.') [[unlikely]] {
  ------------------
  |  Branch (1323:11): [True: 366, False: 14.7k]
  |  Branch (1323:24): [True: 1.73k, False: 13.0k]
  ------------------
 1324|  2.10k|        return ipv4_fast_fail;
 1325|  2.10k|      }
 1326|  13.0k|      ++p;
 1327|  13.0k|    }
 1328|  18.9k|  }
 1329|  3.76k|  if (p != pend) {
  ------------------
  |  Branch (1329:7): [True: 703, False: 3.06k]
  ------------------
 1330|    703|    if (p == pend - 1 && *p == '.') {
  ------------------
  |  Branch (1330:9): [True: 406, False: 297]
  |  Branch (1330:26): [True: 75, False: 331]
  ------------------
 1331|     75|      return ipv4;
 1332|     75|    }
 1333|    628|    return ipv4_fast_fail;
 1334|    703|  }
 1335|  3.06k|  return ipv4;
 1336|  3.76k|}
_ZNK3ada3url15has_credentialsEv:
 7307|  19.4k|[[nodiscard]] ada_really_inline bool url::has_credentials() const noexcept {
 7308|  19.4k|  return !username.empty() || !password.empty();
  ------------------
  |  Branch (7308:10): [True: 1.95k, False: 17.4k]
  |  Branch (7308:31): [True: 307, False: 17.1k]
  ------------------
 7309|  19.4k|}
_ZNK3ada8url_base10is_specialEv:
 7272|   317k|    const noexcept {
 7273|   317k|  return type != ada::scheme::NOT_SPECIAL;
 7274|   317k|}
_ZNK2tl8expectedIN3ada3urlENS1_6errorsEEcvbEv:
 4074|  26.7k|  constexpr explicit operator bool() const noexcept { return this->m_has_val; }
_ZN2tl8expectedIN3ada3urlENS1_6errorsEEptEv:
 4043|  18.7k|  TL_EXPECTED_11_CONSTEXPR T* operator->() {
 4044|  18.7k|    TL_ASSERT(has_value());
  ------------------
  |  | 2096|  18.7k|#define TL_ASSERT(x) assert(x)
  ------------------
  |  Branch (4044:5): [True: 18.7k, False: 0]
  ------------------
 4045|  18.7k|    return valptr();
 4046|  18.7k|  }
_ZN2tl8expectedIN3ada3urlENS1_6errorsEE6valptrEv:
 3339|  18.7k|  T* valptr() { return std::addressof(this->m_val); }
_ZN2tl6detail21expected_storage_baseIN3ada3urlENS2_6errorsELb0ELb1EED2Ev:
 2671|  47.3k|  ~expected_storage_base() {
 2672|  47.3k|    if (m_has_val) {
  ------------------
  |  Branch (2672:9): [True: 22.7k, False: 24.6k]
  ------------------
 2673|  22.7k|      m_val.~T();
 2674|  22.7k|    }
 2675|  47.3k|  }
_ZNK3ada3url13get_href_sizeEv:
 7562|  24.0k|[[nodiscard]] inline size_t url::get_href_size() const noexcept {
 7563|  24.0k|  size_t size = 0;
 7564|  24.0k|  if (is_special()) {
  ------------------
  |  Branch (7564:7): [True: 15.0k, False: 8.92k]
  ------------------
 7565|  15.0k|    size += ada::scheme::details::is_special_list[type].size() + 1;
 7566|  15.0k|  } else {
 7567|  8.92k|    size += non_special_scheme.size() + 1;
 7568|  8.92k|  }
 7569|  24.0k|  if (host.has_value()) {
  ------------------
  |  Branch (7569:7): [True: 16.4k, False: 7.50k]
  ------------------
 7570|  16.4k|    size += host->size();
 7571|  16.4k|    size += 2;
 7572|  16.4k|    if (has_credentials()) {
  ------------------
  |  Branch (7572:9): [True: 1.54k, False: 14.9k]
  ------------------
 7573|  1.54k|      size += username.size();
 7574|  1.54k|      if (!password.empty()) {
  ------------------
  |  Branch (7574:11): [True: 530, False: 1.01k]
  ------------------
 7575|    530|        size += 1 + password.size();
 7576|    530|      }
 7577|  1.54k|      size += 1;
 7578|  1.54k|    }
 7579|  16.4k|    if (port.has_value()) {
  ------------------
  |  Branch (7579:9): [True: 2.80k, False: 13.6k]
  ------------------
 7580|  2.80k|      size += 1;
 7581|  2.80k|      uint16_t p = *port;
 7582|  2.80k|      size += (p >= 10000)  ? 5
  ------------------
  |  Branch (7582:15): [True: 118, False: 2.69k]
  ------------------
 7583|  2.80k|              : (p >= 1000) ? 4
  ------------------
  |  Branch (7583:17): [True: 106, False: 2.58k]
  ------------------
 7584|  2.69k|              : (p >= 100)  ? 3
  ------------------
  |  Branch (7584:17): [True: 126, False: 2.45k]
  ------------------
 7585|  2.58k|              : (p >= 10)   ? 2
  ------------------
  |  Branch (7585:17): [True: 86, False: 2.37k]
  ------------------
 7586|  2.45k|                            : 1;
 7587|  2.80k|    }
 7588|  16.4k|  } else if (!has_opaque_path && path.starts_with("//")) {
  ------------------
  |  Branch (7588:14): [True: 2.83k, False: 4.67k]
  |  Branch (7588:34): [True: 97, False: 2.73k]
  ------------------
 7589|     97|    size += 2;
 7590|     97|  }
 7591|  24.0k|  size += path.size();
 7592|  24.0k|  if (query.has_value()) {
  ------------------
  |  Branch (7592:7): [True: 1.70k, False: 22.2k]
  ------------------
 7593|  1.70k|    size += 1 + query->size();
 7594|  1.70k|  }
 7595|  24.0k|  if (hash.has_value()) {
  ------------------
  |  Branch (7595:7): [True: 1.26k, False: 22.7k]
  ------------------
 7596|  1.26k|    size += 1 + hash->size();
 7597|  1.26k|  }
 7598|  24.0k|  return size;
 7599|  24.0k|}
_ZN3ada8checkers8is_alphaEc:
 1267|  95.4k|constexpr bool is_alpha(char x) noexcept {
 1268|  95.4k|  return (to_lower(x) >= 'a') && (to_lower(x) <= 'z');
  ------------------
  |  Branch (1268:10): [True: 87.3k, False: 8.16k]
  |  Branch (1268:34): [True: 87.0k, False: 257]
  ------------------
 1269|  95.4k|}
_ZN3ada8checkers8to_lowerEc:
 1265|   182k|constexpr char to_lower(char x) noexcept { return (x | 0x20); }
_ZNR2tl8expectedIN3ada3urlENS1_6errorsEEdeIS2_TnPNSt3__19enable_ifIXntsr3std7is_voidIT_EE5valueEvE4typeELPv0EEERS8_v:
 4056|  3.97k|  TL_EXPECTED_11_CONSTEXPR U& operator*() & {
 4057|  3.97k|    TL_ASSERT(has_value());
  ------------------
  |  | 2096|  3.97k|#define TL_ASSERT(x) assert(x)
  ------------------
  |  Branch (4057:5): [True: 3.97k, False: 0]
  ------------------
 4058|  3.97k|    return val();
 4059|  3.97k|  }
_ZN2tl8expectedIN3ada3urlENS1_6errorsEE3valIS2_TnPNSt3__19enable_ifIXntsr3std7is_voidIT_EE5valueEvE4typeELPv0EEERS8_v:
 3348|  3.97k|  TL_EXPECTED_11_CONSTEXPR U& val() {
 3349|  3.97k|    return this->m_val;
 3350|  3.97k|  }
_ZN3ada3urlaSERKS0_:
 5045|    152|  url& operator=(const url& u) = default;
_ZNK2tl8expectedIN3ada3urlENS1_6errorsEE9has_valueEv:
 4073|  74.1k|  constexpr bool has_value() const noexcept { return this->m_has_val; }
_ZN3ada8checkers26last_label_may_be_a_numberENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 1240|  47.0k|constexpr bool last_label_may_be_a_number(std::string_view view) noexcept {
 1241|  47.0k|  if (view.empty()) {
  ------------------
  |  Branch (1241:7): [True: 0, False: 47.0k]
  ------------------
 1242|      0|    return false;
 1243|      0|  }
 1244|  47.0k|  const char* start = view.data();
 1245|  47.0k|  const char* end = start + view.size();
 1246|  47.0k|  if (end[-1] == '.') {
  ------------------
  |  Branch (1246:7): [True: 4.50k, False: 42.5k]
  ------------------
 1247|  4.50k|    --end;
 1248|  4.50k|    if (end == start) {
  ------------------
  |  Branch (1248:9): [True: 2.83k, False: 1.66k]
  ------------------
 1249|  2.83k|      return false;
 1250|  2.83k|    }
 1251|  4.50k|  }
 1252|  44.1k|  if (!is_ipv4_number_char(end[-1])) {
  ------------------
  |  Branch (1252:7): [True: 20.2k, False: 23.9k]
  ------------------
 1253|  20.2k|    return false;
 1254|  20.2k|  }
 1255|  23.9k|  const char* label = end;
 1256|   156k|  while (label != start && is_ipv4_number_char(label[-1])) {
  ------------------
  |  Branch (1256:10): [True: 145k, False: 11.4k]
  |  Branch (1256:28): [True: 132k, False: 12.5k]
  ------------------
 1257|   132k|    --label;
 1258|   132k|  }
 1259|  23.9k|  if (label != start && label[-1] != '.') {
  ------------------
  |  Branch (1259:7): [True: 12.5k, False: 11.4k]
  |  Branch (1259:25): [True: 9.12k, False: 3.40k]
  ------------------
 1260|  9.12k|    return false;
 1261|  9.12k|  }
 1262|  14.8k|  return label != end && is_digit(*label);
  ------------------
  |  Branch (1262:10): [True: 14.8k, False: 0]
  |  Branch (1262:26): [True: 9.36k, False: 5.46k]
  ------------------
 1263|  23.9k|}
_ZN3ada8checkers19is_ipv4_number_charEc:
 1234|   189k|constexpr bool is_ipv4_number_char(char x) noexcept {
 1235|   189k|  const unsigned char c = static_cast<unsigned char>(x);
 1236|   189k|  return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') ||
  ------------------
  |  Branch (1236:11): [True: 178k, False: 11.0k]
  |  Branch (1236:23): [True: 65.0k, False: 113k]
  |  Branch (1236:37): [True: 111k, False: 12.9k]
  |  Branch (1236:49): [True: 62.8k, False: 48.5k]
  ------------------
 1237|  61.5k|         (c >= 'A' && c <= 'F') || c == 'x' || c == 'X';
  ------------------
  |  Branch (1237:11): [True: 49.8k, False: 11.7k]
  |  Branch (1237:23): [True: 519, False: 49.2k]
  |  Branch (1237:36): [True: 27.9k, False: 33.0k]
  |  Branch (1237:48): [True: 285, False: 32.7k]
  ------------------
 1238|   189k|}
_ZN3ada8checkers8is_digitEc:
 1232|  47.5k|constexpr bool is_digit(char x) noexcept { return (x >= '0') & (x <= '9'); }
_ZN3ada6scheme16get_special_portENS0_4typeE:
 6786|  7.90k|constexpr uint16_t get_special_port(ada::scheme::type type) noexcept {
 6787|  7.90k|  return details::special_ports[int(type)];
 6788|  7.90k|}
_ZN3ada14url_aggregatoraSERKS0_:
 7773|    152|  url_aggregator& operator=(const url_aggregator& u) = default;
_ZN3ada14url_aggregator10clear_hashEv:
 8851|    127|inline void url_aggregator::clear_hash() {
 8852|    127|  ada_log("url_aggregator::clear_hash");
 8853|    127|  ADA_ASSERT_TRUE(validate());
 8854|    127|  if (components.hash_start == url_components::omitted) {
  ------------------
  |  Branch (8854:7): [True: 109, False: 18]
  ------------------
 8855|    109|    return;
 8856|    109|  }
 8857|     18|  buffer.resize(components.hash_start);
 8858|     18|  components.hash_start = url_components::omitted;
 8859|       |
 8860|       |#if ADA_DEVELOPMENT_CHECKS
 8861|       |  ADA_ASSERT_EQUAL(get_hash(), "",
 8862|       |                   "hash should have been cleared on buffer=" + buffer +
 8863|       |                       " with " + components.to_string() + "\n" + to_diagram());
 8864|       |#endif
 8865|     18|  ADA_ASSERT_TRUE(validate());
 8866|     18|}
_ZN3ada14url_aggregator20update_base_pathnameENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8494|  16.9k|inline void url_aggregator::update_base_pathname(const std::string_view input) {
 8495|  16.9k|  ada_log("url_aggregator::update_base_pathname '", input, "' [", input.size(),
 8496|  16.9k|          " bytes] \n", to_diagram());
 8497|  16.9k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 8498|  16.9k|  ADA_ASSERT_TRUE(validate());
 8499|       |
 8500|  16.9k|  const bool begins_with_dashdash = input.starts_with("//");
 8501|  16.9k|  if (!begins_with_dashdash && has_dash_dot()) {
  ------------------
  |  Branch (8501:7): [True: 16.3k, False: 586]
  |  Branch (8501:32): [True: 8, False: 16.3k]
  ------------------
 8502|       |    // We must delete the ./
 8503|      8|    delete_dash_dot();
 8504|      8|  }
 8505|       |
 8506|  16.9k|  if (begins_with_dashdash && !has_opaque_path && !has_authority() &&
  ------------------
  |  Branch (8506:7): [True: 586, False: 16.3k]
  |  Branch (8506:31): [True: 586, False: 0]
  |  Branch (8506:51): [True: 69, False: 517]
  ------------------
 8507|     69|      !has_dash_dot()) {
  ------------------
  |  Branch (8507:7): [True: 63, False: 6]
  ------------------
 8508|       |    // If url's host is null, url does not have an opaque path, url's path's
 8509|       |    // size is greater than 1, then append U+002F (/) followed by U+002E (.) to
 8510|       |    // output.
 8511|     63|    buffer.insert(components.pathname_start, "/.");
 8512|     63|    components.pathname_start += 2;
 8513|     63|    if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8513:9): [True: 0, False: 63]
  ------------------
 8514|      0|      components.search_start += 2;
 8515|      0|    }
 8516|     63|    if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8516:9): [True: 0, False: 63]
  ------------------
 8517|      0|      components.hash_start += 2;
 8518|      0|    }
 8519|     63|  }
 8520|       |
 8521|  16.9k|  uint32_t difference = replace_and_resize(
 8522|  16.9k|      components.pathname_start,
 8523|  16.9k|      components.pathname_start + get_pathname_length(), input);
 8524|  16.9k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8524:7): [True: 0, False: 16.9k]
  ------------------
 8525|      0|    components.search_start += difference;
 8526|      0|  }
 8527|  16.9k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8527:7): [True: 0, False: 16.9k]
  ------------------
 8528|      0|    components.hash_start += difference;
 8529|      0|  }
 8530|  16.9k|  ADA_ASSERT_TRUE(validate());
 8531|  16.9k|}
_ZN3ada14url_aggregator18replace_and_resizeEjjNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8336|  52.0k|    uint32_t start, uint32_t end, std::string_view input) {
 8337|  52.0k|  uint32_t current_length = end - start;
 8338|  52.0k|  uint32_t input_size = uint32_t(input.size());
 8339|  52.0k|  uint32_t new_difference = input_size - current_length;
 8340|       |
 8341|  52.0k|  if (current_length == 0) {
  ------------------
  |  Branch (8341:7): [True: 47.6k, False: 4.41k]
  ------------------
 8342|  47.6k|    buffer.insert(start, input);
 8343|  47.6k|  } else if (input_size == current_length) {
  ------------------
  |  Branch (8343:14): [True: 585, False: 3.83k]
  ------------------
 8344|    585|    if (input_size != 0) {
  ------------------
  |  Branch (8344:9): [True: 585, False: 0]
  ------------------
 8345|    585|      std::memmove(buffer.data() + start, input.data(), input_size);
 8346|    585|    }
 8347|  3.83k|  } else if (input_size < current_length) {
  ------------------
  |  Branch (8347:14): [True: 712, False: 3.11k]
  ------------------
 8348|    712|    buffer.erase(start, current_length - input_size);
 8349|    712|    buffer.replace(start, input_size, input);
 8350|  3.11k|  } else {
 8351|  3.11k|    buffer.replace(start, current_length, input.substr(0, current_length));
 8352|  3.11k|    buffer.insert(start + current_length, input.substr(current_length));
 8353|  3.11k|  }
 8354|       |
 8355|  52.0k|  return new_difference;
 8356|  52.0k|}
_ZNK3ada14url_aggregator19get_pathname_lengthEv:
 8387|  16.9k|url_aggregator::get_pathname_length() const noexcept {
 8388|  16.9k|  ada_log("url_aggregator::get_pathname_length");
 8389|  16.9k|  uint32_t ending_index = uint32_t(buffer.size());
 8390|  16.9k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8390:7): [True: 0, False: 16.9k]
  ------------------
 8391|      0|    ending_index = components.search_start;
 8392|  16.9k|  } else if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8392:14): [True: 0, False: 16.9k]
  ------------------
 8393|      0|    ending_index = components.hash_start;
 8394|      0|  }
 8395|  16.9k|  return ending_index - components.pathname_start;
 8396|  16.9k|}
_ZNK3ada14url_aggregator12get_pathnameEv:
 9329|  8.24k|    ada_lifetime_bound {
 9330|  8.24k|  ada_log("url_aggregator::get_pathname pathname_start = ",
 9331|  8.24k|          components.pathname_start, " buffer.size() = ", buffer.size(),
 9332|  8.24k|          " components.search_start = ", components.search_start,
 9333|  8.24k|          " components.hash_start = ", components.hash_start);
 9334|  8.24k|  auto ending_index = uint32_t(buffer.size());
 9335|  8.24k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9335:7): [True: 197, False: 8.05k]
  ------------------
 9336|    197|    ending_index = components.search_start;
 9337|  8.05k|  } else if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9337:14): [True: 66, False: 7.98k]
  ------------------
 9338|     66|    ending_index = components.hash_start;
 9339|     66|  }
 9340|  8.24k|  return helpers::substring(buffer, components.pathname_start, ending_index);
 9341|  8.24k|}
_ZN3ada14url_aggregator26update_unencoded_base_hashENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8312|  1.00k|inline void url_aggregator::update_unencoded_base_hash(std::string_view input) {
 8313|  1.00k|  ada_log("url_aggregator::update_unencoded_base_hash ", input, " [",
 8314|  1.00k|          input.size(), " bytes], buffer is '", buffer, "' [", buffer.size(),
 8315|  1.00k|          " bytes] components.hash_start = ", components.hash_start);
 8316|  1.00k|  ADA_ASSERT_TRUE(validate());
 8317|  1.00k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 8318|  1.00k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8318:7): [True: 16, False: 986]
  ------------------
 8319|     16|    buffer.resize(components.hash_start);
 8320|     16|  }
 8321|  1.00k|  components.hash_start = uint32_t(buffer.size());
 8322|  1.00k|  buffer += "#";
 8323|  1.00k|  bool encoding_required = unicode::percent_encode<true>(
 8324|  1.00k|      input, ada::character_sets::FRAGMENT_PERCENT_ENCODE, buffer);
 8325|       |  // When encoding_required is false, then buffer is left unchanged, and percent
 8326|       |  // encoding was not deemed required.
 8327|  1.00k|  if (!encoding_required) {
  ------------------
  |  Branch (8327:7): [True: 701, False: 301]
  ------------------
 8328|    701|    buffer.append(input);
 8329|    701|  }
 8330|  1.00k|  ada_log("url_aggregator::update_unencoded_base_hash final buffer is '",
 8331|  1.00k|          buffer, "' [", buffer.size(), " bytes]");
 8332|  1.00k|  ADA_ASSERT_TRUE(validate());
 8333|  1.00k|}
_ZN3ada3urlC2Ev:
 5041|  47.3k|  url() = default;
_ZN3ada3url11copy_schemeERKS0_:
 7470|    630|constexpr void url::copy_scheme(const ada::url& u) {
 7471|    630|  non_special_scheme = u.non_special_scheme;
 7472|    630|  type = u.type;
 7473|    630|}
_ZN3ada3url26update_unencoded_base_hashENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 7412|    893|inline void url::update_unencoded_base_hash(std::string_view input) {
 7413|       |  // We do the percent encoding
 7414|    893|  hash = unicode::percent_encode(input,
 7415|    893|                                 ada::character_sets::FRAGMENT_PERCENT_ENCODE);
 7416|    893|}
_ZN3ada3url12clear_searchEv:
 7445|    488|constexpr void url::clear_search() { query = std::nullopt; }
_ZN3ada3url18update_base_searchENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKh:
 7419|  1.16k|                                    const uint8_t query_percent_encode_set[]) {
 7420|  1.16k|  query = ada::unicode::percent_encode(input, query_percent_encode_set);
 7421|  1.16k|}
_ZN3ada3url20update_base_hostnameENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 7410|    136|inline void url::update_base_hostname(std::string_view input) { host = input; }
_ZN3ada3url20update_base_pathnameENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 7427|  9.38k|inline void url::update_base_pathname(const std::string_view input) {
 7428|  9.38k|  path = input;
 7429|  9.38k|}
_ZN3ada3url10parse_portENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEb:
 7602|  1.94k|                                         bool check_trailing_content) noexcept {
 7603|  1.94k|  ada_log("parse_port('", view, "') ", view.size());
 7604|  1.94k|  if (!view.empty() && view[0] == '-') {
  ------------------
  |  Branch (7604:7): [True: 1.30k, False: 640]
  |  Branch (7604:24): [True: 3, False: 1.30k]
  ------------------
 7605|      3|    ada_log("parse_port: view[0] == '0' && view.size() > 1");
 7606|      3|    is_valid = false;
 7607|      3|    return 0;
 7608|      3|  }
 7609|  1.94k|  uint16_t parsed_port{};
 7610|  1.94k|  auto r = std::from_chars(view.data(), view.data() + view.size(), parsed_port);
 7611|  1.94k|  if (r.ec == std::errc::result_out_of_range) {
  ------------------
  |  Branch (7611:7): [True: 35, False: 1.90k]
  ------------------
 7612|     35|    ada_log("parse_port: r.ec == std::errc::result_out_of_range");
 7613|     35|    is_valid = false;
 7614|     35|    return 0;
 7615|     35|  }
 7616|  1.90k|  ada_log("parse_port: ", parsed_port);
 7617|  1.90k|  const auto consumed = size_t(r.ptr - view.data());
 7618|  1.90k|  ada_log("parse_port: consumed ", consumed);
 7619|  1.90k|  if (check_trailing_content) {
  ------------------
  |  Branch (7619:7): [True: 1.90k, False: 0]
  ------------------
 7620|  1.90k|    is_valid &=
 7621|  1.90k|        (consumed == view.size() || view[consumed] == '/' ||
  ------------------
  |  Branch (7621:10): [True: 1.22k, False: 686]
  |  Branch (7621:37): [True: 565, False: 121]
  ------------------
 7622|    121|         view[consumed] == '?' || (is_special() && view[consumed] == '\\'));
  ------------------
  |  Branch (7622:10): [True: 48, False: 73]
  |  Branch (7622:36): [True: 70, False: 3]
  |  Branch (7622:52): [True: 2, False: 68]
  ------------------
 7623|  1.90k|  }
 7624|  1.90k|  ada_log("parse_port: is_valid = ", is_valid);
 7625|  1.90k|  if (is_valid) {
  ------------------
  |  Branch (7625:7): [True: 1.83k, False: 71]
  ------------------
 7626|       |    // scheme_default_port can return 0, and we should allow 0 as a base port.
 7627|  1.83k|    auto default_port = scheme_default_port();
 7628|  1.83k|    bool is_port_valid = (default_port == 0 && parsed_port == 0) ||
  ------------------
  |  Branch (7628:27): [True: 82, False: 1.75k]
  |  Branch (7628:48): [True: 28, False: 54]
  ------------------
 7629|  1.80k|                         (default_port != parsed_port);
  ------------------
  |  Branch (7629:26): [True: 1.80k, False: 7]
  ------------------
 7630|  1.83k|    port = (r.ec == std::errc() && is_port_valid) ? std::optional(parsed_port)
  ------------------
  |  Branch (7630:13): [True: 1.10k, False: 733]
  |  Branch (7630:36): [True: 1.09k, False: 7]
  ------------------
 7631|  1.83k|                                                  : std::nullopt;
 7632|  1.83k|  }
 7633|  1.90k|  return consumed;
 7634|  1.94k|}
_ZNK3ada8url_base19scheme_default_portEv:
 7281|  5.57k|url_base::scheme_default_port() const noexcept {
 7282|  5.57k|  return scheme::get_special_port(type);
 7283|  5.57k|}
_ZNK3ada3url12get_pathnameEv:
 7333|    159|[[nodiscard]] constexpr std::string_view url::get_pathname() const noexcept {
 7334|    159|  return path;
 7335|    159|}
_ZN3ada8checkers23is_windows_drive_letterENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 1271|  12.5k|constexpr bool is_windows_drive_letter(std::string_view input) noexcept {
 1272|  12.5k|  return input.size() >= 2 &&
  ------------------
  |  Branch (1272:10): [True: 8.64k, False: 3.92k]
  ------------------
 1273|  8.64k|         (is_alpha(input[0]) && ((input[1] == ':') || (input[1] == '|'))) &&
  ------------------
  |  Branch (1273:11): [True: 3.54k, False: 5.10k]
  |  Branch (1273:34): [True: 855, False: 2.68k]
  |  Branch (1273:55): [True: 517, False: 2.17k]
  ------------------
 1274|  1.37k|         ((input.size() == 2) || (input[2] == '/' || input[2] == '\\' ||
  ------------------
  |  Branch (1274:11): [True: 529, False: 843]
  |  Branch (1274:35): [True: 156, False: 687]
  |  Branch (1274:54): [True: 34, False: 653]
  ------------------
 1275|    653|                                  input[2] == '?' || input[2] == '#'));
  ------------------
  |  Branch (1275:35): [True: 5, False: 648]
  |  Branch (1275:54): [True: 0, False: 648]
  ------------------
 1276|  12.5k|}
_ZN3ada8checkers34is_normalized_windows_drive_letterENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 1279|  2.01k|    std::string_view input) noexcept {
 1280|  2.01k|  return input.size() == 2 && (is_alpha(input[0]) && (input[1] == ':'));
  ------------------
  |  Branch (1280:10): [True: 988, False: 1.03k]
  |  Branch (1280:32): [True: 846, False: 142]
  |  Branch (1280:54): [True: 764, False: 82]
  ------------------
 1281|  2.01k|}
_ZN3ada3url20set_protocol_as_fileEv:
 7455|  2.97k|constexpr void url::set_protocol_as_file() { type = ada::scheme::type::FILE; }
_ZN3ada3url14clear_pathnameEv:
 7443|     22|constexpr void url::clear_pathname() { path.clear(); }
_ZN3ada7helpers14leading_zeroesEj:
 1978|  42.9k|inline int leading_zeroes(uint32_t input_num) noexcept {
 1979|       |#if ADA_REGULAR_VISUAL_STUDIO
 1980|       |  unsigned long leading_zero(0);
 1981|       |  unsigned long in(input_num);
 1982|       |  return _BitScanReverse(&leading_zero, in) ? int(31 - leading_zero) : 32;
 1983|       |#else
 1984|  42.9k|  return __builtin_clz(input_num);
 1985|  42.9k|#endif  // ADA_REGULAR_VISUAL_STUDIO
 1986|  42.9k|}
_ZN3ada14url_aggregator7reserveEj:
 9002|  42.9k|constexpr void ada::url_aggregator::reserve(uint32_t capacity) {
 9003|  42.9k|  buffer.reserve(capacity);
 9004|  42.9k|}
_ZN3ada14url_aggregator18update_base_searchENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8403|    169|inline void url_aggregator::update_base_search(std::string_view input) {
 8404|    169|  ada_log("url_aggregator::update_base_search ", input);
 8405|    169|  ADA_ASSERT_TRUE(validate());
 8406|    169|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 8407|    169|  if (input.empty()) {
  ------------------
  |  Branch (8407:7): [True: 0, False: 169]
  ------------------
 8408|      0|    clear_search();
 8409|      0|    return;
 8410|      0|  }
 8411|       |
 8412|    169|  if (input[0] == '?') {
  ------------------
  |  Branch (8412:7): [True: 169, False: 0]
  ------------------
 8413|    169|    input.remove_prefix(1);
 8414|    169|  }
 8415|       |
 8416|    169|  if (components.hash_start == url_components::omitted) {
  ------------------
  |  Branch (8416:7): [True: 169, False: 0]
  ------------------
 8417|    169|    if (components.search_start == url_components::omitted) {
  ------------------
  |  Branch (8417:9): [True: 169, False: 0]
  ------------------
 8418|    169|      components.search_start = uint32_t(buffer.size());
 8419|    169|      buffer += "?";
 8420|    169|    } else {
 8421|      0|      buffer.resize(components.search_start + 1);
 8422|      0|    }
 8423|       |
 8424|    169|    buffer.append(input);
 8425|    169|  } else if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8425:14): [True: 0, False: 0]
  ------------------
 8426|      0|    const uint32_t difference = replace_and_resize(
 8427|      0|        components.search_start + 1, components.hash_start, input);
 8428|      0|    components.hash_start += difference;
 8429|      0|  } else {
 8430|      0|    components.search_start = components.hash_start;
 8431|      0|    buffer.insert(components.search_start, input.size() + 1, '?');
 8432|      0|    if (!input.empty()) {
  ------------------
  |  Branch (8432:9): [True: 0, False: 0]
  ------------------
 8433|      0|      std::memmove(buffer.data() + components.search_start + 1, input.data(),
 8434|      0|                   input.size());
 8435|      0|    }
 8436|      0|    components.hash_start += uint32_t(input.size() + 1);  // Do not forget `?`
 8437|      0|  }
 8438|       |
 8439|    169|  ADA_ASSERT_TRUE(validate());
 8440|    169|}
_ZN3ada14url_aggregator20append_base_passwordENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8720|  7.44k|inline void url_aggregator::append_base_password(const std::string_view input) {
 8721|  7.44k|  ada_log("url_aggregator::append_base_password ", input, " ", to_string(),
 8722|  7.44k|          "\n", to_diagram());
 8723|  7.44k|  ADA_ASSERT_TRUE(validate());
 8724|  7.44k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 8725|       |#if ADA_DEVELOPMENT_CHECKS
 8726|       |  // computing the expected password.
 8727|       |  std::string password_expected = std::string(get_password());
 8728|       |  password_expected.append(input);
 8729|       |#endif  // ADA_DEVELOPMENT_CHECKS
 8730|  7.44k|  add_authority_slashes_if_needed();
 8731|       |
 8732|       |  // If input is empty, do nothing.
 8733|  7.44k|  if (input.empty()) {
  ------------------
  |  Branch (8733:7): [True: 2.02k, False: 5.42k]
  ------------------
 8734|  2.02k|    return;
 8735|  2.02k|  }
 8736|       |
 8737|  5.42k|  uint32_t difference = uint32_t(input.size());
 8738|  5.42k|  if (has_password()) {
  ------------------
  |  Branch (8738:7): [True: 4.80k, False: 625]
  ------------------
 8739|  4.80k|    buffer.insert(components.host_start, input);
 8740|  4.80k|  } else {
 8741|    625|    difference++;  // Increment for ":"
 8742|    625|    buffer.insert(components.username_end, ":");
 8743|    625|    buffer.insert(components.username_end + 1, input);
 8744|    625|  }
 8745|  5.42k|  components.host_start += difference;
 8746|       |
 8747|       |  // The following line is required to add "@" to hostname. When updating
 8748|       |  // password if hostname does not start with "@", it is "append_base_password"s
 8749|       |  // responsibility to set it.
 8750|  5.42k|  if (buffer[components.host_start] != '@') {
  ------------------
  |  Branch (8750:7): [True: 422, False: 5.00k]
  ------------------
 8751|    422|    buffer.insert(components.host_start, "@");
 8752|    422|    difference++;
 8753|    422|  }
 8754|       |
 8755|  5.42k|  components.host_end += difference;
 8756|  5.42k|  components.pathname_start += difference;
 8757|  5.42k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8757:7): [True: 0, False: 5.42k]
  ------------------
 8758|      0|    components.search_start += difference;
 8759|      0|  }
 8760|  5.42k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8760:7): [True: 0, False: 5.42k]
  ------------------
 8761|      0|    components.hash_start += difference;
 8762|      0|  }
 8763|       |#if ADA_DEVELOPMENT_CHECKS
 8764|       |  std::string password_after(get_password());
 8765|       |  ADA_ASSERT_EQUAL(
 8766|       |      password_expected, password_after,
 8767|       |      "append_base_password problem after inserting " + std::string(input));
 8768|       |#endif  // ADA_DEVELOPMENT_CHECKS
 8769|  5.42k|  ADA_ASSERT_TRUE(validate());
 8770|  5.42k|}
_ZN3ada14url_aggregator31add_authority_slashes_if_neededEv:
 8976|  56.0k|inline void ada::url_aggregator::add_authority_slashes_if_needed() {
 8977|  56.0k|  ada_log("url_aggregator::add_authority_slashes_if_needed");
 8978|  56.0k|  ADA_ASSERT_TRUE(validate());
 8979|       |  // Protocol setter will insert `http:` to the URL. It is up to hostname setter
 8980|       |  // to insert
 8981|       |  // `//` initially to the buffer, since it depends on the hostname existence.
 8982|  56.0k|  if (has_authority()) {
  ------------------
  |  Branch (8982:7): [True: 28.5k, False: 27.5k]
  ------------------
 8983|  28.5k|    return;
 8984|  28.5k|  }
 8985|       |  // Performance: the common case is components.protocol_end == buffer.size()
 8986|       |  // Optimization opportunity: in many cases, the "//" is part of the input and
 8987|       |  // the insert could be fused with another insert.
 8988|  27.5k|  buffer.insert(components.protocol_end, "//");
 8989|  27.5k|  components.username_end += 2;
 8990|  27.5k|  components.host_start += 2;
 8991|  27.5k|  components.host_end += 2;
 8992|  27.5k|  components.pathname_start += 2;
 8993|  27.5k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8993:7): [True: 0, False: 27.5k]
  ------------------
 8994|      0|    components.search_start += 2;
 8995|      0|  }
 8996|  27.5k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8996:7): [True: 0, False: 27.5k]
  ------------------
 8997|      0|    components.hash_start += 2;
 8998|      0|  }
 8999|  27.5k|  ADA_ASSERT_TRUE(validate());
 9000|  27.5k|}
_ZN3ada14url_aggregator20append_base_usernameENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8604|  13.5k|inline void url_aggregator::append_base_username(const std::string_view input) {
 8605|  13.5k|  ada_log("url_aggregator::append_base_username ", input);
 8606|  13.5k|  ADA_ASSERT_TRUE(validate());
 8607|  13.5k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 8608|       |#if ADA_DEVELOPMENT_CHECKS
 8609|       |  // computing the expected password.
 8610|       |  std::string username_expected(get_username());
 8611|       |  username_expected.append(input);
 8612|       |#endif  // ADA_DEVELOPMENT_CHECKS
 8613|  13.5k|  add_authority_slashes_if_needed();
 8614|       |
 8615|       |  // If input is empty, do nothing.
 8616|  13.5k|  if (input.empty()) {
  ------------------
  |  Branch (8616:7): [True: 3.93k, False: 9.59k]
  ------------------
 8617|  3.93k|    return;
 8618|  3.93k|  }
 8619|       |
 8620|  9.59k|  uint32_t difference = uint32_t(input.size());
 8621|  9.59k|  buffer.insert(components.username_end, input);
 8622|  9.59k|  components.username_end += difference;
 8623|  9.59k|  components.host_start += difference;
 8624|       |
 8625|  9.59k|  if (buffer[components.host_start] != '@' &&
  ------------------
  |  Branch (8625:7): [True: 1.16k, False: 8.42k]
  ------------------
 8626|  1.16k|      components.host_start != components.host_end) {
  ------------------
  |  Branch (8626:7): [True: 1.16k, False: 0]
  ------------------
 8627|  1.16k|    buffer.insert(components.host_start, "@");
 8628|  1.16k|    difference++;
 8629|  1.16k|  }
 8630|       |
 8631|  9.59k|  components.host_end += difference;
 8632|  9.59k|  components.pathname_start += difference;
 8633|  9.59k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8633:7): [True: 0, False: 9.59k]
  ------------------
 8634|      0|    components.search_start += difference;
 8635|      0|  }
 8636|  9.59k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8636:7): [True: 0, False: 9.59k]
  ------------------
 8637|      0|    components.hash_start += difference;
 8638|      0|  }
 8639|       |#if ADA_DEVELOPMENT_CHECKS
 8640|       |  std::string username_after(get_username());
 8641|       |  ADA_ASSERT_EQUAL(
 8642|       |      username_expected, username_after,
 8643|       |      "append_base_username problem after inserting " + std::string(input));
 8644|       |#endif  // ADA_DEVELOPMENT_CHECKS
 8645|  9.59k|  ADA_ASSERT_TRUE(validate());
 8646|  9.59k|}
_ZN3ada14url_aggregator21update_base_authorityENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEERKNS_14url_componentsE:
 8254|  1.26k|    std::string_view base_buffer, const ada::url_components& base) {
 8255|  1.26k|  std::string_view input = base_buffer.substr(
 8256|  1.26k|      base.protocol_end, base.host_start - base.protocol_end);
 8257|  1.26k|  ada_log("url_aggregator::update_base_authority ", input);
 8258|       |
 8259|  1.26k|  bool input_starts_with_dash = input.starts_with("//");
 8260|  1.26k|  uint32_t diff = components.host_start - components.protocol_end;
 8261|       |
 8262|  1.26k|  buffer.erase(components.protocol_end,
 8263|  1.26k|               components.host_start - components.protocol_end);
 8264|  1.26k|  components.username_end = components.protocol_end;
 8265|       |
 8266|  1.26k|  if (input_starts_with_dash) {
  ------------------
  |  Branch (8266:7): [True: 992, False: 270]
  ------------------
 8267|    992|    input.remove_prefix(2);
 8268|    992|    diff += 2;  // add "//"
 8269|    992|    buffer.insert(components.protocol_end, "//");
 8270|    992|    components.username_end += 2;
 8271|    992|  }
 8272|       |
 8273|  1.26k|  size_t password_delimiter = input.find(':');
 8274|       |
 8275|       |  // Check if input contains both username and password by checking the
 8276|       |  // delimiter: ":" A typical input that contains authority would be "user:pass"
 8277|  1.26k|  if (password_delimiter != std::string_view::npos) {
  ------------------
  |  Branch (8277:7): [True: 37, False: 1.22k]
  ------------------
 8278|       |    // Insert both username and password
 8279|     37|    std::string_view username = input.substr(0, password_delimiter);
 8280|     37|    std::string_view password = input.substr(password_delimiter + 1);
 8281|       |
 8282|     37|    buffer.insert(components.protocol_end + diff, username);
 8283|     37|    diff += uint32_t(username.size());
 8284|     37|    buffer.insert(components.protocol_end + diff, ":");
 8285|     37|    components.username_end = components.protocol_end + diff;
 8286|     37|    buffer.insert(components.protocol_end + diff + 1, password);
 8287|     37|    diff += uint32_t(password.size()) + 1;
 8288|  1.22k|  } else if (!input.empty()) {
  ------------------
  |  Branch (8288:14): [True: 41, False: 1.18k]
  ------------------
 8289|       |    // Insert only username
 8290|     41|    buffer.insert(components.protocol_end + diff, input);
 8291|     41|    components.username_end =
 8292|     41|        components.protocol_end + diff + uint32_t(input.size());
 8293|     41|    diff += uint32_t(input.size());
 8294|     41|  }
 8295|       |
 8296|  1.26k|  components.host_start += diff;
 8297|       |
 8298|  1.26k|  if (buffer.size() > base.host_start && buffer[base.host_start] != '@') {
  ------------------
  |  Branch (8298:7): [True: 0, False: 1.26k]
  |  Branch (8298:42): [True: 0, False: 0]
  ------------------
 8299|      0|    buffer.insert(components.host_start, "@");
 8300|      0|    diff++;
 8301|      0|  }
 8302|  1.26k|  components.host_end += diff;
 8303|  1.26k|  components.pathname_start += diff;
 8304|  1.26k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8304:7): [True: 0, False: 1.26k]
  ------------------
 8305|      0|    components.search_start += diff;
 8306|      0|  }
 8307|  1.26k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8307:7): [True: 0, False: 1.26k]
  ------------------
 8308|      0|    components.hash_start += diff;
 8309|      0|  }
 8310|  1.26k|}
_ZNK3ada14url_aggregator8get_hrefEv:
 9080|  27.8k|    const noexcept ada_lifetime_bound {
 9081|  27.8k|  ada_log("url_aggregator::get_href");
 9082|  27.8k|  return buffer;
 9083|  27.8k|}
_ZNK3ada14url_aggregator14get_componentsEv:
 8962|  1.26k|url_aggregator::get_components() const noexcept {
 8963|  1.26k|  return components;
 8964|  1.26k|}
_ZN3ada14url_aggregator24update_host_to_base_hostENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9348|  1.82k|void url_aggregator::update_host_to_base_host(const std::string_view input) {
 9349|  1.82k|  ada_log("url_aggregator::update_host_to_base_host ", input);
 9350|  1.82k|  ADA_ASSERT_TRUE(validate());
 9351|  1.82k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 9352|  1.82k|  if (type != ada::scheme::type::FILE) {
  ------------------
  |  Branch (9352:7): [True: 1.26k, False: 562]
  ------------------
 9353|       |    // Let host be the result of host parsing host_view with url is not special.
 9354|  1.26k|    if (input.empty() && !is_special()) {
  ------------------
  |  Branch (9354:9): [True: 284, False: 978]
  |  Branch (9354:26): [True: 284, False: 0]
  ------------------
 9355|    284|      if (has_hostname()) {
  ------------------
  |  Branch (9355:11): [True: 14, False: 270]
  ------------------
 9356|     14|        clear_hostname();
 9357|    270|      } else if (has_dash_dot()) {
  ------------------
  |  Branch (9357:18): [True: 0, False: 270]
  ------------------
 9358|      0|        add_authority_slashes_if_needed();
 9359|      0|        delete_dash_dot();
 9360|      0|      }
 9361|    284|      return;
 9362|    284|    }
 9363|  1.26k|  }
 9364|  1.54k|  update_base_hostname(input);
 9365|  1.54k|  ADA_ASSERT_TRUE(validate());
 9366|  1.54k|  return;
 9367|  1.82k|}
_ZN3ada14url_aggregator14clear_hostnameEv:
 8903|     14|constexpr void url_aggregator::clear_hostname() {
 8904|     14|  ada_log("url_aggregator::clear_hostname");
 8905|     14|  ADA_ASSERT_TRUE(validate());
 8906|     14|  if (!has_authority()) {
  ------------------
  |  Branch (8906:7): [True: 0, False: 14]
  ------------------
 8907|      0|    return;
 8908|      0|  }
 8909|     14|  ADA_ASSERT_TRUE(has_authority());
 8910|       |
 8911|     14|  uint32_t hostname_length = components.host_end - components.host_start;
 8912|     14|  uint32_t start = components.host_start;
 8913|       |
 8914|       |  // If hostname starts with "@", we should not remove that character.
 8915|     14|  if (hostname_length > 0 && buffer[start] == '@') {
  ------------------
  |  Branch (8915:7): [True: 0, False: 14]
  |  Branch (8915:30): [True: 0, False: 0]
  ------------------
 8916|      0|    start++;
 8917|      0|    hostname_length--;
 8918|      0|  }
 8919|     14|  buffer.erase(start, hostname_length);
 8920|     14|  components.host_end = start;
 8921|     14|  components.pathname_start -= hostname_length;
 8922|     14|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8922:7): [True: 0, False: 14]
  ------------------
 8923|      0|    components.search_start -= hostname_length;
 8924|      0|  }
 8925|     14|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8925:7): [True: 0, False: 14]
  ------------------
 8926|      0|    components.hash_start -= hostname_length;
 8927|      0|  }
 8928|       |#if ADA_DEVELOPMENT_CHECKS
 8929|       |  ADA_ASSERT_EQUAL(get_hostname(), "",
 8930|       |                   "hostname should have been cleared on buffer=" + buffer +
 8931|       |                       " with " + components.to_string() + "\n" + to_diagram());
 8932|       |#endif
 8933|     14|  ADA_ASSERT_TRUE(has_authority());
 8934|     14|  ADA_ASSERT_EQUAL(has_empty_hostname(), true,
 8935|     14|                   "hostname should have been cleared on buffer=" + buffer +
 8936|     14|                       " with " + components.to_string() + "\n" + to_diagram());
 8937|     14|  ADA_ASSERT_TRUE(validate());
 8938|     14|}
_ZN3ada14url_aggregator16update_base_portEj:
 8772|  3.42k|inline void url_aggregator::update_base_port(uint32_t input) {
 8773|  3.42k|  ada_log("url_aggregator::update_base_port");
 8774|  3.42k|  ADA_ASSERT_TRUE(validate());
 8775|  3.42k|  if (input == url_components::omitted) {
  ------------------
  |  Branch (8775:7): [True: 1.23k, False: 2.18k]
  ------------------
 8776|  1.23k|    clear_port();
 8777|  1.23k|    return;
 8778|  1.23k|  }
 8779|       |  // calling std::to_string(input.value()) is unfortunate given that the port
 8780|       |  // value is probably already available as a string.
 8781|  2.18k|  std::string value = helpers::concat(":", std::to_string(input));
 8782|  2.18k|  uint32_t difference = uint32_t(value.size());
 8783|       |
 8784|  2.18k|  if (components.port != url_components::omitted) {
  ------------------
  |  Branch (8784:7): [True: 0, False: 2.18k]
  ------------------
 8785|      0|    difference -= components.pathname_start - components.host_end;
 8786|      0|    buffer.erase(components.host_end,
 8787|      0|                 components.pathname_start - components.host_end);
 8788|      0|  }
 8789|       |
 8790|  2.18k|  buffer.insert(components.host_end, value);
 8791|  2.18k|  components.pathname_start += difference;
 8792|  2.18k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8792:7): [True: 0, False: 2.18k]
  ------------------
 8793|      0|    components.search_start += difference;
 8794|      0|  }
 8795|  2.18k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8795:7): [True: 0, False: 2.18k]
  ------------------
 8796|      0|    components.hash_start += difference;
 8797|      0|  }
 8798|  2.18k|  components.port = input;
 8799|  2.18k|  ADA_ASSERT_TRUE(validate());
 8800|  2.18k|}
_ZN3ada7helpers6concatIJPKcNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEEEESA_DpT_:
 1968|  2.18k|std::string concat(Args... args) {
 1969|  2.18k|  std::string answer;
 1970|  2.18k|  inner_concat(answer, args...);
 1971|  2.18k|  return answer;
 1972|  2.18k|}
_ZN3ada7helpers12inner_concatIPKcJNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEEEEvRSA_T_DpT0_:
 1957|  2.18k|inline void inner_concat(std::string& buffer, T t, Args... args) {
 1958|  2.18k|  buffer.append(t);
 1959|  2.18k|  return inner_concat(buffer, args...);
 1960|  2.18k|}
_ZN3ada7helpers12inner_concatINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEJEEEvRS8_T_:
 1949|  2.18k|inline void inner_concat(std::string& buffer, T t) {
 1950|  2.18k|  buffer.append(t);
 1951|  2.18k|}
_ZNK3ada14url_aggregator18retrieve_base_portEv:
 8821|  1.26k|[[nodiscard]] inline uint32_t url_aggregator::retrieve_base_port() const {
 8822|  1.26k|  ada_log("url_aggregator::retrieve_base_port");
 8823|  1.26k|  return components.port;
 8824|  1.26k|}
_ZN3ada14url_aggregator12clear_searchEv:
 8826|  1.19k|inline void url_aggregator::clear_search() {
 8827|  1.19k|  ada_log("url_aggregator::clear_search");
 8828|  1.19k|  ADA_ASSERT_TRUE(validate());
 8829|  1.19k|  if (components.search_start == url_components::omitted) {
  ------------------
  |  Branch (8829:7): [True: 1.10k, False: 86]
  ------------------
 8830|  1.10k|    return;
 8831|  1.10k|  }
 8832|       |
 8833|     86|  if (components.hash_start == url_components::omitted) {
  ------------------
  |  Branch (8833:7): [True: 86, False: 0]
  ------------------
 8834|     86|    buffer.resize(components.search_start);
 8835|     86|  } else {
 8836|      0|    buffer.erase(components.search_start,
 8837|      0|                 components.hash_start - components.search_start);
 8838|      0|    components.hash_start = components.search_start;
 8839|      0|  }
 8840|       |
 8841|     86|  components.search_start = url_components::omitted;
 8842|       |
 8843|       |#if ADA_DEVELOPMENT_CHECKS
 8844|       |  ADA_ASSERT_EQUAL(get_search(), "",
 8845|       |                   "search should have been cleared on buffer=" + buffer +
 8846|       |                       " with " + components.to_string() + "\n" + to_diagram());
 8847|       |#endif
 8848|     86|  ADA_ASSERT_TRUE(validate());
 8849|     86|}
_ZN3ada14url_aggregator18update_base_searchENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKh:
 8443|  1.16k|    std::string_view input, const uint8_t query_percent_encode_set[]) {
 8444|  1.16k|  ada_log("url_aggregator::update_base_search ", input,
 8445|  1.16k|          " with encoding parameter ", to_string(), "\n", to_diagram());
 8446|  1.16k|  ADA_ASSERT_TRUE(validate());
 8447|  1.16k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 8448|       |
 8449|  1.16k|  if (components.hash_start == url_components::omitted) {
  ------------------
  |  Branch (8449:7): [True: 1.16k, False: 0]
  ------------------
 8450|  1.16k|    if (components.search_start == url_components::omitted) {
  ------------------
  |  Branch (8450:9): [True: 1.15k, False: 8]
  ------------------
 8451|  1.15k|      components.search_start = uint32_t(buffer.size());
 8452|  1.15k|      buffer += "?";
 8453|  1.15k|    } else {
 8454|      8|      buffer.resize(components.search_start + 1);
 8455|      8|    }
 8456|       |
 8457|  1.16k|    bool encoding_required =
 8458|  1.16k|        unicode::percent_encode<true>(input, query_percent_encode_set, buffer);
 8459|       |    // When encoding_required is false, then buffer is left unchanged, and
 8460|       |    // percent encoding was not deemed required.
 8461|  1.16k|    if (!encoding_required) {
  ------------------
  |  Branch (8461:9): [True: 742, False: 423]
  ------------------
 8462|    742|      buffer.append(input);
 8463|    742|    }
 8464|  1.16k|  } else {
 8465|      0|    const size_t idx =
 8466|      0|        ada::unicode::percent_encode_index(input, query_percent_encode_set);
 8467|      0|    std::string encoded;
 8468|      0|    std::string_view replacement = input;
 8469|      0|    if (idx != input.size()) {
  ------------------
  |  Branch (8469:9): [True: 0, False: 0]
  ------------------
 8470|      0|      encoded =
 8471|      0|          ada::unicode::percent_encode(input, query_percent_encode_set, idx);
 8472|      0|      replacement = encoded;
 8473|      0|    }
 8474|       |
 8475|      0|    if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8475:9): [True: 0, False: 0]
  ------------------
 8476|      0|      const uint32_t difference = replace_and_resize(
 8477|      0|          components.search_start + 1, components.hash_start, replacement);
 8478|      0|      components.hash_start += difference;
 8479|      0|    } else {
 8480|      0|      components.search_start = components.hash_start;
 8481|      0|      buffer.insert(components.search_start, replacement.size() + 1, '?');
 8482|      0|      if (!replacement.empty()) {
  ------------------
  |  Branch (8482:11): [True: 0, False: 0]
  ------------------
 8483|      0|        std::memmove(buffer.data() + components.search_start + 1,
 8484|      0|                     replacement.data(), replacement.size());
 8485|      0|      }
 8486|      0|      components.hash_start +=
 8487|      0|          uint32_t(replacement.size() + 1);  // Do not forget `?`
 8488|      0|    }
 8489|      0|  }
 8490|       |
 8491|  1.16k|  ADA_ASSERT_TRUE(validate());
 8492|  1.16k|}
_ZN3ada14url_aggregator20update_base_hostnameENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8358|  35.1k|inline void url_aggregator::update_base_hostname(const std::string_view input) {
 8359|  35.1k|  ada_log("url_aggregator::update_base_hostname ", input, " [", input.size(),
 8360|  35.1k|          " bytes], buffer is '", buffer, "' [", buffer.size(), " bytes]");
 8361|  35.1k|  ADA_ASSERT_TRUE(validate());
 8362|  35.1k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 8363|       |
 8364|       |  // This next line is required for when parsing a URL like `foo://`
 8365|  35.1k|  add_authority_slashes_if_needed();
 8366|       |
 8367|  35.1k|  bool has_credentials = components.protocol_end + 2 < components.host_start;
 8368|  35.1k|  uint32_t new_difference =
 8369|  35.1k|      replace_and_resize(components.host_start, components.host_end, input);
 8370|       |
 8371|  35.1k|  if (has_credentials) {
  ------------------
  |  Branch (8371:7): [True: 1.21k, False: 33.9k]
  ------------------
 8372|  1.21k|    buffer.insert(components.host_start, "@");
 8373|  1.21k|    new_difference++;
 8374|  1.21k|  }
 8375|  35.1k|  components.host_end += new_difference;
 8376|  35.1k|  components.pathname_start += new_difference;
 8377|  35.1k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8377:7): [True: 0, False: 35.1k]
  ------------------
 8378|      0|    components.search_start += new_difference;
 8379|      0|  }
 8380|  35.1k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8380:7): [True: 0, False: 35.1k]
  ------------------
 8381|      0|    components.hash_start += new_difference;
 8382|      0|  }
 8383|  35.1k|  ADA_ASSERT_TRUE(validate());
 8384|  35.1k|}
_ZN3ada14url_aggregator10parse_portENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEb:
 9090|  3.94k|url_aggregator::parse_port(std::string_view view, bool check_trailing_content) {
 9091|  3.94k|  ada_log("url_aggregator::parse_port('", view, "') ", view.size());
 9092|  3.94k|  if (!view.empty() && view[0] == '-') {
  ------------------
  |  Branch (9092:7): [True: 2.65k, False: 1.28k]
  |  Branch (9092:24): [True: 6, False: 2.64k]
  ------------------
 9093|      6|    ada_log("parse_port: view[0] == '0' && view.size() > 1");
 9094|      6|    is_valid = false;
 9095|      6|    return 0;
 9096|      6|  }
 9097|  3.93k|  uint16_t parsed_port{};
 9098|  3.93k|  auto r = std::from_chars(view.data(), view.data() + view.size(), parsed_port);
 9099|  3.93k|  if (r.ec == std::errc::result_out_of_range) {
  ------------------
  |  Branch (9099:7): [True: 62, False: 3.87k]
  ------------------
 9100|     62|    ada_log("parse_port: r.ec == std::errc::result_out_of_range");
 9101|     62|    is_valid = false;
 9102|     62|    return 0;
 9103|     62|  }
 9104|  3.87k|  ada_log("parse_port: ", parsed_port);
 9105|  3.87k|  const size_t consumed = size_t(r.ptr - view.data());
 9106|  3.87k|  ada_log("parse_port: consumed ", consumed);
 9107|  3.87k|  if (check_trailing_content) {
  ------------------
  |  Branch (9107:7): [True: 3.87k, False: 0]
  ------------------
 9108|  3.87k|    is_valid &=
 9109|  3.87k|        (consumed == view.size() || view[consumed] == '/' ||
  ------------------
  |  Branch (9109:10): [True: 2.45k, False: 1.41k]
  |  Branch (9109:37): [True: 1.17k, False: 243]
  ------------------
 9110|    243|         view[consumed] == '?' || (is_special() && view[consumed] == '\\'));
  ------------------
  |  Branch (9110:10): [True: 109, False: 134]
  |  Branch (9110:36): [True: 128, False: 6]
  |  Branch (9110:52): [True: 4, False: 124]
  ------------------
 9111|  3.87k|  }
 9112|  3.87k|  ada_log("parse_port: is_valid = ", is_valid);
 9113|  3.87k|  if (is_valid) {
  ------------------
  |  Branch (9113:7): [True: 3.74k, False: 130]
  ------------------
 9114|  3.74k|    ada_log("parse_port", r.ec == std::errc());
 9115|       |    // scheme_default_port can return 0, and we should allow 0 as a base port.
 9116|  3.74k|    auto default_port = scheme_default_port();
 9117|  3.74k|    bool is_port_valid = (default_port == 0 && parsed_port == 0) ||
  ------------------
  |  Branch (9117:27): [True: 164, False: 3.57k]
  |  Branch (9117:48): [True: 56, False: 108]
  ------------------
 9118|  3.68k|                         (default_port != parsed_port);
  ------------------
  |  Branch (9118:26): [True: 3.67k, False: 16]
  ------------------
 9119|  3.74k|    if (r.ec == std::errc() && is_port_valid) {
  ------------------
  |  Branch (9119:9): [True: 2.17k, False: 1.56k]
  |  Branch (9119:32): [True: 2.15k, False: 16]
  ------------------
 9120|  2.15k|      update_base_port(parsed_port);
 9121|  2.15k|    } else {
 9122|  1.58k|      clear_port();
 9123|  1.58k|    }
 9124|  3.74k|  }
 9125|  3.87k|  return consumed;
 9126|  3.93k|}
_ZN3ada14url_aggregator20append_base_pathnameENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8533|      3|inline void url_aggregator::append_base_pathname(const std::string_view input) {
 8534|      3|  ada_log("url_aggregator::append_base_pathname ", input, " ", to_string(),
 8535|      3|          "\n", to_diagram());
 8536|      3|  ADA_ASSERT_TRUE(validate());
 8537|      3|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 8538|       |#if ADA_DEVELOPMENT_CHECKS
 8539|       |  // computing the expected password.
 8540|       |  std::string path_expected(get_pathname());
 8541|       |  path_expected.append(input);
 8542|       |#endif  // ADA_DEVELOPMENT_CHECKS
 8543|      3|  uint32_t ending_index = uint32_t(buffer.size());
 8544|      3|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8544:7): [True: 0, False: 3]
  ------------------
 8545|      0|    ending_index = components.search_start;
 8546|      3|  } else if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8546:14): [True: 0, False: 3]
  ------------------
 8547|      0|    ending_index = components.hash_start;
 8548|      0|  }
 8549|      3|  buffer.insert(ending_index, input);
 8550|       |
 8551|      3|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8551:7): [True: 0, False: 3]
  ------------------
 8552|      0|    components.search_start += uint32_t(input.size());
 8553|      0|  }
 8554|      3|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8554:7): [True: 0, False: 3]
  ------------------
 8555|      0|    components.hash_start += uint32_t(input.size());
 8556|      0|  }
 8557|       |#if ADA_DEVELOPMENT_CHECKS
 8558|       |  std::string path_after = std::string(get_pathname());
 8559|       |  ADA_ASSERT_EQUAL(
 8560|       |      path_expected, path_after,
 8561|       |      "append_base_pathname problem after inserting " + std::string(input));
 8562|       |#endif  // ADA_DEVELOPMENT_CHECKS
 8563|      3|  ADA_ASSERT_TRUE(validate());
 8564|      3|}
_ZN3ada14url_aggregator20set_protocol_as_fileEv:
 9128|  5.95k|constexpr void url_aggregator::set_protocol_as_file() {
 9129|  5.95k|  ada_log("url_aggregator::set_protocol_as_file ");
 9130|  5.95k|  ADA_ASSERT_TRUE(validate());
 9131|  5.95k|  type = ada::scheme::type::FILE;
 9132|       |  // next line could overflow but unsigned arithmetic has well-defined
 9133|       |  // overflows.
 9134|  5.95k|  uint32_t new_difference = 5 - components.protocol_end;
 9135|       |
 9136|  5.95k|  if (buffer.empty()) {
  ------------------
  |  Branch (9136:7): [True: 512, False: 5.43k]
  ------------------
 9137|    512|    buffer.append("file:");
 9138|  5.43k|  } else {
 9139|  5.43k|    buffer.erase(0, components.protocol_end);
 9140|  5.43k|    buffer.insert(0, "file:");
 9141|  5.43k|  }
 9142|  5.95k|  components.protocol_end = 5;
 9143|       |
 9144|       |  // Update the rest of the components.
 9145|  5.95k|  components.username_end += new_difference;
 9146|  5.95k|  components.host_start += new_difference;
 9147|  5.95k|  components.host_end += new_difference;
 9148|  5.95k|  components.pathname_start += new_difference;
 9149|  5.95k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9149:7): [True: 0, False: 5.95k]
  ------------------
 9150|      0|    components.search_start += new_difference;
 9151|      0|  }
 9152|  5.95k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9152:7): [True: 0, False: 5.95k]
  ------------------
 9153|      0|    components.hash_start += new_difference;
 9154|      0|  }
 9155|  5.95k|  ADA_ASSERT_TRUE(validate());
 9156|  5.95k|}
_ZN3ada14url_aggregator14clear_pathnameEv:
 8868|     44|constexpr void url_aggregator::clear_pathname() {
 8869|     44|  ada_log("url_aggregator::clear_pathname");
 8870|     44|  ADA_ASSERT_TRUE(validate());
 8871|     44|  uint32_t ending_index = uint32_t(buffer.size());
 8872|     44|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8872:7): [True: 0, False: 44]
  ------------------
 8873|      0|    ending_index = components.search_start;
 8874|     44|  } else if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8874:14): [True: 0, False: 44]
  ------------------
 8875|      0|    ending_index = components.hash_start;
 8876|      0|  }
 8877|     44|  uint32_t pathname_length = ending_index - components.pathname_start;
 8878|     44|  buffer.erase(components.pathname_start, pathname_length);
 8879|     44|  uint32_t difference = pathname_length;
 8880|     44|  if (components.pathname_start == components.host_end + 2 &&
  ------------------
  |  Branch (8880:7): [True: 0, False: 44]
  ------------------
 8881|      0|      buffer[components.host_end] == '/' &&
  ------------------
  |  Branch (8881:7): [True: 0, False: 0]
  ------------------
 8882|      0|      buffer[components.host_end + 1] == '.') {
  ------------------
  |  Branch (8882:7): [True: 0, False: 0]
  ------------------
 8883|      0|    components.pathname_start -= 2;
 8884|      0|    buffer.erase(components.host_end, 2);
 8885|      0|    difference += 2;
 8886|      0|  }
 8887|     44|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8887:7): [True: 0, False: 44]
  ------------------
 8888|      0|    components.search_start -= difference;
 8889|      0|  }
 8890|     44|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8890:7): [True: 0, False: 44]
  ------------------
 8891|      0|    components.hash_start -= difference;
 8892|      0|  }
 8893|     44|  ada_log("url_aggregator::clear_pathname completed, running checks...");
 8894|       |#if ADA_DEVELOPMENT_CHECKS
 8895|       |  ADA_ASSERT_EQUAL(get_pathname(), "",
 8896|       |                   "pathname should have been cleared on buffer=" + buffer +
 8897|       |                       " with " + components.to_string() + "\n" + to_diagram());
 8898|       |#endif
 8899|     44|  ADA_ASSERT_TRUE(validate());
 8900|     44|  ada_log("url_aggregator::clear_pathname completed, running checks... ok");
 8901|     44|}
_ZN3ada7unicode20percent_encode_indexENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKh:
 8213|  1.11k|                                              const uint8_t character_set[]) {
 8214|  1.11k|  const char* data = input.data();
 8215|  1.11k|  const size_t size = input.size();
 8216|       |
 8217|       |  // Process 8 bytes at a time using unrolled loop
 8218|  1.11k|  size_t i = 0;
 8219|  3.86k|  for (; i + 8 <= size; i += 8) {
  ------------------
  |  Branch (8219:10): [True: 2.99k, False: 864]
  ------------------
 8220|  2.99k|    unsigned char chunk[8];
 8221|  2.99k|    std::memcpy(&chunk, data + i,
 8222|  2.99k|                8);  // entices compiler to unconditionally process 8 characters
 8223|       |
 8224|       |    // Check 8 characters at once
 8225|  25.1k|    for (size_t j = 0; j < 8; j++) {
  ------------------
  |  Branch (8225:24): [True: 22.3k, False: 2.75k]
  ------------------
 8226|  22.3k|      if (character_sets::bit_at(character_set, chunk[j])) {
  ------------------
  |  Branch (8226:11): [True: 246, False: 22.1k]
  ------------------
 8227|    246|        return i + j;
 8228|    246|      }
 8229|  22.3k|    }
 8230|  2.99k|  }
 8231|       |
 8232|       |  // Handle remaining bytes
 8233|  2.17k|  for (; i < size; i++) {
  ------------------
  |  Branch (8233:10): [True: 1.52k, False: 656]
  ------------------
 8234|  1.52k|    if (character_sets::bit_at(character_set, data[i])) {
  ------------------
  |  Branch (8234:9): [True: 208, False: 1.31k]
  ------------------
 8235|    208|      return i;
 8236|    208|    }
 8237|  1.52k|  }
 8238|       |
 8239|    656|  return size;
 8240|    864|}
_ZN3ada14url_aggregator10clear_portEv:
 8802|  2.81k|inline void url_aggregator::clear_port() {
 8803|  2.81k|  ada_log("url_aggregator::clear_port");
 8804|  2.81k|  ADA_ASSERT_TRUE(validate());
 8805|  2.81k|  if (components.port == url_components::omitted) {
  ------------------
  |  Branch (8805:7): [True: 2.81k, False: 0]
  ------------------
 8806|  2.81k|    return;
 8807|  2.81k|  }
 8808|      0|  uint32_t length = components.pathname_start - components.host_end;
 8809|      0|  buffer.erase(components.host_end, length);
 8810|      0|  components.pathname_start -= length;
 8811|      0|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8811:7): [True: 0, False: 0]
  ------------------
 8812|      0|    components.search_start -= length;
 8813|      0|  }
 8814|      0|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8814:7): [True: 0, False: 0]
  ------------------
 8815|      0|    components.hash_start -= length;
 8816|      0|  }
 8817|      0|  components.port = url_components::omitted;
 8818|      0|  ADA_ASSERT_TRUE(validate());
 8819|      0|}
_ZNK3ada14url_aggregator13has_authorityEv:
 8967|  56.9k|    const noexcept {
 8968|  56.9k|  ada_log("url_aggregator::has_authority");
 8969|       |  // Performance: instead of doing this potentially expensive check, we could
 8970|       |  // have a boolean in the struct.
 8971|  56.9k|  return components.protocol_end + 2 <= components.host_start &&
  ------------------
  |  Branch (8971:10): [True: 29.0k, False: 27.9k]
  ------------------
 8972|  29.0k|         buffer[components.protocol_end] == '/' &&
  ------------------
  |  Branch (8972:10): [True: 29.0k, False: 0]
  ------------------
 8973|  29.0k|         buffer[components.protocol_end + 1] == '/';
  ------------------
  |  Branch (8973:10): [True: 29.0k, False: 0]
  ------------------
 8974|  56.9k|}
_ZNK3ada14url_aggregator12has_dash_dotEv:
 9047|  16.6k|[[nodiscard]] constexpr bool url_aggregator::has_dash_dot() const noexcept {
 9048|       |  // If url's host is null, url does not have an opaque path, url's path's size
 9049|       |  // is greater than 1, and url's path[0] is the empty string, then append
 9050|       |  // U+002F (/) followed by U+002E (.) to output.
 9051|  16.6k|  ada_log("url_aggregator::has_dash_dot");
 9052|       |#if ADA_DEVELOPMENT_CHECKS
 9053|       |  // If pathname_start and host_end are exactly two characters apart, then we
 9054|       |  // either have a one-digit port such as http://test.com:5?param=1 or else we
 9055|       |  // have a /.: sequence such as "non-spec:/.//". We test that this is the case.
 9056|       |  if (components.pathname_start == components.host_end + 2) {
 9057|       |    ADA_ASSERT_TRUE((buffer[components.host_end] == '/' &&
 9058|       |                     buffer[components.host_end + 1] == '.') ||
 9059|       |                    (buffer[components.host_end] == ':' &&
 9060|       |                     checkers::is_digit(buffer[components.host_end + 1])));
 9061|       |  }
 9062|       |  if (components.pathname_start == components.host_end + 2 &&
 9063|       |      buffer[components.host_end] == '/' &&
 9064|       |      buffer[components.host_end + 1] == '.') {
 9065|       |    ADA_ASSERT_TRUE(components.pathname_start + 1 < buffer.size());
 9066|       |    ADA_ASSERT_TRUE(buffer[components.pathname_start] == '/');
 9067|       |    ADA_ASSERT_TRUE(buffer[components.pathname_start + 1] == '/');
 9068|       |  }
 9069|       |#endif
 9070|       |  // Performance: it should be uncommon for components.pathname_start ==
 9071|       |  // components.host_end + 2 to be true. So we put this check first in the
 9072|       |  // sequence. Most times, we do not have an opaque path. Checking for '/.' is
 9073|       |  // more expensive, but should be uncommon.
 9074|  16.6k|  return components.pathname_start == components.host_end + 2 &&
  ------------------
  |  Branch (9074:10): [True: 936, False: 15.7k]
  ------------------
 9075|    936|         !has_opaque_path && buffer[components.host_end] == '/' &&
  ------------------
  |  Branch (9075:10): [True: 936, False: 0]
  |  Branch (9075:30): [True: 14, False: 922]
  ------------------
 9076|     14|         buffer[components.host_end + 1] == '.';
  ------------------
  |  Branch (9076:10): [True: 14, False: 0]
  ------------------
 9077|  16.6k|}
_ZNK2tl8expectedIN3ada14url_aggregatorENS1_6errorsEEcvbEv:
 4074|  43.3k|  constexpr explicit operator bool() const noexcept { return this->m_has_val; }
_ZN2tl8expectedIN3ada14url_aggregatorENS1_6errorsEEptEv:
 4043|  26.6k|  TL_EXPECTED_11_CONSTEXPR T* operator->() {
 4044|  26.6k|    TL_ASSERT(has_value());
  ------------------
  |  | 2096|  26.6k|#define TL_ASSERT(x) assert(x)
  ------------------
  |  Branch (4044:5): [True: 26.6k, False: 0]
  ------------------
 4045|  26.6k|    return valptr();
 4046|  26.6k|  }
_ZN2tl8expectedIN3ada14url_aggregatorENS1_6errorsEE6valptrEv:
 3339|  26.6k|  T* valptr() { return std::addressof(this->m_val); }
_ZNR2tl8expectedIN3ada14url_aggregatorENS1_6errorsEEdeIS2_TnPNSt3__19enable_ifIXntsr3std7is_voidIT_EE5valueEvE4typeELPv0EEERS8_v:
 4056|  3.97k|  TL_EXPECTED_11_CONSTEXPR U& operator*() & {
 4057|  3.97k|    TL_ASSERT(has_value());
  ------------------
  |  | 2096|  3.97k|#define TL_ASSERT(x) assert(x)
  ------------------
  |  Branch (4057:5): [True: 3.97k, False: 0]
  ------------------
 4058|  3.97k|    return val();
 4059|  3.97k|  }
_ZN2tl8expectedIN3ada14url_aggregatorENS1_6errorsEE3valIS2_TnPNSt3__19enable_ifIXntsr3std7is_voidIT_EE5valueEvE4typeELPv0EEERS8_v:
 3348|  3.97k|  TL_EXPECTED_11_CONSTEXPR U& val() {
 3349|  3.97k|    return this->m_val;
 3350|  3.97k|  }
_ZNK2tl8expectedIN3ada14url_aggregatorENS1_6errorsEE9has_valueEv:
 4073|  85.9k|  constexpr bool has_value() const noexcept { return this->m_has_val; }
_ZN2tl6detail21expected_storage_baseIN3ada14url_aggregatorENS2_6errorsELb0ELb1EED2Ev:
 2671|  47.3k|  ~expected_storage_base() {
 2672|  47.3k|    if (m_has_val) {
  ------------------
  |  Branch (2672:9): [True: 22.7k, False: 24.6k]
  ------------------
 2673|  22.7k|      m_val.~T();
 2674|  22.7k|    }
 2675|  47.3k|  }
_ZN3ada7helpers9substringENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEmm:
 1890|  28.6k|                                                       size_t pos2) {
 1891|       |#if ADA_DEVELOPMENT_CHECKS
 1892|       |  if (pos2 < pos1) {
 1893|       |    std::cerr << "Negative-length substring: [" << pos1 << " to " << pos2 << ")"
 1894|       |              << std::endl;
 1895|       |    abort();
 1896|       |  }
 1897|       |#endif
 1898|  28.6k|  return input.substr(pos1, pos2 - pos1);
 1899|  28.6k|}
_ZNK3ada14url_aggregator10is_at_pathEv:
 8399|  4.75k|    const noexcept {
 8400|  4.75k|  return buffer.size() == components.pathname_start;
 8401|  4.75k|}
_ZNK3ada14url_aggregator12has_hostnameEv:
 9036|    284|constexpr bool url_aggregator::has_hostname() const noexcept {
 9037|    284|  return has_authority();
 9038|    284|}
_ZNK3ada14url_aggregator12has_passwordEv:
 9016|  5.42k|constexpr bool url_aggregator::has_password() const noexcept {
 9017|  5.42k|  ada_log("url_aggregator::has_password");
 9018|       |  // This function does not care about the length of the password
 9019|  5.42k|  return components.host_start > components.username_end &&
  ------------------
  |  Branch (9019:10): [True: 4.80k, False: 625]
  ------------------
 9020|  4.80k|         buffer[components.username_end] == ':';
  ------------------
  |  Branch (9020:10): [True: 4.80k, False: 0]
  ------------------
 9021|  5.42k|}
_ZNK3ada3url8get_hrefEv:
 7475|  18.7k|[[nodiscard]] ada_really_inline std::string url::get_href() const {
 7476|  18.7k|  if (is_special() && host.has_value() && username.empty() &&
  ------------------
  |  Branch (7476:7): [True: 15.4k, False: 3.28k]
  |  Branch (7476:23): [True: 15.4k, False: 0]
  |  Branch (7476:43): [True: 14.9k, False: 578]
  ------------------
 7477|  14.9k|      password.empty() && !port.has_value()) [[likely]] {
  ------------------
  |  Branch (7477:7): [True: 14.8k, False: 89]
  |  Branch (7477:27): [True: 13.2k, False: 1.57k]
  ------------------
 7478|  13.2k|    const std::string_view scheme = ada::scheme::details::is_special_list[type];
 7479|  13.2k|    const size_t host_size = host->size();
 7480|  13.2k|    const size_t path_size = path.size();
 7481|  13.2k|    const size_t query_size = query.has_value() ? query->size() : 0;
  ------------------
  |  Branch (7481:31): [True: 764, False: 12.4k]
  ------------------
 7482|  13.2k|    const size_t hash_size = hash.has_value() ? hash->size() : 0;
  ------------------
  |  Branch (7482:30): [True: 589, False: 12.6k]
  ------------------
 7483|  13.2k|    const size_t total = scheme.size() + 3 + host_size + path_size +
 7484|  13.2k|                         (query.has_value() ? query_size + 1 : 0) +
  ------------------
  |  Branch (7484:27): [True: 764, False: 12.4k]
  ------------------
 7485|  13.2k|                         (hash.has_value() ? hash_size + 1 : 0);
  ------------------
  |  Branch (7485:27): [True: 589, False: 12.6k]
  ------------------
 7486|  13.2k|    std::string output(total, '\0');
 7487|  13.2k|    char* p = output.data();
 7488|  13.2k|    std::memcpy(p, scheme.data(), scheme.size());
 7489|  13.2k|    p += scheme.size();
 7490|  13.2k|    p[0] = ':';
 7491|  13.2k|    p[1] = '/';
 7492|  13.2k|    p[2] = '/';
 7493|  13.2k|    p += 3;
 7494|       |    // NOLINTNEXTLINE(bugprone-not-null-terminated-result)
 7495|  13.2k|    std::memcpy(p, host->data(), host_size);
 7496|  13.2k|    p += host_size;
 7497|  13.2k|    std::memcpy(p, path.data(), path_size);
 7498|  13.2k|    p += path_size;
 7499|  13.2k|    if (query.has_value()) {
  ------------------
  |  Branch (7499:9): [True: 764, False: 12.4k]
  ------------------
 7500|    764|      *p++ = '?';
 7501|       |      // NOLINTNEXTLINE(bugprone-not-null-terminated-result)
 7502|    764|      std::memcpy(p, query->data(), query_size);
 7503|    764|      p += query_size;
 7504|    764|    }
 7505|  13.2k|    if (hash.has_value()) {
  ------------------
  |  Branch (7505:9): [True: 589, False: 12.6k]
  ------------------
 7506|    589|      *p++ = '#';
 7507|       |      // NOLINTNEXTLINE(bugprone-not-null-terminated-result)
 7508|    589|      std::memcpy(p, hash->data(), hash_size);
 7509|    589|    }
 7510|  13.2k|    return output;
 7511|  13.2k|  }
 7512|       |
 7513|  5.52k|  std::string output;
 7514|  5.52k|  output.reserve(get_href_size());
 7515|       |
 7516|  5.52k|  if (is_special()) {
  ------------------
  |  Branch (7516:7): [True: 2.23k, False: 3.28k]
  ------------------
 7517|  2.23k|    output.append(ada::scheme::details::is_special_list[type]);
 7518|  2.23k|    output += ':';
 7519|  3.28k|  } else {
 7520|  3.28k|    output.append(non_special_scheme);
 7521|  3.28k|    output += ':';
 7522|  3.28k|  }
 7523|       |
 7524|  5.52k|  if (host.has_value()) {
  ------------------
  |  Branch (7524:7): [True: 2.92k, False: 2.60k]
  ------------------
 7525|  2.92k|    output += '/';
 7526|  2.92k|    output += '/';
 7527|  2.92k|    if (has_credentials()) {
  ------------------
  |  Branch (7527:9): [True: 725, False: 2.19k]
  ------------------
 7528|    725|      output.append(username);
 7529|    725|      if (!password.empty()) {
  ------------------
  |  Branch (7529:11): [True: 244, False: 481]
  ------------------
 7530|    244|        output += ':';
 7531|    244|        output.append(password);
 7532|    244|      }
 7533|    725|      output += '@';
 7534|    725|    }
 7535|  2.92k|    output.append(*host);
 7536|  2.92k|    if (port.has_value()) {
  ------------------
  |  Branch (7536:9): [True: 1.69k, False: 1.22k]
  ------------------
 7537|  1.69k|      output += ':';
 7538|  1.69k|      char port_buf[5];
 7539|  1.69k|      auto [ptr, ec] = std::to_chars(port_buf, port_buf + 5, *port);
 7540|  1.69k|      (void)ec;
 7541|  1.69k|      output.append(port_buf, static_cast<size_t>(ptr - port_buf));
 7542|  1.69k|    }
 7543|  2.92k|  } else if (!has_opaque_path && path.starts_with("//")) {
  ------------------
  |  Branch (7543:14): [True: 1.33k, False: 1.27k]
  |  Branch (7543:34): [True: 42, False: 1.29k]
  ------------------
 7544|       |    // If url's host is null, url does not have an opaque path, url's path's
 7545|       |    // size is greater than 1, and url's path[0] is the empty string, then
 7546|       |    // append U+002F (/) followed by U+002E (.) to output.
 7547|     42|    output += '/';
 7548|     42|    output += '.';
 7549|     42|  }
 7550|  5.52k|  output.append(path);
 7551|  5.52k|  if (query.has_value()) {
  ------------------
  |  Branch (7551:7): [True: 574, False: 4.95k]
  ------------------
 7552|    574|    output += '?';
 7553|    574|    output.append(*query);
 7554|    574|  }
 7555|  5.52k|  if (hash.has_value()) {
  ------------------
  |  Branch (7555:7): [True: 446, False: 5.08k]
  ------------------
 7556|    446|    output += '#';
 7557|    446|    output.append(*hash);
 7558|    446|  }
 7559|  5.52k|  return output;
 7560|  18.7k|}
_ZNK3ada14url_aggregator10has_searchEv:
 8945|  1.69k|[[nodiscard]] constexpr bool url_aggregator::has_search() const noexcept {
 8946|  1.69k|  ada_log("url_aggregator::has_search");
 8947|  1.69k|  return components.search_start != url_components::omitted;
 8948|  1.69k|}
_ZN3ada7helpers6concatIJNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEPKcEEENS2_12basic_stringIcS5_NS2_9allocatorIcEEEEDpT_:
 1968|  22.2k|std::string concat(Args... args) {
 1969|  22.2k|  std::string answer;
 1970|  22.2k|  inner_concat(answer, args...);
 1971|  22.2k|  return answer;
 1972|  22.2k|}
_ZN3ada7helpers12inner_concatINSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEJPKcEEEvRNS2_12basic_stringIcS5_NS2_9allocatorIcEEEET_DpT0_:
 1957|  22.2k|inline void inner_concat(std::string& buffer, T t, Args... args) {
 1958|  22.2k|  buffer.append(t);
 1959|  22.2k|  return inner_concat(buffer, args...);
 1960|  22.2k|}
_ZN3ada7helpers12inner_concatIPKcJEEEvRNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEET_:
 1949|  22.2k|inline void inner_concat(std::string& buffer, T t) {
 1950|  22.2k|  buffer.append(t);
 1951|  22.2k|}
_ZN3ada3url10set_schemeEONSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 7457|  11.1k|inline void url::set_scheme(std::string&& new_scheme) noexcept {
 7458|  11.1k|  type = ada::scheme::get_scheme_type(new_scheme);
 7459|       |  // We only move the 'scheme' if it is non-special.
 7460|  11.1k|  if (!is_special()) {
  ------------------
  |  Branch (7460:7): [True: 5.54k, False: 5.59k]
  ------------------
 7461|  5.54k|    non_special_scheme = std::move(new_scheme);
 7462|  5.54k|  }
 7463|  11.1k|}
_ZN3ada7helpers6concatIJPKcNSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEEEENS4_12basic_stringIcS7_NS4_9allocatorIcEEEEDpT_:
 1968|      3|std::string concat(Args... args) {
 1969|      3|  std::string answer;
 1970|      3|  inner_concat(answer, args...);
 1971|      3|  return answer;
 1972|      3|}
_ZN3ada7helpers12inner_concatIPKcJNSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEEEEvRNS4_12basic_stringIcS7_NS4_9allocatorIcEEEET_DpT0_:
 1957|      3|inline void inner_concat(std::string& buffer, T t, Args... args) {
 1958|      3|  buffer.append(t);
 1959|      3|  return inner_concat(buffer, args...);
 1960|      3|}
_ZN3ada7helpers12inner_concatINSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEJEEEvRNS2_12basic_stringIcS5_NS2_9allocatorIcEEEET_:
 1949|      3|inline void inner_concat(std::string& buffer, T t) {
 1950|      3|  buffer.append(t);
 1951|      3|}

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

