_Z18populate_functionsv:
  548|      1|const auto populate_functions() {
  549|      1|  using I = simdutf::implementation;
  550|      1|  using FuzzSignature = void (*)(std::span<const char>);
  551|       |
  552|      1|#define ADD(lenfunc, conversionfunc)                                           \
  553|      1|  FuzzSignature {                                                              \
  554|      1|    +[](std::span<const char> chardata) {                                      \
  555|      1|      const auto c =                                                           \
  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  562|      1|      c.fuzz(chardata);                                                        \
  563|      1|    }                                                                          \
  564|      1|  }
  565|       |
  566|      1|  return std::array{
  567|       |      // all these cases require valid input for invoking the convert function
  568|       |
  569|       |      // see #493
  570|       |      // IGNORE(latin1_length_from_utf16, convert_valid_utf16be_to_latin1),
  571|      1|      ADD(utf32_length_from_utf16be, convert_valid_utf16be_to_utf32),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  572|      1|      ADD(utf8_length_from_utf16be, convert_valid_utf16be_to_utf8),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  573|       |
  574|       |      //  see #493
  575|       |      // IGNORE(latin1_length_from_utf16, convert_valid_utf16le_to_latin1),
  576|      1|      ADD(utf32_length_from_utf16le, convert_valid_utf16le_to_utf32),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  577|      1|      ADD(utf8_length_from_utf16le, convert_valid_utf16le_to_utf8),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  578|       |
  579|       |      // see #493
  580|       |      // IGNORE(latin1_length_from_utf32, convert_valid_utf32_to_latin1),
  581|      1|      ADD(utf16_length_from_utf32, convert_valid_utf32_to_utf16be),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  582|      1|      ADD(utf16_length_from_utf32, convert_valid_utf32_to_utf16le),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  583|      1|      ADD(utf8_length_from_utf32, convert_valid_utf32_to_utf8),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  584|       |
  585|       |      // see #493
  586|       |      // IGNORE(latin1_length_from_utf8, convert_valid_utf8_to_latin1),
  587|      1|      ADD(utf16_length_from_utf8, convert_valid_utf8_to_utf16be),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  588|      1|      ADD(utf16_length_from_utf8, convert_valid_utf8_to_utf16le),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  589|      1|      ADD(utf32_length_from_utf8, convert_valid_utf8_to_utf32),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  590|       |
  591|       |      // all these cases operate on arbitrary data
  592|      1|      ADD(latin1_length_from_utf16, convert_utf16be_to_latin1),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  593|      1|      ADD(utf32_length_from_utf16be, convert_utf16be_to_utf32),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  594|      1|      ADD(utf8_length_from_utf16be, convert_utf16be_to_utf8),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  595|       |
  596|      1|      ADD(latin1_length_from_utf16, convert_utf16le_to_latin1),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  597|      1|      ADD(utf32_length_from_utf16le, convert_utf16le_to_utf32),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  598|      1|      ADD(utf8_length_from_utf16le, convert_utf16le_to_utf8),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  599|       |
  600|      1|      ADD(latin1_length_from_utf32, convert_utf32_to_latin1),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  601|      1|      ADD(utf16_length_from_utf32, convert_utf32_to_utf16be),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  602|      1|      ADD(utf16_length_from_utf32, convert_utf32_to_utf16le),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  603|      1|      ADD(utf8_length_from_utf32, convert_utf32_to_utf8),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  604|       |
  605|      1|      ADD(latin1_length_from_utf8, convert_utf8_to_latin1),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  606|      1|      ADD(utf16_length_from_utf8, convert_utf8_to_utf16be),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  607|      1|      ADD(utf16_length_from_utf8, convert_utf8_to_utf16le),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  608|      1|      ADD(utf32_length_from_utf8, convert_utf8_to_utf32),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  609|       |
  610|       |      // all these cases operate on arbitrary data and use the _with_errors
  611|       |      // variant
  612|      1|      ADD(latin1_length_from_utf16, convert_utf16be_to_latin1_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  613|      1|      ADD(utf32_length_from_utf16be, convert_utf16be_to_utf32_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  614|      1|      ADD(utf8_length_from_utf16be, convert_utf16be_to_utf8_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  615|       |
  616|      1|      ADD(latin1_length_from_utf16, convert_utf16le_to_latin1_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  617|      1|      ADD(utf32_length_from_utf16le, convert_utf16le_to_utf32_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  618|      1|      ADD(utf8_length_from_utf16le, convert_utf16le_to_utf8_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  619|       |
  620|      1|      ADD(latin1_length_from_utf32, convert_utf32_to_latin1_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  621|      1|      ADD(utf16_length_from_utf32, convert_utf32_to_utf16be_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  622|      1|      ADD(utf16_length_from_utf32, convert_utf32_to_utf16le_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  623|      1|      ADD(utf8_length_from_utf32, convert_utf32_to_utf8_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  624|       |
  625|      1|      ADD(latin1_length_from_utf8, convert_utf8_to_latin1_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  626|      1|      ADD(utf16_length_from_utf8, convert_utf8_to_utf16be_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  627|      1|      ADD(utf16_length_from_utf8, convert_utf8_to_utf16le_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  628|      1|      ADD(utf32_length_from_utf8, convert_utf8_to_utf32_with_errors),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  629|       |
  630|       |      // these are a bit special since all input is valid
  631|      1|      ADD(utf32_length_from_latin1, convert_latin1_to_utf32),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  632|      1|      ADD(utf16_length_from_latin1, convert_latin1_to_utf16be),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  633|      1|      ADD(utf16_length_from_latin1, convert_latin1_to_utf16le),
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  634|      1|      ADD(utf8_length_from_latin1, convert_latin1_to_utf8)};
  ------------------
  |  |  553|      1|  FuzzSignature {                                                              \
  |  |  554|      1|    +[](std::span<const char> chardata) {                                      \
  |  |  555|      1|      const auto c =                                                           \
  |  |  556|      1|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  |  |  557|      1|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  |  |  558|      1|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  |  |  559|      1|              &I::lenfunc, &I::conversionfunc,                                 \
  |  |  560|      1|              std::string{NAMEOF(&I::lenfunc)},                                \
  |  |  561|      1|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  |  |  562|      1|      c.fuzz(chardata);                                                        \
  |  |  563|      1|    }                                                                          \
  |  |  564|      1|  }
  ------------------
  635|       |
  636|      1|#undef ADD
  637|      1|}
LLVMFuzzerTestOneInput:
  639|  9.63k|extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
  640|  9.63k|  static const auto fptrs = populate_functions();
  641|  9.63k|  constexpr std::size_t Ncases = fptrs.size();
  642|       |
  643|       |  // pick one of the function pointers, based on the fuzz data
  644|       |  // the first byte is which action to take. step forward
  645|       |  // several bytes so the input is aligned.
  646|  9.63k|  if (size < 4) {
  ------------------
  |  Branch (646:7): [True: 3, False: 9.62k]
  ------------------
  647|      3|    return 0;
  648|      3|  }
  649|       |
  650|  9.62k|  constexpr auto actionmask = std::bit_ceil(Ncases) - 1;
  651|  9.62k|  const auto action = data[0] & actionmask;
  652|  9.62k|  data += 4;
  653|  9.62k|  size -= 4;
  654|       |
  655|  9.62k|  if (action >= Ncases) {
  ------------------
  |  Branch (655:7): [True: 1, False: 9.62k]
  ------------------
  656|      1|    return 0;
  657|      1|  }
  658|       |
  659|  9.62k|  if constexpr (use_separate_allocation) {
  660|       |    // this is better at exercising null input and catch buffer underflows
  661|  9.62k|    const std::vector<char> separate{data, data + size};
  662|  9.62k|    fptrs[action](std::span(separate));
  663|       |  } else {
  664|       |    std::span<const char> chardata{(const char*)data, size};
  665|       |    fptrs[action](chardata);
  666|       |  }
  667|       |
  668|  9.62k|  return 0;
  669|  9.62k|}
conversion.cpp:_ZZ18populate_functionsvENK3$_0clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     99|    +[](std::span<const char> chardata) {                                      \
  555|     99|      const auto c =                                                           \
  556|     99|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     99|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     99|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     99|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     99|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     99|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     99|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     99|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     99|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     99|  constexpr auto _size = _name.size();                                \
  |  | 1183|     99|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     99|  return _nameof; }()
  ------------------
  561|     99|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     99|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     99|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     99|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     99|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     99|  constexpr auto _size = _name.size();                                \
  |  | 1183|     99|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     99|  return _nameof; }()
  ------------------
  562|     99|      c.fuzz(chardata);                                                        \
  563|     99|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    225|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    225|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    225|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    225|    static const bool do_print_testcase =
  181|    225|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    225|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 225]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    225|    do {
  189|       |      // step 0 - is the input valid?
  190|    225|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    225|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 225]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    225|                    From == UtfEncodings::UTF8) {
  198|    225|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 225]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    225|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    225|      const auto [output_length, length_agree] =
  204|    225|          calculate_length(from, inputisvalid);
  205|    225|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 225]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    225|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 108, False: 117]
  |  Branch (208:28): [True: 28, False: 80]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     28|        return;
  211|     28|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    197|      const auto [written, outputs_agree] =
  215|    197|          do_conversion(from, output_length, inputisvalid);
  216|    197|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 197]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    197|      return;
  221|    197|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    225|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    225|  validation_result verify_valid_input(FromSpan src) const {
  231|    225|    validation_result ret{};
  232|       |
  233|    225|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    225|    const auto implementations = get_supported_implementations();
  235|    225|    std::vector<simdutf::result> results;
  236|    225|    results.reserve(implementations.size());
  237|       |
  238|    675|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 675, False: 225]
  ------------------
  239|    675|      results.push_back(
  240|    675|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    675|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    675|      const bool validation2 =
  245|    675|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    675|                      src.data(), src.size());
  247|    675|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 675]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|    675|    }
  258|       |
  259|    225|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    225|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 225]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    225|    } else {
  273|    225|      ret.implementations_agree = true;
  274|    225|    }
  275|    225|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    225|      return r.error == simdutf::SUCCESS;
  277|    225|    });
  278|    225|    return ret;
  279|    225|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    450|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKNS1_6resultEE_clESI_:
  275|    459|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    459|      return r.error == simdutf::SUCCESS;
  277|    459|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    225|  bool count_the_input(FromSpan src) const {
  290|    225|    const auto implementations = get_supported_implementations();
  291|    225|    std::vector<std::size_t> results;
  292|    225|    results.reserve(implementations.size());
  293|       |
  294|    675|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 675, False: 225]
  ------------------
  295|    675|      std::size_t ret;
  296|    675|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|    675|        ret = impl->count_utf16be(src.data(), src.size());
  298|       |      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|       |        ret = impl->count_utf16le(src.data(), src.size());
  300|       |      } else if constexpr (From == UtfEncodings::UTF8) {
  301|       |        ret = impl->count_utf8(src.data(), src.size());
  302|       |      }
  303|    675|      results.push_back(ret);
  304|    675|    }
  305|    225|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    225|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 225]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|    225|    return true;
  321|    225|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    450|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    225|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    225|    length_result ret{};
  344|       |
  345|    225|    const auto implementations = get_supported_implementations();
  346|    225|    std::vector<std::size_t> results;
  347|    225|    results.reserve(implementations.size());
  348|       |
  349|    675|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 675, False: 225]
  ------------------
  350|    675|      const auto len = invoke_lengthcalc(impl, src);
  351|    675|      results.push_back(len);
  352|    675|      ret.length.push_back(len);
  353|    675|    }
  354|       |
  355|    225|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    225|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 225]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    225|    } else {
  375|    225|      ret.implementations_agree = true;
  376|    225|    }
  377|    225|    return ret;
  378|    225|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    675|                                FromSpan src) const {
  331|    675|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    675|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    450|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    197|                                  const bool inputisvalid) const {
  383|    197|    conversion_result ret{};
  384|       |
  385|    197|    const auto implementations = get_supported_implementations();
  386|       |
  387|    197|    std::vector<result<ConversionResult>> results;
  388|    197|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    197|    std::vector<std::vector<ToType>> outputbuffers;
  393|    197|    outputbuffers.reserve(implementations.size());
  394|    788|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 591, False: 197]
  ------------------
  395|    591|      auto impl = implementations[i];
  396|    591|      const ToType canary1{42};
  397|    591|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    591|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    591|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    591|      const auto success = [](const ConversionResult& r) -> bool {
  402|    591|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    591|          return r != 0;
  404|    591|        } else {
  405|    591|          return r.error == simdutf::error_code::SUCCESS;
  406|    591|        }
  407|    591|      }(implret1);
  408|    591|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    591|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    591|        const ToType canary2{25};
  414|    591|        const auto outputbuffer_first_run = outputbuffer;
  415|    591|        std::ranges::fill(outputbuffer, canary2);
  416|    591|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    591|                                          src.size(), outputbuffer.data());
  418|       |
  419|    591|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 591]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    591|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 351, False: 240]
  |  Branch (423:29): [True: 339, False: 12]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    339|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    339|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 339]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    339|        }
  440|    591|      }
  441|    591|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 339, False: 252]
  ------------------
  442|    591|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    197|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 80, False: 117]
  ------------------
  447|    240|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 240, False: 80]
  ------------------
  448|    240|        e.outputhash.clear();
  449|    240|      }
  450|     80|    }
  451|       |
  452|    197|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    197|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 197]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    197|    } else {
  474|    197|      ret.implementations_agree = true;
  475|    197|    }
  476|    197|    return ret;
  477|    197|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    591|      const auto success = [](const ConversionResult& r) -> bool {
  402|    591|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    591|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    591|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    394|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_1clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    232|    +[](std::span<const char> chardata) {                                      \
  555|    232|      const auto c =                                                           \
  556|    232|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    232|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    232|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    232|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    232|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    232|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    232|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    232|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    232|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    232|  constexpr auto _size = _name.size();                                \
  |  | 1183|    232|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    232|  return _nameof; }()
  ------------------
  561|    232|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    232|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    232|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    232|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    232|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    232|  constexpr auto _size = _name.size();                                \
  |  | 1183|    232|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    232|  return _nameof; }()
  ------------------
  562|    232|      c.fuzz(chardata);                                                        \
  563|    232|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    387|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    387|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    387|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    387|    static const bool do_print_testcase =
  181|    387|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    387|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 387]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    387|    do {
  189|       |      // step 0 - is the input valid?
  190|    387|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    387|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 387]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    387|                    From == UtfEncodings::UTF8) {
  198|    387|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 387]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    387|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    387|      const auto [output_length, length_agree] =
  204|    387|          calculate_length(from, inputisvalid);
  205|    387|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 387]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    387|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 80, False: 307]
  |  Branch (208:28): [True: 17, False: 63]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     17|        return;
  211|     17|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    370|      const auto [written, outputs_agree] =
  215|    370|          do_conversion(from, output_length, inputisvalid);
  216|    370|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 370]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    370|      return;
  221|    370|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    387|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    387|  validation_result verify_valid_input(FromSpan src) const {
  231|    387|    validation_result ret{};
  232|       |
  233|    387|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    387|    const auto implementations = get_supported_implementations();
  235|    387|    std::vector<simdutf::result> results;
  236|    387|    results.reserve(implementations.size());
  237|       |
  238|  1.16k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.16k, False: 387]
  ------------------
  239|  1.16k|      results.push_back(
  240|  1.16k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.16k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.16k|      const bool validation2 =
  245|  1.16k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.16k|                      src.data(), src.size());
  247|  1.16k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.16k]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|  1.16k|    }
  258|       |
  259|    387|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    387|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 387]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    387|    } else {
  273|    387|      ret.implementations_agree = true;
  274|    387|    }
  275|    387|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    387|      return r.error == simdutf::SUCCESS;
  277|    387|    });
  278|    387|    return ret;
  279|    387|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    774|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKNS1_6resultEE_clESI_:
  275|  1.00k|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|  1.00k|      return r.error == simdutf::SUCCESS;
  277|  1.00k|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    387|  bool count_the_input(FromSpan src) const {
  290|    387|    const auto implementations = get_supported_implementations();
  291|    387|    std::vector<std::size_t> results;
  292|    387|    results.reserve(implementations.size());
  293|       |
  294|  1.16k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.16k, False: 387]
  ------------------
  295|  1.16k|      std::size_t ret;
  296|  1.16k|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|  1.16k|        ret = impl->count_utf16be(src.data(), src.size());
  298|       |      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|       |        ret = impl->count_utf16le(src.data(), src.size());
  300|       |      } else if constexpr (From == UtfEncodings::UTF8) {
  301|       |        ret = impl->count_utf8(src.data(), src.size());
  302|       |      }
  303|  1.16k|      results.push_back(ret);
  304|  1.16k|    }
  305|    387|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    387|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 387]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|    387|    return true;
  321|    387|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    774|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    387|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    387|    length_result ret{};
  344|       |
  345|    387|    const auto implementations = get_supported_implementations();
  346|    387|    std::vector<std::size_t> results;
  347|    387|    results.reserve(implementations.size());
  348|       |
  349|  1.16k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.16k, False: 387]
  ------------------
  350|  1.16k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.16k|      results.push_back(len);
  352|  1.16k|      ret.length.push_back(len);
  353|  1.16k|    }
  354|       |
  355|    387|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    387|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 387]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    387|    } else {
  375|    387|      ret.implementations_agree = true;
  376|    387|    }
  377|    387|    return ret;
  378|    387|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.16k|                                FromSpan src) const {
  331|  1.16k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.16k|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    774|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    370|                                  const bool inputisvalid) const {
  383|    370|    conversion_result ret{};
  384|       |
  385|    370|    const auto implementations = get_supported_implementations();
  386|       |
  387|    370|    std::vector<result<ConversionResult>> results;
  388|    370|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    370|    std::vector<std::vector<ToType>> outputbuffers;
  393|    370|    outputbuffers.reserve(implementations.size());
  394|  1.48k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.11k, False: 370]
  ------------------
  395|  1.11k|      auto impl = implementations[i];
  396|  1.11k|      const ToType canary1{42};
  397|  1.11k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.11k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.11k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.11k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.11k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.11k|          return r != 0;
  404|  1.11k|        } else {
  405|  1.11k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.11k|        }
  407|  1.11k|      }(implret1);
  408|  1.11k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.11k|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|  1.11k|        const ToType canary2{25};
  414|  1.11k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.11k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.11k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.11k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.11k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.11k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.11k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 921, False: 189]
  |  Branch (423:29): [True: 912, False: 9]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    912|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    912|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 912]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    912|        }
  440|  1.11k|      }
  441|  1.11k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 912, False: 198]
  ------------------
  442|  1.11k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    370|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 63, False: 307]
  ------------------
  447|    189|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 189, False: 63]
  ------------------
  448|    189|        e.outputhash.clear();
  449|    189|      }
  450|     63|    }
  451|       |
  452|    370|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    370|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 370]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    370|    } else {
  474|    370|      ret.implementations_agree = true;
  475|    370|    }
  476|    370|    return ret;
  477|    370|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.11k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.11k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.11k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.11k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    740|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_2clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     60|    +[](std::span<const char> chardata) {                                      \
  555|     60|      const auto c =                                                           \
  556|     60|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     60|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     60|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     60|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     60|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     60|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     60|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     60|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     60|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     60|  constexpr auto _size = _name.size();                                \
  |  | 1183|     60|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     60|  return _nameof; }()
  ------------------
  561|     60|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     60|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     60|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     60|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     60|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     60|  constexpr auto _size = _name.size();                                \
  |  | 1183|     60|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     60|  return _nameof; }()
  ------------------
  562|     60|      c.fuzz(chardata);                                                        \
  563|     60|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    196|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    196|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    196|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    196|    static const bool do_print_testcase =
  181|    196|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    196|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 196]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    196|    do {
  189|       |      // step 0 - is the input valid?
  190|    196|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    196|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 196]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    196|                    From == UtfEncodings::UTF8) {
  198|    196|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 196]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    196|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    196|      const auto [output_length, length_agree] =
  204|    196|          calculate_length(from, inputisvalid);
  205|    196|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 196]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    196|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 89, False: 107]
  |  Branch (208:28): [True: 6, False: 83]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      6|        return;
  211|      6|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    190|      const auto [written, outputs_agree] =
  215|    190|          do_conversion(from, output_length, inputisvalid);
  216|    190|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 190]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    190|      return;
  221|    190|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    196|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    196|  validation_result verify_valid_input(FromSpan src) const {
  231|    196|    validation_result ret{};
  232|       |
  233|    196|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    196|    const auto implementations = get_supported_implementations();
  235|    196|    std::vector<simdutf::result> results;
  236|    196|    results.reserve(implementations.size());
  237|       |
  238|    588|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 588, False: 196]
  ------------------
  239|    588|      results.push_back(
  240|    588|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    588|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    588|      const bool validation2 =
  245|    588|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    588|                      src.data(), src.size());
  247|    588|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 588]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|    588|    }
  258|       |
  259|    196|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    196|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 196]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    196|    } else {
  273|    196|      ret.implementations_agree = true;
  274|    196|    }
  275|    196|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    196|      return r.error == simdutf::SUCCESS;
  277|    196|    });
  278|    196|    return ret;
  279|    196|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    392|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKNS1_6resultEE_clESI_:
  275|    410|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    410|      return r.error == simdutf::SUCCESS;
  277|    410|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    196|  bool count_the_input(FromSpan src) const {
  290|    196|    const auto implementations = get_supported_implementations();
  291|    196|    std::vector<std::size_t> results;
  292|    196|    results.reserve(implementations.size());
  293|       |
  294|    588|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 588, False: 196]
  ------------------
  295|    588|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|    588|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|    588|        ret = impl->count_utf16le(src.data(), src.size());
  300|       |      } else if constexpr (From == UtfEncodings::UTF8) {
  301|       |        ret = impl->count_utf8(src.data(), src.size());
  302|       |      }
  303|    588|      results.push_back(ret);
  304|    588|    }
  305|    196|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    196|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 196]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|    196|    return true;
  321|    196|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    392|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    196|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    196|    length_result ret{};
  344|       |
  345|    196|    const auto implementations = get_supported_implementations();
  346|    196|    std::vector<std::size_t> results;
  347|    196|    results.reserve(implementations.size());
  348|       |
  349|    588|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 588, False: 196]
  ------------------
  350|    588|      const auto len = invoke_lengthcalc(impl, src);
  351|    588|      results.push_back(len);
  352|    588|      ret.length.push_back(len);
  353|    588|    }
  354|       |
  355|    196|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    196|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 196]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    196|    } else {
  375|    196|      ret.implementations_agree = true;
  376|    196|    }
  377|    196|    return ret;
  378|    196|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    588|                                FromSpan src) const {
  331|    588|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    588|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    392|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    190|                                  const bool inputisvalid) const {
  383|    190|    conversion_result ret{};
  384|       |
  385|    190|    const auto implementations = get_supported_implementations();
  386|       |
  387|    190|    std::vector<result<ConversionResult>> results;
  388|    190|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    190|    std::vector<std::vector<ToType>> outputbuffers;
  393|    190|    outputbuffers.reserve(implementations.size());
  394|    760|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 570, False: 190]
  ------------------
  395|    570|      auto impl = implementations[i];
  396|    570|      const ToType canary1{42};
  397|    570|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    570|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    570|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    570|      const auto success = [](const ConversionResult& r) -> bool {
  402|    570|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    570|          return r != 0;
  404|    570|        } else {
  405|    570|          return r.error == simdutf::error_code::SUCCESS;
  406|    570|        }
  407|    570|      }(implret1);
  408|    570|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    570|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    570|        const ToType canary2{25};
  414|    570|        const auto outputbuffer_first_run = outputbuffer;
  415|    570|        std::ranges::fill(outputbuffer, canary2);
  416|    570|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    570|                                          src.size(), outputbuffer.data());
  418|       |
  419|    570|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 570]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    570|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 321, False: 249]
  |  Branch (423:29): [True: 312, False: 9]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    312|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    312|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 312]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    312|        }
  440|    570|      }
  441|    570|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 312, False: 258]
  ------------------
  442|    570|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    190|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 83, False: 107]
  ------------------
  447|    249|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 249, False: 83]
  ------------------
  448|    249|        e.outputhash.clear();
  449|    249|      }
  450|     83|    }
  451|       |
  452|    190|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    190|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 190]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    190|    } else {
  474|    190|      ret.implementations_agree = true;
  475|    190|    }
  476|    190|    return ret;
  477|    190|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    570|      const auto success = [](const ConversionResult& r) -> bool {
  402|    570|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    570|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    570|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    380|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_3clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    219|    +[](std::span<const char> chardata) {                                      \
  555|    219|      const auto c =                                                           \
  556|    219|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    219|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    219|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    219|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    219|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    219|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    219|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    219|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    219|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    219|  constexpr auto _size = _name.size();                                \
  |  | 1183|    219|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    219|  return _nameof; }()
  ------------------
  561|    219|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    219|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    219|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    219|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    219|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    219|  constexpr auto _size = _name.size();                                \
  |  | 1183|    219|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    219|  return _nameof; }()
  ------------------
  562|    219|      c.fuzz(chardata);                                                        \
  563|    219|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    415|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    415|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    415|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    415|    static const bool do_print_testcase =
  181|    415|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    415|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 415]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    415|    do {
  189|       |      // step 0 - is the input valid?
  190|    415|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    415|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 415]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    415|                    From == UtfEncodings::UTF8) {
  198|    415|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 415]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    415|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    415|      const auto [output_length, length_agree] =
  204|    415|          calculate_length(from, inputisvalid);
  205|    415|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 415]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    415|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 101, False: 314]
  |  Branch (208:28): [True: 14, False: 87]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     14|        return;
  211|     14|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    401|      const auto [written, outputs_agree] =
  215|    401|          do_conversion(from, output_length, inputisvalid);
  216|    401|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 401]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    401|      return;
  221|    401|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    415|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    415|  validation_result verify_valid_input(FromSpan src) const {
  231|    415|    validation_result ret{};
  232|       |
  233|    415|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    415|    const auto implementations = get_supported_implementations();
  235|    415|    std::vector<simdutf::result> results;
  236|    415|    results.reserve(implementations.size());
  237|       |
  238|  1.24k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.24k, False: 415]
  ------------------
  239|  1.24k|      results.push_back(
  240|  1.24k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.24k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.24k|      const bool validation2 =
  245|  1.24k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.24k|                      src.data(), src.size());
  247|  1.24k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.24k]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|  1.24k|    }
  258|       |
  259|    415|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    415|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 415]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    415|    } else {
  273|    415|      ret.implementations_agree = true;
  274|    415|    }
  275|    415|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    415|      return r.error == simdutf::SUCCESS;
  277|    415|    });
  278|    415|    return ret;
  279|    415|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    830|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKNS1_6resultEE_clESI_:
  275|  1.04k|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|  1.04k|      return r.error == simdutf::SUCCESS;
  277|  1.04k|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    415|  bool count_the_input(FromSpan src) const {
  290|    415|    const auto implementations = get_supported_implementations();
  291|    415|    std::vector<std::size_t> results;
  292|    415|    results.reserve(implementations.size());
  293|       |
  294|  1.24k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.24k, False: 415]
  ------------------
  295|  1.24k|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|  1.24k|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|  1.24k|        ret = impl->count_utf16le(src.data(), src.size());
  300|       |      } else if constexpr (From == UtfEncodings::UTF8) {
  301|       |        ret = impl->count_utf8(src.data(), src.size());
  302|       |      }
  303|  1.24k|      results.push_back(ret);
  304|  1.24k|    }
  305|    415|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    415|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 415]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|    415|    return true;
  321|    415|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    830|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    415|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    415|    length_result ret{};
  344|       |
  345|    415|    const auto implementations = get_supported_implementations();
  346|    415|    std::vector<std::size_t> results;
  347|    415|    results.reserve(implementations.size());
  348|       |
  349|  1.24k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.24k, False: 415]
  ------------------
  350|  1.24k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.24k|      results.push_back(len);
  352|  1.24k|      ret.length.push_back(len);
  353|  1.24k|    }
  354|       |
  355|    415|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    415|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 415]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    415|    } else {
  375|    415|      ret.implementations_agree = true;
  376|    415|    }
  377|    415|    return ret;
  378|    415|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.24k|                                FromSpan src) const {
  331|  1.24k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.24k|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    830|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    401|                                  const bool inputisvalid) const {
  383|    401|    conversion_result ret{};
  384|       |
  385|    401|    const auto implementations = get_supported_implementations();
  386|       |
  387|    401|    std::vector<result<ConversionResult>> results;
  388|    401|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    401|    std::vector<std::vector<ToType>> outputbuffers;
  393|    401|    outputbuffers.reserve(implementations.size());
  394|  1.60k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.20k, False: 401]
  ------------------
  395|  1.20k|      auto impl = implementations[i];
  396|  1.20k|      const ToType canary1{42};
  397|  1.20k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.20k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.20k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.20k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.20k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.20k|          return r != 0;
  404|  1.20k|        } else {
  405|  1.20k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.20k|        }
  407|  1.20k|      }(implret1);
  408|  1.20k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.20k|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|  1.20k|        const ToType canary2{25};
  414|  1.20k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.20k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.20k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.20k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.20k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.20k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.20k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 942, False: 261]
  |  Branch (423:29): [True: 933, False: 9]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    933|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    933|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 933]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    933|        }
  440|  1.20k|      }
  441|  1.20k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 933, False: 270]
  ------------------
  442|  1.20k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    401|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 87, False: 314]
  ------------------
  447|    261|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 261, False: 87]
  ------------------
  448|    261|        e.outputhash.clear();
  449|    261|      }
  450|     87|    }
  451|       |
  452|    401|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    401|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 401]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    401|    } else {
  474|    401|      ret.implementations_agree = true;
  475|    401|    }
  476|    401|    return ret;
  477|    401|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.20k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.20k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.20k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.20k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    802|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_4clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     37|    +[](std::span<const char> chardata) {                                      \
  555|     37|      const auto c =                                                           \
  556|     37|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     37|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     37|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     37|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     37|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     37|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     37|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     37|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     37|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     37|  constexpr auto _size = _name.size();                                \
  |  | 1183|     37|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     37|  return _nameof; }()
  ------------------
  561|     37|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     37|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     37|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     37|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     37|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     37|  constexpr auto _size = _name.size();                                \
  |  | 1183|     37|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     37|  return _nameof; }()
  ------------------
  562|     37|      c.fuzz(chardata);                                                        \
  563|     37|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    232|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    232|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    232|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    232|    static const bool do_print_testcase =
  181|    232|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    232|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 232]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    232|    do {
  189|       |      // step 0 - is the input valid?
  190|    232|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    232|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 232]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|       |                    From == UtfEncodings::UTF8) {
  198|       |        if (!count_the_input(from) && !allow_implementations_to_differ)
  199|       |          break;
  200|       |      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    232|      const auto [output_length, length_agree] =
  204|    232|          calculate_length(from, inputisvalid);
  205|    232|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 232]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    232|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 123, False: 109]
  |  Branch (208:28): [True: 1, False: 122]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      1|        return;
  211|      1|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    231|      const auto [written, outputs_agree] =
  215|    231|          do_conversion(from, output_length, inputisvalid);
  216|    231|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 231]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    231|      return;
  221|    231|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    232|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    232|  validation_result verify_valid_input(FromSpan src) const {
  231|    232|    validation_result ret{};
  232|       |
  233|    232|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    232|    const auto implementations = get_supported_implementations();
  235|    232|    std::vector<simdutf::result> results;
  236|    232|    results.reserve(implementations.size());
  237|       |
  238|    696|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 696, False: 232]
  ------------------
  239|    696|      results.push_back(
  240|    696|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    696|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    696|      const bool validation2 =
  245|    696|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    696|                      src.data(), src.size());
  247|    696|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 696]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|    696|    }
  258|       |
  259|    232|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    232|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 232]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    232|    } else {
  273|    232|      ret.implementations_agree = true;
  274|    232|    }
  275|    232|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    232|      return r.error == simdutf::SUCCESS;
  277|    232|    });
  278|    232|    return ret;
  279|    232|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    464|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKNS1_6resultEE_clESI_:
  275|    450|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    450|      return r.error == simdutf::SUCCESS;
  277|    450|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    232|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    232|    length_result ret{};
  344|       |
  345|    232|    const auto implementations = get_supported_implementations();
  346|    232|    std::vector<std::size_t> results;
  347|    232|    results.reserve(implementations.size());
  348|       |
  349|    696|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 696, False: 232]
  ------------------
  350|    696|      const auto len = invoke_lengthcalc(impl, src);
  351|    696|      results.push_back(len);
  352|    696|      ret.length.push_back(len);
  353|    696|    }
  354|       |
  355|    232|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    232|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 232]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    232|    } else {
  375|    232|      ret.implementations_agree = true;
  376|    232|    }
  377|    232|    return ret;
  378|    232|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    696|                                FromSpan src) const {
  331|    696|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    696|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    464|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    231|                                  const bool inputisvalid) const {
  383|    231|    conversion_result ret{};
  384|       |
  385|    231|    const auto implementations = get_supported_implementations();
  386|       |
  387|    231|    std::vector<result<ConversionResult>> results;
  388|    231|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    231|    std::vector<std::vector<ToType>> outputbuffers;
  393|    231|    outputbuffers.reserve(implementations.size());
  394|    924|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 693, False: 231]
  ------------------
  395|    693|      auto impl = implementations[i];
  396|    693|      const ToType canary1{42};
  397|    693|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    693|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    693|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    693|      const auto success = [](const ConversionResult& r) -> bool {
  402|    693|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    693|          return r != 0;
  404|    693|        } else {
  405|    693|          return r.error == simdutf::error_code::SUCCESS;
  406|    693|        }
  407|    693|      }(implret1);
  408|    693|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    693|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    693|        const ToType canary2{25};
  414|    693|        const auto outputbuffer_first_run = outputbuffer;
  415|    693|        std::ranges::fill(outputbuffer, canary2);
  416|    693|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    693|                                          src.size(), outputbuffer.data());
  418|       |
  419|    693|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 693]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    693|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 327, False: 366]
  |  Branch (423:29): [True: 318, False: 9]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    318|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    318|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 318]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    318|        }
  440|    693|      }
  441|    693|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 318, False: 375]
  ------------------
  442|    693|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    231|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 122, False: 109]
  ------------------
  447|    366|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 366, False: 122]
  ------------------
  448|    366|        e.outputhash.clear();
  449|    366|      }
  450|    122|    }
  451|       |
  452|    231|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    231|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 231]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    231|    } else {
  474|    231|      ret.implementations_agree = true;
  475|    231|    }
  476|    231|    return ret;
  477|    231|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    693|      const auto success = [](const ConversionResult& r) -> bool {
  402|    693|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    693|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    693|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    462|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_5clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    120|    +[](std::span<const char> chardata) {                                      \
  555|    120|      const auto c =                                                           \
  556|    120|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    120|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    120|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    120|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    120|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    120|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    120|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    120|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    120|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    120|  constexpr auto _size = _name.size();                                \
  |  | 1183|    120|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    120|  return _nameof; }()
  ------------------
  561|    120|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    120|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    120|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    120|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    120|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    120|  constexpr auto _size = _name.size();                                \
  |  | 1183|    120|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    120|  return _nameof; }()
  ------------------
  562|    120|      c.fuzz(chardata);                                                        \
  563|    120|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    331|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    331|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    331|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    331|    static const bool do_print_testcase =
  181|    331|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    331|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 331]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    331|    do {
  189|       |      // step 0 - is the input valid?
  190|    331|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    331|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 331]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|       |                    From == UtfEncodings::UTF8) {
  198|       |        if (!count_the_input(from) && !allow_implementations_to_differ)
  199|       |          break;
  200|       |      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    331|      const auto [output_length, length_agree] =
  204|    331|          calculate_length(from, inputisvalid);
  205|    331|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 331]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    331|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 161, False: 170]
  |  Branch (208:28): [True: 9, False: 152]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      9|        return;
  211|      9|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    322|      const auto [written, outputs_agree] =
  215|    322|          do_conversion(from, output_length, inputisvalid);
  216|    322|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 322]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    322|      return;
  221|    322|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    331|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    331|  validation_result verify_valid_input(FromSpan src) const {
  231|    331|    validation_result ret{};
  232|       |
  233|    331|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    331|    const auto implementations = get_supported_implementations();
  235|    331|    std::vector<simdutf::result> results;
  236|    331|    results.reserve(implementations.size());
  237|       |
  238|    993|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 993, False: 331]
  ------------------
  239|    993|      results.push_back(
  240|    993|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    993|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    993|      const bool validation2 =
  245|    993|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    993|                      src.data(), src.size());
  247|    993|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 993]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|    993|    }
  258|       |
  259|    331|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    331|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 331]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    331|    } else {
  273|    331|      ret.implementations_agree = true;
  274|    331|    }
  275|    331|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    331|      return r.error == simdutf::SUCCESS;
  277|    331|    });
  278|    331|    return ret;
  279|    331|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    662|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKNS1_6resultEE_clESI_:
  275|    671|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    671|      return r.error == simdutf::SUCCESS;
  277|    671|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    331|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    331|    length_result ret{};
  344|       |
  345|    331|    const auto implementations = get_supported_implementations();
  346|    331|    std::vector<std::size_t> results;
  347|    331|    results.reserve(implementations.size());
  348|       |
  349|    993|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 993, False: 331]
  ------------------
  350|    993|      const auto len = invoke_lengthcalc(impl, src);
  351|    993|      results.push_back(len);
  352|    993|      ret.length.push_back(len);
  353|    993|    }
  354|       |
  355|    331|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    331|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 331]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    331|    } else {
  375|    331|      ret.implementations_agree = true;
  376|    331|    }
  377|    331|    return ret;
  378|    331|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    993|                                FromSpan src) const {
  331|    993|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    993|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    662|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    322|                                  const bool inputisvalid) const {
  383|    322|    conversion_result ret{};
  384|       |
  385|    322|    const auto implementations = get_supported_implementations();
  386|       |
  387|    322|    std::vector<result<ConversionResult>> results;
  388|    322|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    322|    std::vector<std::vector<ToType>> outputbuffers;
  393|    322|    outputbuffers.reserve(implementations.size());
  394|  1.28k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 966, False: 322]
  ------------------
  395|    966|      auto impl = implementations[i];
  396|    966|      const ToType canary1{42};
  397|    966|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    966|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    966|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    966|      const auto success = [](const ConversionResult& r) -> bool {
  402|    966|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    966|          return r != 0;
  404|    966|        } else {
  405|    966|          return r.error == simdutf::error_code::SUCCESS;
  406|    966|        }
  407|    966|      }(implret1);
  408|    966|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    966|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    966|        const ToType canary2{25};
  414|    966|        const auto outputbuffer_first_run = outputbuffer;
  415|    966|        std::ranges::fill(outputbuffer, canary2);
  416|    966|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    966|                                          src.size(), outputbuffer.data());
  418|       |
  419|    966|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 966]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    966|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 510, False: 456]
  |  Branch (423:29): [True: 495, False: 15]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    495|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    495|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 495]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    495|        }
  440|    966|      }
  441|    966|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 495, False: 471]
  ------------------
  442|    966|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    322|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 152, False: 170]
  ------------------
  447|    456|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 456, False: 152]
  ------------------
  448|    456|        e.outputhash.clear();
  449|    456|      }
  450|    152|    }
  451|       |
  452|    322|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    322|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 322]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    322|    } else {
  474|    322|      ret.implementations_agree = true;
  475|    322|    }
  476|    322|    return ret;
  477|    322|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    966|      const auto success = [](const ConversionResult& r) -> bool {
  402|    966|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    966|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    966|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    644|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_6clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    108|    +[](std::span<const char> chardata) {                                      \
  555|    108|      const auto c =                                                           \
  556|    108|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    108|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    108|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    108|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    108|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    108|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    108|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    108|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    108|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    108|  constexpr auto _size = _name.size();                                \
  |  | 1183|    108|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    108|  return _nameof; }()
  ------------------
  561|    108|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    108|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    108|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    108|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    108|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    108|  constexpr auto _size = _name.size();                                \
  |  | 1183|    108|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    108|  return _nameof; }()
  ------------------
  562|    108|      c.fuzz(chardata);                                                        \
  563|    108|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    400|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    400|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    400|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    400|    static const bool do_print_testcase =
  181|    400|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    400|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 400]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    400|    do {
  189|       |      // step 0 - is the input valid?
  190|    400|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    400|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 400]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|       |                    From == UtfEncodings::UTF8) {
  198|       |        if (!count_the_input(from) && !allow_implementations_to_differ)
  199|       |          break;
  200|       |      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    400|      const auto [output_length, length_agree] =
  204|    400|          calculate_length(from, inputisvalid);
  205|    400|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 400]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    400|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 257, False: 143]
  |  Branch (208:28): [True: 7, False: 250]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      7|        return;
  211|      7|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    393|      const auto [written, outputs_agree] =
  215|    393|          do_conversion(from, output_length, inputisvalid);
  216|    393|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 393]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    393|      return;
  221|    393|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    400|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    400|  validation_result verify_valid_input(FromSpan src) const {
  231|    400|    validation_result ret{};
  232|       |
  233|    400|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    400|    const auto implementations = get_supported_implementations();
  235|    400|    std::vector<simdutf::result> results;
  236|    400|    results.reserve(implementations.size());
  237|       |
  238|  1.20k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.20k, False: 400]
  ------------------
  239|  1.20k|      results.push_back(
  240|  1.20k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.20k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.20k|      const bool validation2 =
  245|  1.20k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.20k|                      src.data(), src.size());
  247|  1.20k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.20k]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|  1.20k|    }
  258|       |
  259|    400|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    400|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 400]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    400|    } else {
  273|    400|      ret.implementations_agree = true;
  274|    400|    }
  275|    400|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    400|      return r.error == simdutf::SUCCESS;
  277|    400|    });
  278|    400|    return ret;
  279|    400|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    800|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKNS1_6resultEE_clESI_:
  275|    686|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    686|      return r.error == simdutf::SUCCESS;
  277|    686|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    400|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    400|    length_result ret{};
  344|       |
  345|    400|    const auto implementations = get_supported_implementations();
  346|    400|    std::vector<std::size_t> results;
  347|    400|    results.reserve(implementations.size());
  348|       |
  349|  1.20k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.20k, False: 400]
  ------------------
  350|  1.20k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.20k|      results.push_back(len);
  352|  1.20k|      ret.length.push_back(len);
  353|  1.20k|    }
  354|       |
  355|    400|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    400|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 400]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    400|    } else {
  375|    400|      ret.implementations_agree = true;
  376|    400|    }
  377|    400|    return ret;
  378|    400|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.20k|                                FromSpan src) const {
  331|  1.20k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.20k|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    800|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    393|                                  const bool inputisvalid) const {
  383|    393|    conversion_result ret{};
  384|       |
  385|    393|    const auto implementations = get_supported_implementations();
  386|       |
  387|    393|    std::vector<result<ConversionResult>> results;
  388|    393|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    393|    std::vector<std::vector<ToType>> outputbuffers;
  393|    393|    outputbuffers.reserve(implementations.size());
  394|  1.57k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.17k, False: 393]
  ------------------
  395|  1.17k|      auto impl = implementations[i];
  396|  1.17k|      const ToType canary1{42};
  397|  1.17k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.17k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.17k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.17k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.17k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.17k|          return r != 0;
  404|  1.17k|        } else {
  405|  1.17k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.17k|        }
  407|  1.17k|      }(implret1);
  408|  1.17k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.17k|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|  1.17k|        const ToType canary2{25};
  414|  1.17k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.17k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.17k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.17k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.17k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.17k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.17k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 429, False: 750]
  |  Branch (423:29): [True: 420, False: 9]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    420|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    420|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 420]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    420|        }
  440|  1.17k|      }
  441|  1.17k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 420, False: 759]
  ------------------
  442|  1.17k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    393|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 250, False: 143]
  ------------------
  447|    750|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 750, False: 250]
  ------------------
  448|    750|        e.outputhash.clear();
  449|    750|      }
  450|    250|    }
  451|       |
  452|    393|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    393|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 393]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    393|    } else {
  474|    393|      ret.implementations_agree = true;
  475|    393|    }
  476|    393|    return ret;
  477|    393|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  1.17k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.17k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.17k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  1.17k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    786|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_7clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    399|    +[](std::span<const char> chardata) {                                      \
  555|    399|      const auto c =                                                           \
  556|    399|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    399|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    399|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    399|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    399|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    399|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    399|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    399|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    399|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    399|  constexpr auto _size = _name.size();                                \
  |  | 1183|    399|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    399|  return _nameof; }()
  ------------------
  561|    399|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    399|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    399|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    399|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    399|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    399|  constexpr auto _size = _name.size();                                \
  |  | 1183|    399|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    399|  return _nameof; }()
  ------------------
  562|    399|      c.fuzz(chardata);                                                        \
  563|    399|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    879|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    879|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    879|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    879|    static const bool do_print_testcase =
  181|    879|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    879|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 879]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    879|    do {
  189|       |      // step 0 - is the input valid?
  190|    879|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    879|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 879]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    879|                    From == UtfEncodings::UTF8) {
  198|    879|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 879]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    879|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    879|      const auto [output_length, length_agree] =
  204|    879|          calculate_length(from, inputisvalid);
  205|    879|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 879]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    879|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 347, False: 532]
  |  Branch (208:28): [True: 13, False: 334]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     13|        return;
  211|     13|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    866|      const auto [written, outputs_agree] =
  215|    866|          do_conversion(from, output_length, inputisvalid);
  216|    866|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 866]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    866|      return;
  221|    866|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    879|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    879|  validation_result verify_valid_input(FromSpan src) const {
  231|    879|    validation_result ret{};
  232|       |
  233|    879|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    879|    const auto implementations = get_supported_implementations();
  235|    879|    std::vector<simdutf::result> results;
  236|    879|    results.reserve(implementations.size());
  237|       |
  238|  2.63k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 2.63k, False: 879]
  ------------------
  239|  2.63k|      results.push_back(
  240|  2.63k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  2.63k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  2.63k|      const bool validation2 =
  245|  2.63k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  2.63k|                      src.data(), src.size());
  247|  2.63k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 2.63k]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|  2.63k|    }
  258|       |
  259|    879|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    879|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 879]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    879|    } else {
  273|    879|      ret.implementations_agree = true;
  274|    879|    }
  275|    879|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    879|      return r.error == simdutf::SUCCESS;
  277|    879|    });
  278|    879|    return ret;
  279|    879|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|  1.75k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKNS1_6resultEE_clESI_:
  275|  1.94k|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|  1.94k|      return r.error == simdutf::SUCCESS;
  277|  1.94k|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    879|  bool count_the_input(FromSpan src) const {
  290|    879|    const auto implementations = get_supported_implementations();
  291|    879|    std::vector<std::size_t> results;
  292|    879|    results.reserve(implementations.size());
  293|       |
  294|  2.63k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 2.63k, False: 879]
  ------------------
  295|  2.63k|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|       |      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|       |        ret = impl->count_utf16le(src.data(), src.size());
  300|  2.63k|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|  2.63k|        ret = impl->count_utf8(src.data(), src.size());
  302|  2.63k|      }
  303|  2.63k|      results.push_back(ret);
  304|  2.63k|    }
  305|    879|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    879|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 879]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|    879|    return true;
  321|    879|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|  1.75k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    879|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    879|    length_result ret{};
  344|       |
  345|    879|    const auto implementations = get_supported_implementations();
  346|    879|    std::vector<std::size_t> results;
  347|    879|    results.reserve(implementations.size());
  348|       |
  349|  2.63k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 2.63k, False: 879]
  ------------------
  350|  2.63k|      const auto len = invoke_lengthcalc(impl, src);
  351|  2.63k|      results.push_back(len);
  352|  2.63k|      ret.length.push_back(len);
  353|  2.63k|    }
  354|       |
  355|    879|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    879|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 879]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    879|    } else {
  375|    879|      ret.implementations_agree = true;
  376|    879|    }
  377|    879|    return ret;
  378|    879|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  2.63k|                                FromSpan src) const {
  331|  2.63k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  2.63k|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|  1.75k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    866|                                  const bool inputisvalid) const {
  383|    866|    conversion_result ret{};
  384|       |
  385|    866|    const auto implementations = get_supported_implementations();
  386|       |
  387|    866|    std::vector<result<ConversionResult>> results;
  388|    866|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    866|    std::vector<std::vector<ToType>> outputbuffers;
  393|    866|    outputbuffers.reserve(implementations.size());
  394|  3.46k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 2.59k, False: 866]
  ------------------
  395|  2.59k|      auto impl = implementations[i];
  396|  2.59k|      const ToType canary1{42};
  397|  2.59k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  2.59k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  2.59k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  2.59k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  2.59k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  2.59k|          return r != 0;
  404|  2.59k|        } else {
  405|  2.59k|          return r.error == simdutf::error_code::SUCCESS;
  406|  2.59k|        }
  407|  2.59k|      }(implret1);
  408|  2.59k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  2.59k|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|  2.59k|        const ToType canary2{25};
  414|  2.59k|        const auto outputbuffer_first_run = outputbuffer;
  415|  2.59k|        std::ranges::fill(outputbuffer, canary2);
  416|  2.59k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  2.59k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  2.59k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 2.59k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  2.59k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 1.59k, False: 1.00k]
  |  Branch (423:29): [True: 1.58k, False: 9]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|  1.58k|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|  1.58k|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 1.58k]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|  1.58k|        }
  440|  2.59k|      }
  441|  2.59k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 1.58k, False: 1.01k]
  ------------------
  442|  2.59k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    866|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 334, False: 532]
  ------------------
  447|  1.00k|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 1.00k, False: 334]
  ------------------
  448|  1.00k|        e.outputhash.clear();
  449|  1.00k|      }
  450|    334|    }
  451|       |
  452|    866|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    866|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 866]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    866|    } else {
  474|    866|      ret.implementations_agree = true;
  475|    866|    }
  476|    866|    return ret;
  477|    866|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  2.59k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  2.59k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  2.59k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  2.59k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|  1.73k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_8clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    275|    +[](std::span<const char> chardata) {                                      \
  555|    275|      const auto c =                                                           \
  556|    275|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    275|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    275|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    275|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    275|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    275|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    275|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    275|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    275|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    275|  constexpr auto _size = _name.size();                                \
  |  | 1183|    275|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    275|  return _nameof; }()
  ------------------
  561|    275|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    275|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    275|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    275|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    275|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    275|  constexpr auto _size = _name.size();                                \
  |  | 1183|    275|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    275|  return _nameof; }()
  ------------------
  562|    275|      c.fuzz(chardata);                                                        \
  563|    275|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    767|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    767|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    767|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    767|    static const bool do_print_testcase =
  181|    767|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    767|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 767]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    767|    do {
  189|       |      // step 0 - is the input valid?
  190|    767|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    767|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 767]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    767|                    From == UtfEncodings::UTF8) {
  198|    767|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 767]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    767|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    767|      const auto [output_length, length_agree] =
  204|    767|          calculate_length(from, inputisvalid);
  205|    767|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 767]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    767|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 348, False: 419]
  |  Branch (208:28): [True: 11, False: 337]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|     11|        return;
  211|     11|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    756|      const auto [written, outputs_agree] =
  215|    756|          do_conversion(from, output_length, inputisvalid);
  216|    756|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 756]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    756|      return;
  221|    756|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    767|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    767|  validation_result verify_valid_input(FromSpan src) const {
  231|    767|    validation_result ret{};
  232|       |
  233|    767|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    767|    const auto implementations = get_supported_implementations();
  235|    767|    std::vector<simdutf::result> results;
  236|    767|    results.reserve(implementations.size());
  237|       |
  238|  2.30k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 2.30k, False: 767]
  ------------------
  239|  2.30k|      results.push_back(
  240|  2.30k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  2.30k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  2.30k|      const bool validation2 =
  245|  2.30k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  2.30k|                      src.data(), src.size());
  247|  2.30k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 2.30k]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|  2.30k|    }
  258|       |
  259|    767|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    767|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 767]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    767|    } else {
  273|    767|      ret.implementations_agree = true;
  274|    767|    }
  275|    767|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    767|      return r.error == simdutf::SUCCESS;
  277|    767|    });
  278|    767|    return ret;
  279|    767|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|  1.53k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKNS1_6resultEE_clESI_:
  275|  1.60k|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|  1.60k|      return r.error == simdutf::SUCCESS;
  277|  1.60k|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    767|  bool count_the_input(FromSpan src) const {
  290|    767|    const auto implementations = get_supported_implementations();
  291|    767|    std::vector<std::size_t> results;
  292|    767|    results.reserve(implementations.size());
  293|       |
  294|  2.30k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 2.30k, False: 767]
  ------------------
  295|  2.30k|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|       |      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|       |        ret = impl->count_utf16le(src.data(), src.size());
  300|  2.30k|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|  2.30k|        ret = impl->count_utf8(src.data(), src.size());
  302|  2.30k|      }
  303|  2.30k|      results.push_back(ret);
  304|  2.30k|    }
  305|    767|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    767|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 767]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|    767|    return true;
  321|    767|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|  1.53k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    767|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    767|    length_result ret{};
  344|       |
  345|    767|    const auto implementations = get_supported_implementations();
  346|    767|    std::vector<std::size_t> results;
  347|    767|    results.reserve(implementations.size());
  348|       |
  349|  2.30k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 2.30k, False: 767]
  ------------------
  350|  2.30k|      const auto len = invoke_lengthcalc(impl, src);
  351|  2.30k|      results.push_back(len);
  352|  2.30k|      ret.length.push_back(len);
  353|  2.30k|    }
  354|       |
  355|    767|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    767|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 767]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    767|    } else {
  375|    767|      ret.implementations_agree = true;
  376|    767|    }
  377|    767|    return ret;
  378|    767|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  2.30k|                                FromSpan src) const {
  331|  2.30k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  2.30k|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|  1.53k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    756|                                  const bool inputisvalid) const {
  383|    756|    conversion_result ret{};
  384|       |
  385|    756|    const auto implementations = get_supported_implementations();
  386|       |
  387|    756|    std::vector<result<ConversionResult>> results;
  388|    756|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    756|    std::vector<std::vector<ToType>> outputbuffers;
  393|    756|    outputbuffers.reserve(implementations.size());
  394|  3.02k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 2.26k, False: 756]
  ------------------
  395|  2.26k|      auto impl = implementations[i];
  396|  2.26k|      const ToType canary1{42};
  397|  2.26k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  2.26k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  2.26k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  2.26k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  2.26k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  2.26k|          return r != 0;
  404|  2.26k|        } else {
  405|  2.26k|          return r.error == simdutf::error_code::SUCCESS;
  406|  2.26k|        }
  407|  2.26k|      }(implret1);
  408|  2.26k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  2.26k|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|  2.26k|        const ToType canary2{25};
  414|  2.26k|        const auto outputbuffer_first_run = outputbuffer;
  415|  2.26k|        std::ranges::fill(outputbuffer, canary2);
  416|  2.26k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  2.26k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  2.26k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 2.26k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  2.26k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 1.25k, False: 1.01k]
  |  Branch (423:29): [True: 1.24k, False: 9]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|  1.24k|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|  1.24k|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 1.24k]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|  1.24k|        }
  440|  2.26k|      }
  441|  2.26k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 1.24k, False: 1.02k]
  ------------------
  442|  2.26k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    756|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 337, False: 419]
  ------------------
  447|  1.01k|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 1.01k, False: 337]
  ------------------
  448|  1.01k|        e.outputhash.clear();
  449|  1.01k|      }
  450|    337|    }
  451|       |
  452|    756|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    756|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 756]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    756|    } else {
  474|    756|      ret.implementations_agree = true;
  475|    756|    }
  476|    756|    return ret;
  477|    756|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  2.26k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  2.26k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  2.26k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  2.26k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|  1.51k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK3$_9clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    318|    +[](std::span<const char> chardata) {                                      \
  555|    318|      const auto c =                                                           \
  556|    318|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    318|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    318|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    318|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    318|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    318|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    318|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    318|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    318|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    318|  constexpr auto _size = _name.size();                                \
  |  | 1183|    318|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    318|  return _nameof; }()
  ------------------
  561|    318|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    318|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    318|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    318|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    318|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    318|  constexpr auto _size = _name.size();                                \
  |  | 1183|    318|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    318|  return _nameof; }()
  ------------------
  562|    318|      c.fuzz(chardata);                                                        \
  563|    318|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    778|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    778|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    778|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    778|    static const bool do_print_testcase =
  181|    778|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    778|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 778]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    778|    do {
  189|       |      // step 0 - is the input valid?
  190|    778|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    778|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 778]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    778|                    From == UtfEncodings::UTF8) {
  198|    778|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 778]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    778|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    778|      const auto [output_length, length_agree] =
  204|    778|          calculate_length(from, inputisvalid);
  205|    778|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 778]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    778|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 314, False: 464]
  |  Branch (208:28): [True: 4, False: 310]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      4|        return;
  211|      4|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    774|      const auto [written, outputs_agree] =
  215|    774|          do_conversion(from, output_length, inputisvalid);
  216|    774|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 774]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    774|      return;
  221|    774|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    778|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    778|  validation_result verify_valid_input(FromSpan src) const {
  231|    778|    validation_result ret{};
  232|       |
  233|    778|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    778|    const auto implementations = get_supported_implementations();
  235|    778|    std::vector<simdutf::result> results;
  236|    778|    results.reserve(implementations.size());
  237|       |
  238|  2.33k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 2.33k, False: 778]
  ------------------
  239|  2.33k|      results.push_back(
  240|  2.33k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  2.33k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  2.33k|      const bool validation2 =
  245|  2.33k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  2.33k|                      src.data(), src.size());
  247|  2.33k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 2.33k]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|  2.33k|    }
  258|       |
  259|    778|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    778|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 778]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    778|    } else {
  273|    778|      ret.implementations_agree = true;
  274|    778|    }
  275|    778|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    778|      return r.error == simdutf::SUCCESS;
  277|    778|    });
  278|    778|    return ret;
  279|    778|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|  1.55k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKNS1_6resultEE_clESI_:
  275|  1.70k|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|  1.70k|      return r.error == simdutf::SUCCESS;
  277|  1.70k|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    778|  bool count_the_input(FromSpan src) const {
  290|    778|    const auto implementations = get_supported_implementations();
  291|    778|    std::vector<std::size_t> results;
  292|    778|    results.reserve(implementations.size());
  293|       |
  294|  2.33k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 2.33k, False: 778]
  ------------------
  295|  2.33k|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|       |      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|       |        ret = impl->count_utf16le(src.data(), src.size());
  300|  2.33k|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|  2.33k|        ret = impl->count_utf8(src.data(), src.size());
  302|  2.33k|      }
  303|  2.33k|      results.push_back(ret);
  304|  2.33k|    }
  305|    778|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    778|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 778]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|    778|    return true;
  321|    778|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|  1.55k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    778|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    778|    length_result ret{};
  344|       |
  345|    778|    const auto implementations = get_supported_implementations();
  346|    778|    std::vector<std::size_t> results;
  347|    778|    results.reserve(implementations.size());
  348|       |
  349|  2.33k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 2.33k, False: 778]
  ------------------
  350|  2.33k|      const auto len = invoke_lengthcalc(impl, src);
  351|  2.33k|      results.push_back(len);
  352|  2.33k|      ret.length.push_back(len);
  353|  2.33k|    }
  354|       |
  355|    778|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    778|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 778]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    778|    } else {
  375|    778|      ret.implementations_agree = true;
  376|    778|    }
  377|    778|    return ret;
  378|    778|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  2.33k|                                FromSpan src) const {
  331|  2.33k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  2.33k|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|  1.55k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    774|                                  const bool inputisvalid) const {
  383|    774|    conversion_result ret{};
  384|       |
  385|    774|    const auto implementations = get_supported_implementations();
  386|       |
  387|    774|    std::vector<result<ConversionResult>> results;
  388|    774|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    774|    std::vector<std::vector<ToType>> outputbuffers;
  393|    774|    outputbuffers.reserve(implementations.size());
  394|  3.09k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 2.32k, False: 774]
  ------------------
  395|  2.32k|      auto impl = implementations[i];
  396|  2.32k|      const ToType canary1{42};
  397|  2.32k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  2.32k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  2.32k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  2.32k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  2.32k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  2.32k|          return r != 0;
  404|  2.32k|        } else {
  405|  2.32k|          return r.error == simdutf::error_code::SUCCESS;
  406|  2.32k|        }
  407|  2.32k|      }(implret1);
  408|  2.32k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  2.32k|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|  2.32k|        const ToType canary2{25};
  414|  2.32k|        const auto outputbuffer_first_run = outputbuffer;
  415|  2.32k|        std::ranges::fill(outputbuffer, canary2);
  416|  2.32k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  2.32k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  2.32k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 2.32k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  2.32k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 1.39k, False: 930]
  |  Branch (423:29): [True: 1.38k, False: 6]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|  1.38k|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|  1.38k|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 1.38k]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|  1.38k|        }
  440|  2.32k|      }
  441|  2.32k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 1.38k, False: 936]
  ------------------
  442|  2.32k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    774|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 310, False: 464]
  ------------------
  447|    930|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 930, False: 310]
  ------------------
  448|    930|        e.outputhash.clear();
  449|    930|      }
  450|    310|    }
  451|       |
  452|    774|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    774|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 774]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    774|    } else {
  474|    774|      ret.implementations_agree = true;
  475|    774|    }
  476|    774|    return ret;
  477|    774|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|  2.32k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  2.32k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  2.32k|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|  2.32k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|  1.54k|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_10clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     63|    +[](std::span<const char> chardata) {                                      \
  555|     63|      const auto c =                                                           \
  556|     63|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     63|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     63|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     63|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     63|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     63|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     63|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     63|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     63|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     63|  constexpr auto _size = _name.size();                                \
  |  | 1183|     63|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     63|  return _nameof; }()
  ------------------
  561|     63|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     63|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     63|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     63|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     63|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     63|  constexpr auto _size = _name.size();                                \
  |  | 1183|     63|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     63|  return _nameof; }()
  ------------------
  562|     63|      c.fuzz(chardata);                                                        \
  563|     63|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|     63|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|     63|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|     63|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|     63|    static const bool do_print_testcase =
  181|     63|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|     63|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 63]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|     63|    do {
  189|       |      // step 0 - is the input valid?
  190|     63|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|     63|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 63]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|     63|                    From == UtfEncodings::UTF8) {
  198|     63|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 63]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|     63|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|     63|      const auto [output_length, length_agree] =
  204|     63|          calculate_length(from, inputisvalid);
  205|     63|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 63]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|     63|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 12, False: 51]
  |  Branch (208:28): [True: 0, False: 12]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|     63|      const auto [written, outputs_agree] =
  215|     63|          do_conversion(from, output_length, inputisvalid);
  216|     63|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 63]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|     63|      return;
  221|     63|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|     63|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  230|     63|  validation_result verify_valid_input(FromSpan src) const {
  231|     63|    validation_result ret{};
  232|       |
  233|     63|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|     63|    const auto implementations = get_supported_implementations();
  235|     63|    std::vector<simdutf::result> results;
  236|     63|    results.reserve(implementations.size());
  237|       |
  238|    189|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 189, False: 63]
  ------------------
  239|    189|      results.push_back(
  240|    189|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    189|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    189|      const bool validation2 =
  245|    189|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    189|                      src.data(), src.size());
  247|    189|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 189]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|    189|    }
  258|       |
  259|     63|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|     63|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 63]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|     63|    } else {
  273|     63|      ret.implementations_agree = true;
  274|     63|    }
  275|     63|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|     63|      return r.error == simdutf::SUCCESS;
  277|     63|    });
  278|     63|    return ret;
  279|     63|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    126|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKNS1_6resultEE_clESI_:
  275|    165|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    165|      return r.error == simdutf::SUCCESS;
  277|    165|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE15count_the_inputENSt3__14spanIS5_Lm18446744073709551615EEE:
  289|     63|  bool count_the_input(FromSpan src) const {
  290|     63|    const auto implementations = get_supported_implementations();
  291|     63|    std::vector<std::size_t> results;
  292|     63|    results.reserve(implementations.size());
  293|       |
  294|    189|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 189, False: 63]
  ------------------
  295|    189|      std::size_t ret;
  296|    189|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|    189|        ret = impl->count_utf16be(src.data(), src.size());
  298|       |      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|       |        ret = impl->count_utf16le(src.data(), src.size());
  300|       |      } else if constexpr (From == UtfEncodings::UTF8) {
  301|       |        ret = impl->count_utf8(src.data(), src.size());
  302|       |      }
  303|    189|      results.push_back(ret);
  304|    189|    }
  305|     63|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|     63|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 63]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|     63|    return true;
  321|     63|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE15count_the_inputENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    126|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|     63|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|     63|    length_result ret{};
  344|       |
  345|     63|    const auto implementations = get_supported_implementations();
  346|     63|    std::vector<std::size_t> results;
  347|     63|    results.reserve(implementations.size());
  348|       |
  349|    189|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 189, False: 63]
  ------------------
  350|    189|      const auto len = invoke_lengthcalc(impl, src);
  351|    189|      results.push_back(len);
  352|    189|      ret.length.push_back(len);
  353|    189|    }
  354|       |
  355|     63|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|     63|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 63]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|     63|    } else {
  375|     63|      ret.implementations_agree = true;
  376|     63|    }
  377|     63|    return ret;
  378|     63|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    189|                                FromSpan src) const {
  339|    189|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    189|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    126|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|     63|                                  const bool inputisvalid) const {
  383|     63|    conversion_result ret{};
  384|       |
  385|     63|    const auto implementations = get_supported_implementations();
  386|       |
  387|     63|    std::vector<result<ConversionResult>> results;
  388|     63|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|     63|    std::vector<std::vector<ToType>> outputbuffers;
  393|     63|    outputbuffers.reserve(implementations.size());
  394|    252|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 189, False: 63]
  ------------------
  395|    189|      auto impl = implementations[i];
  396|    189|      const ToType canary1{42};
  397|    189|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    189|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    189|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    189|      const auto success = [](const ConversionResult& r) -> bool {
  402|    189|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    189|          return r != 0;
  404|    189|        } else {
  405|    189|          return r.error == simdutf::error_code::SUCCESS;
  406|    189|        }
  407|    189|      }(implret1);
  408|    189|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    189|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    189|        const ToType canary2{25};
  414|    189|        const auto outputbuffer_first_run = outputbuffer;
  415|    189|        std::ranges::fill(outputbuffer, canary2);
  416|    189|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    189|                                          src.size(), outputbuffer.data());
  418|       |
  419|    189|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 189]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    189|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 153, False: 36]
  |  Branch (423:29): [True: 75, False: 78]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|     75|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|     75|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 75]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|     75|        }
  440|    189|      }
  441|    189|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 75, False: 114]
  ------------------
  442|    189|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|     63|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 12, False: 51]
  ------------------
  447|     36|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 36, False: 12]
  ------------------
  448|     36|        e.outputhash.clear();
  449|     36|      }
  450|     12|    }
  451|       |
  452|     63|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|     63|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 63]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|     63|    } else {
  474|     63|      ret.implementations_agree = true;
  475|     63|    }
  476|     63|    return ret;
  477|     63|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    189|      const auto success = [](const ConversionResult& r) -> bool {
  402|    189|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    189|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    189|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    126|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_11clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    126|    +[](std::span<const char> chardata) {                                      \
  555|    126|      const auto c =                                                           \
  556|    126|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    126|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    126|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    126|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    126|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    126|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    126|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    126|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    126|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    126|  constexpr auto _size = _name.size();                                \
  |  | 1183|    126|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    126|  return _nameof; }()
  ------------------
  561|    126|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    126|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    126|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    126|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    126|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    126|  constexpr auto _size = _name.size();                                \
  |  | 1183|    126|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    126|  return _nameof; }()
  ------------------
  562|    126|      c.fuzz(chardata);                                                        \
  563|    126|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_12clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    155|    +[](std::span<const char> chardata) {                                      \
  555|    155|      const auto c =                                                           \
  556|    155|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    155|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    155|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    155|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    155|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    155|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    155|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    155|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    155|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    155|  constexpr auto _size = _name.size();                                \
  |  | 1183|    155|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    155|  return _nameof; }()
  ------------------
  561|    155|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    155|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    155|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    155|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    155|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    155|  constexpr auto _size = _name.size();                                \
  |  | 1183|    155|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    155|  return _nameof; }()
  ------------------
  562|    155|      c.fuzz(chardata);                                                        \
  563|    155|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_13clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     55|    +[](std::span<const char> chardata) {                                      \
  555|     55|      const auto c =                                                           \
  556|     55|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     55|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     55|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     55|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     55|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     55|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     55|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     55|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     55|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     55|  constexpr auto _size = _name.size();                                \
  |  | 1183|     55|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     55|  return _nameof; }()
  ------------------
  561|     55|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     55|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     55|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     55|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     55|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     55|  constexpr auto _size = _name.size();                                \
  |  | 1183|     55|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     55|  return _nameof; }()
  ------------------
  562|     55|      c.fuzz(chardata);                                                        \
  563|     55|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|     55|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|     55|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|     55|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|     55|    static const bool do_print_testcase =
  181|     55|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|     55|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 55]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|     55|    do {
  189|       |      // step 0 - is the input valid?
  190|     55|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|     55|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 55]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|     55|                    From == UtfEncodings::UTF8) {
  198|     55|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 55]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|     55|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|     55|      const auto [output_length, length_agree] =
  204|     55|          calculate_length(from, inputisvalid);
  205|     55|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 55]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|     55|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 15, False: 40]
  |  Branch (208:28): [True: 0, False: 15]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|     55|      const auto [written, outputs_agree] =
  215|     55|          do_conversion(from, output_length, inputisvalid);
  216|     55|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 55]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|     55|      return;
  221|     55|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|     55|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  230|     55|  validation_result verify_valid_input(FromSpan src) const {
  231|     55|    validation_result ret{};
  232|       |
  233|     55|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|     55|    const auto implementations = get_supported_implementations();
  235|     55|    std::vector<simdutf::result> results;
  236|     55|    results.reserve(implementations.size());
  237|       |
  238|    165|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 165, False: 55]
  ------------------
  239|    165|      results.push_back(
  240|    165|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    165|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    165|      const bool validation2 =
  245|    165|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    165|                      src.data(), src.size());
  247|    165|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 165]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|    165|    }
  258|       |
  259|     55|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|     55|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 55]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|     55|    } else {
  273|     55|      ret.implementations_agree = true;
  274|     55|    }
  275|     55|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|     55|      return r.error == simdutf::SUCCESS;
  277|     55|    });
  278|     55|    return ret;
  279|     55|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    110|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKNS1_6resultEE_clESI_:
  275|    135|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    135|      return r.error == simdutf::SUCCESS;
  277|    135|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE15count_the_inputENSt3__14spanIS5_Lm18446744073709551615EEE:
  289|     55|  bool count_the_input(FromSpan src) const {
  290|     55|    const auto implementations = get_supported_implementations();
  291|     55|    std::vector<std::size_t> results;
  292|     55|    results.reserve(implementations.size());
  293|       |
  294|    165|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 165, False: 55]
  ------------------
  295|    165|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|    165|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|    165|        ret = impl->count_utf16le(src.data(), src.size());
  300|       |      } else if constexpr (From == UtfEncodings::UTF8) {
  301|       |        ret = impl->count_utf8(src.data(), src.size());
  302|       |      }
  303|    165|      results.push_back(ret);
  304|    165|    }
  305|     55|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|     55|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 55]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|     55|    return true;
  321|     55|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE15count_the_inputENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    110|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|     55|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|     55|    length_result ret{};
  344|       |
  345|     55|    const auto implementations = get_supported_implementations();
  346|     55|    std::vector<std::size_t> results;
  347|     55|    results.reserve(implementations.size());
  348|       |
  349|    165|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 165, False: 55]
  ------------------
  350|    165|      const auto len = invoke_lengthcalc(impl, src);
  351|    165|      results.push_back(len);
  352|    165|      ret.length.push_back(len);
  353|    165|    }
  354|       |
  355|     55|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|     55|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 55]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|     55|    } else {
  375|     55|      ret.implementations_agree = true;
  376|     55|    }
  377|     55|    return ret;
  378|     55|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    165|                                FromSpan src) const {
  339|    165|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    165|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    110|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|     55|                                  const bool inputisvalid) const {
  383|     55|    conversion_result ret{};
  384|       |
  385|     55|    const auto implementations = get_supported_implementations();
  386|       |
  387|     55|    std::vector<result<ConversionResult>> results;
  388|     55|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|     55|    std::vector<std::vector<ToType>> outputbuffers;
  393|     55|    outputbuffers.reserve(implementations.size());
  394|    220|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 165, False: 55]
  ------------------
  395|    165|      auto impl = implementations[i];
  396|    165|      const ToType canary1{42};
  397|    165|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    165|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    165|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    165|      const auto success = [](const ConversionResult& r) -> bool {
  402|    165|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    165|          return r != 0;
  404|    165|        } else {
  405|    165|          return r.error == simdutf::error_code::SUCCESS;
  406|    165|        }
  407|    165|      }(implret1);
  408|    165|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    165|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    165|        const ToType canary2{25};
  414|    165|        const auto outputbuffer_first_run = outputbuffer;
  415|    165|        std::ranges::fill(outputbuffer, canary2);
  416|    165|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    165|                                          src.size(), outputbuffer.data());
  418|       |
  419|    165|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 165]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    165|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 120, False: 45]
  |  Branch (423:29): [True: 57, False: 63]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|     57|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|     57|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 57]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|     57|        }
  440|    165|      }
  441|    165|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 57, False: 108]
  ------------------
  442|    165|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|     55|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 15, False: 40]
  ------------------
  447|     45|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 45, False: 15]
  ------------------
  448|     45|        e.outputhash.clear();
  449|     45|      }
  450|     15|    }
  451|       |
  452|     55|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|     55|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 55]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|     55|    } else {
  474|     55|      ret.implementations_agree = true;
  475|     55|    }
  476|     55|    return ret;
  477|     55|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    165|      const auto success = [](const ConversionResult& r) -> bool {
  402|    165|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    165|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    165|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDsmPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    110|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_14clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    136|    +[](std::span<const char> chardata) {                                      \
  555|    136|      const auto c =                                                           \
  556|    136|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    136|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    136|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    136|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    136|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    136|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    136|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    136|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    136|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    136|  constexpr auto _size = _name.size();                                \
  |  | 1183|    136|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    136|  return _nameof; }()
  ------------------
  561|    136|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    136|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    136|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    136|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    136|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    136|  constexpr auto _size = _name.size();                                \
  |  | 1183|    136|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    136|  return _nameof; }()
  ------------------
  562|    136|      c.fuzz(chardata);                                                        \
  563|    136|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_15clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    196|    +[](std::span<const char> chardata) {                                      \
  555|    196|      const auto c =                                                           \
  556|    196|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    196|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    196|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    196|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    196|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    196|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    196|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    196|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    196|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    196|  constexpr auto _size = _name.size();                                \
  |  | 1183|    196|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    196|  return _nameof; }()
  ------------------
  561|    196|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    196|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    196|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    196|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    196|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    196|  constexpr auto _size = _name.size();                                \
  |  | 1183|    196|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    196|  return _nameof; }()
  ------------------
  562|    196|      c.fuzz(chardata);                                                        \
  563|    196|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_16clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     95|    +[](std::span<const char> chardata) {                                      \
  555|     95|      const auto c =                                                           \
  556|     95|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     95|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     95|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     95|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     95|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     95|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     95|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     95|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     95|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     95|  constexpr auto _size = _name.size();                                \
  |  | 1183|     95|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     95|  return _nameof; }()
  ------------------
  561|     95|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     95|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     95|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     95|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     95|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     95|  constexpr auto _size = _name.size();                                \
  |  | 1183|     95|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     95|  return _nameof; }()
  ------------------
  562|     95|      c.fuzz(chardata);                                                        \
  563|     95|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|     95|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|     95|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|     95|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|     95|    static const bool do_print_testcase =
  181|     95|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|     95|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 95]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|     95|    do {
  189|       |      // step 0 - is the input valid?
  190|     95|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|     95|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 95]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|       |                    From == UtfEncodings::UTF8) {
  198|       |        if (!count_the_input(from) && !allow_implementations_to_differ)
  199|       |          break;
  200|       |      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|     95|      const auto [output_length, length_agree] =
  204|     95|          calculate_length(from, inputisvalid);
  205|     95|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 95]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|     95|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 71, False: 24]
  |  Branch (208:28): [True: 0, False: 71]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|     95|      const auto [written, outputs_agree] =
  215|     95|          do_conversion(from, output_length, inputisvalid);
  216|     95|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 95]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|     95|      return;
  221|     95|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|     95|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  230|     95|  validation_result verify_valid_input(FromSpan src) const {
  231|     95|    validation_result ret{};
  232|       |
  233|     95|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|     95|    const auto implementations = get_supported_implementations();
  235|     95|    std::vector<simdutf::result> results;
  236|     95|    results.reserve(implementations.size());
  237|       |
  238|    285|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 285, False: 95]
  ------------------
  239|    285|      results.push_back(
  240|    285|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    285|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    285|      const bool validation2 =
  245|    285|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    285|                      src.data(), src.size());
  247|    285|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 285]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|    285|    }
  258|       |
  259|     95|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|     95|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 95]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|     95|    } else {
  273|     95|      ret.implementations_agree = true;
  274|     95|    }
  275|     95|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|     95|      return r.error == simdutf::SUCCESS;
  277|     95|    });
  278|     95|    return ret;
  279|     95|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    190|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEEENKUlRKNS1_6resultEE_clESI_:
  275|    143|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    143|      return r.error == simdutf::SUCCESS;
  277|    143|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|     95|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|     95|    length_result ret{};
  344|       |
  345|     95|    const auto implementations = get_supported_implementations();
  346|     95|    std::vector<std::size_t> results;
  347|     95|    results.reserve(implementations.size());
  348|       |
  349|    285|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 285, False: 95]
  ------------------
  350|    285|      const auto len = invoke_lengthcalc(impl, src);
  351|    285|      results.push_back(len);
  352|    285|      ret.length.push_back(len);
  353|    285|    }
  354|       |
  355|     95|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|     95|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 95]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|     95|    } else {
  375|     95|      ret.implementations_agree = true;
  376|     95|    }
  377|     95|    return ret;
  378|     95|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    285|                                FromSpan src) const {
  339|    285|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    285|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    190|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|     95|                                  const bool inputisvalid) const {
  383|     95|    conversion_result ret{};
  384|       |
  385|     95|    const auto implementations = get_supported_implementations();
  386|       |
  387|     95|    std::vector<result<ConversionResult>> results;
  388|     95|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|     95|    std::vector<std::vector<ToType>> outputbuffers;
  393|     95|    outputbuffers.reserve(implementations.size());
  394|    380|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 285, False: 95]
  ------------------
  395|    285|      auto impl = implementations[i];
  396|    285|      const ToType canary1{42};
  397|    285|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    285|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    285|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    285|      const auto success = [](const ConversionResult& r) -> bool {
  402|    285|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    285|          return r != 0;
  404|    285|        } else {
  405|    285|          return r.error == simdutf::error_code::SUCCESS;
  406|    285|        }
  407|    285|      }(implret1);
  408|    285|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    285|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    285|        const ToType canary2{25};
  414|    285|        const auto outputbuffer_first_run = outputbuffer;
  415|    285|        std::ranges::fill(outputbuffer, canary2);
  416|    285|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    285|                                          src.size(), outputbuffer.data());
  418|       |
  419|    285|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 285]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    285|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 72, False: 213]
  |  Branch (423:29): [True: 57, False: 15]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|     57|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|     57|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 57]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|     57|        }
  440|    285|      }
  441|    285|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 57, False: 228]
  ------------------
  442|    285|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|     95|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 71, False: 24]
  ------------------
  447|    213|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 213, False: 71]
  ------------------
  448|    213|        e.outputhash.clear();
  449|    213|      }
  450|     71|    }
  451|       |
  452|     95|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|     95|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 95]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|     95|    } else {
  474|     95|      ret.implementations_agree = true;
  475|     95|    }
  476|     95|    return ret;
  477|     95|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    285|      const auto success = [](const ConversionResult& r) -> bool {
  402|    285|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    285|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    285|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKDimPcEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    190|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_17clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    195|    +[](std::span<const char> chardata) {                                      \
  555|    195|      const auto c =                                                           \
  556|    195|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    195|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    195|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    195|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    195|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    195|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    195|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    195|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    195|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    195|  constexpr auto _size = _name.size();                                \
  |  | 1183|    195|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    195|  return _nameof; }()
  ------------------
  561|    195|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    195|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    195|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    195|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    195|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    195|  constexpr auto _size = _name.size();                                \
  |  | 1183|    195|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    195|  return _nameof; }()
  ------------------
  562|    195|      c.fuzz(chardata);                                                        \
  563|    195|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_18clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    211|    +[](std::span<const char> chardata) {                                      \
  555|    211|      const auto c =                                                           \
  556|    211|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    211|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    211|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    211|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    211|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    211|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    211|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    211|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    211|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    211|  constexpr auto _size = _name.size();                                \
  |  | 1183|    211|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    211|  return _nameof; }()
  ------------------
  561|    211|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    211|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    211|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    211|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    211|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    211|  constexpr auto _size = _name.size();                                \
  |  | 1183|    211|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    211|  return _nameof; }()
  ------------------
  562|    211|      c.fuzz(chardata);                                                        \
  563|    211|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_19clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    292|    +[](std::span<const char> chardata) {                                      \
  555|    292|      const auto c =                                                           \
  556|    292|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    292|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    292|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    292|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    292|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    292|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    292|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    292|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    292|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    292|  constexpr auto _size = _name.size();                                \
  |  | 1183|    292|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    292|  return _nameof; }()
  ------------------
  561|    292|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    292|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    292|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    292|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    292|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    292|  constexpr auto _size = _name.size();                                \
  |  | 1183|    292|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    292|  return _nameof; }()
  ------------------
  562|    292|      c.fuzz(chardata);                                                        \
  563|    292|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_20clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    331|    +[](std::span<const char> chardata) {                                      \
  555|    331|      const auto c =                                                           \
  556|    331|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    331|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    331|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    331|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    331|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    331|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    331|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    331|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    331|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    331|  constexpr auto _size = _name.size();                                \
  |  | 1183|    331|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    331|  return _nameof; }()
  ------------------
  561|    331|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    331|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    331|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    331|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    331|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    331|  constexpr auto _size = _name.size();                                \
  |  | 1183|    331|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    331|  return _nameof; }()
  ------------------
  562|    331|      c.fuzz(chardata);                                                        \
  563|    331|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    331|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    331|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    331|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    331|    static const bool do_print_testcase =
  181|    331|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    331|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 331]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    331|    do {
  189|       |      // step 0 - is the input valid?
  190|    331|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    331|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 331]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    331|                    From == UtfEncodings::UTF8) {
  198|    331|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 331]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    331|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    331|      const auto [output_length, length_agree] =
  204|    331|          calculate_length(from, inputisvalid);
  205|    331|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 331]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    331|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 220, False: 111]
  |  Branch (208:28): [True: 0, False: 220]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    331|      const auto [written, outputs_agree] =
  215|    331|          do_conversion(from, output_length, inputisvalid);
  216|    331|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 331]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    331|      return;
  221|    331|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    331|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    331|  validation_result verify_valid_input(FromSpan src) const {
  231|    331|    validation_result ret{};
  232|       |
  233|    331|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    331|    const auto implementations = get_supported_implementations();
  235|    331|    std::vector<simdutf::result> results;
  236|    331|    results.reserve(implementations.size());
  237|       |
  238|    993|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 993, False: 331]
  ------------------
  239|    993|      results.push_back(
  240|    993|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    993|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    993|      const bool validation2 =
  245|    993|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    993|                      src.data(), src.size());
  247|    993|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 993]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|    993|    }
  258|       |
  259|    331|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    331|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 331]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    331|    } else {
  273|    331|      ret.implementations_agree = true;
  274|    331|    }
  275|    331|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    331|      return r.error == simdutf::SUCCESS;
  277|    331|    });
  278|    331|    return ret;
  279|    331|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clINS1_6resultESO_EEDaSI_SL_:
  259|    662|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKNS1_6resultEE_clESI_:
  275|    553|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    553|      return r.error == simdutf::SUCCESS;
  277|    553|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    331|  bool count_the_input(FromSpan src) const {
  290|    331|    const auto implementations = get_supported_implementations();
  291|    331|    std::vector<std::size_t> results;
  292|    331|    results.reserve(implementations.size());
  293|       |
  294|    993|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 993, False: 331]
  ------------------
  295|    993|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|       |      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|       |        ret = impl->count_utf16le(src.data(), src.size());
  300|    993|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|    993|        ret = impl->count_utf8(src.data(), src.size());
  302|    993|      }
  303|    993|      results.push_back(ret);
  304|    993|    }
  305|    331|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    331|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 331]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|    331|    return true;
  321|    331|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  305|    662|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    331|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    331|    length_result ret{};
  344|       |
  345|    331|    const auto implementations = get_supported_implementations();
  346|    331|    std::vector<std::size_t> results;
  347|    331|    results.reserve(implementations.size());
  348|       |
  349|    993|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 993, False: 331]
  ------------------
  350|    993|      const auto len = invoke_lengthcalc(impl, src);
  351|    993|      results.push_back(len);
  352|    993|      ret.length.push_back(len);
  353|    993|    }
  354|       |
  355|    331|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    331|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 331]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    331|    } else {
  375|    331|      ret.implementations_agree = true;
  376|    331|    }
  377|    331|    return ret;
  378|    331|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    993|                                FromSpan src) const {
  331|    993|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    993|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    662|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    331|                                  const bool inputisvalid) const {
  383|    331|    conversion_result ret{};
  384|       |
  385|    331|    const auto implementations = get_supported_implementations();
  386|       |
  387|    331|    std::vector<result<ConversionResult>> results;
  388|    331|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    331|    std::vector<std::vector<ToType>> outputbuffers;
  393|    331|    outputbuffers.reserve(implementations.size());
  394|  1.32k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 993, False: 331]
  ------------------
  395|    993|      auto impl = implementations[i];
  396|    993|      const ToType canary1{42};
  397|    993|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    993|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    993|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    993|      const auto success = [](const ConversionResult& r) -> bool {
  402|    993|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    993|          return r != 0;
  404|    993|        } else {
  405|    993|          return r.error == simdutf::error_code::SUCCESS;
  406|    993|        }
  407|    993|      }(implret1);
  408|    993|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    993|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    993|        const ToType canary2{25};
  414|    993|        const auto outputbuffer_first_run = outputbuffer;
  415|    993|        std::ranges::fill(outputbuffer, canary2);
  416|    993|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    993|                                          src.size(), outputbuffer.data());
  418|       |
  419|    993|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 993]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    993|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 333, False: 660]
  |  Branch (423:29): [True: 306, False: 27]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    306|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    306|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 306]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    306|        }
  440|    993|      }
  441|    993|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 306, False: 687]
  ------------------
  442|    993|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    331|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 220, False: 111]
  ------------------
  447|    660|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 660, False: 220]
  ------------------
  448|    660|        e.outputhash.clear();
  449|    660|      }
  450|    220|    }
  451|       |
  452|    331|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    331|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 331]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    331|    } else {
  474|    331|      ret.implementations_agree = true;
  475|    331|    }
  476|    331|    return ret;
  477|    331|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    993|      const auto success = [](const ConversionResult& r) -> bool {
  402|    993|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    993|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    993|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    662|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_21clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    480|    +[](std::span<const char> chardata) {                                      \
  555|    480|      const auto c =                                                           \
  556|    480|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    480|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    480|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    480|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    480|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    480|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    480|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    480|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    480|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    480|  constexpr auto _size = _name.size();                                \
  |  | 1183|    480|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    480|  return _nameof; }()
  ------------------
  561|    480|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    480|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    480|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    480|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    480|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    480|  constexpr auto _size = _name.size();                                \
  |  | 1183|    480|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    480|  return _nameof; }()
  ------------------
  562|    480|      c.fuzz(chardata);                                                        \
  563|    480|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_22clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    492|    +[](std::span<const char> chardata) {                                      \
  555|    492|      const auto c =                                                           \
  556|    492|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    492|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    492|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    492|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    492|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    492|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    492|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    492|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    492|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    492|  constexpr auto _size = _name.size();                                \
  |  | 1183|    492|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    492|  return _nameof; }()
  ------------------
  561|    492|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    492|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    492|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    492|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    492|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    492|  constexpr auto _size = _name.size();                                \
  |  | 1183|    492|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    492|  return _nameof; }()
  ------------------
  562|    492|      c.fuzz(chardata);                                                        \
  563|    492|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_23clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    460|    +[](std::span<const char> chardata) {                                      \
  555|    460|      const auto c =                                                           \
  556|    460|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    460|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    460|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    460|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    460|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    460|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    460|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    460|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    460|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    460|  constexpr auto _size = _name.size();                                \
  |  | 1183|    460|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    460|  return _nameof; }()
  ------------------
  561|    460|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    460|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    460|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    460|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    460|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    460|  constexpr auto _size = _name.size();                                \
  |  | 1183|    460|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    460|  return _nameof; }()
  ------------------
  562|    460|      c.fuzz(chardata);                                                        \
  563|    460|    }                                                                          \
conversion.cpp:_ZZ18populate_functionsvENK4$_24clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    131|    +[](std::span<const char> chardata) {                                      \
  555|    131|      const auto c =                                                           \
  556|    131|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    131|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    131|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    131|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    131|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    131|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    131|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    131|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    131|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    131|  constexpr auto _size = _name.size();                                \
  |  | 1183|    131|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    131|  return _nameof; }()
  ------------------
  561|    131|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    131|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    131|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    131|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    131|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    131|  constexpr auto _size = _name.size();                                \
  |  | 1183|    131|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    131|  return _nameof; }()
  ------------------
  562|    131|      c.fuzz(chardata);                                                        \
  563|    131|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    131|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    131|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    131|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    131|    static const bool do_print_testcase =
  181|    131|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    131|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 131]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    131|    do {
  189|       |      // step 0 - is the input valid?
  190|    131|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    131|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 131]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    131|                    From == UtfEncodings::UTF8) {
  198|    131|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 131]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    131|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    131|      const auto [output_length, length_agree] =
  204|    131|          calculate_length(from, inputisvalid);
  205|    131|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 131]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    131|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 38, False: 93]
  |  Branch (208:28): [True: 0, False: 38]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    131|      const auto [written, outputs_agree] =
  215|    131|          do_conversion(from, output_length, inputisvalid);
  216|    131|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 131]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    131|      return;
  221|    131|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    131|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEE:
  230|    131|  validation_result verify_valid_input(FromSpan src) const {
  231|    131|    validation_result ret{};
  232|       |
  233|    131|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    131|    const auto implementations = get_supported_implementations();
  235|    131|    std::vector<simdutf::result> results;
  236|    131|    results.reserve(implementations.size());
  237|       |
  238|    393|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 393, False: 131]
  ------------------
  239|    393|      results.push_back(
  240|    393|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    393|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    393|      const bool validation2 =
  245|    393|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    393|                      src.data(), src.size());
  247|    393|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 393]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|    393|    }
  258|       |
  259|    131|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    131|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 131]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    131|    } else {
  273|    131|      ret.implementations_agree = true;
  274|    131|    }
  275|    131|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    131|      return r.error == simdutf::SUCCESS;
  277|    131|    });
  278|    131|    return ret;
  279|    131|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS5_S5_EEDaSJ_SM_:
  259|    262|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKS5_E_clESI_:
  275|    317|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    317|      return r.error == simdutf::SUCCESS;
  277|    317|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE15count_the_inputENSt3__14spanIS6_Lm18446744073709551615EEE:
  289|    131|  bool count_the_input(FromSpan src) const {
  290|    131|    const auto implementations = get_supported_implementations();
  291|    131|    std::vector<std::size_t> results;
  292|    131|    results.reserve(implementations.size());
  293|       |
  294|    393|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 393, False: 131]
  ------------------
  295|    393|      std::size_t ret;
  296|    393|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|    393|        ret = impl->count_utf16be(src.data(), src.size());
  298|       |      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|       |        ret = impl->count_utf16le(src.data(), src.size());
  300|       |      } else if constexpr (From == UtfEncodings::UTF8) {
  301|       |        ret = impl->count_utf8(src.data(), src.size());
  302|       |      }
  303|    393|      results.push_back(ret);
  304|    393|    }
  305|    131|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    131|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 131]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|    131|    return true;
  321|    131|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE15count_the_inputENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    262|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEb:
  342|    131|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    131|    length_result ret{};
  344|       |
  345|    131|    const auto implementations = get_supported_implementations();
  346|    131|    std::vector<std::size_t> results;
  347|    131|    results.reserve(implementations.size());
  348|       |
  349|    393|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 393, False: 131]
  ------------------
  350|    393|      const auto len = invoke_lengthcalc(impl, src);
  351|    393|      results.push_back(len);
  352|    393|      ret.length.push_back(len);
  353|    393|    }
  354|       |
  355|    131|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    131|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 131]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    131|    } else {
  375|    131|      ret.implementations_agree = true;
  376|    131|    }
  377|    131|    return ret;
  378|    131|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSF_NSt3__14spanIS6_Lm18446744073709551615EEE:
  338|    393|                                FromSpan src) const {
  339|    393|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    393|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    262|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    131|                                  const bool inputisvalid) const {
  383|    131|    conversion_result ret{};
  384|       |
  385|    131|    const auto implementations = get_supported_implementations();
  386|       |
  387|    131|    std::vector<result<ConversionResult>> results;
  388|    131|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    131|    std::vector<std::vector<ToType>> outputbuffers;
  393|    131|    outputbuffers.reserve(implementations.size());
  394|    524|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 393, False: 131]
  ------------------
  395|    393|      auto impl = implementations[i];
  396|    393|      const ToType canary1{42};
  397|    393|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    393|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    393|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    393|      const auto success = [](const ConversionResult& r) -> bool {
  402|    393|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    393|          return r != 0;
  404|    393|        } else {
  405|    393|          return r.error == simdutf::error_code::SUCCESS;
  406|    393|        }
  407|    393|      }(implret1);
  408|    393|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    393|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    393|        const ToType canary2{25};
  414|    393|        const auto outputbuffer_first_run = outputbuffer;
  415|    393|        std::ranges::fill(outputbuffer, canary2);
  416|    393|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    393|                                          src.size(), outputbuffer.data());
  418|       |
  419|    393|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 393]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    393|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 279, False: 114]
  |  Branch (423:29): [True: 117, False: 162]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    117|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    117|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 117]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    117|        }
  440|    393|      }
  441|    393|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 117, False: 276]
  ------------------
  442|    393|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    131|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 38, False: 93]
  ------------------
  447|    114|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 114, False: 38]
  ------------------
  448|    114|        e.outputhash.clear();
  449|    114|      }
  450|     38|    }
  451|       |
  452|    131|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    131|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 131]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    131|    } else {
  474|    131|      ret.implementations_agree = true;
  475|    131|    }
  476|    131|    return ret;
  477|    131|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS5_E_clESM_:
  401|    393|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    393|        } else {
  405|    393|          return r.error == simdutf::error_code::SUCCESS;
  406|    393|        }
  407|    393|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS5_ESU_EEDaSN_SQ_:
  452|    262|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_25clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    190|    +[](std::span<const char> chardata) {                                      \
  555|    190|      const auto c =                                                           \
  556|    190|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    190|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    190|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    190|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    190|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    190|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    190|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    190|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    190|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    190|  constexpr auto _size = _name.size();                                \
  |  | 1183|    190|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    190|  return _nameof; }()
  ------------------
  561|    190|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    190|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    190|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    190|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    190|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    190|  constexpr auto _size = _name.size();                                \
  |  | 1183|    190|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    190|  return _nameof; }()
  ------------------
  562|    190|      c.fuzz(chardata);                                                        \
  563|    190|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    190|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    190|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    190|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    190|    static const bool do_print_testcase =
  181|    190|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    190|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 190]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    190|    do {
  189|       |      // step 0 - is the input valid?
  190|    190|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    190|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 190]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    190|                    From == UtfEncodings::UTF8) {
  198|    190|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 190]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    190|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    190|      const auto [output_length, length_agree] =
  204|    190|          calculate_length(from, inputisvalid);
  205|    190|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 190]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    190|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 115, False: 75]
  |  Branch (208:28): [True: 0, False: 115]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    190|      const auto [written, outputs_agree] =
  215|    190|          do_conversion(from, output_length, inputisvalid);
  216|    190|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 190]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    190|      return;
  221|    190|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    190|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    190|  validation_result verify_valid_input(FromSpan src) const {
  231|    190|    validation_result ret{};
  232|       |
  233|    190|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    190|    const auto implementations = get_supported_implementations();
  235|    190|    std::vector<simdutf::result> results;
  236|    190|    results.reserve(implementations.size());
  237|       |
  238|    570|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 570, False: 190]
  ------------------
  239|    570|      results.push_back(
  240|    570|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    570|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    570|      const bool validation2 =
  245|    570|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    570|                      src.data(), src.size());
  247|    570|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 570]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|    570|    }
  258|       |
  259|    190|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    190|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 190]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    190|    } else {
  273|    190|      ret.implementations_agree = true;
  274|    190|    }
  275|    190|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    190|      return r.error == simdutf::SUCCESS;
  277|    190|    });
  278|    190|    return ret;
  279|    190|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    380|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKS7_E_clESI_:
  275|    340|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    340|      return r.error == simdutf::SUCCESS;
  277|    340|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    190|  bool count_the_input(FromSpan src) const {
  290|    190|    const auto implementations = get_supported_implementations();
  291|    190|    std::vector<std::size_t> results;
  292|    190|    results.reserve(implementations.size());
  293|       |
  294|    570|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 570, False: 190]
  ------------------
  295|    570|      std::size_t ret;
  296|    570|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|    570|        ret = impl->count_utf16be(src.data(), src.size());
  298|       |      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|       |        ret = impl->count_utf16le(src.data(), src.size());
  300|       |      } else if constexpr (From == UtfEncodings::UTF8) {
  301|       |        ret = impl->count_utf8(src.data(), src.size());
  302|       |      }
  303|    570|      results.push_back(ret);
  304|    570|    }
  305|    190|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    190|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 190]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|    190|    return true;
  321|    190|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    380|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    190|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    190|    length_result ret{};
  344|       |
  345|    190|    const auto implementations = get_supported_implementations();
  346|    190|    std::vector<std::size_t> results;
  347|    190|    results.reserve(implementations.size());
  348|       |
  349|    570|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 570, False: 190]
  ------------------
  350|    570|      const auto len = invoke_lengthcalc(impl, src);
  351|    570|      results.push_back(len);
  352|    570|      ret.length.push_back(len);
  353|    570|    }
  354|       |
  355|    190|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    190|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 190]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    190|    } else {
  375|    190|      ret.implementations_agree = true;
  376|    190|    }
  377|    190|    return ret;
  378|    190|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    570|                                FromSpan src) const {
  331|    570|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    570|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    380|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    190|                                  const bool inputisvalid) const {
  383|    190|    conversion_result ret{};
  384|       |
  385|    190|    const auto implementations = get_supported_implementations();
  386|       |
  387|    190|    std::vector<result<ConversionResult>> results;
  388|    190|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    190|    std::vector<std::vector<ToType>> outputbuffers;
  393|    190|    outputbuffers.reserve(implementations.size());
  394|    760|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 570, False: 190]
  ------------------
  395|    570|      auto impl = implementations[i];
  396|    570|      const ToType canary1{42};
  397|    570|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    570|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    570|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    570|      const auto success = [](const ConversionResult& r) -> bool {
  402|    570|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    570|          return r != 0;
  404|    570|        } else {
  405|    570|          return r.error == simdutf::error_code::SUCCESS;
  406|    570|        }
  407|    570|      }(implret1);
  408|    570|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    570|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    570|        const ToType canary2{25};
  414|    570|        const auto outputbuffer_first_run = outputbuffer;
  415|    570|        std::ranges::fill(outputbuffer, canary2);
  416|    570|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    570|                                          src.size(), outputbuffer.data());
  418|       |
  419|    570|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 570]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    570|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 225, False: 345]
  |  Branch (423:29): [True: 225, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    225|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    225|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 225]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    225|        }
  440|    570|      }
  441|    570|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 225, False: 345]
  ------------------
  442|    570|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    190|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 115, False: 75]
  ------------------
  447|    345|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 345, False: 115]
  ------------------
  448|    345|        e.outputhash.clear();
  449|    345|      }
  450|    115|    }
  451|       |
  452|    190|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    190|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 190]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    190|    } else {
  474|    190|      ret.implementations_agree = true;
  475|    190|    }
  476|    190|    return ret;
  477|    190|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    570|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    570|        } else {
  405|    570|          return r.error == simdutf::error_code::SUCCESS;
  406|    570|        }
  407|    570|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    380|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_26clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    270|    +[](std::span<const char> chardata) {                                      \
  555|    270|      const auto c =                                                           \
  556|    270|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    270|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    270|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    270|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    270|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    270|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    270|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    270|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    270|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    270|  constexpr auto _size = _name.size();                                \
  |  | 1183|    270|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    270|  return _nameof; }()
  ------------------
  561|    270|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    270|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    270|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    270|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    270|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    270|  constexpr auto _size = _name.size();                                \
  |  | 1183|    270|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    270|  return _nameof; }()
  ------------------
  562|    270|      c.fuzz(chardata);                                                        \
  563|    270|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    270|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    270|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    270|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    270|    static const bool do_print_testcase =
  181|    270|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    270|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 270]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    270|    do {
  189|       |      // step 0 - is the input valid?
  190|    270|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    270|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 270]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    270|                    From == UtfEncodings::UTF8) {
  198|    270|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 270]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    270|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    270|      const auto [output_length, length_agree] =
  204|    270|          calculate_length(from, inputisvalid);
  205|    270|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 270]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    270|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 109, False: 161]
  |  Branch (208:28): [True: 0, False: 109]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    270|      const auto [written, outputs_agree] =
  215|    270|          do_conversion(from, output_length, inputisvalid);
  216|    270|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 270]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    270|      return;
  221|    270|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    270|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    270|  validation_result verify_valid_input(FromSpan src) const {
  231|    270|    validation_result ret{};
  232|       |
  233|    270|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    270|    const auto implementations = get_supported_implementations();
  235|    270|    std::vector<simdutf::result> results;
  236|    270|    results.reserve(implementations.size());
  237|       |
  238|    810|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 810, False: 270]
  ------------------
  239|    810|      results.push_back(
  240|    810|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    810|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    810|      const bool validation2 =
  245|    810|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    810|                      src.data(), src.size());
  247|    810|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 810]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|    810|    }
  258|       |
  259|    270|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    270|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 270]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    270|    } else {
  273|    270|      ret.implementations_agree = true;
  274|    270|    }
  275|    270|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    270|      return r.error == simdutf::SUCCESS;
  277|    270|    });
  278|    270|    return ret;
  279|    270|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    540|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKS7_E_clESI_:
  275|    592|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    592|      return r.error == simdutf::SUCCESS;
  277|    592|    });
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    270|  bool count_the_input(FromSpan src) const {
  290|    270|    const auto implementations = get_supported_implementations();
  291|    270|    std::vector<std::size_t> results;
  292|    270|    results.reserve(implementations.size());
  293|       |
  294|    810|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 810, False: 270]
  ------------------
  295|    810|      std::size_t ret;
  296|    810|      if constexpr (From == UtfEncodings::UTF16BE) {
  297|    810|        ret = impl->count_utf16be(src.data(), src.size());
  298|       |      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|       |        ret = impl->count_utf16le(src.data(), src.size());
  300|       |      } else if constexpr (From == UtfEncodings::UTF8) {
  301|       |        ret = impl->count_utf8(src.data(), src.size());
  302|       |      }
  303|    810|      results.push_back(ret);
  304|    810|    }
  305|    270|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    270|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 270]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|    270|    return true;
  321|    270|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    540|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    270|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    270|    length_result ret{};
  344|       |
  345|    270|    const auto implementations = get_supported_implementations();
  346|    270|    std::vector<std::size_t> results;
  347|    270|    results.reserve(implementations.size());
  348|       |
  349|    810|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 810, False: 270]
  ------------------
  350|    810|      const auto len = invoke_lengthcalc(impl, src);
  351|    810|      results.push_back(len);
  352|    810|      ret.length.push_back(len);
  353|    810|    }
  354|       |
  355|    270|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    270|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 270]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    270|    } else {
  375|    270|      ret.implementations_agree = true;
  376|    270|    }
  377|    270|    return ret;
  378|    270|  }
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    810|                                FromSpan src) const {
  331|    810|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    810|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    540|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    270|                                  const bool inputisvalid) const {
  383|    270|    conversion_result ret{};
  384|       |
  385|    270|    const auto implementations = get_supported_implementations();
  386|       |
  387|    270|    std::vector<result<ConversionResult>> results;
  388|    270|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    270|    std::vector<std::vector<ToType>> outputbuffers;
  393|    270|    outputbuffers.reserve(implementations.size());
  394|  1.08k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 810, False: 270]
  ------------------
  395|    810|      auto impl = implementations[i];
  396|    810|      const ToType canary1{42};
  397|    810|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    810|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    810|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    810|      const auto success = [](const ConversionResult& r) -> bool {
  402|    810|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    810|          return r != 0;
  404|    810|        } else {
  405|    810|          return r.error == simdutf::error_code::SUCCESS;
  406|    810|        }
  407|    810|      }(implret1);
  408|    810|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    810|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    810|        const ToType canary2{25};
  414|    810|        const auto outputbuffer_first_run = outputbuffer;
  415|    810|        std::ranges::fill(outputbuffer, canary2);
  416|    810|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    810|                                          src.size(), outputbuffer.data());
  418|       |
  419|    810|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 810]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    810|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 483, False: 327]
  |  Branch (423:29): [True: 483, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    483|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    483|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 483]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    483|        }
  440|    810|      }
  441|    810|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 483, False: 327]
  ------------------
  442|    810|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    270|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 109, False: 161]
  ------------------
  447|    327|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 327, False: 109]
  ------------------
  448|    327|        e.outputhash.clear();
  449|    327|      }
  450|    109|    }
  451|       |
  452|    270|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    270|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 270]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    270|    } else {
  474|    270|      ret.implementations_agree = true;
  475|    270|    }
  476|    270|    return ret;
  477|    270|  }
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    810|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    810|        } else {
  405|    810|          return r.error == simdutf::error_code::SUCCESS;
  406|    810|        }
  407|    810|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings0ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    540|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_27clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    105|    +[](std::span<const char> chardata) {                                      \
  555|    105|      const auto c =                                                           \
  556|    105|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    105|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    105|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    105|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    105|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    105|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    105|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    105|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    105|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    105|  constexpr auto _size = _name.size();                                \
  |  | 1183|    105|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    105|  return _nameof; }()
  ------------------
  561|    105|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    105|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    105|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    105|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    105|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    105|  constexpr auto _size = _name.size();                                \
  |  | 1183|    105|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    105|  return _nameof; }()
  ------------------
  562|    105|      c.fuzz(chardata);                                                        \
  563|    105|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    105|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    105|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    105|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    105|    static const bool do_print_testcase =
  181|    105|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    105|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 105]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    105|    do {
  189|       |      // step 0 - is the input valid?
  190|    105|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    105|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 105]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    105|                    From == UtfEncodings::UTF8) {
  198|    105|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 105]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    105|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    105|      const auto [output_length, length_agree] =
  204|    105|          calculate_length(from, inputisvalid);
  205|    105|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 105]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    105|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 24, False: 81]
  |  Branch (208:28): [True: 0, False: 24]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    105|      const auto [written, outputs_agree] =
  215|    105|          do_conversion(from, output_length, inputisvalid);
  216|    105|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 105]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    105|      return;
  221|    105|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    105|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEE:
  230|    105|  validation_result verify_valid_input(FromSpan src) const {
  231|    105|    validation_result ret{};
  232|       |
  233|    105|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    105|    const auto implementations = get_supported_implementations();
  235|    105|    std::vector<simdutf::result> results;
  236|    105|    results.reserve(implementations.size());
  237|       |
  238|    315|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 315, False: 105]
  ------------------
  239|    315|      results.push_back(
  240|    315|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    315|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    315|      const bool validation2 =
  245|    315|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    315|                      src.data(), src.size());
  247|    315|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 315]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|    315|    }
  258|       |
  259|    105|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    105|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 105]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    105|    } else {
  273|    105|      ret.implementations_agree = true;
  274|    105|    }
  275|    105|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    105|      return r.error == simdutf::SUCCESS;
  277|    105|    });
  278|    105|    return ret;
  279|    105|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS5_S5_EEDaSJ_SM_:
  259|    210|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKS5_E_clESI_:
  275|    267|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    267|      return r.error == simdutf::SUCCESS;
  277|    267|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE15count_the_inputENSt3__14spanIS6_Lm18446744073709551615EEE:
  289|    105|  bool count_the_input(FromSpan src) const {
  290|    105|    const auto implementations = get_supported_implementations();
  291|    105|    std::vector<std::size_t> results;
  292|    105|    results.reserve(implementations.size());
  293|       |
  294|    315|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 315, False: 105]
  ------------------
  295|    315|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|    315|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|    315|        ret = impl->count_utf16le(src.data(), src.size());
  300|       |      } else if constexpr (From == UtfEncodings::UTF8) {
  301|       |        ret = impl->count_utf8(src.data(), src.size());
  302|       |      }
  303|    315|      results.push_back(ret);
  304|    315|    }
  305|    105|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    105|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 105]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|    105|    return true;
  321|    105|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE15count_the_inputENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    210|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEb:
  342|    105|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    105|    length_result ret{};
  344|       |
  345|    105|    const auto implementations = get_supported_implementations();
  346|    105|    std::vector<std::size_t> results;
  347|    105|    results.reserve(implementations.size());
  348|       |
  349|    315|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 315, False: 105]
  ------------------
  350|    315|      const auto len = invoke_lengthcalc(impl, src);
  351|    315|      results.push_back(len);
  352|    315|      ret.length.push_back(len);
  353|    315|    }
  354|       |
  355|    105|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    105|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 105]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    105|    } else {
  375|    105|      ret.implementations_agree = true;
  376|    105|    }
  377|    105|    return ret;
  378|    105|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSF_NSt3__14spanIS6_Lm18446744073709551615EEE:
  338|    315|                                FromSpan src) const {
  339|    315|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    315|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    210|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    105|                                  const bool inputisvalid) const {
  383|    105|    conversion_result ret{};
  384|       |
  385|    105|    const auto implementations = get_supported_implementations();
  386|       |
  387|    105|    std::vector<result<ConversionResult>> results;
  388|    105|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    105|    std::vector<std::vector<ToType>> outputbuffers;
  393|    105|    outputbuffers.reserve(implementations.size());
  394|    420|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 315, False: 105]
  ------------------
  395|    315|      auto impl = implementations[i];
  396|    315|      const ToType canary1{42};
  397|    315|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    315|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    315|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    315|      const auto success = [](const ConversionResult& r) -> bool {
  402|    315|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    315|          return r != 0;
  404|    315|        } else {
  405|    315|          return r.error == simdutf::error_code::SUCCESS;
  406|    315|        }
  407|    315|      }(implret1);
  408|    315|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    315|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    315|        const ToType canary2{25};
  414|    315|        const auto outputbuffer_first_run = outputbuffer;
  415|    315|        std::ranges::fill(outputbuffer, canary2);
  416|    315|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    315|                                          src.size(), outputbuffer.data());
  418|       |
  419|    315|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 315]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    315|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 243, False: 72]
  |  Branch (423:29): [True: 129, False: 114]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    129|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    129|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 129]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    129|        }
  440|    315|      }
  441|    315|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 129, False: 186]
  ------------------
  442|    315|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    105|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 24, False: 81]
  ------------------
  447|     72|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 72, False: 24]
  ------------------
  448|     72|        e.outputhash.clear();
  449|     72|      }
  450|     24|    }
  451|       |
  452|    105|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    105|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 105]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    105|    } else {
  474|    105|      ret.implementations_agree = true;
  475|    105|    }
  476|    105|    return ret;
  477|    105|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS5_E_clESM_:
  401|    315|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    315|        } else {
  405|    315|          return r.error == simdutf::error_code::SUCCESS;
  406|    315|        }
  407|    315|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDsmPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS5_ESU_EEDaSN_SQ_:
  452|    210|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_28clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    198|    +[](std::span<const char> chardata) {                                      \
  555|    198|      const auto c =                                                           \
  556|    198|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    198|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    198|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    198|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    198|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    198|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    198|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    198|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    198|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    198|  constexpr auto _size = _name.size();                                \
  |  | 1183|    198|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    198|  return _nameof; }()
  ------------------
  561|    198|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    198|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    198|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    198|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    198|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    198|  constexpr auto _size = _name.size();                                \
  |  | 1183|    198|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    198|  return _nameof; }()
  ------------------
  562|    198|      c.fuzz(chardata);                                                        \
  563|    198|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    198|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    198|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    198|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    198|    static const bool do_print_testcase =
  181|    198|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    198|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 198]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    198|    do {
  189|       |      // step 0 - is the input valid?
  190|    198|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    198|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 198]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    198|                    From == UtfEncodings::UTF8) {
  198|    198|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 198]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    198|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    198|      const auto [output_length, length_agree] =
  204|    198|          calculate_length(from, inputisvalid);
  205|    198|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 198]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    198|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 117, False: 81]
  |  Branch (208:28): [True: 0, False: 117]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    198|      const auto [written, outputs_agree] =
  215|    198|          do_conversion(from, output_length, inputisvalid);
  216|    198|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 198]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    198|      return;
  221|    198|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    198|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    198|  validation_result verify_valid_input(FromSpan src) const {
  231|    198|    validation_result ret{};
  232|       |
  233|    198|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    198|    const auto implementations = get_supported_implementations();
  235|    198|    std::vector<simdutf::result> results;
  236|    198|    results.reserve(implementations.size());
  237|       |
  238|    594|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 594, False: 198]
  ------------------
  239|    594|      results.push_back(
  240|    594|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    594|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    594|      const bool validation2 =
  245|    594|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    594|                      src.data(), src.size());
  247|    594|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 594]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|    594|    }
  258|       |
  259|    198|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    198|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 198]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    198|    } else {
  273|    198|      ret.implementations_agree = true;
  274|    198|    }
  275|    198|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    198|      return r.error == simdutf::SUCCESS;
  277|    198|    });
  278|    198|    return ret;
  279|    198|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    396|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKS7_E_clESI_:
  275|    360|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    360|      return r.error == simdutf::SUCCESS;
  277|    360|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    198|  bool count_the_input(FromSpan src) const {
  290|    198|    const auto implementations = get_supported_implementations();
  291|    198|    std::vector<std::size_t> results;
  292|    198|    results.reserve(implementations.size());
  293|       |
  294|    594|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 594, False: 198]
  ------------------
  295|    594|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|    594|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|    594|        ret = impl->count_utf16le(src.data(), src.size());
  300|       |      } else if constexpr (From == UtfEncodings::UTF8) {
  301|       |        ret = impl->count_utf8(src.data(), src.size());
  302|       |      }
  303|    594|      results.push_back(ret);
  304|    594|    }
  305|    198|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    198|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 198]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|    198|    return true;
  321|    198|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    396|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    198|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    198|    length_result ret{};
  344|       |
  345|    198|    const auto implementations = get_supported_implementations();
  346|    198|    std::vector<std::size_t> results;
  347|    198|    results.reserve(implementations.size());
  348|       |
  349|    594|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 594, False: 198]
  ------------------
  350|    594|      const auto len = invoke_lengthcalc(impl, src);
  351|    594|      results.push_back(len);
  352|    594|      ret.length.push_back(len);
  353|    594|    }
  354|       |
  355|    198|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    198|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 198]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    198|    } else {
  375|    198|      ret.implementations_agree = true;
  376|    198|    }
  377|    198|    return ret;
  378|    198|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    594|                                FromSpan src) const {
  331|    594|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    594|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    396|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    198|                                  const bool inputisvalid) const {
  383|    198|    conversion_result ret{};
  384|       |
  385|    198|    const auto implementations = get_supported_implementations();
  386|       |
  387|    198|    std::vector<result<ConversionResult>> results;
  388|    198|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    198|    std::vector<std::vector<ToType>> outputbuffers;
  393|    198|    outputbuffers.reserve(implementations.size());
  394|    792|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 594, False: 198]
  ------------------
  395|    594|      auto impl = implementations[i];
  396|    594|      const ToType canary1{42};
  397|    594|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    594|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    594|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    594|      const auto success = [](const ConversionResult& r) -> bool {
  402|    594|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    594|          return r != 0;
  404|    594|        } else {
  405|    594|          return r.error == simdutf::error_code::SUCCESS;
  406|    594|        }
  407|    594|      }(implret1);
  408|    594|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    594|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    594|        const ToType canary2{25};
  414|    594|        const auto outputbuffer_first_run = outputbuffer;
  415|    594|        std::ranges::fill(outputbuffer, canary2);
  416|    594|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    594|                                          src.size(), outputbuffer.data());
  418|       |
  419|    594|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 594]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    594|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 243, False: 351]
  |  Branch (423:29): [True: 243, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    243|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    243|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 243]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    243|        }
  440|    594|      }
  441|    594|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 243, False: 351]
  ------------------
  442|    594|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    198|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 117, False: 81]
  ------------------
  447|    351|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 351, False: 117]
  ------------------
  448|    351|        e.outputhash.clear();
  449|    351|      }
  450|    117|    }
  451|       |
  452|    198|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    198|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 198]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    198|    } else {
  474|    198|      ret.implementations_agree = true;
  475|    198|    }
  476|    198|    return ret;
  477|    198|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    594|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    594|        } else {
  405|    594|          return r.error == simdutf::error_code::SUCCESS;
  406|    594|        }
  407|    594|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_3EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    396|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_29clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    314|    +[](std::span<const char> chardata) {                                      \
  555|    314|      const auto c =                                                           \
  556|    314|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    314|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    314|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    314|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    314|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    314|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    314|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    314|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    314|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    314|  constexpr auto _size = _name.size();                                \
  |  | 1183|    314|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    314|  return _nameof; }()
  ------------------
  561|    314|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    314|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    314|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    314|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    314|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    314|  constexpr auto _size = _name.size();                                \
  |  | 1183|    314|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    314|  return _nameof; }()
  ------------------
  562|    314|      c.fuzz(chardata);                                                        \
  563|    314|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    314|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    314|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    314|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    314|    static const bool do_print_testcase =
  181|    314|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    314|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 314]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    314|    do {
  189|       |      // step 0 - is the input valid?
  190|    314|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    314|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 314]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    314|                    From == UtfEncodings::UTF8) {
  198|    314|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 314]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    314|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    314|      const auto [output_length, length_agree] =
  204|    314|          calculate_length(from, inputisvalid);
  205|    314|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 314]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    314|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 120, False: 194]
  |  Branch (208:28): [True: 0, False: 120]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    314|      const auto [written, outputs_agree] =
  215|    314|          do_conversion(from, output_length, inputisvalid);
  216|    314|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 314]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    314|      return;
  221|    314|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    314|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    314|  validation_result verify_valid_input(FromSpan src) const {
  231|    314|    validation_result ret{};
  232|       |
  233|    314|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    314|    const auto implementations = get_supported_implementations();
  235|    314|    std::vector<simdutf::result> results;
  236|    314|    results.reserve(implementations.size());
  237|       |
  238|    942|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 942, False: 314]
  ------------------
  239|    942|      results.push_back(
  240|    942|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    942|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    942|      const bool validation2 =
  245|    942|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    942|                      src.data(), src.size());
  247|    942|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 942]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|    942|    }
  258|       |
  259|    314|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    314|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 314]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    314|    } else {
  273|    314|      ret.implementations_agree = true;
  274|    314|    }
  275|    314|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    314|      return r.error == simdutf::SUCCESS;
  277|    314|    });
  278|    314|    return ret;
  279|    314|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    628|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKS7_E_clESI_:
  275|    702|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    702|      return r.error == simdutf::SUCCESS;
  277|    702|    });
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    314|  bool count_the_input(FromSpan src) const {
  290|    314|    const auto implementations = get_supported_implementations();
  291|    314|    std::vector<std::size_t> results;
  292|    314|    results.reserve(implementations.size());
  293|       |
  294|    942|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 942, False: 314]
  ------------------
  295|    942|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|    942|      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|    942|        ret = impl->count_utf16le(src.data(), src.size());
  300|       |      } else if constexpr (From == UtfEncodings::UTF8) {
  301|       |        ret = impl->count_utf8(src.data(), src.size());
  302|       |      }
  303|    942|      results.push_back(ret);
  304|    942|    }
  305|    314|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    314|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 314]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|    314|    return true;
  321|    314|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    628|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    314|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    314|    length_result ret{};
  344|       |
  345|    314|    const auto implementations = get_supported_implementations();
  346|    314|    std::vector<std::size_t> results;
  347|    314|    results.reserve(implementations.size());
  348|       |
  349|    942|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 942, False: 314]
  ------------------
  350|    942|      const auto len = invoke_lengthcalc(impl, src);
  351|    942|      results.push_back(len);
  352|    942|      ret.length.push_back(len);
  353|    942|    }
  354|       |
  355|    314|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    314|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 314]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    314|    } else {
  375|    314|      ret.implementations_agree = true;
  376|    314|    }
  377|    314|    return ret;
  378|    314|  }
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    942|                                FromSpan src) const {
  331|    942|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    942|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    628|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    314|                                  const bool inputisvalid) const {
  383|    314|    conversion_result ret{};
  384|       |
  385|    314|    const auto implementations = get_supported_implementations();
  386|       |
  387|    314|    std::vector<result<ConversionResult>> results;
  388|    314|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    314|    std::vector<std::vector<ToType>> outputbuffers;
  393|    314|    outputbuffers.reserve(implementations.size());
  394|  1.25k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 942, False: 314]
  ------------------
  395|    942|      auto impl = implementations[i];
  396|    942|      const ToType canary1{42};
  397|    942|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    942|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    942|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    942|      const auto success = [](const ConversionResult& r) -> bool {
  402|    942|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    942|          return r != 0;
  404|    942|        } else {
  405|    942|          return r.error == simdutf::error_code::SUCCESS;
  406|    942|        }
  407|    942|      }(implret1);
  408|    942|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    942|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    942|        const ToType canary2{25};
  414|    942|        const auto outputbuffer_first_run = outputbuffer;
  415|    942|        std::ranges::fill(outputbuffer, canary2);
  416|    942|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    942|                                          src.size(), outputbuffer.data());
  418|       |
  419|    942|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 942]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    942|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 582, False: 360]
  |  Branch (423:29): [True: 582, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    582|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    582|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 582]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    582|        }
  440|    942|      }
  441|    942|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 582, False: 360]
  ------------------
  442|    942|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    314|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 120, False: 194]
  ------------------
  447|    360|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 360, False: 120]
  ------------------
  448|    360|        e.outputhash.clear();
  449|    360|      }
  450|    120|    }
  451|       |
  452|    314|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    314|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 314]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    314|    } else {
  474|    314|      ret.implementations_agree = true;
  475|    314|    }
  476|    314|    return ret;
  477|    314|  }
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    942|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    942|        } else {
  405|    942|          return r.error == simdutf::error_code::SUCCESS;
  406|    942|        }
  407|    942|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings1ELS0_2EMN7simdutf14implementationEKDoFmPKDsmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    628|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_30clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    172|    +[](std::span<const char> chardata) {                                      \
  555|    172|      const auto c =                                                           \
  556|    172|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    172|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    172|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    172|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    172|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    172|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    172|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    172|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    172|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    172|  constexpr auto _size = _name.size();                                \
  |  | 1183|    172|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    172|  return _nameof; }()
  ------------------
  561|    172|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    172|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    172|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    172|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    172|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    172|  constexpr auto _size = _name.size();                                \
  |  | 1183|    172|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    172|  return _nameof; }()
  ------------------
  562|    172|      c.fuzz(chardata);                                                        \
  563|    172|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    172|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    172|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    172|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    172|    static const bool do_print_testcase =
  181|    172|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    172|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 172]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    172|    do {
  189|       |      // step 0 - is the input valid?
  190|    172|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    172|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 172]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|       |                    From == UtfEncodings::UTF8) {
  198|       |        if (!count_the_input(from) && !allow_implementations_to_differ)
  199|       |          break;
  200|       |      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    172|      const auto [output_length, length_agree] =
  204|    172|          calculate_length(from, inputisvalid);
  205|    172|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 172]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    172|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 140, False: 32]
  |  Branch (208:28): [True: 0, False: 140]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    172|      const auto [written, outputs_agree] =
  215|    172|          do_conversion(from, output_length, inputisvalid);
  216|    172|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 172]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    172|      return;
  221|    172|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    172|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEE:
  230|    172|  validation_result verify_valid_input(FromSpan src) const {
  231|    172|    validation_result ret{};
  232|       |
  233|    172|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    172|    const auto implementations = get_supported_implementations();
  235|    172|    std::vector<simdutf::result> results;
  236|    172|    results.reserve(implementations.size());
  237|       |
  238|    516|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 516, False: 172]
  ------------------
  239|    516|      results.push_back(
  240|    516|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    516|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    516|      const bool validation2 =
  245|    516|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    516|                      src.data(), src.size());
  247|    516|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 516]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|    516|    }
  258|       |
  259|    172|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    172|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 172]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    172|    } else {
  273|    172|      ret.implementations_agree = true;
  274|    172|    }
  275|    172|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    172|      return r.error == simdutf::SUCCESS;
  277|    172|    });
  278|    172|    return ret;
  279|    172|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS5_S5_EEDaSJ_SM_:
  259|    344|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS6_Lm18446744073709551615EEEENKUlRKS5_E_clESI_:
  275|    236|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    236|      return r.error == simdutf::SUCCESS;
  277|    236|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEb:
  342|    172|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    172|    length_result ret{};
  344|       |
  345|    172|    const auto implementations = get_supported_implementations();
  346|    172|    std::vector<std::size_t> results;
  347|    172|    results.reserve(implementations.size());
  348|       |
  349|    516|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 516, False: 172]
  ------------------
  350|    516|      const auto len = invoke_lengthcalc(impl, src);
  351|    516|      results.push_back(len);
  352|    516|      ret.length.push_back(len);
  353|    516|    }
  354|       |
  355|    172|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    172|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 172]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    172|    } else {
  375|    172|      ret.implementations_agree = true;
  376|    172|    }
  377|    172|    return ret;
  378|    172|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSF_NSt3__14spanIS6_Lm18446744073709551615EEE:
  338|    516|                                FromSpan src) const {
  339|    516|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    516|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE16calculate_lengthENSt3__14spanIS6_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    344|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    172|                                  const bool inputisvalid) const {
  383|    172|    conversion_result ret{};
  384|       |
  385|    172|    const auto implementations = get_supported_implementations();
  386|       |
  387|    172|    std::vector<result<ConversionResult>> results;
  388|    172|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    172|    std::vector<std::vector<ToType>> outputbuffers;
  393|    172|    outputbuffers.reserve(implementations.size());
  394|    688|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 516, False: 172]
  ------------------
  395|    516|      auto impl = implementations[i];
  396|    516|      const ToType canary1{42};
  397|    516|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    516|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    516|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    516|      const auto success = [](const ConversionResult& r) -> bool {
  402|    516|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    516|          return r != 0;
  404|    516|        } else {
  405|    516|          return r.error == simdutf::error_code::SUCCESS;
  406|    516|        }
  407|    516|      }(implret1);
  408|    516|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    516|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    516|        const ToType canary2{25};
  414|    516|        const auto outputbuffer_first_run = outputbuffer;
  415|    516|        std::ranges::fill(outputbuffer, canary2);
  416|    516|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    516|                                          src.size(), outputbuffer.data());
  418|       |
  419|    516|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 516]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    516|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 96, False: 420]
  |  Branch (423:29): [True: 75, False: 21]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|     75|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|     75|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 75]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|     75|        }
  440|    516|      }
  441|    516|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 75, False: 441]
  ------------------
  442|    516|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    172|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 140, False: 32]
  ------------------
  447|    420|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 420, False: 140]
  ------------------
  448|    420|        e.outputhash.clear();
  449|    420|      }
  450|    140|    }
  451|       |
  452|    172|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    172|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 172]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    172|    } else {
  474|    172|      ret.implementations_agree = true;
  475|    172|    }
  476|    172|    return ret;
  477|    172|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS5_E_clESM_:
  401|    516|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    516|        } else {
  405|    516|          return r.error == simdutf::error_code::SUCCESS;
  406|    516|        }
  407|    516|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_4EMN7simdutf14implementationEKDoFmmEMS2_KDoFNS1_6resultEPKDimPcEE13do_conversionENSt3__14spanIS6_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS5_ESU_EEDaSN_SQ_:
  452|    344|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_31clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    285|    +[](std::span<const char> chardata) {                                      \
  555|    285|      const auto c =                                                           \
  556|    285|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    285|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    285|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    285|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    285|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    285|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    285|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    285|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    285|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    285|  constexpr auto _size = _name.size();                                \
  |  | 1183|    285|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    285|  return _nameof; }()
  ------------------
  561|    285|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    285|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    285|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    285|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    285|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    285|  constexpr auto _size = _name.size();                                \
  |  | 1183|    285|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    285|  return _nameof; }()
  ------------------
  562|    285|      c.fuzz(chardata);                                                        \
  563|    285|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    285|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    285|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    285|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    285|    static const bool do_print_testcase =
  181|    285|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    285|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 285]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    285|    do {
  189|       |      // step 0 - is the input valid?
  190|    285|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    285|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 285]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|       |                    From == UtfEncodings::UTF8) {
  198|       |        if (!count_the_input(from) && !allow_implementations_to_differ)
  199|       |          break;
  200|       |      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    285|      const auto [output_length, length_agree] =
  204|    285|          calculate_length(from, inputisvalid);
  205|    285|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 285]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    285|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 208, False: 77]
  |  Branch (208:28): [True: 0, False: 208]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    285|      const auto [written, outputs_agree] =
  215|    285|          do_conversion(from, output_length, inputisvalid);
  216|    285|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 285]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    285|      return;
  221|    285|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    285|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    285|  validation_result verify_valid_input(FromSpan src) const {
  231|    285|    validation_result ret{};
  232|       |
  233|    285|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    285|    const auto implementations = get_supported_implementations();
  235|    285|    std::vector<simdutf::result> results;
  236|    285|    results.reserve(implementations.size());
  237|       |
  238|    855|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 855, False: 285]
  ------------------
  239|    855|      results.push_back(
  240|    855|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    855|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    855|      const bool validation2 =
  245|    855|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    855|                      src.data(), src.size());
  247|    855|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 855]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|    855|    }
  258|       |
  259|    285|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    285|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 285]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    285|    } else {
  273|    285|      ret.implementations_agree = true;
  274|    285|    }
  275|    285|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    285|      return r.error == simdutf::SUCCESS;
  277|    285|    });
  278|    285|    return ret;
  279|    285|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    570|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKS7_E_clESI_:
  275|    439|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    439|      return r.error == simdutf::SUCCESS;
  277|    439|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    285|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    285|    length_result ret{};
  344|       |
  345|    285|    const auto implementations = get_supported_implementations();
  346|    285|    std::vector<std::size_t> results;
  347|    285|    results.reserve(implementations.size());
  348|       |
  349|    855|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 855, False: 285]
  ------------------
  350|    855|      const auto len = invoke_lengthcalc(impl, src);
  351|    855|      results.push_back(len);
  352|    855|      ret.length.push_back(len);
  353|    855|    }
  354|       |
  355|    285|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    285|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 285]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    285|    } else {
  375|    285|      ret.implementations_agree = true;
  376|    285|    }
  377|    285|    return ret;
  378|    285|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    855|                                FromSpan src) const {
  331|    855|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    855|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    570|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    285|                                  const bool inputisvalid) const {
  383|    285|    conversion_result ret{};
  384|       |
  385|    285|    const auto implementations = get_supported_implementations();
  386|       |
  387|    285|    std::vector<result<ConversionResult>> results;
  388|    285|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    285|    std::vector<std::vector<ToType>> outputbuffers;
  393|    285|    outputbuffers.reserve(implementations.size());
  394|  1.14k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 855, False: 285]
  ------------------
  395|    855|      auto impl = implementations[i];
  396|    855|      const ToType canary1{42};
  397|    855|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    855|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    855|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    855|      const auto success = [](const ConversionResult& r) -> bool {
  402|    855|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    855|          return r != 0;
  404|    855|        } else {
  405|    855|          return r.error == simdutf::error_code::SUCCESS;
  406|    855|        }
  407|    855|      }(implret1);
  408|    855|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    855|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    855|        const ToType canary2{25};
  414|    855|        const auto outputbuffer_first_run = outputbuffer;
  415|    855|        std::ranges::fill(outputbuffer, canary2);
  416|    855|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    855|                                          src.size(), outputbuffer.data());
  418|       |
  419|    855|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 855]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    855|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 231, False: 624]
  |  Branch (423:29): [True: 231, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    231|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    231|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 231]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    231|        }
  440|    855|      }
  441|    855|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 231, False: 624]
  ------------------
  442|    855|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    285|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 208, False: 77]
  ------------------
  447|    624|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 624, False: 208]
  ------------------
  448|    624|        e.outputhash.clear();
  449|    624|      }
  450|    208|    }
  451|       |
  452|    285|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    285|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 285]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    285|    } else {
  474|    285|      ret.implementations_agree = true;
  475|    285|    }
  476|    285|    return ret;
  477|    285|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    855|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    855|        } else {
  405|    855|          return r.error == simdutf::error_code::SUCCESS;
  406|    855|        }
  407|    855|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_0EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    570|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_32clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    311|    +[](std::span<const char> chardata) {                                      \
  555|    311|      const auto c =                                                           \
  556|    311|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    311|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    311|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    311|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    311|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    311|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    311|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    311|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    311|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    311|  constexpr auto _size = _name.size();                                \
  |  | 1183|    311|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    311|  return _nameof; }()
  ------------------
  561|    311|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    311|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    311|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    311|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    311|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    311|  constexpr auto _size = _name.size();                                \
  |  | 1183|    311|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    311|  return _nameof; }()
  ------------------
  562|    311|      c.fuzz(chardata);                                                        \
  563|    311|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    311|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    311|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    311|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    311|    static const bool do_print_testcase =
  181|    311|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    311|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 311]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    311|    do {
  189|       |      // step 0 - is the input valid?
  190|    311|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    311|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 311]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|       |                    From == UtfEncodings::UTF8) {
  198|       |        if (!count_the_input(from) && !allow_implementations_to_differ)
  199|       |          break;
  200|       |      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    311|      const auto [output_length, length_agree] =
  204|    311|          calculate_length(from, inputisvalid);
  205|    311|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 311]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    311|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 220, False: 91]
  |  Branch (208:28): [True: 0, False: 220]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    311|      const auto [written, outputs_agree] =
  215|    311|          do_conversion(from, output_length, inputisvalid);
  216|    311|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 311]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    311|      return;
  221|    311|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    311|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    311|  validation_result verify_valid_input(FromSpan src) const {
  231|    311|    validation_result ret{};
  232|       |
  233|    311|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    311|    const auto implementations = get_supported_implementations();
  235|    311|    std::vector<simdutf::result> results;
  236|    311|    results.reserve(implementations.size());
  237|       |
  238|    933|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 933, False: 311]
  ------------------
  239|    933|      results.push_back(
  240|    933|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|    933|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|    933|      const bool validation2 =
  245|    933|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|    933|                      src.data(), src.size());
  247|    933|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 933]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|    933|    }
  258|       |
  259|    311|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    311|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 311]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    311|    } else {
  273|    311|      ret.implementations_agree = true;
  274|    311|    }
  275|    311|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    311|      return r.error == simdutf::SUCCESS;
  277|    311|    });
  278|    311|    return ret;
  279|    311|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    622|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKS7_E_clESI_:
  275|    493|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    493|      return r.error == simdutf::SUCCESS;
  277|    493|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    311|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    311|    length_result ret{};
  344|       |
  345|    311|    const auto implementations = get_supported_implementations();
  346|    311|    std::vector<std::size_t> results;
  347|    311|    results.reserve(implementations.size());
  348|       |
  349|    933|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 933, False: 311]
  ------------------
  350|    933|      const auto len = invoke_lengthcalc(impl, src);
  351|    933|      results.push_back(len);
  352|    933|      ret.length.push_back(len);
  353|    933|    }
  354|       |
  355|    311|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    311|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 311]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    311|    } else {
  375|    311|      ret.implementations_agree = true;
  376|    311|    }
  377|    311|    return ret;
  378|    311|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    933|                                FromSpan src) const {
  331|    933|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    933|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    622|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    311|                                  const bool inputisvalid) const {
  383|    311|    conversion_result ret{};
  384|       |
  385|    311|    const auto implementations = get_supported_implementations();
  386|       |
  387|    311|    std::vector<result<ConversionResult>> results;
  388|    311|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    311|    std::vector<std::vector<ToType>> outputbuffers;
  393|    311|    outputbuffers.reserve(implementations.size());
  394|  1.24k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 933, False: 311]
  ------------------
  395|    933|      auto impl = implementations[i];
  396|    933|      const ToType canary1{42};
  397|    933|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    933|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    933|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    933|      const auto success = [](const ConversionResult& r) -> bool {
  402|    933|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    933|          return r != 0;
  404|    933|        } else {
  405|    933|          return r.error == simdutf::error_code::SUCCESS;
  406|    933|        }
  407|    933|      }(implret1);
  408|    933|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    933|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    933|        const ToType canary2{25};
  414|    933|        const auto outputbuffer_first_run = outputbuffer;
  415|    933|        std::ranges::fill(outputbuffer, canary2);
  416|    933|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    933|                                          src.size(), outputbuffer.data());
  418|       |
  419|    933|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 933]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    933|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 273, False: 660]
  |  Branch (423:29): [True: 273, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    273|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    273|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 273]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    273|        }
  440|    933|      }
  441|    933|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 273, False: 660]
  ------------------
  442|    933|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    311|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 220, False: 91]
  ------------------
  447|    660|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 660, False: 220]
  ------------------
  448|    660|        e.outputhash.clear();
  449|    660|      }
  450|    220|    }
  451|       |
  452|    311|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    311|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 311]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    311|    } else {
  474|    311|      ret.implementations_agree = true;
  475|    311|    }
  476|    311|    return ret;
  477|    311|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|    933|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|    933|        } else {
  405|    933|          return r.error == simdutf::error_code::SUCCESS;
  406|    933|        }
  407|    933|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_1EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    622|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_33clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    386|    +[](std::span<const char> chardata) {                                      \
  555|    386|      const auto c =                                                           \
  556|    386|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    386|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    386|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    386|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    386|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    386|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    386|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    386|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    386|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    386|  constexpr auto _size = _name.size();                                \
  |  | 1183|    386|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    386|  return _nameof; }()
  ------------------
  561|    386|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    386|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    386|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    386|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    386|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    386|  constexpr auto _size = _name.size();                                \
  |  | 1183|    386|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    386|  return _nameof; }()
  ------------------
  562|    386|      c.fuzz(chardata);                                                        \
  563|    386|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE4fuzzENSt3__14spanIKcLm18446744073709551615EEE:
  175|    386|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    386|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    386|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    386|    static const bool do_print_testcase =
  181|    386|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    386|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 386]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    386|    do {
  189|       |      // step 0 - is the input valid?
  190|    386|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    386|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 386]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|       |                    From == UtfEncodings::UTF8) {
  198|       |        if (!count_the_input(from) && !allow_implementations_to_differ)
  199|       |          break;
  200|       |      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    386|      const auto [output_length, length_agree] =
  204|    386|          calculate_length(from, inputisvalid);
  205|    386|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 386]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    386|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 280, False: 106]
  |  Branch (208:28): [True: 0, False: 280]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    386|      const auto [written, outputs_agree] =
  215|    386|          do_conversion(from, output_length, inputisvalid);
  216|    386|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 386]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    386|      return;
  221|    386|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    386|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    386|  validation_result verify_valid_input(FromSpan src) const {
  231|    386|    validation_result ret{};
  232|       |
  233|    386|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    386|    const auto implementations = get_supported_implementations();
  235|    386|    std::vector<simdutf::result> results;
  236|    386|    results.reserve(implementations.size());
  237|       |
  238|  1.15k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.15k, False: 386]
  ------------------
  239|  1.15k|      results.push_back(
  240|  1.15k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.15k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.15k|      const bool validation2 =
  245|  1.15k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.15k|                      src.data(), src.size());
  247|  1.15k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.15k]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|  1.15k|    }
  258|       |
  259|    386|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    386|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 386]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    386|    } else {
  273|    386|      ret.implementations_agree = true;
  274|    386|    }
  275|    386|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    386|      return r.error == simdutf::SUCCESS;
  277|    386|    });
  278|    386|    return ret;
  279|    386|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    772|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKS7_E_clESI_:
  275|    598|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    598|      return r.error == simdutf::SUCCESS;
  277|    598|    });
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    386|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    386|    length_result ret{};
  344|       |
  345|    386|    const auto implementations = get_supported_implementations();
  346|    386|    std::vector<std::size_t> results;
  347|    386|    results.reserve(implementations.size());
  348|       |
  349|  1.15k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.15k, False: 386]
  ------------------
  350|  1.15k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.15k|      results.push_back(len);
  352|  1.15k|      ret.length.push_back(len);
  353|  1.15k|    }
  354|       |
  355|    386|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    386|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 386]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    386|    } else {
  375|    386|      ret.implementations_agree = true;
  376|    386|    }
  377|    386|    return ret;
  378|    386|  }
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.15k|                                FromSpan src) const {
  331|  1.15k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.15k|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    772|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    386|                                  const bool inputisvalid) const {
  383|    386|    conversion_result ret{};
  384|       |
  385|    386|    const auto implementations = get_supported_implementations();
  386|       |
  387|    386|    std::vector<result<ConversionResult>> results;
  388|    386|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    386|    std::vector<std::vector<ToType>> outputbuffers;
  393|    386|    outputbuffers.reserve(implementations.size());
  394|  1.54k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.15k, False: 386]
  ------------------
  395|  1.15k|      auto impl = implementations[i];
  396|  1.15k|      const ToType canary1{42};
  397|  1.15k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.15k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.15k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.15k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.15k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.15k|          return r != 0;
  404|  1.15k|        } else {
  405|  1.15k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.15k|        }
  407|  1.15k|      }(implret1);
  408|  1.15k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.15k|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|  1.15k|        const ToType canary2{25};
  414|  1.15k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.15k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.15k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.15k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.15k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.15k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.15k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 318, False: 840]
  |  Branch (423:29): [True: 318, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    318|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    318|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 318]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    318|        }
  440|  1.15k|      }
  441|  1.15k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 318, False: 840]
  ------------------
  442|  1.15k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    386|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 280, False: 106]
  ------------------
  447|    840|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 840, False: 280]
  ------------------
  448|    840|        e.outputhash.clear();
  449|    840|      }
  450|    280|    }
  451|       |
  452|    386|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    386|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 386]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    386|    } else {
  474|    386|      ret.implementations_agree = true;
  475|    386|    }
  476|    386|    return ret;
  477|    386|  }
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|  1.15k|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|  1.15k|        } else {
  405|  1.15k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.15k|        }
  407|  1.15k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings3ELS0_2EMN7simdutf14implementationEKDoFmPKDimEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    772|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_34clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    375|    +[](std::span<const char> chardata) {                                      \
  555|    375|      const auto c =                                                           \
  556|    375|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    375|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    375|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    375|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    375|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    375|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    375|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    375|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    375|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    375|  constexpr auto _size = _name.size();                                \
  |  | 1183|    375|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    375|  return _nameof; }()
  ------------------
  561|    375|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    375|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    375|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    375|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    375|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    375|  constexpr auto _size = _name.size();                                \
  |  | 1183|    375|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    375|  return _nameof; }()
  ------------------
  562|    375|      c.fuzz(chardata);                                                        \
  563|    375|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    375|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    375|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    375|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    375|    static const bool do_print_testcase =
  181|    375|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    375|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 375]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    375|    do {
  189|       |      // step 0 - is the input valid?
  190|    375|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    375|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 375]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    375|                    From == UtfEncodings::UTF8) {
  198|    375|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 375]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    375|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    375|      const auto [output_length, length_agree] =
  204|    375|          calculate_length(from, inputisvalid);
  205|    375|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 375]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    375|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 258, False: 117]
  |  Branch (208:28): [True: 0, False: 258]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    375|      const auto [written, outputs_agree] =
  215|    375|          do_conversion(from, output_length, inputisvalid);
  216|    375|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 375]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    375|      return;
  221|    375|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    375|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    375|  validation_result verify_valid_input(FromSpan src) const {
  231|    375|    validation_result ret{};
  232|       |
  233|    375|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    375|    const auto implementations = get_supported_implementations();
  235|    375|    std::vector<simdutf::result> results;
  236|    375|    results.reserve(implementations.size());
  237|       |
  238|  1.12k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.12k, False: 375]
  ------------------
  239|  1.12k|      results.push_back(
  240|  1.12k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.12k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.12k|      const bool validation2 =
  245|  1.12k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.12k|                      src.data(), src.size());
  247|  1.12k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.12k]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|  1.12k|    }
  258|       |
  259|    375|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    375|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 375]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    375|    } else {
  273|    375|      ret.implementations_agree = true;
  274|    375|    }
  275|    375|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    375|      return r.error == simdutf::SUCCESS;
  277|    375|    });
  278|    375|    return ret;
  279|    375|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    750|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKS7_E_clESI_:
  275|    609|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    609|      return r.error == simdutf::SUCCESS;
  277|    609|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    375|  bool count_the_input(FromSpan src) const {
  290|    375|    const auto implementations = get_supported_implementations();
  291|    375|    std::vector<std::size_t> results;
  292|    375|    results.reserve(implementations.size());
  293|       |
  294|  1.12k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.12k, False: 375]
  ------------------
  295|  1.12k|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|       |      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|       |        ret = impl->count_utf16le(src.data(), src.size());
  300|  1.12k|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|  1.12k|        ret = impl->count_utf8(src.data(), src.size());
  302|  1.12k|      }
  303|  1.12k|      results.push_back(ret);
  304|  1.12k|    }
  305|    375|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    375|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 375]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|    375|    return true;
  321|    375|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    750|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    375|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    375|    length_result ret{};
  344|       |
  345|    375|    const auto implementations = get_supported_implementations();
  346|    375|    std::vector<std::size_t> results;
  347|    375|    results.reserve(implementations.size());
  348|       |
  349|  1.12k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.12k, False: 375]
  ------------------
  350|  1.12k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.12k|      results.push_back(len);
  352|  1.12k|      ret.length.push_back(len);
  353|  1.12k|    }
  354|       |
  355|    375|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    375|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 375]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    375|    } else {
  375|    375|      ret.implementations_agree = true;
  376|    375|    }
  377|    375|    return ret;
  378|    375|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.12k|                                FromSpan src) const {
  331|  1.12k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.12k|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    750|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    375|                                  const bool inputisvalid) const {
  383|    375|    conversion_result ret{};
  384|       |
  385|    375|    const auto implementations = get_supported_implementations();
  386|       |
  387|    375|    std::vector<result<ConversionResult>> results;
  388|    375|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    375|    std::vector<std::vector<ToType>> outputbuffers;
  393|    375|    outputbuffers.reserve(implementations.size());
  394|  1.50k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.12k, False: 375]
  ------------------
  395|  1.12k|      auto impl = implementations[i];
  396|  1.12k|      const ToType canary1{42};
  397|  1.12k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.12k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.12k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.12k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.12k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.12k|          return r != 0;
  404|  1.12k|        } else {
  405|  1.12k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.12k|        }
  407|  1.12k|      }(implret1);
  408|  1.12k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.12k|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|  1.12k|        const ToType canary2{25};
  414|  1.12k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.12k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.12k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.12k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.12k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.12k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.12k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 351, False: 774]
  |  Branch (423:29): [True: 333, False: 18]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    333|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    333|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 333]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    333|        }
  440|  1.12k|      }
  441|  1.12k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 333, False: 792]
  ------------------
  442|  1.12k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    375|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 258, False: 117]
  ------------------
  447|    774|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 774, False: 258]
  ------------------
  448|    774|        e.outputhash.clear();
  449|    774|      }
  450|    258|    }
  451|       |
  452|    375|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    375|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 375]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    375|    } else {
  474|    375|      ret.implementations_agree = true;
  475|    375|    }
  476|    375|    return ret;
  477|    375|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|  1.12k|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|  1.12k|        } else {
  405|  1.12k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.12k|        }
  407|  1.12k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_4EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    750|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_35clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    442|    +[](std::span<const char> chardata) {                                      \
  555|    442|      const auto c =                                                           \
  556|    442|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    442|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    442|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    442|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    442|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    442|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    442|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    442|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    442|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    442|  constexpr auto _size = _name.size();                                \
  |  | 1183|    442|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    442|  return _nameof; }()
  ------------------
  561|    442|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    442|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    442|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    442|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    442|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    442|  constexpr auto _size = _name.size();                                \
  |  | 1183|    442|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    442|  return _nameof; }()
  ------------------
  562|    442|      c.fuzz(chardata);                                                        \
  563|    442|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    442|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    442|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    442|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    442|    static const bool do_print_testcase =
  181|    442|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    442|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 442]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    442|    do {
  189|       |      // step 0 - is the input valid?
  190|    442|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    442|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 442]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    442|                    From == UtfEncodings::UTF8) {
  198|    442|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 442]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    442|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    442|      const auto [output_length, length_agree] =
  204|    442|          calculate_length(from, inputisvalid);
  205|    442|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 442]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    442|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 264, False: 178]
  |  Branch (208:28): [True: 0, False: 264]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    442|      const auto [written, outputs_agree] =
  215|    442|          do_conversion(from, output_length, inputisvalid);
  216|    442|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 442]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    442|      return;
  221|    442|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    442|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    442|  validation_result verify_valid_input(FromSpan src) const {
  231|    442|    validation_result ret{};
  232|       |
  233|    442|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    442|    const auto implementations = get_supported_implementations();
  235|    442|    std::vector<simdutf::result> results;
  236|    442|    results.reserve(implementations.size());
  237|       |
  238|  1.32k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.32k, False: 442]
  ------------------
  239|  1.32k|      results.push_back(
  240|  1.32k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.32k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.32k|      const bool validation2 =
  245|  1.32k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.32k|                      src.data(), src.size());
  247|  1.32k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.32k]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|  1.32k|    }
  258|       |
  259|    442|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    442|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 442]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    442|    } else {
  273|    442|      ret.implementations_agree = true;
  274|    442|    }
  275|    442|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    442|      return r.error == simdutf::SUCCESS;
  277|    442|    });
  278|    442|    return ret;
  279|    442|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    884|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKS7_E_clESI_:
  275|    798|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    798|      return r.error == simdutf::SUCCESS;
  277|    798|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    442|  bool count_the_input(FromSpan src) const {
  290|    442|    const auto implementations = get_supported_implementations();
  291|    442|    std::vector<std::size_t> results;
  292|    442|    results.reserve(implementations.size());
  293|       |
  294|  1.32k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.32k, False: 442]
  ------------------
  295|  1.32k|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|       |      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|       |        ret = impl->count_utf16le(src.data(), src.size());
  300|  1.32k|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|  1.32k|        ret = impl->count_utf8(src.data(), src.size());
  302|  1.32k|      }
  303|  1.32k|      results.push_back(ret);
  304|  1.32k|    }
  305|    442|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    442|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 442]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|    442|    return true;
  321|    442|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    884|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    442|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    442|    length_result ret{};
  344|       |
  345|    442|    const auto implementations = get_supported_implementations();
  346|    442|    std::vector<std::size_t> results;
  347|    442|    results.reserve(implementations.size());
  348|       |
  349|  1.32k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.32k, False: 442]
  ------------------
  350|  1.32k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.32k|      results.push_back(len);
  352|  1.32k|      ret.length.push_back(len);
  353|  1.32k|    }
  354|       |
  355|    442|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    442|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 442]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    442|    } else {
  375|    442|      ret.implementations_agree = true;
  376|    442|    }
  377|    442|    return ret;
  378|    442|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.32k|                                FromSpan src) const {
  331|  1.32k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.32k|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    884|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    442|                                  const bool inputisvalid) const {
  383|    442|    conversion_result ret{};
  384|       |
  385|    442|    const auto implementations = get_supported_implementations();
  386|       |
  387|    442|    std::vector<result<ConversionResult>> results;
  388|    442|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    442|    std::vector<std::vector<ToType>> outputbuffers;
  393|    442|    outputbuffers.reserve(implementations.size());
  394|  1.76k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.32k, False: 442]
  ------------------
  395|  1.32k|      auto impl = implementations[i];
  396|  1.32k|      const ToType canary1{42};
  397|  1.32k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.32k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.32k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.32k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.32k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.32k|          return r != 0;
  404|  1.32k|        } else {
  405|  1.32k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.32k|        }
  407|  1.32k|      }(implret1);
  408|  1.32k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.32k|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|  1.32k|        const ToType canary2{25};
  414|  1.32k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.32k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.32k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.32k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.32k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.32k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.32k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 534, False: 792]
  |  Branch (423:29): [True: 534, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    534|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    534|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 534]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    534|        }
  440|  1.32k|      }
  441|  1.32k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 534, False: 792]
  ------------------
  442|  1.32k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    442|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 264, False: 178]
  ------------------
  447|    792|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 792, False: 264]
  ------------------
  448|    792|        e.outputhash.clear();
  449|    792|      }
  450|    264|    }
  451|       |
  452|    442|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    442|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 442]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    442|    } else {
  474|    442|      ret.implementations_agree = true;
  475|    442|    }
  476|    442|    return ret;
  477|    442|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|  1.32k|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|  1.32k|        } else {
  405|  1.32k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.32k|        }
  407|  1.32k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_0EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    884|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_36clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    395|    +[](std::span<const char> chardata) {                                      \
  555|    395|      const auto c =                                                           \
  556|    395|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    395|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    395|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    395|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    395|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    395|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    395|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    395|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    395|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    395|  constexpr auto _size = _name.size();                                \
  |  | 1183|    395|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    395|  return _nameof; }()
  ------------------
  561|    395|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    395|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    395|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    395|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    395|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    395|  constexpr auto _size = _name.size();                                \
  |  | 1183|    395|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    395|  return _nameof; }()
  ------------------
  562|    395|      c.fuzz(chardata);                                                        \
  563|    395|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    395|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    395|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    395|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    395|    static const bool do_print_testcase =
  181|    395|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    395|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 395]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    395|    do {
  189|       |      // step 0 - is the input valid?
  190|    395|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    395|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 395]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    395|                    From == UtfEncodings::UTF8) {
  198|    395|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 395]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    395|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    395|      const auto [output_length, length_agree] =
  204|    395|          calculate_length(from, inputisvalid);
  205|    395|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 395]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    395|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 245, False: 150]
  |  Branch (208:28): [True: 0, False: 245]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    395|      const auto [written, outputs_agree] =
  215|    395|          do_conversion(from, output_length, inputisvalid);
  216|    395|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 395]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    395|      return;
  221|    395|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    395|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    395|  validation_result verify_valid_input(FromSpan src) const {
  231|    395|    validation_result ret{};
  232|       |
  233|    395|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    395|    const auto implementations = get_supported_implementations();
  235|    395|    std::vector<simdutf::result> results;
  236|    395|    results.reserve(implementations.size());
  237|       |
  238|  1.18k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.18k, False: 395]
  ------------------
  239|  1.18k|      results.push_back(
  240|  1.18k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.18k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.18k|      const bool validation2 =
  245|  1.18k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.18k|                      src.data(), src.size());
  247|  1.18k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.18k]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|  1.18k|    }
  258|       |
  259|    395|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    395|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 395]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    395|    } else {
  273|    395|      ret.implementations_agree = true;
  274|    395|    }
  275|    395|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    395|      return r.error == simdutf::SUCCESS;
  277|    395|    });
  278|    395|    return ret;
  279|    395|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    790|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKS7_E_clESI_:
  275|    695|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    695|      return r.error == simdutf::SUCCESS;
  277|    695|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    395|  bool count_the_input(FromSpan src) const {
  290|    395|    const auto implementations = get_supported_implementations();
  291|    395|    std::vector<std::size_t> results;
  292|    395|    results.reserve(implementations.size());
  293|       |
  294|  1.18k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.18k, False: 395]
  ------------------
  295|  1.18k|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|       |      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|       |        ret = impl->count_utf16le(src.data(), src.size());
  300|  1.18k|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|  1.18k|        ret = impl->count_utf8(src.data(), src.size());
  302|  1.18k|      }
  303|  1.18k|      results.push_back(ret);
  304|  1.18k|    }
  305|    395|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    395|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 395]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|    395|    return true;
  321|    395|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    790|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    395|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    395|    length_result ret{};
  344|       |
  345|    395|    const auto implementations = get_supported_implementations();
  346|    395|    std::vector<std::size_t> results;
  347|    395|    results.reserve(implementations.size());
  348|       |
  349|  1.18k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.18k, False: 395]
  ------------------
  350|  1.18k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.18k|      results.push_back(len);
  352|  1.18k|      ret.length.push_back(len);
  353|  1.18k|    }
  354|       |
  355|    395|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    395|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 395]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    395|    } else {
  375|    395|      ret.implementations_agree = true;
  376|    395|    }
  377|    395|    return ret;
  378|    395|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.18k|                                FromSpan src) const {
  331|  1.18k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.18k|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    790|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    395|                                  const bool inputisvalid) const {
  383|    395|    conversion_result ret{};
  384|       |
  385|    395|    const auto implementations = get_supported_implementations();
  386|       |
  387|    395|    std::vector<result<ConversionResult>> results;
  388|    395|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    395|    std::vector<std::vector<ToType>> outputbuffers;
  393|    395|    outputbuffers.reserve(implementations.size());
  394|  1.58k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.18k, False: 395]
  ------------------
  395|  1.18k|      auto impl = implementations[i];
  396|  1.18k|      const ToType canary1{42};
  397|  1.18k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.18k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.18k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.18k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.18k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.18k|          return r != 0;
  404|  1.18k|        } else {
  405|  1.18k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.18k|        }
  407|  1.18k|      }(implret1);
  408|  1.18k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.18k|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|  1.18k|        const ToType canary2{25};
  414|  1.18k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.18k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.18k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.18k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.18k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.18k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.18k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 450, False: 735]
  |  Branch (423:29): [True: 450, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    450|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    450|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 450]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    450|        }
  440|  1.18k|      }
  441|  1.18k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 450, False: 735]
  ------------------
  442|  1.18k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    395|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 245, False: 150]
  ------------------
  447|    735|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 735, False: 245]
  ------------------
  448|    735|        e.outputhash.clear();
  449|    735|      }
  450|    245|    }
  451|       |
  452|    395|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    395|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 395]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    395|    } else {
  474|    395|      ret.implementations_agree = true;
  475|    395|    }
  476|    395|    return ret;
  477|    395|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|  1.18k|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|  1.18k|        } else {
  405|  1.18k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.18k|        }
  407|  1.18k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_1EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDsEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    790|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_37clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    473|    +[](std::span<const char> chardata) {                                      \
  555|    473|      const auto c =                                                           \
  556|    473|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    473|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    473|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    473|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    473|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    473|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    473|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    473|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    473|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    473|  constexpr auto _size = _name.size();                                \
  |  | 1183|    473|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    473|  return _nameof; }()
  ------------------
  561|    473|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    473|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    473|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    473|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    473|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    473|  constexpr auto _size = _name.size();                                \
  |  | 1183|    473|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    473|  return _nameof; }()
  ------------------
  562|    473|      c.fuzz(chardata);                                                        \
  563|    473|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    473|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    473|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    473|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    473|    static const bool do_print_testcase =
  181|    473|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    473|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 473]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    473|    do {
  189|       |      // step 0 - is the input valid?
  190|    473|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    473|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 473]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|    473|                    From == UtfEncodings::UTF8) {
  198|    473|        if (!count_the_input(from) && !allow_implementations_to_differ)
  ------------------
  |  Branch (198:13): [True: 0, False: 473]
  |  Branch (198:39): [True: 0, Folded]
  ------------------
  199|      0|          break;
  200|    473|      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    473|      const auto [output_length, length_agree] =
  204|    473|          calculate_length(from, inputisvalid);
  205|    473|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 473]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    473|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 296, False: 177]
  |  Branch (208:28): [True: 0, False: 296]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    473|      const auto [written, outputs_agree] =
  215|    473|          do_conversion(from, output_length, inputisvalid);
  216|    473|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 473]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    473|      return;
  221|    473|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    473|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  230|    473|  validation_result verify_valid_input(FromSpan src) const {
  231|    473|    validation_result ret{};
  232|       |
  233|    473|    auto input_validation = ValidationFunctionTrait<From>::ValidationWithErrors;
  234|    473|    const auto implementations = get_supported_implementations();
  235|    473|    std::vector<simdutf::result> results;
  236|    473|    results.reserve(implementations.size());
  237|       |
  238|  1.41k|    for (auto impl : implementations) {
  ------------------
  |  Branch (238:20): [True: 1.41k, False: 473]
  ------------------
  239|  1.41k|      results.push_back(
  240|  1.41k|          std::invoke(input_validation, impl, src.data(), src.size()));
  241|       |
  242|       |      // make sure the validation variant that returns a bool agrees
  243|  1.41k|      const bool validation1 = results.back().error == simdutf::SUCCESS;
  244|  1.41k|      const bool validation2 =
  245|  1.41k|          std::invoke(ValidationFunctionTrait<From>::Validation, impl,
  246|  1.41k|                      src.data(), src.size());
  247|  1.41k|      if (validation1 != validation2) {
  ------------------
  |  Branch (247:11): [True: 0, False: 1.41k]
  ------------------
  248|      0|        std::cerr << "begin errormessage for verify_valid_input()\n";
  249|      0|        std::cerr << ValidationFunctionTrait<From>::ValidationWithErrorsName
  250|      0|                  << " gives " << validation1 << " while "
  251|      0|                  << ValidationFunctionTrait<From>::ValidationName << " gave "
  252|      0|                  << validation2 << " for implementation " << impl->name()
  253|      0|                  << '\n';
  254|      0|        std::cerr << "end errormessage\n";
  255|      0|        std::abort();
  256|      0|      }
  257|  1.41k|    }
  258|       |
  259|    473|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  260|    473|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (260:9): [True: 0, False: 473]
  ------------------
  261|      0|      std::cerr << "begin errormessage for verify_valid_input()\n";
  262|      0|      std::cerr << "in fuzz case for "
  263|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  264|      0|                << " invoked with " << src.size() << " elements:\n";
  265|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (265:31): [True: 0, False: 0]
  ------------------
  266|      0|        std::cerr << "got return " << std::dec << results[i]
  267|      0|                  << " from implementation " << implementations[i]->name()
  268|      0|                  << '\n';
  269|      0|      }
  270|      0|      std::cerr << "end errormessage\n";
  271|      0|      ret.implementations_agree = false;
  272|    473|    } else {
  273|    473|      ret.implementations_agree = true;
  274|    473|    }
  275|    473|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    473|      return r.error == simdutf::SUCCESS;
  277|    473|    });
  278|    473|    return ret;
  279|    473|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clIS7_S7_EEDaSJ_SM_:
  259|    946|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE18verify_valid_inputIvQneT_LS0_4EEENSB_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKS7_E_clESI_:
  275|    827|    ret.valid = std::ranges::all_of(results, [](const simdutf::result& r) {
  276|    827|      return r.error == simdutf::SUCCESS;
  277|    827|    });
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEE:
  289|    473|  bool count_the_input(FromSpan src) const {
  290|    473|    const auto implementations = get_supported_implementations();
  291|    473|    std::vector<std::size_t> results;
  292|    473|    results.reserve(implementations.size());
  293|       |
  294|  1.41k|    for (auto impl : implementations) {
  ------------------
  |  Branch (294:20): [True: 1.41k, False: 473]
  ------------------
  295|  1.41k|      std::size_t ret;
  296|       |      if constexpr (From == UtfEncodings::UTF16BE) {
  297|       |        ret = impl->count_utf16be(src.data(), src.size());
  298|       |      } else if constexpr (From == UtfEncodings::UTF16LE) {
  299|       |        ret = impl->count_utf16le(src.data(), src.size());
  300|  1.41k|      } else if constexpr (From == UtfEncodings::UTF8) {
  301|  1.41k|        ret = impl->count_utf8(src.data(), src.size());
  302|  1.41k|      }
  303|  1.41k|      results.push_back(ret);
  304|  1.41k|    }
  305|    473|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  306|    473|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (306:9): [True: 0, False: 473]
  ------------------
  307|      0|      std::cerr << "begin errormessage for count_the_input()\n";
  308|      0|      std::cerr << "in fuzz case for "
  309|      0|                << ValidationFunctionTrait<From>::ValidationWithErrorsName
  310|      0|                << " invoked with " << src.size() << " elements:\n";
  311|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (311:31): [True: 0, False: 0]
  ------------------
  312|      0|        std::cerr << "got return " << std::dec << results[i]
  313|      0|                  << " from implementation " << implementations[i]->name()
  314|      0|                  << '\n';
  315|      0|      }
  316|      0|      std::cerr << "end errormessage\n";
  317|      0|      return false;
  318|      0|    }
  319|       |
  320|    473|    return true;
  321|    473|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE15count_the_inputENSt3__14spanIS3_Lm18446744073709551615EEEENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  305|    946|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    473|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    473|    length_result ret{};
  344|       |
  345|    473|    const auto implementations = get_supported_implementations();
  346|    473|    std::vector<std::size_t> results;
  347|    473|    results.reserve(implementations.size());
  348|       |
  349|  1.41k|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 1.41k, False: 473]
  ------------------
  350|  1.41k|      const auto len = invoke_lengthcalc(impl, src);
  351|  1.41k|      results.push_back(len);
  352|  1.41k|      ret.length.push_back(len);
  353|  1.41k|    }
  354|       |
  355|    473|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    473|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 473]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    473|    } else {
  375|    473|      ret.implementations_agree = true;
  376|    473|    }
  377|    473|    return ret;
  378|    473|  }
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSF_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|  1.41k|                                FromSpan src) const {
  331|  1.41k|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|  1.41k|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSH_SK_:
  355|    946|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEb:
  382|    473|                                  const bool inputisvalid) const {
  383|    473|    conversion_result ret{};
  384|       |
  385|    473|    const auto implementations = get_supported_implementations();
  386|       |
  387|    473|    std::vector<result<ConversionResult>> results;
  388|    473|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    473|    std::vector<std::vector<ToType>> outputbuffers;
  393|    473|    outputbuffers.reserve(implementations.size());
  394|  1.89k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 1.41k, False: 473]
  ------------------
  395|  1.41k|      auto impl = implementations[i];
  396|  1.41k|      const ToType canary1{42};
  397|  1.41k|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|  1.41k|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|  1.41k|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|  1.41k|      const auto success = [](const ConversionResult& r) -> bool {
  402|  1.41k|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|  1.41k|          return r != 0;
  404|  1.41k|        } else {
  405|  1.41k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.41k|        }
  407|  1.41k|      }(implret1);
  408|  1.41k|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|  1.41k|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|  1.41k|        const ToType canary2{25};
  414|  1.41k|        const auto outputbuffer_first_run = outputbuffer;
  415|  1.41k|        std::ranges::fill(outputbuffer, canary2);
  416|  1.41k|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|  1.41k|                                          src.size(), outputbuffer.data());
  418|       |
  419|  1.41k|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 1.41k]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|  1.41k|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 531, False: 888]
  |  Branch (423:29): [True: 531, False: 0]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    531|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    531|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 531]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    531|        }
  440|  1.41k|      }
  441|  1.41k|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 531, False: 888]
  ------------------
  442|  1.41k|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    473|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 296, False: 177]
  ------------------
  447|    888|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 888, False: 296]
  ------------------
  448|    888|        e.outputhash.clear();
  449|    888|      }
  450|    296|    }
  451|       |
  452|    473|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    473|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 473]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    473|    } else {
  474|    473|      ret.implementations_agree = true;
  475|    473|    }
  476|    473|    return ret;
  477|    473|  }
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKS7_E_clESM_:
  401|  1.41k|      const auto success = [](const ConversionResult& r) -> bool {
  402|       |        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|       |          return r != 0;
  404|  1.41k|        } else {
  405|  1.41k|          return r.error == simdutf::error_code::SUCCESS;
  406|  1.41k|        }
  407|  1.41k|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings2ELS0_3EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFNS1_6resultES4_mPDiEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSC_6vectorImNSC_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultIS7_ESU_EEDaSN_SQ_:
  452|    946|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_38clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     35|    +[](std::span<const char> chardata) {                                      \
  555|     35|      const auto c =                                                           \
  556|     35|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     35|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     35|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     35|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     35|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     35|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     35|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     35|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     35|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     35|  constexpr auto _size = _name.size();                                \
  |  | 1183|     35|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     35|  return _nameof; }()
  ------------------
  561|     35|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     35|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     35|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     35|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     35|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     35|  constexpr auto _size = _name.size();                                \
  |  | 1183|     35|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     35|  return _nameof; }()
  ------------------
  562|     35|      c.fuzz(chardata);                                                        \
  563|     35|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE4fuzzENSt3__14spanIS5_Lm18446744073709551615EEE:
  175|     35|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|     35|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|     35|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|     35|    static const bool do_print_testcase =
  181|     35|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|     35|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 35]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|     35|    do {
  189|       |      // step 0 - is the input valid?
  190|     35|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|     35|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 35]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|       |                    From == UtfEncodings::UTF8) {
  198|       |        if (!count_the_input(from) && !allow_implementations_to_differ)
  199|       |          break;
  200|       |      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|     35|      const auto [output_length, length_agree] =
  204|     35|          calculate_length(from, inputisvalid);
  205|     35|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 35]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|     35|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 0, False: 35]
  |  Branch (208:28): [True: 0, False: 0]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|     35|      const auto [written, outputs_agree] =
  215|     35|          do_conversion(from, output_length, inputisvalid);
  216|     35|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 35]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|     35|      return;
  221|     35|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|     35|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE18verify_valid_inputIvQeqT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  283|     35|  validation_result verify_valid_input(FromSpan) const {
  284|       |    // all latin1 input is valid. there is no simdutf validation function for
  285|       |    // it.
  286|     35|    return validation_result{.valid = true, .implementations_agree = true};
  287|     35|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|     35|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|     35|    length_result ret{};
  344|       |
  345|     35|    const auto implementations = get_supported_implementations();
  346|     35|    std::vector<std::size_t> results;
  347|     35|    results.reserve(implementations.size());
  348|       |
  349|    105|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 105, False: 35]
  ------------------
  350|    105|      const auto len = invoke_lengthcalc(impl, src);
  351|    105|      results.push_back(len);
  352|    105|      ret.length.push_back(len);
  353|    105|    }
  354|       |
  355|     35|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|     35|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 35]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|     35|    } else {
  375|     35|      ret.implementations_agree = true;
  376|     35|    }
  377|     35|    return ret;
  378|     35|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    105|                                FromSpan src) const {
  339|    105|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    105|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|     70|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|     35|                                  const bool inputisvalid) const {
  383|     35|    conversion_result ret{};
  384|       |
  385|     35|    const auto implementations = get_supported_implementations();
  386|       |
  387|     35|    std::vector<result<ConversionResult>> results;
  388|     35|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|     35|    std::vector<std::vector<ToType>> outputbuffers;
  393|     35|    outputbuffers.reserve(implementations.size());
  394|    140|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 105, False: 35]
  ------------------
  395|    105|      auto impl = implementations[i];
  396|    105|      const ToType canary1{42};
  397|    105|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    105|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    105|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    105|      const auto success = [](const ConversionResult& r) -> bool {
  402|    105|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    105|          return r != 0;
  404|    105|        } else {
  405|    105|          return r.error == simdutf::error_code::SUCCESS;
  406|    105|        }
  407|    105|      }(implret1);
  408|    105|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    105|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    105|        const ToType canary2{25};
  414|    105|        const auto outputbuffer_first_run = outputbuffer;
  415|    105|        std::ranges::fill(outputbuffer, canary2);
  416|    105|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    105|                                          src.size(), outputbuffer.data());
  418|       |
  419|    105|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 105]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    105|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 105, False: 0]
  |  Branch (423:29): [True: 99, False: 6]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|     99|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|     99|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 99]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|     99|        }
  440|    105|      }
  441|    105|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 99, False: 6]
  ------------------
  442|    105|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|     35|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 0, False: 35]
  ------------------
  447|      0|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 0, False: 0]
  ------------------
  448|      0|        e.outputhash.clear();
  449|      0|      }
  450|      0|    }
  451|       |
  452|     35|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|     35|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 35]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|     35|    } else {
  474|     35|      ret.implementations_agree = true;
  475|     35|    }
  476|     35|    return ret;
  477|     35|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    105|      const auto success = [](const ConversionResult& r) -> bool {
  402|    105|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    105|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    105|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings4ELS0_3EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDiEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|     70|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_39clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     42|    +[](std::span<const char> chardata) {                                      \
  555|     42|      const auto c =                                                           \
  556|     42|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     42|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     42|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     42|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     42|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     42|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     42|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     42|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     42|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     42|  constexpr auto _size = _name.size();                                \
  |  | 1183|     42|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     42|  return _nameof; }()
  ------------------
  561|     42|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     42|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     42|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     42|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     42|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     42|  constexpr auto _size = _name.size();                                \
  |  | 1183|     42|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     42|  return _nameof; }()
  ------------------
  562|     42|      c.fuzz(chardata);                                                        \
  563|     42|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE4fuzzENSt3__14spanIS5_Lm18446744073709551615EEE:
  175|     42|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|     42|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|     42|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|     42|    static const bool do_print_testcase =
  181|     42|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|     42|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 42]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|     42|    do {
  189|       |      // step 0 - is the input valid?
  190|     42|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|     42|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 42]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|       |                    From == UtfEncodings::UTF8) {
  198|       |        if (!count_the_input(from) && !allow_implementations_to_differ)
  199|       |          break;
  200|       |      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|     42|      const auto [output_length, length_agree] =
  204|     42|          calculate_length(from, inputisvalid);
  205|     42|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 42]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|     42|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 0, False: 42]
  |  Branch (208:28): [True: 0, False: 0]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|     42|      const auto [written, outputs_agree] =
  215|     42|          do_conversion(from, output_length, inputisvalid);
  216|     42|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 42]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|     42|      return;
  221|     42|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|     42|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE18verify_valid_inputIvQeqT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  283|     42|  validation_result verify_valid_input(FromSpan) const {
  284|       |    // all latin1 input is valid. there is no simdutf validation function for
  285|       |    // it.
  286|     42|    return validation_result{.valid = true, .implementations_agree = true};
  287|     42|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|     42|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|     42|    length_result ret{};
  344|       |
  345|     42|    const auto implementations = get_supported_implementations();
  346|     42|    std::vector<std::size_t> results;
  347|     42|    results.reserve(implementations.size());
  348|       |
  349|    126|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 126, False: 42]
  ------------------
  350|    126|      const auto len = invoke_lengthcalc(impl, src);
  351|    126|      results.push_back(len);
  352|    126|      ret.length.push_back(len);
  353|    126|    }
  354|       |
  355|     42|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|     42|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 42]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|     42|    } else {
  375|     42|      ret.implementations_agree = true;
  376|     42|    }
  377|     42|    return ret;
  378|     42|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    126|                                FromSpan src) const {
  339|    126|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    126|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|     84|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|     42|                                  const bool inputisvalid) const {
  383|     42|    conversion_result ret{};
  384|       |
  385|     42|    const auto implementations = get_supported_implementations();
  386|       |
  387|     42|    std::vector<result<ConversionResult>> results;
  388|     42|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|     42|    std::vector<std::vector<ToType>> outputbuffers;
  393|     42|    outputbuffers.reserve(implementations.size());
  394|    168|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 126, False: 42]
  ------------------
  395|    126|      auto impl = implementations[i];
  396|    126|      const ToType canary1{42};
  397|    126|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    126|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    126|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    126|      const auto success = [](const ConversionResult& r) -> bool {
  402|    126|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    126|          return r != 0;
  404|    126|        } else {
  405|    126|          return r.error == simdutf::error_code::SUCCESS;
  406|    126|        }
  407|    126|      }(implret1);
  408|    126|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    126|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    126|        const ToType canary2{25};
  414|    126|        const auto outputbuffer_first_run = outputbuffer;
  415|    126|        std::ranges::fill(outputbuffer, canary2);
  416|    126|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    126|                                          src.size(), outputbuffer.data());
  418|       |
  419|    126|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 126]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    126|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 126, False: 0]
  |  Branch (423:29): [True: 120, False: 6]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    120|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    120|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 120]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    120|        }
  440|    126|      }
  441|    126|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 120, False: 6]
  ------------------
  442|    126|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|     42|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 0, False: 42]
  ------------------
  447|      0|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 0, False: 0]
  ------------------
  448|      0|        e.outputhash.clear();
  449|      0|      }
  450|      0|    }
  451|       |
  452|     42|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|     42|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 42]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|     42|    } else {
  474|     42|      ret.implementations_agree = true;
  475|     42|    }
  476|     42|    return ret;
  477|     42|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    126|      const auto success = [](const ConversionResult& r) -> bool {
  402|    126|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    126|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    126|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings4ELS0_0EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|     84|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_40clENSt3__14spanIKcLm18446744073709551615EEE:
  554|     49|    +[](std::span<const char> chardata) {                                      \
  555|     49|      const auto c =                                                           \
  556|     49|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|     49|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|     49|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|     49|              &I::lenfunc, &I::conversionfunc,                                 \
  560|     49|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|     49|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     49|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     49|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     49|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     49|  constexpr auto _size = _name.size();                                \
  |  | 1183|     49|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     49|  return _nameof; }()
  ------------------
  561|     49|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|     49|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|     49|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|     49|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|     49|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|     49|  constexpr auto _size = _name.size();                                \
  |  | 1183|     49|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|     49|  return _nameof; }()
  ------------------
  562|     49|      c.fuzz(chardata);                                                        \
  563|     49|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE4fuzzENSt3__14spanIS5_Lm18446744073709551615EEE:
  175|     49|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|     49|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|     49|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|     49|    static const bool do_print_testcase =
  181|     49|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|     49|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 49]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|     49|    do {
  189|       |      // step 0 - is the input valid?
  190|     49|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|     49|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 49]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|       |                    From == UtfEncodings::UTF8) {
  198|       |        if (!count_the_input(from) && !allow_implementations_to_differ)
  199|       |          break;
  200|       |      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|     49|      const auto [output_length, length_agree] =
  204|     49|          calculate_length(from, inputisvalid);
  205|     49|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 49]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|     49|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 0, False: 49]
  |  Branch (208:28): [True: 0, False: 0]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|     49|      const auto [written, outputs_agree] =
  215|     49|          do_conversion(from, output_length, inputisvalid);
  216|     49|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 49]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|     49|      return;
  221|     49|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|     49|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE18verify_valid_inputIvQeqT_LS0_4EEENSA_17validation_resultENSt3__14spanIS5_Lm18446744073709551615EEE:
  283|     49|  validation_result verify_valid_input(FromSpan) const {
  284|       |    // all latin1 input is valid. there is no simdutf validation function for
  285|       |    // it.
  286|     49|    return validation_result{.valid = true, .implementations_agree = true};
  287|     49|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEb:
  342|     49|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|     49|    length_result ret{};
  344|       |
  345|     49|    const auto implementations = get_supported_implementations();
  346|     49|    std::vector<std::size_t> results;
  347|     49|    results.reserve(implementations.size());
  348|       |
  349|    147|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 147, False: 49]
  ------------------
  350|    147|      const auto len = invoke_lengthcalc(impl, src);
  351|    147|      results.push_back(len);
  352|    147|      ret.length.push_back(len);
  353|    147|    }
  354|       |
  355|     49|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|     49|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 49]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|     49|    } else {
  375|     49|      ret.implementations_agree = true;
  376|     49|    }
  377|     49|    return ret;
  378|     49|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_mEEEmSE_NSt3__14spanIS5_Lm18446744073709551615EEE:
  338|    147|                                FromSpan src) const {
  339|    147|    return std::invoke(lengthcalc, impl, /*src.data(),*/ src.size());
  340|    147|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE16calculate_lengthENSt3__14spanIS5_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|     98|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|     49|                                  const bool inputisvalid) const {
  383|     49|    conversion_result ret{};
  384|       |
  385|     49|    const auto implementations = get_supported_implementations();
  386|       |
  387|     49|    std::vector<result<ConversionResult>> results;
  388|     49|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|     49|    std::vector<std::vector<ToType>> outputbuffers;
  393|     49|    outputbuffers.reserve(implementations.size());
  394|    196|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 147, False: 49]
  ------------------
  395|    147|      auto impl = implementations[i];
  396|    147|      const ToType canary1{42};
  397|    147|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    147|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    147|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    147|      const auto success = [](const ConversionResult& r) -> bool {
  402|    147|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    147|          return r != 0;
  404|    147|        } else {
  405|    147|          return r.error == simdutf::error_code::SUCCESS;
  406|    147|        }
  407|    147|      }(implret1);
  408|    147|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    147|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    147|        const ToType canary2{25};
  414|    147|        const auto outputbuffer_first_run = outputbuffer;
  415|    147|        std::ranges::fill(outputbuffer, canary2);
  416|    147|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    147|                                          src.size(), outputbuffer.data());
  418|       |
  419|    147|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 147]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    147|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 147, False: 0]
  |  Branch (423:29): [True: 141, False: 6]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    141|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    141|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 141]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    141|        }
  440|    147|      }
  441|    147|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 141, False: 6]
  ------------------
  442|    147|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|     49|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 0, False: 49]
  ------------------
  447|      0|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 0, False: 0]
  ------------------
  448|      0|        e.outputhash.clear();
  449|      0|      }
  450|      0|    }
  451|       |
  452|     49|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|     49|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 49]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|     49|    } else {
  474|     49|      ret.implementations_agree = true;
  475|     49|    }
  476|     49|    return ret;
  477|     49|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    147|      const auto success = [](const ConversionResult& r) -> bool {
  402|    147|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    147|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    147|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings4ELS0_1EMN7simdutf14implementationEKDoFmmEMS2_KDoFmPKcmPDsEE13do_conversionENSt3__14spanIS5_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|     98|    auto neq = [](const auto& a, const auto& b) { return a != b; };
conversion.cpp:_ZZ18populate_functionsvENK4$_41clENSt3__14spanIKcLm18446744073709551615EEE:
  554|    300|    +[](std::span<const char> chardata) {                                      \
  555|    300|      const auto c =                                                           \
  556|    300|          Conversion<ENCODING_FROM_CONVERSION_NAME(&I::conversionfunc),        \
  557|    300|                     ENCODING_TO_CONVERSION_NAME(&I::conversionfunc),          \
  558|    300|                     decltype(&I::lenfunc), decltype(&I::conversionfunc)>{     \
  559|    300|              &I::lenfunc, &I::conversionfunc,                                 \
  560|    300|              std::string{NAMEOF(&I::lenfunc)},                                \
  ------------------
  |  | 1178|    300|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    300|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    300|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    300|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    300|  constexpr auto _size = _name.size();                                \
  |  | 1183|    300|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    300|  return _nameof; }()
  ------------------
  561|    300|              std::string{NAMEOF(&I::conversionfunc)}};                        \
  ------------------
  |  | 1178|    300|#define NAMEOF(...) []() constexpr noexcept {                         \
  |  | 1179|    300|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
  |  | 1180|    300|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
  |  | 1181|    300|  static_assert(!_name.empty(), "Expression does not have a name.");  \
  |  | 1182|    300|  constexpr auto _size = _name.size();                                \
  |  | 1183|    300|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
  |  | 1184|    300|  return _nameof; }()
  ------------------
  562|    300|      c.fuzz(chardata);                                                        \
  563|    300|    }                                                                          \
_ZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE4fuzzENSt3__14spanIS3_Lm18446744073709551615EEE:
  175|    300|  void fuzz(std::span<const char> chardata) const {
  176|       |    // assume the input is aligned to FromType
  177|    300|    const FromSpan from{reinterpret_cast<const FromType*>(chardata.data()),
  178|    300|                        chardata.size() / sizeof(FromType)};
  179|       |
  180|    300|    static const bool do_print_testcase =
  181|    300|        std::getenv("PRINT_FUZZ_CASE") != nullptr;
  182|       |
  183|    300|    if (do_print_testcase) {
  ------------------
  |  Branch (183:9): [True: 0, False: 300]
  ------------------
  184|      0|      dump_testcase(from, std::cerr);
  185|      0|      std::exit(EXIT_SUCCESS);
  186|      0|    }
  187|       |
  188|    300|    do {
  189|       |      // step 0 - is the input valid?
  190|    300|      const auto [inputisvalid, valid_input_agree] = verify_valid_input(from);
  191|    300|      if (!valid_input_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (191:11): [True: 0, False: 300]
  |  Branch (191:33): [True: 0, Folded]
  ------------------
  192|      0|        break;
  193|       |
  194|       |      // step 1 - count the input (only makes sense for some of the encodings)
  195|       |      if constexpr (From == UtfEncodings::UTF16BE ||
  196|       |                    From == UtfEncodings::UTF16LE ||
  197|       |                    From == UtfEncodings::UTF8) {
  198|       |        if (!count_the_input(from) && !allow_implementations_to_differ)
  199|       |          break;
  200|       |      }
  201|       |
  202|       |      // step 2 - what is the required size of the output?
  203|    300|      const auto [output_length, length_agree] =
  204|    300|          calculate_length(from, inputisvalid);
  205|    300|      if (!length_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (205:11): [True: 0, False: 300]
  |  Branch (205:28): [True: 0, Folded]
  ------------------
  206|      0|        break;
  207|       |
  208|    300|      if (!inputisvalid && name.find("valid") != std::string::npos) {
  ------------------
  |  Branch (208:11): [True: 0, False: 300]
  |  Branch (208:28): [True: 0, False: 0]
  ------------------
  209|       |        // don't run the conversion step, it requires valid input
  210|      0|        return;
  211|      0|      }
  212|       |
  213|       |      // step 3 - run the conversion
  214|    300|      const auto [written, outputs_agree] =
  215|    300|          do_conversion(from, output_length, inputisvalid);
  216|    300|      if (!outputs_agree && !allow_implementations_to_differ)
  ------------------
  |  Branch (216:11): [True: 0, False: 300]
  |  Branch (216:29): [True: 0, Folded]
  ------------------
  217|      0|        break;
  218|       |
  219|       |      // coming this far means no problems were found
  220|    300|      return;
  221|    300|    } while (0);
  ------------------
  |  Branch (221:14): [Folded, False: 0]
  ------------------
  222|       |    // if we come here, something failed
  223|      0|    std::cerr << "something failed, rerun with PRINT_FUZZ_CASE set to print a "
  224|      0|                 "reproducer to stderr\n";
  225|      0|    std::abort();
  226|    300|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE18verify_valid_inputIvQeqT_LS0_4EEENSA_17validation_resultENSt3__14spanIS3_Lm18446744073709551615EEE:
  283|    300|  validation_result verify_valid_input(FromSpan) const {
  284|       |    // all latin1 input is valid. there is no simdutf validation function for
  285|       |    // it.
  286|    300|    return validation_result{.valid = true, .implementations_agree = true};
  287|    300|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEb:
  342|    300|  length_result calculate_length(FromSpan src, const bool inputisvalid) const {
  343|    300|    length_result ret{};
  344|       |
  345|    300|    const auto implementations = get_supported_implementations();
  346|    300|    std::vector<std::size_t> results;
  347|    300|    results.reserve(implementations.size());
  348|       |
  349|    900|    for (auto impl : implementations) {
  ------------------
  |  Branch (349:20): [True: 900, False: 300]
  ------------------
  350|    900|      const auto len = invoke_lengthcalc(impl, src);
  351|    900|      results.push_back(len);
  352|    900|      ret.length.push_back(len);
  353|    900|    }
  354|       |
  355|    300|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  356|    300|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (356:9): [True: 0, False: 300]
  ------------------
  357|      0|      std::cerr << "begin errormessage for calculate_length\n";
  358|      0|      std::cerr << "in fuzz case invoking " << lengthcalcname << " with "
  359|      0|                << src.size() << " elements with valid input=" << inputisvalid
  360|      0|                << ":\n";
  361|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (361:31): [True: 0, False: 0]
  ------------------
  362|      0|        std::cerr << "got return " << std::dec << results[i]
  363|      0|                  << " from implementation " << implementations[i]->name()
  364|      0|                  << '\n';
  365|      0|      }
  366|      0|      std::cerr << "end errormessage\n";
  367|      0|      if (inputisvalid) {
  ------------------
  |  Branch (367:11): [True: 0, False: 0]
  ------------------
  368|      0|        ret.implementations_agree = false;
  369|      0|      } else {
  370|      0|        std::cerr
  371|      0|            << "implementations are allowed to disagree on invalid input\n";
  372|      0|        ret.implementations_agree = true;
  373|      0|      }
  374|    300|    } else {
  375|    300|      ret.implementations_agree = true;
  376|    300|    }
  377|    300|    return ret;
  378|    300|  }
_ZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE17invoke_lengthcalcIvQsr3stdE14is_invocable_vIT1_PKS2_PKN23ValidationFunctionTraitIXT_EE7RawTypeEmEEEmSE_NSt3__14spanIS3_Lm18446744073709551615EEE:
  330|    900|                                FromSpan src) const {
  331|    900|    return std::invoke(lengthcalc, impl, src.data(), src.size());
  332|    900|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE16calculate_lengthENSt3__14spanIS3_Lm18446744073709551615EEEbENKUlRKT_RKT0_E_clImmEEDaSG_SJ_:
  355|    600|    auto neq = [](const auto& a, const auto& b) { return a != b; };
_ZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEb:
  382|    300|                                  const bool inputisvalid) const {
  383|    300|    conversion_result ret{};
  384|       |
  385|    300|    const auto implementations = get_supported_implementations();
  386|       |
  387|    300|    std::vector<result<ConversionResult>> results;
  388|    300|    results.reserve(implementations.size());
  389|       |
  390|       |    // put the output in a separate allocation to make access violations easier
  391|       |    // to catch
  392|    300|    std::vector<std::vector<ToType>> outputbuffers;
  393|    300|    outputbuffers.reserve(implementations.size());
  394|  1.20k|    for (std::size_t i = 0; i < implementations.size(); ++i) {
  ------------------
  |  Branch (394:29): [True: 900, False: 300]
  ------------------
  395|    900|      auto impl = implementations[i];
  396|    900|      const ToType canary1{42};
  397|    900|      auto& outputbuffer = outputbuffers.emplace_back(outlength.at(i), canary1);
  398|    900|      const auto implret1 = std::invoke(conversion, impl, src.data(),
  399|    900|                                        src.size(), outputbuffer.data());
  400|       |      // was the conversion successful?
  401|    900|      const auto success = [](const ConversionResult& r) -> bool {
  402|    900|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    900|          return r != 0;
  404|    900|        } else {
  405|    900|          return r.error == simdutf::error_code::SUCCESS;
  406|    900|        }
  407|    900|      }(implret1);
  408|    900|      const auto hash1 = FNV1A_hash::as_str(outputbuffer);
  409|    900|      if constexpr (use_canary_in_output) {
  410|       |        // optionally convert again, this time with the buffer filled with
  411|       |        // a different value. if the output differs, it means some of the buffer
  412|       |        // was not written to by the conversion function.
  413|    900|        const ToType canary2{25};
  414|    900|        const auto outputbuffer_first_run = outputbuffer;
  415|    900|        std::ranges::fill(outputbuffer, canary2);
  416|    900|        const auto implret2 = std::invoke(conversion, impl, src.data(),
  417|    900|                                          src.size(), outputbuffer.data());
  418|       |
  419|    900|        if (implret1 != implret2) {
  ------------------
  |  Branch (419:13): [True: 0, False: 900]
  ------------------
  420|      0|          std::cerr << "different return value the second time!\n";
  421|      0|          std::abort();
  422|      0|        }
  423|    900|        if (inputisvalid && success) {
  ------------------
  |  Branch (423:13): [True: 900, False: 0]
  |  Branch (423:29): [True: 894, False: 6]
  ------------------
  424|       |          // only care about the output if the input is valid
  425|    894|          const auto hash2 = FNV1A_hash::as_str(outputbuffer);
  426|    894|          if (hash1 != hash2) {
  ------------------
  |  Branch (426:15): [True: 0, False: 894]
  ------------------
  427|      0|            std::cerr << "different output the second time!\n";
  428|      0|            std::cerr << "implementation " << impl->name() << " " << name
  429|      0|                      << '\n';
  430|      0|            std::cerr << "input is valid=" << inputisvalid << '\n';
  431|      0|            std::cerr << "output length=" << outputbuffer.size() << '\n';
  432|      0|            std::cerr << "conversion was a success? " << success << '\n';
  433|      0|            for (std::size_t j = 0; j < outputbuffer.size(); ++j) {
  ------------------
  |  Branch (433:37): [True: 0, False: 0]
  ------------------
  434|      0|              std::cerr << "output[" << j << "]\t" << +outputbuffer_first_run[j]
  435|      0|                        << '\t' << +outputbuffer[j] << '\n';
  436|      0|            }
  437|      0|            std::abort();
  438|      0|          }
  439|    894|        }
  440|    900|      }
  441|    900|      results.emplace_back(implret1, success ? hash1 : "");
  ------------------
  |  Branch (441:38): [True: 894, False: 6]
  ------------------
  442|    900|    }
  443|       |
  444|       |    // do not require implementations to give the same output if
  445|       |    // the input is not valid.
  446|    300|    if (!inputisvalid) {
  ------------------
  |  Branch (446:9): [True: 0, False: 300]
  ------------------
  447|      0|      for (auto& e : results) {
  ------------------
  |  Branch (447:20): [True: 0, False: 0]
  ------------------
  448|      0|        e.outputhash.clear();
  449|      0|      }
  450|      0|    }
  451|       |
  452|    300|    auto neq = [](const auto& a, const auto& b) { return a != b; };
  453|    300|    if (std::ranges::adjacent_find(results, neq) != results.end()) {
  ------------------
  |  Branch (453:9): [True: 0, False: 300]
  ------------------
  454|      0|      std::cerr << "begin errormessage for do_conversion\n";
  455|      0|      std::cerr << "in fuzz case for " << name << " invoked with " << src.size()
  456|      0|                << " elements:\n";
  457|      0|      std::cerr << "input data is valid ? " << inputisvalid << '\n';
  458|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (458:31): [True: 0, False: 0]
  ------------------
  459|      0|        std::cerr << "got return " << std::dec << results[i]
  460|      0|                  << " from implementation " << implementations[i]->name()
  461|      0|                  << " using outlen=" << outlength.at(i) << '\n';
  462|      0|      }
  463|      0|      for (std::size_t i = 0; i < results.size(); ++i) {
  ------------------
  |  Branch (463:31): [True: 0, False: 0]
  ------------------
  464|      0|        std::cerr << "implementation " << implementations[i]->name()
  465|      0|                  << " out: ";
  466|      0|        for (const auto e : outputbuffers.at(i)) {
  ------------------
  |  Branch (466:27): [True: 0, False: 0]
  ------------------
  467|      0|          std::cerr << +e << ", ";
  468|      0|        }
  469|      0|        std::cerr << '\n';
  470|      0|      }
  471|      0|      std::cerr << "end errormessage\n";
  472|      0|      ret.implementations_agree = false;
  473|    300|    } else {
  474|    300|      ret.implementations_agree = true;
  475|    300|    }
  476|    300|    return ret;
  477|    300|  }
_ZZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKmE_clESL_:
  401|    900|      const auto success = [](const ConversionResult& r) -> bool {
  402|    900|        if constexpr (std::is_same_v<ConversionResult, std::size_t>) {
  403|    900|          return r != 0;
  404|       |        } else {
  405|       |          return r.error == simdutf::error_code::SUCCESS;
  406|       |        }
  407|    900|      }(implret1);
_ZZNK10ConversionIL12UtfEncodings4ELS0_2EMN7simdutf14implementationEKDoFmPKcmEMS2_KDoFmS4_mPcEE13do_conversionENSt3__14spanIS3_Lm18446744073709551615EEERKNSB_6vectorImNSB_9allocatorImEEEEbENKUlRKT_RKT0_E_clI6resultImEST_EEDaSM_SP_:
  452|    600|    auto neq = [](const auto& a, const auto& b) { return a != b; };

_ZN10FNV1A_hash14fnv1ahash_implENSt3__14spanIKcLm18446744073709551615EEE:
   75|  16.9k|  static constexpr std::uint64_t fnv1ahash_impl(std::span<const char> bytes) {
   76|  16.9k|    auto hash = offset;
   77|       |
   78|   613M|    for (auto byte : bytes) {
  ------------------
  |  Branch (78:20): [True: 613M, False: 16.9k]
  ------------------
   79|   613M|      hash ^= static_cast<unsigned char>(byte);
   80|   613M|      hash *= prime;
   81|   613M|    }
   82|       |
   83|  16.9k|    return hash;
   84|  16.9k|  }
_ZN10FNV1A_hash14fnv1ahash_implIKDsLm18446744073709551615EQaaaa11is_hashableIT_Entsr3stdE9is_same_vIS2_cEntsr3stdE9is_same_vIS2_hEEEmNSt3__14spanIS2_XT0_EEE:
   89|  16.4k|  static constexpr std::uint64_t fnv1ahash_impl(std::span<Basic, N> data) {
   90|  16.4k|    return fnv1ahash_impl({reinterpret_cast<const unsigned char*>(data.data()),
   91|  16.4k|                           data.size_bytes()});
   92|  16.4k|  }
_ZN10FNV1A_hash14fnv1ahash_implENSt3__14spanIKhLm18446744073709551615EEE:
   65|  25.8k|  fnv1ahash_impl(std::span<const unsigned char> bytes) {
   66|  25.8k|    auto hash = offset;
   67|       |
   68|  2.94G|    for (std::uint64_t byte : bytes) {
  ------------------
  |  Branch (68:29): [True: 2.94G, False: 25.8k]
  ------------------
   69|  2.94G|      hash ^= byte;
   70|  2.94G|      hash *= prime;
   71|  2.94G|    }
   72|       |
   73|  25.8k|    return hash;
   74|  25.8k|  }
_Z29get_supported_implementationsv:
   26|  35.3k|get_supported_implementations() {
   27|  35.3k|  static const auto impl = []() -> auto {
   28|  35.3k|    std::vector<const simdutf::implementation*> ret;
   29|  35.3k|    for (auto e : simdutf::get_available_implementations()) {
   30|  35.3k|      std::cerr << "implementation " << e->name() << " is available? "
   31|  35.3k|                << e->supported_by_runtime_system() << '\n';
   32|  35.3k|      if (e->supported_by_runtime_system()) {
   33|  35.3k|        ret.push_back(e);
   34|  35.3k|      }
   35|  35.3k|    }
   36|  35.3k|    return ret;
   37|  35.3k|  }();
   38|  35.3k|  return {impl.data(), impl.size()};
   39|  35.3k|}
_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|  30.5k|inline bool operator!=(const simdutf::result& a, const simdutf::result& b) {
   43|  30.5k|  return a.count != b.count || a.error != b.error;
  ------------------
  |  Branch (43:10): [True: 0, False: 30.5k]
  |  Branch (43:32): [True: 0, False: 30.5k]
  ------------------
   44|  30.5k|}
_ZN10FNV1A_hash6as_strIJNSt3__16vectorIDiNS1_9allocatorIDiEEEEEEENS1_12basic_stringIcNS1_11char_traitsIcEENS3_IcEEEEDpRKT_:
  100|  9.30k|  template <typename... Data> static std::string as_str(const Data&... data) {
  101|  9.30k|    static_assert(sizeof...(Data) > 0, "must hash with at least one argument");
  102|  9.30k|    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|  9.30k|    } else {
  108|  9.30k|      h = fnv1ahash_impl(data...);
  109|  9.30k|    }
  110|  9.30k|    constexpr std::size_t expected_chars = 16;
  111|  9.30k|    std::string ret(expected_chars, '0');
  112|  9.30k|    auto c = std::to_chars(ret.data(), ret.data() + ret.size(), h, 16);
  113|  9.30k|    assert(c.ec == std::errc{});
  ------------------
  |  Branch (113:5): [True: 9.30k, False: 0]
  ------------------
  114|  9.30k|    auto nwritten = c.ptr - ret.data();
  115|  9.30k|    assert(nwritten <= expected_chars);
  ------------------
  |  Branch (115:5): [True: 9.30k, False: 0]
  ------------------
  116|  9.30k|    std::rotate(ret.data(), c.ptr, ret.data() + expected_chars);
  117|  9.30k|    return ret;
  118|  9.30k|  }
_ZN10FNV1A_hash14fnv1ahash_implIDiQ11is_hashableIT_EEEmRKNSt3__16vectorIS1_NS2_9allocatorIS1_EEEE:
   96|  9.30k|  static constexpr std::uint64_t fnv1ahash_impl(const std::vector<Data>& data) {
   97|  9.30k|    return fnv1ahash_impl(std::span(data));
   98|  9.30k|  }
_ZN10FNV1A_hash14fnv1ahash_implIKDiLm18446744073709551615EQaaaa11is_hashableIT_Entsr3stdE9is_same_vIS2_cEntsr3stdE9is_same_vIS2_hEEEmNSt3__14spanIS2_XT0_EEE:
   89|  9.30k|  static constexpr std::uint64_t fnv1ahash_impl(std::span<Basic, N> data) {
   90|  9.30k|    return fnv1ahash_impl({reinterpret_cast<const unsigned char*>(data.data()),
   91|  9.30k|                           data.size_bytes()});
   92|  9.30k|  }
_ZN10FNV1A_hash6as_strIJNSt3__16vectorIcNS1_9allocatorIcEEEEEEENS1_12basic_stringIcNS1_11char_traitsIcEES4_EEDpRKT_:
  100|  16.9k|  template <typename... Data> static std::string as_str(const Data&... data) {
  101|  16.9k|    static_assert(sizeof...(Data) > 0, "must hash with at least one argument");
  102|  16.9k|    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|  16.9k|    } else {
  108|  16.9k|      h = fnv1ahash_impl(data...);
  109|  16.9k|    }
  110|  16.9k|    constexpr std::size_t expected_chars = 16;
  111|  16.9k|    std::string ret(expected_chars, '0');
  112|  16.9k|    auto c = std::to_chars(ret.data(), ret.data() + ret.size(), h, 16);
  113|  16.9k|    assert(c.ec == std::errc{});
  ------------------
  |  Branch (113:5): [True: 16.9k, False: 0]
  ------------------
  114|  16.9k|    auto nwritten = c.ptr - ret.data();
  115|  16.9k|    assert(nwritten <= expected_chars);
  ------------------
  |  Branch (115:5): [True: 16.9k, False: 0]
  ------------------
  116|  16.9k|    std::rotate(ret.data(), c.ptr, ret.data() + expected_chars);
  117|  16.9k|    return ret;
  118|  16.9k|  }
_ZN10FNV1A_hash14fnv1ahash_implIcQ11is_hashableIT_EEEmRKNSt3__16vectorIS1_NS2_9allocatorIS1_EEEE:
   96|  16.9k|  static constexpr std::uint64_t fnv1ahash_impl(const std::vector<Data>& data) {
   97|  16.9k|    return fnv1ahash_impl(std::span(data));
   98|  16.9k|  }
_ZN10FNV1A_hash6as_strIJNSt3__16vectorIDsNS1_9allocatorIDsEEEEEEENS1_12basic_stringIcNS1_11char_traitsIcEENS3_IcEEEEDpRKT_:
  100|  16.4k|  template <typename... Data> static std::string as_str(const Data&... data) {
  101|  16.4k|    static_assert(sizeof...(Data) > 0, "must hash with at least one argument");
  102|  16.4k|    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|  16.4k|    } else {
  108|  16.4k|      h = fnv1ahash_impl(data...);
  109|  16.4k|    }
  110|  16.4k|    constexpr std::size_t expected_chars = 16;
  111|  16.4k|    std::string ret(expected_chars, '0');
  112|  16.4k|    auto c = std::to_chars(ret.data(), ret.data() + ret.size(), h, 16);
  113|  16.4k|    assert(c.ec == std::errc{});
  ------------------
  |  Branch (113:5): [True: 16.4k, False: 0]
  ------------------
  114|  16.4k|    auto nwritten = c.ptr - ret.data();
  115|  16.4k|    assert(nwritten <= expected_chars);
  ------------------
  |  Branch (115:5): [True: 16.4k, False: 0]
  ------------------
  116|  16.4k|    std::rotate(ret.data(), c.ptr, ret.data() + expected_chars);
  117|  16.4k|    return ret;
  118|  16.4k|  }
_ZN10FNV1A_hash14fnv1ahash_implIDsQ11is_hashableIT_EEEmRKNSt3__16vectorIS1_NS2_9allocatorIS1_EEEE:
   96|  16.4k|  static constexpr std::uint64_t fnv1ahash_impl(const std::vector<Data>& data) {
   97|  16.4k|    return fnv1ahash_impl(std::span(data));
   98|  16.4k|  }
_ZeqRKN7simdutf6resultES2_:
   45|  8.09k|inline bool operator==(const simdutf::result& a, const simdutf::result& b) {
   46|  8.09k|  return a.count == b.count && a.error == b.error;
  ------------------
  |  Branch (46:10): [True: 8.09k, False: 0]
  |  Branch (46:32): [True: 8.09k, False: 0]
  ------------------
   47|  8.09k|}

_ZNK23ValidationFunctionTraitIL12UtfEncodings0EE24ValidationWithErrorsNameMUlvE_clEv:
 1178|      2|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|      2|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|      2|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|      2|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|      2|  constexpr auto _size = _name.size();                                \
 1183|      2|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|      2|  return _nameof; }()
_ZNK6nameof7cstringILt28EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|      4|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt28EE4dataEv:
  233|      4|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt28EE4sizeEv:
  235|      4|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
_ZNK23ValidationFunctionTraitIL12UtfEncodings1EE24ValidationWithErrorsNameMUlvE_clEv:
 1178|      2|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|      2|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|      2|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|      2|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|      2|  constexpr auto _size = _name.size();                                \
 1183|      2|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|      2|  return _nameof; }()
_ZNK23ValidationFunctionTraitIL12UtfEncodings3EE24ValidationWithErrorsNameMUlvE_clEv:
 1178|      2|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|      2|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|      2|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|      2|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|      2|  constexpr auto _size = _name.size();                                \
 1183|      2|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|      2|  return _nameof; }()
_ZNK6nameof7cstringILt26EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|      2|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt26EE4dataEv:
  233|      2|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt26EE4sizeEv:
  235|      2|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
_ZNK23ValidationFunctionTraitIL12UtfEncodings2EE24ValidationWithErrorsNameMUlvE_clEv:
 1178|      2|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|      2|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|      2|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|      2|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|      2|  constexpr auto _size = _name.size();                                \
 1183|      2|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|      2|  return _nameof; }()
_ZNK6nameof7cstringILt25EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|  1.02k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt25EE4dataEv:
  233|  1.02k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt25EE4sizeEv:
  235|  1.02k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_0clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     99|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     99|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     99|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     99|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     99|  constexpr auto _size = _name.size();                                \
 1183|     99|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     99|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_0clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     99|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     99|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     99|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     99|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     99|  constexpr auto _size = _name.size();                                \
 1183|     99|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     99|  return _nameof; }()
_ZNK6nameof7cstringILt30EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    316|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt30EE4dataEv:
  233|    316|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt30EE4sizeEv:
  235|    316|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_1clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    232|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    232|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    232|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    232|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    232|  constexpr auto _size = _name.size();                                \
 1183|    232|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    232|  return _nameof; }()
_ZNK6nameof7cstringILt24EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|  2.80k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt24EE4dataEv:
  233|  2.80k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt24EE4sizeEv:
  235|  2.80k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_1clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    232|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    232|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    232|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    232|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    232|  constexpr auto _size = _name.size();                                \
 1183|    232|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    232|  return _nameof; }()
_ZNK6nameof7cstringILt29EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|  1.12k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt29EE4dataEv:
  233|  1.12k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt29EE4sizeEv:
  235|  1.12k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_2clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     60|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     60|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     60|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     60|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     60|  constexpr auto _size = _name.size();                                \
 1183|     60|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     60|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_2clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     60|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     60|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     60|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     60|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     60|  constexpr auto _size = _name.size();                                \
 1183|     60|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     60|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_3clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    219|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    219|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    219|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    219|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    219|  constexpr auto _size = _name.size();                                \
 1183|    219|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    219|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_3clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    219|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    219|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    219|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    219|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    219|  constexpr auto _size = _name.size();                                \
 1183|    219|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    219|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_4clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     37|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     37|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     37|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     37|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     37|  constexpr auto _size = _name.size();                                \
 1183|     37|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     37|  return _nameof; }()
_ZNK6nameof7cstringILt23EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|  3.61k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt23EE4dataEv:
  233|  3.61k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt23EE4sizeEv:
  235|  3.61k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_4clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     37|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     37|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     37|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     37|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     37|  constexpr auto _size = _name.size();                                \
 1183|     37|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     37|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_5clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    120|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    120|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    120|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    120|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    120|  constexpr auto _size = _name.size();                                \
 1183|    120|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    120|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_5clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    120|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    120|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    120|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    120|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    120|  constexpr auto _size = _name.size();                                \
 1183|    120|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    120|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_6clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    108|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    108|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    108|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    108|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    108|  constexpr auto _size = _name.size();                                \
 1183|    108|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    108|  return _nameof; }()
_ZNK6nameof7cstringILt22EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|  5.15k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt22EE4dataEv:
  233|  5.15k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt22EE4sizeEv:
  235|  5.15k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_6clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    108|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    108|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    108|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    108|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    108|  constexpr auto _size = _name.size();                                \
 1183|    108|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    108|  return _nameof; }()
_ZNK6nameof7cstringILt27EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    426|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt27EE4dataEv:
  233|    426|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt27EE4sizeEv:
  235|    426|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK3$_7clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    399|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    399|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    399|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    399|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    399|  constexpr auto _size = _name.size();                                \
 1183|    399|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    399|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_7clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    399|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    399|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    399|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    399|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    399|  constexpr auto _size = _name.size();                                \
 1183|    399|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    399|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_8clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    275|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    275|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    275|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    275|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    275|  constexpr auto _size = _name.size();                                \
 1183|    275|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    275|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_8clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    275|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    275|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    275|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    275|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    275|  constexpr auto _size = _name.size();                                \
 1183|    275|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    275|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_9clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    318|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    318|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    318|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    318|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    318|  constexpr auto _size = _name.size();                                \
 1183|    318|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    318|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK3$_9clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    318|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    318|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    318|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    318|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    318|  constexpr auto _size = _name.size();                                \
 1183|    318|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    318|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_10clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     63|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     63|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     63|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     63|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     63|  constexpr auto _size = _name.size();                                \
 1183|     63|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     63|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_10clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     63|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     63|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     63|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     63|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     63|  constexpr auto _size = _name.size();                                \
 1183|     63|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     63|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_11clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    126|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    126|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    126|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    126|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    126|  constexpr auto _size = _name.size();                                \
 1183|    126|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    126|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_11clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    126|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    126|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    126|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    126|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    126|  constexpr auto _size = _name.size();                                \
 1183|    126|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    126|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_12clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    155|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    155|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    155|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    155|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    155|  constexpr auto _size = _name.size();                                \
 1183|    155|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    155|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_12clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    155|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    155|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    155|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    155|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    155|  constexpr auto _size = _name.size();                                \
 1183|    155|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    155|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_13clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     55|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     55|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     55|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     55|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     55|  constexpr auto _size = _name.size();                                \
 1183|     55|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     55|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_13clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     55|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     55|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     55|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     55|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     55|  constexpr auto _size = _name.size();                                \
 1183|     55|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     55|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_14clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    136|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    136|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    136|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    136|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    136|  constexpr auto _size = _name.size();                                \
 1183|    136|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    136|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_14clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    136|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    136|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    136|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    136|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    136|  constexpr auto _size = _name.size();                                \
 1183|    136|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    136|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_15clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    196|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    196|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    196|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    196|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    196|  constexpr auto _size = _name.size();                                \
 1183|    196|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    196|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_15clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    196|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    196|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    196|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    196|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    196|  constexpr auto _size = _name.size();                                \
 1183|    196|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    196|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_16clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     95|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     95|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     95|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     95|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     95|  constexpr auto _size = _name.size();                                \
 1183|     95|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     95|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_16clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     95|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     95|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     95|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     95|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     95|  constexpr auto _size = _name.size();                                \
 1183|     95|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     95|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_17clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    195|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    195|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    195|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    195|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    195|  constexpr auto _size = _name.size();                                \
 1183|    195|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    195|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_17clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    195|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    195|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    195|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    195|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    195|  constexpr auto _size = _name.size();                                \
 1183|    195|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    195|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_18clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    211|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    211|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    211|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    211|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    211|  constexpr auto _size = _name.size();                                \
 1183|    211|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    211|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_18clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    211|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    211|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    211|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    211|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    211|  constexpr auto _size = _name.size();                                \
 1183|    211|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    211|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_19clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    292|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    292|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    292|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    292|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    292|  constexpr auto _size = _name.size();                                \
 1183|    292|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    292|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_19clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    292|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    292|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    292|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    292|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    292|  constexpr auto _size = _name.size();                                \
 1183|    292|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    292|  return _nameof; }()
_ZNK6nameof7cstringILt21EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    752|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt21EE4dataEv:
  233|    752|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt21EE4sizeEv:
  235|    752|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_20clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    331|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    331|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    331|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    331|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    331|  constexpr auto _size = _name.size();                                \
 1183|    331|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    331|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_20clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    331|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    331|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    331|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    331|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    331|  constexpr auto _size = _name.size();                                \
 1183|    331|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    331|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_21clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    480|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    480|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    480|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    480|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    480|  constexpr auto _size = _name.size();                                \
 1183|    480|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    480|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_21clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    480|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    480|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    480|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    480|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    480|  constexpr auto _size = _name.size();                                \
 1183|    480|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    480|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_22clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    492|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    492|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    492|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    492|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    492|  constexpr auto _size = _name.size();                                \
 1183|    492|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    492|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_22clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    492|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    492|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    492|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    492|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    492|  constexpr auto _size = _name.size();                                \
 1183|    492|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    492|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_23clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    460|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    460|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    460|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    460|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    460|  constexpr auto _size = _name.size();                                \
 1183|    460|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    460|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_23clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    460|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    460|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    460|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    460|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    460|  constexpr auto _size = _name.size();                                \
 1183|    460|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    460|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_24clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    131|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    131|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    131|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    131|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    131|  constexpr auto _size = _name.size();                                \
 1183|    131|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    131|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_24clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    131|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    131|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    131|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    131|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    131|  constexpr auto _size = _name.size();                                \
 1183|    131|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    131|  return _nameof; }()
_ZNK6nameof7cstringILt37EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    236|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt37EE4dataEv:
  233|    236|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt37EE4sizeEv:
  235|    236|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_25clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    190|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    190|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    190|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    190|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    190|  constexpr auto _size = _name.size();                                \
 1183|    190|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    190|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_25clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    190|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    190|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    190|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    190|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    190|  constexpr auto _size = _name.size();                                \
 1183|    190|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    190|  return _nameof; }()
_ZNK6nameof7cstringILt36EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    984|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt36EE4dataEv:
  233|    984|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt36EE4sizeEv:
  235|    984|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_26clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    270|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    270|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    270|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    270|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    270|  constexpr auto _size = _name.size();                                \
 1183|    270|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    270|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_26clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    270|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    270|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    270|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    270|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    270|  constexpr auto _size = _name.size();                                \
 1183|    270|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    270|  return _nameof; }()
_ZNK6nameof7cstringILt35EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|  1.59k|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt35EE4dataEv:
  233|  1.59k|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt35EE4sizeEv:
  235|  1.59k|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_27clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    105|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    105|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    105|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    105|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    105|  constexpr auto _size = _name.size();                                \
 1183|    105|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    105|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_27clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    105|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    105|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    105|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    105|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    105|  constexpr auto _size = _name.size();                                \
 1183|    105|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    105|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_28clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    198|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    198|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    198|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    198|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    198|  constexpr auto _size = _name.size();                                \
 1183|    198|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    198|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_28clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    198|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    198|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    198|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    198|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    198|  constexpr auto _size = _name.size();                                \
 1183|    198|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    198|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_29clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    314|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    314|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    314|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    314|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    314|  constexpr auto _size = _name.size();                                \
 1183|    314|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    314|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_29clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    314|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    314|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    314|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    314|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    314|  constexpr auto _size = _name.size();                                \
 1183|    314|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    314|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_30clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    172|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    172|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    172|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    172|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    172|  constexpr auto _size = _name.size();                                \
 1183|    172|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    172|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_30clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    172|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    172|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    172|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    172|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    172|  constexpr auto _size = _name.size();                                \
 1183|    172|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    172|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_31clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    285|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    285|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    285|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    285|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    285|  constexpr auto _size = _name.size();                                \
 1183|    285|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    285|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_31clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    285|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    285|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    285|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    285|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    285|  constexpr auto _size = _name.size();                                \
 1183|    285|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    285|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_32clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    311|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    311|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    311|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    311|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    311|  constexpr auto _size = _name.size();                                \
 1183|    311|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    311|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_32clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    311|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    311|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    311|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    311|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    311|  constexpr auto _size = _name.size();                                \
 1183|    311|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    311|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_33clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    386|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    386|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    386|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    386|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    386|  constexpr auto _size = _name.size();                                \
 1183|    386|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    386|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_33clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    386|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    386|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    386|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    386|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    386|  constexpr auto _size = _name.size();                                \
 1183|    386|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    386|  return _nameof; }()
_ZNK6nameof7cstringILt33EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    859|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt33EE4dataEv:
  233|    859|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt33EE4sizeEv:
  235|    859|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_34clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    375|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    375|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    375|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    375|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    375|  constexpr auto _size = _name.size();                                \
 1183|    375|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    375|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_34clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    375|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    375|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    375|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    375|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    375|  constexpr auto _size = _name.size();                                \
 1183|    375|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    375|  return _nameof; }()
_ZNK6nameof7cstringILt34EEcvNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEEv:
  269|    375|  [[nodiscard]] constexpr operator string_view() const noexcept { return {data(), size()}; }
_ZNK6nameof7cstringILt34EE4dataEv:
  233|    375|  [[nodiscard]] constexpr const_pointer data() const noexcept { return chars_; }
_ZNK6nameof7cstringILt34EE4sizeEv:
  235|    375|  [[nodiscard]] constexpr size_type size() const noexcept { return N; }
conversion.cpp:_ZZZ18populate_functionsvENK4$_35clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    442|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    442|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    442|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    442|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    442|  constexpr auto _size = _name.size();                                \
 1183|    442|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    442|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_35clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    442|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    442|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    442|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    442|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    442|  constexpr auto _size = _name.size();                                \
 1183|    442|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    442|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_36clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    395|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    395|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    395|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    395|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    395|  constexpr auto _size = _name.size();                                \
 1183|    395|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    395|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_36clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    395|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    395|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    395|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    395|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    395|  constexpr auto _size = _name.size();                                \
 1183|    395|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    395|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_37clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    473|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    473|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    473|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    473|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    473|  constexpr auto _size = _name.size();                                \
 1183|    473|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    473|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_37clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    473|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    473|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    473|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    473|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    473|  constexpr auto _size = _name.size();                                \
 1183|    473|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    473|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_38clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     35|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     35|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     35|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     35|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     35|  constexpr auto _size = _name.size();                                \
 1183|     35|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     35|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_38clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     35|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     35|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     35|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     35|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     35|  constexpr auto _size = _name.size();                                \
 1183|     35|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     35|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_39clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     42|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     42|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     42|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     42|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     42|  constexpr auto _size = _name.size();                                \
 1183|     42|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     42|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_39clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     42|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     42|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     42|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     42|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     42|  constexpr auto _size = _name.size();                                \
 1183|     42|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     42|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_40clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|     49|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     49|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     49|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     49|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     49|  constexpr auto _size = _name.size();                                \
 1183|     49|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     49|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_40clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|     49|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|     49|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|     49|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|     49|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|     49|  constexpr auto _size = _name.size();                                \
 1183|     49|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|     49|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_41clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE1_clEv:
 1178|    300|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    300|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    300|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    300|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    300|  constexpr auto _size = _name.size();                                \
 1183|    300|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    300|  return _nameof; }()
conversion.cpp:_ZZZ18populate_functionsvENK4$_41clENSt3__14spanIKcLm18446744073709551615EEEENKUlvE2_clEv:
 1178|    300|#define NAMEOF(...) []() constexpr noexcept {                         \
 1179|    300|  ::std::void_t<decltype(__VA_ARGS__)>();                             \
 1180|    300|  constexpr auto _name = ::nameof::detail::pretty_name(#__VA_ARGS__); \
 1181|    300|  static_assert(!_name.empty(), "Expression does not have a name.");  \
 1182|    300|  constexpr auto _size = _name.size();                                \
 1183|    300|  constexpr auto _nameof = ::nameof::cstring<_size>{_name};           \
 1184|    300|  return _nameof; }()

_ZN7simdutf6resultC2ENS_10error_codeEm:
   87|  77.3k|      : error{err}, count{pos} {}
_ZNK7simdutf6result6is_errEv:
   93|  5.41k|  simdutf_really_inline simdutf_constexpr23 bool is_err() const noexcept {
   94|  5.41k|    return error != error_code::SUCCESS;
   95|  5.41k|  }
_ZN7simdutf11full_resultC2ENS_10error_codeEmm:
  111|  5.35k|      : error{err}, input_count{pos_in}, output_count{pos_out} {}
_ZNK7simdutf11full_resultcvNS_6resultEEv:
  117|  3.50k|  simdutf_really_inline simdutf_constexpr23 operator result() const noexcept {
  118|  3.50k|    if (error == error_code::SUCCESS) {
  ------------------
  |  Branch (118:9): [True: 2.13k, False: 1.37k]
  ------------------
  119|  2.13k|      return result{error, output_count};
  120|  2.13k|    } else {
  121|  1.37k|      return result{error, input_count};
  122|  1.37k|    }
  123|  3.50k|  }

_ZNK7simdutf14implementation4nameEv:
 5654|      4|  virtual std::string_view name() const noexcept { return _name; }
_ZNK7simdutf14implementation25required_instruction_setsEv:
 5705|      8|  virtual uint32_t required_instruction_sets() const {
 5706|      8|    return _required_instruction_sets;
 5707|      8|  }
_ZNK7simdutf14implementation24utf16_length_from_latin1Em:
 6920|    273|  utf16_length_from_latin1(size_t length) const noexcept {
 6921|    273|    return length;
 6922|    273|  }
_ZNK7simdutf14implementation24latin1_length_from_utf32Em:
 7108|    801|  latin1_length_from_utf32(size_t length) const noexcept {
 7109|    801|    return length;
 7110|    801|  }
_ZNK7simdutf14implementation24latin1_length_from_utf16Em:
 7148|  1.06k|  latin1_length_from_utf16(size_t length) const noexcept {
 7149|  1.06k|    return length;
 7150|  1.06k|  }
_ZNK7simdutf14implementation24utf32_length_from_latin1Em:
 7181|    105|  utf32_length_from_latin1(size_t length) const noexcept {
 7182|    105|    return length;
 7183|    105|  }
_ZN7simdutf14implementationC2EPKcS2_j:
 7619|      4|      : _name(name), _description(description),
 7620|      4|        _required_instruction_sets(required_instruction_sets) {}
_ZN7simdutf8internal29available_implementation_listC2Ev:
 7651|      1|  simdutf_really_inline available_implementation_list() {}

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_16latin123utf8_length_from_latin1EPKcm:
   10|    694|                                                     size_t len) {
   11|    694|  const uint8_t *c = reinterpret_cast<const uint8_t *>(buf);
   12|    694|  size_t answer = 0;
   13|  5.87k|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (13:22): [True: 5.18k, False: 694]
  ------------------
   14|  5.18k|    if ((c[i] >> 7)) {
  ------------------
  |  Branch (14:9): [True: 1.49k, False: 3.68k]
  ------------------
   15|  1.49k|      answer++;
   16|  1.49k|    }
   17|  5.18k|  }
   18|    694|  return answer + len;
   19|    694|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_115latin1_to_utf167convertILNS_10endiannessE0EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEEmS7_mPDs:
   14|    254|                                   char16_t *utf16_output) {
   15|    254|  size_t pos = 0;
   16|    254|  char16_t *start{utf16_output};
   17|       |
   18|  5.07M|  while (pos < len) {
  ------------------
  |  Branch (18:10): [True: 5.07M, False: 254]
  ------------------
   19|  5.07M|    uint16_t word =
   20|  5.07M|        uint8_t(data[pos]); // extend Latin-1 char to 16-bit Unicode code point
   21|  5.07M|    *utf16_output++ =
   22|  5.07M|        char16_t(match_system(big_endian) ? word : u16_swap_bytes(word));
  ------------------
  |  Branch (22:18): [True: 5.07M, Folded]
  ------------------
   23|  5.07M|    pos++;
   24|  5.07M|  }
   25|       |
   26|    254|  return utf16_output - start;
   27|    254|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_115latin1_to_utf167convertILNS_10endiannessE1EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEEmS7_mPDs:
   14|    192|                                   char16_t *utf16_output) {
   15|    192|  size_t pos = 0;
   16|    192|  char16_t *start{utf16_output};
   17|       |
   18|  1.19M|  while (pos < len) {
  ------------------
  |  Branch (18:10): [True: 1.19M, False: 192]
  ------------------
   19|  1.19M|    uint16_t word =
   20|  1.19M|        uint8_t(data[pos]); // extend Latin-1 char to 16-bit Unicode code point
   21|  1.19M|    *utf16_output++ =
   22|  1.19M|        char16_t(match_system(big_endian) ? word : u16_swap_bytes(word));
  ------------------
  |  Branch (22:18): [Folded, False: 1.19M]
  ------------------
   23|  1.19M|    pos++;
   24|  1.19M|  }
   25|       |
   26|    192|  return utf16_output - start;
   27|    192|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_115latin1_to_utf327convertIPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEEmS6_mPDi:
   14|    162|                                   char32_t *utf32_output) {
   15|    162|  char32_t *start{utf32_output};
   16|  5.02M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (16:22): [True: 5.02M, False: 162]
  ------------------
   17|  5.02M|    *utf32_output++ = uint8_t(data[i]);
   18|  5.02M|  }
   19|    162|  return utf32_output - start;
   20|    162|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114latin1_to_utf87convertEPKcmPc:
   66|  1.67k|                                     char *utf8_output) {
   67|  1.67k|  return convert(reinterpret_cast<const unsigned char *>(buf), len,
   68|  1.67k|                 utf8_output);
   69|  1.67k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114latin1_to_utf87convertIPKhPcQaasr7simdutf6detailE22indexes_into_byte_likeIT_Esr7simdutf6detailE26index_assignable_from_charIT0_EEEmS7_mS8_:
   17|  1.67k|                                   OutputPtr utf8_output) {
   18|       |  // const unsigned char *data = reinterpret_cast<const unsigned char *>(buf);
   19|  1.67k|  size_t pos = 0;
   20|  1.67k|  size_t utf8_pos = 0;
   21|       |
   22|  7.67M|  while (pos < len) {
  ------------------
  |  Branch (22:10): [True: 7.67M, False: 1.67k]
  ------------------
   23|       |#if SIMDUTF_CPLUSPLUS23
   24|       |    if !consteval
   25|       |#endif
   26|  7.67M|    {
   27|       |      // try to convert the next block of 16 ASCII bytes
   28|  7.67M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (28:11): [True: 7.65M, False: 14.7k]
  ------------------
   29|       |                             // they are ascii
   30|  7.65M|        uint64_t v1;
   31|  7.65M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   32|  7.65M|        uint64_t v2;
   33|  7.65M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   34|  7.65M|        uint64_t v{v1 |
   35|  7.65M|                   v2}; // We are only interested in these bits: 1000 1000 1000
   36|       |                        // 1000, so it makes sense to concatenate everything
   37|  7.65M|        if ((v & 0x8080808080808080) ==
  ------------------
  |  Branch (37:13): [True: 2.53M, False: 5.12M]
  ------------------
   38|  7.65M|            0) { // if NONE of these are set, e.g. all of them are zero, then
   39|       |                 // everything is ASCII
   40|  2.53M|          size_t final_pos = pos + 16;
   41|  43.1M|          while (pos < final_pos) {
  ------------------
  |  Branch (41:18): [True: 40.5M, False: 2.53M]
  ------------------
   42|  40.5M|            utf8_output[utf8_pos++] = char(data[pos]);
   43|  40.5M|            pos++;
   44|  40.5M|          }
   45|  2.53M|          continue;
   46|  2.53M|        }
   47|  7.65M|      } // if (pos + 16 <= len)
   48|  7.67M|    } // !consteval scope
   49|       |
   50|  5.13M|    unsigned char byte = data[pos];
   51|  5.13M|    if ((byte & 0x80) == 0) { // if ASCII
  ------------------
  |  Branch (51:9): [True: 3.26M, False: 1.87M]
  ------------------
   52|       |      // will generate one UTF-8 bytes
   53|  3.26M|      utf8_output[utf8_pos++] = char(byte);
   54|  3.26M|      pos++;
   55|  3.26M|    } else {
   56|       |      // will generate two UTF-8 bytes
   57|  1.87M|      utf8_output[utf8_pos++] = char((byte >> 6) | 0b11000000);
   58|  1.87M|      utf8_output[utf8_pos++] = char((byte & 0b111111) | 0b10000000);
   59|  1.87M|      pos++;
   60|  1.87M|    }
   61|  5.13M|  } // while
   62|  1.67k|  return utf8_pos;
   63|  1.67k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114latin1_to_utf823utf8_length_from_latin1IPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEEmS6_m:
  199|    300|utf8_length_from_latin1(InputPtr input, size_t length) noexcept {
  200|    300|  size_t answer = length;
  201|    300|  size_t i = 0;
  202|       |
  203|       |#if SIMDUTF_CPLUSPLUS23
  204|       |  if !consteval
  205|       |#endif
  206|    300|  {
  207|    300|    auto pop = [](uint64_t v) {
  208|    300|      return (size_t)(((v >> 7) & UINT64_C(0x0101010101010101)) *
  209|    300|                          UINT64_C(0x0101010101010101) >>
  210|    300|                      56);
  211|    300|    };
  212|   714k|    for (; i + 32 <= length; i += 32) {
  ------------------
  |  Branch (212:12): [True: 714k, False: 300]
  ------------------
  213|   714k|      uint64_t v;
  214|   714k|      memcpy(&v, input + i, 8);
  215|   714k|      answer += pop(v);
  216|   714k|      memcpy(&v, input + i + 8, sizeof(v));
  217|   714k|      answer += pop(v);
  218|   714k|      memcpy(&v, input + i + 16, sizeof(v));
  219|   714k|      answer += pop(v);
  220|   714k|      memcpy(&v, input + i + 24, sizeof(v));
  221|   714k|      answer += pop(v);
  222|   714k|    }
  223|    569|    for (; i + 8 <= length; i += 8) {
  ------------------
  |  Branch (223:12): [True: 269, False: 300]
  ------------------
  224|    269|      uint64_t v;
  225|    269|      memcpy(&v, input + i, sizeof(v));
  226|    269|      answer += pop(v);
  227|    269|    }
  228|    300|  } // !consteval scope
  229|    850|  for (; i + 1 <= length; i += 1) {
  ------------------
  |  Branch (229:10): [True: 550, False: 300]
  ------------------
  230|    550|    answer += static_cast<uint8_t>(input[i]) >> 7;
  231|    550|  }
  232|    300|  return answer;
  233|    300|}
simdutf.cpp:_ZZN7simdutf6scalar12_GLOBAL__N_114latin1_to_utf823utf8_length_from_latin1IPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEEmS6_mENKUlmE_clEm:
  207|  2.85M|    auto pop = [](uint64_t v) {
  208|  2.85M|      return (size_t)(((v >> 7) & UINT64_C(0x0101010101010101)) *
  209|       |                          UINT64_C(0x0101010101010101) >>
  210|  2.85M|                      56);
  211|  2.85M|    };

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

_ZN7simdutf6scalar5utf168validateILNS_10endiannessE0EEEbPKDsm:
   22|  3.38k|validate(const char16_t *data, size_t len) noexcept {
   23|  3.38k|  uint64_t pos = 0;
   24|  20.4M|  while (pos < len) {
  ------------------
  |  Branch (24:10): [True: 20.4M, False: 2.39k]
  ------------------
   25|  20.4M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(data[pos]);
   26|  20.4M|    if ((word & 0xF800) == 0xD800) {
  ------------------
  |  Branch (26:9): [True: 14.4k, False: 20.4M]
  ------------------
   27|  14.4k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (27:11): [True: 251, False: 14.1k]
  ------------------
   28|    251|        return false;
   29|    251|      }
   30|  14.1k|      char16_t diff = char16_t(word - 0xD800);
   31|  14.1k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (31:11): [True: 287, False: 13.9k]
  ------------------
   32|    287|        return false;
   33|    287|      }
   34|  13.9k|      char16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (34:28): [Folded, False: 13.9k]
  ------------------
   35|  13.9k|                               ? u16_swap_bytes(data[pos + 1])
   36|  13.9k|                               : data[pos + 1];
   37|  13.9k|      char16_t diff2 = char16_t(next_word - 0xDC00);
   38|  13.9k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (38:11): [True: 459, False: 13.4k]
  ------------------
   39|    459|        return false;
   40|    459|      }
   41|  13.4k|      pos += 2;
   42|  20.4M|    } else {
   43|  20.4M|      pos++;
   44|  20.4M|    }
   45|  20.4M|  }
   46|  2.39k|  return true;
   47|  3.38k|}
_ZN7simdutf6scalar5utf168validateILNS_10endiannessE1EEEbPKDsm:
   22|  3.26k|validate(const char16_t *data, size_t len) noexcept {
   23|  3.26k|  uint64_t pos = 0;
   24|  19.3M|  while (pos < len) {
  ------------------
  |  Branch (24:10): [True: 19.3M, False: 2.33k]
  ------------------
   25|  19.3M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(data[pos]);
   26|  19.3M|    if ((word & 0xF800) == 0xD800) {
  ------------------
  |  Branch (26:9): [True: 25.0k, False: 19.3M]
  ------------------
   27|  25.0k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (27:11): [True: 191, False: 24.8k]
  ------------------
   28|    191|        return false;
   29|    191|      }
   30|  24.8k|      char16_t diff = char16_t(word - 0xD800);
   31|  24.8k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (31:11): [True: 258, False: 24.6k]
  ------------------
   32|    258|        return false;
   33|    258|      }
   34|  24.6k|      char16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (34:28): [True: 24.6k, Folded]
  ------------------
   35|  24.6k|                               ? u16_swap_bytes(data[pos + 1])
   36|  24.6k|                               : data[pos + 1];
   37|  24.6k|      char16_t diff2 = char16_t(next_word - 0xDC00);
   38|  24.6k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (38:11): [True: 481, False: 24.1k]
  ------------------
   39|    481|        return false;
   40|    481|      }
   41|  24.1k|      pos += 2;
   42|  19.3M|    } else {
   43|  19.3M|      pos++;
   44|  19.3M|    }
   45|  19.3M|  }
   46|  2.33k|  return true;
   47|  3.26k|}
_ZN7simdutf6scalar5utf1620validate_with_errorsILNS_10endiannessE0EEENS_6resultEPKDsm:
   51|  3.78k|validate_with_errors(const char16_t *data, size_t len) noexcept {
   52|  3.78k|  size_t pos = 0;
   53|  20.4M|  while (pos < len) {
  ------------------
  |  Branch (53:10): [True: 20.4M, False: 2.39k]
  ------------------
   54|  20.4M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(data[pos]);
   55|  20.4M|    if ((word & 0xF800) == 0xD800) {
  ------------------
  |  Branch (55:9): [True: 15.0k, False: 20.4M]
  ------------------
   56|  15.0k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (56:11): [True: 251, False: 14.8k]
  ------------------
   57|    251|        return result(error_code::SURROGATE, pos);
   58|    251|      }
   59|  14.8k|      char16_t diff = char16_t(word - 0xD800);
   60|  14.8k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (60:11): [True: 466, False: 14.3k]
  ------------------
   61|    466|        return result(error_code::SURROGATE, pos);
   62|    466|      }
   63|  14.3k|      char16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (63:28): [Folded, False: 14.3k]
  ------------------
   64|  14.3k|                               ? u16_swap_bytes(data[pos + 1])
   65|  14.3k|                               : data[pos + 1];
   66|  14.3k|      char16_t diff2 = uint16_t(next_word - 0xDC00);
   67|  14.3k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (67:11): [True: 681, False: 13.6k]
  ------------------
   68|    681|        return result(error_code::SURROGATE, pos);
   69|    681|      }
   70|  13.6k|      pos += 2;
   71|  20.4M|    } else {
   72|  20.4M|      pos++;
   73|  20.4M|    }
   74|  20.4M|  }
   75|  2.39k|  return result(error_code::SUCCESS, pos);
   76|  3.78k|}
_ZN7simdutf6scalar5utf1620validate_with_errorsILNS_10endiannessE1EEENS_6resultEPKDsm:
   51|  3.72k|validate_with_errors(const char16_t *data, size_t len) noexcept {
   52|  3.72k|  size_t pos = 0;
   53|  19.3M|  while (pos < len) {
  ------------------
  |  Branch (53:10): [True: 19.3M, False: 2.33k]
  ------------------
   54|  19.3M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(data[pos]);
   55|  19.3M|    if ((word & 0xF800) == 0xD800) {
  ------------------
  |  Branch (55:9): [True: 25.7k, False: 19.3M]
  ------------------
   56|  25.7k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (56:11): [True: 191, False: 25.5k]
  ------------------
   57|    191|        return result(error_code::SURROGATE, pos);
   58|    191|      }
   59|  25.5k|      char16_t diff = char16_t(word - 0xD800);
   60|  25.5k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (60:11): [True: 460, False: 25.0k]
  ------------------
   61|    460|        return result(error_code::SURROGATE, pos);
   62|    460|      }
   63|  25.0k|      char16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (63:28): [True: 25.0k, Folded]
  ------------------
   64|  25.0k|                               ? u16_swap_bytes(data[pos + 1])
   65|  25.0k|                               : data[pos + 1];
   66|  25.0k|      char16_t diff2 = uint16_t(next_word - 0xDC00);
   67|  25.0k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (67:11): [True: 735, False: 24.3k]
  ------------------
   68|    735|        return result(error_code::SURROGATE, pos);
   69|    735|      }
   70|  24.3k|      pos += 2;
   71|  19.3M|    } else {
   72|  19.3M|      pos++;
   73|  19.3M|    }
   74|  19.3M|  }
   75|  2.33k|  return result(error_code::SUCCESS, pos);
   76|  3.72k|}
_ZN7simdutf6scalar5utf1617is_high_surrogateILNS_10endiannessE0EEEbDs:
  137|    416|template <endianness big_endian> constexpr bool is_high_surrogate(char16_t c) {
  138|    416|  c = scalar::utf16::swap_if_needed<big_endian>(c);
  139|    416|  return (0xd800 <= c && c <= 0xdbff);
  ------------------
  |  Branch (139:11): [True: 68, False: 348]
  |  Branch (139:26): [True: 8, False: 60]
  ------------------
  140|    416|}
_ZN7simdutf6scalar5utf1616is_low_surrogateILNS_10endiannessE0EEEbDs:
  142|      8|template <endianness big_endian> constexpr bool is_low_surrogate(char16_t c) {
  143|      8|  c = scalar::utf16::swap_if_needed<big_endian>(c);
  144|      8|  return (0xdc00 <= c && c <= 0xdfff);
  ------------------
  |  Branch (144:11): [True: 4, False: 4]
  |  Branch (144:26): [True: 4, False: 0]
  ------------------
  145|      8|}
_ZN7simdutf6scalar5utf1617is_high_surrogateILNS_10endiannessE1EEEbDs:
  137|    432|template <endianness big_endian> constexpr bool is_high_surrogate(char16_t c) {
  138|    432|  c = scalar::utf16::swap_if_needed<big_endian>(c);
  139|    432|  return (0xd800 <= c && c <= 0xdbff);
  ------------------
  |  Branch (139:11): [True: 24, False: 408]
  |  Branch (139:26): [True: 0, False: 24]
  ------------------
  140|    432|}
_ZN7simdutf6scalar5utf1617count_code_pointsILNS_10endiannessE0EEEmPKDsm:
   79|  4.77k|simdutf_constexpr23 size_t count_code_points(const char16_t *p, size_t len) {
   80|       |  // We are not BOM aware.
   81|  4.77k|  size_t counter{0};
   82|  28.5M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (82:22): [True: 28.5M, False: 4.77k]
  ------------------
   83|  28.5M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
   84|  28.5M|    counter += ((word & 0xFC00) != 0xDC00);
   85|  28.5M|  }
   86|  4.77k|  return counter;
   87|  4.77k|}
_ZN7simdutf6scalar5utf1617count_code_pointsILNS_10endiannessE1EEEmPKDsm:
   79|  4.77k|simdutf_constexpr23 size_t count_code_points(const char16_t *p, size_t len) {
   80|       |  // We are not BOM aware.
   81|  4.77k|  size_t counter{0};
   82|  28.2M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (82:22): [True: 28.2M, False: 4.77k]
  ------------------
   83|  28.2M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
   84|  28.2M|    counter += ((word & 0xFC00) != 0xDC00);
   85|  28.2M|  }
   86|  4.77k|  return counter;
   87|  4.77k|}
_ZN7simdutf6scalar5utf1622utf8_length_from_utf16ILNS_10endiannessE0EEEmPKDsm:
   91|  2.24k|                                                  size_t len) {
   92|       |  // We are not BOM aware.
   93|  2.24k|  size_t counter{0};
   94|  16.1M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (94:22): [True: 16.1M, False: 2.24k]
  ------------------
   95|  16.1M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
   96|  16.1M|    counter++; // ASCII
   97|  16.1M|    counter += static_cast<size_t>(
   98|  16.1M|        word >
   99|  16.1M|        0x7F); // non-ASCII is at least 2 bytes, surrogates are 2*2 == 4 bytes
  100|  16.1M|    counter += static_cast<size_t>((word > 0x7FF && word <= 0xD7FF) ||
  ------------------
  |  Branch (100:37): [True: 4.28M, False: 11.8M]
  |  Branch (100:53): [True: 4.09M, False: 195k]
  ------------------
  101|  12.0M|                                   (word >= 0xE000)); // three-byte
  ------------------
  |  Branch (101:36): [True: 158k, False: 11.8M]
  ------------------
  102|  16.1M|  }
  103|  2.24k|  return counter;
  104|  2.24k|}
_ZN7simdutf6scalar5utf1622utf8_length_from_utf16ILNS_10endiannessE1EEEmPKDsm:
   91|  2.02k|                                                  size_t len) {
   92|       |  // We are not BOM aware.
   93|  2.02k|  size_t counter{0};
   94|  13.7M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (94:22): [True: 13.7M, False: 2.02k]
  ------------------
   95|  13.7M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
   96|  13.7M|    counter++; // ASCII
   97|  13.7M|    counter += static_cast<size_t>(
   98|  13.7M|        word >
   99|  13.7M|        0x7F); // non-ASCII is at least 2 bytes, surrogates are 2*2 == 4 bytes
  100|  13.7M|    counter += static_cast<size_t>((word > 0x7FF && word <= 0xD7FF) ||
  ------------------
  |  Branch (100:37): [True: 3.15M, False: 10.6M]
  |  Branch (100:53): [True: 2.90M, False: 251k]
  ------------------
  101|  10.8M|                                   (word >= 0xE000)); // three-byte
  ------------------
  |  Branch (101:36): [True: 210k, False: 10.6M]
  ------------------
  102|  13.7M|  }
  103|  2.02k|  return counter;
  104|  2.02k|}
_ZN7simdutf6scalar5utf1623utf32_length_from_utf16ILNS_10endiannessE0EEEmPKDsm:
  108|    394|                                                   size_t len) {
  109|       |  // We are not BOM aware.
  110|    394|  size_t counter{0};
  111|  7.86M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (111:22): [True: 7.86M, False: 394]
  ------------------
  112|  7.86M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
  113|  7.86M|    counter += ((word & 0xFC00) != 0xDC00);
  114|  7.86M|  }
  115|    394|  return counter;
  116|    394|}
_ZN7simdutf6scalar5utf1623utf32_length_from_utf16ILNS_10endiannessE1EEEmPKDsm:
  108|    415|                                                   size_t len) {
  109|       |  // We are not BOM aware.
  110|    415|  size_t counter{0};
  111|  9.90M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (111:22): [True: 9.90M, False: 415]
  ------------------
  112|  9.90M|    char16_t word = scalar::utf16::swap_if_needed<big_endian>(p[i]);
  113|  9.90M|    counter += ((word & 0xFC00) != 0xDC00);
  114|  9.90M|  }
  115|    415|  return counter;
  116|    415|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_115utf16_to_latin17convertILNS_10endiannessE0EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEEmS8_mS9_:
   17|    236|                                   OutputPtr latin_output) {
   18|    236|  if (len == 0) {
  ------------------
  |  Branch (18:7): [True: 6, False: 230]
  ------------------
   19|      6|    return 0;
   20|      6|  }
   21|    230|  size_t pos = 0;
   22|    230|  const auto latin_output_start = latin_output;
   23|    230|  uint16_t word = 0;
   24|    230|  uint16_t too_large = 0;
   25|       |
   26|  1.05M|  while (pos < len) {
  ------------------
  |  Branch (26:10): [True: 1.05M, False: 230]
  ------------------
   27|  1.05M|    word = !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (27:12): [Folded, False: 1.05M]
  ------------------
   28|  1.05M|    too_large |= word;
   29|  1.05M|    *latin_output++ = char(word & 0xFF);
   30|  1.05M|    pos++;
   31|  1.05M|  }
   32|    230|  if ((too_large & 0xFF00) != 0) {
  ------------------
  |  Branch (32:7): [True: 144, False: 86]
  ------------------
   33|    144|    return 0;
   34|    144|  }
   35|       |
   36|     86|  return latin_output - latin_output_start;
   37|    230|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_115utf16_to_latin17convertILNS_10endiannessE1EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEEmS8_mS9_:
   17|    268|                                   OutputPtr latin_output) {
   18|    268|  if (len == 0) {
  ------------------
  |  Branch (18:7): [True: 6, False: 262]
  ------------------
   19|      6|    return 0;
   20|      6|  }
   21|    262|  size_t pos = 0;
   22|    262|  const auto latin_output_start = latin_output;
   23|    262|  uint16_t word = 0;
   24|    262|  uint16_t too_large = 0;
   25|       |
   26|  1.58M|  while (pos < len) {
  ------------------
  |  Branch (26:10): [True: 1.58M, False: 262]
  ------------------
   27|  1.58M|    word = !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (27:12): [True: 1.58M, Folded]
  ------------------
   28|  1.58M|    too_large |= word;
   29|  1.58M|    *latin_output++ = char(word & 0xFF);
   30|  1.58M|    pos++;
   31|  1.58M|  }
   32|    262|  if ((too_large & 0xFF00) != 0) {
  ------------------
  |  Branch (32:7): [True: 140, False: 122]
  ------------------
   33|    140|    return 0;
   34|    140|  }
   35|       |
   36|    122|  return latin_output - latin_output_start;
   37|    262|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_115utf16_to_latin119convert_with_errorsILNS_10endiannessE0EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEENS_6resultES8_mS9_:
   45|    364|                                               OutputPtr latin_output) {
   46|    364|  if (len == 0) {
  ------------------
  |  Branch (46:7): [True: 4, False: 360]
  ------------------
   47|      4|    return result(error_code::SUCCESS, 0);
   48|      4|  }
   49|    360|  size_t pos = 0;
   50|    360|  auto start = latin_output;
   51|    360|  uint16_t word;
   52|       |
   53|   452k|  while (pos < len) {
  ------------------
  |  Branch (53:10): [True: 452k, False: 178]
  ------------------
   54|       |#if SIMDUTF_CPLUSPLUS23
   55|       |    if !consteval
   56|       |#endif
   57|   452k|    {
   58|   452k|      if (pos + 16 <= len) { // if it is safe to read 32 more bytes, check that
  ------------------
  |  Branch (58:11): [True: 451k, False: 1.26k]
  ------------------
   59|       |                             // they are Latin1
   60|   451k|        uint64_t v1, v2, v3, v4;
   61|   451k|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   62|   451k|        ::memcpy(&v2, data + pos + 4, sizeof(uint64_t));
   63|   451k|        ::memcpy(&v3, data + pos + 8, sizeof(uint64_t));
   64|   451k|        ::memcpy(&v4, data + pos + 12, sizeof(uint64_t));
   65|       |
   66|       |        if constexpr (!match_system(big_endian)) {
   67|       |          v1 = (v1 >> 8) | (v1 << (64 - 8));
   68|       |        }
   69|       |        if constexpr (!match_system(big_endian)) {
   70|       |          v2 = (v2 >> 8) | (v2 << (64 - 8));
   71|       |        }
   72|       |        if constexpr (!match_system(big_endian)) {
   73|       |          v3 = (v3 >> 8) | (v3 << (64 - 8));
   74|       |        }
   75|       |        if constexpr (!match_system(big_endian)) {
   76|       |          v4 = (v4 >> 8) | (v4 << (64 - 8));
   77|       |        }
   78|       |
   79|   451k|        if (((v1 | v2 | v3 | v4) & 0xFF00FF00FF00FF00) == 0) {
  ------------------
  |  Branch (79:13): [True: 451k, False: 172]
  ------------------
   80|   451k|          size_t final_pos = pos + 16;
   81|  7.67M|          while (pos < final_pos) {
  ------------------
  |  Branch (81:18): [True: 7.21M, False: 451k]
  ------------------
   82|  7.21M|            *latin_output++ = !match_system(big_endian)
  ------------------
  |  Branch (82:31): [Folded, False: 7.21M]
  ------------------
   83|  7.21M|                                  ? char(u16_swap_bytes(data[pos]))
   84|  7.21M|                                  : char(data[pos]);
   85|  7.21M|            pos++;
   86|  7.21M|          }
   87|   451k|          continue;
   88|   451k|        }
   89|   451k|      }
   90|   452k|    }
   91|       |
   92|  1.43k|    word = !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (92:12): [Folded, False: 1.43k]
  ------------------
   93|  1.43k|    if ((word & 0xFF00) == 0) {
  ------------------
  |  Branch (93:9): [True: 1.25k, False: 182]
  ------------------
   94|  1.25k|      *latin_output++ = char(word & 0xFF);
   95|  1.25k|      pos++;
   96|  1.25k|    } else {
   97|    182|      return result(error_code::TOO_LARGE, pos);
   98|    182|    }
   99|  1.43k|  }
  100|    178|  return result(error_code::SUCCESS, latin_output - start);
  101|    360|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_115utf16_to_latin119convert_with_errorsILNS_10endiannessE1EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEENS_6resultES8_mS9_:
   45|    420|                                               OutputPtr latin_output) {
   46|    420|  if (len == 0) {
  ------------------
  |  Branch (46:7): [True: 4, False: 416]
  ------------------
   47|      4|    return result(error_code::SUCCESS, 0);
   48|      4|  }
   49|    416|  size_t pos = 0;
   50|    416|  auto start = latin_output;
   51|    416|  uint16_t word;
   52|       |
   53|   331k|  while (pos < len) {
  ------------------
  |  Branch (53:10): [True: 331k, False: 158]
  ------------------
   54|       |#if SIMDUTF_CPLUSPLUS23
   55|       |    if !consteval
   56|       |#endif
   57|   331k|    {
   58|   331k|      if (pos + 16 <= len) { // if it is safe to read 32 more bytes, check that
  ------------------
  |  Branch (58:11): [True: 330k, False: 1.08k]
  ------------------
   59|       |                             // they are Latin1
   60|   330k|        uint64_t v1, v2, v3, v4;
   61|   330k|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   62|   330k|        ::memcpy(&v2, data + pos + 4, sizeof(uint64_t));
   63|   330k|        ::memcpy(&v3, data + pos + 8, sizeof(uint64_t));
   64|   330k|        ::memcpy(&v4, data + pos + 12, sizeof(uint64_t));
   65|       |
   66|   330k|        if constexpr (!match_system(big_endian)) {
   67|   330k|          v1 = (v1 >> 8) | (v1 << (64 - 8));
   68|   330k|        }
   69|   330k|        if constexpr (!match_system(big_endian)) {
   70|   330k|          v2 = (v2 >> 8) | (v2 << (64 - 8));
   71|   330k|        }
   72|   330k|        if constexpr (!match_system(big_endian)) {
   73|   330k|          v3 = (v3 >> 8) | (v3 << (64 - 8));
   74|   330k|        }
   75|   330k|        if constexpr (!match_system(big_endian)) {
   76|   330k|          v4 = (v4 >> 8) | (v4 << (64 - 8));
   77|   330k|        }
   78|       |
   79|   330k|        if (((v1 | v2 | v3 | v4) & 0xFF00FF00FF00FF00) == 0) {
  ------------------
  |  Branch (79:13): [True: 329k, False: 344]
  ------------------
   80|   329k|          size_t final_pos = pos + 16;
   81|  5.60M|          while (pos < final_pos) {
  ------------------
  |  Branch (81:18): [True: 5.27M, False: 329k]
  ------------------
   82|  5.27M|            *latin_output++ = !match_system(big_endian)
  ------------------
  |  Branch (82:31): [True: 5.27M, Folded]
  ------------------
   83|  5.27M|                                  ? char(u16_swap_bytes(data[pos]))
   84|  5.27M|                                  : char(data[pos]);
   85|  5.27M|            pos++;
   86|  5.27M|          }
   87|   329k|          continue;
   88|   329k|        }
   89|   330k|      }
   90|   331k|    }
   91|       |
   92|  1.43k|    word = !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (92:12): [True: 1.43k, Folded]
  ------------------
   93|  1.43k|    if ((word & 0xFF00) == 0) {
  ------------------
  |  Branch (93:9): [True: 1.17k, False: 258]
  ------------------
   94|  1.17k|      *latin_output++ = char(word & 0xFF);
   95|  1.17k|      pos++;
   96|  1.17k|    } else {
   97|    258|      return result(error_code::TOO_LARGE, pos);
   98|    258|    }
   99|  1.43k|  }
  100|    158|  return result(error_code::SUCCESS, latin_output - start);
  101|    416|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf16_to_utf327convertILNS_10endiannessE0EEEmPKDsmPDi:
   11|    708|                                   char32_t *utf32_output) {
   12|    708|  size_t pos = 0;
   13|    708|  char32_t *start{utf32_output};
   14|  1.01M|  while (pos < len) {
  ------------------
  |  Branch (14:10): [True: 1.01M, False: 420]
  ------------------
   15|  1.01M|    uint16_t word =
   16|  1.01M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (16:9): [Folded, False: 1.01M]
  ------------------
   17|  1.01M|    if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (17:9): [True: 1.00M, False: 3.53k]
  ------------------
   18|       |      // No surrogate pair, extend 16-bit word to 32-bit word
   19|  1.00M|      *utf32_output++ = char32_t(word);
   20|  1.00M|      pos++;
   21|  1.00M|    } else {
   22|       |      // must be a surrogate pair
   23|  3.53k|      uint16_t diff = uint16_t(word - 0xD800);
   24|  3.53k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (24:11): [True: 90, False: 3.44k]
  ------------------
   25|     90|        return 0;
   26|     90|      }
   27|  3.44k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (27:11): [True: 90, False: 3.35k]
  ------------------
   28|     90|        return 0;
   29|     90|      } // minimal bound checking
   30|  3.35k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (30:28): [Folded, False: 3.35k]
  ------------------
   31|  3.35k|                               ? u16_swap_bytes(data[pos + 1])
   32|  3.35k|                               : data[pos + 1];
   33|  3.35k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   34|  3.35k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (34:11): [True: 108, False: 3.24k]
  ------------------
   35|    108|        return 0;
   36|    108|      }
   37|  3.24k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   38|  3.24k|      *utf32_output++ = char32_t(value);
   39|  3.24k|      pos += 2;
   40|  3.24k|    }
   41|  1.01M|  }
   42|    420|  return utf32_output - start;
   43|    708|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf16_to_utf327convertILNS_10endiannessE1EEEmPKDsmPDi:
   11|    680|                                   char32_t *utf32_output) {
   12|    680|  size_t pos = 0;
   13|    680|  char32_t *start{utf32_output};
   14|  1.61M|  while (pos < len) {
  ------------------
  |  Branch (14:10): [True: 1.61M, False: 420]
  ------------------
   15|  1.61M|    uint16_t word =
   16|  1.61M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (16:9): [True: 1.61M, Folded]
  ------------------
   17|  1.61M|    if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (17:9): [True: 1.60M, False: 5.02k]
  ------------------
   18|       |      // No surrogate pair, extend 16-bit word to 32-bit word
   19|  1.60M|      *utf32_output++ = char32_t(word);
   20|  1.60M|      pos++;
   21|  1.60M|    } else {
   22|       |      // must be a surrogate pair
   23|  5.02k|      uint16_t diff = uint16_t(word - 0xD800);
   24|  5.02k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (24:11): [True: 96, False: 4.93k]
  ------------------
   25|     96|        return 0;
   26|     96|      }
   27|  4.93k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (27:11): [True: 30, False: 4.90k]
  ------------------
   28|     30|        return 0;
   29|     30|      } // minimal bound checking
   30|  4.90k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (30:28): [True: 4.90k, Folded]
  ------------------
   31|  4.90k|                               ? u16_swap_bytes(data[pos + 1])
   32|  4.90k|                               : data[pos + 1];
   33|  4.90k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   34|  4.90k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (34:11): [True: 134, False: 4.76k]
  ------------------
   35|    134|        return 0;
   36|    134|      }
   37|  4.76k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   38|  4.76k|      *utf32_output++ = char32_t(value);
   39|  4.76k|      pos += 2;
   40|  4.76k|    }
   41|  1.61M|  }
   42|    420|  return utf32_output - start;
   43|    680|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf16_to_utf3219convert_with_errorsILNS_10endiannessE0EEENS_6resultEPKDsmPDi:
   47|    800|                                               char32_t *utf32_output) {
   48|    800|  size_t pos = 0;
   49|    800|  char32_t *start{utf32_output};
   50|  3.78M|  while (pos < len) {
  ------------------
  |  Branch (50:10): [True: 3.78M, False: 412]
  ------------------
   51|  3.78M|    uint16_t word =
   52|  3.78M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (52:9): [Folded, False: 3.78M]
  ------------------
   53|  3.78M|    if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (53:9): [True: 3.78M, False: 6.60k]
  ------------------
   54|       |      // No surrogate pair, extend 16-bit word to 32-bit word
   55|  3.78M|      *utf32_output++ = char32_t(word);
   56|  3.78M|      pos++;
   57|  3.78M|    } else {
   58|       |      // must be a surrogate pair
   59|  6.60k|      uint16_t diff = uint16_t(word - 0xD800);
   60|  6.60k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (60:11): [True: 136, False: 6.47k]
  ------------------
   61|    136|        return result(error_code::SURROGATE, pos);
   62|    136|      }
   63|  6.47k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (63:11): [True: 90, False: 6.38k]
  ------------------
   64|     90|        return result(error_code::SURROGATE, pos);
   65|     90|      } // minimal bound checking
   66|  6.38k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (66:28): [Folded, False: 6.38k]
  ------------------
   67|  6.38k|                               ? u16_swap_bytes(data[pos + 1])
   68|  6.38k|                               : data[pos + 1];
   69|  6.38k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   70|  6.38k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (70:11): [True: 162, False: 6.22k]
  ------------------
   71|    162|        return result(error_code::SURROGATE, pos);
   72|    162|      }
   73|  6.22k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   74|  6.22k|      *utf32_output++ = char32_t(value);
   75|  6.22k|      pos += 2;
   76|  6.22k|    }
   77|  3.78M|  }
   78|    412|  return result(error_code::SUCCESS, utf32_output - start);
   79|    800|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf16_to_utf3219convert_with_errorsILNS_10endiannessE1EEENS_6resultEPKDsmPDi:
   47|    766|                                               char32_t *utf32_output) {
   48|    766|  size_t pos = 0;
   49|    766|  char32_t *start{utf32_output};
   50|  2.48M|  while (pos < len) {
  ------------------
  |  Branch (50:10): [True: 2.48M, False: 384]
  ------------------
   51|  2.48M|    uint16_t word =
   52|  2.48M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (52:9): [True: 2.48M, Folded]
  ------------------
   53|  2.48M|    if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (53:9): [True: 2.48M, False: 6.76k]
  ------------------
   54|       |      // No surrogate pair, extend 16-bit word to 32-bit word
   55|  2.48M|      *utf32_output++ = char32_t(word);
   56|  2.48M|      pos++;
   57|  2.48M|    } else {
   58|       |      // must be a surrogate pair
   59|  6.76k|      uint16_t diff = uint16_t(word - 0xD800);
   60|  6.76k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (60:11): [True: 90, False: 6.67k]
  ------------------
   61|     90|        return result(error_code::SURROGATE, pos);
   62|     90|      }
   63|  6.67k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (63:11): [True: 96, False: 6.57k]
  ------------------
   64|     96|        return result(error_code::SURROGATE, pos);
   65|     96|      } // minimal bound checking
   66|  6.57k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (66:28): [True: 6.57k, Folded]
  ------------------
   67|  6.57k|                               ? u16_swap_bytes(data[pos + 1])
   68|  6.57k|                               : data[pos + 1];
   69|  6.57k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   70|  6.57k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (70:11): [True: 196, False: 6.37k]
  ------------------
   71|    196|        return result(error_code::SURROGATE, pos);
   72|    196|      }
   73|  6.37k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   74|  6.37k|      *utf32_output++ = char32_t(value);
   75|  6.37k|      pos += 2;
   76|  6.37k|    }
   77|  2.48M|  }
   78|    384|  return result(error_code::SUCCESS, utf32_output - start);
   79|    766|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf16_to_utf3213convert_validILNS_10endiannessE0EEEmPKDsmPDi:
   11|    108|                                         char32_t *utf32_output) {
   12|    108|  size_t pos = 0;
   13|    108|  char32_t *start{utf32_output};
   14|  1.10M|  while (pos < len) {
  ------------------
  |  Branch (14:10): [True: 1.10M, False: 108]
  ------------------
   15|  1.10M|    uint16_t word =
   16|  1.10M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (16:9): [Folded, False: 1.10M]
  ------------------
   17|  1.10M|    if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (17:9): [True: 1.10M, False: 2.09k]
  ------------------
   18|       |      // No surrogate pair, extend 16-bit word to 32-bit word
   19|  1.10M|      *utf32_output++ = char32_t(word);
   20|  1.10M|      pos++;
   21|  1.10M|    } else {
   22|       |      // must be a surrogate pair
   23|  2.09k|      uint16_t diff = uint16_t(word - 0xD800);
   24|  2.09k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (24:11): [True: 0, False: 2.09k]
  ------------------
   25|      0|        return 0;
   26|      0|      } // minimal bound checking
   27|  2.09k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (27:28): [Folded, False: 2.09k]
  ------------------
   28|  2.09k|                               ? u16_swap_bytes(data[pos + 1])
   29|  2.09k|                               : data[pos + 1];
   30|  2.09k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   31|  2.09k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   32|  2.09k|      *utf32_output++ = char32_t(value);
   33|  2.09k|      pos += 2;
   34|  2.09k|    }
   35|  1.10M|  }
   36|    108|  return utf32_output - start;
   37|    108|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf16_to_utf3213convert_validILNS_10endiannessE1EEEmPKDsmPDi:
   11|    142|                                         char32_t *utf32_output) {
   12|    142|  size_t pos = 0;
   13|    142|  char32_t *start{utf32_output};
   14|  5.06M|  while (pos < len) {
  ------------------
  |  Branch (14:10): [True: 5.06M, False: 142]
  ------------------
   15|  5.06M|    uint16_t word =
   16|  5.06M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (16:9): [True: 5.06M, Folded]
  ------------------
   17|  5.06M|    if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (17:9): [True: 5.06M, False: 1.28k]
  ------------------
   18|       |      // No surrogate pair, extend 16-bit word to 32-bit word
   19|  5.06M|      *utf32_output++ = char32_t(word);
   20|  5.06M|      pos++;
   21|  5.06M|    } else {
   22|       |      // must be a surrogate pair
   23|  1.28k|      uint16_t diff = uint16_t(word - 0xD800);
   24|  1.28k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (24:11): [True: 0, False: 1.28k]
  ------------------
   25|      0|        return 0;
   26|      0|      } // minimal bound checking
   27|  1.28k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (27:28): [True: 1.28k, Folded]
  ------------------
   28|  1.28k|                               ? u16_swap_bytes(data[pos + 1])
   29|  1.28k|                               : data[pos + 1];
   30|  1.28k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   31|  1.28k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   32|  1.28k|      *utf32_output++ = char32_t(value);
   33|  1.28k|      pos += 2;
   34|  1.28k|    }
   35|  5.06M|  }
   36|    142|  return utf32_output - start;
   37|    142|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf87convertILNS_10endiannessE0EPKDsPcQsr7simdutf6detailE18indexes_into_utf16IT0_EEEmS8_mT1_:
   17|  1.78k|                                   OutputPtr utf8_output) {
   18|  1.78k|  size_t pos = 0;
   19|  1.78k|  const auto start = utf8_output;
   20|  2.71M|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 2.71M, False: 1.46k]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|  2.71M|    {
   25|       |      // try to convert the next block of 8 bytes
   26|  2.71M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (26:11): [True: 2.71M, False: 3.19k]
  ------------------
   27|       |                            // they are ascii
   28|  2.71M|        uint64_t v;
   29|  2.71M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   30|       |        if constexpr (!match_system(big_endian)) {
   31|       |          v = (v >> 8) | (v << (64 - 8));
   32|       |        }
   33|  2.71M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (33:13): [True: 1.94M, False: 763k]
  ------------------
   34|  1.94M|          size_t final_pos = pos + 4;
   35|  9.73M|          while (pos < final_pos) {
  ------------------
  |  Branch (35:18): [True: 7.79M, False: 1.94M]
  ------------------
   36|  7.79M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (36:30): [Folded, False: 7.79M]
  ------------------
   37|  7.79M|                                 ? char(u16_swap_bytes(data[pos]))
   38|  7.79M|                                 : char(data[pos]);
   39|  7.79M|            pos++;
   40|  7.79M|          }
   41|  1.94M|          continue;
   42|  1.94M|        }
   43|  2.71M|      }
   44|  2.71M|    }
   45|   766k|    uint16_t word =
   46|   766k|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (46:9): [Folded, False: 766k]
  ------------------
   47|   766k|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (47:9): [True: 252k, False: 514k]
  ------------------
   48|       |      // will generate one UTF-8 bytes
   49|   252k|      *utf8_output++ = char(word);
   50|   252k|      pos++;
   51|   514k|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (51:16): [True: 107k, False: 407k]
  ------------------
   52|       |      // will generate two UTF-8 bytes
   53|       |      // we have 0b110XXXXX 0b10XXXXXX
   54|   107k|      *utf8_output++ = char((word >> 6) | 0b11000000);
   55|   107k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   56|   107k|      pos++;
   57|   407k|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (57:16): [True: 397k, False: 9.20k]
  ------------------
   58|       |      // will generate three UTF-8 bytes
   59|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   60|   397k|      *utf8_output++ = char((word >> 12) | 0b11100000);
   61|   397k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   62|   397k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   63|   397k|      pos++;
   64|   397k|    } else {
   65|       |      // must be a surrogate pair
   66|  9.20k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (66:11): [True: 66, False: 9.14k]
  ------------------
   67|     66|        return 0;
   68|     66|      }
   69|  9.14k|      uint16_t diff = uint16_t(word - 0xD800);
   70|  9.14k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (70:11): [True: 108, False: 9.03k]
  ------------------
   71|    108|        return 0;
   72|    108|      }
   73|  9.03k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (73:28): [Folded, False: 9.03k]
  ------------------
   74|  9.03k|                               ? u16_swap_bytes(data[pos + 1])
   75|  9.03k|                               : data[pos + 1];
   76|  9.03k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   77|  9.03k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (77:11): [True: 148, False: 8.88k]
  ------------------
   78|    148|        return 0;
   79|    148|      }
   80|  8.88k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   81|       |      // will generate four UTF-8 bytes
   82|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   83|  8.88k|      *utf8_output++ = char((value >> 18) | 0b11110000);
   84|  8.88k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
   85|  8.88k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
   86|  8.88k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
   87|  8.88k|      pos += 2;
   88|  8.88k|    }
   89|   766k|  }
   90|  1.46k|  return utf8_output - start;
   91|  1.78k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf87convertILNS_10endiannessE1EPKDsPcQsr7simdutf6detailE18indexes_into_utf16IT0_EEEmS8_mT1_:
   17|  1.65k|                                   OutputPtr utf8_output) {
   18|  1.65k|  size_t pos = 0;
   19|  1.65k|  const auto start = utf8_output;
   20|  3.30M|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 3.30M, False: 1.40k]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|  3.30M|    {
   25|       |      // try to convert the next block of 8 bytes
   26|  3.30M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (26:11): [True: 3.30M, False: 2.88k]
  ------------------
   27|       |                            // they are ascii
   28|  3.30M|        uint64_t v;
   29|  3.30M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   30|  3.30M|        if constexpr (!match_system(big_endian)) {
   31|  3.30M|          v = (v >> 8) | (v << (64 - 8));
   32|  3.30M|        }
   33|  3.30M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (33:13): [True: 1.22M, False: 2.08M]
  ------------------
   34|  1.22M|          size_t final_pos = pos + 4;
   35|  6.10M|          while (pos < final_pos) {
  ------------------
  |  Branch (35:18): [True: 4.88M, False: 1.22M]
  ------------------
   36|  4.88M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (36:30): [True: 4.88M, Folded]
  ------------------
   37|  4.88M|                                 ? char(u16_swap_bytes(data[pos]))
   38|  4.88M|                                 : char(data[pos]);
   39|  4.88M|            pos++;
   40|  4.88M|          }
   41|  1.22M|          continue;
   42|  1.22M|        }
   43|  3.30M|      }
   44|  3.30M|    }
   45|  2.08M|    uint16_t word =
   46|  2.08M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (46:9): [True: 2.08M, Folded]
  ------------------
   47|  2.08M|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (47:9): [True: 218k, False: 1.86M]
  ------------------
   48|       |      // will generate one UTF-8 bytes
   49|   218k|      *utf8_output++ = char(word);
   50|   218k|      pos++;
   51|  1.86M|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (51:16): [True: 71.0k, False: 1.79M]
  ------------------
   52|       |      // will generate two UTF-8 bytes
   53|       |      // we have 0b110XXXXX 0b10XXXXXX
   54|  71.0k|      *utf8_output++ = char((word >> 6) | 0b11000000);
   55|  71.0k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   56|  71.0k|      pos++;
   57|  1.79M|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (57:16): [True: 1.78M, False: 8.20k]
  ------------------
   58|       |      // will generate three UTF-8 bytes
   59|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   60|  1.78M|      *utf8_output++ = char((word >> 12) | 0b11100000);
   61|  1.78M|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   62|  1.78M|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   63|  1.78M|      pos++;
   64|  1.78M|    } else {
   65|       |      // must be a surrogate pair
   66|  8.20k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (66:11): [True: 30, False: 8.17k]
  ------------------
   67|     30|        return 0;
   68|     30|      }
   69|  8.17k|      uint16_t diff = uint16_t(word - 0xD800);
   70|  8.17k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (70:11): [True: 64, False: 8.10k]
  ------------------
   71|     64|        return 0;
   72|     64|      }
   73|  8.10k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (73:28): [True: 8.10k, Folded]
  ------------------
   74|  8.10k|                               ? u16_swap_bytes(data[pos + 1])
   75|  8.10k|                               : data[pos + 1];
   76|  8.10k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   77|  8.10k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (77:11): [True: 158, False: 7.95k]
  ------------------
   78|    158|        return 0;
   79|    158|      }
   80|  7.95k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   81|       |      // will generate four UTF-8 bytes
   82|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   83|  7.95k|      *utf8_output++ = char((value >> 18) | 0b11110000);
   84|  7.95k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
   85|  7.95k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
   86|  7.95k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
   87|  7.95k|      pos += 2;
   88|  7.95k|    }
   89|  2.08M|  }
   90|  1.40k|  return utf8_output - start;
   91|  1.65k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf819convert_with_errorsILNS_10endiannessE0ELb0EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT1_Esr7simdutf6detailE26index_assignable_from_charIT2_EEENS_11full_resultES8_mS9_m:
  101|  1.64k|                                                    size_t utf8_len = 0) {
  102|  1.64k|  if (check_output && utf8_len == 0) {
  ------------------
  |  Branch (102:7): [Folded, False: 1.64k]
  |  Branch (102:23): [True: 0, False: 0]
  ------------------
  103|      0|    return full_result(error_code::OUTPUT_BUFFER_TOO_SMALL, 0, 0);
  104|      0|  }
  105|       |
  106|  1.64k|  size_t pos = 0;
  107|  1.64k|  auto start = utf8_output;
  108|  1.64k|  auto end = utf8_output + utf8_len;
  109|       |
  110|  4.63M|  while (pos < len) {
  ------------------
  |  Branch (110:10): [True: 4.63M, False: 1.15k]
  ------------------
  111|       |#if SIMDUTF_CPLUSPLUS23
  112|       |    if !consteval
  113|       |#endif
  114|  4.63M|    {
  115|       |      // try to convert the next block of 8 bytes
  116|  4.63M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (116:11): [True: 4.62M, False: 2.64k]
  ------------------
  117|       |                            // they are ascii
  118|  4.62M|        uint64_t v;
  119|  4.62M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
  120|       |        if constexpr (!match_system(big_endian))
  121|       |          v = (v >> 8) | (v << (64 - 8));
  122|  4.62M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (122:13): [True: 976k, False: 3.65M]
  ------------------
  123|   976k|          size_t final_pos = pos + 4;
  124|  4.88M|          while (pos < final_pos) {
  ------------------
  |  Branch (124:18): [True: 3.90M, False: 976k]
  ------------------
  125|  3.90M|            if (check_output && size_t(end - utf8_output) < 1) {
  ------------------
  |  Branch (125:17): [Folded, False: 3.90M]
  |  Branch (125:33): [True: 0, False: 0]
  ------------------
  126|      0|              return full_result(error_code::OUTPUT_BUFFER_TOO_SMALL, pos,
  127|      0|                                 utf8_output - start);
  128|      0|            }
  129|  3.90M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (129:30): [Folded, False: 3.90M]
  ------------------
  130|  3.90M|                                 ? char(u16_swap_bytes(data[pos]))
  131|  3.90M|                                 : char(data[pos]);
  132|  3.90M|            pos++;
  133|  3.90M|          }
  134|   976k|          continue;
  135|   976k|        }
  136|  4.62M|      }
  137|  4.63M|    }
  138|       |
  139|  3.65M|    uint16_t word =
  140|  3.65M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (140:9): [Folded, False: 3.65M]
  ------------------
  141|  3.65M|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (141:9): [True: 318k, False: 3.33M]
  ------------------
  142|       |      // will generate one UTF-8 bytes
  143|   318k|      if (check_output && size_t(end - utf8_output) < 1) {
  ------------------
  |  Branch (143:11): [Folded, False: 318k]
  |  Branch (143:27): [True: 0, False: 0]
  ------------------
  144|      0|        return full_result(error_code::OUTPUT_BUFFER_TOO_SMALL, pos,
  145|      0|                           utf8_output - start);
  146|      0|      }
  147|   318k|      *utf8_output++ = char(word);
  148|   318k|      pos++;
  149|  3.33M|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (149:16): [True: 127k, False: 3.20M]
  ------------------
  150|       |      // will generate two UTF-8 bytes
  151|       |      // we have 0b110XXXXX 0b10XXXXXX
  152|   127k|      if (check_output && size_t(end - utf8_output) < 2) {
  ------------------
  |  Branch (152:11): [Folded, False: 127k]
  |  Branch (152:27): [True: 0, False: 0]
  ------------------
  153|      0|        return full_result(error_code::OUTPUT_BUFFER_TOO_SMALL, pos,
  154|      0|                           utf8_output - start);
  155|      0|      }
  156|   127k|      *utf8_output++ = char((word >> 6) | 0b11000000);
  157|   127k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  158|   127k|      pos++;
  159|       |
  160|  3.20M|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (160:16): [True: 3.20M, False: 3.75k]
  ------------------
  161|       |      // will generate three UTF-8 bytes
  162|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
  163|  3.20M|      if (check_output && size_t(end - utf8_output) < 3) {
  ------------------
  |  Branch (163:11): [Folded, False: 3.20M]
  |  Branch (163:27): [True: 0, False: 0]
  ------------------
  164|      0|        return full_result(error_code::OUTPUT_BUFFER_TOO_SMALL, pos,
  165|      0|                           utf8_output - start);
  166|      0|      }
  167|  3.20M|      *utf8_output++ = char((word >> 12) | 0b11100000);
  168|  3.20M|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  169|  3.20M|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  170|  3.20M|      pos++;
  171|  3.20M|    } else {
  172|       |
  173|  3.75k|      if (check_output && size_t(end - utf8_output) < 4) {
  ------------------
  |  Branch (173:11): [Folded, False: 3.75k]
  |  Branch (173:27): [True: 0, False: 0]
  ------------------
  174|      0|        return full_result(error_code::OUTPUT_BUFFER_TOO_SMALL, pos,
  175|      0|                           utf8_output - start);
  176|      0|      }
  177|       |      // must be a surrogate pair
  178|  3.75k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (178:11): [True: 60, False: 3.69k]
  ------------------
  179|     60|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  180|     60|      }
  181|  3.69k|      uint16_t diff = uint16_t(word - 0xD800);
  182|  3.69k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (182:11): [True: 142, False: 3.54k]
  ------------------
  183|    142|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  184|    142|      }
  185|  3.54k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (185:28): [Folded, False: 3.54k]
  ------------------
  186|  3.54k|                               ? u16_swap_bytes(data[pos + 1])
  187|  3.54k|                               : data[pos + 1];
  188|  3.54k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
  189|  3.54k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (189:11): [True: 282, False: 3.26k]
  ------------------
  190|    282|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  191|    282|      }
  192|  3.26k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
  193|       |      // will generate four UTF-8 bytes
  194|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
  195|  3.26k|      *utf8_output++ = char((value >> 18) | 0b11110000);
  196|  3.26k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  197|  3.26k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  198|  3.26k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
  199|  3.26k|      pos += 2;
  200|  3.26k|    }
  201|  3.65M|  }
  202|  1.15k|  return full_result(error_code::SUCCESS, pos, utf8_output - start);
  203|  1.64k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf819convert_with_errorsILNS_10endiannessE1ELb0EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT1_Esr7simdutf6detailE26index_assignable_from_charIT2_EEENS_11full_resultES8_mS9_m:
  101|  1.38k|                                                    size_t utf8_len = 0) {
  102|  1.38k|  if (check_output && utf8_len == 0) {
  ------------------
  |  Branch (102:7): [Folded, False: 1.38k]
  |  Branch (102:23): [True: 0, False: 0]
  ------------------
  103|      0|    return full_result(error_code::OUTPUT_BUFFER_TOO_SMALL, 0, 0);
  104|      0|  }
  105|       |
  106|  1.38k|  size_t pos = 0;
  107|  1.38k|  auto start = utf8_output;
  108|  1.38k|  auto end = utf8_output + utf8_len;
  109|       |
  110|  2.58M|  while (pos < len) {
  ------------------
  |  Branch (110:10): [True: 2.58M, False: 958]
  ------------------
  111|       |#if SIMDUTF_CPLUSPLUS23
  112|       |    if !consteval
  113|       |#endif
  114|  2.58M|    {
  115|       |      // try to convert the next block of 8 bytes
  116|  2.58M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (116:11): [True: 2.58M, False: 2.27k]
  ------------------
  117|       |                            // they are ascii
  118|  2.58M|        uint64_t v;
  119|  2.58M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
  120|       |        if constexpr (!match_system(big_endian))
  121|  2.58M|          v = (v >> 8) | (v << (64 - 8));
  122|  2.58M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (122:13): [True: 1.20M, False: 1.37M]
  ------------------
  123|  1.20M|          size_t final_pos = pos + 4;
  124|  6.04M|          while (pos < final_pos) {
  ------------------
  |  Branch (124:18): [True: 4.83M, False: 1.20M]
  ------------------
  125|  4.83M|            if (check_output && size_t(end - utf8_output) < 1) {
  ------------------
  |  Branch (125:17): [Folded, False: 4.83M]
  |  Branch (125:33): [True: 0, False: 0]
  ------------------
  126|      0|              return full_result(error_code::OUTPUT_BUFFER_TOO_SMALL, pos,
  127|      0|                                 utf8_output - start);
  128|      0|            }
  129|  4.83M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (129:30): [True: 4.83M, Folded]
  ------------------
  130|  4.83M|                                 ? char(u16_swap_bytes(data[pos]))
  131|  4.83M|                                 : char(data[pos]);
  132|  4.83M|            pos++;
  133|  4.83M|          }
  134|  1.20M|          continue;
  135|  1.20M|        }
  136|  2.58M|      }
  137|  2.58M|    }
  138|       |
  139|  1.37M|    uint16_t word =
  140|  1.37M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (140:9): [True: 1.37M, Folded]
  ------------------
  141|  1.37M|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (141:9): [True: 437k, False: 941k]
  ------------------
  142|       |      // will generate one UTF-8 bytes
  143|   437k|      if (check_output && size_t(end - utf8_output) < 1) {
  ------------------
  |  Branch (143:11): [Folded, False: 437k]
  |  Branch (143:27): [True: 0, False: 0]
  ------------------
  144|      0|        return full_result(error_code::OUTPUT_BUFFER_TOO_SMALL, pos,
  145|      0|                           utf8_output - start);
  146|      0|      }
  147|   437k|      *utf8_output++ = char(word);
  148|   437k|      pos++;
  149|   941k|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (149:16): [True: 160k, False: 780k]
  ------------------
  150|       |      // will generate two UTF-8 bytes
  151|       |      // we have 0b110XXXXX 0b10XXXXXX
  152|   160k|      if (check_output && size_t(end - utf8_output) < 2) {
  ------------------
  |  Branch (152:11): [Folded, False: 160k]
  |  Branch (152:27): [True: 0, False: 0]
  ------------------
  153|      0|        return full_result(error_code::OUTPUT_BUFFER_TOO_SMALL, pos,
  154|      0|                           utf8_output - start);
  155|      0|      }
  156|   160k|      *utf8_output++ = char((word >> 6) | 0b11000000);
  157|   160k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  158|   160k|      pos++;
  159|       |
  160|   780k|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (160:16): [True: 767k, False: 13.1k]
  ------------------
  161|       |      // will generate three UTF-8 bytes
  162|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
  163|   767k|      if (check_output && size_t(end - utf8_output) < 3) {
  ------------------
  |  Branch (163:11): [Folded, False: 767k]
  |  Branch (163:27): [True: 0, False: 0]
  ------------------
  164|      0|        return full_result(error_code::OUTPUT_BUFFER_TOO_SMALL, pos,
  165|      0|                           utf8_output - start);
  166|      0|      }
  167|   767k|      *utf8_output++ = char((word >> 12) | 0b11100000);
  168|   767k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  169|   767k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  170|   767k|      pos++;
  171|   767k|    } else {
  172|       |
  173|  13.1k|      if (check_output && size_t(end - utf8_output) < 4) {
  ------------------
  |  Branch (173:11): [Folded, False: 13.1k]
  |  Branch (173:27): [True: 0, False: 0]
  ------------------
  174|      0|        return full_result(error_code::OUTPUT_BUFFER_TOO_SMALL, pos,
  175|      0|                           utf8_output - start);
  176|      0|      }
  177|       |      // must be a surrogate pair
  178|  13.1k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (178:11): [True: 54, False: 13.0k]
  ------------------
  179|     54|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  180|     54|      }
  181|  13.0k|      uint16_t diff = uint16_t(word - 0xD800);
  182|  13.0k|      if (diff > 0x3FF) {
  ------------------
  |  Branch (182:11): [True: 134, False: 12.9k]
  ------------------
  183|    134|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  184|    134|      }
  185|  12.9k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (185:28): [True: 12.9k, Folded]
  ------------------
  186|  12.9k|                               ? u16_swap_bytes(data[pos + 1])
  187|  12.9k|                               : data[pos + 1];
  188|  12.9k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
  189|  12.9k|      if (diff2 > 0x3FF) {
  ------------------
  |  Branch (189:11): [True: 234, False: 12.7k]
  ------------------
  190|    234|        return full_result(error_code::SURROGATE, pos, utf8_output - start);
  191|    234|      }
  192|  12.7k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
  193|       |      // will generate four UTF-8 bytes
  194|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
  195|  12.7k|      *utf8_output++ = char((value >> 18) | 0b11110000);
  196|  12.7k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  197|  12.7k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  198|  12.7k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
  199|  12.7k|      pos += 2;
  200|  12.7k|    }
  201|  1.37M|  }
  202|    958|  return full_result(error_code::SUCCESS, pos, utf8_output - start);
  203|  1.38k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf813convert_validILNS_10endiannessE0EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEEmS8_mS9_:
   17|    410|                                         OutputPtr utf8_output) {
   18|    410|  size_t pos = 0;
   19|    410|  auto start = utf8_output;
   20|  5.85M|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 5.85M, False: 410]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|  5.85M|    {
   25|       |      // try to convert the next block of 4 ASCII characters
   26|  5.85M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (26:11): [True: 5.85M, False: 888]
  ------------------
   27|       |                            // they are ascii
   28|  5.85M|        uint64_t v;
   29|  5.85M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   30|       |        if constexpr (!match_system(big_endian)) {
   31|       |          v = (v >> 8) | (v << (64 - 8));
   32|       |        }
   33|  5.85M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (33:13): [True: 1.74M, False: 4.10M]
  ------------------
   34|  1.74M|          size_t final_pos = pos + 4;
   35|  8.74M|          while (pos < final_pos) {
  ------------------
  |  Branch (35:18): [True: 6.99M, False: 1.74M]
  ------------------
   36|  6.99M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (36:30): [Folded, False: 6.99M]
  ------------------
   37|  6.99M|                                 ? char(u16_swap_bytes(data[pos]))
   38|  6.99M|                                 : char(data[pos]);
   39|  6.99M|            pos++;
   40|  6.99M|          }
   41|  1.74M|          continue;
   42|  1.74M|        }
   43|  5.85M|      }
   44|  5.85M|    }
   45|       |
   46|  4.10M|    uint16_t word =
   47|  4.10M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (47:9): [Folded, False: 4.10M]
  ------------------
   48|  4.10M|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (48:9): [True: 402k, False: 3.70M]
  ------------------
   49|       |      // will generate one UTF-8 bytes
   50|   402k|      *utf8_output++ = char(word);
   51|   402k|      pos++;
   52|  3.70M|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (52:16): [True: 140k, False: 3.56M]
  ------------------
   53|       |      // will generate two UTF-8 bytes
   54|       |      // we have 0b110XXXXX 0b10XXXXXX
   55|   140k|      *utf8_output++ = char((word >> 6) | 0b11000000);
   56|   140k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   57|   140k|      pos++;
   58|  3.56M|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (58:16): [True: 3.56M, False: 2.01k]
  ------------------
   59|       |      // will generate three UTF-8 bytes
   60|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   61|  3.56M|      *utf8_output++ = char((word >> 12) | 0b11100000);
   62|  3.56M|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   63|  3.56M|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   64|  3.56M|      pos++;
   65|  3.56M|    } else {
   66|       |      // must be a surrogate pair
   67|  2.01k|      uint16_t diff = uint16_t(word - 0xD800);
   68|  2.01k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (68:11): [True: 0, False: 2.01k]
  ------------------
   69|      0|        return 0;
   70|      0|      } // minimal bound checking
   71|  2.01k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (71:28): [Folded, False: 2.01k]
  ------------------
   72|  2.01k|                               ? u16_swap_bytes(data[pos + 1])
   73|  2.01k|                               : data[pos + 1];
   74|  2.01k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   75|  2.01k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   76|       |      // will generate four UTF-8 bytes
   77|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   78|  2.01k|      *utf8_output++ = char((value >> 18) | 0b11110000);
   79|  2.01k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
   80|  2.01k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
   81|  2.01k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
   82|  2.01k|      pos += 2;
   83|  2.01k|    }
   84|  4.10M|  }
   85|    410|  return utf8_output - start;
   86|    410|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf16_to_utf813convert_validILNS_10endiannessE1EPKDsPcQaasr7simdutf6detailE18indexes_into_utf16IT0_Esr7simdutf6detailE26index_assignable_from_charIT1_EEEmS8_mS9_:
   17|    430|                                         OutputPtr utf8_output) {
   18|    430|  size_t pos = 0;
   19|    430|  auto start = utf8_output;
   20|  3.15M|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 3.15M, False: 430]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|  3.15M|    {
   25|       |      // try to convert the next block of 4 ASCII characters
   26|  3.15M|      if (pos + 4 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (26:11): [True: 3.15M, False: 830]
  ------------------
   27|       |                            // they are ascii
   28|  3.15M|        uint64_t v;
   29|  3.15M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   30|  3.15M|        if constexpr (!match_system(big_endian)) {
   31|  3.15M|          v = (v >> 8) | (v << (64 - 8));
   32|  3.15M|        }
   33|  3.15M|        if ((v & 0xFF80FF80FF80FF80) == 0) {
  ------------------
  |  Branch (33:13): [True: 1.63M, False: 1.51M]
  ------------------
   34|  1.63M|          size_t final_pos = pos + 4;
   35|  8.19M|          while (pos < final_pos) {
  ------------------
  |  Branch (35:18): [True: 6.55M, False: 1.63M]
  ------------------
   36|  6.55M|            *utf8_output++ = !match_system(big_endian)
  ------------------
  |  Branch (36:30): [True: 6.55M, Folded]
  ------------------
   37|  6.55M|                                 ? char(u16_swap_bytes(data[pos]))
   38|  6.55M|                                 : char(data[pos]);
   39|  6.55M|            pos++;
   40|  6.55M|          }
   41|  1.63M|          continue;
   42|  1.63M|        }
   43|  3.15M|      }
   44|  3.15M|    }
   45|       |
   46|  1.51M|    uint16_t word =
   47|  1.51M|        !match_system(big_endian) ? u16_swap_bytes(data[pos]) : data[pos];
  ------------------
  |  Branch (47:9): [True: 1.51M, Folded]
  ------------------
   48|  1.51M|    if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (48:9): [True: 360k, False: 1.15M]
  ------------------
   49|       |      // will generate one UTF-8 bytes
   50|   360k|      *utf8_output++ = char(word);
   51|   360k|      pos++;
   52|  1.15M|    } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (52:16): [True: 181k, False: 969k]
  ------------------
   53|       |      // will generate two UTF-8 bytes
   54|       |      // we have 0b110XXXXX 0b10XXXXXX
   55|   181k|      *utf8_output++ = char((word >> 6) | 0b11000000);
   56|   181k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   57|   181k|      pos++;
   58|   969k|    } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (58:16): [True: 960k, False: 8.80k]
  ------------------
   59|       |      // will generate three UTF-8 bytes
   60|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   61|   960k|      *utf8_output++ = char((word >> 12) | 0b11100000);
   62|   960k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   63|   960k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   64|   960k|      pos++;
   65|   960k|    } else {
   66|       |      // must be a surrogate pair
   67|  8.80k|      uint16_t diff = uint16_t(word - 0xD800);
   68|  8.80k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (68:11): [True: 0, False: 8.80k]
  ------------------
   69|      0|        return 0;
   70|      0|      } // minimal bound checking
   71|  8.80k|      uint16_t next_word = !match_system(big_endian)
  ------------------
  |  Branch (71:28): [True: 8.80k, Folded]
  ------------------
   72|  8.80k|                               ? u16_swap_bytes(data[pos + 1])
   73|  8.80k|                               : data[pos + 1];
   74|  8.80k|      uint16_t diff2 = uint16_t(next_word - 0xDC00);
   75|  8.80k|      uint32_t value = (diff << 10) + diff2 + 0x10000;
   76|       |      // will generate four UTF-8 bytes
   77|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   78|  8.80k|      *utf8_output++ = char((value >> 18) | 0b11110000);
   79|  8.80k|      *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
   80|  8.80k|      *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
   81|  8.80k|      *utf8_output++ = char((value & 0b111111) | 0b10000000);
   82|  8.80k|      pos += 2;
   83|  8.80k|    }
   84|  1.51M|  }
   85|    430|  return utf8_output - start;
   86|    430|}

_ZN7simdutf6scalar5utf328validateEPKDim:
   25|  4.92k|                                                        size_t len) noexcept {
   26|  4.92k|  return validate(reinterpret_cast<const uint32_t *>(buf), len);
   27|  4.92k|}
_ZN7simdutf6scalar5utf3220validate_with_errorsEPKDim:
   49|  6.59k|validate_with_errors(const char32_t *buf, size_t len) noexcept {
   50|  6.59k|  return validate_with_errors(reinterpret_cast<const uint32_t *>(buf), len);
   51|  6.59k|}
_ZN7simdutf6scalar5utf3222utf8_length_from_utf32EPKDim:
   54|  2.37k|                                                         size_t len) {
   55|       |  // We are not BOM aware.
   56|  2.37k|  size_t counter{0};
   57|  2.13M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (57:22): [True: 2.12M, False: 2.37k]
  ------------------
   58|       |    // credit: @ttsugriy  for the vectorizable approach
   59|  2.12M|    counter++;                                     // ASCII
   60|  2.12M|    counter += static_cast<size_t>(p[i] > 0x7F);   // two-byte
   61|  2.12M|    counter += static_cast<size_t>(p[i] > 0x7FF);  // three-byte
   62|  2.12M|    counter += static_cast<size_t>(p[i] > 0xFFFF); // four-bytes
   63|  2.12M|  }
   64|  2.37k|  return counter;
   65|  2.37k|}
_ZN7simdutf6scalar5utf3223utf16_length_from_utf32EPKDim:
   68|  3.50k|utf16_length_from_utf32(const char32_t *p, size_t len) {
   69|       |  // We are not BOM aware.
   70|  3.50k|  size_t counter{0};
   71|  3.94M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (71:22): [True: 3.94M, False: 3.50k]
  ------------------
   72|  3.94M|    counter++;                                     // non-surrogate word
   73|  3.94M|    counter += static_cast<size_t>(p[i] > 0xFFFF); // surrogate pair
   74|  3.94M|  }
   75|  3.50k|  return counter;
   76|  3.50k|}
_ZN7simdutf6scalar5utf328validateIPKjQsr7simdutf6detailE19indexes_into_uint32IT_EEEbS5_m:
   13|  4.92k|                                                      size_t len) noexcept {
   14|  4.92k|  uint64_t pos = 0;
   15|  1.97M|  for (; pos < len; pos++) {
  ------------------
  |  Branch (15:10): [True: 1.97M, False: 2.23k]
  ------------------
   16|  1.97M|    uint32_t word = data[pos];
   17|  1.97M|    if (word > 0x10FFFF || (word >= 0xD800 && word <= 0xDFFF)) {
  ------------------
  |  Branch (17:9): [True: 2.24k, False: 1.96M]
  |  Branch (17:29): [True: 28.8k, False: 1.93M]
  |  Branch (17:47): [True: 438, False: 28.3k]
  ------------------
   18|  2.68k|      return false;
   19|  2.68k|    }
   20|  1.97M|  }
   21|  2.23k|  return true;
   22|  4.92k|}
_ZN7simdutf6scalar5utf3220validate_with_errorsIPKjQsr7simdutf6detailE19indexes_into_uint32IT_EEENS_6resultES5_m:
   34|  6.59k|validate_with_errors(InputPtr data, size_t len) noexcept {
   35|  6.59k|  size_t pos = 0;
   36|  1.97M|  for (; pos < len; pos++) {
  ------------------
  |  Branch (36:10): [True: 1.97M, False: 2.21k]
  ------------------
   37|  1.97M|    uint32_t word = data[pos];
   38|  1.97M|    if (word > 0x10FFFF) {
  ------------------
  |  Branch (38:9): [True: 3.60k, False: 1.97M]
  ------------------
   39|  3.60k|      return result(error_code::TOO_LARGE, pos);
   40|  3.60k|    }
   41|  1.97M|    if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (41:9): [True: 30.0k, False: 1.94M]
  |  Branch (41:27): [True: 780, False: 29.2k]
  ------------------
   42|    780|      return result(error_code::SURROGATE, pos);
   43|    780|    }
   44|  1.97M|  }
   45|  2.21k|  return result(error_code::SUCCESS, pos);
   46|  6.59k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_115utf32_to_latin17convertEPKDimPc:
   12|    434|                                          char *latin1_output) {
   13|    434|  char *start = latin1_output;
   14|    434|  uint32_t utf32_char;
   15|    434|  size_t pos = 0;
   16|    434|  uint32_t too_large = 0;
   17|       |
   18|  2.14M|  while (pos < len) {
  ------------------
  |  Branch (18:10): [True: 2.14M, False: 434]
  ------------------
   19|  2.14M|    utf32_char = (uint32_t)data[pos];
   20|  2.14M|    too_large |= utf32_char;
   21|  2.14M|    *latin1_output++ = (char)(utf32_char & 0xFF);
   22|  2.14M|    pos++;
   23|  2.14M|  }
   24|    434|  if ((too_large & 0xFFFFFF00) != 0) {
  ------------------
  |  Branch (24:7): [True: 344, False: 90]
  ------------------
   25|    344|    return 0;
   26|    344|  }
   27|     90|  return latin1_output - start;
   28|    434|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_115utf32_to_latin119convert_with_errorsEPKDimPc:
   32|    990|                                                      char *latin1_output) {
   33|    990|  char *start{latin1_output};
   34|    990|  size_t pos = 0;
   35|   276k|  while (pos < len) {
  ------------------
  |  Branch (35:10): [True: 276k, False: 108]
  ------------------
   36|       |#if SIMDUTF_CPLUSPLUS23
   37|       |    if !consteval
   38|       |#endif
   39|   276k|    {
   40|   276k|      if (pos + 2 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (40:11): [True: 275k, False: 330]
  ------------------
   41|       |                            // they are Latin1
   42|   275k|        uint64_t v;
   43|   275k|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   44|   275k|        if ((v & 0xFFFFFF00FFFFFF00) == 0) {
  ------------------
  |  Branch (44:13): [True: 275k, False: 778]
  ------------------
   45|   275k|          *latin1_output++ = char(data[pos]);
   46|   275k|          *latin1_output++ = char(data[pos + 1]);
   47|   275k|          pos += 2;
   48|   275k|          continue;
   49|   275k|        }
   50|   275k|      }
   51|   276k|    }
   52|       |
   53|  1.10k|    uint32_t utf32_char = data[pos];
   54|  1.10k|    if ((utf32_char & 0xFFFFFF00) ==
  ------------------
  |  Branch (54:9): [True: 226, False: 882]
  ------------------
   55|  1.10k|        0) { // Check if the character can be represented in Latin-1
   56|    226|      *latin1_output++ = (char)(utf32_char & 0xFF);
   57|    226|      pos++;
   58|    882|    } else {
   59|    882|      return result(error_code::TOO_LARGE, pos);
   60|    882|    };
   61|    226|  }
   62|    108|  return result(error_code::SUCCESS, latin1_output - start);
   63|    990|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf32_to_utf167convertILNS_10endiannessE0EEEmPKDimPDs:
   11|  1.47k|                                   char16_t *utf16_output) {
   12|  1.47k|  size_t pos = 0;
   13|  1.47k|  char16_t *start{utf16_output};
   14|   416k|  while (pos < len) {
  ------------------
  |  Branch (14:10): [True: 416k, False: 778]
  ------------------
   15|   416k|    uint32_t word = data[pos];
   16|   416k|    if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (16:9): [True: 406k, False: 9.56k]
  ------------------
   17|   406k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (17:11): [True: 1.65k, False: 404k]
  |  Branch (17:29): [True: 154, False: 1.50k]
  ------------------
   18|    154|        return 0;
   19|    154|      }
   20|       |      // will not generate a surrogate pair
   21|   406k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (21:25): [Folded, False: 406k]
  ------------------
   22|   406k|                            ? char16_t(u16_swap_bytes(uint16_t(word)))
   23|   406k|                            : char16_t(word);
   24|   406k|    } else {
   25|       |      // will generate a surrogate pair
   26|  9.56k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (26:11): [True: 538, False: 9.02k]
  ------------------
   27|    538|        return 0;
   28|    538|      }
   29|  9.02k|      word -= 0x10000;
   30|  9.02k|      uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   31|  9.02k|      uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
   32|       |      if constexpr (!match_system(big_endian)) {
   33|       |        high_surrogate = u16_swap_bytes(high_surrogate);
   34|       |        low_surrogate = u16_swap_bytes(low_surrogate);
   35|       |      }
   36|  9.02k|      *utf16_output++ = char16_t(high_surrogate);
   37|  9.02k|      *utf16_output++ = char16_t(low_surrogate);
   38|  9.02k|    }
   39|   415k|    pos++;
   40|   415k|  }
   41|    778|  return utf16_output - start;
   42|  1.47k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf32_to_utf167convertILNS_10endiannessE1EEEmPKDimPDs:
   11|  1.18k|                                   char16_t *utf16_output) {
   12|  1.18k|  size_t pos = 0;
   13|  1.18k|  char16_t *start{utf16_output};
   14|  11.8k|  while (pos < len) {
  ------------------
  |  Branch (14:10): [True: 11.3k, False: 570]
  ------------------
   15|  11.3k|    uint32_t word = data[pos];
   16|  11.3k|    if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (16:9): [True: 6.87k, False: 4.44k]
  ------------------
   17|  6.87k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (17:11): [True: 1.30k, False: 5.57k]
  |  Branch (17:29): [True: 116, False: 1.18k]
  ------------------
   18|    116|        return 0;
   19|    116|      }
   20|       |      // will not generate a surrogate pair
   21|  6.76k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (21:25): [True: 6.76k, Folded]
  ------------------
   22|  6.76k|                            ? char16_t(u16_swap_bytes(uint16_t(word)))
   23|  6.76k|                            : char16_t(word);
   24|  6.76k|    } else {
   25|       |      // will generate a surrogate pair
   26|  4.44k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (26:11): [True: 496, False: 3.95k]
  ------------------
   27|    496|        return 0;
   28|    496|      }
   29|  3.95k|      word -= 0x10000;
   30|  3.95k|      uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   31|  3.95k|      uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
   32|  3.95k|      if constexpr (!match_system(big_endian)) {
   33|  3.95k|        high_surrogate = u16_swap_bytes(high_surrogate);
   34|  3.95k|        low_surrogate = u16_swap_bytes(low_surrogate);
   35|  3.95k|      }
   36|  3.95k|      *utf16_output++ = char16_t(high_surrogate);
   37|  3.95k|      *utf16_output++ = char16_t(low_surrogate);
   38|  3.95k|    }
   39|  10.7k|    pos++;
   40|  10.7k|  }
   41|    570|  return utf16_output - start;
   42|  1.18k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf32_to_utf1619convert_with_errorsILNS_10endiannessE0EEENS_6resultEPKDimPDs:
   46|  1.84k|                                               char16_t *utf16_output) {
   47|  1.84k|  size_t pos = 0;
   48|  1.84k|  char16_t *start{utf16_output};
   49|  19.2k|  while (pos < len) {
  ------------------
  |  Branch (49:10): [True: 18.7k, False: 520]
  ------------------
   50|  18.7k|    uint32_t word = data[pos];
   51|  18.7k|    if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (51:9): [True: 14.5k, False: 4.23k]
  ------------------
   52|  14.5k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (52:11): [True: 1.44k, False: 13.0k]
  |  Branch (52:29): [True: 300, False: 1.14k]
  ------------------
   53|    300|        return result(error_code::SURROGATE, pos);
   54|    300|      }
   55|       |      // will not generate a surrogate pair
   56|  14.2k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (56:25): [Folded, False: 14.2k]
  ------------------
   57|  14.2k|                            ? char16_t(u16_swap_bytes(uint16_t(word)))
   58|  14.2k|                            : char16_t(word);
   59|  14.2k|    } else {
   60|       |      // will generate a surrogate pair
   61|  4.23k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (61:11): [True: 1.02k, False: 3.21k]
  ------------------
   62|  1.02k|        return result(error_code::TOO_LARGE, pos);
   63|  1.02k|      }
   64|  3.21k|      word -= 0x10000;
   65|  3.21k|      uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   66|  3.21k|      uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
   67|       |      if constexpr (!match_system(big_endian)) {
   68|       |        high_surrogate = u16_swap_bytes(high_surrogate);
   69|       |        low_surrogate = u16_swap_bytes(low_surrogate);
   70|       |      }
   71|  3.21k|      *utf16_output++ = char16_t(high_surrogate);
   72|  3.21k|      *utf16_output++ = char16_t(low_surrogate);
   73|  3.21k|    }
   74|  17.4k|    pos++;
   75|  17.4k|  }
   76|    520|  return result(error_code::SUCCESS, utf16_output - start);
   77|  1.84k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf32_to_utf1619convert_with_errorsILNS_10endiannessE1EEENS_6resultEPKDimPDs:
   46|  1.68k|                                               char16_t *utf16_output) {
   47|  1.68k|  size_t pos = 0;
   48|  1.68k|  char16_t *start{utf16_output};
   49|  11.5k|  while (pos < len) {
  ------------------
  |  Branch (49:10): [True: 11.1k, False: 436]
  ------------------
   50|  11.1k|    uint32_t word = data[pos];
   51|  11.1k|    if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (51:9): [True: 7.26k, False: 3.85k]
  ------------------
   52|  7.26k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (52:11): [True: 1.79k, False: 5.47k]
  |  Branch (52:29): [True: 252, False: 1.53k]
  ------------------
   53|    252|        return result(error_code::SURROGATE, pos);
   54|    252|      }
   55|       |      // will not generate a surrogate pair
   56|  7.01k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (56:25): [True: 7.01k, Folded]
  ------------------
   57|  7.01k|                            ? char16_t(u16_swap_bytes(uint16_t(word)))
   58|  7.01k|                            : char16_t(word);
   59|  7.01k|    } else {
   60|       |      // will generate a surrogate pair
   61|  3.85k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (61:11): [True: 996, False: 2.86k]
  ------------------
   62|    996|        return result(error_code::TOO_LARGE, pos);
   63|    996|      }
   64|  2.86k|      word -= 0x10000;
   65|  2.86k|      uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   66|  2.86k|      uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
   67|  2.86k|      if constexpr (!match_system(big_endian)) {
   68|  2.86k|        high_surrogate = u16_swap_bytes(high_surrogate);
   69|  2.86k|        low_surrogate = u16_swap_bytes(low_surrogate);
   70|  2.86k|      }
   71|  2.86k|      *utf16_output++ = char16_t(high_surrogate);
   72|  2.86k|      *utf16_output++ = char16_t(low_surrogate);
   73|  2.86k|    }
   74|  9.87k|    pos++;
   75|  9.87k|  }
   76|    436|  return result(error_code::SUCCESS, utf16_output - start);
   77|  1.68k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf32_to_utf1613convert_validILNS_10endiannessE0EEEmPKDimPDs:
   11|    222|                                         char16_t *utf16_output) {
   12|    222|  size_t pos = 0;
   13|    222|  char16_t *start{utf16_output};
   14|  2.24M|  while (pos < len) {
  ------------------
  |  Branch (14:10): [True: 2.24M, False: 222]
  ------------------
   15|  2.24M|    uint32_t word = data[pos];
   16|  2.24M|    if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (16:9): [True: 2.23M, False: 8.57k]
  ------------------
   17|       |      // will not generate a surrogate pair
   18|  2.23M|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (18:25): [Folded, False: 2.23M]
  ------------------
   19|  2.23M|                            ? char16_t(u16_swap_bytes(uint16_t(word)))
   20|  2.23M|                            : char16_t(word);
   21|  2.23M|      pos++;
   22|  2.23M|    } else {
   23|       |      // will generate a surrogate pair
   24|  8.57k|      word -= 0x10000;
   25|  8.57k|      uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   26|  8.57k|      uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
   27|       |      if constexpr (!match_system(big_endian)) {
   28|       |        high_surrogate = u16_swap_bytes(high_surrogate);
   29|       |        low_surrogate = u16_swap_bytes(low_surrogate);
   30|       |      }
   31|  8.57k|      *utf16_output++ = char16_t(high_surrogate);
   32|  8.57k|      *utf16_output++ = char16_t(low_surrogate);
   33|  8.57k|      pos++;
   34|  8.57k|    }
   35|  2.24M|  }
   36|    222|  return utf16_output - start;
   37|    222|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf32_to_utf1613convert_validILNS_10endiannessE1EEEmPKDimPDs:
   11|     72|                                         char16_t *utf16_output) {
   12|     72|  size_t pos = 0;
   13|     72|  char16_t *start{utf16_output};
   14|  3.56k|  while (pos < len) {
  ------------------
  |  Branch (14:10): [True: 3.49k, False: 72]
  ------------------
   15|  3.49k|    uint32_t word = data[pos];
   16|  3.49k|    if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (16:9): [True: 1.39k, False: 2.09k]
  ------------------
   17|       |      // will not generate a surrogate pair
   18|  1.39k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (18:25): [True: 1.39k, Folded]
  ------------------
   19|  1.39k|                            ? char16_t(u16_swap_bytes(uint16_t(word)))
   20|  1.39k|                            : char16_t(word);
   21|  1.39k|      pos++;
   22|  2.09k|    } else {
   23|       |      // will generate a surrogate pair
   24|  2.09k|      word -= 0x10000;
   25|  2.09k|      uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   26|  2.09k|      uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
   27|  2.09k|      if constexpr (!match_system(big_endian)) {
   28|  2.09k|        high_surrogate = u16_swap_bytes(high_surrogate);
   29|  2.09k|        low_surrogate = u16_swap_bytes(low_surrogate);
   30|  2.09k|      }
   31|  2.09k|      *utf16_output++ = char16_t(high_surrogate);
   32|  2.09k|      *utf16_output++ = char16_t(low_surrogate);
   33|  2.09k|      pos++;
   34|  2.09k|    }
   35|  3.49k|  }
   36|     72|  return utf16_output - start;
   37|     72|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf32_to_utf87convertIPKDiPcQaasr7simdutf6detailE18indexes_into_utf32IT_Esr7simdutf6detailE26index_assignable_from_charIT0_EEEmS7_mS8_:
   17|  1.64k|                                   OutputPtr utf8_output) {
   18|  1.64k|  size_t pos = 0;
   19|  1.64k|  auto start = utf8_output;
   20|   235k|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 234k, False: 644]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|   234k|    { // try to convert the next block of 2 ASCII characters
   25|   234k|      if (pos + 2 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (25:11): [True: 234k, False: 872]
  ------------------
   26|       |                            // they are ascii
   27|   234k|        uint64_t v;
   28|   234k|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   29|   234k|        if ((v & 0xFFFFFF80FFFFFF80) == 0) {
  ------------------
  |  Branch (29:13): [True: 210k, False: 23.4k]
  ------------------
   30|   210k|          *utf8_output++ = char(data[pos]);
   31|   210k|          *utf8_output++ = char(data[pos + 1]);
   32|   210k|          pos += 2;
   33|   210k|          continue;
   34|   210k|        }
   35|   234k|      }
   36|   234k|    }
   37|       |
   38|  24.3k|    uint32_t word = data[pos];
   39|  24.3k|    if ((word & 0xFFFFFF80) == 0) {
  ------------------
  |  Branch (39:9): [True: 3.67k, False: 20.6k]
  ------------------
   40|       |      // will generate one UTF-8 bytes
   41|  3.67k|      *utf8_output++ = char(word);
   42|  3.67k|      pos++;
   43|  20.6k|    } else if ((word & 0xFFFFF800) == 0) {
  ------------------
  |  Branch (43:16): [True: 8.53k, False: 12.1k]
  ------------------
   44|       |      // will generate two UTF-8 bytes
   45|       |      // we have 0b110XXXXX 0b10XXXXXX
   46|  8.53k|      *utf8_output++ = char((word >> 6) | 0b11000000);
   47|  8.53k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   48|  8.53k|      pos++;
   49|  12.1k|    } else if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (49:16): [True: 8.44k, False: 3.68k]
  ------------------
   50|       |      // will generate three UTF-8 bytes
   51|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   52|  8.44k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (52:11): [True: 5.91k, False: 2.53k]
  |  Branch (52:29): [True: 174, False: 5.74k]
  ------------------
   53|    174|        return 0;
   54|    174|      }
   55|  8.27k|      *utf8_output++ = char((word >> 12) | 0b11100000);
   56|  8.27k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   57|  8.27k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   58|  8.27k|      pos++;
   59|  8.27k|    } else {
   60|       |      // will generate four UTF-8 bytes
   61|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   62|  3.68k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (62:11): [True: 828, False: 2.85k]
  ------------------
   63|    828|        return 0;
   64|    828|      }
   65|  2.85k|      *utf8_output++ = char((word >> 18) | 0b11110000);
   66|  2.85k|      *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000);
   67|  2.85k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   68|  2.85k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   69|  2.85k|      pos++;
   70|  2.85k|    }
   71|  24.3k|  }
   72|    644|  return utf8_output - start;
   73|  1.64k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf32_to_utf819convert_with_errorsIPKDiPcQaasr7simdutf6detailE18indexes_into_utf32IT_Esr7simdutf6detailE26index_assignable_from_charIT0_EEENS_6resultES7_mS8_:
   81|  2.30k|                                               OutputPtr utf8_output) {
   82|  2.30k|  size_t pos = 0;
   83|  2.30k|  auto start = utf8_output;
   84|  47.8k|  while (pos < len) {
  ------------------
  |  Branch (84:10): [True: 47.2k, False: 628]
  ------------------
   85|       |#if SIMDUTF_CPLUSPLUS23
   86|       |    if !consteval
   87|       |#endif
   88|  47.2k|    { // try to convert the next block of 2 ASCII characters
   89|  47.2k|      if (pos + 2 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (89:11): [True: 46.2k, False: 954]
  ------------------
   90|       |                            // they are ascii
   91|  46.2k|        uint64_t v;
   92|  46.2k|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   93|  46.2k|        if ((v & 0xFFFFFF80FFFFFF80) == 0) {
  ------------------
  |  Branch (93:13): [True: 12.8k, False: 33.3k]
  ------------------
   94|  12.8k|          *utf8_output++ = char(data[pos]);
   95|  12.8k|          *utf8_output++ = char(data[pos + 1]);
   96|  12.8k|          pos += 2;
   97|  12.8k|          continue;
   98|  12.8k|        }
   99|  46.2k|      }
  100|  47.2k|    }
  101|       |
  102|  34.3k|    uint32_t word = data[pos];
  103|  34.3k|    if ((word & 0xFFFFFF80) == 0) {
  ------------------
  |  Branch (103:9): [True: 3.13k, False: 31.1k]
  ------------------
  104|       |      // will generate one UTF-8 bytes
  105|  3.13k|      *utf8_output++ = char(word);
  106|  3.13k|      pos++;
  107|  31.1k|    } else if ((word & 0xFFFFF800) == 0) {
  ------------------
  |  Branch (107:16): [True: 15.3k, False: 15.8k]
  ------------------
  108|       |      // will generate two UTF-8 bytes
  109|       |      // we have 0b110XXXXX 0b10XXXXXX
  110|  15.3k|      *utf8_output++ = char((word >> 6) | 0b11000000);
  111|  15.3k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  112|  15.3k|      pos++;
  113|  15.8k|    } else if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (113:16): [True: 8.16k, False: 7.65k]
  ------------------
  114|       |      // will generate three UTF-8 bytes
  115|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
  116|  8.16k|      if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (116:11): [True: 5.77k, False: 2.39k]
  |  Branch (116:29): [True: 312, False: 5.46k]
  ------------------
  117|    312|        return result(error_code::SURROGATE, pos);
  118|    312|      }
  119|  7.85k|      *utf8_output++ = char((word >> 12) | 0b11100000);
  120|  7.85k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  121|  7.85k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  122|  7.85k|      pos++;
  123|  7.85k|    } else {
  124|       |      // will generate four UTF-8 bytes
  125|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
  126|  7.65k|      if (word > 0x10FFFF) {
  ------------------
  |  Branch (126:11): [True: 1.36k, False: 6.28k]
  ------------------
  127|  1.36k|        return result(error_code::TOO_LARGE, pos);
  128|  1.36k|      }
  129|  6.28k|      *utf8_output++ = char((word >> 18) | 0b11110000);
  130|  6.28k|      *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000);
  131|  6.28k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  132|  6.28k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
  133|  6.28k|      pos++;
  134|  6.28k|    }
  135|  34.3k|  }
  136|    628|  return result(error_code::SUCCESS, utf8_output - start);
  137|  2.30k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf32_to_utf813convert_validIPKDiPcQaasr7simdutf6detailE18indexes_into_utf32IT_Esr7simdutf6detailE26index_assignable_from_charIT0_EEEmS7_mS8_:
   17|    202|                                         OutputPtr utf8_output) {
   18|    202|  size_t pos = 0;
   19|    202|  auto start = utf8_output;
   20|  68.2k|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 68.0k, False: 202]
  ------------------
   21|       |#if SIMDUTF_CPLUSPLUS23
   22|       |    if !consteval
   23|       |#endif
   24|  68.0k|    { // try to convert the next block of 2 ASCII characters
   25|  68.0k|      if (pos + 2 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (25:11): [True: 67.9k, False: 178]
  ------------------
   26|       |                            // they are ascii
   27|  67.9k|        uint64_t v;
   28|  67.9k|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   29|  67.9k|        if ((v & 0xFFFFFF80FFFFFF80) == 0) {
  ------------------
  |  Branch (29:13): [True: 51.1k, False: 16.8k]
  ------------------
   30|  51.1k|          *utf8_output++ = char(data[pos]);
   31|  51.1k|          *utf8_output++ = char(data[pos + 1]);
   32|  51.1k|          pos += 2;
   33|  51.1k|          continue;
   34|  51.1k|        }
   35|  67.9k|      }
   36|  68.0k|    }
   37|       |
   38|  16.9k|    uint32_t word = data[pos];
   39|  16.9k|    if ((word & 0xFFFFFF80) == 0) {
  ------------------
  |  Branch (39:9): [True: 1.17k, False: 15.8k]
  ------------------
   40|       |      // will generate one UTF-8 bytes
   41|  1.17k|      *utf8_output++ = char(word);
   42|  1.17k|      pos++;
   43|  15.8k|    } else if ((word & 0xFFFFF800) == 0) {
  ------------------
  |  Branch (43:16): [True: 8.58k, False: 7.22k]
  ------------------
   44|       |      // will generate two UTF-8 bytes
   45|       |      // we have 0b110XXXXX 0b10XXXXXX
   46|  8.58k|      *utf8_output++ = char((word >> 6) | 0b11000000);
   47|  8.58k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   48|  8.58k|      pos++;
   49|  8.58k|    } else if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (49:16): [True: 2.12k, False: 5.09k]
  ------------------
   50|       |      // will generate three UTF-8 bytes
   51|       |      // we have 0b1110XXXX 0b10XXXXXX 0b10XXXXXX
   52|  2.12k|      *utf8_output++ = char((word >> 12) | 0b11100000);
   53|  2.12k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   54|  2.12k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   55|  2.12k|      pos++;
   56|  5.09k|    } else {
   57|       |      // will generate four UTF-8 bytes
   58|       |      // we have 0b11110XXX 0b10XXXXXX 0b10XXXXXX 0b10XXXXXX
   59|  5.09k|      *utf8_output++ = char((word >> 18) | 0b11110000);
   60|  5.09k|      *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000);
   61|  5.09k|      *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
   62|  5.09k|      *utf8_output++ = char((word & 0b111111) | 0b10000000);
   63|  5.09k|      pos++;
   64|  5.09k|    }
   65|  16.9k|  }
   66|    202|  return utf8_output - start;
   67|    202|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf88validateEPKcm:
  113|  4.44k|                                                        size_t len) noexcept {
  114|  4.44k|  return validate(reinterpret_cast<const uint8_t *>(buf), len);
  115|  4.44k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf88validateIPKhEEbT_m:
   14|  4.44k|                                                      size_t len) noexcept {
   15|  4.44k|  static_assert(
   16|  4.44k|      std::is_same<typename std::decay<decltype(*data)>::type, uint8_t>::value,
   17|  4.44k|      "dereferencing the data pointer must result in a uint8_t");
   18|  4.44k|  uint64_t pos = 0;
   19|  4.44k|  uint32_t code_point = 0;
   20|  12.4M|  while (pos < len) {
  ------------------
  |  Branch (20:10): [True: 12.4M, False: 736]
  ------------------
   21|  12.4M|    uint64_t next_pos;
   22|       |#if SIMDUTF_CPLUSPLUS23
   23|       |    if !consteval
   24|       |#endif
   25|  12.4M|    { // check if the next 16 bytes are ascii.
   26|  12.4M|      next_pos = pos + 16;
   27|  12.4M|      if (next_pos <= len) { // if it is safe to read 16 more bytes, check
  ------------------
  |  Branch (27:11): [True: 12.4M, False: 4.39k]
  ------------------
   28|       |                             // that they are ascii
   29|  12.4M|        uint64_t v1{};
   30|  12.4M|        std::memcpy(&v1, data + pos, sizeof(uint64_t));
   31|  12.4M|        uint64_t v2{};
   32|  12.4M|        std::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   33|  12.4M|        uint64_t v{v1 | v2};
   34|  12.4M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (34:13): [True: 10.8M, False: 1.58M]
  ------------------
   35|  10.8M|          pos = next_pos;
   36|  10.8M|          continue;
   37|  10.8M|        }
   38|  12.4M|      }
   39|  12.4M|    }
   40|       |
   41|  1.58M|    unsigned char byte = data[pos];
   42|       |
   43|  8.51M|    while (byte < 0b10000000) {
  ------------------
  |  Branch (43:12): [True: 6.92M, False: 1.58M]
  ------------------
   44|  6.92M|      if (++pos == len) {
  ------------------
  |  Branch (44:11): [True: 1.41k, False: 6.92M]
  ------------------
   45|  1.41k|        return true;
   46|  1.41k|      }
   47|  6.92M|      byte = data[pos];
   48|  6.92M|    }
   49|       |
   50|  1.58M|    if ((byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (50:9): [True: 1.01M, False: 571k]
  ------------------
   51|  1.01M|      next_pos = pos + 2;
   52|  1.01M|      if (next_pos > len) {
  ------------------
  |  Branch (52:11): [True: 98, False: 1.01M]
  ------------------
   53|     98|        return false;
   54|     98|      }
   55|  1.01M|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (55:11): [True: 331, False: 1.01M]
  ------------------
   56|    331|        return false;
   57|    331|      }
   58|       |      // range check
   59|  1.01M|      code_point = (byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111);
   60|  1.01M|      if (code_point < 0x80) {
  ------------------
  |  Branch (60:11): [True: 44, False: 1.01M]
  ------------------
   61|     44|        return false;
   62|     44|      }
   63|  1.01M|    } else if ((byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (63:16): [True: 479k, False: 91.8k]
  ------------------
   64|   479k|      next_pos = pos + 3;
   65|   479k|      if (next_pos > len) {
  ------------------
  |  Branch (65:11): [True: 56, False: 479k]
  ------------------
   66|     56|        return false;
   67|     56|      }
   68|   479k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (68:11): [True: 152, False: 479k]
  ------------------
   69|    152|        return false;
   70|    152|      }
   71|   479k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (71:11): [True: 60, False: 479k]
  ------------------
   72|     60|        return false;
   73|     60|      }
   74|       |      // range check
   75|   479k|      code_point = (byte & 0b00001111) << 12 |
   76|   479k|                   (data[pos + 1] & 0b00111111) << 6 |
   77|   479k|                   (data[pos + 2] & 0b00111111);
   78|   479k|      if ((code_point < 0x800) ||
  ------------------
  |  Branch (78:11): [True: 40, False: 479k]
  ------------------
   79|   479k|          (0xd7ff < code_point && code_point < 0xe000)) {
  ------------------
  |  Branch (79:12): [True: 11.3k, False: 468k]
  |  Branch (79:35): [True: 14, False: 11.2k]
  ------------------
   80|     54|        return false;
   81|     54|      }
   82|   479k|    } else if ((byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (82:16): [True: 90.6k, False: 1.20k]
  ------------------
   83|  90.6k|      next_pos = pos + 4;
   84|  90.6k|      if (next_pos > len) {
  ------------------
  |  Branch (84:11): [True: 40, False: 90.5k]
  ------------------
   85|     40|        return false;
   86|     40|      }
   87|  90.5k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (87:11): [True: 96, False: 90.4k]
  ------------------
   88|     96|        return false;
   89|     96|      }
   90|  90.4k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (90:11): [True: 51, False: 90.4k]
  ------------------
   91|     51|        return false;
   92|     51|      }
   93|  90.4k|      if ((data[pos + 3] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (93:11): [True: 40, False: 90.3k]
  ------------------
   94|     40|        return false;
   95|     40|      }
   96|       |      // range check
   97|  90.3k|      code_point =
   98|  90.3k|          (byte & 0b00000111) << 18 | (data[pos + 1] & 0b00111111) << 12 |
   99|  90.3k|          (data[pos + 2] & 0b00111111) << 6 | (data[pos + 3] & 0b00111111);
  100|  90.3k|      if (code_point <= 0xffff || 0x10ffff < code_point) {
  ------------------
  |  Branch (100:11): [True: 27, False: 90.3k]
  |  Branch (100:35): [True: 35, False: 90.3k]
  ------------------
  101|     62|        return false;
  102|     62|      }
  103|  90.3k|    } else {
  104|       |      // we may have a continuation
  105|  1.20k|      return false;
  106|  1.20k|    }
  107|  1.58M|    pos = next_pos;
  108|  1.58M|  }
  109|    736|  return true;
  110|  4.44k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf820validate_with_errorsEPKcm:
  221|  8.73k|validate_with_errors(const char *buf, size_t len) noexcept {
  222|  8.73k|  return validate_with_errors(reinterpret_cast<const uint8_t *>(buf), len);
  223|  8.73k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf820validate_with_errorsIPKhEENS_6resultET_m:
  119|  8.73k|validate_with_errors(BytePtr data, size_t len) noexcept {
  120|  8.73k|  static_assert(
  121|  8.73k|      std::is_same<typename std::decay<decltype(*data)>::type, uint8_t>::value,
  122|  8.73k|      "dereferencing the data pointer must result in a uint8_t");
  123|  8.73k|  size_t pos = 0;
  124|  8.73k|  uint32_t code_point = 0;
  125|  12.4M|  while (pos < len) {
  ------------------
  |  Branch (125:10): [True: 12.4M, False: 736]
  ------------------
  126|       |    // check of the next 16 bytes are ascii.
  127|  12.4M|    size_t next_pos = pos + 16;
  128|  12.4M|    if (next_pos <=
  ------------------
  |  Branch (128:9): [True: 12.4M, False: 6.63k]
  ------------------
  129|  12.4M|        len) { // if it is safe to read 16 more bytes, check that they are ascii
  130|  12.4M|      uint64_t v1;
  131|  12.4M|      std::memcpy(&v1, data + pos, sizeof(uint64_t));
  132|  12.4M|      uint64_t v2;
  133|  12.4M|      std::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  134|  12.4M|      uint64_t v{v1 | v2};
  135|  12.4M|      if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (135:11): [True: 10.8M, False: 1.58M]
  ------------------
  136|  10.8M|        pos = next_pos;
  137|  10.8M|        continue;
  138|  10.8M|      }
  139|  12.4M|    }
  140|  1.59M|    unsigned char byte = data[pos];
  141|       |
  142|  8.54M|    while (byte < 0b10000000) {
  ------------------
  |  Branch (142:12): [True: 6.95M, False: 1.59M]
  ------------------
  143|  6.95M|      if (++pos == len) {
  ------------------
  |  Branch (143:11): [True: 1.41k, False: 6.95M]
  ------------------
  144|  1.41k|        return result(error_code::SUCCESS, len);
  145|  1.41k|      }
  146|  6.95M|      byte = data[pos];
  147|  6.95M|    }
  148|       |
  149|  1.59M|    if ((byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (149:9): [True: 1.01M, False: 576k]
  ------------------
  150|  1.01M|      next_pos = pos + 2;
  151|  1.01M|      if (next_pos > len) {
  ------------------
  |  Branch (151:11): [True: 294, False: 1.01M]
  ------------------
  152|    294|        return result(error_code::TOO_SHORT, pos);
  153|    294|      }
  154|  1.01M|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (154:11): [True: 993, False: 1.01M]
  ------------------
  155|    993|        return result(error_code::TOO_SHORT, pos);
  156|    993|      }
  157|       |      // range check
  158|  1.01M|      code_point = (byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111);
  159|  1.01M|      if (code_point < 0x80) {
  ------------------
  |  Branch (159:11): [True: 132, False: 1.01M]
  ------------------
  160|    132|        return result(error_code::OVERLONG, pos);
  161|    132|      }
  162|  1.01M|    } else if ((byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (162:16): [True: 481k, False: 95.0k]
  ------------------
  163|   481k|      next_pos = pos + 3;
  164|   481k|      if (next_pos > len) {
  ------------------
  |  Branch (164:11): [True: 168, False: 481k]
  ------------------
  165|    168|        return result(error_code::TOO_SHORT, pos);
  166|    168|      }
  167|   481k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (167:11): [True: 456, False: 481k]
  ------------------
  168|    456|        return result(error_code::TOO_SHORT, pos);
  169|    456|      }
  170|   481k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (170:11): [True: 180, False: 481k]
  ------------------
  171|    180|        return result(error_code::TOO_SHORT, pos);
  172|    180|      }
  173|       |      // range check
  174|   481k|      code_point = (byte & 0b00001111) << 12 |
  175|   481k|                   (data[pos + 1] & 0b00111111) << 6 |
  176|   481k|                   (data[pos + 2] & 0b00111111);
  177|   481k|      if (code_point < 0x800) {
  ------------------
  |  Branch (177:11): [True: 120, False: 480k]
  ------------------
  178|    120|        return result(error_code::OVERLONG, pos);
  179|    120|      }
  180|   480k|      if (0xd7ff < code_point && code_point < 0xe000) {
  ------------------
  |  Branch (180:11): [True: 12.3k, False: 468k]
  |  Branch (180:34): [True: 42, False: 12.3k]
  ------------------
  181|     42|        return result(error_code::SURROGATE, pos);
  182|     42|      }
  183|   480k|    } else if ((byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (183:16): [True: 91.7k, False: 3.33k]
  ------------------
  184|  91.7k|      next_pos = pos + 4;
  185|  91.7k|      if (next_pos > len) {
  ------------------
  |  Branch (185:11): [True: 120, False: 91.6k]
  ------------------
  186|    120|        return result(error_code::TOO_SHORT, pos);
  187|    120|      }
  188|  91.6k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (188:11): [True: 288, False: 91.3k]
  ------------------
  189|    288|        return result(error_code::TOO_SHORT, pos);
  190|    288|      }
  191|  91.3k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (191:11): [True: 153, False: 91.2k]
  ------------------
  192|    153|        return result(error_code::TOO_SHORT, pos);
  193|    153|      }
  194|  91.2k|      if ((data[pos + 3] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (194:11): [True: 120, False: 91.0k]
  ------------------
  195|    120|        return result(error_code::TOO_SHORT, pos);
  196|    120|      }
  197|       |      // range check
  198|  91.0k|      code_point =
  199|  91.0k|          (byte & 0b00000111) << 18 | (data[pos + 1] & 0b00111111) << 12 |
  200|  91.0k|          (data[pos + 2] & 0b00111111) << 6 | (data[pos + 3] & 0b00111111);
  201|  91.0k|      if (code_point <= 0xffff) {
  ------------------
  |  Branch (201:11): [True: 81, False: 90.9k]
  ------------------
  202|     81|        return result(error_code::OVERLONG, pos);
  203|     81|      }
  204|  90.9k|      if (0x10ffff < code_point) {
  ------------------
  |  Branch (204:11): [True: 105, False: 90.8k]
  ------------------
  205|    105|        return result(error_code::TOO_LARGE, pos);
  206|    105|      }
  207|  90.9k|    } else {
  208|       |      // we either have too many continuation bytes or an invalid leading byte
  209|  3.33k|      if ((byte & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (209:11): [True: 1.72k, False: 1.60k]
  ------------------
  210|  1.72k|        return result(error_code::TOO_LONG, pos);
  211|  1.72k|      } else {
  212|  1.60k|        return result(error_code::HEADER_BITS, pos);
  213|  1.60k|      }
  214|  3.33k|    }
  215|  1.58M|    pos = next_pos;
  216|  1.58M|  }
  217|    736|  return result(error_code::SUCCESS, len);
  218|  8.73k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf831rewind_and_validate_with_errorsEPKcS4_m:
  232|  4.58k|    const char *start, const char *buf, size_t len) noexcept {
  233|       |  // First check that we start with a leading byte
  234|  4.58k|  if ((*start & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (234:7): [True: 288, False: 4.29k]
  ------------------
  235|    288|    return result(error_code::TOO_LONG, 0);
  236|    288|  }
  237|  4.29k|  size_t extra_len{0};
  238|       |  // A leading byte cannot be further than 4 bytes away
  239|  4.63k|  for (int i = 0; i < 5; i++) {
  ------------------
  |  Branch (239:19): [True: 4.63k, False: 0]
  ------------------
  240|  4.63k|    unsigned char byte = *buf;
  241|  4.63k|    if ((byte & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (241:9): [True: 4.29k, False: 338]
  ------------------
  242|  4.29k|      break;
  243|  4.29k|    } else {
  244|    338|      buf--;
  245|    338|      extra_len++;
  246|    338|    }
  247|  4.63k|  }
  248|       |
  249|  4.29k|  result res = validate_with_errors(buf, len + extra_len);
  250|  4.29k|  res.count -= extra_len; // Might underflow
  251|  4.29k|  return res;
  252|  4.58k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf817count_code_pointsIPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEEmS6_m:
  454|  20.5k|simdutf_constexpr23 size_t count_code_points(InputPtr data, size_t len) {
  455|  20.5k|  size_t counter{0};
  456|   319M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (456:22): [True: 319M, False: 20.5k]
  ------------------
  457|       |    // -65 is 0b10111111, anything larger in two-complement's should start a new
  458|       |    // code point.
  459|   319M|    if (int8_t(data[i]) > -65) {
  ------------------
  |  Branch (459:9): [True: 315M, False: 3.87M]
  ------------------
  460|   315M|      counter++;
  461|   315M|    }
  462|   319M|  }
  463|  20.5k|  return counter;
  464|  20.5k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_14utf822utf16_length_from_utf8IPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEEmS6_m:
  470|  7.72k|simdutf_constexpr23 size_t utf16_length_from_utf8(InputPtr data, size_t len) {
  471|  7.72k|  size_t counter{0};
  472|   127M|  for (size_t i = 0; i < len; i++) {
  ------------------
  |  Branch (472:22): [True: 127M, False: 7.72k]
  ------------------
  473|   127M|    if (int8_t(data[i]) > -65) {
  ------------------
  |  Branch (473:9): [True: 126M, False: 1.97M]
  ------------------
  474|   126M|      counter++;
  475|   126M|    }
  476|   127M|    if (uint8_t(data[i]) >= 240) {
  ------------------
  |  Branch (476:9): [True: 140k, False: 127M]
  ------------------
  477|   140k|      counter++;
  478|   140k|    }
  479|   127M|  }
  480|  7.72k|  return counter;
  481|  7.72k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf8_to_latin130rewind_and_convert_with_errorsEmPKcmPc:
  176|  1.02k|                                             char *latin1_output) {
  177|  1.02k|  size_t extra_len{0};
  178|       |  // We potentially need to go back in time and find a leading byte.
  179|       |  // In theory '3' would be sufficient, but sometimes the error can go back
  180|       |  // quite far.
  181|  1.02k|  size_t how_far_back = prior_bytes;
  182|       |  // size_t how_far_back = 3; // 3 bytes in the past + current position
  183|       |  // if(how_far_back >= prior_bytes) { how_far_back = prior_bytes; }
  184|  1.02k|  bool found_leading_bytes{false};
  185|       |  // important: it is i <= how_far_back and not 'i < how_far_back'.
  186|  1.15k|  for (size_t i = 0; i <= how_far_back; i++) {
  ------------------
  |  Branch (186:22): [True: 1.11k, False: 36]
  ------------------
  187|  1.11k|    unsigned char byte = buf[-static_cast<std::ptrdiff_t>(i)];
  188|  1.11k|    found_leading_bytes = ((byte & 0b11000000) != 0b10000000);
  189|  1.11k|    if (found_leading_bytes) {
  ------------------
  |  Branch (189:9): [True: 992, False: 124]
  ------------------
  190|    992|      if (i > 0 && byte < 128) {
  ------------------
  |  Branch (190:11): [True: 76, False: 916]
  |  Branch (190:20): [True: 64, False: 12]
  ------------------
  191|       |        // If we had to go back and the leading byte is ascii
  192|       |        // then we can stop right away.
  193|     64|        return result(error_code::TOO_LONG, 0 - i + 1);
  194|     64|      }
  195|    928|      buf -= i;
  196|    928|      extra_len = i;
  197|    928|      break;
  198|    992|    }
  199|  1.11k|  }
  200|       |  //
  201|       |  // It is possible for this function to return a negative count in its result.
  202|       |  // C++ Standard Section 18.1 defines size_t is in <cstddef> which is described
  203|       |  // in C Standard as <stddef.h>. C Standard Section 4.1.5 defines size_t as an
  204|       |  // unsigned integral type of the result of the sizeof operator
  205|       |  //
  206|       |  // An unsigned type will simply wrap round arithmetically (well defined).
  207|       |  //
  208|    964|  if (!found_leading_bytes) {
  ------------------
  |  Branch (208:7): [True: 36, False: 928]
  ------------------
  209|       |    // If how_far_back == 3, we may have four consecutive continuation bytes!!!
  210|       |    // [....] [continuation] [continuation] [continuation] | [buf is
  211|       |    // continuation] Or we possibly have a stream that does not start with a
  212|       |    // leading byte.
  213|     36|    return result(error_code::TOO_LONG, 0 - how_far_back);
  214|     36|  }
  215|    928|  result res = convert_with_errors(buf, len + extra_len, latin1_output);
  216|    928|  if (res.error) {
  ------------------
  |  Branch (216:7): [True: 768, False: 160]
  ------------------
  217|    768|    res.count -= extra_len;
  218|    768|  }
  219|    928|  return res;
  220|    964|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf8_to_latin119convert_with_errorsIPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEENS_6resultES6_mPc:
   92|  1.97k|                                               char *latin_output) {
   93|  1.97k|  size_t pos = 0;
   94|  1.97k|  char *start{latin_output};
   95|       |
   96|  2.03M|  while (pos < len) {
  ------------------
  |  Branch (96:10): [True: 2.03M, False: 494]
  ------------------
   97|       |#if SIMDUTF_CPLUSPLUS23
   98|       |    if !consteval
   99|       |#endif
  100|  2.03M|    {
  101|       |      // try to convert the next block of 16 ASCII bytes
  102|  2.03M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (102:11): [True: 2.02M, False: 6.39k]
  ------------------
  103|       |                             // they are ascii
  104|  2.02M|        uint64_t v1;
  105|  2.02M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
  106|  2.02M|        uint64_t v2;
  107|  2.02M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  108|  2.02M|        uint64_t v{v1 | v2}; // We are only interested in these bits: 1000 1000
  109|       |                             // 1000 1000...etc
  110|  2.02M|        if ((v & 0x8080808080808080) ==
  ------------------
  |  Branch (110:13): [True: 1.75M, False: 272k]
  ------------------
  111|  2.02M|            0) { // if NONE of these are set, e.g. all of them are zero, then
  112|       |                 // everything is ASCII
  113|  1.75M|          size_t final_pos = pos + 16;
  114|  29.8M|          while (pos < final_pos) {
  ------------------
  |  Branch (114:18): [True: 28.0M, False: 1.75M]
  ------------------
  115|  28.0M|            *latin_output++ = char(data[pos]);
  116|  28.0M|            pos++;
  117|  28.0M|          }
  118|  1.75M|          continue;
  119|  1.75M|        }
  120|  2.02M|      }
  121|  2.03M|    }
  122|       |    // suppose it is not an all ASCII byte sequence
  123|   278k|    uint8_t leading_byte = data[pos]; // leading byte
  124|   278k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (124:9): [True: 232k, False: 46.7k]
  ------------------
  125|       |      // converting one ASCII byte !!!
  126|   232k|      *latin_output++ = char(leading_byte);
  127|   232k|      pos++;
  128|   232k|    } else if ((leading_byte & 0b11100000) ==
  ------------------
  |  Branch (128:16): [True: 45.6k, False: 1.09k]
  ------------------
  129|  46.7k|               0b11000000) { // the first three bits indicate:
  130|       |      // We have a two-byte UTF-8
  131|  45.6k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (131:11): [True: 66, False: 45.6k]
  ------------------
  132|     66|        return result(error_code::TOO_SHORT, pos);
  133|     66|      } // minimal bound checking
  134|  45.6k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (134:11): [True: 246, False: 45.3k]
  ------------------
  135|    246|        return result(error_code::TOO_SHORT, pos);
  136|    246|      } // checks if the next byte is a valid continuation byte in UTF-8. A
  137|       |        // valid continuation byte starts with 10.
  138|       |      // range check -
  139|  45.3k|      uint32_t code_point =
  140|  45.3k|          (leading_byte & 0b00011111) << 6 |
  141|  45.3k|          (data[pos + 1] &
  142|  45.3k|           0b00111111); // assembles the Unicode code point from the two bytes.
  143|       |                        // It does this by discarding the leading 110 and 10
  144|       |                        // bits from the two bytes, shifting the remaining bits
  145|       |                        // of the first byte, and then combining the results
  146|       |                        // with a bitwise OR operation.
  147|  45.3k|      if (code_point < 0x80) {
  ------------------
  |  Branch (147:11): [True: 18, False: 45.3k]
  ------------------
  148|     18|        return result(error_code::OVERLONG, pos);
  149|     18|      }
  150|  45.3k|      if (0xFF < code_point) {
  ------------------
  |  Branch (150:11): [True: 60, False: 45.3k]
  ------------------
  151|     60|        return result(error_code::TOO_LARGE, pos);
  152|     60|      } // We only care about the range 129-255 which is Non-ASCII latin1
  153|       |        // characters
  154|  45.3k|      *latin_output++ = char(code_point);
  155|  45.3k|      pos += 2;
  156|  45.3k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (156:16): [True: 120, False: 974]
  ------------------
  157|       |      // We have a three-byte UTF-8
  158|    120|      return result(error_code::TOO_LARGE, pos);
  159|    974|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (159:16): [True: 84, False: 890]
  ------------------
  160|       |      // we have a 4-byte UTF-8 word.
  161|     84|      return result(error_code::TOO_LARGE, pos);
  162|    890|    } else {
  163|       |      // we either have too many continuation bytes or an invalid leading byte
  164|    890|      if ((leading_byte & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (164:11): [True: 416, False: 474]
  ------------------
  165|    416|        return result(error_code::TOO_LONG, pos);
  166|    416|      }
  167|       |
  168|    474|      return result(error_code::HEADER_BITS, pos);
  169|    890|    }
  170|   278k|  }
  171|    494|  return result(error_code::SUCCESS, latin_output - start);
  172|  1.97k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_114utf8_to_latin17convertIPKcPcQaasr7simdutf6detailE22indexes_into_byte_likeIT_Esr7simdutf6detailE22indexes_into_byte_likeIT0_EEEmS7_mS8_:
   17|  1.55k|                                   OutputPtr latin_output) {
   18|  1.55k|  size_t pos = 0;
   19|  1.55k|  auto start = latin_output;
   20|       |
   21|  1.66M|  while (pos < len) {
  ------------------
  |  Branch (21:10): [True: 1.65M, False: 448]
  ------------------
   22|       |#if SIMDUTF_CPLUSPLUS23
   23|       |    if !consteval
   24|       |#endif
   25|  1.65M|    {
   26|       |      // try to convert the next block of 16 ASCII bytes
   27|  1.65M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (27:11): [True: 1.65M, False: 4.57k]
  ------------------
   28|       |                             // they are ascii
   29|  1.65M|        uint64_t v1;
   30|  1.65M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   31|  1.65M|        uint64_t v2;
   32|  1.65M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   33|  1.65M|        uint64_t v{v1 | v2}; // We are only interested in these bits: 1000 1000
   34|       |                             // 1000 1000 .... etc
   35|  1.65M|        if ((v & 0x8080808080808080) ==
  ------------------
  |  Branch (35:13): [True: 1.41M, False: 240k]
  ------------------
   36|  1.65M|            0) { // if NONE of these are set, e.g. all of them are zero, then
   37|       |                 // everything is ASCII
   38|  1.41M|          size_t final_pos = pos + 16;
   39|  24.0M|          while (pos < final_pos) {
  ------------------
  |  Branch (39:18): [True: 22.6M, False: 1.41M]
  ------------------
   40|  22.6M|            *latin_output++ = char(data[pos]);
   41|  22.6M|            pos++;
   42|  22.6M|          }
   43|  1.41M|          continue;
   44|  1.41M|        }
   45|  1.65M|      }
   46|  1.65M|    }
   47|       |
   48|       |    // suppose it is not an all ASCII byte sequence
   49|   244k|    uint8_t leading_byte = data[pos]; // leading byte
   50|   244k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (50:9): [True: 197k, False: 46.8k]
  ------------------
   51|       |      // converting one ASCII byte !!!
   52|   197k|      *latin_output++ = char(leading_byte);
   53|   197k|      pos++;
   54|   197k|    } else if ((leading_byte & 0b11100000) ==
  ------------------
  |  Branch (54:16): [True: 46.1k, False: 702]
  ------------------
   55|  46.8k|               0b11000000) { // the first three bits indicate:
   56|       |      // We have a two-byte UTF-8
   57|  46.1k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (57:11): [True: 72, False: 46.0k]
  ------------------
   58|     72|        return 0;
   59|     72|      } // minimal bound checking
   60|  46.0k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (60:11): [True: 164, False: 45.9k]
  ------------------
   61|    164|        return 0;
   62|    164|      } // checks if the next byte is a valid continuation byte in UTF-8. A
   63|       |        // valid continuation byte starts with 10.
   64|       |      // range check -
   65|  45.9k|      uint32_t code_point =
   66|  45.9k|          (leading_byte & 0b00011111) << 6 |
   67|  45.9k|          (data[pos + 1] &
   68|  45.9k|           0b00111111); // assembles the Unicode code point from the two bytes.
   69|       |                        // It does this by discarding the leading 110 and 10
   70|       |                        // bits from the two bytes, shifting the remaining bits
   71|       |                        // of the first byte, and then combining the results
   72|       |                        // with a bitwise OR operation.
   73|  45.9k|      if (code_point < 0x80 || 0xFF < code_point) {
  ------------------
  |  Branch (73:11): [True: 42, False: 45.8k]
  |  Branch (73:32): [True: 126, False: 45.7k]
  ------------------
   74|    168|        return 0; // We only care about the range 129-255 which is Non-ASCII
   75|       |                  // latin1 characters. A code_point beneath 0x80 is invalid as
   76|       |                  // it is already covered by bytes whose leading bit is zero.
   77|    168|      }
   78|  45.7k|      *latin_output++ = char(code_point);
   79|  45.7k|      pos += 2;
   80|  45.7k|    } else {
   81|    702|      return 0;
   82|    702|    }
   83|   244k|  }
   84|    448|  return latin_output - start;
   85|  1.55k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf167convertILNS_10endiannessE0EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEEmS7_mPDs:
   16|  2.22k|                                   char16_t *utf16_output) {
   17|  2.22k|  size_t pos = 0;
   18|  2.22k|  char16_t *start{utf16_output};
   19|  3.87M|  while (pos < len) {
  ------------------
  |  Branch (19:10): [True: 3.87M, False: 718]
  ------------------
   20|       |#if SIMDUTF_CPLUSPLUS23
   21|       |    if !consteval
   22|       |#endif
   23|       |    // try to convert the next block of 16 ASCII bytes
   24|  3.87M|    {
   25|  3.87M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (25:11): [True: 3.86M, False: 6.11k]
  ------------------
   26|       |                             // they are ascii
   27|  3.86M|        uint64_t v1;
   28|  3.86M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   29|  3.86M|        uint64_t v2;
   30|  3.86M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   31|  3.86M|        uint64_t v{v1 | v2};
   32|  3.86M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (32:13): [True: 1.86M, False: 2.00M]
  ------------------
   33|  1.86M|          size_t final_pos = pos + 16;
   34|  31.6M|          while (pos < final_pos) {
  ------------------
  |  Branch (34:18): [True: 29.8M, False: 1.86M]
  ------------------
   35|  29.8M|            *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (35:31): [Folded, False: 29.8M]
  ------------------
   36|  29.8M|                                  ? char16_t(u16_swap_bytes(data[pos]))
   37|  29.8M|                                  : char16_t(data[pos]);
   38|  29.8M|            pos++;
   39|  29.8M|          }
   40|  1.86M|          continue;
   41|  1.86M|        }
   42|  3.86M|      }
   43|  3.87M|    }
   44|       |
   45|  2.01M|    uint8_t leading_byte = data[pos]; // leading byte
   46|  2.01M|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (46:9): [True: 1.66M, False: 343k]
  ------------------
   47|       |      // converting one ASCII byte !!!
   48|  1.66M|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (48:25): [Folded, False: 1.66M]
  ------------------
   49|  1.66M|                            ? char16_t(u16_swap_bytes(leading_byte))
   50|  1.66M|                            : char16_t(leading_byte);
   51|  1.66M|      pos++;
   52|  1.66M|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (52:16): [True: 196k, False: 146k]
  ------------------
   53|       |      // We have a two-byte UTF-8, it should become
   54|       |      // a single UTF-16 word.
   55|   196k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (55:11): [True: 54, False: 196k]
  ------------------
   56|     54|        return 0;
   57|     54|      } // minimal bound checking
   58|   196k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (58:11): [True: 244, False: 196k]
  ------------------
   59|    244|        return 0;
   60|    244|      }
   61|       |      // range check
   62|   196k|      uint32_t code_point =
   63|   196k|          (leading_byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111);
   64|   196k|      if (code_point < 0x80) {
  ------------------
  |  Branch (64:11): [True: 26, False: 196k]
  ------------------
   65|     26|        return 0;
   66|     26|      }
   67|       |      if constexpr (!match_system(big_endian)) {
   68|       |        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
   69|       |      }
   70|   196k|      *utf16_output++ = char16_t(code_point);
   71|   196k|      pos += 2;
   72|   196k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (72:16): [True: 129k, False: 17.0k]
  ------------------
   73|       |      // We have a three-byte UTF-8, it should become
   74|       |      // a single UTF-16 word.
   75|   129k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (75:11): [True: 36, False: 129k]
  ------------------
   76|     36|        return 0;
   77|     36|      } // minimal bound checking
   78|       |
   79|   129k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (79:11): [True: 100, False: 129k]
  ------------------
   80|    100|        return 0;
   81|    100|      }
   82|   129k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (82:11): [True: 46, False: 129k]
  ------------------
   83|     46|        return 0;
   84|     46|      }
   85|       |      // range check
   86|   129k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
   87|   129k|                            (data[pos + 1] & 0b00111111) << 6 |
   88|   129k|                            (data[pos + 2] & 0b00111111);
   89|   129k|      if (code_point < 0x800 || (0xd7ff < code_point && code_point < 0xe000)) {
  ------------------
  |  Branch (89:11): [True: 40, False: 129k]
  |  Branch (89:34): [True: 2.25k, False: 126k]
  |  Branch (89:57): [True: 18, False: 2.24k]
  ------------------
   90|     58|        return 0;
   91|     58|      }
   92|       |      if constexpr (!match_system(big_endian)) {
   93|       |        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
   94|       |      }
   95|   129k|      *utf16_output++ = char16_t(code_point);
   96|   129k|      pos += 3;
   97|   129k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (97:16): [True: 16.3k, False: 684]
  ------------------
   98|       |      // we have a 4-byte UTF-8 word.
   99|  16.3k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (99:11): [True: 60, False: 16.3k]
  ------------------
  100|     60|        return 0;
  101|     60|      } // minimal bound checking
  102|  16.3k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (102:11): [True: 82, False: 16.2k]
  ------------------
  103|     82|        return 0;
  104|     82|      }
  105|  16.2k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (105:11): [True: 34, False: 16.2k]
  ------------------
  106|     34|        return 0;
  107|     34|      }
  108|  16.2k|      if ((data[pos + 3] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (108:11): [True: 40, False: 16.1k]
  ------------------
  109|     40|        return 0;
  110|     40|      }
  111|       |
  112|       |      // range check
  113|  16.1k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  114|  16.1k|                            (data[pos + 1] & 0b00111111) << 12 |
  115|  16.1k|                            (data[pos + 2] & 0b00111111) << 6 |
  116|  16.1k|                            (data[pos + 3] & 0b00111111);
  117|  16.1k|      if (code_point <= 0xffff || 0x10ffff < code_point) {
  ------------------
  |  Branch (117:11): [True: 10, False: 16.1k]
  |  Branch (117:35): [True: 28, False: 16.1k]
  ------------------
  118|     38|        return 0;
  119|     38|      }
  120|  16.1k|      code_point -= 0x10000;
  121|       |      // The mask is a no-op (code_point < 0x100000). It stops clang 18's SLP
  122|       |      // vectorizer on RISC-V V from narrowing code_point to 16 bits before
  123|       |      // the shift, which drops bits 16-19 of the code point.
  124|  16.1k|      uint16_t high_surrogate = uint16_t(0xD800 + ((code_point >> 10) & 0x3FF));
  125|  16.1k|      uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF));
  126|       |      if constexpr (!match_system(big_endian)) {
  127|       |        high_surrogate = u16_swap_bytes(high_surrogate);
  128|       |        low_surrogate = u16_swap_bytes(low_surrogate);
  129|       |      }
  130|  16.1k|      *utf16_output++ = char16_t(high_surrogate);
  131|  16.1k|      *utf16_output++ = char16_t(low_surrogate);
  132|  16.1k|      pos += 4;
  133|  16.1k|    } else {
  134|    684|      return 0;
  135|    684|    }
  136|  2.01M|  }
  137|    718|  return utf16_output - start;
  138|  2.22k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf167convertILNS_10endiannessE1EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEEmS7_mPDs:
   16|  2.20k|                                   char16_t *utf16_output) {
   17|  2.20k|  size_t pos = 0;
   18|  2.20k|  char16_t *start{utf16_output};
   19|  3.27M|  while (pos < len) {
  ------------------
  |  Branch (19:10): [True: 3.27M, False: 728]
  ------------------
   20|       |#if SIMDUTF_CPLUSPLUS23
   21|       |    if !consteval
   22|       |#endif
   23|       |    // try to convert the next block of 16 ASCII bytes
   24|  3.27M|    {
   25|  3.27M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (25:11): [True: 3.26M, False: 7.93k]
  ------------------
   26|       |                             // they are ascii
   27|  3.26M|        uint64_t v1;
   28|  3.26M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   29|  3.26M|        uint64_t v2;
   30|  3.26M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   31|  3.26M|        uint64_t v{v1 | v2};
   32|  3.26M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (32:13): [True: 1.81M, False: 1.44M]
  ------------------
   33|  1.81M|          size_t final_pos = pos + 16;
   34|  30.8M|          while (pos < final_pos) {
  ------------------
  |  Branch (34:18): [True: 29.0M, False: 1.81M]
  ------------------
   35|  29.0M|            *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (35:31): [True: 29.0M, Folded]
  ------------------
   36|  29.0M|                                  ? char16_t(u16_swap_bytes(data[pos]))
   37|  29.0M|                                  : char16_t(data[pos]);
   38|  29.0M|            pos++;
   39|  29.0M|          }
   40|  1.81M|          continue;
   41|  1.81M|        }
   42|  3.26M|      }
   43|  3.27M|    }
   44|       |
   45|  1.45M|    uint8_t leading_byte = data[pos]; // leading byte
   46|  1.45M|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (46:9): [True: 1.17M, False: 279k]
  ------------------
   47|       |      // converting one ASCII byte !!!
   48|  1.17M|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (48:25): [True: 1.17M, Folded]
  ------------------
   49|  1.17M|                            ? char16_t(u16_swap_bytes(leading_byte))
   50|  1.17M|                            : char16_t(leading_byte);
   51|  1.17M|      pos++;
   52|  1.17M|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (52:16): [True: 180k, False: 99.0k]
  ------------------
   53|       |      // We have a two-byte UTF-8, it should become
   54|       |      // a single UTF-16 word.
   55|   180k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (55:11): [True: 96, False: 180k]
  ------------------
   56|     96|        return 0;
   57|     96|      } // minimal bound checking
   58|   180k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (58:11): [True: 164, False: 180k]
  ------------------
   59|    164|        return 0;
   60|    164|      }
   61|       |      // range check
   62|   180k|      uint32_t code_point =
   63|   180k|          (leading_byte & 0b00011111) << 6 | (data[pos + 1] & 0b00111111);
   64|   180k|      if (code_point < 0x80) {
  ------------------
  |  Branch (64:11): [True: 22, False: 180k]
  ------------------
   65|     22|        return 0;
   66|     22|      }
   67|   180k|      if constexpr (!match_system(big_endian)) {
   68|   180k|        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
   69|   180k|      }
   70|   180k|      *utf16_output++ = char16_t(code_point);
   71|   180k|      pos += 2;
   72|   180k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (72:16): [True: 79.6k, False: 19.4k]
  ------------------
   73|       |      // We have a three-byte UTF-8, it should become
   74|       |      // a single UTF-16 word.
   75|  79.6k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (75:11): [True: 54, False: 79.5k]
  ------------------
   76|     54|        return 0;
   77|     54|      } // minimal bound checking
   78|       |
   79|  79.5k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (79:11): [True: 86, False: 79.4k]
  ------------------
   80|     86|        return 0;
   81|     86|      }
   82|  79.4k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (82:11): [True: 52, False: 79.4k]
  ------------------
   83|     52|        return 0;
   84|     52|      }
   85|       |      // range check
   86|  79.4k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
   87|  79.4k|                            (data[pos + 1] & 0b00111111) << 6 |
   88|  79.4k|                            (data[pos + 2] & 0b00111111);
   89|  79.4k|      if (code_point < 0x800 || (0xd7ff < code_point && code_point < 0xe000)) {
  ------------------
  |  Branch (89:11): [True: 44, False: 79.3k]
  |  Branch (89:34): [True: 2.79k, False: 76.5k]
  |  Branch (89:57): [True: 14, False: 2.78k]
  ------------------
   90|     58|        return 0;
   91|     58|      }
   92|  79.3k|      if constexpr (!match_system(big_endian)) {
   93|  79.3k|        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
   94|  79.3k|      }
   95|  79.3k|      *utf16_output++ = char16_t(code_point);
   96|  79.3k|      pos += 3;
   97|  79.3k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (97:16): [True: 18.7k, False: 718]
  ------------------
   98|       |      // we have a 4-byte UTF-8 word.
   99|  18.7k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (99:11): [True: 24, False: 18.6k]
  ------------------
  100|     24|        return 0;
  101|     24|      } // minimal bound checking
  102|  18.6k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (102:11): [True: 58, False: 18.6k]
  ------------------
  103|     58|        return 0;
  104|     58|      }
  105|  18.6k|      if ((data[pos + 2] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (105:11): [True: 36, False: 18.5k]
  ------------------
  106|     36|        return 0;
  107|     36|      }
  108|  18.5k|      if ((data[pos + 3] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (108:11): [True: 26, False: 18.5k]
  ------------------
  109|     26|        return 0;
  110|     26|      }
  111|       |
  112|       |      // range check
  113|  18.5k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  114|  18.5k|                            (data[pos + 1] & 0b00111111) << 12 |
  115|  18.5k|                            (data[pos + 2] & 0b00111111) << 6 |
  116|  18.5k|                            (data[pos + 3] & 0b00111111);
  117|  18.5k|      if (code_point <= 0xffff || 0x10ffff < code_point) {
  ------------------
  |  Branch (117:11): [True: 38, False: 18.5k]
  |  Branch (117:35): [True: 48, False: 18.4k]
  ------------------
  118|     86|        return 0;
  119|     86|      }
  120|  18.4k|      code_point -= 0x10000;
  121|       |      // The mask is a no-op (code_point < 0x100000). It stops clang 18's SLP
  122|       |      // vectorizer on RISC-V V from narrowing code_point to 16 bits before
  123|       |      // the shift, which drops bits 16-19 of the code point.
  124|  18.4k|      uint16_t high_surrogate = uint16_t(0xD800 + ((code_point >> 10) & 0x3FF));
  125|  18.4k|      uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF));
  126|  18.4k|      if constexpr (!match_system(big_endian)) {
  127|  18.4k|        high_surrogate = u16_swap_bytes(high_surrogate);
  128|  18.4k|        low_surrogate = u16_swap_bytes(low_surrogate);
  129|  18.4k|      }
  130|  18.4k|      *utf16_output++ = char16_t(high_surrogate);
  131|  18.4k|      *utf16_output++ = char16_t(low_surrogate);
  132|  18.4k|      pos += 4;
  133|  18.4k|    } else {
  134|    718|      return 0;
  135|    718|    }
  136|  1.45M|  }
  137|    728|  return utf16_output - start;
  138|  2.20k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1619convert_with_errorsILNS_10endiannessE0EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEENS_6resultES7_mPDs:
  145|  2.13k|                                               char16_t *utf16_output) {
  146|  2.13k|  size_t pos = 0;
  147|  2.13k|  char16_t *start{utf16_output};
  148|  3.26M|  while (pos < len) {
  ------------------
  |  Branch (148:10): [True: 3.26M, False: 712]
  ------------------
  149|       |#if SIMDUTF_CPLUSPLUS23
  150|       |    if !consteval
  151|       |#endif
  152|  3.26M|    {
  153|       |      // try to convert the next block of 16 ASCII bytes
  154|  3.26M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (154:11): [True: 3.25M, False: 6.63k]
  ------------------
  155|       |                             // they are ascii
  156|  3.25M|        uint64_t v1;
  157|  3.25M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
  158|  3.25M|        uint64_t v2;
  159|  3.25M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  160|  3.25M|        uint64_t v{v1 | v2};
  161|  3.25M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (161:13): [True: 1.94M, False: 1.30M]
  ------------------
  162|  1.94M|          size_t final_pos = pos + 16;
  163|  33.0M|          while (pos < final_pos) {
  ------------------
  |  Branch (163:18): [True: 31.1M, False: 1.94M]
  ------------------
  164|  31.1M|            const char16_t byte = uint8_t(data[pos]);
  165|  31.1M|            *utf16_output++ =
  166|  31.1M|                !match_system(big_endian) ? u16_swap_bytes(byte) : byte;
  ------------------
  |  Branch (166:17): [Folded, False: 31.1M]
  ------------------
  167|  31.1M|            pos++;
  168|  31.1M|          }
  169|  1.94M|          continue;
  170|  1.94M|        }
  171|  3.25M|      }
  172|  3.26M|    }
  173|       |
  174|  1.31M|    auto leading_byte = uint8_t(data[pos]); // leading byte
  175|  1.31M|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (175:9): [True: 1.08M, False: 229k]
  ------------------
  176|       |      // converting one ASCII byte !!!
  177|  1.08M|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (177:25): [Folded, False: 1.08M]
  ------------------
  178|  1.08M|                            ? char16_t(u16_swap_bytes(leading_byte))
  179|  1.08M|                            : char16_t(leading_byte);
  180|  1.08M|      pos++;
  181|  1.08M|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (181:16): [True: 151k, False: 78.0k]
  ------------------
  182|       |      // We have a two-byte UTF-8, it should become
  183|       |      // a single UTF-16 word.
  184|   151k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (184:11): [True: 66, False: 151k]
  ------------------
  185|     66|        return result(error_code::TOO_SHORT, pos);
  186|     66|      } // minimal bound checking
  187|   151k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (187:11): [True: 150, False: 151k]
  ------------------
  188|    150|        return result(error_code::TOO_SHORT, pos);
  189|    150|      }
  190|       |      // range check
  191|   151k|      uint32_t code_point = (leading_byte & 0b00011111) << 6 |
  192|   151k|                            (uint8_t(data[pos + 1]) & 0b00111111);
  193|   151k|      if (code_point < 0x80) {
  ------------------
  |  Branch (193:11): [True: 54, False: 151k]
  ------------------
  194|     54|        return result(error_code::OVERLONG, pos);
  195|     54|      }
  196|       |      if constexpr (!match_system(big_endian)) {
  197|       |        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
  198|       |      }
  199|   151k|      *utf16_output++ = char16_t(code_point);
  200|   151k|      pos += 2;
  201|   151k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (201:16): [True: 62.8k, False: 15.2k]
  ------------------
  202|       |      // We have a three-byte UTF-8, it should become
  203|       |      // a single UTF-16 word.
  204|  62.8k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (204:11): [True: 24, False: 62.8k]
  ------------------
  205|     24|        return result(error_code::TOO_SHORT, pos);
  206|     24|      } // minimal bound checking
  207|       |
  208|  62.8k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (208:11): [True: 72, False: 62.7k]
  ------------------
  209|     72|        return result(error_code::TOO_SHORT, pos);
  210|     72|      }
  211|  62.7k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (211:11): [True: 18, False: 62.7k]
  ------------------
  212|     18|        return result(error_code::TOO_SHORT, pos);
  213|     18|      }
  214|       |      // range check
  215|  62.7k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
  216|  62.7k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 6 |
  217|  62.7k|                            (uint8_t(data[pos + 2]) & 0b00111111);
  218|  62.7k|      if (code_point < 0x800) {
  ------------------
  |  Branch (218:11): [True: 24, False: 62.7k]
  ------------------
  219|     24|        return result(error_code::OVERLONG, pos);
  220|     24|      }
  221|  62.7k|      if (0xd7ff < code_point && code_point < 0xe000) {
  ------------------
  |  Branch (221:11): [True: 3.19k, False: 59.5k]
  |  Branch (221:34): [True: 6, False: 3.18k]
  ------------------
  222|      6|        return result(error_code::SURROGATE, pos);
  223|      6|      }
  224|       |      if constexpr (!match_system(big_endian)) {
  225|       |        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
  226|       |      }
  227|  62.7k|      *utf16_output++ = char16_t(code_point);
  228|  62.7k|      pos += 3;
  229|  62.7k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (229:16): [True: 14.4k, False: 748]
  ------------------
  230|       |      // we have a 4-byte UTF-8 word.
  231|  14.4k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (231:11): [True: 18, False: 14.4k]
  ------------------
  232|     18|        return result(error_code::TOO_SHORT, pos);
  233|     18|      } // minimal bound checking
  234|  14.4k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (234:11): [True: 66, False: 14.3k]
  ------------------
  235|     66|        return result(error_code::TOO_SHORT, pos);
  236|     66|      }
  237|  14.3k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (237:11): [True: 60, False: 14.3k]
  ------------------
  238|     60|        return result(error_code::TOO_SHORT, pos);
  239|     60|      }
  240|  14.3k|      if ((uint8_t(data[pos + 3]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (240:11): [True: 48, False: 14.2k]
  ------------------
  241|     48|        return result(error_code::TOO_SHORT, pos);
  242|     48|      }
  243|       |
  244|       |      // range check
  245|  14.2k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  246|  14.2k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 12 |
  247|  14.2k|                            (uint8_t(data[pos + 2]) & 0b00111111) << 6 |
  248|  14.2k|                            (uint8_t(data[pos + 3]) & 0b00111111);
  249|  14.2k|      if (code_point <= 0xffff) {
  ------------------
  |  Branch (249:11): [True: 30, False: 14.2k]
  ------------------
  250|     30|        return result(error_code::OVERLONG, pos);
  251|     30|      }
  252|  14.2k|      if (0x10ffff < code_point) {
  ------------------
  |  Branch (252:11): [True: 42, False: 14.2k]
  ------------------
  253|     42|        return result(error_code::TOO_LARGE, pos);
  254|     42|      }
  255|  14.2k|      code_point -= 0x10000;
  256|       |      // The mask is a no-op (code_point < 0x100000). It stops clang 18's SLP
  257|       |      // vectorizer on RISC-V V from narrowing code_point to 16 bits before
  258|       |      // the shift, which drops bits 16-19 of the code point.
  259|  14.2k|      uint16_t high_surrogate = uint16_t(0xD800 + ((code_point >> 10) & 0x3FF));
  260|  14.2k|      uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF));
  261|       |      if constexpr (!match_system(big_endian)) {
  262|       |        high_surrogate = u16_swap_bytes(high_surrogate);
  263|       |        low_surrogate = u16_swap_bytes(low_surrogate);
  264|       |      }
  265|  14.2k|      *utf16_output++ = char16_t(high_surrogate);
  266|  14.2k|      *utf16_output++ = char16_t(low_surrogate);
  267|  14.2k|      pos += 4;
  268|  14.2k|    } else {
  269|       |      // we either have too many continuation bytes or an invalid leading byte
  270|    748|      if ((leading_byte & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (270:11): [True: 370, False: 378]
  ------------------
  271|    370|        return result(error_code::TOO_LONG, pos);
  272|    378|      } else {
  273|    378|        return result(error_code::HEADER_BITS, pos);
  274|    378|      }
  275|    748|    }
  276|  1.31M|  }
  277|    712|  return result(error_code::SUCCESS, utf16_output - start);
  278|  2.13k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1619convert_with_errorsILNS_10endiannessE1EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEENS_6resultES7_mPDs:
  145|  2.45k|                                               char16_t *utf16_output) {
  146|  2.45k|  size_t pos = 0;
  147|  2.45k|  char16_t *start{utf16_output};
  148|  4.91M|  while (pos < len) {
  ------------------
  |  Branch (148:10): [True: 4.90M, False: 944]
  ------------------
  149|       |#if SIMDUTF_CPLUSPLUS23
  150|       |    if !consteval
  151|       |#endif
  152|  4.90M|    {
  153|       |      // try to convert the next block of 16 ASCII bytes
  154|  4.90M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (154:11): [True: 4.90M, False: 9.36k]
  ------------------
  155|       |                             // they are ascii
  156|  4.90M|        uint64_t v1;
  157|  4.90M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
  158|  4.90M|        uint64_t v2;
  159|  4.90M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  160|  4.90M|        uint64_t v{v1 | v2};
  161|  4.90M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (161:13): [True: 1.76M, False: 3.14M]
  ------------------
  162|  1.76M|          size_t final_pos = pos + 16;
  163|  29.9M|          while (pos < final_pos) {
  ------------------
  |  Branch (163:18): [True: 28.1M, False: 1.76M]
  ------------------
  164|  28.1M|            const char16_t byte = uint8_t(data[pos]);
  165|  28.1M|            *utf16_output++ =
  166|  28.1M|                !match_system(big_endian) ? u16_swap_bytes(byte) : byte;
  ------------------
  |  Branch (166:17): [True: 28.1M, Folded]
  ------------------
  167|  28.1M|            pos++;
  168|  28.1M|          }
  169|  1.76M|          continue;
  170|  1.76M|        }
  171|  4.90M|      }
  172|  4.90M|    }
  173|       |
  174|  3.14M|    auto leading_byte = uint8_t(data[pos]); // leading byte
  175|  3.14M|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (175:9): [True: 2.59M, False: 551k]
  ------------------
  176|       |      // converting one ASCII byte !!!
  177|  2.59M|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (177:25): [True: 2.59M, Folded]
  ------------------
  178|  2.59M|                            ? char16_t(u16_swap_bytes(leading_byte))
  179|  2.59M|                            : char16_t(leading_byte);
  180|  2.59M|      pos++;
  181|  2.59M|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (181:16): [True: 323k, False: 227k]
  ------------------
  182|       |      // We have a two-byte UTF-8, it should become
  183|       |      // a single UTF-16 word.
  184|   323k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (184:11): [True: 48, False: 323k]
  ------------------
  185|     48|        return result(error_code::TOO_SHORT, pos);
  186|     48|      } // minimal bound checking
  187|   323k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (187:11): [True: 186, False: 323k]
  ------------------
  188|    186|        return result(error_code::TOO_SHORT, pos);
  189|    186|      }
  190|       |      // range check
  191|   323k|      uint32_t code_point = (leading_byte & 0b00011111) << 6 |
  192|   323k|                            (uint8_t(data[pos + 1]) & 0b00111111);
  193|   323k|      if (code_point < 0x80) {
  ------------------
  |  Branch (193:11): [True: 18, False: 323k]
  ------------------
  194|     18|        return result(error_code::OVERLONG, pos);
  195|     18|      }
  196|   323k|      if constexpr (!match_system(big_endian)) {
  197|   323k|        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
  198|   323k|      }
  199|   323k|      *utf16_output++ = char16_t(code_point);
  200|   323k|      pos += 2;
  201|   323k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (201:16): [True: 209k, False: 18.2k]
  ------------------
  202|       |      // We have a three-byte UTF-8, it should become
  203|       |      // a single UTF-16 word.
  204|   209k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (204:11): [True: 42, False: 209k]
  ------------------
  205|     42|        return result(error_code::TOO_SHORT, pos);
  206|     42|      } // minimal bound checking
  207|       |
  208|   209k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (208:11): [True: 138, False: 209k]
  ------------------
  209|    138|        return result(error_code::TOO_SHORT, pos);
  210|    138|      }
  211|   209k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (211:11): [True: 54, False: 209k]
  ------------------
  212|     54|        return result(error_code::TOO_SHORT, pos);
  213|     54|      }
  214|       |      // range check
  215|   209k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
  216|   209k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 6 |
  217|   209k|                            (uint8_t(data[pos + 2]) & 0b00111111);
  218|   209k|      if (code_point < 0x800) {
  ------------------
  |  Branch (218:11): [True: 36, False: 209k]
  ------------------
  219|     36|        return result(error_code::OVERLONG, pos);
  220|     36|      }
  221|   209k|      if (0xd7ff < code_point && code_point < 0xe000) {
  ------------------
  |  Branch (221:11): [True: 5.70k, False: 203k]
  |  Branch (221:34): [True: 6, False: 5.69k]
  ------------------
  222|      6|        return result(error_code::SURROGATE, pos);
  223|      6|      }
  224|   209k|      if constexpr (!match_system(big_endian)) {
  225|   209k|        code_point = uint32_t(u16_swap_bytes(uint16_t(code_point)));
  226|   209k|      }
  227|   209k|      *utf16_output++ = char16_t(code_point);
  228|   209k|      pos += 3;
  229|   209k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (229:16): [True: 17.4k, False: 762]
  ------------------
  230|       |      // we have a 4-byte UTF-8 word.
  231|  17.4k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (231:11): [True: 54, False: 17.3k]
  ------------------
  232|     54|        return result(error_code::TOO_SHORT, pos);
  233|     54|      } // minimal bound checking
  234|  17.3k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (234:11): [True: 72, False: 17.3k]
  ------------------
  235|     72|        return result(error_code::TOO_SHORT, pos);
  236|     72|      }
  237|  17.3k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (237:11): [True: 48, False: 17.2k]
  ------------------
  238|     48|        return result(error_code::TOO_SHORT, pos);
  239|     48|      }
  240|  17.2k|      if ((uint8_t(data[pos + 3]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (240:11): [True: 12, False: 17.2k]
  ------------------
  241|     12|        return result(error_code::TOO_SHORT, pos);
  242|     12|      }
  243|       |
  244|       |      // range check
  245|  17.2k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  246|  17.2k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 12 |
  247|  17.2k|                            (uint8_t(data[pos + 2]) & 0b00111111) << 6 |
  248|  17.2k|                            (uint8_t(data[pos + 3]) & 0b00111111);
  249|  17.2k|      if (code_point <= 0xffff) {
  ------------------
  |  Branch (249:11): [True: 6, False: 17.2k]
  ------------------
  250|      6|        return result(error_code::OVERLONG, pos);
  251|      6|      }
  252|  17.2k|      if (0x10ffff < code_point) {
  ------------------
  |  Branch (252:11): [True: 30, False: 17.2k]
  ------------------
  253|     30|        return result(error_code::TOO_LARGE, pos);
  254|     30|      }
  255|  17.2k|      code_point -= 0x10000;
  256|       |      // The mask is a no-op (code_point < 0x100000). It stops clang 18's SLP
  257|       |      // vectorizer on RISC-V V from narrowing code_point to 16 bits before
  258|       |      // the shift, which drops bits 16-19 of the code point.
  259|  17.2k|      uint16_t high_surrogate = uint16_t(0xD800 + ((code_point >> 10) & 0x3FF));
  260|  17.2k|      uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF));
  261|  17.2k|      if constexpr (!match_system(big_endian)) {
  262|  17.2k|        high_surrogate = u16_swap_bytes(high_surrogate);
  263|  17.2k|        low_surrogate = u16_swap_bytes(low_surrogate);
  264|  17.2k|      }
  265|  17.2k|      *utf16_output++ = char16_t(high_surrogate);
  266|  17.2k|      *utf16_output++ = char16_t(low_surrogate);
  267|  17.2k|      pos += 4;
  268|  17.2k|    } else {
  269|       |      // we either have too many continuation bytes or an invalid leading byte
  270|    762|      if ((leading_byte & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (270:11): [True: 432, False: 330]
  ------------------
  271|    432|        return result(error_code::TOO_LONG, pos);
  272|    432|      } else {
  273|    330|        return result(error_code::HEADER_BITS, pos);
  274|    330|      }
  275|    762|    }
  276|  3.14M|  }
  277|    944|  return result(error_code::SUCCESS, utf16_output - start);
  278|  2.45k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1630rewind_and_convert_with_errorsILNS_10endiannessE0EEENS_6resultEmPKcmPDs:
  298|    824|                                             char16_t *utf16_output) {
  299|    824|  size_t extra_len{0};
  300|       |  // We potentially need to go back in time and find a leading byte.
  301|       |  // In theory '3' would be sufficient, but sometimes the error can go back
  302|       |  // quite far.
  303|    824|  size_t how_far_back = prior_bytes;
  304|       |  // size_t how_far_back = 3; // 3 bytes in the past + current position
  305|       |  // if(how_far_back >= prior_bytes) { how_far_back = prior_bytes; }
  306|    824|  bool found_leading_bytes{false};
  307|       |  // important: it is i <= how_far_back and not 'i < how_far_back'.
  308|    868|  for (size_t i = 0; i <= how_far_back; i++) {
  ------------------
  |  Branch (308:22): [True: 832, False: 36]
  ------------------
  309|    832|    unsigned char byte = buf[-static_cast<std::ptrdiff_t>(i)];
  310|    832|    found_leading_bytes = ((byte & 0b11000000) != 0b10000000);
  311|    832|    if (found_leading_bytes) {
  ------------------
  |  Branch (311:9): [True: 788, False: 44]
  ------------------
  312|    788|      if (i > 0 && byte < 128) {
  ------------------
  |  Branch (312:11): [True: 8, False: 780]
  |  Branch (312:20): [True: 8, False: 0]
  ------------------
  313|       |        // If we had to go back and the leading byte is ascii
  314|       |        // then we can stop right away.
  315|      8|        return result(error_code::TOO_LONG, 0 - i + 1);
  316|      8|      }
  317|    780|      buf -= i;
  318|    780|      extra_len = i;
  319|    780|      break;
  320|    788|    }
  321|    832|  }
  322|       |  //
  323|       |  // It is possible for this function to return a negative count in its result.
  324|       |  // C++ Standard Section 18.1 defines size_t is in <cstddef> which is described
  325|       |  // in C Standard as <stddef.h>. C Standard Section 4.1.5 defines size_t as an
  326|       |  // unsigned integral type of the result of the sizeof operator
  327|       |  //
  328|       |  // An unsigned type will simply wrap round arithmetically (well defined).
  329|       |  //
  330|    816|  if (!found_leading_bytes) {
  ------------------
  |  Branch (330:7): [True: 36, False: 780]
  ------------------
  331|       |    // If how_far_back == 3, we may have four consecutive continuation bytes!!!
  332|       |    // [....] [continuation] [continuation] [continuation] | [buf is
  333|       |    // continuation] Or we possibly have a stream that does not start with a
  334|       |    // leading byte.
  335|     36|    return result(error_code::TOO_LONG, 0 - how_far_back);
  336|     36|  }
  337|    780|  result res = convert_with_errors<endian>(buf, len + extra_len, utf16_output);
  338|    780|  if (res.error) {
  ------------------
  |  Branch (338:7): [True: 612, False: 168]
  ------------------
  339|    612|    res.count -= extra_len;
  340|    612|  }
  341|    780|  return res;
  342|    816|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1630rewind_and_convert_with_errorsILNS_10endiannessE1EEENS_6resultEmPKcmPDs:
  298|  1.08k|                                             char16_t *utf16_output) {
  299|  1.08k|  size_t extra_len{0};
  300|       |  // We potentially need to go back in time and find a leading byte.
  301|       |  // In theory '3' would be sufficient, but sometimes the error can go back
  302|       |  // quite far.
  303|  1.08k|  size_t how_far_back = prior_bytes;
  304|       |  // size_t how_far_back = 3; // 3 bytes in the past + current position
  305|       |  // if(how_far_back >= prior_bytes) { how_far_back = prior_bytes; }
  306|  1.08k|  bool found_leading_bytes{false};
  307|       |  // important: it is i <= how_far_back and not 'i < how_far_back'.
  308|  1.15k|  for (size_t i = 0; i <= how_far_back; i++) {
  ------------------
  |  Branch (308:22): [True: 1.10k, False: 44]
  ------------------
  309|  1.10k|    unsigned char byte = buf[-static_cast<std::ptrdiff_t>(i)];
  310|  1.10k|    found_leading_bytes = ((byte & 0b11000000) != 0b10000000);
  311|  1.10k|    if (found_leading_bytes) {
  ------------------
  |  Branch (311:9): [True: 1.03k, False: 72]
  ------------------
  312|  1.03k|      if (i > 0 && byte < 128) {
  ------------------
  |  Branch (312:11): [True: 28, False: 1.00k]
  |  Branch (312:20): [True: 28, False: 0]
  ------------------
  313|       |        // If we had to go back and the leading byte is ascii
  314|       |        // then we can stop right away.
  315|     28|        return result(error_code::TOO_LONG, 0 - i + 1);
  316|     28|      }
  317|  1.00k|      buf -= i;
  318|  1.00k|      extra_len = i;
  319|  1.00k|      break;
  320|  1.03k|    }
  321|  1.10k|  }
  322|       |  //
  323|       |  // It is possible for this function to return a negative count in its result.
  324|       |  // C++ Standard Section 18.1 defines size_t is in <cstddef> which is described
  325|       |  // in C Standard as <stddef.h>. C Standard Section 4.1.5 defines size_t as an
  326|       |  // unsigned integral type of the result of the sizeof operator
  327|       |  //
  328|       |  // An unsigned type will simply wrap round arithmetically (well defined).
  329|       |  //
  330|  1.05k|  if (!found_leading_bytes) {
  ------------------
  |  Branch (330:7): [True: 44, False: 1.00k]
  ------------------
  331|       |    // If how_far_back == 3, we may have four consecutive continuation bytes!!!
  332|       |    // [....] [continuation] [continuation] [continuation] | [buf is
  333|       |    // continuation] Or we possibly have a stream that does not start with a
  334|       |    // leading byte.
  335|     44|    return result(error_code::TOO_LONG, 0 - how_far_back);
  336|     44|  }
  337|  1.00k|  result res = convert_with_errors<endian>(buf, len + extra_len, utf16_output);
  338|  1.00k|  if (res.error) {
  ------------------
  |  Branch (338:7): [True: 704, False: 304]
  ------------------
  339|    704|    res.count -= extra_len;
  340|    704|  }
  341|  1.00k|  return res;
  342|  1.05k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1613convert_validILNS_10endiannessE0EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEEmS7_mPDs:
   16|  1.39k|                                         char16_t *utf16_output) {
   17|  1.39k|  size_t pos = 0;
   18|  1.39k|  char16_t *start{utf16_output};
   19|  6.07M|  while (pos < len) {
  ------------------
  |  Branch (19:10): [True: 6.07M, False: 1.39k]
  ------------------
   20|       |#if SIMDUTF_CPLUSPLUS23
   21|       |    if !consteval
   22|       |#endif
   23|  6.07M|    {                       // try to convert the next block of 8 ASCII bytes
   24|  6.07M|      if (pos + 8 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (24:11): [True: 6.06M, False: 4.75k]
  ------------------
   25|       |                            // they are ascii
   26|  6.06M|        uint64_t v;
   27|  6.06M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   28|  6.06M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (28:13): [True: 4.71M, False: 1.35M]
  ------------------
   29|  4.71M|          size_t final_pos = pos + 8;
   30|  42.4M|          while (pos < final_pos) {
  ------------------
  |  Branch (30:18): [True: 37.7M, False: 4.71M]
  ------------------
   31|  37.7M|            const char16_t byte = uint8_t(data[pos]);
   32|  37.7M|            *utf16_output++ =
   33|  37.7M|                !match_system(big_endian) ? u16_swap_bytes(byte) : byte;
  ------------------
  |  Branch (33:17): [Folded, False: 37.7M]
  ------------------
   34|  37.7M|            pos++;
   35|  37.7M|          }
   36|  4.71M|          continue;
   37|  4.71M|        }
   38|  6.06M|      }
   39|  6.07M|    }
   40|       |
   41|  1.36M|    auto leading_byte = uint8_t(data[pos]); // leading byte
   42|  1.36M|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (42:9): [True: 938k, False: 423k]
  ------------------
   43|       |      // converting one ASCII byte !!!
   44|   938k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (44:25): [Folded, False: 938k]
  ------------------
   45|   938k|                            ? char16_t(u16_swap_bytes(leading_byte))
   46|   938k|                            : char16_t(leading_byte);
   47|   938k|      pos++;
   48|   938k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (48:16): [True: 235k, False: 188k]
  ------------------
   49|       |      // We have a two-byte UTF-8, it should become
   50|       |      // a single UTF-16 word.
   51|   235k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (51:11): [True: 0, False: 235k]
  ------------------
   52|      0|        break;
   53|      0|      } // minimal bound checking
   54|   235k|      uint16_t code_point = uint16_t(((leading_byte & 0b00011111) << 6) |
   55|   235k|                                     (uint8_t(data[pos + 1]) & 0b00111111));
   56|       |      if constexpr (!match_system(big_endian)) {
   57|       |        code_point = u16_swap_bytes(uint16_t(code_point));
   58|       |      }
   59|   235k|      *utf16_output++ = char16_t(code_point);
   60|   235k|      pos += 2;
   61|   235k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (61:16): [True: 172k, False: 15.9k]
  ------------------
   62|       |      // We have a three-byte UTF-8, it should become
   63|       |      // a single UTF-16 word.
   64|   172k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (64:11): [True: 0, False: 172k]
  ------------------
   65|      0|        break;
   66|      0|      } // minimal bound checking
   67|   172k|      uint16_t code_point =
   68|   172k|          uint16_t(((leading_byte & 0b00001111) << 12) |
   69|   172k|                   ((uint8_t(data[pos + 1]) & 0b00111111) << 6) |
   70|   172k|                   (uint8_t(data[pos + 2]) & 0b00111111));
   71|       |      if constexpr (!match_system(big_endian)) {
   72|       |        code_point = u16_swap_bytes(uint16_t(code_point));
   73|       |      }
   74|   172k|      *utf16_output++ = char16_t(code_point);
   75|   172k|      pos += 3;
   76|   172k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (76:16): [True: 15.9k, False: 0]
  ------------------
   77|       |      // we have a 4-byte UTF-8 word.
   78|  15.9k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (78:11): [True: 0, False: 15.9k]
  ------------------
   79|      0|        break;
   80|      0|      } // minimal bound checking
   81|  15.9k|      uint32_t code_point = ((leading_byte & 0b00000111) << 18) |
   82|  15.9k|                            ((uint8_t(data[pos + 1]) & 0b00111111) << 12) |
   83|  15.9k|                            ((uint8_t(data[pos + 2]) & 0b00111111) << 6) |
   84|  15.9k|                            (uint8_t(data[pos + 3]) & 0b00111111);
   85|  15.9k|      code_point -= 0x10000;
   86|       |      // The mask is a no-op (code_point < 0x100000). It stops clang 18's SLP
   87|       |      // vectorizer on RISC-V V from narrowing code_point to 16 bits before
   88|       |      // the shift, which drops bits 16-19 of the code point.
   89|  15.9k|      uint16_t high_surrogate = uint16_t(0xD800 + ((code_point >> 10) & 0x3FF));
   90|  15.9k|      uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF));
   91|       |      if constexpr (!match_system(big_endian)) {
   92|       |        high_surrogate = u16_swap_bytes(high_surrogate);
   93|       |        low_surrogate = u16_swap_bytes(low_surrogate);
   94|       |      }
   95|  15.9k|      *utf16_output++ = char16_t(high_surrogate);
   96|  15.9k|      *utf16_output++ = char16_t(low_surrogate);
   97|  15.9k|      pos += 4;
   98|  15.9k|    } else {
   99|       |      // we may have a continuation but we do not do error checking
  100|      0|      return 0;
  101|      0|    }
  102|  1.36M|  }
  103|  1.39k|  return utf16_output - start;
  104|  1.39k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf1613convert_validILNS_10endiannessE1EPKcQsr7simdutf6detailE22indexes_into_byte_likeIT0_EEEmS7_mPDs:
   16|  2.01k|                                         char16_t *utf16_output) {
   17|  2.01k|  size_t pos = 0;
   18|  2.01k|  char16_t *start{utf16_output};
   19|  6.92M|  while (pos < len) {
  ------------------
  |  Branch (19:10): [True: 6.91M, False: 2.01k]
  ------------------
   20|       |#if SIMDUTF_CPLUSPLUS23
   21|       |    if !consteval
   22|       |#endif
   23|  6.91M|    {                       // try to convert the next block of 8 ASCII bytes
   24|  6.91M|      if (pos + 8 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (24:11): [True: 6.91M, False: 7.04k]
  ------------------
   25|       |                            // they are ascii
   26|  6.91M|        uint64_t v;
   27|  6.91M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   28|  6.91M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (28:13): [True: 5.69M, False: 1.21M]
  ------------------
   29|  5.69M|          size_t final_pos = pos + 8;
   30|  51.2M|          while (pos < final_pos) {
  ------------------
  |  Branch (30:18): [True: 45.5M, False: 5.69M]
  ------------------
   31|  45.5M|            const char16_t byte = uint8_t(data[pos]);
   32|  45.5M|            *utf16_output++ =
   33|  45.5M|                !match_system(big_endian) ? u16_swap_bytes(byte) : byte;
  ------------------
  |  Branch (33:17): [True: 45.5M, Folded]
  ------------------
   34|  45.5M|            pos++;
   35|  45.5M|          }
   36|  5.69M|          continue;
   37|  5.69M|        }
   38|  6.91M|      }
   39|  6.91M|    }
   40|       |
   41|  1.22M|    auto leading_byte = uint8_t(data[pos]); // leading byte
   42|  1.22M|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (42:9): [True: 790k, False: 435k]
  ------------------
   43|       |      // converting one ASCII byte !!!
   44|   790k|      *utf16_output++ = !match_system(big_endian)
  ------------------
  |  Branch (44:25): [True: 790k, Folded]
  ------------------
   45|   790k|                            ? char16_t(u16_swap_bytes(leading_byte))
   46|   790k|                            : char16_t(leading_byte);
   47|   790k|      pos++;
   48|   790k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (48:16): [True: 308k, False: 127k]
  ------------------
   49|       |      // We have a two-byte UTF-8, it should become
   50|       |      // a single UTF-16 word.
   51|   308k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (51:11): [True: 0, False: 308k]
  ------------------
   52|      0|        break;
   53|      0|      } // minimal bound checking
   54|   308k|      uint16_t code_point = uint16_t(((leading_byte & 0b00011111) << 6) |
   55|   308k|                                     (uint8_t(data[pos + 1]) & 0b00111111));
   56|   308k|      if constexpr (!match_system(big_endian)) {
   57|   308k|        code_point = u16_swap_bytes(uint16_t(code_point));
   58|   308k|      }
   59|   308k|      *utf16_output++ = char16_t(code_point);
   60|   308k|      pos += 2;
   61|   308k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (61:16): [True: 90.1k, False: 37.3k]
  ------------------
   62|       |      // We have a three-byte UTF-8, it should become
   63|       |      // a single UTF-16 word.
   64|  90.1k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (64:11): [True: 0, False: 90.1k]
  ------------------
   65|      0|        break;
   66|      0|      } // minimal bound checking
   67|  90.1k|      uint16_t code_point =
   68|  90.1k|          uint16_t(((leading_byte & 0b00001111) << 12) |
   69|  90.1k|                   ((uint8_t(data[pos + 1]) & 0b00111111) << 6) |
   70|  90.1k|                   (uint8_t(data[pos + 2]) & 0b00111111));
   71|  90.1k|      if constexpr (!match_system(big_endian)) {
   72|  90.1k|        code_point = u16_swap_bytes(uint16_t(code_point));
   73|  90.1k|      }
   74|  90.1k|      *utf16_output++ = char16_t(code_point);
   75|  90.1k|      pos += 3;
   76|  90.1k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (76:16): [True: 37.3k, False: 0]
  ------------------
   77|       |      // we have a 4-byte UTF-8 word.
   78|  37.3k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (78:11): [True: 0, False: 37.3k]
  ------------------
   79|      0|        break;
   80|      0|      } // minimal bound checking
   81|  37.3k|      uint32_t code_point = ((leading_byte & 0b00000111) << 18) |
   82|  37.3k|                            ((uint8_t(data[pos + 1]) & 0b00111111) << 12) |
   83|  37.3k|                            ((uint8_t(data[pos + 2]) & 0b00111111) << 6) |
   84|  37.3k|                            (uint8_t(data[pos + 3]) & 0b00111111);
   85|  37.3k|      code_point -= 0x10000;
   86|       |      // The mask is a no-op (code_point < 0x100000). It stops clang 18's SLP
   87|       |      // vectorizer on RISC-V V from narrowing code_point to 16 bits before
   88|       |      // the shift, which drops bits 16-19 of the code point.
   89|  37.3k|      uint16_t high_surrogate = uint16_t(0xD800 + ((code_point >> 10) & 0x3FF));
   90|  37.3k|      uint16_t low_surrogate = uint16_t(0xDC00 + (code_point & 0x3FF));
   91|  37.3k|      if constexpr (!match_system(big_endian)) {
   92|  37.3k|        high_surrogate = u16_swap_bytes(high_surrogate);
   93|  37.3k|        low_surrogate = u16_swap_bytes(low_surrogate);
   94|  37.3k|      }
   95|  37.3k|      *utf16_output++ = char16_t(high_surrogate);
   96|  37.3k|      *utf16_output++ = char16_t(low_surrogate);
   97|  37.3k|      pos += 4;
   98|  37.3k|    } else {
   99|       |      // we may have a continuation but we do not do error checking
  100|      0|      return 0;
  101|      0|    }
  102|  1.22M|  }
  103|  2.01k|  return utf16_output - start;
  104|  2.01k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf3230rewind_and_convert_with_errorsEmPKcmPDi:
  249|  1.15k|                                             char32_t *utf32_output) {
  250|  1.15k|  size_t extra_len{0};
  251|       |  // We potentially need to go back in time and find a leading byte.
  252|  1.15k|  size_t how_far_back = 3; // 3 bytes in the past + current position
  253|  1.15k|  if (how_far_back > prior_bytes) {
  ------------------
  |  Branch (253:7): [True: 332, False: 820]
  ------------------
  254|    332|    how_far_back = prior_bytes;
  255|    332|  }
  256|  1.15k|  bool found_leading_bytes{false};
  257|       |  // important: it is i <= how_far_back and not 'i < how_far_back'.
  258|  1.20k|  for (size_t i = 0; i <= how_far_back; i++) {
  ------------------
  |  Branch (258:22): [True: 1.17k, False: 28]
  ------------------
  259|  1.17k|    unsigned char byte = buf[-static_cast<std::ptrdiff_t>(i)];
  260|  1.17k|    found_leading_bytes = ((byte & 0b11000000) != 0b10000000);
  261|  1.17k|    if (found_leading_bytes) {
  ------------------
  |  Branch (261:9): [True: 1.12k, False: 52]
  ------------------
  262|  1.12k|      if (i > 0 && byte < 128) {
  ------------------
  |  Branch (262:11): [True: 24, False: 1.10k]
  |  Branch (262:20): [True: 24, False: 0]
  ------------------
  263|       |        // If we had to go back and the leading byte is ascii
  264|       |        // then we can stop right away.
  265|     24|        return result(error_code::TOO_LONG, 0 - i + 1);
  266|     24|      }
  267|  1.10k|      buf -= i;
  268|  1.10k|      extra_len = i;
  269|  1.10k|      break;
  270|  1.12k|    }
  271|  1.17k|  }
  272|       |  //
  273|       |  // It is possible for this function to return a negative count in its result.
  274|       |  // C++ Standard Section 18.1 defines size_t is in <cstddef> which is described
  275|       |  // in C Standard as <stddef.h>. C Standard Section 4.1.5 defines size_t as an
  276|       |  // unsigned integral type of the result of the sizeof operator
  277|       |  //
  278|       |  // An unsigned type will simply wrap round arithmetically (well defined).
  279|       |  //
  280|  1.12k|  if (!found_leading_bytes) {
  ------------------
  |  Branch (280:7): [True: 28, False: 1.10k]
  ------------------
  281|       |    // If how_far_back == 3, we may have four consecutive continuation bytes!!!
  282|       |    // [....] [continuation] [continuation] [continuation] | [buf is
  283|       |    // continuation] Or we possibly have a stream that does not start with a
  284|       |    // leading byte.
  285|     28|    return result(error_code::TOO_LONG, 0 - how_far_back);
  286|     28|  }
  287|       |
  288|  1.10k|  result res = convert_with_errors(buf, len + extra_len, utf32_output);
  289|  1.10k|  if (res.error) {
  ------------------
  |  Branch (289:7): [True: 832, False: 268]
  ------------------
  290|    832|    res.count -= extra_len;
  291|    832|  }
  292|  1.10k|  return res;
  293|  1.12k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf3219convert_with_errorsIPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEENS_6resultES6_mPDi:
  121|  2.60k|                                               char32_t *utf32_output) {
  122|  2.60k|  size_t pos = 0;
  123|  2.60k|  char32_t *start{utf32_output};
  124|  3.89M|  while (pos < len) {
  ------------------
  |  Branch (124:10): [True: 3.89M, False: 882]
  ------------------
  125|       |#if SIMDUTF_CPLUSPLUS23
  126|       |    if !consteval
  127|       |#endif
  128|  3.89M|    {
  129|       |      // try to convert the next block of 16 ASCII bytes
  130|  3.89M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (130:11): [True: 3.88M, False: 9.52k]
  ------------------
  131|       |                             // they are ascii
  132|  3.88M|        uint64_t v1;
  133|  3.88M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
  134|  3.88M|        uint64_t v2;
  135|  3.88M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
  136|  3.88M|        uint64_t v{v1 | v2};
  137|  3.88M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (137:13): [True: 2.22M, False: 1.65M]
  ------------------
  138|  2.22M|          size_t final_pos = pos + 16;
  139|  37.8M|          while (pos < final_pos) {
  ------------------
  |  Branch (139:18): [True: 35.5M, False: 2.22M]
  ------------------
  140|  35.5M|            *utf32_output++ = uint8_t(data[pos]);
  141|  35.5M|            pos++;
  142|  35.5M|          }
  143|  2.22M|          continue;
  144|  2.22M|        }
  145|  3.88M|      }
  146|  3.89M|    }
  147|  1.66M|    auto leading_byte = uint8_t(data[pos]); // leading byte
  148|  1.66M|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (148:9): [True: 1.34M, False: 316k]
  ------------------
  149|       |      // converting one ASCII byte !!!
  150|  1.34M|      *utf32_output++ = char32_t(leading_byte);
  151|  1.34M|      pos++;
  152|  1.34M|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (152:16): [True: 199k, False: 117k]
  ------------------
  153|       |      // We have a two-byte UTF-8
  154|   199k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (154:11): [True: 84, False: 199k]
  ------------------
  155|     84|        return result(error_code::TOO_SHORT, pos);
  156|     84|      } // minimal bound checking
  157|   199k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (157:11): [True: 258, False: 198k]
  ------------------
  158|    258|        return result(error_code::TOO_SHORT, pos);
  159|    258|      }
  160|       |      // range check
  161|   198k|      uint32_t code_point = (leading_byte & 0b00011111) << 6 |
  162|   198k|                            (uint8_t(data[pos + 1]) & 0b00111111);
  163|   198k|      if (code_point < 0x80) {
  ------------------
  |  Branch (163:11): [True: 36, False: 198k]
  ------------------
  164|     36|        return result(error_code::OVERLONG, pos);
  165|     36|      }
  166|   198k|      *utf32_output++ = char32_t(code_point);
  167|   198k|      pos += 2;
  168|   198k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (168:16): [True: 98.0k, False: 19.5k]
  ------------------
  169|       |      // We have a three-byte UTF-8
  170|  98.0k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (170:11): [True: 72, False: 98.0k]
  ------------------
  171|     72|        return result(error_code::TOO_SHORT, pos);
  172|     72|      } // minimal bound checking
  173|       |
  174|  98.0k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (174:11): [True: 126, False: 97.8k]
  ------------------
  175|    126|        return result(error_code::TOO_SHORT, pos);
  176|    126|      }
  177|  97.8k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (177:11): [True: 30, False: 97.8k]
  ------------------
  178|     30|        return result(error_code::TOO_SHORT, pos);
  179|     30|      }
  180|       |      // range check
  181|  97.8k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
  182|  97.8k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 6 |
  183|  97.8k|                            (uint8_t(data[pos + 2]) & 0b00111111);
  184|  97.8k|      if (code_point < 0x800) {
  ------------------
  |  Branch (184:11): [True: 36, False: 97.8k]
  ------------------
  185|     36|        return result(error_code::OVERLONG, pos);
  186|     36|      }
  187|  97.8k|      if (0xd7ff < code_point && code_point < 0xe000) {
  ------------------
  |  Branch (187:11): [True: 2.18k, False: 95.6k]
  |  Branch (187:34): [True: 6, False: 2.17k]
  ------------------
  188|      6|        return result(error_code::SURROGATE, pos);
  189|      6|      }
  190|  97.8k|      *utf32_output++ = char32_t(code_point);
  191|  97.8k|      pos += 3;
  192|  97.8k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (192:16): [True: 18.6k, False: 818]
  ------------------
  193|       |      // we have a 4-byte UTF-8 word.
  194|  18.6k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (194:11): [True: 36, False: 18.6k]
  ------------------
  195|     36|        return result(error_code::TOO_SHORT, pos);
  196|     36|      } // minimal bound checking
  197|  18.6k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (197:11): [True: 84, False: 18.5k]
  ------------------
  198|     84|        return result(error_code::TOO_SHORT, pos);
  199|     84|      }
  200|  18.5k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (200:11): [True: 36, False: 18.5k]
  ------------------
  201|     36|        return result(error_code::TOO_SHORT, pos);
  202|     36|      }
  203|  18.5k|      if ((uint8_t(data[pos + 3]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (203:11): [True: 42, False: 18.4k]
  ------------------
  204|     42|        return result(error_code::TOO_SHORT, pos);
  205|     42|      }
  206|       |
  207|       |      // range check
  208|  18.4k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  209|  18.4k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 12 |
  210|  18.4k|                            (uint8_t(data[pos + 2]) & 0b00111111) << 6 |
  211|  18.4k|                            (uint8_t(data[pos + 3]) & 0b00111111);
  212|  18.4k|      if (code_point <= 0xffff) {
  ------------------
  |  Branch (212:11): [True: 36, False: 18.4k]
  ------------------
  213|     36|        return result(error_code::OVERLONG, pos);
  214|     36|      }
  215|  18.4k|      if (0x10ffff < code_point) {
  ------------------
  |  Branch (215:11): [True: 24, False: 18.4k]
  ------------------
  216|     24|        return result(error_code::TOO_LARGE, pos);
  217|     24|      }
  218|  18.4k|      *utf32_output++ = char32_t(code_point);
  219|  18.4k|      pos += 4;
  220|  18.4k|    } else {
  221|       |      // we either have too many continuation bytes or an invalid leading byte
  222|    818|      if ((leading_byte & 0b11000000) == 0b10000000) {
  ------------------
  |  Branch (222:11): [True: 422, False: 396]
  ------------------
  223|    422|        return result(error_code::TOO_LONG, pos);
  224|    422|      } else {
  225|    396|        return result(error_code::HEADER_BITS, pos);
  226|    396|      }
  227|    818|    }
  228|  1.66M|  }
  229|    882|  return result(error_code::SUCCESS, utf32_output - start);
  230|  2.60k|}
simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf327convertIPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEEmS6_mPDi:
   16|  2.22k|                                   char32_t *utf32_output) {
   17|  2.22k|  size_t pos = 0;
   18|  2.22k|  char32_t *start{utf32_output};
   19|  2.72M|  while (pos < len) {
  ------------------
  |  Branch (19:10): [True: 2.72M, False: 736]
  ------------------
   20|       |#if SIMDUTF_CPLUSPLUS23
   21|       |    if !consteval
   22|       |#endif
   23|  2.72M|    {
   24|       |      // try to convert the next block of 16 ASCII bytes
   25|  2.72M|      if (pos + 16 <= len) { // if it is safe to read 16 more bytes, check that
  ------------------
  |  Branch (25:11): [True: 2.71M, False: 7.94k]
  ------------------
   26|       |                             // they are ascii
   27|  2.71M|        uint64_t v1;
   28|  2.71M|        ::memcpy(&v1, data + pos, sizeof(uint64_t));
   29|  2.71M|        uint64_t v2;
   30|  2.71M|        ::memcpy(&v2, data + pos + sizeof(uint64_t), sizeof(uint64_t));
   31|  2.71M|        uint64_t v{v1 | v2};
   32|  2.71M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (32:13): [True: 1.76M, False: 948k]
  ------------------
   33|  1.76M|          size_t final_pos = pos + 16;
   34|  30.0M|          while (pos < final_pos) {
  ------------------
  |  Branch (34:18): [True: 28.3M, False: 1.76M]
  ------------------
   35|  28.3M|            *utf32_output++ = uint8_t(data[pos]);
   36|  28.3M|            pos++;
   37|  28.3M|          }
   38|  1.76M|          continue;
   39|  1.76M|        }
   40|  2.71M|      }
   41|  2.72M|    }
   42|   956k|    auto leading_byte = uint8_t(data[pos]); // leading byte
   43|   956k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (43:9): [True: 771k, False: 185k]
  ------------------
   44|       |      // converting one ASCII byte !!!
   45|   771k|      *utf32_output++ = char32_t(leading_byte);
   46|   771k|      pos++;
   47|   771k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (47:16): [True: 124k, False: 60.3k]
  ------------------
   48|       |      // We have a two-byte UTF-8
   49|   124k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (49:11): [True: 90, False: 124k]
  ------------------
   50|     90|        return 0;
   51|     90|      } // minimal bound checking
   52|   124k|      if ((data[pos + 1] & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (52:11): [True: 232, False: 124k]
  ------------------
   53|    232|        return 0;
   54|    232|      }
   55|       |      // range check
   56|   124k|      uint32_t code_point = (leading_byte & 0b00011111) << 6 |
   57|   124k|                            (uint8_t(data[pos + 1]) & 0b00111111);
   58|   124k|      if (code_point < 0x80) {
  ------------------
  |  Branch (58:11): [True: 16, False: 124k]
  ------------------
   59|     16|        return 0;
   60|     16|      }
   61|   124k|      *utf32_output++ = char32_t(code_point);
   62|   124k|      pos += 2;
   63|   124k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (63:16): [True: 49.1k, False: 11.1k]
  ------------------
   64|       |      // We have a three-byte UTF-8
   65|  49.1k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (65:11): [True: 72, False: 49.0k]
  ------------------
   66|     72|        return 0;
   67|     72|      } // minimal bound checking
   68|       |
   69|  49.0k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (69:11): [True: 112, False: 48.9k]
  ------------------
   70|    112|        return 0;
   71|    112|      }
   72|  48.9k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (72:11): [True: 74, False: 48.9k]
  ------------------
   73|     74|        return 0;
   74|     74|      }
   75|       |      // range check
   76|  48.9k|      uint32_t code_point = (leading_byte & 0b00001111) << 12 |
   77|  48.9k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 6 |
   78|  48.9k|                            (uint8_t(data[pos + 2]) & 0b00111111);
   79|  48.9k|      if (code_point < 0x800 || (0xd7ff < code_point && code_point < 0xe000)) {
  ------------------
  |  Branch (79:11): [True: 26, False: 48.8k]
  |  Branch (79:34): [True: 1.89k, False: 46.9k]
  |  Branch (79:57): [True: 10, False: 1.88k]
  ------------------
   80|     36|        return 0;
   81|     36|      }
   82|  48.8k|      *utf32_output++ = char32_t(code_point);
   83|  48.8k|      pos += 3;
   84|  48.8k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (84:16): [True: 10.4k, False: 680]
  ------------------
   85|       |      // we have a 4-byte UTF-8 word.
   86|  10.4k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (86:11): [True: 36, False: 10.4k]
  ------------------
   87|     36|        return 0;
   88|     36|      } // minimal bound checking
   89|  10.4k|      if ((uint8_t(data[pos + 1]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (89:11): [True: 50, False: 10.3k]
  ------------------
   90|     50|        return 0;
   91|     50|      }
   92|  10.3k|      if ((uint8_t(data[pos + 2]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (92:11): [True: 26, False: 10.3k]
  ------------------
   93|     26|        return 0;
   94|     26|      }
   95|  10.3k|      if ((uint8_t(data[pos + 3]) & 0b11000000) != 0b10000000) {
  ------------------
  |  Branch (95:11): [True: 20, False: 10.3k]
  ------------------
   96|     20|        return 0;
   97|     20|      }
   98|       |
   99|       |      // range check
  100|  10.3k|      uint32_t code_point = (leading_byte & 0b00000111) << 18 |
  101|  10.3k|                            (uint8_t(data[pos + 1]) & 0b00111111) << 12 |
  102|  10.3k|                            (uint8_t(data[pos + 2]) & 0b00111111) << 6 |
  103|  10.3k|                            (uint8_t(data[pos + 3]) & 0b00111111);
  104|  10.3k|      if (code_point <= 0xffff || 0x10ffff < code_point) {
  ------------------
  |  Branch (104:11): [True: 26, False: 10.3k]
  |  Branch (104:35): [True: 14, False: 10.3k]
  ------------------
  105|     40|        return 0;
  106|     40|      }
  107|  10.3k|      *utf32_output++ = char32_t(code_point);
  108|  10.3k|      pos += 4;
  109|  10.3k|    } else {
  110|    680|      return 0;
  111|    680|    }
  112|   956k|  }
  113|    736|  return utf32_output - start;
  114|  2.22k|}

simdutf.cpp:_ZN7simdutf6scalar12_GLOBAL__N_113utf8_to_utf3213convert_validIPKcQsr7simdutf6detailE22indexes_into_byte_likeIT_EEEmS6_mPDi:
   16|  1.67k|                                         char32_t *utf32_output) {
   17|  1.67k|  size_t pos = 0;
   18|  1.67k|  char32_t *start{utf32_output};
   19|  4.85M|  while (pos < len) {
  ------------------
  |  Branch (19:10): [True: 4.85M, False: 1.67k]
  ------------------
   20|       |#if SIMDUTF_CPLUSPLUS23
   21|       |    if !consteval
   22|       |#endif
   23|  4.85M|    {
   24|       |      // try to convert the next block of 8 ASCII bytes
   25|  4.85M|      if (pos + 8 <= len) { // if it is safe to read 8 more bytes, check that
  ------------------
  |  Branch (25:11): [True: 4.84M, False: 5.49k]
  ------------------
   26|       |                            // they are ascii
   27|  4.84M|        uint64_t v;
   28|  4.84M|        ::memcpy(&v, data + pos, sizeof(uint64_t));
   29|  4.84M|        if ((v & 0x8080808080808080) == 0) {
  ------------------
  |  Branch (29:13): [True: 3.96M, False: 883k]
  ------------------
   30|  3.96M|          size_t final_pos = pos + 8;
   31|  35.6M|          while (pos < final_pos) {
  ------------------
  |  Branch (31:18): [True: 31.7M, False: 3.96M]
  ------------------
   32|  31.7M|            *utf32_output++ = uint8_t(data[pos]);
   33|  31.7M|            pos++;
   34|  31.7M|          }
   35|  3.96M|          continue;
   36|  3.96M|        }
   37|  4.84M|      }
   38|  4.85M|    }
   39|   888k|    auto leading_byte = uint8_t(data[pos]); // leading byte
   40|   888k|    if (leading_byte < 0b10000000) {
  ------------------
  |  Branch (40:9): [True: 547k, False: 340k]
  ------------------
   41|       |      // converting one ASCII byte !!!
   42|   547k|      *utf32_output++ = char32_t(leading_byte);
   43|   547k|      pos++;
   44|   547k|    } else if ((leading_byte & 0b11100000) == 0b11000000) {
  ------------------
  |  Branch (44:16): [True: 230k, False: 110k]
  ------------------
   45|       |      // We have a two-byte UTF-8
   46|   230k|      if (pos + 1 >= len) {
  ------------------
  |  Branch (46:11): [True: 0, False: 230k]
  ------------------
   47|      0|        break;
   48|      0|      } // minimal bound checking
   49|   230k|      *utf32_output++ = char32_t(((leading_byte & 0b00011111) << 6) |
   50|   230k|                                 (uint8_t(data[pos + 1]) & 0b00111111));
   51|   230k|      pos += 2;
   52|   230k|    } else if ((leading_byte & 0b11110000) == 0b11100000) {
  ------------------
  |  Branch (52:16): [True: 74.7k, False: 35.9k]
  ------------------
   53|       |      // We have a three-byte UTF-8
   54|  74.7k|      if (pos + 2 >= len) {
  ------------------
  |  Branch (54:11): [True: 0, False: 74.7k]
  ------------------
   55|      0|        break;
   56|      0|      } // minimal bound checking
   57|  74.7k|      *utf32_output++ = char32_t(((leading_byte & 0b00001111) << 12) |
   58|  74.7k|                                 ((uint8_t(data[pos + 1]) & 0b00111111) << 6) |
   59|  74.7k|                                 (uint8_t(data[pos + 2]) & 0b00111111));
   60|  74.7k|      pos += 3;
   61|  74.7k|    } else if ((leading_byte & 0b11111000) == 0b11110000) { // 0b11110000
  ------------------
  |  Branch (61:16): [True: 35.9k, False: 0]
  ------------------
   62|       |      // we have a 4-byte UTF-8 word.
   63|  35.9k|      if (pos + 3 >= len) {
  ------------------
  |  Branch (63:11): [True: 0, False: 35.9k]
  ------------------
   64|      0|        break;
   65|      0|      } // minimal bound checking
   66|  35.9k|      uint32_t code_word = ((leading_byte & 0b00000111) << 18) |
   67|  35.9k|                           ((uint8_t(data[pos + 1]) & 0b00111111) << 12) |
   68|  35.9k|                           ((uint8_t(data[pos + 2]) & 0b00111111) << 6) |
   69|  35.9k|                           (uint8_t(data[pos + 3]) & 0b00111111);
   70|  35.9k|      *utf32_output++ = char32_t(code_word);
   71|  35.9k|      pos += 4;
   72|  35.9k|    } else {
   73|       |      // we may have a continuation but we do not do error checking
   74|      0|      return 0;
   75|      0|    }
   76|   888k|  }
   77|  1.67k|  return utf32_output - start;
   78|  1.67k|}

_ZNK7simdutf8fallback14implementation13validate_utf8EPKcm:
   37|  4.44k|implementation::validate_utf8(const char *buf, size_t len) const noexcept {
   38|  4.44k|  return scalar::utf8::validate(buf, len);
   39|  4.44k|}
_ZNK7simdutf8fallback14implementation25validate_utf8_with_errorsEPKcm:
   44|  4.44k|    const char *buf, size_t len) const noexcept {
   45|  4.44k|  return scalar::utf8::validate_with_errors(buf, len);
   46|  4.44k|}
_ZNK7simdutf8fallback14implementation16validate_utf16leEPKDsm:
   77|  1.28k|                                 size_t len) const noexcept {
   78|  1.28k|  return scalar::utf16::validate<endianness::LITTLE>(buf, len);
   79|  1.28k|}
_ZNK7simdutf8fallback14implementation16validate_utf16beEPKDsm:
   85|  1.26k|                                 size_t len) const noexcept {
   86|  1.26k|  return scalar::utf16::validate<endianness::BIG>(buf, len);
   87|  1.26k|}
_ZNK7simdutf8fallback14implementation28validate_utf16le_with_errorsEPKDsm:
   90|  1.28k|    const char16_t *buf, size_t len) const noexcept {
   91|  1.28k|  return scalar::utf16::validate_with_errors<endianness::LITTLE>(buf, len);
   92|  1.28k|}
_ZNK7simdutf8fallback14implementation28validate_utf16be_with_errorsEPKDsm:
   95|  1.26k|    const char16_t *buf, size_t len) const noexcept {
   96|  1.26k|  return scalar::utf16::validate_with_errors<endianness::BIG>(buf, len);
   97|  1.26k|}
_ZNK7simdutf8fallback14implementation14validate_utf32EPKDim:
  114|  2.21k|implementation::validate_utf32(const char32_t *buf, size_t len) const noexcept {
  115|  2.21k|  return scalar::utf32::validate(buf, len);
  116|  2.21k|}
_ZNK7simdutf8fallback14implementation26validate_utf32_with_errorsEPKDim:
  121|  2.21k|    const char32_t *buf, size_t len) const noexcept {
  122|  2.21k|  return scalar::utf32::validate_with_errors(buf, len);
  123|  2.21k|}
_ZNK7simdutf8fallback14implementation22convert_latin1_to_utf8EPKcmPc:
  128|    600|    const char *buf, size_t len, char *utf8_output) const noexcept {
  129|    600|  return scalar::latin1_to_utf8::convert(buf, len, utf8_output);
  130|    600|}
_ZNK7simdutf8fallback14implementation25convert_latin1_to_utf16leEPKcmPDs:
  135|     98|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  136|     98|  return scalar::latin1_to_utf16::convert<endianness::LITTLE>(buf, len,
  137|     98|                                                              utf16_output);
  138|     98|}
_ZNK7simdutf8fallback14implementation25convert_latin1_to_utf16beEPKcmPDs:
  141|     84|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  142|     84|  return scalar::latin1_to_utf16::convert<endianness::BIG>(buf, len,
  143|     84|                                                           utf16_output);
  144|     84|}
_ZNK7simdutf8fallback14implementation23convert_latin1_to_utf32EPKcmPDi:
  149|     70|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  150|     70|  return scalar::latin1_to_utf32::convert(buf, len, utf32_output);
  151|     70|}
_ZNK7simdutf8fallback14implementation22convert_utf8_to_latin1EPKcmPc:
  156|    662|    const char *buf, size_t len, char *latin1_output) const noexcept {
  157|    662|  return scalar::utf8_to_latin1::convert(buf, len, latin1_output);
  158|    662|}
_ZNK7simdutf8fallback14implementation34convert_utf8_to_latin1_with_errorsEPKcmPc:
  161|    750|    const char *buf, size_t len, char *latin1_output) const noexcept {
  162|    750|  return scalar::utf8_to_latin1::convert_with_errors(buf, len, latin1_output);
  163|    750|}
_ZNK7simdutf8fallback14implementation23convert_utf8_to_utf16leEPKcmPDs:
  173|    984|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  174|    984|  return scalar::utf8_to_utf16::convert<endianness::LITTLE>(buf, len,
  175|    984|                                                            utf16_output);
  176|    984|}
_ZNK7simdutf8fallback14implementation23convert_utf8_to_utf16beEPKcmPDs:
  179|    960|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  180|    960|  return scalar::utf8_to_utf16::convert<endianness::BIG>(buf, len,
  181|    960|                                                         utf16_output);
  182|    960|}
_ZNK7simdutf8fallback14implementation35convert_utf8_to_utf16le_with_errorsEPKcmPDs:
  185|    790|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  186|    790|  return scalar::utf8_to_utf16::convert_with_errors<endianness::LITTLE>(
  187|    790|      buf, len, utf16_output);
  188|    790|}
_ZNK7simdutf8fallback14implementation35convert_utf8_to_utf16be_with_errorsEPKcmPDs:
  191|    884|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  192|    884|  return scalar::utf8_to_utf16::convert_with_errors<endianness::BIG>(
  193|    884|      buf, len, utf16_output);
  194|    884|}
_ZNK7simdutf8fallback14implementation29convert_valid_utf8_to_utf16leEPKcmPDs:
  197|    528|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  198|    528|  return scalar::utf8_to_utf16::convert_valid<endianness::LITTLE>(buf, len,
  199|    528|                                                                  utf16_output);
  200|    528|}
_ZNK7simdutf8fallback14implementation29convert_valid_utf8_to_utf16beEPKcmPDs:
  203|    772|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  204|    772|  return scalar::utf8_to_utf16::convert_valid<endianness::BIG>(buf, len,
  205|    772|                                                               utf16_output);
  206|    772|}
_ZNK7simdutf8fallback14implementation21convert_utf8_to_utf32EPKcmPDi:
  211|    920|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  212|    920|  return scalar::utf8_to_utf32::convert(buf, len, utf32_output);
  213|    920|}
_ZNK7simdutf8fallback14implementation33convert_utf8_to_utf32_with_errorsEPKcmPDi:
  216|    946|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  217|    946|  return scalar::utf8_to_utf32::convert_with_errors(buf, len, utf32_output);
  218|    946|}
_ZNK7simdutf8fallback14implementation27convert_valid_utf8_to_utf32EPKcmPDi:
  221|    628|    const char *input, size_t size, char32_t *utf32_output) const noexcept {
  222|    628|  return scalar::utf8_to_utf32::convert_valid(input, size, utf32_output);
  223|    628|}
_ZNK7simdutf8fallback14implementation25convert_utf16le_to_latin1EPKDsmPc:
  228|    110|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  229|    110|  return scalar::utf16_to_latin1::convert<endianness::LITTLE>(buf, len,
  230|    110|                                                              latin1_output);
  231|    110|}
_ZNK7simdutf8fallback14implementation25convert_utf16be_to_latin1EPKDsmPc:
  234|    126|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  235|    126|  return scalar::utf16_to_latin1::convert<endianness::BIG>(buf, len,
  236|    126|                                                           latin1_output);
  237|    126|}
_ZNK7simdutf8fallback14implementation37convert_utf16le_to_latin1_with_errorsEPKDsmPc:
  241|    210|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  242|    210|  return scalar::utf16_to_latin1::convert_with_errors<endianness::LITTLE>(
  243|    210|      buf, len, latin1_output);
  244|    210|}
_ZNK7simdutf8fallback14implementation37convert_utf16be_to_latin1_with_errorsEPKDsmPc:
  248|    262|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  249|    262|  return scalar::utf16_to_latin1::convert_with_errors<endianness::BIG>(
  250|    262|      buf, len, latin1_output);
  251|    262|}
_ZNK7simdutf8fallback14implementation23convert_utf16le_to_utf8EPKDsmPc:
  268|    392|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  269|    392|  return scalar::utf16_to_utf8::convert<endianness::LITTLE>(buf, len,
  270|    392|                                                            utf8_output);
  271|    392|}
_ZNK7simdutf8fallback14implementation23convert_utf16be_to_utf8EPKDsmPc:
  274|    310|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  275|    310|  return scalar::utf16_to_utf8::convert<endianness::BIG>(buf, len, utf8_output);
  276|    310|}
_ZNK7simdutf8fallback14implementation35convert_utf16le_to_utf8_with_errorsEPKDsmPc:
  279|    628|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  280|    628|  return scalar::utf16_to_utf8::convert_with_errors<endianness::LITTLE>(
  281|    628|      buf, len, utf8_output);
  282|    628|}
_ZNK7simdutf8fallback14implementation35convert_utf16be_to_utf8_with_errorsEPKDsmPc:
  285|    540|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  286|    540|  return scalar::utf16_to_utf8::convert_with_errors<endianness::BIG>(
  287|    540|      buf, len, utf8_output);
  288|    540|}
_ZNK7simdutf8fallback14implementation29convert_valid_utf16le_to_utf8EPKDsmPc:
  291|    410|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  292|    410|  return scalar::utf16_to_utf8::convert_valid<endianness::LITTLE>(buf, len,
  293|    410|                                                                  utf8_output);
  294|    410|}
_ZNK7simdutf8fallback14implementation29convert_valid_utf16be_to_utf8EPKDsmPc:
  297|    430|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  298|    430|  return scalar::utf16_to_utf8::convert_valid<endianness::BIG>(buf, len,
  299|    430|                                                               utf8_output);
  300|    430|}
_ZNK7simdutf8fallback14implementation23convert_utf32_to_latin1EPKDimPc:
  305|    190|    const char32_t *buf, size_t len, char *latin1_output) const noexcept {
  306|    190|  return scalar::utf32_to_latin1::convert(buf, len, latin1_output);
  307|    190|}
_ZNK7simdutf8fallback14implementation35convert_utf32_to_latin1_with_errorsEPKDimPc:
  310|    344|    const char32_t *buf, size_t len, char *latin1_output) const noexcept {
  311|    344|  return scalar::utf32_to_latin1::convert_with_errors(buf, len, latin1_output);
  312|    344|}
_ZNK7simdutf8fallback14implementation21convert_utf32_to_utf8EPKDimPc:
  322|    584|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
  323|    584|  return scalar::utf32_to_utf8::convert(buf, len, utf8_output);
  324|    584|}
_ZNK7simdutf8fallback14implementation33convert_utf32_to_utf8_with_errorsEPKDimPc:
  327|    772|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
  328|    772|  return scalar::utf32_to_utf8::convert_with_errors(buf, len, utf8_output);
  329|    772|}
_ZNK7simdutf8fallback14implementation27convert_valid_utf32_to_utf8EPKDimPc:
  332|    202|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
  333|    202|  return scalar::utf32_to_utf8::convert_valid(buf, len, utf8_output);
  334|    202|}
_ZNK7simdutf8fallback14implementation24convert_utf32_to_utf16leEPKDimPDs:
  339|    422|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  340|    422|  return scalar::utf32_to_utf16::convert<endianness::LITTLE>(buf, len,
  341|    422|                                                             utf16_output);
  342|    422|}
_ZNK7simdutf8fallback14implementation24convert_utf32_to_utf16beEPKDimPDs:
  345|    390|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  346|    390|  return scalar::utf32_to_utf16::convert<endianness::BIG>(buf, len,
  347|    390|                                                          utf16_output);
  348|    390|}
_ZNK7simdutf8fallback14implementation36convert_utf32_to_utf16le_with_errorsEPKDimPDs:
  351|    622|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  352|    622|  return scalar::utf32_to_utf16::convert_with_errors<endianness::LITTLE>(
  353|    622|      buf, len, utf16_output);
  354|    622|}
_ZNK7simdutf8fallback14implementation36convert_utf32_to_utf16be_with_errorsEPKDimPDs:
  357|    570|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  358|    570|  return scalar::utf32_to_utf16::convert_with_errors<endianness::BIG>(
  359|    570|      buf, len, utf16_output);
  360|    570|}
_ZNK7simdutf8fallback14implementation30convert_valid_utf32_to_utf16leEPKDimPDs:
  363|    222|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  364|    222|  return scalar::utf32_to_utf16::convert_valid<endianness::LITTLE>(
  365|    222|      buf, len, utf16_output);
  366|    222|}
_ZNK7simdutf8fallback14implementation30convert_valid_utf32_to_utf16beEPKDimPDs:
  369|     72|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  370|     72|  return scalar::utf32_to_utf16::convert_valid<endianness::BIG>(buf, len,
  371|     72|                                                                utf16_output);
  372|     72|}
_ZNK7simdutf8fallback14implementation24convert_utf16le_to_utf32EPKDsmPDi:
  375|    272|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  376|    272|  return scalar::utf16_to_utf32::convert<endianness::LITTLE>(buf, len,
  377|    272|                                                             utf32_output);
  378|    272|}
_ZNK7simdutf8fallback14implementation24convert_utf16be_to_utf32EPKDsmPDi:
  381|    252|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  382|    252|  return scalar::utf16_to_utf32::convert<endianness::BIG>(buf, len,
  383|    252|                                                          utf32_output);
  384|    252|}
_ZNK7simdutf8fallback14implementation36convert_utf16le_to_utf32_with_errorsEPKDsmPDi:
  387|    396|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  388|    396|  return scalar::utf16_to_utf32::convert_with_errors<endianness::LITTLE>(
  389|    396|      buf, len, utf32_output);
  390|    396|}
_ZNK7simdutf8fallback14implementation36convert_utf16be_to_utf32_with_errorsEPKDsmPDi:
  393|    380|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  394|    380|  return scalar::utf16_to_utf32::convert_with_errors<endianness::BIG>(
  395|    380|      buf, len, utf32_output);
  396|    380|}
_ZNK7simdutf8fallback14implementation30convert_valid_utf16le_to_utf32EPKDsmPDi:
  399|    108|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  400|    108|  return scalar::utf16_to_utf32::convert_valid<endianness::LITTLE>(
  401|    108|      buf, len, utf32_output);
  402|    108|}
_ZNK7simdutf8fallback14implementation30convert_valid_utf16be_to_utf32EPKDsmPDi:
  405|    142|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  406|    142|  return scalar::utf16_to_utf32::convert_valid<endianness::BIG>(buf, len,
  407|    142|                                                                utf32_output);
  408|    142|}
_ZNK7simdutf8fallback14implementation13count_utf16leEPKDsm:
  419|  1.28k|    const char16_t *input, size_t length) const noexcept {
  420|  1.28k|  return scalar::utf16::count_code_points<endianness::LITTLE>(input, length);
  421|  1.28k|}
_ZNK7simdutf8fallback14implementation13count_utf16beEPKDsm:
  424|  1.26k|    const char16_t *input, size_t length) const noexcept {
  425|  1.26k|  return scalar::utf16::count_code_points<endianness::BIG>(input, length);
  426|  1.26k|}
_ZNK7simdutf8fallback14implementation10count_utf8EPKcm:
  431|  4.44k|implementation::count_utf8(const char *input, size_t length) const noexcept {
  432|  4.44k|  return scalar::utf8::count_code_points(input, length);
  433|  4.44k|}
_ZNK7simdutf8fallback14implementation23latin1_length_from_utf8EPKcm:
  443|    706|    const char *buf, size_t len) const noexcept {
  444|    706|  return scalar::utf8::count_code_points(buf, len);
  445|    706|}
_ZNK7simdutf8fallback14implementation23utf8_length_from_latin1EPKcm:
  450|    300|    const char *input, size_t length) const noexcept {
  451|    300|  return scalar::latin1_to_utf8::utf8_length_from_latin1(input, length);
  452|    300|}
_ZNK7simdutf8fallback14implementation24utf8_length_from_utf16leEPKDsm:
  457|    729|    const char16_t *input, size_t length) const noexcept {
  458|    729|  return scalar::utf16::utf8_length_from_utf16<endianness::LITTLE>(input,
  459|    729|                                                                   length);
  460|    729|}
_ZNK7simdutf8fallback14implementation24utf8_length_from_utf16beEPKDsm:
  463|    657|    const char16_t *input, size_t length) const noexcept {
  464|    657|  return scalar::utf16::utf8_length_from_utf16<endianness::BIG>(input, length);
  465|    657|}
_ZNK7simdutf8fallback14implementation25utf32_length_from_utf16leEPKDsm:
  470|    394|    const char16_t *input, size_t length) const noexcept {
  471|    394|  return scalar::utf16::utf32_length_from_utf16<endianness::LITTLE>(input,
  472|    394|                                                                    length);
  473|    394|}
_ZNK7simdutf8fallback14implementation25utf32_length_from_utf16beEPKDsm:
  476|    415|    const char16_t *input, size_t length) const noexcept {
  477|    415|  return scalar::utf16::utf32_length_from_utf16<endianness::BIG>(input, length);
  478|    415|}
_ZNK7simdutf8fallback14implementation22utf16_length_from_utf8EPKcm:
  483|  2.48k|    const char *input, size_t length) const noexcept {
  484|  2.48k|  return scalar::utf8::utf16_length_from_utf8(input, length);
  485|  2.48k|}
_ZNK7simdutf8fallback14implementation22utf8_length_from_utf32EPKDim:
  518|    786|    const char32_t *input, size_t length) const noexcept {
  519|    786|  return scalar::utf32::utf8_length_from_utf32(input, length);
  520|    786|}
_ZNK7simdutf8fallback14implementation23utf16_length_from_utf32EPKDim:
  525|  1.15k|    const char32_t *input, size_t length) const noexcept {
  526|  1.15k|  return scalar::utf32::utf16_length_from_utf32(input, length);
  527|  1.15k|}
_ZNK7simdutf8fallback14implementation22utf32_length_from_utf8EPKcm:
  532|  1.25k|    const char *input, size_t length) const noexcept {
  533|  1.25k|  return scalar::utf8::count_code_points(input, length);
  534|  1.25k|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split9utf8_headIcEEmPKT_m:
   21|  8.88k|simdutf_really_inline size_t utf8_head(const T *p, size_t len) {
   22|  8.88k|  size_t h = head(p, len);
   23|  8.88k|  if (h != 0) {
  ------------------
  |  Branch (23:7): [True: 968, False: 7.91k]
  ------------------
   24|  1.02k|    for (int i = 0; i < 3 && h < len && (uint8_t(p[h]) & 0xC0) == 0x80; i++) {
  ------------------
  |  Branch (24:21): [True: 1.01k, False: 10]
  |  Branch (24:30): [True: 1.01k, False: 0]
  |  Branch (24:41): [True: 56, False: 958]
  ------------------
   25|     56|      h++;
   26|     56|    }
   27|    968|  }
   28|  8.88k|  return h;
   29|  8.88k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split3allITnDaXadL_ZNS0_21validate_utf8_unsplitEPKcmEEcEEbPKT0_mm:
   57|  4.44k|simdutf_really_inline bool all(const T *p, size_t len, size_t h) {
   58|  4.44k|  if (h != 0 && !out_of_line<F>(p, h)) {
  ------------------
  |  Branch (58:7): [True: 484, False: 3.95k]
  |  Branch (58:17): [True: 31, False: 453]
  ------------------
   59|     31|    return false;
   60|     31|  }
   61|  4.40k|  return F(p + h, len - h);
   62|  4.44k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_21validate_utf8_unsplitEPKcmEEJS5_mEEEDaDpT0_:
   46|    484|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    484|  return F(args...);
   48|    484|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11first_errorITnDaXadL_ZNS0_33validate_utf8_with_errors_unsplitEPKcmEEcEENS_6resultEPKT0_mm:
   65|  4.44k|simdutf_really_inline result first_error(const T *p, size_t len, size_t h) {
   66|  4.44k|  if (h != 0) {
  ------------------
  |  Branch (66:7): [True: 484, False: 3.95k]
  ------------------
   67|    484|    const result first = out_of_line<F>(p, h);
   68|    484|    if (first.error != error_code::SUCCESS) {
  ------------------
  |  Branch (68:9): [True: 31, False: 453]
  ------------------
   69|     31|      return first;
   70|     31|    }
   71|    484|  }
   72|  4.40k|  result r = F(p + h, len - h);
   73|  4.40k|  r.count += h;
   74|  4.40k|  return r;
   75|  4.44k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_33validate_utf8_with_errors_unsplitEPKcmEEJS5_mEEEDaDpT0_:
   46|    484|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    484|  return F(args...);
   48|    484|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split4headIcEEmPKT_m:
    8|  18.0k|simdutf_really_inline size_t head(const T *p, size_t len) {
    9|  18.0k|  if (len * sizeof(T) < min_bytes) {
  ------------------
  |  Branch (9:7): [True: 16.0k, False: 1.98k]
  ------------------
   10|  16.0k|    return 0;
   11|  16.0k|  }
   12|  1.98k|  const size_t misalignment = reinterpret_cast<uintptr_t>(p) % 64;
   13|  1.98k|  if (misalignment == 0 || misalignment % sizeof(T) != 0) {
  ------------------
  |  Branch (13:7): [True: 1, False: 1.98k]
  |  Branch (13:28): [True: 0, False: 1.98k]
  ------------------
   14|      1|    return 0;
   15|      1|  }
   16|  1.98k|  return (64 - misalignment) / sizeof(T);
   17|  1.98k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split4headIDsEEmPKT_m:
    8|  9.84k|simdutf_really_inline size_t head(const T *p, size_t len) {
    9|  9.84k|  if (len * sizeof(T) < min_bytes) {
  ------------------
  |  Branch (9:7): [True: 9.02k, False: 817]
  ------------------
   10|  9.02k|    return 0;
   11|  9.02k|  }
   12|    817|  const size_t misalignment = reinterpret_cast<uintptr_t>(p) % 64;
   13|    817|  if (misalignment == 0 || misalignment % sizeof(T) != 0) {
  ------------------
  |  Branch (13:7): [True: 4, False: 813]
  |  Branch (13:28): [True: 0, False: 813]
  ------------------
   14|      4|    return 0;
   15|      4|  }
   16|    813|  return (64 - misalignment) / sizeof(T);
   17|    817|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split10utf16_headILNS_10endiannessE0EEEmPKDsm:
   34|  2.56k|simdutf_really_inline size_t utf16_head(const char16_t *p, size_t len) {
   35|  2.56k|  size_t h = head(p, len);
   36|  2.56k|  if (h != 0 && h < len &&
  ------------------
  |  Branch (36:7): [True: 208, False: 2.35k]
  |  Branch (36:17): [True: 208, False: 0]
  ------------------
   37|    208|      scalar::utf16::is_high_surrogate<big_endian>(p[h - 1]) &&
  ------------------
  |  Branch (37:7): [True: 4, False: 204]
  ------------------
   38|      4|      scalar::utf16::is_low_surrogate<big_endian>(p[h])) {
  ------------------
  |  Branch (38:7): [True: 2, False: 2]
  ------------------
   39|      2|    h++;
   40|      2|  }
   41|  2.56k|  return h;
   42|  2.56k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split3allITnDaXadL_ZNS0_24validate_utf16le_unsplitEPKDsmEEDsEEbPKT0_mm:
   57|  1.28k|simdutf_really_inline bool all(const T *p, size_t len, size_t h) {
   58|  1.28k|  if (h != 0 && !out_of_line<F>(p, h)) {
  ------------------
  |  Branch (58:7): [True: 104, False: 1.17k]
  |  Branch (58:17): [True: 12, False: 92]
  ------------------
   59|     12|    return false;
   60|     12|  }
   61|  1.27k|  return F(p + h, len - h);
   62|  1.28k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_24validate_utf16le_unsplitEPKDsmEEJS5_mEEEDaDpT0_:
   46|    104|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    104|  return F(args...);
   48|    104|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split10utf16_headILNS_10endiannessE1EEEmPKDsm:
   34|  2.53k|simdutf_really_inline size_t utf16_head(const char16_t *p, size_t len) {
   35|  2.53k|  size_t h = head(p, len);
   36|  2.53k|  if (h != 0 && h < len &&
  ------------------
  |  Branch (36:7): [True: 216, False: 2.31k]
  |  Branch (36:17): [True: 216, False: 0]
  ------------------
   37|    216|      scalar::utf16::is_high_surrogate<big_endian>(p[h - 1]) &&
  ------------------
  |  Branch (37:7): [True: 0, False: 216]
  ------------------
   38|      0|      scalar::utf16::is_low_surrogate<big_endian>(p[h])) {
  ------------------
  |  Branch (38:7): [True: 0, False: 0]
  ------------------
   39|      0|    h++;
   40|      0|  }
   41|  2.53k|  return h;
   42|  2.53k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split3allITnDaXadL_ZNS0_24validate_utf16be_unsplitEPKDsmEEDsEEbPKT0_mm:
   57|  1.26k|simdutf_really_inline bool all(const T *p, size_t len, size_t h) {
   58|  1.26k|  if (h != 0 && !out_of_line<F>(p, h)) {
  ------------------
  |  Branch (58:7): [True: 108, False: 1.15k]
  |  Branch (58:17): [True: 11, False: 97]
  ------------------
   59|     11|    return false;
   60|     11|  }
   61|  1.25k|  return F(p + h, len - h);
   62|  1.26k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_24validate_utf16be_unsplitEPKDsmEEJS5_mEEEDaDpT0_:
   46|    108|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    108|  return F(args...);
   48|    108|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11first_errorITnDaXadL_ZNS0_36validate_utf16le_with_errors_unsplitEPKDsmEEDsEENS_6resultEPKT0_mm:
   65|  1.28k|simdutf_really_inline result first_error(const T *p, size_t len, size_t h) {
   66|  1.28k|  if (h != 0) {
  ------------------
  |  Branch (66:7): [True: 104, False: 1.17k]
  ------------------
   67|    104|    const result first = out_of_line<F>(p, h);
   68|    104|    if (first.error != error_code::SUCCESS) {
  ------------------
  |  Branch (68:9): [True: 12, False: 92]
  ------------------
   69|     12|      return first;
   70|     12|    }
   71|    104|  }
   72|  1.27k|  result r = F(p + h, len - h);
   73|  1.27k|  r.count += h;
   74|  1.27k|  return r;
   75|  1.28k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_36validate_utf16le_with_errors_unsplitEPKDsmEEJS5_mEEEDaDpT0_:
   46|    104|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    104|  return F(args...);
   48|    104|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11first_errorITnDaXadL_ZNS0_36validate_utf16be_with_errors_unsplitEPKDsmEEDsEENS_6resultEPKT0_mm:
   65|  1.26k|simdutf_really_inline result first_error(const T *p, size_t len, size_t h) {
   66|  1.26k|  if (h != 0) {
  ------------------
  |  Branch (66:7): [True: 108, False: 1.15k]
  ------------------
   67|    108|    const result first = out_of_line<F>(p, h);
   68|    108|    if (first.error != error_code::SUCCESS) {
  ------------------
  |  Branch (68:9): [True: 11, False: 97]
  ------------------
   69|     11|      return first;
   70|     11|    }
   71|    108|  }
   72|  1.25k|  result r = F(p + h, len - h);
   73|  1.25k|  r.count += h;
   74|  1.25k|  return r;
   75|  1.26k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_36validate_utf16be_with_errors_unsplitEPKDsmEEJS5_mEEEDaDpT0_:
   46|    108|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    108|  return F(args...);
   48|    108|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split4headIDiEEmPKT_m:
    8|  4.15k|simdutf_really_inline size_t head(const T *p, size_t len) {
    9|  4.15k|  if (len * sizeof(T) < min_bytes) {
  ------------------
  |  Branch (9:7): [True: 4.05k, False: 101]
  ------------------
   10|  4.05k|    return 0;
   11|  4.05k|  }
   12|    101|  const size_t misalignment = reinterpret_cast<uintptr_t>(p) % 64;
   13|    101|  if (misalignment == 0 || misalignment % sizeof(T) != 0) {
  ------------------
  |  Branch (13:7): [True: 0, False: 101]
  |  Branch (13:28): [True: 0, False: 101]
  ------------------
   14|      0|    return 0;
   15|      0|  }
   16|    101|  return (64 - misalignment) / sizeof(T);
   17|    101|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split3allITnDaXadL_ZNS0_22validate_utf32_unsplitEPKDimEEDiEEbPKT0_mm:
   57|  2.21k|simdutf_really_inline bool all(const T *p, size_t len, size_t h) {
   58|  2.21k|  if (h != 0 && !out_of_line<F>(p, h)) {
  ------------------
  |  Branch (58:7): [True: 59, False: 2.15k]
  |  Branch (58:17): [True: 34, False: 25]
  ------------------
   59|     34|    return false;
   60|     34|  }
   61|  2.17k|  return F(p + h, len - h);
   62|  2.21k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_22validate_utf32_unsplitEPKDimEEJS5_mEEEDaDpT0_:
   46|     59|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|     59|  return F(args...);
   48|     59|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split3sumITnDaXadL_ZNS0_21count_utf16le_unsplitEPKDsmEEDsEEmPKT0_mm:
   51|  1.28k|simdutf_really_inline size_t sum(const T *p, size_t len, size_t h) {
   52|  1.28k|  const size_t first = h == 0 ? 0 : out_of_line<F>(p, h);
  ------------------
  |  Branch (52:24): [True: 1.17k, False: 104]
  ------------------
   53|  1.28k|  return first + F(p + h, len - h);
   54|  1.28k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_21count_utf16le_unsplitEPKDsmEEJS5_mEEEDaDpT0_:
   46|    104|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    104|  return F(args...);
   48|    104|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split3sumITnDaXadL_ZNS0_21count_utf16be_unsplitEPKDsmEEDsEEmPKT0_mm:
   51|  1.26k|simdutf_really_inline size_t sum(const T *p, size_t len, size_t h) {
   52|  1.26k|  const size_t first = h == 0 ? 0 : out_of_line<F>(p, h);
  ------------------
  |  Branch (52:24): [True: 1.15k, False: 108]
  ------------------
   53|  1.26k|  return first + F(p + h, len - h);
   54|  1.26k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_21count_utf16be_unsplitEPKDsmEEJS5_mEEEDaDpT0_:
   46|    108|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    108|  return F(args...);
   48|    108|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split3sumITnDaXadL_ZNS0_18count_utf8_unsplitEPKcmEEcEEmPKT0_mm:
   51|  5.14k|simdutf_really_inline size_t sum(const T *p, size_t len, size_t h) {
   52|  5.14k|  const size_t first = h == 0 ? 0 : out_of_line<F>(p, h);
  ------------------
  |  Branch (52:24): [True: 4.58k, False: 560]
  ------------------
   53|  5.14k|  return first + F(p + h, len - h);
   54|  5.14k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_18count_utf8_unsplitEPKcmEEJS5_mEEEDaDpT0_:
   46|    560|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    560|  return F(args...);
   48|    560|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split3sumITnDaXadL_ZNS0_32utf8_length_from_utf16le_unsplitEPKDsmEEDsEEmPKT0_mm:
   51|    729|simdutf_really_inline size_t sum(const T *p, size_t len, size_t h) {
   52|    729|  const size_t first = h == 0 ? 0 : out_of_line<F>(p, h);
  ------------------
  |  Branch (52:24): [True: 675, False: 54]
  ------------------
   53|    729|  return first + F(p + h, len - h);
   54|    729|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_32utf8_length_from_utf16le_unsplitEPKDsmEEJS5_mEEEDaDpT0_:
   46|     54|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|     54|  return F(args...);
   48|     54|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split3sumITnDaXadL_ZNS0_32utf8_length_from_utf16be_unsplitEPKDsmEEDsEEmPKT0_mm:
   51|    657|simdutf_really_inline size_t sum(const T *p, size_t len, size_t h) {
   52|    657|  const size_t first = h == 0 ? 0 : out_of_line<F>(p, h);
  ------------------
  |  Branch (52:24): [True: 603, False: 54]
  ------------------
   53|    657|  return first + F(p + h, len - h);
   54|    657|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_32utf8_length_from_utf16be_unsplitEPKDsmEEJS5_mEEEDaDpT0_:
   46|     54|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|     54|  return F(args...);
   48|     54|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split3sumITnDaXadL_ZNS0_33utf32_length_from_utf16le_unsplitEPKDsmEEDsEEmPKT0_mm:
   51|    394|simdutf_really_inline size_t sum(const T *p, size_t len, size_t h) {
   52|    394|  const size_t first = h == 0 ? 0 : out_of_line<F>(p, h);
  ------------------
  |  Branch (52:24): [True: 361, False: 33]
  ------------------
   53|    394|  return first + F(p + h, len - h);
   54|    394|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_33utf32_length_from_utf16le_unsplitEPKDsmEEJS5_mEEEDaDpT0_:
   46|     33|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|     33|  return F(args...);
   48|     33|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split3sumITnDaXadL_ZNS0_33utf32_length_from_utf16be_unsplitEPKDsmEEDsEEmPKT0_mm:
   51|    415|simdutf_really_inline size_t sum(const T *p, size_t len, size_t h) {
   52|    415|  const size_t first = h == 0 ? 0 : out_of_line<F>(p, h);
  ------------------
  |  Branch (52:24): [True: 379, False: 36]
  ------------------
   53|    415|  return first + F(p + h, len - h);
   54|    415|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_33utf32_length_from_utf16be_unsplitEPKDsmEEJS5_mEEEDaDpT0_:
   46|     36|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|     36|  return F(args...);
   48|     36|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split3sumITnDaXadL_ZNS0_30utf16_length_from_utf8_unsplitEPKcmEEcEEmPKT0_mm:
   51|  2.48k|simdutf_really_inline size_t sum(const T *p, size_t len, size_t h) {
   52|  2.48k|  const size_t first = h == 0 ? 0 : out_of_line<F>(p, h);
  ------------------
  |  Branch (52:24): [True: 2.20k, False: 274]
  ------------------
   53|  2.48k|  return first + F(p + h, len - h);
   54|  2.48k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_30utf16_length_from_utf8_unsplitEPKcmEEJS5_mEEEDaDpT0_:
   46|    274|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    274|  return F(args...);
   48|    274|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split3sumITnDaXadL_ZNS0_31utf8_length_from_latin1_unsplitEPKcmEEcEEmPKT0_mm:
   51|    300|simdutf_really_inline size_t sum(const T *p, size_t len, size_t h) {
   52|    300|  const size_t first = h == 0 ? 0 : out_of_line<F>(p, h);
  ------------------
  |  Branch (52:24): [True: 253, False: 47]
  ------------------
   53|    300|  return first + F(p + h, len - h);
   54|    300|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_31utf8_length_from_latin1_unsplitEPKcmEEJS5_mEEEDaDpT0_:
   46|     47|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|     47|  return F(args...);
   48|     47|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split3sumITnDaXadL_ZNS0_30utf8_length_from_utf32_unsplitEPKDimEEDiEEmPKT0_mm:
   51|    786|simdutf_really_inline size_t sum(const T *p, size_t len, size_t h) {
   52|    786|  const size_t first = h == 0 ? 0 : out_of_line<F>(p, h);
  ------------------
  |  Branch (52:24): [True: 770, False: 16]
  ------------------
   53|    786|  return first + F(p + h, len - h);
   54|    786|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_30utf8_length_from_utf32_unsplitEPKDimEEJS5_mEEEDaDpT0_:
   46|     16|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|     16|  return F(args...);
   48|     16|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split3sumITnDaXadL_ZNS0_31utf16_length_from_utf32_unsplitEPKDimEEDiEEmPKT0_mm:
   51|  1.15k|simdutf_really_inline size_t sum(const T *p, size_t len, size_t h) {
   52|  1.15k|  const size_t first = h == 0 ? 0 : out_of_line<F>(p, h);
  ------------------
  |  Branch (52:24): [True: 1.13k, False: 26]
  ------------------
   53|  1.15k|  return first + F(p + h, len - h);
   54|  1.15k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_31utf16_length_from_utf32_unsplitEPKDimEEJS5_mEEEDaDpT0_:
   46|     26|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|     26|  return F(args...);
   48|     26|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split3sumITnDaXadL_ZNS0_30utf32_length_from_utf8_unsplitEPKcmEEcEEmPKT0_mm:
   51|  1.25k|simdutf_really_inline size_t sum(const T *p, size_t len, size_t h) {
   52|  1.25k|  const size_t first = h == 0 ? 0 : out_of_line<F>(p, h);
  ------------------
  |  Branch (52:24): [True: 1.11k, False: 134]
  ------------------
   53|  1.25k|  return first + F(p + h, len - h);
   54|  1.25k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_30utf32_length_from_utf8_unsplitEPKcmEEJS5_mEEEDaDpT0_:
   46|    134|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    134|  return F(args...);
   48|    134|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split9utf8_headIcEEmPKT_m:
   21|  8.88k|simdutf_really_inline size_t utf8_head(const T *p, size_t len) {
   22|  8.88k|  size_t h = head(p, len);
   23|  8.88k|  if (h != 0) {
  ------------------
  |  Branch (23:7): [True: 968, False: 7.91k]
  ------------------
   24|  1.02k|    for (int i = 0; i < 3 && h < len && (uint8_t(p[h]) & 0xC0) == 0x80; i++) {
  ------------------
  |  Branch (24:21): [True: 1.01k, False: 10]
  |  Branch (24:30): [True: 1.01k, False: 0]
  |  Branch (24:41): [True: 56, False: 958]
  ------------------
   25|     56|      h++;
   26|     56|    }
   27|    968|  }
   28|  8.88k|  return h;
   29|  8.88k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split3allITnDaXadL_ZNS0_21validate_utf8_unsplitEPKcmEEcEEbPKT0_mm:
   57|  4.44k|simdutf_really_inline bool all(const T *p, size_t len, size_t h) {
   58|  4.44k|  if (h != 0 && !out_of_line<F>(p, h)) {
  ------------------
  |  Branch (58:7): [True: 484, False: 3.95k]
  |  Branch (58:17): [True: 31, False: 453]
  ------------------
   59|     31|    return false;
   60|     31|  }
   61|  4.40k|  return F(p + h, len - h);
   62|  4.44k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_21validate_utf8_unsplitEPKcmEEJS5_mEEEDaDpT0_:
   46|    484|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    484|  return F(args...);
   48|    484|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split11first_errorITnDaXadL_ZNS0_33validate_utf8_with_errors_unsplitEPKcmEEcEENS_6resultEPKT0_mm:
   65|  4.44k|simdutf_really_inline result first_error(const T *p, size_t len, size_t h) {
   66|  4.44k|  if (h != 0) {
  ------------------
  |  Branch (66:7): [True: 484, False: 3.95k]
  ------------------
   67|    484|    const result first = out_of_line<F>(p, h);
   68|    484|    if (first.error != error_code::SUCCESS) {
  ------------------
  |  Branch (68:9): [True: 31, False: 453]
  ------------------
   69|     31|      return first;
   70|     31|    }
   71|    484|  }
   72|  4.40k|  result r = F(p + h, len - h);
   73|  4.40k|  r.count += h;
   74|  4.40k|  return r;
   75|  4.44k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_33validate_utf8_with_errors_unsplitEPKcmEEJS5_mEEEDaDpT0_:
   46|    484|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    484|  return F(args...);
   48|    484|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split4headIcEEmPKT_m:
    8|  15.5k|simdutf_really_inline size_t head(const T *p, size_t len) {
    9|  15.5k|  if (len * sizeof(T) < min_bytes) {
  ------------------
  |  Branch (9:7): [True: 13.8k, False: 1.71k]
  ------------------
   10|  13.8k|    return 0;
   11|  13.8k|  }
   12|  1.71k|  const size_t misalignment = reinterpret_cast<uintptr_t>(p) % 64;
   13|  1.71k|  if (misalignment == 0 || misalignment % sizeof(T) != 0) {
  ------------------
  |  Branch (13:7): [True: 1, False: 1.70k]
  |  Branch (13:28): [True: 0, False: 1.70k]
  ------------------
   14|      1|    return 0;
   15|      1|  }
   16|  1.70k|  return (64 - misalignment) / sizeof(T);
   17|  1.71k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split10utf16_headILNS_10endiannessE0EEEmPKDsm:
   34|  2.56k|simdutf_really_inline size_t utf16_head(const char16_t *p, size_t len) {
   35|  2.56k|  size_t h = head(p, len);
   36|  2.56k|  if (h != 0 && h < len &&
  ------------------
  |  Branch (36:7): [True: 208, False: 2.35k]
  |  Branch (36:17): [True: 208, False: 0]
  ------------------
   37|    208|      scalar::utf16::is_high_surrogate<big_endian>(p[h - 1]) &&
  ------------------
  |  Branch (37:7): [True: 4, False: 204]
  ------------------
   38|      4|      scalar::utf16::is_low_surrogate<big_endian>(p[h])) {
  ------------------
  |  Branch (38:7): [True: 2, False: 2]
  ------------------
   39|      2|    h++;
   40|      2|  }
   41|  2.56k|  return h;
   42|  2.56k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split4headIDsEEmPKT_m:
    8|  5.09k|simdutf_really_inline size_t head(const T *p, size_t len) {
    9|  5.09k|  if (len * sizeof(T) < min_bytes) {
  ------------------
  |  Branch (9:7): [True: 4.67k, False: 426]
  ------------------
   10|  4.67k|    return 0;
   11|  4.67k|  }
   12|    426|  const size_t misalignment = reinterpret_cast<uintptr_t>(p) % 64;
   13|    426|  if (misalignment == 0 || misalignment % sizeof(T) != 0) {
  ------------------
  |  Branch (13:7): [True: 2, False: 424]
  |  Branch (13:28): [True: 0, False: 424]
  ------------------
   14|      2|    return 0;
   15|      2|  }
   16|    424|  return (64 - misalignment) / sizeof(T);
   17|    426|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split3allITnDaXadL_ZNS0_24validate_utf16le_unsplitEPKDsmEEDsEEbPKT0_mm:
   57|  1.28k|simdutf_really_inline bool all(const T *p, size_t len, size_t h) {
   58|  1.28k|  if (h != 0 && !out_of_line<F>(p, h)) {
  ------------------
  |  Branch (58:7): [True: 104, False: 1.17k]
  |  Branch (58:17): [True: 12, False: 92]
  ------------------
   59|     12|    return false;
   60|     12|  }
   61|  1.27k|  return F(p + h, len - h);
   62|  1.28k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_24validate_utf16le_unsplitEPKDsmEEJS5_mEEEDaDpT0_:
   46|    104|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    104|  return F(args...);
   48|    104|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split10utf16_headILNS_10endiannessE1EEEmPKDsm:
   34|  2.53k|simdutf_really_inline size_t utf16_head(const char16_t *p, size_t len) {
   35|  2.53k|  size_t h = head(p, len);
   36|  2.53k|  if (h != 0 && h < len &&
  ------------------
  |  Branch (36:7): [True: 216, False: 2.31k]
  |  Branch (36:17): [True: 216, False: 0]
  ------------------
   37|    216|      scalar::utf16::is_high_surrogate<big_endian>(p[h - 1]) &&
  ------------------
  |  Branch (37:7): [True: 0, False: 216]
  ------------------
   38|      0|      scalar::utf16::is_low_surrogate<big_endian>(p[h])) {
  ------------------
  |  Branch (38:7): [True: 0, False: 0]
  ------------------
   39|      0|    h++;
   40|      0|  }
   41|  2.53k|  return h;
   42|  2.53k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split3allITnDaXadL_ZNS0_24validate_utf16be_unsplitEPKDsmEEDsEEbPKT0_mm:
   57|  1.26k|simdutf_really_inline bool all(const T *p, size_t len, size_t h) {
   58|  1.26k|  if (h != 0 && !out_of_line<F>(p, h)) {
  ------------------
  |  Branch (58:7): [True: 108, False: 1.15k]
  |  Branch (58:17): [True: 11, False: 97]
  ------------------
   59|     11|    return false;
   60|     11|  }
   61|  1.25k|  return F(p + h, len - h);
   62|  1.26k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_24validate_utf16be_unsplitEPKDsmEEJS5_mEEEDaDpT0_:
   46|    108|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    108|  return F(args...);
   48|    108|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split11first_errorITnDaXadL_ZNS0_36validate_utf16le_with_errors_unsplitEPKDsmEEDsEENS_6resultEPKT0_mm:
   65|  1.28k|simdutf_really_inline result first_error(const T *p, size_t len, size_t h) {
   66|  1.28k|  if (h != 0) {
  ------------------
  |  Branch (66:7): [True: 104, False: 1.17k]
  ------------------
   67|    104|    const result first = out_of_line<F>(p, h);
   68|    104|    if (first.error != error_code::SUCCESS) {
  ------------------
  |  Branch (68:9): [True: 12, False: 92]
  ------------------
   69|     12|      return first;
   70|     12|    }
   71|    104|  }
   72|  1.27k|  result r = F(p + h, len - h);
   73|  1.27k|  r.count += h;
   74|  1.27k|  return r;
   75|  1.28k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_36validate_utf16le_with_errors_unsplitEPKDsmEEJS5_mEEEDaDpT0_:
   46|    104|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    104|  return F(args...);
   48|    104|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split11first_errorITnDaXadL_ZNS0_36validate_utf16be_with_errors_unsplitEPKDsmEEDsEENS_6resultEPKT0_mm:
   65|  1.26k|simdutf_really_inline result first_error(const T *p, size_t len, size_t h) {
   66|  1.26k|  if (h != 0) {
  ------------------
  |  Branch (66:7): [True: 108, False: 1.15k]
  ------------------
   67|    108|    const result first = out_of_line<F>(p, h);
   68|    108|    if (first.error != error_code::SUCCESS) {
  ------------------
  |  Branch (68:9): [True: 11, False: 97]
  ------------------
   69|     11|      return first;
   70|     11|    }
   71|    108|  }
   72|  1.25k|  result r = F(p + h, len - h);
   73|  1.25k|  r.count += h;
   74|  1.25k|  return r;
   75|  1.26k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_36validate_utf16be_with_errors_unsplitEPKDsmEEJS5_mEEEDaDpT0_:
   46|    108|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    108|  return F(args...);
   48|    108|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split3sumITnDaXadL_ZNS0_18count_utf8_unsplitEPKcmEEcEEmPKT0_mm:
   51|  5.14k|simdutf_really_inline size_t sum(const T *p, size_t len, size_t h) {
   52|  5.14k|  const size_t first = h == 0 ? 0 : out_of_line<F>(p, h);
  ------------------
  |  Branch (52:24): [True: 4.58k, False: 560]
  ------------------
   53|  5.14k|  return first + F(p + h, len - h);
   54|  5.14k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_18count_utf8_unsplitEPKcmEEJS5_mEEEDaDpT0_:
   46|    560|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    560|  return F(args...);
   48|    560|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split3sumITnDaXadL_ZNS0_31utf8_length_from_latin1_unsplitEPKcmEEcEEmPKT0_mm:
   51|    300|simdutf_really_inline size_t sum(const T *p, size_t len, size_t h) {
   52|    300|  const size_t first = h == 0 ? 0 : out_of_line<F>(p, h);
  ------------------
  |  Branch (52:24): [True: 253, False: 47]
  ------------------
   53|    300|  return first + F(p + h, len - h);
   54|    300|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_31utf8_length_from_latin1_unsplitEPKcmEEJS5_mEEEDaDpT0_:
   46|     47|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|     47|  return F(args...);
   48|     47|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split3sumITnDaXadL_ZNS0_30utf32_length_from_utf8_unsplitEPKcmEEcEEmPKT0_mm:
   51|  1.25k|simdutf_really_inline size_t sum(const T *p, size_t len, size_t h) {
   52|  1.25k|  const size_t first = h == 0 ? 0 : out_of_line<F>(p, h);
  ------------------
  |  Branch (52:24): [True: 1.11k, False: 134]
  ------------------
   53|  1.25k|  return first + F(p + h, len - h);
   54|  1.25k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113aligned_split11out_of_lineITnDaXadL_ZNS0_30utf32_length_from_utf8_unsplitEPKcmEEJS5_mEEEDaDpT0_:
   46|    134|simdutf_never_inline auto out_of_line(Args... args) noexcept {
   47|    134|  return F(args...);
   48|    134|}

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

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf1617count_code_pointsILNS_10endiannessE0EEEmPKDsm:
    8|  1.81k|                                               size_t size) {
    9|  1.81k|  size_t pos = 0;
   10|  1.81k|  size_t count = 0;
   11|  1.13M|  for (; pos < size / 32 * 32; pos += 32) {
  ------------------
  |  Branch (11:10): [True: 1.13M, False: 1.81k]
  ------------------
   12|  1.13M|    simd16x32<uint16_t> input(reinterpret_cast<const uint16_t *>(in + pos));
   13|       |    if constexpr (!match_system(big_endian)) {
   14|       |      input.swap_bytes();
   15|       |    }
   16|  1.13M|    uint64_t not_pair = input.not_in_range(0xDC00, 0xDFFF);
   17|  1.13M|    count += count_ones(not_pair) / 2;
   18|  1.13M|  }
   19|  1.81k|  return count +
   20|  1.81k|         scalar::utf16::count_code_points<big_endian>(in + pos, size - pos);
   21|  1.81k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf1617count_code_pointsILNS_10endiannessE1EEEmPKDsm:
    8|  1.82k|                                               size_t size) {
    9|  1.82k|  size_t pos = 0;
   10|  1.82k|  size_t count = 0;
   11|  1.19M|  for (; pos < size / 32 * 32; pos += 32) {
  ------------------
  |  Branch (11:10): [True: 1.19M, False: 1.82k]
  ------------------
   12|  1.19M|    simd16x32<uint16_t> input(reinterpret_cast<const uint16_t *>(in + pos));
   13|  1.19M|    if constexpr (!match_system(big_endian)) {
   14|  1.19M|      input.swap_bytes();
   15|  1.19M|    }
   16|  1.19M|    uint64_t not_pair = input.not_in_range(0xDC00, 0xDFFF);
   17|  1.19M|    count += count_ones(not_pair) / 2;
   18|  1.19M|  }
   19|  1.82k|  return count +
   20|  1.82k|         scalar::utf16::count_code_points<big_endian>(in + pos, size - pos);
   21|  1.82k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf1623utf32_length_from_utf16ILNS_10endiannessE0EEEmPKDsm:
   51|    427|                                                     size_t size) {
   52|    427|  return count_code_points<big_endian>(in, size);
   53|    427|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf1623utf32_length_from_utf16ILNS_10endiannessE1EEEmPKDsm:
   51|    451|                                                     size_t size) {
   52|    451|  return count_code_points<big_endian>(in, size);
   53|    451|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf1617count_code_pointsILNS_10endiannessE0EEEmPKDsm:
    8|  1.67k|                                               size_t size) {
    9|  1.67k|  size_t pos = 0;
   10|  1.67k|  size_t count = 0;
   11|  1.13M|  for (; pos < size / 32 * 32; pos += 32) {
  ------------------
  |  Branch (11:10): [True: 1.13M, False: 1.67k]
  ------------------
   12|  1.13M|    simd16x32<uint16_t> input(reinterpret_cast<const uint16_t *>(in + pos));
   13|       |    if constexpr (!match_system(big_endian)) {
   14|       |      input.swap_bytes();
   15|       |    }
   16|  1.13M|    uint64_t not_pair = input.not_in_range(0xDC00, 0xDFFF);
   17|  1.13M|    count += count_ones(not_pair) / 2;
   18|  1.13M|  }
   19|  1.67k|  return count +
   20|  1.67k|         scalar::utf16::count_code_points<big_endian>(in + pos, size - pos);
   21|  1.67k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf1617count_code_pointsILNS_10endiannessE1EEEmPKDsm:
    8|  1.68k|                                               size_t size) {
    9|  1.68k|  size_t pos = 0;
   10|  1.68k|  size_t count = 0;
   11|  1.19M|  for (; pos < size / 32 * 32; pos += 32) {
  ------------------
  |  Branch (11:10): [True: 1.19M, False: 1.68k]
  ------------------
   12|  1.19M|    simd16x32<uint16_t> input(reinterpret_cast<const uint16_t *>(in + pos));
   13|  1.19M|    if constexpr (!match_system(big_endian)) {
   14|  1.19M|      input.swap_bytes();
   15|  1.19M|    }
   16|  1.19M|    uint64_t not_pair = input.not_in_range(0xDC00, 0xDFFF);
   17|  1.19M|    count += count_ones(not_pair) / 2;
   18|  1.19M|  }
   19|  1.68k|  return count +
   20|  1.68k|         scalar::utf16::count_code_points<big_endian>(in + pos, size - pos);
   21|  1.68k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf1623utf32_length_from_utf16ILNS_10endiannessE0EEEmPKDsm:
   51|    394|                                                     size_t size) {
   52|    394|  return count_code_points<big_endian>(in, size);
   53|    394|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf1623utf32_length_from_utf16ILNS_10endiannessE1EEEmPKDsm:
   51|    415|                                                     size_t size) {
   52|    415|  return count_code_points<big_endian>(in, size);
   53|    415|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf1631utf8_length_from_utf16_bytemaskILNS_10endiannessE0EEEmPKDsm:
   10|    783|                                                             size_t size) {
   11|    783|  size_t pos = 0;
   12|       |
   13|    783|  using vector_u16 = simd16<uint16_t>;
   14|    783|  constexpr size_t N = vector_u16::ELEMENTS;
   15|       |
   16|    783|  const auto one = vector_u16::splat(1);
   17|       |
   18|    783|  auto v_count = vector_u16::zero();
   19|       |
   20|       |  // each char16 yields at least one byte
   21|    783|  size_t count = size / N * N;
   22|       |
   23|       |  // in a single iteration the increment is 0, 1 or 2, despite we have
   24|       |  // three additions
   25|    783|  constexpr size_t max_iterations = 65535 / 2;
   26|    783|  size_t iteration = max_iterations;
   27|       |
   28|  1.00M|  for (; pos < size / N * N; pos += N) {
  ------------------
  |  Branch (28:10): [True: 1.00M, False: 783]
  ------------------
   29|  1.00M|    auto input = vector_u16::load(reinterpret_cast<const uint16_t *>(in + pos));
   30|       |    if constexpr (!match_system(big_endian)) {
   31|       |      input = input.swap_bytes();
   32|       |    }
   33|       |    // 0xd800 .. 0xdbff - low surrogate
   34|       |    // 0xdc00 .. 0xdfff - high surrogate
   35|  1.00M|    const auto is_surrogate = ((input & uint16_t(0xf800)) == uint16_t(0xd800));
   36|       |
   37|       |    // c0 - chars that yield 2- or 3-byte UTF-8 codes
   38|  1.00M|    const auto c0 = min(input & uint16_t(0xff80), one);
   39|       |
   40|       |    // c1 - chars that yield 3-byte UTF-8 codes (including surrogates)
   41|  1.00M|    const auto c1 = min(input & uint16_t(0xf800), one);
   42|       |
   43|       |    /*
   44|       |        Explanation how the counting works.
   45|       |
   46|       |        In the case of a non-surrogate character we count:
   47|       |        * always 1 -- see how `count` is initialized above;
   48|       |        * c0 = 1 if the current char yields 2 or 3 bytes;
   49|       |        * c1 = 1 if the current char yields 3 bytes.
   50|       |
   51|       |        Thus, we always have correct count for the current char:
   52|       |        from 1, 2 or 3 bytes.
   53|       |
   54|       |        A trickier part is how we count surrogate pairs. Whether
   55|       |        we encounter a surrogate (low or high), we count it as
   56|       |        3 chars and then minus 1 (`is_surrogate` is -1 or 0).
   57|       |        Each surrogate char yields 2. A surrogate pair, that
   58|       |        is a low surrogate followed by a high one, yields
   59|       |        the expected 4 bytes.
   60|       |
   61|       |        It also correctly handles cases when low surrogate is
   62|       |        processed by the this loop, but high surrogate is counted
   63|       |        by the scalar procedure. The scalar procedure uses exactly
   64|       |        the described approach, thanks to that for valid UTF-16
   65|       |        strings it always count correctly.
   66|       |    */
   67|  1.00M|    v_count += c0;
   68|  1.00M|    v_count += c1;
   69|  1.00M|    v_count += vector_u16(is_surrogate);
   70|       |
   71|  1.00M|    iteration -= 1;
   72|  1.00M|    if (iteration == 0) {
  ------------------
  |  Branch (72:9): [True: 4, False: 1.00M]
  ------------------
   73|      4|      count += v_count.sum();
   74|      4|      v_count = vector_u16::zero();
   75|      4|      iteration = max_iterations;
   76|      4|    }
   77|  1.00M|  }
   78|       |
   79|    783|  if (iteration > 0) {
  ------------------
  |  Branch (79:7): [True: 783, False: 0]
  ------------------
   80|    783|    count += v_count.sum();
   81|    783|  }
   82|       |
   83|    783|  return count + scalar::utf16::utf8_length_from_utf16<big_endian>(in + pos,
   84|    783|                                                                   size - pos);
   85|    783|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf1631utf8_length_from_utf16_bytemaskILNS_10endiannessE1EEEmPKDsm:
   10|    711|                                                             size_t size) {
   11|    711|  size_t pos = 0;
   12|       |
   13|    711|  using vector_u16 = simd16<uint16_t>;
   14|    711|  constexpr size_t N = vector_u16::ELEMENTS;
   15|       |
   16|    711|  const auto one = vector_u16::splat(1);
   17|       |
   18|    711|  auto v_count = vector_u16::zero();
   19|       |
   20|       |  // each char16 yields at least one byte
   21|    711|  size_t count = size / N * N;
   22|       |
   23|       |  // in a single iteration the increment is 0, 1 or 2, despite we have
   24|       |  // three additions
   25|    711|  constexpr size_t max_iterations = 65535 / 2;
   26|    711|  size_t iteration = max_iterations;
   27|       |
   28|   860k|  for (; pos < size / N * N; pos += N) {
  ------------------
  |  Branch (28:10): [True: 859k, False: 711]
  ------------------
   29|   859k|    auto input = vector_u16::load(reinterpret_cast<const uint16_t *>(in + pos));
   30|   859k|    if constexpr (!match_system(big_endian)) {
   31|   859k|      input = input.swap_bytes();
   32|   859k|    }
   33|       |    // 0xd800 .. 0xdbff - low surrogate
   34|       |    // 0xdc00 .. 0xdfff - high surrogate
   35|   859k|    const auto is_surrogate = ((input & uint16_t(0xf800)) == uint16_t(0xd800));
   36|       |
   37|       |    // c0 - chars that yield 2- or 3-byte UTF-8 codes
   38|   859k|    const auto c0 = min(input & uint16_t(0xff80), one);
   39|       |
   40|       |    // c1 - chars that yield 3-byte UTF-8 codes (including surrogates)
   41|   859k|    const auto c1 = min(input & uint16_t(0xf800), one);
   42|       |
   43|       |    /*
   44|       |        Explanation how the counting works.
   45|       |
   46|       |        In the case of a non-surrogate character we count:
   47|       |        * always 1 -- see how `count` is initialized above;
   48|       |        * c0 = 1 if the current char yields 2 or 3 bytes;
   49|       |        * c1 = 1 if the current char yields 3 bytes.
   50|       |
   51|       |        Thus, we always have correct count for the current char:
   52|       |        from 1, 2 or 3 bytes.
   53|       |
   54|       |        A trickier part is how we count surrogate pairs. Whether
   55|       |        we encounter a surrogate (low or high), we count it as
   56|       |        3 chars and then minus 1 (`is_surrogate` is -1 or 0).
   57|       |        Each surrogate char yields 2. A surrogate pair, that
   58|       |        is a low surrogate followed by a high one, yields
   59|       |        the expected 4 bytes.
   60|       |
   61|       |        It also correctly handles cases when low surrogate is
   62|       |        processed by the this loop, but high surrogate is counted
   63|       |        by the scalar procedure. The scalar procedure uses exactly
   64|       |        the described approach, thanks to that for valid UTF-16
   65|       |        strings it always count correctly.
   66|       |    */
   67|   859k|    v_count += c0;
   68|   859k|    v_count += c1;
   69|   859k|    v_count += vector_u16(is_surrogate);
   70|       |
   71|   859k|    iteration -= 1;
   72|   859k|    if (iteration == 0) {
  ------------------
  |  Branch (72:9): [True: 1, False: 859k]
  ------------------
   73|      1|      count += v_count.sum();
   74|      1|      v_count = vector_u16::zero();
   75|      1|      iteration = max_iterations;
   76|      1|    }
   77|   859k|  }
   78|       |
   79|    711|  if (iteration > 0) {
  ------------------
  |  Branch (79:7): [True: 711, False: 0]
  ------------------
   80|    711|    count += v_count.sum();
   81|    711|  }
   82|       |
   83|    711|  return count + scalar::utf16::utf8_length_from_utf16<big_endian>(in + pos,
   84|    711|                                                                   size - pos);
   85|    711|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf1631utf8_length_from_utf16_bytemaskILNS_10endiannessE0EEEmPKDsm:
   10|    729|                                                             size_t size) {
   11|    729|  size_t pos = 0;
   12|       |
   13|    729|  using vector_u16 = simd16<uint16_t>;
   14|    729|  constexpr size_t N = vector_u16::ELEMENTS;
   15|       |
   16|    729|  const auto one = vector_u16::splat(1);
   17|       |
   18|    729|  auto v_count = vector_u16::zero();
   19|       |
   20|       |  // each char16 yields at least one byte
   21|    729|  size_t count = size / N * N;
   22|       |
   23|       |  // in a single iteration the increment is 0, 1 or 2, despite we have
   24|       |  // three additions
   25|    729|  constexpr size_t max_iterations = 65535 / 2;
   26|    729|  size_t iteration = max_iterations;
   27|       |
   28|  2.01M|  for (; pos < size / N * N; pos += N) {
  ------------------
  |  Branch (28:10): [True: 2.01M, False: 729]
  ------------------
   29|  2.01M|    auto input = vector_u16::load(reinterpret_cast<const uint16_t *>(in + pos));
   30|       |    if constexpr (!match_system(big_endian)) {
   31|       |      input = input.swap_bytes();
   32|       |    }
   33|       |    // 0xd800 .. 0xdbff - low surrogate
   34|       |    // 0xdc00 .. 0xdfff - high surrogate
   35|  2.01M|    const auto is_surrogate = ((input & uint16_t(0xf800)) == uint16_t(0xd800));
   36|       |
   37|       |    // c0 - chars that yield 2- or 3-byte UTF-8 codes
   38|  2.01M|    const auto c0 = min(input & uint16_t(0xff80), one);
   39|       |
   40|       |    // c1 - chars that yield 3-byte UTF-8 codes (including surrogates)
   41|  2.01M|    const auto c1 = min(input & uint16_t(0xf800), one);
   42|       |
   43|       |    /*
   44|       |        Explanation how the counting works.
   45|       |
   46|       |        In the case of a non-surrogate character we count:
   47|       |        * always 1 -- see how `count` is initialized above;
   48|       |        * c0 = 1 if the current char yields 2 or 3 bytes;
   49|       |        * c1 = 1 if the current char yields 3 bytes.
   50|       |
   51|       |        Thus, we always have correct count for the current char:
   52|       |        from 1, 2 or 3 bytes.
   53|       |
   54|       |        A trickier part is how we count surrogate pairs. Whether
   55|       |        we encounter a surrogate (low or high), we count it as
   56|       |        3 chars and then minus 1 (`is_surrogate` is -1 or 0).
   57|       |        Each surrogate char yields 2. A surrogate pair, that
   58|       |        is a low surrogate followed by a high one, yields
   59|       |        the expected 4 bytes.
   60|       |
   61|       |        It also correctly handles cases when low surrogate is
   62|       |        processed by the this loop, but high surrogate is counted
   63|       |        by the scalar procedure. The scalar procedure uses exactly
   64|       |        the described approach, thanks to that for valid UTF-16
   65|       |        strings it always count correctly.
   66|       |    */
   67|  2.01M|    v_count += c0;
   68|  2.01M|    v_count += c1;
   69|  2.01M|    v_count += vector_u16(is_surrogate);
   70|       |
   71|  2.01M|    iteration -= 1;
   72|  2.01M|    if (iteration == 0) {
  ------------------
  |  Branch (72:9): [True: 48, False: 2.01M]
  ------------------
   73|     48|      count += v_count.sum();
   74|     48|      v_count = vector_u16::zero();
   75|     48|      iteration = max_iterations;
   76|     48|    }
   77|  2.01M|  }
   78|       |
   79|    729|  if (iteration > 0) {
  ------------------
  |  Branch (79:7): [True: 729, False: 0]
  ------------------
   80|    729|    count += v_count.sum();
   81|    729|  }
   82|       |
   83|    729|  return count + scalar::utf16::utf8_length_from_utf16<big_endian>(in + pos,
   84|    729|                                                                   size - pos);
   85|    729|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf1631utf8_length_from_utf16_bytemaskILNS_10endiannessE1EEEmPKDsm:
   10|    657|                                                             size_t size) {
   11|    657|  size_t pos = 0;
   12|       |
   13|    657|  using vector_u16 = simd16<uint16_t>;
   14|    657|  constexpr size_t N = vector_u16::ELEMENTS;
   15|       |
   16|    657|  const auto one = vector_u16::splat(1);
   17|       |
   18|    657|  auto v_count = vector_u16::zero();
   19|       |
   20|       |  // each char16 yields at least one byte
   21|    657|  size_t count = size / N * N;
   22|       |
   23|       |  // in a single iteration the increment is 0, 1 or 2, despite we have
   24|       |  // three additions
   25|    657|  constexpr size_t max_iterations = 65535 / 2;
   26|    657|  size_t iteration = max_iterations;
   27|       |
   28|  1.72M|  for (; pos < size / N * N; pos += N) {
  ------------------
  |  Branch (28:10): [True: 1.72M, False: 657]
  ------------------
   29|  1.72M|    auto input = vector_u16::load(reinterpret_cast<const uint16_t *>(in + pos));
   30|  1.72M|    if constexpr (!match_system(big_endian)) {
   31|  1.72M|      input = input.swap_bytes();
   32|  1.72M|    }
   33|       |    // 0xd800 .. 0xdbff - low surrogate
   34|       |    // 0xdc00 .. 0xdfff - high surrogate
   35|  1.72M|    const auto is_surrogate = ((input & uint16_t(0xf800)) == uint16_t(0xd800));
   36|       |
   37|       |    // c0 - chars that yield 2- or 3-byte UTF-8 codes
   38|  1.72M|    const auto c0 = min(input & uint16_t(0xff80), one);
   39|       |
   40|       |    // c1 - chars that yield 3-byte UTF-8 codes (including surrogates)
   41|  1.72M|    const auto c1 = min(input & uint16_t(0xf800), one);
   42|       |
   43|       |    /*
   44|       |        Explanation how the counting works.
   45|       |
   46|       |        In the case of a non-surrogate character we count:
   47|       |        * always 1 -- see how `count` is initialized above;
   48|       |        * c0 = 1 if the current char yields 2 or 3 bytes;
   49|       |        * c1 = 1 if the current char yields 3 bytes.
   50|       |
   51|       |        Thus, we always have correct count for the current char:
   52|       |        from 1, 2 or 3 bytes.
   53|       |
   54|       |        A trickier part is how we count surrogate pairs. Whether
   55|       |        we encounter a surrogate (low or high), we count it as
   56|       |        3 chars and then minus 1 (`is_surrogate` is -1 or 0).
   57|       |        Each surrogate char yields 2. A surrogate pair, that
   58|       |        is a low surrogate followed by a high one, yields
   59|       |        the expected 4 bytes.
   60|       |
   61|       |        It also correctly handles cases when low surrogate is
   62|       |        processed by the this loop, but high surrogate is counted
   63|       |        by the scalar procedure. The scalar procedure uses exactly
   64|       |        the described approach, thanks to that for valid UTF-16
   65|       |        strings it always count correctly.
   66|       |    */
   67|  1.72M|    v_count += c0;
   68|  1.72M|    v_count += c1;
   69|  1.72M|    v_count += vector_u16(is_surrogate);
   70|       |
   71|  1.72M|    iteration -= 1;
   72|  1.72M|    if (iteration == 0) {
  ------------------
  |  Branch (72:9): [True: 36, False: 1.72M]
  ------------------
   73|     36|      count += v_count.sum();
   74|     36|      v_count = vector_u16::zero();
   75|     36|      iteration = max_iterations;
   76|     36|    }
   77|  1.72M|  }
   78|       |
   79|    657|  if (iteration > 0) {
  ------------------
  |  Branch (79:7): [True: 657, False: 0]
  ------------------
   80|    657|    count += v_count.sum();
   81|    657|  }
   82|       |
   83|    657|  return count + scalar::utf16::utf8_length_from_utf16<big_endian>(in + pos,
   84|    657|                                                                   size - pos);
   85|    657|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf3222utf8_length_from_utf32EPKDim:
   11|    786|                                                    size_t length) {
   12|    786|  using vector_u32 = simd32<uint32_t>;
   13|       |
   14|    786|  const char32_t *start = input;
   15|       |
   16|       |  // we add up to three ones in a single iteration (see the vectorized loop in
   17|       |  // section #2 below)
   18|    786|  const size_t max_increment = 3;
   19|       |
   20|    786|  const size_t N = vector_u32::ELEMENTS;
   21|       |
   22|       |#if SIMDUTF_SIMD_HAS_UNSIGNED_CMP
   23|       |  const auto v_0000007f = vector_u32::splat(0x0000007f);
   24|       |  const auto v_000007ff = vector_u32::splat(0x000007ff);
   25|       |  const auto v_0000ffff = vector_u32::splat(0x0000ffff);
   26|       |#else
   27|    786|  const auto v_ffffff80 = vector_u32::splat(0xffffff80);
   28|    786|  const auto v_fffff800 = vector_u32::splat(0xfffff800);
   29|    786|  const auto v_ffff0000 = vector_u32::splat(0xffff0000);
   30|    786|  const auto one = vector_u32::splat(1);
   31|    786|#endif // SIMDUTF_SIMD_HAS_UNSIGNED_CMP
   32|       |
   33|    786|  size_t counter = 0;
   34|       |
   35|       |  // 1. vectorized loop unrolled 4 times
   36|    786|  {
   37|       |    // we use vector of uint32 counters, this is why this limit is used
   38|    786|    const size_t max_iterations =
   39|    786|        std::numeric_limits<uint32_t>::max() / (max_increment * 4);
   40|    786|    size_t blocks = length / (N * 4);
   41|    786|    length -= blocks * (N * 4);
   42|  1.18k|    while (blocks != 0) {
  ------------------
  |  Branch (42:12): [True: 402, False: 786]
  ------------------
   43|    402|      const size_t iterations = min(blocks, max_iterations);
   44|    402|      blocks -= iterations;
   45|       |
   46|    402|      simd32<uint32_t> acc = vector_u32::zero();
   47|   132k|      for (size_t i = 0; i < iterations; i++) {
  ------------------
  |  Branch (47:26): [True: 132k, False: 402]
  ------------------
   48|   132k|        const auto in0 = vector_u32(input + 0 * N);
   49|   132k|        const auto in1 = vector_u32(input + 1 * N);
   50|   132k|        const auto in2 = vector_u32(input + 2 * N);
   51|   132k|        const auto in3 = vector_u32(input + 3 * N);
   52|       |
   53|       |#if SIMDUTF_SIMD_HAS_UNSIGNED_CMP
   54|       |        acc -= as_vector_u32(in0 > v_0000007f);
   55|       |        acc -= as_vector_u32(in1 > v_0000007f);
   56|       |        acc -= as_vector_u32(in2 > v_0000007f);
   57|       |        acc -= as_vector_u32(in3 > v_0000007f);
   58|       |
   59|       |        acc -= as_vector_u32(in0 > v_000007ff);
   60|       |        acc -= as_vector_u32(in1 > v_000007ff);
   61|       |        acc -= as_vector_u32(in2 > v_000007ff);
   62|       |        acc -= as_vector_u32(in3 > v_000007ff);
   63|       |
   64|       |        acc -= as_vector_u32(in0 > v_0000ffff);
   65|       |        acc -= as_vector_u32(in1 > v_0000ffff);
   66|       |        acc -= as_vector_u32(in2 > v_0000ffff);
   67|       |        acc -= as_vector_u32(in3 > v_0000ffff);
   68|       |#else
   69|   132k|        acc += min(one, in0 & v_ffffff80);
   70|   132k|        acc += min(one, in1 & v_ffffff80);
   71|   132k|        acc += min(one, in2 & v_ffffff80);
   72|   132k|        acc += min(one, in3 & v_ffffff80);
   73|       |
   74|   132k|        acc += min(one, in0 & v_fffff800);
   75|   132k|        acc += min(one, in1 & v_fffff800);
   76|   132k|        acc += min(one, in2 & v_fffff800);
   77|   132k|        acc += min(one, in3 & v_fffff800);
   78|       |
   79|   132k|        acc += min(one, in0 & v_ffff0000);
   80|   132k|        acc += min(one, in1 & v_ffff0000);
   81|   132k|        acc += min(one, in2 & v_ffff0000);
   82|   132k|        acc += min(one, in3 & v_ffff0000);
   83|   132k|#endif // SIMDUTF_SIMD_HAS_UNSIGNED_CMP
   84|       |
   85|   132k|        input += 4 * N;
   86|   132k|      }
   87|       |
   88|    402|      counter += acc.sum();
   89|    402|    }
   90|    786|  }
   91|       |
   92|       |  // 2. vectorized loop for tail
   93|    786|  {
   94|    786|    const size_t max_iterations =
   95|    786|        std::numeric_limits<uint32_t>::max() / max_increment;
   96|    786|    size_t blocks = length / N;
   97|    786|    length -= blocks * N;
   98|  1.20k|    while (blocks != 0) {
  ------------------
  |  Branch (98:12): [True: 422, False: 786]
  ------------------
   99|    422|      const size_t iterations = min(blocks, max_iterations);
  100|    422|      blocks -= iterations;
  101|       |
  102|    422|      auto acc = vector_u32::zero();
  103|  1.45k|      for (size_t i = 0; i < iterations; i++) {
  ------------------
  |  Branch (103:26): [True: 1.03k, False: 422]
  ------------------
  104|  1.03k|        const auto in = vector_u32(input);
  105|       |
  106|       |#if SIMDUTF_SIMD_HAS_UNSIGNED_CMP
  107|       |        acc -= as_vector_u32(in > v_0000007f);
  108|       |        acc -= as_vector_u32(in > v_000007ff);
  109|       |        acc -= as_vector_u32(in > v_0000ffff);
  110|       |#else
  111|  1.03k|        acc += min(one, in & v_ffffff80);
  112|  1.03k|        acc += min(one, in & v_fffff800);
  113|  1.03k|        acc += min(one, in & v_ffff0000);
  114|  1.03k|#endif // SIMDUTF_SIMD_HAS_UNSIGNED_CMP
  115|       |
  116|  1.03k|        input += N;
  117|  1.03k|      }
  118|       |
  119|    422|      counter += acc.sum();
  120|    422|    }
  121|    786|  }
  122|       |
  123|    786|  const size_t consumed = input - start;
  124|    786|  if (consumed != 0) {
  ------------------
  |  Branch (124:7): [True: 464, False: 322]
  ------------------
  125|       |    // We don't count 0th bytes in the vectorized loops above, this
  126|       |    // is why we need to count them in the end.
  127|    464|    counter += consumed;
  128|    464|  }
  129|       |
  130|    786|  return counter + scalar::utf32::utf8_length_from_utf32(input, length);
  131|    786|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf323minImEET_S4_S4_:
    8|    824|template <typename T> T min(T a, T b) { return a <= b ? a : b; }
  ------------------
  |  Branch (8:48): [True: 824, False: 0]
  ------------------
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf3222utf8_length_from_utf32EPKDim:
   11|    802|                                                    size_t length) {
   12|    802|  using vector_u32 = simd32<uint32_t>;
   13|       |
   14|    802|  const char32_t *start = input;
   15|       |
   16|       |  // we add up to three ones in a single iteration (see the vectorized loop in
   17|       |  // section #2 below)
   18|    802|  const size_t max_increment = 3;
   19|       |
   20|    802|  const size_t N = vector_u32::ELEMENTS;
   21|       |
   22|       |#if SIMDUTF_SIMD_HAS_UNSIGNED_CMP
   23|       |  const auto v_0000007f = vector_u32::splat(0x0000007f);
   24|       |  const auto v_000007ff = vector_u32::splat(0x000007ff);
   25|       |  const auto v_0000ffff = vector_u32::splat(0x0000ffff);
   26|       |#else
   27|    802|  const auto v_ffffff80 = vector_u32::splat(0xffffff80);
   28|    802|  const auto v_fffff800 = vector_u32::splat(0xfffff800);
   29|    802|  const auto v_ffff0000 = vector_u32::splat(0xffff0000);
   30|    802|  const auto one = vector_u32::splat(1);
   31|    802|#endif // SIMDUTF_SIMD_HAS_UNSIGNED_CMP
   32|       |
   33|    802|  size_t counter = 0;
   34|       |
   35|       |  // 1. vectorized loop unrolled 4 times
   36|    802|  {
   37|       |    // we use vector of uint32 counters, this is why this limit is used
   38|    802|    const size_t max_iterations =
   39|    802|        std::numeric_limits<uint32_t>::max() / (max_increment * 4);
   40|    802|    size_t blocks = length / (N * 4);
   41|    802|    length -= blocks * (N * 4);
   42|    977|    while (blocks != 0) {
  ------------------
  |  Branch (42:12): [True: 175, False: 802]
  ------------------
   43|    175|      const size_t iterations = min(blocks, max_iterations);
   44|    175|      blocks -= iterations;
   45|       |
   46|    175|      simd32<uint32_t> acc = vector_u32::zero();
   47|  66.2k|      for (size_t i = 0; i < iterations; i++) {
  ------------------
  |  Branch (47:26): [True: 66.1k, False: 175]
  ------------------
   48|  66.1k|        const auto in0 = vector_u32(input + 0 * N);
   49|  66.1k|        const auto in1 = vector_u32(input + 1 * N);
   50|  66.1k|        const auto in2 = vector_u32(input + 2 * N);
   51|  66.1k|        const auto in3 = vector_u32(input + 3 * N);
   52|       |
   53|       |#if SIMDUTF_SIMD_HAS_UNSIGNED_CMP
   54|       |        acc -= as_vector_u32(in0 > v_0000007f);
   55|       |        acc -= as_vector_u32(in1 > v_0000007f);
   56|       |        acc -= as_vector_u32(in2 > v_0000007f);
   57|       |        acc -= as_vector_u32(in3 > v_0000007f);
   58|       |
   59|       |        acc -= as_vector_u32(in0 > v_000007ff);
   60|       |        acc -= as_vector_u32(in1 > v_000007ff);
   61|       |        acc -= as_vector_u32(in2 > v_000007ff);
   62|       |        acc -= as_vector_u32(in3 > v_000007ff);
   63|       |
   64|       |        acc -= as_vector_u32(in0 > v_0000ffff);
   65|       |        acc -= as_vector_u32(in1 > v_0000ffff);
   66|       |        acc -= as_vector_u32(in2 > v_0000ffff);
   67|       |        acc -= as_vector_u32(in3 > v_0000ffff);
   68|       |#else
   69|  66.1k|        acc += min(one, in0 & v_ffffff80);
   70|  66.1k|        acc += min(one, in1 & v_ffffff80);
   71|  66.1k|        acc += min(one, in2 & v_ffffff80);
   72|  66.1k|        acc += min(one, in3 & v_ffffff80);
   73|       |
   74|  66.1k|        acc += min(one, in0 & v_fffff800);
   75|  66.1k|        acc += min(one, in1 & v_fffff800);
   76|  66.1k|        acc += min(one, in2 & v_fffff800);
   77|  66.1k|        acc += min(one, in3 & v_fffff800);
   78|       |
   79|  66.1k|        acc += min(one, in0 & v_ffff0000);
   80|  66.1k|        acc += min(one, in1 & v_ffff0000);
   81|  66.1k|        acc += min(one, in2 & v_ffff0000);
   82|  66.1k|        acc += min(one, in3 & v_ffff0000);
   83|  66.1k|#endif // SIMDUTF_SIMD_HAS_UNSIGNED_CMP
   84|       |
   85|  66.1k|        input += 4 * N;
   86|  66.1k|      }
   87|       |
   88|    175|      counter += acc.sum();
   89|    175|    }
   90|    802|  }
   91|       |
   92|       |  // 2. vectorized loop for tail
   93|    802|  {
   94|    802|    const size_t max_iterations =
   95|    802|        std::numeric_limits<uint32_t>::max() / max_increment;
   96|    802|    size_t blocks = length / N;
   97|    802|    length -= blocks * N;
   98|  1.20k|    while (blocks != 0) {
  ------------------
  |  Branch (98:12): [True: 406, False: 802]
  ------------------
   99|    406|      const size_t iterations = min(blocks, max_iterations);
  100|    406|      blocks -= iterations;
  101|       |
  102|    406|      auto acc = vector_u32::zero();
  103|  1.36k|      for (size_t i = 0; i < iterations; i++) {
  ------------------
  |  Branch (103:26): [True: 960, False: 406]
  ------------------
  104|    960|        const auto in = vector_u32(input);
  105|       |
  106|       |#if SIMDUTF_SIMD_HAS_UNSIGNED_CMP
  107|       |        acc -= as_vector_u32(in > v_0000007f);
  108|       |        acc -= as_vector_u32(in > v_000007ff);
  109|       |        acc -= as_vector_u32(in > v_0000ffff);
  110|       |#else
  111|    960|        acc += min(one, in & v_ffffff80);
  112|    960|        acc += min(one, in & v_fffff800);
  113|    960|        acc += min(one, in & v_ffff0000);
  114|    960|#endif // SIMDUTF_SIMD_HAS_UNSIGNED_CMP
  115|       |
  116|    960|        input += N;
  117|    960|      }
  118|       |
  119|    406|      counter += acc.sum();
  120|    406|    }
  121|    802|  }
  122|       |
  123|    802|  const size_t consumed = input - start;
  124|    802|  if (consumed != 0) {
  ------------------
  |  Branch (124:7): [True: 446, False: 356]
  ------------------
  125|       |    // We don't count 0th bytes in the vectorized loops above, this
  126|       |    // is why we need to count them in the end.
  127|    446|    counter += consumed;
  128|    446|  }
  129|       |
  130|    802|  return counter + scalar::utf32::utf8_length_from_utf32(input, length);
  131|    802|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf323minImEET_S4_S4_:
    8|    581|template <typename T> T min(T a, T b) { return a <= b ? a : b; }
  ------------------
  |  Branch (8:48): [True: 581, False: 0]
  ------------------

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14utf826count_code_points_bytemaskEPKcm:
   22|  5.70k|count_code_points_bytemask(const char *in, size_t size) {
   23|  5.70k|  using vector_i8 = simd8<int8_t>;
   24|  5.70k|  using vector_u8 = simd8<uint8_t>;
   25|  5.70k|  using vector_u64 = simd64<uint64_t>;
   26|       |
   27|  5.70k|  constexpr size_t N = vector_i8::SIZE;
   28|  5.70k|  constexpr size_t max_iterations = 255 / 4;
   29|       |
   30|  5.70k|  size_t pos = 0;
   31|  5.70k|  size_t count = 0;
   32|       |
   33|  5.70k|  auto counters = vector_u64::zero();
   34|  5.70k|  auto local = vector_u8::zero();
   35|  5.70k|  size_t iterations = 0;
   36|  2.03M|  for (; pos + 4 * N <= size; pos += 4 * N) {
  ------------------
  |  Branch (36:10): [True: 2.02M, False: 5.70k]
  ------------------
   37|  2.02M|    const auto input0 =
   38|  2.02M|        simd8<int8_t>::load(reinterpret_cast<const int8_t *>(in + pos + 0 * N));
   39|  2.02M|    const auto input1 =
   40|  2.02M|        simd8<int8_t>::load(reinterpret_cast<const int8_t *>(in + pos + 1 * N));
   41|  2.02M|    const auto input2 =
   42|  2.02M|        simd8<int8_t>::load(reinterpret_cast<const int8_t *>(in + pos + 2 * N));
   43|  2.02M|    const auto input3 =
   44|  2.02M|        simd8<int8_t>::load(reinterpret_cast<const int8_t *>(in + pos + 3 * N));
   45|  2.02M|    const auto mask0 = input0 > int8_t(-65);
   46|  2.02M|    const auto mask1 = input1 > int8_t(-65);
   47|  2.02M|    const auto mask2 = input2 > int8_t(-65);
   48|  2.02M|    const auto mask3 = input3 > int8_t(-65);
   49|       |
   50|  2.02M|    local -= vector_u8(mask0);
   51|  2.02M|    local -= vector_u8(mask1);
   52|  2.02M|    local -= vector_u8(mask2);
   53|  2.02M|    local -= vector_u8(mask3);
   54|       |
   55|  2.02M|    iterations += 1;
   56|  2.02M|    if (iterations == max_iterations) {
  ------------------
  |  Branch (56:9): [True: 31.8k, False: 1.99M]
  ------------------
   57|  31.8k|      counters += sum_8bytes(local);
   58|  31.8k|      local = vector_u8::zero();
   59|  31.8k|      iterations = 0;
   60|  31.8k|    }
   61|  2.02M|  }
   62|       |
   63|  5.70k|  if (iterations > 0) {
  ------------------
  |  Branch (63:7): [True: 1.98k, False: 3.72k]
  ------------------
   64|  1.98k|    count += local.sum_bytes();
   65|  1.98k|  }
   66|       |
   67|  5.70k|  count += counters.sum();
   68|       |
   69|  5.70k|  return count + scalar::utf8::count_code_points(in + pos, size - pos);
   70|  5.70k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14utf817count_code_pointsEPKcm:
    9|  1.38k|                                                              size_t size) {
   10|  1.38k|  size_t pos = 0;
   11|  1.38k|  size_t count = 0;
   12|   918k|  for (; pos + 64 <= size; pos += 64) {
  ------------------
  |  Branch (12:10): [True: 917k, False: 1.38k]
  ------------------
   13|   917k|    simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
   14|   917k|    uint64_t utf8_continuation_mask = input.gt(-65);
   15|   917k|    count += count_ones(utf8_continuation_mask);
   16|   917k|  }
   17|  1.38k|  return count + scalar::utf8::count_code_points(in + pos, size - pos);
   18|  1.38k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14utf826count_code_points_bytemaskEPKcm:
   22|  5.70k|count_code_points_bytemask(const char *in, size_t size) {
   23|  5.70k|  using vector_i8 = simd8<int8_t>;
   24|  5.70k|  using vector_u8 = simd8<uint8_t>;
   25|  5.70k|  using vector_u64 = simd64<uint64_t>;
   26|       |
   27|  5.70k|  constexpr size_t N = vector_i8::SIZE;
   28|  5.70k|  constexpr size_t max_iterations = 255 / 4;
   29|       |
   30|  5.70k|  size_t pos = 0;
   31|  5.70k|  size_t count = 0;
   32|       |
   33|  5.70k|  auto counters = vector_u64::zero();
   34|  5.70k|  auto local = vector_u8::zero();
   35|  5.70k|  size_t iterations = 0;
   36|  4.06M|  for (; pos + 4 * N <= size; pos += 4 * N) {
  ------------------
  |  Branch (36:10): [True: 4.05M, False: 5.70k]
  ------------------
   37|  4.05M|    const auto input0 =
   38|  4.05M|        simd8<int8_t>::load(reinterpret_cast<const int8_t *>(in + pos + 0 * N));
   39|  4.05M|    const auto input1 =
   40|  4.05M|        simd8<int8_t>::load(reinterpret_cast<const int8_t *>(in + pos + 1 * N));
   41|  4.05M|    const auto input2 =
   42|  4.05M|        simd8<int8_t>::load(reinterpret_cast<const int8_t *>(in + pos + 2 * N));
   43|  4.05M|    const auto input3 =
   44|  4.05M|        simd8<int8_t>::load(reinterpret_cast<const int8_t *>(in + pos + 3 * N));
   45|  4.05M|    const auto mask0 = input0 > int8_t(-65);
   46|  4.05M|    const auto mask1 = input1 > int8_t(-65);
   47|  4.05M|    const auto mask2 = input2 > int8_t(-65);
   48|  4.05M|    const auto mask3 = input3 > int8_t(-65);
   49|       |
   50|  4.05M|    local -= vector_u8(mask0);
   51|  4.05M|    local -= vector_u8(mask1);
   52|  4.05M|    local -= vector_u8(mask2);
   53|  4.05M|    local -= vector_u8(mask3);
   54|       |
   55|  4.05M|    iterations += 1;
   56|  4.05M|    if (iterations == max_iterations) {
  ------------------
  |  Branch (56:9): [True: 64.0k, False: 3.99M]
  ------------------
   57|  64.0k|      counters += sum_8bytes(local);
   58|  64.0k|      local = vector_u8::zero();
   59|  64.0k|      iterations = 0;
   60|  64.0k|    }
   61|  4.05M|  }
   62|       |
   63|  5.70k|  if (iterations > 0) {
  ------------------
  |  Branch (63:7): [True: 3.63k, False: 2.06k]
  ------------------
   64|  3.63k|    count += local.sum_bytes();
   65|  3.63k|  }
   66|       |
   67|  5.70k|  count += counters.sum();
   68|       |
   69|  5.70k|  return count + scalar::utf8::count_code_points(in + pos, size - pos);
   70|  5.70k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14utf817count_code_pointsEPKcm:
    9|  1.38k|                                                              size_t size) {
   10|  1.38k|  size_t pos = 0;
   11|  1.38k|  size_t count = 0;
   12|   918k|  for (; pos + 64 <= size; pos += 64) {
  ------------------
  |  Branch (12:10): [True: 917k, False: 1.38k]
  ------------------
   13|   917k|    simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
   14|   917k|    uint64_t utf8_continuation_mask = input.gt(-65);
   15|   917k|    count += count_ones(utf8_continuation_mask);
   16|   917k|  }
   17|  1.38k|  return count + scalar::utf8::count_code_points(in + pos, size - pos);
   18|  1.38k|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14utf831utf16_length_from_utf8_bytemaskEPKcm:
    9|  2.48k|                                                             size_t size) {
   10|  2.48k|  using vector_i8 = simd8<int8_t>;
   11|  2.48k|  using vector_u8 = simd8<uint8_t>;
   12|  2.48k|  using vector_u64 = simd64<uint64_t>;
   13|       |
   14|  2.48k|  constexpr size_t N = vector_i8::SIZE;
   15|  2.48k|  constexpr size_t max_iterations = 255 / 2;
   16|       |
   17|  2.48k|  auto counters = vector_u64::zero();
   18|  2.48k|  auto local = vector_u8::zero();
   19|       |
   20|  2.48k|  size_t iterations = 0;
   21|  2.48k|  size_t pos = 0;
   22|  2.48k|  size_t count = 0;
   23|  7.99M|  for (; pos + N <= size; pos += N) {
  ------------------
  |  Branch (23:10): [True: 7.99M, False: 2.48k]
  ------------------
   24|  7.99M|    const auto input =
   25|  7.99M|        vector_i8::load(reinterpret_cast<const int8_t *>(in + pos));
   26|       |
   27|  7.99M|    const auto continuation = input > int8_t(-65);
   28|  7.99M|    const auto utf_4bytes = vector_u8(input.value) >= uint8_t(240);
   29|       |
   30|  7.99M|    local -= vector_u8(continuation);
   31|  7.99M|    local -= vector_u8(utf_4bytes);
   32|       |
   33|  7.99M|    iterations += 1;
   34|  7.99M|    if (iterations == max_iterations) {
  ------------------
  |  Branch (34:9): [True: 62.6k, False: 7.93M]
  ------------------
   35|  62.6k|      counters += sum_8bytes(local);
   36|  62.6k|      local = vector_u8::zero();
   37|  62.6k|      iterations = 0;
   38|  62.6k|    }
   39|  7.99M|  }
   40|       |
   41|  2.48k|  if (iterations > 0) {
  ------------------
  |  Branch (41:7): [True: 1.95k, False: 525]
  ------------------
   42|  1.95k|    count += local.sum_bytes();
   43|  1.95k|  }
   44|       |
   45|  2.48k|  count += counters.sum();
   46|       |
   47|  2.48k|  return count + scalar::utf8::utf16_length_from_utf8(in + pos, size - pos);
   48|  2.48k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14utf831utf16_length_from_utf8_bytemaskEPKcm:
    9|  2.75k|                                                             size_t size) {
   10|  2.75k|  using vector_i8 = simd8<int8_t>;
   11|  2.75k|  using vector_u8 = simd8<uint8_t>;
   12|  2.75k|  using vector_u64 = simd64<uint64_t>;
   13|       |
   14|  2.75k|  constexpr size_t N = vector_i8::SIZE;
   15|  2.75k|  constexpr size_t max_iterations = 255 / 2;
   16|       |
   17|  2.75k|  auto counters = vector_u64::zero();
   18|  2.75k|  auto local = vector_u8::zero();
   19|       |
   20|  2.75k|  size_t iterations = 0;
   21|  2.75k|  size_t pos = 0;
   22|  2.75k|  size_t count = 0;
   23|  3.99M|  for (; pos + N <= size; pos += N) {
  ------------------
  |  Branch (23:10): [True: 3.99M, False: 2.75k]
  ------------------
   24|  3.99M|    const auto input =
   25|  3.99M|        vector_i8::load(reinterpret_cast<const int8_t *>(in + pos));
   26|       |
   27|  3.99M|    const auto continuation = input > int8_t(-65);
   28|  3.99M|    const auto utf_4bytes = vector_u8(input.value) >= uint8_t(240);
   29|       |
   30|  3.99M|    local -= vector_u8(continuation);
   31|  3.99M|    local -= vector_u8(utf_4bytes);
   32|       |
   33|  3.99M|    iterations += 1;
   34|  3.99M|    if (iterations == max_iterations) {
  ------------------
  |  Branch (34:9): [True: 31.2k, False: 3.96M]
  ------------------
   35|  31.2k|      counters += sum_8bytes(local);
   36|  31.2k|      local = vector_u8::zero();
   37|  31.2k|      iterations = 0;
   38|  31.2k|    }
   39|  3.99M|  }
   40|       |
   41|  2.75k|  if (iterations > 0) {
  ------------------
  |  Branch (41:7): [True: 1.98k, False: 772]
  ------------------
   42|  1.98k|    count += local.sum_bytes();
   43|  1.98k|  }
   44|       |
   45|  2.75k|  count += counters.sum();
   46|       |
   47|  2.75k|  return count + scalar::utf8::utf16_length_from_utf8(in + pos, size - pos);
   48|  2.75k|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_114utf8_to_latin121validating_transcoderC2Ev:
  119|  1.41k|  validating_transcoder() : error(uint8_t(0)) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_114utf8_to_latin121validating_transcoder7convertEPKcmPc:
  167|    662|                                       char *latin1_output) {
  168|    662|    if (size < 64) { // too short for the main loop
  ------------------
  |  Branch (168:9): [True: 158, False: 504]
  ------------------
  169|    158|      return scalar::utf8_to_latin1::convert(in, size, latin1_output);
  170|    158|    }
  171|    504|    size_t pos = 0;
  172|    504|    char *start{latin1_output};
  173|       |    // The kernel can write up to 8 bytes past its output
  174|       |    // when calling convert_1_2_byte_utf8_to_latin1_16. If you skip the
  175|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  176|       |    // 16 UTF-8 bytes generate at least 4 bytes. However, you cannot
  177|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  178|       |    // back from the end counting 16 leading bytes, to give us a good margin.
  179|    504|    size_t leading_byte = 0;
  180|    504|    size_t margin = size;
  181|  41.8k|    for (; margin > 0 && leading_byte < 16; margin--) {
  ------------------
  |  Branch (181:12): [True: 41.8k, False: 12]
  |  Branch (181:26): [True: 41.3k, False: 492]
  ------------------
  182|  41.3k|      leading_byte += (int8_t(in[margin - 1]) >
  183|  41.3k|                       -65); // twos complement of -65 is 1011 1111 ...
  184|  41.3k|    }
  185|       |    // If the input is long enough, then we have that margin is the sixteenth
  186|       |    // last leading byte.
  187|    504|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  188|   358k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (188:12): [True: 358k, False: 426]
  ------------------
  189|   358k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  190|   358k|      if (input.is_ascii()) {
  ------------------
  |  Branch (190:11): [True: 346k, False: 12.1k]
  ------------------
  191|   346k|        input.store((int8_t *)latin1_output);
  192|   346k|        latin1_output += 64;
  193|   346k|        pos += 64;
  194|   346k|        if ((pos & 1023) < 64 && errors()) {
  ------------------
  |  Branch (194:13): [True: 21.5k, False: 324k]
  |  Branch (194:34): [True: 20, False: 21.5k]
  ------------------
  195|     20|          return 0;
  196|     20|        }
  197|   346k|      } else {
  198|       |        // you might think that a for-loop would work, but under Visual Studio,
  199|       |        // it is not good enough.
  200|  12.1k|        static_assert(
  201|  12.1k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  202|  12.1k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  203|  12.1k|            "We support either two or four chunks per 64-byte block.");
  204|  12.1k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  205|  12.1k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  206|  12.1k|          this->check_utf8_bytes(input.chunks[0], zero);
  207|  12.1k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  208|       |        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  209|       |          this->check_utf8_bytes(input.chunks[0], zero);
  210|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  211|       |          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  212|       |          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  213|       |        }
  214|  12.1k|        uint64_t utf8_continuation_mask =
  215|  12.1k|            input.lt(-65 + 1); // -64 is 1100 0000 in twos complement. Note: in
  216|       |                               // this case, we also have ASCII to account for.
  217|  12.1k|        if ((utf8_continuation_mask & 1) || ((pos & 1023) < 64 && errors())) {
  ------------------
  |  Branch (217:13): [True: 20, False: 12.1k]
  |  Branch (217:46): [True: 870, False: 11.2k]
  |  Branch (217:67): [True: 38, False: 832]
  ------------------
  218|     58|          return 0; // error
  219|     58|        }
  220|  12.0k|        pos += convert_1_2_byte_utf8_block_to_latin1(
  221|  12.0k|            in + pos, ~utf8_continuation_mask, latin1_output);
  222|  12.0k|      }
  223|   358k|    }
  224|    426|    if (errors()) {
  ------------------
  |  Branch (224:9): [True: 50, False: 376]
  ------------------
  225|     50|      return 0;
  226|     50|    }
  227|    376|    const size_t ascii = convert_ascii_tail(in, pos, size, latin1_output);
  228|    376|    pos += ascii;
  229|    376|    latin1_output += ascii;
  230|    376|    if (pos == size) {
  ------------------
  |  Branch (230:9): [True: 88, False: 288]
  ------------------
  231|     88|      return latin1_output - start;
  232|     88|    }
  233|    288|    SIMDUTF_VZEROUPPER();
  ------------------
  |  |   22|    288|#define SIMDUTF_VZEROUPPER() _mm256_zeroupper()
  ------------------
  234|    288|    size_t howmany =
  235|    288|        scalar::utf8_to_latin1::convert(in + pos, size - pos, latin1_output);
  236|    288|    if (howmany == 0) {
  ------------------
  |  Branch (236:9): [True: 238, False: 50]
  ------------------
  237|    238|      return 0;
  238|    238|    }
  239|     50|    return latin1_output + howmany - start;
  240|    288|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_114utf8_to_latin121validating_transcoder6errorsEv:
  323|  40.5k|  simdutf_really_inline bool errors() const {
  324|  40.5k|    return this->error.any_bits_set_anywhere();
  325|  40.5k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_114utf8_to_latin121validating_transcoder16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  124|  59.6k|                                              const simd8<uint8_t> prev_input) {
  125|       |    // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+
  126|       |    // lead bytes (2, 3, 4-byte leads become large positive numbers instead of
  127|       |    // small negative numbers)
  128|  59.6k|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  129|  59.6k|    this->error |= check_special_cases(input, prev1);
  130|  59.6k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_114utf8_to_latin119check_special_casesENS1_4simd5simd8IhEES5_:
   26|  59.6k|check_special_cases(const simd8<uint8_t> input, const simd8<uint8_t> prev1) {
   27|       |  // For UTF-8 to Latin 1, we can allow any ASCII character, and any
   28|       |  // continuation byte, but the non-ASCII leading bytes must be 0b11000011 or
   29|       |  // 0b11000010 and nothing else.
   30|       |  //
   31|       |  // Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII)
   32|       |  // Bit 1 = Too Long (ASCII followed by continuation)
   33|       |  // Bit 2 = Overlong 3-byte
   34|       |  // Bit 4 = Surrogate
   35|       |  // Bit 5 = Overlong 2-byte
   36|       |  // Bit 7 = Two Continuations
   37|  59.6k|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   38|       |                                               // 11______ 11______
   39|  59.6k|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   40|  59.6k|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   41|  59.6k|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   42|  59.6k|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   43|  59.6k|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   44|  59.6k|  constexpr const uint8_t TOO_LARGE = 1 << 3;  // 11110100 1001____
   45|       |                                               // 11110100 101_____
   46|       |                                               // 11110101 1001____
   47|       |                                               // 11110101 101_____
   48|       |                                               // 1111011_ 1001____
   49|       |                                               // 1111011_ 101_____
   50|       |                                               // 11111___ 1001____
   51|       |                                               // 11111___ 101_____
   52|  59.6k|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   53|       |  // 11110101 1000____
   54|       |  // 1111011_ 1000____
   55|       |  // 11111___ 1000____
   56|  59.6k|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   57|  59.6k|  constexpr const uint8_t FORBIDDEN = 0xff;
   58|       |
   59|  59.6k|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   60|       |      // 0_______ ________ <ASCII in byte 1>
   61|  59.6k|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   62|  59.6k|      TOO_LONG,
   63|       |      // 10______ ________ <continuation in byte 1>
   64|  59.6k|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   65|       |      // 1100____ ________ <two byte lead in byte 1>
   66|  59.6k|      TOO_SHORT | OVERLONG_2,
   67|       |      // 1101____ ________ <two byte lead in byte 1>
   68|  59.6k|      FORBIDDEN,
   69|       |      // 1110____ ________ <three byte lead in byte 1>
   70|  59.6k|      FORBIDDEN,
   71|       |      // 1111____ ________ <four+ byte lead in byte 1>
   72|  59.6k|      FORBIDDEN);
   73|  59.6k|  constexpr const uint8_t CARRY =
   74|  59.6k|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   75|  59.6k|  const simd8<uint8_t> byte_1_low =
   76|  59.6k|      (prev1 & 0x0F)
   77|  59.6k|          .lookup_16<uint8_t>(
   78|       |              // ____0000 ________
   79|  59.6k|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   80|       |              // ____0001 ________
   81|  59.6k|              CARRY | OVERLONG_2,
   82|       |              // ____001_ ________
   83|  59.6k|              CARRY, CARRY,
   84|       |
   85|       |              // ____0100 ________
   86|  59.6k|              FORBIDDEN,
   87|       |              // ____0101 ________
   88|  59.6k|              FORBIDDEN,
   89|       |              // ____011_ ________
   90|  59.6k|              FORBIDDEN, FORBIDDEN,
   91|       |
   92|       |              // ____1___ ________
   93|  59.6k|              FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
   94|       |              // ____1101 ________
   95|  59.6k|              FORBIDDEN, FORBIDDEN, FORBIDDEN);
   96|  59.6k|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   97|       |      // ________ 0_______ <ASCII in byte 2>
   98|  59.6k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   99|  59.6k|      TOO_SHORT, TOO_SHORT,
  100|       |
  101|       |      // ________ 1000____
  102|  59.6k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
  103|  59.6k|          OVERLONG_4,
  104|       |      // ________ 1001____
  105|  59.6k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
  106|       |      // ________ 101_____
  107|  59.6k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
  108|  59.6k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
  109|       |
  110|       |      // ________ 11______
  111|  59.6k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
  112|  59.6k|  return (byte_1_high & byte_1_low & byte_2_high);
  113|  59.6k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_114utf8_to_latin137convert_1_2_byte_utf8_block_to_latin1EPKcmRPc:
    8|  29.6k|    const char *in, uint64_t utf8_leading_mask, char *&latin1_output) {
    9|  29.6k|  size_t consumed = 64;
   10|  29.6k|  if (uint8_t(in[63]) >= 0xc0) {
  ------------------
  |  Branch (10:7): [True: 1.65k, False: 28.0k]
  ------------------
   11|  1.65k|    utf8_leading_mask &= ~(uint64_t(1) << 63);
   12|  1.65k|    consumed = 63;
   13|  1.65k|  }
   14|  29.6k|  latin1_output += convert_1_2_byte_utf8_to_latin1_16(
   15|  29.6k|      in, uint16_t(utf8_leading_mask), latin1_output);
   16|  29.6k|  latin1_output += convert_1_2_byte_utf8_to_latin1_16(
   17|  29.6k|      in + 16, uint16_t(utf8_leading_mask >> 16), latin1_output);
   18|  29.6k|  latin1_output += convert_1_2_byte_utf8_to_latin1_16(
   19|  29.6k|      in + 32, uint16_t(utf8_leading_mask >> 32), latin1_output);
   20|  29.6k|  latin1_output += convert_1_2_byte_utf8_to_latin1_16(
   21|  29.6k|      in + 48, uint16_t(utf8_leading_mask >> 48), latin1_output);
   22|  29.6k|  return consumed;
   23|  29.6k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_114utf8_to_latin121validating_transcoder18convert_ascii_tailEPKcmmPc:
  135|    870|                                                         char *output) {
  136|       |    // A cheap test on the first bytes avoids any SIMD work for most non-ASCII
  137|       |    // tails.
  138|    870|    if (size - pos >= 8) {
  ------------------
  |  Branch (138:9): [True: 870, False: 0]
  ------------------
  139|    870|      uint64_t first_bytes;
  140|    870|      std::memcpy(&first_bytes, in + pos, 8);
  141|    870|      if (first_bytes & 0x8080808080808080) {
  ------------------
  |  Branch (141:11): [True: 178, False: 692]
  ------------------
  142|    178|        return 0;
  143|    178|      }
  144|    870|    }
  145|    692|    const size_t start = pos;
  146|    864|    while (pos + 64 <= size) {
  ------------------
  |  Branch (146:12): [True: 426, False: 438]
  ------------------
  147|    426|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  148|    426|      if (!input.is_ascii()) {
  ------------------
  |  Branch (148:11): [True: 254, False: 172]
  ------------------
  149|    254|        return pos - start;
  150|    254|      }
  151|    172|      input.store(reinterpret_cast<int8_t *>(output + (pos - start)));
  152|    172|      pos += 64;
  153|    172|    }
  154|    438|    if (pos == size || size < 64) {
  ------------------
  |  Branch (154:9): [True: 32, False: 406]
  |  Branch (154:24): [True: 0, False: 406]
  ------------------
  155|     32|      return pos - start;
  156|     32|    }
  157|    406|    simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + size - 64));
  158|    406|    if (!input.is_ascii()) {
  ------------------
  |  Branch (158:9): [True: 264, False: 142]
  ------------------
  159|    264|      return pos - start;
  160|    264|    }
  161|    142|    input.store(reinterpret_cast<int8_t *>(output + (pos - start) -
  162|    142|                                           (pos - (size - 64))));
  163|    142|    return size - start;
  164|    406|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_114utf8_to_latin121validating_transcoder19convert_with_errorsEPKcmPc:
  243|    750|                                                   char *latin1_output) {
  244|    750|    if (size < 64) { // too short for the main loop
  ------------------
  |  Branch (244:9): [True: 150, False: 600]
  ------------------
  245|    150|      return scalar::utf8_to_latin1::convert_with_errors(in, size,
  246|    150|                                                         latin1_output);
  247|    150|    }
  248|    600|    size_t pos = 0;
  249|    600|    char *start{latin1_output};
  250|       |    // The kernel can write up to 8 bytes past its output
  251|       |    // when calling convert_1_2_byte_utf8_to_latin1_16. If you skip the
  252|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  253|       |    // 16 UTF-8 bytes generate at least 4 bytes. However, you cannot
  254|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  255|       |    // back from the end counting 8 leading bytes, to give us a good margin.
  256|    600|    size_t leading_byte = 0;
  257|    600|    size_t margin = size;
  258|  17.0k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (258:12): [True: 17.0k, False: 16]
  |  Branch (258:26): [True: 16.4k, False: 584]
  ------------------
  259|  16.4k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  260|  16.4k|    }
  261|       |    // If the input is long enough, then we have that margin is the eighth last
  262|       |    // leading byte.
  263|    600|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  264|   443k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (264:12): [True: 442k, False: 494]
  ------------------
  265|   442k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  266|   442k|      if (input.is_ascii()) {
  ------------------
  |  Branch (266:11): [True: 425k, False: 17.6k]
  ------------------
  267|   425k|        input.store((int8_t *)latin1_output);
  268|   425k|        latin1_output += 64;
  269|   425k|        pos += 64;
  270|   425k|      } else {
  271|       |        // you might think that a for-loop would work, but under Visual Studio,
  272|       |        // it is not good enough.
  273|  17.6k|        static_assert(
  274|  17.6k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  275|  17.6k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  276|  17.6k|            "We support either two or four chunks per 64-byte block.");
  277|  17.6k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  278|  17.6k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  279|  17.6k|          this->check_utf8_bytes(input.chunks[0], zero);
  280|  17.6k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  281|       |        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  282|       |          this->check_utf8_bytes(input.chunks[0], zero);
  283|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  284|       |          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  285|       |          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  286|       |        }
  287|  17.6k|        if (errors()) {
  ------------------
  |  Branch (287:13): [True: 106, False: 17.5k]
  ------------------
  288|       |          // rewind_and_convert_with_errors will seek a potential error from
  289|       |          // in+pos onward, with the ability to go back up to pos bytes, and
  290|       |          // read size-pos bytes forward.
  291|    106|          SIMDUTF_VZEROUPPER();
  ------------------
  |  |   22|    106|#define SIMDUTF_VZEROUPPER() _mm256_zeroupper()
  ------------------
  292|    106|          result res = scalar::utf8_to_latin1::rewind_and_convert_with_errors(
  293|    106|              pos, in + pos, size - pos, latin1_output);
  294|    106|          res.count += pos;
  295|    106|          return res;
  296|    106|        }
  297|  17.5k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  298|  17.5k|        pos += convert_1_2_byte_utf8_block_to_latin1(
  299|  17.5k|            in + pos, ~utf8_continuation_mask, latin1_output);
  300|  17.5k|      }
  301|   442k|    }
  302|    494|    const size_t ascii = convert_ascii_tail(in, pos, size, latin1_output);
  303|    494|    pos += ascii;
  304|    494|    latin1_output += ascii;
  305|    494|    if (pos == size) {
  ------------------
  |  Branch (305:9): [True: 86, False: 408]
  ------------------
  306|     86|      return result(error_code::SUCCESS, latin1_output - start);
  307|     86|    }
  308|       |    // rewind_and_convert_with_errors will seek a potential error from in+pos
  309|       |    // onward, with the ability to go back up to pos bytes, and read size-pos
  310|       |    // bytes forward.
  311|    408|    SIMDUTF_VZEROUPPER();
  ------------------
  |  |   22|    408|#define SIMDUTF_VZEROUPPER() _mm256_zeroupper()
  ------------------
  312|    408|    result res = scalar::utf8_to_latin1::rewind_and_convert_with_errors(
  313|    408|        pos, in + pos, size - pos, latin1_output);
  314|    408|    if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (314:9): [True: 328, False: 80]
  ------------------
  315|    328|      res.count += pos;
  316|    328|      return res;
  317|    328|    }
  318|       |    // In case of success, we want the number of words written
  319|     80|    latin1_output += res.count;
  320|     80|    return result(error_code::SUCCESS, latin1_output - start);
  321|    408|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_114utf8_to_latin121validating_transcoderC2Ev:
  119|  1.41k|  validating_transcoder() : error(uint8_t(0)) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_114utf8_to_latin121validating_transcoder7convertEPKcmPc:
  167|    662|                                       char *latin1_output) {
  168|    662|    if (size < 64) { // too short for the main loop
  ------------------
  |  Branch (168:9): [True: 158, False: 504]
  ------------------
  169|    158|      return scalar::utf8_to_latin1::convert(in, size, latin1_output);
  170|    158|    }
  171|    504|    size_t pos = 0;
  172|    504|    char *start{latin1_output};
  173|       |    // The kernel can write up to 8 bytes past its output
  174|       |    // when calling convert_1_2_byte_utf8_to_latin1_16. If you skip the
  175|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  176|       |    // 16 UTF-8 bytes generate at least 4 bytes. However, you cannot
  177|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  178|       |    // back from the end counting 16 leading bytes, to give us a good margin.
  179|    504|    size_t leading_byte = 0;
  180|    504|    size_t margin = size;
  181|  41.8k|    for (; margin > 0 && leading_byte < 16; margin--) {
  ------------------
  |  Branch (181:12): [True: 41.8k, False: 12]
  |  Branch (181:26): [True: 41.3k, False: 492]
  ------------------
  182|  41.3k|      leading_byte += (int8_t(in[margin - 1]) >
  183|  41.3k|                       -65); // twos complement of -65 is 1011 1111 ...
  184|  41.3k|    }
  185|       |    // If the input is long enough, then we have that margin is the sixteenth
  186|       |    // last leading byte.
  187|    504|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  188|   358k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (188:12): [True: 358k, False: 426]
  ------------------
  189|   358k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  190|   358k|      if (input.is_ascii()) {
  ------------------
  |  Branch (190:11): [True: 346k, False: 12.1k]
  ------------------
  191|   346k|        input.store((int8_t *)latin1_output);
  192|   346k|        latin1_output += 64;
  193|   346k|        pos += 64;
  194|   346k|        if ((pos & 1023) < 64 && errors()) {
  ------------------
  |  Branch (194:13): [True: 21.5k, False: 324k]
  |  Branch (194:34): [True: 20, False: 21.5k]
  ------------------
  195|     20|          return 0;
  196|     20|        }
  197|   346k|      } else {
  198|       |        // you might think that a for-loop would work, but under Visual Studio,
  199|       |        // it is not good enough.
  200|  12.1k|        static_assert(
  201|  12.1k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  202|  12.1k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  203|  12.1k|            "We support either two or four chunks per 64-byte block.");
  204|  12.1k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  205|       |        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  206|       |          this->check_utf8_bytes(input.chunks[0], zero);
  207|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  208|  12.1k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  209|  12.1k|          this->check_utf8_bytes(input.chunks[0], zero);
  210|  12.1k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  211|  12.1k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  212|  12.1k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  213|  12.1k|        }
  214|  12.1k|        uint64_t utf8_continuation_mask =
  215|  12.1k|            input.lt(-65 + 1); // -64 is 1100 0000 in twos complement. Note: in
  216|       |                               // this case, we also have ASCII to account for.
  217|  12.1k|        if ((utf8_continuation_mask & 1) || ((pos & 1023) < 64 && errors())) {
  ------------------
  |  Branch (217:13): [True: 20, False: 12.1k]
  |  Branch (217:46): [True: 870, False: 11.2k]
  |  Branch (217:67): [True: 38, False: 832]
  ------------------
  218|     58|          return 0; // error
  219|     58|        }
  220|  12.0k|        pos += convert_1_2_byte_utf8_block_to_latin1(
  221|  12.0k|            in + pos, ~utf8_continuation_mask, latin1_output);
  222|  12.0k|      }
  223|   358k|    }
  224|    426|    if (errors()) {
  ------------------
  |  Branch (224:9): [True: 50, False: 376]
  ------------------
  225|     50|      return 0;
  226|     50|    }
  227|    376|    const size_t ascii = convert_ascii_tail(in, pos, size, latin1_output);
  228|    376|    pos += ascii;
  229|    376|    latin1_output += ascii;
  230|    376|    if (pos == size) {
  ------------------
  |  Branch (230:9): [True: 88, False: 288]
  ------------------
  231|     88|      return latin1_output - start;
  232|     88|    }
  233|    288|    SIMDUTF_VZEROUPPER();
  ------------------
  |  |   16|    288|#define SIMDUTF_VZEROUPPER() (void)0
  ------------------
  234|    288|    size_t howmany =
  235|    288|        scalar::utf8_to_latin1::convert(in + pos, size - pos, latin1_output);
  236|    288|    if (howmany == 0) {
  ------------------
  |  Branch (236:9): [True: 238, False: 50]
  ------------------
  237|    238|      return 0;
  238|    238|    }
  239|     50|    return latin1_output + howmany - start;
  240|    288|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_114utf8_to_latin121validating_transcoder6errorsEv:
  323|  40.5k|  simdutf_really_inline bool errors() const {
  324|  40.5k|    return this->error.any_bits_set_anywhere();
  325|  40.5k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_114utf8_to_latin121validating_transcoder16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  124|   119k|                                              const simd8<uint8_t> prev_input) {
  125|       |    // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+
  126|       |    // lead bytes (2, 3, 4-byte leads become large positive numbers instead of
  127|       |    // small negative numbers)
  128|   119k|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  129|   119k|    this->error |= check_special_cases(input, prev1);
  130|   119k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_114utf8_to_latin119check_special_casesENS1_4simd5simd8IhEES5_:
   26|   119k|check_special_cases(const simd8<uint8_t> input, const simd8<uint8_t> prev1) {
   27|       |  // For UTF-8 to Latin 1, we can allow any ASCII character, and any
   28|       |  // continuation byte, but the non-ASCII leading bytes must be 0b11000011 or
   29|       |  // 0b11000010 and nothing else.
   30|       |  //
   31|       |  // Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII)
   32|       |  // Bit 1 = Too Long (ASCII followed by continuation)
   33|       |  // Bit 2 = Overlong 3-byte
   34|       |  // Bit 4 = Surrogate
   35|       |  // Bit 5 = Overlong 2-byte
   36|       |  // Bit 7 = Two Continuations
   37|   119k|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   38|       |                                               // 11______ 11______
   39|   119k|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   40|   119k|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   41|   119k|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   42|   119k|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   43|   119k|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   44|   119k|  constexpr const uint8_t TOO_LARGE = 1 << 3;  // 11110100 1001____
   45|       |                                               // 11110100 101_____
   46|       |                                               // 11110101 1001____
   47|       |                                               // 11110101 101_____
   48|       |                                               // 1111011_ 1001____
   49|       |                                               // 1111011_ 101_____
   50|       |                                               // 11111___ 1001____
   51|       |                                               // 11111___ 101_____
   52|   119k|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   53|       |  // 11110101 1000____
   54|       |  // 1111011_ 1000____
   55|       |  // 11111___ 1000____
   56|   119k|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   57|   119k|  constexpr const uint8_t FORBIDDEN = 0xff;
   58|       |
   59|   119k|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   60|       |      // 0_______ ________ <ASCII in byte 1>
   61|   119k|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   62|   119k|      TOO_LONG,
   63|       |      // 10______ ________ <continuation in byte 1>
   64|   119k|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   65|       |      // 1100____ ________ <two byte lead in byte 1>
   66|   119k|      TOO_SHORT | OVERLONG_2,
   67|       |      // 1101____ ________ <two byte lead in byte 1>
   68|   119k|      FORBIDDEN,
   69|       |      // 1110____ ________ <three byte lead in byte 1>
   70|   119k|      FORBIDDEN,
   71|       |      // 1111____ ________ <four+ byte lead in byte 1>
   72|   119k|      FORBIDDEN);
   73|   119k|  constexpr const uint8_t CARRY =
   74|   119k|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   75|   119k|  const simd8<uint8_t> byte_1_low =
   76|   119k|      (prev1 & 0x0F)
   77|   119k|          .lookup_16<uint8_t>(
   78|       |              // ____0000 ________
   79|   119k|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   80|       |              // ____0001 ________
   81|   119k|              CARRY | OVERLONG_2,
   82|       |              // ____001_ ________
   83|   119k|              CARRY, CARRY,
   84|       |
   85|       |              // ____0100 ________
   86|   119k|              FORBIDDEN,
   87|       |              // ____0101 ________
   88|   119k|              FORBIDDEN,
   89|       |              // ____011_ ________
   90|   119k|              FORBIDDEN, FORBIDDEN,
   91|       |
   92|       |              // ____1___ ________
   93|   119k|              FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
   94|       |              // ____1101 ________
   95|   119k|              FORBIDDEN, FORBIDDEN, FORBIDDEN);
   96|   119k|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   97|       |      // ________ 0_______ <ASCII in byte 2>
   98|   119k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   99|   119k|      TOO_SHORT, TOO_SHORT,
  100|       |
  101|       |      // ________ 1000____
  102|   119k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
  103|   119k|          OVERLONG_4,
  104|       |      // ________ 1001____
  105|   119k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
  106|       |      // ________ 101_____
  107|   119k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
  108|   119k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
  109|       |
  110|       |      // ________ 11______
  111|   119k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
  112|   119k|  return (byte_1_high & byte_1_low & byte_2_high);
  113|   119k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_114utf8_to_latin137convert_1_2_byte_utf8_block_to_latin1EPKcmRPc:
    8|  29.6k|    const char *in, uint64_t utf8_leading_mask, char *&latin1_output) {
    9|  29.6k|  size_t consumed = 64;
   10|  29.6k|  if (uint8_t(in[63]) >= 0xc0) {
  ------------------
  |  Branch (10:7): [True: 1.65k, False: 28.0k]
  ------------------
   11|  1.65k|    utf8_leading_mask &= ~(uint64_t(1) << 63);
   12|  1.65k|    consumed = 63;
   13|  1.65k|  }
   14|  29.6k|  latin1_output += convert_1_2_byte_utf8_to_latin1_16(
   15|  29.6k|      in, uint16_t(utf8_leading_mask), latin1_output);
   16|  29.6k|  latin1_output += convert_1_2_byte_utf8_to_latin1_16(
   17|  29.6k|      in + 16, uint16_t(utf8_leading_mask >> 16), latin1_output);
   18|  29.6k|  latin1_output += convert_1_2_byte_utf8_to_latin1_16(
   19|  29.6k|      in + 32, uint16_t(utf8_leading_mask >> 32), latin1_output);
   20|  29.6k|  latin1_output += convert_1_2_byte_utf8_to_latin1_16(
   21|  29.6k|      in + 48, uint16_t(utf8_leading_mask >> 48), latin1_output);
   22|  29.6k|  return consumed;
   23|  29.6k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_114utf8_to_latin121validating_transcoder18convert_ascii_tailEPKcmmPc:
  135|    870|                                                         char *output) {
  136|       |    // A cheap test on the first bytes avoids any SIMD work for most non-ASCII
  137|       |    // tails.
  138|    870|    if (size - pos >= 8) {
  ------------------
  |  Branch (138:9): [True: 870, False: 0]
  ------------------
  139|    870|      uint64_t first_bytes;
  140|    870|      std::memcpy(&first_bytes, in + pos, 8);
  141|    870|      if (first_bytes & 0x8080808080808080) {
  ------------------
  |  Branch (141:11): [True: 178, False: 692]
  ------------------
  142|    178|        return 0;
  143|    178|      }
  144|    870|    }
  145|    692|    const size_t start = pos;
  146|    864|    while (pos + 64 <= size) {
  ------------------
  |  Branch (146:12): [True: 426, False: 438]
  ------------------
  147|    426|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  148|    426|      if (!input.is_ascii()) {
  ------------------
  |  Branch (148:11): [True: 254, False: 172]
  ------------------
  149|    254|        return pos - start;
  150|    254|      }
  151|    172|      input.store(reinterpret_cast<int8_t *>(output + (pos - start)));
  152|    172|      pos += 64;
  153|    172|    }
  154|    438|    if (pos == size || size < 64) {
  ------------------
  |  Branch (154:9): [True: 32, False: 406]
  |  Branch (154:24): [True: 0, False: 406]
  ------------------
  155|     32|      return pos - start;
  156|     32|    }
  157|    406|    simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + size - 64));
  158|    406|    if (!input.is_ascii()) {
  ------------------
  |  Branch (158:9): [True: 264, False: 142]
  ------------------
  159|    264|      return pos - start;
  160|    264|    }
  161|    142|    input.store(reinterpret_cast<int8_t *>(output + (pos - start) -
  162|    142|                                           (pos - (size - 64))));
  163|    142|    return size - start;
  164|    406|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_114utf8_to_latin121validating_transcoder19convert_with_errorsEPKcmPc:
  243|    750|                                                   char *latin1_output) {
  244|    750|    if (size < 64) { // too short for the main loop
  ------------------
  |  Branch (244:9): [True: 150, False: 600]
  ------------------
  245|    150|      return scalar::utf8_to_latin1::convert_with_errors(in, size,
  246|    150|                                                         latin1_output);
  247|    150|    }
  248|    600|    size_t pos = 0;
  249|    600|    char *start{latin1_output};
  250|       |    // The kernel can write up to 8 bytes past its output
  251|       |    // when calling convert_1_2_byte_utf8_to_latin1_16. If you skip the
  252|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  253|       |    // 16 UTF-8 bytes generate at least 4 bytes. However, you cannot
  254|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  255|       |    // back from the end counting 8 leading bytes, to give us a good margin.
  256|    600|    size_t leading_byte = 0;
  257|    600|    size_t margin = size;
  258|  17.0k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (258:12): [True: 17.0k, False: 16]
  |  Branch (258:26): [True: 16.4k, False: 584]
  ------------------
  259|  16.4k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  260|  16.4k|    }
  261|       |    // If the input is long enough, then we have that margin is the eighth last
  262|       |    // leading byte.
  263|    600|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  264|   443k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (264:12): [True: 442k, False: 494]
  ------------------
  265|   442k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  266|   442k|      if (input.is_ascii()) {
  ------------------
  |  Branch (266:11): [True: 425k, False: 17.6k]
  ------------------
  267|   425k|        input.store((int8_t *)latin1_output);
  268|   425k|        latin1_output += 64;
  269|   425k|        pos += 64;
  270|   425k|      } else {
  271|       |        // you might think that a for-loop would work, but under Visual Studio,
  272|       |        // it is not good enough.
  273|  17.6k|        static_assert(
  274|  17.6k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  275|  17.6k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  276|  17.6k|            "We support either two or four chunks per 64-byte block.");
  277|  17.6k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  278|       |        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  279|       |          this->check_utf8_bytes(input.chunks[0], zero);
  280|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  281|  17.6k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  282|  17.6k|          this->check_utf8_bytes(input.chunks[0], zero);
  283|  17.6k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  284|  17.6k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  285|  17.6k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  286|  17.6k|        }
  287|  17.6k|        if (errors()) {
  ------------------
  |  Branch (287:13): [True: 106, False: 17.5k]
  ------------------
  288|       |          // rewind_and_convert_with_errors will seek a potential error from
  289|       |          // in+pos onward, with the ability to go back up to pos bytes, and
  290|       |          // read size-pos bytes forward.
  291|    106|          SIMDUTF_VZEROUPPER();
  ------------------
  |  |   16|    106|#define SIMDUTF_VZEROUPPER() (void)0
  ------------------
  292|    106|          result res = scalar::utf8_to_latin1::rewind_and_convert_with_errors(
  293|    106|              pos, in + pos, size - pos, latin1_output);
  294|    106|          res.count += pos;
  295|    106|          return res;
  296|    106|        }
  297|  17.5k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  298|  17.5k|        pos += convert_1_2_byte_utf8_block_to_latin1(
  299|  17.5k|            in + pos, ~utf8_continuation_mask, latin1_output);
  300|  17.5k|      }
  301|   442k|    }
  302|    494|    const size_t ascii = convert_ascii_tail(in, pos, size, latin1_output);
  303|    494|    pos += ascii;
  304|    494|    latin1_output += ascii;
  305|    494|    if (pos == size) {
  ------------------
  |  Branch (305:9): [True: 86, False: 408]
  ------------------
  306|     86|      return result(error_code::SUCCESS, latin1_output - start);
  307|     86|    }
  308|       |    // rewind_and_convert_with_errors will seek a potential error from in+pos
  309|       |    // onward, with the ability to go back up to pos bytes, and read size-pos
  310|       |    // bytes forward.
  311|    408|    SIMDUTF_VZEROUPPER();
  ------------------
  |  |   16|    408|#define SIMDUTF_VZEROUPPER() (void)0
  ------------------
  312|    408|    result res = scalar::utf8_to_latin1::rewind_and_convert_with_errors(
  313|    408|        pos, in + pos, size - pos, latin1_output);
  314|    408|    if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (314:9): [True: 328, False: 80]
  ------------------
  315|    328|      res.count += pos;
  316|    328|      return res;
  317|    328|    }
  318|       |    // In case of success, we want the number of words written
  319|     80|    latin1_output += res.count;
  320|     80|    return result(error_code::SUCCESS, latin1_output - start);
  321|    408|  }

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoderC2Ev:
  114|  3.61k|  validating_transcoder() : error(uint8_t(0)) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoderC2Ev:
  114|  3.61k|  validating_transcoder() : error(uint8_t(0)) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder7convertILNS_10endiannessE0EEEmPKcmPDs:
  165|    984|                                       char16_t *utf16_output) {
  166|    984|    if (size < 64) { // too short for the main loop
  ------------------
  |  Branch (166:9): [True: 288, False: 696]
  ------------------
  167|    288|      return scalar::utf8_to_utf16::convert<endian>(in, size, utf16_output);
  168|    288|    }
  169|    696|    size_t pos = 0;
  170|    696|    char16_t *start{utf16_output};
  171|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  172|       |    // of 8 bytes when calling convert_masked_utf8_to_utf16. If you skip the
  173|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  174|       |    // 16 UTF-8 bytes generate much more than 8 bytes. However, you cannot
  175|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  176|       |    // back from the end counting 8 leading bytes, to give us a good margin.
  177|    696|    size_t leading_byte = 0;
  178|    696|    size_t margin = size;
  179|  9.29k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (179:12): [True: 9.28k, False: 12]
  |  Branch (179:26): [True: 8.60k, False: 684]
  ------------------
  180|  8.60k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  181|  8.60k|    }
  182|       |    // If the input is long enough, then we have that margin is the eighth last
  183|       |    // leading byte.
  184|    696|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  185|   521k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (185:12): [True: 520k, False: 556]
  ------------------
  186|   520k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  187|   520k|      if (input.is_ascii()) {
  ------------------
  |  Branch (187:11): [True: 394k, False: 126k]
  ------------------
  188|   394k|        input.store_ascii_as_utf16<endian>(utf16_output);
  189|   394k|        utf16_output += 64;
  190|   394k|        pos += 64;
  191|   394k|        if ((pos & 1023) < 64 && errors()) {
  ------------------
  |  Branch (191:13): [True: 24.4k, False: 369k]
  |  Branch (191:34): [True: 18, False: 24.4k]
  ------------------
  192|     18|          return 0;
  193|     18|        }
  194|   394k|      } else {
  195|       |        // you might think that a for-loop would work, but under Visual Studio,
  196|       |        // it is not good enough.
  197|   126k|        static_assert(
  198|   126k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  199|   126k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  200|   126k|            "We support either two or four chunks per 64-byte block.");
  201|   126k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  202|   126k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  203|   126k|          this->check_utf8_bytes(input.chunks[0], zero);
  204|   126k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  205|       |        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  206|       |          this->check_utf8_bytes(input.chunks[0], zero);
  207|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  208|       |          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  209|       |          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  210|       |        }
  211|   126k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  212|   126k|        if ((utf8_continuation_mask & 1) || ((pos & 1023) < 64 && errors())) {
  ------------------
  |  Branch (212:13): [True: 12, False: 126k]
  |  Branch (212:46): [True: 8.26k, False: 118k]
  |  Branch (212:67): [True: 110, False: 8.15k]
  ------------------
  213|    122|          return 0; // error
  214|    122|        }
  215|   126k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  216|   126k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  217|       |        // We process in blocks of up to 12 bytes except possibly
  218|       |        // for fast paths which may process up to 16 bytes. For the
  219|       |        // slow path to work, we should have at least 12 input bytes left.
  220|   126k|        size_t max_starting_point = (pos + 64) - 12;
  221|       |        // Next loop is going to run at least five times.
  222|   918k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (222:16): [True: 791k, False: 126k]
  ------------------
  223|       |          // Performance note: our ability to compute 'consumed' and
  224|       |          // then shift and recompute is critical. If there is a
  225|       |          // latency of, say, 4 cycles on getting 'consumed', then
  226|       |          // the inner loop might have a total latency of about 6 cycles.
  227|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  228|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  229|       |          // for this section of the code. Hence, there is a limit
  230|       |          // to how much we can further increase this latency before
  231|       |          // it seriously harms performance.
  232|   791k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  233|   791k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  234|   791k|          pos += consumed;
  235|   791k|          utf8_end_of_code_point_mask >>= consumed;
  236|   791k|        }
  237|       |        // At this point there may remain between 0 and 12 bytes in the
  238|       |        // 64-byte block. These bytes will be processed again. So we have an
  239|       |        // 80% efficiency (in the worst case). In practice we expect an
  240|       |        // 85% to 90% efficiency.
  241|   126k|      }
  242|   520k|    }
  243|    556|    if (errors()) {
  ------------------
  |  Branch (243:9): [True: 120, False: 436]
  ------------------
  244|    120|      return 0;
  245|    120|    }
  246|    436|    const size_t ascii =
  247|    436|        convert_ascii_tail<endian>(in, pos, size, utf16_output);
  248|    436|    pos += ascii;
  249|    436|    utf16_output += ascii;
  250|    436|    if (pos == size) {
  ------------------
  |  Branch (250:9): [True: 106, False: 330]
  ------------------
  251|    106|      return utf16_output - start;
  252|    106|    }
  253|    330|    SIMDUTF_VZEROUPPER();
  ------------------
  |  |   22|    330|#define SIMDUTF_VZEROUPPER() _mm256_zeroupper()
  ------------------
  254|    330|    size_t howmany = scalar::utf8_to_utf16::convert<endian>(
  255|    330|        in + pos, size - pos, utf16_output);
  256|    330|    if (howmany == 0) {
  ------------------
  |  Branch (256:9): [True: 260, False: 70]
  ------------------
  257|    260|      return 0;
  258|    260|    }
  259|     70|    return utf16_output + howmany - start;
  260|    330|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder6errorsEv:
  370|   338k|  simdutf_really_inline bool errors() const {
  371|   338k|    return this->error.any_bits_set_anywhere();
  372|   338k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  119|   976k|                                              const simd8<uint8_t> prev_input) {
  120|       |    // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+
  121|       |    // lead bytes (2, 3, 4-byte leads become large positive numbers instead of
  122|       |    // small negative numbers)
  123|   976k|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  124|   976k|    simd8<uint8_t> sc = check_special_cases(input, prev1);
  125|   976k|    this->error |= check_multibyte_lengths(input, prev_input, sc);
  126|   976k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1619check_special_casesENS1_4simd5simd8IhEES5_:
    8|   976k|check_special_cases(const simd8<uint8_t> input, const simd8<uint8_t> prev1) {
    9|       |  // Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII)
   10|       |  // Bit 1 = Too Long (ASCII followed by continuation)
   11|       |  // Bit 2 = Overlong 3-byte
   12|       |  // Bit 4 = Surrogate
   13|       |  // Bit 5 = Overlong 2-byte
   14|       |  // Bit 7 = Two Continuations
   15|   976k|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   16|       |                                               // 11______ 11______
   17|   976k|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   18|   976k|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   19|   976k|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   20|   976k|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   21|   976k|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   22|   976k|  constexpr const uint8_t TOO_LARGE = 1 << 3;  // 11110100 1001____
   23|       |                                               // 11110100 101_____
   24|       |                                               // 11110101 1001____
   25|       |                                               // 11110101 101_____
   26|       |                                               // 1111011_ 1001____
   27|       |                                               // 1111011_ 101_____
   28|       |                                               // 11111___ 1001____
   29|       |                                               // 11111___ 101_____
   30|   976k|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   31|       |  // 11110101 1000____
   32|       |  // 1111011_ 1000____
   33|       |  // 11111___ 1000____
   34|   976k|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   35|       |
   36|   976k|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   37|       |      // 0_______ ________ <ASCII in byte 1>
   38|   976k|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   39|   976k|      TOO_LONG,
   40|       |      // 10______ ________ <continuation in byte 1>
   41|   976k|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   42|       |      // 1100____ ________ <two byte lead in byte 1>
   43|   976k|      TOO_SHORT | OVERLONG_2,
   44|       |      // 1101____ ________ <two byte lead in byte 1>
   45|   976k|      TOO_SHORT,
   46|       |      // 1110____ ________ <three byte lead in byte 1>
   47|   976k|      TOO_SHORT | OVERLONG_3 | SURROGATE,
   48|       |      // 1111____ ________ <four+ byte lead in byte 1>
   49|   976k|      TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4);
   50|   976k|  constexpr const uint8_t CARRY =
   51|   976k|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   52|   976k|  const simd8<uint8_t> byte_1_low =
   53|   976k|      (prev1 & 0x0F)
   54|   976k|          .lookup_16<uint8_t>(
   55|       |              // ____0000 ________
   56|   976k|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   57|       |              // ____0001 ________
   58|   976k|              CARRY | OVERLONG_2,
   59|       |              // ____001_ ________
   60|   976k|              CARRY, CARRY,
   61|       |
   62|       |              // ____0100 ________
   63|   976k|              CARRY | TOO_LARGE,
   64|       |              // ____0101 ________
   65|   976k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   66|       |              // ____011_ ________
   67|   976k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   68|   976k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   69|       |
   70|       |              // ____1___ ________
   71|   976k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   72|   976k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   73|   976k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   74|   976k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   75|   976k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   76|       |              // ____1101 ________
   77|   976k|              CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE,
   78|   976k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   79|   976k|              CARRY | TOO_LARGE | TOO_LARGE_1000);
   80|   976k|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   81|       |      // ________ 0_______ <ASCII in byte 2>
   82|   976k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   83|   976k|      TOO_SHORT, TOO_SHORT,
   84|       |
   85|       |      // ________ 1000____
   86|   976k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
   87|   976k|          OVERLONG_4,
   88|       |      // ________ 1001____
   89|   976k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
   90|       |      // ________ 101_____
   91|   976k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   92|   976k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   93|       |
   94|       |      // ________ 11______
   95|   976k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
   96|   976k|  return (byte_1_high & byte_1_low & byte_2_high);
   97|   976k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1623check_multibyte_lengthsENS1_4simd5simd8IhEES5_S5_:
  101|   976k|                        const simd8<uint8_t> sc) {
  102|   976k|  simd8<uint8_t> prev2 = input.prev<2>(prev_input);
  103|   976k|  simd8<uint8_t> prev3 = input.prev<3>(prev_input);
  104|   976k|  simd8<uint8_t> must23 =
  105|   976k|      simd8<uint8_t>(must_be_2_3_continuation(prev2, prev3));
  106|   976k|  simd8<uint8_t> must23_80 = must23 & uint8_t(0x80);
  107|   976k|  return must23_80 ^ sc;
  108|   976k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder18convert_ascii_tailILNS_10endiannessE0EEEmPKcmmPDs:
  132|  1.38k|                                                         char16_t *output) {
  133|       |    // A cheap test on the first bytes avoids any SIMD work for most non-ASCII
  134|       |    // tails.
  135|  1.38k|    if (size - pos >= 8) {
  ------------------
  |  Branch (135:9): [True: 1.34k, False: 42]
  ------------------
  136|  1.34k|      uint64_t first_bytes;
  137|  1.34k|      std::memcpy(&first_bytes, in + pos, 8);
  138|  1.34k|      if (first_bytes & 0x8080808080808080) {
  ------------------
  |  Branch (138:11): [True: 372, False: 972]
  ------------------
  139|    372|        return 0;
  140|    372|      }
  141|  1.34k|    }
  142|  1.01k|    const size_t start = pos;
  143|  1.16k|    while (pos + 64 <= size) {
  ------------------
  |  Branch (143:12): [True: 416, False: 744]
  ------------------
  144|    416|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  145|    416|      if (!input.is_ascii()) {
  ------------------
  |  Branch (145:11): [True: 270, False: 146]
  ------------------
  146|    270|        return pos - start;
  147|    270|      }
  148|    146|      input.store_ascii_as_utf16<endian>(output + (pos - start));
  149|    146|      pos += 64;
  150|    146|    }
  151|    744|    if (pos == size || size < 64) {
  ------------------
  |  Branch (151:9): [True: 38, False: 706]
  |  Branch (151:24): [True: 70, False: 636]
  ------------------
  152|    108|      return pos - start;
  153|    108|    }
  154|    636|    simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + size - 64));
  155|    636|    if (!input.is_ascii()) {
  ------------------
  |  Branch (155:9): [True: 380, False: 256]
  ------------------
  156|    380|      return pos - start;
  157|    380|    }
  158|    256|    input.store_ascii_as_utf16<endian>(output + (pos - start) -
  159|    256|                                       (pos - (size - 64)));
  160|    256|    return size - start;
  161|    636|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder7convertILNS_10endiannessE1EEEmPKcmPDs:
  165|    960|                                       char16_t *utf16_output) {
  166|    960|    if (size < 64) { // too short for the main loop
  ------------------
  |  Branch (166:9): [True: 308, False: 652]
  ------------------
  167|    308|      return scalar::utf8_to_utf16::convert<endian>(in, size, utf16_output);
  168|    308|    }
  169|    652|    size_t pos = 0;
  170|    652|    char16_t *start{utf16_output};
  171|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  172|       |    // of 8 bytes when calling convert_masked_utf8_to_utf16. If you skip the
  173|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  174|       |    // 16 UTF-8 bytes generate much more than 8 bytes. However, you cannot
  175|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  176|       |    // back from the end counting 8 leading bytes, to give us a good margin.
  177|    652|    size_t leading_byte = 0;
  178|    652|    size_t margin = size;
  179|  8.27k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (179:12): [True: 8.26k, False: 10]
  |  Branch (179:26): [True: 7.62k, False: 642]
  ------------------
  180|  7.62k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  181|  7.62k|    }
  182|       |    // If the input is long enough, then we have that margin is the eighth last
  183|       |    // leading byte.
  184|    652|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  185|   494k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (185:12): [True: 493k, False: 530]
  ------------------
  186|   493k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  187|   493k|      if (input.is_ascii()) {
  ------------------
  |  Branch (187:11): [True: 404k, False: 88.7k]
  ------------------
  188|   404k|        input.store_ascii_as_utf16<endian>(utf16_output);
  189|   404k|        utf16_output += 64;
  190|   404k|        pos += 64;
  191|   404k|        if ((pos & 1023) < 64 && errors()) {
  ------------------
  |  Branch (191:13): [True: 25.2k, False: 379k]
  |  Branch (191:34): [True: 20, False: 25.2k]
  ------------------
  192|     20|          return 0;
  193|     20|        }
  194|   404k|      } else {
  195|       |        // you might think that a for-loop would work, but under Visual Studio,
  196|       |        // it is not good enough.
  197|  88.7k|        static_assert(
  198|  88.7k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  199|  88.7k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  200|  88.7k|            "We support either two or four chunks per 64-byte block.");
  201|  88.7k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  202|  88.7k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  203|  88.7k|          this->check_utf8_bytes(input.chunks[0], zero);
  204|  88.7k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  205|       |        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  206|       |          this->check_utf8_bytes(input.chunks[0], zero);
  207|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  208|       |          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  209|       |          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  210|       |        }
  211|  88.7k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  212|  88.7k|        if ((utf8_continuation_mask & 1) || ((pos & 1023) < 64 && errors())) {
  ------------------
  |  Branch (212:13): [True: 18, False: 88.7k]
  |  Branch (212:46): [True: 6.00k, False: 82.7k]
  |  Branch (212:67): [True: 84, False: 5.91k]
  ------------------
  213|    102|          return 0; // error
  214|    102|        }
  215|  88.6k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  216|  88.6k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  217|       |        // We process in blocks of up to 12 bytes except possibly
  218|       |        // for fast paths which may process up to 16 bytes. For the
  219|       |        // slow path to work, we should have at least 12 input bytes left.
  220|  88.6k|        size_t max_starting_point = (pos + 64) - 12;
  221|       |        // Next loop is going to run at least five times.
  222|   636k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (222:16): [True: 547k, False: 88.6k]
  ------------------
  223|       |          // Performance note: our ability to compute 'consumed' and
  224|       |          // then shift and recompute is critical. If there is a
  225|       |          // latency of, say, 4 cycles on getting 'consumed', then
  226|       |          // the inner loop might have a total latency of about 6 cycles.
  227|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  228|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  229|       |          // for this section of the code. Hence, there is a limit
  230|       |          // to how much we can further increase this latency before
  231|       |          // it seriously harms performance.
  232|   547k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  233|   547k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  234|   547k|          pos += consumed;
  235|   547k|          utf8_end_of_code_point_mask >>= consumed;
  236|   547k|        }
  237|       |        // At this point there may remain between 0 and 12 bytes in the
  238|       |        // 64-byte block. These bytes will be processed again. So we have an
  239|       |        // 80% efficiency (in the worst case). In practice we expect an
  240|       |        // 85% to 90% efficiency.
  241|  88.6k|      }
  242|   493k|    }
  243|    530|    if (errors()) {
  ------------------
  |  Branch (243:9): [True: 140, False: 390]
  ------------------
  244|    140|      return 0;
  245|    140|    }
  246|    390|    const size_t ascii =
  247|    390|        convert_ascii_tail<endian>(in, pos, size, utf16_output);
  248|    390|    pos += ascii;
  249|    390|    utf16_output += ascii;
  250|    390|    if (pos == size) {
  ------------------
  |  Branch (250:9): [True: 74, False: 316]
  ------------------
  251|     74|      return utf16_output - start;
  252|     74|    }
  253|    316|    SIMDUTF_VZEROUPPER();
  ------------------
  |  |   22|    316|#define SIMDUTF_VZEROUPPER() _mm256_zeroupper()
  ------------------
  254|    316|    size_t howmany = scalar::utf8_to_utf16::convert<endian>(
  255|    316|        in + pos, size - pos, utf16_output);
  256|    316|    if (howmany == 0) {
  ------------------
  |  Branch (256:9): [True: 234, False: 82]
  ------------------
  257|    234|      return 0;
  258|    234|    }
  259|     82|    return utf16_output + howmany - start;
  260|    316|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder18convert_ascii_tailILNS_10endiannessE1EEEmPKcmmPDs:
  132|  1.67k|                                                         char16_t *output) {
  133|       |    // A cheap test on the first bytes avoids any SIMD work for most non-ASCII
  134|       |    // tails.
  135|  1.67k|    if (size - pos >= 8) {
  ------------------
  |  Branch (135:9): [True: 1.62k, False: 54]
  ------------------
  136|  1.62k|      uint64_t first_bytes;
  137|  1.62k|      std::memcpy(&first_bytes, in + pos, 8);
  138|  1.62k|      if (first_bytes & 0x8080808080808080) {
  ------------------
  |  Branch (138:11): [True: 416, False: 1.20k]
  ------------------
  139|    416|        return 0;
  140|    416|      }
  141|  1.62k|    }
  142|  1.25k|    const size_t start = pos;
  143|  1.43k|    while (pos + 64 <= size) {
  ------------------
  |  Branch (143:12): [True: 450, False: 980]
  ------------------
  144|    450|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  145|    450|      if (!input.is_ascii()) {
  ------------------
  |  Branch (145:11): [True: 278, False: 172]
  ------------------
  146|    278|        return pos - start;
  147|    278|      }
  148|    172|      input.store_ascii_as_utf16<endian>(output + (pos - start));
  149|    172|      pos += 64;
  150|    172|    }
  151|    980|    if (pos == size || size < 64) {
  ------------------
  |  Branch (151:9): [True: 52, False: 928]
  |  Branch (151:24): [True: 84, False: 844]
  ------------------
  152|    136|      return pos - start;
  153|    136|    }
  154|    844|    simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + size - 64));
  155|    844|    if (!input.is_ascii()) {
  ------------------
  |  Branch (155:9): [True: 608, False: 236]
  ------------------
  156|    608|      return pos - start;
  157|    608|    }
  158|    236|    input.store_ascii_as_utf16<endian>(output + (pos - start) -
  159|    236|                                       (pos - (size - 64)));
  160|    236|    return size - start;
  161|    844|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder19convert_with_errorsILNS_10endiannessE0EEENS_6resultEPKcmPDs:
  264|    790|                                                   char16_t *utf16_output) {
  265|    790|    if (size < 64) { // too short for the main loop
  ------------------
  |  Branch (265:9): [True: 284, False: 506]
  ------------------
  266|    284|      return scalar::utf8_to_utf16::convert_with_errors<endian>(in, size,
  267|    284|                                                                utf16_output);
  268|    284|    }
  269|    506|    size_t pos = 0;
  270|    506|    char16_t *start{utf16_output};
  271|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  272|       |    // of 8 bytes when calling convert_masked_utf8_to_utf16. If you skip the
  273|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  274|       |    // 16 UTF-8 bytes generate much more than 8 bytes. However, you cannot
  275|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  276|       |    // back from the end counting 8 leading bytes, to give us a good margin.
  277|    506|    size_t leading_byte = 0;
  278|    506|    size_t margin = size;
  279|  12.4k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (279:12): [True: 12.4k, False: 16]
  |  Branch (279:26): [True: 11.9k, False: 490]
  ------------------
  280|  11.9k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  281|  11.9k|    }
  282|       |    // If the input is long enough, then we have that margin is the eighth last
  283|       |    // leading byte.
  284|    506|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  285|   521k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (285:12): [True: 520k, False: 422]
  ------------------
  286|   520k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  287|   520k|      if (input.is_ascii()) {
  ------------------
  |  Branch (287:11): [True: 441k, False: 78.8k]
  ------------------
  288|   441k|        input.store_ascii_as_utf16<endian>(utf16_output);
  289|   441k|        utf16_output += 64;
  290|   441k|        pos += 64;
  291|   441k|      } else {
  292|       |        // you might think that a for-loop would work, but under Visual Studio,
  293|       |        // it is not good enough.
  294|  78.8k|        static_assert(
  295|  78.8k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  296|  78.8k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  297|  78.8k|            "We support either two or four chunks per 64-byte block.");
  298|  78.8k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  299|  78.8k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  300|  78.8k|          this->check_utf8_bytes(input.chunks[0], zero);
  301|  78.8k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  302|       |        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  303|       |          this->check_utf8_bytes(input.chunks[0], zero);
  304|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  305|       |          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  306|       |          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  307|       |        }
  308|  78.8k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  309|  78.8k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (309:13): [True: 84, False: 78.7k]
  |  Branch (309:25): [True: 0, False: 78.7k]
  ------------------
  310|       |          // rewind_and_convert_with_errors will seek a potential error from
  311|       |          // in+pos onward, with the ability to go back up to pos bytes, and
  312|       |          // read size-pos bytes forward.
  313|     84|          SIMDUTF_VZEROUPPER();
  ------------------
  |  |   22|     84|#define SIMDUTF_VZEROUPPER() _mm256_zeroupper()
  ------------------
  314|     84|          result res =
  315|     84|              scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  316|     84|                  pos, in + pos, size - pos, utf16_output);
  317|     84|          res.count += pos;
  318|     84|          return res;
  319|     84|        }
  320|  78.7k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  321|  78.7k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  322|       |        // We process in blocks of up to 12 bytes except possibly
  323|       |        // for fast paths which may process up to 16 bytes. For the
  324|       |        // slow path to work, we should have at least 12 input bytes left.
  325|  78.7k|        size_t max_starting_point = (pos + 64) - 12;
  326|       |        // Next loop is going to run at least five times.
  327|   569k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (327:16): [True: 490k, False: 78.7k]
  ------------------
  328|       |          // Performance note: our ability to compute 'consumed' and
  329|       |          // then shift and recompute is critical. If there is a
  330|       |          // latency of, say, 4 cycles on getting 'consumed', then
  331|       |          // the inner loop might have a total latency of about 6 cycles.
  332|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  333|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  334|       |          // for this section of the code. Hence, there is a limit
  335|       |          // to how much we can further increase this latency before
  336|       |          // it seriously harms performance.
  337|   490k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  338|   490k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  339|   490k|          pos += consumed;
  340|   490k|          utf8_end_of_code_point_mask >>= consumed;
  341|   490k|        }
  342|       |        // At this point there may remain between 0 and 12 bytes in the
  343|       |        // 64-byte block. These bytes will be processed again. So we have an
  344|       |        // 80% efficiency (in the worst case). In practice we expect an
  345|       |        // 85% to 90% efficiency.
  346|  78.7k|      }
  347|   520k|    }
  348|    422|    const size_t ascii =
  349|    422|        convert_ascii_tail<endian>(in, pos, size, utf16_output);
  350|    422|    pos += ascii;
  351|    422|    utf16_output += ascii;
  352|    422|    if (pos == size) {
  ------------------
  |  Branch (352:9): [True: 94, False: 328]
  ------------------
  353|     94|      return result(error_code::SUCCESS, utf16_output - start);
  354|     94|    }
  355|       |    // rewind_and_convert_with_errors will seek a potential error from in+pos
  356|       |    // onward, with the ability to go back up to pos bytes, and read size-pos
  357|       |    // bytes forward.
  358|    328|    SIMDUTF_VZEROUPPER();
  ------------------
  |  |   22|    328|#define SIMDUTF_VZEROUPPER() _mm256_zeroupper()
  ------------------
  359|    328|    result res = scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  360|    328|        pos, in + pos, size - pos, utf16_output);
  361|    328|    if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (361:9): [True: 244, False: 84]
  ------------------
  362|    244|      res.count += pos;
  363|    244|      return res;
  364|    244|    }
  365|       |    // In case of success, we want the number of words written
  366|     84|    utf16_output += res.count;
  367|     84|    return result(error_code::SUCCESS, utf16_output - start);
  368|    328|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1621validating_transcoder19convert_with_errorsILNS_10endiannessE1EEENS_6resultEPKcmPDs:
  264|    884|                                                   char16_t *utf16_output) {
  265|    884|    if (size < 64) { // too short for the main loop
  ------------------
  |  Branch (265:9): [True: 282, False: 602]
  ------------------
  266|    282|      return scalar::utf8_to_utf16::convert_with_errors<endian>(in, size,
  267|    282|                                                                utf16_output);
  268|    282|    }
  269|    602|    size_t pos = 0;
  270|    602|    char16_t *start{utf16_output};
  271|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  272|       |    // of 8 bytes when calling convert_masked_utf8_to_utf16. If you skip the
  273|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  274|       |    // 16 UTF-8 bytes generate much more than 8 bytes. However, you cannot
  275|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  276|       |    // back from the end counting 8 leading bytes, to give us a good margin.
  277|    602|    size_t leading_byte = 0;
  278|    602|    size_t margin = size;
  279|  8.41k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (279:12): [True: 8.40k, False: 14]
  |  Branch (279:26): [True: 7.81k, False: 588]
  ------------------
  280|  7.81k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  281|  7.81k|    }
  282|       |    // If the input is long enough, then we have that margin is the eighth last
  283|       |    // leading byte.
  284|    602|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  285|   524k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (285:12): [True: 524k, False: 512]
  ------------------
  286|   524k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  287|   524k|      if (input.is_ascii()) {
  ------------------
  |  Branch (287:11): [True: 330k, False: 194k]
  ------------------
  288|   330k|        input.store_ascii_as_utf16<endian>(utf16_output);
  289|   330k|        utf16_output += 64;
  290|   330k|        pos += 64;
  291|   330k|      } else {
  292|       |        // you might think that a for-loop would work, but under Visual Studio,
  293|       |        // it is not good enough.
  294|   194k|        static_assert(
  295|   194k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  296|   194k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  297|   194k|            "We support either two or four chunks per 64-byte block.");
  298|   194k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  299|   194k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  300|   194k|          this->check_utf8_bytes(input.chunks[0], zero);
  301|   194k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  302|       |        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  303|       |          this->check_utf8_bytes(input.chunks[0], zero);
  304|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  305|       |          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  306|       |          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  307|       |        }
  308|   194k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  309|   194k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (309:13): [True: 90, False: 193k]
  |  Branch (309:25): [True: 0, False: 193k]
  ------------------
  310|       |          // rewind_and_convert_with_errors will seek a potential error from
  311|       |          // in+pos onward, with the ability to go back up to pos bytes, and
  312|       |          // read size-pos bytes forward.
  313|     90|          SIMDUTF_VZEROUPPER();
  ------------------
  |  |   22|     90|#define SIMDUTF_VZEROUPPER() _mm256_zeroupper()
  ------------------
  314|     90|          result res =
  315|     90|              scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  316|     90|                  pos, in + pos, size - pos, utf16_output);
  317|     90|          res.count += pos;
  318|     90|          return res;
  319|     90|        }
  320|   193k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  321|   193k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  322|       |        // We process in blocks of up to 12 bytes except possibly
  323|       |        // for fast paths which may process up to 16 bytes. For the
  324|       |        // slow path to work, we should have at least 12 input bytes left.
  325|   193k|        size_t max_starting_point = (pos + 64) - 12;
  326|       |        // Next loop is going to run at least five times.
  327|  1.40M|        while (pos < max_starting_point) {
  ------------------
  |  Branch (327:16): [True: 1.21M, False: 193k]
  ------------------
  328|       |          // Performance note: our ability to compute 'consumed' and
  329|       |          // then shift and recompute is critical. If there is a
  330|       |          // latency of, say, 4 cycles on getting 'consumed', then
  331|       |          // the inner loop might have a total latency of about 6 cycles.
  332|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  333|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  334|       |          // for this section of the code. Hence, there is a limit
  335|       |          // to how much we can further increase this latency before
  336|       |          // it seriously harms performance.
  337|  1.21M|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  338|  1.21M|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  339|  1.21M|          pos += consumed;
  340|  1.21M|          utf8_end_of_code_point_mask >>= consumed;
  341|  1.21M|        }
  342|       |        // At this point there may remain between 0 and 12 bytes in the
  343|       |        // 64-byte block. These bytes will be processed again. So we have an
  344|       |        // 80% efficiency (in the worst case). In practice we expect an
  345|       |        // 85% to 90% efficiency.
  346|   193k|      }
  347|   524k|    }
  348|    512|    const size_t ascii =
  349|    512|        convert_ascii_tail<endian>(in, pos, size, utf16_output);
  350|    512|    pos += ascii;
  351|    512|    utf16_output += ascii;
  352|    512|    if (pos == size) {
  ------------------
  |  Branch (352:9): [True: 62, False: 450]
  ------------------
  353|     62|      return result(error_code::SUCCESS, utf16_output - start);
  354|     62|    }
  355|       |    // rewind_and_convert_with_errors will seek a potential error from in+pos
  356|       |    // onward, with the ability to go back up to pos bytes, and read size-pos
  357|       |    // bytes forward.
  358|    450|    SIMDUTF_VZEROUPPER();
  ------------------
  |  |   22|    450|#define SIMDUTF_VZEROUPPER() _mm256_zeroupper()
  ------------------
  359|    450|    result res = scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  360|    450|        pos, in + pos, size - pos, utf16_output);
  361|    450|    if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (361:9): [True: 298, False: 152]
  ------------------
  362|    298|      res.count += pos;
  363|    298|      return res;
  364|    298|    }
  365|       |    // In case of success, we want the number of words written
  366|    152|    utf16_output += res.count;
  367|    152|    return result(error_code::SUCCESS, utf16_output - start);
  368|    450|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder7convertILNS_10endiannessE0EEEmPKcmPDs:
  165|    984|                                       char16_t *utf16_output) {
  166|    984|    if (size < 64) { // too short for the main loop
  ------------------
  |  Branch (166:9): [True: 288, False: 696]
  ------------------
  167|    288|      return scalar::utf8_to_utf16::convert<endian>(in, size, utf16_output);
  168|    288|    }
  169|    696|    size_t pos = 0;
  170|    696|    char16_t *start{utf16_output};
  171|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  172|       |    // of 8 bytes when calling convert_masked_utf8_to_utf16. If you skip the
  173|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  174|       |    // 16 UTF-8 bytes generate much more than 8 bytes. However, you cannot
  175|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  176|       |    // back from the end counting 8 leading bytes, to give us a good margin.
  177|    696|    size_t leading_byte = 0;
  178|    696|    size_t margin = size;
  179|  9.29k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (179:12): [True: 9.28k, False: 12]
  |  Branch (179:26): [True: 8.60k, False: 684]
  ------------------
  180|  8.60k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  181|  8.60k|    }
  182|       |    // If the input is long enough, then we have that margin is the eighth last
  183|       |    // leading byte.
  184|    696|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  185|   521k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (185:12): [True: 520k, False: 556]
  ------------------
  186|   520k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  187|   520k|      if (input.is_ascii()) {
  ------------------
  |  Branch (187:11): [True: 394k, False: 126k]
  ------------------
  188|   394k|        input.store_ascii_as_utf16<endian>(utf16_output);
  189|   394k|        utf16_output += 64;
  190|   394k|        pos += 64;
  191|   394k|        if ((pos & 1023) < 64 && errors()) {
  ------------------
  |  Branch (191:13): [True: 24.4k, False: 369k]
  |  Branch (191:34): [True: 18, False: 24.4k]
  ------------------
  192|     18|          return 0;
  193|     18|        }
  194|   394k|      } else {
  195|       |        // you might think that a for-loop would work, but under Visual Studio,
  196|       |        // it is not good enough.
  197|   126k|        static_assert(
  198|   126k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  199|   126k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  200|   126k|            "We support either two or four chunks per 64-byte block.");
  201|   126k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  202|       |        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  203|       |          this->check_utf8_bytes(input.chunks[0], zero);
  204|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  205|   126k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  206|   126k|          this->check_utf8_bytes(input.chunks[0], zero);
  207|   126k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  208|   126k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  209|   126k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  210|   126k|        }
  211|   126k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  212|   126k|        if ((utf8_continuation_mask & 1) || ((pos & 1023) < 64 && errors())) {
  ------------------
  |  Branch (212:13): [True: 12, False: 126k]
  |  Branch (212:46): [True: 8.26k, False: 118k]
  |  Branch (212:67): [True: 110, False: 8.15k]
  ------------------
  213|    122|          return 0; // error
  214|    122|        }
  215|   126k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  216|   126k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  217|       |        // We process in blocks of up to 12 bytes except possibly
  218|       |        // for fast paths which may process up to 16 bytes. For the
  219|       |        // slow path to work, we should have at least 12 input bytes left.
  220|   126k|        size_t max_starting_point = (pos + 64) - 12;
  221|       |        // Next loop is going to run at least five times.
  222|   918k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (222:16): [True: 791k, False: 126k]
  ------------------
  223|       |          // Performance note: our ability to compute 'consumed' and
  224|       |          // then shift and recompute is critical. If there is a
  225|       |          // latency of, say, 4 cycles on getting 'consumed', then
  226|       |          // the inner loop might have a total latency of about 6 cycles.
  227|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  228|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  229|       |          // for this section of the code. Hence, there is a limit
  230|       |          // to how much we can further increase this latency before
  231|       |          // it seriously harms performance.
  232|   791k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  233|   791k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  234|   791k|          pos += consumed;
  235|   791k|          utf8_end_of_code_point_mask >>= consumed;
  236|   791k|        }
  237|       |        // At this point there may remain between 0 and 12 bytes in the
  238|       |        // 64-byte block. These bytes will be processed again. So we have an
  239|       |        // 80% efficiency (in the worst case). In practice we expect an
  240|       |        // 85% to 90% efficiency.
  241|   126k|      }
  242|   520k|    }
  243|    556|    if (errors()) {
  ------------------
  |  Branch (243:9): [True: 120, False: 436]
  ------------------
  244|    120|      return 0;
  245|    120|    }
  246|    436|    const size_t ascii =
  247|    436|        convert_ascii_tail<endian>(in, pos, size, utf16_output);
  248|    436|    pos += ascii;
  249|    436|    utf16_output += ascii;
  250|    436|    if (pos == size) {
  ------------------
  |  Branch (250:9): [True: 106, False: 330]
  ------------------
  251|    106|      return utf16_output - start;
  252|    106|    }
  253|    330|    SIMDUTF_VZEROUPPER();
  ------------------
  |  |   16|    330|#define SIMDUTF_VZEROUPPER() (void)0
  ------------------
  254|    330|    size_t howmany = scalar::utf8_to_utf16::convert<endian>(
  255|    330|        in + pos, size - pos, utf16_output);
  256|    330|    if (howmany == 0) {
  ------------------
  |  Branch (256:9): [True: 260, False: 70]
  ------------------
  257|    260|      return 0;
  258|    260|    }
  259|     70|    return utf16_output + howmany - start;
  260|    330|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder6errorsEv:
  370|   338k|  simdutf_really_inline bool errors() const {
  371|   338k|    return this->error.any_bits_set_anywhere();
  372|   338k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  119|  1.95M|                                              const simd8<uint8_t> prev_input) {
  120|       |    // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+
  121|       |    // lead bytes (2, 3, 4-byte leads become large positive numbers instead of
  122|       |    // small negative numbers)
  123|  1.95M|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  124|  1.95M|    simd8<uint8_t> sc = check_special_cases(input, prev1);
  125|  1.95M|    this->error |= check_multibyte_lengths(input, prev_input, sc);
  126|  1.95M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1619check_special_casesENS1_4simd5simd8IhEES5_:
    8|  1.95M|check_special_cases(const simd8<uint8_t> input, const simd8<uint8_t> prev1) {
    9|       |  // Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII)
   10|       |  // Bit 1 = Too Long (ASCII followed by continuation)
   11|       |  // Bit 2 = Overlong 3-byte
   12|       |  // Bit 4 = Surrogate
   13|       |  // Bit 5 = Overlong 2-byte
   14|       |  // Bit 7 = Two Continuations
   15|  1.95M|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   16|       |                                               // 11______ 11______
   17|  1.95M|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   18|  1.95M|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   19|  1.95M|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   20|  1.95M|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   21|  1.95M|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   22|  1.95M|  constexpr const uint8_t TOO_LARGE = 1 << 3;  // 11110100 1001____
   23|       |                                               // 11110100 101_____
   24|       |                                               // 11110101 1001____
   25|       |                                               // 11110101 101_____
   26|       |                                               // 1111011_ 1001____
   27|       |                                               // 1111011_ 101_____
   28|       |                                               // 11111___ 1001____
   29|       |                                               // 11111___ 101_____
   30|  1.95M|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   31|       |  // 11110101 1000____
   32|       |  // 1111011_ 1000____
   33|       |  // 11111___ 1000____
   34|  1.95M|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   35|       |
   36|  1.95M|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   37|       |      // 0_______ ________ <ASCII in byte 1>
   38|  1.95M|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   39|  1.95M|      TOO_LONG,
   40|       |      // 10______ ________ <continuation in byte 1>
   41|  1.95M|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   42|       |      // 1100____ ________ <two byte lead in byte 1>
   43|  1.95M|      TOO_SHORT | OVERLONG_2,
   44|       |      // 1101____ ________ <two byte lead in byte 1>
   45|  1.95M|      TOO_SHORT,
   46|       |      // 1110____ ________ <three byte lead in byte 1>
   47|  1.95M|      TOO_SHORT | OVERLONG_3 | SURROGATE,
   48|       |      // 1111____ ________ <four+ byte lead in byte 1>
   49|  1.95M|      TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4);
   50|  1.95M|  constexpr const uint8_t CARRY =
   51|  1.95M|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   52|  1.95M|  const simd8<uint8_t> byte_1_low =
   53|  1.95M|      (prev1 & 0x0F)
   54|  1.95M|          .lookup_16<uint8_t>(
   55|       |              // ____0000 ________
   56|  1.95M|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   57|       |              // ____0001 ________
   58|  1.95M|              CARRY | OVERLONG_2,
   59|       |              // ____001_ ________
   60|  1.95M|              CARRY, CARRY,
   61|       |
   62|       |              // ____0100 ________
   63|  1.95M|              CARRY | TOO_LARGE,
   64|       |              // ____0101 ________
   65|  1.95M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   66|       |              // ____011_ ________
   67|  1.95M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   68|  1.95M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   69|       |
   70|       |              // ____1___ ________
   71|  1.95M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   72|  1.95M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   73|  1.95M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   74|  1.95M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   75|  1.95M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   76|       |              // ____1101 ________
   77|  1.95M|              CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE,
   78|  1.95M|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   79|  1.95M|              CARRY | TOO_LARGE | TOO_LARGE_1000);
   80|  1.95M|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   81|       |      // ________ 0_______ <ASCII in byte 2>
   82|  1.95M|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   83|  1.95M|      TOO_SHORT, TOO_SHORT,
   84|       |
   85|       |      // ________ 1000____
   86|  1.95M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
   87|  1.95M|          OVERLONG_4,
   88|       |      // ________ 1001____
   89|  1.95M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
   90|       |      // ________ 101_____
   91|  1.95M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   92|  1.95M|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   93|       |
   94|       |      // ________ 11______
   95|  1.95M|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
   96|  1.95M|  return (byte_1_high & byte_1_low & byte_2_high);
   97|  1.95M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1623check_multibyte_lengthsENS1_4simd5simd8IhEES5_S5_:
  101|  1.95M|                        const simd8<uint8_t> sc) {
  102|  1.95M|  simd8<uint8_t> prev2 = input.prev<2>(prev_input);
  103|  1.95M|  simd8<uint8_t> prev3 = input.prev<3>(prev_input);
  104|  1.95M|  simd8<uint8_t> must23 =
  105|  1.95M|      simd8<uint8_t>(must_be_2_3_continuation(prev2, prev3));
  106|  1.95M|  simd8<uint8_t> must23_80 = must23 & uint8_t(0x80);
  107|  1.95M|  return must23_80 ^ sc;
  108|  1.95M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder18convert_ascii_tailILNS_10endiannessE0EEEmPKcmmPDs:
  132|  1.38k|                                                         char16_t *output) {
  133|       |    // A cheap test on the first bytes avoids any SIMD work for most non-ASCII
  134|       |    // tails.
  135|  1.38k|    if (size - pos >= 8) {
  ------------------
  |  Branch (135:9): [True: 1.34k, False: 42]
  ------------------
  136|  1.34k|      uint64_t first_bytes;
  137|  1.34k|      std::memcpy(&first_bytes, in + pos, 8);
  138|  1.34k|      if (first_bytes & 0x8080808080808080) {
  ------------------
  |  Branch (138:11): [True: 372, False: 972]
  ------------------
  139|    372|        return 0;
  140|    372|      }
  141|  1.34k|    }
  142|  1.01k|    const size_t start = pos;
  143|  1.16k|    while (pos + 64 <= size) {
  ------------------
  |  Branch (143:12): [True: 416, False: 744]
  ------------------
  144|    416|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  145|    416|      if (!input.is_ascii()) {
  ------------------
  |  Branch (145:11): [True: 270, False: 146]
  ------------------
  146|    270|        return pos - start;
  147|    270|      }
  148|    146|      input.store_ascii_as_utf16<endian>(output + (pos - start));
  149|    146|      pos += 64;
  150|    146|    }
  151|    744|    if (pos == size || size < 64) {
  ------------------
  |  Branch (151:9): [True: 38, False: 706]
  |  Branch (151:24): [True: 70, False: 636]
  ------------------
  152|    108|      return pos - start;
  153|    108|    }
  154|    636|    simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + size - 64));
  155|    636|    if (!input.is_ascii()) {
  ------------------
  |  Branch (155:9): [True: 380, False: 256]
  ------------------
  156|    380|      return pos - start;
  157|    380|    }
  158|    256|    input.store_ascii_as_utf16<endian>(output + (pos - start) -
  159|    256|                                       (pos - (size - 64)));
  160|    256|    return size - start;
  161|    636|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder7convertILNS_10endiannessE1EEEmPKcmPDs:
  165|    960|                                       char16_t *utf16_output) {
  166|    960|    if (size < 64) { // too short for the main loop
  ------------------
  |  Branch (166:9): [True: 308, False: 652]
  ------------------
  167|    308|      return scalar::utf8_to_utf16::convert<endian>(in, size, utf16_output);
  168|    308|    }
  169|    652|    size_t pos = 0;
  170|    652|    char16_t *start{utf16_output};
  171|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  172|       |    // of 8 bytes when calling convert_masked_utf8_to_utf16. If you skip the
  173|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  174|       |    // 16 UTF-8 bytes generate much more than 8 bytes. However, you cannot
  175|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  176|       |    // back from the end counting 8 leading bytes, to give us a good margin.
  177|    652|    size_t leading_byte = 0;
  178|    652|    size_t margin = size;
  179|  8.27k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (179:12): [True: 8.26k, False: 10]
  |  Branch (179:26): [True: 7.62k, False: 642]
  ------------------
  180|  7.62k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  181|  7.62k|    }
  182|       |    // If the input is long enough, then we have that margin is the eighth last
  183|       |    // leading byte.
  184|    652|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  185|   494k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (185:12): [True: 493k, False: 530]
  ------------------
  186|   493k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  187|   493k|      if (input.is_ascii()) {
  ------------------
  |  Branch (187:11): [True: 404k, False: 88.7k]
  ------------------
  188|   404k|        input.store_ascii_as_utf16<endian>(utf16_output);
  189|   404k|        utf16_output += 64;
  190|   404k|        pos += 64;
  191|   404k|        if ((pos & 1023) < 64 && errors()) {
  ------------------
  |  Branch (191:13): [True: 25.2k, False: 379k]
  |  Branch (191:34): [True: 20, False: 25.2k]
  ------------------
  192|     20|          return 0;
  193|     20|        }
  194|   404k|      } else {
  195|       |        // you might think that a for-loop would work, but under Visual Studio,
  196|       |        // it is not good enough.
  197|  88.7k|        static_assert(
  198|  88.7k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  199|  88.7k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  200|  88.7k|            "We support either two or four chunks per 64-byte block.");
  201|  88.7k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  202|       |        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  203|       |          this->check_utf8_bytes(input.chunks[0], zero);
  204|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  205|  88.7k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  206|  88.7k|          this->check_utf8_bytes(input.chunks[0], zero);
  207|  88.7k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  208|  88.7k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  209|  88.7k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  210|  88.7k|        }
  211|  88.7k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  212|  88.7k|        if ((utf8_continuation_mask & 1) || ((pos & 1023) < 64 && errors())) {
  ------------------
  |  Branch (212:13): [True: 18, False: 88.7k]
  |  Branch (212:46): [True: 6.00k, False: 82.7k]
  |  Branch (212:67): [True: 84, False: 5.91k]
  ------------------
  213|    102|          return 0; // error
  214|    102|        }
  215|  88.6k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  216|  88.6k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  217|       |        // We process in blocks of up to 12 bytes except possibly
  218|       |        // for fast paths which may process up to 16 bytes. For the
  219|       |        // slow path to work, we should have at least 12 input bytes left.
  220|  88.6k|        size_t max_starting_point = (pos + 64) - 12;
  221|       |        // Next loop is going to run at least five times.
  222|   636k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (222:16): [True: 547k, False: 88.6k]
  ------------------
  223|       |          // Performance note: our ability to compute 'consumed' and
  224|       |          // then shift and recompute is critical. If there is a
  225|       |          // latency of, say, 4 cycles on getting 'consumed', then
  226|       |          // the inner loop might have a total latency of about 6 cycles.
  227|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  228|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  229|       |          // for this section of the code. Hence, there is a limit
  230|       |          // to how much we can further increase this latency before
  231|       |          // it seriously harms performance.
  232|   547k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  233|   547k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  234|   547k|          pos += consumed;
  235|   547k|          utf8_end_of_code_point_mask >>= consumed;
  236|   547k|        }
  237|       |        // At this point there may remain between 0 and 12 bytes in the
  238|       |        // 64-byte block. These bytes will be processed again. So we have an
  239|       |        // 80% efficiency (in the worst case). In practice we expect an
  240|       |        // 85% to 90% efficiency.
  241|  88.6k|      }
  242|   493k|    }
  243|    530|    if (errors()) {
  ------------------
  |  Branch (243:9): [True: 140, False: 390]
  ------------------
  244|    140|      return 0;
  245|    140|    }
  246|    390|    const size_t ascii =
  247|    390|        convert_ascii_tail<endian>(in, pos, size, utf16_output);
  248|    390|    pos += ascii;
  249|    390|    utf16_output += ascii;
  250|    390|    if (pos == size) {
  ------------------
  |  Branch (250:9): [True: 74, False: 316]
  ------------------
  251|     74|      return utf16_output - start;
  252|     74|    }
  253|    316|    SIMDUTF_VZEROUPPER();
  ------------------
  |  |   16|    316|#define SIMDUTF_VZEROUPPER() (void)0
  ------------------
  254|    316|    size_t howmany = scalar::utf8_to_utf16::convert<endian>(
  255|    316|        in + pos, size - pos, utf16_output);
  256|    316|    if (howmany == 0) {
  ------------------
  |  Branch (256:9): [True: 234, False: 82]
  ------------------
  257|    234|      return 0;
  258|    234|    }
  259|     82|    return utf16_output + howmany - start;
  260|    316|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder18convert_ascii_tailILNS_10endiannessE1EEEmPKcmmPDs:
  132|  1.67k|                                                         char16_t *output) {
  133|       |    // A cheap test on the first bytes avoids any SIMD work for most non-ASCII
  134|       |    // tails.
  135|  1.67k|    if (size - pos >= 8) {
  ------------------
  |  Branch (135:9): [True: 1.62k, False: 54]
  ------------------
  136|  1.62k|      uint64_t first_bytes;
  137|  1.62k|      std::memcpy(&first_bytes, in + pos, 8);
  138|  1.62k|      if (first_bytes & 0x8080808080808080) {
  ------------------
  |  Branch (138:11): [True: 416, False: 1.20k]
  ------------------
  139|    416|        return 0;
  140|    416|      }
  141|  1.62k|    }
  142|  1.25k|    const size_t start = pos;
  143|  1.43k|    while (pos + 64 <= size) {
  ------------------
  |  Branch (143:12): [True: 450, False: 980]
  ------------------
  144|    450|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  145|    450|      if (!input.is_ascii()) {
  ------------------
  |  Branch (145:11): [True: 278, False: 172]
  ------------------
  146|    278|        return pos - start;
  147|    278|      }
  148|    172|      input.store_ascii_as_utf16<endian>(output + (pos - start));
  149|    172|      pos += 64;
  150|    172|    }
  151|    980|    if (pos == size || size < 64) {
  ------------------
  |  Branch (151:9): [True: 52, False: 928]
  |  Branch (151:24): [True: 84, False: 844]
  ------------------
  152|    136|      return pos - start;
  153|    136|    }
  154|    844|    simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + size - 64));
  155|    844|    if (!input.is_ascii()) {
  ------------------
  |  Branch (155:9): [True: 608, False: 236]
  ------------------
  156|    608|      return pos - start;
  157|    608|    }
  158|    236|    input.store_ascii_as_utf16<endian>(output + (pos - start) -
  159|    236|                                       (pos - (size - 64)));
  160|    236|    return size - start;
  161|    844|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder19convert_with_errorsILNS_10endiannessE0EEENS_6resultEPKcmPDs:
  264|    790|                                                   char16_t *utf16_output) {
  265|    790|    if (size < 64) { // too short for the main loop
  ------------------
  |  Branch (265:9): [True: 284, False: 506]
  ------------------
  266|    284|      return scalar::utf8_to_utf16::convert_with_errors<endian>(in, size,
  267|    284|                                                                utf16_output);
  268|    284|    }
  269|    506|    size_t pos = 0;
  270|    506|    char16_t *start{utf16_output};
  271|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  272|       |    // of 8 bytes when calling convert_masked_utf8_to_utf16. If you skip the
  273|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  274|       |    // 16 UTF-8 bytes generate much more than 8 bytes. However, you cannot
  275|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  276|       |    // back from the end counting 8 leading bytes, to give us a good margin.
  277|    506|    size_t leading_byte = 0;
  278|    506|    size_t margin = size;
  279|  12.4k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (279:12): [True: 12.4k, False: 16]
  |  Branch (279:26): [True: 11.9k, False: 490]
  ------------------
  280|  11.9k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  281|  11.9k|    }
  282|       |    // If the input is long enough, then we have that margin is the eighth last
  283|       |    // leading byte.
  284|    506|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  285|   521k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (285:12): [True: 520k, False: 422]
  ------------------
  286|   520k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  287|   520k|      if (input.is_ascii()) {
  ------------------
  |  Branch (287:11): [True: 441k, False: 78.8k]
  ------------------
  288|   441k|        input.store_ascii_as_utf16<endian>(utf16_output);
  289|   441k|        utf16_output += 64;
  290|   441k|        pos += 64;
  291|   441k|      } else {
  292|       |        // you might think that a for-loop would work, but under Visual Studio,
  293|       |        // it is not good enough.
  294|  78.8k|        static_assert(
  295|  78.8k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  296|  78.8k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  297|  78.8k|            "We support either two or four chunks per 64-byte block.");
  298|  78.8k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  299|       |        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  300|       |          this->check_utf8_bytes(input.chunks[0], zero);
  301|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  302|  78.8k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  303|  78.8k|          this->check_utf8_bytes(input.chunks[0], zero);
  304|  78.8k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  305|  78.8k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  306|  78.8k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  307|  78.8k|        }
  308|  78.8k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  309|  78.8k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (309:13): [True: 84, False: 78.7k]
  |  Branch (309:25): [True: 0, False: 78.7k]
  ------------------
  310|       |          // rewind_and_convert_with_errors will seek a potential error from
  311|       |          // in+pos onward, with the ability to go back up to pos bytes, and
  312|       |          // read size-pos bytes forward.
  313|     84|          SIMDUTF_VZEROUPPER();
  ------------------
  |  |   16|     84|#define SIMDUTF_VZEROUPPER() (void)0
  ------------------
  314|     84|          result res =
  315|     84|              scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  316|     84|                  pos, in + pos, size - pos, utf16_output);
  317|     84|          res.count += pos;
  318|     84|          return res;
  319|     84|        }
  320|  78.7k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  321|  78.7k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  322|       |        // We process in blocks of up to 12 bytes except possibly
  323|       |        // for fast paths which may process up to 16 bytes. For the
  324|       |        // slow path to work, we should have at least 12 input bytes left.
  325|  78.7k|        size_t max_starting_point = (pos + 64) - 12;
  326|       |        // Next loop is going to run at least five times.
  327|   569k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (327:16): [True: 490k, False: 78.7k]
  ------------------
  328|       |          // Performance note: our ability to compute 'consumed' and
  329|       |          // then shift and recompute is critical. If there is a
  330|       |          // latency of, say, 4 cycles on getting 'consumed', then
  331|       |          // the inner loop might have a total latency of about 6 cycles.
  332|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  333|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  334|       |          // for this section of the code. Hence, there is a limit
  335|       |          // to how much we can further increase this latency before
  336|       |          // it seriously harms performance.
  337|   490k|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  338|   490k|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  339|   490k|          pos += consumed;
  340|   490k|          utf8_end_of_code_point_mask >>= consumed;
  341|   490k|        }
  342|       |        // At this point there may remain between 0 and 12 bytes in the
  343|       |        // 64-byte block. These bytes will be processed again. So we have an
  344|       |        // 80% efficiency (in the worst case). In practice we expect an
  345|       |        // 85% to 90% efficiency.
  346|  78.7k|      }
  347|   520k|    }
  348|    422|    const size_t ascii =
  349|    422|        convert_ascii_tail<endian>(in, pos, size, utf16_output);
  350|    422|    pos += ascii;
  351|    422|    utf16_output += ascii;
  352|    422|    if (pos == size) {
  ------------------
  |  Branch (352:9): [True: 94, False: 328]
  ------------------
  353|     94|      return result(error_code::SUCCESS, utf16_output - start);
  354|     94|    }
  355|       |    // rewind_and_convert_with_errors will seek a potential error from in+pos
  356|       |    // onward, with the ability to go back up to pos bytes, and read size-pos
  357|       |    // bytes forward.
  358|    328|    SIMDUTF_VZEROUPPER();
  ------------------
  |  |   16|    328|#define SIMDUTF_VZEROUPPER() (void)0
  ------------------
  359|    328|    result res = scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  360|    328|        pos, in + pos, size - pos, utf16_output);
  361|    328|    if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (361:9): [True: 244, False: 84]
  ------------------
  362|    244|      res.count += pos;
  363|    244|      return res;
  364|    244|    }
  365|       |    // In case of success, we want the number of words written
  366|     84|    utf16_output += res.count;
  367|     84|    return result(error_code::SUCCESS, utf16_output - start);
  368|    328|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1621validating_transcoder19convert_with_errorsILNS_10endiannessE1EEENS_6resultEPKcmPDs:
  264|    884|                                                   char16_t *utf16_output) {
  265|    884|    if (size < 64) { // too short for the main loop
  ------------------
  |  Branch (265:9): [True: 282, False: 602]
  ------------------
  266|    282|      return scalar::utf8_to_utf16::convert_with_errors<endian>(in, size,
  267|    282|                                                                utf16_output);
  268|    282|    }
  269|    602|    size_t pos = 0;
  270|    602|    char16_t *start{utf16_output};
  271|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  272|       |    // of 8 bytes when calling convert_masked_utf8_to_utf16. If you skip the
  273|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  274|       |    // 16 UTF-8 bytes generate much more than 8 bytes. However, you cannot
  275|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  276|       |    // back from the end counting 8 leading bytes, to give us a good margin.
  277|    602|    size_t leading_byte = 0;
  278|    602|    size_t margin = size;
  279|  8.41k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (279:12): [True: 8.40k, False: 14]
  |  Branch (279:26): [True: 7.81k, False: 588]
  ------------------
  280|  7.81k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  281|  7.81k|    }
  282|       |    // If the input is long enough, then we have that margin is the eighth last
  283|       |    // leading byte.
  284|    602|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  285|   524k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (285:12): [True: 524k, False: 512]
  ------------------
  286|   524k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  287|   524k|      if (input.is_ascii()) {
  ------------------
  |  Branch (287:11): [True: 330k, False: 194k]
  ------------------
  288|   330k|        input.store_ascii_as_utf16<endian>(utf16_output);
  289|   330k|        utf16_output += 64;
  290|   330k|        pos += 64;
  291|   330k|      } else {
  292|       |        // you might think that a for-loop would work, but under Visual Studio,
  293|       |        // it is not good enough.
  294|   194k|        static_assert(
  295|   194k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  296|   194k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  297|   194k|            "We support either two or four chunks per 64-byte block.");
  298|   194k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  299|       |        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  300|       |          this->check_utf8_bytes(input.chunks[0], zero);
  301|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  302|   194k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  303|   194k|          this->check_utf8_bytes(input.chunks[0], zero);
  304|   194k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  305|   194k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  306|   194k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  307|   194k|        }
  308|   194k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  309|   194k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (309:13): [True: 90, False: 193k]
  |  Branch (309:25): [True: 0, False: 193k]
  ------------------
  310|       |          // rewind_and_convert_with_errors will seek a potential error from
  311|       |          // in+pos onward, with the ability to go back up to pos bytes, and
  312|       |          // read size-pos bytes forward.
  313|     90|          SIMDUTF_VZEROUPPER();
  ------------------
  |  |   16|     90|#define SIMDUTF_VZEROUPPER() (void)0
  ------------------
  314|     90|          result res =
  315|     90|              scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  316|     90|                  pos, in + pos, size - pos, utf16_output);
  317|     90|          res.count += pos;
  318|     90|          return res;
  319|     90|        }
  320|   193k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  321|   193k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  322|       |        // We process in blocks of up to 12 bytes except possibly
  323|       |        // for fast paths which may process up to 16 bytes. For the
  324|       |        // slow path to work, we should have at least 12 input bytes left.
  325|   193k|        size_t max_starting_point = (pos + 64) - 12;
  326|       |        // Next loop is going to run at least five times.
  327|  1.40M|        while (pos < max_starting_point) {
  ------------------
  |  Branch (327:16): [True: 1.21M, False: 193k]
  ------------------
  328|       |          // Performance note: our ability to compute 'consumed' and
  329|       |          // then shift and recompute is critical. If there is a
  330|       |          // latency of, say, 4 cycles on getting 'consumed', then
  331|       |          // the inner loop might have a total latency of about 6 cycles.
  332|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  333|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  334|       |          // for this section of the code. Hence, there is a limit
  335|       |          // to how much we can further increase this latency before
  336|       |          // it seriously harms performance.
  337|  1.21M|          size_t consumed = convert_masked_utf8_to_utf16<endian>(
  338|  1.21M|              in + pos, utf8_end_of_code_point_mask, utf16_output);
  339|  1.21M|          pos += consumed;
  340|  1.21M|          utf8_end_of_code_point_mask >>= consumed;
  341|  1.21M|        }
  342|       |        // At this point there may remain between 0 and 12 bytes in the
  343|       |        // 64-byte block. These bytes will be processed again. So we have an
  344|       |        // 80% efficiency (in the worst case). In practice we expect an
  345|       |        // 85% to 90% efficiency.
  346|   193k|      }
  347|   524k|    }
  348|    512|    const size_t ascii =
  349|    512|        convert_ascii_tail<endian>(in, pos, size, utf16_output);
  350|    512|    pos += ascii;
  351|    512|    utf16_output += ascii;
  352|    512|    if (pos == size) {
  ------------------
  |  Branch (352:9): [True: 62, False: 450]
  ------------------
  353|     62|      return result(error_code::SUCCESS, utf16_output - start);
  354|     62|    }
  355|       |    // rewind_and_convert_with_errors will seek a potential error from in+pos
  356|       |    // onward, with the ability to go back up to pos bytes, and read size-pos
  357|       |    // bytes forward.
  358|    450|    SIMDUTF_VZEROUPPER();
  ------------------
  |  |   16|    450|#define SIMDUTF_VZEROUPPER() (void)0
  ------------------
  359|    450|    result res = scalar::utf8_to_utf16::rewind_and_convert_with_errors<endian>(
  360|    450|        pos, in + pos, size - pos, utf16_output);
  361|    450|    if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (361:9): [True: 298, False: 152]
  ------------------
  362|    298|      res.count += pos;
  363|    298|      return res;
  364|    298|    }
  365|       |    // In case of success, we want the number of words written
  366|    152|    utf16_output += res.count;
  367|    152|    return result(error_code::SUCCESS, utf16_output - start);
  368|    450|  }

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1613convert_validILNS_10endiannessE0EEEmPKcmPDs:
   10|    528|                                         char16_t *utf16_output) noexcept {
   11|       |  // The implementation is not specific to haswell and should be moved to the
   12|       |  // generic directory.
   13|    528|  size_t pos = 0;
   14|    528|  char16_t *start{utf16_output};
   15|    528|  const size_t safety_margin = 16; // to avoid overruns!
   16|   639k|  while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (16:10): [True: 638k, False: 528]
  ------------------
   17|       |    // this loop could be unrolled further. For example, we could process the
   18|       |    // mask far more than 64 bytes.
   19|   638k|    simd8x64<int8_t> in(reinterpret_cast<const int8_t *>(input + pos));
   20|   638k|    if (in.is_ascii()) {
  ------------------
  |  Branch (20:9): [True: 479k, False: 158k]
  ------------------
   21|   479k|      in.store_ascii_as_utf16<endian>(utf16_output);
   22|   479k|      utf16_output += 64;
   23|   479k|      pos += 64;
   24|   479k|    } else {
   25|       |      // Slow path. We hope that the compiler will recognize that this is a slow
   26|       |      // path. Anything that is not a continuation mask is a 'leading byte',
   27|       |      // that is, the start of a new code point.
   28|   158k|      uint64_t utf8_continuation_mask = in.lt(-65 + 1);
   29|       |      // -65 is 0b10111111 in two-complement's, so largest possible continuation
   30|       |      // byte
   31|   158k|      uint64_t utf8_leading_mask = ~utf8_continuation_mask;
   32|       |      // The *start* of code points is not so useful, rather, we want the *end*
   33|       |      // of code points.
   34|   158k|      uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
   35|       |      // We process in blocks of up to 12 bytes except possibly
   36|       |      // for fast paths which may process up to 16 bytes. For the
   37|       |      // slow path to work, we should have at least 12 input bytes left.
   38|   158k|      size_t max_starting_point = (pos + 64) - 12;
   39|       |      // Next loop is going to run at least five times when using solely
   40|       |      // the slow/regular path, and at least four times if there are fast paths.
   41|  1.16M|      while (pos < max_starting_point) {
  ------------------
  |  Branch (41:14): [True: 1.00M, False: 158k]
  ------------------
   42|       |        // Performance note: our ability to compute 'consumed' and
   43|       |        // then shift and recompute is critical. If there is a
   44|       |        // latency of, say, 4 cycles on getting 'consumed', then
   45|       |        // the inner loop might have a total latency of about 6 cycles.
   46|       |        // Yet we process between 6 to 12 inputs bytes, thus we get
   47|       |        // a speed limit between 1 cycle/byte and 0.5 cycle/byte
   48|       |        // for this section of the code. Hence, there is a limit
   49|       |        // to how much we can further increase this latency before
   50|       |        // it seriously harms performance.
   51|       |        //
   52|       |        // Thus we may allow convert_masked_utf8_to_utf16 to process
   53|       |        // more bytes at a time under a fast-path mode where 16 bytes
   54|       |        // are consumed at once (e.g., when encountering ASCII).
   55|  1.00M|        size_t consumed = convert_masked_utf8_to_utf16<endian>(
   56|  1.00M|            input + pos, utf8_end_of_code_point_mask, utf16_output);
   57|  1.00M|        pos += consumed;
   58|  1.00M|        utf8_end_of_code_point_mask >>= consumed;
   59|  1.00M|      }
   60|       |      // At this point there may remain between 0 and 12 bytes in the
   61|       |      // 64-byte block. These bytes will be processed again. So we have an
   62|       |      // 80% efficiency (in the worst case). In practice we expect an
   63|       |      // 85% to 90% efficiency.
   64|   158k|    }
   65|   638k|  }
   66|    528|  const size_t ascii = validating_transcoder::convert_ascii_tail<endian>(
   67|    528|      input, pos, size, utf16_output);
   68|    528|  pos += ascii;
   69|    528|  utf16_output += ascii;
   70|    528|  if (pos == size) {
  ------------------
  |  Branch (70:7): [True: 94, False: 434]
  ------------------
   71|     94|    return utf16_output - start;
   72|     94|  }
   73|    434|  utf16_output += scalar::utf8_to_utf16::convert_valid<endian>(
   74|    434|      input + pos, size - pos, utf16_output);
   75|    434|  return utf16_output - start;
   76|    528|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf1613convert_validILNS_10endiannessE1EEEmPKcmPDs:
   10|    772|                                         char16_t *utf16_output) noexcept {
   11|       |  // The implementation is not specific to haswell and should be moved to the
   12|       |  // generic directory.
   13|    772|  size_t pos = 0;
   14|    772|  char16_t *start{utf16_output};
   15|    772|  const size_t safety_margin = 16; // to avoid overruns!
   16|   752k|  while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (16:10): [True: 752k, False: 772]
  ------------------
   17|       |    // this loop could be unrolled further. For example, we could process the
   18|       |    // mask far more than 64 bytes.
   19|   752k|    simd8x64<int8_t> in(reinterpret_cast<const int8_t *>(input + pos));
   20|   752k|    if (in.is_ascii()) {
  ------------------
  |  Branch (20:9): [True: 636k, False: 115k]
  ------------------
   21|   636k|      in.store_ascii_as_utf16<endian>(utf16_output);
   22|   636k|      utf16_output += 64;
   23|   636k|      pos += 64;
   24|   636k|    } else {
   25|       |      // Slow path. We hope that the compiler will recognize that this is a slow
   26|       |      // path. Anything that is not a continuation mask is a 'leading byte',
   27|       |      // that is, the start of a new code point.
   28|   115k|      uint64_t utf8_continuation_mask = in.lt(-65 + 1);
   29|       |      // -65 is 0b10111111 in two-complement's, so largest possible continuation
   30|       |      // byte
   31|   115k|      uint64_t utf8_leading_mask = ~utf8_continuation_mask;
   32|       |      // The *start* of code points is not so useful, rather, we want the *end*
   33|       |      // of code points.
   34|   115k|      uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
   35|       |      // We process in blocks of up to 12 bytes except possibly
   36|       |      // for fast paths which may process up to 16 bytes. For the
   37|       |      // slow path to work, we should have at least 12 input bytes left.
   38|   115k|      size_t max_starting_point = (pos + 64) - 12;
   39|       |      // Next loop is going to run at least five times when using solely
   40|       |      // the slow/regular path, and at least four times if there are fast paths.
   41|   814k|      while (pos < max_starting_point) {
  ------------------
  |  Branch (41:14): [True: 699k, False: 115k]
  ------------------
   42|       |        // Performance note: our ability to compute 'consumed' and
   43|       |        // then shift and recompute is critical. If there is a
   44|       |        // latency of, say, 4 cycles on getting 'consumed', then
   45|       |        // the inner loop might have a total latency of about 6 cycles.
   46|       |        // Yet we process between 6 to 12 inputs bytes, thus we get
   47|       |        // a speed limit between 1 cycle/byte and 0.5 cycle/byte
   48|       |        // for this section of the code. Hence, there is a limit
   49|       |        // to how much we can further increase this latency before
   50|       |        // it seriously harms performance.
   51|       |        //
   52|       |        // Thus we may allow convert_masked_utf8_to_utf16 to process
   53|       |        // more bytes at a time under a fast-path mode where 16 bytes
   54|       |        // are consumed at once (e.g., when encountering ASCII).
   55|   699k|        size_t consumed = convert_masked_utf8_to_utf16<endian>(
   56|   699k|            input + pos, utf8_end_of_code_point_mask, utf16_output);
   57|   699k|        pos += consumed;
   58|   699k|        utf8_end_of_code_point_mask >>= consumed;
   59|   699k|      }
   60|       |      // At this point there may remain between 0 and 12 bytes in the
   61|       |      // 64-byte block. These bytes will be processed again. So we have an
   62|       |      // 80% efficiency (in the worst case). In practice we expect an
   63|       |      // 85% to 90% efficiency.
   64|   115k|    }
   65|   752k|  }
   66|    772|  const size_t ascii = validating_transcoder::convert_ascii_tail<endian>(
   67|    772|      input, pos, size, utf16_output);
   68|    772|  pos += ascii;
   69|    772|  utf16_output += ascii;
   70|    772|  if (pos == size) {
  ------------------
  |  Branch (70:7): [True: 152, False: 620]
  ------------------
   71|    152|    return utf16_output - start;
   72|    152|  }
   73|    620|  utf16_output += scalar::utf8_to_utf16::convert_valid<endian>(
   74|    620|      input + pos, size - pos, utf16_output);
   75|    620|  return utf16_output - start;
   76|    772|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1613convert_validILNS_10endiannessE0EEEmPKcmPDs:
   10|    528|                                         char16_t *utf16_output) noexcept {
   11|       |  // The implementation is not specific to haswell and should be moved to the
   12|       |  // generic directory.
   13|    528|  size_t pos = 0;
   14|    528|  char16_t *start{utf16_output};
   15|    528|  const size_t safety_margin = 16; // to avoid overruns!
   16|   639k|  while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (16:10): [True: 638k, False: 528]
  ------------------
   17|       |    // this loop could be unrolled further. For example, we could process the
   18|       |    // mask far more than 64 bytes.
   19|   638k|    simd8x64<int8_t> in(reinterpret_cast<const int8_t *>(input + pos));
   20|   638k|    if (in.is_ascii()) {
  ------------------
  |  Branch (20:9): [True: 479k, False: 158k]
  ------------------
   21|   479k|      in.store_ascii_as_utf16<endian>(utf16_output);
   22|   479k|      utf16_output += 64;
   23|   479k|      pos += 64;
   24|   479k|    } else {
   25|       |      // Slow path. We hope that the compiler will recognize that this is a slow
   26|       |      // path. Anything that is not a continuation mask is a 'leading byte',
   27|       |      // that is, the start of a new code point.
   28|   158k|      uint64_t utf8_continuation_mask = in.lt(-65 + 1);
   29|       |      // -65 is 0b10111111 in two-complement's, so largest possible continuation
   30|       |      // byte
   31|   158k|      uint64_t utf8_leading_mask = ~utf8_continuation_mask;
   32|       |      // The *start* of code points is not so useful, rather, we want the *end*
   33|       |      // of code points.
   34|   158k|      uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
   35|       |      // We process in blocks of up to 12 bytes except possibly
   36|       |      // for fast paths which may process up to 16 bytes. For the
   37|       |      // slow path to work, we should have at least 12 input bytes left.
   38|   158k|      size_t max_starting_point = (pos + 64) - 12;
   39|       |      // Next loop is going to run at least five times when using solely
   40|       |      // the slow/regular path, and at least four times if there are fast paths.
   41|  1.16M|      while (pos < max_starting_point) {
  ------------------
  |  Branch (41:14): [True: 1.00M, False: 158k]
  ------------------
   42|       |        // Performance note: our ability to compute 'consumed' and
   43|       |        // then shift and recompute is critical. If there is a
   44|       |        // latency of, say, 4 cycles on getting 'consumed', then
   45|       |        // the inner loop might have a total latency of about 6 cycles.
   46|       |        // Yet we process between 6 to 12 inputs bytes, thus we get
   47|       |        // a speed limit between 1 cycle/byte and 0.5 cycle/byte
   48|       |        // for this section of the code. Hence, there is a limit
   49|       |        // to how much we can further increase this latency before
   50|       |        // it seriously harms performance.
   51|       |        //
   52|       |        // Thus we may allow convert_masked_utf8_to_utf16 to process
   53|       |        // more bytes at a time under a fast-path mode where 16 bytes
   54|       |        // are consumed at once (e.g., when encountering ASCII).
   55|  1.00M|        size_t consumed = convert_masked_utf8_to_utf16<endian>(
   56|  1.00M|            input + pos, utf8_end_of_code_point_mask, utf16_output);
   57|  1.00M|        pos += consumed;
   58|  1.00M|        utf8_end_of_code_point_mask >>= consumed;
   59|  1.00M|      }
   60|       |      // At this point there may remain between 0 and 12 bytes in the
   61|       |      // 64-byte block. These bytes will be processed again. So we have an
   62|       |      // 80% efficiency (in the worst case). In practice we expect an
   63|       |      // 85% to 90% efficiency.
   64|   158k|    }
   65|   638k|  }
   66|    528|  const size_t ascii = validating_transcoder::convert_ascii_tail<endian>(
   67|    528|      input, pos, size, utf16_output);
   68|    528|  pos += ascii;
   69|    528|  utf16_output += ascii;
   70|    528|  if (pos == size) {
  ------------------
  |  Branch (70:7): [True: 94, False: 434]
  ------------------
   71|     94|    return utf16_output - start;
   72|     94|  }
   73|    434|  utf16_output += scalar::utf8_to_utf16::convert_valid<endian>(
   74|    434|      input + pos, size - pos, utf16_output);
   75|    434|  return utf16_output - start;
   76|    528|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf1613convert_validILNS_10endiannessE1EEEmPKcmPDs:
   10|    772|                                         char16_t *utf16_output) noexcept {
   11|       |  // The implementation is not specific to haswell and should be moved to the
   12|       |  // generic directory.
   13|    772|  size_t pos = 0;
   14|    772|  char16_t *start{utf16_output};
   15|    772|  const size_t safety_margin = 16; // to avoid overruns!
   16|   752k|  while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (16:10): [True: 752k, False: 772]
  ------------------
   17|       |    // this loop could be unrolled further. For example, we could process the
   18|       |    // mask far more than 64 bytes.
   19|   752k|    simd8x64<int8_t> in(reinterpret_cast<const int8_t *>(input + pos));
   20|   752k|    if (in.is_ascii()) {
  ------------------
  |  Branch (20:9): [True: 636k, False: 115k]
  ------------------
   21|   636k|      in.store_ascii_as_utf16<endian>(utf16_output);
   22|   636k|      utf16_output += 64;
   23|   636k|      pos += 64;
   24|   636k|    } else {
   25|       |      // Slow path. We hope that the compiler will recognize that this is a slow
   26|       |      // path. Anything that is not a continuation mask is a 'leading byte',
   27|       |      // that is, the start of a new code point.
   28|   115k|      uint64_t utf8_continuation_mask = in.lt(-65 + 1);
   29|       |      // -65 is 0b10111111 in two-complement's, so largest possible continuation
   30|       |      // byte
   31|   115k|      uint64_t utf8_leading_mask = ~utf8_continuation_mask;
   32|       |      // The *start* of code points is not so useful, rather, we want the *end*
   33|       |      // of code points.
   34|   115k|      uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
   35|       |      // We process in blocks of up to 12 bytes except possibly
   36|       |      // for fast paths which may process up to 16 bytes. For the
   37|       |      // slow path to work, we should have at least 12 input bytes left.
   38|   115k|      size_t max_starting_point = (pos + 64) - 12;
   39|       |      // Next loop is going to run at least five times when using solely
   40|       |      // the slow/regular path, and at least four times if there are fast paths.
   41|   814k|      while (pos < max_starting_point) {
  ------------------
  |  Branch (41:14): [True: 699k, False: 115k]
  ------------------
   42|       |        // Performance note: our ability to compute 'consumed' and
   43|       |        // then shift and recompute is critical. If there is a
   44|       |        // latency of, say, 4 cycles on getting 'consumed', then
   45|       |        // the inner loop might have a total latency of about 6 cycles.
   46|       |        // Yet we process between 6 to 12 inputs bytes, thus we get
   47|       |        // a speed limit between 1 cycle/byte and 0.5 cycle/byte
   48|       |        // for this section of the code. Hence, there is a limit
   49|       |        // to how much we can further increase this latency before
   50|       |        // it seriously harms performance.
   51|       |        //
   52|       |        // Thus we may allow convert_masked_utf8_to_utf16 to process
   53|       |        // more bytes at a time under a fast-path mode where 16 bytes
   54|       |        // are consumed at once (e.g., when encountering ASCII).
   55|   699k|        size_t consumed = convert_masked_utf8_to_utf16<endian>(
   56|   699k|            input + pos, utf8_end_of_code_point_mask, utf16_output);
   57|   699k|        pos += consumed;
   58|   699k|        utf8_end_of_code_point_mask >>= consumed;
   59|   699k|      }
   60|       |      // At this point there may remain between 0 and 12 bytes in the
   61|       |      // 64-byte block. These bytes will be processed again. So we have an
   62|       |      // 80% efficiency (in the worst case). In practice we expect an
   63|       |      // 85% to 90% efficiency.
   64|   115k|    }
   65|   752k|  }
   66|    772|  const size_t ascii = validating_transcoder::convert_ascii_tail<endian>(
   67|    772|      input, pos, size, utf16_output);
   68|    772|  pos += ascii;
   69|    772|  utf16_output += ascii;
   70|    772|  if (pos == size) {
  ------------------
  |  Branch (70:7): [True: 152, False: 620]
  ------------------
   71|    152|    return utf16_output - start;
   72|    152|  }
   73|    620|  utf16_output += scalar::utf8_to_utf16::convert_valid<endian>(
   74|    620|      input + pos, size - pos, utf16_output);
   75|    620|  return utf16_output - start;
   76|    772|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3221validating_transcoderC2Ev:
  114|  1.86k|  validating_transcoder() : error(uint8_t(0)) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3221validating_transcoder7convertEPKcmPDi:
  162|    920|                                       char32_t *utf32_output) {
  163|    920|    if (size < 64) { // too short for the main loop
  ------------------
  |  Branch (163:9): [True: 282, False: 638]
  ------------------
  164|    282|      return scalar::utf8_to_utf32::convert(in, size, utf32_output);
  165|    282|    }
  166|    638|    size_t pos = 0;
  167|    638|    char32_t *start{utf32_output};
  168|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  169|       |    // of 4 words when calling convert_masked_utf8_to_utf32. If you skip the
  170|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  171|       |    // 16 UTF-8 bytes generate at least 4 words. However, you cannot
  172|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  173|       |    // back from the end counting 8 leading bytes, to give us a good margin.
  174|    638|    size_t leading_byte = 0;
  175|    638|    size_t margin = size;
  176|  10.3k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (176:12): [True: 10.3k, False: 18]
  |  Branch (176:26): [True: 9.75k, False: 620]
  ------------------
  177|  9.75k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  178|  9.75k|    }
  179|       |    // If the input is long enough, then we have that margin is the eighth
  180|       |    // last leading byte.
  181|    638|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  182|   468k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (182:12): [True: 468k, False: 518]
  ------------------
  183|   468k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  184|   468k|      if (input.is_ascii()) {
  ------------------
  |  Branch (184:11): [True: 410k, False: 57.5k]
  ------------------
  185|   410k|        input.store_ascii_as_utf32(utf32_output);
  186|   410k|        utf32_output += 64;
  187|   410k|        pos += 64;
  188|   410k|        if ((pos & 1023) < 64 && errors()) {
  ------------------
  |  Branch (188:13): [True: 25.5k, False: 385k]
  |  Branch (188:34): [True: 10, False: 25.5k]
  ------------------
  189|     10|          return 0;
  190|     10|        }
  191|   410k|      } else {
  192|       |        // you might think that a for-loop would work, but under Visual Studio,
  193|       |        // it is not good enough.
  194|  57.5k|        static_assert(
  195|  57.5k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  196|  57.5k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  197|  57.5k|            "We support either two or four chunks per 64-byte block.");
  198|  57.5k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  199|  57.5k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  200|  57.5k|          this->check_utf8_bytes(input.chunks[0], zero);
  201|  57.5k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  202|       |        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  203|       |          this->check_utf8_bytes(input.chunks[0], zero);
  204|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  205|       |          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  206|       |          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  207|       |        }
  208|  57.5k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  209|  57.5k|        if ((utf8_continuation_mask & 1) || ((pos & 1023) < 64 && errors())) {
  ------------------
  |  Branch (209:13): [True: 6, False: 57.5k]
  |  Branch (209:46): [True: 3.95k, False: 53.5k]
  |  Branch (209:67): [True: 104, False: 3.84k]
  ------------------
  210|    110|          return 0; // we have an error
  211|    110|        }
  212|  57.4k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  213|  57.4k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  214|       |        // We process in blocks of up to 12 bytes except possibly
  215|       |        // for fast paths which may process up to 16 bytes. For the
  216|       |        // slow path to work, we should have at least 12 input bytes left.
  217|  57.4k|        size_t max_starting_point = (pos + 64) - 12;
  218|       |        // Next loop is going to run at least five times.
  219|   413k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (219:16): [True: 356k, False: 57.4k]
  ------------------
  220|       |          // Performance note: our ability to compute 'consumed' and
  221|       |          // then shift and recompute is critical. If there is a
  222|       |          // latency of, say, 4 cycles on getting 'consumed', then
  223|       |          // the inner loop might have a total latency of about 6 cycles.
  224|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  225|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  226|       |          // for this section of the code. Hence, there is a limit
  227|       |          // to how much we can further increase this latency before
  228|       |          // it seriously harms performance.
  229|   356k|          size_t consumed = convert_masked_utf8_to_utf32(
  230|   356k|              in + pos, utf8_end_of_code_point_mask, utf32_output);
  231|   356k|          pos += consumed;
  232|   356k|          utf8_end_of_code_point_mask >>= consumed;
  233|   356k|        }
  234|       |        // At this point there may remain between 0 and 12 bytes in the
  235|       |        // 64-byte block. These bytes will be processed again. So we have an
  236|       |        // 80% efficiency (in the worst case). In practice we expect an
  237|       |        // 85% to 90% efficiency.
  238|  57.4k|      }
  239|   468k|    }
  240|    518|    if (errors()) {
  ------------------
  |  Branch (240:9): [True: 68, False: 450]
  ------------------
  241|     68|      return 0;
  242|     68|    }
  243|    450|    const size_t ascii = convert_ascii_tail(in, pos, size, utf32_output);
  244|    450|    pos += ascii;
  245|    450|    utf32_output += ascii;
  246|    450|    if (pos == size) {
  ------------------
  |  Branch (246:9): [True: 82, False: 368]
  ------------------
  247|     82|      return utf32_output - start;
  248|     82|    }
  249|    368|    SIMDUTF_VZEROUPPER();
  ------------------
  |  |   22|    368|#define SIMDUTF_VZEROUPPER() _mm256_zeroupper()
  ------------------
  250|    368|    size_t howmany =
  251|    368|        scalar::utf8_to_utf32::convert(in + pos, size - pos, utf32_output);
  252|    368|    if (howmany == 0) {
  ------------------
  |  Branch (252:9): [True: 286, False: 82]
  ------------------
  253|    286|      return 0;
  254|    286|    }
  255|     82|    return utf32_output + howmany - start;
  256|    368|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3221validating_transcoder6errorsEv:
  359|   134k|  simdutf_really_inline bool errors() const {
  360|   134k|    return this->error.any_bits_set_anywhere();
  361|   134k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3221validating_transcoder16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  119|   323k|                                              const simd8<uint8_t> prev_input) {
  120|       |    // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+
  121|       |    // lead bytes (2, 3, 4-byte leads become large positive numbers instead of
  122|       |    // small negative numbers)
  123|   323k|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  124|   323k|    simd8<uint8_t> sc = check_special_cases(input, prev1);
  125|   323k|    this->error |= check_multibyte_lengths(input, prev_input, sc);
  126|   323k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3219check_special_casesENS1_4simd5simd8IhEES5_:
    8|   323k|check_special_cases(const simd8<uint8_t> input, const simd8<uint8_t> prev1) {
    9|       |  // Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII)
   10|       |  // Bit 1 = Too Long (ASCII followed by continuation)
   11|       |  // Bit 2 = Overlong 3-byte
   12|       |  // Bit 4 = Surrogate
   13|       |  // Bit 5 = Overlong 2-byte
   14|       |  // Bit 7 = Two Continuations
   15|   323k|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   16|       |                                               // 11______ 11______
   17|   323k|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   18|   323k|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   19|   323k|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   20|   323k|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   21|   323k|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   22|   323k|  constexpr const uint8_t TOO_LARGE = 1 << 3;  // 11110100 1001____
   23|       |                                               // 11110100 101_____
   24|       |                                               // 11110101 1001____
   25|       |                                               // 11110101 101_____
   26|       |                                               // 1111011_ 1001____
   27|       |                                               // 1111011_ 101_____
   28|       |                                               // 11111___ 1001____
   29|       |                                               // 11111___ 101_____
   30|   323k|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   31|       |  // 11110101 1000____
   32|       |  // 1111011_ 1000____
   33|       |  // 11111___ 1000____
   34|   323k|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   35|       |
   36|   323k|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   37|       |      // 0_______ ________ <ASCII in byte 1>
   38|   323k|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   39|   323k|      TOO_LONG,
   40|       |      // 10______ ________ <continuation in byte 1>
   41|   323k|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   42|       |      // 1100____ ________ <two byte lead in byte 1>
   43|   323k|      TOO_SHORT | OVERLONG_2,
   44|       |      // 1101____ ________ <two byte lead in byte 1>
   45|   323k|      TOO_SHORT,
   46|       |      // 1110____ ________ <three byte lead in byte 1>
   47|   323k|      TOO_SHORT | OVERLONG_3 | SURROGATE,
   48|       |      // 1111____ ________ <four+ byte lead in byte 1>
   49|   323k|      TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4);
   50|   323k|  constexpr const uint8_t CARRY =
   51|   323k|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   52|   323k|  const simd8<uint8_t> byte_1_low =
   53|   323k|      (prev1 & 0x0F)
   54|   323k|          .lookup_16<uint8_t>(
   55|       |              // ____0000 ________
   56|   323k|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   57|       |              // ____0001 ________
   58|   323k|              CARRY | OVERLONG_2,
   59|       |              // ____001_ ________
   60|   323k|              CARRY, CARRY,
   61|       |
   62|       |              // ____0100 ________
   63|   323k|              CARRY | TOO_LARGE,
   64|       |              // ____0101 ________
   65|   323k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   66|       |              // ____011_ ________
   67|   323k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   68|   323k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   69|       |
   70|       |              // ____1___ ________
   71|   323k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   72|   323k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   73|   323k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   74|   323k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   75|   323k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   76|       |              // ____1101 ________
   77|   323k|              CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE,
   78|   323k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   79|   323k|              CARRY | TOO_LARGE | TOO_LARGE_1000);
   80|   323k|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   81|       |      // ________ 0_______ <ASCII in byte 2>
   82|   323k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   83|   323k|      TOO_SHORT, TOO_SHORT,
   84|       |
   85|       |      // ________ 1000____
   86|   323k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
   87|   323k|          OVERLONG_4,
   88|       |      // ________ 1001____
   89|   323k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
   90|       |      // ________ 101_____
   91|   323k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   92|   323k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   93|       |
   94|       |      // ________ 11______
   95|   323k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
   96|   323k|  return (byte_1_high & byte_1_low & byte_2_high);
   97|   323k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3223check_multibyte_lengthsENS1_4simd5simd8IhEES5_S5_:
  101|   323k|                        const simd8<uint8_t> sc) {
  102|   323k|  simd8<uint8_t> prev2 = input.prev<2>(prev_input);
  103|   323k|  simd8<uint8_t> prev3 = input.prev<3>(prev_input);
  104|   323k|  simd8<uint8_t> must23 =
  105|   323k|      simd8<uint8_t>(must_be_2_3_continuation(prev2, prev3));
  106|   323k|  simd8<uint8_t> must23_80 = must23 & uint8_t(0x80);
  107|   323k|  return must23_80 ^ sc;
  108|   323k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3221validating_transcoder18convert_ascii_tailEPKcmmPDi:
  131|  1.64k|                                                         char32_t *output) {
  132|       |    // A cheap test on the first bytes avoids any SIMD work for most non-ASCII
  133|       |    // tails.
  134|  1.64k|    if (size - pos >= 8) {
  ------------------
  |  Branch (134:9): [True: 1.59k, False: 50]
  ------------------
  135|  1.59k|      uint64_t first_bytes;
  136|  1.59k|      std::memcpy(&first_bytes, in + pos, 8);
  137|  1.59k|      if (first_bytes & 0x8080808080808080) {
  ------------------
  |  Branch (137:11): [True: 386, False: 1.20k]
  ------------------
  138|    386|        return 0;
  139|    386|      }
  140|  1.59k|    }
  141|  1.25k|    const size_t start = pos;
  142|  1.41k|    while (pos + 64 <= size) {
  ------------------
  |  Branch (142:12): [True: 528, False: 886]
  ------------------
  143|    528|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  144|    528|      if (!input.is_ascii()) {
  ------------------
  |  Branch (144:11): [True: 368, False: 160]
  ------------------
  145|    368|        return pos - start;
  146|    368|      }
  147|    160|      input.store_ascii_as_utf32(output + (pos - start));
  148|    160|      pos += 64;
  149|    160|    }
  150|    886|    if (pos == size || size < 64) {
  ------------------
  |  Branch (150:9): [True: 48, False: 838]
  |  Branch (150:24): [True: 88, False: 750]
  ------------------
  151|    136|      return pos - start;
  152|    136|    }
  153|    750|    simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + size - 64));
  154|    750|    if (!input.is_ascii()) {
  ------------------
  |  Branch (154:9): [True: 520, False: 230]
  ------------------
  155|    520|      return pos - start;
  156|    520|    }
  157|    230|    input.store_ascii_as_utf32(output + (pos - start) - (pos - (size - 64)));
  158|    230|    return size - start;
  159|    750|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3221validating_transcoder19convert_with_errorsEPKcmPDi:
  259|    946|                                                   char32_t *utf32_output) {
  260|    946|    if (size < 64) { // too short for the main loop
  ------------------
  |  Branch (260:9): [True: 280, False: 666]
  ------------------
  261|    280|      return scalar::utf8_to_utf32::convert_with_errors(in, size, utf32_output);
  262|    280|    }
  263|    666|    size_t pos = 0;
  264|    666|    char32_t *start{utf32_output};
  265|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  266|       |    // of 4 words when calling convert_masked_utf8_to_utf32. If you skip the
  267|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  268|       |    // 16 UTF-8 bytes generate at least 4 words. However, you cannot
  269|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  270|       |    // back from the end counting 8 leading bytes, to give us a good margin.
  271|    666|    size_t leading_byte = 0;
  272|    666|    size_t margin = size;
  273|  41.8k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (273:12): [True: 41.8k, False: 14]
  |  Branch (273:26): [True: 41.1k, False: 652]
  ------------------
  274|  41.1k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  275|  41.1k|    }
  276|       |    // If the input is long enough, then we have that margin is the eighth
  277|       |    // last leading byte.
  278|    666|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  279|   601k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (279:12): [True: 600k, False: 562]
  ------------------
  280|   600k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  281|   600k|      if (input.is_ascii()) {
  ------------------
  |  Branch (281:11): [True: 496k, False: 104k]
  ------------------
  282|   496k|        input.store_ascii_as_utf32(utf32_output);
  283|   496k|        utf32_output += 64;
  284|   496k|        pos += 64;
  285|   496k|      } else {
  286|       |        // you might think that a for-loop would work, but under Visual Studio,
  287|       |        // it is not good enough.
  288|   104k|        static_assert(
  289|   104k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  290|   104k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  291|   104k|            "We support either two or four chunks per 64-byte block.");
  292|   104k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  293|   104k|        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  294|   104k|          this->check_utf8_bytes(input.chunks[0], zero);
  295|   104k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  296|       |        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  297|       |          this->check_utf8_bytes(input.chunks[0], zero);
  298|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  299|       |          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  300|       |          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  301|       |        }
  302|   104k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  303|   104k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (303:13): [True: 104, False: 104k]
  |  Branch (303:25): [True: 0, False: 104k]
  ------------------
  304|    104|          SIMDUTF_VZEROUPPER();
  ------------------
  |  |   22|    104|#define SIMDUTF_VZEROUPPER() _mm256_zeroupper()
  ------------------
  305|    104|          result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(
  306|    104|              pos, in + pos, size - pos, utf32_output);
  307|    104|          res.count += pos;
  308|    104|          return res;
  309|    104|        }
  310|   104k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  311|   104k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  312|       |        // We process in blocks of up to 12 bytes except possibly
  313|       |        // for fast paths which may process up to 16 bytes. For the
  314|       |        // slow path to work, we should have at least 12 input bytes left.
  315|   104k|        size_t max_starting_point = (pos + 64) - 12;
  316|       |        // Next loop is going to run at least five times.
  317|   750k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (317:16): [True: 646k, False: 104k]
  ------------------
  318|       |          // Performance note: our ability to compute 'consumed' and
  319|       |          // then shift and recompute is critical. If there is a
  320|       |          // latency of, say, 4 cycles on getting 'consumed', then
  321|       |          // the inner loop might have a total latency of about 6 cycles.
  322|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  323|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  324|       |          // for this section of the code. Hence, there is a limit
  325|       |          // to how much we can further increase this latency before
  326|       |          // it seriously harms performance.
  327|   646k|          size_t consumed = convert_masked_utf8_to_utf32(
  328|   646k|              in + pos, utf8_end_of_code_point_mask, utf32_output);
  329|   646k|          pos += consumed;
  330|   646k|          utf8_end_of_code_point_mask >>= consumed;
  331|   646k|        }
  332|       |        // At this point there may remain between 0 and 12 bytes in the
  333|       |        // 64-byte block. These bytes will be processed again. So we have an
  334|       |        // 80% efficiency (in the worst case). In practice we expect an
  335|       |        // 85% to 90% efficiency.
  336|   104k|      }
  337|   600k|    }
  338|    562|    const size_t ascii = convert_ascii_tail(in, pos, size, utf32_output);
  339|    562|    pos += ascii;
  340|    562|    utf32_output += ascii;
  341|    562|    if (pos == size) {
  ------------------
  |  Branch (341:9): [True: 90, False: 472]
  ------------------
  342|     90|      return result(error_code::SUCCESS, utf32_output - start);
  343|     90|    }
  344|       |    // rewind_and_convert_with_errors will seek a potential error from in+pos
  345|       |    // onward, with the ability to go back up to pos bytes, and read size-pos
  346|       |    // bytes forward.
  347|    472|    SIMDUTF_VZEROUPPER();
  ------------------
  |  |   22|    472|#define SIMDUTF_VZEROUPPER() _mm256_zeroupper()
  ------------------
  348|    472|    result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(
  349|    472|        pos, in + pos, size - pos, utf32_output);
  350|    472|    if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (350:9): [True: 338, False: 134]
  ------------------
  351|    338|      res.count += pos;
  352|    338|      return res;
  353|    338|    }
  354|       |    // In case of success, we want the number of words written
  355|    134|    utf32_output += res.count;
  356|    134|    return result(error_code::SUCCESS, utf32_output - start);
  357|    472|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3221validating_transcoderC2Ev:
  114|  1.86k|  validating_transcoder() : error(uint8_t(0)) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3221validating_transcoder7convertEPKcmPDi:
  162|    920|                                       char32_t *utf32_output) {
  163|    920|    if (size < 64) { // too short for the main loop
  ------------------
  |  Branch (163:9): [True: 282, False: 638]
  ------------------
  164|    282|      return scalar::utf8_to_utf32::convert(in, size, utf32_output);
  165|    282|    }
  166|    638|    size_t pos = 0;
  167|    638|    char32_t *start{utf32_output};
  168|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  169|       |    // of 4 words when calling convert_masked_utf8_to_utf32. If you skip the
  170|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  171|       |    // 16 UTF-8 bytes generate at least 4 words. However, you cannot
  172|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  173|       |    // back from the end counting 8 leading bytes, to give us a good margin.
  174|    638|    size_t leading_byte = 0;
  175|    638|    size_t margin = size;
  176|  10.3k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (176:12): [True: 10.3k, False: 18]
  |  Branch (176:26): [True: 9.75k, False: 620]
  ------------------
  177|  9.75k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  178|  9.75k|    }
  179|       |    // If the input is long enough, then we have that margin is the eighth
  180|       |    // last leading byte.
  181|    638|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  182|   468k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (182:12): [True: 468k, False: 518]
  ------------------
  183|   468k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  184|   468k|      if (input.is_ascii()) {
  ------------------
  |  Branch (184:11): [True: 410k, False: 57.5k]
  ------------------
  185|   410k|        input.store_ascii_as_utf32(utf32_output);
  186|   410k|        utf32_output += 64;
  187|   410k|        pos += 64;
  188|   410k|        if ((pos & 1023) < 64 && errors()) {
  ------------------
  |  Branch (188:13): [True: 25.5k, False: 385k]
  |  Branch (188:34): [True: 10, False: 25.5k]
  ------------------
  189|     10|          return 0;
  190|     10|        }
  191|   410k|      } else {
  192|       |        // you might think that a for-loop would work, but under Visual Studio,
  193|       |        // it is not good enough.
  194|  57.5k|        static_assert(
  195|  57.5k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  196|  57.5k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  197|  57.5k|            "We support either two or four chunks per 64-byte block.");
  198|  57.5k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  199|       |        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  200|       |          this->check_utf8_bytes(input.chunks[0], zero);
  201|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  202|  57.5k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  203|  57.5k|          this->check_utf8_bytes(input.chunks[0], zero);
  204|  57.5k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  205|  57.5k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  206|  57.5k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  207|  57.5k|        }
  208|  57.5k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  209|  57.5k|        if ((utf8_continuation_mask & 1) || ((pos & 1023) < 64 && errors())) {
  ------------------
  |  Branch (209:13): [True: 6, False: 57.5k]
  |  Branch (209:46): [True: 3.95k, False: 53.5k]
  |  Branch (209:67): [True: 104, False: 3.84k]
  ------------------
  210|    110|          return 0; // we have an error
  211|    110|        }
  212|  57.4k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  213|  57.4k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  214|       |        // We process in blocks of up to 12 bytes except possibly
  215|       |        // for fast paths which may process up to 16 bytes. For the
  216|       |        // slow path to work, we should have at least 12 input bytes left.
  217|  57.4k|        size_t max_starting_point = (pos + 64) - 12;
  218|       |        // Next loop is going to run at least five times.
  219|   413k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (219:16): [True: 356k, False: 57.4k]
  ------------------
  220|       |          // Performance note: our ability to compute 'consumed' and
  221|       |          // then shift and recompute is critical. If there is a
  222|       |          // latency of, say, 4 cycles on getting 'consumed', then
  223|       |          // the inner loop might have a total latency of about 6 cycles.
  224|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  225|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  226|       |          // for this section of the code. Hence, there is a limit
  227|       |          // to how much we can further increase this latency before
  228|       |          // it seriously harms performance.
  229|   356k|          size_t consumed = convert_masked_utf8_to_utf32(
  230|   356k|              in + pos, utf8_end_of_code_point_mask, utf32_output);
  231|   356k|          pos += consumed;
  232|   356k|          utf8_end_of_code_point_mask >>= consumed;
  233|   356k|        }
  234|       |        // At this point there may remain between 0 and 12 bytes in the
  235|       |        // 64-byte block. These bytes will be processed again. So we have an
  236|       |        // 80% efficiency (in the worst case). In practice we expect an
  237|       |        // 85% to 90% efficiency.
  238|  57.4k|      }
  239|   468k|    }
  240|    518|    if (errors()) {
  ------------------
  |  Branch (240:9): [True: 68, False: 450]
  ------------------
  241|     68|      return 0;
  242|     68|    }
  243|    450|    const size_t ascii = convert_ascii_tail(in, pos, size, utf32_output);
  244|    450|    pos += ascii;
  245|    450|    utf32_output += ascii;
  246|    450|    if (pos == size) {
  ------------------
  |  Branch (246:9): [True: 82, False: 368]
  ------------------
  247|     82|      return utf32_output - start;
  248|     82|    }
  249|    368|    SIMDUTF_VZEROUPPER();
  ------------------
  |  |   16|    368|#define SIMDUTF_VZEROUPPER() (void)0
  ------------------
  250|    368|    size_t howmany =
  251|    368|        scalar::utf8_to_utf32::convert(in + pos, size - pos, utf32_output);
  252|    368|    if (howmany == 0) {
  ------------------
  |  Branch (252:9): [True: 286, False: 82]
  ------------------
  253|    286|      return 0;
  254|    286|    }
  255|     82|    return utf32_output + howmany - start;
  256|    368|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3221validating_transcoder6errorsEv:
  359|   134k|  simdutf_really_inline bool errors() const {
  360|   134k|    return this->error.any_bits_set_anywhere();
  361|   134k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3221validating_transcoder16check_utf8_bytesENS1_4simd5simd8IhEES6_:
  119|   646k|                                              const simd8<uint8_t> prev_input) {
  120|       |    // Flip prev1...prev3 so we can easily determine if they are 2+, 3+ or 4+
  121|       |    // lead bytes (2, 3, 4-byte leads become large positive numbers instead of
  122|       |    // small negative numbers)
  123|   646k|    simd8<uint8_t> prev1 = input.prev<1>(prev_input);
  124|   646k|    simd8<uint8_t> sc = check_special_cases(input, prev1);
  125|   646k|    this->error |= check_multibyte_lengths(input, prev_input, sc);
  126|   646k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3219check_special_casesENS1_4simd5simd8IhEES5_:
    8|   646k|check_special_cases(const simd8<uint8_t> input, const simd8<uint8_t> prev1) {
    9|       |  // Bit 0 = Too Short (lead byte/ASCII followed by lead byte/ASCII)
   10|       |  // Bit 1 = Too Long (ASCII followed by continuation)
   11|       |  // Bit 2 = Overlong 3-byte
   12|       |  // Bit 4 = Surrogate
   13|       |  // Bit 5 = Overlong 2-byte
   14|       |  // Bit 7 = Two Continuations
   15|   646k|  constexpr const uint8_t TOO_SHORT = 1 << 0;  // 11______ 0_______
   16|       |                                               // 11______ 11______
   17|   646k|  constexpr const uint8_t TOO_LONG = 1 << 1;   // 0_______ 10______
   18|   646k|  constexpr const uint8_t OVERLONG_3 = 1 << 2; // 11100000 100_____
   19|   646k|  constexpr const uint8_t SURROGATE = 1 << 4;  // 11101101 101_____
   20|   646k|  constexpr const uint8_t OVERLONG_2 = 1 << 5; // 1100000_ 10______
   21|   646k|  constexpr const uint8_t TWO_CONTS = 1 << 7;  // 10______ 10______
   22|   646k|  constexpr const uint8_t TOO_LARGE = 1 << 3;  // 11110100 1001____
   23|       |                                               // 11110100 101_____
   24|       |                                               // 11110101 1001____
   25|       |                                               // 11110101 101_____
   26|       |                                               // 1111011_ 1001____
   27|       |                                               // 1111011_ 101_____
   28|       |                                               // 11111___ 1001____
   29|       |                                               // 11111___ 101_____
   30|   646k|  constexpr const uint8_t TOO_LARGE_1000 = 1 << 6;
   31|       |  // 11110101 1000____
   32|       |  // 1111011_ 1000____
   33|       |  // 11111___ 1000____
   34|   646k|  constexpr const uint8_t OVERLONG_4 = 1 << 6; // 11110000 1000____
   35|       |
   36|   646k|  const simd8<uint8_t> byte_1_high = prev1.shr<4>().lookup_16<uint8_t>(
   37|       |      // 0_______ ________ <ASCII in byte 1>
   38|   646k|      TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG, TOO_LONG,
   39|   646k|      TOO_LONG,
   40|       |      // 10______ ________ <continuation in byte 1>
   41|   646k|      TWO_CONTS, TWO_CONTS, TWO_CONTS, TWO_CONTS,
   42|       |      // 1100____ ________ <two byte lead in byte 1>
   43|   646k|      TOO_SHORT | OVERLONG_2,
   44|       |      // 1101____ ________ <two byte lead in byte 1>
   45|   646k|      TOO_SHORT,
   46|       |      // 1110____ ________ <three byte lead in byte 1>
   47|   646k|      TOO_SHORT | OVERLONG_3 | SURROGATE,
   48|       |      // 1111____ ________ <four+ byte lead in byte 1>
   49|   646k|      TOO_SHORT | TOO_LARGE | TOO_LARGE_1000 | OVERLONG_4);
   50|   646k|  constexpr const uint8_t CARRY =
   51|   646k|      TOO_SHORT | TOO_LONG | TWO_CONTS; // These all have ____ in byte 1 .
   52|   646k|  const simd8<uint8_t> byte_1_low =
   53|   646k|      (prev1 & 0x0F)
   54|   646k|          .lookup_16<uint8_t>(
   55|       |              // ____0000 ________
   56|   646k|              CARRY | OVERLONG_3 | OVERLONG_2 | OVERLONG_4,
   57|       |              // ____0001 ________
   58|   646k|              CARRY | OVERLONG_2,
   59|       |              // ____001_ ________
   60|   646k|              CARRY, CARRY,
   61|       |
   62|       |              // ____0100 ________
   63|   646k|              CARRY | TOO_LARGE,
   64|       |              // ____0101 ________
   65|   646k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   66|       |              // ____011_ ________
   67|   646k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   68|   646k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   69|       |
   70|       |              // ____1___ ________
   71|   646k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   72|   646k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   73|   646k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   74|   646k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   75|   646k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   76|       |              // ____1101 ________
   77|   646k|              CARRY | TOO_LARGE | TOO_LARGE_1000 | SURROGATE,
   78|   646k|              CARRY | TOO_LARGE | TOO_LARGE_1000,
   79|   646k|              CARRY | TOO_LARGE | TOO_LARGE_1000);
   80|   646k|  const simd8<uint8_t> byte_2_high = input.shr<4>().lookup_16<uint8_t>(
   81|       |      // ________ 0_______ <ASCII in byte 2>
   82|   646k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT,
   83|   646k|      TOO_SHORT, TOO_SHORT,
   84|       |
   85|       |      // ________ 1000____
   86|   646k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE_1000 |
   87|   646k|          OVERLONG_4,
   88|       |      // ________ 1001____
   89|   646k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | OVERLONG_3 | TOO_LARGE,
   90|       |      // ________ 101_____
   91|   646k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   92|   646k|      TOO_LONG | OVERLONG_2 | TWO_CONTS | SURROGATE | TOO_LARGE,
   93|       |
   94|       |      // ________ 11______
   95|   646k|      TOO_SHORT, TOO_SHORT, TOO_SHORT, TOO_SHORT);
   96|   646k|  return (byte_1_high & byte_1_low & byte_2_high);
   97|   646k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3223check_multibyte_lengthsENS1_4simd5simd8IhEES5_S5_:
  101|   646k|                        const simd8<uint8_t> sc) {
  102|   646k|  simd8<uint8_t> prev2 = input.prev<2>(prev_input);
  103|   646k|  simd8<uint8_t> prev3 = input.prev<3>(prev_input);
  104|   646k|  simd8<uint8_t> must23 =
  105|   646k|      simd8<uint8_t>(must_be_2_3_continuation(prev2, prev3));
  106|   646k|  simd8<uint8_t> must23_80 = must23 & uint8_t(0x80);
  107|   646k|  return must23_80 ^ sc;
  108|   646k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3221validating_transcoder18convert_ascii_tailEPKcmmPDi:
  131|  1.64k|                                                         char32_t *output) {
  132|       |    // A cheap test on the first bytes avoids any SIMD work for most non-ASCII
  133|       |    // tails.
  134|  1.64k|    if (size - pos >= 8) {
  ------------------
  |  Branch (134:9): [True: 1.59k, False: 50]
  ------------------
  135|  1.59k|      uint64_t first_bytes;
  136|  1.59k|      std::memcpy(&first_bytes, in + pos, 8);
  137|  1.59k|      if (first_bytes & 0x8080808080808080) {
  ------------------
  |  Branch (137:11): [True: 386, False: 1.20k]
  ------------------
  138|    386|        return 0;
  139|    386|      }
  140|  1.59k|    }
  141|  1.25k|    const size_t start = pos;
  142|  1.41k|    while (pos + 64 <= size) {
  ------------------
  |  Branch (142:12): [True: 528, False: 886]
  ------------------
  143|    528|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  144|    528|      if (!input.is_ascii()) {
  ------------------
  |  Branch (144:11): [True: 368, False: 160]
  ------------------
  145|    368|        return pos - start;
  146|    368|      }
  147|    160|      input.store_ascii_as_utf32(output + (pos - start));
  148|    160|      pos += 64;
  149|    160|    }
  150|    886|    if (pos == size || size < 64) {
  ------------------
  |  Branch (150:9): [True: 48, False: 838]
  |  Branch (150:24): [True: 88, False: 750]
  ------------------
  151|    136|      return pos - start;
  152|    136|    }
  153|    750|    simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + size - 64));
  154|    750|    if (!input.is_ascii()) {
  ------------------
  |  Branch (154:9): [True: 520, False: 230]
  ------------------
  155|    520|      return pos - start;
  156|    520|    }
  157|    230|    input.store_ascii_as_utf32(output + (pos - start) - (pos - (size - 64)));
  158|    230|    return size - start;
  159|    750|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3221validating_transcoder19convert_with_errorsEPKcmPDi:
  259|    946|                                                   char32_t *utf32_output) {
  260|    946|    if (size < 64) { // too short for the main loop
  ------------------
  |  Branch (260:9): [True: 280, False: 666]
  ------------------
  261|    280|      return scalar::utf8_to_utf32::convert_with_errors(in, size, utf32_output);
  262|    280|    }
  263|    666|    size_t pos = 0;
  264|    666|    char32_t *start{utf32_output};
  265|       |    // In the worst case, we have the haswell kernel which can cause an overflow
  266|       |    // of 4 words when calling convert_masked_utf8_to_utf32. If you skip the
  267|       |    // last 16 bytes, and if the data is valid, then it is entirely safe because
  268|       |    // 16 UTF-8 bytes generate at least 4 words. However, you cannot
  269|       |    // generally assume that you have valid UTF-8 input, so we are going to go
  270|       |    // back from the end counting 8 leading bytes, to give us a good margin.
  271|    666|    size_t leading_byte = 0;
  272|    666|    size_t margin = size;
  273|  41.8k|    for (; margin > 0 && leading_byte < 8; margin--) {
  ------------------
  |  Branch (273:12): [True: 41.8k, False: 14]
  |  Branch (273:26): [True: 41.1k, False: 652]
  ------------------
  274|  41.1k|      leading_byte += (int8_t(in[margin - 1]) > -65);
  275|  41.1k|    }
  276|       |    // If the input is long enough, then we have that margin is the eighth
  277|       |    // last leading byte.
  278|    666|    const size_t safety_margin = size - margin + 1; // to avoid overruns!
  279|   601k|    while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (279:12): [True: 600k, False: 562]
  ------------------
  280|   600k|      simd8x64<int8_t> input(reinterpret_cast<const int8_t *>(in + pos));
  281|   600k|      if (input.is_ascii()) {
  ------------------
  |  Branch (281:11): [True: 496k, False: 104k]
  ------------------
  282|   496k|        input.store_ascii_as_utf32(utf32_output);
  283|   496k|        utf32_output += 64;
  284|   496k|        pos += 64;
  285|   496k|      } else {
  286|       |        // you might think that a for-loop would work, but under Visual Studio,
  287|       |        // it is not good enough.
  288|   104k|        static_assert(
  289|   104k|            (simd8x64<uint8_t>::NUM_CHUNKS == 2) ||
  290|   104k|                (simd8x64<uint8_t>::NUM_CHUNKS == 4),
  291|   104k|            "We support either two or four chunks per 64-byte block.");
  292|   104k|        auto zero = simd8<uint8_t>{uint8_t(0)};
  293|       |        if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 2) {
  294|       |          this->check_utf8_bytes(input.chunks[0], zero);
  295|       |          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  296|   104k|        } else if constexpr (simd8x64<uint8_t>::NUM_CHUNKS == 4) {
  297|   104k|          this->check_utf8_bytes(input.chunks[0], zero);
  298|   104k|          this->check_utf8_bytes(input.chunks[1], input.chunks[0]);
  299|   104k|          this->check_utf8_bytes(input.chunks[2], input.chunks[1]);
  300|   104k|          this->check_utf8_bytes(input.chunks[3], input.chunks[2]);
  301|   104k|        }
  302|   104k|        uint64_t utf8_continuation_mask = input.lt(-65 + 1);
  303|   104k|        if (errors() || (utf8_continuation_mask & 1)) {
  ------------------
  |  Branch (303:13): [True: 104, False: 104k]
  |  Branch (303:25): [True: 0, False: 104k]
  ------------------
  304|    104|          SIMDUTF_VZEROUPPER();
  ------------------
  |  |   16|    104|#define SIMDUTF_VZEROUPPER() (void)0
  ------------------
  305|    104|          result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(
  306|    104|              pos, in + pos, size - pos, utf32_output);
  307|    104|          res.count += pos;
  308|    104|          return res;
  309|    104|        }
  310|   104k|        uint64_t utf8_leading_mask = ~utf8_continuation_mask;
  311|   104k|        uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
  312|       |        // We process in blocks of up to 12 bytes except possibly
  313|       |        // for fast paths which may process up to 16 bytes. For the
  314|       |        // slow path to work, we should have at least 12 input bytes left.
  315|   104k|        size_t max_starting_point = (pos + 64) - 12;
  316|       |        // Next loop is going to run at least five times.
  317|   750k|        while (pos < max_starting_point) {
  ------------------
  |  Branch (317:16): [True: 646k, False: 104k]
  ------------------
  318|       |          // Performance note: our ability to compute 'consumed' and
  319|       |          // then shift and recompute is critical. If there is a
  320|       |          // latency of, say, 4 cycles on getting 'consumed', then
  321|       |          // the inner loop might have a total latency of about 6 cycles.
  322|       |          // Yet we process between 6 to 12 inputs bytes, thus we get
  323|       |          // a speed limit between 1 cycle/byte and 0.5 cycle/byte
  324|       |          // for this section of the code. Hence, there is a limit
  325|       |          // to how much we can further increase this latency before
  326|       |          // it seriously harms performance.
  327|   646k|          size_t consumed = convert_masked_utf8_to_utf32(
  328|   646k|              in + pos, utf8_end_of_code_point_mask, utf32_output);
  329|   646k|          pos += consumed;
  330|   646k|          utf8_end_of_code_point_mask >>= consumed;
  331|   646k|        }
  332|       |        // At this point there may remain between 0 and 12 bytes in the
  333|       |        // 64-byte block. These bytes will be processed again. So we have an
  334|       |        // 80% efficiency (in the worst case). In practice we expect an
  335|       |        // 85% to 90% efficiency.
  336|   104k|      }
  337|   600k|    }
  338|    562|    const size_t ascii = convert_ascii_tail(in, pos, size, utf32_output);
  339|    562|    pos += ascii;
  340|    562|    utf32_output += ascii;
  341|    562|    if (pos == size) {
  ------------------
  |  Branch (341:9): [True: 90, False: 472]
  ------------------
  342|     90|      return result(error_code::SUCCESS, utf32_output - start);
  343|     90|    }
  344|       |    // rewind_and_convert_with_errors will seek a potential error from in+pos
  345|       |    // onward, with the ability to go back up to pos bytes, and read size-pos
  346|       |    // bytes forward.
  347|    472|    SIMDUTF_VZEROUPPER();
  ------------------
  |  |   16|    472|#define SIMDUTF_VZEROUPPER() (void)0
  ------------------
  348|    472|    result res = scalar::utf8_to_utf32::rewind_and_convert_with_errors(
  349|    472|        pos, in + pos, size - pos, utf32_output);
  350|    472|    if (res.error) { // In case of error, we want the error position
  ------------------
  |  Branch (350:9): [True: 338, False: 134]
  ------------------
  351|    338|      res.count += pos;
  352|    338|      return res;
  353|    338|    }
  354|       |    // In case of success, we want the number of words written
  355|    134|    utf32_output += res.count;
  356|    134|    return result(error_code::SUCCESS, utf32_output - start);
  357|    472|  }

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_113utf8_to_utf3213convert_validEPKcmPDi:
    9|    628|                                         char32_t *utf32_output) noexcept {
   10|    628|  size_t pos = 0;
   11|    628|  char32_t *start{utf32_output};
   12|    628|  const size_t safety_margin = 16; // to avoid overruns!
   13|   528k|  while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (13:10): [True: 527k, False: 628]
  ------------------
   14|   527k|    simd8x64<int8_t> in(reinterpret_cast<const int8_t *>(input + pos));
   15|   527k|    if (in.is_ascii()) {
  ------------------
  |  Branch (15:9): [True: 426k, False: 101k]
  ------------------
   16|   426k|      in.store_ascii_as_utf32(utf32_output);
   17|   426k|      utf32_output += 64;
   18|   426k|      pos += 64;
   19|   426k|    } else {
   20|       |      // -65 is 0b10111111 in two-complement's, so largest possible continuation
   21|       |      // byte
   22|   101k|      uint64_t utf8_continuation_mask = in.lt(-65 + 1);
   23|   101k|      uint64_t utf8_leading_mask = ~utf8_continuation_mask;
   24|   101k|      uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
   25|   101k|      size_t max_starting_point = (pos + 64) - 12;
   26|   717k|      while (pos < max_starting_point) {
  ------------------
  |  Branch (26:14): [True: 616k, False: 101k]
  ------------------
   27|   616k|        size_t consumed = convert_masked_utf8_to_utf32(
   28|   616k|            input + pos, utf8_end_of_code_point_mask, utf32_output);
   29|   616k|        pos += consumed;
   30|   616k|        utf8_end_of_code_point_mask >>= consumed;
   31|   616k|      }
   32|   101k|    }
   33|   527k|  }
   34|    628|  const size_t ascii =
   35|    628|      validating_transcoder::convert_ascii_tail(input, pos, size, utf32_output);
   36|    628|  pos += ascii;
   37|    628|  utf32_output += ascii;
   38|    628|  if (pos == size) {
  ------------------
  |  Branch (38:7): [True: 106, False: 522]
  ------------------
   39|    106|    return utf32_output - start;
   40|    106|  }
   41|    522|  utf32_output += scalar::utf8_to_utf32::convert_valid(input + pos, size - pos,
   42|    522|                                                       utf32_output);
   43|    522|  return utf32_output - start;
   44|    628|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_113utf8_to_utf3213convert_validEPKcmPDi:
    9|    628|                                         char32_t *utf32_output) noexcept {
   10|    628|  size_t pos = 0;
   11|    628|  char32_t *start{utf32_output};
   12|    628|  const size_t safety_margin = 16; // to avoid overruns!
   13|   528k|  while (pos + 64 + safety_margin <= size) {
  ------------------
  |  Branch (13:10): [True: 527k, False: 628]
  ------------------
   14|   527k|    simd8x64<int8_t> in(reinterpret_cast<const int8_t *>(input + pos));
   15|   527k|    if (in.is_ascii()) {
  ------------------
  |  Branch (15:9): [True: 426k, False: 101k]
  ------------------
   16|   426k|      in.store_ascii_as_utf32(utf32_output);
   17|   426k|      utf32_output += 64;
   18|   426k|      pos += 64;
   19|   426k|    } else {
   20|       |      // -65 is 0b10111111 in two-complement's, so largest possible continuation
   21|       |      // byte
   22|   101k|      uint64_t utf8_continuation_mask = in.lt(-65 + 1);
   23|   101k|      uint64_t utf8_leading_mask = ~utf8_continuation_mask;
   24|   101k|      uint64_t utf8_end_of_code_point_mask = utf8_leading_mask >> 1;
   25|   101k|      size_t max_starting_point = (pos + 64) - 12;
   26|   717k|      while (pos < max_starting_point) {
  ------------------
  |  Branch (26:14): [True: 616k, False: 101k]
  ------------------
   27|   616k|        size_t consumed = convert_masked_utf8_to_utf32(
   28|   616k|            input + pos, utf8_end_of_code_point_mask, utf32_output);
   29|   616k|        pos += consumed;
   30|   616k|        utf8_end_of_code_point_mask >>= consumed;
   31|   616k|      }
   32|   101k|    }
   33|   527k|  }
   34|    628|  const size_t ascii =
   35|    628|      validating_transcoder::convert_ascii_tail(input, pos, size, utf32_output);
   36|    628|  pos += ascii;
   37|    628|  utf32_output += ascii;
   38|    628|  if (pos == size) {
  ------------------
  |  Branch (38:7): [True: 106, False: 522]
  ------------------
   39|    106|    return utf32_output - start;
   40|    106|  }
   41|    522|  utf32_output += scalar::utf8_to_utf32::convert_valid(input + pos, size - pos,
   42|    522|                                                       utf32_output);
   43|    522|  return utf32_output - start;
   44|    628|}

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

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115utf8_validation21generic_validate_utf8EPKcm:
   65|  4.89k|bool generic_validate_utf8(const char *input, size_t length) {
   66|  4.89k|  return generic_validate_utf8<utf8_checker>(
   67|  4.89k|      reinterpret_cast<const uint8_t *>(input), length);
   68|  4.89k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115utf8_validation21generic_validate_utf8INS2_12utf8_checkerEEEbPKhm:
   46|  4.89k|bool generic_validate_utf8(const uint8_t *input, size_t length) {
   47|  4.89k|  checker c{};
   48|  4.89k|  buf_block_reader<64> reader(input, length);
   49|  4.89k|  size_t next_check = 1024;
   50|  2.89M|  while (reader.has_full_block()) {
  ------------------
  |  Branch (50:10): [True: 2.89M, False: 4.67k]
  ------------------
   51|  2.89M|    simd::simd8x64<uint8_t> in(reader.full_block());
   52|  2.89M|    if (!c.check_next_input(in) &&
  ------------------
  |  Branch (52:9): [True: 459k, False: 2.43M]
  ------------------
   53|   459k|        simdutf_unlikely(reader.block_index() >= next_check)) {
  ------------------
  |  |   93|   459k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 35.8k, False: 424k]
  |  |  ------------------
  ------------------
   54|  35.8k|      if (c.errors()) {
  ------------------
  |  Branch (54:11): [True: 214, False: 35.6k]
  ------------------
   55|    214|        return false;
   56|    214|      }
   57|  35.6k|      next_check = reader.block_index() + 1024;
   58|  35.6k|    }
   59|  2.89M|    reader.advance();
   60|  2.89M|  }
   61|  4.67k|  check_remainder(c, input, length, reader.block_index());
   62|  4.67k|  return !c.errors();
   63|  4.89k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115utf8_validation15check_remainderINS2_12utf8_checkerEEEvRT_PKhmm:
   15|  8.84k|                                           size_t length, size_t idx) {
   16|  8.84k|  constexpr size_t block = sizeof(simd::simd8x64<uint8_t>);
   17|  8.84k|  constexpr size_t width = sizeof(simd::simd8<uint8_t>);
   18|  8.84k|  static_assert(block == 8 * sizeof(uint64_t), "one mask bit per byte");
   19|  8.84k|  if (length >= block + width) {
  ------------------
  |  Branch (19:7): [True: 3.11k, False: 5.72k]
  ------------------
   20|       |    // The window starts at or before idx: buf_block_reader leaves 1 to 64
   21|       |    // bytes, so 0 <= idx - start < 64.
   22|  3.11k|    const size_t start = length - block;
   23|  3.11k|    const simd::simd8x64<uint8_t> in(input + start);
   24|       |    // Bit i is set if byte start + i is not ASCII, so the bytes from idx on
   25|       |    // are the top length - idx bits. is_ascii() goes first because GCC, up
   26|       |    // to at least GCC 17, builds gteq_unsigned(0x80) from min and compare
   27|       |    // instead of one movemask, which costs ASCII tails about 0.5 ns.
   28|  3.11k|    if (!in.is_ascii() && (in.gteq_unsigned(0x80) >> (idx - start)) != 0) {
  ------------------
  |  Branch (28:9): [True: 2.12k, False: 989]
  |  Branch (28:27): [True: 1.76k, False: 362]
  ------------------
   29|  1.76k|      c.check_overlapping_input(in,
   30|  1.76k|                                simd::simd8<uint8_t>(input + start - width));
   31|  1.76k|    }
   32|  5.72k|  } else if (idx != length) {
  ------------------
  |  Branch (32:14): [True: 5.69k, False: 36]
  ------------------
   33|       |    // Only an empty input leaves no bytes. Its pointer may be null, and
   34|       |    // memcpy from a null pointer is undefined.
   35|  5.69k|    uint8_t buffer[block]{};
   36|  5.69k|    std::memcpy(buffer, input + idx, length - idx);
   37|  5.69k|    c.check_next_input(simd::simd8x64<uint8_t>(buffer));
   38|  5.69k|  }
   39|  8.84k|  c.check_eof();
   40|  8.84k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115utf8_validation21generic_validate_utf8EPKcm:
   65|  4.89k|bool generic_validate_utf8(const char *input, size_t length) {
   66|  4.89k|  return generic_validate_utf8<utf8_checker>(
   67|  4.89k|      reinterpret_cast<const uint8_t *>(input), length);
   68|  4.89k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115utf8_validation21generic_validate_utf8INS2_12utf8_checkerEEEbPKhm:
   46|  4.89k|bool generic_validate_utf8(const uint8_t *input, size_t length) {
   47|  4.89k|  checker c{};
   48|  4.89k|  buf_block_reader<64> reader(input, length);
   49|  4.89k|  size_t next_check = 1024;
   50|  2.89M|  while (reader.has_full_block()) {
  ------------------
  |  Branch (50:10): [True: 2.89M, False: 4.67k]
  ------------------
   51|  2.89M|    simd::simd8x64<uint8_t> in(reader.full_block());
   52|  2.89M|    if (!c.check_next_input(in) &&
  ------------------
  |  Branch (52:9): [True: 459k, False: 2.43M]
  ------------------
   53|   459k|        simdutf_unlikely(reader.block_index() >= next_check)) {
  ------------------
  |  |   93|   459k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 35.8k, False: 424k]
  |  |  ------------------
  ------------------
   54|  35.8k|      if (c.errors()) {
  ------------------
  |  Branch (54:11): [True: 214, False: 35.6k]
  ------------------
   55|    214|        return false;
   56|    214|      }
   57|  35.6k|      next_check = reader.block_index() + 1024;
   58|  35.6k|    }
   59|  2.89M|    reader.advance();
   60|  2.89M|  }
   61|  4.67k|  check_remainder(c, input, length, reader.block_index());
   62|  4.67k|  return !c.errors();
   63|  4.89k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115utf8_validation15check_remainderINS2_12utf8_checkerEEEvRT_PKhmm:
   15|  8.84k|                                           size_t length, size_t idx) {
   16|  8.84k|  constexpr size_t block = sizeof(simd::simd8x64<uint8_t>);
   17|  8.84k|  constexpr size_t width = sizeof(simd::simd8<uint8_t>);
   18|  8.84k|  static_assert(block == 8 * sizeof(uint64_t), "one mask bit per byte");
   19|  8.84k|  if (length >= block + width) {
  ------------------
  |  Branch (19:7): [True: 3.55k, False: 5.28k]
  ------------------
   20|       |    // The window starts at or before idx: buf_block_reader leaves 1 to 64
   21|       |    // bytes, so 0 <= idx - start < 64.
   22|  3.55k|    const size_t start = length - block;
   23|  3.55k|    const simd::simd8x64<uint8_t> in(input + start);
   24|       |    // Bit i is set if byte start + i is not ASCII, so the bytes from idx on
   25|       |    // are the top length - idx bits. is_ascii() goes first because GCC, up
   26|       |    // to at least GCC 17, builds gteq_unsigned(0x80) from min and compare
   27|       |    // instead of one movemask, which costs ASCII tails about 0.5 ns.
   28|  3.55k|    if (!in.is_ascii() && (in.gteq_unsigned(0x80) >> (idx - start)) != 0) {
  ------------------
  |  Branch (28:9): [True: 2.55k, False: 1.00k]
  |  Branch (28:27): [True: 2.03k, False: 512]
  ------------------
   29|  2.03k|      c.check_overlapping_input(in,
   30|  2.03k|                                simd::simd8<uint8_t>(input + start - width));
   31|  2.03k|    }
   32|  5.28k|  } else if (idx != length) {
  ------------------
  |  Branch (32:14): [True: 5.25k, False: 36]
  ------------------
   33|       |    // Only an empty input leaves no bytes. Its pointer may be null, and
   34|       |    // memcpy from a null pointer is undefined.
   35|  5.25k|    uint8_t buffer[block]{};
   36|  5.25k|    std::memcpy(buffer, input + idx, length - idx);
   37|  5.25k|    c.check_next_input(simd::simd8x64<uint8_t>(buffer));
   38|  5.25k|  }
   39|  8.84k|  c.check_eof();
   40|  8.84k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115utf8_validation33generic_validate_utf8_with_errorsEPKcm:
  112|  4.89k|result generic_validate_utf8_with_errors(const char *input, size_t length) {
  113|  4.89k|  return generic_validate_utf8_with_errors<utf8_checker>(
  114|  4.89k|      reinterpret_cast<const uint8_t *>(input), length);
  115|  4.89k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_115utf8_validation33generic_validate_utf8_with_errorsINS2_12utf8_checkerEEENS_6resultEPKhm:
   75|  4.89k|result generic_validate_utf8_with_errors(const uint8_t *input, size_t length) {
   76|  4.89k|  checker c{};
   77|  4.89k|  buf_block_reader<64> reader(input, length);
   78|  4.89k|  size_t count{0};
   79|  2.88M|  while (reader.has_full_block()) {
  ------------------
  |  Branch (79:10): [True: 2.87M, False: 4.16k]
  ------------------
   80|  2.87M|    simd::simd8x64<uint8_t> in(reader.full_block());
   81|  2.87M|    c.check_next_input(in);
   82|  2.87M|    if (c.errors()) {
  ------------------
  |  Branch (82:9): [True: 732, False: 2.87M]
  ------------------
   83|    732|      if (count != 0) {
  ------------------
  |  Branch (83:11): [True: 404, False: 328]
  ------------------
   84|    404|        count--;
   85|    404|      } // Sometimes the error is only detected in the next chunk
   86|    732|      SIMDUTF_VZEROUPPER();
  ------------------
  |  |   22|    732|#define SIMDUTF_VZEROUPPER() _mm256_zeroupper()
  ------------------
   87|    732|      result res = scalar::utf8::rewind_and_validate_with_errors(
   88|    732|          reinterpret_cast<const char *>(input),
   89|    732|          reinterpret_cast<const char *>(input + count), length - count);
   90|    732|      res.count += count;
   91|    732|      return res;
   92|    732|    }
   93|  2.87M|    reader.advance();
   94|  2.87M|    count += 64;
   95|  2.87M|  }
   96|  4.16k|  check_remainder(c, input, length, reader.block_index());
   97|  4.16k|  if (c.errors()) {
  ------------------
  |  Branch (97:7): [True: 1.56k, False: 2.60k]
  ------------------
   98|  1.56k|    if (count != 0) {
  ------------------
  |  Branch (98:9): [True: 675, False: 885]
  ------------------
   99|    675|      count--;
  100|    675|    } // Sometimes the error is only detected in the next chunk
  101|  1.56k|    SIMDUTF_VZEROUPPER();
  ------------------
  |  |   22|  1.56k|#define SIMDUTF_VZEROUPPER() _mm256_zeroupper()
  ------------------
  102|  1.56k|    result res = scalar::utf8::rewind_and_validate_with_errors(
  103|  1.56k|        reinterpret_cast<const char *>(input),
  104|  1.56k|        reinterpret_cast<const char *>(input) + count, length - count);
  105|  1.56k|    res.count += count;
  106|  1.56k|    return res;
  107|  2.60k|  } else {
  108|  2.60k|    return result(error_code::SUCCESS, length);
  109|  2.60k|  }
  110|  4.16k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115utf8_validation33generic_validate_utf8_with_errorsEPKcm:
  112|  4.89k|result generic_validate_utf8_with_errors(const char *input, size_t length) {
  113|  4.89k|  return generic_validate_utf8_with_errors<utf8_checker>(
  114|  4.89k|      reinterpret_cast<const uint8_t *>(input), length);
  115|  4.89k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_115utf8_validation33generic_validate_utf8_with_errorsINS2_12utf8_checkerEEENS_6resultEPKhm:
   75|  4.89k|result generic_validate_utf8_with_errors(const uint8_t *input, size_t length) {
   76|  4.89k|  checker c{};
   77|  4.89k|  buf_block_reader<64> reader(input, length);
   78|  4.89k|  size_t count{0};
   79|  2.88M|  while (reader.has_full_block()) {
  ------------------
  |  Branch (79:10): [True: 2.87M, False: 4.16k]
  ------------------
   80|  2.87M|    simd::simd8x64<uint8_t> in(reader.full_block());
   81|  2.87M|    c.check_next_input(in);
   82|  2.87M|    if (c.errors()) {
  ------------------
  |  Branch (82:9): [True: 732, False: 2.87M]
  ------------------
   83|    732|      if (count != 0) {
  ------------------
  |  Branch (83:11): [True: 404, False: 328]
  ------------------
   84|    404|        count--;
   85|    404|      } // Sometimes the error is only detected in the next chunk
   86|    732|      SIMDUTF_VZEROUPPER();
  ------------------
  |  |   16|    732|#define SIMDUTF_VZEROUPPER() (void)0
  ------------------
   87|    732|      result res = scalar::utf8::rewind_and_validate_with_errors(
   88|    732|          reinterpret_cast<const char *>(input),
   89|    732|          reinterpret_cast<const char *>(input + count), length - count);
   90|    732|      res.count += count;
   91|    732|      return res;
   92|    732|    }
   93|  2.87M|    reader.advance();
   94|  2.87M|    count += 64;
   95|  2.87M|  }
   96|  4.16k|  check_remainder(c, input, length, reader.block_index());
   97|  4.16k|  if (c.errors()) {
  ------------------
  |  Branch (97:7): [True: 1.56k, False: 2.60k]
  ------------------
   98|  1.56k|    if (count != 0) {
  ------------------
  |  Branch (98:9): [True: 675, False: 885]
  ------------------
   99|    675|      count--;
  100|    675|    } // Sometimes the error is only detected in the next chunk
  101|  1.56k|    SIMDUTF_VZEROUPPER();
  ------------------
  |  |   16|  1.56k|#define SIMDUTF_VZEROUPPER() (void)0
  ------------------
  102|  1.56k|    result res = scalar::utf8::rewind_and_validate_with_errors(
  103|  1.56k|        reinterpret_cast<const char *>(input),
  104|  1.56k|        reinterpret_cast<const char *>(input) + count, length - count);
  105|  1.56k|    res.count += count;
  106|  1.56k|    return res;
  107|  2.60k|  } else {
  108|  2.60k|    return result(error_code::SUCCESS, length);
  109|  2.60k|  }
  110|  4.16k|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf1626validate_utf16_with_errorsILNS_10endiannessE0EEEKNS_6resultEPKDsm:
   49|  2.73k|const result validate_utf16_with_errors(const char16_t *input, size_t size) {
   50|  2.73k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  2.73k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 15, False: 2.72k]
  |  |  ------------------
  ------------------
   51|     15|    return result(error_code::SUCCESS, 0);
   52|     15|  }
   53|       |
   54|  2.72k|  const char16_t *start = input;
   55|  2.72k|  const char16_t *end = input + size;
   56|       |
   57|  2.72k|  const auto v_d8 = simd8<uint8_t>::splat(0xd8);
   58|  2.72k|  const auto v_f8 = simd8<uint8_t>::splat(0xf8);
   59|  2.72k|  const auto v_fc = simd8<uint8_t>::splat(0xfc);
   60|  2.72k|  const auto v_dc = simd8<uint8_t>::splat(0xdc);
   61|       |
   62|       |  // Each iteration gathers the high bytes of two registers into one byte
   63|       |  // register: N code units, one mask bit each.
   64|  2.72k|  constexpr size_t N = simd16<uint16_t>::SIZE;
   65|  2.72k|  static_assert(N == 16 || N == 32, "one mask bit per code unit");
   66|  2.72k|  using mask_t = std::conditional_t<N == 32, uint32_t, uint16_t>;
   67|  2.72k|  constexpr mask_t all = mask_t(~mask_t(0));
   68|       |
   69|  1.28M|  while (input + N <= end) {
  ------------------
  |  Branch (69:10): [True: 1.27M, False: 2.47k]
  ------------------
   70|       |    // 0. Load data: since the validation takes into account only higher
   71|       |    //    byte of each word, we compress the two vectors into one which
   72|       |    //    consists only the higher bytes.
   73|  1.27M|    auto in0 = simd16<uint16_t>(input);
   74|  1.27M|    auto in1 = simd16<uint16_t>(input + N / 2);
   75|       |
   76|       |    // Function `utf16_gather_high_bytes` consumes two vectors of UTF-16
   77|       |    // and yields a single vector having only higher bytes of characters.
   78|  1.27M|    const auto in = utf16_gather_high_bytes<big_endian>(in0, in1);
   79|       |
   80|       |    // 1. Check whether we have any 0xD800..DFFF word (0b1101'1xxx'yyyy'yyyy).
   81|  1.27M|    const auto surrogates_wordmask = (in & v_f8) == v_d8;
   82|  1.27M|    const mask_t surrogates_bitmask =
   83|  1.27M|        static_cast<mask_t>(surrogates_wordmask.to_bitmask());
   84|  1.27M|    if (surrogates_bitmask == 0) {
  ------------------
  |  Branch (84:9): [True: 1.26M, False: 12.2k]
  ------------------
   85|  1.26M|      input += N;
   86|  1.26M|    } else {
   87|       |      // 2. We have some surrogates that have to be distinguished:
   88|       |      //    - low  surrogates: 0b1101'10xx'yyyy'yyyy (0xD800..0xDBFF)
   89|       |      //    - high surrogates: 0b1101'11xx'yyyy'yyyy (0xDC00..0xDFFF)
   90|       |      //
   91|       |      //    Fact: high surrogate has 11th bit set (3rd bit in the higher byte)
   92|       |
   93|       |      // V - non-surrogate code units
   94|       |      //     V = not surrogates_wordmask
   95|  12.2k|      const mask_t V = static_cast<mask_t>(~surrogates_bitmask);
   96|       |
   97|       |      // H - word-mask for high surrogates: the six highest bits are 0b1101'11
   98|  12.2k|      const auto vH = (in & v_fc) == v_dc;
   99|  12.2k|      const mask_t H = static_cast<mask_t>(vH.to_bitmask());
  100|       |
  101|       |      // L - word mask for low surrogates
  102|       |      //     L = not H and surrogates_wordmask
  103|  12.2k|      const mask_t L = static_cast<mask_t>(~H & surrogates_bitmask);
  104|       |
  105|  12.2k|      const mask_t a = static_cast<mask_t>(
  106|  12.2k|          L & (H >> 1)); // A low surrogate must be followed by high one.
  107|       |                         // (A low surrogate placed in the 7th register's word
  108|       |                         // is an exception we handle.)
  109|  12.2k|      const mask_t b = static_cast<mask_t>(
  110|  12.2k|          a << 1); // Just mark that the opinput - startite fact is hold,
  111|       |                   // thanks to that we have only two masks for valid case.
  112|  12.2k|      const mask_t c = static_cast<mask_t>(
  113|  12.2k|          V | a | b); // Combine all the masks into the final one.
  114|       |
  115|  12.2k|      if (c == all) {
  ------------------
  |  Branch (115:11): [True: 10.7k, False: 1.52k]
  ------------------
  116|       |        // The whole input register contains valid UTF-16, i.e.,
  117|       |        // either single code units or proper surrogate pairs.
  118|  10.7k|        input += N;
  119|  10.7k|      } else if (c == all >> 1) {
  ------------------
  |  Branch (119:18): [True: 1.28k, False: 244]
  ------------------
  120|       |        // The N - 1 lower code units of the input register contain valid
  121|       |        // UTF-16. The last word may be either a low or high surrogate. In the
  122|       |        // next iteration we 1) check if the low surrogate is followed by a
  123|       |        // high one, 2) reject sole high surrogate.
  124|  1.28k|        input += N - 1;
  125|  1.28k|      } else {
  126|    244|        return result(error_code::SURROGATE, input - start);
  127|    244|      }
  128|  12.2k|    }
  129|  1.27M|  }
  130|       |
  131|  2.47k|  return result(error_code::SUCCESS, input - start);
  132|  2.72k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf1626validate_utf16_with_errorsILNS_10endiannessE1EEEKNS_6resultEPKDsm:
   49|  2.71k|const result validate_utf16_with_errors(const char16_t *input, size_t size) {
   50|  2.71k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  2.71k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 16, False: 2.69k]
  |  |  ------------------
  ------------------
   51|     16|    return result(error_code::SUCCESS, 0);
   52|     16|  }
   53|       |
   54|  2.69k|  const char16_t *start = input;
   55|  2.69k|  const char16_t *end = input + size;
   56|       |
   57|  2.69k|  const auto v_d8 = simd8<uint8_t>::splat(0xd8);
   58|  2.69k|  const auto v_f8 = simd8<uint8_t>::splat(0xf8);
   59|  2.69k|  const auto v_fc = simd8<uint8_t>::splat(0xfc);
   60|  2.69k|  const auto v_dc = simd8<uint8_t>::splat(0xdc);
   61|       |
   62|       |  // Each iteration gathers the high bytes of two registers into one byte
   63|       |  // register: N code units, one mask bit each.
   64|  2.69k|  constexpr size_t N = simd16<uint16_t>::SIZE;
   65|  2.69k|  static_assert(N == 16 || N == 32, "one mask bit per code unit");
   66|  2.69k|  using mask_t = std::conditional_t<N == 32, uint32_t, uint16_t>;
   67|  2.69k|  constexpr mask_t all = mask_t(~mask_t(0));
   68|       |
   69|  1.21M|  while (input + N <= end) {
  ------------------
  |  Branch (69:10): [True: 1.21M, False: 2.35k]
  ------------------
   70|       |    // 0. Load data: since the validation takes into account only higher
   71|       |    //    byte of each word, we compress the two vectors into one which
   72|       |    //    consists only the higher bytes.
   73|  1.21M|    auto in0 = simd16<uint16_t>(input);
   74|  1.21M|    auto in1 = simd16<uint16_t>(input + N / 2);
   75|       |
   76|       |    // Function `utf16_gather_high_bytes` consumes two vectors of UTF-16
   77|       |    // and yields a single vector having only higher bytes of characters.
   78|  1.21M|    const auto in = utf16_gather_high_bytes<big_endian>(in0, in1);
   79|       |
   80|       |    // 1. Check whether we have any 0xD800..DFFF word (0b1101'1xxx'yyyy'yyyy).
   81|  1.21M|    const auto surrogates_wordmask = (in & v_f8) == v_d8;
   82|  1.21M|    const mask_t surrogates_bitmask =
   83|  1.21M|        static_cast<mask_t>(surrogates_wordmask.to_bitmask());
   84|  1.21M|    if (surrogates_bitmask == 0) {
  ------------------
  |  Branch (84:9): [True: 1.18M, False: 22.0k]
  ------------------
   85|  1.18M|      input += N;
   86|  1.18M|    } else {
   87|       |      // 2. We have some surrogates that have to be distinguished:
   88|       |      //    - low  surrogates: 0b1101'10xx'yyyy'yyyy (0xD800..0xDBFF)
   89|       |      //    - high surrogates: 0b1101'11xx'yyyy'yyyy (0xDC00..0xDFFF)
   90|       |      //
   91|       |      //    Fact: high surrogate has 11th bit set (3rd bit in the higher byte)
   92|       |
   93|       |      // V - non-surrogate code units
   94|       |      //     V = not surrogates_wordmask
   95|  22.0k|      const mask_t V = static_cast<mask_t>(~surrogates_bitmask);
   96|       |
   97|       |      // H - word-mask for high surrogates: the six highest bits are 0b1101'11
   98|  22.0k|      const auto vH = (in & v_fc) == v_dc;
   99|  22.0k|      const mask_t H = static_cast<mask_t>(vH.to_bitmask());
  100|       |
  101|       |      // L - word mask for low surrogates
  102|       |      //     L = not H and surrogates_wordmask
  103|  22.0k|      const mask_t L = static_cast<mask_t>(~H & surrogates_bitmask);
  104|       |
  105|  22.0k|      const mask_t a = static_cast<mask_t>(
  106|  22.0k|          L & (H >> 1)); // A low surrogate must be followed by high one.
  107|       |                         // (A low surrogate placed in the 7th register's word
  108|       |                         // is an exception we handle.)
  109|  22.0k|      const mask_t b = static_cast<mask_t>(
  110|  22.0k|          a << 1); // Just mark that the opinput - startite fact is hold,
  111|       |                   // thanks to that we have only two masks for valid case.
  112|  22.0k|      const mask_t c = static_cast<mask_t>(
  113|  22.0k|          V | a | b); // Combine all the masks into the final one.
  114|       |
  115|  22.0k|      if (c == all) {
  ------------------
  |  Branch (115:11): [True: 19.9k, False: 2.05k]
  ------------------
  116|       |        // The whole input register contains valid UTF-16, i.e.,
  117|       |        // either single code units or proper surrogate pairs.
  118|  19.9k|        input += N;
  119|  19.9k|      } else if (c == all >> 1) {
  ------------------
  |  Branch (119:18): [True: 1.71k, False: 344]
  ------------------
  120|       |        // The N - 1 lower code units of the input register contain valid
  121|       |        // UTF-16. The last word may be either a low or high surrogate. In the
  122|       |        // next iteration we 1) check if the low surrogate is followed by a
  123|       |        // high one, 2) reject sole high surrogate.
  124|  1.71k|        input += N - 1;
  125|  1.71k|      } else {
  126|    344|        return result(error_code::SURROGATE, input - start);
  127|    344|      }
  128|  22.0k|    }
  129|  1.21M|  }
  130|       |
  131|  2.35k|  return result(error_code::SUCCESS, input - start);
  132|  2.69k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf1626validate_utf16_with_errorsILNS_10endiannessE0EEEKNS_6resultEPKDsm:
   49|  2.73k|const result validate_utf16_with_errors(const char16_t *input, size_t size) {
   50|  2.73k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  2.73k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 15, False: 2.72k]
  |  |  ------------------
  ------------------
   51|     15|    return result(error_code::SUCCESS, 0);
   52|     15|  }
   53|       |
   54|  2.72k|  const char16_t *start = input;
   55|  2.72k|  const char16_t *end = input + size;
   56|       |
   57|  2.72k|  const auto v_d8 = simd8<uint8_t>::splat(0xd8);
   58|  2.72k|  const auto v_f8 = simd8<uint8_t>::splat(0xf8);
   59|  2.72k|  const auto v_fc = simd8<uint8_t>::splat(0xfc);
   60|  2.72k|  const auto v_dc = simd8<uint8_t>::splat(0xdc);
   61|       |
   62|       |  // Each iteration gathers the high bytes of two registers into one byte
   63|       |  // register: N code units, one mask bit each.
   64|  2.72k|  constexpr size_t N = simd16<uint16_t>::SIZE;
   65|  2.72k|  static_assert(N == 16 || N == 32, "one mask bit per code unit");
   66|  2.72k|  using mask_t = std::conditional_t<N == 32, uint32_t, uint16_t>;
   67|  2.72k|  constexpr mask_t all = mask_t(~mask_t(0));
   68|       |
   69|  2.55M|  while (input + N <= end) {
  ------------------
  |  Branch (69:10): [True: 2.55M, False: 2.16k]
  ------------------
   70|       |    // 0. Load data: since the validation takes into account only higher
   71|       |    //    byte of each word, we compress the two vectors into one which
   72|       |    //    consists only the higher bytes.
   73|  2.55M|    auto in0 = simd16<uint16_t>(input);
   74|  2.55M|    auto in1 = simd16<uint16_t>(input + N / 2);
   75|       |
   76|       |    // Function `utf16_gather_high_bytes` consumes two vectors of UTF-16
   77|       |    // and yields a single vector having only higher bytes of characters.
   78|  2.55M|    const auto in = utf16_gather_high_bytes<big_endian>(in0, in1);
   79|       |
   80|       |    // 1. Check whether we have any 0xD800..DFFF word (0b1101'1xxx'yyyy'yyyy).
   81|  2.55M|    const auto surrogates_wordmask = (in & v_f8) == v_d8;
   82|  2.55M|    const mask_t surrogates_bitmask =
   83|  2.55M|        static_cast<mask_t>(surrogates_wordmask.to_bitmask());
   84|  2.55M|    if (surrogates_bitmask == 0) {
  ------------------
  |  Branch (84:9): [True: 2.53M, False: 20.9k]
  ------------------
   85|  2.53M|      input += N;
   86|  2.53M|    } else {
   87|       |      // 2. We have some surrogates that have to be distinguished:
   88|       |      //    - low  surrogates: 0b1101'10xx'yyyy'yyyy (0xD800..0xDBFF)
   89|       |      //    - high surrogates: 0b1101'11xx'yyyy'yyyy (0xDC00..0xDFFF)
   90|       |      //
   91|       |      //    Fact: high surrogate has 11th bit set (3rd bit in the higher byte)
   92|       |
   93|       |      // V - non-surrogate code units
   94|       |      //     V = not surrogates_wordmask
   95|  20.9k|      const mask_t V = static_cast<mask_t>(~surrogates_bitmask);
   96|       |
   97|       |      // H - word-mask for high surrogates: the six highest bits are 0b1101'11
   98|  20.9k|      const auto vH = (in & v_fc) == v_dc;
   99|  20.9k|      const mask_t H = static_cast<mask_t>(vH.to_bitmask());
  100|       |
  101|       |      // L - word mask for low surrogates
  102|       |      //     L = not H and surrogates_wordmask
  103|  20.9k|      const mask_t L = static_cast<mask_t>(~H & surrogates_bitmask);
  104|       |
  105|  20.9k|      const mask_t a = static_cast<mask_t>(
  106|  20.9k|          L & (H >> 1)); // A low surrogate must be followed by high one.
  107|       |                         // (A low surrogate placed in the 7th register's word
  108|       |                         // is an exception we handle.)
  109|  20.9k|      const mask_t b = static_cast<mask_t>(
  110|  20.9k|          a << 1); // Just mark that the opinput - startite fact is hold,
  111|       |                   // thanks to that we have only two masks for valid case.
  112|  20.9k|      const mask_t c = static_cast<mask_t>(
  113|  20.9k|          V | a | b); // Combine all the masks into the final one.
  114|       |
  115|  20.9k|      if (c == all) {
  ------------------
  |  Branch (115:11): [True: 15.8k, False: 5.11k]
  ------------------
  116|       |        // The whole input register contains valid UTF-16, i.e.,
  117|       |        // either single code units or proper surrogate pairs.
  118|  15.8k|        input += N;
  119|  15.8k|      } else if (c == all >> 1) {
  ------------------
  |  Branch (119:18): [True: 4.55k, False: 558]
  ------------------
  120|       |        // The N - 1 lower code units of the input register contain valid
  121|       |        // UTF-16. The last word may be either a low or high surrogate. In the
  122|       |        // next iteration we 1) check if the low surrogate is followed by a
  123|       |        // high one, 2) reject sole high surrogate.
  124|  4.55k|        input += N - 1;
  125|  4.55k|      } else {
  126|    558|        return result(error_code::SURROGATE, input - start);
  127|    558|      }
  128|  20.9k|    }
  129|  2.55M|  }
  130|       |
  131|  2.16k|  return result(error_code::SUCCESS, input - start);
  132|  2.72k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf1626validate_utf16_with_errorsILNS_10endiannessE1EEEKNS_6resultEPKDsm:
   49|  2.71k|const result validate_utf16_with_errors(const char16_t *input, size_t size) {
   50|  2.71k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  2.71k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 16, False: 2.69k]
  |  |  ------------------
  ------------------
   51|     16|    return result(error_code::SUCCESS, 0);
   52|     16|  }
   53|       |
   54|  2.69k|  const char16_t *start = input;
   55|  2.69k|  const char16_t *end = input + size;
   56|       |
   57|  2.69k|  const auto v_d8 = simd8<uint8_t>::splat(0xd8);
   58|  2.69k|  const auto v_f8 = simd8<uint8_t>::splat(0xf8);
   59|  2.69k|  const auto v_fc = simd8<uint8_t>::splat(0xfc);
   60|  2.69k|  const auto v_dc = simd8<uint8_t>::splat(0xdc);
   61|       |
   62|       |  // Each iteration gathers the high bytes of two registers into one byte
   63|       |  // register: N code units, one mask bit each.
   64|  2.69k|  constexpr size_t N = simd16<uint16_t>::SIZE;
   65|  2.69k|  static_assert(N == 16 || N == 32, "one mask bit per code unit");
   66|  2.69k|  using mask_t = std::conditional_t<N == 32, uint32_t, uint16_t>;
   67|  2.69k|  constexpr mask_t all = mask_t(~mask_t(0));
   68|       |
   69|  2.42M|  while (input + N <= end) {
  ------------------
  |  Branch (69:10): [True: 2.42M, False: 2.12k]
  ------------------
   70|       |    // 0. Load data: since the validation takes into account only higher
   71|       |    //    byte of each word, we compress the two vectors into one which
   72|       |    //    consists only the higher bytes.
   73|  2.42M|    auto in0 = simd16<uint16_t>(input);
   74|  2.42M|    auto in1 = simd16<uint16_t>(input + N / 2);
   75|       |
   76|       |    // Function `utf16_gather_high_bytes` consumes two vectors of UTF-16
   77|       |    // and yields a single vector having only higher bytes of characters.
   78|  2.42M|    const auto in = utf16_gather_high_bytes<big_endian>(in0, in1);
   79|       |
   80|       |    // 1. Check whether we have any 0xD800..DFFF word (0b1101'1xxx'yyyy'yyyy).
   81|  2.42M|    const auto surrogates_wordmask = (in & v_f8) == v_d8;
   82|  2.42M|    const mask_t surrogates_bitmask =
   83|  2.42M|        static_cast<mask_t>(surrogates_wordmask.to_bitmask());
   84|  2.42M|    if (surrogates_bitmask == 0) {
  ------------------
  |  Branch (84:9): [True: 2.38M, False: 34.3k]
  ------------------
   85|  2.38M|      input += N;
   86|  2.38M|    } else {
   87|       |      // 2. We have some surrogates that have to be distinguished:
   88|       |      //    - low  surrogates: 0b1101'10xx'yyyy'yyyy (0xD800..0xDBFF)
   89|       |      //    - high surrogates: 0b1101'11xx'yyyy'yyyy (0xDC00..0xDFFF)
   90|       |      //
   91|       |      //    Fact: high surrogate has 11th bit set (3rd bit in the higher byte)
   92|       |
   93|       |      // V - non-surrogate code units
   94|       |      //     V = not surrogates_wordmask
   95|  34.3k|      const mask_t V = static_cast<mask_t>(~surrogates_bitmask);
   96|       |
   97|       |      // H - word-mask for high surrogates: the six highest bits are 0b1101'11
   98|  34.3k|      const auto vH = (in & v_fc) == v_dc;
   99|  34.3k|      const mask_t H = static_cast<mask_t>(vH.to_bitmask());
  100|       |
  101|       |      // L - word mask for low surrogates
  102|       |      //     L = not H and surrogates_wordmask
  103|  34.3k|      const mask_t L = static_cast<mask_t>(~H & surrogates_bitmask);
  104|       |
  105|  34.3k|      const mask_t a = static_cast<mask_t>(
  106|  34.3k|          L & (H >> 1)); // A low surrogate must be followed by high one.
  107|       |                         // (A low surrogate placed in the 7th register's word
  108|       |                         // is an exception we handle.)
  109|  34.3k|      const mask_t b = static_cast<mask_t>(
  110|  34.3k|          a << 1); // Just mark that the opinput - startite fact is hold,
  111|       |                   // thanks to that we have only two masks for valid case.
  112|  34.3k|      const mask_t c = static_cast<mask_t>(
  113|  34.3k|          V | a | b); // Combine all the masks into the final one.
  114|       |
  115|  34.3k|      if (c == all) {
  ------------------
  |  Branch (115:11): [True: 26.4k, False: 7.86k]
  ------------------
  116|       |        // The whole input register contains valid UTF-16, i.e.,
  117|       |        // either single code units or proper surrogate pairs.
  118|  26.4k|        input += N;
  119|  26.4k|      } else if (c == all >> 1) {
  ------------------
  |  Branch (119:18): [True: 7.30k, False: 568]
  ------------------
  120|       |        // The N - 1 lower code units of the input register contain valid
  121|       |        // UTF-16. The last word may be either a low or high surrogate. In the
  122|       |        // next iteration we 1) check if the low surrogate is followed by a
  123|       |        // high one, 2) reject sole high surrogate.
  124|  7.30k|        input += N - 1;
  125|  7.30k|      } else {
  126|    568|        return result(error_code::SURROGATE, input - start);
  127|    568|      }
  128|  34.3k|    }
  129|  2.42M|  }
  130|       |
  131|  2.12k|  return result(error_code::SUCCESS, input - start);
  132|  2.69k|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf3220validate_with_errorsEPKDim:
   51|  2.21k|                                                  size_t size) {
   52|  2.21k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  2.21k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 22, False: 2.19k]
  |  |  ------------------
  ------------------
   53|       |    // empty input is valid UTF-32. protect the implementation from
   54|       |    // handling nullptr
   55|     22|    return result(error_code::SUCCESS, 0);
   56|     22|  }
   57|       |
   58|  2.19k|  const char32_t *start = input;
   59|  2.19k|  const char32_t *end = input + size;
   60|       |
   61|  2.19k|  using vector_u32 = simd32<uint32_t>;
   62|       |
   63|  2.19k|  const auto standardmax = vector_u32::splat(0x10ffff + 1);
   64|  2.19k|  const auto surrogate_mask = vector_u32::splat(0xfffff800);
   65|  2.19k|  const auto surrogate_byte = vector_u32::splat(0x0000d800);
   66|       |
   67|  2.19k|  constexpr size_t N = vector_u32::ELEMENTS;
   68|       |
   69|   247k|  while (input + N < end) {
  ------------------
  |  Branch (69:10): [True: 245k, False: 1.41k]
  ------------------
   70|   245k|    auto in = vector_u32(input);
   71|   245k|    if constexpr (!match_system(endianness::BIG)) {
   72|   245k|      in.swap_bytes();
   73|   245k|    }
   74|       |
   75|   245k|    const auto too_large = in >= standardmax;
   76|   245k|    const auto surrogate = (in & surrogate_mask) == surrogate_byte;
   77|       |
   78|   245k|    const auto combined = too_large | surrogate;
   79|   245k|    if (simdutf_unlikely(combined.any())) {
  ------------------
  |  |   93|   245k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 776, False: 244k]
  |  |  ------------------
  ------------------
   80|    776|      const size_t consumed = input - start;
   81|    776|      auto sr = scalar::utf32::validate_with_errors(input, end - input);
   82|    776|      sr.count += consumed;
   83|       |
   84|    776|      return sr;
   85|    776|    }
   86|       |
   87|   244k|    input += N;
   88|   244k|  }
   89|       |
   90|  1.41k|  const size_t consumed = input - start;
   91|  1.41k|  auto sr = scalar::utf32::validate_with_errors(input, end - input);
   92|  1.41k|  sr.count += consumed;
   93|       |
   94|  1.41k|  return sr;
   95|  2.19k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf328validateEPKDim:
    6|  2.21k|simdutf_really_inline bool validate(const char32_t *input, size_t size) {
    7|  2.21k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  2.21k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 22, False: 2.19k]
  |  |  ------------------
  ------------------
    8|       |    // empty input is valid UTF-32. protect the implementation from
    9|       |    // handling nullptr
   10|     22|    return true;
   11|     22|  }
   12|       |
   13|  2.19k|  const char32_t *end = input + size;
   14|       |
   15|  2.19k|  using vector_u32 = simd32<uint32_t>;
   16|       |
   17|  2.19k|  const auto standardmax = vector_u32::splat(0x10ffff);
   18|  2.19k|  const auto offset = vector_u32::splat(0xffff2000);
   19|  2.19k|  const auto standardoffsetmax = vector_u32::splat(0xfffff7ff);
   20|  2.19k|  auto currentmax = vector_u32::zero();
   21|  2.19k|  auto currentoffsetmax = vector_u32::zero();
   22|       |
   23|  2.19k|  constexpr size_t N = vector_u32::ELEMENTS;
   24|       |
   25|  2.12M|  while (input + N < end) {
  ------------------
  |  Branch (25:10): [True: 2.12M, False: 2.19k]
  ------------------
   26|  2.12M|    auto in = vector_u32(input);
   27|  2.12M|    if constexpr (!match_system(endianness::BIG)) {
   28|  2.12M|      in.swap_bytes();
   29|  2.12M|    }
   30|       |
   31|  2.12M|    currentmax = max(currentmax, in);
   32|  2.12M|    currentoffsetmax = max(currentoffsetmax, in + offset);
   33|  2.12M|    input += N;
   34|  2.12M|  }
   35|       |
   36|  2.19k|  const auto too_large = currentmax > standardmax;
   37|  2.19k|  if (too_large.any()) {
  ------------------
  |  Branch (37:7): [True: 890, False: 1.30k]
  ------------------
   38|    890|    return false;
   39|    890|  }
   40|       |
   41|  1.30k|  const auto surrogate = currentoffsetmax > standardoffsetmax;
   42|  1.30k|  if (surrogate.any()) {
  ------------------
  |  Branch (42:7): [True: 39, False: 1.26k]
  ------------------
   43|     39|    return false;
   44|     39|  }
   45|       |
   46|  1.26k|  return scalar::utf32::validate(input, end - input);
   47|  1.30k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_15utf3220validate_with_errorsEPKDim:
   51|  2.21k|                                                  size_t size) {
   52|  2.21k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  2.21k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 22, False: 2.19k]
  |  |  ------------------
  ------------------
   53|       |    // empty input is valid UTF-32. protect the implementation from
   54|       |    // handling nullptr
   55|     22|    return result(error_code::SUCCESS, 0);
   56|     22|  }
   57|       |
   58|  2.19k|  const char32_t *start = input;
   59|  2.19k|  const char32_t *end = input + size;
   60|       |
   61|  2.19k|  using vector_u32 = simd32<uint32_t>;
   62|       |
   63|  2.19k|  const auto standardmax = vector_u32::splat(0x10ffff + 1);
   64|  2.19k|  const auto surrogate_mask = vector_u32::splat(0xfffff800);
   65|  2.19k|  const auto surrogate_byte = vector_u32::splat(0x0000d800);
   66|       |
   67|  2.19k|  constexpr size_t N = vector_u32::ELEMENTS;
   68|       |
   69|   492k|  while (input + N < end) {
  ------------------
  |  Branch (69:10): [True: 491k, False: 1.26k]
  ------------------
   70|   491k|    auto in = vector_u32(input);
   71|   491k|    if constexpr (!match_system(endianness::BIG)) {
   72|   491k|      in.swap_bytes();
   73|   491k|    }
   74|       |
   75|   491k|    const auto too_large = in >= standardmax;
   76|   491k|    const auto surrogate = (in & surrogate_mask) == surrogate_byte;
   77|       |
   78|   491k|    const auto combined = too_large | surrogate;
   79|   491k|    if (simdutf_unlikely(combined.any())) {
  ------------------
  |  |   93|   491k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 929, False: 490k]
  |  |  ------------------
  ------------------
   80|    929|      const size_t consumed = input - start;
   81|    929|      auto sr = scalar::utf32::validate_with_errors(input, end - input);
   82|    929|      sr.count += consumed;
   83|       |
   84|    929|      return sr;
   85|    929|    }
   86|       |
   87|   490k|    input += N;
   88|   490k|  }
   89|       |
   90|  1.26k|  const size_t consumed = input - start;
   91|  1.26k|  auto sr = scalar::utf32::validate_with_errors(input, end - input);
   92|  1.26k|  sr.count += consumed;
   93|       |
   94|  1.26k|  return sr;
   95|  2.19k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_15utf328validateEPKDim:
    6|  2.23k|simdutf_really_inline bool validate(const char32_t *input, size_t size) {
    7|  2.23k|  if (simdutf_unlikely(size == 0)) {
  ------------------
  |  |   93|  2.23k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 22, False: 2.21k]
  |  |  ------------------
  ------------------
    8|       |    // empty input is valid UTF-32. protect the implementation from
    9|       |    // handling nullptr
   10|     22|    return true;
   11|     22|  }
   12|       |
   13|  2.21k|  const char32_t *end = input + size;
   14|       |
   15|  2.21k|  using vector_u32 = simd32<uint32_t>;
   16|       |
   17|  2.21k|  const auto standardmax = vector_u32::splat(0x10ffff);
   18|  2.21k|  const auto offset = vector_u32::splat(0xffff2000);
   19|  2.21k|  const auto standardoffsetmax = vector_u32::splat(0xfffff7ff);
   20|  2.21k|  auto currentmax = vector_u32::zero();
   21|  2.21k|  auto currentoffsetmax = vector_u32::zero();
   22|       |
   23|  2.21k|  constexpr size_t N = vector_u32::ELEMENTS;
   24|       |
   25|   424k|  while (input + N < end) {
  ------------------
  |  Branch (25:10): [True: 421k, False: 2.21k]
  ------------------
   26|   421k|    auto in = vector_u32(input);
   27|   421k|    if constexpr (!match_system(endianness::BIG)) {
   28|   421k|      in.swap_bytes();
   29|   421k|    }
   30|       |
   31|   421k|    currentmax = max(currentmax, in);
   32|   421k|    currentoffsetmax = max(currentoffsetmax, in + offset);
   33|   421k|    input += N;
   34|   421k|  }
   35|       |
   36|  2.21k|  const auto too_large = currentmax > standardmax;
   37|  2.21k|  if (too_large.any()) {
  ------------------
  |  Branch (37:7): [True: 736, False: 1.47k]
  ------------------
   38|    736|    return false;
   39|    736|  }
   40|       |
   41|  1.47k|  const auto surrogate = currentoffsetmax > standardoffsetmax;
   42|  1.47k|  if (surrogate.any()) {
  ------------------
  |  Branch (42:7): [True: 30, False: 1.44k]
  ------------------
   43|     30|    return false;
   44|     30|  }
   45|       |
   46|  1.44k|  return scalar::utf32::validate(input, end - input);
   47|  1.47k|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_128avx2_convert_latin1_to_utf16ILNS_10endiannessE0EEENSt3__14pairIPKcPDsEES7_mS8_:
    4|     98|                             char16_t *utf16_output) {
    5|     98|  size_t rounded_len = len & ~0xF; // Round down to nearest multiple of 16
    6|       |
    7|     98|  size_t i = 0;
    8|   317k|  for (; i < rounded_len; i += 16) {
  ------------------
  |  Branch (8:10): [True: 317k, False: 98]
  ------------------
    9|       |    // Load 16 bytes from the address (input + i) into a xmm register
   10|   317k|    const __m128i latin1 =
   11|   317k|        _mm_loadu_si128(reinterpret_cast<const __m128i *>(latin1_input + i));
   12|       |
   13|       |    // Zero extend each byte in `in` to word
   14|   317k|    __m256i utf16 = _mm256_cvtepu8_epi16(latin1);
   15|       |
   16|   317k|    if (big_endian) {
  ------------------
  |  Branch (16:9): [Folded, False: 317k]
  ------------------
   17|      0|      const __m128i swap128 =
   18|      0|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   19|      0|      const __m256i swap = _mm256_set_m128i(swap128, swap128);
  ------------------
  |  |    4|      0|      _mm256_permute2f128_si256(_mm256_castsi128_si256(xmm1),                  \
  |  |    5|      0|                                _mm256_castsi128_si256(xmm2), 2)
  ------------------
   20|      0|      utf16 = _mm256_shuffle_epi8(utf16, swap);
   21|      0|    }
   22|       |
   23|       |    // Store the contents of xmm1 into the address pointed by (output + i)
   24|   317k|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf16_output + i), utf16);
   25|   317k|  }
   26|       |
   27|     98|  return std::make_pair(latin1_input + rounded_len, utf16_output + rounded_len);
   28|     98|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_128avx2_convert_latin1_to_utf16ILNS_10endiannessE1EEENSt3__14pairIPKcPDsEES7_mS8_:
    4|     84|                             char16_t *utf16_output) {
    5|     84|  size_t rounded_len = len & ~0xF; // Round down to nearest multiple of 16
    6|       |
    7|     84|  size_t i = 0;
    8|  74.5k|  for (; i < rounded_len; i += 16) {
  ------------------
  |  Branch (8:10): [True: 74.4k, False: 84]
  ------------------
    9|       |    // Load 16 bytes from the address (input + i) into a xmm register
   10|  74.4k|    const __m128i latin1 =
   11|  74.4k|        _mm_loadu_si128(reinterpret_cast<const __m128i *>(latin1_input + i));
   12|       |
   13|       |    // Zero extend each byte in `in` to word
   14|  74.4k|    __m256i utf16 = _mm256_cvtepu8_epi16(latin1);
   15|       |
   16|  74.4k|    if (big_endian) {
  ------------------
  |  Branch (16:9): [True: 74.4k, Folded]
  ------------------
   17|  74.4k|      const __m128i swap128 =
   18|  74.4k|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   19|  74.4k|      const __m256i swap = _mm256_set_m128i(swap128, swap128);
  ------------------
  |  |    4|  74.4k|      _mm256_permute2f128_si256(_mm256_castsi128_si256(xmm1),                  \
  |  |    5|  74.4k|                                _mm256_castsi128_si256(xmm2), 2)
  ------------------
   20|  74.4k|      utf16 = _mm256_shuffle_epi8(utf16, swap);
   21|  74.4k|    }
   22|       |
   23|       |    // Store the contents of xmm1 into the address pointed by (output + i)
   24|  74.4k|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf16_output + i), utf16);
   25|  74.4k|  }
   26|       |
   27|     84|  return std::make_pair(latin1_input + rounded_len, utf16_output + rounded_len);
   28|     84|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_128avx2_convert_latin1_to_utf32EPKcmPDi:
    3|     70|                             char32_t *utf32_output) {
    4|     70|  size_t rounded_len = ((len | 7) ^ 7); // Round down to nearest multiple of 8
    5|       |
    6|   627k|  for (size_t i = 0; i < rounded_len; i += 8) {
  ------------------
  |  Branch (6:22): [True: 627k, False: 70]
  ------------------
    7|       |    // Load 8 Latin1 characters into a 64-bit register
    8|   627k|    __m128i in = _mm_loadl_epi64((__m128i *)&buf[i]);
    9|       |
   10|       |    // Zero extend each set of 8 Latin1 characters to 8 32-bit integers using
   11|       |    // vpmovzxbd
   12|   627k|    __m256i out = _mm256_cvtepu8_epi32(in);
   13|       |
   14|       |    // Store the results back to memory
   15|   627k|    _mm256_storeu_si256((__m256i *)&utf32_output[i], out);
   16|   627k|  }
   17|       |
   18|       |  // return pointers pointing to where we left off
   19|     70|  return std::make_pair(buf + rounded_len, utf32_output + rounded_len);
   20|     70|}

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

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_128avx2_convert_utf16_to_latin1ILNS_10endiannessE0EEENSt3__14pairIPKDsPcEES7_mS8_:
    4|    110|                             char *latin1_output) {
    5|    110|  const char16_t *end = buf + len;
    6|    300|  while (end - buf >= 32) {
  ------------------
  |  Branch (6:10): [True: 210, False: 90]
  ------------------
    7|       |    // Load 16 UTF-16 characters into 256-bit AVX2 register
    8|    210|    __m256i in0 = _mm256_loadu_si256(reinterpret_cast<const __m256i *>(buf));
    9|    210|    __m256i in1 =
   10|    210|        _mm256_loadu_si256(reinterpret_cast<const __m256i *>(buf + 16));
   11|       |
   12|       |    if constexpr (!match_system(big_endian)) {
   13|       |      const __m256i swap = _mm256_setr_epi8(
   14|       |          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
   15|       |          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
   16|       |      in0 = _mm256_shuffle_epi8(in0, swap);
   17|       |      in1 = _mm256_shuffle_epi8(in1, swap);
   18|       |    }
   19|       |
   20|    210|    __m256i high_byte_mask = _mm256_set1_epi16((int16_t)0xFF00);
   21|    210|    if (_mm256_testz_si256(_mm256_or_si256(in0, in1), high_byte_mask)) {
  ------------------
  |  Branch (21:9): [True: 190, False: 20]
  ------------------
   22|       |      // Pack 16-bit characters into 8-bit and store in latin1_output
   23|    190|      const __m256i packed = _mm256_packus_epi16(in0, in1);
   24|       |
   25|    190|      const __m256i result = _mm256_permute4x64_epi64(packed, 0b11011000);
   26|       |
   27|    190|      _mm256_storeu_si256(reinterpret_cast<__m256i *>(latin1_output), result);
   28|       |      // Adjust pointers for the next iteration
   29|    190|      buf += 32;
   30|    190|      latin1_output += 32;
   31|    190|    } else {
   32|     20|      return std::make_pair(nullptr, reinterpret_cast<char *>(latin1_output));
   33|     20|    }
   34|    210|  } // while
   35|     90|  return std::make_pair(buf, latin1_output);
   36|    110|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_128avx2_convert_utf16_to_latin1ILNS_10endiannessE1EEENSt3__14pairIPKDsPcEES7_mS8_:
    4|    126|                             char *latin1_output) {
    5|    126|  const char16_t *end = buf + len;
    6|    446|  while (end - buf >= 32) {
  ------------------
  |  Branch (6:10): [True: 346, False: 100]
  ------------------
    7|       |    // Load 16 UTF-16 characters into 256-bit AVX2 register
    8|    346|    __m256i in0 = _mm256_loadu_si256(reinterpret_cast<const __m256i *>(buf));
    9|    346|    __m256i in1 =
   10|    346|        _mm256_loadu_si256(reinterpret_cast<const __m256i *>(buf + 16));
   11|       |
   12|    346|    if constexpr (!match_system(big_endian)) {
   13|    346|      const __m256i swap = _mm256_setr_epi8(
   14|    346|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
   15|    346|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
   16|    346|      in0 = _mm256_shuffle_epi8(in0, swap);
   17|    346|      in1 = _mm256_shuffle_epi8(in1, swap);
   18|    346|    }
   19|       |
   20|    346|    __m256i high_byte_mask = _mm256_set1_epi16((int16_t)0xFF00);
   21|    346|    if (_mm256_testz_si256(_mm256_or_si256(in0, in1), high_byte_mask)) {
  ------------------
  |  Branch (21:9): [True: 320, False: 26]
  ------------------
   22|       |      // Pack 16-bit characters into 8-bit and store in latin1_output
   23|    320|      const __m256i packed = _mm256_packus_epi16(in0, in1);
   24|       |
   25|    320|      const __m256i result = _mm256_permute4x64_epi64(packed, 0b11011000);
   26|       |
   27|    320|      _mm256_storeu_si256(reinterpret_cast<__m256i *>(latin1_output), result);
   28|       |      // Adjust pointers for the next iteration
   29|    320|      buf += 32;
   30|    320|      latin1_output += 32;
   31|    320|    } else {
   32|     26|      return std::make_pair(nullptr, reinterpret_cast<char *>(latin1_output));
   33|     26|    }
   34|    346|  } // while
   35|    100|  return std::make_pair(buf, latin1_output);
   36|    126|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_140avx2_convert_utf16_to_latin1_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPcEEPKDsmS7_:
   41|    210|                                         char *latin1_output) {
   42|    210|  const char16_t *start = buf;
   43|    210|  const char16_t *end = buf + len;
   44|   451k|  while (end - buf >= 16) {
  ------------------
  |  Branch (44:10): [True: 451k, False: 120]
  ------------------
   45|   451k|    __m256i in = _mm256_loadu_si256(reinterpret_cast<const __m256i *>(buf));
   46|       |
   47|       |    if constexpr (!match_system(big_endian)) {
   48|       |      const __m256i swap = _mm256_setr_epi8(
   49|       |          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
   50|       |          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
   51|       |      in = _mm256_shuffle_epi8(in, swap);
   52|       |    }
   53|       |
   54|   451k|    __m256i high_byte_mask = _mm256_set1_epi16((int16_t)0xFF00);
   55|   451k|    if (_mm256_testz_si256(in, high_byte_mask)) {
  ------------------
  |  Branch (55:9): [True: 451k, False: 90]
  ------------------
   56|   451k|      __m128i lo = _mm256_extractf128_si256(in, 0);
   57|   451k|      __m128i hi = _mm256_extractf128_si256(in, 1);
   58|   451k|      __m128i latin1_packed_lo = _mm_packus_epi16(lo, lo);
   59|   451k|      __m128i latin1_packed_hi = _mm_packus_epi16(hi, hi);
   60|   451k|      _mm_storel_epi64(reinterpret_cast<__m128i *>(latin1_output),
   61|   451k|                       latin1_packed_lo);
   62|   451k|      _mm_storel_epi64(reinterpret_cast<__m128i *>(latin1_output + 8),
   63|   451k|                       latin1_packed_hi);
   64|   451k|      buf += 16;
   65|   451k|      latin1_output += 16;
   66|   451k|    } else {
   67|       |      // Fallback to scalar code for handling errors
   68|    440|      for (int k = 0; k < 16; k++) {
  ------------------
  |  Branch (68:23): [True: 440, False: 0]
  ------------------
   69|    440|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
   70|    440|        if (word <= 0xff) {
  ------------------
  |  Branch (70:13): [True: 350, False: 90]
  ------------------
   71|    350|          *latin1_output++ = char(word);
   72|    350|        } else {
   73|     90|          return std::make_pair(
   74|     90|              result{error_code::TOO_LARGE, (size_t)(buf - start + k)},
   75|     90|              latin1_output);
   76|     90|        }
   77|    440|      }
   78|      0|      buf += 16;
   79|      0|    }
   80|   451k|  } // while
   81|    120|  return std::make_pair(result{error_code::SUCCESS, (size_t)(buf - start)},
   82|    120|                        latin1_output);
   83|    210|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_140avx2_convert_utf16_to_latin1_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPcEEPKDsmS7_:
   41|    262|                                         char *latin1_output) {
   42|    262|  const char16_t *start = buf;
   43|    262|  const char16_t *end = buf + len;
   44|   330k|  while (end - buf >= 16) {
  ------------------
  |  Branch (44:10): [True: 330k, False: 128]
  ------------------
   45|   330k|    __m256i in = _mm256_loadu_si256(reinterpret_cast<const __m256i *>(buf));
   46|       |
   47|   330k|    if constexpr (!match_system(big_endian)) {
   48|   330k|      const __m256i swap = _mm256_setr_epi8(
   49|   330k|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
   50|   330k|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
   51|   330k|      in = _mm256_shuffle_epi8(in, swap);
   52|   330k|    }
   53|       |
   54|   330k|    __m256i high_byte_mask = _mm256_set1_epi16((int16_t)0xFF00);
   55|   330k|    if (_mm256_testz_si256(in, high_byte_mask)) {
  ------------------
  |  Branch (55:9): [True: 329k, False: 134]
  ------------------
   56|   329k|      __m128i lo = _mm256_extractf128_si256(in, 0);
   57|   329k|      __m128i hi = _mm256_extractf128_si256(in, 1);
   58|   329k|      __m128i latin1_packed_lo = _mm_packus_epi16(lo, lo);
   59|   329k|      __m128i latin1_packed_hi = _mm_packus_epi16(hi, hi);
   60|   329k|      _mm_storel_epi64(reinterpret_cast<__m128i *>(latin1_output),
   61|   329k|                       latin1_packed_lo);
   62|   329k|      _mm_storel_epi64(reinterpret_cast<__m128i *>(latin1_output + 8),
   63|   329k|                       latin1_packed_hi);
   64|   329k|      buf += 16;
   65|   329k|      latin1_output += 16;
   66|   329k|    } else {
   67|       |      // Fallback to scalar code for handling errors
   68|    530|      for (int k = 0; k < 16; k++) {
  ------------------
  |  Branch (68:23): [True: 530, False: 0]
  ------------------
   69|    530|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
   70|    530|        if (word <= 0xff) {
  ------------------
  |  Branch (70:13): [True: 396, False: 134]
  ------------------
   71|    396|          *latin1_output++ = char(word);
   72|    396|        } else {
   73|    134|          return std::make_pair(
   74|    134|              result{error_code::TOO_LARGE, (size_t)(buf - start + k)},
   75|    134|              latin1_output);
   76|    134|        }
   77|    530|      }
   78|      0|      buf += 16;
   79|      0|    }
   80|   330k|  } // while
   81|    128|  return std::make_pair(result{error_code::SUCCESS, (size_t)(buf - start)},
   82|    128|                        latin1_output);
   83|    262|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_127avx2_convert_utf16_to_utf32ILNS_10endiannessE0EEENSt3__14pairIPKDsPDiEES7_mS8_:
   57|    380|                            char32_t *utf32_output) {
   58|    380|  const char16_t *end = buf + len;
   59|    380|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
   60|    380|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
   61|       |
   62|   133k|  while (end - buf >= 16) {
  ------------------
  |  Branch (62:10): [True: 132k, False: 282]
  ------------------
   63|   132k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
   64|   132k|    if (big_endian) {
  ------------------
  |  Branch (64:9): [Folded, False: 132k]
  ------------------
   65|      0|      const __m256i swap = _mm256_setr_epi8(
   66|      0|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
   67|      0|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
   68|      0|      in = _mm256_shuffle_epi8(in, swap);
   69|      0|    }
   70|       |
   71|       |    // 1. Check if there are any surrogate word in the input chunk.
   72|       |    //    We have also deal with situation when there is a surrogate word
   73|       |    //    at the end of a chunk.
   74|   132k|    const __m256i surrogates_bytemask =
   75|   132k|        _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_d800);
   76|       |
   77|       |    // bitmask = 0x0000 if there are no surrogates
   78|       |    //         = 0xc000 if the last word is a surrogate
   79|   132k|    const uint32_t surrogates_bitmask =
   80|   132k|        static_cast<uint32_t>(_mm256_movemask_epi8(surrogates_bytemask));
   81|       |    // It might seem like checking for surrogates_bitmask == 0xc000 could help.
   82|       |    // However, it is likely an uncommon occurrence.
   83|   132k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (83:9): [True: 128k, False: 4.28k]
  ------------------
   84|       |      // case: we extend all sixteen 16-bit code units to sixteen 32-bit code
   85|       |      // units
   86|   128k|      _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output),
   87|   128k|                          _mm256_cvtepu16_epi32(_mm256_castsi256_si128(in)));
   88|   128k|      _mm256_storeu_si256(
   89|   128k|          reinterpret_cast<__m256i *>(utf32_output + 8),
   90|   128k|          _mm256_cvtepu16_epi32(_mm256_extractf128_si256(in, 1)));
   91|   128k|      utf32_output += 16;
   92|   128k|      buf += 16;
   93|       |      // surrogate pair(s) in a register
   94|   128k|    } else {
   95|       |      // Let us do a scalar fallback.
   96|       |      // It may seem wasteful to use scalar code, but being efficient with SIMD
   97|       |      // in the presence of surrogate pairs may require non-trivial tables.
   98|  4.28k|      size_t forward = 15;
   99|  4.28k|      size_t k = 0;
  100|  4.28k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (100:11): [True: 0, False: 4.28k]
  ------------------
  101|      0|        forward = size_t(end - buf - 1);
  102|      0|      }
  103|  62.8k|      for (; k < forward; k++) {
  ------------------
  |  Branch (103:14): [True: 58.6k, False: 4.19k]
  ------------------
  104|  58.6k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  105|  58.6k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (105:13): [True: 53.4k, False: 5.18k]
  ------------------
  106|       |          // No surrogate pair
  107|  53.4k|          *utf32_output++ = char32_t(word);
  108|  53.4k|        } else {
  109|       |          // must be a surrogate pair
  110|  5.18k|          uint16_t diff = uint16_t(word - 0xD800);
  111|  5.18k|          uint16_t next_word =
  112|  5.18k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  113|  5.18k|          k++;
  114|  5.18k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  115|  5.18k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (115:15): [True: 98, False: 5.08k]
  ------------------
  116|     98|            return std::make_pair(nullptr, utf32_output);
  117|     98|          }
  118|  5.08k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  119|  5.08k|          *utf32_output++ = char32_t(value);
  120|  5.08k|        }
  121|  58.6k|      }
  122|  4.19k|      buf += k;
  123|  4.19k|    }
  124|   132k|  } // while
  125|    282|  return std::make_pair(buf, utf32_output);
  126|    380|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_127avx2_convert_utf16_to_utf32ILNS_10endiannessE1EEENSt3__14pairIPKDsPDiEES7_mS8_:
   57|    394|                            char32_t *utf32_output) {
   58|    394|  const char16_t *end = buf + len;
   59|    394|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
   60|    394|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
   61|       |
   62|   418k|  while (end - buf >= 16) {
  ------------------
  |  Branch (62:10): [True: 418k, False: 294]
  ------------------
   63|   418k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
   64|   418k|    if (big_endian) {
  ------------------
  |  Branch (64:9): [True: 418k, Folded]
  ------------------
   65|   418k|      const __m256i swap = _mm256_setr_epi8(
   66|   418k|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
   67|   418k|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
   68|   418k|      in = _mm256_shuffle_epi8(in, swap);
   69|   418k|    }
   70|       |
   71|       |    // 1. Check if there are any surrogate word in the input chunk.
   72|       |    //    We have also deal with situation when there is a surrogate word
   73|       |    //    at the end of a chunk.
   74|   418k|    const __m256i surrogates_bytemask =
   75|   418k|        _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_d800);
   76|       |
   77|       |    // bitmask = 0x0000 if there are no surrogates
   78|       |    //         = 0xc000 if the last word is a surrogate
   79|   418k|    const uint32_t surrogates_bitmask =
   80|   418k|        static_cast<uint32_t>(_mm256_movemask_epi8(surrogates_bytemask));
   81|       |    // It might seem like checking for surrogates_bitmask == 0xc000 could help.
   82|       |    // However, it is likely an uncommon occurrence.
   83|   418k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (83:9): [True: 412k, False: 5.17k]
  ------------------
   84|       |      // case: we extend all sixteen 16-bit code units to sixteen 32-bit code
   85|       |      // units
   86|   412k|      _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output),
   87|   412k|                          _mm256_cvtepu16_epi32(_mm256_castsi256_si128(in)));
   88|   412k|      _mm256_storeu_si256(
   89|   412k|          reinterpret_cast<__m256i *>(utf32_output + 8),
   90|   412k|          _mm256_cvtepu16_epi32(_mm256_extractf128_si256(in, 1)));
   91|   412k|      utf32_output += 16;
   92|   412k|      buf += 16;
   93|       |      // surrogate pair(s) in a register
   94|   412k|    } else {
   95|       |      // Let us do a scalar fallback.
   96|       |      // It may seem wasteful to use scalar code, but being efficient with SIMD
   97|       |      // in the presence of surrogate pairs may require non-trivial tables.
   98|  5.17k|      size_t forward = 15;
   99|  5.17k|      size_t k = 0;
  100|  5.17k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (100:11): [True: 0, False: 5.17k]
  ------------------
  101|      0|        forward = size_t(end - buf - 1);
  102|      0|      }
  103|  76.1k|      for (; k < forward; k++) {
  ------------------
  |  Branch (103:14): [True: 71.0k, False: 5.07k]
  ------------------
  104|  71.0k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  105|  71.0k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (105:13): [True: 65.1k, False: 5.95k]
  ------------------
  106|       |          // No surrogate pair
  107|  65.1k|          *utf32_output++ = char32_t(word);
  108|  65.1k|        } else {
  109|       |          // must be a surrogate pair
  110|  5.95k|          uint16_t diff = uint16_t(word - 0xD800);
  111|  5.95k|          uint16_t next_word =
  112|  5.95k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  113|  5.95k|          k++;
  114|  5.95k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  115|  5.95k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (115:15): [True: 100, False: 5.85k]
  ------------------
  116|    100|            return std::make_pair(nullptr, utf32_output);
  117|    100|          }
  118|  5.85k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  119|  5.85k|          *utf32_output++ = char32_t(value);
  120|  5.85k|        }
  121|  71.0k|      }
  122|  5.07k|      buf += k;
  123|  5.07k|    }
  124|   418k|  } // while
  125|    294|  return std::make_pair(buf, utf32_output);
  126|    394|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_139avx2_convert_utf16_to_utf32_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPDiEEPKDsmS7_:
  138|    396|                                        char32_t *utf32_output) {
  139|    396|  const char16_t *start = buf;
  140|    396|  const char16_t *end = buf + len;
  141|    396|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
  142|    396|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
  143|       |
  144|   237k|  while (end - buf >= 16) {
  ------------------
  |  Branch (144:10): [True: 237k, False: 252]
  ------------------
  145|   237k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
  146|   237k|    if (big_endian) {
  ------------------
  |  Branch (146:9): [Folded, False: 237k]
  ------------------
  147|      0|      const __m256i swap = _mm256_setr_epi8(
  148|      0|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
  149|      0|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
  150|      0|      in = _mm256_shuffle_epi8(in, swap);
  151|      0|    }
  152|       |
  153|       |    // 1. Check if there are any surrogate word in the input chunk.
  154|       |    //    We have also deal with situation when there is a surrogate word
  155|       |    //    at the end of a chunk.
  156|   237k|    const __m256i surrogates_bytemask =
  157|   237k|        _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_d800);
  158|       |
  159|       |    // bitmask = 0x0000 if there are no surrogates
  160|       |    //         = 0xc000 if the last word is a surrogate
  161|   237k|    const uint32_t surrogates_bitmask =
  162|   237k|        static_cast<uint32_t>(_mm256_movemask_epi8(surrogates_bytemask));
  163|       |    // It might seem like checking for surrogates_bitmask == 0xc000 could help.
  164|       |    // However, it is likely an uncommon occurrence.
  165|   237k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (165:9): [True: 232k, False: 5.33k]
  ------------------
  166|       |      // case: we extend all sixteen 16-bit code units to sixteen 32-bit code
  167|       |      // units
  168|   232k|      _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output),
  169|   232k|                          _mm256_cvtepu16_epi32(_mm256_castsi256_si128(in)));
  170|   232k|      _mm256_storeu_si256(
  171|   232k|          reinterpret_cast<__m256i *>(utf32_output + 8),
  172|   232k|          _mm256_cvtepu16_epi32(_mm256_extractf128_si256(in, 1)));
  173|   232k|      utf32_output += 16;
  174|   232k|      buf += 16;
  175|       |      // surrogate pair(s) in a register
  176|   232k|    } else {
  177|       |      // Let us do a scalar fallback.
  178|       |      // It may seem wasteful to use scalar code, but being efficient with SIMD
  179|       |      // in the presence of surrogate pairs may require non-trivial tables.
  180|  5.33k|      size_t forward = 15;
  181|  5.33k|      size_t k = 0;
  182|  5.33k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (182:11): [True: 0, False: 5.33k]
  ------------------
  183|      0|        forward = size_t(end - buf - 1);
  184|      0|      }
  185|  78.0k|      for (; k < forward; k++) {
  ------------------
  |  Branch (185:14): [True: 72.8k, False: 5.19k]
  ------------------
  186|  72.8k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  187|  72.8k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (187:13): [True: 66.7k, False: 6.14k]
  ------------------
  188|       |          // No surrogate pair
  189|  66.7k|          *utf32_output++ = char32_t(word);
  190|  66.7k|        } else {
  191|       |          // must be a surrogate pair
  192|  6.14k|          uint16_t diff = uint16_t(word - 0xD800);
  193|  6.14k|          uint16_t next_word =
  194|  6.14k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  195|  6.14k|          k++;
  196|  6.14k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  197|  6.14k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (197:15): [True: 144, False: 6.00k]
  ------------------
  198|    144|            return std::make_pair(
  199|    144|                result(error_code::SURROGATE, buf - start + k - 1),
  200|    144|                utf32_output);
  201|    144|          }
  202|  6.00k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  203|  6.00k|          *utf32_output++ = char32_t(value);
  204|  6.00k|        }
  205|  72.8k|      }
  206|  5.19k|      buf += k;
  207|  5.19k|    }
  208|   237k|  } // while
  209|    252|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf32_output);
  210|    396|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_139avx2_convert_utf16_to_utf32_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPDiEEPKDsmS7_:
  138|    380|                                        char32_t *utf32_output) {
  139|    380|  const char16_t *start = buf;
  140|    380|  const char16_t *end = buf + len;
  141|    380|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
  142|    380|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
  143|       |
  144|   156k|  while (end - buf >= 16) {
  ------------------
  |  Branch (144:10): [True: 155k, False: 242]
  ------------------
  145|   155k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
  146|   155k|    if (big_endian) {
  ------------------
  |  Branch (146:9): [True: 155k, Folded]
  ------------------
  147|   155k|      const __m256i swap = _mm256_setr_epi8(
  148|   155k|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
  149|   155k|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
  150|   155k|      in = _mm256_shuffle_epi8(in, swap);
  151|   155k|    }
  152|       |
  153|       |    // 1. Check if there are any surrogate word in the input chunk.
  154|       |    //    We have also deal with situation when there is a surrogate word
  155|       |    //    at the end of a chunk.
  156|   155k|    const __m256i surrogates_bytemask =
  157|   155k|        _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_d800);
  158|       |
  159|       |    // bitmask = 0x0000 if there are no surrogates
  160|       |    //         = 0xc000 if the last word is a surrogate
  161|   155k|    const uint32_t surrogates_bitmask =
  162|   155k|        static_cast<uint32_t>(_mm256_movemask_epi8(surrogates_bytemask));
  163|       |    // It might seem like checking for surrogates_bitmask == 0xc000 could help.
  164|       |    // However, it is likely an uncommon occurrence.
  165|   155k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (165:9): [True: 152k, False: 2.97k]
  ------------------
  166|       |      // case: we extend all sixteen 16-bit code units to sixteen 32-bit code
  167|       |      // units
  168|   152k|      _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output),
  169|   152k|                          _mm256_cvtepu16_epi32(_mm256_castsi256_si128(in)));
  170|   152k|      _mm256_storeu_si256(
  171|   152k|          reinterpret_cast<__m256i *>(utf32_output + 8),
  172|   152k|          _mm256_cvtepu16_epi32(_mm256_extractf128_si256(in, 1)));
  173|   152k|      utf32_output += 16;
  174|   152k|      buf += 16;
  175|       |      // surrogate pair(s) in a register
  176|   152k|    } else {
  177|       |      // Let us do a scalar fallback.
  178|       |      // It may seem wasteful to use scalar code, but being efficient with SIMD
  179|       |      // in the presence of surrogate pairs may require non-trivial tables.
  180|  2.97k|      size_t forward = 15;
  181|  2.97k|      size_t k = 0;
  182|  2.97k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (182:11): [True: 0, False: 2.97k]
  ------------------
  183|      0|        forward = size_t(end - buf - 1);
  184|      0|      }
  185|  40.5k|      for (; k < forward; k++) {
  ------------------
  |  Branch (185:14): [True: 37.7k, False: 2.83k]
  ------------------
  186|  37.7k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  187|  37.7k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (187:13): [True: 31.4k, False: 6.30k]
  ------------------
  188|       |          // No surrogate pair
  189|  31.4k|          *utf32_output++ = char32_t(word);
  190|  31.4k|        } else {
  191|       |          // must be a surrogate pair
  192|  6.30k|          uint16_t diff = uint16_t(word - 0xD800);
  193|  6.30k|          uint16_t next_word =
  194|  6.30k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  195|  6.30k|          k++;
  196|  6.30k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  197|  6.30k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (197:15): [True: 138, False: 6.16k]
  ------------------
  198|    138|            return std::make_pair(
  199|    138|                result(error_code::SURROGATE, buf - start + k - 1),
  200|    138|                utf32_output);
  201|    138|          }
  202|  6.16k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  203|  6.16k|          *utf32_output++ = char32_t(value);
  204|  6.16k|        }
  205|  37.7k|      }
  206|  2.83k|      buf += k;
  207|  2.83k|    }
  208|   155k|  } // while
  209|    242|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf32_output);
  210|    380|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_126avx2_convert_utf16_to_utf8ILNS_10endiannessE0EEENSt3__14pairIPKDsPcEES7_mS8_:
   56|    802|avx2_convert_utf16_to_utf8(const char16_t *buf, size_t len, char *utf8_output) {
   57|    802|  const char16_t *end = buf + len;
   58|    802|  const __m256i v_0000 = _mm256_setzero_si256();
   59|    802|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
   60|    802|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
   61|    802|  const __m256i v_c080 = _mm256_set1_epi16((int16_t)0xc080);
   62|    802|  const size_t safety_margin =
   63|    802|      12; // to avoid overruns, see issue
   64|       |          // https://github.com/simdutf/simdutf/issues/92
   65|       |
   66|  1.22M|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (66:10): [True: 1.22M, False: 694]
  ------------------
   67|  1.22M|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
   68|  1.22M|    if (big_endian) {
  ------------------
  |  Branch (68:9): [Folded, False: 1.22M]
  ------------------
   69|      0|      const __m256i swap = _mm256_setr_epi8(
   70|      0|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
   71|      0|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
   72|      0|      in = _mm256_shuffle_epi8(in, swap);
   73|      0|    }
   74|       |    // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes
   75|  1.22M|    const __m256i v_ff80 = _mm256_set1_epi16((int16_t)0xff80);
   76|  1.22M|    if (_mm256_testz_si256(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (76:9): [True: 855k, False: 373k]
  ------------------
   77|       |      // 1. pack the bytes
   78|   855k|      const __m128i utf8_packed = _mm_packus_epi16(
   79|   855k|          _mm256_castsi256_si128(in), _mm256_extractf128_si256(in, 1));
   80|       |      // 2. store (16 bytes)
   81|   855k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   82|       |      // 3. adjust pointers
   83|   855k|      buf += 16;
   84|   855k|      utf8_output += 16;
   85|   855k|      continue; // we are done for this round!
   86|   855k|    }
   87|       |    // no bits set above 7th bit
   88|   373k|    const __m256i one_byte_bytemask =
   89|   373k|        _mm256_cmpeq_epi16(_mm256_and_si256(in, v_ff80), v_0000);
   90|   373k|    const uint32_t one_byte_bitmask =
   91|   373k|        static_cast<uint32_t>(_mm256_movemask_epi8(one_byte_bytemask));
   92|       |
   93|       |    // no bits set above 11th bit
   94|   373k|    const __m256i one_or_two_bytes_bytemask =
   95|   373k|        _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_0000);
   96|   373k|    const uint32_t one_or_two_bytes_bitmask =
   97|   373k|        static_cast<uint32_t>(_mm256_movemask_epi8(one_or_two_bytes_bytemask));
   98|   373k|    if (one_or_two_bytes_bitmask == 0xffffffff) {
  ------------------
  |  Branch (98:9): [True: 40.4k, False: 333k]
  ------------------
   99|       |
  100|       |      // 1. prepare 2-byte values
  101|       |      // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8
  102|       |      // expected output   : [110a|aaaa|10bb|bbbb] x 8
  103|  40.4k|      const __m256i v_1f00 = _mm256_set1_epi16((int16_t)0x1f00);
  104|  40.4k|      const __m256i v_003f = _mm256_set1_epi16((int16_t)0x003f);
  105|       |
  106|       |      // t0 = [000a|aaaa|bbbb|bb00]
  107|  40.4k|      const __m256i t0 = _mm256_slli_epi16(in, 2);
  108|       |      // t1 = [000a|aaaa|0000|0000]
  109|  40.4k|      const __m256i t1 = _mm256_and_si256(t0, v_1f00);
  110|       |      // t2 = [0000|0000|00bb|bbbb]
  111|  40.4k|      const __m256i t2 = _mm256_and_si256(in, v_003f);
  112|       |      // t3 = [000a|aaaa|00bb|bbbb]
  113|  40.4k|      const __m256i t3 = _mm256_or_si256(t1, t2);
  114|       |      // t4 = [110a|aaaa|10bb|bbbb]
  115|  40.4k|      const __m256i t4 = _mm256_or_si256(t3, v_c080);
  116|       |
  117|       |      // 2. merge ASCII and 2-byte codewords
  118|  40.4k|      const __m256i utf8_unpacked =
  119|  40.4k|          _mm256_blendv_epi8(t4, in, one_byte_bytemask);
  120|       |
  121|       |      // 3. prepare bitmask for 8-bit lookup
  122|  40.4k|      const uint32_t M0 = one_byte_bitmask & 0x55555555;
  123|  40.4k|      const uint32_t M1 = M0 >> 7;
  124|  40.4k|      const uint32_t M2 = (M1 | M0) & 0x00ff00ff;
  125|       |      // 4. pack the bytes
  126|       |
  127|  40.4k|      const uint8_t *row =
  128|  40.4k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2)][0];
  129|  40.4k|      const uint8_t *row_2 =
  130|  40.4k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2 >>
  131|  40.4k|                                                                       16)][0];
  132|       |
  133|  40.4k|      const __m128i shuffle = _mm_loadu_si128((__m128i *)(row + 1));
  134|  40.4k|      const __m128i shuffle_2 = _mm_loadu_si128((__m128i *)(row_2 + 1));
  135|       |
  136|  40.4k|      const __m256i utf8_packed = _mm256_shuffle_epi8(
  137|  40.4k|          utf8_unpacked, _mm256_setr_m128i(shuffle, shuffle_2));
  ------------------
  |  |    7|  40.4k|      _mm256_permute2f128_si256(_mm256_castsi128_si256(xmm1),                  \
  |  |    8|  40.4k|                                _mm256_castsi128_si256(xmm2), 2)
  ------------------
  138|       |      // 5. store bytes
  139|  40.4k|      _mm_storeu_si128((__m128i *)utf8_output,
  140|  40.4k|                       _mm256_castsi256_si128(utf8_packed));
  141|  40.4k|      utf8_output += row[0];
  142|  40.4k|      _mm_storeu_si128((__m128i *)utf8_output,
  143|  40.4k|                       _mm256_extractf128_si256(utf8_packed, 1));
  144|  40.4k|      utf8_output += row_2[0];
  145|       |
  146|       |      // 6. adjust pointers
  147|  40.4k|      buf += 16;
  148|  40.4k|      continue;
  149|  40.4k|    }
  150|       |    // 1. Check if there are any surrogate word in the input chunk.
  151|       |    //    We have also deal with situation when there is a surrogate word
  152|       |    //    at the end of a chunk.
  153|   333k|    const __m256i surrogates_bytemask =
  154|   333k|        _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_d800);
  155|       |
  156|       |    // bitmask = 0x0000 if there are no surrogates
  157|       |    //         = 0xc000 if the last word is a surrogate
  158|   333k|    const uint32_t surrogates_bitmask =
  159|   333k|        static_cast<uint32_t>(_mm256_movemask_epi8(surrogates_bytemask));
  160|       |    // It might seem like checking for surrogates_bitmask == 0xc000 could help.
  161|       |    // However, it is likely an uncommon occurrence.
  162|   333k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (162:9): [True: 325k, False: 8.01k]
  ------------------
  163|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  164|   325k|      const __m256i dup_even = _mm256_setr_epi16(
  165|   325k|          0x0000, 0x0202, 0x0404, 0x0606, 0x0808, 0x0a0a, 0x0c0c, 0x0e0e,
  166|   325k|          0x0000, 0x0202, 0x0404, 0x0606, 0x0808, 0x0a0a, 0x0c0c, 0x0e0e);
  167|       |
  168|       |      /* In this branch we handle three cases:
  169|       |         1. [0000|0000|0ccc|cccc] => [0ccc|cccc]                           -
  170|       |        single UFT-8 byte
  171|       |         2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc]              - two
  172|       |        UTF-8 bytes
  173|       |         3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] -
  174|       |        three UTF-8 bytes
  175|       |
  176|       |        We expand the input word (16-bit) into two code units (32-bit), thus
  177|       |        we have room for four bytes. However, we need five distinct bit
  178|       |        layouts. Note that the last byte in cases #2 and #3 is the same.
  179|       |
  180|       |        We precompute byte 1 for case #1 and the common byte for cases #2 & #3
  181|       |        in register t2.
  182|       |
  183|       |        We precompute byte 1 for case #3 and -- **conditionally** -- precompute
  184|       |        either byte 1 for case #2 or byte 2 for case #3. Note that they
  185|       |        differ by exactly one bit.
  186|       |
  187|       |        Finally from these two code units we build proper UTF-8 sequence, taking
  188|       |        into account the case (i.e, the number of bytes to write).
  189|       |      */
  190|       |      /**
  191|       |       * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce:
  192|       |       * t2 => [0ccc|cccc] [10cc|cccc]
  193|       |       * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb])
  194|       |       */
  195|   325k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  196|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  197|   325k|      const __m256i t0 = _mm256_shuffle_epi8(in, dup_even);
  198|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  199|   325k|      const __m256i t1 = _mm256_and_si256(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  195|   325k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  200|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  201|   325k|      const __m256i t2 = _mm256_or_si256(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  195|   325k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  202|       |
  203|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  204|   325k|      const __m256i s0 = _mm256_srli_epi16(in, 4);
  205|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  206|   325k|      const __m256i s1 = _mm256_and_si256(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  195|   325k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  207|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  208|   325k|      const __m256i s2 = _mm256_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  195|   325k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  209|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  210|   325k|      const __m256i s3 = _mm256_or_si256(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  195|   325k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  211|   325k|      const __m256i m0 = _mm256_andnot_si256(one_or_two_bytes_bytemask,
  212|   325k|                                             simdutf_vec(0b0100000000000000));
  ------------------
  |  |  195|   325k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  213|   325k|      const __m256i s4 = _mm256_xor_si256(s3, m0);
  214|   325k|#undef simdutf_vec
  215|       |
  216|       |      // 4. expand code units 16-bit => 32-bit
  217|   325k|      const __m256i out0 = _mm256_unpacklo_epi16(t2, s4);
  218|   325k|      const __m256i out1 = _mm256_unpackhi_epi16(t2, s4);
  219|       |
  220|       |      // 5. compress 32-bit code units into 1, 2 or 3 bytes -- 2 x shuffle
  221|   325k|      const uint32_t mask = (one_byte_bitmask & 0x55555555) |
  222|   325k|                            (one_or_two_bytes_bitmask & 0xaaaaaaaa);
  223|       |      // Due to the wider registers, the following path is less likely to be
  224|       |      // useful.
  225|       |      /*if(mask == 0) {
  226|       |        // We only have three-byte code units. Use fast path.
  227|       |        const __m256i shuffle =
  228|       |      _mm256_setr_epi8(2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1,
  229|       |      2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1); const __m256i utf8_0 =
  230|       |      _mm256_shuffle_epi8(out0, shuffle); const __m256i utf8_1 =
  231|       |      _mm256_shuffle_epi8(out1, shuffle);
  232|       |        _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_0));
  233|       |        utf8_output += 12;
  234|       |        _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_1));
  235|       |        utf8_output += 12;
  236|       |        _mm_storeu_si128((__m128i*)utf8_output,
  237|       |      _mm256_extractf128_si256(utf8_0,1)); utf8_output += 12;
  238|       |        _mm_storeu_si128((__m128i*)utf8_output,
  239|       |      _mm256_extractf128_si256(utf8_1,1)); utf8_output += 12; buf += 16;
  240|       |        continue;
  241|       |      }*/
  242|   325k|      const uint8_t mask0 = uint8_t(mask);
  243|   325k|      const uint8_t *row0 =
  244|   325k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  245|   325k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  246|   325k|      const __m128i utf8_0 =
  247|   325k|          _mm_shuffle_epi8(_mm256_castsi256_si128(out0), shuffle0);
  248|       |
  249|   325k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  250|   325k|      const uint8_t *row1 =
  251|   325k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  252|   325k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  253|   325k|      const __m128i utf8_1 =
  254|   325k|          _mm_shuffle_epi8(_mm256_castsi256_si128(out1), shuffle1);
  255|       |
  256|   325k|      const uint8_t mask2 = static_cast<uint8_t>(mask >> 16);
  257|   325k|      const uint8_t *row2 =
  258|   325k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask2][0];
  259|   325k|      const __m128i shuffle2 = _mm_loadu_si128((__m128i *)(row2 + 1));
  260|   325k|      const __m128i utf8_2 =
  261|   325k|          _mm_shuffle_epi8(_mm256_extractf128_si256(out0, 1), shuffle2);
  262|       |
  263|   325k|      const uint8_t mask3 = static_cast<uint8_t>(mask >> 24);
  264|   325k|      const uint8_t *row3 =
  265|   325k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask3][0];
  266|   325k|      const __m128i shuffle3 = _mm_loadu_si128((__m128i *)(row3 + 1));
  267|   325k|      const __m128i utf8_3 =
  268|   325k|          _mm_shuffle_epi8(_mm256_extractf128_si256(out1, 1), shuffle3);
  269|       |
  270|   325k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  271|   325k|      utf8_output += row0[0];
  272|   325k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  273|   325k|      utf8_output += row1[0];
  274|   325k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_2);
  275|   325k|      utf8_output += row2[0];
  276|   325k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_3);
  277|   325k|      utf8_output += row3[0];
  278|   325k|      buf += 16;
  279|       |      // surrogate pair(s) in a register
  280|   325k|    } else {
  281|       |      // Let us do a scalar fallback.
  282|       |      // It may seem wasteful to use scalar code, but being efficient with SIMD
  283|       |      // in the presence of surrogate pairs may require non-trivial tables.
  284|  8.01k|      size_t forward = 15;
  285|  8.01k|      size_t k = 0;
  286|  8.01k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (286:11): [True: 0, False: 8.01k]
  ------------------
  287|      0|        forward = size_t(end - buf - 1);
  288|      0|      }
  289|   117k|      for (; k < forward; k++) {
  ------------------
  |  Branch (289:14): [True: 109k, False: 7.90k]
  ------------------
  290|   109k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  291|   109k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (291:13): [True: 23.3k, False: 85.8k]
  ------------------
  292|  23.3k|          *utf8_output++ = char(word);
  293|  85.8k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (293:20): [True: 15.9k, False: 69.9k]
  ------------------
  294|  15.9k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  295|  15.9k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  296|  69.9k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (296:20): [True: 59.5k, False: 10.3k]
  ------------------
  297|  59.5k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  298|  59.5k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  299|  59.5k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  300|  59.5k|        } else {
  301|       |          // must be a surrogate pair
  302|  10.3k|          uint16_t diff = uint16_t(word - 0xD800);
  303|  10.3k|          uint16_t next_word =
  304|  10.3k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  305|  10.3k|          k++;
  306|  10.3k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  307|  10.3k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (307:15): [True: 108, False: 10.2k]
  ------------------
  308|    108|            return std::make_pair(nullptr, utf8_output);
  309|    108|          }
  310|  10.2k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  311|  10.2k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  312|  10.2k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  313|  10.2k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  314|  10.2k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  315|  10.2k|        }
  316|   109k|      }
  317|  7.90k|      buf += k;
  318|  7.90k|    }
  319|   333k|  } // while
  320|    694|  return std::make_pair(buf, utf8_output);
  321|    802|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_126avx2_convert_utf16_to_utf8ILNS_10endiannessE1EEENSt3__14pairIPKDsPcEES7_mS8_:
   56|    740|avx2_convert_utf16_to_utf8(const char16_t *buf, size_t len, char *utf8_output) {
   57|    740|  const char16_t *end = buf + len;
   58|    740|  const __m256i v_0000 = _mm256_setzero_si256();
   59|    740|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
   60|    740|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
   61|    740|  const __m256i v_c080 = _mm256_set1_epi16((int16_t)0xc080);
   62|    740|  const size_t safety_margin =
   63|    740|      12; // to avoid overruns, see issue
   64|       |          // https://github.com/simdutf/simdutf/issues/92
   65|       |
   66|   940k|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (66:10): [True: 940k, False: 672]
  ------------------
   67|   940k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
   68|   940k|    if (big_endian) {
  ------------------
  |  Branch (68:9): [True: 940k, Folded]
  ------------------
   69|   940k|      const __m256i swap = _mm256_setr_epi8(
   70|   940k|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
   71|   940k|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
   72|   940k|      in = _mm256_shuffle_epi8(in, swap);
   73|   940k|    }
   74|       |    // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes
   75|   940k|    const __m256i v_ff80 = _mm256_set1_epi16((int16_t)0xff80);
   76|   940k|    if (_mm256_testz_si256(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (76:9): [True: 625k, False: 314k]
  ------------------
   77|       |      // 1. pack the bytes
   78|   625k|      const __m128i utf8_packed = _mm_packus_epi16(
   79|   625k|          _mm256_castsi256_si128(in), _mm256_extractf128_si256(in, 1));
   80|       |      // 2. store (16 bytes)
   81|   625k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   82|       |      // 3. adjust pointers
   83|   625k|      buf += 16;
   84|   625k|      utf8_output += 16;
   85|   625k|      continue; // we are done for this round!
   86|   625k|    }
   87|       |    // no bits set above 7th bit
   88|   314k|    const __m256i one_byte_bytemask =
   89|   314k|        _mm256_cmpeq_epi16(_mm256_and_si256(in, v_ff80), v_0000);
   90|   314k|    const uint32_t one_byte_bitmask =
   91|   314k|        static_cast<uint32_t>(_mm256_movemask_epi8(one_byte_bytemask));
   92|       |
   93|       |    // no bits set above 11th bit
   94|   314k|    const __m256i one_or_two_bytes_bytemask =
   95|   314k|        _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_0000);
   96|   314k|    const uint32_t one_or_two_bytes_bitmask =
   97|   314k|        static_cast<uint32_t>(_mm256_movemask_epi8(one_or_two_bytes_bytemask));
   98|   314k|    if (one_or_two_bytes_bitmask == 0xffffffff) {
  ------------------
  |  Branch (98:9): [True: 34.7k, False: 279k]
  ------------------
   99|       |
  100|       |      // 1. prepare 2-byte values
  101|       |      // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8
  102|       |      // expected output   : [110a|aaaa|10bb|bbbb] x 8
  103|  34.7k|      const __m256i v_1f00 = _mm256_set1_epi16((int16_t)0x1f00);
  104|  34.7k|      const __m256i v_003f = _mm256_set1_epi16((int16_t)0x003f);
  105|       |
  106|       |      // t0 = [000a|aaaa|bbbb|bb00]
  107|  34.7k|      const __m256i t0 = _mm256_slli_epi16(in, 2);
  108|       |      // t1 = [000a|aaaa|0000|0000]
  109|  34.7k|      const __m256i t1 = _mm256_and_si256(t0, v_1f00);
  110|       |      // t2 = [0000|0000|00bb|bbbb]
  111|  34.7k|      const __m256i t2 = _mm256_and_si256(in, v_003f);
  112|       |      // t3 = [000a|aaaa|00bb|bbbb]
  113|  34.7k|      const __m256i t3 = _mm256_or_si256(t1, t2);
  114|       |      // t4 = [110a|aaaa|10bb|bbbb]
  115|  34.7k|      const __m256i t4 = _mm256_or_si256(t3, v_c080);
  116|       |
  117|       |      // 2. merge ASCII and 2-byte codewords
  118|  34.7k|      const __m256i utf8_unpacked =
  119|  34.7k|          _mm256_blendv_epi8(t4, in, one_byte_bytemask);
  120|       |
  121|       |      // 3. prepare bitmask for 8-bit lookup
  122|  34.7k|      const uint32_t M0 = one_byte_bitmask & 0x55555555;
  123|  34.7k|      const uint32_t M1 = M0 >> 7;
  124|  34.7k|      const uint32_t M2 = (M1 | M0) & 0x00ff00ff;
  125|       |      // 4. pack the bytes
  126|       |
  127|  34.7k|      const uint8_t *row =
  128|  34.7k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2)][0];
  129|  34.7k|      const uint8_t *row_2 =
  130|  34.7k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2 >>
  131|  34.7k|                                                                       16)][0];
  132|       |
  133|  34.7k|      const __m128i shuffle = _mm_loadu_si128((__m128i *)(row + 1));
  134|  34.7k|      const __m128i shuffle_2 = _mm_loadu_si128((__m128i *)(row_2 + 1));
  135|       |
  136|  34.7k|      const __m256i utf8_packed = _mm256_shuffle_epi8(
  137|  34.7k|          utf8_unpacked, _mm256_setr_m128i(shuffle, shuffle_2));
  ------------------
  |  |    7|  34.7k|      _mm256_permute2f128_si256(_mm256_castsi128_si256(xmm1),                  \
  |  |    8|  34.7k|                                _mm256_castsi128_si256(xmm2), 2)
  ------------------
  138|       |      // 5. store bytes
  139|  34.7k|      _mm_storeu_si128((__m128i *)utf8_output,
  140|  34.7k|                       _mm256_castsi256_si128(utf8_packed));
  141|  34.7k|      utf8_output += row[0];
  142|  34.7k|      _mm_storeu_si128((__m128i *)utf8_output,
  143|  34.7k|                       _mm256_extractf128_si256(utf8_packed, 1));
  144|  34.7k|      utf8_output += row_2[0];
  145|       |
  146|       |      // 6. adjust pointers
  147|  34.7k|      buf += 16;
  148|  34.7k|      continue;
  149|  34.7k|    }
  150|       |    // 1. Check if there are any surrogate word in the input chunk.
  151|       |    //    We have also deal with situation when there is a surrogate word
  152|       |    //    at the end of a chunk.
  153|   279k|    const __m256i surrogates_bytemask =
  154|   279k|        _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_d800);
  155|       |
  156|       |    // bitmask = 0x0000 if there are no surrogates
  157|       |    //         = 0xc000 if the last word is a surrogate
  158|   279k|    const uint32_t surrogates_bitmask =
  159|   279k|        static_cast<uint32_t>(_mm256_movemask_epi8(surrogates_bytemask));
  160|       |    // It might seem like checking for surrogates_bitmask == 0xc000 could help.
  161|       |    // However, it is likely an uncommon occurrence.
  162|   279k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (162:9): [True: 268k, False: 11.4k]
  ------------------
  163|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  164|   268k|      const __m256i dup_even = _mm256_setr_epi16(
  165|   268k|          0x0000, 0x0202, 0x0404, 0x0606, 0x0808, 0x0a0a, 0x0c0c, 0x0e0e,
  166|   268k|          0x0000, 0x0202, 0x0404, 0x0606, 0x0808, 0x0a0a, 0x0c0c, 0x0e0e);
  167|       |
  168|       |      /* In this branch we handle three cases:
  169|       |         1. [0000|0000|0ccc|cccc] => [0ccc|cccc]                           -
  170|       |        single UFT-8 byte
  171|       |         2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc]              - two
  172|       |        UTF-8 bytes
  173|       |         3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] -
  174|       |        three UTF-8 bytes
  175|       |
  176|       |        We expand the input word (16-bit) into two code units (32-bit), thus
  177|       |        we have room for four bytes. However, we need five distinct bit
  178|       |        layouts. Note that the last byte in cases #2 and #3 is the same.
  179|       |
  180|       |        We precompute byte 1 for case #1 and the common byte for cases #2 & #3
  181|       |        in register t2.
  182|       |
  183|       |        We precompute byte 1 for case #3 and -- **conditionally** -- precompute
  184|       |        either byte 1 for case #2 or byte 2 for case #3. Note that they
  185|       |        differ by exactly one bit.
  186|       |
  187|       |        Finally from these two code units we build proper UTF-8 sequence, taking
  188|       |        into account the case (i.e, the number of bytes to write).
  189|       |      */
  190|       |      /**
  191|       |       * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce:
  192|       |       * t2 => [0ccc|cccc] [10cc|cccc]
  193|       |       * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb])
  194|       |       */
  195|   268k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  196|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  197|   268k|      const __m256i t0 = _mm256_shuffle_epi8(in, dup_even);
  198|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  199|   268k|      const __m256i t1 = _mm256_and_si256(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  195|   268k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  200|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  201|   268k|      const __m256i t2 = _mm256_or_si256(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  195|   268k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  202|       |
  203|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  204|   268k|      const __m256i s0 = _mm256_srli_epi16(in, 4);
  205|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  206|   268k|      const __m256i s1 = _mm256_and_si256(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  195|   268k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  207|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  208|   268k|      const __m256i s2 = _mm256_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  195|   268k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  209|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  210|   268k|      const __m256i s3 = _mm256_or_si256(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  195|   268k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  211|   268k|      const __m256i m0 = _mm256_andnot_si256(one_or_two_bytes_bytemask,
  212|   268k|                                             simdutf_vec(0b0100000000000000));
  ------------------
  |  |  195|   268k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  213|   268k|      const __m256i s4 = _mm256_xor_si256(s3, m0);
  214|   268k|#undef simdutf_vec
  215|       |
  216|       |      // 4. expand code units 16-bit => 32-bit
  217|   268k|      const __m256i out0 = _mm256_unpacklo_epi16(t2, s4);
  218|   268k|      const __m256i out1 = _mm256_unpackhi_epi16(t2, s4);
  219|       |
  220|       |      // 5. compress 32-bit code units into 1, 2 or 3 bytes -- 2 x shuffle
  221|   268k|      const uint32_t mask = (one_byte_bitmask & 0x55555555) |
  222|   268k|                            (one_or_two_bytes_bitmask & 0xaaaaaaaa);
  223|       |      // Due to the wider registers, the following path is less likely to be
  224|       |      // useful.
  225|       |      /*if(mask == 0) {
  226|       |        // We only have three-byte code units. Use fast path.
  227|       |        const __m256i shuffle =
  228|       |      _mm256_setr_epi8(2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1,
  229|       |      2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1); const __m256i utf8_0 =
  230|       |      _mm256_shuffle_epi8(out0, shuffle); const __m256i utf8_1 =
  231|       |      _mm256_shuffle_epi8(out1, shuffle);
  232|       |        _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_0));
  233|       |        utf8_output += 12;
  234|       |        _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_1));
  235|       |        utf8_output += 12;
  236|       |        _mm_storeu_si128((__m128i*)utf8_output,
  237|       |      _mm256_extractf128_si256(utf8_0,1)); utf8_output += 12;
  238|       |        _mm_storeu_si128((__m128i*)utf8_output,
  239|       |      _mm256_extractf128_si256(utf8_1,1)); utf8_output += 12; buf += 16;
  240|       |        continue;
  241|       |      }*/
  242|   268k|      const uint8_t mask0 = uint8_t(mask);
  243|   268k|      const uint8_t *row0 =
  244|   268k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  245|   268k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  246|   268k|      const __m128i utf8_0 =
  247|   268k|          _mm_shuffle_epi8(_mm256_castsi256_si128(out0), shuffle0);
  248|       |
  249|   268k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  250|   268k|      const uint8_t *row1 =
  251|   268k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  252|   268k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  253|   268k|      const __m128i utf8_1 =
  254|   268k|          _mm_shuffle_epi8(_mm256_castsi256_si128(out1), shuffle1);
  255|       |
  256|   268k|      const uint8_t mask2 = static_cast<uint8_t>(mask >> 16);
  257|   268k|      const uint8_t *row2 =
  258|   268k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask2][0];
  259|   268k|      const __m128i shuffle2 = _mm_loadu_si128((__m128i *)(row2 + 1));
  260|   268k|      const __m128i utf8_2 =
  261|   268k|          _mm_shuffle_epi8(_mm256_extractf128_si256(out0, 1), shuffle2);
  262|       |
  263|   268k|      const uint8_t mask3 = static_cast<uint8_t>(mask >> 24);
  264|   268k|      const uint8_t *row3 =
  265|   268k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask3][0];
  266|   268k|      const __m128i shuffle3 = _mm_loadu_si128((__m128i *)(row3 + 1));
  267|   268k|      const __m128i utf8_3 =
  268|   268k|          _mm_shuffle_epi8(_mm256_extractf128_si256(out1, 1), shuffle3);
  269|       |
  270|   268k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  271|   268k|      utf8_output += row0[0];
  272|   268k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  273|   268k|      utf8_output += row1[0];
  274|   268k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_2);
  275|   268k|      utf8_output += row2[0];
  276|   268k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_3);
  277|   268k|      utf8_output += row3[0];
  278|   268k|      buf += 16;
  279|       |      // surrogate pair(s) in a register
  280|   268k|    } else {
  281|       |      // Let us do a scalar fallback.
  282|       |      // It may seem wasteful to use scalar code, but being efficient with SIMD
  283|       |      // in the presence of surrogate pairs may require non-trivial tables.
  284|  11.4k|      size_t forward = 15;
  285|  11.4k|      size_t k = 0;
  286|  11.4k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (286:11): [True: 0, False: 11.4k]
  ------------------
  287|      0|        forward = size_t(end - buf - 1);
  288|      0|      }
  289|   167k|      for (; k < forward; k++) {
  ------------------
  |  Branch (289:14): [True: 156k, False: 11.3k]
  ------------------
  290|   156k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  291|   156k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (291:13): [True: 28.9k, False: 127k]
  ------------------
  292|  28.9k|          *utf8_output++ = char(word);
  293|   127k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (293:20): [True: 8.07k, False: 119k]
  ------------------
  294|  8.07k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  295|  8.07k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  296|   119k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (296:20): [True: 103k, False: 16.0k]
  ------------------
  297|   103k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  298|   103k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  299|   103k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  300|   103k|        } else {
  301|       |          // must be a surrogate pair
  302|  16.0k|          uint16_t diff = uint16_t(word - 0xD800);
  303|  16.0k|          uint16_t next_word =
  304|  16.0k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  305|  16.0k|          k++;
  306|  16.0k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  307|  16.0k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (307:15): [True: 68, False: 16.0k]
  ------------------
  308|     68|            return std::make_pair(nullptr, utf8_output);
  309|     68|          }
  310|  16.0k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  311|  16.0k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  312|  16.0k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  313|  16.0k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  314|  16.0k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  315|  16.0k|        }
  316|   156k|      }
  317|  11.3k|      buf += k;
  318|  11.3k|    }
  319|   279k|  } // while
  320|    672|  return std::make_pair(buf, utf8_output);
  321|    740|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_138avx2_convert_utf16_to_utf8_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPcEEPKDsmS7_:
  333|    628|                                       char *utf8_output) {
  334|    628|  const char16_t *start = buf;
  335|    628|  const char16_t *end = buf + len;
  336|       |
  337|    628|  const __m256i v_0000 = _mm256_setzero_si256();
  338|    628|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
  339|    628|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
  340|    628|  const __m256i v_c080 = _mm256_set1_epi16((int16_t)0xc080);
  341|    628|  const size_t safety_margin =
  342|    628|      12; // to avoid overruns, see issue
  343|       |          // https://github.com/simdutf/simdutf/issues/92
  344|       |
  345|   472k|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (345:10): [True: 471k, False: 500]
  ------------------
  346|   471k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
  347|   471k|    if (big_endian) {
  ------------------
  |  Branch (347:9): [Folded, False: 471k]
  ------------------
  348|      0|      const __m256i swap = _mm256_setr_epi8(
  349|      0|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
  350|      0|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
  351|      0|      in = _mm256_shuffle_epi8(in, swap);
  352|      0|    }
  353|       |    // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes
  354|   471k|    const __m256i v_ff80 = _mm256_set1_epi16((int16_t)0xff80);
  355|   471k|    if (_mm256_testz_si256(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (355:9): [True: 208k, False: 263k]
  ------------------
  356|       |      // 1. pack the bytes
  357|   208k|      const __m128i utf8_packed = _mm_packus_epi16(
  358|   208k|          _mm256_castsi256_si128(in), _mm256_extractf128_si256(in, 1));
  359|       |      // 2. store (16 bytes)
  360|   208k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  361|       |      // 3. adjust pointers
  362|   208k|      buf += 16;
  363|   208k|      utf8_output += 16;
  364|   208k|      continue; // we are done for this round!
  365|   208k|    }
  366|       |    // no bits set above 7th bit
  367|   263k|    const __m256i one_byte_bytemask =
  368|   263k|        _mm256_cmpeq_epi16(_mm256_and_si256(in, v_ff80), v_0000);
  369|   263k|    const uint32_t one_byte_bitmask =
  370|   263k|        static_cast<uint32_t>(_mm256_movemask_epi8(one_byte_bytemask));
  371|       |
  372|       |    // no bits set above 11th bit
  373|   263k|    const __m256i one_or_two_bytes_bytemask =
  374|   263k|        _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_0000);
  375|   263k|    const uint32_t one_or_two_bytes_bitmask =
  376|   263k|        static_cast<uint32_t>(_mm256_movemask_epi8(one_or_two_bytes_bytemask));
  377|   263k|    if (one_or_two_bytes_bitmask == 0xffffffff) {
  ------------------
  |  Branch (377:9): [True: 10.7k, False: 252k]
  ------------------
  378|       |
  379|       |      // 1. prepare 2-byte values
  380|       |      // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8
  381|       |      // expected output   : [110a|aaaa|10bb|bbbb] x 8
  382|  10.7k|      const __m256i v_1f00 = _mm256_set1_epi16((int16_t)0x1f00);
  383|  10.7k|      const __m256i v_003f = _mm256_set1_epi16((int16_t)0x003f);
  384|       |
  385|       |      // t0 = [000a|aaaa|bbbb|bb00]
  386|  10.7k|      const __m256i t0 = _mm256_slli_epi16(in, 2);
  387|       |      // t1 = [000a|aaaa|0000|0000]
  388|  10.7k|      const __m256i t1 = _mm256_and_si256(t0, v_1f00);
  389|       |      // t2 = [0000|0000|00bb|bbbb]
  390|  10.7k|      const __m256i t2 = _mm256_and_si256(in, v_003f);
  391|       |      // t3 = [000a|aaaa|00bb|bbbb]
  392|  10.7k|      const __m256i t3 = _mm256_or_si256(t1, t2);
  393|       |      // t4 = [110a|aaaa|10bb|bbbb]
  394|  10.7k|      const __m256i t4 = _mm256_or_si256(t3, v_c080);
  395|       |
  396|       |      // 2. merge ASCII and 2-byte codewords
  397|  10.7k|      const __m256i utf8_unpacked =
  398|  10.7k|          _mm256_blendv_epi8(t4, in, one_byte_bytemask);
  399|       |
  400|       |      // 3. prepare bitmask for 8-bit lookup
  401|  10.7k|      const uint32_t M0 = one_byte_bitmask & 0x55555555;
  402|  10.7k|      const uint32_t M1 = M0 >> 7;
  403|  10.7k|      const uint32_t M2 = (M1 | M0) & 0x00ff00ff;
  404|       |      // 4. pack the bytes
  405|       |
  406|  10.7k|      const uint8_t *row =
  407|  10.7k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2)][0];
  408|  10.7k|      const uint8_t *row_2 =
  409|  10.7k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2 >>
  410|  10.7k|                                                                       16)][0];
  411|       |
  412|  10.7k|      const __m128i shuffle = _mm_loadu_si128((__m128i *)(row + 1));
  413|  10.7k|      const __m128i shuffle_2 = _mm_loadu_si128((__m128i *)(row_2 + 1));
  414|       |
  415|  10.7k|      const __m256i utf8_packed = _mm256_shuffle_epi8(
  416|  10.7k|          utf8_unpacked, _mm256_setr_m128i(shuffle, shuffle_2));
  ------------------
  |  |    7|  10.7k|      _mm256_permute2f128_si256(_mm256_castsi128_si256(xmm1),                  \
  |  |    8|  10.7k|                                _mm256_castsi128_si256(xmm2), 2)
  ------------------
  417|       |      // 5. store bytes
  418|  10.7k|      _mm_storeu_si128((__m128i *)utf8_output,
  419|  10.7k|                       _mm256_castsi256_si128(utf8_packed));
  420|  10.7k|      utf8_output += row[0];
  421|  10.7k|      _mm_storeu_si128((__m128i *)utf8_output,
  422|  10.7k|                       _mm256_extractf128_si256(utf8_packed, 1));
  423|  10.7k|      utf8_output += row_2[0];
  424|       |
  425|       |      // 6. adjust pointers
  426|  10.7k|      buf += 16;
  427|  10.7k|      continue;
  428|  10.7k|    }
  429|       |    // 1. Check if there are any surrogate word in the input chunk.
  430|       |    //    We have also deal with situation when there is a surrogate word
  431|       |    //    at the end of a chunk.
  432|   252k|    const __m256i surrogates_bytemask =
  433|   252k|        _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_d800);
  434|       |
  435|       |    // bitmask = 0x0000 if there are no surrogates
  436|       |    //         = 0xc000 if the last word is a surrogate
  437|   252k|    const uint32_t surrogates_bitmask =
  438|   252k|        static_cast<uint32_t>(_mm256_movemask_epi8(surrogates_bytemask));
  439|       |    // It might seem like checking for surrogates_bitmask == 0xc000 could help.
  440|       |    // However, it is likely an uncommon occurrence.
  441|   252k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (441:9): [True: 250k, False: 2.38k]
  ------------------
  442|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  443|   250k|      const __m256i dup_even = _mm256_setr_epi16(
  444|   250k|          0x0000, 0x0202, 0x0404, 0x0606, 0x0808, 0x0a0a, 0x0c0c, 0x0e0e,
  445|   250k|          0x0000, 0x0202, 0x0404, 0x0606, 0x0808, 0x0a0a, 0x0c0c, 0x0e0e);
  446|       |
  447|       |      /* In this branch we handle three cases:
  448|       |         1. [0000|0000|0ccc|cccc] => [0ccc|cccc]                           -
  449|       |        single UFT-8 byte
  450|       |         2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc]              - two
  451|       |        UTF-8 bytes
  452|       |         3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] -
  453|       |        three UTF-8 bytes
  454|       |
  455|       |        We expand the input word (16-bit) into two code units (32-bit), thus
  456|       |        we have room for four bytes. However, we need five distinct bit
  457|       |        layouts. Note that the last byte in cases #2 and #3 is the same.
  458|       |
  459|       |        We precompute byte 1 for case #1 and the common byte for cases #2 & #3
  460|       |        in register t2.
  461|       |
  462|       |        We precompute byte 1 for case #3 and -- **conditionally** -- precompute
  463|       |        either byte 1 for case #2 or byte 2 for case #3. Note that they
  464|       |        differ by exactly one bit.
  465|       |
  466|       |        Finally from these two code units we build proper UTF-8 sequence, taking
  467|       |        into account the case (i.e, the number of bytes to write).
  468|       |      */
  469|       |      /**
  470|       |       * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce:
  471|       |       * t2 => [0ccc|cccc] [10cc|cccc]
  472|       |       * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb])
  473|       |       */
  474|   250k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  475|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  476|   250k|      const __m256i t0 = _mm256_shuffle_epi8(in, dup_even);
  477|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  478|   250k|      const __m256i t1 = _mm256_and_si256(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  474|   250k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  479|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  480|   250k|      const __m256i t2 = _mm256_or_si256(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  474|   250k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  481|       |
  482|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  483|   250k|      const __m256i s0 = _mm256_srli_epi16(in, 4);
  484|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  485|   250k|      const __m256i s1 = _mm256_and_si256(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  474|   250k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  486|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  487|   250k|      const __m256i s2 = _mm256_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  474|   250k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  488|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  489|   250k|      const __m256i s3 = _mm256_or_si256(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  474|   250k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  490|   250k|      const __m256i m0 = _mm256_andnot_si256(one_or_two_bytes_bytemask,
  491|   250k|                                             simdutf_vec(0b0100000000000000));
  ------------------
  |  |  474|   250k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  492|   250k|      const __m256i s4 = _mm256_xor_si256(s3, m0);
  493|   250k|#undef simdutf_vec
  494|       |
  495|       |      // 4. expand code units 16-bit => 32-bit
  496|   250k|      const __m256i out0 = _mm256_unpacklo_epi16(t2, s4);
  497|   250k|      const __m256i out1 = _mm256_unpackhi_epi16(t2, s4);
  498|       |
  499|       |      // 5. compress 32-bit code units into 1, 2 or 3 bytes -- 2 x shuffle
  500|   250k|      const uint32_t mask = (one_byte_bitmask & 0x55555555) |
  501|   250k|                            (one_or_two_bytes_bitmask & 0xaaaaaaaa);
  502|       |      // Due to the wider registers, the following path is less likely to be
  503|       |      // useful.
  504|       |      /*if(mask == 0) {
  505|       |        // We only have three-byte code units. Use fast path.
  506|       |        const __m256i shuffle =
  507|       |      _mm256_setr_epi8(2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1,
  508|       |      2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1); const __m256i utf8_0 =
  509|       |      _mm256_shuffle_epi8(out0, shuffle); const __m256i utf8_1 =
  510|       |      _mm256_shuffle_epi8(out1, shuffle);
  511|       |        _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_0));
  512|       |        utf8_output += 12;
  513|       |        _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_1));
  514|       |        utf8_output += 12;
  515|       |        _mm_storeu_si128((__m128i*)utf8_output,
  516|       |      _mm256_extractf128_si256(utf8_0,1)); utf8_output += 12;
  517|       |        _mm_storeu_si128((__m128i*)utf8_output,
  518|       |      _mm256_extractf128_si256(utf8_1,1)); utf8_output += 12; buf += 16;
  519|       |        continue;
  520|       |      }*/
  521|   250k|      const uint8_t mask0 = uint8_t(mask);
  522|   250k|      const uint8_t *row0 =
  523|   250k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  524|   250k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  525|   250k|      const __m128i utf8_0 =
  526|   250k|          _mm_shuffle_epi8(_mm256_castsi256_si128(out0), shuffle0);
  527|       |
  528|   250k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  529|   250k|      const uint8_t *row1 =
  530|   250k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  531|   250k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  532|   250k|      const __m128i utf8_1 =
  533|   250k|          _mm_shuffle_epi8(_mm256_castsi256_si128(out1), shuffle1);
  534|       |
  535|   250k|      const uint8_t mask2 = static_cast<uint8_t>(mask >> 16);
  536|   250k|      const uint8_t *row2 =
  537|   250k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask2][0];
  538|   250k|      const __m128i shuffle2 = _mm_loadu_si128((__m128i *)(row2 + 1));
  539|   250k|      const __m128i utf8_2 =
  540|   250k|          _mm_shuffle_epi8(_mm256_extractf128_si256(out0, 1), shuffle2);
  541|       |
  542|   250k|      const uint8_t mask3 = static_cast<uint8_t>(mask >> 24);
  543|   250k|      const uint8_t *row3 =
  544|   250k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask3][0];
  545|   250k|      const __m128i shuffle3 = _mm_loadu_si128((__m128i *)(row3 + 1));
  546|   250k|      const __m128i utf8_3 =
  547|   250k|          _mm_shuffle_epi8(_mm256_extractf128_si256(out1, 1), shuffle3);
  548|       |
  549|   250k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  550|   250k|      utf8_output += row0[0];
  551|   250k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  552|   250k|      utf8_output += row1[0];
  553|   250k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_2);
  554|   250k|      utf8_output += row2[0];
  555|   250k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_3);
  556|   250k|      utf8_output += row3[0];
  557|   250k|      buf += 16;
  558|       |      // surrogate pair(s) in a register
  559|   250k|    } else {
  560|       |      // Let us do a scalar fallback.
  561|       |      // It may seem wasteful to use scalar code, but being efficient with SIMD
  562|       |      // in the presence of surrogate pairs may require non-trivial tables.
  563|  2.38k|      size_t forward = 15;
  564|  2.38k|      size_t k = 0;
  565|  2.38k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (565:11): [True: 0, False: 2.38k]
  ------------------
  566|      0|        forward = size_t(end - buf - 1);
  567|      0|      }
  568|  34.1k|      for (; k < forward; k++) {
  ------------------
  |  Branch (568:14): [True: 31.8k, False: 2.25k]
  ------------------
  569|  31.8k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  570|  31.8k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (570:13): [True: 6.08k, False: 25.8k]
  ------------------
  571|  6.08k|          *utf8_output++ = char(word);
  572|  25.8k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (572:20): [True: 2.78k, False: 23.0k]
  ------------------
  573|  2.78k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  574|  2.78k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  575|  23.0k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (575:20): [True: 20.0k, False: 2.97k]
  ------------------
  576|  20.0k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  577|  20.0k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  578|  20.0k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  579|  20.0k|        } else {
  580|       |          // must be a surrogate pair
  581|  2.97k|          uint16_t diff = uint16_t(word - 0xD800);
  582|  2.97k|          uint16_t next_word =
  583|  2.97k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  584|  2.97k|          k++;
  585|  2.97k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  586|  2.97k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (586:15): [True: 128, False: 2.84k]
  ------------------
  587|    128|            return std::make_pair(
  588|    128|                result(error_code::SURROGATE, buf - start + k - 1),
  589|    128|                utf8_output);
  590|    128|          }
  591|  2.84k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  592|  2.84k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  593|  2.84k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  594|  2.84k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  595|  2.84k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  596|  2.84k|        }
  597|  31.8k|      }
  598|  2.25k|      buf += k;
  599|  2.25k|    }
  600|   252k|  } // while
  601|    500|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output);
  602|    628|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_138avx2_convert_utf16_to_utf8_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPcEEPKDsmS7_:
  333|    540|                                       char *utf8_output) {
  334|    540|  const char16_t *start = buf;
  335|    540|  const char16_t *end = buf + len;
  336|       |
  337|    540|  const __m256i v_0000 = _mm256_setzero_si256();
  338|    540|  const __m256i v_f800 = _mm256_set1_epi16((int16_t)0xf800);
  339|    540|  const __m256i v_d800 = _mm256_set1_epi16((int16_t)0xd800);
  340|    540|  const __m256i v_c080 = _mm256_set1_epi16((int16_t)0xc080);
  341|    540|  const size_t safety_margin =
  342|    540|      12; // to avoid overruns, see issue
  343|       |          // https://github.com/simdutf/simdutf/issues/92
  344|       |
  345|   389k|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (345:10): [True: 389k, False: 420]
  ------------------
  346|   389k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
  347|   389k|    if (big_endian) {
  ------------------
  |  Branch (347:9): [True: 389k, Folded]
  ------------------
  348|   389k|      const __m256i swap = _mm256_setr_epi8(
  349|   389k|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
  350|   389k|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
  351|   389k|      in = _mm256_shuffle_epi8(in, swap);
  352|   389k|    }
  353|       |    // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes
  354|   389k|    const __m256i v_ff80 = _mm256_set1_epi16((int16_t)0xff80);
  355|   389k|    if (_mm256_testz_si256(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (355:9): [True: 227k, False: 161k]
  ------------------
  356|       |      // 1. pack the bytes
  357|   227k|      const __m128i utf8_packed = _mm_packus_epi16(
  358|   227k|          _mm256_castsi256_si128(in), _mm256_extractf128_si256(in, 1));
  359|       |      // 2. store (16 bytes)
  360|   227k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  361|       |      // 3. adjust pointers
  362|   227k|      buf += 16;
  363|   227k|      utf8_output += 16;
  364|   227k|      continue; // we are done for this round!
  365|   227k|    }
  366|       |    // no bits set above 7th bit
  367|   161k|    const __m256i one_byte_bytemask =
  368|   161k|        _mm256_cmpeq_epi16(_mm256_and_si256(in, v_ff80), v_0000);
  369|   161k|    const uint32_t one_byte_bitmask =
  370|   161k|        static_cast<uint32_t>(_mm256_movemask_epi8(one_byte_bytemask));
  371|       |
  372|       |    // no bits set above 11th bit
  373|   161k|    const __m256i one_or_two_bytes_bytemask =
  374|   161k|        _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_0000);
  375|   161k|    const uint32_t one_or_two_bytes_bitmask =
  376|   161k|        static_cast<uint32_t>(_mm256_movemask_epi8(one_or_two_bytes_bytemask));
  377|   161k|    if (one_or_two_bytes_bitmask == 0xffffffff) {
  ------------------
  |  Branch (377:9): [True: 37.0k, False: 124k]
  ------------------
  378|       |
  379|       |      // 1. prepare 2-byte values
  380|       |      // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8
  381|       |      // expected output   : [110a|aaaa|10bb|bbbb] x 8
  382|  37.0k|      const __m256i v_1f00 = _mm256_set1_epi16((int16_t)0x1f00);
  383|  37.0k|      const __m256i v_003f = _mm256_set1_epi16((int16_t)0x003f);
  384|       |
  385|       |      // t0 = [000a|aaaa|bbbb|bb00]
  386|  37.0k|      const __m256i t0 = _mm256_slli_epi16(in, 2);
  387|       |      // t1 = [000a|aaaa|0000|0000]
  388|  37.0k|      const __m256i t1 = _mm256_and_si256(t0, v_1f00);
  389|       |      // t2 = [0000|0000|00bb|bbbb]
  390|  37.0k|      const __m256i t2 = _mm256_and_si256(in, v_003f);
  391|       |      // t3 = [000a|aaaa|00bb|bbbb]
  392|  37.0k|      const __m256i t3 = _mm256_or_si256(t1, t2);
  393|       |      // t4 = [110a|aaaa|10bb|bbbb]
  394|  37.0k|      const __m256i t4 = _mm256_or_si256(t3, v_c080);
  395|       |
  396|       |      // 2. merge ASCII and 2-byte codewords
  397|  37.0k|      const __m256i utf8_unpacked =
  398|  37.0k|          _mm256_blendv_epi8(t4, in, one_byte_bytemask);
  399|       |
  400|       |      // 3. prepare bitmask for 8-bit lookup
  401|  37.0k|      const uint32_t M0 = one_byte_bitmask & 0x55555555;
  402|  37.0k|      const uint32_t M1 = M0 >> 7;
  403|  37.0k|      const uint32_t M2 = (M1 | M0) & 0x00ff00ff;
  404|       |      // 4. pack the bytes
  405|       |
  406|  37.0k|      const uint8_t *row =
  407|  37.0k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2)][0];
  408|  37.0k|      const uint8_t *row_2 =
  409|  37.0k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2 >>
  410|  37.0k|                                                                       16)][0];
  411|       |
  412|  37.0k|      const __m128i shuffle = _mm_loadu_si128((__m128i *)(row + 1));
  413|  37.0k|      const __m128i shuffle_2 = _mm_loadu_si128((__m128i *)(row_2 + 1));
  414|       |
  415|  37.0k|      const __m256i utf8_packed = _mm256_shuffle_epi8(
  416|  37.0k|          utf8_unpacked, _mm256_setr_m128i(shuffle, shuffle_2));
  ------------------
  |  |    7|  37.0k|      _mm256_permute2f128_si256(_mm256_castsi128_si256(xmm1),                  \
  |  |    8|  37.0k|                                _mm256_castsi128_si256(xmm2), 2)
  ------------------
  417|       |      // 5. store bytes
  418|  37.0k|      _mm_storeu_si128((__m128i *)utf8_output,
  419|  37.0k|                       _mm256_castsi256_si128(utf8_packed));
  420|  37.0k|      utf8_output += row[0];
  421|  37.0k|      _mm_storeu_si128((__m128i *)utf8_output,
  422|  37.0k|                       _mm256_extractf128_si256(utf8_packed, 1));
  423|  37.0k|      utf8_output += row_2[0];
  424|       |
  425|       |      // 6. adjust pointers
  426|  37.0k|      buf += 16;
  427|  37.0k|      continue;
  428|  37.0k|    }
  429|       |    // 1. Check if there are any surrogate word in the input chunk.
  430|       |    //    We have also deal with situation when there is a surrogate word
  431|       |    //    at the end of a chunk.
  432|   124k|    const __m256i surrogates_bytemask =
  433|   124k|        _mm256_cmpeq_epi16(_mm256_and_si256(in, v_f800), v_d800);
  434|       |
  435|       |    // bitmask = 0x0000 if there are no surrogates
  436|       |    //         = 0xc000 if the last word is a surrogate
  437|   124k|    const uint32_t surrogates_bitmask =
  438|   124k|        static_cast<uint32_t>(_mm256_movemask_epi8(surrogates_bytemask));
  439|       |    // It might seem like checking for surrogates_bitmask == 0xc000 could help.
  440|       |    // However, it is likely an uncommon occurrence.
  441|   124k|    if (surrogates_bitmask == 0x00000000) {
  ------------------
  |  Branch (441:9): [True: 115k, False: 9.00k]
  ------------------
  442|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  443|   115k|      const __m256i dup_even = _mm256_setr_epi16(
  444|   115k|          0x0000, 0x0202, 0x0404, 0x0606, 0x0808, 0x0a0a, 0x0c0c, 0x0e0e,
  445|   115k|          0x0000, 0x0202, 0x0404, 0x0606, 0x0808, 0x0a0a, 0x0c0c, 0x0e0e);
  446|       |
  447|       |      /* In this branch we handle three cases:
  448|       |         1. [0000|0000|0ccc|cccc] => [0ccc|cccc]                           -
  449|       |        single UFT-8 byte
  450|       |         2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc]              - two
  451|       |        UTF-8 bytes
  452|       |         3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] -
  453|       |        three UTF-8 bytes
  454|       |
  455|       |        We expand the input word (16-bit) into two code units (32-bit), thus
  456|       |        we have room for four bytes. However, we need five distinct bit
  457|       |        layouts. Note that the last byte in cases #2 and #3 is the same.
  458|       |
  459|       |        We precompute byte 1 for case #1 and the common byte for cases #2 & #3
  460|       |        in register t2.
  461|       |
  462|       |        We precompute byte 1 for case #3 and -- **conditionally** -- precompute
  463|       |        either byte 1 for case #2 or byte 2 for case #3. Note that they
  464|       |        differ by exactly one bit.
  465|       |
  466|       |        Finally from these two code units we build proper UTF-8 sequence, taking
  467|       |        into account the case (i.e, the number of bytes to write).
  468|       |      */
  469|       |      /**
  470|       |       * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce:
  471|       |       * t2 => [0ccc|cccc] [10cc|cccc]
  472|       |       * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb])
  473|       |       */
  474|   115k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  475|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  476|   115k|      const __m256i t0 = _mm256_shuffle_epi8(in, dup_even);
  477|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  478|   115k|      const __m256i t1 = _mm256_and_si256(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  474|   115k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  479|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  480|   115k|      const __m256i t2 = _mm256_or_si256(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  474|   115k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  481|       |
  482|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  483|   115k|      const __m256i s0 = _mm256_srli_epi16(in, 4);
  484|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  485|   115k|      const __m256i s1 = _mm256_and_si256(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  474|   115k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  486|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  487|   115k|      const __m256i s2 = _mm256_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  474|   115k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  488|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  489|   115k|      const __m256i s3 = _mm256_or_si256(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  474|   115k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  490|   115k|      const __m256i m0 = _mm256_andnot_si256(one_or_two_bytes_bytemask,
  491|   115k|                                             simdutf_vec(0b0100000000000000));
  ------------------
  |  |  474|   115k|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  492|   115k|      const __m256i s4 = _mm256_xor_si256(s3, m0);
  493|   115k|#undef simdutf_vec
  494|       |
  495|       |      // 4. expand code units 16-bit => 32-bit
  496|   115k|      const __m256i out0 = _mm256_unpacklo_epi16(t2, s4);
  497|   115k|      const __m256i out1 = _mm256_unpackhi_epi16(t2, s4);
  498|       |
  499|       |      // 5. compress 32-bit code units into 1, 2 or 3 bytes -- 2 x shuffle
  500|   115k|      const uint32_t mask = (one_byte_bitmask & 0x55555555) |
  501|   115k|                            (one_or_two_bytes_bitmask & 0xaaaaaaaa);
  502|       |      // Due to the wider registers, the following path is less likely to be
  503|       |      // useful.
  504|       |      /*if(mask == 0) {
  505|       |        // We only have three-byte code units. Use fast path.
  506|       |        const __m256i shuffle =
  507|       |      _mm256_setr_epi8(2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1,
  508|       |      2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1); const __m256i utf8_0 =
  509|       |      _mm256_shuffle_epi8(out0, shuffle); const __m256i utf8_1 =
  510|       |      _mm256_shuffle_epi8(out1, shuffle);
  511|       |        _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_0));
  512|       |        utf8_output += 12;
  513|       |        _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_1));
  514|       |        utf8_output += 12;
  515|       |        _mm_storeu_si128((__m128i*)utf8_output,
  516|       |      _mm256_extractf128_si256(utf8_0,1)); utf8_output += 12;
  517|       |        _mm_storeu_si128((__m128i*)utf8_output,
  518|       |      _mm256_extractf128_si256(utf8_1,1)); utf8_output += 12; buf += 16;
  519|       |        continue;
  520|       |      }*/
  521|   115k|      const uint8_t mask0 = uint8_t(mask);
  522|   115k|      const uint8_t *row0 =
  523|   115k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  524|   115k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  525|   115k|      const __m128i utf8_0 =
  526|   115k|          _mm_shuffle_epi8(_mm256_castsi256_si128(out0), shuffle0);
  527|       |
  528|   115k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  529|   115k|      const uint8_t *row1 =
  530|   115k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  531|   115k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  532|   115k|      const __m128i utf8_1 =
  533|   115k|          _mm_shuffle_epi8(_mm256_castsi256_si128(out1), shuffle1);
  534|       |
  535|   115k|      const uint8_t mask2 = static_cast<uint8_t>(mask >> 16);
  536|   115k|      const uint8_t *row2 =
  537|   115k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask2][0];
  538|   115k|      const __m128i shuffle2 = _mm_loadu_si128((__m128i *)(row2 + 1));
  539|   115k|      const __m128i utf8_2 =
  540|   115k|          _mm_shuffle_epi8(_mm256_extractf128_si256(out0, 1), shuffle2);
  541|       |
  542|   115k|      const uint8_t mask3 = static_cast<uint8_t>(mask >> 24);
  543|   115k|      const uint8_t *row3 =
  544|   115k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask3][0];
  545|   115k|      const __m128i shuffle3 = _mm_loadu_si128((__m128i *)(row3 + 1));
  546|   115k|      const __m128i utf8_3 =
  547|   115k|          _mm_shuffle_epi8(_mm256_extractf128_si256(out1, 1), shuffle3);
  548|       |
  549|   115k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  550|   115k|      utf8_output += row0[0];
  551|   115k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  552|   115k|      utf8_output += row1[0];
  553|   115k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_2);
  554|   115k|      utf8_output += row2[0];
  555|   115k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_3);
  556|   115k|      utf8_output += row3[0];
  557|   115k|      buf += 16;
  558|       |      // surrogate pair(s) in a register
  559|   115k|    } else {
  560|       |      // Let us do a scalar fallback.
  561|       |      // It may seem wasteful to use scalar code, but being efficient with SIMD
  562|       |      // in the presence of surrogate pairs may require non-trivial tables.
  563|  9.00k|      size_t forward = 15;
  564|  9.00k|      size_t k = 0;
  565|  9.00k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (565:11): [True: 0, False: 9.00k]
  ------------------
  566|      0|        forward = size_t(end - buf - 1);
  567|      0|      }
  568|   131k|      for (; k < forward; k++) {
  ------------------
  |  Branch (568:14): [True: 122k, False: 8.88k]
  ------------------
  569|   122k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  570|   122k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (570:13): [True: 41.8k, False: 80.4k]
  ------------------
  571|  41.8k|          *utf8_output++ = char(word);
  572|  80.4k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (572:20): [True: 6.95k, False: 73.4k]
  ------------------
  573|  6.95k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  574|  6.95k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  575|  73.4k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (575:20): [True: 60.9k, False: 12.5k]
  ------------------
  576|  60.9k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  577|  60.9k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  578|  60.9k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  579|  60.9k|        } else {
  580|       |          // must be a surrogate pair
  581|  12.5k|          uint16_t diff = uint16_t(word - 0xD800);
  582|  12.5k|          uint16_t next_word =
  583|  12.5k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  584|  12.5k|          k++;
  585|  12.5k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  586|  12.5k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (586:15): [True: 120, False: 12.4k]
  ------------------
  587|    120|            return std::make_pair(
  588|    120|                result(error_code::SURROGATE, buf - start + k - 1),
  589|    120|                utf8_output);
  590|    120|          }
  591|  12.4k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  592|  12.4k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  593|  12.4k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  594|  12.4k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  595|  12.4k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  596|  12.4k|        }
  597|   122k|      }
  598|  8.88k|      buf += k;
  599|  8.88k|    }
  600|   124k|  } // while
  601|    420|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output);
  602|    540|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_128avx2_convert_utf32_to_latin1EPKDimPc:
    3|    190|                             char *latin1_output) {
    4|    190|  const size_t rounded_len =
    5|    190|      len & ~0x1F; // Round down to nearest multiple of 32
    6|       |
    7|    190|  const __m256i high_bytes_mask = _mm256_set1_epi32(0xFFFFFF00);
    8|       |
    9|  1.79k|  for (size_t i = 0; i < rounded_len; i += 4 * 8) {
  ------------------
  |  Branch (9:22): [True: 1.64k, False: 150]
  ------------------
   10|  1.64k|    __m256i a = _mm256_loadu_si256((__m256i *)(buf + 0 * 8));
   11|  1.64k|    __m256i b = _mm256_loadu_si256((__m256i *)(buf + 1 * 8));
   12|  1.64k|    __m256i c = _mm256_loadu_si256((__m256i *)(buf + 2 * 8));
   13|  1.64k|    __m256i d = _mm256_loadu_si256((__m256i *)(buf + 3 * 8));
   14|       |
   15|  1.64k|    const __m256i check_combined =
   16|  1.64k|        _mm256_or_si256(_mm256_or_si256(a, b), _mm256_or_si256(c, d));
   17|       |
   18|  1.64k|    if (!_mm256_testz_si256(check_combined, high_bytes_mask)) {
  ------------------
  |  Branch (18:9): [True: 40, False: 1.60k]
  ------------------
   19|     40|      return std::make_pair(nullptr, latin1_output);
   20|     40|    }
   21|       |
   22|  1.60k|    b = _mm256_slli_epi32(b, 1 * 8);
   23|  1.60k|    c = _mm256_slli_epi32(c, 2 * 8);
   24|  1.60k|    d = _mm256_slli_epi32(d, 3 * 8);
   25|       |
   26|       |    // clang-format off
   27|       |
   28|       |    // a  = [.. .. .. a7|.. .. .. a6|.. .. .. a5|.. .. .. a4||.. .. .. a3|.. .. .. a2|.. .. .. a1|.. .. .. a0]
   29|       |    // b  = [.. .. b7 ..|.. .. b6 ..|.. .. b5 ..|.. .. b4 ..||.. .. b3 ..|.. .. b2 ..|.. .. b1 ..|.. .. b0 ..]
   30|       |    // c  = [.. c7 .. ..|.. c6 .. ..|.. c5 .. ..|.. c4 .. ..||.. c3 .. ..|.. c2 .. ..|.. c1 .. ..|.. c0 .. ..]
   31|       |    // d  = [d7 .. .. ..|d6 .. .. ..|d5 .. .. ..|d4 .. .. ..||d3 .. .. ..|d2 .. .. ..|d1 .. .. ..|d0 .. .. ..]
   32|       |
   33|       |    // t0 = [d7 c7 b7 a7|d6 c6 b6 a6|d5 c5 b5 a5|d4 c4 b4 a4||d3 c3 b3 a3|d2 c2 b2 a2|d1 c1 b1 a1|d0 c0 b0 a0]
   34|  1.60k|    const __m256i t0 =
   35|  1.60k|        _mm256_or_si256(_mm256_or_si256(a, b), _mm256_or_si256(c, d));
   36|       |
   37|       |    // shuffle bytes within 128-bit lanes
   38|       |    // t1 = [d7 d6 d5 d4|c7 c6 c5 c4|b7 b6 b5 b4|a7 a6 a5 a4||d3 d2 d1 d0|c3 c2 c1 c0|b3 b2 b1 b0|a3 a2 a1 a0]
   39|  1.60k|    const __m256i shuffle_bytes =
   40|  1.60k|        _mm256_setr_epi8(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15,
   41|  1.60k|                         0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15);
   42|       |
   43|  1.60k|    const __m256i t1 = _mm256_shuffle_epi8(t0, shuffle_bytes);
   44|       |
   45|       |    // reshuffle dwords
   46|       |    // t2 = [d7 d6 d5 d4|d3 d2 d1 d0|c7 c6 c5 c4|c3 c2 c1 c0||b7 b6 b5 b4|b3 b2 b1 b0|a7 a6 a5 a4|a3 a2 a1 a0]
   47|  1.60k|    const __m256i shuffle_dwords = _mm256_setr_epi32(0, 4, 1, 5, 2, 6, 3, 7);
   48|  1.60k|    const __m256i t2 = _mm256_permutevar8x32_epi32(t1, shuffle_dwords);
   49|       |// clang format on
   50|       |
   51|  1.60k|    _mm256_storeu_si256((__m256i *)latin1_output, t2);
   52|       |
   53|  1.60k|    latin1_output += 32;
   54|  1.60k|    buf += 32;
   55|  1.60k|  }
   56|       |
   57|    150|  return std::make_pair(buf, latin1_output);
   58|    190|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_140avx2_convert_utf32_to_latin1_with_errorsEPKDimPc:
   62|    344|                                         char *latin1_output) {
   63|    344|  const size_t rounded_len =
   64|    344|      len & ~0x1F; // Round down to nearest multiple of 32
   65|       |
   66|    344|  const char32_t *start = buf;
   67|       |
   68|    344|  const __m256i high_bytes_mask = _mm256_set1_epi32(0xFFFFFF00);
   69|       |
   70|  17.5k|  for (size_t i = 0; i < rounded_len; i += 4 * 8) {
  ------------------
  |  Branch (70:22): [True: 17.2k, False: 296]
  ------------------
   71|  17.2k|    __m256i a = _mm256_loadu_si256((__m256i *)(buf + 0 * 8));
   72|  17.2k|    __m256i b = _mm256_loadu_si256((__m256i *)(buf + 1 * 8));
   73|  17.2k|    __m256i c = _mm256_loadu_si256((__m256i *)(buf + 2 * 8));
   74|  17.2k|    __m256i d = _mm256_loadu_si256((__m256i *)(buf + 3 * 8));
   75|       |
   76|  17.2k|    const __m256i check_combined =
   77|  17.2k|        _mm256_or_si256(_mm256_or_si256(a, b), _mm256_or_si256(c, d));
   78|       |
   79|  17.2k|    if (!_mm256_testz_si256(check_combined, high_bytes_mask)) {
  ------------------
  |  Branch (79:9): [True: 48, False: 17.1k]
  ------------------
   80|       |      // Fallback to scalar code for handling errors
   81|    450|      for (int k = 0; k < 4 * 8; k++) {
  ------------------
  |  Branch (81:23): [True: 450, False: 0]
  ------------------
   82|    450|        char32_t codepoint = buf[k];
   83|    450|        if (codepoint <= 0xFF) {
  ------------------
  |  Branch (83:13): [True: 402, False: 48]
  ------------------
   84|    402|          *latin1_output++ = static_cast<char>(codepoint);
   85|    402|        } else {
   86|     48|          return std::make_pair(result(error_code::TOO_LARGE, buf - start + k),
   87|     48|                                latin1_output);
   88|     48|        }
   89|    450|      }
   90|     48|    }
   91|       |
   92|  17.1k|    b = _mm256_slli_epi32(b, 1 * 8);
   93|  17.1k|    c = _mm256_slli_epi32(c, 2 * 8);
   94|  17.1k|    d = _mm256_slli_epi32(d, 3 * 8);
   95|       |
   96|  17.1k|    const __m256i t0 =
   97|  17.1k|        _mm256_or_si256(_mm256_or_si256(a, b), _mm256_or_si256(c, d));
   98|       |
   99|  17.1k|    const __m256i shuffle_bytes =
  100|  17.1k|        _mm256_setr_epi8(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15,
  101|  17.1k|                         0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15);
  102|       |
  103|  17.1k|    const __m256i t1 = _mm256_shuffle_epi8(t0, shuffle_bytes);
  104|       |
  105|  17.1k|    const __m256i shuffle_dwords = _mm256_setr_epi32(0, 4, 1, 5, 2, 6, 3, 7);
  106|  17.1k|    const __m256i t2 = _mm256_permutevar8x32_epi32(t1, shuffle_dwords);
  107|       |
  108|  17.1k|    _mm256_storeu_si256((__m256i *)latin1_output, t2);
  109|       |
  110|  17.1k|    latin1_output += 32;
  111|  17.1k|    buf += 32;
  112|  17.1k|  }
  113|       |
  114|    296|  return std::make_pair(result(error_code::SUCCESS, buf - start),
  115|    296|                        latin1_output);
  116|    344|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_127avx2_convert_utf32_to_utf16ILNS_10endiannessE0EEENSt3__14pairIPKDiPDsEES7_mS8_:
    4|    644|                            char16_t *utf16_output) {
    5|    644|  const char32_t *end = buf + len;
    6|       |
    7|    644|  const size_t safety_margin =
    8|    644|      12; // to avoid overruns, see issue
    9|       |          // https://github.com/simdutf/simdutf/issues/92
   10|    644|  __m256i forbidden_bytemask = _mm256_setzero_si256();
   11|       |
   12|    644|  const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000);
   13|    644|  const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800);
   14|    644|  const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800);
   15|       |
   16|   332k|  while (end - buf >= std::ptrdiff_t(8 + safety_margin)) {
  ------------------
  |  Branch (16:10): [True: 331k, False: 524]
  ------------------
   17|   331k|    const __m256i in = _mm256_loadu_si256((__m256i *)buf);
   18|       |
   19|   331k|    if (simdutf_likely(_mm256_testz_si256(in, v_ffff0000))) {
  ------------------
  |  |   90|   331k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 329k, False: 2.80k]
  |  |  ------------------
  ------------------
   20|       |      // no bits set above 16th bit <=> can pack to UTF16
   21|       |      // without surrogate pairs
   22|   329k|      forbidden_bytemask = _mm256_or_si256(
   23|   329k|          forbidden_bytemask,
   24|   329k|          _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800));
   25|       |
   26|   329k|      __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in),
   27|   329k|                                              _mm256_extractf128_si256(in, 1));
   28|   329k|      if (big_endian) {
  ------------------
  |  Branch (28:11): [Folded, False: 329k]
  ------------------
   29|      0|        const __m128i swap =
   30|      0|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   31|      0|        utf16_packed = _mm_shuffle_epi8(utf16_packed, swap);
   32|      0|      }
   33|   329k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
   34|   329k|      utf16_output += 8;
   35|   329k|      buf += 8;
   36|   329k|    } else {
   37|  2.80k|      size_t forward = 7;
   38|  2.80k|      size_t k = 0;
   39|  2.80k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (39:11): [True: 0, False: 2.80k]
  ------------------
   40|      0|        forward = size_t(end - buf - 1);
   41|      0|      }
   42|  21.8k|      for (; k < forward; k++) {
  ------------------
  |  Branch (42:14): [True: 19.1k, False: 2.68k]
  ------------------
   43|  19.1k|        uint32_t word = buf[k];
   44|  19.1k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (44:13): [True: 3.97k, False: 15.1k]
  ------------------
   45|       |          // will not generate a surrogate pair
   46|  3.97k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (46:15): [True: 968, False: 3.00k]
  |  Branch (46:33): [True: 6, False: 962]
  ------------------
   47|      6|            return std::make_pair(nullptr, utf16_output);
   48|      6|          }
   49|  3.96k|          *utf16_output++ =
   50|  3.96k|              big_endian
  ------------------
  |  Branch (50:15): [Folded, False: 3.96k]
  ------------------
   51|  3.96k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
   52|  3.96k|                  : char16_t(word);
   53|  15.1k|        } else {
   54|       |          // will generate a surrogate pair
   55|  15.1k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (55:15): [True: 114, False: 15.0k]
  ------------------
   56|    114|            return std::make_pair(nullptr, utf16_output);
   57|    114|          }
   58|  15.0k|          word -= 0x10000;
   59|  15.0k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   60|  15.0k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
   61|  15.0k|          if (big_endian) {
  ------------------
  |  Branch (61:15): [Folded, False: 15.0k]
  ------------------
   62|      0|            high_surrogate =
   63|      0|                uint16_t((high_surrogate >> 8) | (high_surrogate << 8));
   64|      0|            low_surrogate =
   65|      0|                uint16_t((low_surrogate >> 8) | (low_surrogate << 8));
   66|      0|          }
   67|  15.0k|          *utf16_output++ = char16_t(high_surrogate);
   68|  15.0k|          *utf16_output++ = char16_t(low_surrogate);
   69|  15.0k|        }
   70|  19.1k|      }
   71|  2.68k|      buf += k;
   72|  2.68k|    }
   73|   331k|  }
   74|       |
   75|       |  // check for invalid input
   76|    524|  if (static_cast<uint32_t>(_mm256_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (76:7): [True: 38, False: 486]
  ------------------
   77|     38|    return std::make_pair(nullptr, utf16_output);
   78|     38|  }
   79|       |
   80|    486|  return std::make_pair(buf, utf16_output);
   81|    524|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_127avx2_convert_utf32_to_utf16ILNS_10endiannessE1EEENSt3__14pairIPKDiPDsEES7_mS8_:
    4|    462|                            char16_t *utf16_output) {
    5|    462|  const char32_t *end = buf + len;
    6|       |
    7|    462|  const size_t safety_margin =
    8|    462|      12; // to avoid overruns, see issue
    9|       |          // https://github.com/simdutf/simdutf/issues/92
   10|    462|  __m256i forbidden_bytemask = _mm256_setzero_si256();
   11|       |
   12|    462|  const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000);
   13|    462|  const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800);
   14|    462|  const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800);
   15|       |
   16|  1.98k|  while (end - buf >= std::ptrdiff_t(8 + safety_margin)) {
  ------------------
  |  Branch (16:10): [True: 1.60k, False: 376]
  ------------------
   17|  1.60k|    const __m256i in = _mm256_loadu_si256((__m256i *)buf);
   18|       |
   19|  1.60k|    if (simdutf_likely(_mm256_testz_si256(in, v_ffff0000))) {
  ------------------
  |  |   90|  1.60k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 742, False: 866]
  |  |  ------------------
  ------------------
   20|       |      // no bits set above 16th bit <=> can pack to UTF16
   21|       |      // without surrogate pairs
   22|    742|      forbidden_bytemask = _mm256_or_si256(
   23|    742|          forbidden_bytemask,
   24|    742|          _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800));
   25|       |
   26|    742|      __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in),
   27|    742|                                              _mm256_extractf128_si256(in, 1));
   28|    742|      if (big_endian) {
  ------------------
  |  Branch (28:11): [True: 742, Folded]
  ------------------
   29|    742|        const __m128i swap =
   30|    742|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   31|    742|        utf16_packed = _mm_shuffle_epi8(utf16_packed, swap);
   32|    742|      }
   33|    742|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
   34|    742|      utf16_output += 8;
   35|    742|      buf += 8;
   36|    866|    } else {
   37|    866|      size_t forward = 7;
   38|    866|      size_t k = 0;
   39|    866|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (39:11): [True: 0, False: 866]
  ------------------
   40|      0|        forward = size_t(end - buf - 1);
   41|      0|      }
   42|  6.54k|      for (; k < forward; k++) {
  ------------------
  |  Branch (42:14): [True: 5.76k, False: 780]
  ------------------
   43|  5.76k|        uint32_t word = buf[k];
   44|  5.76k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (44:13): [True: 1.30k, False: 4.46k]
  ------------------
   45|       |          // will not generate a surrogate pair
   46|  1.30k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (46:15): [True: 466, False: 838]
  |  Branch (46:33): [True: 4, False: 462]
  ------------------
   47|      4|            return std::make_pair(nullptr, utf16_output);
   48|      4|          }
   49|  1.30k|          *utf16_output++ =
   50|  1.30k|              big_endian
  ------------------
  |  Branch (50:15): [True: 1.30k, Folded]
  ------------------
   51|  1.30k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
   52|  1.30k|                  : char16_t(word);
   53|  4.46k|        } else {
   54|       |          // will generate a surrogate pair
   55|  4.46k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (55:15): [True: 82, False: 4.37k]
  ------------------
   56|     82|            return std::make_pair(nullptr, utf16_output);
   57|     82|          }
   58|  4.37k|          word -= 0x10000;
   59|  4.37k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
   60|  4.37k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
   61|  4.37k|          if (big_endian) {
  ------------------
  |  Branch (61:15): [True: 4.37k, Folded]
  ------------------
   62|  4.37k|            high_surrogate =
   63|  4.37k|                uint16_t((high_surrogate >> 8) | (high_surrogate << 8));
   64|  4.37k|            low_surrogate =
   65|  4.37k|                uint16_t((low_surrogate >> 8) | (low_surrogate << 8));
   66|  4.37k|          }
   67|  4.37k|          *utf16_output++ = char16_t(high_surrogate);
   68|  4.37k|          *utf16_output++ = char16_t(low_surrogate);
   69|  4.37k|        }
   70|  5.76k|      }
   71|    780|      buf += k;
   72|    780|    }
   73|  1.60k|  }
   74|       |
   75|       |  // check for invalid input
   76|    376|  if (static_cast<uint32_t>(_mm256_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (76:7): [True: 6, False: 370]
  ------------------
   77|      6|    return std::make_pair(nullptr, utf16_output);
   78|      6|  }
   79|       |
   80|    370|  return std::make_pair(buf, utf16_output);
   81|    376|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_139avx2_convert_utf32_to_utf16_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPDsEEPKDimS7_:
   86|    622|                                        char16_t *utf16_output) {
   87|    622|  const char32_t *start = buf;
   88|    622|  const char32_t *end = buf + len;
   89|       |
   90|    622|  const size_t safety_margin =
   91|    622|      12; // to avoid overruns, see issue
   92|       |          // https://github.com/simdutf/simdutf/issues/92
   93|       |
   94|    622|  const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000);
   95|    622|  const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800);
   96|    622|  const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800);
   97|       |
   98|  2.41k|  while (end - buf >= std::ptrdiff_t(8 + safety_margin)) {
  ------------------
  |  Branch (98:10): [True: 1.95k, False: 460]
  ------------------
   99|  1.95k|    const __m256i in = _mm256_loadu_si256((__m256i *)buf);
  100|       |
  101|  1.95k|    if (simdutf_likely(_mm256_testz_si256(in, v_ffff0000))) {
  ------------------
  |  |   90|  1.95k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 1.19k, False: 754]
  |  |  ------------------
  ------------------
  102|       |      // no bits set above 16th bit <=> can pack to UTF16 without surrogate
  103|       |      // pairs
  104|  1.19k|      const __m256i forbidden_bytemask =
  105|  1.19k|          _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800);
  106|  1.19k|      if (static_cast<uint32_t>(_mm256_movemask_epi8(forbidden_bytemask)) !=
  ------------------
  |  Branch (106:11): [True: 22, False: 1.17k]
  ------------------
  107|  1.19k|          0x0) {
  108|     22|        return std::make_pair(result(error_code::SURROGATE, buf - start),
  109|     22|                              utf16_output);
  110|     22|      }
  111|       |
  112|  1.17k|      __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in),
  113|  1.17k|                                              _mm256_extractf128_si256(in, 1));
  114|  1.17k|      if (big_endian) {
  ------------------
  |  Branch (114:11): [Folded, False: 1.17k]
  ------------------
  115|      0|        const __m128i swap =
  116|      0|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  117|      0|        utf16_packed = _mm_shuffle_epi8(utf16_packed, swap);
  118|      0|      }
  119|  1.17k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
  120|  1.17k|      utf16_output += 8;
  121|  1.17k|      buf += 8;
  122|  1.17k|    } else {
  123|    754|      size_t forward = 7;
  124|    754|      size_t k = 0;
  125|    754|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (125:11): [True: 0, False: 754]
  ------------------
  126|      0|        forward = size_t(end - buf - 1);
  127|      0|      }
  128|  5.34k|      for (; k < forward; k++) {
  ------------------
  |  Branch (128:14): [True: 4.73k, False: 614]
  ------------------
  129|  4.73k|        uint32_t word = buf[k];
  130|  4.73k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (130:13): [True: 2.35k, False: 2.37k]
  ------------------
  131|       |          // will not generate a surrogate pair
  132|  2.35k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (132:15): [True: 468, False: 1.88k]
  |  Branch (132:33): [True: 30, False: 438]
  ------------------
  133|     30|            return std::make_pair(
  134|     30|                result(error_code::SURROGATE, buf - start + k), utf16_output);
  135|     30|          }
  136|  2.32k|          *utf16_output++ =
  137|  2.32k|              big_endian
  ------------------
  |  Branch (137:15): [Folded, False: 2.32k]
  ------------------
  138|  2.32k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
  139|  2.32k|                  : char16_t(word);
  140|  2.37k|        } else {
  141|       |          // will generate a surrogate pair
  142|  2.37k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (142:15): [True: 110, False: 2.26k]
  ------------------
  143|    110|            return std::make_pair(
  144|    110|                result(error_code::TOO_LARGE, buf - start + k), utf16_output);
  145|    110|          }
  146|  2.26k|          word -= 0x10000;
  147|  2.26k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
  148|  2.26k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
  149|  2.26k|          if (big_endian) {
  ------------------
  |  Branch (149:15): [Folded, False: 2.26k]
  ------------------
  150|      0|            high_surrogate =
  151|      0|                uint16_t((high_surrogate >> 8) | (high_surrogate << 8));
  152|      0|            low_surrogate =
  153|      0|                uint16_t((low_surrogate >> 8) | (low_surrogate << 8));
  154|      0|          }
  155|  2.26k|          *utf16_output++ = char16_t(high_surrogate);
  156|  2.26k|          *utf16_output++ = char16_t(low_surrogate);
  157|  2.26k|        }
  158|  4.73k|      }
  159|    614|      buf += k;
  160|    614|    }
  161|  1.95k|  }
  162|       |
  163|    460|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf16_output);
  164|    622|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_139avx2_convert_utf32_to_utf16_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPDsEEPKDimS7_:
   86|    570|                                        char16_t *utf16_output) {
   87|    570|  const char32_t *start = buf;
   88|    570|  const char32_t *end = buf + len;
   89|       |
   90|    570|  const size_t safety_margin =
   91|    570|      12; // to avoid overruns, see issue
   92|       |          // https://github.com/simdutf/simdutf/issues/92
   93|       |
   94|    570|  const __m256i v_ffff0000 = _mm256_set1_epi32((int32_t)0xffff0000);
   95|    570|  const __m256i v_f800 = _mm256_set1_epi32((uint32_t)0xf800);
   96|    570|  const __m256i v_d800 = _mm256_set1_epi32((uint32_t)0xd800);
   97|       |
   98|  1.48k|  while (end - buf >= std::ptrdiff_t(8 + safety_margin)) {
  ------------------
  |  Branch (98:10): [True: 1.03k, False: 444]
  ------------------
   99|  1.03k|    const __m256i in = _mm256_loadu_si256((__m256i *)buf);
  100|       |
  101|  1.03k|    if (simdutf_likely(_mm256_testz_si256(in, v_ffff0000))) {
  ------------------
  |  |   90|  1.03k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 378, False: 660]
  |  |  ------------------
  ------------------
  102|       |      // no bits set above 16th bit <=> can pack to UTF16 without surrogate
  103|       |      // pairs
  104|    378|      const __m256i forbidden_bytemask =
  105|    378|          _mm256_cmpeq_epi32(_mm256_and_si256(in, v_f800), v_d800);
  106|    378|      if (static_cast<uint32_t>(_mm256_movemask_epi8(forbidden_bytemask)) !=
  ------------------
  |  Branch (106:11): [True: 8, False: 370]
  ------------------
  107|    378|          0x0) {
  108|      8|        return std::make_pair(result(error_code::SURROGATE, buf - start),
  109|      8|                              utf16_output);
  110|      8|      }
  111|       |
  112|    370|      __m128i utf16_packed = _mm_packus_epi32(_mm256_castsi256_si128(in),
  113|    370|                                              _mm256_extractf128_si256(in, 1));
  114|    370|      if (big_endian) {
  ------------------
  |  Branch (114:11): [True: 370, Folded]
  ------------------
  115|    370|        const __m128i swap =
  116|    370|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  117|    370|        utf16_packed = _mm_shuffle_epi8(utf16_packed, swap);
  118|    370|      }
  119|    370|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
  120|    370|      utf16_output += 8;
  121|    370|      buf += 8;
  122|    660|    } else {
  123|    660|      size_t forward = 7;
  124|    660|      size_t k = 0;
  125|    660|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (125:11): [True: 0, False: 660]
  ------------------
  126|      0|        forward = size_t(end - buf - 1);
  127|      0|      }
  128|  4.71k|      for (; k < forward; k++) {
  ------------------
  |  Branch (128:14): [True: 4.17k, False: 542]
  ------------------
  129|  4.17k|        uint32_t word = buf[k];
  130|  4.17k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (130:13): [True: 2.08k, False: 2.08k]
  ------------------
  131|       |          // will not generate a surrogate pair
  132|  2.08k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (132:15): [True: 794, False: 1.29k]
  |  Branch (132:33): [True: 8, False: 786]
  ------------------
  133|      8|            return std::make_pair(
  134|      8|                result(error_code::SURROGATE, buf - start + k), utf16_output);
  135|      8|          }
  136|  2.08k|          *utf16_output++ =
  137|  2.08k|              big_endian
  ------------------
  |  Branch (137:15): [True: 2.08k, Folded]
  ------------------
  138|  2.08k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
  139|  2.08k|                  : char16_t(word);
  140|  2.08k|        } else {
  141|       |          // will generate a surrogate pair
  142|  2.08k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (142:15): [True: 110, False: 1.97k]
  ------------------
  143|    110|            return std::make_pair(
  144|    110|                result(error_code::TOO_LARGE, buf - start + k), utf16_output);
  145|    110|          }
  146|  1.97k|          word -= 0x10000;
  147|  1.97k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
  148|  1.97k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
  149|  1.97k|          if (big_endian) {
  ------------------
  |  Branch (149:15): [True: 1.97k, Folded]
  ------------------
  150|  1.97k|            high_surrogate =
  151|  1.97k|                uint16_t((high_surrogate >> 8) | (high_surrogate << 8));
  152|  1.97k|            low_surrogate =
  153|  1.97k|                uint16_t((low_surrogate >> 8) | (low_surrogate << 8));
  154|  1.97k|          }
  155|  1.97k|          *utf16_output++ = char16_t(high_surrogate);
  156|  1.97k|          *utf16_output++ = char16_t(low_surrogate);
  157|  1.97k|        }
  158|  4.17k|      }
  159|    542|      buf += k;
  160|    542|    }
  161|  1.03k|  }
  162|       |
  163|    444|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf16_output);
  164|    570|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_126avx2_convert_utf32_to_utf8EPKDimPc:
    2|    786|avx2_convert_utf32_to_utf8(const char32_t *buf, size_t len, char *utf8_output) {
    3|    786|  const char32_t *end = buf + len;
    4|    786|  const __m256i v_0000 = _mm256_setzero_si256();
    5|    786|  const __m256i v_ffff0000 = _mm256_set1_epi32((uint32_t)0xffff0000);
    6|    786|  const __m256i v_ff80 = _mm256_set1_epi16((uint16_t)0xff80);
    7|    786|  const __m256i v_f800 = _mm256_set1_epi16((uint16_t)0xf800);
    8|    786|  const __m256i v_c080 = _mm256_set1_epi16((uint16_t)0xc080);
    9|    786|  const __m256i v_7fffffff = _mm256_set1_epi32((uint32_t)0x7fffffff);
   10|    786|  __m256i running_max = _mm256_setzero_si256();
   11|    786|  __m256i forbidden_bytemask = _mm256_setzero_si256();
   12|       |
   13|    786|  const size_t safety_margin =
   14|    786|      12; // to avoid overruns, see issue
   15|       |          // https://github.com/simdutf/simdutf/issues/92
   16|       |
   17|  35.7k|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (17:10): [True: 35.1k, False: 616]
  ------------------
   18|  35.1k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
   19|  35.1k|    __m256i nextin = _mm256_loadu_si256((__m256i *)buf + 1);
   20|  35.1k|    running_max = _mm256_max_epu32(_mm256_max_epu32(in, running_max), nextin);
   21|       |
   22|       |    // Pack 32-bit UTF-32 code units to 16-bit UTF-16 code units with unsigned
   23|       |    // saturation
   24|  35.1k|    __m256i in_16 = _mm256_packus_epi32(_mm256_and_si256(in, v_7fffffff),
   25|  35.1k|                                        _mm256_and_si256(nextin, v_7fffffff));
   26|  35.1k|    in_16 = _mm256_permute4x64_epi64(in_16, 0b11011000);
   27|       |
   28|       |    // Try to apply UTF-16 => UTF-8 routine on 256 bits
   29|       |    // (haswell/avx2_convert_utf16_to_utf8.cpp)
   30|       |
   31|  35.1k|    if (_mm256_testz_si256(in_16, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (31:9): [True: 31.4k, False: 3.63k]
  ------------------
   32|       |      // 1. pack the bytes
   33|  31.4k|      const __m128i utf8_packed = _mm_packus_epi16(
   34|  31.4k|          _mm256_castsi256_si128(in_16), _mm256_extractf128_si256(in_16, 1));
   35|       |      // 2. store (16 bytes)
   36|  31.4k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   37|       |      // 3. adjust pointers
   38|  31.4k|      buf += 16;
   39|  31.4k|      utf8_output += 16;
   40|  31.4k|      continue; // we are done for this round!
   41|  31.4k|    }
   42|       |    // no bits set above 7th bit
   43|  3.63k|    const __m256i one_byte_bytemask =
   44|  3.63k|        _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_ff80), v_0000);
   45|  3.63k|    const uint32_t one_byte_bitmask =
   46|  3.63k|        static_cast<uint32_t>(_mm256_movemask_epi8(one_byte_bytemask));
   47|       |
   48|       |    // no bits set above 11th bit
   49|  3.63k|    const __m256i one_or_two_bytes_bytemask =
   50|  3.63k|        _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_f800), v_0000);
   51|  3.63k|    const uint32_t one_or_two_bytes_bitmask =
   52|  3.63k|        static_cast<uint32_t>(_mm256_movemask_epi8(one_or_two_bytes_bytemask));
   53|  3.63k|    if (one_or_two_bytes_bitmask == 0xffffffff) {
  ------------------
  |  Branch (53:9): [True: 1.39k, False: 2.23k]
  ------------------
   54|       |      // 1. prepare 2-byte values
   55|       |      // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8
   56|       |      // expected output   : [110a|aaaa|10bb|bbbb] x 8
   57|  1.39k|      const __m256i v_1f00 = _mm256_set1_epi16((int16_t)0x1f00);
   58|  1.39k|      const __m256i v_003f = _mm256_set1_epi16((int16_t)0x003f);
   59|       |
   60|       |      // t0 = [000a|aaaa|bbbb|bb00]
   61|  1.39k|      const __m256i t0 = _mm256_slli_epi16(in_16, 2);
   62|       |      // t1 = [000a|aaaa|0000|0000]
   63|  1.39k|      const __m256i t1 = _mm256_and_si256(t0, v_1f00);
   64|       |      // t2 = [0000|0000|00bb|bbbb]
   65|  1.39k|      const __m256i t2 = _mm256_and_si256(in_16, v_003f);
   66|       |      // t3 = [000a|aaaa|00bb|bbbb]
   67|  1.39k|      const __m256i t3 = _mm256_or_si256(t1, t2);
   68|       |      // t4 = [110a|aaaa|10bb|bbbb]
   69|  1.39k|      const __m256i t4 = _mm256_or_si256(t3, v_c080);
   70|       |
   71|       |      // 2. merge ASCII and 2-byte codewords
   72|  1.39k|      const __m256i utf8_unpacked =
   73|  1.39k|          _mm256_blendv_epi8(t4, in_16, one_byte_bytemask);
   74|       |
   75|       |      // 3. prepare bitmask for 8-bit lookup
   76|  1.39k|      const uint32_t M0 = one_byte_bitmask & 0x55555555;
   77|  1.39k|      const uint32_t M1 = M0 >> 7;
   78|  1.39k|      const uint32_t M2 = (M1 | M0) & 0x00ff00ff;
   79|       |      // 4. pack the bytes
   80|       |
   81|  1.39k|      const uint8_t *row =
   82|  1.39k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2)][0];
   83|  1.39k|      const uint8_t *row_2 =
   84|  1.39k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2 >>
   85|  1.39k|                                                                       16)][0];
   86|       |
   87|  1.39k|      const __m128i shuffle = _mm_loadu_si128((__m128i *)(row + 1));
   88|  1.39k|      const __m128i shuffle_2 = _mm_loadu_si128((__m128i *)(row_2 + 1));
   89|       |
   90|  1.39k|      const __m256i utf8_packed = _mm256_shuffle_epi8(
   91|  1.39k|          utf8_unpacked, _mm256_setr_m128i(shuffle, shuffle_2));
  ------------------
  |  |    7|  1.39k|      _mm256_permute2f128_si256(_mm256_castsi128_si256(xmm1),                  \
  |  |    8|  1.39k|                                _mm256_castsi128_si256(xmm2), 2)
  ------------------
   92|       |      // 5. store bytes
   93|  1.39k|      _mm_storeu_si128((__m128i *)utf8_output,
   94|  1.39k|                       _mm256_castsi256_si128(utf8_packed));
   95|  1.39k|      utf8_output += row[0];
   96|  1.39k|      _mm_storeu_si128((__m128i *)utf8_output,
   97|  1.39k|                       _mm256_extractf128_si256(utf8_packed, 1));
   98|  1.39k|      utf8_output += row_2[0];
   99|       |
  100|       |      // 6. adjust pointers
  101|  1.39k|      buf += 16;
  102|  1.39k|      continue;
  103|  1.39k|    }
  104|       |    // Must check for overflow in packing
  105|  2.23k|    const __m256i saturation_bytemask = _mm256_cmpeq_epi32(
  106|  2.23k|        _mm256_and_si256(_mm256_or_si256(in, nextin), v_ffff0000), v_0000);
  107|  2.23k|    const uint32_t saturation_bitmask =
  108|  2.23k|        static_cast<uint32_t>(_mm256_movemask_epi8(saturation_bytemask));
  109|  2.23k|    if (saturation_bitmask == 0xffffffff) {
  ------------------
  |  Branch (109:9): [True: 760, False: 1.47k]
  ------------------
  110|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  111|    760|      const __m256i v_d800 = _mm256_set1_epi16((uint16_t)0xd800);
  112|    760|      forbidden_bytemask = _mm256_or_si256(
  113|    760|          forbidden_bytemask,
  114|    760|          _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_f800), v_d800));
  115|       |
  116|    760|      const __m256i dup_even = _mm256_setr_epi16(
  117|    760|          0x0000, 0x0202, 0x0404, 0x0606, 0x0808, 0x0a0a, 0x0c0c, 0x0e0e,
  118|    760|          0x0000, 0x0202, 0x0404, 0x0606, 0x0808, 0x0a0a, 0x0c0c, 0x0e0e);
  119|       |
  120|       |      /* In this branch we handle three cases:
  121|       |        1. [0000|0000|0ccc|cccc] => [0ccc|cccc]                           -
  122|       |        single UFT-8 byte
  123|       |        2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc]              - two
  124|       |        UTF-8 bytes
  125|       |        3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] -
  126|       |        three UTF-8 bytes
  127|       |
  128|       |        We expand the input word (16-bit) into two code units (32-bit), thus
  129|       |        we have room for four bytes. However, we need five distinct bit
  130|       |        layouts. Note that the last byte in cases #2 and #3 is the same.
  131|       |
  132|       |        We precompute byte 1 for case #1 and the common byte for cases #2 & #3
  133|       |        in register t2.
  134|       |
  135|       |        We precompute byte 1 for case #3 and -- **conditionally** -- precompute
  136|       |        either byte 1 for case #2 or byte 2 for case #3. Note that they
  137|       |        differ by exactly one bit.
  138|       |
  139|       |        Finally from these two code units we build proper UTF-8 sequence, taking
  140|       |        into account the case (i.e, the number of bytes to write).
  141|       |      */
  142|       |      /**
  143|       |       * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce:
  144|       |       * t2 => [0ccc|cccc] [10cc|cccc]
  145|       |       * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb])
  146|       |       */
  147|    760|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  148|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  149|    760|      const __m256i t0 = _mm256_shuffle_epi8(in_16, dup_even);
  150|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  151|    760|      const __m256i t1 = _mm256_and_si256(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  147|    760|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  152|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  153|    760|      const __m256i t2 = _mm256_or_si256(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  147|    760|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  154|       |
  155|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  156|    760|      const __m256i s0 = _mm256_srli_epi16(in_16, 4);
  157|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  158|    760|      const __m256i s1 = _mm256_and_si256(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  147|    760|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  159|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  160|    760|      const __m256i s2 = _mm256_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  147|    760|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  161|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  162|    760|      const __m256i s3 = _mm256_or_si256(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  147|    760|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  163|    760|      const __m256i m0 = _mm256_andnot_si256(one_or_two_bytes_bytemask,
  164|    760|                                             simdutf_vec(0b0100000000000000));
  ------------------
  |  |  147|    760|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  165|    760|      const __m256i s4 = _mm256_xor_si256(s3, m0);
  166|    760|#undef simdutf_vec
  167|       |
  168|       |      // 4. expand code units 16-bit => 32-bit
  169|    760|      const __m256i out0 = _mm256_unpacklo_epi16(t2, s4);
  170|    760|      const __m256i out1 = _mm256_unpackhi_epi16(t2, s4);
  171|       |
  172|       |      // 5. compress 32-bit code units into 1, 2 or 3 bytes -- 2 x shuffle
  173|    760|      const uint32_t mask = (one_byte_bitmask & 0x55555555) |
  174|    760|                            (one_or_two_bytes_bitmask & 0xaaaaaaaa);
  175|       |      // Due to the wider registers, the following path is less likely to be
  176|       |      // useful.
  177|       |      /*if(mask == 0) {
  178|       |        // We only have three-byte code units. Use fast path.
  179|       |        const __m256i shuffle =
  180|       |      _mm256_setr_epi8(2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1,
  181|       |      2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1); const __m256i utf8_0 =
  182|       |      _mm256_shuffle_epi8(out0, shuffle); const __m256i utf8_1 =
  183|       |      _mm256_shuffle_epi8(out1, shuffle);
  184|       |        _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_0));
  185|       |        utf8_output += 12;
  186|       |        _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_1));
  187|       |        utf8_output += 12;
  188|       |        _mm_storeu_si128((__m128i*)utf8_output,
  189|       |      _mm256_extractf128_si256(utf8_0,1)); utf8_output += 12;
  190|       |        _mm_storeu_si128((__m128i*)utf8_output,
  191|       |      _mm256_extractf128_si256(utf8_1,1)); utf8_output += 12; buf += 16;
  192|       |        continue;
  193|       |      }*/
  194|    760|      const uint8_t mask0 = uint8_t(mask);
  195|    760|      const uint8_t *row0 =
  196|    760|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  197|    760|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  198|    760|      const __m128i utf8_0 =
  199|    760|          _mm_shuffle_epi8(_mm256_castsi256_si128(out0), shuffle0);
  200|       |
  201|    760|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  202|    760|      const uint8_t *row1 =
  203|    760|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  204|    760|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  205|    760|      const __m128i utf8_1 =
  206|    760|          _mm_shuffle_epi8(_mm256_castsi256_si128(out1), shuffle1);
  207|       |
  208|    760|      const uint8_t mask2 = static_cast<uint8_t>(mask >> 16);
  209|    760|      const uint8_t *row2 =
  210|    760|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask2][0];
  211|    760|      const __m128i shuffle2 = _mm_loadu_si128((__m128i *)(row2 + 1));
  212|    760|      const __m128i utf8_2 =
  213|    760|          _mm_shuffle_epi8(_mm256_extractf128_si256(out0, 1), shuffle2);
  214|       |
  215|    760|      const uint8_t mask3 = static_cast<uint8_t>(mask >> 24);
  216|    760|      const uint8_t *row3 =
  217|    760|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask3][0];
  218|    760|      const __m128i shuffle3 = _mm_loadu_si128((__m128i *)(row3 + 1));
  219|    760|      const __m128i utf8_3 =
  220|    760|          _mm_shuffle_epi8(_mm256_extractf128_si256(out1, 1), shuffle3);
  221|       |
  222|    760|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  223|    760|      utf8_output += row0[0];
  224|    760|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  225|    760|      utf8_output += row1[0];
  226|    760|      _mm_storeu_si128((__m128i *)utf8_output, utf8_2);
  227|    760|      utf8_output += row2[0];
  228|    760|      _mm_storeu_si128((__m128i *)utf8_output, utf8_3);
  229|    760|      utf8_output += row3[0];
  230|    760|      buf += 16;
  231|  1.47k|    } else {
  232|       |      // case: at least one 32-bit word is larger than 0xFFFF <=> it will
  233|       |      // produce four UTF-8 bytes. Let us do a scalar fallback. It may seem
  234|       |      // wasteful to use scalar code, but being efficient with SIMD may require
  235|       |      // large, non-trivial tables?
  236|  1.47k|      size_t forward = 15;
  237|  1.47k|      size_t k = 0;
  238|  1.47k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (238:11): [True: 0, False: 1.47k]
  ------------------
  239|      0|        forward = size_t(end - buf - 1);
  240|      0|      }
  241|  21.8k|      for (; k < forward; k++) {
  ------------------
  |  Branch (241:14): [True: 20.4k, False: 1.30k]
  ------------------
  242|  20.4k|        uint32_t word = buf[k];
  243|  20.4k|        if ((word & 0xFFFFFF80) == 0) { // 1-byte (ASCII)
  ------------------
  |  Branch (243:13): [True: 8.78k, False: 11.7k]
  ------------------
  244|  8.78k|          *utf8_output++ = char(word);
  245|  11.7k|        } else if ((word & 0xFFFFF800) == 0) { // 2-byte
  ------------------
  |  Branch (245:20): [True: 1.63k, False: 10.0k]
  ------------------
  246|  1.63k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  247|  1.63k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  248|  10.0k|        } else if ((word & 0xFFFF0000) == 0) { // 3-byte
  ------------------
  |  Branch (248:20): [True: 3.69k, False: 6.38k]
  ------------------
  249|  3.69k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (249:15): [True: 1.23k, False: 2.46k]
  |  Branch (249:33): [True: 16, False: 1.21k]
  ------------------
  250|     16|            return std::make_pair(nullptr, utf8_output);
  251|     16|          }
  252|  3.68k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  253|  3.68k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  254|  3.68k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  255|  6.38k|        } else { // 4-byte
  256|  6.38k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (256:15): [True: 154, False: 6.22k]
  ------------------
  257|    154|            return std::make_pair(nullptr, utf8_output);
  258|    154|          }
  259|  6.22k|          *utf8_output++ = char((word >> 18) | 0b11110000);
  260|  6.22k|          *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000);
  261|  6.22k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  262|  6.22k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  263|  6.22k|        }
  264|  20.4k|      }
  265|  1.30k|      buf += k;
  266|  1.30k|    }
  267|  2.23k|  } // while
  268|       |
  269|       |  // check for invalid input
  270|    616|  const __m256i v_10ffff = _mm256_set1_epi32((uint32_t)0x10ffff);
  271|    616|  if (static_cast<uint32_t>(_mm256_movemask_epi8(_mm256_cmpeq_epi32(
  ------------------
  |  Branch (271:7): [True: 28, False: 588]
  ------------------
  272|    616|          _mm256_max_epu32(running_max, v_10ffff), v_10ffff))) != 0xffffffff) {
  273|     28|    return std::make_pair(nullptr, utf8_output);
  274|     28|  }
  275|       |
  276|    588|  if (static_cast<uint32_t>(_mm256_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (276:7): [True: 60, False: 528]
  ------------------
  277|     60|    return std::make_pair(nullptr, utf8_output);
  278|     60|  }
  279|       |
  280|    528|  return std::make_pair(buf, utf8_output);
  281|    588|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_138avx2_convert_utf32_to_utf8_with_errorsEPKDimPc:
  285|    772|                                       char *utf8_output) {
  286|    772|  const char32_t *end = buf + len;
  287|    772|  const char32_t *start = buf;
  288|       |
  289|    772|  const __m256i v_0000 = _mm256_setzero_si256();
  290|    772|  const __m256i v_ffff0000 = _mm256_set1_epi32((uint32_t)0xffff0000);
  291|    772|  const __m256i v_ff80 = _mm256_set1_epi16((uint16_t)0xff80);
  292|    772|  const __m256i v_f800 = _mm256_set1_epi16((uint16_t)0xf800);
  293|    772|  const __m256i v_c080 = _mm256_set1_epi16((uint16_t)0xc080);
  294|    772|  const __m256i v_7fffffff = _mm256_set1_epi32((uint32_t)0x7fffffff);
  295|    772|  const __m256i v_10ffff = _mm256_set1_epi32((uint32_t)0x10ffff);
  296|       |
  297|    772|  const size_t safety_margin =
  298|    772|      12; // to avoid overruns, see issue
  299|       |          // https://github.com/simdutf/simdutf/issues/92
  300|       |
  301|  3.95k|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (301:10): [True: 3.34k, False: 606]
  ------------------
  302|  3.34k|    __m256i in = _mm256_loadu_si256((__m256i *)buf);
  303|  3.34k|    __m256i nextin = _mm256_loadu_si256((__m256i *)buf + 1);
  304|       |    // Check for too large input
  305|  3.34k|    const __m256i max_input =
  306|  3.34k|        _mm256_max_epu32(_mm256_max_epu32(in, nextin), v_10ffff);
  307|  3.34k|    if (static_cast<uint32_t>(_mm256_movemask_epi8(
  ------------------
  |  Branch (307:9): [True: 102, False: 3.24k]
  ------------------
  308|  3.34k|            _mm256_cmpeq_epi32(max_input, v_10ffff))) != 0xffffffff) {
  309|    102|      return std::make_pair(result(error_code::TOO_LARGE, buf - start),
  310|    102|                            utf8_output);
  311|    102|    }
  312|       |
  313|       |    // Pack 32-bit UTF-32 code units to 16-bit UTF-16 code units with unsigned
  314|       |    // saturation
  315|  3.24k|    __m256i in_16 = _mm256_packus_epi32(_mm256_and_si256(in, v_7fffffff),
  316|  3.24k|                                        _mm256_and_si256(nextin, v_7fffffff));
  317|  3.24k|    in_16 = _mm256_permute4x64_epi64(in_16, 0b11011000);
  318|       |
  319|       |    // Try to apply UTF-16 => UTF-8 routine on 256 bits
  320|       |    // (haswell/avx2_convert_utf16_to_utf8.cpp)
  321|       |
  322|  3.24k|    if (_mm256_testz_si256(in_16, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (322:9): [True: 632, False: 2.61k]
  ------------------
  323|       |      // 1. pack the bytes
  324|    632|      const __m128i utf8_packed = _mm_packus_epi16(
  325|    632|          _mm256_castsi256_si128(in_16), _mm256_extractf128_si256(in_16, 1));
  326|       |      // 2. store (16 bytes)
  327|    632|      _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  328|       |      // 3. adjust pointers
  329|    632|      buf += 16;
  330|    632|      utf8_output += 16;
  331|    632|      continue; // we are done for this round!
  332|    632|    }
  333|       |    // no bits set above 7th bit
  334|  2.61k|    const __m256i one_byte_bytemask =
  335|  2.61k|        _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_ff80), v_0000);
  336|  2.61k|    const uint32_t one_byte_bitmask =
  337|  2.61k|        static_cast<uint32_t>(_mm256_movemask_epi8(one_byte_bytemask));
  338|       |
  339|       |    // no bits set above 11th bit
  340|  2.61k|    const __m256i one_or_two_bytes_bytemask =
  341|  2.61k|        _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_f800), v_0000);
  342|  2.61k|    const uint32_t one_or_two_bytes_bitmask =
  343|  2.61k|        static_cast<uint32_t>(_mm256_movemask_epi8(one_or_two_bytes_bytemask));
  344|  2.61k|    if (one_or_two_bytes_bitmask == 0xffffffff) {
  ------------------
  |  Branch (344:9): [True: 1.23k, False: 1.38k]
  ------------------
  345|       |      // 1. prepare 2-byte values
  346|       |      // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8
  347|       |      // expected output   : [110a|aaaa|10bb|bbbb] x 8
  348|  1.23k|      const __m256i v_1f00 = _mm256_set1_epi16((int16_t)0x1f00);
  349|  1.23k|      const __m256i v_003f = _mm256_set1_epi16((int16_t)0x003f);
  350|       |
  351|       |      // t0 = [000a|aaaa|bbbb|bb00]
  352|  1.23k|      const __m256i t0 = _mm256_slli_epi16(in_16, 2);
  353|       |      // t1 = [000a|aaaa|0000|0000]
  354|  1.23k|      const __m256i t1 = _mm256_and_si256(t0, v_1f00);
  355|       |      // t2 = [0000|0000|00bb|bbbb]
  356|  1.23k|      const __m256i t2 = _mm256_and_si256(in_16, v_003f);
  357|       |      // t3 = [000a|aaaa|00bb|bbbb]
  358|  1.23k|      const __m256i t3 = _mm256_or_si256(t1, t2);
  359|       |      // t4 = [110a|aaaa|10bb|bbbb]
  360|  1.23k|      const __m256i t4 = _mm256_or_si256(t3, v_c080);
  361|       |
  362|       |      // 2. merge ASCII and 2-byte codewords
  363|  1.23k|      const __m256i utf8_unpacked =
  364|  1.23k|          _mm256_blendv_epi8(t4, in_16, one_byte_bytemask);
  365|       |
  366|       |      // 3. prepare bitmask for 8-bit lookup
  367|  1.23k|      const uint32_t M0 = one_byte_bitmask & 0x55555555;
  368|  1.23k|      const uint32_t M1 = M0 >> 7;
  369|  1.23k|      const uint32_t M2 = (M1 | M0) & 0x00ff00ff;
  370|       |      // 4. pack the bytes
  371|       |
  372|  1.23k|      const uint8_t *row =
  373|  1.23k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2)][0];
  374|  1.23k|      const uint8_t *row_2 =
  375|  1.23k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[uint8_t(M2 >>
  376|  1.23k|                                                                       16)][0];
  377|       |
  378|  1.23k|      const __m128i shuffle = _mm_loadu_si128((__m128i *)(row + 1));
  379|  1.23k|      const __m128i shuffle_2 = _mm_loadu_si128((__m128i *)(row_2 + 1));
  380|       |
  381|  1.23k|      const __m256i utf8_packed = _mm256_shuffle_epi8(
  382|  1.23k|          utf8_unpacked, _mm256_setr_m128i(shuffle, shuffle_2));
  ------------------
  |  |    7|  1.23k|      _mm256_permute2f128_si256(_mm256_castsi128_si256(xmm1),                  \
  |  |    8|  1.23k|                                _mm256_castsi128_si256(xmm2), 2)
  ------------------
  383|       |      // 5. store bytes
  384|  1.23k|      _mm_storeu_si128((__m128i *)utf8_output,
  385|  1.23k|                       _mm256_castsi256_si128(utf8_packed));
  386|  1.23k|      utf8_output += row[0];
  387|  1.23k|      _mm_storeu_si128((__m128i *)utf8_output,
  388|  1.23k|                       _mm256_extractf128_si256(utf8_packed, 1));
  389|  1.23k|      utf8_output += row_2[0];
  390|       |
  391|       |      // 6. adjust pointers
  392|  1.23k|      buf += 16;
  393|  1.23k|      continue;
  394|  1.23k|    }
  395|       |    // Must check for overflow in packing
  396|  1.38k|    const __m256i saturation_bytemask = _mm256_cmpeq_epi32(
  397|  1.38k|        _mm256_and_si256(_mm256_or_si256(in, nextin), v_ffff0000), v_0000);
  398|  1.38k|    const uint32_t saturation_bitmask =
  399|  1.38k|        static_cast<uint32_t>(_mm256_movemask_epi8(saturation_bytemask));
  400|  1.38k|    if (saturation_bitmask == 0xffffffff) {
  ------------------
  |  Branch (400:9): [True: 600, False: 782]
  ------------------
  401|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  402|       |
  403|       |      // Check for illegal surrogate code units
  404|    600|      const __m256i v_d800 = _mm256_set1_epi16((uint16_t)0xd800);
  405|    600|      const __m256i forbidden_bytemask =
  406|    600|          _mm256_cmpeq_epi16(_mm256_and_si256(in_16, v_f800), v_d800);
  407|    600|      if (static_cast<uint32_t>(_mm256_movemask_epi8(forbidden_bytemask)) !=
  ------------------
  |  Branch (407:11): [True: 52, False: 548]
  ------------------
  408|    600|          0x0) {
  409|     52|        return std::make_pair(result(error_code::SURROGATE, buf - start),
  410|     52|                              utf8_output);
  411|     52|      }
  412|       |
  413|    548|      const __m256i dup_even = _mm256_setr_epi16(
  414|    548|          0x0000, 0x0202, 0x0404, 0x0606, 0x0808, 0x0a0a, 0x0c0c, 0x0e0e,
  415|    548|          0x0000, 0x0202, 0x0404, 0x0606, 0x0808, 0x0a0a, 0x0c0c, 0x0e0e);
  416|       |
  417|       |      /* In this branch we handle three cases:
  418|       |        1. [0000|0000|0ccc|cccc] => [0ccc|cccc]                           -
  419|       |        single UFT-8 byte
  420|       |        2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc]              - two
  421|       |        UTF-8 bytes
  422|       |        3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] -
  423|       |        three UTF-8 bytes
  424|       |
  425|       |        We expand the input word (16-bit) into two code units (32-bit), thus
  426|       |        we have room for four bytes. However, we need five distinct bit
  427|       |        layouts. Note that the last byte in cases #2 and #3 is the same.
  428|       |
  429|       |        We precompute byte 1 for case #1 and the common byte for cases #2 & #3
  430|       |        in register t2.
  431|       |
  432|       |        We precompute byte 1 for case #3 and -- **conditionally** -- precompute
  433|       |        either byte 1 for case #2 or byte 2 for case #3. Note that they
  434|       |        differ by exactly one bit.
  435|       |
  436|       |        Finally from these two code units we build proper UTF-8 sequence, taking
  437|       |        into account the case (i.e, the number of bytes to write).
  438|       |      */
  439|       |      /**
  440|       |       * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce:
  441|       |       * t2 => [0ccc|cccc] [10cc|cccc]
  442|       |       * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb])
  443|       |       */
  444|    548|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  445|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  446|    548|      const __m256i t0 = _mm256_shuffle_epi8(in_16, dup_even);
  447|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  448|    548|      const __m256i t1 = _mm256_and_si256(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  444|    548|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  449|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  450|    548|      const __m256i t2 = _mm256_or_si256(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  444|    548|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  451|       |
  452|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  453|    548|      const __m256i s0 = _mm256_srli_epi16(in_16, 4);
  454|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  455|    548|      const __m256i s1 = _mm256_and_si256(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  444|    548|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  456|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  457|    548|      const __m256i s2 = _mm256_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  444|    548|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  458|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  459|    548|      const __m256i s3 = _mm256_or_si256(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  444|    548|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  460|    548|      const __m256i m0 = _mm256_andnot_si256(one_or_two_bytes_bytemask,
  461|    548|                                             simdutf_vec(0b0100000000000000));
  ------------------
  |  |  444|    548|#define simdutf_vec(x) _mm256_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  462|    548|      const __m256i s4 = _mm256_xor_si256(s3, m0);
  463|    548|#undef simdutf_vec
  464|       |
  465|       |      // 4. expand code units 16-bit => 32-bit
  466|    548|      const __m256i out0 = _mm256_unpacklo_epi16(t2, s4);
  467|    548|      const __m256i out1 = _mm256_unpackhi_epi16(t2, s4);
  468|       |
  469|       |      // 5. compress 32-bit code units into 1, 2 or 3 bytes -- 2 x shuffle
  470|    548|      const uint32_t mask = (one_byte_bitmask & 0x55555555) |
  471|    548|                            (one_or_two_bytes_bitmask & 0xaaaaaaaa);
  472|       |      // Due to the wider registers, the following path is less likely to be
  473|       |      // useful.
  474|       |      /*if(mask == 0) {
  475|       |        // We only have three-byte code units. Use fast path.
  476|       |        const __m256i shuffle =
  477|       |      _mm256_setr_epi8(2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1,
  478|       |      2,3,1,6,7,5,10,11,9,14,15,13,-1,-1,-1,-1); const __m256i utf8_0 =
  479|       |      _mm256_shuffle_epi8(out0, shuffle); const __m256i utf8_1 =
  480|       |      _mm256_shuffle_epi8(out1, shuffle);
  481|       |        _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_0));
  482|       |        utf8_output += 12;
  483|       |        _mm_storeu_si128((__m128i*)utf8_output, _mm256_castsi256_si128(utf8_1));
  484|       |        utf8_output += 12;
  485|       |        _mm_storeu_si128((__m128i*)utf8_output,
  486|       |      _mm256_extractf128_si256(utf8_0,1)); utf8_output += 12;
  487|       |        _mm_storeu_si128((__m128i*)utf8_output,
  488|       |      _mm256_extractf128_si256(utf8_1,1)); utf8_output += 12; buf += 16;
  489|       |        continue;
  490|       |      }*/
  491|    548|      const uint8_t mask0 = uint8_t(mask);
  492|    548|      const uint8_t *row0 =
  493|    548|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  494|    548|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  495|    548|      const __m128i utf8_0 =
  496|    548|          _mm_shuffle_epi8(_mm256_castsi256_si128(out0), shuffle0);
  497|       |
  498|    548|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  499|    548|      const uint8_t *row1 =
  500|    548|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  501|    548|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  502|    548|      const __m128i utf8_1 =
  503|    548|          _mm_shuffle_epi8(_mm256_castsi256_si128(out1), shuffle1);
  504|       |
  505|    548|      const uint8_t mask2 = static_cast<uint8_t>(mask >> 16);
  506|    548|      const uint8_t *row2 =
  507|    548|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask2][0];
  508|    548|      const __m128i shuffle2 = _mm_loadu_si128((__m128i *)(row2 + 1));
  509|    548|      const __m128i utf8_2 =
  510|    548|          _mm_shuffle_epi8(_mm256_extractf128_si256(out0, 1), shuffle2);
  511|       |
  512|    548|      const uint8_t mask3 = static_cast<uint8_t>(mask >> 24);
  513|    548|      const uint8_t *row3 =
  514|    548|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask3][0];
  515|    548|      const __m128i shuffle3 = _mm_loadu_si128((__m128i *)(row3 + 1));
  516|    548|      const __m128i utf8_3 =
  517|    548|          _mm_shuffle_epi8(_mm256_extractf128_si256(out1, 1), shuffle3);
  518|       |
  519|    548|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  520|    548|      utf8_output += row0[0];
  521|    548|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  522|    548|      utf8_output += row1[0];
  523|    548|      _mm_storeu_si128((__m128i *)utf8_output, utf8_2);
  524|    548|      utf8_output += row2[0];
  525|    548|      _mm_storeu_si128((__m128i *)utf8_output, utf8_3);
  526|    548|      utf8_output += row3[0];
  527|    548|      buf += 16;
  528|    782|    } else {
  529|       |      // case: at least one 32-bit word is larger than 0xFFFF <=> it will
  530|       |      // produce four UTF-8 bytes. Let us do a scalar fallback. It may seem
  531|       |      // wasteful to use scalar code, but being efficient with SIMD may require
  532|       |      // large, non-trivial tables?
  533|    782|      size_t forward = 15;
  534|    782|      size_t k = 0;
  535|    782|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (535:11): [True: 0, False: 782]
  ------------------
  536|      0|        forward = size_t(end - buf - 1);
  537|      0|      }
  538|  12.4k|      for (; k < forward; k++) {
  ------------------
  |  Branch (538:14): [True: 11.6k, False: 770]
  ------------------
  539|  11.6k|        uint32_t word = buf[k];
  540|  11.6k|        if ((word & 0xFFFFFF80) == 0) { // 1-byte (ASCII)
  ------------------
  |  Branch (540:13): [True: 3.52k, False: 8.11k]
  ------------------
  541|  3.52k|          *utf8_output++ = char(word);
  542|  8.11k|        } else if ((word & 0xFFFFF800) == 0) { // 2-byte
  ------------------
  |  Branch (542:20): [True: 1.12k, False: 6.99k]
  ------------------
  543|  1.12k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  544|  1.12k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  545|  6.99k|        } else if ((word & 0xFFFF0000) == 0) { // 3-byte
  ------------------
  |  Branch (545:20): [True: 1.81k, False: 5.17k]
  ------------------
  546|  1.81k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (546:15): [True: 888, False: 926]
  |  Branch (546:33): [True: 12, False: 876]
  ------------------
  547|     12|            return std::make_pair(
  548|     12|                result(error_code::SURROGATE, buf - start + k), utf8_output);
  549|     12|          }
  550|  1.80k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  551|  1.80k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  552|  1.80k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  553|  5.17k|        } else { // 4-byte
  554|  5.17k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (554:15): [True: 0, False: 5.17k]
  ------------------
  555|      0|            return std::make_pair(
  556|      0|                result(error_code::TOO_LARGE, buf - start + k), utf8_output);
  557|      0|          }
  558|  5.17k|          *utf8_output++ = char((word >> 18) | 0b11110000);
  559|  5.17k|          *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000);
  560|  5.17k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  561|  5.17k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  562|  5.17k|        }
  563|  11.6k|      }
  564|    770|      buf += k;
  565|    770|    }
  566|  1.38k|  } // while
  567|       |
  568|    606|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output);
  569|    772|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_134convert_1_2_byte_utf8_to_latin1_16EPKctPc:
    4|   118k|    const char *input, uint16_t leading_mask, char *latin1_output) {
    5|   118k|  const __m128i in = _mm_loadu_si128(reinterpret_cast<const __m128i *>(input));
    6|   118k|  const __m128i next =
    7|   118k|      _mm_loadu_si128(reinterpret_cast<const __m128i *>(input + 1));
    8|   118k|  const __m128i combined = _mm_or_si128(
    9|   118k|      _mm_and_si128(_mm_slli_epi16(in, 6), _mm_set1_epi8(char(0xc0))),
   10|   118k|      _mm_and_si128(next, _mm_set1_epi8(0x3f)));
   11|   118k|  const __m128i value =
   12|   118k|      _mm_blendv_epi8(in, combined, _mm_and_si128(in, _mm_add_epi8(in, in)));
   13|   118k|  const uint8_t lo = uint8_t(leading_mask);
   14|   118k|  const uint8_t hi = uint8_t(leading_mask >> 8);
   15|   118k|  const __m128i shuffle = _mm_set_epi64x(
   16|   118k|      int64_t(tables::utf8_to_latin1::pack_8[hi] + 0x0808080808080808),
   17|   118k|      int64_t(tables::utf8_to_latin1::pack_8[lo]));
   18|   118k|  const __m128i packed = _mm_shuffle_epi8(value, shuffle);
   19|   118k|  const size_t lo_count = count_ones(lo);
   20|   118k|  _mm_storel_epi64(reinterpret_cast<__m128i *>(latin1_output), packed);
   21|   118k|  _mm_storel_epi64(reinterpret_cast<__m128i *>(latin1_output + lo_count),
   22|   118k|                   _mm_unpackhi_epi64(packed, packed));
   23|   118k|  return lo_count + count_ones(hi);
   24|   118k|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_128convert_masked_utf8_to_utf16ILNS_10endiannessE0EEEmPKcmRPDs:
   10|  2.28M|                                    char16_t *&utf16_output) {
   11|       |  // we use an approach where we try to process up to 12 input bytes.
   12|       |  // Why 12 input bytes and not 16? Because we are concerned with the size of
   13|       |  // the lookup tables. Also 12 is nicely divisible by two and three.
   14|       |  //
   15|       |  //
   16|       |  // Optimization note: our main path below is load-latency dependent. Thus it
   17|       |  // is maybe beneficial to have fast paths that depend on branch prediction but
   18|       |  // have less latency. This results in more instructions but, potentially, also
   19|       |  // higher speeds.
   20|       |  //
   21|       |  // We first try a few fast paths.
   22|  2.28M|  const __m128i swap =
   23|  2.28M|      _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   24|  2.28M|  const __m128i in = _mm_loadu_si128((__m128i *)input);
   25|  2.28M|  const uint16_t input_utf8_end_of_code_point_mask =
   26|  2.28M|      utf8_end_of_code_point_mask & 0xfff;
   27|  2.28M|  if ((utf8_end_of_code_point_mask & 0xfff) == 0xfff) {
  ------------------
  |  Branch (27:7): [True: 1.06M, False: 1.22M]
  ------------------
   28|       |    // We process the data in chunks of 12 bytes.
   29|  1.06M|    __m256i ascii = _mm256_cvtepu8_epi16(in);
   30|  1.06M|    if (big_endian) {
  ------------------
  |  Branch (30:9): [Folded, False: 1.06M]
  ------------------
   31|      0|      const __m256i swap256 = _mm256_setr_epi8(
   32|      0|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
   33|      0|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
   34|      0|      ascii = _mm256_shuffle_epi8(ascii, swap256);
   35|      0|    }
   36|  1.06M|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf16_output), ascii);
   37|  1.06M|    utf16_output += 12; // We wrote 12 16-bit characters.
   38|  1.06M|    return 12;          // We consumed 12 bytes.
   39|  1.06M|  }
   40|  1.22M|  if (((utf8_end_of_code_point_mask & 0xffff) == 0xaaaa)) {
  ------------------
  |  Branch (40:7): [True: 6.83k, False: 1.21M]
  ------------------
   41|       |    // We want to take 8 2-byte UTF-8 code units and turn them into 8 2-byte
   42|       |    // UTF-16 code units. There is probably a more efficient sequence, but the
   43|       |    // following might do.
   44|  6.83k|    const __m128i sh =
   45|  6.83k|        _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   46|  6.83k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   47|  6.83k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   48|  6.83k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   49|  6.83k|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   50|  6.83k|    if (big_endian)
  ------------------
  |  Branch (50:9): [Folded, False: 6.83k]
  ------------------
   51|      0|      composed = _mm_shuffle_epi8(composed, swap);
   52|  6.83k|    _mm_storeu_si128((__m128i *)utf16_output, composed);
   53|  6.83k|    utf16_output += 8; // We wrote 16 bytes, 8 code points.
   54|  6.83k|    return 16;
   55|  6.83k|  }
   56|  1.21M|  if (input_utf8_end_of_code_point_mask == 0x924) {
  ------------------
  |  Branch (56:7): [True: 2.60k, False: 1.21M]
  ------------------
   57|       |    // We want to take 4 3-byte UTF-8 code units and turn them into 4 2-byte
   58|       |    // UTF-16 code units. There is probably a more efficient sequence, but the
   59|       |    // following might do.
   60|  2.60k|    const __m128i sh =
   61|  2.60k|        _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1);
   62|  2.60k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   63|  2.60k|    const __m128i ascii =
   64|  2.60k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
   65|  2.60k|    const __m128i middlebyte =
   66|  2.60k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
   67|  2.60k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
   68|  2.60k|    const __m128i highbyte =
   69|  2.60k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
   70|  2.60k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
   71|  2.60k|    const __m128i composed =
   72|  2.60k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
   73|  2.60k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
   74|  2.60k|    if (big_endian)
  ------------------
  |  Branch (74:9): [Folded, False: 2.60k]
  ------------------
   75|      0|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
   76|  2.60k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
   77|  2.60k|    utf16_output += 4;
   78|  2.60k|    return 12;
   79|  2.60k|  }
   80|       |
   81|  1.21M|  const uint8_t idx = simdutf::tables::utf8_to_utf16::utf8bigindex
   82|  1.21M|      [input_utf8_end_of_code_point_mask][0];
   83|  1.21M|  const uint8_t consumed = simdutf::tables::utf8_to_utf16::utf8bigindex
   84|  1.21M|      [input_utf8_end_of_code_point_mask][1];
   85|  1.21M|  if (idx < 64) {
  ------------------
  |  Branch (85:7): [True: 710k, False: 501k]
  ------------------
   86|       |    // SIX (6) input code-code units
   87|       |    // this is a relatively easy scenario
   88|       |    // we process SIX (6) input code-code units. The max length in bytes of six
   89|       |    // code code units spanning between 1 and 2 bytes each is 12 bytes. On
   90|       |    // processors where pdep/pext is fast, we might be able to use a small
   91|       |    // lookup table.
   92|   710k|    const __m128i sh = _mm_loadu_si128(
   93|   710k|        (const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]);
   94|   710k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   95|   710k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   96|   710k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   97|   710k|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   98|   710k|    if (big_endian)
  ------------------
  |  Branch (98:9): [Folded, False: 710k]
  ------------------
   99|      0|      composed = _mm_shuffle_epi8(composed, swap);
  100|   710k|    _mm_storeu_si128((__m128i *)utf16_output, composed);
  101|   710k|    utf16_output += 6; // We wrote 12 bytes, 6 code points. There is a potential
  102|       |                       // overflow of 4 bytes.
  103|   710k|  } else if (idx < 145) {
  ------------------
  |  Branch (103:14): [True: 447k, False: 54.0k]
  ------------------
  104|       |    // FOUR (4) input code-code units
  105|   447k|    const __m128i sh = _mm_loadu_si128(
  106|   447k|        (const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]);
  107|   447k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  108|   447k|    const __m128i ascii =
  109|   447k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
  110|   447k|    const __m128i middlebyte =
  111|   447k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
  112|   447k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  113|   447k|    const __m128i highbyte =
  114|   447k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
  115|   447k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
  116|   447k|    const __m128i composed =
  117|   447k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
  118|   447k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
  119|   447k|    if (big_endian)
  ------------------
  |  Branch (119:9): [Folded, False: 447k]
  ------------------
  120|      0|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
  121|   447k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
  122|   447k|    utf16_output += 4; // Here we overflow by 8 bytes.
  123|   447k|  } else if (idx < 209) {
  ------------------
  |  Branch (123:14): [True: 53.7k, False: 248]
  ------------------
  124|       |    // TWO (2) input code-code units
  125|       |    //////////////
  126|       |    // There might be garbage inputs where a leading byte mascarades as a
  127|       |    // four-byte leading byte (by being followed by 3 continuation byte), but is
  128|       |    // not greater than 0xf0. This could trigger a buffer overflow if we only
  129|       |    // counted leading bytes of the form 0xf0 as generating surrogate pairs,
  130|       |    // without further UTF-8 validation. Thus we must be careful to ensure that
  131|       |    // only leading bytes at least as large as 0xf0 generate surrogate pairs. We
  132|       |    // do as at the cost of an extra mask.
  133|       |    /////////////
  134|  53.7k|    const __m128i sh = _mm_loadu_si128(
  135|  53.7k|        (const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]);
  136|  53.7k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  137|  53.7k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f));
  138|  53.7k|    const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00));
  139|  53.7k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  140|  53.7k|    __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000));
  141|       |    // correct for spurious high bit
  142|  53.7k|    const __m128i correct =
  143|  53.7k|        _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1);
  144|  53.7k|    middlehighbyte = _mm_xor_si128(correct, middlehighbyte);
  145|  53.7k|    const __m128i middlehighbyte_shifted = _mm_srli_epi32(middlehighbyte, 4);
  146|       |    // We deliberately carry the leading four bits in highbyte if they are
  147|       |    // present, we remove them later when computing hightenbits.
  148|  53.7k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0xff000000));
  149|  53.7k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 6);
  150|       |    // When we need to generate a surrogate pair (leading byte > 0xF0), then
  151|       |    // the corresponding 32-bit value in 'composed'  will be greater than
  152|       |    // > (0xff00000>>6) or > 0x3c00000. This can be used later to identify the
  153|       |    // location of the surrogate pairs.
  154|  53.7k|    const __m128i composed =
  155|  53.7k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted),
  156|  53.7k|                     _mm_or_si128(highbyte_shifted, middlehighbyte_shifted));
  157|  53.7k|    const __m128i composedminus =
  158|  53.7k|        _mm_sub_epi32(composed, _mm_set1_epi32(0x10000));
  159|  53.7k|    const __m128i lowtenbits =
  160|  53.7k|        _mm_and_si128(composedminus, _mm_set1_epi32(0x3ff));
  161|       |    // Notice the 0x3ff mask:
  162|  53.7k|    const __m128i hightenbits =
  163|  53.7k|        _mm_and_si128(_mm_srli_epi32(composedminus, 10), _mm_set1_epi32(0x3ff));
  164|  53.7k|    const __m128i lowtenbitsadd =
  165|  53.7k|        _mm_add_epi32(lowtenbits, _mm_set1_epi32(0xDC00));
  166|  53.7k|    const __m128i hightenbitsadd =
  167|  53.7k|        _mm_add_epi32(hightenbits, _mm_set1_epi32(0xD800));
  168|  53.7k|    const __m128i lowtenbitsaddshifted = _mm_slli_epi32(lowtenbitsadd, 16);
  169|  53.7k|    __m128i surrogates = _mm_or_si128(hightenbitsadd, lowtenbitsaddshifted);
  170|  53.7k|    uint32_t basic_buffer[4];
  171|  53.7k|    uint32_t basic_buffer_swap[4];
  172|  53.7k|    if (big_endian) {
  ------------------
  |  Branch (172:9): [Folded, False: 53.7k]
  ------------------
  173|      0|      _mm_storeu_si128((__m128i *)basic_buffer_swap,
  174|      0|                       _mm_shuffle_epi8(composed, swap));
  175|      0|      surrogates = _mm_shuffle_epi8(surrogates, swap);
  176|      0|    }
  177|  53.7k|    _mm_storeu_si128((__m128i *)basic_buffer, composed);
  178|  53.7k|    uint32_t surrogate_buffer[4];
  179|  53.7k|    _mm_storeu_si128((__m128i *)surrogate_buffer, surrogates);
  180|   215k|    for (size_t i = 0; i < 3; i++) {
  ------------------
  |  Branch (180:24): [True: 161k, False: 53.7k]
  ------------------
  181|   161k|      if (basic_buffer[i] > 0x3c00000) {
  ------------------
  |  Branch (181:11): [True: 45.3k, False: 116k]
  ------------------
  182|  45.3k|        utf16_output[0] = uint16_t(surrogate_buffer[i] & 0xffff);
  183|  45.3k|        utf16_output[1] = uint16_t(surrogate_buffer[i] >> 16);
  184|  45.3k|        utf16_output += 2;
  185|   116k|      } else {
  186|   116k|        utf16_output[0] = big_endian ? uint16_t(basic_buffer_swap[i])
  ------------------
  |  Branch (186:27): [Folded, False: 116k]
  ------------------
  187|   116k|                                     : uint16_t(basic_buffer[i]);
  188|   116k|        utf16_output++;
  189|   116k|      }
  190|   161k|    }
  191|  53.7k|  } else {
  192|       |    // here we know that there is an error but we do not handle errors
  193|    248|  }
  194|  1.21M|  return consumed;
  195|  1.21M|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_128convert_masked_utf8_to_utf16ILNS_10endiannessE1EEEmPKcmRPDs:
   10|  2.46M|                                    char16_t *&utf16_output) {
   11|       |  // we use an approach where we try to process up to 12 input bytes.
   12|       |  // Why 12 input bytes and not 16? Because we are concerned with the size of
   13|       |  // the lookup tables. Also 12 is nicely divisible by two and three.
   14|       |  //
   15|       |  //
   16|       |  // Optimization note: our main path below is load-latency dependent. Thus it
   17|       |  // is maybe beneficial to have fast paths that depend on branch prediction but
   18|       |  // have less latency. This results in more instructions but, potentially, also
   19|       |  // higher speeds.
   20|       |  //
   21|       |  // We first try a few fast paths.
   22|  2.46M|  const __m128i swap =
   23|  2.46M|      _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   24|  2.46M|  const __m128i in = _mm_loadu_si128((__m128i *)input);
   25|  2.46M|  const uint16_t input_utf8_end_of_code_point_mask =
   26|  2.46M|      utf8_end_of_code_point_mask & 0xfff;
   27|  2.46M|  if ((utf8_end_of_code_point_mask & 0xfff) == 0xfff) {
  ------------------
  |  Branch (27:7): [True: 1.16M, False: 1.30M]
  ------------------
   28|       |    // We process the data in chunks of 12 bytes.
   29|  1.16M|    __m256i ascii = _mm256_cvtepu8_epi16(in);
   30|  1.16M|    if (big_endian) {
  ------------------
  |  Branch (30:9): [True: 1.16M, Folded]
  ------------------
   31|  1.16M|      const __m256i swap256 = _mm256_setr_epi8(
   32|  1.16M|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
   33|  1.16M|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
   34|  1.16M|      ascii = _mm256_shuffle_epi8(ascii, swap256);
   35|  1.16M|    }
   36|  1.16M|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf16_output), ascii);
   37|  1.16M|    utf16_output += 12; // We wrote 12 16-bit characters.
   38|  1.16M|    return 12;          // We consumed 12 bytes.
   39|  1.16M|  }
   40|  1.30M|  if (((utf8_end_of_code_point_mask & 0xffff) == 0xaaaa)) {
  ------------------
  |  Branch (40:7): [True: 16.3k, False: 1.28M]
  ------------------
   41|       |    // We want to take 8 2-byte UTF-8 code units and turn them into 8 2-byte
   42|       |    // UTF-16 code units. There is probably a more efficient sequence, but the
   43|       |    // following might do.
   44|  16.3k|    const __m128i sh =
   45|  16.3k|        _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   46|  16.3k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   47|  16.3k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   48|  16.3k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   49|  16.3k|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   50|  16.3k|    if (big_endian)
  ------------------
  |  Branch (50:9): [True: 16.3k, Folded]
  ------------------
   51|  16.3k|      composed = _mm_shuffle_epi8(composed, swap);
   52|  16.3k|    _mm_storeu_si128((__m128i *)utf16_output, composed);
   53|  16.3k|    utf16_output += 8; // We wrote 16 bytes, 8 code points.
   54|  16.3k|    return 16;
   55|  16.3k|  }
   56|  1.28M|  if (input_utf8_end_of_code_point_mask == 0x924) {
  ------------------
  |  Branch (56:7): [True: 10.3k, False: 1.27M]
  ------------------
   57|       |    // We want to take 4 3-byte UTF-8 code units and turn them into 4 2-byte
   58|       |    // UTF-16 code units. There is probably a more efficient sequence, but the
   59|       |    // following might do.
   60|  10.3k|    const __m128i sh =
   61|  10.3k|        _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1);
   62|  10.3k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   63|  10.3k|    const __m128i ascii =
   64|  10.3k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
   65|  10.3k|    const __m128i middlebyte =
   66|  10.3k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
   67|  10.3k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
   68|  10.3k|    const __m128i highbyte =
   69|  10.3k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
   70|  10.3k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
   71|  10.3k|    const __m128i composed =
   72|  10.3k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
   73|  10.3k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
   74|  10.3k|    if (big_endian)
  ------------------
  |  Branch (74:9): [True: 10.3k, Folded]
  ------------------
   75|  10.3k|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
   76|  10.3k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
   77|  10.3k|    utf16_output += 4;
   78|  10.3k|    return 12;
   79|  10.3k|  }
   80|       |
   81|  1.27M|  const uint8_t idx = simdutf::tables::utf8_to_utf16::utf8bigindex
   82|  1.27M|      [input_utf8_end_of_code_point_mask][0];
   83|  1.27M|  const uint8_t consumed = simdutf::tables::utf8_to_utf16::utf8bigindex
   84|  1.27M|      [input_utf8_end_of_code_point_mask][1];
   85|  1.27M|  if (idx < 64) {
  ------------------
  |  Branch (85:7): [True: 774k, False: 500k]
  ------------------
   86|       |    // SIX (6) input code-code units
   87|       |    // this is a relatively easy scenario
   88|       |    // we process SIX (6) input code-code units. The max length in bytes of six
   89|       |    // code code units spanning between 1 and 2 bytes each is 12 bytes. On
   90|       |    // processors where pdep/pext is fast, we might be able to use a small
   91|       |    // lookup table.
   92|   774k|    const __m128i sh = _mm_loadu_si128(
   93|   774k|        (const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]);
   94|   774k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   95|   774k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   96|   774k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   97|   774k|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   98|   774k|    if (big_endian)
  ------------------
  |  Branch (98:9): [True: 774k, Folded]
  ------------------
   99|   774k|      composed = _mm_shuffle_epi8(composed, swap);
  100|   774k|    _mm_storeu_si128((__m128i *)utf16_output, composed);
  101|   774k|    utf16_output += 6; // We wrote 12 bytes, 6 code points. There is a potential
  102|       |                       // overflow of 4 bytes.
  103|   774k|  } else if (idx < 145) {
  ------------------
  |  Branch (103:14): [True: 415k, False: 85.1k]
  ------------------
  104|       |    // FOUR (4) input code-code units
  105|   415k|    const __m128i sh = _mm_loadu_si128(
  106|   415k|        (const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]);
  107|   415k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  108|   415k|    const __m128i ascii =
  109|   415k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
  110|   415k|    const __m128i middlebyte =
  111|   415k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
  112|   415k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  113|   415k|    const __m128i highbyte =
  114|   415k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
  115|   415k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
  116|   415k|    const __m128i composed =
  117|   415k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
  118|   415k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
  119|   415k|    if (big_endian)
  ------------------
  |  Branch (119:9): [True: 415k, Folded]
  ------------------
  120|   415k|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
  121|   415k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
  122|   415k|    utf16_output += 4; // Here we overflow by 8 bytes.
  123|   415k|  } else if (idx < 209) {
  ------------------
  |  Branch (123:14): [True: 84.8k, False: 342]
  ------------------
  124|       |    // TWO (2) input code-code units
  125|       |    //////////////
  126|       |    // There might be garbage inputs where a leading byte mascarades as a
  127|       |    // four-byte leading byte (by being followed by 3 continuation byte), but is
  128|       |    // not greater than 0xf0. This could trigger a buffer overflow if we only
  129|       |    // counted leading bytes of the form 0xf0 as generating surrogate pairs,
  130|       |    // without further UTF-8 validation. Thus we must be careful to ensure that
  131|       |    // only leading bytes at least as large as 0xf0 generate surrogate pairs. We
  132|       |    // do as at the cost of an extra mask.
  133|       |    /////////////
  134|  84.8k|    const __m128i sh = _mm_loadu_si128(
  135|  84.8k|        (const __m128i *)simdutf::tables::utf8_to_utf16::shufutf8[idx]);
  136|  84.8k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  137|  84.8k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f));
  138|  84.8k|    const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00));
  139|  84.8k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  140|  84.8k|    __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000));
  141|       |    // correct for spurious high bit
  142|  84.8k|    const __m128i correct =
  143|  84.8k|        _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1);
  144|  84.8k|    middlehighbyte = _mm_xor_si128(correct, middlehighbyte);
  145|  84.8k|    const __m128i middlehighbyte_shifted = _mm_srli_epi32(middlehighbyte, 4);
  146|       |    // We deliberately carry the leading four bits in highbyte if they are
  147|       |    // present, we remove them later when computing hightenbits.
  148|  84.8k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0xff000000));
  149|  84.8k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 6);
  150|       |    // When we need to generate a surrogate pair (leading byte > 0xF0), then
  151|       |    // the corresponding 32-bit value in 'composed'  will be greater than
  152|       |    // > (0xff00000>>6) or > 0x3c00000. This can be used later to identify the
  153|       |    // location of the surrogate pairs.
  154|  84.8k|    const __m128i composed =
  155|  84.8k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted),
  156|  84.8k|                     _mm_or_si128(highbyte_shifted, middlehighbyte_shifted));
  157|  84.8k|    const __m128i composedminus =
  158|  84.8k|        _mm_sub_epi32(composed, _mm_set1_epi32(0x10000));
  159|  84.8k|    const __m128i lowtenbits =
  160|  84.8k|        _mm_and_si128(composedminus, _mm_set1_epi32(0x3ff));
  161|       |    // Notice the 0x3ff mask:
  162|  84.8k|    const __m128i hightenbits =
  163|  84.8k|        _mm_and_si128(_mm_srli_epi32(composedminus, 10), _mm_set1_epi32(0x3ff));
  164|  84.8k|    const __m128i lowtenbitsadd =
  165|  84.8k|        _mm_add_epi32(lowtenbits, _mm_set1_epi32(0xDC00));
  166|  84.8k|    const __m128i hightenbitsadd =
  167|  84.8k|        _mm_add_epi32(hightenbits, _mm_set1_epi32(0xD800));
  168|  84.8k|    const __m128i lowtenbitsaddshifted = _mm_slli_epi32(lowtenbitsadd, 16);
  169|  84.8k|    __m128i surrogates = _mm_or_si128(hightenbitsadd, lowtenbitsaddshifted);
  170|  84.8k|    uint32_t basic_buffer[4];
  171|  84.8k|    uint32_t basic_buffer_swap[4];
  172|  84.8k|    if (big_endian) {
  ------------------
  |  Branch (172:9): [True: 84.8k, Folded]
  ------------------
  173|  84.8k|      _mm_storeu_si128((__m128i *)basic_buffer_swap,
  174|  84.8k|                       _mm_shuffle_epi8(composed, swap));
  175|  84.8k|      surrogates = _mm_shuffle_epi8(surrogates, swap);
  176|  84.8k|    }
  177|  84.8k|    _mm_storeu_si128((__m128i *)basic_buffer, composed);
  178|  84.8k|    uint32_t surrogate_buffer[4];
  179|  84.8k|    _mm_storeu_si128((__m128i *)surrogate_buffer, surrogates);
  180|   339k|    for (size_t i = 0; i < 3; i++) {
  ------------------
  |  Branch (180:24): [True: 254k, False: 84.8k]
  ------------------
  181|   254k|      if (basic_buffer[i] > 0x3c00000) {
  ------------------
  |  Branch (181:11): [True: 71.3k, False: 183k]
  ------------------
  182|  71.3k|        utf16_output[0] = uint16_t(surrogate_buffer[i] & 0xffff);
  183|  71.3k|        utf16_output[1] = uint16_t(surrogate_buffer[i] >> 16);
  184|  71.3k|        utf16_output += 2;
  185|   183k|      } else {
  186|   183k|        utf16_output[0] = big_endian ? uint16_t(basic_buffer_swap[i])
  ------------------
  |  Branch (186:27): [True: 183k, Folded]
  ------------------
  187|   183k|                                     : uint16_t(basic_buffer[i]);
  188|   183k|        utf16_output++;
  189|   183k|      }
  190|   254k|    }
  191|  84.8k|  } else {
  192|       |    // here we know that there is an error but we do not handle errors
  193|    342|  }
  194|  1.27M|  return consumed;
  195|  1.28M|}

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_128convert_masked_utf8_to_utf32EPKcmRPDi:
    9|  1.61M|                                    char32_t *&utf32_output) {
   10|       |  // we use an approach where we try to process up to 12 input bytes.
   11|       |  // Why 12 input bytes and not 16? Because we are concerned with the size of
   12|       |  // the lookup tables. Also 12 is nicely divisible by two and three.
   13|       |  //
   14|       |  //
   15|       |  // Optimization note: our main path below is load-latency dependent. Thus it
   16|       |  // is maybe beneficial to have fast paths that depend on branch prediction but
   17|       |  // have less latency. This results in more instructions but, potentially, also
   18|       |  // higher speeds.
   19|       |  //
   20|       |  // We first try a few fast paths.
   21|  1.61M|  const __m128i in = _mm_loadu_si128((__m128i *)input);
   22|  1.61M|  const uint16_t input_utf8_end_of_code_point_mask =
   23|  1.61M|      utf8_end_of_code_point_mask & 0xfff;
   24|  1.61M|  if ((utf8_end_of_code_point_mask & 0xfff) == 0xfff) {
  ------------------
  |  Branch (24:7): [True: 775k, False: 844k]
  ------------------
   25|       |    // We process the data in chunks of 12 bytes.
   26|   775k|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output),
   27|   775k|                        _mm256_cvtepu8_epi32(in));
   28|   775k|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(utf32_output + 8),
   29|   775k|                        _mm256_cvtepu8_epi32(_mm_srli_si128(in, 8)));
   30|   775k|    utf32_output += 12; // We wrote 12 32-bit characters.
   31|   775k|    return 12;          // We consumed 12 bytes.
   32|   775k|  }
   33|   844k|  if (((utf8_end_of_code_point_mask & 0xffff) == 0xaaaa)) {
  ------------------
  |  Branch (33:7): [True: 16.2k, False: 827k]
  ------------------
   34|       |    // We want to take 8 2-byte UTF-8 code units and turn them into 8 4-byte
   35|       |    // UTF-32 code units. There is probably a more efficient sequence, but the
   36|       |    // following might do.
   37|  16.2k|    const __m128i sh =
   38|  16.2k|        _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   39|  16.2k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   40|  16.2k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   41|  16.2k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   42|  16.2k|    const __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   43|  16.2k|    _mm256_storeu_si256((__m256i *)utf32_output,
   44|  16.2k|                        _mm256_cvtepu16_epi32(composed));
   45|  16.2k|    utf32_output += 8; // We wrote 16 bytes, 8 code points.
   46|  16.2k|    return 16;
   47|  16.2k|  }
   48|   827k|  if (input_utf8_end_of_code_point_mask == 0x924) {
  ------------------
  |  Branch (48:7): [True: 4.64k, False: 823k]
  ------------------
   49|       |    // We want to take 4 3-byte UTF-8 code units and turn them into 4 4-byte
   50|       |    // UTF-32 code units. There is probably a more efficient sequence, but the
   51|       |    // following might do.
   52|  4.64k|    const __m128i sh =
   53|  4.64k|        _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1);
   54|  4.64k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   55|  4.64k|    const __m128i ascii =
   56|  4.64k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
   57|  4.64k|    const __m128i middlebyte =
   58|  4.64k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
   59|  4.64k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
   60|  4.64k|    const __m128i highbyte =
   61|  4.64k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
   62|  4.64k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
   63|  4.64k|    const __m128i composed =
   64|  4.64k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
   65|  4.64k|    _mm_storeu_si128((__m128i *)utf32_output, composed);
   66|  4.64k|    utf32_output += 4;
   67|  4.64k|    return 12;
   68|  4.64k|  }
   69|       |  /// We do not have a fast path available, so we fallback.
   70|       |
   71|   823k|  const uint8_t idx =
   72|   823k|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0];
   73|   823k|  const uint8_t consumed =
   74|   823k|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1];
   75|   823k|  if (idx < 64) {
  ------------------
  |  Branch (75:7): [True: 480k, False: 342k]
  ------------------
   76|       |    // SIX (6) input code-code units
   77|       |    // this is a relatively easy scenario
   78|       |    // we process SIX (6) input code-code units. The max length in bytes of six
   79|       |    // code code units spanning between 1 and 2 bytes each is 12 bytes. On
   80|       |    // processors where pdep/pext is fast, we might be able to use a small
   81|       |    // lookup table.
   82|   480k|    const __m128i sh =
   83|   480k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
   84|   480k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   85|   480k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   86|   480k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   87|   480k|    const __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   88|   480k|    _mm256_storeu_si256((__m256i *)utf32_output,
   89|   480k|                        _mm256_cvtepu16_epi32(composed));
   90|   480k|    utf32_output += 6; // We wrote 24 bytes, 6 code points. There is a potential
   91|       |    // overflow of 32 - 24 = 8 bytes.
   92|   480k|  } else if (idx < 145) {
  ------------------
  |  Branch (92:14): [True: 263k, False: 78.6k]
  ------------------
   93|       |    // FOUR (4) input code-code units
   94|   263k|    const __m128i sh =
   95|   263k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
   96|   263k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   97|   263k|    const __m128i ascii =
   98|   263k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
   99|   263k|    const __m128i middlebyte =
  100|   263k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
  101|   263k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  102|   263k|    const __m128i highbyte =
  103|   263k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
  104|   263k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
  105|   263k|    const __m128i composed =
  106|   263k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
  107|   263k|    _mm_storeu_si128((__m128i *)utf32_output, composed);
  108|   263k|    utf32_output += 4;
  109|   263k|  } else if (idx < 209) {
  ------------------
  |  Branch (109:14): [True: 78.3k, False: 278]
  ------------------
  110|       |    // TWO (2) input code-code units
  111|  78.3k|    const __m128i sh =
  112|  78.3k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
  113|  78.3k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  114|  78.3k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f));
  115|  78.3k|    const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00));
  116|  78.3k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  117|  78.3k|    __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000));
  118|       |    // correct for spurious high bit
  119|  78.3k|    const __m128i correct =
  120|  78.3k|        _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1);
  121|  78.3k|    middlehighbyte = _mm_xor_si128(correct, middlehighbyte);
  122|  78.3k|    const __m128i middlehighbyte_shifted = _mm_srli_epi32(middlehighbyte, 4);
  123|  78.3k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0x07000000));
  124|  78.3k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 6);
  125|  78.3k|    const __m128i composed =
  126|  78.3k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted),
  127|  78.3k|                     _mm_or_si128(highbyte_shifted, middlehighbyte_shifted));
  128|  78.3k|    _mm_storeu_si128((__m128i *)utf32_output, composed);
  129|  78.3k|    utf32_output +=
  130|  78.3k|        3; // We wrote 3 * 4 bytes, there is a potential overflow of 4 bytes.
  131|  78.3k|  } else {
  132|       |    // here we know that there is an error but we do not handle errors
  133|    278|  }
  134|   823k|  return consumed;
  135|   827k|}

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

_ZNK7simdutf7haswell14implementation13validate_utf8EPKcm:
  178|  4.44k|implementation::validate_utf8(const char *buf, size_t len) const noexcept {
  179|  4.44k|  return aligned_split::all<validate_utf8_unsplit>(
  180|  4.44k|      buf, len, aligned_split::utf8_head(buf, len));
  181|  4.44k|}
_ZNK7simdutf7haswell14implementation25validate_utf8_with_errorsEPKcm:
  191|  4.44k|    const char *buf, size_t len) const noexcept {
  192|  4.44k|  return aligned_split::first_error<validate_utf8_with_errors_unsplit>(
  193|  4.44k|      buf, len, aligned_split::utf8_head(buf, len));
  194|  4.44k|}
_ZNK7simdutf7haswell14implementation16validate_utf16leEPKDsm:
  276|  1.28k|                                 size_t len) const noexcept {
  277|  1.28k|  return aligned_split::all<validate_utf16le_unsplit>(
  278|  1.28k|      buf, len, aligned_split::utf16_head<endianness::LITTLE>(buf, len));
  279|  1.28k|}
_ZNK7simdutf7haswell14implementation16validate_utf16beEPKDsm:
  306|  1.26k|                                 size_t len) const noexcept {
  307|  1.26k|  return aligned_split::all<validate_utf16be_unsplit>(
  308|  1.26k|      buf, len, aligned_split::utf16_head<endianness::BIG>(buf, len));
  309|  1.26k|}
_ZNK7simdutf7haswell14implementation28validate_utf16le_with_errorsEPKDsm:
  327|  1.28k|    const char16_t *buf, size_t len) const noexcept {
  328|  1.28k|  return aligned_split::first_error<validate_utf16le_with_errors_unsplit>(
  329|  1.28k|      buf, len, aligned_split::utf16_head<endianness::LITTLE>(buf, len));
  330|  1.28k|}
_ZNK7simdutf7haswell14implementation28validate_utf16be_with_errorsEPKDsm:
  347|  1.26k|    const char16_t *buf, size_t len) const noexcept {
  348|  1.26k|  return aligned_split::first_error<validate_utf16be_with_errors_unsplit>(
  349|  1.26k|      buf, len, aligned_split::utf16_head<endianness::BIG>(buf, len));
  350|  1.26k|}
_ZNK7simdutf7haswell14implementation14validate_utf32EPKDim:
  386|  2.21k|implementation::validate_utf32(const char32_t *buf, size_t len) const noexcept {
  387|  2.21k|  return aligned_split::all<validate_utf32_unsplit>(
  388|  2.21k|      buf, len, aligned_split::head(buf, len));
  389|  2.21k|}
_ZNK7simdutf7haswell14implementation26validate_utf32_with_errorsEPKDim:
  394|  2.21k|    const char32_t *buf, size_t len) const noexcept {
  395|  2.21k|  return utf32::validate_with_errors(buf, len);
  396|  2.21k|}
_ZNK7simdutf7haswell14implementation22convert_latin1_to_utf8EPKcmPc:
  401|    600|    const char *buf, size_t len, char *utf8_output) const noexcept {
  402|    600|  std::pair<const char *, char *> ret =
  403|    600|      avx2_convert_latin1_to_utf8(buf, len, utf8_output);
  404|    600|  size_t converted_chars = ret.second - utf8_output;
  405|       |
  406|    600|  if (ret.first != buf + len) {
  ------------------
  |  Branch (406:7): [True: 596, False: 4]
  ------------------
  407|    596|    const size_t scalar_converted_chars = scalar::latin1_to_utf8::convert(
  408|    596|        ret.first, len - (ret.first - buf), ret.second);
  409|    596|    converted_chars += scalar_converted_chars;
  410|    596|  }
  411|       |
  412|    600|  return converted_chars;
  413|    600|}
_ZNK7simdutf7haswell14implementation25convert_latin1_to_utf16leEPKcmPDs:
  418|     98|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  419|     98|  std::pair<const char *, char16_t *> ret =
  420|     98|      avx2_convert_latin1_to_utf16<endianness::LITTLE>(buf, len, utf16_output);
  421|     98|  if (ret.first == nullptr) {
  ------------------
  |  Branch (421:7): [True: 4, False: 94]
  ------------------
  422|      4|    return 0;
  423|      4|  }
  424|     94|  size_t converted_chars = ret.second - utf16_output;
  425|     94|  if (ret.first != buf + len) {
  ------------------
  |  Branch (425:7): [True: 78, False: 16]
  ------------------
  426|     78|    const size_t scalar_converted_chars =
  427|     78|        scalar::latin1_to_utf16::convert<endianness::LITTLE>(
  428|     78|            ret.first, len - (ret.first - buf), ret.second);
  429|     78|    if (scalar_converted_chars == 0) {
  ------------------
  |  Branch (429:9): [True: 0, False: 78]
  ------------------
  430|      0|      return 0;
  431|      0|    }
  432|     78|    converted_chars += scalar_converted_chars;
  433|     78|  }
  434|     94|  return converted_chars;
  435|     94|}
_ZNK7simdutf7haswell14implementation25convert_latin1_to_utf16beEPKcmPDs:
  438|     84|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  439|     84|  std::pair<const char *, char16_t *> ret =
  440|     84|      avx2_convert_latin1_to_utf16<endianness::BIG>(buf, len, utf16_output);
  441|     84|  if (ret.first == nullptr) {
  ------------------
  |  Branch (441:7): [True: 4, False: 80]
  ------------------
  442|      4|    return 0;
  443|      4|  }
  444|     80|  size_t converted_chars = ret.second - utf16_output;
  445|     80|  if (ret.first != buf + len) {
  ------------------
  |  Branch (445:7): [True: 54, False: 26]
  ------------------
  446|     54|    const size_t scalar_converted_chars =
  447|     54|        scalar::latin1_to_utf16::convert<endianness::BIG>(
  448|     54|            ret.first, len - (ret.first - buf), ret.second);
  449|     54|    if (scalar_converted_chars == 0) {
  ------------------
  |  Branch (449:9): [True: 0, False: 54]
  ------------------
  450|      0|      return 0;
  451|      0|    }
  452|     54|    converted_chars += scalar_converted_chars;
  453|     54|  }
  454|     80|  return converted_chars;
  455|     80|}
_ZNK7simdutf7haswell14implementation23convert_latin1_to_utf32EPKcmPDi:
  460|     70|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  461|     70|  std::pair<const char *, char32_t *> ret =
  462|     70|      avx2_convert_latin1_to_utf32(buf, len, utf32_output);
  463|     70|  if (ret.first == nullptr) {
  ------------------
  |  Branch (463:7): [True: 4, False: 66]
  ------------------
  464|      4|    return 0;
  465|      4|  }
  466|     66|  size_t converted_chars = ret.second - utf32_output;
  467|     66|  if (ret.first != buf + len) {
  ------------------
  |  Branch (467:7): [True: 40, False: 26]
  ------------------
  468|     40|    const size_t scalar_converted_chars = scalar::latin1_to_utf32::convert(
  469|     40|        ret.first, len - (ret.first - buf), ret.second);
  470|     40|    if (scalar_converted_chars == 0) {
  ------------------
  |  Branch (470:9): [True: 0, False: 40]
  ------------------
  471|      0|      return 0;
  472|      0|    }
  473|     40|    converted_chars += scalar_converted_chars;
  474|     40|  }
  475|     66|  return converted_chars;
  476|     66|}
_ZNK7simdutf7haswell14implementation22convert_utf8_to_latin1EPKcmPc:
  481|    662|    const char *buf, size_t len, char *latin1_output) const noexcept {
  482|    662|  utf8_to_latin1::validating_transcoder converter;
  483|    662|  return converter.convert(buf, len, latin1_output);
  484|    662|}
_ZNK7simdutf7haswell14implementation34convert_utf8_to_latin1_with_errorsEPKcmPc:
  487|    750|    const char *buf, size_t len, char *latin1_output) const noexcept {
  488|    750|  utf8_to_latin1::validating_transcoder converter;
  489|    750|  return converter.convert_with_errors(buf, len, latin1_output);
  490|    750|}
_ZNK7simdutf7haswell14implementation23convert_utf8_to_utf16leEPKcmPDs:
  500|    984|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  501|    984|  utf8_to_utf16::validating_transcoder converter;
  502|    984|  return converter.convert<endianness::LITTLE>(buf, len, utf16_output);
  503|    984|}
_ZNK7simdutf7haswell14implementation23convert_utf8_to_utf16beEPKcmPDs:
  506|    960|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  507|    960|  utf8_to_utf16::validating_transcoder converter;
  508|    960|  return converter.convert<endianness::BIG>(buf, len, utf16_output);
  509|    960|}
_ZNK7simdutf7haswell14implementation35convert_utf8_to_utf16le_with_errorsEPKcmPDs:
  512|    790|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  513|    790|  utf8_to_utf16::validating_transcoder converter;
  514|    790|  return converter.convert_with_errors<endianness::LITTLE>(buf, len,
  515|    790|                                                           utf16_output);
  516|    790|}
_ZNK7simdutf7haswell14implementation35convert_utf8_to_utf16be_with_errorsEPKcmPDs:
  519|    884|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  520|    884|  utf8_to_utf16::validating_transcoder converter;
  521|    884|  return converter.convert_with_errors<endianness::BIG>(buf, len, utf16_output);
  522|    884|}
_ZNK7simdutf7haswell14implementation29convert_valid_utf8_to_utf16leEPKcmPDs:
  525|    528|    const char *input, size_t size, char16_t *utf16_output) const noexcept {
  526|    528|  return utf8_to_utf16::convert_valid<endianness::LITTLE>(input, size,
  527|    528|                                                          utf16_output);
  528|    528|}
_ZNK7simdutf7haswell14implementation29convert_valid_utf8_to_utf16beEPKcmPDs:
  531|    772|    const char *input, size_t size, char16_t *utf16_output) const noexcept {
  532|    772|  return utf8_to_utf16::convert_valid<endianness::BIG>(input, size,
  533|    772|                                                       utf16_output);
  534|    772|}
_ZNK7simdutf7haswell14implementation21convert_utf8_to_utf32EPKcmPDi:
  539|    920|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  540|    920|  utf8_to_utf32::validating_transcoder converter;
  541|    920|  return converter.convert(buf, len, utf32_output);
  542|    920|}
_ZNK7simdutf7haswell14implementation33convert_utf8_to_utf32_with_errorsEPKcmPDi:
  545|    946|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  546|    946|  utf8_to_utf32::validating_transcoder converter;
  547|    946|  return converter.convert_with_errors(buf, len, utf32_output);
  548|    946|}
_ZNK7simdutf7haswell14implementation27convert_valid_utf8_to_utf32EPKcmPDi:
  551|    628|    const char *input, size_t size, char32_t *utf32_output) const noexcept {
  552|    628|  return utf8_to_utf32::convert_valid(input, size, utf32_output);
  553|    628|}
_ZNK7simdutf7haswell14implementation25convert_utf16le_to_latin1EPKDsmPc:
  558|    110|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  559|    110|  std::pair<const char16_t *, char *> ret =
  560|    110|      haswell::avx2_convert_utf16_to_latin1<endianness::LITTLE>(buf, len,
  561|    110|                                                                latin1_output);
  562|    110|  if (ret.first == nullptr) {
  ------------------
  |  Branch (562:7): [True: 24, False: 86]
  ------------------
  563|     24|    return 0;
  564|     24|  }
  565|     86|  size_t saved_bytes = ret.second - latin1_output;
  566|     86|  if (ret.first != buf + len) {
  ------------------
  |  Branch (566:7): [True: 72, False: 14]
  ------------------
  567|     72|    const size_t scalar_saved_bytes =
  568|     72|        scalar::utf16_to_latin1::convert<endianness::LITTLE>(
  569|     72|            ret.first, len - (ret.first - buf), ret.second);
  570|     72|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (570:9): [True: 46, False: 26]
  ------------------
  571|     46|      return 0;
  572|     46|    }
  573|     26|    saved_bytes += scalar_saved_bytes;
  574|     26|  }
  575|     40|  return saved_bytes;
  576|     86|}
_ZNK7simdutf7haswell14implementation25convert_utf16be_to_latin1EPKDsmPc:
  579|    126|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  580|    126|  std::pair<const char16_t *, char *> ret =
  581|    126|      haswell::avx2_convert_utf16_to_latin1<endianness::BIG>(buf, len,
  582|    126|                                                             latin1_output);
  583|    126|  if (ret.first == nullptr) {
  ------------------
  |  Branch (583:7): [True: 30, False: 96]
  ------------------
  584|     30|    return 0;
  585|     30|  }
  586|     96|  size_t saved_bytes = ret.second - latin1_output;
  587|     96|  if (ret.first != buf + len) {
  ------------------
  |  Branch (587:7): [True: 82, False: 14]
  ------------------
  588|     82|    const size_t scalar_saved_bytes =
  589|     82|        scalar::utf16_to_latin1::convert<endianness::BIG>(
  590|     82|            ret.first, len - (ret.first - buf), ret.second);
  591|     82|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (591:9): [True: 44, False: 38]
  ------------------
  592|     44|      return 0;
  593|     44|    }
  594|     38|    saved_bytes += scalar_saved_bytes;
  595|     38|  }
  596|     52|  return saved_bytes;
  597|     96|}
_ZNK7simdutf7haswell14implementation37convert_utf16le_to_latin1_with_errorsEPKDsmPc:
  601|    210|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  602|    210|  std::pair<result, char *> ret =
  603|    210|      avx2_convert_utf16_to_latin1_with_errors<endianness::LITTLE>(
  604|    210|          buf, len, latin1_output);
  605|    210|  if (ret.first.error) {
  ------------------
  |  Branch (605:7): [True: 90, False: 120]
  ------------------
  606|     90|    return ret.first;
  607|     90|  } // Can return directly since scalar fallback already found correct
  608|       |    // ret.first.count
  609|    120|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (609:7): [True: 84, False: 36]
  ------------------
  610|     84|    result scalar_res =
  611|     84|        scalar::utf16_to_latin1::convert_with_errors<endianness::LITTLE>(
  612|     84|            buf + ret.first.count, len - ret.first.count, ret.second);
  613|     84|    if (scalar_res.error) {
  ------------------
  |  Branch (613:9): [True: 34, False: 50]
  ------------------
  614|     34|      scalar_res.count += ret.first.count;
  615|     34|      return scalar_res;
  616|     50|    } else {
  617|     50|      ret.second += scalar_res.count;
  618|     50|    }
  619|     84|  }
  620|     86|  ret.first.count =
  621|     86|      ret.second -
  622|     86|      latin1_output; // Set count to the number of 8-bit code units written
  623|     86|  return ret.first;
  624|    120|}
_ZNK7simdutf7haswell14implementation37convert_utf16be_to_latin1_with_errorsEPKDsmPc:
  628|    262|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  629|    262|  std::pair<result, char *> ret =
  630|    262|      avx2_convert_utf16_to_latin1_with_errors<endianness::BIG>(buf, len,
  631|    262|                                                                latin1_output);
  632|    262|  if (ret.first.error) {
  ------------------
  |  Branch (632:7): [True: 134, False: 128]
  ------------------
  633|    134|    return ret.first;
  634|    134|  } // Can return directly since scalar fallback already found correct
  635|       |    // ret.first.count
  636|    128|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (636:7): [True: 94, False: 34]
  ------------------
  637|     94|    result scalar_res =
  638|     94|        scalar::utf16_to_latin1::convert_with_errors<endianness::BIG>(
  639|     94|            buf + ret.first.count, len - ret.first.count, ret.second);
  640|     94|    if (scalar_res.error) {
  ------------------
  |  Branch (640:9): [True: 50, False: 44]
  ------------------
  641|     50|      scalar_res.count += ret.first.count;
  642|     50|      return scalar_res;
  643|     50|    } else {
  644|     44|      ret.second += scalar_res.count;
  645|     44|    }
  646|     94|  }
  647|     78|  ret.first.count =
  648|     78|      ret.second -
  649|     78|      latin1_output; // Set count to the number of 8-bit code units written
  650|     78|  return ret.first;
  651|    128|}
_ZNK7simdutf7haswell14implementation23convert_utf16le_to_utf8EPKDsmPc:
  668|    802|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  669|    802|  std::pair<const char16_t *, char *> ret =
  670|    802|      haswell::avx2_convert_utf16_to_utf8<endianness::LITTLE>(buf, len,
  671|    802|                                                              utf8_output);
  672|    802|  if (ret.first == nullptr) {
  ------------------
  |  Branch (672:7): [True: 112, False: 690]
  ------------------
  673|    112|    return 0;
  674|    112|  }
  675|    690|  size_t saved_bytes = ret.second - utf8_output;
  676|    690|  if (ret.first != buf + len) {
  ------------------
  |  Branch (676:7): [True: 688, False: 2]
  ------------------
  677|    688|    const size_t scalar_saved_bytes =
  678|    688|        scalar::utf16_to_utf8::convert<endianness::LITTLE>(
  679|    688|            ret.first, len - (ret.first - buf), ret.second);
  680|    688|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (680:9): [True: 66, False: 622]
  ------------------
  681|     66|      return 0;
  682|     66|    }
  683|    622|    saved_bytes += scalar_saved_bytes;
  684|    622|  }
  685|    624|  return saved_bytes;
  686|    690|}
_ZNK7simdutf7haswell14implementation23convert_utf16be_to_utf8EPKDsmPc:
  689|    740|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  690|    740|  std::pair<const char16_t *, char *> ret =
  691|    740|      haswell::avx2_convert_utf16_to_utf8<endianness::BIG>(buf, len,
  692|    740|                                                           utf8_output);
  693|    740|  if (ret.first == nullptr) {
  ------------------
  |  Branch (693:7): [True: 72, False: 668]
  ------------------
  694|     72|    return 0;
  695|     72|  }
  696|    668|  size_t saved_bytes = ret.second - utf8_output;
  697|    668|  if (ret.first != buf + len) {
  ------------------
  |  Branch (697:7): [True: 666, False: 2]
  ------------------
  698|    666|    const size_t scalar_saved_bytes =
  699|    666|        scalar::utf16_to_utf8::convert<endianness::BIG>(
  700|    666|            ret.first, len - (ret.first - buf), ret.second);
  701|    666|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (701:9): [True: 58, False: 608]
  ------------------
  702|     58|      return 0;
  703|     58|    }
  704|    608|    saved_bytes += scalar_saved_bytes;
  705|    608|  }
  706|    610|  return saved_bytes;
  707|    668|}
_ZNK7simdutf7haswell14implementation35convert_utf16le_to_utf8_with_errorsEPKDsmPc:
  731|    628|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  732|    628|  return convert_utf16_to_utf8_with_details<endianness::LITTLE>(buf, len,
  733|    628|                                                                utf8_output);
  734|    628|}
_ZNK7simdutf7haswell14implementation35convert_utf16be_to_utf8_with_errorsEPKDsmPc:
  737|    540|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  738|    540|  return convert_utf16_to_utf8_with_details<endianness::BIG>(buf, len,
  739|    540|                                                             utf8_output);
  740|    540|}
_ZNK7simdutf7haswell14implementation29convert_valid_utf16le_to_utf8EPKDsmPc:
  743|    410|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  744|    410|  return convert_utf16le_to_utf8(buf, len, utf8_output);
  745|    410|}
_ZNK7simdutf7haswell14implementation29convert_valid_utf16be_to_utf8EPKDsmPc:
  748|    430|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  749|    430|  return convert_utf16be_to_utf8(buf, len, utf8_output);
  750|    430|}
_ZNK7simdutf7haswell14implementation21convert_utf32_to_utf8EPKDimPc:
  755|    786|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
  756|    786|  std::pair<const char32_t *, char *> ret =
  757|    786|      avx2_convert_utf32_to_utf8(buf, len, utf8_output);
  758|    786|  if (ret.first == nullptr) {
  ------------------
  |  Branch (758:7): [True: 262, False: 524]
  ------------------
  759|    262|    return 0;
  760|    262|  }
  761|    524|  size_t saved_bytes = ret.second - utf8_output;
  762|    524|  if (ret.first != buf + len) {
  ------------------
  |  Branch (762:7): [True: 522, False: 2]
  ------------------
  763|    522|    SIMDUTF_VZEROUPPER();
  ------------------
  |  |   22|    522|#define SIMDUTF_VZEROUPPER() _mm256_zeroupper()
  ------------------
  764|    522|    const size_t scalar_saved_bytes = scalar::utf32_to_utf8::convert(
  765|    522|        ret.first, len - (ret.first - buf), ret.second);
  766|    522|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (766:9): [True: 242, False: 280]
  ------------------
  767|    242|      return 0;
  768|    242|    }
  769|    280|    saved_bytes += scalar_saved_bytes;
  770|    280|  }
  771|    282|  return saved_bytes;
  772|    524|}
_ZNK7simdutf7haswell14implementation23convert_utf32_to_latin1EPKDimPc:
  777|    190|    const char32_t *buf, size_t len, char *latin1_output) const noexcept {
  778|    190|  std::pair<const char32_t *, char *> ret =
  779|    190|      avx2_convert_utf32_to_latin1(buf, len, latin1_output);
  780|    190|  if (ret.first == nullptr) {
  ------------------
  |  Branch (780:7): [True: 44, False: 146]
  ------------------
  781|     44|    return 0;
  782|     44|  }
  783|    146|  size_t saved_bytes = ret.second - latin1_output;
  784|    146|  if (ret.first != buf + len) {
  ------------------
  |  Branch (784:7): [True: 130, False: 16]
  ------------------
  785|    130|    const size_t scalar_saved_bytes = scalar::utf32_to_latin1::convert(
  786|    130|        ret.first, len - (ret.first - buf), ret.second);
  787|    130|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (787:9): [True: 106, False: 24]
  ------------------
  788|    106|      return 0;
  789|    106|    }
  790|     24|    saved_bytes += scalar_saved_bytes;
  791|     24|  }
  792|     40|  return saved_bytes;
  793|    146|}
_ZNK7simdutf7haswell14implementation35convert_utf32_to_latin1_with_errorsEPKDimPc:
  796|    344|    const char32_t *buf, size_t len, char *latin1_output) const noexcept {
  797|       |  // ret.first.count is always the position in the buffer, not the number of
  798|       |  // code units written even if finished
  799|    344|  std::pair<result, char *> ret =
  800|    344|      avx2_convert_utf32_to_latin1_with_errors(buf, len, latin1_output);
  801|    344|  if (ret.first.count != len) {
  ------------------
  |  Branch (801:7): [True: 324, False: 20]
  ------------------
  802|    324|    result scalar_res = scalar::utf32_to_latin1::convert_with_errors(
  803|    324|        buf + ret.first.count, len - ret.first.count, ret.second);
  804|    324|    if (scalar_res.error) {
  ------------------
  |  Branch (804:9): [True: 294, False: 30]
  ------------------
  805|    294|      scalar_res.count += ret.first.count;
  806|    294|      return scalar_res;
  807|    294|    } else {
  808|     30|      ret.second += scalar_res.count;
  809|     30|    }
  810|    324|  }
  811|     50|  ret.first.count =
  812|     50|      ret.second -
  813|     50|      latin1_output; // Set count to the number of 8-bit code units written
  814|     50|  return ret.first;
  815|    344|}
_ZNK7simdutf7haswell14implementation33convert_utf32_to_utf8_with_errorsEPKDimPc:
  825|    772|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
  826|       |  // ret.first.count is always the position in the buffer, not the number of
  827|       |  // code units written even if finished
  828|    772|  std::pair<result, char *> ret =
  829|    772|      haswell::avx2_convert_utf32_to_utf8_with_errors(buf, len, utf8_output);
  830|    772|  if (ret.first.count != len) {
  ------------------
  |  Branch (830:7): [True: 768, False: 4]
  ------------------
  831|    768|    result scalar_res = scalar::utf32_to_utf8::convert_with_errors(
  832|    768|        buf + ret.first.count, len - ret.first.count, ret.second);
  833|    768|    if (scalar_res.error) {
  ------------------
  |  Branch (833:9): [True: 560, False: 208]
  ------------------
  834|    560|      scalar_res.count += ret.first.count;
  835|    560|      return scalar_res;
  836|    560|    } else {
  837|    208|      ret.second += scalar_res.count;
  838|    208|    }
  839|    768|  }
  840|    212|  ret.first.count =
  841|    212|      ret.second -
  842|    212|      utf8_output; // Set count to the number of 8-bit code units written
  843|    212|  return ret.first;
  844|    772|}
_ZNK7simdutf7haswell14implementation24convert_utf16le_to_utf32EPKDsmPDi:
  849|    380|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  850|    380|  std::pair<const char16_t *, char32_t *> ret =
  851|    380|      haswell::avx2_convert_utf16_to_utf32<endianness::LITTLE>(buf, len,
  852|    380|                                                               utf32_output);
  853|    380|  if (ret.first == nullptr) {
  ------------------
  |  Branch (853:7): [True: 102, False: 278]
  ------------------
  854|    102|    return 0;
  855|    102|  }
  856|    278|  size_t saved_bytes = ret.second - utf32_output;
  857|    278|  if (ret.first != buf + len) {
  ------------------
  |  Branch (857:7): [True: 236, False: 42]
  ------------------
  858|    236|    const size_t scalar_saved_bytes =
  859|    236|        scalar::utf16_to_utf32::convert<endianness::LITTLE>(
  860|    236|            ret.first, len - (ret.first - buf), ret.second);
  861|    236|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (861:9): [True: 68, False: 168]
  ------------------
  862|     68|      return 0;
  863|     68|    }
  864|    168|    saved_bytes += scalar_saved_bytes;
  865|    168|  }
  866|    210|  return saved_bytes;
  867|    278|}
_ZNK7simdutf7haswell14implementation24convert_utf16be_to_utf32EPKDsmPDi:
  870|    394|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  871|    394|  std::pair<const char16_t *, char32_t *> ret =
  872|    394|      haswell::avx2_convert_utf16_to_utf32<endianness::BIG>(buf, len,
  873|    394|                                                            utf32_output);
  874|    394|  if (ret.first == nullptr) {
  ------------------
  |  Branch (874:7): [True: 106, False: 288]
  ------------------
  875|    106|    return 0;
  876|    106|  }
  877|    288|  size_t saved_bytes = ret.second - utf32_output;
  878|    288|  if (ret.first != buf + len) {
  ------------------
  |  Branch (878:7): [True: 230, False: 58]
  ------------------
  879|    230|    const size_t scalar_saved_bytes =
  880|    230|        scalar::utf16_to_utf32::convert<endianness::BIG>(
  881|    230|            ret.first, len - (ret.first - buf), ret.second);
  882|    230|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (882:9): [True: 60, False: 170]
  ------------------
  883|     60|      return 0;
  884|     60|    }
  885|    170|    saved_bytes += scalar_saved_bytes;
  886|    170|  }
  887|    228|  return saved_bytes;
  888|    288|}
_ZNK7simdutf7haswell14implementation36convert_utf16le_to_utf32_with_errorsEPKDsmPDi:
  891|    396|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  892|       |  // ret.first.count is always the position in the buffer, not the number of
  893|       |  // code units written even if finished
  894|    396|  std::pair<result, char32_t *> ret =
  895|    396|      haswell::avx2_convert_utf16_to_utf32_with_errors<endianness::LITTLE>(
  896|    396|          buf, len, utf32_output);
  897|    396|  if (ret.first.error) {
  ------------------
  |  Branch (897:7): [True: 144, False: 252]
  ------------------
  898|    144|    return ret.first;
  899|    144|  } // Can return directly since scalar fallback already found correct
  900|       |    // ret.first.count
  901|    252|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (901:7): [True: 220, False: 32]
  ------------------
  902|    220|    result scalar_res =
  903|    220|        scalar::utf16_to_utf32::convert_with_errors<endianness::LITTLE>(
  904|    220|            buf + ret.first.count, len - ret.first.count, ret.second);
  905|    220|    if (scalar_res.error) {
  ------------------
  |  Branch (905:9): [True: 90, False: 130]
  ------------------
  906|     90|      scalar_res.count += ret.first.count;
  907|     90|      return scalar_res;
  908|    130|    } else {
  909|    130|      ret.second += scalar_res.count;
  910|    130|    }
  911|    220|  }
  912|    162|  ret.first.count =
  913|    162|      ret.second -
  914|    162|      utf32_output; // Set count to the number of 8-bit code units written
  915|    162|  return ret.first;
  916|    252|}
_ZNK7simdutf7haswell14implementation36convert_utf16be_to_utf32_with_errorsEPKDsmPDi:
  919|    380|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  920|       |  // ret.first.count is always the position in the buffer, not the number of
  921|       |  // code units written even if finished
  922|    380|  std::pair<result, char32_t *> ret =
  923|    380|      haswell::avx2_convert_utf16_to_utf32_with_errors<endianness::BIG>(
  924|    380|          buf, len, utf32_output);
  925|    380|  if (ret.first.error) {
  ------------------
  |  Branch (925:7): [True: 138, False: 242]
  ------------------
  926|    138|    return ret.first;
  927|    138|  } // Can return directly since scalar fallback already found correct
  928|       |    // ret.first.count
  929|    242|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (929:7): [True: 212, False: 30]
  ------------------
  930|    212|    result scalar_res =
  931|    212|        scalar::utf16_to_utf32::convert_with_errors<endianness::BIG>(
  932|    212|            buf + ret.first.count, len - ret.first.count, ret.second);
  933|    212|    if (scalar_res.error) {
  ------------------
  |  Branch (933:9): [True: 92, False: 120]
  ------------------
  934|     92|      scalar_res.count += ret.first.count;
  935|     92|      return scalar_res;
  936|    120|    } else {
  937|    120|      ret.second += scalar_res.count;
  938|    120|    }
  939|    212|  }
  940|    150|  ret.first.count =
  941|    150|      ret.second -
  942|    150|      utf32_output; // Set count to the number of 8-bit code units written
  943|    150|  return ret.first;
  944|    242|}
_ZNK7simdutf7haswell14implementation27convert_valid_utf32_to_utf8EPKDimPc:
  949|    202|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
  950|    202|  return convert_utf32_to_utf8(buf, len, utf8_output);
  951|    202|}
_ZNK7simdutf7haswell14implementation24convert_utf32_to_utf16leEPKDimPDs:
  956|    644|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  957|    644|  std::pair<const char32_t *, char16_t *> ret =
  958|    644|      avx2_convert_utf32_to_utf16<endianness::LITTLE>(buf, len, utf16_output);
  959|    644|  if (ret.first == nullptr) {
  ------------------
  |  Branch (959:7): [True: 164, False: 480]
  ------------------
  960|    164|    return 0;
  961|    164|  }
  962|    480|  size_t saved_bytes = ret.second - utf16_output;
  963|    480|  if (ret.first != buf + len) {
  ------------------
  |  Branch (963:7): [True: 476, False: 4]
  ------------------
  964|    476|    const size_t scalar_saved_bytes =
  965|    476|        scalar::utf32_to_utf16::convert<endianness::LITTLE>(
  966|    476|            ret.first, len - (ret.first - buf), ret.second);
  967|    476|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (967:9): [True: 146, False: 330]
  ------------------
  968|    146|      return 0;
  969|    146|    }
  970|    330|    saved_bytes += scalar_saved_bytes;
  971|    330|  }
  972|    334|  return saved_bytes;
  973|    480|}
_ZNK7simdutf7haswell14implementation24convert_utf32_to_utf16beEPKDimPDs:
  976|    462|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  977|    462|  std::pair<const char32_t *, char16_t *> ret =
  978|    462|      avx2_convert_utf32_to_utf16<endianness::BIG>(buf, len, utf16_output);
  979|    462|  if (ret.first == nullptr) {
  ------------------
  |  Branch (979:7): [True: 96, False: 366]
  ------------------
  980|     96|    return 0;
  981|     96|  }
  982|    366|  size_t saved_bytes = ret.second - utf16_output;
  983|    366|  if (ret.first != buf + len) {
  ------------------
  |  Branch (983:7): [True: 364, False: 2]
  ------------------
  984|    364|    const size_t scalar_saved_bytes =
  985|    364|        scalar::utf32_to_utf16::convert<endianness::BIG>(
  986|    364|            ret.first, len - (ret.first - buf), ret.second);
  987|    364|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (987:9): [True: 152, False: 212]
  ------------------
  988|    152|      return 0;
  989|    152|    }
  990|    212|    saved_bytes += scalar_saved_bytes;
  991|    212|  }
  992|    214|  return saved_bytes;
  993|    366|}
_ZNK7simdutf7haswell14implementation36convert_utf32_to_utf16le_with_errorsEPKDimPDs:
  996|    622|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  997|       |  // ret.first.count is always the position in the buffer, not the number of
  998|       |  // code units written even if finished
  999|    622|  std::pair<result, char16_t *> ret =
 1000|    622|      haswell::avx2_convert_utf32_to_utf16_with_errors<endianness::LITTLE>(
 1001|    622|          buf, len, utf16_output);
 1002|    622|  if (ret.first.count != len) {
  ------------------
  |  Branch (1002:7): [True: 618, False: 4]
  ------------------
 1003|    618|    result scalar_res =
 1004|    618|        scalar::utf32_to_utf16::convert_with_errors<endianness::LITTLE>(
 1005|    618|            buf + ret.first.count, len - ret.first.count, ret.second);
 1006|    618|    if (scalar_res.error) {
  ------------------
  |  Branch (1006:9): [True: 440, False: 178]
  ------------------
 1007|    440|      scalar_res.count += ret.first.count;
 1008|    440|      return scalar_res;
 1009|    440|    } else {
 1010|    178|      ret.second += scalar_res.count;
 1011|    178|    }
 1012|    618|  }
 1013|    182|  ret.first.count =
 1014|    182|      ret.second -
 1015|    182|      utf16_output; // Set count to the number of 8-bit code units written
 1016|    182|  return ret.first;
 1017|    622|}
_ZNK7simdutf7haswell14implementation36convert_utf32_to_utf16be_with_errorsEPKDimPDs:
 1020|    570|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
 1021|       |  // ret.first.count is always the position in the buffer, not the number of
 1022|       |  // code units written even if finished
 1023|    570|  std::pair<result, char16_t *> ret =
 1024|    570|      haswell::avx2_convert_utf32_to_utf16_with_errors<endianness::BIG>(
 1025|    570|          buf, len, utf16_output);
 1026|    570|  if (ret.first.count != len) {
  ------------------
  |  Branch (1026:7): [True: 566, False: 4]
  ------------------
 1027|    566|    result scalar_res =
 1028|    566|        scalar::utf32_to_utf16::convert_with_errors<endianness::BIG>(
 1029|    566|            buf + ret.first.count, len - ret.first.count, ret.second);
 1030|    566|    if (scalar_res.error) {
  ------------------
  |  Branch (1030:9): [True: 416, False: 150]
  ------------------
 1031|    416|      scalar_res.count += ret.first.count;
 1032|    416|      return scalar_res;
 1033|    416|    } else {
 1034|    150|      ret.second += scalar_res.count;
 1035|    150|    }
 1036|    566|  }
 1037|    154|  ret.first.count =
 1038|    154|      ret.second -
 1039|    154|      utf16_output; // Set count to the number of 8-bit code units written
 1040|    154|  return ret.first;
 1041|    570|}
_ZNK7simdutf7haswell14implementation30convert_valid_utf32_to_utf16leEPKDimPDs:
 1044|    222|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
 1045|    222|  return convert_utf32_to_utf16le(buf, len, utf16_output);
 1046|    222|}
_ZNK7simdutf7haswell14implementation30convert_valid_utf32_to_utf16beEPKDimPDs:
 1049|     72|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
 1050|     72|  return convert_utf32_to_utf16be(buf, len, utf16_output);
 1051|     72|}
_ZNK7simdutf7haswell14implementation30convert_valid_utf16le_to_utf32EPKDsmPDi:
 1054|    108|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
 1055|    108|  return convert_utf16le_to_utf32(buf, len, utf32_output);
 1056|    108|}
_ZNK7simdutf7haswell14implementation30convert_valid_utf16be_to_utf32EPKDsmPDi:
 1059|    142|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
 1060|    142|  return convert_utf16be_to_utf32(buf, len, utf32_output);
 1061|    142|}
_ZNK7simdutf7haswell14implementation13count_utf16leEPKDsm:
 1077|  1.28k|    const char16_t *input, size_t length) const noexcept {
 1078|  1.28k|  return aligned_split::sum<count_utf16le_unsplit>(
 1079|  1.28k|      input, length, aligned_split::head(input, length));
 1080|  1.28k|}
_ZNK7simdutf7haswell14implementation13count_utf16beEPKDsm:
 1088|  1.26k|    const char16_t *input, size_t length) const noexcept {
 1089|  1.26k|  return aligned_split::sum<count_utf16be_unsplit>(
 1090|  1.26k|      input, length, aligned_split::head(input, length));
 1091|  1.26k|}
_ZNK7simdutf7haswell14implementation10count_utf8EPKcm:
 1101|  5.14k|implementation::count_utf8(const char *in, size_t size) const noexcept {
 1102|  5.14k|  return aligned_split::sum<count_utf8_unsplit>(in, size,
 1103|  5.14k|                                                aligned_split::head(in, size));
 1104|  5.14k|}
_ZNK7simdutf7haswell14implementation23latin1_length_from_utf8EPKcm:
 1120|    706|    const char *buf, size_t len) const noexcept {
 1121|    706|  return count_utf8(buf, len);
 1122|    706|}
_ZNK7simdutf7haswell14implementation24utf8_length_from_utf16leEPKDsm:
 1133|    729|    const char16_t *input, size_t length) const noexcept {
 1134|    729|  return aligned_split::sum<utf8_length_from_utf16le_unsplit>(
 1135|    729|      input, length, aligned_split::head(input, length));
 1136|    729|}
_ZNK7simdutf7haswell14implementation24utf8_length_from_utf16beEPKDsm:
 1144|    657|    const char16_t *input, size_t length) const noexcept {
 1145|    657|  return aligned_split::sum<utf8_length_from_utf16be_unsplit>(
 1146|    657|      input, length, aligned_split::head(input, length));
 1147|    657|}
_ZNK7simdutf7haswell14implementation25utf32_length_from_utf16leEPKDsm:
 1157|    394|    const char16_t *input, size_t length) const noexcept {
 1158|    394|  return aligned_split::sum<utf32_length_from_utf16le_unsplit>(
 1159|    394|      input, length, aligned_split::head(input, length));
 1160|    394|}
_ZNK7simdutf7haswell14implementation25utf32_length_from_utf16beEPKDsm:
 1168|    415|    const char16_t *input, size_t length) const noexcept {
 1169|    415|  return aligned_split::sum<utf32_length_from_utf16be_unsplit>(
 1170|    415|      input, length, aligned_split::head(input, length));
 1171|    415|}
_ZNK7simdutf7haswell14implementation22utf16_length_from_utf8EPKcm:
 1181|  2.48k|    const char *input, size_t length) const noexcept {
 1182|  2.48k|  return aligned_split::sum<utf16_length_from_utf8_unsplit>(
 1183|  2.48k|      input, length, aligned_split::head(input, length));
 1184|  2.48k|}
_ZNK7simdutf7haswell14implementation23utf8_length_from_latin1EPKcm:
 1279|    300|    const char *input, size_t len) const noexcept {
 1280|    300|  return aligned_split::sum<utf8_length_from_latin1_unsplit>(
 1281|    300|      input, len, aligned_split::head(input, len));
 1282|    300|}
_ZNK7simdutf7haswell14implementation22utf8_length_from_utf32EPKDim:
 1292|    786|    const char32_t *input, size_t length) const noexcept {
 1293|    786|  return aligned_split::sum<utf8_length_from_utf32_unsplit>(
 1294|    786|      input, length, aligned_split::head(input, length));
 1295|    786|}
_ZNK7simdutf7haswell14implementation23utf16_length_from_utf32EPKDim:
 1319|  1.15k|    const char32_t *input, size_t length) const noexcept {
 1320|  1.15k|  return aligned_split::sum<utf16_length_from_utf32_unsplit>(
 1321|  1.15k|      input, length, aligned_split::head(input, length));
 1322|  1.15k|}
_ZNK7simdutf7haswell14implementation22utf32_length_from_utf8EPKcm:
 1332|  1.25k|    const char *input, size_t length) const noexcept {
 1333|  1.25k|  return aligned_split::sum<utf32_length_from_utf8_unsplit>(
 1334|  1.25k|      input, length, aligned_split::head(input, length));
 1335|  1.25k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_18is_asciiERKNS1_4simd8simd8x64IhEE:
   12|  5.78M|simdutf_really_inline bool is_ascii(const simd8x64<uint8_t> &input) {
   13|  5.78M|  return input.reduce_or().is_ascii();
   14|  5.78M|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_124must_be_2_3_continuationENS1_4simd5simd8IhEES4_:
   20|  3.14M|                         const simd8<uint8_t> prev3) {
   21|  3.14M|  simd8<uint8_t> is_third_byte =
   22|  3.14M|      prev2.saturating_sub(0xe0u - 0x80); // Only 111_____ will be > 0x80
   23|  3.14M|  simd8<uint8_t> is_fourth_byte =
   24|  3.14M|      prev3.saturating_sub(0xf0u - 0x80); // Only 1111____ will be > 0x80
   25|  3.14M|  return simd8<bool>(is_third_byte | is_fourth_byte);
   26|  3.14M|}
_ZN7simdutf7haswell21validate_utf8_unsplitEPKcm:
  173|  4.89k|                                                 size_t len) noexcept {
  174|  4.89k|  return haswell::utf8_validation::generic_validate_utf8(buf, len);
  175|  4.89k|}
_ZN7simdutf7haswell33validate_utf8_with_errors_unsplitEPKcm:
  186|  4.89k|validate_utf8_with_errors_unsplit(const char *buf, size_t len) noexcept {
  187|  4.89k|  return haswell::utf8_validation::generic_validate_utf8_with_errors(buf, len);
  188|  4.89k|}
_ZN7simdutf7haswell24validate_utf16le_unsplitEPKDsm:
  254|  1.37k|                                                    size_t len) noexcept {
  255|  1.37k|  if (simdutf_unlikely(len == 0)) {
  ------------------
  |  |   93|  1.37k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 15, False: 1.36k]
  |  |  ------------------
  ------------------
  256|       |    // empty input is valid UTF-16. protect the implementation from
  257|       |    // handling nullptr
  258|     15|    return true;
  259|     15|  }
  260|  1.36k|  const auto res =
  261|  1.36k|      haswell::utf16::validate_utf16_with_errors<endianness::LITTLE>(buf, len);
  262|  1.36k|  if (res.is_err()) {
  ------------------
  |  Branch (262:7): [True: 122, False: 1.23k]
  ------------------
  263|    122|    return false;
  264|    122|  }
  265|       |
  266|  1.23k|  if (res.count == len) {
  ------------------
  |  Branch (266:7): [True: 75, False: 1.16k]
  ------------------
  267|     75|    return true;
  268|     75|  }
  269|       |
  270|  1.16k|  return scalar::utf16::validate<endianness::LITTLE>(buf + res.count,
  271|  1.16k|                                                     len - res.count);
  272|  1.23k|}
_ZN7simdutf7haswell24validate_utf16be_unsplitEPKDsm:
  284|  1.36k|                                                    size_t len) noexcept {
  285|  1.36k|  if (simdutf_unlikely(len == 0)) {
  ------------------
  |  |   93|  1.36k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 16, False: 1.34k]
  |  |  ------------------
  ------------------
  286|       |    // empty input is valid UTF-16. protect the implementation from
  287|       |    // handling nullptr
  288|     16|    return true;
  289|     16|  }
  290|  1.34k|  const auto res =
  291|  1.34k|      haswell::utf16::validate_utf16_with_errors<endianness::BIG>(buf, len);
  292|  1.34k|  if (res.is_err()) {
  ------------------
  |  Branch (292:7): [True: 172, False: 1.17k]
  ------------------
  293|    172|    return false;
  294|    172|  }
  295|       |
  296|  1.17k|  if (res.count == len) {
  ------------------
  |  Branch (296:7): [True: 80, False: 1.09k]
  ------------------
  297|     80|    return true;
  298|     80|  }
  299|       |
  300|  1.09k|  return scalar::utf16::validate<endianness::BIG>(buf + res.count,
  301|  1.09k|                                                  len - res.count);
  302|  1.17k|}
_ZN7simdutf7haswell36validate_utf16le_with_errors_unsplitEPKDsm:
  312|  1.37k|validate_utf16le_with_errors_unsplit(const char16_t *buf, size_t len) noexcept {
  313|       |
  314|  1.37k|  const result res =
  315|  1.37k|      haswell::utf16::validate_utf16_with_errors<endianness::LITTLE>(buf, len);
  316|  1.37k|  if (res.count != len) {
  ------------------
  |  Branch (316:7): [True: 1.28k, False: 90]
  ------------------
  317|  1.28k|    const result scalar_res =
  318|  1.28k|        scalar::utf16::validate_with_errors<endianness::LITTLE>(
  319|  1.28k|            buf + res.count, len - res.count);
  320|  1.28k|    return result(scalar_res.error, res.count + scalar_res.count);
  321|  1.28k|  } else {
  322|     90|    return res;
  323|     90|  }
  324|  1.37k|}
_ZN7simdutf7haswell36validate_utf16be_with_errors_unsplitEPKDsm:
  333|  1.36k|validate_utf16be_with_errors_unsplit(const char16_t *buf, size_t len) noexcept {
  334|  1.36k|  const result res =
  335|  1.36k|      haswell::utf16::validate_utf16_with_errors<endianness::BIG>(buf, len);
  336|  1.36k|  if (res.count != len) {
  ------------------
  |  Branch (336:7): [True: 1.26k, False: 96]
  ------------------
  337|  1.26k|    const result scalar_res =
  338|  1.26k|        scalar::utf16::validate_with_errors<endianness::BIG>(buf + res.count,
  339|  1.26k|                                                             len - res.count);
  340|  1.26k|    return result(scalar_res.error, res.count + scalar_res.count);
  341|  1.26k|  } else {
  342|     96|    return res;
  343|     96|  }
  344|  1.36k|}
_ZN7simdutf7haswell22validate_utf32_unsplitEPKDim:
  381|  2.23k|                                                  size_t len) noexcept {
  382|  2.23k|  return utf32::validate(buf, len);
  383|  2.23k|}
_ZN7simdutf7haswell34convert_utf16_to_utf8_with_detailsILNS_10endiannessE0EEENS_11full_resultEPKDsmPc:
  711|    628|    const char16_t *buf, size_t len, char *utf8_output) {
  712|    628|  std::pair<result, char *> ret =
  713|    628|      haswell::avx2_convert_utf16_to_utf8_with_errors<big_endian>(buf, len,
  714|    628|                                                                  utf8_output);
  715|    628|  if (ret.first.error) {
  ------------------
  |  Branch (715:7): [True: 128, False: 500]
  ------------------
  716|    128|    return full_result(ret.first.error, ret.first.count,
  717|    128|                       size_t(ret.second - utf8_output));
  718|    128|  }
  719|    500|  if (ret.first.count != len) {
  ------------------
  |  Branch (719:7): [True: 496, False: 4]
  ------------------
  720|    496|    full_result sres =
  721|    496|        scalar::utf16_to_utf8::convert_with_errors<big_endian, false>(
  722|    496|            buf + ret.first.count, len - ret.first.count, ret.second, 0);
  723|    496|    return full_result(sres.error, ret.first.count + sres.input_count,
  724|    496|                       size_t(ret.second - utf8_output) + sres.output_count);
  725|    496|  }
  726|      4|  return full_result(error_code::SUCCESS, len,
  727|      4|                     size_t(ret.second - utf8_output));
  728|    500|}
_ZN7simdutf7haswell34convert_utf16_to_utf8_with_detailsILNS_10endiannessE1EEENS_11full_resultEPKDsmPc:
  711|    540|    const char16_t *buf, size_t len, char *utf8_output) {
  712|    540|  std::pair<result, char *> ret =
  713|    540|      haswell::avx2_convert_utf16_to_utf8_with_errors<big_endian>(buf, len,
  714|    540|                                                                  utf8_output);
  715|    540|  if (ret.first.error) {
  ------------------
  |  Branch (715:7): [True: 120, False: 420]
  ------------------
  716|    120|    return full_result(ret.first.error, ret.first.count,
  717|    120|                       size_t(ret.second - utf8_output));
  718|    120|  }
  719|    420|  if (ret.first.count != len) {
  ------------------
  |  Branch (719:7): [True: 416, False: 4]
  ------------------
  720|    416|    full_result sres =
  721|    416|        scalar::utf16_to_utf8::convert_with_errors<big_endian, false>(
  722|    416|            buf + ret.first.count, len - ret.first.count, ret.second, 0);
  723|    416|    return full_result(sres.error, ret.first.count + sres.input_count,
  724|    416|                       size_t(ret.second - utf8_output) + sres.output_count);
  725|    416|  }
  726|      4|  return full_result(error_code::SUCCESS, len,
  727|      4|                     size_t(ret.second - utf8_output));
  728|    420|}
_ZN7simdutf7haswell21count_utf16le_unsplitEPKDsm:
 1072|  1.38k|                                                   size_t length) noexcept {
 1073|  1.38k|  return utf16::count_code_points<endianness::LITTLE>(input, length);
 1074|  1.38k|}
_ZN7simdutf7haswell21count_utf16be_unsplitEPKDsm:
 1083|  1.37k|                                                   size_t length) noexcept {
 1084|  1.37k|  return utf16::count_code_points<endianness::BIG>(input, length);
 1085|  1.37k|}
_ZN7simdutf7haswell18count_utf8_unsplitEPKcm:
 1096|  5.70k|                                                size_t size) noexcept {
 1097|  5.70k|  return utf8::count_code_points_bytemask(in, size);
 1098|  5.70k|}
_ZN7simdutf7haswell32utf8_length_from_utf16le_unsplitEPKDsm:
 1127|    783|    const char16_t *input, size_t length) noexcept {
 1128|    783|  return utf16::utf8_length_from_utf16_bytemask<endianness::LITTLE>(input,
 1129|    783|                                                                    length);
 1130|    783|}
_ZN7simdutf7haswell32utf8_length_from_utf16be_unsplitEPKDsm:
 1139|    711|    const char16_t *input, size_t length) noexcept {
 1140|    711|  return utf16::utf8_length_from_utf16_bytemask<endianness::BIG>(input, length);
 1141|    711|}
_ZN7simdutf7haswell33utf32_length_from_utf16le_unsplitEPKDsm:
 1152|    427|    const char16_t *input, size_t length) noexcept {
 1153|    427|  return utf16::utf32_length_from_utf16<endianness::LITTLE>(input, length);
 1154|    427|}
_ZN7simdutf7haswell33utf32_length_from_utf16be_unsplitEPKDsm:
 1163|    451|    const char16_t *input, size_t length) noexcept {
 1164|    451|  return utf16::utf32_length_from_utf16<endianness::BIG>(input, length);
 1165|    451|}
_ZN7simdutf7haswell30utf16_length_from_utf8_unsplitEPKcm:
 1176|  2.75k|utf16_length_from_utf8_unsplit(const char *input, size_t length) noexcept {
 1177|  2.75k|  return utf8::utf16_length_from_utf8_bytemask(input, length);
 1178|  2.75k|}
_ZN7simdutf7haswell31utf8_length_from_latin1_unsplitEPKcm:
 1223|    347|utf8_length_from_latin1_unsplit(const char *input, size_t len) noexcept {
 1224|    347|  const uint8_t *data = reinterpret_cast<const uint8_t *>(input);
 1225|    347|  size_t answer = len / sizeof(__m256i) * sizeof(__m256i);
 1226|    347|  size_t i = 0;
 1227|    347|  if (answer >= 2048) { // long strings optimization
  ------------------
  |  Branch (1227:7): [True: 160, False: 187]
  ------------------
 1228|    160|    __m256i four_64bits = _mm256_setzero_si256();
 1229|  3.05k|    while (i + sizeof(__m256i) <= len) {
  ------------------
  |  Branch (1229:12): [True: 2.89k, False: 160]
  ------------------
 1230|  2.89k|      __m256i runner = _mm256_setzero_si256();
 1231|       |      // We can do up to 255 loops without overflow.
 1232|  2.89k|      size_t iterations = (len - i) / sizeof(__m256i);
 1233|  2.89k|      if (iterations > 255) {
  ------------------
  |  Branch (1233:11): [True: 2.73k, False: 160]
  ------------------
 1234|  2.73k|        iterations = 255;
 1235|  2.73k|      }
 1236|  2.89k|      size_t max_i = i + iterations * sizeof(__m256i) - sizeof(__m256i);
 1237|   179k|      for (; i + 4 * sizeof(__m256i) <= max_i; i += 4 * sizeof(__m256i)) {
  ------------------
  |  Branch (1237:14): [True: 176k, False: 2.89k]
  ------------------
 1238|   176k|        __m256i input1 = _mm256_loadu_si256((const __m256i *)(data + i));
 1239|   176k|        __m256i input2 =
 1240|   176k|            _mm256_loadu_si256((const __m256i *)(data + i + sizeof(__m256i)));
 1241|   176k|        __m256i input3 = _mm256_loadu_si256(
 1242|   176k|            (const __m256i *)(data + i + 2 * sizeof(__m256i)));
 1243|   176k|        __m256i input4 = _mm256_loadu_si256(
 1244|   176k|            (const __m256i *)(data + i + 3 * sizeof(__m256i)));
 1245|   176k|        __m256i input12 =
 1246|   176k|            _mm256_add_epi8(_mm256_cmpgt_epi8(_mm256_setzero_si256(), input1),
 1247|   176k|                            _mm256_cmpgt_epi8(_mm256_setzero_si256(), input2));
 1248|   176k|        __m256i input23 =
 1249|   176k|            _mm256_add_epi8(_mm256_cmpgt_epi8(_mm256_setzero_si256(), input3),
 1250|   176k|                            _mm256_cmpgt_epi8(_mm256_setzero_si256(), input4));
 1251|   176k|        __m256i input1234 = _mm256_add_epi8(input12, input23);
 1252|   176k|        runner = _mm256_sub_epi8(runner, input1234);
 1253|   176k|      }
 1254|  11.5k|      for (; i <= max_i; i += sizeof(__m256i)) {
  ------------------
  |  Branch (1254:14): [True: 8.61k, False: 2.89k]
  ------------------
 1255|  8.61k|        __m256i input_256_chunk =
 1256|  8.61k|            _mm256_loadu_si256((const __m256i *)(data + i));
 1257|  8.61k|        runner = _mm256_sub_epi8(
 1258|  8.61k|            runner, _mm256_cmpgt_epi8(_mm256_setzero_si256(), input_256_chunk));
 1259|  8.61k|      }
 1260|  2.89k|      four_64bits = _mm256_add_epi64(
 1261|  2.89k|          four_64bits, _mm256_sad_epu8(runner, _mm256_setzero_si256()));
 1262|  2.89k|    }
 1263|    160|    answer += _mm256_extract_epi64(four_64bits, 0) +
 1264|    160|              _mm256_extract_epi64(four_64bits, 1) +
 1265|    160|              _mm256_extract_epi64(four_64bits, 2) +
 1266|    160|              _mm256_extract_epi64(four_64bits, 3);
 1267|    187|  } else if (answer > 0) {
  ------------------
  |  Branch (1267:14): [True: 106, False: 81]
  ------------------
 1268|  1.06k|    for (; i + sizeof(__m256i) <= len; i += sizeof(__m256i)) {
  ------------------
  |  Branch (1268:12): [True: 960, False: 106]
  ------------------
 1269|    960|      __m256i latin = _mm256_loadu_si256((const __m256i *)(data + i));
 1270|    960|      uint32_t non_ascii = _mm256_movemask_epi8(latin);
 1271|    960|      answer += count_ones(non_ascii);
 1272|    960|    }
 1273|    106|  }
 1274|    347|  return answer + scalar::latin1::utf8_length_from_latin1(
 1275|    347|                      reinterpret_cast<const char *>(data + i), len - i);
 1276|    347|}
_ZN7simdutf7haswell30utf8_length_from_utf32_unsplitEPKDim:
 1287|    802|utf8_length_from_utf32_unsplit(const char32_t *input, size_t length) noexcept {
 1288|    802|  return utf32::utf8_length_from_utf32(input, length);
 1289|    802|}
_ZN7simdutf7haswell31utf16_length_from_utf32_unsplitEPKDim:
 1300|  1.18k|utf16_length_from_utf32_unsplit(const char32_t *input, size_t length) noexcept {
 1301|  1.18k|  const __m256i v_00000000 = _mm256_setzero_si256();
 1302|  1.18k|  const __m256i v_ffff0000 = _mm256_set1_epi32((uint32_t)0xffff0000);
 1303|  1.18k|  size_t pos = 0;
 1304|  1.18k|  size_t count = 0;
 1305|   493k|  for (; pos + 8 <= length; pos += 8) {
  ------------------
  |  Branch (1305:10): [True: 491k, False: 1.18k]
  ------------------
 1306|   491k|    __m256i in = _mm256_loadu_si256((__m256i *)(input + pos));
 1307|   491k|    const __m256i surrogate_bytemask =
 1308|   491k|        _mm256_cmpeq_epi32(_mm256_and_si256(in, v_ffff0000), v_00000000);
 1309|   491k|    const uint32_t surrogate_bitmask =
 1310|   491k|        static_cast<uint32_t>(_mm256_movemask_epi8(surrogate_bytemask));
 1311|   491k|    size_t surrogate_count = (32 - count_ones(surrogate_bitmask)) / 4;
 1312|   491k|    count += 8 + surrogate_count;
 1313|   491k|  }
 1314|  1.18k|  return count +
 1315|  1.18k|         scalar::utf32::utf16_length_from_utf32(input + pos, length - pos);
 1316|  1.18k|}
_ZN7simdutf7haswell30utf32_length_from_utf8_unsplitEPKcm:
 1327|  1.38k|utf32_length_from_utf8_unsplit(const char *input, size_t length) noexcept {
 1328|  1.38k|  return utf8::count_code_points(input, length);
 1329|  1.38k|}

_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|}
_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|  3.97M|simdutf_really_inline long long int count_ones(uint64_t input_num) {
   15|       |  return _popcnt64(input_num);
   16|  3.97M|}

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

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5simd8IhEC2Ev:
  191|  29.3k|  simdutf_really_inline simd8() : base8_numeric<uint8_t>() {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIhEC2Ev:
  124|  29.3k|  simdutf_really_inline base8_numeric() : base8<T>() {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEEC2Ev:
   71|  29.3k|  simdutf_really_inline base8() : base<simd8<T>>() {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEC2Ev:
   14|  29.3k|  simdutf_really_inline base() : value{__m256i()} {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IhEC2EPKh:
  274|  5.78M|      : chunks{simd8<T>::load(ptr),
  275|  5.78M|               simd8<T>::load(ptr + sizeof(simd8<T>) / sizeof(T))} {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIhE4loadEPKh:
  111|  12.4M|  static simdutf_really_inline simd8<T> load(const T values[32]) {
  112|  12.4M|    return _mm256_loadu_si256(reinterpret_cast<const __m256i *>(values));
  113|  12.4M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5simd8IhEC2EDv4_x:
  193|   168M|      : base8_numeric<uint8_t>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIhEC2EDv4_x:
  126|   168M|      : base8<T>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEEC2EDv4_x:
   73|   168M|  simdutf_really_inline base8(const __m256i _value) : base<simd8<T>>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEC2EDv4_x:
   17|   168M|  simdutf_really_inline base(const __m256i _value) : value(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEoRES5_:
   59|  8.07M|  simdutf_really_inline Child &operator|=(const Child other) {
   60|  8.07M|    auto this_cast = static_cast<Child *>(this);
   61|  8.07M|    *this_cast = *this_cast | other;
   62|  8.07M|    return *this_cast;
   63|  8.07M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEorES5_:
   50|  17.0M|  simdutf_really_inline Child operator|(const Child other) const {
   51|  17.0M|    return _mm256_or_si256(*this, other);
   52|  17.0M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEcvRKDv4_xEv:
   19|   221M|  simdutf_really_inline operator const __m256i &() const { return this->value; }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IhE9reduce_orEv:
  294|  5.78M|  simdutf_really_inline simd8<T> reduce_or() const {
  295|  5.78M|    return this->chunks[0] | this->chunks[1];
  296|  5.78M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IhE8is_asciiEv:
  234|  5.78M|  simdutf_really_inline bool is_ascii() const {
  235|  5.78M|    return _mm256_movemask_epi8(*this) == 0;
  236|  5.78M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEE4prevILi1EEENS4_IhEES8_:
   83|  3.20M|  simdutf_really_inline simd8<T> prev(const simd8<T> prev_chunk) const {
   84|       |    return _mm256_alignr_epi8(
   85|  3.20M|        *this, _mm256_permute2x128_si256(prev_chunk, *this, 0x21), 16 - N);
   86|  3.20M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IhE3shrILi4EEES4_v:
  245|  6.41M|  template <int N> simdutf_really_inline simd8<uint8_t> shr() const {
  246|  6.41M|    return simd8<uint8_t>(_mm256_srli_epi16(*this, N)) & uint8_t(0xFFu >> N);
  247|  6.41M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIhE9lookup_16IhEENS2_5simd8IT_EES7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_:
  157|  9.62M|            L replace15) const {
  158|  9.62M|    return lookup_16(simd8<L>::repeat_16(
  159|  9.62M|        replace0, replace1, replace2, replace3, replace4, replace5, replace6,
  160|  9.62M|        replace7, replace8, replace9, replace10, replace11, replace12,
  161|  9.62M|        replace13, replace14, replace15));
  162|  9.62M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIhE9lookup_16IhEENS2_5simd8IT_EES8_:
  148|  9.62M|  simdutf_really_inline simd8<L> lookup_16(simd8<L> lookup_table) const {
  149|  9.62M|    return _mm256_shuffle_epi8(lookup_table, *this);
  150|  9.62M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIhE9repeat_16Ehhhhhhhhhhhhhhhh:
  118|  9.62M|                                                  T v14, T v15) {
  119|  9.62M|    return simd8<T>(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,
  120|  9.62M|                    v14, v15, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,
  121|  9.62M|                    v12, v13, v14, v15);
  122|  9.62M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5simd8IhEC2Ehhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh:
  207|  9.62M|      : simd8(_mm256_setr_epi8(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,
  208|  9.62M|                               v12, v13, v14, v15, v16, v17, v18, v19, v20, v21,
  209|  9.62M|                               v22, v23, v24, v25, v26, v27, v28, v29, v30,
  210|  9.62M|                               v31)) {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEanES5_:
   53|  21.7M|  simdutf_really_inline Child operator&(const Child other) const {
   54|  21.7M|    return _mm256_and_si256(*this, other);
   55|  21.7M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5simd8IhEC2Eh:
  195|  23.7M|  simdutf_really_inline simd8(uint8_t _value) : simd8(splat(_value)) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIhE5splatEh:
  105|  23.7M|  static simdutf_really_inline simd8<T> splat(T _value) {
  106|  23.7M|    return _mm256_set1_epi8(_value);
  107|  23.7M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEE4prevILi2EEENS4_IhEES8_:
   83|  3.14M|  simdutf_really_inline simd8<T> prev(const simd8<T> prev_chunk) const {
   84|       |    return _mm256_alignr_epi8(
   85|  3.14M|        *this, _mm256_permute2x128_si256(prev_chunk, *this, 0x21), 16 - N);
   86|  3.14M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEE4prevILi3EEENS4_IhEES8_:
   83|  3.14M|  simdutf_really_inline simd8<T> prev(const simd8<T> prev_chunk) const {
   84|       |    return _mm256_alignr_epi8(
   85|  3.14M|        *this, _mm256_permute2x128_si256(prev_chunk, *this, 0x21), 16 - N);
   86|  3.14M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IhE14saturating_subES4_:
  214|  7.21M|  saturating_sub(const simd8<uint8_t> other) const {
  215|  7.21M|    return _mm256_subs_epu8(*this, other);
  216|  7.21M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5simd8IbEC2EDv4_x:
   95|  25.7M|  simdutf_really_inline simd8(const __m256i _value) : base8<bool>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5base8IbNS2_5simd8IbEEEC2EDv4_x:
   73|  25.7M|  simdutf_really_inline base8(const __m256i _value) : base<simd8<T>>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IbEEEC2EDv4_x:
   17|  25.7M|  simdutf_really_inline base(const __m256i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IbEEEcvRKDv4_xEv:
   19|  19.2M|  simdutf_really_inline operator const __m256i &() const { return this->value; }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEeoES5_:
   56|  3.14M|  simdutf_really_inline Child operator^(const Child other) const {
   57|  3.14M|    return _mm256_xor_si256(*this, other);
   58|  3.14M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5simd8IhEC2EPKh:
  197|   925k|  simdutf_really_inline simd8(const uint8_t values[32]) : simd8(load(values)) {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IhE7gt_bitsES4_:
  225|   923k|  gt_bits(const simd8<uint8_t> other) const {
  226|   923k|    return this->saturating_sub(other);
  227|   923k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IhE8is_asciiEv:
  298|  3.11k|  simdutf_really_inline bool is_ascii() const {
  299|  3.11k|    return this->reduce_or().is_ascii();
  300|  3.11k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IhE13gteq_unsignedEh:
  341|  2.12k|  simdutf_really_inline uint64_t gteq_unsigned(const uint8_t m) const {
  342|  2.12k|    const simd8<uint8_t> mask = simd8<uint8_t>::splat(m);
  343|  2.12k|    return simd8x64<bool>((simd8<uint8_t>(__m256i(this->chunks[0])) >= mask),
  344|  2.12k|                          (simd8<uint8_t>(__m256i(this->chunks[1])) >= mask))
  345|  2.12k|        .to_bitmask();
  346|  2.12k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IhEgeES4_:
  229|  4.00M|  operator>=(const simd8<uint8_t> other) const {
  230|  4.00M|    return other.min_val(*this) == other;
  231|  4.00M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simdeqENS2_5simd8IhEES4_:
   76|  6.52M|                                               const simd8<T> rhs) {
   77|  6.52M|    return _mm256_cmpeq_epi8(lhs, rhs);
   78|  6.52M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IhE7min_valES4_:
  220|  4.00M|  min_val(const simd8<uint8_t> other) const {
  221|  4.00M|    return _mm256_min_epu8(other, *this);
  222|  4.00M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IbEC2ENS2_5simd8IbEES6_:
  272|  1.97M|      : chunks{chunk0, chunk1} {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IbE10to_bitmaskEv:
  282|  1.97M|  simdutf_really_inline uint64_t to_bitmask() const {
  283|  1.97M|    uint64_t r_lo = uint32_t(this->chunks[0].to_bitmask());
  284|  1.97M|    uint64_t r_hi = this->chunks[1].to_bitmask();
  285|  1.97M|    return r_lo | (r_hi << 32);
  286|  1.97M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IbE10to_bitmaskEv:
   99|  6.47M|  simdutf_really_inline uint32_t to_bitmask() const {
  100|  6.47M|    return uint32_t(_mm256_movemask_epi8(value));
  101|  6.47M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IhE21any_bits_set_anywhereEv:
  241|  3.43M|  simdutf_really_inline bool any_bits_set_anywhere() const {
  242|  3.43M|    return !bits_not_set_anywhere();
  243|  3.43M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IhE21bits_not_set_anywhereEv:
  237|  3.43M|  simdutf_really_inline bool bits_not_set_anywhere() const {
  238|  3.43M|    return _mm256_testz_si256(*this, *this);
  239|  3.43M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IaEC2EPKa:
  274|  6.77M|      : chunks{simd8<T>::load(ptr),
  275|  6.77M|               simd8<T>::load(ptr + sizeof(simd8<T>) / sizeof(T))} {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIaE4loadEPKa:
  111|  25.6M|  static simdutf_really_inline simd8<T> load(const T values[32]) {
  112|  25.6M|    return _mm256_loadu_si256(reinterpret_cast<const __m256i *>(values));
  113|  25.6M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5simd8IaEC2EDv4_x:
  169|  45.5M|      : base8_numeric<int8_t>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIaEC2EDv4_x:
  126|  45.5M|      : base8<T>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5base8IaNS2_5simd8IbEEEC2EDv4_x:
   73|  45.5M|  simdutf_really_inline base8(const __m256i _value) : base<simd8<T>>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IaEEEC2EDv4_x:
   17|  45.5M|  simdutf_really_inline base(const __m256i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IaE8is_asciiEv:
  298|  5.85M|  simdutf_really_inline bool is_ascii() const {
  299|  5.85M|    return this->reduce_or().is_ascii();
  300|  5.85M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IaE9reduce_orEv:
  294|  5.85M|  simdutf_really_inline simd8<T> reduce_or() const {
  295|  5.85M|    return this->chunks[0] | this->chunks[1];
  296|  5.85M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IaEEEorES5_:
   50|  5.85M|  simdutf_really_inline Child operator|(const Child other) const {
   51|  5.85M|    return _mm256_or_si256(*this, other);
   52|  5.85M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IaEEEcvRKDv4_xEv:
   19|  72.6M|  simdutf_really_inline operator const __m256i &() const { return this->value; }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IaE8is_asciiEv:
  177|  5.85M|  simdutf_really_inline bool is_ascii() const {
  178|  5.85M|    return _mm256_movemask_epi8(*this) == 0;
  179|  5.85M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IaE5storeEPa:
  277|   771k|  simdutf_really_inline void store(T *ptr) const {
  278|   771k|    this->chunks[0].store(ptr + sizeof(simd8<T>) * 0 / sizeof(T));
  279|   771k|    this->chunks[1].store(ptr + sizeof(simd8<T>) * 1 / sizeof(T));
  280|   771k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIaE5storeEPa:
  129|  1.54M|  simdutf_really_inline void store(T dst[32]) const {
  130|  1.54M|    return _mm256_storeu_si256(reinterpret_cast<__m256i *>(dst), *this);
  131|  1.54M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IaEcvNS3_IhEEEv:
  256|  2.03M|simdutf_really_inline simd8<int8_t>::operator simd8<uint8_t>() const {
  257|  2.03M|  return this->value;
  258|  2.03M|}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IaE2ltEa:
  325|  1.05M|  simdutf_really_inline uint64_t lt(const T m) const {
  326|  1.05M|    const simd8<T> mask = simd8<T>::splat(m);
  327|  1.05M|    return simd8x64<bool>(this->chunks[0] < mask, this->chunks[1] < mask)
  328|  1.05M|        .to_bitmask();
  329|  1.05M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIaE5splatEa:
  105|  14.0M|  static simdutf_really_inline simd8<T> splat(T _value) {
  106|  14.0M|    return _mm256_set1_epi8(_value);
  107|  14.0M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IaEltES4_:
  184|  2.10M|  simdutf_really_inline simd8<bool> operator<(const simd8<int8_t> other) const {
  185|  2.10M|    return _mm256_cmpgt_epi8(other, *this);
  186|  2.10M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IaE20store_ascii_as_utf32EPDi:
  310|  1.33M|  simdutf_really_inline void store_ascii_as_utf32(char32_t *ptr) const {
  311|  1.33M|    this->chunks[0].store_ascii_as_utf32(ptr + sizeof(simd8<T>) * 0);
  312|  1.33M|    this->chunks[1].store_ascii_as_utf32(ptr + sizeof(simd8<T>) * 1);
  313|  1.33M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IaEEE20store_ascii_as_utf32EPDi:
   36|  2.66M|  simdutf_really_inline void store_ascii_as_utf32(char32_t *ptr) const {
   37|  2.66M|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(ptr),
   38|  2.66M|                        _mm256_cvtepu8_epi32(_mm256_castsi256_si128(*this)));
   39|  2.66M|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(ptr + 8),
   40|  2.66M|                        _mm256_cvtepu8_epi32(_mm256_castsi256_si128(
   41|  2.66M|                            _mm256_srli_si256(*this, 8))));
   42|  2.66M|    _mm256_storeu_si256(
   43|  2.66M|        reinterpret_cast<__m256i *>(ptr + 16),
   44|  2.66M|        _mm256_cvtepu8_epi32(_mm256_extractf128_si256(*this, 1)));
   45|  2.66M|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(ptr + 24),
   46|       |                        _mm256_cvtepu8_epi32(_mm_srli_si128(
   47|  2.66M|                            _mm256_extractf128_si256(*this, 1), 8)));
   48|  2.66M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_6simd16ItEEEC2EDv4_x:
   17|  54.5M|  simdutf_really_inline base(const __m256i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_6simd16ItEEEcvRKDv4_xEv:
   19|  65.3M|  simdutf_really_inline operator const __m256i &() const { return this->value; }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_6simd16IbEEEC2EDv4_x:
   17|  6.52M|  simdutf_really_inline base(const __m256i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_6simd16IbEEEcvRKDv4_xEv:
   19|  6.52M|  simdutf_really_inline operator const __m256i &() const { return this->value; }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_6simd16ItEEEanES5_:
   53|  12.6M|  simdutf_really_inline Child operator&(const Child other) const {
   54|  12.6M|    return _mm256_and_si256(*this, other);
   55|  12.6M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IaE20store_ascii_as_utf16ILNS_10endiannessE0EEEvPDs:
  303|  1.31M|  simdutf_really_inline void store_ascii_as_utf16(char16_t *ptr) const {
  304|  1.31M|    this->chunks[0].template store_ascii_as_utf16<endian>(ptr +
  305|  1.31M|                                                          sizeof(simd8<T>) * 0);
  306|  1.31M|    this->chunks[1].template store_ascii_as_utf16<endian>(ptr +
  307|  1.31M|                                                          sizeof(simd8<T>) * 1);
  308|  1.31M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IaEEE20store_ascii_as_utf16ILNS_10endiannessE0EEEvPDs:
   22|  2.63M|  simdutf_really_inline void store_ascii_as_utf16(char16_t *ptr) const {
   23|  2.63M|    __m256i first = _mm256_cvtepu8_epi16(_mm256_castsi256_si128(*this));
   24|  2.63M|    __m256i second = _mm256_cvtepu8_epi16(_mm256_extractf128_si256(*this, 1));
   25|  2.63M|    if (big_endian) {
  ------------------
  |  Branch (25:9): [Folded, False: 2.63M]
  ------------------
   26|      0|      const __m256i swap = _mm256_setr_epi8(
   27|      0|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
   28|      0|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
   29|      0|      first = _mm256_shuffle_epi8(first, swap);
   30|      0|      second = _mm256_shuffle_epi8(second, swap);
   31|      0|    }
   32|  2.63M|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(ptr), first);
   33|  2.63M|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(ptr + 16), second);
   34|  2.63M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IaE20store_ascii_as_utf16ILNS_10endiannessE1EEEvPDs:
  303|  1.37M|  simdutf_really_inline void store_ascii_as_utf16(char16_t *ptr) const {
  304|  1.37M|    this->chunks[0].template store_ascii_as_utf16<endian>(ptr +
  305|  1.37M|                                                          sizeof(simd8<T>) * 0);
  306|  1.37M|    this->chunks[1].template store_ascii_as_utf16<endian>(ptr +
  307|  1.37M|                                                          sizeof(simd8<T>) * 1);
  308|  1.37M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd4baseINS2_5simd8IaEEE20store_ascii_as_utf16ILNS_10endiannessE1EEEvPDs:
   22|  2.74M|  simdutf_really_inline void store_ascii_as_utf16(char16_t *ptr) const {
   23|  2.74M|    __m256i first = _mm256_cvtepu8_epi16(_mm256_castsi256_si128(*this));
   24|  2.74M|    __m256i second = _mm256_cvtepu8_epi16(_mm256_extractf128_si256(*this, 1));
   25|  2.74M|    if (big_endian) {
  ------------------
  |  Branch (25:9): [True: 2.74M, Folded]
  ------------------
   26|  2.74M|      const __m256i swap = _mm256_setr_epi8(
   27|  2.74M|          1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
   28|  2.74M|          21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
   29|  2.74M|      first = _mm256_shuffle_epi8(first, swap);
   30|  2.74M|      second = _mm256_shuffle_epi8(second, swap);
   31|  2.74M|    }
   32|  2.74M|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(ptr), first);
   33|  2.74M|    _mm256_storeu_si256(reinterpret_cast<__m256i *>(ptr + 16), second);
   34|  2.74M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIhE4zeroEv:
  108|   134k|  static simdutf_really_inline simd8<T> zero() {
  109|   134k|    return _mm256_setzero_si256();
  110|   134k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IaEgtES4_:
  181|  13.9M|  simdutf_really_inline simd8<bool> operator>(const simd8<int8_t> other) const {
  182|  13.9M|    return _mm256_cmpgt_epi8(*this, other);
  183|  13.9M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd5simd8IaEC2Ea:
  172|  12.1M|  simdutf_really_inline simd8(int8_t _value) : simd8(splat(_value)) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIhEmIENS2_5simd8IhEE:
  137|  16.1M|  simdutf_really_inline simd8<T> &operator-=(const simd8<T> other) {
  138|  16.1M|    *this = *this - other;
  139|  16.1M|    return *static_cast<simd8<T> *>(this);
  140|  16.1M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd13base8_numericIhEmiENS2_5simd8IhEE:
  134|  16.1M|  simdutf_really_inline simd8<T> operator-(const simd8<T> other) const {
  135|  16.1M|    return _mm256_sub_epi8(*this, other);
  136|  16.1M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd10sum_8bytesENS2_5simd8IhEE:
  353|  63.1k|simdutf_really_inline simd64<uint64_t> sum_8bytes(const simd8<uint8_t> v) {
  354|  63.1k|  return _mm256_sad_epu8(v.value, simd8<uint8_t>::zero());
  355|  63.1k|}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd5simd8IhE9sum_bytesEv:
  249|  3.96k|  simdutf_really_inline uint64_t sum_bytes() const {
  250|  3.96k|    const auto tmp = _mm256_sad_epu8(value, _mm256_setzero_si256());
  251|       |
  252|  3.96k|    return _mm256_extract_epi64(tmp, 0) + _mm256_extract_epi64(tmp, 1) +
  253|  3.96k|           _mm256_extract_epi64(tmp, 2) + _mm256_extract_epi64(tmp, 3);
  254|  3.96k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd8simd8x64IaE2gtEa:
  331|   917k|  simdutf_really_inline uint64_t gt(const T m) const {
  332|   917k|    const simd8<T> mask = simd8<T>::splat(m);
  333|   917k|    return simd8x64<bool>(this->chunks[0] > mask, this->chunks[1] > mask)
  334|   917k|        .to_bitmask();
  335|   917k|  }

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd9simd16x32ItEC2EPKt:
  202|  2.32M|      : chunks{simd16<T>::load(ptr),
  203|  2.32M|               simd16<T>::load(ptr + sizeof(simd16<T>) / sizeof(T))} {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd14base16_numericItE4loadEPKt:
   66|  11.5M|  static simdutf_really_inline simd16<T> load(const T values[8]) {
   67|  11.5M|    return _mm256_loadu_si256(reinterpret_cast<const __m256i *>(values));
   68|  11.5M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd16ItEC2EDv4_x:
   97|  54.5M|      : base16_numeric<uint16_t>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd14base16_numericItEC2EDv4_x:
   73|  54.5M|      : base16<T>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6base16ItNS2_6simd16IbEEEC2EDv4_x:
   20|  54.5M|      : base<simd16<T>>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd9simd16x32ItE10swap_bytesEv:
  229|  1.19M|  simdutf_really_inline void swap_bytes() {
  230|  1.19M|    this->chunks[0] = this->chunks[0].swap_bytes();
  231|  1.19M|    this->chunks[1] = this->chunks[1].swap_bytes();
  232|  1.19M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd6simd16ItE10swap_bytesEv:
  139|  3.24M|  simdutf_really_inline simd16<uint16_t> swap_bytes() const {
  140|  3.24M|    const __m256i swap = _mm256_setr_epi8(
  141|  3.24M|        1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18,
  142|  3.24M|        21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30);
  143|  3.24M|    return _mm256_shuffle_epi8(*this, swap);
  144|  3.24M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd14base16_numericItE5splatEt:
   58|  13.3M|  static simdutf_really_inline simd16<T> splat(T _value) {
   59|  13.3M|    return _mm256_set1_epi16(_value);
   60|  13.3M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simdeqENS2_6simd16ItEES4_:
   26|  6.52M|                                               const simd16<T> rhs) {
   27|  6.52M|    return _mm256_cmpeq_epi16(lhs, rhs);
   28|  6.52M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd16IbEC2EDv4_x:
   45|  6.52M|  simdutf_really_inline simd16(const __m256i _value) : base16<bool>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6base16IbNS2_6simd16IbEEEC2EDv4_x:
   20|  6.52M|      : base<simd16<T>>(_value) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd9simd16x32IbEC2ENS2_6simd16IbEES6_:
  200|  2.32M|      : chunks{chunk0, chunk1} {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd9simd16x32IbE10to_bitmaskEv:
  210|  2.32M|  simdutf_really_inline uint64_t to_bitmask() const {
  211|  2.32M|    uint64_t r_lo = uint32_t(this->chunks[0].to_bitmask());
  212|  2.32M|    uint64_t r_hi = this->chunks[1].to_bitmask();
  213|  2.32M|    return r_lo | (r_hi << 32);
  214|  2.32M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd6simd16IbE10to_bitmaskEv:
   50|  4.65M|  simdutf_really_inline bitmask_type to_bitmask() const {
   51|  4.65M|    return _mm256_movemask_epi8(*this);
   52|  4.65M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd16ItEC2EPKDs:
  104|  4.97M|      : simd16(load(reinterpret_cast<const uint16_t *>(values))) {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd6simd16ItE3shrILi8EEES4_v:
  134|  2.55M|  template <int N> simdutf_really_inline simd16<uint16_t> shr() const {
  135|  2.55M|    return simd16<uint16_t>(_mm256_srli_epi16(*this, N));
  136|  2.55M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd16ItE4packERKS4_S6_:
  149|  2.48M|                                                   const simd16<uint16_t> &v1) {
  150|       |    // Note: the AVX2 variant of pack operates on 128-bit lanes, thus
  151|       |    //       we have to shuffle lanes in order to produce bytes in the
  152|       |    //       correct order.
  153|       |
  154|       |    // get the 0th lanes
  155|  2.48M|    const __m128i lo_0 = _mm256_extracti128_si256(v0, 0);
  156|  2.48M|    const __m128i lo_1 = _mm256_extracti128_si256(v1, 0);
  157|       |
  158|       |    // get the 1st lanes
  159|  2.48M|    const __m128i hi_0 = _mm256_extracti128_si256(v0, 1);
  160|  2.48M|    const __m128i hi_1 = _mm256_extracti128_si256(v1, 1);
  161|       |
  162|       |    // build new vectors (shuffle lanes)
  163|  2.48M|    const __m256i t0 = _mm256_set_m128i(lo_1, lo_0);
  ------------------
  |  |    4|  2.48M|      _mm256_permute2f128_si256(_mm256_castsi128_si256(xmm1),                  \
  |  |    5|  2.48M|                                _mm256_castsi128_si256(xmm2), 2)
  ------------------
  164|  2.48M|    const __m256i t1 = _mm256_set_m128i(hi_1, hi_0);
  ------------------
  |  |    4|  2.48M|      _mm256_permute2f128_si256(_mm256_castsi128_si256(xmm1),                  \
  |  |    5|  2.48M|                                _mm256_castsi128_si256(xmm2), 2)
  ------------------
  165|       |
  166|       |    // pack code units in linear order from v0 and v1
  167|  2.48M|    return _mm256_packus_epi16(t0, t1);
  168|  2.48M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd16ItEC2Et:
  100|  8.67M|  simdutf_really_inline simd16(uint16_t _value) : simd16(splat(_value)) {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd9simd16x32ItE12not_in_rangeEtt:
  249|  2.32M|  simdutf_really_inline uint64_t not_in_range(const T low, const T high) const {
  250|  2.32M|    const T span = static_cast<T>(high - low);
  251|  2.32M|    if ((span & static_cast<T>(span + 1)) == 0 && (low & span) == 0) {
  ------------------
  |  Branch (251:9): [True: 2.32M, False: 0]
  |  Branch (251:51): [True: 2.32M, False: 0]
  ------------------
  252|       |      // Aligned power-of-two block, such as the surrogates: one AND and
  253|       |      // one compare, instead of a min/max and a compare per bound.
  254|  2.32M|      const simd16<T> keep = simd16<T>::splat(static_cast<T>(~span));
  255|  2.32M|      const simd16<T> base = simd16<T>::splat(low);
  256|  2.32M|      return ~simd16x32<bool>((this->chunks[0] & keep) == base,
  257|  2.32M|                              (this->chunks[1] & keep) == base)
  258|  2.32M|                  .to_bitmask();
  259|  2.32M|    }
  260|      0|    const simd16<T> mask_low = simd16<T>::splat(static_cast<T>(low - 1));
  261|      0|    const simd16<T> mask_high = simd16<T>::splat(static_cast<T>(high + 1));
  262|      0|    return simd16x32<bool>(
  263|      0|               (this->chunks[0] >= mask_high) | (this->chunks[0] <= mask_low),
  264|      0|               (this->chunks[1] >= mask_high) | (this->chunks[1] <= mask_low))
  265|      0|        .to_bitmask();
  266|  2.32M|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd14base16_numericItE4zeroEv:
   62|  1.49k|  static simdutf_really_inline simd16<T> zero() {
   63|  1.49k|    return _mm256_setzero_si256();
   64|  1.49k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd3minENS2_6simd16ItEES4_:
  270|  3.73M|simd16<uint16_t> min(const simd16<uint16_t> a, simd16<uint16_t> b) {
  271|  3.73M|  return _mm256_min_epu16(a.value, b.value);
  272|  3.73M|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd14base16_numericItEpLENS2_6simd16ItEE:
   87|  5.59M|  simdutf_really_inline simd16<T> &operator+=(const simd16<T> other) {
   88|  5.59M|    *this = *this + other;
   89|  5.59M|    return *static_cast<simd16<T> *>(this);
   90|  5.59M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd14base16_numericItEplENS2_6simd16ItEE:
   84|  5.59M|  simdutf_really_inline simd16<T> operator+(const simd16<T> other) const {
   85|  5.59M|    return _mm256_add_epi16(*this, other);
   86|  5.59M|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd6simd16ItE3sumEv:
  170|  1.49k|  simdutf_really_inline uint64_t sum() const {
  171|  1.49k|    const auto lo_u16 = _mm256_and_si256(value, _mm256_set1_epi32(0x0000ffff));
  172|  1.49k|    const auto hi_u16 = _mm256_srli_epi32(value, 16);
  173|  1.49k|    const auto sum_u32 = _mm256_add_epi32(lo_u16, hi_u16);
  174|       |
  175|  1.49k|    const auto lo_u32 =
  176|  1.49k|        _mm256_and_si256(sum_u32, _mm256_set1_epi64x(0xffffffff));
  177|  1.49k|    const auto hi_u32 = _mm256_srli_epi64(sum_u32, 32);
  178|  1.49k|    const auto sum_u64 = _mm256_add_epi64(lo_u32, hi_u32);
  179|       |
  180|  1.49k|    return uint64_t(_mm256_extract_epi64(sum_u64, 0)) +
  181|  1.49k|           uint64_t(_mm256_extract_epi64(sum_u64, 1)) +
  182|  1.49k|           uint64_t(_mm256_extract_epi64(sum_u64, 2)) +
  183|       |           uint64_t(_mm256_extract_epi64(sum_u64, 3));
  184|  1.49k|  }

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd32IjE5splatEj:
   46|  16.4k|  simdutf_really_inline static simd32<uint32_t> splat(uint32_t v) {
   47|  16.4k|    return _mm256_set1_epi32(v);
   48|  16.4k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd32IjEC2EDv4_x:
    9|  3.79M|  simdutf_really_inline simd32(const __m256i v) : value(v) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd32IjEC2IDiEEPKT_:
   13|   932k|      : value(_mm256_loadu_si256(reinterpret_cast<const __m256i *>(ptr))) {}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd6simd32IjE10swap_bytesEv:
   27|   667k|  simdutf_really_inline simd32<uint32_t> swap_bytes() const {
   28|   667k|    const __m256i shuffle =
   29|   667k|        _mm256_setr_epi8(3, 2, 1, 0, 7, 6, 5, 4, 8, 9, 10, 11, 15, 14, 13, 12,
   30|   667k|                         3, 2, 1, 0, 7, 6, 5, 4, 8, 9, 10, 11, 15, 14, 13, 12);
   31|       |
   32|   667k|    return _mm256_shuffle_epi8(value, shuffle);
   33|   667k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simdgeENS2_6simd32IjEES4_:
  100|   249k|                                              const simd32<uint32_t> b) {
  101|   249k|  return _mm256_cmpeq_epi32(_mm256_max_epu32(a.value, b.value), a.value);
  102|   249k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd32IbEC2EDv4_x:
   59|   744k|  simdutf_really_inline simd32(const __m256i v) : value(v) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simdeqENS2_6simd32IjEES4_:
   95|   245k|                                              const simd32<uint32_t> b) {
   96|   245k|  return _mm256_cmpeq_epi32(a.value, b.value);
   97|   245k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simdanENS2_6simd32IjEES4_:
   85|  1.04M|                                                 const simd32<uint32_t> a) {
   86|  1.04M|  return _mm256_and_si256(a.value, b.value);
   87|  1.04M|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simdorIbEENS2_6simd32IT_EES6_S6_:
   70|   245k|                                          const simd32<T> b) {
   71|   245k|  return _mm256_or_si256(a.value, b.value);
   72|   245k|}
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd6simd32IbE3anyEv:
   61|   249k|  simdutf_really_inline bool any() const {
   62|   249k|    return _mm256_movemask_epi8(value) != 0;
   63|   249k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd32IjE4zeroEv:
   42|  5.01k|  simdutf_really_inline static simd32<uint32_t> zero() {
   43|  5.01k|    return _mm256_setzero_si256();
   44|  5.01k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd3maxENS2_6simd32IjEES4_:
   80|   843k|                                           const simd32<uint32_t> b) {
   81|   843k|  return _mm256_max_epu32(a.value, b.value);
   82|   843k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simdplENS2_6simd32IjEES4_:
   90|   421k|                                                 const simd32<uint32_t> b) {
   91|   421k|  return _mm256_add_epi32(a.value, b.value);
   92|   421k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simdgtENS2_6simd32IjEES4_:
  109|  3.69k|                                             const simd32<uint32_t> b) {
  110|  3.69k|  return !(b >= a);
  111|  3.69k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simdntENS2_6simd32IbEE:
  104|  3.69k|simdutf_really_inline simd32<bool> operator!(const simd32<bool> v) {
  105|  3.69k|  return _mm256_xor_si256(v.value, _mm256_set1_epi8(-1));
  106|  3.69k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd3minENS2_6simd32IjEES4_:
   75|   796k|                                           const simd32<uint32_t> a) {
   76|   796k|  return _mm256_min_epu32(a.value, b.value);
   77|   796k|}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd32IjEpLES4_:
   36|   796k|  simdutf_really_inline simd32 &operator+=(const simd32 other) {
   37|   796k|    value = _mm256_add_epi32(value, other.value);
   38|   796k|    return *this;
   39|   796k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd6simd32IjE3sumEv:
   15|    581|  simdutf_really_inline uint64_t sum() const {
   16|    581|    const __m256i mask = _mm256_set1_epi64x(0xffffffff);
   17|    581|    const __m256i t0 = _mm256_and_si256(value, mask);
   18|    581|    const __m256i t1 = _mm256_srli_epi64(value, 32);
   19|    581|    const __m256i t2 = _mm256_add_epi64(t0, t1);
   20|       |
   21|    581|    return uint64_t(_mm256_extract_epi64(t2, 0)) +
   22|    581|           uint64_t(_mm256_extract_epi64(t2, 1)) +
   23|    581|           uint64_t(_mm256_extract_epi64(t2, 2)) +
   24|       |           uint64_t(_mm256_extract_epi64(t2, 3));
   25|    581|  }

simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd64ImE4zeroEv:
   27|  8.46k|  simdutf_really_inline static simd64<uint64_t> zero() {
   28|  8.46k|    return _mm256_setzero_si256();
   29|  8.46k|  }
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd64ImEC2EDv4_x:
    9|  71.5k|  simdutf_really_inline simd64(const __m256i v) : value(v) {}
simdutf.cpp:_ZN7simdutf7haswell12_GLOBAL__N_14simd6simd64ImEpLES4_:
   21|  63.1k|  simdutf_really_inline simd64 &operator+=(const simd64 other) {
   22|  63.1k|    value = _mm256_add_epi64(value, other.value);
   23|  63.1k|    return *this;
   24|  63.1k|  }
simdutf.cpp:_ZNK7simdutf7haswell12_GLOBAL__N_14simd6simd64ImE3sumEv:
   15|  8.46k|  simdutf_really_inline uint64_t sum() const {
   16|  8.46k|    return _mm256_extract_epi64(value, 0) + _mm256_extract_epi64(value, 1) +
   17|  8.46k|           _mm256_extract_epi64(value, 2) + _mm256_extract_epi64(value, 3);
   18|  8.46k|  }

_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|  4.47M|simdutf_really_inline long long int count_ones(uint64_t input_num) {
   15|       |  return _popcnt64(input_num);
   16|  4.47M|}

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

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IhEC2Ev:
  183|  29.3k|  simdutf_really_inline simd8() : base8_numeric<uint8_t>() {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhEC2Ev:
  118|  29.3k|  simdutf_really_inline base8_numeric() : base8<T>() {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEEC2Ev:
   68|  29.3k|  simdutf_really_inline base8() : base<simd8<T>>() {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEC2Ev:
   13|  29.3k|  simdutf_really_inline base() : value{__m128i()} {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IhEC2EPKh:
  270|  5.78M|      : chunks{simd8<T>::load(ptr),
  271|  5.78M|               simd8<T>::load(ptr + sizeof(simd8<T>) / sizeof(T)),
  272|  5.78M|               simd8<T>::load(ptr + 2 * sizeof(simd8<T>) / sizeof(T)),
  273|  5.78M|               simd8<T>::load(ptr + 3 * sizeof(simd8<T>) / sizeof(T))} {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhE4loadEPKh:
  106|  24.0M|  static simdutf_really_inline simd8<T> load(const T values[16]) {
  107|  24.0M|    return _mm_loadu_si128(reinterpret_cast<const __m128i *>(values));
  108|  24.0M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IhEC2EDv2_x:
  185|   336M|      : base8_numeric<uint8_t>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhEC2EDv2_x:
  120|   336M|      : base8<T>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEEC2EDv2_x:
   69|   336M|  simdutf_really_inline base8(const __m128i _value) : base<simd8<T>>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEC2EDv2_x:
   16|   336M|  simdutf_really_inline base(const __m128i _value) : value(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEoRES5_:
   51|  11.2M|  simdutf_really_inline Child &operator|=(const Child other) {
   52|  11.2M|    auto this_cast = static_cast<Child *>(this);
   53|  11.2M|    *this_cast = *this_cast | other;
   54|  11.2M|    return *this_cast;
   55|  11.2M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEorES5_:
   42|  34.9M|  simdutf_really_inline Child operator|(const Child other) const {
   43|  34.9M|    return _mm_or_si128(*this, other);
   44|  34.9M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEcvRKDv2_xEv:
   18|   411M|  simdutf_really_inline operator const __m128i &() const { return this->value; }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IhE9reduce_orEv:
  290|  5.78M|  simdutf_really_inline simd8<T> reduce_or() const {
  291|  5.78M|    return (this->chunks[0] | this->chunks[1]) |
  292|  5.78M|           (this->chunks[2] | this->chunks[3]);
  293|  5.78M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE8is_asciiEv:
  228|  5.78M|  simdutf_really_inline bool is_ascii() const {
  229|  5.78M|    return _mm_movemask_epi8(*this) == 0;
  230|  5.78M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEE4prevILi1EEENS4_IhEES8_:
   79|  6.41M|  simdutf_really_inline simd8<T> prev(const simd8<T> prev_chunk) const {
   80|       |    return _mm_alignr_epi8(*this, prev_chunk, 16 - N);
   81|  6.41M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE3shrILi4EEES4_v:
  238|  12.8M|  template <int N> simdutf_really_inline simd8<uint8_t> shr() const {
  239|  12.8M|    return simd8<uint8_t>(_mm_srli_epi16(*this, N)) & uint8_t(0xFFu >> N);
  240|  12.8M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhE9lookup_16IhEENS2_5simd8IT_EES7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_:
  151|  19.2M|            L replace15) const {
  152|  19.2M|    return lookup_16(simd8<L>::repeat_16(
  153|  19.2M|        replace0, replace1, replace2, replace3, replace4, replace5, replace6,
  154|  19.2M|        replace7, replace8, replace9, replace10, replace11, replace12,
  155|  19.2M|        replace13, replace14, replace15));
  156|  19.2M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhE9lookup_16IhEENS2_5simd8IT_EES8_:
  142|  19.2M|  simdutf_really_inline simd8<L> lookup_16(simd8<L> lookup_table) const {
  143|  19.2M|    return _mm_shuffle_epi8(lookup_table, *this);
  144|  19.2M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhE9repeat_16Ehhhhhhhhhhhhhhhh:
  113|  19.2M|                                                  T v14, T v15) {
  114|  19.2M|    return simd8<T>(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,
  115|  19.2M|                    v14, v15);
  116|  19.2M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IhEC2Ehhhhhhhhhhhhhhhh:
  196|  19.2M|      : simd8(_mm_setr_epi8(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,
  197|  19.2M|                            v12, v13, v14, v15)) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEanES5_:
   45|  43.3M|  simdutf_really_inline Child operator&(const Child other) const {
   46|  43.3M|    return _mm_and_si128(*this, other);
   47|  43.3M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IhEC2Eh:
  188|  46.8M|  simdutf_really_inline simd8(uint8_t _value) : simd8(splat(_value)) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhE5splatEh:
  102|  46.8M|  static simdutf_really_inline simd8<T> splat(T _value) {
  103|  46.8M|    return _mm_set1_epi8(_value);
  104|  46.8M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEE4prevILi2EEENS4_IhEES8_:
   79|  6.29M|  simdutf_really_inline simd8<T> prev(const simd8<T> prev_chunk) const {
   80|       |    return _mm_alignr_epi8(*this, prev_chunk, 16 - N);
   81|  6.29M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5base8IhNS2_5simd8IbEEE4prevILi3EEENS4_IhEES8_:
   79|  6.29M|  simdutf_really_inline simd8<T> prev(const simd8<T> prev_chunk) const {
   80|       |    return _mm_alignr_epi8(*this, prev_chunk, 16 - N);
   81|  6.29M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE14saturating_subES4_:
  201|  13.5M|  saturating_sub(const simd8<uint8_t> other) const {
  202|  13.5M|    return _mm_subs_epu8(*this, other);
  203|  13.5M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IbEC2EDv2_x:
   91|  51.4M|  simdutf_really_inline simd8(const __m128i _value) : base8<bool>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5base8IbNS2_5simd8IbEEEC2EDv2_x:
   69|  51.4M|  simdutf_really_inline base8(const __m128i _value) : base<simd8<T>>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IbEEEC2EDv2_x:
   16|  51.4M|  simdutf_really_inline base(const __m128i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IbEEEcvRKDv2_xEv:
   18|  51.4M|  simdutf_really_inline operator const __m128i &() const { return this->value; }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IhEEEeoES5_:
   48|  6.29M|  simdutf_really_inline Child operator^(const Child other) const {
   49|  6.29M|    return _mm_xor_si128(*this, other);
   50|  6.29M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IhEC2EPKh:
  190|   925k|  simdutf_really_inline simd8(const uint8_t *values) : simd8(load(values)) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE7gt_bitsES4_:
  212|   923k|  gt_bits(const simd8<uint8_t> other) const {
  213|   923k|    return this->saturating_sub(other);
  214|   923k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IhE8is_asciiEv:
  295|  3.55k|  simdutf_really_inline bool is_ascii() const {
  296|  3.55k|    return this->reduce_or().is_ascii();
  297|  3.55k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IhE13gteq_unsignedEh:
  352|  2.55k|  simdutf_really_inline uint64_t gteq_unsigned(const uint8_t m) const {
  353|  2.55k|    const simd8<uint8_t> mask = simd8<uint8_t>::splat(m);
  354|  2.55k|    return simd8x64<bool>(simd8<uint8_t>(__m128i(this->chunks[0])) >= mask,
  355|  2.55k|                          simd8<uint8_t>(__m128i(this->chunks[1])) >= mask,
  356|  2.55k|                          simd8<uint8_t>(__m128i(this->chunks[2])) >= mask,
  357|  2.55k|                          simd8<uint8_t>(__m128i(this->chunks[3])) >= mask)
  358|  2.55k|        .to_bitmask();
  359|  2.55k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhEgeES4_:
  217|  8.00M|  operator>=(const simd8<uint8_t> other) const {
  218|  8.00M|    return other.min_val(*this) == other;
  219|  8.00M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simdeqENS2_5simd8IhEES4_:
   72|  13.0M|                                               const simd8<T> rhs) {
   73|  13.0M|    return _mm_cmpeq_epi8(lhs, rhs);
   74|  13.0M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE7min_valES4_:
  207|  8.00M|  min_val(const simd8<uint8_t> other) const {
  208|  8.00M|    return _mm_min_epu8(*this, other);
  209|  8.00M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IbEC2ENS2_5simd8IbEES6_S6_S6_:
  268|  1.97M|      : chunks{chunk0, chunk1, chunk2, chunk3} {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IbE10to_bitmaskEv:
  318|  1.97M|  simdutf_really_inline uint64_t to_bitmask() const {
  319|  1.97M|    uint64_t r0 = uint32_t(this->chunks[0].to_bitmask());
  320|  1.97M|    uint64_t r1 = this->chunks[1].to_bitmask();
  321|  1.97M|    uint64_t r2 = this->chunks[2].to_bitmask();
  322|  1.97M|    uint64_t r3 = this->chunks[3].to_bitmask();
  323|  1.97M|    return r0 | (r1 << 16) | (r2 << 32) | (r3 << 48);
  324|  1.97M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IbE10to_bitmaskEv:
   95|  12.9M|  simdutf_really_inline int to_bitmask() const {
   96|  12.9M|    return _mm_movemask_epi8(*this);
   97|  12.9M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE21any_bits_set_anywhereEv:
  235|  3.43M|  simdutf_really_inline bool any_bits_set_anywhere() const {
  236|  3.43M|    return !bits_not_set_anywhere();
  237|  3.43M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE21bits_not_set_anywhereEv:
  232|  3.43M|  simdutf_really_inline bool bits_not_set_anywhere() const {
  233|  3.43M|    return _mm_testz_si128(*this, *this);
  234|  3.43M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IaEC2EPKa:
  270|  6.77M|      : chunks{simd8<T>::load(ptr),
  271|  6.77M|               simd8<T>::load(ptr + sizeof(simd8<T>) / sizeof(T)),
  272|  6.77M|               simd8<T>::load(ptr + 2 * sizeof(simd8<T>) / sizeof(T)),
  273|  6.77M|               simd8<T>::load(ptr + 3 * sizeof(simd8<T>) / sizeof(T))} {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIaE4loadEPKa:
  106|  51.3M|  static simdutf_really_inline simd8<T> load(const T values[16]) {
  107|  51.3M|    return _mm_loadu_si128(reinterpret_cast<const __m128i *>(values));
  108|  51.3M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IaEC2EDv2_x:
  163|  95.0M|      : base8_numeric<int8_t>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIaEC2EDv2_x:
  120|  95.0M|      : base8<T>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5base8IaNS2_5simd8IbEEEC2EDv2_x:
   69|  95.0M|  simdutf_really_inline base8(const __m128i _value) : base<simd8<T>>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IaEEEC2EDv2_x:
   16|  95.0M|  simdutf_really_inline base(const __m128i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IaE8is_asciiEv:
  295|  5.85M|  simdutf_really_inline bool is_ascii() const {
  296|  5.85M|    return this->reduce_or().is_ascii();
  297|  5.85M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IaE9reduce_orEv:
  290|  5.85M|  simdutf_really_inline simd8<T> reduce_or() const {
  291|  5.85M|    return (this->chunks[0] | this->chunks[1]) |
  292|  5.85M|           (this->chunks[2] | this->chunks[3]);
  293|  5.85M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IaEEEorES5_:
   42|  17.5M|  simdutf_really_inline Child operator|(const Child other) const {
   43|  17.5M|    return _mm_or_si128(*this, other);
   44|  17.5M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IaEEEcvRKDv2_xEv:
   18|   151M|  simdutf_really_inline operator const __m128i &() const { return this->value; }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IaE8is_asciiEv:
  168|  5.85M|  simdutf_really_inline bool is_ascii() const {
  169|  5.85M|    return _mm_movemask_epi8(*this) == 0;
  170|  5.85M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IaE5storeEPa:
  275|   771k|  simdutf_really_inline void store(T *ptr) const {
  276|   771k|    this->chunks[0].store(ptr + sizeof(simd8<T>) * 0 / sizeof(T));
  277|   771k|    this->chunks[1].store(ptr + sizeof(simd8<T>) * 1 / sizeof(T));
  278|   771k|    this->chunks[2].store(ptr + sizeof(simd8<T>) * 2 / sizeof(T));
  279|   771k|    this->chunks[3].store(ptr + sizeof(simd8<T>) * 3 / sizeof(T));
  280|   771k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIaE5storeEPa:
  123|  3.08M|  simdutf_really_inline void store(T dst[16]) const {
  124|  3.08M|    return _mm_storeu_si128(reinterpret_cast<__m128i *>(dst), *this);
  125|  3.08M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IaEcvNS3_IhEEEv:
  251|  4.75M|simdutf_really_inline simd8<int8_t>::operator simd8<uint8_t>() const {
  252|  4.75M|  return this->value;
  253|  4.75M|}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IaE2ltEa:
  326|  1.05M|  simdutf_really_inline uint64_t lt(const T m) const {
  327|  1.05M|    const simd8<T> mask = simd8<T>::splat(m);
  328|  1.05M|    return simd8x64<bool>(this->chunks[0] < mask, this->chunks[1] < mask,
  329|  1.05M|                          this->chunks[2] < mask, this->chunks[3] < mask)
  330|  1.05M|        .to_bitmask();
  331|  1.05M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIaE5splatEa:
  102|  26.2M|  static simdutf_really_inline simd8<T> splat(T _value) {
  103|  26.2M|    return _mm_set1_epi8(_value);
  104|  26.2M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IaEltES4_:
  176|  4.21M|  simdutf_really_inline simd8<bool> operator<(const simd8<int8_t> other) const {
  177|  4.21M|    return _mm_cmpgt_epi8(other, *this);
  178|  4.21M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IaE20store_ascii_as_utf32EPDi:
  311|  1.33M|  simdutf_really_inline void store_ascii_as_utf32(char32_t *ptr) const {
  312|  1.33M|    this->chunks[0].store_ascii_as_utf32(ptr + sizeof(simd8<T>) * 0);
  313|  1.33M|    this->chunks[1].store_ascii_as_utf32(ptr + sizeof(simd8<T>) * 1);
  314|  1.33M|    this->chunks[2].store_ascii_as_utf32(ptr + sizeof(simd8<T>) * 2);
  315|  1.33M|    this->chunks[3].store_ascii_as_utf32(ptr + sizeof(simd8<T>) * 3);
  316|  1.33M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IaEEE20store_ascii_as_utf32EPDi:
   32|  5.33M|  simdutf_really_inline void store_ascii_as_utf32(char32_t *p) const {
   33|  5.33M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(p), _mm_cvtepu8_epi32(*this));
   34|  5.33M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(p + 4),
   35|  5.33M|                     _mm_cvtepu8_epi32(_mm_srli_si128(*this, 4)));
   36|  5.33M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(p + 8),
   37|  5.33M|                     _mm_cvtepu8_epi32(_mm_srli_si128(*this, 8)));
   38|  5.33M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(p + 12),
   39|       |                     _mm_cvtepu8_epi32(_mm_srli_si128(*this, 12)));
   40|  5.33M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_6simd16ItEEEC2EDv2_x:
   16|   104M|  simdutf_really_inline base(const __m128i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_6simd16ItEEEcvRKDv2_xEv:
   18|   120M|  simdutf_really_inline operator const __m128i &() const { return this->value; }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhE4zeroEv:
  105|   261k|  static simdutf_really_inline simd8<T> zero() { return _mm_setzero_si128(); }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IaEgtES4_:
  173|  27.9M|  simdutf_really_inline simd8<bool> operator>(const simd8<int8_t> other) const {
  174|  27.9M|    return _mm_cmpgt_epi8(*this, other);
  175|  27.9M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd5simd8IaEC2Ea:
  165|  24.2M|  simdutf_really_inline simd8(int8_t _value) : simd8(splat(_value)) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhEmIENS2_5simd8IhEE:
  134|  32.2M|  simdutf_really_inline simd8<T> &operator-=(const simd8<T> other) {
  135|  32.2M|    *this = *this - other;
  136|  32.2M|    return *static_cast<simd8<T> *>(this);
  137|  32.2M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd13base8_numericIhEmiENS2_5simd8IhEE:
  131|  32.2M|  simdutf_really_inline simd8<T> operator-(const simd8<T> other) const {
  132|  32.2M|    return _mm_sub_epi8(*this, other);
  133|  32.2M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd10sum_8bytesENS2_5simd8IhEE:
  366|   126k|simdutf_really_inline simd64<uint64_t> sum_8bytes(const simd8<uint8_t> v) {
  367|   126k|  return _mm_sad_epu8(v.value, simd8<uint8_t>::zero());
  368|   126k|}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd5simd8IhE9sum_bytesEv:
  245|  5.59k|  simdutf_really_inline uint64_t sum_bytes() const {
  246|  5.59k|    const auto tmp = _mm_sad_epu8(value, _mm_setzero_si128());
  247|  5.59k|    return _mm_extract_epi64(tmp, 0) + _mm_extract_epi64(tmp, 1);
  248|  5.59k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_6simd16IbEEEC2EDv2_x:
   16|  13.0M|  simdutf_really_inline base(const __m128i _value) : value(_value) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_6simd16IbEEEcvRKDv2_xEv:
   18|  13.0M|  simdutf_really_inline operator const __m128i &() const { return this->value; }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_6simd16ItEEEanES5_:
   45|  25.3M|  simdutf_really_inline Child operator&(const Child other) const {
   46|  25.3M|    return _mm_and_si128(*this, other);
   47|  25.3M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IaE20store_ascii_as_utf16ILNS_10endiannessE0EEEvPDs:
  300|  1.31M|  simdutf_really_inline void store_ascii_as_utf16(char16_t *ptr) const {
  301|  1.31M|    this->chunks[0].template store_ascii_as_utf16<endian>(ptr +
  302|  1.31M|                                                          sizeof(simd8<T>) * 0);
  303|  1.31M|    this->chunks[1].template store_ascii_as_utf16<endian>(ptr +
  304|  1.31M|                                                          sizeof(simd8<T>) * 1);
  305|  1.31M|    this->chunks[2].template store_ascii_as_utf16<endian>(ptr +
  306|  1.31M|                                                          sizeof(simd8<T>) * 2);
  307|  1.31M|    this->chunks[3].template store_ascii_as_utf16<endian>(ptr +
  308|  1.31M|                                                          sizeof(simd8<T>) * 3);
  309|  1.31M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IaEEE20store_ascii_as_utf16ILNS_10endiannessE0EEEvPDs:
   20|  5.26M|  simdutf_really_inline void store_ascii_as_utf16(char16_t *p) const {
   21|  5.26M|    __m128i first = _mm_cvtepu8_epi16(*this);
   22|  5.26M|    __m128i second = _mm_cvtepu8_epi16(_mm_srli_si128(*this, 8));
   23|  5.26M|    if (big_endian) {
  ------------------
  |  Branch (23:9): [Folded, False: 5.26M]
  ------------------
   24|      0|      const __m128i swap =
   25|      0|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   26|      0|      first = _mm_shuffle_epi8(first, swap);
   27|      0|      second = _mm_shuffle_epi8(second, swap);
   28|      0|    }
   29|  5.26M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(p), first);
   30|  5.26M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(p + 8), second);
   31|  5.26M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IaE20store_ascii_as_utf16ILNS_10endiannessE1EEEvPDs:
  300|  1.37M|  simdutf_really_inline void store_ascii_as_utf16(char16_t *ptr) const {
  301|  1.37M|    this->chunks[0].template store_ascii_as_utf16<endian>(ptr +
  302|  1.37M|                                                          sizeof(simd8<T>) * 0);
  303|  1.37M|    this->chunks[1].template store_ascii_as_utf16<endian>(ptr +
  304|  1.37M|                                                          sizeof(simd8<T>) * 1);
  305|  1.37M|    this->chunks[2].template store_ascii_as_utf16<endian>(ptr +
  306|  1.37M|                                                          sizeof(simd8<T>) * 2);
  307|  1.37M|    this->chunks[3].template store_ascii_as_utf16<endian>(ptr +
  308|  1.37M|                                                          sizeof(simd8<T>) * 3);
  309|  1.37M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd4baseINS2_5simd8IaEEE20store_ascii_as_utf16ILNS_10endiannessE1EEEvPDs:
   20|  5.49M|  simdutf_really_inline void store_ascii_as_utf16(char16_t *p) const {
   21|  5.49M|    __m128i first = _mm_cvtepu8_epi16(*this);
   22|  5.49M|    __m128i second = _mm_cvtepu8_epi16(_mm_srli_si128(*this, 8));
   23|  5.49M|    if (big_endian) {
  ------------------
  |  Branch (23:9): [True: 5.49M, Folded]
  ------------------
   24|  5.49M|      const __m128i swap =
   25|  5.49M|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   26|  5.49M|      first = _mm_shuffle_epi8(first, swap);
   27|  5.49M|      second = _mm_shuffle_epi8(second, swap);
   28|  5.49M|    }
   29|  5.49M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(p), first);
   30|  5.49M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(p + 8), second);
   31|  5.49M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd12as_vector_u8ENS2_6simd32IjEE:
  370|  6.11k|simdutf_really_inline simd8<uint8_t> as_vector_u8(const simd32<uint32_t> v) {
  371|  6.11k|  return simd8<uint8_t>(v.value);
  372|  6.11k|}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd8simd8x64IaE2gtEa:
  333|   917k|  simdutf_really_inline uint64_t gt(const T m) const {
  334|   917k|    const simd8<T> mask = simd8<T>::splat(m);
  335|   917k|    return simd8x64<bool>(this->chunks[0] > mask, this->chunks[1] > mask,
  336|   917k|                          this->chunks[2] > mask, this->chunks[3] > mask)
  337|   917k|        .to_bitmask();
  338|   917k|  }

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd9simd16x32ItEC2EPKt:
  164|  2.32M|      : chunks{simd16<T>::load(ptr),
  165|  2.32M|               simd16<T>::load(ptr + sizeof(simd16<T>) / sizeof(T)),
  166|  2.32M|               simd16<T>::load(ptr + 2 * sizeof(simd16<T>) / sizeof(T)),
  167|  2.32M|               simd16<T>::load(ptr + 3 * sizeof(simd16<T>) / sizeof(T))} {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd14base16_numericItE4loadEPKt:
   47|  23.0M|  static simdutf_really_inline simd16<T> load(const T values[8]) {
   48|  23.0M|    return _mm_loadu_si128(reinterpret_cast<const __m128i *>(values));
   49|  23.0M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd16ItEC2EDv2_x:
   79|   104M|      : base16_numeric<uint16_t>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd14base16_numericItEC2EDv2_x:
   54|   104M|      : base16<T>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6base16ItNS2_6simd16IbEEEC2EDv2_x:
    8|   104M|      : base<simd16<T>>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd9simd16x32ItE10swap_bytesEv:
  200|  1.19M|  simdutf_really_inline void swap_bytes() {
  201|  1.19M|    this->chunks[0] = this->chunks[0].swap_bytes();
  202|  1.19M|    this->chunks[1] = this->chunks[1].swap_bytes();
  203|  1.19M|    this->chunks[2] = this->chunks[2].swap_bytes();
  204|  1.19M|    this->chunks[3] = this->chunks[3].swap_bytes();
  205|  1.19M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd6simd16ItE10swap_bytesEv:
  121|  6.48M|  simdutf_really_inline simd16<uint16_t> swap_bytes() const {
  122|  6.48M|    const __m128i swap =
  123|  6.48M|        _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  124|  6.48M|    return _mm_shuffle_epi8(*this, swap);
  125|  6.48M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd14base16_numericItE5splatEt:
   41|  22.0M|  static simdutf_really_inline simd16<T> splat(T _value) {
   42|  22.0M|    return _mm_set1_epi16(_value);
   43|  22.0M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simdeqENS2_6simd16ItEES4_:
   11|  13.0M|                                               const simd16<T> rhs) {
   12|  13.0M|    return _mm_cmpeq_epi16(lhs, rhs);
   13|  13.0M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd16IbEC2EDv2_x:
   28|  13.0M|  simdutf_really_inline simd16(const __m128i _value) : base16<bool>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6base16IbNS2_6simd16IbEEEC2EDv2_x:
    8|  13.0M|      : base<simd16<T>>(_value) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd9simd16x32IbEC2ENS2_6simd16IbEES6_S6_S6_:
  162|  2.32M|      : chunks{chunk0, chunk1, chunk2, chunk3} {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd9simd16x32IbE10to_bitmaskEv:
  192|  2.32M|  simdutf_really_inline uint64_t to_bitmask() const {
  193|  2.32M|    uint64_t r0 = uint32_t(this->chunks[0].to_bitmask());
  194|  2.32M|    uint64_t r1 = this->chunks[1].to_bitmask();
  195|  2.32M|    uint64_t r2 = this->chunks[2].to_bitmask();
  196|  2.32M|    uint64_t r3 = this->chunks[3].to_bitmask();
  197|  2.32M|    return r0 | (r1 << 16) | (r2 << 32) | (r3 << 48);
  198|  2.32M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd6simd16IbE10to_bitmaskEv:
   33|  9.31M|  simdutf_really_inline int to_bitmask() const {
   34|  9.31M|    return _mm_movemask_epi8(*this);
   35|  9.31M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd16ItEC2EPKDs:
   86|  9.96M|      : simd16(load(reinterpret_cast<const uint16_t *>(values))) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd6simd16ItE3shrILi8EEES4_v:
  116|  5.11M|  template <int N> simdutf_really_inline simd16<uint16_t> shr() const {
  117|  5.11M|    return simd16<uint16_t>(_mm_srli_epi16(*this, N));
  118|  5.11M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd16ItE4packERKS4_S6_:
  130|  4.98M|                                                   const simd16<uint16_t> &v1) {
  131|  4.98M|    return _mm_packus_epi16(v0, v1);
  132|  4.98M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd16ItEC2Et:
   82|  17.3M|  simdutf_really_inline simd16(uint16_t _value) : simd16(splat(_value)) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd9simd16x32ItE12not_in_rangeEtt:
  228|  2.32M|  simdutf_really_inline uint64_t not_in_range(const T low, const T high) const {
  229|  2.32M|    const T span = static_cast<T>(high - low);
  230|  2.32M|    if ((span & static_cast<T>(span + 1)) == 0 && (low & span) == 0) {
  ------------------
  |  Branch (230:9): [True: 2.32M, False: 0]
  |  Branch (230:51): [True: 2.32M, False: 0]
  ------------------
  231|       |      // Aligned power-of-two block, such as the surrogates: one AND and
  232|       |      // one compare, instead of a min/max and a compare per bound.
  233|  2.32M|      const simd16<T> keep = simd16<T>::splat(static_cast<T>(~span));
  234|  2.32M|      const simd16<T> base = simd16<T>::splat(low);
  235|  2.32M|      return ~simd16x32<bool>((this->chunks[0] & keep) == base,
  236|  2.32M|                              (this->chunks[1] & keep) == base,
  237|  2.32M|                              (this->chunks[2] & keep) == base,
  238|  2.32M|                              (this->chunks[3] & keep) == base)
  239|  2.32M|                  .to_bitmask();
  240|  2.32M|    }
  241|      0|    const simd16<T> mask_low = simd16<T>::splat(static_cast<T>(low - 1));
  242|      0|    const simd16<T> mask_high = simd16<T>::splat(static_cast<T>(high + 1));
  243|      0|    return simd16x32<bool>(
  244|      0|               (this->chunks[0] >= mask_high) | (this->chunks[0] <= mask_low),
  245|      0|               (this->chunks[1] >= mask_high) | (this->chunks[1] <= mask_low),
  246|      0|               (this->chunks[2] >= mask_high) | (this->chunks[2] <= mask_low),
  247|      0|               (this->chunks[3] >= mask_high) | (this->chunks[3] <= mask_low))
  248|      0|        .to_bitmask();
  249|  2.32M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd14base16_numericItE4zeroEv:
   45|  1.47k|  static simdutf_really_inline simd16<T> zero() { return _mm_setzero_si128(); }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd3minENS2_6simd16ItEES4_:
  253|  7.46M|simd16<uint16_t> min(const simd16<uint16_t> a, simd16<uint16_t> b) {
  254|  7.46M|  return _mm_min_epu16(a.value, b.value);
  255|  7.46M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd14base16_numericItEpLENS2_6simd16ItEE:
   68|  11.2M|  simdutf_really_inline simd16<T> &operator+=(const simd16<T> other) {
   69|  11.2M|    *this = *this + other;
   70|  11.2M|    return *static_cast<simd16<T> *>(this);
   71|  11.2M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd14base16_numericItEplENS2_6simd16ItEE:
   65|  11.2M|  simdutf_really_inline simd16<T> operator+(const simd16<T> other) const {
   66|  11.2M|    return _mm_add_epi16(*this, other);
   67|  11.2M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd6simd16ItE3sumEv:
  134|  1.47k|  simdutf_really_inline uint64_t sum() const {
  135|  1.47k|    const auto lo_u16 = _mm_and_si128(value, _mm_set1_epi32(0x0000ffff));
  136|  1.47k|    const auto hi_u16 = _mm_srli_epi32(value, 16);
  137|  1.47k|    const auto sum_u32 = _mm_add_epi32(lo_u16, hi_u16);
  138|       |
  139|  1.47k|    const auto lo_u32 = _mm_and_si128(sum_u32, _mm_set1_epi64x(0xffffffff));
  140|  1.47k|    const auto hi_u32 = _mm_srli_epi64(sum_u32, 32);
  141|  1.47k|    const auto sum_u64 = _mm_add_epi64(lo_u32, hi_u32);
  142|       |
  143|  1.47k|    return uint64_t(_mm_extract_epi64(sum_u64, 0)) +
  144|       |           uint64_t(_mm_extract_epi64(sum_u64, 1));
  145|  1.47k|  }

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd32IjE5splatEj:
   56|  25.7k|  simdutf_really_inline static simd32<uint32_t> splat(uint32_t v) {
   57|  25.7k|    return _mm_set1_epi32(v);
   58|  25.7k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd32IjEC2EDv2_x:
    9|  12.7M|  simdutf_really_inline simd32(const __m128i v) : value(v) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd32IjE4zeroEv:
   52|  5.20k|  simdutf_really_inline static simd32<uint32_t> zero() {
   53|  5.20k|    return _mm_setzero_si128();
   54|  5.20k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd32IjEC2IDiEEPKT_:
   13|  3.14M|      : value(_mm_loadu_si128(reinterpret_cast<const __m128i *>(ptr))) {}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd6simd32IjE10swap_bytesEv:
   22|  2.61M|  simdutf_really_inline simd32<uint32_t> swap_bytes() const {
   23|  2.61M|    const __m128i shuffle =
   24|  2.61M|        _mm_setr_epi8(3, 2, 1, 0, 7, 6, 5, 4, 8, 9, 10, 11, 15, 14, 13, 12);
   25|       |
   26|  2.61M|    return _mm_shuffle_epi8(value, shuffle);
   27|  2.61M|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd3maxENS2_6simd32IjEES4_:
   94|  4.24M|                                           const simd32<uint32_t> b) {
   95|  4.24M|  return _mm_max_epu32(a.value, b.value);
   96|  4.24M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simdplENS2_6simd32IjEES4_:
  119|  2.12M|                                                 const simd32<uint32_t> b) {
  120|  2.12M|  return _mm_add_epi32(a.value, b.value);
  121|  2.12M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simdgtENS2_6simd32IjEES4_:
  143|  12.9k|                                             const simd32<uint32_t> b) {
  144|  12.9k|  return !(b >= a);
  145|  12.9k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simdntENS2_6simd32IbEE:
  138|  12.9k|simdutf_really_inline simd32<bool> operator!(const simd32<bool> v) {
  139|  12.9k|  return _mm_xor_si128(v.value, _mm_set1_epi8(-1));
  140|  12.9k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd32IbEC2EDv2_x:
   69|  1.51M|  simdutf_really_inline simd32(const __m128i v) : value(v) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simdgeENS2_6simd32IjEES4_:
  134|   504k|                                              const simd32<uint32_t> b) {
  135|   504k|  return _mm_cmpeq_epi32(_mm_max_epu32(a.value, b.value), a.value);
  136|   504k|}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd6simd32IbE3anyEv:
   71|   497k|  simdutf_really_inline bool any() const {
   72|   497k|    return _mm_movemask_epi8(value) != 0;
   73|   497k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simdeqENS2_6simd32IjEES4_:
  129|   491k|                                              const simd32<uint32_t> b) {
  130|   491k|  return _mm_cmpeq_epi32(a.value, b.value);
  131|   491k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simdanENS2_6simd32IjEES4_:
  104|  2.08M|                                                 const simd32<uint32_t> b) {
  105|  2.08M|  return _mm_and_si128(a.value, b.value);
  106|  2.08M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simdorIbEENS2_6simd32IT_EES6_S6_:
   84|   497k|                                          const simd32<T> b) {
   85|   497k|  return _mm_or_si128(a.value, b.value);
   86|   497k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd3minENS2_6simd32IjEES4_:
   89|  1.59M|                                           const simd32<uint32_t> b) {
   90|  1.59M|  return _mm_min_epu32(a.value, b.value);
   91|  1.59M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd32IjEpLES4_:
   46|  1.59M|  simdutf_really_inline simd32 &operator+=(const simd32 other) {
   47|  1.59M|    value = _mm_add_epi32(value, other.value);
   48|  1.59M|    return *this;
   49|  1.59M|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd6simd32IjE3sumEv:
   15|    824|  simdutf_really_inline uint64_t sum() const {
   16|    824|    return uint64_t(_mm_extract_epi32(value, 0)) +
   17|    824|           uint64_t(_mm_extract_epi32(value, 1)) +
   18|    824|           uint64_t(_mm_extract_epi32(value, 2)) +
   19|       |           uint64_t(_mm_extract_epi32(value, 3));
   20|    824|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simdeqENS2_6simd32IjEEj:
   99|  6.11k|                                              uint32_t b) {
  100|  6.11k|  return _mm_cmpeq_epi32(a.value, _mm_set1_epi32(b));
  101|  6.11k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simdanENS2_6simd32IjEEj:
  109|  18.3k|                                                 uint32_t b) {
  110|  18.3k|  return _mm_and_si128(a.value, _mm_set1_epi32(b));
  111|  18.3k|}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd6simd32IbE15to_4bit_bitmaskEv:
   75|  6.11k|  simdutf_really_inline uint8_t to_4bit_bitmask() const {
   76|  6.11k|    return uint8_t(_mm_movemask_ps(_mm_castsi128_ps(value)));
   77|  6.11k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simdmiENS2_6simd32IjEEj:
  124|  6.11k|                                                 uint32_t b) {
  125|  6.11k|  return _mm_sub_epi32(a.value, _mm_set1_epi32(b));
  126|  6.11k|}
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd6simd32IjE3shrILi10EEES4_v:
   29|  6.11k|  template <int N> simdutf_really_inline simd32<uint32_t> shr() const {
   30|  6.11k|    return _mm_srli_epi32(value, N);
   31|  6.11k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd6simd32IjE3shlILi16EEES4_v:
   33|  6.11k|  template <int N> simdutf_really_inline simd32<uint32_t> shl() const {
   34|  6.11k|    return _mm_slli_epi32(value, N);
   35|  6.11k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simdorENS2_6simd32IjEEj:
  114|  6.11k|                                                 uint32_t b) {
  115|  6.11k|  return _mm_or_si128(a.value, _mm_set1_epi32(b));
  116|  6.11k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simdorIjEENS2_6simd32IT_EES6_S6_:
   84|  6.11k|                                          const simd32<T> b) {
   85|  6.11k|  return _mm_or_si128(a.value, b.value);
   86|  6.11k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6selectENS2_6simd32IbEENS3_IjEES5_:
  149|  6.11k|                                              const simd32<uint32_t> v_false) {
  150|  6.11k|  return _mm_blendv_epi8(v_false.value, v_true.value, cond.value);
  151|  6.11k|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd64ImE4zeroEv:
   26|  8.18k|  simdutf_really_inline static simd64<uint64_t> zero() {
   27|  8.18k|    return _mm_setzero_si128();
   28|  8.18k|  }
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd64ImEC2EDv2_x:
    9|   134k|  simdutf_really_inline simd64(const __m128i v) : value(v) {}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_14simd6simd64ImEpLES4_:
   20|   126k|  simdutf_really_inline simd64 &operator+=(const simd64 other) {
   21|   126k|    value = _mm_add_epi64(value, other.value);
   22|   126k|    return *this;
   23|   126k|  }
simdutf.cpp:_ZNK7simdutf8westmere12_GLOBAL__N_14simd6simd64ImE3sumEv:
   15|  8.18k|  simdutf_really_inline uint64_t sum() const {
   16|  8.18k|    return _mm_extract_epi64(value, 0) + _mm_extract_epi64(value, 1);
   17|  8.18k|  }

_ZNK7simdutf8westmere14implementation13validate_utf8EPKcm:
  180|  4.44k|implementation::validate_utf8(const char *buf, size_t len) const noexcept {
  181|  4.44k|  return aligned_split::all<validate_utf8_unsplit>(
  182|  4.44k|      buf, len, aligned_split::utf8_head(buf, len));
  183|  4.44k|}
_ZNK7simdutf8westmere14implementation25validate_utf8_with_errorsEPKcm:
  193|  4.44k|    const char *buf, size_t len) const noexcept {
  194|  4.44k|  return aligned_split::first_error<validate_utf8_with_errors_unsplit>(
  195|  4.44k|      buf, len, aligned_split::utf8_head(buf, len));
  196|  4.44k|}
_ZNK7simdutf8westmere14implementation16validate_utf16leEPKDsm:
  265|  1.28k|                                 size_t len) const noexcept {
  266|  1.28k|  return aligned_split::all<validate_utf16le_unsplit>(
  267|  1.28k|      buf, len, aligned_split::utf16_head<endianness::LITTLE>(buf, len));
  268|  1.28k|}
_ZNK7simdutf8westmere14implementation16validate_utf16beEPKDsm:
  294|  1.26k|                                 size_t len) const noexcept {
  295|  1.26k|  return aligned_split::all<validate_utf16be_unsplit>(
  296|  1.26k|      buf, len, aligned_split::utf16_head<endianness::BIG>(buf, len));
  297|  1.26k|}
_ZNK7simdutf8westmere14implementation28validate_utf16le_with_errorsEPKDsm:
  314|  1.28k|    const char16_t *buf, size_t len) const noexcept {
  315|  1.28k|  return aligned_split::first_error<validate_utf16le_with_errors_unsplit>(
  316|  1.28k|      buf, len, aligned_split::utf16_head<endianness::LITTLE>(buf, len));
  317|  1.28k|}
_ZNK7simdutf8westmere14implementation28validate_utf16be_with_errorsEPKDsm:
  333|  1.26k|    const char16_t *buf, size_t len) const noexcept {
  334|  1.26k|  return aligned_split::first_error<validate_utf16be_with_errors_unsplit>(
  335|  1.26k|      buf, len, aligned_split::utf16_head<endianness::BIG>(buf, len));
  336|  1.26k|}
_ZNK7simdutf8westmere14implementation14validate_utf32EPKDim:
  351|  2.21k|implementation::validate_utf32(const char32_t *buf, size_t len) const noexcept {
  352|  2.21k|  return utf32::validate(buf, len);
  353|  2.21k|}
_ZNK7simdutf8westmere14implementation26validate_utf32_with_errorsEPKDim:
  358|  2.21k|    const char32_t *buf, size_t len) const noexcept {
  359|  2.21k|  return utf32::validate_with_errors(buf, len);
  360|  2.21k|}
_ZNK7simdutf8westmere14implementation22convert_latin1_to_utf8EPKcmPc:
  365|    600|    const char *buf, size_t len, char *utf8_output) const noexcept {
  366|       |
  367|    600|  std::pair<const char *, char *> ret =
  368|    600|      sse_convert_latin1_to_utf8(buf, len, utf8_output);
  369|    600|  size_t converted_chars = ret.second - utf8_output;
  370|       |
  371|    600|  if (ret.first != buf + len) {
  ------------------
  |  Branch (371:7): [True: 482, False: 118]
  ------------------
  372|    482|    const size_t scalar_converted_chars = scalar::latin1_to_utf8::convert(
  373|    482|        ret.first, len - (ret.first - buf), ret.second);
  374|    482|    converted_chars += scalar_converted_chars;
  375|    482|  }
  376|       |
  377|    600|  return converted_chars;
  378|    600|}
_ZNK7simdutf8westmere14implementation25convert_latin1_to_utf16leEPKcmPDs:
  383|     98|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  384|     98|  std::pair<const char *, char16_t *> ret =
  385|     98|      sse_convert_latin1_to_utf16<endianness::LITTLE>(buf, len, utf16_output);
  386|     98|  if (ret.first == nullptr) {
  ------------------
  |  Branch (386:7): [True: 4, False: 94]
  ------------------
  387|      4|    return 0;
  388|      4|  }
  389|     94|  size_t converted_chars = ret.second - utf16_output;
  390|     94|  if (ret.first != buf + len) {
  ------------------
  |  Branch (390:7): [True: 78, False: 16]
  ------------------
  391|     78|    const size_t scalar_converted_chars =
  392|     78|        scalar::latin1_to_utf16::convert<endianness::LITTLE>(
  393|     78|            ret.first, len - (ret.first - buf), ret.second);
  394|     78|    if (scalar_converted_chars == 0) {
  ------------------
  |  Branch (394:9): [True: 0, False: 78]
  ------------------
  395|      0|      return 0;
  396|      0|    }
  397|     78|    converted_chars += scalar_converted_chars;
  398|     78|  }
  399|     94|  return converted_chars;
  400|     94|}
_ZNK7simdutf8westmere14implementation25convert_latin1_to_utf16beEPKcmPDs:
  403|     84|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  404|     84|  std::pair<const char *, char16_t *> ret =
  405|     84|      sse_convert_latin1_to_utf16<endianness::BIG>(buf, len, utf16_output);
  406|     84|  if (ret.first == nullptr) {
  ------------------
  |  Branch (406:7): [True: 4, False: 80]
  ------------------
  407|      4|    return 0;
  408|      4|  }
  409|     80|  size_t converted_chars = ret.second - utf16_output;
  410|     80|  if (ret.first != buf + len) {
  ------------------
  |  Branch (410:7): [True: 54, False: 26]
  ------------------
  411|     54|    const size_t scalar_converted_chars =
  412|     54|        scalar::latin1_to_utf16::convert<endianness::BIG>(
  413|     54|            ret.first, len - (ret.first - buf), ret.second);
  414|     54|    if (scalar_converted_chars == 0) {
  ------------------
  |  Branch (414:9): [True: 0, False: 54]
  ------------------
  415|      0|      return 0;
  416|      0|    }
  417|     54|    converted_chars += scalar_converted_chars;
  418|     54|  }
  419|     80|  return converted_chars;
  420|     80|}
_ZNK7simdutf8westmere14implementation23convert_latin1_to_utf32EPKcmPDi:
  425|     70|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  426|     70|  std::pair<const char *, char32_t *> ret =
  427|     70|      sse_convert_latin1_to_utf32(buf, len, utf32_output);
  428|     70|  if (ret.first == nullptr) {
  ------------------
  |  Branch (428:7): [True: 4, False: 66]
  ------------------
  429|      4|    return 0;
  430|      4|  }
  431|     66|  size_t converted_chars = ret.second - utf32_output;
  432|     66|  if (ret.first != buf + len) {
  ------------------
  |  Branch (432:7): [True: 52, False: 14]
  ------------------
  433|     52|    const size_t scalar_converted_chars = scalar::latin1_to_utf32::convert(
  434|     52|        ret.first, len - (ret.first - buf), ret.second);
  435|     52|    if (scalar_converted_chars == 0) {
  ------------------
  |  Branch (435:9): [True: 0, False: 52]
  ------------------
  436|      0|      return 0;
  437|      0|    }
  438|     52|    converted_chars += scalar_converted_chars;
  439|     52|  }
  440|     66|  return converted_chars;
  441|     66|}
_ZNK7simdutf8westmere14implementation22convert_utf8_to_latin1EPKcmPc:
  446|    662|    const char *buf, size_t len, char *latin1_output) const noexcept {
  447|    662|  utf8_to_latin1::validating_transcoder converter;
  448|    662|  return converter.convert(buf, len, latin1_output);
  449|    662|}
_ZNK7simdutf8westmere14implementation34convert_utf8_to_latin1_with_errorsEPKcmPc:
  452|    750|    const char *buf, size_t len, char *latin1_output) const noexcept {
  453|    750|  utf8_to_latin1::validating_transcoder converter;
  454|    750|  return converter.convert_with_errors(buf, len, latin1_output);
  455|    750|}
_ZNK7simdutf8westmere14implementation23convert_utf8_to_utf16leEPKcmPDs:
  465|    984|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  466|    984|  utf8_to_utf16::validating_transcoder converter;
  467|    984|  return converter.convert<endianness::LITTLE>(buf, len, utf16_output);
  468|    984|}
_ZNK7simdutf8westmere14implementation23convert_utf8_to_utf16beEPKcmPDs:
  471|    960|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  472|    960|  utf8_to_utf16::validating_transcoder converter;
  473|    960|  return converter.convert<endianness::BIG>(buf, len, utf16_output);
  474|    960|}
_ZNK7simdutf8westmere14implementation35convert_utf8_to_utf16le_with_errorsEPKcmPDs:
  477|    790|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  478|    790|  utf8_to_utf16::validating_transcoder converter;
  479|    790|  return converter.convert_with_errors<endianness::LITTLE>(buf, len,
  480|    790|                                                           utf16_output);
  481|    790|}
_ZNK7simdutf8westmere14implementation35convert_utf8_to_utf16be_with_errorsEPKcmPDs:
  484|    884|    const char *buf, size_t len, char16_t *utf16_output) const noexcept {
  485|    884|  utf8_to_utf16::validating_transcoder converter;
  486|    884|  return converter.convert_with_errors<endianness::BIG>(buf, len, utf16_output);
  487|    884|}
_ZNK7simdutf8westmere14implementation29convert_valid_utf8_to_utf16leEPKcmPDs:
  490|    528|    const char *input, size_t size, char16_t *utf16_output) const noexcept {
  491|    528|  return utf8_to_utf16::convert_valid<endianness::LITTLE>(input, size,
  492|    528|                                                          utf16_output);
  493|    528|}
_ZNK7simdutf8westmere14implementation29convert_valid_utf8_to_utf16beEPKcmPDs:
  496|    772|    const char *input, size_t size, char16_t *utf16_output) const noexcept {
  497|    772|  return utf8_to_utf16::convert_valid<endianness::BIG>(input, size,
  498|    772|                                                       utf16_output);
  499|    772|}
_ZNK7simdutf8westmere14implementation21convert_utf8_to_utf32EPKcmPDi:
  504|    920|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  505|    920|  utf8_to_utf32::validating_transcoder converter;
  506|    920|  return converter.convert(buf, len, utf32_output);
  507|    920|}
_ZNK7simdutf8westmere14implementation33convert_utf8_to_utf32_with_errorsEPKcmPDi:
  510|    946|    const char *buf, size_t len, char32_t *utf32_output) const noexcept {
  511|    946|  utf8_to_utf32::validating_transcoder converter;
  512|    946|  return converter.convert_with_errors(buf, len, utf32_output);
  513|    946|}
_ZNK7simdutf8westmere14implementation27convert_valid_utf8_to_utf32EPKcmPDi:
  516|    628|    const char *input, size_t size, char32_t *utf32_output) const noexcept {
  517|    628|  return utf8_to_utf32::convert_valid(input, size, utf32_output);
  518|    628|}
_ZNK7simdutf8westmere14implementation25convert_utf16le_to_latin1EPKDsmPc:
  523|    110|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  524|    110|  std::pair<const char16_t *, char *> ret =
  525|    110|      sse_convert_utf16_to_latin1<endianness::LITTLE>(buf, len, latin1_output);
  526|    110|  if (ret.first == nullptr) {
  ------------------
  |  Branch (526:7): [True: 38, False: 72]
  ------------------
  527|     38|    return 0;
  528|     38|  }
  529|     72|  size_t saved_bytes = ret.second - latin1_output;
  530|       |
  531|     72|  if (ret.first != buf + len) {
  ------------------
  |  Branch (531:7): [True: 54, False: 18]
  ------------------
  532|     54|    const size_t scalar_saved_bytes =
  533|     54|        scalar::utf16_to_latin1::convert<endianness::LITTLE>(
  534|     54|            ret.first, len - (ret.first - buf), ret.second);
  535|     54|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (535:9): [True: 32, False: 22]
  ------------------
  536|     32|      return 0;
  537|     32|    }
  538|     22|    saved_bytes += scalar_saved_bytes;
  539|     22|  }
  540|     40|  return saved_bytes;
  541|     72|}
_ZNK7simdutf8westmere14implementation25convert_utf16be_to_latin1EPKDsmPc:
  544|    126|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  545|    126|  std::pair<const char16_t *, char *> ret =
  546|    126|      sse_convert_utf16_to_latin1<endianness::BIG>(buf, len, latin1_output);
  547|    126|  if (ret.first == nullptr) {
  ------------------
  |  Branch (547:7): [True: 48, False: 78]
  ------------------
  548|     48|    return 0;
  549|     48|  }
  550|     78|  size_t saved_bytes = ret.second - latin1_output;
  551|       |
  552|     78|  if (ret.first != buf + len) {
  ------------------
  |  Branch (552:7): [True: 60, False: 18]
  ------------------
  553|     60|    const size_t scalar_saved_bytes =
  554|     60|        scalar::utf16_to_latin1::convert<endianness::BIG>(
  555|     60|            ret.first, len - (ret.first - buf), ret.second);
  556|     60|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (556:9): [True: 26, False: 34]
  ------------------
  557|     26|      return 0;
  558|     26|    }
  559|     34|    saved_bytes += scalar_saved_bytes;
  560|     34|  }
  561|     52|  return saved_bytes;
  562|     78|}
_ZNK7simdutf8westmere14implementation37convert_utf16le_to_latin1_with_errorsEPKDsmPc:
  566|    210|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  567|    210|  std::pair<result, char *> ret =
  568|    210|      sse_convert_utf16_to_latin1_with_errors<endianness::LITTLE>(
  569|    210|          buf, len, latin1_output);
  570|    210|  if (ret.first.error) {
  ------------------
  |  Branch (570:7): [True: 100, False: 110]
  ------------------
  571|    100|    return ret.first;
  572|    100|  } // Can return directly since scalar fallback already found correct
  573|       |    // ret.first.count
  574|    110|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (574:7): [True: 70, False: 40]
  ------------------
  575|     70|    result scalar_res =
  576|     70|        scalar::utf16_to_latin1::convert_with_errors<endianness::LITTLE>(
  577|     70|            buf + ret.first.count, len - ret.first.count, ret.second);
  578|     70|    if (scalar_res.error) {
  ------------------
  |  Branch (578:9): [True: 24, False: 46]
  ------------------
  579|     24|      scalar_res.count += ret.first.count;
  580|     24|      return scalar_res;
  581|     46|    } else {
  582|     46|      ret.second += scalar_res.count;
  583|     46|    }
  584|     70|  }
  585|     86|  ret.first.count =
  586|     86|      ret.second -
  587|     86|      latin1_output; // Set count to the number of 8-bit code units written
  588|     86|  return ret.first;
  589|    110|}
_ZNK7simdutf8westmere14implementation37convert_utf16be_to_latin1_with_errorsEPKDsmPc:
  593|    262|    const char16_t *buf, size_t len, char *latin1_output) const noexcept {
  594|    262|  std::pair<result, char *> ret =
  595|    262|      sse_convert_utf16_to_latin1_with_errors<endianness::BIG>(buf, len,
  596|    262|                                                               latin1_output);
  597|    262|  if (ret.first.error) {
  ------------------
  |  Branch (597:7): [True: 160, False: 102]
  ------------------
  598|    160|    return ret.first;
  599|    160|  } // Can return directly since scalar fallback already found correct
  600|       |    // ret.first.count
  601|    102|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (601:7): [True: 64, False: 38]
  ------------------
  602|     64|    result scalar_res =
  603|     64|        scalar::utf16_to_latin1::convert_with_errors<endianness::BIG>(
  604|     64|            buf + ret.first.count, len - ret.first.count, ret.second);
  605|     64|    if (scalar_res.error) {
  ------------------
  |  Branch (605:9): [True: 24, False: 40]
  ------------------
  606|     24|      scalar_res.count += ret.first.count;
  607|     24|      return scalar_res;
  608|     40|    } else {
  609|     40|      ret.second += scalar_res.count;
  610|     40|    }
  611|     64|  }
  612|     78|  ret.first.count =
  613|     78|      ret.second -
  614|     78|      latin1_output; // Set count to the number of 8-bit code units written
  615|     78|  return ret.first;
  616|    102|}
_ZNK7simdutf8westmere14implementation23convert_utf16le_to_utf8EPKDsmPc:
  633|    802|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  634|    802|  std::pair<const char16_t *, char *> ret =
  635|    802|      sse_convert_utf16_to_utf8<endianness::LITTLE>(buf, len, utf8_output);
  636|    802|  if (ret.first == nullptr) {
  ------------------
  |  Branch (636:7): [True: 96, False: 706]
  ------------------
  637|     96|    return 0;
  638|     96|  }
  639|    706|  size_t saved_bytes = ret.second - utf8_output;
  640|    706|  if (ret.first != buf + len) {
  ------------------
  |  Branch (640:7): [True: 704, False: 2]
  ------------------
  641|    704|    const size_t scalar_saved_bytes =
  642|    704|        scalar::utf16_to_utf8::convert<endianness::LITTLE>(
  643|    704|            ret.first, len - (ret.first - buf), ret.second);
  644|    704|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (644:9): [True: 82, False: 622]
  ------------------
  645|     82|      return 0;
  646|     82|    }
  647|    622|    saved_bytes += scalar_saved_bytes;
  648|    622|  }
  649|    624|  return saved_bytes;
  650|    706|}
_ZNK7simdutf8westmere14implementation23convert_utf16be_to_utf8EPKDsmPc:
  653|    740|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  654|    740|  std::pair<const char16_t *, char *> ret =
  655|    740|      sse_convert_utf16_to_utf8<endianness::BIG>(buf, len, utf8_output);
  656|    740|  if (ret.first == nullptr) {
  ------------------
  |  Branch (656:7): [True: 62, False: 678]
  ------------------
  657|     62|    return 0;
  658|     62|  }
  659|    678|  size_t saved_bytes = ret.second - utf8_output;
  660|    678|  if (ret.first != buf + len) {
  ------------------
  |  Branch (660:7): [True: 676, False: 2]
  ------------------
  661|    676|    const size_t scalar_saved_bytes =
  662|    676|        scalar::utf16_to_utf8::convert<endianness::BIG>(
  663|    676|            ret.first, len - (ret.first - buf), ret.second);
  664|    676|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (664:9): [True: 68, False: 608]
  ------------------
  665|     68|      return 0;
  666|     68|    }
  667|    608|    saved_bytes += scalar_saved_bytes;
  668|    608|  }
  669|    610|  return saved_bytes;
  670|    678|}
_ZNK7simdutf8westmere14implementation35convert_utf16le_to_utf8_with_errorsEPKDsmPc:
  694|    628|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  695|    628|  return convert_utf16_to_utf8_with_details<endianness::LITTLE>(buf, len,
  696|    628|                                                                utf8_output);
  697|    628|}
_ZNK7simdutf8westmere14implementation35convert_utf16be_to_utf8_with_errorsEPKDsmPc:
  700|    540|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  701|    540|  return convert_utf16_to_utf8_with_details<endianness::BIG>(buf, len,
  702|    540|                                                             utf8_output);
  703|    540|}
_ZNK7simdutf8westmere14implementation29convert_valid_utf16le_to_utf8EPKDsmPc:
  706|    410|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  707|    410|  return convert_utf16le_to_utf8(buf, len, utf8_output);
  708|    410|}
_ZNK7simdutf8westmere14implementation29convert_valid_utf16be_to_utf8EPKDsmPc:
  711|    430|    const char16_t *buf, size_t len, char *utf8_output) const noexcept {
  712|    430|  return convert_utf16be_to_utf8(buf, len, utf8_output);
  713|    430|}
_ZNK7simdutf8westmere14implementation23convert_utf32_to_latin1EPKDimPc:
  718|    190|    const char32_t *buf, size_t len, char *latin1_output) const noexcept {
  719|    190|  std::pair<const char32_t *, char *> ret =
  720|    190|      sse_convert_utf32_to_latin1(buf, len, latin1_output);
  721|    190|  if (ret.first == nullptr) {
  ------------------
  |  Branch (721:7): [True: 58, False: 132]
  ------------------
  722|     58|    return 0;
  723|     58|  }
  724|    132|  size_t saved_bytes = ret.second - latin1_output;
  725|       |  // if (ret.first != buf + len) {
  726|    132|  if (ret.first < buf + len) {
  ------------------
  |  Branch (726:7): [True: 114, False: 18]
  ------------------
  727|    114|    const size_t scalar_saved_bytes = scalar::utf32_to_latin1::convert(
  728|    114|        ret.first, len - (ret.first - buf), ret.second);
  729|    114|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (729:9): [True: 92, False: 22]
  ------------------
  730|     92|      return 0;
  731|     92|    }
  732|     22|    saved_bytes += scalar_saved_bytes;
  733|     22|  }
  734|     40|  return saved_bytes;
  735|    132|}
_ZNK7simdutf8westmere14implementation35convert_utf32_to_latin1_with_errorsEPKDimPc:
  738|    344|    const char32_t *buf, size_t len, char *latin1_output) const noexcept {
  739|       |  // ret.first.count is always the position in the buffer, not the number of
  740|       |  // code units written even if finished
  741|    344|  std::pair<result, char *> ret =
  742|    344|      westmere::sse_convert_utf32_to_latin1_with_errors(buf, len,
  743|    344|                                                        latin1_output);
  744|    344|  if (ret.first.count != len) {
  ------------------
  |  Branch (744:7): [True: 322, False: 22]
  ------------------
  745|    322|    result scalar_res = scalar::utf32_to_latin1::convert_with_errors(
  746|    322|        buf + ret.first.count, len - ret.first.count, ret.second);
  747|    322|    if (scalar_res.error) {
  ------------------
  |  Branch (747:9): [True: 294, False: 28]
  ------------------
  748|    294|      scalar_res.count += ret.first.count;
  749|    294|      return scalar_res;
  750|    294|    } else {
  751|     28|      ret.second += scalar_res.count;
  752|     28|    }
  753|    322|  }
  754|     50|  ret.first.count =
  755|     50|      ret.second -
  756|     50|      latin1_output; // Set count to the number of 8-bit code units written
  757|     50|  return ret.first;
  758|    344|}
_ZNK7simdutf8westmere14implementation21convert_utf32_to_utf8EPKDimPc:
  769|    786|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
  770|    786|  std::pair<const char32_t *, char *> ret =
  771|    786|      sse_convert_utf32_to_utf8(buf, len, utf8_output);
  772|    786|  if (ret.first == nullptr) {
  ------------------
  |  Branch (772:7): [True: 244, False: 542]
  ------------------
  773|    244|    return 0;
  774|    244|  }
  775|    542|  size_t saved_bytes = ret.second - utf8_output;
  776|    542|  if (ret.first != buf + len) {
  ------------------
  |  Branch (776:7): [True: 540, False: 2]
  ------------------
  777|    540|    const size_t scalar_saved_bytes = scalar::utf32_to_utf8::convert(
  778|    540|        ret.first, len - (ret.first - buf), ret.second);
  779|    540|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (779:9): [True: 260, False: 280]
  ------------------
  780|    260|      return 0;
  781|    260|    }
  782|    280|    saved_bytes += scalar_saved_bytes;
  783|    280|  }
  784|    282|  return saved_bytes;
  785|    542|}
_ZNK7simdutf8westmere14implementation33convert_utf32_to_utf8_with_errorsEPKDimPc:
  788|    772|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
  789|       |  // ret.first.count is always the position in the buffer, not the number of
  790|       |  // code units written even if finished
  791|    772|  std::pair<result, char *> ret =
  792|    772|      westmere::sse_convert_utf32_to_utf8_with_errors(buf, len, utf8_output);
  793|    772|  if (ret.first.count != len) {
  ------------------
  |  Branch (793:7): [True: 768, False: 4]
  ------------------
  794|    768|    result scalar_res = scalar::utf32_to_utf8::convert_with_errors(
  795|    768|        buf + ret.first.count, len - ret.first.count, ret.second);
  796|    768|    if (scalar_res.error) {
  ------------------
  |  Branch (796:9): [True: 560, False: 208]
  ------------------
  797|    560|      scalar_res.count += ret.first.count;
  798|    560|      return scalar_res;
  799|    560|    } else {
  800|    208|      ret.second += scalar_res.count;
  801|    208|    }
  802|    768|  }
  803|    212|  ret.first.count =
  804|    212|      ret.second -
  805|    212|      utf8_output; // Set count to the number of 8-bit code units written
  806|    212|  return ret.first;
  807|    772|}
_ZNK7simdutf8westmere14implementation24convert_utf16le_to_utf32EPKDsmPDi:
  812|    380|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  813|    380|  std::pair<const char16_t *, char32_t *> ret =
  814|    380|      sse_convert_utf16_to_utf32<endianness::LITTLE>(buf, len, utf32_output);
  815|    380|  if (ret.first == nullptr) {
  ------------------
  |  Branch (815:7): [True: 116, False: 264]
  ------------------
  816|    116|    return 0;
  817|    116|  }
  818|    264|  size_t saved_bytes = ret.second - utf32_output;
  819|    264|  if (ret.first != buf + len) {
  ------------------
  |  Branch (819:7): [True: 200, False: 64]
  ------------------
  820|    200|    const size_t scalar_saved_bytes =
  821|    200|        scalar::utf16_to_utf32::convert<endianness::LITTLE>(
  822|    200|            ret.first, len - (ret.first - buf), ret.second);
  823|    200|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (823:9): [True: 54, False: 146]
  ------------------
  824|     54|      return 0;
  825|     54|    }
  826|    146|    saved_bytes += scalar_saved_bytes;
  827|    146|  }
  828|    210|  return saved_bytes;
  829|    264|}
_ZNK7simdutf8westmere14implementation24convert_utf16be_to_utf32EPKDsmPDi:
  832|    394|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  833|    394|  std::pair<const char16_t *, char32_t *> ret =
  834|    394|      sse_convert_utf16_to_utf32<endianness::BIG>(buf, len, utf32_output);
  835|    394|  if (ret.first == nullptr) {
  ------------------
  |  Branch (835:7): [True: 126, False: 268]
  ------------------
  836|    126|    return 0;
  837|    126|  }
  838|    268|  size_t saved_bytes = ret.second - utf32_output;
  839|    268|  if (ret.first != buf + len) {
  ------------------
  |  Branch (839:7): [True: 198, False: 70]
  ------------------
  840|    198|    const size_t scalar_saved_bytes =
  841|    198|        scalar::utf16_to_utf32::convert<endianness::BIG>(
  842|    198|            ret.first, len - (ret.first - buf), ret.second);
  843|    198|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (843:9): [True: 40, False: 158]
  ------------------
  844|     40|      return 0;
  845|     40|    }
  846|    158|    saved_bytes += scalar_saved_bytes;
  847|    158|  }
  848|    228|  return saved_bytes;
  849|    268|}
_ZNK7simdutf8westmere14implementation36convert_utf16le_to_utf32_with_errorsEPKDsmPDi:
  852|    396|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  853|       |  // ret.first.count is always the position in the buffer, not the number of
  854|       |  // code units written even if finished
  855|    396|  std::pair<result, char32_t *> ret =
  856|    396|      westmere::sse_convert_utf16_to_utf32_with_errors<endianness::LITTLE>(
  857|    396|          buf, len, utf32_output);
  858|    396|  if (ret.first.error) {
  ------------------
  |  Branch (858:7): [True: 170, False: 226]
  ------------------
  859|    170|    return ret.first;
  860|    170|  } // Can return directly since scalar fallback already found correct
  861|       |    // ret.first.count
  862|    226|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (862:7): [True: 184, False: 42]
  ------------------
  863|    184|    result scalar_res =
  864|    184|        scalar::utf16_to_utf32::convert_with_errors<endianness::LITTLE>(
  865|    184|            buf + ret.first.count, len - ret.first.count, ret.second);
  866|    184|    if (scalar_res.error) {
  ------------------
  |  Branch (866:9): [True: 64, False: 120]
  ------------------
  867|     64|      scalar_res.count += ret.first.count;
  868|     64|      return scalar_res;
  869|    120|    } else {
  870|    120|      ret.second += scalar_res.count;
  871|    120|    }
  872|    184|  }
  873|    162|  ret.first.count =
  874|    162|      ret.second -
  875|    162|      utf32_output; // Set count to the number of 8-bit code units written
  876|    162|  return ret.first;
  877|    226|}
_ZNK7simdutf8westmere14implementation36convert_utf16be_to_utf32_with_errorsEPKDsmPDi:
  880|    380|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
  881|       |  // ret.first.count is always the position in the buffer, not the number of
  882|       |  // code units written even if finished
  883|    380|  std::pair<result, char32_t *> ret =
  884|    380|      westmere::sse_convert_utf16_to_utf32_with_errors<endianness::BIG>(
  885|    380|          buf, len, utf32_output);
  886|    380|  if (ret.first.error) {
  ------------------
  |  Branch (886:7): [True: 170, False: 210]
  ------------------
  887|    170|    return ret.first;
  888|    170|  } // Can return directly since scalar fallback already found correct
  889|       |    // ret.first.count
  890|    210|  if (ret.first.count != len) { // All good so far, but not finished
  ------------------
  |  Branch (890:7): [True: 174, False: 36]
  ------------------
  891|    174|    result scalar_res =
  892|    174|        scalar::utf16_to_utf32::convert_with_errors<endianness::BIG>(
  893|    174|            buf + ret.first.count, len - ret.first.count, ret.second);
  894|    174|    if (scalar_res.error) {
  ------------------
  |  Branch (894:9): [True: 60, False: 114]
  ------------------
  895|     60|      scalar_res.count += ret.first.count;
  896|     60|      return scalar_res;
  897|    114|    } else {
  898|    114|      ret.second += scalar_res.count;
  899|    114|    }
  900|    174|  }
  901|    150|  ret.first.count =
  902|    150|      ret.second -
  903|    150|      utf32_output; // Set count to the number of 8-bit code units written
  904|    150|  return ret.first;
  905|    210|}
_ZNK7simdutf8westmere14implementation27convert_valid_utf32_to_utf8EPKDimPc:
  910|    202|    const char32_t *buf, size_t len, char *utf8_output) const noexcept {
  911|    202|  return convert_utf32_to_utf8(buf, len, utf8_output);
  912|    202|}
_ZNK7simdutf8westmere14implementation24convert_utf32_to_utf16leEPKDimPDs:
  917|    644|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  918|    644|  std::pair<const char32_t *, char16_t *> ret =
  919|    644|      sse_convert_utf32_to_utf16<endianness::LITTLE>(buf, len, utf16_output);
  920|    644|  if (ret.first == nullptr) {
  ------------------
  |  Branch (920:7): [True: 68, False: 576]
  ------------------
  921|     68|    return 0;
  922|     68|  }
  923|    576|  size_t saved_bytes = ret.second - utf16_output;
  924|    576|  if (ret.first != buf + len) {
  ------------------
  |  Branch (924:7): [True: 572, False: 4]
  ------------------
  925|    572|    const size_t scalar_saved_bytes =
  926|    572|        scalar::utf32_to_utf16::convert<endianness::LITTLE>(
  927|    572|            ret.first, len - (ret.first - buf), ret.second);
  928|    572|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (928:9): [True: 242, False: 330]
  ------------------
  929|    242|      return 0;
  930|    242|    }
  931|    330|    saved_bytes += scalar_saved_bytes;
  932|    330|  }
  933|    334|  return saved_bytes;
  934|    576|}
_ZNK7simdutf8westmere14implementation24convert_utf32_to_utf16beEPKDimPDs:
  937|    462|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  938|    462|  std::pair<const char32_t *, char16_t *> ret =
  939|    462|      sse_convert_utf32_to_utf16<endianness::BIG>(buf, len, utf16_output);
  940|    462|  if (ret.first == nullptr) {
  ------------------
  |  Branch (940:7): [True: 32, False: 430]
  ------------------
  941|     32|    return 0;
  942|     32|  }
  943|    430|  size_t saved_bytes = ret.second - utf16_output;
  944|    430|  if (ret.first != buf + len) {
  ------------------
  |  Branch (944:7): [True: 428, False: 2]
  ------------------
  945|    428|    const size_t scalar_saved_bytes =
  946|    428|        scalar::utf32_to_utf16::convert<endianness::BIG>(
  947|    428|            ret.first, len - (ret.first - buf), ret.second);
  948|    428|    if (scalar_saved_bytes == 0) {
  ------------------
  |  Branch (948:9): [True: 216, False: 212]
  ------------------
  949|    216|      return 0;
  950|    216|    }
  951|    212|    saved_bytes += scalar_saved_bytes;
  952|    212|  }
  953|    214|  return saved_bytes;
  954|    430|}
_ZNK7simdutf8westmere14implementation36convert_utf32_to_utf16le_with_errorsEPKDimPDs:
  957|    622|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  958|       |  // ret.first.count is always the position in the buffer, not the number of
  959|       |  // code units written even if finished
  960|    622|  std::pair<result, char16_t *> ret =
  961|    622|      westmere::sse_convert_utf32_to_utf16_with_errors<endianness::LITTLE>(
  962|    622|          buf, len, utf16_output);
  963|    622|  if (ret.first.count != len) {
  ------------------
  |  Branch (963:7): [True: 600, False: 22]
  ------------------
  964|    600|    result scalar_res =
  965|    600|        scalar::utf32_to_utf16::convert_with_errors<endianness::LITTLE>(
  966|    600|            buf + ret.first.count, len - ret.first.count, ret.second);
  967|    600|    if (scalar_res.error) {
  ------------------
  |  Branch (967:9): [True: 440, False: 160]
  ------------------
  968|    440|      scalar_res.count += ret.first.count;
  969|    440|      return scalar_res;
  970|    440|    } else {
  971|    160|      ret.second += scalar_res.count;
  972|    160|    }
  973|    600|  }
  974|    182|  ret.first.count =
  975|    182|      ret.second -
  976|    182|      utf16_output; // Set count to the number of 8-bit code units written
  977|    182|  return ret.first;
  978|    622|}
_ZNK7simdutf8westmere14implementation36convert_utf32_to_utf16be_with_errorsEPKDimPDs:
  981|    570|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
  982|       |  // ret.first.count is always the position in the buffer, not the number of
  983|       |  // code units written even if finished
  984|    570|  std::pair<result, char16_t *> ret =
  985|    570|      westmere::sse_convert_utf32_to_utf16_with_errors<endianness::BIG>(
  986|    570|          buf, len, utf16_output);
  987|    570|  if (ret.first.count != len) {
  ------------------
  |  Branch (987:7): [True: 548, False: 22]
  ------------------
  988|    548|    result scalar_res =
  989|    548|        scalar::utf32_to_utf16::convert_with_errors<endianness::BIG>(
  990|    548|            buf + ret.first.count, len - ret.first.count, ret.second);
  991|    548|    if (scalar_res.error) {
  ------------------
  |  Branch (991:9): [True: 416, False: 132]
  ------------------
  992|    416|      scalar_res.count += ret.first.count;
  993|    416|      return scalar_res;
  994|    416|    } else {
  995|    132|      ret.second += scalar_res.count;
  996|    132|    }
  997|    548|  }
  998|    154|  ret.first.count =
  999|    154|      ret.second -
 1000|    154|      utf16_output; // Set count to the number of 8-bit code units written
 1001|    154|  return ret.first;
 1002|    570|}
_ZNK7simdutf8westmere14implementation30convert_valid_utf32_to_utf16leEPKDimPDs:
 1005|    222|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
 1006|    222|  return convert_utf32_to_utf16le(buf, len, utf16_output);
 1007|    222|}
_ZNK7simdutf8westmere14implementation30convert_valid_utf32_to_utf16beEPKDimPDs:
 1010|     72|    const char32_t *buf, size_t len, char16_t *utf16_output) const noexcept {
 1011|     72|  return convert_utf32_to_utf16be(buf, len, utf16_output);
 1012|     72|}
_ZNK7simdutf8westmere14implementation30convert_valid_utf16le_to_utf32EPKDsmPDi:
 1015|    108|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
 1016|    108|  return convert_utf16le_to_utf32(buf, len, utf32_output);
 1017|    108|}
_ZNK7simdutf8westmere14implementation30convert_valid_utf16be_to_utf32EPKDsmPDi:
 1020|    142|    const char16_t *buf, size_t len, char32_t *utf32_output) const noexcept {
 1021|    142|  return convert_utf16be_to_utf32(buf, len, utf32_output);
 1022|    142|}
_ZNK7simdutf8westmere14implementation13count_utf16leEPKDsm:
 1033|  1.28k|    const char16_t *input, size_t length) const noexcept {
 1034|  1.28k|  return utf16::count_code_points<endianness::LITTLE>(input, length);
 1035|  1.28k|}
_ZNK7simdutf8westmere14implementation13count_utf16beEPKDsm:
 1038|  1.26k|    const char16_t *input, size_t length) const noexcept {
 1039|  1.26k|  return utf16::count_code_points<endianness::BIG>(input, length);
 1040|  1.26k|}
_ZNK7simdutf8westmere14implementation10count_utf8EPKcm:
 1050|  5.14k|implementation::count_utf8(const char *input, size_t length) const noexcept {
 1051|  5.14k|  return aligned_split::sum<count_utf8_unsplit>(
 1052|  5.14k|      input, length, aligned_split::head(input, length));
 1053|  5.14k|}
_ZNK7simdutf8westmere14implementation23latin1_length_from_utf8EPKcm:
 1069|    706|    const char *buf, size_t len) const noexcept {
 1070|    706|  return count_utf8(buf, len);
 1071|    706|}
_ZNK7simdutf8westmere14implementation24utf8_length_from_utf16leEPKDsm:
 1076|    729|    const char16_t *input, size_t length) const noexcept {
 1077|    729|  return utf16::utf8_length_from_utf16_bytemask<endianness::LITTLE>(input,
 1078|    729|                                                                    length);
 1079|    729|}
_ZNK7simdutf8westmere14implementation24utf8_length_from_utf16beEPKDsm:
 1082|    657|    const char16_t *input, size_t length) const noexcept {
 1083|    657|  return utf16::utf8_length_from_utf16_bytemask<endianness::BIG>(input, length);
 1084|    657|}
_ZNK7simdutf8westmere14implementation23utf8_length_from_latin1EPKcm:
 1149|    300|    const char *input, size_t len) const noexcept {
 1150|    300|  return aligned_split::sum<utf8_length_from_latin1_unsplit>(
 1151|    300|      input, len, aligned_split::head(input, len));
 1152|    300|}
_ZNK7simdutf8westmere14implementation25utf32_length_from_utf16leEPKDsm:
 1157|    394|    const char16_t *input, size_t length) const noexcept {
 1158|    394|  return utf16::utf32_length_from_utf16<endianness::LITTLE>(input, length);
 1159|    394|}
_ZNK7simdutf8westmere14implementation25utf32_length_from_utf16beEPKDsm:
 1162|    415|    const char16_t *input, size_t length) const noexcept {
 1163|    415|  return utf16::utf32_length_from_utf16<endianness::BIG>(input, length);
 1164|    415|}
_ZNK7simdutf8westmere14implementation22utf16_length_from_utf8EPKcm:
 1169|  2.48k|    const char *input, size_t length) const noexcept {
 1170|  2.48k|  return utf8::utf16_length_from_utf8_bytemask(input, length);
 1171|  2.48k|}
_ZNK7simdutf8westmere14implementation22utf8_length_from_utf32EPKDim:
 1210|    786|    const char32_t *input, size_t length) const noexcept {
 1211|    786|  return utf32::utf8_length_from_utf32(input, length);
 1212|    786|}
_ZNK7simdutf8westmere14implementation23utf16_length_from_utf32EPKDim:
 1217|  1.15k|    const char32_t *input, size_t length) const noexcept {
 1218|  1.15k|  const __m128i v_00000000 = _mm_setzero_si128();
 1219|  1.15k|  const __m128i v_ffff0000 = _mm_set1_epi32((uint32_t)0xffff0000);
 1220|  1.15k|  size_t pos = 0;
 1221|  1.15k|  size_t count = 0;
 1222|   985k|  for (; pos + 4 <= length; pos += 4) {
  ------------------
  |  Branch (1222:10): [True: 984k, False: 1.15k]
  ------------------
 1223|   984k|    __m128i in = _mm_loadu_si128((__m128i *)(input + pos));
 1224|   984k|    const __m128i surrogate_bytemask =
 1225|   984k|        _mm_cmpeq_epi32(_mm_and_si128(in, v_ffff0000), v_00000000);
 1226|   984k|    const uint16_t surrogate_bitmask =
 1227|   984k|        static_cast<uint16_t>(_mm_movemask_epi8(surrogate_bytemask));
 1228|   984k|    size_t surrogate_count = (16 - count_ones(surrogate_bitmask)) / 4;
 1229|   984k|    count += 4 + surrogate_count;
 1230|   984k|  }
 1231|  1.15k|  return count +
 1232|  1.15k|         scalar::utf32::utf16_length_from_utf32(input + pos, length - pos);
 1233|  1.15k|}
_ZNK7simdutf8westmere14implementation22utf32_length_from_utf8EPKcm:
 1243|  1.25k|    const char *input, size_t length) const noexcept {
 1244|  1.25k|  return aligned_split::sum<utf32_length_from_utf8_unsplit>(
 1245|  1.25k|      input, length, aligned_split::head(input, length));
 1246|  1.25k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_18is_asciiERKNS1_4simd8simd8x64IhEE:
   12|  5.78M|simdutf_really_inline bool is_ascii(const simd8x64<uint8_t> &input) {
   13|  5.78M|  return input.reduce_or().is_ascii();
   14|  5.78M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_124must_be_2_3_continuationENS1_4simd5simd8IhEES4_:
   20|  6.29M|                         const simd8<uint8_t> prev3) {
   21|  6.29M|  simd8<uint8_t> is_third_byte =
   22|  6.29M|      prev2.saturating_sub(0xe0u - 0x80); // Only 111_____ will be >= 0x80
   23|  6.29M|  simd8<uint8_t> is_fourth_byte =
   24|  6.29M|      prev3.saturating_sub(0xf0u - 0x80); // Only 1111____ will be >= 0x80
   25|  6.29M|  return simd8<bool>(is_third_byte | is_fourth_byte);
   26|  6.29M|}
_ZN7simdutf8westmere21validate_utf8_unsplitEPKcm:
  175|  4.89k|                                                 size_t len) noexcept {
  176|  4.89k|  return westmere::utf8_validation::generic_validate_utf8(buf, len);
  177|  4.89k|}
_ZN7simdutf8westmere33validate_utf8_with_errors_unsplitEPKcm:
  188|  4.89k|validate_utf8_with_errors_unsplit(const char *buf, size_t len) noexcept {
  189|  4.89k|  return westmere::utf8_validation::generic_validate_utf8_with_errors(buf, len);
  190|  4.89k|}
_ZN7simdutf8westmere24validate_utf16le_unsplitEPKDsm:
  244|  1.37k|                                                    size_t len) noexcept {
  245|  1.37k|  if (simdutf_unlikely(len == 0)) {
  ------------------
  |  |   93|  1.37k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 15, False: 1.36k]
  |  |  ------------------
  ------------------
  246|       |    // empty input is valid UTF-16. protect the implementation from
  247|       |    // handling nullptr
  248|     15|    return true;
  249|     15|  }
  250|  1.36k|  const auto res =
  251|  1.36k|      westmere::utf16::validate_utf16_with_errors<endianness::LITTLE>(buf, len);
  252|  1.36k|  if (res.is_err()) {
  ------------------
  |  Branch (252:7): [True: 279, False: 1.08k]
  ------------------
  253|    279|    return false;
  254|    279|  }
  255|       |
  256|  1.08k|  if (res.count == len)
  ------------------
  |  Branch (256:7): [True: 139, False: 942]
  ------------------
  257|    139|    return true;
  258|       |
  259|    942|  return scalar::utf16::validate<endianness::LITTLE>(buf + res.count,
  260|    942|                                                     len - res.count);
  261|  1.08k|}
_ZN7simdutf8westmere24validate_utf16be_unsplitEPKDsm:
  273|  1.36k|                                                    size_t len) noexcept {
  274|  1.36k|  if (simdutf_unlikely(len == 0)) {
  ------------------
  |  |   93|  1.36k|    #define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (93:33): [True: 16, False: 1.34k]
  |  |  ------------------
  ------------------
  275|       |    // empty input is valid UTF-16. protect the implementation from
  276|       |    // handling nullptr
  277|     16|    return true;
  278|     16|  }
  279|  1.34k|  const auto res =
  280|  1.34k|      westmere::utf16::validate_utf16_with_errors<endianness::BIG>(buf, len);
  281|  1.34k|  if (res.is_err()) {
  ------------------
  |  Branch (281:7): [True: 284, False: 1.06k]
  ------------------
  282|    284|    return false;
  283|    284|  }
  284|       |
  285|  1.06k|  if (res.count == len)
  ------------------
  |  Branch (285:7): [True: 158, False: 905]
  ------------------
  286|    158|    return true;
  287|       |
  288|    905|  return scalar::utf16::validate<endianness::BIG>(buf + res.count,
  289|    905|                                                  len - res.count);
  290|  1.06k|}
_ZN7simdutf8westmere36validate_utf16le_with_errors_unsplitEPKDsm:
  300|  1.37k|validate_utf16le_with_errors_unsplit(const char16_t *buf, size_t len) noexcept {
  301|  1.37k|  const result res =
  302|  1.37k|      westmere::utf16::validate_utf16_with_errors<endianness::LITTLE>(buf, len);
  303|  1.37k|  if (res.count != len) {
  ------------------
  |  Branch (303:7): [True: 1.22k, False: 154]
  ------------------
  304|  1.22k|    const result scalar_res =
  305|  1.22k|        scalar::utf16::validate_with_errors<endianness::LITTLE>(
  306|  1.22k|            buf + res.count, len - res.count);
  307|  1.22k|    return result(scalar_res.error, res.count + scalar_res.count);
  308|  1.22k|  } else {
  309|    154|    return res;
  310|    154|  }
  311|  1.37k|}
_ZN7simdutf8westmere36validate_utf16be_with_errors_unsplitEPKDsm:
  320|  1.36k|validate_utf16be_with_errors_unsplit(const char16_t *buf, size_t len) noexcept {
  321|  1.36k|  const result res =
  322|  1.36k|      westmere::utf16::validate_utf16_with_errors<endianness::BIG>(buf, len);
  323|  1.36k|  if (res.count != len) {
  ------------------
  |  Branch (323:7): [True: 1.18k, False: 174]
  ------------------
  324|  1.18k|    result scalar_res = scalar::utf16::validate_with_errors<endianness::BIG>(
  325|  1.18k|        buf + res.count, len - res.count);
  326|  1.18k|    return result(scalar_res.error, res.count + scalar_res.count);
  327|  1.18k|  } else {
  328|    174|    return res;
  329|    174|  }
  330|  1.36k|}
_ZN7simdutf8westmere34convert_utf16_to_utf8_with_detailsILNS_10endiannessE0EEENS_11full_resultEPKDsmPc:
  674|    628|    const char16_t *buf, size_t len, char *utf8_output) {
  675|    628|  std::pair<result, char *> ret =
  676|    628|      westmere::sse_convert_utf16_to_utf8_with_errors<big_endian>(buf, len,
  677|    628|                                                                  utf8_output);
  678|    628|  if (ret.first.error) {
  ------------------
  |  Branch (678:7): [True: 108, False: 520]
  ------------------
  679|    108|    return full_result(ret.first.error, ret.first.count,
  680|    108|                       size_t(ret.second - utf8_output));
  681|    108|  }
  682|    520|  if (ret.first.count != len) {
  ------------------
  |  Branch (682:7): [True: 516, False: 4]
  ------------------
  683|    516|    full_result sres =
  684|    516|        scalar::utf16_to_utf8::convert_with_errors<big_endian, false>(
  685|    516|            buf + ret.first.count, len - ret.first.count, ret.second, 0);
  686|    516|    return full_result(sres.error, ret.first.count + sres.input_count,
  687|    516|                       size_t(ret.second - utf8_output) + sres.output_count);
  688|    516|  }
  689|      4|  return full_result(error_code::SUCCESS, len,
  690|      4|                     size_t(ret.second - utf8_output));
  691|    520|}
_ZN7simdutf8westmere34convert_utf16_to_utf8_with_detailsILNS_10endiannessE1EEENS_11full_resultEPKDsmPc:
  674|    540|    const char16_t *buf, size_t len, char *utf8_output) {
  675|    540|  std::pair<result, char *> ret =
  676|    540|      westmere::sse_convert_utf16_to_utf8_with_errors<big_endian>(buf, len,
  677|    540|                                                                  utf8_output);
  678|    540|  if (ret.first.error) {
  ------------------
  |  Branch (678:7): [True: 112, False: 428]
  ------------------
  679|    112|    return full_result(ret.first.error, ret.first.count,
  680|    112|                       size_t(ret.second - utf8_output));
  681|    112|  }
  682|    428|  if (ret.first.count != len) {
  ------------------
  |  Branch (682:7): [True: 424, False: 4]
  ------------------
  683|    424|    full_result sres =
  684|    424|        scalar::utf16_to_utf8::convert_with_errors<big_endian, false>(
  685|    424|            buf + ret.first.count, len - ret.first.count, ret.second, 0);
  686|    424|    return full_result(sres.error, ret.first.count + sres.input_count,
  687|    424|                       size_t(ret.second - utf8_output) + sres.output_count);
  688|    424|  }
  689|      4|  return full_result(error_code::SUCCESS, len,
  690|      4|                     size_t(ret.second - utf8_output));
  691|    428|}
_ZN7simdutf8westmere18count_utf8_unsplitEPKcm:
 1045|  5.70k|                                                size_t length) noexcept {
 1046|  5.70k|  return utf8::count_code_points_bytemask(input, length);
 1047|  5.70k|}
_ZN7simdutf8westmere31utf8_length_from_latin1_unsplitEPKcm:
 1089|    347|utf8_length_from_latin1_unsplit(const char *input, size_t len) noexcept {
 1090|    347|  const uint8_t *str = reinterpret_cast<const uint8_t *>(input);
 1091|    347|  size_t answer = len / sizeof(__m128i) * sizeof(__m128i);
 1092|    347|  size_t i = 0;
 1093|    347|  if (answer >= 2048) { // long strings optimization
  ------------------
  |  Branch (1093:7): [True: 160, False: 187]
  ------------------
 1094|    160|    __m128i two_64bits = _mm_setzero_si128();
 1095|  5.85k|    while (i + sizeof(__m128i) <= len) {
  ------------------
  |  Branch (1095:12): [True: 5.69k, False: 160]
  ------------------
 1096|  5.69k|      __m128i runner = _mm_setzero_si128();
 1097|  5.69k|      size_t iterations = (len - i) / sizeof(__m128i);
 1098|  5.69k|      if (iterations > 255) {
  ------------------
  |  Branch (1098:11): [True: 5.53k, False: 160]
  ------------------
 1099|  5.53k|        iterations = 255;
 1100|  5.53k|      }
 1101|  5.69k|      size_t max_i = i + iterations * sizeof(__m128i) - sizeof(__m128i);
 1102|   358k|      for (; i + 4 * sizeof(__m128i) <= max_i; i += 4 * sizeof(__m128i)) {
  ------------------
  |  Branch (1102:14): [True: 352k, False: 5.69k]
  ------------------
 1103|   352k|        __m128i input1 = _mm_loadu_si128((const __m128i *)(str + i));
 1104|   352k|        __m128i input2 =
 1105|   352k|            _mm_loadu_si128((const __m128i *)(str + i + sizeof(__m128i)));
 1106|   352k|        __m128i input3 =
 1107|   352k|            _mm_loadu_si128((const __m128i *)(str + i + 2 * sizeof(__m128i)));
 1108|   352k|        __m128i input4 =
 1109|   352k|            _mm_loadu_si128((const __m128i *)(str + i + 3 * sizeof(__m128i)));
 1110|   352k|        __m128i input12 =
 1111|   352k|            _mm_add_epi8(_mm_cmpgt_epi8(_mm_setzero_si128(), input1),
 1112|   352k|                         _mm_cmpgt_epi8(_mm_setzero_si128(), input2));
 1113|   352k|        __m128i input34 =
 1114|   352k|            _mm_add_epi8(_mm_cmpgt_epi8(_mm_setzero_si128(), input3),
 1115|   352k|                         _mm_cmpgt_epi8(_mm_setzero_si128(), input4));
 1116|   352k|        __m128i input1234 = _mm_add_epi8(input12, input34);
 1117|   352k|        runner = _mm_sub_epi8(runner, input1234);
 1118|   352k|      }
 1119|  22.6k|      for (; i <= max_i; i += sizeof(__m128i)) {
  ------------------
  |  Branch (1119:14): [True: 16.9k, False: 5.69k]
  ------------------
 1120|  16.9k|        __m128i more_input = _mm_loadu_si128((const __m128i *)(str + i));
 1121|  16.9k|        runner = _mm_sub_epi8(runner,
 1122|  16.9k|                              _mm_cmpgt_epi8(_mm_setzero_si128(), more_input));
 1123|  16.9k|      }
 1124|  5.69k|      two_64bits =
 1125|  5.69k|          _mm_add_epi64(two_64bits, _mm_sad_epu8(runner, _mm_setzero_si128()));
 1126|  5.69k|    }
 1127|    160|    answer +=
 1128|    160|        _mm_extract_epi64(two_64bits, 0) + _mm_extract_epi64(two_64bits, 1);
 1129|    187|  } else if (answer > 0) { // short string optimization
  ------------------
  |  Branch (1129:14): [True: 135, False: 52]
  ------------------
 1130|  1.09k|    for (; i + 2 * sizeof(__m128i) <= len; i += 2 * sizeof(__m128i)) {
  ------------------
  |  Branch (1130:12): [True: 960, False: 135]
  ------------------
 1131|    960|      __m128i latin = _mm_loadu_si128((const __m128i *)(input + i));
 1132|    960|      uint16_t non_ascii = (uint16_t)_mm_movemask_epi8(latin);
 1133|    960|      answer += count_ones(non_ascii);
 1134|    960|      latin = _mm_loadu_si128((const __m128i *)(input + i) + 1);
 1135|    960|      non_ascii = (uint16_t)_mm_movemask_epi8(latin);
 1136|    960|      answer += count_ones(non_ascii);
 1137|    960|    }
 1138|    221|    for (; i + sizeof(__m128i) <= len; i += sizeof(__m128i)) {
  ------------------
  |  Branch (1138:12): [True: 86, False: 135]
  ------------------
 1139|     86|      __m128i latin = _mm_loadu_si128((const __m128i *)(input + i));
 1140|     86|      uint16_t non_ascii = (uint16_t)_mm_movemask_epi8(latin);
 1141|     86|      answer += count_ones(non_ascii);
 1142|     86|    }
 1143|    135|  }
 1144|    347|  return answer + scalar::latin1::utf8_length_from_latin1(
 1145|    347|                      reinterpret_cast<const char *>(str + i), len - i);
 1146|    347|}
_ZN7simdutf8westmere30utf32_length_from_utf8_unsplitEPKcm:
 1238|  1.38k|utf32_length_from_utf8_unsplit(const char *input, size_t length) noexcept {
 1239|  1.38k|  return utf8::count_code_points(input, length);
 1240|  1.38k|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_18internal8westmere26write_v_u16_11bits_to_utf8EDv2_xRPcS4_S4_:
   58|   843k|                                       const __m128i v_ff80) {
   59|       |  // no bits set above 7th bit
   60|   843k|  const __m128i one_byte_bytemask =
   61|   843k|      _mm_cmpeq_epi16(_mm_and_si128(v_u16, v_ff80), v_0000);
   62|   843k|  const uint16_t one_byte_bitmask =
   63|   843k|      static_cast<uint16_t>(_mm_movemask_epi8(one_byte_bytemask));
   64|       |
   65|   843k|  write_v_u16_11bits_to_utf8(v_u16, utf8_output, one_byte_bytemask,
   66|   843k|                             one_byte_bitmask);
   67|   843k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_18internal8westmere26write_v_u16_11bits_to_utf8EDv2_xRPcS4_t:
   10|  1.05M|                                       const uint16_t one_byte_bitmask) {
   11|       |  // 0b1100_0000_1000_0000
   12|  1.05M|  const __m128i v_c080 = _mm_set1_epi16((int16_t)0xc080);
   13|       |  // 0b0001_1111_0000_0000
   14|  1.05M|  const __m128i v_1f00 = _mm_set1_epi16((int16_t)0x1f00);
   15|       |  // 0b0000_0000_0011_1111
   16|  1.05M|  const __m128i v_003f = _mm_set1_epi16((int16_t)0x003f);
   17|       |
   18|       |  // 1. prepare 2-byte values
   19|       |  // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8
   20|       |  // expected output   : [110a|aaaa|10bb|bbbb] x 8
   21|       |
   22|       |  // t0 = [000a|aaaa|bbbb|bb00]
   23|  1.05M|  const __m128i t0 = _mm_slli_epi16(v_u16, 2);
   24|       |  // t1 = [000a|aaaa|0000|0000]
   25|  1.05M|  const __m128i t1 = _mm_and_si128(t0, v_1f00);
   26|       |  // t2 = [0000|0000|00bb|bbbb]
   27|  1.05M|  const __m128i t2 = _mm_and_si128(v_u16, v_003f);
   28|       |  // t3 = [000a|aaaa|00bb|bbbb]
   29|  1.05M|  const __m128i t3 = _mm_or_si128(t1, t2);
   30|       |  // t4 = [110a|aaaa|10bb|bbbb]
   31|  1.05M|  const __m128i t4 = _mm_or_si128(t3, v_c080);
   32|       |
   33|       |  // 2. merge ASCII and 2-byte codewords
   34|  1.05M|  const __m128i utf8_unpacked = _mm_blendv_epi8(t4, v_u16, one_byte_bytemask);
   35|       |
   36|       |  // 3. prepare bitmask for 8-bit lookup
   37|       |  //    one_byte_bitmask = hhggffeeddccbbaa -- the bits are doubled (h - MSB, a
   38|       |  //    - LSB)
   39|  1.05M|  const uint16_t m0 = one_byte_bitmask & 0x5555;      // m0 = 0h0g0f0e0d0c0b0a
   40|  1.05M|  const uint16_t m1 = static_cast<uint16_t>(m0 >> 7); // m1 = 00000000h0g0f0e0
   41|  1.05M|  const uint8_t m2 = static_cast<uint8_t>((m0 | m1) & 0xff); // m2 = hdgcfbea
   42|       |  // 4. pack the bytes
   43|  1.05M|  const uint8_t *row =
   44|  1.05M|      &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[m2][0];
   45|  1.05M|  const __m128i shuffle = _mm_loadu_si128((__m128i *)(row + 1));
   46|  1.05M|  const __m128i utf8_packed = _mm_shuffle_epi8(utf8_unpacked, shuffle);
   47|       |
   48|       |  // 5. store bytes
   49|  1.05M|  _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   50|       |
   51|       |  // 6. adjust pointers
   52|  1.05M|  utf8_output += row[0];
   53|  1.05M|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_127sse_convert_latin1_to_utf16ILNS_10endiannessE0EEENSt3__14pairIPKcPDsEES7_mS8_:
    4|     98|                            char16_t *utf16_output) {
    5|     98|  size_t rounded_len = len & ~0xF; // Round down to nearest multiple of 16
    6|   317k|  for (size_t i = 0; i < rounded_len; i += 16) {
  ------------------
  |  Branch (6:22): [True: 317k, False: 98]
  ------------------
    7|       |    // Load 16 Latin1 characters into a 128-bit register
    8|   317k|    __m128i in =
    9|   317k|        _mm_loadu_si128(reinterpret_cast<const __m128i *>(&latin1_input[i]));
   10|   317k|    __m128i out1 = big_endian ? _mm_unpacklo_epi8(_mm_setzero_si128(), in)
  ------------------
  |  Branch (10:20): [Folded, False: 317k]
  ------------------
   11|   317k|                              : _mm_unpacklo_epi8(in, _mm_setzero_si128());
   12|   317k|    __m128i out2 = big_endian ? _mm_unpackhi_epi8(_mm_setzero_si128(), in)
  ------------------
  |  Branch (12:20): [Folded, False: 317k]
  ------------------
   13|   317k|                              : _mm_unpackhi_epi8(in, _mm_setzero_si128());
   14|       |    // Zero extend each Latin1 character to 16-bit integers and store the
   15|       |    // results back to memory
   16|   317k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(&utf16_output[i]), out1);
   17|   317k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(&utf16_output[i + 8]), out2);
   18|   317k|  }
   19|       |  // return pointers pointing to where we left off
   20|     98|  return std::make_pair(latin1_input + rounded_len, utf16_output + rounded_len);
   21|     98|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_127sse_convert_latin1_to_utf16ILNS_10endiannessE1EEENSt3__14pairIPKcPDsEES7_mS8_:
    4|     84|                            char16_t *utf16_output) {
    5|     84|  size_t rounded_len = len & ~0xF; // Round down to nearest multiple of 16
    6|  74.5k|  for (size_t i = 0; i < rounded_len; i += 16) {
  ------------------
  |  Branch (6:22): [True: 74.4k, False: 84]
  ------------------
    7|       |    // Load 16 Latin1 characters into a 128-bit register
    8|  74.4k|    __m128i in =
    9|  74.4k|        _mm_loadu_si128(reinterpret_cast<const __m128i *>(&latin1_input[i]));
   10|  74.4k|    __m128i out1 = big_endian ? _mm_unpacklo_epi8(_mm_setzero_si128(), in)
  ------------------
  |  Branch (10:20): [True: 74.4k, Folded]
  ------------------
   11|  74.4k|                              : _mm_unpacklo_epi8(in, _mm_setzero_si128());
   12|  74.4k|    __m128i out2 = big_endian ? _mm_unpackhi_epi8(_mm_setzero_si128(), in)
  ------------------
  |  Branch (12:20): [True: 74.4k, Folded]
  ------------------
   13|  74.4k|                              : _mm_unpackhi_epi8(in, _mm_setzero_si128());
   14|       |    // Zero extend each Latin1 character to 16-bit integers and store the
   15|       |    // results back to memory
   16|  74.4k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(&utf16_output[i]), out1);
   17|  74.4k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(&utf16_output[i + 8]), out2);
   18|  74.4k|  }
   19|       |  // return pointers pointing to where we left off
   20|     84|  return std::make_pair(latin1_input + rounded_len, utf16_output + rounded_len);
   21|     84|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_127sse_convert_latin1_to_utf32EPKcmPDi:
    3|     70|                            char32_t *utf32_output) {
    4|     70|  const char *end = buf + len;
    5|       |
    6|   313k|  while (end - buf >= 16) {
  ------------------
  |  Branch (6:10): [True: 313k, False: 70]
  ------------------
    7|       |    // Load 16 Latin1 characters (16 bytes) into a 128-bit register
    8|   313k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
    9|       |
   10|       |    // Shift input to process next 4 bytes
   11|   313k|    __m128i in_shifted1 = _mm_srli_si128(in, 4);
   12|   313k|    __m128i in_shifted2 = _mm_srli_si128(in, 8);
   13|   313k|    __m128i in_shifted3 = _mm_srli_si128(in, 12);
   14|       |
   15|       |    // expand 8-bit to 32-bit unit
   16|   313k|    __m128i out1 = _mm_cvtepu8_epi32(in);
   17|   313k|    __m128i out2 = _mm_cvtepu8_epi32(in_shifted1);
   18|   313k|    __m128i out3 = _mm_cvtepu8_epi32(in_shifted2);
   19|   313k|    __m128i out4 = _mm_cvtepu8_epi32(in_shifted3);
   20|       |
   21|   313k|    _mm_storeu_si128((__m128i *)utf32_output, out1);
   22|   313k|    _mm_storeu_si128((__m128i *)(utf32_output + 4), out2);
   23|   313k|    _mm_storeu_si128((__m128i *)(utf32_output + 8), out3);
   24|   313k|    _mm_storeu_si128((__m128i *)(utf32_output + 12), out4);
   25|       |
   26|   313k|    utf32_output += 16;
   27|   313k|    buf += 16;
   28|   313k|  }
   29|       |
   30|     70|  return std::make_pair(buf, utf32_output);
   31|     70|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_126sse_convert_latin1_to_utf8EPKcmPc:
    3|    600|                           const size_t latin_input_length, char *utf8_output) {
    4|    600|  const char *end = latin_input + latin_input_length;
    5|       |
    6|    600|  const __m128i v_0000 = _mm_setzero_si128();
    7|       |  // 0b1000_0000
    8|    600|  const __m128i v_80 = _mm_set1_epi8((uint8_t)0x80);
    9|       |  // 0b1111_1111_1000_0000
   10|    600|  const __m128i v_ff80 = _mm_set1_epi16((uint16_t)0xff80);
   11|       |
   12|    600|  const __m128i latin_1_half_into_u16_byte_mask =
   13|    600|      _mm_setr_epi8(0, '\x80', 1, '\x80', 2, '\x80', 3, '\x80', 4, '\x80', 5,
   14|    600|                    '\x80', 6, '\x80', 7, '\x80');
   15|       |
   16|    600|  const __m128i latin_2_half_into_u16_byte_mask =
   17|    600|      _mm_setr_epi8(8, '\x80', 9, '\x80', 10, '\x80', 11, '\x80', 12, '\x80',
   18|    600|                    13, '\x80', 14, '\x80', 15, '\x80');
   19|       |
   20|       |  // each latin1 takes 1-2 utf8 bytes
   21|       |  // slow path writes useful 8-15 bytes twice (eagerly writes 16 bytes and then
   22|       |  // adjust the pointer) so the last write can exceed the utf8_output size by
   23|       |  // 8 bytes by reserving 8 extra input bytes, we expect the output to have
   24|       |  // 8-16 bytes free
   25|  2.85M|  while (end - latin_input >= 16 + 8) {
  ------------------
  |  Branch (25:10): [True: 2.85M, False: 600]
  ------------------
   26|       |    // Load 16 Latin1 characters (16 bytes) into a 128-bit register
   27|  2.85M|    __m128i v_latin = _mm_loadu_si128((__m128i *)latin_input);
   28|       |
   29|  2.85M|    if (_mm_testz_si128(v_latin, v_80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (29:9): [True: 2.43M, False: 421k]
  ------------------
   30|  2.43M|      _mm_storeu_si128((__m128i *)utf8_output, v_latin);
   31|  2.43M|      latin_input += 16;
   32|  2.43M|      utf8_output += 16;
   33|  2.43M|      continue;
   34|  2.43M|    }
   35|       |
   36|       |    // assuming a/b are bytes and A/B are uint16 of the same value
   37|       |    // aaaa_aaaa_bbbb_bbbb -> AAAA_AAAA
   38|   421k|    __m128i v_u16_latin_1_half =
   39|   421k|        _mm_shuffle_epi8(v_latin, latin_1_half_into_u16_byte_mask);
   40|       |    // aaaa_aaaa_bbbb_bbbb -> BBBB_BBBB
   41|   421k|    __m128i v_u16_latin_2_half =
   42|   421k|        _mm_shuffle_epi8(v_latin, latin_2_half_into_u16_byte_mask);
   43|       |
   44|   421k|    internal::westmere::write_v_u16_11bits_to_utf8(v_u16_latin_1_half,
   45|   421k|                                                   utf8_output, v_0000, v_ff80);
   46|   421k|    internal::westmere::write_v_u16_11bits_to_utf8(v_u16_latin_2_half,
   47|   421k|                                                   utf8_output, v_0000, v_ff80);
   48|   421k|    latin_input += 16;
   49|   421k|  }
   50|       |
   51|    600|  if (end - latin_input >= 16) {
  ------------------
  |  Branch (51:7): [True: 318, False: 282]
  ------------------
   52|       |    // Load 16 Latin1 characters (16 bytes) into a 128-bit register
   53|    318|    __m128i v_latin = _mm_loadu_si128((__m128i *)latin_input);
   54|       |
   55|    318|    if (_mm_testz_si128(v_latin, v_80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (55:9): [True: 146, False: 172]
  ------------------
   56|    146|      _mm_storeu_si128((__m128i *)utf8_output, v_latin);
   57|    146|      latin_input += 16;
   58|    146|      utf8_output += 16;
   59|    172|    } else {
   60|       |      // assuming a/b are bytes and A/B are uint16 of the same value
   61|       |      // aaaa_aaaa_bbbb_bbbb -> AAAA_AAAA
   62|    172|      __m128i v_u16_latin_1_half =
   63|    172|          _mm_shuffle_epi8(v_latin, latin_1_half_into_u16_byte_mask);
   64|    172|      internal::westmere::write_v_u16_11bits_to_utf8(
   65|    172|          v_u16_latin_1_half, utf8_output, v_0000, v_ff80);
   66|    172|      latin_input += 8;
   67|    172|    }
   68|    318|  }
   69|       |
   70|    600|  return std::make_pair(latin_input, utf8_output);
   71|    600|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_127sse_convert_utf16_to_latin1ILNS_10endiannessE0EEENSt3__14pairIPKDsPcEES7_mS8_:
    4|    110|                            char *latin1_output) {
    5|    110|  const char16_t *end = buf + len;
    6|    880|  while (end - buf >= 8) {
  ------------------
  |  Branch (6:10): [True: 804, False: 76]
  ------------------
    7|       |    // Load 8 UTF-16 characters into 128-bit SSE register
    8|    804|    __m128i in = _mm_loadu_si128(reinterpret_cast<const __m128i *>(buf));
    9|       |
   10|       |    if constexpr (!match_system(big_endian)) {
   11|       |      const __m128i swap =
   12|       |          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   13|       |      in = _mm_shuffle_epi8(in, swap);
   14|       |    }
   15|       |
   16|    804|    __m128i high_byte_mask = _mm_set1_epi16((int16_t)0xFF00);
   17|    804|    if (_mm_testz_si128(in, high_byte_mask)) {
  ------------------
  |  Branch (17:9): [True: 770, False: 34]
  ------------------
   18|       |      // Pack 16-bit characters into 8-bit and store in latin1_output
   19|    770|      __m128i latin1_packed = _mm_packus_epi16(in, in);
   20|    770|      _mm_storel_epi64(reinterpret_cast<__m128i *>(latin1_output),
   21|    770|                       latin1_packed);
   22|       |      // Adjust pointers for next iteration
   23|    770|      buf += 8;
   24|    770|      latin1_output += 8;
   25|    770|    } else {
   26|     34|      return std::make_pair(nullptr, reinterpret_cast<char *>(latin1_output));
   27|     34|    }
   28|    804|  } // while
   29|     76|  return std::make_pair(buf, latin1_output);
   30|    110|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_127sse_convert_utf16_to_latin1ILNS_10endiannessE1EEENSt3__14pairIPKDsPcEES7_mS8_:
    4|    126|                            char *latin1_output) {
    5|    126|  const char16_t *end = buf + len;
    6|  1.46k|  while (end - buf >= 8) {
  ------------------
  |  Branch (6:10): [True: 1.37k, False: 82]
  ------------------
    7|       |    // Load 8 UTF-16 characters into 128-bit SSE register
    8|  1.37k|    __m128i in = _mm_loadu_si128(reinterpret_cast<const __m128i *>(buf));
    9|       |
   10|  1.37k|    if constexpr (!match_system(big_endian)) {
   11|  1.37k|      const __m128i swap =
   12|  1.37k|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   13|  1.37k|      in = _mm_shuffle_epi8(in, swap);
   14|  1.37k|    }
   15|       |
   16|  1.37k|    __m128i high_byte_mask = _mm_set1_epi16((int16_t)0xFF00);
   17|  1.37k|    if (_mm_testz_si128(in, high_byte_mask)) {
  ------------------
  |  Branch (17:9): [True: 1.33k, False: 44]
  ------------------
   18|       |      // Pack 16-bit characters into 8-bit and store in latin1_output
   19|  1.33k|      __m128i latin1_packed = _mm_packus_epi16(in, in);
   20|  1.33k|      _mm_storel_epi64(reinterpret_cast<__m128i *>(latin1_output),
   21|  1.33k|                       latin1_packed);
   22|       |      // Adjust pointers for next iteration
   23|  1.33k|      buf += 8;
   24|  1.33k|      latin1_output += 8;
   25|  1.33k|    } else {
   26|     44|      return std::make_pair(nullptr, reinterpret_cast<char *>(latin1_output));
   27|     44|    }
   28|  1.37k|  } // while
   29|     82|  return std::make_pair(buf, latin1_output);
   30|    126|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_139sse_convert_utf16_to_latin1_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPcEEPKDsmS7_:
   35|    210|                                        char *latin1_output) {
   36|    210|  const char16_t *start = buf;
   37|    210|  const char16_t *end = buf + len;
   38|   902k|  while (end - buf >= 8) {
  ------------------
  |  Branch (38:10): [True: 902k, False: 110]
  ------------------
   39|   902k|    __m128i in = _mm_loadu_si128(reinterpret_cast<const __m128i *>(buf));
   40|       |
   41|       |    if constexpr (!match_system(big_endian)) {
   42|       |      const __m128i swap =
   43|       |          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   44|       |      in = _mm_shuffle_epi8(in, swap);
   45|       |    }
   46|       |
   47|   902k|    __m128i high_byte_mask = _mm_set1_epi16((int16_t)0xFF00);
   48|   902k|    if (_mm_testz_si128(in, high_byte_mask)) {
  ------------------
  |  Branch (48:9): [True: 902k, False: 100]
  ------------------
   49|   902k|      __m128i latin1_packed = _mm_packus_epi16(in, in);
   50|   902k|      _mm_storel_epi64(reinterpret_cast<__m128i *>(latin1_output),
   51|   902k|                       latin1_packed);
   52|   902k|      buf += 8;
   53|   902k|      latin1_output += 8;
   54|   902k|    } else {
   55|       |      // Fallback to scalar code for handling errors
   56|    336|      for (int k = 0; k < 8; k++) {
  ------------------
  |  Branch (56:23): [True: 336, False: 0]
  ------------------
   57|    336|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
   58|    336|        if (word <= 0xff) {
  ------------------
  |  Branch (58:13): [True: 236, False: 100]
  ------------------
   59|    236|          *latin1_output++ = char(word);
   60|    236|        } else {
   61|    100|          return std::make_pair(result(error_code::TOO_LARGE, buf - start + k),
   62|    100|                                latin1_output);
   63|    100|        }
   64|    336|      }
   65|      0|      buf += 8;
   66|      0|    }
   67|   902k|  } // while
   68|    110|  return std::make_pair(result(error_code::SUCCESS, buf - start),
   69|    110|                        latin1_output);
   70|    210|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_139sse_convert_utf16_to_latin1_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPcEEPKDsmS7_:
   35|    262|                                        char *latin1_output) {
   36|    262|  const char16_t *start = buf;
   37|    262|  const char16_t *end = buf + len;
   38|   660k|  while (end - buf >= 8) {
  ------------------
  |  Branch (38:10): [True: 659k, False: 102]
  ------------------
   39|   659k|    __m128i in = _mm_loadu_si128(reinterpret_cast<const __m128i *>(buf));
   40|       |
   41|   659k|    if constexpr (!match_system(big_endian)) {
   42|   659k|      const __m128i swap =
   43|   659k|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   44|   659k|      in = _mm_shuffle_epi8(in, swap);
   45|   659k|    }
   46|       |
   47|   659k|    __m128i high_byte_mask = _mm_set1_epi16((int16_t)0xFF00);
   48|   659k|    if (_mm_testz_si128(in, high_byte_mask)) {
  ------------------
  |  Branch (48:9): [True: 659k, False: 160]
  ------------------
   49|   659k|      __m128i latin1_packed = _mm_packus_epi16(in, in);
   50|   659k|      _mm_storel_epi64(reinterpret_cast<__m128i *>(latin1_output),
   51|   659k|                       latin1_packed);
   52|   659k|      buf += 8;
   53|   659k|      latin1_output += 8;
   54|   659k|    } else {
   55|       |      // Fallback to scalar code for handling errors
   56|    468|      for (int k = 0; k < 8; k++) {
  ------------------
  |  Branch (56:23): [True: 468, False: 0]
  ------------------
   57|    468|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
   58|    468|        if (word <= 0xff) {
  ------------------
  |  Branch (58:13): [True: 308, False: 160]
  ------------------
   59|    308|          *latin1_output++ = char(word);
   60|    308|        } else {
   61|    160|          return std::make_pair(result(error_code::TOO_LARGE, buf - start + k),
   62|    160|                                latin1_output);
   63|    160|        }
   64|    468|      }
   65|      0|      buf += 8;
   66|      0|    }
   67|   659k|  } // while
   68|    102|  return std::make_pair(result(error_code::SUCCESS, buf - start),
   69|    102|                        latin1_output);
   70|    262|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_126sse_convert_utf16_to_utf32ILNS_10endiannessE0EEENSt3__14pairIPKDsPDiEES7_mS8_:
   57|    380|                           char32_t *utf32_output) {
   58|    380|  const char16_t *end = buf + len;
   59|       |
   60|    380|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
   61|    380|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
   62|       |
   63|   262k|  while (end - buf >= 8) {
  ------------------
  |  Branch (63:10): [True: 261k, False: 268]
  ------------------
   64|   261k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
   65|       |
   66|   261k|    if (big_endian) {
  ------------------
  |  Branch (66:9): [Folded, False: 261k]
  ------------------
   67|      0|      const __m128i swap =
   68|      0|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   69|      0|      in = _mm_shuffle_epi8(in, swap);
   70|      0|    }
   71|       |
   72|       |    // 1. Check if there are any surrogate word in the input chunk.
   73|       |    //    We have also deal with situation when there is a surrogate word
   74|       |    //    at the end of a chunk.
   75|   261k|    const __m128i surrogates_bytemask =
   76|   261k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_d800);
   77|       |
   78|       |    // bitmask = 0x0000 if there are no surrogates
   79|       |    //         = 0xc000 if the last word is a surrogate
   80|   261k|    const uint16_t surrogates_bitmask =
   81|   261k|        static_cast<uint16_t>(_mm_movemask_epi8(surrogates_bytemask));
   82|       |    // It might seem like checking for surrogates_bitmask == 0xc000 could help.
   83|       |    // However, it is likely an uncommon occurrence.
   84|   261k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (84:9): [True: 257k, False: 4.13k]
  ------------------
   85|       |      // case: no surrogate pair, extend 16-bit code units to 32-bit code units
   86|   257k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output),
   87|   257k|                       _mm_cvtepu16_epi32(in));
   88|   257k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 4),
   89|   257k|                       _mm_cvtepu16_epi32(_mm_srli_si128(in, 8)));
   90|   257k|      utf32_output += 8;
   91|   257k|      buf += 8;
   92|       |      // surrogate pair(s) in a register
   93|   257k|    } else {
   94|       |      // Let us do a scalar fallback.
   95|       |      // It may seem wasteful to use scalar code, but being efficient with SIMD
   96|       |      // in the presence of surrogate pairs may require non-trivial tables.
   97|  4.13k|      size_t forward = 15;
   98|  4.13k|      size_t k = 0;
   99|  4.13k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (99:11): [True: 82, False: 4.05k]
  ------------------
  100|     82|        forward = size_t(end - buf - 1);
  101|     82|      }
  102|  59.4k|      for (; k < forward; k++) {
  ------------------
  |  Branch (102:14): [True: 55.4k, False: 4.02k]
  ------------------
  103|  55.4k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  104|  55.4k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (104:13): [True: 50.1k, False: 5.27k]
  ------------------
  105|  50.1k|          *utf32_output++ = char32_t(word);
  106|  50.1k|        } else {
  107|       |          // must be a surrogate pair
  108|  5.27k|          uint16_t diff = uint16_t(word - 0xD800);
  109|  5.27k|          uint16_t next_word =
  110|  5.27k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  111|  5.27k|          k++;
  112|  5.27k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  113|  5.27k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (113:15): [True: 112, False: 5.16k]
  ------------------
  114|    112|            return std::make_pair(nullptr, utf32_output);
  115|    112|          }
  116|  5.16k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  117|  5.16k|          *utf32_output++ = char32_t(value);
  118|  5.16k|        }
  119|  55.4k|      }
  120|  4.02k|      buf += k;
  121|  4.02k|    }
  122|   261k|  } // while
  123|    268|  return std::make_pair(buf, utf32_output);
  124|    380|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_126sse_convert_utf16_to_utf32ILNS_10endiannessE1EEENSt3__14pairIPKDsPDiEES7_mS8_:
   57|    394|                           char32_t *utf32_output) {
   58|    394|  const char16_t *end = buf + len;
   59|       |
   60|    394|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
   61|    394|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
   62|       |
   63|   831k|  while (end - buf >= 8) {
  ------------------
  |  Branch (63:10): [True: 831k, False: 274]
  ------------------
   64|   831k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
   65|       |
   66|   831k|    if (big_endian) {
  ------------------
  |  Branch (66:9): [True: 831k, Folded]
  ------------------
   67|   831k|      const __m128i swap =
   68|   831k|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   69|   831k|      in = _mm_shuffle_epi8(in, swap);
   70|   831k|    }
   71|       |
   72|       |    // 1. Check if there are any surrogate word in the input chunk.
   73|       |    //    We have also deal with situation when there is a surrogate word
   74|       |    //    at the end of a chunk.
   75|   831k|    const __m128i surrogates_bytemask =
   76|   831k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_d800);
   77|       |
   78|       |    // bitmask = 0x0000 if there are no surrogates
   79|       |    //         = 0xc000 if the last word is a surrogate
   80|   831k|    const uint16_t surrogates_bitmask =
   81|   831k|        static_cast<uint16_t>(_mm_movemask_epi8(surrogates_bytemask));
   82|       |    // It might seem like checking for surrogates_bitmask == 0xc000 could help.
   83|       |    // However, it is likely an uncommon occurrence.
   84|   831k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (84:9): [True: 825k, False: 5.10k]
  ------------------
   85|       |      // case: no surrogate pair, extend 16-bit code units to 32-bit code units
   86|   825k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output),
   87|   825k|                       _mm_cvtepu16_epi32(in));
   88|   825k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 4),
   89|   825k|                       _mm_cvtepu16_epi32(_mm_srli_si128(in, 8)));
   90|   825k|      utf32_output += 8;
   91|   825k|      buf += 8;
   92|       |      // surrogate pair(s) in a register
   93|   825k|    } else {
   94|       |      // Let us do a scalar fallback.
   95|       |      // It may seem wasteful to use scalar code, but being efficient with SIMD
   96|       |      // in the presence of surrogate pairs may require non-trivial tables.
   97|  5.10k|      size_t forward = 15;
   98|  5.10k|      size_t k = 0;
   99|  5.10k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (99:11): [True: 66, False: 5.04k]
  ------------------
  100|     66|        forward = size_t(end - buf - 1);
  101|     66|      }
  102|  74.3k|      for (; k < forward; k++) {
  ------------------
  |  Branch (102:14): [True: 69.3k, False: 4.98k]
  ------------------
  103|  69.3k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  104|  69.3k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (104:13): [True: 63.3k, False: 6.02k]
  ------------------
  105|  63.3k|          *utf32_output++ = char32_t(word);
  106|  63.3k|        } else {
  107|       |          // must be a surrogate pair
  108|  6.02k|          uint16_t diff = uint16_t(word - 0xD800);
  109|  6.02k|          uint16_t next_word =
  110|  6.02k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  111|  6.02k|          k++;
  112|  6.02k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  113|  6.02k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (113:15): [True: 120, False: 5.90k]
  ------------------
  114|    120|            return std::make_pair(nullptr, utf32_output);
  115|    120|          }
  116|  5.90k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  117|  5.90k|          *utf32_output++ = char32_t(value);
  118|  5.90k|        }
  119|  69.3k|      }
  120|  4.98k|      buf += k;
  121|  4.98k|    }
  122|   831k|  } // while
  123|    274|  return std::make_pair(buf, utf32_output);
  124|    394|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_138sse_convert_utf16_to_utf32_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPDiEEPKDsmS7_:
  136|    396|                                       char32_t *utf32_output) {
  137|    396|  const char16_t *start = buf;
  138|    396|  const char16_t *end = buf + len;
  139|       |
  140|    396|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
  141|    396|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
  142|       |
  143|   470k|  while (end - buf >= 8) {
  ------------------
  |  Branch (143:10): [True: 469k, False: 226]
  ------------------
  144|   469k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
  145|       |
  146|   469k|    if (big_endian) {
  ------------------
  |  Branch (146:9): [Folded, False: 469k]
  ------------------
  147|      0|      const __m128i swap =
  148|      0|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  149|      0|      in = _mm_shuffle_epi8(in, swap);
  150|      0|    }
  151|       |
  152|       |    // 1. Check if there are any surrogate word in the input chunk.
  153|       |    //    We have also deal with situation when there is a surrogate word
  154|       |    //    at the end of a chunk.
  155|   469k|    const __m128i surrogates_bytemask =
  156|   469k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_d800);
  157|       |
  158|       |    // bitmask = 0x0000 if there are no surrogates
  159|       |    //         = 0xc000 if the last word is a surrogate
  160|   469k|    const uint16_t surrogates_bitmask =
  161|   469k|        static_cast<uint16_t>(_mm_movemask_epi8(surrogates_bytemask));
  162|       |    // It might seem like checking for surrogates_bitmask == 0xc000 could help.
  163|       |    // However, it is likely an uncommon occurrence.
  164|   469k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (164:9): [True: 464k, False: 5.09k]
  ------------------
  165|       |      // case: no surrogate pair, extend 16-bit code units to 32-bit code units
  166|   464k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output),
  167|   464k|                       _mm_cvtepu16_epi32(in));
  168|   464k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 4),
  169|   464k|                       _mm_cvtepu16_epi32(_mm_srli_si128(in, 8)));
  170|   464k|      utf32_output += 8;
  171|   464k|      buf += 8;
  172|       |      // surrogate pair(s) in a register
  173|   464k|    } else {
  174|       |      // Let us do a scalar fallback.
  175|       |      // It may seem wasteful to use scalar code, but being efficient with SIMD
  176|       |      // in the presence of surrogate pairs may require non-trivial tables.
  177|  5.09k|      size_t forward = 15;
  178|  5.09k|      size_t k = 0;
  179|  5.09k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (179:11): [True: 84, False: 5.00k]
  ------------------
  180|     84|        forward = size_t(end - buf - 1);
  181|     84|      }
  182|  73.3k|      for (; k < forward; k++) {
  ------------------
  |  Branch (182:14): [True: 68.4k, False: 4.92k]
  ------------------
  183|  68.4k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  184|  68.4k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (184:13): [True: 62.1k, False: 6.24k]
  ------------------
  185|  62.1k|          *utf32_output++ = char32_t(word);
  186|  62.1k|        } else {
  187|       |          // must be a surrogate pair
  188|  6.24k|          uint16_t diff = uint16_t(word - 0xD800);
  189|  6.24k|          uint16_t next_word =
  190|  6.24k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  191|  6.24k|          k++;
  192|  6.24k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  193|  6.24k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (193:15): [True: 170, False: 6.07k]
  ------------------
  194|    170|            return std::make_pair(
  195|    170|                result(error_code::SURROGATE, buf - start + k - 1),
  196|    170|                utf32_output);
  197|    170|          }
  198|  6.07k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  199|  6.07k|          *utf32_output++ = char32_t(value);
  200|  6.07k|        }
  201|  68.4k|      }
  202|  4.92k|      buf += k;
  203|  4.92k|    }
  204|   469k|  } // while
  205|    226|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf32_output);
  206|    396|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_138sse_convert_utf16_to_utf32_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPDiEEPKDsmS7_:
  136|    380|                                       char32_t *utf32_output) {
  137|    380|  const char16_t *start = buf;
  138|    380|  const char16_t *end = buf + len;
  139|       |
  140|    380|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
  141|    380|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
  142|       |
  143|   309k|  while (end - buf >= 8) {
  ------------------
  |  Branch (143:10): [True: 309k, False: 210]
  ------------------
  144|   309k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
  145|       |
  146|   309k|    if (big_endian) {
  ------------------
  |  Branch (146:9): [True: 309k, Folded]
  ------------------
  147|   309k|      const __m128i swap =
  148|   309k|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  149|   309k|      in = _mm_shuffle_epi8(in, swap);
  150|   309k|    }
  151|       |
  152|       |    // 1. Check if there are any surrogate word in the input chunk.
  153|       |    //    We have also deal with situation when there is a surrogate word
  154|       |    //    at the end of a chunk.
  155|   309k|    const __m128i surrogates_bytemask =
  156|   309k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_d800);
  157|       |
  158|       |    // bitmask = 0x0000 if there are no surrogates
  159|       |    //         = 0xc000 if the last word is a surrogate
  160|   309k|    const uint16_t surrogates_bitmask =
  161|   309k|        static_cast<uint16_t>(_mm_movemask_epi8(surrogates_bytemask));
  162|       |    // It might seem like checking for surrogates_bitmask == 0xc000 could help.
  163|       |    // However, it is likely an uncommon occurrence.
  164|   309k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (164:9): [True: 306k, False: 2.84k]
  ------------------
  165|       |      // case: no surrogate pair, extend 16-bit code units to 32-bit code units
  166|   306k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output),
  167|   306k|                       _mm_cvtepu16_epi32(in));
  168|   306k|      _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 4),
  169|   306k|                       _mm_cvtepu16_epi32(_mm_srli_si128(in, 8)));
  170|   306k|      utf32_output += 8;
  171|   306k|      buf += 8;
  172|       |      // surrogate pair(s) in a register
  173|   306k|    } else {
  174|       |      // Let us do a scalar fallback.
  175|       |      // It may seem wasteful to use scalar code, but being efficient with SIMD
  176|       |      // in the presence of surrogate pairs may require non-trivial tables.
  177|  2.84k|      size_t forward = 15;
  178|  2.84k|      size_t k = 0;
  179|  2.84k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (179:11): [True: 86, False: 2.75k]
  ------------------
  180|     86|        forward = size_t(end - buf - 1);
  181|     86|      }
  182|  37.5k|      for (; k < forward; k++) {
  ------------------
  |  Branch (182:14): [True: 34.8k, False: 2.67k]
  ------------------
  183|  34.8k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  184|  34.8k|        if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (184:13): [True: 28.4k, False: 6.39k]
  ------------------
  185|  28.4k|          *utf32_output++ = char32_t(word);
  186|  28.4k|        } else {
  187|       |          // must be a surrogate pair
  188|  6.39k|          uint16_t diff = uint16_t(word - 0xD800);
  189|  6.39k|          uint16_t next_word =
  190|  6.39k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  191|  6.39k|          k++;
  192|  6.39k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  193|  6.39k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (193:15): [True: 170, False: 6.22k]
  ------------------
  194|    170|            return std::make_pair(
  195|    170|                result(error_code::SURROGATE, buf - start + k - 1),
  196|    170|                utf32_output);
  197|    170|          }
  198|  6.22k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  199|  6.22k|          *utf32_output++ = char32_t(value);
  200|  6.22k|        }
  201|  34.8k|      }
  202|  2.67k|      buf += k;
  203|  2.67k|    }
  204|   309k|  } // while
  205|    210|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf32_output);
  206|    380|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_125sse_convert_utf16_to_utf8ILNS_10endiannessE0EEENSt3__14pairIPKDsPcEES7_mS8_:
   56|    802|sse_convert_utf16_to_utf8(const char16_t *buf, size_t len, char *utf8_output) {
   57|       |
   58|    802|  const char16_t *end = buf + len;
   59|       |
   60|    802|  const __m128i v_0000 = _mm_setzero_si128();
   61|    802|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
   62|    802|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
   63|    802|  const size_t safety_margin =
   64|    802|      12; // to avoid overruns, see issue
   65|       |          // https://github.com/simdutf/simdutf/issues/92
   66|       |
   67|  1.54M|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (67:10): [True: 1.54M, False: 710]
  ------------------
   68|  1.54M|    __m128i in = _mm_loadu_si128((__m128i *)buf);
   69|  1.54M|    if (big_endian) {
  ------------------
  |  Branch (69:9): [Folded, False: 1.54M]
  ------------------
   70|      0|      const __m128i swap =
   71|      0|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   72|      0|      in = _mm_shuffle_epi8(in, swap);
   73|      0|    }
   74|       |    // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes
   75|  1.54M|    const __m128i v_ff80 = _mm_set1_epi16((int16_t)0xff80);
   76|  1.54M|    if (_mm_testz_si128(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (76:9): [True: 904k, False: 640k]
  ------------------
   77|   904k|      __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
   78|   904k|      if (big_endian) {
  ------------------
  |  Branch (78:11): [Folded, False: 904k]
  ------------------
   79|      0|        const __m128i swap =
   80|      0|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   81|      0|        nextin = _mm_shuffle_epi8(nextin, swap);
   82|      0|      }
   83|   904k|      if (!_mm_testz_si128(nextin, v_ff80)) {
  ------------------
  |  Branch (83:11): [True: 44.5k, False: 860k]
  ------------------
   84|       |        // 1. pack the bytes
   85|       |        // obviously suboptimal.
   86|  44.5k|        const __m128i utf8_packed = _mm_packus_epi16(in, in);
   87|       |        // 2. store (16 bytes)
   88|  44.5k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   89|       |        // 3. adjust pointers
   90|  44.5k|        buf += 8;
   91|  44.5k|        utf8_output += 8;
   92|  44.5k|        in = nextin;
   93|   860k|      } else {
   94|       |        // 1. pack the bytes
   95|       |        // obviously suboptimal.
   96|   860k|        const __m128i utf8_packed = _mm_packus_epi16(in, nextin);
   97|       |        // 2. store (16 bytes)
   98|   860k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   99|       |        // 3. adjust pointers
  100|   860k|        buf += 16;
  101|   860k|        utf8_output += 16;
  102|   860k|        continue; // we are done for this round!
  103|   860k|      }
  104|   904k|    }
  105|       |
  106|       |    // no bits set above 7th bit
  107|   684k|    const __m128i one_byte_bytemask =
  108|   684k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_ff80), v_0000);
  109|   684k|    const uint16_t one_byte_bitmask =
  110|   684k|        static_cast<uint16_t>(_mm_movemask_epi8(one_byte_bytemask));
  111|       |
  112|       |    // no bits set above 11th bit
  113|   684k|    const __m128i one_or_two_bytes_bytemask =
  114|   684k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_0000);
  115|   684k|    const uint16_t one_or_two_bytes_bitmask =
  116|   684k|        static_cast<uint16_t>(_mm_movemask_epi8(one_or_two_bytes_bytemask));
  117|       |
  118|   684k|    if (one_or_two_bytes_bitmask == 0xffff) {
  ------------------
  |  Branch (118:9): [True: 73.1k, False: 611k]
  ------------------
  119|  73.1k|      internal::westmere::write_v_u16_11bits_to_utf8(
  120|  73.1k|          in, utf8_output, one_byte_bytemask, one_byte_bitmask);
  121|  73.1k|      buf += 8;
  122|  73.1k|      continue;
  123|  73.1k|    }
  124|       |
  125|       |    // 1. Check if there are any surrogate word in the input chunk.
  126|       |    //    We have also deal with situation when there is a surrogate word
  127|       |    //    at the end of a chunk.
  128|   611k|    const __m128i surrogates_bytemask =
  129|   611k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_d800);
  130|       |
  131|       |    // bitmask = 0x0000 if there are no surrogates
  132|       |    //         = 0xc000 if the last word is a surrogate
  133|   611k|    const uint16_t surrogates_bitmask =
  134|   611k|        static_cast<uint16_t>(_mm_movemask_epi8(surrogates_bytemask));
  135|       |    // It might seem like checking for surrogates_bitmask == 0xc000 could help.
  136|       |    // However, it is likely an uncommon occurrence.
  137|   611k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (137:9): [True: 604k, False: 7.61k]
  ------------------
  138|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  139|   604k|      const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606,
  140|   604k|                                              0x0808, 0x0a0a, 0x0c0c, 0x0e0e);
  141|       |
  142|       |      /* In this branch we handle three cases:
  143|       |         1. [0000|0000|0ccc|cccc] => [0ccc|cccc]                           -
  144|       |        single UFT-8 byte
  145|       |         2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc]              - two
  146|       |        UTF-8 bytes
  147|       |         3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] -
  148|       |        three UTF-8 bytes
  149|       |
  150|       |        We expand the input word (16-bit) into two code units (32-bit), thus
  151|       |        we have room for four bytes. However, we need five distinct bit
  152|       |        layouts. Note that the last byte in cases #2 and #3 is the same.
  153|       |
  154|       |        We precompute byte 1 for case #1 and the common byte for cases #2 & #3
  155|       |        in register t2.
  156|       |
  157|       |        We precompute byte 1 for case #3 and -- **conditionally** -- precompute
  158|       |        either byte 1 for case #2 or byte 2 for case #3. Note that they
  159|       |        differ by exactly one bit.
  160|       |
  161|       |        Finally from these two code units we build proper UTF-8 sequence, taking
  162|       |        into account the case (i.e, the number of bytes to write).
  163|       |      */
  164|       |      /**
  165|       |       * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce:
  166|       |       * t2 => [0ccc|cccc] [10cc|cccc]
  167|       |       * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb])
  168|       |       */
  169|   604k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  170|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  171|   604k|      const __m128i t0 = _mm_shuffle_epi8(in, dup_even);
  172|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  173|   604k|      const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  169|   604k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  174|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  175|   604k|      const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  169|   604k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  176|       |
  177|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  178|   604k|      const __m128i s0 = _mm_srli_epi16(in, 4);
  179|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  180|   604k|      const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  169|   604k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  181|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  182|   604k|      const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  169|   604k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  183|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  184|   604k|      const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  169|   604k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  185|   604k|      const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask,
  186|   604k|                                          simdutf_vec(0b0100000000000000));
  ------------------
  |  |  169|   604k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  187|   604k|      const __m128i s4 = _mm_xor_si128(s3, m0);
  188|   604k|#undef simdutf_vec
  189|       |
  190|       |      // 4. expand code units 16-bit => 32-bit
  191|   604k|      const __m128i out0 = _mm_unpacklo_epi16(t2, s4);
  192|   604k|      const __m128i out1 = _mm_unpackhi_epi16(t2, s4);
  193|       |
  194|       |      // 5. compress 32-bit code units into 1, 2 or 3 bytes -- 2 x shuffle
  195|   604k|      const uint16_t mask =
  196|   604k|          (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa);
  197|   604k|      if (mask == 0) {
  ------------------
  |  Branch (197:11): [True: 434k, False: 169k]
  ------------------
  198|       |        // We only have three-byte code units. Use fast path.
  199|   434k|        const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14,
  200|   434k|                                              15, 13, -1, -1, -1, -1);
  201|   434k|        const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle);
  202|   434k|        const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle);
  203|   434k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  204|   434k|        utf8_output += 12;
  205|   434k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  206|   434k|        utf8_output += 12;
  207|   434k|        buf += 8;
  208|   434k|        continue;
  209|   434k|      }
  210|   169k|      const uint8_t mask0 = uint8_t(mask);
  211|       |
  212|   169k|      const uint8_t *row0 =
  213|   169k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  214|   169k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  215|   169k|      const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0);
  216|       |
  217|   169k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  218|       |
  219|   169k|      const uint8_t *row1 =
  220|   169k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  221|   169k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  222|   169k|      const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1);
  223|       |
  224|   169k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  225|   169k|      utf8_output += row0[0];
  226|   169k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  227|   169k|      utf8_output += row1[0];
  228|       |
  229|   169k|      buf += 8;
  230|       |      // surrogate pair(s) in a register
  231|   169k|    } else {
  232|       |      // Let us do a scalar fallback.
  233|       |      // It may seem wasteful to use scalar code, but being efficient with SIMD
  234|       |      // in the presence of surrogate pairs may require non-trivial tables.
  235|  7.61k|      size_t forward = 15;
  236|  7.61k|      size_t k = 0;
  237|  7.61k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (237:11): [True: 0, False: 7.61k]
  ------------------
  238|      0|        forward = size_t(end - buf - 1);
  239|      0|      }
  240|   110k|      for (; k < forward; k++) {
  ------------------
  |  Branch (240:14): [True: 103k, False: 7.52k]
  ------------------
  241|   103k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  242|   103k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (242:13): [True: 22.0k, False: 81.2k]
  ------------------
  243|  22.0k|          *utf8_output++ = char(word);
  244|  81.2k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (244:20): [True: 15.0k, False: 66.2k]
  ------------------
  245|  15.0k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  246|  15.0k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  247|  66.2k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (247:20): [True: 55.8k, False: 10.3k]
  ------------------
  248|  55.8k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  249|  55.8k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  250|  55.8k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  251|  55.8k|        } else {
  252|       |          // must be a surrogate pair
  253|  10.3k|          uint16_t diff = uint16_t(word - 0xD800);
  254|  10.3k|          uint16_t next_word =
  255|  10.3k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  256|  10.3k|          k++;
  257|  10.3k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  258|  10.3k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (258:15): [True: 92, False: 10.2k]
  ------------------
  259|     92|            return std::make_pair(nullptr, utf8_output);
  260|     92|          }
  261|  10.2k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  262|  10.2k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  263|  10.2k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  264|  10.2k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  265|  10.2k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  266|  10.2k|        }
  267|   103k|      }
  268|  7.52k|      buf += k;
  269|  7.52k|    }
  270|   611k|  } // while
  271|       |
  272|    710|  return std::make_pair(buf, utf8_output);
  273|    802|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_125sse_convert_utf16_to_utf8ILNS_10endiannessE1EEENSt3__14pairIPKDsPcEES7_mS8_:
   56|    740|sse_convert_utf16_to_utf8(const char16_t *buf, size_t len, char *utf8_output) {
   57|       |
   58|    740|  const char16_t *end = buf + len;
   59|       |
   60|    740|  const __m128i v_0000 = _mm_setzero_si128();
   61|    740|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
   62|    740|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
   63|    740|  const size_t safety_margin =
   64|    740|      12; // to avoid overruns, see issue
   65|       |          // https://github.com/simdutf/simdutf/issues/92
   66|       |
   67|  1.18M|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (67:10): [True: 1.18M, False: 682]
  ------------------
   68|  1.18M|    __m128i in = _mm_loadu_si128((__m128i *)buf);
   69|  1.18M|    if (big_endian) {
  ------------------
  |  Branch (69:9): [True: 1.18M, Folded]
  ------------------
   70|  1.18M|      const __m128i swap =
   71|  1.18M|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   72|  1.18M|      in = _mm_shuffle_epi8(in, swap);
   73|  1.18M|    }
   74|       |    // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes
   75|  1.18M|    const __m128i v_ff80 = _mm_set1_epi16((int16_t)0xff80);
   76|  1.18M|    if (_mm_testz_si128(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (76:9): [True: 687k, False: 494k]
  ------------------
   77|   687k|      __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
   78|   687k|      if (big_endian) {
  ------------------
  |  Branch (78:11): [True: 687k, Folded]
  ------------------
   79|   687k|        const __m128i swap =
   80|   687k|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   81|   687k|        nextin = _mm_shuffle_epi8(nextin, swap);
   82|   687k|      }
   83|   687k|      if (!_mm_testz_si128(nextin, v_ff80)) {
  ------------------
  |  Branch (83:11): [True: 56.4k, False: 631k]
  ------------------
   84|       |        // 1. pack the bytes
   85|       |        // obviously suboptimal.
   86|  56.4k|        const __m128i utf8_packed = _mm_packus_epi16(in, in);
   87|       |        // 2. store (16 bytes)
   88|  56.4k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   89|       |        // 3. adjust pointers
   90|  56.4k|        buf += 8;
   91|  56.4k|        utf8_output += 8;
   92|  56.4k|        in = nextin;
   93|   631k|      } else {
   94|       |        // 1. pack the bytes
   95|       |        // obviously suboptimal.
   96|   631k|        const __m128i utf8_packed = _mm_packus_epi16(in, nextin);
   97|       |        // 2. store (16 bytes)
   98|   631k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   99|       |        // 3. adjust pointers
  100|   631k|        buf += 16;
  101|   631k|        utf8_output += 16;
  102|   631k|        continue; // we are done for this round!
  103|   631k|      }
  104|   687k|    }
  105|       |
  106|       |    // no bits set above 7th bit
  107|   550k|    const __m128i one_byte_bytemask =
  108|   550k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_ff80), v_0000);
  109|   550k|    const uint16_t one_byte_bitmask =
  110|   550k|        static_cast<uint16_t>(_mm_movemask_epi8(one_byte_bytemask));
  111|       |
  112|       |    // no bits set above 11th bit
  113|   550k|    const __m128i one_or_two_bytes_bytemask =
  114|   550k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_0000);
  115|   550k|    const uint16_t one_or_two_bytes_bitmask =
  116|   550k|        static_cast<uint16_t>(_mm_movemask_epi8(one_or_two_bytes_bytemask));
  117|       |
  118|   550k|    if (one_or_two_bytes_bitmask == 0xffff) {
  ------------------
  |  Branch (118:9): [True: 64.4k, False: 486k]
  ------------------
  119|  64.4k|      internal::westmere::write_v_u16_11bits_to_utf8(
  120|  64.4k|          in, utf8_output, one_byte_bytemask, one_byte_bitmask);
  121|  64.4k|      buf += 8;
  122|  64.4k|      continue;
  123|  64.4k|    }
  124|       |
  125|       |    // 1. Check if there are any surrogate word in the input chunk.
  126|       |    //    We have also deal with situation when there is a surrogate word
  127|       |    //    at the end of a chunk.
  128|   486k|    const __m128i surrogates_bytemask =
  129|   486k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_d800);
  130|       |
  131|       |    // bitmask = 0x0000 if there are no surrogates
  132|       |    //         = 0xc000 if the last word is a surrogate
  133|   486k|    const uint16_t surrogates_bitmask =
  134|   486k|        static_cast<uint16_t>(_mm_movemask_epi8(surrogates_bytemask));
  135|       |    // It might seem like checking for surrogates_bitmask == 0xc000 could help.
  136|       |    // However, it is likely an uncommon occurrence.
  137|   486k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (137:9): [True: 475k, False: 10.4k]
  ------------------
  138|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  139|   475k|      const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606,
  140|   475k|                                              0x0808, 0x0a0a, 0x0c0c, 0x0e0e);
  141|       |
  142|       |      /* In this branch we handle three cases:
  143|       |         1. [0000|0000|0ccc|cccc] => [0ccc|cccc]                           -
  144|       |        single UFT-8 byte
  145|       |         2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc]              - two
  146|       |        UTF-8 bytes
  147|       |         3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] -
  148|       |        three UTF-8 bytes
  149|       |
  150|       |        We expand the input word (16-bit) into two code units (32-bit), thus
  151|       |        we have room for four bytes. However, we need five distinct bit
  152|       |        layouts. Note that the last byte in cases #2 and #3 is the same.
  153|       |
  154|       |        We precompute byte 1 for case #1 and the common byte for cases #2 & #3
  155|       |        in register t2.
  156|       |
  157|       |        We precompute byte 1 for case #3 and -- **conditionally** -- precompute
  158|       |        either byte 1 for case #2 or byte 2 for case #3. Note that they
  159|       |        differ by exactly one bit.
  160|       |
  161|       |        Finally from these two code units we build proper UTF-8 sequence, taking
  162|       |        into account the case (i.e, the number of bytes to write).
  163|       |      */
  164|       |      /**
  165|       |       * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce:
  166|       |       * t2 => [0ccc|cccc] [10cc|cccc]
  167|       |       * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb])
  168|       |       */
  169|   475k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  170|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  171|   475k|      const __m128i t0 = _mm_shuffle_epi8(in, dup_even);
  172|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  173|   475k|      const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  169|   475k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  174|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  175|   475k|      const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  169|   475k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  176|       |
  177|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  178|   475k|      const __m128i s0 = _mm_srli_epi16(in, 4);
  179|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  180|   475k|      const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  169|   475k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  181|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  182|   475k|      const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  169|   475k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  183|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  184|   475k|      const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  169|   475k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  185|   475k|      const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask,
  186|   475k|                                          simdutf_vec(0b0100000000000000));
  ------------------
  |  |  169|   475k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  187|   475k|      const __m128i s4 = _mm_xor_si128(s3, m0);
  188|   475k|#undef simdutf_vec
  189|       |
  190|       |      // 4. expand code units 16-bit => 32-bit
  191|   475k|      const __m128i out0 = _mm_unpacklo_epi16(t2, s4);
  192|   475k|      const __m128i out1 = _mm_unpackhi_epi16(t2, s4);
  193|       |
  194|       |      // 5. compress 32-bit code units into 1, 2 or 3 bytes -- 2 x shuffle
  195|   475k|      const uint16_t mask =
  196|   475k|          (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa);
  197|   475k|      if (mask == 0) {
  ------------------
  |  Branch (197:11): [True: 253k, False: 222k]
  ------------------
  198|       |        // We only have three-byte code units. Use fast path.
  199|   253k|        const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14,
  200|   253k|                                              15, 13, -1, -1, -1, -1);
  201|   253k|        const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle);
  202|   253k|        const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle);
  203|   253k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  204|   253k|        utf8_output += 12;
  205|   253k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  206|   253k|        utf8_output += 12;
  207|   253k|        buf += 8;
  208|   253k|        continue;
  209|   253k|      }
  210|   222k|      const uint8_t mask0 = uint8_t(mask);
  211|       |
  212|   222k|      const uint8_t *row0 =
  213|   222k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  214|   222k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  215|   222k|      const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0);
  216|       |
  217|   222k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  218|       |
  219|   222k|      const uint8_t *row1 =
  220|   222k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  221|   222k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  222|   222k|      const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1);
  223|       |
  224|   222k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  225|   222k|      utf8_output += row0[0];
  226|   222k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  227|   222k|      utf8_output += row1[0];
  228|       |
  229|   222k|      buf += 8;
  230|       |      // surrogate pair(s) in a register
  231|   222k|    } else {
  232|       |      // Let us do a scalar fallback.
  233|       |      // It may seem wasteful to use scalar code, but being efficient with SIMD
  234|       |      // in the presence of surrogate pairs may require non-trivial tables.
  235|  10.4k|      size_t forward = 15;
  236|  10.4k|      size_t k = 0;
  237|  10.4k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (237:11): [True: 0, False: 10.4k]
  ------------------
  238|      0|        forward = size_t(end - buf - 1);
  239|      0|      }
  240|   152k|      for (; k < forward; k++) {
  ------------------
  |  Branch (240:14): [True: 141k, False: 10.4k]
  ------------------
  241|   141k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  242|   141k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (242:13): [True: 23.0k, False: 118k]
  ------------------
  243|  23.0k|          *utf8_output++ = char(word);
  244|   118k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (244:20): [True: 7.17k, False: 111k]
  ------------------
  245|  7.17k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  246|  7.17k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  247|   111k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (247:20): [True: 95.3k, False: 16.0k]
  ------------------
  248|  95.3k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  249|  95.3k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  250|  95.3k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  251|  95.3k|        } else {
  252|       |          // must be a surrogate pair
  253|  16.0k|          uint16_t diff = uint16_t(word - 0xD800);
  254|  16.0k|          uint16_t next_word =
  255|  16.0k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  256|  16.0k|          k++;
  257|  16.0k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  258|  16.0k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (258:15): [True: 58, False: 15.9k]
  ------------------
  259|     58|            return std::make_pair(nullptr, utf8_output);
  260|     58|          }
  261|  15.9k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  262|  15.9k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  263|  15.9k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  264|  15.9k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  265|  15.9k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  266|  15.9k|        }
  267|   141k|      }
  268|  10.4k|      buf += k;
  269|  10.4k|    }
  270|   486k|  } // while
  271|       |
  272|    682|  return std::make_pair(buf, utf8_output);
  273|    740|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_137sse_convert_utf16_to_utf8_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPcEEPKDsmS7_:
  285|    628|                                      char *utf8_output) {
  286|    628|  const char16_t *start = buf;
  287|    628|  const char16_t *end = buf + len;
  288|       |
  289|    628|  const __m128i v_0000 = _mm_setzero_si128();
  290|    628|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
  291|    628|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
  292|    628|  const size_t safety_margin =
  293|    628|      12; // to avoid overruns, see issue
  294|       |          // https://github.com/simdutf/simdutf/issues/92
  295|       |
  296|   709k|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (296:10): [True: 709k, False: 520]
  ------------------
  297|   709k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
  298|   709k|    if (big_endian) {
  ------------------
  |  Branch (298:9): [Folded, False: 709k]
  ------------------
  299|      0|      const __m128i swap =
  300|      0|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  301|      0|      in = _mm_shuffle_epi8(in, swap);
  302|      0|    }
  303|       |    // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes
  304|   709k|    const __m128i v_ff80 = _mm_set1_epi16((int16_t)0xff80);
  305|   709k|    if (_mm_testz_si128(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (305:9): [True: 232k, False: 476k]
  ------------------
  306|   232k|      __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
  307|   232k|      if (big_endian) {
  ------------------
  |  Branch (307:11): [Folded, False: 232k]
  ------------------
  308|      0|        const __m128i swap =
  309|      0|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  310|      0|        nextin = _mm_shuffle_epi8(nextin, swap);
  311|      0|      }
  312|   232k|      if (!_mm_testz_si128(nextin, v_ff80)) {
  ------------------
  |  Branch (312:11): [True: 16.7k, False: 215k]
  ------------------
  313|       |        // 1. pack the bytes
  314|       |        // obviously suboptimal.
  315|  16.7k|        const __m128i utf8_packed = _mm_packus_epi16(in, in);
  316|       |        // 2. store (16 bytes)
  317|  16.7k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  318|       |        // 3. adjust pointers
  319|  16.7k|        buf += 8;
  320|  16.7k|        utf8_output += 8;
  321|  16.7k|        in = nextin;
  322|   215k|      } else {
  323|       |        // 1. pack the bytes
  324|       |        // obviously suboptimal.
  325|   215k|        const __m128i utf8_packed = _mm_packus_epi16(in, nextin);
  326|       |        // 2. store (16 bytes)
  327|   215k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  328|       |        // 3. adjust pointers
  329|   215k|        buf += 16;
  330|   215k|        utf8_output += 16;
  331|   215k|        continue; // we are done for this round!
  332|   215k|      }
  333|   232k|    }
  334|       |
  335|       |    // no bits set above 7th bit
  336|   493k|    const __m128i one_byte_bytemask =
  337|   493k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_ff80), v_0000);
  338|   493k|    const uint16_t one_byte_bitmask =
  339|   493k|        static_cast<uint16_t>(_mm_movemask_epi8(one_byte_bytemask));
  340|       |
  341|       |    // no bits set above 11th bit
  342|   493k|    const __m128i one_or_two_bytes_bytemask =
  343|   493k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_0000);
  344|   493k|    const uint16_t one_or_two_bytes_bitmask =
  345|   493k|        static_cast<uint16_t>(_mm_movemask_epi8(one_or_two_bytes_bytemask));
  346|       |
  347|   493k|    if (one_or_two_bytes_bitmask == 0xffff) {
  ------------------
  |  Branch (347:9): [True: 16.8k, False: 476k]
  ------------------
  348|  16.8k|      internal::westmere::write_v_u16_11bits_to_utf8(
  349|  16.8k|          in, utf8_output, one_byte_bytemask, one_byte_bitmask);
  350|  16.8k|      buf += 8;
  351|  16.8k|      continue;
  352|  16.8k|    }
  353|       |
  354|       |    // 1. Check if there are any surrogate word in the input chunk.
  355|       |    //    We have also deal with situation when there is a surrogate word
  356|       |    //    at the end of a chunk.
  357|   476k|    const __m128i surrogates_bytemask =
  358|   476k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_d800);
  359|       |
  360|       |    // bitmask = 0x0000 if there are no surrogates
  361|       |    //         = 0xc000 if the last word is a surrogate
  362|   476k|    const uint16_t surrogates_bitmask =
  363|   476k|        static_cast<uint16_t>(_mm_movemask_epi8(surrogates_bytemask));
  364|       |    // It might seem like checking for surrogates_bitmask == 0xc000 could help.
  365|       |    // However, it is likely an uncommon occurrence.
  366|   476k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (366:9): [True: 474k, False: 2.18k]
  ------------------
  367|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  368|   474k|      const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606,
  369|   474k|                                              0x0808, 0x0a0a, 0x0c0c, 0x0e0e);
  370|       |
  371|       |      /* In this branch we handle three cases:
  372|       |         1. [0000|0000|0ccc|cccc] => [0ccc|cccc]                           -
  373|       |        single UFT-8 byte
  374|       |         2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc]              - two
  375|       |        UTF-8 bytes
  376|       |         3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] -
  377|       |        three UTF-8 bytes
  378|       |
  379|       |        We expand the input word (16-bit) into two code units (32-bit), thus
  380|       |        we have room for four bytes. However, we need five distinct bit
  381|       |        layouts. Note that the last byte in cases #2 and #3 is the same.
  382|       |
  383|       |        We precompute byte 1 for case #1 and the common byte for cases #2 & #3
  384|       |        in register t2.
  385|       |
  386|       |        We precompute byte 1 for case #3 and -- **conditionally** -- precompute
  387|       |        either byte 1 for case #2 or byte 2 for case #3. Note that they
  388|       |        differ by exactly one bit.
  389|       |
  390|       |        Finally from these two code units we build proper UTF-8 sequence, taking
  391|       |        into account the case (i.e, the number of bytes to write).
  392|       |      */
  393|       |      /**
  394|       |       * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce:
  395|       |       * t2 => [0ccc|cccc] [10cc|cccc]
  396|       |       * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb])
  397|       |       */
  398|   474k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  399|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  400|   474k|      const __m128i t0 = _mm_shuffle_epi8(in, dup_even);
  401|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  402|   474k|      const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  398|   474k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  403|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  404|   474k|      const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  398|   474k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  405|       |
  406|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  407|   474k|      const __m128i s0 = _mm_srli_epi16(in, 4);
  408|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  409|   474k|      const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  398|   474k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  410|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  411|   474k|      const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  398|   474k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  412|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  413|   474k|      const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  398|   474k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  414|   474k|      const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask,
  415|   474k|                                          simdutf_vec(0b0100000000000000));
  ------------------
  |  |  398|   474k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  416|   474k|      const __m128i s4 = _mm_xor_si128(s3, m0);
  417|   474k|#undef simdutf_vec
  418|       |
  419|       |      // 4. expand code units 16-bit => 32-bit
  420|   474k|      const __m128i out0 = _mm_unpacklo_epi16(t2, s4);
  421|   474k|      const __m128i out1 = _mm_unpackhi_epi16(t2, s4);
  422|       |
  423|       |      // 5. compress 32-bit code units into 1, 2 or 3 bytes -- 2 x shuffle
  424|   474k|      const uint16_t mask =
  425|   474k|          (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa);
  426|   474k|      if (mask == 0) {
  ------------------
  |  Branch (426:11): [True: 351k, False: 122k]
  ------------------
  427|       |        // We only have three-byte code units. Use fast path.
  428|   351k|        const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14,
  429|   351k|                                              15, 13, -1, -1, -1, -1);
  430|   351k|        const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle);
  431|   351k|        const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle);
  432|   351k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  433|   351k|        utf8_output += 12;
  434|   351k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  435|   351k|        utf8_output += 12;
  436|   351k|        buf += 8;
  437|   351k|        continue;
  438|   351k|      }
  439|   122k|      const uint8_t mask0 = uint8_t(mask);
  440|       |
  441|   122k|      const uint8_t *row0 =
  442|   122k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  443|   122k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  444|   122k|      const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0);
  445|       |
  446|   122k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  447|       |
  448|   122k|      const uint8_t *row1 =
  449|   122k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  450|   122k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  451|   122k|      const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1);
  452|       |
  453|   122k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  454|   122k|      utf8_output += row0[0];
  455|   122k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  456|   122k|      utf8_output += row1[0];
  457|       |
  458|   122k|      buf += 8;
  459|       |      // surrogate pair(s) in a register
  460|   122k|    } else {
  461|       |      // Let us do a scalar fallback.
  462|       |      // It may seem wasteful to use scalar code, but being efficient with SIMD
  463|       |      // in the presence of surrogate pairs may require non-trivial tables.
  464|  2.18k|      size_t forward = 15;
  465|  2.18k|      size_t k = 0;
  466|  2.18k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (466:11): [True: 0, False: 2.18k]
  ------------------
  467|      0|        forward = size_t(end - buf - 1);
  468|      0|      }
  469|  30.9k|      for (; k < forward; k++) {
  ------------------
  |  Branch (469:14): [True: 28.8k, False: 2.07k]
  ------------------
  470|  28.8k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  471|  28.8k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (471:13): [True: 5.13k, False: 23.7k]
  ------------------
  472|  5.13k|          *utf8_output++ = char(word);
  473|  23.7k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (473:20): [True: 2.07k, False: 21.6k]
  ------------------
  474|  2.07k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  475|  2.07k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  476|  21.6k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (476:20): [True: 18.7k, False: 2.93k]
  ------------------
  477|  18.7k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  478|  18.7k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  479|  18.7k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  480|  18.7k|        } else {
  481|       |          // must be a surrogate pair
  482|  2.93k|          uint16_t diff = uint16_t(word - 0xD800);
  483|  2.93k|          uint16_t next_word =
  484|  2.93k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  485|  2.93k|          k++;
  486|  2.93k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  487|  2.93k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (487:15): [True: 108, False: 2.82k]
  ------------------
  488|    108|            return std::make_pair(
  489|    108|                result(error_code::SURROGATE, buf - start + k - 1),
  490|    108|                utf8_output);
  491|    108|          }
  492|  2.82k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  493|  2.82k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  494|  2.82k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  495|  2.82k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  496|  2.82k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  497|  2.82k|        }
  498|  28.8k|      }
  499|  2.07k|      buf += k;
  500|  2.07k|    }
  501|   476k|  } // while
  502|       |
  503|    520|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output);
  504|    628|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_137sse_convert_utf16_to_utf8_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPcEEPKDsmS7_:
  285|    540|                                      char *utf8_output) {
  286|    540|  const char16_t *start = buf;
  287|    540|  const char16_t *end = buf + len;
  288|       |
  289|    540|  const __m128i v_0000 = _mm_setzero_si128();
  290|    540|  const __m128i v_f800 = _mm_set1_epi16((int16_t)0xf800);
  291|    540|  const __m128i v_d800 = _mm_set1_epi16((int16_t)0xd800);
  292|    540|  const size_t safety_margin =
  293|    540|      12; // to avoid overruns, see issue
  294|       |          // https://github.com/simdutf/simdutf/issues/92
  295|       |
  296|   485k|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (296:10): [True: 484k, False: 428]
  ------------------
  297|   484k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
  298|   484k|    if (big_endian) {
  ------------------
  |  Branch (298:9): [True: 484k, Folded]
  ------------------
  299|   484k|      const __m128i swap =
  300|   484k|          _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  301|   484k|      in = _mm_shuffle_epi8(in, swap);
  302|   484k|    }
  303|       |    // a single 16-bit UTF-16 word can yield 1, 2 or 3 UTF-8 bytes
  304|   484k|    const __m128i v_ff80 = _mm_set1_epi16((int16_t)0xff80);
  305|   484k|    if (_mm_testz_si128(in, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (305:9): [True: 284k, False: 200k]
  ------------------
  306|   284k|      __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
  307|   284k|      if (big_endian) {
  ------------------
  |  Branch (307:11): [True: 284k, Folded]
  ------------------
  308|   284k|        const __m128i swap =
  309|   284k|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  310|   284k|        nextin = _mm_shuffle_epi8(nextin, swap);
  311|   284k|      }
  312|   284k|      if (!_mm_testz_si128(nextin, v_ff80)) {
  ------------------
  |  Branch (312:11): [True: 51.3k, False: 233k]
  ------------------
  313|       |        // 1. pack the bytes
  314|       |        // obviously suboptimal.
  315|  51.3k|        const __m128i utf8_packed = _mm_packus_epi16(in, in);
  316|       |        // 2. store (16 bytes)
  317|  51.3k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  318|       |        // 3. adjust pointers
  319|  51.3k|        buf += 8;
  320|  51.3k|        utf8_output += 8;
  321|  51.3k|        in = nextin;
  322|   233k|      } else {
  323|       |        // 1. pack the bytes
  324|       |        // obviously suboptimal.
  325|   233k|        const __m128i utf8_packed = _mm_packus_epi16(in, nextin);
  326|       |        // 2. store (16 bytes)
  327|   233k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  328|       |        // 3. adjust pointers
  329|   233k|        buf += 16;
  330|   233k|        utf8_output += 16;
  331|   233k|        continue; // we are done for this round!
  332|   233k|      }
  333|   284k|    }
  334|       |
  335|       |    // no bits set above 7th bit
  336|   251k|    const __m128i one_byte_bytemask =
  337|   251k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_ff80), v_0000);
  338|   251k|    const uint16_t one_byte_bitmask =
  339|   251k|        static_cast<uint16_t>(_mm_movemask_epi8(one_byte_bytemask));
  340|       |
  341|       |    // no bits set above 11th bit
  342|   251k|    const __m128i one_or_two_bytes_bytemask =
  343|   251k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_0000);
  344|   251k|    const uint16_t one_or_two_bytes_bitmask =
  345|   251k|        static_cast<uint16_t>(_mm_movemask_epi8(one_or_two_bytes_bytemask));
  346|       |
  347|   251k|    if (one_or_two_bytes_bitmask == 0xffff) {
  ------------------
  |  Branch (347:9): [True: 61.5k, False: 189k]
  ------------------
  348|  61.5k|      internal::westmere::write_v_u16_11bits_to_utf8(
  349|  61.5k|          in, utf8_output, one_byte_bytemask, one_byte_bitmask);
  350|  61.5k|      buf += 8;
  351|  61.5k|      continue;
  352|  61.5k|    }
  353|       |
  354|       |    // 1. Check if there are any surrogate word in the input chunk.
  355|       |    //    We have also deal with situation when there is a surrogate word
  356|       |    //    at the end of a chunk.
  357|   189k|    const __m128i surrogates_bytemask =
  358|   189k|        _mm_cmpeq_epi16(_mm_and_si128(in, v_f800), v_d800);
  359|       |
  360|       |    // bitmask = 0x0000 if there are no surrogates
  361|       |    //         = 0xc000 if the last word is a surrogate
  362|   189k|    const uint16_t surrogates_bitmask =
  363|   189k|        static_cast<uint16_t>(_mm_movemask_epi8(surrogates_bytemask));
  364|       |    // It might seem like checking for surrogates_bitmask == 0xc000 could help.
  365|       |    // However, it is likely an uncommon occurrence.
  366|   189k|    if (surrogates_bitmask == 0x0000) {
  ------------------
  |  Branch (366:9): [True: 181k, False: 8.51k]
  ------------------
  367|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  368|   181k|      const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606,
  369|   181k|                                              0x0808, 0x0a0a, 0x0c0c, 0x0e0e);
  370|       |
  371|       |      /* In this branch we handle three cases:
  372|       |         1. [0000|0000|0ccc|cccc] => [0ccc|cccc]                           -
  373|       |        single UFT-8 byte
  374|       |         2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc]              - two
  375|       |        UTF-8 bytes
  376|       |         3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] -
  377|       |        three UTF-8 bytes
  378|       |
  379|       |        We expand the input word (16-bit) into two code units (32-bit), thus
  380|       |        we have room for four bytes. However, we need five distinct bit
  381|       |        layouts. Note that the last byte in cases #2 and #3 is the same.
  382|       |
  383|       |        We precompute byte 1 for case #1 and the common byte for cases #2 & #3
  384|       |        in register t2.
  385|       |
  386|       |        We precompute byte 1 for case #3 and -- **conditionally** -- precompute
  387|       |        either byte 1 for case #2 or byte 2 for case #3. Note that they
  388|       |        differ by exactly one bit.
  389|       |
  390|       |        Finally from these two code units we build proper UTF-8 sequence, taking
  391|       |        into account the case (i.e, the number of bytes to write).
  392|       |      */
  393|       |      /**
  394|       |       * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce:
  395|       |       * t2 => [0ccc|cccc] [10cc|cccc]
  396|       |       * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb])
  397|       |       */
  398|   181k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  399|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  400|   181k|      const __m128i t0 = _mm_shuffle_epi8(in, dup_even);
  401|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  402|   181k|      const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  398|   181k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  403|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  404|   181k|      const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  398|   181k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  405|       |
  406|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  407|   181k|      const __m128i s0 = _mm_srli_epi16(in, 4);
  408|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  409|   181k|      const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  398|   181k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  410|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  411|   181k|      const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  398|   181k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  412|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  413|   181k|      const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  398|   181k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  414|   181k|      const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask,
  415|   181k|                                          simdutf_vec(0b0100000000000000));
  ------------------
  |  |  398|   181k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  416|   181k|      const __m128i s4 = _mm_xor_si128(s3, m0);
  417|   181k|#undef simdutf_vec
  418|       |
  419|       |      // 4. expand code units 16-bit => 32-bit
  420|   181k|      const __m128i out0 = _mm_unpacklo_epi16(t2, s4);
  421|   181k|      const __m128i out1 = _mm_unpackhi_epi16(t2, s4);
  422|       |
  423|       |      // 5. compress 32-bit code units into 1, 2 or 3 bytes -- 2 x shuffle
  424|   181k|      const uint16_t mask =
  425|   181k|          (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa);
  426|   181k|      if (mask == 0) {
  ------------------
  |  Branch (426:11): [True: 47.5k, False: 133k]
  ------------------
  427|       |        // We only have three-byte code units. Use fast path.
  428|  47.5k|        const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14,
  429|  47.5k|                                              15, 13, -1, -1, -1, -1);
  430|  47.5k|        const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle);
  431|  47.5k|        const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle);
  432|  47.5k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  433|  47.5k|        utf8_output += 12;
  434|  47.5k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  435|  47.5k|        utf8_output += 12;
  436|  47.5k|        buf += 8;
  437|  47.5k|        continue;
  438|  47.5k|      }
  439|   133k|      const uint8_t mask0 = uint8_t(mask);
  440|       |
  441|   133k|      const uint8_t *row0 =
  442|   133k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  443|   133k|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  444|   133k|      const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0);
  445|       |
  446|   133k|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  447|       |
  448|   133k|      const uint8_t *row1 =
  449|   133k|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  450|   133k|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  451|   133k|      const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1);
  452|       |
  453|   133k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  454|   133k|      utf8_output += row0[0];
  455|   133k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  456|   133k|      utf8_output += row1[0];
  457|       |
  458|   133k|      buf += 8;
  459|       |      // surrogate pair(s) in a register
  460|   133k|    } else {
  461|       |      // Let us do a scalar fallback.
  462|       |      // It may seem wasteful to use scalar code, but being efficient with SIMD
  463|       |      // in the presence of surrogate pairs may require non-trivial tables.
  464|  8.51k|      size_t forward = 15;
  465|  8.51k|      size_t k = 0;
  466|  8.51k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (466:11): [True: 0, False: 8.51k]
  ------------------
  467|      0|        forward = size_t(end - buf - 1);
  468|      0|      }
  469|   123k|      for (; k < forward; k++) {
  ------------------
  |  Branch (469:14): [True: 114k, False: 8.40k]
  ------------------
  470|   114k|        uint16_t word = scalar::utf16::swap_if_needed<big_endian>(buf[k]);
  471|   114k|        if ((word & 0xFF80) == 0) {
  ------------------
  |  Branch (471:13): [True: 37.8k, False: 76.7k]
  ------------------
  472|  37.8k|          *utf8_output++ = char(word);
  473|  76.7k|        } else if ((word & 0xF800) == 0) {
  ------------------
  |  Branch (473:20): [True: 6.42k, False: 70.3k]
  ------------------
  474|  6.42k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  475|  6.42k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  476|  70.3k|        } else if ((word & 0xF800) != 0xD800) {
  ------------------
  |  Branch (476:20): [True: 57.8k, False: 12.5k]
  ------------------
  477|  57.8k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  478|  57.8k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  479|  57.8k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  480|  57.8k|        } else {
  481|       |          // must be a surrogate pair
  482|  12.5k|          uint16_t diff = uint16_t(word - 0xD800);
  483|  12.5k|          uint16_t next_word =
  484|  12.5k|              scalar::utf16::swap_if_needed<big_endian>(buf[k + 1]);
  485|  12.5k|          k++;
  486|  12.5k|          uint16_t diff2 = uint16_t(next_word - 0xDC00);
  487|  12.5k|          if ((diff | diff2) > 0x3FF) {
  ------------------
  |  Branch (487:15): [True: 112, False: 12.4k]
  ------------------
  488|    112|            return std::make_pair(
  489|    112|                result(error_code::SURROGATE, buf - start + k - 1),
  490|    112|                utf8_output);
  491|    112|          }
  492|  12.4k|          uint32_t value = (diff << 10) + diff2 + 0x10000;
  493|  12.4k|          *utf8_output++ = char((value >> 18) | 0b11110000);
  494|  12.4k|          *utf8_output++ = char(((value >> 12) & 0b111111) | 0b10000000);
  495|  12.4k|          *utf8_output++ = char(((value >> 6) & 0b111111) | 0b10000000);
  496|  12.4k|          *utf8_output++ = char((value & 0b111111) | 0b10000000);
  497|  12.4k|        }
  498|   114k|      }
  499|  8.40k|      buf += k;
  500|  8.40k|    }
  501|   189k|  } // while
  502|       |
  503|    428|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output);
  504|    540|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_127sse_convert_utf32_to_latin1EPKDimPc:
    3|    190|                            char *latin1_output) {
    4|    190|  const size_t rounded_len = len & ~0xF; // Round down to nearest multiple of 16
    5|       |
    6|    190|  __m128i high_bytes_mask = _mm_set1_epi32(0xFFFFFF00);
    7|    190|  __m128i shufmask =
    8|    190|      _mm_set_epi8(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, 8, 4, 0);
    9|       |
   10|  3.41k|  for (size_t i = 0; i < rounded_len; i += 16) {
  ------------------
  |  Branch (10:22): [True: 3.27k, False: 136]
  ------------------
   11|  3.27k|    __m128i in1 = _mm_loadu_si128((__m128i *)buf);
   12|  3.27k|    __m128i in2 = _mm_loadu_si128((__m128i *)(buf + 4));
   13|  3.27k|    __m128i in3 = _mm_loadu_si128((__m128i *)(buf + 8));
   14|  3.27k|    __m128i in4 = _mm_loadu_si128((__m128i *)(buf + 12));
   15|       |
   16|  3.27k|    __m128i check_combined = _mm_or_si128(in1, in2);
   17|  3.27k|    check_combined = _mm_or_si128(check_combined, in3);
   18|  3.27k|    check_combined = _mm_or_si128(check_combined, in4);
   19|       |
   20|  3.27k|    if (!_mm_testz_si128(check_combined, high_bytes_mask)) {
  ------------------
  |  Branch (20:9): [True: 54, False: 3.22k]
  ------------------
   21|     54|      return std::make_pair(nullptr, latin1_output);
   22|     54|    }
   23|  3.22k|    __m128i pack1 = _mm_unpacklo_epi32(_mm_shuffle_epi8(in1, shufmask),
   24|  3.22k|                                       _mm_shuffle_epi8(in2, shufmask));
   25|  3.22k|    __m128i pack2 = _mm_unpacklo_epi32(_mm_shuffle_epi8(in3, shufmask),
   26|  3.22k|                                       _mm_shuffle_epi8(in4, shufmask));
   27|  3.22k|    __m128i pack = _mm_unpacklo_epi64(pack1, pack2);
   28|  3.22k|    _mm_storeu_si128((__m128i *)latin1_output, pack);
   29|  3.22k|    latin1_output += 16;
   30|  3.22k|    buf += 16;
   31|  3.22k|  }
   32|       |
   33|    136|  return std::make_pair(buf, latin1_output);
   34|    190|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_139sse_convert_utf32_to_latin1_with_errorsEPKDimPc:
   38|    344|                                        char *latin1_output) {
   39|    344|  const char32_t *start = buf;
   40|    344|  const size_t rounded_len = len & ~0xF; // Round down to nearest multiple of 16
   41|       |
   42|    344|  __m128i high_bytes_mask = _mm_set1_epi32(0xFFFFFF00);
   43|    344|  __m128i shufmask =
   44|    344|      _mm_set_epi8(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, 8, 4, 0);
   45|       |
   46|  34.6k|  for (size_t i = 0; i < rounded_len; i += 16) {
  ------------------
  |  Branch (46:22): [True: 34.4k, False: 232]
  ------------------
   47|  34.4k|    __m128i in1 = _mm_loadu_si128((__m128i *)buf);
   48|  34.4k|    __m128i in2 = _mm_loadu_si128((__m128i *)(buf + 4));
   49|  34.4k|    __m128i in3 = _mm_loadu_si128((__m128i *)(buf + 8));
   50|  34.4k|    __m128i in4 = _mm_loadu_si128((__m128i *)(buf + 12));
   51|       |
   52|  34.4k|    __m128i check_combined = _mm_or_si128(in1, in2);
   53|  34.4k|    check_combined = _mm_or_si128(check_combined, in3);
   54|  34.4k|    check_combined = _mm_or_si128(check_combined, in4);
   55|       |
   56|  34.4k|    if (!_mm_testz_si128(check_combined, high_bytes_mask)) {
  ------------------
  |  Branch (56:9): [True: 112, False: 34.3k]
  ------------------
   57|       |      // Fallback to scalar code for handling errors
   58|    472|      for (int k = 0; k < 16; k++) {
  ------------------
  |  Branch (58:23): [True: 472, False: 0]
  ------------------
   59|    472|        char32_t codepoint = buf[k];
   60|    472|        if (codepoint <= 0xff) {
  ------------------
  |  Branch (60:13): [True: 360, False: 112]
  ------------------
   61|    360|          *latin1_output++ = char(codepoint);
   62|    360|        } else {
   63|    112|          return std::make_pair(result(error_code::TOO_LARGE, buf - start + k),
   64|    112|                                latin1_output);
   65|    112|        }
   66|    472|      }
   67|      0|      buf += 16;
   68|      0|      continue;
   69|    112|    }
   70|  34.3k|    __m128i pack1 = _mm_unpacklo_epi32(_mm_shuffle_epi8(in1, shufmask),
   71|  34.3k|                                       _mm_shuffle_epi8(in2, shufmask));
   72|  34.3k|    __m128i pack2 = _mm_unpacklo_epi32(_mm_shuffle_epi8(in3, shufmask),
   73|  34.3k|                                       _mm_shuffle_epi8(in4, shufmask));
   74|  34.3k|    __m128i pack = _mm_unpacklo_epi64(pack1, pack2);
   75|  34.3k|    _mm_storeu_si128((__m128i *)latin1_output, pack);
   76|  34.3k|    latin1_output += 16;
   77|  34.3k|    buf += 16;
   78|  34.3k|  }
   79|       |
   80|    232|  return std::make_pair(result(error_code::SUCCESS, buf - start),
   81|    232|                        latin1_output);
   82|    344|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_126sse_convert_utf32_to_utf16ILNS_10endiannessE0EEENSt3__14pairIPKDiPDsEES7_mS8_:
   58|    644|                           char16_t *utf16_output) {
   59|       |
   60|    644|  const char32_t *end = buf + len;
   61|       |
   62|    644|  const __m128i v_ffff0000 = _mm_set1_epi32((int32_t)0xffff0000);
   63|    644|  __m128i forbidden_bytemask = _mm_setzero_si128();
   64|       |
   65|   166k|  while (end - buf >= 16 + 8) {
  ------------------
  |  Branch (65:10): [True: 165k, False: 596]
  ------------------
   66|   165k|    const __m128i *ptr = reinterpret_cast<const __m128i *>(buf);
   67|   165k|    const __m128i in0 = _mm_loadu_si128(ptr + 0);
   68|   165k|    const __m128i in1 = _mm_loadu_si128(ptr + 1);
   69|   165k|    const __m128i in2 = _mm_loadu_si128(ptr + 2);
   70|   165k|    const __m128i in3 = _mm_loadu_si128(ptr + 3);
   71|       |
   72|   165k|    const __m128i combined =
   73|   165k|        _mm_or_si128(_mm_or_si128(in2, in3), _mm_or_si128(in0, in1));
   74|   165k|    if (simdutf_likely(_mm_testz_si128(combined, v_ffff0000))) {
  ------------------
  |  |   90|   165k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 164k, False: 1.22k]
  |  |  ------------------
  ------------------
   75|       |      // No bits set above 16th, directly pack UTF-32 to UTF-16
   76|   164k|      __m128i utf16_packed0 = _mm_packus_epi32(in0, in1);
   77|   164k|      __m128i utf16_packed1 = _mm_packus_epi32(in2, in3);
   78|       |
   79|   164k|      const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800);
   80|   164k|      const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800);
   81|   164k|      forbidden_bytemask = _mm_or_si128(
   82|   164k|          forbidden_bytemask,
   83|   164k|          _mm_or_si128(
   84|   164k|              _mm_cmpeq_epi16(_mm_and_si128(utf16_packed0, v_f800), v_d800),
   85|   164k|              _mm_cmpeq_epi16(_mm_and_si128(utf16_packed1, v_f800), v_d800)));
   86|       |
   87|   164k|      if (big_endian) {
  ------------------
  |  Branch (87:11): [Folded, False: 164k]
  ------------------
   88|      0|        const __m128i swap =
   89|      0|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   90|      0|        utf16_packed0 = _mm_shuffle_epi8(utf16_packed0, swap);
   91|      0|        utf16_packed1 = _mm_shuffle_epi8(utf16_packed1, swap);
   92|      0|      }
   93|       |
   94|   164k|      _mm_storeu_si128((__m128i *)utf16_output + 0, utf16_packed0);
   95|   164k|      _mm_storeu_si128((__m128i *)utf16_output + 1, utf16_packed1);
   96|   164k|      utf16_output += 16;
   97|   164k|      buf += 16;
   98|   164k|    } else {
   99|  1.22k|      if (!validate_utf32(in0, in1) || !validate_utf32(in2, in3)) {
  ------------------
  |  Branch (99:11): [True: 30, False: 1.19k]
  |  Branch (99:40): [True: 18, False: 1.17k]
  ------------------
  100|     48|        return std::make_pair(nullptr, utf16_output);
  101|     48|      }
  102|       |
  103|  1.17k|      const auto ret0 = sse_expand_surrogate<big_endian>(in0);
  104|  1.17k|      _mm_storeu_si128((__m128i *)utf16_output, ret0.compressed);
  105|  1.17k|      utf16_output += ret0.u16count;
  106|       |
  107|  1.17k|      const auto ret1 = sse_expand_surrogate<big_endian>(in1);
  108|  1.17k|      _mm_storeu_si128((__m128i *)utf16_output, ret1.compressed);
  109|  1.17k|      utf16_output += ret1.u16count;
  110|       |
  111|  1.17k|      const auto ret2 = sse_expand_surrogate<big_endian>(in2);
  112|  1.17k|      _mm_storeu_si128((__m128i *)utf16_output, ret2.compressed);
  113|  1.17k|      utf16_output += ret2.u16count;
  114|       |
  115|  1.17k|      const auto ret3 = sse_expand_surrogate<big_endian>(in3);
  116|  1.17k|      _mm_storeu_si128((__m128i *)utf16_output, ret3.compressed);
  117|  1.17k|      utf16_output += ret3.u16count;
  118|       |
  119|  1.17k|      buf += 16;
  120|  1.17k|    }
  121|   165k|  }
  122|       |
  123|       |  // check for invalid input
  124|    596|  if (static_cast<uint32_t>(_mm_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (124:7): [True: 14, False: 582]
  ------------------
  125|     14|    return std::make_pair(nullptr, utf16_output);
  126|     14|  }
  127|       |
  128|    582|  return std::make_pair(buf, utf16_output);
  129|    596|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_114validate_utf32EDv2_xS2_:
   37|  3.15k|simdutf_really_inline bool validate_utf32(const __m128i a, const __m128i b) {
   38|  3.15k|  using vector_u32 = simd32<uint32_t>;
   39|       |
   40|  3.15k|  const auto in0 = vector_u32(a);
   41|  3.15k|  const auto in1 = vector_u32(b);
   42|       |
   43|  3.15k|  const auto standardmax = vector_u32::splat(0x10ffff);
   44|  3.15k|  const auto offset = vector_u32::splat(0xffff2000);
   45|  3.15k|  const auto standardoffsetmax = vector_u32::splat(0xfffff7ff);
   46|       |
   47|  3.15k|  const auto too_large = max(in0, in1) > standardmax;
   48|  3.15k|  const auto surrogate0 = (in0 + offset) > standardoffsetmax;
   49|  3.15k|  const auto surrogate1 = (in1 + offset) > standardoffsetmax;
   50|       |
   51|  3.15k|  const auto combined = too_large | surrogate0 | surrogate1;
   52|  3.15k|  return !combined.any();
   53|  3.15k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_120sse_expand_surrogateILNS_10endiannessE0EEENS1_18expansion_result_tEDv2_x:
    9|  4.71k|expansion_result_t sse_expand_surrogate(const __m128i x) {
   10|  4.71k|  using vector_u32 = simd32<uint32_t>;
   11|  4.71k|  using vector_u8 = simd8<uint8_t>;
   12|       |
   13|  4.71k|  const auto in = vector_u32(x);
   14|       |
   15|  4.71k|  const auto non_surrogate_mask = (in & uint32_t(0xffff0000)) == uint32_t(0);
   16|  4.71k|  const auto mask = (~non_surrogate_mask.to_4bit_bitmask()) & 0xf;
   17|       |
   18|  4.71k|  const auto t0 = in - uint32_t(0x00010000);
   19|  4.71k|  const auto hi = t0.shr<10>() & uint32_t(0x000003ff);
   20|  4.71k|  const auto lo = t0.shl<16>() & uint32_t(0x03ff0000);
   21|  4.71k|  const auto surrogates = (lo | hi) | uint32_t(0xdc00d800);
   22|       |
   23|  4.71k|  const auto merged = as_vector_u8(select(non_surrogate_mask, in, surrogates));
   24|       |
   25|  4.71k|  const auto shuffle = vector_u8::load(
   26|  4.71k|      (byte_order == endianness::LITTLE)
  ------------------
  |  Branch (26:7): [True: 4.71k, Folded]
  ------------------
   27|  4.71k|          ? tables::utf32_to_utf16::pack_utf32_to_utf16le[mask]
   28|  4.71k|          : tables::utf32_to_utf16::pack_utf32_to_utf16be[mask]);
   29|       |
   30|  4.71k|  const size_t u16count = (4 + count_ones(mask));
   31|  4.71k|  const auto compressed = shuffle.lookup_16(merged);
   32|       |
   33|  4.71k|  return {u16count, compressed};
   34|  4.71k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_126sse_convert_utf32_to_utf16ILNS_10endiannessE1EEENSt3__14pairIPKDiPDsEES7_mS8_:
   58|    462|                           char16_t *utf16_output) {
   59|       |
   60|    462|  const char32_t *end = buf + len;
   61|       |
   62|    462|  const __m128i v_ffff0000 = _mm_set1_epi32((int32_t)0xffff0000);
   63|    462|  __m128i forbidden_bytemask = _mm_setzero_si128();
   64|       |
   65|  1.17k|  while (end - buf >= 16 + 8) {
  ------------------
  |  Branch (65:10): [True: 734, False: 440]
  ------------------
   66|    734|    const __m128i *ptr = reinterpret_cast<const __m128i *>(buf);
   67|    734|    const __m128i in0 = _mm_loadu_si128(ptr + 0);
   68|    734|    const __m128i in1 = _mm_loadu_si128(ptr + 1);
   69|    734|    const __m128i in2 = _mm_loadu_si128(ptr + 2);
   70|    734|    const __m128i in3 = _mm_loadu_si128(ptr + 3);
   71|       |
   72|    734|    const __m128i combined =
   73|    734|        _mm_or_si128(_mm_or_si128(in2, in3), _mm_or_si128(in0, in1));
   74|    734|    if (simdutf_likely(_mm_testz_si128(combined, v_ffff0000))) {
  ------------------
  |  |   90|    734|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 362, False: 372]
  |  |  ------------------
  ------------------
   75|       |      // No bits set above 16th, directly pack UTF-32 to UTF-16
   76|    362|      __m128i utf16_packed0 = _mm_packus_epi32(in0, in1);
   77|    362|      __m128i utf16_packed1 = _mm_packus_epi32(in2, in3);
   78|       |
   79|    362|      const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800);
   80|    362|      const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800);
   81|    362|      forbidden_bytemask = _mm_or_si128(
   82|    362|          forbidden_bytemask,
   83|    362|          _mm_or_si128(
   84|    362|              _mm_cmpeq_epi16(_mm_and_si128(utf16_packed0, v_f800), v_d800),
   85|    362|              _mm_cmpeq_epi16(_mm_and_si128(utf16_packed1, v_f800), v_d800)));
   86|       |
   87|    362|      if (big_endian) {
  ------------------
  |  Branch (87:11): [True: 362, Folded]
  ------------------
   88|    362|        const __m128i swap =
   89|    362|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   90|    362|        utf16_packed0 = _mm_shuffle_epi8(utf16_packed0, swap);
   91|    362|        utf16_packed1 = _mm_shuffle_epi8(utf16_packed1, swap);
   92|    362|      }
   93|       |
   94|    362|      _mm_storeu_si128((__m128i *)utf16_output + 0, utf16_packed0);
   95|    362|      _mm_storeu_si128((__m128i *)utf16_output + 1, utf16_packed1);
   96|    362|      utf16_output += 16;
   97|    362|      buf += 16;
   98|    372|    } else {
   99|    372|      if (!validate_utf32(in0, in1) || !validate_utf32(in2, in3)) {
  ------------------
  |  Branch (99:11): [True: 8, False: 364]
  |  Branch (99:40): [True: 14, False: 350]
  ------------------
  100|     22|        return std::make_pair(nullptr, utf16_output);
  101|     22|      }
  102|       |
  103|    350|      const auto ret0 = sse_expand_surrogate<big_endian>(in0);
  104|    350|      _mm_storeu_si128((__m128i *)utf16_output, ret0.compressed);
  105|    350|      utf16_output += ret0.u16count;
  106|       |
  107|    350|      const auto ret1 = sse_expand_surrogate<big_endian>(in1);
  108|    350|      _mm_storeu_si128((__m128i *)utf16_output, ret1.compressed);
  109|    350|      utf16_output += ret1.u16count;
  110|       |
  111|    350|      const auto ret2 = sse_expand_surrogate<big_endian>(in2);
  112|    350|      _mm_storeu_si128((__m128i *)utf16_output, ret2.compressed);
  113|    350|      utf16_output += ret2.u16count;
  114|       |
  115|    350|      const auto ret3 = sse_expand_surrogate<big_endian>(in3);
  116|    350|      _mm_storeu_si128((__m128i *)utf16_output, ret3.compressed);
  117|    350|      utf16_output += ret3.u16count;
  118|       |
  119|    350|      buf += 16;
  120|    350|    }
  121|    734|  }
  122|       |
  123|       |  // check for invalid input
  124|    440|  if (static_cast<uint32_t>(_mm_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (124:7): [True: 6, False: 434]
  ------------------
  125|      6|    return std::make_pair(nullptr, utf16_output);
  126|      6|  }
  127|       |
  128|    434|  return std::make_pair(buf, utf16_output);
  129|    440|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_120sse_expand_surrogateILNS_10endiannessE1EEENS1_18expansion_result_tEDv2_x:
    9|  1.40k|expansion_result_t sse_expand_surrogate(const __m128i x) {
   10|  1.40k|  using vector_u32 = simd32<uint32_t>;
   11|  1.40k|  using vector_u8 = simd8<uint8_t>;
   12|       |
   13|  1.40k|  const auto in = vector_u32(x);
   14|       |
   15|  1.40k|  const auto non_surrogate_mask = (in & uint32_t(0xffff0000)) == uint32_t(0);
   16|  1.40k|  const auto mask = (~non_surrogate_mask.to_4bit_bitmask()) & 0xf;
   17|       |
   18|  1.40k|  const auto t0 = in - uint32_t(0x00010000);
   19|  1.40k|  const auto hi = t0.shr<10>() & uint32_t(0x000003ff);
   20|  1.40k|  const auto lo = t0.shl<16>() & uint32_t(0x03ff0000);
   21|  1.40k|  const auto surrogates = (lo | hi) | uint32_t(0xdc00d800);
   22|       |
   23|  1.40k|  const auto merged = as_vector_u8(select(non_surrogate_mask, in, surrogates));
   24|       |
   25|  1.40k|  const auto shuffle = vector_u8::load(
   26|  1.40k|      (byte_order == endianness::LITTLE)
  ------------------
  |  Branch (26:7): [Folded, False: 1.40k]
  ------------------
   27|  1.40k|          ? tables::utf32_to_utf16::pack_utf32_to_utf16le[mask]
   28|  1.40k|          : tables::utf32_to_utf16::pack_utf32_to_utf16be[mask]);
   29|       |
   30|  1.40k|  const size_t u16count = (4 + count_ones(mask));
   31|  1.40k|  const auto compressed = shuffle.lookup_16(merged);
   32|       |
   33|  1.40k|  return {u16count, compressed};
   34|  1.40k|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_138sse_convert_utf32_to_utf16_with_errorsILNS_10endiannessE0EEENSt3__14pairINS_6resultEPDsEEPKDimS7_:
  134|    622|                                       char16_t *utf16_output) {
  135|    622|  const char32_t *start = buf;
  136|    622|  const char32_t *end = buf + len;
  137|       |
  138|    622|  const __m128i v_ffff0000 = _mm_set1_epi32((int32_t)0xffff0000);
  139|       |
  140|  2.52k|  while (end - buf >= 8) {
  ------------------
  |  Branch (140:10): [True: 2.22k, False: 304]
  ------------------
  141|  2.22k|    const __m128i in = _mm_loadu_si128((__m128i *)buf);
  142|  2.22k|    const __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
  143|       |
  144|  2.22k|    const __m128i combined = _mm_or_si128(in, nextin);
  145|  2.22k|    if (simdutf_likely(_mm_testz_si128(combined, v_ffff0000))) {
  ------------------
  |  |   90|  2.22k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 1.26k, False: 958]
  |  |  ------------------
  ------------------
  146|       |      // No bits set above 16th, directly pack UTF-32 to UTF-16
  147|  1.26k|      __m128i utf16_packed = _mm_packus_epi32(in, nextin);
  148|       |
  149|  1.26k|      const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800);
  150|  1.26k|      const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800);
  151|  1.26k|      const __m128i forbidden_bytemask =
  152|  1.26k|          _mm_cmpeq_epi16(_mm_and_si128(utf16_packed, v_f800), v_d800);
  153|  1.26k|      if (static_cast<uint32_t>(_mm_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (153:11): [True: 40, False: 1.22k]
  ------------------
  154|     40|        return std::make_pair(result(error_code::SURROGATE, buf - start),
  155|     40|                              utf16_output);
  156|     40|      }
  157|       |
  158|  1.22k|      if (big_endian) {
  ------------------
  |  Branch (158:11): [Folded, False: 1.22k]
  ------------------
  159|      0|        const __m128i swap =
  160|      0|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  161|      0|        utf16_packed = _mm_shuffle_epi8(utf16_packed, swap);
  162|      0|      }
  163|       |
  164|  1.22k|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
  165|  1.22k|      utf16_output += 8;
  166|  1.22k|      buf += 8;
  167|  1.22k|    } else {
  168|    958|      size_t forward = 7;
  169|    958|      size_t k = 0;
  170|    958|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (170:11): [True: 0, False: 958]
  ------------------
  171|      0|        forward = size_t(end - buf - 1);
  172|      0|      }
  173|  6.31k|      for (; k < forward; k++) {
  ------------------
  |  Branch (173:14): [True: 5.63k, False: 680]
  ------------------
  174|  5.63k|        uint32_t word = buf[k];
  175|  5.63k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (175:13): [True: 2.82k, False: 2.81k]
  ------------------
  176|       |          // will not generate a surrogate pair
  177|  2.82k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (177:15): [True: 580, False: 2.24k]
  |  Branch (177:33): [True: 36, False: 544]
  ------------------
  178|     36|            return std::make_pair(
  179|     36|                result(error_code::SURROGATE, buf - start + k), utf16_output);
  180|     36|          }
  181|  2.78k|          *utf16_output++ =
  182|  2.78k|              big_endian
  ------------------
  |  Branch (182:15): [Folded, False: 2.78k]
  ------------------
  183|  2.78k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
  184|  2.78k|                  : char16_t(word);
  185|  2.81k|        } else {
  186|       |          // will generate a surrogate pair
  187|  2.81k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (187:15): [True: 242, False: 2.57k]
  ------------------
  188|    242|            return std::make_pair(
  189|    242|                result(error_code::TOO_LARGE, buf - start + k), utf16_output);
  190|    242|          }
  191|  2.57k|          word -= 0x10000;
  192|  2.57k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
  193|  2.57k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
  194|  2.57k|          if (big_endian) {
  ------------------
  |  Branch (194:15): [Folded, False: 2.57k]
  ------------------
  195|      0|            high_surrogate =
  196|      0|                uint16_t((high_surrogate >> 8) | (high_surrogate << 8));
  197|      0|            low_surrogate =
  198|      0|                uint16_t((low_surrogate >> 8) | (low_surrogate << 8));
  199|      0|          }
  200|  2.57k|          *utf16_output++ = char16_t(high_surrogate);
  201|  2.57k|          *utf16_output++ = char16_t(low_surrogate);
  202|  2.57k|        }
  203|  5.63k|      }
  204|    680|      buf += k;
  205|    680|    }
  206|  2.22k|  }
  207|       |
  208|    304|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf16_output);
  209|    622|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_138sse_convert_utf32_to_utf16_with_errorsILNS_10endiannessE1EEENSt3__14pairINS_6resultEPDsEEPKDimS7_:
  134|    570|                                       char16_t *utf16_output) {
  135|    570|  const char32_t *start = buf;
  136|    570|  const char32_t *end = buf + len;
  137|       |
  138|    570|  const __m128i v_ffff0000 = _mm_set1_epi32((int32_t)0xffff0000);
  139|       |
  140|  1.58k|  while (end - buf >= 8) {
  ------------------
  |  Branch (140:10): [True: 1.30k, False: 280]
  ------------------
  141|  1.30k|    const __m128i in = _mm_loadu_si128((__m128i *)buf);
  142|  1.30k|    const __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
  143|       |
  144|  1.30k|    const __m128i combined = _mm_or_si128(in, nextin);
  145|  1.30k|    if (simdutf_likely(_mm_testz_si128(combined, v_ffff0000))) {
  ------------------
  |  |   90|  1.30k|    #define simdutf_likely(x) __builtin_expect(!!(x), 1)
  |  |  ------------------
  |  |  |  Branch (90:31): [True: 424, False: 878]
  |  |  ------------------
  ------------------
  146|       |      // No bits set above 16th, directly pack UTF-32 to UTF-16
  147|    424|      __m128i utf16_packed = _mm_packus_epi32(in, nextin);
  148|       |
  149|    424|      const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800);
  150|    424|      const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800);
  151|    424|      const __m128i forbidden_bytemask =
  152|    424|          _mm_cmpeq_epi16(_mm_and_si128(utf16_packed, v_f800), v_d800);
  153|    424|      if (static_cast<uint32_t>(_mm_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (153:11): [True: 16, False: 408]
  ------------------
  154|     16|        return std::make_pair(result(error_code::SURROGATE, buf - start),
  155|     16|                              utf16_output);
  156|     16|      }
  157|       |
  158|    408|      if (big_endian) {
  ------------------
  |  Branch (158:11): [True: 408, Folded]
  ------------------
  159|    408|        const __m128i swap =
  160|    408|            _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
  161|    408|        utf16_packed = _mm_shuffle_epi8(utf16_packed, swap);
  162|    408|      }
  163|       |
  164|    408|      _mm_storeu_si128((__m128i *)utf16_output, utf16_packed);
  165|    408|      utf16_output += 8;
  166|    408|      buf += 8;
  167|    878|    } else {
  168|    878|      size_t forward = 7;
  169|    878|      size_t k = 0;
  170|    878|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (170:11): [True: 0, False: 878]
  ------------------
  171|      0|        forward = size_t(end - buf - 1);
  172|      0|      }
  173|  5.68k|      for (; k < forward; k++) {
  ------------------
  |  Branch (173:14): [True: 5.07k, False: 604]
  ------------------
  174|  5.07k|        uint32_t word = buf[k];
  175|  5.07k|        if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (175:13): [True: 2.57k, False: 2.50k]
  ------------------
  176|       |          // will not generate a surrogate pair
  177|  2.57k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (177:15): [True: 1.00k, False: 1.57k]
  |  Branch (177:33): [True: 42, False: 958]
  ------------------
  178|     42|            return std::make_pair(
  179|     42|                result(error_code::SURROGATE, buf - start + k), utf16_output);
  180|     42|          }
  181|  2.53k|          *utf16_output++ =
  182|  2.53k|              big_endian
  ------------------
  |  Branch (182:15): [True: 2.53k, Folded]
  ------------------
  183|  2.53k|                  ? char16_t((uint16_t(word) >> 8) | (uint16_t(word) << 8))
  184|  2.53k|                  : char16_t(word);
  185|  2.53k|        } else {
  186|       |          // will generate a surrogate pair
  187|  2.50k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (187:15): [True: 232, False: 2.27k]
  ------------------
  188|    232|            return std::make_pair(
  189|    232|                result(error_code::TOO_LARGE, buf - start + k), utf16_output);
  190|    232|          }
  191|  2.27k|          word -= 0x10000;
  192|  2.27k|          uint16_t high_surrogate = uint16_t(0xD800 + (word >> 10));
  193|  2.27k|          uint16_t low_surrogate = uint16_t(0xDC00 + (word & 0x3FF));
  194|  2.27k|          if (big_endian) {
  ------------------
  |  Branch (194:15): [True: 2.27k, Folded]
  ------------------
  195|  2.27k|            high_surrogate =
  196|  2.27k|                uint16_t((high_surrogate >> 8) | (high_surrogate << 8));
  197|  2.27k|            low_surrogate =
  198|  2.27k|                uint16_t((low_surrogate >> 8) | (low_surrogate << 8));
  199|  2.27k|          }
  200|  2.27k|          *utf16_output++ = char16_t(high_surrogate);
  201|  2.27k|          *utf16_output++ = char16_t(low_surrogate);
  202|  2.27k|        }
  203|  5.07k|      }
  204|    604|      buf += k;
  205|    604|    }
  206|  1.30k|  }
  207|       |
  208|    280|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf16_output);
  209|    570|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_125sse_convert_utf32_to_utf8EPKDimPc:
    2|    786|sse_convert_utf32_to_utf8(const char32_t *buf, size_t len, char *utf8_output) {
    3|    786|  const char32_t *end = buf + len;
    4|       |
    5|    786|  const __m128i v_0000 = _mm_setzero_si128();              //__m128 = 128 bits
    6|    786|  const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800); // 1111 1000 0000
    7|       |                                                           // 0000
    8|    786|  const __m128i v_c080 = _mm_set1_epi16((uint16_t)0xc080); // 1100 0000 1000
    9|       |                                                           // 0000
   10|    786|  const __m128i v_ff80 = _mm_set1_epi16((uint16_t)0xff80); // 1111 1111 1000
   11|       |                                                           // 0000
   12|    786|  const __m128i v_ffff0000 = _mm_set1_epi32(
   13|    786|      (uint32_t)0xffff0000); // 1111 1111 1111 1111 0000 0000 0000 0000
   14|    786|  const __m128i v_7fffffff = _mm_set1_epi32(
   15|    786|      (uint32_t)0x7fffffff); // 0111 1111 1111 1111 1111 1111 1111 1111
   16|    786|  __m128i running_max = _mm_setzero_si128();
   17|    786|  __m128i forbidden_bytemask = _mm_setzero_si128();
   18|    786|  const size_t safety_margin =
   19|    786|      12; // to avoid overruns, see issue
   20|       |          // https://github.com/simdutf/simdutf/issues/92
   21|       |
   22|  37.3k|  while (end - buf >=
  ------------------
  |  Branch (22:10): [True: 36.7k, False: 620]
  ------------------
   23|  37.3k|         std::ptrdiff_t(
   24|  37.3k|             16 + safety_margin)) { // buf is a char32_t pointer, each char32_t
   25|       |                                    // has 4 bytes or 32 bits, thus buf + 16 *
   26|       |                                    // char_32t = 512 bits = 64 bytes
   27|       |    // We load two 16 bytes registers for a total of 32 bytes or 16 characters.
   28|  36.7k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
   29|  36.7k|    __m128i nextin = _mm_loadu_si128(
   30|  36.7k|        (__m128i *)buf + 1); // These two values can hold only 8 UTF32 chars
   31|  36.7k|    running_max = _mm_max_epu32(
   32|  36.7k|        _mm_max_epu32(in, running_max), // take element-wise max char32_t from
   33|       |                                        // in and running_max vector
   34|  36.7k|        nextin); // and take element-wise max element from nextin and
   35|       |                 // running_max vector
   36|       |
   37|       |    // Pack 32-bit UTF-32 code units to 16-bit UTF-16 code units with unsigned
   38|       |    // saturation
   39|  36.7k|    __m128i in_16 = _mm_packus_epi32(
   40|  36.7k|        _mm_and_si128(in, v_7fffffff),
   41|  36.7k|        _mm_and_si128(
   42|  36.7k|            nextin,
   43|  36.7k|            v_7fffffff)); // in this context pack the two __m128 into a single
   44|       |    // By ensuring the highest bit is set to 0(&v_7fffffff), we are making sure
   45|       |    // all values are interpreted as non-negative, or specifically, the values
   46|       |    // are within the range of valid Unicode code points. remember : having
   47|       |    // leading byte 0 means a positive number by the two complements system.
   48|       |    // Unicode is well beneath the range where you'll start getting issues so
   49|       |    // that's OK.
   50|       |
   51|       |    // Try to apply UTF-16 => UTF-8 from ./sse_convert_utf16_to_utf8.cpp
   52|       |
   53|       |    // Check for ASCII fast path
   54|       |
   55|       |    // ASCII fast path!!!!
   56|       |    // We eagerly load another 32 bytes, hoping that they will be ASCII too.
   57|       |    // The intuition is that we try to collect 16 ASCII characters which
   58|       |    // requires a total of 64 bytes of input. If we fail, we just pass thirdin
   59|       |    // and fourthin as our new inputs.
   60|  36.7k|    if (_mm_testz_si128(in_16, v_ff80)) { // if the first two blocks are ASCII
  ------------------
  |  Branch (60:9): [True: 32.0k, False: 4.76k]
  ------------------
   61|  32.0k|      __m128i thirdin = _mm_loadu_si128((__m128i *)buf + 2);
   62|  32.0k|      __m128i fourthin = _mm_loadu_si128((__m128i *)buf + 3);
   63|  32.0k|      running_max = _mm_max_epu32(
   64|  32.0k|          _mm_max_epu32(thirdin, running_max),
   65|  32.0k|          fourthin); // take the running max of all 4 vectors thus far
   66|  32.0k|      __m128i nextin_16 = _mm_packus_epi32(
   67|  32.0k|          _mm_and_si128(thirdin, v_7fffffff),
   68|  32.0k|          _mm_and_si128(fourthin,
   69|  32.0k|                        v_7fffffff)); // pack into 1 vector, now you have two
   70|  32.0k|      if (!_mm_testz_si128(
  ------------------
  |  Branch (70:11): [True: 478, False: 31.5k]
  ------------------
   71|  32.0k|              nextin_16,
   72|  32.0k|              v_ff80)) { // checks if the second packed vector is ASCII, if not:
   73|       |        // 1. pack the bytes
   74|       |        // obviously suboptimal.
   75|    478|        const __m128i utf8_packed = _mm_packus_epi16(
   76|    478|            in_16, in_16); // creates two copy of in_16 in 1 vector
   77|       |        // 2. store (16 bytes)
   78|    478|        _mm_storeu_si128((__m128i *)utf8_output,
   79|    478|                         utf8_packed); // put them into the output
   80|       |        // 3. adjust pointers
   81|    478|        buf += 8; // the char32_t buffer pointer goes up 8 char32_t chars* 32
   82|       |                  // bits =  256 bits
   83|    478|        utf8_output +=
   84|    478|            8; // same with output, e.g. lift the first two blocks alone.
   85|       |        // Proceed with next input
   86|    478|        in_16 = nextin_16;
   87|       |        // We need to update in and nextin because they are used later.
   88|    478|        in = thirdin;
   89|    478|        nextin = fourthin;
   90|  31.5k|      } else {
   91|       |        // 1. pack the bytes
   92|  31.5k|        const __m128i utf8_packed = _mm_packus_epi16(in_16, nextin_16);
   93|       |        // 2. store (16 bytes)
   94|  31.5k|        _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
   95|       |        // 3. adjust pointers
   96|  31.5k|        buf += 16;
   97|  31.5k|        utf8_output += 16;
   98|  31.5k|        continue; // we are done for this round!
   99|  31.5k|      }
  100|  32.0k|    }
  101|       |
  102|       |    // no bits set above 7th bit -- find out all the ASCII characters
  103|  5.24k|    const __m128i one_byte_bytemask =
  104|  5.24k|        _mm_cmpeq_epi16( // this takes four bytes at a time and compares:
  105|  5.24k|            _mm_and_si128(in_16, v_ff80), // the vector that get only the first
  106|       |                                          // 9 bits of each 16-bit/2-byte units
  107|  5.24k|            v_0000                        //
  108|  5.24k|        ); // they should be all zero if they are ASCII. E.g. ASCII in UTF32 is
  109|       |           // of format 0000 0000 0000 0XXX XXXX
  110|       |    // _mm_cmpeq_epi16 should now return a 1111 1111 1111 1111 for equals, and
  111|       |    // 0000 0000 0000 0000 if not for each 16-bit/2-byte units
  112|  5.24k|    const uint16_t one_byte_bitmask = static_cast<uint16_t>(_mm_movemask_epi8(
  113|  5.24k|        one_byte_bytemask)); // collect the MSB from previous vector and put
  114|       |                             // them into uint16_t mas
  115|       |
  116|       |    // no bits set above 11th bit
  117|  5.24k|    const __m128i one_or_two_bytes_bytemask =
  118|  5.24k|        _mm_cmpeq_epi16(_mm_and_si128(in_16, v_f800), v_0000);
  119|  5.24k|    const uint16_t one_or_two_bytes_bitmask =
  120|  5.24k|        static_cast<uint16_t>(_mm_movemask_epi8(one_or_two_bytes_bytemask));
  121|       |
  122|  5.24k|    if (one_or_two_bytes_bitmask == 0xffff) {
  ------------------
  |  Branch (122:9): [True: 2.55k, False: 2.68k]
  ------------------
  123|       |      // case: all code units either produce 1 or 2 UTF-8 bytes (at least one
  124|       |      // produces 2 bytes)
  125|       |      // 1. prepare 2-byte values
  126|       |      // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8
  127|       |      // expected output   : [110a|aaaa|10bb|bbbb] x 8
  128|  2.55k|      const __m128i v_1f00 =
  129|  2.55k|          _mm_set1_epi16((int16_t)0x1f00); // 0001 1111 0000 0000
  130|  2.55k|      const __m128i v_003f =
  131|  2.55k|          _mm_set1_epi16((int16_t)0x003f); // 0000 0000 0011 1111
  132|       |
  133|       |      // t0 = [000a|aaaa|bbbb|bb00]
  134|  2.55k|      const __m128i t0 = _mm_slli_epi16(in_16, 2); // shift packed vector by two
  135|       |      // t1 = [000a|aaaa|0000|0000]
  136|  2.55k|      const __m128i t1 = _mm_and_si128(t0, v_1f00); // potential first utf8 byte
  137|       |      // t2 = [0000|0000|00bb|bbbb]
  138|  2.55k|      const __m128i t2 =
  139|  2.55k|          _mm_and_si128(in_16, v_003f); // potential second utf8 byte
  140|       |      // t3 = [000a|aaaa|00bb|bbbb]
  141|  2.55k|      const __m128i t3 =
  142|  2.55k|          _mm_or_si128(t1, t2); // first and second potential utf8 byte together
  143|       |      // t4 = [110a|aaaa|10bb|bbbb]
  144|  2.55k|      const __m128i t4 = _mm_or_si128(
  145|  2.55k|          t3,
  146|  2.55k|          v_c080); // t3 | 1100 0000 1000 0000 = full potential 2-byte utf8 unit
  147|       |
  148|       |      // 2. merge ASCII and 2-byte codewords
  149|  2.55k|      const __m128i utf8_unpacked =
  150|  2.55k|          _mm_blendv_epi8(t4, in_16, one_byte_bytemask);
  151|       |
  152|       |      // 3. prepare bitmask for 8-bit lookup
  153|       |      //    one_byte_bitmask = hhggffeeddccbbaa -- the bits are doubled (h -
  154|       |      //    MSB, a - LSB)
  155|  2.55k|      const uint16_t m0 = one_byte_bitmask & 0x5555; // m0 = 0h0g0f0e0d0c0b0a
  156|  2.55k|      const uint16_t m1 =
  157|  2.55k|          static_cast<uint16_t>(m0 >> 7); // m1 = 00000000h0g0f0e0
  158|  2.55k|      const uint8_t m2 =
  159|  2.55k|          static_cast<uint8_t>((m0 | m1) & 0xff); // m2 =         hdgcfbea
  160|       |      // 4. pack the bytes
  161|  2.55k|      const uint8_t *row =
  162|  2.55k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[m2][0];
  163|  2.55k|      const __m128i shuffle = _mm_loadu_si128((__m128i *)(row + 1));
  164|  2.55k|      const __m128i utf8_packed = _mm_shuffle_epi8(utf8_unpacked, shuffle);
  165|       |
  166|       |      // 5. store bytes
  167|  2.55k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  168|       |
  169|       |      // 6. adjust pointers
  170|  2.55k|      buf += 8;
  171|  2.55k|      utf8_output += row[0];
  172|  2.55k|      continue;
  173|  2.55k|    }
  174|       |
  175|       |    // Check for overflow in packing
  176|       |
  177|  2.68k|    const __m128i saturation_bytemask = _mm_cmpeq_epi32(
  178|  2.68k|        _mm_and_si128(_mm_or_si128(in, nextin), v_ffff0000), v_0000);
  179|  2.68k|    const uint32_t saturation_bitmask =
  180|  2.68k|        static_cast<uint32_t>(_mm_movemask_epi8(saturation_bytemask));
  181|  2.68k|    if (saturation_bitmask == 0xffff) {
  ------------------
  |  Branch (181:9): [True: 1.29k, False: 1.39k]
  ------------------
  182|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  183|  1.29k|      const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800);
  184|  1.29k|      forbidden_bytemask =
  185|  1.29k|          _mm_or_si128(forbidden_bytemask,
  186|  1.29k|                       _mm_cmpeq_epi16(_mm_and_si128(in_16, v_f800), v_d800));
  187|       |
  188|  1.29k|      const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606,
  189|  1.29k|                                              0x0808, 0x0a0a, 0x0c0c, 0x0e0e);
  190|       |
  191|       |      /* In this branch we handle three cases:
  192|       |          1. [0000|0000|0ccc|cccc] => [0ccc|cccc]                           -
  193|       |        single UFT-8 byte
  194|       |          2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc]              -
  195|       |        two UTF-8 bytes
  196|       |          3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] -
  197|       |        three UTF-8 bytes
  198|       |
  199|       |        We expand the input word (16-bit) into two code units (32-bit), thus
  200|       |        we have room for four bytes. However, we need five distinct bit
  201|       |        layouts. Note that the last byte in cases #2 and #3 is the same.
  202|       |
  203|       |        We precompute byte 1 for case #1 and the common byte for cases #2 & #3
  204|       |        in register t2.
  205|       |
  206|       |        We precompute byte 1 for case #3 and -- **conditionally** -- precompute
  207|       |        either byte 1 for case #2 or byte 2 for case #3. Note that they
  208|       |        differ by exactly one bit.
  209|       |
  210|       |        Finally from these two code units we build proper UTF-8 sequence, taking
  211|       |        into account the case (i.e, the number of bytes to write).
  212|       |      */
  213|       |      /**
  214|       |       * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce:
  215|       |       * t2 => [0ccc|cccc] [10cc|cccc]
  216|       |       * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb])
  217|       |       */
  218|  1.29k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  219|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  220|  1.29k|      const __m128i t0 = _mm_shuffle_epi8(in_16, dup_even);
  221|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  222|  1.29k|      const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  218|  1.29k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  223|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  224|  1.29k|      const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  218|  1.29k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  225|       |
  226|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  227|  1.29k|      const __m128i s0 = _mm_srli_epi16(in_16, 4);
  228|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  229|  1.29k|      const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  218|  1.29k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  230|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  231|  1.29k|      const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  218|  1.29k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  232|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  233|  1.29k|      const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  218|  1.29k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  234|  1.29k|      const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask,
  235|  1.29k|                                          simdutf_vec(0b0100000000000000));
  ------------------
  |  |  218|  1.29k|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  236|  1.29k|      const __m128i s4 = _mm_xor_si128(s3, m0);
  237|  1.29k|#undef simdutf_vec
  238|       |
  239|       |      // 4. expand code units 16-bit => 32-bit
  240|  1.29k|      const __m128i out0 = _mm_unpacklo_epi16(t2, s4);
  241|  1.29k|      const __m128i out1 = _mm_unpackhi_epi16(t2, s4);
  242|       |
  243|       |      // 5. compress 32-bit code units into 1, 2 or 3 bytes -- 2 x shuffle
  244|  1.29k|      const uint16_t mask =
  245|  1.29k|          (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa);
  246|  1.29k|      if (mask == 0) {
  ------------------
  |  Branch (246:11): [True: 612, False: 684]
  ------------------
  247|       |        // We only have three-byte code units. Use fast path.
  248|    612|        const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14,
  249|    612|                                              15, 13, -1, -1, -1, -1);
  250|    612|        const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle);
  251|    612|        const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle);
  252|    612|        _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  253|    612|        utf8_output += 12;
  254|    612|        _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  255|    612|        utf8_output += 12;
  256|    612|        buf += 8;
  257|    612|        continue;
  258|    612|      }
  259|    684|      const uint8_t mask0 = uint8_t(mask);
  260|       |
  261|    684|      const uint8_t *row0 =
  262|    684|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  263|    684|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  264|    684|      const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0);
  265|       |
  266|    684|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  267|       |
  268|    684|      const uint8_t *row1 =
  269|    684|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  270|    684|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  271|    684|      const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1);
  272|       |
  273|    684|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  274|    684|      utf8_output += row0[0];
  275|    684|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  276|    684|      utf8_output += row1[0];
  277|       |
  278|    684|      buf += 8;
  279|  1.39k|    } else {
  280|       |      // case: at least one 32-bit word produce a surrogate pair in UTF-16 <=>
  281|       |      // will produce four UTF-8 bytes Let us do a scalar fallback. It may seem
  282|       |      // wasteful to use scalar code, but being efficient with SIMD in the
  283|       |      // presence of surrogate pairs may require non-trivial tables.
  284|  1.39k|      size_t forward = 15;
  285|  1.39k|      size_t k = 0;
  286|  1.39k|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (286:11): [True: 0, False: 1.39k]
  ------------------
  287|      0|        forward = size_t(end - buf - 1);
  288|      0|      }
  289|  20.4k|      for (; k < forward; k++) {
  ------------------
  |  Branch (289:14): [True: 19.2k, False: 1.22k]
  ------------------
  290|  19.2k|        uint32_t word = buf[k];
  291|  19.2k|        if ((word & 0xFFFFFF80) == 0) {
  ------------------
  |  Branch (291:13): [True: 7.74k, False: 11.5k]
  ------------------
  292|  7.74k|          *utf8_output++ = char(word);
  293|  11.5k|        } else if ((word & 0xFFFFF800) == 0) {
  ------------------
  |  Branch (293:20): [True: 1.57k, False: 9.95k]
  ------------------
  294|  1.57k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  295|  1.57k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  296|  9.95k|        } else if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (296:20): [True: 3.58k, False: 6.37k]
  ------------------
  297|  3.58k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (297:15): [True: 1.14k, False: 2.43k]
  |  Branch (297:33): [True: 14, False: 1.12k]
  ------------------
  298|     14|            return std::make_pair(nullptr, utf8_output);
  299|     14|          }
  300|  3.56k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  301|  3.56k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  302|  3.56k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  303|  6.37k|        } else {
  304|  6.37k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (304:15): [True: 152, False: 6.22k]
  ------------------
  305|    152|            return std::make_pair(nullptr, utf8_output);
  306|    152|          }
  307|  6.22k|          *utf8_output++ = char((word >> 18) | 0b11110000);
  308|  6.22k|          *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000);
  309|  6.22k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  310|  6.22k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  311|  6.22k|        }
  312|  19.2k|      }
  313|  1.22k|      buf += k;
  314|  1.22k|    }
  315|  2.68k|  } // while
  316|       |
  317|       |  // check for invalid input
  318|    620|  const __m128i v_10ffff = _mm_set1_epi32((uint32_t)0x10ffff);
  319|    620|  if (static_cast<uint16_t>(_mm_movemask_epi8(_mm_cmpeq_epi32(
  ------------------
  |  Branch (319:7): [True: 22, False: 598]
  ------------------
  320|    620|          _mm_max_epu32(running_max, v_10ffff), v_10ffff))) != 0xffff) {
  321|     22|    return std::make_pair(nullptr, utf8_output);
  322|     22|  }
  323|       |
  324|    598|  if (static_cast<uint32_t>(_mm_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (324:7): [True: 52, False: 546]
  ------------------
  325|     52|    return std::make_pair(nullptr, utf8_output);
  326|     52|  }
  327|       |
  328|    546|  return std::make_pair(buf, utf8_output);
  329|    598|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_137sse_convert_utf32_to_utf8_with_errorsEPKDimPc:
  333|    772|                                      char *utf8_output) {
  334|    772|  const char32_t *end = buf + len;
  335|    772|  const char32_t *start = buf;
  336|       |
  337|    772|  const __m128i v_0000 = _mm_setzero_si128();
  338|    772|  const __m128i v_f800 = _mm_set1_epi16((uint16_t)0xf800);
  339|    772|  const __m128i v_c080 = _mm_set1_epi16((uint16_t)0xc080);
  340|    772|  const __m128i v_ff80 = _mm_set1_epi16((uint16_t)0xff80);
  341|    772|  const __m128i v_ffff0000 = _mm_set1_epi32((uint32_t)0xffff0000);
  342|    772|  const __m128i v_7fffffff = _mm_set1_epi32((uint32_t)0x7fffffff);
  343|    772|  const __m128i v_10ffff = _mm_set1_epi32((uint32_t)0x10ffff);
  344|       |
  345|    772|  const size_t safety_margin =
  346|    772|      12; // to avoid overruns, see issue
  347|       |          // https://github.com/simdutf/simdutf/issues/92
  348|       |
  349|  6.37k|  while (end - buf >= std::ptrdiff_t(16 + safety_margin)) {
  ------------------
  |  Branch (349:10): [True: 5.74k, False: 636]
  ------------------
  350|       |    // We load two 16 bytes registers for a total of 32 bytes or 8 characters.
  351|  5.74k|    __m128i in = _mm_loadu_si128((__m128i *)buf);
  352|  5.74k|    __m128i nextin = _mm_loadu_si128((__m128i *)buf + 1);
  353|       |    // Check for too large input
  354|  5.74k|    __m128i max_input = _mm_max_epu32(_mm_max_epu32(in, nextin), v_10ffff);
  355|  5.74k|    if (static_cast<uint16_t>(_mm_movemask_epi8(
  ------------------
  |  Branch (355:9): [True: 26, False: 5.71k]
  ------------------
  356|  5.74k|            _mm_cmpeq_epi32(max_input, v_10ffff))) != 0xffff) {
  357|     26|      return std::make_pair(result(error_code::TOO_LARGE, buf - start),
  358|     26|                            utf8_output);
  359|     26|    }
  360|       |
  361|       |    // Pack 32-bit UTF-32 code units to 16-bit UTF-16 code units with unsigned
  362|       |    // saturation
  363|  5.71k|    __m128i in_16 = _mm_packus_epi32(_mm_and_si128(in, v_7fffffff),
  364|  5.71k|                                     _mm_and_si128(nextin, v_7fffffff));
  365|       |
  366|       |    // Try to apply UTF-16 => UTF-8 from ./sse_convert_utf16_to_utf8.cpp
  367|       |
  368|       |    // Check for ASCII fast path
  369|  5.71k|    if (_mm_testz_si128(in_16, v_ff80)) { // ASCII fast path!!!!
  ------------------
  |  Branch (369:9): [True: 1.55k, False: 4.16k]
  ------------------
  370|       |      // 1. pack the bytes
  371|       |      // obviously suboptimal.
  372|  1.55k|      const __m128i utf8_packed = _mm_packus_epi16(in_16, in_16);
  373|       |      // 2. store (16 bytes)
  374|  1.55k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  375|       |      // 3. adjust pointers
  376|  1.55k|      buf += 8;
  377|  1.55k|      utf8_output += 8;
  378|  1.55k|      continue;
  379|  1.55k|    }
  380|       |
  381|       |    // no bits set above 7th bit
  382|  4.16k|    const __m128i one_byte_bytemask =
  383|  4.16k|        _mm_cmpeq_epi16(_mm_and_si128(in_16, v_ff80), v_0000);
  384|  4.16k|    const uint16_t one_byte_bitmask =
  385|  4.16k|        static_cast<uint16_t>(_mm_movemask_epi8(one_byte_bytemask));
  386|       |
  387|       |    // no bits set above 11th bit
  388|  4.16k|    const __m128i one_or_two_bytes_bytemask =
  389|  4.16k|        _mm_cmpeq_epi16(_mm_and_si128(in_16, v_f800), v_0000);
  390|  4.16k|    const uint16_t one_or_two_bytes_bitmask =
  391|  4.16k|        static_cast<uint16_t>(_mm_movemask_epi8(one_or_two_bytes_bytemask));
  392|       |
  393|  4.16k|    if (one_or_two_bytes_bitmask == 0xffff) {
  ------------------
  |  Branch (393:9): [True: 2.36k, False: 1.80k]
  ------------------
  394|       |      // case: all code units either produce 1 or 2 UTF-8 bytes (at least one
  395|       |      // produces 2 bytes)
  396|       |      // 1. prepare 2-byte values
  397|       |      // input 16-bit word : [0000|0aaa|aabb|bbbb] x 8
  398|       |      // expected output   : [110a|aaaa|10bb|bbbb] x 8
  399|  2.36k|      const __m128i v_1f00 = _mm_set1_epi16((int16_t)0x1f00);
  400|  2.36k|      const __m128i v_003f = _mm_set1_epi16((int16_t)0x003f);
  401|       |
  402|       |      // t0 = [000a|aaaa|bbbb|bb00]
  403|  2.36k|      const __m128i t0 = _mm_slli_epi16(in_16, 2);
  404|       |      // t1 = [000a|aaaa|0000|0000]
  405|  2.36k|      const __m128i t1 = _mm_and_si128(t0, v_1f00);
  406|       |      // t2 = [0000|0000|00bb|bbbb]
  407|  2.36k|      const __m128i t2 = _mm_and_si128(in_16, v_003f);
  408|       |      // t3 = [000a|aaaa|00bb|bbbb]
  409|  2.36k|      const __m128i t3 = _mm_or_si128(t1, t2);
  410|       |      // t4 = [110a|aaaa|10bb|bbbb]
  411|  2.36k|      const __m128i t4 = _mm_or_si128(t3, v_c080);
  412|       |
  413|       |      // 2. merge ASCII and 2-byte codewords
  414|  2.36k|      const __m128i utf8_unpacked =
  415|  2.36k|          _mm_blendv_epi8(t4, in_16, one_byte_bytemask);
  416|       |
  417|       |      // 3. prepare bitmask for 8-bit lookup
  418|       |      //    one_byte_bitmask = hhggffeeddccbbaa -- the bits are doubled (h -
  419|       |      //    MSB, a - LSB)
  420|  2.36k|      const uint16_t m0 = one_byte_bitmask & 0x5555; // m0 = 0h0g0f0e0d0c0b0a
  421|  2.36k|      const uint16_t m1 =
  422|  2.36k|          static_cast<uint16_t>(m0 >> 7); // m1 = 00000000h0g0f0e0
  423|  2.36k|      const uint8_t m2 =
  424|  2.36k|          static_cast<uint8_t>((m0 | m1) & 0xff); // m2 =         hdgcfbea
  425|       |      // 4. pack the bytes
  426|  2.36k|      const uint8_t *row =
  427|  2.36k|          &simdutf::tables::utf16_to_utf8::pack_1_2_utf8_bytes[m2][0];
  428|  2.36k|      const __m128i shuffle = _mm_loadu_si128((__m128i *)(row + 1));
  429|  2.36k|      const __m128i utf8_packed = _mm_shuffle_epi8(utf8_unpacked, shuffle);
  430|       |
  431|       |      // 5. store bytes
  432|  2.36k|      _mm_storeu_si128((__m128i *)utf8_output, utf8_packed);
  433|       |
  434|       |      // 6. adjust pointers
  435|  2.36k|      buf += 8;
  436|  2.36k|      utf8_output += row[0];
  437|  2.36k|      continue;
  438|  2.36k|    }
  439|       |
  440|       |    // Check for overflow in packing
  441|  1.80k|    const __m128i saturation_bytemask = _mm_cmpeq_epi32(
  442|  1.80k|        _mm_and_si128(_mm_or_si128(in, nextin), v_ffff0000), v_0000);
  443|  1.80k|    const uint32_t saturation_bitmask =
  444|  1.80k|        static_cast<uint32_t>(_mm_movemask_epi8(saturation_bytemask));
  445|       |
  446|  1.80k|    if (saturation_bitmask == 0xffff) {
  ------------------
  |  Branch (446:9): [True: 1.00k, False: 800]
  ------------------
  447|       |      // case: code units from register produce either 1, 2 or 3 UTF-8 bytes
  448|       |
  449|       |      // Check for illegal surrogate code units
  450|  1.00k|      const __m128i v_d800 = _mm_set1_epi16((uint16_t)0xd800);
  451|  1.00k|      const __m128i forbidden_bytemask =
  452|  1.00k|          _mm_cmpeq_epi16(_mm_and_si128(in_16, v_f800), v_d800);
  453|  1.00k|      if (static_cast<uint32_t>(_mm_movemask_epi8(forbidden_bytemask)) != 0) {
  ------------------
  |  Branch (453:11): [True: 32, False: 974]
  ------------------
  454|     32|        return std::make_pair(result(error_code::SURROGATE, buf - start),
  455|     32|                              utf8_output);
  456|     32|      }
  457|       |
  458|    974|      const __m128i dup_even = _mm_setr_epi16(0x0000, 0x0202, 0x0404, 0x0606,
  459|    974|                                              0x0808, 0x0a0a, 0x0c0c, 0x0e0e);
  460|       |
  461|       |      /* In this branch we handle three cases:
  462|       |          1. [0000|0000|0ccc|cccc] => [0ccc|cccc]                           -
  463|       |        single UFT-8 byte
  464|       |          2. [0000|0bbb|bbcc|cccc] => [110b|bbbb], [10cc|cccc]              -
  465|       |        two UTF-8 bytes
  466|       |          3. [aaaa|bbbb|bbcc|cccc] => [1110|aaaa], [10bb|bbbb], [10cc|cccc] -
  467|       |        three UTF-8 bytes
  468|       |
  469|       |        We expand the input word (16-bit) into two code units (32-bit), thus
  470|       |        we have room for four bytes. However, we need five distinct bit
  471|       |        layouts. Note that the last byte in cases #2 and #3 is the same.
  472|       |
  473|       |        We precompute byte 1 for case #1 and the common byte for cases #2 & #3
  474|       |        in register t2.
  475|       |
  476|       |        We precompute byte 1 for case #3 and -- **conditionally** -- precompute
  477|       |        either byte 1 for case #2 or byte 2 for case #3. Note that they
  478|       |        differ by exactly one bit.
  479|       |
  480|       |        Finally from these two code units we build proper UTF-8 sequence, taking
  481|       |        into account the case (i.e, the number of bytes to write).
  482|       |      */
  483|       |      /**
  484|       |       * Given [aaaa|bbbb|bbcc|cccc] our goal is to produce:
  485|       |       * t2 => [0ccc|cccc] [10cc|cccc]
  486|       |       * s4 => [1110|aaaa] ([110b|bbbb] OR [10bb|bbbb])
  487|       |       */
  488|    974|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  489|       |      // [aaaa|bbbb|bbcc|cccc] => [bbcc|cccc|bbcc|cccc]
  490|    974|      const __m128i t0 = _mm_shuffle_epi8(in_16, dup_even);
  491|       |      // [bbcc|cccc|bbcc|cccc] => [00cc|cccc|0bcc|cccc]
  492|    974|      const __m128i t1 = _mm_and_si128(t0, simdutf_vec(0b0011111101111111));
  ------------------
  |  |  488|    974|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  493|       |      // [00cc|cccc|0bcc|cccc] => [10cc|cccc|0bcc|cccc]
  494|    974|      const __m128i t2 = _mm_or_si128(t1, simdutf_vec(0b1000000000000000));
  ------------------
  |  |  488|    974|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  495|       |
  496|       |      // [aaaa|bbbb|bbcc|cccc] =>  [0000|aaaa|bbbb|bbcc]
  497|    974|      const __m128i s0 = _mm_srli_epi16(in_16, 4);
  498|       |      // [0000|aaaa|bbbb|bbcc] => [0000|aaaa|bbbb|bb00]
  499|    974|      const __m128i s1 = _mm_and_si128(s0, simdutf_vec(0b0000111111111100));
  ------------------
  |  |  488|    974|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  500|       |      // [0000|aaaa|bbbb|bb00] => [00bb|bbbb|0000|aaaa]
  501|    974|      const __m128i s2 = _mm_maddubs_epi16(s1, simdutf_vec(0x0140));
  ------------------
  |  |  488|    974|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  502|       |      // [00bb|bbbb|0000|aaaa] => [11bb|bbbb|1110|aaaa]
  503|    974|      const __m128i s3 = _mm_or_si128(s2, simdutf_vec(0b1100000011100000));
  ------------------
  |  |  488|    974|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  504|    974|      const __m128i m0 = _mm_andnot_si128(one_or_two_bytes_bytemask,
  505|    974|                                          simdutf_vec(0b0100000000000000));
  ------------------
  |  |  488|    974|#define simdutf_vec(x) _mm_set1_epi16(static_cast<uint16_t>(x))
  ------------------
  506|    974|      const __m128i s4 = _mm_xor_si128(s3, m0);
  507|    974|#undef simdutf_vec
  508|       |
  509|       |      // 4. expand code units 16-bit => 32-bit
  510|    974|      const __m128i out0 = _mm_unpacklo_epi16(t2, s4);
  511|    974|      const __m128i out1 = _mm_unpackhi_epi16(t2, s4);
  512|       |
  513|       |      // 5. compress 32-bit code units into 1, 2 or 3 bytes -- 2 x shuffle
  514|    974|      const uint16_t mask =
  515|    974|          (one_byte_bitmask & 0x5555) | (one_or_two_bytes_bitmask & 0xaaaa);
  516|    974|      if (mask == 0) {
  ------------------
  |  Branch (516:11): [True: 448, False: 526]
  ------------------
  517|       |        // We only have three-byte code units. Use fast path.
  518|    448|        const __m128i shuffle = _mm_setr_epi8(2, 3, 1, 6, 7, 5, 10, 11, 9, 14,
  519|    448|                                              15, 13, -1, -1, -1, -1);
  520|    448|        const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle);
  521|    448|        const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle);
  522|    448|        _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  523|    448|        utf8_output += 12;
  524|    448|        _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  525|    448|        utf8_output += 12;
  526|    448|        buf += 8;
  527|    448|        continue;
  528|    448|      }
  529|    526|      const uint8_t mask0 = uint8_t(mask);
  530|       |
  531|    526|      const uint8_t *row0 =
  532|    526|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask0][0];
  533|    526|      const __m128i shuffle0 = _mm_loadu_si128((__m128i *)(row0 + 1));
  534|    526|      const __m128i utf8_0 = _mm_shuffle_epi8(out0, shuffle0);
  535|       |
  536|    526|      const uint8_t mask1 = static_cast<uint8_t>(mask >> 8);
  537|       |
  538|    526|      const uint8_t *row1 =
  539|    526|          &simdutf::tables::utf16_to_utf8::pack_1_2_3_utf8_bytes[mask1][0];
  540|    526|      const __m128i shuffle1 = _mm_loadu_si128((__m128i *)(row1 + 1));
  541|    526|      const __m128i utf8_1 = _mm_shuffle_epi8(out1, shuffle1);
  542|       |
  543|    526|      _mm_storeu_si128((__m128i *)utf8_output, utf8_0);
  544|    526|      utf8_output += row0[0];
  545|    526|      _mm_storeu_si128((__m128i *)utf8_output, utf8_1);
  546|    526|      utf8_output += row1[0];
  547|       |
  548|    526|      buf += 8;
  549|    800|    } else {
  550|       |      // case: at least one 32-bit word produce a surrogate pair in UTF-16 <=>
  551|       |      // will produce four UTF-8 bytes Let us do a scalar fallback. It may seem
  552|       |      // wasteful to use scalar code, but being efficient with SIMD in the
  553|       |      // presence of surrogate pairs may require non-trivial tables.
  554|    800|      size_t forward = 15;
  555|    800|      size_t k = 0;
  556|    800|      if (size_t(end - buf) < forward + 1) {
  ------------------
  |  Branch (556:11): [True: 0, False: 800]
  ------------------
  557|      0|        forward = size_t(end - buf - 1);
  558|      0|      }
  559|  12.4k|      for (; k < forward; k++) {
  ------------------
  |  Branch (559:14): [True: 11.6k, False: 722]
  ------------------
  560|  11.6k|        uint32_t word = buf[k];
  561|  11.6k|        if ((word & 0xFFFFFF80) == 0) {
  ------------------
  |  Branch (561:13): [True: 3.35k, False: 8.33k]
  ------------------
  562|  3.35k|          *utf8_output++ = char(word);
  563|  8.33k|        } else if ((word & 0xFFFFF800) == 0) {
  ------------------
  |  Branch (563:20): [True: 1.07k, False: 7.26k]
  ------------------
  564|  1.07k|          *utf8_output++ = char((word >> 6) | 0b11000000);
  565|  1.07k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  566|  7.26k|        } else if ((word & 0xFFFF0000) == 0) {
  ------------------
  |  Branch (566:20): [True: 1.92k, False: 5.34k]
  ------------------
  567|  1.92k|          if (word >= 0xD800 && word <= 0xDFFF) {
  ------------------
  |  Branch (567:15): [True: 950, False: 970]
  |  Branch (567:33): [True: 16, False: 934]
  ------------------
  568|     16|            return std::make_pair(
  569|     16|                result(error_code::SURROGATE, buf - start + k), utf8_output);
  570|     16|          }
  571|  1.90k|          *utf8_output++ = char((word >> 12) | 0b11100000);
  572|  1.90k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  573|  1.90k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  574|  5.34k|        } else {
  575|  5.34k|          if (word > 0x10FFFF) {
  ------------------
  |  Branch (575:15): [True: 62, False: 5.28k]
  ------------------
  576|     62|            return std::make_pair(
  577|     62|                result(error_code::TOO_LARGE, buf - start + k), utf8_output);
  578|     62|          }
  579|  5.28k|          *utf8_output++ = char((word >> 18) | 0b11110000);
  580|  5.28k|          *utf8_output++ = char(((word >> 12) & 0b111111) | 0b10000000);
  581|  5.28k|          *utf8_output++ = char(((word >> 6) & 0b111111) | 0b10000000);
  582|  5.28k|          *utf8_output++ = char((word & 0b111111) | 0b10000000);
  583|  5.28k|        }
  584|  11.6k|      }
  585|    722|      buf += k;
  586|    722|    }
  587|  1.80k|  } // while
  588|    636|  return std::make_pair(result(error_code::SUCCESS, buf - start), utf8_output);
  589|    772|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_134convert_1_2_byte_utf8_to_latin1_16EPKctPc:
    4|   118k|    const char *input, uint16_t leading_mask, char *latin1_output) {
    5|   118k|  const __m128i in = _mm_loadu_si128(reinterpret_cast<const __m128i *>(input));
    6|   118k|  const __m128i next =
    7|   118k|      _mm_loadu_si128(reinterpret_cast<const __m128i *>(input + 1));
    8|   118k|  const __m128i combined = _mm_or_si128(
    9|   118k|      _mm_and_si128(_mm_slli_epi16(in, 6), _mm_set1_epi8(char(0xc0))),
   10|   118k|      _mm_and_si128(next, _mm_set1_epi8(0x3f)));
   11|   118k|  const __m128i value =
   12|   118k|      _mm_blendv_epi8(in, combined, _mm_and_si128(in, _mm_add_epi8(in, in)));
   13|   118k|  const uint8_t lo = uint8_t(leading_mask);
   14|   118k|  const uint8_t hi = uint8_t(leading_mask >> 8);
   15|   118k|  const __m128i shuffle = _mm_set_epi64x(
   16|   118k|      int64_t(tables::utf8_to_latin1::pack_8[hi] + 0x0808080808080808),
   17|   118k|      int64_t(tables::utf8_to_latin1::pack_8[lo]));
   18|   118k|  const __m128i packed = _mm_shuffle_epi8(value, shuffle);
   19|   118k|  const size_t lo_count = count_ones(lo);
   20|   118k|  _mm_storel_epi64(reinterpret_cast<__m128i *>(latin1_output), packed);
   21|   118k|  _mm_storel_epi64(reinterpret_cast<__m128i *>(latin1_output + lo_count),
   22|   118k|                   _mm_unpackhi_epi64(packed, packed));
   23|   118k|  return lo_count + count_ones(hi);
   24|   118k|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_128convert_masked_utf8_to_utf16ILNS_10endiannessE0EEEmPKcmRPDs:
   10|  2.28M|                                    char16_t *&utf16_output) {
   11|       |  // we use an approach where we try to process up to 12 input bytes.
   12|       |  // Why 12 input bytes and not 16? Because we are concerned with the size of
   13|       |  // the lookup tables. Also 12 is nicely divisible by two and three.
   14|       |  //
   15|       |  //
   16|       |  // Optimization note: our main path below is load-latency dependent. Thus it
   17|       |  // is maybe beneficial to have fast paths that depend on branch prediction but
   18|       |  // have less latency. This results in more instructions but, potentially, also
   19|       |  // higher speeds.
   20|       |  //
   21|       |  // We first try a few fast paths.
   22|  2.28M|  const __m128i swap =
   23|  2.28M|      _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   24|  2.28M|  const __m128i in = _mm_loadu_si128((__m128i *)input);
   25|  2.28M|  const uint16_t input_utf8_end_of_code_point_mask =
   26|  2.28M|      utf8_end_of_code_point_mask & 0xfff;
   27|  2.28M|  if ((utf8_end_of_code_point_mask & 0xfff) == 0xfff) {
  ------------------
  |  Branch (27:7): [True: 1.06M, False: 1.22M]
  ------------------
   28|       |    // We process the data in chunks of 12 bytes.
   29|       |    // Note: using 16 bytes is unsafe, see issue_ossfuzz_71218
   30|  1.06M|    __m128i ascii_first = _mm_cvtepu8_epi16(in);
   31|  1.06M|    __m128i ascii_second = _mm_cvtepu8_epi16(_mm_srli_si128(in, 8));
   32|  1.06M|    if (big_endian) {
  ------------------
  |  Branch (32:9): [Folded, False: 1.06M]
  ------------------
   33|      0|      ascii_first = _mm_shuffle_epi8(ascii_first, swap);
   34|      0|      ascii_second = _mm_shuffle_epi8(ascii_second, swap);
   35|      0|    }
   36|  1.06M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf16_output), ascii_first);
   37|  1.06M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf16_output + 8),
   38|  1.06M|                     ascii_second);
   39|  1.06M|    utf16_output += 12; // We wrote 12 16-bit characters.
   40|  1.06M|    return 12;          // We consumed 12 bytes.
   41|  1.06M|  }
   42|  1.22M|  if (((utf8_end_of_code_point_mask & 0xFFFF) == 0xaaaa)) {
  ------------------
  |  Branch (42:7): [True: 6.83k, False: 1.21M]
  ------------------
   43|       |    // We want to take 8 2-byte UTF-8 code units and turn them into 8 2-byte
   44|       |    // UTF-16 code units. There is probably a more efficient sequence, but the
   45|       |    // following might do.
   46|  6.83k|    const __m128i sh =
   47|  6.83k|        _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   48|  6.83k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   49|  6.83k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   50|  6.83k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   51|  6.83k|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   52|  6.83k|    if (big_endian)
  ------------------
  |  Branch (52:9): [Folded, False: 6.83k]
  ------------------
   53|      0|      composed = _mm_shuffle_epi8(composed, swap);
   54|  6.83k|    _mm_storeu_si128((__m128i *)utf16_output, composed);
   55|  6.83k|    utf16_output += 8; // We wrote 16 bytes, 8 code points.
   56|  6.83k|    return 16;
   57|  6.83k|  }
   58|  1.21M|  if (input_utf8_end_of_code_point_mask == 0x924) {
  ------------------
  |  Branch (58:7): [True: 2.60k, False: 1.21M]
  ------------------
   59|       |    // We want to take 4 3-byte UTF-8 code units and turn them into 4 2-byte
   60|       |    // UTF-16 code units. There is probably a more efficient sequence, but the
   61|       |    // following might do.
   62|  2.60k|    const __m128i sh =
   63|  2.60k|        _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1);
   64|  2.60k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   65|  2.60k|    const __m128i ascii =
   66|  2.60k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
   67|  2.60k|    const __m128i middlebyte =
   68|  2.60k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
   69|  2.60k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
   70|  2.60k|    const __m128i highbyte =
   71|  2.60k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
   72|  2.60k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
   73|  2.60k|    const __m128i composed =
   74|  2.60k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
   75|  2.60k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
   76|  2.60k|    if (big_endian)
  ------------------
  |  Branch (76:9): [Folded, False: 2.60k]
  ------------------
   77|      0|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
   78|  2.60k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
   79|  2.60k|    utf16_output += 4;
   80|  2.60k|    return 12;
   81|  2.60k|  }
   82|       |  /// We do not have a fast path available, so we fallback.
   83|       |
   84|  1.21M|  const uint8_t idx =
   85|  1.21M|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0];
   86|  1.21M|  const uint8_t consumed =
   87|  1.21M|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1];
   88|  1.21M|  if (idx < 64) {
  ------------------
  |  Branch (88:7): [True: 710k, False: 501k]
  ------------------
   89|       |    // SIX (6) input code-code units
   90|       |    // this is a relatively easy scenario
   91|       |    // we process SIX (6) input code-code units. The max length in bytes of six
   92|       |    // code code units spanning between 1 and 2 bytes each is 12 bytes. On
   93|       |    // processors where pdep/pext is fast, we might be able to use a small
   94|       |    // lookup table.
   95|   710k|    const __m128i sh =
   96|   710k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
   97|   710k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   98|   710k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   99|   710k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
  100|   710k|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
  101|   710k|    if (big_endian)
  ------------------
  |  Branch (101:9): [Folded, False: 710k]
  ------------------
  102|      0|      composed = _mm_shuffle_epi8(composed, swap);
  103|   710k|    _mm_storeu_si128((__m128i *)utf16_output, composed);
  104|   710k|    utf16_output += 6; // We wrote 12 bytes, 6 code points.
  105|   710k|  } else if (idx < 145) {
  ------------------
  |  Branch (105:14): [True: 447k, False: 54.0k]
  ------------------
  106|       |    // FOUR (4) input code-code units
  107|   447k|    const __m128i sh =
  108|   447k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
  109|   447k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  110|   447k|    const __m128i ascii =
  111|   447k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
  112|   447k|    const __m128i middlebyte =
  113|   447k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
  114|   447k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  115|   447k|    const __m128i highbyte =
  116|   447k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
  117|   447k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
  118|   447k|    const __m128i composed =
  119|   447k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
  120|   447k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
  121|   447k|    if (big_endian)
  ------------------
  |  Branch (121:9): [Folded, False: 447k]
  ------------------
  122|      0|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
  123|   447k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
  124|   447k|    utf16_output += 4;
  125|   447k|  } else if (idx < 209) {
  ------------------
  |  Branch (125:14): [True: 53.7k, False: 248]
  ------------------
  126|       |    // TWO (2) input code-code units
  127|       |    //////////////
  128|       |    // There might be garbage inputs where a leading byte mascarades as a
  129|       |    // four-byte leading byte (by being followed by 3 continuation byte), but is
  130|       |    // not greater than 0xf0. This could trigger a buffer overflow if we only
  131|       |    // counted leading bytes of the form 0xf0 as generating surrogate pairs,
  132|       |    // without further UTF-8 validation. Thus we must be careful to ensure that
  133|       |    // only leading bytes at least as large as 0xf0 generate surrogate pairs. We
  134|       |    // do as at the cost of an extra mask.
  135|       |    /////////////
  136|  53.7k|    const __m128i sh =
  137|  53.7k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
  138|  53.7k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  139|  53.7k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f));
  140|  53.7k|    const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00));
  141|  53.7k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  142|  53.7k|    __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000));
  143|       |    // correct for spurious high bit
  144|  53.7k|    const __m128i correct =
  145|  53.7k|        _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1);
  146|  53.7k|    middlehighbyte = _mm_xor_si128(correct, middlehighbyte);
  147|  53.7k|    const __m128i middlehighbyte_shifted = _mm_srli_epi32(middlehighbyte, 4);
  148|       |    // We deliberately carry the leading four bits in highbyte if they are
  149|       |    // present, we remove them later when computing hightenbits.
  150|  53.7k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0xff000000));
  151|  53.7k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 6);
  152|       |    // When we need to generate a surrogate pair (leading byte > 0xF0), then
  153|       |    // the corresponding 32-bit value in 'composed'  will be greater than
  154|       |    // > (0xff00000>>6) or > 0x3c00000. This can be used later to identify the
  155|       |    // location of the surrogate pairs.
  156|  53.7k|    const __m128i composed =
  157|  53.7k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted),
  158|  53.7k|                     _mm_or_si128(highbyte_shifted, middlehighbyte_shifted));
  159|  53.7k|    const __m128i composedminus =
  160|  53.7k|        _mm_sub_epi32(composed, _mm_set1_epi32(0x10000));
  161|  53.7k|    const __m128i lowtenbits =
  162|  53.7k|        _mm_and_si128(composedminus, _mm_set1_epi32(0x3ff));
  163|       |    // Notice the 0x3ff mask:
  164|  53.7k|    const __m128i hightenbits =
  165|  53.7k|        _mm_and_si128(_mm_srli_epi32(composedminus, 10), _mm_set1_epi32(0x3ff));
  166|  53.7k|    const __m128i lowtenbitsadd =
  167|  53.7k|        _mm_add_epi32(lowtenbits, _mm_set1_epi32(0xDC00));
  168|  53.7k|    const __m128i hightenbitsadd =
  169|  53.7k|        _mm_add_epi32(hightenbits, _mm_set1_epi32(0xD800));
  170|  53.7k|    const __m128i lowtenbitsaddshifted = _mm_slli_epi32(lowtenbitsadd, 16);
  171|  53.7k|    __m128i surrogates = _mm_or_si128(hightenbitsadd, lowtenbitsaddshifted);
  172|  53.7k|    uint32_t basic_buffer[4];
  173|  53.7k|    uint32_t basic_buffer_swap[4];
  174|  53.7k|    if (big_endian) {
  ------------------
  |  Branch (174:9): [Folded, False: 53.7k]
  ------------------
  175|      0|      _mm_storeu_si128((__m128i *)basic_buffer_swap,
  176|      0|                       _mm_shuffle_epi8(composed, swap));
  177|      0|      surrogates = _mm_shuffle_epi8(surrogates, swap);
  178|      0|    }
  179|  53.7k|    _mm_storeu_si128((__m128i *)basic_buffer, composed);
  180|  53.7k|    uint32_t surrogate_buffer[4];
  181|  53.7k|    _mm_storeu_si128((__m128i *)surrogate_buffer, surrogates);
  182|   215k|    for (size_t i = 0; i < 3; i++) {
  ------------------
  |  Branch (182:24): [True: 161k, False: 53.7k]
  ------------------
  183|   161k|      if (basic_buffer[i] > 0x3c00000) {
  ------------------
  |  Branch (183:11): [True: 45.3k, False: 116k]
  ------------------
  184|  45.3k|        utf16_output[0] = uint16_t(surrogate_buffer[i] & 0xffff);
  185|  45.3k|        utf16_output[1] = uint16_t(surrogate_buffer[i] >> 16);
  186|  45.3k|        utf16_output += 2;
  187|   116k|      } else {
  188|   116k|        utf16_output[0] = big_endian ? uint16_t(basic_buffer_swap[i])
  ------------------
  |  Branch (188:27): [Folded, False: 116k]
  ------------------
  189|   116k|                                     : uint16_t(basic_buffer[i]);
  190|   116k|        utf16_output++;
  191|   116k|      }
  192|   161k|    }
  193|  53.7k|  } else {
  194|       |    // here we know that there is an error but we do not handle errors
  195|    248|  }
  196|  1.21M|  return consumed;
  197|  1.21M|}
simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_128convert_masked_utf8_to_utf16ILNS_10endiannessE1EEEmPKcmRPDs:
   10|  2.46M|                                    char16_t *&utf16_output) {
   11|       |  // we use an approach where we try to process up to 12 input bytes.
   12|       |  // Why 12 input bytes and not 16? Because we are concerned with the size of
   13|       |  // the lookup tables. Also 12 is nicely divisible by two and three.
   14|       |  //
   15|       |  //
   16|       |  // Optimization note: our main path below is load-latency dependent. Thus it
   17|       |  // is maybe beneficial to have fast paths that depend on branch prediction but
   18|       |  // have less latency. This results in more instructions but, potentially, also
   19|       |  // higher speeds.
   20|       |  //
   21|       |  // We first try a few fast paths.
   22|  2.46M|  const __m128i swap =
   23|  2.46M|      _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   24|  2.46M|  const __m128i in = _mm_loadu_si128((__m128i *)input);
   25|  2.46M|  const uint16_t input_utf8_end_of_code_point_mask =
   26|  2.46M|      utf8_end_of_code_point_mask & 0xfff;
   27|  2.46M|  if ((utf8_end_of_code_point_mask & 0xfff) == 0xfff) {
  ------------------
  |  Branch (27:7): [True: 1.16M, False: 1.30M]
  ------------------
   28|       |    // We process the data in chunks of 12 bytes.
   29|       |    // Note: using 16 bytes is unsafe, see issue_ossfuzz_71218
   30|  1.16M|    __m128i ascii_first = _mm_cvtepu8_epi16(in);
   31|  1.16M|    __m128i ascii_second = _mm_cvtepu8_epi16(_mm_srli_si128(in, 8));
   32|  1.16M|    if (big_endian) {
  ------------------
  |  Branch (32:9): [True: 1.16M, Folded]
  ------------------
   33|  1.16M|      ascii_first = _mm_shuffle_epi8(ascii_first, swap);
   34|  1.16M|      ascii_second = _mm_shuffle_epi8(ascii_second, swap);
   35|  1.16M|    }
   36|  1.16M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf16_output), ascii_first);
   37|  1.16M|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf16_output + 8),
   38|  1.16M|                     ascii_second);
   39|  1.16M|    utf16_output += 12; // We wrote 12 16-bit characters.
   40|  1.16M|    return 12;          // We consumed 12 bytes.
   41|  1.16M|  }
   42|  1.30M|  if (((utf8_end_of_code_point_mask & 0xFFFF) == 0xaaaa)) {
  ------------------
  |  Branch (42:7): [True: 16.3k, False: 1.28M]
  ------------------
   43|       |    // We want to take 8 2-byte UTF-8 code units and turn them into 8 2-byte
   44|       |    // UTF-16 code units. There is probably a more efficient sequence, but the
   45|       |    // following might do.
   46|  16.3k|    const __m128i sh =
   47|  16.3k|        _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   48|  16.3k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   49|  16.3k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   50|  16.3k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   51|  16.3k|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   52|  16.3k|    if (big_endian)
  ------------------
  |  Branch (52:9): [True: 16.3k, Folded]
  ------------------
   53|  16.3k|      composed = _mm_shuffle_epi8(composed, swap);
   54|  16.3k|    _mm_storeu_si128((__m128i *)utf16_output, composed);
   55|  16.3k|    utf16_output += 8; // We wrote 16 bytes, 8 code points.
   56|  16.3k|    return 16;
   57|  16.3k|  }
   58|  1.28M|  if (input_utf8_end_of_code_point_mask == 0x924) {
  ------------------
  |  Branch (58:7): [True: 10.3k, False: 1.27M]
  ------------------
   59|       |    // We want to take 4 3-byte UTF-8 code units and turn them into 4 2-byte
   60|       |    // UTF-16 code units. There is probably a more efficient sequence, but the
   61|       |    // following might do.
   62|  10.3k|    const __m128i sh =
   63|  10.3k|        _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1);
   64|  10.3k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   65|  10.3k|    const __m128i ascii =
   66|  10.3k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
   67|  10.3k|    const __m128i middlebyte =
   68|  10.3k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
   69|  10.3k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
   70|  10.3k|    const __m128i highbyte =
   71|  10.3k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
   72|  10.3k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
   73|  10.3k|    const __m128i composed =
   74|  10.3k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
   75|  10.3k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
   76|  10.3k|    if (big_endian)
  ------------------
  |  Branch (76:9): [True: 10.3k, Folded]
  ------------------
   77|  10.3k|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
   78|  10.3k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
   79|  10.3k|    utf16_output += 4;
   80|  10.3k|    return 12;
   81|  10.3k|  }
   82|       |  /// We do not have a fast path available, so we fallback.
   83|       |
   84|  1.27M|  const uint8_t idx =
   85|  1.27M|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0];
   86|  1.27M|  const uint8_t consumed =
   87|  1.27M|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1];
   88|  1.27M|  if (idx < 64) {
  ------------------
  |  Branch (88:7): [True: 774k, False: 500k]
  ------------------
   89|       |    // SIX (6) input code-code units
   90|       |    // this is a relatively easy scenario
   91|       |    // we process SIX (6) input code-code units. The max length in bytes of six
   92|       |    // code code units spanning between 1 and 2 bytes each is 12 bytes. On
   93|       |    // processors where pdep/pext is fast, we might be able to use a small
   94|       |    // lookup table.
   95|   774k|    const __m128i sh =
   96|   774k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
   97|   774k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   98|   774k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   99|   774k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
  100|   774k|    __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
  101|   774k|    if (big_endian)
  ------------------
  |  Branch (101:9): [True: 774k, Folded]
  ------------------
  102|   774k|      composed = _mm_shuffle_epi8(composed, swap);
  103|   774k|    _mm_storeu_si128((__m128i *)utf16_output, composed);
  104|   774k|    utf16_output += 6; // We wrote 12 bytes, 6 code points.
  105|   774k|  } else if (idx < 145) {
  ------------------
  |  Branch (105:14): [True: 415k, False: 85.1k]
  ------------------
  106|       |    // FOUR (4) input code-code units
  107|   415k|    const __m128i sh =
  108|   415k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
  109|   415k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  110|   415k|    const __m128i ascii =
  111|   415k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
  112|   415k|    const __m128i middlebyte =
  113|   415k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
  114|   415k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  115|   415k|    const __m128i highbyte =
  116|   415k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
  117|   415k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
  118|   415k|    const __m128i composed =
  119|   415k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
  120|   415k|    __m128i composed_repacked = _mm_packus_epi32(composed, composed);
  121|   415k|    if (big_endian)
  ------------------
  |  Branch (121:9): [True: 415k, Folded]
  ------------------
  122|   415k|      composed_repacked = _mm_shuffle_epi8(composed_repacked, swap);
  123|   415k|    _mm_storeu_si128((__m128i *)utf16_output, composed_repacked);
  124|   415k|    utf16_output += 4;
  125|   415k|  } else if (idx < 209) {
  ------------------
  |  Branch (125:14): [True: 84.8k, False: 342]
  ------------------
  126|       |    // TWO (2) input code-code units
  127|       |    //////////////
  128|       |    // There might be garbage inputs where a leading byte mascarades as a
  129|       |    // four-byte leading byte (by being followed by 3 continuation byte), but is
  130|       |    // not greater than 0xf0. This could trigger a buffer overflow if we only
  131|       |    // counted leading bytes of the form 0xf0 as generating surrogate pairs,
  132|       |    // without further UTF-8 validation. Thus we must be careful to ensure that
  133|       |    // only leading bytes at least as large as 0xf0 generate surrogate pairs. We
  134|       |    // do as at the cost of an extra mask.
  135|       |    /////////////
  136|  84.8k|    const __m128i sh =
  137|  84.8k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
  138|  84.8k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  139|  84.8k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f));
  140|  84.8k|    const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00));
  141|  84.8k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  142|  84.8k|    __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000));
  143|       |    // correct for spurious high bit
  144|  84.8k|    const __m128i correct =
  145|  84.8k|        _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1);
  146|  84.8k|    middlehighbyte = _mm_xor_si128(correct, middlehighbyte);
  147|  84.8k|    const __m128i middlehighbyte_shifted = _mm_srli_epi32(middlehighbyte, 4);
  148|       |    // We deliberately carry the leading four bits in highbyte if they are
  149|       |    // present, we remove them later when computing hightenbits.
  150|  84.8k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0xff000000));
  151|  84.8k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 6);
  152|       |    // When we need to generate a surrogate pair (leading byte > 0xF0), then
  153|       |    // the corresponding 32-bit value in 'composed'  will be greater than
  154|       |    // > (0xff00000>>6) or > 0x3c00000. This can be used later to identify the
  155|       |    // location of the surrogate pairs.
  156|  84.8k|    const __m128i composed =
  157|  84.8k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted),
  158|  84.8k|                     _mm_or_si128(highbyte_shifted, middlehighbyte_shifted));
  159|  84.8k|    const __m128i composedminus =
  160|  84.8k|        _mm_sub_epi32(composed, _mm_set1_epi32(0x10000));
  161|  84.8k|    const __m128i lowtenbits =
  162|  84.8k|        _mm_and_si128(composedminus, _mm_set1_epi32(0x3ff));
  163|       |    // Notice the 0x3ff mask:
  164|  84.8k|    const __m128i hightenbits =
  165|  84.8k|        _mm_and_si128(_mm_srli_epi32(composedminus, 10), _mm_set1_epi32(0x3ff));
  166|  84.8k|    const __m128i lowtenbitsadd =
  167|  84.8k|        _mm_add_epi32(lowtenbits, _mm_set1_epi32(0xDC00));
  168|  84.8k|    const __m128i hightenbitsadd =
  169|  84.8k|        _mm_add_epi32(hightenbits, _mm_set1_epi32(0xD800));
  170|  84.8k|    const __m128i lowtenbitsaddshifted = _mm_slli_epi32(lowtenbitsadd, 16);
  171|  84.8k|    __m128i surrogates = _mm_or_si128(hightenbitsadd, lowtenbitsaddshifted);
  172|  84.8k|    uint32_t basic_buffer[4];
  173|  84.8k|    uint32_t basic_buffer_swap[4];
  174|  84.8k|    if (big_endian) {
  ------------------
  |  Branch (174:9): [True: 84.8k, Folded]
  ------------------
  175|  84.8k|      _mm_storeu_si128((__m128i *)basic_buffer_swap,
  176|  84.8k|                       _mm_shuffle_epi8(composed, swap));
  177|  84.8k|      surrogates = _mm_shuffle_epi8(surrogates, swap);
  178|  84.8k|    }
  179|  84.8k|    _mm_storeu_si128((__m128i *)basic_buffer, composed);
  180|  84.8k|    uint32_t surrogate_buffer[4];
  181|  84.8k|    _mm_storeu_si128((__m128i *)surrogate_buffer, surrogates);
  182|   339k|    for (size_t i = 0; i < 3; i++) {
  ------------------
  |  Branch (182:24): [True: 254k, False: 84.8k]
  ------------------
  183|   254k|      if (basic_buffer[i] > 0x3c00000) {
  ------------------
  |  Branch (183:11): [True: 71.3k, False: 183k]
  ------------------
  184|  71.3k|        utf16_output[0] = uint16_t(surrogate_buffer[i] & 0xffff);
  185|  71.3k|        utf16_output[1] = uint16_t(surrogate_buffer[i] >> 16);
  186|  71.3k|        utf16_output += 2;
  187|   183k|      } else {
  188|   183k|        utf16_output[0] = big_endian ? uint16_t(basic_buffer_swap[i])
  ------------------
  |  Branch (188:27): [True: 183k, Folded]
  ------------------
  189|   183k|                                     : uint16_t(basic_buffer[i]);
  190|   183k|        utf16_output++;
  191|   183k|      }
  192|   254k|    }
  193|  84.8k|  } else {
  194|       |    // here we know that there is an error but we do not handle errors
  195|    342|  }
  196|  1.27M|  return consumed;
  197|  1.28M|}

simdutf.cpp:_ZN7simdutf8westmere12_GLOBAL__N_128convert_masked_utf8_to_utf32EPKcmRPDi:
    9|  1.61M|                                    char32_t *&utf32_output) {
   10|       |  // we use an approach where we try to process up to 12 input bytes.
   11|       |  // Why 12 input bytes and not 16? Because we are concerned with the size of
   12|       |  // the lookup tables. Also 12 is nicely divisible by two and three.
   13|       |  //
   14|       |  //
   15|       |  // Optimization note: our main path below is load-latency dependent. Thus it
   16|       |  // is maybe beneficial to have fast paths that depend on branch prediction but
   17|       |  // have less latency. This results in more instructions but, potentially, also
   18|       |  // higher speeds.
   19|       |  //
   20|       |  // We first try a few fast paths.
   21|  1.61M|  const __m128i in = _mm_loadu_si128((__m128i *)input);
   22|  1.61M|  const uint16_t input_utf8_end_of_code_point_mask =
   23|  1.61M|      utf8_end_of_code_point_mask & 0xfff;
   24|  1.61M|  if ((utf8_end_of_code_point_mask & 0xfff) == 0xfff) {
  ------------------
  |  Branch (24:7): [True: 775k, False: 844k]
  ------------------
   25|       |    // We process the data in chunks of 12 bytes.
   26|   775k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output),
   27|   775k|                     _mm_cvtepu8_epi32(in));
   28|   775k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 4),
   29|   775k|                     _mm_cvtepu8_epi32(_mm_srli_si128(in, 4)));
   30|   775k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 8),
   31|   775k|                     _mm_cvtepu8_epi32(_mm_srli_si128(in, 8)));
   32|   775k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 12),
   33|   775k|                     _mm_cvtepu8_epi32(_mm_srli_si128(in, 12)));
   34|   775k|    utf32_output += 12; // We wrote 12 32-bit characters.
   35|   775k|    return 12;          // We consumed 12 bytes.
   36|   775k|  }
   37|   844k|  if (((utf8_end_of_code_point_mask & 0xffff) == 0xaaaa)) {
  ------------------
  |  Branch (37:7): [True: 16.2k, False: 827k]
  ------------------
   38|       |    // We want to take 8 2-byte UTF-8 code units and turn them into 8 4-byte
   39|       |    // UTF-32 code units. There is probably a more efficient sequence, but the
   40|       |    // following might do.
   41|  16.2k|    const __m128i sh =
   42|  16.2k|        _mm_setr_epi8(1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14);
   43|  16.2k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   44|  16.2k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   45|  16.2k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   46|  16.2k|    const __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   47|  16.2k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output),
   48|  16.2k|                     _mm_cvtepu16_epi32(composed));
   49|  16.2k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 4),
   50|  16.2k|                     _mm_cvtepu16_epi32(_mm_srli_si128(composed, 8)));
   51|  16.2k|    utf32_output += 8; // We wrote 32 bytes, 8 code points.
   52|  16.2k|    return 16;
   53|  16.2k|  }
   54|   827k|  if (input_utf8_end_of_code_point_mask == 0x924) {
  ------------------
  |  Branch (54:7): [True: 4.64k, False: 823k]
  ------------------
   55|       |    // We want to take 4 3-byte UTF-8 code units and turn them into 4 4-byte
   56|       |    // UTF-32 code units. There is probably a more efficient sequence, but the
   57|       |    // following might do.
   58|  4.64k|    const __m128i sh =
   59|  4.64k|        _mm_setr_epi8(2, 1, 0, -1, 5, 4, 3, -1, 8, 7, 6, -1, 11, 10, 9, -1);
   60|  4.64k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   61|  4.64k|    const __m128i ascii =
   62|  4.64k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
   63|  4.64k|    const __m128i middlebyte =
   64|  4.64k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
   65|  4.64k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
   66|  4.64k|    const __m128i highbyte =
   67|  4.64k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
   68|  4.64k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
   69|  4.64k|    const __m128i composed =
   70|  4.64k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
   71|  4.64k|    _mm_storeu_si128((__m128i *)utf32_output, composed);
   72|  4.64k|    utf32_output += 4;
   73|  4.64k|    return 12;
   74|  4.64k|  }
   75|       |  /// We do not have a fast path available, so we fallback.
   76|       |
   77|   823k|  const uint8_t idx =
   78|   823k|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][0];
   79|   823k|  const uint8_t consumed =
   80|   823k|      tables::utf8_to_utf16::utf8bigindex[input_utf8_end_of_code_point_mask][1];
   81|   823k|  if (idx < 64) {
  ------------------
  |  Branch (81:7): [True: 480k, False: 342k]
  ------------------
   82|       |    // SIX (6) input code-code units
   83|       |    // this is a relatively easy scenario
   84|       |    // we process SIX (6) input code-code units. The max length in bytes of six
   85|       |    // code code units spanning between 1 and 2 bytes each is 12 bytes. On
   86|       |    // processors where pdep/pext is fast, we might be able to use a small
   87|       |    // lookup table.
   88|   480k|    const __m128i sh =
   89|   480k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
   90|   480k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
   91|   480k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi16(0x7f));
   92|   480k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi16(0x1f00));
   93|   480k|    const __m128i composed = _mm_or_si128(ascii, _mm_srli_epi16(highbyte, 2));
   94|   480k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output),
   95|   480k|                     _mm_cvtepu16_epi32(composed));
   96|   480k|    _mm_storeu_si128(reinterpret_cast<__m128i *>(utf32_output + 4),
   97|   480k|                     _mm_cvtepu16_epi32(_mm_srli_si128(composed, 8)));
   98|   480k|    utf32_output += 6; // We wrote 12 bytes, 6 code points.
   99|   480k|  } else if (idx < 145) {
  ------------------
  |  Branch (99:14): [True: 263k, False: 78.6k]
  ------------------
  100|       |    // FOUR (4) input code-code units
  101|   263k|    const __m128i sh =
  102|   263k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
  103|   263k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  104|   263k|    const __m128i ascii =
  105|   263k|        _mm_and_si128(perm, _mm_set1_epi32(0x7f)); // 7 or 6 bits
  106|   263k|    const __m128i middlebyte =
  107|   263k|        _mm_and_si128(perm, _mm_set1_epi32(0x3f00)); // 5 or 6 bits
  108|   263k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  109|   263k|    const __m128i highbyte =
  110|   263k|        _mm_and_si128(perm, _mm_set1_epi32(0x0f0000)); // 4 bits
  111|   263k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 4);
  112|   263k|    const __m128i composed =
  113|   263k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted), highbyte_shifted);
  114|   263k|    _mm_storeu_si128((__m128i *)utf32_output, composed);
  115|   263k|    utf32_output += 4;
  116|   263k|  } else if (idx < 209) {
  ------------------
  |  Branch (116:14): [True: 78.3k, False: 278]
  ------------------
  117|       |    // TWO (2) input code-code units
  118|  78.3k|    const __m128i sh =
  119|  78.3k|        _mm_loadu_si128((const __m128i *)tables::utf8_to_utf16::shufutf8[idx]);
  120|  78.3k|    const __m128i perm = _mm_shuffle_epi8(in, sh);
  121|  78.3k|    const __m128i ascii = _mm_and_si128(perm, _mm_set1_epi32(0x7f));
  122|  78.3k|    const __m128i middlebyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f00));
  123|  78.3k|    const __m128i middlebyte_shifted = _mm_srli_epi32(middlebyte, 2);
  124|  78.3k|    __m128i middlehighbyte = _mm_and_si128(perm, _mm_set1_epi32(0x3f0000));
  125|       |    // correct for spurious high bit
  126|  78.3k|    const __m128i correct =
  127|  78.3k|        _mm_srli_epi32(_mm_and_si128(perm, _mm_set1_epi32(0x400000)), 1);
  128|  78.3k|    middlehighbyte = _mm_xor_si128(correct, middlehighbyte);
  129|  78.3k|    const __m128i middlehighbyte_shifted = _mm_srli_epi32(middlehighbyte, 4);
  130|  78.3k|    const __m128i highbyte = _mm_and_si128(perm, _mm_set1_epi32(0x07000000));
  131|  78.3k|    const __m128i highbyte_shifted = _mm_srli_epi32(highbyte, 6);
  132|  78.3k|    const __m128i composed =
  133|  78.3k|        _mm_or_si128(_mm_or_si128(ascii, middlebyte_shifted),
  134|  78.3k|                     _mm_or_si128(highbyte_shifted, middlehighbyte_shifted));
  135|  78.3k|    _mm_storeu_si128((__m128i *)utf32_output, composed);
  136|  78.3k|    utf32_output += 3;
  137|  78.3k|  } else {
  138|       |    // here we know that there is an error but we do not handle errors
  139|    278|  }
  140|   823k|  return consumed;
  141|   827k|}

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

