_Z29get_supported_implementationsv:
   26|  3.84k|get_supported_implementations() {
   27|  3.84k|  static const auto impl = []() -> auto {
   28|  3.84k|    std::vector<const simdutf::implementation*> ret;
   29|  3.84k|    for (auto e : simdutf::get_available_implementations()) {
   30|  3.84k|      std::cerr << "implementation " << e->name() << " is available? "
   31|  3.84k|                << e->supported_by_runtime_system() << '\n';
   32|  3.84k|      if (e->supported_by_runtime_system()) {
   33|  3.84k|        ret.push_back(e);
   34|  3.84k|      }
   35|  3.84k|    }
   36|  3.84k|    return ret;
   37|  3.84k|  }();
   38|  3.84k|  return {impl.data(), impl.size()};
   39|  3.84k|}
_ZZ29get_supported_implementationsvENKUlvE_clEv:
   27|      1|  static const auto impl = []() -> auto {
   28|      1|    std::vector<const simdutf::implementation*> ret;
   29|      4|    for (auto e : simdutf::get_available_implementations()) {
  ------------------
  |  Branch (29:17): [True: 4, False: 1]
  ------------------
   30|      4|      std::cerr << "implementation " << e->name() << " is available? "
   31|      4|                << e->supported_by_runtime_system() << '\n';
   32|      4|      if (e->supported_by_runtime_system()) {
  ------------------
  |  Branch (32:11): [True: 3, False: 1]
  ------------------
   33|      3|        ret.push_back(e);
   34|      3|      }
   35|      4|    }
   36|      1|    return ret;
   37|      1|  }();
_ZneRKN7simdutf6resultES2_:
   42|    572|inline bool operator!=(const simdutf::result& a, const simdutf::result& b) {
   43|    572|  return a.count != b.count || a.error != b.error;
  ------------------
  |  Branch (43:10): [True: 0, False: 572]
  |  Branch (43:32): [True: 0, False: 572]
  ------------------
   44|    572|}
_ZN10FNV1A_hash6as_strIJNSt3__16vectorIDsNS1_9allocatorIDsEEEEEEENS1_12basic_stringIcNS1_11char_traitsIcEENS3_IcEEEEDpRKT_:
  100|    387|  template <typename... Data> static std::string as_str(const Data&... data) {
  101|    387|    static_assert(sizeof...(Data) > 0, "must hash with at least one argument");
  102|    387|    std::uint64_t h;
  103|       |    if constexpr (sizeof...(Data) > 1) {
  104|       |      const std::array hashes{fnv1ahash_impl(data)...};
  105|       |      const auto s = std::span(hashes);
  106|       |      h = fnv1ahash_impl(s);
  107|    387|    } else {
  108|    387|      h = fnv1ahash_impl(data...);
  109|    387|    }
  110|    387|    constexpr std::size_t expected_chars = 16;
  111|    387|    std::string ret(expected_chars, '0');
  112|    387|    auto c = std::to_chars(ret.data(), ret.data() + ret.size(), h, 16);
  113|    387|    assert(c.ec == std::errc{});
  ------------------
  |  Branch (113:5): [True: 387, False: 0]
  ------------------
  114|    387|    auto nwritten = c.ptr - ret.data();
  115|    387|    assert(nwritten <= expected_chars);
  ------------------
  |  Branch (115:5): [True: 387, False: 0]
  ------------------
  116|    387|    std::rotate(ret.data(), c.ptr, ret.data() + expected_chars);
  117|    387|    return ret;
  118|    387|  }
_ZN10FNV1A_hash14fnv1ahash_implIDsQ11is_hashableIT_EEEmRKNSt3__16vectorIS1_NS2_9allocatorIS1_EEEE:
   96|    387|  static constexpr std::uint64_t fnv1ahash_impl(const std::vector<Data>& data) {
   97|    387|    return fnv1ahash_impl(std::span(data));
   98|    387|  }
_ZN10FNV1A_hash14fnv1ahash_implIKDsLm18446744073709551615EQaaaa11is_hashableIT_Entsr3stdE9is_same_vIS2_cEntsr3stdE9is_same_vIS2_hEEEmNSt3__14spanIS2_XT0_EEE:
   89|    387|  static constexpr std::uint64_t fnv1ahash_impl(std::span<Basic, N> data) {
   90|    387|    return fnv1ahash_impl({reinterpret_cast<const unsigned char*>(data.data()),
   91|    387|                           data.size_bytes()});
   92|    387|  }
_ZN10FNV1A_hash14fnv1ahash_implENSt3__14spanIKhLm18446744073709551615EEE:
   65|    387|  fnv1ahash_impl(std::span<const unsigned char> bytes) {
   66|    387|    auto hash = offset;
   67|       |
   68|  18.8M|    for (std::uint64_t byte : bytes) {
  ------------------
  |  Branch (68:29): [True: 18.8M, False: 387]
  ------------------
   69|  18.8M|      hash ^= byte;
   70|  18.8M|      hash *= prime;
   71|  18.8M|    }
   72|       |
   73|    387|    return hash;
   74|    387|  }

_Z10autodetectNSt3__14spanIKcLm18446744073709551615EEE:
    9|    926|void autodetect(std::span<const char> chardata) {
   10|    926|  std::vector<simdutf::encoding_type> results;
   11|    926|  const auto implementations = get_supported_implementations();
   12|  2.77k|  for (const simdutf::implementation* impl : implementations) {
  ------------------
  |  Branch (12:44): [True: 2.77k, False: 926]
  ------------------
   13|  2.77k|    results.push_back(
   14|  2.77k|        impl->autodetect_encoding(chardata.data(), chardata.size()));
   15|  2.77k|  }
   16|    926|  auto neq = [](const auto& a, const auto& b) { return a != b; };
   17|    926|  if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (17:7): [True: 0, False: 926]
  ------------------
   18|      0|    std::cerr << "output differs between implementations\n";
   19|      0|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (19:29): [True: 0, False: 0]
  ------------------
   20|      0|      std::cerr << "implementation " << implementations[i] << " gave "
   21|      0|                << results.at(i) << '\n';
   22|      0|    }
   23|      0|    std::abort();
   24|      0|  }
   25|    926|}
_Z6detectNSt3__14spanIKcLm18446744073709551615EEE:
   27|  1.30k|void detect(std::span<const char> chardata) {
   28|  1.30k|  std::vector<int> results;
   29|  1.30k|  const auto implementations = get_supported_implementations();
   30|  3.91k|  for (const simdutf::implementation* impl : implementations) {
  ------------------
  |  Branch (30:44): [True: 3.91k, False: 1.30k]
  ------------------
   31|  3.91k|    results.push_back(impl->detect_encodings(chardata.data(), chardata.size()));
   32|  3.91k|  }
   33|  1.30k|  auto neq = [](const auto& a, const auto& b) { return a != b; };
   34|  1.30k|  if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (34:7): [True: 0, False: 1.30k]
  ------------------
   35|      0|    std::cerr << "in detect_encodings(const char*, std::size_t):\n";
   36|      0|    std::cerr << "output differs between implementations\n";
   37|      0|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (37:29): [True: 0, False: 0]
  ------------------
   38|      0|      std::cerr << "implementation " << implementations[i]->name() << " gave "
   39|      0|                << results.at(i) << '\n';
   40|      0|    }
   41|      0|    std::cerr << " std::vector<unsigned char> data{";
   42|      0|    for (unsigned char x : chardata) {
  ------------------
  |  Branch (42:26): [True: 0, False: 0]
  ------------------
   43|      0|      std::cerr << +x << ", ";
   44|      0|    };
   45|      0|    std::cerr << "};\n";
   46|      0|    std::abort();
   47|      0|  }
   48|  1.30k|}
_Z14validate_asciiNSt3__14spanIKcLm18446744073709551615EEE:
   50|    192|void validate_ascii(std::span<const char> chardata) {
   51|       |  // use int, not bool to avoid vector<bool>
   52|    192|  std::vector<int> results;
   53|    192|  const auto implementations = get_supported_implementations();
   54|    576|  for (const simdutf::implementation* impl : implementations) {
  ------------------
  |  Branch (54:44): [True: 576, False: 192]
  ------------------
   55|    576|    results.push_back(+impl->validate_ascii(chardata.data(), chardata.size()));
   56|    576|  }
   57|    192|  auto neq = [](const auto& a, const auto& b) { return a != b; };
   58|    192|  if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (58:7): [True: 0, False: 192]
  ------------------
   59|      0|    std::cerr << "in validate_ascii(const char*, std::size_t):\n";
   60|      0|    std::cerr << "output differs between implementations\n";
   61|      0|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (61:29): [True: 0, False: 0]
  ------------------
   62|      0|      std::cerr << "implementation " << implementations[i]->name() << " gave "
   63|      0|                << results.at(i) << '\n';
   64|      0|    }
   65|      0|    std::cerr << " std::vector<unsigned char> data{";
   66|      0|    for (unsigned char x : chardata) {
  ------------------
  |  Branch (66:26): [True: 0, False: 0]
  ------------------
   67|      0|      std::cerr << +x << ", ";
   68|      0|    };
   69|      0|    std::cerr << "};\n";
   70|      0|    std::abort();
   71|      0|  }
   72|    192|}
_Z23validate_ascii_with_errNSt3__14spanIKcLm18446744073709551615EEE:
   74|    286|void validate_ascii_with_err(std::span<const char> chardata) {
   75|       |  // use int, not bool to avoid vector<bool>
   76|    286|  std::vector<simdutf::result> results;
   77|    286|  const auto implementations = get_supported_implementations();
   78|    858|  for (const simdutf::implementation* impl : implementations) {
  ------------------
  |  Branch (78:44): [True: 858, False: 286]
  ------------------
   79|    858|    results.push_back(
   80|    858|        impl->validate_ascii_with_errors(chardata.data(), chardata.size()));
   81|    858|  }
   82|    286|  auto neq = [](const auto& a, const auto& b) { return a != b; };
   83|    286|  if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (83:7): [True: 0, False: 286]
  ------------------
   84|      0|    std::cerr << "in validate_ascii(const char*, std::size_t):\n";
   85|      0|    std::cerr << "output differs between implementations\n";
   86|      0|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (86:29): [True: 0, False: 0]
  ------------------
   87|      0|      std::cerr << "implementation " << implementations[i]->name() << " gave "
   88|      0|                << results.at(i) << '\n';
   89|      0|    }
   90|      0|    std::cerr << " std::vector<unsigned char> data{";
   91|      0|    for (unsigned char x : chardata) {
  ------------------
  |  Branch (91:26): [True: 0, False: 0]
  ------------------
   92|      0|      std::cerr << +x << ", ";
   93|      0|    };
   94|      0|    std::cerr << "};\n";
   95|      0|    std::abort();
   96|      0|  }
   97|    286|}
_Z16utf16_endiannessNSt3__14spanIKDsLm18446744073709551615EEE:
   99|    129|void utf16_endianness(std::span<const char16_t> data) {
  100|    129|  std::vector<std::string> results;
  101|    129|  const auto implementations = get_supported_implementations();
  102|    387|  for (const simdutf::implementation* impl : implementations) {
  ------------------
  |  Branch (102:44): [True: 387, False: 129]
  ------------------
  103|    387|    std::vector<char16_t> out(data.size());
  104|    387|    impl->change_endianness_utf16(data.data(), data.size(), out.data());
  105|    387|    results.push_back(FNV1A_hash::as_str(out));
  106|    387|  }
  107|    129|  auto neq = [](const auto& a, const auto& b) { return a != b; };
  108|    129|  if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (108:7): [True: 0, False: 129]
  ------------------
  109|      0|    std::cerr << "in utf16_endianness(const char*, std::size_t):\n";
  110|      0|    std::cerr << "output differs between implementations\n";
  111|      0|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (111:29): [True: 0, False: 0]
  ------------------
  112|      0|      std::cerr << "implementation " << implementations[i]->name() << " gave "
  113|      0|                << results.at(i) << '\n';
  114|      0|    }
  115|      0|    std::cerr << " std::vector<char16_t> data{";
  116|      0|    for (int x : data) {
  ------------------
  |  Branch (116:16): [True: 0, False: 0]
  ------------------
  117|      0|      std::cerr << +x << ", ";
  118|      0|    };
  119|      0|    std::cerr << "};\n";
  120|      0|    std::abort();
  121|      0|  }
  122|    129|}
_Z23validate_utf16_as_asciiNSt3__14spanIKDsLm18446744073709551615EEE:
  126|    244|void validate_utf16_as_ascii(std::span<const char16_t> data) {
  127|    244|  const auto implementations = get_supported_implementations();
  128|       |  // use int, not bool to avoid vector<bool>
  129|    244|  std::vector<int> le_results, be_results;
  130|    244|  le_results.reserve(implementations.size());
  131|    244|  be_results.reserve(implementations.size());
  132|    732|  for (const simdutf::implementation* impl : implementations) {
  ------------------
  |  Branch (132:44): [True: 732, False: 244]
  ------------------
  133|    732|    le_results.push_back(
  134|    732|        +impl->validate_utf16le_as_ascii(data.data(), data.size()));
  135|    732|    be_results.push_back(
  136|    732|        +impl->validate_utf16be_as_ascii(data.data(), data.size()));
  137|    732|  }
  138|    244|  auto neq = [](const auto& a, const auto& b) { return a != b; };
  139|    244|  if (std::ranges::adjacent_find(le_results, neq) != le_results.end()) {
  ------------------
  |  Branch (139:7): [True: 0, False: 244]
  ------------------
  140|      0|    std::cerr << "validate_utf16le_as_ascii: output differs between "
  141|      0|                 "implementations\n";
  142|      0|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (142:29): [True: 0, False: 0]
  ------------------
  143|      0|      std::cerr << "  " << implementations[i]->name() << " gave "
  144|      0|                << le_results[i] << '\n';
  145|      0|    }
  146|      0|    std::abort();
  147|      0|  }
  148|    244|  if (std::ranges::adjacent_find(be_results, neq) != be_results.end()) {
  ------------------
  |  Branch (148:7): [True: 0, False: 244]
  ------------------
  149|      0|    std::cerr << "validate_utf16be_as_ascii: output differs between "
  150|      0|                 "implementations\n";
  151|      0|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (151:29): [True: 0, False: 0]
  ------------------
  152|      0|      std::cerr << "  " << implementations[i]->name() << " gave "
  153|      0|                << be_results[i] << '\n';
  154|      0|    }
  155|      0|    std::abort();
  156|      0|  }
  157|       |  // If LE validates as ASCII, it must also validate as UTF-16LE (ASCII is a
  158|       |  // subset).
  159|    244|  if (le_results[0]) {
  ------------------
  |  Branch (159:7): [True: 20, False: 224]
  ------------------
  160|     60|    for (const simdutf::implementation* impl : implementations) {
  ------------------
  |  Branch (160:46): [True: 60, False: 20]
  ------------------
  161|     60|      if (!impl->validate_utf16le(data.data(), data.size())) {
  ------------------
  |  Branch (161:11): [True: 0, False: 60]
  ------------------
  162|      0|        std::cerr << "validate_utf16le_as_ascii returned true but "
  163|      0|                     "validate_utf16le returned false"
  164|      0|                  << " impl=" << impl->name() << "\n";
  165|      0|        std::abort();
  166|      0|      }
  167|     60|    }
  168|     20|  }
  169|       |  // Same for BE.
  170|    244|  if (be_results[0]) {
  ------------------
  |  Branch (170:7): [True: 20, False: 224]
  ------------------
  171|     60|    for (const simdutf::implementation* impl : implementations) {
  ------------------
  |  Branch (171:46): [True: 60, False: 20]
  ------------------
  172|     60|      if (!impl->validate_utf16be(data.data(), data.size())) {
  ------------------
  |  Branch (172:11): [True: 0, False: 60]
  ------------------
  173|      0|        std::cerr << "validate_utf16be_as_ascii returned true but "
  174|      0|                     "validate_utf16be returned false"
  175|      0|                  << " impl=" << impl->name() << "\n";
  176|      0|        std::abort();
  177|      0|      }
  178|     60|    }
  179|     20|  }
  180|    244|}
_Z20to_well_formed_utf16NSt3__14spanIKDsLm18446744073709551615EEE:
  186|    760|void to_well_formed_utf16(std::span<const char16_t> data) {
  187|    760|  const auto implementations = get_supported_implementations();
  188|    760|  if (implementations.empty()) {
  ------------------
  |  Branch (188:7): [True: 0, False: 760]
  ------------------
  189|      0|    return;
  190|      0|  }
  191|       |
  192|       |  // Check LE variant
  193|    760|  {
  194|    760|    std::vector<std::vector<char16_t>> le_outputs;
  195|    760|    le_outputs.reserve(implementations.size());
  196|  2.28k|    for (const simdutf::implementation* impl : implementations) {
  ------------------
  |  Branch (196:46): [True: 2.28k, False: 760]
  ------------------
  197|  2.28k|      std::vector<char16_t> out(data.size());
  198|  2.28k|      impl->to_well_formed_utf16le(data.data(), data.size(), out.data());
  199|  2.28k|      le_outputs.push_back(std::move(out));
  200|  2.28k|    }
  201|    760|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  202|    760|    if (std::ranges::adjacent_find(le_outputs, neq) != le_outputs.end()) {
  ------------------
  |  Branch (202:9): [True: 0, False: 760]
  ------------------
  203|      0|      std::cerr
  204|      0|          << "to_well_formed_utf16le: outputs differ between implementations\n";
  205|      0|      for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (205:31): [True: 0, False: 0]
  ------------------
  206|      0|        std::cerr << "  " << implementations[i]->name()
  207|      0|                  << ": hash=" << FNV1A_hash::as_str(le_outputs[i]) << "\n";
  208|      0|      }
  209|      0|      std::abort();
  210|      0|    }
  211|       |    // Output must be valid UTF-16LE.
  212|  3.04k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (212:29): [True: 2.28k, False: 760]
  ------------------
  213|  2.28k|      if (!implementations[i]->validate_utf16le(le_outputs[i].data(),
  ------------------
  |  Branch (213:11): [True: 0, False: 2.28k]
  ------------------
  214|  2.28k|                                                le_outputs[i].size())) {
  215|      0|        std::cerr << "to_well_formed_utf16le: output is not valid UTF-16LE"
  216|      0|                  << " impl=" << implementations[i]->name() << "\n";
  217|      0|        std::abort();
  218|      0|      }
  219|  2.28k|    }
  220|       |    // If input was already valid UTF-16LE, output must equal input.
  221|    760|    if (implementations[0]->validate_utf16le(data.data(), data.size())) {
  ------------------
  |  Branch (221:9): [True: 190, False: 570]
  ------------------
  222|    190|      if (!std::ranges::equal(le_outputs[0], data)) {
  ------------------
  |  Branch (222:11): [True: 0, False: 190]
  ------------------
  223|      0|        std::cerr << "to_well_formed_utf16le: valid input was modified\n";
  224|      0|        std::abort();
  225|      0|      }
  226|    190|    }
  227|    760|  }
  228|       |
  229|       |  // Check BE variant
  230|    760|  {
  231|    760|    std::vector<std::vector<char16_t>> be_outputs;
  232|    760|    be_outputs.reserve(implementations.size());
  233|  2.28k|    for (const simdutf::implementation* impl : implementations) {
  ------------------
  |  Branch (233:46): [True: 2.28k, False: 760]
  ------------------
  234|  2.28k|      std::vector<char16_t> out(data.size());
  235|  2.28k|      impl->to_well_formed_utf16be(data.data(), data.size(), out.data());
  236|  2.28k|      be_outputs.push_back(std::move(out));
  237|  2.28k|    }
  238|    760|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  239|    760|    if (std::ranges::adjacent_find(be_outputs, neq) != be_outputs.end()) {
  ------------------
  |  Branch (239:9): [True: 0, False: 760]
  ------------------
  240|      0|      std::cerr
  241|      0|          << "to_well_formed_utf16be: outputs differ between implementations\n";
  242|      0|      for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (242:31): [True: 0, False: 0]
  ------------------
  243|      0|        std::cerr << "  " << implementations[i]->name()
  244|      0|                  << ": hash=" << FNV1A_hash::as_str(be_outputs[i]) << "\n";
  245|      0|      }
  246|      0|      std::abort();
  247|      0|    }
  248|       |    // Output must be valid UTF-16BE.
  249|  3.04k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (249:29): [True: 2.28k, False: 760]
  ------------------
  250|  2.28k|      if (!implementations[i]->validate_utf16be(be_outputs[i].data(),
  ------------------
  |  Branch (250:11): [True: 0, False: 2.28k]
  ------------------
  251|  2.28k|                                                be_outputs[i].size())) {
  252|      0|        std::cerr << "to_well_formed_utf16be: output is not valid UTF-16BE"
  253|      0|                  << " impl=" << implementations[i]->name() << "\n";
  254|      0|        std::abort();
  255|      0|      }
  256|  2.28k|    }
  257|       |    // If input was already valid UTF-16BE, output must equal input.
  258|    760|    if (implementations[0]->validate_utf16be(data.data(), data.size())) {
  ------------------
  |  Branch (258:9): [True: 201, False: 559]
  ------------------
  259|    201|      if (!std::ranges::equal(be_outputs[0], data)) {
  ------------------
  |  Branch (259:11): [True: 0, False: 201]
  ------------------
  260|      0|        std::cerr << "to_well_formed_utf16be: valid input was modified\n";
  261|      0|        std::abort();
  262|      0|      }
  263|    201|    }
  264|    760|  }
  265|    760|}
_Z27convert_latin1_to_utf8_safeNSt3__14spanIKcLm18446744073709551615EEEm:
  268|    267|                                 const std::size_t outputsize) {
  269|       |  // convert with a limited output buffer
  270|    267|  std::vector<char> limited_output(outputsize);
  271|    267|  const auto limited_ret = simdutf::convert_latin1_to_utf8_safe(
  272|    267|      chardata.data(), chardata.size(), limited_output.data(), outputsize);
  273|       |
  274|       |  // convert with a sufficiently large output buffer
  275|    267|  std::vector<char> large_output(2 * chardata.size());
  276|    267|  const auto large_ret = simdutf::convert_latin1_to_utf8(
  277|    267|      chardata.data(), chardata.size(), large_output.data());
  278|       |
  279|    267|  if (large_ret != 0) {
  ------------------
  |  Branch (279:7): [True: 241, False: 26]
  ------------------
  280|       |    // conversion was possible with a large buffer.
  281|    241|    if (large_ret <= outputsize) {
  ------------------
  |  Branch (281:9): [True: 104, False: 137]
  ------------------
  282|       |      // the limited buffer was large enough, ensure we got the same result
  283|    104|      assert(limited_ret == large_ret);
  ------------------
  |  Branch (283:7): [True: 104, False: 0]
  ------------------
  284|    104|      assert(std::ranges::equal(limited_output | std::views::take(large_ret),
  ------------------
  |  Branch (284:7): [True: 104, False: 0]
  ------------------
  285|    104|                                large_output | std::views::take(large_ret)));
  286|    137|    } else {
  287|       |      // the number of written bytes for a limited buffer must not exceed what
  288|       |      // the large buffer got.
  289|    137|      assert(limited_ret <= large_ret);
  ------------------
  |  Branch (289:7): [True: 137, False: 0]
  ------------------
  290|       |      // the written data should be equal
  291|    137|      assert(std::ranges::equal(limited_output | std::views::take(limited_ret),
  ------------------
  |  Branch (291:7): [True: 137, False: 0]
  ------------------
  292|    137|                                large_output | std::views::take(limited_ret)));
  293|    137|    }
  294|    241|  } else {
  295|       |    // conversion with a big buffer failed - is there anything we can check or
  296|       |    // assert for the limited buffer? I don't think so.
  297|     26|  }
  298|    267|}
LLVMFuzzerTestOneInput:
  300|  4.28k|extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
  301|       |  // pick one of the functions, based on the fuzz data.
  302|       |  // the first byte is which action to take. step forward
  303|       |  // several bytes so the input is aligned.
  304|  4.28k|  if (size < 4) {
  ------------------
  |  Branch (304:7): [True: 2, False: 4.28k]
  ------------------
  305|      2|    return 0;
  306|      2|  }
  307|  4.28k|  constexpr auto Ncases = 11u;
  308|  4.28k|  constexpr auto actionmask = std::bit_ceil(Ncases) - 1;
  309|  4.28k|  const auto action = data[0] & actionmask;
  310|       |
  311|  4.28k|  const std::uint16_t u16 = data[1] + (data[2] << 8);
  312|       |
  313|  4.28k|  data += 4;
  314|  4.28k|  size -= 4;
  315|       |
  316|  4.28k|  const std::span<const char> chardata{(const char*)data, size};
  317|  4.28k|  const std::span<const char16_t> u16data{(const char16_t*)data,
  318|  4.28k|                                          size / sizeof(char16_t)};
  319|       |
  320|  4.28k|  switch (action) {
  ------------------
  |  Branch (320:11): [True: 4.28k, False: 1]
  ------------------
  321|    926|  case 0:
  ------------------
  |  Branch (321:3): [True: 926, False: 3.35k]
  ------------------
  322|    926|    autodetect(chardata);
  323|    926|    break;
  324|  1.30k|  case 1:
  ------------------
  |  Branch (324:3): [True: 1.30k, False: 2.97k]
  ------------------
  325|  1.30k|    detect(chardata);
  326|  1.30k|    break;
  327|    192|  case 2:
  ------------------
  |  Branch (327:3): [True: 192, False: 4.09k]
  ------------------
  328|    192|    validate_ascii(chardata);
  329|    192|    break;
  330|    286|  case 3:
  ------------------
  |  Branch (330:3): [True: 286, False: 3.99k]
  ------------------
  331|    286|    validate_ascii_with_err(chardata);
  332|    286|    break;
  333|    129|  case 4:
  ------------------
  |  Branch (333:3): [True: 129, False: 4.15k]
  ------------------
  334|    129|    utf16_endianness(u16data);
  335|    129|    break;
  336|     40|  case 5: {
  ------------------
  |  Branch (336:3): [True: 40, False: 4.24k]
  ------------------
  337|     40|    [[maybe_unused]] auto ret =
  338|     40|        simdutf::trim_partial_utf16le(u16data.data(), u16data.size());
  339|     40|    assert(ret == u16data.size() || ret + 1 == u16data.size());
  ------------------
  |  Branch (339:5): [True: 24, False: 16]
  |  Branch (339:5): [True: 16, False: 0]
  |  Branch (339:5): [True: 40, False: 0]
  ------------------
  340|     40|  } break;
  341|     40|  case 6: {
  ------------------
  |  Branch (341:3): [True: 23, False: 4.26k]
  ------------------
  342|     23|    [[maybe_unused]] auto ret =
  343|     23|        simdutf::trim_partial_utf16be(u16data.data(), u16data.size());
  344|     23|    assert(ret == u16data.size() || ret + 1 == u16data.size());
  ------------------
  |  Branch (344:5): [True: 11, False: 12]
  |  Branch (344:5): [True: 12, False: 0]
  |  Branch (344:5): [True: 23, False: 0]
  ------------------
  345|     23|  } break;
  346|    110|  case 7: {
  ------------------
  |  Branch (346:3): [True: 110, False: 4.17k]
  ------------------
  347|    110|    [[maybe_unused]] const std::size_t N = chardata.size();
  348|    110|    [[maybe_unused]] const auto ret =
  349|    110|        simdutf::trim_partial_utf8(chardata.data(), chardata.size());
  350|    110|    if ((ret + 3 < N) || (ret > N)) {
  ------------------
  |  Branch (350:9): [True: 0, False: 110]
  |  Branch (350:26): [True: 0, False: 110]
  ------------------
  351|      0|      std::cerr << "ret=" << ret << " N=" << N << '\n';
  352|      0|      std::abort();
  353|      0|    }
  354|    110|  } break;
  355|    267|  case 8:
  ------------------
  |  Branch (355:3): [True: 267, False: 4.01k]
  ------------------
  356|    267|    convert_latin1_to_utf8_safe(chardata, u16);
  357|    267|    break;
  358|    244|  case 9:
  ------------------
  |  Branch (358:3): [True: 244, False: 4.03k]
  ------------------
  359|    244|    validate_utf16_as_ascii(u16data);
  360|    244|    break;
  361|    760|  case 10:
  ------------------
  |  Branch (361:3): [True: 760, False: 3.52k]
  ------------------
  362|    760|    to_well_formed_utf16(u16data);
  363|    760|    break;
  364|  4.28k|  }
  365|  4.28k|  return 0;
  366|  4.28k|}
misc.cpp:_ZZ10autodetectNSt3__14spanIKcLm18446744073709551615EEEENK3$_0clIN7simdutf13encoding_typeES6_EEDaRKT_RKT0_:
   16|  1.85k|  auto neq = [](const auto& a, const auto& b) { return a != b; };
misc.cpp:_ZZ6detectNSt3__14spanIKcLm18446744073709551615EEEENK3$_0clIiiEEDaRKT_RKT0_:
   33|  2.61k|  auto neq = [](const auto& a, const auto& b) { return a != b; };
misc.cpp:_ZZ14validate_asciiNSt3__14spanIKcLm18446744073709551615EEEENK3$_0clIiiEEDaRKT_RKT0_:
   57|    384|  auto neq = [](const auto& a, const auto& b) { return a != b; };
misc.cpp:_ZZ23validate_ascii_with_errNSt3__14spanIKcLm18446744073709551615EEEENK3$_0clIN7simdutf6resultES6_EEDaRKT_RKT0_:
   82|    572|  auto neq = [](const auto& a, const auto& b) { return a != b; };
misc.cpp:_ZZ16utf16_endiannessNSt3__14spanIKDsLm18446744073709551615EEEENK3$_0clINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEESA_EEDaRKT_RKT0_:
  107|    258|  auto neq = [](const auto& a, const auto& b) { return a != b; };
misc.cpp:_ZZ23validate_utf16_as_asciiNSt3__14spanIKDsLm18446744073709551615EEEENK3$_0clIiiEEDaRKT_RKT0_:
  138|    976|  auto neq = [](const auto& a, const auto& b) { return a != b; };
misc.cpp:_ZZ20to_well_formed_utf16NSt3__14spanIKDsLm18446744073709551615EEEENK3$_0clINS_6vectorIDsNS_9allocatorIDsEEEES8_EEDaRKT_RKT0_:
  201|  1.52k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
misc.cpp:_ZZ20to_well_formed_utf16NSt3__14spanIKDsLm18446744073709551615EEEENK3$_1clINS_6vectorIDsNS_9allocatorIDsEEEES8_EEDaRKT_RKT0_:
  238|  1.52k|    auto neq = [](const auto& a, const auto& b) { return a != b; };

_ZN7simdutf6resultC2ENS_10error_codeEm:
   87|  9.23k|      : error{err}, count{pos} {}
_ZNK7simdutf6result6is_errEv:
   93|  6.81k|  simdutf_really_inline simdutf_constexpr23 bool is_err() const noexcept {
   94|  6.81k|    return error != error_code::SUCCESS;
   95|  6.81k|  }

_ZNK7simdutf14implementation4nameEv:
 5654|      4|  virtual std::string_view name() const noexcept { return _name; }
_ZNK7simdutf14implementation25required_instruction_setsEv:
 5705|     10|  virtual uint32_t required_instruction_sets() const {
 5706|     10|    return _required_instruction_sets;
 5707|     10|  }
_ZN7simdutf14implementationC2EPKcS2_j:
 7619|      5|      : _name(name), _description(description),
 7620|      5|        _required_instruction_sets(required_instruction_sets) {}
_ZN7simdutf8internal29available_implementation_listC2Ev:
 7651|      1|  simdutf_really_inline available_implementation_list() {}
simdutf.cpp:_ZN7simdutf6detail12_GLOBAL__N_13minEmm:
   59|    764|constexpr std::size_t min(std::size_t a, std::size_t b) {
   60|    764|  return a < b ? a : b;
  ------------------
  |  Branch (60:10): [True: 198, False: 566]
  ------------------
   61|    764|}
_ZN7simdutf8internal10atomic_ptrIKNS_14implementationEEaSEPS3_:
 7722|      1|  atomic_ptr &operator=(T *_ptr) {
 7723|      1|    ptr = _ptr;
 7724|      1|    return *this;
 7725|      1|  }
_ZN7simdutf8internal10atomic_ptrIKNS_14implementationEEcvPS3_Ev:
 7719|      1|  operator T *() { return ptr.load(); }
_ZN7simdutf8internal10atomic_ptrIKNS_14implementationEEC2EPS3_:
 7699|      1|  atomic_ptr(T *_ptr) : ptr{_ptr} {}
_ZN7simdutf8internal10atomic_ptrIKNS_14implementationEEptEv:
 7721|    538|  T *operator->() { return ptr.load(); }

simdutf.cpp:_ZN7simdutf8internalL30detect_supported_architecturesEv:
  301|      9|static inline uint32_t detect_supported_architectures() {
  302|      9|  uint32_t eax;
  303|      9|  uint32_t ebx = 0;
  304|      9|  uint32_t ecx = 0;
  305|      9|  uint32_t edx = 0;
  306|      9|  uint32_t host_isa = 0x0;
  307|       |
  308|       |  // EBX for EAX=0x1
  309|      9|  eax = 0x1;
  310|      9|  cpuid(&eax, &ebx, &ecx, &edx);
  311|       |
  312|      9|  if (ecx & cpuid_bit::sse42) {
  ------------------
  |  Branch (312:7): [True: 9, False: 0]
  ------------------
  313|      9|    host_isa |= instruction_set::SSE42;
  314|      9|  }
  315|       |
  316|      9|  if (ecx & cpuid_bit::pclmulqdq) {
  ------------------
  |  Branch (316:7): [True: 9, False: 0]
  ------------------
  317|      9|    host_isa |= instruction_set::PCLMULQDQ;
  318|      9|  }
  319|       |
  320|      9|  if ((ecx & cpuid_bit::osxsave) != cpuid_bit::osxsave) {
  ------------------
  |  Branch (320:7): [True: 0, False: 9]
  ------------------
  321|      0|    return host_isa;
  322|      0|  }
  323|       |
  324|       |  // xgetbv for checking if the OS saves registers
  325|      9|  uint64_t xcr0 = xgetbv();
  326|       |
  327|      9|  if ((xcr0 & cpuid_bit::xcr0_bit::avx256_saved) == 0) {
  ------------------
  |  Branch (327:7): [True: 0, False: 9]
  ------------------
  328|      0|    return host_isa;
  329|      0|  }
  330|       |  // ECX for EAX=0x7
  331|      9|  eax = 0x7;
  332|      9|  ecx = 0x0; // Sub-leaf = 0
  333|      9|  cpuid(&eax, &ebx, &ecx, &edx);
  334|      9|  if (ebx & cpuid_bit::ebx::avx2) {
  ------------------
  |  Branch (334:7): [True: 9, False: 0]
  ------------------
  335|      9|    host_isa |= instruction_set::AVX2;
  336|      9|  }
  337|      9|  if (ebx & cpuid_bit::ebx::bmi1) {
  ------------------
  |  Branch (337:7): [True: 9, False: 0]
  ------------------
  338|      9|    host_isa |= instruction_set::BMI1;
  339|      9|  }
  340|      9|  if (ebx & cpuid_bit::ebx::bmi2) {
  ------------------
  |  Branch (340:7): [True: 9, False: 0]
  ------------------
  341|      9|    host_isa |= instruction_set::BMI2;
  342|      9|  }
  343|      9|  if (!((xcr0 & cpuid_bit::xcr0_bit::avx512_saved) ==
  ------------------
  |  Branch (343:7): [True: 9, False: 0]
  ------------------
  344|      9|        cpuid_bit::xcr0_bit::avx512_saved)) {
  345|      9|    return host_isa;
  346|      9|  }
  347|      0|  if (ebx & cpuid_bit::ebx::avx512f) {
  ------------------
  |  Branch (347:7): [True: 0, False: 0]
  ------------------
  348|      0|    host_isa |= instruction_set::AVX512F;
  349|      0|  }
  350|      0|  if (ebx & cpuid_bit::ebx::avx512bw) {
  ------------------
  |  Branch (350:7): [True: 0, False: 0]
  ------------------
  351|      0|    host_isa |= instruction_set::AVX512BW;
  352|      0|  }
  353|      0|  if (ebx & cpuid_bit::ebx::avx512cd) {
  ------------------
  |  Branch (353:7): [True: 0, False: 0]
  ------------------
  354|      0|    host_isa |= instruction_set::AVX512CD;
  355|      0|  }
  356|      0|  if (ebx & cpuid_bit::ebx::avx512dq) {
  ------------------
  |  Branch (356:7): [True: 0, False: 0]
  ------------------
  357|      0|    host_isa |= instruction_set::AVX512DQ;
  358|      0|  }
  359|      0|  if (ebx & cpuid_bit::ebx::avx512vl) {
  ------------------
  |  Branch (359:7): [True: 0, False: 0]
  ------------------
  360|      0|    host_isa |= instruction_set::AVX512VL;
  361|      0|  }
  362|      0|  if (ecx & cpuid_bit::ecx::avx512vbmi2) {
  ------------------
  |  Branch (362:7): [True: 0, False: 0]
  ------------------
  363|      0|    host_isa |= instruction_set::AVX512VBMI2;
  364|      0|  }
  365|      0|  if (ecx & cpuid_bit::ecx::avx512vpopcnt) {
  ------------------
  |  Branch (365:7): [True: 0, False: 0]
  ------------------
  366|      0|    host_isa |= instruction_set::AVX512VPOPCNTDQ;
  367|      0|  }
  368|      0|  return host_isa;
  369|      9|}
simdutf.cpp:_ZN7simdutf8internalL5cpuidEPjS1_S1_S1_:
  267|     18|                         uint32_t *edx) {
  268|       |  #if defined(_MSC_VER)
  269|       |  int cpu_info[4];
  270|       |  __cpuidex(cpu_info, *eax, *ecx);
  271|       |  *eax = cpu_info[0];
  272|       |  *ebx = cpu_info[1];
  273|       |  *ecx = cpu_info[2];
  274|       |  *edx = cpu_info[3];
  275|       |  #elif (defined(HAVE_GCC_GET_CPUID) && defined(USE_GCC_GET_CPUID)) ||         \
  276|       |      defined(__FILC__)
  277|       |  uint32_t level = *eax;
  278|       |  __get_cpuid(level, eax, ebx, ecx, edx);
  279|       |  #else
  280|     18|  uint32_t a = *eax, b, c = *ecx, d;
  281|     18|  asm volatile("cpuid\n\t" : "+a"(a), "=b"(b), "+c"(c), "=d"(d));
  282|     18|  *eax = a;
  283|     18|  *ebx = b;
  284|     18|  *ecx = c;
  285|     18|  *edx = d;
  286|     18|  #endif
  287|     18|}
simdutf.cpp:_ZN7simdutf8internalL6xgetbvEv:
  289|      9|static inline uint64_t xgetbv() {
  290|       |  #if defined(_MSC_VER)
  291|       |  return _xgetbv(0);
  292|       |  #elif defined(__FILC__)
  293|       |  return zxgetbv();
  294|       |  #else
  295|      9|  uint32_t xcr0_lo, xcr0_hi;
  296|      9|  asm volatile("xgetbv\n\t" : "=a"(xcr0_lo), "=d"(xcr0_hi) : "c"(0));
  297|      9|  return xcr0_lo | ((uint64_t)xcr0_hi << 32);
  298|      9|  #endif
  299|      9|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_15ascii8validateIPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEEbS6_m:
   16|    192|                                                      size_t len) noexcept {
   17|    192|  uint64_t pos = 0;
   18|       |
   19|       |#if SIMDUTF_CPLUSPLUS23
   20|       |  // avoid memcpy during constant evaluation
   21|       |  if !consteval
   22|       |#endif
   23|       |  // process in blocks of 16 bytes when possible
   24|    192|  {
   25|   273k|    for (; pos + 16 <= len; pos += 16) {
  ------------------
  |  Branch (25:12): [True: 273k, False: 61]
  ------------------
   26|   273k|      uint64_t v1;
   27|   273k|      std::memcpy(&v1, data + pos, sizeof(uint64_t));
   28|   273k|      uint64_t v2;
   29|   273k|      std::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   30|   273k|      uint64_t v{v1 | v2};
   31|   273k|      if ((v & 0x8080808080808080) != 0) {
  ------------------
  |  Branch (31:11): [True: 131, False: 272k]
  ------------------
   32|    131|        return false;
   33|    131|      }
   34|   273k|    }
   35|    192|  }
   36|       |
   37|       |  // process the tail byte-by-byte
   38|    293|  for (; pos < len; pos++) {
  ------------------
  |  Branch (38:10): [True: 259, False: 34]
  ------------------
   39|    259|    if (static_cast<std::uint8_t>(data[pos]) >= 0b10000000) {
  ------------------
  |  Branch (39:9): [True: 27, False: 232]
  ------------------
   40|     27|      return false;
   41|     27|    }
   42|    259|  }
   43|     34|  return true;
   44|     61|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_15ascii20validate_with_errorsIPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEENS_6resultES6_m:
   50|    786|validate_with_errors(InputPtr data, size_t len) noexcept {
   51|    786|  size_t pos = 0;
   52|       |#if SIMDUTF_CPLUSPLUS23
   53|       |  // avoid memcpy during constant evaluation
   54|       |  if !consteval
   55|       |#endif
   56|    786|  {
   57|       |    // process in blocks of 16 bytes when possible
   58|   319k|    for (; pos + 16 <= len; pos += 16) {
  ------------------
  |  Branch (58:12): [True: 318k, False: 157]
  ------------------
   59|   318k|      uint64_t v1;
   60|   318k|      std::memcpy(&v1, data + pos, sizeof(uint64_t));
   61|   318k|      uint64_t v2;
   62|   318k|      std::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   63|   318k|      uint64_t v{v1 | v2};
   64|   318k|      if ((v & 0x8080808080808080) != 0) {
  ------------------
  |  Branch (64:11): [True: 629, False: 318k]
  ------------------
   65|  4.01k|        for (; pos < len; pos++) {
  ------------------
  |  Branch (65:16): [True: 4.01k, False: 0]
  ------------------
   66|  4.01k|          if (static_cast<std::uint8_t>(data[pos]) >= 0b10000000) {
  ------------------
  |  Branch (66:15): [True: 629, False: 3.39k]
  ------------------
   67|    629|            return result(error_code::TOO_LARGE, pos);
   68|    629|          }
   69|  4.01k|        }
   70|    629|      }
   71|   318k|    }
   72|    786|  }
   73|       |
   74|       |  // process the tail byte-by-byte
   75|    560|  for (; pos < len; pos++) {
  ------------------
  |  Branch (75:10): [True: 524, False: 36]
  ------------------
   76|    524|    if (static_cast<std::uint8_t>(data[pos]) >= 0b10000000) {
  ------------------
  |  Branch (76:9): [True: 121, False: 403]
  ------------------
   77|    121|      return result(error_code::TOO_LARGE, pos);
   78|    121|    }
   79|    524|  }
   80|     36|  return result(error_code::SUCCESS, pos);
   81|    157|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114latin1_to_utf812convert_safeEPKcmPcm:
   72|    267|                           size_t utf8_len) {
   73|    267|  const unsigned char *data = reinterpret_cast<const unsigned char *>(buf);
   74|    267|  size_t pos = 0;
   75|    267|  size_t skip_pos = 0;
   76|    267|  size_t utf8_pos = 0;
   77|  1.61k|  while (pos < len && utf8_pos < utf8_len) {
  ------------------
  |  Branch (77:10): [True: 1.48k, False: 130]
  |  Branch (77:23): [True: 1.39k, False: 89]
  ------------------
   78|       |    // try to convert the next block of 16 ASCII bytes
   79|  1.39k|    if (pos >= skip_pos && pos + 16 <= len &&
  ------------------
  |  Branch (79:9): [True: 687, False: 705]
  |  Branch (79:28): [True: 362, False: 325]
  ------------------
   80|    362|        utf8_pos + 16 <= utf8_len) { // if it is safe to read 16 more bytes,
  ------------------
  |  Branch (80:9): [True: 86, False: 276]
  ------------------
   81|       |                                     // check that they are ascii
   82|     86|      uint64_t v1;
   83|     86|      ::memcpy(&v1, data + pos, sizeof(uint64_t));
   84|     86|      uint64_t v2;
   85|     86|      ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   86|     86|      uint64_t v{v1 |
   87|     86|                 v2}; // We are only interested in these bits: 1000 1000 1000
   88|       |                      // 1000, so it makes sense to concatenate everything
   89|     86|      if ((v & 0x8080808080808080) ==
  ------------------
  |  Branch (89:11): [True: 40, False: 46]
  ------------------
   90|     86|          0) { // if NONE of these are set, e.g. all of them are zero, then
   91|       |               // everything is ASCII
   92|     40|        ::memcpy(utf8_output + utf8_pos, buf + pos, 16);
   93|     40|        utf8_pos += 16;
   94|     40|        pos += 16;
   95|     46|      } else {
   96|       |        // At least one of the next 16 bytes are not ASCII, we will process them
   97|       |        // one by one
   98|     46|        skip_pos = pos + 16;
   99|     46|      }
  100|  1.30k|    } else {
  101|  1.30k|      const auto byte = data[pos];
  102|  1.30k|      if ((byte & 0x80) == 0) { // if ASCII
  ------------------
  |  Branch (102:11): [True: 814, False: 492]
  ------------------
  103|       |        // will generate one UTF-8 bytes
  104|    814|        utf8_output[utf8_pos++] = char(byte);
  105|    814|        pos++;
  106|    814|      } else if (utf8_pos + 2 <= utf8_len) {
  ------------------
  |  Branch (106:18): [True: 444, False: 48]
  ------------------
  107|       |        // will generate two UTF-8 bytes
  108|    444|        utf8_output[utf8_pos++] = char((byte >> 6) | 0b11000000);
  109|    444|        utf8_output[utf8_pos++] = char((byte & 0b111111) | 0b10000000);
  110|    444|        pos++;
  111|    444|      } else {
  112|     48|        break;
  113|     48|      }
  114|  1.30k|    }
  115|  1.39k|  }
  116|    267|  return utf8_pos;
  117|    267|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114latin1_to_utf87convertEPKcmPc:
   66|    512|                                     char *utf8_output) {
   67|    512|  return convert(reinterpret_cast<const unsigned char *>(buf), len,
   68|    512|                 utf8_output);
   69|    512|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114latin1_to_utf87convertIPKhPcQaasr7simdutf6detailE22indexes_into_byte_likeIT_Esr7simdutf6detailE26index_assignable_from_charIT0_EEEmS7_mS8_:
   17|    512|                                   OutputPtr utf8_output) {
   18|       |  // const unsigned char *data = reinterpret_cast<const unsigned char *>(buf);
   19|    512|  size_t pos = 0;
   20|    512|  size_t utf8_pos = 0;
   21|       |
   22|  6.85k|  while (pos < len) {
  ------------------
  |  Branch (22:10): [True: 6.33k, False: 512]
  ------------------
   23|       |#if SIMDUTF_CPLUSPLUS23
   24|       |    if !consteval
   25|       |#endif
   26|  6.33k|    {
   27|       |      // try to convert the next block of 16 ASCII bytes
   28|  6.33k|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (28:11): [True: 1.04k, False: 5.29k]
  ------------------
   29|       |                             // they are ascii
   30|  1.04k|        uint64_t v1;
   31|  1.04k|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   32|  1.04k|        uint64_t v2;
   33|  1.04k|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   34|  1.04k|        uint64_t v{v1 |
   35|  1.04k|                   v2}; // We are only interested in these bits: 1000 1000 1000
   36|       |                        // 1000, so it makes sense to concatenate everything
   37|  1.04k|        if ((v & 0x8080808080808080) ==
  ------------------
  |  Branch (37:13): [True: 130, False: 913]
  ------------------
   38|  1.04k|            0) { // if NONE of these are set, e.g. all of them are zero, then
   39|       |                 // everything is ASCII
   40|    130|          size_t final_pos = pos + 16;
   41|  2.21k|          while (pos < final_pos) {
  ------------------
  |  Branch (41:18): [True: 2.08k, False: 130]
  ------------------
   42|  2.08k|            utf8_output[utf8_pos++] = char(data[pos]);
   43|  2.08k|            pos++;
   44|  2.08k|          }
   45|    130|          continue;
   46|    130|        }
   47|  1.04k|      } // if (pos + 16 <= len)
   48|  6.33k|    } // !consteval scope
   49|       |
   50|  6.20k|    unsigned char byte = data[pos];
   51|  6.20k|    if ((byte & 0x80) == 0) { // if ASCII
  ------------------
  |  Branch (51:9): [True: 2.98k, False: 3.22k]
  ------------------
   52|       |      // will generate one UTF-8 bytes
   53|  2.98k|      utf8_output[utf8_pos++] = char(byte);
   54|  2.98k|      pos++;
   55|  3.22k|    } else {
   56|       |      // will generate two UTF-8 bytes
   57|  3.22k|      utf8_output[utf8_pos++] = char((byte >> 6) | 0b11000000);
   58|  3.22k|      utf8_output[utf8_pos++] = char((byte & 0b111111) | 0b10000000);
   59|  3.22k|      pos++;
   60|  3.22k|    }
   61|  6.20k|  } // while
   62|    512|  return utf8_pos;
   63|    512|}

_ZN7simdutf6scalar14u16_swap_bytesEt:
    8|  54.9M|u16_swap_bytes(const uint16_t word) {
    9|  54.9M|  return uint16_t((word >> 8) | (word << 8));
   10|  54.9M|}
_ZN7simdutf6scalar5utf1614swap_if_neededILNS_10endiannessE0EEEtt:
   27|  72.4M|template <endianness big_endian> constexpr uint16_t swap_if_needed(uint16_t c) {
   28|  72.4M|  return !match_system(big_endian) ? scalar::u16_swap_bytes(c) : c;
  ------------------
  |  Branch (28:10): [Folded, False: 72.4M]
  ------------------
   29|  72.4M|}
_ZN7simdutf6scalar5utf1614swap_if_neededILNS_10endiannessE1EEEtt:
   27|  54.9M|template <endianness big_endian> constexpr uint16_t swap_if_needed(uint16_t c) {
   28|  54.9M|  return !match_system(big_endian) ? scalar::u16_swap_bytes(c) : c;
  ------------------
  |  Branch (28:10): [True: 54.9M, Folded]
  ------------------
   29|  54.9M|}

_ZN7simdutf6scalar5utf1623change_endianness_utf16EPKDsmPDs:
  119|    387|change_endianness_utf16(const char16_t *input, size_t size, char16_t *output) {
  120|  3.13M|  for (size_t i = 0; i < size; i++) {
  ------------------
  |  Branch (120:22): [True: 3.13M, False: 387]
  ------------------
  121|  3.13M|    *output++ = char16_t(input[i] >> 8 | input[i] << 8);
  122|  3.13M|  }
  123|    387|}
_ZN7simdutf6scalar5utf1618trim_partial_utf16ILNS_10endiannessE1EEEmPKDsm:
  127|     23|trim_partial_utf16(const char16_t *input, size_t length) {
  128|     23|  if (length == 0) {
  ------------------
  |  Branch (128:7): [True: 1, False: 22]
  ------------------
  129|      1|    return 0;
  130|      1|  }
  131|     22|  uint16_t last_word = uint16_t(input[length - 1]);
  132|     22|  last_word = scalar::utf16::swap_if_needed<big_endian>(last_word);
  133|     22|  length -= ((last_word & 0xFC00) == 0xD800);
  134|     22|  return length;
  135|     23|}
_ZN7simdutf6scalar5utf1618trim_partial_utf16ILNS_10endiannessE0EEEmPKDsm:
  127|     40|trim_partial_utf16(const char16_t *input, size_t length) {
  128|     40|  if (length == 0) {
  ------------------
  |  Branch (128:7): [True: 1, False: 39]
  ------------------
  129|      1|    return 0;
  130|      1|  }
  131|     39|  uint16_t last_word = uint16_t(input[length - 1]);
  132|     39|  last_word = scalar::utf16::swap_if_needed<big_endian>(last_word);
  133|     39|  length -= ((last_word & 0xFC00) == 0xD800);
  134|     39|  return length;
  135|     40|}
_ZN7simdutf6scalar5utf1617validate_as_asciiILNS_10endiannessE0EEEbPKDsm:
   10|    244|validate_as_ascii(const char16_t *data, size_t len) noexcept {
   11|  36.2k|  for (size_t pos = 0; pos < len; pos++) {
  ------------------
  |  Branch (11:24): [True: 36.2k, False: 20]
  ------------------
   12|  36.2k|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(data[pos]);
   13|  36.2k|    if (word >= 0x80) {
  ------------------
  |  Branch (13:9): [True: 224, False: 36.0k]
  ------------------
   14|    224|      return false;
   15|    224|    }
   16|  36.2k|  }
   17|     20|  return true;
   18|    244|}
_ZN7simdutf6scalar5utf1617validate_as_asciiILNS_10endiannessE1EEEbPKDsm:
   10|    244|validate_as_ascii(const char16_t *data, size_t len) noexcept {
   11|  72.5k|  for (size_t pos = 0; pos < len; pos++) {
  ------------------
  |  Branch (11:24): [True: 72.5k, False: 20]
  ------------------
   12|  72.5k|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(data[pos]);
   13|  72.5k|    if (word >= 0x80) {
  ------------------
  |  Branch (13:9): [True: 224, False: 72.3k]
  ------------------
   14|    224|      return false;
   15|    224|    }
   16|  72.5k|  }
   17|     20|  return true;
   18|    244|}
_ZN7simdutf6scalar5utf168validateILNS_10endiannessE0EEEbPKDsm:
   22|  5.28k|validate(const char16_t *data, size_t len) noexcept {
   23|  5.28k|  uint64_t pos = 0;
   24|  32.1M|  while (pos < len) {
  ------------------
  |  Branch (24:10): [True: 32.1M, False: 3.42k]
  ------------------
   25|  32.1M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(data[pos]);
   26|  32.1M|    if ((word & 0xF800) == 0xD800) {
  ------------------
  |  Branch (26:9): [True: 42.3k, False: 32.1M]
  ------------------
   27|  42.3k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (27:11): [True: 280, False: 42.0k]
  ------------------
   28|    280|        return false;
   29|    280|      }
   30|  42.0k|      char16_t diff = char16_t(word - 0xD800);
   31|  42.0k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (31:11): [True: 898, False: 41.1k]
  ------------------
   32|    898|        return false;
   33|    898|      }
   34|  41.1k|      char16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (34:28): [Folded, False: 41.1k]
  ------------------
   35|  41.1k|                               ? u16_swap_bytes(data[pos + 1])
   36|  41.1k|                               : data[pos + 1];
   37|  41.1k|      char16_t diff2 = char16_t(next_word - 0xDC00);
   38|  41.1k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (38:11): [True: 682, False: 40.4k]
  ------------------
   39|    682|        return false;
   40|    682|      }
   41|  40.4k|      pos += 2;
   42|  32.1M|    } else {
   43|  32.1M|      pos++;
   44|  32.1M|    }
   45|  32.1M|  }
   46|  3.42k|  return true;
   47|  5.28k|}
_ZN7simdutf6scalar5utf168validateILNS_10endiannessE1EEEbPKDsm:
   22|  2.70k|validate(const char16_t *data, size_t len) noexcept {
   23|  2.70k|  uint64_t pos = 0;
   24|  14.6M|  while (pos < len) {
  ------------------
  |  Branch (24:10): [True: 14.6M, False: 2.38k]
  ------------------
   25|  14.6M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(data[pos]);
   26|  14.6M|    if ((word & 0xF800) == 0xD800) {
  ------------------
  |  Branch (26:9): [True: 41.0k, False: 14.5M]
  ------------------
   27|  41.0k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (27:11): [True: 50, False: 41.0k]
  ------------------
   28|     50|        return false;
   29|     50|      }
   30|  41.0k|      char16_t diff = char16_t(word - 0xD800);
   31|  41.0k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (31:11): [True: 137, False: 40.8k]
  ------------------
   32|    137|        return false;
   33|    137|      }
   34|  40.8k|      char16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (34:28): [True: 40.8k, Folded]
  ------------------
   35|  40.8k|                               ? u16_swap_bytes(data[pos + 1])
   36|  40.8k|                               : data[pos + 1];
   37|  40.8k|      char16_t diff2 = char16_t(next_word - 0xDC00);
   38|  40.8k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (38:11): [True: 130, False: 40.7k]
  ------------------
   39|    130|        return false;
   40|    130|      }
   41|  40.7k|      pos += 2;
   42|  14.5M|    } else {
   43|  14.5M|      pos++;
   44|  14.5M|    }
   45|  14.6M|  }
   46|  2.38k|  return true;
   47|  2.70k|}
_ZN7simdutf6scalar5utf1620to_well_formed_utf16ILNS_10endiannessE0EEEvPKDsmPDs:
  190|  1.04k|                                              char16_t *output) {
  191|  1.04k|  const char16_t replacement = utf16::replacement<big_endian>();
  192|  1.04k|  bool high_surrogate_prev = false, high_surrogate, low_surrogate;
  193|  1.04k|  size_t i = 0;
  194|  14.6M|  for (; i < len; i++) {
  ------------------
  |  Branch (194:10): [True: 14.6M, False: 1.04k]
  ------------------
  195|  14.6M|    char16_t c = input[i];
  196|  14.6M|    high_surrogate = is_high_surrogate<big_endian>(c);
  197|  14.6M|    low_surrogate = is_low_surrogate<big_endian>(c);
  198|  14.6M|    if (high_surrogate_prev && !low_surrogate) {
  ------------------
  |  Branch (198:9): [True: 148k, False: 14.4M]
  |  Branch (198:32): [True: 108k, False: 39.2k]
  ------------------
  199|   108k|      output[i - 1] = replacement;
  200|   108k|    }
  201|       |
  202|  14.6M|    if (!high_surrogate_prev && low_surrogate) {
  ------------------
  |  Branch (202:9): [True: 14.4M, False: 148k]
  |  Branch (202:33): [True: 397k, False: 14.0M]
  ------------------
  203|   397k|      output[i] = replacement;
  204|  14.2M|    } else {
  205|  14.2M|      output[i] = input[i];
  206|  14.2M|    }
  207|  14.6M|    high_surrogate_prev = high_surrogate;
  208|  14.6M|  }
  209|       |
  210|       |  /* string may not end with high surrogate */
  211|  1.04k|  if (high_surrogate_prev) {
  ------------------
  |  Branch (211:7): [True: 136, False: 906]
  ------------------
  212|    136|    output[i - 1] = replacement;
  213|    136|  }
  214|  1.04k|}
_ZN7simdutf6scalar5utf1617is_high_surrogateILNS_10endiannessE0EEEbDs:
  137|  14.6M|template <endianness big_endian> constexpr bool is_high_surrogate(char16_t c) {
  138|  14.6M|  c = scalar::utf16::swap_if_needed<big_endian>(c);
  139|  14.6M|  return (0xd800 <= c && c <= 0xdbff);
  ------------------
  |  Branch (139:11): [True: 1.06M, False: 13.5M]
  |  Branch (139:26): [True: 148k, False: 918k]
  ------------------
  140|  14.6M|}
_ZN7simdutf6scalar5utf1616is_low_surrogateILNS_10endiannessE0EEEbDs:
  142|  14.6M|template <endianness big_endian> constexpr bool is_low_surrogate(char16_t c) {
  143|  14.6M|  c = scalar::utf16::swap_if_needed<big_endian>(c);
  144|  14.6M|  return (0xdc00 <= c && c <= 0xdfff);
  ------------------
  |  Branch (144:11): [True: 918k, False: 13.7M]
  |  Branch (144:26): [True: 437k, False: 481k]
  ------------------
  145|  14.6M|}
_ZN7simdutf6scalar5utf1620to_well_formed_utf16ILNS_10endiannessE1EEEvPKDsmPDs:
  190|  1.04k|                                              char16_t *output) {
  191|  1.04k|  const char16_t replacement = utf16::replacement<big_endian>();
  192|  1.04k|  bool high_surrogate_prev = false, high_surrogate, low_surrogate;
  193|  1.04k|  size_t i = 0;
  194|  14.6M|  for (; i < len; i++) {
  ------------------
  |  Branch (194:10): [True: 14.6M, False: 1.04k]
  ------------------
  195|  14.6M|    char16_t c = input[i];
  196|  14.6M|    high_surrogate = is_high_surrogate<big_endian>(c);
  197|  14.6M|    low_surrogate = is_low_surrogate<big_endian>(c);
  198|  14.6M|    if (high_surrogate_prev && !low_surrogate) {
  ------------------
  |  Branch (198:9): [True: 149k, False: 14.4M]
  |  Branch (198:32): [True: 109k, False: 40.2k]
  ------------------
  199|   109k|      output[i - 1] = replacement;
  200|   109k|    }
  201|       |
  202|  14.6M|    if (!high_surrogate_prev && low_surrogate) {
  ------------------
  |  Branch (202:9): [True: 14.4M, False: 149k]
  |  Branch (202:33): [True: 397k, False: 14.0M]
  ------------------
  203|   397k|      output[i] = replacement;
  204|  14.2M|    } else {
  205|  14.2M|      output[i] = input[i];
  206|  14.2M|    }
  207|  14.6M|    high_surrogate_prev = high_surrogate;
  208|  14.6M|  }
  209|       |
  210|       |  /* string may not end with high surrogate */
  211|  1.04k|  if (high_surrogate_prev) {
  ------------------
  |  Branch (211:7): [True: 132, False: 910]
  ------------------
  212|    132|    output[i - 1] = replacement;
  213|    132|  }
  214|  1.04k|}
_ZN7simdutf6scalar5utf1617is_high_surrogateILNS_10endiannessE1EEEbDs:
  137|  14.6M|template <endianness big_endian> constexpr bool is_high_surrogate(char16_t c) {
  138|  14.6M|  c = scalar::utf16::swap_if_needed<big_endian>(c);
  139|  14.6M|  return (0xd800 <= c && c <= 0xdbff);
  ------------------
  |  Branch (139:11): [True: 1.06M, False: 13.5M]
  |  Branch (139:26): [True: 150k, False: 917k]
  ------------------
  140|  14.6M|}
_ZN7simdutf6scalar5utf1616is_low_surrogateILNS_10endiannessE1EEEbDs:
  142|  14.6M|template <endianness big_endian> constexpr bool is_low_surrogate(char16_t c) {
  143|  14.6M|  c = scalar::utf16::swap_if_needed<big_endian>(c);
  144|  14.6M|  return (0xdc00 <= c && c <= 0xdfff);
  ------------------
  |  Branch (144:11): [True: 917k, False: 13.7M]
  |  Branch (144:26): [True: 437k, False: 479k]
  ------------------
  145|  14.6M|}

_ZN7simdutf6scalar5utf328validateEPKDim:
   25|  1.52k|                                                        size_t len) noexcept {
   26|  1.52k|  return validate(reinterpret_cast<const uint32_t *>(buf), len);
   27|  1.52k|}
_ZN7simdutf6scalar5utf328validateIPKjQsr7simdutf6detailE19indexes_into_uint32IT_EEEbS5_m:
   13|  1.52k|                                                      size_t len) noexcept {
   14|  1.52k|  uint64_t pos = 0;
   15|  2.05M|  for (; pos < len; pos++) {
  ------------------
  |  Branch (15:10): [True: 2.05M, False: 248]
  ------------------
   16|  2.05M|    uint32_t word = data[pos];
   17|  2.05M|    if (word > 0x10FFFF || (word >= 0xD800 && word <= 0xDFFF)) {
  ------------------
  |  Branch (17:9): [True: 1.17k, False: 2.05M]
  |  Branch (17:29): [True: 5.00k, False: 2.04M]
  |  Branch (17:47): [True: 102, False: 4.90k]
  ------------------
   18|  1.27k|      return false;
   19|  1.27k|    }
   20|  2.05M|  }
   21|    248|  return true;
   22|  1.52k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf88validateEPKcm:
  113|  2.16k|                                                        size_t len) noexcept {
  114|  2.16k|  return validate(reinterpret_cast<const uint8_t *>(buf), len);
  115|  2.16k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf88validateIPKhEEbT_m:
   14|  2.16k|                                                      size_t len) noexcept {
   15|  2.16k|  static_assert(
   16|  2.16k|      std::is_same<typename std::decay<decltype(*data)>::type, uint8_t>::value,
   17|  2.16k|      "dereferencing the data pointer must result in a uint8_t");
   18|  2.16k|  uint64_t pos = 0;
   19|  2.16k|  uint32_t code_point = 0;
   20|  1.64M|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 1.64M, False: 117]
  ------------------
   21|  1.64M|    uint64_t next_pos;
   22|       |#if SIMDUTF_CPLUSPLUS23
   23|       |    if !consteval
   24|       |#endif
   25|  1.64M|    { // check if the next 16 bytes are ascii.
   26|  1.64M|      next_pos = pos + 16;
   27|  1.64M|      if (next_pos <= len) { // if it is safe to read 16 more bytes, check
  ------------------
  |  Branch (27:11): [True: 1.64M, False: 1.09k]
  ------------------
   28|       |                             // that they are ascii
   29|  1.64M|        uint64_t v1{};
   30|  1.64M|        std::memcpy(&v1, data + pos, sizeof(uint64_t));
   31|  1.64M|        uint64_t v2{};
   32|  1.64M|        std::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   33|  1.64M|        uint64_t v{v1 | v2};
   34|  1.64M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (34:13): [True: 1.31M, False: 323k]
  ------------------
   35|  1.31M|          pos = next_pos;
   36|  1.31M|          continue;
   37|  1.31M|        }
   38|  1.64M|      }
   39|  1.64M|    }
   40|       |
   41|   324k|    unsigned char byte = data[pos];
   42|       |
   43|  3.06M|    while (byte < 0b10000000) {
  ------------------
  |  Branch (43:12): [True: 2.74M, False: 324k]
  ------------------
   44|  2.74M|      if (++pos == len) {
  ------------------
  |  Branch (44:11): [True: 120, False: 2.74M]
  ------------------
   45|    120|        return true;
   46|    120|      }
   47|  2.74M|      byte = data[pos];
   48|  2.74M|    }
   49|       |
   50|   324k|    if ((byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (50:9): [True: 34.6k, False: 289k]
  ------------------
   51|  34.6k|      next_pos = pos + 2;
   52|  34.6k|      if (next_pos > len) {
  ------------------
  |  Branch (52:11): [True: 40, False: 34.5k]
  ------------------
   53|     40|        return false;
   54|     40|      }
   55|  34.5k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (55:11): [True: 539, False: 34.0k]
  ------------------
   56|    539|        return false;
   57|    539|      }
   58|       |      // range check
   59|  34.0k|      code_point = (byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111);
   60|  34.0k|      if (code_point < 0x80) {
  ------------------
  |  Branch (60:11): [True: 17, False: 34.0k]
  ------------------
   61|     17|        return false;
   62|     17|      }
   63|   289k|    } else if ((byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (63:16): [True: 147k, False: 142k]
  ------------------
   64|   147k|      next_pos = pos + 3;
   65|   147k|      if (next_pos > len) {
  ------------------
  |  Branch (65:11): [True: 14, False: 147k]
  ------------------
   66|     14|        return false;
   67|     14|      }
   68|   147k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (68:11): [True: 155, False: 146k]
  ------------------
   69|    155|        return false;
   70|    155|      }
   71|   146k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (71:11): [True: 46, False: 146k]
  ------------------
   72|     46|        return false;
   73|     46|      }
   74|       |      // range check
   75|   146k|      code_point = (byte & 0b00001111) << 12 |
   76|   146k|                   (data[pos + 1] & 0b00111111) << 6 |
   77|   146k|                   (data[pos + 2] & 0b00111111);
   78|   146k|      if ((code_point < 0x800) ||
  ------------------
  |  Branch (78:11): [True: 6, False: 146k]
  ------------------
   79|   146k|          (0xd7ff < code_point && code_point < 0xe000)) {
  ------------------
  |  Branch (79:12): [True: 4.01k, False: 142k]
  |  Branch (79:35): [True: 1, False: 4.01k]
  ------------------
   80|      7|        return false;
   81|      7|      }
   82|   146k|    } else if ((byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (82:16): [True: 141k, False: 947]
  ------------------
   83|   141k|      next_pos = pos + 4;
   84|   141k|      if (next_pos > len) {
  ------------------
  |  Branch (84:11): [True: 23, False: 141k]
  ------------------
   85|     23|        return false;
   86|     23|      }
   87|   141k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (87:11): [True: 87, False: 141k]
  ------------------
   88|     87|        return false;
   89|     87|      }
   90|   141k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (90:11): [True: 25, False: 141k]
  ------------------
   91|     25|        return false;
   92|     25|      }
   93|   141k|      if ((data[pos + 3] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (93:11): [True: 17, False: 141k]
  ------------------
   94|     17|        return false;
   95|     17|      }
   96|       |      // range check
   97|   141k|      code_point =
   98|   141k|          (byte & 0b00000111) << 18 | (data[pos + 1] & 0b00111111) << 12 |
   99|   141k|          (data[pos + 2] & 0b00111111) << 6 | (data[pos + 3] & 0b00111111);
  100|   141k|      if (code_point <= 0xffff || 0x10ffff < code_point) {
  ------------------
  |  Branch (100:11): [True: 7, False: 141k]
  |  Branch (100:35): [True: 5, False: 141k]
  ------------------
  101|     12|        return false;
  102|     12|      }
  103|   141k|    } else {
  104|       |      // we may have a continuation
  105|    947|      return false;
  106|    947|    }
  107|   322k|    pos = next_pos;
  108|   322k|  }
  109|    117|  return true;
  110|  2.16k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf817trim_partial_utf8IPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEEmS6_m:
  488|    240|trim_partial_utf8(InputPtr input, size_t length) {
  489|    240|  if (length < 3) {
  ------------------
  |  Branch (489:7): [True: 33, False: 207]
  ------------------
  490|     33|    switch (length) {
  ------------------
  |  Branch (490:13): [True: 33, False: 0]
  ------------------
  491|     18|    case 2:
  ------------------
  |  Branch (491:5): [True: 18, False: 15]
  ------------------
  492|     18|      if (uint8_t(input[length - 1]) >= 0xc0) {
  ------------------
  |  Branch (492:11): [True: 1, False: 17]
  ------------------
  493|      1|        return length - 1;
  494|      1|      } // 2-, 3- and 4-byte characters with only 1 byte left
  495|     17|      if (uint8_t(input[length - 2]) >= 0xe0) {
  ------------------
  |  Branch (495:11): [True: 1, False: 16]
  ------------------
  496|      1|        return length - 2;
  497|      1|      } // 3- and 4-byte characters with only 2 bytes left
  498|     16|      return length;
  499|     14|    case 1:
  ------------------
  |  Branch (499:5): [True: 14, False: 19]
  ------------------
  500|     14|      if (uint8_t(input[length - 1]) >= 0xc0) {
  ------------------
  |  Branch (500:11): [True: 4, False: 10]
  ------------------
  501|      4|        return length - 1;
  502|      4|      } // 2-, 3- and 4-byte characters with only 1 byte left
  503|     10|      return length;
  504|      1|    case 0:
  ------------------
  |  Branch (504:5): [True: 1, False: 32]
  ------------------
  505|      1|      return length;
  506|     33|    }
  507|     33|  }
  508|    207|  if (uint8_t(input[length - 1]) >= 0xc0) {
  ------------------
  |  Branch (508:7): [True: 36, False: 171]
  ------------------
  509|     36|    return length - 1;
  510|     36|  } // 2-, 3- and 4-byte characters with only 1 byte left
  511|    171|  if (uint8_t(input[length - 2]) >= 0xe0) {
  ------------------
  |  Branch (511:7): [True: 5, False: 166]
  ------------------
  512|      5|    return length - 2;
  513|      5|  } // 3- and 4-byte characters with only 1 byte left
  514|    166|  if (uint8_t(input[length - 3]) >= 0xf0) {
  ------------------
  |  Branch (514:7): [True: 7, False: 159]
  ------------------
  515|      7|    return length - 3;
  516|      7|  } // 4-byte characters with only 3 bytes left
  517|    159|  return length;
  518|    166|}

_ZN7simdutf3BOM9check_bomEPKhm:
   26|  6.69k|encoding_type check_bom(const uint8_t *byte, size_t length) {
   27|  6.69k|  if (length >= 2 && byte[0] == 0xff and byte[1] == 0xfe) {
  ------------------
  |  Branch (27:7): [True: 6.65k, False: 42]
  |  Branch (27:22): [True: 534, False: 6.11k]
  |  Branch (27:42): [True: 177, False: 357]
  ------------------
   28|    177|    if (length >= 4 && byte[2] == 0x00 and byte[3] == 0x0) {
  ------------------
  |  Branch (28:9): [True: 168, False: 9]
  |  Branch (28:24): [True: 87, False: 81]
  |  Branch (28:44): [True: 12, False: 75]
  ------------------
   29|     12|      return encoding_type::UTF32_LE;
   30|    165|    } else {
   31|    165|      return encoding_type::UTF16_LE;
   32|    165|    }
   33|  6.51k|  } else if (length >= 2 && byte[0] == 0xfe and byte[1] == 0xff) {
  ------------------
  |  Branch (33:14): [True: 6.47k, False: 42]
  |  Branch (33:29): [True: 147, False: 6.32k]
  |  Branch (33:49): [True: 6, False: 141]
  ------------------
   34|      6|    return encoding_type::UTF16_BE;
   35|  6.51k|  } else if (length >= 4 && byte[0] == 0x00 and byte[1] == 0x00 and
  ------------------
  |  Branch (35:14): [True: 5.94k, False: 567]
  |  Branch (35:29): [True: 2.63k, False: 3.31k]
  |  Branch (35:49): [True: 2.03k, False: 594]
  ------------------
   36|  2.03k|             byte[2] == 0xfe and byte[3] == 0xff) {
  ------------------
  |  Branch (36:14): [True: 96, False: 1.94k]
  |  Branch (36:34): [True: 6, False: 90]
  ------------------
   37|      6|    return encoding_type::UTF32_BE;
   38|  6.50k|  } else if (length >= 3 && byte[0] == 0xef and byte[1] == 0xbb and
  ------------------
  |  Branch (38:14): [True: 6.19k, False: 306]
  |  Branch (38:29): [True: 309, False: 5.88k]
  |  Branch (38:49): [True: 138, False: 171]
  ------------------
   39|    138|             byte[2] == 0xbf) {
  ------------------
  |  Branch (39:14): [True: 6, False: 132]
  ------------------
   40|      6|    return encoding_type::UTF8;
   41|      6|  }
   42|  6.49k|  return encoding_type::unspecified;
   43|  6.69k|}
_ZN7simdutf3BOM9check_bomEPKcm:
   45|  6.69k|encoding_type check_bom(const char *byte, size_t length) {
   46|  6.69k|  return check_bom(reinterpret_cast<const uint8_t *>(byte), length);
   47|  6.69k|}

_ZNK7simdutf8fallback14implementation16detect_encodingsEPKcm:
    9|  1.30k|                                 size_t length) const noexcept {
   10|       |  // If there is a BOM, then we trust it.
   11|  1.30k|  auto bom_encoding = simdutf::BOM::check_bom(input, length);
   12|  1.30k|  if (bom_encoding != encoding_type::unspecified) {
  ------------------
  |  Branch (12:7): [True: 40, False: 1.26k]
  ------------------
   13|     40|    return bom_encoding;
   14|     40|  }
   15|  1.26k|  int out = 0;
   16|       |  // todo: reimplement as a one-pass algorithm.
   17|  1.26k|  if (validate_utf8(input, length)) {
  ------------------
  |  Branch (17:7): [True: 152, False: 1.11k]
  ------------------
   18|    152|    out |= encoding_type::UTF8;
   19|    152|  }
   20|  1.26k|  if ((length % 2) == 0) {
  ------------------
  |  Branch (20:7): [True: 1.02k, False: 239]
  ------------------
   21|  1.02k|    if (validate_utf16le(reinterpret_cast<const char16_t *>(input),
  ------------------
  |  Branch (21:9): [True: 518, False: 508]
  ------------------
   22|  1.02k|                         length / 2)) {
   23|    518|      out |= encoding_type::UTF16_LE;
   24|    518|    }
   25|  1.02k|  }
   26|  1.26k|  if ((length % 4) == 0) {
  ------------------
  |  Branch (26:7): [True: 698, False: 567]
  ------------------
   27|    698|    if (validate_utf32(reinterpret_cast<const char32_t *>(input), length / 4)) {
  ------------------
  |  Branch (27:9): [True: 116, False: 582]
  ------------------
   28|    116|      out |= encoding_type::UTF32_LE;
   29|    116|    }
   30|    698|  }
   31|  1.26k|  return out;
   32|  1.30k|}
_ZNK7simdutf8fallback14implementation13validate_utf8EPKcm:
   37|  2.16k|implementation::validate_utf8(const char *buf, size_t len) const noexcept {
   38|  2.16k|  return scalar::utf8::validate(buf, len);
   39|  2.16k|}
_ZNK7simdutf8fallback14implementation14validate_asciiEPKcm:
   51|    192|implementation::validate_ascii(const char *buf, size_t len) const noexcept {
   52|    192|  return scalar::ascii::validate(buf, len);
   53|    192|}
_ZNK7simdutf8fallback14implementation26validate_ascii_with_errorsEPKcm:
   56|    286|    const char *buf, size_t len) const noexcept {
   57|    286|  return scalar::ascii::validate_with_errors(buf, len);
   58|    286|}
_ZNK7simdutf8fallback14implementation25validate_utf16le_as_asciiEPKDsm:
   64|    244|                                          size_t len) const noexcept {
   65|    244|  return scalar::utf16::validate_as_ascii<endianness::LITTLE>(buf, len);
   66|    244|}
_ZNK7simdutf8fallback14implementation25validate_utf16be_as_asciiEPKDsm:
   70|    244|                                          size_t len) const noexcept {
   71|    244|  return scalar::utf16::validate_as_ascii<endianness::BIG>(buf, len);
   72|    244|}
_ZNK7simdutf8fallback14implementation16validate_utf16leEPKDsm:
   77|  2.47k|                                 size_t len) const noexcept {
   78|  2.47k|  return scalar::utf16::validate<endianness::LITTLE>(buf, len);
   79|  2.47k|}
_ZNK7simdutf8fallback14implementation16validate_utf16beEPKDsm:
   85|    780|                                 size_t len) const noexcept {
   86|    780|  return scalar::utf16::validate<endianness::BIG>(buf, len);
   87|    780|}
_ZNK7simdutf8fallback14implementation22to_well_formed_utf16leEPKDsmPDs:
  100|    760|                                            char16_t *output) const noexcept {
  101|    760|  return scalar::utf16::to_well_formed_utf16<endianness::LITTLE>(input, len,
  102|    760|                                                                 output);
  103|    760|}
_ZNK7simdutf8fallback14implementation22to_well_formed_utf16beEPKDsmPDs:
  106|    760|                                            char16_t *output) const noexcept {
  107|    760|  return scalar::utf16::to_well_formed_utf16<endianness::BIG>(input, len,
  108|    760|                                                              output);
  109|    760|}
_ZNK7simdutf8fallback14implementation14validate_utf32EPKDim:
  114|  1.15k|implementation::validate_utf32(const char32_t *buf, size_t len) const noexcept {
  115|  1.15k|  return scalar::utf32::validate(buf, len);
  116|  1.15k|}
_ZNK7simdutf8fallback14implementation23change_endianness_utf16EPKDsmPDs:
  414|    129|                                             char16_t *output) const noexcept {
  415|    129|  scalar::utf16::change_endianness_utf16(input, length, output);
  416|    129|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split9utf8_headIcEEmPKT_m:
   21|    901|simdutf_really_inline size_t utf8_head(const T *p, size_t len) {
   22|    901|  size_t h = head(p, len);
   23|    901|  if (h != 0) {
  ------------------
  |  Branch (23:7): [True: 196, False: 705]
  ------------------
   24|    243|    for (int i = 0; i < 3 && h < len && (uint8_t(p[h]) & 0xC0) == 0x80; i++) {
  ------------------
  |  Branch (24:21): [True: 234, False: 9]
  |  Branch (24:30): [True: 234, False: 0]
  |  Branch (24:41): [True: 47, False: 187]
  ------------------
   25|     47|      h++;
   26|     47|    }
   27|    196|  }
   28|    901|  return h;
   29|    901|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split3allITnDaXadL_ZNS0_21validate_utf8_unsplitEPKcmEEcEEbPKT0_mm:
   57|    901|simdutf_really_inline bool all(const T *p, size_t len, size_t h) {
   58|    901|  if (h != 0 && !out_of_line<F>(p, h)) {
  ------------------
  |  Branch (58:7): [True: 196, False: 705]
  |  Branch (58:17): [True: 154, False: 42]
  ------------------
   59|    154|    return false;
   60|    154|  }
   61|    747|  return F(p + h, len - h);
   62|    901|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_21validate_utf8_unsplitEPKcmEEJS5_mEEEDaDpT0_:
   46|    196|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    196|  return F(args...);
   48|    196|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split4headIcEEmPKT_m:
    8|  1.37k|simdutf_really_inline size_t head(const T *p, size_t len) {
    9|  1.37k|  if (len * sizeof(T) < min_bytes) {
  ------------------
  |  Branch (9:7): [True: 1.13k, False: 245]
  ------------------
   10|  1.13k|    return 0;
   11|  1.13k|  }
   12|    245|  const size_t misalignment = reinterpret_cast<uintptr_t>(p) % 64;
   13|    245|  if (misalignment == 0 || misalignment % sizeof(T) != 0) {
  ------------------
  |  Branch (13:7): [True: 0, False: 245]
  |  Branch (13:28): [True: 0, False: 245]
  ------------------
   14|      0|    return 0;
   15|      0|  }
   16|    245|  return (64 - misalignment) / sizeof(T);
   17|    245|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split3allITnDaXadL_ZNS0_22validate_ascii_unsplitEPKcmEEcEEbPKT0_mm:
   57|    192|simdutf_really_inline bool all(const T *p, size_t len, size_t h) {
   58|    192|  if (h != 0 && !out_of_line<F>(p, h)) {
  ------------------
  |  Branch (58:7): [True: 20, False: 172]
  |  Branch (58:17): [True: 5, False: 15]
  ------------------
   59|      5|    return false;
   60|      5|  }
   61|    187|  return F(p + h, len - h);
   62|    192|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_22validate_ascii_unsplitEPKcmEEJS5_mEEEDaDpT0_:
   46|     20|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|     20|  return F(args...);
   48|     20|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11first_errorITnDaXadL_ZNS0_34validate_ascii_with_errors_unsplitEPKcmEEcEENS_6resultEPKT0_mm:
   65|    286|simdutf_really_inline result first_error(const T *p, size_t len, size_t h) {
   66|    286|  if (h != 0) {
  ------------------
  |  Branch (66:7): [True: 29, False: 257]
  ------------------
   67|     29|    const result first = out_of_line<F>(p, h);
   68|     29|    if (first.error != error_code::SUCCESS) {
  ------------------
  |  Branch (68:9): [True: 5, False: 24]
  ------------------
   69|      5|      return first;
   70|      5|    }
   71|     29|  }
   72|    281|  result r = F(p + h, len - h);
   73|    281|  r.count += h;
   74|    281|  return r;
   75|    286|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_34validate_ascii_with_errors_unsplitEPKcmEEJS5_mEEEDaDpT0_:
   46|     29|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|     29|  return F(args...);
   48|     29|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split4headIDsEEmPKT_m:
    8|  5.75k|simdutf_really_inline size_t head(const T *p, size_t len) {
    9|  5.75k|  if (len * sizeof(T) < min_bytes) {
  ------------------
  |  Branch (9:7): [True: 4.53k, False: 1.21k]
  ------------------
   10|  4.53k|    return 0;
   11|  4.53k|  }
   12|  1.21k|  const size_t misalignment = reinterpret_cast<uintptr_t>(p) % 64;
   13|  1.21k|  if (misalignment == 0 || misalignment % sizeof(T) != 0) {
  ------------------
  |  Branch (13:7): [True: 0, False: 1.21k]
  |  Branch (13:28): [True: 0, False: 1.21k]
  ------------------
   14|      0|    return 0;
   15|      0|  }
   16|  1.21k|  return (64 - misalignment) / sizeof(T);
   17|  1.21k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split3allITnDaXadL_ZNS0_33validate_utf16le_as_ascii_unsplitEPKDsmEEDsEEbPKT0_mm:
   57|    244|simdutf_really_inline bool all(const T *p, size_t len, size_t h) {
   58|    244|  if (h != 0 && !out_of_line<F>(p, h)) {
  ------------------
  |  Branch (58:7): [True: 42, False: 202]
  |  Branch (58:17): [True: 28, False: 14]
  ------------------
   59|     28|    return false;
   60|     28|  }
   61|    216|  return F(p + h, len - h);
   62|    244|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_33validate_utf16le_as_ascii_unsplitEPKDsmEEJS5_mEEEDaDpT0_:
   46|     42|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|     42|  return F(args...);
   48|     42|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split3allITnDaXadL_ZNS0_33validate_utf16be_as_ascii_unsplitEPKDsmEEDsEEbPKT0_mm:
   57|    244|simdutf_really_inline bool all(const T *p, size_t len, size_t h) {
   58|    244|  if (h != 0 && !out_of_line<F>(p, h)) {
  ------------------
  |  Branch (58:7): [True: 42, False: 202]
  |  Branch (58:17): [True: 25, False: 17]
  ------------------
   59|     25|    return false;
   60|     25|  }
   61|    219|  return F(p + h, len - h);
   62|    244|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_33validate_utf16be_as_ascii_unsplitEPKDsmEEJS5_mEEEDaDpT0_:
   46|     42|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|     42|  return F(args...);
   48|     42|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split10utf16_headILNS_10endiannessE0EEEmPKDsm:
   34|  2.96k|simdutf_really_inline size_t utf16_head(const char16_t *p, size_t len) {
   35|  2.96k|  size_t h = head(p, len);
   36|  2.96k|  if (h != 0 && h < len &&
  ------------------
  |  Branch (36:7): [True: 653, False: 2.31k]
  |  Branch (36:17): [True: 653, False: 0]
  ------------------
   37|    653|      scalar::utf16::is_high_surrogate<big_endian>(p[h - 1]) &&
  ------------------
  |  Branch (37:7): [True: 109, False: 544]
  ------------------
   38|    109|      scalar::utf16::is_low_surrogate<big_endian>(p[h])) {
  ------------------
  |  Branch (38:7): [True: 29, False: 80]
  ------------------
   39|     29|    h++;
   40|     29|  }
   41|  2.96k|  return h;
   42|  2.96k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split3allITnDaXadL_ZNS0_24validate_utf16le_unsplitEPKDsmEEDsEEbPKT0_mm:
   57|  2.20k|simdutf_really_inline bool all(const T *p, size_t len, size_t h) {
   58|  2.20k|  if (h != 0 && !out_of_line<F>(p, h)) {
  ------------------
  |  Branch (58:7): [True: 493, False: 1.71k]
  |  Branch (58:17): [True: 217, False: 276]
  ------------------
   59|    217|    return false;
   60|    217|  }
   61|  1.98k|  return F(p + h, len - h);
   62|  2.20k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_24validate_utf16le_unsplitEPKDsmEEJS5_mEEEDaDpT0_:
   46|    493|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    493|  return F(args...);
   48|    493|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split10utf16_headILNS_10endiannessE1EEEmPKDsm:
   34|  2.30k|simdutf_really_inline size_t utf16_head(const char16_t *p, size_t len) {
   35|  2.30k|  size_t h = head(p, len);
   36|  2.30k|  if (h != 0 && h < len &&
  ------------------
  |  Branch (36:7): [True: 481, False: 1.81k]
  |  Branch (36:17): [True: 481, False: 0]
  ------------------
   37|    481|      scalar::utf16::is_high_surrogate<big_endian>(p[h - 1]) &&
  ------------------
  |  Branch (37:7): [True: 104, False: 377]
  ------------------
   38|    104|      scalar::utf16::is_low_surrogate<big_endian>(p[h])) {
  ------------------
  |  Branch (38:7): [True: 30, False: 74]
  ------------------
   39|     30|    h++;
   40|     30|  }
   41|  2.30k|  return h;
   42|  2.30k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split3allITnDaXadL_ZNS0_24validate_utf16be_unsplitEPKDsmEEDsEEbPKT0_mm:
   57|  1.54k|simdutf_really_inline bool all(const T *p, size_t len, size_t h) {
   58|  1.54k|  if (h != 0 && !out_of_line<F>(p, h)) {
  ------------------
  |  Branch (58:7): [True: 321, False: 1.21k]
  |  Branch (58:17): [True: 117, False: 204]
  ------------------
   59|    117|    return false;
   60|    117|  }
   61|  1.42k|  return F(p + h, len - h);
   62|  1.54k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_24validate_utf16be_unsplitEPKDsmEEJS5_mEEEDaDpT0_:
   46|    321|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    321|  return F(args...);
   48|    321|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split9transformITnDaXadL_ZNS0_30to_well_formed_utf16le_unsplitEPKDsmPDsEEEEvS5_mS6_m:
  114|    760|                                     char16_t *out, size_t h) {
  115|    760|  if (h != 0) {
  ------------------
  |  Branch (115:7): [True: 160, False: 600]
  ------------------
  116|    160|    out_of_line<F>(in, h, out);
  117|    160|  }
  118|    760|  F(in + h, len - h, out + h);
  119|    760|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_30to_well_formed_utf16le_unsplitEPKDsmPDsEEJS5_mS6_EEEDaDpT0_:
   46|    160|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    160|  return F(args...);
   48|    160|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split9transformITnDaXadL_ZNS0_30to_well_formed_utf16be_unsplitEPKDsmPDsEEEEvS5_mS6_m:
  114|    760|                                     char16_t *out, size_t h) {
  115|    760|  if (h != 0) {
  ------------------
  |  Branch (115:7): [True: 160, False: 600]
  ------------------
  116|    160|    out_of_line<F>(in, h, out);
  117|    160|  }
  118|    760|  F(in + h, len - h, out + h);
  119|    760|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_30to_well_formed_utf16be_unsplitEPKDsmPDsEEJS5_mS6_EEEDaDpT0_:
   46|    160|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    160|  return F(args...);
   48|    160|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split4headIDiEEmPKT_m:
    8|    459|simdutf_really_inline size_t head(const T *p, size_t len) {
    9|    459|  if (len * sizeof(T) < min_bytes) {
  ------------------
  |  Branch (9:7): [True: 329, False: 130]
  ------------------
   10|    329|    return 0;
   11|    329|  }
   12|    130|  const size_t misalignment = reinterpret_cast<uintptr_t>(p) % 64;
   13|    130|  if (misalignment == 0 || misalignment % sizeof(T) != 0) {
  ------------------
  |  Branch (13:7): [True: 0, False: 130]
  |  Branch (13:28): [True: 0, False: 130]
  ------------------
   14|      0|    return 0;
   15|      0|  }
   16|    130|  return (64 - misalignment) / sizeof(T);
   17|    130|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split3allITnDaXadL_ZNS0_22validate_utf32_unsplitEPKDimEEDiEEbPKT0_mm:
   57|    459|simdutf_really_inline bool all(const T *p, size_t len, size_t h) {
   58|    459|  if (h != 0 && !out_of_line<F>(p, h)) {
  ------------------
  |  Branch (58:7): [True: 130, False: 329]
  |  Branch (58:17): [True: 100, False: 30]
  ------------------
   59|    100|    return false;
   60|    100|  }
   61|    359|  return F(p + h, len - h);
   62|    459|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_22validate_utf32_unsplitEPKDimEEJS5_mEEEDaDpT0_:
   46|    130|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    130|  return F(args...);
   48|    130|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split9utf8_headIcEEmPKT_m:
   21|    901|simdutf_really_inline size_t utf8_head(const T *p, size_t len) {
   22|    901|  size_t h = head(p, len);
   23|    901|  if (h != 0) {
  ------------------
  |  Branch (23:7): [True: 196, False: 705]
  ------------------
   24|    243|    for (int i = 0; i < 3 && h < len && (uint8_t(p[h]) & 0xC0) == 0x80; i++) {
  ------------------
  |  Branch (24:21): [True: 234, False: 9]
  |  Branch (24:30): [True: 234, False: 0]
  |  Branch (24:41): [True: 47, False: 187]
  ------------------
   25|     47|      h++;
   26|     47|    }
   27|    196|  }
   28|    901|  return h;
   29|    901|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split3allITnDaXadL_ZNS0_21validate_utf8_unsplitEPKcmEEcEEbPKT0_mm:
   57|    901|simdutf_really_inline bool all(const T *p, size_t len, size_t h) {
   58|    901|  if (h != 0 && !out_of_line<F>(p, h)) {
  ------------------
  |  Branch (58:7): [True: 196, False: 705]
  |  Branch (58:17): [True: 154, False: 42]
  ------------------
   59|    154|    return false;
   60|    154|  }
   61|    747|  return F(p + h, len - h);
   62|    901|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_21validate_utf8_unsplitEPKcmEEJS5_mEEEDaDpT0_:
   46|    196|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    196|  return F(args...);
   48|    196|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split4headIcEEmPKT_m:
    8|  1.37k|simdutf_really_inline size_t head(const T *p, size_t len) {
    9|  1.37k|  if (len * sizeof(T) < min_bytes) {
  ------------------
  |  Branch (9:7): [True: 1.13k, False: 245]
  ------------------
   10|  1.13k|    return 0;
   11|  1.13k|  }
   12|    245|  const size_t misalignment = reinterpret_cast<uintptr_t>(p) % 64;
   13|    245|  if (misalignment == 0 || misalignment % sizeof(T) != 0) {
  ------------------
  |  Branch (13:7): [True: 0, False: 245]
  |  Branch (13:28): [True: 0, False: 245]
  ------------------
   14|      0|    return 0;
   15|      0|  }
   16|    245|  return (64 - misalignment) / sizeof(T);
   17|    245|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split3allITnDaXadL_ZNS0_22validate_ascii_unsplitEPKcmEEcEEbPKT0_mm:
   57|    192|simdutf_really_inline bool all(const T *p, size_t len, size_t h) {
   58|    192|  if (h != 0 && !out_of_line<F>(p, h)) {
  ------------------
  |  Branch (58:7): [True: 20, False: 172]
  |  Branch (58:17): [True: 5, False: 15]
  ------------------
   59|      5|    return false;
   60|      5|  }
   61|    187|  return F(p + h, len - h);
   62|    192|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_22validate_ascii_unsplitEPKcmEEJS5_mEEEDaDpT0_:
   46|     20|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|     20|  return F(args...);
   48|     20|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split11first_errorITnDaXadL_ZNS0_34validate_ascii_with_errors_unsplitEPKcmEEcEENS_6resultEPKT0_mm:
   65|    286|simdutf_really_inline result first_error(const T *p, size_t len, size_t h) {
   66|    286|  if (h != 0) {
  ------------------
  |  Branch (66:7): [True: 29, False: 257]
  ------------------
   67|     29|    const result first = out_of_line<F>(p, h);
   68|     29|    if (first.error != error_code::SUCCESS) {
  ------------------
  |  Branch (68:9): [True: 5, False: 24]
  ------------------
   69|      5|      return first;
   70|      5|    }
   71|     29|  }
   72|    281|  result r = F(p + h, len - h);
   73|    281|  r.count += h;
   74|    281|  return r;
   75|    286|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_34validate_ascii_with_errors_unsplitEPKcmEEJS5_mEEEDaDpT0_:
   46|     29|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|     29|  return F(args...);
   48|     29|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split10utf16_headILNS_10endiannessE0EEEmPKDsm:
   34|  1.44k|simdutf_really_inline size_t utf16_head(const char16_t *p, size_t len) {
   35|  1.44k|  size_t h = head(p, len);
   36|  1.44k|  if (h != 0 && h < len &&
  ------------------
  |  Branch (36:7): [True: 321, False: 1.12k]
  |  Branch (36:17): [True: 321, False: 0]
  ------------------
   37|    321|      scalar::utf16::is_high_surrogate<big_endian>(p[h - 1]) &&
  ------------------
  |  Branch (37:7): [True: 37, False: 284]
  ------------------
   38|     37|      scalar::utf16::is_low_surrogate<big_endian>(p[h])) {
  ------------------
  |  Branch (38:7): [True: 15, False: 22]
  ------------------
   39|     15|    h++;
   40|     15|  }
   41|  1.44k|  return h;
   42|  1.44k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split4headIDsEEmPKT_m:
    8|  2.22k|simdutf_really_inline size_t head(const T *p, size_t len) {
    9|  2.22k|  if (len * sizeof(T) < min_bytes) {
  ------------------
  |  Branch (9:7): [True: 1.73k, False: 494]
  ------------------
   10|  1.73k|    return 0;
   11|  1.73k|  }
   12|    494|  const size_t misalignment = reinterpret_cast<uintptr_t>(p) % 64;
   13|    494|  if (misalignment == 0 || misalignment % sizeof(T) != 0) {
  ------------------
  |  Branch (13:7): [True: 24, False: 470]
  |  Branch (13:28): [True: 0, False: 470]
  ------------------
   14|     24|    return 0;
   15|     24|  }
   16|    470|  return (64 - misalignment) / sizeof(T);
   17|    494|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split3allITnDaXadL_ZNS0_24validate_utf16le_unsplitEPKDsmEEDsEEbPKT0_mm:
   57|  1.44k|simdutf_really_inline bool all(const T *p, size_t len, size_t h) {
   58|  1.44k|  if (h != 0 && !out_of_line<F>(p, h)) {
  ------------------
  |  Branch (58:7): [True: 321, False: 1.12k]
  |  Branch (58:17): [True: 94, False: 227]
  ------------------
   59|     94|    return false;
   60|     94|  }
   61|  1.35k|  return F(p + h, len - h);
   62|  1.44k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_24validate_utf16le_unsplitEPKDsmEEJS5_mEEEDaDpT0_:
   46|    321|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    321|  return F(args...);
   48|    321|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split10utf16_headILNS_10endiannessE1EEEmPKDsm:
   34|    780|simdutf_really_inline size_t utf16_head(const char16_t *p, size_t len) {
   35|    780|  size_t h = head(p, len);
   36|    780|  if (h != 0 && h < len &&
  ------------------
  |  Branch (36:7): [True: 149, False: 631]
  |  Branch (36:17): [True: 149, False: 0]
  ------------------
   37|    149|      scalar::utf16::is_high_surrogate<big_endian>(p[h - 1]) &&
  ------------------
  |  Branch (37:7): [True: 5, False: 144]
  ------------------
   38|      5|      scalar::utf16::is_low_surrogate<big_endian>(p[h])) {
  ------------------
  |  Branch (38:7): [True: 5, False: 0]
  ------------------
   39|      5|    h++;
   40|      5|  }
   41|    780|  return h;
   42|    780|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split3allITnDaXadL_ZNS0_24validate_utf16be_unsplitEPKDsmEEDsEEbPKT0_mm:
   57|    780|simdutf_really_inline bool all(const T *p, size_t len, size_t h) {
   58|    780|  if (h != 0 && !out_of_line<F>(p, h)) {
  ------------------
  |  Branch (58:7): [True: 149, False: 631]
  |  Branch (58:17): [True: 0, False: 149]
  ------------------
   59|      0|    return false;
   60|      0|  }
   61|    780|  return F(p + h, len - h);
   62|    780|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_24validate_utf16be_unsplitEPKDsmEEJS5_mEEEDaDpT0_:
   46|    149|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    149|  return F(args...);
   48|    149|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_116ascii_validation22generic_validate_asciiEPKcm:
   76|    207|bool generic_validate_ascii(const char *input, size_t length) {
   77|    207|  buf_block_reader<64> reader(reinterpret_cast<const uint8_t *>(input), length);
   78|  68.4k|  while (reader.has_full_block()) {
  ------------------
  |  Branch (78:10): [True: 68.2k, False: 143]
  ------------------
   79|  68.2k|    simd::simd8x64<uint8_t> in(reader.full_block());
   80|  68.2k|    if (!in.is_ascii()) {
  ------------------
  |  Branch (80:9): [True: 64, False: 68.1k]
  ------------------
   81|     64|      return false;
   82|     64|    }
   83|  68.1k|    reader.advance();
   84|  68.1k|  }
   85|    143|  return remainder_is_ascii(reinterpret_cast<const uint8_t *>(input), length,
   86|    143|                            reader.block_index());
   87|    207|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_116ascii_validation18remainder_is_asciiEPKhmm:
   43|    331|                                              size_t idx) {
   44|    331|  constexpr size_t block = sizeof(simd::simd8x64<uint8_t>);
   45|    331|  if (len >= block) {
  ------------------
  |  Branch (45:7): [True: 166, False: 165]
  ------------------
   46|    166|    return simd::simd8x64<uint8_t>(buf + len - block).is_ascii();
   47|    166|  }
   48|    165|  return tail_is_ascii(buf + idx, len - idx);
   49|    331|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_116ascii_validation13tail_is_asciiEPKhm:
   15|    165|simdutf_really_inline bool tail_is_ascii(const uint8_t *p, size_t n) {
   16|    165|  uint64_t acc = 0;
   17|    165|  if (n >= 16) {
  ------------------
  |  Branch (17:7): [True: 94, False: 71]
  ------------------
   18|    280|    for (size_t i = 0; i + 16 < n; i += 16) {
  ------------------
  |  Branch (18:24): [True: 186, False: 94]
  ------------------
   19|    186|      acc |=
   20|    186|          load_bytes_as<uint64_t>(p + i) | load_bytes_as<uint64_t>(p + i + 8);
   21|    186|    }
   22|     94|    acc |= load_bytes_as<uint64_t>(p + n - 16) |
   23|     94|           load_bytes_as<uint64_t>(p + n - 8);
   24|     94|  } else if (n >= 8) {
  ------------------
  |  Branch (24:14): [True: 27, False: 44]
  ------------------
   25|     27|    acc = load_bytes_as<uint64_t>(p) | load_bytes_as<uint64_t>(p + n - 8);
   26|     44|  } else if (n >= 4) {
  ------------------
  |  Branch (26:14): [True: 14, False: 30]
  ------------------
   27|     14|    acc = load_bytes_as<uint32_t>(p) | load_bytes_as<uint32_t>(p + n - 4);
   28|     30|  } else {
   29|     68|    for (size_t i = 0; i < n; i++) {
  ------------------
  |  Branch (29:24): [True: 38, False: 30]
  ------------------
   30|     38|      acc |= p[i];
   31|     38|    }
   32|     30|  }
   33|    165|  return (acc & 0x8080808080808080) == 0;
   34|    165|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_116ascii_validation13load_bytes_asImEET_PKh:
    6|    614|template <typename T> simdutf_really_inline T load_bytes_as(const uint8_t *p) {
    7|    614|  T v;
    8|    614|  std::memcpy(&v, p, sizeof(T));
    9|    614|  return v;
   10|    614|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_116ascii_validation13load_bytes_asIjEET_PKh:
    6|     28|template <typename T> simdutf_really_inline T load_bytes_as(const uint8_t *p) {
    7|     28|  T v;
    8|     28|  std::memcpy(&v, p, sizeof(T));
    9|     28|  return v;
   10|     28|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_116ascii_validation34generic_validate_ascii_with_errorsEPKcm:
   51|    310|result generic_validate_ascii_with_errors(const char *input, size_t length) {
   52|    310|  buf_block_reader<64> reader(reinterpret_cast<const uint8_t *>(input), length);
   53|    310|  size_t count{0};
   54|  79.7k|  while (reader.has_full_block()) {
  ------------------
  |  Branch (54:10): [True: 79.5k, False: 188]
  ------------------
   55|  79.5k|    simd::simd8x64<uint8_t> in(reader.full_block());
   56|  79.5k|    if (!in.is_ascii()) {
  ------------------
  |  Branch (56:9): [True: 122, False: 79.3k]
  ------------------
   57|    122|      SIMDUTF_VZEROUPPER();
  ------------------
  |  |   22|    122|#define SIMDUTF_VZEROUPPER() _mm256_zeroupper()
  ------------------
   58|    122|      result res = scalar::ascii::validate_with_errors(
   59|    122|          reinterpret_cast<const char *>(input + count), length - count);
   60|    122|      return result(res.error, count + res.count);
   61|    122|    }
   62|  79.3k|    reader.advance();
   63|       |
   64|  79.3k|    count += 64;
   65|  79.3k|  }
   66|    188|  if (remainder_is_ascii(reinterpret_cast<const uint8_t *>(input), length,
  ------------------
  |  Branch (66:7): [True: 60, False: 128]
  ------------------
   67|    188|                         reader.block_index())) {
   68|     60|    return result(error_code::SUCCESS, length);
   69|     60|  }
   70|    128|  SIMDUTF_VZEROUPPER();
  ------------------
  |  |   22|    128|#define SIMDUTF_VZEROUPPER() _mm256_zeroupper()
  ------------------
   71|    128|  result res = scalar::ascii::validate_with_errors(
   72|    128|      reinterpret_cast<const char *>(input + count), length - count);
   73|    128|  return result(res.error, count + res.count);
   74|    188|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_116ascii_validation22generic_validate_asciiEPKcm:
   76|    207|bool generic_validate_ascii(const char *input, size_t length) {
   77|    207|  buf_block_reader<64> reader(reinterpret_cast<const uint8_t *>(input), length);
   78|  68.4k|  while (reader.has_full_block()) {
  ------------------
  |  Branch (78:10): [True: 68.2k, False: 143]
  ------------------
   79|  68.2k|    simd::simd8x64<uint8_t> in(reader.full_block());
   80|  68.2k|    if (!in.is_ascii()) {
  ------------------
  |  Branch (80:9): [True: 64, False: 68.1k]
  ------------------
   81|     64|      return false;
   82|     64|    }
   83|  68.1k|    reader.advance();
   84|  68.1k|  }
   85|    143|  return remainder_is_ascii(reinterpret_cast<const uint8_t *>(input), length,
   86|    143|                            reader.block_index());
   87|    207|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_116ascii_validation18remainder_is_asciiEPKhmm:
   43|    331|                                              size_t idx) {
   44|    331|  constexpr size_t block = sizeof(simd::simd8x64<uint8_t>);
   45|    331|  if (len >= block) {
  ------------------
  |  Branch (45:7): [True: 166, False: 165]
  ------------------
   46|    166|    return simd::simd8x64<uint8_t>(buf + len - block).is_ascii();
   47|    166|  }
   48|    165|  return tail_is_ascii(buf + idx, len - idx);
   49|    331|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_116ascii_validation13tail_is_asciiEPKhm:
   15|    165|simdutf_really_inline bool tail_is_ascii(const uint8_t *p, size_t n) {
   16|    165|  uint64_t acc = 0;
   17|    165|  if (n >= 16) {
  ------------------
  |  Branch (17:7): [True: 94, False: 71]
  ------------------
   18|    280|    for (size_t i = 0; i + 16 < n; i += 16) {
  ------------------
  |  Branch (18:24): [True: 186, False: 94]
  ------------------
   19|    186|      acc |=
   20|    186|          load_bytes_as<uint64_t>(p + i) | load_bytes_as<uint64_t>(p + i + 8);
   21|    186|    }
   22|     94|    acc |= load_bytes_as<uint64_t>(p + n - 16) |
   23|     94|           load_bytes_as<uint64_t>(p + n - 8);
   24|     94|  } else if (n >= 8) {
  ------------------
  |  Branch (24:14): [True: 27, False: 44]
  ------------------
   25|     27|    acc = load_bytes_as<uint64_t>(p) | load_bytes_as<uint64_t>(p + n - 8);
   26|     44|  } else if (n >= 4) {
  ------------------
  |  Branch (26:14): [True: 14, False: 30]
  ------------------
   27|     14|    acc = load_bytes_as<uint32_t>(p) | load_bytes_as<uint32_t>(p + n - 4);
   28|     30|  } else {
   29|     68|    for (size_t i = 0; i < n; i++) {
  ------------------
  |  Branch (29:24): [True: 38, False: 30]
  ------------------
   30|     38|      acc |= p[i];
   31|     38|    }
   32|     30|  }
   33|    165|  return (acc & 0x8080808080808080) == 0;
   34|    165|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_116ascii_validation13load_bytes_asImEET_PKh:
    6|    614|template <typename T> simdutf_really_inline T load_bytes_as(const uint8_t *p) {
    7|    614|  T v;
    8|    614|  std::memcpy(&v, p, sizeof(T));
    9|    614|  return v;
   10|    614|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_116ascii_validation13load_bytes_asIjEET_PKh:
    6|     28|template <typename T> simdutf_really_inline T load_bytes_as(const uint8_t *p) {
    7|     28|  T v;
    8|     28|  std::memcpy(&v, p, sizeof(T));
    9|     28|  return v;
   10|     28|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_116ascii_validation34generic_validate_ascii_with_errorsEPKcm:
   51|    310|result generic_validate_ascii_with_errors(const char *input, size_t length) {
   52|    310|  buf_block_reader<64> reader(reinterpret_cast<const uint8_t *>(input), length);
   53|    310|  size_t count{0};
   54|  79.7k|  while (reader.has_full_block()) {
  ------------------
  |  Branch (54:10): [True: 79.5k, False: 188]
  ------------------
   55|  79.5k|    simd::simd8x64<uint8_t> in(reader.full_block());
   56|  79.5k|    if (!in.is_ascii()) {
  ------------------
  |  Branch (56:9): [True: 122, False: 79.3k]
  ------------------
   57|    122|      SIMDUTF_VZEROUPPER();
  ------------------
  |  |   16|    122|#define SIMDUTF_VZEROUPPER() (void)0
  ------------------
   58|    122|      result res = scalar::ascii::validate_with_errors(
   59|    122|          reinterpret_cast<const char *>(input + count), length - count);
   60|    122|      return result(res.error, count + res.count);
   61|    122|    }
   62|  79.3k|    reader.advance();
   63|       |
   64|  79.3k|    count += 64;
   65|  79.3k|  }
   66|    188|  if (remainder_is_ascii(reinterpret_cast<const uint8_t *>(input), length,
  ------------------
  |  Branch (66:7): [True: 60, False: 128]
  ------------------
   67|    188|                         reader.block_index())) {
   68|     60|    return result(error_code::SUCCESS, length);
   69|     60|  }
   70|    128|  SIMDUTF_VZEROUPPER();
  ------------------
  |  |   16|    128|#define SIMDUTF_VZEROUPPER() (void)0
  ------------------
   71|    128|  result res = scalar::ascii::validate_with_errors(
   72|    128|      reinterpret_cast<const char *>(input + count), length - count);
   73|    128|  return result(res.error, count + res.count);
   74|    188|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_116buf_block_readerILm64EEC2EPKhm:
   36|  1.65k|    : buf{_buf}, len{_len}, lenminusstep{len < STEP_SIZE ? 0 : len - STEP_SIZE},
  ------------------
  |  Branch (36:42): [True: 801, False: 850]
  ------------------
   37|  1.65k|      idx{0} {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_116buf_block_readerILm64EE14has_full_blockEv:
   45|   369k|simdutf_really_inline bool buf_block_reader<STEP_SIZE>::has_full_block() const {
   46|   369k|  return idx < lenminusstep;
   47|   369k|}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_116buf_block_readerILm64EE10full_blockEv:
   51|   368k|buf_block_reader<STEP_SIZE>::full_block() const {
   52|   368k|  return &buf[idx];
   53|   368k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_116buf_block_readerILm64EE11block_indexEv:
   40|  84.5k|simdutf_really_inline size_t buf_block_reader<STEP_SIZE>::block_index() {
   41|  84.5k|  return idx;
   42|  84.5k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_116buf_block_readerILm64EE7advanceEv:
   69|   367k|simdutf_really_inline void buf_block_reader<STEP_SIZE>::advance() {
   70|   367k|  idx += STEP_SIZE;
   71|   367k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_116buf_block_readerILm64EEC2EPKhm:
   36|  1.65k|    : buf{_buf}, len{_len}, lenminusstep{len < STEP_SIZE ? 0 : len - STEP_SIZE},
  ------------------
  |  Branch (36:42): [True: 801, False: 850]
  ------------------
   37|  1.65k|      idx{0} {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_116buf_block_readerILm64EE14has_full_blockEv:
   45|   369k|simdutf_really_inline bool buf_block_reader<STEP_SIZE>::has_full_block() const {
   46|   369k|  return idx < lenminusstep;
   47|   369k|}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_116buf_block_readerILm64EE10full_blockEv:
   51|   368k|buf_block_reader<STEP_SIZE>::full_block() const {
   52|   368k|  return &buf[idx];
   53|   368k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_116buf_block_readerILm64EE11block_indexEv:
   40|  84.5k|simdutf_really_inline size_t buf_block_reader<STEP_SIZE>::block_index() {
   41|  84.5k|  return idx;
   42|  84.5k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_116buf_block_readerILm64EE7advanceEv:
   69|   367k|simdutf_really_inline void buf_block_reader<STEP_SIZE>::advance() {
   70|   367k|  idx += STEP_SIZE;
   71|   367k|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_118encoding_detection16detect_encodingsEPKcm:
   93|  1.26k|int detect_encodings(const char *input, size_t length) {
   94|  1.26k|  if (length % 2 == 1 && length < 1024) {
  ------------------
  |  Branch (94:7): [True: 239, False: 1.02k]
  |  Branch (94:26): [True: 126, False: 113]
  ------------------
   95|       |    // Only UTF-8 is possible, and the input is too short for stopping early
   96|       |    // to pay off.
   97|    126|    return utf8_validation::generic_validate_utf8(input, length)
  ------------------
  |  Branch (97:12): [True: 24, False: 102]
  ------------------
   98|    126|               ? encoding_type::UTF8
   99|    126|               : 0;
  100|    126|  }
  101|       |  // We check UTF-8, UTF-16LE and UTF-32LE in a single pass over the input.
  102|       |  // An encoding that has failed is no longer checked, and we stop as soon as
  103|       |  // all of them have failed.
  104|  1.13k|  int active = encoding_type::UTF8;
  105|  1.13k|  if (length % 2 == 0) {
  ------------------
  |  Branch (105:7): [True: 1.02k, False: 113]
  ------------------
  106|  1.02k|    active |= encoding_type::UTF16_LE;
  107|  1.02k|  }
  108|  1.13k|  if (length % 4 == 0) {
  ------------------
  |  Branch (108:7): [True: 698, False: 441]
  ------------------
  109|    698|    active |= encoding_type::UTF32_LE;
  110|    698|  }
  111|  1.13k|  constexpr int utf8 = encoding_type::UTF8;
  112|  1.13k|  constexpr int utf16 = encoding_type::UTF16_LE;
  113|  1.13k|  constexpr int utf32 = encoding_type::UTF32_LE;
  114|       |
  115|  1.13k|  checkers c{};
  116|  1.13k|  const uint8_t *buf = reinterpret_cast<const uint8_t *>(input);
  117|       |  // Like buf_block_reader, we leave 1 to 64 bytes for the final block, unless
  118|       |  // the input is empty.
  119|  1.13k|  const size_t end = length < 64 ? 0 : length - 64;
  ------------------
  |  Branch (119:22): [True: 276, False: 863]
  ------------------
  120|  1.13k|  size_t idx = 0;
  121|  2.26k|  while (idx < end) {
  ------------------
  |  Branch (121:10): [True: 1.27k, False: 992]
  ------------------
  122|  1.27k|    switch (active) {
  123|    451|    case utf8 | utf16 | utf32:
  ------------------
  |  Branch (123:5): [True: 451, False: 821]
  ------------------
  124|       |    // Valid UTF-8 that is also valid UTF-32LE is always valid UTF-16LE: a
  125|       |    // high byte 0xD8..0xDF in a UTF-16 code unit would be a UTF-8 lead byte
  126|       |    // followed by a continuation byte, and the UTF-32 value would then exceed
  127|       |    // 0x10FFFF. So we do not specialize for UTF-8 and UTF-32 without UTF-16.
  128|    451|    case utf8 | utf32:
  ------------------
  |  Branch (128:5): [True: 0, False: 1.27k]
  ------------------
  129|    451|      idx = check_blocks<true, true, true>(c, buf, idx, end, active);
  130|    451|      break;
  131|    279|    case utf8 | utf16:
  ------------------
  |  Branch (131:5): [True: 279, False: 993]
  ------------------
  132|    279|      idx = check_blocks<true, true, false>(c, buf, idx, end, active);
  133|    279|      break;
  134|    178|    case utf8:
  ------------------
  |  Branch (134:5): [True: 178, False: 1.09k]
  ------------------
  135|    178|      if (idx != 0) {
  ------------------
  |  Branch (135:11): [True: 65, False: 113]
  ------------------
  136|       |        // Only UTF-8 is left, without an error so far, and validate_utf8 is
  137|       |        // faster than our loop. The bytes before idx are valid UTF-8 except
  138|       |        // that they may end with an incomplete character (or a byte that
  139|       |        // cannot start one): validate_utf8 starts with that character.
  140|     65|        const size_t start = scalar::utf8::trim_partial_utf8(input, idx);
  141|     65|        return utf8_validation::generic_validate_utf8(input + start,
  ------------------
  |  Branch (141:16): [True: 19, False: 46]
  ------------------
  142|     65|                                                      length - start)
  143|     65|                   ? utf8
  144|     65|                   : 0;
  145|     65|      }
  146|       |      // Odd length: we check the first 1024 bytes here, so that we stop early
  147|       |      // if the input is not UTF-8.
  148|    113|      idx = check_blocks<true, false, false>(c, buf, idx,
  149|    113|                                             detail::min(end, stride), active);
  150|    113|      break;
  151|     88|    case utf16 | utf32:
  ------------------
  |  Branch (151:5): [True: 88, False: 1.18k]
  ------------------
  152|     88|      idx = check_blocks<false, true, true>(c, buf, idx, end, active);
  153|     88|      break;
  154|    114|    case utf16:
  ------------------
  |  Branch (154:5): [True: 114, False: 1.15k]
  ------------------
  155|    114|      idx = check_blocks<false, true, false>(c, buf, idx, end, active);
  156|    114|      break;
  157|     80|    case utf32:
  ------------------
  |  Branch (157:5): [True: 80, False: 1.19k]
  ------------------
  158|     80|      idx = check_blocks<false, false, true>(c, buf, idx, end, active);
  159|     80|      break;
  160|     82|    default:
  ------------------
  |  Branch (160:5): [True: 82, False: 1.19k]
  ------------------
  161|       |      // All three encodings have failed.
  162|     82|      return 0;
  163|  1.27k|    }
  164|  1.27k|  }
  165|       |
  166|       |  // The last 1 to 64 bytes.
  167|    992|  if (length < 64) {
  ------------------
  |  Branch (167:7): [True: 276, False: 716]
  ------------------
  168|       |    // Short input: copy it to a block padded with zeros. A zero byte is valid
  169|       |    // in all three encodings, and a high surrogate followed by the padding is
  170|       |    // caught.
  171|    276|    if (length != 0) {
  ------------------
  |  Branch (171:9): [True: 275, False: 1]
  ------------------
  172|    275|      uint8_t block[64]{};
  173|    275|      copy_short(block, buf, length);
  174|    275|      const simd::simd8x64<uint8_t> in(block);
  175|    275|      c.check_block<true, true, true>(in);
  176|    275|    }
  177|    276|    c.utf8.check_eof();
  178|    716|  } else {
  179|       |    // The last 64 bytes. They start at an even index if UTF-16LE is still
  180|       |    // active, and at a multiple of four if UTF-32LE is.
  181|    716|    const size_t start = length - 64;
  182|    716|    const simd::simd8x64<uint8_t> in(buf + start);
  183|    716|    if (idx == start) {
  ------------------
  |  Branch (183:9): [True: 78, False: 638]
  ------------------
  184|       |      // They form a full block that has not been checked.
  185|     78|      if (active & utf8) {
  ------------------
  |  Branch (185:11): [True: 61, False: 17]
  ------------------
  186|     61|        c.utf8.check_next_input(in);
  187|     61|        c.utf8.check_eof();
  188|     61|      }
  189|     78|      if (active & utf16) {
  ------------------
  |  Branch (189:11): [True: 75, False: 3]
  ------------------
  190|     75|        c.utf16.check(in);
  191|     75|      }
  192|    638|    } else {
  193|       |      // They overlap the bytes already checked.
  194|    638|      if (active & utf8) {
  ------------------
  |  Branch (194:11): [True: 210, False: 428]
  ------------------
  195|       |        // Same as validate_utf8, it also calls check_eof().
  196|    210|        utf8_validation::check_remainder(c.utf8, buf, length, idx);
  197|    210|      }
  198|    638|      if (active & utf16) {
  ------------------
  |  Branch (198:11): [True: 324, False: 314]
  ------------------
  199|    324|        c.utf16.check<true>(in);
  200|    324|      }
  201|    638|    }
  202|    716|    if (active & utf32) {
  ------------------
  |  Branch (202:9): [True: 135, False: 581]
  ------------------
  203|       |      // Checking values again does not change the result.
  204|    135|      c.utf32.check(in);
  205|    135|    }
  206|    716|  }
  207|       |
  208|    992|  int out = 0;
  209|    992|  if ((active & utf8) && !c.utf8.errors()) {
  ------------------
  |  Branch (209:7): [True: 547, False: 445]
  |  Branch (209:26): [True: 109, False: 438]
  ------------------
  210|    109|    out |= utf8;
  211|    109|  }
  212|    992|  if ((active & utf16) && !c.utf16.errors_at_eof()) {
  ------------------
  |  Branch (212:7): [True: 675, False: 317]
  |  Branch (212:27): [True: 518, False: 157]
  ------------------
  213|    518|    out |= utf16;
  214|    518|  }
  215|    992|  if ((active & utf32) && !c.utf32.errors()) {
  ------------------
  |  Branch (215:7): [True: 330, False: 662]
  |  Branch (215:27): [True: 116, False: 214]
  ------------------
  216|    116|    out |= utf32;
  217|    116|  }
  218|    992|  return out;
  219|  1.13k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_118encoding_detection12check_blocksILb1ELb1ELb1EEEmRNS2_8checkersEPKhmmRi:
   78|    451|                    int &active) {
   79|  4.80k|  while (true) {
  ------------------
  |  Branch (79:10): [True: 4.80k, Folded]
  ------------------
   80|  4.80k|    const size_t stop = (end - idx > stride) ? idx + stride : end;
  ------------------
  |  Branch (80:25): [True: 4.58k, False: 219]
  ------------------
   81|  78.8k|    for (; idx < stop; idx += 64) {
  ------------------
  |  Branch (81:12): [True: 74.0k, False: 4.80k]
  ------------------
   82|  74.0k|      const simd::simd8x64<uint8_t> in(input + idx);
   83|  74.0k|      c.check_block<check_utf8, check_utf16, check_utf32>(in);
   84|  74.0k|    }
   85|  4.80k|    const int valid = c.still_valid(active);
   86|  4.80k|    if (idx >= end || valid != active) {
  ------------------
  |  Branch (86:9): [True: 219, False: 4.58k]
  |  Branch (86:23): [True: 232, False: 4.35k]
  ------------------
   87|    451|      active = valid;
   88|    451|      return idx;
   89|    451|    }
   90|  4.80k|  }
   91|    451|}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_118encoding_detection8checkers11still_validEi:
   31|  24.1k|  simdutf_really_inline int still_valid(int active) const {
   32|  24.1k|    if ((active & encoding_type::UTF8) && utf8.errors()) {
  ------------------
  |  Branch (32:9): [True: 13.1k, False: 10.9k]
  |  Branch (32:43): [True: 527, False: 12.6k]
  ------------------
   33|    527|      active &= ~encoding_type::UTF8;
   34|    527|    }
   35|  24.1k|    if ((active & encoding_type::UTF16_LE) && utf16.errors()) {
  ------------------
  |  Branch (35:9): [True: 22.6k, False: 1.53k]
  |  Branch (35:47): [True: 351, False: 22.2k]
  ------------------
   36|    351|      active &= ~encoding_type::UTF16_LE;
   37|    351|    }
   38|  24.1k|    if ((active & encoding_type::UTF32_LE) && utf32.errors()) {
  ------------------
  |  Branch (38:9): [True: 8.31k, False: 15.8k]
  |  Branch (38:47): [True: 368, False: 7.94k]
  ------------------
   39|    368|      active &= ~encoding_type::UTF32_LE;
   40|    368|    }
   41|  24.1k|    return active;
   42|  24.1k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_118encoding_detection12check_blocksILb1ELb1ELb0EEEmRNS2_8checkersEPKhmmRi:
   78|    279|                    int &active) {
   79|  8.27k|  while (true) {
  ------------------
  |  Branch (79:10): [True: 8.27k, Folded]
  ------------------
   80|  8.27k|    const size_t stop = (end - idx > stride) ? idx + stride : end;
  ------------------
  |  Branch (80:25): [True: 8.09k, False: 183]
  ------------------
   81|   138k|    for (; idx < stop; idx += 64) {
  ------------------
  |  Branch (81:12): [True: 130k, False: 8.27k]
  ------------------
   82|   130k|      const simd::simd8x64<uint8_t> in(input + idx);
   83|   130k|      c.check_block<check_utf8, check_utf16, check_utf32>(in);
   84|   130k|    }
   85|  8.27k|    const int valid = c.still_valid(active);
   86|  8.27k|    if (idx >= end || valid != active) {
  ------------------
  |  Branch (86:9): [True: 183, False: 8.09k]
  |  Branch (86:23): [True: 96, False: 7.99k]
  ------------------
   87|    279|      active = valid;
   88|    279|      return idx;
   89|    279|    }
   90|  8.27k|  }
   91|    279|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_118encoding_detection8checkers11check_blockILb1ELb1ELb0EEEvRKNS1_4simd8simd8x64IhEE:
   12|   130k|  simdutf_really_inline void check_block(const simd::simd8x64<uint8_t> &in) {
   13|   130k|    if constexpr (check_utf8) {
   14|   130k|      const bool ascii = utf8.check_next_input(in);
   15|   130k|      if constexpr (check_utf16) {
   16|   130k|        if (ascii) {
  ------------------
  |  Branch (16:13): [True: 125k, False: 4.68k]
  ------------------
   17|   125k|          utf16.check_ascii();
   18|   125k|        } else {
   19|  4.68k|          utf16.check(in);
   20|  4.68k|        }
   21|   130k|      }
   22|       |    } else if constexpr (check_utf16) {
   23|       |      utf16.check(in);
   24|       |    }
   25|       |    if constexpr (check_utf32) {
   26|       |      utf32.check(in);
   27|       |    }
   28|   130k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_118encoding_detection12check_blocksILb1ELb0ELb0EEEmRNS2_8checkersEPKhmmRi:
   78|    113|                    int &active) {
   79|    113|  while (true) {
  ------------------
  |  Branch (79:10): [True: 113, Folded]
  ------------------
   80|    113|    const size_t stop = (end - idx > stride) ? idx + stride : end;
  ------------------
  |  Branch (80:25): [True: 0, False: 113]
  ------------------
   81|  1.92k|    for (; idx < stop; idx += 64) {
  ------------------
  |  Branch (81:12): [True: 1.80k, False: 113]
  ------------------
   82|  1.80k|      const simd::simd8x64<uint8_t> in(input + idx);
   83|  1.80k|      c.check_block<check_utf8, check_utf16, check_utf32>(in);
   84|  1.80k|    }
   85|    113|    const int valid = c.still_valid(active);
   86|    113|    if (idx >= end || valid != active) {
  ------------------
  |  Branch (86:9): [True: 113, False: 0]
  |  Branch (86:23): [True: 0, False: 0]
  ------------------
   87|    113|      active = valid;
   88|    113|      return idx;
   89|    113|    }
   90|    113|  }
   91|    113|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_118encoding_detection8checkers11check_blockILb1ELb0ELb0EEEvRKNS1_4simd8simd8x64IhEE:
   12|  1.80k|  simdutf_really_inline void check_block(const simd::simd8x64<uint8_t> &in) {
   13|  1.80k|    if constexpr (check_utf8) {
   14|  1.80k|      const bool ascii = utf8.check_next_input(in);
   15|       |      if constexpr (check_utf16) {
   16|       |        if (ascii) {
   17|       |          utf16.check_ascii();
   18|       |        } else {
   19|       |          utf16.check(in);
   20|       |        }
   21|       |      }
   22|       |    } else if constexpr (check_utf16) {
   23|       |      utf16.check(in);
   24|       |    }
   25|       |    if constexpr (check_utf32) {
   26|       |      utf32.check(in);
   27|       |    }
   28|  1.80k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_118encoding_detection12check_blocksILb0ELb1ELb1EEEmRNS2_8checkersEPKhmmRi:
   78|     88|                    int &active) {
   79|  2.09k|  while (true) {
  ------------------
  |  Branch (79:10): [True: 2.09k, Folded]
  ------------------
   80|  2.09k|    const size_t stop = (end - idx > stride) ? idx + stride : end;
  ------------------
  |  Branch (80:25): [True: 2.02k, False: 67]
  ------------------
   81|  34.8k|    for (; idx < stop; idx += 64) {
  ------------------
  |  Branch (81:12): [True: 32.7k, False: 2.09k]
  ------------------
   82|  32.7k|      const simd::simd8x64<uint8_t> in(input + idx);
   83|  32.7k|      c.check_block<check_utf8, check_utf16, check_utf32>(in);
   84|  32.7k|    }
   85|  2.09k|    const int valid = c.still_valid(active);
   86|  2.09k|    if (idx >= end || valid != active) {
  ------------------
  |  Branch (86:9): [True: 67, False: 2.02k]
  |  Branch (86:23): [True: 21, False: 2.00k]
  ------------------
   87|     88|      active = valid;
   88|     88|      return idx;
   89|     88|    }
   90|  2.09k|  }
   91|     88|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_118encoding_detection8checkers11check_blockILb0ELb1ELb1EEEvRKNS1_4simd8simd8x64IhEE:
   12|  32.7k|  simdutf_really_inline void check_block(const simd::simd8x64<uint8_t> &in) {
   13|       |    if constexpr (check_utf8) {
   14|       |      const bool ascii = utf8.check_next_input(in);
   15|       |      if constexpr (check_utf16) {
   16|       |        if (ascii) {
   17|       |          utf16.check_ascii();
   18|       |        } else {
   19|       |          utf16.check(in);
   20|       |        }
   21|       |      }
   22|  32.7k|    } else if constexpr (check_utf16) {
   23|  32.7k|      utf16.check(in);
   24|  32.7k|    }
   25|  32.7k|    if constexpr (check_utf32) {
   26|  32.7k|      utf32.check(in);
   27|  32.7k|    }
   28|  32.7k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_118encoding_detection12check_blocksILb0ELb1ELb0EEEmRNS2_8checkersEPKhmmRi:
   78|    114|                    int &active) {
   79|  7.43k|  while (true) {
  ------------------
  |  Branch (79:10): [True: 7.43k, Folded]
  ------------------
   80|  7.43k|    const size_t stop = (end - idx > stride) ? idx + stride : end;
  ------------------
  |  Branch (80:25): [True: 7.33k, False: 95]
  ------------------
   81|   125k|    for (; idx < stop; idx += 64) {
  ------------------
  |  Branch (81:12): [True: 118k, False: 7.43k]
  ------------------
   82|   118k|      const simd::simd8x64<uint8_t> in(input + idx);
   83|   118k|      c.check_block<check_utf8, check_utf16, check_utf32>(in);
   84|   118k|    }
   85|  7.43k|    const int valid = c.still_valid(active);
   86|  7.43k|    if (idx >= end || valid != active) {
  ------------------
  |  Branch (86:9): [True: 95, False: 7.33k]
  |  Branch (86:23): [True: 19, False: 7.32k]
  ------------------
   87|    114|      active = valid;
   88|    114|      return idx;
   89|    114|    }
   90|  7.43k|  }
   91|    114|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_118encoding_detection8checkers11check_blockILb0ELb1ELb0EEEvRKNS1_4simd8simd8x64IhEE:
   12|   118k|  simdutf_really_inline void check_block(const simd::simd8x64<uint8_t> &in) {
   13|       |    if constexpr (check_utf8) {
   14|       |      const bool ascii = utf8.check_next_input(in);
   15|       |      if constexpr (check_utf16) {
   16|       |        if (ascii) {
   17|       |          utf16.check_ascii();
   18|       |        } else {
   19|       |          utf16.check(in);
   20|       |        }
   21|       |      }
   22|   118k|    } else if constexpr (check_utf16) {
   23|   118k|      utf16.check(in);
   24|   118k|    }
   25|       |    if constexpr (check_utf32) {
   26|       |      utf32.check(in);
   27|       |    }
   28|   118k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_118encoding_detection12check_blocksILb0ELb0ELb1EEEmRNS2_8checkersEPKhmmRi:
   78|     80|                    int &active) {
   79|  1.41k|  while (true) {
  ------------------
  |  Branch (79:10): [True: 1.41k, Folded]
  ------------------
   80|  1.41k|    const size_t stop = (end - idx > stride) ? idx + stride : end;
  ------------------
  |  Branch (80:25): [True: 1.35k, False: 68]
  ------------------
   81|  23.3k|    for (; idx < stop; idx += 64) {
  ------------------
  |  Branch (81:12): [True: 21.9k, False: 1.41k]
  ------------------
   82|  21.9k|      const simd::simd8x64<uint8_t> in(input + idx);
   83|  21.9k|      c.check_block<check_utf8, check_utf16, check_utf32>(in);
   84|  21.9k|    }
   85|  1.41k|    const int valid = c.still_valid(active);
   86|  1.41k|    if (idx >= end || valid != active) {
  ------------------
  |  Branch (86:9): [True: 68, False: 1.35k]
  |  Branch (86:23): [True: 12, False: 1.33k]
  ------------------
   87|     80|      active = valid;
   88|     80|      return idx;
   89|     80|    }
   90|  1.41k|  }
   91|     80|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_118encoding_detection8checkers11check_blockILb0ELb0ELb1EEEvRKNS1_4simd8simd8x64IhEE:
   12|  21.9k|  simdutf_really_inline void check_block(const simd::simd8x64<uint8_t> &in) {
   13|       |    if constexpr (check_utf8) {
   14|       |      const bool ascii = utf8.check_next_input(in);
   15|       |      if constexpr (check_utf16) {
   16|       |        if (ascii) {
   17|       |          utf16.check_ascii();
   18|       |        } else {
   19|       |          utf16.check(in);
   20|       |        }
   21|       |      }
   22|  21.9k|    } else if constexpr (check_utf16) {
   23|  21.9k|      utf16.check(in);
   24|  21.9k|    }
   25|  21.9k|    if constexpr (check_utf32) {
   26|  21.9k|      utf32.check(in);
   27|  21.9k|    }
   28|  21.9k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_118encoding_detection10copy_shortEPhPKhm:
   48|    275|                                      size_t n) {
   49|    275|  if (n >= 32) {
  ------------------
  |  Branch (49:7): [True: 57, False: 218]
  ------------------
   50|     57|    std::memcpy(dst, src, 32);
   51|     57|    std::memcpy(dst + n - 32, src + n - 32, 32);
   52|    218|  } else if (n >= 16) {
  ------------------
  |  Branch (52:14): [True: 35, False: 183]
  ------------------
   53|     35|    std::memcpy(dst, src, 16);
   54|     35|    std::memcpy(dst + n - 16, src + n - 16, 16);
   55|    183|  } else if (n >= 8) {
  ------------------
  |  Branch (55:14): [True: 19, False: 164]
  ------------------
   56|     19|    std::memcpy(dst, src, 8);
   57|     19|    std::memcpy(dst + n - 8, src + n - 8, 8);
   58|    164|  } else if (n >= 4) {
  ------------------
  |  Branch (58:14): [True: 119, False: 45]
  ------------------
   59|    119|    std::memcpy(dst, src, 4);
   60|    119|    std::memcpy(dst + n - 4, src + n - 4, 4);
   61|    119|  } else {
   62|    135|    for (size_t i = 0; i < n; i++) {
  ------------------
  |  Branch (62:24): [True: 90, False: 45]
  ------------------
   63|     90|      dst[i] = src[i];
   64|     90|    }
   65|     45|  }
   66|    275|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_118encoding_detection8checkers11check_blockILb1ELb1ELb1EEEvRKNS1_4simd8simd8x64IhEE:
   12|  74.3k|  simdutf_really_inline void check_block(const simd::simd8x64<uint8_t> &in) {
   13|  74.3k|    if constexpr (check_utf8) {
   14|  74.3k|      const bool ascii = utf8.check_next_input(in);
   15|  74.3k|      if constexpr (check_utf16) {
   16|  74.3k|        if (ascii) {
  ------------------
  |  Branch (16:13): [True: 72.7k, False: 1.51k]
  ------------------
   17|  72.7k|          utf16.check_ascii();
   18|  72.7k|        } else {
   19|  1.51k|          utf16.check(in);
   20|  1.51k|        }
   21|  74.3k|      }
   22|       |    } else if constexpr (check_utf16) {
   23|       |      utf16.check(in);
   24|       |    }
   25|  74.3k|    if constexpr (check_utf32) {
   26|  74.3k|      utf32.check(in);
   27|  74.3k|    }
   28|  74.3k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_118encoding_detection16detect_encodingsEPKcm:
   93|  1.26k|int detect_encodings(const char *input, size_t length) {
   94|  1.26k|  if (length % 2 == 1 && length < 1024) {
  ------------------
  |  Branch (94:7): [True: 239, False: 1.02k]
  |  Branch (94:26): [True: 126, False: 113]
  ------------------
   95|       |    // Only UTF-8 is possible, and the input is too short for stopping early
   96|       |    // to pay off.
   97|    126|    return utf8_validation::generic_validate_utf8(input, length)
  ------------------
  |  Branch (97:12): [True: 24, False: 102]
  ------------------
   98|    126|               ? encoding_type::UTF8
   99|    126|               : 0;
  100|    126|  }
  101|       |  // We check UTF-8, UTF-16LE and UTF-32LE in a single pass over the input.
  102|       |  // An encoding that has failed is no longer checked, and we stop as soon as
  103|       |  // all of them have failed.
  104|  1.13k|  int active = encoding_type::UTF8;
  105|  1.13k|  if (length % 2 == 0) {
  ------------------
  |  Branch (105:7): [True: 1.02k, False: 113]
  ------------------
  106|  1.02k|    active |= encoding_type::UTF16_LE;
  107|  1.02k|  }
  108|  1.13k|  if (length % 4 == 0) {
  ------------------
  |  Branch (108:7): [True: 698, False: 441]
  ------------------
  109|    698|    active |= encoding_type::UTF32_LE;
  110|    698|  }
  111|  1.13k|  constexpr int utf8 = encoding_type::UTF8;
  112|  1.13k|  constexpr int utf16 = encoding_type::UTF16_LE;
  113|  1.13k|  constexpr int utf32 = encoding_type::UTF32_LE;
  114|       |
  115|  1.13k|  checkers c{};
  116|  1.13k|  const uint8_t *buf = reinterpret_cast<const uint8_t *>(input);
  117|       |  // Like buf_block_reader, we leave 1 to 64 bytes for the final block, unless
  118|       |  // the input is empty.
  119|  1.13k|  const size_t end = length < 64 ? 0 : length - 64;
  ------------------
  |  Branch (119:22): [True: 276, False: 863]
  ------------------
  120|  1.13k|  size_t idx = 0;
  121|  2.26k|  while (idx < end) {
  ------------------
  |  Branch (121:10): [True: 1.27k, False: 992]
  ------------------
  122|  1.27k|    switch (active) {
  123|    451|    case utf8 | utf16 | utf32:
  ------------------
  |  Branch (123:5): [True: 451, False: 821]
  ------------------
  124|       |    // Valid UTF-8 that is also valid UTF-32LE is always valid UTF-16LE: a
  125|       |    // high byte 0xD8..0xDF in a UTF-16 code unit would be a UTF-8 lead byte
  126|       |    // followed by a continuation byte, and the UTF-32 value would then exceed
  127|       |    // 0x10FFFF. So we do not specialize for UTF-8 and UTF-32 without UTF-16.
  128|    451|    case utf8 | utf32:
  ------------------
  |  Branch (128:5): [True: 0, False: 1.27k]
  ------------------
  129|    451|      idx = check_blocks<true, true, true>(c, buf, idx, end, active);
  130|    451|      break;
  131|    279|    case utf8 | utf16:
  ------------------
  |  Branch (131:5): [True: 279, False: 993]
  ------------------
  132|    279|      idx = check_blocks<true, true, false>(c, buf, idx, end, active);
  133|    279|      break;
  134|    178|    case utf8:
  ------------------
  |  Branch (134:5): [True: 178, False: 1.09k]
  ------------------
  135|    178|      if (idx != 0) {
  ------------------
  |  Branch (135:11): [True: 65, False: 113]
  ------------------
  136|       |        // Only UTF-8 is left, without an error so far, and validate_utf8 is
  137|       |        // faster than our loop. The bytes before idx are valid UTF-8 except
  138|       |        // that they may end with an incomplete character (or a byte that
  139|       |        // cannot start one): validate_utf8 starts with that character.
  140|     65|        const size_t start = scalar::utf8::trim_partial_utf8(input, idx);
  141|     65|        return utf8_validation::generic_validate_utf8(input + start,
  ------------------
  |  Branch (141:16): [True: 19, False: 46]
  ------------------
  142|     65|                                                      length - start)
  143|     65|                   ? utf8
  144|     65|                   : 0;
  145|     65|      }
  146|       |      // Odd length: we check the first 1024 bytes here, so that we stop early
  147|       |      // if the input is not UTF-8.
  148|    113|      idx = check_blocks<true, false, false>(c, buf, idx,
  149|    113|                                             detail::min(end, stride), active);
  150|    113|      break;
  151|     88|    case utf16 | utf32:
  ------------------
  |  Branch (151:5): [True: 88, False: 1.18k]
  ------------------
  152|     88|      idx = check_blocks<false, true, true>(c, buf, idx, end, active);
  153|     88|      break;
  154|    114|    case utf16:
  ------------------
  |  Branch (154:5): [True: 114, False: 1.15k]
  ------------------
  155|    114|      idx = check_blocks<false, true, false>(c, buf, idx, end, active);
  156|    114|      break;
  157|     80|    case utf32:
  ------------------
  |  Branch (157:5): [True: 80, False: 1.19k]
  ------------------
  158|     80|      idx = check_blocks<false, false, true>(c, buf, idx, end, active);
  159|     80|      break;
  160|     82|    default:
  ------------------
  |  Branch (160:5): [True: 82, False: 1.19k]
  ------------------
  161|       |      // All three encodings have failed.
  162|     82|      return 0;
  163|  1.27k|    }
  164|  1.27k|  }
  165|       |
  166|       |  // The last 1 to 64 bytes.
  167|    992|  if (length < 64) {
  ------------------
  |  Branch (167:7): [True: 276, False: 716]
  ------------------
  168|       |    // Short input: copy it to a block padded with zeros. A zero byte is valid
  169|       |    // in all three encodings, and a high surrogate followed by the padding is
  170|       |    // caught.
  171|    276|    if (length != 0) {
  ------------------
  |  Branch (171:9): [True: 275, False: 1]
  ------------------
  172|    275|      uint8_t block[64]{};
  173|    275|      copy_short(block, buf, length);
  174|    275|      const simd::simd8x64<uint8_t> in(block);
  175|    275|      c.check_block<true, true, true>(in);
  176|    275|    }
  177|    276|    c.utf8.check_eof();
  178|    716|  } else {
  179|       |    // The last 64 bytes. They start at an even index if UTF-16LE is still
  180|       |    // active, and at a multiple of four if UTF-32LE is.
  181|    716|    const size_t start = length - 64;
  182|    716|    const simd::simd8x64<uint8_t> in(buf + start);
  183|    716|    if (idx == start) {
  ------------------
  |  Branch (183:9): [True: 78, False: 638]
  ------------------
  184|       |      // They form a full block that has not been checked.
  185|     78|      if (active & utf8) {
  ------------------
  |  Branch (185:11): [True: 61, False: 17]
  ------------------
  186|     61|        c.utf8.check_next_input(in);
  187|     61|        c.utf8.check_eof();
  188|     61|      }
  189|     78|      if (active & utf16) {
  ------------------
  |  Branch (189:11): [True: 75, False: 3]
  ------------------
  190|     75|        c.utf16.check(in);
  191|     75|      }
  192|    638|    } else {
  193|       |      // They overlap the bytes already checked.
  194|    638|      if (active & utf8) {
  ------------------
  |  Branch (194:11): [True: 210, False: 428]
  ------------------
  195|       |        // Same as validate_utf8, it also calls check_eof().
  196|    210|        utf8_validation::check_remainder(c.utf8, buf, length, idx);
  197|    210|      }
  198|    638|      if (active & utf16) {
  ------------------
  |  Branch (198:11): [True: 324, False: 314]
  ------------------
  199|    324|        c.utf16.check<true>(in);
  200|    324|      }
  201|    638|    }
  202|    716|    if (active & utf32) {
  ------------------
  |  Branch (202:9): [True: 135, False: 581]
  ------------------
  203|       |      // Checking values again does not change the result.
  204|    135|      c.utf32.check(in);
  205|    135|    }
  206|    716|  }
  207|       |
  208|    992|  int out = 0;
  209|    992|  if ((active & utf8) && !c.utf8.errors()) {
  ------------------
  |  Branch (209:7): [True: 547, False: 445]
  |  Branch (209:26): [True: 109, False: 438]
  ------------------
  210|    109|    out |= utf8;
  211|    109|  }
  212|    992|  if ((active & utf16) && !c.utf16.errors_at_eof()) {
  ------------------
  |  Branch (212:7): [True: 675, False: 317]
  |  Branch (212:27): [True: 518, False: 157]
  ------------------
  213|    518|    out |= utf16;
  214|    518|  }
  215|    992|  if ((active & utf32) && !c.utf32.errors()) {
  ------------------
  |  Branch (215:7): [True: 330, False: 662]
  |  Branch (215:27): [True: 116, False: 214]
  ------------------
  216|    116|    out |= utf32;
  217|    116|  }
  218|    992|  return out;
  219|  1.13k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_118encoding_detection12check_blocksILb1ELb1ELb1EEEmRNS2_8checkersEPKhmmRi:
   78|    451|                    int &active) {
   79|  4.80k|  while (true) {
  ------------------
  |  Branch (79:10): [True: 4.80k, Folded]
  ------------------
   80|  4.80k|    const size_t stop = (end - idx > stride) ? idx + stride : end;
  ------------------
  |  Branch (80:25): [True: 4.58k, False: 219]
  ------------------
   81|  78.8k|    for (; idx < stop; idx += 64) {
  ------------------
  |  Branch (81:12): [True: 74.0k, False: 4.80k]
  ------------------
   82|  74.0k|      const simd::simd8x64<uint8_t> in(input + idx);
   83|  74.0k|      c.check_block<check_utf8, check_utf16, check_utf32>(in);
   84|  74.0k|    }
   85|  4.80k|    const int valid = c.still_valid(active);
   86|  4.80k|    if (idx >= end || valid != active) {
  ------------------
  |  Branch (86:9): [True: 219, False: 4.58k]
  |  Branch (86:23): [True: 232, False: 4.35k]
  ------------------
   87|    451|      active = valid;
   88|    451|      return idx;
   89|    451|    }
   90|  4.80k|  }
   91|    451|}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_118encoding_detection8checkers11still_validEi:
   31|  24.1k|  simdutf_really_inline int still_valid(int active) const {
   32|  24.1k|    if ((active & encoding_type::UTF8) && utf8.errors()) {
  ------------------
  |  Branch (32:9): [True: 13.1k, False: 10.9k]
  |  Branch (32:43): [True: 527, False: 12.6k]
  ------------------
   33|    527|      active &= ~encoding_type::UTF8;
   34|    527|    }
   35|  24.1k|    if ((active & encoding_type::UTF16_LE) && utf16.errors()) {
  ------------------
  |  Branch (35:9): [True: 22.6k, False: 1.53k]
  |  Branch (35:47): [True: 351, False: 22.2k]
  ------------------
   36|    351|      active &= ~encoding_type::UTF16_LE;
   37|    351|    }
   38|  24.1k|    if ((active & encoding_type::UTF32_LE) && utf32.errors()) {
  ------------------
  |  Branch (38:9): [True: 8.31k, False: 15.8k]
  |  Branch (38:47): [True: 368, False: 7.94k]
  ------------------
   39|    368|      active &= ~encoding_type::UTF32_LE;
   40|    368|    }
   41|  24.1k|    return active;
   42|  24.1k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_118encoding_detection12check_blocksILb1ELb1ELb0EEEmRNS2_8checkersEPKhmmRi:
   78|    279|                    int &active) {
   79|  8.27k|  while (true) {
  ------------------
  |  Branch (79:10): [True: 8.27k, Folded]
  ------------------
   80|  8.27k|    const size_t stop = (end - idx > stride) ? idx + stride : end;
  ------------------
  |  Branch (80:25): [True: 8.09k, False: 183]
  ------------------
   81|   138k|    for (; idx < stop; idx += 64) {
  ------------------
  |  Branch (81:12): [True: 130k, False: 8.27k]
  ------------------
   82|   130k|      const simd::simd8x64<uint8_t> in(input + idx);
   83|   130k|      c.check_block<check_utf8, check_utf16, check_utf32>(in);
   84|   130k|    }
   85|  8.27k|    const int valid = c.still_valid(active);
   86|  8.27k|    if (idx >= end || valid != active) {
  ------------------
  |  Branch (86:9): [True: 183, False: 8.09k]
  |  Branch (86:23): [True: 96, False: 7.99k]
  ------------------
   87|    279|      active = valid;
   88|    279|      return idx;
   89|    279|    }
   90|  8.27k|  }
   91|    279|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_118encoding_detection8checkers11check_blockILb1ELb1ELb0EEEvRKNS1_4simd8simd8x64IhEE:
   12|   130k|  simdutf_really_inline void check_block(const simd::simd8x64<uint8_t> &in) {
   13|   130k|    if constexpr (check_utf8) {
   14|   130k|      const bool ascii = utf8.check_next_input(in);
   15|   130k|      if constexpr (check_utf16) {
   16|   130k|        if (ascii) {
  ------------------
  |  Branch (16:13): [True: 125k, False: 4.68k]
  ------------------
   17|   125k|          utf16.check_ascii();
   18|   125k|        } else {
   19|  4.68k|          utf16.check(in);
   20|  4.68k|        }
   21|   130k|      }
   22|       |    } else if constexpr (check_utf16) {
   23|       |      utf16.check(in);
   24|       |    }
   25|       |    if constexpr (check_utf32) {
   26|       |      utf32.check(in);
   27|       |    }
   28|   130k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_118encoding_detection12check_blocksILb1ELb0ELb0EEEmRNS2_8checkersEPKhmmRi:
   78|    113|                    int &active) {
   79|    113|  while (true) {
  ------------------
  |  Branch (79:10): [True: 113, Folded]
  ------------------
   80|    113|    const size_t stop = (end - idx > stride) ? idx + stride : end;
  ------------------
  |  Branch (80:25): [True: 0, False: 113]
  ------------------
   81|  1.92k|    for (; idx < stop; idx += 64) {
  ------------------
  |  Branch (81:12): [True: 1.80k, False: 113]
  ------------------
   82|  1.80k|      const simd::simd8x64<uint8_t> in(input + idx);
   83|  1.80k|      c.check_block<check_utf8, check_utf16, check_utf32>(in);
   84|  1.80k|    }
   85|    113|    const int valid = c.still_valid(active);
   86|    113|    if (idx >= end || valid != active) {
  ------------------
  |  Branch (86:9): [True: 113, False: 0]
  |  Branch (86:23): [True: 0, False: 0]
  ------------------
   87|    113|      active = valid;
   88|    113|      return idx;
   89|    113|    }
   90|    113|  }
   91|    113|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_118encoding_detection8checkers11check_blockILb1ELb0ELb0EEEvRKNS1_4simd8simd8x64IhEE:
   12|  1.80k|  simdutf_really_inline void check_block(const simd::simd8x64<uint8_t> &in) {
   13|  1.80k|    if constexpr (check_utf8) {
   14|  1.80k|      const bool ascii = utf8.check_next_input(in);
   15|       |      if constexpr (check_utf16) {
   16|       |        if (ascii) {
   17|       |          utf16.check_ascii();
   18|       |        } else {
   19|       |          utf16.check(in);
   20|       |        }
   21|       |      }
   22|       |    } else if constexpr (check_utf16) {
   23|       |      utf16.check(in);
   24|       |    }
   25|       |    if constexpr (check_utf32) {
   26|       |      utf32.check(in);
   27|       |    }
   28|  1.80k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_118encoding_detection12check_blocksILb0ELb1ELb1EEEmRNS2_8checkersEPKhmmRi:
   78|     88|                    int &active) {
   79|  2.09k|  while (true) {
  ------------------
  |  Branch (79:10): [True: 2.09k, Folded]
  ------------------
   80|  2.09k|    const size_t stop = (end - idx > stride) ? idx + stride : end;
  ------------------
  |  Branch (80:25): [True: 2.02k, False: 67]
  ------------------
   81|  34.8k|    for (; idx < stop; idx += 64) {
  ------------------
  |  Branch (81:12): [True: 32.7k, False: 2.09k]
  ------------------
   82|  32.7k|      const simd::simd8x64<uint8_t> in(input + idx);
   83|  32.7k|      c.check_block<check_utf8, check_utf16, check_utf32>(in);
   84|  32.7k|    }
   85|  2.09k|    const int valid = c.still_valid(active);
   86|  2.09k|    if (idx >= end || valid != active) {
  ------------------
  |  Branch (86:9): [True: 67, False: 2.02k]
  |  Branch (86:23): [True: 21, False: 2.00k]
  ------------------
   87|     88|      active = valid;
   88|     88|      return idx;
   89|     88|    }
   90|  2.09k|  }
   91|     88|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_118encoding_detection8checkers11check_blockILb0ELb1ELb1EEEvRKNS1_4simd8simd8x64IhEE:
   12|  32.7k|  simdutf_really_inline void check_block(const simd::simd8x64<uint8_t> &in) {
   13|       |    if constexpr (check_utf8) {
   14|       |      const bool ascii = utf8.check_next_input(in);
   15|       |      if constexpr (check_utf16) {
   16|       |        if (ascii) {
   17|       |          utf16.check_ascii();
   18|       |        } else {
   19|       |          utf16.check(in);
   20|       |        }
   21|       |      }
   22|  32.7k|    } else if constexpr (check_utf16) {
   23|  32.7k|      utf16.check(in);
   24|  32.7k|    }
   25|  32.7k|    if constexpr (check_utf32) {
   26|  32.7k|      utf32.check(in);
   27|  32.7k|    }
   28|  32.7k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_118encoding_detection12check_blocksILb0ELb1ELb0EEEmRNS2_8checkersEPKhmmRi:
   78|    114|                    int &active) {
   79|  7.43k|  while (true) {
  ------------------
  |  Branch (79:10): [True: 7.43k, Folded]
  ------------------
   80|  7.43k|    const size_t stop = (end - idx > stride) ? idx + stride : end;
  ------------------
  |  Branch (80:25): [True: 7.33k, False: 95]
  ------------------
   81|   125k|    for (; idx < stop; idx += 64) {
  ------------------
  |  Branch (81:12): [True: 118k, False: 7.43k]
  ------------------
   82|   118k|      const simd::simd8x64<uint8_t> in(input + idx);
   83|   118k|      c.check_block<check_utf8, check_utf16, check_utf32>(in);
   84|   118k|    }
   85|  7.43k|    const int valid = c.still_valid(active);
   86|  7.43k|    if (idx >= end || valid != active) {
  ------------------
  |  Branch (86:9): [True: 95, False: 7.33k]
  |  Branch (86:23): [True: 19, False: 7.32k]
  ------------------
   87|    114|      active = valid;
   88|    114|      return idx;
   89|    114|    }
   90|  7.43k|  }
   91|    114|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_118encoding_detection8checkers11check_blockILb0ELb1ELb0EEEvRKNS1_4simd8simd8x64IhEE:
   12|   118k|  simdutf_really_inline void check_block(const simd::simd8x64<uint8_t> &in) {
   13|       |    if constexpr (check_utf8) {
   14|       |      const bool ascii = utf8.check_next_input(in);
   15|       |      if constexpr (check_utf16) {
   16|       |        if (ascii) {
   17|       |          utf16.check_ascii();
   18|       |        } else {
   19|       |          utf16.check(in);
   20|       |        }
   21|       |      }
   22|   118k|    } else if constexpr (check_utf16) {
   23|   118k|      utf16.check(in);
   24|   118k|    }
   25|       |    if constexpr (check_utf32) {
   26|       |      utf32.check(in);
   27|       |    }
   28|   118k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_118encoding_detection12check_blocksILb0ELb0ELb1EEEmRNS2_8checkersEPKhmmRi:
   78|     80|                    int &active) {
   79|  1.41k|  while (true) {
  ------------------
  |  Branch (79:10): [True: 1.41k, Folded]
  ------------------
   80|  1.41k|    const size_t stop = (end - idx > stride) ? idx + stride : end;
  ------------------
  |  Branch (80:25): [True: 1.35k, False: 68]
  ------------------
   81|  23.3k|    for (; idx < stop; idx += 64) {
  ------------------
  |  Branch (81:12): [True: 21.9k, False: 1.41k]
  ------------------
   82|  21.9k|      const simd::simd8x64<uint8_t> in(input + idx);
   83|  21.9k|      c.check_block<check_utf8, check_utf16, check_utf32>(in);
   84|  21.9k|    }
   85|  1.41k|    const int valid = c.still_valid(active);
   86|  1.41k|    if (idx >= end || valid != active) {
  ------------------
  |  Branch (86:9): [True: 68, False: 1.35k]
  |  Branch (86:23): [True: 12, False: 1.33k]
  ------------------
   87|     80|      active = valid;
   88|     80|      return idx;
   89|     80|    }
   90|  1.41k|  }
   91|     80|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_118encoding_detection8checkers11check_blockILb0ELb0ELb1EEEvRKNS1_4simd8simd8x64IhEE:
   12|  21.9k|  simdutf_really_inline void check_block(const simd::simd8x64<uint8_t> &in) {
   13|       |    if constexpr (check_utf8) {
   14|       |      const bool ascii = utf8.check_next_input(in);
   15|       |      if constexpr (check_utf16) {
   16|       |        if (ascii) {
   17|       |          utf16.check_ascii();
   18|       |        } else {
   19|       |          utf16.check(in);
   20|       |        }
   21|       |      }
   22|  21.9k|    } else if constexpr (check_utf16) {
   23|  21.9k|      utf16.check(in);
   24|  21.9k|    }
   25|  21.9k|    if constexpr (check_utf32) {
   26|  21.9k|      utf32.check(in);
   27|  21.9k|    }
   28|  21.9k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_118encoding_detection10copy_shortEPhPKhm:
   48|    275|                                      size_t n) {
   49|    275|  if (n >= 32) {
  ------------------
  |  Branch (49:7): [True: 57, False: 218]
  ------------------
   50|     57|    std::memcpy(dst, src, 32);
   51|     57|    std::memcpy(dst + n - 32, src + n - 32, 32);
   52|    218|  } else if (n >= 16) {
  ------------------
  |  Branch (52:14): [True: 35, False: 183]
  ------------------
   53|     35|    std::memcpy(dst, src, 16);
   54|     35|    std::memcpy(dst + n - 16, src + n - 16, 16);
   55|    183|  } else if (n >= 8) {
  ------------------
  |  Branch (55:14): [True: 19, False: 164]
  ------------------
   56|     19|    std::memcpy(dst, src, 8);
   57|     19|    std::memcpy(dst + n - 8, src + n - 8, 8);
   58|    164|  } else if (n >= 4) {
  ------------------
  |  Branch (58:14): [True: 119, False: 45]
  ------------------
   59|    119|    std::memcpy(dst, src, 4);
   60|    119|    std::memcpy(dst + n - 4, src + n - 4, 4);
   61|    119|  } else {
   62|    135|    for (size_t i = 0; i < n; i++) {
  ------------------
  |  Branch (62:24): [True: 90, False: 45]
  ------------------
   63|     90|      dst[i] = src[i];
   64|     90|    }
   65|     45|  }
   66|    275|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_118encoding_detection8checkers11check_blockILb1ELb1ELb1EEEvRKNS1_4simd8simd8x64IhEE:
   12|  74.3k|  simdutf_really_inline void check_block(const simd::simd8x64<uint8_t> &in) {
   13|  74.3k|    if constexpr (check_utf8) {
   14|  74.3k|      const bool ascii = utf8.check_next_input(in);
   15|  74.3k|      if constexpr (check_utf16) {
   16|  74.3k|        if (ascii) {
  ------------------
  |  Branch (16:13): [True: 72.7k, False: 1.51k]
  ------------------
   17|  72.7k|          utf16.check_ascii();
   18|  72.7k|        } else {
   19|  1.51k|          utf16.check(in);
   20|  1.51k|        }
   21|  74.3k|      }
   22|       |    } else if constexpr (check_utf16) {
   23|       |      utf16.check(in);
   24|       |    }
   25|  74.3k|    if constexpr (check_utf32) {
   26|  74.3k|      utf32.check(in);
   27|  74.3k|    }
   28|  74.3k|  }

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf1623change_endianness_utf16EPKDsmPDs:
   56|    129|change_endianness_utf16(const char16_t *in, size_t size, char16_t *output) {
   57|    129|  size_t pos = 0;
   58|       |
   59|  98.1k|  while (pos < size / 32 * 32) {
  ------------------
  |  Branch (59:10): [True: 97.9k, False: 129]
  ------------------
   60|  97.9k|    simd16x32<uint16_t> input(reinterpret_cast<const uint16_t *>(in + pos));
   61|  97.9k|    input.swap_bytes();
   62|  97.9k|    input.store(reinterpret_cast<uint16_t *>(output));
   63|  97.9k|    pos += 32;
   64|  97.9k|    output += 32;
   65|  97.9k|  }
   66|       |
   67|    129|  scalar::utf16::change_endianness_utf16(in + pos, size - pos, output);
   68|    129|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf1623change_endianness_utf16EPKDsmPDs:
   56|    129|change_endianness_utf16(const char16_t *in, size_t size, char16_t *output) {
   57|    129|  size_t pos = 0;
   58|       |
   59|  98.1k|  while (pos < size / 32 * 32) {
  ------------------
  |  Branch (59:10): [True: 97.9k, False: 129]
  ------------------
   60|  97.9k|    simd16x32<uint16_t> input(reinterpret_cast<const uint16_t *>(in + pos));
   61|  97.9k|    input.swap_bytes();
   62|  97.9k|    input.store(reinterpret_cast<uint16_t *>(output));
   63|  97.9k|    pos += 32;
   64|  97.9k|    output += 32;
   65|  97.9k|  }
   66|       |
   67|    129|  scalar::utf16::change_endianness_utf16(in + pos, size - pos, output);
   68|    129|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115utf8_validation12utf8_checker9check_eofEv:
  207|  1.59k|  simdutf_really_inline void check_eof() {
  208|       |    // If the previous block had incomplete UTF-8 characters at the end, an
  209|       |    // ASCII block can't possibly finish them.
  210|  1.59k|    this->error |= this->prev_incomplete;
  211|  1.59k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115utf8_validation12utf8_checker16check_next_inputERKNS1_4simd8simd8x64IhEE:
  215|   428k|  simdutf_really_inline bool check_next_input(const simd8x64<uint8_t> &input) {
  216|   428k|    if (simdutf_likely(is_ascii(input))) {
  ------------------
  |  |   90|   428k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 341k, False: 86.4k]
  |  |  ------------------
  ------------------
  217|   341k|      this->error |= this->prev_incomplete;
  218|   341k|      return true;
  219|   341k|    } else {
  220|       |      // you might think that a for-loop would work, but under Visual Studio, it
  221|       |      // is not good enough.
  222|  86.4k|      static_assert((simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  223|  86.4k|                        (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  224|  86.4k|                    "We support either two or four chunks per 64-byte block.");
  225|  86.4k|      if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  226|  86.4k|        this->check_utf8_bytes(input.chunks[0], this->prev_input_block);
  227|  86.4k|        this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  228|       |      } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  229|       |        this->check_utf8_bytes(input.chunks[0], this->prev_input_block);
  230|       |        this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  231|       |        this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  232|       |        this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  233|       |      }
  234|  86.4k|      this->prev_incomplete =
  235|  86.4k|          is_incomplete(input.chunks[simd8x64<uint8_t>::NUM_CHUNKS - 1]);
  236|  86.4k|      this->prev_input_block = input.chunks[simd8x64<uint8_t>::NUM_CHUNKS - 1];
  237|  86.4k|      return false;
  238|  86.4k|    }
  239|   428k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115utf8_validation12utf8_checker16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  195|   172k|                                              const simd8<uint8_t> prev_input) {
  196|       |    // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+
  197|       |    // lead bytes (2, 3, 4-byte leads become large positive numbers instead of
  198|       |    // small negative numbers)
  199|   172k|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  200|   172k|    simd8<uint8_t> sc = check_special_cases(input, prev1);
  201|   172k|    this->error |= check_multibyte_lengths(input, prev_input, sc);
  202|   172k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115utf8_validation19check_special_casesENS1_4simd5simd8IhEES5_:
    9|   172k|check_special_cases(const simd8<uint8_t> input, const simd8<uint8_t> prev1) {
   10|       |  // Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII)
   11|       |  // Bit 1 = Too Long (ASCII followed by continuation)
   12|       |  // Bit 2 = Overlong 3-byte
   13|       |  // Bit 4 = Surrogate
   14|       |  // Bit 5 = Overlong 2-byte
   15|       |  // Bit 7 = Two Continuations
   16|   172k|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   17|       |                                               // 11______ 11______
   18|   172k|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   19|   172k|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   20|   172k|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   21|   172k|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   22|   172k|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   23|   172k|  constexpr const uint8_t TOO_LARGE = 1 << 3;  // 11110100 1001____
   24|       |                                               // 11110100 101_____
   25|       |                                               // 11110101 1001____
   26|       |                                               // 11110101 101_____
   27|       |                                               // 1111011_ 1001____
   28|       |                                               // 1111011_ 101_____
   29|       |                                               // 11111___ 1001____
   30|       |                                               // 11111___ 101_____
   31|   172k|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   32|       |  // 11110101 1000____
   33|       |  // 1111011_ 1000____
   34|       |  // 11111___ 1000____
   35|   172k|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   36|       |
   37|   172k|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   38|       |      // 0_______ ________ <ASCII in byte 1>
   39|   172k|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   40|   172k|      TOO_LONG,
   41|       |      // 10______ ________ <continuation in byte 1>
   42|   172k|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   43|       |      // 1100____ ________ <two byte lead in byte 1>
   44|   172k|      TOO_SHORT | OVERLONG_2,
   45|       |      // 1101____ ________ <two byte lead in byte 1>
   46|   172k|      TOO_SHORT,
   47|       |      // 1110____ ________ <three byte lead in byte 1>
   48|   172k|      TOO_SHORT | OVERLONG_3 | SURROGATE,
   49|       |      // 1111____ ________ <four+ byte lead in byte 1>
   50|   172k|      TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4);
   51|   172k|  constexpr const uint8_t CARRY =
   52|   172k|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   53|   172k|  const simd8<uint8_t> byte_1_low =
   54|   172k|      (prev1 & 0x0F)
   55|   172k|          .lookup_16<uint8_t>(
   56|       |              // ____0000 ________
   57|   172k|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   58|       |              // ____0001 ________
   59|   172k|              CARRY | OVERLONG_2,
   60|       |              // ____001_ ________
   61|   172k|              CARRY, CARRY,
   62|       |
   63|       |              // ____0100 ________
   64|   172k|              CARRY | TOO_LARGE,
   65|       |              // ____0101 ________
   66|   172k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   67|       |              // ____011_ ________
   68|   172k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   69|   172k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   70|       |
   71|       |              // ____1___ ________
   72|   172k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   73|   172k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   74|   172k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   75|   172k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   76|   172k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   77|       |              // ____1101 ________
   78|   172k|              CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE,
   79|   172k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   80|   172k|              CARRY | TOO_LARGE | TOO_LARGE_1000);
   81|   172k|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   82|       |      // ________ 0_______ <ASCII in byte 2>
   83|   172k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   84|   172k|      TOO_SHORT, TOO_SHORT,
   85|       |
   86|       |      // ________ 1000____
   87|   172k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
   88|   172k|          OVERLONG_4,
   89|       |      // ________ 1001____
   90|   172k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
   91|       |      // ________ 101_____
   92|   172k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   93|   172k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   94|       |
   95|       |      // ________ 11______
   96|   172k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
   97|   172k|  return (byte_1_high & byte_1_low & byte_2_high);
   98|   172k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115utf8_validation23check_multibyte_lengthsENS1_4simd5simd8IhEES5_S5_:
  102|   172k|                        const simd8<uint8_t> sc) {
  103|   172k|  simd8<uint8_t> prev2 = input.prev<2>(prev_input);
  104|   172k|  simd8<uint8_t> prev3 = input.prev<3>(prev_input);
  105|   172k|  simd8<uint8_t> must23 =
  106|   172k|      simd8<uint8_t>(must_be_2_3_continuation(prev2, prev3));
  107|   172k|  simd8<uint8_t> must23_80 = must23 & uint8_t(0x80);
  108|   172k|  return must23_80 ^ sc;
  109|   172k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115utf8_validation13is_incompleteENS1_4simd5simd8IhEE:
  115|  86.4k|simdutf_really_inline simd8<uint8_t> is_incomplete(const simd8<uint8_t> input) {
  116|       |  // If the previous input's last 3 bytes match this, they're too short (they
  117|       |  // ended at EOF):
  118|       |  // ... 1111____ 111_____ 11______
  119|  86.4k|  static const uint8_t max_array[32] = {255,
  120|  86.4k|                                        255,
  121|  86.4k|                                        255,
  122|  86.4k|                                        255,
  123|  86.4k|                                        255,
  124|  86.4k|                                        255,
  125|  86.4k|                                        255,
  126|  86.4k|                                        255,
  127|  86.4k|                                        255,
  128|  86.4k|                                        255,
  129|  86.4k|                                        255,
  130|  86.4k|                                        255,
  131|  86.4k|                                        255,
  132|  86.4k|                                        255,
  133|  86.4k|                                        255,
  134|  86.4k|                                        255,
  135|  86.4k|                                        255,
  136|  86.4k|                                        255,
  137|  86.4k|                                        255,
  138|  86.4k|                                        255,
  139|  86.4k|                                        255,
  140|  86.4k|                                        255,
  141|  86.4k|                                        255,
  142|  86.4k|                                        255,
  143|  86.4k|                                        255,
  144|  86.4k|                                        255,
  145|  86.4k|                                        255,
  146|  86.4k|                                        255,
  147|  86.4k|                                        255,
  148|  86.4k|                                        0b11110000u - 1,
  149|  86.4k|                                        0b11100000u - 1,
  150|  86.4k|                                        0b11000000u - 1};
  151|  86.4k|  const simd8<uint8_t> max_value(
  152|  86.4k|      &max_array[sizeof(max_array) - sizeof(simd8<uint8_t>)]);
  153|  86.4k|  return input.gt_bits(max_value);
  154|  86.4k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115utf8_validation12utf8_checker23check_overlapping_inputERKNS1_4simd8simd8x64IhEENS4_5simd8IhEE:
  246|    347|                          const simd8<uint8_t> prev_input) {
  247|    347|    this->prev_input_block = prev_input;
  248|    347|    this->check_next_input(input);
  249|    347|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_115utf8_validation12utf8_checker6errorsEv:
  252|  19.7k|  simdutf_really_inline bool errors() const {
  253|  19.7k|    return this->error.any_bits_set_anywhere();
  254|  19.7k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115utf8_validation12utf8_checker9check_eofEv:
  207|  1.59k|  simdutf_really_inline void check_eof() {
  208|       |    // If the previous block had incomplete UTF-8 characters at the end, an
  209|       |    // ASCII block can't possibly finish them.
  210|  1.59k|    this->error |= this->prev_incomplete;
  211|  1.59k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115utf8_validation12utf8_checker16check_next_inputERKNS1_4simd8simd8x64IhEE:
  215|   428k|  simdutf_really_inline bool check_next_input(const simd8x64<uint8_t> &input) {
  216|   428k|    if (simdutf_likely(is_ascii(input))) {
  ------------------
  |  |   90|   428k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 341k, False: 86.4k]
  |  |  ------------------
  ------------------
  217|   341k|      this->error |= this->prev_incomplete;
  218|   341k|      return true;
  219|   341k|    } else {
  220|       |      // you might think that a for-loop would work, but under Visual Studio, it
  221|       |      // is not good enough.
  222|  86.4k|      static_assert((simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  223|  86.4k|                        (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  224|  86.4k|                    "We support either two or four chunks per 64-byte block.");
  225|       |      if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  226|       |        this->check_utf8_bytes(input.chunks[0], this->prev_input_block);
  227|       |        this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  228|  86.4k|      } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  229|  86.4k|        this->check_utf8_bytes(input.chunks[0], this->prev_input_block);
  230|  86.4k|        this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  231|  86.4k|        this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  232|  86.4k|        this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  233|  86.4k|      }
  234|  86.4k|      this->prev_incomplete =
  235|  86.4k|          is_incomplete(input.chunks[simd8x64<uint8_t>::NUM_CHUNKS - 1]);
  236|  86.4k|      this->prev_input_block = input.chunks[simd8x64<uint8_t>::NUM_CHUNKS - 1];
  237|  86.4k|      return false;
  238|  86.4k|    }
  239|   428k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115utf8_validation12utf8_checker16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  195|   345k|                                              const simd8<uint8_t> prev_input) {
  196|       |    // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+
  197|       |    // lead bytes (2, 3, 4-byte leads become large positive numbers instead of
  198|       |    // small negative numbers)
  199|   345k|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  200|   345k|    simd8<uint8_t> sc = check_special_cases(input, prev1);
  201|   345k|    this->error |= check_multibyte_lengths(input, prev_input, sc);
  202|   345k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115utf8_validation19check_special_casesENS1_4simd5simd8IhEES5_:
    9|   345k|check_special_cases(const simd8<uint8_t> input, const simd8<uint8_t> prev1) {
   10|       |  // Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII)
   11|       |  // Bit 1 = Too Long (ASCII followed by continuation)
   12|       |  // Bit 2 = Overlong 3-byte
   13|       |  // Bit 4 = Surrogate
   14|       |  // Bit 5 = Overlong 2-byte
   15|       |  // Bit 7 = Two Continuations
   16|   345k|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   17|       |                                               // 11______ 11______
   18|   345k|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   19|   345k|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   20|   345k|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   21|   345k|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   22|   345k|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   23|   345k|  constexpr const uint8_t TOO_LARGE = 1 << 3;  // 11110100 1001____
   24|       |                                               // 11110100 101_____
   25|       |                                               // 11110101 1001____
   26|       |                                               // 11110101 101_____
   27|       |                                               // 1111011_ 1001____
   28|       |                                               // 1111011_ 101_____
   29|       |                                               // 11111___ 1001____
   30|       |                                               // 11111___ 101_____
   31|   345k|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   32|       |  // 11110101 1000____
   33|       |  // 1111011_ 1000____
   34|       |  // 11111___ 1000____
   35|   345k|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   36|       |
   37|   345k|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   38|       |      // 0_______ ________ <ASCII in byte 1>
   39|   345k|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   40|   345k|      TOO_LONG,
   41|       |      // 10______ ________ <continuation in byte 1>
   42|   345k|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   43|       |      // 1100____ ________ <two byte lead in byte 1>
   44|   345k|      TOO_SHORT | OVERLONG_2,
   45|       |      // 1101____ ________ <two byte lead in byte 1>
   46|   345k|      TOO_SHORT,
   47|       |      // 1110____ ________ <three byte lead in byte 1>
   48|   345k|      TOO_SHORT | OVERLONG_3 | SURROGATE,
   49|       |      // 1111____ ________ <four+ byte lead in byte 1>
   50|   345k|      TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4);
   51|   345k|  constexpr const uint8_t CARRY =
   52|   345k|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   53|   345k|  const simd8<uint8_t> byte_1_low =
   54|   345k|      (prev1 & 0x0F)
   55|   345k|          .lookup_16<uint8_t>(
   56|       |              // ____0000 ________
   57|   345k|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   58|       |              // ____0001 ________
   59|   345k|              CARRY | OVERLONG_2,
   60|       |              // ____001_ ________
   61|   345k|              CARRY, CARRY,
   62|       |
   63|       |              // ____0100 ________
   64|   345k|              CARRY | TOO_LARGE,
   65|       |              // ____0101 ________
   66|   345k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   67|       |              // ____011_ ________
   68|   345k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   69|   345k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   70|       |
   71|       |              // ____1___ ________
   72|   345k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   73|   345k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   74|   345k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   75|   345k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   76|   345k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   77|       |              // ____1101 ________
   78|   345k|              CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE,
   79|   345k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   80|   345k|              CARRY | TOO_LARGE | TOO_LARGE_1000);
   81|   345k|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   82|       |      // ________ 0_______ <ASCII in byte 2>
   83|   345k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   84|   345k|      TOO_SHORT, TOO_SHORT,
   85|       |
   86|       |      // ________ 1000____
   87|   345k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
   88|   345k|          OVERLONG_4,
   89|       |      // ________ 1001____
   90|   345k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
   91|       |      // ________ 101_____
   92|   345k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   93|   345k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   94|       |
   95|       |      // ________ 11______
   96|   345k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
   97|   345k|  return (byte_1_high & byte_1_low & byte_2_high);
   98|   345k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115utf8_validation23check_multibyte_lengthsENS1_4simd5simd8IhEES5_S5_:
  102|   345k|                        const simd8<uint8_t> sc) {
  103|   345k|  simd8<uint8_t> prev2 = input.prev<2>(prev_input);
  104|   345k|  simd8<uint8_t> prev3 = input.prev<3>(prev_input);
  105|   345k|  simd8<uint8_t> must23 =
  106|   345k|      simd8<uint8_t>(must_be_2_3_continuation(prev2, prev3));
  107|   345k|  simd8<uint8_t> must23_80 = must23 & uint8_t(0x80);
  108|   345k|  return must23_80 ^ sc;
  109|   345k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115utf8_validation13is_incompleteENS1_4simd5simd8IhEE:
  115|  86.4k|simdutf_really_inline simd8<uint8_t> is_incomplete(const simd8<uint8_t> input) {
  116|       |  // If the previous input's last 3 bytes match this, they're too short (they
  117|       |  // ended at EOF):
  118|       |  // ... 1111____ 111_____ 11______
  119|  86.4k|  static const uint8_t max_array[32] = {255,
  120|  86.4k|                                        255,
  121|  86.4k|                                        255,
  122|  86.4k|                                        255,
  123|  86.4k|                                        255,
  124|  86.4k|                                        255,
  125|  86.4k|                                        255,
  126|  86.4k|                                        255,
  127|  86.4k|                                        255,
  128|  86.4k|                                        255,
  129|  86.4k|                                        255,
  130|  86.4k|                                        255,
  131|  86.4k|                                        255,
  132|  86.4k|                                        255,
  133|  86.4k|                                        255,
  134|  86.4k|                                        255,
  135|  86.4k|                                        255,
  136|  86.4k|                                        255,
  137|  86.4k|                                        255,
  138|  86.4k|                                        255,
  139|  86.4k|                                        255,
  140|  86.4k|                                        255,
  141|  86.4k|                                        255,
  142|  86.4k|                                        255,
  143|  86.4k|                                        255,
  144|  86.4k|                                        255,
  145|  86.4k|                                        255,
  146|  86.4k|                                        255,
  147|  86.4k|                                        255,
  148|  86.4k|                                        0b11110000u - 1,
  149|  86.4k|                                        0b11100000u - 1,
  150|  86.4k|                                        0b11000000u - 1};
  151|  86.4k|  const simd8<uint8_t> max_value(
  152|  86.4k|      &max_array[sizeof(max_array) - sizeof(simd8<uint8_t>)]);
  153|  86.4k|  return input.gt_bits(max_value);
  154|  86.4k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115utf8_validation12utf8_checker23check_overlapping_inputERKNS1_4simd8simd8x64IhEENS4_5simd8IhEE:
  246|    404|                          const simd8<uint8_t> prev_input) {
  247|    404|    this->prev_input_block = prev_input;
  248|    404|    this->check_next_input(input);
  249|    404|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_115utf8_validation12utf8_checker6errorsEv:
  252|  19.7k|  simdutf_really_inline bool errors() const {
  253|  19.7k|    return this->error.any_bits_set_anywhere();
  254|  19.7k|  }

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115utf8_validation21generic_validate_utf8EPKcm:
   65|  1.13k|bool generic_validate_utf8(const char *input, size_t length) {
   66|  1.13k|  return generic_validate_utf8<utf8_checker>(
   67|  1.13k|      reinterpret_cast<const uint8_t *>(input), length);
   68|  1.13k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115utf8_validation21generic_validate_utf8INS2_12utf8_checkerEEEbPKhm:
   46|  1.13k|bool generic_validate_utf8(const uint8_t *input, size_t length) {
   47|  1.13k|  checker c{};
   48|  1.13k|  buf_block_reader<64> reader(input, length);
   49|  1.13k|  size_t next_check = 1024;
   50|   221k|  while (reader.has_full_block()) {
  ------------------
  |  Branch (50:10): [True: 220k, False: 1.04k]
  ------------------
   51|   220k|    simd::simd8x64<uint8_t> in(reader.full_block());
   52|   220k|    if (!c.check_next_input(in) &&
  ------------------
  |  Branch (52:9): [True: 78.2k, False: 142k]
  ------------------
   53|  78.2k|        simdutf_unlikely(reader.block_index() >= next_check)) {
  ------------------
  |  |   93|  78.2k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 5.00k, False: 73.2k]
  |  |  ------------------
  ------------------
   54|  5.00k|      if (c.errors()) {
  ------------------
  |  Branch (54:11): [True: 91, False: 4.91k]
  ------------------
   55|     91|        return false;
   56|     91|      }
   57|  4.91k|      next_check = reader.block_index() + 1024;
   58|  4.91k|    }
   59|   220k|    reader.advance();
   60|   220k|  }
   61|  1.04k|  check_remainder(c, input, length, reader.block_index());
   62|  1.04k|  return !c.errors();
   63|  1.13k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115utf8_validation15check_remainderINS2_12utf8_checkerEEEvRT_PKhmm:
   15|  1.25k|                                           size_t length, size_t idx) {
   16|  1.25k|  constexpr size_t block = sizeof(simd::simd8x64<uint8_t>);
   17|  1.25k|  constexpr size_t width = sizeof(simd::simd8<uint8_t>);
   18|  1.25k|  static_assert(block == 8 * sizeof(uint64_t), "one mask bit per byte");
   19|  1.25k|  if (length >= block + width) {
  ------------------
  |  Branch (19:7): [True: 437, False: 816]
  ------------------
   20|       |    // The window starts at or before idx: buf_block_reader leaves 1 to 64
   21|       |    // bytes, so 0 <= idx - start < 64.
   22|    437|    const size_t start = length - block;
   23|    437|    const simd::simd8x64<uint8_t> in(input + start);
   24|       |    // Bit i is set if byte start + i is not ASCII, so the bytes from idx on
   25|       |    // are the top length - idx bits. is_ascii() goes first because GCC, up
   26|       |    // to at least GCC 17, builds gteq_unsigned(0x80) from min and compare
   27|       |    // instead of one movemask, which costs ASCII tails about 0.5 ns.
   28|    437|    if (!in.is_ascii() && (in.gteq_unsigned(0x80) >> (idx - start)) != 0) {
  ------------------
  |  Branch (28:9): [True: 368, False: 69]
  |  Branch (28:27): [True: 347, False: 21]
  ------------------
   29|    347|      c.check_overlapping_input(in,
   30|    347|                                simd::simd8<uint8_t>(input + start - width));
   31|    347|    }
   32|    816|  } else if (idx != length) {
  ------------------
  |  Branch (32:14): [True: 815, False: 1]
  ------------------
   33|       |    // Only an empty input leaves no bytes. Its pointer may be null, and
   34|       |    // memcpy from a null pointer is undefined.
   35|    815|    uint8_t buffer[block]{};
   36|    815|    std::memcpy(buffer, input + idx, length - idx);
   37|    815|    c.check_next_input(simd::simd8x64<uint8_t>(buffer));
   38|    815|  }
   39|  1.25k|  c.check_eof();
   40|  1.25k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115utf8_validation21generic_validate_utf8EPKcm:
   65|  1.13k|bool generic_validate_utf8(const char *input, size_t length) {
   66|  1.13k|  return generic_validate_utf8<utf8_checker>(
   67|  1.13k|      reinterpret_cast<const uint8_t *>(input), length);
   68|  1.13k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115utf8_validation21generic_validate_utf8INS2_12utf8_checkerEEEbPKhm:
   46|  1.13k|bool generic_validate_utf8(const uint8_t *input, size_t length) {
   47|  1.13k|  checker c{};
   48|  1.13k|  buf_block_reader<64> reader(input, length);
   49|  1.13k|  size_t next_check = 1024;
   50|   221k|  while (reader.has_full_block()) {
  ------------------
  |  Branch (50:10): [True: 220k, False: 1.04k]
  ------------------
   51|   220k|    simd::simd8x64<uint8_t> in(reader.full_block());
   52|   220k|    if (!c.check_next_input(in) &&
  ------------------
  |  Branch (52:9): [True: 78.2k, False: 142k]
  ------------------
   53|  78.2k|        simdutf_unlikely(reader.block_index() >= next_check)) {
  ------------------
  |  |   93|  78.2k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 5.00k, False: 73.2k]
  |  |  ------------------
  ------------------
   54|  5.00k|      if (c.errors()) {
  ------------------
  |  Branch (54:11): [True: 91, False: 4.91k]
  ------------------
   55|     91|        return false;
   56|     91|      }
   57|  4.91k|      next_check = reader.block_index() + 1024;
   58|  4.91k|    }
   59|   220k|    reader.advance();
   60|   220k|  }
   61|  1.04k|  check_remainder(c, input, length, reader.block_index());
   62|  1.04k|  return !c.errors();
   63|  1.13k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115utf8_validation15check_remainderINS2_12utf8_checkerEEEvRT_PKhmm:
   15|  1.25k|                                           size_t length, size_t idx) {
   16|  1.25k|  constexpr size_t block = sizeof(simd::simd8x64<uint8_t>);
   17|  1.25k|  constexpr size_t width = sizeof(simd::simd8<uint8_t>);
   18|  1.25k|  static_assert(block == 8 * sizeof(uint64_t), "one mask bit per byte");
   19|  1.25k|  if (length >= block + width) {
  ------------------
  |  Branch (19:7): [True: 500, False: 753]
  ------------------
   20|       |    // The window starts at or before idx: buf_block_reader leaves 1 to 64
   21|       |    // bytes, so 0 <= idx - start < 64.
   22|    500|    const size_t start = length - block;
   23|    500|    const simd::simd8x64<uint8_t> in(input + start);
   24|       |    // Bit i is set if byte start + i is not ASCII, so the bytes from idx on
   25|       |    // are the top length - idx bits. is_ascii() goes first because GCC, up
   26|       |    // to at least GCC 17, builds gteq_unsigned(0x80) from min and compare
   27|       |    // instead of one movemask, which costs ASCII tails about 0.5 ns.
   28|    500|    if (!in.is_ascii() && (in.gteq_unsigned(0x80) >> (idx - start)) != 0) {
  ------------------
  |  Branch (28:9): [True: 428, False: 72]
  |  Branch (28:27): [True: 404, False: 24]
  ------------------
   29|    404|      c.check_overlapping_input(in,
   30|    404|                                simd::simd8<uint8_t>(input + start - width));
   31|    404|    }
   32|    753|  } else if (idx != length) {
  ------------------
  |  Branch (32:14): [True: 752, False: 1]
  ------------------
   33|       |    // Only an empty input leaves no bytes. Its pointer may be null, and
   34|       |    // memcpy from a null pointer is undefined.
   35|    752|    uint8_t buffer[block]{};
   36|    752|    std::memcpy(buffer, input + idx, length - idx);
   37|    752|    c.check_next_input(simd::simd8x64<uint8_t>(buffer));
   38|    752|  }
   39|  1.25k|  c.check_eof();
   40|  1.25k|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf1635validate_utf16_as_ascii_with_errorsILNS_10endiannessE0EEEKNS_6resultEPKDsm:
  136|    258|                                                 size_t size) {
  137|    258|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|    258|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 1, False: 257]
  |  |  ------------------
  ------------------
  138|      1|    return result(error_code::SUCCESS, 0);
  139|      1|  }
  140|    257|  size_t pos = 0;
  141|  1.31k|  for (; pos < size / 32 * 32; pos += 32) {
  ------------------
  |  Branch (141:10): [True: 1.22k, False: 90]
  ------------------
  142|  1.22k|    simd16x32<uint16_t> input_vec(
  143|  1.22k|        reinterpret_cast<const uint16_t *>(input + pos));
  144|       |    if constexpr (!match_system(big_endian)) {
  145|       |      input_vec.swap_bytes();
  146|       |    }
  147|  1.22k|    uint64_t matches = input_vec.lteq(uint16_t(0x7f));
  148|  1.22k|    if (~matches) {
  ------------------
  |  Branch (148:9): [True: 167, False: 1.06k]
  ------------------
  149|       |      // Found a match, return the first one
  150|    167|      int index = trailing_zeroes(~matches) / 2;
  151|    167|      return result(error_code::TOO_LARGE, pos + index);
  152|    167|    }
  153|  1.22k|  }
  154|       |
  155|       |  // Scalar tail
  156|    749|  while (pos < size) {
  ------------------
  |  Branch (156:10): [True: 716, False: 33]
  ------------------
  157|       |
  158|    716|    char16_t v = scalar::utf16::swap_if_needed<big_endian>(input[pos]);
  159|    716|    if (v > 0x7F) {
  ------------------
  |  Branch (159:9): [True: 57, False: 659]
  ------------------
  160|     57|      return result(error_code::TOO_LARGE, pos);
  161|     57|    }
  162|    659|    pos++;
  163|    659|  }
  164|     33|  return result(error_code::SUCCESS, size);
  165|     90|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf1635validate_utf16_as_ascii_with_errorsILNS_10endiannessE1EEEKNS_6resultEPKDsm:
  136|    261|                                                 size_t size) {
  137|    261|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|    261|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 1, False: 260]
  |  |  ------------------
  ------------------
  138|      1|    return result(error_code::SUCCESS, 0);
  139|      1|  }
  140|    260|  size_t pos = 0;
  141|  2.45k|  for (; pos < size / 32 * 32; pos += 32) {
  ------------------
  |  Branch (141:10): [True: 2.36k, False: 90]
  ------------------
  142|  2.36k|    simd16x32<uint16_t> input_vec(
  143|  2.36k|        reinterpret_cast<const uint16_t *>(input + pos));
  144|  2.36k|    if constexpr (!match_system(big_endian)) {
  145|  2.36k|      input_vec.swap_bytes();
  146|  2.36k|    }
  147|  2.36k|    uint64_t matches = input_vec.lteq(uint16_t(0x7f));
  148|  2.36k|    if (~matches) {
  ------------------
  |  Branch (148:9): [True: 170, False: 2.19k]
  ------------------
  149|       |      // Found a match, return the first one
  150|    170|      int index = trailing_zeroes(~matches) / 2;
  151|    170|      return result(error_code::TOO_LARGE, pos + index);
  152|    170|    }
  153|  2.36k|  }
  154|       |
  155|       |  // Scalar tail
  156|    782|  while (pos < size) {
  ------------------
  |  Branch (156:10): [True: 746, False: 36]
  ------------------
  157|       |
  158|    746|    char16_t v = scalar::utf16::swap_if_needed<big_endian>(input[pos]);
  159|    746|    if (v > 0x7F) {
  ------------------
  |  Branch (159:9): [True: 54, False: 692]
  ------------------
  160|     54|      return result(error_code::TOO_LARGE, pos);
  161|     54|    }
  162|    692|    pos++;
  163|    692|  }
  164|     36|  return result(error_code::SUCCESS, size);
  165|     90|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf1626validate_utf16_with_errorsILNS_10endiannessE0EEEKNS_6resultEPKDsm:
   49|  2.47k|const result validate_utf16_with_errors(const char16_t *input, size_t size) {
   50|  2.47k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  2.47k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 0, False: 2.47k]
  |  |  ------------------
  ------------------
   51|      0|    return result(error_code::SUCCESS, 0);
   52|      0|  }
   53|       |
   54|  2.47k|  const char16_t *start = input;
   55|  2.47k|  const char16_t *end = input + size;
   56|       |
   57|  2.47k|  const auto v_d8 = simd8<uint8_t>::splat(0xd8);
   58|  2.47k|  const auto v_f8 = simd8<uint8_t>::splat(0xf8);
   59|  2.47k|  const auto v_fc = simd8<uint8_t>::splat(0xfc);
   60|  2.47k|  const auto v_dc = simd8<uint8_t>::splat(0xdc);
   61|       |
   62|       |  // Each iteration gathers the high bytes of two registers into one byte
   63|       |  // register: N code units, one mask bit each.
   64|  2.47k|  constexpr size_t N = simd16<uint16_t>::SIZE;
   65|  2.47k|  static_assert(N == 16 || N == 32, "one mask bit per code unit");
   66|  2.47k|  using mask_t = std::conditional_t<N == 32, uint32_t, uint16_t>;
   67|  2.47k|  constexpr mask_t all = mask_t(~mask_t(0));
   68|       |
   69|   708k|  while (input + N <= end) {
  ------------------
  |  Branch (69:10): [True: 706k, False: 2.05k]
  ------------------
   70|       |    // 0. Load data: since the validation takes into account only higher
   71|       |    //    byte of each word, we compress the two vectors into one which
   72|       |    //    consists only the higher bytes.
   73|   706k|    auto in0 = simd16<uint16_t>(input);
   74|   706k|    auto in1 = simd16<uint16_t>(input + N / 2);
   75|       |
   76|       |    // Function `utf16_gather_high_bytes` consumes two vectors of UTF-16
   77|       |    // and yields a single vector having only higher bytes of characters.
   78|   706k|    const auto in = utf16_gather_high_bytes<big_endian>(in0, in1);
   79|       |
   80|       |    // 1. Check whether we have any 0xD800..DFFF word (0b1101'1xxx'yyyy'yyyy).
   81|   706k|    const auto surrogates_wordmask = (in & v_f8) == v_d8;
   82|   706k|    const mask_t surrogates_bitmask =
   83|   706k|        static_cast<mask_t>(surrogates_wordmask.to_bitmask());
   84|   706k|    if (surrogates_bitmask == 0) {
  ------------------
  |  Branch (84:9): [True: 691k, False: 14.8k]
  ------------------
   85|   691k|      input += N;
   86|   691k|    } else {
   87|       |      // 2. We have some surrogates that have to be distinguished:
   88|       |      //    - low  surrogates: 0b1101'10xx'yyyy'yyyy (0xD800..0xDBFF)
   89|       |      //    - high surrogates: 0b1101'11xx'yyyy'yyyy (0xDC00..0xDFFF)
   90|       |      //
   91|       |      //    Fact: high surrogate has 11th bit set (3rd bit in the higher byte)
   92|       |
   93|       |      // V - non-surrogate code units
   94|       |      //     V = not surrogates_wordmask
   95|  14.8k|      const mask_t V = static_cast<mask_t>(~surrogates_bitmask);
   96|       |
   97|       |      // H - word-mask for high surrogates: the six highest bits are 0b1101'11
   98|  14.8k|      const auto vH = (in & v_fc) == v_dc;
   99|  14.8k|      const mask_t H = static_cast<mask_t>(vH.to_bitmask());
  100|       |
  101|       |      // L - word mask for low surrogates
  102|       |      //     L = not H and surrogates_wordmask
  103|  14.8k|      const mask_t L = static_cast<mask_t>(~H & surrogates_bitmask);
  104|       |
  105|  14.8k|      const mask_t a = static_cast<mask_t>(
  106|  14.8k|          L & (H >> 1)); // A low surrogate must be followed by high one.
  107|       |                         // (A low surrogate placed in the 7th register's word
  108|       |                         // is an exception we handle.)
  109|  14.8k|      const mask_t b = static_cast<mask_t>(
  110|  14.8k|          a << 1); // Just mark that the opinput - startite fact is hold,
  111|       |                   // thanks to that we have only two masks for valid case.
  112|  14.8k|      const mask_t c = static_cast<mask_t>(
  113|  14.8k|          V | a | b); // Combine all the masks into the final one.
  114|       |
  115|  14.8k|      if (c == all) {
  ------------------
  |  Branch (115:11): [True: 12.9k, False: 1.91k]
  ------------------
  116|       |        // The whole input register contains valid UTF-16, i.e.,
  117|       |        // either single code units or proper surrogate pairs.
  118|  12.9k|        input += N;
  119|  12.9k|      } else if (c == all >> 1) {
  ------------------
  |  Branch (119:18): [True: 1.48k, False: 423]
  ------------------
  120|       |        // The N - 1 lower code units of the input register contain valid
  121|       |        // UTF-16. The last word may be either a low or high surrogate. In the
  122|       |        // next iteration we 1) check if the low surrogate is followed by a
  123|       |        // high one, 2) reject sole high surrogate.
  124|  1.48k|        input += N - 1;
  125|  1.48k|      } else {
  126|    423|        return result(error_code::SURROGATE, input - start);
  127|    423|      }
  128|  14.8k|    }
  129|   706k|  }
  130|       |
  131|  2.05k|  return result(error_code::SUCCESS, input - start);
  132|  2.47k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf1626validate_utf16_with_errorsILNS_10endiannessE1EEEKNS_6resultEPKDsm:
   49|  1.74k|const result validate_utf16_with_errors(const char16_t *input, size_t size) {
   50|  1.74k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  1.74k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 0, False: 1.74k]
  |  |  ------------------
  ------------------
   51|      0|    return result(error_code::SUCCESS, 0);
   52|      0|  }
   53|       |
   54|  1.74k|  const char16_t *start = input;
   55|  1.74k|  const char16_t *end = input + size;
   56|       |
   57|  1.74k|  const auto v_d8 = simd8<uint8_t>::splat(0xd8);
   58|  1.74k|  const auto v_f8 = simd8<uint8_t>::splat(0xf8);
   59|  1.74k|  const auto v_fc = simd8<uint8_t>::splat(0xfc);
   60|  1.74k|  const auto v_dc = simd8<uint8_t>::splat(0xdc);
   61|       |
   62|       |  // Each iteration gathers the high bytes of two registers into one byte
   63|       |  // register: N code units, one mask bit each.
   64|  1.74k|  constexpr size_t N = simd16<uint16_t>::SIZE;
   65|  1.74k|  static_assert(N == 16 || N == 32, "one mask bit per code unit");
   66|  1.74k|  using mask_t = std::conditional_t<N == 32, uint32_t, uint16_t>;
   67|  1.74k|  constexpr mask_t all = mask_t(~mask_t(0));
   68|       |
   69|   514k|  while (input + N <= end) {
  ------------------
  |  Branch (69:10): [True: 512k, False: 1.49k]
  ------------------
   70|       |    // 0. Load data: since the validation takes into account only higher
   71|       |    //    byte of each word, we compress the two vectors into one which
   72|       |    //    consists only the higher bytes.
   73|   512k|    auto in0 = simd16<uint16_t>(input);
   74|   512k|    auto in1 = simd16<uint16_t>(input + N / 2);
   75|       |
   76|       |    // Function `utf16_gather_high_bytes` consumes two vectors of UTF-16
   77|       |    // and yields a single vector having only higher bytes of characters.
   78|   512k|    const auto in = utf16_gather_high_bytes<big_endian>(in0, in1);
   79|       |
   80|       |    // 1. Check whether we have any 0xD800..DFFF word (0b1101'1xxx'yyyy'yyyy).
   81|   512k|    const auto surrogates_wordmask = (in & v_f8) == v_d8;
   82|   512k|    const mask_t surrogates_bitmask =
   83|   512k|        static_cast<mask_t>(surrogates_wordmask.to_bitmask());
   84|   512k|    if (surrogates_bitmask == 0) {
  ------------------
  |  Branch (84:9): [True: 498k, False: 14.9k]
  ------------------
   85|   498k|      input += N;
   86|   498k|    } else {
   87|       |      // 2. We have some surrogates that have to be distinguished:
   88|       |      //    - low  surrogates: 0b1101'10xx'yyyy'yyyy (0xD800..0xDBFF)
   89|       |      //    - high surrogates: 0b1101'11xx'yyyy'yyyy (0xDC00..0xDFFF)
   90|       |      //
   91|       |      //    Fact: high surrogate has 11th bit set (3rd bit in the higher byte)
   92|       |
   93|       |      // V - non-surrogate code units
   94|       |      //     V = not surrogates_wordmask
   95|  14.9k|      const mask_t V = static_cast<mask_t>(~surrogates_bitmask);
   96|       |
   97|       |      // H - word-mask for high surrogates: the six highest bits are 0b1101'11
   98|  14.9k|      const auto vH = (in & v_fc) == v_dc;
   99|  14.9k|      const mask_t H = static_cast<mask_t>(vH.to_bitmask());
  100|       |
  101|       |      // L - word mask for low surrogates
  102|       |      //     L = not H and surrogates_wordmask
  103|  14.9k|      const mask_t L = static_cast<mask_t>(~H & surrogates_bitmask);
  104|       |
  105|  14.9k|      const mask_t a = static_cast<mask_t>(
  106|  14.9k|          L & (H >> 1)); // A low surrogate must be followed by high one.
  107|       |                         // (A low surrogate placed in the 7th register's word
  108|       |                         // is an exception we handle.)
  109|  14.9k|      const mask_t b = static_cast<mask_t>(
  110|  14.9k|          a << 1); // Just mark that the opinput - startite fact is hold,
  111|       |                   // thanks to that we have only two masks for valid case.
  112|  14.9k|      const mask_t c = static_cast<mask_t>(
  113|  14.9k|          V | a | b); // Combine all the masks into the final one.
  114|       |
  115|  14.9k|      if (c == all) {
  ------------------
  |  Branch (115:11): [True: 13.2k, False: 1.73k]
  ------------------
  116|       |        // The whole input register contains valid UTF-16, i.e.,
  117|       |        // either single code units or proper surrogate pairs.
  118|  13.2k|        input += N;
  119|  13.2k|      } else if (c == all >> 1) {
  ------------------
  |  Branch (119:18): [True: 1.49k, False: 242]
  ------------------
  120|       |        // The N - 1 lower code units of the input register contain valid
  121|       |        // UTF-16. The last word may be either a low or high surrogate. In the
  122|       |        // next iteration we 1) check if the low surrogate is followed by a
  123|       |        // high one, 2) reject sole high surrogate.
  124|  1.49k|        input += N - 1;
  125|  1.49k|      } else {
  126|    242|        return result(error_code::SURROGATE, input - start);
  127|    242|      }
  128|  14.9k|    }
  129|   512k|  }
  130|       |
  131|  1.49k|  return result(error_code::SUCCESS, input - start);
  132|  1.74k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf1635validate_utf16_as_ascii_with_errorsILNS_10endiannessE0EEEKNS_6resultEPKDsm:
  136|    244|                                                 size_t size) {
  137|    244|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|    244|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 1, False: 243]
  |  |  ------------------
  ------------------
  138|      1|    return result(error_code::SUCCESS, 0);
  139|      1|  }
  140|    243|  size_t pos = 0;
  141|  1.31k|  for (; pos < size / 32 * 32; pos += 32) {
  ------------------
  |  Branch (141:10): [True: 1.26k, False: 48]
  ------------------
  142|  1.26k|    simd16x32<uint16_t> input_vec(
  143|  1.26k|        reinterpret_cast<const uint16_t *>(input + pos));
  144|       |    if constexpr (!match_system(big_endian)) {
  145|       |      input_vec.swap_bytes();
  146|       |    }
  147|  1.26k|    uint64_t matches = input_vec.lteq(uint16_t(0x7f));
  148|  1.26k|    if (~matches) {
  ------------------
  |  Branch (148:9): [True: 195, False: 1.07k]
  ------------------
  149|       |      // Found a match, return the first one
  150|    195|      int index = trailing_zeroes(~matches) / 2;
  151|    195|      return result(error_code::TOO_LARGE, pos + index);
  152|    195|    }
  153|  1.26k|  }
  154|       |
  155|       |  // Scalar tail
  156|    158|  while (pos < size) {
  ------------------
  |  Branch (156:10): [True: 139, False: 19]
  ------------------
  157|       |
  158|    139|    char16_t v = scalar::utf16::swap_if_needed<big_endian>(input[pos]);
  159|    139|    if (v > 0x7F) {
  ------------------
  |  Branch (159:9): [True: 29, False: 110]
  ------------------
  160|     29|      return result(error_code::TOO_LARGE, pos);
  161|     29|    }
  162|    110|    pos++;
  163|    110|  }
  164|     19|  return result(error_code::SUCCESS, size);
  165|     48|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf1635validate_utf16_as_ascii_with_errorsILNS_10endiannessE1EEEKNS_6resultEPKDsm:
  136|    244|                                                 size_t size) {
  137|    244|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|    244|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 1, False: 243]
  |  |  ------------------
  ------------------
  138|      1|    return result(error_code::SUCCESS, 0);
  139|      1|  }
  140|    243|  size_t pos = 0;
  141|  2.45k|  for (; pos < size / 32 * 32; pos += 32) {
  ------------------
  |  Branch (141:10): [True: 2.40k, False: 48]
  ------------------
  142|  2.40k|    simd16x32<uint16_t> input_vec(
  143|  2.40k|        reinterpret_cast<const uint16_t *>(input + pos));
  144|  2.40k|    if constexpr (!match_system(big_endian)) {
  145|  2.40k|      input_vec.swap_bytes();
  146|  2.40k|    }
  147|  2.40k|    uint64_t matches = input_vec.lteq(uint16_t(0x7f));
  148|  2.40k|    if (~matches) {
  ------------------
  |  Branch (148:9): [True: 195, False: 2.21k]
  ------------------
  149|       |      // Found a match, return the first one
  150|    195|      int index = trailing_zeroes(~matches) / 2;
  151|    195|      return result(error_code::TOO_LARGE, pos + index);
  152|    195|    }
  153|  2.40k|  }
  154|       |
  155|       |  // Scalar tail
  156|    165|  while (pos < size) {
  ------------------
  |  Branch (156:10): [True: 146, False: 19]
  ------------------
  157|       |
  158|    146|    char16_t v = scalar::utf16::swap_if_needed<big_endian>(input[pos]);
  159|    146|    if (v > 0x7F) {
  ------------------
  |  Branch (159:9): [True: 29, False: 117]
  ------------------
  160|     29|      return result(error_code::TOO_LARGE, pos);
  161|     29|    }
  162|    117|    pos++;
  163|    117|  }
  164|     19|  return result(error_code::SUCCESS, size);
  165|     48|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf1626validate_utf16_with_errorsILNS_10endiannessE0EEEKNS_6resultEPKDsm:
   49|  1.67k|const result validate_utf16_with_errors(const char16_t *input, size_t size) {
   50|  1.67k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  1.67k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 0, False: 1.67k]
  |  |  ------------------
  ------------------
   51|      0|    return result(error_code::SUCCESS, 0);
   52|      0|  }
   53|       |
   54|  1.67k|  const char16_t *start = input;
   55|  1.67k|  const char16_t *end = input + size;
   56|       |
   57|  1.67k|  const auto v_d8 = simd8<uint8_t>::splat(0xd8);
   58|  1.67k|  const auto v_f8 = simd8<uint8_t>::splat(0xf8);
   59|  1.67k|  const auto v_fc = simd8<uint8_t>::splat(0xfc);
   60|  1.67k|  const auto v_dc = simd8<uint8_t>::splat(0xdc);
   61|       |
   62|       |  // Each iteration gathers the high bytes of two registers into one byte
   63|       |  // register: N code units, one mask bit each.
   64|  1.67k|  constexpr size_t N = simd16<uint16_t>::SIZE;
   65|  1.67k|  static_assert(N == 16 || N == 32, "one mask bit per code unit");
   66|  1.67k|  using mask_t = std::conditional_t<N == 32, uint32_t, uint16_t>;
   67|  1.67k|  constexpr mask_t all = mask_t(~mask_t(0));
   68|       |
   69|  1.30M|  while (input + N <= end) {
  ------------------
  |  Branch (69:10): [True: 1.30M, False: 1.34k]
  ------------------
   70|       |    // 0. Load data: since the validation takes into account only higher
   71|       |    //    byte of each word, we compress the two vectors into one which
   72|       |    //    consists only the higher bytes.
   73|  1.30M|    auto in0 = simd16<uint16_t>(input);
   74|  1.30M|    auto in1 = simd16<uint16_t>(input + N / 2);
   75|       |
   76|       |    // Function `utf16_gather_high_bytes` consumes two vectors of UTF-16
   77|       |    // and yields a single vector having only higher bytes of characters.
   78|  1.30M|    const auto in = utf16_gather_high_bytes<big_endian>(in0, in1);
   79|       |
   80|       |    // 1. Check whether we have any 0xD800..DFFF word (0b1101'1xxx'yyyy'yyyy).
   81|  1.30M|    const auto surrogates_wordmask = (in & v_f8) == v_d8;
   82|  1.30M|    const mask_t surrogates_bitmask =
   83|  1.30M|        static_cast<mask_t>(surrogates_wordmask.to_bitmask());
   84|  1.30M|    if (surrogates_bitmask == 0) {
  ------------------
  |  Branch (84:9): [True: 1.28M, False: 21.1k]
  ------------------
   85|  1.28M|      input += N;
   86|  1.28M|    } else {
   87|       |      // 2. We have some surrogates that have to be distinguished:
   88|       |      //    - low  surrogates: 0b1101'10xx'yyyy'yyyy (0xD800..0xDBFF)
   89|       |      //    - high surrogates: 0b1101'11xx'yyyy'yyyy (0xDC00..0xDFFF)
   90|       |      //
   91|       |      //    Fact: high surrogate has 11th bit set (3rd bit in the higher byte)
   92|       |
   93|       |      // V - non-surrogate code units
   94|       |      //     V = not surrogates_wordmask
   95|  21.1k|      const mask_t V = static_cast<mask_t>(~surrogates_bitmask);
   96|       |
   97|       |      // H - word-mask for high surrogates: the six highest bits are 0b1101'11
   98|  21.1k|      const auto vH = (in & v_fc) == v_dc;
   99|  21.1k|      const mask_t H = static_cast<mask_t>(vH.to_bitmask());
  100|       |
  101|       |      // L - word mask for low surrogates
  102|       |      //     L = not H and surrogates_wordmask
  103|  21.1k|      const mask_t L = static_cast<mask_t>(~H & surrogates_bitmask);
  104|       |
  105|  21.1k|      const mask_t a = static_cast<mask_t>(
  106|  21.1k|          L & (H >> 1)); // A low surrogate must be followed by high one.
  107|       |                         // (A low surrogate placed in the 7th register's word
  108|       |                         // is an exception we handle.)
  109|  21.1k|      const mask_t b = static_cast<mask_t>(
  110|  21.1k|          a << 1); // Just mark that the opinput - startite fact is hold,
  111|       |                   // thanks to that we have only two masks for valid case.
  112|  21.1k|      const mask_t c = static_cast<mask_t>(
  113|  21.1k|          V | a | b); // Combine all the masks into the final one.
  114|       |
  115|  21.1k|      if (c == all) {
  ------------------
  |  Branch (115:11): [True: 17.7k, False: 3.36k]
  ------------------
  116|       |        // The whole input register contains valid UTF-16, i.e.,
  117|       |        // either single code units or proper surrogate pairs.
  118|  17.7k|        input += N;
  119|  17.7k|      } else if (c == all >> 1) {
  ------------------
  |  Branch (119:18): [True: 3.03k, False: 331]
  ------------------
  120|       |        // The N - 1 lower code units of the input register contain valid
  121|       |        // UTF-16. The last word may be either a low or high surrogate. In the
  122|       |        // next iteration we 1) check if the low surrogate is followed by a
  123|       |        // high one, 2) reject sole high surrogate.
  124|  3.03k|        input += N - 1;
  125|  3.03k|      } else {
  126|    331|        return result(error_code::SURROGATE, input - start);
  127|    331|      }
  128|  21.1k|    }
  129|  1.30M|  }
  130|       |
  131|  1.34k|  return result(error_code::SUCCESS, input - start);
  132|  1.67k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf1626validate_utf16_with_errorsILNS_10endiannessE1EEEKNS_6resultEPKDsm:
   49|    927|const result validate_utf16_with_errors(const char16_t *input, size_t size) {
   50|    927|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|    927|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 0, False: 927]
  |  |  ------------------
  ------------------
   51|      0|    return result(error_code::SUCCESS, 0);
   52|      0|  }
   53|       |
   54|    927|  const char16_t *start = input;
   55|    927|  const char16_t *end = input + size;
   56|       |
   57|    927|  const auto v_d8 = simd8<uint8_t>::splat(0xd8);
   58|    927|  const auto v_f8 = simd8<uint8_t>::splat(0xf8);
   59|    927|  const auto v_fc = simd8<uint8_t>::splat(0xfc);
   60|    927|  const auto v_dc = simd8<uint8_t>::splat(0xdc);
   61|       |
   62|       |  // Each iteration gathers the high bytes of two registers into one byte
   63|       |  // register: N code units, one mask bit each.
   64|    927|  constexpr size_t N = simd16<uint16_t>::SIZE;
   65|    927|  static_assert(N == 16 || N == 32, "one mask bit per code unit");
   66|    927|  using mask_t = std::conditional_t<N == 32, uint32_t, uint16_t>;
   67|    927|  constexpr mask_t all = mask_t(~mask_t(0));
   68|       |
   69|   917k|  while (input + N <= end) {
  ------------------
  |  Branch (69:10): [True: 916k, False: 927]
  ------------------
   70|       |    // 0. Load data: since the validation takes into account only higher
   71|       |    //    byte of each word, we compress the two vectors into one which
   72|       |    //    consists only the higher bytes.
   73|   916k|    auto in0 = simd16<uint16_t>(input);
   74|   916k|    auto in1 = simd16<uint16_t>(input + N / 2);
   75|       |
   76|       |    // Function `utf16_gather_high_bytes` consumes two vectors of UTF-16
   77|       |    // and yields a single vector having only higher bytes of characters.
   78|   916k|    const auto in = utf16_gather_high_bytes<big_endian>(in0, in1);
   79|       |
   80|       |    // 1. Check whether we have any 0xD800..DFFF word (0b1101'1xxx'yyyy'yyyy).
   81|   916k|    const auto surrogates_wordmask = (in & v_f8) == v_d8;
   82|   916k|    const mask_t surrogates_bitmask =
   83|   916k|        static_cast<mask_t>(surrogates_wordmask.to_bitmask());
   84|   916k|    if (surrogates_bitmask == 0) {
  ------------------
  |  Branch (84:9): [True: 894k, False: 21.3k]
  ------------------
   85|   894k|      input += N;
   86|   894k|    } else {
   87|       |      // 2. We have some surrogates that have to be distinguished:
   88|       |      //    - low  surrogates: 0b1101'10xx'yyyy'yyyy (0xD800..0xDBFF)
   89|       |      //    - high surrogates: 0b1101'11xx'yyyy'yyyy (0xDC00..0xDFFF)
   90|       |      //
   91|       |      //    Fact: high surrogate has 11th bit set (3rd bit in the higher byte)
   92|       |
   93|       |      // V - non-surrogate code units
   94|       |      //     V = not surrogates_wordmask
   95|  21.3k|      const mask_t V = static_cast<mask_t>(~surrogates_bitmask);
   96|       |
   97|       |      // H - word-mask for high surrogates: the six highest bits are 0b1101'11
   98|  21.3k|      const auto vH = (in & v_fc) == v_dc;
   99|  21.3k|      const mask_t H = static_cast<mask_t>(vH.to_bitmask());
  100|       |
  101|       |      // L - word mask for low surrogates
  102|       |      //     L = not H and surrogates_wordmask
  103|  21.3k|      const mask_t L = static_cast<mask_t>(~H & surrogates_bitmask);
  104|       |
  105|  21.3k|      const mask_t a = static_cast<mask_t>(
  106|  21.3k|          L & (H >> 1)); // A low surrogate must be followed by high one.
  107|       |                         // (A low surrogate placed in the 7th register's word
  108|       |                         // is an exception we handle.)
  109|  21.3k|      const mask_t b = static_cast<mask_t>(
  110|  21.3k|          a << 1); // Just mark that the opinput - startite fact is hold,
  111|       |                   // thanks to that we have only two masks for valid case.
  112|  21.3k|      const mask_t c = static_cast<mask_t>(
  113|  21.3k|          V | a | b); // Combine all the masks into the final one.
  114|       |
  115|  21.3k|      if (c == all) {
  ------------------
  |  Branch (115:11): [True: 18.0k, False: 3.27k]
  ------------------
  116|       |        // The whole input register contains valid UTF-16, i.e.,
  117|       |        // either single code units or proper surrogate pairs.
  118|  18.0k|        input += N;
  119|  18.0k|      } else if (c == all >> 1) {
  ------------------
  |  Branch (119:18): [True: 3.27k, False: 0]
  ------------------
  120|       |        // The N - 1 lower code units of the input register contain valid
  121|       |        // UTF-16. The last word may be either a low or high surrogate. In the
  122|       |        // next iteration we 1) check if the low surrogate is followed by a
  123|       |        // high one, 2) reject sole high surrogate.
  124|  3.27k|        input += N - 1;
  125|  3.27k|      } else {
  126|      0|        return result(error_code::SURROGATE, input - start);
  127|      0|      }
  128|  21.3k|    }
  129|   916k|  }
  130|       |
  131|    927|  return result(error_code::SUCCESS, input - start);
  132|    927|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf328validateEPKDim:
    6|    459|simdutf_really_inline bool validate(const char32_t *input, size_t size) {
    7|    459|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|    459|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 0, False: 459]
  |  |  ------------------
  ------------------
    8|       |    // empty input is valid UTF-32. protect the implementation from
    9|       |    // handling nullptr
   10|      0|    return true;
   11|      0|  }
   12|       |
   13|    459|  const char32_t *end = input + size;
   14|       |
   15|    459|  using vector_u32 = simd32<uint32_t>;
   16|       |
   17|    459|  const auto standardmax = vector_u32::splat(0x10ffff);
   18|    459|  const auto offset = vector_u32::splat(0xffff2000);
   19|    459|  const auto standardoffsetmax = vector_u32::splat(0xfffff7ff);
   20|    459|  auto currentmax = vector_u32::zero();
   21|    459|  auto currentoffsetmax = vector_u32::zero();
   22|       |
   23|    459|  constexpr size_t N = vector_u32::ELEMENTS;
   24|       |
   25|  1.26M|  while (input + N < end) {
  ------------------
  |  Branch (25:10): [True: 1.26M, False: 459]
  ------------------
   26|  1.26M|    auto in = vector_u32(input);
   27|  1.26M|    if constexpr (!match_system(endianness::BIG)) {
   28|  1.26M|      in.swap_bytes();
   29|  1.26M|    }
   30|       |
   31|  1.26M|    currentmax = max(currentmax, in);
   32|  1.26M|    currentoffsetmax = max(currentoffsetmax, in + offset);
   33|  1.26M|    input += N;
   34|  1.26M|  }
   35|       |
   36|    459|  const auto too_large = currentmax > standardmax;
   37|    459|  if (too_large.any()) {
  ------------------
  |  Branch (37:7): [True: 326, False: 133]
  ------------------
   38|    326|    return false;
   39|    326|  }
   40|       |
   41|    133|  const auto surrogate = currentoffsetmax > standardoffsetmax;
   42|    133|  if (surrogate.any()) {
  ------------------
  |  Branch (42:7): [True: 8, False: 125]
  ------------------
   43|      8|    return false;
   44|      8|  }
   45|       |
   46|    125|  return scalar::utf32::validate(input, end - input);
   47|    133|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf328validateEPKDim:
    6|    489|simdutf_really_inline bool validate(const char32_t *input, size_t size) {
    7|    489|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|    489|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 0, False: 489]
  |  |  ------------------
  ------------------
    8|       |    // empty input is valid UTF-32. protect the implementation from
    9|       |    // handling nullptr
   10|      0|    return true;
   11|      0|  }
   12|       |
   13|    489|  const char32_t *end = input + size;
   14|       |
   15|    489|  using vector_u32 = simd32<uint32_t>;
   16|       |
   17|    489|  const auto standardmax = vector_u32::splat(0x10ffff);
   18|    489|  const auto offset = vector_u32::splat(0xffff2000);
   19|    489|  const auto standardoffsetmax = vector_u32::splat(0xfffff7ff);
   20|    489|  auto currentmax = vector_u32::zero();
   21|    489|  auto currentoffsetmax = vector_u32::zero();
   22|       |
   23|    489|  constexpr size_t N = vector_u32::ELEMENTS;
   24|       |
   25|   366k|  while (input + N < end) {
  ------------------
  |  Branch (25:10): [True: 366k, False: 489]
  ------------------
   26|   366k|    auto in = vector_u32(input);
   27|   366k|    if constexpr (!match_system(endianness::BIG)) {
   28|   366k|      in.swap_bytes();
   29|   366k|    }
   30|       |
   31|   366k|    currentmax = max(currentmax, in);
   32|   366k|    currentoffsetmax = max(currentoffsetmax, in + offset);
   33|   366k|    input += N;
   34|   366k|  }
   35|       |
   36|    489|  const auto too_large = currentmax > standardmax;
   37|    489|  if (too_large.any()) {
  ------------------
  |  Branch (37:7): [True: 243, False: 246]
  ------------------
   38|    243|    return false;
   39|    243|  }
   40|       |
   41|    246|  const auto surrogate = currentoffsetmax > standardoffsetmax;
   42|    246|  if (surrogate.any()) {
  ------------------
  |  Branch (42:7): [True: 7, False: 239]
  ------------------
   43|      7|    return false;
   44|      7|  }
   45|       |
   46|    239|  return scalar::utf32::validate(input, end - input);
   47|    246|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_127avx2_convert_latin1_to_utf8EPKcmPc:
    3|    538|                            char *utf8_output) {
    4|    538|  const char *end = latin1_input + len;
    5|    538|  const __m256i v_0000 = _mm256_setzero_si256();
    6|    538|  const __m256i v_c080 = _mm256_set1_epi16((int16_t)0xc080);
    7|    538|  const __m256i v_ff80 = _mm256_set1_epi16((int16_t)0xff80);
    8|    538|  const size_t safety_margin = 12;
    9|       |
   10|  1.10M|  while (end - latin1_input >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (10:10): [True: 1.10M, False: 538]
  ------------------
   11|  1.10M|    __m128i in8 = _mm_loadu_si128((__m128i *)latin1_input);
   12|       |    // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes
   13|  1.10M|    const __m128i v_80 = _mm_set1_epi8((char)0x80);
   14|  1.10M|    if (_mm_testz_si128(in8, v_80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (14:9): [True: 568k, False: 538k]
  ------------------
   15|       |      // 1. store (16 bytes)
   16|   568k|      _mm_storeu_si128((__m128i *)utf8_output, in8);
   17|       |      // 2. adjust pointers
   18|   568k|      latin1_input += 16;
   19|   568k|      utf8_output += 16;
   20|   568k|      continue; // we are done for this round!
   21|   568k|    }
   22|       |    // We proceed only with the first 16 bytes.
   23|   538k|    const __m256i in = _mm256_cvtepu8_epi16((in8));
   24|       |
   25|       |    // 1. prepare 2-byte values
   26|       |    // input 16-bit word : [0000|0000|aabb|bbbb] x 8
   27|       |    // expected output   : [1100|00aa|10bb|bbbb] x 8
   28|   538k|    const __m256i v_1f00 = _mm256_set1_epi16((int16_t)0x1f00);
   29|   538k|    const __m256i v_003f = _mm256_set1_epi16((int16_t)0x003f);
   30|       |
   31|       |    // t0 = [0000|00aa|bbbb|bb00]
   32|   538k|    const __m256i t0 = _mm256_slli_epi16(in, 2);
   33|       |    // t1 = [0000|00aa|0000|0000]
   34|   538k|    const __m256i t1 = _mm256_and_si256(t0, v_1f00);
   35|       |    // t2 = [0000|0000|00bb|bbbb]
   36|   538k|    const __m256i t2 = _mm256_and_si256(in, v_003f);
   37|       |    // t3 = [000a|aaaa|00bb|bbbb]
   38|   538k|    const __m256i t3 = _mm256_or_si256(t1, t2);
   39|       |    // t4 = [1100|00aa|10bb|bbbb]
   40|   538k|    const __m256i t4 = _mm256_or_si256(t3, v_c080);
   41|       |
   42|       |    // 2. merge ASCII and 2-byte codewords
   43|       |
   44|       |    // no bits set above 7th bit
   45|   538k|    const __m256i one_byte_bytemask =
   46|   538k|        _mm256_cmpeq_epi16(_mm256_and_si256(in, v_ff80), v_0000);
   47|   538k|    const uint32_t one_byte_bitmask =
   48|   538k|        static_cast<uint32_t>(_mm256_movemask_epi8(one_byte_bytemask));
   49|       |
   50|   538k|    const __m256i utf8_unpacked = _mm256_blendv_epi8(t4, in, one_byte_bytemask);
   51|       |
   52|       |    // 3. prepare bitmask for 8-bit lookup
   53|   538k|    const uint32_t M0 = one_byte_bitmask & 0x55555555;
   54|   538k|    const uint32_t M1 = M0 >> 7;
   55|   538k|    const uint32_t M2 = (M1 | M0) & 0x00ff00ff;
   56|       |    // 4. pack the bytes
   57|       |
   58|   538k|    const uint8_t *row =
   59|   538k|        &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2)][0];
   60|   538k|    const uint8_t *row_2 =
   61|   538k|        &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2 >> 16)]
   62|   538k|                                                            [0];
   63|       |
   64|   538k|    const __m128i shuffle = _mm_loadu_si128((__m128i *)(row + 1));
   65|   538k|    const __m128i shuffle_2 = _mm_loadu_si128((__m128i *)(row_2 + 1));
   66|       |
   67|   538k|    const __m256i utf8_packed = _mm256_shuffle_epi8(
   68|   538k|        utf8_unpacked, _mm256_setr_m128i(shuffle, shuffle_2));
  ------------------
  |  |    7|   538k|      _mm256_permute2f128_si256(_mm256_castsi128_si256(xmm1),                  \
  |  |    8|   538k|                                _mm256_castsi128_si256(xmm2), 2)
  ------------------
   69|       |    // 5. store bytes
   70|   538k|    _mm_storeu_si128((__m128i *)utf8_output,
   71|   538k|                     _mm256_castsi256_si128(utf8_packed));
   72|   538k|    utf8_output += row[0];
   73|   538k|    _mm_storeu_si128((__m128i *)utf8_output,
   74|   538k|                     _mm256_extractf128_si256(utf8_packed, 1));
   75|   538k|    utf8_output += row_2[0];
   76|       |
   77|       |    // 6. adjust pointers
   78|   538k|    latin1_input += 16;
   79|   538k|    continue;
   80|       |
   81|  1.10M|  } // while
   82|    538|  return std::make_pair(latin1_input, utf8_output);
   83|    538|}

simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_118encoding_detection15utf16le_checker6errorsEv:
   38|  22.6k|  simdutf_really_inline bool errors() const { return error != 0; }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_118encoding_detection15utf16le_checker11check_asciiEv:
   33|   198k|  simdutf_really_inline void check_ascii() {
   34|   198k|    error |= prev_high;
   35|   198k|    prev_high = 0;
   36|   198k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_118encoding_detection15utf16le_checker5checkILb0EEEvRKNS1_4simd8simd8x64IhEE:
   11|   157k|  simdutf_really_inline void check(const simd::simd8x64<uint8_t> &in) {
   12|   157k|    const __m256i v_fc = _mm256_set1_epi8(char(0xfc));
   13|   157k|    const __m256i v_d8 = _mm256_set1_epi8(char(0xd8));
   14|   157k|    const __m256i v_dc = _mm256_set1_epi8(char(0xdc));
   15|   157k|    const __m256i m0 = _mm256_and_si256(in.chunks[0], v_fc);
   16|   157k|    const __m256i m1 = _mm256_and_si256(in.chunks[1], v_fc);
   17|   157k|    const uint64_t odd = 0xaaaaaaaaaaaaaaaa;
   18|   157k|    const uint64_t high =
   19|   157k|        (uint64_t(uint32_t(_mm256_movemask_epi8(_mm256_cmpeq_epi8(m0, v_d8)))) |
   20|   157k|         (uint64_t(uint32_t(_mm256_movemask_epi8(_mm256_cmpeq_epi8(m1, v_d8))))
   21|   157k|          << 32)) &
   22|   157k|        odd;
   23|   157k|    const uint64_t low =
   24|   157k|        (uint64_t(uint32_t(_mm256_movemask_epi8(_mm256_cmpeq_epi8(m0, v_dc)))) |
   25|   157k|         (uint64_t(uint32_t(_mm256_movemask_epi8(_mm256_cmpeq_epi8(m1, v_dc))))
   26|   157k|          << 32)) &
   27|   157k|        odd;
   28|   157k|    const uint64_t carry = overlapping ? (low & 2) : prev_high;
  ------------------
  |  Branch (28:28): [Folded, False: 157k]
  ------------------
   29|   157k|    error |= ((high << 2) | carry) ^ low;
   30|   157k|    prev_high = high >> 62;
   31|   157k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_118encoding_detection15utf16le_checker5checkILb1EEEvRKNS1_4simd8simd8x64IhEE:
   11|    324|  simdutf_really_inline void check(const simd::simd8x64<uint8_t> &in) {
   12|    324|    const __m256i v_fc = _mm256_set1_epi8(char(0xfc));
   13|    324|    const __m256i v_d8 = _mm256_set1_epi8(char(0xd8));
   14|    324|    const __m256i v_dc = _mm256_set1_epi8(char(0xdc));
   15|    324|    const __m256i m0 = _mm256_and_si256(in.chunks[0], v_fc);
   16|    324|    const __m256i m1 = _mm256_and_si256(in.chunks[1], v_fc);
   17|    324|    const uint64_t odd = 0xaaaaaaaaaaaaaaaa;
   18|    324|    const uint64_t high =
   19|    324|        (uint64_t(uint32_t(_mm256_movemask_epi8(_mm256_cmpeq_epi8(m0, v_d8)))) |
   20|    324|         (uint64_t(uint32_t(_mm256_movemask_epi8(_mm256_cmpeq_epi8(m1, v_d8))))
   21|    324|          << 32)) &
   22|    324|        odd;
   23|    324|    const uint64_t low =
   24|    324|        (uint64_t(uint32_t(_mm256_movemask_epi8(_mm256_cmpeq_epi8(m0, v_dc)))) |
   25|    324|         (uint64_t(uint32_t(_mm256_movemask_epi8(_mm256_cmpeq_epi8(m1, v_dc))))
   26|    324|          << 32)) &
   27|    324|        odd;
   28|    324|    const uint64_t carry = overlapping ? (low & 2) : prev_high;
  ------------------
  |  Branch (28:28): [True: 324, Folded]
  ------------------
   29|    324|    error |= ((high << 2) | carry) ^ low;
   30|    324|    prev_high = high >> 62;
   31|    324|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_118encoding_detection15utf32le_checker5checkERKNS1_4simd8simd8x64IhEE:
   49|   129k|  simdutf_really_inline void check(const simd::simd8x64<uint8_t> &in) {
   50|   129k|    const __m256i offset = _mm256_set1_epi32(int32_t(0xffff2000));
   51|   129k|    const __m256i w0 = in.chunks[0];
   52|   129k|    const __m256i w1 = in.chunks[1];
   53|   129k|    currentmax = _mm256_max_epu32(currentmax, _mm256_max_epu32(w0, w1));
   54|   129k|    currentoffsetmax = _mm256_max_epu32(
   55|   129k|        currentoffsetmax, _mm256_max_epu32(_mm256_add_epi32(w0, offset),
   56|   129k|                                           _mm256_add_epi32(w1, offset)));
   57|   129k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_118encoding_detection15utf16le_checker13errors_at_eofEv:
   40|    675|  simdutf_really_inline bool errors_at_eof() const {
   41|    675|    return (error | prev_high) != 0;
   42|    675|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_118encoding_detection15utf32le_checker6errorsEv:
   59|  8.64k|  simdutf_really_inline bool errors() const {
   60|  8.64k|    const __m256i standardmax = _mm256_set1_epi32(0x10ffff);
   61|  8.64k|    const __m256i standardoffsetmax = _mm256_set1_epi32(int32_t(0xfffff7ff));
   62|  8.64k|    const __m256i too_large = _mm256_xor_si256(
   63|  8.64k|        _mm256_max_epu32(currentmax, standardmax), standardmax);
   64|  8.64k|    const __m256i surrogate =
   65|  8.64k|        _mm256_xor_si256(_mm256_max_epu32(currentoffsetmax, standardoffsetmax),
   66|  8.64k|                         standardoffsetmax);
   67|  8.64k|    const __m256i any = _mm256_or_si256(too_large, surrogate);
   68|  8.64k|    return !_mm256_testz_si256(any, any);
   69|  8.64k|  }

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_112utf16fix_avxILNS_10endiannessE0EEEvPKDsmPDs:
  143|    920|void utf16fix_avx(const char16_t *in, size_t n, char16_t *out) {
  144|    920|  const char16_t replacement = scalar::utf16::replacement<big_endian>();
  145|    920|  size_t i;
  146|       |
  147|    920|  if (n < 17) {
  ------------------
  |  Branch (147:7): [True: 267, False: 653]
  ------------------
  148|    267|    utf16fix_sse<big_endian>(in, n, out);
  149|    267|    return;
  150|    267|  }
  151|       |
  152|    653|  out[0] =
  153|    653|      scalar::utf16::is_low_surrogate<big_endian>(in[0]) ? replacement : in[0];
  ------------------
  |  Branch (153:7): [True: 75, False: 578]
  ------------------
  154|       |
  155|       |  /* duplicate code to have the compiler specialise utf16fix_block() */
  156|    653|  if (in == out) {
  ------------------
  |  Branch (156:7): [True: 0, False: 653]
  ------------------
  157|      0|    for (i = 1; i + 16 < n; i += 16) {
  ------------------
  |  Branch (157:17): [True: 0, False: 0]
  ------------------
  158|      0|      utf16fix_block<big_endian, true>(out + i, in + i);
  159|      0|    }
  160|       |
  161|      0|    utf16fix_block<big_endian, true>(out + n - 16, in + n - 16);
  162|    653|  } else {
  163|   914k|    for (i = 1; i + 16 < n; i += 16) {
  ------------------
  |  Branch (163:17): [True: 913k, False: 653]
  ------------------
  164|   913k|      utf16fix_block<big_endian, false>(out + i, in + i);
  165|   913k|    }
  166|       |
  167|    653|    utf16fix_block<big_endian, false>(out + n - 16, in + n - 16);
  168|    653|  }
  169|       |
  170|    653|  out[n - 1] = scalar::utf16::is_high_surrogate<big_endian>(out[n - 1])
  ------------------
  |  Branch (170:16): [True: 93, False: 560]
  ------------------
  171|    653|                   ? replacement
  172|    653|                   : out[n - 1];
  173|    653|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_112utf16fix_sseILNS_10endiannessE0EEEvPKDsmPDs:
  110|    267|void utf16fix_sse(const char16_t *in, size_t n, char16_t *out) {
  111|    267|  const char16_t replacement = scalar::utf16::replacement<big_endian>();
  112|    267|  size_t i;
  113|       |
  114|    267|  if (n < 9) {
  ------------------
  |  Branch (114:7): [True: 143, False: 124]
  ------------------
  115|    143|    scalar::utf16::to_well_formed_utf16<big_endian>(in, n, out);
  116|    143|    return;
  117|    143|  }
  118|       |
  119|    124|  out[0] =
  120|    124|      scalar::utf16::is_low_surrogate<big_endian>(in[0]) ? replacement : in[0];
  ------------------
  |  Branch (120:7): [True: 21, False: 103]
  ------------------
  121|       |
  122|       |  /* duplicate code to have the compiler specialise utf16fix_block() */
  123|    124|  if (in == out) {
  ------------------
  |  Branch (123:7): [True: 0, False: 124]
  ------------------
  124|      0|    for (i = 1; i + 8 < n; i += 8) {
  ------------------
  |  Branch (124:17): [True: 0, False: 0]
  ------------------
  125|      0|      utf16fix_block_sse<big_endian, true>(out + i, in + i);
  126|      0|    }
  127|       |
  128|      0|    utf16fix_block_sse<big_endian, true>(out + n - 8, in + n - 8);
  129|    124|  } else {
  130|    151|    for (i = 1; i + 8 < n; i += 8) {
  ------------------
  |  Branch (130:17): [True: 27, False: 124]
  ------------------
  131|     27|      utf16fix_block_sse<big_endian, false>(out + i, in + i);
  132|     27|    }
  133|       |
  134|    124|    utf16fix_block_sse<big_endian, false>(out + n - 8, in + n - 8);
  135|    124|  }
  136|       |
  137|    124|  out[n - 1] = scalar::utf16::is_high_surrogate<big_endian>(out[n - 1])
  ------------------
  |  Branch (137:16): [True: 18, False: 106]
  ------------------
  138|    124|                   ? replacement
  139|    124|                   : out[n - 1];
  140|    124|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_118utf16fix_block_sseILNS_10endiannessE0ELb0EEEvPDsPKDs:
   72|    151|void utf16fix_block_sse(char16_t *out, const char16_t *in) {
   73|    151|  auto swap_if_needed = [](uint16_t x) constexpr -> uint16_t {
   74|    151|    return scalar::utf16::swap_if_needed<big_endian>(x);
   75|    151|  };
   76|    151|  const char16_t replacement = scalar::utf16::replacement<big_endian>();
   77|    151|  __m128i lookback, block, lb_masked, block_masked, lb_is_high, block_is_low;
   78|    151|  __m128i illseq, lb_illseq, block_illseq;
   79|       |
   80|    151|  lookback = _mm_loadu_si128((const __m128i *)(in - 1));
   81|    151|  block = _mm_loadu_si128((const __m128i *)in);
   82|    151|  lb_masked = _mm_and_si128(lookback, _mm_set1_epi16(swap_if_needed(0xfc00U)));
   83|    151|  block_masked = _mm_and_si128(block, _mm_set1_epi16(swap_if_needed(0xfc00U)));
   84|    151|  lb_is_high =
   85|    151|      _mm_cmpeq_epi16(lb_masked, _mm_set1_epi16(swap_if_needed(0xd800U)));
   86|    151|  block_is_low =
   87|    151|      _mm_cmpeq_epi16(block_masked, _mm_set1_epi16(swap_if_needed(0xdc00U)));
   88|       |
   89|    151|  illseq = _mm_xor_si128(lb_is_high, block_is_low);
   90|    151|  if (_mm_movemask_epi8(illseq) != 0) {
  ------------------
  |  Branch (90:7): [True: 85, False: 66]
  ------------------
   91|       |    /* compute the cause of the illegal sequencing */
   92|     85|    lb_illseq = _mm_andnot_si128(block_is_low, lb_is_high);
   93|     85|    block_illseq = _mm_or_si128(_mm_andnot_si128(lb_is_high, block_is_low),
   94|     85|                                _mm_bsrli_si128(lb_illseq, 2));
   95|       |    /* fix illegal sequencing in the lookback */
   96|     85|    int lb = _mm_cvtsi128_si32(lb_illseq);
   97|     85|    lb = (lb & replacement) | (~lb & out[-1]);
   98|     85|    out[-1] = char16_t(lb);
   99|       |    /* fix illegal sequencing in the main block */
  100|     85|    block =
  101|     85|        _mm_or_si128(_mm_andnot_si128(block_illseq, block),
  102|     85|                     _mm_and_si128(block_illseq, _mm_set1_epi16(replacement)));
  103|     85|    _mm_storeu_si128((__m128i *)out, block);
  104|     85|  } else if (!in_place) {
  ------------------
  |  Branch (104:14): [True: 66, Folded]
  ------------------
  105|     66|    _mm_storeu_si128((__m128i *)out, block);
  106|     66|  }
  107|    151|}
simdutf.cpp:_ZZN7simdutf7haswell12_GLOBAL__N_118utf16fix_block_sseILNS_10endiannessE0ELb0EEEvPDsPKDsENKUltE_clEt:
   73|    604|  auto swap_if_needed = [](uint16_t x) constexpr -> uint16_t {
   74|    604|    return scalar::utf16::swap_if_needed<big_endian>(x);
   75|    604|  };
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_114utf16fix_blockILNS_10endiannessE0ELb0EEEvPDsPKDs:
   10|   914k|void utf16fix_block(char16_t *out, const char16_t *in) {
   11|   914k|  auto swap_if_needed = [](uint16_t x) constexpr -> uint16_t {
   12|   914k|    return scalar::utf16::swap_if_needed<big_endian>(x);
   13|   914k|  };
   14|   914k|  const char16_t replacement = scalar::utf16::replacement<big_endian>();
   15|   914k|  __m256i lookback, block, lb_masked, block_masked, lb_is_high, block_is_low;
   16|   914k|  __m256i illseq, lb_illseq, block_illseq, lb_illseq_shifted;
   17|       |
   18|   914k|  lookback = _mm256_loadu_si256((const __m256i *)(in - 1));
   19|   914k|  block = _mm256_loadu_si256((const __m256i *)in);
   20|   914k|  lb_masked =
   21|   914k|      _mm256_and_si256(lookback, _mm256_set1_epi16(swap_if_needed(0xfc00u)));
   22|   914k|  block_masked =
   23|   914k|      _mm256_and_si256(block, _mm256_set1_epi16(swap_if_needed(0xfc00u)));
   24|   914k|  lb_is_high =
   25|   914k|      _mm256_cmpeq_epi16(lb_masked, _mm256_set1_epi16(swap_if_needed(0xd800u)));
   26|   914k|  block_is_low = _mm256_cmpeq_epi16(block_masked,
   27|   914k|                                    _mm256_set1_epi16(swap_if_needed(0xdc00u)));
   28|       |
   29|   914k|  illseq = _mm256_xor_si256(lb_is_high, block_is_low);
   30|   914k|  if (!_mm256_testz_si256(illseq, illseq)) {
  ------------------
  |  Branch (30:7): [True: 88.2k, False: 825k]
  ------------------
   31|  88.2k|    int lb;
   32|       |
   33|       |    /* compute the cause of the illegal sequencing */
   34|  88.2k|    lb_illseq = _mm256_andnot_si256(block_is_low, lb_is_high);
   35|       |#if SIMDUTF_GCC9OROLDER
   36|       |    // Old GCC versions are missing _mm256_zextsi128_si256, so we emulate it.
   37|       |    __m128i tmp_legacygcc =
   38|       |        _mm_bslli_si128(_mm256_extracti128_si256(lb_illseq, 1), 14);
   39|       |    __m256i tmp_legacygcc256 =
   40|       |        _mm256_set_m128i(_mm_setzero_si128(), tmp_legacygcc);
   41|       |    lb_illseq_shifted =
   42|       |        _mm256_or_si256(_mm256_bsrli_epi128(lb_illseq, 2), tmp_legacygcc256);
   43|       |#else
   44|  88.2k|    lb_illseq_shifted =
   45|  88.2k|        _mm256_or_si256(_mm256_bsrli_epi128(lb_illseq, 2),
   46|  88.2k|                        _mm256_zextsi128_si256(_mm_bslli_si128(
   47|  88.2k|                            _mm256_extracti128_si256(lb_illseq, 1), 14)));
   48|  88.2k|#endif // SIMDUTF_GCC9OROLDER
   49|  88.2k|    block_illseq = _mm256_or_si256(
   50|  88.2k|        _mm256_andnot_si256(lb_is_high, block_is_low), lb_illseq_shifted);
   51|       |
   52|       |    /* fix illegal sequencing in the lookback */
   53|       |#if SIMDUTF_GCC10 || SIMDUTF_GCC9OROLDER
   54|       |    // GCC 10 is missing important intrinsics.
   55|       |    lb = _mm_cvtsi128_si32(_mm256_extractf128_si256(lb_illseq, 0));
   56|       |#else
   57|  88.2k|    lb = _mm256_cvtsi256_si32(lb_illseq);
   58|  88.2k|#endif
   59|  88.2k|    lb = (lb & replacement) | (~lb & out[-1]);
   60|  88.2k|    out[-1] = char16_t(lb);
   61|       |
   62|       |    /* fix illegal sequencing in the main block */
   63|  88.2k|    block =
   64|  88.2k|        _mm256_blendv_epi8(block, _mm256_set1_epi16(replacement), block_illseq);
   65|  88.2k|    _mm256_storeu_si256((__m256i *)out, block);
   66|   825k|  } else if (!in_place) {
  ------------------
  |  Branch (66:14): [True: 825k, Folded]
  ------------------
   67|   825k|    _mm256_storeu_si256((__m256i *)out, block);
   68|   825k|  }
   69|   914k|}
simdutf.cpp:_ZZN7simdutf7haswell12_GLOBAL__N_114utf16fix_blockILNS_10endiannessE0ELb0EEEvPDsPKDsENKUltE_clEt:
   11|  3.65M|  auto swap_if_needed = [](uint16_t x) constexpr -> uint16_t {
   12|  3.65M|    return scalar::utf16::swap_if_needed<big_endian>(x);
   13|  3.65M|  };
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_112utf16fix_avxILNS_10endiannessE1EEEvPKDsmPDs:
  143|    920|void utf16fix_avx(const char16_t *in, size_t n, char16_t *out) {
  144|    920|  const char16_t replacement = scalar::utf16::replacement<big_endian>();
  145|    920|  size_t i;
  146|       |
  147|    920|  if (n < 17) {
  ------------------
  |  Branch (147:7): [True: 267, False: 653]
  ------------------
  148|    267|    utf16fix_sse<big_endian>(in, n, out);
  149|    267|    return;
  150|    267|  }
  151|       |
  152|    653|  out[0] =
  153|    653|      scalar::utf16::is_low_surrogate<big_endian>(in[0]) ? replacement : in[0];
  ------------------
  |  Branch (153:7): [True: 58, False: 595]
  ------------------
  154|       |
  155|       |  /* duplicate code to have the compiler specialise utf16fix_block() */
  156|    653|  if (in == out) {
  ------------------
  |  Branch (156:7): [True: 0, False: 653]
  ------------------
  157|      0|    for (i = 1; i + 16 < n; i += 16) {
  ------------------
  |  Branch (157:17): [True: 0, False: 0]
  ------------------
  158|      0|      utf16fix_block<big_endian, true>(out + i, in + i);
  159|      0|    }
  160|       |
  161|      0|    utf16fix_block<big_endian, true>(out + n - 16, in + n - 16);
  162|    653|  } else {
  163|   914k|    for (i = 1; i + 16 < n; i += 16) {
  ------------------
  |  Branch (163:17): [True: 913k, False: 653]
  ------------------
  164|   913k|      utf16fix_block<big_endian, false>(out + i, in + i);
  165|   913k|    }
  166|       |
  167|    653|    utf16fix_block<big_endian, false>(out + n - 16, in + n - 16);
  168|    653|  }
  169|       |
  170|    653|  out[n - 1] = scalar::utf16::is_high_surrogate<big_endian>(out[n - 1])
  ------------------
  |  Branch (170:16): [True: 95, False: 558]
  ------------------
  171|    653|                   ? replacement
  172|    653|                   : out[n - 1];
  173|    653|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_112utf16fix_sseILNS_10endiannessE1EEEvPKDsmPDs:
  110|    267|void utf16fix_sse(const char16_t *in, size_t n, char16_t *out) {
  111|    267|  const char16_t replacement = scalar::utf16::replacement<big_endian>();
  112|    267|  size_t i;
  113|       |
  114|    267|  if (n < 9) {
  ------------------
  |  Branch (114:7): [True: 143, False: 124]
  ------------------
  115|    143|    scalar::utf16::to_well_formed_utf16<big_endian>(in, n, out);
  116|    143|    return;
  117|    143|  }
  118|       |
  119|    124|  out[0] =
  120|    124|      scalar::utf16::is_low_surrogate<big_endian>(in[0]) ? replacement : in[0];
  ------------------
  |  Branch (120:7): [True: 24, False: 100]
  ------------------
  121|       |
  122|       |  /* duplicate code to have the compiler specialise utf16fix_block() */
  123|    124|  if (in == out) {
  ------------------
  |  Branch (123:7): [True: 0, False: 124]
  ------------------
  124|      0|    for (i = 1; i + 8 < n; i += 8) {
  ------------------
  |  Branch (124:17): [True: 0, False: 0]
  ------------------
  125|      0|      utf16fix_block_sse<big_endian, true>(out + i, in + i);
  126|      0|    }
  127|       |
  128|      0|    utf16fix_block_sse<big_endian, true>(out + n - 8, in + n - 8);
  129|    124|  } else {
  130|    151|    for (i = 1; i + 8 < n; i += 8) {
  ------------------
  |  Branch (130:17): [True: 27, False: 124]
  ------------------
  131|     27|      utf16fix_block_sse<big_endian, false>(out + i, in + i);
  132|     27|    }
  133|       |
  134|    124|    utf16fix_block_sse<big_endian, false>(out + n - 8, in + n - 8);
  135|    124|  }
  136|       |
  137|    124|  out[n - 1] = scalar::utf16::is_high_surrogate<big_endian>(out[n - 1])
  ------------------
  |  Branch (137:16): [True: 23, False: 101]
  ------------------
  138|    124|                   ? replacement
  139|    124|                   : out[n - 1];
  140|    124|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_118utf16fix_block_sseILNS_10endiannessE1ELb0EEEvPDsPKDs:
   72|    151|void utf16fix_block_sse(char16_t *out, const char16_t *in) {
   73|    151|  auto swap_if_needed = [](uint16_t x) constexpr -> uint16_t {
   74|    151|    return scalar::utf16::swap_if_needed<big_endian>(x);
   75|    151|  };
   76|    151|  const char16_t replacement = scalar::utf16::replacement<big_endian>();
   77|    151|  __m128i lookback, block, lb_masked, block_masked, lb_is_high, block_is_low;
   78|    151|  __m128i illseq, lb_illseq, block_illseq;
   79|       |
   80|    151|  lookback = _mm_loadu_si128((const __m128i *)(in - 1));
   81|    151|  block = _mm_loadu_si128((const __m128i *)in);
   82|    151|  lb_masked = _mm_and_si128(lookback, _mm_set1_epi16(swap_if_needed(0xfc00U)));
   83|    151|  block_masked = _mm_and_si128(block, _mm_set1_epi16(swap_if_needed(0xfc00U)));
   84|    151|  lb_is_high =
   85|    151|      _mm_cmpeq_epi16(lb_masked, _mm_set1_epi16(swap_if_needed(0xd800U)));
   86|    151|  block_is_low =
   87|    151|      _mm_cmpeq_epi16(block_masked, _mm_set1_epi16(swap_if_needed(0xdc00U)));
   88|       |
   89|    151|  illseq = _mm_xor_si128(lb_is_high, block_is_low);
   90|    151|  if (_mm_movemask_epi8(illseq) != 0) {
  ------------------
  |  Branch (90:7): [True: 89, False: 62]
  ------------------
   91|       |    /* compute the cause of the illegal sequencing */
   92|     89|    lb_illseq = _mm_andnot_si128(block_is_low, lb_is_high);
   93|     89|    block_illseq = _mm_or_si128(_mm_andnot_si128(lb_is_high, block_is_low),
   94|     89|                                _mm_bsrli_si128(lb_illseq, 2));
   95|       |    /* fix illegal sequencing in the lookback */
   96|     89|    int lb = _mm_cvtsi128_si32(lb_illseq);
   97|     89|    lb = (lb & replacement) | (~lb & out[-1]);
   98|     89|    out[-1] = char16_t(lb);
   99|       |    /* fix illegal sequencing in the main block */
  100|     89|    block =
  101|     89|        _mm_or_si128(_mm_andnot_si128(block_illseq, block),
  102|     89|                     _mm_and_si128(block_illseq, _mm_set1_epi16(replacement)));
  103|     89|    _mm_storeu_si128((__m128i *)out, block);
  104|     89|  } else if (!in_place) {
  ------------------
  |  Branch (104:14): [True: 62, Folded]
  ------------------
  105|     62|    _mm_storeu_si128((__m128i *)out, block);
  106|     62|  }
  107|    151|}
simdutf.cpp:_ZZN7simdutf7haswell12_GLOBAL__N_118utf16fix_block_sseILNS_10endiannessE1ELb0EEEvPDsPKDsENKUltE_clEt:
   73|    604|  auto swap_if_needed = [](uint16_t x) constexpr -> uint16_t {
   74|    604|    return scalar::utf16::swap_if_needed<big_endian>(x);
   75|    604|  };
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_114utf16fix_blockILNS_10endiannessE1ELb0EEEvPDsPKDs:
   10|   914k|void utf16fix_block(char16_t *out, const char16_t *in) {
   11|   914k|  auto swap_if_needed = [](uint16_t x) constexpr -> uint16_t {
   12|   914k|    return scalar::utf16::swap_if_needed<big_endian>(x);
   13|   914k|  };
   14|   914k|  const char16_t replacement = scalar::utf16::replacement<big_endian>();
   15|   914k|  __m256i lookback, block, lb_masked, block_masked, lb_is_high, block_is_low;
   16|   914k|  __m256i illseq, lb_illseq, block_illseq, lb_illseq_shifted;
   17|       |
   18|   914k|  lookback = _mm256_loadu_si256((const __m256i *)(in - 1));
   19|   914k|  block = _mm256_loadu_si256((const __m256i *)in);
   20|   914k|  lb_masked =
   21|   914k|      _mm256_and_si256(lookback, _mm256_set1_epi16(swap_if_needed(0xfc00u)));
   22|   914k|  block_masked =
   23|   914k|      _mm256_and_si256(block, _mm256_set1_epi16(swap_if_needed(0xfc00u)));
   24|   914k|  lb_is_high =
   25|   914k|      _mm256_cmpeq_epi16(lb_masked, _mm256_set1_epi16(swap_if_needed(0xd800u)));
   26|   914k|  block_is_low = _mm256_cmpeq_epi16(block_masked,
   27|   914k|                                    _mm256_set1_epi16(swap_if_needed(0xdc00u)));
   28|       |
   29|   914k|  illseq = _mm256_xor_si256(lb_is_high, block_is_low);
   30|   914k|  if (!_mm256_testz_si256(illseq, illseq)) {
  ------------------
  |  Branch (30:7): [True: 87.8k, False: 826k]
  ------------------
   31|  87.8k|    int lb;
   32|       |
   33|       |    /* compute the cause of the illegal sequencing */
   34|  87.8k|    lb_illseq = _mm256_andnot_si256(block_is_low, lb_is_high);
   35|       |#if SIMDUTF_GCC9OROLDER
   36|       |    // Old GCC versions are missing _mm256_zextsi128_si256, so we emulate it.
   37|       |    __m128i tmp_legacygcc =
   38|       |        _mm_bslli_si128(_mm256_extracti128_si256(lb_illseq, 1), 14);
   39|       |    __m256i tmp_legacygcc256 =
   40|       |        _mm256_set_m128i(_mm_setzero_si128(), tmp_legacygcc);
   41|       |    lb_illseq_shifted =
   42|       |        _mm256_or_si256(_mm256_bsrli_epi128(lb_illseq, 2), tmp_legacygcc256);
   43|       |#else
   44|  87.8k|    lb_illseq_shifted =
   45|  87.8k|        _mm256_or_si256(_mm256_bsrli_epi128(lb_illseq, 2),
   46|  87.8k|                        _mm256_zextsi128_si256(_mm_bslli_si128(
   47|  87.8k|                            _mm256_extracti128_si256(lb_illseq, 1), 14)));
   48|  87.8k|#endif // SIMDUTF_GCC9OROLDER
   49|  87.8k|    block_illseq = _mm256_or_si256(
   50|  87.8k|        _mm256_andnot_si256(lb_is_high, block_is_low), lb_illseq_shifted);
   51|       |
   52|       |    /* fix illegal sequencing in the lookback */
   53|       |#if SIMDUTF_GCC10 || SIMDUTF_GCC9OROLDER
   54|       |    // GCC 10 is missing important intrinsics.
   55|       |    lb = _mm_cvtsi128_si32(_mm256_extractf128_si256(lb_illseq, 0));
   56|       |#else
   57|  87.8k|    lb = _mm256_cvtsi256_si32(lb_illseq);
   58|  87.8k|#endif
   59|  87.8k|    lb = (lb & replacement) | (~lb & out[-1]);
   60|  87.8k|    out[-1] = char16_t(lb);
   61|       |
   62|       |    /* fix illegal sequencing in the main block */
   63|  87.8k|    block =
   64|  87.8k|        _mm256_blendv_epi8(block, _mm256_set1_epi16(replacement), block_illseq);
   65|  87.8k|    _mm256_storeu_si256((__m256i *)out, block);
   66|   826k|  } else if (!in_place) {
  ------------------
  |  Branch (66:14): [True: 826k, Folded]
  ------------------
   67|   826k|    _mm256_storeu_si256((__m256i *)out, block);
   68|   826k|  }
   69|   914k|}
simdutf.cpp:_ZZN7simdutf7haswell12_GLOBAL__N_114utf16fix_blockILNS_10endiannessE1ELb0EEEvPDsPKDsENKUltE_clEt:
   11|  3.65M|  auto swap_if_needed = [](uint16_t x) constexpr -> uint16_t {
   12|  3.65M|    return scalar::utf16::swap_if_needed<big_endian>(x);
   13|  3.65M|  };

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf1623utf16_gather_high_bytesILNS_10endiannessE0EEENS1_4simd5simd8IhEERKNS5_6simd16ItEESB_:
    3|   706k|                                       const simd16<uint16_t> &in1) {
    4|   706k|  if (big_endian) {
  ------------------
  |  Branch (4:7): [Folded, False: 706k]
  ------------------
    5|       |    // we want lower bytes
    6|      0|    const auto mask = simd16<uint16_t>(0x00ff);
    7|      0|    const auto t0 = in0 & mask;
    8|      0|    const auto t1 = in1 & mask;
    9|       |
   10|      0|    return simd16<uint16_t>::pack(t0, t1);
   11|   706k|  } else {
   12|   706k|    const auto t0 = in0.shr<8>();
   13|   706k|    const auto t1 = in1.shr<8>();
   14|       |
   15|   706k|    return simd16<uint16_t>::pack(t0, t1);
   16|   706k|  }
   17|   706k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf1623utf16_gather_high_bytesILNS_10endiannessE1EEENS1_4simd5simd8IhEERKNS5_6simd16ItEESB_:
    3|   512k|                                       const simd16<uint16_t> &in1) {
    4|   512k|  if (big_endian) {
  ------------------
  |  Branch (4:7): [True: 512k, Folded]
  ------------------
    5|       |    // we want lower bytes
    6|   512k|    const auto mask = simd16<uint16_t>(0x00ff);
    7|   512k|    const auto t0 = in0 & mask;
    8|   512k|    const auto t1 = in1 & mask;
    9|       |
   10|   512k|    return simd16<uint16_t>::pack(t0, t1);
   11|   512k|  } else {
   12|      0|    const auto t0 = in0.shr<8>();
   13|      0|    const auto t1 = in1.shr<8>();
   14|       |
   15|      0|    return simd16<uint16_t>::pack(t0, t1);
   16|      0|  }
   17|   512k|}

_ZNK7simdutf7haswell14implementation16detect_encodingsEPKcm:
  161|  1.30k|                                 size_t length) const noexcept {
  162|       |  // If there is a BOM, then we trust it.
  163|  1.30k|  auto bom_encoding = simdutf::BOM::check_bom(input, length);
  164|  1.30k|  if (bom_encoding != encoding_type::unspecified) {
  ------------------
  |  Branch (164:7): [True: 40, False: 1.26k]
  ------------------
  165|     40|    return bom_encoding;
  166|     40|  }
  167|  1.26k|  return encoding_detection::detect_encodings(input, length);
  168|  1.30k|}
_ZNK7simdutf7haswell14implementation13validate_utf8EPKcm:
  178|    901|implementation::validate_utf8(const char *buf, size_t len) const noexcept {
  179|    901|  return aligned_split::all<validate_utf8_unsplit>(
  180|    901|      buf, len, aligned_split::utf8_head(buf, len));
  181|    901|}
_ZNK7simdutf7haswell14implementation14validate_asciiEPKcm:
  204|    192|implementation::validate_ascii(const char *buf, size_t len) const noexcept {
  205|    192|  return aligned_split::all<validate_ascii_unsplit>(
  206|    192|      buf, len, aligned_split::head(buf, len));
  207|    192|}
_ZNK7simdutf7haswell14implementation26validate_ascii_with_errorsEPKcm:
  216|    286|    const char *buf, size_t len) const noexcept {
  217|    286|  return aligned_split::first_error<validate_ascii_with_errors_unsplit>(
  218|    286|      buf, len, aligned_split::head(buf, len));
  219|    286|}
_ZNK7simdutf7haswell14implementation25validate_utf16le_as_asciiEPKDsm:
  232|    244|                                          size_t len) const noexcept {
  233|    244|  return aligned_split::all<validate_utf16le_as_ascii_unsplit>(
  234|    244|      buf, len, aligned_split::head(buf, len));
  235|    244|}
_ZNK7simdutf7haswell14implementation25validate_utf16be_as_asciiEPKDsm:
  246|    244|                                          size_t len) const noexcept {
  247|    244|  return aligned_split::all<validate_utf16be_as_ascii_unsplit>(
  248|    244|      buf, len, aligned_split::head(buf, len));
  249|    244|}
_ZNK7simdutf7haswell14implementation16validate_utf16leEPKDsm:
  276|  2.20k|                                 size_t len) const noexcept {
  277|  2.20k|  return aligned_split::all<validate_utf16le_unsplit>(
  278|  2.20k|      buf, len, aligned_split::utf16_head<endianness::LITTLE>(buf, len));
  279|  2.20k|}
_ZNK7simdutf7haswell14implementation16validate_utf16beEPKDsm:
  306|  1.54k|                                 size_t len) const noexcept {
  307|  1.54k|  return aligned_split::all<validate_utf16be_unsplit>(
  308|  1.54k|      buf, len, aligned_split::utf16_head<endianness::BIG>(buf, len));
  309|  1.54k|}
_ZNK7simdutf7haswell14implementation22to_well_formed_utf16leEPKDsmPDs:
  359|    760|                                            char16_t *output) const noexcept {
  360|    760|  aligned_split::transform<to_well_formed_utf16le_unsplit>(
  361|    760|      input, len, output,
  362|    760|      aligned_split::utf16_head<endianness::LITTLE>(input, len));
  363|    760|}
_ZNK7simdutf7haswell14implementation22to_well_formed_utf16beEPKDsmPDs:
  372|    760|                                            char16_t *output) const noexcept {
  373|    760|  aligned_split::transform<to_well_formed_utf16be_unsplit>(
  374|    760|      input, len, output,
  375|    760|      aligned_split::utf16_head<endianness::BIG>(input, len));
  376|    760|}
_ZNK7simdutf7haswell14implementation14validate_utf32EPKDim:
  386|    459|implementation::validate_utf32(const char32_t *buf, size_t len) const noexcept {
  387|    459|  return aligned_split::all<validate_utf32_unsplit>(
  388|    459|      buf, len, aligned_split::head(buf, len));
  389|    459|}
_ZNK7simdutf7haswell14implementation22convert_latin1_to_utf8EPKcmPc:
  401|    538|    const char *buf, size_t len, char *utf8_output) const noexcept {
  402|    538|  std::pair<const char *, char *> ret =
  403|    538|      avx2_convert_latin1_to_utf8(buf, len, utf8_output);
  404|    538|  size_t converted_chars = ret.second - utf8_output;
  405|       |
  406|    538|  if (ret.first != buf + len) {
  ------------------
  |  Branch (406:7): [True: 512, False: 26]
  ------------------
  407|    512|    const size_t scalar_converted_chars = scalar::latin1_to_utf8::convert(
  408|    512|        ret.first, len - (ret.first - buf), ret.second);
  409|    512|    converted_chars += scalar_converted_chars;
  410|    512|  }
  411|       |
  412|    538|  return converted_chars;
  413|    538|}
_ZNK7simdutf7haswell14implementation23change_endianness_utf16EPKDsmPDs:
 1067|    129|                                             char16_t *output) const noexcept {
 1068|    129|  utf16::change_endianness_utf16(input, length, output);
 1069|    129|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_18is_asciiERKNS1_4simd8simd8x64IhEE:
   12|   428k|simdutf_really_inline bool is_ascii(const simd8x64<uint8_t> &input) {
   13|   428k|  return input.reduce_or().is_ascii();
   14|   428k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_124must_be_2_3_continuationENS1_4simd5simd8IhEES4_:
   20|   172k|                         const simd8<uint8_t> prev3) {
   21|   172k|  simd8<uint8_t> is_third_byte =
   22|   172k|      prev2.saturating_sub(0xe0u - 0x80); // Only 111_____ will be > 0x80
   23|   172k|  simd8<uint8_t> is_fourth_byte =
   24|   172k|      prev3.saturating_sub(0xf0u - 0x80); // Only 1111____ will be > 0x80
   25|   172k|  return simd8<bool>(is_third_byte | is_fourth_byte);
   26|   172k|}
_ZN7simdutf7haswell21validate_utf8_unsplitEPKcm:
  173|    943|                                                 size_t len) noexcept {
  174|    943|  return haswell::utf8_validation::generic_validate_utf8(buf, len);
  175|    943|}
_ZN7simdutf7haswell22validate_ascii_unsplitEPKcm:
  199|    207|                                                  size_t len) noexcept {
  200|    207|  return haswell::ascii_validation::generic_validate_ascii(buf, len);
  201|    207|}
_ZN7simdutf7haswell34validate_ascii_with_errors_unsplitEPKcm:
  210|    310|validate_ascii_with_errors_unsplit(const char *buf, size_t len) noexcept {
  211|    310|  return haswell::ascii_validation::generic_validate_ascii_with_errors(buf,
  212|    310|                                                                       len);
  213|    310|}
_ZN7simdutf7haswell33validate_utf16le_as_ascii_unsplitEPKDsm:
  224|    258|validate_utf16le_as_ascii_unsplit(const char16_t *buf, size_t len) noexcept {
  225|    258|  return haswell::utf16::validate_utf16_as_ascii_with_errors<
  226|    258|             endianness::LITTLE>(buf, len)
  227|    258|             .error == SUCCESS;
  228|    258|}
_ZN7simdutf7haswell33validate_utf16be_as_ascii_unsplitEPKDsm:
  238|    261|validate_utf16be_as_ascii_unsplit(const char16_t *buf, size_t len) noexcept {
  239|    261|  return haswell::utf16::validate_utf16_as_ascii_with_errors<endianness::BIG>(
  240|    261|             buf, len)
  241|    261|             .error == SUCCESS;
  242|    261|}
_ZN7simdutf7haswell24validate_utf16le_unsplitEPKDsm:
  254|  2.48k|                                                    size_t len) noexcept {
  255|  2.48k|  if (simdutf_unlikely(len == 0)) {
  ------------------
  |  |   93|  2.48k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 3, False: 2.47k]
  |  |  ------------------
  ------------------
  256|       |    // empty input is valid UTF-16. protect the implementation from
  257|       |    // handling nullptr
  258|      3|    return true;
  259|      3|  }
  260|  2.47k|  const auto res =
  261|  2.47k|      haswell::utf16::validate_utf16_with_errors<endianness::LITTLE>(buf, len);
  262|  2.47k|  if (res.is_err()) {
  ------------------
  |  Branch (262:7): [True: 423, False: 2.05k]
  ------------------
  263|    423|    return false;
  264|    423|  }
  265|       |
  266|  2.05k|  if (res.count == len) {
  ------------------
  |  Branch (266:7): [True: 202, False: 1.85k]
  ------------------
  267|    202|    return true;
  268|    202|  }
  269|       |
  270|  1.85k|  return scalar::utf16::validate<endianness::LITTLE>(buf + res.count,
  271|  1.85k|                                                     len - res.count);
  272|  2.05k|}
_ZN7simdutf7haswell24validate_utf16be_unsplitEPKDsm:
  284|  1.74k|                                                    size_t len) noexcept {
  285|  1.74k|  if (simdutf_unlikely(len == 0)) {
  ------------------
  |  |   93|  1.74k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 3, False: 1.74k]
  |  |  ------------------
  ------------------
  286|       |    // empty input is valid UTF-16. protect the implementation from
  287|       |    // handling nullptr
  288|      3|    return true;
  289|      3|  }
  290|  1.74k|  const auto res =
  291|  1.74k|      haswell::utf16::validate_utf16_with_errors<endianness::BIG>(buf, len);
  292|  1.74k|  if (res.is_err()) {
  ------------------
  |  Branch (292:7): [True: 242, False: 1.49k]
  ------------------
  293|    242|    return false;
  294|    242|  }
  295|       |
  296|  1.49k|  if (res.count == len) {
  ------------------
  |  Branch (296:7): [True: 178, False: 1.32k]
  ------------------
  297|    178|    return true;
  298|    178|  }
  299|       |
  300|  1.32k|  return scalar::utf16::validate<endianness::BIG>(buf + res.count,
  301|  1.32k|                                                  len - res.count);
  302|  1.49k|}
_ZN7simdutf7haswell30to_well_formed_utf16le_unsplitEPKDsmPDs:
  354|    920|                               char16_t *output) noexcept {
  355|    920|  return utf16fix_avx<endianness::LITTLE>(input, len, output);
  356|    920|}
_ZN7simdutf7haswell30to_well_formed_utf16be_unsplitEPKDsmPDs:
  367|    920|                               char16_t *output) noexcept {
  368|    920|  return utf16fix_avx<endianness::BIG>(input, len, output);
  369|    920|}
_ZN7simdutf7haswell22validate_utf32_unsplitEPKDim:
  381|    489|                                                  size_t len) noexcept {
  382|    489|  return utf32::validate(buf, len);
  383|    489|}

_ZNK7simdutf14implementation27supported_by_runtime_systemEv:
   64|      8|bool implementation::supported_by_runtime_system() const {
   65|      8|  uint32_t required_instruction_sets = this->required_instruction_sets();
   66|      8|  uint32_t supported_instruction_sets =
   67|      8|      internal::detect_supported_architectures();
   68|      8|  return ((supported_instruction_sets & required_instruction_sets) ==
   69|      8|          required_instruction_sets);
   70|      8|}
_ZNK7simdutf14implementation19autodetect_encodingEPKcm:
   74|  2.77k|    const char *input, size_t length) const noexcept {
   75|       |  // If there is a BOM, then we trust it.
   76|  2.77k|  auto bom_encoding = simdutf::BOM::check_bom(input, length);
   77|  2.77k|  if (bom_encoding != encoding_type::unspecified) {
  ------------------
  |  Branch (77:7): [True: 75, False: 2.70k]
  ------------------
   78|     75|    return bom_encoding;
   79|     75|  }
   80|       |  // UTF8 is common, it includes ASCII, and is commonly represented
   81|       |  // without a BOM, so if it fits, go with that. Note that it is still
   82|       |  // possible to get it wrong, we are only 'guessing'. If some has UTF-16
   83|       |  // data without a BOM, it could pass as UTF-8.
   84|       |  //
   85|       |  // An interesting twist might be to check for UTF-16 ASCII first (every
   86|       |  // other byte is zero).
   87|  2.70k|  if (validate_utf8(input, length)) {
  ------------------
  |  Branch (87:7): [True: 255, False: 2.44k]
  ------------------
   88|    255|    return encoding_type::UTF8;
   89|    255|  }
   90|       |  // The next most common encoding that might appear without BOM is probably
   91|       |  // UTF-16LE, so try that next.
   92|  2.44k|  if ((length % 2) == 0) {
  ------------------
  |  Branch (92:7): [True: 1.99k, False: 450]
  ------------------
   93|       |    // important: we need to divide by two
   94|  1.99k|    if (validate_utf16le(reinterpret_cast<const char16_t *>(input),
  ------------------
  |  Branch (94:9): [True: 462, False: 1.53k]
  ------------------
   95|  1.99k|                         length / 2)) {
   96|    462|      return encoding_type::UTF16_LE;
   97|    462|    }
   98|  1.99k|  }
   99|  1.98k|  if ((length % 4) == 0) {
  ------------------
  |  Branch (99:7): [True: 1.37k, False: 609]
  ------------------
  100|  1.37k|    if (validate_utf32(reinterpret_cast<const char32_t *>(input), length / 4)) {
  ------------------
  |  Branch (100:9): [True: 102, False: 1.27k]
  ------------------
  101|    102|      return encoding_type::UTF32_LE;
  102|    102|    }
  103|  1.37k|  }
  104|  1.88k|  return encoding_type::unspecified;
  105|  1.98k|}
_ZNK7simdutf8internal29available_implementation_list5beginEv:
 1513|      1|available_implementation_list::begin() const noexcept {
 1514|      1|  return internal::get_available_implementation_pointers().begin();
 1515|      1|}
_ZNK7simdutf8internal29available_implementation_list3endEv:
 1517|      1|available_implementation_list::end() const noexcept {
 1518|      1|  return internal::get_available_implementation_pointers().end();
 1519|      1|}
_ZNK7simdutf8internal29available_implementation_list21detect_best_supportedEv:
 1521|      1|available_implementation_list::detect_best_supported() const noexcept {
 1522|       |  // They are prelisted in priority order, so we just go down the list
 1523|      1|  uint32_t supported_instruction_sets =
 1524|      1|      internal::detect_supported_architectures();
 1525|      1|  for (const implementation *impl :
  ------------------
  |  Branch (1525:35): [True: 2, False: 0]
  ------------------
 1526|      2|       internal::get_available_implementation_pointers()) {
 1527|      2|    uint32_t required_instruction_sets = impl->required_instruction_sets();
 1528|      2|    if ((supported_instruction_sets & required_instruction_sets) ==
  ------------------
  |  Branch (1528:9): [True: 1, False: 1]
  ------------------
 1529|      2|        required_instruction_sets) {
 1530|      1|      return impl;
 1531|      1|    }
 1532|      2|  }
 1533|      0|  return get_unsupported_singleton(); // this should never happen?
 1534|      1|}
_ZNK7simdutf8internal49detect_best_supported_implementation_on_first_use8set_bestEv:
 1537|      1|detect_best_supported_implementation_on_first_use::set_best() const noexcept {
 1538|      1|  SIMDUTF_PUSH_DISABLE_WARNINGS
 1539|       |  SIMDUTF_DISABLE_DEPRECATED_WARNING // Disable CRT_SECURE warning on MSVC:
 1540|       |                                     // manually verified this is safe
 1541|      1|      char *force_implementation_name = getenv("SIMDUTF_FORCE_IMPLEMENTATION");
 1542|      1|  SIMDUTF_POP_DISABLE_WARNINGS
 1543|       |
 1544|      1|  if (force_implementation_name) {
  ------------------
  |  Branch (1544:7): [True: 0, False: 1]
  ------------------
 1545|      0|    auto force_implementation =
 1546|      0|        get_available_implementations()[force_implementation_name];
 1547|      0|    if (force_implementation) {
  ------------------
  |  Branch (1547:9): [True: 0, False: 0]
  ------------------
 1548|      0|      return get_active_implementation() = force_implementation;
 1549|      0|    } else {
 1550|       |      // Note: abort() and stderr usage within the library is forbidden.
 1551|      0|      return get_active_implementation() = get_unsupported_singleton();
 1552|      0|    }
 1553|      0|  }
 1554|      1|  return get_active_implementation() =
 1555|      1|             get_available_implementations().detect_best_supported();
 1556|      1|}
_ZN7simdutf29get_available_implementationsEv:
 1568|      2|get_available_implementations() {
 1569|      2|#if !SIMDUTF_USE_STATIC_INITIALIZATION
 1570|      2|  static const internal::available_implementation_list
 1571|      2|      available_implementations_instance{};
 1572|      2|#endif
 1573|      2|  return available_implementations_instance;
 1574|      2|}
_ZN7simdutf25get_active_implementationEv:
 1596|    539|get_active_implementation() {
 1597|    539|#if !SIMDUTF_USE_STATIC_INITIALIZATION
 1598|    539|  #if !SIMDUTF_SINGLE_IMPLEMENTATION
 1599|    539|  static const internal::detect_best_supported_implementation_on_first_use
 1600|    539|      detect_best_supported_implementation_on_first_use_singleton;
 1601|    539|  #endif
 1602|    539|  static internal::atomic_ptr<const implementation>
 1603|    539|      active_implementation_instance{
 1604|       |  #if SIMDUTF_SINGLE_IMPLEMENTATION
 1605|       |          internal::get_single_implementation()
 1606|       |  #else
 1607|    539|          &detect_best_supported_implementation_on_first_use_singleton
 1608|    539|  #endif
 1609|    539|      };
 1610|    539|#endif
 1611|    539|  return active_implementation_instance;
 1612|    539|}
_ZN7simdutf22convert_latin1_to_utf8EPKcmPc:
 1678|    538|                                                  char *utf8_output) noexcept {
 1679|    538|  return get_default_implementation()->convert_latin1_to_utf8(buf, len,
 1680|    538|                                                              utf8_output);
 1681|    538|}
_ZN7simdutf27convert_latin1_to_utf8_safeEPKcmPcm:
 2694|    267|    const char *buf, size_t len, char *utf8_output, size_t utf8_len) noexcept {
 2695|    267|  const auto start{utf8_output};
 2696|       |
 2697|    538|  while (true) {
  ------------------
  |  Branch (2697:10): [True: 538, Folded]
  ------------------
 2698|       |    // convert_latin1_to_utf8 will never write more than input length * 2
 2699|    538|    auto read_len = detail::min(len, utf8_len >> 1);
 2700|    538|    if (read_len <= 16) {
  ------------------
  |  Branch (2700:9): [True: 267, False: 271]
  ------------------
 2701|    267|      break;
 2702|    267|    }
 2703|       |
 2704|    271|    const auto write_len =
 2705|    271|        simdutf::convert_latin1_to_utf8(buf, read_len, utf8_output);
 2706|       |
 2707|    271|    utf8_output += write_len;
 2708|    271|    utf8_len -= write_len;
 2709|    271|    buf += read_len;
 2710|    271|    len -= read_len;
 2711|    271|  }
 2712|       |
 2713|    267|  utf8_output +=
 2714|    267|      scalar::latin1_to_utf8::convert_safe(buf, len, utf8_output, utf8_len);
 2715|       |
 2716|    267|  return utf8_output - start;
 2717|    267|}
_ZN7simdutf17trim_partial_utf8EPKcm:
 2811|    110|simdutf_warn_unused size_t trim_partial_utf8(const char *input, size_t length) {
 2812|    110|  return scalar::utf8::trim_partial_utf8(input, length);
 2813|    110|}
_ZN7simdutf20trim_partial_utf16beEPKDsm:
 2823|     23|                                                size_t length) {
 2824|     23|  return scalar::utf16::trim_partial_utf16<BIG>(input, length);
 2825|     23|}
_ZN7simdutf20trim_partial_utf16leEPKDsm:
 2828|     40|                                                size_t length) {
 2829|     40|  return scalar::utf16::trim_partial_utf16<LITTLE>(input, length);
 2830|     40|}
simdutf.cpp:_ZN7simdutf8internalL37get_available_implementation_pointersEv:
  938|      3|get_available_implementation_pointers() {
  939|      3|#if !SIMDUTF_USE_STATIC_INITIALIZATION
  940|      3|  static const std::initializer_list<const implementation *>
  941|      3|      available_implementation_pointers{
  942|      3|  #if SIMDUTF_IMPLEMENTATION_ICELAKE
  943|      3|          get_icelake_singleton(),
  944|      3|  #endif
  945|      3|  #if SIMDUTF_IMPLEMENTATION_HASWELL
  946|      3|          get_haswell_singleton(),
  947|      3|  #endif
  948|      3|  #if SIMDUTF_IMPLEMENTATION_WESTMERE
  949|      3|          get_westmere_singleton(),
  950|      3|  #endif
  951|       |  #if SIMDUTF_IMPLEMENTATION_ARM64
  952|       |          get_arm64_singleton(),
  953|       |  #endif
  954|       |  #if SIMDUTF_IMPLEMENTATION_PPC64
  955|       |          get_ppc64_singleton(),
  956|       |  #endif
  957|       |  #if SIMDUTF_IMPLEMENTATION_RVV
  958|       |          get_rvv_singleton(),
  959|       |  #endif
  960|       |  #if SIMDUTF_IMPLEMENTATION_LASX
  961|       |          get_lasx_singleton(),
  962|       |  #endif
  963|       |  #if SIMDUTF_IMPLEMENTATION_LSX
  964|       |          get_lsx_singleton(),
  965|       |  #endif
  966|      3|  #if SIMDUTF_IMPLEMENTATION_FALLBACK
  967|      3|          get_fallback_singleton(),
  968|      3|  #endif
  969|      3|      };
  970|      3|#endif
  971|      3|  return available_implementation_pointers;
  972|      3|}
simdutf.cpp:_ZN7simdutf8internalL21get_icelake_singletonEv:
  157|      1|static const icelake::implementation *get_icelake_singleton() {
  158|      1|  #if !SIMDUTF_USE_STATIC_INITIALIZATION
  159|      1|  static const icelake::implementation icelake_singleton{};
  160|      1|  #endif
  161|      1|  return &icelake_singleton;
  162|      1|}
simdutf.cpp:_ZN7simdutf8internalL21get_haswell_singletonEv:
  168|      1|static const haswell::implementation *get_haswell_singleton() {
  169|      1|  #if !SIMDUTF_USE_STATIC_INITIALIZATION
  170|      1|  static const haswell::implementation haswell_singleton{};
  171|      1|  #endif
  172|      1|  return &haswell_singleton;
  173|      1|}
simdutf.cpp:_ZN7simdutf8internalL22get_westmere_singletonEv:
  179|      1|static const westmere::implementation *get_westmere_singleton() {
  180|      1|  #if !SIMDUTF_USE_STATIC_INITIALIZATION
  181|      1|  static const westmere::implementation westmere_singleton{};
  182|      1|  #endif
  183|      1|  return &westmere_singleton;
  184|      1|}
simdutf.cpp:_ZN7simdutf8internalL22get_fallback_singletonEv:
  245|      1|static const fallback::implementation *get_fallback_singleton() {
  246|      1|  #if !SIMDUTF_USE_STATIC_INITIALIZATION
  247|      1|  static const fallback::implementation fallback_singleton{};
  248|      1|  #endif
  249|      1|  return &fallback_singleton;
  250|      1|}
_ZN7simdutf8internal49detect_best_supported_implementation_on_first_useC2Ev:
  892|      1|      : implementation("best_supported_detector",
  893|      1|                       "Detects the best supported implementation and sets it",
  894|      1|                       0) {}
_ZNK7simdutf8internal49detect_best_supported_implementation_on_first_use22convert_latin1_to_utf8EPKcmPc:
  399|      1|                         char *utf8_output) const noexcept final override {
  400|      1|    return set_best()->convert_latin1_to_utf8(buf, len, utf8_output);
  401|      1|  }
_ZN7simdutf26get_default_implementationEv:
 1620|    538|get_default_implementation() {
 1621|    538|  return get_active_implementation();
 1622|    538|}

_ZN7simdutf8fallback14implementationC2Ev:
   16|      1|      : simdutf::implementation("fallback", "Generic fallback implementation",
   17|      1|                                0) {}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115trailing_zeroesEm:
   20|    337|simdutf_really_inline int trailing_zeroes(uint64_t input_num) {
   21|       |  #if SIMDUTF_REGULAR_VISUAL_STUDIO
   22|       |  return (int)_tzcnt_u64(input_num);
   23|       |  #else  // SIMDUTF_REGULAR_VISUAL_STUDIO
   24|    337|  return __builtin_ctzll(input_num);
   25|    337|  #endif // SIMDUTF_REGULAR_VISUAL_STUDIO
   26|    337|}

_ZN7simdutf7haswell14implementationC2Ev:
   16|      1|      : simdutf::implementation("haswell", "Intel/AMD AVX2",
   17|      1|                                internal::instruction_set::AVX2 |
   18|      1|                                    internal::instruction_set::BMI1 |
   19|      1|                                    internal::instruction_set::BMI2) {}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5simd8IhEC2Ev:
  191|  6.81k|  simdutf_really_inline simd8() : base8_numeric<uint8_t>() {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIhEC2Ev:
  124|  6.81k|  simdutf_really_inline base8_numeric() : base8<T>() {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEEC2Ev:
   71|  6.81k|  simdutf_really_inline base8() : base<simd8<T>>() {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEC2Ev:
   14|  6.81k|  simdutf_really_inline base() : value{__m256i()} {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IhEC2EPKh:
  274|   749k|      : chunks{simd8<T>::load(ptr),
  275|   749k|               simd8<T>::load(ptr + sizeof(simd8<T>) / sizeof(T))} {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIhE4loadEPKh:
  111|  1.58M|  static simdutf_really_inline simd8<T> load(const T values[32]) {
  112|  1.58M|    return _mm256_loadu_si256(reinterpret_cast<const __m256i *>(values));
  113|  1.58M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5simd8IhEC2EDv4_x:
  193|  10.0M|      : base8_numeric<uint8_t>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIhEC2EDv4_x:
  126|  10.0M|      : base8<T>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEEC2EDv4_x:
   73|  10.0M|  simdutf_really_inline base8(const __m256i _value) : base<simd8<T>>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEC2EDv4_x:
   17|  10.0M|  simdutf_really_inline base(const __m256i _value) : value(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEoRES5_:
   59|   516k|  simdutf_really_inline Child &operator|=(const Child other) {
   60|   516k|    auto this_cast = static_cast<Child *>(this);
   61|   516k|    *this_cast = *this_cast | other;
   62|   516k|    return *this_cast;
   63|   516k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEorES5_:
   50|  1.26M|  simdutf_really_inline Child operator|(const Child other) const {
   51|  1.26M|    return _mm256_or_si256(*this, other);
   52|  1.26M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEcvRKDv4_xEv:
   19|  15.1M|  simdutf_really_inline operator const __m256i &() const { return this->value; }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IhE9reduce_orEv:
  294|   576k|  simdutf_really_inline simd8<T> reduce_or() const {
  295|   576k|    return this->chunks[0] | this->chunks[1];
  296|   576k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IhE8is_asciiEv:
  234|   576k|  simdutf_really_inline bool is_ascii() const {
  235|   576k|    return _mm256_movemask_epi8(*this) == 0;
  236|   576k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEE4prevILi1EEENS4_IhEES8_:
   83|   172k|  simdutf_really_inline simd8<T> prev(const simd8<T> prev_chunk) const {
   84|       |    return _mm256_alignr_epi8(
   85|   172k|        *this, _mm256_permute2x128_si256(prev_chunk, *this, 0x21), 16 - N);
   86|   172k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IhE3shrILi4EEES4_v:
  245|   345k|  template <int N> simdutf_really_inline simd8<uint8_t> shr() const {
  246|   345k|    return simd8<uint8_t>(_mm256_srli_epi16(*this, N)) & uint8_t(0xFFu >> N);
  247|   345k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIhE9lookup_16IhEENS2_5simd8IT_EES7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_:
  157|   518k|            L replace15) const {
  158|   518k|    return lookup_16(simd8<L>::repeat_16(
  159|   518k|        replace0, replace1, replace2, replace3, replace4, replace5, replace6,
  160|   518k|        replace7, replace8, replace9, replace10, replace11, replace12,
  161|   518k|        replace13, replace14, replace15));
  162|   518k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIhE9lookup_16IhEENS2_5simd8IT_EES8_:
  148|   518k|  simdutf_really_inline simd8<L> lookup_16(simd8<L> lookup_table) const {
  149|   518k|    return _mm256_shuffle_epi8(lookup_table, *this);
  150|   518k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIhE9repeat_16Ehhhhhhhhhhhhhhhh:
  118|   518k|                                                  T v14, T v15) {
  119|   518k|    return simd8<T>(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,
  120|   518k|                    v14, v15, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,
  121|   518k|                    v12, v13, v14, v15);
  122|   518k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5simd8IhEC2Ehhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh:
  207|   518k|      : simd8(_mm256_setr_epi8(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,
  208|   518k|                               v12, v13, v14, v15, v16, v17, v18, v19, v20, v21,
  209|   518k|                               v22, v23, v24, v25, v26, v27, v28, v29, v30,
  210|   518k|                               v31)) {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEanES5_:
   53|  2.28M|  simdutf_really_inline Child operator&(const Child other) const {
   54|  2.28M|    return _mm256_and_si256(*this, other);
   55|  2.28M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5simd8IhEC2Eh:
  195|  1.03M|  simdutf_really_inline simd8(uint8_t _value) : simd8(splat(_value)) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIhE5splatEh:
  105|  1.05M|  static simdutf_really_inline simd8<T> splat(T _value) {
  106|  1.05M|    return _mm256_set1_epi8(_value);
  107|  1.05M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEE4prevILi2EEENS4_IhEES8_:
   83|   172k|  simdutf_really_inline simd8<T> prev(const simd8<T> prev_chunk) const {
   84|       |    return _mm256_alignr_epi8(
   85|   172k|        *this, _mm256_permute2x128_si256(prev_chunk, *this, 0x21), 16 - N);
   86|   172k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEE4prevILi3EEENS4_IhEES8_:
   83|   172k|  simdutf_really_inline simd8<T> prev(const simd8<T> prev_chunk) const {
   84|       |    return _mm256_alignr_epi8(
   85|   172k|        *this, _mm256_permute2x128_si256(prev_chunk, *this, 0x21), 16 - N);
   86|   172k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IhE14saturating_subES4_:
  214|   432k|  saturating_sub(const simd8<uint8_t> other) const {
  215|   432k|    return _mm256_subs_epu8(*this, other);
  216|   432k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5simd8IbEC2EDv4_x:
   95|  1.42M|  simdutf_really_inline simd8(const __m256i _value) : base8<bool>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5base8IbNS2_5simd8IbEEEC2EDv4_x:
   73|  1.42M|  simdutf_really_inline base8(const __m256i _value) : base<simd8<T>>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IbEEEC2EDv4_x:
   17|  1.42M|  simdutf_really_inline base(const __m256i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IbEEEcvRKDv4_xEv:
   19|   172k|  simdutf_really_inline operator const __m256i &() const { return this->value; }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEeoES5_:
   56|   172k|  simdutf_really_inline Child operator^(const Child other) const {
   57|   172k|    return _mm256_xor_si256(*this, other);
   58|   172k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5simd8IhEC2EPKh:
  197|  86.7k|  simdutf_really_inline simd8(const uint8_t values[32]) : simd8(load(values)) {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IhE7gt_bitsES4_:
  225|  86.4k|  gt_bits(const simd8<uint8_t> other) const {
  226|  86.4k|    return this->saturating_sub(other);
  227|  86.4k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IhE8is_asciiEv:
  298|   148k|  simdutf_really_inline bool is_ascii() const {
  299|   148k|    return this->reduce_or().is_ascii();
  300|   148k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IhE13gteq_unsignedEh:
  341|    368|  simdutf_really_inline uint64_t gteq_unsigned(const uint8_t m) const {
  342|    368|    const simd8<uint8_t> mask = simd8<uint8_t>::splat(m);
  343|    368|    return simd8x64<bool>((simd8<uint8_t>(__m256i(this->chunks[0])) >= mask),
  344|    368|                          (simd8<uint8_t>(__m256i(this->chunks[1])) >= mask))
  345|    368|        .to_bitmask();
  346|    368|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IhEgeES4_:
  229|    736|  operator>=(const simd8<uint8_t> other) const {
  230|    736|    return other.min_val(*this) == other;
  231|    736|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simdeqENS2_5simd8IhEES4_:
   76|  1.24M|                                               const simd8<T> rhs) {
   77|  1.24M|    return _mm256_cmpeq_epi8(lhs, rhs);
   78|  1.24M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IhE7min_valES4_:
  220|    736|  min_val(const simd8<uint8_t> other) const {
  221|    736|    return _mm256_min_epu8(other, *this);
  222|    736|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IbEC2ENS2_5simd8IbEES6_:
  272|    368|      : chunks{chunk0, chunk1} {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IbE10to_bitmaskEv:
  282|    368|  simdutf_really_inline uint64_t to_bitmask() const {
  283|    368|    uint64_t r_lo = uint32_t(this->chunks[0].to_bitmask());
  284|    368|    uint64_t r_hi = this->chunks[1].to_bitmask();
  285|    368|    return r_lo | (r_hi << 32);
  286|    368|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IbE10to_bitmaskEv:
   99|  1.24M|  simdutf_really_inline uint32_t to_bitmask() const {
  100|  1.24M|    return uint32_t(_mm256_movemask_epi8(value));
  101|  1.24M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IhE21any_bits_set_anywhereEv:
  241|  19.7k|  simdutf_really_inline bool any_bits_set_anywhere() const {
  242|  19.7k|    return !bits_not_set_anywhere();
  243|  19.7k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IhE21bits_not_set_anywhereEv:
  237|  19.7k|  simdutf_really_inline bool bits_not_set_anywhere() const {
  238|  19.7k|    return _mm256_testz_si256(*this, *this);
  239|  19.7k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_6simd16ItEEEC2EDv4_x:
   17|  5.80M|  simdutf_really_inline base(const __m256i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_6simd16ItEEEcvRKDv4_xEv:
   19|  8.76M|  simdutf_really_inline operator const __m256i &() const { return this->value; }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_6simd16IbEEEC2EDv4_x:
   17|  7.18k|  simdutf_really_inline base(const __m256i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_6simd16IbEEEcvRKDv4_xEv:
   19|  7.18k|  simdutf_really_inline operator const __m256i &() const { return this->value; }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_6simd16ItEEEanES5_:
   53|  1.02M|  simdutf_really_inline Child operator&(const Child other) const {
   54|  1.02M|    return _mm256_and_si256(*this, other);
   55|  1.02M|  }

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd9simd16x32ItEC2EPKt:
  202|   101k|      : chunks{simd16<T>::load(ptr),
  203|   101k|               simd16<T>::load(ptr + sizeof(simd16<T>) / sizeof(T))} {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd14base16_numericItE4loadEPKt:
   66|  2.64M|  static simdutf_really_inline simd16<T> load(const T values[8]) {
   67|  2.64M|    return _mm256_loadu_si256(reinterpret_cast<const __m256i *>(values));
   68|  2.64M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd16ItEC2EDv4_x:
   97|  5.80M|      : base16_numeric<uint16_t>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd14base16_numericItEC2EDv4_x:
   73|  5.80M|      : base16<T>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6base16ItNS2_6simd16IbEEEC2EDv4_x:
   20|  5.80M|      : base<simd16<T>>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd9simd16x32ItE10swap_bytesEv:
  229|   100k|  simdutf_really_inline void swap_bytes() {
  230|   100k|    this->chunks[0] = this->chunks[0].swap_bytes();
  231|   100k|    this->chunks[1] = this->chunks[1].swap_bytes();
  232|   100k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd6simd16ItE10swap_bytesEv:
  139|   200k|  simdutf_really_inline simd16<uint16_t> swap_bytes() const {
  140|   200k|    const __m256i swap = _mm256_setr_epi8(
  141|   200k|        1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
  142|   200k|        21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
  143|   200k|    return _mm256_shuffle_epi8(*this, swap);
  144|   200k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd9simd16x32ItE5storeEPt:
  205|  97.9k|  simdutf_really_inline void store(T *ptr) const {
  206|  97.9k|    this->chunks[0].store(ptr + sizeof(simd16<T>) * 0 / sizeof(T));
  207|  97.9k|    this->chunks[1].store(ptr + sizeof(simd16<T>) * 1 / sizeof(T));
  208|  97.9k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd14base16_numericItE5storeEPt:
   76|   195k|  simdutf_really_inline void store(T dst[8]) const {
   77|   195k|    return _mm256_storeu_si256(reinterpret_cast<__m256i *>(dst), *this);
   78|   195k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd14base16_numericItE5splatEt:
   58|   516k|  static simdutf_really_inline simd16<T> splat(T _value) {
   59|   516k|    return _mm256_set1_epi16(_value);
   60|   516k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simdeqENS2_6simd16ItEES4_:
   26|  7.18k|                                               const simd16<T> rhs) {
   27|  7.18k|    return _mm256_cmpeq_epi16(lhs, rhs);
   28|  7.18k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd16IbEC2EDv4_x:
   45|  7.18k|  simdutf_really_inline simd16(const __m256i _value) : base16<bool>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6base16IbNS2_6simd16IbEEEC2EDv4_x:
   20|  7.18k|      : base<simd16<T>>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd9simd16x32IbEC2ENS2_6simd16IbEES6_:
  200|  3.59k|      : chunks{chunk0, chunk1} {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd9simd16x32IbE10to_bitmaskEv:
  210|  3.59k|  simdutf_really_inline uint64_t to_bitmask() const {
  211|  3.59k|    uint64_t r_lo = uint32_t(this->chunks[0].to_bitmask());
  212|  3.59k|    uint64_t r_hi = this->chunks[1].to_bitmask();
  213|  3.59k|    return r_lo | (r_hi << 32);
  214|  3.59k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd6simd16IbE10to_bitmaskEv:
   50|  7.18k|  simdutf_really_inline bitmask_type to_bitmask() const {
   51|  7.18k|    return _mm256_movemask_epi8(*this);
   52|  7.18k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd9simd16x32ItE4lteqEt:
  239|  3.59k|  simdutf_really_inline uint64_t lteq(const T m) const {
  240|  3.59k|    const simd16<T> mask = simd16<T>::splat(m);
  241|  3.59k|    return simd16x32<bool>(this->chunks[0] <= mask, this->chunks[1] <= mask)
  242|  3.59k|        .to_bitmask();
  243|  3.59k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd6simd16ItEleES4_:
  117|  7.18k|  operator<=(const simd16<uint16_t> other) const {
  118|  7.18k|    return other.max_val(*this) == other;
  119|  7.18k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd6simd16ItE7max_valES4_:
  108|  7.18k|  max_val(const simd16<uint16_t> other) const {
  109|  7.18k|    return _mm256_max_epu16(*this, other);
  110|  7.18k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd16ItEC2EPKDs:
  104|  2.43M|      : simd16(load(reinterpret_cast<const uint16_t *>(values))) {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd6simd16ItE3shrILi8EEES4_v:
  134|  1.41M|  template <int N> simdutf_really_inline simd16<uint16_t> shr() const {
  135|  1.41M|    return simd16<uint16_t>(_mm256_srli_epi16(*this, N));
  136|  1.41M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd16ItE4packERKS4_S6_:
  149|  1.21M|                                                   const simd16<uint16_t> &v1) {
  150|       |    // Note: the AVX2 variant of pack operates on 128-bit lanes, thus
  151|       |    //       we have to shuffle lanes in order to produce bytes in the
  152|       |    //       correct order.
  153|       |
  154|       |    // get the 0th lanes
  155|  1.21M|    const __m128i lo_0 = _mm256_extracti128_si256(v0, 0);
  156|  1.21M|    const __m128i lo_1 = _mm256_extracti128_si256(v1, 0);
  157|       |
  158|       |    // get the 1st lanes
  159|  1.21M|    const __m128i hi_0 = _mm256_extracti128_si256(v0, 1);
  160|  1.21M|    const __m128i hi_1 = _mm256_extracti128_si256(v1, 1);
  161|       |
  162|       |    // build new vectors (shuffle lanes)
  163|  1.21M|    const __m256i t0 = _mm256_set_m128i(lo_1, lo_0);
  ------------------
  |  |    4|  1.21M|      _mm256_permute2f128_si256(_mm256_castsi128_si256(xmm1),                  \
  |  |    5|  1.21M|                                _mm256_castsi128_si256(xmm2), 2)
  ------------------
  164|  1.21M|    const __m256i t1 = _mm256_set_m128i(hi_1, hi_0);
  ------------------
  |  |    4|  1.21M|      _mm256_permute2f128_si256(_mm256_castsi128_si256(xmm1),                  \
  |  |    5|  1.21M|                                _mm256_castsi128_si256(xmm2), 2)
  ------------------
  165|       |
  166|       |    // pack code units in linear order from v0 and v1
  167|  1.21M|    return _mm256_packus_epi16(t0, t1);
  168|  1.21M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd16ItEC2Et:
  100|   512k|  simdutf_really_inline simd16(uint16_t _value) : simd16(splat(_value)) {}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd32IjE5splatEj:
   46|  1.46k|  simdutf_really_inline static simd32<uint32_t> splat(uint32_t v) {
   47|  1.46k|    return _mm256_set1_epi32(v);
   48|  1.46k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd32IjEC2EDv4_x:
    9|  1.46M|  simdutf_really_inline simd32(const __m256i v) : value(v) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd32IjEC2IDiEEPKT_:
   13|   366k|      : value(_mm256_loadu_si256(reinterpret_cast<const __m256i *>(ptr))) {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd6simd32IjE10swap_bytesEv:
   27|   366k|  simdutf_really_inline simd32<uint32_t> swap_bytes() const {
   28|   366k|    const __m256i shuffle =
   29|   366k|        _mm256_setr_epi8(3, 2, 1, 0, 7, 6, 5, 4, 8, 9, 10, 11, 15, 14, 13, 12,
   30|   366k|                         3, 2, 1, 0, 7, 6, 5, 4, 8, 9, 10, 11, 15, 14, 13, 12);
   31|       |
   32|   366k|    return _mm256_shuffle_epi8(value, shuffle);
   33|   366k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simdgeENS2_6simd32IjEES4_:
  100|    735|                                              const simd32<uint32_t> b) {
  101|    735|  return _mm256_cmpeq_epi32(_mm256_max_epu32(a.value, b.value), a.value);
  102|    735|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd32IbEC2EDv4_x:
   59|  1.47k|  simdutf_really_inline simd32(const __m256i v) : value(v) {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd6simd32IbE3anyEv:
   61|    735|  simdutf_really_inline bool any() const {
   62|    735|    return _mm256_movemask_epi8(value) != 0;
   63|    735|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd32IjE4zeroEv:
   42|    978|  simdutf_really_inline static simd32<uint32_t> zero() {
   43|    978|    return _mm256_setzero_si256();
   44|    978|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd3maxENS2_6simd32IjEES4_:
   80|   732k|                                           const simd32<uint32_t> b) {
   81|   732k|  return _mm256_max_epu32(a.value, b.value);
   82|   732k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simdplENS2_6simd32IjEES4_:
   90|   366k|                                                 const simd32<uint32_t> b) {
   91|   366k|  return _mm256_add_epi32(a.value, b.value);
   92|   366k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simdgtENS2_6simd32IjEES4_:
  109|    735|                                             const simd32<uint32_t> b) {
  110|    735|  return !(b >= a);
  111|    735|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simdntENS2_6simd32IbEE:
  104|    735|simdutf_really_inline simd32<bool> operator!(const simd32<bool> v) {
  105|    735|  return _mm256_xor_si256(v.value, _mm256_set1_epi8(-1));
  106|    735|}

_ZN7simdutf7icelake14implementationC2Ev:
   16|      1|      : simdutf::implementation(
   17|      1|            "icelake",
   18|      1|            "Intel AVX512 (AVX-512BW, AVX-512CD, AVX-512VL, AVX-512VBMI2 "
   19|      1|            "extensions)",
   20|      1|            internal::instruction_set::AVX2 | internal::instruction_set::BMI1 |
   21|      1|                internal::instruction_set::BMI2 |
   22|      1|                internal::instruction_set::AVX512BW |
   23|      1|                internal::instruction_set::AVX512CD |
   24|      1|                internal::instruction_set::AVX512VL |
   25|      1|                internal::instruction_set::AVX512VBMI2 |
   26|      1|                internal::instruction_set::AVX512VPOPCNTDQ) {}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115trailing_zeroesEm:
   20|    390|simdutf_really_inline int trailing_zeroes(uint64_t input_num) {
   21|       |  #if SIMDUTF_REGULAR_VISUAL_STUDIO
   22|       |  unsigned long ret;
   23|       |  _BitScanForward64(&ret, input_num);
   24|       |  return (int)ret;
   25|       |  #else  // SIMDUTF_REGULAR_VISUAL_STUDIO
   26|    390|  return __builtin_ctzll(input_num);
   27|    390|  #endif // SIMDUTF_REGULAR_VISUAL_STUDIO
   28|    390|}

_ZN7simdutf8westmere14implementationC2Ev:
   18|      1|      : simdutf::implementation("westmere", "Intel/AMD SSE4.2",
   19|      1|                                internal::instruction_set::SSE42) {}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IhEC2Ev:
  183|  6.81k|  simdutf_really_inline simd8() : base8_numeric<uint8_t>() {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhEC2Ev:
  118|  6.81k|  simdutf_really_inline base8_numeric() : base8<T>() {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEEC2Ev:
   68|  6.81k|  simdutf_really_inline base8() : base<simd8<T>>() {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEC2Ev:
   13|  6.81k|  simdutf_really_inline base() : value{__m128i()} {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IhEC2EPKh:
  270|   749k|      : chunks{simd8<T>::load(ptr),
  271|   749k|               simd8<T>::load(ptr + sizeof(simd8<T>) / sizeof(T)),
  272|   749k|               simd8<T>::load(ptr + 2 * sizeof(simd8<T>) / sizeof(T)),
  273|   749k|               simd8<T>::load(ptr + 3 * sizeof(simd8<T>) / sizeof(T))} {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhE4loadEPKh:
  106|  3.08M|  static simdutf_really_inline simd8<T> load(const T values[16]) {
  107|  3.08M|    return _mm_loadu_si128(reinterpret_cast<const __m128i *>(values));
  108|  3.08M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IhEC2EDv2_x:
  185|  19.7M|      : base8_numeric<uint8_t>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhEC2EDv2_x:
  120|  19.7M|      : base8<T>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEEC2EDv2_x:
   69|  19.7M|  simdutf_really_inline base8(const __m128i _value) : base<simd8<T>>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEC2EDv2_x:
   16|  19.7M|  simdutf_really_inline base(const __m128i _value) : value(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEoRES5_:
   51|   688k|  simdutf_really_inline Child &operator|=(const Child other) {
   52|   688k|    auto this_cast = static_cast<Child *>(this);
   53|   688k|    *this_cast = *this_cast | other;
   54|   688k|    return *this_cast;
   55|   688k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEorES5_:
   42|  2.76M|  simdutf_really_inline Child operator|(const Child other) const {
   43|  2.76M|    return _mm_or_si128(*this, other);
   44|  2.76M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEcvRKDv2_xEv:
   18|  27.9M|  simdutf_really_inline operator const __m128i &() const { return this->value; }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IhE9reduce_orEv:
  290|   576k|  simdutf_really_inline simd8<T> reduce_or() const {
  291|   576k|    return (this->chunks[0] | this->chunks[1]) |
  292|   576k|           (this->chunks[2] | this->chunks[3]);
  293|   576k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE8is_asciiEv:
  228|   576k|  simdutf_really_inline bool is_ascii() const {
  229|   576k|    return _mm_movemask_epi8(*this) == 0;
  230|   576k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEE4prevILi1EEENS4_IhEES8_:
   79|   345k|  simdutf_really_inline simd8<T> prev(const simd8<T> prev_chunk) const {
   80|       |    return _mm_alignr_epi8(*this, prev_chunk, 16 - N);
   81|   345k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE3shrILi4EEES4_v:
  238|   691k|  template <int N> simdutf_really_inline simd8<uint8_t> shr() const {
  239|   691k|    return simd8<uint8_t>(_mm_srli_epi16(*this, N)) & uint8_t(0xFFu >> N);
  240|   691k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhE9lookup_16IhEENS2_5simd8IT_EES7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_:
  151|  1.03M|            L replace15) const {
  152|  1.03M|    return lookup_16(simd8<L>::repeat_16(
  153|  1.03M|        replace0, replace1, replace2, replace3, replace4, replace5, replace6,
  154|  1.03M|        replace7, replace8, replace9, replace10, replace11, replace12,
  155|  1.03M|        replace13, replace14, replace15));
  156|  1.03M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhE9lookup_16IhEENS2_5simd8IT_EES8_:
  142|  1.03M|  simdutf_really_inline simd8<L> lookup_16(simd8<L> lookup_table) const {
  143|  1.03M|    return _mm_shuffle_epi8(lookup_table, *this);
  144|  1.03M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhE9repeat_16Ehhhhhhhhhhhhhhhh:
  113|  1.03M|                                                  T v14, T v15) {
  114|  1.03M|    return simd8<T>(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,
  115|  1.03M|                    v14, v15);
  116|  1.03M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IhEC2Ehhhhhhhhhhhhhhhh:
  196|  1.03M|      : simd8(_mm_setr_epi8(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,
  197|  1.03M|                            v12, v13, v14, v15)) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEanES5_:
   45|  4.33M|  simdutf_really_inline Child operator&(const Child other) const {
   46|  4.33M|    return _mm_and_si128(*this, other);
   47|  4.33M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IhEC2Eh:
  188|  2.07M|  simdutf_really_inline simd8(uint8_t _value) : simd8(splat(_value)) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhE5splatEh:
  102|  2.08M|  static simdutf_really_inline simd8<T> splat(T _value) {
  103|  2.08M|    return _mm_set1_epi8(_value);
  104|  2.08M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEE4prevILi2EEENS4_IhEES8_:
   79|   345k|  simdutf_really_inline simd8<T> prev(const simd8<T> prev_chunk) const {
   80|       |    return _mm_alignr_epi8(*this, prev_chunk, 16 - N);
   81|   345k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEE4prevILi3EEENS4_IhEES8_:
   79|   345k|  simdutf_really_inline simd8<T> prev(const simd8<T> prev_chunk) const {
   80|       |    return _mm_alignr_epi8(*this, prev_chunk, 16 - N);
   81|   345k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE14saturating_subES4_:
  201|   777k|  saturating_sub(const simd8<uint8_t> other) const {
  202|   777k|    return _mm_subs_epu8(*this, other);
  203|   777k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IbEC2EDv2_x:
   91|  2.61M|  simdutf_really_inline simd8(const __m128i _value) : base8<bool>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5base8IbNS2_5simd8IbEEEC2EDv2_x:
   69|  2.61M|  simdutf_really_inline base8(const __m128i _value) : base<simd8<T>>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IbEEEC2EDv2_x:
   16|  2.61M|  simdutf_really_inline base(const __m128i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IbEEEcvRKDv2_xEv:
   18|  2.61M|  simdutf_really_inline operator const __m128i &() const { return this->value; }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEeoES5_:
   48|   345k|  simdutf_really_inline Child operator^(const Child other) const {
   49|   345k|    return _mm_xor_si128(*this, other);
   50|   345k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IhEC2EPKh:
  190|  86.8k|  simdutf_really_inline simd8(const uint8_t *values) : simd8(load(values)) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE7gt_bitsES4_:
  212|  86.4k|  gt_bits(const simd8<uint8_t> other) const {
  213|  86.4k|    return this->saturating_sub(other);
  214|  86.4k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IhE8is_asciiEv:
  295|   148k|  simdutf_really_inline bool is_ascii() const {
  296|   148k|    return this->reduce_or().is_ascii();
  297|   148k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IhE13gteq_unsignedEh:
  352|    428|  simdutf_really_inline uint64_t gteq_unsigned(const uint8_t m) const {
  353|    428|    const simd8<uint8_t> mask = simd8<uint8_t>::splat(m);
  354|    428|    return simd8x64<bool>(simd8<uint8_t>(__m128i(this->chunks[0])) >= mask,
  355|    428|                          simd8<uint8_t>(__m128i(this->chunks[1])) >= mask,
  356|    428|                          simd8<uint8_t>(__m128i(this->chunks[2])) >= mask,
  357|    428|                          simd8<uint8_t>(__m128i(this->chunks[3])) >= mask)
  358|    428|        .to_bitmask();
  359|    428|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhEgeES4_:
  217|  1.71k|  operator>=(const simd8<uint8_t> other) const {
  218|  1.71k|    return other.min_val(*this) == other;
  219|  1.71k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simdeqENS2_5simd8IhEES4_:
   72|  2.26M|                                               const simd8<T> rhs) {
   73|  2.26M|    return _mm_cmpeq_epi8(lhs, rhs);
   74|  2.26M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE7min_valES4_:
  207|  1.71k|  min_val(const simd8<uint8_t> other) const {
  208|  1.71k|    return _mm_min_epu8(*this, other);
  209|  1.71k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IbEC2ENS2_5simd8IbEES6_S6_S6_:
  268|    428|      : chunks{chunk0, chunk1, chunk2, chunk3} {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IbE10to_bitmaskEv:
  318|    428|  simdutf_really_inline uint64_t to_bitmask() const {
  319|    428|    uint64_t r0 = uint32_t(this->chunks[0].to_bitmask());
  320|    428|    uint64_t r1 = this->chunks[1].to_bitmask();
  321|    428|    uint64_t r2 = this->chunks[2].to_bitmask();
  322|    428|    uint64_t r3 = this->chunks[3].to_bitmask();
  323|    428|    return r0 | (r1 << 16) | (r2 << 32) | (r3 << 48);
  324|    428|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IbE10to_bitmaskEv:
   95|  2.26M|  simdutf_really_inline int to_bitmask() const {
   96|  2.26M|    return _mm_movemask_epi8(*this);
   97|  2.26M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE21any_bits_set_anywhereEv:
  235|  19.7k|  simdutf_really_inline bool any_bits_set_anywhere() const {
  236|  19.7k|    return !bits_not_set_anywhere();
  237|  19.7k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE21bits_not_set_anywhereEv:
  232|  19.7k|  simdutf_really_inline bool bits_not_set_anywhere() const {
  233|  19.7k|    return _mm_testz_si128(*this, *this);
  234|  19.7k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_6simd16ItEEEC2EDv2_x:
   16|  10.6M|  simdutf_really_inline base(const __m128i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_6simd16ItEEEcvRKDv2_xEv:
   18|  11.5M|  simdutf_really_inline operator const __m128i &() const { return this->value; }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_6simd16IbEEEC2EDv2_x:
   16|  14.7k|  simdutf_really_inline base(const __m128i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_6simd16IbEEEcvRKDv2_xEv:
   18|  14.7k|  simdutf_really_inline operator const __m128i &() const { return this->value; }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_6simd16ItEEEanES5_:
   45|  1.83M|  simdutf_really_inline Child operator&(const Child other) const {
   46|  1.83M|    return _mm_and_si128(*this, other);
   47|  1.83M|  }

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd9simd16x32ItEC2EPKt:
  164|   101k|      : chunks{simd16<T>::load(ptr),
  165|   101k|               simd16<T>::load(ptr + sizeof(simd16<T>) / sizeof(T)),
  166|   101k|               simd16<T>::load(ptr + 2 * sizeof(simd16<T>) / sizeof(T)),
  167|   101k|               simd16<T>::load(ptr + 3 * sizeof(simd16<T>) / sizeof(T))} {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd14base16_numericItE4loadEPKt:
   47|  4.84M|  static simdutf_really_inline simd16<T> load(const T values[8]) {
   48|  4.84M|    return _mm_loadu_si128(reinterpret_cast<const __m128i *>(values));
   49|  4.84M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd16ItEC2EDv2_x:
   79|  10.6M|      : base16_numeric<uint16_t>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd14base16_numericItEC2EDv2_x:
   54|  10.6M|      : base16<T>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6base16ItNS2_6simd16IbEEEC2EDv2_x:
    8|  10.6M|      : base<simd16<T>>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd9simd16x32ItE10swap_bytesEv:
  200|   100k|  simdutf_really_inline void swap_bytes() {
  201|   100k|    this->chunks[0] = this->chunks[0].swap_bytes();
  202|   100k|    this->chunks[1] = this->chunks[1].swap_bytes();
  203|   100k|    this->chunks[2] = this->chunks[2].swap_bytes();
  204|   100k|    this->chunks[3] = this->chunks[3].swap_bytes();
  205|   100k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd6simd16ItE10swap_bytesEv:
  121|   401k|  simdutf_really_inline simd16<uint16_t> swap_bytes() const {
  122|   401k|    const __m128i swap =
  123|   401k|        _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  124|   401k|    return _mm_shuffle_epi8(*this, swap);
  125|   401k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd9simd16x32ItE5storeEPt:
  169|  97.9k|  simdutf_really_inline void store(T *ptr) const {
  170|  97.9k|    this->chunks[0].store(ptr + sizeof(simd16<T>) * 0 / sizeof(T));
  171|  97.9k|    this->chunks[1].store(ptr + sizeof(simd16<T>) * 1 / sizeof(T));
  172|  97.9k|    this->chunks[2].store(ptr + sizeof(simd16<T>) * 2 / sizeof(T));
  173|  97.9k|    this->chunks[3].store(ptr + sizeof(simd16<T>) * 3 / sizeof(T));
  174|  97.9k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd14base16_numericItE5storeEPt:
   57|   391k|  simdutf_really_inline void store(T dst[8]) const {
   58|   391k|    return _mm_storeu_si128(reinterpret_cast<__m128i *>(dst), *this);
   59|   391k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd14base16_numericItE5splatEt:
   41|   919k|  static simdutf_really_inline simd16<T> splat(T _value) {
   42|   919k|    return _mm_set1_epi16(_value);
   43|   919k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simdeqENS2_6simd16ItEES4_:
   11|  14.7k|                                               const simd16<T> rhs) {
   12|  14.7k|    return _mm_cmpeq_epi16(lhs, rhs);
   13|  14.7k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd16IbEC2EDv2_x:
   28|  14.7k|  simdutf_really_inline simd16(const __m128i _value) : base16<bool>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6base16IbNS2_6simd16IbEEEC2EDv2_x:
    8|  14.7k|      : base<simd16<T>>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd9simd16x32IbEC2ENS2_6simd16IbEES6_S6_S6_:
  162|  3.67k|      : chunks{chunk0, chunk1, chunk2, chunk3} {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd9simd16x32IbE10to_bitmaskEv:
  192|  3.67k|  simdutf_really_inline uint64_t to_bitmask() const {
  193|  3.67k|    uint64_t r0 = uint32_t(this->chunks[0].to_bitmask());
  194|  3.67k|    uint64_t r1 = this->chunks[1].to_bitmask();
  195|  3.67k|    uint64_t r2 = this->chunks[2].to_bitmask();
  196|  3.67k|    uint64_t r3 = this->chunks[3].to_bitmask();
  197|  3.67k|    return r0 | (r1 << 16) | (r2 << 32) | (r3 << 48);
  198|  3.67k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd6simd16IbE10to_bitmaskEv:
   33|  14.7k|  simdutf_really_inline int to_bitmask() const {
   34|  14.7k|    return _mm_movemask_epi8(*this);
   35|  14.7k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd9simd16x32ItE4lteqEt:
  207|  3.67k|  simdutf_really_inline uint64_t lteq(const T m) const {
  208|  3.67k|    const simd16<T> mask = simd16<T>::splat(m);
  209|  3.67k|    return simd16x32<bool>(this->chunks[0] <= mask, this->chunks[1] <= mask,
  210|  3.67k|                           this->chunks[2] <= mask, this->chunks[3] <= mask)
  211|  3.67k|        .to_bitmask();
  212|  3.67k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd6simd16ItEleES4_:
  100|  14.7k|  operator<=(const simd16<uint16_t> other) const {
  101|  14.7k|    return other.max_val(*this) == other;
  102|  14.7k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd6simd16ItE7max_valES4_:
   90|  14.7k|  max_val(const simd16<uint16_t> other) const {
   91|  14.7k|    return _mm_max_epu16(*this, other);
   92|  14.7k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd16ItEC2EPKDs:
   86|  4.44M|      : simd16(load(reinterpret_cast<const uint16_t *>(values))) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd6simd16ItE3shrILi8EEES4_v:
  116|  2.60M|  template <int N> simdutf_really_inline simd16<uint16_t> shr() const {
  117|  2.60M|    return simd16<uint16_t>(_mm_srli_epi16(*this, N));
  118|  2.60M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd16ItE4packERKS4_S6_:
  130|  2.22M|                                                   const simd16<uint16_t> &v1) {
  131|  2.22M|    return _mm_packus_epi16(v0, v1);
  132|  2.22M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd16ItEC2Et:
   82|   916k|  simdutf_really_inline simd16(uint16_t _value) : simd16(splat(_value)) {}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd32IjE5splatEj:
   56|  1.37k|  simdutf_really_inline static simd32<uint32_t> splat(uint32_t v) {
   57|  1.37k|    return _mm_set1_epi32(v);
   58|  1.37k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd32IjEC2EDv2_x:
    9|  5.06M|  simdutf_really_inline simd32(const __m128i v) : value(v) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd32IjE4zeroEv:
   52|    918|  simdutf_really_inline static simd32<uint32_t> zero() {
   53|    918|    return _mm_setzero_si128();
   54|    918|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd32IjEC2IDiEEPKT_:
   13|  1.26M|      : value(_mm_loadu_si128(reinterpret_cast<const __m128i *>(ptr))) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd6simd32IjE10swap_bytesEv:
   22|  1.26M|  simdutf_really_inline simd32<uint32_t> swap_bytes() const {
   23|  1.26M|    const __m128i shuffle =
   24|  1.26M|        _mm_setr_epi8(3, 2, 1, 0, 7, 6, 5, 4, 8, 9, 10, 11, 15, 14, 13, 12);
   25|       |
   26|  1.26M|    return _mm_shuffle_epi8(value, shuffle);
   27|  1.26M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd3maxENS2_6simd32IjEES4_:
   94|  2.53M|                                           const simd32<uint32_t> b) {
   95|  2.53M|  return _mm_max_epu32(a.value, b.value);
   96|  2.53M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simdplENS2_6simd32IjEES4_:
  119|  1.26M|                                                 const simd32<uint32_t> b) {
  120|  1.26M|  return _mm_add_epi32(a.value, b.value);
  121|  1.26M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simdgtENS2_6simd32IjEES4_:
  143|    592|                                             const simd32<uint32_t> b) {
  144|    592|  return !(b >= a);
  145|    592|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simdntENS2_6simd32IbEE:
  138|    592|simdutf_really_inline simd32<bool> operator!(const simd32<bool> v) {
  139|    592|  return _mm_xor_si128(v.value, _mm_set1_epi8(-1));
  140|    592|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd32IbEC2EDv2_x:
   69|  1.18k|  simdutf_really_inline simd32(const __m128i v) : value(v) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simdgeENS2_6simd32IjEES4_:
  134|    592|                                              const simd32<uint32_t> b) {
  135|    592|  return _mm_cmpeq_epi32(_mm_max_epu32(a.value, b.value), a.value);
  136|    592|}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd6simd32IbE3anyEv:
   71|    592|  simdutf_really_inline bool any() const {
   72|    592|    return _mm_movemask_epi8(value) != 0;
   73|    592|  }

_ZNK7simdutf8westmere14implementation16detect_encodingsEPKcm:
  163|  1.30k|                                 size_t length) const noexcept {
  164|       |  // If there is a BOM, then we trust it.
  165|  1.30k|  auto bom_encoding = simdutf::BOM::check_bom(input, length);
  166|  1.30k|  if (bom_encoding != encoding_type::unspecified) {
  ------------------
  |  Branch (166:7): [True: 40, False: 1.26k]
  ------------------
  167|     40|    return bom_encoding;
  168|     40|  }
  169|  1.26k|  return encoding_detection::detect_encodings(input, length);
  170|  1.30k|}
_ZNK7simdutf8westmere14implementation13validate_utf8EPKcm:
  180|    901|implementation::validate_utf8(const char *buf, size_t len) const noexcept {
  181|    901|  return aligned_split::all<validate_utf8_unsplit>(
  182|    901|      buf, len, aligned_split::utf8_head(buf, len));
  183|    901|}
_ZNK7simdutf8westmere14implementation14validate_asciiEPKcm:
  206|    192|implementation::validate_ascii(const char *buf, size_t len) const noexcept {
  207|    192|  return aligned_split::all<validate_ascii_unsplit>(
  208|    192|      buf, len, aligned_split::head(buf, len));
  209|    192|}
_ZNK7simdutf8westmere14implementation26validate_ascii_with_errorsEPKcm:
  218|    286|    const char *buf, size_t len) const noexcept {
  219|    286|  return aligned_split::first_error<validate_ascii_with_errors_unsplit>(
  220|    286|      buf, len, aligned_split::head(buf, len));
  221|    286|}
_ZNK7simdutf8westmere14implementation25validate_utf16le_as_asciiEPKDsm:
  227|    244|                                          size_t len) const noexcept {
  228|    244|  return westmere::utf16::validate_utf16_as_ascii_with_errors<
  229|    244|             endianness::LITTLE>(buf, len)
  230|    244|             .error == SUCCESS;
  231|    244|}
_ZNK7simdutf8westmere14implementation25validate_utf16be_as_asciiEPKDsm:
  235|    244|                                          size_t len) const noexcept {
  236|    244|  return westmere::utf16::validate_utf16_as_ascii_with_errors<endianness::BIG>(
  237|    244|             buf, len)
  238|    244|             .error == SUCCESS;
  239|    244|}
_ZNK7simdutf8westmere14implementation16validate_utf16leEPKDsm:
  265|  1.44k|                                 size_t len) const noexcept {
  266|  1.44k|  return aligned_split::all<validate_utf16le_unsplit>(
  267|  1.44k|      buf, len, aligned_split::utf16_head<endianness::LITTLE>(buf, len));
  268|  1.44k|}
_ZNK7simdutf8westmere14implementation16validate_utf16beEPKDsm:
  294|    780|                                 size_t len) const noexcept {
  295|    780|  return aligned_split::all<validate_utf16be_unsplit>(
  296|    780|      buf, len, aligned_split::utf16_head<endianness::BIG>(buf, len));
  297|    780|}
_ZNK7simdutf8westmere14implementation22to_well_formed_utf16leEPKDsmPDs:
  339|    760|                                            char16_t *output) const noexcept {
  340|    760|  return utf16fix_sse<endianness::LITTLE>(input, len, output);
  341|    760|}
_ZNK7simdutf8westmere14implementation22to_well_formed_utf16beEPKDsmPDs:
  344|    760|                                            char16_t *output) const noexcept {
  345|    760|  return utf16fix_sse<endianness::BIG>(input, len, output);
  346|    760|}
_ZNK7simdutf8westmere14implementation14validate_utf32EPKDim:
  351|    459|implementation::validate_utf32(const char32_t *buf, size_t len) const noexcept {
  352|    459|  return utf32::validate(buf, len);
  353|    459|}
_ZNK7simdutf8westmere14implementation23change_endianness_utf16EPKDsmPDs:
 1028|    129|                                             char16_t *output) const noexcept {
 1029|    129|  utf16::change_endianness_utf16(input, length, output);
 1030|    129|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_18is_asciiERKNS1_4simd8simd8x64IhEE:
   12|   428k|simdutf_really_inline bool is_ascii(const simd8x64<uint8_t> &input) {
   13|   428k|  return input.reduce_or().is_ascii();
   14|   428k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_124must_be_2_3_continuationENS1_4simd5simd8IhEES4_:
   20|   345k|                         const simd8<uint8_t> prev3) {
   21|   345k|  simd8<uint8_t> is_third_byte =
   22|   345k|      prev2.saturating_sub(0xe0u - 0x80); // Only 111_____ will be >= 0x80
   23|   345k|  simd8<uint8_t> is_fourth_byte =
   24|   345k|      prev3.saturating_sub(0xf0u - 0x80); // Only 1111____ will be >= 0x80
   25|   345k|  return simd8<bool>(is_third_byte | is_fourth_byte);
   26|   345k|}
_ZN7simdutf8westmere21validate_utf8_unsplitEPKcm:
  175|    943|                                                 size_t len) noexcept {
  176|    943|  return westmere::utf8_validation::generic_validate_utf8(buf, len);
  177|    943|}
_ZN7simdutf8westmere22validate_ascii_unsplitEPKcm:
  201|    207|                                                  size_t len) noexcept {
  202|    207|  return westmere::ascii_validation::generic_validate_ascii(buf, len);
  203|    207|}
_ZN7simdutf8westmere34validate_ascii_with_errors_unsplitEPKcm:
  212|    310|validate_ascii_with_errors_unsplit(const char *buf, size_t len) noexcept {
  213|    310|  return westmere::ascii_validation::generic_validate_ascii_with_errors(buf,
  214|    310|                                                                        len);
  215|    310|}
_ZN7simdutf8westmere24validate_utf16le_unsplitEPKDsm:
  244|  1.67k|                                                    size_t len) noexcept {
  245|  1.67k|  if (simdutf_unlikely(len == 0)) {
  ------------------
  |  |   93|  1.67k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 2, False: 1.67k]
  |  |  ------------------
  ------------------
  246|       |    // empty input is valid UTF-16. protect the implementation from
  247|       |    // handling nullptr
  248|      2|    return true;
  249|      2|  }
  250|  1.67k|  const auto res =
  251|  1.67k|      westmere::utf16::validate_utf16_with_errors<endianness::LITTLE>(buf, len);
  252|  1.67k|  if (res.is_err()) {
  ------------------
  |  Branch (252:7): [True: 331, False: 1.34k]
  ------------------
  253|    331|    return false;
  254|    331|  }
  255|       |
  256|  1.34k|  if (res.count == len)
  ------------------
  |  Branch (256:7): [True: 377, False: 963]
  ------------------
  257|    377|    return true;
  258|       |
  259|    963|  return scalar::utf16::validate<endianness::LITTLE>(buf + res.count,
  260|    963|                                                     len - res.count);
  261|  1.34k|}
_ZN7simdutf8westmere24validate_utf16be_unsplitEPKDsm:
  273|    929|                                                    size_t len) noexcept {
  274|    929|  if (simdutf_unlikely(len == 0)) {
  ------------------
  |  |   93|    929|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 2, False: 927]
  |  |  ------------------
  ------------------
  275|       |    // empty input is valid UTF-16. protect the implementation from
  276|       |    // handling nullptr
  277|      2|    return true;
  278|      2|  }
  279|    927|  const auto res =
  280|    927|      westmere::utf16::validate_utf16_with_errors<endianness::BIG>(buf, len);
  281|    927|  if (res.is_err()) {
  ------------------
  |  Branch (281:7): [True: 0, False: 927]
  ------------------
  282|      0|    return false;
  283|      0|  }
  284|       |
  285|    927|  if (res.count == len)
  ------------------
  |  Branch (285:7): [True: 324, False: 603]
  ------------------
  286|    324|    return true;
  287|       |
  288|    603|  return scalar::utf16::validate<endianness::BIG>(buf + res.count,
  289|    603|                                                  len - res.count);
  290|    927|}

simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_118encoding_detection15utf16le_checker6errorsEv:
   37|  22.6k|  simdutf_really_inline bool errors() const { return error != 0; }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_118encoding_detection15utf16le_checker11check_asciiEv:
   32|   198k|  simdutf_really_inline void check_ascii() {
   33|   198k|    error |= prev_high;
   34|   198k|    prev_high = 0;
   35|   198k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_118encoding_detection15utf16le_checker5checkILb0EEEvRKNS1_4simd8simd8x64IhEE:
   11|   157k|  simdutf_really_inline void check(const simd::simd8x64<uint8_t> &in) {
   12|   157k|    const __m128i v_fc = _mm_set1_epi8(char(0xfc));
   13|   157k|    const __m128i v_d8 = _mm_set1_epi8(char(0xd8));
   14|   157k|    const __m128i v_dc = _mm_set1_epi8(char(0xdc));
   15|   157k|    const uint64_t odd = 0xaaaaaaaaaaaaaaaa;
   16|   157k|    uint64_t high = 0;
   17|   157k|    uint64_t low = 0;
   18|   785k|    for (size_t i = 0; i < 4; i++) {
  ------------------
  |  Branch (18:24): [True: 628k, False: 157k]
  ------------------
   19|   628k|      const __m128i m = _mm_and_si128(in.chunks[i], v_fc);
   20|   628k|      high |= uint64_t(uint16_t(_mm_movemask_epi8(_mm_cmpeq_epi8(m, v_d8))))
   21|   628k|              << (16 * i);
   22|   628k|      low |= uint64_t(uint16_t(_mm_movemask_epi8(_mm_cmpeq_epi8(m, v_dc))))
   23|   628k|             << (16 * i);
   24|   628k|    }
   25|   157k|    high &= odd;
   26|   157k|    low &= odd;
   27|   157k|    const uint64_t carry = overlapping ? (low & 2) : prev_high;
  ------------------
  |  Branch (27:28): [Folded, False: 157k]
  ------------------
   28|   157k|    error |= ((high << 2) | carry) ^ low;
   29|   157k|    prev_high = high >> 62;
   30|   157k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_118encoding_detection15utf16le_checker5checkILb1EEEvRKNS1_4simd8simd8x64IhEE:
   11|    324|  simdutf_really_inline void check(const simd::simd8x64<uint8_t> &in) {
   12|    324|    const __m128i v_fc = _mm_set1_epi8(char(0xfc));
   13|    324|    const __m128i v_d8 = _mm_set1_epi8(char(0xd8));
   14|    324|    const __m128i v_dc = _mm_set1_epi8(char(0xdc));
   15|    324|    const uint64_t odd = 0xaaaaaaaaaaaaaaaa;
   16|    324|    uint64_t high = 0;
   17|    324|    uint64_t low = 0;
   18|  1.62k|    for (size_t i = 0; i < 4; i++) {
  ------------------
  |  Branch (18:24): [True: 1.29k, False: 324]
  ------------------
   19|  1.29k|      const __m128i m = _mm_and_si128(in.chunks[i], v_fc);
   20|  1.29k|      high |= uint64_t(uint16_t(_mm_movemask_epi8(_mm_cmpeq_epi8(m, v_d8))))
   21|  1.29k|              << (16 * i);
   22|  1.29k|      low |= uint64_t(uint16_t(_mm_movemask_epi8(_mm_cmpeq_epi8(m, v_dc))))
   23|  1.29k|             << (16 * i);
   24|  1.29k|    }
   25|    324|    high &= odd;
   26|    324|    low &= odd;
   27|    324|    const uint64_t carry = overlapping ? (low & 2) : prev_high;
  ------------------
  |  Branch (27:28): [True: 324, Folded]
  ------------------
   28|    324|    error |= ((high << 2) | carry) ^ low;
   29|    324|    prev_high = high >> 62;
   30|    324|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_118encoding_detection15utf32le_checker5checkERKNS1_4simd8simd8x64IhEE:
   48|   129k|  simdutf_really_inline void check(const simd::simd8x64<uint8_t> &in) {
   49|   129k|    const __m128i offset = _mm_set1_epi32(int32_t(0xffff2000));
   50|   129k|    const __m128i w0 = in.chunks[0];
   51|   129k|    const __m128i w1 = in.chunks[1];
   52|   129k|    const __m128i w2 = in.chunks[2];
   53|   129k|    const __m128i w3 = in.chunks[3];
   54|   129k|    currentmax =
   55|   129k|        _mm_max_epu32(currentmax, _mm_max_epu32(_mm_max_epu32(w0, w1),
   56|   129k|                                                _mm_max_epu32(w2, w3)));
   57|   129k|    currentoffsetmax =
   58|   129k|        _mm_max_epu32(currentoffsetmax,
   59|   129k|                      _mm_max_epu32(_mm_max_epu32(_mm_add_epi32(w0, offset),
   60|   129k|                                                  _mm_add_epi32(w1, offset)),
   61|   129k|                                    _mm_max_epu32(_mm_add_epi32(w2, offset),
   62|   129k|                                                  _mm_add_epi32(w3, offset))));
   63|   129k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_118encoding_detection15utf16le_checker13errors_at_eofEv:
   39|    675|  simdutf_really_inline bool errors_at_eof() const {
   40|    675|    return (error | prev_high) != 0;
   41|    675|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_118encoding_detection15utf32le_checker6errorsEv:
   65|  8.64k|  simdutf_really_inline bool errors() const {
   66|  8.64k|    const __m128i standardmax = _mm_set1_epi32(0x10ffff);
   67|  8.64k|    const __m128i standardoffsetmax = _mm_set1_epi32(int32_t(0xfffff7ff));
   68|  8.64k|    const __m128i too_large =
   69|  8.64k|        _mm_xor_si128(_mm_max_epu32(currentmax, standardmax), standardmax);
   70|  8.64k|    const __m128i surrogate = _mm_xor_si128(
   71|  8.64k|        _mm_max_epu32(currentoffsetmax, standardoffsetmax), standardoffsetmax);
   72|  8.64k|    const __m128i any = _mm_or_si128(too_large, surrogate);
   73|  8.64k|    return !_mm_testz_si128(any, any);
   74|  8.64k|  }

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_112utf16fix_sseILNS_10endiannessE0EEEvPKDsmPDs:
   53|    760|void utf16fix_sse(const char16_t *in, size_t n, char16_t *out) {
   54|    760|  const char16_t replacement = scalar::utf16::replacement<big_endian>();
   55|    760|  size_t i;
   56|    760|  if (n < 9) {
  ------------------
  |  Branch (56:7): [True: 139, False: 621]
  ------------------
   57|    139|    scalar::utf16::to_well_formed_utf16<big_endian>(in, n, out);
   58|    139|    return;
   59|    139|  }
   60|       |
   61|    621|  out[0] =
   62|    621|      scalar::utf16::is_low_surrogate<big_endian>(in[0]) ? replacement : in[0];
  ------------------
  |  Branch (62:7): [True: 86, False: 535]
  ------------------
   63|       |
   64|       |  /* duplicate code to have the compiler specialise utf16fix_block() */
   65|    621|  if (in == out) {
  ------------------
  |  Branch (65:7): [True: 0, False: 621]
  ------------------
   66|      0|    for (i = 1; i + 8 < n; i += 8) {
  ------------------
  |  Branch (66:17): [True: 0, False: 0]
  ------------------
   67|      0|      utf16fix_block_sse<big_endian, true>(out + i, in + i);
   68|      0|    }
   69|       |
   70|      0|    utf16fix_block_sse<big_endian, true>(out + n - 8, in + n - 8);
   71|    621|  } else {
   72|  1.82M|    for (i = 1; i + 8 < n; i += 8) {
  ------------------
  |  Branch (72:17): [True: 1.82M, False: 621]
  ------------------
   73|  1.82M|      utf16fix_block_sse<big_endian, false>(out + i, in + i);
   74|  1.82M|    }
   75|       |
   76|    621|    utf16fix_block_sse<big_endian, false>(out + n - 8, in + n - 8);
   77|    621|  }
   78|       |
   79|    621|  out[n - 1] = scalar::utf16::is_high_surrogate<big_endian>(out[n - 1])
  ------------------
  |  Branch (79:16): [True: 82, False: 539]
  ------------------
   80|    621|                   ? replacement
   81|    621|                   : out[n - 1];
   82|    621|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_118utf16fix_block_sseILNS_10endiannessE0ELb0EEEvPDsPKDs:
   11|  1.82M|                                              const char16_t *in) {
   12|  1.82M|  auto swap_if_needed = [](uint16_t x) constexpr -> uint16_t {
   13|  1.82M|    return scalar::utf16::swap_if_needed<big_endian>(x);
   14|  1.82M|  };
   15|  1.82M|  const char16_t replacement = scalar::utf16::replacement<big_endian>();
   16|       |
   17|  1.82M|  __m128i lookback, block, lb_masked, block_masked, lb_is_high, block_is_low;
   18|  1.82M|  __m128i illseq, lb_illseq, block_illseq;
   19|       |
   20|  1.82M|  lookback = _mm_loadu_si128((const __m128i *)(in - 1));
   21|  1.82M|  block = _mm_loadu_si128((const __m128i *)in);
   22|  1.82M|  lb_masked = _mm_and_si128(lookback, _mm_set1_epi16(swap_if_needed(0xfc00U)));
   23|  1.82M|  block_masked = _mm_and_si128(block, _mm_set1_epi16(swap_if_needed(0xfc00U)));
   24|  1.82M|  lb_is_high =
   25|  1.82M|      _mm_cmpeq_epi16(lb_masked, _mm_set1_epi16(swap_if_needed(0xd800U)));
   26|  1.82M|  block_is_low =
   27|  1.82M|      _mm_cmpeq_epi16(block_masked, _mm_set1_epi16(swap_if_needed(0xdc00U)));
   28|       |
   29|  1.82M|  illseq = _mm_xor_si128(lb_is_high, block_is_low);
   30|  1.82M|  if (_mm_movemask_epi8(illseq) != 0) {
  ------------------
  |  Branch (30:7): [True: 129k, False: 1.69M]
  ------------------
   31|   129k|    int lb;
   32|       |
   33|       |    /* compute the cause of the illegal sequencing */
   34|   129k|    lb_illseq = _mm_andnot_si128(block_is_low, lb_is_high);
   35|   129k|    block_illseq = _mm_or_si128(_mm_andnot_si128(lb_is_high, block_is_low),
   36|   129k|                                _mm_bsrli_si128(lb_illseq, 2));
   37|       |
   38|       |    /* fix illegal sequencing in the lookback */
   39|   129k|    lb = _mm_cvtsi128_si32(lb_illseq);
   40|   129k|    lb = (lb & replacement) | (~lb & out[-1]);
   41|   129k|    out[-1] = char16_t(lb);
   42|       |    /* fix illegal sequencing in the main block */
   43|   129k|    block =
   44|   129k|        _mm_or_si128(_mm_andnot_si128(block_illseq, block),
   45|   129k|                     _mm_and_si128(block_illseq, _mm_set1_epi16(replacement)));
   46|   129k|    _mm_storeu_si128((__m128i *)out, block);
   47|  1.69M|  } else if (!in_place) {
  ------------------
  |  Branch (47:14): [True: 1.69M, Folded]
  ------------------
   48|  1.69M|    _mm_storeu_si128((__m128i *)out, block);
   49|  1.69M|  }
   50|  1.82M|}
simdutf.cpp:_ZZN7simdutf8westmere12_GLOBAL__N_118utf16fix_block_sseILNS_10endiannessE0ELb0EEEvPDsPKDsENKUltE_clEt:
   12|  7.31M|  auto swap_if_needed = [](uint16_t x) constexpr -> uint16_t {
   13|  7.31M|    return scalar::utf16::swap_if_needed<big_endian>(x);
   14|  7.31M|  };
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_112utf16fix_sseILNS_10endiannessE1EEEvPKDsmPDs:
   53|    760|void utf16fix_sse(const char16_t *in, size_t n, char16_t *out) {
   54|    760|  const char16_t replacement = scalar::utf16::replacement<big_endian>();
   55|    760|  size_t i;
   56|    760|  if (n < 9) {
  ------------------
  |  Branch (56:7): [True: 139, False: 621]
  ------------------
   57|    139|    scalar::utf16::to_well_formed_utf16<big_endian>(in, n, out);
   58|    139|    return;
   59|    139|  }
   60|       |
   61|    621|  out[0] =
   62|    621|      scalar::utf16::is_low_surrogate<big_endian>(in[0]) ? replacement : in[0];
  ------------------
  |  Branch (62:7): [True: 75, False: 546]
  ------------------
   63|       |
   64|       |  /* duplicate code to have the compiler specialise utf16fix_block() */
   65|    621|  if (in == out) {
  ------------------
  |  Branch (65:7): [True: 0, False: 621]
  ------------------
   66|      0|    for (i = 1; i + 8 < n; i += 8) {
  ------------------
  |  Branch (66:17): [True: 0, False: 0]
  ------------------
   67|      0|      utf16fix_block_sse<big_endian, true>(out + i, in + i);
   68|      0|    }
   69|       |
   70|      0|    utf16fix_block_sse<big_endian, true>(out + n - 8, in + n - 8);
   71|    621|  } else {
   72|  1.82M|    for (i = 1; i + 8 < n; i += 8) {
  ------------------
  |  Branch (72:17): [True: 1.82M, False: 621]
  ------------------
   73|  1.82M|      utf16fix_block_sse<big_endian, false>(out + i, in + i);
   74|  1.82M|    }
   75|       |
   76|    621|    utf16fix_block_sse<big_endian, false>(out + n - 8, in + n - 8);
   77|    621|  }
   78|       |
   79|    621|  out[n - 1] = scalar::utf16::is_high_surrogate<big_endian>(out[n - 1])
  ------------------
  |  Branch (79:16): [True: 81, False: 540]
  ------------------
   80|    621|                   ? replacement
   81|    621|                   : out[n - 1];
   82|    621|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_118utf16fix_block_sseILNS_10endiannessE1ELb0EEEvPDsPKDs:
   11|  1.82M|                                              const char16_t *in) {
   12|  1.82M|  auto swap_if_needed = [](uint16_t x) constexpr -> uint16_t {
   13|  1.82M|    return scalar::utf16::swap_if_needed<big_endian>(x);
   14|  1.82M|  };
   15|  1.82M|  const char16_t replacement = scalar::utf16::replacement<big_endian>();
   16|       |
   17|  1.82M|  __m128i lookback, block, lb_masked, block_masked, lb_is_high, block_is_low;
   18|  1.82M|  __m128i illseq, lb_illseq, block_illseq;
   19|       |
   20|  1.82M|  lookback = _mm_loadu_si128((const __m128i *)(in - 1));
   21|  1.82M|  block = _mm_loadu_si128((const __m128i *)in);
   22|  1.82M|  lb_masked = _mm_and_si128(lookback, _mm_set1_epi16(swap_if_needed(0xfc00U)));
   23|  1.82M|  block_masked = _mm_and_si128(block, _mm_set1_epi16(swap_if_needed(0xfc00U)));
   24|  1.82M|  lb_is_high =
   25|  1.82M|      _mm_cmpeq_epi16(lb_masked, _mm_set1_epi16(swap_if_needed(0xd800U)));
   26|  1.82M|  block_is_low =
   27|  1.82M|      _mm_cmpeq_epi16(block_masked, _mm_set1_epi16(swap_if_needed(0xdc00U)));
   28|       |
   29|  1.82M|  illseq = _mm_xor_si128(lb_is_high, block_is_low);
   30|  1.82M|  if (_mm_movemask_epi8(illseq) != 0) {
  ------------------
  |  Branch (30:7): [True: 129k, False: 1.69M]
  ------------------
   31|   129k|    int lb;
   32|       |
   33|       |    /* compute the cause of the illegal sequencing */
   34|   129k|    lb_illseq = _mm_andnot_si128(block_is_low, lb_is_high);
   35|   129k|    block_illseq = _mm_or_si128(_mm_andnot_si128(lb_is_high, block_is_low),
   36|   129k|                                _mm_bsrli_si128(lb_illseq, 2));
   37|       |
   38|       |    /* fix illegal sequencing in the lookback */
   39|   129k|    lb = _mm_cvtsi128_si32(lb_illseq);
   40|   129k|    lb = (lb & replacement) | (~lb & out[-1]);
   41|   129k|    out[-1] = char16_t(lb);
   42|       |    /* fix illegal sequencing in the main block */
   43|   129k|    block =
   44|   129k|        _mm_or_si128(_mm_andnot_si128(block_illseq, block),
   45|   129k|                     _mm_and_si128(block_illseq, _mm_set1_epi16(replacement)));
   46|   129k|    _mm_storeu_si128((__m128i *)out, block);
   47|  1.69M|  } else if (!in_place) {
  ------------------
  |  Branch (47:14): [True: 1.69M, Folded]
  ------------------
   48|  1.69M|    _mm_storeu_si128((__m128i *)out, block);
   49|  1.69M|  }
   50|  1.82M|}
simdutf.cpp:_ZZN7simdutf8westmere12_GLOBAL__N_118utf16fix_block_sseILNS_10endiannessE1ELb0EEEvPDsPKDsENKUltE_clEt:
   12|  7.31M|  auto swap_if_needed = [](uint16_t x) constexpr -> uint16_t {
   13|  7.31M|    return scalar::utf16::swap_if_needed<big_endian>(x);
   14|  7.31M|  };

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_123utf16_gather_high_bytesILNS_10endiannessE0EEENS1_4simd5simd8IhEENS4_6simd16ItEES8_:
    3|  1.30M|                                       const simd16<uint16_t> in1) {
    4|  1.30M|  if (big_endian) {
  ------------------
  |  Branch (4:7): [Folded, False: 1.30M]
  ------------------
    5|       |    // we want lower bytes
    6|      0|    const auto mask = simd16<uint16_t>(0x00ff);
    7|      0|    const auto t0 = in0 & mask;
    8|      0|    const auto t1 = in1 & mask;
    9|       |
   10|      0|    return simd16<uint16_t>::pack(t0, t1);
   11|  1.30M|  } else {
   12|  1.30M|    const auto t0 = in0.shr<8>();
   13|  1.30M|    const auto t1 = in1.shr<8>();
   14|       |
   15|  1.30M|    return simd16<uint16_t>::pack(t0, t1);
   16|  1.30M|  }
   17|  1.30M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_123utf16_gather_high_bytesILNS_10endiannessE1EEENS1_4simd5simd8IhEENS4_6simd16ItEES8_:
    3|   916k|                                       const simd16<uint16_t> in1) {
    4|   916k|  if (big_endian) {
  ------------------
  |  Branch (4:7): [True: 916k, Folded]
  ------------------
    5|       |    // we want lower bytes
    6|   916k|    const auto mask = simd16<uint16_t>(0x00ff);
    7|   916k|    const auto t0 = in0 & mask;
    8|   916k|    const auto t1 = in1 & mask;
    9|       |
   10|   916k|    return simd16<uint16_t>::pack(t0, t1);
   11|   916k|  } else {
   12|      0|    const auto t0 = in0.shr<8>();
   13|      0|    const auto t1 = in1.shr<8>();
   14|       |
   15|      0|    return simd16<uint16_t>::pack(t0, t1);
   16|      0|  }
   17|   916k|}

