_ZN3ada4idna13utf8_to_utf32EPKcmPDi:
  162|  13.1k|size_t utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_output) {
  163|  13.1k|  const uint8_t* data = reinterpret_cast<const uint8_t*>(buf);
  164|  13.1k|  size_t pos = 0;
  165|  13.1k|  const char32_t* start{utf32_output};
  166|   180k|  while (pos < len) {
  ------------------
  |  Branch (166:10): [True: 168k, False: 12.2k]
  ------------------
  167|       |    // try to convert the next block of 16 ASCII bytes
  168|   168k|    if (pos + 16 <= len) {  // if it is safe to read 16 more
  ------------------
  |  Branch (168:9): [True: 96.5k, False: 71.5k]
  ------------------
  169|       |                            // bytes, check that they are ascii
  170|  96.5k|      uint64_t v1;
  171|  96.5k|      std::memcpy(&v1, data + pos, sizeof(uint64_t));
  172|  96.5k|      uint64_t v2;
  173|  96.5k|      std::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  174|  96.5k|      uint64_t v{v1 | v2};
  175|  96.5k|      if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (175:11): [True: 7.86k, False: 88.6k]
  ------------------
  176|  7.86k|        size_t final_pos = pos + 16;
  177|   133k|        while (pos < final_pos) {
  ------------------
  |  Branch (177:16): [True: 125k, False: 7.86k]
  ------------------
  178|   125k|          *utf32_output++ = char32_t(buf[pos]);
  179|   125k|          pos++;
  180|   125k|        }
  181|  7.86k|        continue;
  182|  7.86k|      }
  183|  96.5k|    }
  184|   160k|    uint8_t leading_byte = data[pos];  // leading byte
  185|   160k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (185:9): [True: 92.4k, False: 67.7k]
  ------------------
  186|       |      // converting one ASCII byte !!!
  187|  92.4k|      *utf32_output++ = char32_t(leading_byte);
  188|  92.4k|      pos++;
  189|  92.4k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (189:16): [True: 20.1k, False: 47.5k]
  ------------------
  190|       |      // We have a two-byte UTF-8
  191|  20.1k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (191:11): [True: 150, False: 20.0k]
  ------------------
  192|    150|        return 0;
  193|    150|      }  // minimal bound checking
  194|  20.0k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (194:11): [True: 156, False: 19.8k]
  ------------------
  195|    156|        return 0;
  196|    156|      }
  197|       |      // range check
  198|  19.8k|      uint32_t code_point =
  199|  19.8k|          (leading_byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111);
  200|  19.8k|      if (code_point < 0x80 || 0x7ff < code_point) {
  ------------------
  |  Branch (200:11): [True: 12, False: 19.8k]
  |  Branch (200:32): [True: 0, False: 19.8k]
  ------------------
  201|     12|        return 0;
  202|     12|      }
  203|  19.8k|      *utf32_output++ = char32_t(code_point);
  204|  19.8k|      pos += 2;
  205|  47.5k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (205:16): [True: 45.8k, False: 1.74k]
  ------------------
  206|       |      // We have a three-byte UTF-8
  207|  45.8k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (207:11): [True: 30, False: 45.8k]
  ------------------
  208|     30|        return 0;
  209|     30|      }  // minimal bound checking
  210|       |
  211|  45.8k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (211:11): [True: 54, False: 45.7k]
  ------------------
  212|     54|        return 0;
  213|     54|      }
  214|  45.7k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (214:11): [True: 15, False: 45.7k]
  ------------------
  215|     15|        return 0;
  216|     15|      }
  217|       |      // range check
  218|  45.7k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
  219|  45.7k|                            (data[pos + 1] & 0b00111111) << 6 |
  220|  45.7k|                            (data[pos + 2] & 0b00111111);
  221|  45.7k|      if (code_point < 0x800 || 0xffff < code_point ||
  ------------------
  |  Branch (221:11): [True: 24, False: 45.7k]
  |  Branch (221:33): [True: 0, False: 45.7k]
  ------------------
  222|  45.7k|          (0xd7ff < code_point && code_point < 0xe000)) {
  ------------------
  |  Branch (222:12): [True: 3.92k, False: 41.7k]
  |  Branch (222:35): [True: 9, False: 3.91k]
  ------------------
  223|     33|        return 0;
  224|     33|      }
  225|  45.7k|      *utf32_output++ = char32_t(code_point);
  226|  45.7k|      pos += 3;
  227|  45.7k|    } else if ((leading_byte & 0b11111000) == 0b11110000) {  // 0b11110000
  ------------------
  |  Branch (227:16): [True: 1.44k, False: 306]
  ------------------
  228|       |      // we have a 4-byte UTF-8 word.
  229|  1.44k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (229:11): [True: 45, False: 1.39k]
  ------------------
  230|     45|        return 0;
  231|     45|      }  // minimal bound checking
  232|  1.39k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (232:11): [True: 18, False: 1.38k]
  ------------------
  233|     18|        return 0;
  234|     18|      }
  235|  1.38k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (235:11): [True: 15, False: 1.36k]
  ------------------
  236|     15|        return 0;
  237|     15|      }
  238|  1.36k|      if ((data[pos + 3] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (238:11): [True: 18, False: 1.34k]
  ------------------
  239|     18|        return 0;
  240|     18|      }
  241|       |
  242|       |      // range check
  243|  1.34k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  244|  1.34k|                            (data[pos + 1] & 0b00111111) << 12 |
  245|  1.34k|                            (data[pos + 2] & 0b00111111) << 6 |
  246|  1.34k|                            (data[pos + 3] & 0b00111111);
  247|  1.34k|      if (code_point <= 0xffff || 0x10ffff < code_point) {
  ------------------
  |  Branch (247:11): [True: 21, False: 1.32k]
  |  Branch (247:35): [True: 12, False: 1.31k]
  ------------------
  248|     33|        return 0;
  249|     33|      }
  250|  1.31k|      *utf32_output++ = char32_t(code_point);
  251|  1.31k|      pos += 4;
  252|  1.31k|    } else {
  253|    306|      return 0;
  254|    306|    }
  255|   160k|  }
  256|  12.2k|  return utf32_output - start;
  257|  13.1k|}
_ZN3ada4idna22utf32_length_from_utf8EPKcm:
  272|  13.2k|size_t utf32_length_from_utf8(const char* buf, size_t len) {
  273|  13.2k|  const int8_t* p = reinterpret_cast<const int8_t*>(buf);
  274|  13.2k|  return std::count_if(p, std::next(p, len), [](int8_t c) {
  275|       |    // -65 is 0b10111111, anything larger in two-complement's
  276|       |    // should start a new code point.
  277|  13.2k|    return c > -65;
  278|  13.2k|  });
  279|  13.2k|}
_ZN3ada4idna9ascii_mapEPcm:
 5338|  6.28k|void ascii_map(char* input, size_t length) {
 5339|  6.28k|  auto broadcast = [](uint8_t v) -> uint64_t {
 5340|  6.28k|    return 0x101010101010101ull * v;
 5341|  6.28k|  };
 5342|  6.28k|  uint64_t broadcast_80 = broadcast(0x80);
 5343|  6.28k|  uint64_t broadcast_Ap = broadcast(128 - 'A');
 5344|  6.28k|  uint64_t broadcast_Zp = broadcast(128 - 'Z' - 1);
 5345|  6.28k|  size_t i = 0;
 5346|       |
 5347|  54.2k|  for (; i + 7 < length; i += 8) {
  ------------------
  |  Branch (5347:10): [True: 47.9k, False: 6.28k]
  ------------------
 5348|  47.9k|    uint64_t word{};
 5349|  47.9k|    std::memcpy(&word, input + i, sizeof(word));
 5350|  47.9k|    word ^=
 5351|  47.9k|        (((word + broadcast_Ap) ^ (word + broadcast_Zp)) & broadcast_80) >> 2;
 5352|  47.9k|    std::memcpy(input + i, &word, sizeof(word));
 5353|  47.9k|  }
 5354|  6.28k|  if (i < length) {
  ------------------
  |  Branch (5354:7): [True: 5.46k, False: 820]
  ------------------
 5355|  5.46k|    uint64_t word{};
 5356|  5.46k|    std::memcpy(&word, input + i, length - i);
 5357|  5.46k|    word ^=
 5358|  5.46k|        (((word + broadcast_Ap) ^ (word + broadcast_Zp)) & broadcast_80) >> 2;
 5359|  5.46k|    std::memcpy(input + i, &word, length - i);
 5360|  5.46k|  }
 5361|  6.28k|}
_ZN3ada4idna3mapENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEERNS1_12basic_stringIDiS4_NS1_9allocatorIDiEEEE:
 5365|  19.3k|bool map(std::u32string_view input, std::u32string& out) {
 5366|       |  //  [Map](https://www.unicode.org/reports/tr46/#ProcessingStepMap).
 5367|  19.3k|  out.clear();
 5368|  19.3k|  if (!ensure_tables()) {
  ------------------
  |  Branch (5368:7): [True: 0, False: 19.3k]
  ------------------
 5369|      0|    return false;
 5370|      0|  }
 5371|       |
 5372|       |  // Pass 1: validate and compute exact output length.
 5373|  19.3k|  size_t out_size = 0;
 5374|   346k|  for (char32_t x : input) {
  ------------------
  |  Branch (5374:19): [True: 346k, False: 18.7k]
  ------------------
 5375|   346k|    uint16_t status = idna_lookup(static_cast<uint32_t>(x));
 5376|   346k|    if (status == IDNA_DISALLOWED) {
  ------------------
  |  Branch (5376:9): [True: 543, False: 345k]
  ------------------
 5377|    543|      return false;
 5378|    543|    }
 5379|   345k|    if (status == IDNA_VALID) {
  ------------------
  |  Branch (5379:9): [True: 242k, False: 103k]
  ------------------
 5380|   242k|      ++out_size;
 5381|   242k|      continue;
 5382|   242k|    }
 5383|   103k|    if (static_cast<size_t>(status) >= idna_utf8_mappings_size) {
  ------------------
  |  Branch (5383:9): [True: 0, False: 103k]
  ------------------
 5384|      0|      return false;
 5385|      0|    }
 5386|   103k|    out_size += utf8_count_codepoints(idna_utf8_mappings + status);
 5387|   103k|  }
 5388|       |
 5389|       |  // Pass 2: write into a single allocation.
 5390|  18.7k|  out.resize(out_size);
 5391|  18.7k|  size_t w = 0;
 5392|   344k|  for (char32_t x : input) {
  ------------------
  |  Branch (5392:19): [True: 344k, False: 18.7k]
  ------------------
 5393|   344k|    uint16_t status = idna_lookup(static_cast<uint32_t>(x));
 5394|   344k|    if (status == IDNA_VALID) {
  ------------------
  |  Branch (5394:9): [True: 241k, False: 102k]
  ------------------
 5395|   241k|      out[w++] = x;
 5396|   241k|      continue;
 5397|   241k|    }
 5398|       |    // IGNORED or mapped (status already validated in pass 1).
 5399|   102k|    const uint8_t* ptr = idna_utf8_mappings + status;
 5400|   516k|    while (*ptr != 0) {
  ------------------
  |  Branch (5400:12): [True: 413k, False: 102k]
  ------------------
 5401|   413k|      out[w++] = utf8_next(ptr);
 5402|   413k|    }
 5403|   102k|  }
 5404|  18.7k|  return true;
 5405|  19.3k|}
_ZN3ada4idna28compute_decomposition_lengthENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 5499|  5.65k|    const std::u32string_view input) noexcept {
 5500|  5.65k|  bool decomposition_needed{false};
 5501|  5.65k|  size_t additional_elements{0};
 5502|  83.7k|  for (char32_t current_character : input) {
  ------------------
  |  Branch (5502:35): [True: 83.7k, False: 5.65k]
  ------------------
 5503|  83.7k|    size_t decomposition_length{0};
 5504|       |
 5505|  83.7k|    if (current_character >= hangul_sbase &&
  ------------------
  |  Branch (5505:9): [True: 7.89k, False: 75.8k]
  ------------------
 5506|  7.89k|        current_character < hangul_sbase + hangul_scount) {
  ------------------
  |  Branch (5506:9): [True: 4.87k, False: 3.01k]
  ------------------
 5507|       |      // Full NFD-style Hangul decomp for the decompose() step.
 5508|  4.87k|      decomposition_length = 2;
 5509|  4.87k|      if ((current_character - hangul_sbase) % hangul_tcount) {
  ------------------
  |  Branch (5509:11): [True: 2.07k, False: 2.79k]
  ------------------
 5510|  2.07k|        decomposition_length = 3;
 5511|  2.07k|      }
 5512|  78.8k|    } else if (current_character < 0x110000) {
  ------------------
  |  Branch (5512:16): [True: 78.8k, False: 0]
  ------------------
 5513|  78.8k|      const uint8_t di = decomposition_index[current_character >> 8];
 5514|  78.8k|      const uint16_t* const decomposition =
 5515|  78.8k|          decomposition_block_row(di) + (current_character % 256);
 5516|  78.8k|      decomposition_length = (decomposition[1] >> 2) - (decomposition[0] >> 2);
 5517|  78.8k|      if ((decomposition_length > 0) && (decomposition[0] & 1)) {
  ------------------
  |  Branch (5517:11): [True: 12.7k, False: 66.1k]
  |  Branch (5517:41): [True: 0, False: 12.7k]
  ------------------
 5518|      0|        decomposition_length = 0;
 5519|      0|      }
 5520|  78.8k|    }
 5521|  83.7k|    if (decomposition_length != 0) {
  ------------------
  |  Branch (5521:9): [True: 17.5k, False: 66.1k]
  ------------------
 5522|  17.5k|      decomposition_needed = true;
 5523|  17.5k|      additional_elements += decomposition_length - 1;
 5524|  17.5k|    }
 5525|  83.7k|  }
 5526|  5.65k|  return {decomposition_needed, additional_elements};
 5527|  5.65k|}
_ZN3ada4idna9decomposeERNSt3__112basic_stringIDiNS1_11char_traitsIDiEENS1_9allocatorIDiEEEEm:
 5529|  4.54k|void decompose(std::u32string& input, size_t additional_elements) {
 5530|  4.54k|  input.resize(input.size() + additional_elements);
 5531|  4.54k|  for (size_t descending_idx = input.size(),
 5532|  4.54k|              input_count = descending_idx - additional_elements;
 5533|  51.0k|       input_count--;) {
  ------------------
  |  Branch (5533:8): [True: 46.4k, False: 4.54k]
  ------------------
 5534|  46.4k|    if (input[input_count] >= hangul_sbase &&
  ------------------
  |  Branch (5534:9): [True: 6.58k, False: 39.8k]
  ------------------
 5535|  6.58k|        input[input_count] < hangul_sbase + hangul_scount) {
  ------------------
  |  Branch (5535:9): [True: 4.87k, False: 1.71k]
  ------------------
 5536|       |      // Hangul decomposition.
 5537|  4.87k|      char32_t s_index = input[input_count] - hangul_sbase;
 5538|  4.87k|      if (s_index % hangul_tcount != 0) {
  ------------------
  |  Branch (5538:11): [True: 2.07k, False: 2.79k]
  ------------------
 5539|  2.07k|        input[--descending_idx] = hangul_tbase + s_index % hangul_tcount;
 5540|  2.07k|      }
 5541|  4.87k|      input[--descending_idx] =
 5542|  4.87k|          hangul_vbase + (s_index % hangul_ncount) / hangul_tcount;
 5543|  4.87k|      input[--descending_idx] = hangul_lbase + s_index / hangul_ncount;
 5544|  41.6k|    } else if (input[input_count] < 0x110000) {
  ------------------
  |  Branch (5544:16): [True: 41.6k, False: 0]
  ------------------
 5545|  41.6k|      const uint16_t* decomposition =
 5546|  41.6k|          decomposition_block_row(
 5547|  41.6k|              decomposition_index[input[input_count] >> 8]) +
 5548|  41.6k|          (input[input_count] % 256);
 5549|  41.6k|      uint16_t decomposition_length =
 5550|  41.6k|          (decomposition[1] >> 2) - (decomposition[0] >> 2);
 5551|  41.6k|      if (decomposition_length > 0 && (decomposition[0] & 1)) {
  ------------------
  |  Branch (5551:11): [True: 12.7k, False: 28.8k]
  |  Branch (5551:39): [True: 0, False: 12.7k]
  ------------------
 5552|      0|        decomposition_length = 0;
 5553|      0|      }
 5554|  41.6k|      if (decomposition_length > 0) {
  ------------------
  |  Branch (5554:11): [True: 12.7k, False: 28.8k]
  ------------------
 5555|  12.7k|        const size_t base = static_cast<size_t>(decomposition[0] >> 2);
 5556|  12.7k|        if (base + decomposition_length > decomposition_data_size) {
  ------------------
  |  Branch (5556:13): [True: 0, False: 12.7k]
  ------------------
 5557|      0|          input[--descending_idx] = input[input_count];
 5558|  12.7k|        } else {
 5559|  41.1k|          while (decomposition_length-- > 0) {
  ------------------
  |  Branch (5559:18): [True: 28.4k, False: 12.7k]
  ------------------
 5560|  28.4k|            input[--descending_idx] =
 5561|  28.4k|                decomposition_data[base + decomposition_length];
 5562|  28.4k|          }
 5563|  12.7k|        }
 5564|  28.8k|      } else {
 5565|  28.8k|        input[--descending_idx] = input[input_count];
 5566|  28.8k|      }
 5567|  41.6k|    } else {
 5568|      0|      input[--descending_idx] = input[input_count];
 5569|      0|    }
 5570|  46.4k|  }
 5571|  4.54k|}
_ZN3ada4idna7get_cccEDi:
 5573|  1.56M|uint8_t get_ccc(char32_t c) noexcept {
 5574|  1.56M|  if (c >= 0x110000) {
  ------------------
  |  Branch (5574:7): [True: 0, False: 1.56M]
  ------------------
 5575|      0|    return 0;
 5576|      0|  }
 5577|  1.56M|  return ccc_block_row(ccc_index[c >> 8])[c % 256];
 5578|  1.56M|}
_ZN3ada4idna10sort_marksERNSt3__112basic_stringIDiNS1_11char_traitsIDiEENS1_9allocatorIDiEEEE:
 5580|  5.65k|void sort_marks(std::u32string& input) {
 5581|   106k|  for (size_t idx = 1; idx < input.size(); idx++) {
  ------------------
  |  Branch (5581:24): [True: 100k, False: 5.65k]
  ------------------
 5582|   100k|    uint8_t ccc = get_ccc(input[idx]);
 5583|   100k|    if (ccc == 0) {
  ------------------
  |  Branch (5583:9): [True: 72.3k, False: 28.3k]
  ------------------
 5584|  72.3k|      continue;
 5585|  72.3k|    }
 5586|  28.3k|    auto current_character = input[idx];
 5587|  28.3k|    size_t back_idx = idx;
 5588|  38.5k|    while (back_idx != 0 && get_ccc(input[back_idx - 1]) > ccc) {
  ------------------
  |  Branch (5588:12): [True: 38.2k, False: 315]
  |  Branch (5588:29): [True: 10.1k, False: 28.0k]
  ------------------
 5589|  10.1k|      input[back_idx] = input[back_idx - 1];
 5590|  10.1k|      back_idx--;
 5591|  10.1k|    }
 5592|  28.3k|    input[back_idx] = current_character;
 5593|  28.3k|  }
 5594|  5.65k|}
_ZN3ada4idna13decompose_nfcERNSt3__112basic_stringIDiNS1_11char_traitsIDiEENS1_9allocatorIDiEEEE:
 5596|  5.65k|void decompose_nfc(std::u32string& input) {
 5597|       |  /**
 5598|       |   * Decompose the domain_name string to Unicode Normalization Form C.
 5599|       |   * @see https://www.unicode.org/reports/tr46/#ProcessingStepDecompose
 5600|       |   */
 5601|  5.65k|  auto [decomposition_needed, additional_elements] =
 5602|  5.65k|      compute_decomposition_length(input);
 5603|  5.65k|  if (decomposition_needed) {
  ------------------
  |  Branch (5603:7): [True: 4.54k, False: 1.11k]
  ------------------
 5604|  4.54k|    decompose(input, additional_elements);
 5605|  4.54k|  }
 5606|  5.65k|  sort_marks(input);
 5607|  5.65k|}
_ZN3ada4idna14is_already_nfcENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 5742|  21.1k|bool is_already_nfc(std::u32string_view input) noexcept {
 5743|  21.1k|  if (input.empty()) {
  ------------------
  |  Branch (5743:7): [True: 0, False: 21.1k]
  ------------------
 5744|      0|    return true;
 5745|      0|  }
 5746|  21.1k|  if (!tables_are_ready() && !ensure_tables()) {
  ------------------
  |  Branch (5746:7): [True: 0, False: 21.1k]
  |  Branch (5746:30): [True: 0, False: 0]
  ------------------
 5747|      0|    return false;
 5748|      0|  }
 5749|       |  // 1) A character whose canonical decomposition does not compose back to it is
 5750|       |  //    not NFC: singletons (e.g. U+212B), composition exclusions (e.g. U+0958)
 5751|       |  //    and non-starter decompositions (e.g. U+0344), or one whose
 5752|       |  //    decomposition starts with a code point that composes with the previous
 5753|       |  //    character (e.g. U+1611E U+16121).
 5754|  21.1k|  char32_t previous = 0x110000;  // none
 5755|   483k|  for (char32_t c : input) {
  ------------------
  |  Branch (5755:19): [True: 483k, False: 21.1k]
  ------------------
 5756|   483k|    if (decomposition_is_not_nfc(previous, c)) {
  ------------------
  |  Branch (5756:9): [True: 30, False: 483k]
  ------------------
 5757|     30|      return false;
 5758|     30|    }
 5759|   483k|    previous = c;
 5760|   483k|  }
 5761|       |  // 2) Combining marks already in canonical order. prev_ccc carries the
 5762|       |  //    trailing class of the previous character's canonical decomposition so a
 5763|       |  //    composite starter followed by a lower-class mark is caught.
 5764|  21.1k|  uint8_t prev_ccc = 0;
 5765|   464k|  for (char32_t c : input) {
  ------------------
  |  Branch (5765:19): [True: 464k, False: 12.1k]
  ------------------
 5766|   464k|    uint8_t ccc = get_ccc(c);
 5767|   464k|    if (ccc != 0 && prev_ccc > ccc) {
  ------------------
  |  Branch (5767:9): [True: 26.8k, False: 438k]
  |  Branch (5767:21): [True: 8.96k, False: 17.8k]
  ------------------
 5768|  8.96k|      return false;
 5769|  8.96k|    }
 5770|   455k|    prev_ccc = trailing_ccc(c);
 5771|   455k|  }
 5772|       |  // 3) No pairwise composition would apply (including Hangul L+V / LV+T).
 5773|  12.1k|  return !would_compose(input);
 5774|  21.1k|}
_ZN3ada4idna7composeERNSt3__112basic_stringIDiNS1_11char_traitsIDiEENS1_9allocatorIDiEEEE:
 5776|  38.6k|void compose(std::u32string& input) {
 5777|       |  /**
 5778|       |   * Compose the domain_name string to Unicode Normalization Form C.
 5779|       |   * @see https://www.unicode.org/reports/tr46/#ProcessingStepCompose
 5780|       |   */
 5781|  38.6k|  size_t input_count{0};
 5782|  38.6k|  size_t composition_count{0};
 5783|   142k|  for (; input_count < input.size(); input_count++, composition_count++) {
  ------------------
  |  Branch (5783:10): [True: 103k, False: 38.6k]
  ------------------
 5784|   103k|    input[composition_count] = input[input_count];
 5785|   103k|    if (input[input_count] >= hangul_lbase &&
  ------------------
  |  Branch (5785:9): [True: 20.1k, False: 83.2k]
  ------------------
 5786|  20.1k|        input[input_count] < hangul_lbase + hangul_lcount) {
  ------------------
  |  Branch (5786:9): [True: 8.77k, False: 11.3k]
  ------------------
 5787|  8.77k|      if (input_count + 1 < input.size() &&
  ------------------
  |  Branch (5787:11): [True: 8.73k, False: 48]
  ------------------
 5788|  8.73k|          input[input_count + 1] >= hangul_vbase &&
  ------------------
  |  Branch (5788:11): [True: 5.61k, False: 3.12k]
  ------------------
 5789|  5.61k|          input[input_count + 1] < hangul_vbase + hangul_vcount) {
  ------------------
  |  Branch (5789:11): [True: 5.04k, False: 570]
  ------------------
 5790|  5.04k|        input[composition_count] =
 5791|  5.04k|            hangul_sbase +
 5792|  5.04k|            ((input[input_count] - hangul_lbase) * hangul_vcount +
 5793|  5.04k|             input[input_count + 1] - hangul_vbase) *
 5794|  5.04k|                hangul_tcount;
 5795|  5.04k|        input_count++;
 5796|  5.04k|        if (input_count + 1 < input.size() &&
  ------------------
  |  Branch (5796:13): [True: 4.89k, False: 150]
  ------------------
 5797|  4.89k|            input[input_count + 1] > hangul_tbase &&
  ------------------
  |  Branch (5797:13): [True: 2.69k, False: 2.19k]
  ------------------
 5798|  2.69k|            input[input_count + 1] < hangul_tbase + hangul_tcount) {
  ------------------
  |  Branch (5798:13): [True: 2.13k, False: 564]
  ------------------
 5799|  2.13k|          input[composition_count] += input[++input_count] - hangul_tbase;
 5800|  2.13k|        }
 5801|  5.04k|      }
 5802|  94.6k|    } else if (input[input_count] >= hangul_sbase &&
  ------------------
  |  Branch (5802:16): [True: 3.88k, False: 90.7k]
  ------------------
 5803|  3.88k|               input[input_count] < hangul_sbase + hangul_scount) {
  ------------------
  |  Branch (5803:16): [True: 0, False: 3.88k]
  ------------------
 5804|      0|      if ((input[input_count] - hangul_sbase) % hangul_tcount == 0 &&
  ------------------
  |  Branch (5804:11): [True: 0, False: 0]
  ------------------
 5805|      0|          input_count + 1 < input.size() &&
  ------------------
  |  Branch (5805:11): [True: 0, False: 0]
  ------------------
 5806|      0|          input[input_count + 1] > hangul_tbase &&
  ------------------
  |  Branch (5806:11): [True: 0, False: 0]
  ------------------
 5807|      0|          input[input_count + 1] < hangul_tbase + hangul_tcount) {
  ------------------
  |  Branch (5807:11): [True: 0, False: 0]
  ------------------
 5808|      0|        input[composition_count] += input[++input_count] - hangul_tbase;
 5809|      0|      }
 5810|  94.6k|    } else if (input[input_count] < 0x110000) {
  ------------------
  |  Branch (5810:16): [True: 94.6k, False: 0]
  ------------------
 5811|  94.6k|      const uint16_t* composition =
 5812|  94.6k|          composition_block_row(composition_index[input[input_count] >> 8]) +
 5813|  94.6k|          (input[input_count] % 256);
 5814|  94.6k|      size_t initial_composition_count = composition_count;
 5815|   163k|      for (int32_t previous_ccc = -1; input_count + 1 < input.size();
  ------------------
  |  Branch (5815:39): [True: 124k, False: 38.3k]
  ------------------
 5816|   124k|           input_count++) {
 5817|   124k|        uint8_t ccc = get_ccc(input[input_count + 1]);
 5818|       |
 5819|   124k|        if (composition[1] != composition[0] && previous_ccc < ccc) {
  ------------------
  |  Branch (5819:13): [True: 74.8k, False: 49.7k]
  |  Branch (5819:49): [True: 71.7k, False: 3.18k]
  ------------------
 5820|  71.7k|          int left = composition[0];
 5821|  71.7k|          int right = composition[1];
 5822|  71.7k|          if (left < 0 || right < left ||
  ------------------
  |  Branch (5822:15): [True: 0, False: 71.7k]
  |  Branch (5822:27): [True: 0, False: 71.7k]
  ------------------
 5823|  71.7k|              static_cast<size_t>(right) > composition_data_size) {
  ------------------
  |  Branch (5823:15): [True: 0, False: 71.7k]
  ------------------
 5824|      0|            break;
 5825|      0|          }
 5826|   163k|          while (left + 2 < right) {
  ------------------
  |  Branch (5826:18): [True: 91.8k, False: 71.7k]
  ------------------
 5827|  91.8k|            int middle = left + (((right - left) >> 1) & ~1);
 5828|  91.8k|            if (composition_data[static_cast<size_t>(middle)] <=
  ------------------
  |  Branch (5828:17): [True: 65.9k, False: 25.8k]
  ------------------
 5829|  91.8k|                input[input_count + 1]) {
 5830|  65.9k|              left = middle;
 5831|  65.9k|            }
 5832|  91.8k|            if (composition_data[static_cast<size_t>(middle)] >=
  ------------------
  |  Branch (5832:17): [True: 64.2k, False: 27.5k]
  ------------------
 5833|  91.8k|                input[input_count + 1]) {
 5834|  64.2k|              right = middle;
 5835|  64.2k|            }
 5836|  91.8k|          }
 5837|  71.7k|          if (static_cast<size_t>(left + 1) < composition_data_size &&
  ------------------
  |  Branch (5837:15): [True: 71.7k, False: 0]
  ------------------
 5838|  71.7k|              composition_data[static_cast<size_t>(left)] ==
  ------------------
  |  Branch (5838:15): [True: 56.3k, False: 15.4k]
  ------------------
 5839|  71.7k|                  input[input_count + 1]) {
 5840|  56.3k|            char32_t composed = composition_data[static_cast<size_t>(left + 1)];
 5841|  56.3k|            input[initial_composition_count] = composed;
 5842|  56.3k|            composition =
 5843|  56.3k|                composition_block_row(composition_index[composed >> 8]) +
 5844|  56.3k|                (composed % 256);
 5845|  56.3k|            continue;
 5846|  56.3k|          }
 5847|  71.7k|        }
 5848|       |
 5849|  68.3k|        if (ccc == 0) {
  ------------------
  |  Branch (5849:13): [True: 56.2k, False: 12.0k]
  ------------------
 5850|  56.2k|          break;
 5851|  56.2k|        }
 5852|  12.0k|        previous_ccc = ccc;
 5853|  12.0k|        input[++composition_count] = input[input_count + 1];
 5854|  12.0k|      }
 5855|  94.6k|    }
 5856|   103k|  }
 5857|       |
 5858|  38.6k|  if (composition_count < input_count) {
  ------------------
  |  Branch (5858:7): [True: 38.3k, False: 345]
  ------------------
 5859|  38.3k|    input.resize(composition_count);
 5860|  38.3k|  }
 5861|  38.6k|}
_ZN3ada4idna9normalizeERNSt3__112basic_stringIDiNS1_11char_traitsIDiEENS1_9allocatorIDiEEEE:
 5863|  5.65k|bool normalize(std::u32string& input) {
 5864|       |  /**
 5865|       |   * Normalize the characters according to IDNA (Unicode Normalization Form C).
 5866|       |   * @see https://www.unicode.org/reports/tr46/#ProcessingStepNormalize
 5867|       |   */
 5868|  5.65k|  if (!ensure_tables() || decomposition_index == nullptr ||
  ------------------
  |  Branch (5868:7): [True: 0, False: 5.65k]
  |  Branch (5868:27): [True: 0, False: 5.65k]
  ------------------
 5869|  5.65k|      composition_index == nullptr) {
  ------------------
  |  Branch (5869:7): [True: 0, False: 5.65k]
  ------------------
 5870|      0|    return false;
 5871|      0|  }
 5872|  5.65k|  if (is_already_nfc(input)) {
  ------------------
  |  Branch (5872:7): [True: 0, False: 5.65k]
  ------------------
 5873|      0|    return true;
 5874|      0|  }
 5875|  5.65k|  decompose_nfc(input);
 5876|  5.65k|  compose(input);
 5877|  5.65k|  return true;
 5878|  5.65k|}
_ZN3ada4idna17punycode_to_utf32ENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEERNS1_12basic_stringIDiNS3_IDiEENS1_9allocatorIDiEEEE:
 5938|  7.66k|bool punycode_to_utf32(std::string_view input, std::u32string &out) {
 5939|  7.66k|  int32_t written_out{0};
 5940|  7.66k|  out.reserve(out.size() + input.size());
 5941|  7.66k|  uint32_t n = initial_n;
 5942|  7.66k|  int32_t i = 0;
 5943|  7.66k|  int32_t bias = initial_bias;
 5944|       |  // grab ascii content
 5945|       |  // RFC 3492 section 6.2: copy the code points before the last delimiter,
 5946|       |  // then consume the delimiter only "if more than zero code points were
 5947|       |  // consumed". With a leading delimiter, b == 0, decoding starts at the
 5948|       |  // delimiter itself, which is not a digit, and fails. This matches the
 5949|       |  // reference implementation in appendix C (`in = b > 0 ? b + 1 : 0`).
 5950|  7.66k|  size_t end_of_ascii = input.find_last_of('-');
 5951|  7.66k|  if (end_of_ascii != std::string_view::npos && end_of_ascii > 0) {
  ------------------
  |  Branch (5951:7): [True: 984, False: 6.68k]
  |  Branch (5951:49): [True: 975, False: 9]
  ------------------
 5952|  9.34k|    for (uint8_t c : input.substr(0, end_of_ascii)) {
  ------------------
  |  Branch (5952:20): [True: 9.34k, False: 975]
  ------------------
 5953|  9.34k|      if (c >= 0x80) {
  ------------------
  |  Branch (5953:11): [True: 0, False: 9.34k]
  ------------------
 5954|      0|        return false;
 5955|      0|      }
 5956|  9.34k|      out.push_back(c);
 5957|  9.34k|      written_out++;
 5958|  9.34k|    }
 5959|    975|    input.remove_prefix(end_of_ascii + 1);
 5960|    975|  }
 5961|  77.3k|  while (!input.empty()) {
  ------------------
  |  Branch (5961:10): [True: 69.9k, False: 7.33k]
  ------------------
 5962|  69.9k|    int32_t oldi = i;
 5963|  69.9k|    int32_t w = 1;
 5964|  93.5k|    for (int32_t k = base;; k += base) {
 5965|  93.5k|      if (input.empty()) {
  ------------------
  |  Branch (5965:11): [True: 189, False: 93.3k]
  ------------------
 5966|    189|        return false;
 5967|    189|      }
 5968|  93.3k|      uint8_t code_point = input.front();
 5969|  93.3k|      input.remove_prefix(1);
 5970|  93.3k|      int32_t digit = char_to_digit_value(code_point);
 5971|  93.3k|      if (digit < 0) {
  ------------------
  |  Branch (5971:11): [True: 69, False: 93.2k]
  ------------------
 5972|     69|        return false;
 5973|     69|      }
 5974|  93.2k|      if (digit > (0x7fffffff - i) / w) {
  ------------------
  |  Branch (5974:11): [True: 21, False: 93.2k]
  ------------------
 5975|     21|        return false;
 5976|     21|      }
 5977|  93.2k|      i = i + digit * w;
 5978|  93.2k|      int32_t t = k <= bias ? tmin : k >= bias + tmax ? tmax : k - bias;
  ------------------
  |  Branch (5978:19): [True: 17.9k, False: 75.2k]
  |  Branch (5978:38): [True: 71.6k, False: 3.59k]
  ------------------
 5979|  93.2k|      if (digit < t) {
  ------------------
  |  Branch (5979:11): [True: 69.7k, False: 23.5k]
  ------------------
 5980|  69.7k|        break;
 5981|  69.7k|      }
 5982|  23.5k|      if (w > 0x7fffffff / (base - t)) {
  ------------------
  |  Branch (5982:11): [True: 0, False: 23.5k]
  ------------------
 5983|      0|        return false;
 5984|      0|      }
 5985|  23.5k|      w = w * (base - t);
 5986|  23.5k|    }
 5987|  69.7k|    bias = adapt(i - oldi, written_out + 1, oldi == 0);
 5988|  69.7k|    if (i / (written_out + 1) > int32_t(0x7fffffff - n)) {
  ------------------
  |  Branch (5988:9): [True: 57, False: 69.6k]
  ------------------
 5989|     57|      return false;
 5990|     57|    }
 5991|  69.6k|    n = n + i / (written_out + 1);
 5992|  69.6k|    i = i % (written_out + 1);
 5993|  69.6k|    if (n < 0x80) {
  ------------------
  |  Branch (5993:9): [True: 0, False: 69.6k]
  ------------------
 5994|      0|      return false;
 5995|      0|    }
 5996|  69.6k|    out.insert(out.begin() + i, n);
 5997|  69.6k|    written_out++;
 5998|  69.6k|    ++i;
 5999|  69.6k|  }
 6000|       |  // See https://github.com/whatwg/url/issues/803
 6001|       |  // Reject labels whose decoded form begins with "xn--" (double-encoded ACE).
 6002|  7.33k|  if (out.size() >= 4 && out[0] == U'x' && out[1] == U'n' && out[2] == U'-' &&
  ------------------
  |  Branch (6002:7): [True: 2.48k, False: 4.84k]
  |  Branch (6002:26): [True: 405, False: 2.07k]
  |  Branch (6002:44): [True: 237, False: 168]
  |  Branch (6002:62): [True: 87, False: 150]
  ------------------
 6003|     87|      out[3] == U'-') {
  ------------------
  |  Branch (6003:7): [True: 12, False: 75]
  ------------------
 6004|     12|    return false;
 6005|     12|  }
 6006|  7.32k|  return true;
 6007|  7.33k|}
_ZN3ada4idna17utf32_to_punycodeENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEERNS1_12basic_stringIcNS3_IcEENS1_9allocatorIcEEEE:
 6087|  34.4k|bool utf32_to_punycode(std::u32string_view input, std::string &out) {
 6088|  34.4k|  out.reserve(input.size() + out.size());
 6089|  34.4k|  uint32_t n = initial_n;
 6090|  34.4k|  int32_t d = 0;
 6091|  34.4k|  int32_t bias = initial_bias;
 6092|  34.4k|  size_t h = 0;
 6093|       |  // first push the ascii content
 6094|   153k|  for (uint32_t c : input) {
  ------------------
  |  Branch (6094:19): [True: 153k, False: 34.4k]
  ------------------
 6095|   153k|    if (c < 0x80) {
  ------------------
  |  Branch (6095:9): [True: 15.9k, False: 137k]
  ------------------
 6096|  15.9k|      ++h;
 6097|  15.9k|      out.push_back(char(c));
 6098|  15.9k|    }
 6099|   153k|    if (c > 0x10ffff || (c >= 0xd800 && c < 0xe000)) {
  ------------------
  |  Branch (6099:9): [True: 0, False: 153k]
  |  Branch (6099:26): [True: 1.61k, False: 152k]
  |  Branch (6099:41): [True: 0, False: 1.61k]
  ------------------
 6100|      0|      return false;
 6101|      0|    }
 6102|   153k|  }
 6103|  34.4k|  size_t b = h;
 6104|  34.4k|  if (b > 0) {
  ------------------
  |  Branch (6104:7): [True: 4.84k, False: 29.6k]
  ------------------
 6105|  4.84k|    out.push_back('-');
 6106|  4.84k|  }
 6107|   150k|  while (h < input.size()) {
  ------------------
  |  Branch (6107:10): [True: 116k, False: 34.4k]
  ------------------
 6108|   116k|    uint32_t m = 0x10FFFF;
 6109|   668k|    for (auto code_point : input) {
  ------------------
  |  Branch (6109:26): [True: 668k, False: 116k]
  ------------------
 6110|   668k|      if (code_point >= n && code_point < m) m = code_point;
  ------------------
  |  Branch (6110:11): [True: 389k, False: 278k]
  |  Branch (6110:30): [True: 203k, False: 186k]
  ------------------
 6111|   668k|    }
 6112|       |
 6113|   116k|    if ((m - n) > (0x7fffffff - d) / (h + 1)) {
  ------------------
  |  Branch (6113:9): [True: 0, False: 116k]
  ------------------
 6114|      0|      return false;
 6115|      0|    }
 6116|   116k|    d = d + int32_t((m - n) * (h + 1));
 6117|   116k|    n = m;
 6118|   668k|    for (auto c : input) {
  ------------------
  |  Branch (6118:17): [True: 668k, False: 116k]
  ------------------
 6119|   668k|      if (c < n) {
  ------------------
  |  Branch (6119:11): [True: 278k, False: 389k]
  ------------------
 6120|   278k|        if (d == 0x7fffffff) {
  ------------------
  |  Branch (6120:13): [True: 0, False: 278k]
  ------------------
 6121|      0|          return false;
 6122|      0|        }
 6123|   278k|        ++d;
 6124|   278k|      }
 6125|   668k|      if (c == n) {
  ------------------
  |  Branch (6125:11): [True: 137k, False: 530k]
  ------------------
 6126|   137k|        int32_t q = d;
 6127|   404k|        for (int32_t k = base;; k += base) {
 6128|   404k|          int32_t t = k <= bias ? tmin : k >= bias + tmax ? tmax : k - bias;
  ------------------
  |  Branch (6128:23): [True: 123k, False: 280k]
  |  Branch (6128:42): [True: 202k, False: 78.0k]
  ------------------
 6129|       |
 6130|   404k|          if (q < t) {
  ------------------
  |  Branch (6130:15): [True: 137k, False: 266k]
  ------------------
 6131|   137k|            break;
 6132|   137k|          }
 6133|   266k|          out.push_back(digit_to_char(t + ((q - t) % (base - t))));
 6134|   266k|          q = (q - t) / (base - t);
 6135|   266k|        }
 6136|   137k|        out.push_back(digit_to_char(q));
 6137|   137k|        bias = adapt(d, int32_t(h + 1), h == b);
 6138|   137k|        d = 0;
 6139|   137k|        ++h;
 6140|   137k|      }
 6141|   668k|    }
 6142|   116k|    ++d;
 6143|   116k|    ++n;
 6144|   116k|  }
 6145|  34.4k|  return true;
 6146|  34.4k|}
_ZN3ada4idna14is_label_validENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 6292|  42.2k|bool is_label_valid(const std::u32string_view label) {
 6293|  42.2k|  if (label.empty()) {
  ------------------
  |  Branch (6293:7): [True: 0, False: 42.2k]
  ------------------
 6294|      0|    return true;
 6295|      0|  }
 6296|  42.2k|  if (!ensure_tables() || combining_ranges == nullptr || dir_start == nullptr ||
  ------------------
  |  Branch (6296:7): [True: 0, False: 42.2k]
  |  Branch (6296:27): [True: 0, False: 42.2k]
  |  Branch (6296:58): [True: 0, False: 42.2k]
  ------------------
 6297|  42.2k|      dir_final == nullptr || dir_value == nullptr ||
  ------------------
  |  Branch (6297:7): [True: 0, False: 42.2k]
  |  Branch (6297:31): [True: 0, False: 42.2k]
  ------------------
 6298|  42.2k|      joining_start == nullptr || joining_final == nullptr ||
  ------------------
  |  Branch (6298:7): [True: 0, False: 42.2k]
  |  Branch (6298:35): [True: 0, False: 42.2k]
  ------------------
 6299|  42.2k|      joining_value == nullptr) {
  ------------------
  |  Branch (6299:7): [True: 0, False: 42.2k]
  ------------------
 6300|      0|    return false;
 6301|      0|  }
 6302|       |
 6303|       |  ///////////////
 6304|       |  // We have a normalization step which ensures that we are in NFC.
 6305|       |  // If we receive punycode, we normalize and check that the normalized
 6306|       |  // version matches the original.
 6307|       |  // --------------------------------------
 6308|       |  // The label must be in Unicode Normalization Form NFC.
 6309|       |
 6310|       |  // Current URL standard indicatest that CheckHyphens is set to false.
 6311|       |  // ---------------------------------------
 6312|       |  // If CheckHyphens, the label must not contain a U+002D HYPHEN-MINUS character
 6313|       |  // in both the third and fourth positions. If CheckHyphens, the label must
 6314|       |  // neither begin nor end with a U+002D HYPHEN-MINUS character.
 6315|       |
 6316|       |  // This is not necessary because we segment the
 6317|       |  // labels by '.'.
 6318|       |  // ---------------------------------------
 6319|       |  // The label must not contain a U+002E ( . ) FULL STOP.
 6320|       |  // if (label.find('.') != std::string_view::npos) return false;
 6321|       |
 6322|       |  // The label must not begin with a combining mark.
 6323|       |  // Range membership via lower_bound on range end.
 6324|  42.2k|  const std::span<const uint32_t[2]> comb_span{combining_ranges,
 6325|  42.2k|                                               combining_range_count};
 6326|  42.2k|  const auto comb_it = std::ranges::lower_bound(
 6327|  42.2k|      comb_span, label.front(), {}, [](const auto& range) { return range[1]; });
 6328|  42.2k|  if (comb_it != comb_span.end() && label.front() >= (*comb_it)[0]) {
  ------------------
  |  Branch (6328:7): [True: 42.2k, False: 0]
  |  Branch (6328:7): [True: 306, False: 41.9k]
  |  Branch (6328:37): [True: 306, False: 41.9k]
  ------------------
 6329|    306|    return false;
 6330|    306|  }
 6331|       |  // We verify this next step as part of the mapping:
 6332|       |  // ---------------------------------------------
 6333|       |  // Each code point in the label must only have certain status values
 6334|       |  // according to Section 5, IDNA Mapping Table:
 6335|       |  // - For Transitional Processing, each value must be valid.
 6336|       |  // - For Nontransitional Processing, each value must be either valid or
 6337|       |  // deviation.
 6338|       |
 6339|       |  // If CheckJoiners, the label must satisfy the ContextJ rules from Appendix
 6340|       |  // A, in The Unicode Code Points and Internationalized Domain Names for
 6341|       |  // Applications (IDNA) [IDNA2008].
 6342|  41.9k|  if (!is_contextj_valid(label)) {
  ------------------
  |  Branch (6342:7): [True: 477, False: 41.4k]
  ------------------
 6343|    477|    return false;
 6344|    477|  }
 6345|       |
 6346|       |  // If CheckBidi, and if the domain name is a  Bidi domain name, then the label
 6347|       |  // must satisfy all six of the numbered conditions in [IDNA2008] RFC 5893,
 6348|       |  // Section 2.
 6349|       |
 6350|       |  // The following rule, consisting of six conditions, applies to labels
 6351|       |  // in Bidi domain names.  The requirements that this rule satisfies are
 6352|       |  // described in Section 3.  All of the conditions must be satisfied for
 6353|       |  // the rule to be satisfied.
 6354|       |  //
 6355|       |  //  1.  The first character must be a character with Bidi property L, R,
 6356|       |  //     or AL.  If it has the R or AL property, it is an RTL label; if it
 6357|       |  //     has the L property, it is an LTR label.
 6358|       |  //
 6359|       |  //  2.  In an RTL label, only characters with the Bidi properties R, AL,
 6360|       |  //      AN, EN, ES, CS, ET, ON, BN, or NSM are allowed.
 6361|       |  //
 6362|       |  //   3.  In an RTL label, the end of the label must be a character with
 6363|       |  //       Bidi property R, AL, EN, or AN, followed by zero or more
 6364|       |  //       characters with Bidi property NSM.
 6365|       |  //
 6366|       |  //   4.  In an RTL label, if an EN is present, no AN may be present, and
 6367|       |  //       vice versa.
 6368|       |  //
 6369|       |  //  5.  In an LTR label, only characters with the Bidi properties L, EN,
 6370|       |  //       ES, CS, ET, ON, BN, or NSM are allowed.
 6371|       |  //
 6372|       |  //   6.  In an LTR label, the end of the label must be a character with
 6373|       |  //       Bidi property L or EN, followed by zero or more characters with
 6374|       |  //       Bidi property NSM.
 6375|       |
 6376|  41.4k|  size_t last_non_nsm_char = find_last_not_of_nsm(label);
 6377|  41.4k|  if (last_non_nsm_char == std::u32string_view::npos) {
  ------------------
  |  Branch (6377:7): [True: 0, False: 41.4k]
  ------------------
 6378|      0|    return false;
 6379|      0|  }
 6380|       |
 6381|       |  // A "Bidi domain name" is a domain name that contains at least one RTL label.
 6382|       |  // The following rule, consisting of six conditions, applies to labels in Bidi
 6383|       |  // domain names.
 6384|  41.4k|  if (is_rtl_label(label)) {
  ------------------
  |  Branch (6384:7): [True: 7.11k, False: 34.3k]
  ------------------
 6385|       |    // The first character must be a character with Bidi property L, R,
 6386|       |    // or AL. If it has the R or AL property, it is an RTL label; if it
 6387|       |    // has the L property, it is an LTR label.
 6388|       |
 6389|  7.11k|    if (find_direction(label[0]) == direction::L) {
  ------------------
  |  Branch (6389:9): [True: 504, False: 6.60k]
  ------------------
 6390|       |      // Eval as LTR
 6391|       |
 6392|       |      // In an LTR label, only characters with the Bidi properties L, EN,
 6393|       |      // ES, CS, ET, ON, BN, or NSM are allowed.
 6394|  10.4k|      for (size_t i = 0; i <= last_non_nsm_char; i++) {
  ------------------
  |  Branch (6394:26): [True: 10.4k, False: 0]
  ------------------
 6395|  10.4k|        const direction d = find_direction(label[i]);
 6396|  10.4k|        if (!(d == direction::L || d == direction::EN || d == direction::ES ||
  ------------------
  |  Branch (6396:15): [True: 2.31k, False: 8.11k]
  |  Branch (6396:36): [True: 1.01k, False: 7.10k]
  |  Branch (6396:58): [True: 1.10k, False: 5.99k]
  ------------------
 6397|  5.99k|              d == direction::CS || d == direction::ET || d == direction::ON ||
  ------------------
  |  Branch (6397:15): [True: 996, False: 5.00k]
  |  Branch (6397:37): [True: 1.11k, False: 3.89k]
  |  Branch (6397:59): [True: 1.12k, False: 2.76k]
  ------------------
 6398|  2.76k|              d == direction::BN || d == direction::NSM)) {
  ------------------
  |  Branch (6398:15): [True: 1.23k, False: 1.53k]
  |  Branch (6398:37): [True: 1.02k, False: 504]
  ------------------
 6399|    504|          return false;
 6400|    504|        }
 6401|  10.4k|      }
 6402|       |
 6403|      0|      const direction last_dir = find_direction(label[last_non_nsm_char]);
 6404|      0|      if (!(last_dir == direction::L || last_dir == direction::EN)) {
  ------------------
  |  Branch (6404:13): [True: 0, False: 0]
  |  Branch (6404:41): [True: 0, False: 0]
  ------------------
 6405|      0|        return false;
 6406|      0|      }
 6407|       |
 6408|      0|      return true;
 6409|       |
 6410|  6.60k|    } else {
 6411|       |      // Eval as RTL
 6412|       |
 6413|       |      // The first character must be R or AL; a leading AN (or any other
 6414|       |      // direction) does not start a valid RTL label.
 6415|  6.60k|      const direction first_dir = find_direction(label[0]);
 6416|  6.60k|      if (first_dir != direction::R && first_dir != direction::AL) {
  ------------------
  |  Branch (6416:11): [True: 5.34k, False: 1.26k]
  |  Branch (6416:40): [True: 51, False: 5.29k]
  ------------------
 6417|     51|        return false;
 6418|     51|      }
 6419|       |
 6420|  6.55k|      bool has_an = false;
 6421|  6.55k|      bool has_en = false;
 6422|  34.2k|      for (size_t i = 0; i <= last_non_nsm_char; i++) {
  ------------------
  |  Branch (6422:26): [True: 28.1k, False: 6.07k]
  ------------------
 6423|  28.1k|        const direction d = find_direction(label[i]);
 6424|       |
 6425|       |        // In an RTL label, if an EN is present, no AN may be present, and vice
 6426|       |        // versa.
 6427|  28.1k|        if ((d == direction::EN && ((has_en = true) && has_an)) ||
  ------------------
  |  Branch (6427:14): [True: 2.01k, False: 26.1k]
  |  Branch (6427:37): [True: 2.01k, False: 0]
  |  Branch (6427:56): [True: 9, False: 2.00k]
  ------------------
 6428|  28.1k|            (d == direction::AN && ((has_an = true) && has_en))) {
  ------------------
  |  Branch (6428:14): [True: 1.45k, False: 26.7k]
  |  Branch (6428:37): [True: 1.45k, False: 0]
  |  Branch (6428:56): [True: 9, False: 1.44k]
  ------------------
 6429|     18|          return false;
 6430|     18|        }
 6431|       |
 6432|  28.1k|        if (!(d == direction::R || d == direction::AL || d == direction::AN ||
  ------------------
  |  Branch (6432:15): [True: 2.22k, False: 25.9k]
  |  Branch (6432:36): [True: 14.2k, False: 11.7k]
  |  Branch (6432:58): [True: 1.44k, False: 10.2k]
  ------------------
 6433|  10.2k|              d == direction::EN || d == direction::ES || d == direction::CS ||
  ------------------
  |  Branch (6433:15): [True: 2.00k, False: 8.29k]
  |  Branch (6433:37): [True: 1.00k, False: 7.29k]
  |  Branch (6433:59): [True: 1.03k, False: 6.25k]
  ------------------
 6434|  6.25k|              d == direction::ET || d == direction::ON || d == direction::BN ||
  ------------------
  |  Branch (6434:15): [True: 1.01k, False: 5.24k]
  |  Branch (6434:37): [True: 1.26k, False: 3.97k]
  |  Branch (6434:59): [True: 2.34k, False: 1.63k]
  ------------------
 6435|  1.63k|              d == direction::NSM)) {
  ------------------
  |  Branch (6435:15): [True: 1.37k, False: 261]
  ------------------
 6436|    261|          return false;
 6437|    261|        }
 6438|       |
 6439|  27.9k|        if (i == last_non_nsm_char &&
  ------------------
  |  Branch (6439:13): [True: 6.27k, False: 21.6k]
  ------------------
 6440|  6.27k|            !(d == direction::R || d == direction::AL || d == direction::AN ||
  ------------------
  |  Branch (6440:15): [True: 741, False: 5.53k]
  |  Branch (6440:36): [True: 4.30k, False: 1.23k]
  |  Branch (6440:58): [True: 495, False: 738]
  ------------------
 6441|    738|              d == direction::EN)) {
  ------------------
  |  Branch (6441:15): [True: 537, False: 201]
  ------------------
 6442|    201|          return false;
 6443|    201|        }
 6444|  27.9k|      }
 6445|       |
 6446|  6.07k|      return true;
 6447|  6.55k|    }
 6448|  7.11k|  }
 6449|       |
 6450|  34.3k|  return true;
 6451|  41.4k|}
_ZN3ada4idna8to_asciiENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEERNS1_12basic_stringIcS4_NS1_9allocatorIcEEEE:
 6610|  19.5k|[[nodiscard]] bool to_ascii(std::string_view ut8_string, std::string& out) {
 6611|  19.5k|  out.clear();
 6612|       |  // The ASCII path is a single same-size copy, so it needs no length bound.
 6613|       |  // Checking first would reject the (longer) ASCII output of a non-ASCII input
 6614|       |  // that was accepted, breaking to_ascii(to_ascii(x)) == to_ascii(x).
 6615|  19.5k|  if (is_ascii(ut8_string)) {
  ------------------
  |  Branch (6615:7): [True: 6.28k, False: 13.2k]
  ------------------
 6616|  6.28k|    from_ascii_to_ascii(ut8_string, out);
 6617|  6.28k|    return true;
 6618|  6.28k|  }
 6619|  13.2k|  if (ut8_string.size() > max_domain_input_bytes) {
  ------------------
  |  Branch (6619:7): [True: 0, False: 13.2k]
  ------------------
 6620|      0|    return false;
 6621|      0|  }
 6622|       |
 6623|       |#ifdef ADA_USE_SIMDUTF
 6624|       |  size_t utf32_length =
 6625|       |      simdutf::utf32_length_from_utf8(ut8_string.data(), ut8_string.size());
 6626|       |  if (utf32_length == 0 && !ut8_string.empty()) {
 6627|       |    return false;
 6628|       |  }
 6629|       |  std::u32string working(utf32_length, U'\0');
 6630|       |  size_t actual_utf32_length = simdutf::convert_utf8_to_utf32(
 6631|       |      ut8_string.data(), ut8_string.size(), working.data());
 6632|       |#else
 6633|  13.2k|  size_t utf32_length =
 6634|  13.2k|      ada::idna::utf32_length_from_utf8(ut8_string.data(), ut8_string.size());
 6635|  13.2k|  if (utf32_length == 0 && !ut8_string.empty()) {
  ------------------
  |  Branch (6635:7): [True: 123, False: 13.1k]
  |  Branch (6635:28): [True: 123, False: 0]
  ------------------
 6636|    123|    return false;
 6637|    123|  }
 6638|  13.1k|  std::u32string working(utf32_length, U'\0');
 6639|  13.1k|  size_t actual_utf32_length = ada::idna::utf8_to_utf32(
 6640|  13.1k|      ut8_string.data(), ut8_string.size(), working.data());
 6641|  13.1k|#endif
 6642|  13.1k|  if (actual_utf32_length == 0 || actual_utf32_length != utf32_length) {
  ------------------
  |  Branch (6642:7): [True: 885, False: 12.2k]
  |  Branch (6642:35): [True: 0, False: 12.2k]
  ------------------
 6643|    885|    return false;
 6644|    885|  }
 6645|  12.2k|  working.resize(actual_utf32_length);
 6646|       |
 6647|       |  // Map into a second buffer with exact sizing (no growth reallocs).
 6648|  12.2k|  std::u32string mapped;
 6649|  12.2k|  if (!ada::idna::map(working, mapped)) {
  ------------------
  |  Branch (6649:7): [True: 120, False: 12.1k]
  ------------------
 6650|    120|    return false;
 6651|    120|  }
 6652|       |  // Drop UTF-32 input; reuse `working` as scratch for ACE validation below.
 6653|  12.1k|  working.clear();
 6654|       |
 6655|       |  // Skip NFC when already normalized (ASCII is a fast subset of this check).
 6656|  12.1k|  if (!is_ascii(mapped) && !is_already_nfc(mapped)) {
  ------------------
  |  Branch (6656:7): [True: 9.12k, False: 2.97k]
  |  Branch (6656:28): [True: 1.62k, False: 7.49k]
  ------------------
 6657|  1.62k|    if (!normalize(mapped)) {
  ------------------
  |  Branch (6657:9): [True: 0, False: 1.62k]
  ------------------
 6658|      0|      return false;
 6659|      0|    }
 6660|  1.62k|  }
 6661|       |
 6662|       |  // Estimate ASCII output size (punycode may expand non-ASCII labels).
 6663|  12.1k|  out.reserve(mapped.size() + 8);
 6664|       |
 6665|       |  // Walk labels with a single pointer scan (no repeated string::find).
 6666|  12.1k|  const char32_t* p = mapped.data();
 6667|  12.1k|  const char32_t* const end = p + mapped.size();
 6668|  12.1k|  std::u32string post_map;
 6669|       |
 6670|  60.9k|  while (p < end) {
  ------------------
  |  Branch (6670:10): [True: 52.3k, False: 8.60k]
  ------------------
 6671|  52.3k|    const char32_t* label_begin = p;
 6672|   454k|    while (p < end && *p != U'.') {
  ------------------
  |  Branch (6672:12): [True: 442k, False: 11.5k]
  |  Branch (6672:23): [True: 401k, False: 40.7k]
  ------------------
 6673|   401k|      ++p;
 6674|   401k|    }
 6675|  52.3k|    const size_t label_size = static_cast<size_t>(p - label_begin);
 6676|  52.3k|    std::u32string_view label_view(label_begin, label_size);
 6677|  52.3k|    const bool is_last_label = (p == end);
 6678|  52.3k|    if (p < end) {
  ------------------
  |  Branch (6678:9): [True: 40.7k, False: 11.5k]
  ------------------
 6679|  40.7k|      ++p;  // skip dot
 6680|  40.7k|    }
 6681|       |
 6682|  52.3k|    if (label_size == 0) {
  ------------------
  |  Branch (6682:9): [True: 3.10k, False: 49.2k]
  ------------------
 6683|       |      // empty label
 6684|  49.2k|    } else if (is_ace_prefix(label_view)) {
  ------------------
  |  Branch (6684:16): [True: 7.70k, False: 41.4k]
  ------------------
 6685|   137k|      for (char32_t c : label_view) {
  ------------------
  |  Branch (6685:23): [True: 137k, False: 7.66k]
  ------------------
 6686|   137k|        if (c >= 0x80) {
  ------------------
  |  Branch (6686:13): [True: 36, False: 137k]
  ------------------
 6687|     36|          out.clear();
 6688|     36|          return false;
 6689|     36|        }
 6690|   137k|      }
 6691|  7.66k|      append_ascii_label(out, label_view);
 6692|  7.66k|      std::string_view puny_segment_ascii(
 6693|  7.66k|          out.data() + (out.size() - label_size) + 4, label_size - 4);
 6694|  7.66k|      working.clear();
 6695|  7.66k|      if (!ada::idna::punycode_to_utf32(puny_segment_ascii, working)) {
  ------------------
  |  Branch (6695:11): [True: 348, False: 7.32k]
  ------------------
 6696|    348|        out.clear();
 6697|    348|        return false;
 6698|    348|      }
 6699|  7.32k|      if (is_ascii(working)) {
  ------------------
  |  Branch (6699:11): [True: 234, False: 7.08k]
  ------------------
 6700|    234|        out.clear();
 6701|    234|        return false;
 6702|    234|      }
 6703|  7.08k|      if (!ada::idna::map(working, post_map) || working != post_map) {
  ------------------
  |  Branch (6703:11): [True: 423, False: 6.66k]
  |  Branch (6703:49): [True: 288, False: 6.37k]
  ------------------
 6704|    711|        out.clear();
 6705|    711|        return false;
 6706|    711|      }
 6707|       |      // Mapping must be stable; NFC must not change the mapped form either.
 6708|  6.37k|      if (!is_ascii(post_map) && !is_already_nfc(post_map)) {
  ------------------
  |  Branch (6708:11): [True: 6.37k, False: 0]
  |  Branch (6708:34): [True: 4.02k, False: 2.34k]
  ------------------
 6709|  4.02k|        if (!normalize(post_map) || post_map != working) {
  ------------------
  |  Branch (6709:13): [True: 0, False: 4.02k]
  |  Branch (6709:37): [True: 354, False: 3.67k]
  ------------------
 6710|    354|          out.clear();
 6711|    354|          return false;
 6712|    354|        }
 6713|  4.02k|      }
 6714|  6.02k|      if (post_map.empty() || !is_label_valid(post_map)) {
  ------------------
  |  Branch (6714:11): [True: 0, False: 6.02k]
  |  Branch (6714:31): [True: 99, False: 5.92k]
  ------------------
 6715|     99|        out.clear();
 6716|     99|        return false;
 6717|     99|      }
 6718|  41.4k|    } else if (is_ascii(label_view)) {
  ------------------
  |  Branch (6718:16): [True: 5.30k, False: 36.1k]
  ------------------
 6719|  5.30k|      append_ascii_label(out, label_view);
 6720|  36.1k|    } else {
 6721|  36.1k|      if (!is_label_valid(label_view)) {
  ------------------
  |  Branch (6721:11): [True: 1.71k, False: 34.4k]
  ------------------
 6722|  1.71k|        out.clear();
 6723|  1.71k|        return false;
 6724|  1.71k|      }
 6725|  34.4k|      out.append("xn--");
 6726|  34.4k|      if (!ada::idna::utf32_to_punycode(label_view, out)) {
  ------------------
  |  Branch (6726:11): [True: 0, False: 34.4k]
  ------------------
 6727|      0|        out.clear();
 6728|      0|        return false;
 6729|      0|      }
 6730|  34.4k|    }
 6731|  48.8k|    if (!is_last_label) {
  ------------------
  |  Branch (6731:9): [True: 40.6k, False: 8.10k]
  ------------------
 6732|  40.6k|      out.push_back('.');
 6733|  40.6k|    }
 6734|  48.8k|  }
 6735|  8.60k|  return true;
 6736|  12.1k|}
_ZN3ada4idna8to_asciiENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 6738|  19.5k|std::string to_ascii(std::string_view ut8_string) {
 6739|  19.5k|  std::string out;
 6740|  19.5k|  if (!to_ascii(ut8_string, out)) {
  ------------------
  |  Branch (6740:7): [True: 4.62k, False: 14.8k]
  ------------------
 6741|  4.62k|    return {};
 6742|  4.62k|  }
 6743|  14.8k|  return out;
 6744|  19.5k|}
_ZN3ada7unicode14percent_encodeILb1EEEbNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEPKhRNS2_12basic_stringIcS5_NS2_9allocatorIcEEEE:
 7617|  27.0k|                    std::string& out) {
 7618|  27.0k|  ada_log("percent_encode ", input, " to output string while ",
 7619|  27.0k|          append ? "appending" : "overwriting");
 7620|  27.0k|  auto pointer = std::ranges::find_if(input, [character_set](const char c) {
 7621|  27.0k|    return character_sets::bit_at(character_set, c);
 7622|  27.0k|  });
 7623|  27.0k|  ada_log("percent_encode done checking, moved to ",
 7624|  27.0k|          std::distance(input.begin(), pointer));
 7625|       |
 7626|       |  // Optimization: Don't iterate if percent encode is not required
 7627|  27.0k|  if (pointer == input.end()) {
  ------------------
  |  Branch (7627:7): [True: 16.5k, False: 10.5k]
  ------------------
 7628|  16.5k|    ada_log("percent_encode encoding not needed.");
 7629|  16.5k|    return false;
 7630|  16.5k|  }
 7631|       |  if constexpr (!append) {
 7632|       |    out.clear();
 7633|       |  }
 7634|  10.5k|  ada_log("percent_encode appending ", std::distance(input.begin(), pointer),
 7635|  10.5k|          " bytes");
 7636|       |  // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
 7637|  10.5k|  out.append(input.data(), std::distance(input.begin(), pointer));
 7638|  10.5k|  ada_log("percent_encode processing ", std::distance(pointer, input.end()),
 7639|  10.5k|          " bytes");
 7640|   119k|  for (; pointer != input.end(); pointer++) {
  ------------------
  |  Branch (7640:10): [True: 109k, False: 10.5k]
  ------------------
 7641|   109k|    if (character_sets::bit_at(character_set, *pointer)) {
  ------------------
  |  Branch (7641:9): [True: 99.6k, False: 9.60k]
  ------------------
 7642|  99.6k|      out.append(character_sets::hex + uint8_t(*pointer) * 4, 3);
 7643|  99.6k|    } else {
 7644|  9.60k|      out += *pointer;
 7645|  9.60k|    }
 7646|   109k|  }
 7647|  10.5k|  return true;
 7648|  27.0k|}
_ZN3ada7unicode14percent_decodeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEm:
 7448|  4.03k|std::string percent_decode(const std::string_view input, size_t first_percent) {
 7449|       |  // next line is for safety only, we expect users to avoid calling
 7450|       |  // percent_decode when first_percent is outside the range.
 7451|  4.03k|  if (first_percent == std::string_view::npos) {
  ------------------
  |  Branch (7451:7): [True: 0, False: 4.03k]
  ------------------
 7452|      0|    return std::string(input);
 7453|      0|  }
 7454|       |
 7455|       |  // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
 7456|  4.03k|  const char* const src = input.data();
 7457|  4.03k|  const char* const end = src + input.size();
 7458|       |
 7459|       |  // Decoding never grows the string, so a single pre-sized buffer written via
 7460|       |  // bulk memcpy of the plain runs (then shrunk to the final length) avoids the
 7461|       |  // byte-at-a-time appends of the naive version.
 7462|  4.03k|  std::string out(input.size(), '\0');
 7463|  4.03k|  char* d = out.data();
 7464|  4.03k|  char* const d0 = d;
 7465|       |
 7466|  4.03k|  std::memcpy(d, src, first_percent);
 7467|  4.03k|  d += first_percent;
 7468|       |
 7469|  4.03k|  const char* p = src + first_percent;
 7470|  21.5k|  while (p < end) {
  ------------------
  |  Branch (7470:10): [True: 17.5k, False: 4.03k]
  ------------------
 7471|  17.5k|    if (*p == '%') {
  ------------------
  |  Branch (7471:9): [True: 11.8k, False: 5.75k]
  ------------------
 7472|       |      // Decode runs of valid %XX tightly (common for nested/encoded URLs).
 7473|  18.0k|      while (p + 2 < end && *p == '%') {
  ------------------
  |  Branch (7473:14): [True: 15.4k, False: 2.55k]
  |  Branch (7473:29): [True: 14.0k, False: 1.46k]
  ------------------
 7474|  14.0k|        if (!is_ascii_hex_digit(p[1]) || !is_ascii_hex_digit(p[2])) {
  ------------------
  |  Branch (7474:13): [True: 5.10k, False: 8.91k]
  |  Branch (7474:42): [True: 2.67k, False: 6.23k]
  ------------------
 7475|  7.78k|          break;
 7476|  7.78k|        }
 7477|  6.23k|        *d++ = static_cast<char>(convert_hex_to_binary(p[1]) * 16 +
 7478|  6.23k|                                 convert_hex_to_binary(p[2]));
 7479|  6.23k|        p += 3;
 7480|  6.23k|      }
 7481|  11.8k|      if (p < end && *p == '%') {
  ------------------
  |  Branch (7481:11): [True: 10.6k, False: 1.14k]
  |  Branch (7481:22): [True: 8.59k, False: 2.05k]
  ------------------
 7482|       |        // Not a valid escape (too few chars left or bad hex): copy '%'
 7483|       |        // literally and keep scanning after it.
 7484|  8.59k|        *d++ = *p++;
 7485|  8.59k|      }
 7486|  11.8k|    } else {
 7487|  5.75k|      const char* q = static_cast<const char*>(
 7488|  5.75k|          std::memchr(p, '%', static_cast<size_t>(end - p)));
 7489|  5.75k|      const char* run_end = q ? q : end;
  ------------------
  |  Branch (7489:29): [True: 3.42k, False: 2.32k]
  ------------------
 7490|  5.75k|      const size_t n = static_cast<size_t>(run_end - p);
 7491|  5.75k|      std::memcpy(d, p, n);
 7492|  5.75k|      d += n;
 7493|  5.75k|      p = run_end;
 7494|  5.75k|    }
 7495|  17.5k|  }
 7496|       |
 7497|  4.03k|  out.resize(static_cast<size_t>(d - d0));
 7498|  4.03k|  return out;
 7499|  4.03k|}
_ZN3ada7unicode14percent_encodeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKh:
 7587|  22.8k|                           const uint8_t character_set[]) {
 7588|  22.8k|  auto pointer = std::ranges::find_if(input, [character_set](const char c) {
 7589|  22.8k|    return character_sets::bit_at(character_set, c);
 7590|  22.8k|  });
 7591|       |  // Optimization: Don't iterate if percent encode is not required
 7592|  22.8k|  if (pointer == input.end()) {
  ------------------
  |  Branch (7592:7): [True: 18.8k, False: 4.01k]
  ------------------
 7593|  18.8k|    return std::string(input);
 7594|  18.8k|  }
 7595|       |
 7596|  4.01k|  std::string result;
 7597|  4.01k|  result.reserve(input.length());  // in the worst case, percent encoding might
 7598|       |                                   // produce 3 characters.
 7599|  4.01k|  result.append(input.substr(0, std::distance(input.begin(), pointer)));
 7600|  4.01k|  if (static_cast<size_t>(input.end() - pointer) >= 48) {
  ------------------
  |  Branch (7600:7): [True: 645, False: 3.37k]
  ------------------
 7601|    645|    percent_encode_suffix(&*pointer, input.data() + input.size(), character_set,
 7602|    645|                          result);
 7603|  3.37k|  } else {
 7604|  28.4k|    for (; pointer != input.end(); pointer++) {
  ------------------
  |  Branch (7604:12): [True: 25.0k, False: 3.37k]
  ------------------
 7605|  25.0k|      if (character_sets::bit_at(character_set, *pointer)) {
  ------------------
  |  Branch (7605:11): [True: 21.6k, False: 3.43k]
  ------------------
 7606|  21.6k|        result.append(character_sets::hex + uint8_t(*pointer) * 4, 3);
 7607|  21.6k|      } else {
 7608|  3.43k|        result += *pointer;
 7609|  3.43k|      }
 7610|  25.0k|    }
 7611|  3.37k|  }
 7612|  4.01k|  return result;
 7613|  22.8k|}
_ZN3ada7unicode8to_asciiERNSt3__18optionalINS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEENS1_17basic_string_viewIcS5_EEm:
 7658|  19.5k|              size_t first_percent) {
 7659|  19.5k|  std::string percent_decoded_buffer;
 7660|  19.5k|  std::string_view input = plain;
 7661|  19.5k|  if (first_percent != std::string_view::npos) {
  ------------------
  |  Branch (7661:7): [True: 1.12k, False: 18.3k]
  ------------------
 7662|  1.12k|    percent_decoded_buffer = unicode::percent_decode(plain, first_percent);
 7663|  1.12k|    input = percent_decoded_buffer;
 7664|  1.12k|  }
 7665|       |  // input is a non-empty UTF-8 string, must be percent decoded
 7666|  19.5k|  std::string idna_ascii = ada::idna::to_ascii(input);
 7667|  19.5k|  if (idna_ascii.empty() || contains_forbidden_domain_code_point(
  ------------------
  |  Branch (7667:7): [True: 4.67k, False: 14.8k]
  |  Branch (7667:29): [True: 1.10k, False: 13.7k]
  ------------------
 7668|  14.8k|                                idna_ascii.data(), idna_ascii.size())) {
 7669|  5.77k|    return false;
 7670|  5.77k|  }
 7671|  13.7k|  out = std::move(idna_ascii);
 7672|  13.7k|  return true;
 7673|  19.5k|}
_ZN3ada7unicode14percent_encodeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKhm:
 7676|    480|                           const uint8_t character_set[], size_t index) {
 7677|    480|  std::string out;
 7678|       |  // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
 7679|    480|  out.append(input.data(), index);
 7680|    480|  auto pointer = input.begin() + index;
 7681|    480|  if (static_cast<size_t>(input.end() - pointer) >= 48) {
  ------------------
  |  Branch (7681:7): [True: 182, False: 298]
  ------------------
 7682|    182|    percent_encode_suffix(&*pointer, input.data() + input.size(), character_set,
 7683|    182|                          out);
 7684|    298|  } else {
 7685|  2.83k|    for (; pointer != input.end(); pointer++) {
  ------------------
  |  Branch (7685:12): [True: 2.54k, False: 298]
  ------------------
 7686|  2.54k|      if (character_sets::bit_at(character_set, *pointer)) {
  ------------------
  |  Branch (7686:11): [True: 2.10k, False: 432]
  ------------------
 7687|  2.10k|        out.append(character_sets::hex + uint8_t(*pointer) * 4, 3);
 7688|  2.10k|      } else {
 7689|    432|        out += *pointer;
 7690|    432|      }
 7691|  2.54k|    }
 7692|    298|  }
 7693|    480|  return out;
 7694|    480|}
_ZN3ada7unicode21percent_encode_suffixEPKcS2_PKhRNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE:
 7992|    827|                           const uint8_t character_set[], std::string& out) {
 7993|    827|#if ADA_UNICODE_SSSE3 || ADA_NEON || ADA_RVV
 7994|    827|#ifdef ADA_UNICODE_NEED_SSSE3_TARGET
 7995|    827|  static const bool ssse3_supported = __builtin_cpu_supports("ssse3") != 0;
 7996|    827|  const bool use_wide = ssse3_supported;
 7997|       |#else
 7998|       |  const bool use_wide = true;
 7999|       |#endif
 8000|    827|  if (use_wide && static_cast<size_t>(end - p) >= kPercentEncodeSimdMin) {
  ------------------
  |  Branch (8000:7): [True: 827, False: 0]
  |  Branch (8000:19): [True: 827, False: 0]
  ------------------
 8001|    827|    percent_encode_to_wide(p, end, character_set, out);
 8002|    827|    return;
 8003|    827|  }
 8004|      0|#endif
 8005|      0|  percent_encode_to_scalar(p, end, character_set, out);
 8006|      0|}
_ZN3ada11serializers36find_longest_sequence_of_ipv6_piecesERKNSt3__15arrayItLm8EEERmS6_:
 8071|    978|    size_t& compress_length) noexcept {
 8072|    978|  compress = 0;
 8073|    978|  compress_length = 0;
 8074|    978|  size_t i = 0;
 8075|  4.20k|  while (i < 8) {
  ------------------
  |  Branch (8075:10): [True: 3.22k, False: 978]
  ------------------
 8076|  3.22k|    if (address[i] != 0) {
  ------------------
  |  Branch (8076:9): [True: 2.01k, False: 1.20k]
  ------------------
 8077|  2.01k|      ++i;
 8078|  2.01k|      continue;
 8079|  2.01k|    }
 8080|  1.20k|    size_t next = i + 1;
 8081|  5.80k|    while (next < 8 && address[next] == 0) {
  ------------------
  |  Branch (8081:12): [True: 5.27k, False: 531]
  |  Branch (8081:24): [True: 4.59k, False: 675]
  ------------------
 8082|  4.59k|      ++next;
 8083|  4.59k|    }
 8084|  1.20k|    const size_t count = next - i;
 8085|  1.20k|    if (count > compress_length) {
  ------------------
  |  Branch (8085:9): [True: 1.01k, False: 195]
  ------------------
 8086|  1.01k|      compress_length = count;
 8087|  1.01k|      compress = i;
 8088|  1.01k|    }
 8089|  1.20k|    i = next;
 8090|  1.20k|  }
 8091|    978|}
_ZN3ada11serializers4ipv6ERKNSt3__15arrayItLm8EEE:
 8093|    978|std::string ipv6(const std::array<uint16_t, 8>& address) {
 8094|    978|  size_t compress = 0;
 8095|    978|  size_t compress_length = 0;
 8096|    978|  find_longest_sequence_of_ipv6_pieces(address, compress, compress_length);
 8097|       |
 8098|       |  // Skip compression when the longest zero run is a single piece.
 8099|    978|  if (compress_length <= 1) {
  ------------------
  |  Branch (8099:7): [True: 117, False: 861]
  ------------------
 8100|    117|    compress = compress_length = 8;
 8101|    117|  }
 8102|       |
 8103|       |  // Max: '[' + 8*4 hex + 7 ':' + ']' = 41
 8104|    978|  char output[4 * 8 + 7 + 2];
 8105|    978|  char* point = output;
 8106|    978|  *point++ = '[';
 8107|    978|  size_t piece_index = 0;
 8108|  2.83k|  while (true) {
  ------------------
  |  Branch (8108:10): [True: 2.83k, Folded]
  ------------------
 8109|  2.83k|    if (piece_index == compress) {
  ------------------
  |  Branch (8109:9): [True: 861, False: 1.97k]
  ------------------
 8110|    861|      *point++ = ':';
 8111|       |      // If we skip a value initially, we need to write '::'.
 8112|    861|      if (piece_index == 0) {
  ------------------
  |  Branch (8112:11): [True: 537, False: 324]
  ------------------
 8113|    537|        *point++ = ':';
 8114|    537|      }
 8115|    861|      piece_index += compress_length;
 8116|    861|      if (piece_index == 8) {
  ------------------
  |  Branch (8116:11): [True: 456, False: 405]
  ------------------
 8117|    456|        break;
 8118|    456|      }
 8119|    861|    }
 8120|  2.37k|    point = write_hex_u16(point, address[piece_index]);
 8121|  2.37k|    ++piece_index;
 8122|  2.37k|    if (piece_index == 8) {
  ------------------
  |  Branch (8122:9): [True: 522, False: 1.85k]
  ------------------
 8123|    522|      break;
 8124|    522|    }
 8125|  1.85k|    *point++ = ':';
 8126|  1.85k|  }
 8127|    978|  *point++ = ']';
 8128|    978|  return std::string(output, static_cast<size_t>(point - output));
 8129|    978|}
_ZN3ada11serializers4ipv4Em:
 8131|  4.30k|std::string ipv4(const uint64_t address) {
 8132|  4.30k|  std::string output(15, '\0');
 8133|  4.30k|  char* point = output.data();
 8134|  4.30k|  point = write_u8(point, static_cast<uint8_t>(address >> 24));
 8135|  4.30k|  *point++ = '.';
 8136|  4.30k|  point = write_u8(point, static_cast<uint8_t>(address >> 16));
 8137|  4.30k|  *point++ = '.';
 8138|  4.30k|  point = write_u8(point, static_cast<uint8_t>(address >> 8));
 8139|  4.30k|  *point++ = '.';
 8140|  4.30k|  point = write_u8(point, static_cast<uint8_t>(address));
 8141|  4.30k|  output.resize(static_cast<size_t>(point - output.data()));
 8142|  4.30k|  return output;
 8143|  4.30k|}
_ZN3ada5parseINS_3urlEEEN2tl8expectedIT_NS_6errorsEEENSt3__117basic_string_viewIcNS7_11char_traitsIcEEEEPKS4_:
 8547|  49.0k|    std::string_view input, const result_type* base_url) {
 8548|  49.0k|  result_type u = ada::parser::parse_url_impl<result_type>(input, base_url);
 8549|  49.0k|  if (!u.is_valid) {
  ------------------
  |  Branch (8549:7): [True: 24.9k, False: 24.0k]
  ------------------
 8550|  24.9k|    return tl::unexpected(errors::type_error);
 8551|  24.9k|  }
 8552|  24.0k|  return u;
 8553|  49.0k|}
_ZN3ada5parseINS_14url_aggregatorEEEN2tl8expectedIT_NS_6errorsEEENSt3__117basic_string_viewIcNS7_11char_traitsIcEEEEPKS4_:
 8547|  49.0k|    std::string_view input, const result_type* base_url) {
 8548|  49.0k|  result_type u = ada::parser::parse_url_impl<result_type>(input, base_url);
 8549|  49.0k|  if (!u.is_valid) {
  ------------------
  |  Branch (8549:7): [True: 24.9k, False: 24.0k]
  ------------------
 8550|  24.9k|    return tl::unexpected(errors::type_error);
 8551|  24.9k|  }
 8552|  24.0k|  return u;
 8553|  49.0k|}
_ZN3ada20get_max_input_lengthEv:
 8168|   159k|uint32_t get_max_input_length() {
 8169|   159k|  return max_input_length_.load(std::memory_order_relaxed);
 8170|   159k|}
_ZN3ada9can_parseENSt3__117basic_string_viewIcNS0_11char_traitsIcEEEEPKS4_:
 8595|  44.6k|bool can_parse(std::string_view input, const std::string_view* base_input) {
 8596|       |  // Must match parse().has_value(), including post-normalization max length.
 8597|       |  // Percent-encoding expands a byte by at most 3x, but IDNA expands more: a
 8598|       |  // 3-byte UTF-8 label such as U+337F becomes the 17-byte "xn--6oqv20b1zgzxr",
 8599|       |  // so a dotted host sustains 4.5x. When the input (plus base, if any) fits in
 8600|       |  // max_length/5, the normalized href cannot exceed max_length, so
 8601|       |  // validation-only parsing (store_values=false) is safe.
 8602|       |
 8603|       |  // Hot path first: absolute special URLs, no base. Avoid loading max_length
 8604|       |  // until we need it (common absolute-fast true/false cases).
 8605|  44.6k|  if (base_input == nullptr) {
  ------------------
  |  Branch (8605:7): [True: 32.4k, False: 12.1k]
  ------------------
 8606|  32.4k|    auto r = try_can_parse_clean_http(input);
 8607|  32.4k|    if (!r.has_value()) {
  ------------------
  |  Branch (8607:9): [True: 32.3k, False: 173]
  ------------------
 8608|  32.3k|      r = try_can_parse_absolute_fast(input);
 8609|  32.3k|    }
 8610|  32.4k|    if (r.has_value()) {
  ------------------
  |  Branch (8610:9): [True: 18.6k, False: 13.8k]
  ------------------
 8611|  18.6k|      if (!*r) {
  ------------------
  |  Branch (8611:11): [True: 13.6k, False: 4.95k]
  ------------------
 8612|  13.6k|        return false;
 8613|  13.6k|      }
 8614|       |      // size <= max/5 => normalized href cannot exceed max (4.5x expansion).
 8615|       |      // Check this first: default max is ~4GB so almost all URLs return true.
 8616|  4.95k|      const uint32_t max_length = ada::get_max_input_length();
 8617|  4.95k|      if (input.size() <= static_cast<size_t>(max_length) / 5) {
  ------------------
  |  Branch (8617:11): [True: 4.95k, False: 0]
  ------------------
 8618|  4.95k|        return true;
 8619|  4.95k|      }
 8620|      0|      if (input.size() > max_length) {
  ------------------
  |  Branch (8620:11): [True: 0, False: 0]
  ------------------
 8621|      0|        return false;
 8622|      0|      }
 8623|      0|      return ada::parser::parse_url_impl<ada::url_aggregator, true>(input,
 8624|      0|                                                                    nullptr)
 8625|      0|          .is_valid;
 8626|      0|    }
 8627|  32.4k|  }
 8628|       |
 8629|  26.0k|  const uint32_t max_length = ada::get_max_input_length();
 8630|  26.0k|  if (input.size() > max_length) {
  ------------------
  |  Branch (8630:7): [True: 0, False: 26.0k]
  ------------------
 8631|      0|    return false;
 8632|      0|  }
 8633|  26.0k|  if (base_input != nullptr && base_input->size() > max_length) {
  ------------------
  |  Branch (8633:7): [True: 12.1k, False: 13.8k]
  |  Branch (8633:32): [True: 0, False: 12.1k]
  ------------------
 8634|      0|    return false;
 8635|      0|  }
 8636|       |
 8637|       |  // Relative resolution combines base + input; bound the sum so 4.5x expansion
 8638|       |  // of either side cannot push the final href past max_length.
 8639|  26.0k|  const size_t combined =
 8640|  26.0k|      input.size() + (base_input == nullptr ? 0 : base_input->size());
  ------------------
  |  Branch (8640:23): [True: 13.8k, False: 12.1k]
  ------------------
 8641|  26.0k|  const bool size_safe = combined <= static_cast<size_t>(max_length) / 5;
 8642|       |
 8643|  26.0k|  if (size_safe) {
  ------------------
  |  Branch (8643:7): [True: 26.0k, False: 0]
  ------------------
 8644|       |    // Validation-only: no buffer build, host still fully checked.
 8645|  26.0k|    ada::url_aggregator base_agg;
 8646|  26.0k|    ada::url_aggregator* base_ptr = nullptr;
 8647|  26.0k|    if (base_input != nullptr) {
  ------------------
  |  Branch (8647:9): [True: 12.1k, False: 13.8k]
  ------------------
 8648|  12.1k|      base_agg = ada::parser::parse_url_impl<ada::url_aggregator, false>(
 8649|  12.1k|          *base_input, nullptr);
 8650|  12.1k|      if (!base_agg.is_valid) {
  ------------------
  |  Branch (8650:11): [True: 7.82k, False: 4.35k]
  ------------------
 8651|  7.82k|        return false;
 8652|  7.82k|      }
 8653|  4.35k|      base_ptr = &base_agg;
 8654|  4.35k|    }
 8655|  18.1k|    return ada::parser::parse_url_impl<ada::url_aggregator, false>(input,
 8656|  18.1k|                                                                   base_ptr)
 8657|  18.1k|        .is_valid;
 8658|  26.0k|  }
 8659|       |
 8660|       |  // Near the limit: full parse so post-normalization length matches parse().
 8661|      0|  if (base_input == nullptr) {
  ------------------
  |  Branch (8661:7): [True: 0, False: 0]
  ------------------
 8662|      0|    return ada::parser::parse_url_impl<ada::url_aggregator, true>(input,
 8663|      0|                                                                  nullptr)
 8664|      0|        .is_valid;
 8665|      0|  }
 8666|      0|  ada::url_aggregator base_agg =
 8667|      0|      ada::parser::parse_url_impl<ada::url_aggregator, true>(*base_input,
 8668|      0|                                                             nullptr);
 8669|      0|  if (!base_agg.is_valid) {
  ------------------
  |  Branch (8669:7): [True: 0, False: 0]
  ------------------
 8670|      0|    return false;
 8671|      0|  }
 8672|      0|  return ada::parser::parse_url_impl<ada::url_aggregator, true>(input,
 8673|      0|                                                                &base_agg)
 8674|      0|      .is_valid;
 8675|      0|}
_ZN3ada7helpers18trim_c0_whitespaceERNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9535|   117k|void trim_c0_whitespace(std::string_view& input) noexcept {
 9536|   120k|  while (!input.empty() &&
  ------------------
  |  Branch (9536:10): [True: 71.8k, False: 48.6k]
  ------------------
 9537|  71.8k|         ada::unicode::is_c0_control_or_space(input.front())) {
  ------------------
  |  Branch (9537:10): [True: 2.64k, False: 69.2k]
  ------------------
 9538|  2.64k|    input.remove_prefix(1);
 9539|  2.64k|  }
 9540|   124k|  while (!input.empty() && ada::unicode::is_c0_control_or_space(input.back())) {
  ------------------
  |  Branch (9540:10): [True: 75.4k, False: 48.6k]
  |  Branch (9540:28): [True: 6.25k, False: 69.2k]
  ------------------
 9541|  6.25k|    input.remove_suffix(1);
 9542|  6.25k|  }
 9543|   117k|}
_ZN3ada7helpers8overlapsENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEERKNS1_12basic_stringIcS4_NS1_9allocatorIcEEEE:
 9707|     40|bool overlaps(std::string_view input1, const std::string& input2) noexcept {
 9708|     40|  ada_log("helpers::overlaps check if string_view '", input1, "' [",
 9709|     40|          input1.size(), " bytes] is part of string '", input2, "' [",
 9710|     40|          input2.size(), " bytes]");
 9711|     40|  return !input1.empty() && !input2.empty() && input1.data() >= input2.data() &&
  ------------------
  |  Branch (9711:10): [True: 40, False: 0]
  |  Branch (9711:29): [True: 40, False: 0]
  |  Branch (9711:48): [True: 11, False: 29]
  ------------------
 9712|     11|         input1.data() < input2.data() + input2.size();
  ------------------
  |  Branch (9712:10): [True: 0, False: 11]
  ------------------
 9713|     40|}
_ZN3ada3url17parse_opaque_hostENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
10092|    598|bool url::parse_opaque_host(std::string_view input) {
10093|    598|  ada_log("parse_opaque_host ", input, " [", input.size(), " bytes]");
10094|    598|  if (std::ranges::any_of(input, ada::unicode::is_forbidden_host_code_point)) {
  ------------------
  |  Branch (10094:7): [True: 13, False: 585]
  ------------------
10095|     13|    return is_valid = false;
10096|     13|  }
10097|       |
10098|       |  // Return the result of running UTF-8 percent-encode on input using the C0
10099|       |  // control percent-encode set.
10100|    585|  host = ada::unicode::percent_encode(
10101|    585|      input, ada::character_sets::C0_CONTROL_PERCENT_ENCODE);
10102|    585|  return true;
10103|    598|}
_ZN3ada3url10parse_ipv4ENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
10105|  1.84k|bool url::parse_ipv4(std::string_view input) {
10106|  1.84k|  ada_log("parse_ipv4 ", input, " [", input.size(), " bytes]");
10107|  1.84k|  if (input.empty()) {
  ------------------
  |  Branch (10107:7): [True: 0, False: 1.84k]
  ------------------
10108|      0|    return is_valid = false;
10109|      0|  }
10110|  1.84k|  std::string_view original_input = input;
10111|  1.84k|  if (original_input.back() == '.') {
  ------------------
  |  Branch (10111:7): [True: 60, False: 1.78k]
  ------------------
10112|     60|    original_input.remove_suffix(1);
10113|     60|  }
10114|  1.84k|  if (input.back() == '.') {
  ------------------
  |  Branch (10114:7): [True: 60, False: 1.78k]
  ------------------
10115|     60|    input.remove_suffix(1);
10116|     60|    if (input.empty()) {
  ------------------
  |  Branch (10116:9): [True: 0, False: 60]
  ------------------
10117|      0|      return is_valid = false;
10118|      0|    }
10119|     60|  }
10120|       |
10121|  1.84k|  const uint64_t fast = checkers::try_parse_ipv4_fast(input);
10122|  1.84k|  if (fast < checkers::ipv4_fast_fail) [[likely]] {
  ------------------
  |  Branch (10122:7): [True: 20, False: 1.82k]
  ------------------
10123|     20|    host = original_input;
10124|     20|    host_type = IPV4;
10125|     20|    return true;
10126|     20|  }
10127|       |
10128|  1.82k|  const char* p = input.data();
10129|  1.82k|  const char* end = p + input.size();
10130|  1.82k|  uint64_t ipv4 = 0;
10131|  1.82k|  int digit_count = 0;
10132|  1.82k|  int pure_decimal_count = 0;
10133|       |
10134|  2.27k|  for (; digit_count < 4 && p < end; ++digit_count) {
  ------------------
  |  Branch (10134:10): [True: 2.26k, False: 9]
  |  Branch (10134:29): [True: 2.26k, False: 0]
  ------------------
10135|  2.26k|    uint64_t segment = 0;
10136|  2.26k|    bool pure = false;
10137|  2.26k|    if (!detail::parse_ipv4_number(p, end, segment, pure)) {
  ------------------
  |  Branch (10137:9): [True: 325, False: 1.93k]
  ------------------
10138|    325|      return is_valid = false;
10139|    325|    }
10140|  1.93k|    if (pure) {
  ------------------
  |  Branch (10140:9): [True: 1.42k, False: 511]
  ------------------
10141|  1.42k|      ++pure_decimal_count;
10142|  1.42k|    }
10143|  1.93k|    if (p >= end) {
  ------------------
  |  Branch (10143:9): [True: 1.46k, False: 478]
  ------------------
10144|  1.46k|      const unsigned shift = static_cast<unsigned>(32 - digit_count * 8);
10145|  1.46k|      if (segment >= (uint64_t{1} << shift)) {
  ------------------
  |  Branch (10145:11): [True: 26, False: 1.43k]
  ------------------
10146|     26|        return is_valid = false;
10147|     26|      }
10148|  1.43k|      ipv4 = (ipv4 << shift) | segment;
10149|  1.43k|      host = (pure_decimal_count == 4) ? std::string(original_input)
  ------------------
  |  Branch (10149:14): [True: 0, False: 1.43k]
  ------------------
10150|  1.43k|                                       : ada::serializers::ipv4(ipv4);
10151|  1.43k|      host_type = IPV4;
10152|  1.43k|      return true;
10153|  1.46k|    }
10154|    478|    if (segment > 255 || *p != '.') {
  ------------------
  |  Branch (10154:9): [True: 29, False: 449]
  |  Branch (10154:26): [True: 0, False: 449]
  ------------------
10155|     29|      return is_valid = false;
10156|     29|    }
10157|    449|    ipv4 = (ipv4 << 8) | segment;
10158|    449|    ++p;
10159|    449|  }
10160|      9|  if (digit_count != 4 || p != end) {
  ------------------
  |  Branch (10160:7): [True: 0, False: 9]
  |  Branch (10160:27): [True: 9, False: 0]
  ------------------
10161|      9|    return is_valid = false;
10162|      9|  }
10163|      0|  host = (pure_decimal_count == 4) ? std::string(original_input)
  ------------------
  |  Branch (10163:10): [True: 0, False: 0]
  ------------------
10164|      0|                                   : ada::serializers::ipv4(ipv4);
10165|      0|  host_type = IPV4;
10166|      0|  return true;
10167|      9|}
_ZN3ada3url10parse_ipv6ENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
10169|    518|bool url::parse_ipv6(std::string_view input) {
10170|    518|  ada_log("parse_ipv6 ", input, " [", input.size(), " bytes]");
10171|    518|  if (input.empty() || input.size() > 45) [[unlikely]] {
  ------------------
  |  Branch (10171:7): [True: 18, False: 500]
  |  Branch (10171:24): [True: 13, False: 487]
  ------------------
10172|     31|    return is_valid = false;
10173|     31|  }
10174|    487|  std::array<uint16_t, 8> address{};
10175|       |#if defined(ADA_AVX512_IPV6)
10176|       |  if (bool simd_valid; detail::try_parse_ipv6_avx512(input.data(), input.size(),
10177|       |                                                     address, simd_valid)) {
10178|       |    if (!simd_valid) [[unlikely]] {
10179|       |      return is_valid = false;
10180|       |    }
10181|       |    host = ada::serializers::ipv6(address);
10182|       |    host_type = IPV6;
10183|       |    return true;
10184|       |  }
10185|       |  address = {};
10186|       |#endif
10187|    487|  const char* pointer = input.data();
10188|    487|  const char* const end = pointer + input.size();
10189|    487|  int piece_index = 0;
10190|    487|  int compress = -1;
10191|       |
10192|    487|  if (*pointer == ':') {
  ------------------
  |  Branch (10192:7): [True: 187, False: 300]
  ------------------
10193|    187|    if (input.size() == 1 || pointer[1] != ':') [[unlikely]] {
  ------------------
  |  Branch (10193:9): [True: 3, False: 184]
  |  Branch (10193:30): [True: 4, False: 180]
  ------------------
10194|      7|      return is_valid = false;
10195|      7|    }
10196|    180|    pointer += 2;
10197|    180|    compress = ++piece_index;
10198|    180|  }
10199|       |
10200|  1.44k|  while (pointer != end) {
  ------------------
  |  Branch (10200:10): [True: 1.11k, False: 333]
  ------------------
10201|  1.11k|    if (piece_index == 8) [[unlikely]] {
  ------------------
  |  Branch (10201:9): [True: 3, False: 1.10k]
  ------------------
10202|      3|      return is_valid = false;
10203|      3|    }
10204|  1.10k|    if (*pointer == ':') {
  ------------------
  |  Branch (10204:9): [True: 139, False: 969]
  ------------------
10205|    139|      if (compress != -1) [[unlikely]] {
  ------------------
  |  Branch (10205:11): [True: 3, False: 136]
  ------------------
10206|      3|        return is_valid = false;
10207|      3|      }
10208|    136|      ++pointer;
10209|    136|      compress = ++piece_index;
10210|    136|      continue;
10211|    139|    }
10212|       |
10213|    969|    uint16_t value = 0;
10214|    969|    const int length = detail::parse_hex_piece(pointer, end, value);
10215|       |
10216|    969|    if (pointer != end && *pointer == '.') {
  ------------------
  |  Branch (10216:9): [True: 784, False: 185]
  |  Branch (10216:27): [True: 91, False: 693]
  ------------------
10217|     91|      if (length == 0) [[unlikely]] {
  ------------------
  |  Branch (10217:11): [True: 4, False: 87]
  ------------------
10218|      4|        return is_valid = false;
10219|      4|      }
10220|     87|      pointer -= length;
10221|     87|      if (piece_index > 6) [[unlikely]] {
  ------------------
  |  Branch (10221:11): [True: 3, False: 84]
  ------------------
10222|      3|        return is_valid = false;
10223|      3|      }
10224|       |
10225|     84|      int numbers_seen = 0;
10226|    249|      while (pointer != end) {
  ------------------
  |  Branch (10226:14): [True: 219, False: 30]
  ------------------
10227|    219|        int ipv4_piece = -1;
10228|    219|        if (numbers_seen > 0) {
  ------------------
  |  Branch (10228:13): [True: 135, False: 84]
  ------------------
10229|    135|          if (*pointer == '.' && numbers_seen < 4) {
  ------------------
  |  Branch (10229:15): [True: 120, False: 15]
  |  Branch (10229:34): [True: 115, False: 5]
  ------------------
10230|    115|            ++pointer;
10231|    115|          } else {
10232|     20|            return is_valid = false;
10233|     20|          }
10234|    135|        }
10235|    199|        if (pointer == end || *pointer < '0' || *pointer > '9') [[unlikely]] {
  ------------------
  |  Branch (10235:13): [True: 17, False: 182]
  |  Branch (10235:31): [True: 3, False: 179]
  |  Branch (10235:49): [True: 5, False: 174]
  ------------------
10236|     25|          return is_valid = false;
10237|     25|        }
10238|    174|        ipv4_piece = *pointer - '0';
10239|    174|        ++pointer;
10240|    174|        if (pointer != end && *pointer >= '0' && *pointer <= '9') {
  ------------------
  |  Branch (10240:13): [True: 156, False: 18]
  |  Branch (10240:31): [True: 62, False: 94]
  |  Branch (10240:50): [True: 58, False: 4]
  ------------------
10241|     58|          if (ipv4_piece == 0) [[unlikely]] {
  ------------------
  |  Branch (10241:15): [True: 4, False: 54]
  ------------------
10242|      4|            return is_valid = false;
10243|      4|          }
10244|     54|          ipv4_piece = ipv4_piece * 10 + (*pointer - '0');
10245|     54|          ++pointer;
10246|     54|          if (pointer != end && *pointer >= '0' && *pointer <= '9') {
  ------------------
  |  Branch (10246:15): [True: 48, False: 6]
  |  Branch (10246:33): [True: 27, False: 21]
  |  Branch (10246:52): [True: 24, False: 3]
  ------------------
10247|     24|            ipv4_piece = ipv4_piece * 10 + (*pointer - '0');
10248|     24|            ++pointer;
10249|     24|            if (ipv4_piece > 255) [[unlikely]] {
  ------------------
  |  Branch (10249:17): [True: 5, False: 19]
  ------------------
10250|      5|              return is_valid = false;
10251|      5|            }
10252|     24|          }
10253|     54|        }
10254|    165|        address[static_cast<size_t>(piece_index)] = static_cast<uint16_t>(
10255|    165|            address[static_cast<size_t>(piece_index)] * 0x100 +
10256|    165|            static_cast<uint16_t>(ipv4_piece));
10257|    165|        ++numbers_seen;
10258|    165|        if (numbers_seen == 2 || numbers_seen == 4) {
  ------------------
  |  Branch (10258:13): [True: 52, False: 113]
  |  Branch (10258:34): [True: 17, False: 96]
  ------------------
10259|     69|          ++piece_index;
10260|     69|        }
10261|    165|      }
10262|     30|      if (numbers_seen != 4) [[unlikely]] {
  ------------------
  |  Branch (10262:11): [True: 18, False: 12]
  ------------------
10263|     18|        return is_valid = false;
10264|     18|      }
10265|     12|      break;
10266|     30|    }
10267|       |
10268|    878|    if (length == 0) [[unlikely]] {
  ------------------
  |  Branch (10268:9): [True: 38, False: 840]
  ------------------
10269|     38|      return is_valid = false;
10270|     38|    }
10271|       |
10272|    840|    if (pointer != end && *pointer == ':') {
  ------------------
  |  Branch (10272:9): [True: 655, False: 185]
  |  Branch (10272:27): [True: 646, False: 9]
  ------------------
10273|    646|      ++pointer;
10274|    646|      if (pointer == end) [[unlikely]] {
  ------------------
  |  Branch (10274:11): [True: 3, False: 643]
  ------------------
10275|      3|        return is_valid = false;
10276|      3|      }
10277|    646|    } else if (pointer != end) [[unlikely]] {
  ------------------
  |  Branch (10277:16): [True: 9, False: 185]
  ------------------
10278|      9|      return is_valid = false;
10279|      9|    }
10280|       |
10281|    828|    address[static_cast<size_t>(piece_index)] = value;
10282|    828|    ++piece_index;
10283|    828|  }
10284|       |
10285|    345|  if (compress != -1) {
  ------------------
  |  Branch (10285:7): [True: 307, False: 38]
  ------------------
10286|    307|    const int right = piece_index - compress;
10287|    307|    if (right > 0) {
  ------------------
  |  Branch (10287:9): [True: 159, False: 148]
  ------------------
10288|    159|      const size_t dest = static_cast<size_t>(8 - right);
10289|    159|      const size_t src = static_cast<size_t>(compress);
10290|    159|      if (dest != src) {
  ------------------
  |  Branch (10290:11): [True: 139, False: 20]
  ------------------
10291|    387|        for (size_t i = static_cast<size_t>(right); i-- > 0;) {
  ------------------
  |  Branch (10291:53): [True: 248, False: 139]
  ------------------
10292|    248|          address[dest + i] = address[src + i];
10293|    248|          address[src + i] = 0;
10294|    248|        }
10295|    139|      }
10296|    159|    }
10297|    307|  } else if (piece_index != 8) [[unlikely]] {
  ------------------
  |  Branch (10297:14): [True: 19, False: 19]
  ------------------
10298|     19|    return is_valid = false;
10299|     19|  }
10300|       |
10301|    326|  host = ada::serializers::ipv6(address);
10302|    326|  ada_log("parse_ipv6 ", *host);
10303|    326|  host_type = IPV6;
10304|    326|  return true;
10305|    345|}
_ZN3ada6parser25try_parse_simple_absoluteINS_3urlEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_:
12262|  44.0k|                                                result_type& out) {
12263|  44.0k|  constexpr bool is_ada_url = std::is_same_v<result_type, ada::url>;
12264|  44.0k|  constexpr bool is_aggregator =
12265|  44.0k|      std::is_same_v<result_type, ada::url_aggregator>;
12266|  44.0k|  static_assert(is_ada_url || is_aggregator);
12267|       |
12268|  44.0k|  const size_t len = input.size();
12269|       |  // Shortest accepted form is "ws://x" (6).
12270|  44.0k|  if (len < 6) [[unlikely]] {
  ------------------
  |  Branch (12270:7): [True: 24.5k, False: 19.4k]
  ------------------
12271|  24.5k|    return false;
12272|  24.5k|  }
12273|  19.4k|  const auto* b = reinterpret_cast<const uint8_t*>(input.data());
12274|       |
12275|  19.4k|  size_t pos = 0;
12276|  19.4k|  ada::scheme::type scheme_type = ada::scheme::type::NOT_SPECIAL;
12277|  19.4k|  uint32_t protocol_end = 0;
12278|  19.4k|#if (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \
12279|  19.4k|    defined(_M_X64) || defined(_M_IX86) || defined(_M_AMD64)
12280|       |  // One 8-byte load + integer compare is a single cmp/jcc on x86-64.
12281|       |  // Masked compares cover the shorter special schemes without extra loads.
12282|  19.4k|  if (len >= 8) {
  ------------------
  |  Branch (12282:7): [True: 16.8k, False: 2.63k]
  ------------------
12283|  16.8k|    uint64_t first8 = 0;
12284|  16.8k|    std::memcpy(&first8, b, 8);
12285|  16.8k|    if (first8 == 0x2f2f3a7370747468ull) {  // "https://"
  ------------------
  |  Branch (12285:9): [True: 8, False: 16.8k]
  ------------------
12286|      8|      pos = 8;
12287|      8|      scheme_type = ada::scheme::type::HTTPS;
12288|      8|      protocol_end = 6;
12289|  16.8k|    } else if ((first8 & 0x00ffffffffffffffull) ==
  ------------------
  |  Branch (12289:16): [True: 369, False: 16.4k]
  ------------------
12290|  16.8k|               0x002f2f3a70747468ull) {  // "http://"
12291|    369|      pos = 7;
12292|    369|      scheme_type = ada::scheme::type::HTTP;
12293|    369|      protocol_end = 5;
12294|  16.4k|    } else if ((first8 & 0x0000ffffffffffffull) ==
  ------------------
  |  Branch (12294:16): [True: 58, False: 16.3k]
  ------------------
12295|  16.4k|               0x00002f2f3a737377ull) {  // "wss://"
12296|     58|      pos = 6;
12297|     58|      scheme_type = ada::scheme::type::WSS;
12298|     58|      protocol_end = 4;
12299|  16.3k|    } else if ((first8 & 0x0000ffffffffffffull) ==
  ------------------
  |  Branch (12299:16): [True: 18, False: 16.3k]
  ------------------
12300|  16.3k|               0x00002f2f3a707466ull) {  // "ftp://"
12301|     18|      pos = 6;
12302|     18|      scheme_type = ada::scheme::type::FTP;
12303|     18|      protocol_end = 4;
12304|  16.3k|    } else if ((first8 & 0x000000ffffffffffull) ==
  ------------------
  |  Branch (12304:16): [True: 7.14k, False: 9.23k]
  ------------------
12305|  16.3k|               0x0000002f2f3a7377ull) {  // "ws://"
12306|  7.14k|      pos = 5;
12307|  7.14k|      scheme_type = ada::scheme::type::WS;
12308|  7.14k|      protocol_end = 3;
12309|  9.23k|    } else {
12310|  9.23k|      return false;
12311|  9.23k|    }
12312|  16.8k|  } else if (b[0] == 'w' && b[1] == 's') {
  ------------------
  |  Branch (12312:14): [True: 1.59k, False: 1.04k]
  |  Branch (12312:29): [True: 1.36k, False: 231]
  ------------------
12313|  1.36k|    if (b[2] == ':' && b[3] == '/' && b[4] == '/') {
  ------------------
  |  Branch (12313:9): [True: 1.27k, False: 92]
  |  Branch (12313:24): [True: 527, False: 746]
  |  Branch (12313:39): [True: 511, False: 16]
  ------------------
12314|    511|      pos = 5;
12315|    511|      scheme_type = ada::scheme::type::WS;
12316|    511|      protocol_end = 3;
12317|    854|    } else if (b[2] == 's' && b[3] == ':' && b[4] == '/' && b[5] == '/') {
  ------------------
  |  Branch (12317:16): [True: 72, False: 782]
  |  Branch (12317:31): [True: 64, False: 8]
  |  Branch (12317:46): [True: 10, False: 54]
  |  Branch (12317:61): [True: 5, False: 5]
  ------------------
12318|      5|      pos = 6;
12319|      5|      scheme_type = ada::scheme::type::WSS;
12320|      5|      protocol_end = 4;
12321|    849|    } else {
12322|    849|      return false;
12323|    849|    }
12324|  1.36k|  } else if (b[0] == 'f' && b[1] == 't' && b[2] == 'p' && b[3] == ':' &&
  ------------------
  |  Branch (12324:14): [True: 100, False: 1.17k]
  |  Branch (12324:29): [True: 37, False: 63]
  |  Branch (12324:44): [True: 28, False: 9]
  |  Branch (12324:59): [True: 22, False: 6]
  ------------------
12325|     22|             b[4] == '/' && b[5] == '/') {
  ------------------
  |  Branch (12325:14): [True: 10, False: 12]
  |  Branch (12325:29): [True: 3, False: 7]
  ------------------
12326|      3|    pos = 6;
12327|      3|    scheme_type = ada::scheme::type::FTP;
12328|      3|    protocol_end = 4;
12329|  1.26k|  } else if (len >= 7 && b[0] == 'h' && b[1] == 't' && b[2] == 't' &&
  ------------------
  |  Branch (12329:14): [True: 663, False: 605]
  |  Branch (12329:26): [True: 92, False: 571]
  |  Branch (12329:41): [True: 74, False: 18]
  |  Branch (12329:56): [True: 59, False: 15]
  ------------------
12330|     59|             b[3] == 'p' && b[4] == ':' && b[5] == '/' && b[6] == '/') {
  ------------------
  |  Branch (12330:14): [True: 43, False: 16]
  |  Branch (12330:29): [True: 29, False: 14]
  |  Branch (12330:44): [True: 9, False: 20]
  |  Branch (12330:59): [True: 3, False: 6]
  ------------------
12331|      3|    pos = 7;
12332|      3|    scheme_type = ada::scheme::type::HTTP;
12333|      3|    protocol_end = 5;
12334|  1.26k|  } else {
12335|  1.26k|    return false;
12336|  1.26k|  }
12337|       |#else
12338|       |  // Big-endian / uncommon arches: byte-wise special-scheme match.
12339|       |  if (len >= 8 && b[0] == 'h' && b[1] == 't' && b[2] == 't' && b[3] == 'p' &&
12340|       |      b[4] == 's' && b[5] == ':' && b[6] == '/' && b[7] == '/') {
12341|       |    pos = 8;
12342|       |    scheme_type = ada::scheme::type::HTTPS;
12343|       |    protocol_end = 6;
12344|       |  } else if (len >= 7 && b[0] == 'h' && b[1] == 't' && b[2] == 't' &&
12345|       |             b[3] == 'p' && b[4] == ':' && b[5] == '/' && b[6] == '/') {
12346|       |    pos = 7;
12347|       |    scheme_type = ada::scheme::type::HTTP;
12348|       |    protocol_end = 5;
12349|       |  } else if (b[0] == 'w' && b[1] == 's') {
12350|       |    if (b[2] == ':' && b[3] == '/' && b[4] == '/') {
12351|       |      pos = 5;
12352|       |      scheme_type = ada::scheme::type::WS;
12353|       |      protocol_end = 3;
12354|       |    } else if (len >= 6 && b[2] == 's' && b[3] == ':' && b[4] == '/' &&
12355|       |               b[5] == '/') {
12356|       |      pos = 6;
12357|       |      scheme_type = ada::scheme::type::WSS;
12358|       |      protocol_end = 4;
12359|       |    } else {
12360|       |      return false;
12361|       |    }
12362|       |  } else if (b[0] == 'f' && b[1] == 't' && b[2] == 'p' && b[3] == ':' &&
12363|       |             b[4] == '/' && b[5] == '/') {
12364|       |    pos = 6;
12365|       |    scheme_type = ada::scheme::type::FTP;
12366|       |    protocol_end = 4;
12367|       |  } else {
12368|       |    return false;
12369|       |  }
12370|       |#endif
12371|  8.11k|  if (pos < len && (b[pos] == '/' || b[pos] == '\\')) [[unlikely]] {
  ------------------
  |  Branch (12371:7): [True: 8.10k, False: 10]
  |  Branch (12371:21): [True: 8, False: 8.09k]
  |  Branch (12371:38): [True: 9, False: 8.08k]
  ------------------
12372|     17|    return false;
12373|     17|  }
12374|       |
12375|       |  // Digit-led hosts are IPv4/numeric; '[' is IPv6. Skip before scanning.
12376|  8.09k|  if (pos < len && ((b[pos] >= '0' && b[pos] <= '9') || b[pos] == '[')) {
  ------------------
  |  Branch (12376:7): [True: 8.08k, False: 10]
  |  Branch (12376:22): [True: 6.35k, False: 1.73k]
  |  Branch (12376:39): [True: 1.05k, False: 5.29k]
  |  Branch (12376:57): [True: 99, False: 6.93k]
  ------------------
12377|  1.15k|    return false;
12378|  1.15k|  }
12379|       |
12380|  6.94k|  const size_t host_start = pos;
12381|  6.94k|  bool has_upper = false;
12382|  6.94k|  bool has_x = false;
12383|  6.94k|  size_t host_end = pos;
12384|  6.94k|  if (!scan_plain_host(b, pos, len, host_end, has_upper, has_x)) {
  ------------------
  |  Branch (12384:7): [True: 245, False: 6.69k]
  ------------------
12385|    245|    return false;
12386|    245|  }
12387|  6.69k|  if (host_start == host_end) [[unlikely]] {
  ------------------
  |  Branch (12387:7): [True: 48, False: 6.65k]
  ------------------
12388|     48|    return false;
12389|     48|  }
12390|  6.65k|  const size_t host_len = host_end - host_start;
12391|  6.65k|  if (host_len > 253) [[unlikely]] {
  ------------------
  |  Branch (12391:7): [True: 88, False: 6.56k]
  ------------------
12392|     88|    return false;
12393|     88|  }
12394|  6.56k|  {
12395|  6.56k|    std::string_view hv(input.data() + host_start, host_len);
12396|  6.56k|    char host_buf[256];
12397|  6.56k|    if (has_upper) [[unlikely]] {
  ------------------
  |  Branch (12397:9): [True: 563, False: 5.99k]
  ------------------
12398|    563|      std::memcpy(host_buf, input.data() + host_start, host_len);
12399|    563|      unicode::to_lower_ascii(host_buf, host_len);
12400|    563|      hv = std::string_view(host_buf, host_len);
12401|    563|    }
12402|  6.56k|    if (ada::checkers::last_label_may_be_a_number(hv)) [[unlikely]] {
  ------------------
  |  Branch (12402:9): [True: 85, False: 6.47k]
  ------------------
12403|     85|      return false;
12404|     85|    }
12405|       |    // Punycode is "xn--...". The host scan already notes a lowercase 'x';
12406|       |    // uppercase 'X' is covered by has_upper after the in-place lower.
12407|  6.47k|    static constexpr std::string_view xn{"xn-", 3};
12408|  6.47k|    if ((has_x || has_upper) && hv.find(xn) != std::string_view::npos)
  ------------------
  |  Branch (12408:10): [True: 1.85k, False: 4.61k]
  |  Branch (12408:19): [True: 508, False: 4.11k]
  |  Branch (12408:33): [True: 1.32k, False: 1.04k]
  ------------------
12409|  1.32k|        [[unlikely]] {
12410|  1.32k|      return false;
12411|  1.32k|    }
12412|  6.47k|  }
12413|       |
12414|  5.15k|  if (host_end < len && b[host_end] == ':') [[unlikely]] {
  ------------------
  |  Branch (12414:7): [True: 4.99k, False: 159]
  |  Branch (12414:25): [True: 1.88k, False: 3.11k]
  ------------------
12415|  1.88k|    return finish_simple_absolute_with_port(input, out, scheme_type,
12416|  1.88k|                                            protocol_end, host_start, host_end,
12417|  1.88k|                                            host_len, has_upper);
12418|  1.88k|  }
12419|       |
12420|  3.27k|  size_t i = host_end;
12421|  3.27k|  size_t path_start = host_end;
12422|  3.27k|  size_t path_end = host_end;
12423|  3.27k|  size_t query_start = std::string_view::npos;
12424|  3.27k|  size_t hash_start = std::string_view::npos;
12425|  3.27k|  bool has_path = false;
12426|  3.27k|  bool maybe_dot_segment = false;
12427|  3.27k|  bool rest_simple = true;
12428|       |
12429|  3.27k|  if (i < len && b[i] == '/') {
  ------------------
  |  Branch (12429:7): [True: 3.11k, False: 159]
  |  Branch (12429:18): [True: 2.97k, False: 140]
  ------------------
12430|  2.97k|    has_path = true;
12431|  2.97k|    path_start = i;
12432|  2.97k|    ++i;
12433|  2.97k|    scan_path_run(b, i, len, maybe_dot_segment);
12434|  2.97k|    if (i < len) {
  ------------------
  |  Branch (12434:9): [True: 1.29k, False: 1.67k]
  ------------------
12435|  1.29k|      const uint8_t cls = k_path[b[i]];
12436|  1.29k|      if (cls == 1) {
  ------------------
  |  Branch (12436:11): [True: 369, False: 928]
  ------------------
12437|    369|        path_end = i;
12438|    369|        if (b[i] == '?') {
  ------------------
  |  Branch (12438:13): [True: 222, False: 147]
  ------------------
12439|    222|          query_start = i;
12440|    222|          ++i;
12441|    222|          goto scan_query;
12442|    222|        }
12443|    147|        hash_start = i;
12444|    147|        ++i;
12445|    147|        goto scan_hash;
12446|    369|      }
12447|    928|      rest_simple = false;
12448|    928|      hash_start = input.find('#', i);
12449|    928|      query_start = input.substr(0, hash_start).find('?', i);
12450|    928|      if (query_start != std::string_view::npos) {
  ------------------
  |  Branch (12450:11): [True: 56, False: 872]
  ------------------
12451|     56|        path_end = query_start;
12452|    872|      } else {
12453|    872|        path_end = hash_start != std::string_view::npos ? hash_start : len;
  ------------------
  |  Branch (12453:20): [True: 29, False: 843]
  ------------------
12454|    872|      }
12455|    928|      goto after_rest;
12456|  1.29k|    }
12457|  1.67k|    path_end = i;
12458|  1.67k|  } else if (i < len && b[i] == '?') {
  ------------------
  |  Branch (12458:14): [True: 140, False: 159]
  |  Branch (12458:25): [True: 69, False: 71]
  ------------------
12459|     69|    query_start = i;
12460|     69|    ++i;
12461|     69|    goto scan_query;
12462|    230|  } else if (i < len && b[i] == '#') {
  ------------------
  |  Branch (12462:14): [True: 71, False: 159]
  |  Branch (12462:25): [True: 71, False: 0]
  ------------------
12463|     71|    hash_start = i;
12464|     71|    ++i;
12465|     71|    goto scan_hash;
12466|     71|  }
12467|  1.83k|  goto after_rest;
12468|       |
12469|  1.83k|scan_query:
12470|    291|  scan_query_run(b, i, len);
12471|    291|  if (i < len) {
  ------------------
  |  Branch (12471:7): [True: 148, False: 143]
  ------------------
12472|    148|    if (b[i] == '#') {
  ------------------
  |  Branch (12472:9): [True: 102, False: 46]
  ------------------
12473|    102|      hash_start = i;
12474|    102|      ++i;
12475|    102|      goto scan_hash;
12476|    102|    }
12477|     46|    rest_simple = false;
12478|     46|    goto scan_query_boundary;
12479|    148|  }
12480|    143|  goto after_rest;
12481|       |
12482|    143|scan_query_boundary:
12483|     46|  hash_start = input.find('#', i);
12484|     46|  goto after_rest;
12485|       |
12486|    320|scan_hash:
12487|    320|  scan_hash_run(b, i, len);
12488|    320|  if (i < len) {
  ------------------
  |  Branch (12488:7): [True: 60, False: 260]
  ------------------
12489|     60|    rest_simple = false;
12490|     60|  }
12491|       |
12492|  3.27k|after_rest:
12493|  3.27k|  if (rest_simple && maybe_dot_segment) {
  ------------------
  |  Branch (12493:7): [True: 2.23k, False: 1.03k]
  |  Branch (12493:22): [True: 358, False: 1.88k]
  ------------------
12494|    358|    const std::string_view path_body(input.data() + path_start,
12495|    358|                                     path_end - path_start);
12496|    358|    if (path_has_dot_segment(path_body)) {
  ------------------
  |  Branch (12496:9): [True: 152, False: 206]
  ------------------
12497|    152|      rest_simple = false;
12498|    152|    }
12499|    358|  }
12500|       |
12501|       |  // The slow path removes ASCII tab/newline anywhere in the input and trims a
12502|       |  // trailing C0 control or space; this fast path does neither. A query or
12503|       |  // fragment reaching the helpers below would keep those bytes percent-encoded
12504|       |  // ("?a\nb" -> "?a%0Ab", "#f " -> "#f%20") instead of stripped, so hand such
12505|       |  // inputs back to the slow path.
12506|  3.27k|  if (!rest_simple && (unicode::is_c0_control_or_space(input.back()) ||
  ------------------
  |  Branch (12506:7): [True: 1.18k, False: 2.08k]
  |  Branch (12506:24): [True: 24, False: 1.16k]
  ------------------
12507|  1.16k|                       unicode::has_tabs_or_newline(input))) {
  ------------------
  |  Branch (12507:24): [True: 18, False: 1.14k]
  ------------------
12508|     42|    return false;
12509|     42|  }
12510|       |
12511|  3.23k|  out.type = scheme_type;
12512|  3.23k|  out.is_valid = true;
12513|  3.23k|  out.has_opaque_path = false;
12514|  3.23k|  out.host_type = DEFAULT;
12515|       |
12516|  3.23k|  if (!rest_simple) {
  ------------------
  |  Branch (12516:7): [True: 1.14k, False: 2.08k]
  ------------------
12517|       |    // Host is a plain domain. Finish path/query/hash with
12518|       |    // the regular helpers
12519|       |    // so percent-encoding and dot segments do not re-parse the authority.
12520|  1.14k|    const std::string_view path_view =
12521|  1.14k|        has_path
  ------------------
  |  Branch (12521:9): [True: 1.07k, False: 67]
  ------------------
12522|  1.14k|            ? std::string_view(input.data() + path_start, path_end - path_start)
12523|  1.14k|            : std::string_view{};
12524|  1.14k|    auto apply_query_and_hash = [&]() {
12525|  1.14k|      if (query_start != std::string_view::npos) {
12526|  1.14k|        const size_t q_end =
12527|  1.14k|            (hash_start != std::string_view::npos) ? hash_start : len;
12528|  1.14k|        out.update_base_search(std::string_view(input.data() + query_start + 1,
12529|  1.14k|                                                q_end - query_start - 1),
12530|  1.14k|                               character_sets::SPECIAL_QUERY_PERCENT_ENCODE);
12531|  1.14k|      }
12532|  1.14k|      if (hash_start != std::string_view::npos) {
12533|  1.14k|        out.update_unencoded_base_hash(std::string_view(
12534|  1.14k|            input.data() + hash_start + 1, len - hash_start - 1));
12535|  1.14k|      }
12536|  1.14k|    };
12537|       |    if constexpr (is_aggregator) {
12538|       |      out.buffer.assign(input.substr(0, host_end));
12539|       |      if (has_upper) {
12540|       |        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12541|       |      }
12542|       |      out.components.protocol_end = protocol_end;
12543|       |      out.components.username_end = protocol_end + 2;
12544|       |      out.components.host_start = protocol_end + 2;
12545|       |      out.components.host_end = static_cast<uint32_t>(host_end);
12546|       |      out.components.port = url_components::omitted;
12547|       |      out.components.pathname_start = static_cast<uint32_t>(host_end);
12548|       |      out.components.search_start = url_components::omitted;
12549|       |      out.components.hash_start = url_components::omitted;
12550|       |      out.parse_path(path_view);
12551|       |      apply_query_and_hash();
12552|  1.14k|    } else {
12553|  1.14k|      std::string host_str(input.substr(host_start, host_len));
12554|  1.14k|      if (has_upper) {
  ------------------
  |  Branch (12554:11): [True: 152, False: 992]
  ------------------
12555|    152|        unicode::to_lower_ascii(host_str.data(), host_str.size());
12556|    152|      }
12557|  1.14k|      out.host = std::move(host_str);
12558|  1.14k|      out.parse_path(path_view);
12559|  1.14k|      apply_query_and_hash();
12560|  1.14k|    }
12561|  1.14k|    return true;
12562|  1.14k|  }
12563|       |
12564|  2.08k|  const bool need_slash = !has_path;
12565|       |  if constexpr (is_aggregator) {
12566|       |    if (!need_slash) {
12567|       |      // assign copies once. resize()+memcpy would value-init then overwrite.
12568|       |      out.buffer.assign(input);
12569|       |      if (has_upper) {
12570|       |        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12571|       |      }
12572|       |      out.components.protocol_end = protocol_end;
12573|       |      out.components.username_end = protocol_end + 2;
12574|       |      out.components.host_start = protocol_end + 2;
12575|       |      out.components.host_end = static_cast<uint32_t>(host_end);
12576|       |      out.components.port = url_components::omitted;
12577|       |      out.components.pathname_start = static_cast<uint32_t>(path_start);
12578|       |      out.components.search_start = (query_start != std::string_view::npos)
12579|       |                                        ? static_cast<uint32_t>(query_start)
12580|       |                                        : url_components::omitted;
12581|       |      out.components.hash_start = (hash_start != std::string_view::npos)
12582|       |                                      ? static_cast<uint32_t>(hash_start)
12583|       |                                      : url_components::omitted;
12584|       |    } else {
12585|       |      out.buffer.clear();
12586|       |      out.buffer.reserve(len + 1);
12587|       |      out.buffer.append(input.substr(0, host_end));
12588|       |      out.buffer.push_back('/');
12589|       |      if (host_end < len) {
12590|       |        out.buffer.append(input.substr(host_end));
12591|       |      }
12592|       |      if (has_upper) {
12593|       |        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12594|       |      }
12595|       |      out.components.protocol_end = protocol_end;
12596|       |      out.components.username_end = protocol_end + 2;
12597|       |      out.components.host_start = protocol_end + 2;
12598|       |      out.components.host_end = static_cast<uint32_t>(host_end);
12599|       |      out.components.port = url_components::omitted;
12600|       |      out.components.pathname_start = static_cast<uint32_t>(host_end);
12601|       |      out.components.search_start = (query_start != std::string_view::npos)
12602|       |                                        ? static_cast<uint32_t>(query_start + 1)
12603|       |                                        : url_components::omitted;
12604|       |      out.components.hash_start = (hash_start != std::string_view::npos)
12605|       |                                      ? static_cast<uint32_t>(hash_start + 1)
12606|       |                                      : url_components::omitted;
12607|       |    }
12608|  2.08k|  } else {
12609|  2.08k|    std::string host_str(input.substr(host_start, host_len));
12610|  2.08k|    if (has_upper) {
  ------------------
  |  Branch (12610:9): [True: 127, False: 1.96k]
  ------------------
12611|    127|      unicode::to_lower_ascii(host_str.data(), host_str.size());
12612|    127|    }
12613|  2.08k|    out.host = std::move(host_str);
12614|  2.08k|    if (need_slash) {
  ------------------
  |  Branch (12614:9): [True: 215, False: 1.87k]
  ------------------
12615|    215|      out.path = "/";
12616|  1.87k|    } else {
12617|  1.87k|      out.path.assign(input.data() + path_start, path_end - path_start);
12618|  1.87k|    }
12619|  2.08k|    if (query_start != std::string_view::npos) {
  ------------------
  |  Branch (12619:9): [True: 239, False: 1.84k]
  ------------------
12620|    239|      const size_t q_end =
12621|    239|          (hash_start != std::string_view::npos) ? hash_start : len;
  ------------------
  |  Branch (12621:11): [True: 97, False: 142]
  ------------------
12622|    239|      out.query.emplace(input.data() + query_start + 1,
12623|    239|                        q_end - query_start - 1);
12624|    239|    }
12625|  2.08k|    if (hash_start != std::string_view::npos) {
  ------------------
  |  Branch (12625:9): [True: 260, False: 1.82k]
  ------------------
12626|    260|      out.hash.emplace(input.data() + hash_start + 1, len - hash_start - 1);
12627|    260|    }
12628|  2.08k|  }
12629|  2.08k|  return true;
12630|  3.23k|}
_ZN3ada6parser25try_parse_simple_absoluteINS_14url_aggregatorEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_:
12262|  44.0k|                                                result_type& out) {
12263|  44.0k|  constexpr bool is_ada_url = std::is_same_v<result_type, ada::url>;
12264|  44.0k|  constexpr bool is_aggregator =
12265|  44.0k|      std::is_same_v<result_type, ada::url_aggregator>;
12266|  44.0k|  static_assert(is_ada_url || is_aggregator);
12267|       |
12268|  44.0k|  const size_t len = input.size();
12269|       |  // Shortest accepted form is "ws://x" (6).
12270|  44.0k|  if (len < 6) [[unlikely]] {
  ------------------
  |  Branch (12270:7): [True: 24.5k, False: 19.4k]
  ------------------
12271|  24.5k|    return false;
12272|  24.5k|  }
12273|  19.4k|  const auto* b = reinterpret_cast<const uint8_t*>(input.data());
12274|       |
12275|  19.4k|  size_t pos = 0;
12276|  19.4k|  ada::scheme::type scheme_type = ada::scheme::type::NOT_SPECIAL;
12277|  19.4k|  uint32_t protocol_end = 0;
12278|  19.4k|#if (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \
12279|  19.4k|    defined(_M_X64) || defined(_M_IX86) || defined(_M_AMD64)
12280|       |  // One 8-byte load + integer compare is a single cmp/jcc on x86-64.
12281|       |  // Masked compares cover the shorter special schemes without extra loads.
12282|  19.4k|  if (len >= 8) {
  ------------------
  |  Branch (12282:7): [True: 16.8k, False: 2.63k]
  ------------------
12283|  16.8k|    uint64_t first8 = 0;
12284|  16.8k|    std::memcpy(&first8, b, 8);
12285|  16.8k|    if (first8 == 0x2f2f3a7370747468ull) {  // "https://"
  ------------------
  |  Branch (12285:9): [True: 8, False: 16.8k]
  ------------------
12286|      8|      pos = 8;
12287|      8|      scheme_type = ada::scheme::type::HTTPS;
12288|      8|      protocol_end = 6;
12289|  16.8k|    } else if ((first8 & 0x00ffffffffffffffull) ==
  ------------------
  |  Branch (12289:16): [True: 369, False: 16.4k]
  ------------------
12290|  16.8k|               0x002f2f3a70747468ull) {  // "http://"
12291|    369|      pos = 7;
12292|    369|      scheme_type = ada::scheme::type::HTTP;
12293|    369|      protocol_end = 5;
12294|  16.4k|    } else if ((first8 & 0x0000ffffffffffffull) ==
  ------------------
  |  Branch (12294:16): [True: 58, False: 16.3k]
  ------------------
12295|  16.4k|               0x00002f2f3a737377ull) {  // "wss://"
12296|     58|      pos = 6;
12297|     58|      scheme_type = ada::scheme::type::WSS;
12298|     58|      protocol_end = 4;
12299|  16.3k|    } else if ((first8 & 0x0000ffffffffffffull) ==
  ------------------
  |  Branch (12299:16): [True: 18, False: 16.3k]
  ------------------
12300|  16.3k|               0x00002f2f3a707466ull) {  // "ftp://"
12301|     18|      pos = 6;
12302|     18|      scheme_type = ada::scheme::type::FTP;
12303|     18|      protocol_end = 4;
12304|  16.3k|    } else if ((first8 & 0x000000ffffffffffull) ==
  ------------------
  |  Branch (12304:16): [True: 7.14k, False: 9.23k]
  ------------------
12305|  16.3k|               0x0000002f2f3a7377ull) {  // "ws://"
12306|  7.14k|      pos = 5;
12307|  7.14k|      scheme_type = ada::scheme::type::WS;
12308|  7.14k|      protocol_end = 3;
12309|  9.23k|    } else {
12310|  9.23k|      return false;
12311|  9.23k|    }
12312|  16.8k|  } else if (b[0] == 'w' && b[1] == 's') {
  ------------------
  |  Branch (12312:14): [True: 1.59k, False: 1.04k]
  |  Branch (12312:29): [True: 1.36k, False: 231]
  ------------------
12313|  1.36k|    if (b[2] == ':' && b[3] == '/' && b[4] == '/') {
  ------------------
  |  Branch (12313:9): [True: 1.27k, False: 92]
  |  Branch (12313:24): [True: 527, False: 746]
  |  Branch (12313:39): [True: 511, False: 16]
  ------------------
12314|    511|      pos = 5;
12315|    511|      scheme_type = ada::scheme::type::WS;
12316|    511|      protocol_end = 3;
12317|    854|    } else if (b[2] == 's' && b[3] == ':' && b[4] == '/' && b[5] == '/') {
  ------------------
  |  Branch (12317:16): [True: 72, False: 782]
  |  Branch (12317:31): [True: 64, False: 8]
  |  Branch (12317:46): [True: 10, False: 54]
  |  Branch (12317:61): [True: 5, False: 5]
  ------------------
12318|      5|      pos = 6;
12319|      5|      scheme_type = ada::scheme::type::WSS;
12320|      5|      protocol_end = 4;
12321|    849|    } else {
12322|    849|      return false;
12323|    849|    }
12324|  1.36k|  } else if (b[0] == 'f' && b[1] == 't' && b[2] == 'p' && b[3] == ':' &&
  ------------------
  |  Branch (12324:14): [True: 100, False: 1.17k]
  |  Branch (12324:29): [True: 37, False: 63]
  |  Branch (12324:44): [True: 28, False: 9]
  |  Branch (12324:59): [True: 22, False: 6]
  ------------------
12325|     22|             b[4] == '/' && b[5] == '/') {
  ------------------
  |  Branch (12325:14): [True: 10, False: 12]
  |  Branch (12325:29): [True: 3, False: 7]
  ------------------
12326|      3|    pos = 6;
12327|      3|    scheme_type = ada::scheme::type::FTP;
12328|      3|    protocol_end = 4;
12329|  1.26k|  } else if (len >= 7 && b[0] == 'h' && b[1] == 't' && b[2] == 't' &&
  ------------------
  |  Branch (12329:14): [True: 663, False: 605]
  |  Branch (12329:26): [True: 92, False: 571]
  |  Branch (12329:41): [True: 74, False: 18]
  |  Branch (12329:56): [True: 59, False: 15]
  ------------------
12330|     59|             b[3] == 'p' && b[4] == ':' && b[5] == '/' && b[6] == '/') {
  ------------------
  |  Branch (12330:14): [True: 43, False: 16]
  |  Branch (12330:29): [True: 29, False: 14]
  |  Branch (12330:44): [True: 9, False: 20]
  |  Branch (12330:59): [True: 3, False: 6]
  ------------------
12331|      3|    pos = 7;
12332|      3|    scheme_type = ada::scheme::type::HTTP;
12333|      3|    protocol_end = 5;
12334|  1.26k|  } else {
12335|  1.26k|    return false;
12336|  1.26k|  }
12337|       |#else
12338|       |  // Big-endian / uncommon arches: byte-wise special-scheme match.
12339|       |  if (len >= 8 && b[0] == 'h' && b[1] == 't' && b[2] == 't' && b[3] == 'p' &&
12340|       |      b[4] == 's' && b[5] == ':' && b[6] == '/' && b[7] == '/') {
12341|       |    pos = 8;
12342|       |    scheme_type = ada::scheme::type::HTTPS;
12343|       |    protocol_end = 6;
12344|       |  } else if (len >= 7 && b[0] == 'h' && b[1] == 't' && b[2] == 't' &&
12345|       |             b[3] == 'p' && b[4] == ':' && b[5] == '/' && b[6] == '/') {
12346|       |    pos = 7;
12347|       |    scheme_type = ada::scheme::type::HTTP;
12348|       |    protocol_end = 5;
12349|       |  } else if (b[0] == 'w' && b[1] == 's') {
12350|       |    if (b[2] == ':' && b[3] == '/' && b[4] == '/') {
12351|       |      pos = 5;
12352|       |      scheme_type = ada::scheme::type::WS;
12353|       |      protocol_end = 3;
12354|       |    } else if (len >= 6 && b[2] == 's' && b[3] == ':' && b[4] == '/' &&
12355|       |               b[5] == '/') {
12356|       |      pos = 6;
12357|       |      scheme_type = ada::scheme::type::WSS;
12358|       |      protocol_end = 4;
12359|       |    } else {
12360|       |      return false;
12361|       |    }
12362|       |  } else if (b[0] == 'f' && b[1] == 't' && b[2] == 'p' && b[3] == ':' &&
12363|       |             b[4] == '/' && b[5] == '/') {
12364|       |    pos = 6;
12365|       |    scheme_type = ada::scheme::type::FTP;
12366|       |    protocol_end = 4;
12367|       |  } else {
12368|       |    return false;
12369|       |  }
12370|       |#endif
12371|  8.11k|  if (pos < len && (b[pos] == '/' || b[pos] == '\\')) [[unlikely]] {
  ------------------
  |  Branch (12371:7): [True: 8.10k, False: 10]
  |  Branch (12371:21): [True: 8, False: 8.09k]
  |  Branch (12371:38): [True: 9, False: 8.08k]
  ------------------
12372|     17|    return false;
12373|     17|  }
12374|       |
12375|       |  // Digit-led hosts are IPv4/numeric; '[' is IPv6. Skip before scanning.
12376|  8.09k|  if (pos < len && ((b[pos] >= '0' && b[pos] <= '9') || b[pos] == '[')) {
  ------------------
  |  Branch (12376:7): [True: 8.08k, False: 10]
  |  Branch (12376:22): [True: 6.35k, False: 1.73k]
  |  Branch (12376:39): [True: 1.05k, False: 5.29k]
  |  Branch (12376:57): [True: 99, False: 6.93k]
  ------------------
12377|  1.15k|    return false;
12378|  1.15k|  }
12379|       |
12380|  6.94k|  const size_t host_start = pos;
12381|  6.94k|  bool has_upper = false;
12382|  6.94k|  bool has_x = false;
12383|  6.94k|  size_t host_end = pos;
12384|  6.94k|  if (!scan_plain_host(b, pos, len, host_end, has_upper, has_x)) {
  ------------------
  |  Branch (12384:7): [True: 245, False: 6.69k]
  ------------------
12385|    245|    return false;
12386|    245|  }
12387|  6.69k|  if (host_start == host_end) [[unlikely]] {
  ------------------
  |  Branch (12387:7): [True: 48, False: 6.65k]
  ------------------
12388|     48|    return false;
12389|     48|  }
12390|  6.65k|  const size_t host_len = host_end - host_start;
12391|  6.65k|  if (host_len > 253) [[unlikely]] {
  ------------------
  |  Branch (12391:7): [True: 88, False: 6.56k]
  ------------------
12392|     88|    return false;
12393|     88|  }
12394|  6.56k|  {
12395|  6.56k|    std::string_view hv(input.data() + host_start, host_len);
12396|  6.56k|    char host_buf[256];
12397|  6.56k|    if (has_upper) [[unlikely]] {
  ------------------
  |  Branch (12397:9): [True: 563, False: 5.99k]
  ------------------
12398|    563|      std::memcpy(host_buf, input.data() + host_start, host_len);
12399|    563|      unicode::to_lower_ascii(host_buf, host_len);
12400|    563|      hv = std::string_view(host_buf, host_len);
12401|    563|    }
12402|  6.56k|    if (ada::checkers::last_label_may_be_a_number(hv)) [[unlikely]] {
  ------------------
  |  Branch (12402:9): [True: 85, False: 6.47k]
  ------------------
12403|     85|      return false;
12404|     85|    }
12405|       |    // Punycode is "xn--...". The host scan already notes a lowercase 'x';
12406|       |    // uppercase 'X' is covered by has_upper after the in-place lower.
12407|  6.47k|    static constexpr std::string_view xn{"xn-", 3};
12408|  6.47k|    if ((has_x || has_upper) && hv.find(xn) != std::string_view::npos)
  ------------------
  |  Branch (12408:10): [True: 1.85k, False: 4.61k]
  |  Branch (12408:19): [True: 508, False: 4.11k]
  |  Branch (12408:33): [True: 1.32k, False: 1.04k]
  ------------------
12409|  1.32k|        [[unlikely]] {
12410|  1.32k|      return false;
12411|  1.32k|    }
12412|  6.47k|  }
12413|       |
12414|  5.15k|  if (host_end < len && b[host_end] == ':') [[unlikely]] {
  ------------------
  |  Branch (12414:7): [True: 4.99k, False: 159]
  |  Branch (12414:25): [True: 1.88k, False: 3.11k]
  ------------------
12415|  1.88k|    return finish_simple_absolute_with_port(input, out, scheme_type,
12416|  1.88k|                                            protocol_end, host_start, host_end,
12417|  1.88k|                                            host_len, has_upper);
12418|  1.88k|  }
12419|       |
12420|  3.27k|  size_t i = host_end;
12421|  3.27k|  size_t path_start = host_end;
12422|  3.27k|  size_t path_end = host_end;
12423|  3.27k|  size_t query_start = std::string_view::npos;
12424|  3.27k|  size_t hash_start = std::string_view::npos;
12425|  3.27k|  bool has_path = false;
12426|  3.27k|  bool maybe_dot_segment = false;
12427|  3.27k|  bool rest_simple = true;
12428|       |
12429|  3.27k|  if (i < len && b[i] == '/') {
  ------------------
  |  Branch (12429:7): [True: 3.11k, False: 159]
  |  Branch (12429:18): [True: 2.97k, False: 140]
  ------------------
12430|  2.97k|    has_path = true;
12431|  2.97k|    path_start = i;
12432|  2.97k|    ++i;
12433|  2.97k|    scan_path_run(b, i, len, maybe_dot_segment);
12434|  2.97k|    if (i < len) {
  ------------------
  |  Branch (12434:9): [True: 1.29k, False: 1.67k]
  ------------------
12435|  1.29k|      const uint8_t cls = k_path[b[i]];
12436|  1.29k|      if (cls == 1) {
  ------------------
  |  Branch (12436:11): [True: 369, False: 928]
  ------------------
12437|    369|        path_end = i;
12438|    369|        if (b[i] == '?') {
  ------------------
  |  Branch (12438:13): [True: 222, False: 147]
  ------------------
12439|    222|          query_start = i;
12440|    222|          ++i;
12441|    222|          goto scan_query;
12442|    222|        }
12443|    147|        hash_start = i;
12444|    147|        ++i;
12445|    147|        goto scan_hash;
12446|    369|      }
12447|    928|      rest_simple = false;
12448|    928|      hash_start = input.find('#', i);
12449|    928|      query_start = input.substr(0, hash_start).find('?', i);
12450|    928|      if (query_start != std::string_view::npos) {
  ------------------
  |  Branch (12450:11): [True: 56, False: 872]
  ------------------
12451|     56|        path_end = query_start;
12452|    872|      } else {
12453|    872|        path_end = hash_start != std::string_view::npos ? hash_start : len;
  ------------------
  |  Branch (12453:20): [True: 29, False: 843]
  ------------------
12454|    872|      }
12455|    928|      goto after_rest;
12456|  1.29k|    }
12457|  1.67k|    path_end = i;
12458|  1.67k|  } else if (i < len && b[i] == '?') {
  ------------------
  |  Branch (12458:14): [True: 140, False: 159]
  |  Branch (12458:25): [True: 69, False: 71]
  ------------------
12459|     69|    query_start = i;
12460|     69|    ++i;
12461|     69|    goto scan_query;
12462|    230|  } else if (i < len && b[i] == '#') {
  ------------------
  |  Branch (12462:14): [True: 71, False: 159]
  |  Branch (12462:25): [True: 71, False: 0]
  ------------------
12463|     71|    hash_start = i;
12464|     71|    ++i;
12465|     71|    goto scan_hash;
12466|     71|  }
12467|  1.83k|  goto after_rest;
12468|       |
12469|  1.83k|scan_query:
12470|    291|  scan_query_run(b, i, len);
12471|    291|  if (i < len) {
  ------------------
  |  Branch (12471:7): [True: 148, False: 143]
  ------------------
12472|    148|    if (b[i] == '#') {
  ------------------
  |  Branch (12472:9): [True: 102, False: 46]
  ------------------
12473|    102|      hash_start = i;
12474|    102|      ++i;
12475|    102|      goto scan_hash;
12476|    102|    }
12477|     46|    rest_simple = false;
12478|     46|    goto scan_query_boundary;
12479|    148|  }
12480|    143|  goto after_rest;
12481|       |
12482|    143|scan_query_boundary:
12483|     46|  hash_start = input.find('#', i);
12484|     46|  goto after_rest;
12485|       |
12486|    320|scan_hash:
12487|    320|  scan_hash_run(b, i, len);
12488|    320|  if (i < len) {
  ------------------
  |  Branch (12488:7): [True: 60, False: 260]
  ------------------
12489|     60|    rest_simple = false;
12490|     60|  }
12491|       |
12492|  3.27k|after_rest:
12493|  3.27k|  if (rest_simple && maybe_dot_segment) {
  ------------------
  |  Branch (12493:7): [True: 2.23k, False: 1.03k]
  |  Branch (12493:22): [True: 358, False: 1.88k]
  ------------------
12494|    358|    const std::string_view path_body(input.data() + path_start,
12495|    358|                                     path_end - path_start);
12496|    358|    if (path_has_dot_segment(path_body)) {
  ------------------
  |  Branch (12496:9): [True: 152, False: 206]
  ------------------
12497|    152|      rest_simple = false;
12498|    152|    }
12499|    358|  }
12500|       |
12501|       |  // The slow path removes ASCII tab/newline anywhere in the input and trims a
12502|       |  // trailing C0 control or space; this fast path does neither. A query or
12503|       |  // fragment reaching the helpers below would keep those bytes percent-encoded
12504|       |  // ("?a\nb" -> "?a%0Ab", "#f " -> "#f%20") instead of stripped, so hand such
12505|       |  // inputs back to the slow path.
12506|  3.27k|  if (!rest_simple && (unicode::is_c0_control_or_space(input.back()) ||
  ------------------
  |  Branch (12506:7): [True: 1.18k, False: 2.08k]
  |  Branch (12506:24): [True: 24, False: 1.16k]
  ------------------
12507|  1.16k|                       unicode::has_tabs_or_newline(input))) {
  ------------------
  |  Branch (12507:24): [True: 18, False: 1.14k]
  ------------------
12508|     42|    return false;
12509|     42|  }
12510|       |
12511|  3.23k|  out.type = scheme_type;
12512|  3.23k|  out.is_valid = true;
12513|  3.23k|  out.has_opaque_path = false;
12514|  3.23k|  out.host_type = DEFAULT;
12515|       |
12516|  3.23k|  if (!rest_simple) {
  ------------------
  |  Branch (12516:7): [True: 1.14k, False: 2.08k]
  ------------------
12517|       |    // Host is a plain domain. Finish path/query/hash with
12518|       |    // the regular helpers
12519|       |    // so percent-encoding and dot segments do not re-parse the authority.
12520|  1.14k|    const std::string_view path_view =
12521|  1.14k|        has_path
  ------------------
  |  Branch (12521:9): [True: 1.07k, False: 67]
  ------------------
12522|  1.14k|            ? std::string_view(input.data() + path_start, path_end - path_start)
12523|  1.14k|            : std::string_view{};
12524|  1.14k|    auto apply_query_and_hash = [&]() {
12525|  1.14k|      if (query_start != std::string_view::npos) {
12526|  1.14k|        const size_t q_end =
12527|  1.14k|            (hash_start != std::string_view::npos) ? hash_start : len;
12528|  1.14k|        out.update_base_search(std::string_view(input.data() + query_start + 1,
12529|  1.14k|                                                q_end - query_start - 1),
12530|  1.14k|                               character_sets::SPECIAL_QUERY_PERCENT_ENCODE);
12531|  1.14k|      }
12532|  1.14k|      if (hash_start != std::string_view::npos) {
12533|  1.14k|        out.update_unencoded_base_hash(std::string_view(
12534|  1.14k|            input.data() + hash_start + 1, len - hash_start - 1));
12535|  1.14k|      }
12536|  1.14k|    };
12537|  1.14k|    if constexpr (is_aggregator) {
12538|  1.14k|      out.buffer.assign(input.substr(0, host_end));
12539|  1.14k|      if (has_upper) {
  ------------------
  |  Branch (12539:11): [True: 152, False: 992]
  ------------------
12540|    152|        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12541|    152|      }
12542|  1.14k|      out.components.protocol_end = protocol_end;
12543|  1.14k|      out.components.username_end = protocol_end + 2;
12544|  1.14k|      out.components.host_start = protocol_end + 2;
12545|  1.14k|      out.components.host_end = static_cast<uint32_t>(host_end);
12546|  1.14k|      out.components.port = url_components::omitted;
12547|  1.14k|      out.components.pathname_start = static_cast<uint32_t>(host_end);
12548|  1.14k|      out.components.search_start = url_components::omitted;
12549|  1.14k|      out.components.hash_start = url_components::omitted;
12550|  1.14k|      out.parse_path(path_view);
12551|  1.14k|      apply_query_and_hash();
12552|       |    } else {
12553|       |      std::string host_str(input.substr(host_start, host_len));
12554|       |      if (has_upper) {
12555|       |        unicode::to_lower_ascii(host_str.data(), host_str.size());
12556|       |      }
12557|       |      out.host = std::move(host_str);
12558|       |      out.parse_path(path_view);
12559|       |      apply_query_and_hash();
12560|       |    }
12561|  1.14k|    return true;
12562|  1.14k|  }
12563|       |
12564|  2.08k|  const bool need_slash = !has_path;
12565|  2.08k|  if constexpr (is_aggregator) {
12566|  2.08k|    if (!need_slash) {
  ------------------
  |  Branch (12566:9): [True: 1.87k, False: 215]
  ------------------
12567|       |      // assign copies once. resize()+memcpy would value-init then overwrite.
12568|  1.87k|      out.buffer.assign(input);
12569|  1.87k|      if (has_upper) {
  ------------------
  |  Branch (12569:11): [True: 35, False: 1.83k]
  ------------------
12570|     35|        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12571|     35|      }
12572|  1.87k|      out.components.protocol_end = protocol_end;
12573|  1.87k|      out.components.username_end = protocol_end + 2;
12574|  1.87k|      out.components.host_start = protocol_end + 2;
12575|  1.87k|      out.components.host_end = static_cast<uint32_t>(host_end);
12576|  1.87k|      out.components.port = url_components::omitted;
12577|  1.87k|      out.components.pathname_start = static_cast<uint32_t>(path_start);
12578|  1.87k|      out.components.search_start = (query_start != std::string_view::npos)
  ------------------
  |  Branch (12578:37): [True: 205, False: 1.66k]
  ------------------
12579|  1.87k|                                        ? static_cast<uint32_t>(query_start)
12580|  1.87k|                                        : url_components::omitted;
12581|  1.87k|      out.components.hash_start = (hash_start != std::string_view::npos)
  ------------------
  |  Branch (12581:35): [True: 228, False: 1.64k]
  ------------------
12582|  1.87k|                                      ? static_cast<uint32_t>(hash_start)
12583|  1.87k|                                      : url_components::omitted;
12584|  1.87k|    } else {
12585|    215|      out.buffer.clear();
12586|    215|      out.buffer.reserve(len + 1);
12587|    215|      out.buffer.append(input.substr(0, host_end));
12588|    215|      out.buffer.push_back('/');
12589|    215|      if (host_end < len) {
  ------------------
  |  Branch (12589:11): [True: 56, False: 159]
  ------------------
12590|     56|        out.buffer.append(input.substr(host_end));
12591|     56|      }
12592|    215|      if (has_upper) {
  ------------------
  |  Branch (12592:11): [True: 92, False: 123]
  ------------------
12593|     92|        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12594|     92|      }
12595|    215|      out.components.protocol_end = protocol_end;
12596|    215|      out.components.username_end = protocol_end + 2;
12597|    215|      out.components.host_start = protocol_end + 2;
12598|    215|      out.components.host_end = static_cast<uint32_t>(host_end);
12599|    215|      out.components.port = url_components::omitted;
12600|    215|      out.components.pathname_start = static_cast<uint32_t>(host_end);
12601|    215|      out.components.search_start = (query_start != std::string_view::npos)
  ------------------
  |  Branch (12601:37): [True: 34, False: 181]
  ------------------
12602|    215|                                        ? static_cast<uint32_t>(query_start + 1)
12603|    215|                                        : url_components::omitted;
12604|    215|      out.components.hash_start = (hash_start != std::string_view::npos)
  ------------------
  |  Branch (12604:35): [True: 32, False: 183]
  ------------------
12605|    215|                                      ? static_cast<uint32_t>(hash_start + 1)
12606|    215|                                      : url_components::omitted;
12607|    215|    }
12608|       |  } else {
12609|       |    std::string host_str(input.substr(host_start, host_len));
12610|       |    if (has_upper) {
12611|       |      unicode::to_lower_ascii(host_str.data(), host_str.size());
12612|       |    }
12613|       |    out.host = std::move(host_str);
12614|       |    if (need_slash) {
12615|       |      out.path = "/";
12616|       |    } else {
12617|       |      out.path.assign(input.data() + path_start, path_end - path_start);
12618|       |    }
12619|       |    if (query_start != std::string_view::npos) {
12620|       |      const size_t q_end =
12621|       |          (hash_start != std::string_view::npos) ? hash_start : len;
12622|       |      out.query.emplace(input.data() + query_start + 1,
12623|       |                        q_end - query_start - 1);
12624|       |    }
12625|       |    if (hash_start != std::string_view::npos) {
12626|       |      out.hash.emplace(input.data() + hash_start + 1, len - hash_start - 1);
12627|       |    }
12628|       |  }
12629|  2.08k|  return true;
12630|  3.23k|}
_ZN3ada6parser32finish_simple_absolute_with_portINS_3urlEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_NS_6scheme4typeEjmmmb:
11990|  1.88k|    bool has_upper) {
11991|  1.88k|  constexpr bool is_ada_url = std::is_same_v<result_type, ada::url>;
11992|  1.88k|  constexpr bool is_aggregator =
11993|  1.88k|      std::is_same_v<result_type, ada::url_aggregator>;
11994|  1.88k|  static_assert(is_ada_url || is_aggregator);
11995|       |
11996|  1.88k|  const size_t len = input.size();
11997|  1.88k|  const auto* b = reinterpret_cast<const uint8_t*>(input.data());
11998|  1.88k|  size_t p = host_end + 1;
11999|  1.88k|  uint32_t port_value = 0;
12000|  1.88k|  bool any_digit = false;
12001|  4.07k|  while (p < len && b[p] >= '0' && b[p] <= '9') {
  ------------------
  |  Branch (12001:10): [True: 3.99k, False: 75]
  |  Branch (12001:21): [True: 2.31k, False: 1.68k]
  |  Branch (12001:36): [True: 2.20k, False: 108]
  ------------------
12002|  2.20k|    any_digit = true;
12003|  2.20k|    port_value = port_value * 10 + static_cast<uint32_t>(b[p] - '0');
12004|  2.20k|    if (port_value > 65535) [[unlikely]] {
  ------------------
  |  Branch (12004:9): [True: 11, False: 2.19k]
  ------------------
12005|     11|      return false;
12006|     11|    }
12007|  2.19k|    ++p;
12008|  2.19k|  }
12009|  1.86k|  if (p < len && b[p] != '/' && b[p] != '?' && b[p] != '#') [[unlikely]] {
  ------------------
  |  Branch (12009:7): [True: 1.79k, False: 75]
  |  Branch (12009:18): [True: 192, False: 1.60k]
  |  Branch (12009:33): [True: 119, False: 73]
  |  Branch (12009:48): [True: 51, False: 68]
  ------------------
12010|     51|    return false;
12011|     51|  }
12012|  1.81k|  uint32_t parsed_port = url_components::omitted;
12013|  1.81k|  const uint16_t default_port = ada::scheme::get_special_port(scheme_type);
12014|  1.81k|  if (any_digit && port_value != default_port) {
  ------------------
  |  Branch (12014:7): [True: 1.20k, False: 618]
  |  Branch (12014:20): [True: 1.19k, False: 4]
  ------------------
12015|  1.19k|    parsed_port = port_value;
12016|  1.19k|  }
12017|  1.81k|  const size_t authority_end = p;
12018|       |
12019|  1.81k|  size_t i = authority_end;
12020|  1.81k|  size_t path_start = host_end;
12021|  1.81k|  size_t path_end = host_end;
12022|  1.81k|  size_t query_start = std::string_view::npos;
12023|  1.81k|  size_t hash_start = std::string_view::npos;
12024|  1.81k|  bool has_path = false;
12025|  1.81k|  bool maybe_dot_segment = false;
12026|  1.81k|  bool rest_simple = true;
12027|       |
12028|  1.81k|  if (i < len && b[i] == '/') {
  ------------------
  |  Branch (12028:7): [True: 1.74k, False: 75]
  |  Branch (12028:18): [True: 1.60k, False: 141]
  ------------------
12029|  1.60k|    has_path = true;
12030|  1.60k|    path_start = i;
12031|  1.60k|    ++i;
12032|  1.60k|    scan_path_run(b, i, len, maybe_dot_segment);
12033|  1.60k|    if (i < len) {
  ------------------
  |  Branch (12033:9): [True: 1.01k, False: 589]
  ------------------
12034|  1.01k|      const uint8_t cls = k_path[b[i]];
12035|  1.01k|      if (cls == 1) {
  ------------------
  |  Branch (12035:11): [True: 224, False: 789]
  ------------------
12036|    224|        path_end = i;
12037|    224|        if (b[i] == '?') {
  ------------------
  |  Branch (12037:13): [True: 143, False: 81]
  ------------------
12038|    143|          query_start = i;
12039|    143|          ++i;
12040|    143|          goto scan_query;
12041|    143|        }
12042|     81|        hash_start = i;
12043|     81|        ++i;
12044|     81|        goto scan_hash;
12045|    224|      }
12046|    789|      rest_simple = false;
12047|  24.6k|      for (; i < len; ++i) {
  ------------------
  |  Branch (12047:14): [True: 23.9k, False: 718]
  ------------------
12048|  23.9k|        if (b[i] == '?') {
  ------------------
  |  Branch (12048:13): [True: 54, False: 23.9k]
  ------------------
12049|     54|          path_end = i;
12050|     54|          query_start = i;
12051|     54|          ++i;
12052|     54|          goto scan_query_boundary;
12053|     54|        }
12054|  23.9k|        if (b[i] == '#') {
  ------------------
  |  Branch (12054:13): [True: 17, False: 23.8k]
  ------------------
12055|     17|          path_end = i;
12056|     17|          hash_start = i;
12057|     17|          ++i;
12058|     17|          goto after_rest;
12059|     17|        }
12060|  23.9k|      }
12061|    718|      path_end = i;
12062|    718|      goto after_rest;
12063|    789|    }
12064|    589|    path_end = i;
12065|    589|  } else if (i < len && b[i] == '?') {
  ------------------
  |  Branch (12065:14): [True: 141, False: 75]
  |  Branch (12065:25): [True: 73, False: 68]
  ------------------
12066|     73|    query_start = i;
12067|     73|    ++i;
12068|     73|    goto scan_query;
12069|    143|  } else if (i < len && b[i] == '#') {
  ------------------
  |  Branch (12069:14): [True: 68, False: 75]
  |  Branch (12069:25): [True: 68, False: 0]
  ------------------
12070|     68|    hash_start = i;
12071|     68|    ++i;
12072|     68|    goto scan_hash;
12073|     68|  }
12074|    664|  goto after_rest;
12075|       |
12076|    664|scan_query:
12077|    216|  scan_query_run(b, i, len);
12078|    216|  if (i < len) {
  ------------------
  |  Branch (12078:7): [True: 111, False: 105]
  ------------------
12079|    111|    if (b[i] == '#') {
  ------------------
  |  Branch (12079:9): [True: 76, False: 35]
  ------------------
12080|     76|      hash_start = i;
12081|     76|      ++i;
12082|     76|      goto scan_hash;
12083|     76|    }
12084|     35|    rest_simple = false;
12085|     35|    goto scan_query_boundary;
12086|    111|  }
12087|    105|  goto after_rest;
12088|       |
12089|    105|scan_query_boundary:
12090|  1.46k|  for (; i < len; ++i) {
  ------------------
  |  Branch (12090:10): [True: 1.39k, False: 68]
  ------------------
12091|  1.39k|    if (b[i] == '#') {
  ------------------
  |  Branch (12091:9): [True: 21, False: 1.37k]
  ------------------
12092|     21|      hash_start = i;
12093|     21|      ++i;
12094|     21|      goto after_rest;
12095|     21|    }
12096|  1.39k|  }
12097|     68|  goto after_rest;
12098|       |
12099|    225|scan_hash:
12100|    225|  scan_hash_run(b, i, len);
12101|    225|  if (i < len) {
  ------------------
  |  Branch (12101:7): [True: 56, False: 169]
  ------------------
12102|     56|    rest_simple = false;
12103|     56|  }
12104|       |
12105|  1.81k|after_rest:
12106|  1.81k|  if (rest_simple && maybe_dot_segment) {
  ------------------
  |  Branch (12106:7): [True: 938, False: 880]
  |  Branch (12106:22): [True: 343, False: 595]
  ------------------
12107|    343|    const std::string_view path_body(input.data() + path_start,
12108|    343|                                     path_end - path_start);
12109|    343|    if (path_has_dot_segment(path_body)) {
  ------------------
  |  Branch (12109:9): [True: 231, False: 112]
  ------------------
12110|    231|      rest_simple = false;
12111|    231|    }
12112|    343|  }
12113|       |
12114|       |  // The slow path removes ASCII tab/newline anywhere in the input and trims a
12115|       |  // trailing C0 control or space; this fast path does neither. A query or
12116|       |  // fragment reaching the helpers below would keep those bytes percent-encoded
12117|       |  // ("?a\nb" -> "?a%0Ab", "#f " -> "#f%20") instead of stripped, so hand such
12118|       |  // inputs back to the slow path.
12119|  1.81k|  if (!rest_simple && (unicode::is_c0_control_or_space(input.back()) ||
  ------------------
  |  Branch (12119:7): [True: 1.11k, False: 707]
  |  Branch (12119:24): [True: 29, False: 1.08k]
  ------------------
12120|  1.08k|                       unicode::has_tabs_or_newline(input))) {
  ------------------
  |  Branch (12120:24): [True: 27, False: 1.05k]
  ------------------
12121|     56|    return false;
12122|     56|  }
12123|       |
12124|  1.76k|  out.type = scheme_type;
12125|  1.76k|  out.is_valid = true;
12126|  1.76k|  out.has_opaque_path = false;
12127|  1.76k|  out.host_type = DEFAULT;
12128|       |
12129|  1.76k|  const uint32_t port_bytes = (parsed_port != url_components::omitted)
  ------------------
  |  Branch (12129:31): [True: 1.18k, False: 576]
  ------------------
12130|  1.76k|                                  ? (1 + port_decimal_digit_count(parsed_port))
12131|  1.76k|                                  : 0;
12132|       |
12133|  1.76k|  if (!rest_simple) {
  ------------------
  |  Branch (12133:7): [True: 1.05k, False: 707]
  ------------------
12134|  1.05k|    const std::string_view path_view =
12135|  1.05k|        has_path
  ------------------
  |  Branch (12135:9): [True: 1.01k, False: 44]
  ------------------
12136|  1.05k|            ? std::string_view(input.data() + path_start, path_end - path_start)
12137|  1.05k|            : std::string_view{};
12138|  1.05k|    auto apply_query_and_hash = [&]() {
12139|  1.05k|      if (query_start != std::string_view::npos) {
12140|  1.05k|        const size_t q_end =
12141|  1.05k|            (hash_start != std::string_view::npos) ? hash_start : len;
12142|  1.05k|        out.update_base_search(std::string_view(input.data() + query_start + 1,
12143|  1.05k|                                                q_end - query_start - 1),
12144|  1.05k|                               character_sets::SPECIAL_QUERY_PERCENT_ENCODE);
12145|  1.05k|      }
12146|  1.05k|      if (hash_start != std::string_view::npos) {
12147|  1.05k|        out.update_unencoded_base_hash(std::string_view(
12148|  1.05k|            input.data() + hash_start + 1, len - hash_start - 1));
12149|  1.05k|      }
12150|  1.05k|    };
12151|       |    if constexpr (is_aggregator) {
12152|       |      out.buffer.assign(input.substr(0, host_end));
12153|       |      if (parsed_port != url_components::omitted) {
12154|       |        append_canonical_port(out.buffer, parsed_port);
12155|       |      }
12156|       |      if (has_upper) {
12157|       |        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12158|       |      }
12159|       |      out.components.protocol_end = protocol_end;
12160|       |      out.components.username_end = protocol_end + 2;
12161|       |      out.components.host_start = protocol_end + 2;
12162|       |      out.components.host_end = static_cast<uint32_t>(host_end);
12163|       |      out.components.port = parsed_port;
12164|       |      out.components.pathname_start = static_cast<uint32_t>(out.buffer.size());
12165|       |      out.components.search_start = url_components::omitted;
12166|       |      out.components.hash_start = url_components::omitted;
12167|       |      out.parse_path(path_view);
12168|       |      apply_query_and_hash();
12169|  1.05k|    } else {
12170|  1.05k|      std::string host_str(input.substr(host_start, host_len));
12171|  1.05k|      if (has_upper) {
  ------------------
  |  Branch (12171:11): [True: 150, False: 905]
  ------------------
12172|    150|        unicode::to_lower_ascii(host_str.data(), host_str.size());
12173|    150|      }
12174|  1.05k|      out.host = std::move(host_str);
12175|  1.05k|      if (parsed_port != url_components::omitted) {
  ------------------
  |  Branch (12175:11): [True: 577, False: 478]
  ------------------
12176|    577|        out.port = static_cast<uint16_t>(parsed_port);
12177|    577|      }
12178|  1.05k|      out.parse_path(path_view);
12179|  1.05k|      apply_query_and_hash();
12180|  1.05k|    }
12181|  1.05k|    return true;
12182|  1.05k|  }
12183|       |
12184|    707|  const bool insert_slash = !has_path;
12185|       |  if constexpr (is_aggregator) {
12186|       |    const size_t out_len =
12187|       |        host_end + port_bytes + (insert_slash ? 1 : 0) + (len - authority_end);
12188|       |    const bool omit_port_bytes = parsed_port == url_components::omitted;
12189|       |    if (out_len == len && !insert_slash && !omit_port_bytes) {
12190|       |      out.buffer.assign(input);
12191|       |    } else {
12192|       |      out.buffer.clear();
12193|       |      out.buffer.reserve(out_len);
12194|       |      out.buffer.append(input.substr(0, host_end));
12195|       |      if (parsed_port != url_components::omitted) {
12196|       |        append_canonical_port(out.buffer, parsed_port);
12197|       |      }
12198|       |      if (insert_slash) {
12199|       |        out.buffer.push_back('/');
12200|       |      }
12201|       |      if (authority_end < len) {
12202|       |        out.buffer.append(input.substr(authority_end));
12203|       |      }
12204|       |    }
12205|       |    if (has_upper) {
12206|       |      unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12207|       |    }
12208|       |    const uint32_t pathname_start =
12209|       |        static_cast<uint32_t>(host_end) + port_bytes;
12210|       |    const int32_t tail_delta = static_cast<int32_t>(pathname_start) +
12211|       |                               (insert_slash ? 1 : 0) -
12212|       |                               static_cast<int32_t>(authority_end);
12213|       |    out.components.protocol_end = protocol_end;
12214|       |    out.components.username_end = protocol_end + 2;
12215|       |    out.components.host_start = protocol_end + 2;
12216|       |    out.components.host_end = static_cast<uint32_t>(host_end);
12217|       |    out.components.port = parsed_port;
12218|       |    out.components.pathname_start = pathname_start;
12219|       |    out.components.search_start =
12220|       |        (query_start != std::string_view::npos)
12221|       |            ? static_cast<uint32_t>(static_cast<int32_t>(query_start) +
12222|       |                                    tail_delta)
12223|       |            : url_components::omitted;
12224|       |    out.components.hash_start =
12225|       |        (hash_start != std::string_view::npos)
12226|       |            ? static_cast<uint32_t>(static_cast<int32_t>(hash_start) +
12227|       |                                    tail_delta)
12228|       |            : url_components::omitted;
12229|    707|  } else {
12230|    707|    std::string host_str(input.substr(host_start, host_len));
12231|    707|    if (has_upper) {
  ------------------
  |  Branch (12231:9): [True: 88, False: 619]
  ------------------
12232|     88|      unicode::to_lower_ascii(host_str.data(), host_str.size());
12233|     88|    }
12234|    707|    out.host = std::move(host_str);
12235|    707|    if (parsed_port != url_components::omitted) {
  ------------------
  |  Branch (12235:9): [True: 609, False: 98]
  ------------------
12236|    609|      out.port = static_cast<uint16_t>(parsed_port);
12237|    609|    }
12238|    707|    if (insert_slash) {
  ------------------
  |  Branch (12238:9): [True: 147, False: 560]
  ------------------
12239|    147|      out.path = "/";
12240|    560|    } else {
12241|    560|      out.path.assign(input.data() + path_start, path_end - path_start);
12242|    560|    }
12243|    707|    if (query_start != std::string_view::npos) {
  ------------------
  |  Branch (12243:9): [True: 176, False: 531]
  ------------------
12244|    176|      const size_t q_end =
12245|    176|          (hash_start != std::string_view::npos) ? hash_start : len;
  ------------------
  |  Branch (12245:11): [True: 71, False: 105]
  ------------------
12246|    176|      out.query.emplace(input.data() + query_start + 1,
12247|    176|                        q_end - query_start - 1);
12248|    176|    }
12249|    707|    if (hash_start != std::string_view::npos) {
  ------------------
  |  Branch (12249:9): [True: 169, False: 538]
  ------------------
12250|    169|      out.hash.emplace(input.data() + hash_start + 1, len - hash_start - 1);
12251|    169|    }
12252|    707|  }
12253|    707|  return true;
12254|  1.76k|}
_ZN3ada6parser32finish_simple_absolute_with_portINS_14url_aggregatorEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_NS_6scheme4typeEjmmmb:
11990|  1.88k|    bool has_upper) {
11991|  1.88k|  constexpr bool is_ada_url = std::is_same_v<result_type, ada::url>;
11992|  1.88k|  constexpr bool is_aggregator =
11993|  1.88k|      std::is_same_v<result_type, ada::url_aggregator>;
11994|  1.88k|  static_assert(is_ada_url || is_aggregator);
11995|       |
11996|  1.88k|  const size_t len = input.size();
11997|  1.88k|  const auto* b = reinterpret_cast<const uint8_t*>(input.data());
11998|  1.88k|  size_t p = host_end + 1;
11999|  1.88k|  uint32_t port_value = 0;
12000|  1.88k|  bool any_digit = false;
12001|  4.07k|  while (p < len && b[p] >= '0' && b[p] <= '9') {
  ------------------
  |  Branch (12001:10): [True: 3.99k, False: 75]
  |  Branch (12001:21): [True: 2.31k, False: 1.68k]
  |  Branch (12001:36): [True: 2.20k, False: 108]
  ------------------
12002|  2.20k|    any_digit = true;
12003|  2.20k|    port_value = port_value * 10 + static_cast<uint32_t>(b[p] - '0');
12004|  2.20k|    if (port_value > 65535) [[unlikely]] {
  ------------------
  |  Branch (12004:9): [True: 11, False: 2.19k]
  ------------------
12005|     11|      return false;
12006|     11|    }
12007|  2.19k|    ++p;
12008|  2.19k|  }
12009|  1.86k|  if (p < len && b[p] != '/' && b[p] != '?' && b[p] != '#') [[unlikely]] {
  ------------------
  |  Branch (12009:7): [True: 1.79k, False: 75]
  |  Branch (12009:18): [True: 192, False: 1.60k]
  |  Branch (12009:33): [True: 119, False: 73]
  |  Branch (12009:48): [True: 51, False: 68]
  ------------------
12010|     51|    return false;
12011|     51|  }
12012|  1.81k|  uint32_t parsed_port = url_components::omitted;
12013|  1.81k|  const uint16_t default_port = ada::scheme::get_special_port(scheme_type);
12014|  1.81k|  if (any_digit && port_value != default_port) {
  ------------------
  |  Branch (12014:7): [True: 1.20k, False: 618]
  |  Branch (12014:20): [True: 1.19k, False: 4]
  ------------------
12015|  1.19k|    parsed_port = port_value;
12016|  1.19k|  }
12017|  1.81k|  const size_t authority_end = p;
12018|       |
12019|  1.81k|  size_t i = authority_end;
12020|  1.81k|  size_t path_start = host_end;
12021|  1.81k|  size_t path_end = host_end;
12022|  1.81k|  size_t query_start = std::string_view::npos;
12023|  1.81k|  size_t hash_start = std::string_view::npos;
12024|  1.81k|  bool has_path = false;
12025|  1.81k|  bool maybe_dot_segment = false;
12026|  1.81k|  bool rest_simple = true;
12027|       |
12028|  1.81k|  if (i < len && b[i] == '/') {
  ------------------
  |  Branch (12028:7): [True: 1.74k, False: 75]
  |  Branch (12028:18): [True: 1.60k, False: 141]
  ------------------
12029|  1.60k|    has_path = true;
12030|  1.60k|    path_start = i;
12031|  1.60k|    ++i;
12032|  1.60k|    scan_path_run(b, i, len, maybe_dot_segment);
12033|  1.60k|    if (i < len) {
  ------------------
  |  Branch (12033:9): [True: 1.01k, False: 589]
  ------------------
12034|  1.01k|      const uint8_t cls = k_path[b[i]];
12035|  1.01k|      if (cls == 1) {
  ------------------
  |  Branch (12035:11): [True: 224, False: 789]
  ------------------
12036|    224|        path_end = i;
12037|    224|        if (b[i] == '?') {
  ------------------
  |  Branch (12037:13): [True: 143, False: 81]
  ------------------
12038|    143|          query_start = i;
12039|    143|          ++i;
12040|    143|          goto scan_query;
12041|    143|        }
12042|     81|        hash_start = i;
12043|     81|        ++i;
12044|     81|        goto scan_hash;
12045|    224|      }
12046|    789|      rest_simple = false;
12047|  24.6k|      for (; i < len; ++i) {
  ------------------
  |  Branch (12047:14): [True: 23.9k, False: 718]
  ------------------
12048|  23.9k|        if (b[i] == '?') {
  ------------------
  |  Branch (12048:13): [True: 54, False: 23.9k]
  ------------------
12049|     54|          path_end = i;
12050|     54|          query_start = i;
12051|     54|          ++i;
12052|     54|          goto scan_query_boundary;
12053|     54|        }
12054|  23.9k|        if (b[i] == '#') {
  ------------------
  |  Branch (12054:13): [True: 17, False: 23.8k]
  ------------------
12055|     17|          path_end = i;
12056|     17|          hash_start = i;
12057|     17|          ++i;
12058|     17|          goto after_rest;
12059|     17|        }
12060|  23.9k|      }
12061|    718|      path_end = i;
12062|    718|      goto after_rest;
12063|    789|    }
12064|    589|    path_end = i;
12065|    589|  } else if (i < len && b[i] == '?') {
  ------------------
  |  Branch (12065:14): [True: 141, False: 75]
  |  Branch (12065:25): [True: 73, False: 68]
  ------------------
12066|     73|    query_start = i;
12067|     73|    ++i;
12068|     73|    goto scan_query;
12069|    143|  } else if (i < len && b[i] == '#') {
  ------------------
  |  Branch (12069:14): [True: 68, False: 75]
  |  Branch (12069:25): [True: 68, False: 0]
  ------------------
12070|     68|    hash_start = i;
12071|     68|    ++i;
12072|     68|    goto scan_hash;
12073|     68|  }
12074|    664|  goto after_rest;
12075|       |
12076|    664|scan_query:
12077|    216|  scan_query_run(b, i, len);
12078|    216|  if (i < len) {
  ------------------
  |  Branch (12078:7): [True: 111, False: 105]
  ------------------
12079|    111|    if (b[i] == '#') {
  ------------------
  |  Branch (12079:9): [True: 76, False: 35]
  ------------------
12080|     76|      hash_start = i;
12081|     76|      ++i;
12082|     76|      goto scan_hash;
12083|     76|    }
12084|     35|    rest_simple = false;
12085|     35|    goto scan_query_boundary;
12086|    111|  }
12087|    105|  goto after_rest;
12088|       |
12089|    105|scan_query_boundary:
12090|  1.46k|  for (; i < len; ++i) {
  ------------------
  |  Branch (12090:10): [True: 1.39k, False: 68]
  ------------------
12091|  1.39k|    if (b[i] == '#') {
  ------------------
  |  Branch (12091:9): [True: 21, False: 1.37k]
  ------------------
12092|     21|      hash_start = i;
12093|     21|      ++i;
12094|     21|      goto after_rest;
12095|     21|    }
12096|  1.39k|  }
12097|     68|  goto after_rest;
12098|       |
12099|    225|scan_hash:
12100|    225|  scan_hash_run(b, i, len);
12101|    225|  if (i < len) {
  ------------------
  |  Branch (12101:7): [True: 56, False: 169]
  ------------------
12102|     56|    rest_simple = false;
12103|     56|  }
12104|       |
12105|  1.81k|after_rest:
12106|  1.81k|  if (rest_simple && maybe_dot_segment) {
  ------------------
  |  Branch (12106:7): [True: 938, False: 880]
  |  Branch (12106:22): [True: 343, False: 595]
  ------------------
12107|    343|    const std::string_view path_body(input.data() + path_start,
12108|    343|                                     path_end - path_start);
12109|    343|    if (path_has_dot_segment(path_body)) {
  ------------------
  |  Branch (12109:9): [True: 231, False: 112]
  ------------------
12110|    231|      rest_simple = false;
12111|    231|    }
12112|    343|  }
12113|       |
12114|       |  // The slow path removes ASCII tab/newline anywhere in the input and trims a
12115|       |  // trailing C0 control or space; this fast path does neither. A query or
12116|       |  // fragment reaching the helpers below would keep those bytes percent-encoded
12117|       |  // ("?a\nb" -> "?a%0Ab", "#f " -> "#f%20") instead of stripped, so hand such
12118|       |  // inputs back to the slow path.
12119|  1.81k|  if (!rest_simple && (unicode::is_c0_control_or_space(input.back()) ||
  ------------------
  |  Branch (12119:7): [True: 1.11k, False: 707]
  |  Branch (12119:24): [True: 29, False: 1.08k]
  ------------------
12120|  1.08k|                       unicode::has_tabs_or_newline(input))) {
  ------------------
  |  Branch (12120:24): [True: 27, False: 1.05k]
  ------------------
12121|     56|    return false;
12122|     56|  }
12123|       |
12124|  1.76k|  out.type = scheme_type;
12125|  1.76k|  out.is_valid = true;
12126|  1.76k|  out.has_opaque_path = false;
12127|  1.76k|  out.host_type = DEFAULT;
12128|       |
12129|  1.76k|  const uint32_t port_bytes = (parsed_port != url_components::omitted)
  ------------------
  |  Branch (12129:31): [True: 1.18k, False: 576]
  ------------------
12130|  1.76k|                                  ? (1 + port_decimal_digit_count(parsed_port))
12131|  1.76k|                                  : 0;
12132|       |
12133|  1.76k|  if (!rest_simple) {
  ------------------
  |  Branch (12133:7): [True: 1.05k, False: 707]
  ------------------
12134|  1.05k|    const std::string_view path_view =
12135|  1.05k|        has_path
  ------------------
  |  Branch (12135:9): [True: 1.01k, False: 44]
  ------------------
12136|  1.05k|            ? std::string_view(input.data() + path_start, path_end - path_start)
12137|  1.05k|            : std::string_view{};
12138|  1.05k|    auto apply_query_and_hash = [&]() {
12139|  1.05k|      if (query_start != std::string_view::npos) {
12140|  1.05k|        const size_t q_end =
12141|  1.05k|            (hash_start != std::string_view::npos) ? hash_start : len;
12142|  1.05k|        out.update_base_search(std::string_view(input.data() + query_start + 1,
12143|  1.05k|                                                q_end - query_start - 1),
12144|  1.05k|                               character_sets::SPECIAL_QUERY_PERCENT_ENCODE);
12145|  1.05k|      }
12146|  1.05k|      if (hash_start != std::string_view::npos) {
12147|  1.05k|        out.update_unencoded_base_hash(std::string_view(
12148|  1.05k|            input.data() + hash_start + 1, len - hash_start - 1));
12149|  1.05k|      }
12150|  1.05k|    };
12151|  1.05k|    if constexpr (is_aggregator) {
12152|  1.05k|      out.buffer.assign(input.substr(0, host_end));
12153|  1.05k|      if (parsed_port != url_components::omitted) {
  ------------------
  |  Branch (12153:11): [True: 577, False: 478]
  ------------------
12154|    577|        append_canonical_port(out.buffer, parsed_port);
12155|    577|      }
12156|  1.05k|      if (has_upper) {
  ------------------
  |  Branch (12156:11): [True: 150, False: 905]
  ------------------
12157|    150|        unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12158|    150|      }
12159|  1.05k|      out.components.protocol_end = protocol_end;
12160|  1.05k|      out.components.username_end = protocol_end + 2;
12161|  1.05k|      out.components.host_start = protocol_end + 2;
12162|  1.05k|      out.components.host_end = static_cast<uint32_t>(host_end);
12163|  1.05k|      out.components.port = parsed_port;
12164|  1.05k|      out.components.pathname_start = static_cast<uint32_t>(out.buffer.size());
12165|  1.05k|      out.components.search_start = url_components::omitted;
12166|  1.05k|      out.components.hash_start = url_components::omitted;
12167|  1.05k|      out.parse_path(path_view);
12168|  1.05k|      apply_query_and_hash();
12169|       |    } else {
12170|       |      std::string host_str(input.substr(host_start, host_len));
12171|       |      if (has_upper) {
12172|       |        unicode::to_lower_ascii(host_str.data(), host_str.size());
12173|       |      }
12174|       |      out.host = std::move(host_str);
12175|       |      if (parsed_port != url_components::omitted) {
12176|       |        out.port = static_cast<uint16_t>(parsed_port);
12177|       |      }
12178|       |      out.parse_path(path_view);
12179|       |      apply_query_and_hash();
12180|       |    }
12181|  1.05k|    return true;
12182|  1.05k|  }
12183|       |
12184|    707|  const bool insert_slash = !has_path;
12185|    707|  if constexpr (is_aggregator) {
12186|    707|    const size_t out_len =
12187|    707|        host_end + port_bytes + (insert_slash ? 1 : 0) + (len - authority_end);
  ------------------
  |  Branch (12187:34): [True: 147, False: 560]
  ------------------
12188|    707|    const bool omit_port_bytes = parsed_port == url_components::omitted;
12189|    707|    if (out_len == len && !insert_slash && !omit_port_bytes) {
  ------------------
  |  Branch (12189:9): [True: 579, False: 128]
  |  Branch (12189:27): [True: 522, False: 57]
  |  Branch (12189:44): [True: 522, False: 0]
  ------------------
12190|    522|      out.buffer.assign(input);
12191|    522|    } else {
12192|    185|      out.buffer.clear();
12193|    185|      out.buffer.reserve(out_len);
12194|    185|      out.buffer.append(input.substr(0, host_end));
12195|    185|      if (parsed_port != url_components::omitted) {
  ------------------
  |  Branch (12195:11): [True: 87, False: 98]
  ------------------
12196|     87|        append_canonical_port(out.buffer, parsed_port);
12197|     87|      }
12198|    185|      if (insert_slash) {
  ------------------
  |  Branch (12198:11): [True: 147, False: 38]
  ------------------
12199|    147|        out.buffer.push_back('/');
12200|    147|      }
12201|    185|      if (authority_end < len) {
  ------------------
  |  Branch (12201:11): [True: 110, False: 75]
  ------------------
12202|    110|        out.buffer.append(input.substr(authority_end));
12203|    110|      }
12204|    185|    }
12205|    707|    if (has_upper) {
  ------------------
  |  Branch (12205:9): [True: 88, False: 619]
  ------------------
12206|     88|      unicode::to_lower_ascii(out.buffer.data() + host_start, host_len);
12207|     88|    }
12208|    707|    const uint32_t pathname_start =
12209|    707|        static_cast<uint32_t>(host_end) + port_bytes;
12210|    707|    const int32_t tail_delta = static_cast<int32_t>(pathname_start) +
12211|    707|                               (insert_slash ? 1 : 0) -
  ------------------
  |  Branch (12211:33): [True: 147, False: 560]
  ------------------
12212|    707|                               static_cast<int32_t>(authority_end);
12213|    707|    out.components.protocol_end = protocol_end;
12214|    707|    out.components.username_end = protocol_end + 2;
12215|    707|    out.components.host_start = protocol_end + 2;
12216|    707|    out.components.host_end = static_cast<uint32_t>(host_end);
12217|    707|    out.components.port = parsed_port;
12218|    707|    out.components.pathname_start = pathname_start;
12219|    707|    out.components.search_start =
12220|    707|        (query_start != std::string_view::npos)
  ------------------
  |  Branch (12220:9): [True: 176, False: 531]
  ------------------
12221|    707|            ? static_cast<uint32_t>(static_cast<int32_t>(query_start) +
12222|    176|                                    tail_delta)
12223|    707|            : url_components::omitted;
12224|    707|    out.components.hash_start =
12225|    707|        (hash_start != std::string_view::npos)
  ------------------
  |  Branch (12225:9): [True: 169, False: 538]
  ------------------
12226|    707|            ? static_cast<uint32_t>(static_cast<int32_t>(hash_start) +
12227|    169|                                    tail_delta)
12228|    707|            : url_components::omitted;
12229|       |  } else {
12230|       |    std::string host_str(input.substr(host_start, host_len));
12231|       |    if (has_upper) {
12232|       |      unicode::to_lower_ascii(host_str.data(), host_str.size());
12233|       |    }
12234|       |    out.host = std::move(host_str);
12235|       |    if (parsed_port != url_components::omitted) {
12236|       |      out.port = static_cast<uint16_t>(parsed_port);
12237|       |    }
12238|       |    if (insert_slash) {
12239|       |      out.path = "/";
12240|       |    } else {
12241|       |      out.path.assign(input.data() + path_start, path_end - path_start);
12242|       |    }
12243|       |    if (query_start != std::string_view::npos) {
12244|       |      const size_t q_end =
12245|       |          (hash_start != std::string_view::npos) ? hash_start : len;
12246|       |      out.query.emplace(input.data() + query_start + 1,
12247|       |                        q_end - query_start - 1);
12248|       |    }
12249|       |    if (hash_start != std::string_view::npos) {
12250|       |      out.hash.emplace(input.data() + hash_start + 1, len - hash_start - 1);
12251|       |    }
12252|       |  }
12253|    707|  return true;
12254|  1.76k|}
_ZN3ada6parser25try_parse_simple_relativeINS_3urlEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERKT_RS8_:
12638|  4.35k|                                                result_type& out) {
12639|  4.35k|  constexpr bool is_ada_url = std::is_same_v<result_type, ada::url>;
12640|  4.35k|  constexpr bool is_aggregator =
12641|  4.35k|      std::is_same_v<result_type, ada::url_aggregator>;
12642|  4.35k|  static_assert(is_ada_url || is_aggregator);
12643|       |
12644|  4.35k|  if (!base.is_special() || base.type == ada::scheme::type::FILE ||
  ------------------
  |  Branch (12644:7): [True: 2.27k, False: 2.08k]
  |  Branch (12644:29): [True: 348, False: 1.73k]
  ------------------
12645|  2.70k|      base.has_opaque_path || input.empty()) {
  ------------------
  |  Branch (12645:7): [True: 0, False: 1.73k]
  |  Branch (12645:31): [True: 82, False: 1.65k]
  ------------------
12646|  2.70k|    return false;
12647|  2.70k|  }
12648|  1.65k|  const auto* b = reinterpret_cast<const uint8_t*>(input.data());
12649|  1.65k|  const size_t len = input.size();
12650|  1.65k|  const uint8_t first = b[0];
12651|  1.65k|  const bool path_relative = first != '/' && first != '?' && first != '#';
  ------------------
  |  Branch (12651:30): [True: 1.57k, False: 72]
  |  Branch (12651:46): [True: 1.47k, False: 106]
  |  Branch (12651:62): [True: 1.42k, False: 52]
  ------------------
12652|  1.65k|  if (first == '/' && len > 1 && (b[1] == '/' || b[1] == '\\')) {
  ------------------
  |  Branch (12652:7): [True: 72, False: 1.57k]
  |  Branch (12652:23): [True: 60, False: 12]
  |  Branch (12652:35): [True: 4, False: 56]
  |  Branch (12652:50): [True: 1, False: 55]
  ------------------
12653|      5|    return false;
12654|      5|  }
12655|       |  // A ':' before the first / ? # is a scheme, not a path segment.
12656|  1.64k|  if (path_relative) {
  ------------------
  |  Branch (12656:7): [True: 1.42k, False: 225]
  ------------------
12657|  1.42k|    const size_t delim = input.find_first_of("/?#:");
12658|  1.42k|    if (delim != std::string_view::npos && input[delim] == ':') {
  ------------------
  |  Branch (12658:9): [True: 1.22k, False: 200]
  |  Branch (12658:44): [True: 930, False: 290]
  ------------------
12659|    930|      return false;
12660|    930|    }
12661|  1.42k|  }
12662|       |
12663|    715|  size_t i = 0;
12664|    715|  size_t path_start = 0;
12665|    715|  size_t path_end = 0;
12666|    715|  size_t query_start = std::string_view::npos;
12667|    715|  size_t hash_start = std::string_view::npos;
12668|    715|  bool has_path = false;
12669|    715|  bool maybe_dot_segment = false;
12670|       |
12671|    715|  if (first == '/' || path_relative) {
  ------------------
  |  Branch (12671:7): [True: 67, False: 648]
  |  Branch (12671:23): [True: 490, False: 158]
  ------------------
12672|    557|    has_path = true;
12673|    557|    path_start = 0;
12674|    557|    if (first == '/') {
  ------------------
  |  Branch (12674:9): [True: 67, False: 490]
  ------------------
12675|     67|      i = 1;
12676|     67|    }
12677|    557|    scan_path_run(b, i, len, maybe_dot_segment);
12678|    557|    if (i < len) {
  ------------------
  |  Branch (12678:9): [True: 325, False: 232]
  ------------------
12679|    325|      const uint8_t cls = k_path[b[i]];
12680|    325|      if (cls == 2) {
  ------------------
  |  Branch (12680:11): [True: 157, False: 168]
  ------------------
12681|    157|        return false;
12682|    157|      }
12683|    325|    }
12684|    400|    path_end = i;
12685|    400|    if (i < len && b[i] == '?') {
  ------------------
  |  Branch (12685:9): [True: 168, False: 232]
  |  Branch (12685:20): [True: 114, False: 54]
  ------------------
12686|    114|      query_start = i;
12687|    114|      ++i;
12688|    114|      scan_query_run(b, i, len);
12689|    114|      if (i < len) {
  ------------------
  |  Branch (12689:11): [True: 89, False: 25]
  ------------------
12690|     89|        if (b[i] != '#') {
  ------------------
  |  Branch (12690:13): [True: 28, False: 61]
  ------------------
12691|     28|          return false;
12692|     28|        }
12693|     61|        hash_start = i;
12694|     61|        ++i;
12695|     61|        scan_hash_run(b, i, len);
12696|     61|        if (i < len) {
  ------------------
  |  Branch (12696:13): [True: 47, False: 14]
  ------------------
12697|     47|          return false;
12698|     47|        }
12699|     61|      }
12700|    286|    } else if (i < len && b[i] == '#') {
  ------------------
  |  Branch (12700:16): [True: 54, False: 232]
  |  Branch (12700:27): [True: 54, False: 0]
  ------------------
12701|     54|      hash_start = i;
12702|     54|      ++i;
12703|     54|      scan_hash_run(b, i, len);
12704|     54|      if (i < len) {
  ------------------
  |  Branch (12704:11): [True: 35, False: 19]
  ------------------
12705|     35|        return false;
12706|     35|      }
12707|    232|    } else if (i < len) {
  ------------------
  |  Branch (12707:16): [True: 0, False: 232]
  ------------------
12708|      0|      return false;
12709|      0|    }
12710|    400|  } else if (first == '?') {
  ------------------
  |  Branch (12710:14): [True: 106, False: 52]
  ------------------
12711|    106|    query_start = 0;
12712|    106|    i = 1;
12713|    106|    scan_query_run(b, i, len);
12714|    106|    if (i < len) {
  ------------------
  |  Branch (12714:9): [True: 88, False: 18]
  ------------------
12715|     88|      if (b[i] != '#') {
  ------------------
  |  Branch (12715:11): [True: 33, False: 55]
  ------------------
12716|     33|        return false;
12717|     33|      }
12718|     55|      hash_start = i;
12719|     55|      ++i;
12720|     55|      scan_hash_run(b, i, len);
12721|     55|      if (i < len) {
  ------------------
  |  Branch (12721:11): [True: 38, False: 17]
  ------------------
12722|     38|        return false;
12723|     38|      }
12724|     55|    }
12725|    106|  } else {
12726|     52|    hash_start = 0;
12727|     52|    i = 1;
12728|     52|    scan_hash_run(b, i, len);
12729|     52|    if (i < len) {
  ------------------
  |  Branch (12729:9): [True: 21, False: 31]
  ------------------
12730|     21|      return false;
12731|     21|    }
12732|     52|  }
12733|       |
12734|    356|  if (has_path && maybe_dot_segment) {
  ------------------
  |  Branch (12734:7): [True: 290, False: 66]
  |  Branch (12734:19): [True: 118, False: 172]
  ------------------
12735|    118|    const std::string_view path_body(input.data() + path_start,
12736|    118|                                     path_end - path_start);
12737|    118|    if (path_has_dot_segment(path_body)) {
  ------------------
  |  Branch (12737:9): [True: 98, False: 20]
  ------------------
12738|     98|      return false;
12739|     98|    }
12740|    118|  }
12741|       |
12742|    258|  out = base;
12743|    258|  out.is_valid = true;
12744|    258|  out.has_opaque_path = false;
12745|       |
12746|    258|  const size_t q_end =
12747|    258|      (hash_start != std::string_view::npos) ? hash_start : len;
  ------------------
  |  Branch (12747:7): [True: 80, False: 178]
  ------------------
12748|    258|  const bool has_query = query_start != std::string_view::npos;
12749|    258|  const bool has_hash = hash_start != std::string_view::npos;
12750|    258|  const std::string_view query =
12751|    258|      has_query ? std::string_view(input.data() + query_start + 1,
  ------------------
  |  Branch (12751:7): [True: 71, False: 187]
  ------------------
12752|     71|                                   q_end - query_start - 1)
12753|    258|                : std::string_view{};
12754|    258|  const std::string_view hash =
12755|    258|      has_hash ? std::string_view(input.data() + hash_start + 1,
  ------------------
  |  Branch (12755:7): [True: 80, False: 178]
  ------------------
12756|     80|                                  len - hash_start - 1)
12757|    258|               : std::string_view{};
12758|       |
12759|       |  if constexpr (is_aggregator) {
12760|       |    if (first == '/' || first == '?' || path_relative) {
12761|       |      out.clear_hash();
12762|       |      out.clear_search();
12763|       |    }
12764|       |    if (first == '/') {
12765|       |      out.update_base_pathname(input.substr(path_start, path_end - path_start));
12766|       |    } else if (path_relative) {
12767|       |      const std::string_view base_path = out.get_pathname();
12768|       |      const size_t slash = base_path.rfind('/');
12769|       |      const std::string_view prefix = (slash == std::string_view::npos)
12770|       |                                          ? std::string_view("/")
12771|       |                                          : base_path.substr(0, slash + 1);
12772|       |      const std::string_view rel(input.data() + path_start,
12773|       |                                 path_end - path_start);
12774|       |      std::string new_path;
12775|       |      new_path.reserve(prefix.size() + rel.size());
12776|       |      new_path.assign(prefix);
12777|       |      new_path.append(rel);
12778|       |      out.update_base_pathname(new_path);
12779|       |    }
12780|       |    if (has_query) {
12781|       |      // Do not use update_base_search: it strips a leading '?' and would
12782|       |      // collapse '??a=b' into '?a=b'.
12783|       |      out.components.search_start = static_cast<uint32_t>(out.buffer.size());
12784|       |      out.buffer += '?';
12785|       |      out.buffer.append(query);
12786|       |    }
12787|       |    if (has_hash) {
12788|       |      out.update_unencoded_base_hash(hash);
12789|       |    }
12790|    258|  } else {
12791|    258|    if (first == '/' || first == '?' || path_relative) {
  ------------------
  |  Branch (12791:9): [True: 33, False: 225]
  |  Branch (12791:25): [True: 35, False: 190]
  |  Branch (12791:41): [True: 159, False: 31]
  ------------------
12792|    227|      out.hash.reset();
12793|    227|    }
12794|    258|    if (first == '/') {
  ------------------
  |  Branch (12794:9): [True: 33, False: 225]
  ------------------
12795|     33|      out.query.reset();
12796|     33|      out.path.assign(input.substr(path_start, path_end - path_start));
12797|    225|    } else if (path_relative) {
  ------------------
  |  Branch (12797:16): [True: 159, False: 66]
  ------------------
12798|    159|      out.query.reset();
12799|    159|      const size_t slash = out.path.rfind('/');
12800|    159|      if (slash == std::string::npos) {
  ------------------
  |  Branch (12800:11): [True: 0, False: 159]
  ------------------
12801|      0|        out.path = '/';
12802|    159|      } else {
12803|    159|        out.path.resize(slash + 1);
12804|    159|      }
12805|    159|      out.path.append(input.substr(path_start, path_end - path_start));
12806|    159|    }
12807|    258|    if (has_query) {
  ------------------
  |  Branch (12807:9): [True: 71, False: 187]
  ------------------
12808|     71|      out.query.emplace(query);
12809|     71|    }
12810|    258|    if (has_hash) {
  ------------------
  |  Branch (12810:9): [True: 80, False: 178]
  ------------------
12811|     80|      out.hash.emplace(hash);
12812|     80|    }
12813|    258|  }
12814|    258|  return true;
12815|    356|}
_ZN3ada6parser25try_parse_simple_relativeINS_14url_aggregatorEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERKT_RS8_:
12638|  4.35k|                                                result_type& out) {
12639|  4.35k|  constexpr bool is_ada_url = std::is_same_v<result_type, ada::url>;
12640|  4.35k|  constexpr bool is_aggregator =
12641|  4.35k|      std::is_same_v<result_type, ada::url_aggregator>;
12642|  4.35k|  static_assert(is_ada_url || is_aggregator);
12643|       |
12644|  4.35k|  if (!base.is_special() || base.type == ada::scheme::type::FILE ||
  ------------------
  |  Branch (12644:7): [True: 2.27k, False: 2.08k]
  |  Branch (12644:29): [True: 348, False: 1.73k]
  ------------------
12645|  2.70k|      base.has_opaque_path || input.empty()) {
  ------------------
  |  Branch (12645:7): [True: 0, False: 1.73k]
  |  Branch (12645:31): [True: 82, False: 1.65k]
  ------------------
12646|  2.70k|    return false;
12647|  2.70k|  }
12648|  1.65k|  const auto* b = reinterpret_cast<const uint8_t*>(input.data());
12649|  1.65k|  const size_t len = input.size();
12650|  1.65k|  const uint8_t first = b[0];
12651|  1.65k|  const bool path_relative = first != '/' && first != '?' && first != '#';
  ------------------
  |  Branch (12651:30): [True: 1.57k, False: 72]
  |  Branch (12651:46): [True: 1.47k, False: 106]
  |  Branch (12651:62): [True: 1.42k, False: 52]
  ------------------
12652|  1.65k|  if (first == '/' && len > 1 && (b[1] == '/' || b[1] == '\\')) {
  ------------------
  |  Branch (12652:7): [True: 72, False: 1.57k]
  |  Branch (12652:23): [True: 60, False: 12]
  |  Branch (12652:35): [True: 4, False: 56]
  |  Branch (12652:50): [True: 1, False: 55]
  ------------------
12653|      5|    return false;
12654|      5|  }
12655|       |  // A ':' before the first / ? # is a scheme, not a path segment.
12656|  1.64k|  if (path_relative) {
  ------------------
  |  Branch (12656:7): [True: 1.42k, False: 225]
  ------------------
12657|  1.42k|    const size_t delim = input.find_first_of("/?#:");
12658|  1.42k|    if (delim != std::string_view::npos && input[delim] == ':') {
  ------------------
  |  Branch (12658:9): [True: 1.22k, False: 200]
  |  Branch (12658:44): [True: 930, False: 290]
  ------------------
12659|    930|      return false;
12660|    930|    }
12661|  1.42k|  }
12662|       |
12663|    715|  size_t i = 0;
12664|    715|  size_t path_start = 0;
12665|    715|  size_t path_end = 0;
12666|    715|  size_t query_start = std::string_view::npos;
12667|    715|  size_t hash_start = std::string_view::npos;
12668|    715|  bool has_path = false;
12669|    715|  bool maybe_dot_segment = false;
12670|       |
12671|    715|  if (first == '/' || path_relative) {
  ------------------
  |  Branch (12671:7): [True: 67, False: 648]
  |  Branch (12671:23): [True: 490, False: 158]
  ------------------
12672|    557|    has_path = true;
12673|    557|    path_start = 0;
12674|    557|    if (first == '/') {
  ------------------
  |  Branch (12674:9): [True: 67, False: 490]
  ------------------
12675|     67|      i = 1;
12676|     67|    }
12677|    557|    scan_path_run(b, i, len, maybe_dot_segment);
12678|    557|    if (i < len) {
  ------------------
  |  Branch (12678:9): [True: 325, False: 232]
  ------------------
12679|    325|      const uint8_t cls = k_path[b[i]];
12680|    325|      if (cls == 2) {
  ------------------
  |  Branch (12680:11): [True: 157, False: 168]
  ------------------
12681|    157|        return false;
12682|    157|      }
12683|    325|    }
12684|    400|    path_end = i;
12685|    400|    if (i < len && b[i] == '?') {
  ------------------
  |  Branch (12685:9): [True: 168, False: 232]
  |  Branch (12685:20): [True: 114, False: 54]
  ------------------
12686|    114|      query_start = i;
12687|    114|      ++i;
12688|    114|      scan_query_run(b, i, len);
12689|    114|      if (i < len) {
  ------------------
  |  Branch (12689:11): [True: 89, False: 25]
  ------------------
12690|     89|        if (b[i] != '#') {
  ------------------
  |  Branch (12690:13): [True: 28, False: 61]
  ------------------
12691|     28|          return false;
12692|     28|        }
12693|     61|        hash_start = i;
12694|     61|        ++i;
12695|     61|        scan_hash_run(b, i, len);
12696|     61|        if (i < len) {
  ------------------
  |  Branch (12696:13): [True: 47, False: 14]
  ------------------
12697|     47|          return false;
12698|     47|        }
12699|     61|      }
12700|    286|    } else if (i < len && b[i] == '#') {
  ------------------
  |  Branch (12700:16): [True: 54, False: 232]
  |  Branch (12700:27): [True: 54, False: 0]
  ------------------
12701|     54|      hash_start = i;
12702|     54|      ++i;
12703|     54|      scan_hash_run(b, i, len);
12704|     54|      if (i < len) {
  ------------------
  |  Branch (12704:11): [True: 35, False: 19]
  ------------------
12705|     35|        return false;
12706|     35|      }
12707|    232|    } else if (i < len) {
  ------------------
  |  Branch (12707:16): [True: 0, False: 232]
  ------------------
12708|      0|      return false;
12709|      0|    }
12710|    400|  } else if (first == '?') {
  ------------------
  |  Branch (12710:14): [True: 106, False: 52]
  ------------------
12711|    106|    query_start = 0;
12712|    106|    i = 1;
12713|    106|    scan_query_run(b, i, len);
12714|    106|    if (i < len) {
  ------------------
  |  Branch (12714:9): [True: 88, False: 18]
  ------------------
12715|     88|      if (b[i] != '#') {
  ------------------
  |  Branch (12715:11): [True: 33, False: 55]
  ------------------
12716|     33|        return false;
12717|     33|      }
12718|     55|      hash_start = i;
12719|     55|      ++i;
12720|     55|      scan_hash_run(b, i, len);
12721|     55|      if (i < len) {
  ------------------
  |  Branch (12721:11): [True: 38, False: 17]
  ------------------
12722|     38|        return false;
12723|     38|      }
12724|     55|    }
12725|    106|  } else {
12726|     52|    hash_start = 0;
12727|     52|    i = 1;
12728|     52|    scan_hash_run(b, i, len);
12729|     52|    if (i < len) {
  ------------------
  |  Branch (12729:9): [True: 21, False: 31]
  ------------------
12730|     21|      return false;
12731|     21|    }
12732|     52|  }
12733|       |
12734|    356|  if (has_path && maybe_dot_segment) {
  ------------------
  |  Branch (12734:7): [True: 290, False: 66]
  |  Branch (12734:19): [True: 118, False: 172]
  ------------------
12735|    118|    const std::string_view path_body(input.data() + path_start,
12736|    118|                                     path_end - path_start);
12737|    118|    if (path_has_dot_segment(path_body)) {
  ------------------
  |  Branch (12737:9): [True: 98, False: 20]
  ------------------
12738|     98|      return false;
12739|     98|    }
12740|    118|  }
12741|       |
12742|    258|  out = base;
12743|    258|  out.is_valid = true;
12744|    258|  out.has_opaque_path = false;
12745|       |
12746|    258|  const size_t q_end =
12747|    258|      (hash_start != std::string_view::npos) ? hash_start : len;
  ------------------
  |  Branch (12747:7): [True: 80, False: 178]
  ------------------
12748|    258|  const bool has_query = query_start != std::string_view::npos;
12749|    258|  const bool has_hash = hash_start != std::string_view::npos;
12750|    258|  const std::string_view query =
12751|    258|      has_query ? std::string_view(input.data() + query_start + 1,
  ------------------
  |  Branch (12751:7): [True: 71, False: 187]
  ------------------
12752|     71|                                   q_end - query_start - 1)
12753|    258|                : std::string_view{};
12754|    258|  const std::string_view hash =
12755|    258|      has_hash ? std::string_view(input.data() + hash_start + 1,
  ------------------
  |  Branch (12755:7): [True: 80, False: 178]
  ------------------
12756|     80|                                  len - hash_start - 1)
12757|    258|               : std::string_view{};
12758|       |
12759|    258|  if constexpr (is_aggregator) {
12760|    258|    if (first == '/' || first == '?' || path_relative) {
  ------------------
  |  Branch (12760:9): [True: 33, False: 225]
  |  Branch (12760:25): [True: 35, False: 190]
  |  Branch (12760:41): [True: 159, False: 31]
  ------------------
12761|    227|      out.clear_hash();
12762|    227|      out.clear_search();
12763|    227|    }
12764|    258|    if (first == '/') {
  ------------------
  |  Branch (12764:9): [True: 33, False: 225]
  ------------------
12765|     33|      out.update_base_pathname(input.substr(path_start, path_end - path_start));
12766|    225|    } else if (path_relative) {
  ------------------
  |  Branch (12766:16): [True: 159, False: 66]
  ------------------
12767|    159|      const std::string_view base_path = out.get_pathname();
12768|    159|      const size_t slash = base_path.rfind('/');
12769|    159|      const std::string_view prefix = (slash == std::string_view::npos)
  ------------------
  |  Branch (12769:39): [True: 0, False: 159]
  ------------------
12770|    159|                                          ? std::string_view("/")
12771|    159|                                          : base_path.substr(0, slash + 1);
12772|    159|      const std::string_view rel(input.data() + path_start,
12773|    159|                                 path_end - path_start);
12774|    159|      std::string new_path;
12775|    159|      new_path.reserve(prefix.size() + rel.size());
12776|    159|      new_path.assign(prefix);
12777|    159|      new_path.append(rel);
12778|    159|      out.update_base_pathname(new_path);
12779|    159|    }
12780|    258|    if (has_query) {
  ------------------
  |  Branch (12780:9): [True: 71, False: 187]
  ------------------
12781|       |      // Do not use update_base_search: it strips a leading '?' and would
12782|       |      // collapse '??a=b' into '?a=b'.
12783|     71|      out.components.search_start = static_cast<uint32_t>(out.buffer.size());
12784|     71|      out.buffer += '?';
12785|     71|      out.buffer.append(query);
12786|     71|    }
12787|    258|    if (has_hash) {
  ------------------
  |  Branch (12787:9): [True: 80, False: 178]
  ------------------
12788|     80|      out.update_unencoded_base_hash(hash);
12789|     80|    }
12790|       |  } else {
12791|       |    if (first == '/' || first == '?' || path_relative) {
12792|       |      out.hash.reset();
12793|       |    }
12794|       |    if (first == '/') {
12795|       |      out.query.reset();
12796|       |      out.path.assign(input.substr(path_start, path_end - path_start));
12797|       |    } else if (path_relative) {
12798|       |      out.query.reset();
12799|       |      const size_t slash = out.path.rfind('/');
12800|       |      if (slash == std::string::npos) {
12801|       |        out.path = '/';
12802|       |      } else {
12803|       |        out.path.resize(slash + 1);
12804|       |      }
12805|       |      out.path.append(input.substr(path_start, path_end - path_start));
12806|       |    }
12807|       |    if (has_query) {
12808|       |      out.query.emplace(query);
12809|       |    }
12810|       |    if (has_hash) {
12811|       |      out.hash.emplace(hash);
12812|       |    }
12813|       |  }
12814|    258|  return true;
12815|    356|}
_ZN3ada6parser14parse_url_implINS_3urlELb1EEET_NSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEPKS3_:
12819|  49.0k|                           const result_type* base_url) {
12820|       |  // We can specialize the implementation per type.
12821|       |  // Important: result_type_is_ada_url is evaluated at *compile time*. This
12822|       |  // means that doing if constexpr(result_type_is_ada_url) { something } else {
12823|       |  // something else } is free (at runtime). This means that ada::url_aggregator
12824|       |  // and ada::url **do not have to support the exact same API**.
12825|  49.0k|  constexpr bool result_type_is_ada_url = std::is_same_v<url, result_type>;
12826|  49.0k|  constexpr bool result_type_is_ada_url_aggregator =
12827|  49.0k|      std::is_same_v<url_aggregator, result_type>;
12828|  49.0k|  static_assert(result_type_is_ada_url ||
12829|  49.0k|                result_type_is_ada_url_aggregator);  // We don't support
12830|       |                                                     // anything else for now.
12831|       |
12832|  49.0k|  ada_log("ada::parser::parse_url('", user_input, "' [", user_input.size(),
12833|  49.0k|          " bytes],", (base_url != nullptr ? base_url->to_string() : "null"),
12834|  49.0k|          ")");
12835|       |
12836|  49.0k|  result_type url{};
12837|       |
12838|  49.0k|  const uint32_t max_input_length = ada::get_max_input_length();
12839|       |
12840|       |  // Normalization (percent-encoding, IDNA) can push the serialized URL past
12841|       |  // max_input_length even when the input fit under it. The check at the end of
12842|       |  // the state machine covers URLs that run to completion, but several states
12843|       |  // return early after appending a query or fragment, so run the same check on
12844|       |  // those exits too. Without this, a query- or fragment-terminated URL such as
12845|       |  // file://x/?<...> or https://user@x/?<...> is accepted while the equivalent
12846|       |  // https://x/?<...> that takes the absolute fast path is rejected.
12847|  49.0k|  const auto enforce_max_input_length = [&]() {
12848|  49.0k|    if constexpr (store_values) {
12849|  49.0k|      if (url.is_valid) {
12850|  49.0k|        if constexpr (result_type_is_ada_url_aggregator) {
12851|  49.0k|          if (url.buffer.size() > max_input_length) [[unlikely]] {
12852|  49.0k|            url.is_valid = false;
12853|  49.0k|          }
12854|  49.0k|        } else {
12855|  49.0k|          if (url.get_href_size() > max_input_length) [[unlikely]] {
12856|  49.0k|            url.is_valid = false;
12857|  49.0k|          }
12858|  49.0k|        }
12859|  49.0k|      }
12860|  49.0k|    }
12861|  49.0k|  };
12862|       |
12863|       |  // We refuse to parse URL strings that exceed the maximum input length.
12864|       |  // By default, this is 4GB but can be configured via
12865|       |  // ada::set_max_input_length().
12866|  49.0k|  if (user_input.size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (12866:7): [True: 0, False: 49.0k]
  ------------------
12867|      0|    url.is_valid = false;
12868|      0|  }
12869|       |  // Going forward, user_input.size() is in [0,
12870|       |  // std::numeric_limits<uint32_t>::max). If we are provided with an invalid
12871|       |  // base, or the optional_url was invalid, we must return.
12872|  49.0k|  if (base_url != nullptr) {
  ------------------
  |  Branch (12872:7): [True: 4.35k, False: 44.6k]
  ------------------
12873|  4.35k|    url.is_valid &= base_url->is_valid;
12874|  4.35k|  }
12875|  49.0k|  if (!url.is_valid) {
  ------------------
  |  Branch (12875:7): [True: 0, False: 49.0k]
  ------------------
12876|      0|    return url;
12877|      0|  }
12878|       |
12879|       |  // Simple absolute / relative fast paths (before tabs/newline scan).
12880|  49.0k|  if constexpr (store_values) {
12881|  49.0k|    bool hit_fast_path = false;
12882|  49.0k|    if (base_url == nullptr) {
  ------------------
  |  Branch (12882:9): [True: 44.6k, False: 4.35k]
  ------------------
12883|       |      // IPv4/IPv6 and userinfo miss the fast path. Skip the never_inline
12884|       |      // call so those URLs (including SetHref) do not pay for a miss.
12885|  44.6k|      const auto* p = reinterpret_cast<const uint8_t*>(user_input.data());
12886|  44.6k|      const size_t n = user_input.size();
12887|  44.6k|      size_t host_start = 0;
12888|  44.6k|      if (n >= 8 && p[4] == ':' && p[5] == '/' && p[6] == '/') {
  ------------------
  |  Branch (12888:11): [True: 17.4k, False: 27.1k]
  |  Branch (12888:21): [True: 3.13k, False: 14.3k]
  |  Branch (12888:36): [True: 2.27k, False: 861]
  |  Branch (12888:51): [True: 2.24k, False: 31]
  ------------------
12889|  2.24k|        host_start = 7;
12890|  42.4k|      } else if (n >= 9 && p[5] == ':' && p[6] == '/' && p[7] == '/') {
  ------------------
  |  Branch (12890:18): [True: 13.8k, False: 28.5k]
  |  Branch (12890:28): [True: 240, False: 13.6k]
  |  Branch (12890:43): [True: 48, False: 192]
  |  Branch (12890:58): [True: 28, False: 20]
  ------------------
12891|     28|        host_start = 8;
12892|     28|      }
12893|  44.6k|      const uint8_t host_first = host_start != 0 ? p[host_start] : 0;
  ------------------
  |  Branch (12893:34): [True: 2.27k, False: 42.3k]
  ------------------
12894|  44.6k|      const bool skip_ip =
12895|  44.6k|          host_first == '[' || (host_first >= '0' && host_first <= '9');
  ------------------
  |  Branch (12895:11): [True: 17, False: 44.6k]
  |  Branch (12895:33): [True: 1.68k, False: 42.9k]
  |  Branch (12895:54): [True: 590, False: 1.09k]
  ------------------
12896|  44.6k|      const bool skip_userinfo =
12897|  44.6k|          host_start != 0 && authority_has_at(p, host_start, n);
  ------------------
  |  Branch (12897:11): [True: 2.27k, False: 42.3k]
  |  Branch (12897:30): [True: 24, False: 2.25k]
  ------------------
12898|  44.6k|      hit_fast_path = !skip_ip && !skip_userinfo &&
  ------------------
  |  Branch (12898:23): [True: 44.0k, False: 607]
  |  Branch (12898:35): [True: 44.0k, False: 22]
  ------------------
12899|  44.0k|                      try_parse_simple_absolute(user_input, url);
  ------------------
  |  Branch (12899:23): [True: 4.99k, False: 39.0k]
  ------------------
12900|  44.6k|    } else {
12901|  4.35k|      hit_fast_path = try_parse_simple_relative(user_input, *base_url, url);
12902|  4.35k|    }
12903|  49.0k|    if (hit_fast_path) {
  ------------------
  |  Branch (12903:9): [True: 5.25k, False: 43.7k]
  ------------------
12904|       |      if constexpr (result_type_is_ada_url_aggregator) {
12905|       |        if (url.buffer.size() > max_input_length) [[unlikely]] {
12906|       |          url.is_valid = false;
12907|       |        }
12908|  5.25k|      } else {
12909|       |        // For a small absolute input, even worst-case normalization cannot
12910|       |        // exceed the limit: percent encoding expands at most 3x and IDNA at
12911|       |        // most 4.5x. Avoid traversing every stored component on the common
12912|       |        // default-limit path.
12913|  5.25k|        if ((base_url != nullptr ||
  ------------------
  |  Branch (12913:14): [True: 258, False: 4.99k]
  ------------------
12914|  4.99k|             user_input.size() > static_cast<size_t>(max_input_length) / 5) &&
  ------------------
  |  Branch (12914:14): [True: 0, False: 4.99k]
  ------------------
12915|    258|            url.get_href_size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (12915:13): [True: 0, False: 258]
  ------------------
12916|      0|          url.is_valid = false;
12917|      0|        }
12918|  5.25k|      }
12919|  5.25k|      return url;
12920|  5.25k|    }
12921|  49.0k|  }
12922|       |
12923|  43.7k|  state state = state::SCHEME_START;
12924|       |
12925|  49.0k|  std::string tmp_buffer;
12926|  49.0k|  std::string_view url_data;
12927|  49.0k|  if (unicode::has_tabs_or_newline(user_input)) [[unlikely]] {
  ------------------
  |  Branch (12927:7): [True: 404, False: 48.6k]
  ------------------
12928|    404|    tmp_buffer = user_input;
12929|       |    // Optimization opportunity: Instead of copying and then pruning, we could
12930|       |    // just directly build the string from user_input.
12931|    404|    helpers::remove_ascii_tab_or_newline(tmp_buffer);
12932|    404|    url_data = tmp_buffer;
12933|  48.6k|  } else [[likely]] {
12934|  48.6k|    url_data = user_input;
12935|  48.6k|  }
12936|       |
12937|       |  // Leading and trailing control characters are uncommon and easy to deal with
12938|       |  // (no performance concern).
12939|  49.0k|  helpers::trim_c0_whitespace(url_data);
12940|       |
12941|       |  if constexpr (result_type_is_ada_url_aggregator && store_values) {
12942|       |    // Most of the time, we just need user_input.size().
12943|       |    // In some instances, we may need a bit more.
12944|       |    ///////////////////////////
12945|       |    // This is *very* important. This line should *not* be removed
12946|       |    // hastily. There are principled reasons why reserve is important
12947|       |    // for performance. If you have a benchmark with small inputs,
12948|       |    // it may not matter, but in other instances, it could.
12949|       |    ////
12950|       |    // This rounds up to the next power of two.
12951|       |    // We know that user_input.size() is in [0,
12952|       |    // std::numeric_limits<uint32_t>::max).
12953|       |    uint32_t reserve_capacity =
12954|       |        (0xFFFFFFFF >>
12955|       |         helpers::leading_zeroes(uint32_t(1 | user_input.size()))) +
12956|       |        1;
12957|       |    url.reserve(reserve_capacity);
12958|       |  }
12959|       |
12960|       |  // Optimization opportunity. Most websites do not have fragment.
12961|  49.0k|  std::optional<std::string_view> fragment = helpers::prune_hash(url_data);
12962|       |  // We add it last so that an implementation like ada::url_aggregator
12963|       |  // can append it last to its internal buffer, thus improving performance.
12964|       |
12965|       |  // Here url_data no longer has its fragment.
12966|       |  // We are going to access the data from url_data (it is immutable).
12967|       |  // At any given time, we are pointing at byte 'input_position' in url_data.
12968|       |  // The input_position variable should range from 0 to input_size.
12969|       |  // It is illegal to access url_data at input_size.
12970|  49.0k|  size_t input_position = 0;
12971|  49.0k|  const size_t input_size = url_data.size();
12972|       |  // Keep running the following state machine by switching on state.
12973|       |  // If after a run pointer points to the EOF code point, go to the next step.
12974|       |  // Otherwise, increase pointer by 1 and continue with the state machine.
12975|       |  // We never decrement input_position.
12976|   181k|  while (input_position <= input_size) {
  ------------------
  |  Branch (12976:10): [True: 164k, False: 16.4k]
  ------------------
12977|   164k|    ada_log("In parsing at ", input_position, " out of ", input_size,
12978|   164k|            " in state ", ada::to_string(state));
12979|   164k|    switch (state) {
12980|  43.7k|      case state::SCHEME_START: {
  ------------------
  |  Branch (12980:7): [True: 43.7k, False: 121k]
  ------------------
12981|  43.7k|        ada_log("SCHEME_START ", helpers::substring(url_data, input_position));
12982|       |        // If c is an ASCII alpha, append c, lowercased, to buffer, and set
12983|       |        // state to scheme state.
12984|  43.7k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (12984:13): [True: 23.2k, False: 20.5k]
  ------------------
12985|  23.2k|            checkers::is_alpha(url_data[input_position])) {
  ------------------
  |  Branch (12985:13): [True: 21.7k, False: 1.42k]
  ------------------
12986|  21.7k|          state = state::SCHEME;
12987|  21.7k|          input_position++;
12988|  21.9k|        } else {
12989|       |          // Otherwise, if state override is not given, set state to no scheme
12990|       |          // state and decrease pointer by 1.
12991|  21.9k|          state = state::NO_SCHEME;
12992|  21.9k|        }
12993|  43.7k|        break;
12994|      0|      }
12995|  21.7k|      case state::SCHEME: {
  ------------------
  |  Branch (12995:7): [True: 21.7k, False: 143k]
  ------------------
12996|  21.7k|        ada_log("SCHEME ", helpers::substring(url_data, input_position));
12997|       |        // If c is an ASCII alphanumeric, U+002B (+), U+002D (-), or U+002E (.),
12998|       |        // append c, lowercased, to buffer.
12999|  53.3k|        while ((input_position != input_size) &&
  ------------------
  |  Branch (12999:16): [True: 53.0k, False: 319]
  ------------------
13000|  53.0k|               (unicode::is_alnum_plus(url_data[input_position]))) {
  ------------------
  |  Branch (13000:16): [True: 31.5k, False: 21.4k]
  ------------------
13001|  31.5k|          input_position++;
13002|  31.5k|        }
13003|       |        // Otherwise, if c is U+003A (:), then:
13004|  21.7k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13004:13): [True: 21.4k, False: 319]
  ------------------
13005|  21.4k|            (url_data[input_position] == ':')) {
  ------------------
  |  Branch (13005:13): [True: 21.0k, False: 420]
  ------------------
13006|  21.0k|          ada_log("SCHEME the scheme should be ",
13007|  21.0k|                  url_data.substr(0, input_position));
13008|  21.0k|          if constexpr (result_type_is_ada_url) {
13009|  21.0k|            if (!url.parse_scheme(url_data.substr(0, input_position))) {
  ------------------
  |  Branch (13009:17): [True: 0, False: 21.0k]
  ------------------
13010|      0|              return url;
13011|      0|            }
13012|       |          } else {
13013|       |            // we pass the colon along instead of painfully adding it back.
13014|       |            if (!url.parse_scheme_with_colon(
13015|       |                    url_data.substr(0, input_position + 1))) {
13016|       |              return url;
13017|       |            }
13018|       |          }
13019|  21.0k|          ada_log("SCHEME the scheme is ", url.get_protocol());
13020|       |
13021|       |          // If url's scheme is "file", then:
13022|       |          // NOLINTNEXTLINE(bugprone-branch-clone)
13023|  21.0k|          if (url.type == scheme::type::FILE) {
  ------------------
  |  Branch (13023:15): [True: 2.56k, False: 18.4k]
  ------------------
13024|       |            // Set state to file state.
13025|  2.56k|            state = state::FILE;
13026|  2.56k|          }
13027|       |          // Otherwise, if url is special, base is non-null, and base's scheme
13028|       |          // is url's scheme: Note: Doing base_url->scheme is unsafe if base_url
13029|       |          // != nullptr is false.
13030|  18.4k|          else if (url.is_special() && base_url != nullptr &&
  ------------------
  |  Branch (13030:20): [True: 13.1k, False: 5.37k]
  |  Branch (13030:40): [True: 2.24k, False: 10.8k]
  ------------------
13031|  2.24k|                   base_url->type == url.type) {
  ------------------
  |  Branch (13031:20): [True: 414, False: 1.82k]
  ------------------
13032|       |            // Set state to special relative or authority state.
13033|    414|            state = state::SPECIAL_RELATIVE_OR_AUTHORITY;
13034|    414|          }
13035|       |          // Otherwise, if url is special, set state to special authority
13036|       |          // slashes state.
13037|  18.0k|          else if (url.is_special()) {
  ------------------
  |  Branch (13037:20): [True: 12.6k, False: 5.37k]
  ------------------
13038|  12.6k|            state = state::SPECIAL_AUTHORITY_SLASHES;
13039|  12.6k|          }
13040|       |          // Otherwise, if remaining starts with an U+002F (/), set state to
13041|       |          // path or authority state and increase pointer by 1.
13042|  5.37k|          else if (input_position + 1 < input_size &&
  ------------------
  |  Branch (13042:20): [True: 3.10k, False: 2.27k]
  ------------------
13043|  3.10k|                   url_data[input_position + 1] == '/') {
  ------------------
  |  Branch (13043:20): [True: 2.19k, False: 906]
  ------------------
13044|  2.19k|            state = state::PATH_OR_AUTHORITY;
13045|  2.19k|            input_position++;
13046|  2.19k|          }
13047|       |          // Otherwise, set url's path to the empty string and set state to
13048|       |          // opaque path state.
13049|  3.17k|          else {
13050|  3.17k|            state = state::OPAQUE_PATH;
13051|  3.17k|          }
13052|  21.0k|        }
13053|       |        // Otherwise, if state override is not given, set buffer to the empty
13054|       |        // string, state to no scheme state, and start over (from the first code
13055|       |        // point in input).
13056|    739|        else {
13057|    739|          state = state::NO_SCHEME;
13058|    739|          input_position = 0;
13059|    739|          break;
13060|    739|        }
13061|  21.0k|        input_position++;
13062|  21.0k|        break;
13063|  21.7k|      }
13064|  22.7k|      case state::NO_SCHEME: {
  ------------------
  |  Branch (13064:7): [True: 22.7k, False: 142k]
  ------------------
13065|  22.7k|        ada_log("NO_SCHEME ", helpers::substring(url_data, input_position));
13066|       |        // The fragment was pruned from url_data before the state machine ran,
13067|       |        // so 'c is U+0023 (#)' holds exactly when a fragment was found and
13068|       |        // nothing else remains in front of it.
13069|  22.7k|        const bool c_is_hash =
13070|  22.7k|            fragment.has_value() && input_position == input_size;
  ------------------
  |  Branch (13070:13): [True: 501, False: 22.2k]
  |  Branch (13070:37): [True: 173, False: 328]
  ------------------
13071|       |        // If base is null, or base has an opaque path and c is not U+0023 (#),
13072|       |        // validation error, return failure.
13073|  22.7k|        if (base_url == nullptr || (base_url->has_opaque_path && !c_is_hash)) {
  ------------------
  |  Branch (13073:13): [True: 21.6k, False: 1.04k]
  |  Branch (13073:37): [True: 95, False: 954]
  |  Branch (13073:66): [True: 50, False: 45]
  ------------------
13074|  21.7k|          ada_log("NO_SCHEME validation error");
13075|  21.7k|          url.is_valid = false;
13076|  21.7k|          return url;
13077|  21.7k|        }
13078|       |        // Otherwise, if base has an opaque path and c is U+0023 (#),
13079|       |        // set url's scheme to base's scheme, url's path to base's path, url's
13080|       |        // query to base's query, and set state to fragment state.
13081|    999|        else if (base_url->has_opaque_path && c_is_hash) {
  ------------------
  |  Branch (13081:18): [True: 45, False: 954]
  |  Branch (13081:47): [True: 45, False: 0]
  ------------------
13082|     45|          ada_log("NO_SCHEME opaque base with fragment");
13083|     45|          url.copy_scheme(*base_url);
13084|     45|          url.has_opaque_path = base_url->has_opaque_path;
13085|       |
13086|     45|          if constexpr (result_type_is_ada_url) {
13087|     45|            url.path = base_url->path;
13088|     45|            url.query = base_url->query;
13089|       |          } else {
13090|       |            url.update_base_pathname(base_url->get_pathname());
13091|       |            if (base_url->has_search()) {
13092|       |              // get_search() returns "" for an empty query string (URL ends
13093|       |              // with '?'). update_base_search("") would incorrectly clear the
13094|       |              // query, so pass "?" to preserve the empty query distinction.
13095|       |              auto s = base_url->get_search();
13096|       |              url.update_base_search(s.empty() ? std::string_view("?") : s);
13097|       |            }
13098|       |          }
13099|     45|          url.update_unencoded_base_hash(*fragment);
13100|     45|          enforce_max_input_length();
13101|     45|          return url;
13102|     45|        }
13103|       |        // Otherwise, if base's scheme is not "file", set state to relative
13104|       |        // state and decrease pointer by 1.
13105|       |        // NOLINTNEXTLINE(bugprone-branch-clone)
13106|    954|        else if (base_url->type != scheme::type::FILE) {
  ------------------
  |  Branch (13106:18): [True: 745, False: 209]
  ------------------
13107|    745|          ada_log("NO_SCHEME non-file relative path");
13108|    745|          state = state::RELATIVE_SCHEME;
13109|    745|        }
13110|       |        // Otherwise, set state to file state and decrease pointer by 1.
13111|    209|        else {
13112|    209|          ada_log("NO_SCHEME file base type");
13113|    209|          state = state::FILE;
13114|    209|        }
13115|    954|        break;
13116|  22.7k|      }
13117|  13.9k|      case state::AUTHORITY: {
  ------------------
  |  Branch (13117:7): [True: 13.9k, False: 150k]
  ------------------
13118|  13.9k|        ada_log("AUTHORITY ", helpers::substring(url_data, input_position));
13119|       |        // most URLs have no @. Having no @ tells us that we don't have to worry
13120|       |        // about AUTHORITY. Of course, we could have @ and still not have to
13121|       |        // worry about AUTHORITY.
13122|       |        // TODO: Instead of just collecting a bool, collect the location of the
13123|       |        // '@' and do something useful with it.
13124|       |        // TODO: We could do various processing early on, using a single pass
13125|       |        // over the string to collect information about it, e.g., telling us
13126|       |        // whether there is a @ and if so, where (or how many).
13127|       |
13128|       |        // Check if url data contains an @.
13129|  13.9k|        if (url_data.find('@', input_position) == std::string_view::npos) {
  ------------------
  |  Branch (13129:13): [True: 12.7k, False: 1.22k]
  ------------------
13130|  12.7k|          state = state::HOST;
13131|  12.7k|          break;
13132|  12.7k|        }
13133|  1.22k|        bool at_sign_seen{false};
13134|  1.22k|        bool password_token_seen{false};
13135|       |        /**
13136|       |         * We expect something of the sort...
13137|       |         * https://user:pass@example.com:1234/foo/bar?baz#quux
13138|       |         * --------^
13139|       |         */
13140|  7.59k|        do {
13141|  7.59k|          std::string_view view = url_data.substr(input_position);
13142|       |          // The delimiters are @, /, ? \\.
13143|  7.59k|          size_t location =
13144|  7.59k|              url.is_special() ? helpers::find_authority_delimiter_special(view)
  ------------------
  |  Branch (13144:15): [True: 6.86k, False: 730]
  ------------------
13145|  7.59k|                               : helpers::find_authority_delimiter(view);
13146|  7.59k|          std::string_view authority_view = view.substr(0, location);
13147|  7.59k|          size_t end_of_authority = input_position + authority_view.size();
13148|       |          // If c is U+0040 (@), then:
13149|  7.59k|          if ((end_of_authority != input_size) &&
  ------------------
  |  Branch (13149:15): [True: 6.82k, False: 776]
  ------------------
13150|  6.82k|              (url_data[end_of_authority] == '@')) {
  ------------------
  |  Branch (13150:15): [True: 6.37k, False: 449]
  ------------------
13151|       |            // If atSignSeen is true, then prepend "%40" to buffer.
13152|  6.37k|            if (at_sign_seen) {
  ------------------
  |  Branch (13152:17): [True: 5.29k, False: 1.08k]
  ------------------
13153|  5.29k|              if (password_token_seen) {
  ------------------
  |  Branch (13153:19): [True: 2.21k, False: 3.07k]
  ------------------
13154|  2.21k|                if constexpr (result_type_is_ada_url) {
13155|  2.21k|                  url.password += "%40";
13156|       |                } else {
13157|       |                  url.append_base_password("%40");
13158|       |                }
13159|  3.07k|              } else {
13160|  3.07k|                if constexpr (result_type_is_ada_url) {
13161|  3.07k|                  url.username += "%40";
13162|       |                } else {
13163|       |                  url.append_base_username("%40");
13164|       |                }
13165|  3.07k|              }
13166|  5.29k|            }
13167|       |
13168|  6.37k|            at_sign_seen = true;
13169|       |
13170|  6.37k|            if (!password_token_seen) {
  ------------------
  |  Branch (13170:17): [True: 4.15k, False: 2.21k]
  ------------------
13171|  4.15k|              size_t password_token_location = authority_view.find(':');
13172|  4.15k|              password_token_seen =
13173|  4.15k|                  password_token_location != std::string_view::npos;
13174|       |
13175|  4.15k|              if constexpr (store_values) {
13176|  4.15k|                if (!password_token_seen) {
  ------------------
  |  Branch (13176:21): [True: 3.75k, False: 401]
  ------------------
13177|  3.75k|                  if constexpr (result_type_is_ada_url) {
13178|  3.75k|                    url.username += unicode::percent_encode(
13179|  3.75k|                        authority_view,
13180|  3.75k|                        character_sets::USERINFO_PERCENT_ENCODE);
13181|       |                  } else {
13182|       |                    url.append_base_username(unicode::percent_encode(
13183|       |                        authority_view,
13184|       |                        character_sets::USERINFO_PERCENT_ENCODE));
13185|       |                  }
13186|  3.75k|                } else {
13187|    401|                  if constexpr (result_type_is_ada_url) {
13188|    401|                    url.username += unicode::percent_encode(
13189|    401|                        authority_view.substr(0, password_token_location),
13190|    401|                        character_sets::USERINFO_PERCENT_ENCODE);
13191|    401|                    url.password += unicode::percent_encode(
13192|    401|                        authority_view.substr(password_token_location + 1),
13193|    401|                        character_sets::USERINFO_PERCENT_ENCODE);
13194|       |                  } else {
13195|       |                    url.append_base_username(unicode::percent_encode(
13196|       |                        authority_view.substr(0, password_token_location),
13197|       |                        character_sets::USERINFO_PERCENT_ENCODE));
13198|       |                    url.append_base_password(unicode::percent_encode(
13199|       |                        authority_view.substr(password_token_location + 1),
13200|       |                        character_sets::USERINFO_PERCENT_ENCODE));
13201|       |                  }
13202|    401|                }
13203|  4.15k|              }
13204|  4.15k|            } else if constexpr (store_values) {
13205|  2.21k|              if constexpr (result_type_is_ada_url) {
13206|  2.21k|                url.password += unicode::percent_encode(
13207|  2.21k|                    authority_view, character_sets::USERINFO_PERCENT_ENCODE);
13208|       |              } else {
13209|       |                url.append_base_password(unicode::percent_encode(
13210|       |                    authority_view, character_sets::USERINFO_PERCENT_ENCODE));
13211|       |              }
13212|  2.21k|            }
13213|  6.37k|          }
13214|       |          // Otherwise, if one of the following is true:
13215|       |          // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
13216|       |          // - url is special and c is U+005C (\)
13217|  1.22k|          else if (end_of_authority == input_size ||
  ------------------
  |  Branch (13217:20): [True: 776, False: 449]
  ------------------
13218|    449|                   url_data[end_of_authority] == '/' ||
  ------------------
  |  Branch (13218:20): [True: 406, False: 43]
  ------------------
13219|     43|                   url_data[end_of_authority] == '?' ||
  ------------------
  |  Branch (13219:20): [True: 36, False: 7]
  ------------------
13220|  1.22k|                   (url.is_special() && url_data[end_of_authority] == '\\')) {
  ------------------
  |  Branch (13220:21): [True: 7, False: 0]
  |  Branch (13220:41): [True: 7, False: 0]
  ------------------
13221|       |            // If atSignSeen is true and authority_view is the empty string,
13222|       |            // validation error, return failure.
13223|  1.22k|            if (at_sign_seen && authority_view.empty()) {
  ------------------
  |  Branch (13223:17): [True: 1.08k, False: 143]
  |  Branch (13223:33): [True: 337, False: 745]
  ------------------
13224|    337|              url.is_valid = false;
13225|    337|              return url;
13226|    337|            }
13227|    888|            state = state::HOST;
13228|    888|            break;
13229|  1.22k|          }
13230|  6.37k|          if (end_of_authority == input_size) {
  ------------------
  |  Branch (13230:15): [True: 0, False: 6.37k]
  ------------------
13231|      0|            if constexpr (store_values) {
13232|      0|              if (fragment.has_value()) {
  ------------------
  |  Branch (13232:19): [True: 0, False: 0]
  ------------------
13233|      0|                url.update_unencoded_base_hash(*fragment);
13234|      0|              }
13235|      0|            }
13236|      0|            enforce_max_input_length();
13237|      0|            return url;
13238|      0|          }
13239|  6.37k|          input_position = end_of_authority + 1;
13240|  6.37k|        } while (true);
  ------------------
  |  Branch (13240:18): [True: 6.37k, Folded]
  ------------------
13241|       |
13242|    888|        break;
13243|  1.22k|      }
13244|    888|      case state::SPECIAL_RELATIVE_OR_AUTHORITY: {
  ------------------
  |  Branch (13244:7): [True: 414, False: 164k]
  ------------------
13245|    414|        ada_log("SPECIAL_RELATIVE_OR_AUTHORITY ",
13246|    414|                helpers::substring(url_data, input_position));
13247|       |
13248|       |        // If c is U+002F (/) and remaining starts with U+002F (/),
13249|       |        // then set state to special authority ignore slashes state and increase
13250|       |        // pointer by 1.
13251|    414|        if (url_data.substr(input_position, 2) == "//") {
  ------------------
  |  Branch (13251:13): [True: 342, False: 72]
  ------------------
13252|    342|          state = state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
13253|    342|          input_position += 2;
13254|    342|        } else {
13255|       |          // Otherwise, validation error, set state to relative state and
13256|       |          // decrease pointer by 1.
13257|     72|          state = state::RELATIVE_SCHEME;
13258|     72|        }
13259|       |
13260|    414|        break;
13261|  1.22k|      }
13262|  2.19k|      case state::PATH_OR_AUTHORITY: {
  ------------------
  |  Branch (13262:7): [True: 2.19k, False: 162k]
  ------------------
13263|  2.19k|        ada_log("PATH_OR_AUTHORITY ",
13264|  2.19k|                helpers::substring(url_data, input_position));
13265|       |
13266|       |        // If c is U+002F (/), then set state to authority state.
13267|  2.19k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13267:13): [True: 2.08k, False: 110]
  ------------------
13268|  2.08k|            (url_data[input_position] == '/')) {
  ------------------
  |  Branch (13268:13): [True: 887, False: 1.19k]
  ------------------
13269|    887|          state = state::AUTHORITY;
13270|    887|          input_position++;
13271|  1.30k|        } else {
13272|       |          // Otherwise, set state to path state, and decrease pointer by 1.
13273|  1.30k|          state = state::PATH;
13274|  1.30k|        }
13275|       |
13276|  2.19k|        break;
13277|  1.22k|      }
13278|    817|      case state::RELATIVE_SCHEME: {
  ------------------
  |  Branch (13278:7): [True: 817, False: 164k]
  ------------------
13279|    817|        ada_log("RELATIVE_SCHEME ",
13280|    817|                helpers::substring(url_data, input_position));
13281|       |
13282|       |        // Set url's scheme to base's scheme.
13283|    817|        url.copy_scheme(*base_url);
13284|       |
13285|       |        // If c is U+002F (/), then set state to relative slash state.
13286|    817|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13286:13): [True: 669, False: 148]
  ------------------
13287|       |            // NOLINTNEXTLINE(bugprone-branch-clone)
13288|    669|            (url_data[input_position] == '/')) {
  ------------------
  |  Branch (13288:13): [True: 68, False: 601]
  ------------------
13289|     68|          ada_log(
13290|     68|              "RELATIVE_SCHEME if c is U+002F (/), then set state to relative "
13291|     68|              "slash state");
13292|     68|          state = state::RELATIVE_SLASH;
13293|    749|        } else if (url.is_special() && (input_position != input_size) &&
  ------------------
  |  Branch (13293:20): [True: 614, False: 135]
  |  Branch (13293:40): [True: 507, False: 107]
  ------------------
13294|    507|                   (url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13294:20): [True: 2, False: 505]
  ------------------
13295|       |          // Otherwise, if url is special and c is U+005C (\), validation error,
13296|       |          // set state to relative slash state.
13297|      2|          ada_log(
13298|      2|              "RELATIVE_SCHEME  if url is special and c is U+005C, validation "
13299|      2|              "error, set state to relative slash state");
13300|      2|          state = state::RELATIVE_SLASH;
13301|    747|        } else {
13302|    747|          ada_log("RELATIVE_SCHEME otherwise");
13303|       |          // Set url's username to base's username, url's password to base's
13304|       |          // password, url's host to base's host, url's port to base's port,
13305|       |          // url's path to a clone of base's path, and url's query to base's
13306|       |          // query.
13307|    747|          if constexpr (result_type_is_ada_url) {
13308|    747|            url.username = base_url->username;
13309|    747|            url.password = base_url->password;
13310|    747|            url.host = base_url->host;
13311|    747|            url.port = base_url->port;
13312|       |            // cloning the base path includes cloning the has_opaque_path flag
13313|    747|            url.has_opaque_path = base_url->has_opaque_path;
13314|    747|            url.path = base_url->path;
13315|    747|            url.query = base_url->query;
13316|       |          } else {
13317|       |            url.update_base_authority(base_url->get_href(),
13318|       |                                      base_url->get_components());
13319|       |            url.update_host_to_base_host(base_url->get_hostname());
13320|       |            url.update_base_port(base_url->retrieve_base_port());
13321|       |            // cloning the base path includes cloning the has_opaque_path flag
13322|       |            url.has_opaque_path = base_url->has_opaque_path;
13323|       |            url.update_base_pathname(base_url->get_pathname());
13324|       |            if (base_url->has_search()) {
13325|       |              // get_search() returns "" for an empty query string (URL ends
13326|       |              // with '?'). update_base_search("") would incorrectly clear the
13327|       |              // query, so pass "?" to preserve the empty query distinction.
13328|       |              auto s = base_url->get_search();
13329|       |              url.update_base_search(s.empty() ? std::string_view("?") : s);
13330|       |            }
13331|       |          }
13332|       |
13333|    747|          url.has_opaque_path = base_url->has_opaque_path;
13334|       |
13335|       |          // If c is U+003F (?), then set url's query to the empty string, and
13336|       |          // state to query state.
13337|    747|          if ((input_position != input_size) &&
  ------------------
  |  Branch (13337:15): [True: 599, False: 148]
  ------------------
13338|    599|              (url_data[input_position] == '?')) {
  ------------------
  |  Branch (13338:15): [True: 80, False: 519]
  ------------------
13339|     80|            state = state::QUERY;
13340|     80|          }
13341|       |          // Otherwise, if c is not the EOF code point:
13342|    667|          else if (input_position != input_size) {
  ------------------
  |  Branch (13342:20): [True: 519, False: 148]
  ------------------
13343|       |            // Set url's query to null.
13344|    519|            url.clear_search();
13345|    519|            if constexpr (result_type_is_ada_url) {
13346|       |              // Shorten url's path.
13347|    519|              helpers::shorten_path(url.path, url.type);
13348|       |            } else {
13349|       |              std::string_view path = url.get_pathname();
13350|       |              if (helpers::shorten_path(path, url.type)) {
13351|       |                url.update_base_pathname(std::move(std::string(path)));
13352|       |              }
13353|       |            }
13354|       |            // Set state to path state and decrease pointer by 1.
13355|    519|            state = state::PATH;
13356|    519|            break;
13357|    519|          }
13358|    747|        }
13359|    298|        input_position++;
13360|    298|        break;
13361|    817|      }
13362|     70|      case state::RELATIVE_SLASH: {
  ------------------
  |  Branch (13362:7): [True: 70, False: 164k]
  ------------------
13363|     70|        ada_log("RELATIVE_SLASH ",
13364|     70|                helpers::substring(url_data, input_position));
13365|       |
13366|       |        // If url is special and c is U+002F (/) or U+005C (\), then:
13367|       |        // NOLINTNEXTLINE(bugprone-branch-clone)
13368|     70|        if (url.is_special() && (input_position != input_size) &&
  ------------------
  |  Branch (13368:13): [True: 51, False: 19]
  |  Branch (13368:33): [True: 42, False: 9]
  ------------------
13369|     42|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13369:14): [True: 4, False: 38]
  ------------------
13370|     38|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13370:14): [True: 2, False: 36]
  ------------------
13371|       |          // Set state to special authority ignore slashes state.
13372|      6|          state = state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
13373|      6|        }
13374|       |        // Otherwise, if c is U+002F (/), then set state to authority state.
13375|     64|        else if ((input_position != input_size) &&
  ------------------
  |  Branch (13375:18): [True: 46, False: 18]
  ------------------
13376|     46|                 (url_data[input_position] == '/')) {
  ------------------
  |  Branch (13376:18): [True: 5, False: 41]
  ------------------
13377|      5|          state = state::AUTHORITY;
13378|      5|        }
13379|       |        // Otherwise, set
13380|       |        // - url's username to base's username,
13381|       |        // - url's password to base's password,
13382|       |        // - url's host to base's host,
13383|       |        // - url's port to base's port,
13384|       |        // - state to path state, and then, decrease pointer by 1.
13385|     59|        else {
13386|     59|          if constexpr (result_type_is_ada_url) {
13387|     59|            url.username = base_url->username;
13388|     59|            url.password = base_url->password;
13389|     59|            url.host = base_url->host;
13390|     59|            url.port = base_url->port;
13391|       |          } else {
13392|       |            url.update_base_authority(base_url->get_href(),
13393|       |                                      base_url->get_components());
13394|       |            url.update_host_to_base_host(base_url->get_hostname());
13395|       |            url.update_base_port(base_url->retrieve_base_port());
13396|       |          }
13397|     59|          state = state::PATH;
13398|     59|          break;
13399|     59|        }
13400|       |
13401|     11|        input_position++;
13402|     11|        break;
13403|     70|      }
13404|  12.6k|      case state::SPECIAL_AUTHORITY_SLASHES: {
  ------------------
  |  Branch (13404:7): [True: 12.6k, False: 152k]
  ------------------
13405|  12.6k|        ada_log("SPECIAL_AUTHORITY_SLASHES ",
13406|  12.6k|                helpers::substring(url_data, input_position));
13407|       |
13408|       |        // If c is U+002F (/) and remaining starts with U+002F (/),
13409|       |        // then set state to special authority ignore slashes state and increase
13410|       |        // pointer by 1.
13411|  12.6k|        if (url_data.substr(input_position, 2) == "//") {
  ------------------
  |  Branch (13411:13): [True: 3.23k, False: 9.45k]
  ------------------
13412|  3.23k|          input_position += 2;
13413|  3.23k|        }
13414|       |
13415|  12.6k|        [[fallthrough]];
13416|  12.6k|      }
13417|  13.0k|      case state::SPECIAL_AUTHORITY_IGNORE_SLASHES: {
  ------------------
  |  Branch (13417:7): [True: 348, False: 164k]
  ------------------
13418|  13.0k|        ada_log("SPECIAL_AUTHORITY_IGNORE_SLASHES ",
13419|  13.0k|                helpers::substring(url_data, input_position));
13420|       |
13421|       |        // If c is neither U+002F (/) nor U+005C (\), then set state to
13422|       |        // authority state and decrease pointer by 1.
13423|  14.0k|        while ((input_position != input_size) &&
  ------------------
  |  Branch (13423:16): [True: 13.9k, False: 86]
  ------------------
13424|  13.9k|               ((url_data[input_position] == '/') ||
  ------------------
  |  Branch (13424:17): [True: 644, False: 13.3k]
  ------------------
13425|  13.3k|                (url_data[input_position] == '\\'))) {
  ------------------
  |  Branch (13425:17): [True: 393, False: 12.9k]
  ------------------
13426|  1.03k|          input_position++;
13427|  1.03k|        }
13428|  13.0k|        state = state::AUTHORITY;
13429|       |
13430|  13.0k|        break;
13431|  12.6k|      }
13432|  1.17k|      case state::QUERY: {
  ------------------
  |  Branch (13432:7): [True: 1.17k, False: 163k]
  ------------------
13433|  1.17k|        ada_log("QUERY ", helpers::substring(url_data, input_position));
13434|  1.17k|        if constexpr (store_values) {
13435|       |          // Let queryPercentEncodeSet be the special-query percent-encode set
13436|       |          // if url is special; otherwise the query percent-encode set.
13437|  1.17k|          const uint8_t* query_percent_encode_set =
13438|  1.17k|              url.is_special() ? character_sets::SPECIAL_QUERY_PERCENT_ENCODE
  ------------------
  |  Branch (13438:15): [True: 762, False: 414]
  ------------------
13439|  1.17k|                               : character_sets::QUERY_PERCENT_ENCODE;
13440|       |
13441|       |          // Percent-encode after encoding, with encoding, buffer, and
13442|       |          // queryPercentEncodeSet, and append the result to url's query.
13443|  1.17k|          url.update_base_search(url_data.substr(input_position),
13444|  1.17k|                                 query_percent_encode_set);
13445|  1.17k|          ada_log("QUERY update_base_search completed ");
13446|  1.17k|          if (fragment.has_value()) {
  ------------------
  |  Branch (13446:15): [True: 307, False: 869]
  ------------------
13447|    307|            url.update_unencoded_base_hash(*fragment);
13448|    307|          }
13449|  1.17k|        }
13450|  1.17k|        enforce_max_input_length();
13451|  1.17k|        return url;
13452|  12.6k|      }
13453|  13.5k|      case state::HOST: {
  ------------------
  |  Branch (13453:7): [True: 13.5k, False: 151k]
  ------------------
13454|  13.5k|        ada_log("HOST ", helpers::substring(url_data, input_position));
13455|       |
13456|  13.5k|        std::string_view host_view = url_data.substr(input_position);
13457|  13.5k|        auto [location, found_colon] =
13458|  13.5k|            helpers::get_host_delimiter_location(url.is_special(), host_view);
13459|  13.5k|        input_position = (location != std::string_view::npos)
  ------------------
  |  Branch (13459:26): [True: 13.5k, False: 0]
  ------------------
13460|  13.5k|                             ? input_position + location
13461|  13.5k|                             : input_size;
13462|       |        // Otherwise, if c is U+003A (:) and insideBrackets is false, then:
13463|       |        // Note: the 'found_colon' value is true if and only if a colon was
13464|       |        // encountered while not inside brackets.
13465|  13.5k|        if (found_colon) {
  ------------------
  |  Branch (13465:13): [True: 2.43k, False: 11.1k]
  ------------------
13466|       |          // If buffer is the empty string, validation error, return failure.
13467|       |          // Let host be the result of host parsing buffer with url is not
13468|       |          // special.
13469|  2.43k|          ada_log("HOST parsing ", host_view);
13470|  2.43k|          if (!url.parse_host(host_view)) {
  ------------------
  |  Branch (13470:15): [True: 211, False: 2.22k]
  ------------------
13471|    211|            return url;
13472|    211|          }
13473|  2.22k|          ada_log("HOST parsing results in ", url.get_hostname());
13474|       |          // Set url's host to host, buffer to the empty string, and state to
13475|       |          // port state.
13476|  2.22k|          state = state::PORT;
13477|  2.22k|          input_position++;
13478|  2.22k|        }
13479|       |        // Otherwise, if one of the following is true:
13480|       |        // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
13481|       |        // - url is special and c is U+005C (\)
13482|       |        // The get_host_delimiter_location function either brings us to
13483|       |        // the colon outside of the bracket, or to one of those characters.
13484|  11.1k|        else {
13485|       |          // If url is special and host_view is the empty string, validation
13486|       |          // error, return failure.
13487|  11.1k|          if (host_view.empty() && url.is_special()) {
  ------------------
  |  Branch (13487:15): [True: 222, False: 10.9k]
  |  Branch (13487:36): [True: 91, False: 131]
  ------------------
13488|     91|            url.is_valid = false;
13489|     91|            return url;
13490|     91|          }
13491|  11.0k|          ada_log("HOST parsing ", host_view, " href=", url.get_href());
13492|       |          // Let host be the result of host parsing host_view with url is not
13493|       |          // special.
13494|  11.0k|          if (host_view.empty()) {
  ------------------
  |  Branch (13494:15): [True: 131, False: 10.9k]
  ------------------
13495|    131|            url.update_base_hostname("");
13496|  10.9k|          } else if (!url.parse_host(host_view)) {
  ------------------
  |  Branch (13496:22): [True: 2.29k, False: 8.63k]
  ------------------
13497|  2.29k|            return url;
13498|  2.29k|          }
13499|  8.76k|          ada_log("HOST parsing results in ", url.get_hostname(),
13500|  8.76k|                  " href=", url.get_href());
13501|       |
13502|       |          // Set url's host to host, and state to path start state.
13503|  8.76k|          state = state::PATH_START;
13504|  8.76k|        }
13505|       |
13506|  10.9k|        break;
13507|  13.5k|      }
13508|  10.9k|      case state::OPAQUE_PATH: {
  ------------------
  |  Branch (13508:7): [True: 3.17k, False: 161k]
  ------------------
13509|  3.17k|        ada_log("OPAQUE_PATH ", helpers::substring(url_data, input_position));
13510|       |        // Opaque path, query, and fragment are structurally always valid:
13511|       |        // the parser would just percent-encode whatever is there. When we
13512|       |        // are not storing values (can_parse), we can return immediately.
13513|       |        // We must set has_opaque_path = true before returning so that when
13514|       |        // this URL is used as an internal base inside can_parse, NO_SCHEME
13515|       |        // correctly rejects relative inputs against an opaque-path base
13516|       |        // (e.g. can_parse("", &"W:") must return false).
13517|       |        if constexpr (!store_values) {
13518|       |          url.has_opaque_path = true;
13519|       |          return url;
13520|       |        }
13521|  3.17k|        std::string_view view = url_data.substr(input_position);
13522|       |        // If c is U+003F (?), then set url's query to the empty string and
13523|       |        // state to query state.
13524|  3.17k|        size_t location = view.find('?');
13525|  3.17k|        if (location != std::string_view::npos) {
  ------------------
  |  Branch (13525:13): [True: 281, False: 2.89k]
  ------------------
13526|    281|          view.remove_suffix(view.size() - location);
13527|    281|          state = state::QUERY;
13528|    281|          input_position += location + 1;
13529|  2.89k|        } else {
13530|  2.89k|          input_position = input_size + 1;
13531|  2.89k|        }
13532|  3.17k|        url.has_opaque_path = true;
13533|       |
13534|       |        // This is a really unlikely scenario in real world. We should not seek
13535|       |        // to optimize it.
13536|  3.17k|        if (view.ends_with(' ')) {
  ------------------
  |  Branch (13536:13): [True: 112, False: 3.06k]
  ------------------
13537|    112|          std::string modified_view =
13538|    112|              std::string(view.substr(0, view.size() - 1)) + "%20";
13539|    112|          url.update_base_pathname(unicode::percent_encode(
13540|    112|              modified_view, character_sets::C0_CONTROL_PERCENT_ENCODE));
13541|  3.06k|        } else {
13542|  3.06k|          url.update_base_pathname(unicode::percent_encode(
13543|  3.06k|              view, character_sets::C0_CONTROL_PERCENT_ENCODE));
13544|  3.06k|        }
13545|  3.17k|        break;
13546|  13.5k|      }
13547|  2.22k|      case state::PORT: {
  ------------------
  |  Branch (13547:7): [True: 2.22k, False: 162k]
  ------------------
13548|  2.22k|        ada_log("PORT ", helpers::substring(url_data, input_position));
13549|  2.22k|        std::string_view port_view = url_data.substr(input_position);
13550|  2.22k|        input_position += url.parse_port(port_view, true);
13551|  2.22k|        if (!url.is_valid) {
  ------------------
  |  Branch (13551:13): [True: 118, False: 2.11k]
  ------------------
13552|    118|          return url;
13553|    118|        }
13554|  2.11k|        state = state::PATH_START;
13555|  2.11k|        [[fallthrough]];
13556|  2.11k|      }
13557|  12.7k|      case state::PATH_START: {
  ------------------
  |  Branch (13557:7): [True: 10.6k, False: 154k]
  ------------------
13558|  12.7k|        ada_log("PATH_START ", helpers::substring(url_data, input_position));
13559|       |        // Path, query, and fragment are structurally always valid: the
13560|       |        // parser would just percent-encode whatever is there. When we are
13561|       |        // not storing values (can_parse), we can return immediately since
13562|       |        // no subsequent state can invalidate the URL.
13563|       |        if constexpr (!store_values) {
13564|       |          return url;
13565|       |        }
13566|       |
13567|       |        // If url is special, then:
13568|  12.7k|        if (url.is_special()) {
  ------------------
  |  Branch (13568:13): [True: 12.0k, False: 755]
  ------------------
13569|       |          // Set state to path state.
13570|  12.0k|          state = state::PATH;
13571|       |
13572|       |          // Optimization: Avoiding going into PATH state improves the
13573|       |          // performance of urls ending with /.
13574|  12.0k|          if (input_position == input_size) {
  ------------------
  |  Branch (13574:15): [True: 6.42k, False: 5.59k]
  ------------------
13575|  6.42k|            if constexpr (store_values) {
13576|  6.42k|              url.update_base_pathname("/");
13577|  6.42k|              if (fragment.has_value()) {
  ------------------
  |  Branch (13577:19): [True: 166, False: 6.26k]
  ------------------
13578|    166|                url.update_unencoded_base_hash(*fragment);
13579|    166|              }
13580|  6.42k|            }
13581|  6.42k|            enforce_max_input_length();
13582|  6.42k|            return url;
13583|  6.42k|          }
13584|       |          // If c is neither U+002F (/) nor U+005C (\), then decrease pointer
13585|       |          // by 1. We know that (input_position == input_size) is impossible
13586|       |          // here, because of the previous if-check.
13587|  5.59k|          if ((url_data[input_position] != '/') &&
  ------------------
  |  Branch (13587:15): [True: 387, False: 5.20k]
  ------------------
13588|    387|              (url_data[input_position] != '\\')) {
  ------------------
  |  Branch (13588:15): [True: 373, False: 14]
  ------------------
13589|    373|            break;
13590|    373|          }
13591|  5.59k|        }
13592|       |        // Otherwise, if state override is not given and c is U+003F (?),
13593|       |        // set url's query to the empty string and state to query state.
13594|    755|        else if ((input_position != input_size) &&
  ------------------
  |  Branch (13594:18): [True: 160, False: 595]
  ------------------
13595|    160|                 (url_data[input_position] == '?')) {
  ------------------
  |  Branch (13595:18): [True: 51, False: 109]
  ------------------
13596|     51|          state = state::QUERY;
13597|     51|        }
13598|       |        // Otherwise, if c is not the EOF code point:
13599|    704|        else if (input_position != input_size) {
  ------------------
  |  Branch (13599:18): [True: 109, False: 595]
  ------------------
13600|       |          // Set state to path state.
13601|    109|          state = state::PATH;
13602|       |
13603|       |          // If c is not U+002F (/), then decrease pointer by 1.
13604|    109|          if (url_data[input_position] != '/') {
  ------------------
  |  Branch (13604:15): [True: 0, False: 109]
  ------------------
13605|      0|            break;
13606|      0|          }
13607|    109|        }
13608|       |
13609|  5.97k|        input_position++;
13610|  5.97k|        break;
13611|  12.7k|      }
13612|  8.23k|      case state::PATH: {
  ------------------
  |  Branch (13612:7): [True: 8.23k, False: 156k]
  ------------------
13613|  8.23k|        ada_log("PATH ", helpers::substring(url_data, input_position));
13614|       |        // Path, query, and fragment are structurally always valid: the
13615|       |        // parser would just percent-encode whatever is there. When we are
13616|       |        // not storing values (can_parse), we can return immediately since
13617|       |        // no subsequent state can invalidate the URL.
13618|       |        if constexpr (!store_values) {
13619|       |          return url;
13620|       |        }
13621|  8.23k|        std::string_view view = url_data.substr(input_position);
13622|       |
13623|       |        // Most time, we do not need percent encoding.
13624|       |        // Furthermore, we can immediately locate the '?'.
13625|  8.23k|        size_t locofquestionmark = view.find('?');
13626|  8.23k|        if (locofquestionmark != std::string_view::npos) {
  ------------------
  |  Branch (13626:13): [True: 760, False: 7.47k]
  ------------------
13627|    760|          state = state::QUERY;
13628|    760|          view.remove_suffix(view.size() - locofquestionmark);
13629|    760|          input_position += locofquestionmark + 1;
13630|  7.47k|        } else {
13631|  7.47k|          input_position = input_size + 1;
13632|  7.47k|        }
13633|  8.23k|        if constexpr (store_values) {
13634|  8.23k|          if constexpr (result_type_is_ada_url) {
13635|  8.23k|            helpers::parse_prepared_path(view, url.type, url.path);
13636|       |          } else {
13637|       |            url.consume_prepared_path(view);
13638|       |            ADA_ASSERT_TRUE(url.validate());
13639|       |          }
13640|  8.23k|        }
13641|  8.23k|        break;
13642|  12.7k|      }
13643|  2.20k|      case state::FILE_SLASH: {
  ------------------
  |  Branch (13643:7): [True: 2.20k, False: 162k]
  ------------------
13644|  2.20k|        ada_log("FILE_SLASH ", helpers::substring(url_data, input_position));
13645|       |
13646|       |        // If c is U+002F (/) or U+005C (\), then:
13647|  2.20k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13647:13): [True: 2.13k, False: 67]
  ------------------
13648|  2.13k|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13648:14): [True: 2.08k, False: 49]
  ------------------
13649|  2.09k|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13649:14): [True: 6, False: 43]
  ------------------
13650|  2.09k|          ada_log("FILE_SLASH c is U+002F or U+005C");
13651|       |          // Set state to file host state.
13652|  2.09k|          state = state::FILE_HOST;
13653|  2.09k|          input_position++;
13654|  2.09k|        } else {
13655|    110|          ada_log("FILE_SLASH otherwise");
13656|       |          // If base is non-null and base's scheme is "file", then:
13657|       |          // Note: it is unsafe to do base_url->scheme unless you know that
13658|       |          // base_url_has_value() is true.
13659|    110|          if (base_url != nullptr && base_url->type == scheme::type::FILE) {
  ------------------
  |  Branch (13659:15): [True: 88, False: 22]
  |  Branch (13659:38): [True: 86, False: 2]
  ------------------
13660|       |            // Set url's host to base's host.
13661|     86|            if constexpr (result_type_is_ada_url) {
13662|     86|              url.host = base_url->host;
13663|       |            } else {
13664|       |              url.update_host_to_base_host(base_url->get_host());
13665|       |            }
13666|       |            // If the code point substring from pointer to the end of input does
13667|       |            // not start with a Windows drive letter and base's path[0] is a
13668|       |            // normalized Windows drive letter, then append base's path[0] to
13669|       |            // url's path.
13670|     86|            if (!base_url->get_pathname().empty()) {
  ------------------
  |  Branch (13670:17): [True: 86, False: 0]
  ------------------
13671|     86|              if (!checkers::is_windows_drive_letter(
  ------------------
  |  Branch (13671:19): [True: 81, False: 5]
  ------------------
13672|     86|                      url_data.substr(input_position))) {
13673|     81|                std::string_view first_base_url_path =
13674|     81|                    base_url->get_pathname().substr(1);
13675|     81|                size_t loc = first_base_url_path.find('/');
13676|     81|                if (loc != std::string_view::npos) {
  ------------------
  |  Branch (13676:21): [True: 11, False: 70]
  ------------------
13677|     11|                  helpers::resize(first_base_url_path, loc);
13678|     11|                }
13679|     81|                if (checkers::is_normalized_windows_drive_letter(
  ------------------
  |  Branch (13679:21): [True: 2, False: 79]
  ------------------
13680|     81|                        first_base_url_path)) {
13681|      2|                  if constexpr (result_type_is_ada_url) {
13682|      2|                    url.path += '/';
13683|      2|                    url.path += first_base_url_path;
13684|       |                  } else {
13685|       |                    url.append_base_pathname(
13686|       |                        helpers::concat("/", first_base_url_path));
13687|       |                  }
13688|      2|                }
13689|     81|              }
13690|     86|            }
13691|     86|          }
13692|       |
13693|       |          // Set state to path state, and decrease pointer by 1.
13694|    110|          state = state::PATH;
13695|    110|        }
13696|       |
13697|  2.20k|        break;
13698|  12.7k|      }
13699|  2.09k|      case state::FILE_HOST: {
  ------------------
  |  Branch (13699:7): [True: 2.09k, False: 162k]
  ------------------
13700|  2.09k|        ada_log("FILE_HOST ", helpers::substring(url_data, input_position));
13701|  2.09k|        std::string_view view = url_data.substr(input_position);
13702|       |
13703|  2.09k|        size_t location = view.find_first_of("/\\?");
13704|  2.09k|        std::string_view file_host_buffer = view.substr(
13705|  2.09k|            0, (location != std::string_view::npos) ? location : view.size());
  ------------------
  |  Branch (13705:16): [True: 890, False: 1.20k]
  ------------------
13706|       |
13707|  2.09k|        if (checkers::is_windows_drive_letter(file_host_buffer)) {
  ------------------
  |  Branch (13707:13): [True: 12, False: 2.08k]
  ------------------
13708|     12|          state = state::PATH;
13709|  2.08k|        } else if (file_host_buffer.empty()) {
  ------------------
  |  Branch (13709:20): [True: 257, False: 1.82k]
  ------------------
13710|       |          // Set url's host to the empty string.
13711|    257|          if constexpr (result_type_is_ada_url) {
13712|    257|            url.host = "";
13713|       |          } else {
13714|       |            url.update_base_hostname("");
13715|       |          }
13716|       |          // Set state to path start state.
13717|    257|          state = state::PATH_START;
13718|  1.82k|        } else {
13719|  1.82k|          size_t consumed_bytes = file_host_buffer.size();
13720|  1.82k|          input_position += consumed_bytes;
13721|       |          // Let host be the result of host parsing buffer with url is not
13722|       |          // special.
13723|  1.82k|          if (!url.parse_host(file_host_buffer)) {
  ------------------
  |  Branch (13723:15): [True: 188, False: 1.63k]
  ------------------
13724|    188|            return url;
13725|    188|          }
13726|       |
13727|  1.63k|          if constexpr (result_type_is_ada_url) {
13728|       |            // If host is "localhost", then set host to the empty string.
13729|  1.63k|            if (url.host.has_value() && url.host.value() == "localhost") {
  ------------------
  |  Branch (13729:17): [True: 1.63k, False: 0]
  |  Branch (13729:41): [True: 12, False: 1.62k]
  ------------------
13730|     12|              url.host = "";
13731|     12|            }
13732|       |          } else {
13733|       |            if (url.get_hostname() == "localhost") {
13734|       |              url.update_base_hostname("");
13735|       |            }
13736|       |          }
13737|       |
13738|       |          // Set buffer to the empty string and state to path start state.
13739|  1.63k|          state = state::PATH_START;
13740|  1.63k|        }
13741|       |
13742|  1.90k|        break;
13743|  2.09k|      }
13744|  2.77k|      case state::FILE: {
  ------------------
  |  Branch (13744:7): [True: 2.77k, False: 162k]
  ------------------
13745|  2.77k|        ada_log("FILE ", helpers::substring(url_data, input_position));
13746|  2.77k|        std::string_view file_view = url_data.substr(input_position);
13747|       |
13748|  2.77k|        url.set_protocol_as_file();
13749|  2.77k|        if constexpr (result_type_is_ada_url) {
13750|       |          // Set url's host to the empty string.
13751|  2.77k|          url.host = "";
13752|       |        } else {
13753|       |          url.update_base_hostname("");
13754|       |        }
13755|       |        // If c is U+002F (/) or U+005C (\), then:
13756|  2.77k|        if (input_position != input_size &&
  ------------------
  |  Branch (13756:13): [True: 2.66k, False: 108]
  ------------------
13757|  2.66k|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13757:14): [True: 2.19k, False: 473]
  ------------------
13758|  2.20k|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13758:14): [True: 7, False: 466]
  ------------------
13759|  2.20k|          ada_log("FILE c is U+002F or U+005C");
13760|       |          // Set state to file slash state.
13761|  2.20k|          state = state::FILE_SLASH;
13762|  2.20k|        }
13763|       |        // Otherwise, if base is non-null and base's scheme is "file":
13764|    574|        else if (base_url != nullptr && base_url->type == scheme::type::FILE) {
  ------------------
  |  Branch (13764:18): [True: 206, False: 368]
  |  Branch (13764:41): [True: 140, False: 66]
  ------------------
13765|       |          // Set url's host to base's host, url's path to a clone of base's
13766|       |          // path, and url's query to base's query.
13767|    140|          ada_log("FILE base non-null");
13768|    140|          if constexpr (result_type_is_ada_url) {
13769|    140|            url.host = base_url->host;
13770|    140|            url.path = base_url->path;
13771|    140|            url.query = base_url->query;
13772|       |          } else {
13773|       |            url.update_host_to_base_host(base_url->get_hostname());
13774|       |            url.update_base_pathname(base_url->get_pathname());
13775|       |            if (base_url->has_search()) {
13776|       |              // get_search() returns "" for an empty query string (URL ends
13777|       |              // with '?'). update_base_search("") would incorrectly clear the
13778|       |              // query, so pass "?" to preserve the empty query distinction.
13779|       |              auto s = base_url->get_search();
13780|       |              url.update_base_search(s.empty() ? std::string_view("?") : s);
13781|       |            }
13782|       |          }
13783|    140|          url.has_opaque_path = base_url->has_opaque_path;
13784|       |
13785|       |          // If c is U+003F (?), then set url's query to the empty string and
13786|       |          // state to query state.
13787|    140|          if (input_position != input_size && url_data[input_position] == '?') {
  ------------------
  |  Branch (13787:15): [True: 93, False: 47]
  |  Branch (13787:47): [True: 4, False: 89]
  ------------------
13788|      4|            state = state::QUERY;
13789|      4|          }
13790|       |          // Otherwise, if c is not the EOF code point:
13791|    136|          else if (input_position != input_size) {
  ------------------
  |  Branch (13791:20): [True: 89, False: 47]
  ------------------
13792|       |            // Set url's query to null.
13793|     89|            url.clear_search();
13794|       |            // If the code point substring from pointer to the end of input does
13795|       |            // not start with a Windows drive letter, then shorten url's path.
13796|     89|            if (!checkers::is_windows_drive_letter(file_view)) {
  ------------------
  |  Branch (13796:17): [True: 76, False: 13]
  ------------------
13797|     76|              if constexpr (result_type_is_ada_url) {
13798|     76|                helpers::shorten_path(url.path, url.type);
13799|       |              } else {
13800|       |                std::string_view path = url.get_pathname();
13801|       |                if (helpers::shorten_path(path, url.type)) {
13802|       |                  url.update_base_pathname(std::move(std::string(path)));
13803|       |                }
13804|       |              }
13805|     76|            }
13806|       |            // Otherwise:
13807|     13|            else {
13808|       |              // Set url's path to an empty list.
13809|     13|              url.clear_pathname();
13810|     13|              url.has_opaque_path = true;
13811|     13|            }
13812|       |
13813|       |            // Set state to path state and decrease pointer by 1.
13814|     89|            state = state::PATH;
13815|     89|            break;
13816|     89|          }
13817|    140|        }
13818|       |        // Otherwise, set state to path state, and decrease pointer by 1.
13819|    434|        else {
13820|    434|          ada_log("FILE go to path");
13821|    434|          state = state::PATH;
13822|    434|          break;
13823|    434|        }
13824|       |
13825|  2.25k|        input_position++;
13826|  2.25k|        break;
13827|  2.77k|      }
13828|      0|      default:
  ------------------
  |  Branch (13828:7): [True: 0, False: 164k]
  ------------------
13829|      0|        unreachable();
13830|   164k|    }
13831|   164k|  }
13832|  16.4k|  if constexpr (store_values) {
13833|  16.4k|    if (fragment.has_value()) {
  ------------------
  |  Branch (13833:9): [True: 346, False: 16.0k]
  ------------------
13834|    346|      url.update_unencoded_base_hash(*fragment);
13835|    346|    }
13836|  16.4k|  }
13837|  16.4k|  enforce_max_input_length();
13838|  16.4k|  return url;
13839|  49.0k|}
_ZN3ada6parser14parse_url_implINS_14url_aggregatorELb1EEET_NSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEPKS3_:
12819|  49.0k|                           const result_type* base_url) {
12820|       |  // We can specialize the implementation per type.
12821|       |  // Important: result_type_is_ada_url is evaluated at *compile time*. This
12822|       |  // means that doing if constexpr(result_type_is_ada_url) { something } else {
12823|       |  // something else } is free (at runtime). This means that ada::url_aggregator
12824|       |  // and ada::url **do not have to support the exact same API**.
12825|  49.0k|  constexpr bool result_type_is_ada_url = std::is_same_v<url, result_type>;
12826|  49.0k|  constexpr bool result_type_is_ada_url_aggregator =
12827|  49.0k|      std::is_same_v<url_aggregator, result_type>;
12828|  49.0k|  static_assert(result_type_is_ada_url ||
12829|  49.0k|                result_type_is_ada_url_aggregator);  // We don't support
12830|       |                                                     // anything else for now.
12831|       |
12832|  49.0k|  ada_log("ada::parser::parse_url('", user_input, "' [", user_input.size(),
12833|  49.0k|          " bytes],", (base_url != nullptr ? base_url->to_string() : "null"),
12834|  49.0k|          ")");
12835|       |
12836|  49.0k|  result_type url{};
12837|       |
12838|  49.0k|  const uint32_t max_input_length = ada::get_max_input_length();
12839|       |
12840|       |  // Normalization (percent-encoding, IDNA) can push the serialized URL past
12841|       |  // max_input_length even when the input fit under it. The check at the end of
12842|       |  // the state machine covers URLs that run to completion, but several states
12843|       |  // return early after appending a query or fragment, so run the same check on
12844|       |  // those exits too. Without this, a query- or fragment-terminated URL such as
12845|       |  // file://x/?<...> or https://user@x/?<...> is accepted while the equivalent
12846|       |  // https://x/?<...> that takes the absolute fast path is rejected.
12847|  49.0k|  const auto enforce_max_input_length = [&]() {
12848|  49.0k|    if constexpr (store_values) {
12849|  49.0k|      if (url.is_valid) {
12850|  49.0k|        if constexpr (result_type_is_ada_url_aggregator) {
12851|  49.0k|          if (url.buffer.size() > max_input_length) [[unlikely]] {
12852|  49.0k|            url.is_valid = false;
12853|  49.0k|          }
12854|  49.0k|        } else {
12855|  49.0k|          if (url.get_href_size() > max_input_length) [[unlikely]] {
12856|  49.0k|            url.is_valid = false;
12857|  49.0k|          }
12858|  49.0k|        }
12859|  49.0k|      }
12860|  49.0k|    }
12861|  49.0k|  };
12862|       |
12863|       |  // We refuse to parse URL strings that exceed the maximum input length.
12864|       |  // By default, this is 4GB but can be configured via
12865|       |  // ada::set_max_input_length().
12866|  49.0k|  if (user_input.size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (12866:7): [True: 0, False: 49.0k]
  ------------------
12867|      0|    url.is_valid = false;
12868|      0|  }
12869|       |  // Going forward, user_input.size() is in [0,
12870|       |  // std::numeric_limits<uint32_t>::max). If we are provided with an invalid
12871|       |  // base, or the optional_url was invalid, we must return.
12872|  49.0k|  if (base_url != nullptr) {
  ------------------
  |  Branch (12872:7): [True: 4.35k, False: 44.6k]
  ------------------
12873|  4.35k|    url.is_valid &= base_url->is_valid;
12874|  4.35k|  }
12875|  49.0k|  if (!url.is_valid) {
  ------------------
  |  Branch (12875:7): [True: 0, False: 49.0k]
  ------------------
12876|      0|    return url;
12877|      0|  }
12878|       |
12879|       |  // Simple absolute / relative fast paths (before tabs/newline scan).
12880|  49.0k|  if constexpr (store_values) {
12881|  49.0k|    bool hit_fast_path = false;
12882|  49.0k|    if (base_url == nullptr) {
  ------------------
  |  Branch (12882:9): [True: 44.6k, False: 4.35k]
  ------------------
12883|       |      // IPv4/IPv6 and userinfo miss the fast path. Skip the never_inline
12884|       |      // call so those URLs (including SetHref) do not pay for a miss.
12885|  44.6k|      const auto* p = reinterpret_cast<const uint8_t*>(user_input.data());
12886|  44.6k|      const size_t n = user_input.size();
12887|  44.6k|      size_t host_start = 0;
12888|  44.6k|      if (n >= 8 && p[4] == ':' && p[5] == '/' && p[6] == '/') {
  ------------------
  |  Branch (12888:11): [True: 17.4k, False: 27.1k]
  |  Branch (12888:21): [True: 3.13k, False: 14.3k]
  |  Branch (12888:36): [True: 2.27k, False: 861]
  |  Branch (12888:51): [True: 2.24k, False: 31]
  ------------------
12889|  2.24k|        host_start = 7;
12890|  42.4k|      } else if (n >= 9 && p[5] == ':' && p[6] == '/' && p[7] == '/') {
  ------------------
  |  Branch (12890:18): [True: 13.8k, False: 28.5k]
  |  Branch (12890:28): [True: 240, False: 13.6k]
  |  Branch (12890:43): [True: 48, False: 192]
  |  Branch (12890:58): [True: 28, False: 20]
  ------------------
12891|     28|        host_start = 8;
12892|     28|      }
12893|  44.6k|      const uint8_t host_first = host_start != 0 ? p[host_start] : 0;
  ------------------
  |  Branch (12893:34): [True: 2.27k, False: 42.3k]
  ------------------
12894|  44.6k|      const bool skip_ip =
12895|  44.6k|          host_first == '[' || (host_first >= '0' && host_first <= '9');
  ------------------
  |  Branch (12895:11): [True: 17, False: 44.6k]
  |  Branch (12895:33): [True: 1.68k, False: 42.9k]
  |  Branch (12895:54): [True: 590, False: 1.09k]
  ------------------
12896|  44.6k|      const bool skip_userinfo =
12897|  44.6k|          host_start != 0 && authority_has_at(p, host_start, n);
  ------------------
  |  Branch (12897:11): [True: 2.27k, False: 42.3k]
  |  Branch (12897:30): [True: 24, False: 2.25k]
  ------------------
12898|  44.6k|      hit_fast_path = !skip_ip && !skip_userinfo &&
  ------------------
  |  Branch (12898:23): [True: 44.0k, False: 607]
  |  Branch (12898:35): [True: 44.0k, False: 22]
  ------------------
12899|  44.0k|                      try_parse_simple_absolute(user_input, url);
  ------------------
  |  Branch (12899:23): [True: 4.99k, False: 39.0k]
  ------------------
12900|  44.6k|    } else {
12901|  4.35k|      hit_fast_path = try_parse_simple_relative(user_input, *base_url, url);
12902|  4.35k|    }
12903|  49.0k|    if (hit_fast_path) {
  ------------------
  |  Branch (12903:9): [True: 5.25k, False: 43.7k]
  ------------------
12904|  5.25k|      if constexpr (result_type_is_ada_url_aggregator) {
12905|  5.25k|        if (url.buffer.size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (12905:13): [True: 0, False: 5.25k]
  ------------------
12906|      0|          url.is_valid = false;
12907|      0|        }
12908|       |      } else {
12909|       |        // For a small absolute input, even worst-case normalization cannot
12910|       |        // exceed the limit: percent encoding expands at most 3x and IDNA at
12911|       |        // most 4.5x. Avoid traversing every stored component on the common
12912|       |        // default-limit path.
12913|       |        if ((base_url != nullptr ||
12914|       |             user_input.size() > static_cast<size_t>(max_input_length) / 5) &&
12915|       |            url.get_href_size() > max_input_length) [[unlikely]] {
12916|       |          url.is_valid = false;
12917|       |        }
12918|       |      }
12919|  5.25k|      return url;
12920|  5.25k|    }
12921|  49.0k|  }
12922|       |
12923|  43.7k|  state state = state::SCHEME_START;
12924|       |
12925|  49.0k|  std::string tmp_buffer;
12926|  49.0k|  std::string_view url_data;
12927|  49.0k|  if (unicode::has_tabs_or_newline(user_input)) [[unlikely]] {
  ------------------
  |  Branch (12927:7): [True: 404, False: 48.6k]
  ------------------
12928|    404|    tmp_buffer = user_input;
12929|       |    // Optimization opportunity: Instead of copying and then pruning, we could
12930|       |    // just directly build the string from user_input.
12931|    404|    helpers::remove_ascii_tab_or_newline(tmp_buffer);
12932|    404|    url_data = tmp_buffer;
12933|  48.6k|  } else [[likely]] {
12934|  48.6k|    url_data = user_input;
12935|  48.6k|  }
12936|       |
12937|       |  // Leading and trailing control characters are uncommon and easy to deal with
12938|       |  // (no performance concern).
12939|  49.0k|  helpers::trim_c0_whitespace(url_data);
12940|       |
12941|  49.0k|  if constexpr (result_type_is_ada_url_aggregator && store_values) {
12942|       |    // Most of the time, we just need user_input.size().
12943|       |    // In some instances, we may need a bit more.
12944|       |    ///////////////////////////
12945|       |    // This is *very* important. This line should *not* be removed
12946|       |    // hastily. There are principled reasons why reserve is important
12947|       |    // for performance. If you have a benchmark with small inputs,
12948|       |    // it may not matter, but in other instances, it could.
12949|       |    ////
12950|       |    // This rounds up to the next power of two.
12951|       |    // We know that user_input.size() is in [0,
12952|       |    // std::numeric_limits<uint32_t>::max).
12953|  49.0k|    uint32_t reserve_capacity =
12954|  49.0k|        (0xFFFFFFFF >>
12955|  49.0k|         helpers::leading_zeroes(uint32_t(1 | user_input.size()))) +
12956|  49.0k|        1;
12957|  49.0k|    url.reserve(reserve_capacity);
12958|  49.0k|  }
12959|       |
12960|       |  // Optimization opportunity. Most websites do not have fragment.
12961|  49.0k|  std::optional<std::string_view> fragment = helpers::prune_hash(url_data);
12962|       |  // We add it last so that an implementation like ada::url_aggregator
12963|       |  // can append it last to its internal buffer, thus improving performance.
12964|       |
12965|       |  // Here url_data no longer has its fragment.
12966|       |  // We are going to access the data from url_data (it is immutable).
12967|       |  // At any given time, we are pointing at byte 'input_position' in url_data.
12968|       |  // The input_position variable should range from 0 to input_size.
12969|       |  // It is illegal to access url_data at input_size.
12970|  49.0k|  size_t input_position = 0;
12971|  49.0k|  const size_t input_size = url_data.size();
12972|       |  // Keep running the following state machine by switching on state.
12973|       |  // If after a run pointer points to the EOF code point, go to the next step.
12974|       |  // Otherwise, increase pointer by 1 and continue with the state machine.
12975|       |  // We never decrement input_position.
12976|   181k|  while (input_position <= input_size) {
  ------------------
  |  Branch (12976:10): [True: 164k, False: 16.4k]
  ------------------
12977|   164k|    ada_log("In parsing at ", input_position, " out of ", input_size,
12978|   164k|            " in state ", ada::to_string(state));
12979|   164k|    switch (state) {
12980|  43.7k|      case state::SCHEME_START: {
  ------------------
  |  Branch (12980:7): [True: 43.7k, False: 121k]
  ------------------
12981|  43.7k|        ada_log("SCHEME_START ", helpers::substring(url_data, input_position));
12982|       |        // If c is an ASCII alpha, append c, lowercased, to buffer, and set
12983|       |        // state to scheme state.
12984|  43.7k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (12984:13): [True: 23.2k, False: 20.5k]
  ------------------
12985|  23.2k|            checkers::is_alpha(url_data[input_position])) {
  ------------------
  |  Branch (12985:13): [True: 21.7k, False: 1.42k]
  ------------------
12986|  21.7k|          state = state::SCHEME;
12987|  21.7k|          input_position++;
12988|  21.9k|        } else {
12989|       |          // Otherwise, if state override is not given, set state to no scheme
12990|       |          // state and decrease pointer by 1.
12991|  21.9k|          state = state::NO_SCHEME;
12992|  21.9k|        }
12993|  43.7k|        break;
12994|      0|      }
12995|  21.7k|      case state::SCHEME: {
  ------------------
  |  Branch (12995:7): [True: 21.7k, False: 143k]
  ------------------
12996|  21.7k|        ada_log("SCHEME ", helpers::substring(url_data, input_position));
12997|       |        // If c is an ASCII alphanumeric, U+002B (+), U+002D (-), or U+002E (.),
12998|       |        // append c, lowercased, to buffer.
12999|  53.3k|        while ((input_position != input_size) &&
  ------------------
  |  Branch (12999:16): [True: 53.0k, False: 319]
  ------------------
13000|  53.0k|               (unicode::is_alnum_plus(url_data[input_position]))) {
  ------------------
  |  Branch (13000:16): [True: 31.5k, False: 21.4k]
  ------------------
13001|  31.5k|          input_position++;
13002|  31.5k|        }
13003|       |        // Otherwise, if c is U+003A (:), then:
13004|  21.7k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13004:13): [True: 21.4k, False: 319]
  ------------------
13005|  21.4k|            (url_data[input_position] == ':')) {
  ------------------
  |  Branch (13005:13): [True: 21.0k, False: 420]
  ------------------
13006|  21.0k|          ada_log("SCHEME the scheme should be ",
13007|  21.0k|                  url_data.substr(0, input_position));
13008|       |          if constexpr (result_type_is_ada_url) {
13009|       |            if (!url.parse_scheme(url_data.substr(0, input_position))) {
13010|       |              return url;
13011|       |            }
13012|  21.0k|          } else {
13013|       |            // we pass the colon along instead of painfully adding it back.
13014|  21.0k|            if (!url.parse_scheme_with_colon(
  ------------------
  |  Branch (13014:17): [True: 0, False: 21.0k]
  ------------------
13015|  21.0k|                    url_data.substr(0, input_position + 1))) {
13016|      0|              return url;
13017|      0|            }
13018|  21.0k|          }
13019|  21.0k|          ada_log("SCHEME the scheme is ", url.get_protocol());
13020|       |
13021|       |          // If url's scheme is "file", then:
13022|       |          // NOLINTNEXTLINE(bugprone-branch-clone)
13023|  21.0k|          if (url.type == scheme::type::FILE) {
  ------------------
  |  Branch (13023:15): [True: 2.56k, False: 18.4k]
  ------------------
13024|       |            // Set state to file state.
13025|  2.56k|            state = state::FILE;
13026|  2.56k|          }
13027|       |          // Otherwise, if url is special, base is non-null, and base's scheme
13028|       |          // is url's scheme: Note: Doing base_url->scheme is unsafe if base_url
13029|       |          // != nullptr is false.
13030|  18.4k|          else if (url.is_special() && base_url != nullptr &&
  ------------------
  |  Branch (13030:20): [True: 13.1k, False: 5.37k]
  |  Branch (13030:40): [True: 2.24k, False: 10.8k]
  ------------------
13031|  2.24k|                   base_url->type == url.type) {
  ------------------
  |  Branch (13031:20): [True: 414, False: 1.82k]
  ------------------
13032|       |            // Set state to special relative or authority state.
13033|    414|            state = state::SPECIAL_RELATIVE_OR_AUTHORITY;
13034|    414|          }
13035|       |          // Otherwise, if url is special, set state to special authority
13036|       |          // slashes state.
13037|  18.0k|          else if (url.is_special()) {
  ------------------
  |  Branch (13037:20): [True: 12.6k, False: 5.37k]
  ------------------
13038|  12.6k|            state = state::SPECIAL_AUTHORITY_SLASHES;
13039|  12.6k|          }
13040|       |          // Otherwise, if remaining starts with an U+002F (/), set state to
13041|       |          // path or authority state and increase pointer by 1.
13042|  5.37k|          else if (input_position + 1 < input_size &&
  ------------------
  |  Branch (13042:20): [True: 3.10k, False: 2.27k]
  ------------------
13043|  3.10k|                   url_data[input_position + 1] == '/') {
  ------------------
  |  Branch (13043:20): [True: 2.19k, False: 906]
  ------------------
13044|  2.19k|            state = state::PATH_OR_AUTHORITY;
13045|  2.19k|            input_position++;
13046|  2.19k|          }
13047|       |          // Otherwise, set url's path to the empty string and set state to
13048|       |          // opaque path state.
13049|  3.17k|          else {
13050|  3.17k|            state = state::OPAQUE_PATH;
13051|  3.17k|          }
13052|  21.0k|        }
13053|       |        // Otherwise, if state override is not given, set buffer to the empty
13054|       |        // string, state to no scheme state, and start over (from the first code
13055|       |        // point in input).
13056|    739|        else {
13057|    739|          state = state::NO_SCHEME;
13058|    739|          input_position = 0;
13059|    739|          break;
13060|    739|        }
13061|  21.0k|        input_position++;
13062|  21.0k|        break;
13063|  21.7k|      }
13064|  22.7k|      case state::NO_SCHEME: {
  ------------------
  |  Branch (13064:7): [True: 22.7k, False: 142k]
  ------------------
13065|  22.7k|        ada_log("NO_SCHEME ", helpers::substring(url_data, input_position));
13066|       |        // The fragment was pruned from url_data before the state machine ran,
13067|       |        // so 'c is U+0023 (#)' holds exactly when a fragment was found and
13068|       |        // nothing else remains in front of it.
13069|  22.7k|        const bool c_is_hash =
13070|  22.7k|            fragment.has_value() && input_position == input_size;
  ------------------
  |  Branch (13070:13): [True: 501, False: 22.2k]
  |  Branch (13070:37): [True: 173, False: 328]
  ------------------
13071|       |        // If base is null, or base has an opaque path and c is not U+0023 (#),
13072|       |        // validation error, return failure.
13073|  22.7k|        if (base_url == nullptr || (base_url->has_opaque_path && !c_is_hash)) {
  ------------------
  |  Branch (13073:13): [True: 21.6k, False: 1.04k]
  |  Branch (13073:37): [True: 95, False: 954]
  |  Branch (13073:66): [True: 50, False: 45]
  ------------------
13074|  21.7k|          ada_log("NO_SCHEME validation error");
13075|  21.7k|          url.is_valid = false;
13076|  21.7k|          return url;
13077|  21.7k|        }
13078|       |        // Otherwise, if base has an opaque path and c is U+0023 (#),
13079|       |        // set url's scheme to base's scheme, url's path to base's path, url's
13080|       |        // query to base's query, and set state to fragment state.
13081|    999|        else if (base_url->has_opaque_path && c_is_hash) {
  ------------------
  |  Branch (13081:18): [True: 45, False: 954]
  |  Branch (13081:47): [True: 45, False: 0]
  ------------------
13082|     45|          ada_log("NO_SCHEME opaque base with fragment");
13083|     45|          url.copy_scheme(*base_url);
13084|     45|          url.has_opaque_path = base_url->has_opaque_path;
13085|       |
13086|       |          if constexpr (result_type_is_ada_url) {
13087|       |            url.path = base_url->path;
13088|       |            url.query = base_url->query;
13089|     45|          } else {
13090|     45|            url.update_base_pathname(base_url->get_pathname());
13091|     45|            if (base_url->has_search()) {
  ------------------
  |  Branch (13091:17): [True: 21, False: 24]
  ------------------
13092|       |              // get_search() returns "" for an empty query string (URL ends
13093|       |              // with '?'). update_base_search("") would incorrectly clear the
13094|       |              // query, so pass "?" to preserve the empty query distinction.
13095|     21|              auto s = base_url->get_search();
13096|     21|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (13096:38): [True: 10, False: 11]
  ------------------
13097|     21|            }
13098|     45|          }
13099|     45|          url.update_unencoded_base_hash(*fragment);
13100|     45|          enforce_max_input_length();
13101|     45|          return url;
13102|     45|        }
13103|       |        // Otherwise, if base's scheme is not "file", set state to relative
13104|       |        // state and decrease pointer by 1.
13105|       |        // NOLINTNEXTLINE(bugprone-branch-clone)
13106|    954|        else if (base_url->type != scheme::type::FILE) {
  ------------------
  |  Branch (13106:18): [True: 745, False: 209]
  ------------------
13107|    745|          ada_log("NO_SCHEME non-file relative path");
13108|    745|          state = state::RELATIVE_SCHEME;
13109|    745|        }
13110|       |        // Otherwise, set state to file state and decrease pointer by 1.
13111|    209|        else {
13112|    209|          ada_log("NO_SCHEME file base type");
13113|    209|          state = state::FILE;
13114|    209|        }
13115|    954|        break;
13116|  22.7k|      }
13117|  13.9k|      case state::AUTHORITY: {
  ------------------
  |  Branch (13117:7): [True: 13.9k, False: 150k]
  ------------------
13118|  13.9k|        ada_log("AUTHORITY ", helpers::substring(url_data, input_position));
13119|       |        // most URLs have no @. Having no @ tells us that we don't have to worry
13120|       |        // about AUTHORITY. Of course, we could have @ and still not have to
13121|       |        // worry about AUTHORITY.
13122|       |        // TODO: Instead of just collecting a bool, collect the location of the
13123|       |        // '@' and do something useful with it.
13124|       |        // TODO: We could do various processing early on, using a single pass
13125|       |        // over the string to collect information about it, e.g., telling us
13126|       |        // whether there is a @ and if so, where (or how many).
13127|       |
13128|       |        // Check if url data contains an @.
13129|  13.9k|        if (url_data.find('@', input_position) == std::string_view::npos) {
  ------------------
  |  Branch (13129:13): [True: 12.7k, False: 1.22k]
  ------------------
13130|  12.7k|          state = state::HOST;
13131|  12.7k|          break;
13132|  12.7k|        }
13133|  1.22k|        bool at_sign_seen{false};
13134|  1.22k|        bool password_token_seen{false};
13135|       |        /**
13136|       |         * We expect something of the sort...
13137|       |         * https://user:pass@example.com:1234/foo/bar?baz#quux
13138|       |         * --------^
13139|       |         */
13140|  7.59k|        do {
13141|  7.59k|          std::string_view view = url_data.substr(input_position);
13142|       |          // The delimiters are @, /, ? \\.
13143|  7.59k|          size_t location =
13144|  7.59k|              url.is_special() ? helpers::find_authority_delimiter_special(view)
  ------------------
  |  Branch (13144:15): [True: 6.86k, False: 730]
  ------------------
13145|  7.59k|                               : helpers::find_authority_delimiter(view);
13146|  7.59k|          std::string_view authority_view = view.substr(0, location);
13147|  7.59k|          size_t end_of_authority = input_position + authority_view.size();
13148|       |          // If c is U+0040 (@), then:
13149|  7.59k|          if ((end_of_authority != input_size) &&
  ------------------
  |  Branch (13149:15): [True: 6.82k, False: 776]
  ------------------
13150|  6.82k|              (url_data[end_of_authority] == '@')) {
  ------------------
  |  Branch (13150:15): [True: 6.37k, False: 449]
  ------------------
13151|       |            // If atSignSeen is true, then prepend "%40" to buffer.
13152|  6.37k|            if (at_sign_seen) {
  ------------------
  |  Branch (13152:17): [True: 5.29k, False: 1.08k]
  ------------------
13153|  5.29k|              if (password_token_seen) {
  ------------------
  |  Branch (13153:19): [True: 2.21k, False: 3.07k]
  ------------------
13154|       |                if constexpr (result_type_is_ada_url) {
13155|       |                  url.password += "%40";
13156|  2.21k|                } else {
13157|  2.21k|                  url.append_base_password("%40");
13158|  2.21k|                }
13159|  3.07k|              } else {
13160|       |                if constexpr (result_type_is_ada_url) {
13161|       |                  url.username += "%40";
13162|  3.07k|                } else {
13163|  3.07k|                  url.append_base_username("%40");
13164|  3.07k|                }
13165|  3.07k|              }
13166|  5.29k|            }
13167|       |
13168|  6.37k|            at_sign_seen = true;
13169|       |
13170|  6.37k|            if (!password_token_seen) {
  ------------------
  |  Branch (13170:17): [True: 4.15k, False: 2.21k]
  ------------------
13171|  4.15k|              size_t password_token_location = authority_view.find(':');
13172|  4.15k|              password_token_seen =
13173|  4.15k|                  password_token_location != std::string_view::npos;
13174|       |
13175|  4.15k|              if constexpr (store_values) {
13176|  4.15k|                if (!password_token_seen) {
  ------------------
  |  Branch (13176:21): [True: 3.75k, False: 401]
  ------------------
13177|       |                  if constexpr (result_type_is_ada_url) {
13178|       |                    url.username += unicode::percent_encode(
13179|       |                        authority_view,
13180|       |                        character_sets::USERINFO_PERCENT_ENCODE);
13181|  3.75k|                  } else {
13182|  3.75k|                    url.append_base_username(unicode::percent_encode(
13183|  3.75k|                        authority_view,
13184|  3.75k|                        character_sets::USERINFO_PERCENT_ENCODE));
13185|  3.75k|                  }
13186|  3.75k|                } else {
13187|       |                  if constexpr (result_type_is_ada_url) {
13188|       |                    url.username += unicode::percent_encode(
13189|       |                        authority_view.substr(0, password_token_location),
13190|       |                        character_sets::USERINFO_PERCENT_ENCODE);
13191|       |                    url.password += unicode::percent_encode(
13192|       |                        authority_view.substr(password_token_location + 1),
13193|       |                        character_sets::USERINFO_PERCENT_ENCODE);
13194|    401|                  } else {
13195|    401|                    url.append_base_username(unicode::percent_encode(
13196|    401|                        authority_view.substr(0, password_token_location),
13197|    401|                        character_sets::USERINFO_PERCENT_ENCODE));
13198|    401|                    url.append_base_password(unicode::percent_encode(
13199|    401|                        authority_view.substr(password_token_location + 1),
13200|    401|                        character_sets::USERINFO_PERCENT_ENCODE));
13201|    401|                  }
13202|    401|                }
13203|  4.15k|              }
13204|  4.15k|            } else if constexpr (store_values) {
13205|       |              if constexpr (result_type_is_ada_url) {
13206|       |                url.password += unicode::percent_encode(
13207|       |                    authority_view, character_sets::USERINFO_PERCENT_ENCODE);
13208|  2.21k|              } else {
13209|  2.21k|                url.append_base_password(unicode::percent_encode(
13210|  2.21k|                    authority_view, character_sets::USERINFO_PERCENT_ENCODE));
13211|  2.21k|              }
13212|  2.21k|            }
13213|  6.37k|          }
13214|       |          // Otherwise, if one of the following is true:
13215|       |          // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
13216|       |          // - url is special and c is U+005C (\)
13217|  1.22k|          else if (end_of_authority == input_size ||
  ------------------
  |  Branch (13217:20): [True: 776, False: 449]
  ------------------
13218|    449|                   url_data[end_of_authority] == '/' ||
  ------------------
  |  Branch (13218:20): [True: 406, False: 43]
  ------------------
13219|     43|                   url_data[end_of_authority] == '?' ||
  ------------------
  |  Branch (13219:20): [True: 36, False: 7]
  ------------------
13220|  1.22k|                   (url.is_special() && url_data[end_of_authority] == '\\')) {
  ------------------
  |  Branch (13220:21): [True: 7, False: 0]
  |  Branch (13220:41): [True: 7, False: 0]
  ------------------
13221|       |            // If atSignSeen is true and authority_view is the empty string,
13222|       |            // validation error, return failure.
13223|  1.22k|            if (at_sign_seen && authority_view.empty()) {
  ------------------
  |  Branch (13223:17): [True: 1.08k, False: 143]
  |  Branch (13223:33): [True: 337, False: 745]
  ------------------
13224|    337|              url.is_valid = false;
13225|    337|              return url;
13226|    337|            }
13227|    888|            state = state::HOST;
13228|    888|            break;
13229|  1.22k|          }
13230|  6.37k|          if (end_of_authority == input_size) {
  ------------------
  |  Branch (13230:15): [True: 0, False: 6.37k]
  ------------------
13231|      0|            if constexpr (store_values) {
13232|      0|              if (fragment.has_value()) {
  ------------------
  |  Branch (13232:19): [True: 0, False: 0]
  ------------------
13233|      0|                url.update_unencoded_base_hash(*fragment);
13234|      0|              }
13235|      0|            }
13236|      0|            enforce_max_input_length();
13237|      0|            return url;
13238|      0|          }
13239|  6.37k|          input_position = end_of_authority + 1;
13240|  6.37k|        } while (true);
  ------------------
  |  Branch (13240:18): [True: 6.37k, Folded]
  ------------------
13241|       |
13242|    888|        break;
13243|  1.22k|      }
13244|    888|      case state::SPECIAL_RELATIVE_OR_AUTHORITY: {
  ------------------
  |  Branch (13244:7): [True: 414, False: 164k]
  ------------------
13245|    414|        ada_log("SPECIAL_RELATIVE_OR_AUTHORITY ",
13246|    414|                helpers::substring(url_data, input_position));
13247|       |
13248|       |        // If c is U+002F (/) and remaining starts with U+002F (/),
13249|       |        // then set state to special authority ignore slashes state and increase
13250|       |        // pointer by 1.
13251|    414|        if (url_data.substr(input_position, 2) == "//") {
  ------------------
  |  Branch (13251:13): [True: 342, False: 72]
  ------------------
13252|    342|          state = state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
13253|    342|          input_position += 2;
13254|    342|        } else {
13255|       |          // Otherwise, validation error, set state to relative state and
13256|       |          // decrease pointer by 1.
13257|     72|          state = state::RELATIVE_SCHEME;
13258|     72|        }
13259|       |
13260|    414|        break;
13261|  1.22k|      }
13262|  2.19k|      case state::PATH_OR_AUTHORITY: {
  ------------------
  |  Branch (13262:7): [True: 2.19k, False: 162k]
  ------------------
13263|  2.19k|        ada_log("PATH_OR_AUTHORITY ",
13264|  2.19k|                helpers::substring(url_data, input_position));
13265|       |
13266|       |        // If c is U+002F (/), then set state to authority state.
13267|  2.19k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13267:13): [True: 2.08k, False: 110]
  ------------------
13268|  2.08k|            (url_data[input_position] == '/')) {
  ------------------
  |  Branch (13268:13): [True: 887, False: 1.19k]
  ------------------
13269|    887|          state = state::AUTHORITY;
13270|    887|          input_position++;
13271|  1.30k|        } else {
13272|       |          // Otherwise, set state to path state, and decrease pointer by 1.
13273|  1.30k|          state = state::PATH;
13274|  1.30k|        }
13275|       |
13276|  2.19k|        break;
13277|  1.22k|      }
13278|    817|      case state::RELATIVE_SCHEME: {
  ------------------
  |  Branch (13278:7): [True: 817, False: 164k]
  ------------------
13279|    817|        ada_log("RELATIVE_SCHEME ",
13280|    817|                helpers::substring(url_data, input_position));
13281|       |
13282|       |        // Set url's scheme to base's scheme.
13283|    817|        url.copy_scheme(*base_url);
13284|       |
13285|       |        // If c is U+002F (/), then set state to relative slash state.
13286|    817|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13286:13): [True: 669, False: 148]
  ------------------
13287|       |            // NOLINTNEXTLINE(bugprone-branch-clone)
13288|    669|            (url_data[input_position] == '/')) {
  ------------------
  |  Branch (13288:13): [True: 68, False: 601]
  ------------------
13289|     68|          ada_log(
13290|     68|              "RELATIVE_SCHEME if c is U+002F (/), then set state to relative "
13291|     68|              "slash state");
13292|     68|          state = state::RELATIVE_SLASH;
13293|    749|        } else if (url.is_special() && (input_position != input_size) &&
  ------------------
  |  Branch (13293:20): [True: 614, False: 135]
  |  Branch (13293:40): [True: 507, False: 107]
  ------------------
13294|    507|                   (url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13294:20): [True: 2, False: 505]
  ------------------
13295|       |          // Otherwise, if url is special and c is U+005C (\), validation error,
13296|       |          // set state to relative slash state.
13297|      2|          ada_log(
13298|      2|              "RELATIVE_SCHEME  if url is special and c is U+005C, validation "
13299|      2|              "error, set state to relative slash state");
13300|      2|          state = state::RELATIVE_SLASH;
13301|    747|        } else {
13302|    747|          ada_log("RELATIVE_SCHEME otherwise");
13303|       |          // Set url's username to base's username, url's password to base's
13304|       |          // password, url's host to base's host, url's port to base's port,
13305|       |          // url's path to a clone of base's path, and url's query to base's
13306|       |          // query.
13307|       |          if constexpr (result_type_is_ada_url) {
13308|       |            url.username = base_url->username;
13309|       |            url.password = base_url->password;
13310|       |            url.host = base_url->host;
13311|       |            url.port = base_url->port;
13312|       |            // cloning the base path includes cloning the has_opaque_path flag
13313|       |            url.has_opaque_path = base_url->has_opaque_path;
13314|       |            url.path = base_url->path;
13315|       |            url.query = base_url->query;
13316|    747|          } else {
13317|    747|            url.update_base_authority(base_url->get_href(),
13318|    747|                                      base_url->get_components());
13319|    747|            url.update_host_to_base_host(base_url->get_hostname());
13320|    747|            url.update_base_port(base_url->retrieve_base_port());
13321|       |            // cloning the base path includes cloning the has_opaque_path flag
13322|    747|            url.has_opaque_path = base_url->has_opaque_path;
13323|    747|            url.update_base_pathname(base_url->get_pathname());
13324|    747|            if (base_url->has_search()) {
  ------------------
  |  Branch (13324:17): [True: 85, False: 662]
  ------------------
13325|       |              // get_search() returns "" for an empty query string (URL ends
13326|       |              // with '?'). update_base_search("") would incorrectly clear the
13327|       |              // query, so pass "?" to preserve the empty query distinction.
13328|     85|              auto s = base_url->get_search();
13329|     85|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (13329:38): [True: 41, False: 44]
  ------------------
13330|     85|            }
13331|    747|          }
13332|       |
13333|    747|          url.has_opaque_path = base_url->has_opaque_path;
13334|       |
13335|       |          // If c is U+003F (?), then set url's query to the empty string, and
13336|       |          // state to query state.
13337|    747|          if ((input_position != input_size) &&
  ------------------
  |  Branch (13337:15): [True: 599, False: 148]
  ------------------
13338|    599|              (url_data[input_position] == '?')) {
  ------------------
  |  Branch (13338:15): [True: 80, False: 519]
  ------------------
13339|     80|            state = state::QUERY;
13340|     80|          }
13341|       |          // Otherwise, if c is not the EOF code point:
13342|    667|          else if (input_position != input_size) {
  ------------------
  |  Branch (13342:20): [True: 519, False: 148]
  ------------------
13343|       |            // Set url's query to null.
13344|    519|            url.clear_search();
13345|       |            if constexpr (result_type_is_ada_url) {
13346|       |              // Shorten url's path.
13347|       |              helpers::shorten_path(url.path, url.type);
13348|    519|            } else {
13349|    519|              std::string_view path = url.get_pathname();
13350|    519|              if (helpers::shorten_path(path, url.type)) {
  ------------------
  |  Branch (13350:19): [True: 515, False: 4]
  ------------------
13351|    515|                url.update_base_pathname(std::move(std::string(path)));
13352|    515|              }
13353|    519|            }
13354|       |            // Set state to path state and decrease pointer by 1.
13355|    519|            state = state::PATH;
13356|    519|            break;
13357|    519|          }
13358|    747|        }
13359|    298|        input_position++;
13360|    298|        break;
13361|    817|      }
13362|     70|      case state::RELATIVE_SLASH: {
  ------------------
  |  Branch (13362:7): [True: 70, False: 164k]
  ------------------
13363|     70|        ada_log("RELATIVE_SLASH ",
13364|     70|                helpers::substring(url_data, input_position));
13365|       |
13366|       |        // If url is special and c is U+002F (/) or U+005C (\), then:
13367|       |        // NOLINTNEXTLINE(bugprone-branch-clone)
13368|     70|        if (url.is_special() && (input_position != input_size) &&
  ------------------
  |  Branch (13368:13): [True: 51, False: 19]
  |  Branch (13368:33): [True: 42, False: 9]
  ------------------
13369|     42|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13369:14): [True: 4, False: 38]
  ------------------
13370|     38|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13370:14): [True: 2, False: 36]
  ------------------
13371|       |          // Set state to special authority ignore slashes state.
13372|      6|          state = state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
13373|      6|        }
13374|       |        // Otherwise, if c is U+002F (/), then set state to authority state.
13375|     64|        else if ((input_position != input_size) &&
  ------------------
  |  Branch (13375:18): [True: 46, False: 18]
  ------------------
13376|     46|                 (url_data[input_position] == '/')) {
  ------------------
  |  Branch (13376:18): [True: 5, False: 41]
  ------------------
13377|      5|          state = state::AUTHORITY;
13378|      5|        }
13379|       |        // Otherwise, set
13380|       |        // - url's username to base's username,
13381|       |        // - url's password to base's password,
13382|       |        // - url's host to base's host,
13383|       |        // - url's port to base's port,
13384|       |        // - state to path state, and then, decrease pointer by 1.
13385|     59|        else {
13386|       |          if constexpr (result_type_is_ada_url) {
13387|       |            url.username = base_url->username;
13388|       |            url.password = base_url->password;
13389|       |            url.host = base_url->host;
13390|       |            url.port = base_url->port;
13391|     59|          } else {
13392|     59|            url.update_base_authority(base_url->get_href(),
13393|     59|                                      base_url->get_components());
13394|     59|            url.update_host_to_base_host(base_url->get_hostname());
13395|     59|            url.update_base_port(base_url->retrieve_base_port());
13396|     59|          }
13397|     59|          state = state::PATH;
13398|     59|          break;
13399|     59|        }
13400|       |
13401|     11|        input_position++;
13402|     11|        break;
13403|     70|      }
13404|  12.6k|      case state::SPECIAL_AUTHORITY_SLASHES: {
  ------------------
  |  Branch (13404:7): [True: 12.6k, False: 152k]
  ------------------
13405|  12.6k|        ada_log("SPECIAL_AUTHORITY_SLASHES ",
13406|  12.6k|                helpers::substring(url_data, input_position));
13407|       |
13408|       |        // If c is U+002F (/) and remaining starts with U+002F (/),
13409|       |        // then set state to special authority ignore slashes state and increase
13410|       |        // pointer by 1.
13411|  12.6k|        if (url_data.substr(input_position, 2) == "//") {
  ------------------
  |  Branch (13411:13): [True: 3.23k, False: 9.45k]
  ------------------
13412|  3.23k|          input_position += 2;
13413|  3.23k|        }
13414|       |
13415|  12.6k|        [[fallthrough]];
13416|  12.6k|      }
13417|  13.0k|      case state::SPECIAL_AUTHORITY_IGNORE_SLASHES: {
  ------------------
  |  Branch (13417:7): [True: 348, False: 164k]
  ------------------
13418|  13.0k|        ada_log("SPECIAL_AUTHORITY_IGNORE_SLASHES ",
13419|  13.0k|                helpers::substring(url_data, input_position));
13420|       |
13421|       |        // If c is neither U+002F (/) nor U+005C (\), then set state to
13422|       |        // authority state and decrease pointer by 1.
13423|  14.0k|        while ((input_position != input_size) &&
  ------------------
  |  Branch (13423:16): [True: 13.9k, False: 86]
  ------------------
13424|  13.9k|               ((url_data[input_position] == '/') ||
  ------------------
  |  Branch (13424:17): [True: 644, False: 13.3k]
  ------------------
13425|  13.3k|                (url_data[input_position] == '\\'))) {
  ------------------
  |  Branch (13425:17): [True: 393, False: 12.9k]
  ------------------
13426|  1.03k|          input_position++;
13427|  1.03k|        }
13428|  13.0k|        state = state::AUTHORITY;
13429|       |
13430|  13.0k|        break;
13431|  12.6k|      }
13432|  1.17k|      case state::QUERY: {
  ------------------
  |  Branch (13432:7): [True: 1.17k, False: 163k]
  ------------------
13433|  1.17k|        ada_log("QUERY ", helpers::substring(url_data, input_position));
13434|  1.17k|        if constexpr (store_values) {
13435|       |          // Let queryPercentEncodeSet be the special-query percent-encode set
13436|       |          // if url is special; otherwise the query percent-encode set.
13437|  1.17k|          const uint8_t* query_percent_encode_set =
13438|  1.17k|              url.is_special() ? character_sets::SPECIAL_QUERY_PERCENT_ENCODE
  ------------------
  |  Branch (13438:15): [True: 762, False: 414]
  ------------------
13439|  1.17k|                               : character_sets::QUERY_PERCENT_ENCODE;
13440|       |
13441|       |          // Percent-encode after encoding, with encoding, buffer, and
13442|       |          // queryPercentEncodeSet, and append the result to url's query.
13443|  1.17k|          url.update_base_search(url_data.substr(input_position),
13444|  1.17k|                                 query_percent_encode_set);
13445|  1.17k|          ada_log("QUERY update_base_search completed ");
13446|  1.17k|          if (fragment.has_value()) {
  ------------------
  |  Branch (13446:15): [True: 307, False: 869]
  ------------------
13447|    307|            url.update_unencoded_base_hash(*fragment);
13448|    307|          }
13449|  1.17k|        }
13450|  1.17k|        enforce_max_input_length();
13451|  1.17k|        return url;
13452|  12.6k|      }
13453|  13.5k|      case state::HOST: {
  ------------------
  |  Branch (13453:7): [True: 13.5k, False: 151k]
  ------------------
13454|  13.5k|        ada_log("HOST ", helpers::substring(url_data, input_position));
13455|       |
13456|  13.5k|        std::string_view host_view = url_data.substr(input_position);
13457|  13.5k|        auto [location, found_colon] =
13458|  13.5k|            helpers::get_host_delimiter_location(url.is_special(), host_view);
13459|  13.5k|        input_position = (location != std::string_view::npos)
  ------------------
  |  Branch (13459:26): [True: 13.5k, False: 0]
  ------------------
13460|  13.5k|                             ? input_position + location
13461|  13.5k|                             : input_size;
13462|       |        // Otherwise, if c is U+003A (:) and insideBrackets is false, then:
13463|       |        // Note: the 'found_colon' value is true if and only if a colon was
13464|       |        // encountered while not inside brackets.
13465|  13.5k|        if (found_colon) {
  ------------------
  |  Branch (13465:13): [True: 2.43k, False: 11.1k]
  ------------------
13466|       |          // If buffer is the empty string, validation error, return failure.
13467|       |          // Let host be the result of host parsing buffer with url is not
13468|       |          // special.
13469|  2.43k|          ada_log("HOST parsing ", host_view);
13470|  2.43k|          if (!url.parse_host(host_view)) {
  ------------------
  |  Branch (13470:15): [True: 211, False: 2.22k]
  ------------------
13471|    211|            return url;
13472|    211|          }
13473|  2.22k|          ada_log("HOST parsing results in ", url.get_hostname());
13474|       |          // Set url's host to host, buffer to the empty string, and state to
13475|       |          // port state.
13476|  2.22k|          state = state::PORT;
13477|  2.22k|          input_position++;
13478|  2.22k|        }
13479|       |        // Otherwise, if one of the following is true:
13480|       |        // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
13481|       |        // - url is special and c is U+005C (\)
13482|       |        // The get_host_delimiter_location function either brings us to
13483|       |        // the colon outside of the bracket, or to one of those characters.
13484|  11.1k|        else {
13485|       |          // If url is special and host_view is the empty string, validation
13486|       |          // error, return failure.
13487|  11.1k|          if (host_view.empty() && url.is_special()) {
  ------------------
  |  Branch (13487:15): [True: 222, False: 10.9k]
  |  Branch (13487:36): [True: 91, False: 131]
  ------------------
13488|     91|            url.is_valid = false;
13489|     91|            return url;
13490|     91|          }
13491|  11.0k|          ada_log("HOST parsing ", host_view, " href=", url.get_href());
13492|       |          // Let host be the result of host parsing host_view with url is not
13493|       |          // special.
13494|  11.0k|          if (host_view.empty()) {
  ------------------
  |  Branch (13494:15): [True: 131, False: 10.9k]
  ------------------
13495|    131|            url.update_base_hostname("");
13496|  10.9k|          } else if (!url.parse_host(host_view)) {
  ------------------
  |  Branch (13496:22): [True: 2.29k, False: 8.63k]
  ------------------
13497|  2.29k|            return url;
13498|  2.29k|          }
13499|  8.76k|          ada_log("HOST parsing results in ", url.get_hostname(),
13500|  8.76k|                  " href=", url.get_href());
13501|       |
13502|       |          // Set url's host to host, and state to path start state.
13503|  8.76k|          state = state::PATH_START;
13504|  8.76k|        }
13505|       |
13506|  10.9k|        break;
13507|  13.5k|      }
13508|  10.9k|      case state::OPAQUE_PATH: {
  ------------------
  |  Branch (13508:7): [True: 3.17k, False: 161k]
  ------------------
13509|  3.17k|        ada_log("OPAQUE_PATH ", helpers::substring(url_data, input_position));
13510|       |        // Opaque path, query, and fragment are structurally always valid:
13511|       |        // the parser would just percent-encode whatever is there. When we
13512|       |        // are not storing values (can_parse), we can return immediately.
13513|       |        // We must set has_opaque_path = true before returning so that when
13514|       |        // this URL is used as an internal base inside can_parse, NO_SCHEME
13515|       |        // correctly rejects relative inputs against an opaque-path base
13516|       |        // (e.g. can_parse("", &"W:") must return false).
13517|       |        if constexpr (!store_values) {
13518|       |          url.has_opaque_path = true;
13519|       |          return url;
13520|       |        }
13521|  3.17k|        std::string_view view = url_data.substr(input_position);
13522|       |        // If c is U+003F (?), then set url's query to the empty string and
13523|       |        // state to query state.
13524|  3.17k|        size_t location = view.find('?');
13525|  3.17k|        if (location != std::string_view::npos) {
  ------------------
  |  Branch (13525:13): [True: 281, False: 2.89k]
  ------------------
13526|    281|          view.remove_suffix(view.size() - location);
13527|    281|          state = state::QUERY;
13528|    281|          input_position += location + 1;
13529|  2.89k|        } else {
13530|  2.89k|          input_position = input_size + 1;
13531|  2.89k|        }
13532|  3.17k|        url.has_opaque_path = true;
13533|       |
13534|       |        // This is a really unlikely scenario in real world. We should not seek
13535|       |        // to optimize it.
13536|  3.17k|        if (view.ends_with(' ')) {
  ------------------
  |  Branch (13536:13): [True: 112, False: 3.06k]
  ------------------
13537|    112|          std::string modified_view =
13538|    112|              std::string(view.substr(0, view.size() - 1)) + "%20";
13539|    112|          url.update_base_pathname(unicode::percent_encode(
13540|    112|              modified_view, character_sets::C0_CONTROL_PERCENT_ENCODE));
13541|  3.06k|        } else {
13542|  3.06k|          url.update_base_pathname(unicode::percent_encode(
13543|  3.06k|              view, character_sets::C0_CONTROL_PERCENT_ENCODE));
13544|  3.06k|        }
13545|  3.17k|        break;
13546|  13.5k|      }
13547|  2.22k|      case state::PORT: {
  ------------------
  |  Branch (13547:7): [True: 2.22k, False: 162k]
  ------------------
13548|  2.22k|        ada_log("PORT ", helpers::substring(url_data, input_position));
13549|  2.22k|        std::string_view port_view = url_data.substr(input_position);
13550|  2.22k|        input_position += url.parse_port(port_view, true);
13551|  2.22k|        if (!url.is_valid) {
  ------------------
  |  Branch (13551:13): [True: 118, False: 2.11k]
  ------------------
13552|    118|          return url;
13553|    118|        }
13554|  2.11k|        state = state::PATH_START;
13555|  2.11k|        [[fallthrough]];
13556|  2.11k|      }
13557|  12.7k|      case state::PATH_START: {
  ------------------
  |  Branch (13557:7): [True: 10.6k, False: 154k]
  ------------------
13558|  12.7k|        ada_log("PATH_START ", helpers::substring(url_data, input_position));
13559|       |        // Path, query, and fragment are structurally always valid: the
13560|       |        // parser would just percent-encode whatever is there. When we are
13561|       |        // not storing values (can_parse), we can return immediately since
13562|       |        // no subsequent state can invalidate the URL.
13563|       |        if constexpr (!store_values) {
13564|       |          return url;
13565|       |        }
13566|       |
13567|       |        // If url is special, then:
13568|  12.7k|        if (url.is_special()) {
  ------------------
  |  Branch (13568:13): [True: 12.0k, False: 755]
  ------------------
13569|       |          // Set state to path state.
13570|  12.0k|          state = state::PATH;
13571|       |
13572|       |          // Optimization: Avoiding going into PATH state improves the
13573|       |          // performance of urls ending with /.
13574|  12.0k|          if (input_position == input_size) {
  ------------------
  |  Branch (13574:15): [True: 6.42k, False: 5.59k]
  ------------------
13575|  6.42k|            if constexpr (store_values) {
13576|  6.42k|              url.update_base_pathname("/");
13577|  6.42k|              if (fragment.has_value()) {
  ------------------
  |  Branch (13577:19): [True: 166, False: 6.26k]
  ------------------
13578|    166|                url.update_unencoded_base_hash(*fragment);
13579|    166|              }
13580|  6.42k|            }
13581|  6.42k|            enforce_max_input_length();
13582|  6.42k|            return url;
13583|  6.42k|          }
13584|       |          // If c is neither U+002F (/) nor U+005C (\), then decrease pointer
13585|       |          // by 1. We know that (input_position == input_size) is impossible
13586|       |          // here, because of the previous if-check.
13587|  5.59k|          if ((url_data[input_position] != '/') &&
  ------------------
  |  Branch (13587:15): [True: 387, False: 5.20k]
  ------------------
13588|    387|              (url_data[input_position] != '\\')) {
  ------------------
  |  Branch (13588:15): [True: 373, False: 14]
  ------------------
13589|    373|            break;
13590|    373|          }
13591|  5.59k|        }
13592|       |        // Otherwise, if state override is not given and c is U+003F (?),
13593|       |        // set url's query to the empty string and state to query state.
13594|    755|        else if ((input_position != input_size) &&
  ------------------
  |  Branch (13594:18): [True: 160, False: 595]
  ------------------
13595|    160|                 (url_data[input_position] == '?')) {
  ------------------
  |  Branch (13595:18): [True: 51, False: 109]
  ------------------
13596|     51|          state = state::QUERY;
13597|     51|        }
13598|       |        // Otherwise, if c is not the EOF code point:
13599|    704|        else if (input_position != input_size) {
  ------------------
  |  Branch (13599:18): [True: 109, False: 595]
  ------------------
13600|       |          // Set state to path state.
13601|    109|          state = state::PATH;
13602|       |
13603|       |          // If c is not U+002F (/), then decrease pointer by 1.
13604|    109|          if (url_data[input_position] != '/') {
  ------------------
  |  Branch (13604:15): [True: 0, False: 109]
  ------------------
13605|      0|            break;
13606|      0|          }
13607|    109|        }
13608|       |
13609|  5.97k|        input_position++;
13610|  5.97k|        break;
13611|  12.7k|      }
13612|  8.23k|      case state::PATH: {
  ------------------
  |  Branch (13612:7): [True: 8.23k, False: 156k]
  ------------------
13613|  8.23k|        ada_log("PATH ", helpers::substring(url_data, input_position));
13614|       |        // Path, query, and fragment are structurally always valid: the
13615|       |        // parser would just percent-encode whatever is there. When we are
13616|       |        // not storing values (can_parse), we can return immediately since
13617|       |        // no subsequent state can invalidate the URL.
13618|       |        if constexpr (!store_values) {
13619|       |          return url;
13620|       |        }
13621|  8.23k|        std::string_view view = url_data.substr(input_position);
13622|       |
13623|       |        // Most time, we do not need percent encoding.
13624|       |        // Furthermore, we can immediately locate the '?'.
13625|  8.23k|        size_t locofquestionmark = view.find('?');
13626|  8.23k|        if (locofquestionmark != std::string_view::npos) {
  ------------------
  |  Branch (13626:13): [True: 760, False: 7.47k]
  ------------------
13627|    760|          state = state::QUERY;
13628|    760|          view.remove_suffix(view.size() - locofquestionmark);
13629|    760|          input_position += locofquestionmark + 1;
13630|  7.47k|        } else {
13631|  7.47k|          input_position = input_size + 1;
13632|  7.47k|        }
13633|  8.23k|        if constexpr (store_values) {
13634|       |          if constexpr (result_type_is_ada_url) {
13635|       |            helpers::parse_prepared_path(view, url.type, url.path);
13636|  8.23k|          } else {
13637|  8.23k|            url.consume_prepared_path(view);
13638|  8.23k|            ADA_ASSERT_TRUE(url.validate());
13639|  8.23k|          }
13640|  8.23k|        }
13641|  8.23k|        break;
13642|  12.7k|      }
13643|  2.20k|      case state::FILE_SLASH: {
  ------------------
  |  Branch (13643:7): [True: 2.20k, False: 162k]
  ------------------
13644|  2.20k|        ada_log("FILE_SLASH ", helpers::substring(url_data, input_position));
13645|       |
13646|       |        // If c is U+002F (/) or U+005C (\), then:
13647|  2.20k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13647:13): [True: 2.13k, False: 67]
  ------------------
13648|  2.13k|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13648:14): [True: 2.08k, False: 49]
  ------------------
13649|  2.09k|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13649:14): [True: 6, False: 43]
  ------------------
13650|  2.09k|          ada_log("FILE_SLASH c is U+002F or U+005C");
13651|       |          // Set state to file host state.
13652|  2.09k|          state = state::FILE_HOST;
13653|  2.09k|          input_position++;
13654|  2.09k|        } else {
13655|    110|          ada_log("FILE_SLASH otherwise");
13656|       |          // If base is non-null and base's scheme is "file", then:
13657|       |          // Note: it is unsafe to do base_url->scheme unless you know that
13658|       |          // base_url_has_value() is true.
13659|    110|          if (base_url != nullptr && base_url->type == scheme::type::FILE) {
  ------------------
  |  Branch (13659:15): [True: 88, False: 22]
  |  Branch (13659:38): [True: 86, False: 2]
  ------------------
13660|       |            // Set url's host to base's host.
13661|       |            if constexpr (result_type_is_ada_url) {
13662|       |              url.host = base_url->host;
13663|     86|            } else {
13664|     86|              url.update_host_to_base_host(base_url->get_host());
13665|     86|            }
13666|       |            // If the code point substring from pointer to the end of input does
13667|       |            // not start with a Windows drive letter and base's path[0] is a
13668|       |            // normalized Windows drive letter, then append base's path[0] to
13669|       |            // url's path.
13670|     86|            if (!base_url->get_pathname().empty()) {
  ------------------
  |  Branch (13670:17): [True: 86, False: 0]
  ------------------
13671|     86|              if (!checkers::is_windows_drive_letter(
  ------------------
  |  Branch (13671:19): [True: 81, False: 5]
  ------------------
13672|     86|                      url_data.substr(input_position))) {
13673|     81|                std::string_view first_base_url_path =
13674|     81|                    base_url->get_pathname().substr(1);
13675|     81|                size_t loc = first_base_url_path.find('/');
13676|     81|                if (loc != std::string_view::npos) {
  ------------------
  |  Branch (13676:21): [True: 11, False: 70]
  ------------------
13677|     11|                  helpers::resize(first_base_url_path, loc);
13678|     11|                }
13679|     81|                if (checkers::is_normalized_windows_drive_letter(
  ------------------
  |  Branch (13679:21): [True: 2, False: 79]
  ------------------
13680|     81|                        first_base_url_path)) {
13681|       |                  if constexpr (result_type_is_ada_url) {
13682|       |                    url.path += '/';
13683|       |                    url.path += first_base_url_path;
13684|      2|                  } else {
13685|      2|                    url.append_base_pathname(
13686|      2|                        helpers::concat("/", first_base_url_path));
13687|      2|                  }
13688|      2|                }
13689|     81|              }
13690|     86|            }
13691|     86|          }
13692|       |
13693|       |          // Set state to path state, and decrease pointer by 1.
13694|    110|          state = state::PATH;
13695|    110|        }
13696|       |
13697|  2.20k|        break;
13698|  12.7k|      }
13699|  2.09k|      case state::FILE_HOST: {
  ------------------
  |  Branch (13699:7): [True: 2.09k, False: 162k]
  ------------------
13700|  2.09k|        ada_log("FILE_HOST ", helpers::substring(url_data, input_position));
13701|  2.09k|        std::string_view view = url_data.substr(input_position);
13702|       |
13703|  2.09k|        size_t location = view.find_first_of("/\\?");
13704|  2.09k|        std::string_view file_host_buffer = view.substr(
13705|  2.09k|            0, (location != std::string_view::npos) ? location : view.size());
  ------------------
  |  Branch (13705:16): [True: 890, False: 1.20k]
  ------------------
13706|       |
13707|  2.09k|        if (checkers::is_windows_drive_letter(file_host_buffer)) {
  ------------------
  |  Branch (13707:13): [True: 12, False: 2.08k]
  ------------------
13708|     12|          state = state::PATH;
13709|  2.08k|        } else if (file_host_buffer.empty()) {
  ------------------
  |  Branch (13709:20): [True: 257, False: 1.82k]
  ------------------
13710|       |          // Set url's host to the empty string.
13711|       |          if constexpr (result_type_is_ada_url) {
13712|       |            url.host = "";
13713|    257|          } else {
13714|    257|            url.update_base_hostname("");
13715|    257|          }
13716|       |          // Set state to path start state.
13717|    257|          state = state::PATH_START;
13718|  1.82k|        } else {
13719|  1.82k|          size_t consumed_bytes = file_host_buffer.size();
13720|  1.82k|          input_position += consumed_bytes;
13721|       |          // Let host be the result of host parsing buffer with url is not
13722|       |          // special.
13723|  1.82k|          if (!url.parse_host(file_host_buffer)) {
  ------------------
  |  Branch (13723:15): [True: 188, False: 1.63k]
  ------------------
13724|    188|            return url;
13725|    188|          }
13726|       |
13727|       |          if constexpr (result_type_is_ada_url) {
13728|       |            // If host is "localhost", then set host to the empty string.
13729|       |            if (url.host.has_value() && url.host.value() == "localhost") {
13730|       |              url.host = "";
13731|       |            }
13732|  1.63k|          } else {
13733|  1.63k|            if (url.get_hostname() == "localhost") {
  ------------------
  |  Branch (13733:17): [True: 12, False: 1.62k]
  ------------------
13734|     12|              url.update_base_hostname("");
13735|     12|            }
13736|  1.63k|          }
13737|       |
13738|       |          // Set buffer to the empty string and state to path start state.
13739|  1.63k|          state = state::PATH_START;
13740|  1.63k|        }
13741|       |
13742|  1.90k|        break;
13743|  2.09k|      }
13744|  2.77k|      case state::FILE: {
  ------------------
  |  Branch (13744:7): [True: 2.77k, False: 162k]
  ------------------
13745|  2.77k|        ada_log("FILE ", helpers::substring(url_data, input_position));
13746|  2.77k|        std::string_view file_view = url_data.substr(input_position);
13747|       |
13748|  2.77k|        url.set_protocol_as_file();
13749|       |        if constexpr (result_type_is_ada_url) {
13750|       |          // Set url's host to the empty string.
13751|       |          url.host = "";
13752|  2.77k|        } else {
13753|  2.77k|          url.update_base_hostname("");
13754|  2.77k|        }
13755|       |        // If c is U+002F (/) or U+005C (\), then:
13756|  2.77k|        if (input_position != input_size &&
  ------------------
  |  Branch (13756:13): [True: 2.66k, False: 108]
  ------------------
13757|  2.66k|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13757:14): [True: 2.19k, False: 473]
  ------------------
13758|  2.20k|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13758:14): [True: 7, False: 466]
  ------------------
13759|  2.20k|          ada_log("FILE c is U+002F or U+005C");
13760|       |          // Set state to file slash state.
13761|  2.20k|          state = state::FILE_SLASH;
13762|  2.20k|        }
13763|       |        // Otherwise, if base is non-null and base's scheme is "file":
13764|    574|        else if (base_url != nullptr && base_url->type == scheme::type::FILE) {
  ------------------
  |  Branch (13764:18): [True: 206, False: 368]
  |  Branch (13764:41): [True: 140, False: 66]
  ------------------
13765|       |          // Set url's host to base's host, url's path to a clone of base's
13766|       |          // path, and url's query to base's query.
13767|    140|          ada_log("FILE base non-null");
13768|       |          if constexpr (result_type_is_ada_url) {
13769|       |            url.host = base_url->host;
13770|       |            url.path = base_url->path;
13771|       |            url.query = base_url->query;
13772|    140|          } else {
13773|    140|            url.update_host_to_base_host(base_url->get_hostname());
13774|    140|            url.update_base_pathname(base_url->get_pathname());
13775|    140|            if (base_url->has_search()) {
  ------------------
  |  Branch (13775:17): [True: 43, False: 97]
  ------------------
13776|       |              // get_search() returns "" for an empty query string (URL ends
13777|       |              // with '?'). update_base_search("") would incorrectly clear the
13778|       |              // query, so pass "?" to preserve the empty query distinction.
13779|     43|              auto s = base_url->get_search();
13780|     43|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (13780:38): [True: 16, False: 27]
  ------------------
13781|     43|            }
13782|    140|          }
13783|    140|          url.has_opaque_path = base_url->has_opaque_path;
13784|       |
13785|       |          // If c is U+003F (?), then set url's query to the empty string and
13786|       |          // state to query state.
13787|    140|          if (input_position != input_size && url_data[input_position] == '?') {
  ------------------
  |  Branch (13787:15): [True: 93, False: 47]
  |  Branch (13787:47): [True: 4, False: 89]
  ------------------
13788|      4|            state = state::QUERY;
13789|      4|          }
13790|       |          // Otherwise, if c is not the EOF code point:
13791|    136|          else if (input_position != input_size) {
  ------------------
  |  Branch (13791:20): [True: 89, False: 47]
  ------------------
13792|       |            // Set url's query to null.
13793|     89|            url.clear_search();
13794|       |            // If the code point substring from pointer to the end of input does
13795|       |            // not start with a Windows drive letter, then shorten url's path.
13796|     89|            if (!checkers::is_windows_drive_letter(file_view)) {
  ------------------
  |  Branch (13796:17): [True: 76, False: 13]
  ------------------
13797|       |              if constexpr (result_type_is_ada_url) {
13798|       |                helpers::shorten_path(url.path, url.type);
13799|     76|              } else {
13800|     76|                std::string_view path = url.get_pathname();
13801|     76|                if (helpers::shorten_path(path, url.type)) {
  ------------------
  |  Branch (13801:21): [True: 74, False: 2]
  ------------------
13802|     74|                  url.update_base_pathname(std::move(std::string(path)));
13803|     74|                }
13804|     76|              }
13805|     76|            }
13806|       |            // Otherwise:
13807|     13|            else {
13808|       |              // Set url's path to an empty list.
13809|     13|              url.clear_pathname();
13810|     13|              url.has_opaque_path = true;
13811|     13|            }
13812|       |
13813|       |            // Set state to path state and decrease pointer by 1.
13814|     89|            state = state::PATH;
13815|     89|            break;
13816|     89|          }
13817|    140|        }
13818|       |        // Otherwise, set state to path state, and decrease pointer by 1.
13819|    434|        else {
13820|    434|          ada_log("FILE go to path");
13821|    434|          state = state::PATH;
13822|    434|          break;
13823|    434|        }
13824|       |
13825|  2.25k|        input_position++;
13826|  2.25k|        break;
13827|  2.77k|      }
13828|      0|      default:
  ------------------
  |  Branch (13828:7): [True: 0, False: 164k]
  ------------------
13829|      0|        unreachable();
13830|   164k|    }
13831|   164k|  }
13832|  16.4k|  if constexpr (store_values) {
13833|  16.4k|    if (fragment.has_value()) {
  ------------------
  |  Branch (13833:9): [True: 346, False: 16.0k]
  ------------------
13834|    346|      url.update_unencoded_base_hash(*fragment);
13835|    346|    }
13836|  16.4k|  }
13837|  16.4k|  enforce_max_input_length();
13838|  16.4k|  return url;
13839|  49.0k|}
_ZN3ada6parser14parse_url_implINS_14url_aggregatorELb0EEET_NSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEPKS3_:
12819|  30.3k|                           const result_type* base_url) {
12820|       |  // We can specialize the implementation per type.
12821|       |  // Important: result_type_is_ada_url is evaluated at *compile time*. This
12822|       |  // means that doing if constexpr(result_type_is_ada_url) { something } else {
12823|       |  // something else } is free (at runtime). This means that ada::url_aggregator
12824|       |  // and ada::url **do not have to support the exact same API**.
12825|  30.3k|  constexpr bool result_type_is_ada_url = std::is_same_v<url, result_type>;
12826|  30.3k|  constexpr bool result_type_is_ada_url_aggregator =
12827|  30.3k|      std::is_same_v<url_aggregator, result_type>;
12828|  30.3k|  static_assert(result_type_is_ada_url ||
12829|  30.3k|                result_type_is_ada_url_aggregator);  // We don't support
12830|       |                                                     // anything else for now.
12831|       |
12832|  30.3k|  ada_log("ada::parser::parse_url('", user_input, "' [", user_input.size(),
12833|  30.3k|          " bytes],", (base_url != nullptr ? base_url->to_string() : "null"),
12834|  30.3k|          ")");
12835|       |
12836|  30.3k|  result_type url{};
12837|       |
12838|  30.3k|  const uint32_t max_input_length = ada::get_max_input_length();
12839|       |
12840|       |  // Normalization (percent-encoding, IDNA) can push the serialized URL past
12841|       |  // max_input_length even when the input fit under it. The check at the end of
12842|       |  // the state machine covers URLs that run to completion, but several states
12843|       |  // return early after appending a query or fragment, so run the same check on
12844|       |  // those exits too. Without this, a query- or fragment-terminated URL such as
12845|       |  // file://x/?<...> or https://user@x/?<...> is accepted while the equivalent
12846|       |  // https://x/?<...> that takes the absolute fast path is rejected.
12847|  30.3k|  const auto enforce_max_input_length = [&]() {
12848|  30.3k|    if constexpr (store_values) {
12849|  30.3k|      if (url.is_valid) {
12850|  30.3k|        if constexpr (result_type_is_ada_url_aggregator) {
12851|  30.3k|          if (url.buffer.size() > max_input_length) [[unlikely]] {
12852|  30.3k|            url.is_valid = false;
12853|  30.3k|          }
12854|  30.3k|        } else {
12855|  30.3k|          if (url.get_href_size() > max_input_length) [[unlikely]] {
12856|  30.3k|            url.is_valid = false;
12857|  30.3k|          }
12858|  30.3k|        }
12859|  30.3k|      }
12860|  30.3k|    }
12861|  30.3k|  };
12862|       |
12863|       |  // We refuse to parse URL strings that exceed the maximum input length.
12864|       |  // By default, this is 4GB but can be configured via
12865|       |  // ada::set_max_input_length().
12866|  30.3k|  if (user_input.size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (12866:7): [True: 0, False: 30.3k]
  ------------------
12867|      0|    url.is_valid = false;
12868|      0|  }
12869|       |  // Going forward, user_input.size() is in [0,
12870|       |  // std::numeric_limits<uint32_t>::max). If we are provided with an invalid
12871|       |  // base, or the optional_url was invalid, we must return.
12872|  30.3k|  if (base_url != nullptr) {
  ------------------
  |  Branch (12872:7): [True: 4.35k, False: 26.0k]
  ------------------
12873|  4.35k|    url.is_valid &= base_url->is_valid;
12874|  4.35k|  }
12875|  30.3k|  if (!url.is_valid) {
  ------------------
  |  Branch (12875:7): [True: 0, False: 30.3k]
  ------------------
12876|      0|    return url;
12877|      0|  }
12878|       |
12879|       |  // Simple absolute / relative fast paths (before tabs/newline scan).
12880|       |  if constexpr (store_values) {
12881|       |    bool hit_fast_path = false;
12882|       |    if (base_url == nullptr) {
12883|       |      // IPv4/IPv6 and userinfo miss the fast path. Skip the never_inline
12884|       |      // call so those URLs (including SetHref) do not pay for a miss.
12885|       |      const auto* p = reinterpret_cast<const uint8_t*>(user_input.data());
12886|       |      const size_t n = user_input.size();
12887|       |      size_t host_start = 0;
12888|       |      if (n >= 8 && p[4] == ':' && p[5] == '/' && p[6] == '/') {
12889|       |        host_start = 7;
12890|       |      } else if (n >= 9 && p[5] == ':' && p[6] == '/' && p[7] == '/') {
12891|       |        host_start = 8;
12892|       |      }
12893|       |      const uint8_t host_first = host_start != 0 ? p[host_start] : 0;
12894|       |      const bool skip_ip =
12895|       |          host_first == '[' || (host_first >= '0' && host_first <= '9');
12896|       |      const bool skip_userinfo =
12897|       |          host_start != 0 && authority_has_at(p, host_start, n);
12898|       |      hit_fast_path = !skip_ip && !skip_userinfo &&
12899|       |                      try_parse_simple_absolute(user_input, url);
12900|       |    } else {
12901|       |      hit_fast_path = try_parse_simple_relative(user_input, *base_url, url);
12902|       |    }
12903|       |    if (hit_fast_path) {
12904|       |      if constexpr (result_type_is_ada_url_aggregator) {
12905|       |        if (url.buffer.size() > max_input_length) [[unlikely]] {
12906|       |          url.is_valid = false;
12907|       |        }
12908|       |      } else {
12909|       |        // For a small absolute input, even worst-case normalization cannot
12910|       |        // exceed the limit: percent encoding expands at most 3x and IDNA at
12911|       |        // most 4.5x. Avoid traversing every stored component on the common
12912|       |        // default-limit path.
12913|       |        if ((base_url != nullptr ||
12914|       |             user_input.size() > static_cast<size_t>(max_input_length) / 5) &&
12915|       |            url.get_href_size() > max_input_length) [[unlikely]] {
12916|       |          url.is_valid = false;
12917|       |        }
12918|       |      }
12919|       |      return url;
12920|       |    }
12921|       |  }
12922|       |
12923|  30.3k|  state state = state::SCHEME_START;
12924|       |
12925|  30.3k|  std::string tmp_buffer;
12926|  30.3k|  std::string_view url_data;
12927|  30.3k|  if (unicode::has_tabs_or_newline(user_input)) [[unlikely]] {
  ------------------
  |  Branch (12927:7): [True: 277, False: 30.0k]
  ------------------
12928|    277|    tmp_buffer = user_input;
12929|       |    // Optimization opportunity: Instead of copying and then pruning, we could
12930|       |    // just directly build the string from user_input.
12931|    277|    helpers::remove_ascii_tab_or_newline(tmp_buffer);
12932|    277|    url_data = tmp_buffer;
12933|  30.0k|  } else [[likely]] {
12934|  30.0k|    url_data = user_input;
12935|  30.0k|  }
12936|       |
12937|       |  // Leading and trailing control characters are uncommon and easy to deal with
12938|       |  // (no performance concern).
12939|  30.3k|  helpers::trim_c0_whitespace(url_data);
12940|       |
12941|       |  if constexpr (result_type_is_ada_url_aggregator && store_values) {
12942|       |    // Most of the time, we just need user_input.size().
12943|       |    // In some instances, we may need a bit more.
12944|       |    ///////////////////////////
12945|       |    // This is *very* important. This line should *not* be removed
12946|       |    // hastily. There are principled reasons why reserve is important
12947|       |    // for performance. If you have a benchmark with small inputs,
12948|       |    // it may not matter, but in other instances, it could.
12949|       |    ////
12950|       |    // This rounds up to the next power of two.
12951|       |    // We know that user_input.size() is in [0,
12952|       |    // std::numeric_limits<uint32_t>::max).
12953|       |    uint32_t reserve_capacity =
12954|       |        (0xFFFFFFFF >>
12955|       |         helpers::leading_zeroes(uint32_t(1 | user_input.size()))) +
12956|       |        1;
12957|       |    url.reserve(reserve_capacity);
12958|       |  }
12959|       |
12960|       |  // Optimization opportunity. Most websites do not have fragment.
12961|  30.3k|  std::optional<std::string_view> fragment = helpers::prune_hash(url_data);
12962|       |  // We add it last so that an implementation like ada::url_aggregator
12963|       |  // can append it last to its internal buffer, thus improving performance.
12964|       |
12965|       |  // Here url_data no longer has its fragment.
12966|       |  // We are going to access the data from url_data (it is immutable).
12967|       |  // At any given time, we are pointing at byte 'input_position' in url_data.
12968|       |  // The input_position variable should range from 0 to input_size.
12969|       |  // It is illegal to access url_data at input_size.
12970|  30.3k|  size_t input_position = 0;
12971|  30.3k|  const size_t input_size = url_data.size();
12972|       |  // Keep running the following state machine by switching on state.
12973|       |  // If after a run pointer points to the EOF code point, go to the next step.
12974|       |  // Otherwise, increase pointer by 1 and continue with the state machine.
12975|       |  // We never decrement input_position.
12976|   131k|  while (input_position <= input_size) {
  ------------------
  |  Branch (12976:10): [True: 131k, False: 226]
  ------------------
12977|   131k|    ada_log("In parsing at ", input_position, " out of ", input_size,
12978|   131k|            " in state ", ada::to_string(state));
12979|   131k|    switch (state) {
12980|  30.3k|      case state::SCHEME_START: {
  ------------------
  |  Branch (12980:7): [True: 30.3k, False: 101k]
  ------------------
12981|  30.3k|        ada_log("SCHEME_START ", helpers::substring(url_data, input_position));
12982|       |        // If c is an ASCII alpha, append c, lowercased, to buffer, and set
12983|       |        // state to scheme state.
12984|  30.3k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (12984:13): [True: 22.3k, False: 8.00k]
  ------------------
12985|  22.3k|            checkers::is_alpha(url_data[input_position])) {
  ------------------
  |  Branch (12985:13): [True: 21.6k, False: 735]
  ------------------
12986|  21.6k|          state = state::SCHEME;
12987|  21.6k|          input_position++;
12988|  21.6k|        } else {
12989|       |          // Otherwise, if state override is not given, set state to no scheme
12990|       |          // state and decrease pointer by 1.
12991|  8.74k|          state = state::NO_SCHEME;
12992|  8.74k|        }
12993|  30.3k|        break;
12994|      0|      }
12995|  21.6k|      case state::SCHEME: {
  ------------------
  |  Branch (12995:7): [True: 21.6k, False: 110k]
  ------------------
12996|  21.6k|        ada_log("SCHEME ", helpers::substring(url_data, input_position));
12997|       |        // If c is an ASCII alphanumeric, U+002B (+), U+002D (-), or U+002E (.),
12998|       |        // append c, lowercased, to buffer.
12999|  53.9k|        while ((input_position != input_size) &&
  ------------------
  |  Branch (12999:16): [True: 53.5k, False: 352]
  ------------------
13000|  53.5k|               (unicode::is_alnum_plus(url_data[input_position]))) {
  ------------------
  |  Branch (13000:16): [True: 32.2k, False: 21.2k]
  ------------------
13001|  32.2k|          input_position++;
13002|  32.2k|        }
13003|       |        // Otherwise, if c is U+003A (:), then:
13004|  21.6k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13004:13): [True: 21.2k, False: 352]
  ------------------
13005|  21.2k|            (url_data[input_position] == ':')) {
  ------------------
  |  Branch (13005:13): [True: 21.0k, False: 245]
  ------------------
13006|  21.0k|          ada_log("SCHEME the scheme should be ",
13007|  21.0k|                  url_data.substr(0, input_position));
13008|       |          if constexpr (result_type_is_ada_url) {
13009|       |            if (!url.parse_scheme(url_data.substr(0, input_position))) {
13010|       |              return url;
13011|       |            }
13012|  21.0k|          } else {
13013|       |            // we pass the colon along instead of painfully adding it back.
13014|  21.0k|            if (!url.parse_scheme_with_colon(
  ------------------
  |  Branch (13014:17): [True: 0, False: 21.0k]
  ------------------
13015|  21.0k|                    url_data.substr(0, input_position + 1))) {
13016|      0|              return url;
13017|      0|            }
13018|  21.0k|          }
13019|  21.0k|          ada_log("SCHEME the scheme is ", url.get_protocol());
13020|       |
13021|       |          // If url's scheme is "file", then:
13022|       |          // NOLINTNEXTLINE(bugprone-branch-clone)
13023|  21.0k|          if (url.type == scheme::type::FILE) {
  ------------------
  |  Branch (13023:15): [True: 2.56k, False: 18.4k]
  ------------------
13024|       |            // Set state to file state.
13025|  2.56k|            state = state::FILE;
13026|  2.56k|          }
13027|       |          // Otherwise, if url is special, base is non-null, and base's scheme
13028|       |          // is url's scheme: Note: Doing base_url->scheme is unsafe if base_url
13029|       |          // != nullptr is false.
13030|  18.4k|          else if (url.is_special() && base_url != nullptr &&
  ------------------
  |  Branch (13030:20): [True: 13.0k, False: 5.37k]
  |  Branch (13030:40): [True: 2.24k, False: 10.8k]
  ------------------
13031|  2.24k|                   base_url->type == url.type) {
  ------------------
  |  Branch (13031:20): [True: 414, False: 1.82k]
  ------------------
13032|       |            // Set state to special relative or authority state.
13033|    414|            state = state::SPECIAL_RELATIVE_OR_AUTHORITY;
13034|    414|          }
13035|       |          // Otherwise, if url is special, set state to special authority
13036|       |          // slashes state.
13037|  18.0k|          else if (url.is_special()) {
  ------------------
  |  Branch (13037:20): [True: 12.6k, False: 5.37k]
  ------------------
13038|  12.6k|            state = state::SPECIAL_AUTHORITY_SLASHES;
13039|  12.6k|          }
13040|       |          // Otherwise, if remaining starts with an U+002F (/), set state to
13041|       |          // path or authority state and increase pointer by 1.
13042|  5.37k|          else if (input_position + 1 < input_size &&
  ------------------
  |  Branch (13042:20): [True: 3.10k, False: 2.27k]
  ------------------
13043|  3.10k|                   url_data[input_position + 1] == '/') {
  ------------------
  |  Branch (13043:20): [True: 2.19k, False: 906]
  ------------------
13044|  2.19k|            state = state::PATH_OR_AUTHORITY;
13045|  2.19k|            input_position++;
13046|  2.19k|          }
13047|       |          // Otherwise, set url's path to the empty string and set state to
13048|       |          // opaque path state.
13049|  3.17k|          else {
13050|  3.17k|            state = state::OPAQUE_PATH;
13051|  3.17k|          }
13052|  21.0k|        }
13053|       |        // Otherwise, if state override is not given, set buffer to the empty
13054|       |        // string, state to no scheme state, and start over (from the first code
13055|       |        // point in input).
13056|    597|        else {
13057|    597|          state = state::NO_SCHEME;
13058|    597|          input_position = 0;
13059|    597|          break;
13060|    597|        }
13061|  21.0k|        input_position++;
13062|  21.0k|        break;
13063|  21.6k|      }
13064|  9.34k|      case state::NO_SCHEME: {
  ------------------
  |  Branch (13064:7): [True: 9.34k, False: 122k]
  ------------------
13065|  9.34k|        ada_log("NO_SCHEME ", helpers::substring(url_data, input_position));
13066|       |        // The fragment was pruned from url_data before the state machine ran,
13067|       |        // so 'c is U+0023 (#)' holds exactly when a fragment was found and
13068|       |        // nothing else remains in front of it.
13069|  9.34k|        const bool c_is_hash =
13070|  9.34k|            fragment.has_value() && input_position == input_size;
  ------------------
  |  Branch (13070:13): [True: 295, False: 9.04k]
  |  Branch (13070:37): [True: 102, False: 193]
  ------------------
13071|       |        // If base is null, or base has an opaque path and c is not U+0023 (#),
13072|       |        // validation error, return failure.
13073|  9.34k|        if (base_url == nullptr || (base_url->has_opaque_path && !c_is_hash)) {
  ------------------
  |  Branch (13073:13): [True: 8.03k, False: 1.30k]
  |  Branch (13073:37): [True: 95, False: 1.21k]
  |  Branch (13073:66): [True: 50, False: 45]
  ------------------
13074|  8.08k|          ada_log("NO_SCHEME validation error");
13075|  8.08k|          url.is_valid = false;
13076|  8.08k|          return url;
13077|  8.08k|        }
13078|       |        // Otherwise, if base has an opaque path and c is U+0023 (#),
13079|       |        // set url's scheme to base's scheme, url's path to base's path, url's
13080|       |        // query to base's query, and set state to fragment state.
13081|  1.25k|        else if (base_url->has_opaque_path && c_is_hash) {
  ------------------
  |  Branch (13081:18): [True: 45, False: 1.21k]
  |  Branch (13081:47): [True: 45, False: 0]
  ------------------
13082|     45|          ada_log("NO_SCHEME opaque base with fragment");
13083|     45|          url.copy_scheme(*base_url);
13084|     45|          url.has_opaque_path = base_url->has_opaque_path;
13085|       |
13086|       |          if constexpr (result_type_is_ada_url) {
13087|       |            url.path = base_url->path;
13088|       |            url.query = base_url->query;
13089|     45|          } else {
13090|     45|            url.update_base_pathname(base_url->get_pathname());
13091|     45|            if (base_url->has_search()) {
  ------------------
  |  Branch (13091:17): [True: 0, False: 45]
  ------------------
13092|       |              // get_search() returns "" for an empty query string (URL ends
13093|       |              // with '?'). update_base_search("") would incorrectly clear the
13094|       |              // query, so pass "?" to preserve the empty query distinction.
13095|      0|              auto s = base_url->get_search();
13096|      0|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (13096:38): [True: 0, False: 0]
  ------------------
13097|      0|            }
13098|     45|          }
13099|     45|          url.update_unencoded_base_hash(*fragment);
13100|     45|          enforce_max_input_length();
13101|     45|          return url;
13102|     45|        }
13103|       |        // Otherwise, if base's scheme is not "file", set state to relative
13104|       |        // state and decrease pointer by 1.
13105|       |        // NOLINTNEXTLINE(bugprone-branch-clone)
13106|  1.21k|        else if (base_url->type != scheme::type::FILE) {
  ------------------
  |  Branch (13106:18): [True: 1.00k, False: 209]
  ------------------
13107|  1.00k|          ada_log("NO_SCHEME non-file relative path");
13108|  1.00k|          state = state::RELATIVE_SCHEME;
13109|  1.00k|        }
13110|       |        // Otherwise, set state to file state and decrease pointer by 1.
13111|    209|        else {
13112|    209|          ada_log("NO_SCHEME file base type");
13113|    209|          state = state::FILE;
13114|    209|        }
13115|  1.21k|        break;
13116|  9.34k|      }
13117|  13.9k|      case state::AUTHORITY: {
  ------------------
  |  Branch (13117:7): [True: 13.9k, False: 117k]
  ------------------
13118|  13.9k|        ada_log("AUTHORITY ", helpers::substring(url_data, input_position));
13119|       |        // most URLs have no @. Having no @ tells us that we don't have to worry
13120|       |        // about AUTHORITY. Of course, we could have @ and still not have to
13121|       |        // worry about AUTHORITY.
13122|       |        // TODO: Instead of just collecting a bool, collect the location of the
13123|       |        // '@' and do something useful with it.
13124|       |        // TODO: We could do various processing early on, using a single pass
13125|       |        // over the string to collect information about it, e.g., telling us
13126|       |        // whether there is a @ and if so, where (or how many).
13127|       |
13128|       |        // Check if url data contains an @.
13129|  13.9k|        if (url_data.find('@', input_position) == std::string_view::npos) {
  ------------------
  |  Branch (13129:13): [True: 12.6k, False: 1.26k]
  ------------------
13130|  12.6k|          state = state::HOST;
13131|  12.6k|          break;
13132|  12.6k|        }
13133|  1.26k|        bool at_sign_seen{false};
13134|  1.26k|        bool password_token_seen{false};
13135|       |        /**
13136|       |         * We expect something of the sort...
13137|       |         * https://user:pass@example.com:1234/foo/bar?baz#quux
13138|       |         * --------^
13139|       |         */
13140|  7.64k|        do {
13141|  7.64k|          std::string_view view = url_data.substr(input_position);
13142|       |          // The delimiters are @, /, ? \\.
13143|  7.64k|          size_t location =
13144|  7.64k|              url.is_special() ? helpers::find_authority_delimiter_special(view)
  ------------------
  |  Branch (13144:15): [True: 6.91k, False: 730]
  ------------------
13145|  7.64k|                               : helpers::find_authority_delimiter(view);
13146|  7.64k|          std::string_view authority_view = view.substr(0, location);
13147|  7.64k|          size_t end_of_authority = input_position + authority_view.size();
13148|       |          // If c is U+0040 (@), then:
13149|  7.64k|          if ((end_of_authority != input_size) &&
  ------------------
  |  Branch (13149:15): [True: 6.86k, False: 776]
  ------------------
13150|  6.86k|              (url_data[end_of_authority] == '@')) {
  ------------------
  |  Branch (13150:15): [True: 6.37k, False: 493]
  ------------------
13151|       |            // If atSignSeen is true, then prepend "%40" to buffer.
13152|  6.37k|            if (at_sign_seen) {
  ------------------
  |  Branch (13152:17): [True: 5.29k, False: 1.08k]
  ------------------
13153|  5.29k|              if (password_token_seen) {
  ------------------
  |  Branch (13153:19): [True: 2.21k, False: 3.07k]
  ------------------
13154|       |                if constexpr (result_type_is_ada_url) {
13155|       |                  url.password += "%40";
13156|  2.21k|                } else {
13157|  2.21k|                  url.append_base_password("%40");
13158|  2.21k|                }
13159|  3.07k|              } else {
13160|       |                if constexpr (result_type_is_ada_url) {
13161|       |                  url.username += "%40";
13162|  3.07k|                } else {
13163|  3.07k|                  url.append_base_username("%40");
13164|  3.07k|                }
13165|  3.07k|              }
13166|  5.29k|            }
13167|       |
13168|  6.37k|            at_sign_seen = true;
13169|       |
13170|  6.37k|            if (!password_token_seen) {
  ------------------
  |  Branch (13170:17): [True: 4.15k, False: 2.21k]
  ------------------
13171|  4.15k|              size_t password_token_location = authority_view.find(':');
13172|  4.15k|              password_token_seen =
13173|  4.15k|                  password_token_location != std::string_view::npos;
13174|       |
13175|       |              if constexpr (store_values) {
13176|       |                if (!password_token_seen) {
13177|       |                  if constexpr (result_type_is_ada_url) {
13178|       |                    url.username += unicode::percent_encode(
13179|       |                        authority_view,
13180|       |                        character_sets::USERINFO_PERCENT_ENCODE);
13181|       |                  } else {
13182|       |                    url.append_base_username(unicode::percent_encode(
13183|       |                        authority_view,
13184|       |                        character_sets::USERINFO_PERCENT_ENCODE));
13185|       |                  }
13186|       |                } else {
13187|       |                  if constexpr (result_type_is_ada_url) {
13188|       |                    url.username += unicode::percent_encode(
13189|       |                        authority_view.substr(0, password_token_location),
13190|       |                        character_sets::USERINFO_PERCENT_ENCODE);
13191|       |                    url.password += unicode::percent_encode(
13192|       |                        authority_view.substr(password_token_location + 1),
13193|       |                        character_sets::USERINFO_PERCENT_ENCODE);
13194|       |                  } else {
13195|       |                    url.append_base_username(unicode::percent_encode(
13196|       |                        authority_view.substr(0, password_token_location),
13197|       |                        character_sets::USERINFO_PERCENT_ENCODE));
13198|       |                    url.append_base_password(unicode::percent_encode(
13199|       |                        authority_view.substr(password_token_location + 1),
13200|       |                        character_sets::USERINFO_PERCENT_ENCODE));
13201|       |                  }
13202|       |                }
13203|       |              }
13204|  4.15k|            } else if constexpr (store_values) {
13205|  2.21k|              if constexpr (result_type_is_ada_url) {
13206|  2.21k|                url.password += unicode::percent_encode(
13207|  2.21k|                    authority_view, character_sets::USERINFO_PERCENT_ENCODE);
13208|  2.21k|              } else {
13209|  2.21k|                url.append_base_password(unicode::percent_encode(
13210|  2.21k|                    authority_view, character_sets::USERINFO_PERCENT_ENCODE));
13211|  2.21k|              }
13212|  2.21k|            }
13213|  6.37k|          }
13214|       |          // Otherwise, if one of the following is true:
13215|       |          // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
13216|       |          // - url is special and c is U+005C (\)
13217|  1.26k|          else if (end_of_authority == input_size ||
  ------------------
  |  Branch (13217:20): [True: 776, False: 493]
  ------------------
13218|    493|                   url_data[end_of_authority] == '/' ||
  ------------------
  |  Branch (13218:20): [True: 448, False: 45]
  ------------------
13219|     45|                   url_data[end_of_authority] == '?' ||
  ------------------
  |  Branch (13219:20): [True: 38, False: 7]
  ------------------
13220|  1.26k|                   (url.is_special() && url_data[end_of_authority] == '\\')) {
  ------------------
  |  Branch (13220:21): [True: 7, False: 0]
  |  Branch (13220:41): [True: 7, False: 0]
  ------------------
13221|       |            // If atSignSeen is true and authority_view is the empty string,
13222|       |            // validation error, return failure.
13223|  1.26k|            if (at_sign_seen && authority_view.empty()) {
  ------------------
  |  Branch (13223:17): [True: 1.08k, False: 187]
  |  Branch (13223:33): [True: 337, False: 745]
  ------------------
13224|    337|              url.is_valid = false;
13225|    337|              return url;
13226|    337|            }
13227|    932|            state = state::HOST;
13228|    932|            break;
13229|  1.26k|          }
13230|  6.37k|          if (end_of_authority == input_size) {
  ------------------
  |  Branch (13230:15): [True: 0, False: 6.37k]
  ------------------
13231|       |            if constexpr (store_values) {
13232|       |              if (fragment.has_value()) {
13233|       |                url.update_unencoded_base_hash(*fragment);
13234|       |              }
13235|       |            }
13236|      0|            enforce_max_input_length();
13237|      0|            return url;
13238|      0|          }
13239|  6.37k|          input_position = end_of_authority + 1;
13240|  6.37k|        } while (true);
  ------------------
  |  Branch (13240:18): [True: 6.37k, Folded]
  ------------------
13241|       |
13242|    932|        break;
13243|  1.26k|      }
13244|    932|      case state::SPECIAL_RELATIVE_OR_AUTHORITY: {
  ------------------
  |  Branch (13244:7): [True: 414, False: 131k]
  ------------------
13245|    414|        ada_log("SPECIAL_RELATIVE_OR_AUTHORITY ",
13246|    414|                helpers::substring(url_data, input_position));
13247|       |
13248|       |        // If c is U+002F (/) and remaining starts with U+002F (/),
13249|       |        // then set state to special authority ignore slashes state and increase
13250|       |        // pointer by 1.
13251|    414|        if (url_data.substr(input_position, 2) == "//") {
  ------------------
  |  Branch (13251:13): [True: 342, False: 72]
  ------------------
13252|    342|          state = state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
13253|    342|          input_position += 2;
13254|    342|        } else {
13255|       |          // Otherwise, validation error, set state to relative state and
13256|       |          // decrease pointer by 1.
13257|     72|          state = state::RELATIVE_SCHEME;
13258|     72|        }
13259|       |
13260|    414|        break;
13261|  1.26k|      }
13262|  2.19k|      case state::PATH_OR_AUTHORITY: {
  ------------------
  |  Branch (13262:7): [True: 2.19k, False: 129k]
  ------------------
13263|  2.19k|        ada_log("PATH_OR_AUTHORITY ",
13264|  2.19k|                helpers::substring(url_data, input_position));
13265|       |
13266|       |        // If c is U+002F (/), then set state to authority state.
13267|  2.19k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13267:13): [True: 2.08k, False: 110]
  ------------------
13268|  2.08k|            (url_data[input_position] == '/')) {
  ------------------
  |  Branch (13268:13): [True: 887, False: 1.19k]
  ------------------
13269|    887|          state = state::AUTHORITY;
13270|    887|          input_position++;
13271|  1.30k|        } else {
13272|       |          // Otherwise, set state to path state, and decrease pointer by 1.
13273|  1.30k|          state = state::PATH;
13274|  1.30k|        }
13275|       |
13276|  2.19k|        break;
13277|  1.26k|      }
13278|  1.07k|      case state::RELATIVE_SCHEME: {
  ------------------
  |  Branch (13278:7): [True: 1.07k, False: 130k]
  ------------------
13279|  1.07k|        ada_log("RELATIVE_SCHEME ",
13280|  1.07k|                helpers::substring(url_data, input_position));
13281|       |
13282|       |        // Set url's scheme to base's scheme.
13283|  1.07k|        url.copy_scheme(*base_url);
13284|       |
13285|       |        // If c is U+002F (/), then set state to relative slash state.
13286|  1.07k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13286:13): [True: 896, False: 179]
  ------------------
13287|       |            // NOLINTNEXTLINE(bugprone-branch-clone)
13288|    896|            (url_data[input_position] == '/')) {
  ------------------
  |  Branch (13288:13): [True: 101, False: 795]
  ------------------
13289|    101|          ada_log(
13290|    101|              "RELATIVE_SCHEME if c is U+002F (/), then set state to relative "
13291|    101|              "slash state");
13292|    101|          state = state::RELATIVE_SLASH;
13293|    974|        } else if (url.is_special() && (input_position != input_size) &&
  ------------------
  |  Branch (13293:20): [True: 839, False: 135]
  |  Branch (13293:40): [True: 701, False: 138]
  ------------------
13294|    701|                   (url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13294:20): [True: 2, False: 699]
  ------------------
13295|       |          // Otherwise, if url is special and c is U+005C (\), validation error,
13296|       |          // set state to relative slash state.
13297|      2|          ada_log(
13298|      2|              "RELATIVE_SCHEME  if url is special and c is U+005C, validation "
13299|      2|              "error, set state to relative slash state");
13300|      2|          state = state::RELATIVE_SLASH;
13301|    972|        } else {
13302|    972|          ada_log("RELATIVE_SCHEME otherwise");
13303|       |          // Set url's username to base's username, url's password to base's
13304|       |          // password, url's host to base's host, url's port to base's port,
13305|       |          // url's path to a clone of base's path, and url's query to base's
13306|       |          // query.
13307|       |          if constexpr (result_type_is_ada_url) {
13308|       |            url.username = base_url->username;
13309|       |            url.password = base_url->password;
13310|       |            url.host = base_url->host;
13311|       |            url.port = base_url->port;
13312|       |            // cloning the base path includes cloning the has_opaque_path flag
13313|       |            url.has_opaque_path = base_url->has_opaque_path;
13314|       |            url.path = base_url->path;
13315|       |            url.query = base_url->query;
13316|    972|          } else {
13317|    972|            url.update_base_authority(base_url->get_href(),
13318|    972|                                      base_url->get_components());
13319|    972|            url.update_host_to_base_host(base_url->get_hostname());
13320|    972|            url.update_base_port(base_url->retrieve_base_port());
13321|       |            // cloning the base path includes cloning the has_opaque_path flag
13322|    972|            url.has_opaque_path = base_url->has_opaque_path;
13323|    972|            url.update_base_pathname(base_url->get_pathname());
13324|    972|            if (base_url->has_search()) {
  ------------------
  |  Branch (13324:17): [True: 0, False: 972]
  ------------------
13325|       |              // get_search() returns "" for an empty query string (URL ends
13326|       |              // with '?'). update_base_search("") would incorrectly clear the
13327|       |              // query, so pass "?" to preserve the empty query distinction.
13328|      0|              auto s = base_url->get_search();
13329|      0|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (13329:38): [True: 0, False: 0]
  ------------------
13330|      0|            }
13331|    972|          }
13332|       |
13333|    972|          url.has_opaque_path = base_url->has_opaque_path;
13334|       |
13335|       |          // If c is U+003F (?), then set url's query to the empty string, and
13336|       |          // state to query state.
13337|    972|          if ((input_position != input_size) &&
  ------------------
  |  Branch (13337:15): [True: 793, False: 179]
  ------------------
13338|    793|              (url_data[input_position] == '?')) {
  ------------------
  |  Branch (13338:15): [True: 115, False: 678]
  ------------------
13339|    115|            state = state::QUERY;
13340|    115|          }
13341|       |          // Otherwise, if c is not the EOF code point:
13342|    857|          else if (input_position != input_size) {
  ------------------
  |  Branch (13342:20): [True: 678, False: 179]
  ------------------
13343|       |            // Set url's query to null.
13344|    678|            url.clear_search();
13345|       |            if constexpr (result_type_is_ada_url) {
13346|       |              // Shorten url's path.
13347|       |              helpers::shorten_path(url.path, url.type);
13348|    678|            } else {
13349|    678|              std::string_view path = url.get_pathname();
13350|    678|              if (helpers::shorten_path(path, url.type)) {
  ------------------
  |  Branch (13350:19): [True: 0, False: 678]
  ------------------
13351|      0|                url.update_base_pathname(std::move(std::string(path)));
13352|      0|              }
13353|    678|            }
13354|       |            // Set state to path state and decrease pointer by 1.
13355|    678|            state = state::PATH;
13356|    678|            break;
13357|    678|          }
13358|    972|        }
13359|    397|        input_position++;
13360|    397|        break;
13361|  1.07k|      }
13362|    103|      case state::RELATIVE_SLASH: {
  ------------------
  |  Branch (13362:7): [True: 103, False: 131k]
  ------------------
13363|    103|        ada_log("RELATIVE_SLASH ",
13364|    103|                helpers::substring(url_data, input_position));
13365|       |
13366|       |        // If url is special and c is U+002F (/) or U+005C (\), then:
13367|       |        // NOLINTNEXTLINE(bugprone-branch-clone)
13368|    103|        if (url.is_special() && (input_position != input_size) &&
  ------------------
  |  Branch (13368:13): [True: 84, False: 19]
  |  Branch (13368:33): [True: 59, False: 25]
  ------------------
13369|     59|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13369:14): [True: 4, False: 55]
  ------------------
13370|     55|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13370:14): [True: 2, False: 53]
  ------------------
13371|       |          // Set state to special authority ignore slashes state.
13372|      6|          state = state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
13373|      6|        }
13374|       |        // Otherwise, if c is U+002F (/), then set state to authority state.
13375|     97|        else if ((input_position != input_size) &&
  ------------------
  |  Branch (13375:18): [True: 63, False: 34]
  ------------------
13376|     63|                 (url_data[input_position] == '/')) {
  ------------------
  |  Branch (13376:18): [True: 5, False: 58]
  ------------------
13377|      5|          state = state::AUTHORITY;
13378|      5|        }
13379|       |        // Otherwise, set
13380|       |        // - url's username to base's username,
13381|       |        // - url's password to base's password,
13382|       |        // - url's host to base's host,
13383|       |        // - url's port to base's port,
13384|       |        // - state to path state, and then, decrease pointer by 1.
13385|     92|        else {
13386|       |          if constexpr (result_type_is_ada_url) {
13387|       |            url.username = base_url->username;
13388|       |            url.password = base_url->password;
13389|       |            url.host = base_url->host;
13390|       |            url.port = base_url->port;
13391|     92|          } else {
13392|     92|            url.update_base_authority(base_url->get_href(),
13393|     92|                                      base_url->get_components());
13394|     92|            url.update_host_to_base_host(base_url->get_hostname());
13395|     92|            url.update_base_port(base_url->retrieve_base_port());
13396|     92|          }
13397|     92|          state = state::PATH;
13398|     92|          break;
13399|     92|        }
13400|       |
13401|     11|        input_position++;
13402|     11|        break;
13403|    103|      }
13404|  12.6k|      case state::SPECIAL_AUTHORITY_SLASHES: {
  ------------------
  |  Branch (13404:7): [True: 12.6k, False: 118k]
  ------------------
13405|  12.6k|        ada_log("SPECIAL_AUTHORITY_SLASHES ",
13406|  12.6k|                helpers::substring(url_data, input_position));
13407|       |
13408|       |        // If c is U+002F (/) and remaining starts with U+002F (/),
13409|       |        // then set state to special authority ignore slashes state and increase
13410|       |        // pointer by 1.
13411|  12.6k|        if (url_data.substr(input_position, 2) == "//") {
  ------------------
  |  Branch (13411:13): [True: 3.22k, False: 9.45k]
  ------------------
13412|  3.22k|          input_position += 2;
13413|  3.22k|        }
13414|       |
13415|  12.6k|        [[fallthrough]];
13416|  12.6k|      }
13417|  13.0k|      case state::SPECIAL_AUTHORITY_IGNORE_SLASHES: {
  ------------------
  |  Branch (13417:7): [True: 348, False: 131k]
  ------------------
13418|  13.0k|        ada_log("SPECIAL_AUTHORITY_IGNORE_SLASHES ",
13419|  13.0k|                helpers::substring(url_data, input_position));
13420|       |
13421|       |        // If c is neither U+002F (/) nor U+005C (\), then set state to
13422|       |        // authority state and decrease pointer by 1.
13423|  13.6k|        while ((input_position != input_size) &&
  ------------------
  |  Branch (13423:16): [True: 13.5k, False: 57]
  ------------------
13424|  13.5k|               ((url_data[input_position] == '/') ||
  ------------------
  |  Branch (13424:17): [True: 382, False: 13.2k]
  ------------------
13425|  13.2k|                (url_data[input_position] == '\\'))) {
  ------------------
  |  Branch (13425:17): [True: 242, False: 12.9k]
  ------------------
13426|    624|          input_position++;
13427|    624|        }
13428|  13.0k|        state = state::AUTHORITY;
13429|       |
13430|  13.0k|        break;
13431|  12.6k|      }
13432|    119|      case state::QUERY: {
  ------------------
  |  Branch (13432:7): [True: 119, False: 131k]
  ------------------
13433|    119|        ada_log("QUERY ", helpers::substring(url_data, input_position));
13434|       |        if constexpr (store_values) {
13435|       |          // Let queryPercentEncodeSet be the special-query percent-encode set
13436|       |          // if url is special; otherwise the query percent-encode set.
13437|       |          const uint8_t* query_percent_encode_set =
13438|       |              url.is_special() ? character_sets::SPECIAL_QUERY_PERCENT_ENCODE
13439|       |                               : character_sets::QUERY_PERCENT_ENCODE;
13440|       |
13441|       |          // Percent-encode after encoding, with encoding, buffer, and
13442|       |          // queryPercentEncodeSet, and append the result to url's query.
13443|       |          url.update_base_search(url_data.substr(input_position),
13444|       |                                 query_percent_encode_set);
13445|       |          ada_log("QUERY update_base_search completed ");
13446|       |          if (fragment.has_value()) {
13447|       |            url.update_unencoded_base_hash(*fragment);
13448|       |          }
13449|       |        }
13450|    119|        enforce_max_input_length();
13451|    119|        return url;
13452|  12.6k|      }
13453|  13.5k|      case state::HOST: {
  ------------------
  |  Branch (13453:7): [True: 13.5k, False: 118k]
  ------------------
13454|  13.5k|        ada_log("HOST ", helpers::substring(url_data, input_position));
13455|       |
13456|  13.5k|        std::string_view host_view = url_data.substr(input_position);
13457|  13.5k|        auto [location, found_colon] =
13458|  13.5k|            helpers::get_host_delimiter_location(url.is_special(), host_view);
13459|  13.5k|        input_position = (location != std::string_view::npos)
  ------------------
  |  Branch (13459:26): [True: 13.5k, False: 0]
  ------------------
13460|  13.5k|                             ? input_position + location
13461|  13.5k|                             : input_size;
13462|       |        // Otherwise, if c is U+003A (:) and insideBrackets is false, then:
13463|       |        // Note: the 'found_colon' value is true if and only if a colon was
13464|       |        // encountered while not inside brackets.
13465|  13.5k|        if (found_colon) {
  ------------------
  |  Branch (13465:13): [True: 2.59k, False: 10.9k]
  ------------------
13466|       |          // If buffer is the empty string, validation error, return failure.
13467|       |          // Let host be the result of host parsing buffer with url is not
13468|       |          // special.
13469|  2.59k|          ada_log("HOST parsing ", host_view);
13470|  2.59k|          if (!url.parse_host(host_view)) {
  ------------------
  |  Branch (13470:15): [True: 201, False: 2.39k]
  ------------------
13471|    201|            return url;
13472|    201|          }
13473|  2.39k|          ada_log("HOST parsing results in ", url.get_hostname());
13474|       |          // Set url's host to host, buffer to the empty string, and state to
13475|       |          // port state.
13476|  2.39k|          state = state::PORT;
13477|  2.39k|          input_position++;
13478|  2.39k|        }
13479|       |        // Otherwise, if one of the following is true:
13480|       |        // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
13481|       |        // - url is special and c is U+005C (\)
13482|       |        // The get_host_delimiter_location function either brings us to
13483|       |        // the colon outside of the bracket, or to one of those characters.
13484|  10.9k|        else {
13485|       |          // If url is special and host_view is the empty string, validation
13486|       |          // error, return failure.
13487|  10.9k|          if (host_view.empty() && url.is_special()) {
  ------------------
  |  Branch (13487:15): [True: 191, False: 10.7k]
  |  Branch (13487:36): [True: 60, False: 131]
  ------------------
13488|     60|            url.is_valid = false;
13489|     60|            return url;
13490|     60|          }
13491|  10.9k|          ada_log("HOST parsing ", host_view, " href=", url.get_href());
13492|       |          // Let host be the result of host parsing host_view with url is not
13493|       |          // special.
13494|  10.9k|          if (host_view.empty()) {
  ------------------
  |  Branch (13494:15): [True: 131, False: 10.7k]
  ------------------
13495|    131|            url.update_base_hostname("");
13496|  10.7k|          } else if (!url.parse_host(host_view)) {
  ------------------
  |  Branch (13496:22): [True: 2.29k, False: 8.49k]
  ------------------
13497|  2.29k|            return url;
13498|  2.29k|          }
13499|  8.63k|          ada_log("HOST parsing results in ", url.get_hostname(),
13500|  8.63k|                  " href=", url.get_href());
13501|       |
13502|       |          // Set url's host to host, and state to path start state.
13503|  8.63k|          state = state::PATH_START;
13504|  8.63k|        }
13505|       |
13506|  11.0k|        break;
13507|  13.5k|      }
13508|  11.0k|      case state::OPAQUE_PATH: {
  ------------------
  |  Branch (13508:7): [True: 3.17k, False: 128k]
  ------------------
13509|  3.17k|        ada_log("OPAQUE_PATH ", helpers::substring(url_data, input_position));
13510|       |        // Opaque path, query, and fragment are structurally always valid:
13511|       |        // the parser would just percent-encode whatever is there. When we
13512|       |        // are not storing values (can_parse), we can return immediately.
13513|       |        // We must set has_opaque_path = true before returning so that when
13514|       |        // this URL is used as an internal base inside can_parse, NO_SCHEME
13515|       |        // correctly rejects relative inputs against an opaque-path base
13516|       |        // (e.g. can_parse("", &"W:") must return false).
13517|  3.17k|        if constexpr (!store_values) {
13518|  3.17k|          url.has_opaque_path = true;
13519|  3.17k|          return url;
13520|  3.17k|        }
13521|      0|        std::string_view view = url_data.substr(input_position);
13522|       |        // If c is U+003F (?), then set url's query to the empty string and
13523|       |        // state to query state.
13524|  3.17k|        size_t location = view.find('?');
13525|  3.17k|        if (location != std::string_view::npos) {
  ------------------
  |  Branch (13525:13): [True: 0, False: 3.17k]
  ------------------
13526|      0|          view.remove_suffix(view.size() - location);
13527|      0|          state = state::QUERY;
13528|      0|          input_position += location + 1;
13529|  3.17k|        } else {
13530|  3.17k|          input_position = input_size + 1;
13531|  3.17k|        }
13532|  3.17k|        url.has_opaque_path = true;
13533|       |
13534|       |        // This is a really unlikely scenario in real world. We should not seek
13535|       |        // to optimize it.
13536|  3.17k|        if (view.ends_with(' ')) {
  ------------------
  |  Branch (13536:13): [True: 0, False: 3.17k]
  ------------------
13537|      0|          std::string modified_view =
13538|      0|              std::string(view.substr(0, view.size() - 1)) + "%20";
13539|      0|          url.update_base_pathname(unicode::percent_encode(
13540|      0|              modified_view, character_sets::C0_CONTROL_PERCENT_ENCODE));
13541|  3.17k|        } else {
13542|  3.17k|          url.update_base_pathname(unicode::percent_encode(
13543|  3.17k|              view, character_sets::C0_CONTROL_PERCENT_ENCODE));
13544|  3.17k|        }
13545|  3.17k|        break;
13546|  13.5k|      }
13547|  2.39k|      case state::PORT: {
  ------------------
  |  Branch (13547:7): [True: 2.39k, False: 129k]
  ------------------
13548|  2.39k|        ada_log("PORT ", helpers::substring(url_data, input_position));
13549|  2.39k|        std::string_view port_view = url_data.substr(input_position);
13550|  2.39k|        input_position += url.parse_port(port_view, true);
13551|  2.39k|        if (!url.is_valid) {
  ------------------
  |  Branch (13551:13): [True: 98, False: 2.29k]
  ------------------
13552|     98|          return url;
13553|     98|        }
13554|  2.29k|        state = state::PATH_START;
13555|  2.29k|        [[fallthrough]];
13556|  2.29k|      }
13557|  12.8k|      case state::PATH_START: {
  ------------------
  |  Branch (13557:7): [True: 10.5k, False: 121k]
  ------------------
13558|  12.8k|        ada_log("PATH_START ", helpers::substring(url_data, input_position));
13559|       |        // Path, query, and fragment are structurally always valid: the
13560|       |        // parser would just percent-encode whatever is there. When we are
13561|       |        // not storing values (can_parse), we can return immediately since
13562|       |        // no subsequent state can invalidate the URL.
13563|  12.8k|        if constexpr (!store_values) {
13564|  12.8k|          return url;
13565|  12.8k|        }
13566|       |
13567|       |        // If url is special, then:
13568|  12.8k|        if (url.is_special()) {
  ------------------
  |  Branch (13568:13): [True: 0, False: 12.8k]
  ------------------
13569|       |          // Set state to path state.
13570|      0|          state = state::PATH;
13571|       |
13572|       |          // Optimization: Avoiding going into PATH state improves the
13573|       |          // performance of urls ending with /.
13574|      0|          if (input_position == input_size) {
  ------------------
  |  Branch (13574:15): [True: 0, False: 0]
  ------------------
13575|       |            if constexpr (store_values) {
13576|       |              url.update_base_pathname("/");
13577|       |              if (fragment.has_value()) {
13578|       |                url.update_unencoded_base_hash(*fragment);
13579|       |              }
13580|       |            }
13581|      0|            enforce_max_input_length();
13582|      0|            return url;
13583|      0|          }
13584|       |          // If c is neither U+002F (/) nor U+005C (\), then decrease pointer
13585|       |          // by 1. We know that (input_position == input_size) is impossible
13586|       |          // here, because of the previous if-check.
13587|      0|          if ((url_data[input_position] != '/') &&
  ------------------
  |  Branch (13587:15): [True: 0, False: 0]
  ------------------
13588|      0|              (url_data[input_position] != '\\')) {
  ------------------
  |  Branch (13588:15): [True: 0, False: 0]
  ------------------
13589|      0|            break;
13590|      0|          }
13591|      0|        }
13592|       |        // Otherwise, if state override is not given and c is U+003F (?),
13593|       |        // set url's query to the empty string and state to query state.
13594|  12.8k|        else if ((input_position != input_size) &&
  ------------------
  |  Branch (13594:18): [True: 0, False: 12.8k]
  ------------------
13595|      0|                 (url_data[input_position] == '?')) {
  ------------------
  |  Branch (13595:18): [True: 0, False: 0]
  ------------------
13596|      0|          state = state::QUERY;
13597|      0|        }
13598|       |        // Otherwise, if c is not the EOF code point:
13599|  12.8k|        else if (input_position != input_size) {
  ------------------
  |  Branch (13599:18): [True: 0, False: 12.8k]
  ------------------
13600|       |          // Set state to path state.
13601|      0|          state = state::PATH;
13602|       |
13603|       |          // If c is not U+002F (/), then decrease pointer by 1.
13604|      0|          if (url_data[input_position] != '/') {
  ------------------
  |  Branch (13604:15): [True: 0, False: 0]
  ------------------
13605|      0|            break;
13606|      0|          }
13607|      0|        }
13608|       |
13609|  12.8k|        input_position++;
13610|  12.8k|        break;
13611|  12.8k|      }
13612|  2.72k|      case state::PATH: {
  ------------------
  |  Branch (13612:7): [True: 2.72k, False: 128k]
  ------------------
13613|  2.72k|        ada_log("PATH ", helpers::substring(url_data, input_position));
13614|       |        // Path, query, and fragment are structurally always valid: the
13615|       |        // parser would just percent-encode whatever is there. When we are
13616|       |        // not storing values (can_parse), we can return immediately since
13617|       |        // no subsequent state can invalidate the URL.
13618|  2.72k|        if constexpr (!store_values) {
13619|  2.72k|          return url;
13620|  2.72k|        }
13621|      0|        std::string_view view = url_data.substr(input_position);
13622|       |
13623|       |        // Most time, we do not need percent encoding.
13624|       |        // Furthermore, we can immediately locate the '?'.
13625|  2.72k|        size_t locofquestionmark = view.find('?');
13626|  2.72k|        if (locofquestionmark != std::string_view::npos) {
  ------------------
  |  Branch (13626:13): [True: 0, False: 2.72k]
  ------------------
13627|      0|          state = state::QUERY;
13628|      0|          view.remove_suffix(view.size() - locofquestionmark);
13629|      0|          input_position += locofquestionmark + 1;
13630|  2.72k|        } else {
13631|  2.72k|          input_position = input_size + 1;
13632|  2.72k|        }
13633|       |        if constexpr (store_values) {
13634|       |          if constexpr (result_type_is_ada_url) {
13635|       |            helpers::parse_prepared_path(view, url.type, url.path);
13636|       |          } else {
13637|       |            url.consume_prepared_path(view);
13638|       |            ADA_ASSERT_TRUE(url.validate());
13639|       |          }
13640|       |        }
13641|  2.72k|        break;
13642|  12.8k|      }
13643|  2.20k|      case state::FILE_SLASH: {
  ------------------
  |  Branch (13643:7): [True: 2.20k, False: 129k]
  ------------------
13644|  2.20k|        ada_log("FILE_SLASH ", helpers::substring(url_data, input_position));
13645|       |
13646|       |        // If c is U+002F (/) or U+005C (\), then:
13647|  2.20k|        if ((input_position != input_size) &&
  ------------------
  |  Branch (13647:13): [True: 2.13k, False: 67]
  ------------------
13648|  2.13k|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13648:14): [True: 2.08k, False: 49]
  ------------------
13649|  2.09k|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13649:14): [True: 6, False: 43]
  ------------------
13650|  2.09k|          ada_log("FILE_SLASH c is U+002F or U+005C");
13651|       |          // Set state to file host state.
13652|  2.09k|          state = state::FILE_HOST;
13653|  2.09k|          input_position++;
13654|  2.09k|        } else {
13655|    110|          ada_log("FILE_SLASH otherwise");
13656|       |          // If base is non-null and base's scheme is "file", then:
13657|       |          // Note: it is unsafe to do base_url->scheme unless you know that
13658|       |          // base_url_has_value() is true.
13659|    110|          if (base_url != nullptr && base_url->type == scheme::type::FILE) {
  ------------------
  |  Branch (13659:15): [True: 88, False: 22]
  |  Branch (13659:38): [True: 86, False: 2]
  ------------------
13660|       |            // Set url's host to base's host.
13661|       |            if constexpr (result_type_is_ada_url) {
13662|       |              url.host = base_url->host;
13663|     86|            } else {
13664|     86|              url.update_host_to_base_host(base_url->get_host());
13665|     86|            }
13666|       |            // If the code point substring from pointer to the end of input does
13667|       |            // not start with a Windows drive letter and base's path[0] is a
13668|       |            // normalized Windows drive letter, then append base's path[0] to
13669|       |            // url's path.
13670|     86|            if (!base_url->get_pathname().empty()) {
  ------------------
  |  Branch (13670:17): [True: 0, False: 86]
  ------------------
13671|      0|              if (!checkers::is_windows_drive_letter(
  ------------------
  |  Branch (13671:19): [True: 0, False: 0]
  ------------------
13672|      0|                      url_data.substr(input_position))) {
13673|      0|                std::string_view first_base_url_path =
13674|      0|                    base_url->get_pathname().substr(1);
13675|      0|                size_t loc = first_base_url_path.find('/');
13676|      0|                if (loc != std::string_view::npos) {
  ------------------
  |  Branch (13676:21): [True: 0, False: 0]
  ------------------
13677|      0|                  helpers::resize(first_base_url_path, loc);
13678|      0|                }
13679|      0|                if (checkers::is_normalized_windows_drive_letter(
  ------------------
  |  Branch (13679:21): [True: 0, False: 0]
  ------------------
13680|      0|                        first_base_url_path)) {
13681|       |                  if constexpr (result_type_is_ada_url) {
13682|       |                    url.path += '/';
13683|       |                    url.path += first_base_url_path;
13684|      0|                  } else {
13685|      0|                    url.append_base_pathname(
13686|      0|                        helpers::concat("/", first_base_url_path));
13687|      0|                  }
13688|      0|                }
13689|      0|              }
13690|      0|            }
13691|     86|          }
13692|       |
13693|       |          // Set state to path state, and decrease pointer by 1.
13694|    110|          state = state::PATH;
13695|    110|        }
13696|       |
13697|  2.20k|        break;
13698|  12.8k|      }
13699|  2.09k|      case state::FILE_HOST: {
  ------------------
  |  Branch (13699:7): [True: 2.09k, False: 129k]
  ------------------
13700|  2.09k|        ada_log("FILE_HOST ", helpers::substring(url_data, input_position));
13701|  2.09k|        std::string_view view = url_data.substr(input_position);
13702|       |
13703|  2.09k|        size_t location = view.find_first_of("/\\?");
13704|  2.09k|        std::string_view file_host_buffer = view.substr(
13705|  2.09k|            0, (location != std::string_view::npos) ? location : view.size());
  ------------------
  |  Branch (13705:16): [True: 890, False: 1.20k]
  ------------------
13706|       |
13707|  2.09k|        if (checkers::is_windows_drive_letter(file_host_buffer)) {
  ------------------
  |  Branch (13707:13): [True: 12, False: 2.08k]
  ------------------
13708|     12|          state = state::PATH;
13709|  2.08k|        } else if (file_host_buffer.empty()) {
  ------------------
  |  Branch (13709:20): [True: 257, False: 1.82k]
  ------------------
13710|       |          // Set url's host to the empty string.
13711|       |          if constexpr (result_type_is_ada_url) {
13712|       |            url.host = "";
13713|    257|          } else {
13714|    257|            url.update_base_hostname("");
13715|    257|          }
13716|       |          // Set state to path start state.
13717|    257|          state = state::PATH_START;
13718|  1.82k|        } else {
13719|  1.82k|          size_t consumed_bytes = file_host_buffer.size();
13720|  1.82k|          input_position += consumed_bytes;
13721|       |          // Let host be the result of host parsing buffer with url is not
13722|       |          // special.
13723|  1.82k|          if (!url.parse_host(file_host_buffer)) {
  ------------------
  |  Branch (13723:15): [True: 188, False: 1.63k]
  ------------------
13724|    188|            return url;
13725|    188|          }
13726|       |
13727|       |          if constexpr (result_type_is_ada_url) {
13728|       |            // If host is "localhost", then set host to the empty string.
13729|       |            if (url.host.has_value() && url.host.value() == "localhost") {
13730|       |              url.host = "";
13731|       |            }
13732|  1.63k|          } else {
13733|  1.63k|            if (url.get_hostname() == "localhost") {
  ------------------
  |  Branch (13733:17): [True: 12, False: 1.62k]
  ------------------
13734|     12|              url.update_base_hostname("");
13735|     12|            }
13736|  1.63k|          }
13737|       |
13738|       |          // Set buffer to the empty string and state to path start state.
13739|  1.63k|          state = state::PATH_START;
13740|  1.63k|        }
13741|       |
13742|  1.90k|        break;
13743|  2.09k|      }
13744|  2.77k|      case state::FILE: {
  ------------------
  |  Branch (13744:7): [True: 2.77k, False: 128k]
  ------------------
13745|  2.77k|        ada_log("FILE ", helpers::substring(url_data, input_position));
13746|  2.77k|        std::string_view file_view = url_data.substr(input_position);
13747|       |
13748|  2.77k|        url.set_protocol_as_file();
13749|       |        if constexpr (result_type_is_ada_url) {
13750|       |          // Set url's host to the empty string.
13751|       |          url.host = "";
13752|  2.77k|        } else {
13753|  2.77k|          url.update_base_hostname("");
13754|  2.77k|        }
13755|       |        // If c is U+002F (/) or U+005C (\), then:
13756|  2.77k|        if (input_position != input_size &&
  ------------------
  |  Branch (13756:13): [True: 2.66k, False: 108]
  ------------------
13757|  2.66k|            (url_data[input_position] == '/' ||
  ------------------
  |  Branch (13757:14): [True: 2.19k, False: 473]
  ------------------
13758|  2.20k|             url_data[input_position] == '\\')) {
  ------------------
  |  Branch (13758:14): [True: 7, False: 466]
  ------------------
13759|  2.20k|          ada_log("FILE c is U+002F or U+005C");
13760|       |          // Set state to file slash state.
13761|  2.20k|          state = state::FILE_SLASH;
13762|  2.20k|        }
13763|       |        // Otherwise, if base is non-null and base's scheme is "file":
13764|    574|        else if (base_url != nullptr && base_url->type == scheme::type::FILE) {
  ------------------
  |  Branch (13764:18): [True: 206, False: 368]
  |  Branch (13764:41): [True: 140, False: 66]
  ------------------
13765|       |          // Set url's host to base's host, url's path to a clone of base's
13766|       |          // path, and url's query to base's query.
13767|    140|          ada_log("FILE base non-null");
13768|       |          if constexpr (result_type_is_ada_url) {
13769|       |            url.host = base_url->host;
13770|       |            url.path = base_url->path;
13771|       |            url.query = base_url->query;
13772|    140|          } else {
13773|    140|            url.update_host_to_base_host(base_url->get_hostname());
13774|    140|            url.update_base_pathname(base_url->get_pathname());
13775|    140|            if (base_url->has_search()) {
  ------------------
  |  Branch (13775:17): [True: 0, False: 140]
  ------------------
13776|       |              // get_search() returns "" for an empty query string (URL ends
13777|       |              // with '?'). update_base_search("") would incorrectly clear the
13778|       |              // query, so pass "?" to preserve the empty query distinction.
13779|      0|              auto s = base_url->get_search();
13780|      0|              url.update_base_search(s.empty() ? std::string_view("?") : s);
  ------------------
  |  Branch (13780:38): [True: 0, False: 0]
  ------------------
13781|      0|            }
13782|    140|          }
13783|    140|          url.has_opaque_path = base_url->has_opaque_path;
13784|       |
13785|       |          // If c is U+003F (?), then set url's query to the empty string and
13786|       |          // state to query state.
13787|    140|          if (input_position != input_size && url_data[input_position] == '?') {
  ------------------
  |  Branch (13787:15): [True: 93, False: 47]
  |  Branch (13787:47): [True: 4, False: 89]
  ------------------
13788|      4|            state = state::QUERY;
13789|      4|          }
13790|       |          // Otherwise, if c is not the EOF code point:
13791|    136|          else if (input_position != input_size) {
  ------------------
  |  Branch (13791:20): [True: 89, False: 47]
  ------------------
13792|       |            // Set url's query to null.
13793|     89|            url.clear_search();
13794|       |            // If the code point substring from pointer to the end of input does
13795|       |            // not start with a Windows drive letter, then shorten url's path.
13796|     89|            if (!checkers::is_windows_drive_letter(file_view)) {
  ------------------
  |  Branch (13796:17): [True: 76, False: 13]
  ------------------
13797|       |              if constexpr (result_type_is_ada_url) {
13798|       |                helpers::shorten_path(url.path, url.type);
13799|     76|              } else {
13800|     76|                std::string_view path = url.get_pathname();
13801|     76|                if (helpers::shorten_path(path, url.type)) {
  ------------------
  |  Branch (13801:21): [True: 0, False: 76]
  ------------------
13802|      0|                  url.update_base_pathname(std::move(std::string(path)));
13803|      0|                }
13804|     76|              }
13805|     76|            }
13806|       |            // Otherwise:
13807|     13|            else {
13808|       |              // Set url's path to an empty list.
13809|     13|              url.clear_pathname();
13810|     13|              url.has_opaque_path = true;
13811|     13|            }
13812|       |
13813|       |            // Set state to path state and decrease pointer by 1.
13814|     89|            state = state::PATH;
13815|     89|            break;
13816|     89|          }
13817|    140|        }
13818|       |        // Otherwise, set state to path state, and decrease pointer by 1.
13819|    434|        else {
13820|    434|          ada_log("FILE go to path");
13821|    434|          state = state::PATH;
13822|    434|          break;
13823|    434|        }
13824|       |
13825|  2.25k|        input_position++;
13826|  2.25k|        break;
13827|  2.77k|      }
13828|      0|      default:
  ------------------
  |  Branch (13828:7): [True: 0, False: 131k]
  ------------------
13829|      0|        unreachable();
13830|   131k|    }
13831|   131k|  }
13832|       |  if constexpr (store_values) {
13833|       |    if (fragment.has_value()) {
13834|       |      url.update_unencoded_base_hash(*fragment);
13835|       |    }
13836|       |  }
13837|    226|  enforce_max_input_length();
13838|    226|  return url;
13839|  30.3k|}
_ZNK3ada14url_aggregator8get_hostEv:
14836|    172|    ada_lifetime_bound {
14837|    172|  ada_log("url_aggregator::get_host");
14838|       |  // Technically, we should check if there is a hostname, but
14839|       |  // the code below works even if there isn't.
14840|       |  // if(!has_hostname()) { return ""; }
14841|    172|  size_t start = components.host_start;
14842|    172|  if (components.host_end > components.host_start &&
  ------------------
  |  Branch (14842:7): [True: 42, False: 130]
  ------------------
14843|     42|      buffer[components.host_start] == '@') {
  ------------------
  |  Branch (14843:7): [True: 0, False: 42]
  ------------------
14844|      0|    start++;
14845|      0|  }
14846|       |  // if we have an empty host, then the space between components.host_end and
14847|       |  // components.pathname_start may be occupied by /.
14848|    172|  if (start == components.host_end) {
  ------------------
  |  Branch (14848:7): [True: 130, False: 42]
  ------------------
14849|    130|    return {};
14850|    130|  }
14851|     42|  return helpers::substring(buffer, start, components.pathname_start);
14852|    172|}
_ZNK3ada14url_aggregator12get_hostnameEv:
14855|  19.0k|    ada_lifetime_bound {
14856|  19.0k|  ada_log("url_aggregator::get_hostname");
14857|       |  // Technically, we should check if there is a hostname, but
14858|       |  // the code below works even if there isn't.
14859|       |  // if(!has_hostname()) { return ""; }
14860|  19.0k|  size_t start = components.host_start;
14861|       |  // So host_start is not where the host begins.
14862|  19.0k|  if (components.host_end > components.host_start &&
  ------------------
  |  Branch (14862:7): [True: 5.06k, False: 13.9k]
  ------------------
14863|  5.06k|      buffer[components.host_start] == '@') {
  ------------------
  |  Branch (14863:7): [True: 206, False: 4.85k]
  ------------------
14864|    206|    start++;
14865|    206|  }
14866|  19.0k|  return helpers::substring(buffer, start, components.host_end);
14867|  19.0k|}
_ZNK3ada14url_aggregator10get_searchEv:
14870|    149|    ada_lifetime_bound {
14871|    149|  ada_log("url_aggregator::get_search");
14872|       |  // If this's URL's query is either null or the empty string, then return the
14873|       |  // empty string. Return U+003F (?), followed by this's URL's query.
14874|    149|  if (components.search_start == url_components::omitted) {
  ------------------
  |  Branch (14874:7): [True: 0, False: 149]
  ------------------
14875|      0|    return "";
14876|      0|  }
14877|    149|  auto ending_index = uint32_t(buffer.size());
14878|    149|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (14878:7): [True: 27, False: 122]
  ------------------
14879|     27|    ending_index = components.hash_start;
14880|     27|  }
14881|    149|  if (ending_index - components.search_start <= 1) {
  ------------------
  |  Branch (14881:7): [True: 67, False: 82]
  ------------------
14882|     67|    return "";
14883|     67|  }
14884|     82|  return helpers::substring(buffer, components.search_start, ending_index);
14885|    149|}
_ZNK3ada14url_aggregator12get_protocolEv:
14888|  1.98k|    ada_lifetime_bound {
14889|  1.98k|  ada_log("url_aggregator::get_protocol");
14890|  1.98k|  return helpers::substring(buffer, 0, components.protocol_end);
14891|  1.98k|}
_ZN3ada14url_aggregator10parse_ipv4ENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEb:
15000|  3.68k|bool url_aggregator::parse_ipv4(std::string_view input, bool in_place) {
15001|  3.68k|  ada_log("parse_ipv4 ", input, " [", input.size(),
15002|  3.68k|          " bytes], overlaps with buffer: ",
15003|  3.68k|          helpers::overlaps(input, buffer) ? "yes" : "no");
15004|  3.68k|  ADA_ASSERT_TRUE(validate());
15005|  3.68k|  if (input.empty()) {
  ------------------
  |  Branch (15005:7): [True: 0, False: 3.68k]
  ------------------
15006|      0|    return is_valid = false;
15007|      0|  }
15008|  3.68k|  const bool trailing_dot = (input.back() == '.');
15009|  3.68k|  if (trailing_dot) {
  ------------------
  |  Branch (15009:7): [True: 120, False: 3.56k]
  ------------------
15010|    120|    input.remove_suffix(1);
15011|    120|    if (input.empty()) {
  ------------------
  |  Branch (15011:9): [True: 0, False: 120]
  ------------------
15012|      0|      return is_valid = false;
15013|      0|    }
15014|    120|  }
15015|       |
15016|  3.68k|  const uint64_t fast = checkers::try_parse_ipv4_fast(input);
15017|  3.68k|  if (fast < checkers::ipv4_fast_fail) [[likely]] {
  ------------------
  |  Branch (15017:7): [True: 40, False: 3.64k]
  ------------------
15018|       |    // Pure decimal: keep the buffer when it already holds the address.
15019|       |    // Otherwise write the (trailing-dot-stripped) input.
15020|     40|    if (!(in_place && !trailing_dot)) {
  ------------------
  |  Branch (15020:11): [True: 0, False: 40]
  |  Branch (15020:23): [True: 0, False: 0]
  ------------------
15021|     40|      if (helpers::overlaps(input, buffer)) {
  ------------------
  |  Branch (15021:11): [True: 0, False: 40]
  ------------------
15022|      0|        update_base_hostname(std::string(input));
15023|     40|      } else {
15024|     40|        update_base_hostname(input);
15025|     40|      }
15026|     40|    }
15027|     40|    host_type = IPV4;
15028|     40|    ADA_ASSERT_TRUE(validate());
15029|     40|    return true;
15030|     40|  }
15031|       |
15032|  3.64k|  const char* p = input.data();
15033|  3.64k|  const char* end = p + input.size();
15034|  3.64k|  uint64_t ipv4 = 0;
15035|  3.64k|  int digit_count = 0;
15036|  3.64k|  int pure_decimal_count = 0;
15037|       |
15038|  4.54k|  for (; digit_count < 4 && p < end; ++digit_count) {
  ------------------
  |  Branch (15038:10): [True: 4.52k, False: 18]
  |  Branch (15038:29): [True: 4.52k, False: 0]
  ------------------
15039|  4.52k|    uint64_t segment = 0;
15040|  4.52k|    bool pure = false;
15041|  4.52k|    if (!detail::parse_ipv4_number(p, end, segment, pure)) {
  ------------------
  |  Branch (15041:9): [True: 650, False: 3.87k]
  ------------------
15042|    650|      return is_valid = false;
15043|    650|    }
15044|  3.87k|    if (pure) {
  ------------------
  |  Branch (15044:9): [True: 2.85k, False: 1.02k]
  ------------------
15045|  2.85k|      ++pure_decimal_count;
15046|  2.85k|    }
15047|  3.87k|    if (p >= end) {
  ------------------
  |  Branch (15047:9): [True: 2.92k, False: 956]
  ------------------
15048|  2.92k|      const unsigned shift = static_cast<unsigned>(32 - digit_count * 8);
15049|  2.92k|      if (segment >= (uint64_t{1} << shift)) {
  ------------------
  |  Branch (15049:11): [True: 52, False: 2.87k]
  ------------------
15050|     52|        return is_valid = false;
15051|     52|      }
15052|  2.87k|      ipv4 = (ipv4 << shift) | segment;
15053|  2.87k|      goto ipv4_done;
15054|  2.92k|    }
15055|    956|    if (segment > 255 || *p != '.') {
  ------------------
  |  Branch (15055:9): [True: 58, False: 898]
  |  Branch (15055:26): [True: 0, False: 898]
  ------------------
15056|     58|      return is_valid = false;
15057|     58|    }
15058|    898|    ipv4 = (ipv4 << 8) | segment;
15059|    898|    ++p;
15060|    898|  }
15061|     18|  if (digit_count != 4 || p != end) {
  ------------------
  |  Branch (15061:7): [True: 0, False: 18]
  |  Branch (15061:27): [True: 18, False: 0]
  ------------------
15062|     18|    return is_valid = false;
15063|     18|  }
15064|  2.87k|ipv4_done:
15065|  2.87k|  ada_log("url_aggregator::parse_ipv4 completed ", get_href(),
15066|  2.87k|          " host: ", get_host());
15067|  2.87k|  if (in_place && pure_decimal_count == 4 && !trailing_dot) {
  ------------------
  |  Branch (15067:7): [True: 0, False: 2.87k]
  |  Branch (15067:19): [True: 0, False: 0]
  |  Branch (15067:46): [True: 0, False: 0]
  ------------------
15068|      0|    ada_log(
15069|      0|        "url_aggregator::parse_ipv4 completed and was already correct in the "
15070|      0|        "buffer");
15071|  2.87k|  } else {
15072|  2.87k|    update_base_hostname(ada::serializers::ipv4(ipv4));
15073|  2.87k|  }
15074|  2.87k|  host_type = IPV4;
15075|  2.87k|  ADA_ASSERT_TRUE(validate());
15076|  2.87k|  return true;
15077|     18|}
_ZN3ada14url_aggregator10parse_ipv6ENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
15079|  1.03k|bool url_aggregator::parse_ipv6(std::string_view input) {
15080|  1.03k|  ada_log("parse_ipv6 ", input, " [", input.size(), " bytes]");
15081|  1.03k|  ADA_ASSERT_TRUE(validate());
15082|  1.03k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
15083|  1.03k|  if (input.empty() || input.size() > 45) [[unlikely]] {
  ------------------
  |  Branch (15083:7): [True: 36, False: 1.00k]
  |  Branch (15083:24): [True: 26, False: 974]
  ------------------
15084|     62|    return is_valid = false;
15085|     62|  }
15086|    974|  std::array<uint16_t, 8> address{};
15087|       |#if defined(ADA_AVX512_IPV6)
15088|       |  if (bool simd_valid; detail::try_parse_ipv6_avx512(input.data(), input.size(),
15089|       |                                                     address, simd_valid)) {
15090|       |    if (!simd_valid) [[unlikely]] {
15091|       |      return is_valid = false;
15092|       |    }
15093|       |    const std::string serialized = ada::serializers::ipv6(address);
15094|       |    if (get_hostname() != serialized) {
15095|       |      update_base_hostname(serialized);
15096|       |    }
15097|       |    host_type = IPV6;
15098|       |    return true;
15099|       |  }
15100|       |  address = {};
15101|       |#endif
15102|    974|  const char* pointer = input.data();
15103|    974|  const char* const end = pointer + input.size();
15104|    974|  int piece_index = 0;
15105|    974|  int compress = -1;
15106|       |
15107|    974|  if (*pointer == ':') {
  ------------------
  |  Branch (15107:7): [True: 374, False: 600]
  ------------------
15108|    374|    if (input.size() == 1 || pointer[1] != ':') [[unlikely]] {
  ------------------
  |  Branch (15108:9): [True: 6, False: 368]
  |  Branch (15108:30): [True: 8, False: 360]
  ------------------
15109|     14|      return is_valid = false;
15110|     14|    }
15111|    360|    pointer += 2;
15112|    360|    compress = ++piece_index;
15113|    360|  }
15114|       |
15115|  2.88k|  while (pointer != end) {
  ------------------
  |  Branch (15115:10): [True: 2.22k, False: 666]
  ------------------
15116|  2.22k|    if (piece_index == 8) [[unlikely]] {
  ------------------
  |  Branch (15116:9): [True: 6, False: 2.21k]
  ------------------
15117|      6|      return is_valid = false;
15118|      6|    }
15119|  2.21k|    if (*pointer == ':') {
  ------------------
  |  Branch (15119:9): [True: 278, False: 1.93k]
  ------------------
15120|    278|      if (compress != -1) [[unlikely]] {
  ------------------
  |  Branch (15120:11): [True: 6, False: 272]
  ------------------
15121|      6|        return is_valid = false;
15122|      6|      }
15123|    272|      ++pointer;
15124|    272|      compress = ++piece_index;
15125|    272|      continue;
15126|    278|    }
15127|       |
15128|  1.93k|    uint16_t value = 0;
15129|  1.93k|    const int length = detail::parse_hex_piece(pointer, end, value);
15130|       |
15131|  1.93k|    if (pointer != end && *pointer == '.') {
  ------------------
  |  Branch (15131:9): [True: 1.56k, False: 370]
  |  Branch (15131:27): [True: 182, False: 1.38k]
  ------------------
15132|    182|      if (length == 0) [[unlikely]] {
  ------------------
  |  Branch (15132:11): [True: 8, False: 174]
  ------------------
15133|      8|        return is_valid = false;
15134|      8|      }
15135|    174|      pointer -= length;
15136|    174|      if (piece_index > 6) [[unlikely]] {
  ------------------
  |  Branch (15136:11): [True: 6, False: 168]
  ------------------
15137|      6|        return is_valid = false;
15138|      6|      }
15139|       |
15140|    168|      int numbers_seen = 0;
15141|    498|      while (pointer != end) {
  ------------------
  |  Branch (15141:14): [True: 438, False: 60]
  ------------------
15142|    438|        int ipv4_piece = -1;
15143|    438|        if (numbers_seen > 0) {
  ------------------
  |  Branch (15143:13): [True: 270, False: 168]
  ------------------
15144|    270|          if (*pointer == '.' && numbers_seen < 4) {
  ------------------
  |  Branch (15144:15): [True: 240, False: 30]
  |  Branch (15144:34): [True: 230, False: 10]
  ------------------
15145|    230|            ++pointer;
15146|    230|          } else {
15147|     40|            return is_valid = false;
15148|     40|          }
15149|    270|        }
15150|    398|        if (pointer == end || *pointer < '0' || *pointer > '9') [[unlikely]] {
  ------------------
  |  Branch (15150:13): [True: 34, False: 364]
  |  Branch (15150:31): [True: 6, False: 358]
  |  Branch (15150:49): [True: 10, False: 348]
  ------------------
15151|     50|          return is_valid = false;
15152|     50|        }
15153|    348|        ipv4_piece = *pointer - '0';
15154|    348|        ++pointer;
15155|    348|        if (pointer != end && *pointer >= '0' && *pointer <= '9') {
  ------------------
  |  Branch (15155:13): [True: 312, False: 36]
  |  Branch (15155:31): [True: 124, False: 188]
  |  Branch (15155:50): [True: 116, False: 8]
  ------------------
15156|    116|          if (ipv4_piece == 0) [[unlikely]] {
  ------------------
  |  Branch (15156:15): [True: 8, False: 108]
  ------------------
15157|      8|            return is_valid = false;
15158|      8|          }
15159|    108|          ipv4_piece = ipv4_piece * 10 + (*pointer - '0');
15160|    108|          ++pointer;
15161|    108|          if (pointer != end && *pointer >= '0' && *pointer <= '9') {
  ------------------
  |  Branch (15161:15): [True: 96, False: 12]
  |  Branch (15161:33): [True: 54, False: 42]
  |  Branch (15161:52): [True: 48, False: 6]
  ------------------
15162|     48|            ipv4_piece = ipv4_piece * 10 + (*pointer - '0');
15163|     48|            ++pointer;
15164|     48|            if (ipv4_piece > 255) [[unlikely]] {
  ------------------
  |  Branch (15164:17): [True: 10, False: 38]
  ------------------
15165|     10|              return is_valid = false;
15166|     10|            }
15167|     48|          }
15168|    108|        }
15169|    330|        address[static_cast<size_t>(piece_index)] = static_cast<uint16_t>(
15170|    330|            address[static_cast<size_t>(piece_index)] * 0x100 +
15171|    330|            static_cast<uint16_t>(ipv4_piece));
15172|    330|        ++numbers_seen;
15173|    330|        if (numbers_seen == 2 || numbers_seen == 4) {
  ------------------
  |  Branch (15173:13): [True: 104, False: 226]
  |  Branch (15173:34): [True: 34, False: 192]
  ------------------
15174|    138|          ++piece_index;
15175|    138|        }
15176|    330|      }
15177|     60|      if (numbers_seen != 4) [[unlikely]] {
  ------------------
  |  Branch (15177:11): [True: 36, False: 24]
  ------------------
15178|     36|        return is_valid = false;
15179|     36|      }
15180|     24|      break;
15181|     60|    }
15182|       |
15183|  1.75k|    if (length == 0) [[unlikely]] {
  ------------------
  |  Branch (15183:9): [True: 76, False: 1.68k]
  ------------------
15184|     76|      return is_valid = false;
15185|     76|    }
15186|       |
15187|  1.68k|    if (pointer != end && *pointer == ':') {
  ------------------
  |  Branch (15187:9): [True: 1.31k, False: 370]
  |  Branch (15187:27): [True: 1.29k, False: 18]
  ------------------
15188|  1.29k|      ++pointer;
15189|  1.29k|      if (pointer == end) [[unlikely]] {
  ------------------
  |  Branch (15189:11): [True: 6, False: 1.28k]
  ------------------
15190|      6|        return is_valid = false;
15191|      6|      }
15192|  1.29k|    } else if (pointer != end) [[unlikely]] {
  ------------------
  |  Branch (15192:16): [True: 18, False: 370]
  ------------------
15193|     18|      return is_valid = false;
15194|     18|    }
15195|       |
15196|  1.65k|    address[static_cast<size_t>(piece_index)] = value;
15197|  1.65k|    ++piece_index;
15198|  1.65k|  }
15199|       |
15200|    690|  if (compress != -1) {
  ------------------
  |  Branch (15200:7): [True: 614, False: 76]
  ------------------
15201|    614|    const int right = piece_index - compress;
15202|    614|    if (right > 0) {
  ------------------
  |  Branch (15202:9): [True: 318, False: 296]
  ------------------
15203|    318|      const size_t dest = static_cast<size_t>(8 - right);
15204|    318|      const size_t src = static_cast<size_t>(compress);
15205|    318|      if (dest != src) {
  ------------------
  |  Branch (15205:11): [True: 278, False: 40]
  ------------------
15206|    774|        for (size_t i = static_cast<size_t>(right); i-- > 0;) {
  ------------------
  |  Branch (15206:53): [True: 496, False: 278]
  ------------------
15207|    496|          address[dest + i] = address[src + i];
15208|    496|          address[src + i] = 0;
15209|    496|        }
15210|    278|      }
15211|    318|    }
15212|    614|  } else if (piece_index != 8) [[unlikely]] {
  ------------------
  |  Branch (15212:14): [True: 38, False: 38]
  ------------------
15213|     38|    return is_valid = false;
15214|     38|  }
15215|       |
15216|       |  // Serialize once; skip rewrite when hostname is already canonical.
15217|    652|  const std::string serialized = ada::serializers::ipv6(address);
15218|    652|  const std::string_view current = get_hostname();
15219|    652|  if (current.size() == serialized.size() &&
  ------------------
  |  Branch (15219:7): [True: 0, False: 652]
  ------------------
15220|      0|      std::memcmp(current.data(), serialized.data(), serialized.size()) == 0) {
  ------------------
  |  Branch (15220:7): [True: 0, False: 0]
  ------------------
15221|      0|    ada_log("parse_ipv6 in-place canonical match");
15222|    652|  } else {
15223|    652|    update_base_hostname(serialized);
15224|    652|  }
15225|    652|  ada_log("parse_ipv6 ", get_hostname());
15226|    652|  ADA_ASSERT_TRUE(validate());
15227|    652|  host_type = IPV6;
15228|    652|  return true;
15229|    690|}
_ZN3ada14url_aggregator17parse_opaque_hostENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
15231|  1.19k|bool url_aggregator::parse_opaque_host(std::string_view input) {
15232|  1.19k|  ada_log("parse_opaque_host ", input, " [", input.size(), " bytes]");
15233|  1.19k|  ADA_ASSERT_TRUE(validate());
15234|  1.19k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
15235|  1.19k|  if (std::ranges::any_of(input, ada::unicode::is_forbidden_host_code_point)) {
  ------------------
  |  Branch (15235:7): [True: 26, False: 1.17k]
  ------------------
15236|     26|    return is_valid = false;
15237|     26|  }
15238|       |
15239|       |  // Return the result of running UTF-8 percent-encode on input using the C0
15240|       |  // control percent-encode set.
15241|  1.17k|  size_t idx = ada::unicode::percent_encode_index(
15242|  1.17k|      input, character_sets::C0_CONTROL_PERCENT_ENCODE);
15243|  1.17k|  if (idx == input.size()) {
  ------------------
  |  Branch (15243:7): [True: 690, False: 480]
  ------------------
15244|    690|    update_base_hostname(input);
15245|    690|  } else {
15246|       |    // We only create a temporary string if we need to.
15247|    480|    update_base_hostname(ada::unicode::percent_encode(
15248|    480|        input, character_sets::C0_CONTROL_PERCENT_ENCODE, idx));
15249|    480|  }
15250|  1.17k|  ADA_ASSERT_TRUE(validate());
15251|  1.17k|  return true;
15252|  1.19k|}
_ZN3ada14url_aggregator15delete_dash_dotEv:
15411|      5|void url_aggregator::delete_dash_dot() {
15412|      5|  ada_log("url_aggregator::delete_dash_dot");
15413|      5|  ADA_ASSERT_TRUE(validate());
15414|      5|  ADA_ASSERT_TRUE(has_dash_dot());
15415|      5|  buffer.erase(components.host_end, 2);
15416|      5|  components.pathname_start -= 2;
15417|      5|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (15417:7): [True: 0, False: 5]
  ------------------
15418|      0|    components.search_start -= 2;
15419|      0|  }
15420|      5|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (15420:7): [True: 0, False: 5]
  ------------------
15421|      0|    components.hash_start -= 2;
15422|      0|  }
15423|      5|  ADA_ASSERT_TRUE(validate());
15424|      5|  ADA_ASSERT_TRUE(!has_dash_dot());
15425|      5|}
can_parse.cc:_ZZN3ada4idna22utf32_length_from_utf8EPKcmENK3$_0clEa:
  274|   414k|  return std::count_if(p, std::next(p, len), [](int8_t c) {
  275|       |    // -65 is 0b10111111, anything larger in two-complement's
  276|       |    // should start a new code point.
  277|   414k|    return c > -65;
  278|   414k|  });
_ZN3ada4idna7deflate22make_fixed_litlen_huffEv:
  480|      2|inline Huff make_fixed_litlen_huff() {
  481|      2|  Huff h;
  482|      2|  uint8_t lens[288];
  483|       |  // Fixed Huffman: 0-143:8, 144-255:9, 256-279:7, 280-287:8
  484|    290|  for (int i = 0; i <= 143; i++) lens[i] = 8;
  ------------------
  |  Branch (484:19): [True: 288, False: 2]
  ------------------
  485|    226|  for (int i = 144; i <= 255; i++) lens[i] = 9;
  ------------------
  |  Branch (485:21): [True: 224, False: 2]
  ------------------
  486|     50|  for (int i = 256; i <= 279; i++) lens[i] = 7;
  ------------------
  |  Branch (486:21): [True: 48, False: 2]
  ------------------
  487|     18|  for (int i = 280; i <= 287; i++) lens[i] = 8;
  ------------------
  |  Branch (487:21): [True: 16, False: 2]
  ------------------
  488|      2|  h.build(lens, 288);
  489|      2|  return h;
  490|      2|}
_ZN3ada4idna7deflate4Huff5buildEPKhi:
  429|     16|  bool build(const uint8_t* lens, int n) {
  430|     16|    std::memset(counts, 0, sizeof(counts));
  431|     16|    std::memset(first_code, 0, sizeof(first_code));
  432|     16|    std::memset(base_idx, 0, sizeof(base_idx));
  433|     16|    nsymbols = n;
  434|     16|    max_bits = 0;
  435|  1.99k|    for (int i = 0; i < n; i++) {
  ------------------
  |  Branch (435:21): [True: 1.97k, False: 16]
  ------------------
  436|  1.97k|      lengths[i] = lens[i];
  437|  1.97k|      if (lens[i]) {
  ------------------
  |  Branch (437:11): [True: 1.93k, False: 42]
  ------------------
  438|  1.93k|        counts[lens[i]]++;
  439|  1.93k|        if (lens[i] > max_bits) max_bits = lens[i];
  ------------------
  |  Branch (439:13): [True: 45, False: 1.88k]
  ------------------
  440|  1.93k|      }
  441|  1.97k|    }
  442|       |    // Canonical first code for each bit length (RFC 1951).
  443|     16|    int code = 0;
  444|    256|    for (int bits = 1; bits <= MAXBITS; bits++) {
  ------------------
  |  Branch (444:24): [True: 240, False: 16]
  ------------------
  445|    240|      code = (code + counts[bits - 1]) << 1;
  446|    240|      first_code[bits] = code;
  447|    240|    }
  448|     16|    int idx = 0;
  449|    159|    for (int bits = 1; bits <= max_bits; bits++) {
  ------------------
  |  Branch (449:24): [True: 143, False: 16]
  ------------------
  450|    143|      base_idx[bits] = idx;
  451|       |      // assign symbols in symbol order for codes of this length
  452|  21.8k|      for (int sym = 0; sym < n; sym++) {
  ------------------
  |  Branch (452:25): [True: 21.6k, False: 143]
  ------------------
  453|  21.6k|        if (lengths[sym] == bits) {
  ------------------
  |  Branch (453:13): [True: 1.93k, False: 19.7k]
  ------------------
  454|  1.93k|          symbols[idx++] = static_cast<int16_t>(sym);
  455|  1.93k|        }
  456|  21.6k|      }
  457|    143|    }
  458|     16|    return true;
  459|     16|  }
_ZN3ada4idna7deflate20make_fixed_dist_huffEv:
  492|      2|inline Huff make_fixed_dist_huff() {
  493|      2|  Huff h;
  494|      2|  uint8_t lens[32];
  495|     66|  for (int i = 0; i < 32; i++) lens[i] = 5;
  ------------------
  |  Branch (495:19): [True: 64, False: 2]
  ------------------
  496|      2|  h.build(lens, 32);
  497|      2|  return h;
  498|      2|}
can_parse.cc:_ZZN3ada4idna9ascii_mapEPcmENK3$_0clEh:
 5339|  18.8k|  auto broadcast = [](uint8_t v) -> uint64_t {
 5340|  18.8k|    return 0x101010101010101ull * v;
 5341|  18.8k|  };
_ZN3ada4idna13ensure_tablesEv:
 5085|  67.1k|[[nodiscard]] inline bool ensure_tables() noexcept {
 5086|  67.1k|  uint8_t state = tables_init_state.load(std::memory_order_acquire);
 5087|  67.1k|  if (state == kTablesReady) {
  ------------------
  |  Branch (5087:7): [True: 67.1k, False: 1]
  ------------------
 5088|  67.1k|    return true;
 5089|  67.1k|  }
 5090|      1|  if (state == kTablesFailed) {
  ------------------
  |  Branch (5090:7): [True: 0, False: 1]
  ------------------
 5091|      0|    return false;
 5092|      0|  }
 5093|       |
 5094|      1|  uint8_t expected = kTablesUninit;
 5095|      1|  if (tables_init_state.compare_exchange_strong(expected, kTablesInProgress,
  ------------------
  |  Branch (5095:7): [True: 1, False: 0]
  ------------------
 5096|      1|                                                std::memory_order_acq_rel,
 5097|      1|                                                std::memory_order_acquire)) {
 5098|      1|    uint8_t* buffer = new (std::nothrow) uint8_t[table_blob::uncompressed_size];
 5099|      1|    if (buffer == nullptr) {
  ------------------
  |  Branch (5099:9): [True: 0, False: 1]
  ------------------
 5100|      0|      tables_init_state.store(kTablesFailed, std::memory_order_release);
 5101|      0|      return false;
 5102|      0|    }
 5103|       |
 5104|      1|    const size_t n = deflate::inflate_raw(table_blob::compressed,
 5105|      1|                                          table_blob::compressed_size, buffer,
 5106|      1|                                          table_blob::uncompressed_size);
 5107|      1|    if (n != table_blob::uncompressed_size ||
  ------------------
  |  Branch (5107:9): [True: 0, False: 1]
  ------------------
 5108|      1|        crc32_ieee(buffer, n) != table_blob::uncompressed_crc32) {
  ------------------
  |  Branch (5108:9): [True: 0, False: 1]
  ------------------
 5109|      0|      delete[] buffer;
 5110|      0|      tables_init_state.store(kTablesFailed, std::memory_order_release);
 5111|      0|      return false;
 5112|      0|    }
 5113|       |
 5114|       |    // LE payload verified; convert multi-byte fields for big-endian hosts.
 5115|      1|    detail::convert_table_blob_to_host_endian(buffer);
 5116|       |
 5117|      1|    auto at = [&](size_t off) noexcept -> const uint8_t* {
 5118|      1|      return buffer + off;
 5119|      1|    };
 5120|       |
 5121|       |    // Publish all non-atomic pointers before READY. Waiters synchronize via
 5122|       |    // acquire on tables_init_state and then observe these writes.
 5123|      1|    idna_stage1 =
 5124|      1|        reinterpret_cast<const uint16_t*>(at(table_blob::off_idna_stage1));
 5125|      1|    idna_stage2 =
 5126|      1|        reinterpret_cast<const uint16_t*>(at(table_blob::off_idna_stage2));
 5127|      1|    idna_bool_blocks =
 5128|      1|        reinterpret_cast<const uint64_t*>(at(table_blob::off_idna_bool_blocks));
 5129|      1|    idna_utf8_mappings = at(table_blob::off_idna_utf8_mappings);
 5130|       |
 5131|      1|    decomposition_index = at(table_blob::off_decomposition_index);
 5132|      1|    decomposition_block_flat = reinterpret_cast<const uint16_t*>(
 5133|      1|        at(table_blob::off_decomposition_block));
 5134|      1|    decomposition_data = reinterpret_cast<const char32_t*>(
 5135|      1|        at(table_blob::off_decomposition_data));
 5136|      1|    ccc_index = at(table_blob::off_ccc_index);
 5137|      1|    ccc_block_flat = at(table_blob::off_ccc_block);
 5138|      1|    composition_index = at(table_blob::off_composition_index);
 5139|      1|    composition_block_flat = reinterpret_cast<const uint16_t*>(
 5140|      1|        at(table_blob::off_composition_block));
 5141|      1|    composition_data =
 5142|      1|        reinterpret_cast<const char32_t*>(at(table_blob::off_composition_data));
 5143|       |
 5144|      1|    id_continue =
 5145|      1|        reinterpret_cast<range_pair_ptr>(at(table_blob::off_id_continue_flat));
 5146|      1|    id_start =
 5147|      1|        reinterpret_cast<range_pair_ptr>(at(table_blob::off_id_start_flat));
 5148|       |
 5149|      1|    dir_start =
 5150|      1|        reinterpret_cast<const uint32_t*>(at(table_blob::off_dir_start));
 5151|      1|    dir_final =
 5152|      1|        reinterpret_cast<const uint32_t*>(at(table_blob::off_dir_final));
 5153|      1|    dir_value = at(table_blob::off_dir_value);
 5154|      1|    combining_ranges =
 5155|      1|        reinterpret_cast<range_pair_ptr>(at(table_blob::off_combining_flat));
 5156|      1|    joining_start =
 5157|      1|        reinterpret_cast<const uint32_t*>(at(table_blob::off_joining_start));
 5158|      1|    joining_final =
 5159|      1|        reinterpret_cast<const uint32_t*>(at(table_blob::off_joining_final));
 5160|      1|    joining_value = at(table_blob::off_joining_value);
 5161|       |
 5162|      1|    tables_buffer = buffer;
 5163|      1|    tables_init_state.store(kTablesReady, std::memory_order_release);
 5164|      1|    return true;
 5165|      1|  }
 5166|       |
 5167|       |  // Another thread owns init (or finished between our loads).
 5168|      0|  for (uint64_t spins = 0; spins < kTablesSpinLimit; ++spins) {
  ------------------
  |  Branch (5168:28): [True: 0, False: 0]
  ------------------
 5169|      0|    state = tables_init_state.load(std::memory_order_acquire);
 5170|      0|    if (state == kTablesReady) {
  ------------------
  |  Branch (5170:9): [True: 0, False: 0]
  ------------------
 5171|      0|      return true;
 5172|      0|    }
 5173|      0|    if (state == kTablesFailed) {
  ------------------
  |  Branch (5173:9): [True: 0, False: 0]
  ------------------
 5174|      0|      return false;
 5175|      0|    }
 5176|      0|#if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || \
 5177|      0|    defined(_M_IX86)
 5178|      0|#if defined(__GNUC__) || defined(__clang__)
 5179|      0|    __builtin_ia32_pause();
 5180|      0|#endif
 5181|       |#elif defined(__aarch64__) || defined(_M_ARM64)
 5182|       |#if defined(__GNUC__) || defined(__clang__)
 5183|       |    asm volatile("yield" ::: "memory");
 5184|       |#endif
 5185|       |#endif
 5186|      0|  }
 5187|       |  // Timed out waiting for a peer - treat as failure rather than hang.
 5188|      0|  return false;
 5189|      0|}
_ZN3ada4idna7deflate11inflate_rawEPKhmPhm:
  525|      1|                          size_t dst_cap) {
  526|      1|  BitReader br(src, src_len);
  527|      1|  size_t out = 0;
  528|      4|  for (;;) {
  529|      4|    uint32_t bfinal = br.get(1);
  530|      4|    uint32_t btype = br.get(2);
  531|      4|    if (bfinal == UINT32_MAX || btype == UINT32_MAX) return 0;
  ------------------
  |  Branch (531:9): [True: 0, False: 4]
  |  Branch (531:33): [True: 0, False: 4]
  ------------------
  532|      4|    if (btype == 0) {
  ------------------
  |  Branch (532:9): [True: 0, False: 4]
  ------------------
  533|       |      // stored
  534|      0|      br.align_byte();
  535|      0|      if (!br.ensure(16)) return 0;
  ------------------
  |  Branch (535:11): [True: 0, False: 0]
  ------------------
  536|       |      // read 16+16 from bit buffer awkwardly - use byte path
  537|       |      // Align: bits is multiple of 8
  538|       |      // Get len from remaining bits then bytes
  539|      0|      uint32_t len = br.get(16);
  540|      0|      uint32_t nlen = br.get(16);
  541|      0|      if (len == UINT32_MAX || nlen == UINT32_MAX) return 0;
  ------------------
  |  Branch (541:11): [True: 0, False: 0]
  |  Branch (541:32): [True: 0, False: 0]
  ------------------
  542|      0|      if ((len ^ 0xFFFF) != nlen) return 0;
  ------------------
  |  Branch (542:11): [True: 0, False: 0]
  ------------------
  543|       |      // After get, may have bits in acc from previous - for stored, should be
  544|       |      // byte aligned Copy len bytes from p
  545|      0|      if (br.bits != 0) {
  ------------------
  |  Branch (545:11): [True: 0, False: 0]
  ------------------
  546|       |        // leftover bits should be 0 if aligned
  547|      0|      }
  548|      0|      if (size_t(br.end - br.p) < len) return 0;
  ------------------
  |  Branch (548:11): [True: 0, False: 0]
  ------------------
  549|      0|      if (out + len > dst_cap) return 0;
  ------------------
  |  Branch (549:11): [True: 0, False: 0]
  ------------------
  550|      0|      std::memcpy(dst + out, br.p, len);
  551|      0|      br.p += len;
  552|      0|      out += len;
  553|      4|    } else if (btype == 1 || btype == 2) {
  ------------------
  |  Branch (553:16): [True: 0, False: 4]
  |  Branch (553:30): [True: 4, False: 0]
  ------------------
  554|      4|      Huff lit, dist;
  555|      4|      if (btype == 1) {
  ------------------
  |  Branch (555:11): [True: 0, False: 4]
  ------------------
  556|       |        // use fixed via functions
  557|      4|      } else {
  558|       |        // dynamic
  559|      4|        uint32_t hlit = br.get(5);
  560|      4|        if (hlit == UINT32_MAX) return 0;
  ------------------
  |  Branch (560:13): [True: 0, False: 4]
  ------------------
  561|      4|        hlit += 257;
  562|      4|        uint32_t hdist = br.get(5);
  563|      4|        if (hdist == UINT32_MAX) return 0;
  ------------------
  |  Branch (563:13): [True: 0, False: 4]
  ------------------
  564|      4|        hdist += 1;
  565|      4|        uint32_t hclen = br.get(4);
  566|      4|        if (hclen == UINT32_MAX) return 0;
  ------------------
  |  Branch (566:13): [True: 0, False: 4]
  ------------------
  567|      4|        hclen += 4;
  568|      4|        static const int order[19] = {16, 17, 18, 0, 8,  7, 9,  6, 10, 5,
  569|      4|                                      11, 4,  12, 3, 13, 2, 14, 1, 15};
  570|      4|        uint8_t clen[19]{};
  571|     69|        for (uint32_t i = 0; i < hclen; i++) {
  ------------------
  |  Branch (571:30): [True: 65, False: 4]
  ------------------
  572|     65|          uint32_t v = br.get(3);
  573|     65|          if (v == UINT32_MAX) return 0;
  ------------------
  |  Branch (573:15): [True: 0, False: 65]
  ------------------
  574|     65|          clen[order[i]] = uint8_t(v);
  575|     65|        }
  576|      4|        Huff cl;
  577|      4|        if (!cl.build(clen, 19)) return 0;
  ------------------
  |  Branch (577:13): [True: 0, False: 4]
  ------------------
  578|      4|        uint8_t lens[288 + 32]{};
  579|      4|        uint32_t n = hlit + hdist;
  580|  1.04k|        for (uint32_t i = 0; i < n;) {
  ------------------
  |  Branch (580:30): [True: 1.03k, False: 4]
  ------------------
  581|  1.03k|          int sym = cl.decode(br);
  582|  1.03k|          if (sym < 0) return 0;
  ------------------
  |  Branch (582:15): [True: 0, False: 1.03k]
  ------------------
  583|  1.03k|          if (sym < 16) {
  ------------------
  |  Branch (583:15): [True: 973, False: 63]
  ------------------
  584|    973|            lens[i++] = uint8_t(sym);
  585|    973|          } else if (sym == 16) {
  ------------------
  |  Branch (585:22): [True: 63, False: 0]
  ------------------
  586|     63|            uint32_t rep = br.get(2);
  587|     63|            if (rep == UINT32_MAX) return 0;
  ------------------
  |  Branch (587:17): [True: 0, False: 63]
  ------------------
  588|     63|            rep += 3;
  589|     63|            if (i == 0) return 0;
  ------------------
  |  Branch (589:17): [True: 0, False: 63]
  ------------------
  590|     63|            uint8_t v = lens[i - 1];
  591|    350|            while (rep--) lens[i++] = v;
  ------------------
  |  Branch (591:20): [True: 287, False: 63]
  ------------------
  592|     63|          } else if (sym == 17) {
  ------------------
  |  Branch (592:22): [True: 0, False: 0]
  ------------------
  593|      0|            uint32_t rep = br.get(3);
  594|      0|            if (rep == UINT32_MAX) return 0;
  ------------------
  |  Branch (594:17): [True: 0, False: 0]
  ------------------
  595|      0|            rep += 3;
  596|      0|            while (rep--) lens[i++] = 0;
  ------------------
  |  Branch (596:20): [True: 0, False: 0]
  ------------------
  597|      0|          } else if (sym == 18) {
  ------------------
  |  Branch (597:22): [True: 0, False: 0]
  ------------------
  598|      0|            uint32_t rep = br.get(7);
  599|      0|            if (rep == UINT32_MAX) return 0;
  ------------------
  |  Branch (599:17): [True: 0, False: 0]
  ------------------
  600|      0|            rep += 11;
  601|      0|            while (rep--) lens[i++] = 0;
  ------------------
  |  Branch (601:20): [True: 0, False: 0]
  ------------------
  602|      0|          } else
  603|      0|            return 0;
  604|  1.03k|        }
  605|      4|        if (!lit.build(lens, int(hlit))) return 0;
  ------------------
  |  Branch (605:13): [True: 0, False: 4]
  ------------------
  606|      4|        if (!dist.build(lens + hlit, int(hdist))) return 0;
  ------------------
  |  Branch (606:13): [True: 0, False: 4]
  ------------------
  607|      4|      }
  608|  54.4k|      for (;;) {
  609|  54.4k|        int sym;
  610|  54.4k|        if (btype == 1)
  ------------------
  |  Branch (610:13): [True: 0, False: 54.4k]
  ------------------
  611|      0|          sym = fixed_litlen(br);
  612|  54.4k|        else
  613|  54.4k|          sym = lit.decode(br);
  614|  54.4k|        if (sym < 0) return 0;
  ------------------
  |  Branch (614:13): [True: 0, False: 54.4k]
  ------------------
  615|  54.4k|        if (sym < 256) {
  ------------------
  |  Branch (615:13): [True: 38.5k, False: 15.9k]
  ------------------
  616|  38.5k|          if (out >= dst_cap) return 0;
  ------------------
  |  Branch (616:15): [True: 0, False: 38.5k]
  ------------------
  617|  38.5k|          dst[out++] = uint8_t(sym);
  618|  38.5k|        } else if (sym == 256) {
  ------------------
  |  Branch (618:20): [True: 4, False: 15.9k]
  ------------------
  619|      4|          break;
  620|  15.9k|        } else {
  621|  15.9k|          int len_code = sym - 257;
  622|  15.9k|          if (len_code < 0 || len_code > 28) return 0;
  ------------------
  |  Branch (622:15): [True: 0, False: 15.9k]
  |  Branch (622:31): [True: 0, False: 15.9k]
  ------------------
  623|  15.9k|          uint32_t extra = br.get(len_extra[len_code]);
  624|  15.9k|          if (len_extra[len_code] && extra == UINT32_MAX) return 0;
  ------------------
  |  Branch (624:15): [True: 2.24k, False: 13.6k]
  |  Branch (624:38): [True: 0, False: 2.24k]
  ------------------
  625|  15.9k|          uint32_t length =
  626|  15.9k|              len_base[len_code] + (len_extra[len_code] ? extra : 0);
  ------------------
  |  Branch (626:37): [True: 2.24k, False: 13.6k]
  ------------------
  627|  15.9k|          int dsym;
  628|  15.9k|          if (btype == 1)
  ------------------
  |  Branch (628:15): [True: 0, False: 15.9k]
  ------------------
  629|      0|            dsym = fixed_dist(br);
  630|  15.9k|          else
  631|  15.9k|            dsym = dist.decode(br);
  632|  15.9k|          if (dsym < 0 || dsym > 29) return 0;
  ------------------
  |  Branch (632:15): [True: 0, False: 15.9k]
  |  Branch (632:27): [True: 0, False: 15.9k]
  ------------------
  633|  15.9k|          uint32_t dextra = br.get(dist_extra[dsym]);
  634|  15.9k|          if (dist_extra[dsym] && dextra == UINT32_MAX) return 0;
  ------------------
  |  Branch (634:15): [True: 10.7k, False: 5.16k]
  |  Branch (634:35): [True: 0, False: 10.7k]
  ------------------
  635|  15.9k|          uint32_t distance = dist_base[dsym] + (dist_extra[dsym] ? dextra : 0);
  ------------------
  |  Branch (635:50): [True: 10.7k, False: 5.16k]
  ------------------
  636|  15.9k|          if (distance > out || out + length > dst_cap) return 0;
  ------------------
  |  Branch (636:15): [True: 0, False: 15.9k]
  |  Branch (636:33): [True: 0, False: 15.9k]
  ------------------
  637|   193k|          for (uint32_t k = 0; k < length; k++) {
  ------------------
  |  Branch (637:32): [True: 177k, False: 15.9k]
  ------------------
  638|   177k|            dst[out] = dst[out - distance];
  639|   177k|            out++;
  640|   177k|          }
  641|  15.9k|        }
  642|  54.4k|      }
  643|      4|    } else {
  644|      0|      return 0;  // reserved
  645|      0|    }
  646|      4|    if (bfinal) break;
  ------------------
  |  Branch (646:9): [True: 1, False: 3]
  ------------------
  647|      4|  }
  648|      1|  return out;
  649|      1|}
_ZN3ada4idna7deflate9BitReaderC2EPKhm:
  392|      1|      : p(data), end(data + len) {}
_ZN3ada4idna7deflate9BitReader3getEi:
  402|   475k|  uint32_t get(int n) {
  403|   475k|    if (!ensure(n)) return UINT32_MAX;
  ------------------
  |  Branch (403:9): [True: 0, False: 475k]
  ------------------
  404|   475k|    uint32_t v = acc & ((1u << n) - 1);
  405|   475k|    acc >>= n;
  406|   475k|    bits -= n;
  407|   475k|    return v;
  408|   475k|  }
_ZN3ada4idna7deflate9BitReader6ensureEi:
  394|   475k|  bool ensure(int n) {
  395|   540k|    while (bits < n) {
  ------------------
  |  Branch (395:12): [True: 65.3k, False: 475k]
  ------------------
  396|  65.3k|      if (p >= end) return false;
  ------------------
  |  Branch (396:11): [True: 0, False: 65.3k]
  ------------------
  397|  65.3k|      acc |= uint32_t(*p++) << bits;
  398|  65.3k|      bits += 8;
  399|  65.3k|    }
  400|   475k|    return true;
  401|   475k|  }
_ZNK3ada4idna7deflate4Huff6decodeERNS1_9BitReaderE:
  461|  71.4k|  int decode(BitReader& br) const {
  462|  71.4k|    if (max_bits == 0) return -1;
  ------------------
  |  Branch (462:9): [True: 0, False: 71.4k]
  ------------------
  463|  71.4k|    int code = 0;
  464|   442k|    for (int len = 1; len <= max_bits; len++) {
  ------------------
  |  Branch (464:23): [True: 442k, False: 0]
  ------------------
  465|   442k|      uint32_t b = br.get(1);
  466|   442k|      if (b == UINT32_MAX) return -1;
  ------------------
  |  Branch (466:11): [True: 0, False: 442k]
  ------------------
  467|   442k|      code = (code << 1) | int(b);
  468|   442k|      int first = first_code[len];
  469|   442k|      int cnt = counts[len];
  470|   442k|      if (cnt && code - first < cnt) {
  ------------------
  |  Branch (470:11): [True: 276k, False: 166k]
  |  Branch (470:18): [True: 71.4k, False: 205k]
  ------------------
  471|  71.4k|        return symbols[base_idx[len] + (code - first)];
  472|  71.4k|      }
  473|   442k|    }
  474|      0|    return -1;
  475|  71.4k|  }
_ZN3ada4idna10crc32_ieeeEPKhm:
 5068|      1|                                         size_t len) noexcept {
 5069|      1|  uint32_t c = 0xFFFFFFFFu;
 5070|   216k|  for (size_t i = 0; i < len; ++i) {
  ------------------
  |  Branch (5070:22): [True: 216k, False: 1]
  ------------------
 5071|   216k|    c ^= data[i];
 5072|  1.94M|    for (int k = 0; k < 8; ++k) {
  ------------------
  |  Branch (5072:21): [True: 1.72M, False: 216k]
  ------------------
 5073|  1.72M|      const uint32_t mask = 0u - (c & 1u);
 5074|  1.72M|      c = (c >> 1) ^ (0xEDB88320u & mask);
 5075|  1.72M|    }
 5076|   216k|  }
 5077|      1|  return ~c;
 5078|      1|}
_ZN3ada4idna6detail33convert_table_blob_to_host_endianEPh:
 4873|      1|inline void convert_table_blob_to_host_endian(uint8_t* buffer) noexcept {
 4874|      1|  if constexpr (std::endian::native == std::endian::little) {
 4875|      1|    (void)buffer;
 4876|      1|    return;
 4877|      1|  }
 4878|      0|  auto u16 = [&](size_t off, size_t count) {
 4879|      1|    bswap_inplace(reinterpret_cast<uint16_t*>(buffer + off), count);
 4880|      1|  };
 4881|      1|  auto u32 = [&](size_t off, size_t count) {
 4882|      1|    bswap_inplace(reinterpret_cast<uint32_t*>(buffer + off), count);
 4883|      1|  };
 4884|      1|  auto u64 = [&](size_t off, size_t count) {
 4885|      1|    bswap_inplace(reinterpret_cast<uint64_t*>(buffer + off), count);
 4886|      1|  };
 4887|       |
 4888|      1|  u16(table_blob::off_idna_stage1, table_blob::count_idna_stage1);
 4889|      1|  u16(table_blob::off_idna_stage2, table_blob::count_idna_stage2);
 4890|      1|  u64(table_blob::off_idna_bool_blocks, table_blob::count_idna_bool_blocks);
 4891|      1|  u16(table_blob::off_decomposition_block,
 4892|      1|      table_blob::count_decomposition_block);
 4893|      1|  u32(table_blob::off_decomposition_data, table_blob::count_decomposition_data);
 4894|      1|  u16(table_blob::off_composition_block, table_blob::count_composition_block);
 4895|      1|  u32(table_blob::off_composition_data, table_blob::count_composition_data);
 4896|      1|  u32(table_blob::off_id_continue_flat, table_blob::count_id_continue_flat);
 4897|      1|  u32(table_blob::off_id_start_flat, table_blob::count_id_start_flat);
 4898|      1|  u32(table_blob::off_dir_start, table_blob::count_dir_start);
 4899|      1|  u32(table_blob::off_dir_final, table_blob::count_dir_final);
 4900|      1|  u32(table_blob::off_combining_flat, table_blob::count_combining_flat);
 4901|      1|  u32(table_blob::off_joining_start, table_blob::count_joining_start);
 4902|      1|  u32(table_blob::off_joining_final, table_blob::count_joining_final);
 4903|      1|}
_ZZN3ada4idna13ensure_tablesEvENKUlmE_clEm:
 5117|     21|    auto at = [&](size_t off) noexcept -> const uint8_t* {
 5118|     21|      return buffer + off;
 5119|     21|    };
can_parse.cc:_ZN3ada4idnaL11idna_lookupEj:
 5277|   690k|static uint16_t idna_lookup(uint32_t cp) noexcept {
 5278|   690k|  if (cp < IDNA_LOW_RANGE_END) {
  ------------------
  |  Branch (5278:7): [True: 688k, False: 2.31k]
  ------------------
 5279|   688k|    uint16_t ref = idna_stage1[cp >> IDNA_BLOCK_BITS];
 5280|   688k|    if (ref & IDNA_BOOL_FLAG) {
  ------------------
  |  Branch (5280:9): [True: 300k, False: 388k]
  ------------------
 5281|   300k|      uint32_t bit_idx =
 5282|   300k|          static_cast<uint32_t>(ref & ~IDNA_BOOL_FLAG) * IDNA_BLOCK_SIZE +
 5283|   300k|          (cp & IDNA_BLOCK_MASK);
 5284|   300k|      bool is_valid = (idna_bool_blocks[bit_idx >> 6] >> (bit_idx & 63u)) & 1u;
 5285|   300k|      return is_valid ? IDNA_VALID : IDNA_DISALLOWED;
  ------------------
  |  Branch (5285:14): [True: 300k, False: 39]
  ------------------
 5286|   300k|    }
 5287|   388k|    return idna_stage2[ref + (cp & IDNA_BLOCK_MASK)];
 5288|   688k|  }
 5289|       |
 5290|  2.31k|  if (cp >= IDNA_HIGH_IGNORED_START && cp < IDNA_HIGH_IGNORED_END) {
  ------------------
  |  Branch (5290:7): [True: 2.25k, False: 54]
  |  Branch (5290:40): [True: 1.96k, False: 291]
  ------------------
 5291|  1.96k|    return IDNA_IGNORED;
 5292|  1.96k|  }
 5293|       |
 5294|    345|  return IDNA_DISALLOWED;
 5295|  2.31k|}
can_parse.cc:_ZN3ada4idnaL21utf8_count_codepointsEPKh:
 5320|   103k|static size_t utf8_count_codepoints(const uint8_t* ptr) noexcept {
 5321|   103k|  size_t n = 0;
 5322|   518k|  while (*ptr != 0) {
  ------------------
  |  Branch (5322:10): [True: 415k, False: 103k]
  ------------------
 5323|   415k|    ++n;
 5324|   415k|    if (*ptr < 0x80u) {
  ------------------
  |  Branch (5324:9): [True: 107k, False: 308k]
  ------------------
 5325|   107k|      ++ptr;
 5326|   308k|    } else if (*ptr < 0xE0u) {
  ------------------
  |  Branch (5326:16): [True: 185k, False: 123k]
  ------------------
 5327|   185k|      ptr += 2;
 5328|   185k|    } else if (*ptr < 0xF0u) {
  ------------------
  |  Branch (5328:16): [True: 121k, False: 1.68k]
  ------------------
 5329|   121k|      ptr += 3;
 5330|   121k|    } else {
 5331|  1.68k|      ptr += 4;
 5332|  1.68k|    }
 5333|   415k|  }
 5334|   103k|  return n;
 5335|   103k|}
can_parse.cc:_ZN3ada4idnaL9utf8_nextERPKh:
 5298|   413k|static char32_t utf8_next(const uint8_t*& ptr) noexcept {
 5299|   413k|  uint8_t b0 = *ptr++;
 5300|   413k|  if (b0 < 0x80u) return static_cast<char32_t>(b0);
  ------------------
  |  Branch (5300:7): [True: 107k, False: 306k]
  ------------------
 5301|   306k|  if (b0 < 0xE0u) {
  ------------------
  |  Branch (5301:7): [True: 185k, False: 121k]
  ------------------
 5302|   185k|    uint32_t cp = (b0 & 0x1Fu) << 6;
 5303|   185k|    cp |= (*ptr++ & 0x3Fu);
 5304|   185k|    return static_cast<char32_t>(cp);
 5305|   185k|  }
 5306|   121k|  if (b0 < 0xF0u) {
  ------------------
  |  Branch (5306:7): [True: 119k, False: 1.68k]
  ------------------
 5307|   119k|    uint32_t cp = (b0 & 0x0Fu) << 12;
 5308|   119k|    cp |= ((*ptr++ & 0x3Fu) << 6);
 5309|   119k|    cp |= (*ptr++ & 0x3Fu);
 5310|   119k|    return static_cast<char32_t>(cp);
 5311|   119k|  }
 5312|  1.68k|  uint32_t cp = (b0 & 0x07u) << 18;
 5313|  1.68k|  cp |= ((*ptr++ & 0x3Fu) << 12);
 5314|  1.68k|  cp |= ((*ptr++ & 0x3Fu) << 6);
 5315|  1.68k|  cp |= (*ptr++ & 0x3Fu);
 5316|  1.68k|  return static_cast<char32_t>(cp);
 5317|   121k|}
_ZN3ada4idna23decomposition_block_rowEh:
 5194|  1.06M|inline const uint16_t* decomposition_block_row(uint8_t bi) noexcept {
 5195|  1.06M|  if (bi >= kDecompBlockRows) {
  ------------------
  |  Branch (5195:7): [True: 0, False: 1.06M]
  ------------------
 5196|      0|    bi = 0;
 5197|      0|  }
 5198|  1.06M|  return decomposition_block_flat + static_cast<size_t>(bi) * kDecompBlockCols;
 5199|  1.06M|}
_ZN3ada4idna13ccc_block_rowEh:
 5201|  1.56M|inline const uint8_t* ccc_block_row(uint8_t bi) noexcept {
 5202|  1.56M|  if (bi >= kCccBlockRows) {
  ------------------
  |  Branch (5202:7): [True: 0, False: 1.56M]
  ------------------
 5203|      0|    bi = 0;
 5204|      0|  }
 5205|  1.56M|  return ccc_block_flat + static_cast<size_t>(bi) * kCccBlockCols;
 5206|  1.56M|}
_ZN3ada4idna16tables_are_readyEv:
 5080|  21.1k|[[nodiscard]] inline bool tables_are_ready() noexcept {
 5081|  21.1k|  return tables_init_state.load(std::memory_order_acquire) == kTablesReady;
 5082|  21.1k|}
can_parse.cc:_ZN3ada4idnaL24decomposition_is_not_nfcEDiDi:
 5707|   483k|static bool decomposition_is_not_nfc(char32_t previous, char32_t c) noexcept {
 5708|   483k|  if (c >= hangul_sbase && c < hangul_sbase + hangul_scount) {
  ------------------
  |  Branch (5708:7): [True: 21.1k, False: 462k]
  |  Branch (5708:28): [True: 12.7k, False: 8.43k]
  ------------------
 5709|  12.7k|    return false;
 5710|  12.7k|  }
 5711|   470k|  if (c >= 0x110000) {
  ------------------
  |  Branch (5711:7): [True: 0, False: 470k]
  ------------------
 5712|      0|    return false;
 5713|      0|  }
 5714|   470k|  const uint16_t* const decomposition =
 5715|   470k|      decomposition_block_row(decomposition_index[c >> 8]) + (c % 256);
 5716|   470k|  const size_t length = (decomposition[1] >> 2) - (decomposition[0] >> 2);
 5717|   470k|  if (length == 0 || (decomposition[0] & 1)) {
  ------------------
  |  Branch (5717:7): [True: 437k, False: 33.0k]
  |  Branch (5717:22): [True: 0, False: 33.0k]
  ------------------
 5718|   437k|    return false;  // no canonical decomposition (or compatibility-only)
 5719|   437k|  }
 5720|  33.0k|  if (length == 1) {
  ------------------
  |  Branch (5720:7): [True: 0, False: 33.0k]
  ------------------
 5721|      0|    return true;  // singleton
 5722|      0|  }
 5723|  33.0k|  const size_t base = decomposition[0] >> 2;
 5724|  33.0k|  if (base + length > decomposition_data_size) {
  ------------------
  |  Branch (5724:7): [True: 0, False: 33.0k]
  ------------------
 5725|      0|    return false;
 5726|      0|  }
 5727|       |  // Recompose the canonical decomposition; if it does not collapse back to c,
 5728|       |  // then c is an exclusion / non-starter decomposition and is not NFC.
 5729|  33.0k|  std::u32string decomposed(decomposition_data + base,
 5730|  33.0k|                            decomposition_data + base + length);
 5731|  33.0k|  compose(decomposed);
 5732|  33.0k|  if (!(decomposed.size() == 1 && decomposed[0] == c)) {
  ------------------
  |  Branch (5732:9): [True: 33.0k, False: 0]
  |  Branch (5732:35): [True: 33.0k, False: 0]
  ------------------
 5733|      0|    return true;
 5734|      0|  }
 5735|  33.0k|  return previous < 0x110000 &&
  ------------------
  |  Branch (5735:10): [True: 25.0k, False: 7.92k]
  ------------------
 5736|  25.0k|         has_composition(
  ------------------
  |  Branch (5736:10): [True: 30, False: 25.0k]
  ------------------
 5737|  25.0k|             composition_block_row(composition_index[previous >> 8]) +
 5738|  25.0k|                 (previous % 256),
 5739|  25.0k|             decomposition_data[base]);
 5740|  33.0k|}
can_parse.cc:_ZN3ada4idnaL15has_compositionEPKtDi:
 5611|   114k|                            char32_t second) noexcept {
 5612|   114k|  int left = composition[0];
 5613|   114k|  int right = composition[1];
 5614|   114k|  if (left < 0 || right <= left ||
  ------------------
  |  Branch (5614:7): [True: 0, False: 114k]
  |  Branch (5614:19): [True: 20.3k, False: 94.5k]
  ------------------
 5615|  94.5k|      static_cast<size_t>(right) > composition_data_size) {
  ------------------
  |  Branch (5615:7): [True: 0, False: 94.5k]
  ------------------
 5616|  20.3k|    return false;
 5617|  20.3k|  }
 5618|   260k|  while (left + 2 < right) {
  ------------------
  |  Branch (5618:10): [True: 165k, False: 94.5k]
  ------------------
 5619|   165k|    int middle = left + (((right - left) >> 1) & ~1);
 5620|   165k|    if (composition_data[static_cast<size_t>(middle)] <= second) {
  ------------------
  |  Branch (5620:9): [True: 11.1k, False: 154k]
  ------------------
 5621|  11.1k|      left = middle;
 5622|  11.1k|    }
 5623|   165k|    if (composition_data[static_cast<size_t>(middle)] >= second) {
  ------------------
  |  Branch (5623:9): [True: 155k, False: 9.72k]
  ------------------
 5624|   155k|      right = middle;
 5625|   155k|    }
 5626|   165k|  }
 5627|  94.5k|  return static_cast<size_t>(left + 1) < composition_data_size &&
  ------------------
  |  Branch (5627:10): [True: 94.5k, False: 0]
  ------------------
 5628|  94.5k|         composition_data[static_cast<size_t>(left)] == second;
  ------------------
  |  Branch (5628:10): [True: 1.92k, False: 92.6k]
  ------------------
 5629|   114k|}
can_parse.cc:_ZN3ada4idnaL12trailing_cccEDi:
 5684|   455k|static uint8_t trailing_ccc(char32_t c) noexcept {
 5685|   455k|  const size_t length = canonical_decomp_length(c);
 5686|   455k|  if (length == 0) {
  ------------------
  |  Branch (5686:7): [True: 426k, False: 29.5k]
  ------------------
 5687|   426k|    return get_ccc(c);
 5688|   426k|  }
 5689|  29.5k|  const uint16_t* const decomposition =
 5690|  29.5k|      decomposition_block_row(decomposition_index[c >> 8]) + (c % 256);
 5691|  29.5k|  const size_t base = decomposition[0] >> 2;
 5692|  29.5k|  return get_ccc(decomposition_data[base + length - 1]);
 5693|   455k|}
can_parse.cc:_ZN3ada4idnaL23canonical_decomp_lengthEDi:
 5478|   455k|static size_t canonical_decomp_length(char32_t current_character) noexcept {
 5479|   455k|  if (current_character >= hangul_sbase &&
  ------------------
  |  Branch (5479:7): [True: 15.9k, False: 439k]
  ------------------
 5480|  15.9k|      current_character < hangul_sbase + hangul_scount) {
  ------------------
  |  Branch (5480:7): [True: 8.87k, False: 7.07k]
  ------------------
 5481|       |    // Hangul precomposed syllables are NFC.
 5482|  8.87k|    return 0;
 5483|  8.87k|  }
 5484|   447k|  if (current_character >= 0x110000) {
  ------------------
  |  Branch (5484:7): [True: 0, False: 447k]
  ------------------
 5485|      0|    return 0;
 5486|      0|  }
 5487|   447k|  const uint8_t di = decomposition_index[current_character >> 8];
 5488|   447k|  const uint16_t* const decomposition =
 5489|   447k|      decomposition_block_row(di) + (current_character % 256);
 5490|   447k|  size_t decomposition_length =
 5491|   447k|      (decomposition[1] >> 2) - (decomposition[0] >> 2);
 5492|   447k|  if ((decomposition_length > 0) && (decomposition[0] & 1)) {
  ------------------
  |  Branch (5492:7): [True: 29.5k, False: 417k]
  |  Branch (5492:37): [True: 0, False: 29.5k]
  ------------------
 5493|      0|    decomposition_length = 0;  // compatibility-only: ignored for NFC
 5494|      0|  }
 5495|   447k|  return decomposition_length;
 5496|   447k|}
can_parse.cc:_ZN3ada4idnaL13would_composeENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 5632|  12.1k|static bool would_compose(std::u32string_view input) noexcept {
 5633|   405k|  for (size_t input_count = 0; input_count < input.size();) {
  ------------------
  |  Branch (5633:32): [True: 395k, False: 9.84k]
  ------------------
 5634|   395k|    const char32_t current = input[input_count];
 5635|   395k|    if (current >= hangul_lbase && current < hangul_lbase + hangul_lcount) {
  ------------------
  |  Branch (5635:9): [True: 142k, False: 253k]
  |  Branch (5635:36): [True: 6.95k, False: 135k]
  ------------------
 5636|  6.95k|      if (input_count + 1 < input.size() &&
  ------------------
  |  Branch (5636:11): [True: 6.71k, False: 237]
  ------------------
 5637|  6.71k|          input[input_count + 1] >= hangul_vbase &&
  ------------------
  |  Branch (5637:11): [True: 1.61k, False: 5.10k]
  ------------------
 5638|  1.61k|          input[input_count + 1] < hangul_vbase + hangul_vcount) {
  ------------------
  |  Branch (5638:11): [True: 300, False: 1.31k]
  ------------------
 5639|    300|        return true;
 5640|    300|      }
 5641|  6.65k|      ++input_count;
 5642|  6.65k|      continue;
 5643|  6.95k|    }
 5644|   388k|    if (current >= hangul_sbase && current < hangul_sbase + hangul_scount) {
  ------------------
  |  Branch (5644:9): [True: 8.22k, False: 380k]
  |  Branch (5644:36): [True: 4.42k, False: 3.79k]
  ------------------
 5645|  4.42k|      if ((current - hangul_sbase) % hangul_tcount == 0 &&
  ------------------
  |  Branch (5645:11): [True: 2.77k, False: 1.65k]
  ------------------
 5646|  2.77k|          input_count + 1 < input.size() &&
  ------------------
  |  Branch (5646:11): [True: 2.66k, False: 111]
  ------------------
 5647|  2.66k|          input[input_count + 1] > hangul_tbase &&
  ------------------
  |  Branch (5647:11): [True: 2.03k, False: 630]
  ------------------
 5648|  2.03k|          input[input_count + 1] < hangul_tbase + hangul_tcount) {
  ------------------
  |  Branch (5648:11): [True: 120, False: 1.91k]
  ------------------
 5649|    120|        return true;
 5650|    120|      }
 5651|  4.30k|      ++input_count;
 5652|  4.30k|      continue;
 5653|  4.42k|    }
 5654|   384k|    if (current < 0x110000) {
  ------------------
  |  Branch (5654:9): [True: 384k, False: 0]
  ------------------
 5655|   384k|      const uint16_t* composition =
 5656|   384k|          composition_block_row(composition_index[current >> 8]) +
 5657|   384k|          (current % 256);
 5658|   384k|      int32_t previous_ccc = -1;
 5659|   384k|      size_t j = input_count;
 5660|   392k|      for (; j + 1 < input.size(); ++j) {
  ------------------
  |  Branch (5660:14): [True: 383k, False: 9.39k]
  ------------------
 5661|   383k|        uint8_t ccc = get_ccc(input[j + 1]);
 5662|   383k|        if (composition[1] != composition[0] && previous_ccc < ccc &&
  ------------------
  |  Branch (5662:13): [True: 93.7k, False: 289k]
  |  Branch (5662:49): [True: 89.8k, False: 3.88k]
  ------------------
 5663|  89.8k|            has_composition(composition, input[j + 1])) {
  ------------------
  |  Branch (5663:13): [True: 1.89k, False: 87.9k]
  ------------------
 5664|  1.89k|          return true;
 5665|  1.89k|        }
 5666|   381k|        if (ccc == 0) {
  ------------------
  |  Branch (5666:13): [True: 373k, False: 8.30k]
  ------------------
 5667|   373k|          break;
 5668|   373k|        }
 5669|  8.30k|        previous_ccc = ccc;
 5670|  8.30k|      }
 5671|   382k|      input_count = j + 1;
 5672|   382k|      continue;
 5673|   384k|    }
 5674|      0|    ++input_count;
 5675|      0|  }
 5676|  9.84k|  return false;
 5677|  12.1k|}
_ZN3ada4idna21composition_block_rowEh:
 5208|   560k|inline const uint16_t* composition_block_row(uint8_t bi) noexcept {
 5209|   560k|  if (bi >= kCompBlockRows) {
  ------------------
  |  Branch (5209:7): [True: 0, False: 560k]
  ------------------
 5210|      0|    bi = 0;
 5211|      0|  }
 5212|   560k|  return composition_block_flat + static_cast<size_t>(bi) * kCompBlockCols;
 5213|   560k|}
can_parse.cc:_ZN3ada4idnaL19char_to_digit_valueEc:
 5913|  93.3k|static constexpr int32_t char_to_digit_value(char value) {
 5914|  93.3k|  if (value >= 'a' && value <= 'z') return value - 'a';
  ------------------
  |  Branch (5914:7): [True: 82.8k, False: 10.4k]
  |  Branch (5914:23): [True: 82.8k, False: 15]
  ------------------
 5915|  10.5k|  if (value >= '0' && value <= '9') return value - '0' + 26;
  ------------------
  |  Branch (5915:7): [True: 10.4k, False: 54]
  |  Branch (5915:23): [True: 10.4k, False: 15]
  ------------------
 5916|     69|  return -1;
 5917|  10.5k|}
can_parse.cc:_ZN3ada4idnaL5adaptEiib:
 5923|   207k|static constexpr int32_t adapt(int32_t d, int32_t n, bool firsttime) {
 5924|   207k|  if (firsttime) {
  ------------------
  |  Branch (5924:7): [True: 41.8k, False: 165k]
  ------------------
 5925|  41.8k|    d = d / damp;
 5926|   165k|  } else {
 5927|   165k|    d = d / 2;
 5928|   165k|  }
 5929|   207k|  d += d / n;
 5930|   207k|  int32_t k = 0;
 5931|   292k|  while (d > ((base - tmin) * tmax) / 2) {
  ------------------
  |  Branch (5931:10): [True: 85.2k, False: 207k]
  ------------------
 5932|  85.2k|    d /= base - tmin;
 5933|  85.2k|    k += base;
 5934|  85.2k|  }
 5935|   207k|  return k + (((base - tmin + 1) * d) / (d + skew));
 5936|   207k|}
can_parse.cc:_ZN3ada4idnaL13digit_to_charEi:
 5919|   404k|static constexpr char digit_to_char(int32_t digit) {
 5920|   404k|  return digit < 26 ? char(digit + 97) : char(digit + 22);
  ------------------
  |  Branch (5920:10): [True: 275k, False: 128k]
  ------------------
 5921|   404k|}
can_parse.cc:_ZZN3ada4idna14is_label_validENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEEENK3$_0clIA2_jEEDaRKT_:
 6327|   345k|      comb_span, label.front(), {}, [](const auto& range) { return range[1]; });
can_parse.cc:_ZN3ada4idnaL17is_contextj_validENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 6232|  41.9k|inline static bool is_contextj_valid(std::u32string_view label) noexcept {
 6233|  41.9k|  constexpr uint8_t virama_ccc = 9;
 6234|   302k|  for (size_t i = 0; i < label.size(); i++) {
  ------------------
  |  Branch (6234:22): [True: 260k, False: 41.4k]
  ------------------
 6235|   260k|    if (label[i] != 0x200C && label[i] != 0x200D) {
  ------------------
  |  Branch (6235:9): [True: 259k, False: 1.47k]
  |  Branch (6235:31): [True: 258k, False: 360]
  ------------------
 6236|   258k|      continue;
 6237|   258k|    }
 6238|       |    // If Canonical_Combining_Class(Before(cp)) .eq. Virama Then True;
 6239|  1.83k|    if (i > 0 && get_ccc(label[i - 1]) == virama_ccc) {
  ------------------
  |  Branch (6239:9): [True: 1.81k, False: 18]
  |  Branch (6239:18): [True: 381, False: 1.43k]
  ------------------
 6240|    381|      continue;
 6241|    381|    }
 6242|  1.45k|    if (label[i] == 0x200D) {
  ------------------
  |  Branch (6242:9): [True: 39, False: 1.41k]
  ------------------
 6243|     39|      return false;
 6244|     39|    }
 6245|       |    // If RegExpMatch((Joining_Type:{L,D})(Joining_Type:T)*\u200C
 6246|       |    //    (Joining_Type:T)*(Joining_Type:{R,D})) Then True;
 6247|  1.41k|    joining_type before = joining_type::U;
 6248|  2.32k|    for (size_t j = i; j > 0;) {
  ------------------
  |  Branch (6248:24): [True: 2.31k, False: 18]
  ------------------
 6249|  2.31k|      before = find_joining_type(label[--j]);
 6250|  2.31k|      if (before != joining_type::T) {
  ------------------
  |  Branch (6250:11): [True: 1.39k, False: 912]
  ------------------
 6251|  1.39k|        break;
 6252|  1.39k|      }
 6253|  2.31k|    }
 6254|  1.41k|    if (before != joining_type::L && before != joining_type::D) {
  ------------------
  |  Branch (6254:9): [True: 1.34k, False: 75]
  |  Branch (6254:38): [True: 177, False: 1.16k]
  ------------------
 6255|    177|      return false;
 6256|    177|    }
 6257|  1.23k|    joining_type after = joining_type::U;
 6258|  2.75k|    for (size_t j = i + 1; j < label.size(); j++) {
  ------------------
  |  Branch (6258:28): [True: 2.63k, False: 120]
  ------------------
 6259|  2.63k|      after = find_joining_type(label[j]);
 6260|  2.63k|      if (after != joining_type::T) {
  ------------------
  |  Branch (6260:11): [True: 1.11k, False: 1.51k]
  ------------------
 6261|  1.11k|        break;
 6262|  1.11k|      }
 6263|  2.63k|    }
 6264|  1.23k|    if (after != joining_type::R && after != joining_type::D) {
  ------------------
  |  Branch (6264:9): [True: 1.02k, False: 219]
  |  Branch (6264:37): [True: 261, False: 759]
  ------------------
 6265|    261|      return false;
 6266|    261|    }
 6267|  1.23k|  }
 6268|  41.4k|  return true;
 6269|  41.9k|}
can_parse.cc:_ZN3ada4idnaL17find_joining_typeEj:
 6224|  4.94k|inline static joining_type find_joining_type(uint32_t code_point) noexcept {
 6225|  4.94k|  size_t i =
 6226|  4.94k|      find_range(joining_start, joining_final, joining_table_count, code_point);
 6227|  4.94k|  return i == joining_table_count ? joining_type::U
  ------------------
  |  Branch (6227:10): [True: 297, False: 4.65k]
  ------------------
 6228|  4.94k|                                  : static_cast<joining_type>(joining_value[i]);
 6229|  4.94k|}
can_parse.cc:_ZN3ada4idnaL10find_rangeEPKjS2_mj:
 6203|   364k|                                size_t count, uint32_t code_point) noexcept {
 6204|   364k|  size_t lo = 0, hi = count;
 6205|  4.29M|  while (lo < hi) {
  ------------------
  |  Branch (6205:10): [True: 3.93M, False: 364k]
  ------------------
 6206|  3.93M|    size_t mid = lo + (hi - lo) / 2;
 6207|  3.93M|    if (last[mid] < code_point) {
  ------------------
  |  Branch (6207:9): [True: 1.39M, False: 2.53M]
  ------------------
 6208|  1.39M|      lo = mid + 1;
 6209|  2.53M|    } else {
 6210|  2.53M|      hi = mid;
 6211|  2.53M|    }
 6212|  3.93M|  }
 6213|   364k|  return lo < count && code_point >= start[lo] ? lo : count;
  ------------------
  |  Branch (6213:10): [True: 364k, False: 0]
  |  Branch (6213:24): [True: 364k, False: 297]
  ------------------
 6214|   364k|}
can_parse.cc:_ZN3ada4idnaL20find_last_not_of_nsmENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 6272|  41.4k|    const std::u32string_view label) noexcept {
 6273|  49.4k|  for (int i = static_cast<int>(label.size() - 1); i >= 0; i--)
  ------------------
  |  Branch (6273:52): [True: 49.4k, False: 0]
  ------------------
 6274|  49.4k|    if (find_direction(label[i]) != direction::NSM) return i;
  ------------------
  |  Branch (6274:9): [True: 41.4k, False: 8.06k]
  ------------------
 6275|       |
 6276|      0|  return std::u32string_view::npos;
 6277|  41.4k|}
can_parse.cc:_ZN3ada4idnaL12is_rtl_labelENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 6281|  41.4k|inline static bool is_rtl_label(const std::u32string_view label) noexcept {
 6282|  41.4k|  const size_t mask =
 6283|  41.4k|      (1u << direction::R) | (1u << direction::AL) | (1u << direction::AN);
 6284|       |
 6285|  41.4k|  size_t directions = 0;
 6286|   299k|  for (size_t i = 0; i < label.size(); i++) {
  ------------------
  |  Branch (6286:22): [True: 257k, False: 41.4k]
  ------------------
 6287|   257k|    directions |= 1u << find_direction(label[i]);
 6288|   257k|  }
 6289|  41.4k|  return (directions & mask) != 0;
 6290|  41.4k|}
can_parse.cc:_ZN3ada4idnaL14find_directionEj:
 6217|   359k|inline static direction find_direction(uint32_t code_point) noexcept {
 6218|   359k|  size_t i = find_range(dir_start, dir_final, dir_table_count, code_point);
 6219|   359k|  return i == dir_table_count ? direction::NONE
  ------------------
  |  Branch (6219:10): [True: 0, False: 359k]
  ------------------
 6220|   359k|                              : static_cast<direction>(dir_value[i]);
 6221|   359k|}
_ZN3ada4idna8is_asciiENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 6552|  19.5k|bool constexpr is_ascii(std::string_view view) {
 6553|   492k|  for (uint8_t c : view) {
  ------------------
  |  Branch (6553:18): [True: 492k, False: 6.28k]
  ------------------
 6554|   492k|    if (c >= 0x80) {
  ------------------
  |  Branch (6554:9): [True: 13.2k, False: 479k]
  ------------------
 6555|  13.2k|      return false;
 6556|  13.2k|    }
 6557|   492k|  }
 6558|  6.28k|  return true;
 6559|  19.5k|}
can_parse.cc:_ZN3ada4idnaL19from_ascii_to_asciiENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEERNS1_12basic_stringIcS4_NS1_9allocatorIcEEEE:
 6589|  6.28k|static void from_ascii_to_ascii(std::string_view ut8_string, std::string& out) {
 6590|  6.28k|  out.assign(ut8_string);
 6591|  6.28k|  ascii_map(out.data(), out.size());
 6592|  6.28k|}
_ZN3ada4idna8is_asciiENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 6543|  67.2k|bool constexpr is_ascii(std::u32string_view view) {
 6544|   245k|  for (uint32_t c : view) {
  ------------------
  |  Branch (6544:19): [True: 245k, False: 8.51k]
  ------------------
 6545|   245k|    if (c >= 0x80) {
  ------------------
  |  Branch (6545:9): [True: 58.7k, False: 187k]
  ------------------
 6546|  58.7k|      return false;
 6547|  58.7k|    }
 6548|   245k|  }
 6549|  8.51k|  return true;
 6550|  67.2k|}
can_parse.cc:_ZN3ada4idnaL13is_ace_prefixENSt3__117basic_string_viewIDiNS1_11char_traitsIDiEEEE:
 6605|  49.2k|static bool is_ace_prefix(std::u32string_view label) noexcept {
 6606|  49.2k|  return label.size() >= 4 && label[0] == U'x' && label[1] == U'n' &&
  ------------------
  |  Branch (6606:10): [True: 37.0k, False: 12.1k]
  |  Branch (6606:31): [True: 9.58k, False: 27.4k]
  |  Branch (6606:51): [True: 8.74k, False: 840]
  ------------------
 6607|  8.74k|         label[2] == U'-' && label[3] == U'-';
  ------------------
  |  Branch (6607:10): [True: 8.21k, False: 528]
  |  Branch (6607:30): [True: 7.70k, False: 510]
  ------------------
 6608|  49.2k|}
can_parse.cc:_ZN3ada4idnaL18append_ascii_labelERNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS1_17basic_string_viewIDiNS3_IDiEEEE:
 6595|  12.9k|static void append_ascii_label(std::string& out, std::u32string_view label) {
 6596|  12.9k|  const size_t old = out.size();
 6597|  12.9k|  out.resize(old + label.size());
 6598|  12.9k|  char* dest = out.data() + old;
 6599|   173k|  for (char32_t c : label) {
  ------------------
  |  Branch (6599:19): [True: 173k, False: 12.9k]
  ------------------
 6600|   173k|    *dest++ = static_cast<char>(c);
 6601|   173k|  }
 6602|  12.9k|}
_ZZN3ada7unicode14percent_encodeILb1EEEbNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEPKhRNS2_12basic_stringIcS5_NS2_9allocatorIcEEEEENKUlcE_clEc:
 7620|  67.4k|  auto pointer = std::ranges::find_if(input, [character_set](const char c) {
 7621|  67.4k|    return character_sets::bit_at(character_set, c);
 7622|  67.4k|  });
_ZN3ada7unicode18is_ascii_hex_digitEc:
 7354|  22.9k|ada_really_inline constexpr bool is_ascii_hex_digit(const char c) noexcept {
 7355|  22.9k|  return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') ||
  ------------------
  |  Branch (7355:11): [True: 15.5k, False: 7.40k]
  |  Branch (7355:23): [True: 9.70k, False: 5.82k]
  |  Branch (7355:37): [True: 5.76k, False: 7.47k]
  |  Branch (7355:49): [True: 2.87k, False: 2.88k]
  ------------------
 7356|  10.3k|         (c >= 'a' && c <= 'f');
  ------------------
  |  Branch (7356:11): [True: 2.81k, False: 7.53k]
  |  Branch (7356:23): [True: 2.57k, False: 246]
  ------------------
 7357|  22.9k|}
_ZN3ada7unicode21convert_hex_to_binaryEc:
 7444|  12.4k|unsigned constexpr convert_hex_to_binary(const char c) noexcept {
 7445|  12.4k|  return hex_to_binary_table[c - '0'];
 7446|  12.4k|}
can_parse.cc:_ZZN3ada7unicode14percent_encodeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKhENK3$_0clEc:
 7588|   104k|  auto pointer = std::ranges::find_if(input, [character_set](const char c) {
 7589|   104k|    return character_sets::bit_at(character_set, c);
 7590|   104k|  });
_ZN3ada7unicode36contains_forbidden_domain_code_pointEPKcm:
 7281|  14.8k|    const char* input, size_t length) noexcept {
 7282|  14.8k|  size_t i = 0;
 7283|  14.8k|  uint8_t accumulator{};
 7284|   284k|  for (; i + 4 <= length; i += 4) {
  ------------------
  |  Branch (7284:10): [True: 270k, False: 14.8k]
  ------------------
 7285|   270k|    accumulator |= is_forbidden_domain_code_point_table[uint8_t(input[i])];
 7286|   270k|    accumulator |= is_forbidden_domain_code_point_table[uint8_t(input[i + 1])];
 7287|   270k|    accumulator |= is_forbidden_domain_code_point_table[uint8_t(input[i + 2])];
 7288|   270k|    accumulator |= is_forbidden_domain_code_point_table[uint8_t(input[i + 3])];
 7289|   270k|  }
 7290|  38.0k|  for (; i < length; i++) {
  ------------------
  |  Branch (7290:10): [True: 23.1k, False: 14.8k]
  ------------------
 7291|  23.1k|    accumulator |= is_forbidden_domain_code_point_table[uint8_t(input[i])];
 7292|  23.1k|  }
 7293|  14.8k|  return accumulator;
 7294|  14.8k|}
can_parse.cc:_ZN3ada7unicode12_GLOBAL__N_122percent_encode_to_wideEPKcS3_PKhRNSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEE:
 7974|    827|                            const uint8_t character_set[], std::string& out) {
 7975|       |  // Worst case every byte becomes %XX. Avoids realloc while walking windows.
 7976|    827|  out.reserve(out.size() + static_cast<size_t>(end - p) * 3);
 7977|    827|#if ADA_UNICODE_SSSE3
 7978|    827|  const ssse3_percent_tables tables = load_ssse3_percent_tables(character_set);
 7979|    827|  percent_encode_to_ssse3(p, end, character_set, tables, out);
 7980|       |#elif ADA_NEON
 7981|       |  percent_encode_to_neon(p, end, character_set,
 7982|       |                         load_neon_percent_table(character_set), out);
 7983|       |#elif ADA_RVV
 7984|       |  percent_encode_to_rvv(p, end, character_set, out);
 7985|       |#endif
 7986|    827|}
can_parse.cc:_ZN3ada7unicode12_GLOBAL__N_125load_ssse3_percent_tablesEPKh:
 7801|    827|load_ssse3_percent_tables(const uint8_t character_set[]) noexcept {
 7802|    827|  ssse3_percent_tables t{};
 7803|    827|  t.cs_lo = _mm_loadu_si128(reinterpret_cast<const __m128i*>(character_set));
 7804|    827|  t.cs_hi =
 7805|    827|      _mm_loadu_si128(reinterpret_cast<const __m128i*>(character_set + 16));
 7806|       |  // 1 << (0..7), duplicated so pshufb(index & 7) works for every lane.
 7807|    827|  t.pow2 =
 7808|    827|      _mm_setr_epi8(1, 2, 4, 8, 16, 32, 64, -128, 1, 2, 4, 8, 16, 32, 64, -128);
 7809|    827|  t.mask_0f = _mm_set1_epi8(0x0F);
 7810|    827|  t.mask_07 = _mm_set1_epi8(0x07);
 7811|    827|  t.zero = _mm_setzero_si128();
 7812|    827|  return t;
 7813|    827|}
can_parse.cc:_ZN3ada7unicode12_GLOBAL__N_123percent_encode_to_ssse3EPKcS3_PKhRKNS1_20ssse3_percent_tablesERNSt3__112basic_stringIcNS9_11char_traitsIcEENS9_9allocatorIcEEEE:
 7832|    827|    const ssse3_percent_tables& tables, std::string& out) {
 7833|       |  // Pair 16-byte windows so a fully clean 32-byte run is one append.
 7834|  2.77k|  while (p + 32 <= end) {
  ------------------
  |  Branch (7834:10): [True: 1.95k, False: 827]
  ------------------
 7835|  1.95k|    const __m128i word0 = _mm_loadu_si128(reinterpret_cast<const __m128i*>(p));
 7836|  1.95k|    const __m128i word1 =
 7837|  1.95k|        _mm_loadu_si128(reinterpret_cast<const __m128i*>(p + 16));
 7838|  1.95k|    const int mask0 = ssse3_percent_mask(word0, tables);
 7839|  1.95k|    const int mask1 = ssse3_percent_mask(word1, tables);
 7840|  1.95k|    if ((mask0 | mask1) == 0) {
  ------------------
  |  Branch (7840:9): [True: 126, False: 1.82k]
  ------------------
 7841|    126|      out.append(p, 32);
 7842|  1.82k|    } else {
 7843|  1.82k|      if (mask0 == 0) {
  ------------------
  |  Branch (7843:11): [True: 108, False: 1.71k]
  ------------------
 7844|    108|        out.append(p, 16);
 7845|  1.71k|      } else {
 7846|  1.71k|        encode_mask_window(p, static_cast<uint32_t>(mask0), 16, out);
 7847|  1.71k|      }
 7848|  1.82k|      if (mask1 == 0) {
  ------------------
  |  Branch (7848:11): [True: 178, False: 1.64k]
  ------------------
 7849|    178|        out.append(p + 16, 16);
 7850|  1.64k|      } else {
 7851|  1.64k|        encode_mask_window(p + 16, static_cast<uint32_t>(mask1), 16, out);
 7852|  1.64k|      }
 7853|  1.82k|    }
 7854|  1.95k|    p += 32;
 7855|  1.95k|  }
 7856|    827|  if (p + 16 <= end) {
  ------------------
  |  Branch (7856:7): [True: 543, False: 284]
  ------------------
 7857|    543|    const __m128i word = _mm_loadu_si128(reinterpret_cast<const __m128i*>(p));
 7858|    543|    const int mask = ssse3_percent_mask(word, tables);
 7859|    543|    if (mask == 0) {
  ------------------
  |  Branch (7859:9): [True: 49, False: 494]
  ------------------
 7860|     49|      out.append(p, 16);
 7861|    494|    } else {
 7862|    494|      encode_mask_window(p, static_cast<uint32_t>(mask), 16, out);
 7863|    494|    }
 7864|    543|    p += 16;
 7865|    543|  }
 7866|    827|  percent_encode_to_scalar(p, end, character_set, out);
 7867|    827|}
can_parse.cc:_ZN3ada7unicode12_GLOBAL__N_118ssse3_percent_maskEDv2_xRKNS1_20ssse3_percent_tablesE:
 7816|  4.44k|    __m128i word, const ssse3_percent_tables& tables) noexcept {
 7817|  4.44k|  const __m128i idx = _mm_and_si128(_mm_srli_epi16(word, 3), tables.mask_0f);
 7818|  4.44k|  const __m128i lo = _mm_shuffle_epi8(tables.cs_lo, idx);
 7819|  4.44k|  const __m128i hi = _mm_shuffle_epi8(tables.cs_hi, idx);
 7820|       |  // Bytes 0x80-0xFF are signed-negative; select the high half of the bitmap.
 7821|  4.44k|  const __m128i high_byte = _mm_cmpgt_epi8(tables.zero, word);
 7822|  4.44k|  const __m128i cs_byte = _mm_or_si128(_mm_and_si128(hi, high_byte),
 7823|  4.44k|                                       _mm_andnot_si128(high_byte, lo));
 7824|  4.44k|  const __m128i bits =
 7825|  4.44k|      _mm_shuffle_epi8(tables.pow2, _mm_and_si128(word, tables.mask_07));
 7826|  4.44k|  const __m128i hits = _mm_and_si128(cs_byte, bits);
 7827|  4.44k|  return _mm_movemask_epi8(_mm_cmpeq_epi8(hits, tables.zero)) ^ 0xFFFF;
 7828|  4.44k|}
can_parse.cc:_ZN3ada7unicode12_GLOBAL__N_118encode_mask_windowEPKcjmRNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEE:
 7756|  3.86k|                                          size_t width, std::string& out) {
 7757|  3.86k|  uint64_t bits = mask;
 7758|  3.86k|  size_t off = 0;
 7759|  50.2k|  while (bits != 0) {
  ------------------
  |  Branch (7759:10): [True: 46.4k, False: 3.86k]
  ------------------
 7760|  46.4k|    const int zero_run = trailing_zeroes32(static_cast<uint32_t>(bits));
 7761|  46.4k|    if (zero_run != 0) {
  ------------------
  |  Branch (7761:9): [True: 2.99k, False: 43.4k]
  ------------------
 7762|  2.99k|      out.append(p + off, static_cast<size_t>(zero_run));
 7763|  2.99k|    }
 7764|  46.4k|    off += static_cast<size_t>(zero_run);
 7765|  46.4k|    out.append(character_sets::hex + uint8_t(p[off]) * 4, 3);
 7766|  46.4k|    ++off;
 7767|  46.4k|    bits >>= static_cast<unsigned>(zero_run + 1);
 7768|  46.4k|  }
 7769|  3.86k|  if (off < width) {
  ------------------
  |  Branch (7769:7): [True: 1.06k, False: 2.79k]
  ------------------
 7770|  1.06k|    out.append(p + off, width - off);
 7771|  1.06k|  }
 7772|  3.86k|}
can_parse.cc:_ZN3ada7unicode12_GLOBAL__N_117trailing_zeroes32Ej:
 7744|  46.4k|ada_really_inline int trailing_zeroes32(uint32_t input_num) noexcept {
 7745|       |#ifdef ADA_REGULAR_VISUAL_STUDIO
 7746|       |  unsigned long ret;
 7747|       |  _BitScanForward(&ret, input_num);
 7748|       |  return static_cast<int>(ret);
 7749|       |#else
 7750|  46.4k|  return __builtin_ctz(input_num);
 7751|  46.4k|#endif
 7752|  46.4k|}
can_parse.cc:_ZN3ada7unicode12_GLOBAL__N_124percent_encode_to_scalarEPKcS3_PKhRNSt3__112basic_stringIcNS6_11char_traitsIcEENS6_9allocatorIcEEEE:
 7777|    827|                                                std::string& out) {
 7778|  3.37k|  for (; p != end; ++p) {
  ------------------
  |  Branch (7778:10): [True: 2.54k, False: 827]
  ------------------
 7779|  2.54k|    if (character_sets::bit_at(character_set, *p)) {
  ------------------
  |  Branch (7779:9): [True: 1.97k, False: 564]
  ------------------
 7780|  1.97k|      out.append(character_sets::hex + uint8_t(*p) * 4, 3);
 7781|  1.97k|    } else {
 7782|    564|      out += *p;
 7783|    564|    }
 7784|  2.54k|  }
 7785|    827|}
can_parse.cc:_ZN3ada11serializers12_GLOBAL__N_113write_hex_u16EPct:
 8047|  2.37k|ada_really_inline char* write_hex_u16(char* p, uint16_t v) noexcept {
 8048|  2.37k|  static constexpr char kHex[] = "0123456789abcdef";
 8049|  2.37k|  if (v >= 0x1000) {
  ------------------
  |  Branch (8049:7): [True: 252, False: 2.12k]
  ------------------
 8050|    252|    *p++ = kHex[(v >> 12) & 0xf];
 8051|    252|    *p++ = kHex[(v >> 8) & 0xf];
 8052|    252|    *p++ = kHex[(v >> 4) & 0xf];
 8053|    252|    *p++ = kHex[v & 0xf];
 8054|  2.12k|  } else if (v >= 0x100) {
  ------------------
  |  Branch (8054:14): [True: 300, False: 1.82k]
  ------------------
 8055|    300|    *p++ = kHex[(v >> 8) & 0xf];
 8056|    300|    *p++ = kHex[(v >> 4) & 0xf];
 8057|    300|    *p++ = kHex[v & 0xf];
 8058|  1.82k|  } else if (v >= 0x10) {
  ------------------
  |  Branch (8058:14): [True: 333, False: 1.49k]
  ------------------
 8059|    333|    *p++ = kHex[(v >> 4) & 0xf];
 8060|    333|    *p++ = kHex[v & 0xf];
 8061|  1.49k|  } else {
 8062|  1.49k|    *p++ = kHex[v & 0xf];
 8063|  1.49k|  }
 8064|  2.37k|  return p;
 8065|  2.37k|}
can_parse.cc:_ZN3ada11serializers12_GLOBAL__N_18write_u8EPch:
 8033|  17.2k|ada_really_inline char* write_u8(char* p, uint8_t v) noexcept {
 8034|  17.2k|  if (v < 10) {
  ------------------
  |  Branch (8034:7): [True: 14.3k, False: 2.90k]
  ------------------
 8035|  14.3k|    *p++ = static_cast<char>('0' + v);
 8036|  14.3k|  } else if (v < 100) {
  ------------------
  |  Branch (8036:14): [True: 1.20k, False: 1.69k]
  ------------------
 8037|  1.20k|    std::memcpy(p, &digit_pairs[static_cast<size_t>(v) * 2], 2);
 8038|  1.20k|    p += 2;
 8039|  1.69k|  } else {
 8040|  1.69k|    *p++ = static_cast<char>('0' + v / 100);
 8041|  1.69k|    std::memcpy(p, &digit_pairs[static_cast<size_t>(v % 100) * 2], 2);
 8042|  1.69k|    p += 2;
 8043|  1.69k|  }
 8044|  17.2k|  return p;
 8045|  17.2k|}
_ZN3ada7unicode19has_tabs_or_newlineENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 7130|   127k|    std::string_view user_input) noexcept {
 7131|       |  // first check for short strings in which case we do it naively.
 7132|   127k|  if (user_input.size() < 16) {  // slow path
  ------------------
  |  Branch (7132:7): [True: 95.4k, False: 32.4k]
  ------------------
 7133|  95.4k|    return std::ranges::any_of(user_input, is_tabs_or_newline);
 7134|  95.4k|  }
 7135|       |  // fast path for long strings (expected to be common)
 7136|  32.4k|  size_t i = 0;
 7137|  32.4k|  const __m128i mask1 = _mm_set1_epi8('\r');
 7138|  32.4k|  const __m128i mask2 = _mm_set1_epi8('\n');
 7139|  32.4k|  const __m128i mask3 = _mm_set1_epi8('\t');
 7140|       |  // If we supported SSSE3, we could use the algorithm that we use for NEON.
 7141|  32.4k|  __m128i running{0};
 7142|   163k|  for (; i + 15 < user_input.size(); i += 16) {
  ------------------
  |  Branch (7142:10): [True: 131k, False: 32.4k]
  ------------------
 7143|   131k|    __m128i word = _mm_loadu_si128((const __m128i*)(user_input.data() + i));
 7144|   131k|    running = _mm_or_si128(
 7145|   131k|        _mm_or_si128(running, _mm_or_si128(_mm_cmpeq_epi8(word, mask1),
 7146|   131k|                                           _mm_cmpeq_epi8(word, mask2))),
 7147|   131k|        _mm_cmpeq_epi8(word, mask3));
 7148|   131k|  }
 7149|  32.4k|  if (i < user_input.size()) {
  ------------------
  |  Branch (7149:7): [True: 28.3k, False: 4.07k]
  ------------------
 7150|  28.3k|    __m128i word = _mm_loadu_si128(
 7151|  28.3k|        (const __m128i*)(user_input.data() + user_input.length() - 16));
 7152|  28.3k|    running = _mm_or_si128(
 7153|  28.3k|        _mm_or_si128(running, _mm_or_si128(_mm_cmpeq_epi8(word, mask1),
 7154|  28.3k|                                           _mm_cmpeq_epi8(word, mask2))),
 7155|  28.3k|        _mm_cmpeq_epi8(word, mask3));
 7156|  28.3k|  }
 7157|  32.4k|  return _mm_movemask_epi8(running) != 0;
 7158|   127k|}
_ZN3ada7unicode18is_tabs_or_newlineEc:
 7016|   340k|constexpr bool is_tabs_or_newline(char c) noexcept {
 7017|   340k|  return c == '\r' || c == '\n' || c == '\t';
  ------------------
  |  Branch (7017:10): [True: 350, False: 340k]
  |  Branch (7017:23): [True: 382, False: 339k]
  |  Branch (7017:36): [True: 260, False: 339k]
  ------------------
 7018|   340k|}
can_parse.cc:_ZN3ada12_GLOBAL__N_124try_can_parse_clean_httpENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8226|  32.4k|std::optional<bool> try_can_parse_clean_http(std::string_view input) noexcept {
 8227|  32.4k|  const auto* bytes = reinterpret_cast<const uint8_t*>(input.data());
 8228|  32.4k|  const size_t length = input.size();
 8229|  32.4k|  if (length < 7) {
  ------------------
  |  Branch (8229:7): [True: 15.1k, False: 17.3k]
  ------------------
 8230|  15.1k|    return std::nullopt;
 8231|  15.1k|  }
 8232|       |
 8233|  17.3k|  size_t authority_start;
 8234|  17.3k|  if constexpr (k_can_parse_little_endian) {
 8235|  17.3k|    if (length >= 8) {
  ------------------
  |  Branch (8235:9): [True: 15.9k, False: 1.36k]
  ------------------
 8236|  15.9k|      uint64_t first8 = 0;
 8237|  15.9k|      std::memcpy(&first8, bytes, 8);
 8238|  15.9k|      if (first8 == 0x2f2f3a7370747468ull) {  // "https://"
  ------------------
  |  Branch (8238:11): [True: 8, False: 15.9k]
  ------------------
 8239|      8|        authority_start = 8;
 8240|  15.9k|      } else if ((first8 & 0x00ffffffffffffffull) ==
  ------------------
  |  Branch (8240:18): [True: 357, False: 15.6k]
  ------------------
 8241|  15.9k|                 0x002f2f3a70747468ull) {  // "http://"
 8242|    357|        authority_start = 7;
 8243|  15.6k|      } else {
 8244|  15.6k|        return std::nullopt;
 8245|  15.6k|      }
 8246|  15.9k|    } else if (bytes[0] == 'h' && bytes[1] == 't' && bytes[2] == 't' &&
  ------------------
  |  Branch (8246:16): [True: 82, False: 1.28k]
  |  Branch (8246:35): [True: 66, False: 16]
  |  Branch (8246:54): [True: 52, False: 14]
  ------------------
 8247|     52|               bytes[3] == 'p' && bytes[4] == ':' && bytes[5] == '/' &&
  ------------------
  |  Branch (8247:16): [True: 37, False: 15]
  |  Branch (8247:35): [True: 24, False: 13]
  |  Branch (8247:54): [True: 7, False: 17]
  ------------------
 8248|      7|               bytes[6] == '/') {
  ------------------
  |  Branch (8248:16): [True: 2, False: 5]
  ------------------
 8249|      2|      authority_start = 7;
 8250|  1.36k|    } else {
 8251|  1.36k|      return std::nullopt;
 8252|  1.36k|    }
 8253|       |  } else {
 8254|       |    uint32_t first4{};
 8255|       |    std::memcpy(&first4, bytes, 4);
 8256|       |    if (first4 != 0x68747470u) {  // "http"
 8257|       |      return std::nullopt;
 8258|       |    }
 8259|       |    if (length >= 8 && bytes[4] == 's' && bytes[5] == ':' && bytes[6] == '/' &&
 8260|       |        bytes[7] == '/') {
 8261|       |      authority_start = 8;
 8262|       |    } else if (bytes[4] == ':' && bytes[5] == '/' && bytes[6] == '/') {
 8263|       |      authority_start = 7;
 8264|       |    } else {
 8265|       |      return std::nullopt;
 8266|       |    }
 8267|       |  }
 8268|       |
 8269|  17.3k|  if (authority_start >= length) {
  ------------------
  |  Branch (8269:7): [True: 2, False: 17.3k]
  ------------------
 8270|      2|    return false;
 8271|      2|  }
 8272|       |
 8273|  17.3k|  size_t cursor = authority_start;
 8274|  18.4k|  while (cursor + 8 <= length && eight_clean_http_host_bytes(bytes + cursor)) {
  ------------------
  |  Branch (8274:10): [True: 1.30k, False: 17.1k]
  |  Branch (8274:34): [True: 1.12k, False: 181]
  ------------------
 8275|  1.12k|    cursor += 8;
 8276|  1.12k|  }
 8277|  17.9k|  while (cursor < length) {
  ------------------
  |  Branch (8277:10): [True: 967, False: 17.0k]
  ------------------
 8278|    967|    const uint8_t c = bytes[cursor];
 8279|    967|    if (c == '/' || c == '?' || c == '#') {
  ------------------
  |  Branch (8279:9): [True: 219, False: 748]
  |  Branch (8279:21): [True: 5, False: 743]
  |  Branch (8279:33): [True: 1, False: 742]
  ------------------
 8280|    225|      break;
 8281|    225|    }
 8282|    742|    if (!clean_http_host_byte[c]) {
  ------------------
  |  Branch (8282:9): [True: 109, False: 633]
  ------------------
 8283|    109|      return std::nullopt;
 8284|    109|    }
 8285|    633|    ++cursor;
 8286|    633|  }
 8287|       |
 8288|  17.2k|  const size_t host_length = cursor - authority_start;
 8289|  17.2k|  if (host_length == 0) {
  ------------------
  |  Branch (8289:7): [True: 3, False: 17.2k]
  ------------------
 8290|       |    // Extra special-scheme slashes are normalization, not an empty host.
 8291|      3|    if (bytes[authority_start] == '/' || bytes[authority_start] == '\\') {
  ------------------
  |  Branch (8291:9): [True: 1, False: 2]
  |  Branch (8291:42): [True: 0, False: 2]
  ------------------
 8292|      1|      return std::nullopt;
 8293|      1|    }
 8294|      2|    return false;
 8295|      3|  }
 8296|  17.2k|  if (host_length > 253 || bytes[cursor - 1] == '.') {
  ------------------
  |  Branch (8296:7): [True: 17.0k, False: 244]
  |  Branch (8296:28): [True: 29, False: 215]
  ------------------
 8297|     38|    return std::nullopt;
 8298|     38|  }
 8299|       |
 8300|  17.2k|  const std::string_view host(input.data() + authority_start, host_length);
 8301|  17.2k|  if (checkers::last_label_may_be_a_number(host)) {
  ------------------
  |  Branch (8301:7): [True: 21, False: 17.1k]
  ------------------
 8302|     21|    return std::nullopt;
 8303|     21|  }
 8304|  17.1k|  if (host.find('x') != std::string_view::npos &&
  ------------------
  |  Branch (8304:7): [True: 86, False: 17.1k]
  ------------------
 8305|     86|      host.find("xn-") != std::string_view::npos) {
  ------------------
  |  Branch (8305:7): [True: 25, False: 61]
  ------------------
 8306|     25|    return std::nullopt;
 8307|     25|  }
 8308|       |
 8309|       |  // Once a special URL has a valid host, path/query/fragment bytes cannot make
 8310|       |  // it structurally invalid: the full parser percent-encodes them as needed.
 8311|  17.1k|  return true;
 8312|  17.1k|}
can_parse.cc:_ZN3ada12_GLOBAL__N_127eight_clean_http_host_bytesEPKh:
 8202|  1.30k|    const uint8_t* input) noexcept {
 8203|  1.30k|  uint64_t w = 0;
 8204|  1.30k|  std::memcpy(&w, input, 8);
 8205|  1.30k|  constexpr uint64_t k_high = 0x8080808080808080ull;
 8206|  1.30k|  if ((w & k_high) != 0) {
  ------------------
  |  Branch (8206:7): [True: 10, False: 1.29k]
  ------------------
 8207|     10|    return false;
 8208|     10|  }
 8209|  1.29k|  const uint64_t ok = swar_in_range(w, 'a', 'z') | swar_in_range(w, '0', '9') |
 8210|  1.29k|                      swar_in_range(w, '-', '-') | swar_in_range(w, '.', '.') |
 8211|  1.29k|                      swar_in_range(w, '_', '_') | swar_in_range(w, '~', '~');
 8212|  1.29k|  return ok == k_high;
 8213|  1.30k|}
can_parse.cc:_ZN3ada12_GLOBAL__N_113swar_in_rangeEmhh:
 8193|  7.76k|                                         uint8_t hi) noexcept {
 8194|  7.76k|  constexpr uint64_t k_ones = 0x0101010101010101ull;
 8195|  7.76k|  constexpr uint64_t k_high = 0x8080808080808080ull;
 8196|  7.76k|  const uint64_t ge_lo = (w | k_high) - (k_ones * lo);
 8197|  7.76k|  const uint64_t le_hi = ((k_ones * hi) | k_high) - w;
 8198|  7.76k|  return ge_lo & le_hi & k_high;
 8199|  7.76k|}
can_parse.cc:_ZN3ada12_GLOBAL__N_127try_can_parse_absolute_fastENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8327|  32.3k|    std::string_view input) noexcept {
 8328|  32.3k|  const uint8_t* b = reinterpret_cast<const uint8_t*>(input.data());
 8329|  32.3k|  size_t len = input.size();
 8330|       |
 8331|       |  // -- Inline C0 whitespace trim (no allocation) --------------------------
 8332|       |  // Note: \t (0x09), \n (0x0a), \r (0x0d) are all <= 0x20, so any
 8333|       |  // leading/trailing tabs or newlines are correctly stripped here, matching
 8334|       |  // the WHATWG spec's "remove leading/trailing C0 control and space" step.
 8335|  33.7k|  while (len > 0 && b[0] <= 0x20) {
  ------------------
  |  Branch (8335:10): [True: 21.2k, False: 12.4k]
  |  Branch (8335:21): [True: 1.43k, False: 19.8k]
  ------------------
 8336|  1.43k|    b++;
 8337|  1.43k|    len--;
 8338|  1.43k|  }
 8339|  33.8k|  while (len > 0 && b[len - 1] <= 0x20) {
  ------------------
  |  Branch (8339:10): [True: 21.4k, False: 12.4k]
  |  Branch (8339:21): [True: 1.57k, False: 19.8k]
  ------------------
 8340|  1.57k|    len--;
 8341|  1.57k|  }
 8342|  32.3k|  if (len == 0) return false;
  ------------------
  |  Branch (8342:7): [True: 12.4k, False: 19.8k]
  ------------------
 8343|       |
 8344|       |  // -- Scheme detection -----------------------------------------------------
 8345|       |  // Fast path for HTTP and HTTPS (covers ~90%+ of real-world URLs).
 8346|       |  // Avoids the general scheme loop, buffer copy, and perfect hash lookup.
 8347|       |  // We know HTTP and HTTPS are special non-file schemes, so no further
 8348|       |  // scheme_type checks are needed on the fast path -- only `pos` matters.
 8349|  19.8k|  size_t pos;
 8350|       |
 8351|  19.8k|  if (len >= 7 && (b[0] | 0x20) == 'h' && (b[1] | 0x20) == 't' &&
  ------------------
  |  Branch (8351:7): [True: 17.1k, False: 2.71k]
  |  Branch (8351:19): [True: 487, False: 16.6k]
  |  Branch (8351:43): [True: 387, False: 100]
  ------------------
 8352|    387|      (b[2] | 0x20) == 't' && (b[3] | 0x20) == 'p') {
  ------------------
  |  Branch (8352:7): [True: 362, False: 25]
  |  Branch (8352:31): [True: 337, False: 25]
  ------------------
 8353|    337|    if (b[4] == ':' && b[5] == '/' && b[6] == '/') {
  ------------------
  |  Branch (8353:9): [True: 304, False: 33]
  |  Branch (8353:24): [True: 199, False: 105]
  |  Branch (8353:39): [True: 189, False: 10]
  ------------------
 8354|    189|      pos = 7;
 8355|    189|      goto skip_extra_slashes;
 8356|    189|    }
 8357|    148|    if (len >= 8 && (b[4] | 0x20) == 's' && b[5] == ':' && b[6] == '/' &&
  ------------------
  |  Branch (8357:9): [True: 113, False: 35]
  |  Branch (8357:21): [True: 14, False: 99]
  |  Branch (8357:45): [True: 11, False: 3]
  |  Branch (8357:60): [True: 8, False: 3]
  ------------------
 8358|      8|        b[7] == '/') {
  ------------------
  |  Branch (8358:9): [True: 7, False: 1]
  ------------------
 8359|      7|      pos = 8;
 8360|      7|      goto skip_extra_slashes;
 8361|      7|    }
 8362|       |    // Fall through: could be "httpe://", tabs in scheme, etc.
 8363|    148|  }
 8364|       |
 8365|  19.6k|  {
 8366|       |    // General scheme detection for ws, wss, ftp, and edge cases.
 8367|  19.6k|    if (!checkers::is_alpha(static_cast<char>(b[0]))) return false;
  ------------------
  |  Branch (8367:9): [True: 919, False: 18.7k]
  ------------------
 8368|       |
 8369|       |    // Scan for ':' within the first 7 bytes. All special schemes are <= 5
 8370|       |    // chars ("https"), so any URL whose first ':' is beyond byte 6 is either
 8371|       |    // non-special or relative -- both require the full parser.
 8372|  18.7k|    size_t colon_pos = 0;
 8373|  40.1k|    for (size_t i = 1;; ++i) {
 8374|  40.1k|      if (i >= 7 || i >= len) return std::nullopt;
  ------------------
  |  Branch (8374:11): [True: 98, False: 40.0k]
  |  Branch (8374:21): [True: 186, False: 39.8k]
  ------------------
 8375|  39.8k|      const char c = static_cast<char>(b[i]);
 8376|  39.8k|      if (c == ':') {
  ------------------
  |  Branch (8376:11): [True: 18.1k, False: 21.7k]
  ------------------
 8377|  18.1k|        colon_pos = i;
 8378|  18.1k|        break;
 8379|  18.1k|      }
 8380|       |      // Tabs/newlines in the scheme require the full parser to strip them.
 8381|  21.7k|      if (c == '\t' || c == '\n' || c == '\r') return std::nullopt;
  ------------------
  |  Branch (8381:11): [True: 5, False: 21.7k]
  |  Branch (8381:24): [True: 11, False: 21.7k]
  |  Branch (8381:37): [True: 6, False: 21.7k]
  ------------------
 8382|  21.7k|      if (!unicode::is_alnum_plus(c)) return false;
  ------------------
  |  Branch (8382:11): [True: 238, False: 21.4k]
  ------------------
 8383|  21.7k|    }
 8384|       |
 8385|       |    // Lowercase scheme bytes inline and classify via the existing perfect
 8386|       |    // hash.
 8387|  18.1k|    char scheme_buf[6];
 8388|  18.1k|    scheme_buf[0] = static_cast<char>(b[0] | 0x20);
 8389|  38.8k|    for (size_t i = 1; i < colon_pos; ++i)
  ------------------
  |  Branch (8389:24): [True: 20.6k, False: 18.1k]
  ------------------
 8390|  20.6k|      scheme_buf[i] = static_cast<char>(b[i] | 0x20);
 8391|       |
 8392|  18.1k|    const ada::scheme::type scheme_type =
 8393|  18.1k|        ada::scheme::get_scheme_type({scheme_buf, colon_pos});
 8394|       |
 8395|       |    // Only handle special, non-file schemes.
 8396|  18.1k|    if (scheme_type == ada::scheme::NOT_SPECIAL) return std::nullopt;
  ------------------
  |  Branch (8396:9): [True: 2.63k, False: 15.5k]
  ------------------
 8397|  15.5k|    if (scheme_type == ada::scheme::FILE) return std::nullopt;
  ------------------
  |  Branch (8397:9): [True: 1.81k, False: 13.7k]
  ------------------
 8398|       |
 8399|       |    // Per WHATWG, special URLs don't require "//": "http:example.com" is valid
 8400|       |    // (SPECIAL_AUTHORITY_IGNORE_SLASHES just skips leading slashes and
 8401|       |    // proceeds to AUTHORITY).  Defer to the inline fallback for any input
 8402|       |    // without "://".
 8403|  13.7k|    pos = colon_pos + 1;
 8404|  13.7k|    if (pos + 2 > len || b[pos] != '/' || b[pos + 1] != '/') {
  ------------------
  |  Branch (8404:9): [True: 132, False: 13.5k]
  |  Branch (8404:26): [True: 6.09k, False: 7.49k]
  |  Branch (8404:43): [True: 58, False: 7.43k]
  ------------------
 8405|  6.28k|      return std::nullopt;
 8406|  6.28k|    }
 8407|  7.43k|    pos += 2;
 8408|  7.43k|  }
 8409|       |
 8410|  7.63k|skip_extra_slashes:
 8411|       |  // SPECIAL_AUTHORITY_IGNORE_SLASHES: the full parser skips any additional
 8412|       |  // leading '/' or '\' after the initial "//".  Mirror that here so we don't
 8413|       |  // mis-identify the host as empty when there are extra slashes.
 8414|  8.13k|  while (pos < len && (b[pos] == '/' || b[pos] == '\\')) {
  ------------------
  |  Branch (8414:10): [True: 8.11k, False: 25]
  |  Branch (8414:24): [True: 326, False: 7.78k]
  |  Branch (8414:41): [True: 181, False: 7.60k]
  ------------------
 8415|    507|    ++pos;
 8416|    507|  }
 8417|       |
 8418|       |  // Early IPv6 bail-out: if the authority starts with '[', it's an IPv6
 8419|       |  // literal which requires the full parser.  Checking here avoids scanning
 8420|       |  // the entire bracketed address only to bail out afterward.
 8421|  7.63k|  if (pos < len && b[pos] == '[') return std::nullopt;
  ------------------
  |  Branch (8421:7): [True: 7.60k, False: 25]
  |  Branch (8421:20): [True: 98, False: 7.50k]
  ------------------
 8422|       |
 8423|       |  // -- Merged authority + host scan ------------------------------------------
 8424|       |  // A single forward pass over the authority bytes that simultaneously:
 8425|       |  //   - finds the authority end and port colon
 8426|       |  //   - validates host characters (forbidden domain code points)
 8427|       |  //   - tracks IPv4 indicators (all-decimal-dots, last non-dot char)
 8428|       |  //   - detects xn-- prefixes (IDNA punycode)
 8429|       |  //   - detects tabs/newlines (which require the full parser to strip)
 8430|       |  // This replaces 4 separate scans over the host bytes.
 8431|  7.53k|  const size_t auth_start = pos;
 8432|  7.53k|  size_t auth_end = pos;
 8433|  7.53k|  size_t port_colon = SIZE_MAX;
 8434|  7.53k|  bool all_dec_dots = true;
 8435|       |
 8436|  50.3k|  for (; auth_end < len; ++auth_end) {
  ------------------
  |  Branch (8436:10): [True: 50.0k, False: 300]
  ------------------
 8437|  50.0k|    const uint8_t c = b[auth_end];
 8438|       |
 8439|       |    // Non-ASCII -> needs IDNA processing -> full parser.
 8440|  50.0k|    if (c >= 0x80) return std::nullopt;
  ------------------
  |  Branch (8440:9): [True: 24, False: 50.0k]
  ------------------
 8441|       |
 8442|       |    // Authority delimiters.
 8443|  50.0k|    if (c == '/' || c == '?' || c == '#' || c == '\\') break;
  ------------------
  |  Branch (8443:9): [True: 5.29k, False: 44.7k]
  |  Branch (8443:21): [True: 105, False: 44.6k]
  |  Branch (8443:33): [True: 109, False: 44.4k]
  |  Branch (8443:45): [True: 2, False: 44.4k]
  ------------------
 8444|       |
 8445|       |    // Port separator.
 8446|  44.4k|    if (c == ':') {
  ------------------
  |  Branch (8446:9): [True: 2.12k, False: 42.3k]
  ------------------
 8447|  2.12k|      if (port_colon == SIZE_MAX) port_colon = auth_end;
  ------------------
  |  Branch (8447:11): [True: 1.92k, False: 201]
  ------------------
 8448|  2.12k|      continue;
 8449|  2.12k|    }
 8450|       |
 8451|       |    // Credentials or percent-encoding -> full parser.
 8452|  42.3k|    if (c == '@' || c == '%') return std::nullopt;
  ------------------
  |  Branch (8452:9): [True: 130, False: 42.2k]
  |  Branch (8452:21): [True: 155, False: 42.0k]
  ------------------
 8453|       |
 8454|       |    // Tabs/newlines anywhere in the authority require the full parser to
 8455|       |    // strip them before validation.  Without this, a tab in the port (e.g.
 8456|       |    // "http://host:8\t0/") would be mis-rejected by port validation.
 8457|  42.0k|    if (c == '\t' || c == '\n' || c == '\r') return std::nullopt;
  ------------------
  |  Branch (8457:9): [True: 1, False: 42.0k]
  |  Branch (8457:22): [True: 1, False: 42.0k]
  |  Branch (8457:35): [True: 1, False: 42.0k]
  ------------------
 8458|       |
 8459|       |    // Skip remaining host-specific checks for port bytes.  Port digits are
 8460|       |    // validated separately below, and no forbidden-domain-code-point check
 8461|       |    // is needed on port characters.
 8462|  42.0k|    if (port_colon != SIZE_MAX) continue;
  ------------------
  |  Branch (8462:9): [True: 2.67k, False: 39.4k]
  ------------------
 8463|       |
 8464|       |    // -- Host byte validation (inlined) ------------------------------------
 8465|       |    // Forbidden domain code points that are not already caught above:
 8466|       |    //   C0 controls and space (0x00-0x20), DEL (0x7F), <, >, [, ], ^, |.
 8467|       |    // At this stage, the input may still be userinfo or be normalized later
 8468|       |    // (e.g., percent-encoded), so we do not reject here and defer to the
 8469|       |    // parser. Characters already caught: >= 0x80 (non-ASCII), '/' '?' '#' '\\'
 8470|       |    // (delimiters), ':' (port), '@' '%' (bail), '\t' '\n' '\r' (bail).
 8471|  39.4k|    if (c <= 0x20 || c == 0x7F || c == '<' || c == '>' || c == '[' ||
  ------------------
  |  Branch (8471:9): [True: 7, False: 39.4k]
  |  Branch (8471:22): [True: 1, False: 39.4k]
  |  Branch (8471:35): [True: 1, False: 39.4k]
  |  Branch (8471:47): [True: 1, False: 39.4k]
  |  Branch (8471:59): [True: 2, False: 39.4k]
  ------------------
 8472|  39.4k|        c == ']' || c == '^' || c == '|') {
  ------------------
  |  Branch (8472:9): [True: 1, False: 39.4k]
  |  Branch (8472:21): [True: 1, False: 39.4k]
  |  Branch (8472:33): [True: 2, False: 39.3k]
  ------------------
 8473|     16|      return std::nullopt;
 8474|     16|    }
 8475|       |
 8476|       |    // Track whether host is all decimal digits and dots (potential IPv4).
 8477|  39.3k|    if (c != '.' && (c < '0' || c > '9')) all_dec_dots = false;
  ------------------
  |  Branch (8477:9): [True: 35.3k, False: 4.04k]
  |  Branch (8477:22): [True: 2.12k, False: 33.2k]
  |  Branch (8477:33): [True: 25.2k, False: 7.99k]
  ------------------
 8478|       |
 8479|       |    // Detect xn-- prefix inline (IDNA punycode -> needs full parser).
 8480|       |    // Checking at every position mirrors the original behavior: any
 8481|       |    // occurrence of "xn--" in the host (not just at label boundaries)
 8482|       |    // triggers a bail-out to the full IDNA validator.
 8483|  39.3k|    if ((c | 0x20) == 'x' && auth_end + 4 <= len &&
  ------------------
  |  Branch (8483:9): [True: 6.21k, False: 33.1k]
  |  Branch (8483:30): [True: 5.73k, False: 483]
  ------------------
 8484|  5.73k|        (b[auth_end + 1] | 0x20) == 'n' && b[auth_end + 2] == '-' &&
  ------------------
  |  Branch (8484:9): [True: 1.93k, False: 3.80k]
  |  Branch (8484:44): [True: 1.68k, False: 250]
  ------------------
 8485|  1.68k|        b[auth_end + 3] == '-') {
  ------------------
  |  Branch (8485:9): [True: 1.39k, False: 291]
  ------------------
 8486|  1.39k|      return std::nullopt;
 8487|  1.39k|    }
 8488|  39.3k|  }
 8489|       |
 8490|  5.81k|  const size_t host_end = (port_colon != SIZE_MAX) ? port_colon : auth_end;
  ------------------
  |  Branch (8490:27): [True: 1.85k, False: 3.95k]
  ------------------
 8491|       |
 8492|       |  // Empty host is invalid for special URLs.
 8493|  5.81k|  if (auth_start == host_end) return false;
  ------------------
  |  Branch (8493:7): [True: 37, False: 5.77k]
  ------------------
 8494|       |
 8495|       |  // -- IPv4 handling ---------------------------------------------------------
 8496|  5.77k|  const char* host_ptr = reinterpret_cast<const char*>(b + auth_start);
 8497|  5.77k|  const size_t host_len = host_end - auth_start;
 8498|       |
 8499|  5.77k|  if (all_dec_dots) {
  ------------------
  |  Branch (8499:7): [True: 1.35k, False: 4.42k]
  ------------------
 8500|       |    // Host is all decimal digits and dots -> try the fast IPv4 parser.
 8501|  1.35k|    if (checkers::try_parse_ipv4_fast({host_ptr, host_len}) !=
  ------------------
  |  Branch (8501:9): [True: 663, False: 689]
  ------------------
 8502|  1.35k|        checkers::ipv4_fast_fail) {
 8503|       |      // Valid decimal IPv4 host.  Do NOT return true yet: the port still
 8504|       |      // needs to be validated below before we can declare the URL valid.
 8505|    663|      goto validate_port;
 8506|    663|    }
 8507|       |    // Fast IPv4 parsing failed (e.g. host is ".", "..", "1.2.3.500").
 8508|       |    // Such hosts may still be valid domain names; defer to the full parser.
 8509|    689|    return std::nullopt;
 8510|  1.35k|  }
 8511|       |
 8512|  4.42k|  if (checkers::last_label_may_be_a_number({host_ptr, host_len})) {
  ------------------
  |  Branch (8512:7): [True: 285, False: 4.13k]
  ------------------
 8513|    285|    return std::nullopt;
 8514|    285|  }
 8515|       |
 8516|       |  // -- Port validation -------------------------------------------------------
 8517|  4.80k|validate_port:
 8518|  4.80k|  if (port_colon != SIZE_MAX) {
  ------------------
  |  Branch (8518:7): [True: 1.60k, False: 3.20k]
  ------------------
 8519|  1.60k|    const uint8_t* pp = b + port_colon + 1;
 8520|  1.60k|    size_t pl = auth_end - port_colon - 1;
 8521|  1.60k|    if (pl > 0) {
  ------------------
  |  Branch (8521:9): [True: 1.19k, False: 410]
  ------------------
 8522|       |      // Strip leading zeros: "0000001" == 1, "0000000000000" == 0, both valid.
 8523|       |      // Only the significant digits count toward the 5-digit maximum.
 8524|  1.72k|      while (pl > 0 && *pp == '0') {
  ------------------
  |  Branch (8524:14): [True: 1.37k, False: 350]
  |  Branch (8524:24): [True: 530, False: 840]
  ------------------
 8525|    530|        ++pp;
 8526|    530|        --pl;
 8527|    530|      }
 8528|  1.19k|      if (pl > 5) return false;  // significant digits > 99999
  ------------------
  |  Branch (8528:11): [True: 4, False: 1.18k]
  ------------------
 8529|  1.18k|      uint32_t pv = 0;
 8530|  2.45k|      for (size_t i = 0; i < pl; ++i) {
  ------------------
  |  Branch (8530:26): [True: 1.27k, False: 1.17k]
  ------------------
 8531|  1.27k|        if (pp[i] < '0' || pp[i] > '9') return false;
  ------------------
  |  Branch (8531:13): [True: 4, False: 1.27k]
  |  Branch (8531:28): [True: 9, False: 1.26k]
  ------------------
 8532|  1.26k|        pv = pv * 10 + (pp[i] - '0');
 8533|  1.26k|      }
 8534|  1.17k|      if (pv > 65535) return false;
  ------------------
  |  Branch (8534:11): [True: 3, False: 1.17k]
  ------------------
 8535|  1.17k|    }
 8536|  1.60k|  }
 8537|       |
 8538|       |  // Path, query, and fragment are structurally always valid for can_parse --
 8539|       |  // the parser would encode whatever is there.
 8540|  4.78k|  return true;
 8541|  4.80k|}
_ZN3ada7helpers27remove_ascii_tab_or_newlineERNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 8842|  1.08k|ada_really_inline void remove_ascii_tab_or_newline(std::string& input) {
 8843|       |  // Fast path: inputs with no tab/newline (the common case) avoid the
 8844|       |  // per-character erase_if scan. has_tabs_or_newline uses SIMD for inputs
 8845|       |  // >= 16 bytes, making this check much cheaper than erase_if's scalar
 8846|       |  // predicate walk when there is nothing to remove.
 8847|  1.08k|  if (!ada::unicode::has_tabs_or_newline(input)) {
  ------------------
  |  Branch (8847:7): [True: 0, False: 1.08k]
  ------------------
 8848|      0|    return;
 8849|      0|  }
 8850|  1.08k|  std::erase_if(input, ada::unicode::is_ascii_tab_or_newline);
 8851|  1.08k|}
_ZN3ada7unicode23is_ascii_tab_or_newlineEc:
 7375|  46.3k|    const char c) noexcept {
 7376|  46.3k|  return c == '\t' || c == '\n' || c == '\r';
  ------------------
  |  Branch (7376:10): [True: 1.28k, False: 45.0k]
  |  Branch (7376:23): [True: 2.18k, False: 42.8k]
  |  Branch (7376:36): [True: 953, False: 41.8k]
  ------------------
 7377|  46.3k|}
_ZN3ada7unicode22is_c0_control_or_spaceEc:
 7370|   151k|ada_really_inline constexpr bool is_c0_control_or_space(const char c) noexcept {
 7371|   151k|  return (unsigned char)c <= ' ';
 7372|   151k|}
_ZN3ada7helpers19parse_prepared_pathENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEENS_6scheme4typeERNS1_12basic_stringIcS4_NS1_9allocatorIcEEEE:
 9547|  10.3k|                                           std::string& path) {
 9548|  10.3k|  ada_log("parse_prepared_path ", input);
 9549|  10.3k|  uint8_t accumulator = checkers::path_signature(input);
 9550|       |  // Let us first detect a trivial case.
 9551|       |  // If it is special, we check that we have no dot, no %,  no \ and no
 9552|       |  // character needing percent encoding. Otherwise, we check that we have no %,
 9553|       |  // no dot, and no character needing percent encoding.
 9554|  10.3k|  constexpr uint8_t need_encoding = 1;
 9555|  10.3k|  constexpr uint8_t backslash_char = 2;
 9556|  10.3k|  constexpr uint8_t dot_char = 4;
 9557|  10.3k|  constexpr uint8_t percent_char = 8;
 9558|  10.3k|  bool special = type != ada::scheme::NOT_SPECIAL;
 9559|  10.3k|  bool may_need_slow_file_handling = (type == ada::scheme::type::FILE &&
  ------------------
  |  Branch (9559:39): [True: 1.53k, False: 8.78k]
  ------------------
 9560|  1.53k|                                      checkers::is_windows_drive_letter(input));
  ------------------
  |  Branch (9560:39): [True: 121, False: 1.41k]
  ------------------
 9561|  10.3k|  bool trivial_path =
 9562|  10.3k|      (special ? (accumulator == 0)
  ------------------
  |  Branch (9562:7): [True: 4.77k, False: 5.55k]
  |  Branch (9562:8): [True: 8.80k, False: 1.51k]
  ------------------
 9563|  10.3k|               : ((accumulator & (need_encoding | dot_char | percent_char)) ==
 9564|  1.51k|                  0)) &&
 9565|  4.77k|      (!may_need_slow_file_handling);
  ------------------
  |  Branch (9565:7): [True: 4.68k, False: 85]
  ------------------
 9566|  10.3k|  if (accumulator == dot_char && !may_need_slow_file_handling) {
  ------------------
  |  Branch (9566:7): [True: 1.48k, False: 8.83k]
  |  Branch (9566:34): [True: 1.46k, False: 24]
  ------------------
 9567|       |    // '4' means that we have at least one dot, but nothing that requires
 9568|       |    // percent encoding or decoding. The only part that is not trivial is
 9569|       |    // that we may have single dots and double dots path segments.
 9570|       |    // If we have such segments, then we either have a path that begins
 9571|       |    // with '.' (easy to check), or we have the sequence './'.
 9572|       |    // Note: input cannot be empty, it must at least contain one character ('.')
 9573|       |    // Note: we know that '\' is not present.
 9574|  1.46k|    if (input[0] != '.') {
  ------------------
  |  Branch (9574:9): [True: 777, False: 685]
  ------------------
 9575|    777|      size_t slashdot = 0;
 9576|    777|      bool dot_is_file = true;
 9577|  5.23k|      for (;;) {
 9578|  5.23k|        slashdot = input.find("/.", slashdot);
 9579|  5.23k|        if (slashdot == std::string_view::npos) {  // common case
  ------------------
  |  Branch (9579:13): [True: 777, False: 4.45k]
  ------------------
 9580|    777|          break;
 9581|  4.45k|        } else {  // uncommon
 9582|       |          // only three cases matter: /./, /.. or a final /
 9583|  4.45k|          slashdot += 2;
 9584|  4.45k|          dot_is_file &= !(slashdot == input.size() || input[slashdot] == '.' ||
  ------------------
  |  Branch (9584:28): [True: 178, False: 4.27k]
  |  Branch (9584:56): [True: 2.54k, False: 1.73k]
  ------------------
 9585|  1.73k|                           input[slashdot] == '/');
  ------------------
  |  Branch (9585:28): [True: 1.06k, False: 670]
  ------------------
 9586|  4.45k|        }
 9587|  5.23k|      }
 9588|    777|      trivial_path = dot_is_file;
 9589|    777|    }
 9590|  1.46k|  }
 9591|  10.3k|  if (trivial_path) {
  ------------------
  |  Branch (9591:7): [True: 4.89k, False: 5.42k]
  ------------------
 9592|  4.89k|    ada_log("parse_path trivial");
 9593|  4.89k|    path += '/';
 9594|  4.89k|    path += input;
 9595|  4.89k|    return;
 9596|  4.89k|  }
 9597|       |  // We are going to need to look a bit at the path, but let us see if we can
 9598|       |  // ignore percent encoding *and* backslashes *and* percent characters.
 9599|       |  // Except for the trivial case, this is likely to capture 99% of paths out
 9600|       |  // there.
 9601|  5.42k|  bool fast_path =
 9602|  5.42k|      (special &&
  ------------------
  |  Branch (9602:8): [True: 4.30k, False: 1.12k]
  ------------------
 9603|  4.30k|       (accumulator & (need_encoding | backslash_char | percent_char)) == 0) &&
  ------------------
  |  Branch (9603:8): [True: 1.20k, False: 3.10k]
  ------------------
 9604|  1.20k|      (type != ada::scheme::type::FILE);
  ------------------
  |  Branch (9604:7): [True: 1.04k, False: 163]
  ------------------
 9605|  5.42k|  if (fast_path) {
  ------------------
  |  Branch (9605:7): [True: 1.04k, False: 4.38k]
  ------------------
 9606|  1.04k|    ada_log("parse_prepared_path fast");
 9607|       |    // Here we don't need to worry about \ or percent encoding.
 9608|       |    // We also do not have a file protocol. We might have dots, however,
 9609|       |    // but dots must as appear as '.', and they cannot be encoded because
 9610|       |    // the symbol '%' is not present.
 9611|  1.04k|    size_t previous_location = 0;  // We start at 0.
 9612|  13.8k|    do {
 9613|  13.8k|      size_t new_location = input.find('/', previous_location);
 9614|       |      // std::string_view path_view = input;
 9615|       |      //  We process the last segment separately:
 9616|  13.8k|      if (new_location == std::string_view::npos) {
  ------------------
  |  Branch (9616:11): [True: 1.04k, False: 12.8k]
  ------------------
 9617|  1.04k|        std::string_view path_view = input.substr(previous_location);
 9618|  1.04k|        if (path_view == "..") {  // The path ends with ..
  ------------------
  |  Branch (9618:13): [True: 126, False: 914]
  ------------------
 9619|       |          // e.g., if you receive ".." with an empty path, you go to "/".
 9620|    126|          if (path.empty()) {
  ------------------
  |  Branch (9620:15): [True: 49, False: 77]
  ------------------
 9621|     49|            path = '/';
 9622|     49|            return;
 9623|     49|          }
 9624|       |          // Fast case where we have nothing to do:
 9625|     77|          if (path.back() == '/') {
  ------------------
  |  Branch (9625:15): [True: 26, False: 51]
  ------------------
 9626|     26|            return;
 9627|     26|          }
 9628|       |          // If you have the path "/joe/myfriend",
 9629|       |          // then you delete 'myfriend'.
 9630|     51|          path.resize(path.rfind('/') + 1);
 9631|     51|          return;
 9632|     77|        }
 9633|    914|        path += '/';
 9634|    914|        if (path_view != ".") {
  ------------------
  |  Branch (9634:13): [True: 698, False: 216]
  ------------------
 9635|    698|          path.append(path_view);
 9636|    698|        }
 9637|    914|        return;
 9638|  12.8k|      } else {
 9639|       |        // This is a non-final segment.
 9640|  12.8k|        std::string_view path_view =
 9641|  12.8k|            input.substr(previous_location, new_location - previous_location);
 9642|  12.8k|        previous_location = new_location + 1;
 9643|  12.8k|        if (path_view == "..") {
  ------------------
  |  Branch (9643:13): [True: 2.75k, False: 10.0k]
  ------------------
 9644|  2.75k|          size_t last_delimiter = path.rfind('/');
 9645|  2.75k|          if (last_delimiter != std::string::npos) {
  ------------------
  |  Branch (9645:15): [True: 1.11k, False: 1.63k]
  ------------------
 9646|  1.11k|            path.erase(last_delimiter);
 9647|  1.11k|          }
 9648|  10.0k|        } else if (path_view != ".") {
  ------------------
  |  Branch (9648:20): [True: 8.34k, False: 1.74k]
  ------------------
 9649|  8.34k|          path += '/';
 9650|  8.34k|          path.append(path_view);
 9651|  8.34k|        }
 9652|  12.8k|      }
 9653|  13.8k|    } while (true);
  ------------------
  |  Branch (9653:14): [True: 12.8k, Folded]
  ------------------
 9654|  4.38k|  } else {
 9655|  4.38k|    ada_log("parse_path slow");
 9656|       |    // we have reached the general case
 9657|  4.38k|    bool needs_percent_encoding = (accumulator & 1);
 9658|  29.8k|    do {
 9659|  29.8k|      size_t location = (special && (accumulator & 2))
  ------------------
  |  Branch (9659:26): [True: 22.8k, False: 7.02k]
  |  Branch (9659:37): [True: 1.78k, False: 21.0k]
  ------------------
 9660|  29.8k|                            ? input.find_first_of("/\\")
 9661|  29.8k|                            : input.find('/');
 9662|  29.8k|      std::string_view path_view = input;
 9663|  29.8k|      if (location != std::string_view::npos) {
  ------------------
  |  Branch (9663:11): [True: 25.4k, False: 4.38k]
  ------------------
 9664|  25.4k|        path_view.remove_suffix(path_view.size() - location);
 9665|  25.4k|        input.remove_prefix(location + 1);
 9666|  25.4k|      }
 9667|       |      // Path encoding preserves dots and percent signs, so normalize first.
 9668|  29.8k|      if (unicode::is_double_dot_path_segment(path_view)) {
  ------------------
  |  Branch (9668:11): [True: 4.38k, False: 25.4k]
  ------------------
 9669|  4.38k|        helpers::shorten_path(path, type);
 9670|  4.38k|        if (location == std::string_view::npos) {
  ------------------
  |  Branch (9670:13): [True: 253, False: 4.13k]
  ------------------
 9671|    253|          path += '/';
 9672|    253|        }
 9673|  25.4k|      } else if (unicode::is_single_dot_path_segment(path_view) &&
  ------------------
  |  Branch (9673:18): [True: 1.33k, False: 24.1k]
  ------------------
 9674|  1.33k|                 (location == std::string_view::npos)) {
  ------------------
  |  Branch (9674:18): [True: 115, False: 1.21k]
  ------------------
 9675|    115|        path += '/';
 9676|    115|      }
 9677|       |      // Otherwise, if path_view is not a single-dot path segment, then:
 9678|  25.3k|      else if (!unicode::is_single_dot_path_segment(path_view)) {
  ------------------
  |  Branch (9678:16): [True: 24.1k, False: 1.21k]
  ------------------
 9679|       |        // If url's scheme is "file", url's path is empty, and path_view is a
 9680|       |        // Windows drive letter, then replace the second code point in
 9681|       |        // path_view with U+003A (:).
 9682|  24.1k|        if (type == ada::scheme::type::FILE && path.empty() &&
  ------------------
  |  Branch (9682:13): [True: 1.91k, False: 22.2k]
  |  Branch (9682:48): [True: 818, False: 1.09k]
  ------------------
 9683|    818|            path_view.size() == 2 &&
  ------------------
  |  Branch (9683:13): [True: 341, False: 477]
  ------------------
 9684|    341|            checkers::is_windows_drive_letter(path_view)) {
  ------------------
  |  Branch (9684:13): [True: 137, False: 204]
  ------------------
 9685|    137|          path += '/';
 9686|    137|          path += path_view[0];
 9687|    137|          path += ':';
 9688|    137|          path_view.remove_prefix(2);
 9689|    137|          path.append(path_view);
 9690|  24.0k|        } else {
 9691|       |          // Append encoded bytes directly to the pathname.
 9692|  24.0k|          path += '/';
 9693|  24.0k|          if (!needs_percent_encoding ||
  ------------------
  |  Branch (9693:15): [True: 11.7k, False: 12.2k]
  ------------------
 9694|  12.2k|              !ada::unicode::percent_encode<true>(
  ------------------
  |  Branch (9694:15): [True: 7.47k, False: 4.79k]
  ------------------
 9695|  19.2k|                  path_view, character_sets::PATH_PERCENT_ENCODE, path)) {
 9696|  19.2k|            path.append(path_view);
 9697|  19.2k|          }
 9698|  24.0k|        }
 9699|  24.1k|      }
 9700|  29.8k|      if (location == std::string_view::npos) {
  ------------------
  |  Branch (9700:11): [True: 4.38k, False: 25.4k]
  ------------------
 9701|  4.38k|        return;
 9702|  4.38k|      }
 9703|  29.8k|    } while (true);
  ------------------
  |  Branch (9703:14): [True: 25.4k, Folded]
  ------------------
 9704|  4.38k|  }
 9705|  5.42k|}
_ZN3ada8checkers14path_signatureENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
   77|  20.6k|    std::string_view input) noexcept {
   78|       |  // The path percent-encode set is the query percent-encode set and U+003F (?),
   79|       |  // U+0060 (`), U+007B ({), and U+007D (}). The query percent-encode set is the
   80|       |  // C0 control percent-encode set and U+0020 SPACE, U+0022 ("), U+0023 (#),
   81|       |  // U+003C (<), and U+003E (>). The C0 control percent-encode set are the C0
   82|       |  // controls and all code points greater than U+007E (~).
   83|  20.6k|  size_t i = 0;
   84|  20.6k|  uint8_t accumulator{};
   85|  69.8k|  for (; i + 7 < input.size(); i += 8) {
  ------------------
  |  Branch (85:10): [True: 49.1k, False: 20.6k]
  ------------------
   86|  49.1k|    accumulator |= uint8_t(path_signature_table[uint8_t(input[i])] |
   87|  49.1k|                           path_signature_table[uint8_t(input[i + 1])] |
   88|  49.1k|                           path_signature_table[uint8_t(input[i + 2])] |
   89|  49.1k|                           path_signature_table[uint8_t(input[i + 3])] |
   90|  49.1k|                           path_signature_table[uint8_t(input[i + 4])] |
   91|  49.1k|                           path_signature_table[uint8_t(input[i + 5])] |
   92|  49.1k|                           path_signature_table[uint8_t(input[i + 6])] |
   93|  49.1k|                           path_signature_table[uint8_t(input[i + 7])]);
   94|  49.1k|  }
   95|  56.8k|  for (; i < input.size(); i++) {
  ------------------
  |  Branch (95:10): [True: 36.1k, False: 20.6k]
  ------------------
   96|  36.1k|    accumulator |= uint8_t(path_signature_table[uint8_t(input[i])]);
   97|  36.1k|  }
   98|  20.6k|  return accumulator;
   99|  20.6k|}
_ZN3ada7unicode26is_double_dot_path_segmentENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 7383|  59.7k|    std::string_view input) noexcept {
 7384|       |  // This will catch most cases:
 7385|       |  // The length must be 2,4 or 6.
 7386|       |  // We divide by two and require
 7387|       |  // that the result be between 1 and 3 inclusively.
 7388|  59.7k|  uint64_t half_length = uint64_t(input.size()) / 2;
 7389|  59.7k|  if (half_length - 1 > 2) {
  ------------------
  |  Branch (7389:7): [True: 34.0k, False: 25.6k]
  ------------------
 7390|  34.0k|    return false;
 7391|  34.0k|  }
 7392|       |  // We have a string of length 2, 4 or 6.
 7393|       |  // We now check the first character:
 7394|  25.6k|  if ((input[0] != '.') && (input[0] != '%')) {
  ------------------
  |  Branch (7394:7): [True: 12.1k, False: 13.5k]
  |  Branch (7394:28): [True: 5.25k, False: 6.91k]
  ------------------
 7395|  5.25k|    return false;
 7396|  5.25k|  }
 7397|       |  // We are unlikely the get beyond this point.
 7398|  20.4k|  int hash_value = (input.size() + (unsigned)(input[0])) & 3;
 7399|  20.4k|  const std::string_view target = table_is_double_dot_path_segment[hash_value];
 7400|  20.4k|  if (target.size() != input.size()) {
  ------------------
  |  Branch (7400:7): [True: 5.67k, False: 14.7k]
  ------------------
 7401|  5.67k|    return false;
 7402|  5.67k|  }
 7403|       |  // We almost never get here.
 7404|       |  // Optimizing the rest is relatively unimportant.
 7405|  14.7k|  auto prefix_equal_unsafe = [](std::string_view a, std::string_view b) {
 7406|  14.7k|    uint16_t A, B;
 7407|  14.7k|    memcpy(&A, a.data(), sizeof(A));
 7408|  14.7k|    memcpy(&B, b.data(), sizeof(B));
 7409|  14.7k|    return A == B;
 7410|  14.7k|  };
 7411|  14.7k|  if (!prefix_equal_unsafe(input, target)) {
  ------------------
  |  Branch (7411:7): [True: 3.02k, False: 11.7k]
  ------------------
 7412|  3.02k|    return false;
 7413|  3.02k|  }
 7414|  16.8k|  for (size_t i = 2; i < input.size(); i++) {
  ------------------
  |  Branch (7414:22): [True: 8.06k, False: 8.77k]
  ------------------
 7415|  8.06k|    char c = input[i];
 7416|  8.06k|    if ((uint8_t((c | 0x20) - 0x61) <= 25 ? (c | 0x20) : c) != target[i]) {
  ------------------
  |  Branch (7416:9): [True: 2.94k, False: 5.11k]
  |  Branch (7416:10): [True: 3.93k, False: 4.12k]
  ------------------
 7417|  2.94k|      return false;
 7418|  2.94k|    }
 7419|  8.06k|  }
 7420|  8.77k|  return true;
 7421|       |  // The above code might be a bit better than the code below. Compilers
 7422|       |  // are not stupid and may use the fact that these strings have length 2,4 and
 7423|       |  // 6 and other tricks.
 7424|       |  // return input == ".." ||
 7425|       |  //  input == ".%2e" || input == ".%2E" ||
 7426|       |  //  input == "%2e." || input == "%2E." ||
 7427|       |  //  input == "%2e%2e" || input == "%2E%2E" || input == "%2E%2e" || input ==
 7428|       |  //  "%2e%2E";
 7429|  11.7k|}
_ZZN3ada7unicode26is_double_dot_path_segmentENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEENKUlS5_S5_E_clES5_S5_:
 7405|  14.7k|  auto prefix_equal_unsafe = [](std::string_view a, std::string_view b) {
 7406|  14.7k|    uint16_t A, B;
 7407|  14.7k|    memcpy(&A, a.data(), sizeof(A));
 7408|  14.7k|    memcpy(&B, b.data(), sizeof(B));
 7409|  14.7k|    return A == B;
 7410|  14.7k|  };
_ZN3ada7unicode26is_single_dot_path_segmentENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 7432|   101k|    std::string_view input) noexcept {
 7433|   101k|  return input == "." || input == "%2e" || input == "%2E";
  ------------------
  |  Branch (7433:10): [True: 3.59k, False: 98.1k]
  |  Branch (7433:26): [True: 1.50k, False: 96.6k]
  |  Branch (7433:44): [True: 0, False: 96.6k]
  ------------------
 7434|   101k|}
_ZN3ada7unicode28is_forbidden_host_code_pointEc:
 7253|  70.8k|    const char c) noexcept {
 7254|  70.8k|  return is_forbidden_host_code_point_table[uint8_t(c)];
 7255|  70.8k|}
_ZN3ada6detail17parse_ipv4_numberERPKcS2_RmRb:
 9829|  6.79k|                              bool& is_pure_decimal) noexcept {
 9830|  6.79k|  is_pure_decimal = false;
 9831|  6.79k|  if (p >= end) [[unlikely]] {
  ------------------
  |  Branch (9831:7): [True: 0, False: 6.79k]
  ------------------
 9832|      0|    return false;
 9833|      0|  }
 9834|  6.79k|  if (end - p >= 2 && p[0] == '0' && ((p[1] | 0x20) == 'x')) {
  ------------------
  |  Branch (9834:7): [True: 4.43k, False: 2.36k]
  |  Branch (9834:23): [True: 2.23k, False: 2.19k]
  |  Branch (9834:38): [True: 1.42k, False: 807]
  ------------------
 9835|  1.42k|    p += 2;
 9836|  1.42k|    if (p == end || *p == '.') {
  ------------------
  |  Branch (9836:9): [True: 243, False: 1.18k]
  |  Branch (9836:21): [True: 69, False: 1.11k]
  ------------------
 9837|    312|      value = 0;
 9838|    312|      return true;
 9839|    312|    }
 9840|  1.11k|    uint64_t v = 0;
 9841|  1.11k|    int digits = 0;
 9842|  7.19k|    while (p < end && *p != '.') {
  ------------------
  |  Branch (9842:12): [True: 6.46k, False: 732]
  |  Branch (9842:23): [True: 6.36k, False: 102]
  ------------------
 9843|  6.36k|      const uint8_t nib = hex_nibble[static_cast<unsigned char>(*p)];
 9844|  6.36k|      if (nib == 0xff) [[unlikely]] {
  ------------------
  |  Branch (9844:11): [True: 21, False: 6.34k]
  ------------------
 9845|     21|        return false;
 9846|     21|      }
 9847|  6.34k|      if (v > (0xFFFFFFFFULL >> 4)) [[unlikely]] {
  ------------------
  |  Branch (9847:11): [True: 261, False: 6.08k]
  ------------------
 9848|    261|        return false;
 9849|    261|      }
 9850|  6.08k|      v = (v << 4) | nib;
 9851|  6.08k|      ++p;
 9852|  6.08k|      ++digits;
 9853|  6.08k|    }
 9854|    834|    if (digits == 0) [[unlikely]] {
  ------------------
  |  Branch (9854:9): [True: 0, False: 834]
  ------------------
 9855|      0|      return false;
 9856|      0|    }
 9857|    834|    value = v;
 9858|    834|    return true;
 9859|    834|  }
 9860|  5.36k|  if (end - p >= 2 && p[0] == '0' && p[1] >= '0' && p[1] <= '9') {
  ------------------
  |  Branch (9860:7): [True: 3.00k, False: 2.36k]
  |  Branch (9860:23): [True: 807, False: 2.19k]
  |  Branch (9860:38): [True: 498, False: 309]
  |  Branch (9860:53): [True: 477, False: 21]
  ------------------
 9861|    477|    ++p;
 9862|    477|    uint64_t v = 0;
 9863|  3.56k|    while (p < end && *p != '.') {
  ------------------
  |  Branch (9863:12): [True: 3.26k, False: 297]
  |  Branch (9863:23): [True: 3.17k, False: 90]
  ------------------
 9864|  3.17k|      const char c = *p;
 9865|  3.17k|      if (c < '0' || c > '7') [[unlikely]] {
  ------------------
  |  Branch (9865:11): [True: 12, False: 3.16k]
  |  Branch (9865:22): [True: 48, False: 3.11k]
  ------------------
 9866|     60|        return false;
 9867|     60|      }
 9868|  3.11k|      if (v > (0xFFFFFFFFULL >> 3)) [[unlikely]] {
  ------------------
  |  Branch (9868:11): [True: 30, False: 3.08k]
  ------------------
 9869|     30|        return false;
 9870|     30|      }
 9871|  3.08k|      v = (v << 3) | static_cast<uint64_t>(c - '0');
 9872|  3.08k|      ++p;
 9873|  3.08k|    }
 9874|    387|    value = v;
 9875|    387|    return true;
 9876|    477|  }
 9877|  4.88k|  if (*p < '0' || *p > '9') [[unlikely]] {
  ------------------
  |  Branch (9877:7): [True: 123, False: 4.76k]
  |  Branch (9877:19): [True: 309, False: 4.45k]
  ------------------
 9878|    432|    return false;
 9879|    432|  }
 9880|  4.45k|  is_pure_decimal = true;
 9881|  4.45k|  uint64_t v = static_cast<uint64_t>(*p - '0');
 9882|  4.45k|  ++p;
 9883|  8.86k|  while (p < end && *p != '.') {
  ------------------
  |  Branch (9883:10): [True: 5.75k, False: 3.11k]
  |  Branch (9883:21): [True: 4.58k, False: 1.17k]
  ------------------
 9884|  4.58k|    const char c = *p;
 9885|  4.58k|    if (c < '0' || c > '9') [[unlikely]] {
  ------------------
  |  Branch (9885:9): [True: 24, False: 4.55k]
  |  Branch (9885:20): [True: 57, False: 4.50k]
  ------------------
 9886|     81|      return false;
 9887|     81|    }
 9888|  4.50k|    if (v > 429496729ULL) [[unlikely]] {
  ------------------
  |  Branch (9888:9): [True: 78, False: 4.42k]
  ------------------
 9889|     78|      return false;
 9890|     78|    }
 9891|  4.42k|    v = v * 10u + static_cast<uint64_t>(c - '0');
 9892|  4.42k|    if (v > 0xFFFFFFFFULL) [[unlikely]] {
  ------------------
  |  Branch (9892:9): [True: 12, False: 4.41k]
  ------------------
 9893|     12|      return false;
 9894|     12|    }
 9895|  4.41k|    ++p;
 9896|  4.41k|  }
 9897|  4.28k|  value = v;
 9898|  4.28k|  return true;
 9899|  4.45k|}
_ZN3ada6detail15parse_hex_pieceERPKcS2_Rt:
 9903|  2.90k|                           uint16_t& value) noexcept {
 9904|  2.90k|  if (pointer == end) {
  ------------------
  |  Branch (9904:7): [True: 0, False: 2.90k]
  ------------------
 9905|      0|    return 0;
 9906|      0|  }
 9907|  2.90k|  const uint8_t n0 = hex_nibble[static_cast<unsigned char>(*pointer)];
 9908|  2.90k|  if (n0 == 0xff) {
  ------------------
  |  Branch (9908:7): [True: 126, False: 2.78k]
  ------------------
 9909|    126|    return 0;
 9910|    126|  }
 9911|  2.78k|  uint32_t v = n0;
 9912|  2.78k|  ++pointer;
 9913|  2.78k|  int length = 1;
 9914|  2.78k|  if (pointer != end) {
  ------------------
  |  Branch (9914:7): [True: 2.51k, False: 267]
  ------------------
 9915|  2.51k|    const uint8_t n1 = hex_nibble[static_cast<unsigned char>(*pointer)];
 9916|  2.51k|    if (n1 != 0xff) {
  ------------------
  |  Branch (9916:9): [True: 990, False: 1.52k]
  ------------------
 9917|    990|      v = (v << 4) | n1;
 9918|    990|      ++pointer;
 9919|    990|      ++length;
 9920|    990|      if (pointer != end) {
  ------------------
  |  Branch (9920:11): [True: 903, False: 87]
  ------------------
 9921|    903|        const uint8_t n2 = hex_nibble[static_cast<unsigned char>(*pointer)];
 9922|    903|        if (n2 != 0xff) {
  ------------------
  |  Branch (9922:13): [True: 594, False: 309]
  ------------------
 9923|    594|          v = (v << 4) | n2;
 9924|    594|          ++pointer;
 9925|    594|          ++length;
 9926|    594|          if (pointer != end) {
  ------------------
  |  Branch (9926:15): [True: 498, False: 96]
  ------------------
 9927|    498|            const uint8_t n3 = hex_nibble[static_cast<unsigned char>(*pointer)];
 9928|    498|            if (n3 != 0xff) {
  ------------------
  |  Branch (9928:17): [True: 258, False: 240]
  ------------------
 9929|    258|              v = (v << 4) | n3;
 9930|    258|              ++pointer;
 9931|    258|              ++length;
 9932|    258|            }
 9933|    498|          }
 9934|    594|        }
 9935|    903|      }
 9936|    990|    }
 9937|  2.51k|  }
 9938|  2.78k|  value = static_cast<uint16_t>(v);
 9939|  2.78k|  return length;
 9940|  2.90k|}
_ZN3ada3url10parse_pathENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
10515|  2.19k|ada_really_inline void url::parse_path(std::string_view input) {
10516|  2.19k|  ada_log("parse_path ", input);
10517|  2.19k|  std::string tmp_buffer;
10518|  2.19k|  std::string_view internal_input;
10519|  2.19k|  if (unicode::has_tabs_or_newline(input)) {
  ------------------
  |  Branch (10519:7): [True: 0, False: 2.19k]
  ------------------
10520|      0|    tmp_buffer = input;
10521|       |    // Optimization opportunity: Instead of copying and then pruning, we could
10522|       |    // just directly build the string from user_input.
10523|      0|    helpers::remove_ascii_tab_or_newline(tmp_buffer);
10524|      0|    internal_input = tmp_buffer;
10525|  2.19k|  } else {
10526|  2.19k|    internal_input = input;
10527|  2.19k|  }
10528|       |
10529|       |  // If url is special, then:
10530|  2.19k|  if (is_special()) {
  ------------------
  |  Branch (10530:7): [True: 2.19k, False: 0]
  ------------------
10531|  2.19k|    if (internal_input.empty()) {
  ------------------
  |  Branch (10531:9): [True: 111, False: 2.08k]
  ------------------
10532|    111|      path = "/";
10533|  2.08k|    } else if ((internal_input[0] == '/') || (internal_input[0] == '\\')) {
  ------------------
  |  Branch (10533:16): [True: 2.08k, False: 0]
  |  Branch (10533:46): [True: 0, False: 0]
  ------------------
10534|  2.08k|      helpers::parse_prepared_path(internal_input.substr(1), type, path);
10535|  2.08k|    } else {
10536|      0|      helpers::parse_prepared_path(internal_input, type, path);
10537|      0|    }
10538|  2.19k|  } else if (!internal_input.empty()) {
  ------------------
  |  Branch (10538:14): [True: 0, False: 0]
  ------------------
10539|      0|    if (internal_input[0] == '/') {
  ------------------
  |  Branch (10539:9): [True: 0, False: 0]
  ------------------
10540|      0|      helpers::parse_prepared_path(internal_input.substr(1), type, path);
10541|      0|    } else {
10542|      0|      helpers::parse_prepared_path(internal_input, type, path);
10543|      0|    }
10544|      0|  } else {
10545|      0|    if (!host.has_value()) {
  ------------------
  |  Branch (10545:9): [True: 0, False: 0]
  ------------------
10546|      0|      path = "/";
10547|      0|    }
10548|      0|  }
10549|  2.19k|}
_ZN3ada7unicode13is_alnum_plusEc:
 7347|   181k|ada_really_inline constexpr bool is_alnum_plus(const char c) noexcept {
 7348|   181k|  return is_alnum_plus_table[uint8_t(c)];
 7349|       |  // A table is almost surely much faster than the
 7350|       |  // following under most compilers: return
 7351|       |  // return (std::isalnum(c) || c == '+' || c == '-' || c == '.');
 7352|   181k|}
_ZN3ada7unicode14to_lower_asciiEPcm:
 7024|  39.5k|constexpr bool to_lower_ascii(char* input, size_t length) noexcept {
 7025|  39.5k|  uint64_t broadcast_80 = broadcast(0x80);
 7026|  39.5k|  uint64_t broadcast_Ap = broadcast(128 - 'A');
 7027|  39.5k|  uint64_t broadcast_Zp = broadcast(128 - 'Z' - 1);
 7028|  39.5k|  uint64_t non_ascii = 0;
 7029|  39.5k|  size_t i = 0;
 7030|       |
 7031|  49.4k|  for (; i + 7 < length; i += 8) {
  ------------------
  |  Branch (7031:10): [True: 9.87k, False: 39.5k]
  ------------------
 7032|  9.87k|    uint64_t word{};
 7033|  9.87k|    memcpy(&word, input + i, sizeof(word));
 7034|  9.87k|    non_ascii |= (word & broadcast_80);
 7035|  9.87k|    word ^=
 7036|  9.87k|        (((word + broadcast_Ap) ^ (word + broadcast_Zp)) & broadcast_80) >> 2;
 7037|  9.87k|    memcpy(input + i, &word, sizeof(word));
 7038|  9.87k|  }
 7039|  39.5k|  if (i < length) {
  ------------------
  |  Branch (7039:7): [True: 38.6k, False: 893]
  ------------------
 7040|  38.6k|    uint64_t word{};
 7041|  38.6k|    memcpy(&word, input + i, length - i);
 7042|  38.6k|    non_ascii |= (word & broadcast_80);
 7043|  38.6k|    word ^=
 7044|  38.6k|        (((word + broadcast_Ap) ^ (word + broadcast_Zp)) & broadcast_80) >> 2;
 7045|  38.6k|    memcpy(input + i, &word, length - i);
 7046|  38.6k|  }
 7047|  39.5k|  return non_ascii == 0;
 7048|  39.5k|}
_ZN3ada7unicode9broadcastEh:
 7020|   118k|constexpr uint64_t broadcast(uint8_t v) noexcept {
 7021|   118k|  return 0x101010101010101ull * v;
 7022|   118k|}
_ZZN3ada6parser25try_parse_simple_absoluteINS_3urlEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_ENKUlvE_clEv:
12524|  1.14k|    auto apply_query_and_hash = [&]() {
12525|  1.14k|      if (query_start != std::string_view::npos) {
  ------------------
  |  Branch (12525:11): [True: 101, False: 1.04k]
  ------------------
12526|    101|        const size_t q_end =
12527|    101|            (hash_start != std::string_view::npos) ? hash_start : len;
  ------------------
  |  Branch (12527:13): [True: 25, False: 76]
  ------------------
12528|    101|        out.update_base_search(std::string_view(input.data() + query_start + 1,
12529|    101|                                                q_end - query_start - 1),
12530|    101|                               character_sets::SPECIAL_QUERY_PERCENT_ENCODE);
12531|    101|      }
12532|  1.14k|      if (hash_start != std::string_view::npos) {
  ------------------
  |  Branch (12532:11): [True: 97, False: 1.04k]
  ------------------
12533|     97|        out.update_unencoded_base_hash(std::string_view(
12534|     97|            input.data() + hash_start + 1, len - hash_start - 1));
12535|     97|      }
12536|  1.14k|    };
_ZZN3ada6parser25try_parse_simple_absoluteINS_14url_aggregatorEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_ENKUlvE_clEv:
12524|  1.14k|    auto apply_query_and_hash = [&]() {
12525|  1.14k|      if (query_start != std::string_view::npos) {
  ------------------
  |  Branch (12525:11): [True: 101, False: 1.04k]
  ------------------
12526|    101|        const size_t q_end =
12527|    101|            (hash_start != std::string_view::npos) ? hash_start : len;
  ------------------
  |  Branch (12527:13): [True: 25, False: 76]
  ------------------
12528|    101|        out.update_base_search(std::string_view(input.data() + query_start + 1,
12529|    101|                                                q_end - query_start - 1),
12530|    101|                               character_sets::SPECIAL_QUERY_PERCENT_ENCODE);
12531|    101|      }
12532|  1.14k|      if (hash_start != std::string_view::npos) {
  ------------------
  |  Branch (12532:11): [True: 97, False: 1.04k]
  ------------------
12533|     97|        out.update_unencoded_base_hash(std::string_view(
12534|     97|            input.data() + hash_start + 1, len - hash_start - 1));
12535|     97|      }
12536|  1.14k|    };
_ZZN3ada6parser32finish_simple_absolute_with_portINS_3urlEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_NS_6scheme4typeEjmmmbENKUlvE_clEv:
12138|  1.05k|    auto apply_query_and_hash = [&]() {
12139|  1.05k|      if (query_start != std::string_view::npos) {
  ------------------
  |  Branch (12139:11): [True: 84, False: 971]
  ------------------
12140|     84|        const size_t q_end =
12141|     84|            (hash_start != std::string_view::npos) ? hash_start : len;
  ------------------
  |  Branch (12141:13): [True: 24, False: 60]
  ------------------
12142|     84|        out.update_base_search(std::string_view(input.data() + query_start + 1,
12143|     84|                                                q_end - query_start - 1),
12144|     84|                               character_sets::SPECIAL_QUERY_PERCENT_ENCODE);
12145|     84|      }
12146|  1.05k|      if (hash_start != std::string_view::npos) {
  ------------------
  |  Branch (12146:11): [True: 73, False: 982]
  ------------------
12147|     73|        out.update_unencoded_base_hash(std::string_view(
12148|     73|            input.data() + hash_start + 1, len - hash_start - 1));
12149|     73|      }
12150|  1.05k|    };
_ZZN3ada6parser32finish_simple_absolute_with_portINS_14url_aggregatorEEEbNSt3__117basic_string_viewIcNS3_11char_traitsIcEEEERT_NS_6scheme4typeEjmmmbENKUlvE_clEv:
12138|  1.05k|    auto apply_query_and_hash = [&]() {
12139|  1.05k|      if (query_start != std::string_view::npos) {
  ------------------
  |  Branch (12139:11): [True: 84, False: 971]
  ------------------
12140|     84|        const size_t q_end =
12141|     84|            (hash_start != std::string_view::npos) ? hash_start : len;
  ------------------
  |  Branch (12141:13): [True: 24, False: 60]
  ------------------
12142|     84|        out.update_base_search(std::string_view(input.data() + query_start + 1,
12143|     84|                                                q_end - query_start - 1),
12144|     84|                               character_sets::SPECIAL_QUERY_PERCENT_ENCODE);
12145|     84|      }
12146|  1.05k|      if (hash_start != std::string_view::npos) {
  ------------------
  |  Branch (12146:11): [True: 73, False: 982]
  ------------------
12147|     73|        out.update_unencoded_base_hash(std::string_view(
12148|     73|            input.data() + hash_start + 1, len - hash_start - 1));
12149|     73|      }
12150|  1.05k|    };
_ZN3ada7helpers10prune_hashERNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8782|   117k|    std::string_view& input) noexcept {
 8783|       |  // compiles down to 20--30 instructions including a class to memchr (C
 8784|       |  // function). this function should be quite fast.
 8785|   117k|  size_t location_of_first = input.find('#');
 8786|   117k|  if (location_of_first == std::string_view::npos) {
  ------------------
  |  Branch (8786:7): [True: 114k, False: 3.39k]
  ------------------
 8787|   114k|    return std::nullopt;
 8788|   114k|  }
 8789|  3.39k|  std::string_view hash = input;
 8790|  3.39k|  hash.remove_prefix(location_of_first + 1);
 8791|  3.39k|  input.remove_suffix(input.size() - location_of_first);
 8792|  3.39k|  return hash;
 8793|   117k|}
_ZZN3ada6parser14parse_url_implINS_3urlELb1EEET_NSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEPKS3_ENKUlvE_clEv:
12847|  18.8k|  const auto enforce_max_input_length = [&]() {
12848|  18.8k|    if constexpr (store_values) {
12849|  18.8k|      if (url.is_valid) {
  ------------------
  |  Branch (12849:11): [True: 18.8k, False: 0]
  ------------------
12850|       |        if constexpr (result_type_is_ada_url_aggregator) {
12851|       |          if (url.buffer.size() > max_input_length) [[unlikely]] {
12852|       |            url.is_valid = false;
12853|       |          }
12854|  18.8k|        } else {
12855|  18.8k|          if (url.get_href_size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (12855:15): [True: 0, False: 18.8k]
  ------------------
12856|      0|            url.is_valid = false;
12857|      0|          }
12858|  18.8k|        }
12859|  18.8k|      }
12860|  18.8k|    }
12861|  18.8k|  };
_ZN3ada7helpers32find_authority_delimiter_specialENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9740|  20.6k|find_authority_delimiter_special(std::string_view view) noexcept {
 9741|       |  // performance note: we might be able to gain further performance
 9742|       |  // with SIMD intrinsics.
 9743|   137k|  for (auto pos = view.begin(); pos != view.end(); ++pos) {
  ------------------
  |  Branch (9743:33): [True: 135k, False: 2.00k]
  ------------------
 9744|   135k|    if (authority_delimiter_special[(uint8_t)*pos]) {
  ------------------
  |  Branch (9744:9): [True: 18.6k, False: 116k]
  ------------------
 9745|  18.6k|      return pos - view.begin();
 9746|  18.6k|    }
 9747|   135k|  }
 9748|  2.00k|  return size_t(view.size());
 9749|  20.6k|}
_ZN3ada7helpers24find_authority_delimiterENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9761|  2.19k|find_authority_delimiter(std::string_view view) noexcept {
 9762|       |  // performance note: we might be able to gain further performance
 9763|       |  // with SIMD instrinsics.
 9764|  35.9k|  for (auto pos = view.begin(); pos != view.end(); ++pos) {
  ------------------
  |  Branch (9764:33): [True: 35.6k, False: 324]
  ------------------
 9765|  35.6k|    if (authority_delimiter[(uint8_t)*pos]) {
  ------------------
  |  Branch (9765:9): [True: 1.86k, False: 33.7k]
  ------------------
 9766|  1.86k|      return pos - view.begin();
 9767|  1.86k|    }
 9768|  35.6k|  }
 9769|    324|  return size_t(view.size());
 9770|  2.19k|}
_ZN3ada7helpers12shorten_pathERNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS_6scheme4typeE:
 8795|  9.37k|ada_really_inline bool shorten_path(std::string& path, ada::scheme::type type) {
 8796|       |  // Let path be url's path.
 8797|       |  // If url's scheme is "file", path's size is 1, and path[0] is a normalized
 8798|       |  // Windows drive letter, then return.
 8799|  9.37k|  if (type == ada::scheme::type::FILE &&
  ------------------
  |  Branch (8799:7): [True: 2.90k, False: 6.47k]
  ------------------
 8800|  2.90k|      path.find('/', 1) == std::string_view::npos && !path.empty()) {
  ------------------
  |  Branch (8800:7): [True: 2.21k, False: 690]
  |  Branch (8800:54): [True: 1.44k, False: 762]
  ------------------
 8801|  1.44k|    if (checkers::is_normalized_windows_drive_letter(
  ------------------
  |  Branch (8801:9): [True: 738, False: 710]
  ------------------
 8802|  1.44k|            helpers::substring(path, 1))) {
 8803|    738|      return false;
 8804|    738|    }
 8805|  1.44k|  }
 8806|       |
 8807|       |  // Remove path's last item, if any.
 8808|  8.63k|  size_t last_delimiter = path.rfind('/');
 8809|  8.63k|  if (last_delimiter != std::string::npos) {
  ------------------
  |  Branch (8809:7): [True: 4.41k, False: 4.21k]
  ------------------
 8810|  4.41k|    path.erase(last_delimiter);
 8811|  4.41k|    return true;
 8812|  4.41k|  }
 8813|       |
 8814|  4.21k|  return false;
 8815|  8.63k|}
_ZN3ada7helpers27get_host_delimiter_locationEbRNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9456|  40.7k|    const bool is_special, std::string_view& view) noexcept {
 9457|       |  /**
 9458|       |   * The spec at https://url.spec.whatwg.org/#hostname-state expects us to
 9459|       |   * compute a variable called insideBrackets but this variable is only used
 9460|       |   * once, to check whether a ':' character was found outside brackets. Exact
 9461|       |   * text: "Otherwise, if c is U+003A (:) and insideBrackets is false, then:".
 9462|       |   * It is conceptually simpler and arguably more efficient to just return a
 9463|       |   * Boolean indicating whether ':' was found outside brackets.
 9464|       |   */
 9465|  40.7k|  const size_t view_size = view.size();
 9466|  40.7k|  size_t location = 0;
 9467|  40.7k|  bool found_colon = false;
 9468|       |  /**
 9469|       |   * Performance analysis:
 9470|       |   *
 9471|       |   * We are basically seeking the end of the hostname which can be indicated
 9472|       |   * by the end of the view, or by one of the characters ':', '/', '?', '\\'
 9473|       |   * (where '\\' is only applicable for special URLs). However, these must
 9474|       |   * appear outside a bracket range. E.g., if you have [something?]fd: then the
 9475|       |   * '?' does not count.
 9476|       |   *
 9477|       |   * So we can skip ahead to the next delimiter, as long as we include '[' in
 9478|       |   * the set of delimiters, and that we handle it first.
 9479|       |   *
 9480|       |   * So the trick is to have a fast function that locates the next delimiter.
 9481|       |   * Unless we find '[', then it only needs to be called once! Ideally, such a
 9482|       |   * function would be provided by the C++ standard library, but it seems that
 9483|       |   * find_first_of is not very fast, so we are forced to roll our own.
 9484|       |   *
 9485|       |   * We do not break into two loops for speed, but for clarity.
 9486|       |   */
 9487|  40.7k|  if (is_special) {
  ------------------
  |  Branch (9487:7): [True: 38.1k, False: 2.60k]
  ------------------
 9488|       |    // We move to the next delimiter.
 9489|  38.1k|    location = find_next_host_delimiter_special(view, location);
 9490|       |    // Unless we find '[' then we are going only going to have to call
 9491|       |    // find_next_host_delimiter_special once.
 9492|  41.5k|    for (; location < view_size;
  ------------------
  |  Branch (9492:12): [True: 22.2k, False: 19.2k]
  ------------------
 9493|  38.1k|         location = find_next_host_delimiter_special(view, location)) {
 9494|  22.2k|      if (view[location] == '[') {
  ------------------
  |  Branch (9494:11): [True: 3.56k, False: 18.7k]
  ------------------
 9495|  3.56k|        location = view.find(']', location);
 9496|  3.56k|        if (location == std::string_view::npos) {
  ------------------
  |  Branch (9496:13): [True: 159, False: 3.40k]
  ------------------
 9497|       |          // performance: view.find might get translated to a memchr, which
 9498|       |          // has no notion of std::string_view::npos, so the code does not
 9499|       |          // reflect the assembly.
 9500|    159|          location = view_size;
 9501|    159|          break;
 9502|    159|        }
 9503|  18.7k|      } else {
 9504|  18.7k|        found_colon = view[location] == ':';
 9505|  18.7k|        break;
 9506|  18.7k|      }
 9507|  22.2k|    }
 9508|  38.1k|  } else {
 9509|       |    // We move to the next delimiter.
 9510|  2.60k|    location = find_next_host_delimiter(view, location);
 9511|       |    // Unless we find '[' then we are going only going to have to call
 9512|       |    // find_next_host_delimiter_special once.
 9513|  4.26k|    for (; location < view_size;
  ------------------
  |  Branch (9513:12): [True: 2.49k, False: 1.77k]
  ------------------
 9514|  2.60k|         location = find_next_host_delimiter(view, location)) {
 9515|  2.49k|      if (view[location] == '[') {
  ------------------
  |  Branch (9515:11): [True: 1.73k, False: 759]
  ------------------
 9516|  1.73k|        location = view.find(']', location);
 9517|  1.73k|        if (location == std::string_view::npos) {
  ------------------
  |  Branch (9517:13): [True: 69, False: 1.66k]
  ------------------
 9518|       |          // performance: view.find might get translated to a memchr, which
 9519|       |          // has no notion of std::string_view::npos, so the code does not
 9520|       |          // reflect the assembly.
 9521|     69|          location = view_size;
 9522|     69|          break;
 9523|     69|        }
 9524|  1.73k|      } else {
 9525|    759|        found_colon = view[location] == ':';
 9526|    759|        break;
 9527|    759|      }
 9528|  2.49k|    }
 9529|  2.60k|  }
 9530|       |  // performance: remove_suffix may translate into a single instruction.
 9531|  40.7k|  view.remove_suffix(view_size - location);
 9532|  40.7k|  return {location, found_colon};
 9533|  40.7k|}
_ZN3ada7helpers32find_next_host_delimiter_specialENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEm:
 9046|  41.5k|    std::string_view view, size_t location) noexcept {
 9047|       |  // first check for short strings in which case we do it naively.
 9048|  41.5k|  if (view.size() - location < 16) {  // slow path
  ------------------
  |  Branch (9048:7): [True: 27.8k, False: 13.7k]
  ------------------
 9049|   148k|    for (size_t i = location; i < view.size(); i++) {
  ------------------
  |  Branch (9049:31): [True: 134k, False: 14.3k]
  ------------------
 9050|   134k|      if (view[i] == ':' || view[i] == '/' || view[i] == '\\' ||
  ------------------
  |  Branch (9050:11): [True: 5.10k, False: 129k]
  |  Branch (9050:29): [True: 6.14k, False: 123k]
  |  Branch (9050:47): [True: 33, False: 122k]
  ------------------
 9051|   122k|          view[i] == '?' || view[i] == '[') {
  ------------------
  |  Branch (9051:11): [True: 542, False: 122k]
  |  Branch (9051:29): [True: 1.62k, False: 120k]
  ------------------
 9052|  13.4k|        return i;
 9053|  13.4k|      }
 9054|   134k|    }
 9055|  14.3k|    return size_t(view.size());
 9056|  27.8k|  }
 9057|       |  // fast path for long strings (expected to be common)
 9058|  13.7k|  size_t i = location;
 9059|  13.7k|  const __m128i mask1 = _mm_set1_epi8(':');
 9060|  13.7k|  const __m128i mask2 = _mm_set1_epi8('/');
 9061|  13.7k|  const __m128i mask3 = _mm_set1_epi8('\\');
 9062|  13.7k|  const __m128i mask4 = _mm_set1_epi8('?');
 9063|  13.7k|  const __m128i mask5 = _mm_set1_epi8('[');
 9064|       |
 9065|  52.3k|  for (; i + 15 < view.size(); i += 16) {
  ------------------
  |  Branch (9065:10): [True: 44.4k, False: 7.90k]
  ------------------
 9066|  44.4k|    __m128i word = _mm_loadu_si128((const __m128i*)(view.data() + i));
 9067|  44.4k|    __m128i m1 = _mm_cmpeq_epi8(word, mask1);
 9068|  44.4k|    __m128i m2 = _mm_cmpeq_epi8(word, mask2);
 9069|  44.4k|    __m128i m3 = _mm_cmpeq_epi8(word, mask3);
 9070|  44.4k|    __m128i m4 = _mm_cmpeq_epi8(word, mask4);
 9071|  44.4k|    __m128i m5 = _mm_cmpeq_epi8(word, mask5);
 9072|  44.4k|    __m128i m = _mm_or_si128(
 9073|  44.4k|        _mm_or_si128(_mm_or_si128(m1, m2), _mm_or_si128(m3, m4)), m5);
 9074|  44.4k|    int mask = _mm_movemask_epi8(m);
 9075|  44.4k|    if (mask != 0) {
  ------------------
  |  Branch (9075:9): [True: 5.86k, False: 38.5k]
  ------------------
 9076|  5.86k|      return i + trailing_zeroes(mask);
 9077|  5.86k|    }
 9078|  44.4k|  }
 9079|  7.90k|  if (i < view.size()) {
  ------------------
  |  Branch (9079:7): [True: 7.28k, False: 617]
  ------------------
 9080|  7.28k|    __m128i word =
 9081|  7.28k|        _mm_loadu_si128((const __m128i*)(view.data() + view.length() - 16));
 9082|  7.28k|    __m128i m1 = _mm_cmpeq_epi8(word, mask1);
 9083|  7.28k|    __m128i m2 = _mm_cmpeq_epi8(word, mask2);
 9084|  7.28k|    __m128i m3 = _mm_cmpeq_epi8(word, mask3);
 9085|  7.28k|    __m128i m4 = _mm_cmpeq_epi8(word, mask4);
 9086|  7.28k|    __m128i m5 = _mm_cmpeq_epi8(word, mask5);
 9087|  7.28k|    __m128i m = _mm_or_si128(
 9088|  7.28k|        _mm_or_si128(_mm_or_si128(m1, m2), _mm_or_si128(m3, m4)), m5);
 9089|  7.28k|    int mask = _mm_movemask_epi8(m);
 9090|  7.28k|    if (mask != 0) {
  ------------------
  |  Branch (9090:9): [True: 2.97k, False: 4.31k]
  ------------------
 9091|  2.97k|      return view.length() - 16 + trailing_zeroes(mask);
 9092|  2.97k|    }
 9093|  7.28k|  }
 9094|  4.92k|  return size_t(view.length());
 9095|  7.90k|}
_ZN3ada7helpers15trailing_zeroesEj:
 8868|  10.2k|ada_really_inline int trailing_zeroes(uint32_t input_num) noexcept {
 8869|       |#ifdef ADA_REGULAR_VISUAL_STUDIO
 8870|       |  unsigned long ret;
 8871|       |  // Search the mask data from least significant bit (LSB)
 8872|       |  // to the most significant bit (MSB) for a set bit (1).
 8873|       |  _BitScanForward(&ret, input_num);
 8874|       |  return (int)ret;
 8875|       |#else   // ADA_REGULAR_VISUAL_STUDIO
 8876|  10.2k|  return __builtin_ctzl(input_num);
 8877|  10.2k|#endif  // ADA_REGULAR_VISUAL_STUDIO
 8878|  10.2k|}
_ZN3ada7helpers24find_next_host_delimiterENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEm:
 9322|  4.26k|                                                  size_t location) noexcept {
 9323|       |  // first check for short strings in which case we do it naively.
 9324|  4.26k|  if (view.size() - location < 16) {  // slow path
  ------------------
  |  Branch (9324:7): [True: 2.14k, False: 2.11k]
  ------------------
 9325|  5.83k|    for (size_t i = location; i < view.size(); i++) {
  ------------------
  |  Branch (9325:31): [True: 4.74k, False: 1.09k]
  ------------------
 9326|  4.74k|      if (view[i] == ':' || view[i] == '/' || view[i] == '?' ||
  ------------------
  |  Branch (9326:11): [True: 249, False: 4.49k]
  |  Branch (9326:29): [True: 174, False: 4.31k]
  |  Branch (9326:47): [True: 117, False: 4.20k]
  ------------------
 9327|  4.20k|          view[i] == '[') {
  ------------------
  |  Branch (9327:11): [True: 516, False: 3.68k]
  ------------------
 9328|  1.05k|        return i;
 9329|  1.05k|      }
 9330|  4.74k|    }
 9331|  1.09k|    return size_t(view.size());
 9332|  2.14k|  }
 9333|       |  // fast path for long strings (expected to be common)
 9334|  2.11k|  size_t i = location;
 9335|  2.11k|  const __m128i mask1 = _mm_set1_epi8(':');
 9336|  2.11k|  const __m128i mask2 = _mm_set1_epi8('/');
 9337|  2.11k|  const __m128i mask4 = _mm_set1_epi8('?');
 9338|  2.11k|  const __m128i mask5 = _mm_set1_epi8('[');
 9339|       |
 9340|  6.43k|  for (; i + 15 < view.size(); i += 16) {
  ------------------
  |  Branch (9340:10): [True: 5.66k, False: 768]
  ------------------
 9341|  5.66k|    __m128i word = _mm_loadu_si128((const __m128i*)(view.data() + i));
 9342|  5.66k|    __m128i m1 = _mm_cmpeq_epi8(word, mask1);
 9343|  5.66k|    __m128i m2 = _mm_cmpeq_epi8(word, mask2);
 9344|  5.66k|    __m128i m4 = _mm_cmpeq_epi8(word, mask4);
 9345|  5.66k|    __m128i m5 = _mm_cmpeq_epi8(word, mask5);
 9346|  5.66k|    __m128i m = _mm_or_si128(_mm_or_si128(m1, m2), _mm_or_si128(m4, m5));
 9347|  5.66k|    int mask = _mm_movemask_epi8(m);
 9348|  5.66k|    if (mask != 0) {
  ------------------
  |  Branch (9348:9): [True: 1.34k, False: 4.32k]
  ------------------
 9349|  1.34k|      return i + trailing_zeroes(mask);
 9350|  1.34k|    }
 9351|  5.66k|  }
 9352|    768|  if (i < view.size()) {
  ------------------
  |  Branch (9352:7): [True: 474, False: 294]
  ------------------
 9353|    474|    __m128i word =
 9354|    474|        _mm_loadu_si128((const __m128i*)(view.data() + view.length() - 16));
 9355|    474|    __m128i m1 = _mm_cmpeq_epi8(word, mask1);
 9356|    474|    __m128i m2 = _mm_cmpeq_epi8(word, mask2);
 9357|    474|    __m128i m4 = _mm_cmpeq_epi8(word, mask4);
 9358|    474|    __m128i m5 = _mm_cmpeq_epi8(word, mask5);
 9359|    474|    __m128i m = _mm_or_si128(_mm_or_si128(m1, m2), _mm_or_si128(m4, m5));
 9360|    474|    int mask = _mm_movemask_epi8(m);
 9361|    474|    if (mask != 0) {
  ------------------
  |  Branch (9361:9): [True: 87, False: 387]
  ------------------
 9362|     87|      return view.length() - 16 + trailing_zeroes(mask);
 9363|     87|    }
 9364|    474|  }
 9365|    681|  return size_t(view.length());
 9366|    768|}
_ZN3ada3url10parse_hostENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
10406|  15.2k|ada_really_inline bool url::parse_host(std::string_view input) {
10407|  15.2k|  ada_log("parse_host ", input, " [", input.size(), " bytes]");
10408|  15.2k|  if (input.empty()) {
  ------------------
  |  Branch (10408:7): [True: 19, False: 15.1k]
  ------------------
10409|     19|    return is_valid = false;
10410|     19|  }  // technically unnecessary.
10411|       |  // If input starts with U+005B ([), then:
10412|  15.1k|  if (input[0] == '[') {
  ------------------
  |  Branch (10412:7): [True: 678, False: 14.5k]
  ------------------
10413|       |    // If input does not end with U+005D (]), validation error, return failure.
10414|    678|    if (input.back() != ']') {
  ------------------
  |  Branch (10414:9): [True: 160, False: 518]
  ------------------
10415|    160|      return is_valid = false;
10416|    160|    }
10417|    518|    ada_log("parse_host ipv6");
10418|       |
10419|       |    // Return the result of IPv6 parsing input with its leading U+005B ([) and
10420|       |    // trailing U+005D (]) removed.
10421|    518|    input.remove_prefix(1);
10422|    518|    input.remove_suffix(1);
10423|    518|    return parse_ipv6(input);
10424|    678|  }
10425|       |
10426|       |  // If isNotSpecial is true, then return the result of opaque-host parsing
10427|       |  // input.
10428|  14.5k|  if (!is_special()) {
  ------------------
  |  Branch (10428:7): [True: 598, False: 13.9k]
  ------------------
10429|    598|    return parse_opaque_host(input);
10430|    598|  }
10431|       |
10432|       |  // Fast path: try to parse as pure decimal IPv4 first.
10433|  13.9k|  const uint64_t fast_result = checkers::try_parse_ipv4_fast(input);
10434|  13.9k|  if (fast_result < checkers::ipv4_fast_fail) {
  ------------------
  |  Branch (10434:7): [True: 937, False: 12.9k]
  ------------------
10435|    937|    if (!input.empty() && input.back() == '.') {
  ------------------
  |  Branch (10435:9): [True: 937, False: 0]
  |  Branch (10435:27): [True: 24, False: 913]
  ------------------
10436|     24|      host = input.substr(0, input.size() - 1);
10437|    913|    } else {
10438|    913|      host = input;
10439|    913|    }
10440|    937|    host_type = IPV4;
10441|    937|    is_valid = true;
10442|    937|    ada_log("parse_host fast path decimal ipv4");
10443|    937|    return true;
10444|    937|  }
10445|       |  // Let domain be the result of running UTF-8 decode without BOM on the
10446|       |  // percent-decoding of input. Let asciiDomain be the result of running domain
10447|       |  // to ASCII with domain and false. The most common case is an ASCII input, in
10448|       |  // which case we do not need to call the expensive 'to_ascii' if a few
10449|       |  // conditions are met: no '%' and no 'xn-' subsequence.
10450|  12.9k|  const uint8_t forbidden_or_upper =
10451|  12.9k|      unicode::contains_forbidden_domain_code_point_or_upper(input.data(),
10452|  12.9k|                                                             input.size());
10453|  12.9k|  static constexpr std::string_view xn_dash{"xn-", 3};
10454|  12.9k|  if ((forbidden_or_upper & 1) == 0) {
  ------------------
  |  Branch (10454:7): [True: 7.72k, False: 5.24k]
  ------------------
10455|  7.72k|    host = std::string(input);
10456|  7.72k|    if ((forbidden_or_upper & 2) != 0) {
  ------------------
  |  Branch (10456:9): [True: 1.36k, False: 6.36k]
  ------------------
10457|  1.36k|      unicode::to_lower_ascii(host->data(), host->size());
10458|  1.36k|    }
10459|  7.72k|    if (host->find('-') == std::string_view::npos ||
  ------------------
  |  Branch (10459:9): [True: 5.51k, False: 2.21k]
  ------------------
10460|  5.82k|        host->find(xn_dash) == std::string_view::npos) {
  ------------------
  |  Branch (10460:9): [True: 311, False: 1.89k]
  ------------------
10461|  5.82k|      if (checkers::is_ipv4(*host)) {
  ------------------
  |  Branch (10461:11): [True: 1.38k, False: 4.44k]
  ------------------
10462|  1.38k|        ada_log("parse_host fast path ipv4");
10463|  1.38k|        return parse_ipv4(*host);
10464|  1.38k|      }
10465|  4.44k|      ada_log("parse_host fast path ", *host);
10466|  4.44k|      is_valid = true;
10467|  4.44k|      return true;
10468|  5.82k|    }
10469|  7.72k|  } else if (const size_t first_percent = input.find('%');
10470|  5.24k|             first_percent != std::string_view::npos) {
  ------------------
  |  Branch (10470:14): [True: 971, False: 4.26k]
  ------------------
10471|    971|    std::string decoded = unicode::percent_decode(input, first_percent);
10472|    971|    const uint8_t decoded_flags =
10473|    971|        unicode::contains_forbidden_domain_code_point_or_upper(decoded.data(),
10474|    971|                                                               decoded.size());
10475|    971|    if ((decoded_flags & 1) == 0) {
  ------------------
  |  Branch (10475:9): [True: 643, False: 328]
  ------------------
10476|    643|      if ((decoded_flags & 2) != 0) {
  ------------------
  |  Branch (10476:11): [True: 291, False: 352]
  ------------------
10477|    291|        unicode::to_lower_ascii(decoded.data(), decoded.size());
10478|    291|      }
10479|    643|      if (decoded.find('-') == std::string_view::npos ||
  ------------------
  |  Branch (10479:11): [True: 545, False: 98]
  ------------------
10480|    597|          decoded.find(xn_dash) == std::string_view::npos) {
  ------------------
  |  Branch (10480:11): [True: 52, False: 46]
  ------------------
10481|    597|        host = std::move(decoded);
10482|    597|        if (checkers::is_ipv4(*host)) {
  ------------------
  |  Branch (10482:13): [True: 255, False: 342]
  ------------------
10483|    255|          return parse_ipv4(*host);
10484|    255|        }
10485|    342|        is_valid = true;
10486|    342|        return true;
10487|    597|      }
10488|    643|    }
10489|    971|  }
10490|  6.54k|  ada_log("parse_host calling to_ascii");
10491|  6.54k|  is_valid = ada::unicode::to_ascii(host, input, input.find('%'));
10492|  6.54k|  if (!is_valid || !host.has_value()) {
  ------------------
  |  Branch (10492:7): [True: 1.92k, False: 4.61k]
  |  Branch (10492:20): [True: 0, False: 4.61k]
  ------------------
10493|  1.92k|    ada_log("parse_host to_ascii returns false");
10494|  1.92k|    return is_valid = false;
10495|  1.92k|  }
10496|  4.61k|  ada_log("parse_host to_ascii succeeded ", *host, " [", host->size(),
10497|  4.61k|          " bytes]");
10498|       |
10499|  4.61k|  if (std::any_of(host->begin(), host->end(),
  ------------------
  |  Branch (10499:7): [True: 0, False: 4.61k]
  ------------------
10500|  4.61k|                  ada::unicode::is_forbidden_domain_code_point)) {
10501|      0|    host = std::nullopt;
10502|      0|    return is_valid = false;
10503|      0|  }
10504|       |
10505|       |  // If asciiDomain ends in a number, then return the result of IPv4 parsing
10506|       |  // asciiDomain.
10507|  4.61k|  if (checkers::is_ipv4(*host)) {
  ------------------
  |  Branch (10507:7): [True: 201, False: 4.41k]
  ------------------
10508|    201|    ada_log("parse_host got ipv4 ", *host);
10509|    201|    return parse_ipv4(*host);
10510|    201|  }
10511|       |
10512|  4.41k|  return true;
10513|  4.61k|}
_ZN3ada7unicode45contains_forbidden_domain_code_point_or_upperEPKcm:
 7317|  42.5k|                                              size_t length) noexcept {
 7318|  42.5k|  size_t i = 0;
 7319|  42.5k|  uint8_t accumulator{};
 7320|   276k|  for (; i + 4 <= length; i += 4) {
  ------------------
  |  Branch (7320:10): [True: 234k, False: 42.5k]
  ------------------
 7321|   234k|    accumulator |=
 7322|   234k|        is_forbidden_domain_code_point_table_or_upper[uint8_t(input[i])];
 7323|   234k|    accumulator |=
 7324|   234k|        is_forbidden_domain_code_point_table_or_upper[uint8_t(input[i + 1])];
 7325|   234k|    accumulator |=
 7326|   234k|        is_forbidden_domain_code_point_table_or_upper[uint8_t(input[i + 2])];
 7327|   234k|    accumulator |=
 7328|   234k|        is_forbidden_domain_code_point_table_or_upper[uint8_t(input[i + 3])];
 7329|   234k|  }
 7330|   104k|  for (; i < length; i++) {
  ------------------
  |  Branch (7330:10): [True: 61.8k, False: 42.5k]
  ------------------
 7331|  61.8k|    accumulator |=
 7332|  61.8k|        is_forbidden_domain_code_point_table_or_upper[uint8_t(input[i])];
 7333|  61.8k|  }
 7334|  42.5k|  return accumulator;
 7335|  42.5k|}
_ZN3ada7unicode30is_forbidden_domain_code_pointEc:
 7276|  1.05M|    const char c) noexcept {
 7277|  1.05M|  return is_forbidden_domain_code_point_table[uint8_t(c)];
 7278|  1.05M|}
_ZN3ada7helpers6resizeERNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEm:
 8861|     22|ada_really_inline void resize(std::string_view& input, size_t pos) noexcept {
 8862|     22|  ADA_ASSERT_TRUE(pos <= input.size());
 8863|     22|  input.remove_suffix(input.size() - pos);
 8864|     22|}
_ZZN3ada6parser14parse_url_implINS_14url_aggregatorELb1EEET_NSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEPKS3_ENKUlvE_clEv:
12847|  18.8k|  const auto enforce_max_input_length = [&]() {
12848|  18.8k|    if constexpr (store_values) {
12849|  18.8k|      if (url.is_valid) {
  ------------------
  |  Branch (12849:11): [True: 18.8k, False: 0]
  ------------------
12850|  18.8k|        if constexpr (result_type_is_ada_url_aggregator) {
12851|  18.8k|          if (url.buffer.size() > max_input_length) [[unlikely]] {
  ------------------
  |  Branch (12851:15): [True: 0, False: 18.8k]
  ------------------
12852|      0|            url.is_valid = false;
12853|      0|          }
12854|       |        } else {
12855|       |          if (url.get_href_size() > max_input_length) [[unlikely]] {
12856|       |            url.is_valid = false;
12857|       |          }
12858|       |        }
12859|  18.8k|      }
12860|  18.8k|    }
12861|  18.8k|  };
_ZN3ada7helpers12shorten_pathERNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEENS_6scheme4typeE:
 8818|  1.34k|                                    ada::scheme::type type) {
 8819|       |  // Let path be url's path.
 8820|       |  // If url's scheme is "file", path's size is 1, and path[0] is a normalized
 8821|       |  // Windows drive letter, then return.
 8822|  1.34k|  if (type == ada::scheme::type::FILE &&
  ------------------
  |  Branch (8822:7): [True: 152, False: 1.19k]
  ------------------
 8823|    152|      path.find('/', 1) == std::string_view::npos && !path.empty()) {
  ------------------
  |  Branch (8823:7): [True: 132, False: 20]
  |  Branch (8823:54): [True: 56, False: 76]
  ------------------
 8824|     56|    if (checkers::is_normalized_windows_drive_letter(
  ------------------
  |  Branch (8824:9): [True: 2, False: 54]
  ------------------
 8825|     56|            helpers::substring(path, 1))) {
 8826|      2|      return false;
 8827|      2|    }
 8828|     56|  }
 8829|       |
 8830|       |  // Remove path's last item, if any.
 8831|  1.34k|  if (!path.empty()) {
  ------------------
  |  Branch (8831:7): [True: 589, False: 758]
  ------------------
 8832|    589|    size_t slash_loc = path.rfind('/');
 8833|    589|    if (slash_loc != std::string_view::npos) {
  ------------------
  |  Branch (8833:9): [True: 589, False: 0]
  ------------------
 8834|    589|      path.remove_suffix(path.size() - slash_loc);
 8835|    589|      return true;
 8836|    589|    }
 8837|    589|  }
 8838|       |
 8839|    758|  return false;
 8840|  1.34k|}
_ZZN3ada6parser14parse_url_implINS_14url_aggregatorELb0EEET_NSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEPKS3_ENKUlvE_clEv:
12847|    390|  const auto enforce_max_input_length = [&]() {
12848|       |    if constexpr (store_values) {
12849|       |      if (url.is_valid) {
12850|       |        if constexpr (result_type_is_ada_url_aggregator) {
12851|       |          if (url.buffer.size() > max_input_length) [[unlikely]] {
12852|       |            url.is_valid = false;
12853|       |          }
12854|       |        } else {
12855|       |          if (url.get_href_size() > max_input_length) [[unlikely]] {
12856|       |            url.is_valid = false;
12857|       |          }
12858|       |        }
12859|       |      }
12860|       |    }
12861|    390|  };
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_124port_decimal_digit_countEj:
11177|  2.37k|ada_really_inline uint32_t port_decimal_digit_count(uint32_t port) noexcept {
11178|  2.37k|  uint32_t digits = 1;
11179|  3.19k|  while (port >= 10) {
  ------------------
  |  Branch (11179:10): [True: 818, False: 2.37k]
  ------------------
11180|    818|    port /= 10;
11181|    818|    ++digits;
11182|    818|  }
11183|  2.37k|  return digits;
11184|  2.37k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_121append_canonical_portERNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEj:
11187|    664|                                             uint32_t port) {
11188|    664|  buffer += ':';
11189|    664|  char port_buf[5];
11190|    664|  auto [ptr, ec] = std::to_chars(port_buf, port_buf + 5, port);
11191|    664|  (void)ec;
11192|    664|  buffer.append(port_buf, static_cast<size_t>(ptr - port_buf));
11193|    664|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_116authority_has_atEPKhmm:
11335|  4.54k|                                        size_t n) noexcept {
11336|  4.54k|  const size_t rem = n - host_start;
11337|  4.54k|  if (rem == 0) {
  ------------------
  |  Branch (11337:7): [True: 0, False: 4.54k]
  ------------------
11338|      0|    return false;
11339|      0|  }
11340|       |#if ADA_NEON
11341|       |  if (rem >= 16) {
11342|       |    const uint8x16_t w = vld1q_u8(p + host_start);
11343|       |    const uint64_t at = neon_nibble_bits(vceqq_u8(w, vdupq_n_u8('@')));
11344|       |    if (at == 0) {
11345|       |      return false;
11346|       |    }
11347|       |    const uint64_t delim = neon_nibble_bits(vceqq_u8(w, vdupq_n_u8('/'))) |
11348|       |                           neon_nibble_bits(vceqq_u8(w, vdupq_n_u8('?'))) |
11349|       |                           neon_nibble_bits(vceqq_u8(w, vdupq_n_u8('#')));
11350|       |    return delim == 0 || std::countr_zero(at) < std::countr_zero(delim);
11351|       |  }
11352|       |#elif ADA_SSE2
11353|  4.54k|  if (rem >= 16) {
  ------------------
  |  Branch (11353:7): [True: 1.38k, False: 3.16k]
  ------------------
11354|  1.38k|    const __m128i w =
11355|  1.38k|        _mm_loadu_si128(reinterpret_cast<const __m128i*>(p + host_start));
11356|  1.38k|    const uint16_t at = static_cast<uint16_t>(
11357|  1.38k|        _mm_movemask_epi8(_mm_cmpeq_epi8(w, _mm_set1_epi8('@'))));
11358|  1.38k|    if (at == 0) {
  ------------------
  |  Branch (11358:9): [True: 1.30k, False: 78]
  ------------------
11359|  1.30k|      return false;
11360|  1.30k|    }
11361|     78|    const uint16_t delim = static_cast<uint16_t>(
11362|     78|        _mm_movemask_epi8(_mm_cmpeq_epi8(w, _mm_set1_epi8('/'))) |
11363|     78|        _mm_movemask_epi8(_mm_cmpeq_epi8(w, _mm_set1_epi8('?'))) |
11364|     78|        _mm_movemask_epi8(_mm_cmpeq_epi8(w, _mm_set1_epi8('#'))));
11365|     78|    return delim == 0 || std::countr_zero(at) < std::countr_zero(delim);
  ------------------
  |  Branch (11365:12): [True: 20, False: 58]
  |  Branch (11365:26): [True: 8, False: 50]
  ------------------
11366|  1.38k|  }
11367|  3.16k|#endif
11368|  3.16k|  const size_t lim = host_start + rem;
11369|  16.4k|  for (size_t i = host_start; i < lim; ++i) {
  ------------------
  |  Branch (11369:31): [True: 14.9k, False: 1.50k]
  ------------------
11370|  14.9k|    const uint8_t c = p[i];
11371|  14.9k|    if (c == '@') {
  ------------------
  |  Branch (11371:9): [True: 20, False: 14.9k]
  ------------------
11372|     20|      return true;
11373|     20|    }
11374|  14.9k|    if (c == '/' || c == '?' || c == '#') {
  ------------------
  |  Branch (11374:9): [True: 1.60k, False: 13.3k]
  |  Branch (11374:21): [True: 24, False: 13.3k]
  |  Branch (11374:33): [True: 14, False: 13.3k]
  ------------------
11375|  1.64k|      return false;
11376|  1.64k|    }
11377|  14.9k|  }
11378|  1.50k|  return false;
11379|  3.16k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_115scan_plain_hostEPKhmmRmRbS5_:
11400|  13.8k|                                     bool& has_x) noexcept {
11401|  13.8k|  has_upper = false;
11402|  13.8k|  has_x = false;
11403|  13.8k|  size_t i = start;
11404|  13.8k|#if ADA_PARSER_SSSE3
11405|  13.8k|  if (parser_use_ssse3() && (len - start >= 16)) {
  ------------------
  |  Branch (11405:7): [True: 13.8k, False: 0]
  |  Branch (11405:29): [True: 7.09k, False: 6.79k]
  ------------------
11406|  7.09k|    const __m128i lo_tbl = nibble_load(k_host_nibbles.low);
11407|  7.09k|    const __m128i hi_tbl = nibble_load(k_host_nibbles.high);
11408|  7.09k|    const __m128i x_splat = _mm_set1_epi8('x');
11409|  7.09k|    auto visit = [&](size_t at) noexcept -> bool {
11410|  7.09k|      const __m128i w =
11411|  7.09k|          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + at));
11412|  7.09k|      const int up = sse2_uppercase(w);
11413|  7.09k|      const int xs = _mm_movemask_epi8(_mm_cmpeq_epi8(w, x_splat));
11414|  7.09k|      const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);
11415|  7.09k|      if (mask == 0) {
11416|  7.09k|        if (up != 0) {
11417|  7.09k|          has_upper = true;
11418|  7.09k|        }
11419|  7.09k|        if (xs != 0) {
11420|  7.09k|          has_x = true;
11421|  7.09k|        }
11422|  7.09k|        return false;
11423|  7.09k|      }
11424|  7.09k|      const int hit = trailing_zeroes32(static_cast<uint32_t>(mask));
11425|  7.09k|      const int valid = (1 << hit) - 1;
11426|  7.09k|      if ((up & valid) != 0) {
11427|  7.09k|        has_upper = true;
11428|  7.09k|      }
11429|  7.09k|      if ((xs & valid) != 0) {
11430|  7.09k|        has_x = true;
11431|  7.09k|      }
11432|  7.09k|      end = at + static_cast<size_t>(hit);
11433|  7.09k|      return true;
11434|  7.09k|    };
11435|  12.5k|    for (; i + 32 <= len; i += 32) {
  ------------------
  |  Branch (11435:12): [True: 8.69k, False: 3.89k]
  ------------------
11436|  8.69k|      if (visit(i) || visit(i + 16)) {
  ------------------
  |  Branch (11436:11): [True: 2.99k, False: 5.70k]
  |  Branch (11436:23): [True: 206, False: 5.50k]
  ------------------
11437|  3.19k|        return k_host_class[b[end]] == 1;
11438|  3.19k|      }
11439|  8.69k|    }
11440|  5.24k|    for (; i + 16 <= len; i += 16) {
  ------------------
  |  Branch (11440:12): [True: 3.33k, False: 1.91k]
  ------------------
11441|  3.33k|      if (visit(i)) {
  ------------------
  |  Branch (11441:11): [True: 1.98k, False: 1.34k]
  ------------------
11442|  1.98k|        return k_host_class[b[end]] == 1;
11443|  1.98k|      }
11444|  3.33k|    }
11445|       |    // Overlapping tail only after a full 16-byte step so the window cannot
11446|       |    // start before `start` (a prior '/' would otherwise look like a host stop).
11447|  1.91k|    if (i > start && i < len) {
  ------------------
  |  Branch (11447:9): [True: 1.91k, False: 0]
  |  Branch (11447:22): [True: 1.83k, False: 76]
  ------------------
11448|  1.83k|      if (visit(len - 16) && end >= i) {
  ------------------
  |  Branch (11448:11): [True: 1.77k, False: 64]
  |  Branch (11448:30): [True: 1.77k, False: 0]
  ------------------
11449|  1.77k|        return k_host_class[b[end]] == 1;
11450|  1.77k|      }
11451|     64|      end = len;
11452|     64|      return true;
11453|  1.83k|    }
11454|  1.91k|  }
11455|       |#elif ADA_SSE2
11456|       |  const __m128i x_splat = _mm_set1_epi8('x');
11457|       |  for (; i + 32 <= len; i += 32) {
11458|       |    for (size_t off = 0; off < 32; off += 16) {
11459|       |      const __m128i w =
11460|       |          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i + off));
11461|       |      const int up = sse2_uppercase(w);
11462|       |      const int xs = _mm_movemask_epi8(_mm_cmpeq_epi8(w, x_splat));
11463|       |      const int mask = sse2_host_stop(w);
11464|       |      if (mask != 0) {
11465|       |        const int hit = trailing_zeroes32(static_cast<uint32_t>(mask));
11466|       |        const int valid = (1 << hit) - 1;
11467|       |        if ((up & valid) != 0) {
11468|       |          has_upper = true;
11469|       |        }
11470|       |        if ((xs & valid) != 0) {
11471|       |          has_x = true;
11472|       |        }
11473|       |        end = i + off + static_cast<size_t>(hit);
11474|       |        return k_host_class[b[end]] == 1;
11475|       |      }
11476|       |      if (up != 0) {
11477|       |        has_upper = true;
11478|       |      }
11479|       |      if (xs != 0) {
11480|       |        has_x = true;
11481|       |      }
11482|       |    }
11483|       |  }
11484|       |  for (; i + 16 <= len; i += 16) {
11485|       |    const __m128i w = _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));
11486|       |    const int up = sse2_uppercase(w);
11487|       |    const int xs = _mm_movemask_epi8(_mm_cmpeq_epi8(w, x_splat));
11488|       |    const int mask = sse2_host_stop(w);
11489|       |    if (mask != 0) {
11490|       |      const int hit = trailing_zeroes32(static_cast<uint32_t>(mask));
11491|       |      const int valid = (1 << hit) - 1;
11492|       |      if ((up & valid) != 0) {
11493|       |        has_upper = true;
11494|       |      }
11495|       |      if ((xs & valid) != 0) {
11496|       |        has_x = true;
11497|       |      }
11498|       |      end = i + static_cast<size_t>(hit);
11499|       |      return k_host_class[b[end]] == 1;
11500|       |    }
11501|       |    if (up != 0) {
11502|       |      has_upper = true;
11503|       |    }
11504|       |    if (xs != 0) {
11505|       |      has_x = true;
11506|       |    }
11507|       |  }
11508|       |#elif ADA_NEON
11509|       |  if (len - start >= 16) {
11510|       |    const uint8x16_t lo_tbl = vld1q_u8(k_host_nibbles.low);
11511|       |    const uint8x16_t hi_tbl = vld1q_u8(k_host_nibbles.high);
11512|       |    const uint8x16_t x_splat = vdupq_n_u8('x');
11513|       |    auto visit = [&](size_t at) noexcept -> bool {
11514|       |      const uint8x16_t w = vld1q_u8(b + at);
11515|       |      const uint64_t up = neon_uppercase(w);
11516|       |      const uint64_t xs = neon_nibble_bits(vceqq_u8(w, x_splat));
11517|       |      const uint64_t bits = neon_table_stop(w, lo_tbl, hi_tbl);
11518|       |      if (bits == 0) {
11519|       |        if (up != 0) {
11520|       |          has_upper = true;
11521|       |        }
11522|       |        if (xs != 0) {
11523|       |          has_x = true;
11524|       |        }
11525|       |        return false;
11526|       |      }
11527|       |      const size_t hit = static_cast<size_t>(trailing_zeroes64(bits)) >> 2;
11528|       |      const uint64_t valid = (hit == 0) ? 0 : (uint64_t{1} << (hit * 4)) - 1;
11529|       |      if ((up & valid) != 0) {
11530|       |        has_upper = true;
11531|       |      }
11532|       |      if ((xs & valid) != 0) {
11533|       |        has_x = true;
11534|       |      }
11535|       |      end = at + hit;
11536|       |      return true;
11537|       |    };
11538|       |    for (; i + 32 <= len; i += 32) {
11539|       |      if (visit(i) || visit(i + 16)) {
11540|       |        return k_host_class[b[end]] == 1;
11541|       |      }
11542|       |    }
11543|       |    for (; i + 16 <= len; i += 16) {
11544|       |      if (visit(i)) {
11545|       |        return k_host_class[b[end]] == 1;
11546|       |      }
11547|       |    }
11548|       |    if (i > start && i < len) {
11549|       |      if (visit(len - 16) && end >= i) {
11550|       |        return k_host_class[b[end]] == 1;
11551|       |      }
11552|       |      end = len;
11553|       |      return true;
11554|       |    }
11555|       |  }
11556|       |#endif
11557|  27.9k|  for (; i < len; ++i) {
  ------------------
  |  Branch (11557:10): [True: 27.5k, False: 310]
  ------------------
11558|  27.5k|    const uint8_t c = b[i];
11559|  27.5k|    const uint8_t cls = k_host_class[c];
11560|  27.5k|    if (cls == 1) {
  ------------------
  |  Branch (11560:9): [True: 6.39k, False: 21.2k]
  ------------------
11561|  6.39k|      end = i;
11562|  6.39k|      return true;
11563|  6.39k|    }
11564|  21.2k|    if (cls == 2) {
  ------------------
  |  Branch (11564:9): [True: 162, False: 21.0k]
  ------------------
11565|    162|      return false;
11566|    162|    }
11567|  21.0k|    if (c >= 'A' && c <= 'Z') {
  ------------------
  |  Branch (11567:9): [True: 12.7k, False: 8.33k]
  |  Branch (11567:21): [True: 792, False: 11.9k]
  ------------------
11568|    792|      has_upper = true;
11569|  20.2k|    } else if (c == 'x') {
  ------------------
  |  Branch (11569:16): [True: 2.93k, False: 17.3k]
  ------------------
11570|  2.93k|      has_x = true;
11571|  2.93k|    }
11572|  21.0k|  }
11573|    310|  end = len;
11574|    310|  return true;
11575|  6.86k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_116parser_use_ssse3Ev:
11385|  27.1k|ada_really_inline bool parser_use_ssse3() noexcept {
11386|  27.1k|#ifdef ADA_PARSER_NEED_SSSE3_TARGET
11387|  27.1k|  static const bool supported = __builtin_cpu_supports("ssse3") != 0;
11388|  27.1k|  return supported;
11389|       |#else
11390|       |  return true;
11391|       |#endif
11392|  27.1k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_111nibble_loadEPKh:
11216|  26.7k|ADA_PARSER_SIMD __m128i nibble_load(const uint8_t* t) noexcept {
11217|  26.7k|  return _mm_load_si128(reinterpret_cast<const __m128i*>(t));
11218|  26.7k|}
can_parse.cc:_ZZN3ada6parser12_GLOBAL__N_115scan_plain_hostEPKhmmRmRbS5_ENKUlmE_clEm:
11409|  19.5k|    auto visit = [&](size_t at) noexcept -> bool {
11410|  19.5k|      const __m128i w =
11411|  19.5k|          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + at));
11412|  19.5k|      const int up = sse2_uppercase(w);
11413|  19.5k|      const int xs = _mm_movemask_epi8(_mm_cmpeq_epi8(w, x_splat));
11414|  19.5k|      const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);
11415|  19.5k|      if (mask == 0) {
  ------------------
  |  Branch (11415:11): [True: 12.6k, False: 6.95k]
  ------------------
11416|  12.6k|        if (up != 0) {
  ------------------
  |  Branch (11416:13): [True: 840, False: 11.7k]
  ------------------
11417|    840|          has_upper = true;
11418|    840|        }
11419|  12.6k|        if (xs != 0) {
  ------------------
  |  Branch (11419:13): [True: 9.70k, False: 2.91k]
  ------------------
11420|  9.70k|          has_x = true;
11421|  9.70k|        }
11422|  12.6k|        return false;
11423|  12.6k|      }
11424|  6.95k|      const int hit = trailing_zeroes32(static_cast<uint32_t>(mask));
11425|  6.95k|      const int valid = (1 << hit) - 1;
11426|  6.95k|      if ((up & valid) != 0) {
  ------------------
  |  Branch (11426:11): [True: 714, False: 6.24k]
  ------------------
11427|    714|        has_upper = true;
11428|    714|      }
11429|  6.95k|      if ((xs & valid) != 0) {
  ------------------
  |  Branch (11429:11): [True: 1.32k, False: 5.63k]
  ------------------
11430|  1.32k|        has_x = true;
11431|  1.32k|      }
11432|  6.95k|      end = at + static_cast<size_t>(hit);
11433|  6.95k|      return true;
11434|  19.5k|    };
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_114sse2_uppercaseEDv2_x:
11303|  19.5k|ada_really_inline int sse2_uppercase(__m128i w) noexcept {
11304|  19.5k|  return _mm_movemask_epi8(_mm_and_si128(
11305|  19.5k|      _mm_cmpgt_epi8(w, _mm_set1_epi8(static_cast<char>('A' - 1))),
11306|  19.5k|      _mm_cmplt_epi8(w, _mm_set1_epi8(static_cast<char>('Z' + 1)))));
11307|  19.5k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_117ssse3_nibble_maskEDv2_xS2_S2_:
11223|  37.2k|                                          __m128i hi_tbl) noexcept {
11224|  37.2k|  const __m128i nibble = _mm_set1_epi8(0x0F);
11225|  37.2k|  const __m128i lo = _mm_and_si128(w, nibble);
11226|  37.2k|  const __m128i hi = _mm_and_si128(_mm_srli_epi16(w, 4), nibble);
11227|  37.2k|  const __m128i hit =
11228|  37.2k|      _mm_and_si128(_mm_shuffle_epi8(lo_tbl, lo), _mm_shuffle_epi8(hi_tbl, hi));
11229|  37.2k|  return _mm_movemask_epi8(_mm_cmpeq_epi8(hit, _mm_setzero_si128())) ^ 0xFFFF;
11230|  37.2k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_117trailing_zeroes32Ej:
11195|  11.1k|ada_really_inline int trailing_zeroes32(uint32_t input_num) noexcept {
11196|       |#ifdef ADA_REGULAR_VISUAL_STUDIO
11197|       |  unsigned long ret;
11198|       |  _BitScanForward(&ret, input_num);
11199|       |  return static_cast<int>(ret);
11200|       |#else
11201|  11.1k|  return __builtin_ctz(input_num);
11202|  11.1k|#endif
11203|  11.1k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_113scan_path_runEPKhRmmRb:
11635|  10.2k|                                   bool& maybe_dot_segment) noexcept {
11636|  10.2k|  const size_t run_start = i;
11637|  10.2k|#if ADA_PARSER_SSSE3
11638|  10.2k|  if (parser_use_ssse3() && (i + 16 <= len)) {
  ------------------
  |  Branch (11638:7): [True: 10.2k, False: 0]
  |  Branch (11638:29): [True: 4.53k, False: 5.72k]
  ------------------
11639|  4.53k|    const __m128i lo_tbl = nibble_load(k_path_nibbles.low);
11640|  4.53k|    const __m128i hi_tbl = nibble_load(k_path_nibbles.high);
11641|  7.50k|    for (; i + 32 <= len; i += 32) {
  ------------------
  |  Branch (11641:12): [True: 4.90k, False: 2.60k]
  ------------------
11642|  4.90k|      const __m128i w0 =
11643|  4.90k|          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));
11644|  4.90k|      const int m0 = ssse3_nibble_mask(w0, lo_tbl, hi_tbl);
11645|  4.90k|      if (m0 != 0) {
  ------------------
  |  Branch (11645:11): [True: 1.47k, False: 3.43k]
  ------------------
11646|  1.47k|        const int hit_bit = trailing_zeroes32(static_cast<uint32_t>(m0));
11647|  1.47k|        note_dots_in_window(b, i, run_start, w0, (1 << hit_bit) - 1,
11648|  1.47k|                            maybe_dot_segment);
11649|  1.47k|        i += static_cast<size_t>(hit_bit);
11650|  1.47k|        return;
11651|  1.47k|      }
11652|  3.43k|      note_dots_in_window(b, i, run_start, w0, 0xFFFF, maybe_dot_segment);
11653|  3.43k|      const __m128i w1 =
11654|  3.43k|          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i + 16));
11655|  3.43k|      const int m1 = ssse3_nibble_mask(w1, lo_tbl, hi_tbl);
11656|  3.43k|      if (m1 != 0) {
  ------------------
  |  Branch (11656:11): [True: 462, False: 2.96k]
  ------------------
11657|    462|        const int hit_bit = trailing_zeroes32(static_cast<uint32_t>(m1));
11658|    462|        note_dots_in_window(b, i + 16, run_start, w1, (1 << hit_bit) - 1,
11659|    462|                            maybe_dot_segment);
11660|    462|        i += 16 + static_cast<size_t>(hit_bit);
11661|    462|        return;
11662|    462|      }
11663|  2.96k|      note_dots_in_window(b, i + 16, run_start, w1, 0xFFFF, maybe_dot_segment);
11664|  2.96k|    }
11665|  3.76k|    for (; i + 16 <= len; i += 16) {
  ------------------
  |  Branch (11665:12): [True: 2.02k, False: 1.74k]
  ------------------
11666|  2.02k|      const __m128i w =
11667|  2.02k|          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));
11668|  2.02k|      const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);
11669|  2.02k|      if (mask != 0) {
  ------------------
  |  Branch (11669:11): [True: 858, False: 1.16k]
  ------------------
11670|    858|        const int hit_bit = trailing_zeroes32(static_cast<uint32_t>(mask));
11671|    858|        note_dots_in_window(b, i, run_start, w, (1 << hit_bit) - 1,
11672|    858|                            maybe_dot_segment);
11673|    858|        i += static_cast<size_t>(hit_bit);
11674|    858|        return;
11675|    858|      }
11676|  1.16k|      note_dots_in_window(b, i, run_start, w, 0xFFFF, maybe_dot_segment);
11677|  1.16k|    }
11678|  1.74k|    if (i > run_start && i < len) {
  ------------------
  |  Branch (11678:9): [True: 1.74k, False: 0]
  |  Branch (11678:26): [True: 1.06k, False: 678]
  ------------------
11679|  1.06k|      const __m128i w =
11680|  1.06k|          _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + len - 16));
11681|  1.06k|      const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);
11682|  1.06k|      if (mask != 0) {
  ------------------
  |  Branch (11682:11): [True: 408, False: 660]
  ------------------
11683|    408|        const size_t hit =
11684|    408|            len - 16 +
11685|    408|            static_cast<size_t>(trailing_zeroes32(static_cast<uint32_t>(mask)));
11686|    408|        if (hit >= i) {
  ------------------
  |  Branch (11686:13): [True: 408, False: 0]
  ------------------
11687|  2.15k|          for (size_t j = i; j < hit; ++j) {
  ------------------
  |  Branch (11687:30): [True: 1.74k, False: 408]
  ------------------
11688|  1.74k|            if (b[j] == '.') {
  ------------------
  |  Branch (11688:17): [True: 628, False: 1.12k]
  ------------------
11689|    628|              note_possible_dot_segment(b, j, run_start, maybe_dot_segment);
11690|    628|            }
11691|  1.74k|          }
11692|    408|          i = hit;
11693|    408|          return;
11694|    408|        }
11695|    408|      }
11696|  4.96k|      for (size_t j = i; j < len; ++j) {
  ------------------
  |  Branch (11696:26): [True: 4.30k, False: 660]
  ------------------
11697|  4.30k|        if (b[j] == '.') {
  ------------------
  |  Branch (11697:13): [True: 1.31k, False: 2.99k]
  ------------------
11698|  1.31k|          note_possible_dot_segment(b, j, run_start, maybe_dot_segment);
11699|  1.31k|        }
11700|  4.30k|      }
11701|    660|      i = len;
11702|    660|      return;
11703|  1.06k|    }
11704|  1.74k|  }
11705|       |#elif ADA_SSE2
11706|       |  for (; i + 16 <= len; i += 16) {
11707|       |    const __m128i w = _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));
11708|       |    const int mask = sse2_path_stop(w);
11709|       |    if (mask != 0) {
11710|       |      const int hit_bit = trailing_zeroes32(static_cast<uint32_t>(mask));
11711|       |      note_dots_in_window(b, i, run_start, w, (1 << hit_bit) - 1,
11712|       |                          maybe_dot_segment);
11713|       |      i += static_cast<size_t>(hit_bit);
11714|       |      return;
11715|       |    }
11716|       |    note_dots_in_window(b, i, run_start, w, 0xFFFF, maybe_dot_segment);
11717|       |  }
11718|       |#elif ADA_NEON
11719|       |  if (i + 16 <= len) {
11720|       |    const uint8x16_t lo_tbl = vld1q_u8(k_path_nibbles.low);
11721|       |    const uint8x16_t hi_tbl = vld1q_u8(k_path_nibbles.high);
11722|       |    for (; i + 32 <= len; i += 32) {
11723|       |      const uint8x16_t w0 = vld1q_u8(b + i);
11724|       |      const uint64_t bits0 = neon_table_stop(w0, lo_tbl, hi_tbl);
11725|       |      if (bits0 != 0) {
11726|       |        const size_t hit_off =
11727|       |            static_cast<size_t>(trailing_zeroes64(bits0)) >> 2;
11728|       |        const uint64_t valid =
11729|       |            (hit_off == 0) ? 0 : (uint64_t{1} << (hit_off * 4)) - 1;
11730|       |        note_dots_in_window_neon(b, i, run_start, w0, valid, maybe_dot_segment);
11731|       |        i += hit_off;
11732|       |        return;
11733|       |      }
11734|       |      note_dots_in_window_neon(b, i, run_start, w0, ~uint64_t{0},
11735|       |                               maybe_dot_segment);
11736|       |      const uint8x16_t w1 = vld1q_u8(b + i + 16);
11737|       |      const uint64_t bits1 = neon_table_stop(w1, lo_tbl, hi_tbl);
11738|       |      if (bits1 != 0) {
11739|       |        const size_t hit_off =
11740|       |            static_cast<size_t>(trailing_zeroes64(bits1)) >> 2;
11741|       |        const uint64_t valid =
11742|       |            (hit_off == 0) ? 0 : (uint64_t{1} << (hit_off * 4)) - 1;
11743|       |        note_dots_in_window_neon(b, i + 16, run_start, w1, valid,
11744|       |                                 maybe_dot_segment);
11745|       |        i += 16 + hit_off;
11746|       |        return;
11747|       |      }
11748|       |      note_dots_in_window_neon(b, i + 16, run_start, w1, ~uint64_t{0},
11749|       |                               maybe_dot_segment);
11750|       |    }
11751|       |    for (; i + 16 <= len; i += 16) {
11752|       |      const uint8x16_t w = vld1q_u8(b + i);
11753|       |      const uint64_t bits = neon_table_stop(w, lo_tbl, hi_tbl);
11754|       |      if (bits != 0) {
11755|       |        const size_t hit_off =
11756|       |            static_cast<size_t>(trailing_zeroes64(bits)) >> 2;
11757|       |        const uint64_t valid =
11758|       |            (hit_off == 0) ? 0 : (uint64_t{1} << (hit_off * 4)) - 1;
11759|       |        note_dots_in_window_neon(b, i, run_start, w, valid, maybe_dot_segment);
11760|       |        i += hit_off;
11761|       |        return;
11762|       |      }
11763|       |      note_dots_in_window_neon(b, i, run_start, w, ~uint64_t{0},
11764|       |                               maybe_dot_segment);
11765|       |    }
11766|       |    if (i > run_start && i < len) {
11767|       |      const uint8x16_t w = vld1q_u8(b + len - 16);
11768|       |      const uint64_t bits = neon_table_stop(w, lo_tbl, hi_tbl);
11769|       |      if (bits != 0) {
11770|       |        const size_t hit =
11771|       |            len - 16 + (static_cast<size_t>(trailing_zeroes64(bits)) >> 2);
11772|       |        if (hit >= i) {
11773|       |          for (size_t j = i; j < hit; ++j) {
11774|       |            if (b[j] == '.') {
11775|       |              note_possible_dot_segment(b, j, run_start, maybe_dot_segment);
11776|       |            }
11777|       |          }
11778|       |          i = hit;
11779|       |          return;
11780|       |        }
11781|       |      }
11782|       |      for (size_t j = i; j < len; ++j) {
11783|       |        if (b[j] == '.') {
11784|       |          note_possible_dot_segment(b, j, run_start, maybe_dot_segment);
11785|       |        }
11786|       |      }
11787|       |      i = len;
11788|       |      return;
11789|       |    }
11790|       |  }
11791|       |#endif
11792|  13.3k|  for (; i < len; ++i) {
  ------------------
  |  Branch (11792:10): [True: 9.02k, False: 4.33k]
  ------------------
11793|  9.02k|    const uint8_t c = b[i];
11794|  9.02k|    const uint8_t cls = k_path[c];
11795|  9.02k|    if (cls != 0) {
  ------------------
  |  Branch (11795:9): [True: 2.07k, False: 6.95k]
  ------------------
11796|  2.07k|      return;
11797|  2.07k|    }
11798|  6.95k|    if (c == '.') {
  ------------------
  |  Branch (11798:9): [True: 2.21k, False: 4.74k]
  ------------------
11799|  2.21k|      note_possible_dot_segment(b, i, run_start, maybe_dot_segment);
11800|  2.21k|    }
11801|  6.95k|  }
11802|  6.40k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_119note_dots_in_windowEPKhmmDv2_xiRb:
11592|  10.3k|                                           bool& maybe_dot_segment) noexcept {
11593|  10.3k|  if (maybe_dot_segment || valid_mask == 0) {
  ------------------
  |  Branch (11593:7): [True: 2.34k, False: 8.00k]
  |  Branch (11593:28): [True: 1.38k, False: 6.61k]
  ------------------
11594|  3.73k|    return;
11595|  3.73k|  }
11596|  6.61k|  const int dots =
11597|  6.61k|      _mm_movemask_epi8(_mm_cmpeq_epi8(w, _mm_set1_epi8('.'))) & valid_mask;
11598|  6.61k|  if (dots == 0) {
  ------------------
  |  Branch (11598:7): [True: 2.43k, False: 4.18k]
  ------------------
11599|  2.43k|    return;
11600|  2.43k|  }
11601|  4.18k|  const int slashes =
11602|  4.18k|      _mm_movemask_epi8(_mm_cmpeq_epi8(w, _mm_set1_epi8('/'))) & valid_mask;
11603|  4.18k|  if (((dots & 1) != 0 && (i == run_start || b[i - 1] == '/')) ||
  ------------------
  |  Branch (11603:8): [True: 1.79k, False: 2.38k]
  |  Branch (11603:28): [True: 562, False: 1.23k]
  |  Branch (11603:46): [True: 178, False: 1.05k]
  ------------------
11604|  3.44k|      (dots & (slashes << 1)) != 0) {
  ------------------
  |  Branch (11604:7): [True: 760, False: 2.68k]
  ------------------
11605|  1.50k|    maybe_dot_segment = true;
11606|  1.50k|  }
11607|  4.18k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_125note_possible_dot_segmentEPKhmmRb:
11579|  4.15k|    bool& maybe_dot_segment) noexcept {
11580|  4.15k|  if (pos == run_start || b[pos - 1] == '/') {
  ------------------
  |  Branch (11580:7): [True: 594, False: 3.55k]
  |  Branch (11580:27): [True: 1.51k, False: 2.04k]
  ------------------
11581|  2.10k|    maybe_dot_segment = true;
11582|  2.10k|  }
11583|  4.15k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_114scan_query_runEPKhRmm:
11945|  1.45k|                                    size_t len) noexcept {
11946|  1.45k|  ADA_SCAN_STOP_RUN(k_query_nibbles, k_query, sse2_query_stop);
  ------------------
  |  |11808|  1.45k|  do {                                                                       \
  |  |11809|  1.45k|    const size_t scan_start = i;                                             \
  |  |11810|  1.45k|    if (parser_use_ssse3() && (i + 16 <= len)) {                             \
  |  |  ------------------
  |  |  |  Branch (11810:9): [True: 1.45k, False: 0]
  |  |  |  Branch (11810:31): [True: 854, False: 600]
  |  |  ------------------
  |  |11811|    854|      const __m128i lo_tbl = nibble_load((nibbles).low);                     \
  |  |11812|    854|      const __m128i hi_tbl = nibble_load((nibbles).high);                    \
  |  |11813|  2.01k|      for (; i + 32 <= len; i += 32) {                                       \
  |  |  ------------------
  |  |  |  Branch (11813:14): [True: 1.48k, False: 534]
  |  |  ------------------
  |  |11814|  1.48k|        const __m128i w0 =                                                   \
  |  |11815|  1.48k|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));        \
  |  |11816|  1.48k|        const int m0 = ssse3_nibble_mask(w0, lo_tbl, hi_tbl);                \
  |  |11817|  1.48k|        if (m0 != 0) {                                                       \
  |  |  ------------------
  |  |  |  Branch (11817:13): [True: 206, False: 1.27k]
  |  |  ------------------
  |  |11818|    206|          i += static_cast<size_t>(                                          \
  |  |11819|    206|              trailing_zeroes32(static_cast<uint32_t>(m0)));                 \
  |  |11820|    206|          return;                                                            \
  |  |11821|    206|        }                                                                    \
  |  |11822|  1.48k|        const __m128i w1 =                                                   \
  |  |11823|  1.27k|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i + 16));   \
  |  |11824|  1.27k|        const int m1 = ssse3_nibble_mask(w1, lo_tbl, hi_tbl);                \
  |  |11825|  1.27k|        if (m1 != 0) {                                                       \
  |  |  ------------------
  |  |  |  Branch (11825:13): [True: 114, False: 1.16k]
  |  |  ------------------
  |  |11826|    114|          i += 16 + static_cast<size_t>(                                     \
  |  |11827|    114|                        trailing_zeroes32(static_cast<uint32_t>(m1)));       \
  |  |11828|    114|          return;                                                            \
  |  |11829|    114|        }                                                                    \
  |  |11830|  1.27k|      }                                                                      \
  |  |11831|    854|      for (; i + 16 <= len; i += 16) {                                       \
  |  |  ------------------
  |  |  |  Branch (11831:14): [True: 438, False: 354]
  |  |  ------------------
  |  |11832|    438|        const __m128i w =                                                    \
  |  |11833|    438|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));        \
  |  |11834|    438|        const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);               \
  |  |11835|    438|        if (mask != 0) {                                                     \
  |  |  ------------------
  |  |  |  Branch (11835:13): [True: 180, False: 258]
  |  |  ------------------
  |  |11836|    180|          i += static_cast<size_t>(                                          \
  |  |11837|    180|              trailing_zeroes32(static_cast<uint32_t>(mask)));               \
  |  |11838|    180|          return;                                                            \
  |  |11839|    180|        }                                                                    \
  |  |11840|    438|      }                                                                      \
  |  |11841|    534|      if (i > scan_start && i < len) {                                       \
  |  |  ------------------
  |  |  |  Branch (11841:11): [True: 354, False: 0]
  |  |  |  Branch (11841:29): [True: 262, False: 92]
  |  |  ------------------
  |  |11842|    262|        const __m128i w =                                                    \
  |  |11843|    262|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + len - 16)); \
  |  |11844|    262|        const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);               \
  |  |11845|    262|        if (mask != 0) {                                                     \
  |  |  ------------------
  |  |  |  Branch (11845:13): [True: 120, False: 142]
  |  |  ------------------
  |  |11846|    120|          const size_t hit = len - 16 +                                      \
  |  |11847|    120|                             static_cast<size_t>(trailing_zeroes32(          \
  |  |11848|    120|                                 static_cast<uint32_t>(mask)));              \
  |  |11849|    120|          if (hit >= i) {                                                    \
  |  |  ------------------
  |  |  |  Branch (11849:15): [True: 120, False: 0]
  |  |  ------------------
  |  |11850|    120|            i = hit;                                                         \
  |  |11851|    120|            return;                                                          \
  |  |11852|    120|          }                                                                  \
  |  |11853|    120|        }                                                                    \
  |  |11854|    262|        i = len;                                                             \
  |  |11855|    142|        return;                                                              \
  |  |11856|    262|      }                                                                      \
  |  |11857|    354|    }                                                                        \
  |  |11858|  1.80k|    for (; i < len; ++i) {                                                   \
  |  |  ------------------
  |  |  |  Branch (11858:12): [True: 1.36k, False: 440]
  |  |  ------------------
  |  |11859|  1.36k|      if ((cls)[b[i]] != 0) {                                                \
  |  |  ------------------
  |  |  |  Branch (11859:11): [True: 252, False: 1.11k]
  |  |  ------------------
  |  |11860|    252|        return;                                                              \
  |  |11861|    252|      }                                                                      \
  |  |11862|  1.36k|    }                                                                        \
  |  |11863|    692|  } while (0)
  |  |  ------------------
  |  |  |  Branch (11863:12): [Folded, False: 440]
  |  |  ------------------
  ------------------
11947|  1.45k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_113scan_hash_runEPKhRmm:
11950|  1.53k|                                   size_t len) noexcept {
11951|  1.53k|  ADA_SCAN_STOP_RUN(k_hash_nibbles, k_hash, sse2_hash_stop);
  ------------------
  |  |11808|  1.53k|  do {                                                                       \
  |  |11809|  1.53k|    const size_t scan_start = i;                                             \
  |  |11810|  1.53k|    if (parser_use_ssse3() && (i + 16 <= len)) {                             \
  |  |  ------------------
  |  |  |  Branch (11810:9): [True: 1.53k, False: 0]
  |  |  |  Branch (11810:31): [True: 876, False: 658]
  |  |  ------------------
  |  |11811|    876|      const __m128i lo_tbl = nibble_load((nibbles).low);                     \
  |  |11812|    876|      const __m128i hi_tbl = nibble_load((nibbles).high);                    \
  |  |11813|  1.65k|      for (; i + 32 <= len; i += 32) {                                       \
  |  |  ------------------
  |  |  |  Branch (11813:14): [True: 958, False: 692]
  |  |  ------------------
  |  |11814|    958|        const __m128i w0 =                                                   \
  |  |11815|    958|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));        \
  |  |11816|    958|        const int m0 = ssse3_nibble_mask(w0, lo_tbl, hi_tbl);                \
  |  |11817|    958|        if (m0 != 0) {                                                       \
  |  |  ------------------
  |  |  |  Branch (11817:13): [True: 90, False: 868]
  |  |  ------------------
  |  |11818|     90|          i += static_cast<size_t>(                                          \
  |  |11819|     90|              trailing_zeroes32(static_cast<uint32_t>(m0)));                 \
  |  |11820|     90|          return;                                                            \
  |  |11821|     90|        }                                                                    \
  |  |11822|    958|        const __m128i w1 =                                                   \
  |  |11823|    868|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i + 16));   \
  |  |11824|    868|        const int m1 = ssse3_nibble_mask(w1, lo_tbl, hi_tbl);                \
  |  |11825|    868|        if (m1 != 0) {                                                       \
  |  |  ------------------
  |  |  |  Branch (11825:13): [True: 94, False: 774]
  |  |  ------------------
  |  |11826|     94|          i += 16 + static_cast<size_t>(                                     \
  |  |11827|     94|                        trailing_zeroes32(static_cast<uint32_t>(m1)));       \
  |  |11828|     94|          return;                                                            \
  |  |11829|     94|        }                                                                    \
  |  |11830|    868|      }                                                                      \
  |  |11831|  1.11k|      for (; i + 16 <= len; i += 16) {                                       \
  |  |  ------------------
  |  |  |  Branch (11831:14): [True: 518, False: 598]
  |  |  ------------------
  |  |11832|    518|        const __m128i w =                                                    \
  |  |11833|    518|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + i));        \
  |  |11834|    518|        const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);               \
  |  |11835|    518|        if (mask != 0) {                                                     \
  |  |  ------------------
  |  |  |  Branch (11835:13): [True: 94, False: 424]
  |  |  ------------------
  |  |11836|     94|          i += static_cast<size_t>(                                          \
  |  |11837|     94|              trailing_zeroes32(static_cast<uint32_t>(mask)));               \
  |  |11838|     94|          return;                                                            \
  |  |11839|     94|        }                                                                    \
  |  |11840|    518|      }                                                                      \
  |  |11841|    692|      if (i > scan_start && i < len) {                                       \
  |  |  ------------------
  |  |  |  Branch (11841:11): [True: 598, False: 0]
  |  |  |  Branch (11841:29): [True: 438, False: 160]
  |  |  ------------------
  |  |11842|    438|        const __m128i w =                                                    \
  |  |11843|    438|            _mm_loadu_si128(reinterpret_cast<const __m128i*>(b + len - 16)); \
  |  |11844|    438|        const int mask = ssse3_nibble_mask(w, lo_tbl, hi_tbl);               \
  |  |11845|    438|        if (mask != 0) {                                                     \
  |  |  ------------------
  |  |  |  Branch (11845:13): [True: 120, False: 318]
  |  |  ------------------
  |  |11846|    120|          const size_t hit = len - 16 +                                      \
  |  |11847|    120|                             static_cast<size_t>(trailing_zeroes32(          \
  |  |11848|    120|                                 static_cast<uint32_t>(mask)));              \
  |  |11849|    120|          if (hit >= i) {                                                    \
  |  |  ------------------
  |  |  |  Branch (11849:15): [True: 120, False: 0]
  |  |  ------------------
  |  |11850|    120|            i = hit;                                                         \
  |  |11851|    120|            return;                                                          \
  |  |11852|    120|          }                                                                  \
  |  |11853|    120|        }                                                                    \
  |  |11854|    438|        i = len;                                                             \
  |  |11855|    318|        return;                                                              \
  |  |11856|    438|      }                                                                      \
  |  |11857|    598|    }                                                                        \
  |  |11858|  3.01k|    for (; i < len; ++i) {                                                   \
  |  |  ------------------
  |  |  |  Branch (11858:12): [True: 2.31k, False: 702]
  |  |  ------------------
  |  |11859|  2.31k|      if ((cls)[b[i]] != 0) {                                                \
  |  |  ------------------
  |  |  |  Branch (11859:11): [True: 116, False: 2.20k]
  |  |  ------------------
  |  |11860|    116|        return;                                                              \
  |  |11861|    116|      }                                                                      \
  |  |11862|  2.31k|    }                                                                        \
  |  |11863|    818|  } while (0)
  |  |  ------------------
  |  |  |  Branch (11863:12): [Folded, False: 702]
  |  |  ------------------
  ------------------
11952|  1.53k|}
can_parse.cc:_ZN3ada6parser12_GLOBAL__N_120path_has_dot_segmentENSt3__117basic_string_viewIcNS2_11char_traitsIcEEEE:
11956|  1.63k|bool path_has_dot_segment(std::string_view path) noexcept {
11957|  1.63k|  if (path.empty()) {
  ------------------
  |  Branch (11957:7): [True: 0, False: 1.63k]
  ------------------
11958|      0|    return false;
11959|      0|  }
11960|       |  // "." / ".." at the start, with or without a leading '/'.
11961|  1.63k|  const size_t i = (path[0] == '/') ? 1 : 0;
  ------------------
  |  Branch (11961:20): [True: 1.40k, False: 230]
  ------------------
11962|  1.63k|  if (i < path.size() && path[i] == '.') {
  ------------------
  |  Branch (11962:7): [True: 1.63k, False: 0]
  |  Branch (11962:26): [True: 650, False: 988]
  ------------------
11963|    650|    const size_t after = i + 1;
11964|    650|    if (after == path.size() || path[after] == '/' ||
  ------------------
  |  Branch (11964:9): [True: 50, False: 600]
  |  Branch (11964:33): [True: 184, False: 416]
  ------------------
11965|    416|        (after < path.size() && path[after] == '.' &&
  ------------------
  |  Branch (11965:10): [True: 416, False: 0]
  |  Branch (11965:33): [True: 204, False: 212]
  ------------------
11966|    352|         (after + 1 == path.size() || path[after + 1] == '/'))) {
  ------------------
  |  Branch (11966:11): [True: 34, False: 170]
  |  Branch (11966:39): [True: 84, False: 86]
  ------------------
11967|    352|      return true;
11968|    352|    }
11969|    650|  }
11970|  1.28k|  static constexpr std::string_view slash_dot{"/.", 2};
11971|  1.28k|  size_t p = i;
11972|  3.47k|  while ((p = path.find(slash_dot, p)) != std::string_view::npos) {
  ------------------
  |  Branch (11972:10): [True: 2.80k, False: 676]
  ------------------
11973|  2.80k|    const size_t after = p + 2;
11974|  2.80k|    if (after == path.size() || path[after] == '/' ||
  ------------------
  |  Branch (11974:9): [True: 178, False: 2.62k]
  |  Branch (11974:33): [True: 180, False: 2.44k]
  ------------------
11975|  2.44k|        (after < path.size() && path[after] == '.' &&
  ------------------
  |  Branch (11975:10): [True: 2.44k, False: 0]
  |  Branch (11975:33): [True: 696, False: 1.74k]
  ------------------
11976|    696|         (after + 1 == path.size() || path[after + 1] == '/'))) {
  ------------------
  |  Branch (11976:11): [True: 72, False: 624]
  |  Branch (11976:39): [True: 180, False: 444]
  ------------------
11977|    610|      return true;
11978|    610|    }
11979|  2.19k|    p = after;
11980|  2.19k|  }
11981|    676|  return false;
11982|  1.28k|}
_ZN3ada14url_aggregator11copy_schemeERKS0_:
14064|  1.98k|inline void url_aggregator::copy_scheme(const url_aggregator& u) {
14065|  1.98k|  ada_log("url_aggregator::copy_scheme ", u.buffer);
14066|  1.98k|  ADA_ASSERT_TRUE(validate());
14067|       |  // next line could overflow but unsigned arithmetic has well-defined
14068|       |  // overflows.
14069|  1.98k|  uint32_t new_difference = u.components.protocol_end - components.protocol_end;
14070|       |
14071|  1.98k|  type = u.type;
14072|  1.98k|  buffer.erase(0, components.protocol_end);
14073|  1.98k|  buffer.insert(0, u.get_protocol());
14074|  1.98k|  components.protocol_end = u.components.protocol_end;
14075|       |
14076|       |  // No need to update the components
14077|  1.98k|  if (new_difference == 0) {
  ------------------
  |  Branch (14077:7): [True: 144, False: 1.83k]
  ------------------
14078|    144|    return;
14079|    144|  }
14080|       |
14081|  1.83k|  apply_shifted_non_scheme_offsets(components, new_difference);
14082|  1.83k|  ADA_ASSERT_TRUE(validate());
14083|  1.83k|}
can_parse.cc:_ZN12_GLOBAL__N_132apply_shifted_non_scheme_offsetsERN3ada14url_componentsEj:
13942|  43.9k|    ada::url_components& components, uint32_t new_difference) {
13943|  43.9k|  components.username_end += new_difference;
13944|  43.9k|  components.host_start += new_difference;
13945|  43.9k|  components.host_end += new_difference;
13946|  43.9k|  components.pathname_start += new_difference;
13947|  43.9k|  if (components.search_start != ada::url_components::omitted) {
  ------------------
  |  Branch (13947:7): [True: 0, False: 43.9k]
  ------------------
13948|      0|    components.search_start += new_difference;
13949|      0|  }
13950|  43.9k|  if (components.hash_start != ada::url_components::omitted) {
  ------------------
  |  Branch (13950:7): [True: 0, False: 43.9k]
  ------------------
13951|      0|    components.hash_start += new_difference;
13952|      0|  }
13953|  43.9k|}
_ZN3ada14url_aggregator10parse_pathENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
14312|  2.19k|ada_really_inline void url_aggregator::parse_path(std::string_view input) {
14313|  2.19k|  ada_log("url_aggregator::parse_path ", input);
14314|  2.19k|  ADA_ASSERT_TRUE(validate());
14315|  2.19k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
14316|  2.19k|  std::string tmp_buffer;
14317|  2.19k|  std::string_view internal_input;
14318|  2.19k|  if (unicode::has_tabs_or_newline(input)) {
  ------------------
  |  Branch (14318:7): [True: 0, False: 2.19k]
  ------------------
14319|      0|    tmp_buffer = input;
14320|       |    // Optimization opportunity: Instead of copying and then pruning, we could
14321|       |    // just directly build the string from user_input.
14322|      0|    helpers::remove_ascii_tab_or_newline(tmp_buffer);
14323|      0|    internal_input = tmp_buffer;
14324|  2.19k|  } else {
14325|  2.19k|    internal_input = input;
14326|  2.19k|  }
14327|       |
14328|       |  // If url is special, then:
14329|  2.19k|  if (is_special()) {
  ------------------
  |  Branch (14329:7): [True: 2.19k, False: 0]
  ------------------
14330|  2.19k|    if (internal_input.empty()) {
  ------------------
  |  Branch (14330:9): [True: 111, False: 2.08k]
  ------------------
14331|    111|      update_base_pathname("/");
14332|  2.08k|    } else if ((internal_input[0] == '/') || (internal_input[0] == '\\')) {
  ------------------
  |  Branch (14332:16): [True: 2.08k, False: 0]
  |  Branch (14332:46): [True: 0, False: 0]
  ------------------
14333|  2.08k|      consume_prepared_path(internal_input.substr(1));
14334|  2.08k|    } else {
14335|      0|      consume_prepared_path(internal_input);
14336|      0|    }
14337|  2.19k|  } else if (!internal_input.empty()) {
  ------------------
  |  Branch (14337:14): [True: 0, False: 0]
  ------------------
14338|      0|    if (internal_input[0] == '/') {
  ------------------
  |  Branch (14338:9): [True: 0, False: 0]
  ------------------
14339|      0|      consume_prepared_path(internal_input.substr(1));
14340|      0|    } else {
14341|      0|      consume_prepared_path(internal_input);
14342|      0|    }
14343|      0|  } else {
14344|       |    // Non-special URLs with an empty host can have their paths erased
14345|       |    // Path-only URLs cannot have their paths erased
14346|      0|    if (components.host_start == components.host_end && !has_authority()) {
  ------------------
  |  Branch (14346:9): [True: 0, False: 0]
  |  Branch (14346:57): [True: 0, False: 0]
  ------------------
14347|      0|      update_base_pathname("/");
14348|      0|    }
14349|      0|  }
14350|  2.19k|  ADA_ASSERT_TRUE(validate());
14351|  2.19k|}
_ZN3ada14url_aggregator10parse_hostENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
14445|  30.4k|ada_really_inline bool url_aggregator::parse_host(std::string_view input) {
14446|  30.4k|  ada_log("url_aggregator:parse_host \"", input, "\" [", input.size(),
14447|  30.4k|          " bytes]");
14448|  30.4k|  ADA_ASSERT_TRUE(validate());
14449|  30.4k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
14450|  30.4k|  if (input.empty()) {
  ------------------
  |  Branch (14450:7): [True: 28, False: 30.3k]
  ------------------
14451|     28|    return is_valid = false;
14452|     28|  }  // technically unnecessary.
14453|       |  // If input starts with U+005B ([), then:
14454|  30.3k|  if (input[0] == '[') {
  ------------------
  |  Branch (14454:7): [True: 1.35k, False: 29.0k]
  ------------------
14455|       |    // If input does not end with U+005D (]), validation error, return failure.
14456|  1.35k|    if (input.back() != ']') {
  ------------------
  |  Branch (14456:9): [True: 320, False: 1.03k]
  ------------------
14457|    320|      return is_valid = false;
14458|    320|    }
14459|  1.03k|    ada_log("parse_host ipv6");
14460|       |
14461|       |    // Return the result of IPv6 parsing input with its leading U+005B ([) and
14462|       |    // trailing U+005D (]) removed.
14463|  1.03k|    input.remove_prefix(1);
14464|  1.03k|    input.remove_suffix(1);
14465|  1.03k|    return parse_ipv6(input);
14466|  1.35k|  }
14467|       |
14468|       |  // If isNotSpecial is true, then return the result of opaque-host parsing
14469|       |  // input.
14470|  29.0k|  if (!is_special()) {
  ------------------
  |  Branch (14470:7): [True: 1.19k, False: 27.8k]
  ------------------
14471|  1.19k|    return parse_opaque_host(input);
14472|  1.19k|  }
14473|       |  // Let domain be the result of running UTF-8 decode without BOM on the
14474|       |  // percent-decoding of input. Let asciiDomain be the result of running domain
14475|       |  // to ASCII with domain and false. The most common case is an ASCII input, in
14476|       |  // which case we do not need to call the expensive 'to_ascii' if a few
14477|       |  // conditions are met: no '%' and no 'xn-' subsequence.
14478|       |
14479|       |  // Often, the input does not contain any forbidden code points, and no upper
14480|       |  // case ASCII letter, then we can just copy it to the buffer. We want to
14481|       |  // optimize for such a common case.
14482|       |
14483|       |  // Fast path: try to parse as pure decimal IPv4 first.
14484|  27.8k|  const uint64_t fast_result = checkers::try_parse_ipv4_fast(input);
14485|  27.8k|  if (fast_result < checkers::ipv4_fast_fail) {
  ------------------
  |  Branch (14485:7): [True: 1.21k, False: 26.6k]
  ------------------
14486|  1.21k|    if (!input.empty() && input.back() == '.') {
  ------------------
  |  Branch (14486:9): [True: 1.21k, False: 0]
  |  Branch (14486:27): [True: 47, False: 1.16k]
  ------------------
14487|     47|      update_base_hostname(input.substr(0, input.size() - 1));
14488|  1.16k|    } else {
14489|  1.16k|      update_base_hostname(input);
14490|  1.16k|    }
14491|  1.21k|    host_type = IPV4;
14492|  1.21k|    is_valid = true;
14493|  1.21k|    ada_log("parse_host fast path decimal ipv4");
14494|  1.21k|    ADA_ASSERT_TRUE(validate());
14495|  1.21k|    return true;
14496|  1.21k|  }
14497|  26.6k|  uint8_t is_forbidden_or_upper =
14498|  26.6k|      unicode::contains_forbidden_domain_code_point_or_upper(input.data(),
14499|  26.6k|                                                             input.size());
14500|  26.6k|  static constexpr std::string_view xn_dash{"xn-", 3};
14501|  26.6k|  if ((is_forbidden_or_upper & 1) == 0) {
  ------------------
  |  Branch (14501:7): [True: 16.1k, False: 10.4k]
  ------------------
14502|  16.1k|    if ((is_forbidden_or_upper & 2) != 0) {
  ------------------
  |  Branch (14502:9): [True: 2.80k, False: 13.3k]
  ------------------
14503|  2.80k|      std::string lowered(input);
14504|  2.80k|      unicode::to_lower_ascii(lowered.data(), lowered.size());
14505|  2.80k|      if (lowered.find('-') == std::string_view::npos ||
  ------------------
  |  Branch (14505:11): [True: 2.48k, False: 328]
  ------------------
14506|  2.60k|          lowered.find(xn_dash) == std::string_view::npos) {
  ------------------
  |  Branch (14506:11): [True: 120, False: 208]
  ------------------
14507|       |        // Check IPv4 before mutating so failures leave the buffer untouched.
14508|       |        // This also avoids a double buffer rewrite for hex/octal IPv4.
14509|  2.60k|        if (checkers::is_ipv4(lowered)) {
  ------------------
  |  Branch (14509:13): [True: 452, False: 2.14k]
  ------------------
14510|    452|          ada_log("parse_host fast path ipv4");
14511|    452|          return parse_ipv4(lowered, false);
14512|    452|        }
14513|  2.14k|        update_base_hostname(lowered);
14514|  2.14k|        ada_log("parse_host fast path ", get_hostname());
14515|  2.14k|        is_valid = true;
14516|  2.14k|        return true;
14517|  2.60k|      }
14518|  13.3k|    } else if (input.find('-') == std::string_view::npos ||
  ------------------
  |  Branch (14518:16): [True: 9.38k, False: 3.95k]
  ------------------
14519|  9.85k|               input.find(xn_dash) == std::string_view::npos) {
  ------------------
  |  Branch (14519:16): [True: 473, False: 3.47k]
  ------------------
14520|       |      // Check IPv4 before mutating so failures leave the buffer untouched.
14521|  9.85k|      if (checkers::is_ipv4(input)) {
  ------------------
  |  Branch (14521:11): [True: 2.32k, False: 7.53k]
  ------------------
14522|  2.32k|        ada_log("parse_host fast path ipv4");
14523|  2.32k|        return parse_ipv4(input, false);
14524|  2.32k|      }
14525|  7.53k|      update_base_hostname(input);
14526|  7.53k|      ada_log("parse_host fast path ", get_hostname());
14527|  7.53k|      is_valid = true;
14528|  7.53k|      return true;
14529|  9.85k|    }
14530|  16.1k|  } else if (const size_t first_percent = input.find('%');
14531|  10.4k|             first_percent != std::string_view::npos) {
  ------------------
  |  Branch (14531:14): [True: 1.94k, False: 8.53k]
  ------------------
14532|  1.94k|    std::string decoded = unicode::percent_decode(input, first_percent);
14533|  1.94k|    const uint8_t decoded_flags =
14534|  1.94k|        unicode::contains_forbidden_domain_code_point_or_upper(decoded.data(),
14535|  1.94k|                                                               decoded.size());
14536|  1.94k|    if ((decoded_flags & 1) == 0) {
  ------------------
  |  Branch (14536:9): [True: 1.28k, False: 656]
  ------------------
14537|  1.28k|      if ((decoded_flags & 2) != 0) {
  ------------------
  |  Branch (14537:11): [True: 582, False: 704]
  ------------------
14538|    582|        unicode::to_lower_ascii(decoded.data(), decoded.size());
14539|    582|      }
14540|  1.28k|      if (decoded.find('-') == std::string_view::npos ||
  ------------------
  |  Branch (14540:11): [True: 1.09k, False: 196]
  ------------------
14541|  1.19k|          decoded.find(xn_dash) == std::string_view::npos) {
  ------------------
  |  Branch (14541:11): [True: 104, False: 92]
  ------------------
14542|       |        // Check IPv4 before mutating so failures leave the buffer untouched.
14543|  1.19k|        if (checkers::is_ipv4(decoded)) {
  ------------------
  |  Branch (14543:13): [True: 510, False: 684]
  ------------------
14544|    510|          return parse_ipv4(decoded, false);
14545|    510|        }
14546|    684|        update_base_hostname(decoded);
14547|    684|        is_valid = true;
14548|    684|        return true;
14549|  1.19k|      }
14550|  1.28k|    }
14551|  1.94k|  }
14552|       |  // We have encountered at least one forbidden code point or the input contains
14553|       |  // 'xn-' (case insensitive), so we need to call 'to_ascii' to perform the full
14554|       |  // conversion.
14555|       |
14556|  12.9k|  ada_log("parse_host calling to_ascii");
14557|  12.9k|  std::optional<std::string> host = std::string(get_hostname());
14558|  12.9k|  is_valid = ada::unicode::to_ascii(host, input, input.find('%'));
14559|  12.9k|  if (!is_valid) {
  ------------------
  |  Branch (14559:7): [True: 3.85k, False: 9.12k]
  ------------------
14560|  3.85k|    ada_log("parse_host to_ascii returns false");
14561|  3.85k|    return is_valid = false;
14562|  3.85k|  }
14563|  9.12k|  ada_log("parse_host to_ascii succeeded ", *host, " [", host->size(),
14564|  9.12k|          " bytes]");
14565|       |
14566|  9.12k|  if (std::ranges::any_of(host.value(),
  ------------------
  |  Branch (14566:7): [True: 0, False: 9.12k]
  ------------------
14567|  9.12k|                          ada::unicode::is_forbidden_domain_code_point)) {
14568|      0|    return is_valid = false;
14569|      0|  }
14570|       |
14571|       |  // If asciiDomain ends in a number, then return the result of IPv4 parsing
14572|       |  // asciiDomain.
14573|  9.12k|  if (checkers::is_ipv4(host.value())) {
  ------------------
  |  Branch (14573:7): [True: 402, False: 8.72k]
  ------------------
14574|    402|    ada_log("parse_host got ipv4 ", *host);
14575|    402|    return parse_ipv4(host.value(), false);
14576|    402|  }
14577|       |
14578|  8.72k|  update_base_hostname(host.value());
14579|  8.72k|  ADA_ASSERT_TRUE(validate());
14580|  8.72k|  return true;
14581|  9.12k|}
_ZN3ada7helpers9substringENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEm:
 8854|  1.50k|                                                       size_t pos) {
 8855|  1.50k|  ADA_ASSERT_TRUE(pos <= input.size());
 8856|       |  // The following is safer but unneeded if we have the above line:
 8857|       |  // return pos > input.size() ? std::string_view() : input.substr(pos);
 8858|  1.50k|  return input.substr(pos);
 8859|  1.50k|}
_ZN3ada14url_aggregator21consume_prepared_pathENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
15427|  10.3k|inline void url_aggregator::consume_prepared_path(std::string_view input) {
15428|  10.3k|  ada_log("url_aggregator::consume_prepared_path ", input);
15429|       |  /***
15430|       |   * This is largely duplicated code from helpers::parse_prepared_path, which is
15431|       |   * unfortunate. This particular function is nearly identical, except that it
15432|       |   * is a method on url_aggregator. The idea is that the trivial path (which is
15433|       |   * very common) merely appends to the buffer. This is the same trivial path as
15434|       |   * with helpers::parse_prepared_path, except that we have the additional check
15435|       |   * for is_at_path(). Otherwise, we grab a copy of the current path and we
15436|       |   * modify it, and then insert it back into the buffer.
15437|       |   */
15438|  10.3k|  uint8_t accumulator = checkers::path_signature(input);
15439|       |  // Let us first detect a trivial case.
15440|       |  // If it is special, we check that we have no dot, no %,  no \ and no
15441|       |  // character needing percent encoding. Otherwise, we check that we have no %,
15442|       |  // no dot, and no character needing percent encoding.
15443|  10.3k|  constexpr uint8_t need_encoding = 1;
15444|  10.3k|  constexpr uint8_t backslash_char = 2;
15445|  10.3k|  constexpr uint8_t dot_char = 4;
15446|  10.3k|  constexpr uint8_t percent_char = 8;
15447|  10.3k|  bool special = type != ada::scheme::NOT_SPECIAL;
15448|  10.3k|  bool may_need_slow_file_handling = (type == ada::scheme::type::FILE &&
  ------------------
  |  Branch (15448:39): [True: 1.53k, False: 8.78k]
  ------------------
15449|  1.53k|                                      checkers::is_windows_drive_letter(input));
  ------------------
  |  Branch (15449:39): [True: 121, False: 1.41k]
  ------------------
15450|  10.3k|  bool trivial_path =
15451|  10.3k|      (special ? (accumulator == 0)
  ------------------
  |  Branch (15451:7): [True: 4.77k, False: 5.55k]
  |  Branch (15451:8): [True: 8.80k, False: 1.51k]
  ------------------
15452|  10.3k|               : ((accumulator & (need_encoding | dot_char | percent_char)) ==
15453|  1.51k|                  0)) &&
15454|  4.77k|      (!may_need_slow_file_handling);
  ------------------
  |  Branch (15454:7): [True: 4.68k, False: 85]
  ------------------
15455|  10.3k|  if (accumulator == dot_char && !may_need_slow_file_handling) {
  ------------------
  |  Branch (15455:7): [True: 1.48k, False: 8.83k]
  |  Branch (15455:34): [True: 1.46k, False: 24]
  ------------------
15456|       |    // '4' means that we have at least one dot, but nothing that requires
15457|       |    // percent encoding or decoding. The only part that is not trivial is
15458|       |    // that we may have single dots and double dots path segments.
15459|       |    // If we have such segments, then we either have a path that begins
15460|       |    // with '.' (easy to check), or we have the sequence './'.
15461|       |    // Note: input cannot be empty, it must at least contain one character ('.')
15462|       |    // Note: we know that '\' is not present.
15463|  1.46k|    if (input[0] != '.') {
  ------------------
  |  Branch (15463:9): [True: 777, False: 685]
  ------------------
15464|    777|      size_t slashdot = 0;
15465|    777|      bool dot_is_file = true;
15466|  5.23k|      for (;;) {
15467|  5.23k|        slashdot = input.find("/.", slashdot);
15468|  5.23k|        if (slashdot == std::string_view::npos) {  // common case
  ------------------
  |  Branch (15468:13): [True: 777, False: 4.45k]
  ------------------
15469|    777|          break;
15470|  4.45k|        } else {  // uncommon
15471|       |          // only three cases matter: /./, /.. or a final /
15472|  4.45k|          slashdot += 2;
15473|  4.45k|          dot_is_file &= !(slashdot == input.size() || input[slashdot] == '.' ||
  ------------------
  |  Branch (15473:28): [True: 178, False: 4.27k]
  |  Branch (15473:56): [True: 2.54k, False: 1.73k]
  ------------------
15474|  1.73k|                           input[slashdot] == '/');
  ------------------
  |  Branch (15474:28): [True: 1.06k, False: 670]
  ------------------
15475|  4.45k|        }
15476|  5.23k|      }
15477|    777|      trivial_path = dot_is_file;
15478|    777|    }
15479|  1.46k|  }
15480|  10.3k|  if (trivial_path && is_at_path()) {
  ------------------
  |  Branch (15480:7): [True: 4.89k, False: 5.42k]
  |  Branch (15480:23): [True: 4.81k, False: 79]
  ------------------
15481|  4.81k|    ada_log("parse_path trivial");
15482|  4.81k|    buffer += '/';
15483|  4.81k|    buffer += input;
15484|  4.81k|    return;
15485|  4.81k|  }
15486|  5.50k|  std::string path = std::string(get_pathname());
15487|       |  // We are going to need to look a bit at the path, but let us see if we can
15488|       |  // ignore percent encoding *and* backslashes *and* percent characters.
15489|       |  // Except for the trivial case, this is likely to capture 99% of paths out
15490|       |  // there.
15491|  5.50k|  bool fast_path =
15492|  5.50k|      (special &&
  ------------------
  |  Branch (15492:8): [True: 4.36k, False: 1.14k]
  ------------------
15493|  4.36k|       (accumulator & (need_encoding | backslash_char | percent_char)) == 0) &&
  ------------------
  |  Branch (15493:8): [True: 1.26k, False: 3.10k]
  ------------------
15494|  1.26k|      (type != ada::scheme::type::FILE);
  ------------------
  |  Branch (15494:7): [True: 1.08k, False: 175]
  ------------------
15495|  5.50k|  if (fast_path) {
  ------------------
  |  Branch (15495:7): [True: 1.08k, False: 4.41k]
  ------------------
15496|  1.08k|    ada_log("parse_prepared_path fast");
15497|       |    // Here we don't need to worry about \ or percent encoding.
15498|       |    // We also do not have a file protocol. We might have dots, however,
15499|       |    // but dots must as appear as '.', and they cannot be encoded because
15500|       |    // the symbol '%' is not present.
15501|  1.08k|    size_t previous_location = 0;  // We start at 0.
15502|  13.9k|    do {
15503|  13.9k|      size_t new_location = input.find('/', previous_location);
15504|       |      // std::string_view path_view = input;
15505|       |      //  We process the last segment separately:
15506|  13.9k|      if (new_location == std::string_view::npos) {
  ------------------
  |  Branch (15506:11): [True: 1.08k, False: 12.9k]
  ------------------
15507|  1.08k|        std::string_view path_view = input.substr(previous_location);
15508|  1.08k|        if (path_view == "..") {  // The path ends with ..
  ------------------
  |  Branch (15508:13): [True: 126, False: 961]
  ------------------
15509|       |          // e.g., if you receive ".." with an empty path, you go to "/".
15510|    126|          if (path.empty()) {
  ------------------
  |  Branch (15510:15): [True: 49, False: 77]
  ------------------
15511|     49|            path = '/';
15512|     49|            update_base_pathname(path);
15513|     49|            return;
15514|     49|          }
15515|       |          // Fast case where we have nothing to do:
15516|     77|          if (path.back() == '/') {
  ------------------
  |  Branch (15516:15): [True: 26, False: 51]
  ------------------
15517|     26|            update_base_pathname(path);
15518|     26|            return;
15519|     26|          }
15520|       |          // If you have the path "/joe/myfriend",
15521|       |          // then you delete 'myfriend'.
15522|     51|          path.resize(path.rfind('/') + 1);
15523|     51|          update_base_pathname(path);
15524|     51|          return;
15525|     77|        }
15526|    961|        path += '/';
15527|    961|        if (path_view != ".") {
  ------------------
  |  Branch (15527:13): [True: 745, False: 216]
  ------------------
15528|    745|          path.append(path_view);
15529|    745|        }
15530|    961|        update_base_pathname(path);
15531|    961|        return;
15532|  12.9k|      } else {
15533|       |        // This is a non-final segment.
15534|  12.9k|        std::string_view path_view =
15535|  12.9k|            input.substr(previous_location, new_location - previous_location);
15536|  12.9k|        previous_location = new_location + 1;
15537|  12.9k|        if (path_view == "..") {
  ------------------
  |  Branch (15537:13): [True: 2.75k, False: 10.1k]
  ------------------
15538|  2.75k|          size_t last_delimiter = path.rfind('/');
15539|  2.75k|          if (last_delimiter != std::string::npos) {
  ------------------
  |  Branch (15539:15): [True: 1.11k, False: 1.63k]
  ------------------
15540|  1.11k|            path.erase(last_delimiter);
15541|  1.11k|          }
15542|  10.1k|        } else if (path_view != ".") {
  ------------------
  |  Branch (15542:20): [True: 8.40k, False: 1.74k]
  ------------------
15543|  8.40k|          path += '/';
15544|  8.40k|          path.append(path_view);
15545|  8.40k|        }
15546|  12.9k|      }
15547|  13.9k|    } while (true);
  ------------------
  |  Branch (15547:14): [True: 12.9k, Folded]
  ------------------
15548|  4.41k|  } else {
15549|  4.41k|    ada_log("parse_path slow");
15550|       |    // we have reached the general case
15551|  4.41k|    bool needs_percent_encoding = (accumulator & 1);
15552|  29.8k|    do {
15553|  29.8k|      size_t location = (special && (accumulator & 2))
  ------------------
  |  Branch (15553:26): [True: 22.8k, False: 7.04k]
  |  Branch (15553:37): [True: 1.78k, False: 21.0k]
  ------------------
15554|  29.8k|                            ? input.find_first_of("/\\")
15555|  29.8k|                            : input.find('/');
15556|  29.8k|      std::string_view path_view = input;
15557|  29.8k|      if (location != std::string_view::npos) {
  ------------------
  |  Branch (15557:11): [True: 25.4k, False: 4.41k]
  ------------------
15558|  25.4k|        path_view.remove_suffix(path_view.size() - location);
15559|  25.4k|        input.remove_prefix(location + 1);
15560|  25.4k|      }
15561|       |      // Path encoding preserves dots and percent signs, so normalize first.
15562|  29.8k|      if (unicode::is_double_dot_path_segment(path_view)) {
  ------------------
  |  Branch (15562:11): [True: 4.38k, False: 25.5k]
  ------------------
15563|  4.38k|        helpers::shorten_path(path, type);
15564|  4.38k|        if (location == std::string_view::npos) {
  ------------------
  |  Branch (15564:13): [True: 253, False: 4.13k]
  ------------------
15565|    253|          path += '/';
15566|    253|        }
15567|  25.5k|      } else if (unicode::is_single_dot_path_segment(path_view) &&
  ------------------
  |  Branch (15567:18): [True: 1.33k, False: 24.1k]
  ------------------
15568|  1.33k|                 (location == std::string_view::npos)) {
  ------------------
  |  Branch (15568:18): [True: 115, False: 1.21k]
  ------------------
15569|    115|        path += '/';
15570|    115|      }
15571|       |      // Otherwise, if path_view is not a single-dot path segment, then:
15572|  25.3k|      else if (!unicode::is_single_dot_path_segment(path_view)) {
  ------------------
  |  Branch (15572:16): [True: 24.1k, False: 1.21k]
  ------------------
15573|       |        // If url's scheme is "file", url's path is empty, and path_view is a
15574|       |        // Windows drive letter, then replace the second code point in
15575|       |        // path_view with U+003A (:).
15576|  24.1k|        if (type == ada::scheme::type::FILE && path.empty() &&
  ------------------
  |  Branch (15576:13): [True: 1.92k, False: 22.2k]
  |  Branch (15576:48): [True: 818, False: 1.10k]
  ------------------
15577|    818|            path_view.size() == 2 &&
  ------------------
  |  Branch (15577:13): [True: 341, False: 477]
  ------------------
15578|    341|            checkers::is_windows_drive_letter(path_view)) {
  ------------------
  |  Branch (15578:13): [True: 137, False: 204]
  ------------------
15579|    137|          path += '/';
15580|    137|          path += path_view[0];
15581|    137|          path += ':';
15582|    137|          path_view.remove_prefix(2);
15583|    137|          path.append(path_view);
15584|  24.0k|        } else {
15585|       |          // Append encoded bytes directly to the pathname.
15586|  24.0k|          path += '/';
15587|  24.0k|          if (!needs_percent_encoding ||
  ------------------
  |  Branch (15587:15): [True: 11.7k, False: 12.2k]
  ------------------
15588|  12.2k|              !ada::unicode::percent_encode<true>(
  ------------------
  |  Branch (15588:15): [True: 7.47k, False: 4.79k]
  ------------------
15589|  19.2k|                  path_view, character_sets::PATH_PERCENT_ENCODE, path)) {
15590|  19.2k|            path.append(path_view);
15591|  19.2k|          }
15592|  24.0k|        }
15593|  24.1k|      }
15594|  29.8k|      if (location == std::string_view::npos) {
  ------------------
  |  Branch (15594:11): [True: 4.41k, False: 25.4k]
  ------------------
15595|  4.41k|        update_base_pathname(path);
15596|  4.41k|        return;
15597|  4.41k|      }
15598|  29.8k|    } while (true);
  ------------------
  |  Branch (15598:14): [True: 25.4k, Folded]
  ------------------
15599|  4.41k|  }
15600|  5.50k|}
_ZN3ada8checkers7is_ipv4ENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
   14|  33.8k|ada_really_inline constexpr bool is_ipv4(std::string_view view) noexcept {
   15|       |  // The string is not empty and does not contain upper case ASCII characters.
   16|  33.8k|  if (!last_label_may_be_a_number(view)) {
  ------------------
  |  Branch (16:7): [True: 24.7k, False: 9.03k]
  ------------------
   17|  24.7k|    return false;
   18|  24.7k|  }
   19|       |  // If the address ends with a dot, we need to prune it (special case).
   20|  9.03k|  if (view.ends_with('.')) {
  ------------------
  |  Branch (20:7): [True: 438, False: 8.59k]
  ------------------
   21|    438|    view.remove_suffix(1);
   22|    438|  }
   23|       |  // From the last character, find the last dot.
   24|  9.03k|  size_t last_dot = view.rfind('.');
   25|  9.03k|  if (last_dot != std::string_view::npos) {
  ------------------
  |  Branch (25:7): [True: 2.50k, False: 6.52k]
  ------------------
   26|       |    // We have at least one dot.
   27|  2.50k|    view.remove_prefix(last_dot + 1);
   28|  2.50k|  }
   29|       |  /** Optimization opportunity: we have basically identified the last number of
   30|       |     the ipv4 if we return true here. We might as well parse it and have at
   31|       |     least one number parsed when we get to parse_ipv4. */
   32|  9.03k|  if (std::ranges::all_of(view, ada::checkers::is_digit)) {
  ------------------
  |  Branch (32:7): [True: 4.27k, False: 4.75k]
  ------------------
   33|  4.27k|    return true;
   34|  4.27k|  }
   35|       |  // It could be hex (0x), but not if there is a single character.
   36|  4.75k|  if (view.size() == 1) {
  ------------------
  |  Branch (36:7): [True: 0, False: 4.75k]
  ------------------
   37|      0|    return false;
   38|      0|  }
   39|       |  // It must start with 0x.
   40|  4.75k|  if (!view.starts_with("0x")) {
  ------------------
  |  Branch (40:7): [True: 2.37k, False: 2.38k]
  ------------------
   41|  2.37k|    return false;
   42|  2.37k|  }
   43|       |  // We must allow "0x".
   44|  2.38k|  if (view.size() == 2) {
  ------------------
  |  Branch (44:7): [True: 249, False: 2.13k]
  ------------------
   45|    249|    return true;
   46|    249|  }
   47|       |  // We have 0x followed by some characters, we need to check that they are
   48|       |  // hexadecimals.
   49|  2.13k|  view.remove_prefix(2);
   50|  2.13k|  return std::ranges::all_of(view, ada::unicode::is_lowercase_hex);
   51|  2.38k|}
_ZN3ada7unicode16is_lowercase_hexEc:
 7436|  25.5k|ada_really_inline constexpr bool is_lowercase_hex(const char c) noexcept {
 7437|  25.5k|  return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f');
  ------------------
  |  Branch (7437:11): [True: 25.5k, False: 0]
  |  Branch (7437:23): [True: 12.9k, False: 12.5k]
  |  Branch (7437:37): [True: 12.5k, False: 0]
  |  Branch (7437:49): [True: 11.4k, False: 1.12k]
  ------------------
 7438|  25.5k|}
_ZN3ada3url12parse_schemeILb0EEEbNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEE:
10308|  21.0k|ada_really_inline bool url::parse_scheme(const std::string_view input) {
10309|  21.0k|  auto parsed_type = ada::scheme::get_scheme_type(input);
10310|  21.0k|  bool is_input_special = (parsed_type != ada::scheme::NOT_SPECIAL);
10311|       |  /**
10312|       |   * In the common case, we will immediately recognize a special scheme (e.g.,
10313|       |   *http, https), in which case, we can go really fast.
10314|       |   **/
10315|  21.0k|  if (is_input_special) {  // fast path!!!
  ------------------
  |  Branch (10315:7): [True: 10.2k, False: 10.7k]
  ------------------
10316|       |    if constexpr (has_state_override) {
10317|       |      // If url's scheme is not a special scheme and buffer is a special scheme,
10318|       |      // then return.
10319|       |      if (is_special() != is_input_special) {
10320|       |        return false;
10321|       |      }
10322|       |
10323|       |      // If url includes credentials or has a non-null port, and buffer is
10324|       |      // "file", then return.
10325|       |      if ((has_credentials() || port.has_value()) &&
10326|       |          parsed_type == ada::scheme::type::FILE) {
10327|       |        return false;
10328|       |      }
10329|       |
10330|       |      // If url's scheme is "file" and its host is an empty host, then return.
10331|       |      // An empty host is the empty string.
10332|       |      if (type == ada::scheme::type::FILE && host.has_value() &&
10333|       |          host->empty()) {
10334|       |        return false;
10335|       |      }
10336|       |    }
10337|       |
10338|  10.2k|    type = parsed_type;
10339|       |
10340|       |    if constexpr (has_state_override) {
10341|       |      // This is uncommon.
10342|       |      uint16_t urls_scheme_port = get_special_port();
10343|       |
10344|       |      if (urls_scheme_port) {
10345|       |        // If url's port is url's scheme's default port, then set url's port to
10346|       |        // null.
10347|       |        if (port.has_value() && *port == urls_scheme_port) {
10348|       |          port = std::nullopt;
10349|       |        }
10350|       |      }
10351|       |    }
10352|  10.7k|  } else {  // slow path
10353|  10.7k|    std::string _buffer(input);
10354|       |    // Next function is only valid if the input is ASCII and returns false
10355|       |    // otherwise, but it seems that we always have ascii content so we do not
10356|       |    // need to check the return value.
10357|       |    // bool is_ascii =
10358|  10.7k|    unicode::to_lower_ascii(_buffer.data(), _buffer.size());
10359|       |
10360|       |    if constexpr (has_state_override) {
10361|       |      // The state-override validation errors below ("return" in the WHATWG URL
10362|       |      // parser) leave the URL unchanged. The setter contract is
10363|       |      // "true on success, false if the scheme is invalid" -- the fast path
10364|       |      // above already returns false here, so the slow path must agree.
10365|       |
10366|       |      // If url's scheme is a special scheme and buffer is not a special scheme,
10367|       |      // then return. If url's scheme is not a special scheme and buffer is a
10368|       |      // special scheme, then return.
10369|       |      if (is_special() != ada::scheme::is_special(_buffer)) {
10370|       |        return false;
10371|       |      }
10372|       |
10373|       |      // If url includes credentials or has a non-null port, and buffer is
10374|       |      // "file", then return.
10375|       |      if ((has_credentials() || port.has_value()) && _buffer == "file") {
10376|       |        return false;
10377|       |      }
10378|       |
10379|       |      // If url's scheme is "file" and its host is an empty host, then return.
10380|       |      // An empty host is the empty string.
10381|       |      if (type == ada::scheme::type::FILE && host.has_value() &&
10382|       |          host->empty()) {
10383|       |        return false;
10384|       |      }
10385|       |    }
10386|       |
10387|  10.7k|    set_scheme(std::move(_buffer));
10388|       |
10389|       |    if constexpr (has_state_override) {
10390|       |      // This is uncommon.
10391|       |      uint16_t urls_scheme_port = get_special_port();
10392|       |
10393|       |      if (urls_scheme_port) {
10394|       |        // If url's port is url's scheme's default port, then set url's port to
10395|       |        // null.
10396|       |        if (port.has_value() && *port == urls_scheme_port) {
10397|       |          port = std::nullopt;
10398|       |        }
10399|       |      }
10400|       |    }
10401|  10.7k|  }
10402|       |
10403|  21.0k|  return true;
10404|  21.0k|}
_ZN3ada14url_aggregator23parse_scheme_with_colonILb0EEEbNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEE:
13960|  42.0k|    const std::string_view input_with_colon) {
13961|  42.0k|  ada_log("url_aggregator::parse_scheme_with_colon ", input_with_colon);
13962|  42.0k|  ADA_ASSERT_TRUE(validate());
13963|  42.0k|  ADA_ASSERT_TRUE(!helpers::overlaps(input_with_colon, buffer));
13964|  42.0k|  std::string_view input{input_with_colon};
13965|  42.0k|  input.remove_suffix(1);
13966|  42.0k|  auto parsed_type = ada::scheme::get_scheme_type(input);
13967|  42.0k|  const bool is_input_special = (parsed_type != ada::scheme::NOT_SPECIAL);
13968|       |  /**
13969|       |   * In the common case, we will immediately recognize a special scheme (e.g.,
13970|       |   *http, https), in which case, we can go really fast.
13971|       |   **/
13972|  42.0k|  if (is_input_special) {  // fast path!!!
  ------------------
  |  Branch (13972:7): [True: 20.5k, False: 21.5k]
  ------------------
13973|       |    if constexpr (has_state_override) {
13974|       |      // If url's scheme is not a special scheme and buffer is a special scheme,
13975|       |      // then return.
13976|       |      if (is_special() != is_input_special) {
13977|       |        return false;
13978|       |      }
13979|       |
13980|       |      // If url includes credentials or has a non-null port, and buffer is
13981|       |      // "file", then return.
13982|       |      if ((has_credentials() || components.port != url_components::omitted) &&
13983|       |          parsed_type == ada::scheme::type::FILE) {
13984|       |        return false;
13985|       |      }
13986|       |
13987|       |      // If url's scheme is "file" and its host is an empty host, then return.
13988|       |      // An empty host is the empty string.
13989|       |      if (type == ada::scheme::type::FILE &&
13990|       |          components.host_start == components.host_end) {
13991|       |        return false;
13992|       |      }
13993|       |    }
13994|       |
13995|  20.5k|    type = parsed_type;
13996|  20.5k|    set_scheme_from_view_with_colon(input_with_colon);
13997|       |
13998|       |    if constexpr (has_state_override) {
13999|       |      // This is uncommon.
14000|       |      uint16_t urls_scheme_port = get_special_port();
14001|       |
14002|       |      if (urls_scheme_port) {
14003|       |        // If url's port is url's scheme's default port, then set url's port to
14004|       |        // null.
14005|       |        if (components.port == urls_scheme_port) {
14006|       |          clear_port();
14007|       |        }
14008|       |      }
14009|       |    }
14010|  21.5k|  } else {  // slow path
14011|  21.5k|    std::string _buffer(input);
14012|       |    // Next function is only valid if the input is ASCII and returns false
14013|       |    // otherwise, but it seems that we always have ascii content so we do not
14014|       |    // need to check the return value.
14015|  21.5k|    unicode::to_lower_ascii(_buffer.data(), _buffer.size());
14016|       |
14017|       |    if constexpr (has_state_override) {
14018|       |      // The state-override validation errors below ("return" in the WHATWG URL
14019|       |      // parser) leave the URL unchanged. The setter contract is
14020|       |      // "true on success, false if the scheme is invalid" -- the fast path
14021|       |      // above already returns false here, so the slow path must agree.
14022|       |
14023|       |      // If url's scheme is a special scheme and buffer is not a special scheme,
14024|       |      // then return. If url's scheme is not a special scheme and buffer is a
14025|       |      // special scheme, then return.
14026|       |      if (is_special() != ada::scheme::is_special(_buffer)) {
14027|       |        return false;
14028|       |      }
14029|       |
14030|       |      // If url includes credentials or has a non-null port, and buffer is
14031|       |      // "file", then return.
14032|       |      if ((has_credentials() || components.port != url_components::omitted) &&
14033|       |          _buffer == "file") {
14034|       |        return false;
14035|       |      }
14036|       |
14037|       |      // If url's scheme is "file" and its host is an empty host, then return.
14038|       |      // An empty host is the empty string.
14039|       |      if (type == ada::scheme::type::FILE &&
14040|       |          components.host_start == components.host_end) {
14041|       |        return false;
14042|       |      }
14043|       |    }
14044|       |
14045|  21.5k|    set_scheme(_buffer);
14046|       |
14047|       |    if constexpr (has_state_override) {
14048|       |      // This is uncommon.
14049|       |      uint16_t urls_scheme_port = get_special_port();
14050|       |
14051|       |      if (urls_scheme_port) {
14052|       |        // If url's port is url's scheme's default port, then set url's port to
14053|       |        // null.
14054|       |        if (components.port == urls_scheme_port) {
14055|       |          clear_port();
14056|       |        }
14057|       |      }
14058|       |    }
14059|  21.5k|  }
14060|  42.0k|  ADA_ASSERT_TRUE(validate());
14061|  42.0k|  return true;
14062|  42.0k|}
_ZN3ada14url_aggregator31set_scheme_from_view_with_colonENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
14086|  20.5k|    std::string_view new_scheme_with_colon) {
14087|  20.5k|  ada_log("url_aggregator::set_scheme_from_view_with_colon ",
14088|  20.5k|          new_scheme_with_colon);
14089|  20.5k|  ADA_ASSERT_TRUE(validate());
14090|  20.5k|  ADA_ASSERT_TRUE(!new_scheme_with_colon.empty() &&
14091|  20.5k|                  new_scheme_with_colon.back() == ':');
14092|       |  // next line could overflow but unsigned arithmetic has well-defined
14093|       |  // overflows.
14094|  20.5k|  uint32_t new_difference =
14095|  20.5k|      uint32_t(new_scheme_with_colon.size()) - components.protocol_end;
14096|       |
14097|  20.5k|  if (buffer.empty()) {
  ------------------
  |  Branch (14097:7): [True: 20.5k, False: 0]
  ------------------
14098|  20.5k|    buffer.append(new_scheme_with_colon);
14099|  20.5k|  } else {
14100|      0|    buffer.erase(0, components.protocol_end);
14101|      0|    buffer.insert(0, new_scheme_with_colon);
14102|      0|  }
14103|  20.5k|  components.protocol_end += new_difference;
14104|       |
14105|  20.5k|  apply_shifted_non_scheme_offsets(components, new_difference);
14106|  20.5k|  ADA_ASSERT_TRUE(validate());
14107|  20.5k|}
_ZN3ada14url_aggregator10set_schemeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
14109|  21.5k|inline void url_aggregator::set_scheme(std::string_view new_scheme) {
14110|  21.5k|  ada_log("url_aggregator::set_scheme ", new_scheme);
14111|  21.5k|  ADA_ASSERT_TRUE(validate());
14112|  21.5k|  ADA_ASSERT_TRUE(new_scheme.empty() || new_scheme.back() != ':');
14113|       |  // next line could overflow but unsigned arithmetic has well-defined
14114|       |  // overflows.
14115|  21.5k|  uint32_t new_difference =
14116|  21.5k|      uint32_t(new_scheme.size()) - components.protocol_end + 1;
14117|       |
14118|  21.5k|  type = ada::scheme::get_scheme_type(new_scheme);
14119|  21.5k|  if (buffer.empty()) {
  ------------------
  |  Branch (14119:7): [True: 21.5k, False: 0]
  ------------------
14120|  21.5k|    buffer.append(helpers::concat(new_scheme, ":"));
14121|  21.5k|  } else {
14122|      0|    buffer.erase(0, components.protocol_end);
14123|      0|    buffer.insert(0, helpers::concat(new_scheme, ":"));
14124|      0|  }
14125|  21.5k|  components.protocol_end = uint32_t(new_scheme.size() + 1);
14126|       |
14127|  21.5k|  apply_shifted_non_scheme_offsets(components, new_difference);
14128|  21.5k|  ADA_ASSERT_TRUE(validate());
14129|  21.5k|}

_ZN3ada37url_pattern_compile_component_optionsC2ENSt3__18optionalIcEES3_:
 5869|      6|      : delimiter(new_delimiter), prefix(new_prefix) {}
_ZN3ada14character_sets6bit_atEPKhh:
 1086|   338k|ada_really_inline constexpr bool bit_at(const uint8_t a[], const uint8_t i) {
 1087|   338k|  return !!(a[i >> 3] & (1 << (i & 7)));
 1088|   338k|}
_ZN2tl10unexpectedIN3ada6errorsEEC2EOS2_:
 2216|  99.8k|  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:
 3702|  24.9k|      : impl_base(unexpect, std::move(e.value())),
 3703|  24.9k|        ctor_base(detail::default_constructor_tag{}) {}
_ZNR2tl10unexpectedIN3ada6errorsEE5valueEv:
 2230|  49.9k|  TL_EXPECTED_11_CONSTEXPR E& value() & { return m_val; }
_ZN2tl6detail21expected_storage_baseIN3ada3urlENS2_6errorsELb0ELb1EEC2IJS4_ETnPNSt3__19enable_ifIXsr3std16is_constructibleIS4_DpOT_EE5valueEvE4typeELPv0EEENS_10unexpect_tESB_:
 2688|  24.9k|      : m_unexpect(std::forward<Args>(args)...), m_has_val(false) {}
_ZN2tl6detail26expected_default_ctor_baseIN3ada3urlENS2_6errorsELb1EEC2ENS0_23default_constructor_tagE:
 3306|  49.0k|  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_:
 3788|  24.0k|      : expected(in_place, std::forward<U>(v)) {}
_ZN2tl8expectedIN3ada3urlENS1_6errorsEEC2IJS2_ETnPNSt3__19enable_ifIXsr3std16is_constructibleIS2_DpOT_EE5valueEvE4typeELPv0EEENS_10in_place_tESA_:
 3661|  24.0k|      : impl_base(in_place, std::forward<Args>(args)...),
 3662|  24.0k|        ctor_base(detail::default_constructor_tag{}) {}
_ZN2tl6detail21expected_storage_baseIN3ada3urlENS2_6errorsELb0ELb1EEC2IJS3_ETnPNSt3__19enable_ifIXsr3std16is_constructibleIS3_DpOT_EE5valueEvE4typeELPv0EEENS_10in_place_tESB_:
 2676|  24.0k|      : m_val(std::forward<Args>(args)...), m_has_val(true) {}
_ZN3ada3urlC2EOS0_:
 5108|  24.0k|  url(url&& u) noexcept = default;
_ZN3ada8url_baseD2Ev:
 1712|   202k|  virtual ~url_base() = default;
_ZN3ada3urlD2Ev:
 5111|  73.0k|  ~url() override = default;
_ZN2tl8expectedIN3ada14url_aggregatorENS1_6errorsEEC2IS3_TnPNSt3__19enable_ifIXsr3std16is_constructibleIS3_OT_EE5valueEvE4typeELPv0ETnPNS7_IXsr3std14is_convertibleIS9_S3_EE5valueEvE4typeELSD_0EEEONS_10unexpectedIS8_EE:
 3702|  24.9k|      : impl_base(unexpect, std::move(e.value())),
 3703|  24.9k|        ctor_base(detail::default_constructor_tag{}) {}
_ZN2tl6detail21expected_storage_baseIN3ada14url_aggregatorENS2_6errorsELb0ELb1EEC2IJS4_ETnPNSt3__19enable_ifIXsr3std16is_constructibleIS4_DpOT_EE5valueEvE4typeELPv0EEENS_10unexpect_tESB_:
 2688|  24.9k|      : m_unexpect(std::forward<Args>(args)...), m_has_val(false) {}
_ZN2tl6detail26expected_default_ctor_baseIN3ada14url_aggregatorENS2_6errorsELb1EEC2ENS0_23default_constructor_tagE:
 3306|  49.0k|  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_:
 3788|  24.0k|      : expected(in_place, std::forward<U>(v)) {}
_ZN2tl8expectedIN3ada14url_aggregatorENS1_6errorsEEC2IJS2_ETnPNSt3__19enable_ifIXsr3std16is_constructibleIS2_DpOT_EE5valueEvE4typeELPv0EEENS_10in_place_tESA_:
 3661|  24.0k|      : impl_base(in_place, std::forward<Args>(args)...),
 3662|  24.0k|        ctor_base(detail::default_constructor_tag{}) {}
_ZN2tl6detail21expected_storage_baseIN3ada14url_aggregatorENS2_6errorsELb0ELb1EEC2IJS3_ETnPNSt3__19enable_ifIXsr3std16is_constructibleIS3_DpOT_EE5valueEvE4typeELPv0EEENS_10in_place_tESB_:
 2676|  24.0k|      : m_val(std::forward<Args>(args)...), m_has_val(true) {}
_ZN3ada14url_aggregatorC2EOS0_:
 7922|  24.0k|  url_aggregator(url_aggregator&& u) noexcept = default;
_ZN3ada14url_aggregatorD2Ev:
 7925|   129k|  ~url_aggregator() override = default;
_ZN3ada6scheme15get_scheme_typeENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 6923|   113k|constexpr ada::scheme::type get_scheme_type(std::string_view scheme) noexcept {
 6924|   113k|  if (scheme.empty()) {
  ------------------
  |  Branch (6924:7): [True: 0, False: 113k]
  ------------------
 6925|      0|    return ada::scheme::NOT_SPECIAL;
 6926|      0|  }
 6927|   113k|  int hash_value = (2 * scheme.size() + (unsigned)(scheme[0])) & 7;
 6928|   113k|  const std::string_view target = details::is_special_list[hash_value];
 6929|   113k|  if (scheme.size() == target.size() &&
  ------------------
  |  Branch (6929:7): [True: 91.3k, False: 22.3k]
  ------------------
 6930|  91.3k|      details::branchless_load5(scheme.data(), scheme.size()) ==
  ------------------
  |  Branch (6930:7): [True: 62.5k, False: 28.7k]
  ------------------
 6931|  91.3k|          details::scheme_keys[hash_value]) {
 6932|  62.5k|    return ada::scheme::type(hash_value);
 6933|  62.5k|  } else {
 6934|  51.0k|    return ada::scheme::NOT_SPECIAL;
 6935|  51.0k|  }
 6936|   113k|}
_ZN3ada6scheme7details16branchless_load5EPKcm:
 6864|  91.3k|inline uint64_t branchless_load5(const char* p, size_t n) {
 6865|  91.3k|  uint64_t input = (uint8_t)p[0];
 6866|  91.3k|  input |= ((uint64_t)(uint8_t)p[n > 1] << 8) & (0 - (uint64_t)(n > 1));
 6867|  91.3k|  input |= ((uint64_t)(uint8_t)p[(n > 2) * 2] << 16) & (0 - (uint64_t)(n > 2));
 6868|  91.3k|  input |= ((uint64_t)(uint8_t)p[(n > 3) * 3] << 24) & (0 - (uint64_t)(n > 3));
 6869|  91.3k|  input |= ((uint64_t)(uint8_t)p[(n > 4) * 4] << 32) & (0 - (uint64_t)(n > 4));
 6870|  91.3k|  return input;
 6871|  91.3k|}
_ZN3ada14url_aggregatorC2Ev:
 7920|   105k|  url_aggregator() = default;
_ZN3ada14url_componentsC2Ev:
 5017|   105k|  url_components() = default;
_ZN3ada14url_aggregatoraSEOS0_:
 7923|  12.1k|  url_aggregator& operator=(url_aggregator&& u) noexcept = default;
_ZN3ada8checkers19try_parse_ipv4_fastENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 1460|  48.6k|try_parse_ipv4_fast(std::string_view input) noexcept {
 1461|  48.6k|  const size_t len = input.size();
 1462|       |  // Shortest pure decimal: "0.0.0.0" (7). Longest + trailing dot: 16.
 1463|  48.6k|  if (len < 7 || len > 16) [[unlikely]] {
  ------------------
  |  Branch (1463:7): [True: 25.6k, False: 22.9k]
  |  Branch (1463:18): [True: 9.66k, False: 13.2k]
  ------------------
 1464|  35.3k|    return ipv4_fast_fail;
 1465|  35.3k|  }
 1466|  13.2k|  const char* data = input.data();
 1467|       |
 1468|       |#if defined(ADA_AVX512) && defined(__AVX512VBMI2__)
 1469|       |  return detail::try_parse_ipv4_avx512(data, len);
 1470|       |#else
 1471|  13.2k|  return detail::parse_ipv4_decimal_scalar(data, data + len);
 1472|  48.6k|#endif
 1473|  48.6k|}
_ZN3ada8checkers6detail25parse_ipv4_decimal_scalarEPKcS3_:
 1301|  13.2k|parse_ipv4_decimal_scalar(const char* p, const char* pend) noexcept {
 1302|  13.2k|  uint32_t ipv4 = 0;
 1303|  28.7k|  for (int i = 0; i < 4; ++i) {
  ------------------
  |  Branch (1303:19): [True: 25.3k, False: 3.40k]
  ------------------
 1304|  25.3k|    if (p == pend) [[unlikely]] {
  ------------------
  |  Branch (1304:9): [True: 9, False: 25.3k]
  ------------------
 1305|      9|      return ipv4_fast_fail;
 1306|      9|    }
 1307|  25.3k|    uint32_t val;
 1308|  25.3k|    char c = *p;
 1309|  25.3k|    if (c >= '0' && c <= '9') [[likely]] {
  ------------------
  |  Branch (1309:9): [True: 23.0k, False: 2.21k]
  |  Branch (1309:21): [True: 18.5k, False: 4.49k]
  ------------------
 1310|  18.5k|      val = static_cast<uint32_t>(c - '0');
 1311|  18.5k|      ++p;
 1312|  18.5k|    } else {
 1313|  6.70k|      return ipv4_fast_fail;
 1314|  6.70k|    }
 1315|  18.5k|    if (p < pend) {
  ------------------
  |  Branch (1315:9): [True: 16.7k, False: 1.85k]
  ------------------
 1316|  16.7k|      c = *p;
 1317|  16.7k|      if (c >= '0' && c <= '9') {
  ------------------
  |  Branch (1317:11): [True: 6.87k, False: 9.86k]
  |  Branch (1317:23): [True: 5.64k, False: 1.23k]
  ------------------
 1318|  5.64k|        if (val == 0) [[unlikely]] {
  ------------------
  |  Branch (1318:13): [True: 491, False: 5.15k]
  ------------------
 1319|    491|          return ipv4_fast_fail;
 1320|    491|        }
 1321|  5.15k|        val = val * 10u + static_cast<uint32_t>(c - '0');
 1322|  5.15k|        ++p;
 1323|  5.15k|        if (p < pend) {
  ------------------
  |  Branch (1323:13): [True: 4.53k, False: 613]
  ------------------
 1324|  4.53k|          c = *p;
 1325|  4.53k|          if (c >= '0' && c <= '9') {
  ------------------
  |  Branch (1325:15): [True: 3.15k, False: 1.38k]
  |  Branch (1325:27): [True: 3.02k, False: 134]
  ------------------
 1326|  3.02k|            val = val * 10u + static_cast<uint32_t>(c - '0');
 1327|  3.02k|            ++p;
 1328|  3.02k|            if (val > 255u) [[unlikely]] {
  ------------------
  |  Branch (1328:17): [True: 797, False: 2.22k]
  ------------------
 1329|    797|              return ipv4_fast_fail;
 1330|    797|            }
 1331|  3.02k|          }
 1332|  4.53k|        }
 1333|  5.15k|      }
 1334|  16.7k|    }
 1335|  17.3k|    ipv4 = (ipv4 << 8) | val;
 1336|  17.3k|    if (i < 3) {
  ------------------
  |  Branch (1336:9): [True: 13.9k, False: 3.40k]
  ------------------
 1337|  13.9k|      if (p == pend || *p != '.') [[unlikely]] {
  ------------------
  |  Branch (1337:11): [True: 351, False: 13.5k]
  |  Branch (1337:24): [True: 1.50k, False: 12.0k]
  ------------------
 1338|  1.85k|        return ipv4_fast_fail;
 1339|  1.85k|      }
 1340|  12.0k|      ++p;
 1341|  12.0k|    }
 1342|  17.3k|  }
 1343|  3.40k|  if (p != pend) {
  ------------------
  |  Branch (1343:7): [True: 606, False: 2.79k]
  ------------------
 1344|    606|    if (p == pend - 1 && *p == '.') {
  ------------------
  |  Branch (1344:9): [True: 370, False: 236]
  |  Branch (1344:26): [True: 72, False: 298]
  ------------------
 1345|     72|      return ipv4;
 1346|     72|    }
 1347|    534|    return ipv4_fast_fail;
 1348|    606|  }
 1349|  2.79k|  return ipv4;
 1350|  3.40k|}
_ZNK3ada3url15has_credentialsEv:
 7451|  21.8k|[[nodiscard]] ada_really_inline bool url::has_credentials() const noexcept {
 7452|  21.8k|  return !username.empty() || !password.empty();
  ------------------
  |  Branch (7452:10): [True: 1.92k, False: 19.9k]
  |  Branch (7452:31): [True: 215, False: 19.7k]
  ------------------
 7453|  21.8k|}
_ZNK3ada8url_base10is_specialEv:
 7411|   323k|    const noexcept {
 7412|   323k|  return type != ada::scheme::NOT_SPECIAL;
 7413|   323k|}
_ZNK2tl8expectedIN3ada3urlENS1_6errorsEEcvbEv:
 4101|  28.1k|  constexpr explicit operator bool() const noexcept { return this->m_has_val; }
_ZN2tl8expectedIN3ada3urlENS1_6errorsEEptEv:
 4070|  19.7k|  TL_EXPECTED_11_CONSTEXPR T* operator->() {
 4071|  19.7k|    TL_ASSERT(has_value());
  ------------------
  |  | 2123|  19.7k|#define TL_ASSERT(x) assert(x)
  ------------------
  |  Branch (4071:5): [True: 19.7k, False: 0]
  ------------------
 4072|  19.7k|    return valptr();
 4073|  19.7k|  }
_ZN2tl8expectedIN3ada3urlENS1_6errorsEE6valptrEv:
 3366|  19.7k|  T* valptr() { return std::addressof(this->m_val); }
_ZN2tl6detail21expected_storage_baseIN3ada3urlENS2_6errorsELb0ELb1EED2Ev:
 2698|  49.0k|  ~expected_storage_base() {
 2699|  49.0k|    if (m_has_val) {
  ------------------
  |  Branch (2699:9): [True: 24.0k, False: 24.9k]
  ------------------
 2700|  24.0k|      m_val.~T();
 2701|  24.0k|    }
 2702|  49.0k|  }
_ZNK3ada3url13get_href_sizeEv:
 7709|  25.2k|[[nodiscard]] inline size_t url::get_href_size() const noexcept {
 7710|  25.2k|  size_t size = 0;
 7711|  25.2k|  if (is_special()) {
  ------------------
  |  Branch (7711:7): [True: 16.6k, False: 8.59k]
  ------------------
 7712|  16.6k|    size += ada::scheme::details::is_special_list[type].size() + 1;
 7713|  16.6k|  } else {
 7714|  8.59k|    size += non_special_scheme.size() + 1;
 7715|  8.59k|  }
 7716|  25.2k|  if (host.has_value()) {
  ------------------
  |  Branch (7716:7): [True: 18.1k, False: 7.10k]
  ------------------
 7717|  18.1k|    size += host->size();
 7718|  18.1k|    size += 2;
 7719|  18.1k|    if (has_credentials()) {
  ------------------
  |  Branch (7719:9): [True: 1.45k, False: 16.6k]
  ------------------
 7720|  1.45k|      size += username.size();
 7721|  1.45k|      if (!password.empty()) {
  ------------------
  |  Branch (7721:11): [True: 463, False: 993]
  ------------------
 7722|    463|        size += 1 + password.size();
 7723|    463|      }
 7724|  1.45k|      size += 1;
 7725|  1.45k|    }
 7726|  18.1k|    if (port.has_value()) {
  ------------------
  |  Branch (7726:9): [True: 3.91k, False: 14.2k]
  ------------------
 7727|  3.91k|      size += 1;
 7728|  3.91k|      uint16_t p = *port;
 7729|  3.91k|      size += (p >= 10000)  ? 5
  ------------------
  |  Branch (7729:15): [True: 145, False: 3.76k]
  ------------------
 7730|  3.91k|              : (p >= 1000) ? 4
  ------------------
  |  Branch (7730:17): [True: 149, False: 3.61k]
  ------------------
 7731|  3.76k|              : (p >= 100)  ? 3
  ------------------
  |  Branch (7731:17): [True: 106, False: 3.51k]
  ------------------
 7732|  3.61k|              : (p >= 10)   ? 2
  ------------------
  |  Branch (7732:17): [True: 84, False: 3.42k]
  ------------------
 7733|  3.51k|                            : 1;
 7734|  3.91k|    }
 7735|  18.1k|  } else if (!has_opaque_path && path.starts_with("//")) {
  ------------------
  |  Branch (7735:14): [True: 2.70k, False: 4.39k]
  |  Branch (7735:34): [True: 69, False: 2.63k]
  ------------------
 7736|     69|    size += 2;
 7737|     69|  }
 7738|  25.2k|  size += path.size();
 7739|  25.2k|  if (query.has_value()) {
  ------------------
  |  Branch (7739:7): [True: 2.06k, False: 23.1k]
  ------------------
 7740|  2.06k|    size += 1 + query->size();
 7741|  2.06k|  }
 7742|  25.2k|  if (hash.has_value()) {
  ------------------
  |  Branch (7742:7): [True: 1.50k, False: 23.7k]
  ------------------
 7743|  1.50k|    size += 1 + hash->size();
 7744|  1.50k|  }
 7745|  25.2k|  return size;
 7746|  25.2k|}
_ZN3ada8checkers8is_alphaEc:
 1281|  96.4k|constexpr bool is_alpha(char x) noexcept {
 1282|  96.4k|  return (to_lower(x) >= 'a') && (to_lower(x) <= 'z');
  ------------------
  |  Branch (1282:10): [True: 87.6k, False: 8.81k]
  |  Branch (1282:34): [True: 87.4k, False: 243]
  ------------------
 1283|  96.4k|}
_ZN3ada8checkers8to_lowerEc:
 1279|   184k|constexpr char to_lower(char x) noexcept { return (x | 0x20); }
_ZNR2tl8expectedIN3ada3urlENS1_6errorsEEdeIS2_TnPNSt3__19enable_ifIXntsr3std7is_voidIT_EE5valueEvE4typeELPv0EEERS8_v:
 4083|  4.35k|  TL_EXPECTED_11_CONSTEXPR U& operator*() & {
 4084|  4.35k|    TL_ASSERT(has_value());
  ------------------
  |  | 2123|  4.35k|#define TL_ASSERT(x) assert(x)
  ------------------
  |  Branch (4084:5): [True: 4.35k, False: 0]
  ------------------
 4085|  4.35k|    return val();
 4086|  4.35k|  }
_ZN2tl8expectedIN3ada3urlENS1_6errorsEE3valIS2_TnPNSt3__19enable_ifIXntsr3std7is_voidIT_EE5valueEvE4typeELPv0EEERS8_v:
 3375|  4.35k|  TL_EXPECTED_11_CONSTEXPR U& val() {
 3376|  4.35k|    return this->m_val;
 3377|  4.35k|  }
_ZNK2tl8expectedIN3ada3urlENS1_6errorsEE9has_valueEv:
 4100|  77.1k|  constexpr bool has_value() const noexcept { return this->m_has_val; }
_ZN3ada8checkers26last_label_may_be_a_numberENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 1254|  51.5k|constexpr bool last_label_may_be_a_number(std::string_view view) noexcept {
 1255|  51.5k|  if (view.empty()) {
  ------------------
  |  Branch (1255:7): [True: 0, False: 51.5k]
  ------------------
 1256|      0|    return false;
 1257|      0|  }
 1258|  51.5k|  const char* start = view.data();
 1259|  51.5k|  const char* end = start + view.size();
 1260|  51.5k|  if (end[-1] == '.') {
  ------------------
  |  Branch (1260:7): [True: 5.14k, False: 46.4k]
  ------------------
 1261|  5.14k|    --end;
 1262|  5.14k|    if (end == start) {
  ------------------
  |  Branch (1262:9): [True: 3.55k, False: 1.58k]
  ------------------
 1263|  3.55k|      return false;
 1264|  3.55k|    }
 1265|  5.14k|  }
 1266|  48.0k|  if (!is_ipv4_number_char(end[-1])) {
  ------------------
  |  Branch (1266:7): [True: 23.4k, False: 24.5k]
  ------------------
 1267|  23.4k|    return false;
 1268|  23.4k|  }
 1269|  24.5k|  const char* label = end;
 1270|   175k|  while (label != start && is_ipv4_number_char(label[-1])) {
  ------------------
  |  Branch (1270:10): [True: 163k, False: 12.1k]
  |  Branch (1270:28): [True: 151k, False: 12.4k]
  ------------------
 1271|   151k|    --label;
 1272|   151k|  }
 1273|  24.5k|  if (label != start && label[-1] != '.') {
  ------------------
  |  Branch (1273:7): [True: 12.4k, False: 12.1k]
  |  Branch (1273:25): [True: 9.10k, False: 3.30k]
  ------------------
 1274|  9.10k|    return false;
 1275|  9.10k|  }
 1276|  15.4k|  return label != end && is_digit(*label);
  ------------------
  |  Branch (1276:10): [True: 15.4k, False: 0]
  |  Branch (1276:26): [True: 9.50k, False: 5.99k]
  ------------------
 1277|  24.5k|}
_ZN3ada8checkers19is_ipv4_number_charEc:
 1248|   211k|constexpr bool is_ipv4_number_char(char x) noexcept {
 1249|   211k|  const unsigned char c = static_cast<unsigned char>(x);
 1250|   211k|  return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') ||
  ------------------
  |  Branch (1250:11): [True: 199k, False: 11.5k]
  |  Branch (1250:23): [True: 66.4k, False: 133k]
  |  Branch (1250:37): [True: 130k, False: 14.5k]
  |  Branch (1250:49): [True: 78.5k, False: 51.9k]
  ------------------
 1251|  66.4k|         (c >= 'A' && c <= 'F') || c == 'x' || c == 'X';
  ------------------
  |  Branch (1251:11): [True: 53.9k, False: 12.5k]
  |  Branch (1251:23): [True: 1.02k, False: 52.8k]
  |  Branch (1251:36): [True: 29.2k, False: 36.2k]
  |  Branch (1251:48): [True: 397, False: 35.8k]
  ------------------
 1252|   211k|}
_ZN3ada8checkers8is_digitEc:
 1246|  47.7k|constexpr bool is_digit(char x) noexcept { return (x >= '0') & (x <= '9'); }
_ZN3ada6scheme16get_special_portENS0_4typeE:
 6920|  10.1k|constexpr uint16_t get_special_port(ada::scheme::type type) noexcept {
 6921|  10.1k|  return details::special_ports[int(type)];
 6922|  10.1k|}
_ZN3ada3urlaSERKS0_:
 5110|    258|  url& operator=(const url& u) = default;
_ZN3ada14url_aggregatoraSERKS0_:
 7924|    258|  url_aggregator& operator=(const url_aggregator& u) = default;
_ZN3ada14url_aggregator10clear_hashEv:
 9010|    227|inline void url_aggregator::clear_hash() {
 9011|    227|  ada_log("url_aggregator::clear_hash");
 9012|    227|  ADA_ASSERT_TRUE(validate());
 9013|    227|  if (components.hash_start == url_components::omitted) {
  ------------------
  |  Branch (9013:7): [True: 213, False: 14]
  ------------------
 9014|    213|    return;
 9015|    213|  }
 9016|     14|  buffer.resize(components.hash_start);
 9017|     14|  components.hash_start = url_components::omitted;
 9018|       |
 9019|       |#if ADA_DEVELOPMENT_CHECKS
 9020|       |  ADA_ASSERT_EQUAL(get_hash(), "",
 9021|       |                   "hash should have been cleared on buffer=" + buffer +
 9022|       |                       " with " + components.to_string() + "\n" + to_diagram());
 9023|       |#endif
 9024|     14|  ADA_ASSERT_TRUE(validate());
 9025|     14|}
_ZN3ada14url_aggregator20update_base_pathnameENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8653|  18.0k|inline void url_aggregator::update_base_pathname(const std::string_view input) {
 8654|  18.0k|  ada_log("url_aggregator::update_base_pathname '", input, "' [", input.size(),
 8655|  18.0k|          " bytes] \n", to_diagram());
 8656|  18.0k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 8657|  18.0k|  ADA_ASSERT_TRUE(validate());
 8658|       |
 8659|  18.0k|  const bool begins_with_dashdash = input.starts_with("//");
 8660|  18.0k|  if (!begins_with_dashdash && has_dash_dot()) {
  ------------------
  |  Branch (8660:7): [True: 17.3k, False: 691]
  |  Branch (8660:32): [True: 5, False: 17.3k]
  ------------------
 8661|       |    // We must delete the ./
 8662|      5|    delete_dash_dot();
 8663|      5|  }
 8664|       |
 8665|  18.0k|  if (begins_with_dashdash && !has_opaque_path && !has_authority() &&
  ------------------
  |  Branch (8665:7): [True: 691, False: 17.3k]
  |  Branch (8665:31): [True: 691, False: 0]
  |  Branch (8665:51): [True: 51, False: 640]
  ------------------
 8666|     51|      !has_dash_dot()) {
  ------------------
  |  Branch (8666:7): [True: 45, False: 6]
  ------------------
 8667|       |    // If url's host is null, url does not have an opaque path, url's path's
 8668|       |    // size is greater than 1, then append U+002F (/) followed by U+002E (.) to
 8669|       |    // output.
 8670|     45|    buffer.insert(components.pathname_start, "/.");
 8671|     45|    components.pathname_start += 2;
 8672|     45|    if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8672:9): [True: 0, False: 45]
  ------------------
 8673|      0|      components.search_start += 2;
 8674|      0|    }
 8675|     45|    if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8675:9): [True: 0, False: 45]
  ------------------
 8676|      0|      components.hash_start += 2;
 8677|      0|    }
 8678|     45|  }
 8679|       |
 8680|  18.0k|  uint32_t difference = replace_and_resize(
 8681|  18.0k|      components.pathname_start,
 8682|  18.0k|      components.pathname_start + get_pathname_length(), input);
 8683|  18.0k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8683:7): [True: 0, False: 18.0k]
  ------------------
 8684|      0|    components.search_start += difference;
 8685|      0|  }
 8686|  18.0k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8686:7): [True: 0, False: 18.0k]
  ------------------
 8687|      0|    components.hash_start += difference;
 8688|      0|  }
 8689|  18.0k|  ADA_ASSERT_TRUE(validate());
 8690|  18.0k|}
_ZN3ada14url_aggregator18replace_and_resizeEjjNSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8495|  51.5k|    uint32_t start, uint32_t end, std::string_view input) {
 8496|  51.5k|  uint32_t current_length = end - start;
 8497|  51.5k|  uint32_t input_size = uint32_t(input.size());
 8498|  51.5k|  uint32_t new_difference = input_size - current_length;
 8499|       |
 8500|  51.5k|  if (current_length == 0) {
  ------------------
  |  Branch (8500:7): [True: 49.6k, False: 1.88k]
  ------------------
 8501|  49.6k|    buffer.insert(start, input);
 8502|  49.6k|  } else if (input_size == current_length) {
  ------------------
  |  Branch (8502:14): [True: 389, False: 1.50k]
  ------------------
 8503|    389|    if (input_size != 0) {
  ------------------
  |  Branch (8503:9): [True: 389, False: 0]
  ------------------
 8504|    389|      std::memmove(buffer.data() + start, input.data(), input_size);
 8505|    389|    }
 8506|  1.50k|  } else if (input_size < current_length) {
  ------------------
  |  Branch (8506:14): [True: 668, False: 832]
  ------------------
 8507|    668|    buffer.erase(start, current_length - input_size);
 8508|    668|    buffer.replace(start, input_size, input);
 8509|    832|  } else {
 8510|    832|    buffer.replace(start, current_length, input.substr(0, current_length));
 8511|    832|    buffer.insert(start + current_length, input.substr(current_length));
 8512|    832|  }
 8513|       |
 8514|  51.5k|  return new_difference;
 8515|  51.5k|}
_ZNK3ada14url_aggregator19get_pathname_lengthEv:
 8546|  18.0k|url_aggregator::get_pathname_length() const noexcept {
 8547|  18.0k|  ada_log("url_aggregator::get_pathname_length");
 8548|  18.0k|  uint32_t ending_index = uint32_t(buffer.size());
 8549|  18.0k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8549:7): [True: 0, False: 18.0k]
  ------------------
 8550|      0|    ending_index = components.search_start;
 8551|  18.0k|  } else if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8551:14): [True: 0, False: 18.0k]
  ------------------
 8552|      0|    ending_index = components.hash_start;
 8553|      0|  }
 8554|  18.0k|  return ending_index - components.pathname_start;
 8555|  18.0k|}
_ZNK3ada14url_aggregator12get_pathnameEv:
 9488|  9.35k|    ada_lifetime_bound {
 9489|  9.35k|  ada_log("url_aggregator::get_pathname pathname_start = ",
 9490|  9.35k|          components.pathname_start, " buffer.size() = ", buffer.size(),
 9491|  9.35k|          " components.search_start = ", components.search_start,
 9492|  9.35k|          " components.hash_start = ", components.hash_start);
 9493|  9.35k|  auto ending_index = uint32_t(buffer.size());
 9494|  9.35k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9494:7): [True: 175, False: 9.18k]
  ------------------
 9495|    175|    ending_index = components.search_start;
 9496|  9.18k|  } else if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9496:14): [True: 54, False: 9.12k]
  ------------------
 9497|     54|    ending_index = components.hash_start;
 9498|     54|  }
 9499|  9.35k|  return helpers::substring(buffer, components.pathname_start, ending_index);
 9500|  9.35k|}
_ZN3ada14url_aggregator26update_unencoded_base_hashENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8471|  1.15k|inline void url_aggregator::update_unencoded_base_hash(std::string_view input) {
 8472|  1.15k|  ada_log("url_aggregator::update_unencoded_base_hash ", input, " [",
 8473|  1.15k|          input.size(), " bytes], buffer is '", buffer, "' [", buffer.size(),
 8474|  1.15k|          " bytes] components.hash_start = ", components.hash_start);
 8475|  1.15k|  ADA_ASSERT_TRUE(validate());
 8476|  1.15k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 8477|  1.15k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8477:7): [True: 15, False: 1.14k]
  ------------------
 8478|     15|    buffer.resize(components.hash_start);
 8479|     15|  }
 8480|  1.15k|  components.hash_start = uint32_t(buffer.size());
 8481|  1.15k|  buffer += "#";
 8482|  1.15k|  bool encoding_required = unicode::percent_encode<true>(
 8483|  1.15k|      input, ada::character_sets::FRAGMENT_PERCENT_ENCODE, buffer);
 8484|       |  // When encoding_required is false, then buffer is left unchanged, and percent
 8485|       |  // encoding was not deemed required.
 8486|  1.15k|  if (!encoding_required) {
  ------------------
  |  Branch (8486:7): [True: 699, False: 460]
  ------------------
 8487|    699|    buffer.append(input);
 8488|    699|  }
 8489|  1.15k|  ada_log("url_aggregator::update_unencoded_base_hash final buffer is '",
 8490|  1.15k|          buffer, "' [", buffer.size(), " bytes]");
 8491|  1.15k|  ADA_ASSERT_TRUE(validate());
 8492|  1.15k|}
_ZN3ada3urlC2Ev:
 5106|  49.0k|  url() = default;
_ZN3ada3url11copy_schemeERKS0_:
 7617|    862|constexpr void url::copy_scheme(const ada::url& u) {
 7618|    862|  non_special_scheme = u.non_special_scheme;
 7619|    862|  type = u.type;
 7620|    862|}
_ZN3ada3url26update_unencoded_base_hashENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 7559|  1.03k|inline void url::update_unencoded_base_hash(std::string_view input) {
 7560|       |  // We do the percent encoding
 7561|  1.03k|  hash = unicode::percent_encode(input,
 7562|  1.03k|                                 ada::character_sets::FRAGMENT_PERCENT_ENCODE);
 7563|  1.03k|}
_ZN3ada3url12clear_searchEv:
 7592|    608|constexpr void url::clear_search() { query = std::nullopt; }
_ZN3ada3url18update_base_searchENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKh:
 7566|  1.36k|                                    const uint8_t query_percent_encode_set[]) {
 7567|  1.36k|  query = ada::unicode::percent_encode(input, query_percent_encode_set);
 7568|  1.36k|}
_ZN3ada3url20update_base_hostnameENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 7557|    131|inline void url::update_base_hostname(std::string_view input) { host = input; }
_ZN3ada3url20update_base_pathnameENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 7574|  9.60k|inline void url::update_base_pathname(const std::string_view input) {
 7575|  9.60k|  path = input;
 7576|  9.60k|}
_ZN3ada3url10parse_portENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEb:
 7749|  2.22k|                                         bool check_trailing_content) noexcept {
 7750|  2.22k|  ada_log("parse_port('", view, "') ", view.size());
 7751|  2.22k|  if (!view.empty() && view[0] == '-') {
  ------------------
  |  Branch (7751:7): [True: 1.59k, False: 637]
  |  Branch (7751:24): [True: 6, False: 1.58k]
  ------------------
 7752|      6|    ada_log("parse_port: view[0] == '0' && view.size() > 1");
 7753|      6|    is_valid = false;
 7754|      6|    return 0;
 7755|      6|  }
 7756|  2.22k|  uint16_t parsed_port{};
 7757|  2.22k|  auto r = std::from_chars(view.data(), view.data() + view.size(), parsed_port);
 7758|  2.22k|  if (r.ec == std::errc::result_out_of_range) {
  ------------------
  |  Branch (7758:7): [True: 35, False: 2.18k]
  ------------------
 7759|     35|    ada_log("parse_port: r.ec == std::errc::result_out_of_range");
 7760|     35|    is_valid = false;
 7761|     35|    return 0;
 7762|     35|  }
 7763|  2.18k|  ada_log("parse_port: ", parsed_port);
 7764|  2.18k|  const auto consumed = size_t(r.ptr - view.data());
 7765|  2.18k|  ada_log("parse_port: consumed ", consumed);
 7766|  2.18k|  if (check_trailing_content) {
  ------------------
  |  Branch (7766:7): [True: 2.18k, False: 0]
  ------------------
 7767|  2.18k|    is_valid &=
 7768|  2.18k|        (consumed == view.size() || view[consumed] == '/' ||
  ------------------
  |  Branch (7768:10): [True: 1.25k, False: 931]
  |  Branch (7768:37): [True: 743, False: 188]
  ------------------
 7769|    188|         view[consumed] == '?' || (is_special() && view[consumed] == '\\'));
  ------------------
  |  Branch (7769:10): [True: 109, False: 79]
  |  Branch (7769:36): [True: 75, False: 4]
  |  Branch (7769:52): [True: 2, False: 73]
  ------------------
 7770|  2.18k|  }
 7771|  2.18k|  ada_log("parse_port: is_valid = ", is_valid);
 7772|  2.18k|  if (is_valid) {
  ------------------
  |  Branch (7772:7): [True: 2.11k, False: 77]
  ------------------
 7773|       |    // scheme_default_port can return 0, and we should allow 0 as a base port.
 7774|  2.11k|    auto default_port = scheme_default_port();
 7775|  2.11k|    bool is_port_valid = (default_port == 0 && parsed_port == 0) ||
  ------------------
  |  Branch (7775:27): [True: 78, False: 2.03k]
  |  Branch (7775:48): [True: 24, False: 54]
  ------------------
 7776|  2.08k|                         (default_port != parsed_port);
  ------------------
  |  Branch (7776:26): [True: 2.07k, False: 7]
  ------------------
 7777|  2.11k|    port = (r.ec == std::errc() && is_port_valid) ? std::optional(parsed_port)
  ------------------
  |  Branch (7777:13): [True: 1.37k, False: 734]
  |  Branch (7777:36): [True: 1.36k, False: 7]
  ------------------
 7778|  2.11k|                                                  : std::nullopt;
 7779|  2.11k|  }
 7780|  2.18k|  return consumed;
 7781|  2.22k|}
_ZNK3ada8url_base19scheme_default_portEv:
 7420|  6.51k|url_base::scheme_default_port() const noexcept {
 7421|  6.51k|  return scheme::get_special_port(type);
 7422|  6.51k|}
_ZNK3ada3url12get_pathnameEv:
 7477|    167|[[nodiscard]] constexpr std::string_view url::get_pathname() const noexcept {
 7478|    167|  return path;
 7479|    167|}
_ZN3ada8checkers23is_windows_drive_letterENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 1285|  10.4k|constexpr bool is_windows_drive_letter(std::string_view input) noexcept {
 1286|  10.4k|  return input.size() >= 2 &&
  ------------------
  |  Branch (1286:10): [True: 7.11k, False: 3.34k]
  ------------------
 1287|  7.11k|         (is_alpha(input[0]) && ((input[1] == ':') || (input[1] == '|'))) &&
  ------------------
  |  Branch (1287:11): [True: 2.69k, False: 4.42k]
  |  Branch (1287:34): [True: 558, False: 2.13k]
  |  Branch (1287:55): [True: 196, False: 1.94k]
  ------------------
 1288|    754|         ((input.size() == 2) || (input[2] == '/' || input[2] == '\\' ||
  ------------------
  |  Branch (1288:11): [True: 451, False: 303]
  |  Branch (1288:35): [True: 121, False: 182]
  |  Branch (1288:54): [True: 24, False: 158]
  ------------------
 1289|    158|                                  input[2] == '?' || input[2] == '#'));
  ------------------
  |  Branch (1289:35): [True: 5, False: 153]
  |  Branch (1289:54): [True: 0, False: 153]
  ------------------
 1290|  10.4k|}
_ZN3ada8checkers34is_normalized_windows_drive_letterENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 1293|  1.66k|    std::string_view input) noexcept {
 1294|  1.66k|  return input.size() == 2 && (is_alpha(input[0]) && (input[1] == ':'));
  ------------------
  |  Branch (1294:10): [True: 962, False: 704]
  |  Branch (1294:32): [True: 818, False: 144]
  |  Branch (1294:54): [True: 744, False: 74]
  ------------------
 1295|  1.66k|}
_ZN3ada3url20set_protocol_as_fileEv:
 7602|  2.77k|constexpr void url::set_protocol_as_file() { type = ada::scheme::type::FILE; }
_ZN3ada3url14clear_pathnameEv:
 7590|     13|constexpr void url::clear_pathname() { path.clear(); }
_ZN3ada7helpers14leading_zeroesEj:
 2001|  43.7k|inline int leading_zeroes(uint32_t input_num) noexcept {
 2002|       |#if ADA_REGULAR_VISUAL_STUDIO
 2003|       |  unsigned long leading_zero(0);
 2004|       |  unsigned long in(input_num);
 2005|       |  return _BitScanReverse(&leading_zero, in) ? int(31 - leading_zero) : 32;
 2006|       |#else
 2007|  43.7k|  return __builtin_clz(input_num);
 2008|  43.7k|#endif  // ADA_REGULAR_VISUAL_STUDIO
 2009|  43.7k|}
_ZN3ada14url_aggregator7reserveEj:
 9161|  43.7k|constexpr void ada::url_aggregator::reserve(uint32_t capacity) {
 9162|  43.7k|  buffer.reserve(capacity);
 9163|  43.7k|}
_ZN3ada14url_aggregator18update_base_searchENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8562|    149|inline void url_aggregator::update_base_search(std::string_view input) {
 8563|    149|  ada_log("url_aggregator::update_base_search ", input);
 8564|    149|  ADA_ASSERT_TRUE(validate());
 8565|    149|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 8566|    149|  if (input.empty()) {
  ------------------
  |  Branch (8566:7): [True: 0, False: 149]
  ------------------
 8567|      0|    clear_search();
 8568|      0|    return;
 8569|      0|  }
 8570|       |
 8571|    149|  if (input[0] == '?') {
  ------------------
  |  Branch (8571:7): [True: 149, False: 0]
  ------------------
 8572|    149|    input.remove_prefix(1);
 8573|    149|  }
 8574|       |
 8575|    149|  if (components.hash_start == url_components::omitted) {
  ------------------
  |  Branch (8575:7): [True: 149, False: 0]
  ------------------
 8576|    149|    if (components.search_start == url_components::omitted) {
  ------------------
  |  Branch (8576:9): [True: 149, False: 0]
  ------------------
 8577|    149|      components.search_start = uint32_t(buffer.size());
 8578|    149|      buffer += "?";
 8579|    149|    } else {
 8580|      0|      buffer.resize(components.search_start + 1);
 8581|      0|    }
 8582|       |
 8583|    149|    buffer.append(input);
 8584|    149|  } else if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8584:14): [True: 0, False: 0]
  ------------------
 8585|      0|    const uint32_t difference = replace_and_resize(
 8586|      0|        components.search_start + 1, components.hash_start, input);
 8587|      0|    components.hash_start += difference;
 8588|      0|  } else {
 8589|      0|    components.search_start = components.hash_start;
 8590|      0|    buffer.insert(components.search_start, input.size() + 1, '?');
 8591|      0|    if (!input.empty()) {
  ------------------
  |  Branch (8591:9): [True: 0, False: 0]
  ------------------
 8592|      0|      std::memmove(buffer.data() + components.search_start + 1, input.data(),
 8593|      0|                   input.size());
 8594|      0|    }
 8595|      0|    components.hash_start += uint32_t(input.size() + 1);  // Do not forget `?`
 8596|      0|  }
 8597|       |
 8598|    149|  ADA_ASSERT_TRUE(validate());
 8599|    149|}
_ZN3ada14url_aggregator20append_base_passwordENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8879|  7.05k|inline void url_aggregator::append_base_password(const std::string_view input) {
 8880|  7.05k|  ada_log("url_aggregator::append_base_password ", input, " ", to_string(),
 8881|  7.05k|          "\n", to_diagram());
 8882|  7.05k|  ADA_ASSERT_TRUE(validate());
 8883|  7.05k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 8884|       |#if ADA_DEVELOPMENT_CHECKS
 8885|       |  // computing the expected password.
 8886|       |  std::string password_expected = std::string(get_password());
 8887|       |  password_expected.append(input);
 8888|       |#endif  // ADA_DEVELOPMENT_CHECKS
 8889|  7.05k|  add_authority_slashes_if_needed();
 8890|       |
 8891|       |  // If input is empty, do nothing.
 8892|  7.05k|  if (input.empty()) {
  ------------------
  |  Branch (8892:7): [True: 1.89k, False: 5.16k]
  ------------------
 8893|  1.89k|    return;
 8894|  1.89k|  }
 8895|       |
 8896|  5.16k|  uint32_t difference = uint32_t(input.size());
 8897|  5.16k|  if (has_password()) {
  ------------------
  |  Branch (8897:7): [True: 4.60k, False: 561]
  ------------------
 8898|  4.60k|    buffer.insert(components.host_start, input);
 8899|  4.60k|  } else {
 8900|    561|    difference++;  // Increment for ":"
 8901|    561|    buffer.insert(components.username_end, ":");
 8902|    561|    buffer.insert(components.username_end + 1, input);
 8903|    561|  }
 8904|  5.16k|  components.host_start += difference;
 8905|       |
 8906|       |  // The following line is required to add "@" to hostname. When updating
 8907|       |  // password if hostname does not start with "@", it is "append_base_password"s
 8908|       |  // responsibility to set it.
 8909|  5.16k|  if (buffer[components.host_start] != '@') {
  ------------------
  |  Branch (8909:7): [True: 373, False: 4.79k]
  ------------------
 8910|    373|    buffer.insert(components.host_start, "@");
 8911|    373|    difference++;
 8912|    373|  }
 8913|       |
 8914|  5.16k|  components.host_end += difference;
 8915|  5.16k|  components.pathname_start += difference;
 8916|  5.16k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8916:7): [True: 0, False: 5.16k]
  ------------------
 8917|      0|    components.search_start += difference;
 8918|      0|  }
 8919|  5.16k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8919:7): [True: 0, False: 5.16k]
  ------------------
 8920|      0|    components.hash_start += difference;
 8921|      0|  }
 8922|       |#if ADA_DEVELOPMENT_CHECKS
 8923|       |  std::string password_after(get_password());
 8924|       |  ADA_ASSERT_EQUAL(
 8925|       |      password_expected, password_after,
 8926|       |      "append_base_password problem after inserting " + std::string(input));
 8927|       |#endif  // ADA_DEVELOPMENT_CHECKS
 8928|  5.16k|  ADA_ASSERT_TRUE(validate());
 8929|  5.16k|}
_ZN3ada14url_aggregator31add_authority_slashes_if_neededEv:
 9135|  50.7k|inline void ada::url_aggregator::add_authority_slashes_if_needed() {
 9136|  50.7k|  ada_log("url_aggregator::add_authority_slashes_if_needed");
 9137|  50.7k|  ADA_ASSERT_TRUE(validate());
 9138|       |  // Protocol setter will insert `http:` to the URL. It is up to hostname setter
 9139|       |  // to insert
 9140|       |  // `//` initially to the buffer, since it depends on the hostname existence.
 9141|  50.7k|  if (has_authority()) {
  ------------------
  |  Branch (9141:7): [True: 22.5k, False: 28.2k]
  ------------------
 9142|  22.5k|    return;
 9143|  22.5k|  }
 9144|       |  // Performance: the common case is components.protocol_end == buffer.size()
 9145|       |  // Optimization opportunity: in many cases, the "//" is part of the input and
 9146|       |  // the insert could be fused with another insert.
 9147|  28.2k|  buffer.insert(components.protocol_end, "//");
 9148|  28.2k|  components.username_end += 2;
 9149|  28.2k|  components.host_start += 2;
 9150|  28.2k|  components.host_end += 2;
 9151|  28.2k|  components.pathname_start += 2;
 9152|  28.2k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9152:7): [True: 0, False: 28.2k]
  ------------------
 9153|      0|    components.search_start += 2;
 9154|      0|  }
 9155|  28.2k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9155:7): [True: 0, False: 28.2k]
  ------------------
 9156|      0|    components.hash_start += 2;
 9157|      0|  }
 9158|  28.2k|  ADA_ASSERT_TRUE(validate());
 9159|  28.2k|}
_ZN3ada14url_aggregator20append_base_usernameENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8763|  10.2k|inline void url_aggregator::append_base_username(const std::string_view input) {
 8764|  10.2k|  ada_log("url_aggregator::append_base_username ", input);
 8765|  10.2k|  ADA_ASSERT_TRUE(validate());
 8766|  10.2k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 8767|       |#if ADA_DEVELOPMENT_CHECKS
 8768|       |  // computing the expected password.
 8769|       |  std::string username_expected(get_username());
 8770|       |  username_expected.append(input);
 8771|       |#endif  // ADA_DEVELOPMENT_CHECKS
 8772|  10.2k|  add_authority_slashes_if_needed();
 8773|       |
 8774|       |  // If input is empty, do nothing.
 8775|  10.2k|  if (input.empty()) {
  ------------------
  |  Branch (8775:7): [True: 2.82k, False: 7.47k]
  ------------------
 8776|  2.82k|    return;
 8777|  2.82k|  }
 8778|       |
 8779|  7.47k|  uint32_t difference = uint32_t(input.size());
 8780|  7.47k|  buffer.insert(components.username_end, input);
 8781|  7.47k|  components.username_end += difference;
 8782|  7.47k|  components.host_start += difference;
 8783|       |
 8784|  7.47k|  if (buffer[components.host_start] != '@' &&
  ------------------
  |  Branch (8784:7): [True: 1.14k, False: 6.32k]
  ------------------
 8785|  1.14k|      components.host_start != components.host_end) {
  ------------------
  |  Branch (8785:7): [True: 1.14k, False: 0]
  ------------------
 8786|  1.14k|    buffer.insert(components.host_start, "@");
 8787|  1.14k|    difference++;
 8788|  1.14k|  }
 8789|       |
 8790|  7.47k|  components.host_end += difference;
 8791|  7.47k|  components.pathname_start += difference;
 8792|  7.47k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8792:7): [True: 0, False: 7.47k]
  ------------------
 8793|      0|    components.search_start += difference;
 8794|      0|  }
 8795|  7.47k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8795:7): [True: 0, False: 7.47k]
  ------------------
 8796|      0|    components.hash_start += difference;
 8797|      0|  }
 8798|       |#if ADA_DEVELOPMENT_CHECKS
 8799|       |  std::string username_after(get_username());
 8800|       |  ADA_ASSERT_EQUAL(
 8801|       |      username_expected, username_after,
 8802|       |      "append_base_username problem after inserting " + std::string(input));
 8803|       |#endif  // ADA_DEVELOPMENT_CHECKS
 8804|  7.47k|  ADA_ASSERT_TRUE(validate());
 8805|  7.47k|}
_ZN3ada14url_aggregator21update_base_authorityENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEERKNS_14url_componentsE:
 8413|  1.87k|    std::string_view base_buffer, const ada::url_components& base) {
 8414|  1.87k|  std::string_view input = base_buffer.substr(
 8415|  1.87k|      base.protocol_end, base.host_start - base.protocol_end);
 8416|  1.87k|  ada_log("url_aggregator::update_base_authority ", input);
 8417|       |
 8418|  1.87k|  bool input_starts_with_dash = input.starts_with("//");
 8419|  1.87k|  uint32_t diff = components.host_start - components.protocol_end;
 8420|       |
 8421|  1.87k|  buffer.erase(components.protocol_end,
 8422|  1.87k|               components.host_start - components.protocol_end);
 8423|  1.87k|  components.username_end = components.protocol_end;
 8424|       |
 8425|  1.87k|  if (input_starts_with_dash) {
  ------------------
  |  Branch (8425:7): [True: 1.61k, False: 256]
  ------------------
 8426|  1.61k|    input.remove_prefix(2);
 8427|  1.61k|    diff += 2;  // add "//"
 8428|  1.61k|    buffer.insert(components.protocol_end, "//");
 8429|  1.61k|    components.username_end += 2;
 8430|  1.61k|  }
 8431|       |
 8432|  1.87k|  size_t password_delimiter = input.find(':');
 8433|       |
 8434|       |  // Check if input contains both username and password by checking the
 8435|       |  // delimiter: ":" A typical input that contains authority would be "user:pass"
 8436|  1.87k|  if (password_delimiter != std::string_view::npos) {
  ------------------
  |  Branch (8436:7): [True: 36, False: 1.83k]
  ------------------
 8437|       |    // Insert both username and password
 8438|     36|    std::string_view username = input.substr(0, password_delimiter);
 8439|     36|    std::string_view password = input.substr(password_delimiter + 1);
 8440|       |
 8441|     36|    buffer.insert(components.protocol_end + diff, username);
 8442|     36|    diff += uint32_t(username.size());
 8443|     36|    buffer.insert(components.protocol_end + diff, ":");
 8444|     36|    components.username_end = components.protocol_end + diff;
 8445|     36|    buffer.insert(components.protocol_end + diff + 1, password);
 8446|     36|    diff += uint32_t(password.size()) + 1;
 8447|  1.83k|  } else if (!input.empty()) {
  ------------------
  |  Branch (8447:14): [True: 37, False: 1.79k]
  ------------------
 8448|       |    // Insert only username
 8449|     37|    buffer.insert(components.protocol_end + diff, input);
 8450|     37|    components.username_end =
 8451|     37|        components.protocol_end + diff + uint32_t(input.size());
 8452|     37|    diff += uint32_t(input.size());
 8453|     37|  }
 8454|       |
 8455|  1.87k|  components.host_start += diff;
 8456|       |
 8457|  1.87k|  if (buffer.size() > base.host_start && buffer[base.host_start] != '@') {
  ------------------
  |  Branch (8457:7): [True: 0, False: 1.87k]
  |  Branch (8457:42): [True: 0, False: 0]
  ------------------
 8458|      0|    buffer.insert(components.host_start, "@");
 8459|      0|    diff++;
 8460|      0|  }
 8461|  1.87k|  components.host_end += diff;
 8462|  1.87k|  components.pathname_start += diff;
 8463|  1.87k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8463:7): [True: 0, False: 1.87k]
  ------------------
 8464|      0|    components.search_start += diff;
 8465|      0|  }
 8466|  1.87k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8466:7): [True: 0, False: 1.87k]
  ------------------
 8467|      0|    components.hash_start += diff;
 8468|      0|  }
 8469|  1.87k|}
_ZNK3ada14url_aggregator8get_hrefEv:
 9239|  29.6k|    const noexcept ada_lifetime_bound {
 9240|  29.6k|  ada_log("url_aggregator::get_href");
 9241|  29.6k|  return buffer;
 9242|  29.6k|}
_ZNK3ada14url_aggregator14get_componentsEv:
 9121|  1.87k|url_aggregator::get_components() const noexcept {
 9122|  1.87k|  return components;
 9123|  1.87k|}
_ZN3ada14url_aggregator24update_host_to_base_hostENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 9507|  2.32k|void url_aggregator::update_host_to_base_host(const std::string_view input) {
 9508|  2.32k|  ada_log("url_aggregator::update_host_to_base_host ", input);
 9509|  2.32k|  ADA_ASSERT_TRUE(validate());
 9510|  2.32k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 9511|  2.32k|  if (type != ada::scheme::type::FILE) {
  ------------------
  |  Branch (9511:7): [True: 1.87k, False: 452]
  ------------------
 9512|       |    // Let host be the result of host parsing host_view with url is not special.
 9513|  1.87k|    if (input.empty() && !is_special()) {
  ------------------
  |  Branch (9513:9): [True: 276, False: 1.59k]
  |  Branch (9513:26): [True: 276, False: 0]
  ------------------
 9514|    276|      if (has_hostname()) {
  ------------------
  |  Branch (9514:11): [True: 20, False: 256]
  ------------------
 9515|     20|        clear_hostname();
 9516|    256|      } else if (has_dash_dot()) {
  ------------------
  |  Branch (9516:18): [True: 0, False: 256]
  ------------------
 9517|      0|        add_authority_slashes_if_needed();
 9518|      0|        delete_dash_dot();
 9519|      0|      }
 9520|    276|      return;
 9521|    276|    }
 9522|  1.87k|  }
 9523|  2.04k|  update_base_hostname(input);
 9524|  2.04k|  ADA_ASSERT_TRUE(validate());
 9525|  2.04k|  return;
 9526|  2.32k|}
_ZN3ada14url_aggregator14clear_hostnameEv:
 9062|     20|constexpr void url_aggregator::clear_hostname() {
 9063|     20|  ada_log("url_aggregator::clear_hostname");
 9064|     20|  ADA_ASSERT_TRUE(validate());
 9065|     20|  if (!has_authority()) {
  ------------------
  |  Branch (9065:7): [True: 0, False: 20]
  ------------------
 9066|      0|    return;
 9067|      0|  }
 9068|     20|  ADA_ASSERT_TRUE(has_authority());
 9069|       |
 9070|     20|  uint32_t hostname_length = components.host_end - components.host_start;
 9071|     20|  uint32_t start = components.host_start;
 9072|       |
 9073|       |  // If hostname starts with "@", we should not remove that character.
 9074|     20|  if (hostname_length > 0 && buffer[start] == '@') {
  ------------------
  |  Branch (9074:7): [True: 0, False: 20]
  |  Branch (9074:30): [True: 0, False: 0]
  ------------------
 9075|      0|    start++;
 9076|      0|    hostname_length--;
 9077|      0|  }
 9078|     20|  buffer.erase(start, hostname_length);
 9079|     20|  components.host_end = start;
 9080|     20|  components.pathname_start -= hostname_length;
 9081|     20|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9081:7): [True: 0, False: 20]
  ------------------
 9082|      0|    components.search_start -= hostname_length;
 9083|      0|  }
 9084|     20|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9084:7): [True: 0, False: 20]
  ------------------
 9085|      0|    components.hash_start -= hostname_length;
 9086|      0|  }
 9087|       |#if ADA_DEVELOPMENT_CHECKS
 9088|       |  ADA_ASSERT_EQUAL(get_hostname(), "",
 9089|       |                   "hostname should have been cleared on buffer=" + buffer +
 9090|       |                       " with " + components.to_string() + "\n" + to_diagram());
 9091|       |#endif
 9092|     20|  ADA_ASSERT_TRUE(has_authority());
 9093|     20|  ADA_ASSERT_EQUAL(has_empty_hostname(), true,
 9094|     20|                   "hostname should have been cleared on buffer=" + buffer +
 9095|     20|                       " with " + components.to_string() + "\n" + to_diagram());
 9096|     20|  ADA_ASSERT_TRUE(validate());
 9097|     20|}
_ZN3ada14url_aggregator16update_base_portEj:
 8931|  4.62k|inline void url_aggregator::update_base_port(uint32_t input) {
 8932|  4.62k|  ada_log("url_aggregator::update_base_port");
 8933|  4.62k|  ADA_ASSERT_TRUE(validate());
 8934|  4.62k|  if (input == url_components::omitted) {
  ------------------
  |  Branch (8934:7): [True: 1.85k, False: 2.77k]
  ------------------
 8935|  1.85k|    clear_port();
 8936|  1.85k|    return;
 8937|  1.85k|  }
 8938|       |  // calling std::to_string(input.value()) is unfortunate given that the port
 8939|       |  // value is probably already available as a string.
 8940|  2.77k|  std::string value = helpers::concat(":", std::to_string(input));
 8941|  2.77k|  uint32_t difference = uint32_t(value.size());
 8942|       |
 8943|  2.77k|  if (components.port != url_components::omitted) {
  ------------------
  |  Branch (8943:7): [True: 0, False: 2.77k]
  ------------------
 8944|      0|    difference -= components.pathname_start - components.host_end;
 8945|      0|    buffer.erase(components.host_end,
 8946|      0|                 components.pathname_start - components.host_end);
 8947|      0|  }
 8948|       |
 8949|  2.77k|  buffer.insert(components.host_end, value);
 8950|  2.77k|  components.pathname_start += difference;
 8951|  2.77k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8951:7): [True: 0, False: 2.77k]
  ------------------
 8952|      0|    components.search_start += difference;
 8953|      0|  }
 8954|  2.77k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8954:7): [True: 0, False: 2.77k]
  ------------------
 8955|      0|    components.hash_start += difference;
 8956|      0|  }
 8957|  2.77k|  components.port = input;
 8958|  2.77k|  ADA_ASSERT_TRUE(validate());
 8959|  2.77k|}
_ZN3ada7helpers6concatIJPKcNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEEEESA_DpT_:
 1991|  2.77k|std::string concat(Args... args) {
 1992|  2.77k|  std::string answer;
 1993|  2.77k|  inner_concat(answer, args...);
 1994|  2.77k|  return answer;
 1995|  2.77k|}
_ZN3ada7helpers12inner_concatIPKcJNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEEEEvRSA_T_DpT0_:
 1980|  2.77k|inline void inner_concat(std::string& buffer, T t, Args... args) {
 1981|  2.77k|  buffer.append(t);
 1982|  2.77k|  return inner_concat(buffer, args...);
 1983|  2.77k|}
_ZN3ada7helpers12inner_concatINSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEJEEEvRS8_T_:
 1972|  2.77k|inline void inner_concat(std::string& buffer, T t) {
 1973|  2.77k|  buffer.append(t);
 1974|  2.77k|}
_ZNK3ada14url_aggregator18retrieve_base_portEv:
 8980|  1.87k|[[nodiscard]] inline uint32_t url_aggregator::retrieve_base_port() const {
 8981|  1.87k|  ada_log("url_aggregator::retrieve_base_port");
 8982|  1.87k|  return components.port;
 8983|  1.87k|}
_ZN3ada14url_aggregator12clear_searchEv:
 8985|  1.60k|inline void url_aggregator::clear_search() {
 8986|  1.60k|  ada_log("url_aggregator::clear_search");
 8987|  1.60k|  ADA_ASSERT_TRUE(validate());
 8988|  1.60k|  if (components.search_start == url_components::omitted) {
  ------------------
  |  Branch (8988:7): [True: 1.53k, False: 70]
  ------------------
 8989|  1.53k|    return;
 8990|  1.53k|  }
 8991|       |
 8992|     70|  if (components.hash_start == url_components::omitted) {
  ------------------
  |  Branch (8992:7): [True: 70, False: 0]
  ------------------
 8993|     70|    buffer.resize(components.search_start);
 8994|     70|  } else {
 8995|      0|    buffer.erase(components.search_start,
 8996|      0|                 components.hash_start - components.search_start);
 8997|      0|    components.hash_start = components.search_start;
 8998|      0|  }
 8999|       |
 9000|     70|  components.search_start = url_components::omitted;
 9001|       |
 9002|       |#if ADA_DEVELOPMENT_CHECKS
 9003|       |  ADA_ASSERT_EQUAL(get_search(), "",
 9004|       |                   "search should have been cleared on buffer=" + buffer +
 9005|       |                       " with " + components.to_string() + "\n" + to_diagram());
 9006|       |#endif
 9007|     70|  ADA_ASSERT_TRUE(validate());
 9008|     70|}
_ZN3ada14url_aggregator18update_base_searchENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKh:
 8602|  1.36k|    std::string_view input, const uint8_t query_percent_encode_set[]) {
 8603|  1.36k|  ada_log("url_aggregator::update_base_search ", input,
 8604|  1.36k|          " with encoding parameter ", to_string(), "\n", to_diagram());
 8605|  1.36k|  ADA_ASSERT_TRUE(validate());
 8606|  1.36k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 8607|       |
 8608|  1.36k|  if (components.hash_start == url_components::omitted) {
  ------------------
  |  Branch (8608:7): [True: 1.36k, False: 0]
  ------------------
 8609|  1.36k|    if (components.search_start == url_components::omitted) {
  ------------------
  |  Branch (8609:9): [True: 1.34k, False: 14]
  ------------------
 8610|  1.34k|      components.search_start = uint32_t(buffer.size());
 8611|  1.34k|      buffer += "?";
 8612|  1.34k|    } else {
 8613|     14|      buffer.resize(components.search_start + 1);
 8614|     14|    }
 8615|       |
 8616|  1.36k|    bool encoding_required =
 8617|  1.36k|        unicode::percent_encode<true>(input, query_percent_encode_set, buffer);
 8618|       |    // When encoding_required is false, then buffer is left unchanged, and
 8619|       |    // percent encoding was not deemed required.
 8620|  1.36k|    if (!encoding_required) {
  ------------------
  |  Branch (8620:9): [True: 888, False: 473]
  ------------------
 8621|    888|      buffer.append(input);
 8622|    888|    }
 8623|  1.36k|  } else {
 8624|      0|    const size_t idx =
 8625|      0|        ada::unicode::percent_encode_index(input, query_percent_encode_set);
 8626|      0|    std::string encoded;
 8627|      0|    std::string_view replacement = input;
 8628|      0|    if (idx != input.size()) {
  ------------------
  |  Branch (8628:9): [True: 0, False: 0]
  ------------------
 8629|      0|      encoded =
 8630|      0|          ada::unicode::percent_encode(input, query_percent_encode_set, idx);
 8631|      0|      replacement = encoded;
 8632|      0|    }
 8633|       |
 8634|      0|    if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8634:9): [True: 0, False: 0]
  ------------------
 8635|      0|      const uint32_t difference = replace_and_resize(
 8636|      0|          components.search_start + 1, components.hash_start, replacement);
 8637|      0|      components.hash_start += difference;
 8638|      0|    } else {
 8639|      0|      components.search_start = components.hash_start;
 8640|      0|      buffer.insert(components.search_start, replacement.size() + 1, '?');
 8641|      0|      if (!replacement.empty()) {
  ------------------
  |  Branch (8641:11): [True: 0, False: 0]
  ------------------
 8642|      0|        std::memmove(buffer.data() + components.search_start + 1,
 8643|      0|                     replacement.data(), replacement.size());
 8644|      0|      }
 8645|      0|      components.hash_start +=
 8646|      0|          uint32_t(replacement.size() + 1);  // Do not forget `?`
 8647|      0|    }
 8648|      0|  }
 8649|       |
 8650|  1.36k|  ADA_ASSERT_TRUE(validate());
 8651|  1.36k|}
_ZN3ada14url_aggregator20update_base_hostnameENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8517|  33.4k|inline void url_aggregator::update_base_hostname(const std::string_view input) {
 8518|  33.4k|  ada_log("url_aggregator::update_base_hostname ", input, " [", input.size(),
 8519|  33.4k|          " bytes], buffer is '", buffer, "' [", buffer.size(), " bytes]");
 8520|  33.4k|  ADA_ASSERT_TRUE(validate());
 8521|  33.4k|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 8522|       |
 8523|       |  // This next line is required for when parsing a URL like `foo://`
 8524|  33.4k|  add_authority_slashes_if_needed();
 8525|       |
 8526|  33.4k|  bool has_credentials = components.protocol_end + 2 < components.host_start;
 8527|  33.4k|  uint32_t new_difference =
 8528|  33.4k|      replace_and_resize(components.host_start, components.host_end, input);
 8529|       |
 8530|  33.4k|  if (has_credentials) {
  ------------------
  |  Branch (8530:7): [True: 957, False: 32.4k]
  ------------------
 8531|    957|    buffer.insert(components.host_start, "@");
 8532|    957|    new_difference++;
 8533|    957|  }
 8534|  33.4k|  components.host_end += new_difference;
 8535|  33.4k|  components.pathname_start += new_difference;
 8536|  33.4k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8536:7): [True: 0, False: 33.4k]
  ------------------
 8537|      0|    components.search_start += new_difference;
 8538|      0|  }
 8539|  33.4k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8539:7): [True: 0, False: 33.4k]
  ------------------
 8540|      0|    components.hash_start += new_difference;
 8541|      0|  }
 8542|  33.4k|  ADA_ASSERT_TRUE(validate());
 8543|  33.4k|}
_ZN3ada14url_aggregator10parse_portENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEb:
 9249|  4.61k|url_aggregator::parse_port(std::string_view view, bool check_trailing_content) {
 9250|  4.61k|  ada_log("url_aggregator::parse_port('", view, "') ", view.size());
 9251|  4.61k|  if (!view.empty() && view[0] == '-') {
  ------------------
  |  Branch (9251:7): [True: 3.33k, False: 1.28k]
  |  Branch (9251:24): [True: 10, False: 3.32k]
  ------------------
 9252|     10|    ada_log("parse_port: view[0] == '0' && view.size() > 1");
 9253|     10|    is_valid = false;
 9254|     10|    return 0;
 9255|     10|  }
 9256|  4.60k|  uint16_t parsed_port{};
 9257|  4.60k|  auto r = std::from_chars(view.data(), view.data() + view.size(), parsed_port);
 9258|  4.60k|  if (r.ec == std::errc::result_out_of_range) {
  ------------------
  |  Branch (9258:7): [True: 63, False: 4.54k]
  ------------------
 9259|     63|    ada_log("parse_port: r.ec == std::errc::result_out_of_range");
 9260|     63|    is_valid = false;
 9261|     63|    return 0;
 9262|     63|  }
 9263|  4.54k|  ada_log("parse_port: ", parsed_port);
 9264|  4.54k|  const size_t consumed = size_t(r.ptr - view.data());
 9265|  4.54k|  ada_log("parse_port: consumed ", consumed);
 9266|  4.54k|  if (check_trailing_content) {
  ------------------
  |  Branch (9266:7): [True: 4.54k, False: 0]
  ------------------
 9267|  4.54k|    is_valid &=
 9268|  4.54k|        (consumed == view.size() || view[consumed] == '/' ||
  ------------------
  |  Branch (9268:10): [True: 2.52k, False: 2.01k]
  |  Branch (9268:37): [True: 1.63k, False: 382]
  ------------------
 9269|    382|         view[consumed] == '?' || (is_special() && view[consumed] == '\\'));
  ------------------
  |  Branch (9269:10): [True: 236, False: 146]
  |  Branch (9269:36): [True: 138, False: 8]
  |  Branch (9269:52): [True: 3, False: 135]
  ------------------
 9270|  4.54k|  }
 9271|  4.54k|  ada_log("parse_port: is_valid = ", is_valid);
 9272|  4.54k|  if (is_valid) {
  ------------------
  |  Branch (9272:7): [True: 4.40k, False: 143]
  ------------------
 9273|  4.40k|    ada_log("parse_port", r.ec == std::errc());
 9274|       |    // scheme_default_port can return 0, and we should allow 0 as a base port.
 9275|  4.40k|    auto default_port = scheme_default_port();
 9276|  4.40k|    bool is_port_valid = (default_port == 0 && parsed_port == 0) ||
  ------------------
  |  Branch (9276:27): [True: 156, False: 4.24k]
  |  Branch (9276:48): [True: 48, False: 108]
  ------------------
 9277|  4.35k|                         (default_port != parsed_port);
  ------------------
  |  Branch (9277:26): [True: 4.33k, False: 16]
  ------------------
 9278|  4.40k|    if (r.ec == std::errc() && is_port_valid) {
  ------------------
  |  Branch (9278:9): [True: 2.77k, False: 1.63k]
  |  Branch (9278:32): [True: 2.75k, False: 16]
  ------------------
 9279|  2.75k|      update_base_port(parsed_port);
 9280|  2.75k|    } else {
 9281|  1.64k|      clear_port();
 9282|  1.64k|    }
 9283|  4.40k|  }
 9284|  4.54k|  return consumed;
 9285|  4.60k|}
_ZN3ada14url_aggregator20append_base_pathnameENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEE:
 8692|      2|inline void url_aggregator::append_base_pathname(const std::string_view input) {
 8693|      2|  ada_log("url_aggregator::append_base_pathname ", input, " ", to_string(),
 8694|      2|          "\n", to_diagram());
 8695|      2|  ADA_ASSERT_TRUE(validate());
 8696|      2|  ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
 8697|       |#if ADA_DEVELOPMENT_CHECKS
 8698|       |  // computing the expected password.
 8699|       |  std::string path_expected(get_pathname());
 8700|       |  path_expected.append(input);
 8701|       |#endif  // ADA_DEVELOPMENT_CHECKS
 8702|      2|  uint32_t ending_index = uint32_t(buffer.size());
 8703|      2|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8703:7): [True: 0, False: 2]
  ------------------
 8704|      0|    ending_index = components.search_start;
 8705|      2|  } else if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8705:14): [True: 0, False: 2]
  ------------------
 8706|      0|    ending_index = components.hash_start;
 8707|      0|  }
 8708|      2|  buffer.insert(ending_index, input);
 8709|       |
 8710|      2|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8710:7): [True: 0, False: 2]
  ------------------
 8711|      0|    components.search_start += uint32_t(input.size());
 8712|      0|  }
 8713|      2|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8713:7): [True: 0, False: 2]
  ------------------
 8714|      0|    components.hash_start += uint32_t(input.size());
 8715|      0|  }
 8716|       |#if ADA_DEVELOPMENT_CHECKS
 8717|       |  std::string path_after = std::string(get_pathname());
 8718|       |  ADA_ASSERT_EQUAL(
 8719|       |      path_expected, path_after,
 8720|       |      "append_base_pathname problem after inserting " + std::string(input));
 8721|       |#endif  // ADA_DEVELOPMENT_CHECKS
 8722|      2|  ADA_ASSERT_TRUE(validate());
 8723|      2|}
_ZN3ada14url_aggregator20set_protocol_as_fileEv:
 9287|  5.55k|constexpr void url_aggregator::set_protocol_as_file() {
 9288|  5.55k|  ada_log("url_aggregator::set_protocol_as_file ");
 9289|  5.55k|  ADA_ASSERT_TRUE(validate());
 9290|  5.55k|  type = ada::scheme::type::FILE;
 9291|       |  // next line could overflow but unsigned arithmetic has well-defined
 9292|       |  // overflows.
 9293|  5.55k|  uint32_t new_difference = 5 - components.protocol_end;
 9294|       |
 9295|  5.55k|  if (buffer.empty()) {
  ------------------
  |  Branch (9295:7): [True: 418, False: 5.13k]
  ------------------
 9296|    418|    buffer.append("file:");
 9297|  5.13k|  } else {
 9298|  5.13k|    buffer.erase(0, components.protocol_end);
 9299|  5.13k|    buffer.insert(0, "file:");
 9300|  5.13k|  }
 9301|  5.55k|  components.protocol_end = 5;
 9302|       |
 9303|       |  // Update the rest of the components.
 9304|  5.55k|  components.username_end += new_difference;
 9305|  5.55k|  components.host_start += new_difference;
 9306|  5.55k|  components.host_end += new_difference;
 9307|  5.55k|  components.pathname_start += new_difference;
 9308|  5.55k|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9308:7): [True: 0, False: 5.55k]
  ------------------
 9309|      0|    components.search_start += new_difference;
 9310|      0|  }
 9311|  5.55k|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9311:7): [True: 0, False: 5.55k]
  ------------------
 9312|      0|    components.hash_start += new_difference;
 9313|      0|  }
 9314|  5.55k|  ADA_ASSERT_TRUE(validate());
 9315|  5.55k|}
_ZN3ada14url_aggregator14clear_pathnameEv:
 9027|     26|constexpr void url_aggregator::clear_pathname() {
 9028|     26|  ada_log("url_aggregator::clear_pathname");
 9029|     26|  ADA_ASSERT_TRUE(validate());
 9030|     26|  uint32_t ending_index = uint32_t(buffer.size());
 9031|     26|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9031:7): [True: 0, False: 26]
  ------------------
 9032|      0|    ending_index = components.search_start;
 9033|     26|  } else if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9033:14): [True: 0, False: 26]
  ------------------
 9034|      0|    ending_index = components.hash_start;
 9035|      0|  }
 9036|     26|  uint32_t pathname_length = ending_index - components.pathname_start;
 9037|     26|  buffer.erase(components.pathname_start, pathname_length);
 9038|     26|  uint32_t difference = pathname_length;
 9039|     26|  if (components.pathname_start == components.host_end + 2 &&
  ------------------
  |  Branch (9039:7): [True: 0, False: 26]
  ------------------
 9040|      0|      buffer[components.host_end] == '/' &&
  ------------------
  |  Branch (9040:7): [True: 0, False: 0]
  ------------------
 9041|      0|      buffer[components.host_end + 1] == '.') {
  ------------------
  |  Branch (9041:7): [True: 0, False: 0]
  ------------------
 9042|      0|    components.pathname_start -= 2;
 9043|      0|    buffer.erase(components.host_end, 2);
 9044|      0|    difference += 2;
 9045|      0|  }
 9046|     26|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (9046:7): [True: 0, False: 26]
  ------------------
 9047|      0|    components.search_start -= difference;
 9048|      0|  }
 9049|     26|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (9049:7): [True: 0, False: 26]
  ------------------
 9050|      0|    components.hash_start -= difference;
 9051|      0|  }
 9052|     26|  ada_log("url_aggregator::clear_pathname completed, running checks...");
 9053|       |#if ADA_DEVELOPMENT_CHECKS
 9054|       |  ADA_ASSERT_EQUAL(get_pathname(), "",
 9055|       |                   "pathname should have been cleared on buffer=" + buffer +
 9056|       |                       " with " + components.to_string() + "\n" + to_diagram());
 9057|       |#endif
 9058|     26|  ADA_ASSERT_TRUE(validate());
 9059|     26|  ada_log("url_aggregator::clear_pathname completed, running checks... ok");
 9060|     26|}
_ZN3ada7unicode20percent_encode_indexENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEPKh:
 8369|  1.17k|                                              const uint8_t character_set[]) {
 8370|  1.17k|  const char* data = input.data();
 8371|  1.17k|  const size_t size = input.size();
 8372|       |
 8373|       |  // Process 8 bytes at a time using unrolled loop
 8374|  1.17k|  size_t i = 0;
 8375|  4.32k|  for (; i + 8 <= size; i += 8) {
  ------------------
  |  Branch (8375:10): [True: 3.46k, False: 864]
  ------------------
 8376|  3.46k|    unsigned char chunk[8];
 8377|  3.46k|    std::memcpy(&chunk, data + i,
 8378|  3.46k|                8);  // entices compiler to unconditionally process 8 characters
 8379|       |
 8380|       |    // Check 8 characters at once
 8381|  28.8k|    for (size_t j = 0; j < 8; j++) {
  ------------------
  |  Branch (8381:24): [True: 25.7k, False: 3.15k]
  ------------------
 8382|  25.7k|      if (character_sets::bit_at(character_set, chunk[j])) {
  ------------------
  |  Branch (8382:11): [True: 306, False: 25.4k]
  ------------------
 8383|    306|        return i + j;
 8384|    306|      }
 8385|  25.7k|    }
 8386|  3.46k|  }
 8387|       |
 8388|       |  // Handle remaining bytes
 8389|  2.30k|  for (; i < size; i++) {
  ------------------
  |  Branch (8389:10): [True: 1.61k, False: 690]
  ------------------
 8390|  1.61k|    if (character_sets::bit_at(character_set, data[i])) {
  ------------------
  |  Branch (8390:9): [True: 174, False: 1.44k]
  ------------------
 8391|    174|      return i;
 8392|    174|    }
 8393|  1.61k|  }
 8394|       |
 8395|    690|  return size;
 8396|    864|}
_ZN3ada14url_aggregator10clear_portEv:
 8961|  3.49k|inline void url_aggregator::clear_port() {
 8962|  3.49k|  ada_log("url_aggregator::clear_port");
 8963|  3.49k|  ADA_ASSERT_TRUE(validate());
 8964|  3.49k|  if (components.port == url_components::omitted) {
  ------------------
  |  Branch (8964:7): [True: 3.49k, False: 0]
  ------------------
 8965|  3.49k|    return;
 8966|  3.49k|  }
 8967|      0|  uint32_t length = components.pathname_start - components.host_end;
 8968|      0|  buffer.erase(components.host_end, length);
 8969|      0|  components.pathname_start -= length;
 8970|      0|  if (components.search_start != url_components::omitted) {
  ------------------
  |  Branch (8970:7): [True: 0, False: 0]
  ------------------
 8971|      0|    components.search_start -= length;
 8972|      0|  }
 8973|      0|  if (components.hash_start != url_components::omitted) {
  ------------------
  |  Branch (8973:7): [True: 0, False: 0]
  ------------------
 8974|      0|    components.hash_start -= length;
 8975|      0|  }
 8976|      0|  components.port = url_components::omitted;
 8977|      0|  ADA_ASSERT_TRUE(validate());
 8978|      0|}
_ZNK3ada14url_aggregator13has_authorityEv:
 9126|  51.7k|    const noexcept {
 9127|  51.7k|  ada_log("url_aggregator::has_authority");
 9128|       |  // Performance: instead of doing this potentially expensive check, we could
 9129|       |  // have a boolean in the struct.
 9130|  51.7k|  return components.protocol_end + 2 <= components.host_start &&
  ------------------
  |  Branch (9130:10): [True: 23.2k, False: 28.5k]
  ------------------
 9131|  23.2k|         buffer[components.protocol_end] == '/' &&
  ------------------
  |  Branch (9131:10): [True: 23.2k, False: 0]
  ------------------
 9132|  23.2k|         buffer[components.protocol_end + 1] == '/';
  ------------------
  |  Branch (9132:10): [True: 23.2k, False: 0]
  ------------------
 9133|  51.7k|}
_ZNK3ada14url_aggregator12has_dash_dotEv:
 9206|  17.7k|[[nodiscard]] constexpr bool url_aggregator::has_dash_dot() const noexcept {
 9207|       |  // If url's host is null, url does not have an opaque path, url's path's size
 9208|       |  // is greater than 1, and url's path[0] is the empty string, then append
 9209|       |  // U+002F (/) followed by U+002E (.) to output.
 9210|  17.7k|  ada_log("url_aggregator::has_dash_dot");
 9211|       |#if ADA_DEVELOPMENT_CHECKS
 9212|       |  // If pathname_start and host_end are exactly two characters apart, then we
 9213|       |  // either have a one-digit port such as http://test.com:5?param=1 or else we
 9214|       |  // have a /.: sequence such as "non-spec:/.//". We test that this is the case.
 9215|       |  if (components.pathname_start == components.host_end + 2) {
 9216|       |    ADA_ASSERT_TRUE((buffer[components.host_end] == '/' &&
 9217|       |                     buffer[components.host_end + 1] == '.') ||
 9218|       |                    (buffer[components.host_end] == ':' &&
 9219|       |                     checkers::is_digit(buffer[components.host_end + 1])));
 9220|       |  }
 9221|       |  if (components.pathname_start == components.host_end + 2 &&
 9222|       |      buffer[components.host_end] == '/' &&
 9223|       |      buffer[components.host_end + 1] == '.') {
 9224|       |    ADA_ASSERT_TRUE(components.pathname_start + 1 < buffer.size());
 9225|       |    ADA_ASSERT_TRUE(buffer[components.pathname_start] == '/');
 9226|       |    ADA_ASSERT_TRUE(buffer[components.pathname_start + 1] == '/');
 9227|       |  }
 9228|       |#endif
 9229|       |  // Performance: it should be uncommon for components.pathname_start ==
 9230|       |  // components.host_end + 2 to be true. So we put this check first in the
 9231|       |  // sequence. Most times, we do not have an opaque path. Checking for '/.' is
 9232|       |  // more expensive, but should be uncommon.
 9233|  17.7k|  return components.pathname_start == components.host_end + 2 &&
  ------------------
  |  Branch (9233:10): [True: 1.25k, False: 16.4k]
  ------------------
 9234|  1.25k|         !has_opaque_path && buffer[components.host_end] == '/' &&
  ------------------
  |  Branch (9234:10): [True: 1.25k, False: 0]
  |  Branch (9234:30): [True: 11, False: 1.24k]
  ------------------
 9235|     11|         buffer[components.host_end + 1] == '.';
  ------------------
  |  Branch (9235:10): [True: 11, False: 0]
  ------------------
 9236|  17.7k|}
_ZNK2tl8expectedIN3ada14url_aggregatorENS1_6errorsEEcvbEv:
 4101|  44.9k|  constexpr explicit operator bool() const noexcept { return this->m_has_val; }
_ZN2tl8expectedIN3ada14url_aggregatorENS1_6errorsEEptEv:
 4070|  27.8k|  TL_EXPECTED_11_CONSTEXPR T* operator->() {
 4071|  27.8k|    TL_ASSERT(has_value());
  ------------------
  |  | 2123|  27.8k|#define TL_ASSERT(x) assert(x)
  ------------------
  |  Branch (4071:5): [True: 27.8k, False: 0]
  ------------------
 4072|  27.8k|    return valptr();
 4073|  27.8k|  }
_ZN2tl8expectedIN3ada14url_aggregatorENS1_6errorsEE6valptrEv:
 3366|  27.8k|  T* valptr() { return std::addressof(this->m_val); }
_ZNR2tl8expectedIN3ada14url_aggregatorENS1_6errorsEEdeIS2_TnPNSt3__19enable_ifIXntsr3std7is_voidIT_EE5valueEvE4typeELPv0EEERS8_v:
 4083|  4.35k|  TL_EXPECTED_11_CONSTEXPR U& operator*() & {
 4084|  4.35k|    TL_ASSERT(has_value());
  ------------------
  |  | 2123|  4.35k|#define TL_ASSERT(x) assert(x)
  ------------------
  |  Branch (4084:5): [True: 4.35k, False: 0]
  ------------------
 4085|  4.35k|    return val();
 4086|  4.35k|  }
_ZN2tl8expectedIN3ada14url_aggregatorENS1_6errorsEE3valIS2_TnPNSt3__19enable_ifIXntsr3std7is_voidIT_EE5valueEvE4typeELPv0EEERS8_v:
 3375|  4.35k|  TL_EXPECTED_11_CONSTEXPR U& val() {
 3376|  4.35k|    return this->m_val;
 3377|  4.35k|  }
_ZNK2tl8expectedIN3ada14url_aggregatorENS1_6errorsEE9has_valueEv:
 4100|  89.6k|  constexpr bool has_value() const noexcept { return this->m_has_val; }
_ZN2tl6detail21expected_storage_baseIN3ada14url_aggregatorENS2_6errorsELb0ELb1EED2Ev:
 2698|  49.0k|  ~expected_storage_base() {
 2699|  49.0k|    if (m_has_val) {
  ------------------
  |  Branch (2699:9): [True: 24.0k, False: 24.9k]
  ------------------
 2700|  24.0k|      m_val.~T();
 2701|  24.0k|    }
 2702|  49.0k|  }
_ZN3ada7helpers9substringENSt3__117basic_string_viewIcNS1_11char_traitsIcEEEEmm:
 1913|  30.5k|                                                       size_t pos2) {
 1914|       |#if ADA_DEVELOPMENT_CHECKS
 1915|       |  if (pos2 < pos1) {
 1916|       |    std::cerr << "Negative-length substring: [" << pos1 << " to " << pos2 << ")"
 1917|       |              << std::endl;
 1918|       |    abort();
 1919|       |  }
 1920|       |#endif
 1921|  30.5k|  return input.substr(pos1, pos2 - pos1);
 1922|  30.5k|}
_ZNK3ada14url_aggregator10is_at_pathEv:
 8558|  4.89k|    const noexcept {
 8559|  4.89k|  return buffer.size() == components.pathname_start;
 8560|  4.89k|}
_ZNK3ada14url_aggregator12has_hostnameEv:
 9195|    276|constexpr bool url_aggregator::has_hostname() const noexcept {
 9196|    276|  return has_authority();
 9197|    276|}
_ZNK3ada14url_aggregator12has_passwordEv:
 9175|  5.16k|constexpr bool url_aggregator::has_password() const noexcept {
 9176|  5.16k|  ada_log("url_aggregator::has_password");
 9177|       |  // This function does not care about the length of the password
 9178|  5.16k|  return components.host_start > components.username_end &&
  ------------------
  |  Branch (9178:10): [True: 4.60k, False: 561]
  ------------------
 9179|  4.60k|         buffer[components.username_end] == ':';
  ------------------
  |  Branch (9179:10): [True: 4.60k, False: 0]
  ------------------
 9180|  5.16k|}
_ZNK3ada3url8get_hrefEv:
 7622|  19.7k|[[nodiscard]] ada_really_inline std::string url::get_href() const {
 7623|  19.7k|  if (is_special() && host.has_value() && username.empty() &&
  ------------------
  |  Branch (7623:7): [True: 16.5k, False: 3.16k]
  |  Branch (7623:23): [True: 16.5k, False: 0]
  |  Branch (7623:43): [True: 16.0k, False: 539]
  ------------------
 7624|  16.0k|      password.empty() && !port.has_value()) [[likely]] {
  ------------------
  |  Branch (7624:7): [True: 15.9k, False: 57]
  |  Branch (7624:27): [True: 13.5k, False: 2.40k]
  ------------------
 7625|  13.5k|    const std::string_view scheme = ada::scheme::details::is_special_list[type];
 7626|  13.5k|    const size_t host_size = host->size();
 7627|  13.5k|    const size_t path_size = path.size();
 7628|  13.5k|    const size_t query_size = query.has_value() ? query->size() : 0;
  ------------------
  |  Branch (7628:31): [True: 936, False: 12.6k]
  ------------------
 7629|  13.5k|    const size_t hash_size = hash.has_value() ? hash->size() : 0;
  ------------------
  |  Branch (7629:30): [True: 822, False: 12.7k]
  ------------------
 7630|  13.5k|    const size_t total = scheme.size() + 3 + host_size + path_size +
 7631|  13.5k|                         (query.has_value() ? query_size + 1 : 0) +
  ------------------
  |  Branch (7631:27): [True: 936, False: 12.6k]
  ------------------
 7632|  13.5k|                         (hash.has_value() ? hash_size + 1 : 0);
  ------------------
  |  Branch (7632:27): [True: 822, False: 12.7k]
  ------------------
 7633|  13.5k|    std::string output(total, '\0');
 7634|  13.5k|    char* p = output.data();
 7635|  13.5k|    std::memcpy(p, scheme.data(), scheme.size());
 7636|  13.5k|    p += scheme.size();
 7637|  13.5k|    p[0] = ':';
 7638|  13.5k|    p[1] = '/';
 7639|  13.5k|    p[2] = '/';
 7640|  13.5k|    p += 3;
 7641|       |    // NOLINTNEXTLINE(bugprone-not-null-terminated-result)
 7642|  13.5k|    std::memcpy(p, host->data(), host_size);
 7643|  13.5k|    p += host_size;
 7644|  13.5k|    std::memcpy(p, path.data(), path_size);
 7645|  13.5k|    p += path_size;
 7646|  13.5k|    if (query.has_value()) {
  ------------------
  |  Branch (7646:9): [True: 936, False: 12.6k]
  ------------------
 7647|    936|      *p++ = '?';
 7648|       |      // NOLINTNEXTLINE(bugprone-not-null-terminated-result)
 7649|    936|      std::memcpy(p, query->data(), query_size);
 7650|    936|      p += query_size;
 7651|    936|    }
 7652|  13.5k|    if (hash.has_value()) {
  ------------------
  |  Branch (7652:9): [True: 822, False: 12.7k]
  ------------------
 7653|    822|      *p++ = '#';
 7654|       |      // NOLINTNEXTLINE(bugprone-not-null-terminated-result)
 7655|    822|      std::memcpy(p, hash->data(), hash_size);
 7656|    822|    }
 7657|  13.5k|    return output;
 7658|  13.5k|  }
 7659|       |
 7660|  6.16k|  std::string output;
 7661|  6.16k|  output.reserve(get_href_size());
 7662|       |
 7663|  6.16k|  if (is_special()) {
  ------------------
  |  Branch (7663:7): [True: 3.00k, False: 3.16k]
  ------------------
 7664|  3.00k|    output.append(ada::scheme::details::is_special_list[type]);
 7665|  3.00k|    output += ':';
 7666|  3.16k|  } else {
 7667|  3.16k|    output.append(non_special_scheme);
 7668|  3.16k|    output += ':';
 7669|  3.16k|  }
 7670|       |
 7671|  6.16k|  if (host.has_value()) {
  ------------------
  |  Branch (7671:7): [True: 3.72k, False: 2.44k]
  ------------------
 7672|  3.72k|    output += '/';
 7673|  3.72k|    output += '/';
 7674|  3.72k|    if (has_credentials()) {
  ------------------
  |  Branch (7674:9): [True: 686, False: 3.03k]
  ------------------
 7675|    686|      output.append(username);
 7676|    686|      if (!password.empty()) {
  ------------------
  |  Branch (7676:11): [True: 209, False: 477]
  ------------------
 7677|    209|        output += ':';
 7678|    209|        output.append(password);
 7679|    209|      }
 7680|    686|      output += '@';
 7681|    686|    }
 7682|  3.72k|    output.append(*host);
 7683|  3.72k|    if (port.has_value()) {
  ------------------
  |  Branch (7683:9): [True: 2.53k, False: 1.18k]
  ------------------
 7684|  2.53k|      output += ':';
 7685|  2.53k|      char port_buf[5];
 7686|  2.53k|      auto [ptr, ec] = std::to_chars(port_buf, port_buf + 5, *port);
 7687|  2.53k|      (void)ec;
 7688|  2.53k|      output.append(port_buf, static_cast<size_t>(ptr - port_buf));
 7689|  2.53k|    }
 7690|  3.72k|  } else if (!has_opaque_path && path.starts_with("//")) {
  ------------------
  |  Branch (7690:14): [True: 1.26k, False: 1.17k]
  |  Branch (7690:34): [True: 29, False: 1.23k]
  ------------------
 7691|       |    // If url's host is null, url does not have an opaque path, url's path's
 7692|       |    // size is greater than 1, and url's path[0] is the empty string, then
 7693|       |    // append U+002F (/) followed by U+002E (.) to output.
 7694|     29|    output += '/';
 7695|     29|    output += '.';
 7696|     29|  }
 7697|  6.16k|  output.append(path);
 7698|  6.16k|  if (query.has_value()) {
  ------------------
  |  Branch (7698:7): [True: 732, False: 5.43k]
  ------------------
 7699|    732|    output += '?';
 7700|    732|    output.append(*query);
 7701|    732|  }
 7702|  6.16k|  if (hash.has_value()) {
  ------------------
  |  Branch (7702:7): [True: 558, False: 5.60k]
  ------------------
 7703|    558|    output += '#';
 7704|    558|    output.append(*hash);
 7705|    558|  }
 7706|  6.16k|  return output;
 7707|  19.7k|}
_ZNK3ada14url_aggregator10has_searchEv:
 9104|  2.08k|[[nodiscard]] constexpr bool url_aggregator::has_search() const noexcept {
 9105|  2.08k|  ada_log("url_aggregator::has_search");
 9106|  2.08k|  return components.search_start != url_components::omitted;
 9107|  2.08k|}
_ZN3ada7helpers6concatIJNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEPKcEEENS2_12basic_stringIcS5_NS2_9allocatorIcEEEEDpT_:
 1991|  21.5k|std::string concat(Args... args) {
 1992|  21.5k|  std::string answer;
 1993|  21.5k|  inner_concat(answer, args...);
 1994|  21.5k|  return answer;
 1995|  21.5k|}
_ZN3ada7helpers12inner_concatINSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEJPKcEEEvRNS2_12basic_stringIcS5_NS2_9allocatorIcEEEET_DpT0_:
 1980|  21.5k|inline void inner_concat(std::string& buffer, T t, Args... args) {
 1981|  21.5k|  buffer.append(t);
 1982|  21.5k|  return inner_concat(buffer, args...);
 1983|  21.5k|}
_ZN3ada7helpers12inner_concatIPKcJEEEvRNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEET_:
 1972|  21.5k|inline void inner_concat(std::string& buffer, T t) {
 1973|  21.5k|  buffer.append(t);
 1974|  21.5k|}
_ZN3ada3url10set_schemeEONSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE:
 7604|  10.7k|inline void url::set_scheme(std::string&& new_scheme) noexcept {
 7605|  10.7k|  type = ada::scheme::get_scheme_type(new_scheme);
 7606|       |  // We only move the 'scheme' if it is non-special.
 7607|  10.7k|  if (!is_special()) {
  ------------------
  |  Branch (7607:7): [True: 5.37k, False: 5.42k]
  ------------------
 7608|  5.37k|    non_special_scheme = std::move(new_scheme);
 7609|  5.37k|  }
 7610|  10.7k|}
_ZN3ada7helpers6concatIJPKcNSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEEEENS4_12basic_stringIcS7_NS4_9allocatorIcEEEEDpT_:
 1991|      2|std::string concat(Args... args) {
 1992|      2|  std::string answer;
 1993|      2|  inner_concat(answer, args...);
 1994|      2|  return answer;
 1995|      2|}
_ZN3ada7helpers12inner_concatIPKcJNSt3__117basic_string_viewIcNS4_11char_traitsIcEEEEEEEvRNS4_12basic_stringIcS7_NS4_9allocatorIcEEEET_DpT0_:
 1980|      2|inline void inner_concat(std::string& buffer, T t, Args... args) {
 1981|      2|  buffer.append(t);
 1982|      2|  return inner_concat(buffer, args...);
 1983|      2|}
_ZN3ada7helpers12inner_concatINSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEJEEEvRNS2_12basic_stringIcS5_NS2_9allocatorIcEEEET_:
 1972|      2|inline void inner_concat(std::string& buffer, T t) {
 1973|      2|  buffer.append(t);
 1974|      2|}

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

