LLVMFuzzerTestOneInput:
  164|  3.79k|extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
  165|  3.79k|  constexpr auto optionbytes = 4u;
  166|  3.79k|  static_assert(optionbytes % 2 == 0,
  167|  3.79k|                "optionbytes must be even to avoid misaligned char16 pointers");
  168|  3.79k|  if (size < optionbytes) {
  ------------------
  |  Branch (168:7): [True: 2, False: 3.79k]
  ------------------
  169|      2|    return 0;
  170|      2|  }
  171|       |
  172|  3.79k|  constexpr auto Ncases = 2u;
  173|  3.79k|  constexpr auto actionmask = std::bit_ceil(Ncases) - 1;
  174|  3.79k|  const auto action = data[0] & actionmask;
  175|       |
  176|  3.79k|  const auto opt = [](auto index) {
  177|  3.79k|    if (index >= options.size()) {
  178|  3.79k|      return options[0];
  179|  3.79k|    }
  180|  3.79k|    return options[index];
  181|  3.79k|  }(data[1] & (std::bit_ceil(options.size()) - 1));
  182|       |
  183|  3.79k|  const auto lco =
  184|  3.79k|      (opt == simdutf::base64_url || opt == simdutf::base64_default_no_padding)
  ------------------
  |  Branch (184:8): [True: 667, False: 3.12k]
  |  Branch (184:38): [True: 381, False: 2.74k]
  ------------------
  185|  3.79k|          ? simdutf::last_chunk_handling_options::loose
  186|  3.79k|          : [](auto index) {
  187|  2.74k|              if (index >= last_chunk.size()) {
  188|  2.74k|                return last_chunk[0];
  189|  2.74k|              }
  190|  2.74k|              return last_chunk[index];
  191|  2.74k|            }(data[2] & (std::bit_ceil(last_chunk.size()) - 1));
  192|       |
  193|       |  // data[3] reserved for future use / alignment.
  194|       |
  195|  3.79k|  data += optionbytes;
  196|  3.79k|  size -= optionbytes;
  197|       |
  198|  3.79k|  switch (action) {
  ------------------
  |  Branch (198:11): [True: 3.79k, False: 0]
  ------------------
  199|  1.89k|  case 0: {
  ------------------
  |  Branch (199:3): [True: 1.89k, False: 1.90k]
  ------------------
  200|  1.89k|    const std::span<const char> chardata{reinterpret_cast<const char*>(data),
  201|  1.89k|                                         size};
  202|  1.89k|    test_details(chardata, opt, lco);
  203|  1.89k|  } break;
  204|  1.90k|  case 1: {
  ------------------
  |  Branch (204:3): [True: 1.90k, False: 1.89k]
  ------------------
  205|  1.90k|    const std::span<const char16_t> chardata{
  206|  1.90k|        reinterpret_cast<const char16_t*>(data), size / sizeof(char16_t)};
  207|  1.90k|    test_details(chardata, opt, lco);
  208|  1.90k|  } break;
  209|  3.79k|  }
  210|       |
  211|  3.79k|  return 0;
  212|  3.79k|}
base64_details.cpp:_ZZ22LLVMFuzzerTestOneInputENK3$_0clImEEDaT_:
  176|  3.79k|  const auto opt = [](auto index) {
  177|  3.79k|    if (index >= options.size()) {
  ------------------
  |  Branch (177:9): [True: 0, False: 3.79k]
  ------------------
  178|      0|      return options[0];
  179|      0|    }
  180|  3.79k|    return options[index];
  181|  3.79k|  }(data[1] & (std::bit_ceil(options.size()) - 1));
base64_details.cpp:_ZZ22LLVMFuzzerTestOneInputENK3$_1clImEEDaT_:
  186|  2.74k|          : [](auto index) {
  187|  2.74k|              if (index >= last_chunk.size()) {
  ------------------
  |  Branch (187:19): [True: 289, False: 2.45k]
  ------------------
  188|    289|                return last_chunk[0];
  189|    289|              }
  190|  2.45k|              return last_chunk[index];
  191|  2.74k|            }(data[2] & (std::bit_ceil(last_chunk.size()) - 1));
base64_details.cpp:_ZL12test_detailsIcEvNSt3__14spanIKT_Lm18446744073709551615EEEN7simdutf14base64_optionsENS5_27last_chunk_handling_optionsE:
   57|  1.89k|                         simdutf::last_chunk_handling_options lco) {
   58|  1.89k|  const auto implementations = get_supported_implementations();
   59|  1.89k|  if (implementations.empty()) {
  ------------------
  |  Branch (59:7): [True: 0, False: 1.89k]
  ------------------
   60|      0|    return;
   61|      0|  }
   62|       |
   63|  1.89k|  std::vector<comparable_full_result> results;
   64|  1.89k|  results.reserve(implementations.size());
   65|       |
   66|  5.67k|  for (auto impl : implementations) {
  ------------------
  |  Branch (66:18): [True: 5.67k, False: 1.89k]
  ------------------
   67|       |    // Use a fresh buffer for base64_to_binary_details.
   68|  5.67k|    const std::size_t maxbinary =
   69|  5.67k|        impl->maximal_binary_length_from_base64(input.data(), input.size());
   70|  5.67k|    std::vector<char> out_details(maxbinary);
   71|       |
   72|  5.67k|    const simdutf::full_result fr = impl->base64_to_binary_details(
   73|  5.67k|        input.data(), input.size(), out_details.data(), opt, lco);
   74|       |
   75|       |    // Bounds checks.
   76|  5.67k|    if (fr.input_count > input.size()) {
  ------------------
  |  Branch (76:9): [True: 0, False: 5.67k]
  ------------------
   77|      0|      std::cerr << "base64_to_binary_details: input_count=" << fr.input_count
   78|      0|                << " > input.size()=" << input.size()
   79|      0|                << " impl=" << impl->name() << "\n";
   80|      0|      std::abort();
   81|      0|    }
   82|  5.67k|    if (fr.output_count > maxbinary) {
  ------------------
  |  Branch (82:9): [True: 0, False: 5.67k]
  ------------------
   83|      0|      std::cerr << "base64_to_binary_details: output_count=" << fr.output_count
   84|      0|                << " > maxbinary=" << maxbinary << " impl=" << impl->name()
   85|      0|                << "\n";
   86|      0|      std::abort();
   87|      0|    }
   88|       |
   89|       |    // Consistency check: full_result cast to result must equal
   90|       |    // base64_to_binary.
   91|  5.67k|    std::vector<char> out_plain(maxbinary);
   92|  5.67k|    const simdutf::result r = impl->base64_to_binary(
   93|  5.67k|        input.data(), input.size(), out_plain.data(), opt, lco);
   94|  5.67k|    const simdutf::result r_from_fr = static_cast<simdutf::result>(fr);
   95|       |
   96|  5.67k|    if (r != r_from_fr) {
  ------------------
  |  Branch (96:9): [True: 0, False: 5.67k]
  ------------------
   97|      0|      std::cerr << "base64_to_binary_details vs base64_to_binary inconsistency"
   98|      0|                << " impl=" << impl->name()
   99|      0|                << " base64_to_binary=[error=" << r.error
  100|      0|                << " count=" << r.count << "]"
  101|      0|                << " full_result cast=[error=" << r_from_fr.error
  102|      0|                << " count=" << r_from_fr.count << "]\n";
  103|      0|      std::abort();
  104|      0|    }
  105|       |
  106|       |    // On success, output bytes from both functions must match.
  107|  5.67k|    if (fr.error == simdutf::error_code::SUCCESS) {
  ------------------
  |  Branch (107:9): [True: 2.24k, False: 3.43k]
  ------------------
  108|  2.24k|      if (fr.output_count != r.count) {
  ------------------
  |  Branch (108:11): [True: 0, False: 2.24k]
  ------------------
  109|      0|        std::cerr << "base64_to_binary_details: SUCCESS but output_count="
  110|      0|                  << fr.output_count << " != r.count=" << r.count
  111|      0|                  << " impl=" << impl->name() << "\n";
  112|      0|        std::abort();
  113|      0|      }
  114|  2.24k|      const auto span_details =
  115|  2.24k|          std::span(out_details).subspan(0, fr.output_count);
  116|  2.24k|      const auto span_plain = std::span(out_plain).subspan(0, r.count);
  117|  2.24k|      if (!std::ranges::equal(span_details, span_plain)) {
  ------------------
  |  Branch (117:11): [True: 0, False: 2.24k]
  ------------------
  118|      0|        std::cerr << "base64_to_binary_details: output bytes differ from "
  119|      0|                     "base64_to_binary on SUCCESS"
  120|      0|                  << " impl=" << impl->name() << "\n";
  121|      0|        std::abort();
  122|      0|      }
  123|  2.24k|    }
  124|       |
  125|       |    // Store result for cross-implementation comparison.
  126|       |    //
  127|       |    // output_count on error is implementation-defined: SIMD implementations
  128|       |    // process input in different chunk widths and may write different numbers
  129|       |    // of output bytes before detecting an invalid character. Only compare
  130|       |    // output_count (and output_hash) when the conversion succeeds.
  131|       |    //
  132|       |    // input_count on success is also implementation-defined: with
  133|       |    // stop_before_partial and trailing ignored whitespace, some implementations
  134|       |    // include the trailing whitespace in input_count and others do not. The
  135|       |    // full_result::operator result() cast only uses output_count on success
  136|       |    // (input_count is not part of the base contract there). Only compare
  137|       |    // input_count when the conversion fails, where it carries the error
  138|       |    // position (which must be deterministic).
  139|  5.67k|    comparable_full_result cfr;
  140|  5.67k|    cfr.error = fr.error;
  141|  5.67k|    cfr.padding_error = fr.padding_error;
  142|  5.67k|    if (fr.error == simdutf::error_code::SUCCESS) {
  ------------------
  |  Branch (142:9): [True: 2.24k, False: 3.43k]
  ------------------
  143|  2.24k|      cfr.output_count = fr.output_count;
  144|  2.24k|      cfr.output_hash = FNV1A_hash::as_str(
  145|  2.24k|          std::span(out_details).subspan(0, fr.output_count));
  146|  3.43k|    } else {
  147|  3.43k|      cfr.input_count = fr.input_count;
  148|  3.43k|    }
  149|  5.67k|    results.push_back(std::move(cfr));
  150|  5.67k|  }
  151|       |
  152|       |  // All implementations must agree on the full_result.
  153|  1.89k|  auto neq = [](const auto& a, const auto& b) { return a != b; };
  154|  1.89k|  if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (154:7): [True: 0, False: 1.89k]
  ------------------
  155|      0|    std::cerr << "base64_to_binary_details: implementations disagree\n";
  156|      0|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (156:29): [True: 0, False: 0]
  ------------------
  157|      0|      std::cerr << "  " << implementations[i]->name() << ": " << results[i]
  158|      0|                << "\n";
  159|      0|    }
  160|      0|    std::abort();
  161|      0|  }
  162|  1.89k|}
base64_details.cpp:_ZZL12test_detailsIcEvNSt3__14spanIKT_Lm18446744073709551615EEEN7simdutf14base64_optionsENS5_27last_chunk_handling_optionsEENKUlRS3_RKT0_E_clI22comparable_full_resultSE_EEDaS8_SB_:
  153|  3.78k|  auto neq = [](const auto& a, const auto& b) { return a != b; };
base64_details.cpp:_ZL12test_detailsIDsEvNSt3__14spanIKT_Lm18446744073709551615EEEN7simdutf14base64_optionsENS5_27last_chunk_handling_optionsE:
   57|  1.90k|                         simdutf::last_chunk_handling_options lco) {
   58|  1.90k|  const auto implementations = get_supported_implementations();
   59|  1.90k|  if (implementations.empty()) {
  ------------------
  |  Branch (59:7): [True: 0, False: 1.90k]
  ------------------
   60|      0|    return;
   61|      0|  }
   62|       |
   63|  1.90k|  std::vector<comparable_full_result> results;
   64|  1.90k|  results.reserve(implementations.size());
   65|       |
   66|  5.70k|  for (auto impl : implementations) {
  ------------------
  |  Branch (66:18): [True: 5.70k, False: 1.90k]
  ------------------
   67|       |    // Use a fresh buffer for base64_to_binary_details.
   68|  5.70k|    const std::size_t maxbinary =
   69|  5.70k|        impl->maximal_binary_length_from_base64(input.data(), input.size());
   70|  5.70k|    std::vector<char> out_details(maxbinary);
   71|       |
   72|  5.70k|    const simdutf::full_result fr = impl->base64_to_binary_details(
   73|  5.70k|        input.data(), input.size(), out_details.data(), opt, lco);
   74|       |
   75|       |    // Bounds checks.
   76|  5.70k|    if (fr.input_count > input.size()) {
  ------------------
  |  Branch (76:9): [True: 0, False: 5.70k]
  ------------------
   77|      0|      std::cerr << "base64_to_binary_details: input_count=" << fr.input_count
   78|      0|                << " > input.size()=" << input.size()
   79|      0|                << " impl=" << impl->name() << "\n";
   80|      0|      std::abort();
   81|      0|    }
   82|  5.70k|    if (fr.output_count > maxbinary) {
  ------------------
  |  Branch (82:9): [True: 0, False: 5.70k]
  ------------------
   83|      0|      std::cerr << "base64_to_binary_details: output_count=" << fr.output_count
   84|      0|                << " > maxbinary=" << maxbinary << " impl=" << impl->name()
   85|      0|                << "\n";
   86|      0|      std::abort();
   87|      0|    }
   88|       |
   89|       |    // Consistency check: full_result cast to result must equal
   90|       |    // base64_to_binary.
   91|  5.70k|    std::vector<char> out_plain(maxbinary);
   92|  5.70k|    const simdutf::result r = impl->base64_to_binary(
   93|  5.70k|        input.data(), input.size(), out_plain.data(), opt, lco);
   94|  5.70k|    const simdutf::result r_from_fr = static_cast<simdutf::result>(fr);
   95|       |
   96|  5.70k|    if (r != r_from_fr) {
  ------------------
  |  Branch (96:9): [True: 0, False: 5.70k]
  ------------------
   97|      0|      std::cerr << "base64_to_binary_details vs base64_to_binary inconsistency"
   98|      0|                << " impl=" << impl->name()
   99|      0|                << " base64_to_binary=[error=" << r.error
  100|      0|                << " count=" << r.count << "]"
  101|      0|                << " full_result cast=[error=" << r_from_fr.error
  102|      0|                << " count=" << r_from_fr.count << "]\n";
  103|      0|      std::abort();
  104|      0|    }
  105|       |
  106|       |    // On success, output bytes from both functions must match.
  107|  5.70k|    if (fr.error == simdutf::error_code::SUCCESS) {
  ------------------
  |  Branch (107:9): [True: 1.67k, False: 4.02k]
  ------------------
  108|  1.67k|      if (fr.output_count != r.count) {
  ------------------
  |  Branch (108:11): [True: 0, False: 1.67k]
  ------------------
  109|      0|        std::cerr << "base64_to_binary_details: SUCCESS but output_count="
  110|      0|                  << fr.output_count << " != r.count=" << r.count
  111|      0|                  << " impl=" << impl->name() << "\n";
  112|      0|        std::abort();
  113|      0|      }
  114|  1.67k|      const auto span_details =
  115|  1.67k|          std::span(out_details).subspan(0, fr.output_count);
  116|  1.67k|      const auto span_plain = std::span(out_plain).subspan(0, r.count);
  117|  1.67k|      if (!std::ranges::equal(span_details, span_plain)) {
  ------------------
  |  Branch (117:11): [True: 0, False: 1.67k]
  ------------------
  118|      0|        std::cerr << "base64_to_binary_details: output bytes differ from "
  119|      0|                     "base64_to_binary on SUCCESS"
  120|      0|                  << " impl=" << impl->name() << "\n";
  121|      0|        std::abort();
  122|      0|      }
  123|  1.67k|    }
  124|       |
  125|       |    // Store result for cross-implementation comparison.
  126|       |    //
  127|       |    // output_count on error is implementation-defined: SIMD implementations
  128|       |    // process input in different chunk widths and may write different numbers
  129|       |    // of output bytes before detecting an invalid character. Only compare
  130|       |    // output_count (and output_hash) when the conversion succeeds.
  131|       |    //
  132|       |    // input_count on success is also implementation-defined: with
  133|       |    // stop_before_partial and trailing ignored whitespace, some implementations
  134|       |    // include the trailing whitespace in input_count and others do not. The
  135|       |    // full_result::operator result() cast only uses output_count on success
  136|       |    // (input_count is not part of the base contract there). Only compare
  137|       |    // input_count when the conversion fails, where it carries the error
  138|       |    // position (which must be deterministic).
  139|  5.70k|    comparable_full_result cfr;
  140|  5.70k|    cfr.error = fr.error;
  141|  5.70k|    cfr.padding_error = fr.padding_error;
  142|  5.70k|    if (fr.error == simdutf::error_code::SUCCESS) {
  ------------------
  |  Branch (142:9): [True: 1.67k, False: 4.02k]
  ------------------
  143|  1.67k|      cfr.output_count = fr.output_count;
  144|  1.67k|      cfr.output_hash = FNV1A_hash::as_str(
  145|  1.67k|          std::span(out_details).subspan(0, fr.output_count));
  146|  4.02k|    } else {
  147|  4.02k|      cfr.input_count = fr.input_count;
  148|  4.02k|    }
  149|  5.70k|    results.push_back(std::move(cfr));
  150|  5.70k|  }
  151|       |
  152|       |  // All implementations must agree on the full_result.
  153|  1.90k|  auto neq = [](const auto& a, const auto& b) { return a != b; };
  154|  1.90k|  if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (154:7): [True: 0, False: 1.90k]
  ------------------
  155|      0|    std::cerr << "base64_to_binary_details: implementations disagree\n";
  156|      0|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (156:29): [True: 0, False: 0]
  ------------------
  157|      0|      std::cerr << "  " << implementations[i]->name() << ": " << results[i]
  158|      0|                << "\n";
  159|      0|    }
  160|      0|    std::abort();
  161|      0|  }
  162|  1.90k|}
base64_details.cpp:_ZZL12test_detailsIDsEvNSt3__14spanIKT_Lm18446744073709551615EEEN7simdutf14base64_optionsENS5_27last_chunk_handling_optionsEENKUlRS3_RKT0_E_clI22comparable_full_resultSE_EEDaS8_SB_:
  153|  3.80k|  auto neq = [](const auto& a, const auto& b) { return a != b; };

_Z29get_supported_implementationsv:
   26|  3.79k|get_supported_implementations() {
   27|  3.79k|  static const auto impl = []() -> auto {
   28|  3.79k|    std::vector<const simdutf::implementation*> ret;
   29|  3.79k|    for (auto e : simdutf::get_available_implementations()) {
   30|  3.79k|      std::cerr << "implementation " << e->name() << " is available? "
   31|  3.79k|                << e->supported_by_runtime_system() << '\n';
   32|  3.79k|      if (e->supported_by_runtime_system()) {
   33|  3.79k|        ret.push_back(e);
   34|  3.79k|      }
   35|  3.79k|    }
   36|  3.79k|    return ret;
   37|  3.79k|  }();
   38|  3.79k|  return {impl.data(), impl.size()};
   39|  3.79k|}
_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|  11.3k|inline bool operator!=(const simdutf::result& a, const simdutf::result& b) {
   43|  11.3k|  return a.count != b.count || a.error != b.error;
  ------------------
  |  Branch (43:10): [True: 0, False: 11.3k]
  |  Branch (43:32): [True: 0, False: 11.3k]
  ------------------
   44|  11.3k|}
_ZN10FNV1A_hash6as_strIJNSt3__14spanIcLm18446744073709551615EEEEEENS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEDpRKT_:
  100|  3.91k|  template <typename... Data> static std::string as_str(const Data&... data) {
  101|  3.91k|    static_assert(sizeof...(Data) > 0, "must hash with at least one argument");
  102|  3.91k|    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|  3.91k|    } else {
  108|  3.91k|      h = fnv1ahash_impl(data...);
  109|  3.91k|    }
  110|  3.91k|    constexpr std::size_t expected_chars = 16;
  111|  3.91k|    std::string ret(expected_chars, '0');
  112|  3.91k|    auto c = std::to_chars(ret.data(), ret.data() + ret.size(), h, 16);
  113|  3.91k|    assert(c.ec == std::errc{});
  ------------------
  |  Branch (113:5): [True: 3.91k, False: 0]
  ------------------
  114|  3.91k|    auto nwritten = c.ptr - ret.data();
  115|  3.91k|    assert(nwritten <= expected_chars);
  ------------------
  |  Branch (115:5): [True: 3.91k, False: 0]
  ------------------
  116|  3.91k|    std::rotate(ret.data(), c.ptr, ret.data() + expected_chars);
  117|  3.91k|    return ret;
  118|  3.91k|  }
_ZN10FNV1A_hash14fnv1ahash_implENSt3__14spanIKcLm18446744073709551615EEE:
   75|  3.91k|  static constexpr std::uint64_t fnv1ahash_impl(std::span<const char> bytes) {
   76|  3.91k|    auto hash = offset;
   77|       |
   78|  30.4M|    for (auto byte : bytes) {
  ------------------
  |  Branch (78:20): [True: 30.4M, False: 3.91k]
  ------------------
   79|  30.4M|      hash ^= static_cast<unsigned char>(byte);
   80|  30.4M|      hash *= prime;
   81|  30.4M|    }
   82|       |
   83|  3.91k|    return hash;
   84|  3.91k|  }

_ZN7simdutf11full_resultC2ENS_10error_codeEmm:
  111|  22.3k|      : error{err}, input_count{pos_in}, output_count{pos_out} {}
_ZN7simdutf11full_resultC2ENS_10error_codeEmmb:
  114|    426|      : error{err}, input_count{pos_in}, output_count{pos_out},
  115|    426|        padding_error{padding_err} {}

_ZN7simdutf10is_partialENS_27last_chunk_handling_optionsE:
 4588|  27.6k|is_partial(last_chunk_handling_options options) {
 4589|  27.6k|  return (options == stop_before_partial) || (options == only_full_chunks);
  ------------------
  |  Branch (4589:10): [True: 13.7k, False: 13.8k]
  |  Branch (4589:46): [True: 0, False: 13.8k]
  ------------------
 4590|  27.6k|}
_ZNK7simdutf14implementation4nameEv:
 5562|      4|  virtual std::string_view name() const noexcept { return _name; }
_ZNK7simdutf14implementation25required_instruction_setsEv:
 5613|      8|  virtual uint32_t required_instruction_sets() const {
 5614|      8|    return _required_instruction_sets;
 5615|      8|  }
_ZN7simdutf14implementationC2EPKcS2_j:
 7514|      4|      : _name(name), _description(description),
 7515|      4|        _required_instruction_sets(required_instruction_sets) {}
_ZN7simdutf8internal29available_implementation_listC2Ev:
 7546|      1|  simdutf_really_inline available_implementation_list() {}
_ZN7simdutf16base64_ignorableEcNS_14base64_optionsE:
 5314|  21.9k|base64_ignorable(char input, base64_options options = base64_default) noexcept {
 5315|  21.9k|  return scalar::base64::is_ignorable(input, options);
 5316|  21.9k|}
_ZN7simdutf16base64_ignorableEDsNS_14base64_optionsE:
 5319|  30.2k|                 base64_options options = base64_default) noexcept {
 5320|  30.2k|  return scalar::base64::is_ignorable(input, options);
 5321|  30.2k|}

simdutf.cpp:_ZN7simdutf8internalL30detect_supported_architecturesEv:
  301|      8|static inline uint32_t detect_supported_architectures() {
  302|      8|  uint32_t eax;
  303|      8|  uint32_t ebx = 0;
  304|      8|  uint32_t ecx = 0;
  305|      8|  uint32_t edx = 0;
  306|      8|  uint32_t host_isa = 0x0;
  307|       |
  308|       |  // EBX for EAX=0x1
  309|      8|  eax = 0x1;
  310|      8|  cpuid(&eax, &ebx, &ecx, &edx);
  311|       |
  312|      8|  if (ecx & cpuid_bit::sse42) {
  ------------------
  |  Branch (312:7): [True: 8, False: 0]
  ------------------
  313|      8|    host_isa |= instruction_set::SSE42;
  314|      8|  }
  315|       |
  316|      8|  if (ecx & cpuid_bit::pclmulqdq) {
  ------------------
  |  Branch (316:7): [True: 8, False: 0]
  ------------------
  317|      8|    host_isa |= instruction_set::PCLMULQDQ;
  318|      8|  }
  319|       |
  320|      8|  if ((ecx & cpuid_bit::osxsave) != cpuid_bit::osxsave) {
  ------------------
  |  Branch (320:7): [True: 0, False: 8]
  ------------------
  321|      0|    return host_isa;
  322|      0|  }
  323|       |
  324|       |  // xgetbv for checking if the OS saves registers
  325|      8|  uint64_t xcr0 = xgetbv();
  326|       |
  327|      8|  if ((xcr0 & cpuid_bit::xcr0_bit::avx256_saved) == 0) {
  ------------------
  |  Branch (327:7): [True: 0, False: 8]
  ------------------
  328|      0|    return host_isa;
  329|      0|  }
  330|       |  // ECX for EAX=0x7
  331|      8|  eax = 0x7;
  332|      8|  ecx = 0x0; // Sub-leaf = 0
  333|      8|  cpuid(&eax, &ebx, &ecx, &edx);
  334|      8|  if (ebx & cpuid_bit::ebx::avx2) {
  ------------------
  |  Branch (334:7): [True: 8, False: 0]
  ------------------
  335|      8|    host_isa |= instruction_set::AVX2;
  336|      8|  }
  337|      8|  if (ebx & cpuid_bit::ebx::bmi1) {
  ------------------
  |  Branch (337:7): [True: 8, False: 0]
  ------------------
  338|      8|    host_isa |= instruction_set::BMI1;
  339|      8|  }
  340|      8|  if (ebx & cpuid_bit::ebx::bmi2) {
  ------------------
  |  Branch (340:7): [True: 8, False: 0]
  ------------------
  341|      8|    host_isa |= instruction_set::BMI2;
  342|      8|  }
  343|      8|  if (!((xcr0 & cpuid_bit::xcr0_bit::avx512_saved) ==
  ------------------
  |  Branch (343:7): [True: 8, False: 0]
  ------------------
  344|      8|        cpuid_bit::xcr0_bit::avx512_saved)) {
  345|      8|    return host_isa;
  346|      8|  }
  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|      8|}
simdutf.cpp:_ZN7simdutf8internalL5cpuidEPjS1_S1_S1_:
  267|     16|                         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|     16|  uint32_t a = *eax, b, c = *ecx, d;
  281|     16|  asm volatile("cpuid\n\t" : "+a"(a), "=b"(b), "+c"(c), "=d"(d));
  282|     16|  *eax = a;
  283|     16|  *ebx = b;
  284|     16|  *ecx = c;
  285|     16|  *edx = d;
  286|     16|  #endif
  287|     16|}
simdutf.cpp:_ZN7simdutf8internalL6xgetbvEv:
  289|      8|static inline uint64_t xgetbv() {
  290|       |  #if defined(_MSC_VER)
  291|       |  return _xgetbv(0);
  292|       |  #elif defined(__FILC__)
  293|       |  return zxgetbv();
  294|       |  #else
  295|      8|  uint32_t xcr0_lo, xcr0_hi;
  296|      8|  asm volatile("xgetbv\n\t" : "=a"(xcr0_lo), "=d"(xcr0_hi) : "c"(0));
  297|      8|  return xcr0_lo | ((uint64_t)xcr0_hi << 32);
  298|      8|  #endif
  299|      8|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_16base6413is_eight_byteIcEEbT_:
   19|  26.0M|template <class char_type> simdutf_constexpr23 bool is_eight_byte(char_type c) {
   20|  26.0M|  if constexpr (sizeof(char_type) == 1) {
   21|  26.0M|    return true;
   22|  26.0M|  }
   23|      0|  return uint8_t(c) == c;
   24|  26.0M|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_16base6413is_eight_byteIDsEEbT_:
   19|  7.97M|template <class char_type> simdutf_constexpr23 bool is_eight_byte(char_type c) {
   20|       |  if constexpr (sizeof(char_type) == 1) {
   21|       |    return true;
   22|       |  }
   23|  7.97M|  return uint8_t(c) == c;
   24|  7.97M|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_16base6433maximal_binary_length_from_base64IPKcEEmT_m:
  654|  5.67k|maximal_binary_length_from_base64(InputPtr input, size_t length) noexcept {
  655|       |  // We process the padding characters ('=') at the end to make sure
  656|       |  // that we return an exact result when the input has no ignorable characters
  657|       |  // (e.g., spaces).
  658|  5.67k|  size_t padding = 0;
  659|  5.67k|  if (length > 0) {
  ------------------
  |  Branch (659:7): [True: 5.66k, False: 15]
  ------------------
  660|  5.66k|    if (input[length - 1] == '=') {
  ------------------
  |  Branch (660:9): [True: 231, False: 5.43k]
  ------------------
  661|    231|      padding++;
  662|    231|      if (length > 1 && input[length - 2] == '=') {
  ------------------
  |  Branch (662:11): [True: 225, False: 6]
  |  Branch (662:25): [True: 42, False: 183]
  ------------------
  663|     42|        padding++;
  664|     42|      }
  665|    231|    }
  666|  5.66k|  }
  667|       |  // The input is not otherwise processed for ignorable characters or
  668|       |  // validation, so that the function runs in constant time (very fast). In
  669|       |  // practice, base64 inputs without ignorable characters are common and the
  670|       |  // common case are line separated inputs with relatively long lines (e.g., 76
  671|       |  // characters) which leads this function to a slight (1%) overestimation of
  672|       |  // the output size.
  673|       |  //
  674|       |  // Of course, some inputs might contain an arbitrary number of spaces or
  675|       |  // newlines, which would make this function return a very pessimistic output
  676|       |  // size but systems that produce base64 outputs typically do not do that and
  677|       |  // if they do, they do not care much about minimizing memory usage.
  678|       |  //
  679|       |  // In specialized applications, users may know that their input is line
  680|       |  // separated, which can be checked very quickly by by iterating (e.g., over 76
  681|       |  // character chunks, looking for the linefeed characters only). We could
  682|       |  // provide a specialized function for that, but it is not clear that the added
  683|       |  // complexity is worth it for us.
  684|       |  //
  685|  5.67k|  size_t actual_length = length - padding;
  686|  5.67k|  if (actual_length % 4 <= 1) {
  ------------------
  |  Branch (686:7): [True: 5.11k, False: 564]
  ------------------
  687|  5.11k|    return actual_length / 4 * 3;
  688|  5.11k|  }
  689|       |  // if we have a valid input, then the remainder must be 2 or 3 adding one or
  690|       |  // two extra bytes.
  691|    564|  return actual_length / 4 * 3 + (actual_length % 4) - 1;
  692|  5.67k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_16base6433maximal_binary_length_from_base64IPKDsEEmT_m:
  654|  5.70k|maximal_binary_length_from_base64(InputPtr input, size_t length) noexcept {
  655|       |  // We process the padding characters ('=') at the end to make sure
  656|       |  // that we return an exact result when the input has no ignorable characters
  657|       |  // (e.g., spaces).
  658|  5.70k|  size_t padding = 0;
  659|  5.70k|  if (length > 0) {
  ------------------
  |  Branch (659:7): [True: 5.68k, False: 12]
  ------------------
  660|  5.68k|    if (input[length - 1] == '=') {
  ------------------
  |  Branch (660:9): [True: 285, False: 5.40k]
  ------------------
  661|    285|      padding++;
  662|    285|      if (length > 1 && input[length - 2] == '=') {
  ------------------
  |  Branch (662:11): [True: 279, False: 6]
  |  Branch (662:25): [True: 27, False: 252]
  ------------------
  663|     27|        padding++;
  664|     27|      }
  665|    285|    }
  666|  5.68k|  }
  667|       |  // The input is not otherwise processed for ignorable characters or
  668|       |  // validation, so that the function runs in constant time (very fast). In
  669|       |  // practice, base64 inputs without ignorable characters are common and the
  670|       |  // common case are line separated inputs with relatively long lines (e.g., 76
  671|       |  // characters) which leads this function to a slight (1%) overestimation of
  672|       |  // the output size.
  673|       |  //
  674|       |  // Of course, some inputs might contain an arbitrary number of spaces or
  675|       |  // newlines, which would make this function return a very pessimistic output
  676|       |  // size but systems that produce base64 outputs typically do not do that and
  677|       |  // if they do, they do not care much about minimizing memory usage.
  678|       |  //
  679|       |  // In specialized applications, users may know that their input is line
  680|       |  // separated, which can be checked very quickly by by iterating (e.g., over 76
  681|       |  // character chunks, looking for the linefeed characters only). We could
  682|       |  // provide a specialized function for that, but it is not clear that the added
  683|       |  // complexity is worth it for us.
  684|       |  //
  685|  5.70k|  size_t actual_length = length - padding;
  686|  5.70k|  if (actual_length % 4 <= 1) {
  ------------------
  |  Branch (686:7): [True: 5.23k, False: 468]
  ------------------
  687|  5.23k|    return actual_length / 4 * 3;
  688|  5.23k|  }
  689|       |  // if we have a valid input, then the remainder must be 2 or 3 adding one or
  690|       |  // two extra bytes.
  691|    468|  return actual_length / 4 * 3 + (actual_length % 4) - 1;
  692|  5.70k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_16base6412is_ignorableIcEEbT_NS_14base64_optionsE:
   28|  21.9k|                                      simdutf::base64_options options) {
   29|  21.9k|  const uint8_t *to_base64 =
   30|  21.9k|      (options & base64_default_or_url)
  ------------------
  |  Branch (30:7): [True: 0, False: 21.9k]
  ------------------
   31|  21.9k|          ? tables::base64::to_base64_default_or_url_value
   32|  21.9k|          : ((options & base64_url) ? tables::base64::to_base64_url_value
  ------------------
  |  Branch (32:14): [True: 8.47k, False: 13.4k]
  ------------------
   33|  21.9k|                                    : tables::base64::to_base64_value);
   34|  21.9k|  const bool ignore_garbage =
   35|  21.9k|      (options == base64_options::base64_url_accept_garbage) ||
  ------------------
  |  Branch (35:7): [True: 0, False: 21.9k]
  ------------------
   36|  21.9k|      (options == base64_options::base64_default_accept_garbage) ||
  ------------------
  |  Branch (36:7): [True: 0, False: 21.9k]
  ------------------
   37|  21.9k|      (options == base64_options::base64_default_or_url_accept_garbage);
  ------------------
  |  Branch (37:7): [True: 0, False: 21.9k]
  ------------------
   38|  21.9k|  uint8_t code = to_base64[uint8_t(c)];
   39|  21.9k|  if (is_eight_byte(c) && code <= 63) {
  ------------------
  |  Branch (39:7): [True: 21.9k, False: 0]
  |  Branch (39:27): [True: 2.99k, False: 18.9k]
  ------------------
   40|  2.99k|    return false;
   41|  2.99k|  }
   42|  18.9k|  if (is_eight_byte(c) && code == 64) {
  ------------------
  |  Branch (42:7): [True: 18.9k, False: 0]
  |  Branch (42:27): [True: 18.9k, False: 0]
  ------------------
   43|  18.9k|    return true;
   44|  18.9k|  }
   45|      0|  return ignore_garbage;
   46|  18.9k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_16base6412is_ignorableIDsEEbT_NS_14base64_optionsE:
   28|  30.2k|                                      simdutf::base64_options options) {
   29|  30.2k|  const uint8_t *to_base64 =
   30|  30.2k|      (options & base64_default_or_url)
  ------------------
  |  Branch (30:7): [True: 0, False: 30.2k]
  ------------------
   31|  30.2k|          ? tables::base64::to_base64_default_or_url_value
   32|  30.2k|          : ((options & base64_url) ? tables::base64::to_base64_url_value
  ------------------
  |  Branch (32:14): [True: 9.62k, False: 20.6k]
  ------------------
   33|  30.2k|                                    : tables::base64::to_base64_value);
   34|  30.2k|  const bool ignore_garbage =
   35|  30.2k|      (options == base64_options::base64_url_accept_garbage) ||
  ------------------
  |  Branch (35:7): [True: 0, False: 30.2k]
  ------------------
   36|  30.2k|      (options == base64_options::base64_default_accept_garbage) ||
  ------------------
  |  Branch (36:7): [True: 0, False: 30.2k]
  ------------------
   37|  30.2k|      (options == base64_options::base64_default_or_url_accept_garbage);
  ------------------
  |  Branch (37:7): [True: 0, False: 30.2k]
  ------------------
   38|  30.2k|  uint8_t code = to_base64[uint8_t(c)];
   39|  30.2k|  if (is_eight_byte(c) && code <= 63) {
  ------------------
  |  Branch (39:7): [True: 30.2k, False: 0]
  |  Branch (39:27): [True: 2.82k, False: 27.4k]
  ------------------
   40|  2.82k|    return false;
   41|  2.82k|  }
   42|  27.4k|  if (is_eight_byte(c) && code == 64) {
  ------------------
  |  Branch (42:7): [True: 27.4k, False: 0]
  |  Branch (42:27): [True: 27.4k, False: 0]
  ------------------
   43|  27.4k|    return true;
   44|  27.4k|  }
   45|      0|  return ignore_garbage;
   46|  27.4k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_16base648find_endIcEENS2_13reduced_inputEPKT_mNS_14base64_optionsE:
  100|  11.3k|                                           simdutf::base64_options options) {
  101|  11.3k|  const uint8_t *to_base64 =
  102|  11.3k|      (options & base64_default_or_url)
  ------------------
  |  Branch (102:7): [True: 0, False: 11.3k]
  ------------------
  103|  11.3k|          ? tables::base64::to_base64_default_or_url_value
  104|  11.3k|          : ((options & base64_url) ? tables::base64::to_base64_url_value
  ------------------
  |  Branch (104:14): [True: 5.50k, False: 5.85k]
  ------------------
  105|  11.3k|                                    : tables::base64::to_base64_value);
  106|  11.3k|  const bool ignore_garbage =
  107|  11.3k|      (options == base64_options::base64_url_accept_garbage) ||
  ------------------
  |  Branch (107:7): [True: 0, False: 11.3k]
  ------------------
  108|  11.3k|      (options == base64_options::base64_default_accept_garbage) ||
  ------------------
  |  Branch (108:7): [True: 0, False: 11.3k]
  ------------------
  109|  11.3k|      (options == base64_options::base64_default_or_url_accept_garbage);
  ------------------
  |  Branch (109:7): [True: 0, False: 11.3k]
  ------------------
  110|       |
  111|  11.3k|  size_t equalsigns = 0;
  112|       |  // We intentionally include trailing spaces in the full input length.
  113|       |  // See https://github.com/simdutf/simdutf/issues/824
  114|  11.3k|  size_t full_input_length = srclen;
  115|       |  // skip trailing spaces
  116|  12.6k|  while (!ignore_garbage && srclen > 0 &&
  ------------------
  |  Branch (116:10): [True: 12.6k, False: 0]
  |  Branch (116:29): [True: 12.6k, False: 66]
  ------------------
  117|  12.6k|         scalar::base64::is_eight_byte(src[srclen - 1]) &&
  ------------------
  |  Branch (117:10): [True: 12.6k, False: 0]
  ------------------
  118|  12.6k|         to_base64[uint8_t(src[srclen - 1])] == 64) {
  ------------------
  |  Branch (118:10): [True: 1.32k, False: 11.2k]
  ------------------
  119|  1.32k|    srclen--;
  120|  1.32k|  }
  121|  11.3k|  size_t equallocation =
  122|  11.3k|      srclen; // location of the first padding character if any
  123|  11.3k|  if (ignore_garbage) {
  ------------------
  |  Branch (123:7): [True: 0, False: 11.3k]
  ------------------
  124|       |    // Technically, we don't need to find the first padding character, we can
  125|       |    // just change our algorithms, but it adds substantial complexity.
  126|      0|    auto it = simdutf::find(src, src + srclen, '=');
  127|      0|    if (it != src + srclen) {
  ------------------
  |  Branch (127:9): [True: 0, False: 0]
  ------------------
  128|      0|      equallocation = it - src;
  129|      0|      equalsigns = 1;
  130|      0|      srclen = equallocation;
  131|      0|      full_input_length = equallocation + 1;
  132|      0|    }
  133|      0|    return {equalsigns, equallocation, srclen, full_input_length};
  134|      0|  }
  135|  11.3k|  if (!ignore_garbage && srclen > 0 && src[srclen - 1] == '=') {
  ------------------
  |  Branch (135:7): [True: 11.3k, False: 0]
  |  Branch (135:26): [True: 11.2k, False: 66]
  |  Branch (135:40): [True: 462, False: 10.8k]
  ------------------
  136|       |    // This is the last '=' sign.
  137|    462|    equallocation = srclen - 1;
  138|    462|    srclen--;
  139|    462|    equalsigns = 1;
  140|       |    // skip trailing spaces
  141|  1.08k|    while (srclen > 0 && scalar::base64::is_eight_byte(src[srclen - 1]) &&
  ------------------
  |  Branch (141:12): [True: 1.03k, False: 54]
  |  Branch (141:26): [True: 1.03k, False: 0]
  ------------------
  142|  1.03k|           to_base64[uint8_t(src[srclen - 1])] == 64) {
  ------------------
  |  Branch (142:12): [True: 624, False: 408]
  ------------------
  143|    624|      srclen--;
  144|    624|    }
  145|    462|    if (srclen > 0 && src[srclen - 1] == '=') {
  ------------------
  |  Branch (145:9): [True: 408, False: 54]
  |  Branch (145:23): [True: 84, False: 324]
  ------------------
  146|       |      // This is the second '=' sign.
  147|     84|      equallocation = srclen - 1;
  148|     84|      srclen--;
  149|     84|      equalsigns = 2;
  150|     84|    }
  151|    462|  }
  152|  11.3k|  return {equalsigns, equallocation, srclen, full_input_length};
  153|  11.3k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_16base6417patch_tail_resultENS_11full_resultEmmmmNS_27last_chunk_handling_optionsE:
  394|  13.0k|                  last_chunk_handling_options last_chunk_options) {
  395|  13.0k|  r.input_count += previous_input;
  396|  13.0k|  r.output_count += previous_output;
  397|  13.0k|  if (r.padding_error) {
  ------------------
  |  Branch (397:7): [True: 312, False: 12.7k]
  ------------------
  398|    312|    r.input_count = equallocation;
  399|    312|  }
  400|       |
  401|  13.0k|  if (r.error == error_code::SUCCESS) {
  ------------------
  |  Branch (401:7): [True: 6.49k, False: 6.59k]
  ------------------
  402|  6.49k|    if (!is_partial(last_chunk_options)) {
  ------------------
  |  Branch (402:9): [True: 2.40k, False: 4.09k]
  ------------------
  403|       |      // A success when we are not in stop_before_partial mode.
  404|       |      // means that we have consumed the whole input buffer.
  405|  2.40k|      r.input_count = full_input_length;
  406|  4.09k|    } else if (r.output_count % 3 != 0) {
  ------------------
  |  Branch (406:16): [True: 24, False: 4.06k]
  ------------------
  407|     24|      r.input_count = full_input_length;
  408|     24|    }
  409|  6.49k|  }
  410|  13.0k|  return r;
  411|  13.0k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_16base648find_endIDsEENS2_13reduced_inputEPKT_mNS_14base64_optionsE:
  100|  11.4k|                                           simdutf::base64_options options) {
  101|  11.4k|  const uint8_t *to_base64 =
  102|  11.4k|      (options & base64_default_or_url)
  ------------------
  |  Branch (102:7): [True: 0, False: 11.4k]
  ------------------
  103|  11.4k|          ? tables::base64::to_base64_default_or_url_value
  104|  11.4k|          : ((options & base64_url) ? tables::base64::to_base64_url_value
  ------------------
  |  Branch (104:14): [True: 5.66k, False: 5.73k]
  ------------------
  105|  11.4k|                                    : tables::base64::to_base64_value);
  106|  11.4k|  const bool ignore_garbage =
  107|  11.4k|      (options == base64_options::base64_url_accept_garbage) ||
  ------------------
  |  Branch (107:7): [True: 0, False: 11.4k]
  ------------------
  108|  11.4k|      (options == base64_options::base64_default_accept_garbage) ||
  ------------------
  |  Branch (108:7): [True: 0, False: 11.4k]
  ------------------
  109|  11.4k|      (options == base64_options::base64_default_or_url_accept_garbage);
  ------------------
  |  Branch (109:7): [True: 0, False: 11.4k]
  ------------------
  110|       |
  111|  11.4k|  size_t equalsigns = 0;
  112|       |  // We intentionally include trailing spaces in the full input length.
  113|       |  // See https://github.com/simdutf/simdutf/issues/824
  114|  11.4k|  size_t full_input_length = srclen;
  115|       |  // skip trailing spaces
  116|  12.6k|  while (!ignore_garbage && srclen > 0 &&
  ------------------
  |  Branch (116:10): [True: 12.6k, False: 0]
  |  Branch (116:29): [True: 12.5k, False: 60]
  ------------------
  117|  12.5k|         scalar::base64::is_eight_byte(src[srclen - 1]) &&
  ------------------
  |  Branch (117:10): [True: 8.43k, False: 4.15k]
  ------------------
  118|  8.43k|         to_base64[uint8_t(src[srclen - 1])] == 64) {
  ------------------
  |  Branch (118:10): [True: 1.24k, False: 7.18k]
  ------------------
  119|  1.24k|    srclen--;
  120|  1.24k|  }
  121|  11.4k|  size_t equallocation =
  122|  11.4k|      srclen; // location of the first padding character if any
  123|  11.4k|  if (ignore_garbage) {
  ------------------
  |  Branch (123:7): [True: 0, False: 11.4k]
  ------------------
  124|       |    // Technically, we don't need to find the first padding character, we can
  125|       |    // just change our algorithms, but it adds substantial complexity.
  126|      0|    auto it = simdutf::find(src, src + srclen, '=');
  127|      0|    if (it != src + srclen) {
  ------------------
  |  Branch (127:9): [True: 0, False: 0]
  ------------------
  128|      0|      equallocation = it - src;
  129|      0|      equalsigns = 1;
  130|      0|      srclen = equallocation;
  131|      0|      full_input_length = equallocation + 1;
  132|      0|    }
  133|      0|    return {equalsigns, equallocation, srclen, full_input_length};
  134|      0|  }
  135|  11.4k|  if (!ignore_garbage && srclen > 0 && src[srclen - 1] == '=') {
  ------------------
  |  Branch (135:7): [True: 11.4k, False: 0]
  |  Branch (135:26): [True: 11.3k, False: 60]
  |  Branch (135:40): [True: 570, False: 10.7k]
  ------------------
  136|       |    // This is the last '=' sign.
  137|    570|    equallocation = srclen - 1;
  138|    570|    srclen--;
  139|    570|    equalsigns = 1;
  140|       |    // skip trailing spaces
  141|  1.56k|    while (srclen > 0 && scalar::base64::is_eight_byte(src[srclen - 1]) &&
  ------------------
  |  Branch (141:12): [True: 1.51k, False: 48]
  |  Branch (141:26): [True: 1.34k, False: 174]
  ------------------
  142|  1.34k|           to_base64[uint8_t(src[srclen - 1])] == 64) {
  ------------------
  |  Branch (142:12): [True: 996, False: 348]
  ------------------
  143|    996|      srclen--;
  144|    996|    }
  145|    570|    if (srclen > 0 && src[srclen - 1] == '=') {
  ------------------
  |  Branch (145:9): [True: 522, False: 48]
  |  Branch (145:23): [True: 54, False: 468]
  ------------------
  146|       |      // This is the second '=' sign.
  147|     54|      equallocation = srclen - 1;
  148|     54|      srclen--;
  149|     54|      equalsigns = 2;
  150|     54|    }
  151|    570|  }
  152|  11.4k|  return {equalsigns, equallocation, srclen, full_input_length};
  153|  11.4k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_16base6429base64_to_binary_details_implIcEENS_11full_resultEPKT_mPcNS_14base64_optionsENS_27last_chunk_handling_optionsE:
  727|  3.78k|    last_chunk_handling_options last_chunk_options) noexcept {
  728|  3.78k|  const bool ignore_garbage =
  729|  3.78k|      (options == base64_options::base64_url_accept_garbage) ||
  ------------------
  |  Branch (729:7): [True: 0, False: 3.78k]
  ------------------
  730|  3.78k|      (options == base64_options::base64_default_accept_garbage) ||
  ------------------
  |  Branch (730:7): [True: 0, False: 3.78k]
  ------------------
  731|  3.78k|      (options == base64_options::base64_default_or_url_accept_garbage);
  ------------------
  |  Branch (731:7): [True: 0, False: 3.78k]
  ------------------
  732|  3.78k|  auto ri = simdutf::scalar::base64::find_end(input, length, options);
  733|  3.78k|  size_t equallocation = ri.equallocation;
  734|  3.78k|  size_t equalsigns = ri.equalsigns;
  735|  3.78k|  length = ri.srclen;
  736|  3.78k|  size_t full_input_length = ri.full_input_length;
  737|  3.78k|  if (length == 0) {
  ------------------
  |  Branch (737:7): [True: 42, False: 3.74k]
  ------------------
  738|     42|    if (!ignore_garbage && equalsigns > 0) {
  ------------------
  |  Branch (738:9): [True: 42, False: 0]
  |  Branch (738:28): [True: 20, False: 22]
  ------------------
  739|     20|      return {INVALID_BASE64_CHARACTER, equallocation, 0, true};
  740|     20|    }
  741|     22|    return {SUCCESS, full_input_length, 0};
  742|     42|  }
  743|  3.74k|  full_result r = scalar::base64::base64_tail_decode(
  744|  3.74k|      output, input, length, equalsigns, options, last_chunk_options);
  745|  3.74k|  r = scalar::base64::patch_tail_result(r, 0, 0, equallocation,
  746|  3.74k|                                        full_input_length, last_chunk_options);
  747|  3.74k|  if (!is_partial(last_chunk_options) && r.error == error_code::SUCCESS &&
  ------------------
  |  Branch (747:7): [True: 2.20k, False: 1.53k]
  |  Branch (747:42): [True: 680, False: 1.52k]
  ------------------
  748|    680|      equalsigns > 0 && !ignore_garbage) {
  ------------------
  |  Branch (748:7): [True: 6, False: 674]
  |  Branch (748:25): [True: 6, False: 0]
  ------------------
  749|       |    // additional checks
  750|      6|    if ((r.output_count % 3 == 0) ||
  ------------------
  |  Branch (750:9): [True: 0, False: 6]
  ------------------
  751|      6|        ((r.output_count % 3) + 1 + equalsigns != 4)) {
  ------------------
  |  Branch (751:9): [True: 0, False: 6]
  ------------------
  752|      0|      return {INVALID_BASE64_CHARACTER, equallocation, r.output_count, true};
  753|      0|    }
  754|      6|  }
  755|       |  // When is_partial(last_chunk_options) is true, we must either end with
  756|       |  // the end of the stream (beyond whitespace) or right after a non-ignorable
  757|       |  // character or at the very beginning of the stream.
  758|       |  // See https://tc39.es/proposal-arraybuffer-base64/spec/#sec-frombase64
  759|  3.74k|  if (is_partial(last_chunk_options) && r.error == error_code::SUCCESS &&
  ------------------
  |  Branch (759:7): [True: 1.53k, False: 2.20k]
  |  Branch (759:41): [True: 794, False: 742]
  ------------------
  760|    794|      r.input_count < full_input_length) {
  ------------------
  |  Branch (760:7): [True: 566, False: 228]
  ------------------
  761|       |    // First check if we can extend the input to the end of the stream
  762|  5.14k|    while (r.input_count < full_input_length &&
  ------------------
  |  Branch (762:12): [True: 5.12k, False: 14]
  ------------------
  763|  5.12k|           base64_ignorable(*(input + r.input_count), options)) {
  ------------------
  |  Branch (763:12): [True: 4.57k, False: 552]
  ------------------
  764|  4.57k|      r.input_count++;
  765|  4.57k|    }
  766|       |    // If we are still not at the end of the stream, then we must backtrack
  767|       |    // to the last non-ignorable character.
  768|    566|    if (r.input_count < full_input_length) {
  ------------------
  |  Branch (768:9): [True: 552, False: 14]
  ------------------
  769|  4.85k|      while (r.input_count > 0 &&
  ------------------
  |  Branch (769:14): [True: 4.75k, False: 106]
  ------------------
  770|  4.75k|             base64_ignorable(*(input + r.input_count - 1), options)) {
  ------------------
  |  Branch (770:14): [True: 4.30k, False: 446]
  ------------------
  771|  4.30k|        r.input_count--;
  772|  4.30k|      }
  773|    552|    }
  774|    566|  }
  775|  3.74k|  return r;
  776|  3.74k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_16base6418base64_tail_decodeIcEENS_11full_resultEPcPKT_mmNS_14base64_optionsENS_27last_chunk_handling_optionsE:
  371|  6.54k|    base64_options options, last_chunk_handling_options last_chunk_options) {
  372|  6.54k|  return base64_tail_decode_impl<false>(dst, 0, src, length, padding_characters,
  373|  6.54k|                                        options, last_chunk_options);
  374|  6.54k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_16base6423base64_tail_decode_implILb0EcEENS_11full_resultEPcmPKT0_mmNS_14base64_optionsENS_27last_chunk_handling_optionsE:
  164|  6.54k|    base64_options options, last_chunk_handling_options last_chunk_options) {
  165|  6.54k|  char *dstend = dst + outlen;
  166|  6.54k|  (void)dstend;
  167|       |  // This looks like 10 branches, but we expect the compiler to resolve this to
  168|       |  // two branches (easily predicted):
  169|  6.54k|  const uint8_t *to_base64 =
  170|  6.54k|      (options & base64_default_or_url)
  ------------------
  |  Branch (170:7): [True: 0, False: 6.54k]
  ------------------
  171|  6.54k|          ? tables::base64::to_base64_default_or_url_value
  172|  6.54k|          : ((options & base64_url) ? tables::base64::to_base64_url_value
  ------------------
  |  Branch (172:14): [True: 3.11k, False: 3.43k]
  ------------------
  173|  6.54k|                                    : tables::base64::to_base64_value);
  174|  6.54k|  const uint32_t *d0 =
  175|  6.54k|      (options & base64_default_or_url)
  ------------------
  |  Branch (175:7): [True: 0, False: 6.54k]
  ------------------
  176|  6.54k|          ? tables::base64::base64_default_or_url::d0
  177|  6.54k|          : ((options & base64_url) ? tables::base64::base64_url::d0
  ------------------
  |  Branch (177:14): [True: 3.11k, False: 3.43k]
  ------------------
  178|  6.54k|                                    : tables::base64::base64_default::d0);
  179|  6.54k|  const uint32_t *d1 =
  180|  6.54k|      (options & base64_default_or_url)
  ------------------
  |  Branch (180:7): [True: 0, False: 6.54k]
  ------------------
  181|  6.54k|          ? tables::base64::base64_default_or_url::d1
  182|  6.54k|          : ((options & base64_url) ? tables::base64::base64_url::d1
  ------------------
  |  Branch (182:14): [True: 3.11k, False: 3.43k]
  ------------------
  183|  6.54k|                                    : tables::base64::base64_default::d1);
  184|  6.54k|  const uint32_t *d2 =
  185|  6.54k|      (options & base64_default_or_url)
  ------------------
  |  Branch (185:7): [True: 0, False: 6.54k]
  ------------------
  186|  6.54k|          ? tables::base64::base64_default_or_url::d2
  187|  6.54k|          : ((options & base64_url) ? tables::base64::base64_url::d2
  ------------------
  |  Branch (187:14): [True: 3.11k, False: 3.43k]
  ------------------
  188|  6.54k|                                    : tables::base64::base64_default::d2);
  189|  6.54k|  const uint32_t *d3 =
  190|  6.54k|      (options & base64_default_or_url)
  ------------------
  |  Branch (190:7): [True: 0, False: 6.54k]
  ------------------
  191|  6.54k|          ? tables::base64::base64_default_or_url::d3
  192|  6.54k|          : ((options & base64_url) ? tables::base64::base64_url::d3
  ------------------
  |  Branch (192:14): [True: 3.11k, False: 3.43k]
  ------------------
  193|  6.54k|                                    : tables::base64::base64_default::d3);
  194|  6.54k|  const bool ignore_garbage =
  195|  6.54k|      (options == base64_options::base64_url_accept_garbage) ||
  ------------------
  |  Branch (195:7): [True: 0, False: 6.54k]
  ------------------
  196|  6.54k|      (options == base64_options::base64_default_accept_garbage) ||
  ------------------
  |  Branch (196:7): [True: 0, False: 6.54k]
  ------------------
  197|  6.54k|      (options == base64_options::base64_default_or_url_accept_garbage);
  ------------------
  |  Branch (197:7): [True: 0, False: 6.54k]
  ------------------
  198|       |
  199|  6.54k|  const char_type *srcend = src + length;
  200|  6.54k|  const char_type *srcinit = src;
  201|  6.54k|  const char *dstinit = dst;
  202|       |
  203|  6.54k|  uint32_t x;
  204|  6.54k|  size_t idx;
  205|  6.54k|  uint8_t buffer[4];
  206|   105k|  while (true) {
  ------------------
  |  Branch (206:10): [True: 105k, Folded]
  ------------------
  207|  6.22M|    while (srcend - src >= 4 && is_eight_byte(src[0]) &&
  ------------------
  |  Branch (207:12): [True: 6.22M, False: 3.33k]
  |  Branch (207:33): [True: 6.22M, False: 0]
  ------------------
  208|  6.22M|           is_eight_byte(src[1]) && is_eight_byte(src[2]) &&
  ------------------
  |  Branch (208:12): [True: 6.22M, False: 0]
  |  Branch (208:37): [True: 6.22M, False: 0]
  ------------------
  209|  6.22M|           is_eight_byte(src[3]) &&
  ------------------
  |  Branch (209:12): [True: 6.22M, False: 0]
  ------------------
  210|  6.22M|           (x = d0[uint8_t(src[0])] | d1[uint8_t(src[1])] |
  ------------------
  |  Branch (210:12): [True: 6.11M, False: 101k]
  ------------------
  211|  6.22M|                d2[uint8_t(src[2])] | d3[uint8_t(src[3])]) < 0x01FFFFFF) {
  212|  6.11M|      if (check_capacity && dstend - dst < 3) {
  ------------------
  |  Branch (212:11): [Folded, False: 6.11M]
  |  Branch (212:29): [True: 0, False: 0]
  ------------------
  213|      0|        return {OUTPUT_BUFFER_TOO_SMALL, size_t(src - srcinit),
  214|      0|                size_t(dst - dstinit)};
  215|      0|      }
  216|  6.11M|      *dst++ = static_cast<char>(x & 0xFF);
  217|  6.11M|      *dst++ = static_cast<char>((x >> 8) & 0xFF);
  218|  6.11M|      *dst++ = static_cast<char>((x >> 16) & 0xFF);
  219|  6.11M|      src += 4;
  220|  6.11M|    }
  221|   105k|    const char_type *srccur = src;
  222|   105k|    idx = 0;
  223|       |    // we need at least four characters.
  224|   105k|#ifdef __clang__
  225|       |    // If possible, we read four characters at a time. (It is an optimization.)
  226|   105k|    if (ignore_garbage && src + 4 <= srcend) {
  ------------------
  |  Branch (226:9): [True: 0, False: 105k]
  |  Branch (226:27): [True: 0, False: 0]
  ------------------
  227|      0|      char_type c0 = src[0];
  228|      0|      char_type c1 = src[1];
  229|      0|      char_type c2 = src[2];
  230|      0|      char_type c3 = src[3];
  231|       |
  232|      0|      uint8_t code0 = to_base64[uint8_t(c0)];
  233|      0|      uint8_t code1 = to_base64[uint8_t(c1)];
  234|      0|      uint8_t code2 = to_base64[uint8_t(c2)];
  235|      0|      uint8_t code3 = to_base64[uint8_t(c3)];
  236|       |
  237|      0|      buffer[idx] = code0;
  238|      0|      idx += (is_eight_byte(c0) && code0 <= 63);
  ------------------
  |  Branch (238:15): [True: 0, False: 0]
  |  Branch (238:36): [True: 0, False: 0]
  ------------------
  239|      0|      buffer[idx] = code1;
  240|      0|      idx += (is_eight_byte(c1) && code1 <= 63);
  ------------------
  |  Branch (240:15): [True: 0, False: 0]
  |  Branch (240:36): [True: 0, False: 0]
  ------------------
  241|      0|      buffer[idx] = code2;
  242|      0|      idx += (is_eight_byte(c2) && code2 <= 63);
  ------------------
  |  Branch (242:15): [True: 0, False: 0]
  |  Branch (242:36): [True: 0, False: 0]
  ------------------
  243|      0|      buffer[idx] = code3;
  244|      0|      idx += (is_eight_byte(c3) && code3 <= 63);
  ------------------
  |  Branch (244:15): [True: 0, False: 0]
  |  Branch (244:36): [True: 0, False: 0]
  ------------------
  245|      0|      src += 4;
  246|      0|    }
  247|   105k|#endif
  248|   879k|    while ((idx < 4) && (src < srcend)) {
  ------------------
  |  Branch (248:12): [True: 781k, False: 98.4k]
  |  Branch (248:25): [True: 777k, False: 4.21k]
  ------------------
  249|   777k|      char_type c = *src;
  250|       |
  251|   777k|      uint8_t code = to_base64[uint8_t(c)];
  252|   777k|      buffer[idx] = uint8_t(code);
  253|   777k|      if (is_eight_byte(c) && code <= 63) {
  ------------------
  |  Branch (253:11): [True: 777k, False: 0]
  |  Branch (253:31): [True: 402k, False: 374k]
  ------------------
  254|   402k|        idx++;
  255|   402k|      } else if (!ignore_garbage &&
  ------------------
  |  Branch (255:18): [True: 374k, False: 0]
  ------------------
  256|   374k|                 (code > 64 || !scalar::base64::is_eight_byte(c))) {
  ------------------
  |  Branch (256:19): [True: 2.32k, False: 372k]
  |  Branch (256:32): [True: 0, False: 372k]
  ------------------
  257|  2.32k|        return {INVALID_BASE64_CHARACTER, size_t(src - srcinit),
  258|  2.32k|                size_t(dst - dstinit)};
  259|   372k|      } else {
  260|       |        // We have a space or a newline or garbage. We ignore it.
  261|   372k|      }
  262|   774k|      src++;
  263|   774k|    }
  264|   102k|    if (idx != 4) {
  ------------------
  |  Branch (264:9): [True: 4.21k, False: 98.4k]
  ------------------
  265|  4.21k|      simdutf_log_assert(idx < 4, "idx should be less than 4");
  266|       |      // We never should have that the number of base64 characters + the
  267|       |      // number of padding characters is more than 4.
  268|  4.21k|      if (!ignore_garbage && (idx + padding_characters > 4)) {
  ------------------
  |  Branch (268:11): [True: 4.21k, False: 0]
  |  Branch (268:30): [True: 6, False: 4.20k]
  ------------------
  269|      6|        return {INVALID_BASE64_CHARACTER, size_t(src - srcinit),
  270|      6|                size_t(dst - dstinit), true};
  271|      6|      }
  272|       |
  273|       |      // The idea here is that in loose mode,
  274|       |      // if there is padding at all, it must be used
  275|       |      // to form 4-wise chunk. However, in loose mode,
  276|       |      // we do accept no padding at all.
  277|  4.20k|      if (!ignore_garbage &&
  ------------------
  |  Branch (277:11): [True: 4.20k, False: 0]
  ------------------
  278|  4.20k|          last_chunk_options == last_chunk_handling_options::loose &&
  ------------------
  |  Branch (278:11): [True: 1.72k, False: 2.48k]
  ------------------
  279|  1.72k|          (idx >= 2) && padding_characters > 0 &&
  ------------------
  |  Branch (279:11): [True: 1.02k, False: 696]
  |  Branch (279:25): [True: 18, False: 1.00k]
  ------------------
  280|     18|          ((idx + padding_characters) & 3) != 0) {
  ------------------
  |  Branch (280:11): [True: 12, False: 6]
  ------------------
  281|     12|        return {INVALID_BASE64_CHARACTER, size_t(src - srcinit),
  282|     12|                size_t(dst - dstinit), true};
  283|     12|      } else
  284|       |
  285|       |        // The idea here is that in strict mode, we do not want to accept
  286|       |        // incomplete base64 chunks. So if the chunk was otherwise valid, we
  287|       |        // return BASE64_INPUT_REMAINDER.
  288|  4.19k|        if (!ignore_garbage &&
  ------------------
  |  Branch (288:13): [True: 4.19k, False: 0]
  ------------------
  289|  4.19k|            last_chunk_options == last_chunk_handling_options::strict &&
  ------------------
  |  Branch (289:13): [True: 334, False: 3.86k]
  ------------------
  290|    334|            (idx >= 2) && ((idx + padding_characters) & 3) != 0) {
  ------------------
  |  Branch (290:13): [True: 126, False: 208]
  |  Branch (290:27): [True: 72, False: 54]
  ------------------
  291|       |          // The partial chunk was at src - idx
  292|     72|          return {BASE64_INPUT_REMAINDER, size_t(src - srcinit),
  293|     72|                  size_t(dst - dstinit), true};
  294|     72|        } else
  295|       |          // If there is a partial chunk with insufficient padding, with
  296|       |          // stop_before_partial, we need to just ignore it. In "only full"
  297|       |          // mode, skip the minute there are padding characters.
  298|  4.12k|          if ((last_chunk_options ==
  ------------------
  |  Branch (298:16): [True: 2.15k, False: 1.97k]
  ------------------
  299|  4.12k|                   last_chunk_handling_options::stop_before_partial &&
  300|  2.15k|               (padding_characters + idx < 4) && (idx != 0) &&
  ------------------
  |  Branch (300:16): [True: 2.14k, False: 12]
  |  Branch (300:50): [True: 1.68k, False: 460]
  ------------------
  301|  1.68k|               (idx >= 2 || padding_characters == 0)) ||
  ------------------
  |  Branch (301:17): [True: 744, False: 936]
  |  Branch (301:29): [True: 912, False: 24]
  ------------------
  302|  2.46k|              (last_chunk_options ==
  ------------------
  |  Branch (302:16): [True: 0, False: 2.46k]
  ------------------
  303|  2.46k|                   last_chunk_handling_options::only_full_chunks &&
  304|  1.65k|               (idx >= 2 || padding_characters == 0))) {
  ------------------
  |  Branch (304:17): [True: 0, False: 0]
  |  Branch (304:29): [True: 0, False: 0]
  ------------------
  305|       |            // partial means that we are *not* going to consume the read
  306|       |            // characters. We need to rewind the src pointer.
  307|  1.65k|            src = srccur;
  308|  1.65k|            return {SUCCESS, size_t(src - srcinit), size_t(dst - dstinit)};
  309|  2.46k|          } else {
  310|  2.46k|            if (idx == 2) {
  ------------------
  |  Branch (310:17): [True: 612, False: 1.85k]
  ------------------
  311|    612|              uint32_t triple = (uint32_t(buffer[0]) << 3 * 6) +
  312|    612|                                (uint32_t(buffer[1]) << 2 * 6);
  313|    612|              if (!ignore_garbage &&
  ------------------
  |  Branch (313:19): [True: 612, False: 0]
  ------------------
  314|    612|                  (last_chunk_options == last_chunk_handling_options::strict) &&
  ------------------
  |  Branch (314:19): [True: 30, False: 582]
  ------------------
  315|     30|                  (triple & 0xffff)) {
  ------------------
  |  Branch (315:19): [True: 24, False: 6]
  ------------------
  316|     24|                return {BASE64_EXTRA_BITS, size_t(src - srcinit),
  317|     24|                        size_t(dst - dstinit)};
  318|     24|              }
  319|    588|              if (check_capacity && dstend - dst < 1) {
  ------------------
  |  Branch (319:19): [Folded, False: 588]
  |  Branch (319:37): [True: 0, False: 0]
  ------------------
  320|      0|                return {OUTPUT_BUFFER_TOO_SMALL, size_t(srccur - srcinit),
  321|      0|                        size_t(dst - dstinit)};
  322|      0|              }
  323|    588|              *dst++ = static_cast<char>((triple >> 16) & 0xFF);
  324|  1.85k|            } else if (idx == 3) {
  ------------------
  |  Branch (324:24): [True: 468, False: 1.38k]
  ------------------
  325|    468|              uint32_t triple = (uint32_t(buffer[0]) << 3 * 6) +
  326|    468|                                (uint32_t(buffer[1]) << 2 * 6) +
  327|    468|                                (uint32_t(buffer[2]) << 1 * 6);
  328|    468|              if (!ignore_garbage &&
  ------------------
  |  Branch (328:19): [True: 468, False: 0]
  ------------------
  329|    468|                  (last_chunk_options == last_chunk_handling_options::strict) &&
  ------------------
  |  Branch (329:19): [True: 24, False: 444]
  ------------------
  330|     24|                  (triple & 0xff)) {
  ------------------
  |  Branch (330:19): [True: 18, False: 6]
  ------------------
  331|     18|                return {BASE64_EXTRA_BITS, size_t(src - srcinit),
  332|     18|                        size_t(dst - dstinit)};
  333|     18|              }
  334|    450|              if (check_capacity && dstend - dst < 2) {
  ------------------
  |  Branch (334:19): [Folded, False: 450]
  |  Branch (334:37): [True: 0, False: 0]
  ------------------
  335|      0|                return {OUTPUT_BUFFER_TOO_SMALL, size_t(srccur - srcinit),
  336|      0|                        size_t(dst - dstinit)};
  337|      0|              }
  338|    450|              *dst++ = static_cast<char>((triple >> 16) & 0xFF);
  339|    450|              *dst++ = static_cast<char>((triple >> 8) & 0xFF);
  340|  1.38k|            } else if (!ignore_garbage && idx == 1 &&
  ------------------
  |  Branch (340:24): [True: 1.38k, False: 0]
  |  Branch (340:43): [True: 300, False: 1.08k]
  ------------------
  341|    300|                       (!is_partial(last_chunk_options) ||
  ------------------
  |  Branch (341:25): [True: 276, False: 24]
  ------------------
  342|     24|                        (is_partial(last_chunk_options) &&
  ------------------
  |  Branch (342:26): [True: 24, False: 0]
  ------------------
  343|    300|                         padding_characters > 0))) {
  ------------------
  |  Branch (343:26): [True: 24, False: 0]
  ------------------
  344|    300|              return {BASE64_INPUT_REMAINDER, size_t(src - srcinit),
  345|    300|                      size_t(dst - dstinit)};
  346|  1.08k|            } else if (!ignore_garbage && idx == 0 && padding_characters > 0) {
  ------------------
  |  Branch (346:24): [True: 1.08k, False: 0]
  |  Branch (346:43): [True: 1.08k, False: 0]
  |  Branch (346:55): [True: 36, False: 1.05k]
  ------------------
  347|     36|              return {INVALID_BASE64_CHARACTER, size_t(src - srcinit),
  348|     36|                      size_t(dst - dstinit), true};
  349|     36|            }
  350|  2.09k|            return {SUCCESS, size_t(src - srcinit), size_t(dst - dstinit)};
  351|  2.46k|          }
  352|  4.20k|    }
  353|  98.4k|    if (check_capacity && dstend - dst < 3) {
  ------------------
  |  Branch (353:9): [Folded, False: 98.4k]
  |  Branch (353:27): [True: 0, False: 0]
  ------------------
  354|      0|      return {OUTPUT_BUFFER_TOO_SMALL, size_t(srccur - srcinit),
  355|      0|              size_t(dst - dstinit)};
  356|      0|    }
  357|  98.4k|    uint32_t triple =
  358|  98.4k|        (uint32_t(buffer[0]) << 3 * 6) + (uint32_t(buffer[1]) << 2 * 6) +
  359|  98.4k|        (uint32_t(buffer[2]) << 1 * 6) + (uint32_t(buffer[3]) << 0 * 6);
  360|  98.4k|    *dst++ = static_cast<char>((triple >> 16) & 0xFF);
  361|  98.4k|    *dst++ = static_cast<char>((triple >> 8) & 0xFF);
  362|  98.4k|    *dst++ = static_cast<char>(triple & 0xFF);
  363|  98.4k|  }
  364|  6.54k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_16base6429base64_to_binary_details_implIDsEENS_11full_resultEPKT_mPcNS_14base64_optionsENS_27last_chunk_handling_optionsE:
  727|  3.80k|    last_chunk_handling_options last_chunk_options) noexcept {
  728|  3.80k|  const bool ignore_garbage =
  729|  3.80k|      (options == base64_options::base64_url_accept_garbage) ||
  ------------------
  |  Branch (729:7): [True: 0, False: 3.80k]
  ------------------
  730|  3.80k|      (options == base64_options::base64_default_accept_garbage) ||
  ------------------
  |  Branch (730:7): [True: 0, False: 3.80k]
  ------------------
  731|  3.80k|      (options == base64_options::base64_default_or_url_accept_garbage);
  ------------------
  |  Branch (731:7): [True: 0, False: 3.80k]
  ------------------
  732|  3.80k|  auto ri = simdutf::scalar::base64::find_end(input, length, options);
  733|  3.80k|  size_t equallocation = ri.equallocation;
  734|  3.80k|  size_t equalsigns = ri.equalsigns;
  735|  3.80k|  length = ri.srclen;
  736|  3.80k|  size_t full_input_length = ri.full_input_length;
  737|  3.80k|  if (length == 0) {
  ------------------
  |  Branch (737:7): [True: 38, False: 3.76k]
  ------------------
  738|     38|    if (!ignore_garbage && equalsigns > 0) {
  ------------------
  |  Branch (738:9): [True: 38, False: 0]
  |  Branch (738:28): [True: 18, False: 20]
  ------------------
  739|     18|      return {INVALID_BASE64_CHARACTER, equallocation, 0, true};
  740|     18|    }
  741|     20|    return {SUCCESS, full_input_length, 0};
  742|     38|  }
  743|  3.76k|  full_result r = scalar::base64::base64_tail_decode(
  744|  3.76k|      output, input, length, equalsigns, options, last_chunk_options);
  745|  3.76k|  r = scalar::base64::patch_tail_result(r, 0, 0, equallocation,
  746|  3.76k|                                        full_input_length, last_chunk_options);
  747|  3.76k|  if (!is_partial(last_chunk_options) && r.error == error_code::SUCCESS &&
  ------------------
  |  Branch (747:7): [True: 1.98k, False: 1.77k]
  |  Branch (747:42): [True: 336, False: 1.65k]
  ------------------
  748|    336|      equalsigns > 0 && !ignore_garbage) {
  ------------------
  |  Branch (748:7): [True: 8, False: 328]
  |  Branch (748:25): [True: 8, False: 0]
  ------------------
  749|       |    // additional checks
  750|      8|    if ((r.output_count % 3 == 0) ||
  ------------------
  |  Branch (750:9): [True: 0, False: 8]
  ------------------
  751|      8|        ((r.output_count % 3) + 1 + equalsigns != 4)) {
  ------------------
  |  Branch (751:9): [True: 0, False: 8]
  ------------------
  752|      0|      return {INVALID_BASE64_CHARACTER, equallocation, r.output_count, true};
  753|      0|    }
  754|      8|  }
  755|       |  // When is_partial(last_chunk_options) is true, we must either end with
  756|       |  // the end of the stream (beyond whitespace) or right after a non-ignorable
  757|       |  // character or at the very beginning of the stream.
  758|       |  // See https://tc39.es/proposal-arraybuffer-base64/spec/#sec-frombase64
  759|  3.76k|  if (is_partial(last_chunk_options) && r.error == error_code::SUCCESS &&
  ------------------
  |  Branch (759:7): [True: 1.77k, False: 1.98k]
  |  Branch (759:41): [True: 758, False: 1.01k]
  ------------------
  760|    758|      r.input_count < full_input_length) {
  ------------------
  |  Branch (760:7): [True: 550, False: 208]
  ------------------
  761|       |    // First check if we can extend the input to the end of the stream
  762|  7.25k|    while (r.input_count < full_input_length &&
  ------------------
  |  Branch (762:12): [True: 7.25k, False: 8]
  ------------------
  763|  7.25k|           base64_ignorable(*(input + r.input_count), options)) {
  ------------------
  |  Branch (763:12): [True: 6.70k, False: 542]
  ------------------
  764|  6.70k|      r.input_count++;
  765|  6.70k|    }
  766|       |    // If we are still not at the end of the stream, then we must backtrack
  767|       |    // to the last non-ignorable character.
  768|    550|    if (r.input_count < full_input_length) {
  ------------------
  |  Branch (768:9): [True: 542, False: 8]
  ------------------
  769|  6.99k|      while (r.input_count > 0 &&
  ------------------
  |  Branch (769:14): [True: 6.84k, False: 144]
  ------------------
  770|  6.84k|             base64_ignorable(*(input + r.input_count - 1), options)) {
  ------------------
  |  Branch (770:14): [True: 6.44k, False: 398]
  ------------------
  771|  6.44k|        r.input_count--;
  772|  6.44k|      }
  773|    542|    }
  774|    550|  }
  775|  3.76k|  return r;
  776|  3.76k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_16base6418base64_tail_decodeIDsEENS_11full_resultEPcPKT_mmNS_14base64_optionsENS_27last_chunk_handling_optionsE:
  371|  6.54k|    base64_options options, last_chunk_handling_options last_chunk_options) {
  372|  6.54k|  return base64_tail_decode_impl<false>(dst, 0, src, length, padding_characters,
  373|  6.54k|                                        options, last_chunk_options);
  374|  6.54k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_16base6423base64_tail_decode_implILb0EDsEENS_11full_resultEPcmPKT0_mmNS_14base64_optionsENS_27last_chunk_handling_optionsE:
  164|  6.54k|    base64_options options, last_chunk_handling_options last_chunk_options) {
  165|  6.54k|  char *dstend = dst + outlen;
  166|  6.54k|  (void)dstend;
  167|       |  // This looks like 10 branches, but we expect the compiler to resolve this to
  168|       |  // two branches (easily predicted):
  169|  6.54k|  const uint8_t *to_base64 =
  170|  6.54k|      (options & base64_default_or_url)
  ------------------
  |  Branch (170:7): [True: 0, False: 6.54k]
  ------------------
  171|  6.54k|          ? tables::base64::to_base64_default_or_url_value
  172|  6.54k|          : ((options & base64_url) ? tables::base64::to_base64_url_value
  ------------------
  |  Branch (172:14): [True: 3.24k, False: 3.30k]
  ------------------
  173|  6.54k|                                    : tables::base64::to_base64_value);
  174|  6.54k|  const uint32_t *d0 =
  175|  6.54k|      (options & base64_default_or_url)
  ------------------
  |  Branch (175:7): [True: 0, False: 6.54k]
  ------------------
  176|  6.54k|          ? tables::base64::base64_default_or_url::d0
  177|  6.54k|          : ((options & base64_url) ? tables::base64::base64_url::d0
  ------------------
  |  Branch (177:14): [True: 3.24k, False: 3.30k]
  ------------------
  178|  6.54k|                                    : tables::base64::base64_default::d0);
  179|  6.54k|  const uint32_t *d1 =
  180|  6.54k|      (options & base64_default_or_url)
  ------------------
  |  Branch (180:7): [True: 0, False: 6.54k]
  ------------------
  181|  6.54k|          ? tables::base64::base64_default_or_url::d1
  182|  6.54k|          : ((options & base64_url) ? tables::base64::base64_url::d1
  ------------------
  |  Branch (182:14): [True: 3.24k, False: 3.30k]
  ------------------
  183|  6.54k|                                    : tables::base64::base64_default::d1);
  184|  6.54k|  const uint32_t *d2 =
  185|  6.54k|      (options & base64_default_or_url)
  ------------------
  |  Branch (185:7): [True: 0, False: 6.54k]
  ------------------
  186|  6.54k|          ? tables::base64::base64_default_or_url::d2
  187|  6.54k|          : ((options & base64_url) ? tables::base64::base64_url::d2
  ------------------
  |  Branch (187:14): [True: 3.24k, False: 3.30k]
  ------------------
  188|  6.54k|                                    : tables::base64::base64_default::d2);
  189|  6.54k|  const uint32_t *d3 =
  190|  6.54k|      (options & base64_default_or_url)
  ------------------
  |  Branch (190:7): [True: 0, False: 6.54k]
  ------------------
  191|  6.54k|          ? tables::base64::base64_default_or_url::d3
  192|  6.54k|          : ((options & base64_url) ? tables::base64::base64_url::d3
  ------------------
  |  Branch (192:14): [True: 3.24k, False: 3.30k]
  ------------------
  193|  6.54k|                                    : tables::base64::base64_default::d3);
  194|  6.54k|  const bool ignore_garbage =
  195|  6.54k|      (options == base64_options::base64_url_accept_garbage) ||
  ------------------
  |  Branch (195:7): [True: 0, False: 6.54k]
  ------------------
  196|  6.54k|      (options == base64_options::base64_default_accept_garbage) ||
  ------------------
  |  Branch (196:7): [True: 0, False: 6.54k]
  ------------------
  197|  6.54k|      (options == base64_options::base64_default_or_url_accept_garbage);
  ------------------
  |  Branch (197:7): [True: 0, False: 6.54k]
  ------------------
  198|       |
  199|  6.54k|  const char_type *srcend = src + length;
  200|  6.54k|  const char_type *srcinit = src;
  201|  6.54k|  const char *dstinit = dst;
  202|       |
  203|  6.54k|  uint32_t x;
  204|  6.54k|  size_t idx;
  205|  6.54k|  uint8_t buffer[4];
  206|   109k|  while (true) {
  ------------------
  |  Branch (206:10): [True: 109k, Folded]
  ------------------
  207|  1.75M|    while (srcend - src >= 4 && is_eight_byte(src[0]) &&
  ------------------
  |  Branch (207:12): [True: 1.74M, False: 2.73k]
  |  Branch (207:33): [True: 1.74M, False: 530]
  ------------------
  208|  1.74M|           is_eight_byte(src[1]) && is_eight_byte(src[2]) &&
  ------------------
  |  Branch (208:12): [True: 1.74M, False: 424]
  |  Branch (208:37): [True: 1.74M, False: 382]
  ------------------
  209|  1.74M|           is_eight_byte(src[3]) &&
  ------------------
  |  Branch (209:12): [True: 1.74M, False: 372]
  ------------------
  210|  1.74M|           (x = d0[uint8_t(src[0])] | d1[uint8_t(src[1])] |
  ------------------
  |  Branch (210:12): [True: 1.64M, False: 105k]
  ------------------
  211|  1.74M|                d2[uint8_t(src[2])] | d3[uint8_t(src[3])]) < 0x01FFFFFF) {
  212|  1.64M|      if (check_capacity && dstend - dst < 3) {
  ------------------
  |  Branch (212:11): [Folded, False: 1.64M]
  |  Branch (212:29): [True: 0, False: 0]
  ------------------
  213|      0|        return {OUTPUT_BUFFER_TOO_SMALL, size_t(src - srcinit),
  214|      0|                size_t(dst - dstinit)};
  215|      0|      }
  216|  1.64M|      *dst++ = static_cast<char>(x & 0xFF);
  217|  1.64M|      *dst++ = static_cast<char>((x >> 8) & 0xFF);
  218|  1.64M|      *dst++ = static_cast<char>((x >> 16) & 0xFF);
  219|  1.64M|      src += 4;
  220|  1.64M|    }
  221|   109k|    const char_type *srccur = src;
  222|   109k|    idx = 0;
  223|       |    // we need at least four characters.
  224|   109k|#ifdef __clang__
  225|       |    // If possible, we read four characters at a time. (It is an optimization.)
  226|   109k|    if (ignore_garbage && src + 4 <= srcend) {
  ------------------
  |  Branch (226:9): [True: 0, False: 109k]
  |  Branch (226:27): [True: 0, False: 0]
  ------------------
  227|      0|      char_type c0 = src[0];
  228|      0|      char_type c1 = src[1];
  229|      0|      char_type c2 = src[2];
  230|      0|      char_type c3 = src[3];
  231|       |
  232|      0|      uint8_t code0 = to_base64[uint8_t(c0)];
  233|      0|      uint8_t code1 = to_base64[uint8_t(c1)];
  234|      0|      uint8_t code2 = to_base64[uint8_t(c2)];
  235|      0|      uint8_t code3 = to_base64[uint8_t(c3)];
  236|       |
  237|      0|      buffer[idx] = code0;
  238|      0|      idx += (is_eight_byte(c0) && code0 <= 63);
  ------------------
  |  Branch (238:15): [True: 0, False: 0]
  |  Branch (238:36): [True: 0, False: 0]
  ------------------
  239|      0|      buffer[idx] = code1;
  240|      0|      idx += (is_eight_byte(c1) && code1 <= 63);
  ------------------
  |  Branch (240:15): [True: 0, False: 0]
  |  Branch (240:36): [True: 0, False: 0]
  ------------------
  241|      0|      buffer[idx] = code2;
  242|      0|      idx += (is_eight_byte(c2) && code2 <= 63);
  ------------------
  |  Branch (242:15): [True: 0, False: 0]
  |  Branch (242:36): [True: 0, False: 0]
  ------------------
  243|      0|      buffer[idx] = code3;
  244|      0|      idx += (is_eight_byte(c3) && code3 <= 63);
  ------------------
  |  Branch (244:15): [True: 0, False: 0]
  |  Branch (244:36): [True: 0, False: 0]
  ------------------
  245|      0|      src += 4;
  246|      0|    }
  247|   109k|#endif
  248|   768k|    while ((idx < 4) && (src < srcend)) {
  ------------------
  |  Branch (248:12): [True: 665k, False: 103k]
  |  Branch (248:25): [True: 662k, False: 3.16k]
  ------------------
  249|   662k|      char_type c = *src;
  250|       |
  251|   662k|      uint8_t code = to_base64[uint8_t(c)];
  252|   662k|      buffer[idx] = uint8_t(code);
  253|   662k|      if (is_eight_byte(c) && code <= 63) {
  ------------------
  |  Branch (253:11): [True: 659k, False: 2.59k]
  |  Branch (253:31): [True: 421k, False: 238k]
  ------------------
  254|   421k|        idx++;
  255|   421k|      } else if (!ignore_garbage &&
  ------------------
  |  Branch (255:18): [True: 241k, False: 0]
  ------------------
  256|   241k|                 (code > 64 || !scalar::base64::is_eight_byte(c))) {
  ------------------
  |  Branch (256:19): [True: 1.99k, False: 239k]
  |  Branch (256:32): [True: 1.38k, False: 237k]
  ------------------
  257|  3.38k|        return {INVALID_BASE64_CHARACTER, size_t(src - srcinit),
  258|  3.38k|                size_t(dst - dstinit)};
  259|   237k|      } else {
  260|       |        // We have a space or a newline or garbage. We ignore it.
  261|   237k|      }
  262|   659k|      src++;
  263|   659k|    }
  264|   106k|    if (idx != 4) {
  ------------------
  |  Branch (264:9): [True: 3.16k, False: 103k]
  ------------------
  265|  3.16k|      simdutf_log_assert(idx < 4, "idx should be less than 4");
  266|       |      // We never should have that the number of base64 characters + the
  267|       |      // number of padding characters is more than 4.
  268|  3.16k|      if (!ignore_garbage && (idx + padding_characters > 4)) {
  ------------------
  |  Branch (268:11): [True: 3.16k, False: 0]
  |  Branch (268:30): [True: 6, False: 3.16k]
  ------------------
  269|      6|        return {INVALID_BASE64_CHARACTER, size_t(src - srcinit),
  270|      6|                size_t(dst - dstinit), true};
  271|      6|      }
  272|       |
  273|       |      // The idea here is that in loose mode,
  274|       |      // if there is padding at all, it must be used
  275|       |      // to form 4-wise chunk. However, in loose mode,
  276|       |      // we do accept no padding at all.
  277|  3.16k|      if (!ignore_garbage &&
  ------------------
  |  Branch (277:11): [True: 3.16k, False: 0]
  ------------------
  278|  3.16k|          last_chunk_options == last_chunk_handling_options::loose &&
  ------------------
  |  Branch (278:11): [True: 776, False: 2.38k]
  ------------------
  279|    776|          (idx >= 2) && padding_characters > 0 &&
  ------------------
  |  Branch (279:11): [True: 474, False: 302]
  |  Branch (279:25): [True: 12, False: 462]
  ------------------
  280|     12|          ((idx + padding_characters) & 3) != 0) {
  ------------------
  |  Branch (280:11): [True: 6, False: 6]
  ------------------
  281|      6|        return {INVALID_BASE64_CHARACTER, size_t(src - srcinit),
  282|      6|                size_t(dst - dstinit), true};
  283|      6|      } else
  284|       |
  285|       |        // The idea here is that in strict mode, we do not want to accept
  286|       |        // incomplete base64 chunks. So if the chunk was otherwise valid, we
  287|       |        // return BASE64_INPUT_REMAINDER.
  288|  3.15k|        if (!ignore_garbage &&
  ------------------
  |  Branch (288:13): [True: 3.15k, False: 0]
  ------------------
  289|  3.15k|            last_chunk_options == last_chunk_handling_options::strict &&
  ------------------
  |  Branch (289:13): [True: 366, False: 2.78k]
  ------------------
  290|    366|            (idx >= 2) && ((idx + padding_characters) & 3) != 0) {
  ------------------
  |  Branch (290:13): [True: 222, False: 144]
  |  Branch (290:27): [True: 162, False: 60]
  ------------------
  291|       |          // The partial chunk was at src - idx
  292|    162|          return {BASE64_INPUT_REMAINDER, size_t(src - srcinit),
  293|    162|                  size_t(dst - dstinit), true};
  294|    162|        } else
  295|       |          // If there is a partial chunk with insufficient padding, with
  296|       |          // stop_before_partial, we need to just ignore it. In "only full"
  297|       |          // mode, skip the minute there are padding characters.
  298|  2.99k|          if ((last_chunk_options ==
  ------------------
  |  Branch (298:16): [True: 2.01k, False: 974]
  ------------------
  299|  2.99k|                   last_chunk_handling_options::stop_before_partial &&
  300|  2.01k|               (padding_characters + idx < 4) && (idx != 0) &&
  ------------------
  |  Branch (300:16): [True: 2.00k, False: 12]
  |  Branch (300:50): [True: 1.65k, False: 350]
  ------------------
  301|  1.65k|               (idx >= 2 || padding_characters == 0)) ||
  ------------------
  |  Branch (301:17): [True: 870, False: 786]
  |  Branch (301:29): [True: 756, False: 30]
  ------------------
  302|  1.36k|              (last_chunk_options ==
  ------------------
  |  Branch (302:16): [True: 0, False: 1.36k]
  ------------------
  303|  1.36k|                   last_chunk_handling_options::only_full_chunks &&
  304|  1.62k|               (idx >= 2 || padding_characters == 0))) {
  ------------------
  |  Branch (304:17): [True: 0, False: 0]
  |  Branch (304:29): [True: 0, False: 0]
  ------------------
  305|       |            // partial means that we are *not* going to consume the read
  306|       |            // characters. We need to rewind the src pointer.
  307|  1.62k|            src = srccur;
  308|  1.62k|            return {SUCCESS, size_t(src - srcinit), size_t(dst - dstinit)};
  309|  1.62k|          } else {
  310|  1.36k|            if (idx == 2) {
  ------------------
  |  Branch (310:17): [True: 252, False: 1.11k]
  ------------------
  311|    252|              uint32_t triple = (uint32_t(buffer[0]) << 3 * 6) +
  312|    252|                                (uint32_t(buffer[1]) << 2 * 6);
  313|    252|              if (!ignore_garbage &&
  ------------------
  |  Branch (313:19): [True: 252, False: 0]
  ------------------
  314|    252|                  (last_chunk_options == last_chunk_handling_options::strict) &&
  ------------------
  |  Branch (314:19): [True: 36, False: 216]
  ------------------
  315|     36|                  (triple & 0xffff)) {
  ------------------
  |  Branch (315:19): [True: 24, False: 12]
  ------------------
  316|     24|                return {BASE64_EXTRA_BITS, size_t(src - srcinit),
  317|     24|                        size_t(dst - dstinit)};
  318|     24|              }
  319|    228|              if (check_capacity && dstend - dst < 1) {
  ------------------
  |  Branch (319:19): [Folded, False: 228]
  |  Branch (319:37): [True: 0, False: 0]
  ------------------
  320|      0|                return {OUTPUT_BUFFER_TOO_SMALL, size_t(srccur - srcinit),
  321|      0|                        size_t(dst - dstinit)};
  322|      0|              }
  323|    228|              *dst++ = static_cast<char>((triple >> 16) & 0xFF);
  324|  1.11k|            } else if (idx == 3) {
  ------------------
  |  Branch (324:24): [True: 288, False: 826]
  ------------------
  325|    288|              uint32_t triple = (uint32_t(buffer[0]) << 3 * 6) +
  326|    288|                                (uint32_t(buffer[1]) << 2 * 6) +
  327|    288|                                (uint32_t(buffer[2]) << 1 * 6);
  328|    288|              if (!ignore_garbage &&
  ------------------
  |  Branch (328:19): [True: 288, False: 0]
  ------------------
  329|    288|                  (last_chunk_options == last_chunk_handling_options::strict) &&
  ------------------
  |  Branch (329:19): [True: 24, False: 264]
  ------------------
  330|     24|                  (triple & 0xff)) {
  ------------------
  |  Branch (330:19): [True: 18, False: 6]
  ------------------
  331|     18|                return {BASE64_EXTRA_BITS, size_t(src - srcinit),
  332|     18|                        size_t(dst - dstinit)};
  333|     18|              }
  334|    270|              if (check_capacity && dstend - dst < 2) {
  ------------------
  |  Branch (334:19): [Folded, False: 270]
  |  Branch (334:37): [True: 0, False: 0]
  ------------------
  335|      0|                return {OUTPUT_BUFFER_TOO_SMALL, size_t(srccur - srcinit),
  336|      0|                        size_t(dst - dstinit)};
  337|      0|              }
  338|    270|              *dst++ = static_cast<char>((triple >> 16) & 0xFF);
  339|    270|              *dst++ = static_cast<char>((triple >> 8) & 0xFF);
  340|    826|            } else if (!ignore_garbage && idx == 1 &&
  ------------------
  |  Branch (340:24): [True: 826, False: 0]
  |  Branch (340:43): [True: 192, False: 634]
  ------------------
  341|    192|                       (!is_partial(last_chunk_options) ||
  ------------------
  |  Branch (341:25): [True: 162, False: 30]
  ------------------
  342|     30|                        (is_partial(last_chunk_options) &&
  ------------------
  |  Branch (342:26): [True: 30, False: 0]
  ------------------
  343|    192|                         padding_characters > 0))) {
  ------------------
  |  Branch (343:26): [True: 30, False: 0]
  ------------------
  344|    192|              return {BASE64_INPUT_REMAINDER, size_t(src - srcinit),
  345|    192|                      size_t(dst - dstinit)};
  346|    634|            } else if (!ignore_garbage && idx == 0 && padding_characters > 0) {
  ------------------
  |  Branch (346:24): [True: 634, False: 0]
  |  Branch (346:43): [True: 634, False: 0]
  |  Branch (346:55): [True: 12, False: 622]
  ------------------
  347|     12|              return {INVALID_BASE64_CHARACTER, size_t(src - srcinit),
  348|     12|                      size_t(dst - dstinit), true};
  349|     12|            }
  350|  1.12k|            return {SUCCESS, size_t(src - srcinit), size_t(dst - dstinit)};
  351|  1.36k|          }
  352|  3.16k|    }
  353|   103k|    if (check_capacity && dstend - dst < 3) {
  ------------------
  |  Branch (353:9): [Folded, False: 103k]
  |  Branch (353:27): [True: 0, False: 0]
  ------------------
  354|      0|      return {OUTPUT_BUFFER_TOO_SMALL, size_t(srccur - srcinit),
  355|      0|              size_t(dst - dstinit)};
  356|      0|    }
  357|   103k|    uint32_t triple =
  358|   103k|        (uint32_t(buffer[0]) << 3 * 6) + (uint32_t(buffer[1]) << 2 * 6) +
  359|   103k|        (uint32_t(buffer[2]) << 1 * 6) + (uint32_t(buffer[3]) << 0 * 6);
  360|   103k|    *dst++ = static_cast<char>((triple >> 16) & 0xFF);
  361|   103k|    *dst++ = static_cast<char>((triple >> 8) & 0xFF);
  362|   103k|    *dst++ = static_cast<char>(triple & 0xFF);
  363|   103k|  }
  364|  6.54k|}

_ZN7simdutf6scalar14u32_swap_bytesEj:
   13|  29.8k|u32_swap_bytes(const uint32_t word) {
   14|  29.8k|  return ((word >> 24) & 0xff) |      // move byte 3 to byte 0
   15|  29.8k|         ((word << 8) & 0xff0000) |   // move byte 1 to byte 2
   16|  29.8k|         ((word >> 8) & 0xff00) |     // move byte 2 to byte 1
   17|  29.8k|         ((word << 24) & 0xff000000); // byte 0 to byte 3
   18|  29.8k|}

_ZNK7simdutf8fallback14implementation16base64_to_binaryEPKcmPcNS_14base64_optionsENS_27last_chunk_handling_optionsE:
  541|  1.89k|    last_chunk_handling_options last_chunk_options) const noexcept {
  542|  1.89k|  return simdutf::scalar::base64::base64_to_binary_details_impl(
  543|  1.89k|      input, length, output, options, last_chunk_options);
  544|  1.89k|}
_ZNK7simdutf8fallback14implementation16base64_to_binaryEPKDsmPcNS_14base64_optionsENS_27last_chunk_handling_optionsE:
  548|  1.90k|    last_chunk_handling_options last_chunk_options) const noexcept {
  549|  1.90k|  return simdutf::scalar::base64::base64_to_binary_details_impl(
  550|  1.90k|      input, length, output, options, last_chunk_options);
  551|  1.90k|}
_ZNK7simdutf8fallback14implementation24base64_to_binary_detailsEPKcmPcNS_14base64_optionsENS_27last_chunk_handling_optionsE:
  555|  1.89k|    last_chunk_handling_options last_chunk_options) const noexcept {
  556|  1.89k|  return simdutf::scalar::base64::base64_to_binary_details_impl(
  557|  1.89k|      input, length, output, options, last_chunk_options);
  558|  1.89k|}
_ZNK7simdutf8fallback14implementation24base64_to_binary_detailsEPKDsmPcNS_14base64_optionsENS_27last_chunk_handling_optionsE:
  562|  1.90k|    last_chunk_handling_options last_chunk_options) const noexcept {
  563|  1.90k|  return simdutf::scalar::base64::base64_to_binary_details_impl(
  564|  1.90k|      input, length, output, options, last_chunk_options);
  565|  1.90k|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_16base6422compress_decode_base64ILb1ELb0ELb0EcEENS_11full_resultEPcPKT2_mNS_14base64_optionsENS_27last_chunk_handling_optionsE:
   45|  1.83k|                       last_chunk_handling_options last_chunk_options) {
   46|  1.83k|  const uint8_t *to_base64 =
   47|  1.83k|      default_or_url ? tables::base64::to_base64_default_or_url_value
  ------------------
  |  Branch (47:7): [Folded, False: 1.83k]
  ------------------
   48|  1.83k|                     : (base64_url ? tables::base64::to_base64_url_value
  ------------------
  |  Branch (48:25): [True: 1.83k, Folded]
  ------------------
   49|  1.83k|                                   : tables::base64::to_base64_value);
   50|  1.83k|  auto ri = simdutf::scalar::base64::find_end(src, srclen, options);
   51|  1.83k|  size_t equallocation = ri.equallocation;
   52|  1.83k|  size_t equalsigns = ri.equalsigns;
   53|  1.83k|  srclen = ri.srclen;
   54|  1.83k|  size_t full_input_length = ri.full_input_length;
   55|  1.83k|  if (srclen == 0) {
  ------------------
  |  Branch (55:7): [True: 20, False: 1.81k]
  ------------------
   56|     20|    if (!ignore_garbage && equalsigns > 0) {
  ------------------
  |  Branch (56:9): [True: 20, Folded]
  |  Branch (56:28): [True: 8, False: 12]
  ------------------
   57|      8|      return {INVALID_BASE64_CHARACTER, equallocation, 0, true};
   58|      8|    }
   59|     12|    return {SUCCESS, full_input_length, 0};
   60|     20|  }
   61|  1.81k|  const chartype *const srcinit = src;
   62|  1.81k|  const char *const dstinit = dst;
   63|  1.81k|  const chartype *const srcend = src + srclen;
   64|       |
   65|  1.81k|  constexpr size_t block_size = 6;
   66|  1.81k|  static_assert(block_size >= 2, "block_size must be at least two");
   67|  1.81k|  char buffer[block_size * 64];
   68|  1.81k|  char *bufferptr = buffer;
   69|       |  // A wide block store writes 4 bytes past its 48. That is safe when the next
   70|       |  // store starts 48 bytes later. Pairs of clean blocks wide-store the first
   71|       |  // and end the second on byte 48. Anything shorter, or a block that is not
   72|       |  // clean, uses the exact store. The pair attempt is only worth it on a long
   73|       |  // input: a short one often fails the first block and then repeats that work.
   74|  1.81k|  if (srclen >= 512) {
  ------------------
  |  Branch (74:7): [True: 912, False: 902]
  ------------------
   75|    912|    const chartype *const srcend128 = src + srclen - 128;
   76|  21.9k|    while (bufferptr == buffer && src <= srcend128) {
  ------------------
  |  Branch (76:12): [True: 21.9k, False: 0]
  |  Branch (76:35): [True: 21.9k, False: 12]
  ------------------
   77|  21.9k|      block64 b0(src);
   78|  21.9k|      uint64_t e0 = 0;
   79|  21.9k|      const uint64_t m0 =
   80|  21.9k|          b0.to_base64_mask<base64_url, ignore_garbage, default_or_url>(&e0);
   81|  21.9k|      if ((!ignore_garbage && e0) || m0 != 0) {
  ------------------
  |  Branch (81:12): [True: 21.9k, Folded]
  |  Branch (81:31): [True: 218, False: 21.7k]
  |  Branch (81:38): [True: 316, False: 21.4k]
  ------------------
   82|    534|        break;
   83|    534|      }
   84|  21.4k|      block64 b1(src + 64);
   85|  21.4k|      uint64_t e1 = 0;
   86|  21.4k|      const uint64_t m1 =
   87|  21.4k|          b1.to_base64_mask<base64_url, ignore_garbage, default_or_url>(&e1);
   88|  21.4k|      if ((!ignore_garbage && e1) || m1 != 0) {
  ------------------
  |  Branch (88:12): [True: 21.4k, Folded]
  |  Branch (88:31): [True: 182, False: 21.2k]
  |  Branch (88:38): [True: 184, False: 21.0k]
  ------------------
   89|    366|        break;
   90|    366|      }
   91|  21.0k|      b0.base64_decode_block(dst);
   92|  21.0k|      b1.template base64_decode_block<true>(dst + 48);
   93|  21.0k|      src += 128;
   94|  21.0k|      dst += 96;
   95|  21.0k|    }
   96|    912|  }
   97|  1.81k|  if (srclen >= 64) {
  ------------------
  |  Branch (97:7): [True: 1.56k, False: 246]
  ------------------
   98|  1.56k|    const chartype *const srcend64 = srcinit + srclen - 64;
   99|  53.9k|    while (src <= srcend64) {
  ------------------
  |  Branch (99:12): [True: 53.3k, False: 584]
  ------------------
  100|  53.3k|      block64 b(src);
  101|  53.3k|      uint64_t error = 0;
  102|  53.3k|      const uint64_t badcharmask =
  103|  53.3k|          b.to_base64_mask<base64_url, ignore_garbage, default_or_url>(&error);
  104|  53.3k|      if (!ignore_garbage && error) {
  ------------------
  |  Branch (104:11): [True: 53.3k, Folded]
  |  Branch (104:30): [True: 984, False: 52.3k]
  ------------------
  105|    984|        const size_t error_offset = trailing_zeroes(error);
  106|    984|        return {error_code::INVALID_BASE64_CHARACTER,
  107|    984|                size_t(src - srcinit + error_offset), size_t(dst - dstinit)};
  108|    984|      }
  109|  52.3k|      src += 64;
  110|  52.3k|      if (badcharmask != 0) {
  ------------------
  |  Branch (110:11): [True: 27.0k, False: 25.2k]
  ------------------
  111|  27.0k|        bufferptr += b.compress_block(badcharmask, bufferptr);
  112|  27.0k|      } else if (bufferptr != buffer) {
  ------------------
  |  Branch (112:18): [True: 24.4k, False: 866]
  ------------------
  113|  24.4k|        b.copy_block(bufferptr);
  114|  24.4k|        bufferptr += 64;
  115|  24.4k|      } else {
  116|    866|        b.template base64_decode_block<true>(dst);
  117|    866|        dst += 48;
  118|    866|      }
  119|  52.3k|      if (bufferptr >= (block_size - 1) * 64 + buffer) {
  ------------------
  |  Branch (119:11): [True: 9.78k, False: 42.5k]
  ------------------
  120|  48.9k|        for (size_t i = 0; i < (block_size - 2); i++) {
  ------------------
  |  Branch (120:28): [True: 39.1k, False: 9.78k]
  ------------------
  121|  39.1k|          base64_decode_block(dst, buffer + i * 64);
  122|  39.1k|          dst += 48;
  123|  39.1k|        }
  124|  9.78k|        base64_decode_block<true>(dst, buffer + (block_size - 2) * 64);
  125|  9.78k|        dst += 48;
  126|  9.78k|        std::memcpy(buffer, buffer + (block_size - 1) * 64,
  127|  9.78k|                    64); // 64 might be too much
  128|  9.78k|        bufferptr -= (block_size - 1) * 64;
  129|  9.78k|      }
  130|  52.3k|    }
  131|  1.56k|  }
  132|       |
  133|    830|  char *buffer_start = buffer;
  134|       |  // Optimization note: if this is almost full, then it is worth our
  135|       |  // time, otherwise, we should just decode directly.
  136|    830|  int last_block = (int)((bufferptr - buffer_start) % 64);
  137|    830|  if (last_block != 0 && srcend - src + last_block >= 64) {
  ------------------
  |  Branch (137:7): [True: 530, False: 300]
  |  Branch (137:26): [True: 78, False: 452]
  ------------------
  138|       |
  139|  1.04k|    while ((bufferptr - buffer_start) % 64 != 0 && src < srcend) {
  ------------------
  |  Branch (139:12): [True: 980, False: 62]
  |  Branch (139:52): [True: 970, False: 10]
  ------------------
  140|    970|      uint8_t val = to_base64[uint8_t(*src)];
  141|    970|      *bufferptr = char(val);
  142|    970|      if (!ignore_garbage &&
  ------------------
  |  Branch (142:11): [True: 970, Folded]
  ------------------
  143|    970|          (!scalar::base64::is_eight_byte(*src) || val > 64)) {
  ------------------
  |  Branch (143:12): [True: 0, False: 970]
  |  Branch (143:52): [True: 6, False: 964]
  ------------------
  144|      6|        return {error_code::INVALID_BASE64_CHARACTER, size_t(src - srcinit),
  145|      6|                size_t(dst - dstinit)};
  146|      6|      }
  147|    964|      bufferptr += (val <= 63);
  148|    964|      src++;
  149|    964|    }
  150|     78|  }
  151|       |
  152|  1.28k|  for (; buffer_start + 64 <= bufferptr; buffer_start += 64) {
  ------------------
  |  Branch (152:10): [True: 460, False: 824]
  ------------------
  153|       |    // 8 payload bytes still in the buffer become 6 output bytes, which cover
  154|       |    // the 4-byte tail of a wide store. Fewer than that, and the tail can
  155|       |    // stick out past the real end.
  156|    460|    const size_t after = size_t(bufferptr - (buffer_start + 64));
  157|    460|    if (after >= 8) {
  ------------------
  |  Branch (157:9): [True: 376, False: 84]
  ------------------
  158|    376|      base64_decode_block(dst, buffer_start);
  159|    376|    } else {
  160|     84|      base64_decode_block<true>(dst, buffer_start);
  161|     84|    }
  162|    460|    dst += 48;
  163|    460|  }
  164|    824|  if ((bufferptr - buffer_start) % 64 != 0) {
  ------------------
  |  Branch (164:7): [True: 462, False: 362]
  ------------------
  165|  3.91k|    while (buffer_start + 4 < bufferptr) {
  ------------------
  |  Branch (165:12): [True: 3.45k, False: 462]
  ------------------
  166|  3.45k|      uint32_t triple = ((uint32_t(uint8_t(buffer_start[0])) << 3 * 6) +
  167|  3.45k|                         (uint32_t(uint8_t(buffer_start[1])) << 2 * 6) +
  168|  3.45k|                         (uint32_t(uint8_t(buffer_start[2])) << 1 * 6) +
  169|  3.45k|                         (uint32_t(uint8_t(buffer_start[3])) << 0 * 6))
  170|  3.45k|                        << 8;
  171|  3.45k|#if !SIMDUTF_IS_BIG_ENDIAN
  172|  3.45k|      triple = scalar::u32_swap_bytes(triple);
  173|  3.45k|#endif
  174|  3.45k|      std::memcpy(dst, &triple, 3);
  175|       |
  176|  3.45k|      dst += 3;
  177|  3.45k|      buffer_start += 4;
  178|  3.45k|    }
  179|    462|    if (buffer_start + 4 <= bufferptr) {
  ------------------
  |  Branch (179:9): [True: 128, False: 334]
  ------------------
  180|    128|      uint32_t triple = ((uint32_t(uint8_t(buffer_start[0])) << 3 * 6) +
  181|    128|                         (uint32_t(uint8_t(buffer_start[1])) << 2 * 6) +
  182|    128|                         (uint32_t(uint8_t(buffer_start[2])) << 1 * 6) +
  183|    128|                         (uint32_t(uint8_t(buffer_start[3])) << 0 * 6))
  184|    128|                        << 8;
  185|    128|#if !SIMDUTF_IS_BIG_ENDIAN
  186|    128|      triple = scalar::u32_swap_bytes(triple);
  187|    128|#endif
  188|    128|      std::memcpy(dst, &triple, 3);
  189|       |
  190|    128|      dst += 3;
  191|    128|      buffer_start += 4;
  192|    128|    }
  193|       |    // we may have 1, 2 or 3 bytes left and we need to decode them so let us
  194|       |    // backtrack
  195|    462|    int leftover = int(bufferptr - buffer_start);
  196|  1.11k|    while (leftover > 0) {
  ------------------
  |  Branch (196:12): [True: 656, False: 462]
  ------------------
  197|    656|      if (!ignore_garbage) {
  ------------------
  |  Branch (197:11): [True: 656, Folded]
  ------------------
  198|  5.10k|        while (to_base64[uint8_t(*(src - 1))] == 64) {
  ------------------
  |  Branch (198:16): [True: 4.45k, False: 656]
  ------------------
  199|  4.45k|          src--;
  200|  4.45k|        }
  201|    656|      } else {
  202|      0|        while (to_base64[uint8_t(*(src - 1))] >= 64) {
  ------------------
  |  Branch (202:16): [True: 0, False: 0]
  ------------------
  203|      0|          src--;
  204|      0|        }
  205|      0|      }
  206|    656|      src--;
  207|    656|      leftover--;
  208|    656|    }
  209|    462|  }
  210|    824|  if (src < srcend + equalsigns) {
  ------------------
  |  Branch (210:7): [True: 648, False: 176]
  ------------------
  211|    648|    full_result r = scalar::base64::base64_tail_decode(
  212|    648|        dst, src, srcend - src, equalsigns, options, last_chunk_options);
  213|    648|    r = scalar::base64::patch_tail_result(
  214|    648|        r, size_t(src - srcinit), size_t(dst - dstinit), equallocation,
  215|    648|        full_input_length, last_chunk_options);
  216|       |    // When is_partial(last_chunk_options) is true, we must either end with
  217|       |    // the end of the stream (beyond whitespace) or right after a non-ignorable
  218|       |    // character or at the very beginning of the stream.
  219|       |    // See https://tc39.es/proposal-arraybuffer-base64/spec/#sec-frombase64
  220|    648|    if (is_partial(last_chunk_options) && r.error == error_code::SUCCESS &&
  ------------------
  |  Branch (220:9): [True: 292, False: 356]
  |  Branch (220:43): [True: 274, False: 18]
  ------------------
  221|    274|        r.input_count < full_input_length) {
  ------------------
  |  Branch (221:9): [True: 246, False: 28]
  ------------------
  222|       |      // First check if we can extend the input to the end of the stream
  223|    680|      while (r.input_count < full_input_length &&
  ------------------
  |  Branch (223:14): [True: 676, False: 4]
  ------------------
  224|    676|             base64_ignorable(*(srcinit + r.input_count), options)) {
  ------------------
  |  Branch (224:14): [True: 434, False: 242]
  ------------------
  225|    434|        r.input_count++;
  226|    434|      }
  227|       |      // If we are still not at the end of the stream, then we must backtrack
  228|       |      // to the last non-ignorable character.
  229|    246|      if (r.input_count < full_input_length) {
  ------------------
  |  Branch (229:11): [True: 242, False: 4]
  ------------------
  230|  1.79k|        while (r.input_count > 0 &&
  ------------------
  |  Branch (230:16): [True: 1.73k, False: 58]
  ------------------
  231|  1.73k|               base64_ignorable(*(srcinit + r.input_count - 1), options)) {
  ------------------
  |  Branch (231:16): [True: 1.55k, False: 184]
  ------------------
  232|  1.55k|          r.input_count--;
  233|  1.55k|        }
  234|    242|      }
  235|    246|    }
  236|    648|    return r;
  237|    648|  }
  238|    176|  if (!ignore_garbage && equalsigns > 0) {
  ------------------
  |  Branch (238:7): [True: 176, Folded]
  |  Branch (238:26): [True: 0, False: 176]
  ------------------
  239|      0|    if ((size_t(dst - dstinit) % 3 == 0) ||
  ------------------
  |  Branch (239:9): [True: 0, False: 0]
  ------------------
  240|      0|        ((size_t(dst - dstinit) % 3) + 1 + equalsigns != 4)) {
  ------------------
  |  Branch (240:9): [True: 0, False: 0]
  ------------------
  241|      0|      return {INVALID_BASE64_CHARACTER, equallocation, size_t(dst - dstinit),
  242|      0|              true};
  243|      0|    }
  244|      0|  }
  245|    176|  return {SUCCESS, srclen, size_t(dst - dstinit)};
  246|    176|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_16base6422compress_decode_base64ILb0ELb0ELb0EcEENS_11full_resultEPcPKT2_mNS_14base64_optionsENS_27last_chunk_handling_optionsE:
   45|  1.95k|                       last_chunk_handling_options last_chunk_options) {
   46|  1.95k|  const uint8_t *to_base64 =
   47|  1.95k|      default_or_url ? tables::base64::to_base64_default_or_url_value
  ------------------
  |  Branch (47:7): [Folded, False: 1.95k]
  ------------------
   48|  1.95k|                     : (base64_url ? tables::base64::to_base64_url_value
  ------------------
  |  Branch (48:25): [Folded, False: 1.95k]
  ------------------
   49|  1.95k|                                   : tables::base64::to_base64_value);
   50|  1.95k|  auto ri = simdutf::scalar::base64::find_end(src, srclen, options);
   51|  1.95k|  size_t equallocation = ri.equallocation;
   52|  1.95k|  size_t equalsigns = ri.equalsigns;
   53|  1.95k|  srclen = ri.srclen;
   54|  1.95k|  size_t full_input_length = ri.full_input_length;
   55|  1.95k|  if (srclen == 0) {
  ------------------
  |  Branch (55:7): [True: 22, False: 1.93k]
  ------------------
   56|     22|    if (!ignore_garbage && equalsigns > 0) {
  ------------------
  |  Branch (56:9): [True: 22, Folded]
  |  Branch (56:28): [True: 12, False: 10]
  ------------------
   57|     12|      return {INVALID_BASE64_CHARACTER, equallocation, 0, true};
   58|     12|    }
   59|     10|    return {SUCCESS, full_input_length, 0};
   60|     22|  }
   61|  1.93k|  const chartype *const srcinit = src;
   62|  1.93k|  const char *const dstinit = dst;
   63|  1.93k|  const chartype *const srcend = src + srclen;
   64|       |
   65|  1.93k|  constexpr size_t block_size = 6;
   66|  1.93k|  static_assert(block_size >= 2, "block_size must be at least two");
   67|  1.93k|  char buffer[block_size * 64];
   68|  1.93k|  char *bufferptr = buffer;
   69|       |  // A wide block store writes 4 bytes past its 48. That is safe when the next
   70|       |  // store starts 48 bytes later. Pairs of clean blocks wide-store the first
   71|       |  // and end the second on byte 48. Anything shorter, or a block that is not
   72|       |  // clean, uses the exact store. The pair attempt is only worth it on a long
   73|       |  // input: a short one often fails the first block and then repeats that work.
   74|  1.93k|  if (srclen >= 512) {
  ------------------
  |  Branch (74:7): [True: 970, False: 960]
  ------------------
   75|    970|    const chartype *const srcend128 = src + srclen - 128;
   76|  47.4k|    while (bufferptr == buffer && src <= srcend128) {
  ------------------
  |  Branch (76:12): [True: 47.4k, False: 0]
  |  Branch (76:35): [True: 47.4k, False: 20]
  ------------------
   77|  47.4k|      block64 b0(src);
   78|  47.4k|      uint64_t e0 = 0;
   79|  47.4k|      const uint64_t m0 =
   80|  47.4k|          b0.to_base64_mask<base64_url, ignore_garbage, default_or_url>(&e0);
   81|  47.4k|      if ((!ignore_garbage && e0) || m0 != 0) {
  ------------------
  |  Branch (81:12): [True: 47.4k, Folded]
  |  Branch (81:31): [True: 228, False: 47.1k]
  |  Branch (81:38): [True: 342, False: 46.8k]
  ------------------
   82|    570|        break;
   83|    570|      }
   84|  46.8k|      block64 b1(src + 64);
   85|  46.8k|      uint64_t e1 = 0;
   86|  46.8k|      const uint64_t m1 =
   87|  46.8k|          b1.to_base64_mask<base64_url, ignore_garbage, default_or_url>(&e1);
   88|  46.8k|      if ((!ignore_garbage && e1) || m1 != 0) {
  ------------------
  |  Branch (88:12): [True: 46.8k, Folded]
  |  Branch (88:31): [True: 208, False: 46.6k]
  |  Branch (88:38): [True: 172, False: 46.4k]
  ------------------
   89|    380|        break;
   90|    380|      }
   91|  46.4k|      b0.base64_decode_block(dst);
   92|  46.4k|      b1.template base64_decode_block<true>(dst + 48);
   93|  46.4k|      src += 128;
   94|  46.4k|      dst += 96;
   95|  46.4k|    }
   96|    970|  }
   97|  1.93k|  if (srclen >= 64) {
  ------------------
  |  Branch (97:7): [True: 1.66k, False: 268]
  ------------------
   98|  1.66k|    const chartype *const srcend64 = srcinit + srclen - 64;
   99|   207k|    while (src <= srcend64) {
  ------------------
  |  Branch (99:12): [True: 206k, False: 652]
  ------------------
  100|   206k|      block64 b(src);
  101|   206k|      uint64_t error = 0;
  102|   206k|      const uint64_t badcharmask =
  103|   206k|          b.to_base64_mask<base64_url, ignore_garbage, default_or_url>(&error);
  104|   206k|      if (!ignore_garbage && error) {
  ------------------
  |  Branch (104:11): [True: 206k, Folded]
  |  Branch (104:30): [True: 1.01k, False: 205k]
  ------------------
  105|  1.01k|        const size_t error_offset = trailing_zeroes(error);
  106|  1.01k|        return {error_code::INVALID_BASE64_CHARACTER,
  107|  1.01k|                size_t(src - srcinit + error_offset), size_t(dst - dstinit)};
  108|  1.01k|      }
  109|   205k|      src += 64;
  110|   205k|      if (badcharmask != 0) {
  ------------------
  |  Branch (110:11): [True: 48.8k, False: 157k]
  ------------------
  111|  48.8k|        bufferptr += b.compress_block(badcharmask, bufferptr);
  112|   157k|      } else if (bufferptr != buffer) {
  ------------------
  |  Branch (112:18): [True: 143k, False: 13.9k]
  ------------------
  113|   143k|        b.copy_block(bufferptr);
  114|   143k|        bufferptr += 64;
  115|   143k|      } else {
  116|  13.9k|        b.template base64_decode_block<true>(dst);
  117|  13.9k|        dst += 48;
  118|  13.9k|      }
  119|   205k|      if (bufferptr >= (block_size - 1) * 64 + buffer) {
  ------------------
  |  Branch (119:11): [True: 37.4k, False: 168k]
  ------------------
  120|   187k|        for (size_t i = 0; i < (block_size - 2); i++) {
  ------------------
  |  Branch (120:28): [True: 149k, False: 37.4k]
  ------------------
  121|   149k|          base64_decode_block(dst, buffer + i * 64);
  122|   149k|          dst += 48;
  123|   149k|        }
  124|  37.4k|        base64_decode_block<true>(dst, buffer + (block_size - 2) * 64);
  125|  37.4k|        dst += 48;
  126|  37.4k|        std::memcpy(buffer, buffer + (block_size - 1) * 64,
  127|  37.4k|                    64); // 64 might be too much
  128|  37.4k|        bufferptr -= (block_size - 1) * 64;
  129|  37.4k|      }
  130|   205k|    }
  131|  1.66k|  }
  132|       |
  133|    920|  char *buffer_start = buffer;
  134|       |  // Optimization note: if this is almost full, then it is worth our
  135|       |  // time, otherwise, we should just decode directly.
  136|    920|  int last_block = (int)((bufferptr - buffer_start) % 64);
  137|    920|  if (last_block != 0 && srcend - src + last_block >= 64) {
  ------------------
  |  Branch (137:7): [True: 592, False: 328]
  |  Branch (137:26): [True: 82, False: 510]
  ------------------
  138|       |
  139|  1.34k|    while ((bufferptr - buffer_start) % 64 != 0 && src < srcend) {
  ------------------
  |  Branch (139:12): [True: 1.29k, False: 54]
  |  Branch (139:52): [True: 1.27k, False: 20]
  ------------------
  140|  1.27k|      uint8_t val = to_base64[uint8_t(*src)];
  141|  1.27k|      *bufferptr = char(val);
  142|  1.27k|      if (!ignore_garbage &&
  ------------------
  |  Branch (142:11): [True: 1.27k, Folded]
  ------------------
  143|  1.27k|          (!scalar::base64::is_eight_byte(*src) || val > 64)) {
  ------------------
  |  Branch (143:12): [True: 0, False: 1.27k]
  |  Branch (143:52): [True: 8, False: 1.26k]
  ------------------
  144|      8|        return {error_code::INVALID_BASE64_CHARACTER, size_t(src - srcinit),
  145|      8|                size_t(dst - dstinit)};
  146|      8|      }
  147|  1.26k|      bufferptr += (val <= 63);
  148|  1.26k|      src++;
  149|  1.26k|    }
  150|     82|  }
  151|       |
  152|  1.43k|  for (; buffer_start + 64 <= bufferptr; buffer_start += 64) {
  ------------------
  |  Branch (152:10): [True: 520, False: 912]
  ------------------
  153|       |    // 8 payload bytes still in the buffer become 6 output bytes, which cover
  154|       |    // the 4-byte tail of a wide store. Fewer than that, and the tail can
  155|       |    // stick out past the real end.
  156|    520|    const size_t after = size_t(bufferptr - (buffer_start + 64));
  157|    520|    if (after >= 8) {
  ------------------
  |  Branch (157:9): [True: 442, False: 78]
  ------------------
  158|    442|      base64_decode_block(dst, buffer_start);
  159|    442|    } else {
  160|     78|      base64_decode_block<true>(dst, buffer_start);
  161|     78|    }
  162|    520|    dst += 48;
  163|    520|  }
  164|    912|  if ((bufferptr - buffer_start) % 64 != 0) {
  ------------------
  |  Branch (164:7): [True: 530, False: 382]
  ------------------
  165|  4.64k|    while (buffer_start + 4 < bufferptr) {
  ------------------
  |  Branch (165:12): [True: 4.11k, False: 530]
  ------------------
  166|  4.11k|      uint32_t triple = ((uint32_t(uint8_t(buffer_start[0])) << 3 * 6) +
  167|  4.11k|                         (uint32_t(uint8_t(buffer_start[1])) << 2 * 6) +
  168|  4.11k|                         (uint32_t(uint8_t(buffer_start[2])) << 1 * 6) +
  169|  4.11k|                         (uint32_t(uint8_t(buffer_start[3])) << 0 * 6))
  170|  4.11k|                        << 8;
  171|  4.11k|#if !SIMDUTF_IS_BIG_ENDIAN
  172|  4.11k|      triple = scalar::u32_swap_bytes(triple);
  173|  4.11k|#endif
  174|  4.11k|      std::memcpy(dst, &triple, 3);
  175|       |
  176|  4.11k|      dst += 3;
  177|  4.11k|      buffer_start += 4;
  178|  4.11k|    }
  179|    530|    if (buffer_start + 4 <= bufferptr) {
  ------------------
  |  Branch (179:9): [True: 146, False: 384]
  ------------------
  180|    146|      uint32_t triple = ((uint32_t(uint8_t(buffer_start[0])) << 3 * 6) +
  181|    146|                         (uint32_t(uint8_t(buffer_start[1])) << 2 * 6) +
  182|    146|                         (uint32_t(uint8_t(buffer_start[2])) << 1 * 6) +
  183|    146|                         (uint32_t(uint8_t(buffer_start[3])) << 0 * 6))
  184|    146|                        << 8;
  185|    146|#if !SIMDUTF_IS_BIG_ENDIAN
  186|    146|      triple = scalar::u32_swap_bytes(triple);
  187|    146|#endif
  188|    146|      std::memcpy(dst, &triple, 3);
  189|       |
  190|    146|      dst += 3;
  191|    146|      buffer_start += 4;
  192|    146|    }
  193|       |    // we may have 1, 2 or 3 bytes left and we need to decode them so let us
  194|       |    // backtrack
  195|    530|    int leftover = int(bufferptr - buffer_start);
  196|  1.31k|    while (leftover > 0) {
  ------------------
  |  Branch (196:12): [True: 786, False: 530]
  ------------------
  197|    786|      if (!ignore_garbage) {
  ------------------
  |  Branch (197:11): [True: 786, Folded]
  ------------------
  198|  5.39k|        while (to_base64[uint8_t(*(src - 1))] == 64) {
  ------------------
  |  Branch (198:16): [True: 4.61k, False: 786]
  ------------------
  199|  4.61k|          src--;
  200|  4.61k|        }
  201|    786|      } else {
  202|      0|        while (to_base64[uint8_t(*(src - 1))] >= 64) {
  ------------------
  |  Branch (202:16): [True: 0, False: 0]
  ------------------
  203|      0|          src--;
  204|      0|        }
  205|      0|      }
  206|    786|      src--;
  207|    786|      leftover--;
  208|    786|    }
  209|    530|  }
  210|    912|  if (src < srcend + equalsigns) {
  ------------------
  |  Branch (210:7): [True: 750, False: 162]
  ------------------
  211|    750|    full_result r = scalar::base64::base64_tail_decode(
  212|    750|        dst, src, srcend - src, equalsigns, options, last_chunk_options);
  213|    750|    r = scalar::base64::patch_tail_result(
  214|    750|        r, size_t(src - srcinit), size_t(dst - dstinit), equallocation,
  215|    750|        full_input_length, last_chunk_options);
  216|       |    // When is_partial(last_chunk_options) is true, we must either end with
  217|       |    // the end of the stream (beyond whitespace) or right after a non-ignorable
  218|       |    // character or at the very beginning of the stream.
  219|       |    // See https://tc39.es/proposal-arraybuffer-base64/spec/#sec-frombase64
  220|    750|    if (is_partial(last_chunk_options) && r.error == error_code::SUCCESS &&
  ------------------
  |  Branch (220:9): [True: 410, False: 340]
  |  Branch (220:43): [True: 384, False: 26]
  ------------------
  221|    384|        r.input_count < full_input_length) {
  ------------------
  |  Branch (221:9): [True: 318, False: 66]
  ------------------
  222|       |      // First check if we can extend the input to the end of the stream
  223|    592|      while (r.input_count < full_input_length &&
  ------------------
  |  Branch (223:14): [True: 584, False: 8]
  ------------------
  224|    584|             base64_ignorable(*(srcinit + r.input_count), options)) {
  ------------------
  |  Branch (224:14): [True: 274, False: 310]
  ------------------
  225|    274|        r.input_count++;
  226|    274|      }
  227|       |      // If we are still not at the end of the stream, then we must backtrack
  228|       |      // to the last non-ignorable character.
  229|    318|      if (r.input_count < full_input_length) {
  ------------------
  |  Branch (229:11): [True: 310, False: 8]
  ------------------
  230|  3.06k|        while (r.input_count > 0 &&
  ------------------
  |  Branch (230:16): [True: 3.01k, False: 48]
  ------------------
  231|  3.01k|               base64_ignorable(*(srcinit + r.input_count - 1), options)) {
  ------------------
  |  Branch (231:16): [True: 2.75k, False: 262]
  ------------------
  232|  2.75k|          r.input_count--;
  233|  2.75k|        }
  234|    310|      }
  235|    318|    }
  236|    750|    return r;
  237|    750|  }
  238|    162|  if (!ignore_garbage && equalsigns > 0) {
  ------------------
  |  Branch (238:7): [True: 162, Folded]
  |  Branch (238:26): [True: 0, False: 162]
  ------------------
  239|      0|    if ((size_t(dst - dstinit) % 3 == 0) ||
  ------------------
  |  Branch (239:9): [True: 0, False: 0]
  ------------------
  240|      0|        ((size_t(dst - dstinit) % 3) + 1 + equalsigns != 4)) {
  ------------------
  |  Branch (240:9): [True: 0, False: 0]
  ------------------
  241|      0|      return {INVALID_BASE64_CHARACTER, equallocation, size_t(dst - dstinit),
  242|      0|              true};
  243|      0|    }
  244|      0|  }
  245|    162|  return {SUCCESS, srclen, size_t(dst - dstinit)};
  246|    162|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_16base6422compress_decode_base64ILb1ELb0ELb0EDsEENS_11full_resultEPcPKT2_mNS_14base64_optionsENS_27last_chunk_handling_optionsE:
   45|  1.88k|                       last_chunk_handling_options last_chunk_options) {
   46|  1.88k|  const uint8_t *to_base64 =
   47|  1.88k|      default_or_url ? tables::base64::to_base64_default_or_url_value
  ------------------
  |  Branch (47:7): [Folded, False: 1.88k]
  ------------------
   48|  1.88k|                     : (base64_url ? tables::base64::to_base64_url_value
  ------------------
  |  Branch (48:25): [True: 1.88k, Folded]
  ------------------
   49|  1.88k|                                   : tables::base64::to_base64_value);
   50|  1.88k|  auto ri = simdutf::scalar::base64::find_end(src, srclen, options);
   51|  1.88k|  size_t equallocation = ri.equallocation;
   52|  1.88k|  size_t equalsigns = ri.equalsigns;
   53|  1.88k|  srclen = ri.srclen;
   54|  1.88k|  size_t full_input_length = ri.full_input_length;
   55|  1.88k|  if (srclen == 0) {
  ------------------
  |  Branch (55:7): [True: 22, False: 1.86k]
  ------------------
   56|     22|    if (!ignore_garbage && equalsigns > 0) {
  ------------------
  |  Branch (56:9): [True: 22, Folded]
  |  Branch (56:28): [True: 10, False: 12]
  ------------------
   57|     10|      return {INVALID_BASE64_CHARACTER, equallocation, 0, true};
   58|     10|    }
   59|     12|    return {SUCCESS, full_input_length, 0};
   60|     22|  }
   61|  1.86k|  const chartype *const srcinit = src;
   62|  1.86k|  const char *const dstinit = dst;
   63|  1.86k|  const chartype *const srcend = src + srclen;
   64|       |
   65|  1.86k|  constexpr size_t block_size = 6;
   66|  1.86k|  static_assert(block_size >= 2, "block_size must be at least two");
   67|  1.86k|  char buffer[block_size * 64];
   68|  1.86k|  char *bufferptr = buffer;
   69|       |  // A wide block store writes 4 bytes past its 48. That is safe when the next
   70|       |  // store starts 48 bytes later. Pairs of clean blocks wide-store the first
   71|       |  // and end the second on byte 48. Anything shorter, or a block that is not
   72|       |  // clean, uses the exact store. The pair attempt is only worth it on a long
   73|       |  // input: a short one often fails the first block and then repeats that work.
   74|  1.86k|  if (srclen >= 512) {
  ------------------
  |  Branch (74:7): [True: 928, False: 938]
  ------------------
   75|    928|    const chartype *const srcend128 = src + srclen - 128;
   76|  1.30k|    while (bufferptr == buffer && src <= srcend128) {
  ------------------
  |  Branch (76:12): [True: 1.30k, False: 0]
  |  Branch (76:35): [True: 1.29k, False: 10]
  ------------------
   77|  1.29k|      block64 b0(src);
   78|  1.29k|      uint64_t e0 = 0;
   79|  1.29k|      const uint64_t m0 =
   80|  1.29k|          b0.to_base64_mask<base64_url, ignore_garbage, default_or_url>(&e0);
   81|  1.29k|      if ((!ignore_garbage && e0) || m0 != 0) {
  ------------------
  |  Branch (81:12): [True: 1.29k, Folded]
  |  Branch (81:31): [True: 226, False: 1.06k]
  |  Branch (81:38): [True: 332, False: 736]
  ------------------
   82|    558|        break;
   83|    558|      }
   84|    736|      block64 b1(src + 64);
   85|    736|      uint64_t e1 = 0;
   86|    736|      const uint64_t m1 =
   87|    736|          b1.to_base64_mask<base64_url, ignore_garbage, default_or_url>(&e1);
   88|    736|      if ((!ignore_garbage && e1) || m1 != 0) {
  ------------------
  |  Branch (88:12): [True: 736, Folded]
  |  Branch (88:31): [True: 180, False: 556]
  |  Branch (88:38): [True: 180, False: 376]
  ------------------
   89|    360|        break;
   90|    360|      }
   91|    376|      b0.base64_decode_block(dst);
   92|    376|      b1.template base64_decode_block<true>(dst + 48);
   93|    376|      src += 128;
   94|    376|      dst += 96;
   95|    376|    }
   96|    928|  }
   97|  1.86k|  if (srclen >= 64) {
  ------------------
  |  Branch (97:7): [True: 1.59k, False: 274]
  ------------------
   98|  1.59k|    const chartype *const srcend64 = srcinit + srclen - 64;
   99|  54.5k|    while (src <= srcend64) {
  ------------------
  |  Branch (99:12): [True: 54.0k, False: 572]
  ------------------
  100|  54.0k|      block64 b(src);
  101|  54.0k|      uint64_t error = 0;
  102|  54.0k|      const uint64_t badcharmask =
  103|  54.0k|          b.to_base64_mask<base64_url, ignore_garbage, default_or_url>(&error);
  104|  54.0k|      if (!ignore_garbage && error) {
  ------------------
  |  Branch (104:11): [True: 54.0k, Folded]
  |  Branch (104:30): [True: 1.02k, False: 52.9k]
  ------------------
  105|  1.02k|        const size_t error_offset = trailing_zeroes(error);
  106|  1.02k|        return {error_code::INVALID_BASE64_CHARACTER,
  107|  1.02k|                size_t(src - srcinit + error_offset), size_t(dst - dstinit)};
  108|  1.02k|      }
  109|  52.9k|      src += 64;
  110|  52.9k|      if (badcharmask != 0) {
  ------------------
  |  Branch (110:11): [True: 43.8k, False: 9.11k]
  ------------------
  111|  43.8k|        bufferptr += b.compress_block(badcharmask, bufferptr);
  112|  43.8k|      } else if (bufferptr != buffer) {
  ------------------
  |  Branch (112:18): [True: 8.52k, False: 584]
  ------------------
  113|  8.52k|        b.copy_block(bufferptr);
  114|  8.52k|        bufferptr += 64;
  115|  8.52k|      } else {
  116|    584|        b.template base64_decode_block<true>(dst);
  117|    584|        dst += 48;
  118|    584|      }
  119|  52.9k|      if (bufferptr >= (block_size - 1) * 64 + buffer) {
  ------------------
  |  Branch (119:11): [True: 9.97k, False: 43.0k]
  ------------------
  120|  49.8k|        for (size_t i = 0; i < (block_size - 2); i++) {
  ------------------
  |  Branch (120:28): [True: 39.8k, False: 9.97k]
  ------------------
  121|  39.8k|          base64_decode_block(dst, buffer + i * 64);
  122|  39.8k|          dst += 48;
  123|  39.8k|        }
  124|  9.97k|        base64_decode_block<true>(dst, buffer + (block_size - 2) * 64);
  125|  9.97k|        dst += 48;
  126|  9.97k|        std::memcpy(buffer, buffer + (block_size - 1) * 64,
  127|  9.97k|                    64); // 64 might be too much
  128|  9.97k|        bufferptr -= (block_size - 1) * 64;
  129|  9.97k|      }
  130|  52.9k|    }
  131|  1.59k|  }
  132|       |
  133|    846|  char *buffer_start = buffer;
  134|       |  // Optimization note: if this is almost full, then it is worth our
  135|       |  // time, otherwise, we should just decode directly.
  136|    846|  int last_block = (int)((bufferptr - buffer_start) % 64);
  137|    846|  if (last_block != 0 && srcend - src + last_block >= 64) {
  ------------------
  |  Branch (137:7): [True: 532, False: 314]
  |  Branch (137:26): [True: 86, False: 446]
  ------------------
  138|       |
  139|    560|    while ((bufferptr - buffer_start) % 64 != 0 && src < srcend) {
  ------------------
  |  Branch (139:12): [True: 528, False: 32]
  |  Branch (139:52): [True: 512, False: 16]
  ------------------
  140|    512|      uint8_t val = to_base64[uint8_t(*src)];
  141|    512|      *bufferptr = char(val);
  142|    512|      if (!ignore_garbage &&
  ------------------
  |  Branch (142:11): [True: 512, Folded]
  ------------------
  143|    512|          (!scalar::base64::is_eight_byte(*src) || val > 64)) {
  ------------------
  |  Branch (143:12): [True: 18, False: 494]
  |  Branch (143:52): [True: 20, False: 474]
  ------------------
  144|     38|        return {error_code::INVALID_BASE64_CHARACTER, size_t(src - srcinit),
  145|     38|                size_t(dst - dstinit)};
  146|     38|      }
  147|    474|      bufferptr += (val <= 63);
  148|    474|      src++;
  149|    474|    }
  150|     86|  }
  151|       |
  152|  1.13k|  for (; buffer_start + 64 <= bufferptr; buffer_start += 64) {
  ------------------
  |  Branch (152:10): [True: 326, False: 808]
  ------------------
  153|       |    // 8 payload bytes still in the buffer become 6 output bytes, which cover
  154|       |    // the 4-byte tail of a wide store. Fewer than that, and the tail can
  155|       |    // stick out past the real end.
  156|    326|    const size_t after = size_t(bufferptr - (buffer_start + 64));
  157|    326|    if (after >= 8) {
  ------------------
  |  Branch (157:9): [True: 272, False: 54]
  ------------------
  158|    272|      base64_decode_block(dst, buffer_start);
  159|    272|    } else {
  160|     54|      base64_decode_block<true>(dst, buffer_start);
  161|     54|    }
  162|    326|    dst += 48;
  163|    326|  }
  164|    808|  if ((bufferptr - buffer_start) % 64 != 0) {
  ------------------
  |  Branch (164:7): [True: 462, False: 346]
  ------------------
  165|  3.89k|    while (buffer_start + 4 < bufferptr) {
  ------------------
  |  Branch (165:12): [True: 3.43k, False: 462]
  ------------------
  166|  3.43k|      uint32_t triple = ((uint32_t(uint8_t(buffer_start[0])) << 3 * 6) +
  167|  3.43k|                         (uint32_t(uint8_t(buffer_start[1])) << 2 * 6) +
  168|  3.43k|                         (uint32_t(uint8_t(buffer_start[2])) << 1 * 6) +
  169|  3.43k|                         (uint32_t(uint8_t(buffer_start[3])) << 0 * 6))
  170|  3.43k|                        << 8;
  171|  3.43k|#if !SIMDUTF_IS_BIG_ENDIAN
  172|  3.43k|      triple = scalar::u32_swap_bytes(triple);
  173|  3.43k|#endif
  174|  3.43k|      std::memcpy(dst, &triple, 3);
  175|       |
  176|  3.43k|      dst += 3;
  177|  3.43k|      buffer_start += 4;
  178|  3.43k|    }
  179|    462|    if (buffer_start + 4 <= bufferptr) {
  ------------------
  |  Branch (179:9): [True: 94, False: 368]
  ------------------
  180|     94|      uint32_t triple = ((uint32_t(uint8_t(buffer_start[0])) << 3 * 6) +
  181|     94|                         (uint32_t(uint8_t(buffer_start[1])) << 2 * 6) +
  182|     94|                         (uint32_t(uint8_t(buffer_start[2])) << 1 * 6) +
  183|     94|                         (uint32_t(uint8_t(buffer_start[3])) << 0 * 6))
  184|     94|                        << 8;
  185|     94|#if !SIMDUTF_IS_BIG_ENDIAN
  186|     94|      triple = scalar::u32_swap_bytes(triple);
  187|     94|#endif
  188|     94|      std::memcpy(dst, &triple, 3);
  189|       |
  190|     94|      dst += 3;
  191|     94|      buffer_start += 4;
  192|     94|    }
  193|       |    // we may have 1, 2 or 3 bytes left and we need to decode them so let us
  194|       |    // backtrack
  195|    462|    int leftover = int(bufferptr - buffer_start);
  196|  1.21k|    while (leftover > 0) {
  ------------------
  |  Branch (196:12): [True: 750, False: 462]
  ------------------
  197|    750|      if (!ignore_garbage) {
  ------------------
  |  Branch (197:11): [True: 750, Folded]
  ------------------
  198|  7.06k|        while (to_base64[uint8_t(*(src - 1))] == 64) {
  ------------------
  |  Branch (198:16): [True: 6.31k, False: 750]
  ------------------
  199|  6.31k|          src--;
  200|  6.31k|        }
  201|    750|      } else {
  202|      0|        while (to_base64[uint8_t(*(src - 1))] >= 64) {
  ------------------
  |  Branch (202:16): [True: 0, False: 0]
  ------------------
  203|      0|          src--;
  204|      0|        }
  205|      0|      }
  206|    750|      src--;
  207|    750|      leftover--;
  208|    750|    }
  209|    462|  }
  210|    808|  if (src < srcend + equalsigns) {
  ------------------
  |  Branch (210:7): [True: 690, False: 118]
  ------------------
  211|    690|    full_result r = scalar::base64::base64_tail_decode(
  212|    690|        dst, src, srcend - src, equalsigns, options, last_chunk_options);
  213|    690|    r = scalar::base64::patch_tail_result(
  214|    690|        r, size_t(src - srcinit), size_t(dst - dstinit), equallocation,
  215|    690|        full_input_length, last_chunk_options);
  216|       |    // When is_partial(last_chunk_options) is true, we must either end with
  217|       |    // the end of the stream (beyond whitespace) or right after a non-ignorable
  218|       |    // character or at the very beginning of the stream.
  219|       |    // See https://tc39.es/proposal-arraybuffer-base64/spec/#sec-frombase64
  220|    690|    if (is_partial(last_chunk_options) && r.error == error_code::SUCCESS &&
  ------------------
  |  Branch (220:9): [True: 398, False: 292]
  |  Branch (220:43): [True: 324, False: 74]
  ------------------
  221|    324|        r.input_count < full_input_length) {
  ------------------
  |  Branch (221:9): [True: 290, False: 34]
  ------------------
  222|       |      // First check if we can extend the input to the end of the stream
  223|    702|      while (r.input_count < full_input_length &&
  ------------------
  |  Branch (223:14): [True: 698, False: 4]
  ------------------
  224|    698|             base64_ignorable(*(srcinit + r.input_count), options)) {
  ------------------
  |  Branch (224:14): [True: 412, False: 286]
  ------------------
  225|    412|        r.input_count++;
  226|    412|      }
  227|       |      // If we are still not at the end of the stream, then we must backtrack
  228|       |      // to the last non-ignorable character.
  229|    290|      if (r.input_count < full_input_length) {
  ------------------
  |  Branch (229:11): [True: 286, False: 4]
  ------------------
  230|  2.08k|        while (r.input_count > 0 &&
  ------------------
  |  Branch (230:16): [True: 2.00k, False: 78]
  ------------------
  231|  2.00k|               base64_ignorable(*(srcinit + r.input_count - 1), options)) {
  ------------------
  |  Branch (231:16): [True: 1.79k, False: 208]
  ------------------
  232|  1.79k|          r.input_count--;
  233|  1.79k|        }
  234|    286|      }
  235|    290|    }
  236|    690|    return r;
  237|    690|  }
  238|    118|  if (!ignore_garbage && equalsigns > 0) {
  ------------------
  |  Branch (238:7): [True: 118, Folded]
  |  Branch (238:26): [True: 0, False: 118]
  ------------------
  239|      0|    if ((size_t(dst - dstinit) % 3 == 0) ||
  ------------------
  |  Branch (239:9): [True: 0, False: 0]
  ------------------
  240|      0|        ((size_t(dst - dstinit) % 3) + 1 + equalsigns != 4)) {
  ------------------
  |  Branch (240:9): [True: 0, False: 0]
  ------------------
  241|      0|      return {INVALID_BASE64_CHARACTER, equallocation, size_t(dst - dstinit),
  242|      0|              true};
  243|      0|    }
  244|      0|  }
  245|    118|  return {SUCCESS, srclen, size_t(dst - dstinit)};
  246|    118|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_16base6422compress_decode_base64ILb0ELb0ELb0EDsEENS_11full_resultEPcPKT2_mNS_14base64_optionsENS_27last_chunk_handling_optionsE:
   45|  1.91k|                       last_chunk_handling_options last_chunk_options) {
   46|  1.91k|  const uint8_t *to_base64 =
   47|  1.91k|      default_or_url ? tables::base64::to_base64_default_or_url_value
  ------------------
  |  Branch (47:7): [Folded, False: 1.91k]
  ------------------
   48|  1.91k|                     : (base64_url ? tables::base64::to_base64_url_value
  ------------------
  |  Branch (48:25): [Folded, False: 1.91k]
  ------------------
   49|  1.91k|                                   : tables::base64::to_base64_value);
   50|  1.91k|  auto ri = simdutf::scalar::base64::find_end(src, srclen, options);
   51|  1.91k|  size_t equallocation = ri.equallocation;
   52|  1.91k|  size_t equalsigns = ri.equalsigns;
   53|  1.91k|  srclen = ri.srclen;
   54|  1.91k|  size_t full_input_length = ri.full_input_length;
   55|  1.91k|  if (srclen == 0) {
  ------------------
  |  Branch (55:7): [True: 16, False: 1.89k]
  ------------------
   56|     16|    if (!ignore_garbage && equalsigns > 0) {
  ------------------
  |  Branch (56:9): [True: 16, Folded]
  |  Branch (56:28): [True: 8, False: 8]
  ------------------
   57|      8|      return {INVALID_BASE64_CHARACTER, equallocation, 0, true};
   58|      8|    }
   59|      8|    return {SUCCESS, full_input_length, 0};
   60|     16|  }
   61|  1.89k|  const chartype *const srcinit = src;
   62|  1.89k|  const char *const dstinit = dst;
   63|  1.89k|  const chartype *const srcend = src + srclen;
   64|       |
   65|  1.89k|  constexpr size_t block_size = 6;
   66|  1.89k|  static_assert(block_size >= 2, "block_size must be at least two");
   67|  1.89k|  char buffer[block_size * 64];
   68|  1.89k|  char *bufferptr = buffer;
   69|       |  // A wide block store writes 4 bytes past its 48. That is safe when the next
   70|       |  // store starts 48 bytes later. Pairs of clean blocks wide-store the first
   71|       |  // and end the second on byte 48. Anything shorter, or a block that is not
   72|       |  // clean, uses the exact store. The pair attempt is only worth it on a long
   73|       |  // input: a short one often fails the first block and then repeats that work.
   74|  1.89k|  if (srclen >= 512) {
  ------------------
  |  Branch (74:7): [True: 894, False: 1.00k]
  ------------------
   75|    894|    const chartype *const srcend128 = src + srclen - 128;
   76|  1.25k|    while (bufferptr == buffer && src <= srcend128) {
  ------------------
  |  Branch (76:12): [True: 1.25k, False: 0]
  |  Branch (76:35): [True: 1.24k, False: 8]
  ------------------
   77|  1.24k|      block64 b0(src);
   78|  1.24k|      uint64_t e0 = 0;
   79|  1.24k|      const uint64_t m0 =
   80|  1.24k|          b0.to_base64_mask<base64_url, ignore_garbage, default_or_url>(&e0);
   81|  1.24k|      if ((!ignore_garbage && e0) || m0 != 0) {
  ------------------
  |  Branch (81:12): [True: 1.24k, Folded]
  |  Branch (81:31): [True: 226, False: 1.01k]
  |  Branch (81:38): [True: 294, False: 722]
  ------------------
   82|    520|        break;
   83|    520|      }
   84|    722|      block64 b1(src + 64);
   85|    722|      uint64_t e1 = 0;
   86|    722|      const uint64_t m1 =
   87|    722|          b1.to_base64_mask<base64_url, ignore_garbage, default_or_url>(&e1);
   88|    722|      if ((!ignore_garbage && e1) || m1 != 0) {
  ------------------
  |  Branch (88:12): [True: 722, Folded]
  |  Branch (88:31): [True: 184, False: 538]
  |  Branch (88:38): [True: 182, False: 356]
  ------------------
   89|    366|        break;
   90|    366|      }
   91|    356|      b0.base64_decode_block(dst);
   92|    356|      b1.template base64_decode_block<true>(dst + 48);
   93|    356|      src += 128;
   94|    356|      dst += 96;
   95|    356|    }
   96|    894|  }
   97|  1.89k|  if (srclen >= 64) {
  ------------------
  |  Branch (97:7): [True: 1.59k, False: 302]
  ------------------
   98|  1.59k|    const chartype *const srcend64 = srcinit + srclen - 64;
   99|  58.9k|    while (src <= srcend64) {
  ------------------
  |  Branch (99:12): [True: 58.3k, False: 600]
  ------------------
  100|  58.3k|      block64 b(src);
  101|  58.3k|      uint64_t error = 0;
  102|  58.3k|      const uint64_t badcharmask =
  103|  58.3k|          b.to_base64_mask<base64_url, ignore_garbage, default_or_url>(&error);
  104|  58.3k|      if (!ignore_garbage && error) {
  ------------------
  |  Branch (104:11): [True: 58.3k, Folded]
  |  Branch (104:30): [True: 994, False: 57.3k]
  ------------------
  105|    994|        const size_t error_offset = trailing_zeroes(error);
  106|    994|        return {error_code::INVALID_BASE64_CHARACTER,
  107|    994|                size_t(src - srcinit + error_offset), size_t(dst - dstinit)};
  108|    994|      }
  109|  57.3k|      src += 64;
  110|  57.3k|      if (badcharmask != 0) {
  ------------------
  |  Branch (110:11): [True: 45.0k, False: 12.3k]
  ------------------
  111|  45.0k|        bufferptr += b.compress_block(badcharmask, bufferptr);
  112|  45.0k|      } else if (bufferptr != buffer) {
  ------------------
  |  Branch (112:18): [True: 11.8k, False: 580]
  ------------------
  113|  11.8k|        b.copy_block(bufferptr);
  114|  11.8k|        bufferptr += 64;
  115|  11.8k|      } else {
  116|    580|        b.template base64_decode_block<true>(dst);
  117|    580|        dst += 48;
  118|    580|      }
  119|  57.3k|      if (bufferptr >= (block_size - 1) * 64 + buffer) {
  ------------------
  |  Branch (119:11): [True: 10.8k, False: 46.5k]
  ------------------
  120|  54.4k|        for (size_t i = 0; i < (block_size - 2); i++) {
  ------------------
  |  Branch (120:28): [True: 43.5k, False: 10.8k]
  ------------------
  121|  43.5k|          base64_decode_block(dst, buffer + i * 64);
  122|  43.5k|          dst += 48;
  123|  43.5k|        }
  124|  10.8k|        base64_decode_block<true>(dst, buffer + (block_size - 2) * 64);
  125|  10.8k|        dst += 48;
  126|  10.8k|        std::memcpy(buffer, buffer + (block_size - 1) * 64,
  127|  10.8k|                    64); // 64 might be too much
  128|  10.8k|        bufferptr -= (block_size - 1) * 64;
  129|  10.8k|      }
  130|  57.3k|    }
  131|  1.59k|  }
  132|       |
  133|    902|  char *buffer_start = buffer;
  134|       |  // Optimization note: if this is almost full, then it is worth our
  135|       |  // time, otherwise, we should just decode directly.
  136|    902|  int last_block = (int)((bufferptr - buffer_start) % 64);
  137|    902|  if (last_block != 0 && srcend - src + last_block >= 64) {
  ------------------
  |  Branch (137:7): [True: 564, False: 338]
  |  Branch (137:26): [True: 106, False: 458]
  ------------------
  138|       |
  139|    712|    while ((bufferptr - buffer_start) % 64 != 0 && src < srcend) {
  ------------------
  |  Branch (139:12): [True: 670, False: 42]
  |  Branch (139:52): [True: 656, False: 14]
  ------------------
  140|    656|      uint8_t val = to_base64[uint8_t(*src)];
  141|    656|      *bufferptr = char(val);
  142|    656|      if (!ignore_garbage &&
  ------------------
  |  Branch (142:11): [True: 656, Folded]
  ------------------
  143|    656|          (!scalar::base64::is_eight_byte(*src) || val > 64)) {
  ------------------
  |  Branch (143:12): [True: 28, False: 628]
  |  Branch (143:52): [True: 22, False: 606]
  ------------------
  144|     50|        return {error_code::INVALID_BASE64_CHARACTER, size_t(src - srcinit),
  145|     50|                size_t(dst - dstinit)};
  146|     50|      }
  147|    606|      bufferptr += (val <= 63);
  148|    606|      src++;
  149|    606|    }
  150|    106|  }
  151|       |
  152|  1.22k|  for (; buffer_start + 64 <= bufferptr; buffer_start += 64) {
  ------------------
  |  Branch (152:10): [True: 372, False: 852]
  ------------------
  153|       |    // 8 payload bytes still in the buffer become 6 output bytes, which cover
  154|       |    // the 4-byte tail of a wide store. Fewer than that, and the tail can
  155|       |    // stick out past the real end.
  156|    372|    const size_t after = size_t(bufferptr - (buffer_start + 64));
  157|    372|    if (after >= 8) {
  ------------------
  |  Branch (157:9): [True: 312, False: 60]
  ------------------
  158|    312|      base64_decode_block(dst, buffer_start);
  159|    312|    } else {
  160|     60|      base64_decode_block<true>(dst, buffer_start);
  161|     60|    }
  162|    372|    dst += 48;
  163|    372|  }
  164|    852|  if ((bufferptr - buffer_start) % 64 != 0) {
  ------------------
  |  Branch (164:7): [True: 472, False: 380]
  ------------------
  165|  3.91k|    while (buffer_start + 4 < bufferptr) {
  ------------------
  |  Branch (165:12): [True: 3.44k, False: 472]
  ------------------
  166|  3.44k|      uint32_t triple = ((uint32_t(uint8_t(buffer_start[0])) << 3 * 6) +
  167|  3.44k|                         (uint32_t(uint8_t(buffer_start[1])) << 2 * 6) +
  168|  3.44k|                         (uint32_t(uint8_t(buffer_start[2])) << 1 * 6) +
  169|  3.44k|                         (uint32_t(uint8_t(buffer_start[3])) << 0 * 6))
  170|  3.44k|                        << 8;
  171|  3.44k|#if !SIMDUTF_IS_BIG_ENDIAN
  172|  3.44k|      triple = scalar::u32_swap_bytes(triple);
  173|  3.44k|#endif
  174|  3.44k|      std::memcpy(dst, &triple, 3);
  175|       |
  176|  3.44k|      dst += 3;
  177|  3.44k|      buffer_start += 4;
  178|  3.44k|    }
  179|    472|    if (buffer_start + 4 <= bufferptr) {
  ------------------
  |  Branch (179:9): [True: 120, False: 352]
  ------------------
  180|    120|      uint32_t triple = ((uint32_t(uint8_t(buffer_start[0])) << 3 * 6) +
  181|    120|                         (uint32_t(uint8_t(buffer_start[1])) << 2 * 6) +
  182|    120|                         (uint32_t(uint8_t(buffer_start[2])) << 1 * 6) +
  183|    120|                         (uint32_t(uint8_t(buffer_start[3])) << 0 * 6))
  184|    120|                        << 8;
  185|    120|#if !SIMDUTF_IS_BIG_ENDIAN
  186|    120|      triple = scalar::u32_swap_bytes(triple);
  187|    120|#endif
  188|    120|      std::memcpy(dst, &triple, 3);
  189|       |
  190|    120|      dst += 3;
  191|    120|      buffer_start += 4;
  192|    120|    }
  193|       |    // we may have 1, 2 or 3 bytes left and we need to decode them so let us
  194|       |    // backtrack
  195|    472|    int leftover = int(bufferptr - buffer_start);
  196|  1.19k|    while (leftover > 0) {
  ------------------
  |  Branch (196:12): [True: 722, False: 472]
  ------------------
  197|    722|      if (!ignore_garbage) {
  ------------------
  |  Branch (197:11): [True: 722, Folded]
  ------------------
  198|  6.57k|        while (to_base64[uint8_t(*(src - 1))] == 64) {
  ------------------
  |  Branch (198:16): [True: 5.85k, False: 722]
  ------------------
  199|  5.85k|          src--;
  200|  5.85k|        }
  201|    722|      } else {
  202|      0|        while (to_base64[uint8_t(*(src - 1))] >= 64) {
  ------------------
  |  Branch (202:16): [True: 0, False: 0]
  ------------------
  203|      0|          src--;
  204|      0|        }
  205|      0|      }
  206|    722|      src--;
  207|    722|      leftover--;
  208|    722|    }
  209|    472|  }
  210|    852|  if (src < srcend + equalsigns) {
  ------------------
  |  Branch (210:7): [True: 702, False: 150]
  ------------------
  211|    702|    full_result r = scalar::base64::base64_tail_decode(
  212|    702|        dst, src, srcend - src, equalsigns, options, last_chunk_options);
  213|    702|    r = scalar::base64::patch_tail_result(
  214|    702|        r, size_t(src - srcinit), size_t(dst - dstinit), equallocation,
  215|    702|        full_input_length, last_chunk_options);
  216|       |    // When is_partial(last_chunk_options) is true, we must either end with
  217|       |    // the end of the stream (beyond whitespace) or right after a non-ignorable
  218|       |    // character or at the very beginning of the stream.
  219|       |    // See https://tc39.es/proposal-arraybuffer-base64/spec/#sec-frombase64
  220|    702|    if (is_partial(last_chunk_options) && r.error == error_code::SUCCESS &&
  ------------------
  |  Branch (220:9): [True: 366, False: 336]
  |  Branch (220:43): [True: 288, False: 78]
  ------------------
  221|    288|        r.input_count < full_input_length) {
  ------------------
  |  Branch (221:9): [True: 260, False: 28]
  ------------------
  222|       |      // First check if we can extend the input to the end of the stream
  223|    560|      while (r.input_count < full_input_length &&
  ------------------
  |  Branch (223:14): [True: 556, False: 4]
  ------------------
  224|    556|             base64_ignorable(*(srcinit + r.input_count), options)) {
  ------------------
  |  Branch (224:14): [True: 300, False: 256]
  ------------------
  225|    300|        r.input_count++;
  226|    300|      }
  227|       |      // If we are still not at the end of the stream, then we must backtrack
  228|       |      // to the last non-ignorable character.
  229|    260|      if (r.input_count < full_input_length) {
  ------------------
  |  Branch (229:11): [True: 256, False: 4]
  ------------------
  230|  4.90k|        while (r.input_count > 0 &&
  ------------------
  |  Branch (230:16): [True: 4.84k, False: 66]
  ------------------
  231|  4.84k|               base64_ignorable(*(srcinit + r.input_count - 1), options)) {
  ------------------
  |  Branch (231:16): [True: 4.65k, False: 190]
  ------------------
  232|  4.65k|          r.input_count--;
  233|  4.65k|        }
  234|    256|      }
  235|    260|    }
  236|    702|    return r;
  237|    702|  }
  238|    150|  if (!ignore_garbage && equalsigns > 0) {
  ------------------
  |  Branch (238:7): [True: 150, Folded]
  |  Branch (238:26): [True: 0, False: 150]
  ------------------
  239|      0|    if ((size_t(dst - dstinit) % 3 == 0) ||
  ------------------
  |  Branch (239:9): [True: 0, False: 0]
  ------------------
  240|      0|        ((size_t(dst - dstinit) % 3) + 1 + equalsigns != 4)) {
  ------------------
  |  Branch (240:9): [True: 0, False: 0]
  ------------------
  241|      0|      return {INVALID_BASE64_CHARACTER, equallocation, size_t(dst - dstinit),
  242|      0|              true};
  243|      0|    }
  244|      0|  }
  245|    150|  return {SUCCESS, srclen, size_t(dst - dstinit)};
  246|    150|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_16base6422compress_decode_base64ILb1ELb0ELb0EcEENS_11full_resultEPcPKT2_mNS_14base64_optionsENS_27last_chunk_handling_optionsE:
   45|  1.83k|                       last_chunk_handling_options last_chunk_options) {
   46|  1.83k|  const uint8_t *to_base64 =
   47|  1.83k|      default_or_url ? tables::base64::to_base64_default_or_url_value
  ------------------
  |  Branch (47:7): [Folded, False: 1.83k]
  ------------------
   48|  1.83k|                     : (base64_url ? tables::base64::to_base64_url_value
  ------------------
  |  Branch (48:25): [True: 1.83k, Folded]
  ------------------
   49|  1.83k|                                   : tables::base64::to_base64_value);
   50|  1.83k|  auto ri = simdutf::scalar::base64::find_end(src, srclen, options);
   51|  1.83k|  size_t equallocation = ri.equallocation;
   52|  1.83k|  size_t equalsigns = ri.equalsigns;
   53|  1.83k|  srclen = ri.srclen;
   54|  1.83k|  size_t full_input_length = ri.full_input_length;
   55|  1.83k|  if (srclen == 0) {
  ------------------
  |  Branch (55:7): [True: 20, False: 1.81k]
  ------------------
   56|     20|    if (!ignore_garbage && equalsigns > 0) {
  ------------------
  |  Branch (56:9): [True: 20, Folded]
  |  Branch (56:28): [True: 8, False: 12]
  ------------------
   57|      8|      return {INVALID_BASE64_CHARACTER, equallocation, 0, true};
   58|      8|    }
   59|     12|    return {SUCCESS, full_input_length, 0};
   60|     20|  }
   61|  1.81k|  const chartype *const srcinit = src;
   62|  1.81k|  const char *const dstinit = dst;
   63|  1.81k|  const chartype *const srcend = src + srclen;
   64|       |
   65|  1.81k|  constexpr size_t block_size = 6;
   66|  1.81k|  static_assert(block_size >= 2, "block_size must be at least two");
   67|  1.81k|  char buffer[block_size * 64];
   68|  1.81k|  char *bufferptr = buffer;
   69|       |  // A wide block store writes 4 bytes past its 48. That is safe when the next
   70|       |  // store starts 48 bytes later. Pairs of clean blocks wide-store the first
   71|       |  // and end the second on byte 48. Anything shorter, or a block that is not
   72|       |  // clean, uses the exact store. The pair attempt is only worth it on a long
   73|       |  // input: a short one often fails the first block and then repeats that work.
   74|  1.81k|  if (srclen >= 512) {
  ------------------
  |  Branch (74:7): [True: 912, False: 902]
  ------------------
   75|    912|    const chartype *const srcend128 = src + srclen - 128;
   76|  21.9k|    while (bufferptr == buffer && src <= srcend128) {
  ------------------
  |  Branch (76:12): [True: 21.9k, False: 0]
  |  Branch (76:35): [True: 21.9k, False: 12]
  ------------------
   77|  21.9k|      block64 b0(src);
   78|  21.9k|      uint64_t e0 = 0;
   79|  21.9k|      const uint64_t m0 =
   80|  21.9k|          b0.to_base64_mask<base64_url, ignore_garbage, default_or_url>(&e0);
   81|  21.9k|      if ((!ignore_garbage && e0) || m0 != 0) {
  ------------------
  |  Branch (81:12): [True: 21.9k, Folded]
  |  Branch (81:31): [True: 218, False: 21.7k]
  |  Branch (81:38): [True: 316, False: 21.4k]
  ------------------
   82|    534|        break;
   83|    534|      }
   84|  21.4k|      block64 b1(src + 64);
   85|  21.4k|      uint64_t e1 = 0;
   86|  21.4k|      const uint64_t m1 =
   87|  21.4k|          b1.to_base64_mask<base64_url, ignore_garbage, default_or_url>(&e1);
   88|  21.4k|      if ((!ignore_garbage && e1) || m1 != 0) {
  ------------------
  |  Branch (88:12): [True: 21.4k, Folded]
  |  Branch (88:31): [True: 182, False: 21.2k]
  |  Branch (88:38): [True: 184, False: 21.0k]
  ------------------
   89|    366|        break;
   90|    366|      }
   91|  21.0k|      b0.base64_decode_block(dst);
   92|  21.0k|      b1.template base64_decode_block<true>(dst + 48);
   93|  21.0k|      src += 128;
   94|  21.0k|      dst += 96;
   95|  21.0k|    }
   96|    912|  }
   97|  1.81k|  if (srclen >= 64) {
  ------------------
  |  Branch (97:7): [True: 1.56k, False: 246]
  ------------------
   98|  1.56k|    const chartype *const srcend64 = srcinit + srclen - 64;
   99|  53.9k|    while (src <= srcend64) {
  ------------------
  |  Branch (99:12): [True: 53.3k, False: 584]
  ------------------
  100|  53.3k|      block64 b(src);
  101|  53.3k|      uint64_t error = 0;
  102|  53.3k|      const uint64_t badcharmask =
  103|  53.3k|          b.to_base64_mask<base64_url, ignore_garbage, default_or_url>(&error);
  104|  53.3k|      if (!ignore_garbage && error) {
  ------------------
  |  Branch (104:11): [True: 53.3k, Folded]
  |  Branch (104:30): [True: 984, False: 52.3k]
  ------------------
  105|    984|        const size_t error_offset = trailing_zeroes(error);
  106|    984|        return {error_code::INVALID_BASE64_CHARACTER,
  107|    984|                size_t(src - srcinit + error_offset), size_t(dst - dstinit)};
  108|    984|      }
  109|  52.3k|      src += 64;
  110|  52.3k|      if (badcharmask != 0) {
  ------------------
  |  Branch (110:11): [True: 27.0k, False: 25.2k]
  ------------------
  111|  27.0k|        bufferptr += b.compress_block(badcharmask, bufferptr);
  112|  27.0k|      } else if (bufferptr != buffer) {
  ------------------
  |  Branch (112:18): [True: 24.4k, False: 866]
  ------------------
  113|  24.4k|        b.copy_block(bufferptr);
  114|  24.4k|        bufferptr += 64;
  115|  24.4k|      } else {
  116|    866|        b.template base64_decode_block<true>(dst);
  117|    866|        dst += 48;
  118|    866|      }
  119|  52.3k|      if (bufferptr >= (block_size - 1) * 64 + buffer) {
  ------------------
  |  Branch (119:11): [True: 9.78k, False: 42.5k]
  ------------------
  120|  48.9k|        for (size_t i = 0; i < (block_size - 2); i++) {
  ------------------
  |  Branch (120:28): [True: 39.1k, False: 9.78k]
  ------------------
  121|  39.1k|          base64_decode_block(dst, buffer + i * 64);
  122|  39.1k|          dst += 48;
  123|  39.1k|        }
  124|  9.78k|        base64_decode_block<true>(dst, buffer + (block_size - 2) * 64);
  125|  9.78k|        dst += 48;
  126|  9.78k|        std::memcpy(buffer, buffer + (block_size - 1) * 64,
  127|  9.78k|                    64); // 64 might be too much
  128|  9.78k|        bufferptr -= (block_size - 1) * 64;
  129|  9.78k|      }
  130|  52.3k|    }
  131|  1.56k|  }
  132|       |
  133|    830|  char *buffer_start = buffer;
  134|       |  // Optimization note: if this is almost full, then it is worth our
  135|       |  // time, otherwise, we should just decode directly.
  136|    830|  int last_block = (int)((bufferptr - buffer_start) % 64);
  137|    830|  if (last_block != 0 && srcend - src + last_block >= 64) {
  ------------------
  |  Branch (137:7): [True: 530, False: 300]
  |  Branch (137:26): [True: 78, False: 452]
  ------------------
  138|       |
  139|  1.04k|    while ((bufferptr - buffer_start) % 64 != 0 && src < srcend) {
  ------------------
  |  Branch (139:12): [True: 980, False: 62]
  |  Branch (139:52): [True: 970, False: 10]
  ------------------
  140|    970|      uint8_t val = to_base64[uint8_t(*src)];
  141|    970|      *bufferptr = char(val);
  142|    970|      if (!ignore_garbage &&
  ------------------
  |  Branch (142:11): [True: 970, Folded]
  ------------------
  143|    970|          (!scalar::base64::is_eight_byte(*src) || val > 64)) {
  ------------------
  |  Branch (143:12): [True: 0, False: 970]
  |  Branch (143:52): [True: 6, False: 964]
  ------------------
  144|      6|        return {error_code::INVALID_BASE64_CHARACTER, size_t(src - srcinit),
  145|      6|                size_t(dst - dstinit)};
  146|      6|      }
  147|    964|      bufferptr += (val <= 63);
  148|    964|      src++;
  149|    964|    }
  150|     78|  }
  151|       |
  152|  1.28k|  for (; buffer_start + 64 <= bufferptr; buffer_start += 64) {
  ------------------
  |  Branch (152:10): [True: 460, False: 824]
  ------------------
  153|       |    // 8 payload bytes still in the buffer become 6 output bytes, which cover
  154|       |    // the 4-byte tail of a wide store. Fewer than that, and the tail can
  155|       |    // stick out past the real end.
  156|    460|    const size_t after = size_t(bufferptr - (buffer_start + 64));
  157|    460|    if (after >= 8) {
  ------------------
  |  Branch (157:9): [True: 376, False: 84]
  ------------------
  158|    376|      base64_decode_block(dst, buffer_start);
  159|    376|    } else {
  160|     84|      base64_decode_block<true>(dst, buffer_start);
  161|     84|    }
  162|    460|    dst += 48;
  163|    460|  }
  164|    824|  if ((bufferptr - buffer_start) % 64 != 0) {
  ------------------
  |  Branch (164:7): [True: 462, False: 362]
  ------------------
  165|  3.91k|    while (buffer_start + 4 < bufferptr) {
  ------------------
  |  Branch (165:12): [True: 3.45k, False: 462]
  ------------------
  166|  3.45k|      uint32_t triple = ((uint32_t(uint8_t(buffer_start[0])) << 3 * 6) +
  167|  3.45k|                         (uint32_t(uint8_t(buffer_start[1])) << 2 * 6) +
  168|  3.45k|                         (uint32_t(uint8_t(buffer_start[2])) << 1 * 6) +
  169|  3.45k|                         (uint32_t(uint8_t(buffer_start[3])) << 0 * 6))
  170|  3.45k|                        << 8;
  171|  3.45k|#if !SIMDUTF_IS_BIG_ENDIAN
  172|  3.45k|      triple = scalar::u32_swap_bytes(triple);
  173|  3.45k|#endif
  174|  3.45k|      std::memcpy(dst, &triple, 3);
  175|       |
  176|  3.45k|      dst += 3;
  177|  3.45k|      buffer_start += 4;
  178|  3.45k|    }
  179|    462|    if (buffer_start + 4 <= bufferptr) {
  ------------------
  |  Branch (179:9): [True: 128, False: 334]
  ------------------
  180|    128|      uint32_t triple = ((uint32_t(uint8_t(buffer_start[0])) << 3 * 6) +
  181|    128|                         (uint32_t(uint8_t(buffer_start[1])) << 2 * 6) +
  182|    128|                         (uint32_t(uint8_t(buffer_start[2])) << 1 * 6) +
  183|    128|                         (uint32_t(uint8_t(buffer_start[3])) << 0 * 6))
  184|    128|                        << 8;
  185|    128|#if !SIMDUTF_IS_BIG_ENDIAN
  186|    128|      triple = scalar::u32_swap_bytes(triple);
  187|    128|#endif
  188|    128|      std::memcpy(dst, &triple, 3);
  189|       |
  190|    128|      dst += 3;
  191|    128|      buffer_start += 4;
  192|    128|    }
  193|       |    // we may have 1, 2 or 3 bytes left and we need to decode them so let us
  194|       |    // backtrack
  195|    462|    int leftover = int(bufferptr - buffer_start);
  196|  1.11k|    while (leftover > 0) {
  ------------------
  |  Branch (196:12): [True: 656, False: 462]
  ------------------
  197|    656|      if (!ignore_garbage) {
  ------------------
  |  Branch (197:11): [True: 656, Folded]
  ------------------
  198|  5.10k|        while (to_base64[uint8_t(*(src - 1))] == 64) {
  ------------------
  |  Branch (198:16): [True: 4.45k, False: 656]
  ------------------
  199|  4.45k|          src--;
  200|  4.45k|        }
  201|    656|      } else {
  202|      0|        while (to_base64[uint8_t(*(src - 1))] >= 64) {
  ------------------
  |  Branch (202:16): [True: 0, False: 0]
  ------------------
  203|      0|          src--;
  204|      0|        }
  205|      0|      }
  206|    656|      src--;
  207|    656|      leftover--;
  208|    656|    }
  209|    462|  }
  210|    824|  if (src < srcend + equalsigns) {
  ------------------
  |  Branch (210:7): [True: 648, False: 176]
  ------------------
  211|    648|    full_result r = scalar::base64::base64_tail_decode(
  212|    648|        dst, src, srcend - src, equalsigns, options, last_chunk_options);
  213|    648|    r = scalar::base64::patch_tail_result(
  214|    648|        r, size_t(src - srcinit), size_t(dst - dstinit), equallocation,
  215|    648|        full_input_length, last_chunk_options);
  216|       |    // When is_partial(last_chunk_options) is true, we must either end with
  217|       |    // the end of the stream (beyond whitespace) or right after a non-ignorable
  218|       |    // character or at the very beginning of the stream.
  219|       |    // See https://tc39.es/proposal-arraybuffer-base64/spec/#sec-frombase64
  220|    648|    if (is_partial(last_chunk_options) && r.error == error_code::SUCCESS &&
  ------------------
  |  Branch (220:9): [True: 292, False: 356]
  |  Branch (220:43): [True: 274, False: 18]
  ------------------
  221|    274|        r.input_count < full_input_length) {
  ------------------
  |  Branch (221:9): [True: 246, False: 28]
  ------------------
  222|       |      // First check if we can extend the input to the end of the stream
  223|    680|      while (r.input_count < full_input_length &&
  ------------------
  |  Branch (223:14): [True: 676, False: 4]
  ------------------
  224|    676|             base64_ignorable(*(srcinit + r.input_count), options)) {
  ------------------
  |  Branch (224:14): [True: 434, False: 242]
  ------------------
  225|    434|        r.input_count++;
  226|    434|      }
  227|       |      // If we are still not at the end of the stream, then we must backtrack
  228|       |      // to the last non-ignorable character.
  229|    246|      if (r.input_count < full_input_length) {
  ------------------
  |  Branch (229:11): [True: 242, False: 4]
  ------------------
  230|  1.79k|        while (r.input_count > 0 &&
  ------------------
  |  Branch (230:16): [True: 1.73k, False: 58]
  ------------------
  231|  1.73k|               base64_ignorable(*(srcinit + r.input_count - 1), options)) {
  ------------------
  |  Branch (231:16): [True: 1.55k, False: 184]
  ------------------
  232|  1.55k|          r.input_count--;
  233|  1.55k|        }
  234|    242|      }
  235|    246|    }
  236|    648|    return r;
  237|    648|  }
  238|    176|  if (!ignore_garbage && equalsigns > 0) {
  ------------------
  |  Branch (238:7): [True: 176, Folded]
  |  Branch (238:26): [True: 0, False: 176]
  ------------------
  239|      0|    if ((size_t(dst - dstinit) % 3 == 0) ||
  ------------------
  |  Branch (239:9): [True: 0, False: 0]
  ------------------
  240|      0|        ((size_t(dst - dstinit) % 3) + 1 + equalsigns != 4)) {
  ------------------
  |  Branch (240:9): [True: 0, False: 0]
  ------------------
  241|      0|      return {INVALID_BASE64_CHARACTER, equallocation, size_t(dst - dstinit),
  242|      0|              true};
  243|      0|    }
  244|      0|  }
  245|    176|  return {SUCCESS, srclen, size_t(dst - dstinit)};
  246|    176|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_16base6422compress_decode_base64ILb0ELb0ELb0EcEENS_11full_resultEPcPKT2_mNS_14base64_optionsENS_27last_chunk_handling_optionsE:
   45|  1.95k|                       last_chunk_handling_options last_chunk_options) {
   46|  1.95k|  const uint8_t *to_base64 =
   47|  1.95k|      default_or_url ? tables::base64::to_base64_default_or_url_value
  ------------------
  |  Branch (47:7): [Folded, False: 1.95k]
  ------------------
   48|  1.95k|                     : (base64_url ? tables::base64::to_base64_url_value
  ------------------
  |  Branch (48:25): [Folded, False: 1.95k]
  ------------------
   49|  1.95k|                                   : tables::base64::to_base64_value);
   50|  1.95k|  auto ri = simdutf::scalar::base64::find_end(src, srclen, options);
   51|  1.95k|  size_t equallocation = ri.equallocation;
   52|  1.95k|  size_t equalsigns = ri.equalsigns;
   53|  1.95k|  srclen = ri.srclen;
   54|  1.95k|  size_t full_input_length = ri.full_input_length;
   55|  1.95k|  if (srclen == 0) {
  ------------------
  |  Branch (55:7): [True: 22, False: 1.93k]
  ------------------
   56|     22|    if (!ignore_garbage && equalsigns > 0) {
  ------------------
  |  Branch (56:9): [True: 22, Folded]
  |  Branch (56:28): [True: 12, False: 10]
  ------------------
   57|     12|      return {INVALID_BASE64_CHARACTER, equallocation, 0, true};
   58|     12|    }
   59|     10|    return {SUCCESS, full_input_length, 0};
   60|     22|  }
   61|  1.93k|  const chartype *const srcinit = src;
   62|  1.93k|  const char *const dstinit = dst;
   63|  1.93k|  const chartype *const srcend = src + srclen;
   64|       |
   65|  1.93k|  constexpr size_t block_size = 6;
   66|  1.93k|  static_assert(block_size >= 2, "block_size must be at least two");
   67|  1.93k|  char buffer[block_size * 64];
   68|  1.93k|  char *bufferptr = buffer;
   69|       |  // A wide block store writes 4 bytes past its 48. That is safe when the next
   70|       |  // store starts 48 bytes later. Pairs of clean blocks wide-store the first
   71|       |  // and end the second on byte 48. Anything shorter, or a block that is not
   72|       |  // clean, uses the exact store. The pair attempt is only worth it on a long
   73|       |  // input: a short one often fails the first block and then repeats that work.
   74|  1.93k|  if (srclen >= 512) {
  ------------------
  |  Branch (74:7): [True: 970, False: 960]
  ------------------
   75|    970|    const chartype *const srcend128 = src + srclen - 128;
   76|  47.4k|    while (bufferptr == buffer && src <= srcend128) {
  ------------------
  |  Branch (76:12): [True: 47.4k, False: 0]
  |  Branch (76:35): [True: 47.4k, False: 20]
  ------------------
   77|  47.4k|      block64 b0(src);
   78|  47.4k|      uint64_t e0 = 0;
   79|  47.4k|      const uint64_t m0 =
   80|  47.4k|          b0.to_base64_mask<base64_url, ignore_garbage, default_or_url>(&e0);
   81|  47.4k|      if ((!ignore_garbage && e0) || m0 != 0) {
  ------------------
  |  Branch (81:12): [True: 47.4k, Folded]
  |  Branch (81:31): [True: 228, False: 47.1k]
  |  Branch (81:38): [True: 342, False: 46.8k]
  ------------------
   82|    570|        break;
   83|    570|      }
   84|  46.8k|      block64 b1(src + 64);
   85|  46.8k|      uint64_t e1 = 0;
   86|  46.8k|      const uint64_t m1 =
   87|  46.8k|          b1.to_base64_mask<base64_url, ignore_garbage, default_or_url>(&e1);
   88|  46.8k|      if ((!ignore_garbage && e1) || m1 != 0) {
  ------------------
  |  Branch (88:12): [True: 46.8k, Folded]
  |  Branch (88:31): [True: 208, False: 46.6k]
  |  Branch (88:38): [True: 172, False: 46.4k]
  ------------------
   89|    380|        break;
   90|    380|      }
   91|  46.4k|      b0.base64_decode_block(dst);
   92|  46.4k|      b1.template base64_decode_block<true>(dst + 48);
   93|  46.4k|      src += 128;
   94|  46.4k|      dst += 96;
   95|  46.4k|    }
   96|    970|  }
   97|  1.93k|  if (srclen >= 64) {
  ------------------
  |  Branch (97:7): [True: 1.66k, False: 268]
  ------------------
   98|  1.66k|    const chartype *const srcend64 = srcinit + srclen - 64;
   99|   207k|    while (src <= srcend64) {
  ------------------
  |  Branch (99:12): [True: 206k, False: 652]
  ------------------
  100|   206k|      block64 b(src);
  101|   206k|      uint64_t error = 0;
  102|   206k|      const uint64_t badcharmask =
  103|   206k|          b.to_base64_mask<base64_url, ignore_garbage, default_or_url>(&error);
  104|   206k|      if (!ignore_garbage && error) {
  ------------------
  |  Branch (104:11): [True: 206k, Folded]
  |  Branch (104:30): [True: 1.01k, False: 205k]
  ------------------
  105|  1.01k|        const size_t error_offset = trailing_zeroes(error);
  106|  1.01k|        return {error_code::INVALID_BASE64_CHARACTER,
  107|  1.01k|                size_t(src - srcinit + error_offset), size_t(dst - dstinit)};
  108|  1.01k|      }
  109|   205k|      src += 64;
  110|   205k|      if (badcharmask != 0) {
  ------------------
  |  Branch (110:11): [True: 48.8k, False: 157k]
  ------------------
  111|  48.8k|        bufferptr += b.compress_block(badcharmask, bufferptr);
  112|   157k|      } else if (bufferptr != buffer) {
  ------------------
  |  Branch (112:18): [True: 143k, False: 13.9k]
  ------------------
  113|   143k|        b.copy_block(bufferptr);
  114|   143k|        bufferptr += 64;
  115|   143k|      } else {
  116|  13.9k|        b.template base64_decode_block<true>(dst);
  117|  13.9k|        dst += 48;
  118|  13.9k|      }
  119|   205k|      if (bufferptr >= (block_size - 1) * 64 + buffer) {
  ------------------
  |  Branch (119:11): [True: 37.4k, False: 168k]
  ------------------
  120|   187k|        for (size_t i = 0; i < (block_size - 2); i++) {
  ------------------
  |  Branch (120:28): [True: 149k, False: 37.4k]
  ------------------
  121|   149k|          base64_decode_block(dst, buffer + i * 64);
  122|   149k|          dst += 48;
  123|   149k|        }
  124|  37.4k|        base64_decode_block<true>(dst, buffer + (block_size - 2) * 64);
  125|  37.4k|        dst += 48;
  126|  37.4k|        std::memcpy(buffer, buffer + (block_size - 1) * 64,
  127|  37.4k|                    64); // 64 might be too much
  128|  37.4k|        bufferptr -= (block_size - 1) * 64;
  129|  37.4k|      }
  130|   205k|    }
  131|  1.66k|  }
  132|       |
  133|    920|  char *buffer_start = buffer;
  134|       |  // Optimization note: if this is almost full, then it is worth our
  135|       |  // time, otherwise, we should just decode directly.
  136|    920|  int last_block = (int)((bufferptr - buffer_start) % 64);
  137|    920|  if (last_block != 0 && srcend - src + last_block >= 64) {
  ------------------
  |  Branch (137:7): [True: 592, False: 328]
  |  Branch (137:26): [True: 82, False: 510]
  ------------------
  138|       |
  139|  1.34k|    while ((bufferptr - buffer_start) % 64 != 0 && src < srcend) {
  ------------------
  |  Branch (139:12): [True: 1.29k, False: 54]
  |  Branch (139:52): [True: 1.27k, False: 20]
  ------------------
  140|  1.27k|      uint8_t val = to_base64[uint8_t(*src)];
  141|  1.27k|      *bufferptr = char(val);
  142|  1.27k|      if (!ignore_garbage &&
  ------------------
  |  Branch (142:11): [True: 1.27k, Folded]
  ------------------
  143|  1.27k|          (!scalar::base64::is_eight_byte(*src) || val > 64)) {
  ------------------
  |  Branch (143:12): [True: 0, False: 1.27k]
  |  Branch (143:52): [True: 8, False: 1.26k]
  ------------------
  144|      8|        return {error_code::INVALID_BASE64_CHARACTER, size_t(src - srcinit),
  145|      8|                size_t(dst - dstinit)};
  146|      8|      }
  147|  1.26k|      bufferptr += (val <= 63);
  148|  1.26k|      src++;
  149|  1.26k|    }
  150|     82|  }
  151|       |
  152|  1.43k|  for (; buffer_start + 64 <= bufferptr; buffer_start += 64) {
  ------------------
  |  Branch (152:10): [True: 520, False: 912]
  ------------------
  153|       |    // 8 payload bytes still in the buffer become 6 output bytes, which cover
  154|       |    // the 4-byte tail of a wide store. Fewer than that, and the tail can
  155|       |    // stick out past the real end.
  156|    520|    const size_t after = size_t(bufferptr - (buffer_start + 64));
  157|    520|    if (after >= 8) {
  ------------------
  |  Branch (157:9): [True: 442, False: 78]
  ------------------
  158|    442|      base64_decode_block(dst, buffer_start);
  159|    442|    } else {
  160|     78|      base64_decode_block<true>(dst, buffer_start);
  161|     78|    }
  162|    520|    dst += 48;
  163|    520|  }
  164|    912|  if ((bufferptr - buffer_start) % 64 != 0) {
  ------------------
  |  Branch (164:7): [True: 530, False: 382]
  ------------------
  165|  4.64k|    while (buffer_start + 4 < bufferptr) {
  ------------------
  |  Branch (165:12): [True: 4.11k, False: 530]
  ------------------
  166|  4.11k|      uint32_t triple = ((uint32_t(uint8_t(buffer_start[0])) << 3 * 6) +
  167|  4.11k|                         (uint32_t(uint8_t(buffer_start[1])) << 2 * 6) +
  168|  4.11k|                         (uint32_t(uint8_t(buffer_start[2])) << 1 * 6) +
  169|  4.11k|                         (uint32_t(uint8_t(buffer_start[3])) << 0 * 6))
  170|  4.11k|                        << 8;
  171|  4.11k|#if !SIMDUTF_IS_BIG_ENDIAN
  172|  4.11k|      triple = scalar::u32_swap_bytes(triple);
  173|  4.11k|#endif
  174|  4.11k|      std::memcpy(dst, &triple, 3);
  175|       |
  176|  4.11k|      dst += 3;
  177|  4.11k|      buffer_start += 4;
  178|  4.11k|    }
  179|    530|    if (buffer_start + 4 <= bufferptr) {
  ------------------
  |  Branch (179:9): [True: 146, False: 384]
  ------------------
  180|    146|      uint32_t triple = ((uint32_t(uint8_t(buffer_start[0])) << 3 * 6) +
  181|    146|                         (uint32_t(uint8_t(buffer_start[1])) << 2 * 6) +
  182|    146|                         (uint32_t(uint8_t(buffer_start[2])) << 1 * 6) +
  183|    146|                         (uint32_t(uint8_t(buffer_start[3])) << 0 * 6))
  184|    146|                        << 8;
  185|    146|#if !SIMDUTF_IS_BIG_ENDIAN
  186|    146|      triple = scalar::u32_swap_bytes(triple);
  187|    146|#endif
  188|    146|      std::memcpy(dst, &triple, 3);
  189|       |
  190|    146|      dst += 3;
  191|    146|      buffer_start += 4;
  192|    146|    }
  193|       |    // we may have 1, 2 or 3 bytes left and we need to decode them so let us
  194|       |    // backtrack
  195|    530|    int leftover = int(bufferptr - buffer_start);
  196|  1.31k|    while (leftover > 0) {
  ------------------
  |  Branch (196:12): [True: 786, False: 530]
  ------------------
  197|    786|      if (!ignore_garbage) {
  ------------------
  |  Branch (197:11): [True: 786, Folded]
  ------------------
  198|  5.39k|        while (to_base64[uint8_t(*(src - 1))] == 64) {
  ------------------
  |  Branch (198:16): [True: 4.61k, False: 786]
  ------------------
  199|  4.61k|          src--;
  200|  4.61k|        }
  201|    786|      } else {
  202|      0|        while (to_base64[uint8_t(*(src - 1))] >= 64) {
  ------------------
  |  Branch (202:16): [True: 0, False: 0]
  ------------------
  203|      0|          src--;
  204|      0|        }
  205|      0|      }
  206|    786|      src--;
  207|    786|      leftover--;
  208|    786|    }
  209|    530|  }
  210|    912|  if (src < srcend + equalsigns) {
  ------------------
  |  Branch (210:7): [True: 750, False: 162]
  ------------------
  211|    750|    full_result r = scalar::base64::base64_tail_decode(
  212|    750|        dst, src, srcend - src, equalsigns, options, last_chunk_options);
  213|    750|    r = scalar::base64::patch_tail_result(
  214|    750|        r, size_t(src - srcinit), size_t(dst - dstinit), equallocation,
  215|    750|        full_input_length, last_chunk_options);
  216|       |    // When is_partial(last_chunk_options) is true, we must either end with
  217|       |    // the end of the stream (beyond whitespace) or right after a non-ignorable
  218|       |    // character or at the very beginning of the stream.
  219|       |    // See https://tc39.es/proposal-arraybuffer-base64/spec/#sec-frombase64
  220|    750|    if (is_partial(last_chunk_options) && r.error == error_code::SUCCESS &&
  ------------------
  |  Branch (220:9): [True: 410, False: 340]
  |  Branch (220:43): [True: 384, False: 26]
  ------------------
  221|    384|        r.input_count < full_input_length) {
  ------------------
  |  Branch (221:9): [True: 318, False: 66]
  ------------------
  222|       |      // First check if we can extend the input to the end of the stream
  223|    592|      while (r.input_count < full_input_length &&
  ------------------
  |  Branch (223:14): [True: 584, False: 8]
  ------------------
  224|    584|             base64_ignorable(*(srcinit + r.input_count), options)) {
  ------------------
  |  Branch (224:14): [True: 274, False: 310]
  ------------------
  225|    274|        r.input_count++;
  226|    274|      }
  227|       |      // If we are still not at the end of the stream, then we must backtrack
  228|       |      // to the last non-ignorable character.
  229|    318|      if (r.input_count < full_input_length) {
  ------------------
  |  Branch (229:11): [True: 310, False: 8]
  ------------------
  230|  3.06k|        while (r.input_count > 0 &&
  ------------------
  |  Branch (230:16): [True: 3.01k, False: 48]
  ------------------
  231|  3.01k|               base64_ignorable(*(srcinit + r.input_count - 1), options)) {
  ------------------
  |  Branch (231:16): [True: 2.75k, False: 262]
  ------------------
  232|  2.75k|          r.input_count--;
  233|  2.75k|        }
  234|    310|      }
  235|    318|    }
  236|    750|    return r;
  237|    750|  }
  238|    162|  if (!ignore_garbage && equalsigns > 0) {
  ------------------
  |  Branch (238:7): [True: 162, Folded]
  |  Branch (238:26): [True: 0, False: 162]
  ------------------
  239|      0|    if ((size_t(dst - dstinit) % 3 == 0) ||
  ------------------
  |  Branch (239:9): [True: 0, False: 0]
  ------------------
  240|      0|        ((size_t(dst - dstinit) % 3) + 1 + equalsigns != 4)) {
  ------------------
  |  Branch (240:9): [True: 0, False: 0]
  ------------------
  241|      0|      return {INVALID_BASE64_CHARACTER, equallocation, size_t(dst - dstinit),
  242|      0|              true};
  243|      0|    }
  244|      0|  }
  245|    162|  return {SUCCESS, srclen, size_t(dst - dstinit)};
  246|    162|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_16base6422compress_decode_base64ILb1ELb0ELb0EDsEENS_11full_resultEPcPKT2_mNS_14base64_optionsENS_27last_chunk_handling_optionsE:
   45|  1.88k|                       last_chunk_handling_options last_chunk_options) {
   46|  1.88k|  const uint8_t *to_base64 =
   47|  1.88k|      default_or_url ? tables::base64::to_base64_default_or_url_value
  ------------------
  |  Branch (47:7): [Folded, False: 1.88k]
  ------------------
   48|  1.88k|                     : (base64_url ? tables::base64::to_base64_url_value
  ------------------
  |  Branch (48:25): [True: 1.88k, Folded]
  ------------------
   49|  1.88k|                                   : tables::base64::to_base64_value);
   50|  1.88k|  auto ri = simdutf::scalar::base64::find_end(src, srclen, options);
   51|  1.88k|  size_t equallocation = ri.equallocation;
   52|  1.88k|  size_t equalsigns = ri.equalsigns;
   53|  1.88k|  srclen = ri.srclen;
   54|  1.88k|  size_t full_input_length = ri.full_input_length;
   55|  1.88k|  if (srclen == 0) {
  ------------------
  |  Branch (55:7): [True: 22, False: 1.86k]
  ------------------
   56|     22|    if (!ignore_garbage && equalsigns > 0) {
  ------------------
  |  Branch (56:9): [True: 22, Folded]
  |  Branch (56:28): [True: 10, False: 12]
  ------------------
   57|     10|      return {INVALID_BASE64_CHARACTER, equallocation, 0, true};
   58|     10|    }
   59|     12|    return {SUCCESS, full_input_length, 0};
   60|     22|  }
   61|  1.86k|  const chartype *const srcinit = src;
   62|  1.86k|  const char *const dstinit = dst;
   63|  1.86k|  const chartype *const srcend = src + srclen;
   64|       |
   65|  1.86k|  constexpr size_t block_size = 6;
   66|  1.86k|  static_assert(block_size >= 2, "block_size must be at least two");
   67|  1.86k|  char buffer[block_size * 64];
   68|  1.86k|  char *bufferptr = buffer;
   69|       |  // A wide block store writes 4 bytes past its 48. That is safe when the next
   70|       |  // store starts 48 bytes later. Pairs of clean blocks wide-store the first
   71|       |  // and end the second on byte 48. Anything shorter, or a block that is not
   72|       |  // clean, uses the exact store. The pair attempt is only worth it on a long
   73|       |  // input: a short one often fails the first block and then repeats that work.
   74|  1.86k|  if (srclen >= 512) {
  ------------------
  |  Branch (74:7): [True: 928, False: 938]
  ------------------
   75|    928|    const chartype *const srcend128 = src + srclen - 128;
   76|  1.30k|    while (bufferptr == buffer && src <= srcend128) {
  ------------------
  |  Branch (76:12): [True: 1.30k, False: 0]
  |  Branch (76:35): [True: 1.29k, False: 10]
  ------------------
   77|  1.29k|      block64 b0(src);
   78|  1.29k|      uint64_t e0 = 0;
   79|  1.29k|      const uint64_t m0 =
   80|  1.29k|          b0.to_base64_mask<base64_url, ignore_garbage, default_or_url>(&e0);
   81|  1.29k|      if ((!ignore_garbage && e0) || m0 != 0) {
  ------------------
  |  Branch (81:12): [True: 1.29k, Folded]
  |  Branch (81:31): [True: 226, False: 1.06k]
  |  Branch (81:38): [True: 332, False: 736]
  ------------------
   82|    558|        break;
   83|    558|      }
   84|    736|      block64 b1(src + 64);
   85|    736|      uint64_t e1 = 0;
   86|    736|      const uint64_t m1 =
   87|    736|          b1.to_base64_mask<base64_url, ignore_garbage, default_or_url>(&e1);
   88|    736|      if ((!ignore_garbage && e1) || m1 != 0) {
  ------------------
  |  Branch (88:12): [True: 736, Folded]
  |  Branch (88:31): [True: 180, False: 556]
  |  Branch (88:38): [True: 180, False: 376]
  ------------------
   89|    360|        break;
   90|    360|      }
   91|    376|      b0.base64_decode_block(dst);
   92|    376|      b1.template base64_decode_block<true>(dst + 48);
   93|    376|      src += 128;
   94|    376|      dst += 96;
   95|    376|    }
   96|    928|  }
   97|  1.86k|  if (srclen >= 64) {
  ------------------
  |  Branch (97:7): [True: 1.59k, False: 274]
  ------------------
   98|  1.59k|    const chartype *const srcend64 = srcinit + srclen - 64;
   99|  54.5k|    while (src <= srcend64) {
  ------------------
  |  Branch (99:12): [True: 54.0k, False: 572]
  ------------------
  100|  54.0k|      block64 b(src);
  101|  54.0k|      uint64_t error = 0;
  102|  54.0k|      const uint64_t badcharmask =
  103|  54.0k|          b.to_base64_mask<base64_url, ignore_garbage, default_or_url>(&error);
  104|  54.0k|      if (!ignore_garbage && error) {
  ------------------
  |  Branch (104:11): [True: 54.0k, Folded]
  |  Branch (104:30): [True: 1.02k, False: 52.9k]
  ------------------
  105|  1.02k|        const size_t error_offset = trailing_zeroes(error);
  106|  1.02k|        return {error_code::INVALID_BASE64_CHARACTER,
  107|  1.02k|                size_t(src - srcinit + error_offset), size_t(dst - dstinit)};
  108|  1.02k|      }
  109|  52.9k|      src += 64;
  110|  52.9k|      if (badcharmask != 0) {
  ------------------
  |  Branch (110:11): [True: 43.8k, False: 9.11k]
  ------------------
  111|  43.8k|        bufferptr += b.compress_block(badcharmask, bufferptr);
  112|  43.8k|      } else if (bufferptr != buffer) {
  ------------------
  |  Branch (112:18): [True: 8.52k, False: 584]
  ------------------
  113|  8.52k|        b.copy_block(bufferptr);
  114|  8.52k|        bufferptr += 64;
  115|  8.52k|      } else {
  116|    584|        b.template base64_decode_block<true>(dst);
  117|    584|        dst += 48;
  118|    584|      }
  119|  52.9k|      if (bufferptr >= (block_size - 1) * 64 + buffer) {
  ------------------
  |  Branch (119:11): [True: 9.97k, False: 43.0k]
  ------------------
  120|  49.8k|        for (size_t i = 0; i < (block_size - 2); i++) {
  ------------------
  |  Branch (120:28): [True: 39.8k, False: 9.97k]
  ------------------
  121|  39.8k|          base64_decode_block(dst, buffer + i * 64);
  122|  39.8k|          dst += 48;
  123|  39.8k|        }
  124|  9.97k|        base64_decode_block<true>(dst, buffer + (block_size - 2) * 64);
  125|  9.97k|        dst += 48;
  126|  9.97k|        std::memcpy(buffer, buffer + (block_size - 1) * 64,
  127|  9.97k|                    64); // 64 might be too much
  128|  9.97k|        bufferptr -= (block_size - 1) * 64;
  129|  9.97k|      }
  130|  52.9k|    }
  131|  1.59k|  }
  132|       |
  133|    846|  char *buffer_start = buffer;
  134|       |  // Optimization note: if this is almost full, then it is worth our
  135|       |  // time, otherwise, we should just decode directly.
  136|    846|  int last_block = (int)((bufferptr - buffer_start) % 64);
  137|    846|  if (last_block != 0 && srcend - src + last_block >= 64) {
  ------------------
  |  Branch (137:7): [True: 532, False: 314]
  |  Branch (137:26): [True: 86, False: 446]
  ------------------
  138|       |
  139|    560|    while ((bufferptr - buffer_start) % 64 != 0 && src < srcend) {
  ------------------
  |  Branch (139:12): [True: 528, False: 32]
  |  Branch (139:52): [True: 512, False: 16]
  ------------------
  140|    512|      uint8_t val = to_base64[uint8_t(*src)];
  141|    512|      *bufferptr = char(val);
  142|    512|      if (!ignore_garbage &&
  ------------------
  |  Branch (142:11): [True: 512, Folded]
  ------------------
  143|    512|          (!scalar::base64::is_eight_byte(*src) || val > 64)) {
  ------------------
  |  Branch (143:12): [True: 18, False: 494]
  |  Branch (143:52): [True: 20, False: 474]
  ------------------
  144|     38|        return {error_code::INVALID_BASE64_CHARACTER, size_t(src - srcinit),
  145|     38|                size_t(dst - dstinit)};
  146|     38|      }
  147|    474|      bufferptr += (val <= 63);
  148|    474|      src++;
  149|    474|    }
  150|     86|  }
  151|       |
  152|  1.13k|  for (; buffer_start + 64 <= bufferptr; buffer_start += 64) {
  ------------------
  |  Branch (152:10): [True: 326, False: 808]
  ------------------
  153|       |    // 8 payload bytes still in the buffer become 6 output bytes, which cover
  154|       |    // the 4-byte tail of a wide store. Fewer than that, and the tail can
  155|       |    // stick out past the real end.
  156|    326|    const size_t after = size_t(bufferptr - (buffer_start + 64));
  157|    326|    if (after >= 8) {
  ------------------
  |  Branch (157:9): [True: 272, False: 54]
  ------------------
  158|    272|      base64_decode_block(dst, buffer_start);
  159|    272|    } else {
  160|     54|      base64_decode_block<true>(dst, buffer_start);
  161|     54|    }
  162|    326|    dst += 48;
  163|    326|  }
  164|    808|  if ((bufferptr - buffer_start) % 64 != 0) {
  ------------------
  |  Branch (164:7): [True: 462, False: 346]
  ------------------
  165|  3.89k|    while (buffer_start + 4 < bufferptr) {
  ------------------
  |  Branch (165:12): [True: 3.43k, False: 462]
  ------------------
  166|  3.43k|      uint32_t triple = ((uint32_t(uint8_t(buffer_start[0])) << 3 * 6) +
  167|  3.43k|                         (uint32_t(uint8_t(buffer_start[1])) << 2 * 6) +
  168|  3.43k|                         (uint32_t(uint8_t(buffer_start[2])) << 1 * 6) +
  169|  3.43k|                         (uint32_t(uint8_t(buffer_start[3])) << 0 * 6))
  170|  3.43k|                        << 8;
  171|  3.43k|#if !SIMDUTF_IS_BIG_ENDIAN
  172|  3.43k|      triple = scalar::u32_swap_bytes(triple);
  173|  3.43k|#endif
  174|  3.43k|      std::memcpy(dst, &triple, 3);
  175|       |
  176|  3.43k|      dst += 3;
  177|  3.43k|      buffer_start += 4;
  178|  3.43k|    }
  179|    462|    if (buffer_start + 4 <= bufferptr) {
  ------------------
  |  Branch (179:9): [True: 94, False: 368]
  ------------------
  180|     94|      uint32_t triple = ((uint32_t(uint8_t(buffer_start[0])) << 3 * 6) +
  181|     94|                         (uint32_t(uint8_t(buffer_start[1])) << 2 * 6) +
  182|     94|                         (uint32_t(uint8_t(buffer_start[2])) << 1 * 6) +
  183|     94|                         (uint32_t(uint8_t(buffer_start[3])) << 0 * 6))
  184|     94|                        << 8;
  185|     94|#if !SIMDUTF_IS_BIG_ENDIAN
  186|     94|      triple = scalar::u32_swap_bytes(triple);
  187|     94|#endif
  188|     94|      std::memcpy(dst, &triple, 3);
  189|       |
  190|     94|      dst += 3;
  191|     94|      buffer_start += 4;
  192|     94|    }
  193|       |    // we may have 1, 2 or 3 bytes left and we need to decode them so let us
  194|       |    // backtrack
  195|    462|    int leftover = int(bufferptr - buffer_start);
  196|  1.21k|    while (leftover > 0) {
  ------------------
  |  Branch (196:12): [True: 750, False: 462]
  ------------------
  197|    750|      if (!ignore_garbage) {
  ------------------
  |  Branch (197:11): [True: 750, Folded]
  ------------------
  198|  7.06k|        while (to_base64[uint8_t(*(src - 1))] == 64) {
  ------------------
  |  Branch (198:16): [True: 6.31k, False: 750]
  ------------------
  199|  6.31k|          src--;
  200|  6.31k|        }
  201|    750|      } else {
  202|      0|        while (to_base64[uint8_t(*(src - 1))] >= 64) {
  ------------------
  |  Branch (202:16): [True: 0, False: 0]
  ------------------
  203|      0|          src--;
  204|      0|        }
  205|      0|      }
  206|    750|      src--;
  207|    750|      leftover--;
  208|    750|    }
  209|    462|  }
  210|    808|  if (src < srcend + equalsigns) {
  ------------------
  |  Branch (210:7): [True: 690, False: 118]
  ------------------
  211|    690|    full_result r = scalar::base64::base64_tail_decode(
  212|    690|        dst, src, srcend - src, equalsigns, options, last_chunk_options);
  213|    690|    r = scalar::base64::patch_tail_result(
  214|    690|        r, size_t(src - srcinit), size_t(dst - dstinit), equallocation,
  215|    690|        full_input_length, last_chunk_options);
  216|       |    // When is_partial(last_chunk_options) is true, we must either end with
  217|       |    // the end of the stream (beyond whitespace) or right after a non-ignorable
  218|       |    // character or at the very beginning of the stream.
  219|       |    // See https://tc39.es/proposal-arraybuffer-base64/spec/#sec-frombase64
  220|    690|    if (is_partial(last_chunk_options) && r.error == error_code::SUCCESS &&
  ------------------
  |  Branch (220:9): [True: 398, False: 292]
  |  Branch (220:43): [True: 324, False: 74]
  ------------------
  221|    324|        r.input_count < full_input_length) {
  ------------------
  |  Branch (221:9): [True: 290, False: 34]
  ------------------
  222|       |      // First check if we can extend the input to the end of the stream
  223|    702|      while (r.input_count < full_input_length &&
  ------------------
  |  Branch (223:14): [True: 698, False: 4]
  ------------------
  224|    698|             base64_ignorable(*(srcinit + r.input_count), options)) {
  ------------------
  |  Branch (224:14): [True: 412, False: 286]
  ------------------
  225|    412|        r.input_count++;
  226|    412|      }
  227|       |      // If we are still not at the end of the stream, then we must backtrack
  228|       |      // to the last non-ignorable character.
  229|    290|      if (r.input_count < full_input_length) {
  ------------------
  |  Branch (229:11): [True: 286, False: 4]
  ------------------
  230|  2.08k|        while (r.input_count > 0 &&
  ------------------
  |  Branch (230:16): [True: 2.00k, False: 78]
  ------------------
  231|  2.00k|               base64_ignorable(*(srcinit + r.input_count - 1), options)) {
  ------------------
  |  Branch (231:16): [True: 1.79k, False: 208]
  ------------------
  232|  1.79k|          r.input_count--;
  233|  1.79k|        }
  234|    286|      }
  235|    290|    }
  236|    690|    return r;
  237|    690|  }
  238|    118|  if (!ignore_garbage && equalsigns > 0) {
  ------------------
  |  Branch (238:7): [True: 118, Folded]
  |  Branch (238:26): [True: 0, False: 118]
  ------------------
  239|      0|    if ((size_t(dst - dstinit) % 3 == 0) ||
  ------------------
  |  Branch (239:9): [True: 0, False: 0]
  ------------------
  240|      0|        ((size_t(dst - dstinit) % 3) + 1 + equalsigns != 4)) {
  ------------------
  |  Branch (240:9): [True: 0, False: 0]
  ------------------
  241|      0|      return {INVALID_BASE64_CHARACTER, equallocation, size_t(dst - dstinit),
  242|      0|              true};
  243|      0|    }
  244|      0|  }
  245|    118|  return {SUCCESS, srclen, size_t(dst - dstinit)};
  246|    118|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_16base6422compress_decode_base64ILb0ELb0ELb0EDsEENS_11full_resultEPcPKT2_mNS_14base64_optionsENS_27last_chunk_handling_optionsE:
   45|  1.91k|                       last_chunk_handling_options last_chunk_options) {
   46|  1.91k|  const uint8_t *to_base64 =
   47|  1.91k|      default_or_url ? tables::base64::to_base64_default_or_url_value
  ------------------
  |  Branch (47:7): [Folded, False: 1.91k]
  ------------------
   48|  1.91k|                     : (base64_url ? tables::base64::to_base64_url_value
  ------------------
  |  Branch (48:25): [Folded, False: 1.91k]
  ------------------
   49|  1.91k|                                   : tables::base64::to_base64_value);
   50|  1.91k|  auto ri = simdutf::scalar::base64::find_end(src, srclen, options);
   51|  1.91k|  size_t equallocation = ri.equallocation;
   52|  1.91k|  size_t equalsigns = ri.equalsigns;
   53|  1.91k|  srclen = ri.srclen;
   54|  1.91k|  size_t full_input_length = ri.full_input_length;
   55|  1.91k|  if (srclen == 0) {
  ------------------
  |  Branch (55:7): [True: 16, False: 1.89k]
  ------------------
   56|     16|    if (!ignore_garbage && equalsigns > 0) {
  ------------------
  |  Branch (56:9): [True: 16, Folded]
  |  Branch (56:28): [True: 8, False: 8]
  ------------------
   57|      8|      return {INVALID_BASE64_CHARACTER, equallocation, 0, true};
   58|      8|    }
   59|      8|    return {SUCCESS, full_input_length, 0};
   60|     16|  }
   61|  1.89k|  const chartype *const srcinit = src;
   62|  1.89k|  const char *const dstinit = dst;
   63|  1.89k|  const chartype *const srcend = src + srclen;
   64|       |
   65|  1.89k|  constexpr size_t block_size = 6;
   66|  1.89k|  static_assert(block_size >= 2, "block_size must be at least two");
   67|  1.89k|  char buffer[block_size * 64];
   68|  1.89k|  char *bufferptr = buffer;
   69|       |  // A wide block store writes 4 bytes past its 48. That is safe when the next
   70|       |  // store starts 48 bytes later. Pairs of clean blocks wide-store the first
   71|       |  // and end the second on byte 48. Anything shorter, or a block that is not
   72|       |  // clean, uses the exact store. The pair attempt is only worth it on a long
   73|       |  // input: a short one often fails the first block and then repeats that work.
   74|  1.89k|  if (srclen >= 512) {
  ------------------
  |  Branch (74:7): [True: 894, False: 1.00k]
  ------------------
   75|    894|    const chartype *const srcend128 = src + srclen - 128;
   76|  1.25k|    while (bufferptr == buffer && src <= srcend128) {
  ------------------
  |  Branch (76:12): [True: 1.25k, False: 0]
  |  Branch (76:35): [True: 1.24k, False: 8]
  ------------------
   77|  1.24k|      block64 b0(src);
   78|  1.24k|      uint64_t e0 = 0;
   79|  1.24k|      const uint64_t m0 =
   80|  1.24k|          b0.to_base64_mask<base64_url, ignore_garbage, default_or_url>(&e0);
   81|  1.24k|      if ((!ignore_garbage && e0) || m0 != 0) {
  ------------------
  |  Branch (81:12): [True: 1.24k, Folded]
  |  Branch (81:31): [True: 226, False: 1.01k]
  |  Branch (81:38): [True: 294, False: 722]
  ------------------
   82|    520|        break;
   83|    520|      }
   84|    722|      block64 b1(src + 64);
   85|    722|      uint64_t e1 = 0;
   86|    722|      const uint64_t m1 =
   87|    722|          b1.to_base64_mask<base64_url, ignore_garbage, default_or_url>(&e1);
   88|    722|      if ((!ignore_garbage && e1) || m1 != 0) {
  ------------------
  |  Branch (88:12): [True: 722, Folded]
  |  Branch (88:31): [True: 184, False: 538]
  |  Branch (88:38): [True: 182, False: 356]
  ------------------
   89|    366|        break;
   90|    366|      }
   91|    356|      b0.base64_decode_block(dst);
   92|    356|      b1.template base64_decode_block<true>(dst + 48);
   93|    356|      src += 128;
   94|    356|      dst += 96;
   95|    356|    }
   96|    894|  }
   97|  1.89k|  if (srclen >= 64) {
  ------------------
  |  Branch (97:7): [True: 1.59k, False: 302]
  ------------------
   98|  1.59k|    const chartype *const srcend64 = srcinit + srclen - 64;
   99|  58.9k|    while (src <= srcend64) {
  ------------------
  |  Branch (99:12): [True: 58.3k, False: 600]
  ------------------
  100|  58.3k|      block64 b(src);
  101|  58.3k|      uint64_t error = 0;
  102|  58.3k|      const uint64_t badcharmask =
  103|  58.3k|          b.to_base64_mask<base64_url, ignore_garbage, default_or_url>(&error);
  104|  58.3k|      if (!ignore_garbage && error) {
  ------------------
  |  Branch (104:11): [True: 58.3k, Folded]
  |  Branch (104:30): [True: 994, False: 57.3k]
  ------------------
  105|    994|        const size_t error_offset = trailing_zeroes(error);
  106|    994|        return {error_code::INVALID_BASE64_CHARACTER,
  107|    994|                size_t(src - srcinit + error_offset), size_t(dst - dstinit)};
  108|    994|      }
  109|  57.3k|      src += 64;
  110|  57.3k|      if (badcharmask != 0) {
  ------------------
  |  Branch (110:11): [True: 45.0k, False: 12.3k]
  ------------------
  111|  45.0k|        bufferptr += b.compress_block(badcharmask, bufferptr);
  112|  45.0k|      } else if (bufferptr != buffer) {
  ------------------
  |  Branch (112:18): [True: 11.8k, False: 580]
  ------------------
  113|  11.8k|        b.copy_block(bufferptr);
  114|  11.8k|        bufferptr += 64;
  115|  11.8k|      } else {
  116|    580|        b.template base64_decode_block<true>(dst);
  117|    580|        dst += 48;
  118|    580|      }
  119|  57.3k|      if (bufferptr >= (block_size - 1) * 64 + buffer) {
  ------------------
  |  Branch (119:11): [True: 10.8k, False: 46.5k]
  ------------------
  120|  54.4k|        for (size_t i = 0; i < (block_size - 2); i++) {
  ------------------
  |  Branch (120:28): [True: 43.5k, False: 10.8k]
  ------------------
  121|  43.5k|          base64_decode_block(dst, buffer + i * 64);
  122|  43.5k|          dst += 48;
  123|  43.5k|        }
  124|  10.8k|        base64_decode_block<true>(dst, buffer + (block_size - 2) * 64);
  125|  10.8k|        dst += 48;
  126|  10.8k|        std::memcpy(buffer, buffer + (block_size - 1) * 64,
  127|  10.8k|                    64); // 64 might be too much
  128|  10.8k|        bufferptr -= (block_size - 1) * 64;
  129|  10.8k|      }
  130|  57.3k|    }
  131|  1.59k|  }
  132|       |
  133|    902|  char *buffer_start = buffer;
  134|       |  // Optimization note: if this is almost full, then it is worth our
  135|       |  // time, otherwise, we should just decode directly.
  136|    902|  int last_block = (int)((bufferptr - buffer_start) % 64);
  137|    902|  if (last_block != 0 && srcend - src + last_block >= 64) {
  ------------------
  |  Branch (137:7): [True: 564, False: 338]
  |  Branch (137:26): [True: 106, False: 458]
  ------------------
  138|       |
  139|    712|    while ((bufferptr - buffer_start) % 64 != 0 && src < srcend) {
  ------------------
  |  Branch (139:12): [True: 670, False: 42]
  |  Branch (139:52): [True: 656, False: 14]
  ------------------
  140|    656|      uint8_t val = to_base64[uint8_t(*src)];
  141|    656|      *bufferptr = char(val);
  142|    656|      if (!ignore_garbage &&
  ------------------
  |  Branch (142:11): [True: 656, Folded]
  ------------------
  143|    656|          (!scalar::base64::is_eight_byte(*src) || val > 64)) {
  ------------------
  |  Branch (143:12): [True: 28, False: 628]
  |  Branch (143:52): [True: 22, False: 606]
  ------------------
  144|     50|        return {error_code::INVALID_BASE64_CHARACTER, size_t(src - srcinit),
  145|     50|                size_t(dst - dstinit)};
  146|     50|      }
  147|    606|      bufferptr += (val <= 63);
  148|    606|      src++;
  149|    606|    }
  150|    106|  }
  151|       |
  152|  1.22k|  for (; buffer_start + 64 <= bufferptr; buffer_start += 64) {
  ------------------
  |  Branch (152:10): [True: 372, False: 852]
  ------------------
  153|       |    // 8 payload bytes still in the buffer become 6 output bytes, which cover
  154|       |    // the 4-byte tail of a wide store. Fewer than that, and the tail can
  155|       |    // stick out past the real end.
  156|    372|    const size_t after = size_t(bufferptr - (buffer_start + 64));
  157|    372|    if (after >= 8) {
  ------------------
  |  Branch (157:9): [True: 312, False: 60]
  ------------------
  158|    312|      base64_decode_block(dst, buffer_start);
  159|    312|    } else {
  160|     60|      base64_decode_block<true>(dst, buffer_start);
  161|     60|    }
  162|    372|    dst += 48;
  163|    372|  }
  164|    852|  if ((bufferptr - buffer_start) % 64 != 0) {
  ------------------
  |  Branch (164:7): [True: 472, False: 380]
  ------------------
  165|  3.91k|    while (buffer_start + 4 < bufferptr) {
  ------------------
  |  Branch (165:12): [True: 3.44k, False: 472]
  ------------------
  166|  3.44k|      uint32_t triple = ((uint32_t(uint8_t(buffer_start[0])) << 3 * 6) +
  167|  3.44k|                         (uint32_t(uint8_t(buffer_start[1])) << 2 * 6) +
  168|  3.44k|                         (uint32_t(uint8_t(buffer_start[2])) << 1 * 6) +
  169|  3.44k|                         (uint32_t(uint8_t(buffer_start[3])) << 0 * 6))
  170|  3.44k|                        << 8;
  171|  3.44k|#if !SIMDUTF_IS_BIG_ENDIAN
  172|  3.44k|      triple = scalar::u32_swap_bytes(triple);
  173|  3.44k|#endif
  174|  3.44k|      std::memcpy(dst, &triple, 3);
  175|       |
  176|  3.44k|      dst += 3;
  177|  3.44k|      buffer_start += 4;
  178|  3.44k|    }
  179|    472|    if (buffer_start + 4 <= bufferptr) {
  ------------------
  |  Branch (179:9): [True: 120, False: 352]
  ------------------
  180|    120|      uint32_t triple = ((uint32_t(uint8_t(buffer_start[0])) << 3 * 6) +
  181|    120|                         (uint32_t(uint8_t(buffer_start[1])) << 2 * 6) +
  182|    120|                         (uint32_t(uint8_t(buffer_start[2])) << 1 * 6) +
  183|    120|                         (uint32_t(uint8_t(buffer_start[3])) << 0 * 6))
  184|    120|                        << 8;
  185|    120|#if !SIMDUTF_IS_BIG_ENDIAN
  186|    120|      triple = scalar::u32_swap_bytes(triple);
  187|    120|#endif
  188|    120|      std::memcpy(dst, &triple, 3);
  189|       |
  190|    120|      dst += 3;
  191|    120|      buffer_start += 4;
  192|    120|    }
  193|       |    // we may have 1, 2 or 3 bytes left and we need to decode them so let us
  194|       |    // backtrack
  195|    472|    int leftover = int(bufferptr - buffer_start);
  196|  1.19k|    while (leftover > 0) {
  ------------------
  |  Branch (196:12): [True: 722, False: 472]
  ------------------
  197|    722|      if (!ignore_garbage) {
  ------------------
  |  Branch (197:11): [True: 722, Folded]
  ------------------
  198|  6.57k|        while (to_base64[uint8_t(*(src - 1))] == 64) {
  ------------------
  |  Branch (198:16): [True: 5.85k, False: 722]
  ------------------
  199|  5.85k|          src--;
  200|  5.85k|        }
  201|    722|      } else {
  202|      0|        while (to_base64[uint8_t(*(src - 1))] >= 64) {
  ------------------
  |  Branch (202:16): [True: 0, False: 0]
  ------------------
  203|      0|          src--;
  204|      0|        }
  205|      0|      }
  206|    722|      src--;
  207|    722|      leftover--;
  208|    722|    }
  209|    472|  }
  210|    852|  if (src < srcend + equalsigns) {
  ------------------
  |  Branch (210:7): [True: 702, False: 150]
  ------------------
  211|    702|    full_result r = scalar::base64::base64_tail_decode(
  212|    702|        dst, src, srcend - src, equalsigns, options, last_chunk_options);
  213|    702|    r = scalar::base64::patch_tail_result(
  214|    702|        r, size_t(src - srcinit), size_t(dst - dstinit), equallocation,
  215|    702|        full_input_length, last_chunk_options);
  216|       |    // When is_partial(last_chunk_options) is true, we must either end with
  217|       |    // the end of the stream (beyond whitespace) or right after a non-ignorable
  218|       |    // character or at the very beginning of the stream.
  219|       |    // See https://tc39.es/proposal-arraybuffer-base64/spec/#sec-frombase64
  220|    702|    if (is_partial(last_chunk_options) && r.error == error_code::SUCCESS &&
  ------------------
  |  Branch (220:9): [True: 366, False: 336]
  |  Branch (220:43): [True: 288, False: 78]
  ------------------
  221|    288|        r.input_count < full_input_length) {
  ------------------
  |  Branch (221:9): [True: 260, False: 28]
  ------------------
  222|       |      // First check if we can extend the input to the end of the stream
  223|    560|      while (r.input_count < full_input_length &&
  ------------------
  |  Branch (223:14): [True: 556, False: 4]
  ------------------
  224|    556|             base64_ignorable(*(srcinit + r.input_count), options)) {
  ------------------
  |  Branch (224:14): [True: 300, False: 256]
  ------------------
  225|    300|        r.input_count++;
  226|    300|      }
  227|       |      // If we are still not at the end of the stream, then we must backtrack
  228|       |      // to the last non-ignorable character.
  229|    260|      if (r.input_count < full_input_length) {
  ------------------
  |  Branch (229:11): [True: 256, False: 4]
  ------------------
  230|  4.90k|        while (r.input_count > 0 &&
  ------------------
  |  Branch (230:16): [True: 4.84k, False: 66]
  ------------------
  231|  4.84k|               base64_ignorable(*(srcinit + r.input_count - 1), options)) {
  ------------------
  |  Branch (231:16): [True: 4.65k, False: 190]
  ------------------
  232|  4.65k|          r.input_count--;
  233|  4.65k|        }
  234|    256|      }
  235|    260|    }
  236|    702|    return r;
  237|    702|  }
  238|    150|  if (!ignore_garbage && equalsigns > 0) {
  ------------------
  |  Branch (238:7): [True: 150, Folded]
  |  Branch (238:26): [True: 0, False: 150]
  ------------------
  239|      0|    if ((size_t(dst - dstinit) % 3 == 0) ||
  ------------------
  |  Branch (239:9): [True: 0, False: 0]
  ------------------
  240|      0|        ((size_t(dst - dstinit) % 3) + 1 + equalsigns != 4)) {
  ------------------
  |  Branch (240:9): [True: 0, False: 0]
  ------------------
  241|      0|      return {INVALID_BASE64_CHARACTER, equallocation, size_t(dst - dstinit),
  242|      0|              true};
  243|      0|    }
  244|      0|  }
  245|    150|  return {SUCCESS, srclen, size_t(dst - dstinit)};
  246|    150|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_17block64C2EPKc:
  488|   397k|  simdutf_really_inline block64(const char *src) {
  489|   397k|    chunks[0] = _mm256_loadu_si256(reinterpret_cast<const __m256i *>(src));
  490|   397k|    chunks[1] = _mm256_loadu_si256(reinterpret_cast<const __m256i *>(src + 32));
  491|   397k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_17block6419base64_decode_blockILb0EEEvPc:
  520|  68.2k|  simdutf_really_inline void base64_decode_block(char *out) {
  521|  68.2k|    base64_decode(out, chunks[0]);
  522|  68.2k|    base64_decode<exact_tail>(out + 24, chunks[1]);
  523|  68.2k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113base64_decodeILb0EEEvPcDv4_x:
  450|   836k|simdutf_really_inline void base64_decode(char *out, __m256i str) {
  451|       |  // credit: aqrit
  452|   836k|  const __m256i pack_shuffle =
  453|   836k|      _mm256_setr_epi8(2, 1, 0, 6, 5, 4, 10, 9, 8, 14, 13, 12, -1, -1, -1, -1,
  454|   836k|                       2, 1, 0, 6, 5, 4, 10, 9, 8, 14, 13, 12, -1, -1, -1, -1);
  455|   836k|  const __m256i t0 = _mm256_maddubs_epi16(str, _mm256_set1_epi32(0x01400140));
  456|   836k|  const __m256i t1 = _mm256_madd_epi16(t0, _mm256_set1_epi32(0x00011000));
  457|   836k|  const __m256i t2 = _mm256_shuffle_epi8(t1, pack_shuffle);
  458|       |
  459|       |  // Store the output:
  460|   836k|  _mm_storeu_si128((__m128i *)out, _mm256_castsi256_si128(t2));
  461|   836k|  const __m128i hi = _mm256_extracti128_si256(t2, 1);
  462|       |  if constexpr (exact_tail) {
  463|       |    _mm_storel_epi64((__m128i *)(out + 12), hi);
  464|       |    const int32_t last = _mm_extract_epi32(hi, 2);
  465|       |    std::memcpy(out + 20, &last, sizeof(last));
  466|   836k|  } else {
  467|   836k|    _mm_storeu_si128((__m128i *)(out + 12), hi);
  468|   836k|  }
  469|   836k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_17block6419base64_decode_blockILb1EEEvPc:
  520|  84.2k|  simdutf_really_inline void base64_decode_block(char *out) {
  521|  84.2k|    base64_decode(out, chunks[0]);
  522|  84.2k|    base64_decode<exact_tail>(out + 24, chunks[1]);
  523|  84.2k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113base64_decodeILb1EEEvPcDv4_x:
  450|   152k|simdutf_really_inline void base64_decode(char *out, __m256i str) {
  451|       |  // credit: aqrit
  452|   152k|  const __m256i pack_shuffle =
  453|   152k|      _mm256_setr_epi8(2, 1, 0, 6, 5, 4, 10, 9, 8, 14, 13, 12, -1, -1, -1, -1,
  454|   152k|                       2, 1, 0, 6, 5, 4, 10, 9, 8, 14, 13, 12, -1, -1, -1, -1);
  455|   152k|  const __m256i t0 = _mm256_maddubs_epi16(str, _mm256_set1_epi32(0x01400140));
  456|   152k|  const __m256i t1 = _mm256_madd_epi16(t0, _mm256_set1_epi32(0x00011000));
  457|   152k|  const __m256i t2 = _mm256_shuffle_epi8(t1, pack_shuffle);
  458|       |
  459|       |  // Store the output:
  460|   152k|  _mm_storeu_si128((__m128i *)out, _mm256_castsi256_si128(t2));
  461|   152k|  const __m128i hi = _mm256_extracti128_si256(t2, 1);
  462|   152k|  if constexpr (exact_tail) {
  463|   152k|    _mm_storel_epi64((__m128i *)(out + 12), hi);
  464|   152k|    const int32_t last = _mm_extract_epi32(hi, 2);
  465|   152k|    std::memcpy(out + 20, &last, sizeof(last));
  466|       |  } else {
  467|       |    _mm_storeu_si128((__m128i *)(out + 12), hi);
  468|       |  }
  469|   152k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_17block6414compress_blockEmPc:
  662|   164k|  simdutf_really_inline uint64_t compress_block(uint64_t mask, char *output) {
  663|   164k|    if (is_power_of_two(mask)) {
  ------------------
  |  Branch (663:9): [True: 124k, False: 40.1k]
  ------------------
  664|   124k|      return compress_block_single(mask, output);
  665|   124k|    }
  666|       |
  667|  40.1k|    uint64_t nmask = ~mask;
  668|  40.1k|    compress(chunks[0], uint32_t(mask), output);
  669|  40.1k|    compress(chunks[1], uint32_t(mask >> 32),
  670|  40.1k|             output + count_ones(nmask & 0xFFFFFFFF));
  671|  40.1k|    return count_ones(nmask);
  672|   164k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_17block6421compress_block_singleEmPc:
  675|   124k|                                                     char *output) {
  676|   124k|    const size_t pos64 = trailing_zeroes(mask);
  677|   124k|    const int8_t pos = pos64 & 0xf;
  678|   124k|    switch (pos64 >> 4) {
  ------------------
  |  Branch (678:13): [True: 124k, False: 0]
  ------------------
  679|  31.0k|    case 0b00: {
  ------------------
  |  Branch (679:5): [True: 31.0k, False: 93.6k]
  ------------------
  680|  31.0k|      const __m128i lane0 = _mm256_extracti128_si256(chunks[0], 0);
  681|  31.0k|      const __m128i lane1 = _mm256_extracti128_si256(chunks[0], 1);
  682|       |
  683|  31.0k|      const __m128i v0 = _mm_set1_epi8(char(pos - 1));
  684|  31.0k|      const __m128i v1 =
  685|  31.0k|          _mm_setr_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
  686|  31.0k|      const __m128i v2 = _mm_cmpgt_epi8(v1, v0);
  687|  31.0k|      const __m128i sh = _mm_sub_epi8(v1, v2);
  688|  31.0k|      const __m128i compressed = _mm_shuffle_epi8(lane0, sh);
  689|       |
  690|  31.0k|      _mm_storeu_si128((__m128i *)(output + 0 * 16), compressed);
  691|  31.0k|      _mm_storeu_si128((__m128i *)(output + 1 * 16 - 1), lane1);
  692|  31.0k|      _mm256_storeu_si256((__m256i *)(output + 2 * 16 - 1), chunks[1]);
  693|  31.0k|    } break;
  694|  32.2k|    case 0b01: {
  ------------------
  |  Branch (694:5): [True: 32.2k, False: 92.4k]
  ------------------
  695|  32.2k|      const __m128i lane0 = _mm256_extracti128_si256(chunks[0], 0);
  696|  32.2k|      const __m128i lane1 = _mm256_extracti128_si256(chunks[0], 1);
  697|  32.2k|      _mm_storeu_si128((__m128i *)(output + 0 * 16), lane0);
  698|       |
  699|  32.2k|      const __m128i v0 = _mm_set1_epi8(char(pos - 1));
  700|  32.2k|      const __m128i v1 =
  701|  32.2k|          _mm_setr_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
  702|  32.2k|      const __m128i v2 = _mm_cmpgt_epi8(v1, v0);
  703|  32.2k|      const __m128i sh = _mm_sub_epi8(v1, v2);
  704|  32.2k|      const __m128i compressed = _mm_shuffle_epi8(lane1, sh);
  705|       |
  706|  32.2k|      _mm_storeu_si128((__m128i *)(output + 1 * 16), compressed);
  707|  32.2k|      _mm256_storeu_si256((__m256i *)(output + 2 * 16 - 1), chunks[1]);
  708|  32.2k|    } break;
  709|  32.1k|    case 0b10: {
  ------------------
  |  Branch (709:5): [True: 32.1k, False: 92.5k]
  ------------------
  710|  32.1k|      const __m128i lane2 = _mm256_extracti128_si256(chunks[1], 0);
  711|  32.1k|      const __m128i lane3 = _mm256_extracti128_si256(chunks[1], 1);
  712|       |
  713|  32.1k|      _mm256_storeu_si256((__m256i *)(output + 0 * 16), chunks[0]);
  714|       |
  715|  32.1k|      const __m128i v0 = _mm_set1_epi8(char(pos - 1));
  716|  32.1k|      const __m128i v1 =
  717|  32.1k|          _mm_setr_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
  718|  32.1k|      const __m128i v2 = _mm_cmpgt_epi8(v1, v0);
  719|  32.1k|      const __m128i sh = _mm_sub_epi8(v1, v2);
  720|  32.1k|      const __m128i compressed = _mm_shuffle_epi8(lane2, sh);
  721|       |
  722|  32.1k|      _mm_storeu_si128((__m128i *)(output + 2 * 16), compressed);
  723|  32.1k|      _mm_storeu_si128((__m128i *)(output + 3 * 16 - 1), lane3);
  724|  32.1k|    } break;
  725|  29.2k|    case 0b11: {
  ------------------
  |  Branch (725:5): [True: 29.2k, False: 95.4k]
  ------------------
  726|  29.2k|      const __m128i lane2 = _mm256_extracti128_si256(chunks[1], 0);
  727|  29.2k|      const __m128i lane3 = _mm256_extracti128_si256(chunks[1], 1);
  728|       |
  729|  29.2k|      _mm256_storeu_si256((__m256i *)(output + 0 * 16), chunks[0]);
  730|  29.2k|      _mm_storeu_si128((__m128i *)(output + 2 * 16), lane2);
  731|       |
  732|  29.2k|      const __m128i v0 = _mm_set1_epi8(char(pos - 1));
  733|  29.2k|      const __m128i v1 =
  734|  29.2k|          _mm_setr_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
  735|  29.2k|      const __m128i v2 = _mm_cmpgt_epi8(v1, v0);
  736|  29.2k|      const __m128i sh = _mm_sub_epi8(v1, v2);
  737|  29.2k|      const __m128i compressed = _mm_shuffle_epi8(lane3, sh);
  738|       |
  739|  29.2k|      _mm_storeu_si128((__m128i *)(output + 3 * 16), compressed);
  740|  29.2k|    } break;
  741|   124k|    }
  742|       |
  743|   124k|    return 63;
  744|   124k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_18compressIvEEvDv4_xjPc:
  435|  80.2k|simdutf_really_inline void compress(__m256i data, uint32_t mask, char *output) {
  436|  80.2k|  if (mask == 0) {
  ------------------
  |  Branch (436:7): [True: 16.4k, False: 63.8k]
  ------------------
  437|  16.4k|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(output), data);
  438|  16.4k|    return;
  439|  16.4k|  }
  440|  63.8k|  compress(_mm256_castsi256_si128(data), uint16_t(mask), output);
  441|       |  compress(_mm256_extracti128_si256(data, 1), uint16_t(mask >> 16),
  442|  63.8k|           output + count_ones(~mask & 0xFFFF));
  443|  63.8k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_18compressEDv2_xtPc:
  398|   127k|static inline void compress(__m128i data, uint16_t mask, char *output) {
  399|   127k|  if (mask == 0) {
  ------------------
  |  Branch (399:7): [True: 42.4k, False: 85.1k]
  ------------------
  400|  42.4k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(output), data);
  401|  42.4k|    return;
  402|  42.4k|  }
  403|       |  // this particular implementation was inspired by work done by @animetosho
  404|       |  // we do it in two steps, first 8 bytes and then second 8 bytes
  405|  85.1k|  uint8_t mask1 = uint8_t(mask);      // least significant 8 bits
  406|  85.1k|  uint8_t mask2 = uint8_t(mask >> 8); // most significant 8 bits
  407|       |  // next line just loads the 64-bit values thintable_epi8[mask1] and
  408|       |  // thintable_epi8[mask2] into a 128-bit register, using only
  409|       |  // two instructions on most compilers.
  410|       |
  411|  85.1k|  __m128i shufmask = _mm_set_epi64x(tables::base64::thintable_epi8[mask2],
  412|  85.1k|                                    tables::base64::thintable_epi8[mask1]);
  413|       |  // we increment by 0x08 the second half of the mask
  414|  85.1k|  shufmask =
  415|  85.1k|      _mm_add_epi8(shufmask, _mm_set_epi32(0x08080808, 0x08080808, 0, 0));
  416|       |  // this is the version "nearly pruned"
  417|  85.1k|  __m128i pruned = _mm_shuffle_epi8(data, shufmask);
  418|       |  // we still need to put the two halves together.
  419|       |  // we compute the popcount of the first half:
  420|  85.1k|  int pop1 = tables::base64::BitsSetTable256mul2[mask1];
  421|       |  // then load the corresponding mask, what it does is to write
  422|       |  // only the first pop1 bytes from the first 8 bytes, and then
  423|       |  // it fills in with the bytes from the second 8 bytes + some filling
  424|       |  // at the end.
  425|  85.1k|  __m128i compactmask = _mm_loadu_si128(reinterpret_cast<const __m128i *>(
  426|  85.1k|      tables::base64::pshufb_combine_table + pop1 * 8));
  427|  85.1k|  __m128i answer = _mm_shuffle_epi8(pruned, compactmask);
  428|       |
  429|  85.1k|  _mm_storeu_si128(reinterpret_cast<__m128i *>(output), answer);
  430|  85.1k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_17block6410copy_blockEPc:
  513|   187k|  simdutf_really_inline void copy_block(char *output) {
  514|   187k|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(output), chunks[0]);
  515|   187k|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(output + 32), chunks[1]);
  516|   187k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_119base64_decode_blockILb0EEEvPcPKc:
  472|   273k|simdutf_really_inline void base64_decode_block(char *out, const char *src) {
  473|   273k|  base64_decode(out,
  474|   273k|                _mm256_loadu_si256(reinterpret_cast<const __m256i *>(src)));
  475|   273k|  base64_decode<exact_tail>(
  476|   273k|      out + 24,
  477|   273k|      _mm256_loadu_si256(reinterpret_cast<const __m256i *>(src + 32)));
  478|   273k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_119base64_decode_blockILb1EEEvPcPKc:
  472|  68.3k|simdutf_really_inline void base64_decode_block(char *out, const char *src) {
  473|  68.3k|  base64_decode(out,
  474|  68.3k|                _mm256_loadu_si256(reinterpret_cast<const __m256i *>(src)));
  475|  68.3k|  base64_decode<exact_tail>(
  476|  68.3k|      out + 24,
  477|  68.3k|      _mm256_loadu_si256(reinterpret_cast<const __m256i *>(src + 32)));
  478|  68.3k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_17block6414to_base64_maskILb1ELb0ELb0EEEmPm:
  526|   152k|  simdutf_really_inline uint64_t to_base64_mask(uint64_t *error) {
  527|   152k|    uint32_t err0 = 0;
  528|   152k|    uint32_t err1 = 0;
  529|   152k|    uint64_t m0 = to_base64_mask<base64_url, ignore_garbage, default_or_url>(
  530|   152k|        &chunks[0], &err0);
  531|   152k|    uint64_t m1 = to_base64_mask<base64_url, ignore_garbage, default_or_url>(
  532|   152k|        &chunks[1], &err1);
  533|   152k|    if (!ignore_garbage) {
  ------------------
  |  Branch (533:9): [True: 152k, Folded]
  ------------------
  534|   152k|      *error = err0 | ((uint64_t)err1 << 32);
  535|   152k|    }
  536|   152k|    return m0 | (m1 << 32);
  537|   152k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_17block6414to_base64_maskILb1ELb0ELb0EEEjPDv4_xPj:
  540|   305k|  simdutf_really_inline uint32_t to_base64_mask(__m256i *src, uint32_t *error) {
  541|   305k|    const __m256i ascii_space_tbl =
  542|   305k|        _mm256_setr_epi8(0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9, 0xa,
  543|   305k|                         0x0, 0xc, 0xd, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0,
  544|   305k|                         0x0, 0x0, 0x0, 0x9, 0xa, 0x0, 0xc, 0xd, 0x0, 0x0);
  545|       |    // credit: aqrit
  546|   305k|    __m256i delta_asso;
  547|   305k|    if (default_or_url) {
  ------------------
  |  Branch (547:9): [Folded, False: 305k]
  ------------------
  548|      0|      delta_asso = _mm256_setr_epi8(
  549|      0|          0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
  550|      0|          0x00, 0x00, 0x11, 0x00, 0x16, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  551|      0|          0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x16);
  552|   305k|    } else if (base64_url) {
  ------------------
  |  Branch (552:16): [True: 305k, Folded]
  ------------------
  553|   305k|      delta_asso = _mm256_setr_epi8(0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0,
  554|   305k|                                    0x0, 0x0, 0x0, 0x0, 0xF, 0x0, 0xF, 0x1, 0x1,
  555|   305k|                                    0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0,
  556|   305k|                                    0x0, 0x0, 0xF, 0x0, 0xF);
  557|   305k|    } else {
  558|      0|      delta_asso = _mm256_setr_epi8(
  559|      0|          0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
  560|      0|          0x00, 0x00, 0x0F, 0x00, 0x0F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  561|      0|          0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x0F);
  562|      0|    }
  563|       |
  564|   305k|    __m256i delta_values;
  565|   305k|    if (default_or_url) {
  ------------------
  |  Branch (565:9): [Folded, False: 305k]
  ------------------
  566|      0|      delta_values = _mm256_setr_epi8(
  567|      0|          uint8_t(0xBF), uint8_t(0xE0), uint8_t(0xB9), uint8_t(0x13),
  568|      0|          uint8_t(0x04), uint8_t(0xBF), uint8_t(0xBF), uint8_t(0xB9),
  569|      0|          uint8_t(0xB9), uint8_t(0x00), uint8_t(0xFF), uint8_t(0x11),
  570|      0|          uint8_t(0xFF), uint8_t(0xBF), uint8_t(0x10), uint8_t(0xB9),
  571|      0|          uint8_t(0xBF), uint8_t(0xE0), uint8_t(0xB9), uint8_t(0x13),
  572|      0|          uint8_t(0x04), uint8_t(0xBF), uint8_t(0xBF), uint8_t(0xB9),
  573|      0|          uint8_t(0xB9), uint8_t(0x00), uint8_t(0xFF), uint8_t(0x11),
  574|      0|          uint8_t(0xFF), uint8_t(0xBF), uint8_t(0x10), uint8_t(0xB9));
  575|   305k|    } else if (base64_url) {
  ------------------
  |  Branch (575:16): [True: 305k, Folded]
  ------------------
  576|   305k|      delta_values = _mm256_setr_epi8(
  577|   305k|          0x0, 0x0, 0x0, 0x13, 0x4, uint8_t(0xBF), uint8_t(0xBF), uint8_t(0xB9),
  578|   305k|          uint8_t(0xB9), 0x0, 0x11, uint8_t(0xC3), uint8_t(0xBF), uint8_t(0xE0),
  579|   305k|          uint8_t(0xB9), uint8_t(0xB9), 0x0, 0x0, 0x0, 0x13, 0x4, uint8_t(0xBF),
  580|   305k|          uint8_t(0xBF), uint8_t(0xB9), uint8_t(0xB9), 0x0, 0x11, uint8_t(0xC3),
  581|   305k|          uint8_t(0xBF), uint8_t(0xE0), uint8_t(0xB9), uint8_t(0xB9));
  582|   305k|    } else {
  583|      0|      delta_values = _mm256_setr_epi8(
  584|      0|          int8_t(0x00), int8_t(0x00), int8_t(0x00), int8_t(0x13), int8_t(0x04),
  585|      0|          int8_t(0xBF), int8_t(0xBF), int8_t(0xB9), int8_t(0xB9), int8_t(0x00),
  586|      0|          int8_t(0x10), int8_t(0xC3), int8_t(0xBF), int8_t(0xBF), int8_t(0xB9),
  587|      0|          int8_t(0xB9), int8_t(0x00), int8_t(0x00), int8_t(0x00), int8_t(0x13),
  588|      0|          int8_t(0x04), int8_t(0xBF), int8_t(0xBF), int8_t(0xB9), int8_t(0xB9),
  589|      0|          int8_t(0x00), int8_t(0x10), int8_t(0xC3), int8_t(0xBF), int8_t(0xBF),
  590|      0|          int8_t(0xB9), int8_t(0xB9));
  591|      0|    }
  592|       |
  593|   305k|    __m256i check_asso;
  594|   305k|    if (default_or_url) {
  ------------------
  |  Branch (594:9): [Folded, False: 305k]
  ------------------
  595|      0|      check_asso = _mm256_setr_epi8(
  596|      0|          0x0D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03,
  597|      0|          0x07, 0x0B, 0x0E, 0x0B, 0x06, 0x0D, 0x01, 0x01, 0x01, 0x01, 0x01,
  598|      0|          0x01, 0x01, 0x01, 0x01, 0x03, 0x07, 0x0B, 0x0E, 0x0B, 0x06);
  599|   305k|    } else if (base64_url) {
  ------------------
  |  Branch (599:16): [True: 305k, Folded]
  ------------------
  600|   305k|      check_asso = _mm256_setr_epi8(0xD, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1,
  601|   305k|                                    0x1, 0x3, 0x7, 0xB, 0xE, 0xB, 0x6, 0xD, 0x1,
  602|   305k|                                    0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x3,
  603|   305k|                                    0x7, 0xB, 0xE, 0xB, 0x6);
  604|   305k|    } else {
  605|      0|      check_asso = _mm256_setr_epi8(
  606|      0|          0x0D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03,
  607|      0|          0x07, 0x0B, 0x0B, 0x0B, 0x0F, 0x0D, 0x01, 0x01, 0x01, 0x01, 0x01,
  608|      0|          0x01, 0x01, 0x01, 0x01, 0x03, 0x07, 0x0B, 0x0B, 0x0B, 0x0F);
  609|      0|    }
  610|   305k|    __m256i check_values;
  611|   305k|    if (default_or_url) {
  ------------------
  |  Branch (611:9): [Folded, False: 305k]
  ------------------
  612|      0|      check_values = _mm256_setr_epi8(
  613|      0|          uint8_t(0x80), uint8_t(0x80), uint8_t(0x80), uint8_t(0x80),
  614|      0|          uint8_t(0xCF), uint8_t(0xBF), uint8_t(0xD5), uint8_t(0xA6),
  615|      0|          uint8_t(0xB5), uint8_t(0xA1), uint8_t(0x00), uint8_t(0x80),
  616|      0|          uint8_t(0x00), uint8_t(0x80), uint8_t(0x00), uint8_t(0x80),
  617|      0|          uint8_t(0x80), uint8_t(0x80), uint8_t(0x80), uint8_t(0x80),
  618|      0|          uint8_t(0xCF), uint8_t(0xBF), uint8_t(0xD5), uint8_t(0xA6),
  619|      0|          uint8_t(0xB5), uint8_t(0xA1), uint8_t(0x00), uint8_t(0x80),
  620|      0|          uint8_t(0x00), uint8_t(0x80), uint8_t(0x00), uint8_t(0x80));
  621|   305k|    } else if (base64_url) {
  ------------------
  |  Branch (621:16): [True: 305k, Folded]
  ------------------
  622|   305k|      check_values = _mm256_setr_epi8(
  623|   305k|          uint8_t(0x80), uint8_t(0x80), uint8_t(0x80), uint8_t(0x80),
  624|   305k|          uint8_t(0xCF), uint8_t(0xBF), uint8_t(0xB6), uint8_t(0xA6),
  625|   305k|          uint8_t(0xB5), uint8_t(0xA1), 0x0, uint8_t(0x80), 0x0, uint8_t(0x80),
  626|   305k|          0x0, uint8_t(0x80), uint8_t(0x80), uint8_t(0x80), uint8_t(0x80),
  627|   305k|          uint8_t(0x80), uint8_t(0xCF), uint8_t(0xBF), uint8_t(0xB6),
  628|   305k|          uint8_t(0xA6), uint8_t(0xB5), uint8_t(0xA1), 0x0, uint8_t(0x80), 0x0,
  629|   305k|          uint8_t(0x80), 0x0, uint8_t(0x80));
  630|   305k|    } else {
  631|      0|      check_values = _mm256_setr_epi8(
  632|      0|          int8_t(0x80), int8_t(0x80), int8_t(0x80), int8_t(0x80), int8_t(0xCF),
  633|      0|          int8_t(0xBF), int8_t(0xD5), int8_t(0xA6), int8_t(0xB5), int8_t(0x86),
  634|      0|          int8_t(0xD1), int8_t(0x80), int8_t(0xB1), int8_t(0x80), int8_t(0x91),
  635|      0|          int8_t(0x80), int8_t(0x80), int8_t(0x80), int8_t(0x80), int8_t(0x80),
  636|      0|          int8_t(0xCF), int8_t(0xBF), int8_t(0xD5), int8_t(0xA6), int8_t(0xB5),
  637|      0|          int8_t(0x86), int8_t(0xD1), int8_t(0x80), int8_t(0xB1), int8_t(0x80),
  638|      0|          int8_t(0x91), int8_t(0x80));
  639|      0|    }
  640|   305k|    const __m256i shifted = _mm256_srli_epi32(*src, 3);
  641|   305k|    __m256i delta_hash =
  642|   305k|        _mm256_avg_epu8(_mm256_shuffle_epi8(delta_asso, *src), shifted);
  643|   305k|    if (default_or_url) {
  ------------------
  |  Branch (643:9): [Folded, False: 305k]
  ------------------
  644|      0|      delta_hash = _mm256_and_si256(delta_hash, _mm256_set1_epi8(0xf));
  645|      0|    }
  646|   305k|    const __m256i check_hash =
  647|   305k|        _mm256_avg_epu8(_mm256_shuffle_epi8(check_asso, *src), shifted);
  648|   305k|    const __m256i out =
  649|   305k|        _mm256_adds_epi8(_mm256_shuffle_epi8(delta_values, delta_hash), *src);
  650|   305k|    const __m256i chk =
  651|   305k|        _mm256_adds_epi8(_mm256_shuffle_epi8(check_values, check_hash), *src);
  652|   305k|    const int mask = _mm256_movemask_epi8(chk);
  653|   305k|    if (!ignore_garbage && mask) {
  ------------------
  |  Branch (653:9): [True: 305k, Folded]
  |  Branch (653:28): [True: 87.4k, False: 218k]
  ------------------
  654|  87.4k|      __m256i ascii_space =
  655|  87.4k|          _mm256_cmpeq_epi8(_mm256_shuffle_epi8(ascii_space_tbl, *src), *src);
  656|  87.4k|      *error = (mask ^ _mm256_movemask_epi8(ascii_space));
  657|  87.4k|    }
  658|   305k|    *src = out;
  659|   305k|    return (uint32_t)mask;
  660|   305k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_17block6414to_base64_maskILb0ELb0ELb0EEEmPm:
  526|   361k|  simdutf_really_inline uint64_t to_base64_mask(uint64_t *error) {
  527|   361k|    uint32_t err0 = 0;
  528|   361k|    uint32_t err1 = 0;
  529|   361k|    uint64_t m0 = to_base64_mask<base64_url, ignore_garbage, default_or_url>(
  530|   361k|        &chunks[0], &err0);
  531|   361k|    uint64_t m1 = to_base64_mask<base64_url, ignore_garbage, default_or_url>(
  532|   361k|        &chunks[1], &err1);
  533|   361k|    if (!ignore_garbage) {
  ------------------
  |  Branch (533:9): [True: 361k, Folded]
  ------------------
  534|   361k|      *error = err0 | ((uint64_t)err1 << 32);
  535|   361k|    }
  536|   361k|    return m0 | (m1 << 32);
  537|   361k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_17block6414to_base64_maskILb0ELb0ELb0EEEjPDv4_xPj:
  540|   723k|  simdutf_really_inline uint32_t to_base64_mask(__m256i *src, uint32_t *error) {
  541|   723k|    const __m256i ascii_space_tbl =
  542|   723k|        _mm256_setr_epi8(0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9, 0xa,
  543|   723k|                         0x0, 0xc, 0xd, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0,
  544|   723k|                         0x0, 0x0, 0x0, 0x9, 0xa, 0x0, 0xc, 0xd, 0x0, 0x0);
  545|       |    // credit: aqrit
  546|   723k|    __m256i delta_asso;
  547|   723k|    if (default_or_url) {
  ------------------
  |  Branch (547:9): [Folded, False: 723k]
  ------------------
  548|      0|      delta_asso = _mm256_setr_epi8(
  549|      0|          0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
  550|      0|          0x00, 0x00, 0x11, 0x00, 0x16, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  551|      0|          0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x16);
  552|   723k|    } else if (base64_url) {
  ------------------
  |  Branch (552:16): [Folded, False: 723k]
  ------------------
  553|      0|      delta_asso = _mm256_setr_epi8(0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0,
  554|      0|                                    0x0, 0x0, 0x0, 0x0, 0xF, 0x0, 0xF, 0x1, 0x1,
  555|      0|                                    0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0,
  556|      0|                                    0x0, 0x0, 0xF, 0x0, 0xF);
  557|   723k|    } else {
  558|   723k|      delta_asso = _mm256_setr_epi8(
  559|   723k|          0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
  560|   723k|          0x00, 0x00, 0x0F, 0x00, 0x0F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  561|   723k|          0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x0F);
  562|   723k|    }
  563|       |
  564|   723k|    __m256i delta_values;
  565|   723k|    if (default_or_url) {
  ------------------
  |  Branch (565:9): [Folded, False: 723k]
  ------------------
  566|      0|      delta_values = _mm256_setr_epi8(
  567|      0|          uint8_t(0xBF), uint8_t(0xE0), uint8_t(0xB9), uint8_t(0x13),
  568|      0|          uint8_t(0x04), uint8_t(0xBF), uint8_t(0xBF), uint8_t(0xB9),
  569|      0|          uint8_t(0xB9), uint8_t(0x00), uint8_t(0xFF), uint8_t(0x11),
  570|      0|          uint8_t(0xFF), uint8_t(0xBF), uint8_t(0x10), uint8_t(0xB9),
  571|      0|          uint8_t(0xBF), uint8_t(0xE0), uint8_t(0xB9), uint8_t(0x13),
  572|      0|          uint8_t(0x04), uint8_t(0xBF), uint8_t(0xBF), uint8_t(0xB9),
  573|      0|          uint8_t(0xB9), uint8_t(0x00), uint8_t(0xFF), uint8_t(0x11),
  574|      0|          uint8_t(0xFF), uint8_t(0xBF), uint8_t(0x10), uint8_t(0xB9));
  575|   723k|    } else if (base64_url) {
  ------------------
  |  Branch (575:16): [Folded, False: 723k]
  ------------------
  576|      0|      delta_values = _mm256_setr_epi8(
  577|      0|          0x0, 0x0, 0x0, 0x13, 0x4, uint8_t(0xBF), uint8_t(0xBF), uint8_t(0xB9),
  578|      0|          uint8_t(0xB9), 0x0, 0x11, uint8_t(0xC3), uint8_t(0xBF), uint8_t(0xE0),
  579|      0|          uint8_t(0xB9), uint8_t(0xB9), 0x0, 0x0, 0x0, 0x13, 0x4, uint8_t(0xBF),
  580|      0|          uint8_t(0xBF), uint8_t(0xB9), uint8_t(0xB9), 0x0, 0x11, uint8_t(0xC3),
  581|      0|          uint8_t(0xBF), uint8_t(0xE0), uint8_t(0xB9), uint8_t(0xB9));
  582|   723k|    } else {
  583|   723k|      delta_values = _mm256_setr_epi8(
  584|   723k|          int8_t(0x00), int8_t(0x00), int8_t(0x00), int8_t(0x13), int8_t(0x04),
  585|   723k|          int8_t(0xBF), int8_t(0xBF), int8_t(0xB9), int8_t(0xB9), int8_t(0x00),
  586|   723k|          int8_t(0x10), int8_t(0xC3), int8_t(0xBF), int8_t(0xBF), int8_t(0xB9),
  587|   723k|          int8_t(0xB9), int8_t(0x00), int8_t(0x00), int8_t(0x00), int8_t(0x13),
  588|   723k|          int8_t(0x04), int8_t(0xBF), int8_t(0xBF), int8_t(0xB9), int8_t(0xB9),
  589|   723k|          int8_t(0x00), int8_t(0x10), int8_t(0xC3), int8_t(0xBF), int8_t(0xBF),
  590|   723k|          int8_t(0xB9), int8_t(0xB9));
  591|   723k|    }
  592|       |
  593|   723k|    __m256i check_asso;
  594|   723k|    if (default_or_url) {
  ------------------
  |  Branch (594:9): [Folded, False: 723k]
  ------------------
  595|      0|      check_asso = _mm256_setr_epi8(
  596|      0|          0x0D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03,
  597|      0|          0x07, 0x0B, 0x0E, 0x0B, 0x06, 0x0D, 0x01, 0x01, 0x01, 0x01, 0x01,
  598|      0|          0x01, 0x01, 0x01, 0x01, 0x03, 0x07, 0x0B, 0x0E, 0x0B, 0x06);
  599|   723k|    } else if (base64_url) {
  ------------------
  |  Branch (599:16): [Folded, False: 723k]
  ------------------
  600|      0|      check_asso = _mm256_setr_epi8(0xD, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1,
  601|      0|                                    0x1, 0x3, 0x7, 0xB, 0xE, 0xB, 0x6, 0xD, 0x1,
  602|      0|                                    0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x3,
  603|      0|                                    0x7, 0xB, 0xE, 0xB, 0x6);
  604|   723k|    } else {
  605|   723k|      check_asso = _mm256_setr_epi8(
  606|   723k|          0x0D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03,
  607|   723k|          0x07, 0x0B, 0x0B, 0x0B, 0x0F, 0x0D, 0x01, 0x01, 0x01, 0x01, 0x01,
  608|   723k|          0x01, 0x01, 0x01, 0x01, 0x03, 0x07, 0x0B, 0x0B, 0x0B, 0x0F);
  609|   723k|    }
  610|   723k|    __m256i check_values;
  611|   723k|    if (default_or_url) {
  ------------------
  |  Branch (611:9): [Folded, False: 723k]
  ------------------
  612|      0|      check_values = _mm256_setr_epi8(
  613|      0|          uint8_t(0x80), uint8_t(0x80), uint8_t(0x80), uint8_t(0x80),
  614|      0|          uint8_t(0xCF), uint8_t(0xBF), uint8_t(0xD5), uint8_t(0xA6),
  615|      0|          uint8_t(0xB5), uint8_t(0xA1), uint8_t(0x00), uint8_t(0x80),
  616|      0|          uint8_t(0x00), uint8_t(0x80), uint8_t(0x00), uint8_t(0x80),
  617|      0|          uint8_t(0x80), uint8_t(0x80), uint8_t(0x80), uint8_t(0x80),
  618|      0|          uint8_t(0xCF), uint8_t(0xBF), uint8_t(0xD5), uint8_t(0xA6),
  619|      0|          uint8_t(0xB5), uint8_t(0xA1), uint8_t(0x00), uint8_t(0x80),
  620|      0|          uint8_t(0x00), uint8_t(0x80), uint8_t(0x00), uint8_t(0x80));
  621|   723k|    } else if (base64_url) {
  ------------------
  |  Branch (621:16): [Folded, False: 723k]
  ------------------
  622|      0|      check_values = _mm256_setr_epi8(
  623|      0|          uint8_t(0x80), uint8_t(0x80), uint8_t(0x80), uint8_t(0x80),
  624|      0|          uint8_t(0xCF), uint8_t(0xBF), uint8_t(0xB6), uint8_t(0xA6),
  625|      0|          uint8_t(0xB5), uint8_t(0xA1), 0x0, uint8_t(0x80), 0x0, uint8_t(0x80),
  626|      0|          0x0, uint8_t(0x80), uint8_t(0x80), uint8_t(0x80), uint8_t(0x80),
  627|      0|          uint8_t(0x80), uint8_t(0xCF), uint8_t(0xBF), uint8_t(0xB6),
  628|      0|          uint8_t(0xA6), uint8_t(0xB5), uint8_t(0xA1), 0x0, uint8_t(0x80), 0x0,
  629|      0|          uint8_t(0x80), 0x0, uint8_t(0x80));
  630|   723k|    } else {
  631|   723k|      check_values = _mm256_setr_epi8(
  632|   723k|          int8_t(0x80), int8_t(0x80), int8_t(0x80), int8_t(0x80), int8_t(0xCF),
  633|   723k|          int8_t(0xBF), int8_t(0xD5), int8_t(0xA6), int8_t(0xB5), int8_t(0x86),
  634|   723k|          int8_t(0xD1), int8_t(0x80), int8_t(0xB1), int8_t(0x80), int8_t(0x91),
  635|   723k|          int8_t(0x80), int8_t(0x80), int8_t(0x80), int8_t(0x80), int8_t(0x80),
  636|   723k|          int8_t(0xCF), int8_t(0xBF), int8_t(0xD5), int8_t(0xA6), int8_t(0xB5),
  637|   723k|          int8_t(0x86), int8_t(0xD1), int8_t(0x80), int8_t(0xB1), int8_t(0x80),
  638|   723k|          int8_t(0x91), int8_t(0x80));
  639|   723k|    }
  640|   723k|    const __m256i shifted = _mm256_srli_epi32(*src, 3);
  641|   723k|    __m256i delta_hash =
  642|   723k|        _mm256_avg_epu8(_mm256_shuffle_epi8(delta_asso, *src), shifted);
  643|   723k|    if (default_or_url) {
  ------------------
  |  Branch (643:9): [Folded, False: 723k]
  ------------------
  644|      0|      delta_hash = _mm256_and_si256(delta_hash, _mm256_set1_epi8(0xf));
  645|      0|    }
  646|   723k|    const __m256i check_hash =
  647|   723k|        _mm256_avg_epu8(_mm256_shuffle_epi8(check_asso, *src), shifted);
  648|   723k|    const __m256i out =
  649|   723k|        _mm256_adds_epi8(_mm256_shuffle_epi8(delta_values, delta_hash), *src);
  650|   723k|    const __m256i chk =
  651|   723k|        _mm256_adds_epi8(_mm256_shuffle_epi8(check_values, check_hash), *src);
  652|   723k|    const int mask = _mm256_movemask_epi8(chk);
  653|   723k|    if (!ignore_garbage && mask) {
  ------------------
  |  Branch (653:9): [True: 723k, Folded]
  |  Branch (653:28): [True: 114k, False: 608k]
  ------------------
  654|   114k|      __m256i ascii_space =
  655|   114k|          _mm256_cmpeq_epi8(_mm256_shuffle_epi8(ascii_space_tbl, *src), *src);
  656|   114k|      *error = (mask ^ _mm256_movemask_epi8(ascii_space));
  657|   114k|    }
  658|   723k|    *src = out;
  659|   723k|    return (uint32_t)mask;
  660|   723k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_17block64C2EPKDs:
  495|   116k|  simdutf_really_inline block64(const char16_t *src) {
  496|   116k|    const auto m1 = _mm256_loadu_si256(reinterpret_cast<const __m256i *>(src));
  497|   116k|    const auto m2 =
  498|   116k|        _mm256_loadu_si256(reinterpret_cast<const __m256i *>(src + 16));
  499|   116k|    const auto m3 =
  500|   116k|        _mm256_loadu_si256(reinterpret_cast<const __m256i *>(src + 32));
  501|   116k|    const auto m4 =
  502|   116k|        _mm256_loadu_si256(reinterpret_cast<const __m256i *>(src + 48));
  503|       |
  504|   116k|    const auto m1p = _mm256_permute2x128_si256(m1, m2, 0x20);
  505|   116k|    const auto m2p = _mm256_permute2x128_si256(m1, m2, 0x31);
  506|   116k|    const auto m3p = _mm256_permute2x128_si256(m3, m4, 0x20);
  507|   116k|    const auto m4p = _mm256_permute2x128_si256(m3, m4, 0x31);
  508|       |
  509|   116k|    chunks[0] = _mm256_packus_epi16(m1p, m2p);
  510|   116k|    chunks[1] = _mm256_packus_epi16(m3p, m4p);
  511|   116k|  }

_ZNK7simdutf7haswell14implementation16base64_to_binaryEPKcmPcNS_14base64_optionsENS_27last_chunk_handling_optionsE:
 1274|  1.89k|    last_chunk_handling_options last_chunk_options) const noexcept {
 1275|  1.89k|  if (options & base64_default_or_url) {
  ------------------
  |  Branch (1275:7): [True: 0, False: 1.89k]
  ------------------
 1276|      0|    if (options == base64_options::base64_default_or_url_accept_garbage) {
  ------------------
  |  Branch (1276:9): [True: 0, False: 0]
  ------------------
 1277|      0|      return base64::compress_decode_base64<false, true, true>(
 1278|      0|          output, input, length, options, last_chunk_options);
 1279|      0|    } else {
 1280|      0|      return base64::compress_decode_base64<false, false, true>(
 1281|      0|          output, input, length, options, last_chunk_options);
 1282|      0|    }
 1283|  1.89k|  } else if (options & base64_url) {
  ------------------
  |  Branch (1283:14): [True: 917, False: 976]
  ------------------
 1284|    917|    if (options == base64_options::base64_url_accept_garbage) {
  ------------------
  |  Branch (1284:9): [True: 0, False: 917]
  ------------------
 1285|      0|      return base64::compress_decode_base64<true, true, false>(
 1286|      0|          output, input, length, options, last_chunk_options);
 1287|    917|    } else {
 1288|    917|      return base64::compress_decode_base64<true, false, false>(
 1289|    917|          output, input, length, options, last_chunk_options);
 1290|    917|    }
 1291|    976|  } else {
 1292|    976|    if (options == base64_options::base64_default_accept_garbage) {
  ------------------
  |  Branch (1292:9): [True: 0, False: 976]
  ------------------
 1293|      0|      return base64::compress_decode_base64<false, true, false>(
 1294|      0|          output, input, length, options, last_chunk_options);
 1295|    976|    } else {
 1296|    976|      return base64::compress_decode_base64<false, false, false>(
 1297|    976|          output, input, length, options, last_chunk_options);
 1298|    976|    }
 1299|    976|  }
 1300|  1.89k|}
_ZNK7simdutf7haswell14implementation24base64_to_binary_detailsEPKcmPcNS_14base64_optionsENS_27last_chunk_handling_optionsE:
 1304|  1.89k|    last_chunk_handling_options last_chunk_options) const noexcept {
 1305|  1.89k|  if (options & base64_default_or_url) {
  ------------------
  |  Branch (1305:7): [True: 0, False: 1.89k]
  ------------------
 1306|      0|    if (options == base64_options::base64_default_or_url_accept_garbage) {
  ------------------
  |  Branch (1306:9): [True: 0, False: 0]
  ------------------
 1307|      0|      return base64::compress_decode_base64<false, true, true>(
 1308|      0|          output, input, length, options, last_chunk_options);
 1309|      0|    } else {
 1310|      0|      return base64::compress_decode_base64<false, false, true>(
 1311|      0|          output, input, length, options, last_chunk_options);
 1312|      0|    }
 1313|  1.89k|  } else if (options & base64_url) {
  ------------------
  |  Branch (1313:14): [True: 917, False: 976]
  ------------------
 1314|    917|    if (options == base64_options::base64_url_accept_garbage) {
  ------------------
  |  Branch (1314:9): [True: 0, False: 917]
  ------------------
 1315|      0|      return base64::compress_decode_base64<true, true, false>(
 1316|      0|          output, input, length, options, last_chunk_options);
 1317|    917|    } else {
 1318|    917|      return base64::compress_decode_base64<true, false, false>(
 1319|    917|          output, input, length, options, last_chunk_options);
 1320|    917|    }
 1321|    976|  } else {
 1322|    976|    if (options == base64_options::base64_default_accept_garbage) {
  ------------------
  |  Branch (1322:9): [True: 0, False: 976]
  ------------------
 1323|      0|      return base64::compress_decode_base64<false, true, false>(
 1324|      0|          output, input, length, options, last_chunk_options);
 1325|    976|    } else {
 1326|    976|      return base64::compress_decode_base64<false, false, false>(
 1327|    976|          output, input, length, options, last_chunk_options);
 1328|    976|    }
 1329|    976|  }
 1330|  1.89k|}
_ZNK7simdutf7haswell14implementation16base64_to_binaryEPKDsmPcNS_14base64_optionsENS_27last_chunk_handling_optionsE:
 1334|  1.90k|    last_chunk_handling_options last_chunk_options) const noexcept {
 1335|  1.90k|  if (options & base64_default_or_url) {
  ------------------
  |  Branch (1335:7): [True: 0, False: 1.90k]
  ------------------
 1336|      0|    if (options == base64_options::base64_default_or_url_accept_garbage) {
  ------------------
  |  Branch (1336:9): [True: 0, False: 0]
  ------------------
 1337|      0|      return base64::compress_decode_base64<false, true, true>(
 1338|      0|          output, input, length, options, last_chunk_options);
 1339|      0|    } else {
 1340|      0|      return base64::compress_decode_base64<false, false, true>(
 1341|      0|          output, input, length, options, last_chunk_options);
 1342|      0|    }
 1343|  1.90k|  } else if (options & base64_url) {
  ------------------
  |  Branch (1343:14): [True: 944, False: 956]
  ------------------
 1344|    944|    if (options == base64_options::base64_url_accept_garbage) {
  ------------------
  |  Branch (1344:9): [True: 0, False: 944]
  ------------------
 1345|      0|      return base64::compress_decode_base64<true, true, false>(
 1346|      0|          output, input, length, options, last_chunk_options);
 1347|    944|    } else {
 1348|    944|      return base64::compress_decode_base64<true, false, false>(
 1349|    944|          output, input, length, options, last_chunk_options);
 1350|    944|    }
 1351|    956|  } else {
 1352|    956|    if (options == base64_options::base64_default_accept_garbage) {
  ------------------
  |  Branch (1352:9): [True: 0, False: 956]
  ------------------
 1353|      0|      return base64::compress_decode_base64<false, true, false>(
 1354|      0|          output, input, length, options, last_chunk_options);
 1355|    956|    } else {
 1356|    956|      return base64::compress_decode_base64<false, false, false>(
 1357|    956|          output, input, length, options, last_chunk_options);
 1358|    956|    }
 1359|    956|  }
 1360|  1.90k|}
_ZNK7simdutf7haswell14implementation24base64_to_binary_detailsEPKDsmPcNS_14base64_optionsENS_27last_chunk_handling_optionsE:
 1364|  1.90k|    last_chunk_handling_options last_chunk_options) const noexcept {
 1365|  1.90k|  if (options & base64_default_or_url) {
  ------------------
  |  Branch (1365:7): [True: 0, False: 1.90k]
  ------------------
 1366|      0|    if (options == base64_options::base64_default_or_url_accept_garbage) {
  ------------------
  |  Branch (1366:9): [True: 0, False: 0]
  ------------------
 1367|      0|      return base64::compress_decode_base64<false, true, true>(
 1368|      0|          output, input, length, options, last_chunk_options);
 1369|      0|    } else {
 1370|      0|      return base64::compress_decode_base64<false, false, true>(
 1371|      0|          output, input, length, options, last_chunk_options);
 1372|      0|    }
 1373|  1.90k|  } else if (options & base64_url) {
  ------------------
  |  Branch (1373:14): [True: 944, False: 956]
  ------------------
 1374|    944|    if (options == base64_options::base64_url_accept_garbage) {
  ------------------
  |  Branch (1374:9): [True: 0, False: 944]
  ------------------
 1375|      0|      return base64::compress_decode_base64<true, true, false>(
 1376|      0|          output, input, length, options, last_chunk_options);
 1377|    944|    } else {
 1378|    944|      return base64::compress_decode_base64<true, false, false>(
 1379|    944|          output, input, length, options, last_chunk_options);
 1380|    944|    }
 1381|    956|  } else {
 1382|    956|    if (options == base64_options::base64_default_accept_garbage) {
  ------------------
  |  Branch (1382:9): [True: 0, False: 956]
  ------------------
 1383|      0|      return base64::compress_decode_base64<false, true, false>(
 1384|      0|          output, input, length, options, last_chunk_options);
 1385|    956|    } else {
 1386|    956|      return base64::compress_decode_base64<false, false, false>(
 1387|    956|          output, input, length, options, last_chunk_options);
 1388|    956|    }
 1389|    956|  }
 1390|  1.90k|}

_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|}
_ZNK7simdutf14implementation33maximal_binary_length_from_base64EPKcm:
  117|  5.67k|    const char *input, size_t length) const noexcept {
  118|  5.67k|  return scalar::base64::maximal_binary_length_from_base64(input, length);
  119|  5.67k|}
_ZNK7simdutf14implementation33maximal_binary_length_from_base64EPKDsm:
  122|  5.70k|    const char16_t *input, size_t length) const noexcept {
  123|  5.70k|  return scalar::base64::maximal_binary_length_from_base64(input, length);
  124|  5.70k|}
_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|}
_ZN7simdutf29get_available_implementationsEv:
 1568|      1|get_available_implementations() {
 1569|      1|#if !SIMDUTF_USE_STATIC_INITIALIZATION
 1570|      1|  static const internal::available_implementation_list
 1571|      1|      available_implementations_instance{};
 1572|      1|#endif
 1573|      1|  return available_implementations_instance;
 1574|      1|}
simdutf.cpp:_ZN7simdutf8internalL37get_available_implementation_pointersEv:
  938|      2|get_available_implementation_pointers() {
  939|      2|#if !SIMDUTF_USE_STATIC_INITIALIZATION
  940|      2|  static const std::initializer_list<const implementation *>
  941|      2|      available_implementation_pointers{
  942|      2|  #if SIMDUTF_IMPLEMENTATION_ICELAKE
  943|      2|          get_icelake_singleton(),
  944|      2|  #endif
  945|      2|  #if SIMDUTF_IMPLEMENTATION_HASWELL
  946|      2|          get_haswell_singleton(),
  947|      2|  #endif
  948|      2|  #if SIMDUTF_IMPLEMENTATION_WESTMERE
  949|      2|          get_westmere_singleton(),
  950|      2|  #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|      2|  #if SIMDUTF_IMPLEMENTATION_FALLBACK
  967|      2|          get_fallback_singleton(),
  968|      2|  #endif
  969|      2|      };
  970|      2|#endif
  971|      2|  return available_implementation_pointers;
  972|      2|}
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|}

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

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_110count_onesEm:
   14|   144k|simdutf_really_inline long long int count_ones(uint64_t input_num) {
   15|       |  return _popcnt64(input_num);
   16|   144k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115trailing_zeroesEm:
   20|   128k|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|   128k|  return __builtin_ctzll(input_num);
   25|   128k|  #endif // SIMDUTF_REGULAR_VISUAL_STUDIO
   26|   128k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115is_power_of_twoImEEbT_:
   29|   164k|template <typename T> bool is_power_of_two(T x) { return (x & (x - 1)) == 0; }

_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) {}

_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_110count_onesEm:
   14|   160k|simdutf_really_inline long long int count_ones(uint64_t input_num) {
   15|       |  return _popcnt64(input_num);
   16|   160k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115trailing_zeroesEm:
   20|   128k|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|   128k|  return __builtin_ctzll(input_num);
   27|   128k|  #endif // SIMDUTF_REGULAR_VISUAL_STUDIO
   28|   128k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115is_power_of_twoImEEbT_:
   31|   164k|template <typename T> bool is_power_of_two(T x) { return (x & (x - 1)) == 0; }

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

_ZNK7simdutf8westmere14implementation16base64_to_binaryEPKcmPcNS_14base64_optionsENS_27last_chunk_handling_optionsE:
 1304|  1.89k|    last_chunk_handling_options last_chunk_options) const noexcept {
 1305|  1.89k|  if (options & base64_default_or_url) {
  ------------------
  |  Branch (1305:7): [True: 0, False: 1.89k]
  ------------------
 1306|      0|    if (options == base64_options::base64_default_or_url_accept_garbage) {
  ------------------
  |  Branch (1306:9): [True: 0, False: 0]
  ------------------
 1307|      0|      return base64::compress_decode_base64<false, true, true>(
 1308|      0|          output, input, length, options, last_chunk_options);
 1309|      0|    } else {
 1310|      0|      return base64::compress_decode_base64<false, false, true>(
 1311|      0|          output, input, length, options, last_chunk_options);
 1312|      0|    }
 1313|  1.89k|  } else if (options & base64_url) {
  ------------------
  |  Branch (1313:14): [True: 917, False: 976]
  ------------------
 1314|    917|    if (options == base64_options::base64_url_accept_garbage) {
  ------------------
  |  Branch (1314:9): [True: 0, False: 917]
  ------------------
 1315|      0|      return base64::compress_decode_base64<true, true, false>(
 1316|      0|          output, input, length, options, last_chunk_options);
 1317|    917|    } else {
 1318|    917|      return base64::compress_decode_base64<true, false, false>(
 1319|    917|          output, input, length, options, last_chunk_options);
 1320|    917|    }
 1321|    976|  } else {
 1322|    976|    if (options == base64_options::base64_default_accept_garbage) {
  ------------------
  |  Branch (1322:9): [True: 0, False: 976]
  ------------------
 1323|      0|      return base64::compress_decode_base64<false, true, false>(
 1324|      0|          output, input, length, options, last_chunk_options);
 1325|    976|    } else {
 1326|    976|      return base64::compress_decode_base64<false, false, false>(
 1327|    976|          output, input, length, options, last_chunk_options);
 1328|    976|    }
 1329|    976|  }
 1330|  1.89k|}
_ZNK7simdutf8westmere14implementation24base64_to_binary_detailsEPKcmPcNS_14base64_optionsENS_27last_chunk_handling_optionsE:
 1334|  1.89k|    last_chunk_handling_options last_chunk_options) const noexcept {
 1335|  1.89k|  if (options & base64_default_or_url) {
  ------------------
  |  Branch (1335:7): [True: 0, False: 1.89k]
  ------------------
 1336|      0|    if (options == base64_options::base64_default_or_url_accept_garbage) {
  ------------------
  |  Branch (1336:9): [True: 0, False: 0]
  ------------------
 1337|      0|      return base64::compress_decode_base64<false, true, true>(
 1338|      0|          output, input, length, options, last_chunk_options);
 1339|      0|    } else {
 1340|      0|      return base64::compress_decode_base64<false, false, true>(
 1341|      0|          output, input, length, options, last_chunk_options);
 1342|      0|    }
 1343|  1.89k|  } else if (options & base64_url) {
  ------------------
  |  Branch (1343:14): [True: 917, False: 976]
  ------------------
 1344|    917|    if (options == base64_options::base64_url_accept_garbage) {
  ------------------
  |  Branch (1344:9): [True: 0, False: 917]
  ------------------
 1345|      0|      return base64::compress_decode_base64<true, true, false>(
 1346|      0|          output, input, length, options, last_chunk_options);
 1347|    917|    } else {
 1348|    917|      return base64::compress_decode_base64<true, false, false>(
 1349|    917|          output, input, length, options, last_chunk_options);
 1350|    917|    }
 1351|    976|  } else {
 1352|    976|    if (options == base64_options::base64_default_accept_garbage) {
  ------------------
  |  Branch (1352:9): [True: 0, False: 976]
  ------------------
 1353|      0|      return base64::compress_decode_base64<false, true, false>(
 1354|      0|          output, input, length, options, last_chunk_options);
 1355|    976|    } else {
 1356|    976|      return base64::compress_decode_base64<false, false, false>(
 1357|    976|          output, input, length, options, last_chunk_options);
 1358|    976|    }
 1359|    976|  }
 1360|  1.89k|}
_ZNK7simdutf8westmere14implementation16base64_to_binaryEPKDsmPcNS_14base64_optionsENS_27last_chunk_handling_optionsE:
 1364|  1.90k|    last_chunk_handling_options last_chunk_options) const noexcept {
 1365|  1.90k|  if (options & base64_default_or_url) {
  ------------------
  |  Branch (1365:7): [True: 0, False: 1.90k]
  ------------------
 1366|      0|    if (options == base64_options::base64_default_or_url_accept_garbage) {
  ------------------
  |  Branch (1366:9): [True: 0, False: 0]
  ------------------
 1367|      0|      return base64::compress_decode_base64<false, true, true>(
 1368|      0|          output, input, length, options, last_chunk_options);
 1369|      0|    } else {
 1370|      0|      return base64::compress_decode_base64<false, false, true>(
 1371|      0|          output, input, length, options, last_chunk_options);
 1372|      0|    }
 1373|  1.90k|  } else if (options & base64_url) {
  ------------------
  |  Branch (1373:14): [True: 944, False: 956]
  ------------------
 1374|    944|    if (options == base64_options::base64_url_accept_garbage) {
  ------------------
  |  Branch (1374:9): [True: 0, False: 944]
  ------------------
 1375|      0|      return base64::compress_decode_base64<true, true, false>(
 1376|      0|          output, input, length, options, last_chunk_options);
 1377|    944|    } else {
 1378|    944|      return base64::compress_decode_base64<true, false, false>(
 1379|    944|          output, input, length, options, last_chunk_options);
 1380|    944|    }
 1381|    956|  } else {
 1382|    956|    if (options == base64_options::base64_default_accept_garbage) {
  ------------------
  |  Branch (1382:9): [True: 0, False: 956]
  ------------------
 1383|      0|      return base64::compress_decode_base64<false, true, false>(
 1384|      0|          output, input, length, options, last_chunk_options);
 1385|    956|    } else {
 1386|    956|      return base64::compress_decode_base64<false, false, false>(
 1387|    956|          output, input, length, options, last_chunk_options);
 1388|    956|    }
 1389|    956|  }
 1390|  1.90k|}
_ZNK7simdutf8westmere14implementation24base64_to_binary_detailsEPKDsmPcNS_14base64_optionsENS_27last_chunk_handling_optionsE:
 1394|  1.90k|    last_chunk_handling_options last_chunk_options) const noexcept {
 1395|  1.90k|  if (options & base64_default_or_url) {
  ------------------
  |  Branch (1395:7): [True: 0, False: 1.90k]
  ------------------
 1396|      0|    if (options == base64_options::base64_default_or_url_accept_garbage) {
  ------------------
  |  Branch (1396:9): [True: 0, False: 0]
  ------------------
 1397|      0|      return base64::compress_decode_base64<false, true, true>(
 1398|      0|          output, input, length, options, last_chunk_options);
 1399|      0|    } else {
 1400|      0|      return base64::compress_decode_base64<false, false, true>(
 1401|      0|          output, input, length, options, last_chunk_options);
 1402|      0|    }
 1403|  1.90k|  } else if (options & base64_url) {
  ------------------
  |  Branch (1403:14): [True: 944, False: 956]
  ------------------
 1404|    944|    if (options == base64_options::base64_url_accept_garbage) {
  ------------------
  |  Branch (1404:9): [True: 0, False: 944]
  ------------------
 1405|      0|      return base64::compress_decode_base64<true, true, false>(
 1406|      0|          output, input, length, options, last_chunk_options);
 1407|    944|    } else {
 1408|    944|      return base64::compress_decode_base64<true, false, false>(
 1409|    944|          output, input, length, options, last_chunk_options);
 1410|    944|    }
 1411|    956|  } else {
 1412|    956|    if (options == base64_options::base64_default_accept_garbage) {
  ------------------
  |  Branch (1412:9): [True: 0, False: 956]
  ------------------
 1413|      0|      return base64::compress_decode_base64<false, true, false>(
 1414|      0|          output, input, length, options, last_chunk_options);
 1415|    956|    } else {
 1416|    956|      return base64::compress_decode_base64<false, false, false>(
 1417|    956|          output, input, length, options, last_chunk_options);
 1418|    956|    }
 1419|    956|  }
 1420|  1.90k|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_17block64C2EPKc:
  408|   397k|  simdutf_really_inline block64(const char *src) {
  409|   397k|    chunks[0] = _mm_loadu_si128(reinterpret_cast<const __m128i *>(src));
  410|   397k|    chunks[1] = _mm_loadu_si128(reinterpret_cast<const __m128i *>(src + 16));
  411|   397k|    chunks[2] = _mm_loadu_si128(reinterpret_cast<const __m128i *>(src + 32));
  412|   397k|    chunks[3] = _mm_loadu_si128(reinterpret_cast<const __m128i *>(src + 48));
  413|   397k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_17block6419base64_decode_blockILb0EEEvPc:
  652|  68.2k|  simdutf_really_inline void base64_decode_block(char *out) {
  653|  68.2k|    base64_decode(out, chunks[0]);
  654|  68.2k|    base64_decode(out + 12, chunks[1]);
  655|  68.2k|    base64_decode(out + 24, chunks[2]);
  656|  68.2k|    base64_decode<exact>(out + 36, chunks[3]);
  657|  68.2k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113base64_decodeILb0EEEvPcDv2_x:
  369|  1.82M|static simdutf_really_inline void base64_decode(char *out, __m128i str) {
  370|       |  // credit: aqrit
  371|       |
  372|  1.82M|  const __m128i pack_shuffle =
  373|  1.82M|      _mm_setr_epi8(2, 1, 0, 6, 5, 4, 10, 9, 8, 14, 13, 12, -1, -1, -1, -1);
  374|       |
  375|  1.82M|  const __m128i t0 = _mm_maddubs_epi16(str, _mm_set1_epi32(0x01400140));
  376|  1.82M|  const __m128i t1 = _mm_madd_epi16(t0, _mm_set1_epi32(0x00011000));
  377|  1.82M|  const __m128i t2 = _mm_shuffle_epi8(t1, pack_shuffle);
  378|       |  if constexpr (exact) {
  379|       |    _mm_storel_epi64((__m128i *)out, t2);
  380|       |    const int32_t last = _mm_extract_epi32(t2, 2);
  381|       |    std::memcpy(out + 8, &last, sizeof(last));
  382|  1.82M|  } else {
  383|       |    // this writes 16 bytes, but we only need 12.
  384|  1.82M|    _mm_storeu_si128((__m128i *)out, t2);
  385|  1.82M|  }
  386|  1.82M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_17block6419base64_decode_blockILb1EEEvPc:
  652|  84.2k|  simdutf_really_inline void base64_decode_block(char *out) {
  653|  84.2k|    base64_decode(out, chunks[0]);
  654|  84.2k|    base64_decode(out + 12, chunks[1]);
  655|  84.2k|    base64_decode(out + 24, chunks[2]);
  656|  84.2k|    base64_decode<exact>(out + 36, chunks[3]);
  657|  84.2k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113base64_decodeILb1EEEvPcDv2_x:
  369|   152k|static simdutf_really_inline void base64_decode(char *out, __m128i str) {
  370|       |  // credit: aqrit
  371|       |
  372|   152k|  const __m128i pack_shuffle =
  373|   152k|      _mm_setr_epi8(2, 1, 0, 6, 5, 4, 10, 9, 8, 14, 13, 12, -1, -1, -1, -1);
  374|       |
  375|   152k|  const __m128i t0 = _mm_maddubs_epi16(str, _mm_set1_epi32(0x01400140));
  376|   152k|  const __m128i t1 = _mm_madd_epi16(t0, _mm_set1_epi32(0x00011000));
  377|   152k|  const __m128i t2 = _mm_shuffle_epi8(t1, pack_shuffle);
  378|   152k|  if constexpr (exact) {
  379|   152k|    _mm_storel_epi64((__m128i *)out, t2);
  380|   152k|    const int32_t last = _mm_extract_epi32(t2, 2);
  381|   152k|    std::memcpy(out + 8, &last, sizeof(last));
  382|       |  } else {
  383|       |    // this writes 16 bytes, but we only need 12.
  384|       |    _mm_storeu_si128((__m128i *)out, t2);
  385|       |  }
  386|   152k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_17block6414compress_blockEmPc:
  449|   164k|  simdutf_really_inline uint64_t compress_block(uint64_t mask, char *output) {
  450|   164k|    if (is_power_of_two(mask)) {
  ------------------
  |  Branch (450:9): [True: 124k, False: 40.1k]
  ------------------
  451|   124k|      return compress_block_single(mask, output);
  452|   124k|    }
  453|       |
  454|  40.1k|    uint64_t nmask = ~mask;
  455|  40.1k|    compress(chunks[0], uint16_t(mask), output);
  456|  40.1k|    compress(chunks[1], uint16_t(mask >> 16),
  457|  40.1k|             output + count_ones(nmask & 0xFFFF));
  458|  40.1k|    compress(chunks[2], uint16_t(mask >> 32),
  459|  40.1k|             output + count_ones(nmask & 0xFFFFFFFF));
  460|  40.1k|    compress(chunks[3], uint16_t(mask >> 48),
  461|  40.1k|             output + count_ones(nmask & 0xFFFFFFFFFFFFULL));
  462|  40.1k|    return count_ones(nmask);
  463|   164k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_17block6421compress_block_singleEmPc:
  467|   124k|                                                     char *output) {
  468|   124k|    const size_t pos64 = trailing_zeroes(mask);
  469|   124k|    const int8_t pos = pos64 & 0xf;
  470|   124k|    switch (pos64 >> 4) {
  ------------------
  |  Branch (470:13): [True: 124k, False: 0]
  ------------------
  471|  31.0k|    case 0b00: {
  ------------------
  |  Branch (471:5): [True: 31.0k, False: 93.6k]
  ------------------
  472|  31.0k|      const __m128i v0 = _mm_set1_epi8(char(pos - 1));
  473|  31.0k|      const __m128i v1 =
  474|  31.0k|          _mm_setr_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
  475|  31.0k|      const __m128i v2 = _mm_cmpgt_epi8(v1, v0);
  476|  31.0k|      const __m128i sh = _mm_sub_epi8(v1, v2);
  477|  31.0k|      const __m128i compressed = _mm_shuffle_epi8(chunks[0], sh);
  478|       |
  479|  31.0k|      _mm_storeu_si128((__m128i *)(output + 0 * 16), compressed);
  480|  31.0k|      _mm_storeu_si128((__m128i *)(output + 1 * 16 - 1), chunks[1]);
  481|  31.0k|      _mm_storeu_si128((__m128i *)(output + 2 * 16 - 1), chunks[2]);
  482|  31.0k|      _mm_storeu_si128((__m128i *)(output + 3 * 16 - 1), chunks[3]);
  483|  31.0k|    } break;
  484|  32.2k|    case 0b01: {
  ------------------
  |  Branch (484:5): [True: 32.2k, False: 92.4k]
  ------------------
  485|  32.2k|      _mm_storeu_si128((__m128i *)(output + 0 * 16), chunks[0]);
  486|       |
  487|  32.2k|      const __m128i v0 = _mm_set1_epi8(char(pos - 1));
  488|  32.2k|      const __m128i v1 =
  489|  32.2k|          _mm_setr_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
  490|  32.2k|      const __m128i v2 = _mm_cmpgt_epi8(v1, v0);
  491|  32.2k|      const __m128i sh = _mm_sub_epi8(v1, v2);
  492|  32.2k|      const __m128i compressed = _mm_shuffle_epi8(chunks[1], sh);
  493|       |
  494|  32.2k|      _mm_storeu_si128((__m128i *)(output + 1 * 16), compressed);
  495|  32.2k|      _mm_storeu_si128((__m128i *)(output + 2 * 16 - 1), chunks[2]);
  496|  32.2k|      _mm_storeu_si128((__m128i *)(output + 3 * 16 - 1), chunks[3]);
  497|  32.2k|    } break;
  498|  32.1k|    case 0b10: {
  ------------------
  |  Branch (498:5): [True: 32.1k, False: 92.5k]
  ------------------
  499|  32.1k|      _mm_storeu_si128((__m128i *)(output + 0 * 16), chunks[0]);
  500|  32.1k|      _mm_storeu_si128((__m128i *)(output + 1 * 16), chunks[1]);
  501|       |
  502|  32.1k|      const __m128i v0 = _mm_set1_epi8(char(pos - 1));
  503|  32.1k|      const __m128i v1 =
  504|  32.1k|          _mm_setr_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
  505|  32.1k|      const __m128i v2 = _mm_cmpgt_epi8(v1, v0);
  506|  32.1k|      const __m128i sh = _mm_sub_epi8(v1, v2);
  507|  32.1k|      const __m128i compressed = _mm_shuffle_epi8(chunks[2], sh);
  508|       |
  509|  32.1k|      _mm_storeu_si128((__m128i *)(output + 2 * 16), compressed);
  510|  32.1k|      _mm_storeu_si128((__m128i *)(output + 3 * 16 - 1), chunks[3]);
  511|  32.1k|    } break;
  512|  29.2k|    case 0b11: {
  ------------------
  |  Branch (512:5): [True: 29.2k, False: 95.4k]
  ------------------
  513|  29.2k|      _mm_storeu_si128((__m128i *)(output + 0 * 16), chunks[0]);
  514|  29.2k|      _mm_storeu_si128((__m128i *)(output + 1 * 16), chunks[1]);
  515|  29.2k|      _mm_storeu_si128((__m128i *)(output + 2 * 16), chunks[2]);
  516|       |
  517|  29.2k|      const __m128i v0 = _mm_set1_epi8(char(pos - 1));
  518|  29.2k|      const __m128i v1 =
  519|  29.2k|          _mm_setr_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
  520|  29.2k|      const __m128i v2 = _mm_cmpgt_epi8(v1, v0);
  521|  29.2k|      const __m128i sh = _mm_sub_epi8(v1, v2);
  522|  29.2k|      const __m128i compressed = _mm_shuffle_epi8(chunks[3], sh);
  523|       |
  524|  29.2k|      _mm_storeu_si128((__m128i *)(output + 3 * 16), compressed);
  525|  29.2k|    } break;
  526|   124k|    }
  527|       |
  528|   124k|    return 63;
  529|   124k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_18compressEDv2_xtPc:
  332|   160k|                                           char *output) {
  333|   160k|  if (mask == 0) {
  ------------------
  |  Branch (333:7): [True: 75.3k, False: 85.1k]
  ------------------
  334|  75.3k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(output), data);
  335|  75.3k|    return;
  336|  75.3k|  }
  337|       |
  338|       |  // this particular implementation was inspired by work done by @animetosho
  339|       |  // we do it in two steps, first 8 bytes and then second 8 bytes
  340|  85.1k|  uint8_t mask1 = uint8_t(mask);      // least significant 8 bits
  341|  85.1k|  uint8_t mask2 = uint8_t(mask >> 8); // most significant 8 bits
  342|       |  // next line just loads the 64-bit values thintable_epi8[mask1] and
  343|       |  // thintable_epi8[mask2] into a 128-bit register, using only
  344|       |  // two instructions on most compilers.
  345|       |
  346|  85.1k|  __m128i shufmask = _mm_set_epi64x(tables::base64::thintable_epi8[mask2],
  347|  85.1k|                                    tables::base64::thintable_epi8[mask1]);
  348|       |  // we increment by 0x08 the second half of the mask
  349|  85.1k|  shufmask =
  350|  85.1k|      _mm_add_epi8(shufmask, _mm_set_epi32(0x08080808, 0x08080808, 0, 0));
  351|       |  // this is the version "nearly pruned"
  352|  85.1k|  __m128i pruned = _mm_shuffle_epi8(data, shufmask);
  353|       |  // we still need to put the two halves together.
  354|       |  // we compute the popcount of the first half:
  355|  85.1k|  int pop1 = tables::base64::BitsSetTable256mul2[mask1];
  356|       |  // then load the corresponding mask, what it does is to write
  357|       |  // only the first pop1 bytes from the first 8 bytes, and then
  358|       |  // it fills in with the bytes from the second 8 bytes + some filling
  359|       |  // at the end.
  360|  85.1k|  __m128i compactmask = _mm_loadu_si128(reinterpret_cast<const __m128i *>(
  361|  85.1k|      tables::base64::pshufb_combine_table + pop1 * 8));
  362|  85.1k|  __m128i answer = _mm_shuffle_epi8(pruned, compactmask);
  363|  85.1k|  _mm_storeu_si128(reinterpret_cast<__m128i *>(output), answer);
  364|  85.1k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_17block6410copy_blockEPc:
  441|   187k|  simdutf_really_inline void copy_block(char *output) {
  442|   187k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(output), chunks[0]);
  443|   187k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(output + 16), chunks[1]);
  444|   187k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(output + 32), chunks[2]);
  445|   187k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(output + 48), chunks[3]);
  446|   187k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_119base64_decode_blockILb0EEEvPcPKc:
  390|   273k|static inline void base64_decode_block(char *out, const char *src) {
  391|   273k|  base64_decode(out, _mm_loadu_si128(reinterpret_cast<const __m128i *>(src)));
  392|   273k|  base64_decode(out + 12,
  393|   273k|                _mm_loadu_si128(reinterpret_cast<const __m128i *>(src + 16)));
  394|   273k|  base64_decode(out + 24,
  395|   273k|                _mm_loadu_si128(reinterpret_cast<const __m128i *>(src + 32)));
  396|   273k|  base64_decode<exact>(
  397|   273k|      out + 36, _mm_loadu_si128(reinterpret_cast<const __m128i *>(src + 48)));
  398|   273k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_119base64_decode_blockILb1EEEvPcPKc:
  390|  68.3k|static inline void base64_decode_block(char *out, const char *src) {
  391|  68.3k|  base64_decode(out, _mm_loadu_si128(reinterpret_cast<const __m128i *>(src)));
  392|  68.3k|  base64_decode(out + 12,
  393|  68.3k|                _mm_loadu_si128(reinterpret_cast<const __m128i *>(src + 16)));
  394|  68.3k|  base64_decode(out + 24,
  395|  68.3k|                _mm_loadu_si128(reinterpret_cast<const __m128i *>(src + 32)));
  396|  68.3k|  base64_decode<exact>(
  397|  68.3k|      out + 36, _mm_loadu_si128(reinterpret_cast<const __m128i *>(src + 48)));
  398|  68.3k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_17block6414to_base64_maskILb1ELb0ELb0EEEmPm:
  533|   152k|  simdutf_really_inline uint64_t to_base64_mask(uint64_t *error) {
  534|   152k|    uint32_t err0 = 0;
  535|   152k|    uint32_t err1 = 0;
  536|   152k|    uint32_t err2 = 0;
  537|   152k|    uint32_t err3 = 0;
  538|   152k|    uint64_t m0 = to_base64_mask<base64_url, ignore_garbage, default_or_url>(
  539|   152k|        &chunks[0], &err0);
  540|   152k|    uint64_t m1 = to_base64_mask<base64_url, ignore_garbage, default_or_url>(
  541|   152k|        &chunks[1], &err1);
  542|   152k|    uint64_t m2 = to_base64_mask<base64_url, ignore_garbage, default_or_url>(
  543|   152k|        &chunks[2], &err2);
  544|   152k|    uint64_t m3 = to_base64_mask<base64_url, ignore_garbage, default_or_url>(
  545|   152k|        &chunks[3], &err3);
  546|   152k|    if (!ignore_garbage) {
  ------------------
  |  Branch (546:9): [True: 152k, Folded]
  ------------------
  547|   152k|      *error = (err0) | ((uint64_t)err1 << 16) | ((uint64_t)err2 << 32) |
  548|   152k|               ((uint64_t)err3 << 48);
  549|   152k|    }
  550|   152k|    return m0 | (m1 << 16) | (m2 << 32) | (m3 << 48);
  551|   152k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_17block6414to_base64_maskILb1ELb0ELb0EEEtPDv2_xPj:
  555|   610k|  simdutf_really_inline uint16_t to_base64_mask(__m128i *src, uint32_t *error) {
  556|   610k|    const __m128i ascii_space_tbl =
  557|   610k|        _mm_setr_epi8(0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9, 0xa,
  558|   610k|                      0x0, 0xc, 0xd, 0x0, 0x0);
  559|       |    // credit: aqrit
  560|   610k|    __m128i delta_asso;
  561|   610k|    if (default_or_url) {
  ------------------
  |  Branch (561:9): [Folded, False: 610k]
  ------------------
  562|      0|      delta_asso =
  563|      0|          _mm_setr_epi8(0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00,
  564|      0|                        0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x16);
  565|   610k|    } else if (base64_url) {
  ------------------
  |  Branch (565:16): [True: 610k, Folded]
  ------------------
  566|   610k|      delta_asso = _mm_setr_epi8(0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0,
  567|   610k|                                 0x0, 0x0, 0x0, 0x0, 0xF, 0x0, 0xF);
  568|   610k|    } else {
  569|      0|      delta_asso =
  570|      0|          _mm_setr_epi8(0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00,
  571|      0|                        0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x0F);
  572|      0|    }
  573|   610k|    __m128i delta_values;
  574|   610k|    if (default_or_url) {
  ------------------
  |  Branch (574:9): [Folded, False: 610k]
  ------------------
  575|      0|      delta_values = _mm_setr_epi8(
  576|      0|          uint8_t(0xBF), uint8_t(0xE0), uint8_t(0xB9), uint8_t(0x13),
  577|      0|          uint8_t(0x04), uint8_t(0xBF), uint8_t(0xBF), uint8_t(0xB9),
  578|      0|          uint8_t(0xB9), uint8_t(0x00), uint8_t(0xFF), uint8_t(0x11),
  579|      0|          uint8_t(0xFF), uint8_t(0xBF), uint8_t(0x10), uint8_t(0xB9));
  580|       |
  581|   610k|    } else if (base64_url) {
  ------------------
  |  Branch (581:16): [True: 610k, Folded]
  ------------------
  582|   610k|      delta_values = _mm_setr_epi8(0x0, 0x0, 0x0, 0x13, 0x4, uint8_t(0xBF),
  583|   610k|                                   uint8_t(0xBF), uint8_t(0xB9), uint8_t(0xB9),
  584|   610k|                                   0x0, 0x11, uint8_t(0xC3), uint8_t(0xBF),
  585|   610k|                                   uint8_t(0xE0), uint8_t(0xB9), uint8_t(0xB9));
  586|   610k|    } else {
  587|      0|      delta_values =
  588|      0|          _mm_setr_epi8(int8_t(0x00), int8_t(0x00), int8_t(0x00), int8_t(0x13),
  589|      0|                        int8_t(0x04), int8_t(0xBF), int8_t(0xBF), int8_t(0xB9),
  590|      0|                        int8_t(0xB9), int8_t(0x00), int8_t(0x10), int8_t(0xC3),
  591|      0|                        int8_t(0xBF), int8_t(0xBF), int8_t(0xB9), int8_t(0xB9));
  592|      0|    }
  593|   610k|    __m128i check_asso;
  594|   610k|    if (default_or_url) {
  ------------------
  |  Branch (594:9): [Folded, False: 610k]
  ------------------
  595|      0|      check_asso =
  596|      0|          _mm_setr_epi8(0x0D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  597|      0|                        0x01, 0x03, 0x07, 0x0B, 0x0E, 0x0B, 0x06);
  598|   610k|    } else if (base64_url) {
  ------------------
  |  Branch (598:16): [True: 610k, Folded]
  ------------------
  599|   610k|      check_asso = _mm_setr_epi8(0xD, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1,
  600|   610k|                                 0x1, 0x3, 0x7, 0xB, 0xE, 0xB, 0x6);
  601|   610k|    } else {
  602|      0|      check_asso =
  603|      0|          _mm_setr_epi8(0x0D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  604|      0|                        0x01, 0x03, 0x07, 0x0B, 0x0B, 0x0B, 0x0F);
  605|      0|    }
  606|   610k|    __m128i check_values;
  607|   610k|    if (default_or_url) {
  ------------------
  |  Branch (607:9): [Folded, False: 610k]
  ------------------
  608|      0|      check_values = _mm_setr_epi8(
  609|      0|          uint8_t(0x80), uint8_t(0x80), uint8_t(0x80), uint8_t(0x80),
  610|      0|          uint8_t(0xCF), uint8_t(0xBF), uint8_t(0xD5), uint8_t(0xA6),
  611|      0|          uint8_t(0xB5), uint8_t(0xA1), uint8_t(0x00), uint8_t(0x80),
  612|      0|          uint8_t(0x00), uint8_t(0x80), uint8_t(0x00), uint8_t(0x80));
  613|   610k|    } else if (base64_url) {
  ------------------
  |  Branch (613:16): [True: 610k, Folded]
  ------------------
  614|   610k|      check_values = _mm_setr_epi8(uint8_t(0x80), uint8_t(0x80), uint8_t(0x80),
  615|   610k|                                   uint8_t(0x80), uint8_t(0xCF), uint8_t(0xBF),
  616|   610k|                                   uint8_t(0xB6), uint8_t(0xA6), uint8_t(0xB5),
  617|   610k|                                   uint8_t(0xA1), 0x0, uint8_t(0x80), 0x0,
  618|   610k|                                   uint8_t(0x80), 0x0, uint8_t(0x80));
  619|   610k|    } else {
  620|      0|      check_values =
  621|      0|          _mm_setr_epi8(int8_t(0x80), int8_t(0x80), int8_t(0x80), int8_t(0x80),
  622|      0|                        int8_t(0xCF), int8_t(0xBF), int8_t(0xD5), int8_t(0xA6),
  623|      0|                        int8_t(0xB5), int8_t(0x86), int8_t(0xD1), int8_t(0x80),
  624|      0|                        int8_t(0xB1), int8_t(0x80), int8_t(0x91), int8_t(0x80));
  625|      0|    }
  626|   610k|    const __m128i shifted = _mm_srli_epi32(*src, 3);
  627|       |
  628|   610k|    __m128i delta_hash =
  629|   610k|        _mm_avg_epu8(_mm_shuffle_epi8(delta_asso, *src), shifted);
  630|   610k|    if (default_or_url) {
  ------------------
  |  Branch (630:9): [Folded, False: 610k]
  ------------------
  631|      0|      delta_hash = _mm_and_si128(delta_hash, _mm_set1_epi8(0xf));
  632|      0|    }
  633|   610k|    const __m128i check_hash =
  634|   610k|        _mm_avg_epu8(_mm_shuffle_epi8(check_asso, *src), shifted);
  635|       |
  636|   610k|    const __m128i out =
  637|   610k|        _mm_adds_epi8(_mm_shuffle_epi8(delta_values, delta_hash), *src);
  638|   610k|    const __m128i chk =
  639|   610k|        _mm_adds_epi8(_mm_shuffle_epi8(check_values, check_hash), *src);
  640|   610k|    const int mask = _mm_movemask_epi8(chk);
  641|   610k|    if (!ignore_garbage && mask) {
  ------------------
  |  Branch (641:9): [True: 610k, Folded]
  |  Branch (641:28): [True: 99.5k, False: 511k]
  ------------------
  642|  99.5k|      __m128i ascii_space =
  643|  99.5k|          _mm_cmpeq_epi8(_mm_shuffle_epi8(ascii_space_tbl, *src), *src);
  644|  99.5k|      *error = (mask ^ _mm_movemask_epi8(ascii_space));
  645|  99.5k|    }
  646|   610k|    *src = out;
  647|   610k|    return (uint16_t)mask;
  648|   610k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_17block6414to_base64_maskILb0ELb0ELb0EEEmPm:
  533|   361k|  simdutf_really_inline uint64_t to_base64_mask(uint64_t *error) {
  534|   361k|    uint32_t err0 = 0;
  535|   361k|    uint32_t err1 = 0;
  536|   361k|    uint32_t err2 = 0;
  537|   361k|    uint32_t err3 = 0;
  538|   361k|    uint64_t m0 = to_base64_mask<base64_url, ignore_garbage, default_or_url>(
  539|   361k|        &chunks[0], &err0);
  540|   361k|    uint64_t m1 = to_base64_mask<base64_url, ignore_garbage, default_or_url>(
  541|   361k|        &chunks[1], &err1);
  542|   361k|    uint64_t m2 = to_base64_mask<base64_url, ignore_garbage, default_or_url>(
  543|   361k|        &chunks[2], &err2);
  544|   361k|    uint64_t m3 = to_base64_mask<base64_url, ignore_garbage, default_or_url>(
  545|   361k|        &chunks[3], &err3);
  546|   361k|    if (!ignore_garbage) {
  ------------------
  |  Branch (546:9): [True: 361k, Folded]
  ------------------
  547|   361k|      *error = (err0) | ((uint64_t)err1 << 16) | ((uint64_t)err2 << 32) |
  548|   361k|               ((uint64_t)err3 << 48);
  549|   361k|    }
  550|   361k|    return m0 | (m1 << 16) | (m2 << 32) | (m3 << 48);
  551|   361k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_17block6414to_base64_maskILb0ELb0ELb0EEEtPDv2_xPj:
  555|  1.44M|  simdutf_really_inline uint16_t to_base64_mask(__m128i *src, uint32_t *error) {
  556|  1.44M|    const __m128i ascii_space_tbl =
  557|  1.44M|        _mm_setr_epi8(0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9, 0xa,
  558|  1.44M|                      0x0, 0xc, 0xd, 0x0, 0x0);
  559|       |    // credit: aqrit
  560|  1.44M|    __m128i delta_asso;
  561|  1.44M|    if (default_or_url) {
  ------------------
  |  Branch (561:9): [Folded, False: 1.44M]
  ------------------
  562|      0|      delta_asso =
  563|      0|          _mm_setr_epi8(0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00,
  564|      0|                        0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x16);
  565|  1.44M|    } else if (base64_url) {
  ------------------
  |  Branch (565:16): [Folded, False: 1.44M]
  ------------------
  566|      0|      delta_asso = _mm_setr_epi8(0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0,
  567|      0|                                 0x0, 0x0, 0x0, 0x0, 0xF, 0x0, 0xF);
  568|  1.44M|    } else {
  569|  1.44M|      delta_asso =
  570|  1.44M|          _mm_setr_epi8(0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00,
  571|  1.44M|                        0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x0F);
  572|  1.44M|    }
  573|  1.44M|    __m128i delta_values;
  574|  1.44M|    if (default_or_url) {
  ------------------
  |  Branch (574:9): [Folded, False: 1.44M]
  ------------------
  575|      0|      delta_values = _mm_setr_epi8(
  576|      0|          uint8_t(0xBF), uint8_t(0xE0), uint8_t(0xB9), uint8_t(0x13),
  577|      0|          uint8_t(0x04), uint8_t(0xBF), uint8_t(0xBF), uint8_t(0xB9),
  578|      0|          uint8_t(0xB9), uint8_t(0x00), uint8_t(0xFF), uint8_t(0x11),
  579|      0|          uint8_t(0xFF), uint8_t(0xBF), uint8_t(0x10), uint8_t(0xB9));
  580|       |
  581|  1.44M|    } else if (base64_url) {
  ------------------
  |  Branch (581:16): [Folded, False: 1.44M]
  ------------------
  582|      0|      delta_values = _mm_setr_epi8(0x0, 0x0, 0x0, 0x13, 0x4, uint8_t(0xBF),
  583|      0|                                   uint8_t(0xBF), uint8_t(0xB9), uint8_t(0xB9),
  584|      0|                                   0x0, 0x11, uint8_t(0xC3), uint8_t(0xBF),
  585|      0|                                   uint8_t(0xE0), uint8_t(0xB9), uint8_t(0xB9));
  586|  1.44M|    } else {
  587|  1.44M|      delta_values =
  588|  1.44M|          _mm_setr_epi8(int8_t(0x00), int8_t(0x00), int8_t(0x00), int8_t(0x13),
  589|  1.44M|                        int8_t(0x04), int8_t(0xBF), int8_t(0xBF), int8_t(0xB9),
  590|  1.44M|                        int8_t(0xB9), int8_t(0x00), int8_t(0x10), int8_t(0xC3),
  591|  1.44M|                        int8_t(0xBF), int8_t(0xBF), int8_t(0xB9), int8_t(0xB9));
  592|  1.44M|    }
  593|  1.44M|    __m128i check_asso;
  594|  1.44M|    if (default_or_url) {
  ------------------
  |  Branch (594:9): [Folded, False: 1.44M]
  ------------------
  595|      0|      check_asso =
  596|      0|          _mm_setr_epi8(0x0D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  597|      0|                        0x01, 0x03, 0x07, 0x0B, 0x0E, 0x0B, 0x06);
  598|  1.44M|    } else if (base64_url) {
  ------------------
  |  Branch (598:16): [Folded, False: 1.44M]
  ------------------
  599|      0|      check_asso = _mm_setr_epi8(0xD, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1,
  600|      0|                                 0x1, 0x3, 0x7, 0xB, 0xE, 0xB, 0x6);
  601|  1.44M|    } else {
  602|  1.44M|      check_asso =
  603|  1.44M|          _mm_setr_epi8(0x0D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  604|  1.44M|                        0x01, 0x03, 0x07, 0x0B, 0x0B, 0x0B, 0x0F);
  605|  1.44M|    }
  606|  1.44M|    __m128i check_values;
  607|  1.44M|    if (default_or_url) {
  ------------------
  |  Branch (607:9): [Folded, False: 1.44M]
  ------------------
  608|      0|      check_values = _mm_setr_epi8(
  609|      0|          uint8_t(0x80), uint8_t(0x80), uint8_t(0x80), uint8_t(0x80),
  610|      0|          uint8_t(0xCF), uint8_t(0xBF), uint8_t(0xD5), uint8_t(0xA6),
  611|      0|          uint8_t(0xB5), uint8_t(0xA1), uint8_t(0x00), uint8_t(0x80),
  612|      0|          uint8_t(0x00), uint8_t(0x80), uint8_t(0x00), uint8_t(0x80));
  613|  1.44M|    } else if (base64_url) {
  ------------------
  |  Branch (613:16): [Folded, False: 1.44M]
  ------------------
  614|      0|      check_values = _mm_setr_epi8(uint8_t(0x80), uint8_t(0x80), uint8_t(0x80),
  615|      0|                                   uint8_t(0x80), uint8_t(0xCF), uint8_t(0xBF),
  616|      0|                                   uint8_t(0xB6), uint8_t(0xA6), uint8_t(0xB5),
  617|      0|                                   uint8_t(0xA1), 0x0, uint8_t(0x80), 0x0,
  618|      0|                                   uint8_t(0x80), 0x0, uint8_t(0x80));
  619|  1.44M|    } else {
  620|  1.44M|      check_values =
  621|  1.44M|          _mm_setr_epi8(int8_t(0x80), int8_t(0x80), int8_t(0x80), int8_t(0x80),
  622|  1.44M|                        int8_t(0xCF), int8_t(0xBF), int8_t(0xD5), int8_t(0xA6),
  623|  1.44M|                        int8_t(0xB5), int8_t(0x86), int8_t(0xD1), int8_t(0x80),
  624|  1.44M|                        int8_t(0xB1), int8_t(0x80), int8_t(0x91), int8_t(0x80));
  625|  1.44M|    }
  626|  1.44M|    const __m128i shifted = _mm_srli_epi32(*src, 3);
  627|       |
  628|  1.44M|    __m128i delta_hash =
  629|  1.44M|        _mm_avg_epu8(_mm_shuffle_epi8(delta_asso, *src), shifted);
  630|  1.44M|    if (default_or_url) {
  ------------------
  |  Branch (630:9): [Folded, False: 1.44M]
  ------------------
  631|      0|      delta_hash = _mm_and_si128(delta_hash, _mm_set1_epi8(0xf));
  632|      0|    }
  633|  1.44M|    const __m128i check_hash =
  634|  1.44M|        _mm_avg_epu8(_mm_shuffle_epi8(check_asso, *src), shifted);
  635|       |
  636|  1.44M|    const __m128i out =
  637|  1.44M|        _mm_adds_epi8(_mm_shuffle_epi8(delta_values, delta_hash), *src);
  638|  1.44M|    const __m128i chk =
  639|  1.44M|        _mm_adds_epi8(_mm_shuffle_epi8(check_values, check_hash), *src);
  640|  1.44M|    const int mask = _mm_movemask_epi8(chk);
  641|  1.44M|    if (!ignore_garbage && mask) {
  ------------------
  |  Branch (641:9): [True: 1.44M, Folded]
  |  Branch (641:28): [True: 134k, False: 1.31M]
  ------------------
  642|   134k|      __m128i ascii_space =
  643|   134k|          _mm_cmpeq_epi8(_mm_shuffle_epi8(ascii_space_tbl, *src), *src);
  644|   134k|      *error = (mask ^ _mm_movemask_epi8(ascii_space));
  645|   134k|    }
  646|  1.44M|    *src = out;
  647|  1.44M|    return (uint16_t)mask;
  648|  1.44M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_17block64C2EPKDs:
  419|   116k|  simdutf_really_inline block64(const char16_t *src) {
  420|   116k|    const auto m1 = _mm_loadu_si128(reinterpret_cast<const __m128i *>(src));
  421|   116k|    const auto m2 = _mm_loadu_si128(reinterpret_cast<const __m128i *>(src + 8));
  422|   116k|    const auto m3 =
  423|   116k|        _mm_loadu_si128(reinterpret_cast<const __m128i *>(src + 16));
  424|   116k|    const auto m4 =
  425|   116k|        _mm_loadu_si128(reinterpret_cast<const __m128i *>(src + 24));
  426|   116k|    const auto m5 =
  427|   116k|        _mm_loadu_si128(reinterpret_cast<const __m128i *>(src + 32));
  428|   116k|    const auto m6 =
  429|   116k|        _mm_loadu_si128(reinterpret_cast<const __m128i *>(src + 40));
  430|   116k|    const auto m7 =
  431|   116k|        _mm_loadu_si128(reinterpret_cast<const __m128i *>(src + 48));
  432|   116k|    const auto m8 =
  433|   116k|        _mm_loadu_si128(reinterpret_cast<const __m128i *>(src + 56));
  434|   116k|    chunks[0] = _mm_packus_epi16(m1, m2);
  435|   116k|    chunks[1] = _mm_packus_epi16(m3, m4);
  436|   116k|    chunks[2] = _mm_packus_epi16(m5, m6);
  437|   116k|    chunks[3] = _mm_packus_epi16(m7, m8);
  438|   116k|  }

_ZNK7simdutf11full_resultcvNS_6resultEEv:
  117|  22.7k|  simdutf_really_inline simdutf_constexpr23 operator result() const noexcept {
  118|  22.7k|    if (error == error_code::SUCCESS) {
  ------------------
  |  Branch (118:9): [True: 7.83k, False: 14.9k]
  ------------------
  119|  7.83k|      return result{error, output_count};
  120|  14.9k|    } else {
  121|  14.9k|      return result{error, input_count};
  122|  14.9k|    }
  123|  22.7k|  }
_ZN7simdutf6resultC2ENS_10error_codeEm:
   87|  22.7k|      : error{err}, count{pos} {}

